~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/App/WildMagic4/Wm4UniqueVerticesTriangles.h

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Wild Magic Source Code
 
2
// David Eberly
 
3
// http://www.geometrictools.com
 
4
// Copyright (c) 1998-2007
 
5
//
 
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.
 
14
//
 
15
// Version: 4.0.0 (2006/06/28)
 
16
 
 
17
#ifndef WM4UNIQUEVERTICESTRIANGLES_H
 
18
#define WM4UNIQUEVERTICESTRIANGLES_H
 
19
 
 
20
#include "Wm4FoundationLIB.h"
 
21
#include "Wm4System.h"
 
22
 
 
23
namespace Wm4
 
24
{
 
25
 
 
26
template <int N, class Real>
 
27
class UniqueVerticesTriangles
 
28
{
 
29
public:
 
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.
 
33
    //
 
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
 
36
    // code uses e = 0.
 
37
    
 
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
 
47
    // deleting them.
 
48
    UniqueVerticesTriangles (int iTQuantity,
 
49
        const TTuple<N,Real>* akInVertex, int& riOutVQuantity,
 
50
        TTuple<N,Real>*& rakOutVertex, int*& raiOutIndex);
 
51
 
 
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
 
62
    // deleting them.
 
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);
 
67
 
 
68
    ~UniqueVerticesTriangles ();
 
69
 
 
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;
 
77
 
 
78
private:
 
79
    void ConstructUniqueVertices (int iInVQuantity,
 
80
        const TTuple<N,Real>* akInVertex, int& raiOutVQuantity,
 
81
        TTuple<N,Real>*& rakOutVertex);
 
82
 
 
83
    int m_iInVQuantity, m_iOutVQuantity;
 
84
    int* m_aiInToOutMapping;
 
85
};
 
86
 
 
87
#include "Wm4UniqueVerticesTriangles.inl"
 
88
 
 
89
}
 
90
 
 
91
#endif