00001 #include "DefOrgAdapter_VesselCrawler.h" 00002 00003 extern "C" 00004 #ifdef _WIN32 00005 __declspec( dllexport ) 00006 #endif 00007 //DO NOT MODIFY THIS 00008 mial::DefOrgViewerAdapterBase* defOrgLoad() 00009 { 00010 return new mial::DefOrgAdapter_VesselCrawler(); 00011 } 00012 00013 00014 namespace mial{ 00015 DefOrgAdapter_VesselCrawler::DefOrgAdapter_VesselCrawler():DefOrgViewerAdapterBaseTemplated(MaxNumberOfOutputImages()){ 00016 /*Example 00017 //Expose a property called "Sigma" with selectable range 0 to 10. 00018 //The default value is 1, the resolution of the select scale is 0.1, and 00019 //a help message "Sigma for Gradient Sensor" 00020 AddOrganismProperty("Sigma",0,10,1.0,0.1,"Sigma for Gradient Sensor"); 00021 */ 00022 AddOrganismProperty("Sigma",0,10,1.0,0.1,"Sigma for Gradient Sensor"); 00023 m_OutputImages[0].windowName = "Main Window"; 00024 m_OutputImages[0].dimension = 3; 00025 00026 m_OutputImages[1].windowName = "Slice One"; 00027 m_OutputImages[1].dimension = 2; 00028 00029 m_OutputImages[2].windowName = "Slice Two"; 00030 m_OutputImages[2].dimension = 2; 00031 00032 //Create a vessel crawler 00033 crawler = VesselCrawlerType::New(); 00034 lock =0; 00035 } 00036 00037 00038 int DefOrgAdapter_VesselCrawler::MaxNumberOfOutputItkSpatialObjects(){ 00039 //Return the number of spatial object output this organism will have 00040 //In this case, 2 is returned, so the viewer will create 1 additional window 00041 //This first output will always be displayed in the primary window 00042 return 1; 00043 } 00044 00045 00046 unsigned int DefOrgAdapter_VesselCrawler::MaxNumberOfOutputImages(){ 00047 //Return the number of spatial object output this organism will have 00048 //In this case, 2 is returned, so the viewer will create 1 additional window 00049 //This first output will always be displayed in the primary window 00050 return 3; 00051 } 00052 00053 void DefOrgAdapter_VesselCrawler::HandleUserMouseInteraction(vtkTransform* userTransformation){ 00054 //To Do: Based on the userTransformation, update the internal data structure of the organism 00055 //The following example merely prints the transformation to acknowledge the organism 00056 //recieved the input. 00057 userTransformation->Print(std::cout); 00058 } 00059 00060 void DefOrgAdapter_VesselCrawler::PopulateItkScene(){ 00061 /* 00062 This method is called ONCE only when the user select a mesh from Load Mesh button. 00063 00064 When new information needs to be displayed in the viewer, the isModified 00065 field of the corresponding output must be set to true*/ 00066 itkScenePointer itkScene = m_OutputItkSpatialObjects[0].theItkScene; 00067 m_OutputItkSpatialObjects[0].isModified=true; 00068 //geomLayerPointer->readTopologyFromFile( m_MeshFileName ); 00069 00070 /*The spatial objects to be displayed should be added to the itkScene(s) supplied 00071 by the viewer. The number of itkScene supplied depends on MaxNumberOfOutputItkSpatialObjects()*/ 00072 00073 //To Do: Replace 0 with correct output 00074 itkScene->AddSpatialObject( 0 /*geomLayerPointer->theMeshSpatialObject*/); 00075 } 00076 00077 void DefOrgAdapter_VesselCrawler::PopulateVtkImage(){ 00078 /* 00079 This method is called ONCE only when the user select a mesh from Load Image button. 00080 00081 When new information needs to be displayed in the viewer, the isModified 00082 field of the corresponding output must be set to true*/ 00083 vtkImageImport* vtkImporter = m_OutputImages[0].theImageVolume; 00084 m_OutputImages[0].isModified=true; 00085 00086 vtkImageImport* vtkImporter2 = m_OutputImages[1].theImageVolume; 00087 m_OutputImages[1].isModified=true; 00088 00089 vtkImageImport* vtkImporter3 = m_OutputImages[2].theImageVolume; 00090 m_OutputImages[2].isModified=true; 00091 00092 m_InputImageReader = ImageFileReader::New(); 00093 m_InputImageReader->SetFileName(m_ImageFileName.c_str()); 00094 00095 m_InputImageReader->Update(); 00096 ImageType::Pointer image = m_InputImageReader->GetOutput(); 00097 00098 /*The image to be displayed should be connected to the vtkImporter(s) supplied 00099 by the viewer. 00100 The number of vtkImporter supplied depends on MaxNumberOfOutputImages()*/ 00101 00102 //To Do: Replace 0 with correct output 00103 00104 PopulateVtkImageHelper(image, vtkImporter); 00105 PopulateVtkImageHelper(image, vtkImporter2); 00106 PopulateVtkImageHelper(image, vtkImporter3); 00107 } 00108 00109 00110 void DefOrgAdapter_VesselCrawler::UpdateOrganism(){ 00111 itkScenePointer itkScene = m_OutputItkSpatialObjects[0].theItkScene; 00112 m_OutputItkSpatialObjects[0].isModified=true; 00113 00114 if(lock==0) 00115 { 00116 lock = 1; 00117 crawler->run(); 00118 lock = 0; 00119 } 00120 //TODO get geomLayer from org and upcast to geom_vessel crawler 00121 //itkScene->AddSpatialObject(geomLayerPointer->theMeshSpatialObject); 00122 } 00123 00124 00125 void DefOrgAdapter_VesselCrawler::SetupOrganism() 00126 { 00127 //Setup the organism 00128 00129 //Load the input image 00130 this->m_InputImageReader->Update(); 00131 crawler->SetInput(this->m_InputImageReader->GetOutput());//Use the setInput method defined via public inheritance from itk::imageToimageFilter 00132 } 00133 00134 00135 void DefOrgAdapter_VesselCrawler::PopulateVtkUnstructuredGrid(vtkUnstructuredGrid* vtkGrid /*in/out*/){ 00136 //This method is currently not used 00137 //geomLayerPointer->readTopologyFromFile( m_MeshFileName ); 00138 //MeshToUnstructuredGrid( geomLayerPointer->theMesh, vtkGrid/*in/out*/ ); 00139 } 00140 }