diff --git a/src/App/Application.cpp b/src/App/Application.cpp
index 585de9e6a..e378cbbb5 100644
--- a/src/App/Application.cpp
+++ b/src/App/Application.cpp
@@ -66,6 +66,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -157,7 +158,7 @@ PyDoc_STRVAR(Console_doc,
"FreeCAD Console\n"
);
-Application::Application(ParameterManager * /*pcSysParamMngr*/,
+Application::Application(ParameterManager * /*pcSysParamMngr*/,
ParameterManager * /*pcUserParamMngr*/,
std::map &mConfig)
://_pcSysParamMngr(pcSysParamMngr),
@@ -202,17 +203,22 @@ Application::Application(ParameterManager * /*pcSysParamMngr*/,
union PyType_Object pyRotationPyType = {&Base::RotationPy::Type};
PyModule_AddObject(pAppModule, "Rotation", pyRotationPyType.o);
+ if (PyType_Ready(&Base::AxisPy::Type) < 0) return;
+ union PyType_Object pyAxisPyType = {&Base::AxisPy::Type};
+ PyModule_AddObject(pAppModule, "Axis", pyAxisPyType.o);
+
// Note: Create an own module 'Base' which should provide the python
- // binding classes from the base module. At a later stage we should
+ // binding classes from the base module. At a later stage we should
// remove these types from the FreeCAD module.
PyObject* pBaseModule = Py_InitModule3("__FreeCADBase__", NULL,
"The Base module contains the classes for the geometric basics\n"
- "like vector, matrix, bounding box, placement, rotation, ...");
+ "like vector, matrix, bounding box, placement, rotation, axis, ...");
Base::Interpreter().addType(&Base::VectorPy ::Type,pBaseModule,"Vector");
Base::Interpreter().addType(&Base::MatrixPy ::Type,pBaseModule,"Matrix");
Base::Interpreter().addType(&Base::BoundBoxPy ::Type,pBaseModule,"BoundBox");
Base::Interpreter().addType(&Base::PlacementPy ::Type,pBaseModule,"Placement");
Base::Interpreter().addType(&Base::RotationPy ::Type,pBaseModule,"Rotation");
+ Base::Interpreter().addType(&Base::AxisPy ::Type,pBaseModule,"Axis");
//insert Base and Console
Py_INCREF(pBaseModule);
@@ -1285,7 +1291,7 @@ void Application::LoadParameters(void)
// fix weird error while linking boost (all versions of VC)
namespace boost { namespace program_options { std::string arg="arg"; } }
#if (defined (BOOST_VERSION) && (BOOST_VERSION == 104100))
-namespace boost { namespace program_options {
+namespace boost { namespace program_options {
const unsigned options_description::m_default_line_length = 80;
} }
#endif
@@ -1295,7 +1301,7 @@ namespace boost { namespace program_options {
// reported for SUSE in issue #0000208
#if defined(__GNUC__)
#if BOOST_VERSION == 104400
-namespace boost { namespace filesystem {
+namespace boost { namespace filesystem {
bool no_check( const std::string & ) { return true; }
} }
#endif
@@ -1597,7 +1603,7 @@ void Application::ExtractUserPath()
}
appData += PATHSEP;
}
-
+
appData += mConfig["ExeName"];
fi.setFile(appData.c_str());
if (!fi.exists() && !Py_IsInitialized()) {
@@ -1652,7 +1658,7 @@ void Application::ExtractUserPath()
}
appData += PATHSEP;
}
-
+
appData += mConfig["ExeName"];
fi.setFile(appData.c_str());
if (!fi.exists() && !Py_IsInitialized()) {
diff --git a/src/Base/Axis.cpp b/src/Base/Axis.cpp
new file mode 100644
index 000000000..aa4a6cdc9
--- /dev/null
+++ b/src/Base/Axis.cpp
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * Copyright (c) 2011 Juergen Riegel *
+ * *
+ * This file is part of the FreeCAD CAx development system. *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; see the file COPYING.LIB. If not, *
+ * write to the Free Software Foundation, Inc., 59 Temple Place, *
+ * Suite 330, Boston, MA 02111-1307, USA *
+ * *
+ ***************************************************************************/
+
+#include "PreCompiled.h"
+#ifndef _PreComp_
+#endif
+
+#include "Axis.h"
+
+using namespace Base;
+
+Axis::Axis()
+{
+
+}
+
+Axis::Axis(const Axis& that)
+{
+ this->_base = that._base;
+ this->_dir = that._dir;
+}
+
+Axis::Axis(const Vector3d& Orig, const Vector3d& Dir)
+{
+ this->_base = Orig;
+ this->_dir = Dir;
+}
+
+void Axis::reverse()
+{
+ this->_dir = -this->_dir;
+}
+
+Axis Axis::reversed() const
+{
+ Axis a(*this);
+ a.reverse();
+ return a;
+}
+
+void Axis::move(const Vector3d& MovVec)
+{
+ _base += MovVec;
+}
+
+bool Axis::operator ==(const Axis& that) const
+{
+ return (this->_base == that._base) && (this->_dir == that._dir);
+}
+
+bool Axis::operator !=(const Axis& that) const
+{
+ return !(*this == that);
+}
+
+Axis& Axis::operator *=(const Placement &p)
+{
+ p.multVec(this->_base, this->_base);
+ return *this;
+}
+
+Axis Axis::operator *(const Placement &p) const
+{
+ Axis a(*this);
+ a *= p;
+ return a;
+}
+
+Axis& Axis::operator = (const Axis &New)
+{
+ this->_base = New._base;
+ this->_dir = New._dir;
+ return *this;
+}
+
diff --git a/src/Base/Axis.h b/src/Base/Axis.h
new file mode 100644
index 000000000..be980606c
--- /dev/null
+++ b/src/Base/Axis.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * Copyright (c) 2011 Juergen Riegel *
+ * *
+ * This file is part of the FreeCAD CAx development system. *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; see the file COPYING.LIB. If not, *
+ * write to the Free Software Foundation, Inc., 59 Temple Place, *
+ * Suite 330, Boston, MA 02111-1307, USA *
+ * *
+ ***************************************************************************/
+
+
+#ifndef BASE_AXIS_H
+#define BASE_AXIS_H
+
+#include "Vector3D.h"
+#include "Placement.h"
+
+namespace Base {
+
+/**
+ * The Axis class.
+ */
+class BaseExport Axis
+{
+public:
+ /// default constructor
+ Axis(void);
+ Axis(const Axis&);
+ Axis(const Vector3d& Orig, const Vector3d& Dir);
+ /// Destruction
+ ~Axis () {};
+
+ const Vector3d& getBase(void) const {return _base;}
+ const Vector3d& getDirection(void) const {return _dir;}
+ void setBase(const Vector3d& Orig) {_base=Orig;}
+ void setDirection(const Vector3d& Dir) {_dir=Dir;}
+
+ void reverse();
+ Axis reversed() const;
+ void move(const Vector3d& MovVec);
+
+ /** Operators. */
+ //@{
+ Axis& operator *=(const Placement &p);
+ Axis operator *(const Placement &p) const;
+ bool operator ==(const Axis&) const;
+ bool operator !=(const Axis&) const;
+ Axis& operator =(const Axis&);
+ //@}
+
+protected:
+ Vector3d _base;
+ Vector3d _dir;
+};
+
+} // namespace Base
+
+#endif // BASE_AXIS_H
+
+
diff --git a/src/Base/AxisPy.xml b/src/Base/AxisPy.xml
new file mode 100644
index 000000000..5a520198d
--- /dev/null
+++ b/src/Base/AxisPy.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+ Axis
+An defines a direction and a position (base) in 3D space.
+
+The following constructors are supported:
+Axis() -- empty constructor
+Axis(Axis) -- copy constructor
+Axis(Base, Direction) -- define position and direction
+
+ Axis
+
+ >
+
+
+ copy()
+ Returns a copy of this Axis
+
+
+
+
+
+
+ move(Vector)
+ Move the axis base along the vector
+
+
+
+
+
+
+ multiply(Placement)
+ Multiply this axis with a placement
+
+
+
+
+
+
+ reversed() -> Axis
+ compute the reversed axis
+
+
+
+
+
+ Vector to the Base position of the Axis
+
+
+
+
+
+ Direction vector of the Axis
+
+
+
+
+
diff --git a/src/Base/AxisPyImp.cpp b/src/Base/AxisPyImp.cpp
new file mode 100644
index 000000000..76f7ff329
--- /dev/null
+++ b/src/Base/AxisPyImp.cpp
@@ -0,0 +1,147 @@
+/***************************************************************************
+ * Copyright (c) 2011 Juergen Riegel *
+ * *
+ * This file is part of the FreeCAD CAx development system. *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; see the file COPYING.LIB. If not, *
+ * write to the Free Software Foundation, Inc., 59 Temple Place, *
+ * Suite 330, Boston, MA 02111-1307, USA *
+ * *
+ ***************************************************************************/
+
+#include "PreCompiled.h"
+
+#include "Axis.h"
+#include "GeometryPyCXX.h"
+
+// inclusion of the generated files (generated out of AxisPy.xml)
+#include "AxisPy.h"
+#include "AxisPy.cpp"
+
+#include "VectorPy.h"
+#include "PlacementPy.h"
+
+using namespace Base;
+
+// returns a string which represents the object e.g. when printed in python
+std::string AxisPy::representation(void) const
+{
+ AxisPy::PointerType ptr = reinterpret_cast(_pcTwinPointer);
+ std::stringstream str;
+ str << "Axis [Base=(";
+ str << ptr->getBase().x << ","<< ptr->getBase().y << "," << ptr->getBase().z;
+ str << "), Direction=(";
+ str << ptr->getDirection().x << ","<< ptr->getDirection().y << "," << ptr->getDirection().z << ")]";
+
+ return str.str();
+}
+
+PyObject *AxisPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
+{
+ // create a new instance of AxisPy and the Twin object
+ return new AxisPy(new Axis);
+}
+
+// constructor method
+int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
+{
+ PyObject* o;
+ if (PyArg_ParseTuple(args, "")) {
+ return 0;
+ }
+
+ PyErr_Clear();
+ if (PyArg_ParseTuple(args, "O!", &(Base::AxisPy::Type), &o)) {
+ Base::Axis *a = static_cast(o)->getAxisPtr();
+ *(getAxisPtr()) = *a;
+ return 0;
+ }
+
+ PyErr_Clear();
+ PyObject* d;
+ if (PyArg_ParseTuple(args, "O!O", &(Base::VectorPy::Type), &o,
+ &(Base::VectorPy::Type), &d)) {
+ // NOTE: The first parameter defines the base (origin) and the second the direction.
+ *getAxisPtr() = Base::Axis(static_cast(o)->value(),
+ static_cast(d)->value());
+ return 0;
+ }
+
+ PyErr_SetString(PyExc_Exception, "empty parameter list, axis or base and direction expected");
+ return -1;
+}
+
+PyObject* AxisPy::move(PyObject * args)
+{
+ PyObject *vec;
+ if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec))
+ return NULL;
+ getAxisPtr()->move(static_cast(vec)->value());
+ Py_Return;
+}
+
+PyObject* AxisPy::multiply(PyObject * args)
+{
+ PyObject *plm;
+ if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm))
+ return NULL;
+ Axis mult = (*getAxisPtr()) * (*static_cast(plm)->getPlacementPtr());
+ return new AxisPy(new Axis(mult));
+}
+
+PyObject* AxisPy::copy(PyObject * args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ return new AxisPy(new Axis(*getAxisPtr()));
+}
+
+PyObject* AxisPy::reversed(PyObject * args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ Base::Axis a = getAxisPtr()->reversed();
+ return new AxisPy(new Axis(a));
+}
+
+Py::Object AxisPy::getBase(void) const
+{
+ return Py::Vector(getAxisPtr()->getBase());
+}
+
+void AxisPy::setBase(Py::Object arg)
+{
+ getAxisPtr()->setBase(Py::Vector(arg).toVector());
+}
+
+Py::Object AxisPy::getDirection(void) const
+{
+ return Py::Vector(getAxisPtr()->getDirection());
+}
+
+void AxisPy::setDirection(Py::Object arg)
+{
+ getAxisPtr()->setDirection(Py::Vector(arg).toVector());
+}
+
+PyObject *AxisPy::getCustomAttributes(const char* /*attr*/) const
+{
+ return 0;
+}
+
+int AxisPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
+{
+ return 0;
+}
+
diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt
index 23fd4e78d..458fcf651 100644
--- a/src/Base/CMakeLists.txt
+++ b/src/Base/CMakeLists.txt
@@ -61,6 +61,7 @@ generate_from_xml(VectorPy)
generate_from_xml(MatrixPy)
generate_from_xml(RotationPy)
generate_from_xml(PlacementPy)
+generate_from_xml(AxisPy)
if(SWIG_FOUND)
execute_process(COMMAND ${SWIG_EXECUTABLE} -python -external-runtime ${CMAKE_CURRENT_BINARY_DIR}/swigpyrun.h)
@@ -137,6 +138,7 @@ SET(pycxx_SRCS
SOURCE_GROUP("pycxx" FILES ${pycxx_SRCS})
SET(FreeCADBase_XML_SRCS
+ AxisPy.xml
BaseClassPy.xml
BoundBoxPy.xml
MatrixPy.xml
@@ -170,6 +172,8 @@ SET(FreeCADBase_UNITAPI_SRCS
SOURCE_GROUP("Units" FILES ${FreeCADBase_UNITAPI_SRCS})
SET(FreeCADBase_CPP_SRCS
+ Axis.cpp
+ AxisPyImp.cpp
Base64.cpp
BaseClass.cpp
BaseClassPyImp.cpp
@@ -222,6 +226,7 @@ SET(FreeCADBase_CPP_SRCS
)
SET(FreeCADBase_HPP_SRCS
+ Axis.h
Base64.h
BaseClass.h
BoundBox.h
diff --git a/src/Base/Makefile.am b/src/Base/Makefile.am
index 8378355bf..d94f38828 100644
--- a/src/Base/Makefile.am
+++ b/src/Base/Makefile.am
@@ -3,6 +3,7 @@ lib_LTLIBRARIES=libFreeCADBase.la
BUILT_SOURCES=\
moc_FutureWatcherProgress.cpp \
+ AxisPy.cpp \
BaseClassPy.cpp \
BoundBoxPy.cpp \
MatrixPy.cpp \
@@ -17,6 +18,7 @@ endif
libFreeCADBase_la_BUILT=\
+ AxisPy.h \
BaseClassPy.h \
BoundBoxPy.h \
MatrixPy.h \
@@ -26,6 +28,8 @@ libFreeCADBase_la_BUILT=\
VectorPy.h
libFreeCADBase_la_SOURCES=\
+ Axis.cpp \
+ AxisPyImp.cpp \
Base64.cpp \
BaseClass.cpp \
BaseClassPyImp.cpp \
@@ -103,6 +107,7 @@ nodist_include_HEADERS=\
$(libFreeCADBase_la_BUILT)
include_HEADERS=\
+ Axis.h \
Base64.h \
BaseClass.h \
BoundBox.h \
@@ -177,6 +182,7 @@ libFreeCADBase_la_CPPFLAGS = -DHAVE_SWIG=$(HAVE_SWIG)
EXTRA_DIST = \
CMakeLists.txt \
+ AxisPy.xml \
BaseClassPy.xml \
BoundBoxPy.xml \
MatrixPy.xml \