<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
<!--
@font-face
{font-family:Courier}
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
.MsoChpDefault
{font-family:"Calibri",sans-serif}
@page WordSection1
{margin:70.85pt 70.85pt 70.85pt 70.85pt}
-->
</style><style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" lang="NL">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I don't know the details of your app, but you should follow the following schema<br>
I'll assume for simplicity, that the hexahedra do not share any vertices with any other hexahedra<br>
if they do, then you need to figure out how to avoid replicating points.<br>
<br>
# use "output", as the pre-defined vtkUnstructuredGrid created for you<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<div>
<div class="WordSection1"># create a single vtkPoints and add all vertices to it<br>
# if you have N hexahedra, you'll add 8xN points<br>
# create a single vtkDoubleArray of size N<br>
# offset the indices of each hexahedra by 8<br>
<p class="MsoNormal"><i><span style="color:#7F7F7F"><br>
</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points = vtk.vtkPoints()</span></i></p>
<p class="MsoNormal"><br>
</p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> #Create the attribute</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> NodeLength = vtk.vtkDoubleArray()</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> NodeLength.SetName('Node lenght')</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> I=0<br>
</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> for materialpath, x , y , z , leafsize in octree:</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> # create the coordinates for the points</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> l = .5*leafsize</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> xL = int(x)-l</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> xR = int(x)+l </span>
</i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> yL = int(y)-l</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> yR = int(y)+l </span>
</i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> zL = int(z)-l</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> zR = int(z)+l</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> </span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xL, yL, zL)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xR, yL, zL)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xR, yR, zL)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xL, yR, zL)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xL, yL, zR)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xR, yL, zR)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xR, yR, zR)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> points.InsertNextPoint(xL, yR, zR)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> </span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> # Create a hexahedron from the points</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> hex_ = vtk.vtkHexahedron()</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> for i in range(0, numberOfVertices):</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> hex_.GetPointIds().SetId(i, 8*I+i)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> </span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> NodeLength.InsertNextValue(leafsize)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> </span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> # Add the geometry to the unstructured grid</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> output.InsertNextCell(hex_.GetCellType(), hex_.GetPointIds())</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> I = I +1</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"><br>
</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> # Add the points and hexahedron to an unstructured grid</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> output.Points = points</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> output.CellData.SetScalars(NodeLength)</span></i></p>
<p class="MsoNormal"><i><span style="color:#7F7F7F"> </span></i></p>
<p class="MsoNormal"><span style="font-size:12.0pt; font-family:"Times New Roman",serif"> </span></p>
</div>
</div>
</div>
</div>
</body>
</html>