ITK  4.2.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 
97  inline void QuadricAtOrigin(OutputQEType *iEdge, QuadricElementType & oQ)
98  {
99  OutputMeshPointer output = this->GetOutput();
100 
101  OutputPointIdentifier id[3];
102 
103  id[0] = iEdge->GetOrigin();
104  id[1] = iEdge->GetDestination();
105  id[2] = iEdge->GetOnext()->GetDestination();
106 
107  OutputPointType p[3];
108 
109  for ( int i = 0; i < 3; i++ )
110  {
111  p[i] = output->GetPoint(id[i]);
112  }
113 
114  oQ.AddTriangle(p[0], p[1], p[2]);
115  }
116 
121  inline MeasureType MeasureEdge(OutputQEType *iEdge)
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  OutputMeshPointer output = this->GetOutput();
128 
129  OutputPointType org = output->GetPoint(id_org);
130  OutputPointType dest = output->GetPoint(id_dest);
131 
132  OutputPointType mid;
133 
134  mid.SetToMidPoint(org, dest);
136 
137  return static_cast< MeasureType >( Q.ComputeError(p) );
138  }
139 
144  virtual void DeletePoint(const OutputPointIdentifier & iIdToBeDeleted,
145  const OutputPointIdentifier & iRemaining);
146 
151  OutputPointType Relocate(OutputQEType *iEdge);
152 
154  virtual void Initialize();
155 
156 private:
157  QuadricDecimationQuadEdgeMeshFilter(const Self &); // purposely not implemented
158  void operator=(const Self &); // purposely not implemented
159 
161 };
162 }
163 #ifndef ITK_MANUAL_INSTANTIATION
164 #include "itkQuadricDecimationQuadEdgeMeshFilter.hxx"
165 #endif
166 #endif
167