1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    pipe1.cxx
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #include "vtkCallbackCommand.h"
17 #include "vtkImageData.h"
18 #include "vtkOutputPort.h"
19 #include "vtkRTAnalyticSource.h"
20 
21 #include "PipelineParallelism.h"
22 
23 static float XFreq = 60;
24 
25 // Increments XFreq of the synthetic source
IncrementXFreq(vtkObject * vtkNotUsed (caller),unsigned long vtkNotUsed (eventId),void * sr,void *)26 static void IncrementXFreq(vtkObject *vtkNotUsed( caller ),
27                            unsigned long vtkNotUsed(eventId),
28                            void *sr, void *)
29 {
30   vtkRTAnalyticSource* source1 = reinterpret_cast<vtkRTAnalyticSource*>(sr);
31   XFreq = XFreq + 10;
32   source1->SetXFreq(XFreq);
33 }
34 
35 
36 // Pipe 1 for PipelineParallelism.
37 // See PipelineParallelism.cxx for more information.
pipe1(vtkMultiProcessController * vtkNotUsed (controller),void * vtkNotUsed (arg))38 void pipe1(vtkMultiProcessController* vtkNotUsed(controller),
39            void* vtkNotUsed(arg))
40 {
41   double extent = 20;
42   int iextent = static_cast<int>(extent);
43 
44   // Synthetic image source.
45   vtkRTAnalyticSource* source1 = vtkRTAnalyticSource::New();
46   source1->SetWholeExtent (-1*iextent, iextent, -1*iextent, iextent,
47                            -1*iextent, iextent );
48   source1->SetCenter(0, 0, 0);
49   source1->SetStandardDeviation( 0.5 );
50   source1->SetMaximum( 255.0 );
51   source1->SetXFreq( XFreq );
52   source1->SetXMag( 10 );
53   source1->SetYFreq( 30 );
54   source1->SetYMag( 18 );
55   source1->SetZFreq( 40 );
56   source1->SetZMag( 5 );
57   source1->GetOutput()->SetSpacing(2.0/extent,2.0/extent,2.0/extent);
58 
59   // Output port
60   vtkOutputPort* op = vtkOutputPort::New();
61   op->SetInputConnection(source1->GetOutputPort());
62   op->SetTag(11);
63 
64   // Called every time data is requested from the output port
65   vtkCallbackCommand *cbc = vtkCallbackCommand::New();
66   cbc->SetCallback(IncrementXFreq);
67   cbc->SetClientData((void *)source1);
68   op->AddObserver(vtkCommand::EndEvent,cbc);
69   cbc->Delete();
70 
71   // Process requests
72   op->WaitForUpdate();
73 
74   // Cleanup
75   op->Delete();
76   source1->Delete();
77 
78 }
79 
80 
81