Plot lines using pairs of points

Li Gao li at sourcesignal.com
Mon Oct 18 17:03:02 EDT 1999


Hello,

I have a number of pairs of points, representing the two end points of
lines, in the format of
(xs1, ys1, zs1, vs1), (xe1, ye1, ze1, ve1)
(xs2, ys2, zs2, vs2), (xe2, ye2, ze2, ve2)
...
(xsN, ysN, zsN, vsN), (xeN, yeN, zeN, veN),
where vs and ve are the color value of the start and the end points of a
line.

I am going to use the following to display these lines but not sure it is
the best way to do it.

vtkLineSource* line_source = vtkLineSource::New();
vtkScalars* lineScalar = vtkFloatScalars::New();
lineScalar->SetNumberOfScalars(1);
vtkAppendPolyData* line_group = vtkAppendPolyData::New();

for (int i=0; i<numLines; i++)
{
	float v = (points[2*i][_V] + points[2*i+1][_V]) / 2.;	// _V=3
	lineScalar->SetScalar(0, v);
	line_source->SetPoint1(points[2*i][_X], points[2*i][_Y], points[2*i][_Z]);
// _X=0,_Y=1,_Z=2
	line_source->SetPoint2(points[2*i+1][_X], points[2*i+1][_Y],
points[2*i+1][_Z]);
	line_source->SetResolution(1);
	line_source->GetOutput()->GetCellData()->SetScalars( lineScalar );
	line_source->Update();

	line_group->AddInput( line_source->GetOutput() );
	line_group->Update();
}

Is it the right way to display a set of colored lines? Please help.

Li



-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list