Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkPhotoacousticTissueGeneratorTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <mitkTestFixture.h>
14 #include <mitkTestingMacros.h>
15 
16 #include "mitkPATissueGenerator.h"
17 
18 class mitkPhotoacousticTissueGeneratorTestSuite : public mitk::TestFixture
19 {
20  CPPUNIT_TEST_SUITE(mitkPhotoacousticTissueGeneratorTestSuite);
21  MITK_TEST(testCallWithEmptyParameters);
22  MITK_TEST(testCallWithWorkingParameters);
23  CPPUNIT_TEST_SUITE_END();
24 
25 private:
26 
27 public:
28 
29  void setUp() override
30  {
31  }
32 
33  mitk::pa::TissueGeneratorParameters::Pointer createRandomTestVolumeParameters()
34  {
35  auto returnParameters = mitk::pa::TissueGeneratorParameters::New();
36 
37  returnParameters->SetXDim(rand() % 50 + 1);
38  returnParameters->SetYDim(rand() % 50 + 1);
39  returnParameters->SetZDim(rand() % 50 + 1);
40  double absorb = rand() % 100 / 10.0;
41  returnParameters->SetMinBackgroundAbsorption(absorb);
42  returnParameters->SetMaxBackgroundAbsorption(absorb);
43  returnParameters->SetBackgroundScattering(rand() % 100 / 10.0);
44  returnParameters->SetBackgroundAnisotropy(rand() % 100 / 10.0);
45  int min = rand() % 10;
46  returnParameters->SetMinNumberOfVessels(min);
47  returnParameters->SetMaxNumberOfVessels(min + (rand() % 10));
48  returnParameters->SetCalculateNewVesselPositionCallback(
50  returnParameters->SetMinVesselZOrigin(rand() % 3 + 1);
51  returnParameters->SetMaxVesselZOrigin(rand() % 3 + 1);
52  int minRad = rand() % 100;
53  returnParameters->SetMinVesselRadiusInMillimeters(minRad);
54  returnParameters->SetMaxVesselRadiusInMillimeters(minRad + (rand() % 100));
55  returnParameters->SetVoxelSpacingInCentimeters(1);
56  return returnParameters;
57  }
58 
59  void testCallWithEmptyParameters()
60  {
61  auto parameters = mitk::pa::TissueGeneratorParameters::New();
63  CPPUNIT_ASSERT(volume.IsNotNull());
64  }
65 
66  void testCallWithWorkingParameters()
67  {
68  for (int i = 0; i < 20; i++)
69  {
70  auto parameters = createRandomTestVolumeParameters();
72  CPPUNIT_ASSERT(volume.IsNotNull());
73  }
74  }
75 
76  void tearDown() override
77  {
78  }
79 };
80 
81 MITK_TEST_SUITE_REGISTRATION(mitkPhotoacousticTissueGenerator)
void CalculateNewRandomlyDivergingDirectionVector(Vector::Pointer direction, double bendingFactor, std::mt19937 *rng)
CalculateRandomlyDivergingPosition calculates the new position by modifying the direction vector rand...
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static InSilicoTissueVolume::Pointer GenerateInSilicoData(TissueGeneratorParameters::Pointer parameters)
GenerateInSilicoData This method will return a InSilicoTissueVolume created in terms of the given par...
Test fixture for parameterized tests.
static T min(T x, T y)
Definition: svm.cpp:53