Skip to content
tpaviot edited this page Jan 25, 2012 · 3 revisions

About

The dev branch tp/TKCOLLADA hosts an experimental COLLADA exporter: "COLLADA is a royalty-free XML schema that enables digital asset exchange within the interactive 3D industry".

How to use?

The COLLADA exporter just works as the STL exporter. Here is an example that creates a sphere and exports the result to a DAE file:

BRepPrimAPI_MakeSphere my_sphere(50.);
my_sphere.Build();
ColladaAPI_Writer myColladaWriter;
myColladaWriter.Write(my_sphere.Shape(), "sphere.dae");

You can pass any TopoDS_Shape to the COLLADA exporter. This TopoDS_Shape can come for instance from a standard file (STEP, IGES) or any .brep OCC file. A test was conducted with a part named "cylinder_head", avaible from the OpenCascade.org website (see http://www.opencascade.org/showroom/shapegallery/gal4/).

In the following example, the .brep file is loaded as a TopoDS_Shape and passed to the COLLADA exporter. This generates a file named "15_cylinder_head.dae" which can be imported into Google Sketchup or viewed the the builtin OSX viewer (see screenshots below).

The code for this example is the following:

// import file
Standard_CString aFileName = (Standard_CString) "15_cylinder_head.brep";
BRep_Builder aBuilder;
TopoDS_Shape aShape;
Standard_Boolean result = BRepTools::Read(aShape,aFileName,aBuilder);
// export TopoDS to a DAE file
ColladaAPI_Writer myColladaWriter;
myColladaWriter.Write(aShape, "15_cylinder_head.dae");
}

text

text

Status

So far, the COLLADA exporter only exports a triangular mesh with normals for a single shape. The exporter comes as a new OCE Toolkit, named TKCOLLADA, that was obtained from a copy/paste of the TKSTL toolkit before being modified. The developments are currently in an experimental phase: the code is in a very early stage, docstrings from the STL toolkit ware not modified, the C++ code still need optimization as well as refactoring maybe. These first experiments aim at studying the feasibility of such an impoter/exporter.

The first experiments show that:

  • computing time might be high for some complexe geometries (a few minutes for the cylinder head),
  • the generated DAE file (XML formatted) is quite big: the mesh has to be reduced in order to embed a lightweight tesselation into the XML representation.

TODO/Plans

  • Use LDOM to handle XML elements
  • Add support for multiple shapes (TopoDS_Compound)
  • Update the CDL files
  • Enable passing an AIS_Shape
  • Add support for KMZ export
Clone this wiki locally