1
/***************************************************************************
2
* Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
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 "GeometryPyCXX.h"
27
// inclusion of the generated files (generated out of AxisPy.xml)
32
#include "PlacementPy.h"
36
// returns a string which represents the object e.g. when printed in python
37
std::string AxisPy::representation() const
39
AxisPy::PointerType ptr = getAxisPtr();
40
std::stringstream str;
41
str << "Axis [Base=(";
42
str << ptr->getBase().x << "," << ptr->getBase().y << "," << ptr->getBase().z;
43
str << "), Direction=(";
44
str << ptr->getDirection().x << "," << ptr->getDirection().y << "," << ptr->getDirection().z
50
PyObject* AxisPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
52
// create a new instance of AxisPy and the Twin object
53
return new AxisPy(new Axis);
57
int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
60
if (PyArg_ParseTuple(args, "")) {
65
if (PyArg_ParseTuple(args, "O!", &(Base::AxisPy::Type), &o)) {
66
Base::Axis* a = static_cast<Base::AxisPy*>(o)->getAxisPtr();
73
if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type), &o, &(Base::VectorPy::Type), &d)) {
74
// NOTE: The first parameter defines the base (origin) and the second the direction.
75
*getAxisPtr() = Base::Axis(static_cast<Base::VectorPy*>(o)->value(),
76
static_cast<Base::VectorPy*>(d)->value());
80
PyErr_SetString(PyExc_TypeError, "empty parameter list, axis or base and direction expected");
84
PyObject* AxisPy::move(PyObject* args)
87
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec)) {
90
getAxisPtr()->move(static_cast<VectorPy*>(vec)->value());
94
PyObject* AxisPy::multiply(PyObject* args)
97
if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm)) {
100
Axis mult = (*getAxisPtr()) * (*static_cast<PlacementPy*>(plm)->getPlacementPtr());
101
return new AxisPy(new Axis(mult));
104
PyObject* AxisPy::copy(PyObject* args)
106
if (!PyArg_ParseTuple(args, "")) {
109
return new AxisPy(new Axis(*getAxisPtr()));
112
PyObject* AxisPy::reversed(PyObject* args)
114
if (!PyArg_ParseTuple(args, "")) {
117
Base::Axis a = getAxisPtr()->reversed();
118
return new AxisPy(new Axis(a));
121
Py::Object AxisPy::getBase() const
123
return Py::Vector(getAxisPtr()->getBase()); // NOLINT
126
void AxisPy::setBase(Py::Object arg)
128
getAxisPtr()->setBase(Py::Vector(arg).toVector());
131
Py::Object AxisPy::getDirection() const
133
return Py::Vector(getAxisPtr()->getDirection()); // NOLINT
136
void AxisPy::setDirection(Py::Object arg)
138
getAxisPtr()->setDirection(Py::Vector(arg).toVector());
141
PyObject* AxisPy::getCustomAttributes(const char* /*attr*/) const
146
int AxisPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)