BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Iso_cuboid_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/Iso_cuboid_3.h $
00019 // $Id: Iso_cuboid_3.h 42932 2008-04-17 10:13:31Z spion $
00020 //
00021 //
00022 // Author(s)     : Stefan Schirra
00023 
00024 #ifndef CGAL_ISO_CUBOID_3_H
00025 #define CGAL_ISO_CUBOID_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 Iso_cuboid_3 : public R_::Kernel_base::Iso_cuboid_3
00037 {
00038   typedef typename R_::RT                 RT;
00039   typedef typename R_::Point_3            Point_3;
00040   typedef typename R_::Aff_transformation_3  Aff_transformation_3;
00041 
00042   typedef Iso_cuboid_3                    Self;
00043   BOOST_STATIC_ASSERT((boost::is_same<Self, typename R_::Iso_cuboid_3>::value));
00044 
00045 public:
00046 
00047   typedef Dimension_tag<3>  Ambient_dimension;
00048   typedef Dimension_tag<3>  Feature_dimension;
00049 
00050   typedef typename R_::Kernel_base::Iso_cuboid_3  Rep;
00051 
00052   const Rep& rep() const
00053   {
00054     return *this;
00055   }
00056 
00057   Rep& rep()
00058   {
00059     return *this;
00060   }
00061 
00062   typedef          R_                    R;
00063 
00064   Iso_cuboid_3() {}
00065 
00066   Iso_cuboid_3(const Rep&  r)
00067       : Rep(r) {}
00068 
00069   Iso_cuboid_3(const Point_3& p, const Point_3& q)
00070    : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), p,q)) {}
00071 
00072   Iso_cuboid_3(const Point_3& p, const Point_3& q, int)
00073    : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), p, q, 0)) {}
00074 
00075   Iso_cuboid_3(const Point_3 &left,   const Point_3 &right,
00076                const Point_3 &bottom, const Point_3 &top,
00077                const Point_3 &far_,   const Point_3 &close)
00078    : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), left, right, bottom,
00079                                                     top, far_, close)) {}
00080 
00081   Iso_cuboid_3(const RT& min_hx, const RT& min_hy, const RT& min_hz,
00082                const RT& max_hx, const RT& max_hy, const RT& max_hz,
00083                const RT& hw)
00084    : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), min_hx, min_hy, min_hz,
00085                                      max_hx, max_hy, max_hz, hw)) {}
00086 
00087   Iso_cuboid_3(const RT& min_hx, const RT& min_hy, const RT& min_hz,
00088                const RT& max_hx, const RT& max_hy, const RT& max_hz)
00089    : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), min_hx, min_hy, min_hz,
00090                                              max_hx, max_hy, max_hz)) {}
00091 
00092 // TODO FIXME : why is Qrt not working here ?
00093 // TODO       : the Cartesian and Homogeneous functors should be split here
00094 //              given that the Qrt differs.
00095 //              (or is the Homogeneous optimization simply not worth it ?)
00096   //typename Qualified_result_of<typename R::Construct_min_vertex_3, Iso_cuboid_3 >::type
00097   Point_3
00098   min BOOST_PREVENT_MACRO_SUBSTITUTION () const
00099   {
00100     return R().construct_min_vertex_3_object()(*this);
00101   }
00102 
00103   //typename Qualified_result_of<typename R::Construct_max_vertex_3, Iso_cuboid_3 >::type
00104   Point_3
00105   max BOOST_PREVENT_MACRO_SUBSTITUTION () const
00106   {
00107     return R().construct_max_vertex_3_object()(*this);
00108   }
00109 
00110   //typename Qualified_result_of<typename R::Construct_vertex_3, Iso_cuboid_3 >::type
00111   Point_3
00112   vertex(int i) const
00113   {
00114     return R().construct_vertex_3_object()(*this,i);
00115   }
00116 
00117   //typename Qualified_result_of<typename R::Construct_vertex_3, Iso_cuboid_3 >::type
00118   Point_3
00119   operator[](int i) const
00120   {
00121     return R().construct_vertex_3_object()(*this,i);
00122   }
00123 
00124   typename Qualified_result_of<typename R::Compute_xmin_3, Iso_cuboid_3 >::type
00125   xmin() const
00126   {
00127     return R().compute_xmin_3_object()(*this);
00128   }
00129 
00130   typename Qualified_result_of<typename R::Compute_xmax_3, Iso_cuboid_3 >::type
00131   xmax() const
00132   {
00133     return R().compute_xmax_3_object()(*this);
00134   }
00135 
00136   typename Qualified_result_of<typename R::Compute_ymin_3, Iso_cuboid_3 >::type
00137   ymin() const
00138   {
00139     return R().compute_ymin_3_object()(*this);
00140   }
00141 
00142   typename Qualified_result_of<typename R::Compute_ymax_3, Iso_cuboid_3 >::type
00143   ymax() const
00144   {
00145     return R().compute_ymax_3_object()(*this);
00146   }
00147 
00148   typename Qualified_result_of<typename R::Compute_zmin_3, Iso_cuboid_3 >::type
00149   zmin() const
00150   {
00151     return R().compute_zmin_3_object()(*this);
00152   }
00153 
00154   typename Qualified_result_of<typename R::Compute_zmax_3, Iso_cuboid_3 >::type
00155   zmax() const
00156   {
00157     return R().compute_zmax_3_object()(*this);
00158   }
00159 
00160   typename Qualified_result_of<typename R::Compute_xmin_3, Iso_cuboid_3 >::type
00161   min_coord(int i) const
00162   {
00163     CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 );
00164     if (i == 0)
00165        return xmin();
00166     else if (i == 1)
00167        return ymin();
00168     else
00169        return zmin();
00170   }
00171 
00172   typename Qualified_result_of<typename R::Compute_xmax_3, Iso_cuboid_3 >::type
00173   max_coord(int i) const
00174   {
00175     CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 );
00176     if (i == 0)
00177        return xmax();
00178     else if (i == 1)
00179        return ymax();
00180     else
00181        return zmax();
00182   }
00183 
00184   bool
00185   has_on_bounded_side(const Point_3 &p) const
00186   {
00187     return R().has_on_bounded_side_3_object()(*this,p);
00188   }
00189 
00190   bool
00191   has_on_unbounded_side(const Point_3 &p) const
00192   {
00193     return R().has_on_unbounded_side_3_object()(*this,p);
00194   }
00195 
00196   bool
00197   has_on_boundary(const Point_3 &p) const
00198   {
00199     return R().has_on_boundary_3_object()(*this,p);
00200   }
00201 
00202   bool
00203   has_on(const Point_3 &p) const
00204   {
00205     return has_on_boundary(p);
00206   }
00207 
00208   Bounded_side
00209   bounded_side(const Point_3 &p) const
00210   {
00211     return R().bounded_side_3_object()(*this,p);
00212   }
00213 
00214   bool
00215   is_degenerate() const
00216   {
00217     return R().is_degenerate_3_object()(*this);
00218   }
00219 
00220   typename Qualified_result_of<typename R::Compute_volume_3, Iso_cuboid_3 >::type
00221   volume() const
00222   {
00223     return R().compute_volume_3_object()(*this);
00224   }
00225 
00226   Bbox_3
00227   bbox() const
00228   {
00229     return R().construct_bbox_3_object()(*this);
00230   }
00231 
00232   Iso_cuboid_3
00233   transform(const Aff_transformation_3 &t) const
00234   {
00235     return Iso_cuboid_3(t.transform((this->min)()), t.transform((this->max)()));
00236   }
00237 
00238 };
00239 
00240 
00241 template < class R >
00242 std::ostream &
00243 operator<<(std::ostream& os, const Iso_cuboid_3<R>& r)
00244 {
00245   switch(os.iword(IO::mode)) {
00246   case IO::ASCII :
00247     return os << (r.min)() << ' ' << (r.max)();
00248   case IO::BINARY :
00249     return os << (r.min)() << (r.max)();
00250   default:
00251     return os << "Iso_cuboid_3(" << (r.min)() << ", " << (r.max)() << ")";
00252   }
00253 }
00254 
00255 template < class R >
00256 std::istream &
00257 operator>>(std::istream& is, Iso_cuboid_3<R>& r)
00258 {
00259   typename R::Point_3 p, q;
00260   is >> p >> q;
00261   if (is)
00262       r = Iso_cuboid_3<R>(p, q);
00263   return is;
00264 }
00265 
00266 CGAL_END_NAMESPACE
00267 
00268 #endif // CGAL_ISO_CUBOID_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines