<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>directly adding elements to unstructured grids... extension to more than one</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>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.</FONT></P>

<P><FONT SIZE=2>Here's what I'm doing now (in Python). Only two types of elements are in to save space.</FONT>
</P>

<P><FONT SIZE=2>Cheers,</FONT>
<BR><FONT SIZE=2>Kyle</FONT>
</P>
<BR>

<P><FONT SIZE=2># Create the usual rendering stuff.</FONT>
</P>

<P><FONT SIZE=2>ren = vtk.vtkRenderer()</FONT>
<BR><FONT SIZE=2>renWin = vtk.vtkRenderWindow()</FONT>
<BR><FONT SIZE=2>renWin.AddRenderer(ren)</FONT>
<BR><FONT SIZE=2>renWin.SetSize(1280, 1024)</FONT>
<BR><FONT SIZE=2>iren = vtk.vtkRenderWindowInteractor()</FONT>
<BR><FONT SIZE=2>iren.SetRenderWindow(renWin)</FONT>
</P>

<P><FONT SIZE=2>ren.SetBackground(.1, .2, .4)</FONT>
</P>

<P><FONT SIZE=2># Use the brute-force method to make an actor for each thing</FONT>
</P>
<BR>

<P><FONT SIZE=2>for k,v in elem.items() :</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; if v[0] == &quot;S3R&quot; :</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints = vtk.vtkPoints()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.SetNumberOfPoints(3)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(0, node[v[2]][0], node[v[2]][1], node[v[2]][2])</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(1, node[v[3]][0], node[v[3]][1], node[v[3]][2])</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(2, node[v[4]][0], node[v[4]][1], node[v[4]][2])</FONT>
</P>
<BR>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing = vtk.vtkTriangle()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(0, 0)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(1, 1)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(2, 2)</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid = vtk.vtkUnstructuredGrid()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid.Allocate(1, 1)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid.InsertNextCell(aThing.GetCellType(),\</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds())</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid.SetPoints(thingPoints)</FONT>
</P>
<BR>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingMapper = vtk.vtkDataSetMapper()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingMapper.SetInput(aThingGrid)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor = vtk.vtkActor()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor.SetMapper(aThingMapper)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor.GetProperty().SetDiffuseColor(1, 1, 0)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # aThingActor.GetProperty().SetOpacity(0.15)</FONT>
</P>
<BR>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor.GetProperty().SetRepresentationToWireframe()</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ren.AddActor(aThingActor)</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; elif v[0] == &quot;S4R&quot; :</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints = vtk.vtkPoints()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.SetNumberOfPoints(4)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(0, node[v[2]][0], node[v[2]][1], node[v[2]][2])</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(1, node[v[3]][0], node[v[3]][1], node[v[3]][2])</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(2, node[v[4]][0], node[v[4]][1], node[v[4]][2])</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thingPoints.InsertPoint(3, node[v[5]][0], node[v[5]][1], node[v[5]][2])</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing = vtk.vtkQuad()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(0, 0)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(1, 1)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(2, 2)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds().SetId(3, 3)</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid = vtk.vtkUnstructuredGrid()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid.Allocate(1, 1)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid.InsertNextCell(aThing.GetCellType(),\</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThing.GetPointIds())</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingGrid.SetPoints(thingPoints)</FONT>
</P>
<BR>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingMapper = vtk.vtkDataSetMapper()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingMapper.SetInput(aThingGrid)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor = vtk.vtkActor()</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor.SetMapper(aThingMapper)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor.GetProperty().SetDiffuseColor(1, 1, 0)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; aThingActor.GetProperty().SetOpacity(0.15)</FONT>
</P>
<BR>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aThingActor.GetProperty().SetRepresentationToWireframe()</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ren.AddActor(aThingActor)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2># ... several more for different elements elided ...</FONT>
</P>

<P><FONT SIZE=2># Render the scene and start interaction.</FONT>
</P>

<P><FONT SIZE=2>iren.Initialize()</FONT>
<BR><FONT SIZE=2>renWin.Render()</FONT>
<BR><FONT SIZE=2>iren.Start()</FONT>
</P>

</BODY>
</HTML>