ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkRegularSphereMeshSource.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 __itkRegularSphereMeshSource_h
00019 #define __itkRegularSphereMeshSource_h
00020 
00021 #include "itkIntTypes.h"
00022 #include "itkMesh.h"
00023 #include "itkMeshSource.h"
00024 #include "itkTriangleCell.h"
00025 
00026 namespace itk
00027 {
00040 template< class TOutputMesh >
00041 class ITK_EXPORT RegularSphereMeshSource:public MeshSource< TOutputMesh >
00042 {
00043 public:
00045   typedef RegularSphereMeshSource         Self;
00046   typedef itk::MeshSource< TOutputMesh >  Superclass;
00047   typedef itk::SmartPointer< Self >       Pointer;
00048   typedef itk::SmartPointer< const Self > ConstPointer;
00049 
00051   itkNewMacro(Self);
00052 
00054   itkTypeMacro(RegularSphereMeshSource, MeshSource);
00055 
00057   typedef TOutputMesh                         OutputMeshType;
00058   typedef typename OutputMeshType::MeshTraits MeshTraits;
00059   typedef typename OutputMeshType::PointType  PointType;
00060   typedef typename MeshTraits::PixelType      PixelType;
00061   typedef typename PointType::VectorType      VectorType;
00062 
00064   typedef typename OutputMeshType::Pointer                OutputMeshPointer;
00065   typedef typename OutputMeshType::CellTraits             CellTraits;
00066   typedef typename OutputMeshType::PointsContainerPointer PointsContainerPointer;
00067   typedef typename OutputMeshType::PointsContainer        PointsContainer;
00068 
00070   typedef itk::CellInterface< PixelType, CellTraits > CellInterfaceType;
00071   typedef itk::TriangleCell< CellInterfaceType >      TriCellType;
00072   typedef typename TriCellType::SelfAutoPointer       TriCellAutoPointer;
00073   typedef typename TriCellType::CellAutoPointer       CellAutoPointer;
00074 
00075   typedef std::pair< IdentifierType, IdentifierType >         IndexPairType;
00076   typedef itk::MapContainer< IndexPairType, IdentifierType >  PointMapType;
00077 
00080   itkSetMacro(Resolution, unsigned int);
00081   itkGetConstMacro(Resolution, unsigned int);
00083 
00085   itkSetMacro(Center, PointType);
00086   itkGetConstMacro(Center, PointType);
00088 
00092   itkSetMacro(Scale,  VectorType);
00093   itkGetConstMacro(Scale,  VectorType);
00094 protected:
00095   RegularSphereMeshSource();
00096   ~RegularSphereMeshSource() {}
00097   void PrintSelf(std::ostream & os, itk::Indent indent) const;
00099 
00100   void GenerateData();
00101 
00102   PointType Divide(const PointType & p1, const PointType & p2) const;
00103 
00104   void AddCell(OutputMeshType *mesh, const typename OutputMeshType::PointIdentifier *pointIds, IdentifierType idx);
00105 
00107   PointType m_Center;
00108 
00110   unsigned int m_Resolution;
00111 
00113   VectorType m_Scale;
00114 private:
00115   RegularSphereMeshSource(const Self &); //purposely not implemented
00116   void operator=(const Self &);          //purposely not implemented
00117 };
00118 } // end namespace itk
00120 
00121 #ifndef ITK_MANUAL_INSTANTIATION
00122 #include "itkRegularSphereMeshSource.hxx"
00123 #endif
00124 
00125 #endif //_itkRegularSphereMeshSource_h
00126