mirror of https://github.com/CGAL/cgal
BUGFIX: Bbox_3-line_3 do_intersect missing two cases when the y-slope or z-slope
of the line is 0. Add a testsuite for Bbox_3-Line_3 do_intersect.
This commit is contained in:
parent
6eb04b1056
commit
0331ea939b
|
|
@ -57,10 +57,9 @@ namespace internal {
|
|||
dmin = px - qx;
|
||||
}
|
||||
|
||||
if ( dmin == FT(0) && (tmin > FT(0) || tmax < FT(0)) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if px is not in the x-slab
|
||||
if ( dmin == FT(0) && (tmin > FT(0) || tmax < FT(0)) ) return false;
|
||||
|
||||
FT dmax = dmin;
|
||||
|
||||
// -----------------------------------
|
||||
|
|
@ -79,6 +78,9 @@ namespace internal {
|
|||
tmax_ = py - bymin;
|
||||
d_ = py - qy;
|
||||
}
|
||||
|
||||
//if py is not in the y-slab
|
||||
if ( d_ == FT(0) && (tmin_ > FT(0) || tmax_ < FT(0)) ) return false;
|
||||
|
||||
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
||||
return false;
|
||||
|
|
@ -110,6 +112,9 @@ namespace internal {
|
|||
tmax_ = pz - bzmin;
|
||||
d_ = pz - qz;
|
||||
}
|
||||
|
||||
//if pz is not in the z-slab
|
||||
if ( d_ == FT(0) && (tmin_ > FT(0) || tmax_ < FT(0)) ) return false;
|
||||
|
||||
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ struct Test {
|
|||
typedef CGAL::Triangle_3< K > Tr;
|
||||
typedef CGAL::Ray_3< K > R;
|
||||
typedef CGAL::Iso_cuboid_3< K > Cub;
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
|
||||
|
||||
template < typename Type >
|
||||
|
|
@ -380,6 +381,53 @@ struct Test {
|
|||
check_no_intersection (R(P(0,0,0),P(1,0,0)),R(P(0,1,0),P(0,2,0)));
|
||||
}
|
||||
|
||||
void Bbox_L(){
|
||||
std::cout << "Bbox - Line\n";
|
||||
Bbox box(-1,-1,-1,1,1,1);
|
||||
|
||||
//not in x,y,z slab
|
||||
check_no_intersection (box,L(P(2,0,0),P(2,0,0.5)));
|
||||
check_no_intersection (box,L(P(0,2,0),P(0,2,0.5)));
|
||||
check_no_intersection (box,L(P(0,0,2),P(0.5,0,2)));
|
||||
//not in x,y,z slab
|
||||
check_no_intersection (box,L(P(2,0,0.5),P(2,0,0)));
|
||||
check_no_intersection (box,L(P(0,2,0.5),P(0,2,0)));
|
||||
check_no_intersection (box,L(P(0.5,0,2),P(0,0,2)));
|
||||
//in each slab, time not matching
|
||||
//xz
|
||||
check_no_intersection (box,L(P(-8,0,0),P(0,0, 8)));
|
||||
check_no_intersection (box,L(P( 8,0,0),P(0,0, 8)));
|
||||
check_no_intersection (box,L(P(-8,0,0),P(0,0,-8)));
|
||||
check_no_intersection (box,L(P( 8,0,0),P(0,0,-8)));
|
||||
//yz
|
||||
check_no_intersection (box,L(P(0,-8,0),P(0,0, 8)));
|
||||
check_no_intersection (box,L(P(0, 8,0),P(0,0, 8)));
|
||||
check_no_intersection (box,L(P(0,-8,0),P(0,0,-8)));
|
||||
check_no_intersection (box,L(P(0, 8,0),P(0,0,-8)));
|
||||
//xy
|
||||
check_no_intersection (box,L(P(0,-8,0),P(8,0,0)));
|
||||
check_no_intersection (box,L(P(0, 8,0),P(8,0,0)));
|
||||
check_no_intersection (box,L(P(0,-8,0),P(-8,0,0)));
|
||||
check_no_intersection (box,L(P(0, 8,0),P(-8,0,0)));
|
||||
//Intersecting
|
||||
//xz
|
||||
check_intersection<S> (box,L(P(-0.5,0,0),P(0,0, 0.5)));
|
||||
check_intersection<S> (box,L(P( 0.5,0,0),P(0,0, 0.5)));
|
||||
check_intersection<S> (box,L(P(-0.5,0,0),P(0,0,-0.5)));
|
||||
check_intersection<S> (box,L(P( 0.5,0,0),P(0,0,-0.5)));
|
||||
//yz
|
||||
check_intersection<S> (box,L(P(0,-0.5,0),P(0,0, 0.5)));
|
||||
check_intersection<S> (box,L(P(0, 0.5,0),P(0,0, 0.5)));
|
||||
check_intersection<S> (box,L(P(0,-0.5,0),P(0,0,-0.5)));
|
||||
check_intersection<S> (box,L(P(0, 0.5,0),P(0,0,-0.5)));
|
||||
//xy
|
||||
check_intersection<S> (box,L(P(0,-0.5,0),P(0.5,0,0)));
|
||||
check_intersection<S> (box,L(P(0, 0.5,0),P(0.5,0,0)));
|
||||
check_intersection<S> (box,L(P(0,-0.5,0),P(-0.5,0,0)));
|
||||
check_intersection<S> (box,L(P(0, 0.5,0),P(-0.5,0,0)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
|
|
@ -398,6 +446,7 @@ struct Test {
|
|||
R_L();
|
||||
R_S();
|
||||
R_R();
|
||||
Bbox_L();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue