add method to project shape on mesh
This commit is contained in:
@@ -63,7 +63,9 @@ public:
|
||||
);
|
||||
add_varargs_method("projectShapeOnMesh",&Module::projectShapeOnMesh,
|
||||
"Projects a shape onto a mesh with a given maximum distance\n"
|
||||
"projectShapeOnMesh(shape, mesh, float) -> polygon"
|
||||
"projectShapeOnMesh(Shape, Mesh, float) -> polygon\n"
|
||||
"or projects the shape in a given direction\n"
|
||||
"projectShapeOnMesh(Shape, Mesh, Vector) -> list of polygons"
|
||||
);
|
||||
add_varargs_method("wireFromSegment",&Module::wireFromSegment,
|
||||
"Create wire(s) from boundary of segment\n"
|
||||
@@ -205,26 +207,61 @@ private:
|
||||
{
|
||||
PyObject *s, *m;
|
||||
double maxDist;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!O!d", &Part::TopoShapePy::Type, &s,
|
||||
&Mesh::MeshPy::Type, &m,
|
||||
&maxDist))
|
||||
throw Py::Exception();
|
||||
TopoDS_Shape shape = static_cast<Part::TopoShapePy*>(s)->getTopoShapePtr()->getShape();
|
||||
const Mesh::MeshObject* mesh = static_cast<Mesh::MeshPy*>(m)->getMeshObjectPtr();
|
||||
MeshCore::MeshKernel kernel(mesh->getKernel());
|
||||
kernel.Transform(mesh->getTransform());
|
||||
if (PyArg_ParseTuple(args.ptr(), "O!O!d", &Part::TopoShapePy::Type, &s,
|
||||
&Mesh::MeshPy::Type, &m,
|
||||
&maxDist)) {
|
||||
TopoDS_Shape shape = static_cast<Part::TopoShapePy*>(s)->getTopoShapePtr()->getShape();
|
||||
const Mesh::MeshObject* mesh = static_cast<Mesh::MeshPy*>(m)->getMeshObjectPtr();
|
||||
MeshCore::MeshKernel kernel(mesh->getKernel());
|
||||
kernel.Transform(mesh->getTransform());
|
||||
|
||||
MeshProjection proj(kernel);
|
||||
std::vector<MeshProjection::SplitEdge> rSplitEdges;
|
||||
proj.projectToMesh(shape, maxDist, rSplitEdges);
|
||||
MeshProjection proj(kernel);
|
||||
std::vector<MeshProjection::PolyLine> polylines;
|
||||
proj.projectToMesh(shape, maxDist, polylines);
|
||||
|
||||
Py::List list;
|
||||
for (auto it : rSplitEdges) {
|
||||
Py::Vector v(it.cPt);
|
||||
list.append(v);
|
||||
Py::List list;
|
||||
for (auto it : polylines) {
|
||||
Py::List poly;
|
||||
for (auto jt : it.points) {
|
||||
Py::Vector v(jt);
|
||||
poly.append(v);
|
||||
}
|
||||
list.append(poly);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return list;
|
||||
PyErr_Clear();
|
||||
PyObject *v;
|
||||
if (PyArg_ParseTuple(args.ptr(), "O!O!O!", &Part::TopoShapePy::Type, &s,
|
||||
&Mesh::MeshPy::Type, &m,
|
||||
&Base::VectorPy::Type, &v)) {
|
||||
TopoDS_Shape shape = static_cast<Part::TopoShapePy*>(s)->getTopoShapePtr()->getShape();
|
||||
const Mesh::MeshObject* mesh = static_cast<Mesh::MeshPy*>(m)->getMeshObjectPtr();
|
||||
Base::Vector3d* vec = static_cast<Base::VectorPy*>(v)->getVectorPtr();
|
||||
Base::Vector3f dir = Base::convertTo<Base::Vector3f>(*vec);
|
||||
|
||||
MeshCore::MeshKernel kernel(mesh->getKernel());
|
||||
kernel.Transform(mesh->getTransform());
|
||||
|
||||
MeshProjection proj(kernel);
|
||||
std::vector<MeshProjection::PolyLine> polylines;
|
||||
proj.projectParallelToMesh(shape, dir, polylines);
|
||||
Py::List list;
|
||||
for (auto it : polylines) {
|
||||
Py::List poly;
|
||||
for (auto jt : it.points) {
|
||||
Py::Vector v(jt);
|
||||
poly.append(v);
|
||||
}
|
||||
list.append(poly);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
throw Py::TypeError("Expected arguments are: Shape, Mesh, float or Vector");
|
||||
}
|
||||
Py::Object wireFromSegment(const Py::Tuple& args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user