diff --git a/Core/Code/DataManagement/mitkProportionalTimeGeometry.h b/Core/Code/DataManagement/mitkProportionalTimeGeometry.h index 7854697d42..116c93f6b6 100644 --- a/Core/Code/DataManagement/mitkProportionalTimeGeometry.h +++ b/Core/Code/DataManagement/mitkProportionalTimeGeometry.h @@ -1,208 +1,216 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef ProportialTimeGeometry_h #define ProportialTimeGeometry_h //ITK #include #include #include //MITK #include #include #include #include "mitkOperationActor.h" #include "mitkVector.h" // To be replaced #include // STL #include namespace mitk { /** - * \brief la + * \brief Organizes geometries over proportional time steps * + * For this TimeGeometry implementation it is assumed that + * the durations of the time steps are equidistant, e.g. + * the durations of the time steps in one ProportionalTimeGeometry + * are the same. The geometries of the time steps are independent, + * and not linked to each other. Since the timeBounds of the + * geometries are different for each time step it is not possible + * to set the same geometry to different time steps. Instead + * copies should be used. * * \addtogroup geometry */ class MITK_CORE_EXPORT ProportionalTimeGeometry : public TimeGeometry { public: mitkClassMacro(ProportionalTimeGeometry, TimeGeometry); ProportionalTimeGeometry(); typedef ProportionalTimeGeometry self; itkNewMacro(self); /** * \brief Returns the number of time steps. * * Returns the number of time steps for which * geometries are saved. The number of time steps * is also the upper bound of the time steps. The * minimum time steps is always 0. */ virtual TimeStepType GetNumberOfTimeSteps() const; /** * \brief Returns the first time point for which the object is valid. * * Returns the first valid time point for this geometry. If only one * time steps available it usually goes from -max to +max. The time point * is given in ms. */ virtual TimePointType GetMinimumTimePoint () const; /** * \brief Returns the last time point for which the object is valid * * Gives the last time point for which a valid geometrie is saved in * this time geometry. The time point is given in ms. */ virtual TimePointType GetMaximumTimePoint () const; /** * \brief Get the time bounds (in ms) */ virtual TimeBounds GetTimeBounds( ) const; /** * \brief Tests if a given time point is covered by this object * * Returns true if a geometry can be returned for the given time * point and falls if not. The time point must be given in ms. */ virtual bool IsValidTimePoint (TimePointType timePoint) const; /** * \brief Test for the given time step if a geometry is availible * * Returns true if a geometry is defined for the given time step. * Otherwise false is returned. * The time step is defined as positiv number. */ virtual bool IsValidTimeStep (TimeStepType timeStep) const; /** * \brief Converts a time step to a time point * * Converts a time step to a time point in a way that * the new time point indicates the same geometry as the time step. * If the original time steps does not point to a valid geometry, * a time point is calculated that also does not point to a valid * geometry, but no exception is raised. */ virtual TimePointType TimeStepToTimePoint (TimeStepType timeStep) const; /** * \brief Converts a time point to the corresponding time step * * Converts a time point to a time step in a way that * the new time step indicates the same geometry as the time point. * If a negativ invalid time point is given always time step 0 is * returned. If an positiv invalid time step is given an invalid * time step will be returned. */ virtual TimeStepType TimePointToTimeStep (TimePointType timePoint) const; /** * \brief Returns the geometry which corresponds to the given time step * * Returns a clone of the geometry which defines the given time step. If * the given time step is invalid an null-pointer is returned. */ virtual Geometry3D::Pointer GetGeometryCloneForTimeStep( TimeStepType timeStep) const; /** * \brief Returns the geometry which corresponds to the given time point * * Returns the geometry which defines the given time point. If * the given time point is invalid an null-pointer is returned. * * If the returned geometry is changed this will affect the saved * geometry. */ virtual Geometry3D* GetGeometryForTimePoint ( TimePointType timePoint) const; /** * \brief Returns the geometry which corresponds to the given time step * * Returns the geometry which defines the given time step. If * the given time step is invalid an null-pointer is returned. * * If the returned geometry is changed this will affect the saved * geometry. */ virtual Geometry3D* GetGeometryForTimeStep ( TimeStepType timeStep) const; /** * \brief Tests if all necessary informations are set and the object is valid */ virtual bool IsValid (); /** * \brief Initilizes a new object with one time steps which contains an empty geometry. */ virtual void Initialize(); /** * \brief Expands the time geometry to the given number of time steps. * * Initializes the new time steps with empty geometries. * Shrinking is not supported. */ virtual void Expand(TimeStepType size); /** * \brief Sets the geometry for the given time step * * This method does not afflict other time steps, since the geometry for * each time step is saved individually. */ virtual void SetTimeStepGeometry(Geometry3D* geometry, TimeStepType timeStep); /** * \brief Makes a deep copy of the current object */ virtual itk::LightObject::Pointer InternalClone () const; itkGetMacro(FirstTimePoint, TimePointType); itkSetMacro(FirstTimePoint, TimePointType); itkGetMacro(StepDuration, TimePointType); itkSetMacro(StepDuration, TimePointType); // void SetGeometryForTimeStep(TimeStepType timeStep, BaseGeometry& geometry); void ClearAllGeometries (); // void AddGeometry(BaseGeometry geometry); void ReserveSpaceForGeometries (TimeStepType numberOfGeometries); /** * \brief Initializes the TimeGeometry with equally time Step geometries * * Saves a copy for each time step. */ void Initialize (Geometry3D * geometry, TimeStepType timeSteps); /** * \brief Initialize the TimeGeometry with empty Geometry3D */ void Initialize (TimeStepType timeSteps); protected: virtual ~ProportionalTimeGeometry(); std::vector m_GeometryVector; TimePointType m_FirstTimePoint; TimePointType m_StepDuration; }; // end class ProportialTimeGeometry } // end namespace MITK #endif // ProportialTimeGeometry_h \ No newline at end of file diff --git a/Core/Code/DataManagement/mitkTimeGeometry.h b/Core/Code/DataManagement/mitkTimeGeometry.h index f4ec455188..4afadbaa72 100644 --- a/Core/Code/DataManagement/mitkTimeGeometry.h +++ b/Core/Code/DataManagement/mitkTimeGeometry.h @@ -1,294 +1,291 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef TimeGeometry_h #define TimeGeometry_h //ITK #include #include #include //MITK #include #include #include "mitkOperationActor.h" #include "mitkVector.h" // To be replaced #include // STL #include namespace mitk { -// typedef itk::BoundingBox BoundingBox; -// typedef itk::FixedArray TimeBounds; - - -// typedef unsigned long TimePointType; typedef float TimePointType; typedef std::size_t TimeStepType; /** * \brief Manages the geometries of a data object for each time step * * This class is an abstract class. The concrete implementation * depends on the way the different time steps are managed. * * The time is defined either by a time step or a time point. Time steps * are non-negativ integers starting from 0. A time point is is an float value * which gives the passed time since start in ms. Be aware that the starting * point is not fixed so it is possible that the same time point defines two * different time depending on the start time of the used time geometry. + * + * \addtogroup geometry */ class MITK_CORE_EXPORT TimeGeometry : public itk::Object, public OperationActor { protected: TimeGeometry(); virtual ~TimeGeometry(); /** * \brief Contains a bounding box which includes all time steps */ BoundingBox::Pointer m_BoundingBox; public: mitkClassMacro(TimeGeometry, itk::Object); itkCloneMacro(Self); /** * \brief Returns the number of time steps. * * Returns the number of time steps for which * geometries are saved. The number of time steps * is also the upper bound of the time steps. The * minimum time steps is always 0. */ virtual TimeStepType GetNumberOfTimeSteps() const = 0; /** * \brief Returns the first time point for which the object is valid. * * Returns the first valid time point for this geometry. If only one * time steps available it usually goes from -max to +max. The time point * is given in ms. */ virtual TimePointType GetMinimumTimePoint () const = 0; /** * \brief Returns the last time point for which the object is valid * * Gives the last time point for which a valid geometrie is saved in * this time geometry. The time point is given in ms. */ virtual TimePointType GetMaximumTimePoint () const = 0; /** * \brief Get the time bounds (in ms) */ virtual TimeBounds GetTimeBounds( ) const = 0; /** * \brief Tests if a given time point is covered by this object * * Returns true if a geometry can be returned for the given time * point and falls if not. The time point must be given in ms. */ virtual bool IsValidTimePoint (TimePointType timePoint) const = 0; /** * \brief Test for the given time step if a geometry is availible * * Returns true if a geometry is defined for the given time step. * Otherwise false is returned. * The time step is defined as positiv number. */ virtual bool IsValidTimeStep (TimeStepType timeStep) const = 0; /** * \brief Converts a time step to a time point * * Converts a time step to a time point in a way that * the new time point indicates the same geometry as the time step. * If the original time steps does not point to a valid geometry, * a time point is calculated that also does not point to a valid * geometry, but no exception is raised. */ virtual TimePointType TimeStepToTimePoint (TimeStepType timeStep) const = 0; /** * \brief Converts a time point to the corresponding time step * * Converts a time point to a time step in a way that * the new time step indicates the same geometry as the time point. * If a negativ invalid time point is given always time step 0 is * returned. If an positiv invalid time step is given an invalid * time step will be returned. */ virtual TimeStepType TimePointToTimeStep (TimePointType timePoint) const = 0; /** * \brief Returns the geometry of a specific time point * * Returns the geometry which defines the given time point. If * the given time point is invalid an null-pointer is returned. * * The pointer to the returned geometry may point to the saved * geometry but this is not necessarily the case. So a change to * the returned geometry may or may not afflict the geometry for the * time point or all time points depending on the used implementation * of TimeGeometry. */ virtual Geometry3D* GetGeometryForTimePoint ( TimePointType timePoint) const = 0; /** * \brief Returns the geometry which corresponds to the given time step * * Returns the geometry which defines the given time step. If * the given time step is invalid an null-pointer is returned. * * The pointer to the returned geometry may point to the saved * geometry but this is not necessarily the case. So a change to * the returned geometry may or may not afflict the geometry for the * time step or all time steps depending on the used implementation * of TimeGeometry. */ virtual Geometry3D* GetGeometryForTimeStep ( TimeStepType timeStep) const = 0; /** * \brief Returns a clone of the geometry of a specific time point * * If an invalid time step is given (e.g. no geometry is defined for this time step) * a null-pointer will be returned. */ virtual Geometry3D::Pointer GetGeometryCloneForTimeStep( TimeStepType timeStep) const = 0; /** * \brief Sets the geometry for a given time step * * Sets the geometry for the given time steps. This may also afflects other * time steps, depending on the implementation of TimeGeometry. */ virtual void SetTimeStepGeometry(Geometry3D* geometry, TimeStepType timeStep) = 0; /** * \brief Expands to the given number of time steps * * Expands to the given number of time steps. Each new created time * step is filled with an empty geometry. * Shrinking is not supported! */ virtual void Expand(TimeStepType size) = 0; /** * \brief Tests if all necessary informations are set and the object is valid */ virtual bool IsValid () = 0; /** * \brief Get the position of the corner number \a id (in world coordinates) * * See SetImageGeometry for how a corner is defined on images. */ Point3D GetCornerPointInWorld(int id) const; /** * \brief Get the position of a corner (in world coordinates) * * See SetImageGeometry for how a corner is defined on images. */ Point3D GetCornerPointInWorld(bool xFront=true, bool yFront=true, bool zFront=true) const; /** * \brief Get the center of the bounding-box in mm */ Point3D GetCenterInWorld() const; /** * \brief Get the squared length of the diagonal of the bounding-box in mm */ double GetDiagonalLength2InWorld() const; /** * \brief Get the length of the diagonal of the bounding-box in mm */ double GetDiagonalLengthInWorld() const; /** * \brief Test whether the point \a p (world coordinates in mm) is inside the bounding box */ bool IsWorldPointInside(const mitk::Point3D& p) const; /** * \brief Updates the bounding box to cover the area used in all time steps * * The bounding box is updated by this method. The new bounding box * covers an area which includes all bounding boxes during * all times steps. */ void UpdateBoundingBox(); /** * \brief Returns a bounding box that covers all time steps */ BoundingBox* GetBoundingBoxInWorld() const { return m_BoundingBox; } /** * \brief Returns the world bounds of the object that cover all time steps */ BoundingBox::BoundsArrayType GetBoundsInWorld() const { return m_BoundingBox->GetBounds(); } /** * \brief Returns the Extend of the bounding in the given direction */ ScalarType GetExtentInWorld (unsigned int direction) const; /** * \brief Makes a deep copy of the current object */ virtual itk::LightObject::Pointer InternalClone () const = 0 ; /** * \brief Initializes the TimeGeometry */ virtual void Initialize(); /** * \brief Updates the geometry */ void Update(); /** * \brief Updates everything except the Bounding box * * This class should be overwritten by child classes. * The method is called when Update() is required. */ virtual void UpdateWithoutBoundingBox() {}; /** * \brief Executes the given operation on all time steps */ virtual void ExecuteOperation(Operation *op); virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; }; // end class TimeGeometry } // end namespace MITK #endif // TimeGeometry_h \ No newline at end of file diff --git a/Core/Code/Testing/mitkTimeGeometryTest.cpp b/Core/Code/Testing/mitkTimeGeometryTest.cpp index c62a665d33..ce32a4de0a 100644 --- a/Core/Code/Testing/mitkTimeGeometryTest.cpp +++ b/Core/Code/Testing/mitkTimeGeometryTest.cpp @@ -1,689 +1,718 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTimeGeometry.h" #include "mitkGeometry3D.h" #include "mitkRotationOperation.h" #include "mitkInteractionConst.h" #include #include #include "mitkTestingMacros.h" #include #include #include #include "mitkImageGenerator.h" +#include "mitkPointSet.h" #include class mitkTimeGeometryTestClass { public: - void Translation_Image_MovedOrigin(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void Translation_Image_MovedOrigin(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { // DimX, DimY, DimZ, mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::Geometry3D::Pointer geometry = image->GetTimeGeometry()->GetGeometryForTimeStep(0); + mitk::Geometry3D::Pointer geometry = baseData->GetTimeGeometry()->GetGeometryForTimeStep(0); mitk::Point3D imageOrigin = geometry->GetOrigin(); mitk::Point3D expectedOrigin; expectedOrigin[0] = 0; expectedOrigin[1] = 0; expectedOrigin[2] = 0; MITK_TEST_CONDITION(mitk::Equal(imageOrigin, expectedOrigin), "Original origin match expected origin"); expectedOrigin[0] = 0.325; expectedOrigin[1] = 0.487; expectedOrigin[2] = 0.78; mitk::Vector3D translationVector; translationVector[0] = expectedOrigin[0]; translationVector[1] = expectedOrigin[1]; translationVector[2] = expectedOrigin[2]; for (mitk::TimeStepType timeStep = 0; timeStep < image->GetTimeGeometry()->GetNumberOfTimeSteps(); ++timeStep) { image->GetTimeGeometry()->GetGeometryForTimeStep(timeStep)->Translate(translationVector); } imageOrigin = image->GetGeometry(0)->GetOrigin(); MITK_TEST_CONDITION(mitk::Equal(imageOrigin, expectedOrigin), "Translated origin match expected origin"); expectedOrigin[0] = 2*translationVector[0]; expectedOrigin[1] = 2*translationVector[1]; expectedOrigin[2] = 2*translationVector[2]; for (mitk::TimeStepType timeStep = 0; timeStep < image->GetTimeGeometry()->GetNumberOfTimeSteps(); ++timeStep) { image->GetTimeGeometry()->GetGeometryForTimeStep(timeStep)->Translate(translationVector); } imageOrigin = image->GetGeometry(0)->GetOrigin(); MITK_TEST_CONDITION(mitk::Equal(imageOrigin, expectedOrigin), "Translated origin match expected origin"); } - void Rotate_Image_RotatedPoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void Rotate_Image_RotatedPoint(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); mitk::DataNode::Pointer dataNode = mitk::DataNode::New(); // DimX, DimY, DimZ, - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - dataNode->SetData(image); + dataNode->SetData(baseData); ds->Add(dataNode); - mitk::Geometry3D::Pointer geometry = image->GetTimeGeometry()->GetGeometryForTimeStep(0); + mitk::Geometry3D::Pointer geometry = baseData->GetTimeGeometry()->GetGeometryForTimeStep(0); mitk::Point3D expectedPoint; expectedPoint[0] = 3*0.5; expectedPoint[1] = 3*0.33; expectedPoint[2] = 3*0.78; mitk::Point3D originalPoint; originalPoint[0] = 3; originalPoint[1] = 3; originalPoint[2] = 3; mitk::Point3D worldPoint; geometry->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Index-to-World without rotation as expected "); mitk::Point3D pointOfRotation; pointOfRotation[0] = 0; pointOfRotation[1] = 0; pointOfRotation[2] = 0; mitk::Vector3D vectorOfRotation; vectorOfRotation[0] = 1; vectorOfRotation[1] = 0.5; vectorOfRotation[2] = 0.2; float angleOfRotation = 73.0; mitk::RotationOperation* rotation = new mitk::RotationOperation(mitk::OpROTATE,pointOfRotation, vectorOfRotation, angleOfRotation); - image->GetTimeGeometry()->ExecuteOperation(rotation); + baseData->GetTimeGeometry()->ExecuteOperation(rotation); delete rotation; expectedPoint[0] = 2.6080379; expectedPoint[1] = -0.75265157; expectedPoint[2] = 1.1564401; - image->GetGeometry(0)->IndexToWorld(originalPoint,worldPoint); + baseData->GetGeometry(0)->IndexToWorld(originalPoint,worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Rotation returns expected values "); } void Scale_Image_ScaledPoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { // DimX, DimY, DimZ, mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::Geometry3D::Pointer geometry = image->GetTimeGeometry()->GetGeometryForTimeStep(0); mitk::Point3D expectedPoint; expectedPoint[0] = 3*0.5; expectedPoint[1] = 3*0.33; expectedPoint[2] = 3*0.78; mitk::Point3D originalPoint; originalPoint[0] = 3; originalPoint[1] = 3; originalPoint[2] = 3; mitk::Point3D worldPoint; geometry->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Index-to-World with old Scaling as expected "); mitk::Vector3D newSpacing; newSpacing[0] = 2; newSpacing[1] = 1.254; newSpacing[2] = 0.224; image->SetSpacing(newSpacing); expectedPoint[0] = 3*2; expectedPoint[1] = 3*1.254; expectedPoint[2] = 3*0.224; image->GetGeometry(0)->IndexToWorld(originalPoint,worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Index-toWorld with new Scaling returns expected values "); } void GetMinimumTimePoint_4DImage_Zero(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::TimePointType expectedTimePoint = geometry->GetMinimumTimePoint(); MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, 0), "Returns correct minimum time point "); } void GetMaximumTimePoint_4DImage_DimT(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::TimePointType expectedTimePoint = geometry->GetMaximumTimePoint(); MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, DimT), "Returns correct maximum time point "); } - void GetNumberOfTimeSteps_Image_ReturnDimT(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void GetNumberOfTimeSteps_Image_ReturnDimT(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimeStepType expectedTimeSteps = geometry->GetNumberOfTimeSteps(); MITK_TEST_CONDITION(mitk::Equal(expectedTimeSteps, DimT), "Returns correct number of time Steps "); } - void GetMinimumTimePoint_3DImage_Min(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void GetMinimumTimePoint_3DImage_Min(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimePointType expectedTimePoint = geometry->GetMinimumTimePoint(); MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, -std::numeric_limits().max()), "Returns correct minimum time point "); } - void GetMaximumTimePoint_3DImage_Max(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void GetMaximumTimePoint_3DImage_Max(mitk::BaseData* baseData,unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimePointType expectedTimePoint = geometry->GetMaximumTimePoint(); MITK_INFO << expectedTimePoint; MITK_INFO << std::numeric_limits().max(); MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, std::numeric_limits().max()), "Returns correct maximum time point "); } void GetTimeBounds_4DImage_ZeroAndDimT(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::TimeBounds expectedTimeBounds = geometry->GetTimeBounds(); MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[0], 0), "Returns correct minimum time point "); MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[1], DimT), "Returns correct maximum time point "); } - void GetTimeBounds_3DImage_ZeroAndDimT(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void GetTimeBounds_3DImage_ZeroAndDimT(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimeBounds expectedTimeBounds = geometry->GetTimeBounds(); MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[0], -std::numeric_limits().max()), "Returns correct minimum time point "); MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[1], std::numeric_limits().max()), "Returns correct maximum time point "); } - void IsValidTimePoint_ImageValidTimePoint_True(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void IsValidTimePoint_ImageValidTimePoint_True(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); bool isValid = geometry->IsValidTimePoint(DimT-1); MITK_TEST_CONDITION(mitk::Equal(isValid, true), "Is valid time Point correct minimum time point "); } void IsValidTimePoint_ImageNegativInvalidTimePoint_False(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); bool isValid = geometry->IsValidTimePoint(-DimT); MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point "); } void IsValidTimePoint_ImageInvalidTimePoint_False(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); bool isValid = geometry->IsValidTimePoint(DimT+1); MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point "); } - void IsValidTimeStep_ImageValidTimeStep_True(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void IsValidTimeStep_ImageValidTimeStep_True(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); bool isValid = geometry->IsValidTimeStep(DimT-1); MITK_TEST_CONDITION(mitk::Equal(isValid, true), "Is valid time Point correct minimum time point "); } - void IsValidTimeStep_ImageNegativInvalidTimeStep_False(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void IsValidTimeStep_ImageNegativInvalidTimeStep_False(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); bool isValid = geometry->IsValidTimeStep(-DimT); MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point "); } - void IsValidTimeStep_ImageInvalidTimeStep_False(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void IsValidTimeStep_ImageInvalidTimeStep_False(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); bool isValid = geometry->IsValidTimeStep(DimT); MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point "); } - void TimeStepToTimePoint_ImageValidTimeStep_TimePoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void TimeStepToTimePoint_ImageValidTimeStep_TimePoint(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimePointType timePoint= geometry->TimeStepToTimePoint(DimT-1); MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT-1), "Calculated right time Point for Time Step "); } - void TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimePointType timePoint= geometry->TimeStepToTimePoint(DimT+1); MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT+1), "Calculated right time Point for invalid Time Step "); } - void TimePointToTimeStep_ImageValidTimePoint_TimePoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) + void TimePointToTimeStep_ImageValidTimePoint_TimePoint(mitk::BaseData* baseData, unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { - mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); - mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); + mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry(); mitk::TimeStepType timePoint= geometry->TimePointToTimeStep(DimT-0.5); MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT-1), "Calculated right time step for valid time point"); } void TimePointToTimeStep_4DImageInvalidTimePoint_TimePoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::TimeStepType timePoint= geometry->TimePointToTimeStep(DimT+1.5); MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT+1), "Calculated right time step for invalid time point"); } void TimePointToTimeStep_4DImageNegativInvalidTimePoint_TimePoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::TimePointType negativTimePoint = (-1.0*DimT) - 1.5; mitk::TimeStepType timePoint= geometry->TimePointToTimeStep(negativTimePoint); MITK_TEST_CONDITION(mitk::Equal(timePoint, 0), "Calculated right time step for negativ invalid time point"); } void GetGeometryForTimeStep_ImageValidTimeStep_CorrectGeometry(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryForTimeStep(DimT-1); MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned"); mitk::Point3D expectedPoint; expectedPoint[0] = 3*0.5; expectedPoint[1] = 3*0.33; expectedPoint[2] = 3*0.78; mitk::Point3D originalPoint; originalPoint[0] = 3; originalPoint[1] = 3; originalPoint[2] = 3; mitk::Point3D worldPoint; geometry3D->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Geometry transformation match expection. "); } void GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryForTimeStep(DimT+1); MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned"); } void GetGeometryForTimePoint_ImageValidTimePoint_CorrectGeometry(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryForTimePoint(DimT-0.5); MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned"); mitk::Point3D expectedPoint; expectedPoint[0] = 3*0.5; expectedPoint[1] = 3*0.33; expectedPoint[2] = 3*0.78; mitk::Point3D originalPoint; originalPoint[0] = 3; originalPoint[1] = 3; originalPoint[2] = 3; mitk::Point3D worldPoint; geometry3D->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Geometry transformation match expection. "); } void GetGeometryForTimePoint_4DImageInvalidTimePoint_NullPointer(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryForTimePoint(DimT+1); MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned with invalid time point"); } void GetGeometryForTimePoint_4DImageNEgativInvalidTimePoint_NullPointer(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::TimePointType timePoint = (-1.0*(DimT)) -1; mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryForTimePoint(timePoint); MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned with invalid negativ time point"); } void GetGeometryCloneForTimeStep_ImageValidTimeStep_CorrectGeometry(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryCloneForTimeStep(DimT-1); MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned"); mitk::Point3D expectedPoint; expectedPoint[0] = 3*0.5; expectedPoint[1] = 3*0.33; expectedPoint[2] = 3*0.78; mitk::Point3D originalPoint; originalPoint[0] = 3; originalPoint[1] = 3; originalPoint[2] = 3; mitk::Point3D worldPoint; geometry3D->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Geometry transformation match expection. "); mitk::Vector3D translationVector; translationVector[0] = 5; translationVector[1] = 8; translationVector[2] = 7; geometry3D->Translate(translationVector); geometry3D = geometry->GetGeometryForTimeStep(DimT-1); geometry3D->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Geometry transformation not changed. "); } void GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryCloneForTimeStep(DimT+1); MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned"); } void SetTimeStepGeometry_ImageValidTimeStep_CorrectGeometry(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryCloneForTimeStep(DimT-1); MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned"); mitk::Vector3D translationVector; translationVector[0] = 5; translationVector[1] = 8; translationVector[2] = 7; geometry3D->Translate(translationVector); geometry->SetTimeStepGeometry(geometry3D,DimT-1); mitk::Point3D expectedPoint; expectedPoint[0] = 3*0.5+5; expectedPoint[1] = 3*0.33+8; expectedPoint[2] = 3*0.78+7; mitk::Point3D originalPoint; originalPoint[0] = 3; originalPoint[1] = 3; originalPoint[2] = 3; mitk::Point3D worldPoint; geometry->GetGeometryForTimeStep(DimT-1)->IndexToWorld(originalPoint, worldPoint); MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Geometry transformation match expection. "); } void Expand_ImageDoubleSize_SizeChanged(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); MITK_TEST_CONDITION(geometry->GetNumberOfTimeSteps()==DimT, "Number of time Steps match expection. "); geometry->Expand(DimT * 2); MITK_TEST_CONDITION(geometry->GetNumberOfTimeSteps()==DimT*2, "Number of time Steps match expection. "); mitk::Geometry3D::Pointer geometry3D = geometry->GetGeometryForTimeStep(DimT*2 -1); MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry is generated. "); } void CheckBounds_Image_PointsAsExpected(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Point3D expectedPoint; expectedPoint[0] = -0.5*0.5; expectedPoint[1] = -0.5*0.33; expectedPoint[2] = -0.5*0.78; mitk::Point3D point = geometry->GetCornerPointInWorld(0); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 0 as expected "); point = geometry->GetCornerPointInWorld(true,true,true); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 0 as expected "); point = geometry->GetCornerPointInWorld(1); expectedPoint[0] = -0.5*0.5; expectedPoint[1] = -0.5*0.33; expectedPoint[2] = 19.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "GBounding Point 1 as expected "); point = geometry->GetCornerPointInWorld(true,true,false); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 1 as expected "); point = geometry->GetCornerPointInWorld(2); expectedPoint[0] = -0.5*0.5; expectedPoint[1] = 24.5*0.33; expectedPoint[2] = -0.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 2 as expected "); point = geometry->GetCornerPointInWorld(true,false,true); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 2 as expected "); point = geometry->GetCornerPointInWorld(3); expectedPoint[0] = -0.5*0.5; expectedPoint[1] = 24.5*0.33; expectedPoint[2] = 19.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 3 as expected "); point = geometry->GetCornerPointInWorld(true,false,false); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 3 as expected "); point = geometry->GetCornerPointInWorld(4); expectedPoint[0] = 29.5*0.5; expectedPoint[1] = -0.5*0.33; expectedPoint[2] = -0.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 4 as expected "); point = geometry->GetCornerPointInWorld(false,true,true); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 4 as expected "); point = geometry->GetCornerPointInWorld(5); expectedPoint[0] = 29.5*0.5; expectedPoint[1] = -0.5*0.33; expectedPoint[2] = 19.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 5 as expected "); point = geometry->GetCornerPointInWorld(false,true,false); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 5 as expected "); point = geometry->GetCornerPointInWorld(6); expectedPoint[0] = 29.5*0.5; expectedPoint[1] = 24.5*0.33; expectedPoint[2] = -0.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 6 as expected "); point = geometry->GetCornerPointInWorld(false,false,true); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 6 as expected "); point = geometry->GetCornerPointInWorld(7); expectedPoint[0] = 29.5*0.5; expectedPoint[1] = 24.5*0.33; expectedPoint[2] = 19.5*0.78; MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 7 as expected "); point = geometry->GetCornerPointInWorld(false,false,false); MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point), "Bounding Point 7 as expected "); } void CheckLength_Image_AsExpected(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); double dimension = geometry->GetDiagonalLengthInWorld(); MITK_TEST_CONDITION(mitk::Equal(dimension,23.160796233014466 ), "Length as expected "); dimension = geometry->GetDiagonalLength2InWorld(); MITK_TEST_CONDITION(mitk::Equal(dimension,536.42248214721712 ), "Square length as expected "); } void CheckPointInside_ImagePointInside_True(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Point3D expectedPoint; expectedPoint[0] = 10; expectedPoint[1] = 5; expectedPoint[2] = 5; bool isInside = geometry->IsWorldPointInside(expectedPoint); MITK_TEST_CONDITION(isInside, "Point is inside Image..."); } void CheckPointInside_ImagePointOutside_False(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::Point3D expectedPoint; expectedPoint[0] = 100; expectedPoint[1] = 500; expectedPoint[2] = 500; bool isInside = geometry->IsWorldPointInside(expectedPoint); MITK_TEST_CONDITION(!isInside, "Point is outside Image..."); } void CheckBounds_Image_AsSet(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::BoundingBox::BoundsArrayType bound = geometry->GetBoundsInWorld(); bool isEqual = true; isEqual = isEqual && mitk::Equal(bound[0], -0.5*0.5); isEqual = isEqual && mitk::Equal(bound[1], 29.5*0.5); isEqual = isEqual && mitk::Equal(bound[2], -0.5*0.33); isEqual = isEqual && mitk::Equal(bound[3], 24.5*0.33); isEqual = isEqual && mitk::Equal(bound[4], -0.5*0.78); isEqual = isEqual && mitk::Equal(bound[5], 19.5*0.78); MITK_TEST_CONDITION(isEqual, "Bounds as precalculated..."); } void CheckExtent_Image_AsSet(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(DimX, DimY, DimZ, DimT,0.5,0.33,0.78,100); mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry(); mitk::BoundingBox::BoundsArrayType bound = geometry->GetBoundsInWorld(); bool isEqual = true; isEqual = isEqual && mitk::Equal(geometry->GetExtentInWorld(0), 30*0.5); isEqual = isEqual && mitk::Equal(geometry->GetExtentInWorld(1), 25*0.33); isEqual = isEqual && mitk::Equal(geometry->GetExtentInWorld(2), 20*0.78); MITK_TEST_CONDITION(isEqual, "Extent as precalculated..."); } }; int mitkTimeGeometryTest(int /*argc*/, char* /*argv*/[]) { MITK_TEST_BEGIN(mitkTimeGeometryTest); mitkTimeGeometryTestClass testClass; MITK_TEST_OUTPUT(<< "Test for 3D image"); - testClass.Translation_Image_MovedOrigin(30,25,20,1); - testClass.Rotate_Image_RotatedPoint(30,25,20,1); + mitk::Image::Pointer image = mitk::ImageGenerator::GenerateRandomImage(30, 25, 20, 1,0.5,0.33,0.78,100); + testClass.Translation_Image_MovedOrigin(image->Clone(),30,25,20,1); + testClass.Rotate_Image_RotatedPoint(image->Clone(),30,25,20,1); testClass.Scale_Image_ScaledPoint(30,25,20,1); - testClass.GetNumberOfTimeSteps_Image_ReturnDimT(30,25,20,1); - testClass.GetMinimumTimePoint_3DImage_Min(30,25,20,1); - testClass.GetMaximumTimePoint_3DImage_Max(30,25,20,1); - testClass.GetTimeBounds_3DImage_ZeroAndDimT(30,25,20,1); - testClass.IsValidTimePoint_ImageValidTimePoint_True(30,25,20,1); - testClass.IsValidTimeStep_ImageValidTimeStep_True(30,25,20,1); - testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(30,25,20,1); - testClass.IsValidTimeStep_ImageInvalidTimeStep_False(30,25,20,1); - testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(30,25,20,1); - testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(30,25,20,1); - testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(30,25,20,1); + testClass.GetNumberOfTimeSteps_Image_ReturnDimT(image->Clone(),30,25,20,1); + testClass.GetMinimumTimePoint_3DImage_Min(image->Clone(),30,25,20,1); + testClass.GetMaximumTimePoint_3DImage_Max(image->Clone(),30,25,20,1); + testClass.GetTimeBounds_3DImage_ZeroAndDimT(image->Clone(),30,25,20,1); + testClass.IsValidTimePoint_ImageValidTimePoint_True(image->Clone(),30,25,20,1); + testClass.IsValidTimeStep_ImageValidTimeStep_True(image->Clone(), 30,25,20,1); + testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(image->Clone(), 30,25,20,1); + testClass.IsValidTimeStep_ImageInvalidTimeStep_False(image->Clone(), 30,25,20,1); + testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(image->Clone(), 30,25,20,1); + testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(image->Clone(), 30,25,20,1); + testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(image->Clone(), 30,25,20,1); testClass.GetGeometryForTimeStep_ImageValidTimeStep_CorrectGeometry(30,25,20,1); testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(30,25,20,1); testClass.GetGeometryForTimePoint_ImageValidTimePoint_CorrectGeometry(30,25,20,1); testClass.GetGeometryCloneForTimeStep_ImageValidTimeStep_CorrectGeometry(30,25,20,1); testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(30,25,20,1); testClass.SetTimeStepGeometry_ImageValidTimeStep_CorrectGeometry(30,25,20,1); testClass.Expand_ImageDoubleSize_SizeChanged(30,25,20,1); testClass.CheckBounds_Image_PointsAsExpected(30,25,20,1); testClass.CheckLength_Image_AsExpected(30,25,20,1); testClass.CheckPointInside_ImagePointInside_True(30,25,20,1); testClass.CheckPointInside_ImagePointOutside_False(30,25,20,1); testClass.CheckBounds_Image_AsSet(30,25,20,1); testClass.CheckExtent_Image_AsSet(30,25,20,1); /* MITK_TEST_OUTPUT(<< "Test for 2D image"); testClass.Translation_Image_MovedOrigin(30,25,1 ,1); // Test with 2D-Image testClass.Rotate_Image_RotatedPoint(30,25,1 ,1); // Test with 2D-Image testClass.Scale_Image_ScaledPoint(30,25,1 ,1); // Test with 2D-Image */ MITK_TEST_OUTPUT(<< "Test for 3D+time image"); - testClass.Translation_Image_MovedOrigin(30,25,20,5); // Test with 3D+t-Image - testClass.Rotate_Image_RotatedPoint(30,25,20,5); // Test with 3D+t-Image + image = mitk::ImageGenerator::GenerateRandomImage(30, 25, 20, 5,0.5,0.33,0.78,100); + testClass.Translation_Image_MovedOrigin(image->Clone(),30,25,20,5); // Test with 3D+t-Image + testClass.Rotate_Image_RotatedPoint(image->Clone(),30,25,20,5); // Test with 3D+t-Image testClass.Scale_Image_ScaledPoint(30,25,20,5); // Test with 3D+t-Image - testClass.GetNumberOfTimeSteps_Image_ReturnDimT(30,25,20,5); + testClass.GetNumberOfTimeSteps_Image_ReturnDimT(image->Clone(),30,25,20,5); testClass.GetMinimumTimePoint_4DImage_Zero(30,25,20,5); testClass.GetMaximumTimePoint_4DImage_DimT(30,25,20,5); testClass.GetTimeBounds_4DImage_ZeroAndDimT(30,25,20,5); - testClass.IsValidTimePoint_ImageValidTimePoint_True(30,25,20,5); + testClass.IsValidTimePoint_ImageValidTimePoint_True(image->Clone(),30,25,20,5); testClass.IsValidTimePoint_ImageNegativInvalidTimePoint_False(30,25,20,5); testClass.IsValidTimePoint_ImageInvalidTimePoint_False(30,25,20,5); - testClass.IsValidTimeStep_ImageValidTimeStep_True(30,25,20,5); - testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(30,25,20,5); - testClass.IsValidTimeStep_ImageInvalidTimeStep_False(30,25,20,5); - testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(30,25,20,5); - testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(30,25,20,5); - testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(30,25,20,5); + testClass.IsValidTimeStep_ImageValidTimeStep_True(image->Clone(), 30,25,20,5); + testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(image->Clone(), 30,25,20,5); + testClass.IsValidTimeStep_ImageInvalidTimeStep_False(image->Clone(), 30,25,20,5); + testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(image->Clone(), 30,25,20,5); + testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(image->Clone(), 30,25,20,5); + testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(image->Clone(), 30,25,20,5); testClass.TimePointToTimeStep_4DImageInvalidTimePoint_TimePoint(30,25,20,5); testClass.TimePointToTimeStep_4DImageNegativInvalidTimePoint_TimePoint(30,25,20,5); testClass.GetGeometryForTimeStep_ImageValidTimeStep_CorrectGeometry(30,25,20,5); testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(30,25,20,5); testClass.GetGeometryForTimePoint_ImageValidTimePoint_CorrectGeometry(30,25,20,5); testClass.GetGeometryForTimePoint_4DImageInvalidTimePoint_NullPointer(30,25,20,5); testClass.GetGeometryForTimePoint_4DImageNEgativInvalidTimePoint_NullPointer(30,25,20,5); testClass.GetGeometryCloneForTimeStep_ImageValidTimeStep_CorrectGeometry(30,25,20,5); testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(30,25,20,5); testClass.SetTimeStepGeometry_ImageValidTimeStep_CorrectGeometry(30,25,20,5); testClass.Expand_ImageDoubleSize_SizeChanged(30,25,20,5); testClass.CheckBounds_Image_PointsAsExpected(30,25,20,5); testClass.CheckLength_Image_AsExpected(30,25,20,5); testClass.CheckPointInside_ImagePointInside_True(30,25,20,5); testClass.CheckPointInside_ImagePointOutside_False(30,25,20,5); testClass.CheckBounds_Image_AsSet(30,25,20,5); testClass.CheckExtent_Image_AsSet(30,25,20,5); /* MITK_TEST_OUTPUT(<< "Test for 2D+time image"); testClass.Translation_Image_MovedOrigin(30,25,1 ,5); // Test with 2D+t-Image testClass.Rotate_Image_RotatedPoint(30,25,1 ,5); // Test with 2D+t-Image testClass.Scale_Image_ScaledPoint(30,25,1 ,5); // Test with 2D+t-Image */ + + mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); + mitk::Point3D pointA, pointB, pointC; + pointA.Fill(1); + pointB.Fill(2); + pointC.Fill(3); + pointSet->SetPoint(1,pointA); + pointSet->SetPoint(2,pointB); + pointSet->SetPoint(3,pointC); + testClass.Translation_Image_MovedOrigin(pointSet->Clone(),30,25,20,1); + //testClass.Rotate_Image_RotatedPoint(pointSet->Clone(),30,25,20,1); + //testClass.Scale_Image_ScaledPoint(30,25,20,1); + testClass.GetNumberOfTimeSteps_Image_ReturnDimT(pointSet->Clone(),30,25,20,1); + testClass.GetMinimumTimePoint_3DImage_Min(pointSet->Clone(),30,25,20,1); + testClass.GetMaximumTimePoint_3DImage_Max(pointSet->Clone(),30,25,20,1); + testClass.GetTimeBounds_3DImage_ZeroAndDimT(pointSet->Clone(),30,25,20,1); + testClass.IsValidTimePoint_ImageValidTimePoint_True(pointSet->Clone(),30,25,20,1); + testClass.IsValidTimeStep_ImageValidTimeStep_True(pointSet->Clone(),30,25,20,1); + testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(pointSet->Clone(),30,25,20,1); + testClass.IsValidTimeStep_ImageInvalidTimeStep_False(pointSet->Clone(),30,25,20,1); + testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(pointSet->Clone(),30,25,20,1); + testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(pointSet->Clone(),30,25,20,1); + testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(pointSet->Clone(),30,25,20,1); + //testClass.GetGeometryForTimeStep_ImageValidTimeStep_CorrectGeometry(30,25,20,1); + //testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(30,25,20,1); + //testClass.GetGeometryForTimePoint_ImageValidTimePoint_CorrectGeometry(30,25,20,1); + //testClass.GetGeometryCloneForTimeStep_ImageValidTimeStep_CorrectGeometry(30,25,20,1); + //testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(30,25,20,1); + //testClass.SetTimeStepGeometry_ImageValidTimeStep_CorrectGeometry(30,25,20,1); + //testClass.Expand_ImageDoubleSize_SizeChanged(30,25,20,1); + //testClass.CheckBounds_Image_PointsAsExpected(30,25,20,1); + //testClass.CheckLength_Image_AsExpected(30,25,20,1); + //testClass.CheckPointInside_ImagePointInside_True(30,25,20,1); + //testClass.CheckPointInside_ImagePointOutside_False(30,25,20,1); + //testClass.CheckBounds_Image_AsSet(30,25,20,1); + //testClass.CheckExtent_Image_AsSet(30,25,20,1); + MITK_TEST_END(); return EXIT_SUCCESS; }