ON_BOOL32 ON_PointCloud::Write( ON_BinaryArchive& file ) const { bool rc = file.Write3dmChunkVersion(1,1); if (rc) rc = file.WriteArray( m_P ); if (rc) rc = file.WritePlane( m_plane ); if (rc) rc = file.WriteBoundingBox( m_bbox ); if (rc) rc = file.WriteInt( m_flags); // added for 1.1 (7 December 2005) if (rc) rc = file.WriteArray(m_N); if (rc) rc = file.WriteArray(m_C); return rc; }
ON_BOOL32 ON_Linetype::Write( ON_BinaryArchive& file) const { bool rc = file.BeginWrite3dmChunk(TCODE_ANONYMOUS_CHUNK,1,1); if (rc) { for(;;) { // chunk version 1.0 fields rc = file.WriteInt( LinetypeIndex()); if(!rc) break; rc = file.WriteString( m_linetype_name ); if (!rc) break; rc = file.WriteArray( m_segments ); if(!rc) break; // chunk version 1.1 fields rc = file.WriteUuid( m_linetype_id ); if (!rc) break; break; } if ( !file.EndWrite3dmChunk() ) rc = false; } 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_HatchLine::Write( ON_BinaryArchive& ar) const { BOOL rc = ar.Write3dmChunkVersion(1,1); if (rc) rc = ar.WriteDouble( m_angle); if (rc) rc = ar.WritePoint( m_base); if (rc) rc = ar.WriteVector( m_offset); if (rc) rc = ar.WriteArray( m_dashes); return rc; }
BOOL ON_BrepVertex::Write( ON_BinaryArchive& file ) const { BOOL rc = file.WriteInt( m_vertex_index ); if ( rc ) rc = file.WritePoint( point ); if ( rc ) rc = file.WriteArray( m_ei ); if ( rc ) rc = file.WriteDouble( m_tolerance ); return rc; }
BOOL ON_BrepFace::Write( ON_BinaryArchive& file ) const { bool rc = file.WriteInt( m_face_index ); if ( rc ) rc = file.WriteArray( m_li ); if ( rc ) rc = file.WriteInt( m_si ); if ( rc ) rc = file.WriteInt( m_bRev ); if ( rc ) rc = file.WriteInt( m_face_material_channel ); return rc; }
BOOL ON_BrepLoop::Write( ON_BinaryArchive& file ) const { int i; BOOL rc = file.WriteInt( m_loop_index ); if (rc) rc = file.WriteArray( m_ti ); i = m_type; if (rc) rc = file.WriteInt( i ); if (rc) rc = file.WriteInt( m_fi ); return rc; }
BOOL ON_BrepEdge::Write( ON_BinaryArchive& file ) const { BOOL rc = file.WriteInt( m_edge_index ); if (rc) rc = file.WriteInt( m_c3i ); int i = ProxyCurveIsReversed() ? 1 : 0; if (rc) rc = file.WriteInt( i ); if (rc) rc = file.WriteInterval( ProxyCurveDomain() ); if (rc) rc = file.WriteInt( 2, m_vi ); if (rc) rc = file.WriteArray( m_ti ); if (rc) rc = file.WriteDouble( m_tolerance ); if ( file.Archive3dmVersion() >= 3 ) { // added in opennurbs version 200206180 if (rc) rc = file.WriteInterval( Domain() ); } return rc; }
ON_BOOL32 ON_BrepRegion::Write(ON_BinaryArchive& file) const { bool rc = file.BeginWrite3dmChunk(TCODE_ANONYMOUS_CHUNK,1,0); if ( !rc ) return false; for(;;) { rc = file.WriteInt( m_region_index ); if (!rc) break; rc = file.WriteInt( m_type ); if (!rc) break; rc = file.WriteArray( m_fsi ); if (!rc) break; rc = file.WriteBoundingBox( m_bbox ); if (!rc) break; break; } if (!file.EndWrite3dmChunk()) rc = false; return rc; }
ON_BOOL32 ON_Annotation::Write( ON_BinaryArchive& file ) const { int i; ON_BOOL32 rc = file.Write3dmChunkVersion( 1, 0 ); // TODO: use // if (rc) rc = file.WritePoint(....); // if (rc) rc = file.WriteString(....); // if (rc) rc = file.WriteDouble(....); // to write object. i = m_type; if (rc) rc = file.WriteInt( i ); if (rc) rc = file.WritePlane( m_plane ); if (rc) rc = file.WriteArray( m_points ); if (rc) rc = file.WriteString( m_usertext ); if (rc) rc = file.WriteString( m_defaulttext ); if( rc ) rc = file.WriteInt( m_userpositionedtext ); return rc; }
ON_BOOL32 ON_3dmObjectAttributes::Write( ON_BinaryArchive& file ) const { if ( file.Archive3dmVersion() >= 5 ) { // added at opennurbs version 200712190 return WriteV5Helper(file); } bool rc = file.Write3dmChunkVersion(1,7); // version 1.0 fields if (rc) rc = file.WriteUuid(m_uuid); if (rc) rc = file.WriteInt(m_layer_index); if (rc) rc = file.WriteInt(m_material_index); if (rc) rc = file.WriteColor(m_color); if (rc) { // OBSOLETE if (rc) rc = file.WriteLineStyle(m_line_style); // 23 March 2005 Dale Lear short s; s = (short)m_object_decoration; if (rc) rc = file.WriteShort(s); s = 0; if (rc) rc = file.WriteShort(s); if (rc) rc = file.WriteDouble(0.0); if (rc) rc = file.WriteDouble(1.0); } if (rc) rc = file.WriteInt(m_wire_density); if (rc) rc = file.WriteChar(m_mode); if (rc) rc = file.WriteChar(m_color_source); if (rc) rc = file.WriteChar(m_linetype_source); if (rc) rc = file.WriteChar(m_material_source); if (rc) rc = file.WriteString(m_name); if (rc) rc = file.WriteString(m_url); // version 1.1 fields if (rc) rc = file.WriteArray(m_group); // version 1.2 fields if (rc) rc = file.WriteBool(m_bVisible); // version 1.3 fields if (rc) rc = file.WriteArray(m_dmref); // version 1.4 fields - 23 March 2005 Dale Lear if (rc) rc = file.WriteInt(m_object_decoration); if (rc) rc = file.WriteChar(m_plot_color_source); if (rc) rc = file.WriteColor(m_plot_color); if (rc) rc = file.WriteChar(m_plot_weight_source); if (rc) rc = file.WriteDouble(m_plot_weight_mm); // version 1.5 fields 11 April 2005 if (rc) rc = file.WriteInt(m_linetype_index); // version 1.6 fields 2 September 2005 if (rc) { unsigned char uc = 0; switch(m_space) { case ON::no_space: uc = 0; break; case ON::model_space: uc = 0; break; case ON::page_space: uc = 1; break; } rc = file.WriteChar(uc); } if (rc) { // 22 Sep 2006 - the way ON_3dmObjectAttiributes indicates // that an object is put on a particular page view changed // from being saved in the m_dmref[] list to using the // m_space and m_viewport_id settings. But the file format // cannot change at this point. So, the bAddPagespaceDMR // is here to save the page info in the old dmr format. int count = m_dmref.Count(); if ( count < 0 ) count = 0; bool bAddPagespaceDMR = ( ON::page_space == m_space && !ON_UuidIsNil(m_viewport_id) ); rc = file.WriteInt( bAddPagespaceDMR ? (count+1) : count ); if ( rc && bAddPagespaceDMR ) { rc = file.WriteUuid(m_viewport_id); if (rc) rc = file.WriteUuid(ON_ObsoletePageSpaceObjectId); } int i; for ( i = 0; i < count && rc; i++ ) { const ON_DisplayMaterialRef& dmr = m_dmref[i]; rc = file.WriteUuid(dmr.m_viewport_id); if (rc) rc = file.WriteUuid(dmr.m_display_material_id); } } // version 1.7 fields 6 June 2006 if (rc) rc = m_rendering_attributes.Write(file); return rc; }
bool ON_3dmObjectAttributes::WriteV5Helper( ON_BinaryArchive& file ) const { unsigned char c; // 29 Nov. 2009 S. Baer // Chunk version updated to 2.1 in order to support m_display_order bool rc = file.Write3dmChunkVersion(2,1); while(rc) { if (!rc) break; rc = file.WriteUuid(m_uuid); if (!rc) break; rc = file.WriteInt(m_layer_index); if (!rc) break; // write non-default settings - skip everything else if ( !m_name.IsEmpty() ) { c = 1; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteString(m_name); if (!rc) break; } if ( !m_url.IsEmpty() ) { c = 2; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteString(m_url); if (!rc) break; } if ( -1 != m_linetype_index ) { c = 3; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteInt(m_linetype_index); if (!rc) break; } if ( -1 != m_material_index ) { c = 4; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteInt(m_material_index); if (!rc) break; } if ( m_rendering_attributes.m_mappings.Count() > 0 || m_rendering_attributes.m_materials.Count() > 0 || true != m_rendering_attributes.m_bCastsShadows || true != m_rendering_attributes.m_bReceivesShadows || false != m_rendering_attributes.AdvancedTexturePreview() ) { c = 5; rc = file.WriteChar(c); if (!rc) break; rc = m_rendering_attributes.Write(file); if (!rc) break; } if ( 0 != m_color ) { c = 6; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteColor(m_color); if (!rc) break; } if ( 0 != m_plot_color ) { c = 7; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteColor(m_plot_color); if (!rc) break; } if ( 0.0 != m_plot_weight_mm ) { c = 8; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteDouble(m_plot_weight_mm); if (!rc) break; } if ( ON::no_object_decoration != m_object_decoration ) { c = 9; rc = file.WriteChar(c); if (!rc) break; c = (unsigned char)m_object_decoration; rc = file.WriteChar(c); if (!rc) break; } if ( 1 != m_wire_density ) { c = 10; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteInt(m_wire_density); if (!rc) break; } if ( true != m_bVisible ) { c = 11; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteBool(m_bVisible); if (!rc) break; } if ( ON::normal_object != m_mode ) { c = 12; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteChar(m_mode); if (!rc) break; } if ( ON::color_from_layer != m_color_source ) { c = 13; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteChar(m_color_source); if (!rc) break; } if ( ON::plot_color_from_layer != m_plot_color_source ) { c = 14; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteChar(m_plot_color_source); if (!rc) break; } if ( ON::plot_weight_from_layer != m_plot_weight_source ) { c = 15; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteChar(m_plot_weight_source); if (!rc) break; } if ( ON::material_from_layer != m_material_source ) { c = 16; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteChar(m_material_source); if (!rc) break; } if ( ON::linetype_from_layer != m_linetype_source ) { c = 17; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteChar(m_linetype_source); if (!rc) break; } if ( m_group.Count() > 0 ) { c = 18; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteArray(m_group); if (!rc) break; } if ( ON::model_space != m_space ) { c = 19; rc = file.WriteChar(c); if (!rc) break; c = (unsigned char)m_space; rc = file.WriteChar(c); if (!rc) break; } if ( !ON_UuidIsNil(m_viewport_id) ) { c = 20; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteUuid(m_viewport_id); if (!rc) break; } if ( m_dmref.Count() > 0 ) { c = 21; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteArray(m_dmref); if (!rc) break; } // 29 Nov. 2009 - S. Baer // Only write m_display_order if it's value!=0 // m_display_order is written to version 2.1 files if ( 0 != m_display_order ) { c = 22; rc = file.WriteChar(c); if (!rc) break; rc = file.WriteInt(m_display_order); if (!rc) break; } // 0 indicates end of attributes; c = 0; rc = file.WriteChar(c); break; } return rc; }
ON_BOOL32 ON_InstanceDefinition::Write( ON_BinaryArchive& binary_archive ) const { bool rc = binary_archive.Write3dmChunkVersion(1,5); // version 1.0 fields if ( rc ) rc = binary_archive.WriteUuid( m_uuid ); if ( rc ) { if ( binary_archive.Archive3dmVersion() >= 4 && ON_InstanceDefinition::linked_def == m_idef_update_type ) { // linked instance definition geometry is never in the file ON_SimpleArray<ON_UUID> empty_uuid_list; rc = binary_archive.WriteArray( empty_uuid_list ); } else { rc = binary_archive.WriteArray( m_object_uuid ); } } if ( rc ) rc = binary_archive.WriteString( m_name ); if ( rc ) rc = binary_archive.WriteString( m_description ); if ( rc ) rc = binary_archive.WriteString( m_url ); if ( rc ) rc = binary_archive.WriteString( m_url_tag ); if ( rc ) rc = binary_archive.WriteBoundingBox( m_bbox ); // m_idef_update_type was an unsigned int and got changed to an enum. Read and write // as an unsigned int to support backwards compatibility if ( rc ) rc = binary_archive.WriteInt( (unsigned int)m_idef_update_type ); if ( rc ) rc = binary_archive.WriteString( m_source_archive ); // version 1.1 fields if (rc) rc = m_source_archive_checksum.Write( binary_archive ); // version 1.2 fields if (rc) rc = binary_archive.WriteInt( m_us.m_unit_system ); // version 1.3 fields - added 6 March 2006 if (rc) rc = binary_archive.WriteDouble( m_us.m_custom_unit_scale ); if ( rc ) rc = binary_archive.WriteBool( m_source_bRelativePath ); // version 1.4 fields if (rc) rc = m_us.Write(binary_archive); // version 1.5 fields if (rc) rc = binary_archive.WriteInt(m_idef_update_depth); return rc; }
ON_BOOL32 ON_InstanceDefinition::Write( ON_BinaryArchive& binary_archive ) const { bool rc = binary_archive.Write3dmChunkVersion(1,6); // version 1.0 fields if ( rc ) rc = binary_archive.WriteUuid( m_uuid ); if ( rc ) { if ( binary_archive.Archive3dmVersion() >= 4 && ON_InstanceDefinition::linked_def == m_idef_update_type ) { // linked instance definition geometry is never in the file ON_SimpleArray<ON_UUID> empty_uuid_list; rc = binary_archive.WriteArray( empty_uuid_list ); } else { rc = binary_archive.WriteArray( m_object_uuid ); } } if ( rc ) rc = binary_archive.WriteString( m_name ); if ( rc ) rc = binary_archive.WriteString( m_description ); if ( rc ) rc = binary_archive.WriteString( m_url ); if ( rc ) rc = binary_archive.WriteString( m_url_tag ); if ( rc ) rc = binary_archive.WriteBoundingBox( m_bbox ); // m_idef_update_type was an unsigned int and got changed to an enum. Read and write // as an unsigned int to support backwards compatibility const unsigned int idef_update_type = (unsigned int)this->IdefUpdateType(); if ( rc ) rc = binary_archive.WriteInt( idef_update_type ); if ( rc ) { // 7 February 2012 // Purge source archive information from static_defs if ( ON_InstanceDefinition::static_def == idef_update_type ) { ON_wString empty_string; rc = binary_archive.WriteString( empty_string ); } else rc = binary_archive.WriteString( m_source_archive ); } // version 1.1 fields if (rc) { // 7 February 2012 // Purge source archive information from static_defs if ( ON_InstanceDefinition::static_def == idef_update_type ) ON_CheckSum::UnsetCheckSum.Write(binary_archive); else rc = m_source_archive_checksum.Write( binary_archive ); } // version 1.2 fields if (rc) rc = binary_archive.WriteInt( m_us.m_unit_system ); // version 1.3 fields - added 6 March 2006 if (rc) rc = binary_archive.WriteDouble( m_us.m_custom_unit_scale ); if ( rc ) { bool b = (ON_InstanceDefinition::static_def == idef_update_type) ? false : m_source_bRelativePath; rc = binary_archive.WriteBool( b ); } // version 1.4 fields if (rc) rc = m_us.Write(binary_archive); // version 1.5 fields if (rc) rc = binary_archive.WriteInt(m_idef_update_depth); // version 1.6 fields ( added 14 February 2012 ) if (rc) rc = binary_archive.WriteInt( m_idef_layer_style ); return rc; }