Error importing vrml model

Hello,

When I imported the vrml model, I obtain a mirror of the model. And you can see that the letters are in the opposite direction. I don't know how to solve this problem. Do you have any good suggestions?

Here's my code to import vrml file:

Handle(TDocStd_Application) m_app;
Handle(TDocStd_Document) m_doc;
Handle(VrmlAPI_CafReader) m_reader;

m_app = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(m_app);
m_app->NewDocument("BinXCAF", m_doc);

m_reader = new VrmlAPI_CafReader;
m_reader->SetDocument(m_doc);

TDF_Label mainLabel = m_doc->Main();
Handle(XCAFDoc_ShapeTool) myShapeTool = XCAFDoc_DocumentTool::ShapeTool(mainLabel);

Message_ProgressRange range;
m_reader->Perform(fileName, range); // vrml filepath

TDF_LabelSequence FreeShape;
myShapeTool->GetFreeShapes(FreeShape);
int Roots = FreeShape.Length();

for (int index = 1; index <= Roots; index++)
{
TDF_Label label = FreeShape.Value(index);
Handle(XCAFPrs_AISObject) displayedShape = new XCAFPrs_AISObject(label);

m_context->Display(displayedShape, false);
}

Please change the file suffix name from .info to .wrl, because we are unable to upload the .wrl file.

Dmitrii Pasukhin's picture

Hello, I guess you need to specify direction.

You have 2 ways:

Use DE_Wrapper interface:

Handle(Vrml_ConfigurationNode) aNode = new Vrml_ConfigurationNode();
// Setting up read process
// aNode->InternalParameters...
// aNode->GlobalParameters...
// Directions have correct default value look into 
// InternalParameters.ReadFileCoordinateSys
// InternalParameters.ReadSystemCoordinateSys
Handle(DE_Provider) aVrlmProvider = aNode->BuildProvider();
//Init doc
Handle(TDocStd_Document) aDocument;
//...
//
const TCollection_AsciiString aPath = "";
bool anIsDone = aVrlmProvider->Read(aPath, aDocument);

Call methods into VrmlAPI_CafReader:

  VrmlAPI_CafReader aVrmlReader;
  aVrmlReader.SetDocument(theDocument);
  aVrmlReader.SetFileLengthUnit(1.0);
  aVrmlReader.SetSystemLengthUnit(0.001); //mm
  aVrmlReader.SetFileCoordinateSystem(RWMesh_CoordinateSystem_Yup);
  aVrmlReader.SetSystemCoordinateSystem(RWMesh_CoordinateSystem_Zup);
  aVrmlReader.SetFillIncompleteDocument(true);

Best regards, Dmitrii

Vispec DMIS's picture

Thank you very much for your suggestion. I have solved my problem perfectly using the VrmlAPI_CafReader method you provided.

Best regards, Vispec