(forwarding this to the list at-large, for archival)<br><br><div class="gmail_quote">I had the same problem, and eventually wound up adding a Cell array entitled "BlockID'.. The resulting code that i'm using looks like this (pardon the macros you don't have):
<br><br><span style="font-family: courier new,monospace;">
DEBUGMSG(2, "Constructing a vtkEnSightWriter to save data");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens = vtkEnSightWriter::New();
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ezViz_RegisterNewVtkObject(scene, ptr_ens);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
// We need this magical "BlockID" scalar celldata field</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (data->GetCellData()) {
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (data->GetCellData()->GetArray("BlockId")) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> FoundCellData = true;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span>
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (FoundCellData == false) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> DEBUGMSG(2, "Creating \"BlockId\" Cell Array...");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
//Looks like we have to create it.. crap</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkIntArray *bids = vtkIntArray::New();</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> bids->SetName("BlockId");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
for(i=0; i<data->GetNumberOfCells(); i++)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> bids->InsertNextValue(1);</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> data->GetCellData()->SetScalars(bids);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (data->IsA("vtkUnstructuredGrid")) {
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> } else {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
DEBUGMSG(2, "Converting data to Unstructured Grid...");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkDataSetTriangleFilter *tri = vtkDataSetTriangleFilter::New();
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ezViz_RegisterNewVtkObject(scene, tri);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
tri->SetInput(data);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> tri->Update();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> data = tri->GetOutput();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> int blockids[2];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> blockids[0] = 1;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> blockids[1] = 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens->SetNumberOfBlocks(1);
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens->SetBlockIDs(blockids);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
ptr_ens->SetTimeStep(0);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens->SetInput(vtkUnstructuredGrid::SafeDownCast(data));</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens->SetFileName(scene->output_filename);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
DEBUGMSG1(1, "Saving to \"%s\"", scene->output_filename);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens->Write();
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ptr_ens->WriteCaseFile(1);</span><div><div></div><div class="Wj3C7c"><br style="font-family: courier new,monospace;">
<br><br><div class="gmail_quote">
On Nov 29, 2007 6:17 AM, Eduardo Camargo <<a href="mailto:camargo@lncc.br" target="_blank">camargo@lncc.br</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Did anyone of you write EnSight files and did not have problems with
BlockID?<br><br>Regards, Eduardo<br><br><br><br>Martin
Baumann schrieb:<br><br>> Hi,<br>> I am trying to save EnSight
data files with the following code:<br>> string in_file =
"test.asc";<br>> string out_file =
"ensight.ens";<br>> ///
**********************************************/<br>> /// read
Legacy-Format variables/<br>> ///
**********************************************/<br>>
vtkUnstructuredGridReader* _reader = vtkUnstructuredGridReader::New();
_reader->SetFileName(in_file.c_str());<br>>
_reader->Update();<br>> ///
**********************************************/<br>> /// write
EnSight/<br>> /// **********************************************/<br>> vtkEnSightWriter* _ens_writer = vtkEnSightWriter::New();<br>>
_ens_writer->SetFileName(out_file.c_str());<br>>
_ens_writer->SetInput(_reader->GetOutput());<br>>
_ens_writer->Write();<br>> _ens_writer->WriteCaseFile(1);<br>> <br>> When I run this I get the error<br>> No BlockID
was found<br>> for some some hundred times.<br>> Still threee
files are created:<br>> ensight.0.case<br>>
ensight.0.00000.geo<br>> ensight.0.00000_n.u_x<br>> - I tried
to find out what the error means. What are BlockIDs used for? - Is there
any information on writing EnSight files with vtk?<br>> - In the
example file (test.asc) there are contained three scalars: u_x, u_y and
u_z.<br>> Only one (u_x) is written to an EnSight data file. I need
to export all of the<br>> scalars and vectors if there are any in
the input file. How can I do<br>this?<br>> Regards, M.B.<br>>------------------------------------------------------------------------
_______________________________________________<br>>This is the
private VTK discussion list. <br>>Please keep messages on-topic.
Check the FAQ at:<br><a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>Follow
this link to subscribe/unsubscribe:<br>><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a> <br><font color="#888888"><br><br><br>-- <br>Atenciosamente,
<br><br>Eduardo Camargo<br>Analista de
Sistemas<br>HeMoLab - <a href="http://www.lncc.br/prjhemo" target="_blank">http://www.lncc.br/prjhemo</a><br>Laboratório
Nacional de Computação Científica - LNCC<br></font><br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br><br></blockquote>
</div><br><br clear="all"><br>-- <br></div></div>----------------------------------------<br><font color="#888888">Randall Hand <br>Visualization Scientist<br>ERDC MSRC-ITL
</font></div><br><br clear="all"><br>-- <br>----------------------------------------<br>Randall Hand <br>Visualization Scientist<br>ERDC MSRC-ITL