[vtkusers] Generating U, V vleocity vector plots.. Problem!!

Rakesh Patil rakeshthp at in.com
Tue Jan 12 00:34:24 EST 2010


HI there..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:NP NE // First line contains total number of points(NP) and total number of elements(NE)Lon, Lat, depth// From next line onwards NP number of point coordinate values are listed.........eleno,nd1,nd2, nd3// Index of node 1, 2 and 3 of triangles elements, for NE number of elements;.........Velocity vectors file contains data in the following format:timeinsecondspointno, u, v.........nexttimeinsecondspointno, u, v.........One timestep contains NP number of UV dataset. Now actually, i want to plot vector plot for this data ..I have used vtkGlyph3D class to do so,.. But all the arrows are being shown in the same direction.. Here goes the code:unsigned int numpts = x.size();vtkPoints *pts = vtkPoints::New();pts>SetNumberOfPoints(numpts);vtkDoubleArray *vecArr = vtkDoubleArray::New();vecArr>SetNumberOfComponents(2);vecArr>SetN
 umberOfTuples(numpts);for( unsigned int i=0; i < numpts; i++){ pts>InsertPoint(i, x(i), y(i), 0); vecArr>InsertTuple2(i, velu(i), velv(i));}unsigned int numcells = elem.rows(); // elem is a matrix that contains the index of nodes of elements in the meshvtkCellArray *cellA = vtlCellArray::New();cellA>SetNumberOfCells(numcells);for (unsigned int i=0; i < numcells; i++){ cellA>InsertNextCell(3); cellA>InsertCellPoint( elem(i, 0) ); cellA>InsertCellPoint( elem(i, 1) ); cellA>InsertCellPoint( elem(i, 2) );}vtkUnstructuredGrid *uGrid = vtkUnstructuredGrid::New();uGrid>Allocate(numcells, numcells);uGrid>SetCells( VTKTRIANGLE, cellA);uGrid>SetPoints(pts);uGrid>GetPointData()>SetVector(vecArr);vtkArrowSource *arrow = vtkArrowSource::New();arrow>SetTipResolution(1);arrow>SetTipRadius(0.1);arrow>SetTipLength(0.35);arrow>SetShaftResolution(0.1);arrow>SetShaftRadius(0.03);vtkGlyph3D *glyph = vtkGlyph3D::New();glyph>SetInput(uGrid);glyph>SetSource(arrow>GetOutput());glyph>SetVectorModeToU
 seVector();glyph>SetColorModeToColorByVector();glyph>SetScaleModeToDataScalingOff();glyph>OrientOn();glyph>SetScaleFactor(0.01);vtkPolyDataMapper *gMapper = vtkPolyDataMapper::New();gMapper>SetInput( glyph>GetOutput());gMapper>ScalarVisibilityOn();gMapper>SetScalarRange(uGrid>GetScalarRange());vtkActor *gactor = vtkActor::New();gactor>SetMapper(gMapper);pRenderer>AddActor(gactor);pRenderer>ResetCamera();When I run this code, it shows error saying that wrong number of components for setVetor(). What is the data it takes.??How do i achieve my goal..??Thanks in advanceRegardsRakesh PatilDear vtkusers ! Get Yourself a cool, short @in.com Email ID now!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100112/910f1833/attachment.htm>


More information about the vtkusers mailing list