Part: add functions to return the number of nodes and triangles of a tessellation

This commit is contained in:
wmayer
2023-04-11 12:32:34 +02:00
committed by wwmayer
parent 88ee605dd1
commit 122ab14d92
4 changed files with 66 additions and 0 deletions

View File

@@ -757,6 +757,40 @@ PyObject* TopoShapeFacePy::validate(PyObject *args)
}
}
PyObject* TopoShapeFacePy::countNodes(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
TopoDS_Face aFace = TopoDS::Face(shape);
TopLoc_Location aLoc;
const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
int count = 0;
if (!aTriangulation.IsNull()) {
count = aTriangulation->NbNodes();
}
return Py::new_reference_to(Py::Long(count));
}
PyObject* TopoShapeFacePy::countTriangles(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
TopoDS_Face aFace = TopoDS::Face(shape);
TopLoc_Location aLoc;
const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
int count = 0;
if (!aTriangulation.IsNull()) {
count = aTriangulation->NbTriangles();
}
return Py::new_reference_to(Py::Long(count));
}
PyObject* TopoShapeFacePy::curveOnSurface(PyObject *args)
{
PyObject* e;