diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index fe4b65e49c..13346c376a 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -112,6 +112,7 @@ #include #include #include +#include #include #include "Mod/Part/App/SpherePy.h" #include "Mod/Part/App/SurfaceOfExtrusionPy.h" @@ -358,6 +359,7 @@ PyMOD_INIT_FUNC(Part) Base::Interpreter().addType(&Part::ShapeFix_ShellPy::Type, shapeFix, "Shell"); Base::Interpreter().addType(&Part::ShapeFix_SolidPy::Type, shapeFix, "Solid"); Base::Interpreter().addType(&Part::ShapeFix_WirePy::Type, shapeFix, "Wire"); + Base::Interpreter().addType(&Part::ShapeFix_WireVertexPy::Type, shapeFix, "WireVertex"); 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"); diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt index a254d2d04f..829ca2a85e 100644 --- a/src/Mod/Part/App/CMakeLists.txt +++ b/src/Mod/Part/App/CMakeLists.txt @@ -143,6 +143,7 @@ generate_from_xml(ShapeFix/ShapeFix_ShapePy) generate_from_xml(ShapeFix/ShapeFix_ShellPy) generate_from_xml(ShapeFix/ShapeFix_SolidPy) generate_from_xml(ShapeFix/ShapeFix_WirePy) +generate_from_xml(ShapeFix/ShapeFix_WireVertexPy) generate_from_xml(ShapeFix/ShapeFix_EdgeConnectPy) generate_from_xml(ShapeFix/ShapeFix_FaceConnectPy) generate_from_xml(ShapeFix/ShapeFix_FreeBoundsPy) @@ -447,6 +448,8 @@ SET(ShapeFixPy_SRCS ShapeFix/ShapeFix_SolidPyImp.cpp ShapeFix/ShapeFix_WirePy.xml ShapeFix/ShapeFix_WirePyImp.cpp + ShapeFix/ShapeFix_WireVertexPy.xml + ShapeFix/ShapeFix_WireVertexPyImp.cpp ShapeFix/ShapeFix_EdgeConnectPy.xml ShapeFix/ShapeFix_EdgeConnectPyImp.cpp ShapeFix/ShapeFix_FaceConnectPy.xml diff --git a/src/Mod/Part/App/ShapeFix/ShapeFix_WireVertexPy.xml b/src/Mod/Part/App/ShapeFix/ShapeFix_WireVertexPy.xml new file mode 100644 index 0000000000..c785e3f2d8 --- /dev/null +++ b/src/Mod/Part/App/ShapeFix/ShapeFix_WireVertexPy.xml @@ -0,0 +1,42 @@ + + + + + + Fixing disconnected edges in the wire + + + + Loads the wire, ininializes internal analyzer with the given precision + + + + + Returns resulting wire + + + + + Returns the count of fixed vertices, 0 if none + + + + + Fixes all statuses except Disjoined, i.e. the cases in which a +common value has been set, with or without changing parameters +Returns the count of fixed vertices, 0 if none + + + + diff --git a/src/Mod/Part/App/ShapeFix/ShapeFix_WireVertexPyImp.cpp b/src/Mod/Part/App/ShapeFix/ShapeFix_WireVertexPyImp.cpp new file mode 100644 index 0000000000..1690a30a48 --- /dev/null +++ b/src/Mod/Part/App/ShapeFix/ShapeFix_WireVertexPyImp.cpp @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright (c) 2022 Werner Mayer * + * * + * 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 +# include +# include +#endif + +#include "ShapeFix/ShapeFix_WireVertexPy.h" +#include "ShapeFix/ShapeFix_WireVertexPy.cpp" +#include "TopoShapeWirePy.h" + +using namespace Part; + +// returns a string which represents the object e.g. when printed in python +std::string ShapeFix_WireVertexPy::representation() const +{ + return ""; +} + +PyObject *ShapeFix_WireVertexPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper +{ + return new ShapeFix_WireVertexPy(new ShapeFix_WireVertex); +} + +// constructor method +int ShapeFix_WireVertexPy::PyInit(PyObject* args, PyObject* /*kwds*/) +{ + if (!PyArg_ParseTuple(args, "")) + return -1; + + return 0; +} + +PyObject* ShapeFix_WireVertexPy::init(PyObject *args) +{ + PyObject* shape; + double prec; + if (!PyArg_ParseTuple(args, "O!d", &TopoShapeWirePy::Type, &shape, &prec)) + return nullptr; + + TopoDS_Shape sh = static_cast(shape)->getTopoShapePtr()->getShape(); + getShapeFix_WireVertexPtr()->Init(TopoDS::Wire(sh), prec); + Py_Return; +} + +PyObject* ShapeFix_WireVertexPy::wire(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + TopoShape w = getShapeFix_WireVertexPtr()->Wire(); + return w.getPyObject(); +} + +PyObject* ShapeFix_WireVertexPy::fixSame(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + int num = getShapeFix_WireVertexPtr()->FixSame(); + return Py::new_reference_to(Py::Long(num)); +} + +PyObject* ShapeFix_WireVertexPy::fix(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + int num = getShapeFix_WireVertexPtr()->Fix(); + return Py::new_reference_to(Py::Long(num)); +} + +PyObject *ShapeFix_WireVertexPy::getCustomAttributes(const char* /*attr*/) const +{ + return nullptr; +} + +int ShapeFix_WireVertexPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) +{ + return 0; +}