/////////////////////////////////////////////////////////////////////////////// // 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 __TNW_DATABASE_H__ #define __TNW_DATABASE_H__ #include "NwObject.h" #include "NwExport.h" #define STL_USING_MAP #include "OdaSTL.h" #include "NwModelUnits.h" #include "NwFormatVersion.h" #include "NwFileType.h" #include "SharedPtr.h" #include "NwSavedItemsElementType.h" class OdNwHostAppServices; class OdGeMatrix3d; class OdNwUnitsFormatter; class OdNwGridSystemElement; class OdNwLightsElement; class OdNwDatabaseWriteTransaction; class OdNwPublishSettings; struct OdNwStats; /** \details This template class is a specialization of the OdSharedPtr class for OdNwDatabaseWriteTransaction object pointers. */ typedef OdSharedPtr OdNwDatabaseWriteTransactionPtr; /** \details This template class is a specialization of the OdSmartPtr class for OdNwGridSystemElement object pointers. */ typedef OdSmartPtr OdNwGridSystemElementPtr; /** \details This template class is a specialization of the OdSmartPtr class for OdNwLightsElement object pointers. */ typedef OdSmartPtr OdNwLightsElementPtr; class OdNwPublishSettings; /** \details This template class is a specialization of the OdSharedPtr class for OdNwPublishSettings object pointers. */ typedef OdSharedPtr OdNwPublishSettingsPtr; /** \details This class implements the interface for interaction with a BimNv SDK database. */ class NWDBEXPORT OdNwDatabase : public OdNwObject { //DOM-IGNORE-BEGIN ODRX_DECLARE_MEMBERS(OdNwDatabase); //DOM-IGNORE-END public: /** \details Default constructor. Creates a new object of the OdNwDatabase class. */ OdNwDatabase(); public: /** \details Virtual destructor. Frees allocated resources. */ virtual ~OdNwDatabase(); /** \details Declares the method decrementing the reference counter in objects derived from this class. */ void release() override; /** \details Receives the OdNwHostAppServices object associated with this database object. \returns OdNwHostAppServices object associated with this database object. */ virtual OdNwHostAppServices* appServices() const; /** \details Reads the contents of the specified stream buffer object or a file into this database object. \param pStreamBuf [in] Pointer to the stream buffer object from which the data is read. \param partialLoad [in] Controls the partial loading of .nwd files. The default value is true. \param password [in] Password for the file. \remarks Throws: OdError if the read operation is unsuccessful. */ virtual void readFile(OdStreamBuf* pStreamBuf, bool partialLoad = true, const OdString& password = OdString::kEmpty); /** \details Reads the contents of the specified file into this database object. \param fileName [in] Name of the file from which the data is read. \param partialLoad [in] Controls the partial loading of .nwd files. \param password [in] Password for the file. \remarks Throws: OdError if the read operation is unsuccessful. */ virtual void readFile(const OdString& fileName, bool partialLoad = true, const OdString& password = OdString::kEmpty); /** \details Writes this database object to the specific file. \param fileName [in] Name of the file to be written. \param fileType [in] File type to write (default: determined by file extension). \param version [in] Format version to write (default: latest version). \remarks fileType can be one of the following: Name Value Description NwFileType::kNwd 0x00 Navisworks Database file (.nwd) - published model file. NwFileType::kNwc 0x01 Navisworks Cache file (.nwc) - cached model file. NwFileType::kNwf 0x02 Navisworks file set (.nwf) - models file set.
version can be one of the following: Name Value Description NwFormatVersion::NW_2016 0xC Format version is NW-2016..NW-2025. NwFormatVersion::NW_2026 0xD Format version is NW-2026.
Version restrictions: - NWC files: Only NW_2016 version supported - NWD files: Both NW_2016 and NW_2026 versions supported - NWF files: Both NW_2016 and NW_2026 versions supported, but cannot be created from scratch File type restrictions: - NWF files are federated models and cannot be created from scratch, only saved from existing federated models Throws: OdError if the write operation is unsuccessful. */ virtual void writeFile(const OdString& fileName, NwFileType::Enum fileType = NwFileType::kNwd, NwFormatVersion::Enum version = NwFormatVersion::NW_2026); /** \details Writes this database object to the specific stream. \param pStreamBuf [in] Pointer to the StreamBuf object. \param fileType [in] File type to write (default: NWD format). \param version [in] Format version to write (default: latest version). \remarks fileType can be one of the following: Name Value Description NwFileType::kNwd 0x00 Navisworks Database file (.nwd) - published model file. NwFileType::kNwc 0x01 Navisworks Cache file (.nwc) - cached model file. NwFileType::kNwf 0x02 Navisworks file set (.nwf) - models file set.
version can be one of the following: Name Value Description NwFormatVersion::NW_2016 0xC Format version is NW-2016..NW-2025. NwFormatVersion::NW_2026 0xD Format version is NW-2026.
Version restrictions: - NWC files: Only NW_2016 version supported - NWD files: Both NW_2016 and NW_2026 versions supported - NWF files: Both NW_2016 and NW_2026 versions supported, but cannot be created from scratch File type restrictions: - NWF files are federated models and cannot be created from scratch, only saved from existing federated models Throws: OdError if the write is unsuccessful. */ virtual void writeFile(OdStreamBuf* pStreamBuf, NwFileType::Enum fileType = NwFileType::kNwd, NwFormatVersion::Enum version = NwFormatVersion::NW_2026); /** \details Receives the name of the file associated with this database object. \returns Name of the file associated with this database object. */ virtual OdString getFilename() const; /** \details Publishes this database object to the specified file. \param publSettings [in] OdNwPublishSettings object. \remarks Throws OdError if the publish is not successful. */ void publish(const OdString& fileName, const OdNwPublishSettings& publSettings); /** \details Publishes this database object to the specified stream. \param publSettings [in] OdNwPublishSettings object. \remarks Throws OdError if the publish is unsuccessful. */ void publish(OdStreamBuf* pStreamBuf, const OdNwPublishSettings& publSettings); public: /** \details Receives the database's ID of an object by its handle. \param handle [in] OdDbHandle object with the object's handle. \param createIfNotFound [in] Boolean flag for whether to create the object if it is not found. \returns OdNwObjectId of the object. */ OdNwObjectId getObjectId(const OdDbHandle& handle, bool createIfNotFound = false); public: /** \details Receives an object ID of the saved items element of the database by selected type. \param siElementType [in] Saved item element type. \param pResCode [out] Receives eOk if the element getting is successfully, or an appropriate error code otherwise. \returns Object ID of the database's object with the OdNwSavedItemsElement derrived class. If the database does not have a required element, returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. siElementType can be one of the following: Name Value Description NwSavedItemsElementType::kSavedViews 0x00 OdNwSavedViewsElement class object. NwSavedItemsElementType::kClash 0x01 OdNwClashElement class object. NwSavedItemsElementType::kLights 0x02 OdNwLightsElement class object. NwSavedItemsElementType::kSelectionSets 0x03 OdNwSelectionSetsElement class object. NwSavedItemsElementType::kSavedAnimation 0x04 OdNwSavedAnimElement class object. NwSavedItemsElementType::kTimeLiner 0x05 OdNwTimeLinerElement class object. NwSavedItemsElementType::kMaterial 0x06 OdNwMaterialElement class object.
The method is not applicable for composite databases (NWF files) if type is 'NwSavedItemsElementType::kSavedViews' or 'NwSavedItemsElementType::kSavedAnimation'. */ OdNwObjectId getSavedItemsElement(NwSavedItemsElementType::Enum siElementType, OdResult* pResCode = NULL) const; /** \details Receives an object ID of the current viewpoint of the database. \returns Object ID of the OdNwViewpoint object with the current viewpoint of the database. If the database does not have a current viewpoint, returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getCurrentViewId() const; /** \details Receives an object ID of the clipping planes of current view of the database. \returns Object ID of the OdNwClipPlaneSet object with the clipping planes of the current view of the database. If the database does not have a current view, the method returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getCurrrentViewClippingPlanesId() const; /** \details Gets an array of object IDs of the database's saved view elements (with viewpoints, animation, etc.). \param aSavedViewsElementIds [out] OdArray object of object IDs of the saved view elements. \returns The eOk value if the array of object IDs of the saved view elements is retrieved successfully, or an appropriate error code otherwise. \remarks This method is not applicable for composite databases (NWF files). The method returns a value that corresponds to the sheet, selected as active for the database. The method is deprecated since version 25.0. Instead, use the getSavedItemsElement method with 'NwSavedItemsElementType::kSavedViews'. */ OdResult getSavedViewsElements(OdNwObjectIdArray& aSavedViewsElementIds) const; /** \details Receives an object ID of the headlight element. \returns Object ID of an OdNwHeadlightElement object with ambient and intensity of light in "Headlight" mode. If the database does not have a headlight element, the method returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getHeadlightElementId() const; /** \details Receives an object ID of the speed element. \returns Object ID of an OdNwSpeedElement object with a frame rate. If the database does not have a speed element, the method returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getSpeedElementId() const; /** \details Receives an object ID of the culling element. \returns Object ID of an OdNwCullingElement object with a culling settings. If the database does not have a culling element, the method returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getCullingElementId() const; /** \details Receives an object ID of the DBDatabaseLinksElement element. \returns Object ID of an OdNwDBDatabaseLinksElement object with a databse links settings. \remarks If the database does not have an OdNwDBDatabaseLinksElement, the method returns an empty object ID. The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getDBDatabaseLinksElementId() const; /** \details Receives an object ID of the background element. \returns Object ID of an OdNwBackgroundElement object with background colors of the database. If the database does not have a background element, the method returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getBackgroundElementId() const; /** \details Receives an object ID of the clash element. \returns Object ID of an OdNwClashElement object with the saved clash element of the database. If the database does not have a clash element, the method returns an empty object ID. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. The method is deprecated since version 25.0. Instead, use the getSavedItemsElement method with 'NwSavedItemsElementType::kClash'. */ OdNwObjectId getClashElementId() const; /** \details Gets an array with object IDs of models. \param arrModels [out] Array with object IDs of models. \returns The eOk value if the operation is successful, or an appropriate error code otherwise. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdResult getModels(OdNwObjectIdArray& arrModels) const; /** \details Receives a scene's statistics. \returns OdNwStats object. \remarks Use this method only if the database is not a composite model. The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwStats getSceneStats() const; /** \details Receives a transformation matrix of a model. \returns OdGeMatrix3d object with the transformation matrix of a model. \remarks Use this method only if the database is not a composite model. The method returns a value that corresponds to the sheet, selected as active for the database. The method has been deprecated since version 26.1 and will be removed soon. Instead, use method with OdGeMatrix3d OdNwModel::getTransform() const. */ OdGeMatrix3d getModelTransform() const; /** \details Indicates whether the database is composite. \returns The true value if the database contains more than one object, or false otherwise. */ bool isComposite() const; /** \details Receives the units in which dimensions of this model are defined. \returns One of the enumerated items from the NwModelUnits::Enum enumerated type. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. getUnits() Returns one of the following: Name Value Description NwModelUnits::UNITS_METERS 0x00 SI meter. Length of the path travelled by light in a vacuum in 1 299,792,458th of second. NwModelUnits::UNITS_CENTIMETERS 0x01 1/100th of an SI meter. NwModelUnits::UNITS_MILLIMETERS 0x02 1/1000th of an SI meter. NwModelUnits::UNITS_FEET 0x03 1/3rd of a yard. NwModelUnits::UNITS_INCHES 0x04 1/12th of a foot, 2.54 SI centimeters. NwModelUnits::UNITS_YARDS 0x05 Imperial yard, 0.9144 SI meters. NwModelUnits::UNITS_KILOMETERS 0x06 1000 SI meters. NwModelUnits::UNITS_MILES 0x07 1760 yards. NwModelUnits::UNITS_MICROMETERS 0x08 1/1,000,000th of an SI meter, micron. NwModelUnits::UNITS_MILS 0x09 1/1,000th of an inch. NwModelUnits::UNITS_MICROINCHES 0x0A 1/1,000,000th of an inch.
*/ NwModelUnits::Enum getUnits() const; /** \details Receives a smart pointer to the lights element. \returns Smart pointer to an OdNwLightsElementPtr object. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. The method is deprecated since version 25.0. Instead, use the getSavedItemsElement method with 'NwSavedItemsElementType::kLights'. */ OdNwLightsElementPtr getLightsElement() const; /** \details Receives a smart pointer to the grid system element. \returns Smart pointer to an OdNwGridSystemElement object. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwGridSystemElementPtr getGridSystemElement() const; /** \details Receives the object ID of a selection sets element. \returns OdNwObjectId with an OdNwSelectionSetsElement object. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. The method is deprecated since version 25.0. Instead, use the getSavedItemsElement method with 'NwSavedItemsElementType::kSelectionSets'. */ OdNwObjectId getSelectionSetsElementId() const; /** \details Receives an object ID of the current sheet element. \returns Object ID of an OdNwSheetInfo object with the current sheet element of the database. */ OdNwObjectId getActiveSheetId() const; /** \details Gets an array with object IDs of sheets of the database. \param aSheets [out] Array with object IDs of sheets. \returns The eOk value if the operation is successful, or an appropriate error code otherwise. */ OdResult getSheets(OdNwObjectIdArray& aSheets) const; /** \details Receives an object ID of the file information object. \returns Object ID of the OdNwFileInfo object of the database. */ OdNwObjectId getFileInfo() const; /** \details Receives the version of the original software the file was created with. \returns The original file format version as one of the enumerated items from the NwModelUnits::Enum enumerated type. \remarks If the file was not loaded the method returns the latest possible version. */ NwFormatVersion::Enum getOriginalFormatVersion(); /** \details Receives an object ID of the saved animation element. \returns OdNwObjectId with an OdNwSavedAnimElement object. \remarks This method is not applicable for composite databases (NWF files). The method returns a value that corresponds to the sheet, selected as active for the database. The method is deprecated since version 25.0. Instead, use the getSavedItemsElement method with 'NwSavedItemsElementType::kSavedAnimation'. */ OdNwObjectId getSavedAnimationElementId() const; /** \details Receives an object ID of the timeliner element. \returns OdNwObjectId with an OdNwTimeLinerElement object. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. The method is deprecated since version 25.0. Instead, use the getSavedItemsElement method with 'NwSavedItemsElementType::kTimeLiner'. */ OdNwObjectId getTimeLinerElementId() const; /** \details Receives an object ID of the timeliner simulate duration element. \returns OdNwObjectId with an OdNwTimeLinerSimulateDurationElement object. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. */ OdNwObjectId getTimeLinerSimulateDurationElementId() const; public: /** \details Adds a new model to the model collection of the database by its source path. \param sourcePath [in] String with the path to the source model to be added to the collection. \param pResCode [out] Receives eOk if the model is added successfully, or an appropriate error code otherwise. \returns ID of the new OdNwModel object in the database if successful, or null pointer otherwise. \remarks This method is applicable only for composite databases (NWF files). This method performs an action for the database state with the sheet selected as active for the database. */ OdNwObjectId addModel(const OdString& sourcePath, OdResult* pResCode = NULL); /** \details Sets a new active sheet and switches the database to the state, corresponding to the new sheet. \param sheetId [in] Sheet ID. \returns The eOk value if the database is set to the new sheet state successfully, or an appropriate error code otherwise. \remarks The method changes the current state of the database to the selected sheet (if the selected sheet has not yet been read, partial loading is performed). */ OdResult setActiveSheet(const OdString& sheetId); /** \details Retrieves the unit formatter for the database as a constant object. \returns Smart pointer to the OdNwUnitsFormatter object that represents the currently used unit formatter. */ const OdNwUnitsFormatter& formatter() const; /** \details Retrieves the unit formatter for the database. \returns Smart pointer to the OdNwUnitsFormatter object that represents the currently used unit formatter. */ OdNwUnitsFormatter& formatter(); /** \details Retrieves a smart pointer to an OdStreamBuf object containing looking stream. \param name [in] Name of looking stream. \param res [out] Pointer to the OdResult object with the error code. \returns Smart pointer to the OdStreamBuf object. */ OdStreamBufPtr getEmbeddedStream(const OdString & name, OdResult * res = nullptr) const; /** \details Retrieves the map of OdString and OdStreamBuf containing only external streams. \param streamMap [out] The std::map of OdString and OdStreamBuf returning all stream in the database. \returns The eOk value if streams are retrieved successfully, or eFileNotFound if at least one external file can't be open. \remarks The method returns the map that have a key containing name of embedded stream otherwise full path to a file that is an external stream. And also value that is the OdStreamBuf pointer that saves key specified object. Or Null if external file can't be open for any reason. The method is deprecated since version 25.9. Instead, use the getEmbeddedStream method with the needed key. */ OdResult getNamedStreamMap(std::map& streamMap) const; /** \details Creates a new write transaction for the database. \returns A shared pointer to the OdNwDatabaseWriteTransaction object. \remarks The method is deprecated since relaese/26.10. It is unsafe due to an auto-commit pattern that hides errors. */ OdNwDatabaseWriteTransactionPtr createWriteTransaction(); /** \details Creates a grid system element. \returns Smart pointer to an OdNwGridSystemElement object. \remarks The method returns a value that corresponds to the sheet selected as active for the database. */ OdNwGridSystemElementPtr createGridSystemElement(); /** \details Creates an object ID with the saved items element of the database by selected type. \param siElementType [in] Saved item element type. \param pResCode [out] Receives eOk if the element creating is successfully, or an appropriate error code otherwise. \returns Object ID of the database's object with the OdNwSavedItemsElement derrived class. If creation of new element was not applicaple it will return empty object id. \remarks The method returns a value that corresponds to the sheet, selected as active for the database. If the database does already have a required element it will be replaced by new element. siElementType can be one of the following: Name Value Description NwSavedItemsElementType::kSavedViews 0x00 OdNwSavedViewsElement class object. NwSavedItemsElementType::kClash 0x01 OdNwClashElement class object. NwSavedItemsElementType::kLights 0x02 OdNwLightsElement class object. NwSavedItemsElementType::kSelectionSets 0x03 OdNwSelectionSetsElement class object. NwSavedItemsElementType::kSavedAnimation 0x04 OdNwSavedAnimElement class object. NwSavedItemsElementType::kTimeLiner 0x05 OdNwTimeLinerElement class object.
This method is not applicable for composite databases (NWF files) if type is 'NwSavedItemsElementType::kSavedViews' or 'NwSavedItemsElementType::kSavedAnimation'. */ OdNwObjectId createSavedItemsElement(NwSavedItemsElementType::Enum siElementType, OdResult* pResCode = NULL); }; /** \details This template class is a specialization of the OdSmartPtr class for OdNwDatabase object pointers. */ typedef OdSmartPtr OdNwDatabasePtr; #endif //__TNW_DATABASE_H__