[vtkusers] vtkVector_vtkScalar?
Karshi
karshi.hasanov at utoronto.ca
Wed Feb 20 12:37:07 EST 2002
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