ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Delaunay2dMesh.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 <cstddef>
12 #include <vector>
13 
15 #include "GenericIndexedMesh.h"
16 #include "SimpleTriangle.h"
17 
18 namespace cloudViewer {
19 
20 class GenericIndexedCloud;
21 class Polyline;
22 
25 public:
26  static constexpr int USE_ALL_POINTS = 0;
27 
30 
32  ~Delaunay2dMesh() override;
33 
35 
37  static bool Available();
38 
40 
48  virtual void linkMeshWith(GenericIndexedCloud* aCloud,
49  bool passOwnership = false);
50 
52 
57  virtual bool buildMesh(const std::vector<CCVector2>& points2D,
58  std::size_t pointCountToUse,
59  std::string& outputErrorStr);
60 
62 
67  virtual bool buildMesh(const std::vector<CCVector2>& points2D,
68  const std::vector<int>& segments2D,
69  std::string& outputErrorStr);
70 
72 
77  virtual bool removeOuterTriangles(const std::vector<CCVector2>& vertices2D,
78  const std::vector<CCVector2>& polygon2D,
79  bool removeOutside = true);
80 
81  // inherited methods (see GenericMesh)
82  virtual unsigned size() const override { return m_numberOfTriangles; }
83  void forEach(genericTriangleAction action) override;
84  void getBoundingBox(CCVector3& bbMin, CCVector3& bbMax) override;
85  void placeIteratorAtBeginning() override;
86  GenericTriangle* _getNextTriangle() override;
87  GenericTriangle* _getTriangle(unsigned triangleIndex) override;
88  VerticesIndexes* getNextTriangleVertIndexes() override;
89  VerticesIndexes* getTriangleVertIndexes(unsigned triangleIndex) override;
90  virtual void getTriangleVertices(unsigned triangleIndex,
91  CCVector3& A,
92  CCVector3& B,
93  CCVector3& C) const override;
94  virtual void getTriangleVertices(unsigned triangleIndex,
95  double A[3],
96  double B[3],
97  double C[3]) const override;
98 
100 
102  inline int* getTriangleVertIndexesArray() { return m_triIndexes; }
103 
105 
108  bool removeTrianglesWithEdgesLongerThan(PointCoordinateType maxEdgeLength);
109 
112  return m_associatedCloud;
113  }
114 
117  static Delaunay2dMesh* TesselateContour(
118  const std::vector<CCVector2>& contourPoints);
119 
121  static Delaunay2dMesh* TesselateContour(
122  GenericIndexedCloudPersist* contourPoints, int flatDimension = -1);
123 
124 protected:
127 
130 
133 
136 
139 
143 
146 
149 };
150 
151 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
A class to compute and handle a Delaunay 2D mesh on a subset of points.
int * m_globalIterator
Iterator on the list of triangle vertex indexes.
int * m_triIndexes
Triangle vertex indexes.
unsigned m_numberOfTriangles
The number of triangles.
virtual unsigned size() const override
Returns the number of triangles.
GenericIndexedCloud * m_associatedCloud
Associated point cloud.
int * m_globalIteratorEnd
End position of global iterator.
int * getTriangleVertIndexesArray()
Returns triangles indexes array (pointer to)
VerticesIndexes m_dumpTriangleIndexes
Dump triangle index structure to transmit temporary data.
GenericIndexedCloud * getAssociatedCloud()
Returns associated cloud.
SimpleTriangle m_dumpTriangle
Dump triangle structure to transmit temporary data.
A generic 3D point cloud with index-based and presistent access to points.
A generic 3D point cloud with index-based point access.
A generic mesh with index-based vertex access.
A generic triangle interface.
A simple triangle class.
Generic file read and write utility for python interface.
Triangle described by the indexes of its 3 vertices.