[vtkusers] streamlines from arbitrary points

berk.geveci at kitware.com berk.geveci at kitware.com
Sun Jan 14 11:30:53 EST 2001


> I have a 3d vector field on a structured grid and I have a list of
> select points from which I want to start streamlines.

	There are a few ways of accomplishing this. If you want to be able
	to set the properties of each streamline differently, create a number
	of vtkStreamLines (or something similar) and merge their outputs
	with an append filter. If not, you can create your own source
	like this:

	const int numPoints = <number of streamlines>;
	float x[3];

	vtkPolyData* startingPoints = vtkPolyData::New();

// Initialization of points and cell
	vtkPoints* newPoints = vtkPoints::New();
	vtkCellArray* newVerts = vtkCellArray::New();
	newPoints->Allocate(numPoints);
	newVerts->Allocate(newVerts->EstimateSize(1,numPoints));

// Insert the first (and the only cell)
	newVerts->InsertNextCell(numPoints);

// Insert the starting points
	for (int i=0; i<numPoints; i++)
	{
	x[0] = <x of ith starting point>;
	x[1] = <y of ith starting point>;
	x[2] = <z of ith starting point>;
	newVerts->InsertCellPoint(newPoints->InsertNextPoint(x));
	}

// Create the polydata by setting the points and vertices
	startingPoints->SetPoints(newPoints);
	newPoints->Delete();
	startingPoints->SetVerts(newVerts);
	newVerts->Delete();

	You can then use this polydata as your source. A similar
	example is in the Execute() method of vtkPointSource.
	
	Berk
	







More information about the vtkusers mailing list