1
// Wild Magic Source Code
3
// http://www.geometrictools.com
4
// Copyright (c) 1998-2007
6
// This library is free software; you can redistribute it and/or modify it
7
// under the terms of the GNU Lesser General Public License as published by
8
// the Free Software Foundation; either version 2.1 of the License, or (at
9
// your option) any later version. The license is available for reading at
10
// either of the locations:
11
// http://www.gnu.org/copyleft/lgpl.html
12
// http://www.geometrictools.com/License/WildMagicLicense.pdf
13
// The license applies to versions 0 through 4 of Wild Magic.
15
// Version: 4.0.0 (2006/06/28)
17
#include "Wm4FoundationPCH.h"
18
#include "Wm4DelTetrahedron.h"
22
//----------------------------------------------------------------------------
24
DelTetrahedron<Real>::DelTetrahedron (int iV0, int iV1, int iV2, int iV3)
38
//----------------------------------------------------------------------------
40
bool DelTetrahedron<Real>::IsInsertionComponent (int i, DelTetrahedron* pkAdj,
41
const Query3<Real>* pkQuery, const int* aiSupervertex)
43
// Indexing for the vertices of the triangle opposite a vertex. The
44
// triangle opposite vertex j is
45
// <aaiIndex[j][0], aaiIndex[j][1], aaiIndex[j][2]>
46
// and is listed in counterclockwise order when viewed from outside the
48
const int aaiIndex[4][3] = { {1,2,3}, {0,3,2}, {0,1,3}, {0,2,1} };
54
// Determine if the circumsphere of the tetrahedron contains the
56
int iRelation = pkQuery->ToCircumsphere(i,V[0],V[1],V[2],V[3]);
57
IsComponent = (iRelation <= 0 ? true : false);
63
// It is possible that a tetrahedron that shares a supervertex does
64
// not have the circumsphere-containing property, but all faces of
65
// it (other than the shared one with the calling tetrahedron) are
66
// visible. These are also included in the insertion polyhedron.
67
for (int j = 0; j < 4; j++)
69
for (int k = 0; k < 4; k++)
71
if (V[j] == aiSupervertex[k])
73
// Tetrahedron shares a supervertex. It is safe to reuse
74
// k as a loop index because we are returning from the
76
int iNumInvisible = 0;
77
for (k = 0; k < 4; k++)
81
int iV0 = V[aaiIndex[k][0]];
82
int iV1 = V[aaiIndex[k][1]];
83
int iV2 = V[aaiIndex[k][2]];
84
iRelation = pkQuery->ToPlane(i,iV0,iV1,iV2);
91
IsComponent = (iNumInvisible == 0 ? true : false);
100
//----------------------------------------------------------------------------
101
template <class Real>
102
int DelTetrahedron<Real>::DetachFrom (int iAdj, DelTetrahedron* pkAdj)
104
assert(0 <= iAdj && iAdj < 4 && A[iAdj] == pkAdj);
106
for (int i = 0; i < 4; i++)
108
if (pkAdj->A[i] == this)
116
//----------------------------------------------------------------------------
118
//----------------------------------------------------------------------------
119
// explicit instantiation
120
//----------------------------------------------------------------------------
121
template WM4_FOUNDATION_ITEM
122
class DelTetrahedron<float>;
124
template WM4_FOUNDATION_ITEM
125
class DelTetrahedron<double>;
126
//----------------------------------------------------------------------------