ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
distanceMapGenerationTool.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Qt
11 #include <QImage>
12 #include <QSharedPointer>
13 
14 // cloudViewer
15 #include <CVGeom.h>
16 
17 // CV_DB_LIB
18 #include <ecvColorScale.h>
19 #include <ecvGLMatrix.h>
20 
21 // system
22 #include <vector>
23 
24 class ccPointCloud;
25 class ccMesh;
26 class ccPolyline;
27 class ccScalarField;
29 
30 // Default radial distance scalar field name
31 const char RADIAL_DIST_SF_NAME[] = "Radial distance";
32 // Default radii scalar field name
33 const char RADII_SF_NAME[] = "Radius";
34 
37 public:
38  struct ProfileMetaData {
40  : revolDim(2),
41  origin(0, 0, 0),
42  heightShift(0),
43  hasAxis(false),
44  axis(0, 0, 1) {}
45 
48 
49  int revolDim;
54  bool hasAxis;
57  };
58 
61 
63  static bool GetPoylineMetaData(const ccPolyline* polyline,
64  ProfileMetaData& data);
65 
67 
69  static void SetPoylineOrigin(ccPolyline* polyline, const CCVector3& origin);
70 
72 
75  static bool GetPoylineOrigin(const ccPolyline* polyline, CCVector3& origin);
76 
78 
80  static void SetPoylineRevolDim(ccPolyline* polyline, int revolDim);
81 
84 
88  static int GetPoylineRevolDim(const ccPolyline* polyline);
89 
91 
93  static void SetPoylineAxis(ccPolyline* polyline, const CCVector3& axis);
94 
96 
99  static bool GetPoylineAxis(const ccPolyline* polyline, CCVector3& axis);
100 
102 
104  static void SetPolylineHeightShift(ccPolyline* polyline,
105  PointCoordinateType heightShift);
106 
108 
111  static bool GetPolylineHeightShift(const ccPolyline* polyline,
112  PointCoordinateType& heightShift);
113 
115  static bool ComputeRadialDist(ccPointCloud* cloud,
117  bool storeRadiiAsSF = false,
118  ecvMainAppInterface* app = 0);
119 
121  struct MapCell {
123  MapCell() : value(0), count(0) {}
124 
126  double value;
128  unsigned count;
129  };
130 
132  class Map : public std::vector<MapCell> {
133  public:
134  Map()
135  : xSteps(0),
136  xMin(0.0),
137  xMax(0.0),
138  xStep(1.0),
139  ySteps(0),
140  yMin(0.0),
141  yMax(0.0),
142  yStep(1.0),
143  conical(false),
144  minVal(0.0),
145  maxVal(0.0),
146  counterclockwise(false),
147  conicalSpanRatio(0) {}
148 
149  unsigned xSteps;
150  double xMin;
151  double xMax;
152  double xStep;
153 
154  unsigned ySteps;
155  double yMin;
156  double yMax;
157  double yStep;
158 
159  // conical (true) or cylindrical (false) projection
160  bool conical;
161 
162  // min and max values
163  double minVal;
164  double maxVal;
165 
167 
170 
172 
174  };
175 
182  };
183 
189  };
190 
193 
198  static QSharedPointer<Map> CreateMap(
199  ccPointCloud* cloud,
200  ccScalarField* sf,
201  const ccGLMatrix& cloudToSurface, // e.g. translation to the
202  // revolution origin
203  unsigned char revolutionAxisDim,
204  double angStep_rad,
205  double yStep,
206  double yMin,
207  double yMax,
208  bool conical,
209  bool counterclockwise,
210  FillStrategyType fillStrategy,
211  EmptyCellFillOption emptyCellfillOption,
212  ecvMainAppInterface* app = 0);
213 
215  static ccMesh* ConvertConicalMapToMesh(const QSharedPointer<Map>& map,
216  bool counterclockwise,
217  QImage mapTexture = QImage());
218 
221  static double ConicalProjectN(double phi1, double phi2);
222 
225  static double ConicalProject(double phi, double phi1, double n);
226 
228  static bool ConvertCloudToCylindrical(
229  ccPointCloud* cloud,
230  const ccGLMatrix& cloudToSurface, // e.g. translation to the
231  // revolution origin
232  unsigned char revolutionAxisDim,
233  bool counterclockwise = false);
234 
236 
238  static bool ConvertCloudToConical(
239  ccPointCloud* cloud,
240  const ccGLMatrix& cloudToSurface, // e.g. translation to the
241  // revolution origin
242  unsigned char revolutionAxisDim,
243  double latMin_rad,
244  double latMax_rad,
245  double conicalSpanRatio = 1.0,
246  bool counterclockwise = false);
247 
249 
251  static CCVector3 ProjectPointOnCone(double lon_rad,
252  double lat_rad,
253  double latMin_rad,
254  double nProj,
255  bool counterclockwise);
256 
259  static bool ComputeMinAndMaxLatitude_rad(
260  ccPointCloud* cloud,
261  double& minLat_rad,
262  double& maxLat_rad,
263  const ccGLMatrix& cloudToSurfaceOrigin, // e.g. translation to the
264  // revolution origin
265  unsigned char revolutionAxisDim);
266 
268  static bool SaveMapAsCSVMatrix(const QSharedPointer<Map>& map,
269  QString filename,
270  QString xUnit,
271  QString yUnit,
272  double xConversionFactor = 1.0,
273  double yConversionFactor = 1.0,
274  ecvMainAppInterface* app = 0);
275 
277  static QImage ConvertMapToImage(
278  const QSharedPointer<Map>& map,
279  ccColorScale::Shared colorScale,
280  unsigned colorScaleSteps = ccColorScale::MAX_STEPS);
281 
283  static ccPointCloud* ConvertMapToCloud(const QSharedPointer<Map>& map,
285  double baseRadius = 1.0,
286  bool keepNaNPoints = true);
287 
291  const ccGLMatrix&
292  cloudToProfile, // e.g. translation to the profile origin
293  bool counterclockwise,
294  unsigned angularSteps = 36,
295  QImage mapTexture = QImage());
296 
299  struct Measures {
300  double total;
301  double theoretical;
302  double positive;
303  double negative;
304 
306  };
307 
310 
316  static bool ComputeSurfacesAndVolumes(const QSharedPointer<Map>& map,
318  Measures& surfaces,
319  Measures& volumes);
320 };
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
std::string filename
CloudViewerScene::LightingProfile profile
Distance map generation tool (surface of revolution)
EmptyCellFillOption
Option for handling empty cells.
static bool SaveMapAsCSVMatrix(const QSharedPointer< Map > &map, QString filename, QString xUnit, QString yUnit, double xConversionFactor=1.0, double yConversionFactor=1.0, ecvMainAppInterface *app=0)
Saves a map as a CSV matrix.
static void SetPoylineAxis(ccPolyline *polyline, const CCVector3 &axis)
Sets the revolution axis of a given polyline.
static ccPointCloud * ConvertMapToCloud(const QSharedPointer< Map > &map, ccPolyline *profile, double baseRadius=1.0, bool keepNaNPoints=true)
Converts map to a point cloud.
static bool GetPoylineOrigin(const ccPolyline *polyline, CCVector3 &origin)
Returns the origin associated to a given polyline/profile.
static void SetPoylineOrigin(ccPolyline *polyline, const CCVector3 &origin)
Sets the origin of a given polyline/profile.
static bool ComputeRadialDist(ccPointCloud *cloud, ccPolyline *profile, bool storeRadiiAsSF=false, ecvMainAppInterface *app=0)
Computes radial distance between cloud and a profile.
static ccMesh * ConvertProfileToMesh(ccPolyline *profile, const ccGLMatrix &cloudToProfile, bool counterclockwise, unsigned angularSteps=36, QImage mapTexture=QImage())
Converts profile to a (textured) mesh.
static QImage ConvertMapToImage(const QSharedPointer< Map > &map, ccColorScale::Shared colorScale, unsigned colorScaleSteps=ccColorScale::MAX_STEPS)
Converts map to a QImage.
static double ConicalProject(double phi, double phi1, double n)
static void SetPoylineRevolDim(ccPolyline *polyline, int revolDim)
Sets the revolution dimension of a given polyline.
static bool ComputeMinAndMaxLatitude_rad(ccPointCloud *cloud, double &minLat_rad, double &maxLat_rad, const ccGLMatrix &cloudToSurfaceOrigin, unsigned char revolutionAxisDim)
static int GetPoylineRevolDim(const ccPolyline *polyline)
static bool GetPoylineAxis(const ccPolyline *polyline, CCVector3 &axis)
Returns the revolution axis associated to a given profile (polyline)
static bool ConvertCloudToConical(ccPointCloud *cloud, const ccGLMatrix &cloudToSurface, unsigned char revolutionAxisDim, double latMin_rad, double latMax_rad, double conicalSpanRatio=1.0, bool counterclockwise=false)
Converts a point cloud coordinates to "conical" ones (in place)
static double ConicalProjectN(double phi1, double phi2)
static void SetPolylineHeightShift(ccPolyline *polyline, PointCoordinateType heightShift)
Sets the profile 'height shift' (i.e. along the revolution axis)
static bool GetPolylineHeightShift(const ccPolyline *polyline, PointCoordinateType &heightShift)
Returns the profile 'height shift' (i.e. along the revolution axis)
static bool ComputeSurfacesAndVolumes(const QSharedPointer< Map > &map, ccPolyline *profile, Measures &surfaces, Measures &volumes)
FillStrategyType
Grid filling strategy.
static bool ConvertCloudToCylindrical(ccPointCloud *cloud, const ccGLMatrix &cloudToSurface, unsigned char revolutionAxisDim, bool counterclockwise=false)
Converts a point cloud coordinates to "cylindrical" ones (in place)
static QSharedPointer< Map > CreateMap(ccPointCloud *cloud, ccScalarField *sf, const ccGLMatrix &cloudToSurface, unsigned char revolutionAxisDim, double angStep_rad, double yStep, double yMin, double yMax, bool conical, bool counterclockwise, FillStrategyType fillStrategy, EmptyCellFillOption emptyCellfillOption, ecvMainAppInterface *app=0)
static bool GetPoylineMetaData(const ccPolyline *polyline, ProfileMetaData &data)
static CCVector3 ProjectPointOnCone(double lon_rad, double lat_rad, double latMin_rad, double nProj, bool counterclockwise)
Projects a (longitude,r) couple to a 2D map.
static ccMesh * ConvertConicalMapToMesh(const QSharedPointer< Map > &map, bool counterclockwise, QImage mapTexture=QImage())
Creates a conical projection (textured) mesh.
QSharedPointer< ccColorScale > Shared
Shared pointer type.
Definition: ecvColorScale.h:74
static const unsigned MAX_STEPS
Maximum number of steps (internal representation)
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
Triangular mesh.
Definition: ecvMesh.h:35
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Colored polyline.
Definition: ecvPolyline.h:24
A scalar field associated to display-related parameters.
Main application interface (for plugins)
const char RADIAL_DIST_SF_NAME[]
const char RADII_SF_NAME[]
unsigned count
Number of values projected in this cell (for average computation)
int revolDim
revolution axis (X=0, Y=1, Z=2)
CCVector3 origin
origin of the surface of revolution