ccVolumeCalcTool.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_VOLUME_CALC_TOOL_HEADER
  18. #define CC_VOLUME_CALC_TOOL_HEADER
  19. //Local
  20. #include "cc2.5DimEditor.h"
  21. //Qt
  22. #include <QDialog>
  23. class ccGenericPointCloud;
  24. class ccPointCloud;
  25. class ccPolyline;
  26. namespace Ui {
  27. class VolumeCalcDialog;
  28. }
  29. //! Volume calculation tool (dialog)
  30. class ccVolumeCalcTool : public QDialog, public cc2Point5DimEditor
  31. {
  32. Q_OBJECT
  33. public:
  34. //! Default constructor
  35. ccVolumeCalcTool(ccGenericPointCloud* cloud1, ccGenericPointCloud* cloud2, QWidget* parent = nullptr);
  36. //! Destructor
  37. ~ccVolumeCalcTool();
  38. //Inherited from cc2Point5DimEditor
  39. virtual double getGridStep() const override;
  40. virtual unsigned char getProjectionDimension() const override;
  41. virtual ccRasterGrid::ProjectionType getTypeOfProjection() const override;
  42. //! Report info
  43. struct ReportInfo
  44. {
  45. ReportInfo()
  46. : volume(0)
  47. , addedVolume(0)
  48. , removedVolume(0)
  49. , surface(0)
  50. , matchingPrecent(0)
  51. , ceilNonMatchingPercent(0)
  52. , groundNonMatchingPercent(0)
  53. , averageNeighborsPerCell(0)
  54. {}
  55. QString toText(int precision = 6) const;
  56. double volume;
  57. double addedVolume;
  58. double removedVolume;
  59. double surface;
  60. float matchingPrecent;
  61. float ceilNonMatchingPercent;
  62. float groundNonMatchingPercent;
  63. double averageNeighborsPerCell;
  64. };
  65. //! Static accessor
  66. static bool ComputeVolume( ccRasterGrid& grid,
  67. ccGenericPointCloud* ground,
  68. ccGenericPointCloud* ceil,
  69. const ccBBox& gridBox,
  70. unsigned char vertDim,
  71. double gridStep,
  72. unsigned gridWidth,
  73. unsigned gridHeight,
  74. ccRasterGrid::ProjectionType projectionType,
  75. ccRasterGrid::EmptyCellFillOption groundEmptyCellFillStrategy,
  76. double groundMaxEdgeLength,
  77. ccRasterGrid::EmptyCellFillOption ceilEmptyCellFillStrategy,
  78. double ceilMaxEdgeLength,
  79. ccVolumeCalcTool::ReportInfo& reportInfo,
  80. double groundHeight,
  81. double ceilHeight,
  82. QWidget* parentWidget = nullptr);
  83. //! Converts a (volume) grid to a point cloud
  84. static ccPointCloud* ConvertGridToCloud( ccRasterGrid& grid,
  85. const ccBBox& gridBox,
  86. unsigned char vertDim,
  87. bool exportToOriginalCS);
  88. protected:
  89. //! Accepts the dialog and save settings
  90. void saveSettingsAndAccept();
  91. //! Save persistent settings and 'accept' dialog
  92. void saveSettings();
  93. //! Called when the projection direction changes
  94. void projectionDirChanged(int);
  95. //! Called when the SF projection type changes
  96. void sfProjectionTypeChanged(int);
  97. //Inherited from cc2Point5DimEditor
  98. virtual bool showGridBoxEditor() override;
  99. //! Called when the (ground) empty cell filling strategy changes
  100. void groundFillEmptyCellStrategyChanged(int);
  101. //! Called when the (ceil) empty cell filling strategy changes
  102. void ceilFillEmptyCellStrategyChanged(int);
  103. //! Called when the an option of the grid generation has changed
  104. void gridOptionChanged();
  105. //! Updates the gid info
  106. void updateGridInfo();
  107. //! Update the grid and the 2D display
  108. void updateGridAndDisplay();
  109. //! Swap roles
  110. void swapRoles();
  111. //! Ground source changed
  112. void groundSourceChanged(int);
  113. //! Ceil source changed
  114. void ceilSourceChanged(int);
  115. //! Exports info to clipboard
  116. void exportToClipboard() const;
  117. //! Exports the grid as a point cloud
  118. void exportGridAsCloud() const;
  119. //! Sets the displayed number precision
  120. void setDisplayedNumberPrecision(int);
  121. //! Returns the ground cloud (or constant height)
  122. std::pair<ccGenericPointCloud*, double> getGroundCloud() const;
  123. //! Returns the ceil cloud (or constant height)
  124. std::pair<ccGenericPointCloud*, double> getCeilCloud() const;
  125. protected: //standard methods
  126. //Inherited from cc2Point5DimEditor
  127. virtual void gridIsUpToDate(bool state) override;
  128. //! Load persistent settings
  129. void loadSettings();
  130. //! Updates the grid
  131. bool updateGrid();
  132. //! Converts the grid to a point cloud
  133. ccPointCloud* convertGridToCloud(bool exportToOriginalCS) const;
  134. //! Outputs the report
  135. void outputReport(const ReportInfo& info);
  136. protected: //members
  137. //! First associated cloud
  138. ccGenericPointCloud* m_cloud1;
  139. //! Second associated cloud
  140. ccGenericPointCloud* m_cloud2;
  141. //! Last report
  142. /** Only valid if clipboardPushButton is enabled
  143. **/
  144. ReportInfo m_lastReport;
  145. Ui::VolumeCalcDialog* m_ui;
  146. };
  147. #endif //CC_VOLUME_CALC_TOOL_HEADER