Hide menu
Loading...
Searching...
No Matches
CDXWEB Converter Example

Converts a CAD file to CDXWEB format used in Web Toolkit.

Overview

The CDXWEB Converter shows how to import models from different formats and export their data to CDXWEB format, which can be used to display CAD models in the web browser with the help of Web Toolkit.

Export to CDXWEB

Export to CDXWEB format is enabled using ModelData_WriterParameters:

ModelData_WriterParameters aParams;
@ CDXWEB
Definition: ModelData_WriterParameters.hxx:32

The options below can be used to optimize the export. In this snippet the parameters are set to default values explicitly. Assign them the values you need for customization.

aParams.WriteBRepRepresentation() = true;
aParams.WritePolyRepresentation() = true;
aParams.PreferredLOD() = ModelData_RepresentationMask::ModelData_RM_MediumLOD;
aParams.WriteTextures() = false;
aParams.WritePMI() = false;

Let's call ModelData_Model::Save() method to store data in CDXWEB file format:

if (!aModel.Save (aDest, aParams)) {
cerr << "Failed to write the file " << aDest << endl;
return 1;
}

Usage

You can try this example with the following model:

./examples/models/Radial_Engine.jt

CDXWEB model usually consists of multiple files. When ModelData_Model::Save() is called with "scenegraph.cdxweb", a few auxiliary files will be created next to scenegraph.cdxweb. Therefore writing multiple CDXWEB models to a single directory might make it hard to navigate. It is recommended to save each CDXWEB model to a separate folder. Any folders you specify in the output path that are not yet present in the filesystem will be created automatically.

Save the model to the source folder for this example:

./examples/cxx/conversion/cdxwebconverter/Radial_Engine.jt.cdxweb/scenegraph.cdxweb

Files