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
#ifndef WM4UNIQUEVERTICESTRIANGLES_H
18
#define WM4UNIQUEVERTICESTRIANGLES_H
20
#include "Wm4FoundationLIB.h"
21
#include "Wm4System.h"
26
template <int N, class Real>
27
class UniqueVerticesTriangles
30
// Construction and destruction. A vertex is an N-tuple of Real values,
31
// usually starting with position and optionally followed by attributes
32
// such as normal vector, colors, and texture coordinates.
34
// TO DO: Allow the user to specify an epsilon e > 0 so that vertices V0
35
// and V1 are considered to be the same when |V1-V0| <= e. The current
38
// Triangle soup. The input vertex array consists of triples of vertices,
39
// each triple representing a triangle. The array akInVertex must have
40
// 3*iTQuantity tuples. The caller is responsible for deleting the input
41
// vertex array if it was dynamically allocated. An array rakOutVertex of
42
// riOutVQuantity unique vertices and an array aiOutIndex of
43
// riOutTQuantity unique index triples are computed; raiOutIndex has
44
// 3*iTQuantity elements. The indices are relative to the array of unique
45
// vertices and each index triple represents a triangle. The output
46
// arrays are dynamically allocated. The caller is responsible for
48
UniqueVerticesTriangles (int iTQuantity,
49
const TTuple<N,Real>* akInVertex, int& riOutVQuantity,
50
TTuple<N,Real>*& rakOutVertex, int*& raiOutIndex);
52
// Indexed triangles. The input vertex array consists of all vertices
53
// referenced by the input index array. The array akInVertex must have
54
// iInVQuantity tuples. The array aiInIndex must have 3*iTQuantity
55
// elements. The caller is responsible for deleting the input arrays if
56
// they were dynamically allocated. An array rakOutVertex of
57
// riOutVQuantity unique vertices and an array aiOutIndex of iTQuantity
58
// unique index triples are computed; raiOutIndex has 3*iTQuantity
59
// elements. The indices are relative to the array of unique
60
// vertices and each index triple represents a triangle. The output
61
// arrays are dynamically allocated. The caller is responsible for
63
UniqueVerticesTriangles (int iInVQuantity,
64
const TTuple<N,Real>* akInVertex, int iTQuantity,
65
const int* aiInIndex, int& riOutVQuantity,
66
TTuple<N,Real>*& rakOutVertex, int*& raiOutIndex);
68
~UniqueVerticesTriangles ();
70
// The input vertices have indices 0 <= i < VINum. The output vertices
71
// have indices 0 <= j < VONum. The construction leads to a mapping of
72
// input indices i to output indices j. Duplicate vertices have different
73
// input indices but the same output index. The following function gives
74
// you access to the mapping. If the input index is invalid (i < 0 or
75
// i >= VINum), the return value is -1.
76
int GetOutputIndexFor (int iInputIndex) const;
79
void ConstructUniqueVertices (int iInVQuantity,
80
const TTuple<N,Real>* akInVertex, int& raiOutVQuantity,
81
TTuple<N,Real>*& rakOutVertex);
83
int m_iInVQuantity, m_iOutVQuantity;
84
int* m_aiInToOutMapping;
87
#include "Wm4UniqueVerticesTriangles.inl"