ITK  4.6.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 >
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 
71 
74 
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 
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 
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
MeasureType MeasureEdge(OutputQEType *iEdge)
Compute the measure value for iEdge.
Light weight base class for most itk classes.
QuadEdgeMeshEulerOperatorJoinVertexFunction< OutputMeshType, OutputQEType > OperatorType
void QuadricAtOrigin(OutputQEType *iEdge, QuadricElementType &oQ, OutputMeshType *outputMesh)
Compute the quadric error at the origin of the edge.
OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
OutputPointType Relocate(OutputQEType *iEdge)
Compute the optimal position for a given edge iEdge.
std::map< OutputPointIdentifier, QuadricElementType > QuadricElementMapType
virtual void DeletePoint(const OutputPointIdentifier &iIdToBeDeleted, const OutputPointIdentifier &iRemaining)
Delete point.
virtual ~QuadricDecimationQuadEdgeMeshFilter()
Destructor.
OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
std::map< OutputQEType *, PriorityQueueItemType * > QueueMapType
CoordType ComputeError(const PointType &iP) const
TODO this method should be really optimized!!!
OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
EdgeDecimationQuadEdgeMeshFilter< TInput, TOutput, TCriterion > Superclass
virtual void Initialize()
Compute Quadric error for all edges.
CriterionType::PriorityQueueWrapperType PriorityQueueItemType
PriorityQueueContainer< PriorityQueueItemType *, ElementWrapperPointerInterface< PriorityQueueItemType * >, PriorityType > PriorityQueueType
QuadEdgeMeshDecimationQuadricElementHelper< OutputPointType > QuadricElementType
void AddTriangle(const PointType &iP1, const PointType &iP2, const PointType &iP3, const CoordType &iWeight=static_cast< CoordType >(1.))