原創(chuàng)|行業(yè)資訊|編輯:吳秋紅|2023-07-11 09:53:26.667|閱讀 109 次
概述:本文介紹了如何用3D轉(zhuǎn)換工具HOOPS Exchange與LibConverter進(jìn)行流緩存導(dǎo)出,希望對您有所幫助~
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
如果您正在使用,您可能想在生成流緩存模型之前利用的高級功能和轉(zhuǎn)換選項(xiàng)。
如何使用
如您所知,LibConverter是HOOPS Communicator軟件包中包含的一個(gè)簡單的API,converter.exe實(shí)際上就是使用這個(gè)API。
項(xiàng)目mini_converter是使用該API的良好開端:
HOOPS_Communicator\authoring\converter\example\sample_projects\mini_converter
CAD文件——[HOOPS Exchange C API]——PRC ModelFile——[LibConverter]——SCS文件
實(shí)現(xiàn)這個(gè)工作流程最重要的API是在LibConvert中:
bool Communicator::Importer::Load (void * modelFile )
實(shí)施
您需要做的是:
要初始化和使用,您可以查看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));
調(diào)用導(dǎo)入函數(shù)后,PRC緩沖區(qū)將在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這種結(jié)構(gòu)隱藏了對API的實(shí)際調(diào)用,這使得它更簡單。但如果你只是做直接調(diào)用,那它不適合你,因?yàn)樗枰嗟陌?/span>
下面是一個(gè)示例來演示上述實(shí)現(xiàn):
#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(導(dǎo)入選項(xiàng))。它比converter.exe包含更多參數(shù)。您還可以在導(dǎo)出前對模型進(jìn)行處理(例如,縫合修復(fù)BRep)。
------------------2023 HOOPS Exchange專場峰會火熱報(bào)名中 -----------------
2023 HOOPS Exchange專場峰會 ? 中國場
--------------------------------------------------------------------------------------------------------------------------
慧都科技是Tech Soft 3D-Hoops在中國區(qū)的唯一增值服務(wù)商,負(fù)責(zé)HOOPS試用,咨詢,銷售,技術(shù)支持,售后,旨在為企業(yè)提供一站式的3D開發(fā)解決方案。更多信息,請?jiān)L問(HOOPS Platform、CEETRON SDKS中國區(qū)獨(dú)家代理)。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn