~ubuntu-branches/ubuntu/saucy/ifrit/saucy

« back to all changes in this revision

Viewing changes to core/ivolumedataconverter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-10-28 15:06:32 UTC
  • mfrom: (1.1.4 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061028150632-hyvuhvsv6zpmf5ev
Tags: 3.0.5-1
New upstream version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include "imath.h"
36
36
#include "iparallel.h"
37
37
#include "iviewmodule.h"
38
 
#include "iviewobject.h"
 
38
#include "iviewsubject.h"
39
39
 
40
40
#include <vtkPointData.h>
41
41
#include <vtkStructuredPoints.h>
47
47
#include "igenericfiltertemplate.h"
48
48
 
49
49
 
50
 
//------------------------------------------------------------------------------
51
 
iVolumeDataConverter* iVolumeDataConverter::New(iViewObject *vo)
52
 
{
53
 
        return new iVolumeDataConverter(vo);
54
 
}
55
 
 
56
 
 
57
 
iVolumeDataConverter::iVolumeDataConverter(iViewObject *vo) : iViewObjectComponent(vo), iParallelWorker(vo->GetViewModule()->GetParallelManager())
 
50
iVolumeDataConverter::iVolumeDataConverter(iViewSubject *vo) : iGenericFilter<vtkStructuredPointsToStructuredPointsFilter,vtkImageData,vtkStructuredPoints>(vo,1,true,true), iParallelWorker(vo->GetViewModule()->GetParallelManager())
58
51
{
59
52
        mCurVar = 0;
60
53
}
61
54
 
62
55
 
63
 
void iVolumeDataConverter::SyncWithData(int, void *)
64
 
{
65
 
        this->Modified();
66
 
}
67
 
 
68
 
 
69
56
void iVolumeDataConverter::SetCurrentVar(int n)
70
57
71
 
        if(n >= 0)
 
58
        if(n>=0 && n!= mCurVar)
72
59
        {
73
60
                mCurVar = n;
74
61
                this->Modified();
76
63
}
77
64
 
78
65
 
79
 
void iVolumeDataConverter::ProduceOutput(vtkImageData *input, vtkStructuredPoints *output)
 
66
void iVolumeDataConverter::ProduceOutput()
80
67
{
81
68
        int dims[3];
82
69
        double pos[3];
83
70
        
 
71
        vtkImageData *input = this->GetInput();
 
72
        vtkImageData *output = this->GetOutput();
 
73
 
84
74
        output->Initialize();
85
75
 
86
 
        int n = input->GetPointData()->GetNumberOfArrays();
87
 
        if(n == 0) return;
88
 
        if(n != this->GetLimits()->GetNumVars())
 
76
        wNumComp = input->GetPointData()->GetScalars()->GetNumberOfComponents();
 
77
        if(wNumComp == 0) return;
 
78
 
 
79
        if(wNumComp != this->GetLimits()->GetNumVars())
89
80
        {
90
81
                vtkErrorMacro("Wrong number of components in the input data");
91
82
                return;
92
83
    }
93
 
        if(mCurVar<0 || mCurVar>=n)
 
84
        if(mCurVar<0 || mCurVar>=wNumComp)
94
85
        {
95
86
                return; 
96
87
    }
112
103
        output->SetNumberOfScalarComponents(1);
113
104
        output->AllocateScalars();
114
105
        
115
 
        wInPtr = (float *)input->GetPointData()->GetArray(mCurVar)->GetVoidPointer(0);
 
106
        wInPtr = (float *)input->GetPointData()->GetScalars()->GetVoidPointer(0) + mCurVar;
116
107
        wOutPtr = (unsigned char *)output->GetScalarPointer();
117
108
        
118
109
        wStretch = this->GetLimits()->GetStretch(mCurVar);
140
131
                        if(this->GetAbortExecute()) break;
141
132
                }
142
133
 
143
 
                f = wFscale*(iDataStretch::ApplyStretch(wInPtr[l],wStretch,false)-wFoffset);
 
134
                f = wFscale*(iDataStretch::ApplyStretch(wInPtr[l*wNumComp],wStretch,false)-wFoffset);
144
135
                if(f < 0.0f) f = 0.0f;
145
136
                if(f > 255.0f) f = 255.0f;
146
137
                wOutPtr[l] = (unsigned char)round(f);