[vtkusers] Stream lines from custom data
Sebastian Gatzka
sebastian.gatzka at stud.tu-darmstadt.de
Wed Apr 14 10:43:40 EDT 2010
I had the same problem.
You will have to use the vtkCellDataToPointData filter first!
Input to the filter should be your structured grid.
And then you can use the output from this filter as input to the stream
line.
-----Ursprüngliche Nachricht-----
Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im Auftrag
von Gomez, Alberto
Gesendet: Mittwoch, 14. April 2010 16:05
Cc: vtkusers
Betreff: [vtkusers] Stream lines from custom data
Hi all,
I have been looking for a way to represent a vector field with stream
lines, but I have not found a solution so far. My case differs from the
example in http://www.itk.org/Wiki/VTK/Examples/StreamLines in two things:
I would like to use vtkStreamTracer as vtkStreamLine may be deprecated soon.
I am using custom data and not reading from a file.
So I have my points in the variable positions[][] ( size n x 3) and my
vectors in the variable directions[][] (size n x 3 also).
I have tried both StreamTracer and StreamLines but all I see is a black
background. When using vtkStreamLines I get the error :
Debug: In /data/workspace/vtk-5.4.2/src/Filtering/vtkAlgorithm.h, line 150
vtkStreamLine (0x22a0880): vtkStreamLine (0x22a0880): setting
AbortExecute to 0
Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.cxx, line 475
vtkStreamLine (0x22a0880): Generating streamers
ERROR: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.cxx, line 488
vtkStreamLine (0x22a0880): No vector data defined!
But I actually define the vectors, so I do not know what I am doing wrong.
This is my source code (an extract of it)
vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkDoubleArray> vecArr =
vtkSmartPointer<vtkDoubleArray>::New();
vecArr->SetNumberOfComponents(3);
for (int i = 0; i < n; i++) {
pts->InsertNextPoint(positions[i][0], positions[i][1],
positions[i][2]);
vecArr->InsertNextTuple3(directions[i][0] , directions[i][1] ,
directions[i][2] );
}
// Generate the vector field
vtkSmartPointer<vtkStructuredGrid> sGrid =
vtkSmartPointer<vtkStructuredGrid>::New();
sGrid->GetCellData()->SetVectors(vecArr);
sGrid->SetPoints(pts);
//Generate start points
vtkSmartPointer<vtkPointSource> seeds =
vtkSmartPointer<vtkPointSource>::New();
seeds->SetRadius(20.0);
seeds->SetCenter(positions[0][0], positions[0][1], positions[0][2]);
seeds->SetNumberOfPoints(100);
//vtkSmartPointer<vtkStreamTracer> streamer =
vtkSmartPointer<vtkStreamTracer>::New();
vtkSmartPointer<vtkStreamLine> streamer =
vtkSmartPointer<vtkStreamLine>::New();
streamer->SetInput(sGrid);
streamer->SetSource(seeds->GetOutput());
streamer->SetIntegrationDirection(0);
streamer->DebugOn();
streamer->Update();
vtkSmartPointer<vtkPolyDataMapper> gMapper = vtkSmartPointer<
vtkPolyDataMapper>::New();
gMapper->SetInputConnection(streamer->GetOutputPort());
...
Many thanks!!!!
--
Alberto Gómez
/Division of Imaging Sciences
The Rayne Institute
4th Floor, Lambeth Wing
St Thomas' Hospital
London SE1 7EH /
phone: +44 (0) 20 718 88364
email: alberto.gomez at kcl.ac.uk <mailto:alberto.gomez at kcl.ac.uk>
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list