ITK  4.4.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< class TInput, class TOutput, class TCriterion >
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;
54  typedef typename OutputMeshType::PointType OutputPointType;
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 
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  inline MeasureType MeasureEdge(OutputQEType *iEdge)
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);
143 
148  OutputPointType Relocate(OutputQEType *iEdge);
149 
151  virtual void Initialize();
152 
153 private:
154  QuadricDecimationQuadEdgeMeshFilter(const Self &); // purposely not implemented
155  void operator=(const Self &); // purposely not implemented
156 
158 };
159 }
160 #ifndef ITK_MANUAL_INSTANTIATION
161 #include "itkQuadricDecimationQuadEdgeMeshFilter.hxx"
162 #endif
163 #endif
164