[vtkusers] Display Pointcloud in 3d
David Doria
daviddoria at gmail.com
Fri Jan 6 08:15:35 EST 2012
On Fri, Jan 6, 2012 at 4:55 AM, h0ppel <h0ppel at web.de> wrote:
> Hi,
>
> I do have an example point Cloud and put it into imagedata like this:
>
> int i, j, k;
>
> int[][][] Matrix;
> var rand = new Random(100);
>
> var x = 100; var y = 200; var z = 35;
> var size = x * y * z * sizeof(int);
>
> Matrix = new int[x][][];
>
> for (i = 0; i < x; i++)
> {
> Matrix[i] = new int[y][];
>
> for (j = 0; j < y; j++)
> {
> Matrix[i][j] = new int[z];
>
> for (k = 0; k < z; k++)
> {
> Matrix[i][j][k] = rand.Next();
> }
> }
> }
>
> vtkImageData image = new vtkImageData();
>
> image.SetDimensions(100, 200, 35);
> image.SetSpacing(1, 1, 1);
> image.SetOrigin(0, 0, 0);
> image.SetNumberOfScalarComponents(1);
> image.SetScalarTypeToFloat();
> image.AllocateScalars();
>
> unsafe
> {
> int* ptr = (int*)(image.GetScalarPointer());
>
> for (i = 0; i < 100; i++)
> {
> for (j = 0; j < 200; ++j)
> {
> for (k = 0; k < 35; ++k)
> {
> *ptr++ = Matrix[i][j][k];
> }
> }
> }}< /raw>
>
> but how can I display this cloud in 3d and not only in the viewer?
>
> thanks
I think you are mixing terminology a little bit. If you want a "point
cloud", you should use a vtkPolyData object, then it is very simple to
display:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PointSource
If you create a 3D image (vtkImageData), you will have to use much
fancier display techniques, something like volume rendering.
David
More information about the vtkusers
mailing list