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 /**************************************************************************** 00025 ****************************************************************************/ 00026 00027 00028 #ifndef __VCG_JUMPING_FACE_POS 00029 #define __VCG_JUMPING_FACE_POS 00030 00031 #include <assert.h> 00032 #include <vcg/simplex/face/pos.h> 00033 00034 namespace vcg 00035 { 00036 namespace face 00037 { 00040 00041 template < class FACE_TYPE > 00042 class JumpingPos : public Pos< FACE_TYPE > 00043 { 00044 public: // Typedefs 00045 typedef FACE_TYPE FaceType; 00046 typedef Pos<FaceType> PosType; 00047 typedef JumpingPos<FaceType> JumpingPosType; 00048 typedef typename FaceType::VertexType VertexType; 00049 typedef typename VertexType::CoordType CoordType; 00050 typedef typename VertexType::ScalarType ScalarType; 00051 using Pos<FACE_TYPE>::f; 00052 using Pos<FACE_TYPE>::z; 00053 using Pos<FACE_TYPE>::FFlip; 00054 public: 00055 // Constructors 00056 JumpingPos() : Pos<FACE_TYPE>() { } 00057 JumpingPos(FaceType * const pFace, int const z, VertexType * const pVertex) : Pos<FACE_TYPE>(pFace, z, pVertex) { } 00058 JumpingPos(FaceType * const pFace, int const z) : Pos<FACE_TYPE>(pFace, z) { } 00059 JumpingPos(FaceType * const pFace, VertexType * const pVertex) : Pos<FACE_TYPE>(pFace, pVertex) { } 00060 00061 bool FindBorder() 00062 { 00063 PosType startPos=*this; 00064 do 00065 { 00066 if(f==FFlip() ) { 00067 PosType::FlipE(); 00068 return true; // we are on a border 00069 } 00070 PosType::FlipF(); 00071 PosType::FlipE(); 00072 } while(*this != startPos); 00073 00074 return false; 00075 } 00076 00088 bool NextFE() 00089 { 00090 if ( f==FFlip() ) // we are on a border 00091 { 00092 do { 00093 PosType::FlipF(); 00094 PosType::FlipE(); 00095 } while (f!=FFlip()); 00096 PosType::FlipE(); 00097 return false; 00098 } 00099 else 00100 { 00101 PosType::FlipF(); 00102 PosType::FlipE(); 00103 return true; 00104 } 00105 } 00106 }; 00107 00109 } // end of namespace face 00110 } // end of namespace vcg 00111 00112 #endif // __VCG_JUMPING_FACE_POS