23
#include "PreCompiled.h"
25
# include <BRepOffsetAPI_MakePipeShell.hxx>
29
# include <Standard_Version.hxx>
31
# include <TopTools_ListIteratorOfListOfShape.hxx>
34
#include <Base/GeometryPyCXX.h>
35
#include <Base/PyWrapParseTupleAndKeywords.h>
36
#include <Base/VectorPy.h>
38
#include "BRepOffsetAPI_MakePipeShellPy.h"
39
#include "BRepOffsetAPI_MakePipeShellPy.cpp"
42
#include "TopoShapePy.h"
43
#include "TopoShapeVertexPy.h"
48
PyObject *BRepOffsetAPI_MakePipeShellPy::PyMake(struct _typeobject *, PyObject *args, PyObject *)
52
if (!PyArg_ParseTuple(args, "O!",&(TopoShapePy::Type),&obj))
54
const TopoDS_Shape& wire = static_cast<TopoShapePy*>(obj)->getTopoShapePtr()->getShape();
55
if (!wire.IsNull() && wire.ShapeType() == TopAbs_WIRE) {
56
return new BRepOffsetAPI_MakePipeShellPy(new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(wire)));
59
PyErr_SetString(PartExceptionOCCError, "A valid wire is needed as argument");
64
int BRepOffsetAPI_MakePipeShellPy::PyInit(PyObject* , PyObject* )
70
std::string BRepOffsetAPI_MakePipeShellPy::representation() const
72
return {"<BRepOffsetAPI_MakePipeShell object>"};
75
PyObject* BRepOffsetAPI_MakePipeShellPy::setFrenetMode(PyObject *args)
78
if (!PyArg_ParseTuple(args, "O!",&PyBool_Type,&obj))
82
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(Base::asBoolean(obj));
85
catch (Standard_Failure& e) {
86
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
91
PyObject* BRepOffsetAPI_MakePipeShellPy::setTrihedronMode(PyObject *args)
94
if (!PyArg_ParseTuple(args, "O!O!",&Base::VectorPy::Type,&pnt
95
,&Base::VectorPy::Type,&dir))
99
gp_Pnt p = Base::convertTo<gp_Pnt>(Py::Vector(pnt,false).toVector());
100
gp_Dir d = Base::convertTo<gp_Dir>(Py::Vector(dir,false).toVector());
101
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(gp_Ax2(p,d));
104
catch (Standard_Failure& e) {
105
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
110
PyObject* BRepOffsetAPI_MakePipeShellPy::setBiNormalMode(PyObject *args)
113
if (!PyArg_ParseTuple(args, "O!",&Base::VectorPy::Type,&dir))
117
gp_Dir d = Base::convertTo<gp_Dir>(Py::Vector(dir,false).toVector());
118
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(d);
121
catch (Standard_Failure& e) {
122
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
127
PyObject* BRepOffsetAPI_MakePipeShellPy::setSpineSupport(PyObject *args)
130
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape))
134
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
135
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(s);
136
return Py::new_reference_to(Py::Boolean(ok ? true : false));
138
catch (Standard_Failure& e) {
139
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
144
PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args)
146
PyObject *spine, *curv, *keep;
147
if (!PyArg_ParseTuple(args, "O!O!O!",&Part::TopoShapePy::Type,&spine
149
,&PyLong_Type,&keep))
153
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(spine)->getTopoShapePtr()->getShape();
154
if (s.IsNull() || s.ShapeType() != TopAbs_WIRE) {
155
PyErr_SetString(PyExc_TypeError, "spine is not a wire");
159
BRepFill_TypeOfContact typeOfCantact;
160
switch (PyLong_AsLong(keep)) {
162
typeOfCantact = BRepFill_Contact;
165
typeOfCantact = BRepFill_ContactOnBorder;
168
typeOfCantact = BRepFill_NoContact;
171
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(
173
Base::asBoolean(curv),
177
catch (Standard_Failure& e) {
178
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
183
PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args, PyObject *kwds)
185
PyObject *prof, *curv=Py_False, *keep=Py_False;
186
static const std::array<const char *, 4> keywords_pro{"Profile", "WithContact", "WithCorrection", nullptr};
187
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!|O!O!", keywords_pro, &Part::TopoShapePy::Type, &prof,
188
&PyBool_Type, &curv, &PyBool_Type, &keep)) {
190
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
191
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, Base::asBoolean(curv), Base::asBoolean(keep));
194
catch (Standard_Failure& e) {
195
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
202
static const std::array<const char *, 5> keywords_loc{"Profile", "Location", "WithContact", "WithCorrection",
204
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!O!|O!O!", keywords_loc, &Part::TopoShapePy::Type, &prof,
205
&Part::TopoShapeVertexPy::Type, &loc, &PyBool_Type, &curv, &PyBool_Type,
208
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
209
const TopoDS_Vertex& v = TopoDS::Vertex(static_cast<Part::TopoShapePy*>(loc)->getTopoShapePtr()->getShape());
210
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, v, Base::asBoolean(curv), Base::asBoolean(keep));
213
catch (Standard_Failure& e) {
214
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
219
PyErr_SetString(PyExc_TypeError, "Wrong arguments:\n"
220
"add(Profile, WithContact=False, WithCorrection=False)\n"
221
"add(Profile, Location, WithContact=False, WithCorrection=False)"
226
PyObject* BRepOffsetAPI_MakePipeShellPy::remove(PyObject *args)
229
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&prof))
233
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
234
this->getBRepOffsetAPI_MakePipeShellPtr()->Delete(s);
237
catch (Standard_Failure& e) {
238
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
243
PyObject* BRepOffsetAPI_MakePipeShellPy::isReady(PyObject *args)
245
if (!PyArg_ParseTuple(args, ""))
249
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->IsReady();
250
return Py::new_reference_to(Py::Boolean(ok ? true : false));
252
catch (Standard_Failure& e) {
253
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
258
PyObject* BRepOffsetAPI_MakePipeShellPy::getStatus(PyObject *args)
260
if (!PyArg_ParseTuple(args, ""))
264
Standard_Integer val = this->getBRepOffsetAPI_MakePipeShellPtr()->GetStatus();
265
return Py::new_reference_to(Py::Long(val));
267
catch (Standard_Failure& e) {
268
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
273
PyObject* BRepOffsetAPI_MakePipeShellPy::makeSolid(PyObject *args)
275
if (!PyArg_ParseTuple(args, ""))
279
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->MakeSolid();
280
return Py::new_reference_to(Py::Boolean(ok ? true : false));
282
catch (Standard_Failure& e) {
283
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
288
PyObject* BRepOffsetAPI_MakePipeShellPy::build(PyObject *args)
290
if (!PyArg_ParseTuple(args, ""))
294
this->getBRepOffsetAPI_MakePipeShellPtr()->Build();
297
catch (Standard_Failure& e) {
298
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
303
PyObject* BRepOffsetAPI_MakePipeShellPy::shape(PyObject *args)
305
if (!PyArg_ParseTuple(args, ""))
309
const TopoDS_Shape& shape = this->getBRepOffsetAPI_MakePipeShellPtr()->Shape();
310
return new TopoShapePy(new TopoShape(shape));
312
catch (Standard_Failure& e) {
313
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
318
PyObject* BRepOffsetAPI_MakePipeShellPy::firstShape(PyObject *args)
320
if (!PyArg_ParseTuple(args, ""))
324
TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->FirstShape();
325
return new TopoShapePy(new TopoShape(shape));
327
catch (Standard_Failure& e) {
328
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
333
PyObject* BRepOffsetAPI_MakePipeShellPy::lastShape(PyObject *args)
335
if (!PyArg_ParseTuple(args, ""))
339
TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->LastShape();
340
return new TopoShapePy(new TopoShape(shape));
342
catch (Standard_Failure& e) {
343
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
348
PyObject* BRepOffsetAPI_MakePipeShellPy::generated(PyObject *args)
351
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape))
355
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
356
const TopTools_ListOfShape& list = this->getBRepOffsetAPI_MakePipeShellPtr()->Generated(s);
359
TopTools_ListIteratorOfListOfShape it;
360
for (it.Initialize(list); it.More(); it.Next()) {
361
const TopoDS_Shape& s = it.Value();
362
shapes.append(Py::asObject(new TopoShapePy(new TopoShape(s))));
364
return Py::new_reference_to(shapes);
366
catch (Standard_Failure& e) {
367
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
372
PyObject* BRepOffsetAPI_MakePipeShellPy::setTolerance(PyObject *args)
374
double tol3d, boundTol, tolAngular;
375
if (!PyArg_ParseTuple(args, "ddd",&tol3d,&boundTol,&tolAngular))
379
this->getBRepOffsetAPI_MakePipeShellPtr()->SetTolerance(tol3d, boundTol, tolAngular);
382
catch (Standard_Failure& e) {
383
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
388
PyObject* BRepOffsetAPI_MakePipeShellPy::setTransitionMode(PyObject *args)
391
if (!PyArg_ParseTuple(args, "i",&mode))
395
this->getBRepOffsetAPI_MakePipeShellPtr()->SetTransitionMode(BRepBuilderAPI_TransitionMode(mode));
398
catch (Standard_Failure& e) {
399
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
404
PyObject* BRepOffsetAPI_MakePipeShellPy::setMaxDegree(PyObject *args)
407
if (!PyArg_ParseTuple(args, "i",°ree))
411
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMaxDegree(degree);
414
catch (Standard_Failure& e) {
415
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
420
PyObject* BRepOffsetAPI_MakePipeShellPy::setMaxSegments(PyObject *args)
423
if (!PyArg_ParseTuple(args, "i",&nbseg))
427
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMaxSegments(nbseg);
430
catch (Standard_Failure& e) {
431
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
436
PyObject* BRepOffsetAPI_MakePipeShellPy::setForceApproxC1(PyObject *args)
439
if (!PyArg_ParseTuple(args, "O!",&PyBool_Type,&obj))
443
this->getBRepOffsetAPI_MakePipeShellPtr()->SetForceApproxC1(Base::asBoolean(obj));
446
catch (Standard_Failure& e) {
447
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
453
PyObject* BRepOffsetAPI_MakePipeShellPy::simulate(PyObject *args)
456
if (!PyArg_ParseTuple(args, "i",&nbsec))
460
TopTools_ListOfShape list;
461
this->getBRepOffsetAPI_MakePipeShellPtr()->Simulate(nbsec, list);
464
TopTools_ListIteratorOfListOfShape it;
465
for (it.Initialize(list); it.More(); it.Next()) {
466
const TopoDS_Shape& s = it.Value();
467
shapes.append(Py::asObject(new TopoShapePy(new TopoShape(s))));
469
return Py::new_reference_to(shapes);
471
catch (Standard_Failure& e) {
472
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
478
PyObject *BRepOffsetAPI_MakePipeShellPy::getCustomAttributes(const char* ) const
483
int BRepOffsetAPI_MakePipeShellPy::setCustomAttributes(const char* , PyObject *)