<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Hi,<br>
<br>
You can visualize the vector field as arrows (or any other shape) using
vtkGlyph. I found it quite unclear when I first did it and I don't know
if I am doing it the best way, but here is an example of what works for
me.<br>
<br>
You need to provide a set of points and a set of vectors corresponding
to those points (in world coords). I store them in two std::vector ,
"directions" and "positions":<br>
<br>
<br>
//positions<br>
int num_pts = directions.size();<br>
vtkSmartPointer<vtkPoints> pts =
vtkSmartPointer<vtkPoints>::New();<br>
pts->SetNumberOfPoints(num_pts);<br>
<br>
//directions<br>
vtkSmartPointer<vtkDoubleArray> vecArr =
vtkSmartPointer<vtkDoubleArray>::New();<br>
vecArr->SetNumberOfComponents(3);<br>
vecArr->SetNumberOfTuples(num_pts);<br>
<br>
for( int i=0; i < num_pts; i++)<br>
{<br>
pts->InsertPoint(i, positions[i][0], positions[i][1],
positions[i][2]);<br>
vecArr->InsertTuple3(i, directions[i][0]*sf,
directions[i][1]*sf, directions[i][2]*sf);<br>
}<br>
<br>
// put vectors and positions into a grid which will be the glyph's
input<br>
vtkSmartPointer<vtkUnstructuredGrid> uGrid =
vtkSmartPointer<vtkUnstructuredGrid>::New();<br>
uGrid->SetPoints(pts);<br>
uGrid->GetPointData()->SetVectors(vecArr);<br>
<br>
<br>
<br>
// glyph construction<br>
// build arrow<br>
vtkSmartPointer<vtkArrowSource> arrow =
vtkSmartPointer<vtkArrowSource>::New();<br>
<br>
//build arrow Field<br>
vtkSmartPointer<vtkGlyph3D> glyph =
vtkSmartPointer<vtkGlyph3D>::New();<br>
glyph->SetInput(uGrid);<br>
glyph->SetSource(arrow->GetOutput());<br>
glyph->SetScaleModeToScaleByVector();<br>
<br>
//display<br>
vtkSmartPointer<vtkPolyDataMapper> gMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
gMapper->SetInput( glyph->GetOutput());<br>
gMapper->ScalarVisibilityOn();<br>
gMapper->SetScalarRange(uGrid->GetScalarRange());<br>
<br>
vtkSmartPointer<vtkActor> gactor =
vtkSmartPointer<vtkActor>::New();<br>
gactor->SetMapper(gMapper);<br>
gactor->GetProperty()->SetColor(color);<br>
ren->AddActor(gactor);<br>
<br>
<br>
Hope this helps,<br>
<br>
<br>
Alberto<br>
<br>
<br>
<br>
<br>
<br>
<br>
Kishore Mosaliganti wrote:
<blockquote
cite="mid:cd51098d1002102106v7038f905tc74ed3b778f7787d@mail.gmail.com"
type="cite">
<pre wrap="">For 2, you can use Paraview to visualize the vector field.
Kishore
On Wed, Feb 10, 2010 at 8:35 AM, Arunachalam Kana
<a class="moz-txt-link-rfc2396E" href="mailto:Kana.Arunachalam@fh-wels.at"><Kana.Arunachalam@fh-wels.at></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi User,
My goal is to implement insight journal paper:
"Edge based tube detection for coronary artery centerline extraction"