[vtkusers] How to extract datas from vtkLSdynaReader

David Thompson dcthomp at sandia.gov
Thu Jun 17 15:00:08 EDT 2010


>  I used vtkLSdynaReader to read a ls-dyna d3plot file which just  
> contain a solid object, but program crashed when run to:
>
> cout<<"number of Solid cell:"<<  rdr->OutputSolid- 
> >GetNumberOfCells()<<endl;
> In fact, all variables Output*****  are defined as  
> vtkUnstructuredGrid*,
>
> I checked the variable "OutputSolid" using function "getNameclass",  
> and find it is not  "vtkUnstructuredGrid" type after program  
> running.So I have no idea how to extract data from "OutputSolid".
>
> Could you do me a favor that how to extract all datas from  
> "OutputSolid"?
>
> By the way, all variables are changed from "protected" to "public"  
> for debugging.
>
Those variables are not meant to be accessible and do not have well- 
defined values outside of RequestData. Instead, you should use the  
public API to obtain the output dataset:

   vtkMultiBlockDataSet* output =  
vtkMultiBlockDataSet::SafeDownCast( rdr->GetOutput() )

The blocks of this dataset contain data in the same order as listed in  
the documentation:
	http://www.vtk.org/doc/nightly/html/classvtkLSDynaReader.html
Presumably,

   vtkUnstructuredGrid* solid =  
vtkUnstructuredGrid::SafeDownCast( output->GetBlock( 0 ) );
   if ( solid )
     cout << "Number of solid elements: " << solid->GetNumberOfCells()  
<< "\n";

should return a non-NULL pointer containing the solid object from the  
file and (if non-NULL) print the number of cells.

	David




More information about the vtkusers mailing list