CAD Assistant - BRepMesh_IncrementalMesh - Parameters

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.

Dmitrii Pasukhin's picture

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:

Log:Best regards, Dmitrii

miquel valverde's picture

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.

gkv311 n's picture

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().

miquel valverde's picture

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)

Mikhail Sazonov's picture

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

gkv311 n's picture

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
miquel valverde's picture

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/

gkv311 n's picture

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);
}
miquel valverde's picture

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

Mikhail Sazonov's picture

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.