[vtkusers] Stream lines from custom data

Gomez, Alberto alberto.gomez at kcl.ac.uk
Wed Apr 14 11:09:37 EDT 2010


Thanks for the quick answer,

Unfortunately, it doesn't work for me: the vtkCellToPointData filter 
crashes. Would you have a sample code that I can compare to mine? That 
would be very useful :-).

Anyway, I found out a tournaround that, I think, gets me closer to the 
visualisation of streamlines (but does not work yet):
...
...
vtkSmartPointer<vtkPolyData> sGrid = vtkSmartPointer<vtkPolyData>::New();
sGrid->GetPointData()->SetVectors(vecArr);
    sGrid->SetPoints(pts);
vtkSmartPointer<vtkStreamLine> streamer = 
vtkSmartPointer<vtkStreamLine>::New();
 streamer->SetInput(sGrid);

Then I still see black but I get

Debug: In /data/workspace/vtk-5.4.2/src/Filtering/vtkAlgorithm.h, line 150
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): setting 
AbortExecute to 0

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.cxx, line 475
vtkStreamLine (0x22fd980): Generating streamers

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 149
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
TerminalSpeed of 0

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 107
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
MaximumPropagationTime of 200

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 165
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
SavePointInterval of 0.1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 149
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
TerminalSpeed of 0

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 107
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
MaximumPropagationTime of 200

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 165
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
SavePointInterval of 0.1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 174
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
Integrator address 0x2300f50

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 149
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
TerminalSpeed of 0

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 107
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
MaximumPropagationTime of 200

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 165
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
SavePointInterval of 0.1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 149
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
TerminalSpeed of 0

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 107
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
MaximumPropagationTime of 200

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 165
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
SavePointInterval of 0.1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamer.h, line 290
vtkStreamLine (0x22fd980): vtkStreamLine (0x22fd980): returning 
NumberOfStreamers of 1

Debug: In /data/workspace/vtk-5.4.2/src/Graphics/vtkStreamLine.cxx, line 178
vtkStreamLine (0x22fd980): Created 0 points, 0 lines


Any clue?

Thanks
Sebastian Gatzka wrote:
> 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>




More information about the vtkusers mailing list