BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Triangulation_vertex_base_2.h
Go to the documentation of this file.
00001 // Copyright (c) 1997  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under
00005 // the terms of the Q Public License version 1.0.
00006 // See the file LICENSE.QPL distributed with CGAL.
00007 //
00008 // Licensees holding a valid commercial license may use this file in
00009 // accordance with the commercial license agreement provided with the software.
00010 //
00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 //
00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Triangulation_2/include/CGAL/Triangulation_vertex_base_2.h $
00015 // $Id: Triangulation_vertex_base_2.h 48844 2009-04-21 18:28:04Z spion $
00016 // 
00017 //
00018 // Author(s)     : Mariette Yvinec
00019 
00020 #ifndef CGAL_TRIANGULATION_VERTEX_BASE_2_H
00021 #define CGAL_TRIANGULATION_VERTEX_BASE_2_H
00022 
00023 #include <CGAL/basic.h>
00024 #include <CGAL/Triangulation_ds_vertex_base_2.h>
00025 
00026 CGAL_BEGIN_NAMESPACE
00027 
00028 template < typename GT,
00029            typename Vb = Triangulation_ds_vertex_base_2<> >
00030 class Triangulation_vertex_base_2 
00031   : public Vb
00032 
00033 {
00034   typedef typename Vb::Triangulation_data_structure    Tds;
00035 public:
00036   typedef GT                                    Geom_traits;
00037   typedef typename GT::Point_2                  Point;
00038   typedef Tds                                   Triangulation_data_structure;
00039   typedef typename Tds::Face_handle             Face_handle;
00040   typedef typename Tds::Vertex_handle           Vertex_handle;
00041 #ifndef CGAL_NO_DEPRECATED_CODE
00042   typedef typename Tds::Vertex_circulator       Vertex_circulator; // needed for degree
00043   typedef typename Tds::Edge_circulator         Edge_circulator;   // needed for degree
00044   typedef typename Tds::Face_circulator         Face_circulator;   // needed for degree
00045   typedef typename Tds::size_type               size_type;         // needed for degree
00046 #endif
00047   template < typename TDS2 >
00048   struct Rebind_TDS {
00049     typedef typename Vb::template Rebind_TDS<TDS2>::Other  Vb2;
00050     typedef Triangulation_vertex_base_2<GT, Vb2>           Other;
00051   };
00052 
00053 private:
00054   Point _p;
00055 
00056 public:
00057   Triangulation_vertex_base_2 () : Vb() {}
00058   Triangulation_vertex_base_2(const Point & p) : Vb(), _p(p) {}
00059   Triangulation_vertex_base_2(const Point & p, Face_handle f)
00060     : Vb(f), _p(p) {}
00061   Triangulation_vertex_base_2(Face_handle f) : Vb(f) {} 
00062 
00063   void set_point(const Point & p) { _p = p; }
00064   const Point&  point() const { return _p; }
00065 
00066   // the non const version of point() is undocument
00067   // but needed to make the point iterator works
00068   // using Lutz projection scheme
00069   Point&        point() { return _p; }
00070 
00071   //the following trivial is_valid to allow
00072   // the user of derived face base classes 
00073   // to add their own purpose checking
00074   bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const
00075     {return true;}
00076 
00077 #ifndef CGAL_NO_DEPRECATED_CODE
00078   size_type degree(); //should be const
00079 
00080   Vertex_circulator incident_vertices()     
00081     {return Vertex_circulator(handle());}
00082  
00083   Vertex_circulator incident_vertices( Face_handle f)  
00084     {return Vertex_circulator(handle(),f);}
00085   
00086   Face_circulator incident_faces()  
00087     { return Face_circulator(handle()) ;}
00088   
00089   Face_circulator incident_faces( Face_handle f)    
00090     { return Face_circulator(handle(), f);}
00091   
00092   Edge_circulator incident_edges()   
00093     { return Edge_circulator(handle());}
00094   
00095   Edge_circulator incident_edges( Face_handle f)  
00096     { return Edge_circulator(handle(), f);}
00097  
00098   Vertex_handle handle();
00099 
00100 #endif //  CGAL_NO_DEPRECATED_CODE
00101 };
00102 
00103 template < class GT, class Vb >
00104 std::istream&
00105 operator>>(std::istream &is, Triangulation_vertex_base_2<GT, Vb> &v)
00106   // non combinatorial information. Default = point
00107 {
00108   return is >> static_cast<Vb&>(v) >> v.point();
00109 }
00110 
00111 template < class GT, class Vb >
00112 std::ostream&
00113 operator<<(std::ostream &os, const Triangulation_vertex_base_2<GT, Vb> &v)
00114   // non combinatorial information. Default = point
00115 {
00116   return os << static_cast<const Vb&>(v) << v.point();
00117 }
00118 
00119 #ifndef CGAL_NO_DEPRECATED_CODE
00120 template <class GT, class Vb>
00121 typename Triangulation_vertex_base_2 <GT, Vb>::size_type
00122 Triangulation_vertex_base_2 <GT, Vb>::
00123 degree() //const
00124 {
00125   int count = 0;
00126   Vertex_circulator vc = incident_vertices(), done(vc);
00127   if ( ! vc.is_empty()) {
00128     do { 
00129       count += 1;
00130     } while (++vc != done);
00131   }
00132   return count;
00133 }
00134 template <class GT, class Vb>
00135 typename Triangulation_vertex_base_2<GT, Vb>::Vertex_handle
00136 Triangulation_vertex_base_2 <GT, Vb> ::
00137 handle()
00138 {
00139   Face_handle fh = this->face();
00140   for(int i = 0 ; i < 3 ; ++i){
00141     if ( &*fh->vertex(i) == this) return fh->vertex(i);
00142   }
00143   return Vertex_handle();                                   
00144 }
00145 #endif
00146 CGAL_END_NAMESPACE
00147 
00148 #endif //CGAL_TRIANGULATION_VERTEX_BASE_2_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines