[vtkusers] vtkVector_vtkScalar?

Karshi karshi.hasanov at utoronto.ca
Wed Feb 20 15:46:01 EST 2002


Thanks Berk.
It works now.


On Wednesday 20 February 2002 03:09 pm, you wrote:
> If you use
> vectors.SetNumberOfTuples(Nx*Ny*Nz)
> then
> vectors.InsertNextTuple3(Jx[x,y,z],Jy[x,y,z],Jz[x,y,z])
>
> the tuple is inserted AFTER the last value, i.e. at Nx*Ny*Nz.
> You shoud use either get rid of SetNumberOfTuples() or use
> SetTuple[1,2,3](index,val1,val2,val3).
>
> -Berk
>
> On Wed, 2002-02-20 at 12:37, Karshi wrote:
> > Hi Berk,
> >
> > I  made the following modification in my code:
> > -----------------------------------------------------------------
> >
> > data.SetDimensions(Nx,Ny,Nz)
> > data.SetSpacing(xspace, yspace, zspace)
> > vectors=vtkFloatArray()
> > vectors.SetNumberOfComponents(3)
> > vectors.SetNumberOfTuples(Nx*Ny*Nz)
> >
> > for z in range(Nz):
> >     for y in range(Ny):
> >         for x in range(Nx):
> >
> >              dum =
> > vectors.InsertNextTuple3(Jx[x,y,z],Jy[x,y,z],Jz[x,y,z])
> > data.GetPointData().SetVectors(vectors)
> >
> > writer = vtkStructuredPointsWriter()
> > writer.SetInput(data)
> >
> > J_mag = sqrt(pow(Jx,2)+pow(Jy,2)+pow(Jz,2))
> >
> > scalars=vtkFloatArray()
> > scalars.SetNumberOfComponents(1)
> > scalars.SetNumberOfTuples(Nx*Ny*Nz)
> >
> >
> > for z in range(Nz):
> >     for y in range(Ny):
> >         for x in range(Nx):
> >             dum = scalars.InsertNextTuple1(J_mag[x,y,z])
> > data.GetPointData().SetScalars(scalars)
> >
> >
> > writer = vtkStructuredPointsWriter()
> > writer.SetInput(data)
> > writer.SetFileName("Test.vtk")
> > writer.Write()
> > ---------------------------------------------------------------------
> > No errors , but  I get wrong results . ( All " zeros")
> >
> > On Tuesday 19 February 2002 01:52 pm, you wrote:
> > > Take a look at
> > > http://public.kitware.com/cgi-bin/vtkfaq?req=show&file=faq06.007.htp
> > > and
> > > http://public.kitware.com/cgi-bin/vtkfaq?req=show&file=faq06.009.htp
> > >
> > > -Berk
> > >
> > > > data = vtkStructuredPoints()
> > > > data.SetDimensions(Nx,Ny,Nz)
> > > > data.SetSpacing(xspace, yspace, zspace)
> > > > vectors =vtkVectors()
> > > >
> > > > for z in range(Nz):
> > > >     for y in range(Ny):
> > > >         for x in range(Nx):
> > > >             dum =
> > > > vectors.InsertNextVector(Jx[x,y,z],Jy[x,y,z],Jz[x,y,z])
> > > > data.GetPointData().SetVectors(vectors)
> > > >
> > > > writer = vtkStructuredPointsWriter()
> > > > writer.SetInput(data)
> > > >
> > > > J_mag = sqrt(pow(Jx,2)+pow(Jy,2)+pow(Jz,2))
> > > >
> > > > scalars = vtkScalars()
> > > >
> > > > for z in range(Nz):
> > > >     for y in range(Ny):
> > > >         for x in range(Nx):
> > > >             dum = scalars.InsertNextScalar(J_mag[x,y,z])
> > > > data.GetPointData().SetScalars(scalars)
> > > >
> > > >
> > > > writer = vtkStructuredPointsWriter()
> > > > writer.SetInput(data)
> > > > writer.SetFileName("Anisotropic_Case_Jmag_Jvec.vtk")
> > > > writer.Write()
> > > > ---------------------------------------------------------------------
> > > >----



More information about the vtkusers mailing list