ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGenericPointCloud.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 "ecvAdvancedTypes.h"
12 #include "ecvBBox.h"
13 #include "ecvOctree.h"
14 #include "ecvOrientedBBox.h"
15 #include "ecvShiftedObject.h"
16 
17 // System
18 #include <vector>
19 
20 namespace cloudViewer {
21 class GenericProgressCallback;
22 class ReferenceCloud;
23 } // namespace cloudViewer
24 
25 class ccOctreeProxy;
26 
27 /***************************************************
28  ccGenericPointCloud
29 ***************************************************/
30 
31 // default material for clouds (with normals)
32 #define CC_DEFAULT_CLOUD_AMBIENT_COLOR ecvColor::bright
33 #define CC_DEFAULT_CLOUD_SPECULAR_COLOR ecvColor::bright
34 #define CC_DEFAULT_CLOUD_DIFFUSE_COLOR ecvColor::bright
35 #define CC_DEFAULT_CLOUD_EMISSION_COLOR ecvColor::night
36 #define CC_DEFAULT_CLOUD_SHININESS 50.0f
37 
39 
46  : public ccShiftedObject,
48  friend class ccMesh;
49 
50 public:
52  ccGenericPointCloud(QString name = QString());
53 
56 
58  ~ccGenericPointCloud() override;
59 
60  /***************************************************
61  Clone/Copy
62  ***************************************************/
63 
65 
72  virtual ccGenericPointCloud* clone(ccGenericPointCloud* destCloud = nullptr,
73  bool ignoreChildren = false) = 0;
74 
75  /***************************************************
76  Features deletion/clearing
77  ***************************************************/
78 
80 
82  virtual void clear();
83 
84  /***************************************************
85  Octree management
86  ***************************************************/
87 
89 
99  cloudViewer::GenericProgressCallback* progressCb = nullptr,
100  bool autoAddChild = true);
101 
103  virtual ccOctree::Shared getOctree() const;
105  virtual void setOctree(ccOctree::Shared octree, bool autoAddChild = true);
107  virtual ccOctreeProxy* getOctreeProxy() const;
108 
110  virtual void deleteOctree();
111 
112  /***************************************************
113  Features getters
114  ***************************************************/
115 
117 
122  virtual const ecvColor::Rgb* getScalarValueColor(ScalarType d) const = 0;
123 
125 
130  virtual const ecvColor::Rgb* getPointScalarValueColor(
131  unsigned pointIndex) const = 0;
132 
134 
138  virtual ScalarType getPointDisplayedDistance(unsigned pointIndex) const = 0;
139 
141 
143  virtual const ecvColor::Rgb& getPointColor(unsigned pointIndex) const = 0;
144 
146 
149  virtual const CompressedNormType& getPointNormalIndex(
150  unsigned pointIndex) const = 0;
151 
153 
156  virtual const CCVector3& getPointNormal(unsigned pointIndex) const = 0;
157 
158  /***************************************************
159  Visibility array
160  ***************************************************/
161 
163 
165  using VisibilityTableType = std::vector<unsigned char>;
166 
169  return m_pointsVisibility;
170  }
171 
173  virtual inline const VisibilityTableType& getTheVisibilityArray() const {
174  return m_pointsVisibility;
175  }
176 
178 
183  virtual cloudViewer::ReferenceCloud* getTheVisiblePoints(
184  const VisibilityTableType* visTable = nullptr,
185  bool silent = false,
186  cloudViewer::ReferenceCloud* selection = nullptr) const;
187 
189  virtual bool isVisibilityTableInstantiated() const;
190 
192 
194  virtual bool resetVisibilityArray();
195 
197  virtual void invertVisibilityArray();
198 
200  virtual void unallocateVisibilityArray();
201 
202  /***************************************************
203  Other methods
204  ***************************************************/
205 
206  // Inherited from ccHObject
207  ccBBox getOwnBB(bool withGLFeatures = false) override;
208 
210  virtual void refreshBB() = 0;
211 
214 
224  virtual ccGenericPointCloud* createNewCloudFromVisibilitySelection(
225  bool removeSelectedPoints = false,
226  VisibilityTableType* visTable = nullptr,
227  std::vector<int>* newIndexesOfRemainingPoints = nullptr,
228  bool silent = false,
229  cloudViewer::ReferenceCloud* selection = nullptr) = 0;
230 
232 
237  virtual bool removeVisiblePoints(
238  VisibilityTableType* visTable = nullptr,
239  std::vector<int>* newIndexes = nullptr) = 0;
240 
242  virtual void applyRigidTransformation(const ccGLMatrix& trans) = 0;
243 
245 
250  virtual cloudViewer::ReferenceCloud* crop(const ccBBox& box,
251  bool inside = true) = 0;
252  virtual cloudViewer::ReferenceCloud* crop(const ecvOrientedBBox& box) = 0;
253 
254  virtual void removePoints(size_t index) = 0;
255 
257 
263  virtual void scale(PointCoordinateType fx,
266  CCVector3 center = CCVector3(0, 0, 0)) = 0;
267 
268  // inherited from ccSerializableObject
269  bool isSerializable() const override { return true; }
270 
272 
275  void setPointSize(unsigned size = 0) {
276  m_pointSize = static_cast<unsigned char>(size);
277  }
278 
280 
283  unsigned char getPointSize() const { return m_pointSize; }
284 
286 
288  void importParametersFrom(const ccGenericPointCloud* cloud);
289 
291 
293  bool pointPicking(const CCVector2d& clickPos,
294  const ccGLCameraParameters& camera,
295  int& nearestPointIndex,
296  double& nearestSquareDist,
297  double pickWidth = 2.0,
298  double pickHeight = 2.0,
299  bool autoComputeOctree = false);
300 
301  std::tuple<Eigen::Vector3d, Eigen::Matrix3d> computeMeanAndCovariance()
302  const;
303  cloudViewer::SquareMatrixd computeCovariance() const;
304 
305 protected:
306  // inherited from ccHObject
307  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
308  short minimumFileVersion_MeOnly() const override;
309  bool fromFile_MeOnly(QFile& in,
310  short dataVersion,
311  int flags,
312  LoadedIDMap& oldToNewIDMap) override;
313 
315 
319 
321  unsigned char m_pointSize;
322 };
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
ccGenericPointCloud::m_pointsVisibility
VisibilityTableType m_pointsVisibility
Per-point visibility table.
Definition: ecvGenericPointCloud.h:318
ccSerializableObject::LoadedIDMap
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
Definition: ecvSerializableObject.h:61
ccHObject::toFile_MeOnly
virtual bool toFile_MeOnly(QFile &out, short dataVersion) const
Save own object data.
Definition: ecvHObject.cpp:1302
ccHObject::minimumFileVersion_MeOnly
virtual short minimumFileVersion_MeOnly() const
Definition: ecvHObject.cpp:1364
cloudViewer::SquareMatrixTpl< double >
ccGenericPointCloud::m_pointSize
unsigned char m_pointSize
Point size (won't be applied if 0)
Definition: ecvGenericPointCloud.h:321
ccBBox
Bounding box structure.
Definition: ecvBBox.h:25
ecvBBox.h
ccGenericMesh::importParametersFrom
void importParametersFrom(const ccGenericMesh *mesh)
Imports the parameters from another mesh.
Definition: ecvGenericMesh.cpp:452
cloudViewer::GenericProgressCallback
Definition: GenericProgressCallback.h:20
ccOctree::Shared
QSharedPointer< ccOctree > Shared
Shared pointer.
Definition: ecvOctree.h:32
CCVector3
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
ccGLCameraParameters
OpenGL camera parameters.
Definition: ecvGenericDisplayTools.h:554
Vector2Tpl< double >
size
int size
Definition: FileIOFactory.cpp:130
ccGenericPointCloud::setPointSize
void setPointSize(unsigned size=0)
Sets point size.
Definition: ecvGenericPointCloud.h:275
ccGenericPointCloud::getTheVisibilityArray
virtual VisibilityTableType & getTheVisibilityArray()
Returns associated visibility array.
Definition: ecvGenericPointCloud.h:168
ccGenericPointCloud
A 3D cloud interface with associated features (color, normals, octree, etc.)
Definition: ecvGenericPointCloud.h:45
Vector3Tpl< PointCoordinateType >
ecvOrientedBBox.h
CompressedNormType
unsigned int CompressedNormType
Compressed normals type.
Definition: ecvBasicTypes.h:16
ccHObject::fromFile_MeOnly
virtual bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Loads own object data.
Definition: ecvHObject.cpp:1371
ccGenericPointCloud::isSerializable
bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvGenericPointCloud.h:269
ccOctreeProxy
Octree structure proxy.
Definition: ecvOctreeProxy.h:18
ecvAdvancedTypes.h
ecvShiftedObject.h
ccShiftedObject
Shifted entity interface.
Definition: ecvShiftedObject.h:18
cloudViewer::GenericIndexedCloudPersist
A generic 3D point cloud with index-based and presistent access to points.
Definition: GenericIndexedCloudPersist.h:18
ccGLMatrix
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
octree
cloudViewer::DgmOctree * octree
Definition: qCanupoTools.cpp:37
cloudViewer::ReferenceCloud
A very simple point cloud (no point duplication)
Definition: ReferenceCloud.h:29
ccMesh::clear
void clear()
Definition: ecvMesh.cpp:2126
ecvColor::RgbTpl
RGB color structure.
Definition: ecvColorTypes.h:49
ccMesh
Triangular mesh.
Definition: ecvMesh.h:35
ecvOrientedBBox
Definition: ecvOrientedBBox.h:29
ccGenericPointCloud::getTheVisibilityArray
virtual const VisibilityTableType & getTheVisibilityArray() const
Returns associated visibility array (const version)
Definition: ecvGenericPointCloud.h:173
ccHObject::getOwnBB
virtual ccBBox getOwnBB(bool withGLFeatures=false)
Returns the entity's own bounding-box.
Definition: ecvHObject.cpp:757
CV_DB_LIB_API
#define CV_DB_LIB_API
Definition: CV_db.h:15
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
ccEntityAction::computeOctree
bool computeOctree(const ccHObject::Container &selectedEntities, QWidget *parent)
Definition: ecvEntityAction.cpp:2072
ccGenericPointCloud::getPointSize
unsigned char getPointSize() const
Returns current point size.
Definition: ecvGenericPointCloud.h:283
ccMesh::refreshBB
void refreshBB() override
Forces bounding-box update.
Definition: ecvMesh.cpp:2387
ecvOctree.h
name
std::string name
Definition: FileIOFactory.cpp:129
ccGenericPointCloud::VisibilityTableType
std::vector< unsigned char > VisibilityTableType
Array of "visibility" information for each point.
Definition: ecvGenericPointCloud.h:165