📄 overlay_meta_traits.h
字号:
if (overlap_cv != NULL) { Halfedge_handle_red red_he; Halfedge_handle_blue blue_he; if(cv1.get_color() == Curve_info::RED) { red_he = cv1.get_red_halfedge_handle(); // overlap can occur only between curves from a different color CGAL_assertion(cv2.get_color() == Curve_info::BLUE); blue_he = cv2.get_blue_halfedge_handle(); } else { CGAL_assertion(cv1.get_color() == Curve_info::BLUE && cv2.get_color() == Curve_info::RED); red_he = cv2.get_red_halfedge_handle(); blue_he = cv1.get_blue_halfedge_handle(); } *oi = CGAL::make_object (X_monotone_curve_2 (*overlap_cv, red_he, blue_he)); } } } //return past-end iterator return oi_end; } }; /*! Get an Intersect_2 functor object. */ Intersect_2 intersect_2_object () const { return Intersect_2(m_base_traits); } class Split_2 { private: Base_Split_2 m_base_split; public: /*! Constructor. */ Split_2 (const Base_Split_2& base) : m_base_split (base) {} void operator() (const X_monotone_curve_2& cv, const Point_2 & p, X_monotone_curve_2& c1, X_monotone_curve_2& c2) { m_base_split(cv.base_curve(), p.base_point(), c1.base_curve(), c2.base_curve()); c1.set_curve_info(cv.get_curve_info()); c2.set_curve_info(cv.get_curve_info()); } }; /*! Get a Split_2 functor object. */ Split_2 split_2_object () const { return Split_2(m_base_traits->split_2_object()); } class Construct_min_vertex_2 { private: Base_Construct_min_vertex_2 m_base_min_v; Base_Equal_2 m_base_equal; public: Construct_min_vertex_2 (const Base_Construct_min_vertex_2& base_min_v, const Base_Equal_2& base_equal): m_base_min_v (base_min_v), m_base_equal (base_equal) {} /*! * Get the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ Point_2 operator() (const X_monotone_curve_2 & cv) { const Base_Point_2& base_p = m_base_min_v (cv.base_curve()); Object red, blue; if(cv.get_color() == Curve_info::RED) { red = CGAL::make_object(cv.get_red_halfedge_handle()->target()); } else if(cv.get_color() == Curve_info::BLUE) { blue = CGAL::make_object(cv.get_blue_halfedge_handle()->target()); } else { CGAL_assertion(cv.get_color() == Curve_info::PURPLE); if (! cv.get_red_halfedge_handle()->target()->is_at_infinity() && m_base_equal (base_p, cv.get_red_halfedge_handle()->target()->point())) { red = CGAL::make_object(cv.get_red_halfedge_handle()->target()); } if (! cv.get_blue_halfedge_handle()->target()->is_at_infinity() && m_base_equal (base_p, cv.get_blue_halfedge_handle()->target()->point())) { blue = CGAL::make_object(cv.get_blue_halfedge_handle()->target()); } } return (Point_2 (base_p, red, blue)); } }; /*! Get a Construct_min_vertex_2 functor object. */ Construct_min_vertex_2 construct_min_vertex_2_object () const { return (Construct_min_vertex_2 (m_base_traits->construct_min_vertex_2_object(), m_base_traits->equal_2_object())); } class Construct_max_vertex_2 { private: Base_Construct_max_vertex_2 m_base_max_v; Base_Equal_2 m_base_equal; public: Construct_max_vertex_2 (const Base_Construct_max_vertex_2& base_max_v, const Base_Equal_2& base_equal): m_base_max_v (base_max_v), m_base_equal (base_equal) {} /*! * Get the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ Point_2 operator() (const X_monotone_curve_2 & cv) const { const Base_Point_2& base_p = m_base_max_v (cv.base_curve()); Object red, blue; if(cv.get_color() == Curve_info::RED) { red = CGAL::make_object(cv.get_red_halfedge_handle()->source()); } else if(cv.get_color() == Curve_info::BLUE) { blue = CGAL::make_object(cv.get_blue_halfedge_handle()->source()); } else { CGAL_assertion(cv.get_color() == Curve_info::PURPLE); if (! cv.get_red_halfedge_handle()->source()->is_at_infinity() && m_base_equal (base_p, cv.get_red_halfedge_handle()->source()->point())) { red = CGAL::make_object(cv.get_red_halfedge_handle()->source()); } if (! cv.get_blue_halfedge_handle()->source()->is_at_infinity() && m_base_equal (base_p, cv.get_blue_halfedge_handle()->source()->point())) { blue = CGAL::make_object(cv.get_blue_halfedge_handle()->source()); } } return (Point_2 (base_p, red, blue)); } }; /*! Get a Construct_min_vertex_2 functor object. */ Construct_max_vertex_2 construct_max_vertex_2_object () const { return (Construct_max_vertex_2 (m_base_traits->construct_max_vertex_2_object(), m_base_traits->equal_2_object())); } class Compare_xy_2 { private: Base_Compare_xy_2 m_base_cmp_xy; public: Compare_xy_2(const Base_Compare_xy_2& base): m_base_cmp_xy(base) {} /*! * Get the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ Comparison_result operator() (const Point_2& p1, const Point_2& p2) const { Vertex_handle_red vr1; Vertex_handle_red vr2; Vertex_handle_blue vb1; Vertex_handle_blue vb2; bool did_assign_v1_red = assign(vr1, p1.get_red_object()); bool did_assign_v2_red = assign(vr2, p2.get_red_object()); bool did_assign_v1_blue = assign(vb1, p1.get_blue_object()); bool did_assign_v2_blue = assign(vb2, p2.get_blue_object()); if((did_assign_v1_red && did_assign_v1_blue) || (did_assign_v2_red && did_assign_v2_blue)) return (m_base_cmp_xy(p1.base_point(), p2.base_point())); if(did_assign_v1_red && did_assign_v2_red) { if(vr1 == vr2) return EQUAL; return (m_base_cmp_xy(p1.base_point(), p2.base_point())); } if(did_assign_v1_blue && did_assign_v2_blue) { if(vb1 == vb2) return EQUAL; return (m_base_cmp_xy(p1.base_point(), p2.base_point())); } return (m_base_cmp_xy(p1.base_point(), p2.base_point())); } }; /*! Get a Construct_min_vertex_2 functor object. */ Compare_xy_2 compare_xy_2_object () const { return Compare_xy_2(m_base_traits->compare_xy_2_object()); } /*! \class * The Comapre_x_2 functor. */ class Compare_x_2 { private: Base_Compare_x_2 m_base_cmp_x; public: Compare_x_2(const Base_Compare_x_2& base): m_base_cmp_x(base) {} Comparison_result operator() (const Point_2& p1, const Point_2& p2) const { return (m_base_cmp_x(p1.base_point(), p2.base_point())); } Comparison_result operator() (const Point_2& p, const X_monotone_curve_2& cv, Curve_end ind) const { return (_compare_point_curve_imp (p, cv, ind, Base_has_boundary_category())); } Comparison_result operator() (const X_monotone_curve_2& cv1, Curve_end ind1, const X_monotone_curve_2& cv2, Curve_end ind2) const { return (_compare_curves_imp (cv1, ind1, cv2, ind2, Base_has_boundary_category())); } private: Comparison_result _compare_point_curve_imp (const Point_2& p, const X_monotone_curve_2& cv, Curve_end ind, Tag_true) const { return (m_base_cmp_x (p.base_point(), cv.base_curve(), ind)); } Comparison_result _compare_point_curve_imp (const Point_2& , const X_monotone_curve_2& , Curve_end , Tag_false) const { return (EQUAL); } Comparison_result _compare_curves_imp (const X_monotone_curve_2& cv1, Curve_end ind1, const X_monotone_curve_2& cv2, Curve_end ind2, Tag_true) const { return (m_base_cmp_x (cv1.base_curve(), ind1, cv2.base_curve(), ind2)); } Comparison_result _compare_curves_imp (const X_monotone_curve_2& , Curve_end, const X_monotone_curve_2& , Curve_end ind2, Tag_false) const { return (EQUAL); } }; Compare_x_2 compare_x_2_object () const { return (Compare_x_2 (m_base_traits->compare_x_2_object())); } class Compare_y_at_x_2 { private: Base_Compare_y_at_x_2 m_base_cmp_y_at_x; public: Compare_y_at_x_2(const Base_Compare_y_at_x_2& base): m_base_cmp_y_at_x(base) {} /*! * Get the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ Comparison_result operator() (const Point_2 & p, const X_monotone_curve_2 & cv) const { return (m_base_cmp_y_at_x(p.base_point(), cv.base_curve())); } Comparison_result operator() (const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2, Curve_end ind) const { // The function is implemented based on the Has_infinite category. // If the traits class does not support unbounded curves, we just // return EQUAL, as this comparison will not be invoked anyway. return _comp_y_at_infinity_imp (cv1, cv2, ind, Base_has_boundary_category()); } private: Comparison_result _comp_y_at_infinity_imp (const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2, Curve_end ind, Tag_true) const { return (m_base_cmp_y_at_x (cv1.base_curve(), cv2.base_curve(), ind)); } Comparison_result _comp_y_at_infinity_imp (const X_monotone_curve_2& , const X_monotone_curve_2& , Curve_end , Tag_false) const { return (EQUAL); } }; /*! Get a Construct_min_vertex_2 functor object. */ Compare_y_at_x_2 compare_y_at_x_2_object () const { return Compare_y_at_x_2(m_base_traits->compare_y_at_x_2_object()); } class Compare_y_at_x_right_2 { private: Base_Compare_y_at_x_right_2 m_base_cmp_y_at_x_right; public: Compare_y_at_x_right_2(const Base_Compare_y_at_x_right_2& base): m_base_cmp_y_at_x_right(base) {} /*! * Get the left endpoint of the x-monotone curve (segment). * \param cv The curve. * \return The left endpoint. */ Comparison_result operator() (const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2, const Point_2& p) const { return (m_base_cmp_y_at_x_right(cv1.base_curve(), cv2.base_curve(), p.base_point())); } }; /*! Get a Construct_min_vertex_2 functor object. */ Compare_y_at_x_right_2 compare_y_at_x_right_2_object () const { return Compare_y_at_x_right_2(m_base_traits->compare_y_at_x_right_2_object()); } bool are_same_color(const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2) const { return (cv1.get_color() == cv2.get_color()); } class Boundary_in_x_2 { public: Boundary_type operator() (const X_monotone_curve_2& cv, Curve_end ind) const { return _boundary_in_x_imp(cv, ind, Base_has_boundary_category()); } private: Boundary_type _boundary_in_x_imp(const X_monotone_curve_2& cv, Curve_end ind, Tag_true) const { Traits tr; return (tr.boundary_in_x_2_object() (cv.base_curve(), ind)); } Boundary_type _boundary_in_x_imp(const X_monotone_curve_2& , Curve_end , Tag_false) const { return NO_BOUNDARY; } }; /*! Get an Boundary_in_x_2 functor object. */ Boundary_in_x_2 boundary_in_x_2_object () const { return Boundary_in_x_2(); } class Boundary_in_y_2 { public: Boundary_type operator() (const X_monotone_curve_2& cv, Curve_end ind) const { return _boundary_in_y_imp(cv, ind, Base_has_boundary_category()); } private: Boundary_type _boundary_in_y_imp(const X_monotone_curve_2& cv, Curve_end ind, Tag_true) const { Traits tr; return (tr.boundary_in_y_2_object() (cv.base_curve(), ind)); } Boundary_type _boundary_in_y_imp(const X_monotone_curve_2& , Curve_end , Tag_false) const { return NO_BOUNDARY; } }; /*! Get an Boundary_in_x_2 functor object. */ Boundary_in_y_2 boundary_in_y_2_object () const { return Boundary_in_y_2(); } };CGAL_END_NAMESPACE#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -