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