/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #ifndef NWGEOMETRYIMPORT_H #define NWGEOMETRYIMPORT_H #include "TD_PackPush.h" #define STL_USING_LIST #define STL_USING_MAP #define STL_USING_FUNCTIONAL #define STL_USING_STACK #define STL_USING_MEMORY #include "OdaSTL.h" #include //tv #include "TvLayer.h" #include "TvDatabase.h" //nw #include "NwObject.h" #include "NwModelUnits.h" #include "NwMaterialImport.h" class OdPerfTimerBase; class OdNwMaterialAttribute; typedef OdSmartPtr OdNwMaterialAttributePtr; class OdNwGraphicMaterialAttribute; typedef OdSmartPtr OdNwGraphicMaterialAttributePtr; typedef std::pair OdNwMaterial2TvNode; //from animation typedef std::map > mapNwObjId2TvIdsType; class OdNwGeometryImport { public: //nw2visualize properties struct ImportProperties { bool m_isNeedCDATree; bool m_isStoreSourceObjects; bool m_isLowMemoryImportToVSF; bool m_isNeedGroupsUsing; bool m_isImportRefGeomAsInserts; bool m_isImportRecap; bool m_isImportRecapAsRcsPointCloud; std::function m_clbkFindReference; }; public: OdNwGeometryImport(const OdTvDatabaseId& tvDatabaseId, OdPerfTimerBase* pTvTimer, double& nTotalTvTime, ODCOLORREF* pDefColor, ImportProperties&& importProps, const OdString& sReflEnv, mapNwObjId2TvIdsType* mNwId2TvIds, NwModelUnits::Enum nwModelUnits, const OdNwObjectId& nwMatElId, std::function getTempFilePath); public: //start traversing by logical hierarchy tree from NwDatabase void importLH(const OdNwObjectId& nwModelItemRootId, OdTvModelId tvModelId); protected: struct OdGeometryData { OdGeometryData(bool isSolid) : isSolid(isSolid) {} OdGeometryData(const OdGeometryData& other) : occurencesNum(other.occurencesNum), isReferencedGeom(other.isReferencedGeom), isSolid(other.isSolid) { } OdUInt32 occurencesNum = 1; OdString blockName; bool isReferencedGeom = false; bool isSolid; }; //recursive function for processing logical hierarchy node void goThroughtLHTree(const OdNwObjectId& nwModelItemId, const OdTvModelId& tvModelId, std::map& geometryMap); //append tv entity object by model item OdTvEntityPtr appendEntity(const OdNwObjectId& nwModelItemId, const OdTvModelId& tvModelId, const OdTvMatrix& trm, OdTvMaterialDef tvMatDef, OdTvVisibilityDef tvVisDef); OdTvGroupPtr appendGroup(const OdNwObjectId& nwModelItemId, const OdTvModelId& tvModelId, const OdTvMatrix& trm, OdTvMaterialDef tvMatDef, OdTvVisibilityDef tvVisDef); //append tv insert object by model item void appendInsert(const OdNwObjectId& nwInsId, const OdTvModelId& tvModelId, const OdTvMatrix& insTrm, OdTvMaterialDef tvMatDef, OdTvLayerId tvLayerId, bool isHidden); OdTvEntityId createInsertByBlock(const OdNwObjectId& nwInsId, const OdTvBlockId& tvBlockId, const OdTvModelId& tvModelId, const OdString& insName, const OdTvMatrix& insTrm, OdTvMaterialDef tvMatDef, OdTvLayerId tvLrId, OdTvVisibilityDef tvVisib); void createEntitiesFromNwComponent(const OdNwObjectId& nwCompId, std::map&geometryMap, std::function setTrm); //method for appending geometry data from nw database into tv entity template void appendGeomDataToEntity(const OdNwObjectId& nwGeomId, T pTvEntity, bool isSolid); OdTvMaterialId importMaterial(const OdNwMaterial2TvNode& nwMat2TvNode); private: void collectGeometryInfo(const OdNwObjectId& nwModelItemId, std::map& geometryRefCounter); //tv data OdTvDatabaseId m_tvDatabaseId; OdTvRegAppId m_regAppId; //tv timing OdPerfTimerBase* m_pTvTimer; double& m_nTotalTvTime; //for amimation import mapNwObjId2TvIdsType* m_mNwId2TvIds; ImportProperties m_ImportProperties; /*helper data for logical hierarchy traversing*/ //stack with tv objects in traverse branch, in the same time stack node must be one of - tv entity, tv subentity(tv geom data) or tv block //this branch is need for appending new tv objects in correct parent node std::stack > m_stTvEntBranch; //list with all not identity transformations in branch while traversing //using list structure is needed for calculation of end transform and compared it with nw fragments transformations std::list m_lNwTrsfmBranch; //list with all partition and sub partition transformation //using list for calculation first tranformation for tv objects which must be appended into tv model directly std::list m_lNwPartitionTrm; //help structure for saving insert model item node data struct Nw2TvInsBranchElement { OdNwObjectId m_nwInsMI;//object id of nw model item with icon type 'insert' OdUInt32 m_chldCnt;//count of insert model item children bool& m_popEntBranch;//reference to bool flag with necesering of removing top elemtn from m_stTvEntBranch in stack of method goThroughtLHTree for insert model item processing step OdTvEntityPtr m_pTvEnt;//pointer to tv entity which coreesponds for model item with nwInsMI, created if current model item does not meet the conditions of insert-block structure OdTvMatrix m_trsfm;//transformation of insert node OdTvMaterialId m_tvMatId;//tv material id of isnert node }; //list with insert data in branch while logical hierarchy traversing std::list m_lTvInsBranch; //current state of branch hiddines, remember only flags from model item which doesn't have correspond tv objects - collections, subpartitions and etc. bool m_bIsHiddenBranch; //real materials attribute for current level, contain only nearest parent material and texture attributes(use while traversing logical hierarchy) //OdNwMaterial2TvNode - is std::pair where first element is pointer to OdNwMaterialAttribute, and second is pointer to OdNwGraphicMaterialAttribute OdNwMaterial2TvNode m_curLevelMaterial; //map with link between model item object id and corresponded tv block std::map m_mTvBlocks; //class correct and fast nw material data import, with fast searching through already existed materials NwMaterialImport::OdNw2TvMaterialImport m_tvMaterialImporter; //current tv layer id, is used for setting layerd id for enities and inserts which appended into tv model directly OdTvLayerId m_tvCurLayerId; //nw partition units of the nearest partition NwModelUnits::Enum m_nwCurPartUnits; bool m_isPtCldAdded; OdUInt32 m_numRefGeomBlock; }; #include "TD_PackPop.h" #endif // NWGEOMETRYIMPORT_H