[vtkusers] Help with drawing lines

Sercani sercanimailgroups at gmail.com
Mon Jan 19 14:28:46 EST 2009


i think vtkLineRepresentation  (or vtkLinewidget) is a better way to draw lines in a scene…you must set the properties of the line the  way you like, add it to the renderer  and simply set the coordinates(in world coordinates) of two end points of the line …

 

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Konstantinos Kelg
Sent: Monday, January 19, 2009 5:07 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Help with drawing lines

 


Hi. I need to render some vectors in 3D space and I've decided to draw them as lines. However my code doesn't seem to work (I see nothing). Does anyone know why ?

vtkCellArray *cellArrayNorm = vtkCellArray::New();
vtkPoints *points2 = vtkPoints::New();
points2->Allocate(2*m_NumOfVertices*3*sizeof(float));

for(int k=0; k<m_NumOfVertices; k++)

  {
  float* fp = VerticesP[k].coords; // Get vertex coords.

  float* fpN = NormP[k].coords; // Get vertex normal.

  points2->SetPoint(k, fp); // Set 1st point
  points2->SetPoint(m_NumOfVertices + k, // Set 2nd point.
      fp[0]+fpN[0], // x+dx
      fp[1]+fpN[1], // y+dy
      fp[2]+fpN[2]);// z+dz
  // Set up new (line) cell and insert.
  int pts[2] = {k, m_NumOfVertices+k};
  cellArrayNorm->InsertNextCell(2, pts);
  }

 

  vtkPolyData *polyDataNorm = vtkPolyData::New();
  polyDataNorm->SetPoints(points2);
  polyDataNorm->SetPolys(cellArrayNorm);

  vtkPolyDataMapper *polyDataMapperNorm = vtkPolyDataMapper::New();
  polyDataMapperNorm->SetInput(polyDataNorm);

  ActorNorm->SetMapper(polyDataMapperNorm);
  ren1->AddActor(ActorNorm);

  vtkProperty *prop = vtkProperty::New();
  prop->SetColor(1.0, 0.0, 0.0);
  ActorNorm->SetProperty(prop);

  points2->Delete();
  cellArrayNorm->Delete();
  polyDataNorm->Delete();
  polyDataMapperNorm->Delete();
  prop->Delete();

Thanks.

 

  _____  

Χρησιμοποιείτε Yahoo!
Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων 
http://login.yahoo.com/config/mail?.intl=gr 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090119/a5dc740b/attachment.htm>


More information about the vtkusers mailing list