[vtkusers] vtkActor

Sandro Rosi s.rosi at optikon.it
Tue Dec 13 07:02:25 EST 2005


Hi!

I'm trying to render a volume adding the XYZ axes in the rendering, but when I add the vtkActor of the axes the volume disappears: I mean I can see or the volume either the axes. Can someone help me? 

The code of the pipeline is the following:

void C3D_ReconstructorView::Pipeline(vtkImageData *pData)
{

    vtkWin32OpenGLRenderWindow *renWin;
    vtkRenderer *ren;
    vtkWin32RenderWindowInteractor *iren;
    vtkStructuredPointsReader * VTKreader;
    vtkImageIslandRemoval2D * islandRemover;
    vtkImageGaussianSmooth *gaussian;
    vtkImageThreshold *selectTissue;
    vtkPiecewiseFunction *opacityTransferFunction;
    vtkColorTransferFunction *colorTransferFunction;
    vtkVolumeProperty * volumeProperty[1];
    vtkVolumeRayCastCompositeFunction *compositeFunction;
    vtkVolumeRayCastMapper *volumeMapper;
    vtkVolume *volume;

    islandRemover = vtkImageIslandRemoval2D::New();
    islandRemover->SetAreaThreshold(4);
    islandRemover->SetIslandValue(-1);
    islandRemover->SetReplaceValue(1.0);
    islandRemover->SetInput(pData);
    gaussian = vtkImageGaussianSmooth::New();
    gaussian->SetStandardDeviations(1.0, 1.0, 1.0);
    gaussian->SetRadiusFactors(1.0, 1.0, 1.0);
    gaussian->SetInput(islandRemover->GetOutput());
    selectTissue = vtkImageThreshold::New();
    selectTissue->ThresholdBetween(m_stVievParms.dblNoise, 255.0);
    selectTissue->ReplaceInOff();
    selectTissue->SetOutValue(0.0);
    selectTissue->SetInput(gaussian->GetOutput());

// Create transfer mapping scalar value to opacity
    opacityTransferFunction = vtkPiecewiseFunction::New();
    opacityTransferFunction->AddPoint(0, 0.0);
    opacityTransferFunction->AddPoint(static_cast<int>(m_stVievParms.dblNoise), 0.259);
    opacityTransferFunction->AddPoint(255, 1.0);

// Create transfer mapping scalar value to color
    colorTransferFunction = vtkColorTransferFunction::New();
    colorTransferFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
    colorTransferFunction->AddRGBPoint(m_stVievParms.dblNoise, 0.259, 0.259, 0.259);
    colorTransferFunction->AddRGBPoint(255.0, 1.0, 1.0, 1.0);

// The property describes how the data will look
    volumeProperty[0] = vtkVolumeProperty::New();
    volumeProperty[0]->SetColor(colorTransferFunction);
    volumeProperty[0]->SetScalarOpacity(opacityTransferFunction);
    volumeProperty[0]->SetInterpolationTypeToLinear();
//
// The mapper / ray cast function know how to render the data
    compositeFunction = vtkVolumeRayCastCompositeFunction::New();
    volumeMapper = vtkVolumeRayCastMapper::New();
    volumeMapper->SetSampleDistance(0.2);
    volumeMapper->SetVolumeRayCastFunction(compositeFunction);
    volumeMapper->SetInput(selectTissue->GetOutput());

// axes to follow camera
    float bounds[6];
    volumeMapper->GetBounds(bounds);
    vtkAxes* axes = vtkAxes::New(); //source.
    vtkPolyDataMapper* axesMapper = vtkPolyDataMapper::New();
    vtkActor* axesActor = vtkActor::New();
    axes->SetOrigin( bounds[0],bounds[2],bounds[4]);
    axes->SetScaleFactor(bounds[1] - bounds[0]);
    axesMapper->SetInput( axes->GetOutput());
    axesActor->SetMapper(axesMapper);
    axesActor->PickableOff();
    axesActor->GetProperty()->SetColor( 255, 255, 255);
    axesActor->GetProperty()->SetLineWidth( 5.);
    axesActor->GetProperty()->SetOpacity(10);

// The volume holds the mapper and the property and
// can be used to position/orient the volume
    volume->SetMapper(volumeMapper);
    volume->SetProperty(volumeProperty[0]);
    volume->Update();
//  ren->AddActor( axesActor); //this is the line that makes disappear the volume
    ren->AddVolume(volume);

    axes->Delete();
    axesMapper->Delete();
    axesActor->Delete();
    islandRemover->Delete();
    gaussian->Delete();
    selectTissue->Delete();
    opacityTransferFunction->Delete();
    colorTransferFunction->Delete();
    compositeFunction->Delete();
    volumeProperty[0]->Delete();
    volumeMapper->Delete();
}

Thank you in advance.

Sandro Rosi
R&D Software Project Manager
Optikon 2000 S.p.A.
Via del Casale di Settebagni, 13
00138 Roma (Italy)
Tel +39068887978
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051213/3ce67568/attachment.htm>


More information about the vtkusers mailing list