[vtkusers] Basic question, vtkStructuredPoints

Oeyvind Knudsen knudsen at operamail.com
Thu Feb 12 11:48:35 EST 2004


Hi!

Tried your method below, which resulted in the object below:

vtkStructuredPoints (0x83c86b8)
  Debug: Off
  Modified Time: 498
  Reference Count: 2
  Registered Events: (none)
  Source: (none)
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  MaximumNumberOfPieces: -1
  PipelineMTime: 0
  UpdateTime: 0
  UpdateExtent: Not Initialized
  Update Number Of Pieces: 1
  Update Piece: 0
  Update Ghost Level: 0
  RequestExactExtent: Off
   UpdateExtent: 0, 0, 0, 0, 0, 0
  WholeExtent: 0, -1, 0, -1, 0, -1
  Field Data:
    Debug: Off
    Modified Time: 448
    Reference Count: 1
    Registered Events: (none)
    Number Of Arrays: 0
    Number Of Components: 0
    Number Of Tuples: 0
  Locality: 0
  NumberOfConsumers: 0
  ExtentTranslator: (0x84c01f8)
  MaximumNumberOfPieces: -1
  Number Of Points: 6561
  Number Of Cells: 6400
  Cell Data:
    Debug: Off
    Modified Time: 452
    Reference Count: 1
    Registered Events: (none)
    Number Of Arrays: 0
    Number Of Components: 0
    Number Of Tuples: 0
    Copy Flags: ( 1 1 1 1 1 )
    Scalars: (none)
    Vectors: (none)
    Normals: (none)
    TCoords: (none)
    Tensors: (none)
  Point Data:
    Debug: Off
    Modified Time: 498
    Reference Count: 3
    Registered Events: (none)
    Number Of Arrays: 1
    Array 0 name = NULL
    Number Of Components: 1
    Number Of Tuples: 6561
    Copy Flags: ( 1 1 1 1 1 )
    Scalars:       Debug: Off
      Modified Time: 495
      Reference Count: 3
      Registered Events: (none)
      Name: (none)
      Number Of Components: 1
      Number Of Tuples: 6561
      Size: 8191
      MaxId: 6560
      LookupTable: (none)
      Array: 0x850d1c8
    Vectors: (none)
    Normals: (none)
    TCoords: (none)
    Tensors: (none)
  Bounds: 
    Xmin,Xmax: (0, 80)
    Ymin,Ymax: (0, 80)
    Zmin,Zmax: (0, 0)
  Compute Time: 0
  Release Data: Off
  ScalarType: 10
  NumberOfScalarComponents: 1
  Spacing: (1, 1, 1)
  Origin: (0, 0, 0)
  Dimensions: (81, 81, 1)
  Increments: (1, 81, 6561)
  Extent: (0, 80, 0, 80, 0, 0)
  WholeExtent: (0, -1, 0, -1, 0, -1)

Filled with point data alright, but it looks nothing like the object i get out of the reader:

vtkStructuredPoints (0x83ac898)
  Debug: Off
  Modified Time: 553
  Reference Count: 3
  Registered Events: (none)
  Source: 0x83f7e20
  Release Data: Off
  Data Released: True
  Global Release Data: Off
  MaximumNumberOfPieces: -1
  PipelineMTime: 0
  UpdateTime: 0
  UpdateExtent: Not Initialized
  Update Number Of Pieces: 1
  Update Piece: 0
  Update Ghost Level: 0
  RequestExactExtent: Off
   UpdateExtent: 0, 0, 0, 0, 0, 0
  WholeExtent: 0, -1, 0, -1, 0, -1
  Field Data:
    Debug: Off
    Modified Time: 550
    Reference Count: 1
    Registered Events: (none)
    Number Of Arrays: 0
    Number Of Components: 0
    Number Of Tuples: 0
  Locality: 0
  NumberOfConsumers: 0
  ExtentTranslator: (0x84c2810)
  MaximumNumberOfPieces: -1
  Number Of Points: 0
  Number Of Cells: 0
  Cell Data:
    Debug: Off
    Modified Time: 552
    Reference Count: 1
    Registered Events: (none)
    Number Of Arrays: 0
    Number Of Components: 0
    Number Of Tuples: 0
    Copy Flags: ( 1 1 1 1 1 )
    Scalars: (none)
    Vectors: (none)
    Normals: (none)
    TCoords: (none)
    Tensors: (none)
  Point Data:
    Debug: Off
    Modified Time: 553
    Reference Count: 1
    Registered Events: (none)
    Number Of Arrays: 0
    Number Of Components: 0
    Number Of Tuples: 0
    Copy Flags: ( 1 1 1 1 1 )
    Scalars: (none)
    Vectors: (none)
    Normals: (none)
    TCoords: (none)
    Tensors: (none)
  Bounds: 
    Xmin,Xmax: (1e+38, -1e+38)
    Ymin,Ymax: (1e+38, -1e+38)
    Zmin,Zmax: (1e+38, -1e+38)
  Compute Time: 0
  Release Data: Off
  ScalarType: 10
  NumberOfScalarComponents: 1
  Spacing: (1, 1, 1)
  Origin: (0, 0, 0)
  Dimensions: (0, 0, 0)
  Increments: (0, 0, 0)
  Extent: (0, -1, 0, -1, 0, -1)
  WholeExtent: (0, -1, 0, -1, 0, -1)

-- which looks strangely empty. Still the rendering works with the latter object, but not with the former. I'm starting to get frustrated...

Regards,
Øyvind Knudsen

----- Original Message -----
From: REGAT-BARREL Aurélien <arbvtk at yahoo.fr>
Date: Wed, 11 Feb 2004 20:13:21 +0100 (CET)
To: Oeyvind Knudsen <knudsen at operamail.com>, vtkusers at vtk.org
Subject: Re: [vtkusers] Basic question, vtkStructuredPoints

> Hello,
> So you want to include a vtk data file directly in your Python source code and build a vtkStructuredGrid from scratch ? Why ?
> I work on a project in Python which used to build its own vtkStructuredPoints from scratch in Python.
> Here is the code equivalent for you :
>     spData = vtkStructuredPoints()
>     spData.SetDimensions( 81, 81, 1 )
>     spData.SetOrigin( 0, 0, 0 )
>     spData.SetSpacing( 1, 1, 1 )
>     scalars = vtkUnsignedCharArray()
>     for z in range( 0, 1 ) :
>         for y in range( 0, 81 ) :
>             for x in range( 0, 81 ) :
>                 val = getValue( x, y, z )
>                 scalars.InsertNextValue( val )
>     spData.GetPointData().SetScalars( scalars )
>  
> It should work (you must replace getValue( x, y, z ) by the right thing) but in my opinion you should not use this method, since it is very slow because each VTK object method call cost is high du to the wrapping layer between VTK (C++) and your Python code. That's why the program I am working on was very slow and why I moved this code to C++.  If your really want to do it in Python, I recommend your to create a temporary vtk file, to read it as you are currently doing and then delete it in order to keep good performances. But maybe that if you dont use a bigger object than your 81x81x1 grid it will be done enough fast for your need.
> Hope it helps.
>  
> Aurélien REGAT-BARREL
>  
> 
> Oeyvind Knudsen <knudsen at operamail.com> wrote:
> Hi!
> 
> I'm using VTK to visualize a surface from a data file using the vtkStructuredPointsReader in Python. But from now the data should be passed directly from within the program, i.e. without using files or readers at all. Currently the code for making the surface looks like this:
> 
> reader = vtkStructuredPointsReader()
> reader.SetFileName("data.vtk")
> 
> geometry = vtkImageDataGeometryFilter()
> geometry.SetInput(reader.GetOutput()) #
> warp = vtkWarpScalar()
> warp.SetInput(geometry.GetOutput())
> warp.XYPlaneOff()
> warp.SetScaleFactor(100)
> 
> merge = vtkMergeFilter()
> merge.SetGeometry(warp.GetOutput())
> merge.SetScalars(reader.GetOutput()) #
> 
> smoother = vtkSmoothPolyDataFilter()
> smoother.SetInput(merge.GetOutput())
> smoother.SetNumberOfIterations(50)
> 
> mapper = vtkPolyDataMapper()
> mapper.SetInput(smoother.GetOutput())
> mapper.SetScalarRange(self.minData,self.maxData)
> mapper.ImmediateModeRenderingOff()
> 
> surface = vtkLODActor()
> surface.SetMapper(mapper)
> 
> self.renderer.AddActor(surface)
> (+ some axis stuff)
> 
> The data is in this format:
> 
> # vtk DataFile Version 2.0
> data
> ASCII
> DATASET STRUCTURED_POINTS
> DIMENSIONS 81 81 1
> ORIGIN 0 0 0
> SPACING 1 1 1
> POINT_DATA 6561
> SCALARS Scalars0 float 1
> LOOKUP_TABLE default
> 0.0624595315954 0.0686842278186 0.0747777522745 (+ many more numbers)
> 
> So, instead of using this file as a source I now get a python list of the data in to my visualization method. But I can't seem to get the vtkStructuredPoints object constructed in a proper way as my surface will no longer appear. I start with this:
> 
> spData = vtkStructuredPoints()
> spData.SetDimensions(81, 81, 1)
> 
> But how do I get the scalar values into spData so that spData and reader.GetOutput() (from the current code) yields the same resulting object? The goal is to replace all the occurences of reader.GetOutput() from the above code with just spData.
> 
> Regards, 
> Øyvind Knudsen
> 
> 		
> ---------------------------------
> Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail
-- 
_____________________________________________________________
Web-based SMS services available at http://www.operamail.com.
>From your mailbox to local or overseas cell phones.

Powered by Outblaze



More information about the vtkusers mailing list