mirror of https://github.com/CGAL/cgal
Debug CSG Point Tetrahedron
This commit is contained in:
parent
c631613612
commit
dce9e4fde7
|
|
@ -144,7 +144,6 @@ squared_distance(const typename K::Tetrahedron_3& tet,
|
|||
}
|
||||
|
||||
template <class K>
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_distance(const typename K::Point_3& pt,
|
||||
const typename K::Tetrahedron_3& tet,
|
||||
|
|
@ -192,7 +191,7 @@ compare_squared_distance(const typename K::Point_3& pt,
|
|||
{
|
||||
on_bounded_side = false;
|
||||
const typename K::Comparison_result temp_res = compare_squared_distance_to_triangle(pt, t0, t3, t1, k, d2, inside_or_far_to_the_plane);
|
||||
if(inside_or_far_to_the_plane || res==SMALLER)
|
||||
if(inside_or_far_to_the_plane || temp_res==SMALLER)
|
||||
return temp_res;
|
||||
res = smaller_of(res, temp_res);
|
||||
}
|
||||
|
|
@ -201,7 +200,7 @@ compare_squared_distance(const typename K::Point_3& pt,
|
|||
{
|
||||
on_bounded_side = false;
|
||||
const typename K::Comparison_result temp_res = compare_squared_distance_to_triangle(pt, t1, t3, t2, k, d2, inside_or_far_to_the_plane);
|
||||
if(inside_or_far_to_the_plane || res==SMALLER)
|
||||
if(inside_or_far_to_the_plane || temp_res==SMALLER)
|
||||
return temp_res;
|
||||
res = smaller_of(res, temp_res);
|
||||
}
|
||||
|
|
@ -210,7 +209,7 @@ compare_squared_distance(const typename K::Point_3& pt,
|
|||
{
|
||||
on_bounded_side = false;
|
||||
const typename K::Comparison_result temp_res = compare_squared_distance_to_triangle(pt, t2, t3, t0, k, d2, inside_or_far_to_the_plane);
|
||||
if(inside_or_far_to_the_plane || res==SMALLER)
|
||||
if(inside_or_far_to_the_plane || temp_res==SMALLER)
|
||||
return temp_res;
|
||||
res = smaller_of(res, temp_res);
|
||||
}
|
||||
|
|
@ -221,6 +220,17 @@ compare_squared_distance(const typename K::Point_3& pt,
|
|||
return res;
|
||||
}
|
||||
|
||||
template <class K>
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_distance(const typename K::Tetrahedron_3& tet,
|
||||
const typename K::Point_3& pt,
|
||||
const K& k,
|
||||
const typename K::FT& d2)
|
||||
{
|
||||
return compare_squared_distance(pt, tet, k, d2);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -218,54 +218,42 @@ typename K::Comparison_result
|
|||
compare_squared_distance(const typename K::Triangle_3& tr1,
|
||||
const typename K::Triangle_3& tr2,
|
||||
const K& k,
|
||||
const typename K::FT& d2)
|
||||
const typename K::FT& d2,
|
||||
bool are_triangles_known_to_be_disjoint)
|
||||
{
|
||||
typedef typename K::FT FT;
|
||||
|
||||
typename K::Construct_vertex_3 vertex = k.construct_vertex_3_object();
|
||||
typename K::Compare_squared_distance_3 csq_dist = k.compare_squared_distance_3_object();
|
||||
|
||||
bool tr_contains_proj_p=[](const typename K::Triangle_3& tr, const typename K::Point_3 &p)
|
||||
{
|
||||
typename K::Point_3 p_proj= tr.supporting_plane().projection(p);
|
||||
return tr.has_on(p_proj);
|
||||
};
|
||||
typename K::Comparison_result res(LARGER);
|
||||
|
||||
typename K::Comparison_result temp_res(CGAL::LARGER);
|
||||
|
||||
std::pair<Distance_3::internal::Segment_3_Segment_3_Result<K>, bool> ss_res;
|
||||
for(int i=0; i<3; ++i)
|
||||
{
|
||||
for(int j=0; j<3; ++j)
|
||||
{
|
||||
if(CGAL::possibly(CGAL::compare_squared_distance(Line_3(vertex(tr1, i%3), vertex(tr1, (i+1)%3)),Line_3(vertex(tr2, j%3), vertex(tr2, (j+1)%3)),d2)!=CGAL::LARGER))
|
||||
{
|
||||
typename K::comparison_result res_seg_seg= CGAL::compare_squared_distance(Segment_3(vertex(tr1, i%3), vertex(tr1, (i+1)%3)),Segment_3(vertex(tr2, j%3), vertex(tr2, (j+1)%3)),d2);
|
||||
if(is_certain(res_seg_seg) && res_seg_seg==CGAL::SMALLER)
|
||||
return CGAL::SMALLER;
|
||||
}
|
||||
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)
|
||||
return SMALLER;
|
||||
smaller_of(res, temp_res_ss);
|
||||
}
|
||||
|
||||
typename K::comparison_result res_v_pl= CGAL::compare_squared_distance(vertex(tr1, i), tr2.supporting_plane(),d2);
|
||||
if(tr_contains_proj_p(tr2, vertex(tr1, i)))
|
||||
if(res_v_pl==CGAL::SMALLER)
|
||||
return CGAL::SMALLER;
|
||||
typename K::comparison_result temp_res_v_pl= csq_dist(vertex(tr1, i), tr2,d2);
|
||||
if(temp_res_v_pl==SMALLER)
|
||||
return SMALLER;
|
||||
smaller_of(res, temp_res_v_pl);
|
||||
|
||||
}
|
||||
|
||||
if(!are_triangles_known_to_be_disjoint){
|
||||
//TODO check are disjoint
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
template <class K>
|
||||
inline
|
||||
typename K::FT
|
||||
squared_distance(const Triangle_3<K>& tr1,
|
||||
const Triangle_3<K>& tr2)
|
||||
{
|
||||
return K().compute_squared_distance_3_object()(tr1, tr2);
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_DISTANCE_3_TRIANGLE_3_TRIANGLE_3_H
|
||||
|
|
|
|||
|
|
@ -82,9 +82,10 @@ CGAL_COMPARE_SQUARED_DISTANCE_FUNCTION(A, B)
|
|||
namespace CGAL {
|
||||
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION_SELF(Point_3)
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION_SELF(Plane_3)
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION_SELF(Segment_3)
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION_SELF(Line_3)
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION_SELF(Plane_3)
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION_SELF(Triangle_3)
|
||||
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION(Point_3, Line_3)
|
||||
CGAL_COMPUTE_AND_COMPARE_SQUARED_DISTANCE_FUNCTION(Point_3, Ray_3)
|
||||
|
|
|
|||
|
|
@ -188,8 +188,8 @@ private:
|
|||
|
||||
const FT up = upper_bound * (1 + epsilon) + std::numeric_limits<FT>::epsilon();
|
||||
|
||||
const bool res_o1o2 = (CGAL::compare_squared_distance(o1, o2, up) == CGAL::SMALLER);
|
||||
const bool res_o2o1 = (CGAL::compare_squared_distance(o2, o1, up) == CGAL::SMALLER);
|
||||
const bool res_o1o2 = (CGAL::compare_squared_distance(o1, o2, up) != CGAL::LARGER);
|
||||
const bool res_o2o1 = (CGAL::compare_squared_distance(o2, o1, up) != CGAL::LARGER);
|
||||
|
||||
assert(res_o1o2);
|
||||
assert(res_o2o1);
|
||||
|
|
@ -744,7 +744,7 @@ public:
|
|||
P_L();
|
||||
P_T();
|
||||
P_Pl();
|
||||
// P_Tet();
|
||||
P_Tet();
|
||||
|
||||
S_S();
|
||||
// S_R();
|
||||
|
|
@ -771,8 +771,8 @@ int main()
|
|||
|
||||
std::cout << "3D Distance tests" << std::endl;
|
||||
|
||||
// CGAL::Random r(1740056029);
|
||||
CGAL::Random r;
|
||||
CGAL::Random r(1740152576);
|
||||
// CGAL::Random r;
|
||||
std::cout << "random seed = " << r.get_seed() << std::endl;
|
||||
|
||||
// @todo Some tests are too difficult for these kernels
|
||||
|
|
|
|||
Loading…
Reference in New Issue