/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// /************************************************************************/ /* This console application loads BCF 2.1 file. */ /* */ /* Calling sequence: */ /* */ /* ExBcf_2_1LoadFile */ /* */ /************************************************************************/ #include "OdaCommon.h" #include "StaticRxObject.h" #include "ExIfcHostAppServices.h" #include "IfcExamplesCommon.h" #include "BcfUtils.h" #include "Bcf_2_1GUIDAttribute.h" #include "Bcf_2_1Session.h" #include "Bcf_2_1DataAccessorXml.h" #include "Bcf_2_1Archive.h" #include "BcfArchiveFolder.h" #include "Bcf_2_1TopicFolder.h" #include "Bcf_2_1Markup.h" #include "Bcf_2_1Header.h" #include "Bcf_2_1Topic.h" #include "Bcf_2_1Comment.h" #include "BcfTimeStamp.h" #include "Bcf_2_1Viewpoint.h" #include "BcfToolsModule.h" #include "BcfLoader.h" // // Define module map for statically linked modules: // #ifndef _TOOLKIT_IN_DLL_ ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdSDAIModule); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdIfcCoreModule); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdBcfCommonModule); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdBcf_2_1Module); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdBcf_3_0Module); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdBcfToolsModule); ODRX_BEGIN_STATIC_MODULE_MAP() ODRX_DEFINE_STATIC_APPMODULE(OdSDAIModuleName, OdSDAIModule) ODRX_DEFINE_STATIC_APPMODULE(OdIfcCoreModuleName, OdIfcCoreModule) ODRX_DEFINE_STATIC_APPMODULE(OdBcfCommonModuleName, OdBcfCommonModule) ODRX_DEFINE_STATIC_APPMODULE(OdBcf_2_1ModuleName, OdBcf_2_1Module) ODRX_DEFINE_STATIC_APPMODULE(OdBcf_3_0ModuleName, OdBcf_3_0Module) ODRX_DEFINE_STATIC_APPMODULE(OdBcfToolsModuleName, OdBcfToolsModule) ODRX_END_STATIC_MODULE_MAP() #endif #if defined(OD_USE_WMAIN) int wmain(int argc, wchar_t* argv[]) #else int main(int argc, char* argv[]) #endif { /**********************************************************************/ /* Command line parameters description */ /**********************************************************************/ if(argc < 3) { odPrintConsoleString(OD_T("\nExBcf_2_1LoadFile sample program. Copyright (c) 2025, Open Design Alliance\n")); odPrintConsoleString(OD_T("\tusage: ExBcf_2_1LoadFile [workfolder]\n")); odPrintConsoleString(OD_T("\t - BCF 2.1 archive to open.\n")); odPrintConsoleString(OD_T("\t - write BCF file if outfilename is not empty.\n")); odPrintConsoleString(OD_T("\t [workfolder] - work folder for BCF archive content, optional.\n")); odPrintConsoleString(OD_T("\nPress ENTER to continue...\n")); return 1; } #ifndef _TOOLKIT_IN_DLL_ ODRX_INIT_STATIC_MODULE_MAP(); #endif // create a service OdStaticRxObject< MyServices > svcs; OdString fileName = argv[1]; OdString outFileName = argv[2]; OdString workFolder = argc > 3 ? argv[3] : svcs.getTemporaryPath(); /**********************************************************************/ /* Initialize Runtime Extension environment */ /**********************************************************************/ odrxInitialize(&svcs); /**********************************************************************/ /* Initialize BCF */ /**********************************************************************/ odBcfToolsInitialize(kVersionBcfAll); try { OdBcf::OdBcfDataAccessorPtr pDataAccessor = OdBcfTools::OdBcfLoader::openProject(fileName); if (pDataAccessor->getBcfFileVersion() == BcfVersionNumbers[kVersionBcf_2_1]) { OdBcf_2_1::OdBcfDataAccessorPtr pAccessor = OdBcf_2_1::OdBcfDataAccessorXml::cast(pDataAccessor); const OdBcf_2_1::OdBcfArchivePtr pArchive = pAccessor->getArchive(fileName); OdString rootDir = pArchive->getRootDir()->getFolder(); // // Dump topics // const OdBcf_2_1::OdBcfTopicFolderMap& topicFolders = pArchive->getTopics(); for (const auto& node : topicFolders) { OdString strGUID = node.first.toString(); odPrintConsoleString(OD_T("\nTopicFolder GUID: %s\n"), strGUID.c_str()); OdBcf_2_1::OdBcfTopicFolderPtr topicFolder = node.second; OdBcf_2_1::OdBcfMarkupPtr markup = topicFolder->getMarkup(); const OdBcf_2_1::OdBcfTopicPtr topic = markup->getTopic(); odPrintConsoleString(OD_T(" GUID: %s\n"), topic->getGuid().toString().c_str()); odPrintConsoleString(OD_T(" Title: %s\n"), topic->getTitle().c_str()); odPrintConsoleString(OD_T(" CreationAuthor: %s\n"), topic->getCreationAuthor().c_str()); odPrintConsoleString(OD_T(" Priority: %s\n"), topic->getPriority().c_str()); odPrintConsoleString(OD_T(" Index: %d\n"), topic->getIndex()); odPrintConsoleString(OD_T(" CreationDate: %s\n"), topic->getCreationDate()->toString().c_str()); if (!topic->getModifiedDate().isNull()) odPrintConsoleString(OD_T(" ModifiedDate: %s\n"), topic->getModifiedDate()->toString().c_str()); if (!topic->getDueDate().isNull()) odPrintConsoleString(OD_T(" DueDate: %s\n"), topic->getDueDate()->toString().c_str()); odPrintConsoleString(OD_T(" AssignedTo: %s\n"), topic->getAssignedTo().c_str()); odPrintConsoleString(OD_T(" Description: %s\n"), topic->getDescription().c_str()); const OdBcf_2_1::OdBcfCommentArray& comments = markup->getComment(); if (comments.size() > 0) { odPrintConsoleString(OD_T(" Comments (%d):\n"), comments.size()); for (const OdBcf_2_1::OdBcfCommentPtr& comment : comments) { odPrintConsoleString(OD_T(" Date: %s\n"), comment->getDate()->toString().c_str()); odPrintConsoleString(OD_T(" Author: %s\n"), comment->getAuthor().c_str()); odPrintConsoleString(OD_T(" Comment: %s\n"), comment->getComment().c_str()); const OdBcf_2_1::OdBcfGUIDAttributePtr viewpointGuidAttribute = comment->getViewpoint(); if (!viewpointGuidAttribute.isNull() && viewpointGuidAttribute->validate()) { odPrintConsoleString(OD_T(" Viewpoint GUID: %s (let's find into Markup.Viewpoints)\n"), viewpointGuidAttribute->getGuid().toString().c_str()); const OdBcf_2_1::OdBcfViewPointArray& viewPoints = markup->getViewpoints(); for (const auto& viewPoint : viewPoints) { if (viewPoint->getGuid() == viewpointGuidAttribute->getGuid()) { odPrintConsoleString(OD_T(" Index: %d\n"), viewPoint->getIndex()); odPrintConsoleString(OD_T(" Viewpoint: %s\n"), viewPoint->getViewpoint().c_str()); odPrintConsoleString(OD_T(" Snapshot: %s\n"), viewPoint->getSnapshot().c_str()); } } } // ... odPrintConsoleString(OD_T("\n")); } } odPrintConsoleString(OD_T("==================================\n")); } if (!outFileName.isEmpty()) { odPrintConsoleString(OD_T("Writing BCF Project to: %s..."), outFileName.c_str()); if (eOk == pAccessor->putArchive(outFileName, pArchive)) { odPrintConsoleString(OD_T(" ok\n")); } else { odPrintConsoleString(OD_T(" failed\n")); } } } else { throw("Unsupported file version"); } } catch (OdError& e) { odPrintConsoleString(OD_T("\nError: %ls\n"), e.description().c_str()); } catch (...) { odPrintConsoleString(OD_T("\nUnknown Error.\n")); } /**********************************************************************/ /* Uninitialize BCF */ /**********************************************************************/ odBcfToolsUninitialize(); /**********************************************************************/ /* Uninitialize Runtime Extension environment */ /**********************************************************************/ ::odrxUninitialize(); return 0; }