From 0b8990c96c6bcd4f51bc993bbb18d992b5aac9cd Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Mar 2024 14:09:17 +0100 Subject: [PATCH] Points: fix many linter warnings --- src/Mod/Mesh/App/WildMagic4/Wm4Sphere3.h | 2 +- src/Mod/Points/App/AppPointsPy.cpp | 12 +- src/Mod/Points/App/Points.cpp | 32 ++- src/Mod/Points/App/Points.h | 12 +- src/Mod/Points/App/PointsAlgos.cpp | 259 ++++++++++++----------- src/Mod/Points/App/PointsAlgos.h | 17 +- src/Mod/Points/App/PointsFeature.h | 2 +- src/Mod/Points/App/PointsGrid.cpp | 167 ++++++++------- src/Mod/Points/App/PointsGrid.h | 19 +- src/Mod/Points/App/PointsPyImp.cpp | 10 +- src/Mod/Points/App/Properties.h | 2 +- src/Mod/Points/Gui/DlgPointsReadImp.cpp | 2 +- src/Mod/Points/Gui/DlgPointsReadImp.h | 2 + src/Mod/Points/Gui/ViewProvider.cpp | 2 +- 14 files changed, 298 insertions(+), 242 deletions(-) diff --git a/src/Mod/Mesh/App/WildMagic4/Wm4Sphere3.h b/src/Mod/Mesh/App/WildMagic4/Wm4Sphere3.h index 9eface1c34..14e23f4c4d 100644 --- a/src/Mod/Mesh/App/WildMagic4/Wm4Sphere3.h +++ b/src/Mod/Mesh/App/WildMagic4/Wm4Sphere3.h @@ -38,7 +38,7 @@ public: Sphere3& operator= (const Sphere3& rkSphere); Vector3 Center; - Real Radius; + Real Radius{}; }; } diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index c439779e74..3f15ed8665 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -75,7 +75,7 @@ private: } Py::Object open(const Py::Tuple& args) { - char* Name; + char* Name {}; if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name)) { throw Py::Exception(); } @@ -196,8 +196,8 @@ private: Py::Object importer(const Py::Tuple& args) { - char* Name; - const char* DocName; + char* Name {}; + const char* DocName {}; if (!PyArg_ParseTuple(args.ptr(), "ets", "utf-8", &Name, &DocName)) { throw Py::Exception(); } @@ -311,8 +311,8 @@ private: Py::Object exporter(const Py::Tuple& args) { - PyObject* object; - char* Name; + PyObject* object {}; + char* Name {}; if (!PyArg_ParseTuple(args.ptr(), "Oet", &object, "utf-8", &Name)) { throw Py::Exception(); @@ -403,7 +403,7 @@ private: Py::Object show(const Py::Tuple& args) { - PyObject* pcObj; + PyObject* pcObj {}; const char* name = "Points"; if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(PointsPy::Type), &pcObj, &name)) { throw Py::Exception(); diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index 67e9d4bfef..bbfda4a309 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -50,6 +50,11 @@ PointKernel::PointKernel(const PointKernel& pts) , _Points(pts._Points) {} +PointKernel::PointKernel(PointKernel&& pts) noexcept + : _Mtrx(pts._Mtrx) + , _Points(std::move(pts._Points)) +{} + std::vector PointKernel::getElementTypes() const { std::vector temp; @@ -121,13 +126,26 @@ Base::BoundBox3d PointKernel::getBoundBox() const return bnd; } -void PointKernel::operator=(const PointKernel& Kernel) +PointKernel& PointKernel::operator=(const PointKernel& Kernel) { if (this != &Kernel) { // copy the mesh structure setTransform(Kernel._Mtrx); this->_Points = Kernel._Points; } + + return *this; +} + +PointKernel& PointKernel::operator=(PointKernel&& Kernel) noexcept +{ + if (this != &Kernel) { + // copy the mesh structure + setTransform(Kernel._Mtrx); + this->_Points = std::move(Kernel._Points); + } + + return *this; } unsigned int PointKernel::getMemSize() const @@ -204,9 +222,9 @@ void PointKernel::RestoreDocFile(Base::Reader& reader) str >> uCt; _Points.resize(uCt); for (unsigned long i = 0; i < uCt; i++) { - float x; - float y; - float z; + float x {}; + float y {}; + float z {}; str >> x >> y >> z; _Points[i].Set(x, y, z); } @@ -260,11 +278,17 @@ PointKernel::const_point_iterator::const_point_iterator( PointKernel::const_point_iterator::const_point_iterator( const PointKernel::const_point_iterator& fi) = default; +PointKernel::const_point_iterator::const_point_iterator(PointKernel::const_point_iterator&& fi) = + default; + PointKernel::const_point_iterator::~const_point_iterator() = default; PointKernel::const_point_iterator& PointKernel::const_point_iterator::operator=(const PointKernel::const_point_iterator& pi) = default; +PointKernel::const_point_iterator& +PointKernel::const_point_iterator::operator=(PointKernel::const_point_iterator&& pi) = default; + void PointKernel::const_point_iterator::dereference() { value_type vertd(_p_it->x, _p_it->y, _p_it->z); diff --git a/src/Mod/Points/App/Points.h b/src/Mod/Points/App/Points.h index 6f21b76b0a..8ddec22a1e 100644 --- a/src/Mod/Points/App/Points.h +++ b/src/Mod/Points/App/Points.h @@ -58,9 +58,11 @@ public: resize(size); } PointKernel(const PointKernel&); + PointKernel(PointKernel&&) noexcept; ~PointKernel() override = default; - void operator=(const PointKernel&); + PointKernel& operator=(const PointKernel&); + PointKernel& operator=(PointKernel&&) noexcept; /** @name Subelement management */ //@{ @@ -180,13 +182,15 @@ public: const_point_iterator(const PointKernel*, std::vector::const_iterator index); const_point_iterator(const const_point_iterator& pi); + const_point_iterator(const_point_iterator&& pi); ~const_point_iterator(); - const_point_iterator& operator=(const const_point_iterator& fi); + const_point_iterator& operator=(const const_point_iterator& pi); + const_point_iterator& operator=(const_point_iterator&& pi); const value_type& operator*(); const value_type* operator->(); - bool operator==(const const_point_iterator& fi) const; - bool operator!=(const const_point_iterator& fi) const; + bool operator==(const const_point_iterator& pi) const; + bool operator!=(const const_point_iterator& pi) const; const_point_iterator& operator++(); const_point_iterator operator++(int); const_point_iterator& operator--(); diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index 491005e633..fcec4cce95 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -124,11 +124,7 @@ void PointsAlgos::LoadAscii(PointKernel& points, const char* FileName) // ---------------------------------------------------------------------------- -Reader::Reader() -{ - width = 0; - height = 0; -} +Reader::Reader() = default; Reader::~Reader() = default; @@ -253,11 +249,8 @@ class DataStreambuf: public std::streambuf public: explicit DataStreambuf(const std::vector& data) : _buffer(data) - { - _beg = 0; - _end = data.size(); - _cur = 0; - } + , _end(int(data.size())) + {} ~DataStreambuf() override = default; protected: @@ -291,8 +284,9 @@ protected: } pos_type seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, - std::ios_base::openmode = std::ios::in | std::ios::out) override + std::ios_base::openmode mode = std::ios::in | std::ios::out) override { + (void)mode; int p_pos = -1; if (way == std::ios_base::beg) { p_pos = _beg; @@ -331,9 +325,10 @@ public: private: const std::vector& _buffer; - int _beg, _end, _cur; + int _beg {0}, _end {0}, _cur {0}; }; +// NOLINTBEGIN // Taken from https://github.com/PointCloudLibrary/pcl/blob/master/io/src/lzf.cpp unsigned int lzfDecompress(const void* const in_data, unsigned int in_len, void* out_data, unsigned int out_len) @@ -544,6 +539,7 @@ lzfDecompress(const void* const in_data, unsigned int in_len, void* out_data, un return (static_cast(op - static_cast(out_data))); } } // namespace Points +// NOLINTEND PlyReader::PlyReader() = default; @@ -561,7 +557,7 @@ void PlyReader::read(const std::string& filename) std::vector types; std::vector sizes; std::size_t offset = 0; - std::size_t numPoints = readHeader(inp, format, offset, fields, types, sizes); + Eigen::Index numPoints = Eigen::Index(readHeader(inp, format, offset, fields, types, sizes)); Eigen::MatrixXd data(numPoints, fields.size()); if (format == "ascii") { @@ -575,31 +571,31 @@ void PlyReader::read(const std::string& filename) } std::vector::iterator it; - std::size_t max_size = std::numeric_limits::max(); + Eigen::Index max_size = std::numeric_limits::max(); // x field - std::size_t x = max_size; + Eigen::Index x = max_size; it = std::find(fields.begin(), fields.end(), "x"); if (it != fields.end()) { x = std::distance(fields.begin(), it); } // y field - std::size_t y = max_size; + Eigen::Index y = max_size; it = std::find(fields.begin(), fields.end(), "y"); if (it != fields.end()) { y = std::distance(fields.begin(), it); } // z field - std::size_t z = max_size; + Eigen::Index z = max_size; it = std::find(fields.begin(), fields.end(), "z"); if (it != fields.end()) { z = std::distance(fields.begin(), it); } // normal x field - std::size_t normal_x = max_size; + Eigen::Index normal_x = max_size; it = std::find(fields.begin(), fields.end(), "normal_x"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "nx"); @@ -609,7 +605,7 @@ void PlyReader::read(const std::string& filename) } // normal y field - std::size_t normal_y = max_size; + Eigen::Index normal_y = max_size; it = std::find(fields.begin(), fields.end(), "normal_y"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "ny"); @@ -619,7 +615,7 @@ void PlyReader::read(const std::string& filename) } // normal z field - std::size_t normal_z = max_size; + Eigen::Index normal_z = max_size; it = std::find(fields.begin(), fields.end(), "normal_z"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "nz"); @@ -629,14 +625,17 @@ void PlyReader::read(const std::string& filename) } // intensity field - std::size_t greyvalue = max_size; + Eigen::Index greyvalue = max_size; it = std::find(fields.begin(), fields.end(), "intensity"); if (it != fields.end()) { greyvalue = std::distance(fields.begin(), it); } // rgb(a) field - std::size_t red = max_size, green = max_size, blue = max_size, alpha = max_size; + Eigen::Index red = max_size; + Eigen::Index green = max_size; + Eigen::Index blue = max_size; + Eigen::Index alpha = max_size; it = std::find(fields.begin(), fields.end(), "red"); if (it != fields.end()) { red = std::distance(fields.begin(), it); @@ -665,22 +664,22 @@ void PlyReader::read(const std::string& filename) if (hasData) { points.reserve(numPoints); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { points.push_back(Base::Vector3d(data(i, x), data(i, y), data(i, z))); } } if (hasData && hasNormal) { normals.reserve(numPoints); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { normals.emplace_back(data(i, normal_x), data(i, normal_y), data(i, normal_z)); } } if (hasData && hasIntensity) { intensity.reserve(numPoints); - for (std::size_t i = 0; i < numPoints; i++) { - intensity.push_back(data(i, greyvalue)); + for (Eigen::Index i = 0; i < numPoints; i++) { + intensity.push_back(static_cast(data(i, greyvalue))); } } @@ -688,26 +687,26 @@ void PlyReader::read(const std::string& filename) colors.reserve(numPoints); float a = 1.0; if (types[red] == "uchar") { - for (std::size_t i = 0; i < numPoints; i++) { - float r = data(i, red); - float g = data(i, green); - float b = data(i, blue); + for (Eigen::Index i = 0; i < numPoints; i++) { + float r = static_cast(data(i, red)); + float g = static_cast(data(i, green)); + float b = static_cast(data(i, blue)); if (alpha != max_size) { - a = data(i, alpha); + a = static_cast(data(i, alpha)); } - colors.emplace_back(static_cast(r) / 255.0f, - static_cast(g) / 255.0f, - static_cast(b) / 255.0f, - static_cast(a) / 255.0f); + colors.emplace_back(static_cast(r) / 255.0F, + static_cast(g) / 255.0F, + static_cast(b) / 255.0F, + static_cast(a) / 255.0F); } } else if (types[red] == "float") { - for (std::size_t i = 0; i < numPoints; i++) { - float r = data(i, red); - float g = data(i, green); - float b = data(i, blue); + for (Eigen::Index i = 0; i < numPoints; i++) { + float r = static_cast(data(i, red)); + float g = static_cast(data(i, green)); + float b = static_cast(data(i, blue)); if (alpha != max_size) { - a = data(i, alpha); + a = static_cast(data(i, alpha)); } colors.emplace_back(r, g, b, a); } @@ -722,7 +721,8 @@ std::size_t PlyReader::readHeader(std::istream& in, std::vector& types, std::vector& sizes) { - std::string line, element; + std::string line; + std::string element; std::vector list; std::size_t numPoints = 0; // a pair of numbers of elements and the total size of the properties @@ -887,9 +887,9 @@ std::size_t PlyReader::readHeader(std::istream& in, void PlyReader::readAscii(std::istream& inp, std::size_t offset, Eigen::MatrixXd& data) { std::string line; - std::size_t row = 0; - std::size_t numPoints = data.rows(); - std::size_t numFields = data.cols(); + Eigen::Index row = 0; + Eigen::Index numPoints = Eigen::Index(data.rows()); + Eigen::Index numFields = Eigen::Index(data.cols()); std::vector list; while (std::getline(inp, line) && row < numPoints) { if (line.empty()) { @@ -907,7 +907,8 @@ void PlyReader::readAscii(std::istream& inp, std::size_t offset, Eigen::MatrixXd std::istringstream str(line); - for (std::size_t col = 0; col < list.size() && col < numFields; col++) { + Eigen::Index size = Eigen::Index(list.size()); + for (Eigen::Index col = 0; col < size && col < numFields; col++) { double value = boost::lexical_cast(list[col]); data(row, col) = value; } @@ -923,8 +924,8 @@ void PlyReader::readBinary(bool swapByteOrder, const std::vector& sizes, Eigen::MatrixXd& data) { - std::size_t numPoints = data.rows(); - std::size_t numFields = data.cols(); + Eigen::Index numPoints = data.rows(); + Eigen::Index numFields = data.cols(); int neededSize = 0; ConverterPtr convert_float32(new ConverterT); @@ -937,8 +938,8 @@ void PlyReader::readBinary(bool swapByteOrder, ConverterPtr convert_uint32(new ConverterT); std::vector converters; - for (std::size_t j = 0; j < numFields; j++) { - std::string t = types[j]; + for (Eigen::Index j = 0; j < numFields; j++) { + const std::string& t = types[j]; switch (sizes[j]) { case 1: if (t == "char" || t == "int8") { @@ -1005,8 +1006,8 @@ void PlyReader::readBinary(bool swapByteOrder, Base::InputStream str(inp); str.setByteOrder(swapByteOrder ? Base::Stream::BigEndian : Base::Stream::LittleEndian); - for (std::size_t i = 0; i < numPoints; i++) { - for (std::size_t j = 0; j < numFields; j++) { + for (Eigen::Index i = 0; i < numPoints; i++) { + for (Eigen::Index j = 0; j < numFields; j++) { double value = converters[j]->toDouble(str); data(i, j) = value; } @@ -1030,7 +1031,7 @@ void PcdReader::read(const std::string& filename) std::vector fields; std::vector types; std::vector sizes; - std::size_t numPoints = readHeader(inp, format, fields, types, sizes); + Eigen::Index numPoints = Eigen::Index(readHeader(inp, format, fields, types, sizes)); Eigen::MatrixXd data(numPoints, fields.size()); if (format == "ascii") { @@ -1040,14 +1041,15 @@ void PcdReader::read(const std::string& filename) readBinary(false, inp, types, sizes, data); } else if (format == "binary_compressed") { - unsigned int c, u; + unsigned int c {}; + unsigned int u {}; Base::InputStream str(inp); str >> c >> u; std::vector compressed(c); - inp.read(&compressed[0], c); + inp.read(compressed.data(), c); std::vector uncompressed(u); - if (lzfDecompress(&compressed[0], c, &uncompressed[0], u) == u) { + if (lzfDecompress(compressed.data(), c, uncompressed.data(), u) == u) { DataStreambuf ibuf(uncompressed); std::istream istr(nullptr); istr.rdbuf(&ibuf); @@ -1059,31 +1061,31 @@ void PcdReader::read(const std::string& filename) } std::vector::iterator it; - std::size_t max_size = std::numeric_limits::max(); + Eigen::Index max_size = std::numeric_limits::max(); // x field - std::size_t x = max_size; + Eigen::Index x = max_size; it = std::find(fields.begin(), fields.end(), "x"); if (it != fields.end()) { x = std::distance(fields.begin(), it); } // y field - std::size_t y = max_size; + Eigen::Index y = max_size; it = std::find(fields.begin(), fields.end(), "y"); if (it != fields.end()) { y = std::distance(fields.begin(), it); } // z field - std::size_t z = max_size; + Eigen::Index z = max_size; it = std::find(fields.begin(), fields.end(), "z"); if (it != fields.end()) { z = std::distance(fields.begin(), it); } // normal x field - std::size_t normal_x = max_size; + Eigen::Index normal_x = max_size; it = std::find(fields.begin(), fields.end(), "normal_x"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "nx"); @@ -1093,7 +1095,7 @@ void PcdReader::read(const std::string& filename) } // normal y field - std::size_t normal_y = max_size; + Eigen::Index normal_y = max_size; it = std::find(fields.begin(), fields.end(), "normal_y"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "ny"); @@ -1103,7 +1105,7 @@ void PcdReader::read(const std::string& filename) } // normal z field - std::size_t normal_z = max_size; + Eigen::Index normal_z = max_size; it = std::find(fields.begin(), fields.end(), "normal_z"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "nz"); @@ -1113,14 +1115,14 @@ void PcdReader::read(const std::string& filename) } // intensity field - std::size_t greyvalue = max_size; + Eigen::Index greyvalue = max_size; it = std::find(fields.begin(), fields.end(), "intensity"); if (it != fields.end()) { greyvalue = std::distance(fields.begin(), it); } // rgb(a) field - std::size_t rgba = max_size; + Eigen::Index rgba = max_size; it = std::find(fields.begin(), fields.end(), "rgb"); if (it == fields.end()) { it = std::find(fields.begin(), fields.end(), "rgba"); @@ -1137,21 +1139,21 @@ void PcdReader::read(const std::string& filename) if (hasData) { points.reserve(numPoints); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { points.push_back(Base::Vector3d(data(i, x), data(i, y), data(i, z))); } } if (hasData && hasNormal) { normals.reserve(numPoints); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { normals.emplace_back(data(i, normal_x), data(i, normal_y), data(i, normal_z)); } } if (hasData && hasIntensity) { intensity.reserve(numPoints); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { intensity.push_back(data(i, greyvalue)); } } @@ -1159,7 +1161,7 @@ void PcdReader::read(const std::string& filename) if (hasData && hasColor) { colors.reserve(numPoints); if (types[rgba] == "U") { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { uint32_t packed = static_cast(data(i, rgba)); App::Color col; col.setPackedARGB(packed); @@ -1169,9 +1171,9 @@ void PcdReader::read(const std::string& filename) else if (types[rgba] == "F") { static_assert(sizeof(float) == sizeof(uint32_t), "float and uint32_t have different sizes"); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { float f = static_cast(data(i, rgba)); - uint32_t packed; + uint32_t packed {}; std::memcpy(&packed, &f, sizeof(packed)); App::Color col; col.setPackedARGB(packed); @@ -1255,9 +1257,9 @@ std::size_t PcdReader::readHeader(std::istream& in, void PcdReader::readAscii(std::istream& inp, Eigen::MatrixXd& data) { std::string line; - std::size_t row = 0; - std::size_t numPoints = data.rows(); - std::size_t numFields = data.cols(); + Eigen::Index row = 0; + Eigen::Index numPoints = data.rows(); + Eigen::Index numFields = data.cols(); std::vector list; while (std::getline(inp, line) && row < numPoints) { if (line.empty()) { @@ -1270,7 +1272,8 @@ void PcdReader::readAscii(std::istream& inp, Eigen::MatrixXd& data) std::istringstream str(line); - for (std::size_t col = 0; col < list.size() && col < numFields; col++) { + Eigen::Index size = Eigen::Index(list.size()); + for (Eigen::Index col = 0; col < size && col < numFields; col++) { double value = boost::lexical_cast(list[col]); data(row, col) = value; } @@ -1285,8 +1288,8 @@ void PcdReader::readBinary(bool transpose, const std::vector& sizes, Eigen::MatrixXd& data) { - std::size_t numPoints = data.rows(); - std::size_t numFields = data.cols(); + Eigen::Index numPoints = data.rows(); + Eigen::Index numFields = data.cols(); int neededSize = 0; ConverterPtr convert_float32(new ConverterT); @@ -1299,7 +1302,7 @@ void PcdReader::readBinary(bool transpose, ConverterPtr convert_uint32(new ConverterT); std::vector converters; - for (std::size_t j = 0; j < numFields; j++) { + for (Eigen::Index j = 0; j < numFields; j++) { char t = types[j][0]; switch (sizes[j]) { case 1: @@ -1367,16 +1370,16 @@ void PcdReader::readBinary(bool transpose, Base::InputStream str(inp); if (transpose) { - for (std::size_t j = 0; j < numFields; j++) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index j = 0; j < numFields; j++) { + for (Eigen::Index i = 0; i < numPoints; i++) { double value = converters[j]->toDouble(str); data(i, j) = value; } } } else { - for (std::size_t i = 0; i < numPoints; i++) { - for (std::size_t j = 0; j < numFields; j++) { + for (Eigen::Index i = 0; i < numPoints; i++) { + for (Eigen::Index j = 0; j < numFields; j++) { double value = converters[j]->toDouble(str); data(i, j) = value; } @@ -1580,7 +1583,7 @@ private: ); return true; } - else if (node.elementName() == "colorGreen") { + if (node.elementName() == "colorGreen") { proto.cnt_rgb++; proto.sdb .emplace_back(imfi, node.elementName(), proto.greenData.data(), buf_size, true, true @@ -1588,7 +1591,7 @@ private: ); return true; } - else if (node.elementName() == "colorBlue") { + if (node.elementName() == "colorBlue") { proto.cnt_rgb++; proto.sdb .emplace_back(imfi, node.elementName(), proto.blueData.data(), buf_size, true, true @@ -1702,9 +1705,9 @@ private: App::Color getColor(const Proto& proto, size_t index) const { App::Color c; - c.r = static_cast(proto.redData[index]) / 255.0f; - c.g = static_cast(proto.greenData[index]) / 255.0f; - c.b = static_cast(proto.blueData[index]) / 255.0f; + c.r = static_cast(proto.redData[index]) / 255.0F; + c.g = static_cast(proto.greenData[index]) / 255.0F; + c.b = static_cast(proto.blueData[index]) / 255.0F; return c; } @@ -1798,10 +1801,9 @@ void E57Reader::read(const std::string& filename) Writer::Writer(const PointKernel& p) : points(p) -{ - width = p.size(); - height = 1; -} + , width(int(p.size())) + , height {1} +{} Writer::~Writer() = default; @@ -1903,10 +1905,10 @@ void PlyWriter::write(const std::string& filename) converters.push_back(convert_float); } - std::size_t numPoints = points.size(); - std::size_t numValid = 0; + Eigen::Index numPoints = Eigen::Index(points.size()); + Eigen::Index numValid = 0; const std::vector& pts = points.getBasicPoints(); - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { const Base::Vector3f& p = pts[i]; if (!boost::math::isnan(p.x) && !boost::math::isnan(p.y) && !boost::math::isnan(p.z)) { numValid++; @@ -1916,7 +1918,7 @@ void PlyWriter::write(const std::string& filename) Eigen::MatrixXf data(numPoints, properties.size()); if (placement.isIdentity()) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { data(i, 0) = pts[i].x; data(i, 1) = pts[i].y; data(i, 2) = pts[i].z; @@ -1924,7 +1926,7 @@ void PlyWriter::write(const std::string& filename) } else { Base::Vector3d tmp; - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { tmp = Base::convertTo(pts[i]); placement.multVec(tmp, tmp); data(i, 0) = static_cast(tmp.x); @@ -1933,14 +1935,14 @@ void PlyWriter::write(const std::string& filename) } } - std::size_t col = 3; + Eigen::Index col = 3; if (hasNormals) { - int col0 = col; - int col1 = col + 1; - int col2 = col + 2; + Eigen::Index col0 = col; + Eigen::Index col1 = col + 1; + Eigen::Index col2 = col + 2; Base::Rotation rot = placement.getRotation(); if (rot.isIdentity()) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { data(i, col0) = normals[i].x; data(i, col1) = normals[i].y; data(i, col2) = normals[i].z; @@ -1948,7 +1950,7 @@ void PlyWriter::write(const std::string& filename) } else { Base::Vector3d tmp; - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { tmp = Base::convertTo(normals[i]); rot.multVec(tmp, tmp); data(i, col0) = static_cast(tmp.x); @@ -1960,22 +1962,22 @@ void PlyWriter::write(const std::string& filename) } if (hasColors) { - int col0 = col; - int col1 = col + 1; - int col2 = col + 2; - int col3 = col + 3; - for (std::size_t i = 0; i < numPoints; i++) { + Eigen::Index col0 = col; + Eigen::Index col1 = col + 1; + Eigen::Index col2 = col + 2; + Eigen::Index col3 = col + 3; + for (Eigen::Index i = 0; i < numPoints; i++) { App::Color c = colors[i]; - data(i, col0) = (c.r * 255.0f + 0.5f); - data(i, col1) = (c.g * 255.0f + 0.5f); - data(i, col2) = (c.b * 255.0f + 0.5f); - data(i, col3) = (c.a * 255.0f + 0.5f); + data(i, col0) = (c.r * 255.0F + 0.5F); + data(i, col1) = (c.g * 255.0F + 0.5F); + data(i, col2) = (c.b * 255.0F + 0.5F); + data(i, col3) = (c.a * 255.0F + 0.5F); } col += 4; } if (hasIntensity) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { data(i, col) = intensity[i]; } col += 1; @@ -1993,7 +1995,7 @@ void PlyWriter::write(const std::string& filename) } out << "end_header" << std::endl; - for (std::size_t r = 0; r < numPoints; r++) { + for (Eigen::Index r = 0; r < numPoints; r++) { if (boost::math::isnan(data(r, 0))) { continue; } @@ -2003,7 +2005,7 @@ void PlyWriter::write(const std::string& filename) if (boost::math::isnan(data(r, 2))) { continue; } - for (std::size_t c = 0; c < col; c++) { + for (Eigen::Index c = 0; c < col; c++) { float value = data(r, c); out << converters[c]->toString(value) << " "; } @@ -2065,13 +2067,13 @@ void PcdWriter::write(const std::string& filename) converters.push_back(convert_float); } - std::size_t numPoints = points.size(); + Eigen::Index numPoints = Eigen::Index(points.size()); const std::vector& pts = points.getBasicPoints(); Eigen::MatrixXd data(numPoints, fields.size()); if (placement.isIdentity()) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { data(i, 0) = pts[i].x; data(i, 1) = pts[i].y; data(i, 2) = pts[i].z; @@ -2079,7 +2081,7 @@ void PcdWriter::write(const std::string& filename) } else { Base::Vector3d tmp; - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { tmp = Base::convertTo(pts[i]); placement.multVec(tmp, tmp); data(i, 0) = static_cast(tmp.x); @@ -2088,14 +2090,14 @@ void PcdWriter::write(const std::string& filename) } } - std::size_t col = 3; + Eigen::Index col = 3; if (hasNormals) { - int col0 = col; - int col1 = col + 1; - int col2 = col + 2; + Eigen::Index col0 = col; + Eigen::Index col1 = col + 1; + Eigen::Index col2 = col + 2; Base::Rotation rot = placement.getRotation(); if (rot.isIdentity()) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { data(i, col0) = normals[i].x; data(i, col1) = normals[i].y; data(i, col2) = normals[i].z; @@ -2103,7 +2105,7 @@ void PcdWriter::write(const std::string& filename) } else { Base::Vector3d tmp; - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { tmp = Base::convertTo(normals[i]); rot.multVec(tmp, tmp); data(i, col0) = static_cast(tmp.x); @@ -2115,7 +2117,7 @@ void PcdWriter::write(const std::string& filename) } if (hasColors) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { // http://docs.pointclouds.org/1.3.0/structpcl_1_1_r_g_b.html data(i, col) = colors[i].getPackedARGB(); } @@ -2123,7 +2125,7 @@ void PcdWriter::write(const std::string& filename) } if (hasIntensity) { - for (std::size_t i = 0; i < numPoints; i++) { + for (Eigen::Index i = 0; i < numPoints; i++) { data(i, col) = intensity[i]; } col += 1; @@ -2167,15 +2169,18 @@ void PcdWriter::write(const std::string& filename) Base::Placement plm; Base::Vector3d p = plm.getPosition(); Base::Rotation o = plm.getRotation(); - double x, y, z, w; + double x {}; + double y {}; + double z {}; + double w {}; o.getValue(x, y, z, w); out << "VIEWPOINT " << p.x << " " << p.y << " " << p.z << " " << w << " " << x << " " << y << " " << z << std::endl; out << "POINTS " << numPoints << std::endl << "DATA ascii" << std::endl; - for (std::size_t r = 0; r < numPoints; r++) { - for (std::size_t c = 0; c < col; c++) { + for (Eigen::Index r = 0; r < numPoints; r++) { + for (Eigen::Index c = 0; c < col; c++) { double value = data(r, c); if (boost::math::isnan(value)) { out << "nan "; diff --git a/src/Mod/Points/App/PointsAlgos.h b/src/Mod/Points/App/PointsAlgos.h index 4743d225bf..8a178fd5f3 100644 --- a/src/Mod/Points/App/PointsAlgos.h +++ b/src/Mod/Points/App/PointsAlgos.h @@ -65,12 +65,20 @@ public: int getWidth() const; int getHeight() const; + Reader(const Reader&) = delete; + Reader(Reader&&) = delete; + Reader& operator=(const Reader&) = delete; + Reader& operator=(Reader&&) = delete; + protected: + // NOLINTBEGIN PointKernel points; std::vector intensity; std::vector colors; std::vector normals; - int width, height; + int width {}; + int height {}; + // NOLINTEND }; class AscReader: public Reader @@ -147,13 +155,20 @@ public: void setHeight(int); void setPlacement(const Base::Placement&); + Writer(const Writer&) = delete; + Writer(Writer&&) = delete; + Writer& operator=(const Writer&) = delete; + Writer& operator=(Writer&&) = delete; + protected: + // NOLINTBEGIN const PointKernel& points; std::vector intensity; std::vector colors; std::vector normals; int width, height; Base::Placement placement; + // NOLINTEND }; class AscWriter: public Writer diff --git a/src/Mod/Points/App/PointsFeature.h b/src/Mod/Points/App/PointsFeature.h index f271c3621f..39d0f598b5 100644 --- a/src/Mod/Points/App/PointsFeature.h +++ b/src/Mod/Points/App/PointsFeature.h @@ -25,7 +25,7 @@ #include #include -#include // must be first include +#include #include #include "Points.h" diff --git a/src/Mod/Points/App/PointsGrid.cpp b/src/Mod/Points/App/PointsGrid.cpp index 8a4bf793f4..162b7cbc21 100644 --- a/src/Mod/Points/App/PointsGrid.cpp +++ b/src/Mod/Points/App/PointsGrid.cpp @@ -33,14 +33,14 @@ PointsGrid::PointsGrid(const PointKernel& rclM) , _ulCtGridsX(0) , _ulCtGridsY(0) , _ulCtGridsZ(0) - , _fGridLenX(0.0f) - , _fGridLenY(0.0f) - , _fGridLenZ(0.0f) - , _fMinX(0.0f) - , _fMinY(0.0f) - , _fMinZ(0.0f) + , _fGridLenX(0.0F) + , _fGridLenY(0.0F) + , _fGridLenZ(0.0F) + , _fMinX(0.0F) + , _fMinY(0.0F) + , _fMinZ(0.0F) { - RebuildGrid(); + PointsGrid::RebuildGrid(); } PointsGrid::PointsGrid() @@ -49,12 +49,12 @@ PointsGrid::PointsGrid() , _ulCtGridsX(POINTS_CT_GRID) , _ulCtGridsY(POINTS_CT_GRID) , _ulCtGridsZ(POINTS_CT_GRID) - , _fGridLenX(0.0f) - , _fGridLenY(0.0f) - , _fGridLenZ(0.0f) - , _fMinX(0.0f) - , _fMinY(0.0f) - , _fMinZ(0.0f) + , _fGridLenX(0.0F) + , _fGridLenY(0.0F) + , _fGridLenZ(0.0F) + , _fMinX(0.0F) + , _fMinY(0.0F) + , _fMinZ(0.0F) {} PointsGrid::PointsGrid(const PointKernel& rclM, @@ -66,14 +66,14 @@ PointsGrid::PointsGrid(const PointKernel& rclM, , _ulCtGridsX(0) , _ulCtGridsY(0) , _ulCtGridsZ(0) - , _fGridLenX(0.0f) - , _fGridLenY(0.0f) - , _fGridLenZ(0.0f) - , _fMinX(0.0f) - , _fMinY(0.0f) - , _fMinZ(0.0f) + , _fGridLenX(0.0F) + , _fGridLenY(0.0F) + , _fGridLenZ(0.0F) + , _fMinX(0.0F) + , _fMinY(0.0F) + , _fMinZ(0.0F) { - Rebuild(ulX, ulY, ulZ); + PointsGrid::Rebuild(ulX, ulY, ulZ); } PointsGrid::PointsGrid(const PointKernel& rclM, int iCtGridPerAxis) @@ -82,14 +82,14 @@ PointsGrid::PointsGrid(const PointKernel& rclM, int iCtGridPerAxis) , _ulCtGridsX(0) , _ulCtGridsY(0) , _ulCtGridsZ(0) - , _fGridLenX(0.0f) - , _fGridLenY(0.0f) - , _fGridLenZ(0.0f) - , _fMinX(0.0f) - , _fMinY(0.0f) - , _fMinZ(0.0f) + , _fGridLenX(0.0F) + , _fGridLenY(0.0F) + , _fGridLenZ(0.0F) + , _fMinX(0.0F) + , _fMinY(0.0F) + , _fMinZ(0.0F) { - Rebuild(iCtGridPerAxis); + PointsGrid::Rebuild(iCtGridPerAxis); } PointsGrid::PointsGrid(const PointKernel& rclM, double fGridLen) @@ -98,20 +98,20 @@ PointsGrid::PointsGrid(const PointKernel& rclM, double fGridLen) , _ulCtGridsX(0) , _ulCtGridsY(0) , _ulCtGridsZ(0) - , _fGridLenX(0.0f) - , _fGridLenY(0.0f) - , _fGridLenZ(0.0f) - , _fMinX(0.0f) - , _fMinY(0.0f) - , _fMinZ(0.0f) + , _fGridLenX(0.0F) + , _fGridLenY(0.0F) + , _fGridLenZ(0.0F) + , _fMinX(0.0F) + , _fMinY(0.0F) + , _fMinZ(0.0F) { Base::BoundBox3d clBBPts; // = _pclPoints->GetBoundBox(); for (const auto& pnt : *_pclPoints) { clBBPts.Add(pnt); } - Rebuild(std::max((unsigned long)(clBBPts.LengthX() / fGridLen), 1), - std::max((unsigned long)(clBBPts.LengthY() / fGridLen), 1), - std::max((unsigned long)(clBBPts.LengthZ() / fGridLen), 1)); + PointsGrid::Rebuild(std::max((unsigned long)(clBBPts.LengthX() / fGridLen), 1), + std::max((unsigned long)(clBBPts.LengthY() / fGridLen), 1), + std::max((unsigned long)(clBBPts.LengthZ() / fGridLen), 1)); } void PointsGrid::Attach(const PointKernel& rclM) @@ -153,8 +153,6 @@ void PointsGrid::InitGrid() { assert(_pclPoints); - unsigned long i, j; - // Calculate grid lengths if not initialized // if ((_ulCtGridsX == 0) || (_ulCtGridsY == 0) || (_ulCtGridsZ == 0)) { @@ -180,8 +178,8 @@ void PointsGrid::InitGrid() if (num == 0) { num = 1; } - _fGridLenX = (1.0f + fLengthX) / double(num); - _fMinX = clBBPts.MinX - 0.5f; + _fGridLenX = (1.0F + fLengthX) / double(num); + _fMinX = clBBPts.MinX - 0.5F; } { @@ -189,8 +187,8 @@ void PointsGrid::InitGrid() if (num == 0) { num = 1; } - _fGridLenY = (1.0f + fLengthY) / double(num); - _fMinY = clBBPts.MinY - 0.5f; + _fGridLenY = (1.0F + fLengthY) / double(num); + _fMinY = clBBPts.MinY - 0.5F; } { @@ -198,17 +196,17 @@ void PointsGrid::InitGrid() if (num == 0) { num = 1; } - _fGridLenZ = (1.0f + fLengthZ) / double(num); - _fMinZ = clBBPts.MinZ - 0.5f; + _fGridLenZ = (1.0F + fLengthZ) / double(num); + _fMinZ = clBBPts.MinZ - 0.5F; } } // Create data structure _aulGrid.clear(); _aulGrid.resize(_ulCtGridsX); - for (i = 0; i < _ulCtGridsX; i++) { + for (unsigned long i = 0; i < _ulCtGridsX; i++) { _aulGrid[i].resize(_ulCtGridsY); - for (j = 0; j < _ulCtGridsY; j++) { + for (unsigned long j = 0; j < _ulCtGridsY; j++) { _aulGrid[i][j].resize(_ulCtGridsZ); } } @@ -218,7 +216,12 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, std::vector& raulElements, bool bDelDoubles) const { - unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; + unsigned long ulMinX {}; + unsigned long ulMinY {}; + unsigned long ulMinZ {}; + unsigned long ulMaxX {}; + unsigned long ulMaxY {}; + unsigned long ulMaxZ {}; raulElements.clear(); @@ -226,9 +229,9 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, Position(Base::Vector3d(rclBB.MinX, rclBB.MinY, rclBB.MinZ), ulMinX, ulMinY, ulMinZ); Position(Base::Vector3d(rclBB.MaxX, rclBB.MaxY, rclBB.MaxZ), ulMaxX, ulMaxY, ulMaxZ); - for (i = ulMinX; i <= ulMaxX; i++) { - for (j = ulMinY; j <= ulMaxY; j++) { - for (k = ulMinZ; k <= ulMaxZ; k++) { + for (auto i = ulMinX; i <= ulMaxX; i++) { + for (auto j = ulMinY; j <= ulMaxY; j++) { + for (auto k = ulMinZ; k <= ulMaxZ; k++) { raulElements.insert(raulElements.end(), _aulGrid[i][j][k].begin(), _aulGrid[i][j][k].end()); @@ -252,7 +255,8 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, double fMaxDist, bool bDelDoubles) const { - unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; + unsigned long ulMinX {}, ulMinY {}, ulMinZ {}; + unsigned long ulMaxX {}, ulMaxY {}, ulMaxZ {}; double fGridDiag = GetBoundBox(0, 0, 0).CalcDiagonalLength(); double fMinDistP2 = (fGridDiag * fGridDiag) + (fMaxDist * fMaxDist); @@ -262,9 +266,9 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, Position(Base::Vector3d(rclBB.MinX, rclBB.MinY, rclBB.MinZ), ulMinX, ulMinY, ulMinZ); Position(Base::Vector3d(rclBB.MaxX, rclBB.MaxY, rclBB.MaxZ), ulMaxX, ulMaxY, ulMaxZ); - for (i = ulMinX; i <= ulMaxX; i++) { - for (j = ulMinY; j <= ulMaxY; j++) { - for (k = ulMinZ; k <= ulMaxZ; k++) { + for (auto i = ulMinX; i <= ulMaxX; i++) { + for (auto j = ulMinY; j <= ulMaxY; j++) { + for (auto k = ulMinZ; k <= ulMaxZ; k++) { if (Base::DistanceP2(GetBoundBox(i, j, k).GetCenter(), rclOrg) < fMinDistP2) { raulElements.insert(raulElements.end(), _aulGrid[i][j][k].begin(), @@ -287,7 +291,8 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, std::set& raulElements) const { - unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; + unsigned long ulMinX {}, ulMinY {}, ulMinZ {}; + unsigned long ulMaxX {}, ulMaxY {}, ulMaxZ {}; raulElements.clear(); @@ -295,9 +300,9 @@ unsigned long PointsGrid::InSide(const Base::BoundBox3d& rclBB, Position(Base::Vector3d(rclBB.MinX, rclBB.MinY, rclBB.MinZ), ulMinX, ulMinY, ulMinZ); Position(Base::Vector3d(rclBB.MaxX, rclBB.MaxY, rclBB.MaxZ), ulMaxX, ulMaxY, ulMaxZ); - for (i = ulMinX; i <= ulMaxX; i++) { - for (j = ulMinY; j <= ulMaxY; j++) { - for (k = ulMinZ; k <= ulMaxZ; k++) { + for (auto i = ulMinX; i <= ulMaxX; i++) { + for (auto j = ulMinY; j <= ulMaxY; j++) { + for (auto k = ulMinZ; k <= ulMaxZ; k++) { raulElements.insert(_aulGrid[i][j][k].begin(), _aulGrid[i][j][k].end()); } } @@ -345,7 +350,7 @@ void PointsGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMax for (const auto& pnt : *_pclPoints) { clBBPtsEnlarged.Add(pnt); } - double fVolElem; + double fVolElem {}; if (_ulCtElements > (ulMaxGrids * ulCtGrid)) { fVolElem = @@ -359,7 +364,7 @@ void PointsGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMax } double fVol = fVolElem * float(ulCtGrid); - double fGridLen = float(pow((float)fVol, 1.0f / 3.0f)); + double fGridLen = float(pow((float)fVol, 1.0F / 3.0F)); if (fGridLen > 0) { _ulCtGridsX = @@ -398,7 +403,7 @@ void PointsGrid::CalculateGridLength(int iCtGridPerAxis) double fLenghtD = clBBPts.CalcDiagonalLength(); - double fLengthTol = 0.05f * fLenghtD; + double fLengthTol = 0.05F * fLenghtD; bool bLenghtXisZero = (fLenghtX <= fLengthTol); bool bLenghtYisZero = (fLenghtY <= fLengthTol); @@ -444,7 +449,7 @@ void PointsGrid::CalculateGridLength(int iCtGridPerAxis) fVolumenGrid = fVolumen / (float)iMaxGrids; } - double fLengthGrid = float(pow((float)fVolumenGrid, 1.0f / 3.0f)); + double fLengthGrid = float(pow((float)fVolumenGrid, 1.0F / 3.0F)); _ulCtGridsX = std::max((unsigned long)(fLenghtX / fLengthGrid), 1); _ulCtGridsY = std::max((unsigned long)(fLenghtY / fLengthGrid), 1); @@ -529,7 +534,9 @@ void PointsGrid::SearchNearestFromPoint(const Base::Vector3d& rclPt, Base::BoundBox3d clBB = GetBoundBox(); if (clBB.IsInBox(rclPt)) { // Point lies within - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}; + unsigned long ulY {}; + unsigned long ulZ {}; Position(rclPt, ulX, ulY, ulZ); unsigned long ulLevel = 0; while (raclInd.empty()) { @@ -632,41 +639,39 @@ void PointsGrid::GetHull(unsigned long ulX, int nY2 = std::min(int(_ulCtGridsY) - 1, int(ulY) + int(ulDistance)); int nZ2 = std::min(int(_ulCtGridsZ) - 1, int(ulZ) + int(ulDistance)); - int i, j; - // top plane - for (i = nX1; i <= nX2; i++) { - for (j = nY1; j <= nY2; j++) { + for (int i = nX1; i <= nX2; i++) { + for (int j = nY1; j <= nY2; j++) { GetElements(i, j, nZ1, raclInd); } } // bottom plane - for (i = nX1; i <= nX2; i++) { - for (j = nY1; j <= nY2; j++) { + for (int i = nX1; i <= nX2; i++) { + for (int j = nY1; j <= nY2; j++) { GetElements(i, j, nZ2, raclInd); } } // left plane - for (i = nY1; i <= nY2; i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = nY1; i <= nY2; i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(nX1, i, j, raclInd); } } // right plane - for (i = nY1; i <= nY2; i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = nY1; i <= nY2; i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(nX2, i, j, raclInd); } } // front plane - for (i = (nX1 + 1); i <= (nX2 - 1); i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = (nX1 + 1); i <= (nX2 - 1); i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(i, nY1, j, raclInd); } } // back plane - for (i = (nX1 + 1); i <= (nX2 - 1); i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = (nX1 + 1); i <= (nX2 - 1); i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(i, nY2, j, raclInd); } } @@ -688,7 +693,7 @@ unsigned long PointsGrid::GetElements(unsigned long ulX, void PointsGrid::AddPoint(const Base::Vector3d& rclPt, unsigned long ulPtIndex, float /*fEpsilon*/) { - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; Pos(Base::Vector3d(rclPt.x, rclPt.y, rclPt.z), ulX, ulY, ulZ); if ((ulX < _ulCtGridsX) && (ulY < _ulCtGridsY) && (ulZ < _ulCtGridsZ)) { _aulGrid[ulX][ulY][ulZ].insert(ulPtIndex); @@ -767,7 +772,7 @@ void PointsGrid::Pos(const Base::Vector3d& rclPoint, unsigned long PointsGrid::FindElements(const Base::Vector3d& rclPoint, std::set& aulElements) const { - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; Pos(rclPoint, ulX, ulY, ulZ); // check if the given point is inside the grid structure @@ -782,8 +787,8 @@ unsigned long PointsGrid::FindElements(const Base::Vector3d& rclPoint, PointsGridIterator::PointsGridIterator(const PointsGrid& rclG) : _rclGrid(rclG) - , _clPt(0.0f, 0.0f, 0.0f) - , _clDir(0.0f, 0.0f, 0.0f) + , _clPt(0.0F, 0.0F, 0.0F) + , _clDir(0.0F, 0.0F, 0.0F) {} bool PointsGridIterator::InitOnRay(const Base::Vector3d& rclPt, diff --git a/src/Mod/Points/App/PointsGrid.h b/src/Mod/Points/App/PointsGrid.h index 78a6abe4b1..2070e59807 100644 --- a/src/Mod/Points/App/PointsGrid.h +++ b/src/Mod/Points/App/PointsGrid.h @@ -63,8 +63,12 @@ public: PointsGrid(const PointKernel& rclM, double fGridLen); /// Construction PointsGrid(const PointKernel& rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ); + PointsGrid(const PointsGrid&) = default; + PointsGrid(PointsGrid&&) = default; /// Destruction virtual ~PointsGrid() = default; + PointsGrid& operator=(const PointsGrid&) = default; + PointsGrid& operator=(PointsGrid&&) = default; //@} public: @@ -174,7 +178,7 @@ protected: unsigned long ulDistance, std::set& raclInd) const; -protected: +private: std::vector>>> _aulGrid; /**< Grid data structure. */ const PointKernel* _pclPoints; /**< The point kernel. */ @@ -280,7 +284,7 @@ public: rulZ = _ulZ; } -protected: +private: const PointsGrid& _rclGrid; /**< The point grid. */ unsigned long _ulX {0}; /**< Number of grids in x. */ unsigned long _ulY {0}; /**< Number of grids in y. */ @@ -293,11 +297,10 @@ protected: struct GridElement { GridElement(unsigned long x, unsigned long y, unsigned long z) - { - this->x = x; - this->y = y; - this->z = z; - } + : x {x} + , y {y} + , z {z} + {} bool operator<(const GridElement& pos) const { if (x == pos.x) { @@ -324,7 +327,7 @@ protected: inline Base::BoundBox3d PointsGrid::GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const { - double fX, fY, fZ; + double fX {}, fY {}, fZ {}; fX = _fMinX + (double(ulX) * _fGridLenX); fY = _fMinY + (double(ulY) * _fGridLenY); diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index 16fb08bd0a..e9e0643791 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -32,10 +32,8 @@ #include "Points.h" // inclusion of the generated files (generated out of PointsPy.xml) -// clang-format off #include "PointsPy.h" #include "PointsPy.cpp" -// clang-format on using namespace Points; @@ -102,7 +100,7 @@ PyObject* PointsPy::copy(PyObject* args) PyObject* PointsPy::read(PyObject* args) { - const char* Name; + const char* Name {}; if (!PyArg_ParseTuple(args, "s", &Name)) { return nullptr; } @@ -118,7 +116,7 @@ PyObject* PointsPy::read(PyObject* args) PyObject* PointsPy::write(PyObject* args) { - const char* Name; + const char* Name {}; if (!PyArg_ParseTuple(args, "s", &Name)) { return nullptr; } @@ -156,7 +154,7 @@ PyObject* PointsPy::writeInventor(PyObject* args) PyObject* PointsPy::addPoints(PyObject* args) { - PyObject* obj; + PyObject* obj {}; if (!PyArg_ParseTuple(args, "O", &obj)) { return nullptr; } @@ -193,7 +191,7 @@ PyObject* PointsPy::addPoints(PyObject* args) PyObject* PointsPy::fromSegment(PyObject* args) { - PyObject* obj; + PyObject* obj {}; if (!PyArg_ParseTuple(args, "O", &obj)) { return nullptr; } diff --git a/src/Mod/Points/App/Properties.h b/src/Mod/Points/App/Properties.h index 9442e68f6e..fc059d111b 100644 --- a/src/Mod/Points/App/Properties.h +++ b/src/Mod/Points/App/Properties.h @@ -156,7 +156,7 @@ private: /** Curvature information. */ struct PointsExport CurvatureInfo { - float fMaxCurvature, fMinCurvature; + float fMaxCurvature {}, fMinCurvature {}; Base::Vector3f cMaxCurvDir, cMinCurvDir; }; diff --git a/src/Mod/Points/Gui/DlgPointsReadImp.cpp b/src/Mod/Points/Gui/DlgPointsReadImp.cpp index 1d42bc04b7..ff9f0384d5 100644 --- a/src/Mod/Points/Gui/DlgPointsReadImp.cpp +++ b/src/Mod/Points/Gui/DlgPointsReadImp.cpp @@ -31,9 +31,9 @@ using namespace PointsGui; DlgPointsReadImp::DlgPointsReadImp(const char* FileName, QWidget* parent, Qt::WindowFlags fl) : QDialog(parent, fl) , ui(new Ui_DlgPointsRead) + , _FileName(FileName) { ui->setupUi(this); - _FileName = FileName; } /* diff --git a/src/Mod/Points/Gui/DlgPointsReadImp.h b/src/Mod/Points/Gui/DlgPointsReadImp.h index 157fad19f9..abe5103fcb 100644 --- a/src/Mod/Points/Gui/DlgPointsReadImp.h +++ b/src/Mod/Points/Gui/DlgPointsReadImp.h @@ -46,6 +46,8 @@ public: private: std::unique_ptr ui; std::string _FileName; + + Q_DISABLE_COPY_MOVE(DlgPointsReadImp) }; } // namespace PointsGui diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index b90e8fe7f0..36423a85ed 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -62,7 +62,7 @@ ViewProviderPoints::ViewProviderPoints() { static const char* osgroup = "Object Style"; - ADD_PROPERTY_TYPE(PointSize, (2.0f), osgroup, App::Prop_None, "Set point size"); + ADD_PROPERTY_TYPE(PointSize, (2.0F), osgroup, App::Prop_None, "Set point size"); PointSize.setConstraints(&floatRange); // Create the selection node