void ON_PlugInRef::Dump(ON_TextLog& text_log) const { text_log.Print("Plug-in executable information:\n"); text_log.PushIndent(); text_log.Print("id = ");text_log.Print(m_plugin_id);text_log.Print("\n"); text_log.Print("type = %d\n",m_plugin_type); text_log.Print("platform = %d\n",m_plugin_platform); text_log.Print("sdk version = %d.%d\n",m_plugin_sdk_version,m_plugin_sdk_service_release); text_log.Print("name = "); text_log.Print(m_plugin_name); text_log.Print("\n"); text_log.Print("version = "); text_log.Print(m_plugin_version); text_log.Print("\n"); text_log.Print("file name = "); text_log.Print(m_plugin_filename); text_log.Print("\n"); text_log.PopIndent(); text_log.Print("Developer information:\n"); text_log.PushIndent(); text_log.Print("website url = ");text_log.Print(m_developer_website); text_log.Print("\n"); text_log.Print("update url = ");text_log.Print(m_developer_updateurl); text_log.Print("\n"); text_log.Print("organization = ");text_log.Print(m_developer_organization); text_log.Print("\n"); text_log.Print("address = ");text_log.Print(m_developer_address); text_log.Print("\n"); text_log.Print("country = ");text_log.Print(m_developer_country); text_log.Print("\n"); text_log.Print("voice = ");text_log.Print(m_developer_phone); text_log.Print("\n"); text_log.Print("email = ");text_log.Print(m_developer_email); text_log.Print("\n"); text_log.Print("fax = ");text_log.Print(m_developer_fax); text_log.Print("\n"); text_log.PopIndent(); }
void ON_3dmProperties::Dump( ON_TextLog& dump ) const { dump.Print("Revision history:\n"); dump.PushIndent(); m_RevisionHistory.Dump(dump); dump.PopIndent(); dump.Print("\n"); dump.Print("Notes:\n"); if ( m_Notes.m_notes.Length() > 0 ) { dump.PushIndent(); m_Notes.Dump(dump); dump.PopIndent(); } dump.Print("\n"); dump.Print("Application information:\n"); dump.PushIndent(); m_Application.Dump(dump); dump.PopIndent(); if ( m_PreviewImage.IsValid() ) { dump.Print("\n"); dump.Print("Preview image:\n"); dump.PushIndent(); m_PreviewImage.Dump(dump); dump.PopIndent(); } }
void ON_ClippingPlaneSurface::Dump( ON_TextLog& text_log ) const { text_log.Print("Clipping plane surface\n"); text_log.PushIndent(); text_log.Print("Enabled = %d",m_clipping_plane.m_bEnabled); text_log.Print("View IDs =\n"); { text_log.PushIndent(); ON_SimpleArray<ON_UUID> uuid_list; m_clipping_plane.m_viewport_ids.GetUuids(uuid_list); for( int i=0; i<uuid_list.Count(); i++ ) { text_log.Print( uuid_list[i] ); text_log.Print("\n"); } text_log.PopIndent(); } text_log.Print("Plane ID = "); text_log.Print(m_clipping_plane.m_plane_id); text_log.Print("\n"); text_log.Print("Plane surface\n"); text_log.PushIndent(); ON_PlaneSurface::Dump(text_log); text_log.PopIndent(); text_log.PopIndent(); }
void ON_CheckSum::Dump(ON_TextLog& text_log) const { // Using %llu so this code is portable for both 32 and 64 bit // builds on a wide range of compilers. unsigned long long u; // 8 bytes in windows and gcc - should be at least as big // as a size_t or time_t. text_log.Print("Checksum:"); if ( !IsSet() ) text_log.Print("zero (not set)\n"); else { text_log.PushIndent(); text_log.Print("\n"); u = (unsigned long long)m_size; text_log.Print("Size: %llu bytes\n",u); u = (unsigned long long)m_time; text_log.Print("Last Modified Time: %u (seconds since January 1, 1970, UCT)\n",u); text_log.Print("CRC List: %08x, %08x, %08x, %08x, %08x, %08x, %08x, %08x\n", m_crc[0],m_crc[1],m_crc[2],m_crc[3],m_crc[4],m_crc[5],m_crc[6],m_crc[7] ); text_log.PopIndent(); } }
void CCommandSampleDumpBlockTree::DumpInstanceDefinition( const CRhinoInstanceDefinition* idef, ON_TextLog& dump, bool bRoot ) { if( idef && ! idef->IsDeleted() ) { ON_wString node; if( bRoot ) node = L"\u2500"; else node = L"\u2514"; dump.Print(L"%s Instance definition %d = %s\n", node, idef->Index(), idef->Name() ); const int idef_object_count = idef->ObjectCount(); if( idef_object_count ) { dump.PushIndent(); for( int i = 0; i < idef->ObjectCount(); i++ ) { const CRhinoObject* obj = idef->Object( i ); if( obj ) { const CRhinoInstanceObject* iref = CRhinoInstanceObject::Cast( obj ); if( iref ) DumpInstanceDefinition( iref->InstanceDefinition(), dump, false ); else dump.Print(L"\u2514 Object %d = %s\n", i, obj->ShortDescription(false) ); } } dump.PopIndent(); } } }
void ON_UserData::Dump( ON_TextLog& text_log ) const { text_log.Print("User Data:\n"); text_log.PushIndent(); // print class name and class uuid ON_Object::Dump(text_log); // developer's user data description ON_wString description; const_cast<ON_UserData*>(this)->GetDescription(description); if ( description.IsEmpty() ) description = L"none"; const wchar_t* ws = description; text_log.Print("user data description: %S\n",ws); text_log.Print("user data uuid: "); text_log.Print(m_userdata_uuid); text_log.Print("\n"); text_log.Print("user data copy count: %d\n",this->m_userdata_copycount); // archive setting text_log.Print("user data saved in 3dm archive: %s\n",Archive() ? "yes" : "no"); text_log.PopIndent(); }
void ON_UnknownUserData::Dump( ON_TextLog& dump ) const { ON_UserData::Dump(dump); dump.PushIndent(); dump.Print( "unknown class uuid: "); dump.Print( m_unknownclass_uuid ); dump.Print( "\n"); dump.Print( "Data size in 3dm archive: %d bytes\n",m_sizeof_buffer); dump.PopIndent(); }
void ON_ArcCurve::Dump( ON_TextLog& dump ) const { dump.Print( "ON_ArcCurve: domain = [%g,%g]\n",m_t[0],m_t[1]); dump.PushIndent(); dump.Print( "center = "); dump.Print( m_arc.plane.origin ); dump.Print( "\nradius = %g\n",m_arc.radius); dump.Print( "length = %g\n",m_arc.Length()); dump.PopIndent(); }
void CExampleWriteUserData::Dump( ON_TextLog& text_log ) const { ON_UserData::Dump(text_log); text_log.PushIndent(); const wchar_t* s = m_str; if ( 0 == s ) s = L""; text_log.Print("m_str: %ls\n",s); text_log.Print("m_sn: %d\n",m_sn); text_log.PopIndent(); }
void ON_UserStringList::Dump( ON_TextLog& text_log ) const { int i, count = m_e.Count(); text_log.Print(L"%d entries\n",count); text_log.PushIndent(); for ( i = 0; i < count; i++ ) { m_e[i].Dump(text_log); } text_log.PopIndent(); }
void ON_LineCurve::Dump( ON_TextLog& dump ) const { dump.Print( "ON_LineCurve: domain = [%g,%g]\n",m_t[0],m_t[1]); dump.PushIndent(); dump.Print( "start = "); dump.Print( m_line.from ); dump.Print( "\nend = "); dump.Print( m_line.to ); dump.Print( "\n"); dump.Print( "length = %g\n",m_line.Length()); dump.PopIndent(); }
bool ON__ClassIdDumpNode::Dump( int depth, ON_TextLog& text_log ) { bool rc = true; if ( 0 == m_class_id || m_depth != 0 || depth < 1) rc = false; else { m_depth = depth; const char* class_name = m_class_id->ClassName(); if ( 0 == class_name ) { class_name = "!!ERROR!!"; rc = false; } text_log.Print("%s::ClassId: ",m_class_id->ClassName()); text_log.Print( "mark=%d ",m_class_id->Mark() ); text_log.Print( m_class_id->Uuid() ); text_log.Print(" (%08x)\n",m_class_id); int i, count = m_child_nodes.Count(); if ( count > 0 ) { // dump children names alphabetically m_child_nodes.HeapSort( ON__ClassIdDumpNode_CompareName ); text_log.PushIndent(); for ( i = 0; i < count; i++ ) { ON__ClassIdDumpNode* child_node = m_child_nodes[i]; if ( 0 == child_node ) rc = false; else { if ( !child_node->Dump(depth+1,text_log) ) rc = false; } } text_log.PopIndent(); } } return rc; }
static bool Dump3dmFileHelper( const wchar_t* sFileName, // full name of file ON_TextLog& dump ) { dump.Print("====== FILENAME: %ls\n",sFileName); ON_Workspace ws; FILE* fp = ws.OpenFile( sFileName, L"rb" ); // file automatically closed by ~ON_Workspace() if ( !fp ) { dump.Print("**ERROR** Unable to open file.\n"); return false; } ON_BinaryFile file( ON::read3dm, fp ); int version = 0; ON_String comment_block; ON_BOOL32 rc = file.Read3dmStartSection( &version, comment_block ); if (!rc) { dump.Print("**ERROR** Read3dmStartSection() failed\n"); return false; } dump.Print("====== VERSION: %d\n",version ); dump.Print("====== COMMENT BLOCK:\n",version ); dump.PushIndent(); dump.Print(comment_block); dump.PopIndent(); dump.Print("====== CHUNKS:\n",version ); unsigned int typecode; while ( !file.AtEnd() ) { typecode = file.Dump3dmChunk( dump, 0 ); if ( !typecode ) break; if ( typecode == TCODE_ENDOFFILE ) break; } dump.Print("====== FINISHED: %ls\n",sFileName); return true; }
void ON_PointCloud::Dump( ON_TextLog& dump ) const { int i; const bool bHasNormals = HasPointNormals(); const bool bHasHiddenPoints = (HiddenPointCount() > 0); const int point_count = m_P.Count(); dump.Print("ON_PointCloud: %d points\n",point_count); dump.PushIndent(); for ( i = 0; i < point_count; i++ ) { dump.Print("point[%2d]: ",i); dump.Print( m_P[i] ); if ( bHasNormals ) { dump.Print(", normal = "); dump.Print(m_N[i]); } if ( bHasHiddenPoints && m_H[i]) { dump.Print(" (hidden)"); } dump.Print("\n"); } dump.PopIndent(); }
void ON_InstanceDefinition::Dump( ON_TextLog& text_log ) const { const wchar_t* s; s = m_name; if ( 0 == s ) s = L""; text_log.Print(L"Name: \"%s\"\n",s); text_log.Print("Type: "); switch(m_idef_update_type) { case ON_InstanceDefinition::static_def: text_log.Print("embedded."); break; case ON_InstanceDefinition::embedded_def: text_log.Print("embedded - definition from source archive."); break; case ON_InstanceDefinition::linked_and_embedded_def: text_log.Print("embedded and linked - definition from source archive."); break; case ON_InstanceDefinition::linked_def: text_log.Print("linked - definition from source archive."); break; default: text_log.Print("not valid"); break; } text_log.Print("\n"); text_log.Print(L"Id: "); text_log.Print(m_uuid); text_log.Print(L"\n"); s = m_description; if ( 0 != s && 0 != s[0]) text_log.Print(L"Description: \"%s\"\n",s); s = m_url; if ( 0 != s && 0 != s[0]) text_log.Print(L"URL: \"%s\"\n",s); s = m_url_tag; if ( 0 != s && 0 != s[0]) text_log.Print(L"URL tag: \"%s\"\n",s); m_us.Dump(text_log); s = SourceArchive(); text_log.Print(L"Source archive: "); if ( 0 == s || 0 == s[0] ) { text_log.Print(L"none.\n"); } else { bool bRel = m_source_bRelativePath; text_log.Print(L"\"%s\" (%s)\n",s,bRel?L"relative":L"absolute"); text_log.PushIndent(); ON_wString str; bRel = false; if ( GetAlternateSourceArchivePath(str,bRel) ) { s = str; if ( 0 == s || 0 == s[0] ) s = L""; text_log.Print(L"Alternate archive: \"%s\" (%s)\n",s,bRel?L"relative":L"absolute"); } text_log.Print(L"Update depth: %d\n",m_idef_update_type); text_log.Print(L"Archive "); m_source_archive_checksum.Dump(text_log); text_log.PopIndent(); } const int id_count = m_object_uuid.Count(); text_log.Print(L"Contains: %d objects\n",id_count); if ( id_count > 0 ) { text_log.PushIndent(); text_log.Print(m_object_uuid[0]); text_log.Print(L"\n"); if ( id_count > 4 ) { text_log.Print(L"...\n"); } else { for ( int i = 1; i < id_count; i++ ) { text_log.Print(m_object_uuid[i]); text_log.Print(L"\n"); } } text_log.PopIndent(); } m_bbox.Dump(text_log); }
void DumpSSXEvent(ON_SSX_EVENT &x, ON_TextLog &text_log) { text_log.Print("m_type: "); switch (x.m_type) { case ON_SSX_EVENT::no_ssx_event: text_log.Print("no_ssx_event"); break; case ON_SSX_EVENT::ssx_transverse: text_log.Print("ssx_transverse"); break; case ON_SSX_EVENT::ssx_tangent: text_log.Print("ssx_tangent"); break; case ON_SSX_EVENT::ssx_overlap: text_log.Print("ssx_overlap"); break; case ON_SSX_EVENT::ssx_transverse_point: text_log.Print("ssx_transverse_point"); break; case ON_SSX_EVENT::ssx_tangent_point: text_log.Print("ssx_tangent_point"); break; default: text_log.Print("illegal value"); break; } text_log.Print("\n"); text_log.PushIndent(); switch (x.m_type) { case ON_SSX_EVENT::ssx_transverse_point: case ON_SSX_EVENT::ssx_tangent_point: // don't use %g so the text_log double format can control display precision text_log.Print("SurfaceA("); text_log.Print(x.m_pointA[0]); text_log.Print(","); text_log.Print(x.m_pointA[1]); text_log.Print(") = \n"); text_log.Print("SurfaceB("); text_log.Print(x.m_pointB[0]); text_log.Print(","); text_log.Print(x.m_pointB[1]); text_log.Print(") = \n"); text_log.PushIndent(); text_log.Print(x.m_point3d); text_log.Print("\n"); text_log.PopIndent(); break; case ON_SSX_EVENT::ssx_transverse: case ON_SSX_EVENT::ssx_tangent: case ON_SSX_EVENT::ssx_overlap: text_log.Print("SurfaceA:\n"); text_log.PushIndent(); x.m_curveA->Dump(text_log); text_log.PopIndent(); text_log.Print("SurfaceB:\n"); text_log.PushIndent(); x.m_curveB->Dump(text_log); text_log.PopIndent(); text_log.Print("3D curves:\n"); text_log.PushIndent(); x.m_curve3d->Dump(text_log); text_log.PopIndent(); break; case ON_SSX_EVENT::no_ssx_event: case ON_SSX_EVENT::ssx_32bit_enum: // these extra cses keep gcc happy and quiet break; } }
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; }
static const ONX_ErrorCounter Internal_TestModelRead( ON_TextLog& text_log, const ON_wString text_log_3dm_file_name, ON_BinaryArchive& source_archive, bool bVerbose ) { ONX_ModelTest::Type test_type = ONX_ModelTest::Type::ReadWriteReadCompare; ///// // // Read the orginal file // text_log.PushIndent(); ONX_ModelTest test; test.ReadTest(source_archive, test_type, true, text_log_3dm_file_name, &text_log); text_log.PrintNewLine(); text_log.Print("Test Results:\n"); text_log.PushIndent(); test.Dump(text_log); text_log.PopIndent(); ONX_ErrorCounter error_counter = test.ErrorCounter(); const ONX_Model* source_model = test.SourceModel().get(); if (nullptr == source_model) { text_log.PopIndent(); return error_counter; } const bool bCompareTestFailed = ONX_ModelTest::Result::Fail == test.TestResult(ONX_ModelTest::Type::ReadWriteReadCompare); if ( bVerbose || bCompareTestFailed ) { for (int i = 0; i < 2; i++) { if (0 == i) test.DumpSourceModel(); else test.DumpReadWriteReadModel(); if (false == bCompareTestFailed) break; } } text_log.PrintNewLine(); const ON_ModelComponent::Type component_types[] = { // TODO uncomment types as components are derived from ON_ModelComponent ON_ModelComponent::Type::Image, //ON_ModelComponent::Type::TextureMapping, ON_ModelComponent::Type::RenderMaterial, ON_ModelComponent::Type::LinePattern, ON_ModelComponent::Type::Layer, //ON_ModelComponent::Type::Group, ON_ModelComponent::Type::TextStyle, ON_ModelComponent::Type::DimStyle, ON_ModelComponent::Type::RenderLight, ON_ModelComponent::Type::HatchPattern, ON_ModelComponent::Type::InstanceDefinition, ON_ModelComponent::Type::ModelGeometry, //ON_ModelComponent::Type::HistoryRecord }; const unsigned int component_type_count = (unsigned int)(sizeof(component_types) / sizeof(component_types[0])); const ONX_Model& model = *source_model; error_counter.ClearLibraryErrorsAndWarnings(); const ON_ComponentManifest& manifest = model.Manifest(); ON_SerialNumberMap it_map; for (unsigned int i = 0; i < component_type_count; i++) { const ON_ModelComponent::Type component_type = component_types[i]; const bool bUniqueNameRequired = ON_ModelComponent::UniqueNameRequired(component_type); const bool bEmbeddedFileComponent = (ON_ModelComponent::Type::Image == component_type); ONX_ModelComponentIterator it(model,component_type); unsigned int it_count = 0; for (ON_ModelComponentReference mcr = it.FirstComponentReference(); false == mcr.IsEmpty(); mcr = it.NextComponentReference()) { const ON_ModelComponent* model_component = mcr.ModelComponent(); if (nullptr == model_component) { ON_ERROR("Iterator returned nullptr mcr.ModelComponent()"); continue; } if (model_component->ComponentType() != component_type) { ON_ERROR("Iterator returned wrong mcr.ModelComponent()->ComponentType()"); continue; } const ON__UINT64 model_component_sn = model_component->RuntimeSerialNumber(); const ON_UUID model_component_id = model_component->Id(); if (0 == model_component_sn) { ON_ERROR("Iterator mcr.ModelComponent()->RuntimeSerialNumber() is zero."); continue; } if (ON_nil_uuid == model_component_id) { ON_ERROR("Iterator mcr.ModelComponent()->Id() is nil."); continue; } const ON_SerialNumberMap::SN_ELEMENT* e_sn = it_map.FindSerialNumber(model_component_sn); if (nullptr != e_sn) { ON_ERROR("Iterator returned component serial number twice."); continue; } const ON_SerialNumberMap::SN_ELEMENT* e_id = it_map.FindId(model_component_id); if (nullptr != e_id) { ON_ERROR("Iterator returned component id twice."); continue; } ON_SerialNumberMap::SN_ELEMENT* e = it_map.AddSerialNumberAndId(model_component_sn,model_component_id); if (nullptr == e) { ON_ERROR("ON_SerialNumberMap failed to add sn and id."); continue; } if (e->m_value.m_u_type != 0) { ON_ERROR("ON_SerialNumberMap error."); continue; } e->m_value.m_u_type = 1; e->m_value.m_u.ptr = (void*)model_component; const ON_ComponentManifestItem& item = manifest.ItemFromComponentRuntimeSerialNumber(model_component_sn); if (item.IsUnset()) { ON_ERROR("Iterator returned item not in manifest."); continue; } if (model_component_sn != item.ComponentRuntimeSerialNumber()) { ON_ERROR("manifest.ItemFromComponentRuntimeSerialNumber() error."); continue; } if (model_component_id != item.Id()) { ON_ERROR("item has wrong id."); continue; } const ON_ComponentManifestItem& item_id = manifest.ItemFromId(model_component_id); if (&item != &item_id) { ON_ERROR("manifest.ItemFromId() failed."); continue; } if (bUniqueNameRequired || bEmbeddedFileComponent) { const ON_Bitmap* embedded_file_reference = bEmbeddedFileComponent ? ON_Bitmap::Cast(model_component) : nullptr; const ON_NameHash full_path_hash = (nullptr != embedded_file_reference) ? ON_NameHash::CreateFilePathHash(embedded_file_reference->FileReference()) : ON_NameHash::EmptyNameHash; const ON_NameHash name_hash =bEmbeddedFileComponent ? full_path_hash : model_component->NameHash(); if (false == name_hash.IsValidAndNotEmpty()) { ON_ERROR("model compoent name is not valid."); continue; } if (name_hash != item.NameHash()) { ON_ERROR("item has wrong name hash."); continue; } const ON_ComponentManifestItem& item_name = manifest.ItemFromNameHash(component_type,name_hash); if (&item != &item_name) { ON_ERROR("manifest.ItemFromNameHash() failed."); continue; } } it_count++; } if (it_count != manifest.ActiveAndDeletedComponentCount(component_type)) { ON_ERROR("iterator count != manifest.ActiveAndDeletedComponentCount(component_type)"); continue; } } text_log.PopIndent(); error_counter.AddLibraryErrorsAndWarnings(); return error_counter; }
static const ONX_ErrorCounter Internal_TestReadFolder( ON_TextLog& text_log, const wchar_t* directory_path, unsigned int directory_tree_depth, bool bVerbose, Internal_CTestContext& test_context ) { ONX_ErrorCounter error_counter; error_counter.ClearLibraryErrors(); if (nullptr == directory_path || 0 == directory_path[0]) { text_log.Print(L"Empty directory name.\n"); } ON_FileIterator fit; if (false == fit.Initialize(directory_path)) { text_log.Print( L"Invalid directory name: %ls\n", directory_path ); error_counter.IncrementFailureCount(); return error_counter; } const ON_wString text_log_directory_name = (directory_tree_depth <= 1) ? ON_wString(directory_path) : test_context.TextLogPathFromFullPath(directory_path); text_log.Print( L"Directory name: %ls\n", static_cast<const wchar_t*>(text_log_directory_name) ); text_log.PushIndent(); ON_ClassArray< ON_wString > sub_directories(32); ON_ClassArray< ON_wString > skipped_files(32); ON_ClassArray< ON_wString > tested_files(32); for ( bool bHaveItem = fit.FirstItem(); bHaveItem; bHaveItem = fit.NextItem() ) { if ( test_context.m_max_file_count > 0 && test_context.m_file_count >= test_context.m_max_file_count) break; if (fit.CurrentItemIsDirectory()) { if (directory_tree_depth < test_context.m_max_directory_tree_depth) { sub_directories.Append(fit.CurrentItemFullPathName()); } continue; } ON_wString fullpath = fit.CurrentItemFullPathName(); if (ON_FileStream::Is3dmFile(fullpath, false)) tested_files.Append(fullpath); else skipped_files.Append(fullpath); } // sort file and folder names so test order depends only on content. // This is required so results from different computers can be compared. sub_directories.QuickSort(Internal_ComparePath); skipped_files.QuickSort(Internal_ComparePath); tested_files.QuickSort(Internal_ComparePath); if (skipped_files.Count() > 0) { text_log.PrintNewLine(); for (int i = 0; i < skipped_files.Count(); i++) { const ON_wString path_to_print = test_context.TextLogPathFromFullPath(skipped_files[i]); text_log.Print( L"Skipped file: %ls\n", static_cast<const wchar_t*>(path_to_print) ); } text_log.PrintNewLine(); } for ( int i = 0; i < tested_files.Count(); i++ ) { const ON_wString full_path = tested_files[i]; const ON_wString path_to_print = test_context.TextLogPathFromFullPath(full_path); test_context.m_file_count++; const ONX_ErrorCounter file_error_counter = Internal_TestFileRead(text_log, full_path, path_to_print, bVerbose); error_counter += file_error_counter; } for (int i = 0; i < sub_directories.Count(); i++) { if (test_context.m_max_file_count > 0 && test_context.m_file_count >= test_context.m_max_file_count) break; const ON_wString sub_directory_path = sub_directories[i]; test_context.m_directory_count++; error_counter += Internal_TestReadFolder(text_log, sub_directory_path, directory_tree_depth + 1, bVerbose, test_context); } text_log.PopIndent(); return error_counter; }
int main(int argc, const char *argv[]) { // If you are using OpenNURBS as a Windows DLL, then you MUST use // ON::OpenFile() to open the file. If you are not using OpenNURBS // as a Windows DLL, then you may use either ON::OpenFile() or fopen() // to open the file. int argi; if (argc < 2) { Usage(argv[0]); return 0; } // Call once in your application to initialze opennurbs library ON::Begin(); int version = 0; // write current Rhino file // default dump is to stdout ON_TextLog dump_to_stdout; ON_TextLog* dump = &dump_to_stdout; ON_String input; ON_String output; ON_String logfile; for (argi = 1; argi < argc; argi++) { ON_String arg(argv[argi]); if (arg.Left(10).CompareOrdinal("--version=", true) == 0) { arg = arg.Mid(10); version = atoi(arg); continue; } if (arg.Left(2).CompareOrdinal("/v", true) == 0 || arg.Left(2).CompareOrdinal("-v", true) == 0) { argi++; const char* sversion = argv[argi]; version = atoi(sversion); continue; } if (arg.Left(6).CompareOrdinal("--log=", true) == 0) { arg = arg.Mid(6); logfile = arg; continue; } if (input.IsEmpty()) { input = arg; if (false == ON_FileStream::Is3dmFile(input, true)) { input = ON_String::EmptyString; break; } continue; } if (output.IsEmpty()) { output = arg; continue; } // Invalid command line parameter input = ON_String::EmptyString; output = ON_String::EmptyString; break; } if (input.IsEmpty() || output.IsEmpty()) { Usage(argv[0]); return 1; } dump->Print("\nOpenNURBS Archive File: %s\n", static_cast<const char*>(input) ); // open file containing opennurbs archive FILE* archive_fp = ON_FileStream::Open3dmToRead(input); if (nullptr == archive_fp) { dump->Print(" Unable to open file.\n"); return 1; } dump->PushIndent(); // create achive object from file pointer ON_BinaryFile archive(ON::archive_mode::read3dm, archive_fp); // read the contents of the file into "model" ONX_Model model; bool rc = model.Read(archive, dump); // close the file ON::CloseFile(archive_fp); if (false == rc) { dump->Print("Errors during reading.\n"); return 1; } if (HasErrorsOrWarnings(dump, "reading input file")) return 1; // print diagnostic dump->Print("Successfully read.\n"); // Write file model.m_sStartSectionComments = "Converted by example_convert.exe"; bool outrc = model.Write(output, version, dump); if (HasErrorsOrWarnings(dump, "writing output file")) return 1; if (outrc) { dump->Print("model.Write(%s) succeeded.\n", static_cast<const char*>(output)); ONX_Model model2; if (model2.Read(output, dump)) { dump->Print("model2.Read(%s) succeeded.\n", static_cast<const char*>(output)); if (HasErrorsOrWarnings(dump, "verifying output file")) return 1; if (!logfile.IsEmpty()) { FILE* fp = ON::OpenFile(logfile, "w"); ON_TextLog log(fp); model2.Dump(log); ON::CloseFile(fp); } } else { dump->Print("model2.Read(%s) failed.\n", static_cast<const char*>(output)); } dump->PopIndent(); } // OPTIONAL: Call just before your application exits to clean // up opennurbs class definition information. // Opennurbs will not work correctly after ON::End() // is called. ON::End(); return 0; }
void ON_PX_EVENT::Dump(ON_TextLog& text_log) const { text_log.Print("m_type: "); switch (m_type) { case ON_PX_EVENT::no_px_event: text_log.Print("no_px_event"); break; case ON_PX_EVENT::ppx_point: text_log.Print("ppx_point"); break; case ON_PX_EVENT::pcx_point: text_log.Print("pcx_point"); break; case ON_PX_EVENT::psx_point: text_log.Print("psx_point"); break; default: text_log.Print("illegal value"); break; } text_log.Print("\n"); text_log.PushIndent(); text_log.Print("Intersection Point: \n"); text_log.PushIndent(); text_log.Print(m_Mid); text_log.Print("\n"); text_log.PopIndent(); text_log.Print("With uncertainty radius: \n"); text_log.PushIndent(); text_log.Print(m_radius); text_log.Print("\n"); text_log.PopIndent(); text_log.PopIndent(); text_log.Print("pointA = \n"); text_log.PushIndent(); text_log.Print(m_A); text_log.Print("\n"); text_log.PopIndent(); switch (m_type) { case ON_PX_EVENT::ppx_point: text_log.Print("pointB = \n"); break; case ON_PX_EVENT::pcx_point: text_log.Print("curveB("); text_log.Print(m_b[0]); text_log.Print(") = \n"); break; case ON_PX_EVENT::psx_point: text_log.Print("surfaceB"); text_log.Print(m_b); text_log.Print(" = \n"); break; case ON_PX_EVENT::no_px_event: break; } text_log.PushIndent(); text_log.Print(m_B); text_log.Print("\n"); text_log.PopIndent(); text_log.PopIndent(); }
/* Returns: True if .3dm file was successfully read into an ONX_Model class. */ static bool ReadFileHelper( const wchar_t* sFileName, bool bVerboseTextDump, bool bChunkDump, ON_TextLog& dump ) { if ( bChunkDump ) { return Dump3dmFileHelper(sFileName,dump); } ONX_Model model; dump.Print("\nOpenNURBS Archive File: %ls\n", sFileName ); // open file containing opennurbs archive FILE* archive_fp = ON::OpenFile( sFileName, L"rb"); if ( !archive_fp ) { dump.Print(" Unable to open file.\n" ); return false; } dump.PushIndent(); // create achive object from file pointer ON_BinaryFile archive( ON::read3dm, archive_fp ); // read the contents of the file into "model" bool rc = model.Read( archive, &dump ); // close the file ON::CloseFile( archive_fp ); // print diagnostic if ( rc ) dump.Print("Successfully read.\n"); else dump.Print("Errors during reading.\n"); // see if everything is in good shape if ( model.IsValid(&dump) ) { dump.Print("Model is valid.\n"); } else { dump.Print("Model is not valid.\n"); } // create a text dump of the model if ( bVerboseTextDump ) { dump.PushIndent(); model.Dump(dump); dump.PopIndent(); } // destroy this model model.Destroy(); dump.PopIndent(); return rc; }
void ON_MassProperties::Dump( ON_TextLog& dump ) const { const char* sMass = 0; switch( m_mass_type ) { case 1: sMass = "Length"; break; case 2: sMass = "Area"; break; case 3: sMass = "Volume"; break; } if ( 0 == sMass ) { dump.Print("Invalid mass properties.\n"); } else { dump.Print("%s mass properties:\n",sMass); dump.PushIndent(); if ( m_bValidMass ) dump.Print("%s = %g (+/- %g)\n",sMass,m_mass,m_mass_err); if ( m_bValidCentroid ) dump.Print("Centroid = (%g,%g,%g) (+/- %g,%g,%g)\n", m_x0,m_y0,m_z0,m_x0_err,m_y0_err,m_z0_err); if ( m_bValidFirstMoments ) { dump.Print("First moments:\n"); dump.PushIndent(); dump.Print("x: %g (+/- %g)\n",m_world_x,m_world_x_err); dump.Print("y: %g (+/- %g)\n",m_world_y,m_world_y_err); dump.Print("z: %g (+/- %g)\n",m_world_z,m_world_z_err); dump.PopIndent(); } if ( m_bValidSecondMoments ) { dump.Print("Second moments about world coordinate axes\n"); dump.PushIndent(); dump.Print("xx: %g (+/- %g)\n",m_world_xx,m_world_xx_err); dump.Print("yy: %g (+/- %g)\n",m_world_yy,m_world_yy_err); dump.Print("zz: %g (+/- %g)\n",m_world_zz,m_world_zz_err); dump.PopIndent(); dump.Print("Second moments about centroid coordinate axes\n"); dump.PushIndent(); dump.Print("xx: %g (+/- %g)\n",m_ccs_xx,m_ccs_xx_err); dump.Print("yy: %g (+/- %g)\n",m_ccs_yy,m_ccs_yy_err); dump.Print("zz: %g (+/- %g)\n",m_ccs_zz,m_ccs_zz_err); dump.PopIndent(); } if ( m_bValidProductMoments ) { dump.Print("Product moments about world coordinate axes\n"); dump.PushIndent(); dump.Print("xy: %g (+/- %g)\n",m_world_xy,m_world_xy_err); dump.Print("yz: %g (+/- %g)\n",m_world_yz,m_world_yz_err); dump.Print("zx: %g (+/- %g)\n",m_world_zx,m_world_zx_err); dump.PopIndent(); dump.Print("Product moments about centroid coordinate axes\n"); dump.PushIndent(); dump.Print("xy: %g (+/- %g)\n",m_ccs_xy,m_ccs_xy_err); dump.Print("yz: %g (+/- %g)\n",m_ccs_yz,m_ccs_yz_err); dump.Print("zx: %g (+/- %g)\n",m_ccs_zx,m_ccs_zx_err); dump.PopIndent(); } double Ixx, Iyy, Izz; ON_3dVector X, Y, Z; if ( CentroidCoordPrincipalMoments( &Ixx, X, &Iyy, Y, &Izz, Z ) ) { dump.Print("Principal moments and axes:\n"); dump.Print("Ixx: %g (%g,%g,%g)\n",Ixx,X.x,X.y,X.z); dump.Print("Iyy: %g (%g,%g,%g)\n",Iyy,Y.x,Y.y,Y.z); dump.Print("Izz: %g (%g,%g,%g)\n",Izz,Z.x,Z.y,Z.z); dump.PopIndent(); } if ( m_bValidSecondMoments && m_bValidMass && m_mass > 0.0 ) { ON_3dVector I, R; I = WorldCoordMomentsOfInertia(); R = WorldCoordRadiiOfGyration(); dump.Print("Moments of inertia about world coordinate axes\n"); dump.PushIndent(); dump.Print("Ix: %g\n",I.x); dump.Print("Iy: %g\n",I.y); dump.Print("Iz: %g\n",I.z); dump.PopIndent(); dump.Print("Radii of gyration about world coordinate axes\n"); dump.PushIndent(); dump.Print("Rx: %g\n",R.x); dump.Print("Ry: %g\n",R.y); dump.Print("Rz: %g\n",R.z); dump.PopIndent(); I = CentroidCoordMomentsOfInertia(); R = CentroidCoordRadiiOfGyration(); dump.Print("Moments of inertia about centroid coordinate axes\n"); dump.PushIndent(); dump.Print("Ix: %g\n",I.x); dump.Print("Iy: %g\n",I.y); dump.Print("Iz: %g\n",I.z); dump.PopIndent(); dump.Print("Radii of gyration about centroid coordinate axes\n"); dump.PushIndent(); dump.Print("Rx: %g\n",R.x); dump.Print("Ry: %g\n",R.y); dump.Print("Rz: %g\n",R.z); dump.PopIndent(); } dump.PopIndent(); } }
void ON_InstanceDefinition::Dump( ON_TextLog& text_log ) const { const wchar_t* wsIDefName = m_name; if ( 0 == wsIDefName ) wsIDefName = L""; text_log.Print("Name: \"%ls\"\n",wsIDefName); text_log.Print("Type: "); switch(m_idef_update_type) { case ON_InstanceDefinition::static_def: text_log.Print("embedded."); break; case ON_InstanceDefinition::embedded_def: if ( m_source_archive.Length() > 0 ) text_log.Print("OBSOLETE embedded_def with non-empty source archive - should be linked_and_embedded_def."); else text_log.Print("OBSOLETE embedded_def with empty source archive - should be static_def."); break; case ON_InstanceDefinition::linked_and_embedded_def: text_log.Print("embedded and linked - definition from source archive."); break; case ON_InstanceDefinition::linked_def: text_log.Print("linked - definition from source archive."); break; default: text_log.Print("not valid"); break; } text_log.Print("\n"); text_log.Print("Id: "); text_log.Print(m_uuid); text_log.Print("\n"); const wchar_t* wsDescription = m_description; if ( 0 != wsDescription && 0 != wsDescription[0]) text_log.Print("Description: \"%ls\"\n",wsDescription); const wchar_t* wsURL = m_url; if ( 0 != wsURL && 0 != wsURL[0]) text_log.Print("URL: \"%ls\"\n",wsURL); const wchar_t* wsTag = m_url_tag; if ( 0 != wsTag && 0 != wsTag[0]) text_log.Print("URL tag: \"%ls\"\n",wsTag); m_us.Dump(text_log); const wchar_t* wsSourceArchive = SourceArchive(); text_log.Print("Source archive: "); if ( 0 == wsSourceArchive || 0 == wsSourceArchive[0] ) { text_log.Print("none.\n"); } else { bool bRel = m_source_bRelativePath; text_log.Print("\"%ls\" (%s)\n",wsSourceArchive,bRel?"relative":"absolute"); text_log.PushIndent(); ON_wString str; bRel = false; if ( GetAlternateSourceArchivePath(str,bRel) ) { const wchar_t* wsAlternateArchive = str; if ( 0 == wsAlternateArchive || 0 == wsAlternateArchive[0] ) wsAlternateArchive = L""; text_log.Print("Alternate archive: \"%ls\" (%s)\n",wsAlternateArchive,bRel?"relative":"absolute"); } text_log.Print("Update depth: %d\n",m_idef_update_type); text_log.Print("Archive "); m_source_archive_checksum.Dump(text_log); text_log.PopIndent(); } const int id_count = m_object_uuid.Count(); text_log.Print("Contains: %d objects\n",id_count); if ( id_count > 0 ) { text_log.PushIndent(); text_log.Print(m_object_uuid[0]); text_log.Print("\n"); if ( id_count > 4 ) { text_log.Print("...\n"); } else { for ( int i = 1; i < id_count; i++ ) { text_log.Print(m_object_uuid[i]); text_log.Print("\n"); } } text_log.PopIndent(); } m_bbox.Dump(text_log); }
void ON_X_EVENT::Dump(ON_TextLog& text_log) const { int j; text_log.Print("m_type: "); switch( m_type ) { case ON_X_EVENT::no_x_event: text_log.Print("no_x_event"); break; case ON_X_EVENT::ccx_point: text_log.Print("ccx_point"); break; case ON_X_EVENT::ccx_overlap: text_log.Print("ccx_overlap"); break; case ON_X_EVENT::csx_point: text_log.Print("csx_point"); break; case ON_X_EVENT::csx_overlap: text_log.Print("csx_overlap"); break; default: text_log.Print("illegal value"); break; } text_log.Print("\n"); text_log.PushIndent(); switch( m_type ) { case ON_X_EVENT::ccx_point: case ON_X_EVENT::csx_point: // don't use %g so the text_log double format can control display precision text_log.Print("curveA("); text_log.Print(m_a[0]); text_log.Print(") = \n"); text_log.PushIndent(); text_log.Print(m_A[0]); text_log.Print("\n"); text_log.PopIndent(); break; case ON_X_EVENT::ccx_overlap: case ON_X_EVENT::csx_overlap: // don't use %g so the text_log double format can control display precision text_log.Print("curveA("); text_log.Print(m_a[0]); text_log.Print(" to "); text_log.Print(m_a[1]); text_log.Print(") = \n"); text_log.PushIndent(); text_log.Print(m_A[0]); text_log.Print(" to "); text_log.Print(m_A[1]); text_log.Print("\n"); text_log.PopIndent(); break; case ON_X_EVENT::no_x_event: break; } switch( m_type ) { case ON_X_EVENT::ccx_point: // don't use %g so the text_log double format can control display precision text_log.Print("curveB("); text_log.Print(m_b[0]); text_log.Print(") = \n"); text_log.PushIndent(); text_log.Print(m_B[0]); text_log.Print("\n"); text_log.PopIndent(); DumpDistanceABHelper(text_log,m_A[0],m_B[0]); break; case ON_X_EVENT::csx_point: // don't use %g so the text_log double format can control display precision text_log.Print("surfaceB"); text_log.Print(ON_2dPoint(m_b[0],m_b[1])); text_log.Print(" = \n"); text_log.PushIndent(); text_log.Print(m_B[0]); text_log.Print("\n"); text_log.PopIndent(); DumpDistanceABHelper(text_log,m_A[0],m_B[0]); break; case ON_X_EVENT::ccx_overlap: // don't use %g so the text_log double format can control display precision text_log.Print("curveB("); text_log.Print(m_b[0]); text_log.Print(" to "); text_log.Print(m_b[1]); text_log.Print(") = \n"); text_log.PushIndent(); text_log.Print(m_B[0]); text_log.Print(" to "); text_log.Print(m_B[1]); text_log.Print("\n"); text_log.PopIndent(); DumpDistanceABHelper(text_log,m_A[0],m_B[0],m_A[1],m_B[1]); break; case ON_X_EVENT::csx_overlap: // don't use %g so the text_log double format can control display precision text_log.Print("surface("); text_log.Print(ON_2dPoint(m_b[0],m_b[1])); text_log.Print(" to "); text_log.Print(ON_2dPoint(m_b[2],m_b[3])); text_log.Print(") = \n"); text_log.PushIndent(); text_log.Print(m_B[0]); text_log.Print(" to "); text_log.Print(m_B[1]); text_log.Print("\n"); text_log.PopIndent(); DumpDistanceABHelper(text_log,m_A[0],m_B[0],m_A[1],m_B[1]); break; case ON_X_EVENT::no_x_event: break; } text_log.Print("m_dirA[] = ("); for ( j = 0; j < 2; j++ ) { if (j) { text_log.Print(", "); } switch(m_dirA[j]) { case ON_X_EVENT::no_x_dir: text_log.Print("no_x_dir"); break; case ON_X_EVENT::at_end_dir: text_log.Print("at_end_dir"); break; case ON_X_EVENT::from_above_dir: text_log.Print("from_above_dir"); break; case ON_X_EVENT::from_below_dir: text_log.Print("from_below_dir"); break; case ON_X_EVENT::from_on_dir: text_log.Print("from_on_dir"); break; case ON_X_EVENT::to_above_dir: text_log.Print("to_above_dir"); break; case ON_X_EVENT::to_below_dir: text_log.Print("to_below_dir"); break; case ON_X_EVENT::to_on_dir: text_log.Print("to_on_dir"); break; default: text_log.Print("illegal value"); break; } } text_log.Print(")\n"); #if defined(OPENNURBS_PLUS_INC_) switch( m_type ) { case ON_X_EVENT::ccx_point: case ON_X_EVENT::ccx_overlap: text_log.Print("cnodeA sn = %d,%d ",m_cnodeA[0]?m_cnodeA[0]->m_nodesn:-1,m_cnodeA[1]?m_cnodeA[1]->m_nodesn:-1); text_log.Print("cnodeB sn = %d,%d\n",m_cnodeB[0]?m_cnodeB[0]->m_nodesn:-1,m_cnodeB[1]?m_cnodeB[1]->m_nodesn:-1); break; case ON_X_EVENT::csx_point: case ON_X_EVENT::csx_overlap: text_log.Print("cnodeA sn = %d,%d ",m_cnodeA[0]?m_cnodeA[0]->m_nodesn:-1,m_cnodeA[1]?m_cnodeA[1]->m_nodesn:-1); text_log.Print("snodeB sn = %d,%d\n",m_snodeB[0]?m_snodeB[0]->m_nodesn:-1,m_snodeB[1]?m_snodeB[1]->m_nodesn:-1); break; } #endif text_log.PopIndent(); }
int main( int argc, const char *argv[] ) { // If you are using OpenNURBS as a Windows DLL, then you MUST use // ON::OpenFile() to open the file. If you are not using OpenNURBS // as a Windows DLL, then you may use either ON::OpenFile() or fopen() // to open the file. int argi; if ( argc < 2 ) { printf("Syntax: %s [-out:outputfilename.txt] file1.3dm file2.3dm ...\n",argv[0] ); return 0; } // Call once in your application to initialze opennurbs library ON::Begin(); // default dump is to stdout ON_TextLog dump_to_stdout; ON_TextLog* dump = &dump_to_stdout; FILE* dump_fp = 0; ONX_Model model; for ( argi = 1; argi < argc; argi++ ) { const char* arg = argv[argi]; // check for -out or /out option if ( ( 0 == strncmp(arg,"-out:",5) || 0 == strncmp(arg,"/out:",5) ) && arg[5] ) { // change destination of dump file const char* sDumpFilename = arg+5; FILE* text_fp = ON::OpenFile(sDumpFilename,"w"); if ( text_fp ) { if ( dump_fp ) { delete dump; ON::CloseFile(dump_fp); } dump_fp = text_fp; dump = new ON_TextLog(dump_fp); } continue; } const char* sFileName = arg; dump->Print("\nOpenNURBS Archive File: %s\n", sFileName ); // open file containing opennurbs archive FILE* archive_fp = ON::OpenFile( sFileName, "rb"); if ( !archive_fp ) { dump->Print(" Unable to open file.\n" ); continue; } dump->PushIndent(); // create achive object from file pointer ON_BinaryFile archive( ON::read3dm, archive_fp ); // read the contents of the file into "model" bool rc = model.Read( archive, dump ); // close the file ON::CloseFile( archive_fp ); // print diagnostic if ( rc ) dump->Print("Successfully read.\n"); else dump->Print("Errors during reading.\n"); // see if everything is in good shape if ( model.IsValid(dump) ) dump->Print("Model is valid.\n"); else { model.Polish(); if ( model.IsValid() ) { dump->Print("Model is valid after calling Polish().\n"); } else { dump->Print("Model is not valid.\n"); } } /* int oi = 14; if ( oi >=0 && oi < model.m_object_table.Count() ) { dump->Print("m_object_table[%d].m_object:\n",oi); dump->PushIndent(); model.m_object_table[oi].m_object->Dump(*dump); dump->PopIndent(); } */ int version = 0; // write current Rhino file ON_String outfile = sFileName; int len = outfile.Length() - 4; outfile.SetLength(len); outfile += "_roundtrip.3dm"; bool outrc = model.Write( outfile, version, "roundtrip", dump ); if ( outrc ) { dump->Print("model.Write(%s) succeeded.\n",outfile.Array()); ONX_Model model2; if ( model2.Read( outfile, dump ) ) { dump->Print("model2.Read(%s) succeeded.\n",outfile.Array()); if ( model2.IsValid(dump) ) { dump->Print("Model2 is valid.\n"); } else { dump->Print("Model2 is not valid.\n"); } /* if ( oi >=0 && oi < model2.m_object_table.Count() ) { dump->Print("m_object_table[%d].m_object:\n",oi); dump->PushIndent(); model2.m_object_table[oi].m_object->Dump(*dump); dump->PopIndent(); } */ } else { dump->Print("model2.Read(%s) failed.\n",outfile.Array()); } } else dump->Print("model.Write(%s) failed.\n",outfile.Array()); // destroy this model model.Destroy(); dump->PopIndent(); } if ( dump_fp ) { // close the text dump file delete dump; ON::CloseFile( dump_fp ); } // OPTIONAL: Call just before your application exits to clean // up opennurbs class definition information. // Opennurbs will not work correctly after ON::End() // is called. ON::End(); return 0; }