Since it says wrong number of components for vector, try setting the number of components to 3.<div><br></div><div>vecArr-&gt;SetNumberOfComponents(<span class="Apple-style-span" style="text-decoration: underline;">3</span>);</div>
<div><br></div><div>vecArr-&gt;InsertTuple3(i, vel_u(i), vel_v(i), 0);</div><div><br></div><div>Maybe that might work?</div><div><br><br><div class="gmail_quote">On Mon, Jan 11, 2010 at 10:34 PM, Rakesh Patil <span dir="ltr">&lt;<a href="mailto:rakeshthp@in.com">rakeshthp@in.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">HI there..<br><br>I got the following data in hand.. Mesh data is in one file and corresponding velocity vectors data in another file.. Mesh file format is as follows:<br>
<br>NP NE                           // First line contains total number of points(NP) and total number of elements(NE)<br>Lon, Lat, depth            // From next line onwards NP number of point coordinate values are listed<br>
...<br>...<br>...<br>ele_no,  nd1,  nd2,   nd3    // Index of node 1, 2 and 3 of triangles elements, for NE number of elements;<br>...<br>...<br>...<br><br>Velocity vectors file contains data in the following format:<br><br>
time_in_seconds<br>point_no, u, v<br>...<br>...<br>...<br>next_time_in_seconds<br>point_no, u, v<br>...<br>...<br>...<br><br>One timestep contains NP number of UV dataset. Now actually, i want to plot vector plot for this data ..<br>
I have used vtkGlyph3D class to do so,.. But all the arrows are being shown in the same direction.. Here goes the code:<br><br>unsigned 
 int num_pts = x.size();<br><br>vtkPoints *pts = vtkPoints::New();<br>pts-&gt;SetNumberOfPoints(num_pts);<br><br>vtkDoubleArray *vecArr = vtkDoubleArray::New();<br>vecArr-&gt;SetNumberOfComponents(2);<br>vecArr-&gt;SetNumberOfTuples(num_pts);<br>
<br>for( unsigned int i=0; i &lt; num_pts; i++)<br>{<br>   pts-&gt;InsertPoint(i, x(i), y(i), 0);<br>   vecArr-&gt;InsertTuple2(i, vel_u(i), vel_v(i));<br>}<br><br>unsigned int num_cells = elem.rows();   // elem is a matrix that contains the index of nodes of elements in the mesh<br>
<br>vtkCellArray *cellA = vtlCellArray::New();<br>cellA-&gt;SetNumberOfCells(num_cells);<br><br>for (unsigned int i=0; i &lt; num_cells; i++)<br>{<br>   cellA-&gt;InsertNextCell(3);<br>   cellA-&gt;InsertCellPoint( elem(i, 0) );<br>
   cellA-&gt;InsertCellPoint( elem(i, 1) );<br>   cellA-&gt;InsertCellPoint( elem(i, 2) );<br>}<br><br>vtkUnstructuredGrid *uGrid = vtkUnstructuredGrid::New();<br>uGrid-&gt;Allocate(num_cells, num_cells);<br>uGrid-&gt;SetCells( 
 VTK_TRIANGLE, cellA);<br>uGrid-&gt;SetPoints(pts);<br>uGrid-&gt;GetPointData()-&gt;SetVector(vecArr);<br><br>vtkArrowSource *arrow = vtkArrowSource::New();<br>arrow-&gt;SetTipResolution(1);<br>arrow-&gt;SetTipRadius(0.1);<br>
arrow-&gt;SetTipLength(0.35);<br>arrow-&gt;SetShaftResolution(0.1);<br>arrow-&gt;SetShaftRadius(0.03);<br><br>vtkGlyph3D *glyph = vtkGlyph3D::New();<br>glyph-&gt;SetInput(uGrid);<br>glyph-&gt;SetSource(arrow-&gt;GetOutput());<br>
glyph-&gt;SetVectorModeToUseVector();<br>glyph-&gt;SetColorModeToColorByVector();<br>glyph-&gt;SetScaleModeToDataScalingOff();<br>glyph-&gt;OrientOn();<br>glyph-&gt;SetScaleFactor(0.01);<br><br>vtkPolyDataMapper *gMapper = vtkPolyDataMapper::New();<br>
gMapper-&gt;SetInput( glyph-&gt;GetOutput());<br>gMapper-&gt;ScalarVisibilityOn();<br>gMapper-&gt;SetScalarRange(uGrid-&gt;GetScalarRange());<br><br>vtkActor *gactor = vtkActor::New();<br>gactor-&gt;SetMapper(gMapper);<br>
<br>pRenderer-&gt;AddActor(gactor);<br><br>pRenderer-&gt;Rese
 tCamera();<br><br>When I run this code, it shows error saying that wrong number of components for setVetor(). What is the data it takes.??<br>How do i achieve my goal..??<br><br>Thanks in advance<br><br>Regards<br>Rakesh Patil<br>
<br><br><div style="border-top:1px dashed #ccc;border-bottom:1px dashed #ccc;padding:5px"><a href="http://mail.in.com/mails/new_reg.php?utm_source=invite&amp;utm_medium=outgoing" style="font:13px arial;color:#1E56A1;text-decoration:none" target="_blank">Dear <b>vtkusers !</b> Get Yourself a cool, short <b>@in.com</b> Email ID now!</a></div>

<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>