MCPcopy Create free account
hub / github.com/Kitware/VTK / MyMain

Function MyMain

Examples/ParallelProcessing/Generic/Cxx/ParallelIso.cxx:77–210  ·  view source on GitHub ↗

This will be called by all processes

Source from the content-addressed store, hash-verified

75
76// This will be called by all processes
77void MyMain(vtkMultiProcessController* controller, void* arg)
78{
79 vtkImageReader* reader;
80 vtkContourFilter* iso;
81 vtkElevationFilter* elev;
82 int myid, numProcs;
83 float val;
84 ParallelIsoArgs_tmp* args = reinterpret_cast<ParallelIsoArgs_tmp*>(arg);
85
86 // Obtain the id of the running process and the total
87 // number of processes
88 myid = controller->GetLocalProcessId();
89 numProcs = controller->GetNumberOfProcesses();
90
91 // Create the reader, the data file name might have
92 // to be changed depending on where the data files are.
93 char* fname = vtkTestUtilities::ExpandDataFileName(args->argc, args->argv, "Data/headsq/quarter");
94 reader = vtkImageReader::New();
95 reader->SetDataByteOrderToLittleEndian();
96 reader->SetDataExtent(0, 63, 0, 63, 1, 93);
97 reader->SetFilePrefix(fname);
98 reader->SetDataSpacing(3.2, 3.2, 1.5);
99 delete[] fname;
100
101 // Iso-surface.
102 iso = vtkContourFilter::New();
103 iso->SetInputConnection(reader->GetOutputPort());
104 iso->SetValue(0, ISO_START);
105 iso->ComputeScalarsOff();
106 iso->ComputeGradientsOff();
107
108 // Compute a different color for each process.
109 elev = vtkElevationFilter::New();
110 elev->SetInputConnection(iso->GetOutputPort());
111 val = (myid + 1) / static_cast<float>(numProcs);
112 elev->SetScalarRange(val, val + 0.001);
113
114 if (myid != 0)
115 {
116 // If I am not the root process
117 ParallelIsoRMIArgs_tmp args2;
118 args2.ContourFilter = iso;
119 args2.Controller = controller;
120 args2.Elevation = elev;
121
122 // Last, set up a RMI call back to change the iso surface value.
123 // This is done so that the root process can let this process
124 // know that it wants the contour value to change.
125 controller->AddRMI(SetIsoValueRMI, (void*)&args2, ISO_VALUE_RMI_TAG);
126 controller->ProcessRMIs();
127 }
128 else
129 {
130 // Create the rendering part of the pipeline
131 vtkAppendPolyData* app = vtkAppendPolyData::New();
132 vtkRenderer* ren = vtkRenderer::New();
133 vtkRenderWindow* renWindow = vtkRenderWindow::New();
134 vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();

Callers

nothing calls this directly

Calls 15

GetNumberOfProcessesMethod · 0.80
SetDataExtentMethod · 0.80
SetDataSpacingMethod · 0.80
AddRMIMethod · 0.80
SetViewUpMethod · 0.80
SetViewAngleMethod · 0.80
SetActiveCameraMethod · 0.80
UpdatePieceMethod · 0.80
TriggerRMIMethod · 0.80
DeleteMethod · 0.65
RenderMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected