OCC7.2 Import/Export problems

Hi,

I am using the 7.2 version for my application ported from release 6.6.0. I have problem with export of vrml and stl file. The code is the same as the ImportExport sample, but when I try to export an vrml file i get an empty file(only header) and with export of stl the app crashes.

Have any one the same problem ? What can I check ?

 

 

 

Patrik Mueller's picture

Hi,

6.6.0 triangulates inside the writers. In newer versions you have to build the triangulation by yourself before using a writer!

Greets,

Patrik

Marco Balen's picture

Hi Patrik,

Thank you for the information.

Have I to use BRepMesh_IncrementalMesh() on the shape before writing it ?

Is there another method ? Have you any reference to this behaviour change ? (release Notes? Version ?)

Patrik Mueller's picture

Hi Marco

https://www.opencascade.com/content/problem-stlapiwriter-occ-700 :

Since version 6.9.0, STL writer relies on triangulation stored in the shape for exporting STL data (see Release Notes of OCCT 6.9.0, issue 25357).
This allows better control over  the quality of the triangulation (in previous versions shape was triangulated by STL writer internally).
Use BRepMesh_IncrementalMesh to build triangulation before calling StlAPI_Writer.

Greets,

Patrik

Marco Balen's picture

Hi Patrik,

Ok, I have understand and will try it.

Do you think the missing triangulation is the origin of empty file also for vrml exports ? I am loading an iges file and than i write it in wrl format. I think if I display the shape it will be triangulated, but converting it from iges to wrl I have to triangulate it before saving.

Do you think so ?

Patrik Mueller's picture

Hi Marco,

I also think so. For display in an AIS_Context, shapes are meshed. So the export should be successful (you can test it with ImportExport sample), because the Poly_Triangulation is already added to the shapes.

Greets,

Patrik

Marco Balen's picture

Hi Patrik, 

I have tried to insert this code to triangulate the shape before write it.

  const Standard_Real aLinearDeflection = 0.1;
  if (BRepTools::Triangulation(shape, aLinearDeflection) == false) {
      BRepMesh_IncrementalMesh aMesh(shape, aLinearDeflection);
  }

  bool bcheck= BRepTools::Triangulation(shape, aLinearDeflection);

This works for WRL write, but I get an exception writing stl(the same situation as reported in the link you have sent me) !

Checking if the shape was triangulated after the BRepMesh I get always false. 

Have you any idea ?

Patrik Mueller's picture

Hi Marco,

have you tried a STL export from the ImportExportSample with such a problematic IGES file?

I always do the "BRepMesh_IncrementalMesh aMesh(shape, aLinearDeflection);" without checking (if you look inside the source, you'll see there are several possibilities for false as result). For example, If you also do a preview, the preview can have a higher deflection and BRepTools::Triangulation will return false.

Can you post such a file?

What is shown in debug mode?

Greets,

Patrik

Marco Balen's picture

Hi Patrik,

I am checked with OCC ImportExport application and I get the same error on same files.

In debug I have seen that same faces of the shape don't have Nodes and triangles.

Standard_Boolean StlAPI_Writer::Write(.........)

.........

const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();

aNodes and aTriangles do not contains valid data and this is unexpected.

ASSE_2.igs,ASSE_6.igs, Esempio2.igs cannot be converted.

Can you check with your app ?

Thank you in advance

Attachments: 
Nico Probst's picture

Is there already a solution to this problem?

When i try to write to a file with STLWriter.Write i get following exception in StlAPI_Writer.cxx in Line 75: Read Access Violation "aNodes" was 0x18.

This also occurs when i run the QT IESample.

Thank you in advance.

Vishesh Chanana's picture

This is out of context but can the import/export convert an STL file into a STEP file??

Marco Balen's picture

You can convert from STEP/IGES to WRL/STL.

From STL/WLR to STEP/IGES i think you have to rebuild the surface from the points.