diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 48eba5343..875f04cd4 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -74,6 +74,7 @@ #include "SurfaceOfExtrusionPy.h" #include "SurfaceOfRevolutionPy.h" #include "ToroidPy.h" +#include "BRepOffsetAPI_MakePipeShellPy.h" #include "PartFeaturePy.h" #include "PropertyGeometryList.h" @@ -125,6 +126,11 @@ void PartExport initPart() Base::Interpreter().addType(&Part::PartFeaturePy ::Type,partModule,"Feature"); + PyObject* brepModule = Py_InitModule3("BRepOffsetAPI", 0, "BrepOffsetAPI"); + Py_INCREF(brepModule); + PyModule_AddObject(partModule, "BRepOffsetAPI", brepModule); + Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepModule,"MakePipeShell"); + Part::TopoShape ::init(); Part::PropertyPartShape ::init(); Part::PropertyGeometryList ::init(); diff --git a/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.xml b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.xml new file mode 100644 index 000000000..1f375a437 --- /dev/null +++ b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.xml @@ -0,0 +1,107 @@ + + + + + + Describes a portion of a circle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0: BRepBuilderAPI_Transformed + 1: BRepBuilderAPI_RightCorner + 2: BRepBuilderAPI_RoundCorner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp new file mode 100644 index 000000000..8e587c860 --- /dev/null +++ b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp @@ -0,0 +1,248 @@ +/*************************************************************************** + * Copyright (c) 2012 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 +# include +# include +# include +#endif + +#include "TopoShapePy.h" +#include "BRepOffsetAPI_MakePipeShellPy.h" +#include "BRepOffsetAPI_MakePipeShellPy.cpp" +#include "Tools.h" +#include +#include + +using namespace Part; + +PyObject *BRepOffsetAPI_MakePipeShellPy::PyMake(struct _typeobject *, PyObject *args, PyObject *) // Python wrapper +{ + // create a new instance of BRepOffsetAPI_MakePipeShellPy and the Twin object + PyObject* obj; + if (!PyArg_ParseTuple(args, "O!",&(TopoShapePy::Type),&obj)) + return 0; + const TopoDS_Shape& wire = static_cast(obj)->getTopoShapePtr()->_Shape; + if (!wire.IsNull() && wire.ShapeType() == TopAbs_WIRE) { + return new BRepOffsetAPI_MakePipeShellPy(new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(wire))); + } + + PyErr_SetString(PyExc_Exception, "A valid wire is needed as argument"); + return 0; +} + +// constructor method +int BRepOffsetAPI_MakePipeShellPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) +{ + return 0; +} + +// returns a string which represents the object e.g. when printed in python +std::string BRepOffsetAPI_MakePipeShellPy::representation(void) const +{ + return std::string(""); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setFrenetMode(PyObject *args) +{ + PyObject *obj; + if (!PyArg_ParseTuple(args, "O!",&PyBool_Type,&obj)) + return 0; + this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(obj==Py_True); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setTrihedronMode(PyObject *args) +{ + PyObject *pnt, *dir; + if (!PyArg_ParseTuple(args, "O!O!",&Base::VectorPy::Type,&pnt + ,&Base::VectorPy::Type,&dir)) + return 0; + gp_Pnt p = Base::convertTo(Py::Vector(pnt,false).toVector()); + gp_Dir d = Base::convertTo(Py::Vector(dir,false).toVector()); + this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(gp_Ax2(p,d)); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setBiNormalMode(PyObject *args) +{ + PyObject *dir; + if (!PyArg_ParseTuple(args, "O!",&Base::VectorPy::Type,&dir)) + return 0; + gp_Dir d = Base::convertTo(Py::Vector(dir,false).toVector()); + this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(d); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setSpineSupport(PyObject *args) +{ + PyObject *shape; + if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape)) + return 0; + const TopoDS_Shape& s = static_cast(shape)->getTopoShapePtr()->_Shape; + Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(s); + return Py::new_reference_to(Py::Boolean(ok ? true : false)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args) +{ + PyObject *spine, *curv, *keep; + if (!PyArg_ParseTuple(args, "O!O!O!",&Part::TopoShapePy::Type,&spine + ,&PyBool_Type,&curv + ,&PyBool_Type,&keep)) + return 0; + const TopoDS_Shape& s = static_cast(spine)->getTopoShapePtr()->_Shape; + if (s.IsNull() || s.ShapeType() != TopAbs_WIRE) { + PyErr_SetString(PyExc_TypeError, "spine is not a wire"); + return 0; + } + this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(TopoDS::Wire(s), curv==Py_True, keep==Py_True); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args) +{ + PyObject *prof, *curv=0, *keep=0; + if (!PyArg_ParseTuple(args, "O!|O!O!",&Part::TopoShapePy::Type,&prof + ,&PyBool_Type,&curv + ,&PyBool_Type,&keep)) + return 0; + const TopoDS_Shape& s = static_cast(prof)->getTopoShapePtr()->_Shape; + this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, curv==Py_True, keep==Py_True); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::remove(PyObject *args) +{ + PyObject *prof; + if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&prof)) + return 0; + const TopoDS_Shape& s = static_cast(prof)->getTopoShapePtr()->_Shape; + this->getBRepOffsetAPI_MakePipeShellPtr()->Delete(s); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::isReady(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->IsReady(); + return Py::new_reference_to(Py::Boolean(ok ? true : false)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::getStatus(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + Standard_Integer val = this->getBRepOffsetAPI_MakePipeShellPtr()->GetStatus(); + return Py::new_reference_to(Py::Int(val)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::makeSolid(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->MakeSolid(); + return Py::new_reference_to(Py::Boolean(ok ? true : false)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::build(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + this->getBRepOffsetAPI_MakePipeShellPtr()->Build(); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::shape(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + const TopoDS_Shape& shape = this->getBRepOffsetAPI_MakePipeShellPtr()->Shape(); + return new TopoShapePy(new TopoShape(shape)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::firstShape(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->FirstShape(); + return new TopoShapePy(new TopoShape(shape)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::lastShape(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return 0; + TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->LastShape(); + return new TopoShapePy(new TopoShape(shape)); +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::generated(PyObject *args) +{ + //PyObject *shape; + //if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape)) + // return 0; + //const TopoDS_Shape& s = static_cast(shape)->getTopoShapePtr()->_Shape; + //const TopTools_ListOfShape& list = this->getBRepOffsetAPI_MakePipeShellPtr()->Generated(s); + + //Py::List shapes; + //for (int i=1; i<=list.Extent(); i++) { + // const TopoDS_Shape& s = list. + //} + //return Py::new_reference_to(shapes); + PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); + return 0; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setTolerance(PyObject *args) +{ + double tol3d, boundTol, tolAngular; + if (!PyArg_ParseTuple(args, "ddd",&tol3d,&boundTol,&tolAngular)) + return 0; + this->getBRepOffsetAPI_MakePipeShellPtr()->SetTolerance(tol3d, boundTol, tolAngular); + Py_Return; +} + +PyObject* BRepOffsetAPI_MakePipeShellPy::setTransitionMode(PyObject *args) +{ + int mode; + if (!PyArg_ParseTuple(args, "i",&mode)) + return 0; + this->getBRepOffsetAPI_MakePipeShellPtr()->SetTransitionMode(BRepBuilderAPI_TransitionMode(mode)); + Py_Return; +} + +PyObject *BRepOffsetAPI_MakePipeShellPy::getCustomAttributes(const char* attr) const +{ + return 0; +} + +int BRepOffsetAPI_MakePipeShellPy::setCustomAttributes(const char* attr, PyObject *obj) +{ + return 0; +} diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt index bd0cb791a..20a33407b 100644 --- a/src/Mod/Part/App/CMakeLists.txt +++ b/src/Mod/Part/App/CMakeLists.txt @@ -61,6 +61,7 @@ generate_from_xml(TopoShapeShellPy) generate_from_xml(TopoShapeSolidPy) generate_from_xml(TopoShapeVertexPy) generate_from_xml(TopoShapeWirePy) +generate_from_xml(BRepOffsetAPI_MakePipeShellPy) SET(Features_SRCS FeaturePartBoolean.cpp @@ -203,6 +204,8 @@ SET(Python_SRCS TopoShapeVertexPyImp.cpp TopoShapeWirePy.xml TopoShapeWirePyImp.cpp + BRepOffsetAPI_MakePipeShellPy.xml + BRepOffsetAPI_MakePipeShellPyImp.cpp ) SOURCE_GROUP("Python" FILES ${Python_SRCS}) diff --git a/src/Mod/Part/App/Makefile.am b/src/Mod/Part/App/Makefile.am index 91c711564..778427814 100644 --- a/src/Mod/Part/App/Makefile.am +++ b/src/Mod/Part/App/Makefile.am @@ -4,6 +4,7 @@ lib_LTLIBRARIES=libPart.la Part.la BUILT_SOURCES=\ ArcPy.cpp \ ArcOfCirclePy.cpp \ + BRepOffsetAPI_MakePipeShellPy.cpp \ CirclePy.cpp \ EllipsePy.cpp \ HyperbolaPy.cpp \ @@ -42,6 +43,7 @@ BUILT_SOURCES=\ libPart_la_BUILT=\ ArcPy.h \ ArcOfCirclePy.h \ + BRepOffsetAPI_MakePipeShellPy.h \ CirclePy.h \ EllipsePy.h \ HyperbolaPy.h \ @@ -81,6 +83,7 @@ libPart_la_SOURCES=\ AppPartPy.cpp \ ArcPyImp.cpp \ ArcOfCirclePyImp.cpp \ + BRepOffsetAPI_MakePipeShellPyImp.cpp \ CirclePyImp.cpp \ CrossSection.cpp \ EllipsePyImp.cpp \ @@ -260,6 +263,7 @@ EXTRA_DIST = \ OpenCascadeAll.h \ ArcPy.xml \ ArcOfCirclePy.xml \ + BRepOffsetAPI_MakePipeShellPy.xml \ CirclePy.xml \ EllipsePy.xml \ HyperbolaPy.xml \