-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgalHeader.hpp
109 lines (84 loc) · 3.75 KB
/
cgalHeader.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* Created on: 31/03/2021
* Author: Ziniu Lu ([email protected])
*/
#pragma once
// for skeletonization & segmentation
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/extract_mean_curvature_flow_skeleton.h>
#include <CGAL/mesh_segmentation.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
// for isotropic remeshing
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/border.h>
#include <boost/iterator/function_output_iterator.hpp>
// for transforming
#include <CGAL/Aff_transformation_3.h>
#include <CGAL/aff_transformation_tags.h>
#include <CGAL/polygon_mesh_processing.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
// for skeletonization & segmentation
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Plane_3 Plane_3;
typedef Kernel::Vector_3 Vector_3;
// structure of polygon mesh
typedef CGAL::Surface_mesh<Point> Triangle_mesh;
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron;
// for skeletonization module
typedef CGAL::Mean_curvature_flow_skeletonization<Polyhedron> Skeletonization;
typedef Skeletonization::Skeleton Skeleton;
typedef Skeleton::vertex_descriptor Skeleton_vertex;
typedef Skeleton::edge_descriptor Skeleton_edge;
// descriptor
typedef boost::graph_traits<Triangle_mesh>::vertex_descriptor t_vertex_descriptor;
typedef boost::graph_traits<Triangle_mesh>::halfedge_descriptor t_halfedge_descriptor;
typedef boost::graph_traits<Triangle_mesh>::face_descriptor t_face_descriptor;
typedef boost::graph_traits<Polyhedron>::vertex_descriptor p_vertex_descriptor;
typedef boost::graph_traits<Polyhedron>::halfedge_descriptor p_halfedge_descriptor;
typedef boost::graph_traits<Polyhedron>::face_descriptor p_face_descriptor;
// for isotropic remeshing
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> r_Mesh;
typedef boost::graph_traits<r_Mesh>::halfedge_descriptor r_halfedge_descriptor;
typedef boost::graph_traits<r_Mesh>::edge_descriptor r_edge_descriptor;
// for segmentation
namespace PMP = CGAL::Polygon_mesh_processing;
//typedef CGAL::Face_filtered_graph<Polyhedron> Filtered_graph;
typedef Kernel::Aff_transformation_3 Transform;
struct halfedge2edge
{
halfedge2edge(const r_Mesh& m, std::vector<r_edge_descriptor>& edges)
: m_mesh(m), m_edges(edges)
{}
void operator()(const r_halfedge_descriptor& h) const
{
m_edges.push_back(edge(h, m_mesh));
}
const r_Mesh& m_mesh;
std::vector<r_edge_descriptor>& m_edges;
};
// Property map associating a facet with an integer as id to an
// element in a vector stored internally
template<class ValueType>
struct Facet_with_id_pmap : public boost::put_get_helper<ValueType&, Facet_with_id_pmap<ValueType> >
{
typedef p_face_descriptor key_type;
typedef ValueType value_type;
typedef value_type& reference;
typedef boost::lvalue_property_map_tag category;
Facet_with_id_pmap(std::vector<ValueType>& internal_vector) : internal_vector(internal_vector) { }
reference operator[](key_type key) const
{
return this->internal_vector[key->id()];
}
inline std::vector<ValueType>& get() const
{
return this->internal_vector;
}
private:
std::vector<ValueType>& internal_vector;
};