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 <Geom2d_Conic.hxx>
28
#include <Base/GeometryPyCXX.h>
30
#include "Geom2d/Conic2dPy.h"
31
#include "Geom2d/Conic2dPy.cpp"
37
// returns a string which represents the object e.g. when printed in python
38
std::string Conic2dPy::representation() const
40
return "<Conic2d object>";
43
PyObject *Conic2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
45
// never create such objects with the constructor
46
PyErr_SetString(PyExc_RuntimeError,
47
"You cannot create an instance of the abstract class 'Conic2d'.");
52
int Conic2dPy::PyInit(PyObject* /*args*/, PyObject* /*kwds*/)
57
Py::Object Conic2dPy::getLocation() const
59
Base::Vector2d loc = getGeom2dConicPtr()->getLocation();
60
return Base::Vector2dPy::create(loc);
63
void Conic2dPy::setLocation(Py::Object arg)
65
Base::Vector2d loc = Py::toVector2d(arg.ptr());
66
getGeom2dConicPtr()->setLocation(loc);
69
Py::Float Conic2dPy::getEccentricity() const
71
Handle(Geom2d_Conic) conic = Handle(Geom2d_Conic)::DownCast(getGeom2dConicPtr()->handle());
72
return Py::Float(conic->Eccentricity());
75
Py::Object Conic2dPy::getXAxis() const
77
Handle(Geom2d_Conic) conic = Handle(Geom2d_Conic)::DownCast(getGeom2dConicPtr()->handle());
78
gp_Dir2d xdir = conic->XAxis().Direction();
79
return Base::Vector2dPy::create(xdir.X(), xdir.Y());
82
void Conic2dPy::setXAxis(Py::Object arg)
84
Base::Vector2d dir = Py::toVector2d(arg.ptr());
85
Handle(Geom2d_Conic) conic = Handle(Geom2d_Conic)::DownCast(getGeom2dConicPtr()->handle());
86
gp_Ax2d xaxis = conic->XAxis();
87
xaxis.SetDirection(gp_Dir2d(dir.x, dir.y));
88
conic->SetXAxis(xaxis);
91
Py::Object Conic2dPy::getYAxis() const
93
Handle(Geom2d_Conic) conic = Handle(Geom2d_Conic)::DownCast(getGeom2dConicPtr()->handle());
94
gp_Dir2d ydir = conic->YAxis().Direction();
95
return Base::Vector2dPy::create(ydir.X(), ydir.Y());
98
void Conic2dPy::setYAxis(Py::Object arg)
100
Base::Vector2d dir = Py::toVector2d(arg.ptr());
101
Handle(Geom2d_Conic) conic = Handle(Geom2d_Conic)::DownCast(getGeom2dConicPtr()->handle());
102
gp_Ax2d yaxis = conic->YAxis();
103
yaxis.SetDirection(gp_Dir2d(dir.x, dir.y));
104
conic->SetYAxis(yaxis);
107
PyObject *Conic2dPy::getCustomAttributes(const char* ) const
112
int Conic2dPy::setCustomAttributes(const char* , PyObject *)