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_MakeArcOfParabola.hxx>
26
# include <Geom2d_Parabola.hxx>
27
# include <Geom2d_TrimmedCurve.hxx>
28
# include <gp_Parab2d.hxx>
31
#include "Geom2d/ArcOfParabola2dPy.h"
32
#include "Geom2d/ArcOfParabola2dPy.cpp"
33
#include "Geom2d/Parabola2dPy.h"
39
extern const char* gce_ErrorStatusText(gce_ErrorType et);
41
// returns a string which represents the object e.g. when printed in python
42
std::string ArcOfParabola2dPy::representation() const
44
return "<ArcOfParabola2d object>";
47
PyObject *ArcOfParabola2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
49
// create a new instance of ArcOfParabola2dPy and the Twin object
50
return new ArcOfParabola2dPy(new Geom2dArcOfParabola);
54
int ArcOfParabola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
58
PyObject *sense=Py_True;
59
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::Parabola2dPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
61
Handle(Geom2d_Parabola) parabola = Handle(Geom2d_Parabola)::DownCast
62
(static_cast<Parabola2dPy*>(o)->getGeom2dParabolaPtr()->handle());
63
GCE2d_MakeArcOfParabola arc(parabola->Parab2d(), u1, u2, Base::asBoolean(sense));
65
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
69
getGeom2dArcOfParabolaPtr()->setHandle(arc.Value());
72
catch (Standard_Failure& e) {
74
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
78
PyErr_SetString(PartExceptionOCCError, "creation of arc failed");
84
PyErr_SetString(PyExc_TypeError,
85
"ArcOfParabola2d constructor expects an parabola curve and a parameter range");
89
Py::Float ArcOfParabola2dPy::getFocal() const
91
return Py::Float(getGeom2dArcOfParabolaPtr()->getFocal());
94
void ArcOfParabola2dPy::setFocal(Py::Float arg)
96
getGeom2dArcOfParabolaPtr()->setFocal((double)arg);
99
Py::Object ArcOfParabola2dPy::getParabola() const
101
Handle(Geom2d_TrimmedCurve) trim = Handle(Geom2d_TrimmedCurve)::DownCast
102
(getGeom2dArcOfParabolaPtr()->handle());
103
Handle(Geom2d_Parabola) parabola = Handle(Geom2d_Parabola)::DownCast(trim->BasisCurve());
104
return Py::asObject(new Parabola2dPy(new Geom2dParabola(parabola)));
107
PyObject *ArcOfParabola2dPy::getCustomAttributes(const char* ) const
112
int ArcOfParabola2dPy::setCustomAttributes(const char* , PyObject *)