BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Triangle_3_Plane_3_do_intersect.h
Go to the documentation of this file.
00001 // Copyright (c) 2003  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License as
00006 // published by the Free Software Foundation; version 2.1 of the License.
00007 // See the file LICENSE.LGPL distributed with CGAL.
00008 //
00009 // Licensees holding a valid commercial license may use this file in
00010 // accordance with the commercial license agreement provided with the software.
00011 //
00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 //
00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Intersections_3/include/CGAL/Triangle_3_Plane_3_do_intersect.h $
00016 // $Id: Triangle_3_Plane_3_do_intersect.h 39776 2007-08-08 15:15:20Z spion $
00017 // 
00018 //
00019 // Author(s)     : Philippe Guigue
00020 
00021 #ifndef CGAL_TRIANGLE_3_PLANE_3_DO_INTERSECT_H
00022 #define CGAL_TRIANGLE_3_PLANE_3_DO_INTERSECT_H
00023 
00024 CGAL_BEGIN_NAMESPACE
00025 
00026 namespace CGALi {
00027 
00028 template <class K>
00029 bool do_intersect(const typename K::Triangle_3 &t, 
00030                   const typename K::Plane_3   &h,
00031                   const K & k)
00032 {
00033   
00034   CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t)) ;
00035   CGAL_kernel_precondition( ! k.is_degenerate_3_object()(h)) ;
00036 
00037    
00038   typename K::Construct_vertex_3 vertex_on =
00039     k.construct_vertex_3_object();
00040   
00041   typename K::Oriented_side_3 oriented_side =
00042     k.oriented_side_3_object();
00043 
00044   
00045 
00046   switch ( oriented_side(h,vertex_on(t,0)) ) {
00047   case ON_POSITIVE_SIDE:
00048     return oriented_side(h,vertex_on(t,1)) != ON_POSITIVE_SIDE
00049       || oriented_side(h,vertex_on(t,2)) != ON_POSITIVE_SIDE;
00050   case ON_NEGATIVE_SIDE:
00051     return oriented_side(h,vertex_on(t,1)) != ON_NEGATIVE_SIDE
00052       || oriented_side(h,vertex_on(t,2)) != ON_NEGATIVE_SIDE ;
00053   case ON_ORIENTED_BOUNDARY:
00054     return true;
00055   default:// should not happen.
00056     CGAL_kernel_assertion(false);
00057     return false;
00058   }
00059 }
00060 
00061 
00062 template <class K>
00063 inline
00064 bool do_intersect(const typename K::Plane_3   &h,
00065                   const typename K::Triangle_3 &t, 
00066                   const K & k)
00067 {
00068   return do_intersect(t, h, k);
00069 }
00070 
00071 
00072 } // namespace CGALi
00073 
00074 
00075 template <class K>
00076 inline bool do_intersect(const Triangle_3<K> &t, 
00077                          const Plane_3<K>    &h)
00078 {
00079   return typename K::Do_intersect_3()(t,h);
00080 }
00081   
00082 template <class K>
00083 inline bool do_intersect(const Plane_3<K>    &h, 
00084                          const Triangle_3<K> &t)
00085 {
00086   return typename K::Do_intersect_3()(t,h);
00087 }
00088 
00089 /*
00090 template <class K>
00091 inline bool do_intersect(const Plane_3<K>    &h, 
00092                          const Triangle_3<K> &t,
00093                          const K & k)
00094 {
00095   return do_intersect(t,h,k);
00096 }
00097 */
00098 
00099 
00100 CGAL_END_NAMESPACE
00101 
00102 #endif //CGAL_TRIANGLE_3_PLANE_3_DO_INTERSECT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines