diff --git a/src/Mod/Part/App/TopoShapeCompoundPy.xml b/src/Mod/Part/App/TopoShapeCompoundPy.xml
index 35c6dc8345..19b61cbcd8 100644
--- a/src/Mod/Part/App/TopoShapeCompoundPy.xml
+++ b/src/Mod/Part/App/TopoShapeCompoundPy.xml
@@ -30,5 +30,10 @@ If Shared is True connection is performed only when adjacent edges share the sa
If Shared is False connection is performed only when ends of adjacent edges are at distance less than Tolerance.
+
+
+ A shape is created from points and triangles and set to this object
+
+
diff --git a/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp b/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp
index 37f9c170e8..267f7b50c8 100644
--- a/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp
+++ b/src/Mod/Part/App/TopoShapeCompoundPyImp.cpp
@@ -35,6 +35,7 @@
#endif
#include "OCCError.h"
+#include
// inclusion of the generated files (generated out of TopoShapeCompoundPy.xml)
#include "TopoShapeCompoundPy.h"
@@ -156,6 +157,66 @@ PyObject* TopoShapeCompoundPy::connectEdgesToWires(PyObject *args)
}
}
+PyObject* TopoShapeCompoundPy::setFaces(PyObject *args)
+{
+ using Facet = Data::ComplexGeoData::Facet;
+ using Point = Base::Vector3d;
+
+ std::vector points;
+ std::vector facets;
+
+ PyObject* data{};
+ double accuracy = 1.0e-06; // NOLINT
+ if (!PyArg_ParseTuple(args, "O!|d", &PyTuple_Type, &data, &accuracy)) {
+ return nullptr;
+ }
+
+ Py::Tuple tuple(data);
+
+ Py::Sequence pts(tuple.getItem(0));
+ points.reserve(pts.size());
+ for (const auto& pt : pts) {
+ Py::Vector vec(pt);
+ points.push_back(vec.toVector());
+ }
+
+ std::size_t count = points.size();
+ auto checkFace = [count](const Facet& face) {
+ if (face.I1 >= count) {
+ return false;
+ }
+ if (face.I2 >= count) {
+ return false;
+ }
+ if (face.I3 >= count) {
+ return false;
+ }
+
+ return true;
+ };
+
+ Py::Sequence fts(tuple.getItem(1));
+ facets.reserve(fts.size());
+ Facet face;
+ for (const auto& ft : fts) {
+ Py::Tuple index(ft);
+ face.I1 = int32_t(static_cast(Py::Long(index.getItem(0))));
+ face.I2 = int32_t(static_cast(Py::Long(index.getItem(1))));
+ face.I3 = int32_t(static_cast(Py::Long(index.getItem(2))));
+
+ if (!checkFace(face)) {
+ PyErr_SetString(PyExc_ValueError, "Point index out of range");
+ return nullptr;
+ }
+
+ facets.push_back(face);
+ }
+
+ getTopoShapePtr()->setFaces(points, facets, accuracy);
+
+ Py_Return;
+}
+
PyObject *TopoShapeCompoundPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;