ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
cgal_utils.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include <CGAL/Simple_cartesian.h>
7#include <CGAL/Surface_mesh.h>
8#include <Eigen/Core>
9#include <pcl/PolygonMesh.h>
10
12
14using K = CGAL::Simple_cartesian<double>;
15
17using Point_3 = K::Point_3;
18
20using Vector_3 = K::Vector_3;
21
23using Mesh = CGAL::Surface_mesh<Point_3>;
24
28Mesh pcl_to_cgal_mesh(const pcl::PolygonMesh& pcl_mesh);
29
33pcl::PolygonMesh cgal_to_pcl_mesh(const Mesh& cgal_mesh);
34
38inline Point_3 eigen_to_cgal(const Eigen::Vector3d& v) {
39 return Point_3(v.x(), v.y(), v.z());
40}
41
45inline Eigen::Vector3d cgal_to_eigen(const Point_3& p) {
46 return Eigen::Vector3d(CGAL::to_double(p.x()),
47 CGAL::to_double(p.y()),
48 CGAL::to_double(p.z()));
49}
50
54inline Eigen::Vector3d cgal_to_eigen(const Vector_3& v) {
55 return Eigen::Vector3d(CGAL::to_double(v.x()),
56 CGAL::to_double(v.y()),
57 CGAL::to_double(v.z()));
58}
59
62std::vector<pcl::PolygonMeshPtr>
63decompose_mesh(const pcl::PolygonMesh &mesh);
64
65} // namespace reusex::geometry::cgal
CGAL::Surface_mesh< Point_3 > Mesh
CGAL surface mesh type.
K::Vector_3 Vector_3
CGAL 3D vector type.
pcl::PolygonMesh cgal_to_pcl_mesh(const Mesh &cgal_mesh)
Convert CGAL Surface_mesh to PCL PolygonMesh.
Point_3 eigen_to_cgal(const Eigen::Vector3d &v)
Convert Eigen Vector3d to CGAL Point_3.
Eigen::Vector3d cgal_to_eigen(const Point_3 &p)
Convert CGAL Point_3 to Eigen Vector3d.
CGAL::Simple_cartesian< double > K
CGAL kernel for geometric computations.
K::Point_3 Point_3
CGAL 3D point type.
Mesh pcl_to_cgal_mesh(const pcl::PolygonMesh &pcl_mesh)
Convert PCL PolygonMesh to CGAL Surface_mesh.
std::vector< pcl::PolygonMeshPtr > decompose_mesh(const pcl::PolygonMesh &mesh)
Split a mesh into its connected components.
pcl::PolygonMeshPtr mesh(CloudConstPtr cloud, CloudNConstPtr normals, EigenVectorContainer< double, 4 > &planes, EigenVectorContainer< double, 3 > &centroids, std::vector< IndicesPtr > &inliers, CloudLConstPtr rooms, MeshOptions const opt=MeshOptions{})
Generate a mesh from point cloud and geometric primitives.