]> Creatis software - cpMesh.git/blob - lib/cpm/Algorithms/Simplex/DeformationFilter.h
First commit
[cpMesh.git] / lib / cpm / Algorithms / Simplex / DeformationFilter.h
1 #ifndef __CPM__ALGORITHMS__SIMPLEX__DEFORMATIONFILTER__H__
2 #define __CPM__ALGORITHMS__SIMPLEX__DEFORMATIONFILTER__H__
3
4 #include <utility>
5 #include <vector>
6 #include <itkEventObject.h>
7 #include <cpm/Algorithms/Base/InPlaceMeshFilter.h>
8 #include <cpm/Algorithms/Base/ForceFunction.h>
9
10 namespace cpm
11 {
12   namespace Algorithms
13   {
14     namespace Simplex
15     {
16       /**
17        */
18       template< class M >
19       class DeformationFilter
20         : public cpm::Algorithms::Base::InPlaceMeshFilter< M >
21       {
22       public:
23         typedef DeformationFilter                             Self;
24         typedef cpm::Algorithms::Base::InPlaceMeshFilter< M > Superclass;
25         typedef itk::SmartPointer< Self >                     Pointer;
26         typedef itk::SmartPointer< const Self >               ConstPointer;
27
28         typedef M TMesh;
29         typedef typename M::PointIdentifier TPointId;
30         typedef typename M::ValueType       TScalar;
31
32         typedef cpm::Algorithms::Base::ForceFunction< M > TForceFunction;
33         typedef typename TForceFunction::Pointer          PtrFunction;
34         typedef std::pair< PtrFunction, TScalar >         TFunctionPair;
35         typedef std::vector< TFunctionPair >              TFunctionContainer;
36
37         /**
38          */
39         class AllMeshUpdatedEvent
40           : public itk::EventObject
41         {
42         public:
43           AllMeshUpdatedEvent( ) { }
44           AllMeshUpdatedEvent( const AllMeshUpdatedEvent& b ) { }
45           virtual ~AllMeshUpdatedEvent( ) { }
46           itk::EventObject* MakeObject( ) const
47             { return( new AllMeshUpdatedEvent( ) ); }
48           virtual const char* GetEventName( ) const
49             {
50               return(
51                 "cpm::Algoritms::Simplex::DeformationFilter::AllMeshUpdatedEvent"
52                 );
53             }
54           virtual bool CheckEvent( const itk::EventObject* e ) const
55             {
56               return(
57                 dynamic_cast< const AllMeshUpdatedEvent* >( e ) != NULL
58                 );
59             }
60         private:
61           AllMeshUpdatedEvent& operator=( const AllMeshUpdatedEvent& b );
62         };
63
64         /**
65          */
66         class PointUpdatedEvent
67           : public itk::EventObject
68         {
69         public:
70           PointUpdatedEvent( )
71             : PointId( TPointId( 0 ) )
72             { }
73           PointUpdatedEvent( const TPointId& pId )
74             : PointId( pId )
75             { }
76           PointUpdatedEvent( const PointUpdatedEvent& b )
77             : PointId( b.PointId )
78             { }
79           virtual ~PointUpdatedEvent( ) { }
80           itk::EventObject* MakeObject( ) const
81             { return( new PointUpdatedEvent( ) ); }
82           virtual const char* GetEventName( ) const
83             {
84               return(
85                 "cpm::Algoritms::Simplex::DeformationFilter::PointUpdatedEvent"
86                 );
87             }
88           virtual bool CheckEvent( const itk::EventObject* e ) const
89             {
90               return(
91                 dynamic_cast< const PointUpdatedEvent* >( e ) != NULL
92                 );
93             }
94         private:
95           PointUpdatedEvent& operator=( const PointUpdatedEvent& b );
96         public:
97           TPointId PointId;
98         };
99
100       public:
101         itkNewMacro( Self );
102         itkTypeMacro( DeformationFilter, InPlaceMeshFilter );
103
104         itkGetConstMacro( Damping, TScalar );
105         itkSetMacro( Damping, TScalar );
106
107       public:
108         void AddForce( TForceFunction* f, const TScalar& w );
109
110       protected:
111         DeformationFilter( );
112         virtual ~DeformationFilter( );
113
114         virtual void GenerateData( );
115
116       private:
117         DeformationFilter( const Self& );
118         Self& operator=( const Self& );
119
120       protected:
121         TFunctionContainer m_Forces;
122         TScalar m_Damping;
123       };
124
125     } // ecapseman
126
127   } // ecapseman
128
129 } // ecapseman
130
131 #include <cpm/Algorithms/Simplex/DeformationFilter.hxx>
132
133 #endif // __CPM__ALGORITHMS__SIMPLEX__DEFORMATIONFILTER__H__
134
135 // eof - $RCSfile$