How to control the size of triangulation during the triangulation mesh

How to control the size of triangulation when use BRepMesh_Discret to do triangulation mesh?

For the same shape, how to control the number of triangles during the triangulation mesh?

Thank you in advance

Rob Bachrach's picture

You can't really control the number, size or shape of the triangles directly. The only thing you have control over is how closely the triangles approximate your surface. If you have curved edges or surfaces, changing the angle and deflection will produce more or less triangles, but you do not have fine control over this. If you want better control over the mesh, you need a FEM style mesh framework like OCC ExpressMesh, the OCC Mesh Framework, or one of the public domain options like NETGEN.

P Dolbey's picture

I've been playing with some of the open source stuff in this space. So far I've compiled up a standalone version of Tetgen - this will read in STL files directly and remesh them. This does produce a quality tet mesh, which can be viewed with its own viewer TetView. Tetgen can be configured as an API but I haven't yet build it this way. However I prefer the quality of the meshes created by GMSH but haven't yet separated the mesher from the GUI. It should theoretically be possible to create a MeshVS datasource, similar to (or fudged from) the exising VRMLSTL API to render the output in OCC. Still working on this. Alternatively it could be run as pre-processor (but thats cheating in my opinion).

NETGEN (or as Salome plugin) will be another avenue of investigation, but I'm still having problems getting a clean compile 4.5 on VS2005, and again I need to separate the GUI from the meshing algorithms - anybody else managed this?

The issue of quality meshing in OCC seems like one of those jokes "You're the hundredth person whose asked for that today - I keep telling you there's no demand"

Pete

QbProg's picture

Hello,
it is really easy to implement a MeshVS_DataSource, you just need to reimplement some methods (i.e. fill the data).
I've implemented it to display STL meshes in OCC. I can not publish the code, but it is a matter of 15 mins.

Good Bye !

P Dolbey's picture

Thomas,

The code for importing STL is quite neatly handled by OCC internally - the final code segment in http://www.opencascade.org/org/forum/thread_9793/ provides an outline solution. But it would be very useful to have a generic template to handle other mesh datasources - if possible I'd like a virtual C++ mesh interface which could be subclassed to handle tetgen, netgen, gmsh and so on. If you can't publish, can you identify the major activities?

Pete

lejingwang's picture

Thank you first! What is the angle and deflection? How do them affect the triangle approximation of the surface?

Rob Bachrach's picture

The deflection is the maximum distance between the actual surface and the triangulation. This sets the amount by which curves in the surface can be flattened.

I have never seen documentation on the angle. As far as I can tell, the angle is the angular deflection. I think that this takes two subsequent vertices on the meshed edge. It then find the approximate midpoint on the edge between these vertices. The angular deflection is the sign of the angle between the vectors formed by two vertices and the midpoint. The closer this number is to 0, the closer these points must be toward linear (ie. less distance to the original curve).

hunter_wwq's picture

Hi, I'm developing using OpenCascade,appreciate your answers!I have other opinion about the angle parameter, in Mesh refinement algorithm, it will probably used triangulation algorithm such as constrained Delaunay triangulation method, and this method had used angle to constrain every angles of the producing triangle. Thus I guess that the angle parameter in OCC is used to constraint the minimal angle of triangles while processing triangulation algorithm.