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

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/App/WildMagic4/Wm4LinComp.inl

  • 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
//----------------------------------------------------------------------------
 
18
template <class Real>
 
19
LinComp<Real>::LinComp ()
 
20
{
 
21
    m_iType = CT_EMPTY;
 
22
    m_fMin = Math<Real>::MAX_REAL;
 
23
    m_fMax = -Math<Real>::MAX_REAL;
 
24
}
 
25
//----------------------------------------------------------------------------
 
26
template <class Real>
 
27
LinComp<Real>::~LinComp ()
 
28
{
 
29
}
 
30
//----------------------------------------------------------------------------
 
31
template <class Real>
 
32
LinComp<Real>& LinComp<Real>::operator= (const LinComp& rkComponent)
 
33
{
 
34
    m_iType = rkComponent.m_iType;
 
35
    m_fMin = rkComponent.m_fMin;
 
36
    m_fMax = rkComponent.m_fMax;
 
37
    return *this;
 
38
}
 
39
//----------------------------------------------------------------------------
 
40
template <class Real>
 
41
int LinComp<Real>::GetType () const
 
42
{
 
43
    return m_iType;
 
44
}
 
45
//----------------------------------------------------------------------------
 
46
template <class Real>
 
47
Real LinComp<Real>::GetMin () const
 
48
{
 
49
    return m_fMin;
 
50
}
 
51
//----------------------------------------------------------------------------
 
52
template <class Real>
 
53
Real LinComp<Real>::GetMax () const
 
54
{
 
55
    return m_fMax;
 
56
}
 
57
//----------------------------------------------------------------------------
 
58
template <class Real>
 
59
bool LinComp<Real>::Contains (Real fParam) const
 
60
{
 
61
    return m_fMin <= fParam && fParam <= m_fMax;
 
62
}
 
63
//----------------------------------------------------------------------------
 
64
template <class Real>
 
65
void LinComp<Real>::SetInterval (Real fMin, Real fMax)
 
66
{
 
67
    m_iType = GetTypeFromInterval(fMin,fMax);
 
68
    m_fMin = fMin;
 
69
    m_fMax = fMax;
 
70
}
 
71
//----------------------------------------------------------------------------
 
72
template <class Real>
 
73
int LinComp<Real>::GetTypeFromInterval (Real fMin, Real fMax)
 
74
{
 
75
    if (fMin < fMax)
 
76
    {
 
77
        if (fMax == Math<Real>::MAX_REAL)
 
78
        {
 
79
            if (fMin == -Math<Real>::MAX_REAL)
 
80
            {
 
81
                return CT_LINE;
 
82
            }
 
83
            else
 
84
            {
 
85
                return CT_RAY;
 
86
            }
 
87
        }
 
88
        else
 
89
        {
 
90
            if (fMin == -Math<Real>::MAX_REAL)
 
91
            {
 
92
                return CT_RAY;
 
93
            }
 
94
            else
 
95
            {
 
96
                return CT_SEGMENT;
 
97
            }
 
98
        }
 
99
    }
 
100
    else if (fMin == fMax)
 
101
    {
 
102
        if (fMin != -Math<Real>::MAX_REAL && fMax != Math<Real>::MAX_REAL)
 
103
        {
 
104
            return CT_POINT;
 
105
        }
 
106
    }
 
107
 
 
108
    return CT_EMPTY;
 
109
}
 
110
//----------------------------------------------------------------------------
 
111
template <class Real>
 
112
bool LinComp<Real>::IsCanonical () const
 
113
{
 
114
    if (m_iType == CT_RAY)
 
115
    {
 
116
        return m_fMin == (Real)0.0 && m_fMax == Math<Real>::MAX_REAL;
 
117
    }
 
118
 
 
119
    if (m_iType == CT_SEGMENT)
 
120
    {
 
121
        return m_fMin == -m_fMax;
 
122
    }
 
123
 
 
124
    if (m_iType == CT_POINT)
 
125
    {
 
126
        return m_fMin == (Real)0.0; 
 
127
    }
 
128
 
 
129
    if (m_iType == CT_EMPTY)
 
130
    {
 
131
        return m_fMin == Math<Real>::MAX_REAL
 
132
            && m_fMax == -Math<Real>::MAX_REAL;
 
133
    }
 
134
 
 
135
    // m_iType == CT_LINE
 
136
    return true;
 
137
}
 
138
//----------------------------------------------------------------------------