]> Creatis software - cpMesh.git/blob - lib/cpm/Algorithms/QuadEdge/EdgeDecimationFilter.h
First commit
[cpMesh.git] / lib / cpm / Algorithms / QuadEdge / EdgeDecimationFilter.h
1 #ifndef __CPM__ALGORITHMS__QUADEDGE__EDGEDECIMATIONFILTER__H__
2 #define __CPM__ALGORITHMS__QUADEDGE__EDGEDECIMATIONFILTER__H__
3
4 #include <map>
5
6 #include <itkPriorityQueueContainer.h>
7
8 #include <cpm/Algorithms/QuadEdge/DecimationFilter.h>
9 #include <cpm/Algorithms/QuadEdge/MeshEulerOperatorJoinVertexFunction.h>
10
11 namespace cpm
12 {
13   namespace Algorithms
14   {
15     namespace QuadEdge
16     {
17       /**
18        */
19       template< class I, class O, class C >
20       class EdgeDecimationFilter
21         : public DecimationFilter< I, O, C >
22       {
23       public:
24         typedef EdgeDecimationFilter            Self;
25         typedef DecimationFilter< I, O, C >     Superclass;
26         typedef itk::SmartPointer< Self >       Pointer;
27         typedef itk::SmartPointer< const Self > ConstPointer;
28
29         typedef I TInputMesh;
30         typedef O TOutputMesh;
31         typedef C TCriterion;
32
33         typedef typename O::PointType       TOutPoint;
34         typedef typename O::PointIdentifier TOutPointIdentifier;
35         typedef typename O::TPrimalEdge     TOutPrimalEdge;
36
37         typedef typename C::TPriority     TPriority;
38         typedef typename C::TQueueWrapper TQueueWrapper;
39         typedef typename C::TQueueWrapper TPriorityQueueItem;
40         typedef typename C::TScalar       TScalar;
41
42         typedef std::map< TOutPrimalEdge*, TPriorityQueueItem* > TQueueMap;
43         typedef MeshEulerOperatorJoinVertexFunction< O >         TOperator;
44
45         typedef itk::PriorityQueueContainer< TPriorityQueueItem*, itk::ElementWrapperPointerInterface< TPriorityQueueItem* >, TPriority > TPriorityQueue;
46
47       public:
48         itkTypeMacro( EdgeDecimationFilter, DecimationFilter );
49
50       protected:
51         EdgeDecimationFilter( );
52         virtual ~EdgeDecimationFilter( );
53
54         virtual TScalar MeasureEdge( TOutPrimalEdge* iEdge ) = 0;
55         void FillPriorityQueue( );
56         void PushElement( TOutPrimalEdge* iEdge );
57         bool IsEdgeOKToBeProcessed( TOutPrimalEdge* iEdge );
58         void Extract( );
59         void DeleteElement( TOutPrimalEdge* iEdge );
60         virtual void DeletePoint(
61           const TOutPointIdentifier& iIdToBeDeleted,
62           const TOutPointIdentifier& iRemaining
63           );
64         virtual void PushOrUpdateElement( TOutPrimalEdge* iEdge );
65         virtual void JoinVertexFailed( );
66         virtual bool ProcessWithoutAnyTopologicalGuarantee( );
67         virtual unsigned int CheckQEProcessingStatus( );
68         virtual bool ProcessWithTopologicalGuarantee( );
69         unsigned long NumberOfCommonVerticesIn0Ring( ) const;
70         void RemoveSamosa( );
71         void TagElementOut( TOutPrimalEdge* iEdge );
72         void RemoveEye( );
73         virtual TOutPoint Relocate( TOutPrimalEdge* iEdge ) = 0;
74         bool CheckOrientation(
75           TOutPrimalEdge* iEdge,
76           const TOutPointIdentifier& iId,
77           const TOutPoint& iPt
78           );
79         bool IsCriterionSatisfied( );
80
81       private:
82         // Purposely not implemented
83         EdgeDecimationFilter( const Self& );
84         void operator=( const Self& );
85
86       protected:
87         bool m_Relocate;
88         bool m_CheckOrientation;
89
90         typename TPriorityQueue::Pointer m_PriorityQueue;
91         typename TOperator::Pointer      m_JoinVertexFunction;
92
93         TQueueMap       m_QueueMapper;
94         TOutPrimalEdge* m_Element;
95         TPriority       m_Priority;
96       };
97
98     } // ecapseman
99
100   } // ecapseman
101
102 } // ecapseman
103
104 #include <cpm/Algorithms/QuadEdge/EdgeDecimationFilter.hxx>
105
106 #endif // __CPM__ALGORITHMS__QUADEDGE__EDGEDECIMATIONFILTER__H__
107
108 // eof - $RCSfile$