35 CPPUNIT_TEST_SUITE(mitkPointSetOnEmptyTestSuite);
43 MITK_TEST(TestPointDataContainerCorrectAfterPointSetManipulation);
45 CPPUNIT_TEST_SUITE_END();
54 CPPUNIT_ASSERT_EQUAL_MESSAGE(
55 "PointContainer and PointDataContainer have same size",
true, pc->Size() == pd->Size());
56 mitk::PointSet::PointsContainer::ConstIterator pIt = pc->Begin();
57 mitk::PointSet::PointDataContainer::ConstIterator dIt = pd->Begin();
59 for (; pIt != pc->End(); ++pIt, ++dIt)
60 if (pIt->Index() != dIt->Index())
65 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Indices in PointContainer and PointDataContainer are equal",
false, failed);
75 void tearDown()
override { pointSet =
nullptr; }
76 void TestInstantiation() { CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing instantiation",
true, pointSet.IsNotNull()); }
77 void TestGetITKPointSet()
80 mitk::PointSet::DataType::Pointer itkdata =
nullptr;
81 itkdata = pointSet->GetPointSet();
82 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"try to get the itkPointSet from a newly created PointSet",
true, itkdata.IsNotNull());
85 void TestGetSizeIsZero()
88 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet size is 0 ",
true, pointSet->GetSize() == 0);
93 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet is empty",
true, pointSet->IsEmptyTimeStep(0));
96 void TestAddPointDirectly()
103 pointSet->GetPointSet()->GetPoints()->InsertElement(
id, point);
105 CPPUNIT_ASSERT_EQUAL_MESSAGE(
106 "check if added points exists",
true, pointSet->GetSize() == 1 || pointSet->IndexExists(
id));
111 tempPoint = pointSet->GetPoint(
id);
113 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if added point contains real value",
true, point == tempPoint);
116 void TestPointSetClone(
void)
124 pointSet->InsertPoint(112, new1, 0);
125 pointSet->InsertPoint(2, new2, 0);
126 pointSet->InsertPoint(2, new0, 1);
127 pointSet->InsertPoint(1, new1, 1);
128 pointSet->InsertPoint(0, new2, 1);
129 pointSet->InsertPoint(0, new0, 2);
130 pointSet->InsertPoint(2, new1, 2);
131 pointSet->InsertPoint(1, new2, 2);
137 for (
unsigned int t = 0; t < pointSet->GetTimeSteps(); t++)
140 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Clone has same size",
true, pointSet->GetSize(t) == clonePS->GetSize(t));
144 i != pointSet->End() && j != clonePS->End();
147 CPPUNIT_ASSERT_EQUAL_MESSAGE(
148 "Cloned PS and PS have same points",
true, i.Index() == j.Index() &&
mitk::Equal(i.Value(), j.Value()));
154 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Valid point data container",
true, pointDataCont && clonePointDataCont);
155 CPPUNIT_ASSERT_EQUAL_MESSAGE(
156 "Cloned point data container has same size",
true, pointDataCont->Size() == clonePointDataCont->Size());
158 i != pointDataCont->End() && j != clonePointDataCont->End();
161 CPPUNIT_ASSERT_EQUAL_MESSAGE(
162 "Cloned PS and PS have same point data",
true, i.Index() == j.Index() && i.Value() == j.Value());
166 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet is not empty",
false, clonePS->IsEmptyTimeStep(0));
168 CPPUNIT_ASSERT_EQUAL_MESSAGE(
169 "Testing cloned point set's size!",
true, clonePS->GetPointSetSeriesSize() == pointSet->GetPointSetSeriesSize());
170 CPPUNIT_ASSERT_EQUAL_MESSAGE(
171 "Testing that the clone is not the source PS!",
true, clonePS.GetPointer() != pointSet.GetPointer());
172 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing if the geometry is cloned correctly!",
174 clonePS->GetGeometry()->GetCenter() == pointSet->GetGeometry()->GetCenter());
175 CPPUNIT_ASSERT_EQUAL_MESSAGE(
176 "Testing if the property list is cloned correctly!",
178 clonePS->GetPropertyList()->GetMap()->size() == pointSet->GetPropertyList()->GetMap()->size());
183 clonePS->InsertPoint(0, p);
184 pointSet->InsertPoint(0, p2);
185 p = clonePS->GetPoint(0);
186 p2 = pointSet->GetPoint(0);
187 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Testing that the clone is independent from source!",
true, p != p2);
190 void TestPointDataContainerCorrectAfterPointSetManipulation(
void)
193 MITK_TEST_OUTPUT(<<
"Test InsertPoint(), SetPoint() and SwapPointPosition()");
196 pointSet->InsertPoint(17, point);
197 pointSet->SetPoint(4, point);
198 pointSet->SetPoint(7, point);
199 pointSet->SetPoint(2, point);
200 pointSet->SwapPointPosition(7,
true);
201 pointSet->SwapPointPosition(3,
true);
202 pointSet->SwapPointPosition(2,
false);
203 TestPointContainerPointDataContainer(pointSet);
207 pointSet->ExecuteOperation(&op1);
209 pointSet->ExecuteOperation(&op1b);
210 TestPointContainerPointDataContainer(pointSet);
214 pointSet->ExecuteOperation(&op2);
216 pointSet->ExecuteOperation(&op3);
217 TestPointContainerPointDataContainer(pointSet);
221 pointSet->ExecuteOperation(&op4);
223 pointSet->ExecuteOperation(&op5);
224 TestPointContainerPointDataContainer(pointSet);
DataType::PointDataContainer PointDataContainer
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
Constants for most interaction classes, due to the generic StateMachines.
DataType::PointsContainer::ConstIterator PointsConstIterator
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.