BOOL ON_BrepEdge::Read( ON_BinaryArchive& file ) { int bReversed = false; ON_Interval proxy_domain; BOOL rc = file.ReadInt( &m_edge_index ); if (rc) rc = file.ReadInt( &m_c3i ); if (rc) rc = file.ReadInt( &bReversed ); if (rc) rc = file.ReadInterval( proxy_domain ); if (rc) rc = file.ReadInt( 2, m_vi ); if (rc) rc = file.ReadArray( m_ti ); if (rc) rc = file.ReadDouble( &m_tolerance ); ON_Interval domain = proxy_domain; if ( file.Archive3dmVersion() >= 3 && file.ArchiveOpenNURBSVersion() >= 200206180 ) { if (rc) { rc = file.ReadInterval(domain); if ( !rc) domain = proxy_domain; } } SetProxyCurve( NULL, proxy_domain ); if ( bReversed ) ON_CurveProxy::Reverse(); SetDomain(domain); return rc; }
bool ON_CheckSum::Read(ON_BinaryArchive& archive) { bool rc; Zero(); rc = archive.ReadBigSize(&m_size); if (rc) rc = archive.ReadBigTime(&m_time); if (rc) rc = archive.ReadInt(8,&m_crc[0]); if ( archive.ArchiveOpenNURBSVersion() < 200603100 || archive.Archive3dmVersion() < 4 ) { // ON_CheckSums in V3 archives and V4 archives with // version < 200603100 have the same size but an // incompatible format. These were not used. Zero(); } return rc; }
ON_BOOL32 ON_3dmObjectAttributes::Read( ON_BinaryArchive& file ) { Default(); if ( file.Archive3dmVersion() >= 5 && file.ArchiveOpenNURBSVersion() >= 200712190 ) { return ReadV5Helper(file); } int i; int major_version = 0; int minor_version = 0; bool rc = file.Read3dmChunkVersion(&major_version,&minor_version); if ( rc && major_version == 1 ) { if (rc) rc = file.ReadUuid(m_uuid); if (rc) rc = file.ReadInt(&m_layer_index); if (rc) rc = file.ReadInt(&m_material_index); if (rc) rc = file.ReadColor(m_color); while(rc) { // OBSOLETE if (rc) rc = file.ReadLineStyle(m_line_style); // 23 March 2005 Dale Lear // replaced with short s = 0; double x; rc = file.ReadShort(&s); if (!rc) break; if ( file.Archive3dmVersion() < 4 || file.ArchiveOpenNURBSVersion() < 200503170 ) { // ignore unused linestyle info in old files // This bit keeps the curve arrowheads from V3 showing up // in V4. m_object_decoration = ON::ObjectDecoration( (s & ON::both_arrowhead) ); } rc = file.ReadShort(&s); if (!rc) break; rc = file.ReadDouble(&x); if (!rc) break; rc = file.ReadDouble(&x); break; } if (rc) rc = file.ReadInt(&m_wire_density); if (rc) rc = file.ReadChar(&m_mode); if (rc) rc = file.ReadChar(&m_color_source); if (rc) m_color_source = (unsigned char)ON::ObjectColorSource(m_color_source); if (rc) rc = file.ReadChar(&m_linetype_source); if (rc) m_linetype_source = (unsigned char)ON::ObjectLinetypeSource(m_linetype_source); if (rc) rc = file.ReadChar(&m_material_source); if (rc) m_material_source = (unsigned char)ON::ObjectMaterialSource(m_material_source); if (rc) rc = file.ReadString(m_name); if (rc) rc = file.ReadString(m_url); m_bVisible = (Mode() != ON::hidden_object); if ( rc && minor_version >= 1 ) { rc = file.ReadArray( m_group ); if ( rc && minor_version >= 2 ) { rc = file.ReadBool(&m_bVisible); if ( rc && minor_version >= 3 ) { rc = file.ReadArray(m_dmref); if (rc && minor_version >= 4 ) { // 23 March 2005 Dale Lear // Added m_plot_color_source and m_plot_color i = 0; if (rc) rc = file.ReadInt(&i); if (rc) m_object_decoration = ON::ObjectDecoration(i); if (rc) rc = file.ReadChar(&m_plot_color_source); if (rc) m_plot_color_source = (unsigned char)ON::PlotColorSource(m_plot_color_source); if (rc) rc = file.ReadColor( m_plot_color ); if (rc) rc = file.ReadChar(&m_plot_weight_source); if (rc) m_plot_weight_source = (unsigned char)ON::PlotWeightSource(m_plot_weight_source); if (rc) rc = file.ReadDouble(&m_plot_weight_mm); if (rc && minor_version >= 5 ) { // version 1.5 fields 11 April 2005 if (rc) rc = file.ReadInt(&m_linetype_index); // version 1.6 fields 2 September 2005 if (rc && minor_version >= 6 ) { unsigned char uc = 0; rc = file.ReadChar(&uc); if (rc) { m_space = (1 == uc) ? ON::page_space : ON::model_space; m_dmref.Empty(); int i, count=0; rc = file.ReadInt(&count); if (rc && count > 0) { m_dmref.SetCapacity(count); for ( i = 0; i < count && rc; i++) { ON_DisplayMaterialRef& dmr = m_dmref.AppendNew(); rc = file.ReadUuid(dmr.m_viewport_id); if (rc) rc = file.ReadUuid(dmr.m_display_material_id); if ( rc ) { // Assigning an object to a page started out as // using dmrs. The way the runtime info is saved // has changed, but, at this point, I can't change // the way the information is saved in the file and // it doesn't matter. if ( 0 == ON_UuidCompare(&ON_ObsoletePageSpaceObjectId,&dmr.m_display_material_id) ) { m_viewport_id = dmr.m_viewport_id; m_dmref.Remove(); } } } if ( 0 == m_dmref.Count() ) m_dmref.Destroy(); } } if ( rc && minor_version >= 7 ) { // version 1.7 fields 6 June 2006 if (rc) rc = m_rendering_attributes.Read(file); } } } } } } } } else { rc = false; } return rc; }
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_BrepTrim::Read( ON_BinaryArchive& file ) { ON_3dPoint P[2]; int i; BOOL rc = file.ReadInt( &m_trim_index ); if ( rc ) rc = file.ReadInt( &m_c2i ); if ( rc ) { ON_Interval d; rc = file.ReadInterval( d ); if (rc) { SetProxyCurveDomain(d); SetDomain(d); } } if ( rc ) rc = file.ReadInt( &m_ei ); if ( rc ) rc = file.ReadInt( 2, m_vi ); if ( rc ) { i = m_bRev3d; rc = file.ReadInt( &i ); if (rc) m_bRev3d = (i!=0); } i = unknown; if ( rc ) rc = file.ReadInt( &i ); switch (i) { case unknown: m_type = unknown; break; case boundary: m_type = boundary; break; case mated: m_type = mated; break; case seam: m_type = seam; break; case singular: m_type = singular; break; } i = ON_Surface::not_iso; if ( rc ) rc = file.ReadInt( &i ); switch(i) { case ON_Surface::not_iso: m_iso = ON_Surface::not_iso; break; case ON_Surface::x_iso: m_iso = ON_Surface::x_iso; break; case ON_Surface::y_iso: m_iso = ON_Surface::y_iso; break; case ON_Surface::W_iso: m_iso = ON_Surface::W_iso; break; case ON_Surface::S_iso: m_iso = ON_Surface::S_iso; break; case ON_Surface::E_iso: m_iso = ON_Surface::E_iso; break; case ON_Surface::N_iso: m_iso = ON_Surface::N_iso; break; } if ( rc ) rc = file.ReadInt( &m_li ); if ( rc ) rc = file.ReadDouble( 2, m_tolerance ); if ( file.Archive3dmVersion() >= 3 && file.ArchiveOpenNURBSVersion() >= 200206180 ) { // read trim proxy curve information added in version 200206180 ON_Interval d = ProxyCurveDomain(); if (rc ) { rc = file.ReadInterval( d ); if ( !rc ) d = ProxyCurveDomain(); } unsigned char b[24]; memset(b,0,sizeof(b)); bool bProxyCurveIsReversed = false; if (rc) { rc = file.ReadChar(8,b); if (rc && b[0] == 1 ) bProxyCurveIsReversed = true; } if (rc) rc = file.ReadChar(24,b); if ( bProxyCurveIsReversed ) ON_CurveProxy::Reverse(); SetDomain(d); } else { if ( rc ) rc = file.ReadPoint( P[0] ); //m_P[0] ); if ( rc ) rc = file.ReadPoint( P[1] ); //m_P[1] ); } if ( rc ) rc = file.ReadDouble( &m__legacy_2d_tol ); if ( rc ) rc = file.ReadDouble( &m__legacy_3d_tol ); return rc; }
BOOL ON_Layer::Read( ON_BinaryArchive& file // restore definition from binary archive ) { int obsolete_value1 = 0; // see ON_Layer::Write int major_version=0; int minor_version=0; int mode = ON::normal_layer; Default(); BOOL rc = file.Read3dmChunkVersion(&major_version,&minor_version); if ( rc && major_version == 1 ) { // common to all 1.x formats if ( rc ) rc = file.ReadInt( &mode ); if ( rc ) { switch(mode) { case 0: // OBSOLETE ON::normal_layer m_bVisible = true; m_bLocked = false; break; case 1: // OBSOLETE ON::hidden_layer m_bVisible = false; m_bLocked = false; break; case 2: // OBSOLETE ON::locked_layer m_bVisible = true; m_bLocked = true; break; default: m_bVisible = true; m_bLocked = false; break; } } if ( rc ) rc = file.ReadInt( &m_layer_index ); if ( rc ) rc = file.ReadInt( &m_iges_level ); if ( rc ) rc = file.ReadInt( &m_material_index ); if ( rc ) rc = file.ReadInt( &obsolete_value1 ); if ( rc ) rc = file.ReadColor( m_color ); { // OBSOLETE line style was never used - read and discard the next 20 bytes short s; double x; if (rc) file.ReadShort(&s); if (rc) file.ReadShort(&s); if (rc) file.ReadDouble(&x); if (rc) file.ReadDouble(&x); } if ( rc ) rc = file.ReadString( m_name ); if ( rc && minor_version >= 1 ) { rc = file.ReadBool(&m_bVisible); if ( rc && minor_version >= 2 ) { rc = file.ReadInt( &m_linetype_index); if (rc && minor_version >= 3 ) { // 23 March 2005 Dale Lear rc = file.ReadColor( m_plot_color); if (rc) rc = file.ReadDouble( &m_plot_weight_mm); if (rc && minor_version >= 4 ) { rc = file.ReadBool(&m_bLocked); if (rc && minor_version >= 5 ) { rc = file.ReadUuid(m_layer_id); if ( rc && minor_version >= 6 && file.ArchiveOpenNURBSVersion() > 200505110 ) { // Some files saved with opennurbs version 200505110 // do not contain correctly written m_parent_layer_id // and m_bExpanded values. // It is ok to default these values. rc = file.ReadUuid(m_parent_layer_id); if (rc) rc = file.ReadBool(&m_bExpanded); } if ( rc && minor_version >= 7 ) { // 1.7 field - added 6 June 2006 rc = m_rendering_attributes.Read(file); if ( rc && minor_version >= 8 ) { // 1.8 field - added 19 Sep 2006 rc = file.ReadUuid(m_display_material_id); } } } } } } } if ( ON_UuidIsNil(m_layer_id) ) { // old files didn't have layer ids and we need unique ones. ON_CreateUuid(m_layer_id); } } else { ON_ERROR("ON_Layer::Read() encountered a layer written by future code."); rc = false; } return rc; }