/////////////////////////////////////////////////////////////////////////////// // 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_EXCHANGE_PARAMS_H__ #define __TNW_EXCHANGE_PARAMS_H__ #include "OdString.h" #include #define STL_USING_MEMORY #include "OdaSTL.h" /** \details Token for external cancellation of asynchronous operations. */ struct NwCancelToken { std::atomic m_flag{ false }; ///< Cancellation flag (set to true to request cancellation). }; /** \details Contains exchange operation type definitions. */ enum class NwExchangeType { /** Unknown or unspecified exchange type. */ kUnknown, /** Navisworks to IFC format conversion. */ kNw2Ifc, /** Navisworks to VSFX format conversion. */ kNw2Vsfx }; /** \details Traits template for mapping exchange types to their corresponding parameter classes. Specializations provide a type alias to the appropriate parameters struct for each exchange type. */ template struct NwExchangeTraits; /** \details Base parameters for Navisworks database exchange operations (export/import). */ struct NwExchangeConvertParams { OdString m_sOutputPath; ///< Path to the output file for export operations. NwCancelToken* m_pCancel = nullptr; ///< Optional cancellation token for external operation control. /** \details Default constructor. */ NwExchangeConvertParams() { } /** \details Virtual destructor. */ virtual ~NwExchangeConvertParams() {} /** \details Gets the exchange operation type for these parameters. \returns NwExchangeType value indicating the parameter type. \remarks Returned value can be one of the following: Name Description NwExchangeType::kUnknown Unknown or unspecified exchange type NwExchangeType::kNw2Ifc Navisworks to IFC format conversion NwExchangeType::kNw2Vsfx Navisworks to VSFX format conversion
*/ virtual NwExchangeType getType() const { return NwExchangeType::kUnknown; } /** \details Create a copy of this parameters object. \returns Unique pointer to cloned parameters. */ virtual std::unique_ptr clone() const { return std::make_unique(*this); } /** \details Safely converts this parameters object to the specified exchange type. \returns Const pointer to the parameters cast to the target type, or null if types don't match. \remarks This template method provides safe type-aware conversion using dynamic_cast. Use getType() to check the type before calling this method. */ template const typename NwExchangeTraits::type* convert2() const { return dynamic_cast::type*>(this); } /** \details Safely converts this parameters object to the specified exchange type (non-const version). \returns Pointer to the parameters cast to the target type, or null if types don't match. \remarks This template method provides safe type-aware conversion using dynamic_cast. Use getType() to check the type before calling this method. */ template typename NwExchangeTraits::type* convert2() { return dynamic_cast::type*>(this); } }; /** \details IFC-specific export parameters derived from base exchange parameters. */ struct Nw2IfcExchangeConvertParams : public NwExchangeConvertParams { OdUInt16 m_schemaVersion; ///< IFC schema version (e.g., 4 for IFC4, 3 for IFC2x3). bool m_propertiesConversion; ///< Enable conversion of custom properties during export. OdString m_sDictionaryFilePath; ///< Optional path to dictionary file for property name mapping (format: "NwPropertyName=IfcAttributePath"). /** \details Constructor with default values for IFC export. Initializes schemaVersion to 4 (IFC4) and propertiesConversion to true. */ Nw2IfcExchangeConvertParams() : NwExchangeConvertParams() , m_schemaVersion(4) , m_propertiesConversion(true) { } /** \details Virtual destructor. */ virtual ~Nw2IfcExchangeConvertParams() = default; /** \details Gets the exchange operation type for these IFC parameters. \returns NwExchangeType::kNw2Ifc. */ NwExchangeType getType() const override { return NwExchangeType::kNw2Ifc; } /** \details Create a copy of these IFC parameters. \returns Unique pointer to cloned IFC parameters. */ std::unique_ptr clone() const override { return std::make_unique(*this); } }; /** \details Contains Navisworks to VSFX conversion flag definitions. */ namespace Nw2VsfxConvertFlags { /** \details Flags controlling various aspects of Navisworks to VSFX format conversion. */ enum Enum { /** No conversion flags set. */ kNone = 0, /** Use groups during conversion (default: true). */ kNeedGroupsUsing = 1 << 0, /** Import reference geometry as inserts (default: false). */ kImportRefGeomAsInserts = 1 << 1, /** Collect properties in CDA tree (default: true). */ kCollectPropertiesInCDA = 1 << 2, /** Import light sources (default: true). */ kImportLights = 1 << 3, /** Import saved viewpoints (default: true). */ kImportSavedViewpoints = 1 << 4, /** Import ReCap point clouds (default: false). */ kImportRecap = 1 << 5, /** Import ReCap as RCS point cloud format (default: false). */ kImportRecapAsRcsPointCloud = 1 << 6, /** Default combination of flags for typical conversion. */ kDefault = kNeedGroupsUsing | kCollectPropertiesInCDA | kImportLights | kImportSavedViewpoints }; } /** \details VSFX-specific export parameters derived from base exchange parameters. */ struct Nw2VsfxExchangeConvertParams : public NwExchangeConvertParams { OdUInt32 m_flags; ///< Bitfield containing Nw2VsfxConvertFlags flags controlling conversion behavior. /** \details Constructor with default values for VSFX export. */ Nw2VsfxExchangeConvertParams() : NwExchangeConvertParams() , m_flags(Nw2VsfxConvertFlags::kDefault) { } /** \details Virtual destructor. */ virtual ~Nw2VsfxExchangeConvertParams() = default; /** \details Gets the exchange operation type for these VSFX parameters. \returns NwExchangeType::kNw2Vsfx. */ NwExchangeType getType() const override { return NwExchangeType::kNw2Vsfx; } /** \details Create a copy of these VSFX parameters. \returns Unique pointer to cloned VSFX parameters. */ std::unique_ptr clone() const override { return std::make_unique(*this); } private: /** \details Sets or clears a specific conversion flag. \param flag [in] The flag to modify. \param value [in] true to set the flag, false to clear it. */ void setFlag(Nw2VsfxConvertFlags::Enum flag, bool value) { if (value) { m_flags |= static_cast(flag); } else { m_flags &= ~flag; } } /** \details Checks whether a specific conversion flag is set. \param flag [in] The flag to check. \returns true if the flag is set, false otherwise. */ bool hasFlag(Nw2VsfxConvertFlags::Enum flag) const { return (m_flags & flag) == static_cast(flag); } public: /** \details Checks whether groups are used during conversion. \returns true if groups are used, false otherwise. */ bool isNeedGroupsUsing() const { return hasFlag(Nw2VsfxConvertFlags::kNeedGroupsUsing); } /** \details Sets whether to use groups during conversion. \param v [in] true to use groups, false otherwise. */ void setNeedGroupsUsing(bool v) { setFlag(Nw2VsfxConvertFlags::kNeedGroupsUsing, v); } /** \details Checks whether reference geometry is imported as inserts. \returns true if reference geometry is imported as inserts, false otherwise. */ bool isImportRefGeomAsInserts() const { return hasFlag(Nw2VsfxConvertFlags::kImportRefGeomAsInserts); } /** \details Sets whether to import reference geometry as inserts. \param v [in] true to import as inserts, false otherwise. */ void setImportRefGeomAsInserts(bool v) { setFlag(Nw2VsfxConvertFlags::kImportRefGeomAsInserts, v); } /** \details Checks whether properties are collected in CDA tree during conversion. \returns true if properties are collected in CDA tree, false otherwise. */ bool isNeedCollectPropertiesInCDA() const { return hasFlag(Nw2VsfxConvertFlags::kCollectPropertiesInCDA); } /** \details Sets whether to collect properties in CDA tree during conversion. \param v [in] true to collect properties, false otherwise. */ void setNeedCollectPropertiesInCDA(bool v) { setFlag(Nw2VsfxConvertFlags::kCollectPropertiesInCDA, v); } /** \details Checks whether light sources are imported during conversion. \returns true if lights are imported, false otherwise. */ bool isImportLights() const { return hasFlag(Nw2VsfxConvertFlags::kImportLights); } /** \details Sets whether to import light sources during conversion. \param v [in] true to import lights, false otherwise. */ void setImportLights(bool v) { setFlag(Nw2VsfxConvertFlags::kImportLights, v); } /** \details Checks whether saved viewpoints are imported during conversion. \returns true if saved viewpoints are imported, false otherwise. */ bool isImportSavedViewpoints() const { return hasFlag(Nw2VsfxConvertFlags::kImportSavedViewpoints); } /** \details Sets whether to import saved viewpoints during conversion. \param v [in] true to import saved viewpoints, false otherwise. */ void setImportSavedViewpoints(bool v) { setFlag(Nw2VsfxConvertFlags::kImportSavedViewpoints, v); } /** \details Checks whether ReCap point clouds are imported during conversion. \returns true if ReCap data is imported, false otherwise. */ bool isImportRecap() const { return hasFlag(Nw2VsfxConvertFlags::kImportRecap); } /** \details Sets whether to import ReCap point clouds during conversion. \param v [in] true to import ReCap data, false otherwise. */ void setImportRecap(bool v) { setFlag(Nw2VsfxConvertFlags::kImportRecap, v); } /** \details Checks whether ReCap data is imported as RCS point cloud format. \returns true if ReCap is imported as RCS format, false otherwise. */ bool isImportRecapAsRcsPointCloud() const { return hasFlag(Nw2VsfxConvertFlags::kImportRecapAsRcsPointCloud); } /** \details Sets whether to import ReCap as RCS point cloud format. \param v [in] true to import as RCS format, false otherwise. */ void setImportRecapAsRcsPointCloud(bool v) { setFlag(Nw2VsfxConvertFlags::kImportRecapAsRcsPointCloud, v); } }; /** \details Specialization of NwExchangeTraits for IFC exchange type. */ template <> struct NwExchangeTraits { using type = Nw2IfcExchangeConvertParams; ///< IFC exchange parameters type. }; /** \details Specialization of NwExchangeTraits for VSFX exchange type. */ template <> struct NwExchangeTraits { using type = Nw2VsfxExchangeConvertParams; ///< VSFX exchange parameters type. }; #endif //__TNW_EXCHANGE_PARAMS_H__