23
#include "PreCompiled.h"
26
# include <BRepOffsetAPI_MakeFilling.hxx>
27
# include <GeomAbs_Shape.hxx>
30
# include <TopoDS_Face.hxx>
33
#include <Base/PyWrapParseTupleAndKeywords.h>
34
#include <Base/VectorPy.h>
36
#include "BRepOffsetAPI_MakeFillingPy.h"
37
#include "BRepOffsetAPI_MakeFillingPy.cpp"
38
#include "TopoShapeEdgePy.h"
39
#include "TopoShapeFacePy.h"
75
PyObject *BRepOffsetAPI_MakeFillingPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
78
return new BRepOffsetAPI_MakeFillingPy(nullptr);
82
int BRepOffsetAPI_MakeFillingPy::PyInit(PyObject* args, PyObject* kwds)
89
double tol2d = 0.00001;
90
double tol3d = 0.0001;
93
PyObject* anisotropy = Py_False;
95
static const std::array<const char *, 11> keywords{"Degree", "NbPtsOnCur", "NbIter", "MaxDegree", "MaxSegments",
96
"Tol2d", "Tol3d", "TolAng", "TolCurv", "Anisotropy", nullptr};
97
if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "|iiiiiddddO!", keywords,
98
°ree, &nbPtsOnCur, &nbIter, &maxDeg, &maxSegments,
99
&tol2d, &tol3d, &tolAng, &tolCurv, &PyBool_Type, &anisotropy)) {
104
std::unique_ptr<BRepOffsetAPI_MakeFilling> ptr(new BRepOffsetAPI_MakeFilling(degree, nbPtsOnCur, nbIter,
105
Base::asBoolean(anisotropy),
106
tol2d, tol3d, tolAng, tolCurv, maxDeg, maxSegments));
109
setTwinPointer(ptr.release());
112
catch (const Standard_Failure& e) {
113
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
119
std::string BRepOffsetAPI_MakeFillingPy::representation() const
121
return {"<BRepOffsetAPI_MakeFilling object>"};
124
PyObject* BRepOffsetAPI_MakeFillingPy::setConstrParam(PyObject *args, PyObject *kwds)
126
double tol2d = 0.00001;
127
double tol3d = 0.0001;
128
double tolAng = 0.01;
129
double tolCurv = 0.1;
131
static const std::array<const char *, 5> keywords {"Tol2d", "Tol3d", "TolAng", "TolCurv", nullptr};
132
if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "|dddd", keywords,
133
&tol2d, &tol3d, &tolAng, &tolCurv)) {
138
getBRepOffsetAPI_MakeFillingPtr()->SetConstrParam(tol2d, tol3d, tolAng, tolCurv);
141
catch (const Standard_Failure& e) {
142
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
147
PyObject* BRepOffsetAPI_MakeFillingPy::setResolParam(PyObject *args, PyObject *kwds)
152
PyObject* anisotropy = Py_False;
154
static const std::array<const char *, 5> keywords {"Degree", "NbPtsOnCur", "NbIter", "Anisotropy", nullptr};
155
if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "|iiiO!", keywords,
156
°ree, &nbPtsOnCur, &nbIter, &PyBool_Type, &anisotropy)) {
161
getBRepOffsetAPI_MakeFillingPtr()->SetResolParam(degree, nbPtsOnCur, nbIter,
162
Base::asBoolean(anisotropy));
165
catch (const Standard_Failure& e) {
166
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
171
PyObject* BRepOffsetAPI_MakeFillingPy::setApproxParam(PyObject *args, PyObject *kwds)
176
static const std::array<const char *, 3> keywords {"MaxDegree", "MaxSegments", nullptr};
177
if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "|ii", keywords,
178
&maxDeg, &maxSegments)) {
183
getBRepOffsetAPI_MakeFillingPtr()->SetApproxParam(maxDeg, maxSegments);
186
catch (const Standard_Failure& e) {
187
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
192
PyObject* BRepOffsetAPI_MakeFillingPy::loadInitSurface(PyObject *args)
195
if (!PyArg_ParseTuple(args, "O!", &(TopoShapeFacePy::Type), &shape))
198
TopoDS_Face face = TopoDS::Face(static_cast<TopoShapeFacePy*>(shape)->getTopoShapePtr()->getShape());
200
PyErr_SetString(PyExc_ReferenceError, "No valid face");
205
getBRepOffsetAPI_MakeFillingPtr()->LoadInitSurface(face);
208
catch (const Standard_Failure& e) {
209
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
214
PyObject* BRepOffsetAPI_MakeFillingPy::add(PyObject *args, PyObject *kwds)
218
static const std::array<const char *, 2> keywords_pnt {"Point", nullptr};
219
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!", keywords_pnt,
220
&Base::VectorPy::Type, &pnt)) {
222
Base::Vector3d vec = static_cast<Base::VectorPy*>(pnt)->value();
223
getBRepOffsetAPI_MakeFillingPtr()->Add(gp_Pnt(vec.x, vec.y, vec.z));
226
catch (const Standard_Failure& e) {
227
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
235
static const std::array<const char *, 3> keywords_sup_ord {"Support", "Order", nullptr};
237
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!i", keywords_sup_ord,
238
&TopoShapeFacePy::Type, &support, &order)) {
240
TopoDS_Face face = TopoDS::Face(static_cast<TopoShapeFacePy*>(support)->getTopoShapePtr()->getShape());
242
PyErr_SetString(PyExc_ReferenceError, "No valid face");
246
if (order < 0 || order > 2) {
247
PyErr_SetString(PyExc_ReferenceError, "Order must be in the [0, 2] with 0 -> C0, 1 -> G1, 2 -> G2");
251
getBRepOffsetAPI_MakeFillingPtr()->Add(face, static_cast<GeomAbs_Shape>(order));
254
catch (const Standard_Failure& e) {
255
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
262
PyObject* isbound = Py_True;
263
static const std::array<const char *, 4> keywords_const {"Constraint", "Order", "IsBound", nullptr};
265
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!i|O!", keywords_const,
266
&TopoShapeEdgePy::Type, &constr,
267
&order, &PyBool_Type, isbound)) {
269
TopoDS_Edge edge = TopoDS::Edge(static_cast<TopoShapeEdgePy*>(constr)->getTopoShapePtr()->getShape());
271
PyErr_SetString(PyExc_ReferenceError, "No valid constraint edge");
275
if (order < 0 || order > 2) {
276
PyErr_SetString(PyExc_ReferenceError, "Order must be in the [0, 2] with 0 -> C0, 1 -> G1, 2 -> G2");
280
getBRepOffsetAPI_MakeFillingPtr()->Add(edge, static_cast<GeomAbs_Shape>(order),
281
Base::asBoolean(isbound));
284
catch (const Standard_Failure& e) {
285
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
291
static const std::array<const char *, 5> keywords_const_sup {"Constraint", "Support", "Order", "IsBound", nullptr};
293
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!O!i|O!", keywords_const_sup,
294
&TopoShapeEdgePy::Type, &constr,
295
&TopoShapeFacePy::Type, &support,
296
&order, &PyBool_Type, isbound)) {
298
TopoDS_Edge edge = TopoDS::Edge(static_cast<TopoShapeEdgePy*>(constr)->getTopoShapePtr()->getShape());
300
PyErr_SetString(PyExc_ReferenceError, "No valid constraint edge");
303
TopoDS_Face face = TopoDS::Face(static_cast<TopoShapeFacePy*>(support)->getTopoShapePtr()->getShape());
305
PyErr_SetString(PyExc_ReferenceError, "No valid face");
309
if (order < 0 || order > 2) {
310
PyErr_SetString(PyExc_ReferenceError, "Order must be in the [0, 2] with 0 -> C0, 1 -> G1, 2 -> G2");
314
getBRepOffsetAPI_MakeFillingPtr()->Add(edge, face, static_cast<GeomAbs_Shape>(order),
315
Base::asBoolean(isbound));
318
catch (const Standard_Failure& e) {
319
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
326
static const std::array<const char *, 5> keywords_uv {"U", "V", "Support", "Order", nullptr};
328
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "ddO!i", keywords_uv,
329
&u, &v, &TopoShapeFacePy::Type, &support, &order)) {
331
TopoDS_Face face = TopoDS::Face(static_cast<TopoShapeFacePy*>(support)->getTopoShapePtr()->getShape());
333
PyErr_SetString(PyExc_ReferenceError, "No valid face");
337
if (order < 0 || order > 2) {
338
PyErr_SetString(PyExc_ReferenceError, "Order must be in the [0, 2] with 0 -> C0, 1 -> G1, 2 -> G2");
342
getBRepOffsetAPI_MakeFillingPtr()->Add(u, v, face, static_cast<GeomAbs_Shape>(order));
345
catch (const Standard_Failure& e) {
346
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
351
PyErr_SetString(PyExc_TypeError, "wrong argument");
355
PyObject* BRepOffsetAPI_MakeFillingPy::build(PyObject *args)
357
if (!PyArg_ParseTuple(args, ""))
361
getBRepOffsetAPI_MakeFillingPtr()->Build();
364
catch (const Standard_Failure& e) {
365
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
370
PyObject* BRepOffsetAPI_MakeFillingPy::isDone(PyObject *args)
372
if (!PyArg_ParseTuple(args, ""))
376
Standard_Boolean ok = getBRepOffsetAPI_MakeFillingPtr()->IsDone();
377
return Py_BuildValue("O", (ok ? Py_True : Py_False));
379
catch (const Standard_Failure& e) {
380
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
385
PyObject* BRepOffsetAPI_MakeFillingPy::G0Error(PyObject *args)
388
if (!PyArg_ParseTuple(args, "|i", &index))
392
Standard_Real v = index < 1 ? getBRepOffsetAPI_MakeFillingPtr()->G0Error()
393
: getBRepOffsetAPI_MakeFillingPtr()->G0Error(index);
394
return PyFloat_FromDouble(v);
396
catch (const Standard_Failure& e) {
397
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
402
PyObject* BRepOffsetAPI_MakeFillingPy::G1Error(PyObject *args)
405
if (!PyArg_ParseTuple(args, "|i", &index))
409
Standard_Real v = index < 1 ? getBRepOffsetAPI_MakeFillingPtr()->G1Error()
410
: getBRepOffsetAPI_MakeFillingPtr()->G1Error(index);
411
return PyFloat_FromDouble(v);
413
catch (const Standard_Failure& e) {
414
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
419
PyObject* BRepOffsetAPI_MakeFillingPy::G2Error(PyObject *args)
422
if (!PyArg_ParseTuple(args, "|i", &index))
426
Standard_Real v = index < 1 ? getBRepOffsetAPI_MakeFillingPtr()->G2Error()
427
: getBRepOffsetAPI_MakeFillingPtr()->G2Error(index);
428
return PyFloat_FromDouble(v);
430
catch (const Standard_Failure& e) {
431
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
436
PyObject* BRepOffsetAPI_MakeFillingPy::shape(PyObject *args)
438
if (!PyArg_ParseTuple(args, ""))
442
const TopoDS_Shape& shape = this->getBRepOffsetAPI_MakeFillingPtr()->Shape();
443
return new TopoShapePy(new TopoShape(shape));
445
catch (Standard_Failure& e) {
446
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
451
PyObject *BRepOffsetAPI_MakeFillingPy::getCustomAttributes(const char* ) const
456
int BRepOffsetAPI_MakeFillingPy::setCustomAttributes(const char* , PyObject* )