ON_BOOL32 ON_DetailView::Read(ON_BinaryArchive& archive) { m_page_per_model_ratio = 0.0; m_view.Default(); m_boundary.Destroy(); int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &major_version, &minor_version ); if (!rc) return false; for(;;) { rc = (1 == major_version ); if (!rc) break; // m_view is wrapped in a subchunk so ON_3dmView can be expanded // without breaking the file format. int mj = 0, mn = 0; rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &mj, &mn ); if (rc) { rc = m_view.Read(archive); if (!archive.EndRead3dmChunk()) rc = false; } if (!rc) break; // m_boundary is wrapped in a subchunk so ON_NurbsCurve can be expanded // without breaking the file format. mj = mn = 0; rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &mj, &mn ); if (rc) { rc = m_boundary.Read(archive)?true:false; if (!archive.EndRead3dmChunk()) rc = false; } if (!rc) break; if ( minor_version >= 1 ) { rc = archive.ReadDouble(&m_page_per_model_ratio); } break; } if ( !archive.EndRead3dmChunk() ) rc = false; return rc; }
// virtual ON_Object override ON_BOOL32 ON__IDefAlternativePathUserData::Read(ON_BinaryArchive& binary_archive) { DestroyHelper(); int major_version = 0; int minor_version = 0; bool rc = binary_archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; rc = false; while ( 1 == major_version ) { if ( !binary_archive.ReadString(m_alternate_path) ) break; if ( !binary_archive.ReadBool(&m_bRelativePath) ) break; rc = true; break; } if ( !binary_archive.EndRead3dmChunk() ) rc = false; return rc; }
bool ON_UserString::Read(ON_BinaryArchive& archive) { m_key.Empty(); m_string_value.Empty(); int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for(;;) { rc = ( 1 == major_version ); if (!rc) break; rc = archive.ReadString(m_key); if (!rc) break; rc = archive.ReadString(m_string_value); if (!rc) break; break; } if ( !archive.EndRead3dmChunk() ) rc = false; return rc; }
BOOL ON_BrepLoopArray::Read( ON_BinaryArchive& file ) { Empty(); unsigned int tcode = 0; int count = 0; int i; int major_version = 0; int minor_version = 0; BOOL rc = file.BeginRead3dmChunk( &tcode, &i ); if (rc) { if (tcode != TCODE_ANONYMOUS_CHUNK) rc = false; if (rc) rc = file.Read3dmChunkVersion(&major_version,&minor_version); if (rc) { if ( major_version==1 ) { if (rc) rc = file.ReadInt(&count); SetCapacity(count); for ( i = 0; i < count && rc ; i++ ) { ON_BrepLoop& loop = AppendNew(); rc = loop.Read(file); } } else { rc = 0; } } if ( !file.EndRead3dmChunk() ) rc = false; } return rc; }
bool ON_ClippingPlaneInfo::Read( ON_BinaryArchive& file ) { Default(); int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for(;;) { rc = (1 == major_version); if (!rc) break; rc = file.ReadPlaneEquation(m_plane_equation); if (!rc) break; rc = file.ReadUuid(m_plane_id); if (!rc) break; rc = file.ReadBool(&m_bEnabled); if (!rc) break; break; } if ( !file.EndRead3dmChunk() ) rc = false; return rc; }
bool ON_BrepRegionTopology::Read( ON_BinaryArchive& file ) { int i; int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; for(;;) { rc = (1 == major_version); if (!rc) break; rc = m_FS.Read(file); for ( i = 0; i < m_FS.Count(); i++ ) m_FS[i].m_rtop = this; if (!rc) break; rc = m_R.Read(file); for ( i = 0; i < m_R.Count(); i++ ) m_R[i].m_rtop = this; if (!rc) break; break; } if ( !file.EndRead3dmChunk() ) rc = false; return rc; }
bool ON_BrepRegionArray::Read( ON_BinaryArchive& file ) { Empty(); int count = 0; int i; int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &major_version, &minor_version ); if (rc) { for(;;) { rc = (1 == major_version); if (!rc) break; if (rc) rc = file.ReadInt(&count); SetCapacity(count); for ( i = 0; i < count && rc ; i++ ) { ON_BrepRegion& region = AppendNew(); rc = region.Read(file)?true:false; } break; } if ( !file.EndRead3dmChunk() ) rc = false; } return rc; }
ON_BOOL32 ON_BrepRegion::Read(ON_BinaryArchive& file) { int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; for(;;) { rc = (1==major_version); if (!rc) break; rc = file.ReadInt( &m_region_index ); if (!rc) break; rc = file.ReadInt( &m_type ); if (!rc) break; rc = file.ReadArray( m_fsi ); if (!rc) break; rc = file.ReadBoundingBox( m_bbox ); if (!rc) break; break; } if (!file.EndRead3dmChunk()) rc = false; return rc; }
ON_BOOL32 ON_BrepFaceSide::Read(ON_BinaryArchive& file) { int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; for(;;) { rc = (1==major_version); if (!rc) break; rc = file.ReadInt( &m_faceside_index ); if (!rc) break; rc = file.ReadInt( &m_ri ); if (!rc) break; rc = file.ReadInt( &m_fi ); if (!rc) break; rc = file.ReadInt( &m_srf_dir ); if (!rc) break; break; } if (!file.EndRead3dmChunk()) rc = false; return rc; }
ON_BOOL32 ON_MeshNgonUserData::Read(ON_BinaryArchive& archive) { if ( 0 != m_ngon_list ) { delete m_ngon_list; m_ngon_list = 0; } int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for (;;) { rc = (1 == major_version); if (!rc) break; int count = 0; rc = archive.ReadInt(&count); if (count <= 0 || !rc) break; m_ngon_list = new ON_MeshNgonList(); if ( 0 == m_ngon_list ) break; m_ngon_list->ReserveNgonCapacity(count); for ( int i = 0; i < count; i++ ) { int N = 0; rc = archive.ReadInt(&N); if (!rc) break; if ( N <= 0 ) continue; struct ON_MeshNgon* ngon = m_ngon_list->AddNgon(N); if ( 0 == ngon ) break; rc = archive.ReadInt(N,ngon->vi); if (!rc) break; rc = archive.ReadInt(N,ngon->fi); if (!rc) break; ngon->N = N; } if (!rc) break; break; } if ( !archive.EndRead3dmChunk() ) rc = false; return rc; }
// virtual ON_Object override ON_BOOL32 ON__IDefLayerSettingsUserData::Read(ON_BinaryArchive& binary_archive) { DestroyHelper(); int major_version = 0; int minor_version = 0; bool rc = binary_archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; rc = false; while ( 1 == major_version ) { if ( !binary_archive.ReadArray(m_layers) ) break; if ( minor_version <= 0 ) { rc = true; break; } // added in version 1.1 chunks bool bHaveParentLayer = false; if ( !binary_archive.ReadBool(&bHaveParentLayer) ) break; if ( bHaveParentLayer ) { ON_Object* p = 0; if ( !binary_archive.ReadObject(&p) || 0 == p ) { if (p) { delete p; break; } } m_idef_layer_table_parent_layer = ON_Layer::Cast(p); if ( 0 == m_idef_layer_table_parent_layer ) { delete p; break; } } rc = true; break; } if ( !binary_archive.EndRead3dmChunk() ) rc = false; return rc; }
bool ON_CompressedBuffer::Read( ON_BinaryArchive& binary_archive ) { int major_version = 0; int minor_version = 0; bool rc = binary_archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; for(;;) { rc = ( 1 == major_version ); if ( !rc ) break; rc = binary_archive.ReadSize(&m_sizeof_uncompressed); if (!rc) break; rc = binary_archive.ReadSize(&m_sizeof_compressed); if (!rc) break; rc = binary_archive.ReadInt(&m_crc_uncompressed); if (!rc) break; rc = binary_archive.ReadInt(&m_crc_compressed); if (!rc) break; rc = binary_archive.ReadInt(&m_method); if (!rc) break; rc = binary_archive.ReadInt(&m_sizeof_element); if (!rc) break; if ( m_sizeof_compressed > 0 ) { m_buffer_compressed = onmalloc(m_sizeof_compressed); if ( m_buffer_compressed ) { m_buffer_compressed_capacity = m_sizeof_compressed; rc = binary_archive.ReadByte(m_sizeof_compressed,m_buffer_compressed); } else { m_sizeof_compressed =0; } if (!rc) break; } break; } if ( !binary_archive.EndRead3dmChunk() ) rc = false; return rc; }
BOOL CSampleObjectUserData::Read( ON_BinaryArchive& binary_archive ) { int major_version = 0; int minor_version = 0; bool rc = binary_archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &major_version, &minor_version ); if( !rc ) return false; // Read class members like this for(;;) { rc = ( 1 == major_version ); if( !rc ) break; // version 1.0 fields rc = binary_archive.ReadPoint( m_point ); if( !rc ) break; rc = binary_archive.ReadString( m_string ); if( !rc ) break; // The code in the comment below demonstrates how to // correctly read information added in later releases // of your product. //if ( minor_version >= 1 ) //{ // // version 1.1 fields added DD MMM YYYY // rc = binary_archive.ReadSomethingNew( ... ); // if (!rc) break; // rc = binary_archive.ReadSomethingElseNew( ... ); // if (!rc) break; // // if ( minor_version >= 2 ) // { // // version 1.2 fields added DD MMM YYYY // rc = binary_archive.ReadAnotherSomethingNew( ... ); // if (!rc) break; // rc = binary_archive.ReadAnotherSomethingElseNew( ... ); // if (!rc) break; // } //} break; } // If BeginRead3dmChunk() returns true, // then EndRead3dmChunk() must be called, // even if a read operation failed. if( !binary_archive.EndRead3dmChunk() ) rc = false; return rc; }
bool ON_PlugInRef::Read( ON_BinaryArchive& file ) { Default(); int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &major_version, &minor_version); if (rc) { if( 1 == major_version && minor_version >= 0 ) { //version 1.0 fields if (rc) rc = file.ReadUuid(m_plugin_id); if (rc) rc = file.ReadInt(&m_plugin_type); if (rc) rc = file.ReadString(m_plugin_name); if (rc) rc = file.ReadString(m_plugin_version); if (rc) rc = file.ReadString(m_plugin_filename); if ( minor_version >= 1) { // version 1.1 fields if (rc) rc = file.ReadString(m_developer_organization); if (rc) rc = file.ReadString(m_developer_address); if (rc) rc = file.ReadString(m_developer_country); if (rc) rc = file.ReadString(m_developer_phone); if (rc) rc = file.ReadString(m_developer_email); if (rc) rc = file.ReadString(m_developer_website); if (rc) rc = file.ReadString(m_developer_updateurl); if (rc) rc = file.ReadString(m_developer_fax); if ( minor_version >= 2 ) { if (rc) rc = file.ReadInt(&m_plugin_platform); if (rc) rc = file.ReadInt(&m_plugin_sdk_version); if (rc) rc = file.ReadInt(&m_plugin_sdk_service_release); } } } else { rc = false; } if( !file.EndRead3dmChunk() ) rc = false; } return rc; }
bool ON_ClippingPlane::Read( ON_BinaryArchive& file ) { Default(); int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for(;;) { rc = (1 == major_version); if (!rc) break; ON_UUID viewport_id; rc = file.ReadUuid(viewport_id); if(!rc) break; if( 0 == minor_version ) m_viewport_ids.AddUuid( viewport_id ); rc = file.ReadUuid(m_plane_id); if (!rc) break; rc = file.ReadPlane(m_plane); if (!rc) break; rc = file.ReadBool(&m_bEnabled); if (!rc) break; if( minor_version > 0 ) { rc = m_viewport_ids.Read(file); if (!rc) break; } break; } if ( !file.EndRead3dmChunk() ) rc = false; return rc; }
ON_BOOL32 ON_PolyEdgeSegment::Read( ON_BinaryArchive& archive ) { Init(); int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for(;;) { rc = (1 == major_version); if ( !rc ) break; rc = archive.ReadUuid(m_object_id); if (!rc) break; rc = archive.ReadComponentIndex(m_component_index); if (!rc) break; rc = archive.ReadInterval(m_edge_domain); if (!rc) break; rc = archive.ReadInterval(m_trim_domain); if (!rc) break; // Read ON_ProxyCurve values we need bool bReversed = false; rc = archive.ReadBool(&bReversed); if (!rc) break; ON_Interval this_domain; rc = archive.ReadInterval(this_domain); if (!rc) break; ON_Interval real_curve_domain; rc = archive.ReadInterval(real_curve_domain); if (!rc) break; if ( bReversed) ON_CurveProxy::Reverse(); ON_CurveProxy::SetDomain(this_domain); ON_CurveProxy::SetProxyCurveDomain(real_curve_domain); break; } if ( !archive.EndRead3dmChunk() ) rc = false; return rc; }
ON_BOOL32 ON_HatchExtra::Read(ON_BinaryArchive& archive) { int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if(major_version != 1) rc = false; m_basepoint.Set(0.0,0.0); if(rc) rc = archive.ReadUuid(m_parent_hatch); if(rc) rc = archive.ReadPoint(m_basepoint); if(!archive.EndRead3dmChunk()) rc = false; return rc; }
bool ON_BezierCageMorph::Read(ON_BinaryArchive& archive) { int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( rc ) { if ( major_version != 1 ) rc = false; if (rc) rc = archive.ReadXform(m_xyz2rst); if(rc) rc = m_rst2xyz.Read(archive); if ( !archive.EndRead3dmChunk() ) rc = false; } return rc; }
BOOL ON_BrepFaceArray::Read( ON_BinaryArchive& file ) { Empty(); unsigned int tcode = 0; int count = 0; int i; int major_version = 0; int minor_version = 0; BOOL rc = file.BeginRead3dmChunk( &tcode, &i ); if (rc) { if (tcode != TCODE_ANONYMOUS_CHUNK) rc = false; if (rc) rc = file.Read3dmChunkVersion(&major_version,&minor_version); if (rc) { if ( major_version==1 ) { if (rc) rc = file.ReadInt(&count); SetCapacity(count); for ( i = 0; i < count && rc ; i++ ) { ON_BrepFace& face = AppendNew(); rc = face.Read(file); } if ( minor_version >= 1 ) { // chunk version 1.1 and later has face uuids for ( i = 0; i < count && rc; i++ ) { rc = file.ReadUuid( m_a[i].m_face_uuid ); } } } else { rc = 0; } } if ( !file.EndRead3dmChunk() ) rc = false; } return rc; }
ON_BOOL32 ON_ClippingPlaneSurface::Read( ON_BinaryArchive& file ) { Default(); int major_version = 0; int minor_version = 0; bool rc = file.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for(;;) { rc = ( 1 == major_version ); if (!rc) break; ON__UINT32 tcode = 0; ON__INT64 big_value = 0; rc = file.BeginRead3dmBigChunk(&tcode,&big_value)?true:false; if (rc) { rc = (TCODE_ANONYMOUS_CHUNK == tcode); if (rc) rc = (ON_PlaneSurface::Read(file)?true:false); if (!file.EndRead3dmChunk()) rc = false; } if (!rc) break; rc = m_clipping_plane.Read(file); if (rc) break; break; } if (!file.EndRead3dmChunk() ) rc = false; return rc; }
ON_BOOL32 ON_Linetype::Read( ON_BinaryArchive& file) { Default(); m_linetype_index = -1; int major_version=0; int minor_version=0; bool rc = file.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, &major_version, &minor_version ); if (rc) { if( 1 == major_version ) { // chunk version 1.0 fields if( rc) rc = file.ReadInt( &m_linetype_index ); if( rc) rc = file.ReadString( m_linetype_name ); if( rc) rc = file.ReadArray( m_segments ); if ( minor_version >= 1 ) { if (rc) rc = file.ReadUuid( m_linetype_id ); } } else { rc = false; } if ( !file.EndRead3dmChunk() ) rc = false; } return rc; }
BOOL ON_UserStringList::Read(ON_BinaryArchive& archive) { int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( !rc ) return false; for(;;) { rc = (1 == major_version); if (!rc) break; int count = 0; rc = archive.ReadInt(&count); if(!rc) break; for ( int i = 0; i < count; i++ ) { rc = m_e.AppendNew().Read(archive); if ( !rc) { m_e.Remove(); break; } } if (!rc) break; break; } if ( !archive.EndRead3dmChunk() ) rc = false; return rc; }
bool ON_Localizer::Read(ON_BinaryArchive& archive) { Destroy(); int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if (!rc) return false; for(;;) { rc = (1 == major_version); if ( !rc ) break; int i = no_type; rc = archive.ReadInt(&i); if ( !rc ) break; switch(i) { case sphere_type: m_type = sphere_type; break; case plane_type: m_type = plane_type; break; case cylinder_type: m_type = cylinder_type; break; case curve_type: m_type = curve_type; break; case surface_type: m_type = surface_type; break; case distance_type: m_type = distance_type; break; } rc = archive.ReadPoint(m_P); if ( !rc ) break; rc = archive.ReadVector(m_V); if ( !rc ) break; rc = archive.ReadInterval(m_d); if ( !rc ) break; int mjv = 0, mnv = 0; rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&mjv,&mnv); if (!rc) break; rc = (1 == mjv); bool bReadCurve = false; if (rc) rc = archive.ReadBool( &bReadCurve ); if ( rc && bReadCurve) { m_nurbs_curve = new ON_NurbsCurve(); rc = m_nurbs_curve->Read(archive)?true:false; } if ( !archive.EndRead3dmChunk() ) rc = false; if (!rc) break; rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&mjv,&mnv); if (!rc) break; rc = (1 == mjv); bool bReadSurface = false; rc = archive.ReadBool( &bReadSurface ); if ( rc && bReadSurface ) { m_nurbs_surface = new ON_NurbsSurface(); rc = m_nurbs_surface->Read(archive)?true:false; } if ( !archive.EndRead3dmChunk() ) rc = false; if (!rc) break; break; } if ( !archive.EndRead3dmChunk() ) rc = false; return rc; }
unsigned int Dump3dmChunk( ON_BinaryArchive& file, ON_TextLog& dump, int recursion_depth ) { BOOL bShortChunk = FALSE; const size_t offset0 = file.CurrentPosition(); unsigned int typecode = 0; int value; BOOL rc = file.BeginRead3dmChunk( &typecode, &value ); if (!rc) { ErrorReport(offset0,"BeginRead3dmChunk() failed.",dump); } else { if ( !typecode ) { ErrorReport(offset0,"BeginRead3dmChunk() returned typecode = 0.",dump); file.EndRead3dmChunk(); return 0; } else { if ( 0 == recursion_depth ) { dump.Print("\n"); } bShortChunk = (0 != (typecode & TCODE_SHORT)); if ( bShortChunk ) { dump.Print("%6d: %08X %s: value = %d (%08X)\n", offset0, typecode, TypeCodeString(typecode), value, value ); } else { // long chunk value = length of chunk data if ( value < 0 ) { ErrorReport(offset0,"BeginRead3dmChunk() returned length < 0.",dump); file.EndRead3dmChunk(); return 0; } dump.Print("%6d: %08X %s: length = %d bytes\n", offset0, typecode, TypeCodeString(typecode), value ); } int major_userdata_version = -1; int minor_userdata_version = -1; switch( typecode ) { case TCODE_PROPERTIES_TABLE: case TCODE_SETTINGS_TABLE: case TCODE_BITMAP_TABLE: case TCODE_MATERIAL_TABLE: case TCODE_LAYER_TABLE: case TCODE_GROUP_TABLE: case TCODE_LIGHT_TABLE: case TCODE_FONT_TABLE: case TCODE_DIMSTYLE_TABLE: case TCODE_HATCHPATTERN_TABLE: case TCODE_LINETYPE_TABLE: case TCODE_TEXTURE_MAPPING_TABLE: case TCODE_HISTORYRECORD_TABLE: case TCODE_USER_TABLE: case TCODE_INSTANCE_DEFINITION_TABLE: case TCODE_OBJECT_TABLE: // start of a table { dump.PushIndent(); unsigned int record_typecode = 0; for (;;) { record_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !record_typecode ) { break; } if ( TCODE_ENDOFTABLE == record_typecode ) { break; } } dump.PopIndent(); } break; case TCODE_BITMAP_RECORD: { dump.PushIndent(); unsigned int bitmap_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = bitmap_chunk_typecode; dump.PopIndent(); } break; case TCODE_MATERIAL_RECORD: { dump.PushIndent(); unsigned int material_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = material_chunk_typecode; dump.PopIndent(); } break; case TCODE_LAYER_RECORD: { dump.PushIndent(); unsigned int layer_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = layer_chunk_typecode; dump.PopIndent(); } break; case TCODE_GROUP_RECORD: { dump.PushIndent(); unsigned int group_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = group_chunk_typecode; dump.PopIndent(); } break; case TCODE_FONT_RECORD: { dump.PushIndent(); unsigned int font_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = font_chunk_typecode; dump.PopIndent(); } break; case TCODE_DIMSTYLE_RECORD: { dump.PushIndent(); unsigned int dimstyle_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = dimstyle_chunk_typecode; dump.PopIndent(); } break; case TCODE_LIGHT_RECORD: { dump.PushIndent(); unsigned int light_chunk_typecode = 0; for (;;) { light_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !light_chunk_typecode ) { break; } if ( TCODE_LIGHT_RECORD_END == light_chunk_typecode ) { break; } switch( light_chunk_typecode ) { //case TCODE_OBJECT_RECORD_TYPE: case TCODE_LIGHT_RECORD_ATTRIBUTES: case TCODE_OPENNURBS_CLASS: break; default: { ErrorReport(offset0,"Rogue chunk in light record.",dump); } } } dump.PopIndent(); } break; break; //case TCODE_LIGHT_RECORD_ATTRIBUTES: // { // dump.PushIndent(); // unsigned int light_attributes_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); // dump.PopIndent(); // } // break; case TCODE_TEXTURE_MAPPING_RECORD: { dump.PushIndent(); unsigned int mapping_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = mapping_chunk_typecode; dump.PopIndent(); } break; case TCODE_HISTORYRECORD_RECORD: { dump.PushIndent(); unsigned int history_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = history_chunk_typecode; dump.PopIndent(); } break; case TCODE_HATCHPATTERN_RECORD: { dump.PushIndent(); unsigned int hatch_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !typecode ) typecode = hatch_chunk_typecode; dump.PopIndent(); } break; case TCODE_OBJECT_RECORD: { dump.PushIndent(); unsigned int object_chunk_typecode = 0; for (;;) { object_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !object_chunk_typecode ) { break; } if ( TCODE_OBJECT_RECORD_END == object_chunk_typecode ) { break; } switch( object_chunk_typecode ) { case TCODE_OBJECT_RECORD_TYPE: case TCODE_OBJECT_RECORD_ATTRIBUTES: case TCODE_OPENNURBS_CLASS: break; default: { ErrorReport(offset0,"Rogue chunk in object record.",dump); } } } dump.PopIndent(); } break; case TCODE_OPENNURBS_CLASS: { dump.PushIndent(); unsigned int opennurbs_object_chunk_typecode = 0; for (;;) { opennurbs_object_chunk_typecode = Dump3dmChunk( file, dump, recursion_depth+1 ); if ( !opennurbs_object_chunk_typecode ) { break; } if ( TCODE_OPENNURBS_CLASS_END == opennurbs_object_chunk_typecode ) { break; } switch( opennurbs_object_chunk_typecode ) { case TCODE_OPENNURBS_CLASS_UUID: break; case TCODE_OPENNURBS_CLASS_DATA: break; case TCODE_OPENNURBS_CLASS_USERDATA: break; default: { ErrorReport(offset0,"Rogue chunk in OpenNURBS class record.",dump); } } } dump.PopIndent(); } break; case TCODE_OPENNURBS_CLASS_USERDATA: { if ( !file.Read3dmChunkVersion(&major_userdata_version, &minor_userdata_version ) ) { ErrorReport(offset0,"Read3dmChunkVersion() failed to read TCODE_OPENNURBS_CLASS_USERDATA chunk version.",dump); } else { dump.PushIndent(); dump.Print("UserData chunk version: %d.%d\n", major_userdata_version, minor_userdata_version ); if ( 1 == major_userdata_version || 2 == major_userdata_version ) { const size_t userdata_header_offset = file.CurrentPosition(); switch ( major_userdata_version ) { case 1: { // version 1 user data header information was not wrapped // in a chunk. if ( Read3dmUserDataHeader( userdata_header_offset, file, dump ) ) { // a TCODE_ANONYMOUS_CHUNK contains user data goo int anon_typecode = Dump3dmChunk(file, dump, recursion_depth+1 ); if ( TCODE_ANONYMOUS_CHUNK != anon_typecode ) { ErrorReport( offset0,"Userdata Expected a TCODE_ANONYMOUS_CHUNK chunk.",dump); } } } break; case 2: { // version 2 user data header information is wrapped // in a TCODE_OPENNURBS_CLASS_USERDATA_HEADER chunk. unsigned int userdata_header_typecode = Dump3dmChunk(file, dump, recursion_depth+1 ); if ( TCODE_OPENNURBS_CLASS_USERDATA_HEADER != userdata_header_typecode ) { ErrorReport(userdata_header_offset,"Expected a TCODE_OPENNURBS_CLASS_USERDATA_HEADER chunk.",dump); } else { int anon_typecode = Dump3dmChunk(file, dump, recursion_depth+1 ); if ( TCODE_ANONYMOUS_CHUNK != anon_typecode ) { ErrorReport( offset0,"Userdata Expected a TCODE_ANONYMOUS_CHUNK chunk.",dump); } } } break; default: if ( major_userdata_version < 3 ) { } else { dump.Print("New user data format created after this diagnostic tool was written.\n"); } break; } } dump.PopIndent(); } } break; case TCODE_OPENNURBS_CLASS_UUID: case TCODE_USER_TABLE_UUID: { dump.PushIndent(); ON_UUID uuid = ON_nil_uuid; const ON_ClassId* pClassId = 0; if ( !file.ReadUuid( uuid ) ) { ErrorReport(offset0,"ReadUuid() failed.",dump); } else { if ( typecode == TCODE_OPENNURBS_CLASS_UUID ) { dump.Print("OpenNURBS class id = "); pClassId = ON_ClassId::ClassId(uuid); } else if ( typecode == TCODE_USER_TABLE_UUID ) { dump.Print("User table id = "); } else { dump.Print("UUID = "); } dump.Print( uuid ); if ( pClassId ) { const char* sClassName = pClassId->ClassName(); if ( sClassName ) { dump.Print(" (%s)",sClassName); } } dump.Print("\n"); } dump.PopIndent(); } break; case TCODE_OPENNURBS_CLASS_USERDATA_HEADER: { if ( !Read3dmUserDataHeader( offset0, file, dump ) ) { ErrorReport(offset0,"Unable to read userdata header.",dump); } } break; case TCODE_ENDOFFILE: case TCODE_ENDOFFILE_GOO: { dump.PushIndent(); if ( value < 4 ) { ErrorReport(offset0,"TCODE_ENDOFFILE chunk withlength < 4.",dump); } else { int sizeof_file = 0; file.ReadInt(&sizeof_file); dump.Print("current position = %d stored size = %d\n", file.CurrentPosition(), sizeof_file); } dump.PopIndent(); } break; } } const size_t offset1 = file.CurrentPosition(); if ( !file.EndRead3dmChunk() ) { ErrorReport(offset1,"EndRead3dmChunk() failed.",dump); rc = FALSE; } else if (!bShortChunk) { const size_t extra = value - (offset1-offset0-8); if ( extra < 0 ) { ErrorReport(offset0,"Read beyond end of chunk.",dump); } } } return typecode; }
BOOL ON_Brep::Read( ON_BinaryArchive& file ) { int i; int C2_count = 0; int C3_count = 0; int S_count = 0; int major_version = 0; int minor_version = 0; BOOL rc = file.Read3dmChunkVersion( &major_version, &minor_version ); if ( rc && major_version == 2 ) { rc = ReadOld200(file,minor_version); // legacy trimmed face } else if ( rc && major_version == 3 ) { // 2d curves if (rc) rc = m_C2.Read(file); C2_count = m_C2.Count(); // 3d curves if (rc) rc = m_C3.Read(file); C3_count = m_C3.Count(); // untrimmed surfaces if (rc) rc = m_S.Read(file); S_count = m_S.Count(); // vertices if (rc) rc = m_V.Read(file); // edges if (rc) { rc = m_E.Read(file); if (rc) { for ( i = 0; i < m_E.Count(); i++ ) { ON_BrepEdge& e = m_E[i]; e.m_brep = this; if ( e.m_c3i >= 0 && e.m_c3i < C3_count ) { bool bProxyCurveIsReversed = e.ProxyCurveIsReversed(); ON_Interval pdom = e.ProxyCurveDomain(); ON_Interval edom = e.Domain(); e.SetProxyCurve( m_C3[e.m_c3i], pdom ); if ( bProxyCurveIsReversed ) e.ON_CurveProxy::Reverse(); e.SetDomain(edom); } } } } // trims if (rc) { rc = m_T.Read(file); if (rc) { for ( i = 0; i < m_T.Count(); i++ ) { ON_BrepTrim& trim = m_T[i]; trim.m_brep = this; if ( trim.m_c2i >= 0 && trim.m_c2i < C2_count ) { bool bProxyCurveIsReversed = trim.ProxyCurveIsReversed(); ON_Interval pdom = trim.ProxyCurveDomain(); ON_Interval tdom = trim.Domain(); trim.SetProxyCurve( m_C2[trim.m_c2i], pdom ); if ( bProxyCurveIsReversed ) trim.ON_CurveProxy::Reverse(); trim.SetDomain(tdom); } } } } // loops if (rc) { rc = m_L.Read(file); if ( rc ) { for ( i = 0; i < m_L.Count(); i++ ) { m_L[i].m_brep = this; } } } // faces if (rc) { rc = m_F.Read(file); if (rc) { for ( i = 0; i < m_F.Count(); i++ ) { ON_BrepFace& f = m_F[i]; f.m_brep = this; if ( f.m_si >= 0 && f.m_si < S_count ) f.SetProxySurface(m_S[f.m_si]); } } } // bounding box if (rc) rc = file.ReadPoint( m_bbox.m_min ); if (rc) rc = file.ReadPoint( m_bbox.m_max ); // fill in missing information ReadFillInMissingBoxes(*this); // end of chunk version 3.0 if (rc && minor_version >= 1 ) { // added for chunk version 3.1 ON_Object* obj; unsigned int tcode; int value, fi; unsigned char b; const int face_count = m_F.Count(); // read render meshes rc = file.BeginRead3dmChunk( &tcode, &value ); if ( rc ) { if ( tcode != TCODE_ANONYMOUS_CHUNK ) rc = false; else { for ( fi = 0; rc && fi < face_count; fi++ ) { rc = file.ReadChar(&b); if (rc && b) { rc = file.ReadObject(&obj); m_F[fi].m_render_mesh = ON_Mesh::Cast(obj); if ( !m_F[fi].m_render_mesh ) delete obj; } } } if ( !file.EndRead3dmChunk() ) rc = false; } // read analysis meshes rc = file.BeginRead3dmChunk( &tcode, &value ); if ( rc ) { if ( tcode != TCODE_ANONYMOUS_CHUNK ) rc = false; else { for ( fi = 0; rc && fi < face_count; fi++ ) { rc = file.ReadChar(&b); if (rc && b) { rc = file.ReadObject(&obj); m_F[fi].m_analysis_mesh = ON_Mesh::Cast(obj); if ( !m_F[fi].m_analysis_mesh ) delete obj; } } } if ( !file.EndRead3dmChunk() ) rc = false; } } if ( rc && minor_version >= 2 ) { rc = file.ReadInt( &m_is_solid ); if ( m_is_solid < 0 || m_is_solid >= 3 ) m_is_solid = 0; } } if ( file.ArchiveOpenNURBSVersion() < 20021002 ) { m_is_solid = 0; } return rc; }
bool ON_BezierCage::Read(ON_BinaryArchive& archive) { Destroy(); int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if ( rc ) { while(rc) { if ( major_version != 1 ) { ON_ERROR("ON_BezierCage::Read - old code unable to read new version of chunk"); rc = false; break; } int dim=0,order0=0,order1=0,order2=0; bool is_rat=false; rc = archive.ReadInt(&dim); if (!rc) break; if (dim < 1 || dim > 10000) { ON_ERROR("ON_BezierCage::Read - invalid dim"); rc=false; break; } rc = archive.ReadBool(&is_rat); if (!rc) break; rc = archive.ReadInt(&order0); if (!rc) break; if ( order0 < 2 || order0 > 10000 ) { ON_ERROR("ON_BezierCage::Read - invalid order0"); rc=false; break; } rc = archive.ReadInt(&order1); if (!rc) break; if ( order1 < 2 || order1 > 10000 ) { ON_ERROR("ON_BezierCage::Read - invalid order1"); rc=false; break; } rc = archive.ReadInt(&order2); if (!rc) break; if ( order2 < 2 || order2 > 10000 ) { ON_ERROR("ON_BezierCage::Read - invalid order2"); rc=false; break; } rc = Create(dim,is_rat,order0,order1,order2); if (!rc) break; int i,j,k; const int cv_dim = m_is_rat?(m_dim+1):m_dim; for(i = 0; i < order0 && rc; i++) { for(j = 0; j < order1 && rc; j++) { for ( k = 0; k < order2 && rc; k++) { rc = archive.ReadDouble(cv_dim,CV(i,j,k)); } } } break; } if ( !archive.EndRead3dmChunk() ) { rc = false; } } return rc; }