Task 3 for TaskParallelismWithPorts. See TaskParallelismWithPorts.cxx for more information.
| 13 | // Task 3 for TaskParallelismWithPorts. |
| 14 | // See TaskParallelismWithPorts.cxx for more information. |
| 15 | void task3(double data) |
| 16 | { |
| 17 | double extent = data; |
| 18 | int iextent = static_cast<int>(data); |
| 19 | // The pipeline |
| 20 | |
| 21 | // Synthetic image source. |
| 22 | vtkRTAnalyticSource* source1 = vtkRTAnalyticSource::New(); |
| 23 | source1->SetWholeExtent(-1 * iextent, iextent, -1 * iextent, iextent, -1 * iextent, iextent); |
| 24 | source1->SetCenter(0, 0, 0); |
| 25 | source1->SetStandardDeviation(0.5); |
| 26 | source1->SetMaximum(255.0); |
| 27 | source1->SetXFreq(60); |
| 28 | source1->SetXMag(10); |
| 29 | source1->SetYFreq(30); |
| 30 | source1->SetYMag(18); |
| 31 | source1->SetZFreq(40); |
| 32 | source1->SetZMag(5); |
| 33 | source1->GetOutput()->SetSpacing(2.0 / extent, 2.0 / extent, 2.0 / extent); |
| 34 | |
| 35 | // Iso-surfacing. |
| 36 | vtkContourFilter* contour = vtkContourFilter::New(); |
| 37 | contour->SetInputConnection(source1->GetOutputPort()); |
| 38 | contour->SetNumberOfContours(1); |
| 39 | contour->SetValue(0, 220); |
| 40 | |
| 41 | // Magnitude of the gradient vector. |
| 42 | vtkImageGradientMagnitude* magn = vtkImageGradientMagnitude::New(); |
| 43 | magn->SetDimensionality(3); |
| 44 | magn->SetInputConnection(source1->GetOutputPort()); |
| 45 | |
| 46 | // Probe magnitude with iso-surface. |
| 47 | vtkProbeFilter* probe = vtkProbeFilter::New(); |
| 48 | probe->SetInputConnection(contour->GetOutputPort()); |
| 49 | probe->SetSource(magn->GetOutput()); |
| 50 | probe->SpatialMatchOn(); |
| 51 | |
| 52 | // Input port |
| 53 | vtkInputPort* ip = vtkInputPort::New(); |
| 54 | ip->SetRemoteProcessId(1); |
| 55 | ip->SetTag(11); |
| 56 | |
| 57 | // Append the local and remote data |
| 58 | vtkAppendPolyData* append = vtkAppendPolyData::New(); |
| 59 | append->AddInput(ip->GetPolyDataOutput()); |
| 60 | append->AddInput(probe->GetPolyDataOutput()); |
| 61 | |
| 62 | // Rendering objects. |
| 63 | vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); |
| 64 | mapper->SetInputConnection(append->GetOutputPort()); |
| 65 | mapper->SetScalarRange(50, 180); |
| 66 | |
| 67 | vtkActor* actor = vtkActor::New(); |
| 68 | actor->SetMapper(mapper); |
| 69 | |
| 70 | // Create the render objects |
| 71 | vtkRenderWindow* renWin = vtkRenderWindow::New(); |
| 72 | renWin->SetSize(WINDOW_WIDTH, WINDOW_HEIGHT); |
nothing calls this directly
no test coverage detected