~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/visualizator/visualizator/wxvtk/reconstruction/pipelines/volumepipeline.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
ImportĀ upstreamĀ versionĀ 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*
 
3
*  $Id: volumepipeline.cpp 3558 2011-03-20 20:02:22Z carlos $
 
4
*  Ginkgo CADx Project
 
5
*
 
6
*  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
*  http://ginkgo-cadx.com
 
8
*
 
9
*  This file is licensed under LGPL v3 license.
 
10
*  See License.txt for details
 
11
*
 
12
*
 
13
*/
 
14
#ifdef __DEPRECATED
 
15
#undef __DEPRECATED
 
16
#endif
 
17
#include "volumepipeline.h"
 
18
#include "../volumedataset/volumedataset.h"
 
19
 
 
20
#include <exception>
 
21
#include <wx/window.h>
 
22
#include <api/internacionalizacion.h>
 
23
#include <main/controllers/controladorlog.h>
 
24
 
 
25
#ifdef __DEPRECATED
 
26
#undef __DEPRECATED
 
27
#endif
 
28
 
 
29
#include <vtkCommand.h>
 
30
#include <vtkImageData.h>
 
31
#include <vtkRenderer.h>
 
32
#include <vtkImageData.h>
 
33
#include <vtkRenderer.h>
 
34
#include <vtkImageResample.h>
 
35
#include <vtkImageData.h>
 
36
#include <vtkRenderer.h>
 
37
#include <vtkImageResample.h>
 
38
#include <vtkVolume.h>
 
39
#include <vtkSmartVolumeMapper.h>
 
40
#include <vtkColorTransferFunction.h>
 
41
#include <vtkPiecewiseFunction.h>
 
42
#include <vtkVolumeProperty.h>
 
43
#include <vtkImageReslice.h>
 
44
 
 
45
#include <vtkCamera.h>
 
46
#include <vtkProperty.h>
 
47
#include <vtkRenderWindow.h>
 
48
#include <vtkRenderWindowInteractor.h>
 
49
 
 
50
#include <vtkWindowToImageFilter.h>
 
51
#include <vtkJPEGWriter.h>
 
52
 
 
53
#include "../interactors/reconstructioninteractor.h"
 
54
#include <vtkInteractorStyleTrackballCamera.h>
 
55
 
 
56
class InteractionCommand : public vtkCommand
 
57
{
 
58
public:
 
59
 
 
60
        typedef MedicalViewer::Reconstruction::Pipelines::VolumePipeline TPipeline;
 
61
        typedef GinkgoInteractorStyleReconstruction TStyleReconstruction;
 
62
 
 
63
        InteractionCommand() : Pipeline(NULL), InitialWindow(0), InitialLevel(0), WindowEventStatus(false)
 
64
        {
 
65
                Initiallized = false;
 
66
        }
 
67
 
 
68
        static  InteractionCommand* New()
 
69
        {
 
70
                return new InteractionCommand();
 
71
        }
 
72
 
 
73
        void SetPipeline(TPipeline* pipeline)
 
74
        {
 
75
                Pipeline = pipeline;
 
76
        }
 
77
 
 
78
        void Execute(vtkObject *   caller,
 
79
                                 unsigned long event,
 
80
                                 void *        callData)
 
81
        {
 
82
 
 
83
                if (this->Pipeline == NULL)
 
84
                {
 
85
                        return;
 
86
                }
 
87
 
 
88
                if (event == vtkCommand::StartWindowLevelEvent) {
 
89
                        if (this->Pipeline->IsInitiallized() ) {
 
90
                                Initiallized = true;
 
91
                        }
 
92
                        if (Initiallized) {
 
93
                                this->StartWindowing();
 
94
                        }
 
95
                        return;
 
96
                }
 
97
                if (event == vtkCommand::EndWindowLevelEvent) {
 
98
                        if (Initiallized) {
 
99
                                this->EndWindowing();
 
100
                        }
 
101
                        return;
 
102
                }
 
103
                if (event == vtkCommand::WindowLevelEvent) {
 
104
                        if (Initiallized) {
 
105
                                this->Windowing( (TStyleReconstruction*) caller);
 
106
                        }
 
107
                        return;
 
108
                }
 
109
        }
 
110
 
 
111
        //ETX
 
112
 
 
113
private:
 
114
 
 
115
        void Windowing(TStyleReconstruction* p_isi)
 
116
        {
 
117
                if( !p_isi )
 
118
                {
 
119
                        return;
 
120
                }
 
121
 
 
122
                double window = this->InitialWindow;
 
123
                double level  = this->InitialLevel;
 
124
                double EPS    = std::numeric_limits<double>::epsilon();
 
125
 
 
126
 
 
127
                double dx = p_isi->GetWindowStep();
 
128
                double dy = p_isi->GetLevelStep();
 
129
 
 
130
                // Scale by current values
 
131
                if (fabs(window) > EPS)
 
132
                {
 
133
                        dx = dx * window;
 
134
                }
 
135
                else
 
136
                {
 
137
                        dx = dx * (window < 0 ? -EPS : EPS);
 
138
                }
 
139
 
 
140
                if (fabs(level) > EPS)
 
141
                {
 
142
                        dy = dy * level;
 
143
                }
 
144
                else
 
145
                {
 
146
                        dy = dy * (level < 0 ? -EPS : EPS);
 
147
                }
 
148
 
 
149
                // Abs so that direction does not flip
 
150
                if (window < 0.0f)
 
151
                {
 
152
                        dx = -1*dx;
 
153
                }
 
154
                if (level < 0.0f)
 
155
                {
 
156
                        dy = -1*dy;
 
157
                }
 
158
 
 
159
                // Compute new window level
 
160
                double newWindow = dx + window;
 
161
                double newLevel  = level - dy;
 
162
 
 
163
                // Stay away from zero and really
 
164
                if (fabs(newWindow) < EPS)
 
165
                {
 
166
                        newWindow = EPS * (newWindow < 0 ? -1 : 1);
 
167
                }
 
168
 
 
169
                if (fabs(newLevel) < EPS)
 
170
                {
 
171
                        newLevel = EPS * (newLevel < 0 ? -1 : 1);
 
172
                }
 
173
 
 
174
                this->Pipeline->UpdateBlending(newWindow, newLevel);
 
175
        }
 
176
 
 
177
        void StartWindowing()
 
178
        {
 
179
                this->InitialWindow = this->Pipeline->Window;
 
180
                this->InitialLevel  = this->Pipeline->Level;
 
181
        }
 
182
 
 
183
        void EndWindowing()
 
184
        {
 
185
 
 
186
        }
 
187
 
 
188
private:
 
189
        TPipeline*      Pipeline;
 
190
 
 
191
        double          InitialWindow;
 
192
        double          InitialLevel;
 
193
 
 
194
        bool            WindowEventStatus;
 
195
        bool            Initiallized;
 
196
 
 
197
};
 
198
 
 
199
//==============================================================================================
 
200
 
 
201
namespace MedicalViewer {
 
202
        namespace Reconstruction {
 
203
                namespace Pipelines {
 
204
 
 
205
                        class VolumeCommandObserver : public vtkCommand
 
206
                        {
 
207
                        public:
 
208
 
 
209
                                static VolumeCommandObserver* New() {
 
210
                                        return new VolumeCommandObserver();
 
211
                                }
 
212
 
 
213
                                void SetInformation(const std::string& text)
 
214
                                {
 
215
                                        Text = text;
 
216
                                }
 
217
 
 
218
                                void SetNotifier(IReconstructionNotifier* notifier)
 
219
                                {
 
220
                                        Notifier = notifier;
 
221
                                }
 
222
 
 
223
                                virtual void Execute(vtkObject* caller, unsigned long, void *callData) {
 
224
                                        double dProgress = *( (double*)(callData) );
 
225
                                        vtkAlgorithm* alg = (vtkAlgorithm* ) caller;
 
226
                                        if (Notifier) {
 
227
                                                if (! Notifier->NotifyReconstructionProgress( Text, (float)dProgress) ){
 
228
                                                        alg->AbortExecuteOn();
 
229
                                                }
 
230
                                        }
 
231
                                }
 
232
 
 
233
                                std::string Text;
 
234
 
 
235
                                IReconstructionNotifier* Notifier;
 
236
                        };
 
237
                }
 
238
        }
 
239
}
 
240
 
 
241
MedicalViewer::Reconstruction::Pipelines::VolumePipeline::VolumePipeline(wxWindow* win3d) : IPipeline("Reconstruction/Surface", win3d)
 
242
{
 
243
 
 
244
        CurrentBlendType = VBT_MIP;
 
245
        vtkSmartPointer<VolumeCommandObserver> Progress;
 
246
 
 
247
        Renderer->SetBackground(0.0, 0.0, 0.0);
 
248
 
 
249
        Resample = vtkSmartPointer<vtkImageResample>::New();
 
250
 
 
251
        Volume = vtkSmartPointer<vtkVolume>::New();
 
252
        Mapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
 
253
        Mapper->SetRequestedRenderMode(vtkSmartVolumeMapper::RayCastRenderMode);
 
254
        Mapper->SetInputConnection( Resample->GetOutputPort() );
 
255
 
 
256
        ColorTransferFunction   = vtkSmartPointer<vtkColorTransferFunction>::New();
 
257
        OpacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
 
258
 
 
259
        VolumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
 
260
 
 
261
        VolumeProperty->SetColor( ColorTransferFunction );
 
262
        VolumeProperty->SetScalarOpacity( OpacityTransferFunction );
 
263
        VolumeProperty->SetInterpolationTypeToLinear();
 
264
 
 
265
        Volume->SetProperty( VolumeProperty );
 
266
        Volume->SetMapper( Mapper );
 
267
        Volume->VisibilityOff();
 
268
 
 
269
        Renderer->AddVolume(Volume);
 
270
 
 
271
        Interactor = vtkSmartPointer<GinkgoInteractorStyleReconstruction>::New();
 
272
 
 
273
        //Progresses
 
274
 
 
275
        Progress = vtkSmartPointer<VolumeCommandObserver>::New();
 
276
        Progress->SetInformation("Resampling volume");
 
277
        Resample->AddObserver(vtkCommand::ProgressEvent, Progress);
 
278
        Progresses.push_back(Progress);
 
279
 
 
280
        Progress = vtkSmartPointer<VolumeCommandObserver>::New();
 
281
        Progress->SetInformation("Computing volume");
 
282
        Volume->AddObserver(vtkCommand::ProgressEvent, Progress);
 
283
        Progresses.push_back(Progress);
 
284
 
 
285
        Progress = vtkSmartPointer<VolumeCommandObserver>::New();
 
286
        Progress->SetInformation("Mapping volume");
 
287
        Mapper->AddObserver(vtkCommand::ProgressEvent, Progress);
 
288
        Progresses.push_back(Progress);
 
289
 
 
290
 
 
291
 
 
292
}
 
293
MedicalViewer::Reconstruction::Pipelines::VolumePipeline::~VolumePipeline()
 
294
{
 
295
}
 
296
 
 
297
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetupInteractor()
 
298
{
 
299
 
 
300
        vtkSmartPointer<InteractionCommand> cbk = vtkSmartPointer<InteractionCommand>::New();
 
301
        cbk->SetPipeline(this);
 
302
        //Interactor->AddObserver(vtkCommand::KeyPressEvent, cbk);
 
303
        Interactor->AddObserver(vtkCommand::WindowLevelEvent, cbk);
 
304
        Interactor->AddObserver(vtkCommand::StartWindowLevelEvent, cbk);
 
305
        Interactor->AddObserver(vtkCommand::ResetWindowLevelEvent, cbk);
 
306
        Interactor->AddObserver(vtkCommand::EndWindowLevelEvent, cbk);
 
307
        //Interactor->AddObserver(InteractionCommand::ZoomEvent, cbk);
 
308
        SetInteractorStyleToDefault();
 
309
 
 
310
}
 
311
 
 
312
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetInteractorStyleToDefault()
 
313
{
 
314
        Renderer->GetRenderWindow()->GetInteractor()->SetInteractorStyle(vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New());
 
315
}
 
316
 
 
317
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetInteractorStyleToWindowLevel()
 
318
{
 
319
        Renderer->GetRenderWindow()->GetInteractor()->SetInteractorStyle(Interactor);
 
320
}
 
321
 
 
322
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetWindowLevel(double window, double level)
 
323
{
 
324
        SettedWindow = Window = window;
 
325
        SettedLevel = Level = level;
 
326
}
 
327
 
 
328
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::ResetWindowLevel()
 
329
{
 
330
        Window = SettedWindow;
 
331
        Level = SettedLevel;
 
332
        if (CurrentBlendType < VBT_RGB_Composite) {
 
333
                SetBlendingType(CurrentBlendType);
 
334
        }
 
335
}
 
336
 
 
337
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::UpdateBlending(double window, double level)
 
338
{
 
339
        Window = window;
 
340
        Level = level;
 
341
        if (CurrentBlendType < VBT_RGB_Composite) {
 
342
                SetBlendingType(CurrentBlendType);
 
343
                Render();
 
344
        }
 
345
 
 
346
}
 
347
 
 
348
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingType(VolumeBlendType blendType) {
 
349
        switch(blendType) {
 
350
                case VBT_CompositeRamp:
 
351
                        SetBlendingToCompositeRamp();
 
352
                        break;
 
353
                case VBT_CompositeShadeRamp:
 
354
                        SetBlendingToCompositeShadeRamp();
 
355
                        break;
 
356
                case VBT_RGB_Composite:
 
357
                        SetBlendingToRGBComposite();
 
358
                        break;
 
359
                case VBT_CT_Skin:
 
360
                        SetBlendingToCTSkin();
 
361
                        break;
 
362
                case VBT_CT_Muscle:
 
363
                        SetBlendingToCTMuscle();
 
364
                        break;
 
365
                case VBT_CT_Bone:
 
366
                        SetBlendingToCTBone();
 
367
                        break;
 
368
                case VBT_MIP:
 
369
                default:
 
370
                        SetBlendingToMIP();
 
371
                        break;
 
372
        }
 
373
        CurrentBlendType = blendType;
 
374
}
 
375
 
 
376
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToMIP()
 
377
{
 
378
        ColorTransferFunction->RemoveAllPoints();
 
379
        OpacityTransferFunction->RemoveAllPoints();
 
380
        OpacityTransferFunction->Modified();
 
381
        ColorTransferFunction->Modified();
 
382
 
 
383
        ColorTransferFunction->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0 );
 
384
        OpacityTransferFunction->AddSegment( Level - 0.5 * Window, 0.0,
 
385
                                                  Level + 0.5 * Window, 1.0 );
 
386
        Mapper->SetBlendModeToMaximumIntensity();
 
387
}
 
388
 
 
389
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToCompositeRamp()
 
390
{
 
391
        ColorTransferFunction->RemoveAllPoints();
 
392
        OpacityTransferFunction->RemoveAllPoints();
 
393
        OpacityTransferFunction->Modified();
 
394
        ColorTransferFunction->Modified();
 
395
 
 
396
        ColorTransferFunction->AddRGBSegment(Level - 0.5 * Window, 0.0, 0.0, 0.0, Level + 0.5*Window, 1.0, 1.0, 1.0 );
 
397
        OpacityTransferFunction->AddSegment( Level - 0.5 * Window, 0.0, Level + 0.5 * Window, 1.0 );
 
398
        Mapper->SetBlendModeToComposite();
 
399
        VolumeProperty->ShadeOff();
 
400
}
 
401
 
 
402
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToCompositeShadeRamp()
 
403
{
 
404
        ColorTransferFunction->RemoveAllPoints();
 
405
        OpacityTransferFunction->RemoveAllPoints();
 
406
        OpacityTransferFunction->Modified();
 
407
        ColorTransferFunction->Modified();
 
408
 
 
409
        ColorTransferFunction->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0 );
 
410
        OpacityTransferFunction->AddSegment( Level - 0.5 * Window, 0.0, Level + 0.5 * Window, 1.0 );
 
411
        Mapper->SetBlendModeToComposite();
 
412
        VolumeProperty->ShadeOn();
 
413
}
 
414
 
 
415
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToRGBComposite()
 
416
{
 
417
        ColorTransferFunction->RemoveAllPoints();
 
418
        OpacityTransferFunction->RemoveAllPoints();
 
419
        OpacityTransferFunction->Modified();
 
420
        ColorTransferFunction->Modified();
 
421
 
 
422
        OpacityTransferFunction->AddPoint(0, 0.0);
 
423
        OpacityTransferFunction->AddPoint(5.0, 0.0);
 
424
        OpacityTransferFunction->AddPoint(30.0, 0.05);
 
425
        OpacityTransferFunction->AddPoint(31.0, 0.0);
 
426
        OpacityTransferFunction->AddPoint(90.0, 0.0);
 
427
        OpacityTransferFunction->AddPoint(100.0, 0.3);
 
428
        OpacityTransferFunction->AddPoint(110.0, 0.0);
 
429
        OpacityTransferFunction->AddPoint(190.0, 0.0);
 
430
        OpacityTransferFunction->AddPoint(200.0, 0.4);
 
431
        OpacityTransferFunction->AddPoint(210.0, 0.0);
 
432
        OpacityTransferFunction->AddPoint(245.0, 0.0);
 
433
        OpacityTransferFunction->AddPoint(255.0, 0.5);
 
434
 
 
435
        Mapper->SetBlendModeToComposite();
 
436
        VolumeProperty->ShadeOff();
 
437
        VolumeProperty->SetScalarOpacityUnitDistance(1.0);
 
438
}
 
439
 
 
440
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToCTSkin()
 
441
{
 
442
        ColorTransferFunction->RemoveAllPoints();
 
443
        OpacityTransferFunction->RemoveAllPoints();
 
444
        OpacityTransferFunction->Modified();
 
445
        ColorTransferFunction->Modified();
 
446
 
 
447
        ColorTransferFunction->AddRGBPoint( -3024, 0, 0, 0, 0.5, 0.0 );
 
448
        ColorTransferFunction->AddRGBPoint( -1000, .62, .36, .18, 0.5, 0.0 );
 
449
        ColorTransferFunction->AddRGBPoint( 100, .88, .60, .29, 0.33, 0.45 );
 
450
        ColorTransferFunction->AddRGBPoint( 3071, .83, .66, 1, 0.5, 0.0 );
 
451
 
 
452
        OpacityTransferFunction->AddPoint(-3024, 0, 0.5, 0.0 );
 
453
        OpacityTransferFunction->AddPoint(-1000, 0, 0.5, 0.0 );
 
454
        OpacityTransferFunction->AddPoint(100, 1.0, 0.33, 0.45 );
 
455
        OpacityTransferFunction->AddPoint(3071, 1.0, 0.5, 0.0);
 
456
 
 
457
        Mapper->SetBlendModeToComposite();
 
458
        VolumeProperty->ShadeOn();
 
459
        VolumeProperty->SetAmbient(0.1);
 
460
        VolumeProperty->SetDiffuse(0.9);
 
461
        VolumeProperty->SetSpecular(0.2);
 
462
        VolumeProperty->SetSpecularPower(10.0);
 
463
        VolumeProperty->SetScalarOpacityUnitDistance(0.8919);
 
464
}
 
465
 
 
466
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToCTMuscle()
 
467
{
 
468
        ColorTransferFunction->RemoveAllPoints();
 
469
        OpacityTransferFunction->RemoveAllPoints();
 
470
        OpacityTransferFunction->Modified();
 
471
        ColorTransferFunction->Modified();
 
472
 
 
473
        ColorTransferFunction->AddRGBPoint( -3024, 0, 0, 0, 0.5, 0.0 );
 
474
        ColorTransferFunction->AddRGBPoint( -155, .55, .25, .15, 0.5, .92 );
 
475
        ColorTransferFunction->AddRGBPoint( 217, .88, .60, .29, 0.33, 0.45 );
 
476
        ColorTransferFunction->AddRGBPoint( 420, 1, .94, .95, 0.5, 0.0 );
 
477
        ColorTransferFunction->AddRGBPoint( 3071, .83, .66, 1, 0.5, 0.0 );
 
478
 
 
479
        OpacityTransferFunction->AddPoint(-3024, 0, 0.5, 0.0 );
 
480
        OpacityTransferFunction->AddPoint(-155, 0, 0.5, 0.92 );
 
481
        OpacityTransferFunction->AddPoint(217, .68, 0.33, 0.45 );
 
482
        OpacityTransferFunction->AddPoint(420,.83, 0.5, 0.0);
 
483
        OpacityTransferFunction->AddPoint(3071, .80, 0.5, 0.0);
 
484
 
 
485
        Mapper->SetBlendModeToComposite();
 
486
        VolumeProperty->ShadeOn();
 
487
        VolumeProperty->SetAmbient(0.1);
 
488
        VolumeProperty->SetDiffuse(0.9);
 
489
        VolumeProperty->SetSpecular(0.2);
 
490
        VolumeProperty->SetSpecularPower(10.0);
 
491
        VolumeProperty->SetScalarOpacityUnitDistance(0.8919);
 
492
}
 
493
 
 
494
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetBlendingToCTBone()
 
495
{
 
496
        ColorTransferFunction->RemoveAllPoints();
 
497
        OpacityTransferFunction->RemoveAllPoints();
 
498
        OpacityTransferFunction->Modified();
 
499
        ColorTransferFunction->Modified();
 
500
 
 
501
        ColorTransferFunction->AddRGBPoint( -3024, 0, 0, 0, 0.5, 0.0 );
 
502
        ColorTransferFunction->AddRGBPoint( -16, 0.73, 0.25, 0.30, 0.49, .61 );
 
503
        ColorTransferFunction->AddRGBPoint( 641, .90, .82, .56, .5, 0.0 );
 
504
        ColorTransferFunction->AddRGBPoint( 3071, 1, 1, 1, .5, 0.0 );
 
505
 
 
506
        OpacityTransferFunction->AddPoint(-3024, 0, 0.5, 0.0 );
 
507
        OpacityTransferFunction->AddPoint(-16, 0, .49, .61 );
 
508
        OpacityTransferFunction->AddPoint(641, .72, .5, 0.0 );
 
509
        OpacityTransferFunction->AddPoint(3071, .71, 0.5, 0.0);
 
510
 
 
511
        Mapper->SetBlendModeToComposite();
 
512
        VolumeProperty->ShadeOn();
 
513
        VolumeProperty->SetAmbient(0.1);
 
514
        VolumeProperty->SetDiffuse(0.9);
 
515
        VolumeProperty->SetSpecular(0.2);
 
516
        VolumeProperty->SetSpecularPower(10.0);
 
517
        VolumeProperty->SetScalarOpacityUnitDistance(0.8919);
 
518
}
 
519
 
 
520
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetDataSet(unsigned int volNum, double reductionFactor)
 
521
{
 
522
 
 
523
        GnkPtr<TDataSet> vol = FindDataSet(volNum);
 
524
 
 
525
        if (!vol) {
 
526
                LOG_ERROR("Reconstruction/Volume", "Unable to set DataSet " << volNum << ": DataSet not found");
 
527
                return;
 
528
        }
 
529
 
 
530
        LOG_DEBUG("Reconstruction/Volume", "Setting DataSet " << volNum << ". Range = [ " << vol->MinValue << ", " << vol->MaxValue << " ]");
 
531
 
 
532
        CurrentImage = vol->Img;
 
533
        Window = (double)vol->MaxValue - (double)vol->MinValue;
 
534
        Level = 0.5 * Window;
 
535
 
 
536
        Resample->RemoveAllInputs();
 
537
        Resample->SetInput(CurrentImage);
 
538
        Resample->SetAxisMagnificationFactor(0, reductionFactor);
 
539
        Resample->SetAxisMagnificationFactor(1, reductionFactor);
 
540
        Resample->SetAxisMagnificationFactor(2, reductionFactor);
 
541
}
 
542
 
 
543
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::Enable(bool enable)
 
544
{
 
545
        Volume->SetVisibility(enable? 1: 0);
 
546
}
 
547
 
 
548
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::Update()
 
549
{
 
550
 
 
551
        LOG_DEBUG("VolumePipeline", _Std("Updating..."));
 
552
 
 
553
        Resample->AbortExecuteOff();
 
554
        Mapper->AbortExecuteOff();
 
555
 
 
556
        try {
 
557
                Mapper->Update();
 
558
        }
 
559
        catch (...)
 
560
        {
 
561
        }
 
562
 
 
563
        LOG_DEBUG("VolumePipeline", _Std("Update done"));
 
564
}
 
565
 
 
566
void MedicalViewer::Reconstruction::Pipelines::VolumePipeline::SetProgressNotifier(IReconstructionNotifier* notifier)
 
567
{
 
568
        for (TProgressList::iterator it = Progresses.begin(); it != Progresses.end(); it++) {
 
569
                (*it)->SetNotifier(notifier);
 
570
        }
 
571
}