DE_Wrapper Sample is a demonstration application showcasing the Data Exchange Wrapper (DE_Wrapper) functionality in OpenCASCADE Technology (OCCT). This project provides a flexible, configurable CAD file format converter with dynamic library loading capabilities, supporting conversion between various CAD formats including STEP, IGES, STL, glTF, OBJ, PLY, VRML, BREP, and XBF.
- Multiple CAD Format Support: Convert between STEP, IGES, STL, glTF, OBJ, PLY, VRML, BREP, and XBF formats
- Dynamic Library Loading: Load only necessary Data Exchange libraries at runtime
- Cross-Platform Support: Works on Windows, Linux, and macOS
- Configurable Transfer Process: Fine-tune conversion parameters via resource files
- Optional Tessellation: Generate meshes from CAD models before export
- Thread-Safe Operations: Safe multi-threaded library loading
- Requirements
- Build Instructions
- Installation
- Usage
- Configuration
- Supported Formats
- API Documentation
- Architecture
- Troubleshooting
- OCCT 7.8.0 or newer
- CMake 3.15 or newer
- C++17 compatible compiler:
- Visual Studio 2019+ (Windows)
- GCC 7+ (Linux)
- Clang 9+ (macOS)
- Optional Dependencies (for full format support):
- draco (for mesh compression support in glTF)
- RapidJSON (for glTF format)
- Windows 10/11 (x64)
- Ubuntu 20.04+ / Debian 10+
- macOS 11.0+ (Big Sur or newer)
- RHEL/CentOS 8+
git clone https://github.com/yourusername/DE_Wrapper-Sample.git
cd DE_Wrapper-Sample
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 \
-DBUILD_CONSOLE_CPP=ON \
-DOpenCASCADE_DIR="C:/path/to/occt" \
-DCMAKE_INSTALL_PREFIX="C:/path/to/install" ..
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_CONSOLE_CPP=ON \
-DOpenCASCADE_DIR="/path/to/occt" \
-DCMAKE_INSTALL_PREFIX="/path/to/install" ..
cmake --build . --config Release --target install -j 8
cmake --build . --target install -j 8
# or with make:
make -j8 install
After successful build and installation:
-
Library Dependencies: The installation process automatically copies required OCCT libraries to the installation directory.
-
Directory Structure:
install_dir/
├── bin/ # Release executables and libraries
├── bind/ # Debug executables and libraries
├── bini/ # RelWithDebInfo executables and libraries
├── CONF # Default configuration file
└── LIBS # Default library list
- Environment Setup (Optional):
# Linux/macOS
export LD_LIBRARY_PATH=/path/to/install/bin:$LD_LIBRARY_PATH
export PATH=/path/to/install/bin:$PATH
# Windows
set PATH=C:\path\to\install\bin;%PATH%
The console application provides a simple interface for CAD file conversion:
./ConsoleCPP [options]
Option | Description | Required | Example |
---|---|---|---|
-from <path> |
Input CAD file path | Yes | -from model.step |
-to <path> |
Output CAD file path | Yes | -to model.stl |
-lib <path> |
Path to library list file | No | -lib custom_libs.txt |
-config <path> |
Path to configuration file | No | -config myconfig.conf |
--tess |
Enable tessellation before export | No | --tess |
-dump <path> |
Generate configuration template | No | -dump newconfig.conf |
# Convert STEP to STL
./ConsoleCPP -from input.step -to output.stl
# Convert IGES to glTF with tessellation
./ConsoleCPP -from model.iges -to model.gltf --tess
# Use custom configuration for fine-tuned conversion
./ConsoleCPP -from input.stp -to output.obj -config custom.conf
# Create a new configuration file for specified libraries
./ConsoleCPP -lib my_libs.txt -dump my_config.conf
#!/bin/bash
for file in *.step; do
./ConsoleCPP -from "$file" -to "${file%.step}.stl" --tess
done
Create a file minimal_libs.txt
:
TKDESTEP
TKDESTL
Then use it:
./ConsoleCPP -from model.stp -to model.stl -lib minimal_libs.txt
The LIBS file specifies which Data Exchange libraries to load. Default content:
TKDESTEP # STEP format support
TKDEIGES # IGES format support
TKDEGLTF # glTF format support
TKDEOBJ # OBJ format support
TKDEPLY # PLY format support
TKDEVRML # VRML format support
TKDESTL # STL format support
TKDECascade # Native OCCT BREP and XBF format
The CONF file contains detailed parameters for each format. Key sections include:
global.priority.vendor : TKDESTEP TKDEIGES TKDESTL
global.length.unit : 1
global.angular.unit : 1
provider.STEP.OCC.read.precision.mode : 0
provider.STEP.OCC.read.precision.val : 0.0001
provider.STEP.OCC.read.step.product.name : 1
provider.STEP.OCC.read.step.product.context : 1
provider.STEP.OCC.read.step.shape.repr : 1
provider.STEP.OCC.read.step.assembly.level : 1
provider.STEP.OCC.read.step.shape.relationship : 1
provider.STEP.OCC.read.step.shape.aspect : 1
provider.STEP.OCC.read.step.constructivegeom.representation : 0
provider.STEP.OCC.read.step.stepcaf.subshapes.name : 0
provider.STEP.OCC.read.step.encoding : 0
provider.STEP.OCC.read.step.nonmanifold : 0
provider.STEP.OCC.read.step.ideas : 0
provider.STEP.OCC.read.step.all.shapes : 0
provider.STEP.OCC.read.step.root.transformation : 1
provider.STEP.OCC.read.color : 1
provider.STEP.OCC.read.name : 1
provider.STEP.OCC.read.layer : 1
provider.STEP.OCC.read.props : 1
provider.STEP.OCC.read.metadata : 1
provider.STEP.OCC.write.precision.mode : 0
provider.STEP.OCC.write.precision.val : 0.0001
provider.STEP.OCC.write.step.assembly : 2
provider.STEP.OCC.write.step.schema : 1
provider.STEP.OCC.write.step.product.name :
provider.STEP.OCC.write.step.tessellated : 2
provider.STEP.OCC.write.step.vertex.mode : 0
provider.STEP.OCC.write.color : 1
provider.STEP.OCC.write.name : 1
provider.STEP.OCC.write.layer : 1
provider.STEP.OCC.write.props : 1
provider.STEP.OCC.write.model.type : 0
Format | Extension | Read | Write | Tessellation | Colors | Assembly |
---|---|---|---|---|---|---|
STEP | .step, .stp | ✅ | ✅ | Optional | ✅ | ✅ |
IGES | .iges, .igs | ✅ | ✅ | Optional | ✅ | ❌ |
STL | .stl | ✅ | ✅ | Required | ❌ | ❌ |
glTF | .gltf, .glb | ✅ | ✅ | Required | ✅ | ✅ |
OBJ | .obj | ✅ | ✅ | Required | ✅ | ❌ |
PLY | .ply | ✅ | ✅ | Required | ✅ | ❌ |
VRML | .vrml, .wrl | ✅ | ✅ | Required | ✅ | ❌ |
BREP | .brep | ✅ | ✅ | Optional | ❌ | ❌ |
XBF | .xbf | ✅ | ✅ | Optional | ✅ | ✅ |
The CoreDE library provides the main conversion functionality:
// Main conversion function
bool Convert(const std::string& theInputPath,
const std::string& theOutputPath,
bool theTessellate = false);
// Configuration management
bool LoadConfiguration(const std::string& theConfigPath);
bool SaveConfiguration(const std::string& theConfigPath);
// Dynamic library management
bool LoadComponent(std::string theComp);
const std::map<std::string, bool>& Components();
#include "Converter.hxx"
int main() {
// Load configuration
if (!LoadConfiguration("config.conf")) {
std::cerr << "Failed to load configuration" << std::endl;
return 1;
}
// Perform conversion with tessellation
bool success = Convert("input.step", "output.stl", true);
if (success) {
std::cout << "Conversion successful!" << std::endl;
}
return success ? 0 : 1;
}
DE_Wrapper-Sample/
├── src/
│ ├── CoreDE/ # Core library with conversion logic
│ │ ├── Converter.hxx
│ │ └── Converter.cxx
│ └── ConsoleCPP/ # Command-line interface
│ └── Console.cxx
├── data/
│ ├── CONF # Default configuration
│ └── LIBS # Default library list
└── adm/
└── cmake/ # CMake modules
└── FindOCCT.cmake
- Singleton Pattern: Global DE_Wrapper instance management
- Factory Pattern: Dynamic component loading
- Mutex Protection: Thread-safe library loading
- Resource Management: External configuration files
Error: Could not open: [libTKDESTEP.so] or [TKDESTEP.so]
Solution:
- Ensure OCCT libraries are in the library path
- Check file permissions
- Verify library naming convention
Error: Cannot read file: unsupported format
Solution:
- Verify the input file format
- Check if required library is listed in LIBS file
- Ensure file is not corrupted
Error: Tessellation failed for shape
Solution:
- Adjust mesh parameters in configuration
- Check model validity using OCCT tools
- Try different precision values
- Library Loading: Load only necessary libraries for your formats
- Tessellation: Adjust mesh deflection for quality vs. speed
- Parallel Processing: Use thread pools for batch conversions
- Memory Management: Clear document between conversions for large batches
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This sample is provided under the same license as OCCT. Please refer to OCCT documentation for licensing details.
For issues, questions, or suggestions:
- Open an issue on GitHub
- Consult OCCT forums
- Review OCCT documentation
Version: 1.0.0
Last Updated: 2025-08-07
Compatibility: OCCT 7.8.0+