原創|行業資訊|編輯:吳秋紅|2023-07-11 09:53:26.667|閱讀 109 次
概述:本文介紹了如何用3D轉換工具HOOPS Exchange與LibConverter進行流緩存導出,希望對您有所幫助~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
如果您正在使用,您可能想在生成流緩存模型之前利用的高級功能和轉換選項。
如何使用
如您所知,LibConverter是HOOPS Communicator軟件包中包含的一個簡單的API,converter.exe實際上就是使用這個API。
項目mini_converter是使用該API的良好開端:
HOOPS_Communicator\authoring\converter\example\sample_projects\mini_converter
CAD文件——[HOOPS Exchange C API]——PRC ModelFile——[LibConverter]——SCS文件
實現這個工作流程最重要的API是在LibConvert中:
bool Communicator::Importer::Load (void * modelFile )
實施
您需要做的是:
要初始化和使用,您可以查看HOOPS Exchange包中的ImportExport示例。
類A3DSDKHOOPSExchangeLoader使API的使用更容易,我們在編程指南1中,展示了如何使用它:
A3DSDKHOOPSExchangeLoader sHoopsExchangeLoader(_T(HOOPS_BINARY_DIRECTORY)); A3DImport sImport(acSrcFileName); // see A3DSDKInternalConvert.hxx for import and export detailed parameters CHECK_RET(sHoopsExchangeLoader.Import(sImport));
調用導入函數后,PRC緩沖區將在sHoopsExchangeLoader.m_psModelFile中。
因此,您可以像這樣使用以后的LibConverter:
SC_Import_Options importOptions; importer.Load(sHoopsExchangeLoader.m_psModelFile); SC_Export_Options exportOptions; // Export SSC exporter.WriteSC(nullptr, output.c_str(), exportOptions);
樣本
使用A3DSDKHOOPSExchangeLoader這種結構隱藏了對API的實際調用,這使得它更簡單。但如果你只是做直接調用,那它不適合你,因為它需要更多的包含。
下面是一個示例來演示上述實現:
#include "libconverter.h" using namespace Communicator; ///TODO: Add the Additional include directory = "[...]/HOOPS_Exchange_Publish_2022_XX\include" #define INITIALIZE_A3D_API #include#include using namespace std; int main(int argc, char* argv[]) { ///TODO: the license variable is not used, you may pass "" as the first argument. ///USAGE: ./mini_converter "" "CAD/FILE/INPUT.CAD" "PATH/TO/SCS.SCS" string input, output; // Obtain the input and output filenames size_t n = 1; // Skip verb if (n < argc) input = argv[n++]; if (n < argc) output = argv[n++]; // Initiliaze HOOPS Exchange ///TODO: REPLACE THE PATH TO BIN\\WIN64_VC140 A3DStatus iRet; if (!A3DSDKLoadLibrary("HOOPS_Exchange_Publish_2022_SP1_U1\\bin\\win64_v140")) return A3D_ERROR; ///TODO: I'm using directly the HOOPS_LICENSE variable defined in hoops_license.h. The license you generate on our developer zone is unified, //that means it works with HOOPS COmmunicator, HOOPS Exchange, LibConverter, etc... A3DLicPutUnifiedLicense(HOOPS_LICENSE); A3DInt32 iMajorVersion = 0, iMinorVersion = 0; iRet = A3DDllGetVersion(&iMajorVersion, &iMinorVersion); if (iRet != A3D_SUCCESS) return iRet; iRet = A3DDllInitialize(A3D_DLL_MAJORVERSION, A3D_DLL_MINORVERSION); if (iRet != A3D_SUCCESS) return iRet; // Import A3DAsmModelFile* m_psModelFile; A3DRWParamsLoadData m_sLoadData; A3D_INITIALIZE_DATA(A3DRWParamsLoadData, m_sLoadData); m_sLoadData.m_sGeneral.m_bReadSolids = true; m_sLoadData.m_sGeneral.m_bReadSurfaces = true; m_sLoadData.m_sGeneral.m_bReadWireframes = true; m_sLoadData.m_sGeneral.m_bReadPmis = true; m_sLoadData.m_sGeneral.m_bReadAttributes = true; m_sLoadData.m_sGeneral.m_bReadHiddenObjects = true; m_sLoadData.m_sGeneral.m_bReadConstructionAndReferences = false; m_sLoadData.m_sGeneral.m_bReadActiveFilter = true; m_sLoadData.m_sGeneral.m_eReadingMode2D3D = kA3DRead_3D; m_sLoadData.m_sGeneral.m_eReadGeomTessMode = kA3DReadGeomAndTess; m_sLoadData.m_sGeneral.m_eDefaultUnit = kA3DUnitUnknown; m_sLoadData.m_sTessellation.m_eTessellationLevelOfDetail = kA3DTessLODMedium; m_sLoadData.m_sAssembly.m_bUseRootDirectory = true; m_sLoadData.m_sMultiEntries.m_bLoadDefault = true; m_sLoadData.m_sPmi.m_bAlwaysSubstituteFont = false; m_sLoadData.m_sPmi.m_pcSubstitutionFont = (char*)"Myriad CAD"; iRet = A3DAsmModelFileLoadFromFile(input.c_str(), &m_sLoadData, &m_psModelFile); if (iRet != A3D_SUCCESS) return iRet; // HERE YOU CAN PROCESS m_psModelFile WITH HOOPS EXCHANGE ADVANCED FUNCTION Converter converter; // License Registration converter.Init(HOOPS_LICENSE); Importer importer; // Import Initialization if (!importer.Init(&converter)) return EXIT_FAILURE; //Import the PRC buffer directly SC_Import_Options importOptions; // Import if (!importer.Load(m_psModelFile)) return EXIT_FAILURE; Exporter exporter; // Export Initialization if (!exporter.Init(&importer)) return EXIT_FAILURE; SC_Export_Options exportOptions; // Export Stream Cache Model //export SCS if (!exporter.WriteSC(nullptr, output.c_str(), exportOptions)) return EXIT_FAILURE; return EXIT_SUCCESS; }
使用該工作流,您可以完全訪問m_sLoadData(導入選項)。它比converter.exe包含更多參數。您還可以在導出前對模型進行處理(例如,縫合修復BRep)。
------------------2023 HOOPS Exchange專場峰會火熱報名中 -----------------
2023 HOOPS Exchange專場峰會 ? 中國場
--------------------------------------------------------------------------------------------------------------------------
慧都科技是Tech Soft 3D-Hoops在中國區的唯一增值服務商,負責HOOPS試用,咨詢,銷售,技術支持,售后,旨在為企業提供一站式的3D開發解決方案。更多信息,請訪問(HOOPS Platform、CEETRON SDKS中國區獨家代理)。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn