23 CPPUNIT_TEST_SUITE(mitkPointSetOnEmptyTestSuite);
31 MITK_TEST(TestPointDataContainerCorrectAfterPointSetManipulation);
33 CPPUNIT_TEST_SUITE_END();
42 CPPUNIT_ASSERT_EQUAL_MESSAGE(
43 "PointContainer and PointDataContainer have same size",
true, pc->Size() == pd->Size());
44 mitk::PointSet::PointsContainer::ConstIterator pIt = pc->Begin();
45 mitk::PointSet::PointDataContainer::ConstIterator dIt = pd->Begin();
47 for (; pIt != pc->End(); ++pIt, ++dIt)
48 if (pIt->Index() != dIt->Index())
53 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Indices in PointContainer and PointDataContainer are equal",
false, failed);
63 void tearDown()
override { pointSet =
nullptr; }
64 void TestInstantiation() { CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing instantiation",
true, pointSet.IsNotNull()); }
65 void TestGetITKPointSet()
69 itkdata = pointSet->GetPointSet();
70 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"try to get the itkPointSet from a newly created PointSet",
true, itkdata.IsNotNull());
73 void TestGetSizeIsZero()
76 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet size is 0 ",
true, pointSet->GetSize() == 0);
81 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet is empty",
true, pointSet->IsEmptyTimeStep(0));
84 void TestAddPointDirectly()
91 pointSet->GetPointSet()->GetPoints()->InsertElement(
id, point);
93 CPPUNIT_ASSERT_EQUAL_MESSAGE(
94 "check if added points exists",
true, pointSet->GetSize() == 1 || pointSet->IndexExists(
id));
99 tempPoint = pointSet->GetPoint(
id);
101 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if added point contains real value",
true, point == tempPoint);
104 void TestPointSetClone(
void)
112 pointSet->InsertPoint(112, new1, 0);
113 pointSet->InsertPoint(2, new2, 0);
114 pointSet->InsertPoint(2, new0, 1);
115 pointSet->InsertPoint(1, new1, 1);
116 pointSet->InsertPoint(0, new2, 1);
117 pointSet->InsertPoint(0, new0, 2);
118 pointSet->InsertPoint(2, new1, 2);
119 pointSet->InsertPoint(1, new2, 2);
125 for (
unsigned int t = 0; t < pointSet->GetTimeSteps(); t++)
128 CPPUNIT_ASSERT_EQUAL_MESSAGE("
Clone has same size", true, pointSet->GetSize(t) == clonePS->GetSize(t));
131 for (
mitk::PointSet::PointsConstIterator i = pointSet->Begin(), j = clonePS->Begin();
132 i != pointSet->End() && j != clonePS->End();
135 CPPUNIT_ASSERT_EQUAL_MESSAGE(
136 "Cloned PS and PS have same points",
true, i.Index() == j.Index() &&
mitk::Equal(i.Value(), j.Value()));
142 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Valid point data container",
true, pointDataCont && clonePointDataCont);
143 CPPUNIT_ASSERT_EQUAL_MESSAGE(
144 "Cloned point data container has same size",
true, pointDataCont->Size() == clonePointDataCont->Size());
146 i != pointDataCont->End() && j != clonePointDataCont->End();
149 CPPUNIT_ASSERT_EQUAL_MESSAGE(
150 "Cloned PS and PS have same point data",
true, i.Index() == j.Index() && i.Value() == j.Value());
154 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet is not empty",
false, clonePS->IsEmptyTimeStep(0));
156 CPPUNIT_ASSERT_EQUAL_MESSAGE(
157 "Testing cloned point set's size!",
true, clonePS->GetPointSetSeriesSize() == pointSet->GetPointSetSeriesSize());
158 CPPUNIT_ASSERT_EQUAL_MESSAGE(
159 "Testing that the clone is not the source PS!",
true, clonePS.GetPointer() != pointSet.GetPointer());
160 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing if the geometry is cloned correctly!",
162 clonePS->GetGeometry()->GetCenter() == pointSet->GetGeometry()->GetCenter());
163 CPPUNIT_ASSERT_EQUAL_MESSAGE(
164 "Testing if the property list is cloned correctly!",
166 clonePS->GetPropertyList()->GetMap()->size() == pointSet->GetPropertyList()->GetMap()->size());
171 clonePS->InsertPoint(0, p);
172 pointSet->InsertPoint(0, p2);
173 p = clonePS->GetPoint(0);
174 p2 = pointSet->GetPoint(0);
175 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing that the clone is independent from source!",
true, p != p2);
178 void TestPointDataContainerCorrectAfterPointSetManipulation(
void)
181 MITK_TEST_OUTPUT(<<
"Test InsertPoint(), SetPoint() and SwapPointPosition()");
184 pointSet->InsertPoint(17, point);
185 pointSet->SetPoint(4, point);
186 pointSet->SetPoint(7, point);
187 pointSet->SetPoint(2, point);
188 pointSet->SwapPointPosition(7,
true);
189 pointSet->SwapPointPosition(3,
true);
190 pointSet->SwapPointPosition(2,
false);
191 TestPointContainerPointDataContainer(pointSet);
195 pointSet->ExecuteOperation(&op1);
197 pointSet->ExecuteOperation(&op1b);
198 TestPointContainerPointDataContainer(pointSet);
202 pointSet->ExecuteOperation(&op2);
204 pointSet->ExecuteOperation(&op3);
205 TestPointContainerPointDataContainer(pointSet);
209 pointSet->ExecuteOperation(&op4);
211 pointSet->ExecuteOperation(&op5);
212 TestPointContainerPointDataContainer(pointSet);
itk::SmartPointer< Self > Pointer
DataType::PointDataContainer PointDataContainer
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
DataCollection - Class to facilitate loading/accessing structured data.
Constants for most interaction classes, due to the generic StateMachines.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
DataType::PointDataContainerIterator PointDataConstIterator
#define MITK_TEST_OUTPUT(x)
Output some text.
Data structure which stores a set of points. Superclass of mitk::Mesh.
virtual DataType::Pointer GetPointSet(int t=0) const
returns the pointset
Test fixture for parameterized tests.
Operation that handles all actions on one Point.
DataType::PointsContainer PointsContainer
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.