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.1 (2006/07/19)
17
#include "Wm4FoundationPCH.h"
18
#include "Wm4DelTriangle.h"
22
//----------------------------------------------------------------------------
24
DelTriangle<Real>::DelTriangle (int iV0, int iV1, int iV2)
36
//----------------------------------------------------------------------------
38
bool DelTriangle<Real>::IsInsertionComponent (int i, DelTriangle* pkAdj,
39
const Query2<Real>* pkQuery, const int* aiSupervertex)
45
// Determine the number of vertices in common with the supertriangle.
46
// The supertriangle vertices have indices VQ-3, VQ-2, and VQ-1, where
47
// VQ is the quantity of input vertices.
48
int iCommon = 0, iSVIndex = -1, j;
49
for (j = 0; j < 3; j++)
51
for (int k = 0; k < 3; k++)
53
if (V[j] == aiSupervertex[k])
64
// The classic case is that a point is in the mesh formed only by
65
// the input vertices, in which case we only test for containment
66
// in the circumcircle of the triangle.
67
iRelation = pkQuery->ToCircumcircle(i,V[0],V[1],V[2]);
71
// The classic problem is that points outside the mesh formed
72
// only by the input vertices must be handled from a visibility
73
// perspective rather than using circumcircles (compare with
74
// convex hull construction). By not doing this, you can run into
75
// the pitfall that has snared many folks--the boundary edges of
76
// the final triangulation do not form a convex polygon.
80
iV0 = V[(iSVIndex+1)%3];
81
iV1 = V[(iSVIndex+2)%3];
85
for (j = 0; j < 3; j++)
87
if (A[j] != 0 && A[j] != pkAdj)
95
iRelation = pkQuery->ToLine(i,iV0,iV1);
98
IsComponent = (iRelation < 0 ? true : false);
103
//----------------------------------------------------------------------------
104
template <class Real>
105
int DelTriangle<Real>::DetachFrom (int iAdj, DelTriangle* pkAdj)
107
assert(0 <= iAdj && iAdj < 3 && A[iAdj] == pkAdj);
109
for (int i = 0; i < 3; i++)
111
if (pkAdj->A[i] == this)
119
//----------------------------------------------------------------------------
121
//----------------------------------------------------------------------------
122
// explicit instantiation
123
//----------------------------------------------------------------------------
124
template WM4_FOUNDATION_ITEM
125
class DelTriangle<float>;
127
template WM4_FOUNDATION_ITEM
128
class DelTriangle<double>;
129
//----------------------------------------------------------------------------