[Paraview] is there any wrong?
胡健
hujian198681 at gmail.com
Sat Feb 19 03:47:33 EST 2011
dear all:
I want to parallel volume rendering in my computer, but I can not make it
parallel, here is my code. Is there any wrong?
#include "vtkCompositeRenderManager.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkMPIController.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkCamera.h"
#include <vtkHAVSVolumeMapper.h>
#include <vtkDataSetTriangleFilter.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include <vtkVolumeProperty.h>
#include <vtkVolume.h>
#include <vtkPolyDataMapper.h>
#include <vtkStdString.h>
#include <vtkXMLUnstructuredGridReader.h>
#include <vtkStructuredGridOutlineFilter.h>
#include <vtkStreamLine.h>
#include <vtkProperty.h>
#include "vtkPointData.h"
#include <vtkPointSource.h>
#include <vtkTubeFilter.h>
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkIceTRenderManager.h"
#include "vtkMPIController.h"
#include "vtkDataSetMapper.h"
#include "vtkContourFilter.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkActor.h"
#include "vtkPolyDataMapper.h"
#include "vtkSmartPointer.h"
#include "vtkDistributedDataFilter.h"
#include "vtkDataSetAttributes.h"
#include "vtkProjectedTetrahedraMapper.h"
#include "vtkUnstructuredGrid.h"
#include "vtkUnstructuredGridVolumeRayCastMapper.h"
#include "vtkIceTRenderer.h"
#include "vtkParallelRenderManager.h"
#include "vtkOrderedCompositeDistributor.h"
#include "vtkPKdTree.h"
#include "vtkFixedPointVolumeRayCastMapper.h"
#include <iostream>
using namespace std;
struct args_struct
{
int argc;
char** argv;
};
void process(vtkMultiProcessController* controller, void* arg)
{
int myId = controller->GetLocalProcessId();
args_struct * args = reinterpret_cast<args_struct *>(arg);
vtkIceTRenderManager *manager = vtkIceTRenderManager::New();
//vtkCompositeRenderManager *manager =
vtkCompositeRenderManager::New();
//vtkRenderer *ren = manager->MakeRenderer();
vtkIceTRenderer *ren =vtkIceTRenderer::New();
vtkRenderWindow* renWin = manager->MakeRenderWindow();
renWin->AddRenderer(ren);
renWin->SetSize(400, 300);
if(myId == 0)
renWin->SetPosition(400, 500);
manager->SetRenderWindow(renWin);
manager->SetController(controller);
vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
std::string dataRoot = "E:\\vtkdata-5.4.2\\VTKData";
std::string filename = dataRoot + "/Data/hj_vector_xyz2.vtu";
vtkXMLUnstructuredGridReader *reader =
vtkXMLUnstructuredGridReader::New();
reader->SetFileName(filename.c_str());
/////////////////////////////////////////////////////////////////////////////////////体绘制
vtkDistributedDataFilter * piece = vtkDistributedDataFilter::New();
piece->SetInputConnection(reader->GetOutputPort());
piece->SetController(controller);
vtkDataSetTriangleFilter *trifilter =
vtkDataSetTriangleFilter::New();
trifilter->SetInputConnection(piece->GetOutputPort());
vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint(-3.0, 0.02);
opacityTransferFunction->AddPoint(0.0, 0.04);
opacityTransferFunction->AddPoint(2.0, 0.06);
vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New();
colorTransferFunction->AddRGBPoint(-3, 1, 1.0, 0.0);
colorTransferFunction->AddRGBPoint(-1, 1, 1, 0);
colorTransferFunction->AddRGBPoint(0, 1, 1, 0);
colorTransferFunction->AddRGBPoint(1.0, 1, 0.0, 0.0);
colorTransferFunction->AddRGBPoint(1.5, 1, 1.0, 0);
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetColor(colorTransferFunction);
volumeProperty->SetScalarOpacity(opacityTransferFunction);
vtkHAVSVolumeMapper *volumeMapper = vtkHAVSVolumeMapper::New();
volumeMapper->SetInputConnection(trifilter->GetOutputPort());
volumeMapper->SetGPUDataStructures(true);
volumeMapper->SetKBufferSizeTo2();
vtkVolume *volume = vtkVolume::New();
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
ren->AddActor(volume);
if(myId==0)
{
renWin->Render();
ren->ResetCamera();
manager->StartInteractor();
manager->StopServices();
}
else
{
manager->StartServices();
}
iren->Delete();
renWin->Delete();
manager->Delete();
}
int main( int argc, char* argv[] )
{
vtkMPIController* controller = vtkMPIController::New();
controller->Initialize(&argc, &argv);
vtkMultiProcessController::SetGlobalController(controller);
args_struct args;
args.argc = argc;
args.argv = argv;
controller->SetSingleMethod(process,&args);
controller->SingleMethodExecute();
controller->Finalize();
controller->Delete();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20110219/27aefa91/attachment.htm>
More information about the ParaView
mailing list