1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter_h
19 #define itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter_h
20 
21 #include "itkEdgeDecimationQuadEdgeMeshFilter.h"
22 
23 namespace itk
24 {
25 /**
26  * \class SquaredEdgeLengthDecimationQuadEdgeMeshFilter
27  * \brief
28  * \ingroup ITKQuadEdgeMeshFiltering
29  */
30 template< typename TInput, typename TOutput, typename TCriterion >
31 class ITK_TEMPLATE_EXPORT SquaredEdgeLengthDecimationQuadEdgeMeshFilter:
32   public EdgeDecimationQuadEdgeMeshFilter< TInput, TOutput, TCriterion >
33 {
34 public:
35   ITK_DISALLOW_COPY_AND_ASSIGN(SquaredEdgeLengthDecimationQuadEdgeMeshFilter);
36 
37   using Self = SquaredEdgeLengthDecimationQuadEdgeMeshFilter;
38   using Pointer = SmartPointer< Self >;
39   using ConstPointer = SmartPointer< const Self >;
40   using Superclass = EdgeDecimationQuadEdgeMeshFilter<
41     TInput, TOutput, TCriterion >;
42 
43   /** Run-time type information (and related methods).   */
44   itkTypeMacro(SquaredEdgeLengthDecimationQuadEdgeMeshFilter, EdgeDecimationQuadEdgeMeshFilter);
45 
46   /** New macro for creation of through a Smart Pointer   */
47   itkNewMacro(Self);
48 
49   using InputMeshType = TInput;
50   using InputMeshPointer = typename InputMeshType::Pointer;
51 
52   using OutputMeshType = TOutput;
53   using OutputMeshPointer = typename OutputMeshType::Pointer;
54   using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
55   using OutputPointType = typename OutputMeshType::PointType;
56   using OutputQEType = typename OutputMeshType::QEType;
57   using OutputEdgeCellType = typename OutputMeshType::EdgeCellType;
58   using OutputCellsContainerIterator = typename OutputMeshType::CellsContainerIterator;
59 
60   using CriterionType = TCriterion;
61   using MeasureType = typename CriterionType::MeasureType;
62 
63   using PriorityType = typename Superclass::PriorityType;
64   using PriorityQueueItemType = typename Superclass::PriorityQueueItemType;
65   using PriorityQueueType = typename Superclass::PriorityQueueType;
66   using PriorityQueuePointer = typename Superclass::PriorityQueuePointer;
67 
68   using QueueMapType = typename Superclass::QueueMapType;
69   using QueueMapIterator = typename Superclass::QueueMapIterator;
70 
71   using OperatorType = typename Superclass::OperatorType;
72   using OperatorPointer = typename Superclass::OperatorPointer;
73 
74 protected:
75   SquaredEdgeLengthDecimationQuadEdgeMeshFilter();
76   ~SquaredEdgeLengthDecimationQuadEdgeMeshFilter() override = default;
77 
78   // keep the start of this documentation text on very first comment line,
79   // it prevents a Doxygen bug
80   /** Compute the measure value for iEdge.
81    *
82    * \param[in] iEdge
83    * \return measure value, here the squared edge length
84    */
MeasureEdge(OutputQEType * iEdge)85   MeasureType MeasureEdge(OutputQEType *iEdge) override
86     {
87     OutputPointIdentifier id_org = iEdge->GetOrigin();
88     OutputPointIdentifier id_dest = iEdge->GetDestination();
89 
90     OutputPointType org = this->m_OutputMesh->GetPoint(id_org);
91     OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest);
92 
93     return static_cast< MeasureType >( org.SquaredEuclideanDistanceTo(dest) );
94     }
95 
96   // keep the start of this documentation text on very first comment line,
97   // it prevents a Doxygen bug
98   /** Calculate the position of the remaining vertex from collapsing iEdge.
99    *
100    * \param[in] iEdge
101    * \return the optimal point location
102    */
103   OutputPointType Relocate(OutputQEType *iEdge) override;
104 };
105 }
106 
107 #include "itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.hxx"
108 #endif
109