Part: expose HLR algorithm to Python

This commit is contained in:
wmayer
2021-12-21 10:49:03 +01:00
parent dede24d5e4
commit 73a986714c
8 changed files with 793 additions and 2 deletions

View File

@@ -142,6 +142,8 @@
#include <Mod/Part/App/GeomPlate/BuildPlateSurfacePy.h>
#include <Mod/Part/App/GeomPlate/CurveConstraintPy.h>
#include <Mod/Part/App/GeomPlate/PointConstraintPy.h>
#include <Mod/Part/App/HLRBRep/HLRBRep_AlgoPy.h>
#include <Mod/Part/App/HLRBRep/HLRToShapePy.h>
#include <Mod/Part/App/ShapeUpgrade/UnifySameDomainPy.h>
#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");

View File

@@ -317,6 +317,17 @@ public:
virtual ~GeomPlateModule() {}
};
class HLRBRepModule : public Py::ExtensionModule<HLRBRepModule>
{
public:
HLRBRepModule() : Py::ExtensionModule<HLRBRepModule>("HLRBRep")
{
initialize("This is a module working with the HLRBRep framework."); // register with Python
}
virtual ~HLRBRepModule() {}
};
class ShapeUpgradeModule : public Py::ExtensionModule<ShapeUpgradeModule>
{
public:
@@ -334,6 +345,7 @@ class Module : public Py::ExtensionModule<Module>
BRepOffsetAPIModule brepOffsetApi;
Geom2dModule geom2d;
GeomPlateModule geomPlate;
HLRBRepModule HLRBRep;
ShapeUpgradeModule shapeUpgrade;
public:
Module() : Py::ExtensionModule<Module>("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());
}

View File

@@ -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

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="HLRBRep_AlgoPy"
PythonName="Part.HLRBRep_Algo"
Twin="HLRBRep_Algo"
TwinPointer="HLRBRep_Algo"
Include="HLRBRep_Algo.hxx"
Namespace="Part"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="false">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
<UserDocu>Describes functions to use HLR algorithm.</UserDocu>
</Documentation>
<Methode Name="add">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="remove">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="index">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="outLinedShapeNullify">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="setProjector" Keyword="true">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="nbShapes">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="showAll">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="hide">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="hideAll">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="partialHide">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="select">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="selectEdge">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="selectFace">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="initEdgeStatus">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="update">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<ClassDeclarations>
private:
Handle(HLRBRep_Algo) hAlgo;
public:
Handle(HLRBRep_Algo) handle() {
return hAlgo;
}
</ClassDeclarations>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,265 @@
/***************************************************************************
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 <gp_Ax2.hxx>
# include <gp_Pnt.hxx>
# include <limits>
#endif
#include "HLRBRep/HLRBRep_AlgoPy.h"
#include "HLRBRep/HLRBRep_AlgoPy.cpp"
#include <Mod/Part/App/TopoShapePy.h>
#include <Mod/Part/App/Tools.h>
#include <Base/VectorPy.h>
#include <Base/GeometryPyCXX.h>
#include <boost/math/special_functions/fpclassify.hpp>
#include <HLRAlgo_Projector.hxx>
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("<HLRBRep_Algo object>");
}
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<TopoShapePy*>(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<TopoShapePy*>(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<double>::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<gp_Pnt>(p));
ax2.SetDirection(Base::convertTo<gp_Dir>(z));
ax2.SetXDirection(Base::convertTo<gp_Dir>(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<gp_Pnt>(p));
ax2.SetDirection(Base::convertTo<gp_Dir>(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;
}

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="HLRToShapePy"
PythonName="Part.HLRToShapePy"
Twin="HLRBRep_HLRToShape"
TwinPointer="HLRBRep_HLRToShape"
Include="HLRBRep_HLRToShape.hxx"
Namespace="Part"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="true">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
<UserDocu>Describes functions to use HLR algorithm.</UserDocu>
</Documentation>
<Methode Name="vCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="Rg1LineVCompound">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="RgNLineVCompound">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="outLineVCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="outLineVCompound3d">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isoLineVCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="hCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="Rg1LineHCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="RgNLineHCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="outLineHCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isoLineHCompound">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="compoundOfEdges" Keyword="true">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,278 @@
/***************************************************************************
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 <Mod/Part/App/TopoShapePy.h>
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<HLRBRep_AlgoPy*>(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("<HLRBRep_HLRToShape object>");
}
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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(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<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
TopoDS_Shape result = getHLRBRep_HLRToShapePtr()->CompoundOfEdges(input, static_cast<HLRBRep_TypeOfResultingEdge>(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<HLRBRep_TypeOfResultingEdge>(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;
}

View File

@@ -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