[vtkusers] Generating U, V vleocity vector plots.. Problem!!
Rakesh Patil
rakeshthp at in.com
Tue Jan 12 23:19:43 EST 2010
I tried giving one, two and three... For all it is displaying same error...Am confused.. What should be the format of data that vtkGlyph3D accepts..?? Original message From:da< remywendy at gmail.com >Date: 12 Jan 10 21:09:00Subject:Re: [vtkusers] Generating U, V vleocity vector plots.. Problem!!To: Rakesh Patil , vtkusers at vtk.orgSince it says wrong number of components for vector, try setting the number of components to 3.vecArr>SetNumberOfComponents(3); vecArr>InsertTuple3(i, velu(i), velv(i), 0);Maybe that might work?On Mon, Jan 11, 2010 at 10:34 PM, Rakesh Patilwrote: 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 element
s, 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>SetNumberOfTuples(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 mesh vtkCellArray *cellA = vtlCellArray::New();cellA>SetNumberOfCells(numcells);for (unsigned int i=0; i < numcells; i++){ cellA>InsertNextCell(3); cellA>Ins
ertCellPoint( 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>SetVectorModeToUseVector();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>ResetCame
ra();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 Patil Dear vtkusers ! Get Yourself a cool, short @in.com Email ID now! Powered by www.kitware.comVisit other Kitware opensource projects at http://www.kitware.com/opensource/opensource.htmlPlease keep messages ontopic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTKFAQFollow this link to subscribe/unsubscribe: http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100113/b1ec33dd/attachment.htm>
More information about the vtkusers
mailing list