projection_mesh.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
33 #ifndef _projection_mesh_H_
34 #define _projection_mesh_H_
35 
36 //####################################################################
37 // Includes:
38 //####################################################################
39 
40 //System Includes
41 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
42 #include <CGAL/IO/Color.h>
43 #include <CGAL/Triangulation_2.h>
44 #include <CGAL/Triangulation_vertex_base_with_info_2.h>
45 
46 #include <CGAL/Polygon_2_algorithms.h>
47 #include <CGAL/Delaunay_triangulation_2.h>
48 
49 #include <CGAL/basic.h>
50 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
51 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
52 #include <CGAL/Partition_traits_2.h>
53 #include <CGAL/Partition_is_valid_traits_2.h>
54 #include <CGAL/polygon_function_objects.h>
55 #include <CGAL/partition_2.h>
56 #include <CGAL/point_generators_2.h>
57 #include <CGAL/Polygon_set_2.h>
58 #include <CGAL/Cartesian.h>
59 #include <CGAL/polygon_function_objects.h>
60 #include <CGAL/random_polygon_2.h>
61 
62 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
63 #include <CGAL/Constrained_Delaunay_triangulation_2.h>
64 
65 #include <pcl/segmentation/sac_segmentation.h>
66 #include <pcl/filters/project_inliers.h>
67 #include <pcl/point_cloud.h>
68 #include <pcl/point_types.h>
69 #include <pcl_ros/transforms.h>
70 #include <pcl/ModelCoefficients.h>
71 #include <tf/tf.h>
72 #include <visualization_msgs/Marker.h>
73 
74 #include <CGAL/Constrained_Delaunay_triangulation_2.h>
75 #include <CGAL/Constrained_triangulation_plus_2.h>
76 
77 #include <opencv2/imgproc/imgproc.hpp>
78 #include <opencv2/highgui/highgui.hpp>
79 #include <opencv2/core/core.hpp>
80 
81 //define the kernel
82 //typedef CGAL::Exact_predicates_exact_constructions_kernel K;
83 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
84 
85 //Define an extension to the vertex
86 typedef struct {double z;float rgb;float weight;} t_vertex_extension;
87 
88 //define the face from the class Enriched_face_base_2
89 template <class Gt, class Fb >
90 class face_extension : public Fb
91 {
92  public:
93  typedef Gt Geom_traits;
94  typedef typename Fb::Vertex_handle Vertex_handle;
95  typedef typename Fb::Face_handle Face_handle;
96 
97  template < typename TDS2 >
98  struct Rebind_TDS
99  {
100  typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
102  };
103 
104  int status;
105  int counter;
106  bool visited;
107 
108  float weight;
109  inline bool is_in_domain() const { return (status%2 == 1); };
110 
111  inline void set_in_domain(const bool b) { status = (b ? 1 : 0); };
112 
113 
114  face_extension(): Fb(), status(-1) {};
115 
117  Vertex_handle v1,
118  Vertex_handle v2): Fb(v0,v1,v2), status(-1) {};
119 
121  Vertex_handle v1,
122  Vertex_handle v2,
123  Face_handle n0,
124  Face_handle n1,
125  Face_handle n2): Fb(v0,v1,v2,n0,n1,n2), status(-1) {};
126 
127 }; // end class Enriched_face_base_2
128 
129 
130 //Define the face as the extension class
131 //typedef face_extension<K, CGAL::Constrained_triangulation_face_base_2<K> > Fb;
132 //typedef CGAL::Triangulation_vertex_base_with_info_2<t_vertex_extension, K> Vb;
133 
134 
135 //Define the triangulation data_structure
136 typedef CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<t_vertex_extension, K>,
138 
139 //Define the Constrained Delaunay Triangulation plus we are using as projection triangulation PT
140 typedef CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<K, TDS_projection_mesh, CGAL::No_intersection_tag> > PT;
141 //typedef CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<K, TDS_projection_mesh, CGAL::Exact_intersections_tag> > PT;
142 
143 
144 //Now the actual class
146 {
147  public:
149  {
150  };
152 
153  int draw_mesh_triangles(cv::Mat* image, cv::Scalar color, int thickness);
154  int print_all_vertices(void);
155  int clear_constraints(void);
156  int clear_vertices(void);
157  int add_vertex_to_mesh(double x, double y, double z, float rgb, float weight);
158  int set_constraint_polygon(std::vector<pcl::PointXY>* p);
159  int export_triangles(pcl::PointCloud<pcl::PointXYZRGB>* vertex_list, std::vector<float>* face_weights);
160  int export_triangles_in_order(pcl::PointCloud<pcl::PointXYZRGB>* vertex_list, std::vector<float>* face_weights);
161  int compute_face_weights(void);
163  {
164  for(PT::All_faces_iterator it = mesh.all_faces_begin(); it != mesh.all_faces_end(); ++it)
165  {
166  it->visited=false;
167  }
168  return 1;
169  }
170 
171  //Variables
173 
174  void discoverComponents(const PT& ct);
175  void discoverComponent(const PT& ct, PT::Face_handle start, int index, std::list<PT::Edge>& border );
176  int initialize_all_faces_status(void);
177 };
178 
179 
180 
181 #endif
182 
int initialize_all_faces_status(void)
CGAL::Exact_predicates_inexact_constructions_kernel K
bool is_in_domain() const
void discoverComponents(const PT &ct)
face_extension(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Face_handle n0, Face_handle n1, Face_handle n2)
int print_all_vertices(void)
CGAL::Triangulation_data_structure_2< CGAL::Triangulation_vertex_base_with_info_2< t_vertex_extension, K >, face_extension< K, CGAL::Constrained_triangulation_face_base_2< K > > > TDS_projection_mesh
CDT::All_faces_iterator All_faces_iterator
int draw_mesh_triangles(cv::Mat *image, cv::Scalar color, int thickness)
Fb::Face_handle Face_handle
face_extension< Gt, Fb2 > Other
void set_in_domain(const bool b)
void discoverComponent(const PT &ct, PT::Face_handle start, int index, std::list< PT::Edge > &border)
Fb::Vertex_handle Vertex_handle
int set_constraint_polygon(std::vector< pcl::PointXY > *p)
face_extension(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2)
unsigned char b[16]
CGAL::Constrained_triangulation_plus_2< CGAL::Constrained_Delaunay_triangulation_2< K, TDS_projection_mesh, CGAL::No_intersection_tag > > PT
int add_vertex_to_mesh(double x, double y, double z, float rgb, float weight)
int export_triangles_in_order(pcl::PointCloud< pcl::PointXYZRGB > *vertex_list, std::vector< float > *face_weights)
CDT::Face_handle Face_handle
int export_triangles(pcl::PointCloud< pcl::PointXYZRGB > *vertex_list, std::vector< float > *face_weights)
Fb::template Rebind_TDS< TDS2 >::Other Fb2


polygon_primitives_extraction
Author(s): Miguel Oliveira
autogenerated on Mon Mar 2 2015 01:32:42