FreeCAD

Форк
0
/
Conic2dPyImp.cpp 
115 строк · 4.0 Кб
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_Conic.hxx>
26
#endif
27

28
#include <Base/GeometryPyCXX.h>
29

30
#include "Geom2d/Conic2dPy.h"
31
#include "Geom2d/Conic2dPy.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 Conic2dPy::representation() const
39
{
40
    return "<Conic2d object>";
41
}
42

43
PyObject *Conic2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
44
{
45
    // never create such objects with the constructor
46
    PyErr_SetString(PyExc_RuntimeError,
47
        "You cannot create an instance of the abstract class 'Conic2d'.");
48
    return nullptr;
49
}
50

51
// constructor method
52
int Conic2dPy::PyInit(PyObject* /*args*/, PyObject* /*kwds*/)
53
{
54
    return 0;
55
}
56

57
Py::Object Conic2dPy::getLocation() const
58
{
59
    Base::Vector2d loc = getGeom2dConicPtr()->getLocation();
60
    return Base::Vector2dPy::create(loc);
61
}
62

63
void  Conic2dPy::setLocation(Py::Object arg)
64
{
65
    Base::Vector2d loc = Py::toVector2d(arg.ptr());
66
    getGeom2dConicPtr()->setLocation(loc);
67
}
68

69
Py::Float Conic2dPy::getEccentricity() const
70
{
71
    Handle(Geom2d_Conic) conic = Handle(Geom2d_Conic)::DownCast(getGeom2dConicPtr()->handle());
72
    return Py::Float(conic->Eccentricity());
73
}
74

75
Py::Object Conic2dPy::getXAxis() const
76
{
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());
80
}
81

82
void  Conic2dPy::setXAxis(Py::Object arg)
83
{
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);
89
}
90

91
Py::Object Conic2dPy::getYAxis() const
92
{
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());
96
}
97

98
void  Conic2dPy::setYAxis(Py::Object arg)
99
{
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);
105
}
106

107
PyObject *Conic2dPy::getCustomAttributes(const char* ) const
108
{
109
    return nullptr;
110
}
111

112
int Conic2dPy::setCustomAttributes(const char* , PyObject *)
113
{
114
    return 0;
115
}
116

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

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

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

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