mirror of https://github.com/CGAL/cgal
Adapt csq_dist P_T and T_T for Uncertain_result
This commit is contained in:
parent
6dedfe8858
commit
042e2ad862
|
|
@ -164,6 +164,10 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
average_length/=(3*input_triangles.size());
|
average_length/=(3*input_triangles.size());
|
||||||
|
|
||||||
|
std::cout << "Simple_Cartesian<double>" << std::endl;
|
||||||
|
Test<CGAL::Simple_cartesian<double> >().run(filename, average_length*average_length/256);
|
||||||
|
Test<CGAL::Simple_cartesian<double> >().run(filename, min_sq_length*4);
|
||||||
|
|
||||||
// Equivalent to EPECK since there are only predicates
|
// Equivalent to EPECK since there are only predicates
|
||||||
// Test<CGAL::Exact_predicates_inexact_constructions_kernel>().run(filename, 100*max/input_points.size());
|
// Test<CGAL::Exact_predicates_inexact_constructions_kernel>().run(filename, 100*max/input_points.size());
|
||||||
// std::cout << "EPICK" << std::endl;
|
// std::cout << "EPICK" << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ compare_squared_distance_to_triangle(const typename K::Point_3& pt,
|
||||||
// Note that in the degenerate case, at most 2 edges cover the full triangle,
|
// Note that in the degenerate case, at most 2 edges cover the full triangle,
|
||||||
// and only two distances could be used
|
// and only two distances could be used
|
||||||
typename K::Comparison_result res1 = csq_dist(pt, segment(t2, t0), d2);
|
typename K::Comparison_result res1 = csq_dist(pt, segment(t2, t0), d2);
|
||||||
if(is_certain(res1) && (res1 == SMALLER))
|
if(certainly(res1 == SMALLER))
|
||||||
return SMALLER;
|
return SMALLER;
|
||||||
typename K::Comparison_result res2 = csq_dist(pt, segment(t1, t2), d2);
|
typename K::Comparison_result res2 = csq_dist(pt, segment(t1, t2), d2);
|
||||||
return smaller_of(res1,res2);
|
return smaller_of(res1,res2);
|
||||||
|
|
@ -334,7 +334,7 @@ compare_squared_distance_to_triangle(const typename K::Point_3& pt,
|
||||||
|
|
||||||
// Compare first the distance to the plane, if larger we can exit early
|
// Compare first the distance to the plane, if larger we can exit early
|
||||||
typename K::Comparison_result res_p_pl = compare(squared_distance_to_plane(normal, vector(t0, pt), k), d2);
|
typename K::Comparison_result res_p_pl = compare(squared_distance_to_plane(normal, vector(t0, pt), k), d2);
|
||||||
if(is_certain(res_p_pl) && res_p_pl==LARGER)
|
if(certainly(res_p_pl==LARGER))
|
||||||
{
|
{
|
||||||
inside_or_far_to_the_plane=true;
|
inside_or_far_to_the_plane=true;
|
||||||
return LARGER;
|
return LARGER;
|
||||||
|
|
@ -344,7 +344,7 @@ compare_squared_distance_to_triangle(const typename K::Point_3& pt,
|
||||||
if(!on_left_of_triangle_edge(pt, normal, t0, t1, k))
|
if(!on_left_of_triangle_edge(pt, normal, t0, t1, k))
|
||||||
{
|
{
|
||||||
typename K::Comparison_result res_p_s1 = csq_dist(pt, segment(t0, t1), d2);
|
typename K::Comparison_result res_p_s1 = csq_dist(pt, segment(t0, t1), d2);
|
||||||
if(res_p_s1==SMALLER)
|
if(certainly(res_p_s1==SMALLER))
|
||||||
return SMALLER;
|
return SMALLER;
|
||||||
if(!on_left_of_triangle_edge(pt, normal, t1, t2, k))
|
if(!on_left_of_triangle_edge(pt, normal, t1, t2, k))
|
||||||
{
|
{
|
||||||
|
|
@ -370,7 +370,7 @@ compare_squared_distance_to_triangle(const typename K::Point_3& pt,
|
||||||
if(!on_left_of_triangle_edge(pt, normal, t1, t2, k))
|
if(!on_left_of_triangle_edge(pt, normal, t1, t2, k))
|
||||||
{
|
{
|
||||||
typename K::Comparison_result res_p_s2 = csq_dist(pt, segment(t1, t2), d2);
|
typename K::Comparison_result res_p_s2 = csq_dist(pt, segment(t1, t2), d2);
|
||||||
if(res_p_s2 == SMALLER)
|
if(certainly(res_p_s2 == SMALLER))
|
||||||
return SMALLER;
|
return SMALLER;
|
||||||
if(!on_left_of_triangle_edge(pt, normal, t2, t0, k))
|
if(!on_left_of_triangle_edge(pt, normal, t2, t0, k))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ squared_distance(const typename K::Segment_3& seg,
|
||||||
const Point_3& ss = seg.source();
|
const Point_3& ss = seg.source();
|
||||||
const Point_3& se = seg.target();
|
const Point_3& se = seg.target();
|
||||||
|
|
||||||
//TODO Me semble vachement compliqué pour un truc si simple, est-ce que y'a pas moyen de s'inspirer de Lumelsky pour segment segment
|
//TODO This seems complicated compared to Segment_3_Segment_3.h. Consider improving by adapting Lumelsky's method for segment-segment intersection.
|
||||||
|
|
||||||
if(ss == se)
|
if(ss == se)
|
||||||
return sq_dist(ss, ray);
|
return sq_dist(ss, ray);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ squared_distance(const typename K::Segment_3& s1,
|
||||||
CGAL_assertion(a > 0 && d < 0);
|
CGAL_assertion(a > 0 && d < 0);
|
||||||
|
|
||||||
const FT det = a*d - b*c;
|
const FT det = a*d - b*c;
|
||||||
if(det == 0)
|
if(is_zero(det))
|
||||||
res.x = 0;
|
res.x = 0;
|
||||||
else
|
else
|
||||||
res.x = boost::algorithm::clamp<FT>((e*d - b*f) / det, 0, 1);
|
res.x = boost::algorithm::clamp<FT>((e*d - b*f) / det, 0, 1);
|
||||||
|
|
@ -209,7 +209,7 @@ compare_squared_distance(const typename K::Segment_3& s1,
|
||||||
/* The content of this function is very similar with the one above, the difference is we can exit earlier if
|
/* The content of this function is very similar with the one above, the difference is we can exit earlier if
|
||||||
the supporting line are farther than d since we do not need the exact distance. */
|
the supporting line are farther than d since we do not need the exact distance. */
|
||||||
|
|
||||||
|
#if 1
|
||||||
const Point_3& p1 = vertex(s1, 0);
|
const Point_3& p1 = vertex(s1, 0);
|
||||||
const Point_3& q1 = vertex(s1, 1);
|
const Point_3& q1 = vertex(s1, 1);
|
||||||
const Point_3& p2 = vertex(s2, 0);
|
const Point_3& p2 = vertex(s2, 0);
|
||||||
|
|
@ -231,7 +231,7 @@ compare_squared_distance(const typename K::Segment_3& s1,
|
||||||
|
|
||||||
// Compare first the distance between the lines, if larger we can exit early
|
// Compare first the distance between the lines, if larger we can exit early
|
||||||
typename K::Comparison_result res_ll=csq_dist(s1.supporting_line(), s2.supporting_line(), d2);
|
typename K::Comparison_result res_ll=csq_dist(s1.supporting_line(), s2.supporting_line(), d2);
|
||||||
if(is_certain(res_ll) && res_ll==LARGER)
|
if(certainly(res_ll==LARGER))
|
||||||
return LARGER;
|
return LARGER;
|
||||||
|
|
||||||
// Compute the distance between the segments
|
// Compute the distance between the segments
|
||||||
|
|
@ -247,7 +247,7 @@ compare_squared_distance(const typename K::Segment_3& s1,
|
||||||
CGAL_assertion(a > 0 && d < 0);
|
CGAL_assertion(a > 0 && d < 0);
|
||||||
const FT det = a*d - b*c;
|
const FT det = a*d - b*c;
|
||||||
FT res_x;
|
FT res_x;
|
||||||
if(det == 0)
|
if(is_zero(det))
|
||||||
res_x = 0;
|
res_x = 0;
|
||||||
else
|
else
|
||||||
res_x = boost::algorithm::clamp<FT>((e*d - b*f) / det, 0, 1);
|
res_x = boost::algorithm::clamp<FT>((e*d - b*f) / det, 0, 1);
|
||||||
|
|
@ -280,6 +280,10 @@ compare_squared_distance(const typename K::Segment_3& s1,
|
||||||
return res_ll;
|
return res_ll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Faster with Simple_cartesian<double>, a bit slower with EPICK or EPECK specifically if d2 is small
|
||||||
|
return compare(squared_distance(s1, s2 ,k), d2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
||||||
|
|
@ -237,19 +237,19 @@ compare_squared_distance_disjoint(const typename K::Triangle_3& tr1,
|
||||||
for(int j=0; j<3; ++j)
|
for(int j=0; j<3; ++j)
|
||||||
{
|
{
|
||||||
typename K::Comparison_result temp_res_ss=csq_dist(Segment_3(vertex(tr1, i%3), vertex(tr1, (i+1)%3)),Segment_3(vertex(tr2, j%3), vertex(tr2, (j+1)%3)),d2);
|
typename K::Comparison_result temp_res_ss=csq_dist(Segment_3(vertex(tr1, i%3), vertex(tr1, (i+1)%3)),Segment_3(vertex(tr2, j%3), vertex(tr2, (j+1)%3)),d2);
|
||||||
if(temp_res_ss==SMALLER)
|
if(certainly(temp_res_ss==SMALLER))
|
||||||
return SMALLER;
|
return SMALLER;
|
||||||
res=smaller_of(res, temp_res_ss);
|
res=smaller_of(res, temp_res_ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Compare the distance between vertices and triangles
|
//Compare the distance between vertices and triangles
|
||||||
typename K::Comparison_result temp_res_v_pl= csq_dist(vertex(tr1, i), tr2,d2);
|
typename K::Comparison_result temp_res_v_pl= csq_dist(vertex(tr1, i), tr2,d2);
|
||||||
if(temp_res_v_pl==SMALLER)
|
if(certainly(temp_res_v_pl==SMALLER))
|
||||||
return SMALLER;
|
return SMALLER;
|
||||||
res=smaller_of(res, temp_res_v_pl);
|
res=smaller_of(res, temp_res_v_pl);
|
||||||
|
|
||||||
temp_res_v_pl= csq_dist(vertex(tr2, i), tr1,d2);
|
temp_res_v_pl= csq_dist(vertex(tr2, i), tr1,d2);
|
||||||
if(temp_res_v_pl==SMALLER)
|
if(certainly(temp_res_v_pl==SMALLER))
|
||||||
return SMALLER;
|
return SMALLER;
|
||||||
res=smaller_of(res, temp_res_v_pl);
|
res=smaller_of(res, temp_res_v_pl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,28 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename K_Comparison_result>
|
inline
|
||||||
K_Comparison_result smaller_of(const K_Comparison_result a, const K_Comparison_result b)
|
Comparison_result smaller_of(const Comparison_result& a, const Comparison_result& b)
|
||||||
{
|
{
|
||||||
if((a==SMALLER) || (b==SMALLER))
|
return (std::min)(a,b);
|
||||||
return SMALLER;
|
}
|
||||||
if((a==EQUAL) || (b==EQUAL))
|
|
||||||
return EQUAL;
|
inline
|
||||||
return LARGER;
|
Uncertain<Comparison_result> smaller_of(const Uncertain<Comparison_result>& a, const Uncertain<Comparison_result>& b)
|
||||||
|
{
|
||||||
|
return Uncertain((std::min)(a.inf(),b.inf()), (std::min)(a.sup(),b.sup()));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
Uncertain<Comparison_result> smaller_of(const Uncertain<Comparison_result>& a, const Comparison_result& b)
|
||||||
|
{
|
||||||
|
return smaller_of(a,make_uncertain(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
Uncertain<Comparison_result> smaller_of(const Comparison_result& a, const Uncertain<Comparison_result>& b)
|
||||||
|
{
|
||||||
|
return smaller_of(make_uncertain(a),b);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
BGL
|
BGL
|
||||||
Circulator
|
Circulator
|
||||||
Distance_3
|
|
||||||
HalfedgeDS
|
HalfedgeDS
|
||||||
Hash_map
|
Hash_map
|
||||||
Installation
|
Installation
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue