[vtkusers] Unable to access vtkDataArray after reading data from file

vtk replies vtk_replies at yahoo.com
Thu Jun 6 00:40:10 EDT 2002


Hi,

I have problems accessing the vtkDataArray class instance in my program. 
I have a structured Grid data file that I read with the help of the vtkStructuredGridReader class. The points in the file are of type double. 
I want to copy some of the points from the vtkDoubleArray, ( I presume that the (x,y,z) point coordinates are stored after structuredGridReader reads the file), into my own double array. 

It looks like it is possible to get points of type float or int using the code below but there is no method that returns points of type double.

****
	vtkStructuredGridReader *reader = vtkStructuredGridReader::New();
     reader->SetFileName("../../../vtk32/java/frame51.vtk");
     reader->SetScalarsName("sc2");
     reader->Update();
	vtkStructuredGrid *structGrid = vtkStructuredGrid::New();
	 structGrid = reader->GetOutput();

 structGrid->GetPoint (vtkIdType ptId, float p[3]);   // some variable ptId .



 I want to get type double points that I initially had on the file. Is there a way to do this ? ( I want to use the StructuredGridReader object so that I can get the structuredGrid that I intend to use for finding cell connectivity later ). 

I tested using the ReadArray(const char* dataType, int numTuples, int numComponents) in the vtkDataReader class but the method seems to dump core.

The code is given below. If anyone knows a way to get the point coordinates as type double, please let me know.


Thanks in advance for any help.

Regards,
Joseph.

*************************************************

	vtkStructuredGridReader *reader = vtkStructuredGridReader::New();
	
     reader->SetFileName("../../../vtk32/java/frame51.vtk");
     reader->SetScalarsName("sc2");
     reader->Update();
	vtkStructuredGrid *structGrid = vtkStructuredGrid::New();
    structGrid = reader->GetOutput();
	 	
	int dimensions[3];
	    structGrid->GetDimensions(dimensions);
	    static int totalPoints = 1;
	   for(int i=0; i<3; i++)
 	totalPoints = totalPoints * dimensions[i];

    cout << "total Points is " << totalPoints <<endl;

	vtkDataArray *dataArray;

	dataArray = vtkDoubleArray::New();
		 
	dataArray = reader->ReadArray("double", totalPoints, 3);




---------------------------------
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020605/affe7541/attachment.htm>


More information about the vtkusers mailing list