For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Exception during Meshing / Missing triangles

Göran Barz's picture
Forums: 

Hello,

when I import the attached step file and try to mesh it, I receive an exception in one of the faces. I use OCC 6.5.1 but the Exception also occurs in the current beta-Version of OCC 6.5.3.

The exception occurs in the methode BRepMesh_DataStructureOfDelaun::AddElement(const BRepMesh_Triangle& theElement)
in the line
myLinks(ed2).Append(ElemIndex);

If I use a try-catch-block to handle the exception, some triangles are missing in the triangulation

Here is some sample-Code to reproduce this error:

Handle(TDocStd_Document) hDoc;
XCAFApp_Application::GetApplication()->NewDocument("MDTV_XCAF", hDoc);
STEPCAFControl_Reader reader;
reader.SetColorMode(true);
reader.ReadFile(strFileName);
reader.Transfer(hDoc);

for (TDF_ChildIterator it(XCAFDoc_DocumentTool::ShapesLabel(hDoc->Main())); it.More() && !progress.canceled(); it.Next())
{
if (XCAFDoc_ShapeTool::IsSimpleShape(it.Value()))
{
TopoDS_Shape shapeCurrent;
XCAFDoc_ShapeTool::GetShape(it.Value(), shapeCurrent);

TopExp_Explorer expFace;
expFace.Init(shapeCurrent, TopAbs_FACE);
int nMin(371), nMax(371); //The exception occurs in face 371
for (Standard_Integer numFace = 0; expFace.More(); expFace.Next(), ++numFace)
{
if (numFace nMax)
continue;
TopoDS_Face myFace = TopoDS::Face(expFace.Current());
Handle(Poly_Triangulation) myT = BRep_Tool::Triangulation(myFace, myLocation);
if (myT.IsNull())
{
BRepMesh_IncrementalMesh Mesh(myFace, 0.7, Standard_False, 0.75);
myT = BRep_Tool::Triangulation(myFace, myLocation);
}
}
}
}

Regards

Göran

Attachments: 
Pawel's picture

Hi Göran,

you're meshing a face for which you know the triangulation is Null.

Use

if(!myT.IsNull())

instead of

if(myT.IsNull())

Pawel

Göran Barz's picture

Hi Pawel,

the meshing is used to create the triangulation, if it doesn't exist, so if the face already has a triangulation, the meshing is not necessary. For the other faces of the step file, the meshing works without any problem.

Göran

Pawel's picture

Yes sorry,

I checked the file but with a slightly different logics:
I mesh with StlTransfer::BuildIncrementalMesh and then expect each face to have a triangulation on it.

Anyway, for you model one face is not triangulated but no exception occurs. It is probably handled somewhere in StlTransfer::BuildIncrementalMesh.

Pawel

Göran Barz's picture

Hi Pawel,

your right, the exception is caught internally by BRepMesh_FastDiscretFace::Add, but as a result of the exception, one triangulation is missing just as you saw it in your tests.

Göran

Forum supervisor's picture

Dear Göran,
The exception is not reproduced (OCCT6.5.2 is used) as for the face 371 as for the entire solid.
See below Draw reproducer.

Draw[25]> pload ALL
Draw[26]> smallview
Draw[27]> stepread 3359.500_Klima_high.stp s *
# ...
# STEP Loading done : 27844 Entities
# File STEP to read : 3359.500_Klima_high.stp
# -- Names of variables BREP-DRAW prefixed by : s
#Transferrable Roots : Nb entities selected : 1
#Transfer entity n0 34 OK -> DRAW Shape: s_1
#Now, 1 Shapes produced
Draw[28]> explo s_1 F
Draw[29]> don s_1
Draw[30]> fit
Draw[31]> incmesh s_1_371 0.1
#Meshing statuses: NoError
Draw[32]> trinfo s_1_371

#This shape contains 18 triangles.
# 20 nodes.
#Maximal deflection 0.046205413718201908

Draw[39]> triangles s_1_371 ## the triangles will be displayed if exist

## and for the Solid
Draw[40]> incmesh s_1 0.1
#Meshing statuses: NoError
Draw[41]> trinfo s_1

#This shape contains 20049 triangles.
# 16460 nodes.
#Maximal deflection 1.2190478901163622

You may try this script in your local environment.
Regards

Forum supervisor's picture

See also the picture (face 371) attached.

Attachments: 
Göran Barz's picture

If you do it this way, the error should occure in triangle 372. I startet counting at 0 because I'm used to it from C++, OCC containers usually start counting at 1. Sorry for using the wrong count.

Göran

Forum supervisor's picture

Dear Göran,
I would like to inform you that the posted problem for the face s_1_372 (see the attached picture) has been reproduced => Standard_OutOfRange exception.
I suggest you to register the issue in Mantis Bugtracker which is available now via the Collaborative portal - http://dev.opencascade.org/index.php?q=home/get_involved.
Regards

Attachments: 
Göran Barz's picture

Thanks, I've just registered and reported the issue.

Göran