BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Triangle_3_Tetrahedron_3_do_intersect.h
Go to the documentation of this file.
00001 // Copyright (c) 2005  Utrecht University (The Netherlands),
00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
00005 // and Tel-Aviv University (Israel).  All rights reserved.
00006 //
00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License as
00009 // published by the Free Software Foundation; version 2.1 of the License.
00010 // See the file LICENSE.LGPL distributed with CGAL.
00011 //
00012 // Licensees holding a valid commercial license may use this file in
00013 // accordance with the commercial license agreement provided with the software.
00014 //
00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 //
00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Intersections_3/include/CGAL/Triangle_3_Tetrahedron_3_do_intersect.h $
00019 // $Id: Triangle_3_Tetrahedron_3_do_intersect.h 45156 2008-08-26 13:40:26Z spion $
00020 // 
00021 //
00022 // Author(s)     : Nico Kruithof
00023 
00024 #ifndef CGAL_TRIANGLE_3_TETRAHEDRON_3_DO_INTERSECT_H
00025 #define CGAL_TRIANGLE_3_TETRAHEDRON_3_DO_INTERSECT_H
00026 
00027 #include <CGAL/Triangle_3_Triangle_3_do_intersect.h>
00028 
00029 CGAL_BEGIN_NAMESPACE
00030 
00031 namespace CGALi {
00032 
00033 // This code is not optimized:
00034 template <class K>
00035 typename K::Boolean
00036 do_intersect(const typename K::Triangle_3 &tr,
00037              const typename K::Tetrahedron_3 &tet,
00038              const K & k)
00039 {
00040     typedef typename K::Triangle_3 Triangle;
00041     typedef typename K::Point_3    Point;
00042 
00043     CGAL_kernel_precondition( ! k.is_degenerate_3_object() (tr) );
00044     CGAL_kernel_precondition( ! k.is_degenerate_3_object() (tet) );
00045 
00046     if (do_intersect(tr, Triangle(tet[0], tet[1], tet[2]), k)) return true;
00047     if (do_intersect(tr, Triangle(tet[0], tet[1], tet[3]), k)) return true;
00048     if (do_intersect(tr, Triangle(tet[0], tet[2], tet[3]), k)) return true;
00049     if (do_intersect(tr, Triangle(tet[1], tet[2], tet[3]), k)) return true;
00050 
00051     CGAL_kernel_assertion(k.bounded_side_3_object()(tet, tr[0]) ==
00052                           k.bounded_side_3_object()(tet, tr[1]));
00053     CGAL_kernel_assertion(k.bounded_side_3_object()(tet, tr[0]) ==
00054                           k.bounded_side_3_object()(tet, tr[2]));
00055 
00056     return k.has_on_bounded_side_3_object()(tet, tr[0]);
00057 }
00058 
00059 
00060 template <class K>
00061 inline
00062 typename K::Boolean
00063 do_intersect(const typename K::Tetrahedron_3 &tet,
00064              const typename K::Triangle_3 &tr,
00065              const K & k)
00066 {
00067   return do_intersect(tr, tet, k);
00068 }
00069 
00070 } // namespace CGALi
00071 
00072 
00073 
00074 template <class K>
00075 inline bool do_intersect(const Tetrahedron_3<K> &tet,
00076                          const Triangle_3<K> &tr)
00077 {
00078   return typename K::Do_intersect_3()(tr,tet);
00079 }
00080 
00081 template <class K>
00082 inline bool do_intersect(const Triangle_3<K> &tr,
00083                          const Tetrahedron_3<K> &tet)
00084 {
00085   return typename K::Do_intersect_3()(tr,tet);
00086 }
00087 
00088 CGAL_END_NAMESPACE
00089 
00090 #endif // CGAL_TRIANGLE_3_TETRAHEDRON_3_DO_INTERSECT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines