Fri, 03/30/2018 - 16:57
Forums:
Hi everyone,
I am new with opencascade. I would like to create a geometric entity (plane/cylinder/circle/sphere...) and triangulate this entity in order to draw it in my own viewer (not in the opencascade one).
// This is how i create my plane :
gp_Pnt p(i_p->getCenter().x(), i_p->getCenter().y(), i_p->getCenter().z());
gp_Dir dir(i_p->getNormal().x(), i_p->getNormal().y(), i_p->getNormal().z());
gp_Pln plane(p, dir);
// Then a create the shape of the face :
const Standard_Real aRadius = 10.0;
const Standard_Real aHeight = 25.0;
BRepBuilderAPI_MakeFace aPlane(plane);
TopoDS_Shape aShape = aPlane.Shape();
// Now I triangulate the shape :
const Standard_Real aLinearDeflection = 0.01;
const Standard_Real anAngularDeflection = 0.5;
BRepMesh_IncrementalMesh aMesh(aShape, aLinearDeflection, Standard_False, anAngularDeflection);
aMesh.Perform();
if (aMesh.IsDone() == false) return;
TopExp_Explorer exFace;
// for each Face (object)
for (exFace.Init(aShape, TopAbs_FACE); exFace.More(); exFace.Next()) {
// get the face
TopoDS_Face face = TopoDS::Face(exFace.Current());
TopLoc_Location loc;
// get the triangulation
Handle(Poly_Triangulation) tri = BRep_Tool::Triangulation(face, loc);
if (tri.IsNull()) continue;
}
My problem is : tri.IsNull() is always equal to true... I don't understand where is my mistake because the value of aMesh.isDone() is equal to "true" and in the documentation that mean "the triangulation was performed and has success". I use the same method to read and triangulate a step file and it's work.
I am very grateful if someone knows the correct solution to do that.
Thk,
Manon
Sun, 04/01/2018 - 13:23
Hi Manon,
do you really need a infinite plane? I'm not sure if OCC bounds such a plane inside BRepBuilderAPI_MakeFace.
What happens if you try something like this
BRepBuilderAPI_MakeFace aPlane(plane, 0.0, 1.0, 0.0, 1.0);
?
Greets,
Patrik
Tue, 04/03/2018 - 11:13
Hello Patrick,
It works ! Thanks you very much, I totally forgot to restrict the plane...
Manon