//============================================================================ // Name : tumor.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C, Ansi-style //============================================================================ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "vtkRenderer.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkVolume16Reader.h" #include "vtkPolyDataMapper.h" #include "vtkActor.h" #include "vtkOutlineFilter.h" #include "vtkCamera.h" #include "vtkProperty.h" #include "vtkPolyDataNormals.h" #include "vtkContourFilter.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void readNconvertFiles () { printf("START readNconvertFiles()\n"); // read fMRI sequence vtkImageReader2 *fMRI_reader = vtkImageReader2::New(); fMRI_reader->SetFileName("rawData/case1_fMRI.raw"); fMRI_reader->SetFileDimensionality(3); fMRI_reader->SetDataExtent(0,63,0,63,0,35); fMRI_reader->SetDataSpacing(1, 1, 1); fMRI_reader->SetDataByteOrderToLittleEndian(); fMRI_reader->SetDataScalarTypeToUnsignedShort(); fMRI_reader->Update(); fMRI_reader->UpdateWholeExtent(); printf("case1_fMRI.raw reading... done\n"); // read fMRI t-map sequence vtkImageReader *fMRI_tMAP_reader = vtkImageReader::New(); fMRI_tMAP_reader->SetFileName("case1_fMRI_tMAP.raw"); fMRI_tMAP_reader->SetFileDimensionality(3); fMRI_tMAP_reader->SetDataExtent(0,63,0,63,0,35); fMRI_tMAP_reader->SetDataSpacing(1, 1, 1); fMRI_tMAP_reader->SetDataByteOrderToLittleEndian(); fMRI_tMAP_reader->SetDataScalarTypeToFloat(); fMRI_tMAP_reader->Update(); fMRI_tMAP_reader->UpdateWholeExtent(); printf("case1_fMRI_tMAP.raw reading... done\n"); // read DTI (diffusion weighted images) sequence vtkImageReader *DTI_reader = vtkImageReader::New(); DTI_reader->SetFileName("rawData/case1_DTI.raw"); DTI_reader->SetFileDimensionality(3); DTI_reader->SetDataExtent(0,127,0,127,0,71); DTI_reader->SetDataSpacing(1, 1, 1); DTI_reader->SetDataByteOrderToLittleEndian(); DTI_reader->SetDataScalarTypeToUnsignedShort(); DTI_reader->Update(); DTI_reader->UpdateWholeExtent(); // read T1 post contrast, N3 intensity corrected sequence vtkImageReader *T1_post_reader = vtkImageReader::New(); T1_post_reader->SetFileName("rawData/case1_T1_post.raw"); T1_post_reader->SetFileDimensionality(3); T1_post_reader->SetDataExtent(0,511,0,511,0,175); T1_post_reader->SetDataSpacing(1, 1, 1); T1_post_reader->SetDataByteOrderToLittleEndian(); T1_post_reader->SetDataScalarTypeToUnsignedShort(); T1_post_reader->Update(); T1_post_reader->UpdateWholeExtent(); printf("case1_T1_post.raw reading... done\n"); // read Tumor segmentation sequence vtkImageReader *T1_post_tumormask_reader = vtkImageReader::New(); T1_post_tumormask_reader->SetFileName("rawData/case1_T1_post_tumormask.raw"); T1_post_tumormask_reader->SetFileDimensionality(3); T1_post_tumormask_reader->SetDataExtent(0,43,0,42,0,18); T1_post_tumormask_reader->SetDataSpacing(1, 1, 1); T1_post_tumormask_reader->SetDataByteOrderToLittleEndian(); T1_post_tumormask_reader->SetDataScalarTypeToUnsignedChar(); T1_post_tumormask_reader->Update(); T1_post_tumormask_reader->UpdateWholeExtent(); printf("case1_T1_post_tumormask.raw reading... done\n"); // read Brain mask based on pre contrast T1 sequence vtkImageReader *T1_pre_brainmask_reader = vtkImageReader::New(); T1_pre_brainmask_reader->SetFileName("rawData/case1_T1_pre_brainmask.raw"); T1_pre_brainmask_reader->SetFileDimensionality(3); T1_pre_brainmask_reader->SetDataExtent(0,511,0,511,0,175); T1_pre_brainmask_reader->SetDataSpacing(1, 1, 1); T1_pre_brainmask_reader->SetDataByteOrderToLittleEndian(); T1_pre_brainmask_reader->SetDataScalarTypeToUnsignedChar(); T1_pre_brainmask_reader->Update(); T1_pre_brainmask_reader->UpdateWholeExtent(); printf("case1_pre_brainmask.raw reading... done\n"); // read T1 pre-contrast, N3 intensity corrected sequence vtkImageReader *T1_pre_reader = vtkImageReader::New(); T1_pre_reader->SetFileName("rawData/case1_T1_pre.raw"); T1_pre_reader->SetFileDimensionality(3); T1_pre_reader->SetDataExtent(0,511,0,511,0,175); T1_pre_reader->SetDataSpacing(1, 1, 1); T1_pre_reader->SetDataByteOrderToLittleEndian(); T1_pre_reader->SetDataScalarTypeToUnsignedShort(); T1_pre_reader->Update(); T1_pre_reader->UpdateWholeExtent(); printf("case1_T1_pre_reader.raw reading... done\n"); // read FLAIR sequence vtkImageReader *FLAIR_reader = vtkImageReader::New(); FLAIR_reader->SetFileName("rawData/case1_FLAIR.raw"); FLAIR_reader->SetFileDimensionality(3); FLAIR_reader->SetDataExtent(0,431,0,511,0,23); FLAIR_reader->SetDataSpacing(1, 1, 1); FLAIR_reader->SetDataByteOrderToLittleEndian(); FLAIR_reader->SetDataScalarTypeToUnsignedShort(); FLAIR_reader->Update(); FLAIR_reader->UpdateWholeExtent(); printf("case1_FLAIR.raw reading... done\n"); // read T2 sequence vtkImageReader *T2_reader = vtkImageReader::New(); T2_reader->SetFileName("rawData/case1_T2.raw"); T2_reader->SetFileDimensionality(3); T2_reader->SetDataExtent(0,543,0,639,0,23); T2_reader->SetDataSpacing(1, 1, 1); T2_reader->SetDataByteOrderToLittleEndian(); T2_reader->SetDataScalarTypeToUnsignedShort(); T2_reader->Update(); T2_reader->UpdateWholeExtent(); printf("case1_T2.raw reading... done\n"); // read SWI sequence vtkImageReader *SWI_reader = vtkImageReader::New(); SWI_reader->SetFileName("rawData/case1_SWI.raw"); SWI_reader->SetFileDimensionality(3); SWI_reader->SetDataExtent(0,191,0,255,0,59); SWI_reader->SetDataSpacing(1, 1, 1); SWI_reader->SetDataByteOrderToLittleEndian(); SWI_reader->SetDataScalarTypeToUnsignedShort(); SWI_reader->Update(); SWI_reader->UpdateWholeExtent(); printf("case1_SWI.raw reading... done\n"); // fMRI vtkXMLImageDataWriter *fMRI_writer = vtkXMLImageDataWriter::New(); fMRI_writer->SetInputConnection(fMRI_reader->GetOutputPort()); fMRI_writer->SetFileName("tumor_fMRI.vti"); assert (1 == fMRI_writer->Write()); fMRI_writer->Update(); // fMRI t-map vtkXMLImageDataWriter *fMRI_tMAP_writer = vtkXMLImageDataWriter::New(); fMRI_tMAP_writer->SetInputConnection(fMRI_tMAP_reader->GetOutputPort()); fMRI_tMAP_writer->SetFileName("tumor_fMRI_tMAP.vti"); assert (1 == fMRI_tMAP_writer->Write()); fMRI_tMAP_writer->Update(); // DTI vtkXMLImageDataWriter *DTI_writer = vtkXMLImageDataWriter::New(); DTI_writer->SetInputConnection(DTI_reader->GetOutputPort()); DTI_writer->SetFileName("tumor_DTI.vti"); assert (1 == DTI_writer->Write()); DTI_writer->Update(); // vtkTIFFWriter *DTI_writer2 = vtkTIFFWriter::New(); // DTI_writer2->SetInputConnection(DTI_reader->GetOutputPort()); // DTI_writer2->SetFileName("tumor_DTI.tif"); // DTI_writer2->Write(); // DTI_writer2->Update(); // T1 post contrast vtkXMLImageDataWriter *T1_post_writer = vtkXMLImageDataWriter::New(); T1_post_writer->SetInputConnection(T1_post_reader->GetOutputPort()); T1_post_writer->SetFileName("tumor_T1_post.vti"); assert (1 == T1_post_writer->Write()); T1_post_writer->Update(); // vtkTIFFWriter *T1_post_writer2 = vtkTIFFWriter::New(); // T1_post_writer2->SetInputConnection(T1_post_reader->GetOutputPort()); // T1_post_writer2->SetFileName("tumor_T1_post.tif"); // T1_post_writer2->Write(); // T1_post_writer2->Update(); // Tumor segmentation vtkXMLImageDataWriter *T1_post_tumormask_writer = vtkXMLImageDataWriter::New(); T1_post_tumormask_writer->SetInputConnection(T1_post_tumormask_reader->GetOutputPort()); T1_post_tumormask_writer->SetFileName("tumor_T1_post_tumormask.vti"); assert (1 == T1_post_tumormask_writer->Write()); T1_post_tumormask_writer->Update(); // vtkTIFFWriter *T1_post_tumormask_writer2 = vtkTIFFWriter::New(); // T1_post_tumormask_writer2->SetInputConnection(T1_post_tumormask_reader->GetOutputPort()); // T1_post_tumormask_writer2->SetFileName("tumor_T1_post_tumormask.tif"); // T1_post_tumormask_writer2->Write(); // T1_post_tumormask_writer2->Update(); // Brain mask based on pre contrast vtkXMLImageDataWriter *T1_pre_brainmask_writer = vtkXMLImageDataWriter::New(); T1_pre_brainmask_writer->SetInputConnection(T1_pre_brainmask_reader->GetOutputPort()); T1_pre_brainmask_writer->SetFileName("tumor_T1_pre_brainmask.vti"); assert (1 == T1_pre_brainmask_writer->Write()); T1_pre_brainmask_writer->Update(); // vtkTIFFWriter *T1_pre_brainmask_writer2 = vtkTIFFWriter::New(); // T1_pre_brainmask_writer2->SetInputConnection(T1_pre_brainmask_reader->GetOutputPort()); // T1_pre_brainmask_writer2->SetFileName("tumor_T1_pre_brainmask.tif"); // T1_pre_brainmask_writer2->Write(); // T1_pre_brainmask_writer2->Update(); // T1 pre contrast vtkXMLImageDataWriter *T1_pre_writer = vtkXMLImageDataWriter::New(); T1_pre_writer->SetInputConnection(T1_pre_reader->GetOutputPort()); T1_pre_writer->SetFileName("tumor_T1_pre.vti"); assert (1 == T1_pre_writer->Write()); T1_pre_writer->Update(); // vtkTIFFWriter *T1_pre_writer2 = vtkTIFFWriter::New(); // T1_pre_writer2->SetInputConnection(T1_pre_reader->GetOutputPort()); // T1_pre_writer2->SetFileName("tumor_T1_pre.tif"); // T1_pre_writer2->Write(); // T1_pre_writer2->Update(); // FLAIR vtkXMLImageDataWriter *FLAIR_writer = vtkXMLImageDataWriter::New(); FLAIR_writer->SetInputConnection(FLAIR_reader->GetOutputPort()); FLAIR_writer->SetFileName("tumor_FLAIR.vti"); assert (1 == FLAIR_writer->Write()); FLAIR_writer->Update(); // vtkTIFFWriter *FLAIR_writer2 = vtkTIFFWriter::New(); // FLAIR_writer2->SetInputConnection(FLAIR_reader->GetOutputPort()); // FLAIR_writer2->SetFileName("tumor_FLAIR.tif"); // FLAIR_writer2->Write(); // FLAIR_writer2->Update(); // T2 vtkXMLImageDataWriter *T2_writer = vtkXMLImageDataWriter::New(); T2_writer->SetInputConnection(T2_reader->GetOutputPort()); T2_writer->SetFileName("tumor_T2.vti"); assert (1 == T2_writer->Write()); T2_writer->Update(); // vtkTIFFWriter *T2_writer2 = vtkTIFFWriter::New(); // T2_writer2->SetInputConnection(T2_reader->GetOutputPort()); // T2_writer2->SetFileName("tumor_T2.tif"); // T2_writer2->Write(); // T2_writer2->Update(); // SWI vtkXMLImageDataWriter *SWI_writer = vtkXMLImageDataWriter::New(); SWI_writer->SetInputConnection(SWI_reader->GetOutputPort()); SWI_writer->SetFileName("tumor_SWI.vti"); assert (1 == SWI_writer->Write()); SWI_writer->Update(); // vtkTIFFWriter *SWI_writer2 = vtkTIFFWriter::New(); // SWI_writer2->SetInputConnection(SWI_reader->GetOutputPort()); // SWI_writer2->SetFileName("tumor_SWI.tif"); // SWI_writer2->Write(); // SWI_writer2->Update(); } int main(int argc, char **argv) { readNconvertFiles(); int val; sscanf(argv[1],"%d", &val); // Create the renderer, the render window, and the interactor. The renderer // draws into the render window, the interactor enables mouse- and // keyboard-based interaction with the data within the render window. // vtkRenderer *aRenderer = vtkRenderer::New(); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(aRenderer); vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); // read T2 sequence vtkImageReader *T2_reader = vtkImageReader::New(); T2_reader->SetFileName("case1_FLAIR.raw"); T2_reader->SetFileDimensionality(3); //T2_reader->SetDataExtent(0,511,0,511,0,175); T2_reader->SetDataExtent(0,431,0,511,0,23); T2_reader->SetDataSpacing(1, 1, 1); T2_reader->SetDataByteOrderToLittleEndian(); T2_reader->SetDataScalarTypeToUnsignedShort(); T2_reader->Update(); T2_reader->UpdateWholeExtent(); printf("case1_FLAIR.raw reading... done\n"); // pointer to the image data vtkImageData *pData; pData = T2_reader->GetOutput(); double max = -1.0; // find the max value for (int i=0; iGetNumberOfPoints(); i++) { double val = pData->GetPointData()->GetArray(0)->GetTuple1(i); double *index = pData->GetPoint(i); if (val > max) max = val; } printf("Max value %f\n", max); vtkXMLImageDataWriter *writer = vtkXMLImageDataWriter::New(); // map the data point to a grid. // grids dimensions same as data dimensions vtkImageData *Grid = vtkImageData::New(); Grid->SetOrigin(0, 0, 0); //Grid->SetDimensions(512,512,176); Grid->SetDimensions(432, 512, 24); Grid->SetSpacing(1, 1, 1); vtkDataArray *color; color = color->CreateDataArray(VTK_INT); color->SetNumberOfComponents(1); color->SetNumberOfTuples(Grid->GetNumberOfPoints()); color->SetName("color"); Grid->GetPointData()->AddArray(color); for (int i=0; iGetNumberOfPoints(); i++) { color->SetTuple1(i, 0); } // tried to use a simple translation function for (int i=0; iGetNumberOfPoints(); i++) { double val = pData->GetPointData()->GetArray(0)->GetTuple1(i); if (val > 600.0) val = 600.0; if (val < 300.0) val = 0.0; color->SetTuple1(i,val); } assert(0 == Grid->CheckAttributes()); writer->SetInputConnection(0, Grid->GetProducerPort()); writer->SetFileName("flair2.vti"); assert (1 == writer->Write()); printf("flair2.vti was written to disk\n"); if (val==0) { vtkLookupTable *table = vtkLookupTable::New(); table->SetSaturationRange(0,0); table->SetRange(0, (double)max); table->SetRampToLinear(); table->SetValueRange(0.0, 1.0); table->Build(); vtkImageMapToColors *color = vtkImageMapToColors::New(); color->SetInput(pData); color->SetLookupTable(table); color->SetInputConnection(T2_reader->GetOutputPort()); vtkPiecewiseFunction *opacityTransferFunction=vtkPiecewiseFunction::New(); double *range = opacityTransferFunction->GetRange(); printf("range %f %f\n", range[0], range[1]); opacityTransferFunction->AddPoint(0,0.0); opacityTransferFunction->AddPoint(330,1.0); opacityTransferFunction->AddPoint(531,0.7); range = opacityTransferFunction->GetRange(); printf("range %f %f\n", range[0], range[1]); vtkColorTransferFunction *colorTransferFunction = vtkColorTransferFunction::New(); //bones are white colorTransferFunction->AddRGBPoint(0,1.0,1.0,1.0); colorTransferFunction->AddRGBPoint(1,1.0,1.0,1.0); vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New(); volumeProperty->SetColor(colorTransferFunction); volumeProperty->SetScalarOpacity(opacityTransferFunction); volumeProperty->SetInterpolationTypeToLinear(); vtkVolumeRayCastCompositeFunction *compositeFunction = vtkVolumeRayCastCompositeFunction::New(); vtkVolumeRayCastMapper *volumeMapper=vtkVolumeRayCastMapper::New(); volumeMapper->SetVolumeRayCastFunction(compositeFunction); volumeMapper->SetInputConnection(color->GetOutputPort()); vtkVolume *volume=vtkVolume::New(); volume->SetMapper(volumeMapper); volume->SetProperty(volumeProperty); // An outline provides context around the data. vtkOutlineFilter *outlineData = vtkOutlineFilter::New(); outlineData->SetInputConnection(T2_reader->GetOutputPort()); vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New(); mapOutline->SetInputConnection(outlineData->GetOutputPort()); vtkActor *outline = vtkActor::New(); outline->SetMapper(mapOutline); outline->GetProperty()->SetColor(0,0,1); // An initial view of the data. The FocalPoint // and Position form a vector direction. Later on (ResetCamera() method) // this vector is used to position the camera to look at the data in // this direction. vtkCamera *aCamera = vtkCamera::New(); aCamera->SetViewUp (0, 0, 0); aCamera->SetPosition (0, 0, 1); aCamera->SetFocalPoint (0,0, 0); aCamera->ComputeViewPlaneNormal(); aCamera->Roll(180.0); // Actors are added to the renderer. An initial camera view is created. // The Dolly() method moves the camera towards the FocalPoint, // thereby enlarging the image. aRenderer->AddActor(outline); aRenderer->AddVolume(volume); aRenderer->SetActiveCamera(aCamera); aRenderer->ResetCamera (); aCamera->Dolly(1.5); // Set a background color for the renderer and set the size of the // render window (expressed in pixels). aRenderer->SetBackground(1,1,1); renWin->SetSize(640, 480); aRenderer->Render(); aRenderer->ResetCameraClippingRange (); // Initialize the event loop and then start it. iren->Initialize(); iren->Start(); } else if (val==1) // isosurfaces { // I don't know an isosurface, or contour value that corresponds to grey // matter or tumor value. Once generated, a vtkPolyDataNormals filter is // is used to create normals for smooth surface shading during rendering. vtkContourFilter *greyMatterExtractor = vtkContourFilter::New(); greyMatterExtractor->SetInputConnection(T2_reader->GetOutputPort()); greyMatterExtractor->SetValue(0, 1000); // for smooth shading vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New(); skinNormals->SetInputConnection(greyMatterExtractor->GetOutputPort()); skinNormals->SetFeatureAngle(60.0); vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New(); skinMapper->SetInputConnection(greyMatterExtractor->GetOutputPort()); skinMapper->ScalarVisibilityOff(); vtkActor *skin = vtkActor::New(); skin->SetMapper(skinMapper); skin->GetProperty()->SetColor(1,0,0); vtkContourFilter *brainExtractor = vtkContourFilter::New(); brainExtractor->SetInputConnection(T2_reader->GetOutputPort()); brainExtractor->SetValue(0, 400); vtkPolyDataMapper *brainMapper = vtkPolyDataMapper::New(); brainMapper->SetInputConnection(brainExtractor->GetOutputPort()); brainMapper->ScalarVisibilityOff(); vtkActor *brain = vtkActor::New(); brain->SetMapper(brainMapper); brain->GetProperty()->SetColor(0,1,0); vtkContourFilter *isoExtractor = vtkContourFilter::New(); isoExtractor->SetInputConnection(T2_reader->GetOutputPort()); isoExtractor->SetValue(0, 300); vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New(); isoMapper->SetInputConnection(isoExtractor->GetOutputPort()); isoMapper->ScalarVisibilityOff(); vtkActor *isoSurf = vtkActor::New(); isoSurf->SetMapper(isoMapper); isoSurf->GetProperty()->SetColor(0,0,1); // An outline provides context around the data. // vtkOutlineFilter *outlineData = vtkOutlineFilter::New(); outlineData->SetInputConnection(T2_reader->GetOutputPort()); vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New(); mapOutline->SetInputConnection(outlineData->GetOutputPort()); vtkActor *outline = vtkActor::New(); outline->SetMapper(mapOutline); outline->GetProperty()->SetColor(0,0,1); // It is convenient to create an initial view of the data. The FocalPoint // and Position form a vector direction. Later on (ResetCamera() method) // this vector is used to position the camera to look at the data in // this direction. vtkCamera *aCamera = vtkCamera::New(); aCamera->SetViewUp (0, 0, 0); aCamera->SetPosition (0, 0, 1); aCamera->SetFocalPoint (0,0, 0); aCamera->ComputeViewPlaneNormal(); aCamera->Roll(180.0); // Actors are added to the renderer. An initial camera view is created. // The Dolly() method moves the camera towards the FocalPoint, // thereby enlarging the image. aRenderer->AddActor(outline); aRenderer->AddActor(skin); aRenderer->AddActor(brain); aRenderer->AddActor(isoSurf); aRenderer->SetActiveCamera(aCamera); aRenderer->ResetCamera (); aCamera->Dolly(1.5); // Set a background color for the renderer and set the size of the // render window (expressed in pixels). aRenderer->SetBackground(1,1,1); renWin->SetSize(640, 480); // Note that when camera movement occurs (as it does in the Dolly() // method), the clipping planes often need adjusting. Clipping planes // consist of two planes: near and far along the view direction. The // near plane clips out objects in front of the plane; the far plane // clips out objects behind the plane. This way only what is drawn // between the planes is actually rendered. aRenderer->ResetCameraClippingRange (); // Initialize the event loop and then start it. iren->Initialize(); iren->Start(); } else if (val==2) // color map { vtkLookupTable *lut = vtkLookupTable::New(); lut->SetNumberOfColors(256); lut->SetHueRange(0.0,0.6777); lut->SetSaturationRange(.5, 1.0); lut->Build(); vtkDataSetMapper *mapper = vtkDataSetMapper::New(); mapper->SetInputConnection(T2_reader->GetOutputPort()); mapper->SetLookupTable(lut); mapper->SetScalarRange(0.0, (double)max); vtkActor *actors = vtkActor::New(); actors->SetMapper(mapper); vtkOutlineFilter *outlineData = vtkOutlineFilter::New(); outlineData->SetInputConnection(T2_reader->GetOutputPort()); vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New(); mapOutline->SetInputConnection(outlineData->GetOutputPort()); vtkActor *outline = vtkActor::New(); outline->SetMapper(mapOutline); // outline->GetProperty()->SetColor(1,1,1); vtkCamera *aCamera = vtkCamera::New(); aCamera->SetViewUp (0, 0, 0); aCamera->SetPosition (0, 0, 1); aCamera->SetFocalPoint (0, 0, 0); aCamera->ComputeViewPlaneNormal(); aCamera->Roll(180.0); aRenderer->AddActor(outline); aRenderer->AddActor(actors); aRenderer->SetActiveCamera(aCamera); aRenderer->ResetCamera(); aCamera->Dolly(1.5); aRenderer->SetBackground(1,1,1); renWin->SetSize(640, 480); aRenderer->ResetCameraClippingRange (); // Initialize the event loop and then start it. iren->Initialize(); iren->Start(); } else if (val==3) // diffusion color { vtkLookupTable *lut = vtkLookupTable::New(); lut->SetNumberOfColors(256); lut->SetHueRange(0.0,1.0); lut->SetSaturationRange(.0, 1.0); lut->SetValueRange(0.1,1.0); lut->SetAlpha(0.9); lut->Build(); vtkDataSetMapper *mapper = vtkDataSetMapper::New(); mapper->SetLookupTable(lut); mapper->SetInput(T2_reader->GetOutput()); mapper->SetScalarRange(0.0, 600.0); vtkActor *actor = vtkActor::New(); actor->SetMapper(mapper); actor->GetProperty()->SetDiffuseColor(1, 0.49, .25); vtkOutlineFilter *outlineData = vtkOutlineFilter::New(); outlineData->SetInputConnection(T2_reader->GetOutputPort()); vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New(); mapOutline->SetInputConnection(outlineData->GetOutputPort()); vtkActor *outline = vtkActor::New(); outline->SetMapper(mapOutline); outline->GetProperty()->SetColor(0,0,1); vtkCamera *aCamera = vtkCamera::New(); aCamera->SetViewUp (0, 0, 0); aCamera->SetPosition (0, 0, 1); aCamera->SetFocalPoint (0,0, 0); aCamera->ComputeViewPlaneNormal(); aCamera->Roll(180.0); aRenderer->AddActor(outline); aRenderer->AddActor(actor); aRenderer->SetActiveCamera(aCamera); aRenderer->ResetCamera (); aCamera->Dolly(1.5); aRenderer->SetBackground(1,1,1); renWin->SetSize(640, 480); aRenderer->ResetCameraClippingRange (); // Initialize the event loop and then start it. iren->Initialize(); iren->Start(); } return 0; }