ITK  5.2.0
Insight Toolkit
itkQuadricDecimationQuadEdgeMeshFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 itkQuadricDecimationQuadEdgeMeshFilter_h
19 #define itkQuadricDecimationQuadEdgeMeshFilter_h
20 
23 
24 namespace itk
25 {
31 template <typename TInput, typename TOutput, typename TCriterion>
32 class ITK_TEMPLATE_EXPORT QuadricDecimationQuadEdgeMeshFilter
33  : public EdgeDecimationQuadEdgeMeshFilter<TInput, TOutput, TCriterion>
34 {
35 public:
36  ITK_DISALLOW_COPY_AND_MOVE(QuadricDecimationQuadEdgeMeshFilter);
37 
42 
45 
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;
56  using OutputCoordType = typename OutputPointType::CoordRepType;
57  using OutputQEType = typename OutputMeshType::QEType;
58  using OutputEdgeCellType = typename OutputMeshType::EdgeCellType;
59  using OutputCellsContainerIterator = typename OutputMeshType::CellsContainerIterator;
60  using OutputPointsContainerPointer = typename OutputMeshType::PointsContainerPointer;
61  using OutputPointsContainerIterator = typename OutputMeshType::PointsContainerIterator;
62 
63  static constexpr unsigned int OutputPointDimension = OutputMeshType::PointDimension;
64 
65  using CriterionType = TCriterion;
66  using MeasureType = typename CriterionType::MeasureType;
67 
68  using PriorityType = typename Superclass::PriorityType;
69  using PriorityQueueItemType = typename Superclass::PriorityQueueItemType;
70  using PriorityQueueType = typename Superclass::PriorityQueueType;
71  using PriorityQueuePointer = typename Superclass::PriorityQueuePointer;
72 
73  using QueueMapType = typename Superclass::QueueMapType;
74  using QueueMapIterator = typename Superclass::QueueMapIterator;
75 
76  using OperatorType = typename Superclass::OperatorType;
77  using OperatorPointer = typename Superclass::OperatorPointer;
78 
80 
81  using QuadricElementMapType = std::map<OutputPointIdentifier, QuadricElementType>;
82 
83  using QuadricElementMapIterator = typename QuadricElementMapType::iterator;
84 
85 protected:
88 
90  ~QuadricDecimationQuadEdgeMeshFilter() override = default;
91 
97  inline void
99  {
100  OutputPointIdentifier id[3];
101 
102  id[0] = iEdge->GetOrigin();
103  id[1] = iEdge->GetDestination();
104  id[2] = iEdge->GetOnext()->GetDestination();
105 
106  OutputPointType p[3];
107 
108  for (int i = 0; i < 3; i++)
109  {
110  p[i] = outputMesh->GetPoint(id[i]);
111  }
112 
113  oQ.AddTriangle(p[0], p[1], p[2]);
114  }
115 
120  MeasureType
121  MeasureEdge(OutputQEType * iEdge) override
122  {
123  OutputPointIdentifier id_org = iEdge->GetOrigin();
124  OutputPointIdentifier id_dest = iEdge->GetDestination();
125  QuadricElementType Q = m_Quadric[id_org] + m_Quadric[id_dest];
126 
127  OutputPointType org = this->m_OutputMesh->GetPoint(id_org);
128  OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest);
129 
130  OutputPointType mid;
131 
132  mid.SetToMidPoint(org, dest);
134 
135  return static_cast<MeasureType>(Q.ComputeError(p));
136  }
137 
142  void
143  DeletePoint(const OutputPointIdentifier & iIdToBeDeleted, const OutputPointIdentifier & iRemaining) override;
144 
149  OutputPointType
150  Relocate(OutputQEType * iEdge) override;
151 
153  void
154  Initialize() override;
155 
156 private:
158 };
159 } // namespace itk
160 #ifndef ITK_MANUAL_INSTANTIATION
161 # include "itkQuadricDecimationQuadEdgeMeshFilter.hxx"
162 #endif
163 #endif
itk::QuadricDecimationQuadEdgeMeshFilter::QuadricElementMapType
std::map< OutputPointIdentifier, QuadricElementType > QuadricElementMapType
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:81
itk::DecimationQuadEdgeMeshFilter::MeasureType
typename CriterionType::MeasureType MeasureType
Definition: itkDecimationQuadEdgeMeshFilter.h:53
itk::QuadricDecimationQuadEdgeMeshFilter::OutputCoordType
typename OutputPointType::CoordRepType OutputCoordType
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:56
itk::EdgeDecimationQuadEdgeMeshFilter::QueueMapIterator
typename QueueMapType::iterator QueueMapIterator
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:84
itk::EdgeDecimationQuadEdgeMeshFilter::OutputCellsContainerIterator
typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:67
itk::QuadEdgeMeshDecimationQuadricElementHelper::ComputeOptimalLocation
PointType ComputeOptimalLocation(const PointType &iP)
Definition: itkQuadEdgeMeshDecimationQuadricElementHelper.h:145
itk::EdgeDecimationQuadEdgeMeshFilter::QueueMapType
std::map< OutputQEType *, PriorityQueueItemType * > QueueMapType
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:82
itk::QuadricDecimationQuadEdgeMeshFilter::MeasureEdge
MeasureType MeasureEdge(OutputQEType *iEdge) override
Compute the measure value for iEdge.
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:121
itk::QuadricDecimationQuadEdgeMeshFilter::m_Quadric
QuadricElementMapType m_Quadric
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:157
itk::EdgeDecimationQuadEdgeMeshFilter::OutputQEType
typename OutputMeshType::QEType OutputQEType
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:62
itk::QuadricDecimationQuadEdgeMeshFilter::OutputPointsContainerPointer
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:60
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::EdgeDecimationQuadEdgeMeshFilter::OutputEdgeCellType
typename OutputMeshType::EdgeCellType OutputEdgeCellType
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:63
itk::SmartPointer< Self >
itk::DecimationQuadEdgeMeshFilter::CriterionType
TCriterion CriterionType
Definition: itkDecimationQuadEdgeMeshFilter.h:51
itk::EdgeDecimationQuadEdgeMeshFilter::OutputPointIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:59
itk::QuadricDecimationQuadEdgeMeshFilter::OutputPointsContainerIterator
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:61
itk::DecimationQuadEdgeMeshFilter::OutputMeshPointer
typename OutputMeshType::Pointer OutputMeshPointer
Definition: itkDecimationQuadEdgeMeshFilter.h:49
itk::DecimationQuadEdgeMeshFilter::InputMeshType
TInput InputMeshType
Definition: itkDecimationQuadEdgeMeshFilter.h:45
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::QuadricDecimationQuadEdgeMeshFilter
Quadric decimation.
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:32
itk::QuadricDecimationQuadEdgeMeshFilter::QuadricElementMapIterator
typename QuadricElementMapType::iterator QuadricElementMapIterator
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:83
itk::DecimationQuadEdgeMeshFilter::PriorityQueueItemType
typename CriterionType::PriorityQueueWrapperType PriorityQueueItemType
Definition: itkDecimationQuadEdgeMeshFilter.h:55
itk::QuadEdgeMeshDecimationQuadricElementHelper::AddTriangle
void AddTriangle(const PointType &iP1, const PointType &iP2, const PointType &iP3, const CoordType &iWeight=static_cast< CoordType >(1.))
Definition: itkQuadEdgeMeshDecimationQuadricElementHelper.h:172
itkQuadEdgeMeshDecimationQuadricElementHelper.h
itk::DecimationQuadEdgeMeshFilter::InputMeshPointer
typename InputMeshType::Pointer InputMeshPointer
Definition: itkDecimationQuadEdgeMeshFilter.h:46
itk::QuadEdgeMeshDecimationQuadricElementHelper::ComputeError
CoordType ComputeError(const PointType &iP) const
TODO this method should be really optimized!!!
Definition: itkQuadEdgeMeshDecimationQuadricElementHelper.h:100
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuadEdgeMeshEulerOperatorJoinVertexFunction
Collapse a given edge by joining its dest and its org.
Definition: itkQuadEdgeMeshEulerOperatorJoinVertexFunction.h:57
itk::EdgeDecimationQuadEdgeMeshFilter
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:40
itkEdgeDecimationQuadEdgeMeshFilter.h
itk::QuadEdgeMeshDecimationQuadricElementHelper
TODO explicit specification for VDimension=3!!!
Definition: itkQuadEdgeMeshDecimationQuadricElementHelper.h:32
itk::EdgeDecimationQuadEdgeMeshFilter::OutputPointType
typename OutputMeshType::PointType OutputPointType
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:60
itk::EdgeDecimationQuadEdgeMeshFilter::OperatorPointer
typename OperatorType::Pointer OperatorPointer
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:87
itk::DecimationQuadEdgeMeshFilter::PriorityType
typename CriterionType::PriorityType PriorityType
Definition: itkDecimationQuadEdgeMeshFilter.h:54
itk::DecimationQuadEdgeMeshFilter::OutputMeshType
TOutput OutputMeshType
Definition: itkDecimationQuadEdgeMeshFilter.h:48
itk::EdgeDecimationQuadEdgeMeshFilter::PriorityQueuePointer
typename PriorityQueueType::Pointer PriorityQueuePointer
Definition: itkEdgeDecimationQuadEdgeMeshFilter.h:80
itk::QuadricDecimationQuadEdgeMeshFilter::QuadricAtOrigin
void QuadricAtOrigin(OutputQEType *iEdge, QuadricElementType &oQ, OutputMeshType *outputMesh)
Compute the quadric error at the origin of the edge.
Definition: itkQuadricDecimationQuadEdgeMeshFilter.h:98
itk::PriorityQueueContainer
Definition: itkPriorityQueueContainer.h:193