23
#include "PreCompiled.h"
25
# include <Standard_Failure.hxx>
27
# include <TopoDS_Edge.hxx>
30
#include "ChFi2d/ChFi2d_ChamferAPIPy.h"
31
#include "ChFi2d/ChFi2d_ChamferAPIPy.cpp"
32
#include "TopoShapeEdgePy.h"
33
#include "TopoShapeWirePy.h"
38
PyObject *ChFi2d_ChamferAPIPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
41
return new ChFi2d_ChamferAPIPy(new ChFi2d_ChamferAPI);
45
int ChFi2d_ChamferAPIPy::PyInit(PyObject* args, PyObject* )
51
if (PyArg_ParseTuple(args, "O!", &TopoShapeWirePy::Type, &wire)) {
52
TopoDS_Shape shape = static_cast<TopoShapeWirePy*>(wire)->getTopoShapePtr()->getShape();
53
getChFi2d_ChamferAPIPtr()->Init(TopoDS::Wire(shape));
60
if (PyArg_ParseTuple(args, "O!O!", &TopoShapeEdgePy::Type, &edge1,
61
&TopoShapeEdgePy::Type, &edge2)) {
62
TopoDS_Shape shape1 = static_cast<TopoShapeEdgePy*>(edge1)->getTopoShapePtr()->getShape();
63
TopoDS_Shape shape2 = static_cast<TopoShapeEdgePy*>(edge2)->getTopoShapePtr()->getShape();
64
getChFi2d_ChamferAPIPtr()->Init(TopoDS::Edge(shape1), TopoDS::Edge(shape2));
68
PyErr_SetString(PyExc_TypeError, "Wrong arguments:\n"
71
"-- ChamferAPI(edge, edge)\n");
76
std::string ChFi2d_ChamferAPIPy::representation() const
78
return {"<ChamferAPI object>"};
81
PyObject* ChFi2d_ChamferAPIPy::init(PyObject *args)
84
if (PyArg_ParseTuple(args, "O!", &TopoShapeWirePy::Type, &wire)) {
85
TopoDS_Shape shape = static_cast<TopoShapeWirePy*>(wire)->getTopoShapePtr()->getShape();
86
getChFi2d_ChamferAPIPtr()->Init(TopoDS::Wire(shape));
93
if (PyArg_ParseTuple(args, "O!O!", &TopoShapeEdgePy::Type, &edge1,
94
&TopoShapeEdgePy::Type, &edge2)) {
95
TopoDS_Shape shape1 = static_cast<TopoShapeEdgePy*>(edge1)->getTopoShapePtr()->getShape();
96
TopoDS_Shape shape2 = static_cast<TopoShapeEdgePy*>(edge2)->getTopoShapePtr()->getShape();
97
getChFi2d_ChamferAPIPtr()->Init(TopoDS::Edge(shape1), TopoDS::Edge(shape2));
101
PyErr_SetString(PyExc_TypeError, "Wrong arguments:\n"
103
"-- init(edge, edge)\n");
107
PyObject* ChFi2d_ChamferAPIPy::perform(PyObject *args)
109
if (!PyArg_ParseTuple(args, ""))
113
bool ok = getChFi2d_ChamferAPIPtr()->Perform();
114
return Py::new_reference_to(Py::Boolean(ok));
116
catch (Standard_Failure& e) {
117
PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString());
122
PyObject* ChFi2d_ChamferAPIPy::result(PyObject *args)
124
double length1, length2;
125
if (!PyArg_ParseTuple(args, "dd", &length1, &length2))
129
TopoDS_Edge theEdge1, theEdge2;
130
TopoDS_Shape res_edge = getChFi2d_ChamferAPIPtr()->Result(theEdge1, theEdge2, length1, length2);
132
Py::TupleN tuple(Py::asObject(TopoShape(res_edge).getPyObject()),
133
Py::asObject(TopoShape(theEdge1).getPyObject()),
134
Py::asObject(TopoShape(theEdge2).getPyObject()));
135
return Py::new_reference_to(tuple);
137
catch (Standard_Failure& e) {
138
PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString());
143
PyObject *ChFi2d_ChamferAPIPy::getCustomAttributes(const char* ) const
148
int ChFi2d_ChamferAPIPy::setCustomAttributes(const char* , PyObject* )