<div>Hello again. I hope it is okay i send all these questions...this program is causing me some problems. I have read on google and in the userguide, but i was not able to find any explanation to how it is possible to put now data into the contourfilter, and rerender this every time a certain key is pressed. I managed to create a vtkCallbackcommand and us this. This works fine, and i can write to the std::cout whenever a key is pressed and do some action. I made a callbackfunction.
</div>
<div>void callbackMethod(vtkObject *caller, unsigned long eventID, void* clientData,void* data){...}</div>
<div>which is called everytime a key is pressed. Wonderful.</div>
<div> </div>
<div>Now, what i want to do is to take my data, manipulate them everytime a key is pressed, and then show these on the screen instead. But when i put the new data into my objects, a pointer exception occurs (as always). I dont understand why this occurs, and I hope somebody can help me. I have copied my program, i know its quite a long code, but the reason for this is that i have 12 different actors that i need to render, and a pipeline with different data for each actor.
</div>
<div> </div>
<div>So my question is: How do i change the data of the contourfilter and rerender it on the fly(while program is running): A very short pseudo code of what i am doing is the following</div>
<div> </div>
<div>1. load files</div>
<div>2. import files: binary->vnl->itk->vtk</div>
<div>3. find zerocrossings in data and create isosurfaces for rendering using vtkContourFilter</div>
<div>4. Setup Commandobjekt for keyboardevents</div>
<div>5. render</div>
<div>6. onclick: use vnl to manipulate data from binary files (this creating different volumes) to again import to vtk, use contourfilter and render isosurface. <---This is the point going wrong. See function void callbackMethod().
</div>
<div> </div>
<div>Thank you very much, and sorry for all the questions once again. I appreciate your help.</div>
<div> </div>
<div> </div>
<div>Program listing:</div>
<div> </div>
<div>
<p>#include <ctime><br>#include<cstdio><br>#include <fstream><br>#include <vtkImageData.h><br>#include "vtkImageImport.h" //Import images for VTK<br>#include "vtkActor.h"<br>#include "
vtkOutlineFilter.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderer.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkLight.h
"<br>#include "vtkCamera.h"<br>#include "vtkContourFilter.h"<br>#include "vtkProperty.h"<br>#include "vtkMarchingCubes.h"<br>#include "vtkWindowedSincPolyDataFilter.h"
<br>#include "vtkDataSetWriter.h"<br>#include "vtkCallbackCommand.h"<br>#include "vtkCommand.h"</p>
<p><br>#include "itkImportImageFilter.h"<br>#include "itkImage.h"<br>#include "itkImageRegionConstIterator.h"<br>#include "itkVTKImageExport.h"<br>#include "itkZeroCrossingImageFilter.h
"</p>
<p>#include<map><br>#include <blitz/Array.h><br>#include <vnl/vnl_matrix.h><br>#include <vnl/vnl_vector.h><br>#include <vnl/vnl_identity.h></p>
<p><br>typedef float SDMdatatype;<br>typedef unsigned short Binarytype;</p>
<p>typedef itk::Image<SDMdatatype,3> SDMimg;<br>typedef vnl_matrix<SDMdatatype> mat;<br>typedef itk::ImportImageFilter<SDMdatatype,3> ImportFilterType;<br>typedef itk::VTKImageExport<SDMimg> ImageExportType;
</p>
<p><br>ImportFilterType::Pointer dataPointer2itk(SDMdatatype* data);</p>
<p>int D[]={110,129,97};</p>
<p>unsigned int N=D[0]*D[1]*D[2];<br>unsigned short m=12; //Shape count<br>unsigned short sm=7; //Significant modes chosen<br>mat meanShape(N*m,1);<br>mat prinComp(N*m,sm);<br>mat prinVal(sm,1);<br>struct commandObj{
<br> ImportFilterType::Pointer importFilter1;<br> ImportFilterType::Pointer importFilter2;<br> ImportFilterType::Pointer importFilter3;<br> ImportFilterType::Pointer importFilter4;<br> ImportFilterType::Pointer importFilter5;
<br> ImportFilterType::Pointer importFilter6;<br> ImportFilterType::Pointer importFilter7;<br> ImportFilterType::Pointer importFilter8;<br> ImportFilterType::Pointer importFilter9;<br> ImportFilterType::Pointer importFilter10;
<br> ImportFilterType::Pointer importFilter11;<br> ImportFilterType::Pointer importFilter12;<br>};</p>
<p>void callbackMethod(vtkObject *caller, unsigned long eventID, void* clientData,void* data){<br> vtkRenderWindowInteractor *iren = reinterpret_cast<vtkRenderWindowInteractor*>(caller);<br> commandObj* cmdObj = reinterpret_cast<commandObj*> ( clientData ) ;
</p>
<p> mat m1=meanShape.extract(N,1, 0*N,0);<br> mat m2=meanShape.extract(N,1, 1*N,0);<br> mat m3=meanShape.extract(N,1, 2*N,0);<br> mat m4=meanShape.extract(N,1, 3*N,0);<br> mat m5=meanShape.extract(N,1, 4*N,0);<br> mat m6=
meanShape.extract(N,1, 5*N,0);<br> mat m7=meanShape.extract(N,1, 6*N,0);<br> mat m8=meanShape.extract(N,1, 7*N,0);<br> mat m9=meanShape.extract(N,1, 8*N,0);<br> mat m10=meanShape.extract(N,1, 9*N,0);<br> mat m11=meanShape.extract
(N,1, 10*N,0);<br> mat m12=meanShape.extract(N,1, 11*N,0);</p>
<p> cmdObj->importFilter1->SetImportPointer(m1.data_block(),N,true);<br> cmdObj->importFilter2->SetImportPointer(m2.data_block(),N,true);<br> cmdObj->importFilter3->SetImportPointer(m3.data_block(),N,true);
<br> cmdObj->importFilter4->SetImportPointer(m4.data_block(),N,true);<br> cmdObj->importFilter5->SetImportPointer(m5.data_block(),N,true);<br> cmdObj->importFilter6->SetImportPointer(m6.data_block(),N,true);
<br> cmdObj->importFilter7->SetImportPointer(m7.data_block(),N,true);<br> cmdObj->importFilter8->SetImportPointer(m8.data_block(),N,true);<br> cmdObj->importFilter9->SetImportPointer(m9.data_block(),N,true);
<br> cmdObj->importFilter10->SetImportPointer(m10.data_block(),N,true);<br> cmdObj->importFilter11->SetImportPointer(m11.data_block(),N,true);<br> cmdObj->importFilter12->SetImportPointer(m12.data_block(),N,true);
</p>
<p> std::cout<<"rendering..."<<std::endl;<br> iren->Render();<br> std::cout<<"rendering done"<<std::endl;<br>}</p>
<p>/**<br> * This function will connect the given vtkImageExport filter to<br> * the given itk::VTKImageImport filter.<br> */<br>//template <typename VTK_Exporter, typename ITK_Importer><br>void ConnectPipelines(ImageExportType* exporter, vtkImageImport* importer)
<br>{<br> importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());<br> importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());<br> importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
<br> importer->SetSpacingCallback(exporter->GetSpacingCallback());<br> importer->SetOriginCallback(exporter->GetOriginCallback());<br> importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
<br> importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());<br> importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());<br> importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
<br> importer->SetDataExtentCallback(exporter->GetDataExtentCallback());<br> importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());<br> importer->SetCallbackUserData(exporter->GetCallbackUserData());
<br>}</p>
<p>SDMdatatype* readArrayFromFile(char* fn,long size){<br> std::ifstream file;<br> file.open(fn,std::ios::in|std::ios::binary);<br> if (!file) { printf("file was not opened, issue error msg"); }<br> SDMdatatype* buffer;
<br> buffer = new SDMdatatype[size];<br> file.read(reinterpret_cast<char*>(buffer), sizeof (SDMdatatype) * size);//static_cast <char *> buffer<br> file.close();<br> return buffer;<br>}<br>// Import data from a pointer into an itkImportFilter
<br>ImportFilterType::Pointer dataPointer2itk(SDMdatatype* data){<br> ImportFilterType::Pointer importFilter = ImportFilterType::New();<br> ImportFilterType::SizeType size;<br> double origin[3];<br> double spacing[3];<br>
size[0] = D[0]; // size along X<br> size[1] = D[1]; // size along Y<br> size[2] = D[2]; // size along Z<br> origin[0] = 0.0; // X coordinate <br> origin[1] = 0.0; // Y coordinate<br> origin[2] = 0.0; // Z coordinate
<br> spacing[0] = 1.0; // along X direction <br> spacing[1] = 1.0; // along Y direction<br> spacing[2] = 1.0; // along Z direction<br> ImportFilterType::IndexType start;<br> start.Fill( 0 );<br> ImportFilterType::RegionType region;
<br> region.SetIndex( start );<br> region.SetSize( size );<br> importFilter->SetRegion( region );<br> importFilter->SetOrigin( origin );<br> importFilter->SetSpacing( spacing );<br> importFilter->SetImportPointer(data,N,true);
<br> return importFilter;<br>}<br>void loadPCAResults(){<br> SDMdatatype* b1=readArrayFromFile(<br> "C:\\thesisIntermediate\\meanshape.dat",<br> N*m);<br> meanShape.copy_in(b1);<br> delete b1;</p>
<p> SDMdatatype* b2=readArrayFromFile(<br> "C:\\thesisIntermediate\\prinComp.dat",<br> N*m*sm);<br> prinComp.copy_in(b2);<br> delete b2; </p>
<p> SDMdatatype* b3=readArrayFromFile(<br> "C:\\thesisIntermediate\\prinVal.dat",<br> sm);<br> prinVal.copy_in(b3);<br> delete b3;</p>
<p>}</p>
<p>mat ColVecElemWiseMult(mat A,SDMdatatype* B){<br> for(short i=0;i<A.size();i++) A(i,0)=B[i]*A(i,0);<br> return A;<br>}<br>int main(int argc,char* argv[])<br>{<br> double elapsedTime;<br> clock_t begin, end; <br> begin = clock();
<br> loadPCAResults();<br> end = clock();<br> begin = clock();</p>
<p> //mat A(3,3);<br> //meanShape.set_identity();<br> //A*=(A*2);<br> //A*=(A*2);<br> //meanShape=meanShape.e*meanShape;<br> //std::cout<<meanShape<<std::endl;<br> //meanShape+prinComp*(prinVal*)</p>
<p> // Get vols from SDM<br> //extract(højde,bredde,top,left)<br> mat m1=meanShape.extract(N,1, 0*N,0);<br> mat m2=meanShape.extract(N,1, 1*N,0);<br> mat m3=meanShape.extract(N,1, 2*N,0);<br> mat m4=meanShape.extract(N,1, 3*N,0);
<br> mat m5=meanShape.extract(N,1, 4*N,0);<br> mat m6=meanShape.extract(N,1, 5*N,0);<br> mat m7=meanShape.extract(N,1, 6*N,0);<br> mat m8=meanShape.extract(N,1, 7*N,0);<br> mat m9=meanShape.extract(N,1, 8*N,0);<br> mat m10=
meanShape.extract(N,1, 9*N,0);<br> mat m11=meanShape.extract(N,1, 10*N,0);<br> mat m12=meanShape.extract(N,1, 11*N,0);<br> //////////////////////////////////////////////////////////////////////////////////<br> // Create objects for use //
<br> //////////////////////////////////////////////////////////////////////////////////</p>
<p> //structure actors<br> vtkActor *Temporopolar_region_left_actor = vtkActor::New();<br> vtkActor *Temporopolar_region_right_actor = vtkActor::New();<br> vtkActor *Entorhinal_region_left_actor = vtkActor::New();<br>
vtkActor *Entorhinal_region_right_actor = vtkActor::New();<br> vtkActor *Perirhinal_region_left_actor = vtkActor::New();<br> vtkActor *Perirhinal_region_right_actor = vtkActor::New();<br> vtkActor *Parahippocampal_region_left_actor = vtkActor::New();
<br> vtkActor *Parahippocampal_region_right_actor = vtkActor::New();<br> vtkActor *Hippocampal_region_left_actor = vtkActor::New();<br> vtkActor *Hippocampal_region_right_actor = vtkActor::New();<br> vtkActor *Amygdalar_region_left_actor = vtkActor::New();
<br> vtkActor *Amygdalar_region_right_actor = vtkActor::New();</p>
<p> //Bounding box<br> vtkOutlineFilter *outlineData = vtkOutlineFilter::New();<br> vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();<br> vtkActor *outline = vtkActor::New();</p>
<p> //rendering objects<br> vtkRenderer *aRenderer = vtkRenderer::New();<br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br> vtkCamera *aCamera = vtkCamera::New();
</p>
<p> </p>
<p> ImportFilterType::Pointer importFilter1=dataPointer2itk(m1.data_block());<br> ImportFilterType::Pointer importFilter2=dataPointer2itk(m2.data_block());<br> ImportFilterType::Pointer importFilter3=dataPointer2itk(m3.data_block
());<br> ImportFilterType::Pointer importFilter4=dataPointer2itk(m4.data_block());<br> ImportFilterType::Pointer importFilter5=dataPointer2itk(m5.data_block());<br> ImportFilterType::Pointer importFilter6=dataPointer2itk(
m6.data_block());<br> ImportFilterType::Pointer importFilter7=dataPointer2itk(m7.data_block());<br> ImportFilterType::Pointer importFilter8=dataPointer2itk(m8.data_block());<br> ImportFilterType::Pointer importFilter9=dataPointer2itk(
m9.data_block());<br> ImportFilterType::Pointer importFilter10=dataPointer2itk(m10.data_block());<br> ImportFilterType::Pointer importFilter11=dataPointer2itk(m11.data_block());<br> ImportFilterType::Pointer importFilter12=dataPointer2itk(
m12.data_block());<br> <br> vtkImageImport* vtkImporter1 = vtkImageImport::New();<br> vtkImageImport* vtkImporter2 = vtkImageImport::New();<br> vtkImageImport* vtkImporter3 = vtkImageImport::New();<br> vtkImageImport* vtkImporter4 = vtkImageImport::New();
<br> vtkImageImport* vtkImporter5 = vtkImageImport::New();<br> vtkImageImport* vtkImporter6 = vtkImageImport::New();<br> vtkImageImport* vtkImporter7 = vtkImageImport::New();<br> vtkImageImport* vtkImporter8 = vtkImageImport::New();
<br> vtkImageImport* vtkImporter9 = vtkImageImport::New();<br> vtkImageImport* vtkImporter10 = vtkImageImport::New();<br> vtkImageImport* vtkImporter11 = vtkImageImport::New();<br> vtkImageImport* vtkImporter12 = vtkImageImport::New();
</p>
<p> ImageExportType::Pointer itkExporter1 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter2 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter3 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter4 = ImageExportType::New();
<br> ImageExportType::Pointer itkExporter5 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter6 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter7 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter8 = ImageExportType::New();
<br> ImageExportType::Pointer itkExporter9 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter10 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter11 = ImageExportType::New();<br> ImageExportType::Pointer itkExporter12 = ImageExportType::New();
</p>
<p> itkExporter1->SetInput(importFilter1->GetOutput());<br> itkExporter2->SetInput(importFilter2->GetOutput());<br> itkExporter3->SetInput(importFilter3->GetOutput());<br> itkExporter4->SetInput(importFilter4->GetOutput());
<br> itkExporter5->SetInput(importFilter5->GetOutput());<br> itkExporter6->SetInput(importFilter6->GetOutput());<br> itkExporter7->SetInput(importFilter7->GetOutput());<br> itkExporter8->SetInput(importFilter8->GetOutput());
<br> itkExporter9->SetInput(importFilter9->GetOutput());<br> itkExporter10->SetInput(importFilter10->GetOutput());<br> itkExporter11->SetInput(importFilter11->GetOutput());<br> itkExporter12->SetInput(importFilter12->GetOutput());
<br> <br> ConnectPipelines(itkExporter1, vtkImporter1);<br> ConnectPipelines(itkExporter2, vtkImporter2);<br> ConnectPipelines(itkExporter3, vtkImporter3);<br> ConnectPipelines(itkExporter4, vtkImporter4);<br> ConnectPipelines(itkExporter5, vtkImporter5);
<br> ConnectPipelines(itkExporter6, vtkImporter6);<br> ConnectPipelines(itkExporter7, vtkImporter7);<br> ConnectPipelines(itkExporter8, vtkImporter8);<br> ConnectPipelines(itkExporter9, vtkImporter9);<br> ConnectPipelines(itkExporter10, vtkImporter10);
<br> ConnectPipelines(itkExporter11, vtkImporter11);<br> ConnectPipelines(itkExporter12, vtkImporter12);<br> <br> vtkPolyDataMapper *polyMapper1 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper2 = vtkPolyDataMapper::New();
<br> vtkPolyDataMapper *polyMapper3 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper4 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper5 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper6 = vtkPolyDataMapper::New();
<br> vtkPolyDataMapper *polyMapper7 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper8 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper9 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper10 = vtkPolyDataMapper::New();
<br> vtkPolyDataMapper *polyMapper11 = vtkPolyDataMapper::New();<br> vtkPolyDataMapper *polyMapper12 = vtkPolyDataMapper::New();</p>
<p> vtkContourFilter *contours1 = vtkContourFilter::New();<br> vtkContourFilter *contours2 = vtkContourFilter::New();<br> vtkContourFilter *contours3 = vtkContourFilter::New();<br> vtkContourFilter *contours4 = vtkContourFilter::New();
<br> vtkContourFilter *contours5 = vtkContourFilter::New();<br> vtkContourFilter *contours6 = vtkContourFilter::New();<br> vtkContourFilter *contours7 = vtkContourFilter::New();<br> vtkContourFilter *contours8 = vtkContourFilter::New();
<br> vtkContourFilter *contours9 = vtkContourFilter::New();<br> vtkContourFilter *contours10 = vtkContourFilter::New();<br> vtkContourFilter *contours11 = vtkContourFilter::New();<br> vtkContourFilter *contours12 = vtkContourFilter::New();
</p>
<p> outlineData->SetInput(vtkImporter1->GetOutput());<br> mapOutline->SetInput(outlineData->GetOutput());<br> outline->SetMapper(mapOutline);<br> outline->GetProperty()->SetColor(0.,0.,1.);</p>
<p> contours1->SetInput(vtkImporter1->GetOutput());<br> contours2->SetInput(vtkImporter2->GetOutput());<br> contours3->SetInput(vtkImporter3->GetOutput());<br> contours4->SetInput(vtkImporter4->GetOutput());
<br> contours5->SetInput(vtkImporter5->GetOutput());<br> contours6->SetInput(vtkImporter6->GetOutput());<br> contours7->SetInput(vtkImporter7->GetOutput());<br> contours8->SetInput(vtkImporter8->GetOutput());
<br> contours9->SetInput(vtkImporter9->GetOutput());<br> contours10->SetInput(vtkImporter10->GetOutput());<br> contours11->SetInput(vtkImporter11->GetOutput());<br> contours12->SetInput(vtkImporter12->GetOutput());
</p>
<p> contours1->SetValue(0,0);<br> contours2->SetValue(0,0);<br> contours3->SetValue(0,0);<br> contours4->SetValue(0,0);<br> contours5->SetValue(0,0);<br> contours6->SetValue(0,0);<br> contours7->SetValue(0,0);
<br> contours8->SetValue(0,0);<br> contours9->SetValue(0,0);<br> contours10->SetValue(0,0);<br> contours11->SetValue(0,0);<br> contours12->SetValue(0,0);</p>
<p> polyMapper1->SetInput(contours1->GetOutput());<br> polyMapper2->SetInput(contours2->GetOutput());<br> polyMapper3->SetInput(contours3->GetOutput());<br> polyMapper4->SetInput(contours4->GetOutput());
<br> polyMapper5->SetInput(contours5->GetOutput());<br> polyMapper6->SetInput(contours6->GetOutput());<br> polyMapper7->SetInput(contours7->GetOutput());<br> polyMapper8->SetInput(contours8->GetOutput());
<br> polyMapper9->SetInput(contours9->GetOutput());<br> polyMapper10->SetInput(contours10->GetOutput());<br> polyMapper11->SetInput(contours11->GetOutput());<br> polyMapper12->SetInput(contours12->GetOutput());
</p>
<p> polyMapper1->ScalarVisibilityOff();<br> polyMapper2->ScalarVisibilityOff();<br> polyMapper3->ScalarVisibilityOff();<br> polyMapper4->ScalarVisibilityOff();<br> polyMapper5->ScalarVisibilityOff();<br> polyMapper6->ScalarVisibilityOff();
<br> polyMapper7->ScalarVisibilityOff();<br> polyMapper8->ScalarVisibilityOff();<br> polyMapper9->ScalarVisibilityOff();<br> polyMapper10->ScalarVisibilityOff();<br> polyMapper11->ScalarVisibilityOff();<br>
polyMapper12->ScalarVisibilityOff();</p>
<p> Temporopolar_region_left_actor->SetMapper(polyMapper1);<br> Temporopolar_region_right_actor->SetMapper(polyMapper2);<br> Entorhinal_region_left_actor->SetMapper(polyMapper3);<br> Entorhinal_region_right_actor->SetMapper(polyMapper4);
<br> Perirhinal_region_left_actor->SetMapper(polyMapper5);<br> Perirhinal_region_right_actor->SetMapper(polyMapper6);<br> Parahippocampal_region_left_actor->SetMapper(polyMapper7);<br> Parahippocampal_region_right_actor->SetMapper(polyMapper8);
<br> Hippocampal_region_left_actor->SetMapper(polyMapper9);<br> Hippocampal_region_right_actor->SetMapper(polyMapper10);<br> Amygdalar_region_left_actor->SetMapper(polyMapper11);<br> Amygdalar_region_right_actor->SetMapper(polyMapper12);
<br> <br> Temporopolar_region_left_actor->GetProperty()-> SetColor(1,0,0);<br> Temporopolar_region_right_actor->GetProperty()-> SetColor(1,0,0);<br> Entorhinal_region_left_actor->GetProperty()-> SetColor(0,1,0);
<br> Entorhinal_region_right_actor->GetProperty()-> SetColor(0,1,0);<br> Perirhinal_region_left_actor->GetProperty()-> SetColor(0,0,1);<br> Perirhinal_region_right_actor->GetProperty()-> SetColor(0,0,1);
<br> Parahippocampal_region_left_actor->GetProperty()-> SetColor(1,0,1);<br> Parahippocampal_region_right_actor->GetProperty()-> SetColor(1,0,1);<br> Hippocampal_region_left_actor->GetProperty()-> SetColor(0,1,1);
<br> Hippocampal_region_right_actor->GetProperty()-> SetColor(0,1,1);<br> Amygdalar_region_left_actor->GetProperty()-> SetColor(1,1,0);<br> Amygdalar_region_right_actor->GetProperty()-> SetColor(1,1,0);
<br> </p>
<p> vtkCallbackCommand *callback = vtkCallbackCommand::New();<br> callback->SetCallback(callbackMethod);<br> commandObj* cmdObj=new commandObj;<br> callback->SetClientData(cmdObj);<br> iren->AddObserver(vtkCommand::KeyPressEvent,callback);
</p>
<p><br> // Actors are added to the renderer. <br> //aRenderer->AddActor(outline);<br> aRenderer->AddActor(Temporopolar_region_left_actor);<br> aRenderer->AddActor(Temporopolar_region_right_actor);<br> aRenderer->AddActor(Entorhinal_region_left_actor);
<br> aRenderer->AddActor(Entorhinal_region_right_actor);<br> aRenderer->AddActor(Perirhinal_region_left_actor);<br> aRenderer->AddActor(Perirhinal_region_right_actor);<br> aRenderer->AddActor(Parahippocampal_region_left_actor);
<br> aRenderer->AddActor(Parahippocampal_region_right_actor);<br> aRenderer->AddActor(Hippocampal_region_left_actor);<br> aRenderer->AddActor(Hippocampal_region_right_actor);<br> aRenderer->AddActor(Amygdalar_region_left_actor);
<br> aRenderer->AddActor(Amygdalar_region_right_actor);<br> aRenderer->AddActor(outline);<br> <br> aRenderer->SetBackground(0,0,0);<br> iren->SetRenderWindow(renWin);<br> renWin->AddRenderer(aRenderer);<br>
aRenderer->SetActiveCamera(aCamera);</p>
<p> // Setting the color and size of the renderwindow,<br> // initializing the camera position<br> aCamera->SetViewUp(0, 0, -1);<br> aCamera->SetPosition(-150, -150, -150);<br> aCamera->SetFocalPoint(0, 0, 0);<br>
aCamera->ComputeViewPlaneNormal();<br> aRenderer->ResetCamera();<br> aRenderer->ResetCameraClippingRange();<br> aRenderer->SetBackground(0.2, 0.2, 0.2);<br> renWin->SetSize(800, 600);</p>
<p> // Here we go!<br> iren->Initialize();<br> renWin->Render();<br> iren->Start();</p>
<p> end = clock();<br> elapsedTime = static_cast<double>(end - begin) / CLOCKS_PER_SEC;std::cout<<elapsedTime<<std::endl;<br> //////////////////////////////////////////////////////////////////////////////////
<br> // CLEAN UP //<br> //////////////////////////////////////////////////////////////////////////////////<br> <br> aCamera->Delete();<br> aRenderer->Delete();<br> renWin->Delete();<br> iren->Delete();
<br>}<br></p></div>