// ====================================================================== // // Copyright (c) 2001 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------- // // release : // release_date : // // file : include/CGAL/Splitting_rules.h // package : APSPAS // revision : 1.0 // revision_date : 2001/06/12 // maintainer : Hans Tangelder () // // ====================================================================== // Defines rules used for constructing a split node. That is, it implements, in several ways, the concept // Boxtree_splitter. #ifndef CGAL_SPLITTING_RULES_H #define CGAL_SPLITTING_RULES_H #include #include namespace CGAL { enum Split_rule {MEDIAN_OF_MAX_SPREAD, MEDIAN_OF_BOX, MIDPOINT_OF_MAX_SPREAD, MIDPOINT_OF_BOX, FAIR, SLIDING_MIDPOINT, SLIDING_FAIR}; enum Shrink_rule {NONE, SIMPLE, CENTROID}; template class Splitter { public: typedef typename P::FT NT; virtual void Rule(Points_container

& c, Plane_separator* sep) {} }; template class Median_Of_Max_Spread : public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c) { Plane_separator* sep = new Plane_separator(c.max_tight_span_coord(),0.0); sep->set_cutting_val(c.median(sep->cutting_dimension())); return sep; } }; template class Fair : public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c, NT Aspect_ratio) { // find legal cut with max spread Plane_separator* sep = new Plane_separator(c.max_tight_span_coord_balanced(Aspect_ratio),0.0); sep->set_cutting_val(c.balanced_fair(sep->cutting_dimension(),Aspect_ratio)); return sep; } }; template class Sliding_Fair : public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c, NT Aspect_ratio) { // find legal cut with max spread Plane_separator* sep = new Plane_separator(c.max_tight_span_coord_balanced(Aspect_ratio),0.0); sep->set_cutting_val(c.balanced_sliding_fair(sep->cutting_dimension(),Aspect_ratio)); return sep; } }; template class Sliding_MidPoint: public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c) { Plane_separator* sep = new Plane_separator(c.max_span_coord(), (c.max_span_upper() + c.max_span_lower())/2.0); NT max_span_lower = c.tight_bounding_box().lower(c.max_span_coord()); NT max_span_upper = c.tight_bounding_box().upper(c.max_span_coord()); if (max_span_upper <= sep->cutting_value()) { sep->set_cutting_val(max_span_upper); } if (max_span_lower >= sep->cutting_value()) { sep->set_cutting_val(max_span_lower); } return sep; } }; template class Median_Of_Box : public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c) { Plane_separator* sep = new Plane_separator(c.max_span_coord(),0.0); sep->set_cutting_val(c.median(sep->cutting_dimension())); return sep; } }; template class MidPoint_Of_Max_Spread : public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c) { Plane_separator* sep = new Plane_separator(c.max_tight_span_coord(), (c.max_tight_span_upper() + c.max_tight_span_lower())/2.0); return sep; } }; template class MidPoint_Of_Box: public Splitter

{ public: typedef typename P::FT NT; Plane_separator* Rule(Points_container

& c) { Plane_separator* sep = new Plane_separator(c.max_span_coord(), (c.max_span_upper() + c.max_span_lower())/2.0); return sep; } }; } // namespace CGAL #endif // CGAL_SPLITTING_RULES_H