<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>directly adding elements to unstructured grids... extension to more than one</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Kyle</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Hope this helps</FONT></DIV>
<DIV><FONT face=Arial size=2>Malcolm</FONT></DIV>
<DIV> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=Kyle_Roberson@duratekinc.com
href="mailto:Kyle_Roberson@duratekinc.com">Roberson, Kyle</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=vtkusers@public.kitware.com
href="mailto:vtkusers@public.kitware.com">Vtk-Mailing-List (E-mail)</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, April 14, 2003 6:20
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [vtkusers] directly adding
elements to unstructured grids... extension to mo re than one</DIV>
<DIV><BR></DIV>
<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> if v[0] == "S3R" :</FONT> </P>
<P><FONT size=2> thingPoints =
vtk.vtkPoints()</FONT> <BR><FONT
size=2>
thingPoints.SetNumberOfPoints(3)</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(0,
node[v[2]][0], node[v[2]][1], node[v[2]][2])</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(1,
node[v[3]][0], node[v[3]][1], node[v[3]][2])</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(2,
node[v[4]][0], node[v[4]][1], node[v[4]][2])</FONT> </P><BR>
<P><FONT size=2> aThing =
vtk.vtkTriangle()</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(0, 0)</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(1, 1)</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(2, 2)</FONT> </P>
<P><FONT size=2> aThingGrid =
vtk.vtkUnstructuredGrid()</FONT> <BR><FONT
size=2> aThingGrid.Allocate(1,
1)</FONT> <BR><FONT size=2>
aThingGrid.InsertNextCell(aThing.GetCellType(),\</FONT> <BR><FONT
size=2>
aThing.GetPointIds())</FONT> <BR><FONT
size=2>
aThingGrid.SetPoints(thingPoints)</FONT> </P><BR>
<P><FONT size=2> aThingMapper =
vtk.vtkDataSetMapper()</FONT> <BR><FONT
size=2>
aThingMapper.SetInput(aThingGrid)</FONT> <BR><FONT
size=2> aThingActor =
vtk.vtkActor()</FONT> <BR><FONT
size=2>
aThingActor.SetMapper(aThingMapper)</FONT> <BR><FONT
size=2>
aThingActor.GetProperty().SetDiffuseColor(1, 1, 0)</FONT> <BR><FONT
size=2> #
aThingActor.GetProperty().SetOpacity(0.15)</FONT> </P><BR>
<P><FONT size=2>
aThingActor.GetProperty().SetRepresentationToWireframe()</FONT> </P>
<P><FONT size=2>
ren.AddActor(aThingActor)</FONT> </P>
<P><FONT size=2> elif v[0] == "S4R" :</FONT> <BR><FONT
size=2> thingPoints =
vtk.vtkPoints()</FONT> <BR><FONT
size=2>
thingPoints.SetNumberOfPoints(4)</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(0,
node[v[2]][0], node[v[2]][1], node[v[2]][2])</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(1,
node[v[3]][0], node[v[3]][1], node[v[3]][2])</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(2,
node[v[4]][0], node[v[4]][1], node[v[4]][2])</FONT> <BR><FONT
size=2> thingPoints.InsertPoint(3,
node[v[5]][0], node[v[5]][1], node[v[5]][2])</FONT> </P>
<P><FONT size=2> aThing =
vtk.vtkQuad()</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(0, 0)</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(1, 1)</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(2, 2)</FONT> <BR><FONT
size=2>
aThing.GetPointIds().SetId(3, 3)</FONT> </P>
<P><FONT size=2> aThingGrid =
vtk.vtkUnstructuredGrid()</FONT> <BR><FONT
size=2> aThingGrid.Allocate(1,
1)</FONT> <BR><FONT size=2>
aThingGrid.InsertNextCell(aThing.GetCellType(),\</FONT> <BR><FONT
size=2>
aThing.GetPointIds())</FONT> <BR><FONT
size=2>
aThingGrid.SetPoints(thingPoints)</FONT> </P><BR>
<P><FONT size=2> aThingMapper =
vtk.vtkDataSetMapper()</FONT> <BR><FONT
size=2>
aThingMapper.SetInput(aThingGrid)</FONT> <BR><FONT
size=2> aThingActor =
vtk.vtkActor()</FONT> <BR><FONT
size=2>
aThingActor.SetMapper(aThingMapper)</FONT> <BR><FONT
size=2>
aThingActor.GetProperty().SetDiffuseColor(1, 1, 0)</FONT> <BR><FONT
size=2> #
aThingActor.GetProperty().SetOpacity(0.15)</FONT> </P><BR>
<P><FONT size=2>
aThingActor.GetProperty().SetRepresentationToWireframe()</FONT> </P>
<P><FONT size=2>
ren.AddActor(aThingActor)</FONT> <BR><FONT
size=2> </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></BLOCKQUOTE></BODY></HTML>