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 
56 
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; }
90 
93 
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 
113 
115 
120 
123  int aimedPopulationPerCell = 16;
124  int aimedPopulationRange =
125  4;
126  int minCellPopulation = 6;
127  double minAboveMinRatio = 0.97;
129  };
130 
132 
140  ccGenericPointCloud* cloud,
141  const BestRadiusParams& params,
142  cloudViewer::DgmOctree* cloudOctree = nullptr,
143  cloudViewer::GenericProgressCallback* progressCb = nullptr);
144 
147 
154  ccGenericPointCloud* cloud,
155  const BestRadiusParams& params,
156  QWidget* parentWidget = nullptr);
157 
158 signals:
159 
161  void updated();
162 
163 protected:
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
cmdLineReadable * params[]
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
static bool DrawCellAsAPrimitive(const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=0)
DisplayMode getDisplayMode() const
Returns the currently display mode.
Definition: ecvOctree.h:87
int m_displayedLevel
Displayed level.
Definition: ecvOctree.h:183
static void ComputeAverageColor(cloudViewer::ReferenceCloud *subset, ccGenericPointCloud *sourceCloud, ColorCompType meanCol[])
Computes the average color of a set of points.
void setDisplayedLevel(int level)
Sets the currently displayed octree level.
static PointCoordinateType GuessBestRadiusAutoComputeOctree(ccGenericPointCloud *cloud, const BestRadiusParams &params, QWidget *parentWidget=nullptr)
static bool DrawCellAsAPoint(const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=0)
void setVisible(bool state)
Sets octree visibility.
Definition: ecvOctree.h:74
virtual void clear() override
Clears the octree.
ccBBox getSquareBB() const
Returns the octree (square) bounding-box.
ccOctree(ccGenericPointCloud *cloud)
Default constructor.
void setDisplayMode(DisplayMode mode)
Sets the currently display mode.
bool intersectWithFrustum(ccCameraSensor *sensor, std::vector< unsigned > &inCameraFrustum)
Intersects octree with a camera sensor.
virtual ~ccOctree()
Destructor.
void multiplyBoundingBox(const PointCoordinateType multFactor)
Multiplies the bounding-box of the octree.
ccGenericPointCloud * m_theAssociatedCloudAsGPC
Associated cloud (as a ccGenericPointCloud)
Definition: ecvOctree.h:180
static PointCoordinateType GuessBestRadius(ccGenericPointCloud *cloud, const BestRadiusParams &params, cloudViewer::DgmOctree *cloudOctree=nullptr, cloudViewer::GenericProgressCallback *progressCb=nullptr)
Tries to guess the best 'local radius' for octree-based computation.
bool isVisible() const
Returns whether octree is visible or not.
Definition: ecvOctree.h:72
static PointCoordinateType GuessNaiveRadius(ccGenericPointCloud *cloud)
Tries to guess a very naive 'local radius' for octree-based computation.
void updated()
Signal sent when the octree organization is modified (cleared, etc.)
DisplayMode
Octree displaying methods.
Definition: ecvOctree.h:77
ccBBox getPointsBB() const
Returns the points bounding-box.
bool pointPicking(const CCVector2d &clickPos, const ccGLCameraParameters &camera, PointDescriptor &output, double pickWidth_pix=3.0) const
Octree-driven point picking algorithm.
ccOctreeFrustumIntersector * m_frustumIntersector
For frustum intersection.
Definition: ecvOctree.h:189
DisplayMode m_displayMode
Display mode.
Definition: ecvOctree.h:186
static bool DrawCellAsABox(const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=0)
int getDisplayedLevel() const
Returns the currently displayed octree level.
Definition: ecvOctree.h:67
void draw(CC_DRAW_CONTEXT &context)
Draws the octree.
QSharedPointer< ccOctree > Shared
Shared pointer.
Definition: ecvOctree.h:32
bool m_visible
For Octree Display.
Definition: ecvOctree.h:192
void translateBoundingBox(const CCVector3 &T)
Translates the bounding-box of the octree.
static CCVector3 ComputeAverageNorm(cloudViewer::ReferenceCloud *subset, ccGenericPointCloud *sourceCloud)
Computes the average normal of a set of points.
The octree structure used throughout the library.
Definition: DgmOctree.h:39
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
OpenGL camera parameters.
Display context.
Parameters for the GuessBestRadius method.
Definition: ecvOctree.h:122
Structure used during nearest neighbour search.
Definition: DgmOctree.h:101
Octree cell descriptor.
Definition: DgmOctree.h:354