36 CPPUNIT_TEST_SUITE(mitkGeometryDataIOTestSuite);
45 CPPUNIT_TEST_SUITE_END();
61 m_GeometryData->SetGeometry(m_Geom3D);
66 CPPUNIT_ASSERT(m_TimeGeometry.IsNotNull());
69 void tearDown()
override
71 m_GeometryData =
nullptr;
73 m_ReadGeometryData =
nullptr;
74 m_ReadGeom3D =
nullptr;
75 m_ReadProportionalTimeGeom =
nullptr;
78 void StoreDefaultGeometry3D()
81 ASSERT_Geometry3D_WriteReadLoop_Works();
84 void StoreImageGeometry()
86 m_Geom3D->SetImageGeometry(
true);
87 ASSERT_Geometry3D_WriteReadLoop_Works();
89 m_Geom3D->SetImageGeometry(
false);
90 ASSERT_Geometry3D_WriteReadLoop_Works();
93 void StoreFrameOfReference()
95 m_Geom3D->SetFrameOfReferenceID(513);
96 ASSERT_Geometry3D_WriteReadLoop_Works();
99 ASSERT_Geometry3D_WriteReadLoop_Works();
106 m_Geom3D->SetOrigin(origin);
107 ASSERT_Geometry3D_WriteReadLoop_Works();
110 m_Geom3D->SetOrigin(origin);
111 ASSERT_Geometry3D_WriteReadLoop_Works();
121 m_Geom3D->SetSpacing(spacing);
122 ASSERT_Geometry3D_WriteReadLoop_Works();
135 bounds[3] = 918273645.18293746;
138 m_Geom3D->SetBounds(bounds);
139 ASSERT_Geometry3D_WriteReadLoop_Works();
142 void StoreTransform()
144 mitk::ScalarType matrixCoeffs[9] = {0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8};
146 mitk::AffineTransform3D::MatrixType matrix;
147 matrix.GetVnlMatrix().set(matrixCoeffs);
149 mitk::AffineTransform3D::OffsetType
offset;
150 offset[0] = -918273645.1829374;
153 offset[2] = +918273645.1829374;
156 transform->SetMatrix(matrix);
157 transform->SetOffset(offset);
158 m_Geom3D->SetIndexToWorldTransform(transform);
160 ASSERT_Geometry3D_WriteReadLoop_Works();
163 void WriteAndRead_m_GeometryData()
169 std::string
filename(
"geometrydata_geometry3d");
178 CPPUNIT_ASSERT_MESSAGE(
"IOUtil could read something (and just one)", loadedData.size() == 1);
180 m_ReadGeometryData =
dynamic_cast<mitk::GeometryData *
>(loadedData.front().GetPointer());
181 CPPUNIT_ASSERT_MESSAGE(
"IOUtil could read _some_ GeometryData", m_ReadGeometryData.IsNotNull());
183 m_ReadGeom3D =
dynamic_cast<mitk::Geometry3D *
>(m_ReadGeometryData->GetGeometry());
184 CPPUNIT_ASSERT_MESSAGE(
"IOUtil could read _some_ Geometry3D", m_ReadGeom3D.IsNotNull());
187 CPPUNIT_ASSERT_MESSAGE(
"IOUtil could read _some_ ProportionalTimeGeometry", m_ReadProportionalTimeGeom.IsNotNull());
190 void ASSERT_Geometry3D_WriteReadLoop_Works()
192 WriteAndRead_m_GeometryData();
197 CPPUNIT_ASSERT_MESSAGE(
"Geometry3D > file > Geometry3D keeps geometry",
198 mitk::Equal(*m_Geom3D, *m_ReadGeom3D, 0.000001,
true));
204 void StoreProportionalTimeGeometry()
207 m_TimeGeometry->ClearAllGeometries();
209 for (
int t = 0; t < 4; ++t)
214 for (
int i = 0; i != 4; ++i)
216 for (
int j = 0; j != 4; ++j)
218 vtk_matrix->SetElement(i, j, t + (i + j) / 8.0);
223 vtk_matrix->Invert();
225 timestepGeometry->SetIndexToWorldTransformByVtkMatrix(vtk_matrix);
226 m_TimeGeometry->SetTimeStepGeometry(timestepGeometry, t);
230 m_TimeGeometry->SetFirstTimePoint(-5017.20);
231 m_TimeGeometry->SetStepDuration(2743.83);
234 ASSERT_ProportionalTimeGeometry_WriteReadLoop_Works();
237 void ASSERT_ProportionalTimeGeometry_WriteReadLoop_Works()
239 WriteAndRead_m_GeometryData();
241 CPPUNIT_ASSERT_MESSAGE(
"ProportionalTimeGeometry > file > ProportionalTimeGeometry keeps geometry",
242 mitk::Equal(*m_TimeGeometry, *m_ReadProportionalTimeGeom, 0.000001,
true));
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
itk::SmartPointer< Self > Pointer
Standard implementation of BaseGeometry.
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
BoundingBoxType::BoundsArrayType BoundsArrayType
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
static const std::string filename
Test fixture for parameterized tests.
Data class only having a BaseGeometry but not containing any specific data.
static std::string CreateTemporaryDirectory(const std::string &templateName="XXXXXX", std::string path=std::string())
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.
static CustomMimeType GEOMETRY_DATA_MIMETYPE()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.