KWStyle - itkCellInterfaceVisitor.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkCellInterfaceVisitor.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:33 $
7   Version:   $Revision: 1.4 $
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 __itkCellInterfaceVisitor_h
18 #define __itkCellInterfaceVisitor_h
19
20 #include "itkLightObject.h"
21 #include "itkObjectFactory.h"
22
23 namespace itk
24 {
25 // forward reference CellInterface
26 template <
27   typename TPixelType,
28   typename TCellTraits
29
30 class CellInterface;
31   
32 /** \class CellInterfaceVisitor
33  * Define the abstract interface for a visitor class that can visit the
34  * cells in a Mesh.  This follows the Visitor Design Pattern.   To make
35  * this class easier to use, the CellInterfaceVisitorImplementation is 
36  * provided as a templated class to implement the pure virtual functions
37  * of CellInterfaceVisitor.
38  *
39  * \ingroup MeshAccess 
40  */
41 template <
42   typename TPixelType,
43   typename TCellTraits
44 >  
45 class CellInterfaceVisitor : public LightObject
46 {
47 public: 
48   /** Standard class typedefs. */
49   typedef CellInterfaceVisitor       Self;
50 TDA   typedef LightObject  Superclass;
51 TDA   typedef SmartPointer<Self>  Pointer;
52 TDA   typedef SmartPointer<const Self>  ConstPointer;
53     
54   /** Run-time type information (and related methods). */
55   itkTypeMacro(CellInterfaceVisitor,LightObject);
56
57   /** This method is called by each cell as it visits this visitor. */
58 LEN   virtual void VisitFromCell(unsigned long cellId, CellInterface<TPixelType, TCellTraits>*) = 0;
59
60   /**  Return the index of the CellTopology. */
61   virtual int GetCellTopologyId() = 0;
62   
63 protected:
64   CellInterfaceVisitor() {};
65   ~CellInterfaceVisitor() {};
66
67 private:
68   CellInterfaceVisitor(const Self&); //purposely not implemented
69   void operator=(const Self&); //purposely not implemented
70 };
71
72   
73 /** \class CellInterfaceVisitorImplementation
74  * A template class used to implement a visitor object.
75  *
76  * The Visitor implementation does the down cast to 
77  * the specific cell type that is being visited.  After the
78  * cast, a member of the UserVisitor type called Visit is
79  * passed the exact cell type being visited.  To use this
80  * class, write a class that implements a function 
81  * Visit(int id, CellTopology*).   Then, use that as the UserVisitor
82  * template parameter.
83  *
84  * Template parameters for CellInterfaceVisitorImplementation:
85  * TPixelType = see CellInterface
86  *
87  * TCellTraits = see CellInterface
88  *
89  * CellTopology = The specific type of cell that needs to be visited.
90  *
91  * UserVisitor = A user supplied class that implements the function
92  *               Visit(int id, CellTopology*)
93  *
94  * \ingroup MeshAccess 
95  */
96 template<
97 typename TPixelType,
98   typename TCellTraits,
99   class CellTopology,
100   class UserVisitor 
101 >
102 class CellInterfaceVisitorImplementation : 
103 IND ****public CellInterfaceVisitor<TPixelType, TCellTraits>, public UserVisitor
104 {
105 public:
106   /** Standard class typedefs. */
107   typedef CellInterfaceVisitorImplementation       Self;
108 TDA   typedef SmartPointer<Self>  Pointer;
109     
110   /** Method for creation through the object factory. */
111   itkNewMacro(Self);
112   
113   /** Run-time type information (and related methods). */
114   itkTypeMacro(CellInterfaceVisitorImplementation,LightObject);
115   
116   /** Call the static method GetTopologyId for the CellTopology type that
117    * we are templated over. */
118   virtual int GetCellTopologyId() { return CellTopology::GetTopologyId();}
119
120   /** Call the method Visit from the UserVisitor template parameter that
121    * this class inherits from.  I am my own gradpa... */
122 LEN   void VisitFromCell(unsigned long cellId, CellInterface<TPixelType, TCellTraits>* c)
123     {
124 IND ******this->UserVisitor::Visit(cellId, (CellTopology*)c);
125     }
126
127 protected:
128   CellInterfaceVisitorImplementation() {};
129   ~CellInterfaceVisitorImplementation() {};
130
131 private:
132   CellInterfaceVisitorImplementation(const Self&); //purposely not implemented
133   void operator=(const Self&); //purposely not implemented
134   
135 };
136
137 // end namespace itk
138
139 #endif
140

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:01PM
© Kitware Inc.