add method to get wires of mesh boundaries

This commit is contained in:
wmayer
2019-11-10 11:14:04 +01:00
parent 08b54bb5a0
commit 4e7c2a233f

View File

@@ -86,7 +86,10 @@ public:
"projectPointsOnMesh(list of points, Mesh, Vector, [float]) -> list of points\n"
);
add_varargs_method("wireFromSegment",&Module::wireFromSegment,
"Create wire(s) from boundary of segment\n"
"Create wire(s) from boundary of a mesh segment\n"
);
add_varargs_method("wireFromMesh",&Module::wireFromMesh,
"Create wire(s) from boundary of a mesh\n"
);
add_keyword_method("meshFromShape",&Module::meshFromShape,
"Create surface mesh from shape\n"
@@ -442,6 +445,34 @@ private:
return wires;
}
Py::Object wireFromMesh(const Py::Tuple& args)
{
PyObject *m;
if (!PyArg_ParseTuple(args.ptr(), "O!", &(Mesh::MeshPy::Type), &m))
throw Py::Exception();
Mesh::MeshObject* mesh = static_cast<Mesh::MeshPy*>(m)->getMeshObjectPtr();
std::list<std::vector<Base::Vector3f> > bounds;
MeshCore::MeshAlgorithm algo(mesh->getKernel());
algo.GetMeshBorders(bounds);
Py::List wires;
std::list<std::vector<Base::Vector3f> >::iterator bt;
for (bt = bounds.begin(); bt != bounds.end(); ++bt) {
BRepBuilderAPI_MakePolygon mkPoly;
for (std::vector<Base::Vector3f>::reverse_iterator it = bt->rbegin(); it != bt->rend(); ++it) {
mkPoly.Add(gp_Pnt(it->x,it->y,it->z));
}
if (mkPoly.IsDone()) {
PyObject* wire = new Part::TopoShapeWirePy(new Part::TopoShape(mkPoly.Wire()));
wires.append(Py::Object(wire, true));
}
}
return wires;
}
Py::Object meshFromShape(const Py::Tuple& args, const Py::Dict& kwds)
{
PyObject *shape;