/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "NwRecapExternalGeometryImpl.h" #include "NwRecapModule.h" #include "DynamicLinker.h" #include "NwGeometryExternal.h" #include "CommonSchema/NwSchema.h" #include "CommonSchema/NwSchemaInt32Field.h" #include "CommonSchema/NwSchemaGuidField.h" #include "RxObjectImpl.h" #include "RcsFileServices/RxRcsFileServices.h" #include "RcsFileServices/OdPointCloudScanDatabase.h" #include "RcsFileServices/OdPointCloudProjectDatabase.h" #include "RcsFileServices/OdRcsDataManager.h" #include "NwGeometryExternalPE.h" ODRX_CONS_DEFINE_MEMBERS(NwRecapAbstractExternalGeometryPE, OdNwAbstractExternalGeometryPE, RXIMPL_CONSTR); NwRecapAbstractExternalGeometryPE::NwRecapAbstractExternalGeometryPE() { } NwRecapAbstractExternalGeometryPE::~NwRecapAbstractExternalGeometryPE() { } OdResult NwRecapAbstractExternalGeometryPE::setStreamMap(const std::map& streamMap) { ODA_ASSERT_ONCE(!OD_T("The method is deprecated since release/25.9. Use method setFindReferenceCallback with 'lazy' map initialization instead.")); OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { pPointCloudImporter->setStreamMap(streamMap); } return eOk; } return eNullObjectPointer; } OdResult NwRecapAbstractExternalGeometryPE::setRcsService(OdRxRcsFileServicesPtr pRcsSrv) { OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { pPointCloudImporter->setRcsService(pRcsSrv); } return eOk; } return eNullObjectPointer; } OdResult NwRecapAbstractExternalGeometryPE::getPointCloud(const OdString& refName, const OdGUID& scanGuid, OdUInt64 voxIdx, OdGePoint3dArray& coords, OdCmEntityColorArray& colors) { ODA_ASSERT_ONCE(!OD_T("The method is deprecated since release/25.9. Use method getPointCloud(const OdNwGeometryExternal* pGeomExternal, OdGePoint3dArray& coords, OdCmEntityColorArray& colors) instead.")); OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { return pPointCloudImporter->getPointCloud(refName, scanGuid, voxIdx, coords, colors); } } return eNullObjectPointer; } OdResult NwRecapAbstractExternalGeometryPE::getPointCloud(const OdNwGeometryExternal* pGeomExternal, OdGePoint3dArray& coords, OdCmEntityColorArray& colors) { if (!pGeomExternal) return eNullPtr; OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { OdNwSchemaPtr pSchema = pGeomExternal->getSchemaData(); if (!pSchema.isNull()) { OdArray schemaFields; pSchema->getValue(schemaFields); OdInt32 voxIdx = -1; OdGUID guid; for (auto& sf : schemaFields) { const OdString& sfId = sf->getId(); if (sfId == OD_T("index")) { voxIdx = OdNwSchemaInt32Field::cast(sf)->getValue(); break; } else if (sfId == OD_T("guid")) { guid = OdNwSchemaGuidField::cast(sf)->getGuidValue(); } } if (voxIdx != -1) { return pPointCloudImporter->getPointCloud(pGeomExternal->getReference(), guid, voxIdx, coords, colors); } } else { return pPointCloudImporter->getPointCloud(pGeomExternal->getReference(), coords, colors); } } } return eNullObjectPointer; } OdGUID NwRecapAbstractExternalGeometryPE::getGuid(const OdNwGeometryExternal* pGeomExternal) { OdNwSchemaPtr pSchema = pGeomExternal->getSchemaData(); if (!pSchema.isNull()) { OdArray schemaFields; pSchema->getValue(schemaFields); for (auto& sf : schemaFields) { const OdString& sfId = sf->getId(); if (sfId == OD_T("guid")) { return OdNwSchemaGuidField::cast(sf)->getGuidValue(); } } } return OdGUID(); } OdResult NwRecapAbstractExternalGeometryPE::getPointCloud(const OdNwGeometryExternal* pGeomExternal, OdPointCloudScanDatabasePtr& pScanDb, OdPointCloudProjectDatabasePtr& pProjDb) { if (!pGeomExternal) return eNullPtr; OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { OdGUID guid = getGuid(pGeomExternal); return pPointCloudImporter->getPointCloud(pGeomExternal->getReference(), guid, pScanDb, pProjDb); } } return eNullObjectPointer; } OdResult NwRecapAbstractExternalGeometryPE::getPointCloud(const OdNwGeometryExternal* pGeomExternal, OdNwPointCloudData& pcData) { if (!pGeomExternal) return eNullPtr; OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { OdGUID guid = getGuid(pGeomExternal); return pPointCloudImporter->getPointCloud(pGeomExternal->getReference(), guid, pcData); } } return eNullObjectPointer; } OdResult NwRecapAbstractExternalGeometryPE::isStreamMapEmpty(bool& result) { ODA_ASSERT_ONCE(!OD_T("The method is deprecated since release/25.9. Use method setFindReferenceCallback with 'lazy' map initialization instead.")); OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { result = pPointCloudImporter->isStreamMapEmpty(); return eOk; } } return eNullObjectPointer; } OdResult NwRecapAbstractExternalGeometryPE::setFindReferenceCallback(std::function findReferenceCallback) { OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { pPointCloudImporter->setFindReferenceCallback(findReferenceCallback); return eOk; } } return eNullObjectPointer; } //=== RecapAbstractDBExternalGeometryPE === ODRX_CONS_DEFINE_MEMBERS(NwRecapAbstractDBExternalGeometryPE, OdNwAbstractDBExternalGeometryPE, RXIMPL_CONSTR); OdResult NwRecapAbstractDBExternalGeometryPE::setFindReferenceCallback(const OdRxObject* /*pThis*/, std::function findReferenceCallback) { OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { pPointCloudImporter->setFindReferenceCallback(findReferenceCallback); return eOk; } } return eNullObjectPointer; } OdStreamBufPtr NwRecapAbstractDBExternalGeometryPE::getEmbeddedStreamBuffer(const OdRxObject* /*pThis*/, const OdString& refName, const std::function& findReferenceCallback, bool create) { OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { return pPointCloudImporter->getEmbeddedStreamBuffer(refName, findReferenceCallback, create); } } return OdStreamBufPtr(); } void NwRecapAbstractDBExternalGeometryPE::resetCache(const OdRxObject* /*pThis*/) { OdNwRecapModulePtr pModule = odrxDynamicLinker()->getModule(OdNwRecapImportModuleName); if (!pModule.isNull()) { OdNwPointCloudPtr pPointCloudImporter = pModule->getNwPointCloud(); if (!pPointCloudImporter.isNull()) { pPointCloudImporter->resetCache(); } } }