[vtkusers] vtk guru needed (vtkGlyph3D + vtkImageData)...this time in 3D

Mathieu Malaterre malat at free.fr
Thu Feb 13 10:13:47 EST 2003


Hi all, Hi Berk,

  This time I tried vtkGlyph3D on a 3D image following your advice. But 
I got a seg fault.

Here is the backtrace of it:

$ gdb /usr/bin/python2.2
GNU gdb Red Hat Linux (5.1.90CVS-5)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...(no debugging symbols 
found)...
(gdb) run hack.py
Starting program: /usr/bin/python2.2 hack.py
(no debugging symbols found)...(no debugging symbols found)...[New 
Thread 1024 (LWP 26286)]
(no debugging symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)...
Program received signal SIGABRT, Aborted.
[Switching to Thread 1024 (LWP 26286)]
0x42029241 in kill () from /lib/i686/libc.so.6
(gdb) bt
#0  0x42029241 in kill () from /lib/i686/libc.so.6
#1  0x4003ec4b in raise () from /lib/i686/libpthread.so.0
#2  0x4202a7d2 in abort () from /lib/i686/libc.so.6
#3  0x4050db8b in __default_terminate () at ../../gcc/libgcc2.c:-1
#4  0x4050dbaa in __terminate () from /usr/lib/libstdc++-libc6.2-2.so.3
#5  0x4050e8e5 in throw_helper (eh=0xb6800478, pc=0x80cb708, 
my_udata=0xbfffe8a0, offset_p=0xbfffe89c) from 
/usr/lib/libstdc++-libc6.2-2.so.3
#6  0x4050ebdf in __rethrow (index=0x4051bdc8) from 
/usr/lib/libstdc++-libc6.2-2.so.3
#7  0x4051141f in __builtin_vec_new (sz=1409286144) at 
../../gcc/cp/new2.cc:-1
#8  0x4039070d in vtkFloatArray::Allocate (this=0x242aed00, 
sz=352321536) at /home/malat/Kitware/VTK/Common/vtkFloatArray.cxx:79
#9  0x41047e61 in vtkGlyph3D::Execute (this=0x82428a8) at 
/home/malat/Kitware/VTK/Graphics/vtkGlyph3D.cxx:283
#10 0x4042091b in vtkSource::ExecuteData (this=0x82428a8) at 
/home/malat/Kitware/VTK/Common/vtkSource.h:136
#11 0x4041f729 in vtkSource::UpdateData (this=0x82428a8, 
output=0x8242958) at /home/malat/Kitware/VTK/Common/vtkSource.cxx:395
#12 0x40379614 in vtkDataObject::UpdateData (this=0x8242958) at 
/home/malat/Kitware/VTK/Common/vtkDataObject.cxx:373
#13 0x403793cf in vtkDataObject::Update (this=0x8242958) at 
/home/malat/Kitware/VTK/Common/vtkDataObject.cxx:254
#14 0x41427556 in vtkMapper::Update (this=0x8242ed0) at 
/home/malat/Kitware/VTK/Rendering/vtkMapper.cxx:347
#15 0x41435ad4 in vtkPolyDataMapper::Update (this=0x8242ed0) at 
/home/malat/Kitware/VTK/Rendering/vtkPolyDataMapper.cxx:104
#16 0x41435b19 in vtkPolyDataMapper::GetBounds (this=0x8242ed0) at 
/home/malat/Kitware/VTK/Rendering/vtkPolyDataMapper.cxx:119
#17 0x413cac15 in vtkActor::GetBounds (this=0x823fdb8) at 
/home/malat/Kitware/VTK/Rendering/vtkActor.cxx:322
#18 0x4145224e in vtkRenderer::ComputeVisiblePropBounds (this=0x8243510, 
allBounds=0xbfffedc0) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderer.cxx:626
#19 0x41452549 in vtkRenderer::ResetCamera (this=0x8243510) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderer.cxx:684
#20 0x41451ef3 in vtkRenderer::GetActiveCamera (this=0x8243510) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderer.cxx:519
#21 0x413eb042 in vtkFrustumCoverageCuller::Cull (this=0x8243770, 
ren=0x8243510, propList=0x82ad100, listLength=@0x8243614, 
initialized=@0xbfffef68)
    at /home/malat/Kitware/VTK/Rendering/vtkFrustumCoverageCuller.cxx:73
#22 0x41451b14 in vtkRenderer::AllocateTime (this=0x8243510) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderer.cxx:402
#23 0x41451409 in vtkRenderer::Render (this=0x8243510) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderer.cxx:225
#24 0x41456795 in vtkRendererCollection::Render (this=0x82438a0) at 
/home/malat/Kitware/VTK/Rendering/vtkRendererCollection.cxx:54
#25 0x41444de8 in vtkRenderWindow::DoStereoRender (this=0x8242270) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderWindow.cxx:617
#26 0x41444d98 in vtkRenderWindow::DoFDRender (this=0x8242270) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderWindow.cxx:605
#27 0x41444a44 in vtkRenderWindow::DoAARender (this=0x8242270) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderWindow.cxx:499
#28 0x41444327 in vtkRenderWindow::Render (this=0x8242270) at 
/home/malat/Kitware/VTK/Rendering/vtkRenderWindow.cxx:326
#29 0x414be37c in vtkXOpenGLRenderWindow::Render (this=0x8242270) at 
/home/malat/Kitware/VTK/Rendering/vtkXOpenGLRenderWindow.cxx:1285
#30 0x41281a49 in PyvtkXOpenGLRenderWindow_Render (self=0x8243880, 
args=0x810302c) at 
/home/malat/Kitware/VTKBin/Rendering/vtkXOpenGLRenderWindowPython.cxx:941
#31 0x080cb709 in PyCFunction_Call ()
#32 0x08079641 in eval_frame ()
#33 0x0807a8bc in PyEval_EvalCodeEx ()
#34 0x08076871 in PyEval_EvalCode ()
#35 0x08096201 in run_node ()
#36 0x080952d6 in PyRun_SimpleFileExFlags ()
#37 0x08094cff in PyRun_AnyFileExFlags ()
#38 0x08053aa2 in Py_Main ()
#39 0x080531f3 in main ()
#40 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6


And the script is simply:

#begining of script
from vtk import *

reader = vtkStructuredPointsReader()
reader.SetFileName('image.vtk')
reader.UpdateWholeExtent()  #important

reader.GetOutput().GetPointData().SetVectors(reader.GetOutput().GetPointData().GetScalars()) 
#Berk advice

gs = vtkGlyphSource2D ()
gs.SetGlyphTypeToArrow()

glypher = vtkGlyph3D()
glypher .SetInput (reader.GetOutput())
glypher .SetSource (gs.GetOutput())
glypher.OrientOn();
glypher.SetVectorModeToUseVector();

mapper = vtkPolyDataMapper ()
mapper .SetInput (glypher .GetOutput())

actor = vtkActor()
actor.SetMapper(mapper)

ren = vtkRenderer()
ren.AddActor(actor)

renWin = vtkRenderWindow()
renWin.AddRenderer(ren)

iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
renWin.Render()
iren.Start()


Any help appreciate,
mathieu


Berk Geveci wrote:

>Just do
>
>grad.GetOutput().GetPointData().SetVectors(
>     grad.GetOutput().GetPointData().GetScalars())
>
>However, this will only work if you are using VTK 4.0 or newer.
>
>-Berk
>
>
>On Wed, 2003-02-12 at 11:34, Mathieu Malaterre wrote:
>  
>
>>Hi vtk guru,
>>  Here is a small python script which I would like to improve. As I want 
>>to display a vector field I would like to use vtkGlyph3D but for that I 
>>need to have all my vectors in PointData.Vectors (or PointData.Normals). 
>>The problem is that I use vtkImageGradient which puts stuff in 
>>PointData.Scalars.
>>
>>  So what I would like is to move (instead of copying) all the tuples 
>>from Scalars to Vectors.
>>
>>Thanks for any help,
>>mathieu
>>
>>
>>#beginning of script
>>
>>from vtk import *
>>
>>reader = vtkStructuredPointsReader()
>>reader.SetFileName('gvf.vtk')
>>
>>grad = vtkImageGradient()
>>grad.SetInput(reader.GetOutput())
>>grad.SetDimensionality(2)
>>
>>grad.UpdateWholeExtent()  #important
>>
>>size = grad.GetOutput().GetPointData().GetScalars().GetNumberOfTuples()
>>
>>vec = vtkDoubleArray()
>>vec.SetNumberOfComponents(3)
>>vec.Allocate(3*size, 0)
>>
>>for i in range(size):
>>   x = grad.GetOutput().GetPointData().GetScalars().GetTuple2(i) 
>>   vec.InsertNextTuple3(x[0],x[1],0.)  #this is so bad !
>>
>>grad.GetOutput().GetPointData().SetVectors(vec)
>>
>>
>>gs = vtkGlyphSource2D ()
>>gs .SetGlyphTypeToArrow()
>>gs .SetScale (0.2)
>>gs .FilledOff()
>>
>># Create a table of glyphs
>>glypher = vtkGlyph3D()
>>glypher .SetInput (reader.GetOutput())
>>glypher .SetSource (gs.GetOutput())
>>glypher.ScalingOff();
>>glypher.OrientOn();
>>glypher.SetVectorModeToUseVector();
>>glypher.SetColorModeToColorByVector();
>>
>>mapper = vtkPolyDataMapper ()
>>mapper .SetInput (glypher .GetOutput())
>>
>>actor = vtkActor()
>>actor.SetMapper(mapper)
>>
>>ren = vtkRenderer()
>>ren.AddActor(actor)
>>
>>renWin = vtkRenderWindow()
>>renWin.AddRenderer(ren)
>>
>>iren = vtkRenderWindowInteractor()
>>iren.SetRenderWindow(renWin)
>>
>>iren.Initialize()
>>renWin.Render()
>>iren.Start()
>>
>>
>>_______________________________________________
>>This is the private VTK discussion list. 
>>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>Follow this link to subscribe/unsubscribe:
>>http://public.kitware.com/mailman/listinfo/vtkusers
>>    
>>
>
>
>
>
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>  
>





More information about the vtkusers mailing list