[vtkusers] How to solve the display out of window?

Jianlong Zhou zhoujianlong at hotmail.com
Mon Jul 23 03:37:49 EDT 2001


hi, vtkusers
I do my work based on Sample MFC program. Now I want to the program to 
render a volume scene. The volume is read into VTK in SampleDOC class and 
then I render volume in SampleView class. My code in SampleViw class as 
follows, But when I run the program, the display is out of window and if a 
use mouse to dolly the scene, I can see part of the image. Anyone know what 
is the problem?
By the way, could someone kind enough to tell me the efficient pipeline and 
strategy to render volume in MFC based program?

Thank you.

Best regards.

jl

////////////////

void CSampleView::OnVolumeDisplay()
{
	// Create a transfer function mapping scalar value to opacity
	this->oTFun = vtkPiecewiseFunction::New();
	    oTFun->AddSegment(80, 0.0, 255, 1.0);

	// Create a transfer function mapping scalar value to
        // color (grey)
	this->cTFun = vtkPiecewiseFunction::New();
	    cTFun->AddSegment(0, 1.0, 255, 1.0);

	// Create a property for the volume and set the
        //transfer functions.
	// Turn shading on and use trilinear interpolation
	this->volumeProperty = vtkVolumeProperty::New();
	    volumeProperty->SetColor(cTFun);
	    volumeProperty->SetScalarOpacity(oTFun);
	    volumeProperty->SetInterpolationTypeToLinear();
	    volumeProperty->ShadeOn();

	// Create a ray function - this is a compositing ray function
	this->compositeFunction =
	    vtkVolumeRayCastCompositeFunction::New();

	// Create the volume mapper and set the ray function and
        // scalar input
	this->volumeMapper = vtkVolumeRayCastMapper::New();
	    volumeMapper->SetInput(this->GetDocument()->ireader->GetOutput());
                       //ireader is a object of vtkImageReader class
	    volumeMapper->SetVolumeRayCastFunction(compositeFunction);

	// Create the volume and set the mapper and property
	this->volume = vtkVolume::New();
	    volume->SetMapper(volumeMapper);
	    volume->SetProperty(volumeProperty);

	///////////////////////////////////
	this->volume->SetOrigin(0.5,0.5,0);
	/////////////////////////////

	this->Renderer->AddVolume(this->volume);
	this->Renderer->GetActiveCamera()->Azimuth(20.0);
	this->Renderer->GetActiveCamera()->Dolly(1.60);
	this->Renderer->ResetCameraClippingRange();

	// interact with data
    this->RenderWindow->SetSize(300, 300);
    this->RenderWindow->Render();

	this->RenderWindow->Render();

	// Interact with the data at 3 frames per second
	this->Interactor->SetDesiredUpdateRate(3.0);
	this->Interactor->SetStillUpdateRate(0.001);
	this->Interactor->Start();

	this->oTFun->Delete();
	this->cTFun->Delete();
	this->volumeProperty->Delete();
	this->compositeFunction->Delete();
	this->volumeMapper->Delete();
	this->volume->Delete();
}

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





More information about the vtkusers mailing list