[vtkusers] parallel coordinates..

K.R.Subramanian krs at cs.uncc.edu
Sat Nov 10 18:15:25 EST 2001




Folks:

This piece of code (part of a larger application) used to work (prior to the DataArray
changes)..

Its dying due to a divide by 0 exception in vtkParallelCoordinates::PlaceAxes().. My vtk
distribution
does run the parallel coordinate example fine, so its not the distribution..

The code below should put up a plot with 3 axes, with all values at 0..

It dies with teh same problem on both irix and linux, so definitely I am doing
something wrong.

Thanks.

    -- krs





--
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
-------------- next part --------------
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkFloatArray.h"
#include "vtkFieldData.h"
#include "vtkActor.h"
#include "vtkParallelCoordinatesActor.h"
#include "vtkPolyDataMapper.h"
#include <vtkDataObject.h>

int main( int argc, char *argv[] )
{
  char a;
  
  			// create a rendering window and renderer

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  vtkRenderer *ren = vtkRenderer::New();
  vtkRenderWindow *renWindow = vtkRenderWindow::New();
  renWindow->AddRenderer(ren);
  renWindow->SetSize( 300, 300 );
  iren->SetRenderWindow (renWindow);

  vtkFieldData *field_data = vtkFieldData::New();

        field_data->SetNumberOfArrays (3);
        vtkFloatArray **metric_pc = new vtkFloatArray*[3];

        char s[100];

        for (int j = 0; j < 3; j++)
        {
            metric_pc[j] = vtkFloatArray::New();
                metric_pc[j]->SetNumberOfTuples (100);
                metric_pc[j]->SetNumberOfValues (100);

                for (int k = 0; k < 100; k++)
                    metric_pc[j]->SetValue (k, 0.0);

            sprintf (s, "array%d", j);
            field_data->AddArray (metric_pc[j], s);
        }

    vtkDataObject *ds = vtkDataObject::New();
        ds->SetFieldData (field_data);

  vtkParallelCoordinatesActor *pcoord= vtkParallelCoordinatesActor::New();
	pcoord->GetPositionCoordinate()->SetValue (0.05, 0.05, 0.0);
    pcoord->GetPosition2Coordinate()->SetValue (0.95, 0.85, 0.0);
	pcoord->SetIndependentVariablesToColumns();
    pcoord->SetInput (ds);

  ren->AddActor(pcoord);
  renWindow->Render();

  iren->Start();

  ren->Delete();
  renWindow->Delete();
  iren->Delete();
  pcoord->Delete();
  ds->Delete();
}



More information about the vtkusers mailing list