Part: expose ShapeFix_Wire to Python

This commit is contained in:
wmayer
2022-05-01 17:35:56 +02:00
parent da4b05fdcc
commit 94f6279a67
6 changed files with 1297 additions and 1 deletions

View File

@@ -103,6 +103,7 @@
#include <Mod/Part/App/ShapeFix/ShapeFix_RootPy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_FacePy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_ShellPy.h>
#include <Mod/Part/App/ShapeFix/ShapeFix_WirePy.h>
#include <Mod/Part/App/ShapeUpgrade/UnifySameDomainPy.h>
#include "Mod/Part/App/SpherePy.h"
#include "Mod/Part/App/SurfaceOfExtrusionPy.h"
@@ -345,6 +346,7 @@ PyMOD_INIT_FUNC(Part)
Base::Interpreter().addType(&Part::ShapeFix_RootPy::Type, shapeFix, "Root");
Base::Interpreter().addType(&Part::ShapeFix_FacePy::Type, shapeFix, "Face");
Base::Interpreter().addType(&Part::ShapeFix_ShellPy::Type, shapeFix, "Shell");
Base::Interpreter().addType(&Part::ShapeFix_WirePy::Type, shapeFix, "Wire");
// ShapeUpgrade sub-module
PyObject* shapeUpgrade(module.getAttr("ShapeUpgrade").ptr());

View File

@@ -139,6 +139,7 @@ generate_from_xml(HLRBRep/PolyHLRToShapePy)
generate_from_xml(ShapeFix/ShapeFix_RootPy)
generate_from_xml(ShapeFix/ShapeFix_FacePy)
generate_from_xml(ShapeFix/ShapeFix_ShellPy)
generate_from_xml(ShapeFix/ShapeFix_WirePy)
generate_from_xml(ShapeUpgrade/UnifySameDomainPy)
@@ -430,6 +431,8 @@ SET(ShapeFixPy_SRCS
ShapeFix/ShapeFix_FacePyImp.cpp
ShapeFix/ShapeFix_ShellPy.xml
ShapeFix/ShapeFix_ShellPyImp.cpp
ShapeFix/ShapeFix_WirePy.xml
ShapeFix/ShapeFix_WirePyImp.cpp
)
SOURCE_GROUP("ShapeFix" FILES ${ShapeFixPy_SRCS})

View File

@@ -22,7 +22,7 @@
</Methode>
<Methode Name="clearModes">
<Documentation>
<UserDocu>Iterates on subshapes and performs fixes</UserDocu>
<UserDocu>Sets all modes to default</UserDocu>
</Documentation>
</Methode>
<Methode Name="add">

View File

@@ -0,0 +1,359 @@
<?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_WirePy"
PythonName="Part.ShapeFix.Wire"
Twin="ShapeFix_Wire"
TwinPointer="ShapeFix_Wire"
Include="ShapeFix_Wire.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 wires</UserDocu>
</Documentation>
<Methode Name="init">
<Documentation>
<UserDocu>Initializes by wire, face, precision</UserDocu>
</Documentation>
</Methode>
<Methode Name="clearModes">
<Documentation>
<UserDocu>Sets all modes to default</UserDocu>
</Documentation>
</Methode>
<Methode Name="clearStatuses">
<Documentation>
<UserDocu>Clears all statuses</UserDocu>
</Documentation>
</Methode>
<Methode Name="load">
<Documentation>
<UserDocu>Load data for the wire, and drops all fixing statuses</UserDocu>
</Documentation>
</Methode>
<Methode Name="setFace">
<Documentation>
<UserDocu>Set working face for the wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="setSurface">
<Documentation>
<UserDocu>setSurface(surface, [Placement])
Set surface for the wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="setMaxTailAngle">
<Documentation>
<UserDocu>Sets the maximal allowed angle of the tails in radians</UserDocu>
</Documentation>
</Methode>
<Methode Name="setMaxTailWidth">
<Documentation>
<UserDocu>Sets the maximal allowed width of the tails</UserDocu>
</Documentation>
</Methode>
<Methode Name="isLoaded">
<Documentation>
<UserDocu>Tells if the wire is loaded</UserDocu>
</Documentation>
</Methode>
<Methode Name="isReady">
<Documentation>
<UserDocu>Tells if the wire and face are loaded</UserDocu>
</Documentation>
</Methode>
<Methode Name="numberOfEdges">
<Documentation>
<UserDocu>Returns number of edges in the working wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="wire">
<Documentation>
<UserDocu>Makes the resulting Wire (by basic Brep_Builder)</UserDocu>
</Documentation>
</Methode>
<Methode Name="wireAPIMake">
<Documentation>
<UserDocu>Makes the resulting Wire (by BRepAPI_MakeWire)</UserDocu>
</Documentation>
</Methode>
<Methode Name="face">
<Documentation>
<UserDocu>Returns working face</UserDocu>
</Documentation>
</Methode>
<Methode Name="perform">
<Documentation>
<UserDocu>Iterates on subshapes and performs fixes</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixReorder">
<Documentation>
<UserDocu>Performs an analysis and reorders edges in the wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixSmall">
<Documentation>
<UserDocu>Applies fixSmall(...) to all edges in the wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixConnected">
<Documentation>
<UserDocu>Applies fixConnected(num) to all edges in the wire
Connection between first and last edges is treated only if
flag ClosedMode is True
If prec is -1 then maxTolerance() is taken.</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixEdgeCurves">
<Documentation>
<UserDocu>Groups the fixes dealing with 3d and pcurves of the edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixDegenerated">
<Documentation>
<UserDocu>Applies fixDegenerated(...) to all edges in the wire</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixSelfIntersection">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="fixLacking">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="fixClosed">
<Documentation>
<UserDocu>Fixes a wire to be well closed</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixGaps3d">
<Documentation>
<UserDocu>Fixes gaps between ends of 3d curves on adjacent edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixGaps2d">
<Documentation>
<UserDocu>Fixes gaps between ends of pcurves on adjacent edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixSeam">
<Documentation>
<UserDocu>Fixes seam edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixShifted">
<Documentation>
<UserDocu>Fixes edges which have pcurves shifted by whole parameter
range on the closed surface</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixNotchedEdges">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="fixGap3d">
<Documentation>
<UserDocu>Fixes gap between ends of 3d curves on num-1 and num-th edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixGap2d">
<Documentation>
<UserDocu>Fixes gap between ends of pcurves on num-1 and num-th edges</UserDocu>
</Documentation>
</Methode>
<Methode Name="fixTails">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Attribute Name="ModifyTopologyMode" ReadOnly="false">
<Documentation>
<UserDocu>Mode for modifying topology of the wire</UserDocu>
</Documentation>
<Parameter Name="ModifyTopologyMode" Type="Boolean"/>
</Attribute>
<Attribute Name="ModifyGeometryMode" ReadOnly="false">
<Documentation>
<UserDocu>Mode for modifying geometry of vertexes and edges</UserDocu>
</Documentation>
<Parameter Name="ModifyGeometryMode" Type="Boolean"/>
</Attribute>
<Attribute Name="ModifyRemoveLoopMode" ReadOnly="false">
<Documentation>
<UserDocu>Mode for modifying edges</UserDocu>
</Documentation>
<Parameter Name="ModifyRemoveLoopMode" Type="Boolean"/>
</Attribute>
<Attribute Name="ClosedWireMode" ReadOnly="false">
<Documentation>
<UserDocu>Mode which defines whether the wire
is to be closed (by calling methods like fixDegenerated()
and fixConnected() for last and first edges)</UserDocu>
</Documentation>
<Parameter Name="ClosedWireMode" Type="Boolean"/>
</Attribute>
<Attribute Name="PreferencePCurveMode" ReadOnly="false">
<Documentation>
<UserDocu>Mode which defines whether the 2d (True)
representation of the wire is preferable over 3d one (in the
case of ambiguity in FixEdgeCurves)</UserDocu>
</Documentation>
<Parameter Name="PreferencePCurveMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixGapsByRangesMode" ReadOnly="false">
<Documentation>
<UserDocu>Mode which defines whether tool
tries to fix gaps first by changing curves ranges (i.e.
using intersection, extrema, projections) or not</UserDocu>
</Documentation>
<Parameter Name="FixGapsByRangesMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixReorderMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixReorderMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixSmallMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixSmallMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixConnectedMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixConnectedMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixEdgeCurvesMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixEdgeCurvesMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixDegeneratedMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixDegeneratedMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixSelfIntersectionMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixSelfIntersectionMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixLackingMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixLackingMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixGaps3dMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixGaps3dMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixGaps2dMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixGaps2dMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixReversed2dMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixReversed2dMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixRemovePCurveMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixRemovePCurveMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixAddPCurveMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixAddPCurveMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixRemoveCurve3dMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixRemoveCurve3dMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixAddCurve3dMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixAddCurve3dMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixSeamMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixSeamMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixShiftedMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixShiftedMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixSameParameterMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixSameParameterMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixVertexToleranceMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixVertexToleranceMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixNotchedEdgesMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixNotchedEdgesMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixSelfIntersectingEdgeMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixSelfIntersectingEdgeMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixIntersectingEdgesMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixIntersectingEdgesMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixNonAdjacentIntersectingEdgesMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixNonAdjacentIntersectingEdgesMode" Type="Boolean"/>
</Attribute>
<Attribute Name="FixTailMode" ReadOnly="false">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
<Parameter Name="FixTailMode" Type="Boolean"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,795 @@
/***************************************************************************
* 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 <gp_Quaternion.hxx>
# include <ShapeFix_Wire.hxx>
# include <TopoDS.hxx>
#endif
#include "ShapeFix/ShapeFix_WirePy.h"
#include "ShapeFix/ShapeFix_WirePy.cpp"
#include <Base/PlacementPy.h>
#include <Mod/Part/App/GeometrySurfacePy.h>
#include <Mod/Part/App/TopoShapeFacePy.h>
#include <Mod/Part/App/TopoShapeWirePy.h>
#include "OCCError.h"
using namespace Part;
// returns a string which represents the object e.g. when printed in python
std::string ShapeFix_WirePy::representation() const
{
return "<ShapeFix_Wire object>";
}
PyObject *ShapeFix_WirePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
return new ShapeFix_WirePy(new ShapeFix_Wire);
}
// constructor method
int ShapeFix_WirePy::PyInit(PyObject* args, PyObject* /*kwds*/)
{
if (PyArg_ParseTuple(args, "")) {
// Nothing needs to be done
return 0;
}
PyErr_Clear();
PyObject* wire;
PyObject* face;
double prec;
if (PyArg_ParseTuple(args, "O!O!d", &TopoShapeWirePy::Type, &wire,
&TopoShapeFacePy::Type, &face, &prec)) {
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);
return 0;
}
PyErr_SetString(PyExc_TypeError, "Supported arguments are:\n"
"-- Empty\n"
"-- Wire, Face, Precision"
);
return -1;
}
PyObject* ShapeFix_WirePy::init(PyObject *args)
{
PyObject* wire;
PyObject* face;
double prec;
if (!PyArg_ParseTuple(args, "O!O!d", &TopoShapeWirePy::Type, &wire,
&TopoShapeFacePy::Type, &face, &prec))
return nullptr;
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);
Py_Return;
}
PyObject* ShapeFix_WirePy::clearModes(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
getShapeFix_WirePtr()->ClearModes();
Py_Return;
}
PyObject* ShapeFix_WirePy::clearStatuses(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
getShapeFix_WirePtr()->ClearStatuses();
Py_Return;
}
PyObject* ShapeFix_WirePy::load(PyObject *args)
{
PyObject* wire;
if (!PyArg_ParseTuple(args, "O!", &TopoShapeWirePy::Type, &wire))
return nullptr;
TopoDS_Shape w = static_cast<TopoShapePy*>(wire)->getTopoShapePtr()->getShape();
getShapeFix_WirePtr()->Load(TopoDS::Wire(w));
Py_Return;
}
PyObject* ShapeFix_WirePy::setFace(PyObject *args)
{
PyObject* face;
if (!PyArg_ParseTuple(args, "O!", &TopoShapeFacePy::Type, &face))
return nullptr;
TopoDS_Shape f = static_cast<TopoShapePy*>(face)->getTopoShapePtr()->getShape();
getShapeFix_WirePtr()->SetFace(TopoDS::Face(f));
Py_Return;
}
PyObject* ShapeFix_WirePy::setSurface(PyObject *args)
{
PyObject* surface;
PyObject* plm = nullptr;
if (!PyArg_ParseTuple(args, "O!|O!", &GeometrySurfacePy::Type, &surface,
&Base::PlacementPy::Type, &plm))
return nullptr;
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(static_cast<GeometrySurfacePy*>(surface)->getGeomSurfacePtr()->handle());
if (plm) {
Base::Placement* pm = static_cast<Base::PlacementPy*>(plm)->getPlacementPtr();
Base::Rotation r = pm->getRotation();
double q1, q2, q3, q4;
r.getValue(q1, q2, q3, q4);
Base::Vector3d t = pm->getPosition();
gp_Trsf trf;
trf.SetTranslation(gp_Vec(t.x, t.y, t.z));
trf.SetRotation(gp_Quaternion(q1, q2, q3, q4));
TopLoc_Location loc(trf);
getShapeFix_WirePtr()->SetSurface(surf, loc);
}
else {
getShapeFix_WirePtr()->SetSurface(surf);
}
Py_Return;
}
PyObject* ShapeFix_WirePy::setMaxTailAngle(PyObject *args)
{
double angle;
if (!PyArg_ParseTuple(args, "d", &angle))
return nullptr;
getShapeFix_WirePtr()->SetMaxTailAngle(angle);
Py_Return;
}
PyObject* ShapeFix_WirePy::setMaxTailWidth(PyObject *args)
{
double width;
if (!PyArg_ParseTuple(args, "d", &width))
return nullptr;
getShapeFix_WirePtr()->SetMaxTailWidth(width);
Py_Return;
}
PyObject* ShapeFix_WirePy::isLoaded(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->IsLoaded();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::isReady(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->IsReady();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::numberOfEdges(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
int num = getShapeFix_WirePtr()->NbEdges();
return Py::new_reference_to(Py::Long(num));
}
PyObject* ShapeFix_WirePy::wire(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TopoShape wire = getShapeFix_WirePtr()->Wire();
return wire.getPyObject();
}
PyObject* ShapeFix_WirePy::wireAPIMake(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TopoShape wire = getShapeFix_WirePtr()->WireAPIMake();
return wire.getPyObject();
}
PyObject* ShapeFix_WirePy::face(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TopoShape face = getShapeFix_WirePtr()->Face();
return face.getPyObject();
}
PyObject* ShapeFix_WirePy::perform(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->Perform();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixReorder(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixReorder();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixSmall(PyObject *args)
{
PyObject* lock;
double prec = 0.0;
if (PyArg_ParseTuple(args, "O!|d", &PyBool_Type, &lock, &prec)) {
try {
int num = getShapeFix_WirePtr()->FixSmall(PyObject_IsTrue(lock) ? Standard_True : Standard_False, prec);
return Py::new_reference_to(Py::Long(num));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyErr_Clear();
int num;
if (PyArg_ParseTuple(args, "iO!d", &num, &PyBool_Type, &lock, &prec)) {
try {
bool ok = getShapeFix_WirePtr()->FixSmall(num, PyObject_IsTrue(lock) ? Standard_True : Standard_False, prec);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyErr_SetString(PyExc_TypeError, "Arguments must be:\n"
"-- fixSmall(bool, [float]) or\n"
"-- fixSmall(int, bool, float)");
return nullptr;
}
PyObject* ShapeFix_WirePy::fixConnected(PyObject *args)
{
double prec = -1.0;
if (PyArg_ParseTuple(args, "|d", &prec)) {
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixConnected(prec);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyErr_Clear();
int num;
if (PyArg_ParseTuple(args, "id", &num, &prec)) {
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixConnected(num, prec);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyErr_SetString(PyExc_TypeError, "Arguments must be:\n"
"-- fixConnected([float]) or\n"
"-- fixConnected(int, float)");
return nullptr;
}
PyObject* ShapeFix_WirePy::fixEdgeCurves(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixEdgeCurves();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixDegenerated(PyObject *args)
{
int num = -1;
if (!PyArg_ParseTuple(args, "|i", &num))
return nullptr;
try {
Standard_Boolean ok = num > -1 ? getShapeFix_WirePtr()->FixDegenerated(num)
: getShapeFix_WirePtr()->FixDegenerated();
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyObject* ShapeFix_WirePy::fixSelfIntersection(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixSelfIntersection();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixLacking(PyObject *args)
{
PyObject* force = Py_False;
if (PyArg_ParseTuple(args, "|O!", &PyBool_Type, &force)) {
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixLacking(PyObject_IsTrue(force) ? Standard_True : Standard_False);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyErr_Clear();
int num;
force = Py_False;
if (PyArg_ParseTuple(args, "i|O!", &num, &PyBool_Type, &force)) {
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixLacking(num, PyObject_IsTrue(force) ? Standard_True : Standard_False);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyErr_SetString(PyExc_TypeError, "Arguments must be:\n"
"-- fixLacking([bool=False]) or\n"
"-- fixLacking(int, bool)");
return nullptr;
}
PyObject* ShapeFix_WirePy::fixClosed(PyObject *args)
{
double prec = -1.0;
if (!PyArg_ParseTuple(args, "|d", &prec))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixClosed(prec);
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixGaps3d(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixGaps3d();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixGaps2d(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixGaps2d();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixGap3d(PyObject *args)
{
int num;
PyObject* convert;
if (!PyArg_ParseTuple(args, "iO!", &num, &PyBool_Type, &convert))
return nullptr;
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixGap3d(num, PyObject_IsTrue(convert) ? Standard_True : Standard_False);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyObject* ShapeFix_WirePy::fixGap2d(PyObject *args)
{
int num;
PyObject* convert;
if (!PyArg_ParseTuple(args, "iO!", &num, &PyBool_Type, &convert))
return nullptr;
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixGap2d(num, PyObject_IsTrue(convert) ? Standard_True : Standard_False);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyObject* ShapeFix_WirePy::fixSeam(PyObject *args)
{
int num;
if (!PyArg_ParseTuple(args, "i", &num))
return nullptr;
try {
Standard_Boolean ok = getShapeFix_WirePtr()->FixSeam(num);
return Py::new_reference_to(Py::Boolean(ok));
}
catch (const Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return nullptr;
}
}
PyObject* ShapeFix_WirePy::fixShifted(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixShifted();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixNotchedEdges(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixNotchedEdges();
return Py::new_reference_to(Py::Boolean(ok));
}
PyObject* ShapeFix_WirePy::fixTails(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
Standard_Boolean ok = getShapeFix_WirePtr()->FixTails();
return Py::new_reference_to(Py::Boolean(ok));
}
Py::Boolean ShapeFix_WirePy::getModifyTopologyMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->ModifyTopologyMode());
}
void ShapeFix_WirePy::setModifyTopologyMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->ModifyTopologyMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getModifyGeometryMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->ModifyGeometryMode());
}
void ShapeFix_WirePy::setModifyGeometryMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->ModifyGeometryMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getModifyRemoveLoopMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->ModifyRemoveLoopMode());
}
void ShapeFix_WirePy::setModifyRemoveLoopMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->ModifyRemoveLoopMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getClosedWireMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->ClosedWireMode());
}
void ShapeFix_WirePy::setClosedWireMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->ClosedWireMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getPreferencePCurveMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->PreferencePCurveMode());
}
void ShapeFix_WirePy::setPreferencePCurveMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->PreferencePCurveMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixGapsByRangesMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixGapsByRangesMode());
}
void ShapeFix_WirePy::setFixGapsByRangesMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixGapsByRangesMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixReorderMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixReorderMode());
}
void ShapeFix_WirePy::setFixReorderMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixReorderMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixSmallMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixSmallMode());
}
void ShapeFix_WirePy::setFixSmallMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixSmallMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixConnectedMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixConnectedMode());
}
void ShapeFix_WirePy::setFixConnectedMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixConnectedMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixEdgeCurvesMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixEdgeCurvesMode());
}
void ShapeFix_WirePy::setFixEdgeCurvesMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixEdgeCurvesMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixDegeneratedMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixDegeneratedMode());
}
void ShapeFix_WirePy::setFixDegeneratedMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixDegeneratedMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixSelfIntersectionMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixSelfIntersectionMode());
}
void ShapeFix_WirePy::setFixSelfIntersectionMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixSelfIntersectionMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixLackingMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixLackingMode());
}
void ShapeFix_WirePy::setFixLackingMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixLackingMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixGaps3dMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixGaps3dMode());
}
void ShapeFix_WirePy::setFixGaps3dMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixGaps3dMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixGaps2dMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixGaps2dMode());
}
void ShapeFix_WirePy::setFixGaps2dMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixGaps2dMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixReversed2dMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixReversed2dMode());
}
void ShapeFix_WirePy::setFixReversed2dMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixReversed2dMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixRemovePCurveMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixRemovePCurveMode());
}
void ShapeFix_WirePy::setFixRemovePCurveMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixRemovePCurveMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixAddPCurveMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixAddPCurveMode());
}
void ShapeFix_WirePy::setFixAddPCurveMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixAddPCurveMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixRemoveCurve3dMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixRemoveCurve3dMode());
}
void ShapeFix_WirePy::setFixRemoveCurve3dMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixRemoveCurve3dMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixAddCurve3dMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixAddCurve3dMode());
}
void ShapeFix_WirePy::setFixAddCurve3dMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixAddCurve3dMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixSeamMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixSeamMode());
}
void ShapeFix_WirePy::setFixSeamMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixSeamMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixShiftedMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixShiftedMode());
}
void ShapeFix_WirePy::setFixShiftedMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixShiftedMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixSameParameterMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixSameParameterMode());
}
void ShapeFix_WirePy::setFixSameParameterMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixSameParameterMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixVertexToleranceMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixVertexToleranceMode());
}
void ShapeFix_WirePy::setFixVertexToleranceMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixVertexToleranceMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixNotchedEdgesMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixNotchedEdgesMode());
}
void ShapeFix_WirePy::setFixNotchedEdgesMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixNotchedEdgesMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixSelfIntersectingEdgeMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixSelfIntersectingEdgeMode());
}
void ShapeFix_WirePy::setFixSelfIntersectingEdgeMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixSelfIntersectingEdgeMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixIntersectingEdgesMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixIntersectingEdgesMode());
}
void ShapeFix_WirePy::setFixIntersectingEdgesMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixIntersectingEdgesMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixNonAdjacentIntersectingEdgesMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixNonAdjacentIntersectingEdgesMode());
}
void ShapeFix_WirePy::setFixNonAdjacentIntersectingEdgesMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixNonAdjacentIntersectingEdgesMode() = arg;
}
Py::Boolean ShapeFix_WirePy::getFixTailMode() const
{
return Py::Boolean(getShapeFix_WirePtr()->FixTailMode());
}
void ShapeFix_WirePy::setFixTailMode(Py::Boolean arg)
{
getShapeFix_WirePtr()->FixTailMode() = arg;
}
PyObject *ShapeFix_WirePy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
int ShapeFix_WirePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -503,3 +503,140 @@ class PartTestShapeFix(unittest.TestCase):
fix.FixOrientationMode = True
self.assertEqual(fix.FixOrientationMode, True)
def testShapeFix_Wire(self):
with self.assertRaises(TypeError):
Part.ShapeFix.Wire([])
surface = Part.Plane()
face = surface.toShape(-1, 1, -1, 1)
Part.ShapeFix.Wire(face.OuterWire, face, 1e-7)
fix = Part.ShapeFix.Wire()
fix.init(face.OuterWire, face, 1e-7)
fix.load(face.OuterWire)
fix.setSurface(surface)
fix.setSurface(surface, face.Placement)
fix.setFace(face)
fix.setMaxTailAngle(math.pi)
fix.setMaxTailWidth(10.0)
self.assertEqual(fix.isLoaded(), True)
self.assertEqual(fix.isReady(), True)
self.assertEqual(fix.numberOfEdges(), 4)
print (fix)
fix.clearModes()
fix.clearStatuses()
fix.wire()
fix.wireAPIMake()
fix.face()
fix.ModifyTopologyMode = True
self.assertEqual(fix.ModifyTopologyMode, True)
fix.ModifyGeometryMode = True
self.assertEqual(fix.ModifyGeometryMode, True)
fix.ModifyRemoveLoopMode = True
self.assertEqual(fix.ModifyRemoveLoopMode, True)
fix.ClosedWireMode = True
self.assertEqual(fix.ClosedWireMode, True)
fix.PreferencePCurveMode = True
self.assertEqual(fix.PreferencePCurveMode, True)
fix.FixGapsByRangesMode = True
self.assertEqual(fix.FixGapsByRangesMode, True)
fix.FixReorderMode = True
self.assertEqual(fix.FixReorderMode, True)
fix.FixSmallMode = True
self.assertEqual(fix.FixSmallMode, True)
fix.FixConnectedMode = True
self.assertEqual(fix.FixConnectedMode, True)
fix.FixEdgeCurvesMode = True
self.assertEqual(fix.FixEdgeCurvesMode, True)
fix.FixDegeneratedMode = True
self.assertEqual(fix.FixDegeneratedMode, True)
fix.FixSelfIntersectionMode = True
self.assertEqual(fix.FixSelfIntersectionMode, True)
fix.FixLackingMode = True
self.assertEqual(fix.FixLackingMode, True)
fix.FixGaps3dMode = True
self.assertEqual(fix.FixGaps3dMode, True)
fix.FixGaps2dMode = True
self.assertEqual(fix.FixGaps2dMode, True)
fix.FixReversed2dMode = True
self.assertEqual(fix.FixReversed2dMode, True)
fix.FixRemovePCurveMode = True
self.assertEqual(fix.FixRemovePCurveMode, True)
fix.FixAddPCurveMode = True
self.assertEqual(fix.FixAddPCurveMode, True)
fix.FixRemoveCurve3dMode = True
self.assertEqual(fix.FixRemoveCurve3dMode, True)
fix.FixAddCurve3dMode = True
self.assertEqual(fix.FixAddCurve3dMode, True)
fix.FixSeamMode = True
self.assertEqual(fix.FixSeamMode, True)
fix.FixShiftedMode = True
self.assertEqual(fix.FixShiftedMode, True)
fix.FixSameParameterMode = True
self.assertEqual(fix.FixSameParameterMode, True)
fix.FixVertexToleranceMode = True
self.assertEqual(fix.FixVertexToleranceMode, True)
fix.FixNotchedEdgesMode = True
self.assertEqual(fix.FixNotchedEdgesMode, True)
fix.FixSelfIntersectingEdgeMode = True
self.assertEqual(fix.FixSelfIntersectingEdgeMode, True)
fix.FixIntersectingEdgesMode = True
self.assertEqual(fix.FixIntersectingEdgesMode, True)
fix.FixNonAdjacentIntersectingEdgesMode = True
self.assertEqual(fix.FixNonAdjacentIntersectingEdgesMode, True)
fix.FixTailMode = True
self.assertEqual(fix.FixTailMode, True)
fix.perform()
fix.fixReorder()
fix.fixSmall(True)
fix.fixSmall(1, True, 1e-7)
fix.fixConnected()
fix.fixConnected(1, True)
fix.fixEdgeCurves()
fix.fixDegenerated()
fix.fixDegenerated(1)
fix.fixSelfIntersection()
fix.fixLacking()
fix.fixLacking(1, False)
fix.fixClosed()
fix.fixGaps3d()
fix.fixGaps2d()
fix.fixSeam(1)
fix.fixShifted()
fix.fixNotchedEdges()
fix.fixGap3d(1, False)
fix.fixGap2d(1, False)
fix.fixTails()