ITK  6.0.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 * https://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
24namespace itk
25{
31template <typename TInput, typename TOutput, typename TCriterion>
32class ITK_TEMPLATE_EXPORT QuadricDecimationQuadEdgeMeshFilter
33 : public EdgeDecimationQuadEdgeMeshFilter<TInput, TOutput, TCriterion>
34{
35public:
36 ITK_DISALLOW_COPY_AND_MOVE(QuadricDecimationQuadEdgeMeshFilter);
37
42
44 itkOverrideGetNameOfClassMacro(QuadricDecimationQuadEdgeMeshFilter);
45
47 itkNewMacro(Self);
48
49 using InputMeshType = TInput;
51
52 using OutputMeshType = TOutput;
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 typename Superclass::PriorityType;
69 using typename Superclass::PriorityQueueItemType;
70 using typename Superclass::PriorityQueueType;
71 using typename Superclass::PriorityQueuePointer;
72
73 using typename Superclass::QueueMapType;
74 using typename Superclass::QueueMapIterator;
75
76 using typename Superclass::OperatorType;
77 using typename Superclass::OperatorPointer;
78
80
81 using QuadricElementMapType = std::map<OutputPointIdentifier, QuadricElementType>;
82
83 using QuadricElementMapIterator = typename QuadricElementMapType::iterator;
84
85protected:
88
91
97 inline void
99 {
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
150 Relocate(OutputQEType * iEdge) override;
151
153 void
154 Initialize() override;
155
156private:
158};
159} // namespace itk
160#ifndef ITK_MANUAL_INSTANTIATION
161# include "itkQuadricDecimationQuadEdgeMeshFilter.hxx"
162#endif
163#endif
typename InputMeshType::Pointer InputMeshPointer
typename CriterionType::MeasureType MeasureType
typename OutputMeshType::Pointer OutputMeshPointer
typename OutputMeshType::PointIdentifier OutputPointIdentifier
typename OutputMeshType::EdgeCellType OutputEdgeCellType
typename OutputMeshType::CellsContainerIterator OutputCellsContainerIterator
Light weight base class for most itk classes.
CoordType ComputeError(const PointType &iP) const
TODO this method should be really optimized!!!
void AddTriangle(const PointType &iP1, const PointType &iP2, const PointType &iP3, const CoordType &iWeight=static_cast< CoordType >(1.))
void QuadricAtOrigin(OutputQEType *iEdge, QuadricElementType &oQ, OutputMeshType *outputMesh)
Compute the quadric error at the origin of the edge.
QuadricDecimationQuadEdgeMeshFilter()=default
Constructor.
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
void Initialize() override
Compute Quadric error for all edges.
~QuadricDecimationQuadEdgeMeshFilter() override=default
Destructor.
void DeletePoint(const OutputPointIdentifier &iIdToBeDeleted, const OutputPointIdentifier &iRemaining) override
Delete point.
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
std::map< OutputPointIdentifier, QuadricElementType > QuadricElementMapType
typename QuadricElementMapType::iterator QuadricElementMapIterator
OutputPointType Relocate(OutputQEType *iEdge) override
Compute the optimal position for a given edge iEdge.
MeasureType MeasureEdge(OutputQEType *iEdge) override
Compute the measure value for iEdge.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....