[vtkusers] Slow Dicom blend mode.

Alessandro Martini alessandromartini at gmail.com
Wed Oct 13 03:09:16 EDT 2010


I get the medical4.cxx example and change it to open a dicom file, resulting
this code, but with SetBlendModeToComposite the volume dond appear, and
SetBlendModeToAdictive is to much slow, what I need to use
SetBlendModeToComposite?

        vtkSmartPointer<vtkRenderer>ren = vtkWindow1->GetRenderer();
        vtkSmartPointer<vtkRenderWindowInteractor>iren =
        vtkWindow1->GetInteractor();

        vtkSmartPointer<vtkDICOMImageReader>dicomReader =
        vtkSmartPointer<vtkDICOMImageReader>::New();
        dicomReader->SetDirectoryName(dirname);
        dicomReader->Update();

        vtkSmartPointer<vtkSmartVolumeMapper>volumeMapper =
        vtkSmartPointer<vtkSmartVolumeMapper>::New();
        volumeMapper->SetInput(dicomReader->GetOutput());

-->>        volumeMapper->SetBlendModeToAdditive();
<<--

        vtkSmartPointer<vtkColorTransferFunction>volumeColor =
        vtkSmartPointer<vtkColorTransferFunction>::New();
        volumeColor->AddRGBPoint(0, 0.0, 0.0, 0.0);
        volumeColor->AddRGBPoint(500, 1.0, 0.5, 0.3);
        volumeColor->AddRGBPoint(1000, 1.0, 0.5, 0.3);
        volumeColor->AddRGBPoint(1150, 1.0, 1.0, 0.9);

        vtkSmartPointer<vtkPiecewiseFunction>volumeScalarOpacity =
        vtkSmartPointer<vtkPiecewiseFunction>::New();
        volumeScalarOpacity->AddPoint(0, 0.00);
        volumeScalarOpacity->AddPoint(500, 0.15);
        volumeScalarOpacity->AddPoint(1000, 0.15);
        volumeScalarOpacity->AddPoint(1150, 0.85);

        vtkSmartPointer<vtkPiecewiseFunction>volumeGradientOpacity =
        vtkSmartPointer<vtkPiecewiseFunction>::New();
        volumeGradientOpacity->AddPoint(0, 0.0);
        volumeGradientOpacity->AddPoint(90, 0.5);
        volumeGradientOpacity->AddPoint(100, 1.0);

        vtkSmartPointer<vtkVolumeProperty>volumeProperty =
        vtkSmartPointer<vtkVolumeProperty>::New();
        volumeProperty->SetColor(volumeColor);
        volumeProperty->SetScalarOpacity(volumeScalarOpacity);
        volumeProperty->SetGradientOpacity(volumeGradientOpacity);
        volumeProperty->SetInterpolationTypeToLinear();
        volumeProperty->ShadeOn();
        volumeProperty->SetAmbient(0.4);
        volumeProperty->SetDiffuse(0.6);
        volumeProperty->SetSpecular(0.2);

        vtkSmartPointer<vtkVolume>volume =
vtkSmartPointer<vtkVolume>::New();
        volume->SetMapper(volumeMapper);
        volume->SetProperty(volumeProperty);

        ren->AddViewProp(volume);

        vtkCamera *camera = ren->GetActiveCamera();
        double *c = volume->GetCenter();
        camera->SetFocalPoint(c[0], c[1], c[2]);
        camera->SetPosition(c[0] + 400, c[1], c[2]);
        camera->SetViewUp(0, 0, -1);

        vtkWindow1->Invalidate();

        iren->Initialize();
        iren->Start();

Thank's,
Alessandro Martini
alessandromartini at gmail.com
-------------------------------------------------
'Existem 10 tipos de pessoas no mundo:
aquelem que entendem binário, e aqueles que não!'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101013/7290ed80/attachment.htm>


More information about the vtkusers mailing list