1
/***************************************************************************
2
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
# include <GCE2d_MakeArcOfCircle.hxx>
26
# include <Geom2d_Circle.hxx>
27
# include <Geom2d_TrimmedCurve.hxx>
28
# include <gp_Circ2d.hxx>
31
#include <Base/GeometryPyCXX.h>
33
#include "Geom2d/ArcOfCircle2dPy.h"
34
#include "Geom2d/ArcOfCircle2dPy.cpp"
35
#include "Geom2d/Circle2dPy.h"
41
extern const char* gce_ErrorStatusText(gce_ErrorType et);
43
// returns a string which represents the object e.g. when printed in python
44
std::string ArcOfCircle2dPy::representation() const
46
return "<Arc of circle2d object>";
49
PyObject *ArcOfCircle2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
51
// create a new instance of ArcOfCirclePy and the Twin object
52
return new ArcOfCircle2dPy(new Geom2dArcOfCircle);
56
int ArcOfCircle2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
60
PyObject *sense=Py_True;
61
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::Circle2dPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
63
Handle(Geom2d_Circle) circle = Handle(Geom2d_Circle)::DownCast
64
(static_cast<Circle2dPy*>(o)->getGeom2dCirclePtr()->handle());
65
GCE2d_MakeArcOfCircle arc(circle->Circ2d(), u1, u2, Base::asBoolean(sense));
67
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
71
getGeom2dArcOfCirclePtr()->setHandle(arc.Value());
74
catch (Standard_Failure& e) {
75
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
79
PyErr_SetString(PartExceptionOCCError, "creation of arc failed");
85
PyObject *pV1, *pV2, *pV3;
86
if (PyArg_ParseTuple(args, "O!O!O!", Base::Vector2dPy::type_object(), &pV1,
87
Base::Vector2dPy::type_object(), &pV2,
88
Base::Vector2dPy::type_object(), &pV3)) {
89
Base::Vector2d v1 = Py::toVector2d(pV1);
90
Base::Vector2d v2 = Py::toVector2d(pV2);
91
Base::Vector2d v3 = Py::toVector2d(pV3);
93
GCE2d_MakeArcOfCircle arc(gp_Pnt2d(v1.x,v1.y),
97
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
101
getGeom2dArcOfCirclePtr()->setHandle(arc.Value());
106
PyErr_SetString(PyExc_TypeError,
107
"ArcOfCircle2d constructor expects a circle curve and a parameter range or three points");
111
Py::Float ArcOfCircle2dPy::getRadius() const
113
return Py::Float(getGeom2dArcOfCirclePtr()->getRadius());
116
void ArcOfCircle2dPy::setRadius(Py::Float arg)
118
getGeom2dArcOfCirclePtr()->setRadius((double)arg);
121
Py::Object ArcOfCircle2dPy::getCircle() const
123
Handle(Geom2d_TrimmedCurve) curve = Handle(Geom2d_TrimmedCurve)::DownCast(getGeom2dArcOfConicPtr()->handle());
124
Handle(Geom2d_Circle) circle = Handle(Geom2d_Circle)::DownCast(curve->BasisCurve());
125
return Py::asObject(new Circle2dPy(new Geom2dCircle(circle)));
128
PyObject *ArcOfCircle2dPy::getCustomAttributes(const char* ) const
133
int ArcOfCircle2dPy::setCustomAttributes(const char* , PyObject *)