<meta http-equiv="content-type" content="text/html; charset=utf-8"><div>On Fri, Feb 19, 2010 at 6:30 AM, Sebastian Gatzka <span dir="ltr"><<a href="mailto:sebastian.gatzka@stud.tu-darmstadt.de">sebastian.gatzka@stud.tu-darmstadt.de</a>></span> wrote:</div>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Hello.<br>
<br>
This time I'm trying to set cell (centroid) values (scalar and vector)
to a structured grid.<br>
All the examples I have found set values to the grid points - not the
cell-centroids.<br>
<br>
This should lead to a classical CFD / finite-volume representation of
field data like temperature, density or velocities.<br>
So beside the actual assignment to the field I need to know how to
display the field data, and maybe how to switch between them.<br>
<br>
Have a nice day.<br>
Sebastian<br>
</font></font>
</div><div bgcolor="#ffffff" text="#000000"><font size="-1"><font face="Helvetica, Arial, sans-serif"><br></font></font></div></blockquote><div><br></div><div>Sebastian,</div><div><br></div><div>You can access cells via their (i,j,k) coordinates using this function:</div>
<div> </div><div>vtkCell* GetCell(vtkStructuredGrid* grid, int i, int j, int k)</div><div>{</div><div> int dims[3];</div><div> grid->GetDimensions(dims);</div><div><br></div><div> if(i < 0 || i > dims[0] - 1 || </div>
<div> j < 0 || j > dims[1] - 1 || </div><div> k < 0 || k > dims[2] - 1 )</div><div> {</div><div> return NULL; // out of bounds!</div><div> }</div><div> </div><div> int pos[3];</div><div> pos[0] = i;</div>
<div> pos[1] = j;</div><div> pos[2] = k;</div><div><br></div><div> vtkIdType id;</div><div> id = vtkStructuredData::ComputeCellId(dims, pos);</div><div> </div><div> return grid->GetCell(id); </div><div>}</div><div>
<br></div><div>I'm working on adding it to vtk so you can directly call</div><div><br></div><div>grid->GetCell(i,j,k)</div><div><br></div><div>Hope this helps,</div><br>David</div>