Orfeo Toolbox  4.0
itkCellInterface.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkCellInterface_h
19 #define __itkCellInterface_h
20 
21 #include "itkObject.h"
22 #include <map>
24 #include "itkAutoPointer.h"
25 #include "itkArray.h"
26 
27 // Define a macro for CellInterface sub-classes to use
28 // to define the Accept and GetTopologyId virtuals used
29 // by the MultiVisitor class
30 #define itkCellVisitMacro(TopologyId) \
31  static int GetTopologyId() \
32  { \
33  return TopologyId; \
34  } \
35  virtual void Accept(CellIdentifier cellid, typename CellInterface< PixelType, \
36  CellTraits >::MultiVisitor * mv) \
37  { \
38  typename CellInterfaceVisitor< PixelType, CellTraits >::Pointer v = \
39  mv->GetVisitor(TopologyId); \
40  if ( v ) \
41  { \
42  v->VisitFromCell(cellid, this); \
43  } \
44  }
45 
46 // Define a macro for the common typedefs required by the
47 // classes deriving form CellInterface (included).
48 #define itkCellCommonTypedefs(celltype) \
49  typedef celltype Self; \
50  typedef AutoPointer< const Self > ConstSelfAutoPointer; \
51  typedef AutoPointer< Self > SelfAutoPointer; \
52  typedef Self * RawPointer; \
53  typedef const Self *ConstRawPointer
54 
55 // Define a macro for the common typedefs required by the
56 // classes deriving form CellInterface (excluded).
57 #define itkCellInheritedTypedefs(superclassArg) \
58  typedef superclassArg Superclass; \
59  typedef typename Superclass::PixelType PixelType; \
60  typedef typename Superclass::CellType CellType; \
61  typedef typename Superclass::CellAutoPointer CellAutoPointer; \
62  typedef typename Superclass::CellConstAutoPointer CellConstAutoPointer; \
63  typedef typename Superclass::CellRawPointer CellRawPointer; \
64  typedef typename Superclass::CellConstRawPointer CellConstRawPointer; \
65  typedef typename Superclass::CellTraits CellTraits; \
66  typedef typename Superclass::CoordRepType CoordRepType; \
67  typedef typename Superclass::InterpolationWeightType \
68  InterpolationWeightType; \
69  typedef typename Superclass::PointIdentifier PointIdentifier; \
70  typedef typename Superclass::PointIdIterator PointIdIterator; \
71  typedef typename Superclass::PointIdConstIterator PointIdConstIterator; \
72  typedef typename Superclass::CellIdentifier CellIdentifier; \
73  typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier; \
74  typedef typename Superclass::CellFeatureIdentifier CellFeatureCount; \
75  typedef typename Superclass::PointType PointType; \
76  typedef typename Superclass::VectorType VectorType; \
77  typedef typename Superclass::PointsContainer PointsContainer; \
78  typedef typename Superclass::UsingCellsContainer UsingCellsContainer; \
79  typedef typename Superclass::CellGeometry CellGeometry; \
80  typedef typename Superclass::ParametricCoordArrayType \
81  ParametricCoordArrayType; \
82  typedef typename Superclass::ShapeFunctionsArrayType \
83  ShapeFunctionsArrayType; \
84  itkStaticConstMacro(PointDimension, unsigned int, Superclass::PointDimension)
85 
86 namespace itk
87 {
100 template<
101  typename TPixelType,
102  typename TCellTraits
103  >
105 {
106 public:
107 
110 
112  typedef TPixelType PixelType;
113 
115  typedef TCellTraits CellTraits;
116 
118  typedef typename CellTraits::CoordRepType CoordRepType;
119  typedef typename CellTraits::InterpolationWeightType InterpolationWeightType;
120  typedef typename CellTraits::PointIdentifier PointIdentifier;
121  typedef typename CellTraits::PointIdIterator PointIdIterator;
122  typedef typename CellTraits::PointIdConstIterator PointIdConstIterator;
123  typedef typename CellTraits::CellIdentifier CellIdentifier;
124  typedef typename CellTraits::CellFeatureIdentifier CellFeatureIdentifier;
125  typedef typename CellTraits::PointType PointType;
126  typedef typename CellTraits::PointsContainer PointsContainer;
127  typedef typename CellTraits::UsingCellsContainer UsingCellsContainer;
128 
131 
133  itkStaticConstMacro(PointDimension, unsigned int, CellTraits::PointDimension);
134 
136  typedef typename UsingCellsContainer::iterator UsingCellsContainerIterator;
137 
140  typedef SelfAutoPointer CellAutoPointer;
141  typedef ConstSelfAutoPointer CellConstAutoPointer;
142  typedef RawPointer CellRawPointer;
143  typedef ConstRawPointer CellConstRawPointer;
144 
147 
153 
157 
158 // static int GetNextUserCellId(); // never return > MAX_INTERFACE
159 
169  {
170 public:
174 
178 
180  //itkNewMacro(Self);
181  static Pointer New(void) { Pointer smartPtr = new Self; smartPtr->UnRegister(); return smartPtr; }
182 
184  itkTypeMacro(MultiVisitor, LightObject);
185 
187  typedef typename VisitorType::Pointer VisitorPointer;
188  typedef typename std::map< int, VisitorPointer >::value_type
190 
191 public:
193  {
194  if ( id < LAST_ITK_CELL )
195  {
196  return m_Visitors[id];
197  }
198  else
199  {
200  typename std::map< int, typename VisitorType::Pointer >::iterator
201  pos = m_UserDefined.find(id);
202  if ( pos != m_UserDefined.end() )
203  {
204  return ( *pos ).second;
205  }
206  }
207  return 0;
208  }
209 
211  {
212  int id = v->GetCellTopologyId();
213 
214  if ( id < LAST_ITK_CELL )
215  {
216  m_Visitors[id] = v;
217  }
218  else
219  {
220  m_UserDefined.insert( VisitorPointerValueType(id, v) );
221  }
222  }
223 
224  virtual ~MultiVisitor() {}
225 
226 protected:
227  VisitorPointer m_Visitors[LAST_ITK_CELL]; // fixed array set to the
228  // size
229  // from the enum
230  std::map< int, VisitorPointer > m_UserDefined; // user defined cell types
231  // go here
232  };
233 
235  virtual void Accept(CellIdentifier cellId, MultiVisitor *) = 0;
236 
239  virtual CellGeometry GetType(void) const = 0;
240 
243  virtual void MakeCopy(CellAutoPointer &) const = 0;
244 
246  virtual unsigned int GetDimension(void) const = 0;
247 
249  virtual unsigned int GetInterpolationOrder(void) const;
250 
252  virtual unsigned int GetNumberOfPoints(void) const = 0;
253 
255  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const = 0;
256 
258  virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier,
259  CellAutoPointer &) = 0;
260 
264  virtual PointIdConstIterator GetPointIds(void) const;
265 
269  virtual void SetPointIds(PointIdConstIterator first) = 0;
270 
275  virtual void SetPointIds(PointIdConstIterator first,
276  PointIdConstIterator last) = 0;
277 
280  virtual void SetPointId(int localId, PointIdentifier) = 0;
281 
283  virtual PointIdIterator PointIdsBegin(void) = 0;
284 
287  virtual PointIdConstIterator PointIdsBegin(void) const = 0;
288 
290  virtual PointIdIterator PointIdsEnd(void) = 0;
291 
294  virtual PointIdConstIterator PointIdsEnd(void) const = 0;
295 
300 
306  { return false; }
307 
325  PointsContainer *,
326  CoordRepType *,
327  CoordRepType[],
328  double *,
330  { return bool(); }
331 
336  const ParametricCoordArrayType &,
337  ShapeFunctionsArrayType &) const {}
338 
355  CoordRepType[PointDimension],
356  CoordRepType,
357  CoordRepType[PointDimension],
358  CoordRepType *,
359  CoordRepType[]) { return bool(); }
360 
366 
369 
383  CoordRepType[PointDimension],
384  CoordRepType[PointDimension],
385  CoordRepType[PointDimension],
386  CoordRepType *) { return bool(); }
387 
393  virtual bool IsExplicitBoundary(void);
394 
399  virtual void AddUsingCell(CellIdentifier cellId);
400 
404  virtual void RemoveUsingCell(CellIdentifier cellId);
405 
411  virtual bool IsUsingCell(CellIdentifier cellId);
412 
416  virtual unsigned int GetNumberOfUsingCells(void);
417 
418 #if !defined( CABLE_CONFIGURATION )
419 
423 
428 
429 #endif
430 
432  itkTypeMacro(CellInterface, LightObject);
433 
434 public:
436  virtual ~CellInterface() {}
440 // bool GetPointPosition(PointsContainer*, int localId, Point*)=0;
441 
442 protected:
445 
446 private:
447  CellInterface(const Self &); //purposely not implemented
448  void operator=(const Self &); //purposely not implemented
449 };
450 
469 template< int VPointDimension, typename TCoordRep,
470  typename TInterpolationWeight, typename TPointIdentifier,
471  typename TCellIdentifier, typename TCellFeatureIdentifier,
472  typename TPoint, typename TPointsContainer,
473  typename TUsingCellsContainer >
475 {
476 public:
477  itkStaticConstMacro(PointDimension, unsigned int, VPointDimension);
478  typedef TCoordRep CoordRepType;
479  typedef TInterpolationWeight InterpolationWeightType;
480  typedef TPointIdentifier PointIdentifier;
481  typedef TCellIdentifier CellIdentifier;
482  typedef TCellFeatureIdentifier CellFeatureIdentifier;
483  typedef TPoint PointType;
484  typedef TPointsContainer PointsContainer;
485  typedef TUsingCellsContainer UsingCellsContainer;
487 
489 };
490 
491 #define itkMakeCellTraitsMacro \
492  CellTraitsInfo < itkGetStaticConstMacro(PointDimension), CoordRepType, \
493  InterpolationWeightType, \
494  PointIdentifier, CellIdentifier, CellFeatureIdentifier, \
495  PointType, PointsContainer, UsingCellsContainer >
496 } // end namespace itk
497 
498 #if !defined( CABLE_CONFIGURATION )
499 #ifndef ITK_MANUAL_INSTANTIATION
500 #include "itkCellInterface.hxx"
501 #endif
502 #endif
503 
504 #endif

Generated at Sat Mar 8 2014 14:25:38 for Orfeo Toolbox with doxygen 1.8.3.1