[vtkusers] multi-component data arrays..

K.R.Subramanian krs at cs.uncc.edu
Thu Jul 25 19:32:20 EDT 2002


I have consistently had troubles in using multicomponent data arrays.

I wrote a simple program that uses a 3 component unsigned char array to be
used to color map some scalar data, but the program seems to die almost all
the time. The same program with just a single component has no problem at all.
Are there any known bugs?

Thanks.

    -- krs

Here is the code segment I am using..


vtkStructuredGrid *sg;
    vtkActor *a, *a2[8];

    sg = vtkStructuredGrid::New();
        sg->SetDimensions (TRes, NMetrics, 1);

    vtkPoints *pts = vtkPoints::New();
        pts->SetNumberOfPoints(TRes*NMetrics);

    vtkUnsignedCharArray *uca = vtkUnsignedCharArray::New();
        uca->SetNumberOfTuples (TRes*NMetrics);
        uca->SetNumberOfComponents (3);

    sg->GetCellData()->SetScalars (uca);
    sg->SetPoints (pts);

    float val;
    float *col = new float[3];
    for (k = n = 0; k < NMetrics; k++)
    {
        for (i = 0; i < TRes; i++)
        {
            switch (k)
            {
                case 0:
                    val = 0.;
                    col[0] = 255; col[1] = 0; col[2] = 0;
                    break;
                case 1:
                    val = dch[i];
                    col[0] = 0; col[1] = 255; col[2] = 0;
                    break;
                case 2:
                    val = cpch[i]+dch[i];
                    col[0] = 0; col[1] = 0; col[2] = 255;
                    break;
                case 3:
                    val = dcch[i]+cpchc[i]+dch[i]+cpch[i];
                    col[0] = 255; col[1] = 0; col[2] = 255;
                    break;
                case 4:
                    val = ul[i];
                    col[0] = 0; col[1] = 255; col[2] = 255;
                    break;
            }
            r = val*ScaleFact;

            uca->SetTuple (n, col);
            pts->SetPoint (n++, (float) i, r, 0.);
        }
    }



--
K.R.Subramanian                        Phone: (704) 687-4872
Department of Computer Science         FAX:   (704) 687-4893
UNC Charlotte, CARC 311                Email: krs at cs.uncc.edu
Charlotte, NC 28223-0001               Web: http://www.cs.uncc.edu/~krs






More information about the vtkusers mailing list