GteTetrahedronKey.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 #include <algorithm>
11 
12 namespace gte
13 {
14 
15 
16 // TetrahedronKey<true>
17 
18 template<> std::array<int, 3> const TetrahedronKey<true>::oppositeFace[4] =
19  { { 1, 2, 3 }, { 0, 3, 2 }, { 0, 1, 3 }, { 0, 2, 1 } };
20 
21 static void Permute(int u0, int u1, int u2, int V[4])
22 {
23  // Once V[0] is determined, create a permutation (V[1],V[2],V[3]) so
24  // that (V[0],V[1],V[2],V[3]) is a positive permutation of (v0,v1,v2,v3).
25  if (u0 < u1)
26  {
27  if (u0 < u2)
28  {
29  // u0 is minimum
30  V[1] = u0;
31  V[2] = u1;
32  V[3] = u2;
33  }
34  else
35  {
36  // u2 is minimum
37  V[1] = u2;
38  V[2] = u0;
39  V[3] = u1;
40  }
41  }
42  else
43  {
44  if (u1 < u2)
45  {
46  // u1 is minimum
47  V[1] = u1;
48  V[2] = u2;
49  V[3] = u0;
50  }
51  else
52  {
53  // u2 is minimum
54  V[1] = u2;
55  V[2] = u0;
56  V[3] = u1;
57  }
58  }
59 }
60 
61 template<>
63 {
64  int imin = 0;
65  V[0] = v0;
66  if (v1 < V[0])
67  {
68  V[0] = v1;
69  imin = 1;
70  }
71  if (v2 < V[0])
72  {
73  V[0] = v2;
74  imin = 2;
75  }
76  if (v3 < V[0])
77  {
78  V[0] = v3;
79  imin = 3;
80  }
81 
82  if (imin == 0)
83  {
84  Permute(v1, v2, v3, V);
85  }
86  else if (imin == 1)
87  {
88  Permute(v0, v3, v2, V);
89  }
90  else if (imin == 2)
91  {
92  Permute(v0, v1, v3, V);
93  }
94  else // imin == 3
95  {
96  Permute(v0, v2, v1, V);
97  }
98 }
99 
100 
101 
102 // TetrahedronKey<false>
103 
104 template<> std::array<int, 3> const TetrahedronKey<false>::oppositeFace[4] =
105  { { 1, 2, 3 }, { 0, 3, 2 }, { 0, 1, 3 }, { 0, 2, 1 } };
106 
107 template<>
109 {
110  V[0] = v0;
111  V[1] = v1;
112  V[2] = v2;
113  V[3] = v3;
114  std::sort(&V[0], &V[4]);
115 }
116 
117 
118 }
GLfixed GLfixed u2
Definition: glext.h:4927
TetrahedronKey(int v0=-1, int v1=-1, int v2=-1, int v3=-1)
GLfixed u1
Definition: glext.h:4927
GLfloat GLfloat v1
Definition: glcorearb.h:812
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:814
GLfloat v0
Definition: glcorearb.h:811
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:813
static void Permute(int u0, int u1, int u2, int V[4])


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:01