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