Exchange Module
CAD file import/export capabilities.
LightOcct::LExchange
Light OCCT wrapper for OCCT DE_Wrapper (Data Exchange Wrapper).
Provides a simplified interface for CAD file exchange operations using OCCT's DE_Wrapper system. Supports automatic format detection by file extension and dynamic provider registration for various CAD formats. Follows Light OCCT architecture: POD structures for cross-language data exchange Wrapper methods hide OCCT implementation details No OCCT types exposed in public interface Support for dynamic library loading and provider registration Key features: Automatic file format detection by extension Dynamic provider registration for extensibility Support for STEP, IGES, STL, OBJ, BRep, PLY, glTF formats Configuration management for read/write operations Thread-safe operations Comprehensive error reporting
#include <light-occt/exchange/LExchange.hxx>Quick Reference
Factory Methods: ResultToString()
Methods: LExchange(), LExchange(), operator=(), ~LExchange(), ReadFile(), ReadFile(), WriteFile(), WriteFile(), DetectFormat(), IsReadSupported(), IsWriteSupported(), GetSupportedFormats(), RegisterProvider(), GetRegisteredProviders(), SetDefaultConfig(), GetDefaultConfig(), LoadConfigFromString(), LoadConfigFromFile(), SaveConfigToString(), Reset(), IsValid(), CreateDeepCopy()
Methods
Factory Methods
ResultToString
Convert exchange result enum to string.
static std::string ResultToString(ExchangeResult result);result Exchange result String representation of result
Parameters:
result- Exchange result String representation of result
Instance Methods
LExchange
Default constructor - creates wrapper with default providers.
LExchange() const;LExchange
Copy constructor.
LExchange(const & LExchange other) const;other Wrapper to copy from
Parameters:
other- Wrapper to copy from
operator=
Assignment operator.
& LExchange operator=(const & LExchange other) const;other Wrapper to assign from Reference to this wrapper
Parameters:
other- Wrapper to assign from Reference to this wrapper
~LExchange
Destructor.
~LExchange() const;ReadFile
Read a CAD file and return the shape. Automatically detects file format by extension.
ExchangeResultInfo ReadFile(const std::string & filePath, & LShape shape) const;filePath Path to the file to read Result containing the shape and operation status
Parameters:
filePath- Path to the file to read Result containing the shape and operation statusshape- and operation status
ReadFile
Read a CAD file with specific configuration.
ExchangeResultInfo ReadFile(const std::string & filePath, & LShape shape, const & ExchangeConfig config) const;filePath Path to the file to read config Configuration for read operation Result containing the shape and operation status
Parameters:
filePath- Path to the file to read config Configuration for read operation Result containing the shape and operation statusshape- and operation statusconfig- Configuration for read operation Result containing the shape and operation status
WriteFile
Write a shape to a CAD file. Automatically detects file format by extension.
ExchangeResultInfo WriteFile(const std::string & filePath, const & LShape shape) const;filePath Path to the file to write shape Shape to write Result containing operation status
Parameters:
filePath- Path to the file to write shape Shape to write Result containing operation statusshape- Shape to write Result containing operation status
WriteFile
Write a shape to a CAD file with specific configuration.
ExchangeResultInfo WriteFile(const std::string & filePath, const & LShape shape, const & ExchangeConfig config) const;filePath Path to the file to write shape Shape to write config Configuration for write operation Result containing operation status
Parameters:
filePath- Path to the file to write shape Shape to write config Configuration for write operation Result containing operation statusshape- Shape to write config Configuration for write operation Result containing operation statusconfig- Configuration for write operation Result containing operation status
DetectFormat
Detect file format by file path using OCCT's native detection.
std::string DetectFormat(const std::string & filePath) const;filePath Path to analyze Detected format name (empty if unknown)
Parameters:
filePath- Path to analyze Detected format name (empty if unknown)
IsReadSupported
Check if a file path is supported for reading.
bool IsReadSupported(const std::string & filePath) const;filePath File path to check True if format is supported for reading
Parameters:
filePath- File path to check True if format is supported for reading
IsWriteSupported
Check if a file path is supported for writing.
bool IsWriteSupported(const std::string & filePath) const;filePath File path to check True if format is supported for writing
Parameters:
filePath- File path to check True if format is supported for writing
GetSupportedFormats
Get information about all supported formats from OCCT.
std::vector< > FormatInfo GetSupportedFormats() const;of format information Vector
RegisterProvider
Register a format provider from a dynamic library.
bool RegisterProvider(const std::string & libraryPath) const;libraryPath Path to the dynamic library (.dll, .so, .dylib) True if provider was successfully registered
Parameters:
libraryPath- Path to the dynamic library (.
GetRegisteredProviders
Get information about all registered providers from OCCT.
std::vector< > ProviderInfo GetRegisteredProviders() const;of provider information Vector
SetDefaultConfig
Set default configuration for read/write operations.
void SetDefaultConfig(const & ExchangeConfig config) const;config Default configuration to use
Parameters:
config- Default configuration to use
GetDefaultConfig
Get current default configuration.
ExchangeConfig GetDefaultConfig() const;Current default configuration
LoadConfigFromString
Load configuration from resource string.
bool LoadConfigFromString(const std::string & resourceString) const;resourceString Configuration resource string True if configuration was loaded successfully
Parameters:
resourceString- Configuration resource string True if configuration was loaded successfully
LoadConfigFromFile
Load configuration from file.
bool LoadConfigFromFile(const std::string & configFilePath) const;configFilePath Path to configuration file True if configuration was loaded successfully
Parameters:
configFilePath- Path to configuration file True if configuration was loaded successfully
SaveConfigToString
Save current configuration to string.
std::string SaveConfigToString() const;Configuration as resource string
Reset
Clear all registered providers and reset to defaults.
void Reset() const;IsValid
Check if wrapper is properly initialized.
bool IsValid() const;True if wrapper is ready for operations
CreateDeepCopy
Create a deep copy of the current DE_Wrapper state. Use this when you need to modify DE_Wrapper configuration without affecting global state.
bool CreateDeepCopy() const;True if deep copy was successful