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; }
ON_BOOL32 ON_Font::Read( ON_BinaryArchive& file // restore definition from binary archive ) { Defaults(); m_font_index = -1; int major_version = 0; int minor_version = 0; bool rc = file.Read3dmChunkVersion(&major_version,&minor_version); if ( rc && major_version == 1 ) { int i; for(;;) { rc = file.ReadInt( &m_font_index ); if (!rc) break; rc = file.ReadString( m_font_name ); if (!rc) break; { // 18 October 2002 Dale Lear: // Lowell, wchar_t has different sizes on different OSs. // When writing a wchar_t string, you should use one // of the WriteString functions. This function must continue // to use ReadShort(64,...) so old files will remain valid. unsigned short sh[64]; rc = file.ReadShort(64, sh); if (!rc) break; wchar_t facename[65]; for ( i = 0; i < 64; i++ ) { facename[i] = sh[i]; } facename[64] = 0; SetFontFaceName(facename); } if( minor_version >= 1 ) { rc = file.ReadInt( &i ); if (!rc) break; SetFontWeight(i); rc = file.ReadInt( &i); if (!rc) break; SetIsItalic(i?true:false); rc = file.ReadDouble( &m_linefeed_ratio ); if (!rc) break; if ( minor_version >= 2 ) { rc = file.ReadUuid( m_font_id ); if (!rc) break; } //if ( minor_version >= 3 ) //{ // rc = file.ReadInt( &i); // if (!rc) break; // SetUnderlined(i?true:false); //} } break; } } else { ON_ERROR("ON_Font::Read - get newer version of opennurbs"); rc = false; } 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; }