/////////////////////////////////////////////////////////////////////////////// // 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 NW2VISUALIZE_H #define NW2VISUALIZE_H #include "TD_PackPush.h" #include "RxDispatchImpl.h" // Visualize SDK #include "TvVisualizeFiler.h" #include "NwHostAppServices.h" /** \details Type defenition for pass callback for selecting directory. */ typedef OdString(*OdNwChooseFileCallback)(const OdString&); namespace NW2Visualize { /** \details This class implements the properties of the obj loader */ class OdTvVisualizeNwFilerProperties : public OdRxDispatchImpl<> { enum ParamFlags { kNeedCDATree = 0x1, // Need create CDA tree kNeedCollectPropertiesInCDA = 0x2, // Need collect native properties in CDA nodes kChangeToNwc = 0x4, // is model is original with nwc or it replacing origin format file in nwf kStoreSource = 0x8, // Store source objects (OdDbEntities) kImportCuttingPlanes = 0x10, // Import cutting planes kImportGrid = 0x20, // Import grid kImportAnimation = 0x40, // Import animation kImportRecap = 0x80, // Import recap data kImportSavedViewpoints = 0x100, // Import saved viewpoints kImportLights = 0x200, // Import lights kLowMemoryImportToVSF = 0x400, // Low memorty import to vsf/vsfx kNeedGroupsUsing = 0x800, // Need use groups in hierarchy kImportRefGeomAsInserts = 0x1000,// Need use referenced geometry in hierarchy kImportRecapAsRcsPointCloud = 0x2000 // Import recap data as rcs pont cloud as Tv Entity }; public: OdTvVisualizeNwFilerProperties(); virtual ~OdTvVisualizeNwFilerProperties(); ODRX_DECLARE_DYNAMIC_PROPERTY_MAP(OdTvVisualizeNwFilerProperties); static OdRxDictionaryPtr createObject(); void setDCRect(OdIntPtr rect); //should be pointer to OdTvDCRect OdIntPtr getDCRect() const; void setBackgroundColor(OdIntPtr pBackgroundColor); OdIntPtr getBackgroundColor() const; void setDefaultNwColor(OdIntPtr pDefColor); OdIntPtr getDefaultNwColor() const; void setNeedCDATree(bool bSet) { SETBIT(m_flags, kNeedCDATree, bSet); } bool getNeedCDATree() const { return GETBIT(m_flags, kNeedCDATree); } void setNeedCollectPropertiesInCDA(bool bSet) { SETBIT(m_flags, kNeedCollectPropertiesInCDA, bSet); } bool getNeedCollectPropertiesInCDA() const { return GETBIT(m_flags, kNeedCollectPropertiesInCDA); } void setReplaceByNwc(bool bSet) { SETBIT(m_flags, kChangeToNwc, bSet); } bool getReplaceByNwc() const { return GETBIT(m_flags, kChangeToNwc); } void setAppendTransform(OdIntPtr pTransform); OdIntPtr getAppendTransform() const; void setDeviceToAppend(OdIntPtr pDevice); OdIntPtr getDeviceToAppend() const; OdTvGsDeviceId getTvDeviceToAppend() const { return m_appendDevice; } void setStoreSourceObjects(bool bSet) { SETBIT(m_flags, kStoreSource, bSet); } bool getStoreSourceObjects() const { return GETBIT(m_flags, kStoreSource); } void setImportCuttingPlanes(bool bSet) { SETBIT(m_flags, kImportCuttingPlanes, bSet); } bool getImportCuttingPlanes() const { return GETBIT(m_flags, kImportCuttingPlanes); } void setFeedbackForChooseCallback(OdIntPtr pCallback); OdIntPtr getFeedbackForChooseCallback() const; void setFeedbackForChooseFileCallback(OdIntPtr pCallback); OdIntPtr getFeedbackForChooseFileCallback() const; void setImportGrid(bool bSet) { SETBIT(m_flags, kImportGrid, bSet); } bool getImportGrid() const { return GETBIT(m_flags, kImportGrid); } void setImportAnimation(bool bSet) { SETBIT(m_flags, kImportAnimation, bSet); } bool getImportAnimation() const { return GETBIT(m_flags, kImportAnimation); } void setImportRecap(bool bSet) { SETBIT(m_flags, kImportRecap, bSet); } bool getImportRecap() const { return GETBIT(m_flags, kImportRecap); } void setImportRecapAsRcsPointCloud(bool bSet) { SETBIT(m_flags, kImportRecapAsRcsPointCloud, bSet); } bool getImportRecapAsRcsPointCloud() const { return GETBIT(m_flags, kImportRecapAsRcsPointCloud); } void setImportSavedViewpoints(bool bSet) { SETBIT(m_flags, kImportSavedViewpoints, bSet); } bool getImportSavedViewpoints() const { return GETBIT(m_flags, kImportSavedViewpoints); } void setImportLights(bool bSet) { SETBIT(m_flags, kImportLights, bSet); } bool getImportLights() const { return GETBIT(m_flags, kImportLights); } void setLowMemoryImportToVSF(bool bSet) { SETBIT(m_flags, kLowMemoryImportToVSF, bSet); } bool getLowMemoryImportToVSF() const { return GETBIT(m_flags, kLowMemoryImportToVSF); } void setNeedGroupsUsing(bool bSet) { SETBIT(m_flags, kNeedGroupsUsing, bSet); } bool getNeedGroupsUsing() const { return GETBIT(m_flags, kNeedGroupsUsing); } void setImportRefGeomAsInserts(bool bSet) { SETBIT(m_flags, kImportRefGeomAsInserts, bSet); } bool getImportRefGeomAsInserts() const { return GETBIT(m_flags, kImportRefGeomAsInserts); } void setTempDirectoryPath(const OdString& strSet) { m_strTempDirectoryPath = strSet; } OdString getTempDirectoryPath() const { return m_strTempDirectoryPath; } void setPartialImportDumpFile(const OdString& strSet) { m_strPartialImportDumpFile = strSet; } OdString getPartialImportDumpFile() const { return m_strPartialImportDumpFile; } void setMultiThreadsCnt(OdUInt32 mtCnt) { m_multiThreadsCnt = mtCnt; } OdUInt32 getMultiThreadsCnt() const { return m_multiThreadsCnt; } void setReflectionEnvFile(const OdString& strSet) { m_strReflectionEnvFile = strSet; } OdString getReflectionEnvFile() const { return m_strReflectionEnvFile; } protected: OdTvDCRect m_importRect; // Output rectangle. Used for correct import of some specific objects (OLE image, camera). The normal way is to set the output window size ODCOLORREF m_background; // Background color. ODCOLORREF m_defaultColor; // default color which is set to the entity OdUInt16 m_flags; // Different options OdTvMatrix m_appendTransform;// Transform for the append OdTvGsDeviceId m_appendDevice; // Device that will receive appended data OdTvFeedbackForChooseCallback m_pCallback; // Callback for choose OdNwChooseFileCallback m_pFileCallback; //Callback for choose file OdString m_strPartialImportDumpFile; //path to vsf/vsfx for low memory import mode OdUInt32 m_multiThreadsCnt;//thread count for mt-loading of BimNv database OdString m_strReflectionEnvFile;//path to refelction environment texture(.ocm,.png,.jpg) OdString m_strTempDirectoryPath;//path to temp directory for embedded files }; typedef OdSmartPtr OdTvVisualizeNwFilerPropertiesPtr; } class OdTvVisualizeNwFilerSourceFromFile; class OdNwDatabase; typedef OdSmartPtr OdNwDatabasePtr; class OdNwObjectId; typedef OdArray > OdNwObjectIdArray; /** \details This class is an interface for the internal helper objects used inside the import process */ class OdTvVisualizeNwFilerDbSource { public: virtual ~OdTvVisualizeNwFilerDbSource() {}; virtual OdNwDatabasePtr getDb() = 0; virtual OdString getFilename() = 0; virtual double getInitTime() const { return 0; } virtual bool odWasInitialized() const { return true; } }; /** \details This class is nwinterop loader (to the Visualize database) */ class OdTvVisualizeNwFiler : public OdTvVisualizeFiler { public: OdTvVisualizeNwFiler(); virtual ~OdTvVisualizeNwFiler(); virtual OdRxDictionaryPtr properties() { return m_properties; } virtual OdTvDatabaseId loadFrom(OdDbBaseDatabase* pDatabase, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; virtual OdTvDatabaseId loadFrom(OdStreamBuf* pBuffer, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; virtual OdTvDatabaseId loadFrom(const OdString& filePath, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; virtual OdTvDatabaseId generate(OdTvFilerTimeProfiling* pProfileRes = NULL) const; virtual OdTvModelId appendFrom(const OdTvDatabaseId& databaseId, OdDbBaseDatabase* pDatabase, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; virtual OdTvModelId appendFrom(const OdTvDatabaseId& databaseId, OdStreamBuf* pBuffer, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; virtual OdTvModelId appendFrom(const OdTvDatabaseId& databaseId, const OdString& filePath, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; //Native properties support virtual bool hasNativePropertiesSupport() const { return true; } virtual OdTvResult startActionsWithNativeProperties(const OdString& sFilePath, bool bPartial); virtual bool isActionsWithNativePropertiesStarted(const OdString& sFilePath); virtual OdTvResult endActionsWithNativeProperties(); virtual OdRxMemberIteratorPtr getNativePropertiesIterator(OdUInt64 dbHandle, OdTvResult* rc = NULL); virtual OdRxValue getNativePropertyValue(OdUInt64 dbHandle, const OdRxPropertyPtr& pProperty, bool* bReadOnly = NULL, OdTvResult* rc = NULL); virtual OdRxValueIteratorPtr getNativeCollectionPropertyIterator(OdUInt64 dbHandle, const OdRxCollectionPropertyPtr& pCollectionProperty, bool* bReadOnly = NULL, OdTvResult* rc = NULL); virtual OdTvResult setNativePropertyValue(OdUInt64 dbHandle, OdRxPropertyPtr& pProperty, const OdRxValue& value); virtual OdDbBaseDatabase* getNativeDatabase(OdTvResult* rc = NULL) const; private: OdTvModelId appendFrom(const OdTvDatabaseId& databaseId, OdTvVisualizeNwFilerDbSource *pNwDatabaseSource, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; //used for external geometry streams bool getEmbeddedFileResolver(OdNwDatabasePtr pNwDb, OdString& sPath, OdStreamBufPtr& pStreamBuf) const; //void setupLHTree(const OdNwObjectId& nwModelItemRootId, const OdTvModelId& tvModelId, OdPerfTimerBase* pTvTimer, double& nTotalTvTime, mapNwObjId2TvIdsType& nwId2TvIds) const; OdTvGsViewBackgroundId setupBackground(const OdNwObjectId& nwBackGroundId, OdTvDatabasePtr tvDb) const; void setupGrid(OdNwDatabasePtr pNwDb, OdTvDatabaseId tvDbId, OdTvGsViewId viewId, OdString modelName) const; void loadNwd(OdTvDatabaseId tvDbId, OdNwDatabasePtr pNwDb, OdTvFilerTimer &timing, OdTvFilerTimeProfiling* pProfileRes) const; void loadNwf(OdTvDatabaseId tvDbId, OdNwDatabasePtr pNwDb, OdTvFilerTimer &timing, OdTvFilerTimeProfiling* pProfileRes) const; void createCommonDataAccessTree(OdTvDatabasePtr pTvDb, OdDbBaseDatabase *pDatabase, const OdString& strTreeName, const OdTvModelId& modelId) const; struct LoadNwOptions { enum Type { kFilePath, kDatabase, kBuffer }; OdString m_filePath; OdDbBaseDatabase* m_pDatabase; OdStreamBuf* m_pBuffer; Type m_type; LoadNwOptions(const OdString& filePath) : m_filePath(filePath), m_type(kFilePath), m_pDatabase(NULL), m_pBuffer(NULL) {} LoadNwOptions(OdDbBaseDatabase* pDatabase) : m_pDatabase(pDatabase), m_type(kDatabase), m_pBuffer(NULL) {} LoadNwOptions(OdStreamBuf* pBuffer) : m_pBuffer(pBuffer), m_type(kBuffer), m_pDatabase(NULL) {} }; OdTvDatabaseId importFile(const LoadNwOptions& opt, OdTvFilerTimeProfiling* pProfileRes = NULL, OdTvResult* rc = NULL) const; private: NW2Visualize::OdTvVisualizeNwFilerPropertiesPtr m_properties; OdRxModulePtr m_pNwPropertiesModule; OdRxModulePtr m_pRxPropertiesModule; OdRxModulePtr m_pNwDatabaseModule; OdTvVisualizeNwFilerSourceFromFile* m_pDl; OdNwDatabasePtr m_pDatabaseForNativeProp; }; /** \details This class is obj loader module implementation */ class OdTvVisualizeNwFilerModule : public OdTvVisualizeFilerModule { public: virtual OdTvVisualizeFilerPtr getVisualizeFiler() const; void initApp(); void uninitApp(); }; typedef OdSmartPtr OdTvVisualizeNwFilerModulePtr; class TvRxSystemServicesImpl : public OdRxSystemServices { public: TvRxSystemServicesImpl() {}; OdInt64 getFileCTime(const OdString& filename) { return 0; }; OdInt64 getFileMTime(const OdString& filename) { return 0; }; OdInt64 getFileSize(const OdString& filename) { return 0; }; OdString formatMessage(unsigned int formatId, va_list* argList = 0) { return OD_T(""); }; /** \details Returns the system code page. \remarks On Windows platforms system code page is initialized based on computer's Regional Settings. On other platforms with CP_UNDEFINED. It can be altered by setSystemCodePage() */ OdCodePageId systemCodePage() const { return CP_UNDEFINED; }; OdResult getEnvVar(const OdString &varName, OdString &value) { return eNotImplemented; }; OdResult setEnvVar(const OdString &varName, const OdString &newValue) { return eNotImplemented; }; }; /** \details This class is service for getting database for nw file */ class OdTvNw2VisService : public OdNwHostAppServices, public OdDbHostAppProgressMeter, public TvRxSystemServicesImpl { public: virtual void start(const OdString& displayString = OdString::kEmpty) { }; virtual void stop() { }; virtual void meterProgress() { }; virtual void setLimit(int max) { }; virtual ~OdTvNw2VisService() { } void setNumThreads(int numThreads) { m_NumThreads = numThreads; } virtual int numThreads(OdDb::MultiThreadedMode mtMode) override { int numThrs = 1; bool bEnabled = false; switch (mtMode) { case OdDb::kMTLoading: bEnabled = GETBIT(getMtMode(), 1); break; default: ODA_FAIL_ONCE(); } if (bEnabled) numThrs = m_NumThreads; return numThrs; } OdString handleEmbeddedFile(const OdString& sPath, OdStreamBufPtr pEmbFile, OdString sType) const override; void setTempDirectoryPath(const OdString& sTempPath) { m_TempDirectoryPath = sTempPath; } protected: ODRX_USING_HEAP_OPERATORS(TvRxSystemServicesImpl); private: int m_NumThreads; OdString m_TempDirectoryPath; }; #include "TD_PackPop.h" #endif // NW2VISUALIZE_H