2004-03-10 09:32:30 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* 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. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
|
2004-10-28 02:56:44 +02:00
|
|
|
/** \file face/pos.h
|
2004-03-10 09:32:30 +01:00
|
|
|
* Definition of vcg:face::Pos class.
|
|
|
|
* This file contain the definition of vcg::face::Pos class and the derived vcg::face::PosN class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VCG_FACE_POS
|
|
|
|
#define __VCG_FACE_POS
|
|
|
|
|
2007-01-11 11:37:08 +01:00
|
|
|
#include <assert.h>
|
|
|
|
|
2004-03-10 09:32:30 +01:00
|
|
|
namespace vcg {
|
|
|
|
namespace face {
|
2004-03-12 16:22:28 +01:00
|
|
|
|
|
|
|
/** \addtogroup face */
|
|
|
|
/*@{*/
|
|
|
|
|
2006-11-13 02:57:23 +01:00
|
|
|
// Needed Prototypes (pos is include before topology)
|
|
|
|
template <class FaceType>
|
|
|
|
bool IsBorder(FaceType const & f, const int j );
|
|
|
|
template <class FaceType>
|
|
|
|
bool IsManifold(FaceType const & f, const int j );
|
|
|
|
|
2004-03-10 09:32:30 +01:00
|
|
|
/** Templated over the class face, it stores a \em position over a face in a mesh.
|
|
|
|
It contain a pointer to the current face,
|
2008-04-11 12:11:32 +02:00
|
|
|
the index of one edge and a pointer to one of the vertices of the edge.
|
|
|
|
See also the JumpingPos in jumping_pos.h for an iterator that loops
|
|
|
|
around the faces of a vertex without requiring the VF topology.
|
2004-03-10 09:32:30 +01:00
|
|
|
*/
|
2005-10-17 01:30:39 +02:00
|
|
|
|
|
|
|
|
2004-07-15 13:28:44 +02:00
|
|
|
template <class FaceType>
|
2004-03-10 09:32:30 +01:00
|
|
|
class Pos
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// The vertex type
|
|
|
|
typedef typename FaceType::VertexType VertexType;
|
2008-04-11 12:11:32 +02:00
|
|
|
///The Pos type
|
2004-07-15 13:28:44 +02:00
|
|
|
typedef Pos<FaceType> PosType;
|
2004-03-10 09:32:30 +01:00
|
|
|
/// The scalar type
|
|
|
|
typedef typename VertexType::ScalarType ScalarType;
|
2004-07-15 13:28:44 +02:00
|
|
|
|
2004-03-10 09:32:30 +01:00
|
|
|
/// Pointer to the face of the half-edge
|
2004-07-15 13:28:44 +02:00
|
|
|
typename FaceType::FaceType *f;
|
2004-03-10 09:32:30 +01:00
|
|
|
/// Index of the edge
|
|
|
|
int z;
|
|
|
|
/// Pointer to the vertex
|
|
|
|
VertexType *v;
|
|
|
|
|
|
|
|
/// Default constructor
|
|
|
|
Pos(){}
|
2005-12-15 11:53:16 +01:00
|
|
|
/// Constructor which associates the half-edge element with a face, its edge and its vertex
|
|
|
|
Pos(FaceType * const fp, int const zp, VertexType * const vp){f=fp; z=zp; v=vp;}
|
|
|
|
Pos(FaceType * const fp, int const zp){f=fp; z=zp; v=f->V(zp);}
|
|
|
|
Pos(FaceType * const fp, VertexType * const vp)
|
|
|
|
{
|
|
|
|
f = fp;
|
|
|
|
v = vp;
|
2008-10-08 11:10:53 +02:00
|
|
|
for(int i = 0; i < f->VN(); ++i)
|
|
|
|
if (f->V(i) == v) { z = f->Prev(i); break;}
|
2005-12-15 11:53:16 +01:00
|
|
|
}
|
2004-07-15 13:28:44 +02:00
|
|
|
|
2008-04-11 12:11:32 +02:00
|
|
|
// Official Access functions functions
|
|
|
|
VertexType *& V(){ return v; }
|
|
|
|
int & E(){ return z; }
|
2011-10-05 17:04:40 +02:00
|
|
|
FaceType *& F(){ return f; }
|
2007-10-17 21:46:50 +02:00
|
|
|
|
2011-10-05 17:04:40 +02:00
|
|
|
VertexType * V() const { return v; }
|
|
|
|
int E() const { return z; }
|
|
|
|
FaceType * F() const { return f; }
|
2004-03-10 09:32:30 +01:00
|
|
|
|
2008-04-11 12:11:32 +02:00
|
|
|
// Returns the face index of the vertex inside the face.
|
|
|
|
// Note that this is DIFFERENT from using the z member that denotes the edge index inside the face.
|
|
|
|
// It should holds that Vind != (z+1)%3 && Vind == z || Vind = z+2%3
|
|
|
|
int VInd()
|
|
|
|
{
|
2008-10-08 11:10:53 +02:00
|
|
|
for(int i = 0; i < f->VN(); ++i) if(v==f->V(i)) return i;
|
2008-04-11 12:11:32 +02:00
|
|
|
assert(0);
|
2008-10-24 11:49:47 +02:00
|
|
|
return -1;
|
2008-04-11 12:11:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-10 09:32:30 +01:00
|
|
|
/// Operator to compare two half-edge
|
2005-12-15 12:57:48 +01:00
|
|
|
inline bool operator == ( PosType const & p ) const {
|
2004-03-10 09:32:30 +01:00
|
|
|
return (f==p.f && z==p.z && v==p.v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Operator to compare two half-edge
|
2005-12-15 12:57:48 +01:00
|
|
|
inline bool operator != ( PosType const & p ) const {
|
2004-03-10 09:32:30 +01:00
|
|
|
return (f!=p.f || z!=p.z || 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
|
2005-12-15 12:57:48 +01:00
|
|
|
inline bool operator <= ( PosType const & p) const {
|
2011-10-05 17:04:40 +02:00
|
|
|
return (f!=p.f)?(f<p.f):
|
2004-03-10 09:32:30 +01:00
|
|
|
(z!=p.z)?(z<p.z):
|
|
|
|
(v<=p.v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Assignment operator
|
2004-07-15 13:28:44 +02:00
|
|
|
inline FaceType & operator = ( const FaceType & h ){
|
2004-03-10 09:32:30 +01:00
|
|
|
f=h.f;
|
|
|
|
z=h.z;
|
|
|
|
v=h.v;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
/// Set to null the half-edge
|
|
|
|
void SetNull(){
|
|
|
|
f=0;
|
|
|
|
v=0;
|
|
|
|
z=-1;
|
|
|
|
}
|
|
|
|
/// Check if the half-edge is null
|
|
|
|
bool IsNull() const {
|
|
|
|
return f==0 || v==0 || z<0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Cambia Faccia lungo z
|
|
|
|
// e' uguale a FlipF solo che funziona anche per non manifold.
|
|
|
|
/// Change face via z
|
|
|
|
void NextF()
|
|
|
|
{
|
2004-06-02 18:25:45 +02:00
|
|
|
FaceType * t = f;
|
|
|
|
f = t->FFp(z);
|
|
|
|
z = t->FFi(z);
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Paolo Cignoni 19/6/99
|
|
|
|
// Si muove sulla faccia adiacente a f, lungo uno spigolo che
|
|
|
|
// NON e' j, e che e' adiacente a v
|
|
|
|
// in questo modo si scandiscono tutte le facce incidenti in un
|
|
|
|
// vertice f facendo Next() finche' non si ritorna all'inizio
|
|
|
|
// Nota che sul bordo rimbalza, cioe' se lo spigolo !=j e' di bordo
|
|
|
|
// restituisce sempre la faccia f ma con nj che e' il nuovo spigolo di bordo
|
|
|
|
// vecchi parametri: FaceType * & f, VertexType * v, int & j
|
|
|
|
|
|
|
|
/// It moves on the adjacent face incident to v, via a different edge that j
|
|
|
|
void NextE()
|
|
|
|
{
|
2008-10-08 11:10:53 +02:00
|
|
|
assert( f->V(z)==v || f->V(f->Next(z))==v ); // L'edge j deve contenere v
|
2004-03-10 09:32:30 +01:00
|
|
|
FlipE();
|
|
|
|
FlipF();
|
2008-10-08 11:10:53 +02:00
|
|
|
assert( f->V(z)==v || f->V(f->Next(z))==v );
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
// Cambia edge mantenendo la stessa faccia e lo stesso vertice
|
|
|
|
/// Changes edge maintaining the same face and the same vertex
|
|
|
|
void FlipE()
|
|
|
|
{
|
2008-12-19 11:30:51 +01:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z+0)%f->VN())==v));
|
2008-10-08 11:10:53 +02:00
|
|
|
if(f->V(f->Next(z))==v) z=f->Next(z);
|
|
|
|
else z= f->Prev(z);
|
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z))==v));
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cambia Faccia mantenendo lo stesso vertice e lo stesso edge
|
|
|
|
// Vale che he.flipf.flipf= he
|
|
|
|
// Se l'he e' di bordo he.flipf()==he
|
|
|
|
// Si puo' usare SOLO se l'edge e' 2manifold altrimenti
|
|
|
|
// si deve usare nextf
|
|
|
|
|
|
|
|
/// Changes face maintaining the same vertex and the same edge
|
|
|
|
void FlipF()
|
|
|
|
{
|
2008-04-11 12:11:32 +02:00
|
|
|
assert( f->FFp(z)->FFp(f->FFi(z))==f ); // two manifoldness check
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z))==v));
|
2004-06-02 18:25:45 +02:00
|
|
|
FaceType *nf=f->FFp(z);
|
|
|
|
int nz=f->FFi(z);
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(nf->V(f->Prev(nz))!=v && (nf->V(f->Next(nz))==v || nf->V((nz))==v));
|
2004-03-10 09:32:30 +01:00
|
|
|
f=nf;
|
|
|
|
z=nz;
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Changes vertex maintaining the same face and the same edge
|
|
|
|
void FlipV()
|
|
|
|
{
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
2004-03-10 09:32:30 +01:00
|
|
|
|
2008-10-08 11:10:53 +02:00
|
|
|
if(f->V(f->Next(z))==v)
|
|
|
|
v=f->V(z);
|
2004-03-10 09:32:30 +01:00
|
|
|
else
|
2008-10-08 11:10:53 +02:00
|
|
|
v=f->V(f->Next(z));
|
2004-03-10 09:32:30 +01:00
|
|
|
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// return the vertex that it should have if we make FlipV;
|
|
|
|
VertexType *VFlip()
|
|
|
|
{
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
|
|
|
if(f->V(f->Next(z))==v) return f->V(z);
|
|
|
|
else return f->V(f->Next(z));
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2006-12-04 17:06:12 +01:00
|
|
|
// return the vertex that it should have if we make FlipV;
|
|
|
|
const VertexType *VFlip() const
|
|
|
|
{
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->cV(f->Prev(z))!=v && (f->cV(f->Next(z))==v || f->cV(z)==v));
|
|
|
|
if(f->cV(f->Next(z))==v) return f->cV(z);
|
|
|
|
else return f->cV(f->Next(z));
|
2006-12-04 17:06:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// return the face that it should have if we make FlipF;
|
|
|
|
const FaceType *FFlip() const
|
|
|
|
{
|
|
|
|
assert( f->FFp(z)->FFp(f->FFi(z))==f );
|
2008-12-19 11:30:51 +01:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V((z+0)%f->VN())==v));
|
2006-12-04 17:06:12 +01:00
|
|
|
FaceType *nf=f->FFp(z);
|
|
|
|
return nf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-10 09:32:30 +01:00
|
|
|
// 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);
|
|
|
|
|
|
|
|
/// Finds the next half-edge border
|
|
|
|
void NextB( )
|
|
|
|
{
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
2004-10-18 19:14:42 +02:00
|
|
|
assert(f->FFp(z)==f); // f is border along j
|
2004-03-10 09:32:30 +01:00
|
|
|
// Si deve cambiare faccia intorno allo stesso vertice v
|
|
|
|
//finche' non si trova una faccia di bordo.
|
|
|
|
do
|
|
|
|
NextE();
|
2005-10-13 11:29:10 +02:00
|
|
|
while(!IsBorder());
|
2004-03-10 09:32:30 +01:00
|
|
|
|
|
|
|
// L'edge j e' di bordo e deve contenere v
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(IsBorder() &&( f->V(z)==v || f->V(f->Next(z))==v ));
|
2004-03-10 09:32:30 +01:00
|
|
|
|
|
|
|
FlipV();
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
2004-06-02 18:25:45 +02:00
|
|
|
assert(f->FFp(z)==f); // f is border along j
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Checks if the half-edge is of border
|
|
|
|
bool IsBorder()
|
|
|
|
{
|
2005-10-13 11:29:10 +02:00
|
|
|
return face::IsBorder(*f,z);
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 18:22:56 +01:00
|
|
|
bool IsManifold()
|
|
|
|
{
|
|
|
|
return face::IsManifold(*f,z);
|
|
|
|
}
|
|
|
|
|
2007-05-16 17:11:32 +02:00
|
|
|
/*!
|
|
|
|
* Returns the number of vertices incident on the vertex pos is currently pointing to.
|
|
|
|
*/
|
|
|
|
int NumberOfIncidentVertices()
|
2004-03-10 09:32:30 +01:00
|
|
|
{
|
2007-05-16 17:11:32 +02:00
|
|
|
int count = 0;
|
|
|
|
bool on_border = false;
|
|
|
|
CheckIncidentFaces(count, on_border);
|
|
|
|
if(on_border) return (count/2)+1;
|
|
|
|
else return count;
|
|
|
|
}
|
2004-03-10 09:32:30 +01:00
|
|
|
|
2007-05-16 17:11:32 +02:00
|
|
|
/*!
|
|
|
|
* Returns the number of faces incident on the vertex pos is currently pointing to.
|
|
|
|
*/
|
|
|
|
int NumberOfIncidentFaces()
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
bool on_border = false;
|
|
|
|
CheckIncidentFaces(count, on_border);
|
|
|
|
if(on_border) return count/2;
|
|
|
|
else return count;
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2011-03-22 12:52:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Returns the number of faces incident on the edge the pos is currently pointing to.
|
|
|
|
* useful to compute the complexity of a non manifold edge
|
|
|
|
*/
|
|
|
|
int NumberOfFacesOnEdge() const
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
PosType ht = *this;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ht.NextF();
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
while (ht!=*this);
|
|
|
|
return count;
|
|
|
|
}
|
2004-03-10 09:32:30 +01:00
|
|
|
/** Function to inizialize an half-edge.
|
|
|
|
@param fp Puntatore alla faccia
|
|
|
|
@param zp Indice dell'edge
|
|
|
|
@param vp Puntatore al vertice
|
|
|
|
*/
|
2004-07-15 13:28:44 +02:00
|
|
|
void Set(FaceType * const fp, int const zp, VertexType * const vp)
|
2004-03-10 09:32:30 +01:00
|
|
|
{
|
|
|
|
f=fp;z=zp;v=vp;
|
2008-10-08 11:10:53 +02:00
|
|
|
assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v));
|
2004-03-10 09:32:30 +01:00
|
|
|
}
|
2007-05-28 16:09:41 +02:00
|
|
|
|
|
|
|
void Set(FaceType * const pFace, VertexType * const pVertex)
|
|
|
|
{
|
|
|
|
f = pFace;
|
|
|
|
v = pVertex;
|
2008-10-08 11:10:53 +02:00
|
|
|
for(int i = 0; i < f->VN(); ++i) if(f->V(i) == v ) {z = f->Prev(i);break;}
|
2007-05-28 16:09:41 +02:00
|
|
|
}
|
2004-03-10 09:32:30 +01:00
|
|
|
|
|
|
|
void Assert()
|
|
|
|
#ifdef _DEBUG
|
|
|
|
{
|
2004-07-15 13:28:44 +02:00
|
|
|
FaceType ht=*this;
|
2004-03-10 09:32:30 +01:00
|
|
|
ht.FlipF();
|
|
|
|
ht.FlipF();
|
|
|
|
assert(ht==*this);
|
|
|
|
|
|
|
|
ht.FlipE();
|
|
|
|
ht.FlipE();
|
|
|
|
assert(ht==*this);
|
|
|
|
|
|
|
|
ht.FlipV();
|
|
|
|
ht.FlipV();
|
|
|
|
assert(ht==*this);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{}
|
|
|
|
#endif
|
|
|
|
|
2007-05-16 17:11:32 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void CheckIncidentFaces(int & count, bool & on_border)
|
|
|
|
{
|
|
|
|
PosType ht = *this;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
++count;
|
|
|
|
ht.NextE();
|
|
|
|
if(ht.IsBorder()) on_border=true;
|
|
|
|
} while (ht != *this);
|
|
|
|
}
|
2004-03-10 09:32:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class FaceType>
|
|
|
|
/** Class PosN.
|
|
|
|
This structure is equivalent to a Pos, but it contains a normal.
|
|
|
|
@param FaceType (Template-Parameter) Specifies the type of the faces
|
|
|
|
*/
|
|
|
|
class PosN : public Pos<FaceType>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef typename FaceType::CoordType CoordType;
|
|
|
|
//normale per visualizzazione creaseangle
|
|
|
|
CoordType normal;
|
|
|
|
};
|
|
|
|
|
2004-05-10 15:41:57 +02:00
|
|
|
|
|
|
|
/** Class VFIterator.
|
|
|
|
This class is used as an iterator over the VF adjacency.
|
2008-04-11 12:11:32 +02:00
|
|
|
It allow to easily traverse all the faces around a given vertex v;
|
|
|
|
The faces are traversed in no particular order. No Manifoldness requirement.
|
|
|
|
|
2005-01-03 12:22:31 +01:00
|
|
|
typical example:
|
|
|
|
|
2008-04-11 12:11:32 +02:00
|
|
|
VertexPointer v;
|
|
|
|
vcg::face::VFIterator<FaceType> vfi(v);
|
2006-09-25 11:57:49 +02:00
|
|
|
for (;!vfi.End();++vfi)
|
|
|
|
vfi.F()->ClearV();
|
|
|
|
|
|
|
|
// Alternative
|
|
|
|
|
|
|
|
vcg::face::VFIterator<FaceType> vfi(f, 1);
|
2005-01-03 12:22:31 +01:00
|
|
|
while (!vfi.End()){
|
2006-09-25 11:57:49 +02:00
|
|
|
vfi.F()->ClearV();
|
2005-01-03 12:22:31 +01:00
|
|
|
++vfi;
|
|
|
|
}
|
2008-04-11 12:11:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
See also the JumpingPos in jumping_pos.h for an iterator that loops
|
|
|
|
around the faces of a vertex using FF topology and without requiring the VF topology.
|
|
|
|
|
2004-05-10 15:41:57 +02:00
|
|
|
*/
|
|
|
|
|
2004-08-25 17:15:27 +02:00
|
|
|
template <typename FaceType>
|
2004-05-10 15:41:57 +02:00
|
|
|
class VFIterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// The vertex type
|
|
|
|
typedef typename FaceType::VertexType VertexType;
|
2004-07-06 08:25:44 +02:00
|
|
|
/// The Base face type
|
2004-08-25 17:15:27 +02:00
|
|
|
typedef FaceType VFIFaceType;
|
2004-05-10 15:41:57 +02:00
|
|
|
/// The vector type
|
|
|
|
typedef typename VertexType::CoordType CoordType;
|
|
|
|
/// The scalar type
|
|
|
|
typedef typename VertexType::ScalarType ScalarType;
|
|
|
|
|
|
|
|
/// Pointer to the face of the half-edge
|
2004-08-25 17:15:27 +02:00
|
|
|
FaceType *f;
|
2004-07-15 13:28:44 +02:00
|
|
|
/// Index of the vertex
|
2004-05-10 15:41:57 +02:00
|
|
|
int z;
|
|
|
|
|
|
|
|
/// Default constructor
|
|
|
|
VFIterator(){}
|
2004-07-15 13:28:44 +02:00
|
|
|
/// Constructor which associates the half-edge elementet with a face and its vertex
|
2012-03-14 17:02:30 +01:00
|
|
|
VFIterator(FaceType * _f, const int & _z){f = _f; z = _z; assert(z>=0 && "VFAdj must be initialized");}
|
2004-09-14 21:46:10 +02:00
|
|
|
|
|
|
|
/// Constructor which takes a pointer to vertex
|
2012-03-14 17:02:30 +01:00
|
|
|
VFIterator(VertexType * _v){f = _v->VFp(); z = _v->VFi(); assert(z>=0 && "VFAdj must be initialized");}
|
2004-07-15 14:04:14 +02:00
|
|
|
|
2004-09-14 21:46:10 +02:00
|
|
|
VFIFaceType *& F() { return f;}
|
2005-01-03 12:22:31 +01:00
|
|
|
int & I() { return z;}
|
2006-10-07 16:24:26 +02:00
|
|
|
|
|
|
|
// Access to the vertex. Having a VFIterator vfi, it corresponds to
|
|
|
|
// vfi.V() = vfi.F()->V(vfi.I())
|
2005-01-03 12:22:31 +01:00
|
|
|
inline VertexType *V() const { return f->V(z);}
|
2004-05-10 15:41:57 +02:00
|
|
|
|
2005-01-03 12:22:31 +01:00
|
|
|
inline VertexType * const & V0() const { return f->V0(z);}
|
|
|
|
inline VertexType * const & V1() const { return f->V1(z);}
|
|
|
|
inline VertexType * const & V2() const { return f->V2(z);}
|
|
|
|
|
2004-05-10 15:41:57 +02:00
|
|
|
bool End() const {return f==0;}
|
2004-07-15 14:04:14 +02:00
|
|
|
VFIFaceType *operator++() {
|
2004-07-15 13:28:44 +02:00
|
|
|
FaceType* t = f;
|
2008-04-11 12:11:32 +02:00
|
|
|
f = f->VFp(z);
|
2004-05-10 15:41:57 +02:00
|
|
|
z = t->VFi(z);
|
2004-07-06 08:25:44 +02:00
|
|
|
return f;
|
2004-05-10 15:41:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2004-03-12 16:22:28 +01:00
|
|
|
/*@}*/
|
2004-03-10 09:32:30 +01:00
|
|
|
} // end namespace
|
|
|
|
} // end namespace
|
|
|
|
#endif
|