[vtkusers] can't label poly data

vidyadhar vidyadhar at lucidindia.net
Thu Jan 20 22:39:10 EST 2005


Hi,
For polydata it is not enough to specify points. You need to specify cell(s) too. That is indication of connectivity of points as well as what the connectivity describes. For example, four points could represent triangle or three segmented polyline. Refer to vtk cell types.
HTH
Vidyadhar
  ----- Original Message ----- 
  From: payman labbaf 
  To: vtkusers at vtk.org 
  Sent: Thursday, January 20, 2005 7:31 PM
  Subject: [vtkusers] can't label poly data


  Dear All,

  I've been trying to label some points with irregular geometery and topology. 
  I chose vtkPolyData as it says in the specification that is fine for 0 dimension data.

  Now I have a problem with labeling the data. 
  Could you please have a look at my simplified code and let me know what I'm doing wrong.

  //Points

  float pointsArray[12] = {1,1,0,1,2,0,2,1,0,2,2,0};

  vtkFloatArray *pointFloatArray = vtkFloatArray::New();

  pointFloatArray->SetNumberOfComponents(3);

  pointFloatArray->SetNumberOfTuples(dims[0]*dims[1]*dims[2]); 

  pointFloatArray->SetVoidArray(&pointsArray[0],12,1);

  vtkPoints *points = vtkPoints::New();

  points->SetData(pointFloatArray);



  //Vectors

  float array[12] = {10,5,0,11,6,0,12,7,0,13,8,0};

  vtkFloatArray *vectors = vtkFloatArray::New();

  vectors->SetNumberOfComponents(3);

  vectors->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);

  vectors->SetArray(&array[0],12,1);



  //Poly Data

  vtkPolyData *polyData = vtkPolyData::New();

  polyData->SetPoints(points);

  polyData->GetPointData()->SetVectors(vectors);



  //Label Mapper

  vtkLabeledDataMapper *labelMapper = vtkLabeledDataMapper::New();

  labelMapper->SetInput(polyData);

  labelMapper->SetLabelModeToLabelVectors();



  //Actor

  vtkActor2D *actor = vtkActor2D::New();

  actor->SetMapper(labelMapper);



  The above code works when I'm using vtkStructuredGrid but not for polyData.

  (I also tried InsertNextPoint() function for giving the points coordinates to vtkPolyData and that didn't work either)

  Many thanks in advance



------------------------------------------------------------------------------
  ALL-NEW Yahoo! Messenger - all new features - even more fun! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050121/17958989/attachment.htm>


More information about the vtkusers mailing list