00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkDataNode.h"
00019
00020 #include <vtkWindow.h>
00021 #include "mitkVtkPropRenderer.h"
00022
00023 #include "mitkTestingMacros.h"
00024 #include "mitkGlobalInteraction.h"
00025
00026 #include <iostream>
00027
00028
00029 #include <mitkContour.h>
00030 #include <mitkContourSet.h>
00031 #include <mitkItkBaseDataAdapter.h>
00032 #include <mitkPointData.h>
00033 #include <mitkMesh.h>
00034 #include <mitkSeedsImage.h>
00035 #include <mitkBoundingObject.h>
00036 #include <mitkUnstructuredGrid.h>
00037
00038
00039 #include <mitkMapper.h>
00040 #include <mitkMapper2D.h>
00041 #include <mitkVtkMapper2D.h>
00042 #include <mitkContourMapper2D.h>
00043 #include <mitkContourSetMapper2D.h>
00044 #include <mitkMeshMapper2D.h>
00045 #include <mitkUnstructuredGridMapper2D.h>
00046 #include <mitkLineMapper2D.h>
00047 #include <mitkSplineMapper2D.h>
00048
00049 #include <mitkContourSetVtkMapper3D.h>
00050 #include <mitkContourVtkMapper3D.h>
00051 #include <mitkMeshVtkMapper3D.h>
00052 #include <mitkPointDataVtkMapper3D.h>
00053 #include <mitkUnstructuredGridVtkMapper3D.h>
00054 #include <mitkLineVtkMapper3D.h>
00055 #include <mitkSplineVtkMapper3D.h>
00056
00057
00058 #include <mitkConnectPointsInteractor.h>
00059 #include <mitkContourInteractor.h>
00060 #include <mitkExtrudedContourInteractor.h>
00061 #include <mitkPointInteractor.h>
00062 #include <mitkPointSelectorInteractor.h>
00063 #include <mitkSeedsInteractor.h>
00064 #include <mitkDisplayPointSetInteractor.h>
00065
00066
00067 #include <mitkAnnotationProperty.h>
00068 #include <mitkClippingProperty.h>
00069 #include <mitkColorProperty.h>
00070 #include <mitkEnumerationProperty.h>
00071 #include <mitkGridRepresentationProperty.h>
00072 #include <mitkGridVolumeMapperProperty.h>
00073 #include <mitkOrganTypeProperty.h>
00074 #include <mitkVtkInterpolationProperty.h>
00075 #include <mitkVtkRepresentationProperty.h>
00076 #include <mitkVtkResliceInterpolationProperty.h>
00077 #include <mitkVtkScalarModeProperty.h>
00078
00079
00084 class mitkDataNodeExtTestClass { public:
00085
00086 static void TestDataSetting(mitk::DataNode::Pointer dataNode)
00087 {
00088
00089 mitk::BaseData::Pointer baseData;
00090
00091
00092 dataNode->SetData(baseData);
00093 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a NULL pointer was set correctly" )
00094
00095 baseData = mitk::Contour::New();
00096 dataNode->SetData(baseData);
00097 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a Contour object was set correctly" )
00098
00099 baseData = mitk::ContourSet::New();
00100 dataNode->SetData(baseData);
00101 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a ContourSet object was set correctly" )
00102
00103 baseData = mitk::ItkBaseDataAdapter::New();
00104 dataNode->SetData(baseData);
00105 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a ItkBaseDataAdapter object was set correctly" )
00106
00107 baseData = mitk::PointData::New();
00108 dataNode->SetData(baseData);
00109 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a PointSet object was set correctly" )
00110
00111 baseData = mitk::Mesh::New();
00112 dataNode->SetData(baseData);
00113 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a Mesh object was set correctly" )
00114
00115 baseData = mitk::SeedsImage::New();
00116 dataNode->SetData(baseData);
00117 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a SeedsImage object was set correctly" )
00118
00119 baseData = mitk::BoundingObject::New();
00120 dataNode->SetData(baseData);
00121 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a BoundingObject object was set correctly" )
00122
00123 baseData = mitk::UnstructuredGrid::New();
00124 dataNode->SetData(baseData);
00125 MITK_TEST_CONDITION( baseData == dataNode->GetData(), "Testing if a UnstructuredGrid object was set correctly" )
00126 }
00127
00128 static void TestMapperSetting(mitk::DataNode::Pointer dataNode)
00129 {
00130
00131
00132
00133
00134 mitk::Mapper::Pointer mapper;
00135
00136 dataNode->SetMapper(0,mapper);
00137 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(0), "Testing if a NULL pointer was set correctly" )
00138
00139 mapper = mitk::ContourMapper2D::New();
00140 dataNode->SetMapper(1,mapper);
00141 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a ContourMapper2D was set correctly" )
00142 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00143
00144 mapper = mitk::ContourSetMapper2D::New();
00145 dataNode->SetMapper(1,mapper);
00146 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a ContourSetMapper2D was set correctly" )
00147 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00148
00149 mapper = mitk::MeshMapper2D::New();
00150 dataNode->SetMapper(1,mapper);
00151 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a MeshMapper2D was set correctly" )
00152 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00153
00154 mapper = mitk::UnstructuredGridMapper2D::New();
00155 dataNode->SetMapper(1,mapper);
00156 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a UnstructuredGridMapper2D was set correctly" )
00157 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00158
00159 mapper = mitk::LineMapper2D::New();
00160 dataNode->SetMapper(1,mapper);
00161 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a LineMapper2D was set correctly" )
00162 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00163
00164 mapper = mitk::SplineMapper2D::New();
00165 dataNode->SetMapper(1,mapper);
00166 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a SplineMapper2D was set correctly" )
00167 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00168
00169
00170 mapper = mitk::ContourSetVtkMapper3D::New();
00171 dataNode->SetMapper(1,mapper);
00172 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a ContourSetVtkMapper3D was set correctly" )
00173 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00174
00175 mapper = mitk::ContourVtkMapper3D::New();
00176 dataNode->SetMapper(1,mapper);
00177 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a ContourVtkMapper3D was set correctly" )
00178 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00179
00180 mapper = mitk::MeshVtkMapper3D::New();
00181 dataNode->SetMapper(1,mapper);
00182 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a MeshVtkMapper3D was set correctly" )
00183 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00184
00185 mapper = mitk::PointDataVtkMapper3D::New();
00186 dataNode->SetMapper(1,mapper);
00187 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a PointDataVtkMapper3D was set correctly" )
00188 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00189
00190 mapper = mitk::UnstructuredGridVtkMapper3D::New();
00191 dataNode->SetMapper(1,mapper);
00192 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a UnstructuredGridVtkMapper3D was set correctly" )
00193 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00194
00195
00196
00197
00198
00199
00200
00201 mapper = mitk::SplineVtkMapper3D::New();
00202 dataNode->SetMapper(1,mapper);
00203 MITK_TEST_CONDITION( mapper == dataNode->GetMapper(1), "Testing if a SplineVtkMapper3D was set correctly" )
00204 MITK_TEST_CONDITION( dataNode == mapper->GetDataNode(), "Testing if the mapper returns the right DataNode" )
00205 }
00206 static void TestInteractorSetting(mitk::DataNode::Pointer dataNode)
00207 {
00208
00209
00210
00211
00212 mitk::Interactor::Pointer interactor;
00213
00214 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a NULL pointer was set correctly (Interactor)" )
00215
00216 interactor = mitk::ConnectPointsInteractor::New("AffineInteractions click to select", dataNode);
00217 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a ConnectPointsInteractor was set correctly" )
00218
00219 interactor = mitk::ContourInteractor::New("AffineInteractions click to select", dataNode);
00220 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a ContourInteractor was set correctly" )
00221
00222 interactor = mitk::ExtrudedContourInteractor::New("AffineInteractions click to select", dataNode);
00223 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a ExtrudedContourInteractor was set correctly" )
00224
00225 interactor = mitk::PointInteractor::New("AffineInteractions click to select", dataNode);
00226 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a PointInteractor was set correctly" )
00227
00228 interactor = mitk::PointSelectorInteractor::New("AffineInteractions click to select", dataNode);
00229 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a PointSelectorInteractor was set correctly" )
00230
00231 interactor = mitk::SeedsInteractor::New("AffineInteractions click to select", dataNode);
00232 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a SeedsInteractor was set correctly" )
00233
00234 interactor = mitk::DisplayPointSetInteractor::New("AffineInteractions click to select", dataNode);
00235 MITK_TEST_CONDITION( interactor == dataNode->GetInteractor(), "Testing if a DisplayPointSetInteractor was set correctly" )
00236 }
00237
00238 };
00239
00240 int mitkDataNodeExtTest(int , char* [])
00241 {
00242
00243 MITK_TEST_BEGIN("DataNode")
00244
00245
00246 mitk::GlobalInteraction::GetInstance()->Initialize("global");
00247
00248
00249 mitk::DataNode::Pointer myDataNode = mitk::DataNode::New();
00250
00251
00252
00253
00254 MITK_TEST_CONDITION_REQUIRED(myDataNode.IsNotNull(),"Testing instantiation")
00255
00256
00257 mitkDataNodeExtTestClass::TestDataSetting(myDataNode);
00258 mitkDataNodeExtTestClass::TestMapperSetting(myDataNode);
00259
00260
00261 mitkDataNodeExtTestClass::TestInteractorSetting(myDataNode);
00262
00263
00264
00265
00266
00267 MITK_TEST_END()
00268 }