ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkCellInterfaceVisitor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkCellInterfaceVisitor_h
00019 #define __itkCellInterfaceVisitor_h
00020 
00021 #include "itkLightObject.h"
00022 #include "itkObjectFactory.h"
00023 
00024 namespace itk
00025 {
00026 // forward reference CellInterface
00027 template<
00028   typename TPixelType,
00029   typename TCellTraits
00030   >
00031 class CellInterface;
00032 
00046 template<
00047   typename TPixelType,
00048   typename TCellTraits
00049   >
00050 class CellInterfaceVisitor:public LightObject
00051 {
00052 public:
00054   typedef CellInterfaceVisitor                  Self;
00055   typedef LightObject                           Superclass;
00056   typedef SmartPointer< Self >                  Pointer;
00057   typedef SmartPointer< const Self >            ConstPointer;
00058   typedef typename TCellTraits::CellIdentifier  CellIdentifier;
00059 
00061   itkTypeMacro(CellInterfaceVisitor, LightObject);
00062 
00064   virtual void VisitFromCell(CellIdentifier cellId, CellInterface< TPixelType,
00065                                                                    TCellTraits > *) = 0;
00066 
00068   virtual int GetCellTopologyId() = 0;
00069 
00070 protected:
00071   CellInterfaceVisitor() {}
00072   ~CellInterfaceVisitor() {}
00073 private:
00074   CellInterfaceVisitor(const Self &); //purposely not implemented
00075   void operator=(const Self &);       //purposely not implemented
00076 };
00077 
00104 template<
00105   typename TPixelType,
00106   typename TCellTraits,
00107   class CellTopology,
00108   class UserVisitor
00109   >
00110 class CellInterfaceVisitorImplementation:
00111   public CellInterfaceVisitor< TPixelType, TCellTraits >, public UserVisitor
00112 {
00113 public:
00115   typedef CellInterfaceVisitorImplementation    Self;
00116   typedef SmartPointer< Self >                  Pointer;
00117   typedef typename TCellTraits::CellIdentifier  CellIdentifier;
00118 
00120   itkNewMacro(Self);
00121 
00123   itkTypeMacro(CellInterfaceVisitorImplementation, LightObject);
00124 
00127   virtual int GetCellTopologyId() { return CellTopology::GetTopologyId(); }
00128 
00131   void VisitFromCell(CellIdentifier cellId, CellInterface< TPixelType,
00132                                                            TCellTraits > *c)
00133   {
00134     this->UserVisitor::Visit(cellId, (CellTopology *)c);
00135   }
00136 
00137 protected:
00138   CellInterfaceVisitorImplementation() {}
00139   ~CellInterfaceVisitorImplementation() {}
00140 private:
00141   CellInterfaceVisitorImplementation(const Self &); //purposely not implemented
00142   void operator=(const Self &);                     //purposely not implemented
00143 };
00144 } // end namespace itk
00145 
00146 #endif
00147