File: itkCorrespondingPointsEuclideanDistancePointMetricGTest.cxx

package info (click to toggle)
elastix 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 45,644 kB
  • sloc: cpp: 85,720; lisp: 4,118; python: 1,045; sh: 200; xml: 182; makefile: 33
file content (73 lines) | stat: -rw-r--r-- 3,623 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*=========================================================================
 *
 *  Copyright UMC Utrecht and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

// First include the header file to be tested:
#include "CorrespondingPointsEuclideanDistanceMetric/itkCorrespondingPointsEuclideanDistancePointMetric.h"
#include "itkAdvancedTranslationTransform.h"
#include "elxDefaultConstruct.h"
#include <itkPointSet.h>
#include <gtest/gtest.h>

// The template to be tested.
using itk::CorrespondingPointsEuclideanDistancePointMetric;

// Checks if a default-constructed CorrespondingPointsEuclideanDistancePointMetric has the expected properties.
GTEST_TEST(CorrespondingPointsEuclideanDistancePointMetric, DefaultConstruct)
{
  using PointSetType = itk::PointSet<double>;
  using MetricType = CorrespondingPointsEuclideanDistancePointMetric<PointSetType, PointSetType>;
  const elx::DefaultConstruct<MetricType>                                       defaultConstructedMetric{};
  const itk::SingleValuedPointSetToPointSetMetric<PointSetType, PointSetType> & pointSetToPointSetMetric =
    defaultConstructedMetric;

  EXPECT_EQ(pointSetToPointSetMetric.GetFixedPointSet(), nullptr);
  EXPECT_EQ(pointSetToPointSetMetric.GetMovingPointSet(), nullptr);
  EXPECT_EQ(pointSetToPointSetMetric.GetFixedImageMask(), nullptr);
  EXPECT_EQ(pointSetToPointSetMetric.GetMovingImageMask(), nullptr);
  EXPECT_EQ(pointSetToPointSetMetric.GetTransform(), nullptr);
  EXPECT_TRUE(pointSetToPointSetMetric.GetUseMetricSingleThreaded());

  // Note: `pointSetToPointSetMetric.m_NumberOfPointsCounted` is not public, and does not have a Get member function to
  // test its value.
}


// Checks if CorrespondingPointsEuclideanDistancePointMetric has the expected result on a minimal point set pair.
GTEST_TEST(CorrespondingPointsEuclideanDistancePointMetric, MinimalPointSets)
{
  using PointSetType = itk::PointSet<double>;
  using PointsVectorContainerType = PointSetType::PointsVectorContainer;
  using MetricType = CorrespondingPointsEuclideanDistancePointMetric<PointSetType, PointSetType>;

  elx::DefaultConstruct<itk::AdvancedTranslationTransform<double, PointSetType::PointDimension>> transform{};
  elx::DefaultConstruct<PointsVectorContainerType> fixedPointsVectorContainer{};

  fixedPointsVectorContainer.resize(PointSetType::PointDimension);
  elx::DefaultConstruct<PointsVectorContainerType> movingPointsVectorContainer{};
  movingPointsVectorContainer.CastToSTLContainer() = fixedPointsVectorContainer.CastToSTLConstContainer();
  elx::DefaultConstruct<PointSetType> fixedPointSet{};
  fixedPointSet.SetPoints(&fixedPointsVectorContainer);
  elx::DefaultConstruct<PointSetType> movingPointSet{};
  movingPointSet.SetPoints(&movingPointsVectorContainer);
  elx::DefaultConstruct<MetricType> metric{};
  metric.SetFixedPointSet(&fixedPointSet);
  metric.SetMovingPointSet(&movingPointSet);
  metric.SetTransform(&transform);
  metric.Initialize();
  EXPECT_EQ(metric.GetValue(transform.GetParameters()), 0);
}