📄 voronoi_vertex_sqrt_field_c2.h
字号:
} else if ( s1.is_segment() && s2.is_point() && s3.is_point() ) { compute_vertex(s2, s3, s1); pps_idx = 1; } else if ( s1.is_point() && s2.is_segment() && s3.is_point() ) { compute_vertex(s3, s1, s2); pps_idx = 2; } else if ( s1.is_point() && s2.is_point() && s3.is_segment() ) { compute_pps(s1, s2, s3); pps_idx = 0; } else if ( s1.is_point() && s2.is_segment() && s3.is_segment() ) { compute_pss(s1, s2, s3); } else if ( s1.is_segment() && s2.is_point() && s3.is_segment() ) { compute_vertex(s2, s3, s1); } else if ( s1.is_segment() && s2.is_segment() && s3.is_point() ) { compute_vertex(s3, s1, s2); } else { compute_sss(s1, s2, s3); } } //-------------------------------------------------------------------------- bool is_endpoint_of(const Site_2& p, const Site_2& s) const { CGAL_precondition( p.is_point() && s.is_segment() ); return ( same_points(p, s.source_site()) || same_points(p, s.target_site()) ); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // the incircle test //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // the incircle test when the fourth site is a point //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- Sign check_easy_degeneracies(const Site_2& t, PPS_Type, bool& use_result) const { CGAL_precondition( t.is_point() ); use_result = false; if ( ( p_.is_point() && same_points(p_, t) ) || ( q_.is_point() && same_points(q_, t) ) || ( r_.is_point() && same_points(r_, t) ) ) { use_result = true; return ZERO; } if ( ( p_.is_segment() && is_endpoint_of(t, p_) ) || ( q_.is_segment() && is_endpoint_of(t, q_) ) || ( r_.is_segment() && is_endpoint_of(t, r_) ) ) { use_result = true; return POSITIVE; } return ZERO; } Sign check_easy_degeneracies(const Site_2& t, PSS_Type, bool& use_result) const { CGAL_precondition( t.is_point() ); return check_easy_degeneracies(t, PPS_Type(), use_result); } Sign check_easy_degeneracies(const Site_2& t, SSS_Type, bool& use_result) const { CGAL_precondition( t.is_point() ); use_result = false; // ADD THE CASES WHERE t IS AN ENDPOINT OF ONE OF THE SEGMENTS return ZERO; } //-------------------------------------------------------------------------- Sign incircle_p(const Site_2& st, PPP_Type) const { CGAL_precondition( st.is_point() ); Point_2 t = st.point(); Oriented_side os = side_of_oriented_circle(p_.point(), q_.point(), r_.point(), t); if ( os == ON_POSITIVE_SIDE ) { return NEGATIVE; } if ( os == ON_NEGATIVE_SIDE ) { return POSITIVE; } return ZERO; } //-------------------------------------------------------------------------- template<class Type> inline Sign incircle_p(const Site_2& st, Type type) const { CGAL_precondition( st.is_point() ); bool use_result(false); Sign s = check_easy_degeneracies(st, type, use_result); if ( use_result ) { return s; } return incircle_p_no_easy(st, type); } template<class Type> Sign incircle_p_no_easy(const Site_2& st, Type) const { CGAL_precondition( st.is_point() ); FT r2 = squared_radius(); Point_2 t = st.point(); FT d2 = CGAL::square(x() - t.x()) + CGAL::square(y() - t.y());#ifdef CGAL_CFG_NO_OPERATOR_TIMES_FOR_SIGN return CGAL::Sign( (CGAL::Comparison_result) CGAL::compare(d2, r2) );#else return CGAL::compare(d2, r2);#endif } //-------------------------------------------------------------------------- Sign incircle_p(const Site_2& t) const { if ( is_degenerate_Voronoi_circle() ) { return POSITIVE; } Sign s(ZERO); switch ( v_type ) { case PPP: s = incircle_p(t, PPP_Type()); break; case PPS: s = incircle_p(t, PPS_Type()); break; case PSS: s = incircle_p(t, PSS_Type()); break; case SSS: s = incircle_p(t, SSS_Type()); break; } return s; } Sign incircle_p_no_easy(const Site_2& t) const { Sign s(ZERO); switch ( v_type ) { case PPP: s = incircle_p(t, PPP_Type()); break; case PPS: s = incircle_p_no_easy(t, PPS_Type()); break; case PSS: s = incircle_p_no_easy(t, PSS_Type()); break; case SSS: s = incircle_p_no_easy(t, SSS_Type()); break; } return s; } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // the incircle test when the fourth site is a segment //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- Oriented_side oriented_side(const Line_2& l, const Point_2& p) const { Line_2 l1(l.b(), -l.a(), l.a() * y() - l.b() * x()); return oriented_side_of_line(l1, p); } Sign incircle(const Line_2& l) const { FT r2 = squared_radius(); FT n2 = CGAL::square(l.a()) + CGAL::square(l.b()); FT d2 = CGAL::square(l.a() * x() + l.b() * y() + l.c());#ifdef CGAL_CFG_NO_OPERATOR_TIMES_FOR_SIGN return CGAL::Sign( (CGAL::Comparison_result) CGAL::compare(d2, r2 * n2) );#else return CGAL::compare(d2, r2 * n2);#endif } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- Sign incircle_s(const Site_2& t, int i) const { CGAL_precondition( t.is_segment() ); if ( v_type == PPP || v_type == PPS ) { if ( p_.is_point() && q_.is_point() && is_endpoint_of(p_, t) && is_endpoint_of(q_, t) ) { return NEGATIVE; } if ( p_.is_point() && r_.is_point() && is_endpoint_of(p_, t) && is_endpoint_of(r_, t) ){ return NEGATIVE; } if ( q_.is_point() && r_.is_point() && is_endpoint_of(q_, t) && is_endpoint_of(r_, t) ){ return NEGATIVE; } } if ( v_type == PSS ) { if ( p_.is_segment() && same_segments(p_.supporting_site(), t.supporting_site()) ) { return POSITIVE; } if ( q_.is_segment() && same_segments(q_.supporting_site(), t.supporting_site()) ) { return POSITIVE; } if ( r_.is_segment() && same_segments(r_.supporting_site(), t.supporting_site()) ) { return POSITIVE; } } return incircle_s_no_easy(t, i); } Sign incircle_s_no_easy(const Site_2& t, int) const { Sign d1, d2; if ( ( p_.is_point() && same_points(p_, t.source_site()) ) || ( q_.is_point() && same_points(q_, t.source_site()) ) || ( r_.is_point() && same_points(r_, t.source_site()) ) ) { d1 = ZERO; } else { d1 = incircle_p(t.source_site()); } if ( d1 == NEGATIVE ) { return NEGATIVE; } if ( ( p_.is_point() && same_points(p_, t.target_site()) ) || ( q_.is_point() && same_points(q_, t.target_site()) ) || ( r_.is_point() && same_points(r_, t.target_site()) ) ) { d2 = ZERO; } else { d2 = incircle_p(t.target_site()); } if ( d2 == NEGATIVE ) { return NEGATIVE; } Line_2 l = compute_supporting_line(t.supporting_site()); Sign sl = incircle(l); if ( sl == POSITIVE ) { return sl; } if ( sl == ZERO && (d1 == ZERO || d2 == ZERO) ) { return ZERO; } Oriented_side os1 = oriented_side(l, t.source()); Oriented_side os2 = oriented_side(l, t.target()); if ( sl == ZERO ) { if (os1 == ON_ORIENTED_BOUNDARY || os2 == ON_ORIENTED_BOUNDARY) { return ZERO; } return ( os1 == os2 ) ? POSITIVE : ZERO; } return (os1 == os2) ? POSITIVE : NEGATIVE; } //-------------------------------------------------------------------------- Sign incircle_s(const Site_2& t) const { CGAL_precondition( t.is_segment() ); if ( is_degenerate_Voronoi_circle() ) { // case 1: the new segment is not adjacent to the center of the // degenerate Voronoi circle if ( !same_points( p_ref(), t.source_site() ) && !same_points( p_ref(), t.target_site() ) ) { return POSITIVE; } CGAL_assertion( v_type == PSS ); if ( p_.is_segment() && same_segments(p_.supporting_site(), t.supporting_site()) ) { return ZERO; } if ( q_.is_segment() && same_segments(q_.supporting_site(), t.supporting_site()) ) { return ZERO; } if ( r_.is_segment() && same_segments(r_.supporting_site(), t.supporting_site()) ) { return ZERO; } Site_2 pr; Site_2 sp, sq; if ( p_.is_point() ) { CGAL_assertion( q_.is_segment() && r_.is_segment() ); pr = p_; sp = q_; sq = r_; } else if ( q_.is_point() ) { CGAL_assertion( r_.is_segment() && p_.is_segment() ); pr = q_; sp = r_; sq = p_; } else { CGAL_assertion( p_.is_segment() && q_.is_segment() ); pr = r_; sp = p_; sq = q_; } Point_2 pq = sq.source(), pp = sp.source(), pt = t.source(); if ( same_points(sp.source_site(), pr) ) { pp = sp.target(); } if ( same_points(sq.source_site(), pr) ) { pq = sq.target(); } if ( same_points( t.source_site(), pr) ) { pt = t.target(); } Point_2 pr_ = pr.point(); if ( CGAL::orientation(pr_, pp, pt) == LEFT_TURN && CGAL::orientation(pr_, pq, pt) == RIGHT_TURN ) { return NEGATIVE; } return ZERO; } // if ( is_degenerate_Voronoi_circle() ) Sign s = incircle_s(t, 0); return s; } inline Sign incircle_s_no_easy(const Site_2& t) const { return incircle_s_no_easy(t, 0); } //-------------------------------------------------------------------------- // subpredicates for the incircle test //--------------------------------------------------------------------------public: bool is_degenerate_Voronoi_circle() const { if ( v_type != PSS ) { return false; } if ( p_.is_point() ) { return ( is_endpoint_of(p_, q_) && is_endpoint_of(p_, r_) ); } else if ( q_.is_point() ) { return ( is_endpoint_of(q_, p_) && is_endpoint_of(q_, r_) ); } else { CGAL_assertion( r_.is_point() ); return ( is_endpoint_of(r_, p_) && is_endpoint_of(r_, q_) ); } } //--------------------------------------------------------------------------private: //-------------------------------------------------------------------------- // the reference point (valid if v_type != SSS) //-------------------------------------------------------------------------- Site_2 p_ref() const { CGAL_precondition ( v_type != SSS ); if ( v_type == PPS ) { if ( pps_idx == 0 ) { return p_; } if ( pps_idx == 1 ) { return q_; } return r_; } if ( p_.is_point() ) { return p_; } else if ( q_.is_point() ) { return q_; } else { CGAL_assertion( r_.is_point() ); return r_; } }public: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // access methods //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- FT x() const { return hx() / hw(); } FT y() const { return hy() / hw(); } FT hx() const { return ux; } FT hy() const { return uy; } FT hw() const { return uz; } FT squared_radius() const { switch (v_type) { case PPP: case PPS: case PSS: { Point_2 pref = p_ref().point(); FT dx2 = CGAL::square(x() - pref.x()); FT dy2 = CGAL::square(y() - pref.y()); return dx2 + dy2; } case SSS: { Line_2 l = compute_supporting_line(p_.supporting_site()); Homogeneous_point_2 q = compute_projection(l, point()); FT dx2 = CGAL::square(x() - q.x()); FT dy2 = CGAL::square(y() - q.y()); return dx2 + dy2; } default: return FT(0); } } Point_2 point() const { if ( is_degenerate_Voronoi_circle() ) { return degenerate_point(); } return Point_2(x(), y()); } Point_2 degenerate_point() const { CGAL_precondition( is_degenerate_Voronoi_circle() ); return p_ref().point(); } typename K::Circle_2 circle() const { typedef typename K::Circle_2 K_Circle_2; return K_Circle_2(point(), squared_radius()); } vertex_t type() const { return v_type; }public: Voronoi_vertex_sqrt_field_C2(const Site_2& p, const Site_2& q, const Site_2& r) : p_(p), q_(q), r_(r) { compute_vertex(p, q, r); } //-------------------------------------------------------------------------- Sign incircle(const Site_2& t) const { if ( t.is_point() ) { return incircle_p(t); } return incircle_s(t); } Sign incircle_no_easy(const Site_2& t) const { Sign s; if ( t.is_point() ) { s = incircle_p_no_easy(t); } else { s = incircle_s_no_easy(t); } return s; } //-------------------------------------------------------------------------- Orientation orientation(const Line_2& l) const { Sign s = CGAL::sign(l.a() * x() + l.b() * y() + l.c()); if ( s == ZERO ) { return COLLINEAR; } return ( s == POSITIVE ) ? LEFT_TURN : RIGHT_TURN; } Oriented_side oriented_side(const Line_2& l) const { Orientation o = orientation(l); if ( o == COLLINEAR ) { return ON_ORIENTED_BOUNDARY; } return ( o == LEFT_TURN ) ? ON_POSITIVE_SIDE : ON_NEGATIVE_SIDE; } //--------------------------------------------------------------------------private: const Site_2& p_, q_, r_; vertex_t v_type; // index that indicates the refence point for the case PPS short pps_idx; FT ux, uy, uz;};CGAL_SEGMENT_DELAUNAY_GRAPH_2_END_NAMESPACECGAL_END_NAMESPACE#endif // CGAL_SEGMENT_DELAUNAY_GRAPH_2_VORONOI_VEFTEX_SQRT_FIELD_C2_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -