Part: expose Poly HLR algorithm to Python
This commit is contained in:
@@ -144,6 +144,8 @@
|
||||
#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/HLRBRep/HLRBRep_PolyAlgoPy.h>
|
||||
#include <Mod/Part/App/HLRBRep/PolyHLRToShapePy.h>
|
||||
#include <Mod/Part/App/ShapeUpgrade/UnifySameDomainPy.h>
|
||||
#include "PropertyGeometryList.h"
|
||||
#include "DatumFeature.h"
|
||||
@@ -301,6 +303,8 @@ PyMOD_INIT_FUNC(Part)
|
||||
PyObject* hlrfeatModule(module.getAttr("HLRBRep").ptr());
|
||||
Base::Interpreter().addType(&Part::HLRBRep_AlgoPy::Type,hlrfeatModule,"Algo");
|
||||
Base::Interpreter().addType(&Part::HLRToShapePy::Type,hlrfeatModule,"HLRToShape");
|
||||
Base::Interpreter().addType(&Part::HLRBRep_PolyAlgoPy::Type,hlrfeatModule,"PolyAlgo");
|
||||
Base::Interpreter().addType(&Part::PolyHLRToShapePy::Type,hlrfeatModule,"PolyHLRToShape");
|
||||
|
||||
// Geom2d package
|
||||
PyObject* geom2dModule(module.getAttr("Geom2d").ptr());
|
||||
|
||||
@@ -126,6 +126,8 @@ generate_from_xml(GeomPlate/PointConstraintPy)
|
||||
|
||||
generate_from_xml(HLRBRep/HLRBRep_AlgoPy)
|
||||
generate_from_xml(HLRBRep/HLRToShapePy)
|
||||
generate_from_xml(HLRBRep/HLRBRep_PolyAlgoPy)
|
||||
generate_from_xml(HLRBRep/PolyHLRToShapePy)
|
||||
|
||||
generate_from_xml(ShapeUpgrade/UnifySameDomainPy)
|
||||
|
||||
@@ -386,6 +388,11 @@ SET(HLRBRepPy_SRCS
|
||||
HLRBRep/HLRBRep_AlgoPyImp.cpp
|
||||
HLRBRep/HLRToShapePy.xml
|
||||
HLRBRep/HLRToShapePyImp.cpp
|
||||
|
||||
HLRBRep/HLRBRep_PolyAlgoPy.xml
|
||||
HLRBRep/HLRBRep_PolyAlgoPyImp.cpp
|
||||
HLRBRep/PolyHLRToShapePy.xml
|
||||
HLRBRep/PolyHLRToShapePyImp.cpp
|
||||
)
|
||||
SOURCE_GROUP("HLRBRep" FILES ${HLRBRepPy_SRCS})
|
||||
|
||||
|
||||
127
src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPy.xml
Normal file
127
src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPy.xml
Normal file
@@ -0,0 +1,127 @@
|
||||
<?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_PolyAlgoPy"
|
||||
PythonName="Part.HLRBRep_PolyAlgo"
|
||||
Twin="HLRBRep_PolyAlgo"
|
||||
TwinPointer="HLRBRep_PolyAlgo"
|
||||
Include="HLRBRep_PolyAlgo.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="load">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="remove">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="nbShapes">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="shape">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="index">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setProjector" Keyword="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="update">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="initHide">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="moreHide">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="nextHide">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="initShow">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="moreShow">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="nextShow">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="outLinedShape">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Angle">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Angle" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="TolAngular">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="TolAngular" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="TolCoef">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="TolCoef" Type="Float"/>
|
||||
</Attribute>
|
||||
<ClassDeclarations>
|
||||
private:
|
||||
Handle(HLRBRep_PolyAlgo) hAlgo;
|
||||
|
||||
public:
|
||||
Handle(HLRBRep_PolyAlgo) handle() {
|
||||
return hAlgo;
|
||||
}
|
||||
</ClassDeclarations>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
281
src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp
Normal file
281
src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
/***************************************************************************
|
||||
* 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_PolyAlgoPy.h"
|
||||
#include "HLRBRep/HLRBRep_PolyAlgoPy.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_PolyAlgoPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
|
||||
{
|
||||
// create a new instance of HLRBRep_AlgoPy
|
||||
return new HLRBRep_PolyAlgoPy(nullptr);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int HLRBRep_PolyAlgoPy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
PyObject* shape = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "|O!", &Part::TopoShapePy::Type, &shape))
|
||||
return -1;
|
||||
|
||||
// The lifetime of the HLRBRep_PolyAlgo is controlled by the hAlgo handle
|
||||
if (shape) {
|
||||
TopoDS_Shape input = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
|
||||
HLRBRep_PolyAlgo* algo = new HLRBRep_PolyAlgo(input);
|
||||
hAlgo = algo;
|
||||
setTwinPointer(algo);
|
||||
}
|
||||
else {
|
||||
HLRBRep_PolyAlgo* algo = new HLRBRep_PolyAlgo();
|
||||
hAlgo = algo;
|
||||
setTwinPointer(algo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string HLRBRep_PolyAlgoPy::representation(void) const
|
||||
{
|
||||
return std::string("<HLRBRep_PolyAlgo object>");
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::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_PolyAlgoPtr()->Projector(HLRAlgo_Projector(ax2));
|
||||
else
|
||||
getHLRBRep_PolyAlgoPtr()->Projector(HLRAlgo_Projector(ax2, focus));
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::update(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->Update();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::load(PyObject *args)
|
||||
{
|
||||
PyObject* shape;
|
||||
if (!PyArg_ParseTuple(args, "O!", &Part::TopoShapePy::Type, &shape))
|
||||
return nullptr;
|
||||
|
||||
TopoDS_Shape input = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
|
||||
getHLRBRep_PolyAlgoPtr()->Load(input);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::remove(PyObject *args)
|
||||
{
|
||||
int index;
|
||||
if (!PyArg_ParseTuple(args, "i", &index))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->Remove(index);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::nbShapes(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
int num = getHLRBRep_PolyAlgoPtr()->NbShapes();
|
||||
return Py_BuildValue("i", num);
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::shape(PyObject *args)
|
||||
{
|
||||
int index;
|
||||
if (!PyArg_ParseTuple(args, "i", &index))
|
||||
return nullptr;
|
||||
|
||||
TopoDS_Shape result = getHLRBRep_PolyAlgoPtr()->Shape(index);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::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_PolyAlgoPtr()->Index(input);
|
||||
return Py_BuildValue("i", value);
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::initHide(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->InitHide();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::moreHide(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->MoreHide();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::nextHide(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->NextHide();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::initShow(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->InitShow();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::moreShow(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->MoreShow();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::nextShow(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyAlgoPtr()->NextShow();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* HLRBRep_PolyAlgoPy::outLinedShape(PyObject *args)
|
||||
{
|
||||
PyObject* shape;
|
||||
if (!PyArg_ParseTuple(args, "O!", &Part::TopoShapePy::Type, &shape))
|
||||
return nullptr;
|
||||
|
||||
TopoDS_Shape input = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
|
||||
TopoDS_Shape result = getHLRBRep_PolyAlgoPtr()->OutLinedShape(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
|
||||
Py::Float HLRBRep_PolyAlgoPy::getAngle() const
|
||||
{
|
||||
return Py::Float(getHLRBRep_PolyAlgoPtr()->Angle());
|
||||
}
|
||||
|
||||
void HLRBRep_PolyAlgoPy::setAngle(Py::Float arg)
|
||||
{
|
||||
getHLRBRep_PolyAlgoPtr()->Angle(static_cast<double>(arg));
|
||||
}
|
||||
|
||||
Py::Float HLRBRep_PolyAlgoPy::getTolAngular() const
|
||||
{
|
||||
return Py::Float(getHLRBRep_PolyAlgoPtr()->TolAngular());
|
||||
}
|
||||
|
||||
void HLRBRep_PolyAlgoPy::setTolAngular(Py::Float arg)
|
||||
{
|
||||
getHLRBRep_PolyAlgoPtr()->TolAngular(static_cast<double>(arg));
|
||||
}
|
||||
|
||||
Py::Float HLRBRep_PolyAlgoPy::getTolCoef() const
|
||||
{
|
||||
return Py::Float(getHLRBRep_PolyAlgoPtr()->TolCoef());
|
||||
}
|
||||
|
||||
void HLRBRep_PolyAlgoPy::setTolCoef(Py::Float arg)
|
||||
{
|
||||
getHLRBRep_PolyAlgoPtr()->TolCoef(static_cast<double>(arg));
|
||||
}
|
||||
|
||||
PyObject *HLRBRep_PolyAlgoPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int HLRBRep_PolyAlgoPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
84
src/Mod/Part/App/HLRBRep/PolyHLRToShapePy.xml
Normal file
84
src/Mod/Part/App/HLRBRep/PolyHLRToShapePy.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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="PolyHLRToShapePy"
|
||||
PythonName="Part.PolyHLRToShapePy"
|
||||
Twin="HLRBRep_PolyHLRToShape"
|
||||
TwinPointer="HLRBRep_PolyHLRToShape"
|
||||
Include="HLRBRep_PolyHLRToShape.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="update">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="show">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="hide">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<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="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>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
236
src/Mod/Part/App/HLRBRep/PolyHLRToShapePyImp.cpp
Normal file
236
src/Mod/Part/App/HLRBRep/PolyHLRToShapePyImp.cpp
Normal file
@@ -0,0 +1,236 @@
|
||||
/***************************************************************************
|
||||
* 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/PolyHLRToShapePy.h"
|
||||
#include "HLRBRep/PolyHLRToShapePy.cpp"
|
||||
#include "HLRBRep/HLRBRep_PolyAlgoPy.h"
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
||||
PyObject *PolyHLRToShapePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
|
||||
{
|
||||
// create a new instance of HLRBRep_AlgoPy
|
||||
return new PolyHLRToShapePy(new HLRBRep_PolyHLRToShape());
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int PolyHLRToShapePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
PyObject* algo = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "|O!", &Part::HLRBRep_PolyAlgoPy::Type, &algo))
|
||||
return -1;
|
||||
|
||||
if (algo) {
|
||||
HLRBRep_PolyAlgoPy* py = static_cast<HLRBRep_PolyAlgoPy*>(algo);
|
||||
getHLRBRep_PolyHLRToShapePtr()->Update(py->handle());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string PolyHLRToShapePy::representation(void) const
|
||||
{
|
||||
return std::string("<HLRBRep_PolyHLRToShape object>");
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::update(PyObject *args)
|
||||
{
|
||||
PyObject* algo;
|
||||
if (!PyArg_ParseTuple(args, "O!", &Part::HLRBRep_PolyAlgoPy::Type, &algo))
|
||||
return nullptr;
|
||||
|
||||
HLRBRep_PolyAlgoPy* py = static_cast<HLRBRep_PolyAlgoPy*>(algo);
|
||||
getHLRBRep_PolyHLRToShapePtr()->Update(py->handle());
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::show(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyHLRToShapePtr()->Show();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::hide(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
getHLRBRep_PolyHLRToShapePtr()->Hide();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->VCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->VCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->Rg1LineVCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->Rg1LineVCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->RgNLineVCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->RgNLineVCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->OutLineVCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->OutLineVCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->HCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->HCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->Rg1LineHCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->Rg1LineHCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->RgNLineHCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->RgNLineHCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PolyHLRToShapePy::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_PolyHLRToShapePtr()->OutLineHCompound(input);
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
else {
|
||||
TopoDS_Shape result = getHLRBRep_PolyHLRToShapePtr()->OutLineHCompound();
|
||||
return new TopoShapePy(new TopoShape(result));
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PolyHLRToShapePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int PolyHLRToShapePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user