opennurbs_annotation.cpp
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #include "pcl/surface/3rdparty/opennurbs/opennurbs.h"
00018 
00019 ON_VIRTUAL_OBJECT_IMPLEMENT( ON_Annotation,       ON_Geometry,   "ABAF5873-4145-11d4-800F-0010830122F0" );
00020 ON_OBJECT_IMPLEMENT( ON_LinearDimension,  ON_Annotation, "5DE6B20D-486B-11d4-8014-0010830122F0" );
00021 ON_OBJECT_IMPLEMENT( ON_RadialDimension,  ON_Annotation, "5DE6B20E-486B-11d4-8014-0010830122F0" );
00022 ON_OBJECT_IMPLEMENT( ON_AngularDimension, ON_Annotation, "5DE6B20F-486B-11d4-8014-0010830122F0" );
00023 ON_OBJECT_IMPLEMENT( ON_TextEntity,       ON_Annotation, "5DE6B210-486B-11d4-8014-0010830122F0" );
00024 ON_OBJECT_IMPLEMENT( ON_Leader,           ON_Annotation, "5DE6B211-486B-11d4-8014-0010830122F0" );
00025 
00026 ON_BOOL32 ON_LinearDimension::IsRealObject() const {return true;}
00027 ON_BOOL32 ON_RadialDimension::IsRealObject() const {return true;}
00028 ON_BOOL32 ON_AngularDimension::IsRealObject() const {return true;}
00029 ON_BOOL32 ON_TextEntity::IsRealObject() const {return true;}
00030 ON_BOOL32 ON_Leader::IsRealObject() const {return true;}
00031 
00032 #define REALLY_BIG_NUMBER 1e150
00033 
00034 static const ON_3dmAnnotationSettings* sglb_asets = 0;
00035 
00036 void ON_Annotation::SetAnnotationSettings( const ON_3dmAnnotationSettings* p )
00037 {
00038   sglb_asets = p;
00039 }
00040 
00041 const ON_3dmAnnotationSettings& ON_Annotation::AnnotationSettings()
00042 {
00043   static ON_3dmAnnotationSettings defaults;
00044   return sglb_asets ? *sglb_asets : defaults;
00045 }
00046 
00047 void ON_Annotation::Create()
00048 {
00049   // TODO: initialize class members assuming any member that is not a class
00050   // is not initialized.
00051   m_type = ON::dtNothing;
00052   m_plane = ON_xy_plane;
00053   m_points.EmergencyDestroy();
00054   m_usertext.EmergencyDestroy();
00055   m_defaulttext.EmergencyDestroy();
00056   m_userpositionedtext = false;
00057 }
00058 
00059 void ON_Annotation::Destroy()
00060 {
00061   m_points.Destroy();
00062   m_usertext.Destroy();
00063   m_defaulttext.Destroy();
00064   m_type = ON::dtNothing;
00065   m_plane = ON_xy_plane;
00066   m_userpositionedtext = false;
00067 }
00068 
00069 void ON_Annotation::EmergencyDestroy()
00070 {
00071   m_points.EmergencyDestroy();
00072   m_usertext.EmergencyDestroy();
00073   m_defaulttext.EmergencyDestroy();
00074   m_type = ON::dtNothing;
00075   m_plane = ON_xy_plane;
00076   m_userpositionedtext = false;
00077 }
00078 
00079 ON_Annotation::ON_Annotation()
00080 {
00081   Create();
00082 }
00083 
00084 ON_Annotation::ON_Annotation(const ON_Annotation& src)
00085 {
00086   Create();
00087   *this = src;
00088 }
00089 
00090 ON_Annotation::~ON_Annotation()
00091 {
00092   Destroy();
00093 }
00094 
00095 
00096 bool ON_Annotation::IsText() const { return Type() == ON::dtTextBlock; }
00097 bool ON_Annotation::IsLeader() const { return Type() == ON::dtLeader; }
00098 bool ON_Annotation::IsDimension() const { if( IsText() || IsLeader()) return false; return true; }
00099 
00100 //virtual 
00101 double ON_Annotation::NumericValue() const { return 0.0; }
00102 //virtual 
00103 void ON_Annotation::SetTextToDefault() { SetDefaultText( L""); }
00104 
00105 void ON_Annotation::SetType( ON::eAnnotationType type ) { m_type = type; }
00106 ON::eAnnotationType ON_Annotation::Type() const { return m_type; }
00107 void ON_Annotation::SetTextDisplayMode( ON::eTextDisplayMode mode) { m_textdisplaymode = mode; }
00108 ON::eTextDisplayMode ON_Annotation::TextDisplayMode() const { return m_textdisplaymode; }
00109 
00110 void ON_Annotation::SetPlane( const ON_Plane& plane ) { m_plane = plane; }
00111 ON_Plane ON_Annotation::Plane() const { return m_plane; }
00112 int ON_Annotation::PointCount() const { return m_points.Count(); }
00113 void ON_Annotation::SetPoints( const ON_SimpleArray<ON_2dPoint>& points ) { m_points = points; }
00114 const ON_SimpleArray<ON_2dPoint>& ON_Annotation::Points() const { return m_points; }
00115 void ON_Annotation::SetUserText( const wchar_t* string ) {m_usertext = string; }
00116 const ON_wString& ON_Annotation::UserText() const { return m_usertext; }
00117 void ON_Annotation::SetDefaultText( const wchar_t* string ) { m_defaulttext = string; }
00118 const ON_wString& ON_Annotation::DefaultText() const { return m_defaulttext; }
00119 void ON_Annotation::SetUserPositionedText( int bUserPositionedText ) { m_userpositionedtext = (bUserPositionedText?true:false); }
00120 bool ON_Annotation::UserPositionedText() const { return m_userpositionedtext; }
00121 
00122 
00123 ON_Annotation& ON_Annotation::operator=(const ON_Annotation& src)
00124 {
00125   if ( this != &src ) {
00126     // get a clean and empty "this"
00127     Destroy();
00128     Create();
00129     ON_Geometry::operator=(src);
00130 
00131     // TODO: copy fields
00132     m_type = src.m_type;
00133     m_plane = src.m_plane;
00134     m_points = src.m_points;
00135     m_usertext = src.m_usertext;
00136     m_userpositionedtext = src.m_userpositionedtext;
00137   }
00138   return *this;
00139 }
00140 
00141 ON_BOOL32 ON_Annotation::IsValid( ON_TextLog* text_log ) const
00142 {
00143   // TODO: quickly inspect object and return true/false
00144   bool rc = true;
00145   if ( ON::dtNothing == m_type  )
00146   {
00147     if ( 0 != text_log )
00148       text_log->Print("ON_Annotation has m_type = ON::dtNothing.\n");
00149     rc = false;
00150   }
00151   return rc;
00152 }
00153 
00154 void ON_Annotation::Dump( ON_TextLog& dump ) const
00155 {
00156   // for debugging
00157   dump.Print("ON_Annotation: ....\n");
00158 }
00159 
00160 ON_BOOL32 ON_Annotation::Write( ON_BinaryArchive& file ) const
00161 {
00162   int i;
00163   ON_BOOL32 rc = file.Write3dmChunkVersion( 1, 0 );
00164     // TODO: use 
00165     //    if (rc) rc = file.WritePoint(....);
00166     //    if (rc) rc = file.WriteString(....);
00167     //    if (rc) rc = file.WriteDouble(....);
00168     // to write object.
00169   i = m_type;
00170   if (rc) 
00171     rc = file.WriteInt( i );
00172   if (rc) 
00173     rc = file.WritePlane( m_plane );
00174   if (rc) 
00175     rc = file.WriteArray( m_points );
00176   if (rc) 
00177     rc = file.WriteString( m_usertext );
00178   if (rc) 
00179     rc = file.WriteString( m_defaulttext );
00180   if( rc )
00181     rc = file.WriteInt( m_userpositionedtext );
00182   return rc;
00183 }
00184 
00185 ON_BOOL32 ON_Annotation::Read( ON_BinaryArchive& file )
00186 {
00187   Destroy();
00188   int major_version = 0;
00189   int minor_version = 0;
00190   ON_BOOL32 rc = file.Read3dmChunkVersion(&major_version,&minor_version);
00191   if ( rc && major_version == 1 ) 
00192   {
00193     int i;
00194     if (rc)
00195     {
00196       rc = file.ReadInt( &i );
00197       if (rc)
00198         m_type = ON::AnnotationType(i);
00199     }
00200     if (rc)
00201       rc = file.ReadPlane( m_plane );
00202     if (rc)
00203       rc = file.ReadArray( m_points );
00204     if (rc)
00205       rc = file.ReadString( m_usertext );
00206     if (rc)
00207       rc = file.ReadString( m_defaulttext );
00208     if( rc )
00209     {
00210       rc = file.ReadInt( &i );
00211       if (rc) m_userpositionedtext = i ? true : false;
00212     }
00213   }
00214 
00215   if( fabs( m_plane.origin.x) > REALLY_BIG_NUMBER || fabs( m_plane.origin.y) > REALLY_BIG_NUMBER || fabs( m_plane.origin.z) > REALLY_BIG_NUMBER)
00216     return false;
00217 
00218   for( int i = 0; i < m_points.Count(); i++)
00219   {
00220     if( fabs( m_points[i].x) > REALLY_BIG_NUMBER || fabs( m_points[i].y) > REALLY_BIG_NUMBER)
00221       return false;
00222   }
00223 
00224 
00225   return rc;
00226 }
00227 
00228 ON::object_type ON_Annotation::ObjectType() const
00229 {
00230   return ON::annotation_object;
00231 }
00232 
00233 
00234 
00235 int ON_Annotation::Dimension() const
00236 {
00237   return 3; 
00238 }
00239 
00240 ON_BOOL32 ON_Annotation::GetBBox( // returns true if successful
00241        double* boxmin,
00242        double* boxmax,
00243        ON_BOOL32 bGrowBox // default = false
00244        ) const
00245 {
00246   // TODO:
00247   //   If the class is not valid, return false.
00248   //
00249   //   If the class is valid and bGrowBox is false, 
00250   //   return the 3d bounding box of the annotation.
00251   //
00252   //   If the class is valid and bGrowBox is true, 
00253   //   return the union of the input box and the 3d bounding 
00254   //   box of the annotation.
00255   if( !bGrowBox )
00256   {
00257     boxmin[0] = boxmin[1] = boxmin[2] =  1e300;
00258     boxmax[0] = boxmax[1] = boxmax[2] = -1e300;
00259   }
00260 
00261   ON_3dPoint wpt;
00262   ON_Xform xform;
00263   GetECStoWCSXform( xform );
00264   for( int i = 0; i < m_points.Count(); i++ )
00265   {
00266     wpt = m_points[i];
00267     
00268     if( wpt.y < boxmin[1] )
00269       boxmin[1] = wpt.y;
00270     if( wpt.z < boxmin[2] )
00271       boxmin[2] = wpt.z;
00272     if( wpt.x > boxmax[0] )
00273       boxmax[0] = wpt.x;
00274     if( wpt.y > boxmax[1] )
00275       boxmax[1] = wpt.y;
00276     if( wpt.z > boxmax[2] )
00277       boxmax[2] = wpt.z;
00278   }
00279   return true;
00280 }
00281 
00282 ON_BOOL32 ON_Annotation::Transform( const ON_Xform& xform )
00283 {
00284   // TODO: Return false if class is invalid or xform cannot be applied.
00285   //       Otherwise, apply xform to geometry and return true.
00286   TransformUserData(xform);
00287   return m_plane.Transform( xform );
00288 }
00289 
00290 // Converts 2d points in annotation to 3d WCS points 
00291 bool ON_Annotation::GetECStoWCSXform( ON_Xform& xform ) const
00292 {
00293   ON_3dVector z = ON_CrossProduct( m_plane.xaxis, m_plane.yaxis );
00294   return xform.ChangeBasis( m_plane.origin, m_plane.xaxis, m_plane.yaxis, z, 
00295                             ON_origin, ON_xaxis, ON_yaxis, ON_zaxis );
00296 }
00297 
00298 // Converts from WCS 3d points to 2d points in annotation
00299 bool ON_Annotation::GeWCStoECSXform( ON_Xform& xform ) const
00300 {
00301   ON_3dVector z = ON_CrossProduct( m_plane.xaxis, m_plane.yaxis );
00302   return xform.ChangeBasis( ON_origin, ON_xaxis, ON_yaxis, ON_zaxis,
00303                             m_plane.origin, m_plane.xaxis, m_plane.yaxis, z );
00304 }
00305 
00306 void ON_Annotation::SetPoint( int idx, ON_3dPoint point )
00307 {
00308   if( idx >= 0 && idx < m_points.Count() )
00309     m_points[idx] = point;
00310 }
00311   
00312 ON_2dPoint ON_Annotation::Point( int idx ) const
00313 {
00314   if( idx >= 0 && idx < m_points.Count() )
00315     return m_points[idx];
00316 
00317   return ON_2dPoint( 0.0, 0.0 );
00318 }
00319 
00320 
00321 
00322 //----- ON_LinearDimension ------------------------------------------
00323 ON_LinearDimension::ON_LinearDimension()
00324 {
00325 }
00326 
00327 ON_LinearDimension::ON_LinearDimension(const ON_LinearDimension& src) : ON_Annotation(src)
00328 {
00329 }
00330 
00331 ON_LinearDimension::~ON_LinearDimension()
00332 {
00333 }
00334 
00335 ON_LinearDimension& ON_LinearDimension::operator=(const ON_LinearDimension& src)
00336 {
00337   if ( this != &src ) {
00338     ON_Annotation::operator=(src);
00339   }
00340   return *this;
00341 }
00342 
00343 void ON_LinearDimension::EmergencyDestroy()
00344 {
00345   ON_Annotation::EmergencyDestroy();
00346 }
00347 
00348 double ON_LinearDimension::NumericValue()
00349 {
00350   return (Point( 1) - Point( 3)).Length();
00351 }
00352 void ON_LinearDimension::SetTextToDefault() 
00353 { 
00354   SetUserText( L"<>"); 
00355 }
00356 
00357 
00358 //----- ON_RadialDimension ------------------------------------------
00359 ON_RadialDimension::ON_RadialDimension()
00360 {
00361 }
00362 
00363 ON_RadialDimension::ON_RadialDimension(const ON_RadialDimension& src) : ON_Annotation(src)
00364 {
00365 }
00366 
00367 ON_RadialDimension::~ON_RadialDimension()
00368 {
00369 }
00370 
00371 ON_RadialDimension& ON_RadialDimension::operator=(const ON_RadialDimension& src)
00372 {
00373   if ( this != &src ) {
00374     ON_Annotation::operator=(src);
00375   }
00376   return *this;
00377 }
00378 
00379 void ON_RadialDimension::EmergencyDestroy()
00380 {
00381   ON_Annotation::EmergencyDestroy();
00382 }
00383 
00384 double ON_RadialDimension::NumericValue()
00385 {
00386   double d = (Point( 0) - Point( 1)).Length();
00387   if( Type() == ON::dtDimDiameter)
00388     d *= 2.0;
00389   return d;
00390 }
00391 
00392 void ON_RadialDimension::SetTextToDefault() 
00393 { 
00394   ON_wString s; 
00395   if( Type() == ON::dtDimDiameter) 
00396     s.Format( L"%c<>", ON_Annotation::diametersym); 
00397   else 
00398     s.Format( L"%c<>", ON_Annotation::radiussym); 
00399   SetUserText( s); 
00400 }
00401 
00402 //----- ON_AngularDimension -----------------------------------------
00403 ON_AngularDimension::ON_AngularDimension() : m_angle(0.0), m_radius(0.0)
00404 {
00405 }
00406 
00407 ON_AngularDimension::ON_AngularDimension(const ON_AngularDimension& src) : ON_Annotation(src)
00408 {
00409   m_angle = src.m_angle;
00410   m_radius = src.m_radius;
00411 }
00412 
00413 ON_AngularDimension::~ON_AngularDimension()
00414 {
00415 }
00416 
00417 ON_AngularDimension& ON_AngularDimension::operator=(const ON_AngularDimension& src)
00418 {
00419   if ( this != &src ) {
00420     ON_Annotation::operator=(src);
00421     m_angle = src.m_angle;
00422     m_radius = src.m_radius;
00423   }
00424   return *this;
00425 }
00426 
00427 void ON_AngularDimension::EmergencyDestroy()
00428 {
00429   ON_Annotation::EmergencyDestroy();
00430 }
00431 
00432 ON_BOOL32 ON_AngularDimension::Write( ON_BinaryArchive& file ) const
00433 {
00434   ON_BOOL32 rc = ON_Annotation::Write( file );
00435   if( rc )
00436     rc = file.WriteDouble( m_angle );
00437   if( rc )
00438     rc = file.WriteDouble( m_radius );
00439   return rc;
00440 }
00441 
00442 ON_BOOL32 ON_AngularDimension::Read( ON_BinaryArchive& file )
00443 {
00444   ON_BOOL32 rc = ON_Annotation::Read( file );
00445   if( rc )
00446     rc = file.ReadDouble( &m_angle );
00447   if( rc )
00448     rc = file.ReadDouble( &m_radius );
00449 
00450   if( m_angle <= 0.0 || m_angle > REALLY_BIG_NUMBER)
00451     return false;
00452 
00453   if( m_radius <= 0.0 || m_radius > REALLY_BIG_NUMBER)
00454     return false;
00455 
00456   return rc;
00457 }
00458 
00459 double ON_AngularDimension::NumericValue()
00460 {
00461   return Angle() * 180.0 / ON_PI;
00462 }
00463 
00464 void ON_AngularDimension::SetTextToDefault() 
00465 { 
00466   ON_wString s; 
00467   s.Format( L"<>%c", ON_Annotation::degreesym); 
00468   SetUserText( s); 
00469 }
00470 
00471 //----- ON_TextEntity -----------------------------------------------
00472 ON_TextEntity::ON_TextEntity() : m_fontweight(400), m_height(20.0)
00473 {
00474 }
00475 
00476 ON_TextEntity::ON_TextEntity(const ON_TextEntity& src) : ON_Annotation(src)
00477 {
00478   m_facename = src.m_facename;
00479   m_fontweight = src.m_fontweight;
00480   m_height = src.m_height;
00481 }
00482 
00483 ON_TextEntity::~ON_TextEntity()
00484 {
00485   m_facename.Destroy();
00486 }
00487 
00488 ON_TextEntity& ON_TextEntity::operator=(const ON_TextEntity& src)
00489 {
00490   if ( this != &src ) {
00491     m_facename = src.m_facename;
00492     m_fontweight = src.m_fontweight;
00493     m_height = src.m_height;
00494     ON_Annotation::operator=(src);
00495   }
00496   return *this;
00497 }
00498 
00499 void ON_TextEntity::EmergencyDestroy()
00500 {
00501   ON_Annotation::EmergencyDestroy();
00502   m_facename.EmergencyDestroy();
00503 }
00504 
00505 ON_BOOL32 ON_TextEntity::Write( ON_BinaryArchive& file ) const
00506 {
00507   ON_BOOL32 rc = ON_Annotation::Write( file );
00508   if( rc )
00509     rc = file.WriteString( m_facename );
00510   if( rc )
00511     rc = file.WriteInt( m_fontweight );
00512   if( rc )
00513     rc = file.WriteDouble( m_height );
00514   return rc;
00515 }
00516 
00517 ON_BOOL32 ON_TextEntity::Read( ON_BinaryArchive& file )
00518 {
00519   ON_BOOL32 rc = ON_Annotation::Read( file );
00520   if( rc )
00521     rc = file.ReadString( m_facename );
00522   if( rc )
00523     rc = file.ReadInt( &m_fontweight );
00524   if( rc )
00525     rc = file.ReadDouble( &m_height );
00526 
00527   if( fabs( m_height) > REALLY_BIG_NUMBER)
00528     return false;
00529 
00530 
00531   return rc;
00532 }
00533 
00534 //----- ON_Leader ------------------------------------------
00535 ON_Leader::ON_Leader()
00536 {
00537 }
00538 
00539 ON_Leader::ON_Leader(const ON_Leader& src) : ON_Annotation(src)
00540 {
00541 }
00542 
00543 ON_Leader::~ON_Leader()
00544 {
00545 }
00546 
00547 ON_Leader& ON_Leader::operator=(const ON_Leader& src)
00548 {
00549   if ( this != &src ) {
00550     ON_Annotation::operator=(src);
00551   }
00552   return *this;
00553 }
00554 
00555 void ON_Leader::EmergencyDestroy()
00556 {
00557   ON_Annotation::EmergencyDestroy();
00558 }
00559 
00560 
00561 ON_OBJECT_IMPLEMENT(ON_AnnotationTextDot,ON_Point,"8BD94E19-59E1-11d4-8018-0010830122F0");
00562 
00563 ON_AnnotationTextDot::ON_AnnotationTextDot()
00564 {}
00565 
00566 ON_AnnotationTextDot::~ON_AnnotationTextDot()
00567 {
00568   m_text.Destroy();
00569 }
00570 
00571 ON_AnnotationTextDot::ON_AnnotationTextDot(const ON_AnnotationTextDot& src) : ON_Point(src), m_text(src.m_text)
00572 {}
00573 
00574 ON_AnnotationTextDot& ON_AnnotationTextDot::operator=(const ON_AnnotationTextDot& src)
00575 {
00576   if ( this != &src ) {
00577     ON_Point::operator=(src);
00578     m_text = src.m_text;
00579   }
00580   return *this;
00581 }
00582 
00583 ON_BOOL32 ON_AnnotationTextDot::IsValid( ON_TextLog* text_log ) const
00584 {
00585   bool rc = true;
00586   if ( m_text.IsEmpty() )
00587   {
00588     if ( 0 != text_log )
00589       text_log->Print("ON_AnnotationTextDot.m_text is empty\n");
00590     rc = false;
00591   }
00592   return rc;
00593 }
00594 
00595 void ON_AnnotationTextDot::Dump( ON_TextLog& log ) const
00596 {
00597   log.Print("ON_AnnotationTextDot \"%ls\" at ",m_text.Array());
00598   log.Print(point);
00599   log.Print("\n");
00600 }
00601 
00602 ON_BOOL32 ON_AnnotationTextDot::Write( ON_BinaryArchive& file ) const
00603 {
00604   ON_BOOL32 rc = file.Write3dmChunkVersion(1,0);
00605   if (rc) rc = file.WritePoint( point );
00606   if (rc) rc = file.WriteString( m_text );
00607   return rc;
00608 }
00609 
00610 ON_BOOL32 ON_AnnotationTextDot::Read( ON_BinaryArchive& file )
00611 {
00612   m_text.Destroy();
00613   int major_version = 0;
00614   int minor_version = 0;
00615   ON_BOOL32 rc = file.Read3dmChunkVersion(&major_version,&minor_version);
00616   if ( major_version == 1 ) {
00617     if (rc) rc = file.ReadPoint( point );
00618     if (rc) rc = file.ReadString( m_text );
00619   }
00620   else {
00621     rc = false;
00622   }
00623   return rc;
00624 }
00625 
00626 ON_OBJECT_IMPLEMENT(ON_AnnotationArrow,ON_Geometry,"8BD94E1A-59E1-11d4-8018-0010830122F0");
00627 
00628 ON_AnnotationArrow::ON_AnnotationArrow() : m_tail(0.0,0.0,0.0), m_head(0.0,0.0,0.0)
00629 {}
00630 
00631 ON_AnnotationArrow::~ON_AnnotationArrow()
00632 {}
00633 
00634 ON_AnnotationArrow::ON_AnnotationArrow(const ON_AnnotationArrow& src) : ON_Geometry(src), m_tail(src.m_tail), m_head(src.m_head)
00635 {}
00636 
00637 ON_AnnotationArrow& ON_AnnotationArrow::operator=(const ON_AnnotationArrow& src)
00638 {
00639   if ( this != &src ) {
00640     ON_Geometry::operator=(src);
00641     m_tail = src.m_tail;
00642     m_head = src.m_head;
00643   }
00644   return *this;
00645 }
00646 
00647 ON_BOOL32 ON_AnnotationArrow::IsValid( ON_TextLog* text_log ) const
00648 {
00649   bool rc = true;
00650   if (m_tail == m_head)
00651   {
00652     if ( 0 != text_log )
00653       text_log->Print("ON_AnnotationArrow has m_head=m_tail.\n");
00654     rc = false;
00655   }
00656   return rc;
00657 }
00658 
00659 void ON_AnnotationArrow::Dump( ON_TextLog& log ) const
00660 {
00661   log.Print("ON_AnnotationArrow: ");
00662   log.Print(m_tail);
00663   log.Print(" to ");
00664   log.Print(m_head);
00665   log.Print("\n");
00666 }
00667 
00668 ON_BOOL32 ON_AnnotationArrow::Write( ON_BinaryArchive& file ) const
00669 {
00670   ON_BOOL32 rc = file.Write3dmChunkVersion(1,0);
00671   if (rc) rc = file.WritePoint( m_tail );
00672   if (rc) rc = file.WritePoint( m_head );
00673   return rc;
00674 }
00675 
00676 ON_BOOL32 ON_AnnotationArrow::Read(ON_BinaryArchive& file)
00677 {
00678   int major_version = 0;
00679   int minor_version = 0;
00680   ON_BOOL32 rc = file.Read3dmChunkVersion(&major_version,&minor_version);
00681   if ( major_version == 1 ) {
00682     if (rc) rc = file.ReadPoint( m_tail );
00683     if (rc) rc = file.ReadPoint( m_head );
00684 
00685   }
00686   else {
00687     rc = false;
00688   }
00689   return rc;
00690 }
00691 
00692 ON::object_type ON_AnnotationArrow::ObjectType() const
00693 {
00694   return ON::annotation_object;
00695 }
00696 
00697 int ON_AnnotationArrow::Dimension() const
00698 {
00699   return 3;
00700 }
00701 
00702 ON_BOOL32 ON_AnnotationArrow::GetBBox( double* boxmin, double* boxmax, ON_BOOL32 bGrowBox ) const
00703 {
00704   ON_BOOL32 rc = ON_GetPointListBoundingBox( 3, false, 1, 3, m_tail, boxmin, boxmax, bGrowBox?true:false );
00705   if (rc)
00706     rc = ON_GetPointListBoundingBox( 3, false, 1, 3, m_head, boxmin, boxmax, true );
00707   return rc;
00708 }
00709 
00710 ON_BOOL32 ON_AnnotationArrow::Transform( const ON_Xform& xform )
00711 {
00712   TransformUserData(xform);
00713   m_tail = xform*m_tail;
00714   m_head = xform*m_head;
00715   return true;
00716 }
00717 
00718 ON_3dVector ON_AnnotationArrow::Vector() const
00719 {
00720   return (m_head-m_tail);
00721 }
00722 
00723 ON_3dPoint ON_AnnotationArrow::Head() const
00724 {
00725   return m_head;
00726 }
00727 
00728 ON_3dPoint ON_AnnotationArrow::Tail() const
00729 {
00730   return m_tail;
00731 }
00732 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:26:58