fix readability-isolate-declarations

This commit is contained in:
wmayer
2023-11-15 11:55:10 +01:00
parent 276bbcad6e
commit a602003747
16 changed files with 226 additions and 91 deletions

View File

@@ -59,7 +59,12 @@ int BoundBoxPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear(); // set by PyArg_ParseTuple()
double xMin = 0.0, yMin = 0.0, zMin = 0.0, xMax = 0.0, yMax = 0.0, zMax = 0.0;
double xMin = 0.0;
double yMin = 0.0;
double zMin = 0.0;
double xMax = 0.0;
double yMax = 0.0;
double zMax = 0.0;
PyObject *object1 {}, *object2 {};
BoundBoxPy::PointerType ptr = getBoundBoxPtr();
if (PyArg_ParseTuple(args, "d|ddddd", &xMin, &yMin, &zMin, &xMax, &yMax, &zMax)) {
@@ -128,7 +133,9 @@ PyObject* BoundBoxPy::isValid(PyObject* args)
PyObject* BoundBoxPy::add(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
if (PyArg_ParseTuple(args, "ddd", &x, &y, &z)) {
getBoundBoxPtr()->Add(Vector3d(x, y, z));
@@ -189,7 +196,8 @@ PyObject* BoundBoxPy::getEdge(PyObject* args)
return nullptr;
}
Base::Vector3d pnt1, pnt2;
Base::Vector3d pnt1;
Base::Vector3d pnt2;
getBoundBoxPtr()->CalcEdge(index, pnt1, pnt2);
Py::Tuple tuple(2);
tuple.setItem(0, Py::Vector(pnt1));
@@ -199,7 +207,9 @@ PyObject* BoundBoxPy::getEdge(PyObject* args)
PyObject* BoundBoxPy::closestPoint(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Base::Vector3d vec;
@@ -232,7 +242,8 @@ PyObject* BoundBoxPy::closestPoint(PyObject* args)
PyObject* BoundBoxPy::intersect(PyObject* args)
{
PyObject *object {}, *object2 {};
PyObject* object1 {};
PyObject* object2 {};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -244,23 +255,23 @@ PyObject* BoundBoxPy::intersect(PyObject* args)
if (PyArg_ParseTuple(args,
"O!O!",
&(Base::VectorPy::Type),
&object,
&object1,
&(Base::VectorPy::Type),
&object2)) {
retVal = getBoundBoxPtr()->IsCutLine(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
break;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object)) {
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object1)) {
if (!static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr()->IsValid()) {
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
return nullptr;
}
retVal = getBoundBoxPtr()->Intersect(
*(static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()));
*(static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr()));
break;
}
@@ -325,12 +336,13 @@ PyObject* BoundBoxPy::enlarge(PyObject* args)
PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
{
PyObject *object {}, *object2 {};
PyObject* object1 {};
PyObject* object2 {};
double epsilon = 0.0001;
if (!PyArg_ParseTuple(args,
"O!O!|d;Need base and direction vector",
&(Base::VectorPy::Type),
&object,
&object1,
&(Base::VectorPy::Type),
&object2,
&epsilon)) {
@@ -339,7 +351,7 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
Base::Vector3d point;
bool ok = getBoundBoxPtr()->IntersectionPoint(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()),
point,
epsilon);
@@ -353,7 +365,9 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
PyObject* BoundBoxPy::move(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Base::Vector3d vec;
@@ -389,7 +403,9 @@ PyObject* BoundBoxPy::move(PyObject* args)
PyObject* BoundBoxPy::scale(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Base::Vector3d vec;
@@ -441,7 +457,8 @@ PyObject* BoundBoxPy::transformed(PyObject* args)
PyObject* BoundBoxPy::isCutPlane(PyObject* args)
{
PyObject *object {}, *object2 {};
PyObject* object {};
PyObject* object2 {};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -466,7 +483,9 @@ PyObject* BoundBoxPy::isCutPlane(PyObject* args)
PyObject* BoundBoxPy::isInside(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Py::Boolean retVal;

View File

@@ -81,7 +81,10 @@ struct vec_traits<Rotation>
{}
inline std::tuple<float_type, float_type, float_type, float_type> get() const
{
float_type q1 {}, q2 {}, q3 {}, q4 {};
float_type q1 {};
float_type q2 {};
float_type q3 {};
float_type q4 {};
v.getValue(q1, q2, q3, q4);
return std::make_tuple(q1, q2, q3, q4);
}

View File

@@ -53,7 +53,8 @@ int CoordinateSystemPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
PyObject* CoordinateSystemPy::setAxes(PyObject* args)
{
PyObject *axis {}, *xdir {};
PyObject* axis {};
PyObject* xdir {};
if (PyArg_ParseTuple(args, "O!O!", &(AxisPy::Type), &axis, &(VectorPy::Type), &xdir)) {
getCoordinateSystemPtr()->setAxes(*static_cast<AxisPy*>(axis)->getAxisPtr(),
*static_cast<VectorPy*>(xdir)->getVectorPtr());

View File

@@ -127,7 +127,8 @@ Py::PythonClassObject<Vector2dPy> Vector2dPy::create(double vx, double vy)
Vector2dPy::Vector2dPy(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& kwds)
: Py::PythonClass<Vector2dPy>::PythonClass(self, args, kwds)
{
double vx = 0, vy = 0;
double vx = 0;
double vy = 0;
if (!PyArg_ParseTuple(args.ptr(), "|dd", &vx, &vy)) {
throw Py::Exception();
}

View File

@@ -160,7 +160,10 @@ SystemExitException::SystemExitException()
long int errCode = 1;
std::string errMsg = "System exit";
PyObject *type {}, *value {}, *traceback {}, *code {};
PyObject* type {};
PyObject* value {};
PyObject* traceback {};
PyObject* code {};
PyGILStateLocker locker;
PyErr_Fetch(&type, &value, &traceback);
@@ -228,7 +231,9 @@ InterpreterSingleton::~InterpreterSingleton() = default;
std::string InterpreterSingleton::runString(const char* sCmd)
{
PyObject *module {}, *dict {}, *presult {}; /* "exec code in d, d" */
PyObject* module {};
PyObject* dict {};
PyObject* presult {};
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */
@@ -308,7 +313,9 @@ std::string InterpreterSingleton::runStringWithKey(const char* psCmd,
Py::Object InterpreterSingleton::runStringObject(const char* sCmd)
{
PyObject *module {}, *dict {}, *presult {}; /* "exec code in d, d" */
PyObject* module {};
PyObject* dict {};
PyObject* presult {};
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */
@@ -336,7 +343,9 @@ Py::Object InterpreterSingleton::runStringObject(const char* sCmd)
void InterpreterSingleton::systemExit()
{
/* This code is taken from the original Python code */
PyObject *exception {}, *value {}, *tb {};
PyObject* exception {};
PyObject* value {};
PyObject* tb {};
int exitcode = 0;
PyErr_Fetch(&exception, &value, &tb);
@@ -379,7 +388,9 @@ done:
void InterpreterSingleton::runInteractiveString(const char* sCmd)
{
PyObject *module {}, *dict {}, *presult {}; /* "exec code in d, d" */
PyObject* module {};
PyObject* dict {};
PyObject* presult {};
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */
@@ -398,7 +409,9 @@ void InterpreterSingleton::runInteractiveString(const char* sCmd)
}
/* get latest python exception information */
/* and print the error to the error output */
PyObject *errobj {}, *errdata {}, *errtraceback {};
PyObject* errobj {};
PyObject* errdata {};
PyObject* errtraceback {};
PyErr_Fetch(&errobj, &errdata, &errtraceback);
RuntimeError exc(""); // do not use PyException since this clears the error indicator
@@ -427,7 +440,8 @@ void InterpreterSingleton::runFile(const char* pxFileName, bool local)
#endif
if (fp) {
PyGILStateLocker locker;
PyObject *module {}, *dict {};
PyObject* module {};
PyObject* dict {};
module = PyImport_AddModule("__main__");
dict = PyModule_GetDict(module);
if (local) {
@@ -737,7 +751,9 @@ void InterpreterSingleton::runMethod(PyObject* pobject,
const char* argfmt,
...) /* convert to python */
{
PyObject *pmeth {}, *pargs {}, *presult {};
PyObject* pmeth {};
PyObject* pargs {};
PyObject* presult {};
va_list argslist; /* "pobject.method(args)" */
va_start(argslist, argfmt);
@@ -777,7 +793,9 @@ void InterpreterSingleton::runMethod(PyObject* pobject,
PyObject* InterpreterSingleton::getValue(const char* key, const char* result_var)
{
PyObject *module {}, *dict {}, *presult {}; /* "exec code in d, d" */
PyObject* module {};
PyObject* dict {};
PyObject* presult {};
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */

View File

@@ -540,6 +540,7 @@ void Matrix4D::inverse()
using Matrix = double*;
// NOLINTBEGIN
void Matrix_gauss(Matrix a, Matrix b)
{
int ipiv[4], indxr[4], indxc[4];
@@ -617,6 +618,7 @@ void Matrix_gauss(Matrix a, Matrix b)
}
}
}
// NOLINTEND
void Matrix4D::inverseOrthogonal()
{

View File

@@ -61,10 +61,12 @@ PyObject* MatrixPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObj
// constructor method
int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
// NOLINTBEGIN
double a11 = 1.0, a12 = 0.0, a13 = 0.0, a14 = 0.0;
double a21 = 0.0, a22 = 1.0, a23 = 0.0, a24 = 0.0;
double a31 = 0.0, a32 = 0.0, a33 = 1.0, a34 = 0.0;
double a41 = 0.0, a42 = 0.0, a43 = 0.0, a44 = 1.0;
// NOLINTEND
// clang-format off
if (PyArg_ParseTuple(args,
@@ -263,7 +265,9 @@ PyObject* MatrixPy::richCompare(PyObject* v, PyObject* w, int op)
PyObject* MatrixPy::move(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
Base::Vector3d vec;
PyObject* pcVecObj {};
@@ -304,7 +308,9 @@ PyObject* MatrixPy::move(PyObject* args)
PyObject* MatrixPy::scale(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
Base::Vector3d vec;
PyObject* pcVecObj {};
@@ -425,7 +431,8 @@ PyObject* MatrixPy::transform(PyObject* args)
{
Base::Vector3d vec;
Matrix4D mat;
PyObject *pcVecObj {}, *pcMatObj {};
PyObject* pcVecObj {};
PyObject* pcMatObj {};
if (!PyArg_ParseTuple(
args,

View File

@@ -40,7 +40,9 @@ using namespace Base;
// returns a string which represents the object e.g. when printed in python
std::string PlacementPy::representation() const
{
double yaw {}, pitch {}, roll {};
double yaw {};
double pitch {};
double roll {};
PlacementPy::PointerType ptr = getPlacementPtr();
std::stringstream str;
ptr->getRotation().getYawPitchRoll(yaw, pitch, roll);
@@ -398,7 +400,8 @@ PyObject* PlacementPy::getCustomAttributes(const char* attr) const
{
// for backward compatibility
if (strcmp(attr, "isNull") == 0) {
PyObject *w {}, *res {};
PyObject* w {};
PyObject* res {};
w = PyUnicode_InternFromString("isIdentity");
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
res = PyObject_GenericGetAttr(const_cast<PlacementPy*>(this), w);

View File

@@ -420,7 +420,8 @@ PyObject *PyObjectBase::_getattr(const char *attr)
}
else {
// As fallback solution use Python's default method to get generic attributes
PyObject *w{}, *res{};
PyObject *w{};
PyObject *res{};
w = PyUnicode_InternFromString(attr);
if (w) {
res = PyObject_GenericGetAttr(this, w);

View File

@@ -343,8 +343,10 @@ static Quantity& pyToQuantity(Quantity& q, PyObject* pyobj)
PyObject* QuantityPy::number_add_handler(PyObject* self, PyObject* other)
{
Quantity *pa = nullptr, *pb = nullptr;
Quantity a, b;
Quantity* pa = nullptr;
Quantity* pb = nullptr;
Quantity a;
Quantity b;
PY_TRY
{
if (PyObject_TypeCheck(self, &(QuantityPy::Type))) {
@@ -367,8 +369,10 @@ PyObject* QuantityPy::number_add_handler(PyObject* self, PyObject* other)
PyObject* QuantityPy::number_subtract_handler(PyObject* self, PyObject* other)
{
Quantity *pa = nullptr, *pb = nullptr;
Quantity a, b;
Quantity* pa = nullptr;
Quantity* pb = nullptr;
Quantity a;
Quantity b;
PY_TRY
{
if (PyObject_TypeCheck(self, &(QuantityPy::Type))) {
@@ -391,8 +395,10 @@ PyObject* QuantityPy::number_subtract_handler(PyObject* self, PyObject* other)
PyObject* QuantityPy::number_multiply_handler(PyObject* self, PyObject* other)
{
Quantity *pa = nullptr, *pb = nullptr;
Quantity a, b;
Quantity* pa = nullptr;
Quantity* pb = nullptr;
Quantity a;
Quantity b;
PY_TRY
{
if (PyObject_TypeCheck(self, &(QuantityPy::Type))) {
@@ -415,8 +421,10 @@ PyObject* QuantityPy::number_multiply_handler(PyObject* self, PyObject* other)
PyObject* QuantityPy::number_divide_handler(PyObject* self, PyObject* other)
{
Quantity *pa = nullptr, *pb = nullptr;
Quantity a, b;
Quantity* pa = nullptr;
Quantity* pb = nullptr;
Quantity a;
Quantity b;
PY_TRY
{
if (PyObject_TypeCheck(self, &(QuantityPy::Type))) {
@@ -444,7 +452,8 @@ PyObject* QuantityPy::number_remainder_handler(PyObject* self, PyObject* other)
return nullptr;
}
double d1 {}, d2 {};
double d1 {};
double d2 {};
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
d1 = a->getValue();

View File

@@ -388,9 +388,16 @@ Rotation Rotation::operator*(const Rotation& q) const
Rotation& Rotation::multRight(const Base::Rotation& q)
{
// Taken from <http://de.wikipedia.org/wiki/Quaternionen>
double x0 {}, y0 {}, z0 {}, w0 {};
double x0 {};
double y0 {};
double z0 {};
double w0 {};
this->getValue(x0, y0, z0, w0);
double x1 {}, y1 {}, z1 {}, w1 {};
double x1 {};
double y1 {};
double z1 {};
double w1 {};
q.getValue(x1, y1, z1, w1);
this->setValue(w0 * x1 + x0 * w1 + y0 * z1 - z0 * y1,
@@ -409,9 +416,16 @@ Rotation& Rotation::multRight(const Base::Rotation& q)
Rotation& Rotation::multLeft(const Base::Rotation& q)
{
// Taken from <http://de.wikipedia.org/wiki/Quaternionen>
double x0 {}, y0 {}, z0 {}, w0 {};
double x0 {};
double y0 {};
double z0 {};
double w0 {};
q.getValue(x0, y0, z0, w0);
double x1 {}, y1 {}, z1 {}, w1 {};
double x1 {};
double y1 {};
double z1 {};
double w1 {};
this->getValue(x1, y1, z1, w1);
this->setValue(w0 * x1 + x0 * w1 + y0 * z1 - z0 * y1,
@@ -989,7 +1003,9 @@ void Rotation::setEulerAngles(EulerSequence theOrder,
theBeta *= D_PI / 180.0;
theGamma *= D_PI / 180.0;
double a = theAlpha, b = theBeta, c = theGamma;
double a = theAlpha;
double b = theBeta;
double c = theGamma;
if (!o.isExtrinsic) {
std::swap(a, c);
}

View File

@@ -117,14 +117,19 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
}
PyErr_Clear();
double q0 {}, q1 {}, q2 {}, q3 {};
double q0 {};
double q1 {};
double q2 {};
double q3 {};
if (PyArg_ParseTuple(args, "dddd", &q0, &q1, &q2, &q3)) {
getRotationPtr()->setValue(q0, q1, q2, q3);
return 0;
}
PyErr_Clear();
double y {}, p {}, r {};
double y {};
double p {};
double r {};
if (PyArg_ParseTuple(args, "ddd", &y, &p, &r)) {
getRotationPtr()->setYawPitchRoll(y, p, r);
return 0;
@@ -132,7 +137,9 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
PyErr_Clear();
const char* seq {};
double a {}, b {}, c {};
double a {};
double b {};
double c {};
if (PyArg_ParseTuple(args, "sddd", &seq, &a, &b, &c)) {
PY_TRY
{
@@ -142,10 +149,12 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
_PY_CATCH(return -1)
}
// NOLINTBEGIN
double a11 = 1.0, a12 = 0.0, a13 = 0.0, a14 = 0.0;
double a21 = 0.0, a22 = 1.0, a23 = 0.0, a24 = 0.0;
double a31 = 0.0, a32 = 0.0, a33 = 1.0, a34 = 0.0;
double a41 = 0.0, a42 = 0.0, a43 = 0.0, a44 = 1.0;
// NOLINTEND
// try read a 4x4 matrix
PyErr_Clear();
@@ -190,7 +199,8 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
}
PyErr_Clear();
PyObject *v1 {}, *v2 {};
PyObject* v1 {};
PyObject* v2 {};
if (PyArg_ParseTuple(args,
"O!O!",
&(Base::VectorPy::Type), &v1,
@@ -333,7 +343,9 @@ PyObject* RotationPy::slerp(PyObject* args)
PyObject* RotationPy::setYawPitchRoll(PyObject* args)
{
double A {}, B {}, C {};
double A {};
double B {};
double C {};
if (!PyArg_ParseTuple(args, "ddd", &A, &B, &C)) {
return nullptr;
}
@@ -346,7 +358,9 @@ PyObject* RotationPy::getYawPitchRoll(PyObject* args)
if (!PyArg_ParseTuple(args, "")) {
return nullptr;
}
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
Py::Tuple tuple(3);
@@ -359,7 +373,9 @@ PyObject* RotationPy::getYawPitchRoll(PyObject* args)
PyObject* RotationPy::setEulerAngles(PyObject* args)
{
const char* seq {};
double A {}, B {}, C {};
double A {};
double B {};
double C {};
if (!PyArg_ParseTuple(args, "sddd", &seq, &A, &B, &C)) {
return nullptr;
}
@@ -390,7 +406,9 @@ PyObject* RotationPy::toEulerAngles(PyObject* args)
PY_TRY
{
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getEulerAngles(Rotation::eulerSequenceFromName(seq), A, B, C);
Py::Tuple tuple(3);
@@ -446,7 +464,10 @@ PyObject* RotationPy::isNull(PyObject* args)
Py::Tuple RotationPy::getQ() const
{
double q0 {}, q1 {}, q2 {}, q3 {};
double q0 {};
double q1 {};
double q2 {};
double q3 {};
this->getRotationPtr()->getValue(q0, q1, q2, q3);
Py::Tuple tuple(4);
@@ -516,17 +537,23 @@ PyObject* RotationPy::getCustomAttributes(const char* attr) const
return new MatrixPy(mat);
}
if (strcmp(attr, "Yaw") == 0) {
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
return PyFloat_FromDouble(A);
}
if (strcmp(attr, "Pitch") == 0) {
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
return PyFloat_FromDouble(B);
}
if (strcmp(attr, "Roll") == 0) {
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
return PyFloat_FromDouble(C);
}
@@ -567,7 +594,9 @@ int RotationPy::setCustomAttributes(const char* attr, PyObject* obj)
else if (strcmp(attr, "Yaw") == 0) {
if (PyNumber_Check(obj)) {
double V = PyFloat_AsDouble(obj);
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
this->getRotationPtr()->setYawPitchRoll(V, B, C);
return 1;
@@ -576,7 +605,9 @@ int RotationPy::setCustomAttributes(const char* attr, PyObject* obj)
else if (strcmp(attr, "Pitch") == 0) {
if (PyNumber_Check(obj)) {
double V = PyFloat_AsDouble(obj);
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
this->getRotationPtr()->setYawPitchRoll(A, V, C);
return 1;
@@ -585,7 +616,9 @@ int RotationPy::setCustomAttributes(const char* attr, PyObject* obj)
else if (strcmp(attr, "Roll") == 0) {
if (PyNumber_Check(obj)) {
double V = PyFloat_AsDouble(obj);
double A {}, B {}, C {};
double A {};
double B {};
double C {};
this->getRotationPtr()->getYawPitchRoll(A, B, C);
this->getRotationPtr()->setYawPitchRoll(A, B, V);
return 1;

View File

@@ -35,7 +35,8 @@ using namespace Base;
double Vector2d::GetAngle(const Vector2d& vec) const
{
double fDivid = 0.0, fNum = 0.0;
double fDivid = 0.0;
double fNum = 0.0;
fDivid = Length() * vec.Length();
@@ -162,7 +163,10 @@ BoundBox2d Line2d::CalcBoundBox() const
bool Line2d::Intersect(const Line2d& rclLine, Vector2d& rclV) const
{
double m1 = 0.0, m2 = 0.0, b1 = 0.0, b2 = 0.0;
double m1 = 0.0;
double m2 = 0.0;
double b1 = 0.0;
double b2 = 0.0;
// calc coefficients
if (fabs(clV2.x - clV1.x) > 1e-10) {
@@ -254,14 +258,13 @@ BoundBox2d Polygon2d::CalcBoundBox() const
return clBB;
}
static short _CalcTorsion(double* pfLine, double fX, double fY)
static short _CalcTorsion(const double* pfLine, double fX, double fY)
{
int sQuad[2],
i = 0; // Changing this from short to int allows the compiler to inline this function
std::array<int, 2> sQuad;
double fResX = 0.0;
// Classification of both polygon points into quadrants
for (i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++) {
if (pfLine[i * 2] <= fX) {
sQuad[i] = (pfLine[i * 2 + 1] > fY) ? 0 : 3;
}

View File

@@ -367,10 +367,9 @@ template<class _Precision>
void Vector3<_Precision>::RotateX(_Precision f)
{
Vector3 cPt(*this);
_Precision fsin, fcos;
fsin = static_cast<_Precision>(sin(f));
fcos = static_cast<_Precision>(cos(f));
_Precision fsin = static_cast<_Precision>(sin(f));
_Precision fcos = static_cast<_Precision>(cos(f));
y = (cPt.y * fcos) - (cPt.z * fsin);
z = (cPt.y * fsin) + (cPt.z * fcos);
}
@@ -379,10 +378,9 @@ template<class _Precision>
void Vector3<_Precision>::RotateY(_Precision f)
{
Vector3 cPt(*this);
_Precision fsin, fcos;
fsin = static_cast<_Precision>(sin(f));
fcos = static_cast<_Precision>(cos(f));
_Precision fsin = static_cast<_Precision>(sin(f));
_Precision fcos = static_cast<_Precision>(cos(f));
x = (cPt.z * fsin) + (cPt.x * fcos);
z = (cPt.z * fcos) - (cPt.x * fsin);
}
@@ -391,10 +389,9 @@ template<class _Precision>
void Vector3<_Precision>::RotateZ(_Precision f)
{
Vector3 cPt(*this);
_Precision fsin, fcos;
fsin = static_cast<_Precision>(sin(f));
fcos = static_cast<_Precision>(cos(f));
_Precision fsin = static_cast<_Precision>(sin(f));
_Precision fcos = static_cast<_Precision>(cos(f));
x = (cPt.x * fcos) - (cPt.y * fsin);
y = (cPt.x * fsin) + (cPt.y * fcos);
}
@@ -446,7 +443,10 @@ void Vector3<_Precision>::TransformToCoordinateSystem(const Vector3& rclBase,
const Vector3& rclDirX,
const Vector3& rclDirY)
{
Vector3 clVectX, clVectY, clVectZ, clVectOld;
Vector3 clVectX;
Vector3 clVectY;
Vector3 clVectZ;
Vector3 clVectOld;
clVectX = rclDirX;
clVectY = rclDirY;

View File

@@ -253,7 +253,9 @@ public:
template<class _Precision>
inline _Precision Distance(const Vector3<_Precision>& v1, const Vector3<_Precision>& v2)
{
_Precision x = v1.x - v2.x, y = v1.y - v2.y, z = v1.z - v2.z;
_Precision x = v1.x - v2.x;
_Precision y = v1.y - v2.y;
_Precision z = v1.z - v2.z;
return static_cast<_Precision>(sqrt((x * x) + (y * y) + (z * z)));
}
@@ -261,7 +263,9 @@ inline _Precision Distance(const Vector3<_Precision>& v1, const Vector3<_Precisi
template<class _Precision>
inline _Precision DistanceP2(const Vector3<_Precision>& v1, const Vector3<_Precision>& v2)
{
_Precision x = v1.x - v2.x, y = v1.y - v2.y, z = v1.z - v2.z;
_Precision x = v1.x - v2.x;
_Precision y = v1.y - v2.y;
_Precision z = v1.z - v2.z;
return x * x + y * y + z * z;
}

View File

@@ -61,7 +61,9 @@ PyObject* VectorPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObj
// constructor method
int VectorPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
double x = 0.0, y = 0.0, z = 0.0;
double x = 0.0;
double y = 0.0;
double z = 0.0;
PyObject* object = nullptr;
VectorPy::PointerType ptr = getVectorPtr();
if (PyArg_ParseTuple(args, "|ddd", &x, &y, &z)) {
@@ -242,7 +244,12 @@ PyObject* VectorPy::mapping_subscript(PyObject* self, PyObject* item)
return sequence_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start = 0, stop = 0, step = 0, slicelength = 0, cur = 0, i = 0;
Py_ssize_t start = 0;
Py_ssize_t stop = 0;
Py_ssize_t step = 0;
Py_ssize_t slicelength = 0;
Py_ssize_t cur = 0;
Py_ssize_t i = 0;
PyObject* slice = item;
if (PySlice_GetIndicesEx(slice, sequence_length(self), &start, &stop, &step, &slicelength)
@@ -372,7 +379,9 @@ PyObject* VectorPy::isEqual(PyObject* args)
PyObject* VectorPy::scale(PyObject* args)
{
double factorX = 0.0, factorY = 0.0, factorZ = 0.0;
double factorX = 0.0;
double factorY = 0.0;
double factorZ = 0.0;
if (!PyArg_ParseTuple(args, "ddd", &factorX, &factorY, &factorZ)) {
return nullptr;
}
@@ -428,7 +437,8 @@ PyObject* VectorPy::cross(PyObject* args)
PyObject* VectorPy::isOnLineSegment(PyObject* args)
{
PyObject *start = nullptr, *end = nullptr;
PyObject* start = nullptr;
PyObject* end = nullptr;
if (!PyArg_ParseTuple(args, "OO", &start, &end)) {
return nullptr;
}
@@ -487,7 +497,8 @@ PyObject* VectorPy::normalize(PyObject* args)
PyObject* VectorPy::projectToLine(PyObject* args)
{
PyObject *base = nullptr, *line = nullptr;
PyObject* base = nullptr;
PyObject* line = nullptr;
if (!PyArg_ParseTuple(args, "OO", &base, &line)) {
return nullptr;
}
@@ -514,7 +525,8 @@ PyObject* VectorPy::projectToLine(PyObject* args)
PyObject* VectorPy::projectToPlane(PyObject* args)
{
PyObject *base = nullptr, *line = nullptr;
PyObject* base = nullptr;
PyObject* line = nullptr;
if (!PyArg_ParseTuple(args, "OO", &base, &line)) {
return nullptr;
}
@@ -556,7 +568,8 @@ PyObject* VectorPy::distanceToPoint(PyObject* args)
PyObject* VectorPy::distanceToLine(PyObject* args)
{
PyObject *base = nullptr, *line = nullptr;
PyObject* base = nullptr;
PyObject* line = nullptr;
if (!PyArg_ParseTuple(args, "OO", &base, &line)) {
return nullptr;
}
@@ -582,7 +595,8 @@ PyObject* VectorPy::distanceToLine(PyObject* args)
PyObject* VectorPy::distanceToLineSegment(PyObject* args)
{
PyObject *base = nullptr, *line = nullptr;
PyObject* base = nullptr;
PyObject* line = nullptr;
if (!PyArg_ParseTuple(args, "OO", &base, &line)) {
return nullptr;
}
@@ -608,7 +622,8 @@ PyObject* VectorPy::distanceToLineSegment(PyObject* args)
PyObject* VectorPy::distanceToPlane(PyObject* args)
{
PyObject *base = nullptr, *line = nullptr;
PyObject* base = nullptr;
PyObject* line = nullptr;
if (!PyArg_ParseTuple(args, "OO", &base, &line)) {
return nullptr;
}