21 #ifndef EMODNET_QMGC_POINT_SET_FEATURES_SIMPLIFICATION_COST_H 22 #define EMODNET_QMGC_POINT_SET_FEATURES_SIMPLIFICATION_COST_H 24 #include <CGAL/algorithm.h> 25 #include <CGAL/intersections.h> 32 namespace Polyline_simplification_2
57 boost::optional<typename CDT::Geom_traits::FT>
64 typedef typename Geom_traits::FT FT;
65 typedef typename Geom_traits::Compute_squared_distance_3 Compute_squared_distance;
66 typedef typename Geom_traits::Construct_segment_3 Construct_segment;
67 typedef typename Geom_traits::Segment_3 Segment;
68 typedef typename Geom_traits::Point_3 Point;
71 typedef typename Geom_traits::Rp::Vector_3 Vector_3;
72 typedef typename Geom_traits::Rp::Plane_3 Plane_3;
73 typedef typename Geom_traits::Rp::Line_3 Line_3;
74 typedef typename Geom_traits::Rp::Segment_3 Segment_3;
75 typedef typename Geom_traits::Rp::Intersect_3 Intersect_3;
77 Compute_squared_distance compute_squared_distance = pct.geom_traits().compute_squared_distance_3_object();
78 Construct_segment construct_segment = pct.geom_traits().construct_segment_3_object();
82 Vertices_in_constraint_iterator vicp = boost::prior(vicq);
83 Vertices_in_constraint_iterator vicr = boost::next(vicq);
85 Point
const& lP = (*vicp)->point();
86 Point
const& lR = (*vicr)->point();
87 Point
const& Q = (*vicq)->point();
90 Point
const& lP2 = Point(lP.x(), lP.y(), FT(0.0));
91 Point
const& lR2 = Point(lR.x(), lR.y(), FT(0.0));
92 Point
const& Q2 = Point(Q.x(), Q.y(), FT(0.0));
93 if ( compute_squared_distance(lP2, Q2) > m_maxSqLength || compute_squared_distance(lR2, Q2) > m_maxSqLength ) {
94 return std::numeric_limits<double>::infinity();
98 Segment lP_R = construct_segment(lP, lR) ;
109 Vector_3 cpLineAndZAxis = CGAL::cross_product<typename Geom_traits::Rp>(lP_R.to_vector(), Vector_3(0,0,1));
110 Vector_3 planeNml = CGAL::cross_product<typename Geom_traits::Rp>(lP_R.to_vector(), cpLineAndZAxis);
111 Plane_3 lineAsAPlane = Plane_3(lP, planeNml);
114 Points_in_constraint_iterator pp(vicp), rr(vicr);
116 for ( ;pp != rr; ++pp ) {
118 Line_3 l(*pp, Vector_3(0, 0, 1));
121 typedef typename CGAL::cpp11::result_of<typename Geom_traits::Rp::Intersect_3(Line_3, Plane_3)>::type IntersectionResult;
122 IntersectionResult intersect = CGAL::intersection(l, lineAsAPlane);
126 std::cerr <<
"Error! Empty intersection" << std::endl;
127 return std::numeric_limits<double>::infinity();
129 if (
const Line_3 *s = boost::get<Line_3>(&*intersect)) {
130 std::cerr <<
"Error! Line intersection" << std::endl;
131 return std::numeric_limits<double>::infinity();
135 const Point *ip = boost::get<Point>(&*intersect);
138 FT sqDist = CGAL::squared_distance<typename Geom_traits::Rp>(*pp, *ip);
139 d1 = (std::max)(d1, sqDist) ;
147 double m_maxSqLength;
155 #endif //EMODNET_QMGC_POINT_SET_FEATURES_SIMPLIFICATION_COST_H Definition: point_set_features_simplification_cost.h:30
Extension of CGAL's Constrained_placement class.
Definition: further_constrained_placement.h:38
Polyline simplification cost function used by point set simplification methods.
Definition: point_set_features_simplification_cost.h:43
PointSetFeaturesSimplificationCost(const double &maxLength)
Initializes the cost function.
Definition: point_set_features_simplification_cost.h:49
boost::optional< typename CDT::Geom_traits::FT > operator()(const Constrained_triangulation_plus_2< CDT > &pct, typename Constrained_triangulation_plus_2< CDT >::Vertices_in_constraint_iterator vicq) const
Definition: point_set_features_simplification_cost.h:58