ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkQuadricDecimationQuadEdgeMeshFilter.h
Go to the documentation of this file.
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 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:
40  TInput, TOutput, TCriterion > Superclass;
41 
44 
46  itkNewMacro(Self);
47 
48  typedef TInput InputMeshType;
49  typedef typename InputMeshType::Pointer InputMeshPointer;
50 
51  typedef TOutput OutputMeshType;
52  typedef typename OutputMeshType::Pointer OutputMeshPointer;
53  typedef typename OutputMeshType::PointIdentifier OutputPointIdentifier;
55  typedef typename OutputPointType::CoordRepType OutputCoordType;
56  typedef typename OutputMeshType::QEType OutputQEType;
57  typedef typename OutputMeshType::EdgeCellType OutputEdgeCellType;
58  typedef typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator;
59  typedef typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer;
60  typedef typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator;
61 
62  itkStaticConstMacro(OutputPointDimension, unsigned int, OutputMeshType::PointDimension);
63 
64  typedef TCriterion CriterionType;
65  typedef typename CriterionType::MeasureType MeasureType;
66 
67  typedef typename Superclass::PriorityType PriorityType;
68  typedef typename Superclass::PriorityQueueItemType PriorityQueueItemType;
69  typedef typename Superclass::PriorityQueueType PriorityQueueType;
70  typedef typename Superclass::PriorityQueuePointer PriorityQueuePointer;
71 
72  typedef typename Superclass::QueueMapType QueueMapType;
73  typedef typename Superclass::QueueMapIterator QueueMapIterator;
74 
75  typedef typename Superclass::OperatorType OperatorType;
76  typedef typename Superclass::OperatorPointer OperatorPointer;
77 
80 
81  typedef std::map< OutputPointIdentifier, QuadricElementType >
83 
84  typedef typename QuadricElementMapType::iterator QuadricElementMapIterator;
85 
86 protected:
89 
91  virtual ~QuadricDecimationQuadEdgeMeshFilter() ITK_OVERRIDE;
92 
98  inline void QuadricAtOrigin(OutputQEType *iEdge, QuadricElementType & oQ, OutputMeshType *outputMesh)
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 MeasureEdge(OutputQEType *iEdge) ITK_OVERRIDE
121  {
122  OutputPointIdentifier id_org = iEdge->GetOrigin();
123  OutputPointIdentifier id_dest = iEdge->GetDestination();
124  QuadricElementType Q = m_Quadric[id_org] + m_Quadric[id_dest];
125 
126  OutputPointType org = this->m_OutputMesh->GetPoint(id_org);
127  OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest);
128 
129  OutputPointType mid;
130 
131  mid.SetToMidPoint(org, dest);
133 
134  return static_cast< MeasureType >( Q.ComputeError(p) );
135  }
136 
141  virtual void DeletePoint(const OutputPointIdentifier & iIdToBeDeleted,
142  const OutputPointIdentifier & iRemaining) ITK_OVERRIDE;
143 
148  OutputPointType Relocate(OutputQEType *iEdge) ITK_OVERRIDE;
149 
151  virtual void Initialize() ITK_OVERRIDE;
152 
153 private:
154  ITK_DISALLOW_COPY_AND_ASSIGN(QuadricDecimationQuadEdgeMeshFilter);
155 
156  QuadricElementMapType m_Quadric;
157 };
158 }
159 #ifndef ITK_MANUAL_INSTANTIATION
160 #include "itkQuadricDecimationQuadEdgeMeshFilter.hxx"
161 #endif
162 #endif
Light weight base class for most itk classes.
OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
std::map< OutputPointIdentifier, QuadricElementType > QuadricElementMapType
OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
CoordType ComputeError(const PointType &iP) const
TODO this method should be really optimized!!!
OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
EdgeDecimationQuadEdgeMeshFilter< TInput, TOutput, TCriterion > Superclass
MeasureType MeasureEdge(OutputQEType *iEdge) override
Compute the measure value for iEdge.
QuadEdgeMeshDecimationQuadricElementHelper< OutputPointType > QuadricElementType