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

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/App/WildMagic4/Wm4Mapper2.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 WM4MAPPER2_H
 
18
#define WM4MAPPER2_H
 
19
 
 
20
#include "Wm4FoundationLIB.h"
 
21
#include "Wm4Vector2.h"
 
22
 
 
23
namespace Wm4
 
24
{
 
25
 
 
26
template <class Real>
 
27
class Mapper2
 
28
{
 
29
public:
 
30
    // Construction and destruction.  The value of epsilon is used as a
 
31
    // relative error when computing the dimension of the point set.
 
32
    Mapper2 (int iVQuantity, const Vector2<Real>* akVertex, Real fEpsilon);
 
33
    ~Mapper2 ();
 
34
 
 
35
    // Axis-aligned bounding box of the input points.
 
36
    const Vector2<Real>& GetMin () const;
 
37
    const Vector2<Real>& GetMax () const;
 
38
    Real GetMaxRange () const;
 
39
 
 
40
    // Dimension d of the set (0, 1, or 2).
 
41
    int GetDimension () const;
 
42
 
 
43
    // Coordinate system.  The origin is valid for any dimension d.  The
 
44
    // unit-length direction vector is valid only for 0 <= i < d.  The extreme
 
45
    // index is relative to the array of input points, and is also valid only
 
46
    // for 0 <= i < d.  If d = 0, all points are effectively the same, but the
 
47
    // use of an epsilon may lead to an extreme index that is not zero.  If
 
48
    // d = 1, all points effectively lie on a line segment.  The extreme
 
49
    // indices correspond to input points that are the end points of the
 
50
    // segment.  If d = 2, the first two extreme indices correspond to a
 
51
    // line segment.  The next extreme index corresponds to the input point
 
52
    // that is farthest from this line segment in the direction perpendicular
 
53
    // to the segment.
 
54
    const Vector2<Real>& GetOrigin () const;
 
55
    const Vector2<Real>& GetDirection (int i) const;
 
56
    int GetExtremeIndex (int i) const;
 
57
 
 
58
    // If d = 2, the direction vectors {U0,U1} form a right-handed set.  The
 
59
    // three extreme points form a triangle.  This function indicates if that
 
60
    // triangle is counterclockwise ordered.
 
61
    bool GetExtremeCCW () const;
 
62
 
 
63
private:
 
64
    // Axis-aligned bounding box of input points.  The maximum range is the
 
65
    // larger of max[0]-min[0] and max[1]-min[1].
 
66
    Vector2<Real> m_kMin, m_kMax;
 
67
    Real m_fMaxRange;
 
68
 
 
69
    // The intrinsic dimension of the input set.  The parameter fEpsilon to
 
70
    // the constructor is used to provide a tolerance when determining the
 
71
    // dimension.
 
72
    int m_iDimension;
 
73
 
 
74
    // The indices that define the maximum dimensional extents.  The values
 
75
    // m_aiExtreme[0] and m_aiExtreme[1] are the indices for the vertices
 
76
    // which define the largest extent in one of the coordinate axis
 
77
    // directions.  If the intrinsic dimensionality is 2, then m_aiExtreme[2]
 
78
    // is the index for the vertex which causes the largest extent in the
 
79
    // direction perpendicular to the line through the vertices corresponding
 
80
    // to m_aiExtreme[0] and m_aiExtreme[1].  The triangle
 
81
    // <V[extreme0],V[extreme1],V[extreme2]> can be clockwise or
 
82
    // counterclockwise, the condition stored in m_bExtremeCCW.
 
83
    int m_aiExtreme[3];
 
84
    bool m_bExtremeCCW;
 
85
 
 
86
    // See the comments describing the member functions which return these
 
87
    // values.
 
88
    Vector2<Real> m_kOrigin;
 
89
    Vector2<Real> m_akDirection[2];
 
90
};
 
91
 
 
92
#include "Wm4Mapper2.inl"
 
93
 
 
94
typedef Mapper2<float> Mapper2f;
 
95
typedef Mapper2<double> Mapper2d;
 
96
 
 
97
}
 
98
 
 
99
#endif