Using "BRepMesh_FastDiscret"

I want to make tri mesh using "BRepMesh_FastDiscret"
My code is in belows.

==================================================
const TopoDS_Face& F = TopoDS::Face(myFace);

Handle(Poly_Triangulation) T;
TopLoc_Location loc;

Bnd_Box aBox;
Standard_Boolean bWithShare = Standard_True;
Standard_Real aDiscret, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Standard_Real dX, dY, dZ, dMax, aCoeff;
BRepBndLib::Add(F, aBox);
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);

dX = aXmax-aXmin;
dY = aYmax-aYmin;
dZ = aZmax-aZmin;
dMax = dX;
if(dY > dMax) {
dMax = dY;
}
if(dZ > dMax) {
dMax = dZ;
}

aCoeff = 0.001;
aDiscret = aCoeff * dMax;
BRepMesh_FastDiscret aMesher(aDiscret, 0.5, aBox, bWithShare, Standard_True, Standard_False, Standard_True);

aMesher.Add(F);
Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, loc);
==================================================

Geometry Shape is simple square.

In this case, "facing" returns just two tri meshs.
I want to control the mesh seed and make finer mesh.

What is my fault in my code?

Rob Bachrach's picture

The meshing built into OCC (like FastDiscret) is taylored to generate meshes required for displaying the shapes. Therefore, it will only ever generate 2 triangles for a rectangular face, since that is all that is needed to display it. The deflection and optional angle arguments are used to control how closely the mesh conforms to curved edges and surfaces.

If you want a finer mesh even for rectangular surfaces, you need to use a separate meshing tool or library.