diff --git a/src/Mod/Part/App/TopoShapeFacePy.xml b/src/Mod/Part/App/TopoShapeFacePy.xml index 0b6b200512..72d786e372 100644 --- a/src/Mod/Part/App/TopoShapeFacePy.xml +++ b/src/Mod/Part/App/TopoShapeFacePy.xml @@ -19,16 +19,16 @@ Offset the face by a given amount. Returns Compound of Wires. Deprecated - use makeOffset2D instead. - - - + + + getUVNodes() --> list Get the list of (u,v) nodes of the tessellation An exception is raised if the face is not triangulated. - - - + + + Get the tangent in u and v isoparametric at the given point if defined @@ -73,17 +73,24 @@ An exception is raised if the face is not triangulated. Validate the face. - - - + + + curveonSurface(Edge) -> None or tuple Returns the curve associated to the edge in the parametric space of the face. Returns None if this curve does not exist. If this curve exists then a tuple of curve and and parameter range is returned. - - - + + + + + + Cut holes in the face. +aFace.cutHoles(list_of_wires) + + + Set or get the tolerance of the vertex @@ -115,24 +122,24 @@ deprecated -- please use OuterWire - - - Returns the mass of the current system. - - - - - - Returns the center of mass of the current system. + + + Returns the mass of the current system. + + + + + + Returns the center of mass of the current system. If the gravitational field is uniform, it is the center of gravity. The coordinates returned for the center of mass are expressed in the absolute Cartesian coordinate system. - - - - - - Returns the matrix of inertia. It is a symmetrical matrix. + + + + + + Returns the matrix of inertia. It is a symmetrical matrix. The coefficients of the matrix are the quadratic moments of inertia. @@ -148,20 +155,20 @@ system (G, Gx, Gy, Gz) where G is the centre of mass of the system and Gx, Gy, Gz the directions parallel to the X(1,0,0) Y(0,1,0) Z(0,0,1) directions of the absolute cartesian coordinate system. - - - - - - Returns Ix, Iy, Iz, the static moments of inertia of the + + + + + + Returns Ix, Iy, Iz, the static moments of inertia of the current system; i.e. the moments of inertia about the three axes of the Cartesian coordinate system. - - - - - - Computes the principal properties of inertia of the current system. + + + + + + Computes the principal properties of inertia of the current system. There is always a set of axes for which the products of inertia of a geometric system are equal to 0; i.e. the matrix of inertia of the system is diagonal. These axes @@ -170,8 +177,8 @@ coordinate system. associated moments are called the principal moments of inertia. This function computes the eigen values and the eigen vectors of the matrix of inertia of the system. - - - + + + diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index b3d5c2da1f..a3be2714c9 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -691,6 +691,73 @@ PyObject* TopoShapeFacePy::curveOnSurface(PyObject *args) } } +PyObject* TopoShapeFacePy::cutHoles(PyObject *args) +{ + PyObject *holes=0; + if (PyArg_ParseTuple(args, "O!", &(PyList_Type), &holes)) { + try { + std::vector wires; + Py::List list(holes); + for (Py::List::iterator it = list.begin(); it != list.end(); ++it) { + PyObject* item = (*it).ptr(); + if (PyObject_TypeCheck(item, &(Part::TopoShapePy::Type))) { + const TopoDS_Shape& sh = static_cast(item)->getTopoShapePtr()->getShape(); + if (sh.ShapeType() == TopAbs_WIRE) + wires.push_back(TopoDS::Wire(sh)); + else + Standard_Failure::Raise("shape is not a wire"); + } + else + Standard_Failure::Raise("argument is not a shape"); + } + + if (!wires.empty()) { + const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->getShape()); + BRepBuilderAPI_MakeFace mkFace(f); + for (std::vector::iterator it = wires.begin(); it != wires.end(); ++it) + mkFace.Add(*it); + if (!mkFace.IsDone()) { + switch (mkFace.Error()) { + case BRepBuilderAPI_NoFace: + Standard_Failure::Raise("No face"); + break; + case BRepBuilderAPI_NotPlanar: + Standard_Failure::Raise("Not planar"); + break; + case BRepBuilderAPI_CurveProjectionFailed: + Standard_Failure::Raise("Curve projection failed"); + break; + case BRepBuilderAPI_ParametersOutOfRange: + Standard_Failure::Raise("Parameters out of range"); + break; +#if OCC_VERSION_HEX < 0x060500 + case BRepBuilderAPI_SurfaceNotC2: + Standard_Failure::Raise("Surface not C2"); + break; +#endif + default: + Standard_Failure::Raise("Unknown failure"); + break; + } + } + + getTopoShapePtr()->setShape(mkFace.Face()); + Py_Return; + } + else { + Standard_Failure::Raise("empty wire list"); + } + } + catch (Standard_Failure& e) { + PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); + return 0; + } + } + PyErr_SetString(PyExc_RuntimeError, "invalid list of wires"); + return 0; +} + + Py::Object TopoShapeFacePy::getSurface() const { const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->getShape());