/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2004 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ /**************************************************************************** History $Log: not supported by cvs2svn $ Revision 1.2 2004/05/10 14:40:47 ganovelli name of adhacency function updated Revision 1.1 2004/05/10 14:01:56 ganovelli created ****************************************************************************/ #ifndef __VCG_EDGE_POS #define __VCG_EDGE_POS #include namespace vcg { namespace edge { /* Vertex_Edge: run over the fan of a vertex (no order is specified) */ /** Class VertexStar @param EDGETYPE Specifies the type of the faces */ template class VertexStar { public: /// Pointer to an edge EDGETYPE *e; /// Local index of the vertex int z; /// Default Constructor VertexStar() {} /// Constructor which associates the EdgePos elementet with a face and its edge VertexStar(EDGETYPE * const ep, int const zp) { e=ep; z=zp; } /// Function to jump on the next face of the list of vertex z void NextF() { EDGETYPE * t = e; e = (EDGETYPE *)t->VEp(z); z = t->VEi(z); } }; /* */ /** Class Pos. This structure is equivalent to a half-edge. @param MFTYPE (Template-Parameter) Specifies the type of the edges */ template class Pos { public: /// The vertex type typedef typename EDGETYPE::VertexType VertexType; /////The HEdgePos type typedef Pos< EDGETYPE> POSTYPE; ///// The vector type //typedef typename MVTYPE::coord_type vectorial_type; ///// The scalar type //typedef typename MVTYPE::scalar_type scalar_type; /// Pointer to the face of the half-edge EDGETYPE *e; /// Pointer to the vertex VertexType *v; /// Default constructor Pos(){} /// Constructor which associates the half-edge elementet with a face, its edge and its vertex Pos(EDGETYPE * ep, int zp) {e=ep;v=ep->V(zp);} Pos(EDGETYPE * ep, VertexType *vp){e=ep;v=vp;} // Official Access functions functions VertexType *& V(){ return v; } EDGETYPE *& E(){ return e; } int VInd(){ return (e->V(0)==v)?0:1; } /// Operator to compare two half-edge inline bool operator == ( POSTYPE const & p ) const { return (e==p.e &&v==p.v); } /// Operator to compare two half-edge inline bool operator != ( POSTYPE const & p ) const { return (e!=p.e || v!=p.v); } /// Operator to order half-edge; it's compare at the first the face pointers, then the index of the edge and finally the vertex pointers inline bool operator <= ( POSTYPE const & p) const { return (e!=p.e)?(eV(0)==v)?e->V(1):e->V(0); } void FlipE() { assert( (e->V(0)==v) ||(e->V(1)==v)); e = (e->V(0)==v)?e->EEp(0):e->EEp(1); } // return the vertex that it should have if we make FlipV; VertexType *VFlip() { return (e->V(0)==v)?e->V(1):e->V(0); } // Trova il prossimo half-edge di bordo (nhe) // tale che // --nhe.f adiacente per vertice a he.f // --nhe.v adiacente per edge di bordo a he.v // l'idea e' che se he e' un half edge di bordo // si puo scorrere tutto un bordo facendo // // hei=he; // do // hei.Nextb() // while(hei!=he); /// Checks if the half-edge is of border bool IsBorder() { return edge::IsEdgeBorder(*e,VInd()); } bool IsManifold() { return edge::IsEdgeManifold(*e,VInd()); } /** Function to inizialize an half-edge. @param fp Puntatore alla faccia @param zp Indice dell'edge @param vp Puntatore al vertice */ void Set(EDGETYPE * const ep, VertexType * const vp) { e=ep;v=vp; } }; } // end namespace } // end namespace #endif