0000646: Expose BRepOffsetAPI_MakePipeShell to python
This commit is contained in:
parent
7b2e15bedf
commit
c9fa928b80
|
@ -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();
|
||||
|
|
107
src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.xml
Normal file
107
src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.xml
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?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="BRepOffsetAPI_MakePipeShellPy"
|
||||
Twin="BRepOffsetAPI_MakePipeShell"
|
||||
TwinPointer="BRepOffsetAPI_MakePipeShell"
|
||||
Include="BRepOffsetAPI_MakePipeShell.hxx"
|
||||
Namespace="Part"
|
||||
FatherInclude="Base/PyObjectBase.h"
|
||||
FatherNamespace="Base"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
|
||||
<UserDocu>Describes a portion of a circle</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="setFrenetMode">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setTrihedronMode">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setBiNormalMode">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setSpineSupport">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setAuxiliarySpine">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="add">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="remove">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="isReady">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getStatus">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeSolid">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setTolerance">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setTransitionMode">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
0: BRepBuilderAPI_Transformed
|
||||
1: BRepBuilderAPI_RightCorner
|
||||
2: BRepBuilderAPI_RoundCorner
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="firstShape">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="lastShape">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="build">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="shape">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="generated">
|
||||
<Documentation>
|
||||
<UserDocu></UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
248
src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp
Normal file
248
src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp
Normal file
|
@ -0,0 +1,248 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 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_Ax2.hxx>
|
||||
# include <gp_Dir.hxx>
|
||||
# include <gp_Pnt.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <BRepOffsetAPI_MakePipeShell.hxx>
|
||||
#endif
|
||||
|
||||
#include "TopoShapePy.h"
|
||||
#include "BRepOffsetAPI_MakePipeShellPy.h"
|
||||
#include "BRepOffsetAPI_MakePipeShellPy.cpp"
|
||||
#include "Tools.h"
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
|
||||
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<TopoShapePy*>(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("<BRepOffsetAPI_MakePipeShell object>");
|
||||
}
|
||||
|
||||
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<gp_Pnt>(Py::Vector(pnt,false).toVector());
|
||||
gp_Dir d = Base::convertTo<gp_Dir>(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<gp_Dir>(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<Part::TopoShapePy*>(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<Part::TopoShapePy*>(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<Part::TopoShapePy*>(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<Part::TopoShapePy*>(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<Part::TopoShapePy*>(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;
|
||||
}
|
|
@ -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})
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in New Issue
Block a user