Orfeo Toolbox  3.16
itkCellInterface.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkCellInterface.h,v $
5  Language: C++
6  Date: $Date: 2009-08-08 20:13:35 $
7  Version: $Revision: 1.72 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkCellInterface_h
18 #define __itkCellInterface_h
19 
20 #include "itkObject.h"
21 #include "itkObjectFactory.h"
22 #include <map>
24 #include "itkAutoPointer.h"
25 #include "itkArray.h"
26 
27 
28 // Define a macro for CellInterface sub-classes to use
29 // to define the Accept and GetTopologyId virtuals used
30 // by the MultiVisitor class
31 #define itkCellVisitMacro(TopologyId) \
32 static int GetTopologyId() {return TopologyId;}\
33 virtual void Accept(unsigned long cellid, typename CellInterface<PixelType,\
34  CellTraits>::MultiVisitor* mv)\
35 {\
36  typename CellInterfaceVisitor<PixelType, CellTraits>::Pointer v = \
37  mv->GetVisitor(TopologyId);\
38  if(v)\
39  {\
40  v->VisitFromCell(cellid, this);\
41  }\
42 }
43 
44 
45 // Define a macro for the common typedefs required by the
46 // classes deriving form CellInterface (included).
47 // This wouldn't be necessary if SGI compilers
48 // were able to inherit types.
49 #define itkCellCommonTypedefs( celltype ) \
50  typedef celltype Self; \
51  typedef AutoPointer<const Self> ConstSelfAutoPointer; \
52  typedef AutoPointer<Self> SelfAutoPointer; \
53  typedef Self * RawPointer; \
54  typedef const Self * ConstRawPointer
55 
56 
57 // Define a macro for the common typedefs required by the
58 // classes deriving form CellInterface (excluded).
59 // This wouldn't be necessary if SGI compilers
60 // were able to inherit types.
61 #define itkCellInheritedTypedefs( superclassArg ) \
62  typedef superclassArg Superclass; \
63  typedef typename Superclass::PixelType PixelType; \
64  typedef typename Superclass::CellType CellType; \
65  typedef typename Superclass::CellAutoPointer CellAutoPointer; \
66  typedef typename Superclass::CellConstAutoPointer CellConstAutoPointer; \
67  typedef typename Superclass::CellRawPointer CellRawPointer; \
68  typedef typename Superclass::CellConstRawPointer CellConstRawPointer; \
69  typedef typename Superclass::CellTraits CellTraits; \
70  typedef typename Superclass::CoordRepType CoordRepType; \
71  typedef typename Superclass::InterpolationWeightType \
72  InterpolationWeightType; \
73  typedef typename Superclass::PointIdentifier PointIdentifier; \
74  typedef typename Superclass::PointIdIterator PointIdIterator; \
75  typedef typename Superclass::PointIdConstIterator PointIdConstIterator; \
76  typedef typename Superclass::CellIdentifier CellIdentifier; \
77  typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier; \
78  typedef typename Superclass::CellFeatureIdentifier CellFeatureCount; \
79  typedef typename Superclass::PointType PointType; \
80  typedef typename Superclass::VectorType VectorType; \
81  typedef typename Superclass::PointsContainer PointsContainer; \
82  typedef typename Superclass::UsingCellsContainer UsingCellsContainer; \
83  typedef typename Superclass::CellGeometry CellGeometry; \
84  typedef typename Superclass::ParametricCoordArrayType \
85  ParametricCoordArrayType; \
86  typedef typename Superclass::ShapeFunctionsArrayType \
87  ShapeFunctionsArrayType; \
88  itkStaticConstMacro(PointDimension, unsigned int, Superclass::PointDimension)
89 
90 
91 namespace itk
92 {
93 
106 template <
107  typename TPixelType,
108  typename TCellTraits
109  >
111 {
112 public:
113 
116 
118  typedef TPixelType PixelType;
119 
121  typedef TCellTraits CellTraits;
122 
124  typedef typename CellTraits::CoordRepType CoordRepType;
125  typedef typename CellTraits::InterpolationWeightType InterpolationWeightType;
126  typedef typename CellTraits::PointIdentifier PointIdentifier;
127  typedef typename CellTraits::PointIdIterator PointIdIterator;
128  typedef typename CellTraits::PointIdConstIterator PointIdConstIterator;
129  typedef typename CellTraits::CellIdentifier CellIdentifier;
130  typedef typename CellTraits::CellFeatureIdentifier CellFeatureIdentifier;
131  typedef typename CellTraits::PointType PointType;
132  typedef typename CellTraits::PointsContainer PointsContainer;
133  typedef typename CellTraits::UsingCellsContainer UsingCellsContainer;
134 
137 
139  itkStaticConstMacro(PointDimension, unsigned int,CellTraits::PointDimension);
140 
142  typedef typename UsingCellsContainer::iterator UsingCellsContainerIterator;
143 
146  typedef SelfAutoPointer CellAutoPointer;
147  typedef ConstSelfAutoPointer CellConstAutoPointer;
148  typedef RawPointer CellRawPointer;
149  typedef ConstRawPointer CellConstRawPointer;
150 
153 
159 
163 
164 // static int GetNextUserCellId(); // never return > MAX_INTERFACE
165 
172  class MultiVisitor : public LightObject
173  {
174  public:
178 
182 
184  //itkNewMacro(Self);
185  static Pointer New(void) { Pointer smartPtr = new Self; smartPtr->UnRegister(); return smartPtr;}
186 
188  itkTypeMacro(MultiVisitor,LightObject);
189 
191  typedef typename VisitorType::Pointer VisitorPointer;
194 
195  public:
197  {
198  if(id <= LAST_ITK_CELL)
199  {
200  return m_Visitors[id];
201  }
202  else
203  {
204  typename std::map<int, ITK_TYPENAME VisitorType::Pointer>::iterator
205  pos = m_UserDefined.find(id);
206  if(pos != m_UserDefined.end())
207  {
208  return (*pos).second;
209  }
210  }
211  return 0;
212  }
213 
215  {
216  int id = v->GetCellTopologyId();
217  if(id <= LAST_ITK_CELL)
218  {
219  m_Visitors[id] = v;
220  }
221  else
222  {
224  }
225  }
226  virtual ~MultiVisitor() {}
227 
228  protected:
229  VisitorPointer m_Visitors[LAST_ITK_CELL]; // fixed array set to the size
230  // from the enum
231  std::map<int,VisitorPointer> m_UserDefined; // user defined cell types
232  // go here
233  };
234 
236  virtual void Accept(unsigned long cellId, MultiVisitor*)= 0;
237 
240  virtual CellGeometry GetType(void) const =0;
241 
244  virtual void MakeCopy( CellAutoPointer & ) const = 0;
245 
247  virtual unsigned int GetDimension(void) const=0;
248 
250  virtual unsigned int GetInterpolationOrder(void) const;
251 
253  virtual unsigned int GetNumberOfPoints(void) const=0;
254 
256  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const =0;
257 
259  virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier,
260  CellAutoPointer & )=0;
261 
265  virtual PointIdConstIterator GetPointIds(void) const;
266 
270  virtual void SetPointIds(PointIdConstIterator first)=0;
271 
276  virtual void SetPointIds(PointIdConstIterator first,
277  PointIdConstIterator last)=0;
278 
281  virtual void SetPointId(int localId, PointIdentifier)=0;
282 
284  virtual PointIdIterator PointIdsBegin(void)=0;
285 
288  virtual PointIdConstIterator PointIdsBegin(void) const =0;
289 
291  virtual PointIdIterator PointIdsEnd(void)=0;
292 
295  virtual PointIdConstIterator PointIdsEnd(void) const =0;
296 
301  virtual bool GetClosestBoundary(CoordRepType [], bool* , CellAutoPointer &)
302  {return false;}
303 
321  PointsContainer* ,
322  CoordRepType* ,
323  CoordRepType [],
324  double *,
326  {return bool();}
327 
331  virtual void EvaluateShapeFunctions(
332  const ParametricCoordArrayType &,
333  ShapeFunctionsArrayType &) const {}
334 
351  CoordRepType [PointDimension],
352  CoordRepType ,
353  CoordRepType [PointDimension],
354  CoordRepType*,
355  CoordRepType []) {return bool();}
356 
362 
365 
379  CoordRepType [PointDimension],
380  CoordRepType [PointDimension],
381  CoordRepType [PointDimension],
382  CoordRepType* ) {return bool();}
383 
389  virtual bool IsExplicitBoundary(void);
390 
395  virtual void AddUsingCell(CellIdentifier cellId);
396 
400  virtual void RemoveUsingCell(CellIdentifier cellId);
401 
407  virtual bool IsUsingCell(CellIdentifier cellId);
408 
412  virtual unsigned int GetNumberOfUsingCells(void);
413 
414 #if !defined(CABLE_CONFIGURATION)
415 
419 
424 #endif
425 
427  itkTypeMacro(CellInterface, LightObject);
428 
429 public:
431  virtual ~CellInterface() {}
435 // bool GetPointPosition(PointsContainer*, int localId, Point*)=0;
436 
437 protected:
440 
441 private:
442  CellInterface(const Self&); //purposely not implemented
443  void operator=(const Self&); //purposely not implemented
444 };
445 
446 
464 template <int VPointDimension, typename TCoordRep,
465  typename TInterpolationWeight, typename TPointIdentifier,
466  typename TCellIdentifier, typename TCellFeatureIdentifier,
467  typename TPoint, typename TPointsContainer,
468  typename TUsingCellsContainer>
470 {
471 public:
472  itkStaticConstMacro(PointDimension, unsigned int, VPointDimension);
473  typedef TCoordRep CoordRepType;
474  typedef TInterpolationWeight InterpolationWeightType;
475  typedef TPointIdentifier PointIdentifier;
476  typedef TCellIdentifier CellIdentifier;
477  typedef TCellFeatureIdentifier CellFeatureIdentifier;
478  typedef TPoint PointType;
479  typedef TPointsContainer PointsContainer;
480  typedef TUsingCellsContainer UsingCellsContainer;
483 };
484 
485 #define itkMakeCellTraitsMacro \
486  CellTraitsInfo<itkGetStaticConstMacro(PointDimension), CoordRepType, \
487  InterpolationWeightType, \
488  PointIdentifier, CellIdentifier, CellFeatureIdentifier, \
489  PointType, PointsContainer, UsingCellsContainer>
490 
491 } // end namespace itk
492 
493 #if !defined(CABLE_CONFIGURATION)
494 # ifndef ITK_MANUAL_INSTANTIATION
495 #include "itkCellInterface.txx"
496 #endif
497 #endif
498 
499 #endif

Generated at Sat Feb 2 2013 23:31:22 for Orfeo Toolbox with doxygen 1.8.1.1