Cleaned up a few things for edge topology management. Added isborder for edges...

This commit is contained in:
Paolo Cignoni 2011-05-24 09:39:37 +00:00
parent 8dd6bd85b4
commit e2d800f89f
2 changed files with 84 additions and 72 deletions

View File

@ -35,6 +35,7 @@ created
#ifndef __VCG_EDGE_POS
#define __VCG_EDGE_POS
#include <vcg/simplex/edge/topology.h>
namespace vcg {
namespace edge {
@ -101,8 +102,16 @@ public:
/// Default constructor
Pos(){}
/// Constructor which associates the half-edge elementet with a face, its edge and its vertex
Pos(EDGETYPE * const ep, int const zp,
VertexType * const vp){e=ep;v=vp;}
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 {
@ -164,10 +173,7 @@ public:
assert( (e->V(0)==v) ||(e->V(1)==v));
e = (e->V(0)==v)?e->EEp(0):e->EEp(1);
}
int Z(){
return (e->V(0)==v)?0:1;
}
// return the vertex that it should have if we make FlipV;
// return the vertex that it should have if we make FlipV;
VertexType *VFlip()
{
return (e->V(0)==v)?e->V(1):e->V(0);
@ -185,85 +191,29 @@ public:
// hei.Nextb()
// while(hei!=he);
/// Finds the next half-edge border
void NextB( )
{
// assert(f->V((z+2)%3)!=v && (f->V((z+1)%3)==v || f->V((z+0)%3)==v));
// assert(f->F(z)==f); // f is border along j
//// Si deve cambiare faccia intorno allo stesso vertice v
////finche' non si trova una faccia di bordo.
// do
// NextE();
// while(!f->IsBorder(z));
//
// // L'edge j e' di bordo e deve contenere v
// assert(f->IsBorder(z) &&( f->V(z)==v || f->V((z+1)%3)==v ));
//
// FlipV();
// assert(f->V((z+2)%3)!=v && (f->V((z+1)%3)==v || f->V((z+0)%3)==v));
// assert(f->F(z)==f); // f is border along j
}
/// Checks if the half-edge is of border
//bool IsBorder()
//{
//return f->IsBorder(z);
//}
/// Checks if the half-edge is of border
bool IsBorder()
{
return edge::IsEdgeBorder(*e,VInd());
}
/// Return the dimension of the star
//int StarSize()
//{
//int n=0;
//POSTYPE ht=*this;
//bool bf=false;
//do
//{
// ++n;
// ht.NextE();
// if(ht.IsBorder()) bf=true;
//} while(ht!=*this);
bool IsManifold()
{
return edge::IsEdgeManifold(*e,VInd());
}
//if(bf) return n/2;
//else return n;
//}
/** 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)
void Set(EDGETYPE * const ep, VertexType * const vp)
{
e=ep;v=vp;
}
void Assert()
#ifdef _DEBUG
{/*
POSTYPE ht=*this;
ht.FlipE();
ht.FlipE();
assert(ht==*this);
ht.FlipE();
ht.FlipE();
assert(ht==*this);
ht.FlipV();
ht.FlipV();
assert(ht==*this);*/
}
#else
{}
#endif
// Controlla la coerenza di orientamento di un hpos con la relativa faccia
/// Checks the orientation coherence of a half-edge with the face
//inline bool Coherent() const
//{
// return v == f->V(z); // e^(ip)+1=0 ovvero E=mc^2
//}
};
} // end namespace
} // end namespace

View File

@ -0,0 +1,62 @@
/****************************************************************************
* 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. *
* *
****************************************************************************/
#ifndef _VCG_EDGE_TOPOLOGY
#define _VCG_EDGE_TOPOLOGY
#include <vector>
#include <algorithm>
namespace vcg {
namespace edge {
/** \addtogroup edge */
/*@{*/template <class EdgeType>
inline bool IsEdgeManifold( EdgeType const & e, const int j )
{
assert(e.cFFp(j) != 0); // never try to use this on uncomputed topology
if(EdgeType::HasFFAdjacency())
return ( e.cFFp(j) == &e || &e == e.cFFp(j)->cFFp(e.cFFi(j)) );
else
return true;
}
/** Return a boolean that indicate if the j-th edge of the face is a border.
@param j Index of the edge
@return true if j is an edge of border, false otherwise
*/
template <class EdgeType>
inline bool IsEdgeBorder(EdgeType const & e, const int j )
{
if(EdgeType::HasEEAdjacency())
return e.cEEp(j)==&e;
assert(0);
return true;
}
} // end namespace edge
} // end namespace vcg
#endif