[vtkusers] use the delaunry3D or vtkDataSetTriangleFilter with the output of vtkDICOMImageReader

Ali Habib ali.mahmoud.habib at gmail.com
Fri Oct 23 18:35:59 EDT 2009


Hi all,

I am trying to use the following steps to create tetrahdral mesh as appear
in the photo ins this link :
http://www.iue.tuwien.ac.at/phd/fleischmann/img346.gif

1. I read the 2D slices using vtkDICOMImageReader
2. apply delaunry3D or vtkDataSetTriangleFilte for the vtkdicomimagereader
output.
3. defien iso value to render the skull
4. create a volume and rendering it.

there're two error appears , which are :
1.vtkstreamingdemandpibline error.
2. vtkfixedpointvolumeraycastmapper error : No input.


I think the problem in use the output of vtkdicomimagereader in delaunary3d
any suggestion please



the code is :

//Variables
array<double> ^metaScalarRange = gcnew array<double>(2) { 0, 0 };
vtk:: vtkRenderWindow renwM = gcnew vtk::vtkRenderWindow();
vtk:: vtkRenderer ren1 = gcnew vtkRenderer();
vtk:: vtkRenderWindowInteractor iren = gcnew
vtk::vtkRenderWindowInteractor();
vtk:: vtkVolume volume = gcnew vtk::vtkVolume();
renwM::AddRenderer(ren1);

iren::SetRenderWindow(renwM);

// Read a DICOM series path:
vtk:: vtkDICOMImageReader VDR = gcnew vtk::vtkDICOMImageReader();
VDR::SetDirectoryName("H:\\work\\Master
Degree\\DataSet\\case1-\\DICOM\\PA1\\ST1\\SE1");
VDR::SetDataOrigin(0, 0, 0);

VDR->Update();

/////
vtk:: vtkImageChangeInformation VIC = gcnew
vtk::vtkImageChangeInformation();
VIC::SetInput(VDR::GetOutput());

VIC::CenterImageOn();

VIC->Update();

///////// Applying the mesh
vtkDataSetTriangleFilter ^VDST = gcnew vtkDataSetTriangleFilter();
VDST->SetInputConnection(VDR::GetOutputPort());

//
//            vtkDelaunay3D VDST = new vtkDelaunay3D();
//
//            VDST.SetInputConnection(VDR.GetOutputPort());

// Load the data on vtkimagedata.
vtk:: vtkImageData VoxelData = VIC::GetOutput();
// Start adjust the rendering
vtkVolumeProperty ^volumeProperty = gcnew vtkVolumeProperty();
metaScalarRange = VoxelData::GetScalarRange();

int isovalue = Convert::ToInt32(0.8 * (metaScalarRange[1] +
metaScalarRange[0]));
/////////////////////////////////////////////
array<double> ^inputRange = VoxelData::GetScalarRange();
vtk:: vtkPiecewiseFunction opacityIsoTransferFunction = gcnew
vtk::vtkPiecewiseFunction();
double per = ((inputRange[1] - inputRange[0]) / 100);
if (isovalue > (inputRange[0] + per))
{

opacityIsoTransferFunction::AddPoint(inputRange[0], 0);

opacityIsoTransferFunction::AddPoint(isovalue - (per), 0);

}

opacityIsoTransferFunction::AddPoint(isovalue, 1);

opacityIsoTransferFunction::AddPoint(inputRange[1], 1);

vtk:: vtkColorTransferFunction colorTransferFunction = gcnew
vtk::vtkColorTransferFunction();
colorTransferFunction::AddRGBPoint(inputRange[0], 1.0, 1.0, 1.0);

colorTransferFunction::AddRGBPoint(inputRange[1], 1.0, 1.0, 1.0);

volumeProperty->SetColor(colorTransferFunction);

volumeProperty->SetScalarOpacity(opacityIsoTransferFunction);

volumeProperty->ShadeOn();

volumeProperty->SetInterpolationTypeToLinear();

volume::SetProperty(volumeProperty);

///////////////////////////
vtk:: vtkFixedPointVolumeRayCastMapper volumeMapper = gcnew
vtk::vtkFixedPointVolumeRayCastMapper();
volumeMapper::SetInputConnection(VDST->GetOutputPort());

volumeMapper::AutoAdjustSampleDistancesOn();

volumeMapper->Update();

volume::SetMapper(volumeMapper);

volume->Update();

//////////////////////////////////
vtkActor ^actor = gcnew vtkActor();
actor->GetProperty()->SetRepresentationToWireframe();

ren1::AddVolume(volume);

ren1::AddActor(actor);

ren1::ResetCamera();

//            ren1.GetActiveCamera().Azimuth(0);
//            ren1.GetActiveCamera().Roll(0);

ren1::GetActiveCamera()->Elevation(90);

renwM::Render();

iren->Initialize();
iren::Enable();


best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091024/6c788a76/attachment.htm>


More information about the vtkusers mailing list