Skip to content

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

cpp
#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.

cpp
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.

cpp
 LExchange() const;
LExchange

Copy constructor.

cpp
 LExchange(const  & LExchange other) const;

other Wrapper to copy from

Parameters:

  • other - Wrapper to copy from
operator=

Assignment operator.

cpp
& 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.

cpp
 ~LExchange() const;
ReadFile

Read a CAD file and return the shape. Automatically detects file format by extension.

cpp
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 status
  • shape - and operation status
ReadFile

Read a CAD file with specific configuration.

cpp
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 status
  • shape - and operation status
  • config - 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.

cpp
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 status
  • shape - Shape to write Result containing operation status
WriteFile

Write a shape to a CAD file with specific configuration.

cpp
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 status
  • shape - Shape to write config Configuration for write operation Result containing operation status
  • config - Configuration for write operation Result containing operation status
DetectFormat

Detect file format by file path using OCCT's native detection.

cpp
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.

cpp
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.

cpp
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.

cpp
std::vector<  > FormatInfo GetSupportedFormats() const;

of format information Vector

RegisterProvider

Register a format provider from a dynamic library.

cpp
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.

cpp
std::vector<  > ProviderInfo GetRegisteredProviders() const;

of provider information Vector

SetDefaultConfig

Set default configuration for read/write operations.

cpp
void SetDefaultConfig(const  & ExchangeConfig config) const;

config Default configuration to use

Parameters:

  • config - Default configuration to use
GetDefaultConfig

Get current default configuration.

cpp
ExchangeConfig GetDefaultConfig() const;

Current default configuration

LoadConfigFromString

Load configuration from resource string.

cpp
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.

cpp
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.

cpp
std::string SaveConfigToString() const;

Configuration as resource string

Reset

Clear all registered providers and reset to defaults.

cpp
void Reset() const;
IsValid

Check if wrapper is properly initialized.

cpp
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.

cpp
bool CreateDeepCopy() const;

True if deep copy was successful


Released under the LGPL-2.1 License