Points: fix many linter warnings

This commit is contained in:
wmayer
2024-03-12 14:09:17 +01:00
committed by wwmayer
parent be5dce2e9e
commit 0b8990c96c
14 changed files with 298 additions and 242 deletions

View File

@@ -38,7 +38,7 @@ public:
Sphere3& operator= (const Sphere3& rkSphere);
Vector3<Real> Center;
Real Radius;
Real Radius{};
};
}

View File

@@ -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();

View File

@@ -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<const char*> PointKernel::getElementTypes() const
{
std::vector<const char*> 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);

View File

@@ -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<kernel_type>::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--();

View File

@@ -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<char>& 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<char>& _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<unsigned int>(op - static_cast<unsigned char*>(out_data)));
}
} // namespace Points
// NOLINTEND
PlyReader::PlyReader() = default;
@@ -561,7 +557,7 @@ void PlyReader::read(const std::string& filename)
std::vector<std::string> types;
std::vector<int> 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<std::string>::iterator it;
std::size_t max_size = std::numeric_limits<std::size_t>::max();
Eigen::Index max_size = std::numeric_limits<Eigen::Index>::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<float>(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<float>(data(i, red));
float g = static_cast<float>(data(i, green));
float b = static_cast<float>(data(i, blue));
if (alpha != max_size) {
a = data(i, alpha);
a = static_cast<float>(data(i, alpha));
}
colors.emplace_back(static_cast<float>(r) / 255.0f,
static_cast<float>(g) / 255.0f,
static_cast<float>(b) / 255.0f,
static_cast<float>(a) / 255.0f);
colors.emplace_back(static_cast<float>(r) / 255.0F,
static_cast<float>(g) / 255.0F,
static_cast<float>(b) / 255.0F,
static_cast<float>(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<float>(data(i, red));
float g = static_cast<float>(data(i, green));
float b = static_cast<float>(data(i, blue));
if (alpha != max_size) {
a = data(i, alpha);
a = static_cast<float>(data(i, alpha));
}
colors.emplace_back(r, g, b, a);
}
@@ -722,7 +721,8 @@ std::size_t PlyReader::readHeader(std::istream& in,
std::vector<std::string>& types,
std::vector<int>& sizes)
{
std::string line, element;
std::string line;
std::string element;
std::vector<std::string> 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<std::string> 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<double>(list[col]);
data(row, col) = value;
}
@@ -923,8 +924,8 @@ void PlyReader::readBinary(bool swapByteOrder,
const std::vector<int>& 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<float>);
@@ -937,8 +938,8 @@ void PlyReader::readBinary(bool swapByteOrder,
ConverterPtr convert_uint32(new ConverterT<uint32_t>);
std::vector<ConverterPtr> 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<std::string> fields;
std::vector<std::string> types;
std::vector<int> 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<char> compressed(c);
inp.read(&compressed[0], c);
inp.read(compressed.data(), c);
std::vector<char> 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<std::string>::iterator it;
std::size_t max_size = std::numeric_limits<std::size_t>::max();
Eigen::Index max_size = std::numeric_limits<Eigen::Index>::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<uint32_t>(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<float>(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<std::string> 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<double>(list[col]);
data(row, col) = value;
}
@@ -1285,8 +1288,8 @@ void PcdReader::readBinary(bool transpose,
const std::vector<int>& 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<float>);
@@ -1299,7 +1302,7 @@ void PcdReader::readBinary(bool transpose,
ConverterPtr convert_uint32(new ConverterT<uint32_t>);
std::vector<ConverterPtr> 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<float>(proto.redData[index]) / 255.0f;
c.g = static_cast<float>(proto.greenData[index]) / 255.0f;
c.b = static_cast<float>(proto.blueData[index]) / 255.0f;
c.r = static_cast<float>(proto.redData[index]) / 255.0F;
c.g = static_cast<float>(proto.greenData[index]) / 255.0F;
c.b = static_cast<float>(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<Base::Vector3f>& 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<Base::Vector3d>(pts[i]);
placement.multVec(tmp, tmp);
data(i, 0) = static_cast<float>(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<Base::Vector3d>(normals[i]);
rot.multVec(tmp, tmp);
data(i, col0) = static_cast<float>(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<Base::Vector3f>& 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<Base::Vector3d>(pts[i]);
placement.multVec(tmp, tmp);
data(i, 0) = static_cast<float>(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<Base::Vector3d>(normals[i]);
rot.multVec(tmp, tmp);
data(i, col0) = static_cast<float>(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 ";

View File

@@ -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<float> intensity;
std::vector<App::Color> colors;
std::vector<Base::Vector3f> 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<float> intensity;
std::vector<App::Color> colors;
std::vector<Base::Vector3f> normals;
int width, height;
Base::Placement placement;
// NOLINTEND
};
class AscWriter: public Writer

View File

@@ -25,7 +25,7 @@
#include <App/FeatureCustom.h>
#include <App/FeaturePython.h>
#include <App/GeoFeature.h> // must be first include
#include <App/GeoFeature.h>
#include <App/PropertyGeo.h>
#include "Points.h"

View File

@@ -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>((unsigned long)(clBBPts.LengthX() / fGridLen), 1),
std::max<unsigned long>((unsigned long)(clBBPts.LengthY() / fGridLen), 1),
std::max<unsigned long>((unsigned long)(clBBPts.LengthZ() / fGridLen), 1));
PointsGrid::Rebuild(std::max<unsigned long>((unsigned long)(clBBPts.LengthX() / fGridLen), 1),
std::max<unsigned long>((unsigned long)(clBBPts.LengthY() / fGridLen), 1),
std::max<unsigned long>((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<unsigned long>& 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<unsigned long>& 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>((unsigned long)(fLenghtX / fLengthGrid), 1);
_ulCtGridsY = std::max<unsigned long>((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>(int(_ulCtGridsY) - 1, int(ulY) + int(ulDistance));
int nZ2 = std::min<int>(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<unsigned long>& 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,

View File

@@ -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<unsigned long>& raclInd) const;
protected:
private:
std::vector<std::vector<std::vector<std::set<unsigned long>>>>
_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);

View File

@@ -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;
}

View File

@@ -156,7 +156,7 @@ private:
/** Curvature information. */
struct PointsExport CurvatureInfo
{
float fMaxCurvature, fMinCurvature;
float fMaxCurvature {}, fMinCurvature {};
Base::Vector3f cMaxCurvDir, cMinCurvDir;
};

View File

@@ -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;
}
/*

View File

@@ -46,6 +46,8 @@ public:
private:
std::unique_ptr<Ui_DlgPointsRead> ui;
std::string _FileName;
Q_DISABLE_COPY_MOVE(DlgPointsReadImp)
};
} // namespace PointsGui

View File

@@ -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