diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 903e9e8e8f..8c44453731 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -142,6 +142,8 @@ #include #include #include +#include +#include #include #include "PropertyGeometryList.h" #include "DatumFeature.h" @@ -295,6 +297,11 @@ PyMOD_INIT_FUNC(Part) Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepOffsetApiModule,"MakePipeShell"); Base::Interpreter().addType(&Part::BRepOffsetAPI_MakeFillingPy::Type,brepOffsetApiModule,"MakeFilling"); + // HLRBRep package + PyObject* hlrfeatModule(module.getAttr("HLRBRep").ptr()); + Base::Interpreter().addType(&Part::HLRBRep_AlgoPy::Type,hlrfeatModule,"Algo"); + Base::Interpreter().addType(&Part::HLRToShapePy::Type,hlrfeatModule,"HLRToShape"); + // Geom2d package PyObject* geom2dModule(module.getAttr("Geom2d").ptr()); Base::Interpreter().addType(&Part::Geometry2dPy::Type,geom2dModule,"Geometry2d"); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index f16ae7e221..b21e9f26bc 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -317,6 +317,17 @@ public: virtual ~GeomPlateModule() {} }; +class HLRBRepModule : public Py::ExtensionModule +{ +public: + HLRBRepModule() : Py::ExtensionModule("HLRBRep") + { + initialize("This is a module working with the HLRBRep framework."); // register with Python + } + + virtual ~HLRBRepModule() {} +}; + class ShapeUpgradeModule : public Py::ExtensionModule { public: @@ -334,6 +345,7 @@ class Module : public Py::ExtensionModule BRepOffsetAPIModule brepOffsetApi; Geom2dModule geom2d; GeomPlateModule geomPlate; + HLRBRepModule HLRBRep; ShapeUpgradeModule shapeUpgrade; public: Module() : Py::ExtensionModule("Part") @@ -559,6 +571,7 @@ public: PyModule_AddObject(m_module, "BRepOffsetAPI", brepOffsetApi.module().ptr()); PyModule_AddObject(m_module, "Geom2d", geom2d.module().ptr()); PyModule_AddObject(m_module, "GeomPlate", geomPlate.module().ptr()); + PyModule_AddObject(m_module, "HLRBRep", HLRBRep.module().ptr()); PyModule_AddObject(m_module, "ShapeUpgrade", shapeUpgrade.module().ptr()); } diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt index 67478980de..90623fb850 100644 --- a/src/Mod/Part/App/CMakeLists.txt +++ b/src/Mod/Part/App/CMakeLists.txt @@ -97,6 +97,7 @@ generate_from_xml(BRepOffsetAPI_MakeFillingPy) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/BRepFeat) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Geom2d) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/GeomPlate) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/HLRBRep) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ShapeUpgrade) generate_from_xml(BRepFeat/MakePrismPy) @@ -123,6 +124,9 @@ generate_from_xml(GeomPlate/BuildPlateSurfacePy) generate_from_xml(GeomPlate/CurveConstraintPy) generate_from_xml(GeomPlate/PointConstraintPy) +generate_from_xml(HLRBRep/HLRBRep_AlgoPy) +generate_from_xml(HLRBRep/HLRToShapePy) + generate_from_xml(ShapeUpgrade/UnifySameDomainPy) SET(Features_SRCS @@ -322,8 +326,7 @@ SET(BRepFeatPy_SRCS BRepFeat/MakePrismPy.xml BRepFeat/MakePrismPyImp.cpp ) - -SOURCE_GROUP("ShapeUpgrade" FILES ${ShapeUpgradePy_SRCS}) +SOURCE_GROUP("BRepFeat" FILES ${BRepFeatPy_SRCS}) # Geom2d wrappers SET(Geom2dPy_SRCS @@ -377,6 +380,15 @@ SET(GeomPlatePy_SRCS SOURCE_GROUP("GeomPlate" FILES ${GeomPlatePy_SRCS}) +# HLRBRep wrappers +SET(HLRBRepPy_SRCS + HLRBRep/HLRBRep_AlgoPy.xml + HLRBRep/HLRBRep_AlgoPyImp.cpp + HLRBRep/HLRToShapePy.xml + HLRBRep/HLRToShapePyImp.cpp +) +SOURCE_GROUP("HLRBRep" FILES ${HLRBRepPy_SRCS}) + # ShapeUpgrade wrappers SET(ShapeUpgradePy_SRCS ShapeUpgrade/UnifySameDomainPy.xml @@ -392,6 +404,7 @@ SET(Part_SRCS ${BRepFeatPy_SRCS} ${Geom2dPy_SRCS} ${GeomPlatePy_SRCS} + ${HLRBRepPy_SRCS} ${ShapeUpgradePy_SRCS} Attacher.cpp Attacher.h diff --git a/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPy.xml b/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPy.xml new file mode 100644 index 0000000000..167dff70d3 --- /dev/null +++ b/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPy.xml @@ -0,0 +1,117 @@ + + + + + + Describes functions to use HLR algorithm. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +private: + Handle(HLRBRep_Algo) hAlgo; + +public: + Handle(HLRBRep_Algo) handle() { + return hAlgo; + } + + + diff --git a/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp b/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp new file mode 100644 index 0000000000..2c00d363e1 --- /dev/null +++ b/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp @@ -0,0 +1,265 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ +# include +# include +# include +#endif + +#include "HLRBRep/HLRBRep_AlgoPy.h" +#include "HLRBRep/HLRBRep_AlgoPy.cpp" +#include +#include +#include +#include + +#include +#include + +using namespace Part; + + +PyObject *HLRBRep_AlgoPy::PyMake(struct _typeobject *, PyObject *, PyObject *) +{ + // create a new instance of HLRBRep_AlgoPy + return new HLRBRep_AlgoPy(nullptr); +} + +// constructor method +int HLRBRep_AlgoPy::PyInit(PyObject* /*args*/, PyObject* /*kwds*/) +{ + // The lifetime of the HLRBRep_Algo is controlled by the hAlgo handle + HLRBRep_Algo* algo = new HLRBRep_Algo(); + hAlgo = algo; + setTwinPointer(algo); + return 0; +} + +// returns a string which represents the object e.g. when printed in python +std::string HLRBRep_AlgoPy::representation(void) const +{ + return std::string(""); +} + +PyObject* HLRBRep_AlgoPy::add(PyObject *args) +{ + PyObject* shape; + int nbIso = 0; + if (!PyArg_ParseTuple(args, "O!|i", &Part::TopoShapePy::Type, &shape, &nbIso)) + return nullptr; + + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + getHLRBRep_AlgoPtr()->Add(input, nbIso); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::remove(PyObject *args) +{ + int index; + if (!PyArg_ParseTuple(args, "i", &index)) + return nullptr; + + getHLRBRep_AlgoPtr()->Remove(index); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::index(PyObject *args) +{ + PyObject* shape; + if (!PyArg_ParseTuple(args, "O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + int value = getHLRBRep_AlgoPtr()->Index(input); + return Py_BuildValue("i", value); +} + +PyObject* HLRBRep_AlgoPy::outLinedShapeNullify(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + getHLRBRep_AlgoPtr()->OutLinedShapeNullify(); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::setProjector(PyObject *args, PyObject *kwds) +{ + PyObject* ps = nullptr; + PyObject* zd = nullptr; + PyObject* xd = nullptr; + double focus = std::numeric_limits::quiet_NaN(); + + static char *kwlist[] = {"Origin", "ZDir", "XDir", nullptr}; + if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!O!O!d", kwlist, + &Base::VectorPy::Type, &ps, + &Base::VectorPy::Type, &zd, + &Base::VectorPy::Type, &xd, + &focus)) { + gp_Ax2 ax2; + if (ps && zd && xd) { + Base::Vector3d p = Py::Vector(ps,false).toVector(); + Base::Vector3d z = Py::Vector(zd,false).toVector(); + Base::Vector3d x = Py::Vector(xd,false).toVector(); + ax2.SetLocation(Base::convertTo(p)); + ax2.SetDirection(Base::convertTo(z)); + ax2.SetXDirection(Base::convertTo(x)); + } + else if (ps && zd) { + Base::Vector3d p = Py::Vector(ps,false).toVector(); + Base::Vector3d z = Py::Vector(zd,false).toVector(); + ax2.SetLocation(Base::convertTo(p)); + ax2.SetDirection(Base::convertTo(z)); + } + + if (boost::math::isnan(focus)) + getHLRBRep_AlgoPtr()->Projector(HLRAlgo_Projector(ax2)); + else + getHLRBRep_AlgoPtr()->Projector(HLRAlgo_Projector(ax2, focus)); + Py_Return; + } + + return nullptr; +} + +PyObject* HLRBRep_AlgoPy::nbShapes(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + int num = getHLRBRep_AlgoPtr()->NbShapes(); + return Py_BuildValue("i", num); +} + +PyObject* HLRBRep_AlgoPy::showAll(PyObject *args) +{ + int i=-1; + if (!PyArg_ParseTuple(args, "|i", &i)) + return nullptr; + + if (i < 1) + getHLRBRep_AlgoPtr()->ShowAll(); + else + getHLRBRep_AlgoPtr()->ShowAll(i); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::hide(PyObject *args) +{ + int i=-1, j=-1; + if (!PyArg_ParseTuple(args, "|ii", &i, &j)) + return nullptr; + + if (i < 1) + getHLRBRep_AlgoPtr()->Hide(); + else if (j < 1) + getHLRBRep_AlgoPtr()->Hide(i); + else + getHLRBRep_AlgoPtr()->Hide(i, j); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::hideAll(PyObject *args) +{ + int i=-1; + if (!PyArg_ParseTuple(args, "|i", &i)) + return nullptr; + + if (i < 1) + getHLRBRep_AlgoPtr()->HideAll(); + else + getHLRBRep_AlgoPtr()->HideAll(i); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::partialHide(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + getHLRBRep_AlgoPtr()->PartialHide(); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::select(PyObject *args) +{ + int i=-1; + if (!PyArg_ParseTuple(args, "|i", &i)) + return nullptr; + + if (i < 1) + getHLRBRep_AlgoPtr()->Select(); + else + getHLRBRep_AlgoPtr()->Select(i); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::selectEdge(PyObject *args) +{ + int index; + if (!PyArg_ParseTuple(args, "i", &index)) + return nullptr; + + getHLRBRep_AlgoPtr()->SelectEdge(index); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::selectFace(PyObject *args) +{ + int index; + if (!PyArg_ParseTuple(args, "i", &index)) + return nullptr; + + getHLRBRep_AlgoPtr()->SelectFace(index); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::initEdgeStatus(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + getHLRBRep_AlgoPtr()->InitEdgeStatus(); + Py_Return; +} + +PyObject* HLRBRep_AlgoPy::update(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + getHLRBRep_AlgoPtr()->Update(); + Py_Return; +} + +PyObject *HLRBRep_AlgoPy::getCustomAttributes(const char* /*attr*/) const +{ + return nullptr; +} + +int HLRBRep_AlgoPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) +{ + return 0; +} diff --git a/src/Mod/Part/App/HLRBRep/HLRToShapePy.xml b/src/Mod/Part/App/HLRBRep/HLRToShapePy.xml new file mode 100644 index 0000000000..4be1afc6c6 --- /dev/null +++ b/src/Mod/Part/App/HLRBRep/HLRToShapePy.xml @@ -0,0 +1,90 @@ + + + + + + Describes functions to use HLR algorithm. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Part/App/HLRBRep/HLRToShapePyImp.cpp b/src/Mod/Part/App/HLRBRep/HLRToShapePyImp.cpp new file mode 100644 index 0000000000..88f2c8663e --- /dev/null +++ b/src/Mod/Part/App/HLRBRep/HLRToShapePyImp.cpp @@ -0,0 +1,278 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ +#endif + +#include "HLRBRep/HLRToShapePy.h" +#include "HLRBRep/HLRToShapePy.cpp" +#include "HLRBRep/HLRBRep_AlgoPy.h" +#include + +using namespace Part; + + +PyObject *HLRToShapePy::PyMake(struct _typeobject *, PyObject *, PyObject *) +{ + // create a new instance of HLRBRep_AlgoPy + return new HLRToShapePy(nullptr); +} + +// constructor method +int HLRToShapePy::PyInit(PyObject* args, PyObject* /*kwds*/) +{ + PyObject* algo; + if (!PyArg_ParseTuple(args, "O!", &Part::HLRBRep_AlgoPy::Type, &algo)) + return -1; + + HLRBRep_AlgoPy* py = static_cast(algo); + setTwinPointer(new HLRBRep_HLRToShape(py->handle())); + + return 0; +} + +// returns a string which represents the object e.g. when printed in python +std::string HLRToShapePy::representation(void) const +{ + return std::string(""); +} + +PyObject* HLRToShapePy::vCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->VCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->VCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::Rg1LineVCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->Rg1LineVCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->Rg1LineVCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::RgNLineVCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->RgNLineVCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->RgNLineVCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::outLineVCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->OutLineVCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->OutLineVCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::outLineVCompound3d(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->OutLineVCompound3d(); + return new TopoShapePy(new TopoShape(result)); +} + +PyObject* HLRToShapePy::isoLineVCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->IsoLineVCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->IsoLineVCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::hCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->HCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->HCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::Rg1LineHCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->Rg1LineHCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->Rg1LineHCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::RgNLineHCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->RgNLineHCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->RgNLineHCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::outLineHCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->OutLineHCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->OutLineHCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::isoLineHCompound(PyObject *args) +{ + PyObject* shape = nullptr; + if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->IsoLineHCompound(input); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->IsoLineHCompound(); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject* HLRToShapePy::compoundOfEdges(PyObject *args, PyObject *kwds) +{ + int type; + PyObject* visible = nullptr; + PyObject* in3d = nullptr; + PyObject* shape = nullptr; + + static char* keywords[] = {"Type", "Visible", "In3D", "Shape", nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "iO!O!|O!", keywords, + &type, + &PyBool_Type, &visible, + &PyBool_Type, &in3d, + &Part::TopoShapePy::Type, &shape)) + return nullptr; + + if (shape) { + TopoDS_Shape input = static_cast(shape)->getTopoShapePtr()->getShape(); + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->CompoundOfEdges(input, static_cast(type), + PyObject_IsTrue(visible) ? Standard_True : Standard_False, + PyObject_IsTrue(in3d) ? Standard_True : Standard_False); + return new TopoShapePy(new TopoShape(result)); + } + else { + TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->CompoundOfEdges(static_cast(type), + PyObject_IsTrue(visible) ? Standard_True : Standard_False, + PyObject_IsTrue(in3d) ? Standard_True : Standard_False); + return new TopoShapePy(new TopoShape(result)); + } +} + +PyObject *HLRToShapePy::getCustomAttributes(const char* /*attr*/) const +{ + return nullptr; +} + +int HLRToShapePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) +{ + return 0; +} diff --git a/src/Mod/Part/PartEnums.py b/src/Mod/Part/PartEnums.py index dbd983c908..c5c81057be 100644 --- a/src/Mod/Part/PartEnums.py +++ b/src/Mod/Part/PartEnums.py @@ -63,3 +63,11 @@ class ShapeEnum(IntEnum): VERTEX = 7 SHAPE = 8 +class HLRBRep_TypeOfResultingEdge(IntEnum): + Undefined = 0 + IsoLine = 1 + OutLine = 2 + Rg1Line = 3 + RgNLine = 4 + Sharp = 5 +