File: jumping_pos.h

package info (click to toggle)
meshlab 1.3.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,096 kB
  • ctags: 33,630
  • sloc: cpp: 224,813; ansic: 8,170; xml: 119; makefile: 80
file content (113 lines) | stat: -rw-r--r-- 4,164 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/****************************************************************************
* 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_JUMPING_FACE_POS
#define __VCG_JUMPING_FACE_POS

#include <assert.h>
#include <vcg/simplex/face/pos.h>

namespace vcg 
{
	namespace face 
	{
		/** \addtogroup face */
		/*@{*/

		template < class FACE_TYPE >
		class JumpingPos : public Pos< FACE_TYPE >
		{
		public: // Typedefs
			typedef						FACE_TYPE								FaceType;
			typedef						Pos<FaceType>						PosType;
			typedef						JumpingPos<FaceType>		JumpingPosType;
			typedef typename	FaceType::VertexType		VertexType;
			typedef typename	VertexType::CoordType		CoordType;
			typedef typename	VertexType::ScalarType	ScalarType;
			using Pos<FACE_TYPE>::f;
			using Pos<FACE_TYPE>::z;
			using Pos<FACE_TYPE>::FFlip;
		public:
			// Constructors
			JumpingPos()																																: Pos<FACE_TYPE>()   								{ }
			JumpingPos(FaceType * const pFace, int const z, VertexType * const pVertex) : Pos<FACE_TYPE>(pFace, z, pVertex)	{   }
			JumpingPos(FaceType * const pFace, int const z)															: Pos<FACE_TYPE>(pFace, z)						{  }
			JumpingPos(FaceType * const pFace, VertexType * const pVertex)							: Pos<FACE_TYPE>(pFace, pVertex)			{  }

      /// Move the pos to a border (if exists). Return true if actually succeed to find a border
      bool FindBorder()
			{
				PosType startPos=*this;
				do
				{
					if(f==FFlip() ) {
					PosType::FlipE();
					return true; // we are on a border
					}
					PosType::FlipF();
					PosType::FlipE();
				} while(*this != startPos);
				
				return false;
			}
			
			/*!
			* Returns the next edge skipping the border
			*      _________
			*     /\ c | b /\
			*    /  \  |  /  \
			*   / d  \ | / a  \
			*  /______\|/______\
			*          v
			* In this example, if a and d are of-border and the pos is iterating counterclockwise, this method iterate through the faces incident on vertex v,
			* producing the sequence a, b, c, d, a, b, c, ... 
			*/
			bool NextFE()
			{
				if ( f==FFlip() ) // we are on a border
				{
					do {
					PosType::FlipF();
					PosType::FlipE();
					} while (f!=FFlip());
					PosType::FlipE();
					return false;
				}
				else
				{
					PosType::FlipF();
					PosType::FlipE();
					return true;
				}
			}
		};

		/*@}*/
	} // end of namespace face
} // end of namespace vcg

#endif // __VCG_JUMPING_FACE_POS