DiscussionsIssue archiveData Exchange and Application Framework

Archived discussion

Error importing vrml model

Data Exchange and Application FrameworkWed, 06/07/2023 - 06:299 replies

Browse this forum
QuestionAuthor

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.

Discussion

9 archived replies

Posts are displayed in their archived order.

01Commenter-1

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, Commenter-1

02Author

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

Best regards, Author

03Commenter-2

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.

04Commenter-1

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, Commenter-1.

05Commenter-2

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.

06Commenter-1

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, Commenter-1.

07Commenter-2

Currently I am using version 7.7

08Commenter-1

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:

Archived image: 004-vrml.png

 

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, Commenter-1.

09Commenter-2

Could you please let me know which VRML node types are supported in Open Cascade 7.9, and which VRML versions (e.g., 1.0 or 2.0) are compatible?