[vtkusers] directly adding elements to unstructured grids... extension to mo re than one

Malcolm Drummond malcolm at geovision.co.za
Tue Apr 15 06:34:18 EDT 2003


directly adding elements to unstructured grids... extension to more than oneHi Kyle

Here's a TCL script that combines many wedges into one UG dataset - it could be more efficient but at least it's a starting point.

Hope this helps
Malcolm

----- Original Message ----- 
  From: Roberson, Kyle 
  To: Vtk-Mailing-List (E-mail) 
  Sent: Monday, April 14, 2003 6:20 PM
  Subject: [vtkusers] directly adding elements to unstructured grids... extension to mo re than one


  I'm trying to make unstructured grids out of various ABAQUS elements. I can successfully make a picture of the model by making an unstructured grid for EACH element and turning it into an independent actor. I would like to put several elements into each unstructured grid and turn that into an actor to make my subsequent manipulations easier to handle. However, I havent figured out how to do that. When I add more than one to the unstructured grid, no graphics come out the other end.

  Here's what I'm doing now (in Python). Only two types of elements are in to save space. 

  Cheers, 
  Kyle 



  # Create the usual rendering stuff. 

  ren = vtk.vtkRenderer() 
  renWin = vtk.vtkRenderWindow() 
  renWin.AddRenderer(ren) 
  renWin.SetSize(1280, 1024) 
  iren = vtk.vtkRenderWindowInteractor() 
  iren.SetRenderWindow(renWin) 

  ren.SetBackground(.1, .2, .4) 

  # Use the brute-force method to make an actor for each thing 



  for k,v in elem.items() : 

      if v[0] == "S3R" : 

          thingPoints = vtk.vtkPoints() 
          thingPoints.SetNumberOfPoints(3) 
          thingPoints.InsertPoint(0, node[v[2]][0], node[v[2]][1], node[v[2]][2]) 
          thingPoints.InsertPoint(1, node[v[3]][0], node[v[3]][1], node[v[3]][2]) 
          thingPoints.InsertPoint(2, node[v[4]][0], node[v[4]][1], node[v[4]][2]) 



          aThing = vtk.vtkTriangle() 
          aThing.GetPointIds().SetId(0, 0) 
          aThing.GetPointIds().SetId(1, 1) 
          aThing.GetPointIds().SetId(2, 2) 

          aThingGrid = vtk.vtkUnstructuredGrid() 
          aThingGrid.Allocate(1, 1) 
          aThingGrid.InsertNextCell(aThing.GetCellType(),\ 
                                         aThing.GetPointIds()) 
          aThingGrid.SetPoints(thingPoints) 



          aThingMapper = vtk.vtkDataSetMapper() 
          aThingMapper.SetInput(aThingGrid) 
          aThingActor = vtk.vtkActor() 
          aThingActor.SetMapper(aThingMapper) 
          aThingActor.GetProperty().SetDiffuseColor(1, 1, 0) 
          # aThingActor.GetProperty().SetOpacity(0.15) 



          aThingActor.GetProperty().SetRepresentationToWireframe() 

          ren.AddActor(aThingActor) 

      elif v[0] == "S4R" : 
          thingPoints = vtk.vtkPoints() 
          thingPoints.SetNumberOfPoints(4) 
          thingPoints.InsertPoint(0, node[v[2]][0], node[v[2]][1], node[v[2]][2]) 
          thingPoints.InsertPoint(1, node[v[3]][0], node[v[3]][1], node[v[3]][2]) 
          thingPoints.InsertPoint(2, node[v[4]][0], node[v[4]][1], node[v[4]][2]) 
          thingPoints.InsertPoint(3, node[v[5]][0], node[v[5]][1], node[v[5]][2]) 

          aThing = vtk.vtkQuad() 
          aThing.GetPointIds().SetId(0, 0) 
          aThing.GetPointIds().SetId(1, 1) 
          aThing.GetPointIds().SetId(2, 2) 
          aThing.GetPointIds().SetId(3, 3) 

          aThingGrid = vtk.vtkUnstructuredGrid() 
          aThingGrid.Allocate(1, 1) 
          aThingGrid.InsertNextCell(aThing.GetCellType(),\ 
                                         aThing.GetPointIds()) 
          aThingGrid.SetPoints(thingPoints) 



          aThingMapper = vtk.vtkDataSetMapper() 
          aThingMapper.SetInput(aThingGrid) 
          aThingActor = vtk.vtkActor() 
          aThingActor.SetMapper(aThingMapper) 
          aThingActor.GetProperty().SetDiffuseColor(1, 1, 0) 
          #    aThingActor.GetProperty().SetOpacity(0.15) 



          aThingActor.GetProperty().SetRepresentationToWireframe() 

          ren.AddActor(aThingActor) 
          
  # ... several more for different elements elided ... 

  # Render the scene and start interaction. 

  iren.Initialize() 
  renWin.Render() 
  iren.Start() 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030415/ae7dbaa1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wedges1.tcl
Type: application/octet-stream
Size: 1345 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030415/ae7dbaa1/attachment.obj>


More information about the vtkusers mailing list