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

rahulmulik9's picture

Hi Dimitrii,
I have tried same approach.
But aVrlmProvider giving me error : pointer to incomplete class type is not allowed.
Also
in aVrmlReader apart from SetDocument, id didn't find any other methods.
Thank you in Advance.

Dmitrii Pasukhin's picture

It is compiling issue. Please add #include lines of any classes that you are using or trying to use including as a non-direct casting. As for a document, you need to create (initialize) one before using.

If problem still here, please share logs and code samples :)

Best regards, Dmitrii.

rahulmulik9's picture

Sorry. It was my mistake. Code is working fine.
But I am not able to load the model.
I have tried to open model in CAD Assistance also. But that application also fails to open model. (See attached model)
Error is : VrmlData_VrmlFormatError
Thank you Dmitrii.

Attachments: 
Dmitrii Pasukhin's picture

Let me chack the issue. I will return to you during a week. We resolve an issue with VRML #1 in 7.8 I hope it will help with first file. But for now, could you please share the version of OCC, that are you using.

In bug case i will create an issue in bug tracker and share the link. The priority in case of small fix will be increased.

Best regards, Dmitrii.

rahulmulik9's picture

Currently I am using version 7.7

Dmitrii Pasukhin's picture

Hello, the issue in insupported type.

Issue: 0033745: VRLM Import - Unsupported type MaterialBinding - MantisBT (opencascade.org) for wrl file. As for a vrml file it is read correct with no issue:

 

VRML Reader is very sensetive, indeed need to find a way to process and skip unsupported types. Issue created, there are no planning for that issue for now.

As for a 

Best regards, Dmitrii.