Part: expose ShapeFix_Shape to Python
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
#include <Mod/Part/App/RectangularTrimmedSurfacePy.h>
|
||||
#include <Mod/Part/App/ShapeFix/ShapeFix_RootPy.h>
|
||||
#include <Mod/Part/App/ShapeFix/ShapeFix_FacePy.h>
|
||||
#include <Mod/Part/App/ShapeFix/ShapeFix_ShapePy.h>
|
||||
#include <Mod/Part/App/ShapeFix/ShapeFix_ShellPy.h>
|
||||
#include <Mod/Part/App/ShapeFix/ShapeFix_WirePy.h>
|
||||
#include <Mod/Part/App/ShapeUpgrade/UnifySameDomainPy.h>
|
||||
@@ -345,6 +346,7 @@ PyMOD_INIT_FUNC(Part)
|
||||
PyObject* shapeFix(module.getAttr("ShapeFix").ptr());
|
||||
Base::Interpreter().addType(&Part::ShapeFix_RootPy::Type, shapeFix, "Root");
|
||||
Base::Interpreter().addType(&Part::ShapeFix_FacePy::Type, shapeFix, "Face");
|
||||
Base::Interpreter().addType(&Part::ShapeFix_ShapePy::Type, shapeFix, "Shape");
|
||||
Base::Interpreter().addType(&Part::ShapeFix_ShellPy::Type, shapeFix, "Shell");
|
||||
Base::Interpreter().addType(&Part::ShapeFix_WirePy::Type, shapeFix, "Wire");
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ generate_from_xml(HLRBRep/PolyHLRToShapePy)
|
||||
|
||||
generate_from_xml(ShapeFix/ShapeFix_RootPy)
|
||||
generate_from_xml(ShapeFix/ShapeFix_FacePy)
|
||||
generate_from_xml(ShapeFix/ShapeFix_ShapePy)
|
||||
generate_from_xml(ShapeFix/ShapeFix_ShellPy)
|
||||
generate_from_xml(ShapeFix/ShapeFix_WirePy)
|
||||
|
||||
@@ -429,6 +430,8 @@ SET(ShapeFixPy_SRCS
|
||||
ShapeFix/ShapeFix_RootPyImp.cpp
|
||||
ShapeFix/ShapeFix_FacePy.xml
|
||||
ShapeFix/ShapeFix_FacePyImp.cpp
|
||||
ShapeFix/ShapeFix_ShapePy.xml
|
||||
ShapeFix/ShapeFix_ShapePyImp.cpp
|
||||
ShapeFix/ShapeFix_ShellPy.xml
|
||||
ShapeFix/ShapeFix_ShellPyImp.cpp
|
||||
ShapeFix/ShapeFix_WirePy.xml
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
<UserDocu>Initializes by face</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixWireTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing wires</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearModes">
|
||||
<Documentation>
|
||||
<UserDocu>Sets all modes to default</UserDocu>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "ShapeFix/ShapeFix_FacePy.h"
|
||||
#include "ShapeFix/ShapeFix_FacePy.cpp"
|
||||
#include "ShapeFix/ShapeFix_WirePy.h"
|
||||
#include <Mod/Part/App/GeometrySurfacePy.h>
|
||||
#include <Mod/Part/App/TopoShapeFacePy.h>
|
||||
#include <Mod/Part/App/TopoShapeWirePy.h>
|
||||
@@ -43,7 +44,7 @@ std::string ShapeFix_FacePy::representation() const
|
||||
PyObject *ShapeFix_FacePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of ShapeFix_FacePy
|
||||
return new ShapeFix_FacePy(new ShapeFix_Face);
|
||||
return new ShapeFix_FacePy(nullptr);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
@@ -51,6 +52,7 @@ int ShapeFix_FacePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
PyObject* face = nullptr;
|
||||
if (PyArg_ParseTuple(args, "|O!", &TopoShapeFacePy::Type, &face)) {
|
||||
setHandle(new ShapeFix_Face());
|
||||
if (face) {
|
||||
getShapeFix_FacePtr()->Init(TopoDS::Face(static_cast<TopoShapePy*>(face)->getTopoShapePtr()->getShape()));
|
||||
}
|
||||
@@ -62,6 +64,7 @@ int ShapeFix_FacePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
double prec;
|
||||
PyObject* fwd = Py_True;
|
||||
if (PyArg_ParseTuple(args, "O!d|O!", &GeometrySurfacePy::Type, &face, &prec, &PyBool_Type, &fwd)) {
|
||||
setHandle(new ShapeFix_Face());
|
||||
if (face) {
|
||||
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(face)->getGeomSurfacePtr()->handle());
|
||||
getShapeFix_FacePtr()->Init(surf, prec, PyObject_IsTrue(fwd) ? Standard_True : Standard_False);
|
||||
@@ -75,7 +78,7 @@ int ShapeFix_FacePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
"-- Surface, Precision, [Forward=True}\n"
|
||||
" Precision is a Float\n"
|
||||
" If Forward is the orientation will be FORWARD or REVERSED otherwise"
|
||||
);
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -108,6 +111,17 @@ PyObject* ShapeFix_FacePy::init(PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_FacePy::fixWireTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Handle(ShapeFix_Wire) tool = getShapeFix_FacePtr()->FixWireTool();
|
||||
ShapeFix_WirePy* wire = new ShapeFix_WirePy(nullptr);
|
||||
wire->setHandle(tool);
|
||||
return wire;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_FacePy::clearModes(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
FatherInclude="Base/PyObjectBase.h"
|
||||
FatherNamespace="Base"
|
||||
Constructor="true"
|
||||
Delete="true">
|
||||
Delete="false">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>Root class for fixing operations</UserDocu>
|
||||
@@ -39,5 +39,15 @@
|
||||
</Documentation>
|
||||
<Parameter Name="MaxTolerance" Type="Float"/>
|
||||
</Attribute>
|
||||
<ClassDeclarations>
|
||||
private:
|
||||
Handle(ShapeFix_Root) hRoot;
|
||||
|
||||
public:
|
||||
void setHandle(Handle(ShapeFix_Root) handle) {
|
||||
setTwinPointer(handle.get());
|
||||
hRoot = handle;
|
||||
}
|
||||
</ClassDeclarations>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -41,7 +41,7 @@ std::string ShapeFix_RootPy::representation() const
|
||||
PyObject *ShapeFix_RootPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of ShapeFix_RootPy
|
||||
return new ShapeFix_RootPy(new ShapeFix_Root);
|
||||
return new ShapeFix_RootPy(nullptr);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
@@ -50,6 +50,7 @@ int ShapeFix_RootPy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return -1;
|
||||
|
||||
setHandle(new ShapeFix_Root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
101
src/Mod/Part/App/ShapeFix/ShapeFix_ShapePy.xml
Normal file
101
src/Mod/Part/App/ShapeFix/ShapeFix_ShapePy.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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_ShapePy"
|
||||
PythonName="Part.ShapeFix.Shape"
|
||||
Twin="ShapeFix_Shape"
|
||||
TwinPointer="ShapeFix_Shape"
|
||||
Include="ShapeFix_Shape.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>Class for fixing operations on shapes</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="init">
|
||||
<Documentation>
|
||||
<UserDocu>Initializes by shape</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="perform">
|
||||
<Documentation>
|
||||
<UserDocu>Iterates on sub- shape and performs fixes</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="shape">
|
||||
<Documentation>
|
||||
<UserDocu>Returns resulting shape</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixSolidTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing solids</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixShellTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing shells</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixFaceTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing faces</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixWireTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing wires</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixEdgeTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing edges</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="FixSolidMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying fixes of ShapeFix_Solid</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixSolidMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixFreeShellMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying fixes of ShapeFix_Shell</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixFreeShellMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixFreeFaceMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying fixes of ShapeFix_Face</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixFreeFaceMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixFreeWireMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying fixes of ShapeFix_Wire</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixFreeWireMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixSameParameterMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying ShapeFix::SameParameter after all fixes</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixSameParameterMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixVertexPositionMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying ShapeFix::FixVertexPosition before all fixes</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixVertexPositionMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixVertexTolMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for fixing tolerances of vertices on whole shape</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixVertexTolMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
224
src/Mod/Part/App/ShapeFix/ShapeFix_ShapePyImp.cpp
Normal file
224
src/Mod/Part/App/ShapeFix/ShapeFix_ShapePyImp.cpp
Normal file
@@ -0,0 +1,224 @@
|
||||
/***************************************************************************
|
||||
* 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 <TopoDS.hxx>
|
||||
#endif
|
||||
|
||||
#include "ShapeFix/ShapeFix_ShapePy.h"
|
||||
#include "ShapeFix/ShapeFix_ShapePy.cpp"
|
||||
//#include "ShapeFix/ShapeFix_EdgePy.h"
|
||||
#include "ShapeFix/ShapeFix_WirePy.h"
|
||||
#include "ShapeFix/ShapeFix_FacePy.h"
|
||||
#include "ShapeFix/ShapeFix_ShellPy.h"
|
||||
//#include "ShapeFix/ShapeFix_SolidPy.h"
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string ShapeFix_ShapePy::representation() const
|
||||
{
|
||||
return "<ShapeFix_Shape object>";
|
||||
}
|
||||
|
||||
PyObject *ShapeFix_ShapePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of ShapeFix_ShapePy
|
||||
return new ShapeFix_ShapePy(nullptr);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int ShapeFix_ShapePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
PyObject* shape = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "|O!", &TopoShapePy::Type, &shape))
|
||||
return -1;
|
||||
|
||||
setHandle(new ShapeFix_Shape);
|
||||
if (shape) {
|
||||
getShapeFix_ShapePtr()->Init(static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::init(PyObject *args)
|
||||
{
|
||||
PyObject* shape;
|
||||
if (!PyArg_ParseTuple(args, "O!", &TopoShapePy::Type, &shape))
|
||||
return nullptr;
|
||||
|
||||
getShapeFix_ShapePtr()->Init(static_cast<TopoShapePy*>(shape)->getTopoShapePtr()->getShape());
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::perform(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Standard_Boolean ok = getShapeFix_ShapePtr()->Perform();
|
||||
return Py::new_reference_to(Py::Boolean(ok ? true : false));
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::shape(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
TopoShape shape = getShapeFix_ShapePtr()->Shape();
|
||||
return shape.getPyObject();
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::fixSolidTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Handle(ShapeFix_Solid) tool = getShapeFix_ShapePtr()->FixSolidTool();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::fixShellTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Handle(ShapeFix_Shell) tool = getShapeFix_ShapePtr()->FixShellTool();
|
||||
ShapeFix_ShellPy* shell = new ShapeFix_ShellPy(nullptr);
|
||||
shell->setHandle(tool);
|
||||
return shell;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::fixFaceTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Handle(ShapeFix_Face) tool = getShapeFix_ShapePtr()->FixFaceTool();
|
||||
ShapeFix_FacePy* face = new ShapeFix_FacePy(nullptr);
|
||||
face->setHandle(tool);
|
||||
return face;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::fixWireTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Handle(ShapeFix_Wire) tool = getShapeFix_ShapePtr()->FixWireTool();
|
||||
ShapeFix_WirePy* wire = new ShapeFix_WirePy(nullptr);
|
||||
wire->setHandle(tool);
|
||||
return wire;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShapePy::fixEdgeTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
//Handle(ShapeFix_Edge) tool = getShapeFix_ShapePtr()->FixEdgeTool();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixSolidMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixSolidMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixSolidMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixSolidMode() = arg;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixFreeShellMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixFreeShellMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixFreeShellMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixFreeShellMode() = arg;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixFreeFaceMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixFreeFaceMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixFreeFaceMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixFreeFaceMode() = arg;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixFreeWireMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixFreeWireMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixFreeWireMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixFreeWireMode() = arg;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixSameParameterMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixSameParameterMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixSameParameterMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixSameParameterMode() = arg;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixVertexPositionMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixVertexPositionMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixVertexPositionMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixVertexPositionMode() = arg;
|
||||
}
|
||||
|
||||
Py::Boolean ShapeFix_ShapePy::getFixVertexTolMode() const
|
||||
{
|
||||
return Py::Boolean(getShapeFix_ShapePtr()->FixVertexTolMode());
|
||||
}
|
||||
|
||||
void ShapeFix_ShapePy::setFixVertexTolMode(Py::Boolean arg)
|
||||
{
|
||||
getShapeFix_ShapePtr()->FixVertexTolMode() = arg;
|
||||
}
|
||||
|
||||
PyObject *ShapeFix_ShapePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int ShapeFix_ShapePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -20,6 +20,11 @@
|
||||
<UserDocu>Initializes by shell</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixFaceTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing faces</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="perform">
|
||||
<Documentation>
|
||||
<UserDocu>Iterates on subshapes and performs fixes</UserDocu>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "ShapeFix/ShapeFix_ShellPy.h"
|
||||
#include "ShapeFix/ShapeFix_ShellPy.cpp"
|
||||
#include "ShapeFix/ShapeFix_FacePy.h"
|
||||
#include <Mod/Part/App/TopoShapeShellPy.h>
|
||||
|
||||
using namespace Part;
|
||||
@@ -43,7 +44,7 @@ std::string ShapeFix_ShellPy::representation() const
|
||||
PyObject *ShapeFix_ShellPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of ShapeFix_RootPy
|
||||
return new ShapeFix_ShellPy(new ShapeFix_Shell);
|
||||
return new ShapeFix_ShellPy(nullptr);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
@@ -53,6 +54,7 @@ int ShapeFix_ShellPy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
if (!PyArg_ParseTuple(args, "|O!", &TopoShapeShellPy::Type, &shell))
|
||||
return -1;
|
||||
|
||||
setHandle(new ShapeFix_Shell);
|
||||
if (shell) {
|
||||
getShapeFix_ShellPtr()->Init(TopoDS::Shell(static_cast<TopoShapePy*>(shell)->getTopoShapePtr()->getShape()));
|
||||
}
|
||||
@@ -70,6 +72,17 @@ PyObject* ShapeFix_ShellPy::init(PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShellPy::fixFaceTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Handle(ShapeFix_Face) tool = getShapeFix_ShellPtr()->FixFaceTool();
|
||||
ShapeFix_FacePy* face = new ShapeFix_FacePy(nullptr);
|
||||
face->setHandle(tool);
|
||||
return face;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_ShellPy::perform(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
<UserDocu>Initializes by wire, face, precision</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixEdgeTool">
|
||||
<Documentation>
|
||||
<UserDocu>Returns tool for fixing wires</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearModes">
|
||||
<Documentation>
|
||||
<UserDocu>Sets all modes to default</UserDocu>
|
||||
|
||||
@@ -46,7 +46,7 @@ std::string ShapeFix_WirePy::representation() const
|
||||
|
||||
PyObject *ShapeFix_WirePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
return new ShapeFix_WirePy(new ShapeFix_Wire);
|
||||
return new ShapeFix_WirePy(nullptr);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
@@ -54,6 +54,7 @@ int ShapeFix_WirePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
// Nothing needs to be done
|
||||
setHandle(new ShapeFix_Wire);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -63,6 +64,7 @@ int ShapeFix_WirePy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
double prec;
|
||||
if (PyArg_ParseTuple(args, "O!O!d", &TopoShapeWirePy::Type, &wire,
|
||||
&TopoShapeFacePy::Type, &face, &prec)) {
|
||||
setHandle(new ShapeFix_Wire);
|
||||
TopoDS_Shape w = static_cast<TopoShapePy*>(wire)->getTopoShapePtr()->getShape();
|
||||
TopoDS_Shape f = static_cast<TopoShapePy*>(face)->getTopoShapePtr()->getShape();
|
||||
getShapeFix_WirePtr()->Init(TopoDS::Wire(w), TopoDS::Face(f), prec);
|
||||
@@ -93,6 +95,15 @@ PyObject* ShapeFix_WirePy::init(PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_WirePy::fixEdgeTool(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
//Handle(ShapeFix_Edge) tool = getShapeFix_WirePtr()->FixEdgeTool();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ShapeFix_WirePy::clearModes(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
||||
@@ -414,6 +414,46 @@ class PartTestShapeFix(unittest.TestCase):
|
||||
|
||||
self.assertEqual(fix.limitTolerance(0.25), 0.25)
|
||||
|
||||
def testShapeFix_Shape(self):
|
||||
surface = Part.Plane()
|
||||
face = surface.toShape(-1, 1, -1, 1)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
Part.ShapeFix.Shape([])
|
||||
|
||||
fix = Part.ShapeFix.Shape(face)
|
||||
fix.init(face)
|
||||
print (fix)
|
||||
fix.shape()
|
||||
fix.fixSolidTool()
|
||||
fix.fixShellTool()
|
||||
fix.fixFaceTool()
|
||||
fix.fixWireTool()
|
||||
fix.fixEdgeTool()
|
||||
|
||||
fix.FixSolidMode = True
|
||||
self.assertEqual(fix.FixSolidMode, True)
|
||||
|
||||
fix.FixFreeShellMode = True
|
||||
self.assertEqual(fix.FixFreeShellMode, True)
|
||||
|
||||
fix.FixFreeFaceMode = True
|
||||
self.assertEqual(fix.FixFreeFaceMode, True)
|
||||
|
||||
fix.FixFreeWireMode = True
|
||||
self.assertEqual(fix.FixFreeWireMode, True)
|
||||
|
||||
fix.FixSameParameterMode = True
|
||||
self.assertEqual(fix.FixSameParameterMode, True)
|
||||
|
||||
fix.FixVertexPositionMode = True
|
||||
self.assertEqual(fix.FixVertexPositionMode, True)
|
||||
|
||||
fix.FixVertexTolMode = True
|
||||
self.assertEqual(fix.FixVertexTolMode, True)
|
||||
|
||||
fix.perform()
|
||||
|
||||
def testShapeFix_Face(self):
|
||||
surface = Part.Plane()
|
||||
face = surface.toShape(-1, 1, -1, 1)
|
||||
@@ -439,6 +479,7 @@ class PartTestShapeFix(unittest.TestCase):
|
||||
fix.add(face.OuterWire)
|
||||
current = fix.face()
|
||||
result = fix.result()
|
||||
fix.fixWireTool()
|
||||
|
||||
fix.FixWireMode = True
|
||||
self.assertEqual(fix.FixWireMode, True)
|
||||
@@ -490,6 +531,7 @@ class PartTestShapeFix(unittest.TestCase):
|
||||
fix.perform()
|
||||
fix.shell()
|
||||
fix.shape()
|
||||
fix.fixFaceTool()
|
||||
|
||||
fix.setNonManifoldFlag(True)
|
||||
fix.fixFaceOrientation(shell)
|
||||
@@ -519,6 +561,7 @@ class PartTestShapeFix(unittest.TestCase):
|
||||
fix.setFace(face)
|
||||
fix.setMaxTailAngle(math.pi)
|
||||
fix.setMaxTailWidth(10.0)
|
||||
fix.fixEdgeTool()
|
||||
|
||||
self.assertEqual(fix.isLoaded(), True)
|
||||
self.assertEqual(fix.isReady(), True)
|
||||
|
||||
Reference in New Issue
Block a user