[vtkusers] How to set position and orientation of vtk volumes

Dime Vitanovski vitanovski at hotmail.com
Thu Jan 20 11:22:44 EST 2011


Hello VTK community,
I am having some problems with orienting and positioning a volumes in VTK. I am cutting a DICOM volume with a plane which has its own orientation and position and I want to visualize the cutted volume with VTK. However, sofar I am doing everything right for the visualization part but the visualized volume is not orientated with the plane and it's not passing through the plane's origin. Here is the simplified code: 

	vtkSmartPointer<vtkStructuredPoints> med_volume = vtkSmartPointer<vtkStructuredPoints>::New();
	// properites + data of the cutted volume        // volume to be visualized	std::shared_ptr<Image3DUShort> image3D(dynamic_pointer_cast<Image3DUShort>(imagePtr) );

	int       size[3];           //volume size	double resolution[3];  //volume resolution	double origin[3];        //plane origin        double orient[9];       // orientation of the plane X-axis, Y-axis and Z-Axis
	image3D->getParams().getDim(size);	image3D->getParams().getRes(resolution);	image3D->getParams().getOrigin(origin);	image3D->getParams().getOrient(orient);
	vtkSmartPointer<vtkUnsignedShortArray> array(vtkSmartPointer<vtkUnsignedShortArray>::New());	array->SetNumberOfComponents(1);                //copy data of the cutted volume	array->SetArray(image3D->getRawData(), image3D->getParams().getDataSize(), 1);	array->SetName("CuttedVolume");
        //prepare vktStructuredPoints	med_volume->SetDimensions(size);	med_volume->SetOrigin(origin);	med_volume->SetSpacing(resolution);	med_volume->GetPointData()->SetScalars(array);
	OpacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();	ColorTransferFunction = vtkSmartPointer<vtkColorTransferFunction>::New();
	VolumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();	VolumeProperty->SetColor(ColorTransferFunction);	VolumeProperty->SetScalarOpacity(OpacityTransferFunction);	VolumeProperty->SetInterpolationTypeToLinear();
	VolumeMapper = vtkSmartPointer<vtkVolumeTextureMapper3D>::New();	VolumeMapper->SetInput(med_volume);
	Volume = vtkSmartPointer<vtkVolume>::New();	Volume->SetMapper(VolumeMapper);	Volume->SetProperty(VolumeProperty);

With this simplified code I can visualize the cutted volume. Can you please give me some code how to properly orient and position the "med_volume" with the given information from plane:
	image3D->getParams().getOrigin(origin);   // planes origin	image3D->getParams().getOrient(orient);  // planes orientation

Thank you very much,padre 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110120/b90599a3/attachment.htm>


More information about the vtkusers mailing list