[vtkusers] proper use of vtkStructuredPoints in C++ for vtkVolume ?
jean-charles campagne
jcpouce at yahoo.com
Mon Apr 14 07:14:42 EDT 2003
hello,
i'm trying to generated a volume
(vtkVolumeRayCastMapper) out of structured points in
C++.
But i am having troubles specifying the points
manually (eg from an array of integers or float).
Can someone illustrate the use of vtkStructuredPoints
(specifying points/dimensions/... manu)?
this is the source of the program i'm trying to write
correctly. It fails miserably at the rendering phase.
i'm guessing i'm missing or mis-initializing
something... but i'm not sure what...
-----------------------------------------
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkStructuredPoints.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPoints.h"
int main( int argc, char *argv[] )
{
vtkPoints *points = vtkPoints::New();
vtkVolumeMapper *volumeMapper =
vtkVolumeRayCastMapper::New();
vtkVolume *volume = vtkVolume::New();
vtkRenderer *ren1= vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkStructuredPoints *structuredPoints =
vtkStructuredPoints::New();
structuredPoints->SetSpacing(1.0,1.0,1.0);
structuredPoints->SetScalarType(VTK_UNSIGNED_SHORT);
structuredPoints->SetDimensions(2, 2, 2);
structuredPoints->SetNumberOfScalarComponents (1);
structuredPoints->SetUpdateExtent(-100,100,-100,100,-100,100);
structuredPoints->SetExtent(-10,100,-100,100,-100,100);
//setting points
const int n = 5;
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
for (int k=0; k<n; k++) {
structuredPoints
->SetScalarComponentFromFloat (i, j, k, 0, 1.0);
}
}
}
volumeMapper->SetInput(structuredPoints);
volume->SetMapper(volumeMapper);
ren1->AddVolume(volume);
ren1->SetBackground( 1.0, 1.0, 1.0 );
renWin->AddRenderer( ren1 );
renWin->SetSize( 300, 300 );
renWin->Render();
return 0;
}
-----------------------------------------
many thanks
JCC
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
More information about the vtkusers
mailing list