ON_BOOL32 ON_CurveOnSurface::Write( ON_BinaryArchive& file // open binary file ) const { ON_BOOL32 rc = IsValid(); if (rc) rc = file.WriteObject(*m_c2); if (rc) rc = file.WriteInt( m_c3?1:0 ); if ( rc && m_c3 ) rc = file.WriteObject(*m_c3); if (rc) rc = file.WriteObject(*m_s); return rc; }
ON_BOOL32 ON_SurfaceArray::Write( ON_BinaryArchive& file ) const { ON_BOOL32 rc = file.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 0 ); if (rc) rc = file.Write3dmChunkVersion(1,0); if (rc ) { int i; rc = file.WriteInt( Count() ); for ( i = 0; rc && i < Count(); i++ ) { if ( m_a[i] ) { rc = file.WriteInt(1); if ( rc ) rc = file.WriteObject( *m_a[i] ); // polymorphic surfaces } else { // NULL surface rc = file.WriteInt(0); } } if ( !file.EndWrite3dmChunk() ) rc = false; } return rc; }
BOOL ON_HatchLoop::Write( ON_BinaryArchive& ar) const { BOOL rc = ar.Write3dmChunkVersion(1,1); if( rc) rc = ar.WriteInt( m_type); if( rc) rc = ar.WriteObject( m_p2dCurve); return rc; }
// virtual ON_Object override ON_BOOL32 ON__IDefLayerSettingsUserData::Write(ON_BinaryArchive& binary_archive) const { bool rc = binary_archive.BeginWrite3dmChunk(TCODE_ANONYMOUS_CHUNK,1,1); if ( !rc ) return false; rc = false; for(;;) { if ( !binary_archive.WriteArray(m_layers.Count(),m_layers.Array()) ) break; // added in version 1.1 chunks bool bHaveParentLayer = ( 0 != m_idef_layer_table_parent_layer ); if ( !binary_archive.WriteBool(bHaveParentLayer) ) break; if ( bHaveParentLayer ) { if ( !binary_archive.WriteObject(m_idef_layer_table_parent_layer) ) break; } rc = true; break; } if ( !binary_archive.EndWrite3dmChunk() ) rc = false; return rc; }
BOOL ON_Brep::Write( ON_BinaryArchive& file ) const { const ON_Brep* brep = this; ON_Brep* v2brep = 0; if ( file.Archive3dmVersion() <= 2 && !IsValidForV2() ) { v2brep = ON_Brep::New(*this); v2brep->MakeValidForV2(); brep = v2brep; } //BOOL rc = file.Write3dmChunkVersion(3,0); // serialization version //BOOL rc = file.Write3dmChunkVersion(3,1); // added meshes BOOL rc = file.Write3dmChunkVersion(3,2); // added m_is_solid // 2d curves if (rc) rc = brep->m_C2.Write(file); // 3d curves if (rc) rc = brep->m_C3.Write(file); // untrimmed surfaces if (rc) rc = brep->m_S.Write(file); // vertices if (rc) rc = brep->m_V.Write(file); // edges if (rc) rc = brep->m_E.Write(file); // trims if (rc) rc = brep->m_T.Write(file); // loops if (rc) rc = brep->m_L.Write(file); // faces if (rc) rc = brep->m_F.Write(file); // bounding box if (rc) rc = file.WritePoint( brep->m_bbox.m_min ); if (rc) rc = file.WritePoint( brep->m_bbox.m_max ); // end of chunk version 3.0 if (rc) { // added for chunk version 3.1 const int face_count = brep->m_F.Count(); int fi; unsigned char b; // write render meshes rc = file.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 0 ); if ( rc ) { for ( fi = 0; rc && fi < face_count; fi++ ) { const ON_Mesh* mesh = file.Save3dmRenderMeshes() ? brep->m_F[fi].m_render_mesh : 0; b = mesh ? 1 : 0; file.WriteChar(b); if (mesh) { rc = file.WriteObject(*mesh); } } if ( !file.EndWrite3dmChunk() ) { rc = false; } } // write analysis meshes rc = file.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 0 ); if ( rc ) { for ( fi = 0; rc && fi < face_count; fi++ ) { const ON_Mesh* mesh = file.Save3dmAnalysisMeshes() ? brep->m_F[fi].m_analysis_mesh : 0; b = mesh ? 1 : 0; file.WriteChar(b); if (mesh) { rc = file.WriteObject(*mesh); } } if ( !file.EndWrite3dmChunk() ) rc = false; } } // end of chunk version 3.1 // use value of "this" m_is_solid to avoid expensive // calculation on the v2brep if ( !file.WriteInt( m_is_solid ) ) rc = false; // end of chunk version 3.2 if ( 0 != v2brep ) delete v2brep; return rc; }