<p>dear all: <br>&nbsp; &nbsp;I want to parallel volume rendering in my computer, but I can not make it parallel, here is my code. Is there any wrong? <br>#include &quot;vtkCompositeRenderManager.h&quot; <br>#include &quot;vtkRenderWindow.h&quot; <br>
#include &quot;vtkRenderWindowInteractor.h&quot; <br>#include &quot;vtkProperty.h&quot; <br>#include &quot;vtkMPIController.h&quot; <br>#include &quot;vtkDataSetMapper.h&quot; <br>#include &quot;vtkActor.h&quot; <br>#include &quot;vtkRenderWindow.h&quot; <br>
#include &quot;vtkRenderer.h&quot; <br>#include &quot;vtkCamera.h&quot; <br>#include &lt;vtkHAVSVolumeMapper.h&gt; <br>#include &lt;vtkDataSetTriangleFilter.h&gt; <br>#include &lt;vtkPiecewiseFunction.h&gt; <br>#include &lt;vtkColorTransferFunction.h&gt; <br>
#include &lt;vtkVolumeProperty.h&gt; <br>#include &lt;vtkVolume.h&gt; <br>#include &lt;vtkPolyDataMapper.h&gt; <br>#include &lt;vtkStdString.h&gt; <br>#include &lt;vtkXMLUnstructuredGridReader.h&gt; <br>#include &lt;vtkStructuredGridOutlineFilter.h&gt; <br>
#include &lt;vtkStreamLine.h&gt; <br>#include &lt;vtkProperty.h&gt; <br>#include &quot;vtkPointData.h&quot; <br>#include &lt;vtkPointSource.h&gt; <br>#include &lt;vtkTubeFilter.h&gt; <br>#include &quot;vtkPolyDataMapper.h&quot; <br>
#include &quot;vtkRenderWindow.h&quot; <br>#include &quot;vtkRenderWindowInteractor.h&quot; <br>#include &quot;vtkIceTRenderManager.h&quot; <br>#include &quot;vtkMPIController.h&quot; <br>#include &quot;vtkDataSetMapper.h&quot; <br>
#include &quot;vtkContourFilter.h&quot; <br>#include &quot;vtkActor.h&quot; <br>#include &quot;vtkRenderWindow.h&quot; <br>#include &quot;vtkRenderer.h&quot; <br>#include &quot;vtkActor.h&quot; <br>#include &quot;vtkPolyDataMapper.h&quot; <br>
#include &quot;vtkSmartPointer.h&quot; <br>#include &quot;vtkDistributedDataFilter.h&quot; <br>#include &quot;vtkDataSetAttributes.h&quot; <br>#include &quot;vtkProjectedTetrahedraMapper.h&quot; <br>#include &quot;vtkUnstructuredGrid.h&quot; <br>
#include &quot;vtkUnstructuredGridVolumeRayCastMapper.h&quot; <br>#include &quot;vtkIceTRenderer.h&quot; <br>#include &quot;vtkParallelRenderManager.h&quot; <br>#include &quot;vtkOrderedCompositeDistributor.h&quot; <br>#include &quot;vtkPKdTree.h&quot; <br>
#include &quot;vtkFixedPointVolumeRayCastMapper.h&quot; <br>#include &lt;iostream&gt; <br>using namespace std; <br>struct args_struct <br>{ <br>&nbsp; &nbsp; &nbsp; &nbsp; int argc; <br>&nbsp; &nbsp; &nbsp; &nbsp; char** argv; <br>}; <br><br>void process(vtkMultiProcessController* controller, void* arg) <br>
{ <br>&nbsp; &nbsp; &nbsp; &nbsp; int myId = controller-&gt;GetLocalProcessId(); <br>&nbsp; &nbsp; &nbsp; &nbsp; args_struct * args = reinterpret_cast&lt;args_struct *&gt;(arg); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkIceTRenderManager *manager = vtkIceTRenderManager::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; //vtkCompositeRenderManager *manager = vtkCompositeRenderManager::New(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; //vtkRenderer *ren = manager-&gt;MakeRenderer(); <br>&nbsp; &nbsp; &nbsp; &nbsp; vtkIceTRenderer *ren =vtkIceTRenderer::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindow* renWin = manager-&gt;MakeRenderWindow(); <br>&nbsp; &nbsp; &nbsp; &nbsp; renWin-&gt;AddRenderer(ren); <br>
&nbsp; &nbsp; &nbsp; &nbsp; renWin-&gt;SetSize(400, 300); <br><br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; if(myId == 0) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renWin-&gt;SetPosition(400, 500); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; manager-&gt;SetRenderWindow(renWin); <br>&nbsp; &nbsp; &nbsp; &nbsp; manager-&gt;SetController(controller); <br>
<br>&nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindowInteractor* iren = <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindowInteractor::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; iren-&gt;SetRenderWindow(renWin); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; std::string dataRoot = &quot;E:\\vtkdata-5.4.2\\VTKData&quot;; <br>
<br>&nbsp; &nbsp; &nbsp; &nbsp; std::string filename = dataRoot + &quot;/Data/hj_vector_xyz2.vtu&quot;; <br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkXMLUnstructuredGridReader *reader = vtkXMLUnstructuredGridReader::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; reader-&gt;SetFileName(filename.c_str()); <br>
<br>/////////////////////////////////////////////////////////////////////////////////////Ìå»æÖÆ <br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkDistributedDataFilter * piece = vtkDistributedDataFilter::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; piece-&gt;SetInputConnection(reader-&gt;GetOutputPort()); <br>
&nbsp; &nbsp; &nbsp; &nbsp; piece-&gt;SetController(controller); <br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkDataSetTriangleFilter *trifilter = vtkDataSetTriangleFilter::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; trifilter-&gt;SetInputConnection(piece-&gt;GetOutputPort()); <br><br><br>
&nbsp; &nbsp; &nbsp; &nbsp; vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; opacityTransferFunction-&gt;AddPoint(-3.0, &nbsp;0.02); <br>&nbsp; &nbsp; &nbsp; &nbsp; opacityTransferFunction-&gt;AddPoint(0.0, 0.04); <br>&nbsp; &nbsp; &nbsp; &nbsp; opacityTransferFunction-&gt;AddPoint(2.0, 0.06); <br>
<br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkColorTransferFunction *colorTransferFunction = vtkColorTransferFunction::New(); <br>&nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction-&gt;AddRGBPoint(-3, &nbsp;1, 1.0, 0.0); <br>&nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction-&gt;AddRGBPoint(-1, 1, 1, 0); <br>
&nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction-&gt;AddRGBPoint(0, 1, 1, 0); <br>&nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction-&gt;AddRGBPoint(1.0, 1, 0.0, 0.0); <br>&nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction-&gt;AddRGBPoint(1.5, 1, 1.0, 0); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; volumeProperty-&gt;SetColor(colorTransferFunction); <br>&nbsp; &nbsp; &nbsp; &nbsp; volumeProperty-&gt;SetScalarOpacity(opacityTransferFunction); <br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkHAVSVolumeMapper *volumeMapper = vtkHAVSVolumeMapper::New(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; volumeMapper-&gt;SetInputConnection(trifilter-&gt;GetOutputPort()); <br>&nbsp; &nbsp; &nbsp; &nbsp; volumeMapper-&gt;SetGPUDataStructures(true); <br>&nbsp; &nbsp; &nbsp; &nbsp; volumeMapper-&gt;SetKBufferSizeTo2(); <br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkVolume *volume = vtkVolume::New(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; volume-&gt;SetMapper(volumeMapper); <br>&nbsp; &nbsp; &nbsp; &nbsp; volume-&gt;SetProperty(volumeProperty); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; ren-&gt;AddActor(volume); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; if(myId==0) <br>&nbsp; &nbsp; &nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renWin-&gt;Render(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ren-&gt;ResetCamera(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; manager-&gt;StartInteractor(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; manager-&gt;StopServices(); <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; else <br>&nbsp; &nbsp; &nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; manager-&gt;StartServices(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; } <br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; iren-&gt;Delete(); <br>&nbsp; &nbsp; &nbsp; &nbsp; renWin-&gt;Delete(); <br>&nbsp; &nbsp; &nbsp; &nbsp; manager-&gt;Delete(); <br>} <br><br>int main( int argc, char* argv[] ) <br>{ <br><br>&nbsp; &nbsp; &nbsp; &nbsp; vtkMPIController* controller = vtkMPIController::New(); <br>
&nbsp; &nbsp; &nbsp; &nbsp; controller-&gt;Initialize(&amp;argc, &amp;argv); <br>&nbsp; &nbsp; &nbsp; &nbsp; vtkMultiProcessController::SetGlobalController(controller); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; args_struct args; <br>&nbsp; &nbsp; &nbsp; &nbsp; args.argc = argc; <br>&nbsp; &nbsp; &nbsp; &nbsp; args.argv = argv; <br>
<br><br>&nbsp; &nbsp; &nbsp; &nbsp; controller-&gt;SetSingleMethod(process,&amp;args); <br>&nbsp; &nbsp; &nbsp; &nbsp; controller-&gt;SingleMethodExecute(); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; controller-&gt;Finalize(); <br>&nbsp; &nbsp; &nbsp; &nbsp; controller-&gt;Delete(); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; return 0; <br>
} <br><br></p>