mirror of https://github.com/CGAL/cgal
Implement Sylvain's comments:
+ add missing includes + avoid object copies + replace CGAL_kernel_assertion(false) by CGAL_error() + use is() function of CGAL::Object + improve style (remove spaces, white lines...)
This commit is contained in:
parent
b9a62e057c
commit
cab2982563
|
|
@ -14,7 +14,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Laurent Rineau, Camille Wormser, Jane Tournois, Pierre Alliez
|
// Author(s) : Laurent Rineau, Camille Wormser, Jane Tournois, Pierre Alliez
|
||||||
|
|
||||||
|
|
@ -26,11 +26,13 @@
|
||||||
#pragma warning ( disable : 4003 )
|
#pragma warning ( disable : 4003 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/Bbox_3.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
bool
|
bool
|
||||||
inline
|
inline
|
||||||
do_intersect(const CGAL::Bbox_3& c,
|
do_intersect(const CGAL::Bbox_3& c,
|
||||||
const CGAL::Bbox_3& bbox)
|
const CGAL::Bbox_3& bbox)
|
||||||
{
|
{
|
||||||
return CGAL::do_overlap(c, bbox);
|
return CGAL::do_overlap(c, bbox);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb
|
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace internal {
|
||||||
|
|
||||||
template <typename FT>
|
template <typename FT>
|
||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
bbox_line_do_intersect_aux(const FT& px, const FT& py, const FT& pz,
|
bbox_line_do_intersect_aux(const FT& px, const FT& py, const FT& pz,
|
||||||
const FT& qx, const FT& qy, const FT& qz,
|
const FT& qx, const FT& qy, const FT& qz,
|
||||||
const FT& bxmin, const FT& bymin, const FT& bzmin,
|
const FT& bxmin, const FT& bymin, const FT& bzmin,
|
||||||
|
|
@ -48,7 +48,7 @@ namespace internal {
|
||||||
tmax = bxmax - px;
|
tmax = bxmax - px;
|
||||||
dmin = qx - px;
|
dmin = qx - px;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmin = px - bxmax;
|
tmin = px - bxmax;
|
||||||
tmax = px - bxmin;
|
tmax = px - bxmin;
|
||||||
|
|
@ -60,7 +60,6 @@ namespace internal {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FT dmax = dmin;
|
FT dmax = dmin;
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// treat y coord
|
// treat y coord
|
||||||
|
|
@ -78,23 +77,22 @@ namespace internal {
|
||||||
tmax_ = py - bymin;
|
tmax_ = py - bymin;
|
||||||
d_ = py - qy;
|
d_ = py - qy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( (dmin*tmin_) > (d_*tmin) )
|
if( (dmin*tmin_) > (d_*tmin) )
|
||||||
{
|
{
|
||||||
tmin = tmin_;
|
tmin = tmin_;
|
||||||
dmin = d_;
|
dmin = d_;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (dmax*tmax_) < (d_*tmax) )
|
if( (dmax*tmax_) < (d_*tmax) )
|
||||||
{
|
{
|
||||||
tmax = tmax_;
|
tmax = tmax_;
|
||||||
dmax = d_;
|
dmax = d_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// treat z coord
|
// treat z coord
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
@ -110,24 +108,24 @@ namespace internal {
|
||||||
tmax_ = pz - bzmin;
|
tmax_ = pz - bzmin;
|
||||||
d_ = pz - qz;
|
d_ = pz - qz;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const typename K::Line_3& line,
|
bool do_intersect(const typename K::Line_3& line,
|
||||||
const CGAL::Bbox_3& bbox,
|
const CGAL::Bbox_3& bbox,
|
||||||
const K&)
|
const K&)
|
||||||
{
|
{
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
typedef typename K::Vector_3 Vector_3;
|
typedef typename K::Vector_3 Vector_3;
|
||||||
|
|
||||||
const Point_3 point = line.point();
|
const Point_3& point = line.point();
|
||||||
const Vector_3 v = line.to_vector();
|
const Vector_3& v = line.to_vector();
|
||||||
|
|
||||||
return bbox_line_do_intersect_aux(
|
return bbox_line_do_intersect_aux(
|
||||||
point.x(), point.y(), point.z(),
|
point.x(), point.y(), point.z(),
|
||||||
point.x()+v.x(), point.y()+v.y(), point.z()+v.z(),
|
point.x()+v.x(), point.y()+v.y(), point.z()+v.z(),
|
||||||
FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()),
|
FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()),
|
||||||
FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) );
|
FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) );
|
||||||
|
|
@ -136,14 +134,14 @@ namespace internal {
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Line_3<K>& line,
|
bool do_intersect(const CGAL::Line_3<K>& line,
|
||||||
const CGAL::Bbox_3& bbox)
|
const CGAL::Bbox_3& bbox)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(line, bbox);
|
return typename K::Do_intersect_3()(line, bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Bbox_3& bbox,
|
bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
const CGAL::Line_3<K>& line)
|
const CGAL::Line_3<K>& line)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(line, bbox);
|
return typename K::Do_intersect_3()(line, bbox);
|
||||||
|
|
@ -152,5 +150,3 @@ bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_LINE_3_DO_INTERSECT_H
|
#endif // CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_LINE_3_DO_INTERSECT_H
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez
|
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez
|
||||||
|
|
||||||
|
|
@ -33,61 +33,61 @@ namespace internal {
|
||||||
template <class K>
|
template <class K>
|
||||||
void get_min_max(const typename K::Vector_3& p,
|
void get_min_max(const typename K::Vector_3& p,
|
||||||
const CGAL::Bbox_3& bbox,
|
const CGAL::Bbox_3& bbox,
|
||||||
typename K::Point_3& p_min,
|
typename K::Point_3& p_min,
|
||||||
typename K::Point_3& p_max)
|
typename K::Point_3& p_max)
|
||||||
{
|
{
|
||||||
if(p.x() > 0) {
|
if(p.x() > 0) {
|
||||||
if(p.y() > 0) {
|
if(p.y() > 0) {
|
||||||
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmin());
|
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmin());
|
||||||
p_max = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmax());}
|
p_max = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmax());}
|
||||||
else { p_min = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmax());
|
else { p_min = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmax());
|
||||||
p_max = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmin());}
|
p_max = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmin());}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmin());
|
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmin());
|
||||||
p_max = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmax());}
|
p_max = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmax());}
|
||||||
else { p_min = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmax());
|
else { p_min = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmax());
|
||||||
p_max = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmin());}
|
p_max = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmin());}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(p.y() > 0) {
|
if(p.y() > 0) {
|
||||||
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmin());
|
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmin());
|
||||||
p_max = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmax());}
|
p_max = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmax());}
|
||||||
else { p_min = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmax());
|
else { p_min = typename K::Point_3(bbox.xmax(), bbox.ymin(),bbox.zmax());
|
||||||
p_max = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmin());}
|
p_max = typename K::Point_3(bbox.xmin(), bbox.ymax(),bbox.zmin());}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmin());
|
if(p.z() > 0) { p_min = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmin());
|
||||||
p_max = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmax());}
|
p_max = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmax());}
|
||||||
else { p_min = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmax());
|
else { p_min = typename K::Point_3(bbox.xmax(), bbox.ymax(),bbox.zmax());
|
||||||
p_max = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmin());}
|
p_max = typename K::Point_3(bbox.xmin(), bbox.ymin(),bbox.zmin());}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const typename K::Plane_3& plane,
|
bool do_intersect(const typename K::Plane_3& plane,
|
||||||
const CGAL::Bbox_3& bbox,
|
const CGAL::Bbox_3& bbox,
|
||||||
const K&)
|
const K&)
|
||||||
{
|
{
|
||||||
typename K::Point_3 p_max, p_min;
|
typename K::Point_3 p_max, p_min;
|
||||||
get_min_max<K>(plane.orthogonal_vector(), bbox, p_min, p_max);
|
get_min_max<K>(plane.orthogonal_vector(), bbox, p_min, p_max);
|
||||||
return ! (plane.oriented_side(p_max) == ON_NEGATIVE_SIDE ||
|
return ! (plane.oriented_side(p_max) == ON_NEGATIVE_SIDE ||
|
||||||
plane.oriented_side(p_min) == ON_POSITIVE_SIDE);
|
plane.oriented_side(p_min) == ON_POSITIVE_SIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Plane_3<K>& plane,
|
bool do_intersect(const CGAL::Plane_3<K>& plane,
|
||||||
const CGAL::Bbox_3& bbox)
|
const CGAL::Bbox_3& bbox)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(plane, bbox);
|
return typename K::Do_intersect_3()(plane, bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Bbox_3& bbox,
|
bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
const CGAL::Plane_3<K>& plane)
|
const CGAL::Plane_3<K>& plane)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(plane, bbox);
|
return typename K::Do_intersect_3()(plane, bbox);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb
|
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace internal {
|
||||||
|
|
||||||
template <typename FT>
|
template <typename FT>
|
||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
bbox_ray_do_intersect_aux(const FT& px, const FT& py, const FT& pz,
|
bbox_ray_do_intersect_aux(const FT& px, const FT& py, const FT& pz,
|
||||||
const FT& qx, const FT& qy, const FT& qz,
|
const FT& qx, const FT& qy, const FT& qz,
|
||||||
const FT& bxmin, const FT& bymin, const FT& bzmin,
|
const FT& bxmin, const FT& bymin, const FT& bzmin,
|
||||||
|
|
@ -50,7 +50,7 @@ namespace internal {
|
||||||
if ( tmax < FT(0) )
|
if ( tmax < FT(0) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmin = px - bxmax;
|
tmin = px - bxmax;
|
||||||
tmax = px - bxmin;
|
tmax = px - bxmin;
|
||||||
|
|
@ -58,7 +58,7 @@ namespace internal {
|
||||||
if ( tmax < FT(0) )
|
if ( tmax < FT(0) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT dmax = dmin;
|
FT dmax = dmin;
|
||||||
if ( tmin > FT(0) )
|
if ( tmin > FT(0) )
|
||||||
{
|
{
|
||||||
|
|
@ -66,11 +66,11 @@ namespace internal {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmin = FT(0);
|
tmin = FT(0);
|
||||||
dmin = FT(1);
|
dmin = FT(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// treat y coord
|
// treat y coord
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
@ -87,23 +87,22 @@ namespace internal {
|
||||||
tmax_ = py - bymin;
|
tmax_ = py - bymin;
|
||||||
d_ = py - qy;
|
d_ = py - qy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( (dmin*tmin_) > (d_*tmin) )
|
if( (dmin*tmin_) > (d_*tmin) )
|
||||||
{
|
{
|
||||||
tmin = tmin_;
|
tmin = tmin_;
|
||||||
dmin = d_;
|
dmin = d_;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (dmax*tmax_) < (d_*tmax) )
|
if( (dmax*tmax_) < (d_*tmax) )
|
||||||
{
|
{
|
||||||
tmax = tmax_;
|
tmax = tmax_;
|
||||||
dmax = d_;
|
dmax = d_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// treat z coord
|
// treat z coord
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
@ -119,23 +118,23 @@ namespace internal {
|
||||||
tmax_ = pz - bzmin;
|
tmax_ = pz - bzmin;
|
||||||
d_ = pz - qz;
|
d_ = pz - qz;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const typename K::Ray_3& ray,
|
bool do_intersect(const typename K::Ray_3& ray,
|
||||||
const CGAL::Bbox_3& bbox,
|
const CGAL::Bbox_3& bbox,
|
||||||
const K&)
|
const K&)
|
||||||
{
|
{
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
const Point_3 source = ray.source();
|
const Point_3& source = ray.source();
|
||||||
const Point_3 point_on_ray = ray.point(1);
|
const Point_3& point_on_ray = ray.point(1);
|
||||||
|
|
||||||
return bbox_ray_do_intersect_aux(
|
return bbox_ray_do_intersect_aux(
|
||||||
source.x(), source.y(), source.z(),
|
source.x(), source.y(), source.z(),
|
||||||
point_on_ray.x(), point_on_ray.y(), point_on_ray.z(),
|
point_on_ray.x(), point_on_ray.y(), point_on_ray.z(),
|
||||||
FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()),
|
FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()),
|
||||||
FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) );
|
FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) );
|
||||||
|
|
@ -144,14 +143,14 @@ namespace internal {
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Ray_3<K>& ray,
|
bool do_intersect(const CGAL::Ray_3<K>& ray,
|
||||||
const CGAL::Bbox_3& bbox)
|
const CGAL::Bbox_3& bbox)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(ray, bbox);
|
return typename K::Do_intersect_3()(ray, bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Bbox_3& bbox,
|
bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
const CGAL::Ray_3<K>& ray)
|
const CGAL::Ray_3<K>& ray)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(ray, bbox);
|
return typename K::Do_intersect_3()(ray, bbox);
|
||||||
|
|
@ -160,5 +159,3 @@ bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_RAY_3_DO_INTERSECT_H
|
#endif // CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_RAY_3_DO_INTERSECT_H
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb
|
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb
|
||||||
|
|
||||||
|
|
@ -30,9 +30,9 @@ CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename FT>
|
template <typename FT>
|
||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
do_intersect_bbox_segment_aux(
|
do_intersect_bbox_segment_aux(
|
||||||
const FT& px, const FT& py, const FT& pz,
|
const FT& px, const FT& py, const FT& pz,
|
||||||
const FT& qx, const FT& qy, const FT& qz,
|
const FT& qx, const FT& qy, const FT& qz,
|
||||||
|
|
@ -49,29 +49,29 @@ namespace internal {
|
||||||
tmax = bxmax - px;
|
tmax = bxmax - px;
|
||||||
dmin = qx - px;
|
dmin = qx - px;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmin = px - bxmax;
|
tmin = px - bxmax;
|
||||||
tmax = px - bxmin;
|
tmax = px - bxmin;
|
||||||
dmin = px - qx;
|
dmin = px - qx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tmax < FT(0) || tmin > dmin )
|
if ( tmax < FT(0) || tmin > dmin )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FT dmax = dmin;
|
FT dmax = dmin;
|
||||||
if ( tmin < FT(0) )
|
if ( tmin < FT(0) )
|
||||||
{
|
{
|
||||||
tmin = FT(0);
|
tmin = FT(0);
|
||||||
dmin = FT(1);
|
dmin = FT(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tmax > dmax )
|
if ( tmax > dmax )
|
||||||
{
|
{
|
||||||
tmax = FT(1);
|
tmax = FT(1);
|
||||||
dmax = FT(1);
|
dmax = FT(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// treat y coord
|
// treat y coord
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
@ -88,23 +88,22 @@ namespace internal {
|
||||||
tmax_ = py - bymin;
|
tmax_ = py - bymin;
|
||||||
d_ = py - qy;
|
d_ = py - qy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( (dmin*tmin_) > (d_*tmin) )
|
if( (dmin*tmin_) > (d_*tmin) )
|
||||||
{
|
{
|
||||||
tmin = tmin_;
|
tmin = tmin_;
|
||||||
dmin = d_;
|
dmin = d_;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (dmax*tmax_) < (d_*tmax) )
|
if( (dmax*tmax_) < (d_*tmax) )
|
||||||
{
|
{
|
||||||
tmax = tmax_;
|
tmax = tmax_;
|
||||||
dmax = d_;
|
dmax = d_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// treat z coord
|
// treat z coord
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
@ -123,20 +122,20 @@ namespace internal {
|
||||||
|
|
||||||
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const typename K::Segment_3& segment,
|
bool do_intersect(const typename K::Segment_3& segment,
|
||||||
const CGAL::Bbox_3& bbox,
|
const CGAL::Bbox_3& bbox,
|
||||||
const K&)
|
const K&)
|
||||||
{
|
{
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
const Point_3 source = segment.source();
|
const Point_3& source = segment.source();
|
||||||
const Point_3 target = segment.target();
|
const Point_3& target = segment.target();
|
||||||
|
|
||||||
return do_intersect_bbox_segment_aux(
|
return do_intersect_bbox_segment_aux(
|
||||||
source.x(), source.y(), source.z(),
|
source.x(), source.y(), source.z(),
|
||||||
target.x(), target.y(), target.z(),
|
target.x(), target.y(), target.z(),
|
||||||
FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()),
|
FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()),
|
||||||
FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) );
|
FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) );
|
||||||
|
|
@ -144,7 +143,7 @@ namespace internal {
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Bbox_3& bbox,
|
bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
const typename K::Segment_3& segment,
|
const typename K::Segment_3& segment,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
return do_intersect(segment, bbox, k);
|
return do_intersect(segment, bbox, k);
|
||||||
|
|
@ -153,14 +152,14 @@ namespace internal {
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Segment_3<K>& segment,
|
bool do_intersect(const CGAL::Segment_3<K>& segment,
|
||||||
const CGAL::Bbox_3& bbox)
|
const CGAL::Bbox_3& bbox)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(segment, bbox);
|
return typename K::Do_intersect_3()(segment, bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Bbox_3& bbox,
|
bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
const CGAL::Segment_3<K>& segment)
|
const CGAL::Segment_3<K>& segment)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(segment, bbox);
|
return typename K::Do_intersect_3()(segment, bbox);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez
|
// Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ CGAL_BEGIN_NAMESPACE
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const typename K::Sphere_3& sphere,
|
bool do_intersect(const typename K::Sphere_3& sphere,
|
||||||
const CGAL::Bbox_3& bbox,
|
const CGAL::Bbox_3& bbox,
|
||||||
const K&)
|
const K&)
|
||||||
{
|
{
|
||||||
|
|
@ -98,14 +98,14 @@ namespace internal {
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Sphere_3<K>& sphere,
|
bool do_intersect(const CGAL::Sphere_3<K>& sphere,
|
||||||
const CGAL::Bbox_3& bbox)
|
const CGAL::Bbox_3& bbox)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(sphere, bbox);
|
return typename K::Do_intersect_3()(sphere, bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool do_intersect(const CGAL::Bbox_3& bbox,
|
bool do_intersect(const CGAL::Bbox_3& bbox,
|
||||||
const CGAL::Sphere_3<K>& sphere)
|
const CGAL::Sphere_3<K>& sphere)
|
||||||
{
|
{
|
||||||
return typename K::Do_intersect_3()(sphere, bbox);
|
return typename K::Do_intersect_3()(sphere, bbox);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace internal {
|
||||||
const typename K::Point_3& p = triangle.vertex(0);
|
const typename K::Point_3& p = triangle.vertex(0);
|
||||||
const typename K::Point_3& q = triangle.vertex(1);
|
const typename K::Point_3& q = triangle.vertex(1);
|
||||||
const typename K::Point_3& r = triangle.vertex(2);
|
const typename K::Point_3& r = triangle.vertex(2);
|
||||||
|
|
||||||
for(int i = 0; i < 3; ++i) {
|
for(int i = 0; i < 3; ++i) {
|
||||||
if(p[i] <= q[i]) {
|
if(p[i] <= q[i]) {
|
||||||
if(q[i] <= r[i]) { // pqr
|
if(q[i] <= r[i]) { // pqr
|
||||||
|
|
@ -100,17 +100,17 @@ namespace internal {
|
||||||
p_min = typename K::Point_3(c.xmin(), c.ymin(),c.zmin());
|
p_min = typename K::Point_3(c.xmin(), c.ymin(),c.zmin());
|
||||||
p_max = typename K::Point_3(c.xmax(), c.ymax(),c.zmax());
|
p_max = typename K::Point_3(c.xmax(), c.ymax(),c.zmax());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p_min = typename K::Point_3(c.xmin(), c.ymin(),c.zmax());
|
p_min = typename K::Point_3(c.xmin(), c.ymin(),c.zmax());
|
||||||
p_max = typename K::Point_3(c.xmax(), c.ymax(),c.zmin());
|
p_max = typename K::Point_3(c.xmax(), c.ymax(),c.zmin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(AXE == 2 || pz > 0) {
|
if(AXE == 2 || pz > 0) {
|
||||||
p_min = typename K::Point_3(c.xmin(), c.ymax(),c.zmin());
|
p_min = typename K::Point_3(c.xmin(), c.ymax(),c.zmin());
|
||||||
p_max = typename K::Point_3(c.xmax(), c.ymin(),c.zmax());
|
p_max = typename K::Point_3(c.xmax(), c.ymin(),c.zmax());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p_min = typename K::Point_3(c.xmin(), c.ymax(),c.zmax());
|
p_min = typename K::Point_3(c.xmin(), c.ymax(),c.zmax());
|
||||||
p_max = typename K::Point_3(c.xmax(), c.ymin(),c.zmin());
|
p_max = typename K::Point_3(c.xmax(), c.ymin(),c.zmin());
|
||||||
}
|
}
|
||||||
|
|
@ -118,29 +118,29 @@ namespace internal {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(AXE == 1 || py > 0) {
|
if(AXE == 1 || py > 0) {
|
||||||
if(AXE == 2 || pz > 0) {
|
if(AXE == 2 || pz > 0) {
|
||||||
p_min = typename K::Point_3(c.xmax(), c.ymin(),c.zmin());
|
p_min = typename K::Point_3(c.xmax(), c.ymin(),c.zmin());
|
||||||
p_max = typename K::Point_3(c.xmin(), c.ymax(),c.zmax());
|
p_max = typename K::Point_3(c.xmin(), c.ymax(),c.zmax());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p_min = typename K::Point_3(c.xmax(), c.ymin(),c.zmax());
|
p_min = typename K::Point_3(c.xmax(), c.ymin(),c.zmax());
|
||||||
p_max = typename K::Point_3(c.xmin(), c.ymax(),c.zmin());
|
p_max = typename K::Point_3(c.xmin(), c.ymax(),c.zmin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(AXE == 2 || pz > 0) {
|
if(AXE == 2 || pz > 0) {
|
||||||
p_min = typename K::Point_3(c.xmax(), c.ymax(),c.zmin());
|
p_min = typename K::Point_3(c.xmax(), c.ymax(),c.zmin());
|
||||||
p_max = typename K::Point_3(c.xmin(), c.ymin(),c.zmax());
|
p_max = typename K::Point_3(c.xmin(), c.ymin(),c.zmax());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p_min = typename K::Point_3(c.xmax(), c.ymax(),c.zmax());
|
p_min = typename K::Point_3(c.xmax(), c.ymax(),c.zmax());
|
||||||
p_max = typename K::Point_3(c.xmin(), c.ymin(),c.zmin());
|
p_max = typename K::Point_3(c.xmin(), c.ymin(),c.zmin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K, int AXE, int SIDE>
|
template <class K, int AXE, int SIDE>
|
||||||
inline
|
inline
|
||||||
typename K::FT
|
typename K::FT
|
||||||
|
|
@ -157,12 +157,12 @@ namespace internal {
|
||||||
case 2:
|
case 2:
|
||||||
return -sides[SIDE].y()*alpha + sides[SIDE].x()*beta;
|
return -sides[SIDE].y()*alpha + sides[SIDE].x()*beta;
|
||||||
default:
|
default:
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return typename K::FT(0.);
|
return typename K::FT(0.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K, int AXE, int SIDE>
|
template <class K, int AXE, int SIDE>
|
||||||
inline
|
inline
|
||||||
bool do_axis_intersect(const typename K::Triangle_3& triangle,
|
bool do_axis_intersect(const typename K::Triangle_3& triangle,
|
||||||
|
|
@ -171,25 +171,25 @@ namespace internal {
|
||||||
{
|
{
|
||||||
const typename K::Point_3& j = triangle.vertex(SIDE);
|
const typename K::Point_3& j = triangle.vertex(SIDE);
|
||||||
const typename K::Point_3& k = triangle.vertex((SIDE+2)%3);
|
const typename K::Point_3& k = triangle.vertex((SIDE+2)%3);
|
||||||
|
|
||||||
typename K::Point_3 p_min, p_max;
|
typename K::Point_3 p_min, p_max;
|
||||||
get_min_max<K, AXE>(AXE==0? 0: AXE==1? sides[SIDE].z(): -sides[SIDE].y(),
|
get_min_max<K, AXE>(AXE==0? 0: AXE==1? sides[SIDE].z(): -sides[SIDE].y(),
|
||||||
AXE==0? -sides[SIDE].z(): AXE==1? 0: sides[SIDE].x(),
|
AXE==0? -sides[SIDE].z(): AXE==1? 0: sides[SIDE].x(),
|
||||||
AXE==0? sides[SIDE].y(): AXE==1? -sides[SIDE].x(): 0,
|
AXE==0? sides[SIDE].y(): AXE==1? -sides[SIDE].x(): 0,
|
||||||
bbox, p_min, p_max);
|
bbox, p_min, p_max);
|
||||||
|
|
||||||
switch ( AXE )
|
switch ( AXE )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
// t_max >= t_min
|
// t_max >= t_min
|
||||||
if ( do_axis_intersect_aux<K,AXE,SIDE>(k.y()-j.y(), k.z()-j.z(), sides) >= 0 )
|
if ( do_axis_intersect_aux<K,AXE,SIDE>(k.y()-j.y(), k.z()-j.z(), sides) >= 0 )
|
||||||
{
|
{
|
||||||
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.y()-k.y(), p_min.z()-k.z(), sides) <= 0
|
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.y()-k.y(), p_min.z()-k.z(), sides) <= 0
|
||||||
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.y()-j.y(), p_max.z()-j.z(), sides) >= 0 );
|
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.y()-j.y(), p_max.z()-j.z(), sides) >= 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.y()-j.y(), p_min.z()-j.z(), sides) <= 0
|
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.y()-j.y(), p_min.z()-j.z(), sides) <= 0
|
||||||
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.y()-k.y(), p_max.z()-k.z(), sides) >= 0 );
|
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.y()-k.y(), p_max.z()-k.z(), sides) >= 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -197,12 +197,12 @@ namespace internal {
|
||||||
// t_max >= t_min
|
// t_max >= t_min
|
||||||
if ( do_axis_intersect_aux<K,AXE,SIDE>(k.x()-j.x(), k.z()-j.z(), sides) >= 0 )
|
if ( do_axis_intersect_aux<K,AXE,SIDE>(k.x()-j.x(), k.z()-j.z(), sides) >= 0 )
|
||||||
{
|
{
|
||||||
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-k.x(), p_min.z()-k.z(), sides) <= 0
|
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-k.x(), p_min.z()-k.z(), sides) <= 0
|
||||||
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-j.x(), p_max.z()-j.z(), sides) >= 0 );
|
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-j.x(), p_max.z()-j.z(), sides) >= 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-j.x(), p_min.z()-j.z(), sides) <= 0
|
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-j.x(), p_min.z()-j.z(), sides) <= 0
|
||||||
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-k.x(), p_max.z()-k.z(), sides) >= 0 );
|
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-k.x(), p_max.z()-k.z(), sides) >= 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -210,18 +210,18 @@ namespace internal {
|
||||||
// t_max >= t_min
|
// t_max >= t_min
|
||||||
if ( do_axis_intersect_aux<K,AXE,SIDE>(k.x()-j.x(), k.y()-j.y(), sides) >= 0 )
|
if ( do_axis_intersect_aux<K,AXE,SIDE>(k.x()-j.x(), k.y()-j.y(), sides) >= 0 )
|
||||||
{
|
{
|
||||||
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-k.x(), p_min.y()-k.y(), sides) <= 0
|
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-k.x(), p_min.y()-k.y(), sides) <= 0
|
||||||
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-j.x(), p_max.y()-j.y(), sides) >= 0 );
|
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-j.x(), p_max.y()-j.y(), sides) >= 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-j.x(), p_min.y()-j.y(), sides) <= 0
|
return ( do_axis_intersect_aux<K,AXE,SIDE>(p_min.x()-j.x(), p_min.y()-j.y(), sides) <= 0
|
||||||
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-k.x(), p_max.y()-k.y(), sides) >= 0 );
|
|| do_axis_intersect_aux<K,AXE,SIDE>(p_max.x()-k.x(), p_max.y()-k.y(), sides) >= 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Should not happen
|
// Should not happen
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Stéphane Tayeb
|
// Author(s) : Stéphane Tayeb
|
||||||
//
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
// File Description :
|
// File Description : Implements triangle_3 line_3 intersection construction.
|
||||||
//
|
// This implementation is adapted from Triangle_3_Line_3_do_intersect.h.
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
|
|
||||||
|
|
||||||
#ifndef CGAL_INTERNAL_INTERSECTIONS_3_TRIANGLE_3_LINE_3_INTERSECTION_H
|
#ifndef CGAL_INTERNAL_INTERSECTIONS_3_TRIANGLE_3_LINE_3_INTERSECTION_H
|
||||||
#define CGAL_INTERNAL_INTERSECTIONS_3_TRIANGLE_3_LINE_3_INTERSECTION_H
|
#define CGAL_INTERNAL_INTERSECTIONS_3_TRIANGLE_3_LINE_3_INTERSECTION_H
|
||||||
|
|
||||||
|
|
@ -37,42 +37,42 @@ t3l3_intersection_coplanar_aux(const typename K::Line_3& l,
|
||||||
const typename K::Point_3& a,
|
const typename K::Point_3& a,
|
||||||
const typename K::Point_3& b,
|
const typename K::Point_3& b,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
// Returns the intersection point between line l and segment [a,b]
|
// Returns the intersection point between line l and segment [a,b]
|
||||||
//
|
//
|
||||||
// preconditions:
|
// preconditions:
|
||||||
// + l,a,b are coplanar
|
// + l,a,b are coplanar
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
typedef typename K::Vector_3 Vector_3;
|
typedef typename K::Vector_3 Vector_3;
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
|
|
||||||
typename K::Construct_vector_3 vector =
|
typename K::Construct_vector_3 vector =
|
||||||
k.construct_vector_3_object();
|
k.construct_vector_3_object();
|
||||||
|
|
||||||
typename K::Construct_cross_product_vector_3 cross_product =
|
typename K::Construct_cross_product_vector_3 cross_product =
|
||||||
k.construct_cross_product_vector_3_object();
|
k.construct_cross_product_vector_3_object();
|
||||||
|
|
||||||
typename K::Compute_scalar_product_3 scalar_product =
|
typename K::Compute_scalar_product_3 scalar_product =
|
||||||
k.compute_scalar_product_3_object();
|
k.compute_scalar_product_3_object();
|
||||||
|
|
||||||
typename K::Compute_squared_length_3 sq_length =
|
typename K::Compute_squared_length_3 sq_length =
|
||||||
k.compute_squared_length_3_object();
|
k.compute_squared_length_3_object();
|
||||||
|
|
||||||
const Point_3 p = l.point();
|
const Point_3& p = l.point();
|
||||||
const Vector_3 v = l.to_vector();
|
const Vector_3& v = l.to_vector();
|
||||||
const Vector_3 ab = vector(a,b);
|
const Vector_3 ab = vector(a,b);
|
||||||
const Vector_3 pa = vector(p,a);
|
const Vector_3 pa = vector(p,a);
|
||||||
|
|
||||||
const Vector_3 pa_ab = cross_product(pa,ab);
|
const Vector_3 pa_ab = cross_product(pa,ab);
|
||||||
const Vector_3 v_ab = cross_product(v,ab);
|
const Vector_3 v_ab = cross_product(v,ab);
|
||||||
|
|
||||||
const FT t = scalar_product(pa_ab,v_ab) / sq_length(v_ab);
|
const FT t = scalar_product(pa_ab,v_ab) / sq_length(v_ab);
|
||||||
|
|
||||||
return ( p + t*v );
|
return ( p + t*v );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
t3l3_intersection_coplanar_aux(const typename K::Point_3& a,
|
t3l3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
|
|
@ -93,69 +93,66 @@ t3l3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
// | l
|
// | l
|
||||||
//
|
//
|
||||||
// We know that c is isolated on the negative side of pq
|
// We know that c is isolated on the negative side of pq
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
typename K::Intersect_3 intersection =
|
typename K::Intersect_3 intersection =
|
||||||
k.intersect_3_object();
|
k.intersect_3_object();
|
||||||
|
|
||||||
typename K::Construct_line_3 line =
|
typename K::Construct_line_3 line =
|
||||||
k.construct_line_3_object();
|
k.construct_line_3_object();
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
// Let's get the intersection points
|
// Let's get the intersection points
|
||||||
const Point_3 l_bc = t3l3_intersection_coplanar_aux(l,b,c,k);
|
const Point_3 l_bc = t3l3_intersection_coplanar_aux(l,b,c,k);
|
||||||
const Point_3 l_ca = t3l3_intersection_coplanar_aux(l,c,a,k);
|
const Point_3 l_ca = t3l3_intersection_coplanar_aux(l,c,a,k);
|
||||||
|
|
||||||
if ( negative_side )
|
if ( negative_side )
|
||||||
return make_object(segment(l_bc, l_ca));
|
return make_object(segment(l_bc, l_ca));
|
||||||
else
|
else
|
||||||
return make_object(segment(l_ca, l_bc));
|
return make_object(segment(l_ca, l_bc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection_coplanar(const typename K::Triangle_3 &t,
|
intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
const typename K::Line_3 &l,
|
const typename K::Line_3 &l,
|
||||||
const K & k )
|
const K & k )
|
||||||
{
|
{
|
||||||
|
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(l) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(l) ) ;
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
|
typename K::Construct_point_on_3 point_on =
|
||||||
typename K::Construct_point_on_3 point_on =
|
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename K::Coplanar_orientation_3 coplanar_orientation =
|
typename K::Coplanar_orientation_3 coplanar_orientation =
|
||||||
k.coplanar_orientation_3_object();
|
k.coplanar_orientation_3_object();
|
||||||
|
|
||||||
typename K::Construct_line_3 line =
|
typename K::Construct_line_3 line =
|
||||||
k.construct_line_3_object();
|
k.construct_line_3_object();
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
|
|
||||||
const Point_3 & p = point_on(l,0);
|
const Point_3 & p = point_on(l,0);
|
||||||
const Point_3 & q = point_on(l,1);
|
const Point_3 & q = point_on(l,1);
|
||||||
|
|
||||||
const Point_3 & A = vertex_on(t,0);
|
const Point_3 & A = vertex_on(t,0);
|
||||||
const Point_3 & B = vertex_on(t,1);
|
const Point_3 & B = vertex_on(t,1);
|
||||||
const Point_3 & C = vertex_on(t,2);
|
const Point_3 & C = vertex_on(t,2);
|
||||||
|
|
||||||
int k0 = 0;
|
int k0 = 0;
|
||||||
int k1 = 1;
|
int k1 = 1;
|
||||||
int k2 = 2;
|
int k2 = 2;
|
||||||
|
|
||||||
// Determine the orientation of the triangle in the common plane
|
// Determine the orientation of the triangle in the common plane
|
||||||
if (coplanar_orientation(A,B,C) != POSITIVE)
|
if (coplanar_orientation(A,B,C) != POSITIVE)
|
||||||
{
|
{
|
||||||
|
|
@ -163,20 +160,20 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// swap two vertices.
|
// swap two vertices.
|
||||||
std::swap(k1,k2);
|
std::swap(k1,k2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Point_3& a = vertex_on(t,k0);
|
const Point_3& a = vertex_on(t,k0);
|
||||||
const Point_3& b = vertex_on(t,k1);
|
const Point_3& b = vertex_on(t,k1);
|
||||||
const Point_3& c = vertex_on(t,k2);
|
const Point_3& c = vertex_on(t,k2);
|
||||||
|
|
||||||
// Test whether the line intersects the triangle in the common plane
|
// Test whether the line intersects the triangle in the common plane
|
||||||
const Orientation pqa = coplanar_orientation(p,q,a);
|
const Orientation pqa = coplanar_orientation(p,q,a);
|
||||||
const Orientation pqb = coplanar_orientation(p,q,b);
|
const Orientation pqb = coplanar_orientation(p,q,b);
|
||||||
const Orientation pqc = coplanar_orientation(p,q,c);
|
const Orientation pqc = coplanar_orientation(p,q,c);
|
||||||
|
|
||||||
switch ( pqa ) {
|
switch ( pqa ) {
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa POSITIVE
|
// pqa POSITIVE
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -191,7 +188,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
return make_object(c);
|
return make_object(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
if ( POSITIVE == pqc )
|
if ( POSITIVE == pqc )
|
||||||
// b is isolated on the negative side
|
// b is isolated on the negative side
|
||||||
|
|
@ -200,7 +197,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// a is isolated on the positive side (here mb c could be use as
|
// a is isolated on the positive side (here mb c could be use as
|
||||||
// an endpoint instead of computing an intersection is some cases)
|
// an endpoint instead of computing an intersection is some cases)
|
||||||
return t3l3_intersection_coplanar_aux(b,c,a,l,false,k);
|
return t3l3_intersection_coplanar_aux(b,c,a,l,false,k);
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -213,15 +210,15 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// b,c,p,q are aligned, [p,q]&[b,c] have the same direction
|
// b,c,p,q are aligned, [p,q]&[b,c] have the same direction
|
||||||
return make_object(segment(b,c));
|
return make_object(segment(b,c));
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa NEGATIVE
|
// pqa NEGATIVE
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -232,7 +229,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// b is isolated on the positive side (here mb c could be use as
|
// b is isolated on the positive side (here mb c could be use as
|
||||||
// an endpoint instead of computing an intersection, in some cases)
|
// an endpoint instead of computing an intersection, in some cases)
|
||||||
return t3l3_intersection_coplanar_aux(c,a,b,l,false,k);
|
return t3l3_intersection_coplanar_aux(c,a,b,l,false,k);
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -245,28 +242,28 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
return make_object(c);
|
return make_object(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// a is isolated on the negative side (here mb b could be use as
|
// a is isolated on the negative side (here mb b could be use as
|
||||||
// an endpoint instead of computing an intersection)
|
// an endpoint instead of computing an intersection)
|
||||||
return t3l3_intersection_coplanar_aux(b,c,a,l,true,k);
|
return t3l3_intersection_coplanar_aux(b,c,a,l,true,k);
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
return make_object(b);
|
return make_object(b);
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// b,c,p,q are aligned, [p,q]&[c,b] have the same direction
|
// b,c,p,q are aligned, [p,q]&[c,b] have the same direction
|
||||||
return make_object(segment(c,b));
|
return make_object(segment(c,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa COLLINEAR
|
// pqa COLLINEAR
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -281,7 +278,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// a,c,p,q are aligned, [p,q]&[c,a] have the same direction
|
// a,c,p,q are aligned, [p,q]&[c,a] have the same direction
|
||||||
return make_object(segment(c,a));
|
return make_object(segment(c,a));
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -294,7 +291,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// a,c,p,q are aligned, [p,q]&[a,c] have the same direction
|
// a,c,p,q are aligned, [p,q]&[a,c] have the same direction
|
||||||
return make_object(segment(a,c));
|
return make_object(segment(a,c));
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -306,45 +303,42 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// case pqc == COLLINEAR is impossible since the triangle is
|
// case pqc == COLLINEAR is impossible since the triangle is
|
||||||
// assumed to be non flat
|
// assumed to be non flat
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:// should not happen.
|
default:// should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
Object
|
Object
|
||||||
t3l3_intersection_aux(const typename K::Triangle_3 &t,
|
t3l3_intersection_aux(const typename K::Triangle_3 &t,
|
||||||
const typename K::Line_3 &l,
|
const typename K::Line_3 &l,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
typename K::Intersect_3 intersection =
|
typename K::Intersect_3 intersection =
|
||||||
k.intersect_3_object();
|
k.intersect_3_object();
|
||||||
|
|
||||||
Object obj = intersection(l,t.supporting_plane());
|
Object obj = intersection(l,t.supporting_plane());
|
||||||
|
|
||||||
// Intersection should be a point (because of orientation test done before)
|
// Intersection should be a point (because of orientation test done before)
|
||||||
if ( NULL == object_cast<typename K::Line_3>(&obj) )
|
if ( obj.is<typename K::Line_3>() )
|
||||||
return obj;
|
|
||||||
else
|
|
||||||
return Object();
|
return Object();
|
||||||
|
else
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Triangle_3 &t,
|
intersection(const typename K::Triangle_3 &t,
|
||||||
|
|
@ -353,78 +347,76 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
{
|
{
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(l) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(l) ) ;
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
typename K::Construct_point_on_3 point_on =
|
typename K::Construct_point_on_3 point_on =
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename K::Orientation_3 orientation =
|
typename K::Orientation_3 orientation =
|
||||||
k.orientation_3_object();
|
k.orientation_3_object();
|
||||||
|
|
||||||
typename K::Coplanar_orientation_3 coplanar_orientation =
|
typename K::Coplanar_orientation_3 coplanar_orientation =
|
||||||
k.coplanar_orientation_3_object();
|
k.coplanar_orientation_3_object();
|
||||||
|
|
||||||
typename K::Intersect_3 intersection =
|
typename K::Intersect_3 intersection =
|
||||||
k.intersect_3_object();
|
k.intersect_3_object();
|
||||||
|
|
||||||
const Point_3 & a = vertex_on(t,0);
|
const Point_3 & a = vertex_on(t,0);
|
||||||
const Point_3 & b = vertex_on(t,1);
|
const Point_3 & b = vertex_on(t,1);
|
||||||
const Point_3 & c = vertex_on(t,2);
|
const Point_3 & c = vertex_on(t,2);
|
||||||
const Point_3 & p = point_on(l,0);
|
const Point_3 & p = point_on(l,0);
|
||||||
const Point_3 & q = point_on(l,1);
|
const Point_3 & q = point_on(l,1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( ( orientation(a,b,c,p) != COPLANAR )
|
if ( ( orientation(a,b,c,p) != COPLANAR )
|
||||||
|| ( orientation(a,b,c,q) != COPLANAR ) )
|
|| ( orientation(a,b,c,q) != COPLANAR ) )
|
||||||
{
|
{
|
||||||
const Orientation pqab = orientation(p,q,a,b);
|
const Orientation pqab = orientation(p,q,a,b);
|
||||||
const Orientation pqbc = orientation(p,q,b,c);
|
const Orientation pqbc = orientation(p,q,b,c);
|
||||||
switch ( pqab ) {
|
switch ( pqab ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
if ( pqbc != NEGATIVE && orientation(p,q,c,a) != NEGATIVE )
|
if ( pqbc != NEGATIVE && orientation(p,q,c,a) != NEGATIVE )
|
||||||
return t3l3_intersection_aux(t,l,k);
|
return t3l3_intersection_aux(t,l,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
if ( pqbc != POSITIVE && orientation(p,q,c,a) != POSITIVE )
|
if ( pqbc != POSITIVE && orientation(p,q,c,a) != POSITIVE )
|
||||||
return t3l3_intersection_aux(t,l,k);
|
return t3l3_intersection_aux(t,l,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
switch ( pqbc ) {
|
switch ( pqbc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
if ( orientation(p,q,c,a) != NEGATIVE )
|
if ( orientation(p,q,c,a) != NEGATIVE )
|
||||||
return t3l3_intersection_aux(t,l,k);
|
return t3l3_intersection_aux(t,l,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
if ( orientation(p,q,c,a) != POSITIVE )
|
if ( orientation(p,q,c,a) != POSITIVE )
|
||||||
return t3l3_intersection_aux(t,l,k);
|
return t3l3_intersection_aux(t,l,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR: // pqa or pqb or pqc are collinear
|
case COPLANAR: // pqa or pqb or pqc are collinear
|
||||||
return t3l3_intersection_aux(t,l,k);
|
return t3l3_intersection_aux(t,l,k);
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coplanar case
|
// Coplanar case
|
||||||
return intersection_coplanar(t,l,k);
|
return intersection_coplanar(t,l,k);
|
||||||
}
|
}
|
||||||
|
|
@ -433,12 +425,12 @@ template <class K>
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Line_3 &l,
|
intersection(const typename K::Line_3 &l,
|
||||||
const typename K::Triangle_3 &t,
|
const typename K::Triangle_3 &t,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
return internal::intersection(t,l,k);
|
return internal::intersection(t,l,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Adapted from <CGAL/Triangle_3_Plane_3_do_intersect.h>
|
// Adapted from <CGAL/Triangle_3_Plane_3_do_intersect.h>
|
||||||
//
|
//
|
||||||
|
|
@ -32,11 +32,11 @@ namespace CGAL {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
typename K::Point_3
|
typename K::Point_3
|
||||||
inter_plane_triangle_3_aux(const typename K::Point_3 &p1,
|
inter_plane_triangle_3_aux(const typename K::Point_3 &p1,
|
||||||
const typename K::RT & f1,
|
const typename K::RT & f1,
|
||||||
const typename K::Point_3 &p2,
|
const typename K::Point_3 &p2,
|
||||||
const typename K::RT & f2)
|
const typename K::RT & f2)
|
||||||
{
|
{
|
||||||
return typename K::Point_3(f2 * p1.x() - f1 * p2.x(),
|
return typename K::Point_3(f2 * p1.x() - f1 * p2.x(),
|
||||||
|
|
@ -47,8 +47,8 @@ inter_plane_triangle_3_aux(const typename K::Point_3 &p1,
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Plane_3 &plane,
|
intersection(const typename K::Plane_3 &plane,
|
||||||
const typename K::Triangle_3 &triangle,
|
const typename K::Triangle_3 &triangle,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(triangle)) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(triangle)) ;
|
||||||
|
|
@ -59,17 +59,17 @@ intersection(const typename K::Plane_3 &plane,
|
||||||
typedef typename K::Object_3 Object_3;
|
typedef typename K::Object_3 Object_3;
|
||||||
typedef typename K::RT RT;
|
typedef typename K::RT RT;
|
||||||
typedef typename Sgn<RT>::result_type SignRT;
|
typedef typename Sgn<RT>::result_type SignRT;
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
//typename K::Oriented_side_3 oriented_side =
|
//typename K::Oriented_side_3 oriented_side =
|
||||||
//k.oriented_side_3_object(); // PA: never used
|
//k.oriented_side_3_object(); // PA: never used
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
typename K::Construct_object_3 make_object =
|
typename K::Construct_object_3 make_object =
|
||||||
k.construct_object_3_object();
|
k.construct_object_3_object();
|
||||||
|
|
||||||
const Point_3& t0 = vertex_on(triangle,0);
|
const Point_3& t0 = vertex_on(triangle,0);
|
||||||
|
|
@ -157,8 +157,8 @@ intersection(const typename K::Plane_3 &plane,
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Triangle_3 &triangle,
|
intersection(const typename K::Triangle_3 &triangle,
|
||||||
const typename K::Plane_3 &plane,
|
const typename K::Plane_3 &plane,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
return intersection(plane, triangle, k);
|
return intersection(plane, triangle, k);
|
||||||
|
|
@ -168,7 +168,7 @@ intersection(const typename K::Triangle_3 &triangle,
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
Object
|
Object
|
||||||
intersection(const Plane_3<K> &plane, const Triangle_3<K> &triangle)
|
intersection(const Plane_3<K> &plane, const Triangle_3<K> &triangle)
|
||||||
{
|
{
|
||||||
return typename K::Intersect_3()(plane, triangle);
|
return typename K::Intersect_3()(plane, triangle);
|
||||||
|
|
@ -176,7 +176,7 @@ intersection(const Plane_3<K> &plane, const Triangle_3<K> &triangle)
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
Object
|
Object
|
||||||
intersection(const Triangle_3<K> &triangle, const Plane_3<K> &plane)
|
intersection(const Triangle_3<K> &triangle, const Plane_3<K> &plane)
|
||||||
{
|
{
|
||||||
return typename K::Intersect_3()(plane, triangle);
|
return typename K::Intersect_3()(plane, triangle);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
//
|
//
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
// File Description : Implements triangle_3 ray_3 intersection construction.
|
// File Description : Implements triangle_3 ray_3 intersection construction.
|
||||||
//
|
|
||||||
// This implementation is adapted from Triangle_3_Ray_3_do_intersect.h.
|
// This implementation is adapted from Triangle_3_Ray_3_do_intersect.h.
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
|
|
||||||
|
|
@ -32,7 +31,7 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
typename K::Point_3
|
typename K::Point_3
|
||||||
t3r3_intersection_coplanar_aux(const typename K::Point_3& p,
|
t3r3_intersection_coplanar_aux(const typename K::Point_3& p,
|
||||||
|
|
@ -40,40 +39,40 @@ t3r3_intersection_coplanar_aux(const typename K::Point_3& p,
|
||||||
const typename K::Point_3& a,
|
const typename K::Point_3& a,
|
||||||
const typename K::Point_3& b,
|
const typename K::Point_3& b,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
// Returns the intersection point between line (p,v) and line (a,b)
|
// Returns the intersection point between line (p,v) and line (a,b)
|
||||||
//
|
//
|
||||||
// preconditions:
|
// preconditions:
|
||||||
// + p,v,a,b are coplanar
|
// + p,v,a,b are coplanar
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
typedef typename K::Vector_3 Vector_3;
|
typedef typename K::Vector_3 Vector_3;
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
|
|
||||||
typename K::Construct_vector_3 vector =
|
typename K::Construct_vector_3 vector =
|
||||||
k.construct_vector_3_object();
|
k.construct_vector_3_object();
|
||||||
|
|
||||||
typename K::Construct_cross_product_vector_3 cross_product =
|
typename K::Construct_cross_product_vector_3 cross_product =
|
||||||
k.construct_cross_product_vector_3_object();
|
k.construct_cross_product_vector_3_object();
|
||||||
|
|
||||||
typename K::Compute_scalar_product_3 scalar_product =
|
typename K::Compute_scalar_product_3 scalar_product =
|
||||||
k.compute_scalar_product_3_object();
|
k.compute_scalar_product_3_object();
|
||||||
|
|
||||||
typename K::Compute_squared_length_3 sq_length =
|
typename K::Compute_squared_length_3 sq_length =
|
||||||
k.compute_squared_length_3_object();
|
k.compute_squared_length_3_object();
|
||||||
|
|
||||||
const Vector_3 ab = vector(a,b);
|
const Vector_3 ab = vector(a,b);
|
||||||
const Vector_3 pa = vector(p,a);
|
const Vector_3 pa = vector(p,a);
|
||||||
|
|
||||||
const Vector_3 pa_ab = cross_product(pa,ab);
|
const Vector_3 pa_ab = cross_product(pa,ab);
|
||||||
const Vector_3 v_ab = cross_product(v,ab);
|
const Vector_3 v_ab = cross_product(v,ab);
|
||||||
|
|
||||||
const FT t = scalar_product(pa_ab,v_ab) / sq_length(v_ab);
|
const FT t = scalar_product(pa_ab,v_ab) / sq_length(v_ab);
|
||||||
|
|
||||||
return ( p + t*v );
|
return ( p + t*v );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
t3r3_intersection_coplanar_aux(const typename K::Point_3& a,
|
t3r3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
|
|
@ -86,61 +85,58 @@ t3r3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
// This function is designed to clip r into the triangle abc.
|
// This function is designed to clip r into the triangle abc.
|
||||||
// Point configuration should be as follows
|
// Point configuration should be as follows
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// p+ +b
|
// p+ +b
|
||||||
// |
|
// |
|
||||||
// +c | +a
|
// +c | +a
|
||||||
// |
|
// |
|
||||||
// |r
|
// |r
|
||||||
//
|
//
|
||||||
// We know that c is isolated on the negative side of r
|
// We know that c is isolated on the negative side of r
|
||||||
// but we don't know p position wrt [bc]&[ca]
|
// but we don't know p position wrt [bc]&[ca]
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
typedef typename K::Vector_3 Vector_3;
|
typedef typename K::Vector_3 Vector_3;
|
||||||
|
|
||||||
typename K::Coplanar_orientation_3 coplanar_orientation =
|
typename K::Coplanar_orientation_3 coplanar_orientation =
|
||||||
k.coplanar_orientation_3_object();
|
k.coplanar_orientation_3_object();
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
typename K::Construct_point_on_3 point_on =
|
typename K::Construct_point_on_3 point_on =
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
const Point_3& p = point_on(r,0);
|
const Point_3& p = point_on(r,0);
|
||||||
|
|
||||||
// A ray is not symetric, 2 cases depending on isolated side of c
|
// A ray is not symetric, 2 cases depending on isolated side of c
|
||||||
Orientation cap;
|
Orientation cap = negative_side ? coplanar_orientation(c,a,p)
|
||||||
if ( negative_side )
|
: coplanar_orientation(b,c,p);
|
||||||
cap = coplanar_orientation(c,a,p);
|
|
||||||
else
|
|
||||||
cap = coplanar_orientation(b,c,p);
|
|
||||||
|
|
||||||
switch ( cap ) {
|
switch ( cap ) {
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// p is bellow [c,a]
|
// p is bellow [c,a]
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
return make_object(p);
|
return make_object(p);
|
||||||
|
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
{
|
{
|
||||||
// Compute the intersection points between ray and [b,c],[c,a]
|
// Compute the intersection points between ray and [b,c],[c,a]
|
||||||
Vector_3 v = r.to_vector();
|
Vector_3 v = r.to_vector();
|
||||||
|
|
||||||
// Get intersection point at p side
|
// Get intersection point at p side
|
||||||
Point_3 p_side_end_point(p);
|
Point_3 p_side_end_point(p);
|
||||||
Point_3 q_side_end_point;
|
Point_3 q_side_end_point;
|
||||||
|
|
||||||
// A ray is not symetric, 2 cases depending on isolated side of c
|
// A ray is not symetric, 2 cases depending on isolated side of c
|
||||||
if ( negative_side )
|
if ( negative_side )
|
||||||
{
|
{
|
||||||
if ( NEGATIVE == coplanar_orientation(b,c,p) )
|
if ( NEGATIVE == coplanar_orientation(b,c,p) )
|
||||||
p_side_end_point = t3r3_intersection_coplanar_aux(p,v,b,c,k);
|
p_side_end_point = t3r3_intersection_coplanar_aux(p,v,b,c,k);
|
||||||
|
|
||||||
// Get other end point (always intersection computation on the unbounded
|
// Get other end point (always intersection computation on the unbounded
|
||||||
// side of the ray)
|
// side of the ray)
|
||||||
q_side_end_point = t3r3_intersection_coplanar_aux(p,v,c,a,k);
|
q_side_end_point = t3r3_intersection_coplanar_aux(p,v,c,a,k);
|
||||||
|
|
@ -149,73 +145,67 @@ t3r3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
{
|
{
|
||||||
if ( NEGATIVE == coplanar_orientation(c,a,p) )
|
if ( NEGATIVE == coplanar_orientation(c,a,p) )
|
||||||
p_side_end_point = t3r3_intersection_coplanar_aux(p,v,c,a,k);
|
p_side_end_point = t3r3_intersection_coplanar_aux(p,v,c,a,k);
|
||||||
|
|
||||||
// Get other end point (always intersection computation on the unbounded
|
// Get other end point (always intersection computation on the unbounded
|
||||||
// side of the ray)
|
// side of the ray)
|
||||||
q_side_end_point = t3r3_intersection_coplanar_aux(p,v,b,c,k);
|
q_side_end_point = t3r3_intersection_coplanar_aux(p,v,b,c,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build result
|
// Build result
|
||||||
return make_object(segment(p_side_end_point, q_side_end_point));
|
return make_object(segment(p_side_end_point, q_side_end_point));
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection_coplanar(const typename K::Triangle_3 &t,
|
intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
const typename K::Ray_3 &r,
|
const typename K::Ray_3 &r,
|
||||||
const K & k )
|
const K & k )
|
||||||
{
|
{
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ;
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
|
typename K::Construct_point_on_3 point_on =
|
||||||
typename K::Construct_point_on_3 point_on =
|
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename K::Coplanar_orientation_3 coplanar_orientation =
|
typename K::Coplanar_orientation_3 coplanar_orientation =
|
||||||
k.coplanar_orientation_3_object();
|
k.coplanar_orientation_3_object();
|
||||||
|
|
||||||
typename K::Construct_line_3 line =
|
typename K::Construct_line_3 line =
|
||||||
k.construct_line_3_object();
|
k.construct_line_3_object();
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
typename K::Collinear_are_ordered_along_line_3 collinear_ordered =
|
typename K::Collinear_are_ordered_along_line_3 collinear_ordered =
|
||||||
k.collinear_are_ordered_along_line_3_object();
|
k.collinear_are_ordered_along_line_3_object();
|
||||||
|
|
||||||
|
|
||||||
const Point_3 & p = point_on(r,0);
|
const Point_3 & p = point_on(r,0);
|
||||||
const Point_3 & q = point_on(r,1);
|
const Point_3 & q = point_on(r,1);
|
||||||
|
|
||||||
const Point_3 & A = vertex_on(t,0);
|
const Point_3 & A = vertex_on(t,0);
|
||||||
const Point_3 & B = vertex_on(t,1);
|
const Point_3 & B = vertex_on(t,1);
|
||||||
const Point_3 & C = vertex_on(t,2);
|
const Point_3 & C = vertex_on(t,2);
|
||||||
|
|
||||||
int k0 = 0;
|
int k0 = 0;
|
||||||
int k1 = 1;
|
int k1 = 1;
|
||||||
int k2 = 2;
|
int k2 = 2;
|
||||||
|
|
||||||
// Determine the orientation of the triangle in the common plane
|
// Determine the orientation of the triangle in the common plane
|
||||||
if (coplanar_orientation(A,B,C) != POSITIVE)
|
if (coplanar_orientation(A,B,C) != POSITIVE)
|
||||||
{
|
{
|
||||||
|
|
@ -223,21 +213,21 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// swap two vertices.
|
// swap two vertices.
|
||||||
std::swap(k1,k2);
|
std::swap(k1,k2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Point_3& a = vertex_on(t,k0);
|
const Point_3& a = vertex_on(t,k0);
|
||||||
const Point_3& b = vertex_on(t,k1);
|
const Point_3& b = vertex_on(t,k1);
|
||||||
const Point_3& c = vertex_on(t,k2);
|
const Point_3& c = vertex_on(t,k2);
|
||||||
|
|
||||||
// Test whether the ray's supporting line intersects the
|
// Test whether the ray's supporting line intersects the
|
||||||
// triangle in the common plane
|
// triangle in the common plane
|
||||||
const Orientation pqa = coplanar_orientation(p,q,a);
|
const Orientation pqa = coplanar_orientation(p,q,a);
|
||||||
const Orientation pqb = coplanar_orientation(p,q,b);
|
const Orientation pqb = coplanar_orientation(p,q,b);
|
||||||
const Orientation pqc = coplanar_orientation(p,q,c);
|
const Orientation pqc = coplanar_orientation(p,q,c);
|
||||||
|
|
||||||
switch ( pqa ) {
|
switch ( pqa ) {
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa POSITIVE
|
// pqa POSITIVE
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -246,11 +236,11 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// the triangle lies in the positive halfspace
|
// the triangle lies in the positive halfspace
|
||||||
// defined by the segment's supporting line.
|
// defined by the segment's supporting line.
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// c is isolated on the negative side
|
// c is isolated on the negative side
|
||||||
return t3r3_intersection_coplanar_aux(a,b,c,r,true,k);
|
return t3r3_intersection_coplanar_aux(a,b,c,r,true,k);
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// p,q,c are collinear
|
// p,q,c are collinear
|
||||||
if ( collinear_ordered(p,c,q) || collinear_ordered(p,q,c) )
|
if ( collinear_ordered(p,c,q) || collinear_ordered(p,q,c) )
|
||||||
|
|
@ -258,7 +248,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
if ( POSITIVE == pqc )
|
if ( POSITIVE == pqc )
|
||||||
// b is isolated on the negative side
|
// b is isolated on the negative side
|
||||||
|
|
@ -267,7 +257,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// a is isolated on the positive side (here mb c could be use as
|
// a is isolated on the positive side (here mb c could be use as
|
||||||
// an endpoint instead of computing an intersection is some cases)
|
// an endpoint instead of computing an intersection is some cases)
|
||||||
return t3r3_intersection_coplanar_aux(b,c,a,r,false,k);
|
return t3r3_intersection_coplanar_aux(b,c,a,r,false,k);
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -276,12 +266,12 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
return make_object(b);
|
return make_object(b);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// a is isolated on the positive side (here mb b could be use as
|
// a is isolated on the positive side (here mb b could be use as
|
||||||
// an endpoint instead of computing an intersection)
|
// an endpoint instead of computing an intersection)
|
||||||
return t3r3_intersection_coplanar_aux(b,c,a,r,false,k);
|
return t3r3_intersection_coplanar_aux(b,c,a,r,false,k);
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// b,c,p,q are aligned, [p,q]&[b,c] have the same direction
|
// b,c,p,q are aligned, [p,q]&[b,c] have the same direction
|
||||||
if ( collinear_ordered(p,b,c) )
|
if ( collinear_ordered(p,b,c) )
|
||||||
|
|
@ -289,15 +279,15 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return make_object(segment(p,c));
|
return make_object(segment(p,c));
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa NEGATIVE
|
// pqa NEGATIVE
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -308,18 +298,18 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// b is isolated on the positive side (here mb c could be use as
|
// b is isolated on the positive side (here mb c could be use as
|
||||||
// an endpoint instead of computing an intersection, in some cases)
|
// an endpoint instead of computing an intersection, in some cases)
|
||||||
return t3r3_intersection_coplanar_aux(c,a,b,r,false,k);
|
return t3r3_intersection_coplanar_aux(c,a,b,r,false,k);
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// c is isolated on the positive side
|
// c is isolated on the positive side
|
||||||
return t3r3_intersection_coplanar_aux(a,b,c,r,false,k);
|
return t3r3_intersection_coplanar_aux(a,b,c,r,false,k);
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// the triangle lies in the negative halfspace
|
// the triangle lies in the negative halfspace
|
||||||
// defined by the segment's supporting line.
|
// defined by the segment's supporting line.
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// p,q,c are collinear
|
// p,q,c are collinear
|
||||||
if ( collinear_ordered(p,c,q) || collinear_ordered(p,q,c) )
|
if ( collinear_ordered(p,c,q) || collinear_ordered(p,q,c) )
|
||||||
|
|
@ -327,21 +317,21 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// a is isolated on the negative side (here mb b could be use as
|
// a is isolated on the negative side (here mb b could be use as
|
||||||
// an endpoint instead of computing an intersection)
|
// an endpoint instead of computing an intersection)
|
||||||
return t3r3_intersection_coplanar_aux(b,c,a,r,true,k);
|
return t3r3_intersection_coplanar_aux(b,c,a,r,true,k);
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// p,q,b are collinear
|
// p,q,b are collinear
|
||||||
if ( collinear_ordered(p,b,q) || collinear_ordered(p,q,b) )
|
if ( collinear_ordered(p,b,q) || collinear_ordered(p,q,b) )
|
||||||
return make_object(b);
|
return make_object(b);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// b,c,p,q are aligned, [p,q]&[c,b] have the same direction
|
// b,c,p,q are aligned, [p,q]&[c,b] have the same direction
|
||||||
if ( collinear_ordered(p,c,b) )
|
if ( collinear_ordered(p,c,b) )
|
||||||
|
|
@ -349,15 +339,15 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return make_object(segment(p,b));
|
return make_object(segment(p,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa COLLINEAR
|
// pqa COLLINEAR
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -368,12 +358,12 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
return make_object(a);
|
return make_object(a);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// b is isolated on the positive side (here mb a could be use as
|
// b is isolated on the positive side (here mb a could be use as
|
||||||
// an endpoint instead of computing an intersection)
|
// an endpoint instead of computing an intersection)
|
||||||
return t3r3_intersection_coplanar_aux(c,a,b,r,false,k);
|
return t3r3_intersection_coplanar_aux(c,a,b,r,false,k);
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// a,c,p,q are aligned, [p,q]&[c,a] have the same direction
|
// a,c,p,q are aligned, [p,q]&[c,a] have the same direction
|
||||||
if ( collinear_ordered(p,c,a) )
|
if ( collinear_ordered(p,c,a) )
|
||||||
|
|
@ -381,21 +371,21 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return make_object(segment(p,a));
|
return make_object(segment(p,a));
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// b is isolated on the negative side (here mb a could be use as
|
// b is isolated on the negative side (here mb a could be use as
|
||||||
// an endpoint instead of computing an intersection)
|
// an endpoint instead of computing an intersection)
|
||||||
return t3r3_intersection_coplanar_aux(c,a,b,r,true,k);
|
return t3r3_intersection_coplanar_aux(c,a,b,r,true,k);
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// p,q,a are collinear
|
// p,q,a are collinear
|
||||||
if ( collinear_ordered(p,a,q) || collinear_ordered(p,q,a) )
|
if ( collinear_ordered(p,a,q) || collinear_ordered(p,q,a) )
|
||||||
return make_object(a);
|
return make_object(a);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// a,c,p,q are aligned, [p,q]&[a,c] have the same direction
|
// a,c,p,q are aligned, [p,q]&[a,c] have the same direction
|
||||||
if ( collinear_ordered(p,a,c) )
|
if ( collinear_ordered(p,a,c) )
|
||||||
|
|
@ -403,7 +393,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return make_object(segment(p,c));
|
return make_object(segment(p,c));
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -412,55 +402,55 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
return make_object(segment(a,b));
|
return make_object(segment(a,b));
|
||||||
else
|
else
|
||||||
return make_object(segment(p,b));
|
return make_object(segment(p,b));
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// a,b,p,q are aligned, [p,q]&[b,a] have the same direction
|
// a,b,p,q are aligned, [p,q]&[b,a] have the same direction
|
||||||
if ( collinear_ordered(p,b,a) )
|
if ( collinear_ordered(p,b,a) )
|
||||||
return make_object(segment(b,a));
|
return make_object(segment(b,a));
|
||||||
else
|
else
|
||||||
return make_object(segment(p,a));
|
return make_object(segment(p,a));
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// case pqc == COLLINEAR is impossible since the triangle is
|
// case pqc == COLLINEAR is impossible since the triangle is
|
||||||
// assumed to be non flat
|
// assumed to be non flat
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:// should not happen.
|
default:// should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
Object
|
Object
|
||||||
t3r3_intersection_aux(const typename K::Triangle_3 &t,
|
t3r3_intersection_aux(const typename K::Triangle_3 &t,
|
||||||
const typename K::Ray_3 &r,
|
const typename K::Ray_3 &r,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
typename K::Intersect_3 intersection =
|
typename K::Intersect_3 intersection =
|
||||||
k.intersect_3_object();
|
k.intersect_3_object();
|
||||||
|
|
||||||
Object obj = intersection(r.supporting_line(),t.supporting_plane());
|
Object obj = intersection(r.supporting_line(),t.supporting_plane());
|
||||||
|
|
||||||
// Intersection should be a point (because of orientation test done before)
|
// Intersection should be a point (because of orientation test done before)
|
||||||
if ( NULL == object_cast<typename K::Line_3>(&obj) )
|
if ( obj.is<typename K::Line_3>() )
|
||||||
return obj;
|
|
||||||
else
|
|
||||||
return Object();
|
return Object();
|
||||||
|
else
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Triangle_3 &t,
|
intersection(const typename K::Triangle_3 &t,
|
||||||
|
|
@ -469,22 +459,22 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
{
|
{
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ;
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename K::Orientation_3 orientation =
|
typename K::Orientation_3 orientation =
|
||||||
k.orientation_3_object();
|
k.orientation_3_object();
|
||||||
|
|
||||||
typename K::Construct_ray_3 ray =
|
typename K::Construct_ray_3 ray =
|
||||||
k.construct_ray_3_object();
|
k.construct_ray_3_object();
|
||||||
|
|
||||||
typename K::Construct_point_on_3 point_on =
|
typename K::Construct_point_on_3 point_on =
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
|
|
||||||
const Point_3& a = vertex_on(t,0);
|
const Point_3& a = vertex_on(t,0);
|
||||||
const Point_3& b = vertex_on(t,1);
|
const Point_3& b = vertex_on(t,1);
|
||||||
const Point_3& c = vertex_on(t,2);
|
const Point_3& c = vertex_on(t,2);
|
||||||
|
|
@ -492,18 +482,18 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
const Point_3& q = point_on(r,1);
|
const Point_3& q = point_on(r,1);
|
||||||
|
|
||||||
Point_3 d = point_on(ray(a,r.to_vector()),1);
|
Point_3 d = point_on(ray(a,r.to_vector()),1);
|
||||||
|
|
||||||
const Orientation ray_direction = orientation(a,b,c,d);
|
const Orientation ray_direction = orientation(a,b,c,d);
|
||||||
const Orientation abcp = orientation(a,b,c,p);
|
const Orientation abcp = orientation(a,b,c,p);
|
||||||
|
|
||||||
switch ( abcp ) {
|
switch ( abcp ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
switch ( ray_direction ) {
|
switch ( ray_direction ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// the ray lies in the positive open halfspaces defined by the
|
// the ray lies in the positive open halfspaces defined by the
|
||||||
// triangle's supporting plane
|
// triangle's supporting plane
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// The ray straddles the triangle's plane
|
// The ray straddles the triangle's plane
|
||||||
// p sees the triangle in counterclockwise order
|
// p sees the triangle in counterclockwise order
|
||||||
|
|
@ -513,46 +503,46 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return t3r3_intersection_aux(t,r,k);
|
return t3r3_intersection_aux(t,r,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
// The ray lie in a plane parallel to a,b,c support plane
|
// The ray lie in a plane parallel to a,b,c support plane
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( ray_direction ) {
|
switch ( ray_direction ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// The ray straddles the triangle's plane
|
// The ray straddles the triangle's plane
|
||||||
// q sees the triangle in counterclockwise order
|
// q sees the triangle in counterclockwise order
|
||||||
|
|
||||||
if ( orientation(q,p,a,b) != POSITIVE
|
if ( orientation(q,p,a,b) != POSITIVE
|
||||||
&& orientation(q,p,b,c) != POSITIVE
|
&& orientation(q,p,b,c) != POSITIVE
|
||||||
&& orientation(q,p,c,a) != POSITIVE )
|
&& orientation(q,p,c,a) != POSITIVE )
|
||||||
return t3r3_intersection_aux(t,r,k);
|
return t3r3_intersection_aux(t,r,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// the ray lies in the negative open halfspaces defined by the
|
// the ray lies in the negative open halfspaces defined by the
|
||||||
// triangle's supporting plane
|
// triangle's supporting plane
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
// The ray lie in a plane parallel to a,b,c support plane
|
// The ray lie in a plane parallel to a,b,c support plane
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
case COPLANAR: // p belongs to the triangle's supporting plane
|
case COPLANAR: // p belongs to the triangle's supporting plane
|
||||||
switch ( ray_direction ) {
|
switch ( ray_direction ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// q sees the triangle in counterclockwise order
|
// q sees the triangle in counterclockwise order
|
||||||
if ( orientation(q,p,a,b) != POSITIVE
|
if ( orientation(q,p,a,b) != POSITIVE
|
||||||
&& orientation(q,p,b,c) != POSITIVE
|
&& orientation(q,p,b,c) != POSITIVE
|
||||||
|
|
@ -560,7 +550,7 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return t3r3_intersection_aux(t,r,k);
|
return t3r3_intersection_aux(t,r,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// q sees the triangle in clockwise order
|
// q sees the triangle in clockwise order
|
||||||
if ( orientation(p,q,a,b) != POSITIVE
|
if ( orientation(p,q,a,b) != POSITIVE
|
||||||
|
|
@ -569,23 +559,22 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return t3r3_intersection_aux(t,r,k);
|
return t3r3_intersection_aux(t,r,k);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
// The ray lie in triangle supporting plane
|
// The ray lie in triangle supporting plane
|
||||||
return intersection_coplanar(t,r,k);
|
return intersection_coplanar(t,r,k);
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
}
|
||||||
}
|
|
||||||
|
CGAL_error();
|
||||||
CGAL_kernel_assertion(false);
|
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,41 +40,41 @@ t3s3_intersection_coplanar_aux(const typename K::Point_3& p,
|
||||||
const typename K::Point_3& a,
|
const typename K::Point_3& a,
|
||||||
const typename K::Point_3& b,
|
const typename K::Point_3& b,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
// Returns the intersection point between segment [p,q] and [a,b]
|
// Returns the intersection point between segment [p,q] and [a,b]
|
||||||
//
|
//
|
||||||
// preconditions:
|
// preconditions:
|
||||||
// + p,q,a,b are coplanar
|
// + p,q,a,b are coplanar
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
typedef typename K::Vector_3 Vector_3;
|
typedef typename K::Vector_3 Vector_3;
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
|
|
||||||
typename K::Construct_vector_3 vector =
|
typename K::Construct_vector_3 vector =
|
||||||
k.construct_vector_3_object();
|
k.construct_vector_3_object();
|
||||||
|
|
||||||
typename K::Construct_cross_product_vector_3 cross_product =
|
typename K::Construct_cross_product_vector_3 cross_product =
|
||||||
k.construct_cross_product_vector_3_object();
|
k.construct_cross_product_vector_3_object();
|
||||||
|
|
||||||
typename K::Compute_scalar_product_3 scalar_product =
|
typename K::Compute_scalar_product_3 scalar_product =
|
||||||
k.compute_scalar_product_3_object();
|
k.compute_scalar_product_3_object();
|
||||||
|
|
||||||
typename K::Compute_squared_length_3 sq_length =
|
typename K::Compute_squared_length_3 sq_length =
|
||||||
k.compute_squared_length_3_object();
|
k.compute_squared_length_3_object();
|
||||||
|
|
||||||
const Vector_3 pq = vector(p,q);
|
const Vector_3 pq = vector(p,q);
|
||||||
const Vector_3 ab = vector(a,b);
|
const Vector_3 ab = vector(a,b);
|
||||||
const Vector_3 pa = vector(p,a);
|
const Vector_3 pa = vector(p,a);
|
||||||
|
|
||||||
const Vector_3 pa_ab = cross_product(pa,ab);
|
const Vector_3 pa_ab = cross_product(pa,ab);
|
||||||
const Vector_3 pq_ab = cross_product(pq,ab);
|
const Vector_3 pq_ab = cross_product(pq,ab);
|
||||||
|
|
||||||
const FT t = scalar_product(pa_ab,pq_ab) / sq_length(pq_ab);
|
const FT t = scalar_product(pa_ab,pq_ab) / sq_length(pq_ab);
|
||||||
|
|
||||||
return ( p + t*pq );
|
return ( p + t*pq );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
t3s3_intersection_coplanar_aux(const typename K::Point_3& a,
|
t3s3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
|
|
@ -97,18 +97,18 @@ t3s3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
//
|
//
|
||||||
// We know that c is isolated on the negative side of pq, but we don't know
|
// We know that c is isolated on the negative side of pq, but we don't know
|
||||||
// p position wrt [bc]&[ca] and q position wrt [bc]&[ca]
|
// p position wrt [bc]&[ca] and q position wrt [bc]&[ca]
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
typename K::Coplanar_orientation_3 coplanar_orientation =
|
typename K::Coplanar_orientation_3 coplanar_orientation =
|
||||||
k.coplanar_orientation_3_object();
|
k.coplanar_orientation_3_object();
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
const Orientation bcq = coplanar_orientation(b,c,q);
|
const Orientation bcq = coplanar_orientation(b,c,q);
|
||||||
const Orientation cap = coplanar_orientation(c,a,p);
|
const Orientation cap = coplanar_orientation(c,a,p);
|
||||||
|
|
||||||
if ( NEGATIVE == bcq || NEGATIVE == cap )
|
if ( NEGATIVE == bcq || NEGATIVE == cap )
|
||||||
return Object();
|
return Object();
|
||||||
else if ( COLLINEAR == bcq )
|
else if ( COLLINEAR == bcq )
|
||||||
|
|
@ -126,7 +126,7 @@ t3s3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
{
|
{
|
||||||
p_side_end_point = t3s3_intersection_coplanar_aux(p,q,b,c,k);
|
p_side_end_point = t3s3_intersection_coplanar_aux(p,q,b,c,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point_3 q_side_end_point(q);
|
Point_3 q_side_end_point(q);
|
||||||
if ( NEGATIVE == coplanar_orientation(c,a,q) )
|
if ( NEGATIVE == coplanar_orientation(c,a,q) )
|
||||||
{
|
{
|
||||||
|
|
@ -137,27 +137,27 @@ t3s3_intersection_coplanar_aux(const typename K::Point_3& a,
|
||||||
return make_object(segment(p_side_end_point, q_side_end_point));
|
return make_object(segment(p_side_end_point, q_side_end_point));
|
||||||
else
|
else
|
||||||
return make_object(segment(q_side_end_point, p_side_end_point));
|
return make_object(segment(q_side_end_point, p_side_end_point));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
t3s3_intersection_collinear_aux(const typename K::Point_3& a,
|
t3s3_intersection_collinear_aux(const typename K::Point_3& a,
|
||||||
const typename K::Point_3& b,
|
const typename K::Point_3& b,
|
||||||
const typename K::Point_3& p,
|
const typename K::Point_3& p,
|
||||||
const typename K::Point_3& q,
|
const typename K::Point_3& q,
|
||||||
const K& k)
|
const K& k)
|
||||||
{
|
{
|
||||||
// Builds resulting segment of intersection of [a,b] and [p,q]
|
// Builds resulting segment of intersection of [a,b] and [p,q]
|
||||||
// Precondition: [a,b] and [p,q] have the same direction
|
// Precondition: [a,b] and [p,q] have the same direction
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
typename K::Collinear_are_ordered_along_line_3 collinear_ordered =
|
typename K::Collinear_are_ordered_along_line_3 collinear_ordered =
|
||||||
k.collinear_are_ordered_along_line_3_object();
|
k.collinear_are_ordered_along_line_3_object();
|
||||||
|
|
||||||
// possible orders: [p,a,b,q], [p,a,q,b], [a,p,b,q], [a,p,q,b]
|
// possible orders: [p,a,b,q], [p,a,q,b], [a,p,b,q], [a,p,q,b]
|
||||||
if ( collinear_ordered(p,a,q) )
|
if ( collinear_ordered(p,a,q) )
|
||||||
{
|
{
|
||||||
|
|
@ -175,52 +175,52 @@ t3s3_intersection_collinear_aux(const typename K::Point_3& a,
|
||||||
else
|
else
|
||||||
return make_object(segment(p,q));
|
return make_object(segment(p,q));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection_coplanar(const typename K::Triangle_3 &t,
|
intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
const typename K::Segment_3 &s,
|
const typename K::Segment_3 &s,
|
||||||
const K & k )
|
const K & k )
|
||||||
{
|
{
|
||||||
|
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(s) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(s) ) ;
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
|
|
||||||
typename K::Construct_point_on_3 point_on =
|
typename K::Construct_point_on_3 point_on =
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename K::Coplanar_orientation_3 coplanar_orientation =
|
typename K::Coplanar_orientation_3 coplanar_orientation =
|
||||||
k.coplanar_orientation_3_object();
|
k.coplanar_orientation_3_object();
|
||||||
|
|
||||||
typename K::Collinear_are_ordered_along_line_3 collinear_ordered =
|
typename K::Collinear_are_ordered_along_line_3 collinear_ordered =
|
||||||
k.collinear_are_ordered_along_line_3_object();
|
k.collinear_are_ordered_along_line_3_object();
|
||||||
|
|
||||||
typename K::Construct_line_3 line =
|
typename K::Construct_line_3 line =
|
||||||
k.construct_line_3_object();
|
k.construct_line_3_object();
|
||||||
|
|
||||||
typename K::Construct_segment_3 segment =
|
typename K::Construct_segment_3 segment =
|
||||||
k.construct_segment_3_object();
|
k.construct_segment_3_object();
|
||||||
|
|
||||||
|
|
||||||
const Point_3 & p = point_on(s,0);
|
const Point_3 & p = point_on(s,0);
|
||||||
const Point_3 & q = point_on(s,1);
|
const Point_3 & q = point_on(s,1);
|
||||||
|
|
||||||
const Point_3 & A = vertex_on(t,0);
|
const Point_3 & A = vertex_on(t,0);
|
||||||
const Point_3 & B = vertex_on(t,1);
|
const Point_3 & B = vertex_on(t,1);
|
||||||
const Point_3 & C = vertex_on(t,2);
|
const Point_3 & C = vertex_on(t,2);
|
||||||
|
|
||||||
int k0 = 0;
|
int k0 = 0;
|
||||||
int k1 = 1;
|
int k1 = 1;
|
||||||
int k2 = 2;
|
int k2 = 2;
|
||||||
|
|
||||||
// Determine the orientation of the triangle in the common plane
|
// Determine the orientation of the triangle in the common plane
|
||||||
if (coplanar_orientation(A,B,C) != POSITIVE)
|
if (coplanar_orientation(A,B,C) != POSITIVE)
|
||||||
{
|
{
|
||||||
|
|
@ -228,21 +228,21 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// swap two vertices.
|
// swap two vertices.
|
||||||
std::swap(k1,k2);
|
std::swap(k1,k2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Point_3& a = vertex_on(t,k0);
|
const Point_3& a = vertex_on(t,k0);
|
||||||
const Point_3& b = vertex_on(t,k1);
|
const Point_3& b = vertex_on(t,k1);
|
||||||
const Point_3& c = vertex_on(t,k2);
|
const Point_3& c = vertex_on(t,k2);
|
||||||
|
|
||||||
// Test whether the segment's supporting line intersects the
|
// Test whether the segment's supporting line intersects the
|
||||||
// triangle in the common plane
|
// triangle in the common plane
|
||||||
const Orientation pqa = coplanar_orientation(p,q,a);
|
const Orientation pqa = coplanar_orientation(p,q,a);
|
||||||
const Orientation pqb = coplanar_orientation(p,q,b);
|
const Orientation pqb = coplanar_orientation(p,q,b);
|
||||||
const Orientation pqc = coplanar_orientation(p,q,c);
|
const Orientation pqc = coplanar_orientation(p,q,c);
|
||||||
|
|
||||||
switch ( pqa ) {
|
switch ( pqa ) {
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa POSITIVE
|
// pqa POSITIVE
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -260,7 +260,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
if ( POSITIVE == pqc )
|
if ( POSITIVE == pqc )
|
||||||
// b is isolated on the negative side
|
// b is isolated on the negative side
|
||||||
|
|
@ -283,15 +283,15 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// b,c,p,q are aligned, [p,q]&[b,c] have the same direction
|
// b,c,p,q are aligned, [p,q]&[b,c] have the same direction
|
||||||
return t3s3_intersection_collinear_aux(b,c,p,q,k);
|
return t3s3_intersection_collinear_aux(b,c,p,q,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa NEGATIVE
|
// pqa NEGATIVE
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -301,7 +301,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
// b is isolated on the positive side
|
// b is isolated on the positive side
|
||||||
return t3s3_intersection_coplanar_aux(c,a,b,q,p,false,k);
|
return t3s3_intersection_coplanar_aux(c,a,b,q,p,false,k);
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -317,12 +317,12 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
// a is isolated on the negative side
|
// a is isolated on the negative side
|
||||||
return t3s3_intersection_coplanar_aux(b,c,a,p,q,true,k);
|
return t3s3_intersection_coplanar_aux(b,c,a,p,q,true,k);
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
if ( collinear_ordered(p,b,q) ) // b is inside [p,q]
|
if ( collinear_ordered(p,b,q) ) // b is inside [p,q]
|
||||||
return make_object(b);
|
return make_object(b);
|
||||||
|
|
@ -332,15 +332,15 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// b,c,p,q are aligned, [p,q]&[c,b] have the same direction
|
// b,c,p,q are aligned, [p,q]&[c,b] have the same direction
|
||||||
return t3s3_intersection_collinear_aux(c,b,p,q,k);
|
return t3s3_intersection_collinear_aux(c,b,p,q,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// pqa COLLINEAR
|
// pqa COLLINEAR
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqb ) {
|
switch ( pqb ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -357,7 +357,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// a,c,p,q are aligned, [p,q]&[c,a] have the same direction
|
// a,c,p,q are aligned, [p,q]&[c,a] have the same direction
|
||||||
return t3s3_intersection_collinear_aux(c,a,p,q,k);
|
return t3s3_intersection_collinear_aux(c,a,p,q,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -372,7 +372,7 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
// a,c,p,q are aligned, [p,q]&[a,c] have the same direction
|
// a,c,p,q are aligned, [p,q]&[a,c] have the same direction
|
||||||
return t3s3_intersection_collinear_aux(a,c,p,q,k);
|
return t3s3_intersection_collinear_aux(a,c,p,q,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
switch ( pqc ) {
|
switch ( pqc ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
|
|
@ -384,59 +384,54 @@ intersection_coplanar(const typename K::Triangle_3 &t,
|
||||||
case COLLINEAR:
|
case COLLINEAR:
|
||||||
// case pqc == COLLINEAR is impossible since the triangle is
|
// case pqc == COLLINEAR is impossible since the triangle is
|
||||||
// assumed to be non flat
|
// assumed to be non flat
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:// should not happen.
|
default:// should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Triangle_3 &t,
|
intersection(const typename K::Triangle_3 &t,
|
||||||
const typename K::Segment_3 &s,
|
const typename K::Segment_3 &s,
|
||||||
const K & k)
|
const K & k)
|
||||||
{
|
{
|
||||||
|
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
|
||||||
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(s) ) ;
|
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(s) ) ;
|
||||||
|
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
|
||||||
|
typename K::Construct_point_on_3 point_on =
|
||||||
typename K::Construct_point_on_3 point_on =
|
|
||||||
k.construct_point_on_3_object();
|
k.construct_point_on_3_object();
|
||||||
|
|
||||||
typename K::Construct_vertex_3 vertex_on =
|
typename K::Construct_vertex_3 vertex_on =
|
||||||
k.construct_vertex_3_object();
|
k.construct_vertex_3_object();
|
||||||
|
|
||||||
typename K::Orientation_3 orientation =
|
typename K::Orientation_3 orientation =
|
||||||
k.orientation_3_object();
|
k.orientation_3_object();
|
||||||
|
|
||||||
typename K::Intersect_3 intersection =
|
typename K::Intersect_3 intersection =
|
||||||
k.intersect_3_object();
|
k.intersect_3_object();
|
||||||
|
|
||||||
const Point_3 & a = vertex_on(t,0);
|
const Point_3 & a = vertex_on(t,0);
|
||||||
const Point_3 & b = vertex_on(t,1);
|
const Point_3 & b = vertex_on(t,1);
|
||||||
const Point_3 & c = vertex_on(t,2);
|
const Point_3 & c = vertex_on(t,2);
|
||||||
const Point_3 & p = point_on(s,0);
|
const Point_3 & p = point_on(s,0);
|
||||||
const Point_3 & q = point_on(s,1);
|
const Point_3 & q = point_on(s,1);
|
||||||
|
|
||||||
|
|
||||||
const Orientation abcp = orientation(a,b,c,p);
|
const Orientation abcp = orientation(a,b,c,p);
|
||||||
const Orientation abcq = orientation(a,b,c,q);
|
const Orientation abcq = orientation(a,b,c,q);
|
||||||
|
|
||||||
switch ( abcp ) {
|
switch ( abcp ) {
|
||||||
case POSITIVE:
|
case POSITIVE:
|
||||||
switch ( abcq ) {
|
switch ( abcq ) {
|
||||||
|
|
@ -444,23 +439,23 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
// the segment lies in the positive open halfspaces defined by the
|
// the segment lies in the positive open halfspaces defined by the
|
||||||
// triangle's supporting plane
|
// triangle's supporting plane
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// p sees the triangle in counterclockwise order
|
// p sees the triangle in counterclockwise order
|
||||||
if ( orientation(p,q,a,b) != POSITIVE
|
if ( orientation(p,q,a,b) != POSITIVE
|
||||||
&& orientation(p,q,b,c) != POSITIVE
|
&& orientation(p,q,b,c) != POSITIVE
|
||||||
&& orientation(p,q,c,a) != POSITIVE )
|
&& orientation(p,q,c,a) != POSITIVE )
|
||||||
{
|
{
|
||||||
// The intersection should be a point
|
// The intersection should be a point
|
||||||
Object obj = intersection(s.supporting_line(),t.supporting_plane());
|
Object obj = intersection(s.supporting_line(),t.supporting_plane());
|
||||||
if ( NULL == object_cast<typename K::Line_3>(&obj) )
|
if ( obj.is<typename K::Line_3>() )
|
||||||
return obj;
|
|
||||||
else
|
|
||||||
return Object();
|
return Object();
|
||||||
|
else
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
// q belongs to the triangle's supporting plane
|
// q belongs to the triangle's supporting plane
|
||||||
// p sees the triangle in counterclockwise order
|
// p sees the triangle in counterclockwise order
|
||||||
|
|
@ -470,9 +465,9 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return make_object(q);
|
return make_object(q);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
|
|
@ -482,21 +477,21 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
if ( orientation(q,p,a,b) != POSITIVE
|
if ( orientation(q,p,a,b) != POSITIVE
|
||||||
&& orientation(q,p,b,c) != POSITIVE
|
&& orientation(q,p,b,c) != POSITIVE
|
||||||
&& orientation(q,p,c,a) != POSITIVE )
|
&& orientation(q,p,c,a) != POSITIVE )
|
||||||
{
|
{
|
||||||
Object obj = intersection(s.supporting_line(),t.supporting_plane());
|
Object obj = intersection(s.supporting_line(),t.supporting_plane());
|
||||||
if ( NULL == object_cast<typename K::Line_3>(&obj) )
|
if ( obj.is<typename K::Line_3>() )
|
||||||
return obj;
|
|
||||||
else
|
|
||||||
return Object();
|
return Object();
|
||||||
|
else
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// the segment lies in the negative open halfspaces defined by the
|
// the segment lies in the negative open halfspaces defined by the
|
||||||
// triangle's supporting plane
|
// triangle's supporting plane
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
// q belongs to the triangle's supporting plane
|
// q belongs to the triangle's supporting plane
|
||||||
// p sees the triangle in clockwise order
|
// p sees the triangle in clockwise order
|
||||||
|
|
@ -506,9 +501,9 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return make_object(q);
|
return make_object(q);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
case COPLANAR: // p belongs to the triangle's supporting plane
|
case COPLANAR: // p belongs to the triangle's supporting plane
|
||||||
|
|
@ -521,7 +516,7 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return make_object(p);
|
return make_object(p);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
// q sees the triangle in clockwise order
|
// q sees the triangle in clockwise order
|
||||||
if ( orientation(p,q,a,b) != POSITIVE
|
if ( orientation(p,q,a,b) != POSITIVE
|
||||||
|
|
@ -530,34 +525,34 @@ intersection(const typename K::Triangle_3 &t,
|
||||||
return make_object(p);
|
return make_object(p);
|
||||||
else
|
else
|
||||||
return Object();
|
return Object();
|
||||||
|
|
||||||
case COPLANAR:
|
case COPLANAR:
|
||||||
// the segment is coplanar with the triangle's supporting plane
|
// the segment is coplanar with the triangle's supporting plane
|
||||||
// we test whether the segment intersects the triangle in the common
|
// we test whether the segment intersects the triangle in the common
|
||||||
// supporting plane
|
// supporting plane
|
||||||
return intersection_coplanar(t,s,k);
|
return intersection_coplanar(t,s,k);
|
||||||
|
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
default: // should not happen.
|
default: // should not happen.
|
||||||
CGAL_kernel_assertion(false);
|
CGAL_error();
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
inline
|
inline
|
||||||
Object
|
Object
|
||||||
intersection(const typename K::Segment_3 &s,
|
intersection(const typename K::Segment_3 &s,
|
||||||
const typename K::Triangle_3 &t,
|
const typename K::Triangle_3 &t,
|
||||||
const K & k)
|
const K & k)
|
||||||
{
|
{
|
||||||
return internal::intersection(t,s,k);
|
return internal::intersection(t,s,k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
|
|
@ -579,4 +574,3 @@ intersection(const Segment_3<K> &s, const Triangle_3<K> &t)
|
||||||
} // end namespace CGAL
|
} // end namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_INTERNAL_INTERSECTIONS_3_TRIANGLE_3_SEGMENT_3_INTERSECTION_H
|
#endif // CGAL_INTERNAL_INTERSECTIONS_3_TRIANGLE_3_SEGMENT_3_INTERSECTION_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Bbox_3_do_intersect.h>
|
||||||
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Ray_3_do_intersect.h>
|
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Ray_3_do_intersect.h>
|
||||||
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Line_3_do_intersect.h>
|
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Line_3_do_intersect.h>
|
||||||
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Segment_3_do_intersect.h>
|
#include <CGAL/internal/AABB_Intersections_3/Bbox_3_Segment_3_do_intersect.h>
|
||||||
|
|
@ -271,6 +272,9 @@ bool test()
|
||||||
test_aux(line2, "line2", bbox2, false);
|
test_aux(line2, "line2", bbox2, false);
|
||||||
test_aux(line3, "line3", bbox3, true);
|
test_aux(line3, "line3", bbox3, true);
|
||||||
test_aux(line4, "line4", bbox4, false);
|
test_aux(line4, "line4", bbox4, false);
|
||||||
|
|
||||||
|
// Use do_intersect(bbox,bbox)
|
||||||
|
CGAL::do_intersect(bbox2,bbox4);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue