21 #ifndef EMODNET_QMGC_GENERATE_BORDER_FEATURES_POLYLINES_H 22 #define EMODNET_QMGC_GENERATE_BORDER_FEATURES_POLYLINES_H 24 #include "tin_creation/tin_creation_cgal_types.h" 26 #include <CGAL/centroid.h> 39 template <
class Polyhedron>
40 std::vector<std::vector<typename Polyhedron::Point_3>>
41 generateBorderFeaturesPolylines(
const Polyhedron& surface,
42 const bool& constrainEastBorder =
true,
43 const bool& constrainWestBorder =
true,
44 const bool& constrainNorthBorder =
true,
45 const bool& constrainSouthBorder =
true )
47 typedef typename Polyhedron::Point_3 Point_3;
48 typedef typename Polyhedron::Traits::FT FT;
49 typedef typename Polyhedron::Vertex_const_iterator Vertex_const_iterator;
50 typedef std::vector<Point_3> Polyline;
51 typedef std::vector<Polyline> Polylines;
56 std::vector<Point_3 > pts ;
57 for ( Vertex_const_iterator it = surface.vertices_begin(); it != surface.vertices_end(); ++it )
58 pts.push_back(it->point());
59 Point_3 c3 = CGAL::centroid(pts.begin(), pts.end(),CGAL::Dimension_tag<0>());
66 typename Polyhedron::Halfedge_const_handle startHE = surface.border_halfedges_begin() ;
67 if (!startHE->is_border())
68 startHE = startHE->opposite() ;
69 typename Polyhedron::Halfedge_const_handle e = startHE ;
72 bool prevIsRegularBorder = false ;
75 Point_3 p0 = e->vertex()->point() ;
76 Point_3 p1 = e->prev()->vertex()->point() ;
78 double diffX = fabs( p1.x() - p0.x() ) ;
79 double diffY = fabs( p1.y() - p0.y() ) ;
81 if ( ( constrainEastBorder && diffX < diffY && p0.x() > midX ) ||
82 ( constrainWestBorder && diffX < diffY && p0.x() < midX ) ||
83 ( constrainNorthBorder && diffY < diffX && p0.y() > midY ) ||
84 ( constrainSouthBorder && diffY < diffX && p0.y() < midY ) ) {
90 polylines.push_back(pl);
91 prevIsRegularBorder =
false;
95 if (!prevIsRegularBorder) {
97 polylines.push_back(plU);
101 prevIsRegularBorder = true ;
108 if (prevIsRegularBorder)
110 prevIsRegularBorder = !isTileCorner<Polyhedron>(e) ;
114 while ( e != startHE );
117 polylines.push_back(plU) ;
122 #endif //EMODNET_QMGC_GENERATE_BORDER_FEATURES_POLYLINES_H Set of miscellaneous functions extending the functionality of the CGAL library.