diff --git a/src/App/ExtensionContainerPyImp.cpp b/src/App/ExtensionContainerPyImp.cpp index a048731032..22166e2a11 100644 --- a/src/App/ExtensionContainerPyImp.cpp +++ b/src/App/ExtensionContainerPyImp.cpp @@ -54,7 +54,7 @@ int ExtensionContainerPy::initialization() { // The PyTypeObject is shared by all instances of this type and therefore // we have to add new methods only once. PyObject* obj = (*it).second->getExtensionPyObject(); - PyMethodDef* meth = reinterpret_cast(obj->ob_type->tp_methods); + PyMethodDef* meth = obj->ob_type->tp_methods; PyTypeObject *type = this->ob_type; PyObject *dict = type->tp_dict; @@ -214,7 +214,7 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { str << "No extension found of type '" << typeId << "'" << std::ends; throw Py::TypeError(str.str()); } - + //register the extension App::Extension* ext = static_cast(extension.createInstance()); //check if this really is a python extension! @@ -224,14 +224,14 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { str << "Extension is not a python addable version: '" << typeId << "'" << std::ends; throw Py::TypeError(str.str()); } - + GetApplication().signalBeforeAddingDynamicExtension(*getExtensionContainerPtr(), typeId); ext->initExtension(getExtensionContainerPtr()); - // The PyTypeObject is shared by all instances of this type and therefore + // The PyTypeObject is shared by all instances of this type and therefore // we have to add new methods only once. PyObject* obj = ext->getExtensionPyObject(); - PyMethodDef* meth = reinterpret_cast(obj->ob_type->tp_methods); + PyMethodDef* meth = obj->ob_type->tp_methods; PyTypeObject *type = this->ob_type; PyObject *dict = type->tp_dict; diff --git a/src/Base/AxisPyImp.cpp b/src/Base/AxisPyImp.cpp index 25a7eb268b..020a713341 100644 --- a/src/Base/AxisPyImp.cpp +++ b/src/Base/AxisPyImp.cpp @@ -36,7 +36,7 @@ using namespace Base; // returns a string which represents the object e.g. when printed in python std::string AxisPy::representation() const { - AxisPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + AxisPy::PointerType ptr = getAxisPtr(); std::stringstream str; str << "Axis [Base=("; str << ptr->getBase().x << ","<< ptr->getBase().y << "," << ptr->getBase().z; diff --git a/src/Base/BoundBoxPyImp.cpp b/src/Base/BoundBoxPyImp.cpp index 2414e2a664..f4d6e1918c 100644 --- a/src/Base/BoundBoxPyImp.cpp +++ b/src/Base/BoundBoxPyImp.cpp @@ -91,14 +91,12 @@ int BoundBoxPy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); // set by PyArg_ParseTuple() if (PyArg_ParseTuple(args,"O!O!",&(Base::VectorPy::Type), &object1, &(Base::VectorPy::Type), &object2)) { - // Note: must be static_cast, not reinterpret_cast ptr->Add(*(static_cast(object1)->getVectorPtr())); ptr->Add(*(static_cast(object2)->getVectorPtr())); return 0; } PyErr_Clear(); // set by PyArg_ParseTuple() if (PyArg_ParseTuple(args,"O!",&(Base::BoundBoxPy::Type), &object1)) { - // Note: must be static_cast, not reinterpret_cast *ptr = *(static_cast(object1)->getBoundBoxPtr()); return 0; } diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index 0ff2d2d98f..5ab17cb566 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -68,7 +68,7 @@ int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/) &a21,&a22,&a23,&a24, &a31,&a32,&a33,&a34, &a41,&a42,&a43,&a44)) { - MatrixPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + MatrixPy::PointerType ptr = getMatrixPtr(); (*ptr) = Matrix4D(a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34, @@ -79,7 +79,7 @@ int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); PyObject *o; if (PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type), &o)) { - MatrixPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + MatrixPy::PointerType ptr = getMatrixPtr(); (*ptr) = static_cast(o)->value(); return 0; } diff --git a/src/Base/PlacementPyImp.cpp b/src/Base/PlacementPyImp.cpp index 781267fb73..34d3956322 100644 --- a/src/Base/PlacementPyImp.cpp +++ b/src/Base/PlacementPyImp.cpp @@ -40,7 +40,7 @@ using namespace Base; std::string PlacementPy::representation() const { double A,B,C; - PlacementPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + PlacementPy::PointerType ptr = getPlacementPtr(); std::stringstream str; ptr->getRotation().getYawPitchRoll(A,B,C); diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index 5200d2ef56..5764035beb 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -37,7 +37,7 @@ using namespace Base; // returns a string which represents the object e.g. when printed in python std::string RotationPy::representation() const { - RotationPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + RotationPy::PointerType ptr = getRotationPtr(); Py::Float q0(ptr->getValue()[0]); Py::Float q1(ptr->getValue()[1]); Py::Float q2(ptr->getValue()[2]); diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index df5308bf98..35b057c1e4 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -41,7 +41,7 @@ using namespace Base; // returns a string which represent the object e.g. when printed in python std::string VectorPy::representation() const { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); Py::Float x(ptr->x); Py::Float y(ptr->y); Py::Float z(ptr->z); @@ -66,14 +66,13 @@ int VectorPy::PyInit(PyObject* args, PyObject* /*kwd*/) { double x=0.0,y=0.0,z=0.0; PyObject *object; - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); if (PyArg_ParseTuple(args, "|ddd", &x,&y,&z)) { ptr->Set(x,y,z); return 0; } PyErr_Clear(); // set by PyArg_ParseTuple() if (PyArg_ParseTuple(args,"O!",&(Base::VectorPy::Type), &object)) { - // Note: must be static_cast, not reinterpret_cast *ptr = *(static_cast(object)->getVectorPtr()); return 0; } @@ -286,8 +285,8 @@ PyObject* VectorPy::add(PyObject *args) VectorPy* vec = static_cast(obj); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType vect_ptr = reinterpret_cast(vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType vect_ptr = vec->getVectorPtr(); Base::Vector3d v = (*this_ptr) + (*vect_ptr); return new VectorPy(v); @@ -301,8 +300,8 @@ PyObject* VectorPy::sub(PyObject *args) VectorPy* vec = static_cast(obj); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType vect_ptr = reinterpret_cast(vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType vect_ptr = vec->getVectorPtr(); Base::Vector3d v = (*this_ptr) - (*vect_ptr); return new VectorPy(v); @@ -313,7 +312,7 @@ PyObject* VectorPy::negative(PyObject *args) if (!PyArg_ParseTuple(args, "")) return nullptr; - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); Base::Vector3d v = -(*this_ptr); return new VectorPy(v); } @@ -358,8 +357,8 @@ PyObject* VectorPy::isEqual(PyObject *args) VectorPy* vec = static_cast(obj); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType vect_ptr = reinterpret_cast(vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType vect_ptr = vec->getVectorPtr(); Py::Boolean eq((*this_ptr).IsEqual(*vect_ptr, tolerance)); return Py::new_reference_to(eq); @@ -370,7 +369,7 @@ PyObject* VectorPy::scale(PyObject *args) double factorX, factorY, factorZ; if (!PyArg_ParseTuple(args, "ddd", &factorX, &factorY, &factorZ)) return nullptr; - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); ptr->Scale(factorX, factorY, factorZ); return Py::new_reference_to(this); @@ -381,7 +380,7 @@ PyObject* VectorPy::multiply(PyObject *args) double factor; if (!PyArg_ParseTuple(args, "d", &factor)) return nullptr; - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); ptr->Scale(factor, factor, factor); return Py::new_reference_to(this); @@ -395,8 +394,8 @@ PyObject* VectorPy::dot(PyObject *args) VectorPy* vec = static_cast(obj); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType vect_ptr = reinterpret_cast(vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType vect_ptr = vec->getVectorPtr(); Py::Float mult((*this_ptr) * (*vect_ptr)); return Py::new_reference_to(mult); @@ -410,8 +409,8 @@ PyObject* VectorPy::cross(PyObject *args) VectorPy* vec = static_cast(obj); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType vect_ptr = reinterpret_cast(vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType vect_ptr = vec->getVectorPtr(); Base::Vector3d v = (*this_ptr) % (*vect_ptr); return new VectorPy(v); @@ -434,9 +433,9 @@ PyObject* VectorPy::isOnLineSegment(PyObject *args) VectorPy* start_vec = static_cast(start); VectorPy* end_vec = static_cast(end); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType start_ptr = reinterpret_cast(start_vec->_pcTwinPointer); - VectorPy::PointerType end_ptr = reinterpret_cast(end_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType start_ptr = start_vec->getVectorPtr(); + VectorPy::PointerType end_ptr = end_vec->getVectorPtr(); Py::Boolean result = this_ptr->IsOnLineSegment(*start_ptr, *end_ptr); @@ -451,8 +450,8 @@ PyObject* VectorPy::getAngle(PyObject *args) VectorPy* vec = static_cast(obj); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType vect_ptr = reinterpret_cast(vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType vect_ptr = vec->getVectorPtr(); Py::Float angle(this_ptr->GetAngle(*vect_ptr)); return Py::new_reference_to(angle); @@ -462,7 +461,7 @@ PyObject* VectorPy::normalize(PyObject *args) { if (!PyArg_ParseTuple(args, "")) return nullptr; - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); if (ptr->Length() < Vector3d::epsilon()) { PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot normalize null vector"); return nullptr; @@ -490,9 +489,9 @@ PyObject* VectorPy::projectToLine(PyObject *args) VectorPy* base_vec = static_cast(base); VectorPy* line_vec = static_cast(line); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); - VectorPy::PointerType line_ptr = reinterpret_cast(line_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType base_ptr = base_vec->getVectorPtr(); + VectorPy::PointerType line_ptr = line_vec->getVectorPtr(); this_ptr->ProjectToLine(*base_ptr, *line_ptr); @@ -516,9 +515,9 @@ PyObject* VectorPy::projectToPlane(PyObject *args) VectorPy* base_vec = static_cast(base); VectorPy* line_vec = static_cast(line); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); - VectorPy::PointerType line_ptr = reinterpret_cast(line_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType base_ptr = base_vec->getVectorPtr(); + VectorPy::PointerType line_ptr = line_vec->getVectorPtr(); this_ptr->ProjectToPlane(*base_ptr, *line_ptr); @@ -532,8 +531,8 @@ PyObject* VectorPy::distanceToPoint(PyObject *args) return nullptr; VectorPy* base_vec = static_cast(pnt); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType base_ptr = base_vec->getVectorPtr(); Py::Float dist(Base::Distance(*this_ptr, *base_ptr)); return Py::new_reference_to(dist); @@ -556,9 +555,9 @@ PyObject* VectorPy::distanceToLine(PyObject *args) VectorPy* base_vec = static_cast(base); VectorPy* line_vec = static_cast(line); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); - VectorPy::PointerType line_ptr = reinterpret_cast(line_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType base_ptr = base_vec->getVectorPtr(); + VectorPy::PointerType line_ptr = line_vec->getVectorPtr(); Py::Float dist(this_ptr->DistanceToLine(*base_ptr, *line_ptr)); return Py::new_reference_to(dist); @@ -581,9 +580,9 @@ PyObject* VectorPy::distanceToLineSegment(PyObject *args) VectorPy* base_vec = static_cast(base); VectorPy* line_vec = static_cast(line); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); - VectorPy::PointerType line_ptr = reinterpret_cast(line_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType base_ptr = base_vec->getVectorPtr(); + VectorPy::PointerType line_ptr = line_vec->getVectorPtr(); Vector3d v = this_ptr->DistanceToLineSegment(*base_ptr, *line_ptr); return new VectorPy(v); @@ -606,9 +605,9 @@ PyObject* VectorPy::distanceToPlane(PyObject *args) VectorPy* base_vec = static_cast(base); VectorPy* line_vec = static_cast(line); - VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); - VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); - VectorPy::PointerType line_ptr = reinterpret_cast(line_vec->_pcTwinPointer); + VectorPy::PointerType this_ptr = getVectorPtr(); + VectorPy::PointerType base_ptr = base_vec->getVectorPtr(); + VectorPy::PointerType line_ptr = line_vec->getVectorPtr(); Py::Float dist(this_ptr->DistanceToPlane(*base_ptr, *line_ptr)); return Py::new_reference_to(dist); @@ -616,13 +615,13 @@ PyObject* VectorPy::distanceToPlane(PyObject *args) Py::Float VectorPy::getLength() const { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); return Py::Float(ptr->Length()); } void VectorPy::setLength(Py::Float arg) { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); double len = ptr->Length(); if (len < Vector3d::epsilon()) { throw Py::RuntimeError(std::string("Cannot set length of null vector")); @@ -636,37 +635,37 @@ void VectorPy::setLength(Py::Float arg) Py::Float VectorPy::getx() const { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); return Py::Float(ptr->x); } void VectorPy::setx(Py::Float arg) { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); ptr->x = static_cast(arg); } Py::Float VectorPy::gety() const { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); return Py::Float(ptr->y); } void VectorPy::sety(Py::Float arg) { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); ptr->y = static_cast(arg); } Py::Float VectorPy::getz() const { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); return Py::Float(ptr->z); } void VectorPy::setz(Py::Float arg) { - VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType ptr = getVectorPtr(); ptr->z = static_cast(arg); }