ccClippingBoxTool.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_CLIPPING_BOX_TOOL_HEADER
  18. #define CC_CLIPPING_BOX_TOOL_HEADER
  19. //common
  20. #include <ccOverlayDialog.h>
  21. //local
  22. #include "ccEnvelopeExtractor.h"
  23. #include <ui_clippingBoxDlg.h>
  24. //qCC_db
  25. #include <ccGLUtils.h>
  26. //system
  27. #include <vector>
  28. class ccGenericPointCloud;
  29. class ccGenericMesh;
  30. class ccProgressDialog;
  31. class ccGLWindowInterface;
  32. class ccHObject;
  33. class ccClipBox;
  34. class ccPolyline;
  35. class ccBBox;
  36. //! Dialog for managing a clipping box
  37. class ccClippingBoxTool : public ccOverlayDialog, public Ui::ClippingBoxDlg
  38. {
  39. Q_OBJECT
  40. public:
  41. //! Default constructor
  42. explicit ccClippingBoxTool(QWidget* parent);
  43. //! Default destructor
  44. virtual ~ccClippingBoxTool();
  45. //inherited from ccOverlayDialog
  46. virtual bool linkWith(ccGLWindowInterface* win) override;
  47. virtual bool start() override;
  48. virtual void stop(bool state) override;
  49. //! Returns box
  50. const ccClipBox* box() const { return m_clipBox; }
  51. //! Adds an entity
  52. /** \return success, if the entity is eligible for clipping
  53. **/
  54. bool addAssociatedEntity(ccHObject* anObject);
  55. //! Returns the current number of associated entities
  56. unsigned getNumberOfAssociatedEntity() const;
  57. //! Extract slices and optionally envelopes from various clouds and/or clouds
  58. /** \param clouds input clouds (may be empty if meshes are defined)
  59. \param meshes input meshes (may be empty if clouds are defined)
  60. \param clipBox clipping box
  61. \param singleSliceMode if true, a single cut is made (the process is not repeated) and only the envelope is extracted (not the slice)
  62. \param processDimensions If singleSliceMode is true: the dimension normal to the slice should be true (and the others false). Otherwise: the dimensions along which to repeat the cuting process should be true.
  63. \param outputSlices output slices (if successful)
  64. \param extractEnvelopes whether to extract envelopes or not
  65. \param maxEdgeLength max envelope edge length (the smaller, the tighter the envelope will be)
  66. \param envelopeType envelope type
  67. \param outputEnvelopes output envelopes (if successful)
  68. \param extractLevelSet whether to extract the level set or not
  69. \param levelSetGridStep the step of the grid from which the level set will be extraced
  70. \param levelSetMinVertCount minimum number of vertex count per contour
  71. \param levelSet level set (contour) lines (if any)
  72. \param gap optional gap between each slice
  73. \param multiPass multi-pass envelope extraction
  74. \param splitEnvelopes whether to split the envelope(s) when the segment can't be smaller than the specified 'maxEdgeLength'
  75. \param projectOnBestFitPlane to project the points on the slice best fitting plane (otherwise the plane normal to the
  76. \param visualDebugMode displays a 'debugging' window during the envelope extraction process
  77. \param generateRandomColors randomly colors the extracted slices
  78. \param progressDialog optional progress dialog
  79. **/
  80. static bool ExtractSlicesAndContours
  81. (
  82. const std::vector<ccGenericPointCloud*>& clouds,
  83. const std::vector<ccGenericMesh*>& meshes,
  84. ccClipBox& clipBox,
  85. bool singleSliceMode,
  86. bool processDimensions[3],
  87. std::vector<ccHObject*>& outputSlices,
  88. bool extractEnvelopes,
  89. PointCoordinateType maxEdgeLength,
  90. ccEnvelopeExtractor::EnvelopeType envelopeType,
  91. std::vector<ccPolyline*>& outputEnvelopes,
  92. bool extractLevelSet,
  93. double levelSetGridStep,
  94. int levelSetMinVertCount,
  95. std::vector<ccPolyline*>& levelSet,
  96. PointCoordinateType gap = 0,
  97. bool multiPass = false,
  98. bool splitEnvelopes = false,
  99. bool projectOnBestFitPlane = false,
  100. bool visualDebugMode = false,
  101. bool generateRandomColors = false,
  102. ccProgressDialog* progressDialog = 0);
  103. protected:
  104. void toggleInteractors(bool);
  105. void toggleBox(bool);
  106. void editBox();
  107. void restoreLastBox();
  108. void reset();
  109. void closeDialog();
  110. void extractContour();
  111. void removeLastContour();
  112. void exportSlice();
  113. void exportMultSlices();
  114. void onBoxModified(const ccBBox* box);
  115. void thicknessChanged(double);
  116. inline void shiftXMinus() { shiftBox(0, true); }
  117. inline void shiftXPlus() { shiftBox(0, false); }
  118. inline void shiftYMinus() { shiftBox(1, true); }
  119. inline void shiftYPlus() { shiftBox(1, false); }
  120. inline void shiftZMinus() { shiftBox(2, true); }
  121. inline void shiftZPlus() { shiftBox(2, false); }
  122. void setFrontView();
  123. void setBottomView();
  124. void setTopView();
  125. void setBackView();
  126. void setLeftView();
  127. void setRightView();
  128. protected:
  129. //! Extracts slices and/or contours
  130. void extractSlicesAndContours(bool singleSliceMode);
  131. //! Shift box
  132. void shiftBox(unsigned char dim, bool minus);
  133. //! Sets predefined view
  134. void setView(CC_VIEW_ORIENTATION orientation);
  135. //! Clipping box
  136. ccClipBox* m_clipBox;
  137. };
  138. #endif //CC_CLIPPING_BOX_TOOL_HEADER