VRML import


I would like to use OpenCASCADE to create STEP files from existing VRML 2.0 data (in the end this shall become a STEP export filter which is integrated into an existing software product). At the moment I'm running some tests, and there are some problems:

First of all the VRML 2.0 import doesn't seem to be reliable. I tried to read a VRML file and convert it to a TopoDS_Shape using these lines of code:

std::ifstream in("vrmlfile.vrml");
VrmlData_Scene scene;

After this, scene.Status() gives me a VrmlData_VrmlFormatError in most cases. But all the models I tried can be read by other software without any problems. What is wrong here?

But this is not the real problem for me because in our software the VRML data is loaded by another library (and this will probably never change...), so let's assume the VRML data is already in memory and just has to be transferred to the OpenCASCADE representation. I've started to write a converter that creates a VrmlData_Scene from the already existing data. This scene can then be converted to a TopoDS_Shape which can be exported as STEP file. This works well as long as my file only uses very simple geometries (Box, Cone, Cylinder, Sphere). But as soon as I try to load and convert a VRML file which contains an IndexedFaceSet, the software crashes during the STEP conversion. If I try to apply a shape healing algorithm (I tried with ShapeFix_Shape), the software crashes while the healing is performed. I have tracked the problem and found out that the algorithm is trying to retrieve and use a Geom_Surface handle via BRep_TFace::Surface(), but the Geom_Surface is a NULL handle which leads to a crash.

Does anyone know a solution for this? Or do I have to write the conversion from VRML to the TopoDS_Shape from scratch?
Any help would be appreciated. Thanks


Alexander Müller's picture

For all people with this problem finding this thread: I had the same problem and my solution was before I import a vrml file with the VrmlData_Scene::<< operator to remove Sensor Nodes, EXTERNPROTO Nodes and ROUTE operations. Maybe there are more node types which were not successfully read and causes the VrmlData_VrmlFormatError.