[vtkusers] reading element blocks from exodus mesh into a vtkSurfaceFilter

Joseph Butner liljoe at unm.edu
Fri Dec 12 13:47:28 EST 2014

I have an exodus mesh file that contains numbered element blocks.  I want to be able to determine which element block (if any) any (x, y, z) coordinate is in.  To do this, I read the mesh in with vtkExodusiiMeshReader, attempt to generate a vtkSurfaceFilter for each element block, and use vtkSelectEnclosedPoints to find the element block the point is in.  Unfortunately, I'm doing something wrong when reading the nodes for each element block, the data structure that is supposed to have the node coordinates seems to be empty, it throws this error:

ERROR: In /home/joe/Downloads/VTK-6.1.0/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 715
vtkCompositeDataPipeline (0x35181a0): Input port 1 of algorithm vtkSelectEnclosedPoints(0x1c31480) has 0 connections but is not optional.

A small piece of the code I have is:

#define Instantiate(obj, class) vtkSmartPointer<class> obj = vtkSmartPointer<class>::New()

//I want to store the vtkPolyData for each element block in a vector, will be passed to vtkSelectEnclosedPoints later:
std::vector<vtkSmartPointer<vtkPolyData> > element_blocks_surface_filter_vector;

std::string exodusMesh = "foo.exo";

// get the metadata from the mesh:

// read in the element blocks, make a surface filter for each, push_back into vector:
for (int z = 0; z < exodusiiReader->GetNumberOfElementBlockArrays(); z++)
    const char* nname = exodusiiReader->GetElementBlockArrayName(z);

 *  I think my mistake is in the following line
    exodusiiReader->SetObjectArrayStatus(exodusiiReader->ELEM_BLOCK, nname, 1);

    Instantiate( surfaceFilter,vtkDataSetSurfaceFilter );
    Instantiate( MultiBlockData, vtkMultiBlockDataSet );
    Instantiate( DataObject, vtkDataObject );

    MultiBlockData = exodusiiReader->GetOutput();
    DataObject= MultiBlockData->GetBlock(0);

 * everything below here should be fine (except the DataObject generated above isn't correct).

 * it works when I just send it the whole mesh

    #if VTK_MAJOR_VERSION <= 5



Any information about what I'm doing wrong above would be greatly appreciated. Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141212/a5590dff/attachment.html>

More information about the vtkusers mailing list