FreeCAD

Форк
0
/
Parabola2dPyImp.cpp 
95 строк · 3.4 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
# include <Geom2d_Parabola.hxx>
26
#endif
27

28
#include <Base/GeometryPyCXX.h>
29

30
#include "Geom2d/Parabola2dPy.h"
31
#include "Geom2d/Parabola2dPy.cpp"
32
#include "OCCError.h"
33

34

35
using namespace Part;
36

37
// returns a string which represents the object e.g. when printed in python
38
std::string Parabola2dPy::representation() const
39
{
40
    return "<Parabola2d object>";
41
}
42

43
PyObject *Parabola2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
44
{
45
    // create a new instance of Parabola2dPy and the Twin object
46
    return new Parabola2dPy(new Geom2dParabola);
47
}
48

49
// constructor method
50
int Parabola2dPy::PyInit(PyObject* args, PyObject* /*kwd*/)
51
{
52
    if (PyArg_ParseTuple(args, "")) {
53
        Handle(Geom2d_Parabola) c = Handle(Geom2d_Parabola)::DownCast
54
            (getGeometry2dPtr()->handle());
55
        c->SetFocal(1.0);
56
        return 0;
57
    }
58

59
    return -1;
60
}
61

62
Py::Float Parabola2dPy::getFocal() const
63
{
64
    Handle(Geom2d_Parabola) curve = Handle(Geom2d_Parabola)::DownCast(getGeometry2dPtr()->handle());
65
    return Py::Float(curve->Focal());
66
}
67

68
void Parabola2dPy::setFocal(Py::Float arg)
69
{
70
    Handle(Geom2d_Parabola) curve = Handle(Geom2d_Parabola)::DownCast(getGeometry2dPtr()->handle());
71
    curve->SetFocal((double)arg);
72
}
73

74
Py::Object Parabola2dPy::getFocus() const
75
{
76
    Handle(Geom2d_Parabola) curve = Handle(Geom2d_Parabola)::DownCast(getGeometry2dPtr()->handle());
77
    gp_Pnt2d loc = curve->Focus();
78
    return Base::Vector2dPy::create(loc.X(), loc.Y());
79
}
80

81
Py::Float Parabola2dPy::getParameter() const
82
{
83
    Handle(Geom2d_Parabola) curve = Handle(Geom2d_Parabola)::DownCast(getGeometry2dPtr()->handle());
84
    return Py::Float(curve->Parameter());
85
}
86

87
PyObject *Parabola2dPy::getCustomAttributes(const char* /*attr*/) const
88
{
89
    return nullptr;
90
}
91

92
int Parabola2dPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
93
{
94
    return 0;
95
}
96

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.