ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
PointProjectionTools.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 "CVConst.h"
12 #include "CVPointCloud.h"
13 #include "CVToolbox.h"
14 #include "SquareMatrix.h"
15 
16 // System
17 #include <list>
18 
19 namespace cloudViewer {
20 
24  1,
27 };
28 
29 class GenericIndexedMesh;
30 class GenericProgressCallback;
31 
35 public:
36  static constexpr int IGNORE_MAX_EDGE_LENGTH = 0;
38 
40  struct Transformation {
46  double s;
47 
49  Transformation() : s(1.0) {}
50 
52  inline CCVector3d apply(const CCVector3d& P) const {
53  return s * (R * P) + T;
54  }
55 
57  inline CCVector3 apply(const CCVector3& P) const {
58  return (s * (R * P) + T).toPC();
59  }
60 
62 
66  CV_CORE_LIB_API void apply(GenericIndexedCloudPersist& cloud) const;
67  };
68 
70 
80  static PointCloud* developCloudOnCylinder(
81  GenericCloud* cloud,
82  PointCoordinateType radius,
83  unsigned char dim = 2,
84  CCVector3* center = nullptr,
85  GenericProgressCallback* progressCb = nullptr);
86 
88 
99  static PointCloud* developCloudOnCone(
100  GenericCloud* cloud,
101  unsigned char dim,
102  PointCoordinateType baseRadius,
103  float alpha,
104  const CCVector3& center,
105  GenericProgressCallback* progressCb = nullptr);
106 
108 
114  static PointCloud* applyTransformation(
115  GenericCloud* cloud,
116  Transformation& trans,
117  GenericProgressCallback* progressCb = nullptr);
118 
120 
126  static PointCloud* applyTransformation(
127  GenericIndexedCloud* cloud,
128  Transformation& trans,
129  GenericProgressCallback* progressCb = nullptr);
130 
132 
136  // static CCVector3 applyTransformation(const CCVector3& P, Transformation&
137  // trans);
138 
140 
151  static GenericIndexedMesh* computeTriangulation(
154  PointCoordinateType maxEdgeLength,
155  unsigned char dim,
156  std::string& outputErrorStr);
157 
159 
161  class IndexedCCVector2 : public CCVector2 {
162  public:
164  IndexedCCVector2() : CCVector2(), index(0) {}
167  : CCVector2(x, y), index(0) {}
171  unsigned i)
172  : CCVector2(x, y), index(i) {}
174  IndexedCCVector2(const CCVector2& v) : CCVector2(v), index(0) {}
175 
177  unsigned index;
178  };
179 
181 
191  static bool extractConvexHull2D(std::vector<IndexedCCVector2>& points,
192  std::list<IndexedCCVector2*>& hullPoints);
193 
195 
203  static bool extractConcaveHull2D(std::vector<IndexedCCVector2>& points,
204  std::list<IndexedCCVector2*>& hullPoints,
205  PointCoordinateType maxSquareLength = 0);
206 
208  static bool segmentIntersect(const CCVector2& A,
209  const CCVector2& B,
210  const CCVector2& C,
211  const CCVector2& D);
212 };
213 
214 } // namespace cloudViewer
cloudViewer::GenericIndexedCloud
A generic 3D point cloud with index-based point access.
Definition: GenericIndexedCloud.h:18
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
x
normal_z x
Definition: my_point_types.h:165
cloudViewer::PointProjectionTools::Transformation::apply
CCVector3d apply(const CCVector3d &P) const
Applies the transformation to a point.
Definition: PointProjectionTools.h:52
cloudViewer::PointProjectionTools::IndexedCCVector2::index
unsigned index
Point index.
Definition: PointProjectionTools.h:177
CVConst.h
cloudViewer::SquareMatrixTpl< double >
cloudViewer::GenericCloud
Definition: GenericCloud.h:20
Vector3Tpl::toPC
Vector3Tpl< PointCoordinateType > toPC() const
Definition: CVGeom.h:263
cloudViewer::DELAUNAY_2D_AXIS_ALIGNED
@ DELAUNAY_2D_AXIS_ALIGNED
Definition: PointProjectionTools.h:23
cloudViewer::GenericProgressCallback
Definition: GenericProgressCallback.h:20
cloudViewer::PointProjectionTools::Transformation::R
SquareMatrixd R
Rotation.
Definition: PointProjectionTools.h:42
cloudViewer::CVToolbox
Empty class - for classification purpose only.
Definition: CVToolbox.h:15
Vector2Tpl< PointCoordinateType >
cloudViewer::PointProjectionTools::Transformation::apply
CCVector3 apply(const CCVector3 &P) const
Applies the transformation to a point.
Definition: PointProjectionTools.h:57
y
normal_z y
Definition: my_point_types.h:168
cloudViewer::PointProjectionTools::IndexedCCVector2
Indexed 2D vector.
Definition: PointProjectionTools.h:161
Vector3Tpl< double >
cloudViewer::PointProjectionTools::Transformation::s
double s
Scale.
Definition: PointProjectionTools.h:46
cloudViewer::PointCloud
Definition: CVPointCloud.h:18
CVToolbox.h
cloudViewer::PointProjectionTools
Definition: PointProjectionTools.h:34
CVPointCloud.h
cloudViewer::PointProjectionTools::Transformation::T
CCVector3d T
Translation.
Definition: PointProjectionTools.h:44
cloudViewer::PointProjectionTools::IndexedCCVector2::IndexedCCVector2
IndexedCCVector2(PointCoordinateType x, PointCoordinateType y)
Constructor.
Definition: PointProjectionTools.h:166
points
int points
Definition: FileIOFactory.cpp:144
cloudViewer::GenericIndexedMesh
A generic mesh with index-based vertex access.
Definition: GenericIndexedMesh.h:37
cloudViewer::PointProjectionTools::IndexedCCVector2::IndexedCCVector2
IndexedCCVector2()
Default constructor.
Definition: PointProjectionTools.h:164
cloudViewer::GenericIndexedCloudPersist
A generic 3D point cloud with index-based and presistent access to points.
Definition: GenericIndexedCloudPersist.h:18
cloudViewer::DELAUNAY_2D_BEST_LS_PLANE
@ DELAUNAY_2D_BEST_LS_PLANE
Definition: PointProjectionTools.h:25
cloudViewer::PointProjectionTools::Transformation
A scaled geometrical transformation (scale + rotation + translation)
Definition: PointProjectionTools.h:40
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
cloudViewer::PointProjectionTools::Transformation::Transformation
Transformation()
Default constructor.
Definition: PointProjectionTools.h:49
cloudViewer::PointProjectionTools::IndexedCCVector2::IndexedCCVector2
IndexedCCVector2(PointCoordinateType x, PointCoordinateType y, unsigned i)
Constructor.
Definition: PointProjectionTools.h:169
cloudViewer::TRIANGULATION_TYPES
TRIANGULATION_TYPES
Triangulation types.
Definition: PointProjectionTools.h:22
type
char type
Definition: FileIOFactory.cpp:131
SquareMatrix.h
CV_CORE_LIB_API
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
cloudViewer::PointProjectionTools::IndexedCCVector2::IndexedCCVector2
IndexedCCVector2(const CCVector2 &v)
Copy constructor.
Definition: PointProjectionTools.h:174