ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvOctree.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 // Local
11 #include "ecvHObject.h"
12 
13 // cloudViewer
14 #include <DgmOctree.h>
15 #include <ReferenceCloud.h>
16 
17 // Qt
18 #include <QObject>
19 
20 class ccCameraSensor;
23 
25 
27 class CV_DB_LIB_API ccOctree : public QObject, public cloudViewer::DgmOctree {
28  Q_OBJECT
29 
30 public: // GENERAL METHODS
32  typedef QSharedPointer<ccOctree> Shared;
33 
35 
37  explicit ccOctree(ccGenericPointCloud* cloud);
38 
40  virtual ~ccOctree();
41 
43 
48  void multiplyBoundingBox(const PointCoordinateType multFactor);
49 
51 
55  void translateBoundingBox(const CCVector3& T);
56 
58  ccBBox getSquareBB() const;
60  ccBBox getPointsBB() const;
61 
62  // inherited from DgmOctree
63  virtual void clear() override;
64 
65 public: // RENDERING
67  int getDisplayedLevel() const { return m_displayedLevel; }
69  void setDisplayedLevel(int level);
70 
72  bool isVisible() const { return m_visible; }
74  inline void setVisible(bool state) { m_visible = state; }
75 
77  enum DisplayMode {
78  WIRE = 0,
80  MEAN_POINTS =
81  1,
83  MEAN_CUBES = 2
85  };
87  DisplayMode getDisplayMode() const { return m_displayMode; }
89  void setDisplayMode(DisplayMode mode);
90 
92  void draw(CC_DRAW_CONTEXT& context);
93 
95  bool intersectWithFrustum(ccCameraSensor* sensor,
96  std::vector<unsigned>& inCameraFrustum);
97 
99  bool pointPicking(const CCVector2d& clickPos,
100  const ccGLCameraParameters& camera,
101  PointDescriptor& output,
102  double pickWidth_pix = 3.0) const;
103 
104 public: // HELPERS
108  ColorCompType meanCol[]);
109 
111  static CCVector3 ComputeAverageNorm(cloudViewer::ReferenceCloud* subset,
113 
115 
119  static PointCoordinateType GuessNaiveRadius(ccGenericPointCloud* cloud);
120 
123  int aimedPopulationPerCell = 16;
124  int aimedPopulationRange =
125  4;
126  int minCellPopulation = 6;
127  double minAboveMinRatio = 0.97;
129  };
130 
132 
139  static PointCoordinateType GuessBestRadius(
140  ccGenericPointCloud* cloud,
141  const BestRadiusParams& params,
142  cloudViewer::DgmOctree* cloudOctree = nullptr,
143  cloudViewer::GenericProgressCallback* progressCb = nullptr);
144 
147 
153  static PointCoordinateType GuessBestRadiusAutoComputeOctree(
154  ccGenericPointCloud* cloud,
155  const BestRadiusParams& params,
156  QWidget* parentWidget = nullptr);
157 
158 signals:
159 
161  void updated();
162 
163 protected:
164  static bool DrawCellAsABox(const cloudViewer::DgmOctree::octreeCell& cell,
165  void** additionalParameters,
167 
168  static bool DrawCellAsAPoint(
170  void** additionalParameters,
172 
173  static bool DrawCellAsAPrimitive(
175  void** additionalParameters,
177 
178 protected: // MEMBERS
181 
184 
187 
190 
192  bool m_visible;
193 };
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
#define CV_DB_LIB_API
Definition: CV_db.h:15
#define signals
Bounding box structure.
Definition: ecvBBox.h:25
Camera (projective) sensor.
A 3D cloud interface with associated features (color, normals, octree, etc.)
Octree structure.
Definition: ecvOctree.h:27
DisplayMode getDisplayMode() const
Returns the currently display mode.
Definition: ecvOctree.h:87
int m_displayedLevel
Displayed level.
Definition: ecvOctree.h:183
void setVisible(bool state)
Sets octree visibility.
Definition: ecvOctree.h:74
ccGenericPointCloud * m_theAssociatedCloudAsGPC
Associated cloud (as a ccGenericPointCloud)
Definition: ecvOctree.h:180
bool isVisible() const
Returns whether octree is visible or not.
Definition: ecvOctree.h:72
void updated()
Signal sent when the octree organization is modified (cleared, etc.)
DisplayMode
Octree displaying methods.
Definition: ecvOctree.h:77
ccOctreeFrustumIntersector * m_frustumIntersector
For frustum intersection.
Definition: ecvOctree.h:189
DisplayMode m_displayMode
Display mode.
Definition: ecvOctree.h:186
int getDisplayedLevel() const
Returns the currently displayed octree level.
Definition: ecvOctree.h:67
QSharedPointer< ccOctree > Shared
Shared pointer.
Definition: ecvOctree.h:32
bool m_visible
For Octree Display.
Definition: ecvOctree.h:192
The octree structure used throughout the library.
Definition: DgmOctree.h:39
virtual void clear()
Clears the octree.
Definition: DgmOctree.cpp:183
A very simple point cloud (no point duplication)
unsigned char ColorCompType
Default color components type (R,G and B)
Definition: ecvColorTypes.h:29
ImGuiContext * context
Definition: Window.cpp:76
cloudViewer::NormalizedProgress * nProgress
ccGenericPointCloud * sourceCloud
static ecvColor::Rgb ComputeAverageColor(const ccPointCloud &cloud, cloudViewer::ReferenceCloud *subset)
OpenGL camera parameters.
Display context.
Parameters for the GuessBestRadius method.
Definition: ecvOctree.h:122
Octree cell descriptor.
Definition: DgmOctree.h:354