Forum archiveIssue archiveModeling Data and Algorithms

Archived discussion

CAD Assistant - BRepMesh_IncrementalMesh - Parameters

Modeling Data and AlgorithmsWed, 04/17/2024 - 17:2710 replies

Browse this forum
QuestionAuthor

So CAD Assistant has 5 levels of detailing to perform Meshing: ["Very Rough", "Rough", "Normal", "High", "Very High"]

Can we know which are the "Normal" exact parameters being used to set BRepMesh_IncrementalMesh? (deflection, deflection interior, angle, angle interior, minSize, etc.)

If confidential, please share the ones being used inside Draw Harness.

Thanks.

Discussion

10 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hello, that is not a secret and you are free to find that info in logs.

The related with enum param:
DeviationCoefficient (0.001);
DeviationAngle (M_PI * 20.0 / 180.0);

Enabling logs:

Archived image: 001-Screenshot%202024-04-18%20101701.png

Log:Archived image: 002-Screenshot%202024-04-18%20101802.pngBest regards, Commenter-1

02Author

Thank you so much for this insight!

I've recreated it like this:

meshParams.MeshAlgo = IMeshTools_MeshAlgoType::IMeshTools_MeshAlgoType_DEFAULT;
meshParams.Angle = 0.34906585;
meshParams.Deflection = 0.001;
meshParams.MinSize = 0.1;
meshParams.InParallel = 1;
meshParams.InternalVerticesMode = 1;
meshParams.ControlSurfaceDeflection = 1;
auto mesher = BRepMesh_IncrementalMesh(face, meshParams);

But with those parameters I get 67,243 triangles , and in CAD Assistant it gets 10,286 triangles, so its way more optimized somehow.

03Commenter-2

You set Deflection=0.001, while CAD Assistant uses Deflection close to 0.1. The 'rel' means 'relative' calculated from bounding box (the explanation from here might help) using math like StdPrs_ToolTriangulatedShape::GetDeflection().

04Author

So I used your personal blogspot commands with a specific brep face (0:1:1:1:1) of the initial .iges file that I shared . It is also attatched as outputBFace.brep

Also isn't there any commands to perform meshing this quick but with the whole .iges file directly, instead of only a face?

But still pretty ugly triangularization I think, isn't it? (LOOK AT THE IMAGE ATTATCHED)

05Commenter-3

In your incmesh command you used deflection 100, which is quite large value I think to get a good triangulation.

06Commenter-2

You haven't shared your script. I guess you have read IGES file into XCAF document via ReadIges command. In this case you may use XGetOneShape command to get entire document as a shape:

ReadIges D model.iges
XGetOneShape s D
incmesh s -prs
07Author

So, indeed the holy grail was to do meshing with all faces in a compound, instead of meshing faces one by one....

Now the other question is how do I use "ComputeNormals()"? I mean I have all the triangularizations done, and topology is good, but my model looks like "flat shading" after I generate a .obj out of it... It doesn't look like "averaged normals" or "surface normals" like here:

https://unlimited3d.wordpress.com/2024/03/17/brepmesh-intro/

08Commenter-2

Something like this?

TopoDS_Compound theComp = ...;
TopLoc_Location aLoc;
for (TopExp_Explorer aFaceExp (theComp, TopAbs_FACE);
      aFaceExp.More(); aFaceExp.Next())
{
  const TopoDS_Face& aFace = TopExp::Face(aFaceExp.Current());
  const Handle(Poly_Triangulation)& aTri = BRepTool::Triangulation(aFace, aLoc);
  if (aTri.IsNull()) { continue; }

  BRepLib_ToolTriangulatedShape::ComputeNormals(aFace, aTri);
}
09Author

Thank you very much. With everything I discovered here I finally have it perfectly.

Key takeaways:
- use relative/absolute deflections based from bounding box of compound.
- use compound (instead of meshing by individual face shapes)
- use smooth normals from brep (instead of averaging mesh face normals)

How can this simple API call tweak be so different.....
triangulation->ComputeNormals(); // BAD
BRepLib_ToolTriangulatedShape::ComputeNormals(face, triangulation); // GOOD

10Commenter-3

Did you use the command "vdefaults -autoTriang 0" before displaying? If you didn't then the command "vdisplay" can ignore the available triangulation and build a new one.