Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part: start to expose ShapeFix framework to Python
- Loading branch information
Showing
7 changed files
with
327 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?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_RootPy" | ||
PythonName="Part.ShapeFix.Root" | ||
Twin="ShapeFix_Root" | ||
TwinPointer="ShapeFix_Root" | ||
Include="ShapeFix_Root.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>Root class for fixing operations</UserDocu> | ||
</Documentation> | ||
<Methode Name="limitTolerance" Const="true"> | ||
<Documentation> | ||
<UserDocu>Returns tolerance limited by [MinTolerance,MaxTolerance]</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Attribute Name="Precision" ReadOnly="false"> | ||
<Documentation> | ||
<UserDocu>Basic precision value</UserDocu> | ||
</Documentation> | ||
<Parameter Name="Precision" Type="Float"/> | ||
</Attribute> | ||
<Attribute Name="MinTolerance" ReadOnly="false"> | ||
<Documentation> | ||
<UserDocu>Minimal allowed tolerance</UserDocu> | ||
</Documentation> | ||
<Parameter Name="MinTolerance" Type="Float"/> | ||
</Attribute> | ||
<Attribute Name="MaxTolerance" ReadOnly="false"> | ||
<Documentation> | ||
<UserDocu>Maximal allowed tolerance</UserDocu> | ||
</Documentation> | ||
<Parameter Name="MaxTolerance" Type="Float"/> | ||
</Attribute> | ||
</PythonExport> | ||
</GenerateModel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/*************************************************************************** | ||
* 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 <Precision.hxx> | ||
# include <Standard_Failure.hxx> | ||
#endif | ||
|
||
#include "ShapeFix/ShapeFix_RootPy.h" | ||
#include "ShapeFix/ShapeFix_RootPy.cpp" | ||
|
||
using namespace Part; | ||
|
||
// returns a string which represents the object e.g. when printed in python | ||
std::string ShapeFix_RootPy::representation() const | ||
{ | ||
return "<ShapeFix_Root object>"; | ||
} | ||
|
||
PyObject *ShapeFix_RootPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper | ||
{ | ||
// create a new instance of ShapeFix_RootPy | ||
return new ShapeFix_RootPy(new ShapeFix_Root); | ||
} | ||
|
||
// constructor method | ||
int ShapeFix_RootPy::PyInit(PyObject* /*args*/, PyObject* /*kwds*/) | ||
{ | ||
return 0; | ||
} | ||
|
||
PyObject* ShapeFix_RootPy::limitTolerance(PyObject *args) | ||
{ | ||
double tol; | ||
if (!PyArg_ParseTuple(args, "d", &tol)) | ||
return nullptr; | ||
|
||
tol = getShapeFix_RootPtr()->LimitTolerance(tol); | ||
return Py::new_reference_to(Py::Float(tol)); | ||
} | ||
|
||
Py::Float ShapeFix_RootPy::getPrecision() const | ||
{ | ||
return Py::Float(getShapeFix_RootPtr()->Precision()); | ||
} | ||
|
||
void ShapeFix_RootPy::setPrecision(Py::Float arg) | ||
{ | ||
getShapeFix_RootPtr()->SetPrecision(arg); | ||
} | ||
|
||
Py::Float ShapeFix_RootPy::getMinTolerance() const | ||
{ | ||
return Py::Float(getShapeFix_RootPtr()->MinTolerance()); | ||
} | ||
|
||
void ShapeFix_RootPy::setMinTolerance(Py::Float arg) | ||
{ | ||
getShapeFix_RootPtr()->SetMinTolerance(arg); | ||
} | ||
|
||
Py::Float ShapeFix_RootPy::getMaxTolerance() const | ||
{ | ||
return Py::Float(getShapeFix_RootPtr()->MaxTolerance()); | ||
} | ||
|
||
void ShapeFix_RootPy::setMaxTolerance(Py::Float arg) | ||
{ | ||
getShapeFix_RootPtr()->SetMaxTolerance(arg); | ||
} | ||
|
||
PyObject *ShapeFix_RootPy::getCustomAttributes(const char* /*attr*/) const | ||
{ | ||
return nullptr; | ||
} | ||
|
||
int ShapeFix_RootPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd"> | ||
<PythonExport | ||
Father="ShapeFix_RootPy" | ||
Name="ShapeFix_ShellPy" | ||
PythonName="Part.ShapeFix.Shell" | ||
Twin="ShapeFix_Shell" | ||
TwinPointer="ShapeFix_Shell" | ||
Include="ShapeFix_Shell.hxx" | ||
Namespace="Part" | ||
FatherInclude="Mod/Part/App/ShapeFix/ShapeFix_RootPy.h" | ||
FatherNamespace="Part" | ||
Constructor="true"> | ||
<Documentation> | ||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" /> | ||
<UserDocu>Root class for fixing operations</UserDocu> | ||
</Documentation> | ||
<Methode Name="init"> | ||
<Documentation> | ||
<UserDocu>Initializes by shell</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="perform"> | ||
<Documentation> | ||
<UserDocu>Iterates on subshapes and performs fixes</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="shell"> | ||
<Documentation> | ||
<UserDocu>Returns fixed shell (or subset of oriented faces)</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="shape"> | ||
<Documentation> | ||
<UserDocu>In case of multiconnexity returns compound of fixed shells and one shell otherwise</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
</PythonExport> | ||
</GenerateModel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/*************************************************************************** | ||
* 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 <Precision.hxx> | ||
# include <Standard_Failure.hxx> | ||
# include <TopoDS.hxx> | ||
#endif | ||
|
||
#include "ShapeFix/ShapeFix_ShellPy.h" | ||
#include "ShapeFix/ShapeFix_ShellPy.cpp" | ||
#include <Mod/Part/App/TopoShapeShellPy.h> | ||
|
||
using namespace Part; | ||
|
||
// returns a string which represents the object e.g. when printed in python | ||
std::string ShapeFix_ShellPy::representation() const | ||
{ | ||
return "<ShapeFix_Shell object>"; | ||
} | ||
|
||
PyObject *ShapeFix_ShellPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper | ||
{ | ||
// create a new instance of ShapeFix_RootPy | ||
return new ShapeFix_ShellPy(new ShapeFix_Shell); | ||
} | ||
|
||
// constructor method | ||
int ShapeFix_ShellPy::PyInit(PyObject* args, PyObject* /*kwds*/) | ||
{ | ||
PyObject* shell = nullptr; | ||
if (!PyArg_ParseTuple(args, "|O!", &TopoShapeShellPy::Type, &shell)) | ||
return -1; | ||
|
||
if (shell) { | ||
getShapeFix_ShellPtr()->Init(TopoDS::Shell(static_cast<TopoShapePy*>(shell)->getTopoShapePtr()->getShape())); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
PyObject* ShapeFix_ShellPy::init(PyObject *args) | ||
{ | ||
PyObject* shell; | ||
if (!PyArg_ParseTuple(args, "O!", &TopoShapeShellPy::Type, &shell)) | ||
return nullptr; | ||
|
||
getShapeFix_ShellPtr()->Init(TopoDS::Shell(static_cast<TopoShapePy*>(shell)->getTopoShapePtr()->getShape())); | ||
Py_Return; | ||
} | ||
|
||
PyObject* ShapeFix_ShellPy::perform(PyObject *args) | ||
{ | ||
if (!PyArg_ParseTuple(args, "")) | ||
return nullptr; | ||
|
||
Standard_Boolean ok = getShapeFix_ShellPtr()->Perform(); | ||
return Py::new_reference_to(Py::Boolean(ok ? true : false)); | ||
} | ||
|
||
PyObject* ShapeFix_ShellPy::shell(PyObject *args) | ||
{ | ||
if (!PyArg_ParseTuple(args, "")) | ||
return nullptr; | ||
|
||
TopoShape shape = getShapeFix_ShellPtr()->Shell(); | ||
return shape.getPyObject(); | ||
} | ||
|
||
PyObject* ShapeFix_ShellPy::shape(PyObject *args) | ||
{ | ||
if (!PyArg_ParseTuple(args, "")) | ||
return nullptr; | ||
|
||
TopoShape shape = getShapeFix_ShellPtr()->Shape(); | ||
return shape.getPyObject(); | ||
} | ||
|
||
PyObject *ShapeFix_ShellPy::getCustomAttributes(const char* /*attr*/) const | ||
{ | ||
return nullptr; | ||
} | ||
|
||
int ShapeFix_ShellPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) | ||
{ | ||
return 0; | ||
} |