ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Delaynay2dMesh.cpp
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 #include <pybind11/pybind11.h>
9 #include <pybind11/stl_bind.h>
10 
11 #include <Delaunay2dMesh.h>
12 #include <GenericIndexedCloud.h>
14 #include <GenericIndexedMesh.h>
15 
16 namespace py = pybind11;
17 using namespace pybind11::literals;
18 
19 void define_Delaunay2dMesh(py::module &cccorelib)
20 {
21  py::class_<cloudViewer::Delaunay2dMesh, cloudViewer::GenericIndexedMesh>(cccorelib, "Delaunay2dMesh")
22  .def_property_readonly_static("USE_ALL_POINTS",
23  [](const py::object & /* self */)
25  .def(py::init<>())
26  .def_static("Available", &cloudViewer::Delaunay2dMesh::Available)
27  .def(
28  "linkMeshWith", &cloudViewer::Delaunay2dMesh::linkMeshWith, "aCloud"_a, "passOwnership"_a = false)
29  .def("buildMesh",
30  (bool(cloudViewer::Delaunay2dMesh::*)(const std::vector<CCVector2> &,
31  std::size_t,
33  "points2D"_a,
34  "pointCountToUse"_a,
35  "outputErrorStr"_a)
36  .def("buildMesh",
37  (bool(cloudViewer::Delaunay2dMesh::*)(const std::vector<CCVector2> &,
38  const std::vector<int> &,
40  "points2D"_a,
41  "segments2D"_a,
42  "outputErrorStr"_a)
43  .def("removeOuterTriangles",
45  const std::vector<CCVector2> &, const std::vector<CCVector2> &, bool removeOutside))(
47  "vertices2D"_a,
48  "polygon2D"_a,
49  "removeOutside"_a = true)
50  .def("getTriangleVertIndexesArray",
52  py::return_value_policy::reference)
53  .def("getTriangleVertIndexesArray",
55  "maxEdgeLength"_a)
56  .def("getAssociatedCloud",
58  py::return_value_policy::reference)
59  .def_static("TesselateContour",
61  (*)(const std::vector<CCVector2> &))(&cloudViewer::Delaunay2dMesh::TesselateContour),
62  "contourPoints"_a)
63  .def_static("TesselateContour",
66  "contourPoints"_a,
67  "flatDimension"_a = -1);
68 }
void define_Delaunay2dMesh(py::module &cccorelib)
A class to compute and handle a Delaunay 2D mesh on a subset of points.
static Delaunay2dMesh * TesselateContour(const std::vector< CCVector2 > &contourPoints)
static bool Available()
Returns whether 2D Delaunay triangulation is supported or not.
virtual bool removeOuterTriangles(const std::vector< CCVector2 > &vertices2D, const std::vector< CCVector2 > &polygon2D, bool removeOutside=true)
Removes the triangles falling outside of a given (2D) polygon.
bool removeTrianglesWithEdgesLongerThan(PointCoordinateType maxEdgeLength)
Filters out the triangles based on their edge length.
virtual bool buildMesh(const std::vector< CCVector2 > &points2D, std::size_t pointCountToUse, std::string &outputErrorStr)
Build the Delaunay mesh on top a set of 2D points.
virtual void linkMeshWith(GenericIndexedCloud *aCloud, bool passOwnership=false)
Associate this mesh to a point cloud.
int * getTriangleVertIndexesArray()
Returns triangles indexes array (pointer to)
GenericIndexedCloud * getAssociatedCloud()
Returns associated cloud.
static constexpr int USE_ALL_POINTS
A generic 3D point cloud with index-based and presistent access to points.