<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
as I learned today the elements that are within an EnSight file belong
to blocks.<br>
For example there can be three blocks if you have three different
surfaces.<br>
By default an vtkUnstructuredGrid has no blocks. So I put all elements
of my grid<br>
into one block by creating a CellDataArray of integers with the size of
cells contained<br>
in the grid. Each component contains '1' to make the cell belong to
block 1.<br>
<br>
I do this in the following way:<br>
<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre> <span style="color: rgb(128, 128, 128);"><i>// Checking BlockIDs</i></span>
vtkDataArray *Blocks=grid->GetCellData()->GetScalars(<span
style="color: rgb(221, 0, 0);">"BlockId"</span>);
<b>if</b> (Blocks==NULL) <span
style="color: rgb(128, 128, 128);"><i>//|| strcmp(BlockData->GetName(),"BlockId"))</i></span>
{
cout << <span
style="color: rgb(221, 0, 0);">"Warning: No BlockIDs were found in source."</span> << endl;
cout << <span
style="color: rgb(221, 0, 0);">" BlockID is set to 1 for all Cells."</span> << endl;
<span
style="color: rgb(128, 128, 128);"><i>// Adding BlockID (BlockID = 1 for all cells)</i></span>
<span
style="color: rgb(128, 0, 0);">long</span> number_cells = grid->GetNumberOfCells();
vtkUnsignedIntArray* blockIDs = vtkUnsignedIntArray::New();
blockIDs->SetNumberOfTuples(number_cells);
blockIDs->SetNumberOfComponents(<span
style="color: rgb(0, 0, 255);">1</span>);
blockIDs->SetName(<span
style="color: rgb(221, 0, 0);">"BlockId"</span>);
<b>for</b> (<span
style="color: rgb(128, 0, 0);">int</span> c=<span
style="color: rgb(0, 0, 255);">0</span>; c<number_cells; ++c)
blockIDs->SetValue (c, <span
style="color: rgb(0, 0, 255);">1</span>); <span
style="color: rgb(128, 128, 128);"><i>// all cells have BlockID = 1</i></span>
grid->GetCellData()->AddArray(blockIDs);
}
</pre>
Now writing the EnSight file works without error.<br>
I can open the file in EnSight and plot gridpoints and color them with
scalar values that are <br>
written in the files for example. But I cannot do anything else in
EnSight! For example no<br>
Isosurfaces can be created. Is it necessary to have cell data in
EnSight? My grid contains points,<br>
point data and cells.<br>
<br>
I tried to create cell data out of my point data but the export doesn't
work any more: All files are<br>
created and no errors are shown, but the files that should contain the
cell data are empty.<br>
<br>
I create the cell data by:<br>
<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre> <span style="color: rgb(128, 128, 128);"><i>// convert to unstructured grid with cells</i></span>
vtkPointDataToCellData *point2cell = vtkPointDataToCellData::New();
point2cell->SetInputConnection(reader->GetOutputPort());
point2cell->Update();
grid = point2cell->GetUnstructuredGridOutput();
</pre>
<br>
Regards, M.B.<br>
</body>
</html>