pos.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 /****************************************************************************
00024   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.2  2004/05/10 14:40:47  ganovelli
00028 name of adhacency function updated
00029 
00030 Revision 1.1  2004/05/10 14:01:56  ganovelli
00031 created
00032 
00033 ****************************************************************************/
00034 
00035 
00036 #ifndef __VCG_EDGE_POS
00037 #define __VCG_EDGE_POS
00038 
00039 namespace vcg {
00040 namespace edge {
00041 
00042 // Needed Prototypes (pos is include before topology)
00043 template <class EDGETYPE>
00044 bool IsEdgeBorder(EDGETYPE const & e,  const int j );
00045 template <class EDGETYPE>
00046 bool IsEdgeManifold(EDGETYPE const & e,  const int j );
00047 
00048 /*
00049  Vertex_Edge: run over the fan of a vertex (no order is specified)
00050 */
00054 template <class EDGETYPE> 
00055 class VertexStar
00056 {
00057 public:
00059         EDGETYPE *e;
00061         int z;
00063   VertexStar() : e(0), z(0) {}
00065         VertexStar(EDGETYPE  * const ep, int const zp)
00066         {
00067                 e=ep;
00068                 z=zp;
00069         }
00070 
00072         void NextF()
00073         {
00074                 EDGETYPE * t = e;
00075                 e = (EDGETYPE *)t->VEp(z);
00076                 z = t->VEi(z);
00077         }
00078 };
00079 
00080 
00081 /*
00082  
00083 */
00088 template <class EDGETYPE> 
00089 class Pos
00090 {
00091 public:
00092 
00093         typedef typename EDGETYPE::VertexType VertexType;
00094         typedef Pos< EDGETYPE> POSTYPE;
00095 
00097         EDGETYPE *e;
00099         VertexType *v;
00100 
00102         Pos(){}
00104   Pos(EDGETYPE  * ep, int zp) {e=ep;v=ep->V(zp);}
00105   Pos(EDGETYPE  * ep, VertexType  *vp){e=ep;v=vp;}
00106 
00107 
00108   // Official Access functions functions
00109    VertexType *& V(){ return v; }
00110    EDGETYPE   *& E(){ return e; }
00111    int VInd(){
00112      return (e->V(0)==v)?0:1;
00113      }
00114 
00116         inline bool operator == ( POSTYPE const & p ) const {
00117                         return (e==p.e &&v==p.v);
00118         } 
00119 
00121         inline bool operator != ( POSTYPE const & p ) const {
00122                         return (e!=p.e || v!=p.v);
00123         } 
00125         inline bool operator <= ( POSTYPE const & p) const {
00126     return      (e!=p.e)?(e<p.e):
00127                                                 (v<=p.v);
00128         }       
00129 
00131         inline POSTYPE & operator = ( const POSTYPE & h ){
00132                 e=h.e;
00133                 v=h.v;
00134                 return *this;
00135                 }
00137         void SetNull(){
00138                 e=0;
00139                 v=0;
00140         }
00142         bool IsNull() const {
00143                 return e==0 || v==0 ;
00144         }
00145 
00146 
00160         void NextE()
00161         {
00162        FlipE();
00163        FlipV();
00164         }
00165   
00167         void FlipV()
00168         {
00169                 v = (e->V(0)==v)?e->V(1):e->V(0);
00170         }
00172         void FlipE()
00173         {
00174                 assert( (e->V(0)==v) ||(e->V(1)==v));
00175                 e = (e->V(0)==v)?e->EEp(0):e->EEp(1);
00176         }
00177   // return the vertex that it should have if we make FlipV;
00178         VertexType *VFlip()
00179         {
00180                 return (e->V(0)==v)?e->V(1):e->V(0);
00181         }
00182 
00183         // Trova il prossimo half-edge di bordo (nhe)
00184         // tale che 
00185         // --nhe.f adiacente per vertice a he.f
00186         // --nhe.v adiacente per edge di bordo a he.v 
00187         // l'idea e' che se he e' un half edge di bordo 
00188         // si puo scorrere tutto un bordo facendo 
00189         //
00190         //              hei=he;
00191         //              do
00192         //                      hei.Nextb()
00193         //              while(hei!=he);
00194         
00195 
00197   bool IsBorder()
00198   {
00199     return edge::IsEdgeBorder(*e,VInd());
00200   }
00201 
00202   bool IsManifold()
00203   {
00204     return edge::IsEdgeManifold(*e,VInd());
00205   }
00206 
00207 
00213   void Set(EDGETYPE  * const ep, VertexType  * const vp)
00214         {
00215                 e=ep;v=vp;
00216         }
00217 
00218 };
00219 
00220 
00221 
00248 template <typename EdgeType>
00249 class VEIterator
00250 {
00251 public:
00252 
00254         typedef typename EdgeType::VertexType VertexType;
00256         typedef  EdgeType  VFIEdgeType;
00258         typedef typename VertexType::CoordType CoordType;
00260         typedef typename VertexType::ScalarType ScalarType;
00261 
00263         EdgeType *e;
00265         int z;
00266 
00268         VEIterator(){}
00270         VEIterator(EdgeType * _e,  const int &  _z){e = _e; z = _z;}
00271 
00273     VEIterator(const VertexType * _v){
00274       e = _v->cVEp(); z = _v->cVEi();
00275           assert(z>=0 && "VE adjacency not initialized");
00276         }
00277 
00278         VFIEdgeType * &E() { return e;}
00279         int     &                                         I() { return z;}
00280 
00281   // Access to the vertex. Having a VEIterator vfi, it corresponds to
00282   // vfi.V() = vfi.I()->V(vfi.I())
00283   inline VertexType *V() const { return e->V(z);}
00284 
00285   inline VertexType * const & V0() const { return e->V0(z);}
00286   inline VertexType * const & V1() const { return e->V1(z);}
00287 
00288   bool End() const {return e==0;}
00289   VFIEdgeType *operator++() {
00290     EdgeType* t = e;
00291         e = e->VEp(z);
00292         z = t->VEi(z);
00293     return e;
00294   }
00295 
00296 };
00297 
00298 
00299         }        // end namespace
00300 }        // end namespace
00301 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:34:32