mirror of https://github.com/CGAL/cgal
Merge pull request #1378 from sloriot/Polyline_simplification_2-handle_undefined_cost
Handle edges with undefined cost
This commit is contained in:
commit
3466dee055
|
|
@ -267,11 +267,17 @@ operator()()
|
||||||
if((*u)->is_removable()){
|
if((*u)->is_removable()){
|
||||||
boost::optional<FT> dist = cost(pct, u);
|
boost::optional<FT> dist = cost(pct, u);
|
||||||
if(! dist){
|
if(! dist){
|
||||||
std::cerr << "undefined cost not handled yet" << std::endl;
|
// cost is undefined
|
||||||
|
if( mpq->contains(u) ){
|
||||||
|
mpq->erase(u);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(*u)->set_cost(*dist);
|
(*u)->set_cost(*dist);
|
||||||
if((*mpq).contains(u)){
|
if(mpq->contains(u)){
|
||||||
(*mpq).update(u, true);
|
mpq->update(u, true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mpq->push(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -279,11 +285,17 @@ operator()()
|
||||||
if((*w)->is_removable()){
|
if((*w)->is_removable()){
|
||||||
boost::optional<FT> dist = cost(pct, w);
|
boost::optional<FT> dist = cost(pct, w);
|
||||||
if(! dist){
|
if(! dist){
|
||||||
std::cerr << "undefined cost not handled yet" << std::endl;
|
// cost is undefined
|
||||||
|
if( mpq->contains(w) ){
|
||||||
|
mpq->erase(w);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(*w)->set_cost(*dist);
|
(*w)->set_cost(*dist);
|
||||||
if((*mpq).contains(w)){
|
if(mpq->contains(w)){
|
||||||
(*mpq).update(w, true);
|
mpq->update(w, true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mpq->push(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,11 @@ typedef CGAL::Constrained_Delaunay_triangulation_2<K,TDS, Itag> CDT;
|
||||||
typedef CGAL::Constrained_triangulation_plus_2<CDT> CT;
|
typedef CGAL::Constrained_triangulation_plus_2<CDT> CT;
|
||||||
typedef CGAL::Polygon_2<K> Polygon_2;
|
typedef CGAL::Polygon_2<K> Polygon_2;
|
||||||
typedef PS::Stop_above_cost_threshold Stop;
|
typedef PS::Stop_above_cost_threshold Stop;
|
||||||
typedef PS::Squared_distance_cost Cost;
|
typedef PS::Squared_distance_cost Cost1;
|
||||||
|
typedef PS::Scaled_squared_distance_cost Cost2;
|
||||||
|
|
||||||
|
|
||||||
|
template <class Cost>
|
||||||
void test(char* fname)
|
void test(char* fname)
|
||||||
{
|
{
|
||||||
CGAL::Timer timer;
|
CGAL::Timer timer;
|
||||||
|
|
@ -45,7 +46,8 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
for(int i= 1;i < argc; i++){
|
for(int i= 1;i < argc; i++){
|
||||||
test(argv[i]);
|
test<Cost1>(argv[i]);
|
||||||
|
test<Cost2>(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ public:
|
||||||
handle update ( value_type const& v, handle h ) { mHeap.update(v); return h ; }
|
handle update ( value_type const& v, handle h ) { mHeap.update(v); return h ; }
|
||||||
|
|
||||||
handle erase ( value_type const& v, handle ) { mHeap.remove(v); return null_handle() ; }
|
handle erase ( value_type const& v, handle ) { mHeap.remove(v); return null_handle() ; }
|
||||||
|
handle erase ( value_type const& v ) { mHeap.remove(v); return null_handle() ; }
|
||||||
|
|
||||||
value_type top() const { return mHeap.top() ; }
|
value_type top() const { return mHeap.top() ; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue