[vtkusers] Problem with vtkImageData->GetScalarComponentAsFloat()
Dzung Manh Chu
cmdungbk at yahoo.com
Thu Aug 2 12:52:05 EDT 2007
Hello all.
I'm writing a C/C++ program in which I use VTK 4.4 (on Fedora platform). I'm trying to read a VTK-formated file and store data to an array. This is part of the code:
vtkImageData *coral = vtkImageData::New();
/* Set up an XML reader object */
vtkXMLImageDataReader *reader = vtkXMLImageDataReader::New();
/* Put here the file name of the data set */
reader->SetFileName("/MadracisMirabilisFirst.vti");
/* With vtkExtractGrid we can choose the volume of interest (VOI) and
subsample the data set */
vtkExtractVOI *voi = vtkExtractVOI::New();
voi->SetInput(reader->GetOutput());
reader->Update(); /* Read the data file */
/* Choose the volume of interest and do the resampling */
voi->SetSampleRate(8, 8, 8);
voi->SetOutput(coral);
voi->Update(); /* Apply the update */
/* Get the number of points in the data */
int extent[6];
coral->GetExtent(extent);
/* Get the spacing in the data. Because our data is in cm and the data of
coral is in mm, we have to multiply the spacing with 0.10 */
double spacing[3];
coral->GetSpacing(spacing);
spacing[0] *= 0.10;
spacing[1] *= 0.10;
spacing[2] *= 0.10;
/* Rotate the coral in a way that it stands correct in the computational
domain and save it in the array 'compdom'. This is for the fist and
second data set. This is for object 389 and 393! */
int X = (extent[1] - extent[0] + 1);
int Y = (extent[3] - extent[2] + 1);
int Z = (extent[5] - extent[4] + 1);
int *compdom;
if((compdom = (int *)malloc(sizeof(int) * X*Y*Z)) == NULL) {
fprintf(stderr, "failed to allocate memory for computational domain\n");
exit(EXIT_FAILURE);
}
for(int k = extent[5], c = 0; k >= extent[4]; k--, c++) {
for(int j = extent[3], b = 0; j >= extent[2]; j--, b++) {
for(int i = extent[0], a = 0; i <= extent[1]; i++, a++) {
COMPDOM(a,b,c) =
(int)(coral->GetScalarComponentAsFloat(i,j,k,0));
}
}
}
I'm using CMake to create Makefile and it already created the Makefile. But when I compiled the program by "make" command, it raised the following error:
/ufs/chu/VTK/extract/extract.cxx:82: error: âclass vtkImageDataâ has no member named âGetScalarComponentAsFloatâ
I already checked the help document and found that the method GetScalarComponentAsFloat() is used only for TCL. Any of you know how to do replace this method when using C/C++?
Thank you very much in advance.
Dzung.
---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070802/6ca3bd7c/attachment.htm>
More information about the vtkusers
mailing list