Base: C++ core guidelines: init variables

This commit is contained in:
wmayer
2023-08-24 14:21:05 +02:00
committed by wwmayer
parent 53a4fb14c3
commit 010dca8303
43 changed files with 622 additions and 626 deletions

View File

@@ -55,7 +55,7 @@ PyObject *AxisPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Pytho
// constructor method
int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject* o;
PyObject* o{};
if (PyArg_ParseTuple(args, "")) {
return 0;
}
@@ -68,7 +68,7 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
PyObject* d;
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.
@@ -83,7 +83,7 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* AxisPy::move(PyObject * args)
{
PyObject *vec;
PyObject *vec{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec))
return nullptr;
getAxisPtr()->move(static_cast<VectorPy*>(vec)->value());
@@ -92,7 +92,7 @@ PyObject* AxisPy::move(PyObject * args)
PyObject* AxisPy::multiply(PyObject * args)
{
PyObject *plm;
PyObject *plm{};
if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm))
return nullptr;
Axis mult = (*getAxisPtr()) * (*static_cast<PlacementPy*>(plm)->getPlacementPtr());
@@ -116,7 +116,7 @@ PyObject* AxisPy::reversed(PyObject * args)
Py::Object AxisPy::getBase() const
{
return Py::Vector(getAxisPtr()->getBase());
return Py::Vector(getAxisPtr()->getBase()); // NOLINT
}
void AxisPy::setBase(Py::Object arg)
@@ -126,7 +126,7 @@ void AxisPy::setBase(Py::Object arg)
Py::Object AxisPy::getDirection() const
{
return Py::Vector(getAxisPtr()->getDirection());
return Py::Vector(getAxisPtr()->getDirection()); // NOLINT
}
void AxisPy::setDirection(Py::Object arg)

View File

@@ -38,7 +38,7 @@ std::string BaseClassPy::representation() const
PyObject* BaseClassPy::isDerivedFrom(PyObject *args)
{
char *name;
char *name{};
if (!PyArg_ParseTuple(args, "s", &name))
return nullptr;

View File

@@ -172,7 +172,7 @@ public:
*/
BoundBox3<_Precision> Transformed(const Matrix4D& mat) const;
/** Returns the center.of the box. */
/** Returns the center of the box. */
inline Vector3<_Precision> GetCenter () const;
/** Compute the diagonal length of this bounding box.
* @note It's up to the client programmer to make sure that this bounding box is valid.
@@ -180,9 +180,9 @@ public:
inline _Precision CalcDiagonalLength () const;
void SetVoid ();
/** Enlarges the box with factor \a fLen. */
/** Enlarges the box with \a fLen. */
inline void Enlarge (_Precision fLen);
/** Shrinks the box with factor \a fLen. */
/** Shrinks the box with \a fLen. */
inline void Shrink (_Precision fLen);
/** Calculates expansion in x-direction. */
@@ -240,7 +240,7 @@ inline BoundBox3<_Precision>::BoundBox3 (const Vector3<_Precision> *pclVect, uns
, MaxY(-std::numeric_limits<_Precision>::max())
, MaxZ(-std::numeric_limits<_Precision>::max())
{
const Vector3<_Precision> *pI, *pEnd = pclVect + ulCt;
const Vector3<_Precision> *pI = nullptr, *pEnd = pclVect + ulCt;
for (pI = pclVect; pI < pEnd; ++pI) {
MinX = std::min<_Precision>(MinX, pI->x);
MinY = std::min<_Precision>(MinY, pI->y);
@@ -596,7 +596,7 @@ inline bool BoundBox3<_Precision>::IntersectionPoint (const Vector3<_Precision>
{
bool rc=false;
BoundBox3<_Precision> cCmpBound(*this);
unsigned short i;
unsigned short i{};
// enlarge bounding box by epsilon
cCmpBound.Enlarge(epsilon);
@@ -637,7 +637,7 @@ inline bool BoundBox3<_Precision>::IsCutLine (const Vector3<_Precision>& rcBase,
return false;
}
else { // more detailed test here
unsigned char i;
unsigned char i{};
Vector3<_Precision> clVectRes;
// intersect each face with the line

View File

@@ -63,7 +63,7 @@ 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;
PyObject *object1, *object2;
PyObject *object1{}, *object2{};
BoundBoxPy::PointerType ptr = getBoundBoxPtr();
if (PyArg_ParseTuple(args, "d|ddddd", &xMin, &yMin, &zMin, &xMax, &yMax, &zMax)) {
ptr->MaxX = xMax;
@@ -125,8 +125,8 @@ PyObject* BoundBoxPy::isValid(PyObject *args)
PyObject* BoundBoxPy::add(PyObject *args)
{
double x,y,z;
PyObject *object;
double x{},y{},z{};
PyObject *object{};
if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) {
getBoundBoxPtr()->Add(Vector3d(x,y,z));
Py_Return;
@@ -156,7 +156,7 @@ PyObject* BoundBoxPy::add(PyObject *args)
PyObject* BoundBoxPy::getPoint(PyObject *args)
{
unsigned short index;
unsigned short index{};
if (!PyArg_ParseTuple(args,"H",&index))
return nullptr;
@@ -171,7 +171,7 @@ PyObject* BoundBoxPy::getPoint(PyObject *args)
PyObject* BoundBoxPy::getEdge(PyObject *args)
{
unsigned short index;
unsigned short index{};
if (!PyArg_ParseTuple(args,"H",&index))
return nullptr;
@@ -190,8 +190,8 @@ PyObject* BoundBoxPy::getEdge(PyObject *args)
PyObject* BoundBoxPy::closestPoint(PyObject *args)
{
double x,y,z;
PyObject *object;
double x{},y{},z{};
PyObject *object{};
Base::Vector3d vec;
@@ -225,7 +225,7 @@ PyObject* BoundBoxPy::closestPoint(PyObject *args)
PyObject* BoundBoxPy::intersect(PyObject *args)
{
PyObject *object,*object2;
PyObject *object{},*object2{};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -267,7 +267,7 @@ PyObject* BoundBoxPy::intersected(PyObject *args)
return nullptr;
}
PyObject *object;
PyObject *object{};
if (!PyArg_ParseTuple(args,"O!",&(Base::BoundBoxPy::Type), &object))
return nullptr;
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
@@ -286,7 +286,7 @@ PyObject* BoundBoxPy::united(PyObject *args)
return nullptr;
}
PyObject *object;
PyObject *object{};
if (!PyArg_ParseTuple(args,"O!",&(Base::BoundBoxPy::Type), &object))
return nullptr;
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
@@ -300,7 +300,7 @@ PyObject* BoundBoxPy::united(PyObject *args)
PyObject* BoundBoxPy::enlarge(PyObject *args)
{
double s;
double s{};
if (!PyArg_ParseTuple(args, "d;Need float parameter to enlarge", &s))
return nullptr;
getBoundBoxPtr()->Enlarge(s);
@@ -309,7 +309,7 @@ PyObject* BoundBoxPy::enlarge(PyObject *args)
PyObject* BoundBoxPy::getIntersectionPoint(PyObject *args)
{
PyObject *object,*object2;
PyObject *object{},*object2{};
double epsilon=0.0001;
if (!PyArg_ParseTuple(args,"O!O!|d;Need base and direction vector",
&(Base::VectorPy::Type), &object,&(Base::VectorPy::Type), &object2, &epsilon))
@@ -331,8 +331,8 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject *args)
PyObject* BoundBoxPy::move(PyObject *args)
{
double x,y,z;
PyObject *object;
double x{},y{},z{};
PyObject *object{};
Base::Vector3d vec;
@@ -369,8 +369,8 @@ PyObject* BoundBoxPy::move(PyObject *args)
PyObject* BoundBoxPy::scale(PyObject *args)
{
double x,y,z;
PyObject *object;
double x{},y{},z{};
PyObject *object{};
Base::Vector3d vec;
@@ -407,7 +407,7 @@ PyObject* BoundBoxPy::scale(PyObject *args)
PyObject* BoundBoxPy::transformed(PyObject *args)
{
PyObject *mat;
PyObject *mat{};
if (!PyArg_ParseTuple(args,"O!", &(Base::MatrixPy::Type), &mat))
return nullptr;
@@ -420,7 +420,7 @@ PyObject* BoundBoxPy::transformed(PyObject *args)
PyObject* BoundBoxPy::isCutPlane(PyObject *args)
{
PyObject *object,*object2;
PyObject *object{},*object2{};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -441,8 +441,8 @@ PyObject* BoundBoxPy::isCutPlane(PyObject *args)
PyObject* BoundBoxPy::isInside(PyObject *args)
{
double x,y,z;
PyObject *object;
double x{},y{},z{};
PyObject *object{};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -488,7 +488,7 @@ PyObject* BoundBoxPy::isInside(PyObject *args)
Py::Object BoundBoxPy::getCenter() const
{
return Py::Vector(getBoundBoxPtr()->GetCenter());
return Py::Vector(getBoundBoxPtr()->GetCenter()); // NOLINT
}
Py::Float BoundBoxPy::getXMax() const

View File

@@ -294,7 +294,7 @@ void ConsoleSingleton::postEvent(ConsoleSingleton::FreeCAD_ConsoleMsgType type,
ILogger *ConsoleSingleton::Get(const char *Name) const
{
const char* OName;
const char* OName{};
for (ILogger* Iter : _aclObservers) {
OName = Iter->Name(); // get the name
if (OName && strcmp(OName,Name) == 0)
@@ -424,8 +424,8 @@ PyMethodDef ConsoleSingleton::Methods[] = {
namespace {
PyObject* FC_PYCONSOLE_MSG(std::function<void(const char*, const char *)> func, PyObject* args)
{
PyObject *output;
PyObject *notifier;
PyObject *output{};
PyObject *notifier{};
const char* notifierStr = "";
@@ -592,8 +592,8 @@ PyObject *ConsoleSingleton::sPyTranslatedNotification(PyObject * /*self*/, PyObj
PyObject *ConsoleSingleton::sPyGetStatus(PyObject * /*self*/, PyObject *args)
{
char *pstr1;
char *pstr2;
char *pstr1{};
char *pstr2{};
if (!PyArg_ParseTuple(args, "ss", &pstr1, &pstr2))
return nullptr;
@@ -625,9 +625,9 @@ PyObject *ConsoleSingleton::sPyGetStatus(PyObject * /*self*/, PyObject *args)
PyObject *ConsoleSingleton::sPySetStatus(PyObject * /*self*/, PyObject *args)
{
char *pstr1;
char *pstr2;
PyObject* pyStatus;
char *pstr1{};
char *pstr2{};
PyObject* pyStatus{};
if (!PyArg_ParseTuple(args, "ssO!", &pstr1, &pstr2, &PyBool_Type, &pyStatus))
return nullptr;

View File

@@ -64,7 +64,7 @@ struct vec_traits<Rotation> {
using float_type = double;
vec_traits(const vec_type& v) : v(v){}
inline std::tuple<float_type,float_type,float_type,float_type> get() const {
float_type q1,q2,q3,q4;
float_type q1{},q2{},q3{},q4{};
v.getValue(q1,q2,q3,q4);
return std::make_tuple(q1, q2, q3, q4);
}

View File

@@ -52,7 +52,7 @@ int CoordinateSystemPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
PyObject* CoordinateSystemPy::setAxes(PyObject * args)
{
PyObject *axis, *xdir;
PyObject *axis{}, *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());
@@ -72,7 +72,7 @@ PyObject* CoordinateSystemPy::setAxes(PyObject * args)
PyObject* CoordinateSystemPy::displacement(PyObject * args)
{
PyObject *cs;
PyObject *cs{};
if (!PyArg_ParseTuple(args, "O!", &(CoordinateSystemPy::Type), &cs))
return nullptr;
Placement p = getCoordinateSystemPtr()->displacement(
@@ -82,7 +82,7 @@ PyObject* CoordinateSystemPy::displacement(PyObject * args)
PyObject* CoordinateSystemPy::transformTo(PyObject * args)
{
PyObject *vec;
PyObject *vec{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec))
return nullptr;
Vector3d v = static_cast<VectorPy*>(vec)->value();
@@ -92,7 +92,7 @@ PyObject* CoordinateSystemPy::transformTo(PyObject * args)
PyObject* CoordinateSystemPy::transform(PyObject * args)
{
PyObject *plm;
PyObject *plm{};
if (PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm)) {
getCoordinateSystemPtr()->transform(*static_cast<PlacementPy*>(plm)->getPlacementPtr());
Py_Return;
@@ -110,7 +110,7 @@ PyObject* CoordinateSystemPy::transform(PyObject * args)
PyObject* CoordinateSystemPy::setPlacement(PyObject * args)
{
PyObject *plm;
PyObject *plm{};
if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm))
return nullptr;
getCoordinateSystemPtr()->setPlacement(*static_cast<PlacementPy*>(plm)->getPlacementPtr());
@@ -136,7 +136,7 @@ void CoordinateSystemPy::setAxis(Py::Object arg)
Py::Object CoordinateSystemPy::getXDirection() const
{
return Py::Vector(getCoordinateSystemPtr()->getXDirection());
return Py::Vector(getCoordinateSystemPtr()->getXDirection()); // NOLINT
}
void CoordinateSystemPy::setXDirection(Py::Object arg)
@@ -146,7 +146,7 @@ void CoordinateSystemPy::setXDirection(Py::Object arg)
Py::Object CoordinateSystemPy::getYDirection() const
{
return Py::Vector(getCoordinateSystemPtr()->getYDirection());
return Py::Vector(getCoordinateSystemPtr()->getYDirection()); // NOLINT
}
void CoordinateSystemPy::setYDirection(Py::Object arg)
@@ -156,7 +156,7 @@ void CoordinateSystemPy::setYDirection(Py::Object arg)
Py::Object CoordinateSystemPy::getZDirection() const
{
return Py::Vector(getCoordinateSystemPtr()->getZDirection());
return Py::Vector(getCoordinateSystemPtr()->getZDirection()); // NOLINT
}
void CoordinateSystemPy::setZDirection(Py::Object arg)
@@ -166,7 +166,7 @@ void CoordinateSystemPy::setZDirection(Py::Object arg)
Py::Object CoordinateSystemPy::getPosition() const
{
return Py::Vector(getCoordinateSystemPtr()->getPosition());
return Py::Vector(getCoordinateSystemPtr()->getPosition()); // NOLINT
}
void CoordinateSystemPy::setPosition(Py::Object arg)

View File

@@ -80,7 +80,7 @@ const char* Exception::what() const noexcept
void Exception::ReportException () const
{
if (!_isReported) {
const char *msg;
const char *msg{};
if (_sErrMsg.empty())
msg = typeid(*this).name();
else
@@ -304,7 +304,7 @@ const char* FileException::what() const noexcept
void FileException::ReportException () const
{
if (!_isReported) {
const char *msg;
const char *msg{};
if (_sErrMsgAndFileName.empty())
msg = typeid(*this).name();
else

View File

@@ -248,7 +248,7 @@ std::string FileInfo::fileName() const
std::string FileInfo::dirPath() const
{
std::size_t last_pos;
std::size_t last_pos{};
std::string retval;
last_pos = FileName.find_last_of('/');
if (last_pos != std::string::npos) {
@@ -411,7 +411,7 @@ bool FileInfo::isDir() const
return ((st.st_mode & _S_IFDIR) != 0);
#elif defined (FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st;
struct stat st{};
if (stat(FileName.c_str(), &st) != 0) {
return false;
}
@@ -447,7 +447,7 @@ TimeInfo FileInfo::lastModified() const
}
#elif defined (FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st;
struct stat st{};
if (stat(FileName.c_str(), &st) == 0) {
ti.setTime_t(st.st_mtime);
}
@@ -470,7 +470,7 @@ TimeInfo FileInfo::lastRead() const
}
#elif defined (FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st;
struct stat st{};
if (stat(FileName.c_str(), &st) == 0) {
ti.setTime_t(st.st_atime);
}
@@ -494,7 +494,7 @@ bool FileInfo::deleteFile() const
bool FileInfo::renameFile(const char* NewName)
{
bool res;
bool res{};
#if defined (FC_OS_WIN32)
std::wstring oldname = toStdWString();
std::wstring newname = ConvertToWideString(NewName);

View File

@@ -48,8 +48,10 @@ PyException::PyException(const Py::Object &obj) {
// WARNING: we are assuming that python type object will never be
// destroyed, so we don't keep reference here to save book-keeping in
// our copy constructor and destructor
// NOLINTBEGIN
_exceptionType = reinterpret_cast<PyObject*>(obj.ptr()->ob_type);
_errorType = obj.ptr()->ob_type->tp_name;
// NOLINTEND
}
PyException::PyException()
@@ -73,6 +75,7 @@ PyException::PyException()
_sErrMsg = error;
_errorType = prefix;
// NOLINTNEXTLINE
_exceptionType = PP_last_exception_type;
if (PP_last_exception_type) {
@@ -160,7 +163,7 @@ SystemExitException::SystemExitException()
long int errCode = 1;
std::string errMsg = "System exit";
PyObject *type, *value, *traceback, *code;
PyObject *type{}, *value{}, *traceback{}, *code{};
PyGILStateLocker locker;
PyErr_Fetch(&type, &value, &traceback);
@@ -190,6 +193,7 @@ SystemExitException::SystemExitException()
// ---------------------------------------------------------
// Fixes #0000831: python print causes File descriptor error on windows
// NOLINTNEXTLINE
class PythonStdOutput : public Py::PythonExtension<PythonStdOutput>
{
public:
@@ -226,7 +230,7 @@ InterpreterSingleton::~InterpreterSingleton() = default;
std::string InterpreterSingleton::runString(const char *sCmd)
{
PyObject *module, *dict, *presult; /* "exec code in d, d" */
PyObject *module{}, *dict{}, *presult{}; /* "exec code in d, d" */
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */
@@ -303,7 +307,7 @@ std::string InterpreterSingleton::runStringWithKey(const char *psCmd, const char
Py::Object InterpreterSingleton::runStringObject(const char *sCmd)
{
PyObject *module, *dict, *presult; /* "exec code in d, d" */
PyObject *module{}, *dict{}, *presult{}; /* "exec code in d, d" */
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */
@@ -328,13 +332,13 @@ 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{}, *value{}, *tb{};
int exitcode = 0;
PyErr_Fetch(&exception, &value, &tb);
fflush(stdout);
if (!value || value == Py_None)
goto done;
goto done; // NOLINT
if (PyExceptionInstance_Check(value)) {
/* The error code should be in the `code' attribute. */
PyObject *code = PyObject_GetAttrString(value, "code");
@@ -342,7 +346,7 @@ void InterpreterSingleton::systemExit()
Py_DECREF(value);
value = code;
if (value == Py_None)
goto done;
goto done; // NOLINT
}
/* If we failed to dig out the 'code' attribute,
just let the else clause below print the error. */
@@ -369,7 +373,7 @@ done:
void InterpreterSingleton::runInteractiveString(const char *sCmd)
{
PyObject *module, *dict, *presult; /* "exec code in d, d" */
PyObject *module{}, *dict{}, *presult{}; /* "exec code in d, d" */
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */
@@ -386,7 +390,7 @@ 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{}, *errdata{}, *errtraceback{};
PyErr_Fetch(&errobj, &errdata, &errtraceback);
RuntimeError exc(""); // do not use PyException since this clears the error indicator
@@ -416,7 +420,7 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local)
//std::string encoding = PyUnicode_GetDefaultEncoding();
//PyUnicode_SetDefaultEncoding("utf-8");
//PyUnicode_SetDefaultEncoding(encoding.c_str());
PyObject *module, *dict;
PyObject *module{}, *dict{};
module = PyImport_AddModule("__main__");
dict = PyModule_GetDict(module);
if (local) {
@@ -463,7 +467,7 @@ bool InterpreterSingleton::loadModule(const char* psModName)
{
// buffer acrobatics
//PyBuf ModName(psModName);
PyObject *module;
PyObject *module{};
PyGILStateLocker locker;
module = PP_Load_Module(psModName);
@@ -698,7 +702,7 @@ void InterpreterSingleton::runMethodVoid(PyObject *pobject, const char *method)
PyObject* InterpreterSingleton::runMethodObject(PyObject *pobject, const char *method)
{
PyObject *pcO;
PyObject *pcO{};
PyGILStateLocker locker;
if (PP_Run_Method(pobject , // object
@@ -716,7 +720,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
const char *resfmt, void *cresult, /* convert to c/c++ */
const char *argfmt, ... ) /* convert to python */
{
PyObject *pmeth, *pargs, *presult;
PyObject *pmeth{}, *pargs{}, *presult{};
va_list argslist; /* "pobject.method(args)" */
va_start(argslist, argfmt);
@@ -752,7 +756,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
PyObject * InterpreterSingleton::getValue(const char * key, const char * result_var)
{
PyObject *module, *dict, *presult; /* "exec code in d, d" */
PyObject *module{}, *dict{}, *presult{}; /* "exec code in d, d" */
PyGILStateLocker locker;
module = PP_Load_Module("__main__"); /* get module, init python */

View File

@@ -188,7 +188,7 @@ void Matrix4D::scale (const Vector3d& rclVct)
void Matrix4D::rotX (double fAngle)
{
Matrix4D clMat;
double fsin, fcos;
double fsin{}, fcos{};
fsin = sin (fAngle);
fcos = cos (fAngle);
@@ -201,7 +201,7 @@ void Matrix4D::rotX (double fAngle)
void Matrix4D::rotY (double fAngle)
{
Matrix4D clMat;
double fsin, fcos;
double fsin{}, fcos{};
fsin = sin (fAngle);
fcos = cos (fAngle);
@@ -214,7 +214,7 @@ void Matrix4D::rotY (double fAngle)
void Matrix4D::rotZ (double fAngle)
{
Matrix4D clMat;
double fsin, fcos;
double fsin{}, fcos{};
fsin = sin (fAngle);
fcos = cos (fAngle);
@@ -229,8 +229,8 @@ void Matrix4D::rotLine(const Vector3d& rclVct, double fAngle)
// **** algorithm was taken from a math book
Matrix4D clMA, clMB, clMC, clMRot;
Vector3d clRotAxis(rclVct);
short iz, is;
double fcos, fsin;
short iz{}, is{};
double fcos{}, fsin{};
// set all entries to "0"
for (iz = 0; iz < 4; iz++) {
@@ -383,7 +383,7 @@ bool Matrix4D::toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& rfAngle
else
{
// angle is PI
double fHalfInverse;
double fHalfInverse{};
if ( dMtrx4D[0][0] >= dMtrx4D[1][1] )
{
// r00 >= r11
@@ -472,7 +472,7 @@ void Matrix4D::transform (const Vector3d& rclVct, const Matrix4D& rclMtrx)
void Matrix4D::inverse ()
{
Matrix4D clInvTrlMat, clInvRotMat;
short iz, is;
short iz{}, is{};
/**** Herausnehmen und Inversion der TranslationsMatrix
aus der TransformationMatrix ****/
@@ -494,10 +494,10 @@ using Matrix = double *;
void Matrix_gauss(Matrix a, Matrix b)
{
int ipiv[4], indxr[4], indxc[4];
int i,j,k,l,ll;
int i{},j{},k{},l{},ll{};
int irow=0, icol=0;
double big, pivinv;
double dum;
double big{}, pivinv{};
double dum{};
for (j = 0; j < 4; j++)
ipiv[j] = 0;
for (i = 0; i < 4; i++) {
@@ -587,38 +587,38 @@ void Matrix4D::inverseGauss ()
void Matrix4D::getMatrix (double dMtrx[16]) const
{
short iz, is;
for (iz = 0; iz < 4; iz++)
for (is = 0; is < 4; is++)
dMtrx[ 4*iz + is ] = dMtrx4D[iz][is];
for (short iz = 0; iz < 4; iz++) {
for (short is = 0; is < 4; is++) {
dMtrx[ 4*iz + is ] = dMtrx4D[iz][is];
}
}
}
void Matrix4D::setMatrix (const double dMtrx[16])
{
short iz, is;
for (iz = 0; iz < 4; iz++)
for (is = 0; is < 4; is++)
dMtrx4D[iz][is] = dMtrx[ 4*iz + is ];
for (short iz = 0; iz < 4; iz++) {
for (short is = 0; is < 4; is++) {
dMtrx4D[iz][is] = dMtrx[ 4*iz + is ];
}
}
}
void Matrix4D::getGLMatrix (double dMtrx[16]) const
{
short iz, is;
for (iz = 0; iz < 4; iz++)
for (is = 0; is < 4; is++)
dMtrx[ iz + 4*is ] = dMtrx4D[iz][is];
for (short iz = 0; iz < 4; iz++) {
for (short is = 0; is < 4; is++) {
dMtrx[ iz + 4*is ] = dMtrx4D[iz][is];
}
}
}
void Matrix4D::setGLMatrix (const double dMtrx[16])
{
short iz, is;
for (iz = 0; iz < 4; iz++)
for (is = 0; is < 4; is++)
dMtrx4D[iz][is] = dMtrx[ iz + 4*is ];
for (short iz = 0; iz < 4; iz++) {
for (short is = 0; is < 4; is++) {
dMtrx4D[iz][is] = dMtrx[ iz + 4*is ];
}
}
}
unsigned long Matrix4D::getMemSpace ()
@@ -637,15 +637,15 @@ void Matrix4D::Print () const
void Matrix4D::transpose ()
{
double dNew[4][4];
double dNew[4][4];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
dNew[j][i] = dMtrx4D[i][j];
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
dNew[j][i] = dMtrx4D[i][j];
}
}
memcpy(dMtrx4D, dNew, sizeof(dMtrx4D));
memcpy(dMtrx4D, dNew, sizeof(dMtrx4D));
}

View File

@@ -45,325 +45,317 @@ enum class ScaleType {
/**
* The Matrix4D class.
*/
class BaseExport Matrix4D
class BaseExport Matrix4D //NOLINT(cppcoreguidelines-special-member-functions)
{
using traits_type = float_traits<double>;
using traits_type = float_traits<double>;
public:
/// Default constructor
/*!
* Initialises to an identity matrix
*/
Matrix4D();
/// Default constructor
/*!
* Initialises to an identity matrix
*/
Matrix4D();
/// Construction
Matrix4D (float a11, float a12, float a13, float a14,
float a21, float a22, float a23, float a24,
float a31, float a32, float a33, float a34,
float a41, float a42, float a43, float a44 );
/// Construction
Matrix4D (double a11, double a12, double a13, double a14,
double a21, double a22, double a23, double a24,
double a31, double a32, double a33, double a34,
double a41, double a42, double a43, double a44 );
/// Construction
Matrix4D (const Matrix4D& rclMtrx);
/// Construction with an Axis
Matrix4D (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle);
Matrix4D (const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
/// Destruction
~Matrix4D () = default;
/// Construction
Matrix4D (float a11, float a12, float a13, float a14,
float a21, float a22, float a23, float a24,
float a31, float a32, float a33, float a34,
float a41, float a42, float a43, float a44 );
/// Construction
Matrix4D (double a11, double a12, double a13, double a14,
double a21, double a22, double a23, double a24,
double a31, double a32, double a33, double a34,
double a41, double a42, double a43, double a44 );
/// Construction
Matrix4D (const Matrix4D& rclMtrx);
/// Construction with an Axis
Matrix4D (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle);
Matrix4D (const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
/// Destruction
~Matrix4D () = default;
/** @name Operators */
//@{
/// Matrix addition
inline Matrix4D operator + (const Matrix4D& rclMtrx) const;
inline Matrix4D& operator += (const Matrix4D& rclMtrx);
/// Matrix subtraction
inline Matrix4D operator - (const Matrix4D& rclMtrx) const;
inline Matrix4D& operator -= (const Matrix4D& rclMtrx);
/// Matrix multiplication
inline Matrix4D& operator *= (const Matrix4D& rclMtrx);
/// Assignment
inline Matrix4D& operator = (const Matrix4D& rclMtrx);
/// Matrix multiplication
inline Matrix4D operator * (const Matrix4D& rclMtrx) const;
/// Multiplication matrix with vector
inline Vector3f operator * (const Vector3f& rclVct) const;
inline Vector3d operator * (const Vector3d& rclVct) const;
inline void multVec(const Vector3d & src, Vector3d & dst) const;
inline void multVec(const Vector3f & src, Vector3f & dst) const;
inline Matrix4D operator * (double) const;
inline Matrix4D& operator *= (double);
/// Comparison
inline bool operator != (const Matrix4D& rclMtrx) const;
/// Comparison
inline bool operator == (const Matrix4D& rclMtrx) const;
/// Index operator
inline double* operator [] (unsigned short usNdx);
/// Index operator
inline const double* operator[] (unsigned short usNdx) const;
/// Get vector of row
inline Vector3d getRow(unsigned short usNdx) const;
/// Get vector of column
inline Vector3d getCol(unsigned short usNdx) const;
/// Get vector of trace
inline Vector3d trace() const;
/// Set row to vector
inline void setRow(unsigned short usNdx, const Vector3d&);
/// Set column to vector
inline void setCol(unsigned short usNdx, const Vector3d&);
/// Set trace to vector
inline void setTrace(const Vector3d&);
/// Compute the determinant of the matrix
double determinant() const;
/// Compute the determinant of the 3x3 sub-matrix
double determinant3() const;
/// Analyse the transformation
std::string analyse() const;
/// Outer product (Dyadic product)
Matrix4D& Outer(const Vector3f& rV1, const Vector3f& rV2);
Matrix4D& Outer(const Vector3d& rV1, const Vector3d& rV2);
/// Hat operator (skew symmetric)
Matrix4D& Hat(const Vector3f& rV);
Matrix4D& Hat(const Vector3d& rV);
//@}
/** @name Operators */
//@{
/// Matrix addition
inline Matrix4D operator + (const Matrix4D& rclMtrx) const;
inline Matrix4D& operator += (const Matrix4D& rclMtrx);
/// Matrix subtraction
inline Matrix4D operator - (const Matrix4D& rclMtrx) const;
inline Matrix4D& operator -= (const Matrix4D& rclMtrx);
/// Matrix multiplication
inline Matrix4D& operator *= (const Matrix4D& rclMtrx);
/// Assignment
inline Matrix4D& operator = (const Matrix4D& rclMtrx);
/// Matrix multiplication
inline Matrix4D operator * (const Matrix4D& rclMtrx) const;
/// Multiplication matrix with vector
inline Vector3f operator * (const Vector3f& rclVct) const;
inline Vector3d operator * (const Vector3d& rclVct) const;
inline void multVec(const Vector3d & src, Vector3d & dst) const;
inline void multVec(const Vector3f & src, Vector3f & dst) const;
inline Matrix4D operator * (double) const;
inline Matrix4D& operator *= (double);
/// Comparison
inline bool operator != (const Matrix4D& rclMtrx) const;
/// Comparison
inline bool operator == (const Matrix4D& rclMtrx) const;
/// Index operator
inline double* operator [] (unsigned short usNdx);
/// Index operator
inline const double* operator[] (unsigned short usNdx) const;
/// Get vector of row
inline Vector3d getRow(unsigned short usNdx) const;
/// Get vector of column
inline Vector3d getCol(unsigned short usNdx) const;
/// Get vector of trace
inline Vector3d trace() const;
/// Set row to vector
inline void setRow(unsigned short usNdx, const Vector3d&);
/// Set column to vector
inline void setCol(unsigned short usNdx, const Vector3d&);
/// Set trace to vector
inline void setTrace(const Vector3d&);
/// Compute the determinant of the matrix
double determinant() const;
/// Compute the determinant of the 3x3 sub-matrix
double determinant3() const;
/// Analyse the transformation
std::string analyse() const;
/// Outer product (Dyadic product)
Matrix4D& Outer(const Vector3f& rV1, const Vector3f& rV2);
Matrix4D& Outer(const Vector3d& rV1, const Vector3d& rV2);
/// Hat operator (skew symmetric)
Matrix4D& Hat(const Vector3f& rV);
Matrix4D& Hat(const Vector3d& rV);
//@}
void getMatrix (double dMtrx[16]) const;
void setMatrix (const double dMtrx[16]);
/// get the matrix in OpenGL style
void getGLMatrix (double dMtrx[16]) const;
/// set the matrix in OpenGL style
void setGLMatrix (const double dMtrx[16]);
void getMatrix (double dMtrx[16]) const;
void setMatrix (const double dMtrx[16]);
/// get the matrix in OpenGL style
void getGLMatrix (double dMtrx[16]) const;
/// set the matrix in OpenGL style
void setGLMatrix (const double dMtrx[16]);
unsigned long getMemSpace ();
unsigned long getMemSpace ();
/** @name Manipulation */
//@{
/// Makes unity matrix
void setToUnity();
/// Checks if this is the unit matrix
bool isUnity() const;
/// Makes a null matrix
void nullify();
/// Checks if this is the null matrix
bool isNull() const;
/// moves the coordinatesystem for the x,y,z value
void move (float x, float y, float z)
{ move(Vector3f(x,y,z)); }
void move (double x, double y, double z)
{ move(Vector3d(x,y,z)); }
/// moves the coordinatesystem for the vector
void move (const Vector3f& rclVct);
void move (const Vector3d& rclVct);
/// scale for the vector
void scale (float x, float y, float z)
{ scale(Vector3f(x,y,z)); }
void scale (double x, double y, double z)
{ scale(Vector3d(x,y,z)); }
/// scale for the x,y,z value
void scale (const Vector3f& rclVct);
void scale (const Vector3d& rclVct);
/// uniform scale
void scale (float scalexyz)
{ scale(Vector3f(scalexyz, scalexyz, scalexyz)); }
void scale (double scalexyz)
{ scale(Vector3d(scalexyz, scalexyz, scalexyz)); }
/// Check for scaling factor
ScaleType hasScale(double tol=0.0) const;
/// Rotate around the X axis (in transformed space) for the given value in radians
void rotX (double fAngle);
/// Rotate around the Y axis (in transformed space) for the given value in radians
void rotY (double fAngle);
/// Rotate around the Z axis (in transformed space) for the given value in radians
void rotZ (double fAngle);
/// Rotate around an arbitrary axis passing the origin in radians
void rotLine (const Vector3f& rclVct, float fAngle);
/// Rotate around an arbitrary axis passing the origin in radians
void rotLine (const Vector3d& rclVct, double fAngle);
/// Rotate around an arbitrary axis that needn't necessarily pass the origin in radians
void rotLine (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle);
/// Rotate around an arbitrary axis that needn't necessarily pass the origin in radians
void rotLine (const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
/// Extract the rotation axis and angle. Therefore the 3x3 submatrix must be orthogonal.
bool toAxisAngle (Vector3f& rclBase, Vector3f& rclDir, float& fAngle, float& fTranslation) const;
bool toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& fAngle, double& fTranslation) const;
/// transform (move,scale,rotate) around a point
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);
/// Matrix is expected to have a 3x3 rotation submatrix.
void inverse ();
/// Matrix is expected to have a 3x3 rotation submatrix.
void inverseOrthogonal();
/// Arbitrary, non-singular matrix
void inverseGauss ();
void transpose ();
//@}
/** @name Manipulation */
//@{
/// Makes unity matrix
void setToUnity();
/// Checks if this is the unit matrix
bool isUnity() const;
/// Makes a null matrix
void nullify();
/// Checks if this is the null matrix
bool isNull() const;
/// moves the coordinatesystem for the x,y,z value
void move (float x, float y, float z)
{ move(Vector3f(x,y,z)); }
void move (double x, double y, double z)
{ move(Vector3d(x,y,z)); }
/// moves the coordinatesystem for the vector
void move (const Vector3f& rclVct);
void move (const Vector3d& rclVct);
/// scale for the vector
void scale (float x, float y, float z)
{ scale(Vector3f(x,y,z)); }
void scale (double x, double y, double z)
{ scale(Vector3d(x,y,z)); }
/// scale for the x,y,z value
void scale (const Vector3f& rclVct);
void scale (const Vector3d& rclVct);
/// uniform scale
void scale (float scalexyz)
{ scale(Vector3f(scalexyz, scalexyz, scalexyz)); }
void scale (double scalexyz)
{ scale(Vector3d(scalexyz, scalexyz, scalexyz)); }
/// Check for scaling factor
ScaleType hasScale(double tol=0.0) const;
/// Rotate around the X axis (in transformed space) for the given value in radians
void rotX (double fAngle);
/// Rotate around the Y axis (in transformed space) for the given value in radians
void rotY (double fAngle);
/// Rotate around the Z axis (in transformed space) for the given value in radians
void rotZ (double fAngle);
/// Rotate around an arbitrary axis passing the origin in radians
void rotLine (const Vector3f& rclVct, float fAngle);
/// Rotate around an arbitrary axis passing the origin in radians
void rotLine (const Vector3d& rclVct, double fAngle);
/// Rotate around an arbitrary axis that needn't necessarily pass the origin in radians
void rotLine (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle);
/// Rotate around an arbitrary axis that needn't necessarily pass the origin in radians
void rotLine (const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
/// Extract the rotation axis and angle. Therefore the 3x3 submatrix must be orthogonal.
bool toAxisAngle (Vector3f& rclBase, Vector3f& rclDir, float& fAngle, float& fTranslation) const;
bool toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& fAngle, double& fTranslation) const;
/// transform (move,scale,rotate) around a point
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);
/// Matrix is expected to have a 3x3 rotation submatrix.
void inverse ();
/// Matrix is expected to have a 3x3 rotation submatrix.
void inverseOrthogonal();
/// Arbitrary, non-singular matrix
void inverseGauss ();
void transpose ();
//@}
void Print () const;
/// write the 16 double of the matrix into a string
std::string toString() const;
/// read the 16 double of the matrix from a string
void fromString (const std::string &str);
void Print () const;
/// write the 16 double of the matrix into a string
std::string toString() const;
/// read the 16 double of the matrix from a string
void fromString (const std::string &str);
private:
double dMtrx4D[4][4];
double dMtrx4D[4][4];
};
inline Matrix4D Matrix4D::operator + (const Matrix4D& rclMtrx) const
inline Matrix4D Matrix4D::operator + (const Matrix4D& rclMtrx) const
{
Matrix4D clMat;
unsigned short iz, is;
Matrix4D clMat;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] + rclMtrx[iz][is];
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] + rclMtrx[iz][is];
}
}
}
return clMat;
return clMat;
}
inline Matrix4D& Matrix4D::operator += (const Matrix4D& rclMtrx)
{
unsigned short iz, is;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
dMtrx4D[iz][is] += rclMtrx[iz][is];
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
dMtrx4D[iz][is] += rclMtrx[iz][is];
}
}
}
return *this;
return *this;
}
inline Matrix4D Matrix4D::operator - (const Matrix4D& rclMtrx) const
{
Matrix4D clMat;
unsigned short iz, is;
Matrix4D clMat;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] - rclMtrx[iz][is];
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] - rclMtrx[iz][is];
}
}
}
return clMat;
return clMat;
}
inline Matrix4D& Matrix4D::operator -= (const Matrix4D& rclMtrx)
{
unsigned short iz, is;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
dMtrx4D[iz][is] -= rclMtrx[iz][is];
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
dMtrx4D[iz][is] -= rclMtrx[iz][is];
}
}
}
return *this;
return *this;
}
inline Matrix4D& Matrix4D::operator *= (const Matrix4D& rclMtrx)
{
Matrix4D clMat;
unsigned short ie, iz, is;
Matrix4D clMat;
for (iz = 0; iz < 4; iz++)
for (is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = 0;
for (ie = 0; ie < 4; ie++)
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] *
rclMtrx.dMtrx4D[ie][is];
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = 0;
for (int ie = 0; ie < 4; ie++) {
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] *
rclMtrx.dMtrx4D[ie][is];
}
}
}
(*this) = clMat;
(*this) = clMat;
return *this;
return *this;
}
inline Matrix4D Matrix4D::operator * (const Matrix4D& rclMtrx) const
{
Matrix4D clMat;
unsigned short ie, iz, is;
Matrix4D clMat;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = 0;
for (ie = 0; ie < 4; ie++) {
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] *
rclMtrx.dMtrx4D[ie][is];
}
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
clMat.dMtrx4D[iz][is] = 0;
for (int ie = 0; ie < 4; ie++) {
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] *
rclMtrx.dMtrx4D[ie][is];
}
}
}
}
return clMat;
return clMat;
}
inline Matrix4D& Matrix4D::operator= (const Matrix4D& rclMtrx)
{
unsigned short iz, is;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
dMtrx4D[iz][is] = rclMtrx.dMtrx4D[iz][is];
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
dMtrx4D[iz][is] = rclMtrx.dMtrx4D[iz][is];
}
}
}
return *this;
return *this;
}
inline Vector3f Matrix4D::operator* (const Vector3f& rclVct) const
{
double x = static_cast<double>(rclVct.x);
double y = static_cast<double>(rclVct.y);
double z = static_cast<double>(rclVct.z);
return Vector3f(
static_cast<float>(dMtrx4D[0][0]*x + dMtrx4D[0][1]*y +
dMtrx4D[0][2]*z + dMtrx4D[0][3]),
static_cast<float>(dMtrx4D[1][0]*x + dMtrx4D[1][1]*y +
dMtrx4D[1][2]*z + dMtrx4D[1][3]),
static_cast<float>(dMtrx4D[2][0]*x + dMtrx4D[2][1]*y +
dMtrx4D[2][2]*z + dMtrx4D[2][3])
);
double x = static_cast<double>(rclVct.x);
double y = static_cast<double>(rclVct.y);
double z = static_cast<double>(rclVct.z);
return Vector3f(
static_cast<float>(dMtrx4D[0][0]*x + dMtrx4D[0][1]*y +
dMtrx4D[0][2]*z + dMtrx4D[0][3]),
static_cast<float>(dMtrx4D[1][0]*x + dMtrx4D[1][1]*y +
dMtrx4D[1][2]*z + dMtrx4D[1][3]),
static_cast<float>(dMtrx4D[2][0]*x + dMtrx4D[2][1]*y +
dMtrx4D[2][2]*z + dMtrx4D[2][3])
);
}
inline Vector3d Matrix4D::operator* (const Vector3d& rclVct) const
{
return Vector3d((dMtrx4D[0][0]*rclVct.x + dMtrx4D[0][1]*rclVct.y +
dMtrx4D[0][2]*rclVct.z + dMtrx4D[0][3]),
(dMtrx4D[1][0]*rclVct.x + dMtrx4D[1][1]*rclVct.y +
dMtrx4D[1][2]*rclVct.z + dMtrx4D[1][3]),
(dMtrx4D[2][0]*rclVct.x + dMtrx4D[2][1]*rclVct.y +
dMtrx4D[2][2]*rclVct.z + dMtrx4D[2][3]));
return Vector3d((dMtrx4D[0][0]*rclVct.x + dMtrx4D[0][1]*rclVct.y +
dMtrx4D[0][2]*rclVct.z + dMtrx4D[0][3]),
(dMtrx4D[1][0]*rclVct.x + dMtrx4D[1][1]*rclVct.y +
dMtrx4D[1][2]*rclVct.z + dMtrx4D[1][3]),
(dMtrx4D[2][0]*rclVct.x + dMtrx4D[2][1]*rclVct.y +
dMtrx4D[2][2]*rclVct.z + dMtrx4D[2][3]));
}
inline void Matrix4D::multVec(const Vector3d & src, Vector3d & dst) const
{
double x = (dMtrx4D[0][0]*src.x + dMtrx4D[0][1]*src.y +
dMtrx4D[0][2]*src.z + dMtrx4D[0][3]);
double y = (dMtrx4D[1][0]*src.x + dMtrx4D[1][1]*src.y +
dMtrx4D[1][2]*src.z + dMtrx4D[1][3]);
double z = (dMtrx4D[2][0]*src.x + dMtrx4D[2][1]*src.y +
dMtrx4D[2][2]*src.z + dMtrx4D[2][3]);
dst.Set(x,y,z);
double x = (dMtrx4D[0][0]*src.x + dMtrx4D[0][1]*src.y +
dMtrx4D[0][2]*src.z + dMtrx4D[0][3]);
double y = (dMtrx4D[1][0]*src.x + dMtrx4D[1][1]*src.y +
dMtrx4D[1][2]*src.z + dMtrx4D[1][3]);
double z = (dMtrx4D[2][0]*src.x + dMtrx4D[2][1]*src.y +
dMtrx4D[2][2]*src.z + dMtrx4D[2][3]);
dst.Set(x,y,z);
}
inline void Matrix4D::multVec(const Vector3f & src, Vector3f & dst) const
{
double sx = static_cast<double>(src.x);
double sy = static_cast<double>(src.y);
double sz = static_cast<double>(src.z);
double sx = static_cast<double>(src.x);
double sy = static_cast<double>(src.y);
double sz = static_cast<double>(src.z);
double x = (dMtrx4D[0][0]*sx + dMtrx4D[0][1]*sy +
dMtrx4D[0][2]*sz + dMtrx4D[0][3]);
double y = (dMtrx4D[1][0]*sx + dMtrx4D[1][1]*sy +
dMtrx4D[1][2]*sz + dMtrx4D[1][3]);
double z = (dMtrx4D[2][0]*sx + dMtrx4D[2][1]*sy +
dMtrx4D[2][2]*sz + dMtrx4D[2][3]);
dst.Set(static_cast<float>(x),
static_cast<float>(y),
static_cast<float>(z));
double x = (dMtrx4D[0][0]*sx + dMtrx4D[0][1]*sy +
dMtrx4D[0][2]*sz + dMtrx4D[0][3]);
double y = (dMtrx4D[1][0]*sx + dMtrx4D[1][1]*sy +
dMtrx4D[1][2]*sz + dMtrx4D[1][3]);
double z = (dMtrx4D[2][0]*sx + dMtrx4D[2][1]*sy +
dMtrx4D[2][2]*sz + dMtrx4D[2][3]);
dst.Set(static_cast<float>(x),
static_cast<float>(y),
static_cast<float>(z));
}
inline Matrix4D Matrix4D::operator * (double scalar) const
@@ -380,48 +372,48 @@ inline Matrix4D Matrix4D::operator * (double scalar) const
inline Matrix4D& Matrix4D::operator *= (double scalar)
{
//NOLINTBEGIN
for (unsigned short i = 0; i < 4; i++) {
for (unsigned short j = 0; j < 4; j++) {
dMtrx4D[i][j] *= scalar;
}
}
//NOLINTEND
return *this;
}
inline bool Matrix4D::operator== (const Matrix4D& rclMtrx) const
{
unsigned short iz, is;
for (iz = 0; iz < 4; iz++) {
for (is = 0; is < 4; is++) {
if (fabs(dMtrx4D[iz][is] - rclMtrx.dMtrx4D[iz][is]) > traits_type::epsilon())
return false;
for (int iz = 0; iz < 4; iz++) {
for (int is = 0; is < 4; is++) {
if (fabs(dMtrx4D[iz][is] - rclMtrx.dMtrx4D[iz][is]) > traits_type::epsilon())
return false;
}
}
}
return true;
return true;
}
inline bool Matrix4D::operator!= (const Matrix4D& rclMtrx) const
{
return !( (*this) == rclMtrx );
return !( (*this) == rclMtrx );
}
inline Vector3f& operator*= (Vector3f& rclVect,
const Matrix4D& rclMtrx)
{
rclVect = rclMtrx * rclVect;
return rclVect;
rclVect = rclMtrx * rclVect;
return rclVect;
}
inline double* Matrix4D::operator[] (unsigned short usNdx)
{
return dMtrx4D[usNdx];
return dMtrx4D[usNdx];
}
inline const double* Matrix4D::operator[] (unsigned short usNdx) const
{
return dMtrx4D[usNdx];
return dMtrx4D[usNdx];
}
inline Vector3d Matrix4D::getRow(unsigned short usNdx) const

View File

@@ -77,7 +77,7 @@ int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
PyObject *o;
PyObject *o{};
if (PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type), &o)) {
MatrixPy::PointerType ptr = getMatrixPtr();
(*ptr) = static_cast<MatrixPy*>(o)->value();
@@ -85,10 +85,10 @@ int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
PyObject *o1;
PyObject *o2;
PyObject *o3;
PyObject *o4 = nullptr;
PyObject *o1{};
PyObject *o2{};
PyObject *o3{};
PyObject *o4{};
if (PyArg_ParseTuple(args, "O!O!O!|O!", &(Base::VectorPy::Type), &o1
, &(Base::VectorPy::Type), &o2
, &(Base::VectorPy::Type), &o3
@@ -239,12 +239,12 @@ PyObject* MatrixPy::richCompare(PyObject *v, PyObject *w, int op)
return nullptr;
}
else if (op == Py_EQ) {
res = (m1 == m2) ? Py_True : Py_False;
res = (m1 == m2) ? Py_True : Py_False; //NOLINT
Py_INCREF(res);
return res;
}
else {
res = (m1 != m2) ? Py_True : Py_False;
res = (m1 != m2) ? Py_True : Py_False; //NOLINT
Py_INCREF(res);
return res;
}
@@ -258,9 +258,9 @@ PyObject* MatrixPy::richCompare(PyObject *v, PyObject *w, int op)
PyObject* MatrixPy::move(PyObject * args)
{
double x,y,z;
double x{},y{},z{};
Base::Vector3d vec;
PyObject *pcVecObj;
PyObject *pcVecObj{};
do { // dummy do..while for cascaded if
if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) {
@@ -298,9 +298,9 @@ PyObject* MatrixPy::move(PyObject * args)
PyObject* MatrixPy::scale(PyObject * args)
{
double x,y,z;
double x{},y{},z{};
Base::Vector3d vec;
PyObject *pcVecObj;
PyObject *pcVecObj{};
do { // dummy do..while for cascaded if
if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) {
@@ -404,7 +404,7 @@ PyObject* MatrixPy::transform(PyObject * args)
{
Base::Vector3d vec;
Matrix4D mat;
PyObject *pcVecObj,*pcMatObj;
PyObject *pcVecObj{}, *pcMatObj{};
if (!PyArg_ParseTuple(args, "O!O!: a transform point (Vector) and a transform matrix (Matrix) is needed",
&(Base::VectorPy::Type), &pcVecObj, &(MatrixPy::Type), &pcMatObj))
@@ -421,7 +421,7 @@ PyObject* MatrixPy::transform(PyObject * args)
PyObject* MatrixPy::col(PyObject * args)
{
int index;
int index{};
if (!PyArg_ParseTuple(args, "i", &index))
return nullptr;
@@ -437,8 +437,8 @@ PyObject* MatrixPy::col(PyObject * args)
PyObject* MatrixPy::setCol(PyObject * args)
{
int index;
PyObject* o;
int index{};
PyObject* o{};
if (!PyArg_ParseTuple(args, "iO!", &index, &(VectorPy::Type), &o))
return nullptr;
@@ -455,7 +455,7 @@ PyObject* MatrixPy::setCol(PyObject * args)
PyObject* MatrixPy::row(PyObject * args)
{
int index;
int index{};
if (!PyArg_ParseTuple(args, "i", &index))
return nullptr;
@@ -471,8 +471,8 @@ PyObject* MatrixPy::row(PyObject * args)
PyObject* MatrixPy::setRow(PyObject * args)
{
int index;
PyObject* o;
int index{};
PyObject* o{};
if (!PyArg_ParseTuple(args, "iO!", &index, &(VectorPy::Type), &o))
return nullptr;
@@ -499,7 +499,7 @@ PyObject* MatrixPy::trace(PyObject * args)
PyObject* MatrixPy::setTrace(PyObject * args)
{
PyObject* o;
PyObject* o{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &o))
return nullptr;
@@ -513,7 +513,7 @@ PyObject* MatrixPy::rotateX(PyObject * args)
{
double angle = 0;
do {
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
Quantity *q = static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
if (q->getUnit() == Base::Unit::Angle) {
@@ -543,7 +543,7 @@ PyObject* MatrixPy::rotateY(PyObject * args)
{
double angle = 0;
do {
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
Quantity *q = static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
if (q->getUnit() == Base::Unit::Angle) {
@@ -573,7 +573,7 @@ PyObject* MatrixPy::rotateZ(PyObject * args)
{
double angle = 0;
do {
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
Quantity *q = static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
if (q->getUnit() == Base::Unit::Angle) {
@@ -601,7 +601,7 @@ PyObject* MatrixPy::rotateZ(PyObject * args)
PyObject* MatrixPy::multiply(PyObject * args)
{
PyObject* o;
PyObject* o{};
if (PyArg_ParseTuple(args, "O!", &(MatrixPy::Type), &o)) {
Matrix4D mat = (*getMatrixPtr()) * static_cast<Base::MatrixPy*>(o)->value();
return new MatrixPy(new Matrix4D(mat));
@@ -619,7 +619,7 @@ PyObject* MatrixPy::multiply(PyObject * args)
PyObject* MatrixPy::multVec(PyObject * args)
{
PyObject *obj;
PyObject *obj{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
@@ -675,7 +675,7 @@ PyObject* MatrixPy::determinant(PyObject * args)
PyObject* MatrixPy::submatrix(PyObject * args)
{
int dim;
int dim{};
if (!PyArg_ParseTuple(args, "i", &dim))
return nullptr;
@@ -962,7 +962,7 @@ Py::Sequence MatrixPy::getA() const
for (int i=0; i<16; i++) {
tuple[i] = Py::Float(mat[i]);
}
return tuple;
return std::move(tuple);
}
void MatrixPy::setA(Py::Sequence arg)

View File

@@ -191,7 +191,7 @@ public:
*/
Observer<_MessageType> * Get(const char *Name)
{
const char* OName;
const char* OName = nullptr;
for(typename std::set<Observer<_MessageType> * >::iterator Iter=_ObserverSet.begin();Iter!=_ObserverSet.end();++Iter)
{
OName = (*Iter)->Name(); // get the name

View File

@@ -396,7 +396,7 @@ Base::Reference<ParameterGrp> ParameterGrp::_GetGroup(const char* Name)
return rParamGrp;
}
DOMElement *pcTemp;
DOMElement *pcTemp{};
// search if Group node already there
pcTemp = FindElement(_pGroupNode,"FCParamGroup",Name);

View File

@@ -263,7 +263,7 @@ Py::Object ParameterGrpPy::repr()
Py::Object ParameterGrpPy::importFrom(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -273,7 +273,7 @@ Py::Object ParameterGrpPy::importFrom(const Py::Tuple& args)
Py::Object ParameterGrpPy::insert(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -283,7 +283,7 @@ Py::Object ParameterGrpPy::insert(const Py::Tuple& args)
Py::Object ParameterGrpPy::exportTo(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -293,7 +293,7 @@ Py::Object ParameterGrpPy::exportTo(const Py::Tuple& args)
Py::Object ParameterGrpPy::getGroup(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -377,8 +377,8 @@ Py::Object ParameterGrpPy::getGroups(const Py::Tuple& args)
Py::Object ParameterGrpPy::setBool(const Py::Tuple& args)
{
char *pstr;
int Bool;
char *pstr = nullptr;
int Bool = 0;
if (!PyArg_ParseTuple(args.ptr(), "si", &pstr,&Bool))
throw Py::Exception();
@@ -388,7 +388,7 @@ Py::Object ParameterGrpPy::setBool(const Py::Tuple& args)
Py::Object ParameterGrpPy::getBool(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
int Bool=0;
if (!PyArg_ParseTuple(args.ptr(), "s|i", &pstr,&Bool))
throw Py::Exception();
@@ -413,8 +413,8 @@ Py::Object ParameterGrpPy::getBools(const Py::Tuple& args)
Py::Object ParameterGrpPy::setInt(const Py::Tuple& args)
{
char *pstr;
int Int;
char *pstr = nullptr;
int Int = 0;
if (!PyArg_ParseTuple(args.ptr(), "si", &pstr,&Int))
throw Py::Exception();
@@ -424,7 +424,7 @@ Py::Object ParameterGrpPy::setInt(const Py::Tuple& args)
Py::Object ParameterGrpPy::getInt(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
int Int=0;
if (!PyArg_ParseTuple(args.ptr(), "s|i", &pstr,&Int))
throw Py::Exception();
@@ -448,8 +448,8 @@ Py::Object ParameterGrpPy::getInts(const Py::Tuple& args)
Py::Object ParameterGrpPy::setUnsigned(const Py::Tuple& args)
{
char *pstr;
unsigned int UInt;
char *pstr = nullptr;
unsigned int UInt = 0;
if (!PyArg_ParseTuple(args.ptr(), "sI", &pstr,&UInt))
throw Py::Exception();
@@ -459,7 +459,7 @@ Py::Object ParameterGrpPy::setUnsigned(const Py::Tuple& args)
Py::Object ParameterGrpPy::getUnsigned(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
unsigned int UInt=0;
if (!PyArg_ParseTuple(args.ptr(), "s|I", &pstr,&UInt))
throw Py::Exception();
@@ -483,8 +483,8 @@ Py::Object ParameterGrpPy::getUnsigneds(const Py::Tuple& args)
Py::Object ParameterGrpPy::setFloat(const Py::Tuple& args)
{
char *pstr;
double Float;
char *pstr = nullptr;
double Float{};
if (!PyArg_ParseTuple(args.ptr(), "sd", &pstr,&Float))
throw Py::Exception();
@@ -494,7 +494,7 @@ Py::Object ParameterGrpPy::setFloat(const Py::Tuple& args)
Py::Object ParameterGrpPy::getFloat(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
double Float=0.0;
if (!PyArg_ParseTuple(args.ptr(), "s|d", &pstr,&Float))
throw Py::Exception();
@@ -519,8 +519,8 @@ Py::Object ParameterGrpPy::getFloats(const Py::Tuple& args)
Py::Object ParameterGrpPy::setString(const Py::Tuple& args)
{
char *pstr;
char * str;
char *pstr = nullptr;
char * str = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "ss", &pstr,&str))
throw Py::Exception();
@@ -530,7 +530,7 @@ Py::Object ParameterGrpPy::setString(const Py::Tuple& args)
Py::Object ParameterGrpPy::getString(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
char * str="";
if (!PyArg_ParseTuple(args.ptr(), "s|s", &pstr,&str))
throw Py::Exception();
@@ -555,7 +555,7 @@ Py::Object ParameterGrpPy::getStrings(const Py::Tuple& args)
Py::Object ParameterGrpPy::remInt(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -565,7 +565,7 @@ Py::Object ParameterGrpPy::remInt(const Py::Tuple& args)
Py::Object ParameterGrpPy::remUnsigned(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -575,7 +575,7 @@ Py::Object ParameterGrpPy::remUnsigned(const Py::Tuple& args)
Py::Object ParameterGrpPy::remBool(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -585,7 +585,7 @@ Py::Object ParameterGrpPy::remBool(const Py::Tuple& args)
Py::Object ParameterGrpPy::remGroup(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -595,7 +595,7 @@ Py::Object ParameterGrpPy::remGroup(const Py::Tuple& args)
Py::Object ParameterGrpPy::remFloat(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -605,7 +605,7 @@ Py::Object ParameterGrpPy::remFloat(const Py::Tuple& args)
Py::Object ParameterGrpPy::remString(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -632,7 +632,7 @@ Py::Object ParameterGrpPy::isEmpty(const Py::Tuple& args)
Py::Object ParameterGrpPy::hasGroup(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
@@ -641,7 +641,7 @@ Py::Object ParameterGrpPy::hasGroup(const Py::Tuple& args)
Py::Object ParameterGrpPy::attach(const Py::Tuple& args)
{
PyObject* obj;
PyObject* obj = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "O", &obj))
throw Py::Exception();
@@ -664,7 +664,7 @@ Py::Object ParameterGrpPy::attach(const Py::Tuple& args)
Py::Object ParameterGrpPy::attachManager(const Py::Tuple& args)
{
PyObject* obj;
PyObject* obj = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "O", &obj))
throw Py::Exception();
@@ -714,7 +714,7 @@ Py::Object ParameterGrpPy::attachManager(const Py::Tuple& args)
Py::Object ParameterGrpPy::detach(const Py::Tuple& args)
{
PyObject* obj;
PyObject* obj = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "O", &obj))
throw Py::Exception();
@@ -737,7 +737,7 @@ Py::Object ParameterGrpPy::detach(const Py::Tuple& args)
Py::Object ParameterGrpPy::notify(const Py::Tuple& args)
{
char *pstr;
char *pstr = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();

View File

@@ -114,7 +114,7 @@ PyObject* PersistencePy::dumpContent(PyObject *args, PyObject *kwds)
PyObject* PersistencePy::restoreContent(PyObject *args)
{
PyObject* buffer;
PyObject* buffer = nullptr;
if( !PyArg_ParseTuple(args, "O", &buffer) )
return nullptr;

View File

@@ -60,7 +60,7 @@ PyObject *PlacementPy::PyMake(struct _typeobject *, PyObject *, PyObject *) //
// constructor method
int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject* o;
PyObject* o{};
if (PyArg_ParseTuple(args, "")) {
return 0;
}
@@ -86,8 +86,8 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
PyObject* d;
double angle;
PyObject* d{};
double angle{};
if (PyArg_ParseTuple(args, "O!O!d", &(Base::VectorPy::Type), &o,
&(Base::VectorPy::Type), &d, &angle)) {
// NOTE: The first parameter defines the translation, the second the rotation axis
@@ -108,7 +108,7 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
PyObject* c;
PyObject* c{};
if (PyArg_ParseTuple(args, "O!O!O!", &(Base::VectorPy::Type), &o,
&(Base::RotationPy::Type), &d,
&(Base::VectorPy::Type), &c)) {
@@ -157,7 +157,7 @@ PyObject* PlacementPy::richCompare(PyObject *v, PyObject *w, int op)
PyObject* PlacementPy::move(PyObject * args)
{
PyObject *vec;
PyObject *vec{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec))
return nullptr;
getPlacementPtr()->move(static_cast<VectorPy*>(vec)->value());
@@ -171,7 +171,7 @@ PyObject* PlacementPy::translate(PyObject * args)
PyObject* PlacementPy::rotate(PyObject *args, PyObject *kwds)
{
double angle;
double angle{};
char *keywords[] = { "center", "axis", "angle", "comp", nullptr };
Vector3d center;
Vector3d axis;
@@ -205,7 +205,7 @@ PyObject* PlacementPy::rotate(PyObject *args, PyObject *kwds)
PyObject* PlacementPy::multiply(PyObject * args)
{
PyObject *plm;
PyObject *plm{};
if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm))
return nullptr;
Placement mult = (*getPlacementPtr()) * (*static_cast<PlacementPy*>(plm)->getPlacementPtr());
@@ -214,7 +214,7 @@ PyObject* PlacementPy::multiply(PyObject * args)
PyObject* PlacementPy::multVec(PyObject * args)
{
PyObject *vec;
PyObject *vec{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec))
return nullptr;
Base::Vector3d pnt(static_cast<VectorPy*>(vec)->value());
@@ -247,7 +247,7 @@ PyObject* PlacementPy::inverse(PyObject * args)
PyObject* PlacementPy::pow(PyObject* args)
{
double t;
double t{};
PyObject* shorten = Py_True;
if (!PyArg_ParseTuple(args, "d|O!", &t, &(PyBool_Type), &shorten))
return nullptr;
@@ -258,8 +258,8 @@ PyObject* PlacementPy::pow(PyObject* args)
PyObject* PlacementPy::sclerp(PyObject* args)
{
PyObject* pyplm2;
double t;
PyObject* pyplm2{};
double t{};
PyObject* shorten = Py_True;
if (!PyArg_ParseTuple(args, "O!d|O!", &(PlacementPy::Type), &pyplm2, &t, &(PyBool_Type), &shorten))
return nullptr;
@@ -270,8 +270,8 @@ PyObject* PlacementPy::sclerp(PyObject* args)
PyObject* PlacementPy::slerp(PyObject* args)
{
PyObject* pyplm2;
double t;
PyObject* pyplm2{};
double t{};
if (!PyArg_ParseTuple(args, "O!d", &(PlacementPy::Type), &pyplm2, &t))
return nullptr;
Base::Placement plm2 = static_cast<Base::PlacementPy*>(pyplm2)->value();
@@ -291,7 +291,7 @@ PyObject* PlacementPy::isIdentity(PyObject *args)
PyObject* PlacementPy::isSame(PyObject *args)
{
PyObject* plm;
PyObject* plm{};
double tol = 0.0;
if (!PyArg_ParseTuple(args, "O!|d", &PlacementPy::Type, &plm, &tol))
return nullptr;
@@ -304,7 +304,7 @@ PyObject* PlacementPy::isSame(PyObject *args)
Py::Object PlacementPy::getBase() const
{
return Py::Vector(getPlacementPtr()->getPosition());
return Py::Vector(getPlacementPtr()->getPosition()); // NOLINT
}
void PlacementPy::setBase(Py::Object arg)
@@ -361,8 +361,9 @@ PyObject *PlacementPy::getCustomAttributes(const char* attr) const
{
// for backward compatibility
if (strcmp(attr, "isNull") == 0) {
PyObject *w, *res;
PyObject *w{}, *res{};
w = PyUnicode_InternFromString("isIdentity");
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
res = PyObject_GenericGetAttr(const_cast<PlacementPy *>(this), w);
Py_XDECREF(w);
return res;
@@ -412,7 +413,7 @@ PyObject * PlacementPy::number_power_handler (PyObject* self, PyObject* other, P
Py::Tuple tup(1);
tup[0] = pw;
double pw_v;
double pw_v{};
if (!PyArg_ParseTuple(tup.ptr(), "d", &pw_v)){
//PyErr_SetString(PyExc_NotImplementedError, "Wrong exponent type (expect float).");
return nullptr;

View File

@@ -88,14 +88,14 @@ PyObject* PrecisionPy::approximation(PyObject *args)
PyObject* PrecisionPy::parametric(PyObject *args)
{
double p;
double p{};
if (PyArg_ParseTuple(args, "d", &p)) {
Py::Float v(Precision::Parametric(p));
return Py::new_reference_to(v);
}
PyErr_Clear();
double t;
double t{};
if (PyArg_ParseTuple(args, "dd", &p, &t)) {
Py::Float v(Precision::Parametric(p, t));
return Py::new_reference_to(v);
@@ -107,7 +107,7 @@ PyObject* PrecisionPy::parametric(PyObject *args)
PyObject* PrecisionPy::isInfinite(PyObject *args)
{
double v;
double v{};
if (!PyArg_ParseTuple(args, "d", &v)) {
return nullptr;
}
@@ -118,7 +118,7 @@ PyObject* PrecisionPy::isInfinite(PyObject *args)
PyObject* PrecisionPy::isPositiveInfinite(PyObject *args)
{
double v;
double v{};
if (!PyArg_ParseTuple(args, "d", &v)) {
return nullptr;
}
@@ -129,7 +129,7 @@ PyObject* PrecisionPy::isPositiveInfinite(PyObject *args)
PyObject* PrecisionPy::isNegativeInfinite(PyObject *args)
{
double v;
double v{};
if (!PyArg_ParseTuple(args, "d", &v)) {
return nullptr;
}

View File

@@ -70,13 +70,13 @@ ProgressIndicatorPy::~ProgressIndicatorPy() = default;
Py::Object ProgressIndicatorPy::repr()
{
std::string s = "Base.ProgressIndicator";
return Py::String(s);
return Py::String(s); // NOLINT
}
Py::Object ProgressIndicatorPy::start(const Py::Tuple& args)
{
char* text;
unsigned int steps;
char* text = nullptr;
unsigned int steps = 0;
if (!PyArg_ParseTuple(args.ptr(), "sI",&text,&steps))
throw Py::Exception();
if (!_seq.get()) {

View File

@@ -30,7 +30,7 @@
namespace Base
{
// NOLINTNEXTLINE
class BaseExport ProgressIndicatorPy : public Py::PythonExtension<ProgressIndicatorPy>
{
public:

View File

@@ -282,7 +282,7 @@ PyMethodDef PyObjectBase::Methods[] = {
PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
{
const char *attr;
const char *attr{};
attr = PyUnicode_AsUTF8(attro);
// For the __class__ attribute get it directly as with
@@ -346,7 +346,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value)
{
const char *attr;
const char *attr{};
attr = PyUnicode_AsUTF8(attro);
//Hint: In general we don't allow to delete attributes (i.e. value=0). However, if we want to allow
@@ -409,7 +409,7 @@ PyObject *PyObjectBase::_getattr(const char *attr)
}
else {
// As fallback solution use Python's default method to get generic attributes
PyObject *w, *res;
PyObject *w{}, *res{};
w = PyUnicode_InternFromString(attr);
if (w) {
res = PyObject_GenericGetAttr(this, w);
@@ -428,7 +428,7 @@ int PyObjectBase::_setattr(const char *attr, PyObject *value)
{
if (streq(attr,"softspace"))
return -1; // filter out softspace
PyObject *w;
PyObject *w{};
// As fallback solution use Python's default method to get generic attributes
w = PyUnicode_InternFromString(attr); // new reference
if (w) {

View File

@@ -117,7 +117,7 @@ inline void Assert(int expr, char *msg) // C++ assert
inline PyObject* getTypeAsObject(PyTypeObject* type) {
// See https://en.cppreference.com/w/cpp/string/byte/memcpy
// and https://en.cppreference.com/w/cpp/language/reinterpret_cast
PyObject* obj;
PyObject* obj{};
std::memcpy(&obj, &type, sizeof type);
return obj;
}
@@ -184,7 +184,7 @@ namespace Base
* @see Py_Try
* @see Py_Assert
*/
class BaseExport PyObjectBase : public PyObject
class BaseExport PyObjectBase : public PyObject //NOLINT
{
/** Py_Header struct from python.h.
* Every PyObjectBase object is also a python object. So you can use
@@ -337,12 +337,12 @@ private:
void clearAttributes();
protected:
std::bitset<32> StatusBits;
std::bitset<32> StatusBits; //NOLINT
/// pointer to the handled class
void * _pcTwinPointer;
void * _pcTwinPointer; //NOLINT
public:
PyObject* baseProxy{nullptr};
PyObject* baseProxy{nullptr}; //NOLINT
private:
PyObject* attrDict{nullptr};

View File

@@ -20,7 +20,7 @@ is provided on an as is basis, without warranties of any kind.
#include <eval.h>
#endif
//NOLINTBEGIN
/*****************************************************************************
* RUN EMBEDDED OBJECT METHODS, ACCESS OBJECT ATTRIBUTES
* handles attribute fetch, debugging, input/output conversions;
@@ -32,7 +32,7 @@ PP_Run_Method(PyObject *pobject, const char *method,
const char *resfmt, void *cresult, /* convert to c/c++ */
const char *argfmt, ... /* arg,... */ ) /* convert to python */
{
PyObject *pmeth, *pargs, *presult;
PyObject *pmeth = NULL, *pargs = NULL, *presult = NULL;
va_list argslist; /* "pobject.method(args)" */
va_start(argslist, argfmt);
@@ -75,7 +75,7 @@ int
PP_Get_Member(PyObject *pobject, const char *attrname,
const char *resfmt, void *cresult) /* convert to c/c++ */
{
PyObject *pmemb; /* "pobject.attrname" */
PyObject *pmemb = NULL; /* "pobject.attrname" */
Py_Initialize();
pmemb = PyObject_GetAttrString(pobject, attrname); /* incref'd */
return PP_Convert_Result(pmemb, resfmt, cresult); /* to C form, decrefs */
@@ -86,8 +86,8 @@ int
PP_Set_Member(PyObject *pobject, const char *attrname,
const char *argfmt, ... /* arg,... */ ) /* convert to python */
{
int result;
PyObject *pval;
int result = 0;
PyObject *pval = NULL;
va_list argslist; /* "pobject.attrname = v" */
va_start(argslist, argfmt);
Py_Initialize(); /* init if first time */
@@ -117,7 +117,7 @@ PP_Run_Function(const char *modname, const char *funcname, /* load from
const char *argfmt, ... /* arg, arg... */ ) /* convert to python */
{
/* call a function or class in a module */
PyObject *func, *args, *presult;
PyObject *func = NULL, *args = NULL, *presult = NULL;
va_list argslist;
va_start(argslist, argfmt); /* "modname.funcname(args)" */
@@ -150,8 +150,8 @@ PP_Run_Function(const char *modname, const char *funcname, /* load from
PyObject *
PP_Debug_Function(PyObject *func, PyObject *args)
{
int oops, res;
PyObject *presult;
int oops = 0, res = 0;
PyObject *presult = NULL;
/* expand tuple at front */
// it seems that some versions of python want just 2 arguments; in that
@@ -175,7 +175,7 @@ PP_Run_Known_Callable(PyObject *object, /* func|class|method */
const char *argfmt, ... /* arg,.. */) /* convert args, result */
{
/* call a known callable object */
PyObject *args, *presult;
PyObject *args = NULL, *presult = NULL;
va_list argslist;
va_start(argslist, argfmt); /* "return object(args)" */
@@ -234,8 +234,8 @@ void PP_Fetch_Error_Text()
// called without exception happened!
//assert(PyErr_Occurred());
char *tempstr;
PyObject *errobj, *errdata, *errtraceback, *pystring, *pydict;
char *tempstr = NULL;
PyObject *errobj = NULL, *errdata = NULL, *errtraceback = NULL, *pystring = NULL, *pydict = NULL;
/* get latest python exception information */
/* this also clears the current exception */
@@ -393,7 +393,7 @@ PP_Convert_Result(PyObject *presult, const char *resFormat, void *resTarget)
int
PP_Get_Global(const char *modname, const char *varname, const char *resfmt, void *cresult)
{
PyObject *var; /* "x = modname.varname" */
PyObject *var = NULL; /* "x = modname.varname" */
var = PP_Load_Attribute(modname, varname); /* var is incref'd */
return PP_Convert_Result(var, resfmt, cresult); /* convert var to C form */
}
@@ -402,8 +402,8 @@ PP_Get_Global(const char *modname, const char *varname, const char *resfmt, void
int
PP_Set_Global(const char *modname, const char *varname, const char *valfmt, ... /* cval(s) */)
{
int result;
PyObject *module, *val; /* "modname.varname = val" */
int result = 0;
PyObject *module = NULL, *val = NULL; /* "modname.varname = val" */
va_list cvals;
va_start(cvals, valfmt); /* C args after valfmt */
@@ -456,7 +456,7 @@ const char *PP_Init(const char *modname) {
int
PP_Make_Dummy_Module(const char *modname) /* namespace for strings, if no file */
{ /* instead of sharing __main__ for all */
PyObject *module, *dict; /* note: __main__ is created in py_init */
PyObject *module = NULL, *dict = NULL; /* note: __main__ is created in py_init */
Py_Initialize();
module = PyImport_AddModule(modname); /* fetch or make, no load */
if (module == NULL) /* module not incref'd */
@@ -481,7 +481,7 @@ PP_Load_Module(const char *modname) /* modname can be "package.module" for
* - not loaded yet, or loaded but reload=off: "import" to fetch or load
*/
PyObject *module, *sysmods;
PyObject *module = NULL, *sysmods = NULL;
modname = PP_Init(modname); /* default to __main__ */
if (strcmp(modname, "__main__") == 0) /* main: no file */
@@ -512,7 +512,7 @@ PP_Load_Module(const char *modname) /* modname can be "package.module" for
PyObject *
PP_Load_Attribute(const char *modname, const char *attrname)
{
PyObject *module; /* fetch "module.attr" */
PyObject *module = NULL; /* fetch "module.attr" */
modname = PP_Init(modname); /* use before PyEval_CallObject */
module = PP_Load_Module(modname); /* not incref'd, may reload */
if (module == NULL)
@@ -525,7 +525,7 @@ PP_Load_Attribute(const char *modname, const char *attrname)
int
PP_Run_Command_Line(const char *prompt)
{
int res; /* interact with python, in "__main__" */
int res = 0; /* interact with python, in "__main__" */
Py_Initialize(); /* in the program's "stdio" window */
if (prompt != NULL)
#if defined (FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX)
@@ -553,8 +553,8 @@ PP_Run_Codestr(PPStringModes mode, const char *code, /* expr or stmt string */
const char *resfmt, void *cresult) /* converts expr result to C */
{
/* run a string of Python code */
int parse_mode; /* "eval(code, d, d)", or */
PyObject *module, *dict, *presult; /* "exec code in d, d" */
int parse_mode = 0; /* "eval(code, d, d)", or */
PyObject *module = NULL, *dict = NULL, *presult = NULL; /* "exec code in d, d" */
module = PP_Load_Module(modname); /* get module, init python */
if (module == NULL) /* not incref'd */
@@ -582,7 +582,7 @@ PyObject *
PP_Compile_Codestr(PPStringModes mode, /* precompile string to bytecode */
const char *codestr) /* pass result to PP_Run_Bytecode */
{
int start;
int start = 0;
Py_Initialize();
switch (mode) {
case PP_STATEMENT:
@@ -601,7 +601,7 @@ PP_Run_Bytecode(PyObject *codeobj, /* run compiled bytecode object */
const char *modname, /* in named module's namespace */
const char *resfmt, void *restarget)
{
PyObject *presult, *module, *dict;
PyObject *presult = NULL, *module = NULL, *dict = NULL;
if (! PyCode_Check(codeobj)) /* make sure it's bytecode */
return -1;
@@ -655,8 +655,8 @@ static void fixPdbRetval(PyObject *moddict)
PyObject *
PP_Debug_Codestr(PPStringModes mode, const char *codestring, PyObject *moddict)
{
int res;
PyObject *presult;
int res = 0;
PyObject *presult = NULL;
const char *pdbname = (mode == PP_EXPRESSION ? "runeval" : "run");
fixPdbRetval(moddict);
/* pass code to a pbd.py function */
@@ -671,8 +671,8 @@ PP_Debug_Codestr(PPStringModes mode, const char *codestring, PyObject *moddict)
PyObject *
PP_Debug_Bytecode(PyObject *codeobject, PyObject *moddict)
{
int res;
PyObject *presult;
int res = 0;
PyObject *presult = NULL;
fixPdbRetval(moddict);
res = PP_Run_Function( /* "pdb.runeval(codeobj, gdict, ldict)" */
"pdb", "runeval", /* accepts string|code, code=stmt|expr */
@@ -680,7 +680,4 @@ PP_Debug_Bytecode(PyObject *codeobject, PyObject *moddict)
"(OOO)", codeobject, moddict, moddict);
return (res != 0) ? NULL : presult; /* null if error in run_function */
}
// NOLINTEND

View File

@@ -84,7 +84,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
Quantity *self = getQuantityPtr();
PyErr_Clear(); // set by PyArg_ParseTuple()
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
*self = *(static_cast<Base::QuantityPy*>(object)->getQuantityPtr());
return 0;
@@ -127,7 +127,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear(); // set by PyArg_ParseTuple()
char* string;
char* string{};
if (PyArg_ParseTuple(args,"et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
PyMem_Free(string);
@@ -164,7 +164,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* QuantityPy::getUserPreferred(PyObject* /*args*/)
{
QString uus;
double factor;
double factor{};
Py::Tuple res(3);
QString uss = getQuantityPtr()->getUserString(factor,uus);
@@ -183,14 +183,14 @@ PyObject* QuantityPy::getValueAs(PyObject *args)
// first try Quantity
if (!quant.isValid()) {
PyObject *object;
PyObject *object{};
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
quant = * static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
}
}
if (!quant.isValid()) {
PyObject *object;
PyObject *object{};
PyErr_Clear();
if (PyArg_ParseTuple(args,"O!",&(Base::UnitPy::Type), &object)) {
quant.setUnit(*static_cast<Base::UnitPy*>(object)->getUnitPtr());
@@ -199,8 +199,8 @@ PyObject* QuantityPy::getValueAs(PyObject *args)
}
if (!quant.isValid()) {
PyObject *object;
double value;
PyObject *object{};
double value{};
PyErr_Clear();
if (PyArg_ParseTuple(args,"dO!",&value, &(Base::UnitPy::Type), &object)) {
quant.setUnit(*static_cast<Base::UnitPy*>(object)->getUnitPtr());
@@ -235,7 +235,7 @@ PyObject* QuantityPy::getValueAs(PyObject *args)
if (!quant.isValid()) {
PyErr_Clear();
char* string;
char* string{};
if (PyArg_ParseTuple(args,"et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
PyMem_Free(string);
@@ -417,7 +417,7 @@ PyObject * QuantityPy::number_remainder_handler (PyObject *self, PyObject *other
return nullptr;
}
double d1, d2;
double d1{}, d2{};
Base::Quantity *a = static_cast<QuantityPy*>(self) ->getQuantityPtr();
d1 = a->getValue();
@@ -641,7 +641,7 @@ void QuantityPy::setFormat(Py::Dict arg)
if (fmtstr.size() != 1)
throw Py::ValueError("Invalid format character");
bool ok;
bool ok = false;
fmt.format = Base::QuantityFormat::toFormat(fmtstr[0], &ok);
if (!ok)
throw Py::ValueError("Invalid format character");

View File

@@ -231,7 +231,7 @@ bool Base::XMLReader::read()
void Base::XMLReader::readElement(const char* ElementName)
{
bool ok;
bool ok{};
int currentLevel = Level;
std::string currentName = LocalName;
do {
@@ -268,7 +268,7 @@ void Base::XMLReader::readEndElement(const char* ElementName, int level)
throw Base::XMLParseException("End of document reached");
}
bool ok;
bool ok{};
do {
ok = read(); if (!ok) break;
if (ReadType == EndDocument)
@@ -369,7 +369,7 @@ void Base::XMLReader::readBinFile(const char* filename)
if (!to)
throw Base::FileException("XMLReader::readBinFile() Could not open file!");
bool ok;
bool ok{};
do {
ok = read(); if (!ok) break;
} while (ReadType != EndCDATA);

View File

@@ -401,9 +401,9 @@ 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{}, y0{}, z0{}, w0{};
this->getValue(x0, y0, z0, w0);
double x1, y1, z1, w1;
double x1{}, y1{}, z1{}, w1{};
q.getValue(x1, y1, z1, w1);
this->setValue(w0*x1 + x0*w1 + y0*z1 - z0*y1,
@@ -422,9 +422,9 @@ 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{}, y0{}, z0{}, w0{};
q.getValue(x0, y0, z0, w0);
double x1, y1, z1, w1;
double x1{}, y1{}, z1{}, w1{};
this->getValue(x1, y1, z1, w1);
this->setValue(w0*x1 + x0*w1 + y0*z1 - z0*y1,
@@ -496,7 +496,7 @@ Vector3f Rotation::multVec(const Vector3f & src) const
void Rotation::scaleAngle(const double scaleFactor)
{
Vector3d axis;
double fAngle;
double fAngle{};
this->getValue(axis, fAngle);
this->setValue(axis, fAngle * scaleFactor);
}
@@ -574,7 +574,7 @@ Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdi
auto dropPriority = [&order](int index){
int tmp;
int tmp{};
if (index == 0){
tmp = order[0];
order[0] = order[1];

View File

@@ -62,7 +62,7 @@ PyObject *RotationPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // P
// constructor method
int RotationPy::PyInit(PyObject* args, PyObject* kwds)
{
PyObject* o;
PyObject* o{};
if (PyArg_ParseTuple(args, "")) {
return 0;
}
@@ -75,7 +75,7 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
}
PyErr_Clear();
double angle;
double angle{};
static char *kw_deg[] = {"Axis", "Degree", nullptr};
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_deg, &(Base::VectorPy::Type), &o, &angle)) {
// NOTE: The last parameter defines the rotation angle in degree.
@@ -103,22 +103,22 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
}
PyErr_Clear();
double q0, q1, q2, q3;
double q0{}, q1{}, q2{}, 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{}, p{}, r{};
if (PyArg_ParseTuple(args, "ddd", &y, &p, &r)) {
getRotationPtr()->setYawPitchRoll(y, p, r);
return 0;
}
PyErr_Clear();
const char *seq;
double a, b, c;
const char *seq{};
double a{}, b{}, c{};
if (PyArg_ParseTuple(args, "sddd", &seq, &a, &b, &c)) {
PY_TRY {
getRotationPtr()->setEulerAngles(
@@ -176,7 +176,7 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
}
PyErr_Clear();
PyObject *v1, *v2;
PyObject *v1{}, *v2{};
if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type), &v1,
&(Base::VectorPy::Type), &v2)) {
Py::Vector from(v1, false);
@@ -186,7 +186,7 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
}
PyErr_Clear();
PyObject *v3;
PyObject *v3{};
const char *priority = nullptr;
if (PyArg_ParseTuple(args, "O!O!O!|s", &(Base::VectorPy::Type), &v1,
&(Base::VectorPy::Type), &v2,
@@ -275,7 +275,7 @@ PyObject* RotationPy::inverted(PyObject * args)
PyObject* RotationPy::multiply(PyObject * args)
{
PyObject *rot;
PyObject *rot{};
if (!PyArg_ParseTuple(args, "O!", &(RotationPy::Type), &rot))
return nullptr;
Rotation mult = (*getRotationPtr()) * (*static_cast<RotationPy*>(rot)->getRotationPtr());
@@ -284,7 +284,7 @@ PyObject* RotationPy::multiply(PyObject * args)
PyObject* RotationPy::multVec(PyObject * args)
{
PyObject *obj;
PyObject *obj{};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
Base::Vector3d vec(static_cast<VectorPy*>(obj)->value());
@@ -294,8 +294,8 @@ PyObject* RotationPy::multVec(PyObject * args)
PyObject* RotationPy::slerp(PyObject * args)
{
PyObject *rot;
double t;
PyObject *rot{};
double t{};
if (!PyArg_ParseTuple(args, "O!d", &(RotationPy::Type), &rot, &t))
return nullptr;
Rotation *rot0 = this->getRotationPtr();
@@ -306,7 +306,7 @@ PyObject* RotationPy::slerp(PyObject * args)
PyObject* RotationPy::setYawPitchRoll(PyObject * args)
{
double A,B,C;
double A{},B{},C{};
if (!PyArg_ParseTuple(args, "ddd", &A, &B, &C))
return nullptr;
this->getRotationPtr()->setYawPitchRoll(A,B,C);
@@ -317,7 +317,7 @@ PyObject* RotationPy::getYawPitchRoll(PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
double A,B,C;
double A{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
Py::Tuple tuple(3);
@@ -329,8 +329,8 @@ PyObject* RotationPy::getYawPitchRoll(PyObject * args)
PyObject* RotationPy::setEulerAngles(PyObject * args)
{
const char *seq;
double A,B,C;
const char *seq{};
double A{},B{},C{};
if (!PyArg_ParseTuple(args, "sddd", &seq, &A, &B, &C))
return nullptr;
@@ -358,7 +358,7 @@ PyObject* RotationPy::toEulerAngles(PyObject * args)
}
PY_TRY {
double A,B,C;
double A{},B{},C{};
this->getRotationPtr()->getEulerAngles(
Rotation::eulerSequenceFromName(seq),A,B,C);
@@ -382,7 +382,7 @@ PyObject* RotationPy::toMatrix(PyObject * args)
PyObject* RotationPy::isSame(PyObject *args)
{
PyObject *rot;
PyObject *rot{};
double tol = 0.0;
if (!PyArg_ParseTuple(args, "O!|d", &(RotationPy::Type), &rot, &tol))
return nullptr;
@@ -412,7 +412,7 @@ PyObject* RotationPy::isNull(PyObject *args)
Py::Tuple RotationPy::getQ() const
{
double q0, q1, q2, q3;
double q0{}, q1{}, q2{}, q3{};
this->getRotationPtr()->getValue(q0,q1,q2,q3);
Py::Tuple tuple(4);
@@ -434,21 +434,21 @@ void RotationPy::setQ(Py::Tuple arg)
Py::Object RotationPy::getRawAxis() const
{
Base::Vector3d axis; double angle;
Base::Vector3d axis; double angle{};
this->getRotationPtr()->getRawValue(axis, angle);
return Py::Vector(axis);
return Py::Vector(axis); // NOLINT
}
Py::Object RotationPy::getAxis() const
{
Base::Vector3d axis; double angle;
Base::Vector3d axis; double angle{};
this->getRotationPtr()->getValue(axis, angle);
return Py::Vector(axis);
return Py::Vector(axis); // NOLINT
}
void RotationPy::setAxis(Py::Object arg)
{
Base::Vector3d axis; double angle;
Base::Vector3d axis; double angle{};
this->getRotationPtr()->getValue(axis, angle);
axis = Py::Vector(arg).toVector();
this->getRotationPtr()->setValue(axis, angle);
@@ -456,14 +456,14 @@ void RotationPy::setAxis(Py::Object arg)
Py::Float RotationPy::getAngle() const
{
Base::Vector3d axis; double angle;
Base::Vector3d axis; double angle{};
this->getRotationPtr()->getValue(axis, angle);
return Py::Float(angle);
}
void RotationPy::setAngle(Py::Float arg)
{
Base::Vector3d axis; double angle;
Base::Vector3d axis; double angle{};
this->getRotationPtr()->getRawValue(axis, angle);
angle = static_cast<double>(arg);
this->getRotationPtr()->setValue(axis, angle);
@@ -477,21 +477,22 @@ PyObject *RotationPy::getCustomAttributes(const char* attr) const
return new MatrixPy(mat);
}
else if (strcmp(attr, "Yaw") == 0) {
double A,B,C;
double A{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
return PyFloat_FromDouble(A);
}
else if (strcmp(attr, "Pitch") == 0) {
double A,B,C;
double A{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
return PyFloat_FromDouble(B);
}
else if (strcmp(attr, "Roll") == 0) {
double A,B,C;
double A{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
return PyFloat_FromDouble(C);
}
else if (strcmp(attr, "toEuler") == 0) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
Py::Object self(const_cast<RotationPy*>(this), false);
return Py::new_reference_to(self.getAttr("getYawPitchRoll"));
}
@@ -528,7 +529,7 @@ 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{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
this->getRotationPtr()->setYawPitchRoll(V,B,C);
return 1;
@@ -537,7 +538,7 @@ 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{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
this->getRotationPtr()->setYawPitchRoll(A,V,C);
return 1;
@@ -546,7 +547,7 @@ 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{},B{},C{};
this->getRotationPtr()->getYawPitchRoll(A,B,C);
this->getRotationPtr()->setYawPitchRoll(A,B,V);
return 1;
@@ -602,7 +603,7 @@ PyObject * RotationPy::number_power_handler (PyObject* self, PyObject* other, Py
long b = Py::Int(other);
Vector3d axis;
double rfAngle;
double rfAngle{};
a.getRawValue(axis, rfAngle);
rfAngle *= b;

View File

@@ -42,7 +42,7 @@ void Base::SwapVar (unsigned char&)
void Base::SwapVar (short& s)
{
short sTmp = s;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (short); i++)
*(((char*) &sTmp) + i) = *(((char*) &s) + sizeof (short) - i - 1);
@@ -52,7 +52,7 @@ void Base::SwapVar (short& s)
void Base::SwapVar (unsigned short& s)
{
short sTmp = s;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (short); i++)
*(((char*) &sTmp) + i) = *(((char*) &s) + sizeof (short) - i - 1);
@@ -62,7 +62,7 @@ void Base::SwapVar (unsigned short& s)
void Base::SwapVar (long& l)
{
long lTmp = l;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (long); i++)
*(((char*) &lTmp) + i) = *(((char*) &l) + sizeof (long) - i - 1);
@@ -72,7 +72,7 @@ void Base::SwapVar (long& l)
void Base::SwapVar (unsigned long& l)
{
long lTmp = l;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (long); i++)
*(((char*) &lTmp) + i) = *(((char*) &l) + sizeof (long) - i - 1);
@@ -82,7 +82,7 @@ void Base::SwapVar (unsigned long& l)
void Base::SwapVar (float& f)
{
float fTmp = f;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (float); i++)
*(((char*) &fTmp) + i) = *(((char*) &f) + sizeof (float) - i - 1);
@@ -92,7 +92,7 @@ void Base::SwapVar (float& f)
void Base::SwapVar (double& d)
{
double dTmp = d;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (double); i++)
*(((char*) &dTmp) + i) = *(((char*) &d) + sizeof (double) - i - 1);

View File

@@ -51,7 +51,7 @@ template <class T>
void SwapEndian(T& v)
{
T tmp = v;
int i;
int i = 0;
for (i = 0; i < (int)sizeof (T); i++)
*(((char*) &tmp) + i) = *(((char*) &v) + sizeof (T) - i - 1);

View File

@@ -35,7 +35,7 @@ using namespace Base;
double Vector2d::GetAngle (const Vector2d &rclVect) const
{
double fDivid, fNum;
double fDivid = 0.0, fNum = 0.0;
fDivid = Length() * rclVect.Length();
@@ -129,7 +129,7 @@ bool BoundBox2d::Intersect(const BoundBox2d &rclBB) const
bool BoundBox2d::Intersect(const Polygon2d &rclPoly) const
{
unsigned long i;
unsigned long i = 0;
Line2d clLine;
// points contained in boundbox
@@ -181,7 +181,7 @@ BoundBox2d Line2d::CalcBoundBox () const
bool Line2d::Intersect (const Line2d& rclLine, Vector2d &rclV) const
{
double m1, m2, b1, b2;
double m1 = 0.0, m2 = 0.0, b1 = 0.0, b2 = 0.0;
// calc coefficients
if (fabs (clV2.x - clV1.x) > 1e-10)
@@ -261,7 +261,7 @@ bool Line2d::IntersectAndContain (const Line2d& rclLine, Vector2d &rclV) const
BoundBox2d Polygon2d::CalcBoundBox () const
{
unsigned long i;
unsigned long i = 0;
BoundBox2d clBB;
for (i = 0; i < _aclVct.size(); i++)
{
@@ -275,8 +275,8 @@ BoundBox2d Polygon2d::CalcBoundBox () const
static short _CalcTorsion (double *pfLine, double fX, double fY)
{
int sQuad[2], i; // Changing this from short to int allows the compiler to inline this function
double fResX;
int sQuad[2], i = 0; // Changing this from short to int allows the compiler to inline this function
double fResX = 0.0;
// Classification of both polygon points into quadrants
for (i = 0; i < 2; i++)
@@ -315,7 +315,7 @@ bool Polygon2d::Contains (const Vector2d &rclV) const
// whether a point is contained within a polygon.
// The sum of all turns indicates whether yes or no.
double pfTmp[4];
unsigned long i;
unsigned long i = 0;
short sTorsion = 0;
// Error check

View File

@@ -76,8 +76,8 @@ Translate::~Translate() = default;
Py::Object Translate::translate(const Py::Tuple& args)
{
char *context;
char *source;
char *context = nullptr;
char *source = nullptr;
char *disambiguation = nullptr;
int n=-1;
if (!PyArg_ParseTuple(args.ptr(), "ss|zi", &context, &source, &disambiguation, &n))
@@ -89,8 +89,8 @@ Py::Object Translate::translate(const Py::Tuple& args)
Py::Object Translate::translateNoop(const Py::Tuple& args)
{
PyObject* arg1;
PyObject* arg2;
PyObject* arg1 = nullptr;
PyObject* arg2 = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "OO", &arg1, &arg2))
throw Py::Exception();
return Py::Object(arg2);
@@ -98,9 +98,9 @@ Py::Object Translate::translateNoop(const Py::Tuple& args)
Py::Object Translate::translateNoop3(const Py::Tuple& args)
{
PyObject* arg1;
PyObject* arg2;
PyObject* arg3;
PyObject* arg1 = nullptr;
PyObject* arg2 = nullptr;
PyObject* arg3 = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "OOO", &arg1, &arg2, &arg3))
throw Py::Exception();
return Py::Object(arg2);
@@ -108,7 +108,7 @@ Py::Object Translate::translateNoop3(const Py::Tuple& args)
Py::Object Translate::trNoop(const Py::Tuple& args)
{
PyObject* arg1;
PyObject* arg1 = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "O", &arg1))
throw Py::Exception();
return Py::Object(arg1);
@@ -116,7 +116,7 @@ Py::Object Translate::trNoop(const Py::Tuple& args)
Py::Object Translate::installTranslator(const Py::Tuple& args)
{
char* Name;
char* Name = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
throw Py::Exception();
QString filename = QString::fromUtf8(Name);
@@ -132,7 +132,7 @@ Py::Object Translate::installTranslator(const Py::Tuple& args)
ok = true;
}
return Py::Boolean(ok);
return Py::Boolean(ok); // NOLINT
}
Py::Object Translate::removeTranslators(const Py::Tuple& args)
@@ -145,5 +145,5 @@ Py::Object Translate::removeTranslators(const Py::Tuple& args)
}
translators.clear();
return Py::Boolean(ok);
return Py::Boolean(ok); // NOLINT
}

View File

@@ -41,7 +41,7 @@ std::string TypePy::representation() const
PyObject* TypePy::fromName (PyObject *args)
{
const char *name;
const char *name{};
if (!PyArg_ParseTuple(args, "s", &name))
return nullptr;
@@ -51,7 +51,7 @@ PyObject* TypePy::fromName (PyObject *args)
PyObject* TypePy::fromKey (PyObject *args)
{
unsigned int index;
unsigned int index{};
if (!PyArg_ParseTuple(args, "I", &index))
return nullptr;
@@ -100,14 +100,14 @@ PyObject* TypePy::isDerivedFrom(PyObject *args)
Base::Type type;
do {
const char *name;
const char *name{};
if (PyArg_ParseTuple(args, "s", &name)) {
type = Base::Type::fromName(name);
break;
}
PyErr_Clear();
PyObject* t;
PyObject* t{};
if (PyArg_ParseTuple(args, "O!", &TypePy::Type, &t)) {
type = *static_cast<TypePy*>(t)->getBaseTypePtr();
break;
@@ -127,14 +127,14 @@ PyObject* TypePy::getAllDerivedFrom(PyObject *args)
Base::Type type;
do {
const char *name;
const char *name{};
if (PyArg_ParseTuple(args, "s", &name)) {
type = Base::Type::fromName(name);
break;
}
PyErr_Clear();
PyObject* t;
PyObject* t{};
if (PyArg_ParseTuple(args, "O!", &TypePy::Type, &t)) {
type = *static_cast<TypePy*>(t)->getBaseTypePtr();
break;
@@ -224,8 +224,8 @@ PyObject* TypePy::createInstance (PyObject *args)
PyObject* TypePy::createInstanceByName (PyObject *args)
{
const char* name;
PyObject* load = Py_False;
const char* name{};
PyObject* load = Py_False; //NOLINT
if (!PyArg_ParseTuple(args, "s|O!", &name, &PyBool_Type, &load))
return nullptr;

View File

@@ -62,7 +62,7 @@ PyObject *UnitPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Pytho
// constructor method
int UnitPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject *object;
PyObject *object{};
Unit *self = getUnitPtr();
// get quantity
@@ -80,7 +80,7 @@ int UnitPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear(); // set by PyArg_ParseTuple()
// get string
char* string;
char* string{};
if (PyArg_ParseTuple(args,"et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
PyMem_Free(string);
@@ -194,12 +194,12 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op)
return nullptr;
}
else if (op == Py_EQ) {
res = (*u1 == *u2) ? Py_True : Py_False;
res = (*u1 == *u2) ? Py_True : Py_False; //NOLINT
Py_INCREF(res);
return res;
}
else {
res = (*u1 != *u2) ? Py_True : Py_False;
res = (*u1 != *u2) ? Py_True : Py_False; //NOLINT
Py_INCREF(res);
return res;
}

View File

@@ -198,7 +198,7 @@ double UnitsApi::toDouble(PyObject *ArgObj, const Base::Unit &u)
Quantity UnitsApi::toQuantity(PyObject *ArgObj, const Base::Unit &u)
{
double d;
double d{};
if (PyUnicode_Check(ArgObj)) {
QString str = QString::fromUtf8(PyUnicode_AsUTF8(ArgObj));
// Parse the string

View File

@@ -60,7 +60,7 @@ public:
static QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString);
static QString schemaTranslate(const Base::Quantity& quant) { // to satisfy GCC
double dummy1;
double dummy1{};
QString dummy2;
return UnitsApi::schemaTranslate(quant, dummy1, dummy2);
}

View File

@@ -76,7 +76,7 @@ PyMethodDef UnitsApi::Methods[] = {
PyObject* UnitsApi::sParseQuantity(PyObject * /*self*/, PyObject *args)
{
char *pstr;
char *pstr{};
if (!PyArg_ParseTuple(args, "et", "utf-8", &pstr))
return nullptr;
@@ -108,7 +108,7 @@ PyObject* UnitsApi::sListSchemas(PyObject * /*self*/, PyObject *args)
}
PyErr_Clear();
int index;
int index{};
if (PyArg_ParseTuple(args, "i", &index)) {
int num = static_cast<int>(UnitSystem::NumUnitSystemTypes);
if (index < 0 || index >= num) {
@@ -135,7 +135,7 @@ PyObject* UnitsApi::sGetSchema(PyObject * /*self*/, PyObject *args)
PyObject* UnitsApi::sSetSchema(PyObject * /*self*/, PyObject *args)
{
PyErr_Clear();
int index;
int index{};
if (PyArg_ParseTuple(args, "i", &index)) {
int num = static_cast<int>(UnitSystem::NumUnitSystemTypes);
if (index < 0 || index >= num) {
@@ -149,8 +149,8 @@ PyObject* UnitsApi::sSetSchema(PyObject * /*self*/, PyObject *args)
PyObject* UnitsApi::sSchemaTranslate(PyObject * /*self*/, PyObject *args)
{
PyObject* q;
int index;
PyObject* q{};
int index{};
if (!PyArg_ParseTuple(args, "O!i", &(QuantityPy::Type), &q, &index))
return nullptr;
@@ -163,7 +163,7 @@ PyObject* UnitsApi::sSchemaTranslate(PyObject * /*self*/, PyObject *args)
return nullptr;
}
double factor;
double factor{};
QString uus;
QString uss = schema->schemaTranslate(quant, factor, uus);
@@ -177,12 +177,12 @@ PyObject* UnitsApi::sSchemaTranslate(PyObject * /*self*/, PyObject *args)
PyObject* UnitsApi::sToNumber(PyObject * /*self*/, PyObject *args)
{
double value;
double value{};
char* format = "g";
int decimals;
int decimals{};
do {
PyObject* q;
PyObject* q{};
if (PyArg_ParseTuple(args, "O!|si", &(QuantityPy::Type), &q, &format, &decimals)) {
value = static_cast<QuantityPy*>(q)->getQuantityPtr()->getValue();
break;
@@ -203,7 +203,7 @@ PyObject* UnitsApi::sToNumber(PyObject * /*self*/, PyObject *args)
return nullptr;
}
bool ok;
bool ok{};
QuantityFormat qf;
qf.format = QuantityFormat::toFormat(format[0], &ok);
qf.precision = decimals;

View File

@@ -218,18 +218,18 @@ QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity &quant, doub
double totalInches = std::abs(quant.getValue())/factor;
// minimum denominator (8 for 1/8, 16 for 1/16, etc)
int minden;
int minden{};
// Outputs
int feet; // whole feet
int inches; // whole inches
int num,den; // numerator and denominator of fractional val
int feet{}; // whole feet
int inches{}; // whole inches
int num{},den{}; // numerator and denominator of fractional val
std::stringstream output; // output stream
// Intermediate values
int ntot; // total fractional units
int a,b,d; // used to compute greatest common denominator
int tmp; // temporary variable for GCD
int ntot{}; // total fractional units
int a{},b{},d{}; // used to compute greatest common denominator
int tmp{}; // temporary variable for GCD
// Get the current user specified minimum denominator
minden = quant.getFormat().getDenominator();

View File

@@ -63,7 +63,7 @@ PyObject *VectorPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Pyt
int VectorPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
double x=0.0,y=0.0,z=0.0;
PyObject *object;
PyObject *object = nullptr;
VectorPy::PointerType ptr = getVectorPtr();
if (PyArg_ParseTuple(args, "|ddd", &x,&y,&z)) {
ptr->Set(x,y,z);
@@ -240,7 +240,7 @@ PyObject * VectorPy::mapping_subscript(PyObject *self, PyObject *item)
return sequence_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, cur, i;
Py_ssize_t start = 0, stop = 0, step = 0, slicelength = 0, cur = 0, i = 0;
PyObject* slice = item;
if (PySlice_GetIndicesEx(slice,
@@ -283,7 +283,7 @@ PyObject * VectorPy::mapping_subscript(PyObject *self, PyObject *item)
PyObject* VectorPy::add(PyObject *args)
{
PyObject *obj;
PyObject *obj = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
@@ -298,7 +298,7 @@ PyObject* VectorPy::add(PyObject *args)
PyObject* VectorPy::sub(PyObject *args)
{
PyObject *obj;
PyObject *obj = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
@@ -335,12 +335,12 @@ PyObject* VectorPy::richCompare(PyObject *v, PyObject *w, int op)
return nullptr;
}
else if (op == Py_EQ) {
res = (v1 == v2) ? Py_True : Py_False;
res = (v1 == v2) ? Py_True : Py_False; //NOLINT
Py_INCREF(res);
return res;
}
else {
res = (v1 != v2) ? Py_True : Py_False;
res = (v1 != v2) ? Py_True : Py_False; //NOLINT
Py_INCREF(res);
return res;
}
@@ -354,7 +354,7 @@ PyObject* VectorPy::richCompare(PyObject *v, PyObject *w, int op)
PyObject* VectorPy::isEqual(PyObject *args)
{
PyObject *obj;
PyObject *obj = nullptr;
double tolerance=0;
if (!PyArg_ParseTuple(args, "O!d", &(VectorPy::Type), &obj, &tolerance))
return nullptr;
@@ -370,7 +370,7 @@ PyObject* VectorPy::isEqual(PyObject *args)
PyObject* VectorPy::scale(PyObject *args)
{
double factorX, factorY, factorZ;
double factorX = 0.0, factorY = 0.0, factorZ = 0.0;
if (!PyArg_ParseTuple(args, "ddd", &factorX, &factorY, &factorZ))
return nullptr;
VectorPy::PointerType ptr = getVectorPtr();
@@ -381,7 +381,7 @@ PyObject* VectorPy::scale(PyObject *args)
PyObject* VectorPy::multiply(PyObject *args)
{
double factor;
double factor = 0.0;
if (!PyArg_ParseTuple(args, "d", &factor))
return nullptr;
VectorPy::PointerType ptr = getVectorPtr();
@@ -392,7 +392,7 @@ PyObject* VectorPy::multiply(PyObject *args)
PyObject* VectorPy::dot(PyObject *args)
{
PyObject *obj;
PyObject *obj = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
@@ -407,7 +407,7 @@ PyObject* VectorPy::dot(PyObject *args)
PyObject* VectorPy::cross(PyObject *args)
{
PyObject *obj;
PyObject *obj = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
@@ -422,7 +422,7 @@ PyObject* VectorPy::cross(PyObject *args)
PyObject* VectorPy::isOnLineSegment(PyObject *args)
{
PyObject *start, *end;
PyObject *start = nullptr, *end = nullptr;
if (!PyArg_ParseTuple(args, "OO",&start, &end))
return nullptr;
if (!PyObject_TypeCheck(start, &(VectorPy::Type))) {
@@ -448,7 +448,7 @@ PyObject* VectorPy::isOnLineSegment(PyObject *args)
PyObject* VectorPy::getAngle(PyObject *args)
{
PyObject *obj;
PyObject *obj = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
return nullptr;
@@ -478,7 +478,7 @@ PyObject* VectorPy::normalize(PyObject *args)
PyObject* VectorPy::projectToLine(PyObject *args)
{
PyObject *base, *line;
PyObject *base = nullptr, *line = nullptr;
if (!PyArg_ParseTuple(args, "OO",&base, &line))
return nullptr;
if (!PyObject_TypeCheck(base, &(VectorPy::Type))) {
@@ -504,7 +504,7 @@ PyObject* VectorPy::projectToLine(PyObject *args)
PyObject* VectorPy::projectToPlane(PyObject *args)
{
PyObject *base, *line;
PyObject *base = nullptr, *line = nullptr;
if (!PyArg_ParseTuple(args, "OO",&base, &line))
return nullptr;
if (!PyObject_TypeCheck(base, &(VectorPy::Type))) {
@@ -530,7 +530,7 @@ PyObject* VectorPy::projectToPlane(PyObject *args)
PyObject* VectorPy::distanceToPoint(PyObject *args)
{
PyObject *pnt;
PyObject *pnt = nullptr;
if (!PyArg_ParseTuple(args, "O!",&(VectorPy::Type),&pnt))
return nullptr;
@@ -544,7 +544,7 @@ PyObject* VectorPy::distanceToPoint(PyObject *args)
PyObject* VectorPy::distanceToLine(PyObject *args)
{
PyObject *base, *line;
PyObject *base = nullptr, *line = nullptr;
if (!PyArg_ParseTuple(args, "OO",&base, &line))
return nullptr;
if (!PyObject_TypeCheck(base, &(VectorPy::Type))) {
@@ -569,7 +569,7 @@ PyObject* VectorPy::distanceToLine(PyObject *args)
PyObject* VectorPy::distanceToLineSegment(PyObject *args)
{
PyObject *base, *line;
PyObject *base = nullptr, *line = nullptr;
if (!PyArg_ParseTuple(args, "OO",&base, &line))
return nullptr;
if (!PyObject_TypeCheck(base, &(VectorPy::Type))) {
@@ -594,7 +594,7 @@ PyObject* VectorPy::distanceToLineSegment(PyObject *args)
PyObject* VectorPy::distanceToPlane(PyObject *args)
{
PyObject *base, *line;
PyObject *base = nullptr, *line = nullptr;
if (!PyArg_ParseTuple(args, "OO",&base, &line))
return nullptr;
if (!PyObject_TypeCheck(base, &(VectorPy::Type))) {

View File

@@ -129,7 +129,7 @@ void Writer::insertAsciiFile(const char* FileName)
throw Base::FileException("Writer::insertAsciiFile() Could not open file!");
Stream() << "<![CDATA[";
char ch;
char ch{};
while (from.get(ch))
Stream().put(ch);
Stream() << "]]>" << endl;
@@ -146,6 +146,7 @@ void Writer::insertBinFile(const char* FileName)
std::ifstream::pos_type fileSize = from.tellg();
from.seekg(0, std::ios::beg);
std::vector<unsigned char> bytes(static_cast<size_t>(fileSize));
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
from.read(reinterpret_cast<char*>(&bytes[0]), fileSize);
Stream() << Base::base64_encode(&bytes[0], static_cast<unsigned int>(fileSize));
Stream() << "]]>" << endl;

View File

@@ -33,7 +33,7 @@ void XMLTools::initialize()
{
XERCES_CPP_NAMESPACE_USE;
if (!transcoder.get()) {
XMLTransService::Codes res;
XMLTransService::Codes res{};
transcoder.reset(XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XERCES_CPP_NAMESPACE_QUALIFIER XMLRecognizer::UTF_8, res, 4096, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager));
if (res != XMLTransService::Ok)
throw Base::UnicodeError("Can\'t create transcoder");
@@ -49,7 +49,7 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode)
//char outBuff[128];
static XMLByte outBuff[128];
XMLSize_t outputLength;
XMLSize_t outputLength = 0;
XMLSize_t eaten = 0;
XMLSize_t offset = 0;
XMLSize_t inputLength = XMLString::stringLen(toTranscode);
@@ -80,7 +80,7 @@ std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
static XMLCh outBuff[128];
const XMLByte* xmlBytes = reinterpret_cast<const XMLByte*>(fromTranscode);
XMLSize_t outputLength;
XMLSize_t outputLength = 0;
XMLSize_t eaten = 0;
XMLSize_t offset = 0;
XMLSize_t inputLength = std::string(fromTranscode).size();

View File

@@ -150,7 +150,7 @@ bool ZipHeader::readEndOfCentralDirectory(std::istream &_zipfile)
bool ZipHeader::confirmLocalHeaders(std::istream &_zipfile)
{
zipios::Entries::const_iterator it;
zipios::ZipCDirEntry *ent;
zipios::ZipCDirEntry *ent{};
int inconsistencies = 0;
zipios::ZipLocalEntry zlh;
for (it = _entries.begin(); it != _entries.end(); ++it) {

View File

@@ -74,7 +74,7 @@ void cleanupSWIG_T(const char* TypeName)
if (!swig_type)
return;
PyObject *module, *dict;
PyObject *module{}, *dict{};
PyObject *modules = PyImport_GetModuleDict();
module = PyDict_GetItemString(modules, "__builtin__");
if (module && PyModule_Check(module)) {
@@ -87,8 +87,8 @@ void cleanupSWIG_T(const char* TypeName)
PyObject* dict = PyModule_GetDict(module);
if (!dict) return;
Py_ssize_t pos;
PyObject *key, *value;
Py_ssize_t pos{};
PyObject *key{}, *value{};
pos = 0;
while (PyDict_Next(dict, &pos, &key, &value)) {
if (value != Py_None && PyUnicode_Check(key)) {