mirror of https://github.com/CGAL/cgal
Dropped out-dated examples, simplify.cpp example compiles.
This commit is contained in:
parent
3a841c38c6
commit
cfea03d54b
|
|
@ -3278,9 +3278,6 @@ Polyline_simplification_2/doc_tex/Polyline_simplification_2_ref/Stop_below_count
|
|||
Polyline_simplification_2/doc_tex/Polyline_simplification_2_ref/Stop_below_count_threshold.tex -text
|
||||
Polyline_simplification_2/doc_tex/Polyline_simplification_2_ref/intro.tex -text
|
||||
Polyline_simplification_2/doc_tex/Polyline_simplification_2_ref/main.tex -text
|
||||
Polyline_simplification_2/examples/Polyline_simplification_2/Polyline_simplification_2_basic_example.cpp -text
|
||||
Polyline_simplification_2/examples/Polyline_simplification_2/Polyline_simplification_2_example_from_original.cpp -text
|
||||
Polyline_simplification_2/examples/Polyline_simplification_2/Polyline_simplification_2_example_with_visitor.cpp -text
|
||||
Polyline_simplification_2/include/CGAL/Polyline_simplification_2/reference_manual_concepts/CostFunction_concept.h -text
|
||||
Polyline_simplification_2/include/CGAL/Polyline_simplification_2/reference_manual_concepts/PolylineNode_concept.h -text
|
||||
Polyline_simplification_2/include/CGAL/Polyline_simplification_2/reference_manual_concepts/StopPredicate_concept.h -text
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
// Recommended kernel
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
// The simplification data structure
|
||||
#include <CGAL/Polyline_simplification_2.h>
|
||||
|
||||
// Stop predicate
|
||||
#include <CGAL/Polyline_simplification_2/Stop_below_count_ratio_threshold.h>
|
||||
|
||||
// Cost function
|
||||
#include <CGAL/Polyline_simplification_2/Scaled_squared_distance_cost.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
||||
typedef K::Point_2 Point ;
|
||||
|
||||
typedef CGAL::Simplify_polylines_2<K> PS;
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
PS ps ;
|
||||
|
||||
Point points[] = { Point(0,1)
|
||||
, Point(1,2)
|
||||
, Point(2,1)
|
||||
, Point(3,3)
|
||||
, Point(4,1)
|
||||
, Point(5,4)
|
||||
, Point(6,1)
|
||||
, Point(3,0)
|
||||
} ;
|
||||
|
||||
// Insert polygon into simplification class
|
||||
PS::Closed_polyline_handle poly = ps.insert_polygon(points,points+8);
|
||||
|
||||
std::cout << "Before simplification" << std::endl ;
|
||||
std::cout << std::endl ;
|
||||
|
||||
// Iterate over the vertices of the inserted polygon before simplification
|
||||
PS::Closed_polyline::Circulator head = poly->circulator();
|
||||
PS::Closed_polyline::Circulator cit = head;
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << cit->point() << std::endl ;
|
||||
}
|
||||
while ( ++ cit != head ) ;
|
||||
|
||||
// Define the stop predicate to finish when the number of vertices drops
|
||||
// below half the initial amount
|
||||
CGAL::Polyline_simplification_2::Stop_below_count_ratio_threshold stop(0.5);
|
||||
|
||||
// Use the scaled squared distance cost function
|
||||
CGAL::Polyline_simplification_2::Scaled_squared_distance_cost<double> cost;
|
||||
|
||||
// Proceed with the simplification
|
||||
ps.simplify(stop, cost) ;
|
||||
|
||||
// Continue with the simplification from the previously simplified set
|
||||
ps.simplify(stop, cost) ;
|
||||
|
||||
// And again...
|
||||
ps.simplify(stop, cost) ;
|
||||
|
||||
std::cout << "After simplification" << std::endl ;
|
||||
std::cout << std::endl ;
|
||||
|
||||
// Iterate over the now simplified polyline showing the remaning vertices
|
||||
head = poly->circulator();
|
||||
cit = head;
|
||||
do
|
||||
{
|
||||
std::cout << cit->point() << std::endl ;
|
||||
}
|
||||
while ( ++ cit != head ) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
// Recommended kernel
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
// The simplification data structure
|
||||
#include <CGAL/Polyline_simplification_2.h>
|
||||
|
||||
// Stop predicate
|
||||
#include <CGAL/Polyline_simplification_2/Stop_below_count_ratio_threshold.h>
|
||||
|
||||
// Cost functions
|
||||
#include <CGAL/Polyline_simplification_2/Scaled_squared_distance_cost.h>
|
||||
#include <CGAL/Polyline_simplification_2/Squared_distance_cost.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
||||
typedef K::Point_2 Point ;
|
||||
|
||||
typedef CGAL::Simplify_polylines_2<K> PS;
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
PS ps ;
|
||||
|
||||
Point points[] = { Point(0,1)
|
||||
, Point(1,2)
|
||||
, Point(2,1)
|
||||
, Point(3,3)
|
||||
, Point(4,1)
|
||||
, Point(5,4)
|
||||
, Point(6,1)
|
||||
, Point(3,0)
|
||||
} ;
|
||||
|
||||
// Insert polygon into simplification class
|
||||
PS::Closed_polyline_handle poly = ps.insert_polygon(points,points+8);
|
||||
|
||||
std::cout << "Before simplification" << std::endl ;
|
||||
std::cout << std::endl ;
|
||||
|
||||
// Iterate over the vertices of the inserted polygon before simplification
|
||||
PS::Closed_polyline::Circulator head = poly->circulator();
|
||||
PS::Closed_polyline::Circulator cit = head;
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << cit->point() << std::endl ;
|
||||
}
|
||||
while ( ++ cit != head ) ;
|
||||
|
||||
// Define the stop predicate to finish when the number of vertices drops
|
||||
// below half the initial amount
|
||||
CGAL::Polyline_simplification_2::Stop_below_count_ratio_threshold stop(0.5);
|
||||
|
||||
CGAL::Polyline_simplification_2::Scaled_squared_distance_cost<double> cost1;
|
||||
CGAL::Polyline_simplification_2::Squared_distance_cost<double> cost2;
|
||||
|
||||
// Proceed with the simplification
|
||||
ps.simplify(stop, cost1) ;
|
||||
|
||||
std::cout << "Using the scaled squared distance" << std::endl ;
|
||||
std::cout << std::endl ;
|
||||
|
||||
// Iterate over the now simplified polyline showing the remaining vertices
|
||||
head = poly->circulator();
|
||||
cit = head;
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << cit->point() << std::endl ;
|
||||
}
|
||||
while ( ++ cit != head ) ;
|
||||
|
||||
// Start again but using the other cost function
|
||||
ps.simplify_original(stop, cost2) ;
|
||||
|
||||
std::cout << "Using the absolute squared distance" << std::endl ;
|
||||
std::cout << std::endl ;
|
||||
|
||||
// Iterate over the now simplified polyline showing the remaning vertices
|
||||
head = poly->circulator();
|
||||
cit = head;
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << cit->point() << std::endl ;
|
||||
}
|
||||
while ( ++ cit != head ) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
// Recommended kernel
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
// The simplification data structure
|
||||
#include <CGAL/Polyline_simplification_2.h>
|
||||
|
||||
// Stop predicate
|
||||
#include <CGAL/Polyline_simplification_2/Stop_below_count_ratio_threshold.h>
|
||||
|
||||
// Cost function
|
||||
#include <CGAL/Polyline_simplification_2/Scaled_squared_distance_cost.h>
|
||||
|
||||
// Helper visitor base
|
||||
#include <CGAL/Polyline_simplification_2/Visitor_base.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
||||
typedef K::Point_2 Point ;
|
||||
|
||||
typedef CGAL::Simplify_polylines_2<K> PS;
|
||||
|
||||
// Create a custom visitor using the helper base class and overriding only one function
|
||||
struct My_visitor : CGAL::Polyline_simplification_2::Visitor_base<PS>
|
||||
{
|
||||
void OnSelected( Vertex_handle const& v, boost::optional<FT> const& cost, unsigned icount , unsigned ccount ) const
|
||||
{
|
||||
std::cout << "step [" << ccount << "/" << icount << "]: " << "V" << v->id() << " with cost " << cost << " selected" << std::endl ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
PS ps ;
|
||||
|
||||
Point points[] = { Point(0,1)
|
||||
, Point(1,2)
|
||||
, Point(2,1)
|
||||
, Point(3,3)
|
||||
, Point(4,1)
|
||||
, Point(5,4)
|
||||
, Point(6,1)
|
||||
, Point(3,0)
|
||||
} ;
|
||||
|
||||
// Insert polygon into simplification class
|
||||
PS::Closed_polyline_handle poly = ps.insert_polygon(points,points+8);
|
||||
|
||||
std::cout << "Before simplification" << std::endl ;
|
||||
std::cout << std::endl ;
|
||||
|
||||
// Iterate over the vertices of the inserted polygon before simplification
|
||||
PS::Closed_polyline::Circulator head = poly->circulator();
|
||||
PS::Closed_polyline::Circulator cit = head;
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << cit->point() << std::endl ;
|
||||
}
|
||||
while ( ++ cit != head ) ;
|
||||
|
||||
// Define the stop predicate to finish when the number of vertices drops
|
||||
// below half the initial amount
|
||||
CGAL::Polyline_simplification_2::Stop_below_count_ratio_threshold stop(0.5);
|
||||
|
||||
// Use the scaled squared distance cost function
|
||||
CGAL::Polyline_simplification_2::Scaled_squared_distance_cost<double> cost;
|
||||
|
||||
// Proceed with the simplification tracking the process
|
||||
My_visitor visitor ;
|
||||
|
||||
ps.simplify(stop, cost, visitor) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ int main( )
|
|||
pct.vertices_in_constraint_begin(*cit);
|
||||
vit != pct.vertices_in_constraint_end(*cit);
|
||||
++vit)
|
||||
std::cout << vit->point << std::endl;
|
||||
std::cout << vit->point() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ mark_vertices_unremovable(CGAL::Polyline_constrained_triangulation_2<Tr>& pct,
|
|||
if(it->point.y() > t->point().y()) t = *it;
|
||||
}
|
||||
l->fixed = r->fixed = t->fixed = b->fixed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fix the leftmost, rightmost, topmost and bottommost vertex
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
bool operator() ( Vertices_in_constraint_iterator const& x,
|
||||
Vertices_in_constraint_iterator const& y ) const
|
||||
{
|
||||
return x->cost < y->cost;
|
||||
return x->vertex->cost < y->vertex->cost;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ public:
|
|||
Id_map idm;
|
||||
mpq = new MPQ(m, cc, idm);
|
||||
initialize_costs(cid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -129,17 +129,17 @@ public:
|
|||
for(Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid);
|
||||
it != pct.vertices_in_constraint_end(cid);
|
||||
++it){
|
||||
if(! it->fixed && ! it->removed){
|
||||
if(! it->vertex->fixed){
|
||||
Vertices_in_constraint_iterator u = boost::prior(it);
|
||||
Vertices_in_constraint_iterator w = boost::next(it);
|
||||
|
||||
boost::optional<double> dist = cost(pct, u, it, w);
|
||||
if(dist){
|
||||
it->cost = *dist;
|
||||
it->vertex->cost = *dist;
|
||||
(*mpq).push(it);
|
||||
++n;
|
||||
} else {
|
||||
it->cost = (std::numeric_limits<double>::max)();
|
||||
it->vertex->cost = (std::numeric_limits<double>::max)();
|
||||
std::cerr << "could not compute a cost" << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ public:
|
|||
is_removable(Vertices_in_constraint_iterator it)
|
||||
{
|
||||
typedef typename PCT::Geom_traits Geom_traits;
|
||||
if( it->removed || it->fixed){
|
||||
if(it->vertex->fixed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -237,26 +237,26 @@ operator()()
|
|||
Vertices_in_constraint_iterator u = boost::prior(v), w = boost::next(v);
|
||||
pct.simplify(u,v,w, keep_points);
|
||||
|
||||
if(! u->fixed){
|
||||
if(! u->vertex->fixed){
|
||||
Vertices_in_constraint_iterator uu = boost::prior(u);
|
||||
boost::optional<double> dist = cost(pct, uu,u,w);
|
||||
if(! dist){
|
||||
std::cerr << "undefined cost not handled yet" << std::endl;
|
||||
} else {
|
||||
u->cost = *dist;
|
||||
u->vertex->cost = *dist;
|
||||
if((*mpq).contains(u)){
|
||||
(*mpq).update(u, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(! w->fixed){
|
||||
if(! w->vertex->fixed){
|
||||
Vertices_in_constraint_iterator ww = boost::next(w);
|
||||
boost::optional<double> dist = cost(pct, u,w,ww);
|
||||
if(! dist){
|
||||
std::cerr << "undefined cost not handled yet" << std::endl;
|
||||
} else {
|
||||
w->cost = *dist;
|
||||
w->vertex->cost = *dist;
|
||||
if((*mpq).contains(w)){
|
||||
(*mpq).update(w, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,13 @@ public:
|
|||
return boost::make_iterator_range(skip_begin(), skip_end());
|
||||
}
|
||||
|
||||
/// The elements pointed to by it are no longer in the range
|
||||
/// [skip_begin(), skip_end()).
|
||||
void skip(skip_iterator it)
|
||||
{
|
||||
skip_.erase(it.base());
|
||||
}
|
||||
|
||||
/// The elements pointed to by it are no longer in the range
|
||||
/// [skip_begin(), skip_end()).
|
||||
///
|
||||
|
|
|
|||
|
|
@ -498,18 +498,17 @@ remove_constraint(Constraint_id hvl){
|
|||
// and for the case that the constrained edge u,w has no intersections
|
||||
template <class T, class Data>
|
||||
void Polyline_constraint_hierarchy_2<T,Data>::simplify(H_vertex_it uc,
|
||||
H_vertex_it vc,
|
||||
H_vertex_it wc)
|
||||
H_vertex_it vc,
|
||||
H_vertex_it wc)
|
||||
|
||||
{
|
||||
CGAL_assertion(vc->fixed != true);
|
||||
CGAL_assertion(vc->removed != true);
|
||||
CGAL_assertion(vc->vertex->fixed != true);
|
||||
Vertex_handle u = uc->vertex, v = vc->vertex, w = wc->vertex;
|
||||
typename H_sc_to_c_map::iterator uv_sc_iter = sc_to_c_map.find(make_edge(u, v));
|
||||
CGAL_assertion_msg( uv_sc_iter != sc_to_c_map.end(), "not a subconstraint" );
|
||||
H_context_list* uv_hcl = uv_sc_iter->second;
|
||||
CGAL_assertion_msg(uv_hcl->size() == 1, "more than one constraint passing through the subconstraint" );
|
||||
if((uv_hcl->front().current())->vertex != u){
|
||||
if((uv_hcl->front().current())->vertex != u) {
|
||||
std::swap(u,w);
|
||||
uv_sc_iter = sc_to_c_map.find(make_edge(u, v));
|
||||
CGAL_assertion_msg( uv_sc_iter != sc_to_c_map.end(), "not a subconstraint" );
|
||||
|
|
@ -524,7 +523,8 @@ void Polyline_constraint_hierarchy_2<T,Data>::simplify(H_vertex_it uc,
|
|||
H_vertex_list* vertex_list = uv_hcl->front().id();
|
||||
CGAL_assertion_msg(vertex_list == vw_hcl->front().id(), "subconstraints from different polyline constraints" );
|
||||
// Remove the list item which points to v
|
||||
vc->removed = true;
|
||||
vertex_list->skip(vc);
|
||||
|
||||
// Remove the entries for [u,v] and [v,w]
|
||||
sc_to_c_map.erase(uv_sc_iter);
|
||||
sc_to_c_map.erase(vw_sc_iter);
|
||||
|
|
@ -539,7 +539,7 @@ int
|
|||
Polyline_constraint_hierarchy_2<T,Data>::remove_points_from_constraint(Constraint_id cid)
|
||||
{
|
||||
int n=0;
|
||||
for(H_all_it it = cid->begin(); it != cid->end(); ++it) {
|
||||
for(H_all_it it = cid->all_begin(); it != cid->all_end(); ++it) {
|
||||
if(cid->is_skipped(it)) {
|
||||
it = cid->erase(it);
|
||||
++n;
|
||||
|
|
|
|||
Loading…
Reference in New Issue