23
#include "PreCompiled.h"
25
# include <GC_MakeCircle.hxx>
26
# include <Geom_Circle.hxx>
27
# include <gp_Circ.hxx>
30
#include <Base/PyWrapParseTupleAndKeywords.h>
31
#include <Base/VectorPy.h>
34
#include "CirclePy.cpp"
40
extern const char* gce_ErrorStatusText(gce_ErrorType et);
43
std::string CirclePy::representation() const
45
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
46
gp_Ax1 axis = circle->Axis();
47
gp_Dir dir = axis.Direction();
48
gp_Pnt loc = axis.Location();
49
Standard_Real fRad = circle->Radius();
51
std::stringstream str;
53
str << "Radius : " << fRad << ", ";
54
str << "Position : (" << loc.X() << ", "<< loc.Y() << ", "<< loc.Z() << "), ";
55
str << "Direction : (" << dir.X() << ", "<< dir.Y() << ", "<< dir.Z() << ")";
61
PyObject *CirclePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
64
Handle(Geom_Circle) circle = new Geom_Circle(gp_Circ());
65
return new CirclePy(new GeomCircle(circle));
69
int CirclePy::PyInit(PyObject* args, PyObject* kwds)
74
static const std::array<const char *, 3> keywords_cd {"Circle", "Distance", nullptr};
75
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!d", keywords_cd, &(CirclePy::Type), &pCirc, &dist)) {
76
CirclePy* pcCircle = static_cast<CirclePy*>(pCirc);
77
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast
78
(pcCircle->getGeomCirclePtr()->handle());
79
GC_MakeCircle mc(circle->Circ(), dist);
81
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(mc.Status()));
85
Handle(Geom_Circle) circ = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
86
circ->SetCirc(mc.Value()->Circ());
91
PyObject *pV1, *pV2, *pV3;
92
static const std::array<const char *, 4> keywords_cnr {"Center", "Normal", "Radius", nullptr};
94
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!O!d", keywords_cnr,
95
&(Base::VectorPy::Type), &pV1,
96
&(Base::VectorPy::Type), &pV2,
98
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pV1)->value();
99
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pV2)->value();
100
GC_MakeCircle mc(gp_Pnt(v1.x,v1.y,v1.z),
101
gp_Dir(v2.x,v2.y,v2.z),
104
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(mc.Status()));
108
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
109
circle->SetCirc(mc.Value()->Circ());
113
static const std::array<const char *, 2> keywords_c {"Circle", nullptr};
115
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!", keywords_c, &(CirclePy::Type), &pCirc)) {
116
CirclePy* pcCircle = static_cast<CirclePy*>(pCirc);
117
Handle(Geom_Circle) circ1 = Handle(Geom_Circle)::DownCast
118
(pcCircle->getGeomCirclePtr()->handle());
119
Handle(Geom_Circle) circ2 = Handle(Geom_Circle)::DownCast
120
(this->getGeomCirclePtr()->handle());
121
circ2->SetCirc(circ1->Circ());
125
static const std::array<const char *, 4> keywords_ppp {"Point1", "Point2", "Point3", nullptr};
127
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "O!O!O!", keywords_ppp,
128
&(Base::VectorPy::Type), &pV1,
129
&(Base::VectorPy::Type), &pV2,
130
&(Base::VectorPy::Type), &pV3)) {
131
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pV1)->value();
132
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pV2)->value();
133
Base::Vector3d v3 = static_cast<Base::VectorPy*>(pV3)->value();
134
GC_MakeCircle mc(gp_Pnt(v1.x,v1.y,v1.z),
135
gp_Pnt(v2.x,v2.y,v2.z),
136
gp_Pnt(v3.x,v3.y,v3.z));
138
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(mc.Status()));
142
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
143
circle->SetCirc(mc.Value()->Circ());
148
static const std::array<const char *, 1> keywords_n {nullptr};
150
if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "", keywords_n)) {
151
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
152
circle->SetRadius(1.0);
156
PyErr_SetString(PyExc_TypeError, "Circle constructor accepts:\n"
157
"-- empty parameter list\n"
159
"-- Circle, Distance\n"
160
"-- Center, Normal, Radius\n"
161
"-- Point1, Point2, Point3");
165
Py::Float CirclePy::getRadius() const
167
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
168
return Py::Float(circle->Radius());
171
void CirclePy::setRadius(Py::Float arg)
173
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(getGeomCirclePtr()->handle());
174
circle->SetRadius((double)arg);
177
PyObject *CirclePy::getCustomAttributes(const char* ) const
182
int CirclePy::setCustomAttributes(const char* , PyObject *)