[vtkusers] Can't see the effect of delaunary3D or vtkDataSetTriangleFilter

Ali Habib ali.mahmoud.habib at gmail.com
Wed Oct 21 10:09:06 EDT 2009


I created a 3D of human face and tried to mesh it , but unfortunately I
can't see the tetrahedral mesh efect on the output  (I used delaunary3D ,
then  vtkDataSetTriangleFilter )
 the attached is the output image

and the code is :



//Variables

double[] metaScalarRange = new double[2] { 0, 0 };

vtk.vtkRenderWindow renwM = new vtk.vtkRenderWindow();

vtk.vtkRenderer ren1= new vtkRenderer();

vtk.vtkRenderWindowInteractor iren = new vtk.vtkRenderWindowInteractor();

vtk.vtkVolume volume = new vtk.vtkVolume();

renwM.AddRenderer(ren1);

iren.SetRenderWindow(renwM);

// Read a DICOM series path:

vtk.vtkDICOMImageReader VDR = new vtk.vtkDICOMImageReader();

VDR.SetDirectoryName("D:\\Programming and tutorials\\Master source\\CT
test\\DICOM\\PA1\\ST1\\SE1\\");

VDR.SetDataOrigin(0, 0, 0);

VDR.Update();

/////

vtk.vtkImageChangeInformation VIC = new vtk.vtkImageChangeInformation();

VIC.SetInput(VDR.GetOutput());

VIC.CenterImageOn();

VIC.Update();

///////// Applying the mesh

/* vtkDataSetTriangleFilter VDST = new 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 = new vtkVolumeProperty();

metaScalarRange = VoxelData.GetScalarRange();

int isovalue =Convert.ToInt32( 0.8 * (metaScalarRange[1] +
metaScalarRange[0]));

/////////////////////////////////////////////

double[] inputRange = VoxelData.GetScalarRange();

vtk.vtkPiecewiseFunction opacityIsoTransferFunction = new 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 = new 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 = new vtk.
vtkFixedPointVolumeRayCastMapper();

volumeMapper.SetInput(VoxelData);

volumeMapper.AutoAdjustSampleDistancesOn();

volumeMapper.Update();

volume.SetMapper(volumeMapper);

volume.Update();

//////////////////////////////////

vtkActor actor = new 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/20091021/baad86db/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: output.jpg
Type: image/jpeg
Size: 42443 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091021/baad86db/attachment.jpg>


More information about the vtkusers mailing list