ccInnerRect2DFinder.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_INNER_RECT_2D_FINDER_HEADER
  18. #define CC_INNER_RECT_2D_FINDER_HEADER
  19. //qCC_db
  20. #include <ccBox.h>
  21. #include <ccGenericPointCloud.h>
  22. //! Finds a the biggets enclosed rectangle in a point cloud (2D)
  23. class ccInnerRect2DFinder
  24. {
  25. public:
  26. //! Default constructor
  27. ccInnerRect2DFinder();
  28. //! Finds the biggest enclosed rectangle
  29. ccBox* process( ccGenericPointCloud* cloud, unsigned char zDim = 2 );
  30. protected:
  31. //! Initializes internal structures
  32. bool init(ccGenericPointCloud* cloud, unsigned char zDim);
  33. //! 2D rectangle
  34. struct Rect
  35. {
  36. Rect() : x0(0), y0(0), x1(0), y1(0) {}
  37. Rect(double _x0, double _y0, double _x1, double _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
  38. double x0, y0, x1, y1;
  39. inline double width() const { return x1 - x0; }
  40. inline double height() const { return y1 - y0; }
  41. inline double area() const { return width() * height(); }
  42. };
  43. //! Internal processs
  44. void findBiggestRect(const Rect& rect, unsigned startIndex);
  45. //! Global rectangle
  46. Rect m_boundingRect;
  47. //! Inner rectangle
  48. Rect m_maxRect;
  49. //! Inner rectangle max area
  50. double m_maxArea;
  51. //! Associated cloud
  52. ccGenericPointCloud* m_cloud;
  53. //! X dimension
  54. unsigned char m_X;
  55. //! Y dimension
  56. unsigned char m_Y;
  57. };
  58. #endif //CC_INNER_RECT_2D_FINDER_HEADER