00001 #ifndef DefOrgViewer_h
00002 #define DefOrgViewer_h
00003
00004 #include "DefOrgViewerGUI.h"
00005
00006
00007
00008
00009
00010 #include "itkImage.h"
00011 #include "itkImageFileReader.h"
00012 #include "itkEllipseSpatialObject.h"
00013 #include "itkBlobSpatialObject.h"
00014 #include "itkSceneSpatialObject.h"
00015 #include "itkMeshSpatialObject.h"
00016 #include "itkGroupSpatialObject.h"
00017 #include "itkSpatialObjectReader.h"
00018 #include "itkImageSpatialObject.h"
00019 #include "itkMinimumMaximumImageFilter.h"
00020 #include "itkVTKImageExport.h"
00021 #include <itkCastImageFilter.h>
00022
00023 #include <itkRegularSphereMeshSource.h>
00024
00025
00026 #include <iostream>
00027
00028
00029 #include <vtkPointPicker.h>
00030 #include "vtkRenderWindow.h"
00031 #include "vtkImageImport.h"
00032 #include "vtkImagePlaneWidget.h"
00033 #include "vtkImageActor.h"
00034 #include <vtkImageViewer.h>
00035 #include "vtkImplicitPlaneWidget.h"
00036
00037
00038 #include "vtkVolumeMapper.h"
00039 #include <vtkMetaImageReader.h>
00040
00041
00042 #include <vtkPiecewiseFunction.h>
00043 #include "vtkColorTransferFunction.h"
00044 #include "vtkVolumeProperty.h"
00045 #include "vtkVolumeRayCastCompositeFunction.h"
00046 #include "vtkVolumeRayCastMIPFunction.h"
00047 #include "vtkVolumeRayCastMapper.h"
00048 #include "vtkVolume.h"
00049 #include "vtkCamera.h"
00050 #include "vtkLight.h"
00051 #include "vtkInteractorStyleTrackballActor.h"
00052 #include "vtkCubeAxesActor2D.h"
00053 #include "vtkProperty2D.h"
00054
00055 #include "vtkRenderer.h"
00056 #include "vtkOpenGLRenderer.h"
00057 #include "vtkUnstructuredGrid.h"
00058 #include "vtkCellArray.h"
00059 #include "vtkProperty.h"
00060 #include "vtkDataSetMapper.h"
00061 #include "vtkImageData.h"
00062 #include "vtkDataSet.h"
00063
00064
00065
00066
00067 #include <itkMetaImageIOFactory.h>
00068 #include "BYUToMeta.h"
00069 #include "itkImageFileReader.h"
00070 #include "itkImageFileWriter.h"
00071 #include "itkMeanImageFilter.h"
00072 #include "itkBinaryThresholdImageFilter.h"
00073 #include "itkCovariantVector.h"
00074 #include <iostream>
00075 #include "itkOrganism.h"
00076 #include "Phys_Euler.h"
00077 #include "Ctrl_ScheduleDriven.h"
00078 #include "Beh_TranslateAll.h"
00079 #include "Def_Translation.h"
00080 #include "Sense_Gradient.h"
00081 #include "Geom_MeshSpatialObject.h"
00082 #include "Phys_LevelSet.h"
00083
00084 #define N_DIMS 3
00085
00086 class VistVTKCellsClass;
00087
00088 class DefOrgViewer
00089 : public DefOrgViewerGUI
00090 {
00091 public:
00092
00093 typedef float DataType;
00094 typedef unsigned char PixelType;
00095 typedef itk::Image< PixelType, N_DIMS > ImageType;
00096 typedef Geom_MeshSpatialObject< DataType, N_DIMS > GeometricType;
00097 typedef itk::CovariantVector< DataType, N_DIMS > GradientPixelType;
00098 typedef itk::Image< GradientPixelType, N_DIMS > GradientImageType;
00099 typedef Phys_LevelSet< DataType, ImageType, N_DIMS > LevelSetPhysicsType;
00100 typedef Phys_Euler< DataType,
00101 GradientImageType, N_DIMS > EulerPhysicsType;
00102 typedef Sense_Gradient< DataType, ImageType,
00103 GradientImageType, N_DIMS > GradientSensorType;
00104 typedef Ctrl_ScheduleDriven<DataType, N_DIMS> CognitiveType;
00105 typedef Beh_TranslateAll<DataType, N_DIMS> Beh_TranslateAllType;
00106 typedef Def_Translation<DataType, N_DIMS> Def_TranslateAllType;
00107
00108 typedef itk::ItkOrganism < ImageType, ImageType,
00109 GradientImageType, DataType, N_DIMS > OrganismType;
00110
00111 typedef itk::DefaultDynamicMeshTraits<
00112 DataType, N_DIMS, N_DIMS > MeshTrait;
00113 typedef itk::Mesh< DataType, N_DIMS, MeshTrait > MeshType;
00114 typedef MeshType::Pointer MeshTypePointer;
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 typedef vtkRenderer RendererType;
00125 typedef RendererType* RendererPointer;
00126 typedef itk::VTKImageExport< ImageType > itkImageExportType;
00127 typedef vtkImageImport vtkImageImportType;
00128
00129 typedef itk::ImageFileReader< ImageType > ImageReaderType;
00130 ImageReaderType::Pointer imageReader;
00131
00132
00133 typedef itk::CellInterfaceVisitorImplementation<
00134 DataType, MeshType::CellTraits,
00135 itk::TriangleCell< itk::CellInterface<MeshType::PixelType, MeshType::CellTraits > >,
00136 VistVTKCellsClass> TriangleVisitor;
00137
00138 typedef itk::CellInterfaceVisitorImplementation<
00139 DataType, MeshType::CellTraits,
00140 itk::QuadrilateralCell< itk::CellInterface<MeshType::PixelType, MeshType::CellTraits > >,
00141 VistVTKCellsClass> QuadrilateralVisitor;
00142
00143
00144 DefOrgViewer();
00145 DefOrgViewer( MeshTypePointer itkMesh );
00146
00147
00148 void Quit();
00149 void Show();
00150 void Update();
00151 void LoadImage();
00152 void LoadMeta();
00153 void TogglePlayPause();
00154 void ToggleVolumeRendering();
00155 void TransferSlider1();
00156 void TransferSlider2();
00157
00158
00159
00160 vtkUnstructuredGrid* MeshToUnstructuredGrid( MeshType::Pointer itkMesh );
00161 void ConnectPipelines( itkImageExportType::Pointer exporter, vtkImageImportType* importer);
00162 void SetupOrganism();
00163 void UpdateOrganism();
00164
00165 private:
00166
00167 OrganismType::Pointer testOrg;
00168 LevelSetPhysicsType levelSetPhysLayer;
00169 EulerPhysicsType * eulerPhysLayerPointer;
00170 GradientSensorType::sensorIn sensorInput;
00171 GradientSensorType gradientSensor;
00172 GeometricType* geomLayerPointer;
00173 CognitiveType* cognitiveLayerPointer;
00174 Beh_TranslateAllType * beh1;
00175 Def_TranslateAllType * def1;
00176
00177
00178 vtkCubeAxesActor2D* axes;
00179 vtkLight* light;
00180 vtkCamera* camera;
00181 vtkImagePlaneWidget* planeX;
00182 ImageType::Pointer image;
00183 RendererPointer renderer;
00184 vtkRenderWindow* renderWindow;
00185 itkImageExportType::Pointer itkExporter;
00186 vtkImageImport* vtkImporter;
00187
00188
00189 vtkPiecewiseFunction* opacityTransferFunction;
00190 vtkColorTransferFunction* colorTransferFunction;
00191 vtkVolumeRayCastCompositeFunction* compositeFunction;
00192 vtkVolumeRayCastMIPFunction* MIPFunction;
00193 vtkVolumeProperty* volumeProperty;
00194 vtkVolumeRayCastMapper* volumeMapper;
00195 vtkVolume* volume;
00196 vtkDataSetMapper* meshMapper;
00197 vtkActor* meshActor;
00198
00199
00200
00201 std::string scheduleFileName;
00202 bool isVolumeRenderingOn;
00203 bool orgNotSet;
00204
00205 };
00206
00207
00208
00209
00210 class VistVTKCellsClass
00211 {
00212 vtkCellArray* m_Cells;
00213 int* m_LastCell;
00214 int* m_TypeArray;
00215 public:
00216
00217 typedef itk::CellInterface<
00218 DefOrgViewer::MeshType::PixelType,
00219 DefOrgViewer::MeshType::CellTraits > CellInterfaceType;
00220
00221 typedef itk::TriangleCell<CellInterfaceType> floatTriangleCell;
00222 typedef itk::QuadrilateralCell<CellInterfaceType> floatQuadrilateralCell;
00223
00224
00225 void SetCellArray(vtkCellArray* a)
00226 {
00227 m_Cells = a;
00228 }
00229
00230 void SetCellCounter(int* i)
00231 {
00232 m_LastCell = i;
00233 }
00234
00235 void SetTypeArray(int* i)
00236 {
00237 m_TypeArray = i;
00238 }
00239
00240 void Visit(unsigned long, floatTriangleCell* t)
00241 {
00242 m_Cells->InsertNextCell(3, (vtkIdType*)t->PointIdsBegin());
00243 m_TypeArray[*m_LastCell] = VTK_TRIANGLE;
00244 (*m_LastCell)++;
00245 }
00246
00247 void Visit(unsigned long, floatQuadrilateralCell* t)
00248 {
00249 m_Cells->InsertNextCell(4, (vtkIdType*)t->PointIdsBegin());
00250 m_TypeArray[*m_LastCell] = VTK_QUAD;
00251 (*m_LastCell)++;
00252 }
00253 };
00254
00255
00256
00257 #endif // DefOrgViewer defined