[vtkusers] Fw: cutter for vtkGlyph3D

alex Dowson alexdowson at hotmail.com
Wed Apr 25 01:07:06 EDT 2012


Hi

For visibility of plane you need widget for that.  check the vtkPlaneWidget .


alex


From: zhixiu li 
Sent: Wednesday, April 25, 2012 10:15 AM
To: alex Dowson 
Subject: Re: [vtkusers] Fw: cutter for vtkGlyph3D

Thank you. I correct but can't see the plain. And I also set the ren.SetBackground(0, 0.1, 0.5)
but the background is still black.... 


On Wed, Apr 25, 2012 at 12:38 AM, alex Dowson <alexdowson at hotmail.com> wrote:

  Hi

  In Cutter code there is problem 

  cutter.SetInput(pdb.GetInput())
  should be
  cutter.SetInput(pdb.GetOutput())


  Alex



  From: zhixiu li 
  Sent: Wednesday, April 25, 2012 9:35 AM
  To: alex Dowson 
  Subject: Re: [vtkusers] cutter for vtkGlyph3D

  Here is my code.
  PDB format is a format for protein structure.
  Basicly it has n atoms and each atom has x.y,z coordinate. It is like a network. I attach a pdb file for you~
  The visualization of the pdb is fine. The only thing is the cutting doesn't work

  Thank you very much!


   
  import vtk
  import sys
   

  pdb = vtk.vtkPDBReader()
  pdb.SetFileName(sys.argv[1])
  pdb.SetHBScale(1.0)
  pdb.SetBScale(1.0)
  pdb.Update()

  #create a plane to cut,here it cuts in the XZ direction (xz normal=(1,0,0);XY =(0,0,1),YZ =(0,1,0)
  plane=vtk.vtkPlane()
  plane.SetOrigin(0,0,0)
  plane.SetNormal(10,0,0)
   
  #create cutter
  cutter=vtk.vtkCutter()
  cutter.SetCutFunction(plane)
  cutter.SetInput(pdb.GetInput())
  cutter.Update()
  cutterMapper=vtk.vtkPolyDataMapper()
  cutterMapper.SetInputConnection(cutter.GetOutputPort())
   
  #create plane actor
  planeActor=vtk.vtkActor()
  planeActor.GetProperty().SetColor(1.0,0.8,0)
  planeActor.GetProperty().SetLineWidth(2)
  planeActor.SetMapper(cutterMapper)
   
   
  #create renderers and add actors of plane and cube
  ren = vtk.vtkRenderer()
  ren.AddActor(planeActor)


  #creat atom sphere
  sphere = vtk.vtkSphereSource()
  sphere.SetCenter(0, 0, 0)
  sphere.SetRadius(1)
  sphere.SetThetaResolution(10)
  sphere.SetPhiResolution(10)

  glyph = vtk.vtkGlyph3D()
  glyph.SetInputConnection(pdb.GetOutputPort())
  glyph.SetOrient(1)
  glyph.SetColorMode(1)
  # // glyph.ScalingOn()
  glyph.SetScaleMode(2)
  glyph.SetScaleFactor(.25)
  glyph.SetSourceConnection(sphere.GetOutputPort())

  atomMapper = vtk.vtkPolyDataMapper()
  atomMapper.SetInputConnection(glyph.GetOutputPort())
  atomMapper.ImmediateModeRenderingOn()
  atomMapper.UseLookupTableScalarRangeOff()
  atomMapper.ScalarVisibilityOn()
  atomMapper.SetScalarModeToDefault()

  atom = vtk.vtkLODActor()
  atom.SetMapper(atomMapper)
  atom.GetProperty().SetRepresentationToSurface()
  atom.GetProperty().SetInterpolationToGouraud()
  atom.GetProperty().SetAmbient(0.15)
  atom.GetProperty().SetDiffuse(0.85)
  atom.GetProperty().SetSpecular(0.1)
  atom.GetProperty().SetSpecularPower(30)
  atom.GetProperty().SetSpecularColor(1, 1, 1)
  atom.SetNumberOfCloudPoints(30000)
  ren.AddActor(atom)


  #connection between atoms
  tube = vtk.vtkTubeFilter()
  tube.SetInputConnection(pdb.GetOutputPort())
  tube.SetNumberOfSides(10)
  tube.CappingOff()
  tube.SetRadius(0.2)
  tube.SetVaryRadius(0)
  tube.SetRadiusFactor(10)

  bondMapper = vtk.vtkPolyDataMapper()
  bondMapper.SetInputConnection(tube.GetOutputPort())
  bondMapper.ImmediateModeRenderingOn()
  bondMapper.UseLookupTableScalarRangeOff()
  bondMapper.ScalarVisibilityOff()
  bondMapper.SetScalarModeToDefault()

  bond = vtk.vtkLODActor()
  bond.SetMapper(bondMapper)
  bond.GetProperty().SetRepresentationToSurface()
  bond.GetProperty().SetInterpolationToGouraud()
  bond.GetProperty().SetAmbient(0.15)
  bond.GetProperty().SetDiffuse(0.85)
  bond.GetProperty().SetSpecular(0.1)
  bond.GetProperty().SetSpecularPower(30)
  bond.GetProperty().SetSpecularColor(1, 1, 1)
  bond.GetProperty().SetDiffuseColor(1.0000, 0.8941, 0.70981)

  ren.AddActor(bond)

  #Add renderer to renderwindow and render
  renWin = vtk.vtkRenderWindow()
  renWin.AddRenderer(ren)
  renWin.SetSize(600, 600)
  iren = vtk.vtkRenderWindowInteractor()
  iren.SetRenderWindow(renWin)
  ren.SetBackground(0,0,0)
  renWin.Render()
  iren.Start()



  On Tue, Apr 24, 2012 at 11:48 PM, alex Dowson <alexdowson at hotmail.com> wrote:

    Hi

    Check you PDBReader FileName path . If is not locating file then output will be empty and you will get this error due to empty output. Also I still donot know
    what is PDB format so is it triangulated polydata ?


    Alex



    From: zhixiu li 
    Sent: Wednesday, April 25, 2012 9:14 AM
    To: alex Dowson 
    Subject: Re: [vtkusers] cutter for vtkGlyph3D

    Thank you.
    But after I tried your method,I got this kind of error:
    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkExecutive.cxx, line 377
    vtkStreamingDemandDrivenPipeline (02B1D470): Attempt to get input information vector from input port index 0 for algorithm vtkPDBReader(02B1D150), which has 0 input ports.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkExecutive.cxx, line 377
    vtkStreamingDemandDrivenPipeline (02B1D470): Attempt to get input information vector from input port index 0 for algorithm vtkPDBReader(02B1D150), which has 0 input ports.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkExecutive.cxx, line 377
    vtkStreamingDemandDrivenPipeline (02B1D470): Attempt to get input information vector from input port index 0 for algorithm vtkPDBReader(02B1D150), which has 0 input ports.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkDemandDrivenPipeline.cxx, line 727
    vtkStreamingDemandDrivenPipeline (02B360A8): Input port 0 of algorithm vtkStructuredGridOutlineFilter(02B24EB0) has 0 connections but is not optional.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkDemandDrivenPipeline.cxx, line 727
    vtkStreamingDemandDrivenPipeline (02B33170): Input port 0 of algorithm vtkStructuredGridGeometryFilter(02B32C00) has 0 connections but is not optional.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkDemandDrivenPipeline.cxx, line 727
    vtkStreamingDemandDrivenPipeline (02B2FEB8): Input port 0 of algorithm vtkCutter(02B2BE00) has 0 connections but is not optional.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkDemandDrivenPipeline.cxx, line 727
    vtkStreamingDemandDrivenPipeline (02B360A8): Input port 0 of algorithm vtkStructuredGridOutlineFilter(02B24EB0) has 0 connections but is not optional.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkDemandDrivenPipeline.cxx, line 727
    vtkStreamingDemandDrivenPipeline (02B33170): Input port 0 of algorithm vtkStructuredGridGeometryFilter(02B32C00) has 0 connections but is not optional.

    ERROR: In ..\..\vtk-5.8.0\Filtering\vtkDemandDrivenPipeline.cxx, line 727
    vtkStreamingDemandDrivenPipeline (02B2FEB8): Input port 0 of algorithm vtkCutter(02B2BE00) has 0 connections but is not optional.



    On Tue, Apr 24, 2012 at 11:38 PM, alex Dowson <alexdowson at hotmail.com> wrote:

      Hi

      You can try like this

      plane = vtk.vtkPlane()
      plane.SetOrigin(0,0,0) 

      plane.SetNormal(0.17, 0, 0.9579)
      planeCut = vtk.vtkCutter()

      planeCut.SetInput(pdb.GetOutput())
      planeCut.SetCutFunction(plane) 




      From: zhixiu li 
      Sent: Wednesday, April 25, 2012 8:48 AM
      To: vtkusers 
      Subject: Re: [vtkusers] cutter for vtkGlyph3D

      Sorry, I didn't say it clearly.
      I read the pdb by
      pdb = vtk.vtkPDBReader()
      pdb.SetFileName(sys.argv[1])

      And I want to cut the pdb by the plain and its cutter

      plane = vtk.vtkPlane()
      plane.SetOrigin(??????????????????????what should I put in here)
      plane.SetNormal(0.17, 0, 0.9579)
      planeCut = vtk.vtkCutter()
      planeCut.SetInput(????????????????????what should I put in here)
      planeCut.SetCutFunction(plane)


      Thank you!



      On Tue, Apr 24, 2012 at 11:04 PM, zhixiu li <zhixiuli at gmail.com> wrote:

        Dear ALL,
        I have a pdb file and I want to use the pdbreader to read the pdb file. And use use vtkGlyph3D for each atom (each points ) of the pdb. I want to use a plain to cut this pdb and show the cutting plain of the pdb. How do I combine vtkCutter and vtkGlyph3D to achieve the aim? Thank you. 



--------------------------------------------------------------------------
      _______________________________________________
      Powered by www.kitware.com

      Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

      Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

      Follow this link to subscribe/unsubscribe:
      http://www.vtk.org/mailman/listinfo/vtkusers




  _______________________________________________
  Powered by www.kitware.com

  Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

  Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

  Follow this link to subscribe/unsubscribe:
  http://www.vtk.org/mailman/listinfo/vtkusers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120425/cb018030/attachment.htm>


More information about the vtkusers mailing list