BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Tetrahedron_3.h
Go to the documentation of this file.
00001 // Copyright (c) 1999  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/Kernel_23/include/CGAL/Tetrahedron_3.h $
00019 // $Id: Tetrahedron_3.h 42932 2008-04-17 10:13:31Z spion $
00020 //
00021 //
00022 // Author(s)     : Andreas Fabri, Stefan Schirra
00023 
00024 #ifndef CGAL_TETRAHEDRON_3_H
00025 #define CGAL_TETRAHEDRON_3_H
00026 
00027 #include <boost/static_assert.hpp>
00028 #include <boost/type_traits.hpp>
00029 #include <CGAL/Kernel/Return_base_tag.h>
00030 #include <CGAL/Bbox_3.h>
00031 #include <CGAL/Dimension.h>
00032 
00033 CGAL_BEGIN_NAMESPACE
00034 
00035 template <class R_>
00036 class Tetrahedron_3 : public R_::Kernel_base::Tetrahedron_3
00037 {
00038   typedef typename R_::Point_3             Point_3;
00039   typedef typename R_::Aff_transformation_3  Aff_transformation_3;
00040 
00041   typedef Tetrahedron_3                      Self;
00042   BOOST_STATIC_ASSERT((boost::is_same<Self, typename R_::Tetrahedron_3>::value));
00043 
00044 public:
00045 
00046   typedef Dimension_tag<3>  Ambient_dimension;
00047   typedef Dimension_tag<3>  Feature_dimension;
00048 
00049   typedef typename R_::Kernel_base::Tetrahedron_3  Rep;
00050 
00051   const Rep& rep() const
00052   {
00053     return *this;
00054   }
00055 
00056   Rep& rep()
00057   {
00058     return *this;
00059   }
00060 
00061   typedef          R_                       R;
00062 
00063   Tetrahedron_3() {}
00064 
00065   Tetrahedron_3(const Rep& t)
00066       : Rep(t) {}
00067 
00068   Tetrahedron_3(const Point_3& p, const Point_3& q,
00069                 const Point_3& r, const Point_3& s)
00070     : Rep(typename R::Construct_tetrahedron_3()(Return_base_tag(), p, q, r, s)) {}
00071 
00072   Tetrahedron_3 transform(const Aff_transformation_3 &t) const
00073   {
00074     return Tetrahedron_3(t.transform(this->vertex(0)),
00075                          t.transform(this->vertex(1)),
00076                          t.transform(this->vertex(2)),
00077                          t.transform(this->vertex(3)));
00078   }
00079 
00080   // FIXME TODO : Why doesn't Qrt work here ???
00081   //typename Qualified_result_of<typename R::Construct_vertex_3, Tetrahedron_3, int>::type
00082   Point_3
00083   vertex(int i) const
00084   {
00085     return R().construct_vertex_3_object()(*this,i);
00086   }
00087 
00088   //typename Qualified_result_of<typename R::Construct_vertex_3, Tetrahedron_3, int>::type
00089   Point_3
00090   operator[](int i) const
00091   {
00092     return vertex(i);
00093   }
00094 
00095   bool
00096   is_degenerate() const
00097   {
00098     return R().is_degenerate_3_object()(*this);
00099   }
00100 
00101   Orientation orientation() const
00102   {
00103     return R().orientation_3_object()(*this);
00104   }
00105 
00106   Bounded_side bounded_side(const Point_3 &p) const
00107   {
00108     return R().bounded_side_3_object()(*this, p);
00109   }
00110 
00111   Oriented_side oriented_side(const Point_3 &p) const
00112   {
00113     return R().oriented_side_3_object()(*this, p);
00114   }
00115 
00116   bool has_on_positive_side(const Point_3 &p) const
00117   {
00118     return R().has_on_positive_side_3_object()(*this, p);
00119   }
00120 
00121   bool has_on_negative_side(const Point_3 &p) const
00122   {
00123     return R().has_on_negative_side_3_object()(*this, p);
00124   }
00125 
00126   bool has_on_boundary(const Point_3 &p) const
00127   {
00128     return R().has_on_boundary_3_object()(*this, p);
00129   }
00130 
00131   bool has_on_bounded_side(const Point_3 &p) const
00132   {
00133     return R().has_on_bounded_side_3_object()(*this, p);
00134   }
00135 
00136   bool has_on_unbounded_side(const Point_3 &p) const
00137   {
00138     return R().has_on_unbounded_side_3_object()(*this, p);
00139   }
00140 
00141   typename Qualified_result_of<typename R::Compute_volume_3, Tetrahedron_3>::type
00142   volume() const
00143   {
00144     return R().compute_volume_3_object()(*this);
00145   }
00146 
00147   Bbox_3
00148   bbox() const
00149   {
00150     return R().construct_bbox_3_object()(*this);
00151   }
00152 
00153 };
00154 
00155 
00156 template < class R >
00157 std::ostream &
00158 operator<<(std::ostream &os, const Tetrahedron_3<R> &t)
00159 {
00160     switch(os.iword(IO::mode)) {
00161     case IO::ASCII :
00162         return os << t[0] << ' ' << t[1] << ' ' << t[2] << ' ' << t[3];
00163     case IO::BINARY :
00164         return os << t[0]  << t[1]  << t[2] << t[3];
00165     default:
00166         os << "Tetrahedron_3(" << t[0] <<  ", " << t[1] <<   ", " << t[2];
00167         os <<  ", " << t[3] << ")";
00168         return os;
00169     }
00170 }
00171 
00172 template < class R >
00173 std::istream &
00174 operator>>(std::istream &is, Tetrahedron_3<R> &t)
00175 {
00176     typename R::Point_3 p, q, r, s;
00177 
00178     is >> p >> q >> r >> s;
00179 
00180     if (is)
00181         t = Tetrahedron_3<R>(p, q, r, s);
00182     return is;
00183 }
00184 
00185 CGAL_END_NAMESPACE
00186 
00187 #endif  // CGAL_TETRAHEDRON_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines