Tests: add more unit tests for Points module

This commit is contained in:
wmayer
2024-03-12 15:39:42 +01:00
committed by wwmayer
parent ed573fcf86
commit 84202c4b1e
3 changed files with 250 additions and 16 deletions

View File

@@ -197,6 +197,8 @@ AscReader::AscReader() = default;
void AscReader::read(const std::string& filename)
{
points.load(filename.c_str());
this->height = 1;
this->width = points.size();
}
// ----------------------------------------------------------------------------
@@ -546,8 +548,6 @@ PlyReader::PlyReader() = default;
void PlyReader::read(const std::string& filename)
{
clear();
this->width = 1;
this->height = 0;
Base::FileInfo fi(filename);
Base::ifstream inp(fi, std::ios::in | std::ios::binary);
@@ -559,6 +559,9 @@ void PlyReader::read(const std::string& filename)
std::size_t offset = 0;
Eigen::Index numPoints = Eigen::Index(readHeader(inp, format, offset, fields, types, sizes));
this->width = numPoints;
this->height = 1;
Eigen::MatrixXd data(numPoints, fields.size());
if (format == "ascii") {
readAscii(inp, offset, data);
@@ -1021,8 +1024,8 @@ PcdReader::PcdReader() = default;
void PcdReader::read(const std::string& filename)
{
clear();
this->width = -1;
this->height = -1;
this->width = 0;
this->height = 1;
Base::FileInfo fi(filename);
Base::ifstream inp(fi, std::ios::in | std::ios::binary);
@@ -1788,6 +1791,8 @@ void E57Reader::read(const std::string& filename)
normals = reader.getNormals();
colors = reader.getColors();
intensity = reader.getItensity();
width = points.size();
height = 1;
}
catch (const Base::BadFormatError&) {
throw;

View File

@@ -45,7 +45,7 @@ public:
static void LoadAscii(PointKernel&, const char* FileName);
};
class Reader
class PointsExport Reader
{
public:
Reader();
@@ -76,19 +76,19 @@ protected:
std::vector<float> intensity;
std::vector<App::Color> colors;
std::vector<Base::Vector3f> normals;
int width {};
int height {};
int width {0};
int height {1};
// NOLINTEND
};
class AscReader: public Reader
class PointsExport AscReader: public Reader
{
public:
AscReader();
void read(const std::string& filename) override;
};
class PlyReader: public Reader
class PointsExport PlyReader: public Reader
{
public:
PlyReader();
@@ -110,7 +110,7 @@ private:
Eigen::MatrixXd& data);
};
class PcdReader: public Reader
class PointsExport PcdReader: public Reader
{
public:
PcdReader();
@@ -130,7 +130,7 @@ private:
Eigen::MatrixXd& data);
};
class E57Reader: public Reader
class PointsExport E57Reader: public Reader
{
public:
E57Reader(bool Color, bool State, double Distance);
@@ -141,7 +141,7 @@ protected:
double minDistance;
};
class Writer
class PointsExport Writer
{
public:
explicit Writer(const PointKernel&);
@@ -171,21 +171,21 @@ protected:
// NOLINTEND
};
class AscWriter: public Writer
class PointsExport AscWriter: public Writer
{
public:
explicit AscWriter(const PointKernel&);
void write(const std::string& filename) override;
};
class PlyWriter: public Writer
class PointsExport PlyWriter: public Writer
{
public:
explicit PlyWriter(const PointKernel&);
void write(const std::string& filename) override;
};
class PcdWriter: public Writer
class PointsExport PcdWriter: public Writer
{
public:
explicit PcdWriter(const PointKernel&);