Part: expose ShapeFix_FreeBounds to Python

This commit is contained in:
wmayer
2022-05-05 00:11:23 +02:00
parent 125d5b6360
commit 1ee1aee10e
4 changed files with 163 additions and 0 deletions

View File

@@ -105,6 +105,7 @@
#include <Mod/Part/App/ShapeFix/ShapeFix_EdgeConnectPy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_FacePy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_FaceConnectPy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_FreeBoundsPy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_ShapePy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_ShapeTolerancePy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_ShellPy.h>
@@ -359,6 +360,7 @@ PyMOD_INIT_FUNC(Part)
Base::Interpreter().addType(&Part::ShapeFix_WirePy::Type, shapeFix, "Wire");
Base::Interpreter().addType(&Part::ShapeFix_EdgeConnectPy::Type, shapeFix, "EdgeConnect");
Base::Interpreter().addType(&Part::ShapeFix_FaceConnectPy::Type, shapeFix, "FaceConnect");
Base::Interpreter().addType(&Part::ShapeFix_FreeBoundsPy::Type, shapeFix, "FreeBounds");
Base::Interpreter().addType(&Part::ShapeFix_ShapeTolerancePy::Type, shapeFix, "ShapeTolerance");
Base::Interpreter().addType(&Part::ShapeFix_SplitCommonVertexPy::Type, shapeFix, "SplitCommonVertex");

View File

@@ -145,6 +145,7 @@ generate_from_xml(ShapeFix/ShapeFix_SolidPy)
generate_from_xml(ShapeFix/ShapeFix_WirePy)
generate_from_xml(ShapeFix/ShapeFix_EdgeConnectPy)
generate_from_xml(ShapeFix/ShapeFix_FaceConnectPy)
generate_from_xml(ShapeFix/ShapeFix_FreeBoundsPy)
generate_from_xml(ShapeFix/ShapeFix_ShapeTolerancePy)
generate_from_xml(ShapeFix/ShapeFix_SplitCommonVertexPy)
@@ -450,6 +451,8 @@ SET(ShapeFixPy_SRCS
ShapeFix/ShapeFix_EdgeConnectPyImp.cpp
ShapeFix/ShapeFix_FaceConnectPy.xml
ShapeFix/ShapeFix_FaceConnectPyImp.cpp
ShapeFix/ShapeFix_FreeBoundsPy.xml
ShapeFix/ShapeFix_FreeBoundsPyImp.cpp
ShapeFix/ShapeFix_ShapeTolerancePy.xml
ShapeFix/ShapeFix_ShapeTolerancePyImp.cpp
ShapeFix/ShapeFix_SplitCommonVertexPy.xml

View File

@@ -0,0 +1,35 @@
<?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="ShapeFix_FreeBoundsPy"
PythonName="Part.ShapeFix.FreeBounds"
Twin="ShapeFix_FreeBounds"
TwinPointer="ShapeFix_FreeBounds"
Include="ShapeFix_FreeBounds.hxx"
Namespace="Part"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="true">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
<UserDocu>This class is intended to output free bounds of the shape</UserDocu>
</Documentation>
<Methode Name="closedWires">
<Documentation>
<UserDocu>Returns compound of closed wires out of free edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="openWires">
<Documentation>
<UserDocu>Returns compound of open wires out of free edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="shape">
<Documentation>
<UserDocu>Returns modified source shape</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,123 @@
/***************************************************************************
* Copyright (c) 2022 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 <Standard_Failure.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Shell.hxx>
#endif
#include "ShapeFix/ShapeFix_FreeBoundsPy.h"
#include "ShapeFix/ShapeFix_FreeBoundsPy.cpp"
#include "TopoShapePy.h"
using namespace Part;
// returns a string which represents the object e.g. when printed in python
std::string ShapeFix_FreeBoundsPy::representation() const
{
return "<ShapeFix_FreeBounds object>";
}
PyObject *ShapeFix_FreeBoundsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
return new ShapeFix_FreeBoundsPy(nullptr);
}
// constructor method
int ShapeFix_FreeBoundsPy::PyInit(PyObject* args, PyObject* /*kwds*/)
{
if (PyArg_ParseTuple(args, "")) {
setTwinPointer(new ShapeFix_FreeBounds);
return 0;
}
PyErr_Clear();
PyObject* shape;
PyObject* splitclosed;
PyObject* splitopen;
double sewtoler;
double closetoler;
if (PyArg_ParseTuple(args, "O!ddO!O!", &TopoShapePy::Type, &shape, &sewtoler, &closetoler,
&PyBool_Type, &splitclosed, &PyBool_Type, &splitopen)) {
TopoDS_Shape sh = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
setTwinPointer(new ShapeFix_FreeBounds(sh, sewtoler, closetoler,
PyObject_IsTrue(splitclosed) ? Standard_True : Standard_False,
PyObject_IsTrue(splitopen) ? Standard_True : Standard_False));
return 0;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!dO!O!", &TopoShapePy::Type, &shape, &closetoler,
&PyBool_Type, &splitclosed, &PyBool_Type, &splitopen)) {
TopoDS_Shape sh = static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
setTwinPointer(new ShapeFix_FreeBounds(sh, closetoler,
PyObject_IsTrue(splitclosed) ? Standard_True : Standard_False,
PyObject_IsTrue(splitopen) ? Standard_True : Standard_False));
return 0;
}
PyErr_SetString(PyExc_TypeError, "ShapeFix_FreeBounds()\n"
"ShapeFix_FreeBounds(shape, sewtolerance, closetolerance, splitClosed, splitOpen)\n"
"ShapeFix_FreeBounds(shape, closetolerance, splitClosed, splitOpen)");
return -1;
}
PyObject* ShapeFix_FreeBoundsPy::closedWires(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TopoShape comp = getShapeFix_FreeBoundsPtr()->GetClosedWires();
return comp.getPyObject();
}
PyObject* ShapeFix_FreeBoundsPy::openWires(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TopoShape comp = getShapeFix_FreeBoundsPtr()->GetOpenWires();
return comp.getPyObject();
}
PyObject* ShapeFix_FreeBoundsPy::shape(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TopoShape shape = getShapeFix_FreeBoundsPtr()->GetShape();
return shape.getPyObject();
}
PyObject *ShapeFix_FreeBoundsPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
int ShapeFix_FreeBoundsPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}