opennurbs_detail.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_OBJECT_IMPLEMENT(ON_DetailView,ON_Geometry,"C8C66EFA-B3CB-4e00-9440-2AD66203379E");
00020 
00021 ON_DetailView::ON_DetailView()
00022 {
00023   m_page_per_model_ratio = 0.0;
00024 }
00025 
00026 ON_DetailView::~ON_DetailView()
00027 {
00028 }
00029 
00030 void ON_DetailView::MemoryRelocate()
00031 {
00032   m_boundary.MemoryRelocate();
00033 }
00034 
00035 ON_BOOL32 ON_DetailView::IsValid( ON_TextLog* text_log ) const
00036 {
00037   // Don't bother checking m_view - during runtime it's
00038   // not filled in. It is only used for IO.  See
00039   // CRhDetailViewObject::PrepareToWrite() for details.
00040   return m_boundary.IsValid(text_log);
00041 }
00042 
00043 void ON_DetailView::Dump( ON_TextLog& text_log ) const
00044 {
00045   m_view.Dump(text_log);
00046   m_boundary.Dump(text_log);
00047 }
00048 
00049 unsigned int ON_DetailView::SizeOf() const
00050 {
00051   unsigned int sz = ON_Geometry::SizeOf();
00052   sz += sizeof(*this) - sizeof(ON_Geometry);
00053   sz += m_boundary.SizeOf();
00054   return sz;
00055 }
00056 
00057 ON_BOOL32 ON_DetailView::Write( ON_BinaryArchive& archive ) const
00058 {
00059   bool rc = archive.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 1, 1 );
00060   if (!rc)
00061     return false;
00062 
00063   for(;;)
00064   {
00065     // m_view is wrapped in a subchunk so ON_3dmView can be expanded 
00066     // without breaking the file format.
00067     rc = archive.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 1, 0 );
00068     if (rc) 
00069     {
00070       rc = m_view.Write(archive);
00071       if (!archive.EndWrite3dmChunk())
00072         rc = false;
00073     }
00074     if(!rc)
00075       break;
00076 
00077     // m_boundary is wrapped in a subchunk so ON_NurbsCurve can be expanded 
00078     // without breaking the file format.
00079     rc = archive.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 1, 0 );
00080     if (rc) 
00081     {
00082       rc = m_boundary.Write(archive)?true:false;
00083       if (!archive.EndWrite3dmChunk())
00084         rc = false;
00085     }
00086     if(!rc)
00087       break;
00088 
00089     // 28 Feb 2006  1.1 fields added
00090     rc = archive.WriteDouble(m_page_per_model_ratio);
00091     if ( !rc )
00092       break;
00093 
00094     break;
00095   }
00096 
00097   if ( !archive.EndWrite3dmChunk() )
00098     rc = false;
00099 
00100   return rc;
00101 }
00102 
00103 ON_BOOL32 ON_DetailView::Read(ON_BinaryArchive& archive)
00104 {
00105   m_page_per_model_ratio = 0.0;
00106   m_view.Default();
00107   m_boundary.Destroy();
00108 
00109   int major_version = 0;
00110   int minor_version = 0;
00111   bool rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &major_version, &minor_version );
00112   if (!rc)
00113     return false;
00114 
00115   for(;;)
00116   {
00117     rc = (1 == major_version );
00118     if (!rc) break;
00119 
00120     // m_view is wrapped in a subchunk so ON_3dmView can be expanded 
00121     // without breaking the file format.
00122     int mj = 0, mn = 0;
00123     rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &mj, &mn );
00124     if (rc) 
00125     {
00126       rc = m_view.Read(archive);
00127       if (!archive.EndRead3dmChunk())
00128         rc = false;
00129     }
00130     if (!rc) break;
00131 
00132 
00133     // m_boundary is wrapped in a subchunk so ON_NurbsCurve can be expanded 
00134     // without breaking the file format.
00135     mj = mn = 0;
00136     rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &mj, &mn );
00137     if (rc) 
00138     {
00139       rc = m_boundary.Read(archive)?true:false;
00140       if (!archive.EndRead3dmChunk())
00141         rc = false;
00142     }
00143     if (!rc) break;
00144 
00145     if ( minor_version >= 1 )
00146     {
00147       rc = archive.ReadDouble(&m_page_per_model_ratio);
00148     }
00149 
00150 
00151     break;
00152   }
00153 
00154   if ( !archive.EndRead3dmChunk() )
00155     rc = false;
00156 
00157   return rc;
00158 }
00159 
00160 ON::object_type ON_DetailView::ObjectType() const
00161 {
00162   return ON::detail_object;
00163 }
00164 
00165 int ON_DetailView::Dimension() const
00166 {
00167   return m_boundary.Dimension();
00168 }
00169 
00170 ON_BOOL32 ON_DetailView::GetBBox(
00171     double* boxmin,
00172     double* boxmax,
00173     int bGrowBox
00174     ) const
00175 {
00176   return m_boundary.GetBBox(boxmin,boxmax,bGrowBox);
00177 }
00178 
00179 bool ON_DetailView::GetTightBoundingBox( 
00180       ON_BoundingBox& tight_bbox, int bGrowBox, const ON_Xform* xform
00181       ) const
00182 {
00183   return m_boundary.GetTightBoundingBox(tight_bbox,bGrowBox,xform);
00184 }
00185 
00186 ON_BOOL32 ON_DetailView::Transform( const ON_Xform& xform )
00187 {
00188   return m_boundary.Transform(xform);
00189 }
00190 


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