[vtkusers] writing EnSight files - Error: No BlockID was found

Randall Hand randall.hand at gmail.com
Thu Nov 29 09:49:03 EST 2007


(forwarding this to the list at-large, for archival)

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):

            DEBUGMSG(2, "Constructing a vtkEnSightWriter to save data");
            ptr_ens = vtkEnSightWriter::New();
            ezViz_RegisterNewVtkObject(scene, ptr_ens);
            // We need this magical "BlockID" scalar celldata field
            if (data->GetCellData()) {
                if (data->GetCellData()->GetArray("BlockId")) {
                    FoundCellData = true;
                }
            }
            if (FoundCellData == false) {
                DEBUGMSG(2, "Creating \"BlockId\" Cell Array...");
                //Looks like we have to create it.. crap
                vtkIntArray *bids = vtkIntArray::New();
                bids->SetName("BlockId");
                for(i=0; i<data->GetNumberOfCells(); i++)
                    bids->InsertNextValue(1);
                data->GetCellData()->SetScalars(bids);
            }

            if (data->IsA("vtkUnstructuredGrid")) {
            } else {
                DEBUGMSG(2, "Converting data to Unstructured Grid...");
                vtkDataSetTriangleFilter *tri =
vtkDataSetTriangleFilter::New();
                ezViz_RegisterNewVtkObject(scene, tri);
                tri->SetInput(data);
                tri->Update();
                data = tri->GetOutput();
            }
            int blockids[2];
            blockids[0] = 1;
            blockids[1] = 0;
            ptr_ens->SetNumberOfBlocks(1);
            ptr_ens->SetBlockIDs(blockids);
            ptr_ens->SetTimeStep(0);
            ptr_ens->SetInput(vtkUnstructuredGrid::SafeDownCast(data));
            ptr_ens->SetFileName(scene->output_filename);
            DEBUGMSG1(1, "Saving to \"%s\"", scene->output_filename);
            ptr_ens->Write();
            ptr_ens->WriteCaseFile(1);



On Nov 29, 2007 6:17 AM, Eduardo Camargo <camargo at lncc.br> wrote:

>
> Did anyone of you write EnSight files and did not have problems with
> BlockID?
>
> Regards, Eduardo
>
>
>
> Martin Baumann schrieb:
>
> > Hi,
> > I am trying to save EnSight data files with the following code:
> > string in_file = "test.asc";
> > string out_file = "ensight.ens";
> > /// **********************************************/
> > /// read Legacy-Format variables/
> > /// **********************************************/
> > vtkUnstructuredGridReader* _reader = vtkUnstructuredGridReader::New();
> _reader->SetFileName(in_file.c_str());
> > _reader->Update();
> > /// **********************************************/
> > /// write EnSight/
> > /// **********************************************/
> > vtkEnSightWriter* _ens_writer = vtkEnSightWriter::New();
> > _ens_writer->SetFileName(out_file.c_str());
> > _ens_writer->SetInput(_reader->GetOutput());
> > _ens_writer->Write();
> > _ens_writer->WriteCaseFile(1);
> >
> > When I run this I get the error
> > No BlockID was found
> > for some some hundred times.
> > Still threee files are created:
> > ensight.0.case
> > ensight.0.00000.geo
> > ensight.0.00000_n.u_x
> > - I tried to find out what the error means. What are BlockIDs used for?
> - Is there any information on writing EnSight files with vtk?
> > - In the example file (test.asc) there are contained three scalars: u_x,
> u_y and u_z.
> > Only one (u_x) is written to an EnSight data file. I need to export all
> of the
> > scalars and vectors if there are any in the input file. How can I do
> this?
> > Regards, M.B.
> >------------------------------------------------------------------------
> _______________________________________________
> >This is the private VTK discussion list.
> >Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> >Follow this link to subscribe/unsubscribe:
> >http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
> --
> Atenciosamente,
>
> Eduardo Camargo
> Analista de Sistemas
> HeMoLab - http://www.lncc.br/prjhemo
> Laboratório Nacional de Computação Científica - LNCC
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
----------------------------------------
Randall Hand
Visualization Scientist
ERDC MSRC-ITL



-- 
----------------------------------------
Randall Hand
Visualization Scientist
ERDC MSRC-ITL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071129/1f6ee6c1/attachment.htm>


More information about the vtkusers mailing list