File: Wm5PdeFilter.cpp

package info (click to toggle)
libwildmagic 5.17%2Bcleaned1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 90,112 kB
  • sloc: cpp: 215,940; csh: 637; sh: 91; makefile: 39
file content (77 lines) | stat: -rw-r--r-- 2,000 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Geometric Tools, LLC
// Copyright (c) 1998-2014
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.0 (2010/01/01)

#include "Wm5ImagicsPCH.h"
#include "Wm5PdeFilter.h"
using namespace Wm5;

//----------------------------------------------------------------------------
PdeFilter::PdeFilter (int quantity, const float* data, float borderValue,
    ScaleType scaleType)
{
    mQuantity = quantity;
    mBorderValue = borderValue;
    mScaleType = scaleType;
    mTimeStep = 0.0f;

    float maxValue = data[0];
    mMin = maxValue;
    for (int i = 1; i < mQuantity; i++)
    {
        float value = data[i];
        if (value < mMin)
        {
            mMin = value;
        }
        else if (value > maxValue)
        {
            maxValue = value;
        }
    }

    if (mMin != maxValue)
    {
        switch (mScaleType)
        {
        case ST_NONE:
            mOffset = 0.0f;
            mScale = 1.0f;
            break;
        case ST_UNIT:
            mOffset = 0.0f;
            mScale = 1.0f/(maxValue - mMin);
            break;
        case ST_SYMMETRIC:
            mOffset = -1.0f;
            mScale = 2.0f/(maxValue - mMin);
            break;
        case ST_PRESERVE_ZERO:
            mOffset = 0.0f;
            mScale = (maxValue >= -mMin ? 1.0f/maxValue : -1.0f/mMin);
            mMin = 0.0f;
            break;
        }
    }
    else
    {
        mOffset = 0.0f;
        mScale = 1.0f;
    }
}
//----------------------------------------------------------------------------
PdeFilter::~PdeFilter ()
{
}
//----------------------------------------------------------------------------
void PdeFilter::Update ()
{
    OnPreUpdate();
    OnUpdate();
    OnPostUpdate();
}
//----------------------------------------------------------------------------