Moby
IndexedTri.h
1 /****************************************************************************
2  * Copyright 2008 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef _INDEXED_TRI_
8 #define _INDEXED_TRI_
9 
10 #include <limits>
11 
12 namespace Moby {
13 
15 struct IndexedTri
16 {
17  IndexedTri() { a = b = c = std::numeric_limits<unsigned>::max(); }
18  IndexedTri(unsigned v1, unsigned v2, unsigned v3) { a = v1; b = v2; c = v3; }
19 
21  IndexedTri& reverse() { std::swap(b, c); return *this; }
22 
24  unsigned a;
25 
27  unsigned b;
28 
30  unsigned c;
31 
32  bool operator<(const IndexedTri& t) const
33  {
34  if (a < t.a)
35  return true;
36  else if (a == t.a)
37  {
38  if (b < t.b)
39  return true;
40  else if (b == t.b && c < t.c)
41  return true;
42  }
43  return false;
44  }
45 };
46 
47 } // end namespace
48 
49 #endif
unsigned a
Index of the first vertex of the triangle.
Definition: IndexedTri.h:24
IndexedTri & reverse()
Reverses the orientation of the triangle.
Definition: IndexedTri.h:21
An indexed triangle.
Definition: IndexedTri.h:15
unsigned c
Index of the third vertex of the triangle.
Definition: IndexedTri.h:30
unsigned b
Index of the second vertex of the triangle.
Definition: IndexedTri.h:27