<div>I try to make project which is simillar with example Medical3.cxx</div>
<div>(I want to make another plane in Medical3.cxx)</div>
<div>but I don't know what is the SetDisplayExtent. there are 6 numbers behind that </div>
<div>so I try to change but there is nothing to happen.</div>
<div>this is the source of Medical3.cxx please tell me what is SetDisplayExtent and how do they perform in that program?</div>
<div> </div>
<div>#include "vtkRenderer.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkVolume16Reader.h"<br>#include "vtkPolyDataMapper.h"<br>
#include "vtkActor.h"<br>#include "vtkOutlineFilter.h"<br>#include "vtkCamera.h"<br>#include "vtkStripper.h"<br>#include "vtkLookupTable.h"<br>#include "vtkImageDataGeometryFilter.h"<br>
#include "vtkProperty.h"<br>#include "vtkPolyDataNormals.h"<br>#include "vtkContourFilter.h"<br>#include "vtkImageData.h"<br>#include "vtkImageMapToColors.h"<br>#include "vtkImageActor.h"</div>
<div>int main (int argc, char **argv)<br>{<br> if (argc < 2)<br> {<br> cout << "Usage: " << argv[0] << " DATADIR/headsq/quarter" << endl;<br> return 1;<br> }</div>
<div> // Create the renderer, the render window, and the interactor. The<br> // renderer draws into the render window, the interactor enables<br> // mouse- and keyboard-based interaction with the data within the<br> // render window.<br>
//<br> vtkRenderer *aRenderer = vtkRenderer::New();<br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br> renWin->AddRenderer(aRenderer);<br> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);</div>
<div> // The following reader is used to read a series of 2D slices (images)<br> // that compose the volume. The slice dimensions are set, and the<br> // pixel spacing. The data Endianness must also be specified. The<br>
// reader usese the FilePrefix in combination with the slice number to<br> // construct filenames using the format FilePrefix.%d. (In this case<br> // the FilePrefix is the root name of the file: quarter.)<br> vtkVolume16Reader *v16 = vtkVolume16Reader::New();<br>
v16->SetDataDimensions(64,64);<br> v16->SetDataByteOrderToLittleEndian();<br> v16->SetFilePrefix (argv[1]);<br> v16->SetImageRange(1, 93);<br> v16->SetDataSpacing (3.2, 3.2, 1.5);</div>
<div> // An isosurface, or contour value of 500 is known to correspond to<br> // the skin of the patient. Once generated, a vtkPolyDataNormals<br> // filter is is used to create normals for smooth surface shading<br> // during rendering. The triangle stripper is used to create triangle<br>
// strips from the isosurface; these render much faster on may<br> // systems.<br> vtkContourFilter *skinExtractor = vtkContourFilter::New();<br> skinExtractor->SetInputConnection( v16->GetOutputPort());<br> skinExtractor->SetValue(0, 500);<br>
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();<br> skinNormals->SetInputConnection(skinExtractor->GetOutputPort());<br> skinNormals->SetFeatureAngle(60.0);<br> vtkStripper *skinStripper = vtkStripper::New();<br>
skinStripper->SetInputConnection(skinNormals->GetOutputPort());<br> vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();<br> skinMapper->SetInputConnection(skinStripper->GetOutputPort());<br> skinMapper->ScalarVisibilityOff();<br>
vtkActor *skin = vtkActor::New();<br> skin->SetMapper(skinMapper);<br> skin->GetProperty()->SetDiffuseColor(1, .49, .25);<br> skin->GetProperty()->SetSpecular(.3);<br> skin->GetProperty()->SetSpecularPower(20);</div>
<div> // An isosurface, or contour value of 1150 is known to correspond to<br> // the skin of the patient. Once generated, a vtkPolyDataNormals<br> // filter is is used to create normals for smooth surface shading<br>
// during rendering. The triangle stripper is used to create triangle<br> // strips from the isosurface; these render much faster on may<br> // systems.<br> vtkContourFilter *boneExtractor = vtkContourFilter::New();<br>
boneExtractor->SetInputConnection(v16->GetOutputPort());<br> boneExtractor->SetValue(0, 1150);<br> vtkPolyDataNormals *boneNormals = vtkPolyDataNormals::New();<br> boneNormals->SetInputConnection(boneExtractor->GetOutputPort());<br>
boneNormals->SetFeatureAngle(60.0);<br> vtkStripper *boneStripper = vtkStripper::New();<br> boneStripper->SetInputConnection(boneNormals->GetOutputPort());<br> vtkPolyDataMapper *boneMapper = vtkPolyDataMapper::New();<br>
boneMapper->SetInputConnection(boneStripper->GetOutputPort());<br> boneMapper->ScalarVisibilityOff();<br> vtkActor *bone = vtkActor::New();<br> bone->SetMapper(boneMapper);<br> bone->GetProperty()->SetDiffuseColor(1, 1, .9412);</div>
<div> // An outline provides context around the data.<br> //<br> vtkOutlineFilter *outlineData = vtkOutlineFilter::New();<br> outlineData->SetInputConnection(v16->GetOutputPort());<br> vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();<br>
mapOutline->SetInputConnection(outlineData->GetOutputPort());<br> vtkActor *outline = vtkActor::New();<br> outline->SetMapper(mapOutline);<br> outline->GetProperty()->SetColor(0,0,0);</div>
<div> // Now we are creating three orthogonal planes passing through the<br> // volume. Each plane uses a different texture map and therefore has<br> // different coloration.</div>
<div> // Start by creatin a black/white lookup table.<br> vtkLookupTable *bwLut = vtkLookupTable::New();<br> bwLut->SetTableRange (0, 2000);<br> bwLut->SetSaturationRange (0, 0);<br> bwLut->SetHueRange (0, 0);<br>
bwLut->SetValueRange (0, 1);<br> bwLut->Build(); //effective built</div>
<div> // Now create a lookup table that consists of the full hue circle<br> // (from HSV).<br> vtkLookupTable *hueLut = vtkLookupTable::New();<br> hueLut->SetTableRange (0, 2000);<br> hueLut->SetHueRange (0, 1);<br>
hueLut->SetSaturationRange (1, 1);<br> hueLut->SetValueRange (1, 1);<br> hueLut->Build(); //effective built</div>
<div> // Finally, create a lookup table with a single hue but having a range<br> // in the saturation of the hue.<br> vtkLookupTable *satLut = vtkLookupTable::New();<br> satLut->SetTableRange (0, 2000);<br> satLut->SetHueRange (.6, .6);<br>
satLut->SetSaturationRange (0, 1);<br> satLut->SetValueRange (1, 1);<br> satLut->Build(); //effective built</div>
<div> // Create the first of the three planes. The filter vtkImageMapToColors<br> // maps the data through the corresponding lookup table created above. The<br> // vtkImageActor is a type of vtkProp and conveniently displays an image on<br>
// a single quadrilateral plane. It does this using texture mapping and as<br> // a result is quite fast. (Note: the input image has to be unsigned char<br> // values, which the vtkImageMapToColors produces.) Note also that by<br>
// specifying the DisplayExtent, the pipeline requests data of this extent<br> // and the vtkImageMapToColors only processes a slice of data.<br> vtkImageMapToColors *saggitalColors = vtkImageMapToColors::New();<br> saggitalColors->SetInputConnection(v16->GetOutputPort());<br>
saggitalColors->SetLookupTable(bwLut);<br> vtkImageActor *saggital = vtkImageActor::New();<br> saggital->SetInput(saggitalColors->GetOutput());<br> saggital->SetDisplayExtent(32,32, 0,63, 0,92);</div>
<div> // Create the second (axial) plane of the three planes. We use the<br> // same approach as before except that the extent differs.<br> vtkImageMapToColors *axialColors = vtkImageMapToColors::New();<br> axialColors->SetInputConnection(v16->GetOutputPort());<br>
axialColors->SetLookupTable(hueLut);<br> vtkImageActor *axial = vtkImageActor::New();<br> axial->SetInput(axialColors->GetOutput());<br> axial->SetDisplayExtent(0,63, 0,63, 46,46);</div>
<div> // Create the third (coronal) plane of the three planes. We use <br> // the same approach as before except that the extent differs.<br> vtkImageMapToColors *coronalColors = vtkImageMapToColors::New();<br> coronalColors->SetInputConnection(v16->GetOutputPort());<br>
coronalColors->SetLookupTable(satLut);<br> vtkImageActor *coronal = vtkImageActor::New();<br> coronal->SetInput(coronalColors->GetOutput());<br> coronal->SetDisplayExtent(0,63, 32,32, 0,92);</div>
<div> // It is convenient to create an initial view of the data. The<br> // FocalPoint and Position form a vector direction. Later on<br> // (ResetCamera() method) this vector is used to position the camera<br> // to look at the data in this direction.<br>
vtkCamera *aCamera = vtkCamera::New();<br> aCamera->SetViewUp (0, 0, -1);<br> aCamera->SetPosition (0, 1, 0);<br> aCamera->SetFocalPoint (0, 0, 0);<br> aCamera->ComputeViewPlaneNormal();</div>
<div> // Actors are added to the renderer. <br> aRenderer->AddActor(outline);<br> aRenderer->AddActor(saggital);<br> aRenderer->AddActor(axial);<br> aRenderer->AddActor(coronal);<br> aRenderer->AddActor(axial);<br>
aRenderer->AddActor(coronal);<br> aRenderer->AddActor(skin);<br> aRenderer->AddActor(bone);</div>
<div> // Turn off bone for this example.<br> bone->VisibilityOff();</div>
<div> // Set skin to semi-transparent.<br> skin->GetProperty()->SetOpacity(0.5);</div>
<div> // An initial camera view is created. The Dolly() method moves <br> // the camera towards the FocalPoint, thereby enlarging the image.<br> aRenderer->SetActiveCamera(aCamera);<br> aRenderer->Render();<br>
aRenderer->ResetCamera ();<br> aCamera->Dolly(1.5);</div>
<div> // Set a background color for the renderer and set the size of the<br> // render window (expressed in pixels).<br> aRenderer->SetBackground(1,1,1);<br> renWin->SetSize(640, 480);</div>
<div> // Note that when camera movement occurs (as it does in the Dolly()<br> // method), the clipping planes often need adjusting. Clipping planes<br> // consist of two planes: near and far along the view direction. The <br>
// near plane clips out objects in front of the plane; the far plane<br> // clips out objects behind the plane. This way only what is drawn<br> // between the planes is actually rendered.<br> aRenderer->ResetCameraClippingRange ();</div>
<div> // interact with data<br> iren->Initialize();<br> iren->Start(); </div>
<div> // It is important to delete all objects created previously to prevent<br> // memory leaks. In this case, since the program is on its way to<br> // exiting, it is not so important. But in applications it is<br> // essential.<br>
v16->Delete();<br> skinExtractor->Delete();<br> skinNormals->Delete();<br> skinStripper->Delete();<br> skinMapper->Delete();<br> skin->Delete();<br> boneExtractor->Delete();<br> boneNormals->Delete();<br>
boneStripper->Delete();<br> boneMapper->Delete();<br> bone->Delete();<br> outlineData->Delete();<br> mapOutline->Delete();<br> outline->Delete();<br> bwLut->Delete();<br> hueLut->Delete();<br>
satLut->Delete();<br> saggitalColors->Delete();<br> saggital->Delete();<br> axialColors->Delete();<br> axial->Delete();<br> coronalColors->Delete();<br> coronal->Delete();<br> aCamera->Delete();<br>
aRenderer->Delete();<br> renWin->Delete();<br> iren->Delete();</div>
<div> return 0;<br>}<br></div>
<div> </div>