Add a basic visitor to AW3

This commit is contained in:
Mael Rouxel-Labbé 2022-06-08 12:04:02 +02:00
parent 37390bb6b8
commit beeae185a7
1 changed files with 24 additions and 2 deletions

View File

@ -103,13 +103,26 @@ struct Wrapping_default_visitor
{ {
Wrapping_default_visitor() { } Wrapping_default_visitor() { }
template <typename AlphaWrapper>
void on_alpha_wrapping_begin(const AlphaWrapper&) { }
template <typename AlphaWrapper>
void on_flood_fill_begin(const AlphaWrapper&) { }
template <typename AlphaWrapper, typename Gate>
void before_facet_treatment(const AlphaWrapper&, const Gate&) { }
template <typename Wrapper, typename Point> template <typename Wrapper, typename Point>
void before_Steiner_point_insertion(const Wrapper&, const Point&) { } void before_Steiner_point_insertion(const Wrapper&, const Point&) { }
template <typename Wrapper, typename VertexHandle> template <typename Wrapper, typename VertexHandle>
void after_Steiner_point_insertion(const Wrapper&, VertexHandle) { } void after_Steiner_point_insertion(const Wrapper&, VertexHandle) { }
void after_alpha_wrapping() { } template <typename AlphaWrapper>
void on_flood_fill_end(const AlphaWrapper&) { }
template <typename AlphaWrapper>
void on_alpha_wrapping_end(const AlphaWrapper&) { };
}; };
template <typename Oracle> template <typename Oracle>
@ -187,6 +200,7 @@ public:
const Geom_traits& geom_traits() const { return m_dt.geom_traits(); } const Geom_traits& geom_traits() const { return m_dt.geom_traits(); }
Dt& triangulation() { return m_dt; } Dt& triangulation() { return m_dt; }
const Dt& triangulation() const { return m_dt; } const Dt& triangulation() const { return m_dt; }
const Alpha_PQ& queue() const { return m_queue; }
double default_alpha() const double default_alpha() const
{ {
@ -252,6 +266,8 @@ public:
t.start(); t.start();
#endif #endif
visitor.on_alpha_wrapping_begin(*this);
if(!initialize(alpha, offset, seeds)) if(!initialize(alpha, offset, seeds))
return; return;
@ -340,7 +356,7 @@ public:
#endif #endif
#endif #endif
visitor.after_alpha_wrapping(); visitor.on_alpha_wrapping_end(*this);
} }
// Convenience overloads // Convenience overloads
@ -1029,6 +1045,8 @@ private:
std::cout << "> Flood fill..." << std::endl; std::cout << "> Flood fill..." << std::endl;
#endif #endif
visitor.on_flood_fill_begin(*this);
// Explore all finite cells that are reachable from one of the initial outside cells. // Explore all finite cells that are reachable from one of the initial outside cells.
while(!m_queue.empty()) while(!m_queue.empty())
{ {
@ -1055,6 +1073,8 @@ private:
std::cout << "Priority: " << gate.priority() << std::endl; std::cout << "Priority: " << gate.priority() << std::endl;
#endif #endif
visitor.before_facet_treatment(*this, gate);
m_queue.pop(); m_queue.pop();
#ifdef CGAL_AW3_DEBUG_DUMP_EVERY_STEP #ifdef CGAL_AW3_DEBUG_DUMP_EVERY_STEP
@ -1170,6 +1190,8 @@ private:
} }
} // while(!queue.empty()) } // while(!queue.empty())
visitor.on_flood_fill_end(*this);
// Check that no useful facet has been ignored // Check that no useful facet has been ignored
CGAL_postcondition_code(for(auto fit=m_dt.finite_facets_begin(), fend=m_dt.finite_facets_end(); fit!=fend; ++fit) {) CGAL_postcondition_code(for(auto fit=m_dt.finite_facets_begin(), fend=m_dt.finite_facets_end(); fit!=fend; ++fit) {)
CGAL_postcondition_code( if(fit->first->info().is_outside == fit->first->neighbor(fit->second)->info().is_outside) continue;) CGAL_postcondition_code( if(fit->first->info().is_outside == fit->first->neighbor(fit->second)->info().is_outside) continue;)