Deflection and mesher

Hi,

Looking for a mesher to convert from STEP/IGES to my own data format, I need to use a mesher.

1st question : What is the deflection ? I didn't found anything about that.
And what about the Angle ? (default = 0.5)

2d question : Why is there so much mesher ? is there a best one ?
* BRepMesh_IncrementalMesh
* BRepMesh_FastDiscret
...

Thanks for your help.

Vincent.

Rob Bachrach's picture

To my understanding...

The deflection is the maximum distance between an edge of your mesh and the corresponding surface. This will always be non-zero for a curved surface.

I believe the angle refers to the angular deflection of your mesh at the edges of your shape. This is best described in the documentation for the GCPnts_TangentialDeflection class, which is actually used by the mesher.

As for the meshers, IncrementalMesh actually calls FastDiscret. The only difference is that IncrementalMesh will only remesh the shape if the deflection gets smaller. Equal or greater deflections are ignored.

Rob

_VincentB_'s picture

Hi Rob.

Thanks for the explanation.

For the moment, my meshed file is very very detailed in some part... so from the original file (~100k face) i get a huge model (~4M face)... So I'm looking a way to mesh without so much faces.

In all the Meshers, is there one which is not so precise ?
BRepMesh::Mesh
BRepMesh_Discret
BRepMesh_IncrementalMesh
BRepMesh_FastDiscret
... (maybe more)
Can it change anything to use a delaunay mesher ? (I just saw one)

I assume the deflection have to be bigger for a smaller number of face... but even with 100 I cannot get less than 3.8M faces...

I get every idea that can help me.

thanks a lot.

Regards,
Vincent.

PS : sorry for the newbie questions, I jsut have started OCC few days ago.

Rob Bachrach's picture

Wow! That's a lot of faces.

I don't believe that BRepMesh_Discret is no longer supported under OCC 6.3. However, it wasn't very different from FastDiscret. BRepMesh::Mesh simply calls BRepMesh_IncrementalMesh, which calls BRepMesh_FastDiscret. So, don't expect anything different. I believe that BRepMesh_FastDiscret actually uses a delaunay mesher under the covers. So that probably won't help much.

Understand that every face will be meshed. So, I high number of mesh elements is not surprising. If you have a highly contoured surface, 1000 or more triangles is not rediculous, you just have a high number when all the faces are accumulated.

Maybe, you could consider simplifying your geometry (removing small faces, rounds, chamfers, embossments, etc). If you limit the number of faces and the contours of those faces, you could reduce the resulting triangles.

Another option might be to mesh the faces independantly, each with an appropriate deflection. Note, however, that this will remove your smooth transition at the edges between faces.

Finally, you could consider a finite element surface mesher, like netgen, the one on Salome, or the commercial OCC mesher. These would be slower in creating the mesh, but give you more control over what is generated.

Good luck,
Rob

_VincentB_'s picture

Okay,

So nothing to do one the mesher for the moment.

But I can simplify the geometry, but how to detect if a face/Shape is a chamfer, embossments, ... ?

I currently work on TopoDS_Face and Handle_Poly_Triangulation to build my own geometry.

thanks,
Vincent.

Rob Bachrach's picture

That is a challenge in its own right.

The easiest part is to eliminate small faces. You can use ShapeFix_FixSmallFace to help with this.

Although it is not trivial, you can also write code to find adjacent faces that share the same underlying surface. Depending on the connected faces, you may be able to replace them with a single face. Starting with planar surfaces is the easiest way.

Identifying things like chamfers, fillets, embossments, etc. is a project unto itself and these items may have different definitions depending on the application. I don't know of any built in OCC tools to help with this.

Good luck

Jun WANG's picture

Actually all of Mesher APIs can NOT generate manifold meshes, if there are more than one surface in your IGES file. You can find that the non-manifold will occur at the bounday of adjcent surfaces, i.e. the triangle meshes at the boundary are not cocicident. If there is only one surface in your IGES file, it works well. Below is my sample codes. Hope it makes sense.
-----------------------------------
Bnd_Box myBox;
BRepBndLib::Add (m_topoShape, myBox);

double myDeflection = 0.1;
double myDefAngle = 0.17;
try {BRepMesh_FastDiscret* myMesh =
new BRepMesh_FastDiscret(myDeflection, m_topoShape, myBox, myDefAngle,
Standard_True, Standard_True,Standard_False,Standard_False); // BRepMesh_Discret is Okay as well
}
catch (...) {
BRepMesh_IncrementalMesh(m_topoShape, myDeflection, false, myDefAngle);
}
-----------------------------------

In addition, you can also translate your question to another way:
Step 1. Open your IGES file with OCC
Step 2. Save it with STL format with OCC
Step 3. Then Open the *.stl file

Accordingly, the file is automatically converted into triangle mesh. In this situation, the problem I mentioned above also is inevitable because the Step(2)also implictedly call the mesher APIs in OCC when you investigate the source codes.

Stephane Routelous's picture

>> the triangle meshes at the boundary are not cocicident

That's not true if your edges are shared

Stephane

Jun WANG's picture

Thanks for your reply.

Actually I have set the fourth para(withShare) with TRUE in the BRepMesh_FastDiscret(,,,TRUE,...), please see my post above. Even so, I get the triangle meshes at the boundary are not cocicident. I am not sure if other setting is corrent? would you pleas give me some instruction.

Thanks a lot.

Stephane Routelous's picture

did you try sewing your faces together with BRepBuilderAPI_Sewing ?

Stephane

_VincentB_'s picture

Hi Jun,

My problem is i use files with more than one surface...

I am building a scenegraph when reading the file, making a new geometry per Shape.
The stl writer can help, but it makes objects distinction/separation disappear, color disappear... so this is not a good solution for me.

How do you determine the defAngle ? (I put 0.5 by default...)

Thanks.

Vincent.

Anup's picture

Hi Rob,

Can you please help me with this. I have written a code to convert from IGES/IGS file to STL file. When i was using OCC-6.6.0 this code was working perfectly, Due to some reasons i had to migrate to Visual studio 2013 so i downloaded OCC 6.9.1, Now i am facing with weird issue which i am not able to resolve. I have attached screenshot while i debug you can have a look at it. The following is my code

    IGESControl_Controller::Init();
    IGESControl_Reader My_reader;

    Standard_Integer status = My_reader.ReadFile(file);

    status = My_reader.TransferRoots();

    /// The shape stores all translated data as single shape
    IGES_Shape = My_reader.OneShape();

    status = IGES_Shape.IsNull(); //  <--- --- ---- over here the status value is 0 i.e., Standard_boolean value is false /// so the shape is not NULL
    

    StlAPI_Writer wr;
    status = wr.Write(IGES_Shape, "temp/IGES_Temp.stl"); // <- - --- --------- ( over here the status value is 1 i.e., //StlAPI_ErrorStatus = StlAPI_MeshIsEmpty  which is showing me that the mesh is empty.)

Please help me out guys. I havent faced with this issue earlier.

Timo Roth's picture

Dear Anup,

probably the reason is a change in OCC 6.9.0. STLWriter no longer crates a triangulation. See Release Notes or Mantis issue #25357.

So before calling the STL writer, you have to mesh the shape using BRepMesh_IncrementalMesh.

Regards