I am assuming that you have already got your volume rendering working in serial.

At first glance, I can see that the IceT parallel render manager is in the 
wrong compositing mode.  By default, the manager uses a z buffer comparison as 
its composite operation.  That works great for opaque surfaces, but does not 
work at all for transparent objects (as is the case for volume rendering).  In 
fact, I believe most of the volume rendering algorithms write nothing in the z 
buffer, so IceT will assume that nothing is rendered and throw away all your 
rendered pixels.

You need to tell the parallel render manager to do alpha blending.  Because 
alpha blending is order dependent, you also have to tell the parallel render 
manager the spatial decomposition of your data.  You do that by creating a 
vtkPKdTree to the parallel render manager (if I remember right).

-Ken

   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmo...@sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

From: 胡健 <hujian198...@gmail.com<mailto:hujian198...@gmail.com>>
Date: Sat, 19 Feb 2011 01:47:33 -0700
To: "paraview@paraview.org<mailto:paraview@paraview.org>" 
<paraview@paraview.org<mailto:paraview@paraview.org>>
Subject: [Paraview] is there any wrong?


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;
}

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to