[vtkusers] Picking Point Problem

Mathieu Malaterre mathieu.malaterre at kitware.com
Thu Jul 8 08:18:11 EDT 2004


Andrea,

  A bug was recently found in vtkPicker.cxx, please try to apply a simila patch to your VTK version, or use the latest CVS

HTH
Mathieu

> 
> From: Andrea Gavana <andrea.gavana at polymtl.ca>
> Date: 2004/07/08 Thu AM 05:57:38 EDT
> To: vtk <vtkusers at vtk.org>
> Subject: [vtkusers] Picking Point Problem
> 
> Hello NG,
> 
>       by using the very nice suggestion from Prabhu, I was able to transform a 
> Numeric matrix into a vtkStructuredGrid object and to display it very fast. 
> Unfortunately, now I'm facing a more complicated problem. 
>       I'm using wxPython together with VTK in order to build a small GUI. Now, 
> in order to use wxPython with VTK, I use wxVTKRenderWindow and 
> wxVTKRenderWindowInteractor from the VTK 4.2 (VTK/Wrapping/Python/wx) release. 
> Everything goes fine, I can interact with my window (even if I always have the 
> feeling that wxVTKRenderWindowInteractor is never called, and wxVTKRenderWindow 
> is called instead to do interactions...). I can zoom, pan, rotate, transform to 
> wireframe, surface, and so on...
> 
> BUT, when I try to use the "P" key from the keyboard (I think it is used to 
> Pick a point), Python (IDLE, Pythonwin, whatever you prefer) crashes with a 
> Window$ message dialog like this (sorry I'm translating the error from italian 
> language, so it may not be exactly the same in an english/us computer):
> 
> -- ERROR MESSAGE BEGIN --
> 
> VTK Reservoir Surface: pythonwin.exe - Application Error (THIS IS THE TITLE)
> 
> The instruction "0x02a9749e" has made refernce to the memory "0x0cf30020". The 
> memory could not be "read".
> 
> Click on OK to terminate the application
> Click on Abort to debug the application
> 
> -- ERROR MESSAGE END --
> 
> I don't know what happens, every time is the same. I would just like to be able 
> to pick a point in the 3D grid and show it on a small GUI (like mayavi), but 
> using wxPython seems to be not so easy.
> 
> I include the code I'm using. In the code, nanna refers to my matrix that 
> contains all the coordinates of the 3D grid, while zcentout is an array of 
> scalars I use to color my 3D grid.
> 
> Does anyone has some suggestion? Even other ideas on how to build my GUI or a 
> GUI-point picker are welcome...
> 
> Thank you a lot for every suggestion.
> 
> # CODE BEGIN
> 
> vtk_xyz = vtkpython.vtkFloatArray()
> vtk_xyz.SetNumberOfTuples(8*nx*ny*nz)
> vtk_xyz.SetNumberOfComponents(3)
> vtk_xyz.SetVoidArray(Numeric.ravel(nanna),24*nx*ny*nz,1)
> 
> vtk_pts = vtkpython.vtkPoints()
> vtk_pts.SetNumberOfPoints(8*nx*ny*nz)
> vtk_pts.SetDataTypeToFloat()
> vtk_pts.SetData(vtk_xyz)
> 
> # create vtk data
> a = vtkpython.vtkStructuredGrid()
> a.SetDimensions(2*nx, 2*ny, 2*nz)
> a.SetPoints(vtk_pts)
> 
> # create scalars
> vtk_scal = vtkpython.vtkFloatArray()
> vtk_scal.SetNumberOfTuples(8*nx*ny*nz)
> vtk_scal.SetNumberOfComponents(1)
> vtk_scal.SetVoidArray(Numeric.ravel(zcentout),8*nx*ny*nz,1)
> 
> a.GetPointData().SetScalars(vtk_scal)
> 
> mapsurface = vtkpython.vtkDataSetMapper()
> mapedge = vtkpython.vtkDataSetMapper()
> meshGeom = vtkpython.vtkExtractGrid()
> 
> meshGeom.SetInput(a)
> 
> mapsurface.SetInput(meshGeom.GetOutput())
> mapedge.SetInput(meshGeom.GetOutput())
> 	
> actsurface = vtkpython.vtkActor()
> actsurface.SetMapper(mapsurface)
> actedge = vtkpython.vtkActor()
> actedge.SetMapper(mapedge)
> 	
> data_range = a.GetScalarRange()
> mapsurface.SetScalarRange(data_range)
> mapsurface.ScalarVisibilityOn()
> mapedge.SetScalarRange(data_range)
> mapedge.ScalarVisibilityOff()
> 
> actsurface.GetProperty().SetRepresentationToSurface()
> actsurface.SetScale(1.0,1.0,6.0)
> actsurface.SetOrientation(135.0,0.0,0.0)
> 
> actedge.GetProperty().SetRepresentationToWireframe()
> actedge.GetProperty().SetLineWidth(1.5)
> actedge.SetScale(1.0,1.0,6.0)
> actedge.SetOrientation(135.0,0.0,0.0)
> actedge.GetProperty().SetColor(0,0,0)
> actedge.GetProperty().SetAmbient(1.0);
> actedge.GetProperty().SetDiffuse(0.0);
> actedge.GetProperty().SetSpecular(0.0);
> 	
> ren = vtkpython.vtkRenderer()
> 
> self.window = wxFrame(None, -1, "VTK Reservoir Surface", wxPoint(100,10), 
> wxSize518, 282), 
> style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxNO_FULL_REPAINT_ON_RESIZE)
> 
> hiwin = wxVTKRenderWindow(self.window,-1,1)
> hirenWin = hiwin.GetRenderWindow()
> hiren = vtkpython.vtkRenderer()
> hiren.SetRenderWindow(hirenWin)
> 
> hiren.AddActor(actsurface)
> hiren.AddActor(actedge)
> 
> hirenWin.AddRenderer(hiren)
> hiren.GetActiveCamera().Zoom(1.5)
> self.window.Show(TRUE)
> self.window.SetSize((1000,900))
> 
> iren = wxVTKRenderWindowInteractor(self.window, -1,1)
> iren.SetRenderWindow(hirenWin)
> 
> iren.Initialize()
> iren.Start()
> 
> 
> # CODE END
> _______________________________________________
> 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://www.vtk.org/mailman/listinfo/vtkusers
> 





More information about the vtkusers mailing list