Helios++
Helios software for LiDAR simulations
XYZPointCloudFileLoader.h
1 #pragma once
2 
3 #include "AbstractGeometryFilter.h"
4 #include "Voxel.h"
5 #include <string>
6 #include <fstream>
7 #include <armadillo>
8 
9 using std::string;
10 using std::ifstream;
11 using arma::Mat;
12 
18  Voxel *voxel = nullptr;
19  Mat<double> *matrix = nullptr;
20  size_t cursor = 0;
21  double closestPointDistance = std::numeric_limits<double>::max();
22 };
23 
28 public:
29  // *** CONSTANTS *** //
30  // ******************* //
35  static int const minPointsForSafeNormalEstimation = 3;
39  static size_t const batchSize = 10000000;
44  static int const voxelPopulationThreshold = 40000;
45 private:
46  // *** ATTRIBUTES *** //
47  // ******************** //
51  std::string separator = " ";
55  double voxelSize = 1;
59  double maxColorValue = 0;
60 
64  bool snapNeighborNormal = false;
69  bool assignDefaultNormal = false;
73  glm::dvec3 defaultNormal = glm::dvec3(0,0,0);
78  size_t unsafeNormalEstimations = 0;
84  size_t discardedPointsByNormal = 0;
85 
89  size_t n;
93  double minX;
97  double minY;
101  double minZ;
105  double maxX;
109  double maxY;
113  double maxZ;
114 
118  size_t nx;
122  size_t ny;
126  size_t nz;
131  size_t nynz;
132 
141  double xCoeff;
150  double yCoeff;
159  double zCoeff;
160 
164  VoxelGridCell *voxels = nullptr;
169  size_t maxNVoxels;
173  size_t numBatches;
174 
180 
181  // *** MAIN PARSING METHODS *** //
182  // ****************************** //
187  void parse(std::string const & filePath);
188 
195  void firstPass(string const & filePathString, ifstream &ifs);
203  void secondPass(
204  string const &filePathString,
205  string const &matName,
206  ifstream &ifs
207  );
208  void loadMaterial();
209 
210  // *** AUXILIAR PARSING METHODS *** //
211  // ********************************** //
218  void prepareVoxelsGrid(
219  int &estimateNormals,
220  double &halfVoxelSize
221  );
230  void fillVoxelsGrid(
231  ifstream &ifs,
232  int estimateNormals,
233  double halfVoxelSize,
234  string const &filePathString
235  );
244  bool correctNormal(
245  double &x,
246  double &y,
247  double &z
248  );
254  void digestVoxel(
255  int estimateNormals,
256  double halfVoxelSize,
257  double x,
258  double y,
259  double z,
260  double r,
261  double g,
262  double b,
263  double xnorm,
264  double ynorm,
265  double znorm
266  );
267 
273  void postProcess(string const &matName, int estimateNormals);
278  void estimateNormals(ifstream &ifs);
287  void estimateNormalsBatch(ifstream &ifs);
295  void _estimateNormals(size_t start, size_t end);
299  void voxelsGridToScenePart();
300 
308  size_t indexFromCoordinates(
309  double x, double y, double z,
310  size_t &I, size_t &J, size_t &K
311  );
312 
313  // *** STATIC METHODS *** //
314  // ************************ //
320  static bool isLineComment(string const & line);
325  static void restartInputFileStream(ifstream &ifs);
326 
327 public:
328  // *** CONSTRUCTION / DESTRUCTION *** //
329  // ************************************ //
336  {}
337 
341  ScenePart* run();
342 
343 };
size_t n
The number of points in the point cloud.
Definition: XYZPointCloudFileLoader.h:89
size_t maxNVoxels
Total size of full voxels grid.
Definition: XYZPointCloudFileLoader.h:169
size_t nx
Number of partitions along x-axis.
Definition: XYZPointCloudFileLoader.h:118
double minZ
Minimum Z coordinate considering all points.
Definition: XYZPointCloudFileLoader.h:101
double minX
Minimum X coordinate considering all points.
Definition: XYZPointCloudFileLoader.h:93
double zCoeff
Coefficient ( ) to compute voxel index for a given coordinate.
Definition: XYZPointCloudFileLoader.h:159
size_t nz
Number of partitions along z-axis.
Definition: XYZPointCloudFileLoader.h:126
VoxelGridCell is used to build and fill all necessary voxels to represent input point cloud...
Definition: XYZPointCloudFileLoader.h:17
double minY
Minimum Y coordinate considering all points.
Definition: XYZPointCloudFileLoader.h:97
double maxX
Maximum X coordinate considering all points.
Definition: XYZPointCloudFileLoader.h:105
size_t numBatches
How many batches are necessary to estimate normals.
Definition: XYZPointCloudFileLoader.h:173
Class representing a voxel primitive.
Definition: Voxel.h:11
double xCoeff
Coefficient ( ) to compute voxel index for a given coordinate.
Definition: XYZPointCloudFileLoader.h:141
Import point cloud files abstracting them to a set of voxels.
Definition: XYZPointCloudFileLoader.h:27
size_t lastNumVoxels
Used to correctly report number of voxels for each part when reading multiple files at once (i...
Definition: XYZPointCloudFileLoader.h:179
double maxZ
Maximum Z coordinate considering all points.
Definition: XYZPointCloudFileLoader.h:113
double maxY
Maximum Y coordinate considering all points.
Definition: XYZPointCloudFileLoader.h:109
double yCoeff
Coefficient ( ) to compute voxel index for a given coordinate.
Definition: XYZPointCloudFileLoader.h:150
Class representing a scene part.
Definition: ScenePart.h:16
size_t nynz
Product . Stored in a variable because of its recurrent usage.
Definition: XYZPointCloudFileLoader.h:131
Abstract class defining asset loading filters common behavior.
Definition: AbstractGeometryFilter.h:18
XYZPointCloudFileLoader()
Constructor for point cloud loader.
Definition: XYZPointCloudFileLoader.h:334
size_t ny
Number of partitions along y-axis.
Definition: XYZPointCloudFileLoader.h:122