Re-mesh previously meshed surface

When using BRepMesh_IncrementalMesh on a shape it gladly meshes the shape according to the parameters specified. Now, when I want to 're-mesh' that same shape the meshing only happens when the parameters given request a smaller deflection. I understand that this is the expected behavior. Is there a way to tell BRepMesh_IncrementalMesh to mesh a shape that has been previously meshed with the parameters given, regardless if these request a smaller deflection or not? In other words how can this behavior be switched off? Thanks.

Nathaniel Essenberg's picture

I don't know if BRepMesh_IncrementalMesh is supposed to ignore new parameters even if they are courser...

Maybe a workaround would be to use BRepTools::Clean first?

Kirill Gavrilov's picture

No re-meshing in this case is a current design of BRepMesh_IncrementalMesh and expected behavior.
Thus, BRepTools::Clean() is not a workaround, but expected interface in case if user really needs re-meshing shape.

Oliver R's picture

Thank you. This is exactly what I was looking for.

JUSTIN SAVAGE's picture

Does this work if the mesh is input from .obj using RWObj_TriangulationReader? If not, is it possible to remesh a mesh from .obj?

Dmitrii Pasukhin's picture

Hello, no. Generated mesh based on BRep(geometry). If something has no related geometry you can't regenerate mesh with pure mesh objects with OCC tools. When cleaning model, please check that any of cleaned shapes has geometry to re-generate mesh.

Best regards, Dmitrii.

gkv311 n's picture

Justin wrote:

Does this work if the mesh is input from .obj using RWObj_TriangulationReader? If not, is it possible to remesh a mesh from .obj?

BRepMesh works only on analytical geometry - B-Spline, conical surfaces and others, while OBJ file defines nothing but triangulation.

There are remeshing and mesh refining algorithms that could be found in the wild, but OCCT doesn't offer any of them right now (as it is focused to work with analytical B-Rep geometry).

Gena Sorokin's picture

When working with BRepMesh_IncrementalMesh and needing to remesh a shape with specific parameters regardless of deflection, consider these steps:

1 Clear Mesh Data: Before calling BRepMesh_IncrementalMesh again, ensure that any existing mesh data for the shape is cleared or reset. This can be done by using appropriate functions or methods provided by the library or toolkit you are using.

2 Check Mesh Quality: Evaluate the quality of the existing mesh to determine if remeshing is necessary. If the current mesh meets your requirements, you may choose to skip remeshing to save computational resources.

3 Custom Remeshing Logic: Implement custom logic to control the remeshing process based on your specific needs. This may involve creating wrapper functions or classes to encapsulate the meshing operations with desired parameters and remeshing conditions.

By combining these strategies, you can achieve more control over the meshing process and ensure that shapes are remeshed according to your specified parameters when needed.