]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h
...
[cpPlugins.git] / lib / cpPlugins / Extensions / DataStructures / QuadEdgeMesh.h
1 #ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__
2 #define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__
3
4 #include <set>
5 #include <vector>
6
7 #include <itkMesh.h>
8 #include <cpPlugins/Extensions/DataStructures/QuadEdgeCell.h>
9 #include <cpPlugins/Extensions/DataStructures/QuadEdge.h>
10
11 namespace cpPlugins
12 {
13   namespace Extensions
14   {
15     namespace DataStructures
16     {
17       /**
18        */
19       template< typename P, unsigned int D = 3, typename T = itk::DefaultStaticMeshTraits< P, D, D > >
20       class QuadEdgeMesh
21         : public itk::Mesh< P, D, T >
22       {
23       public:
24         typedef QuadEdgeMesh                    Self;
25         typedef itk::Mesh< P, D, T >            Superclass;
26         typedef itk::SmartPointer< Self >       Pointer;
27         typedef itk::SmartPointer< const Self > ConstPointer;
28
29         /// Types from superclass
30         typedef typename
31         Superclass::BoundaryAssignmentsContainer
32         BoundaryAssignmentsContainer;
33
34         typedef typename
35         Superclass::BoundaryAssignmentsContainerPointer
36         BoundaryAssignmentsContainerPointer;
37
38         typedef typename Superclass::BoundingBoxType       BoundingBoxType;
39         typedef typename Superclass::CellAutoPointer       CellAutoPointer;
40         typedef typename Superclass::CellsContainer        CellsContainer;
41         typedef typename Superclass::CellDataContainer     CellDataContainer;
42         typedef typename Superclass::CellFeatureCount      CellFeatureCount;
43         typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier;
44         typedef typename Superclass::CellIdentifier        CellIdentifier;
45         typedef typename Superclass::CellLinksContainer    CellLinksContainer;
46         typedef typename Superclass::CellMultiVisitorType  CellMultiVisitorType;
47         typedef typename Superclass::CellPixelType         CellPixelType;
48         typedef typename Superclass::CellType              CellType;
49         typedef typename Superclass::PointIdentifier       PointIdentifier;
50         typedef typename Superclass::PointsContainer       PointsContainer;
51         typedef typename Superclass::PointType             PointType;
52
53         /// QuadEdge types (primal and dual)
54         typedef QuadEdge< PointIdentifier, CellIdentifier > TPrimalEdge;
55         typedef typename TPrimalEdge::TDual                 TDualEdge;
56         typedef QuadEdgeCell< CellType, TPrimalEdge >       TQuadEdgeCell;
57
58         /// Memory management objects
59         typedef std::set< typename TPrimalEdge::Pointer > CntPrimalEdges;
60         typedef std::set< typename TDualEdge::Pointer >   CntDualEdges;
61         typedef std::vector< TPrimalEdge* > CntOnextRings;
62
63         /// More geometry types
64         typedef typename PointType::VectorType      VectorType;
65         typedef typename VectorType::ValueType      TScalar;
66         typedef std::vector< VectorType >           CntNormals;
67         typedef typename CntNormals::const_iterator NormalsIterator;
68
69       protected:
70         typedef std::vector< TPrimalEdge* > _TEdges;
71
72       public:
73         itkNewMacro( Self );
74         itkTypeMacro( QuadEdgeMesh, itkMesh );
75
76       public:
77         // Edge related methods
78         TPrimalEdge* FindEdge( const PointIdentifier& a ) const;
79         TPrimalEdge* FindEdge(
80           const PointIdentifier& a, const PointIdentifier& b
81           ) const;
82         TPrimalEdge* FindEntryEdge( const CellIdentifier& i ) const;
83
84         /// New geometric methods
85         const CntNormals& GetPointNormalsContainer( ) const;
86         NormalsIterator BeginPointNormals( ) const;
87         NormalsIterator EndPointNormals( ) const;
88         const VectorType& GetPointNormal( const PointIdentifier& id ) const;
89
90         /// itk::DataObject methods overloading 
91         virtual bool RequestedRegionIsOutsideOfTheBufferedRegion( );
92
93         /// itk::PointSet methods overloading 
94         virtual void SetPoints( PointsContainer* points );
95         virtual void SetPoint( PointIdentifier id , PointType point );
96
97         /// itk::Mesh methods overloading
98         virtual void PassStructure( Self* inputMesh )
99           {
100             std::cout << "PassStructure" << std::endl;
101             std::exit( 1 );
102           }
103
104         virtual void Initialize( );
105         virtual void Graft( const itk::DataObject* data );
106
107         void SetCellLinks( CellLinksContainer* cellLinks )
108           {
109             std::cout << "SetCellLinks" << std::endl;
110             std::exit( 1 );
111           }
112         virtual CellLinksContainer* GetCellLinks( )
113           {
114             std::cout << "GetCellLinks" << std::endl;
115             std::exit( 1 );
116           }
117         virtual const CellLinksContainer* GetCellLinks( ) const
118           {
119             std::cout << "GetCellLinks (const)" << std::endl;
120             std::exit( 1 );
121           }
122         virtual void SetCells( CellsContainer* cells );
123         virtual void SetCellData( CellDataContainer* data );
124         virtual CellDataContainer* GetCellData( )
125           {
126             std::cout << "GetCellData" << std::endl;
127             std::exit( 1 );
128           }
129         virtual const CellDataContainer* GetCellData( ) const
130           {
131             std::cout << "GetCellData (const)" << std::endl;
132             std::exit( 1 );
133           }
134
135 #if !defined( CABLE_CONFIGURATION )
136         virtual void SetBoundaryAssignments(
137           int dimension, BoundaryAssignmentsContainer* container
138           )
139           {
140             std::cout << "SetBoundaryAssignments" << std::endl;
141             std::exit( 1 );
142           }
143         virtual BoundaryAssignmentsContainerPointer
144         GetBoundaryAssignments( int dimension )
145           {
146             std::cout << "GetBoundaryAssignments" << std::endl;
147             std::exit( 1 );
148           }
149         virtual const BoundaryAssignmentsContainerPointer
150         GetBoundaryAssignments( int dimension ) const
151           {
152             std::cout << "GetBoundaryAssignments (const)" << std::endl;
153             std::exit( 1 );
154           }
155 #endif
156
157         virtual void SetCell( CellIdentifier id, CellAutoPointer& ptr );
158         virtual void SetCellData( CellIdentifier id, CellPixelType data );
159         virtual bool GetCellData( CellIdentifier id, CellPixelType* data ) const
160           {
161             std::cout << "GetCellData" << std::endl;
162             std::exit( 1 );
163           }
164         virtual void SetBoundaryAssignment(
165           int dimension, CellIdentifier cellId,
166           CellFeatureIdentifier featureId,
167           CellIdentifier boundaryId
168           )
169           {
170             std::cout << "SetBoundaryAssignment" << std::endl;
171             std::exit( 1 );
172           }
173         virtual bool GetBoundaryAssignment(
174           int dimension, CellIdentifier cellId,
175           CellFeatureIdentifier featureId,
176           CellIdentifier* boundaryId
177           ) const
178           {
179             std::cout << "GetBoundaryAssignment" << std::endl;
180             std::exit( 1 );
181           }
182         virtual bool RemoveBoundaryAssignment(
183           int dimension, CellIdentifier cellId,
184           CellFeatureIdentifier featureId
185           )
186           {
187             std::cout << "RemoveBoundaryAssignment" << std::endl;
188             std::exit( 1 );
189           }
190         virtual CellFeatureCount GetNumberOfCellBoundaryFeatures(
191           int dimension,
192           CellIdentifier id
193           ) const
194           {
195             std::cout << "GetNumberOfCellBoundaryFeatures" << std::endl;
196             std::exit( 1 );
197           }
198         virtual bool GetCellBoundaryFeature(
199           int dimension, CellIdentifier id,
200           CellFeatureIdentifier fid,
201           CellAutoPointer& ptr
202           ) const
203           {
204             std::cout << "GetCellBoundaryFeature" << std::endl;
205             std::exit( 1 );
206           }
207         virtual CellIdentifier GetCellBoundaryFeatureNeighbors( 
208           int dimension,
209           CellIdentifier id,
210           CellFeatureIdentifier fid,
211           std::set< CellIdentifier >* cellSet )
212           {
213             std::cout << "GetCellBoundaryFeatureNeighbors" << std::endl;
214             std::exit( 1 );
215           }
216         virtual CellIdentifier GetCellNeighbors(
217           CellIdentifier cellId,
218           std::set< CellIdentifier >* cellSet
219           )
220           {
221             std::cout << "GetCellNeighbors" << std::endl;
222             std::exit( 1 );
223           }
224         virtual bool GetAssignedCellBoundaryIfOneExists(
225           int dimension, CellIdentifier id,
226           CellFeatureIdentifier fid,
227           CellAutoPointer& ptr
228           ) const
229           {
230             std::cout << "GetAssignedCellBoundaryIfOneExists" << std::endl;
231             std::exit( 1 );
232           }
233         virtual void BuildCellLinks( ) const;
234
235         virtual void Accept( CellMultiVisitorType* mv ) const
236           {
237             std::cout << "Accept" << std::endl;
238             std::exit( 1 );
239           }
240
241       protected:
242         QuadEdgeMesh( );
243         virtual ~QuadEdgeMesh( );
244
245         virtual void ReleaseCellsMemory( )
246           {
247             std::cout << "ReleaseCellsMemory" << std::endl;
248             std::exit( 1 );
249           }
250
251         inline bool _CheckPoints( const CellAutoPointer& ptr ) const;
252         inline void _DeletePoint( const PointIdentifier& pId );
253         inline TPrimalEdge* _CreateQuadEdge(
254           const PointIdentifier& a, const PointIdentifier& b
255           );
256         inline void _DeleteEdge( TPrimalEdge* edge );
257         inline void _DeleteFace( const CellIdentifier& f );
258         inline void _ConstructEdges(
259           _TEdges& edges, const CellAutoPointer& ptr
260           );
261         virtual VectorType _ComputePointNormal( const TPrimalEdge* e ) const;
262         inline void _ReleaseQuadEdgeObjects( );
263
264       private:
265         QuadEdgeMesh( const Self& );   // Not implemented
266         void operator=( const Self& ); // Not implemented
267
268       protected:
269         CntPrimalEdges m_PrimalEdges;
270         CntDualEdges   m_DualEdges;
271
272         CntOnextRings m_OnextRings;
273
274         CntNormals m_PointNormals;
275       };
276
277     } // ecapseman
278
279   } // ecapseman
280
281 } // ecapseman
282
283 #include <cpPlugins/Extensions/DataStructures/QuadEdgeMesh.hxx>
284
285 #endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__
286
287 // eof - $RCSfile$