00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkRegularSphereMeshSource_h
00018 #define __itkRegularSphereMeshSource_h
00019
00020 #include "itkMesh.h"
00021 #include "itkMeshSource.h"
00022 #include "itkTriangleCell.h"
00023 #include "itkMapContainer.h"
00024
00025 namespace itk
00026 {
00027
00039 template <class TOutputMesh>
00040 class RegularSphereMeshSource : public MeshSource<TOutputMesh>
00041 {
00042 public:
00044 typedef RegularSphereMeshSource Self;
00045 typedef itk::MeshSource<TOutputMesh> Superclass;
00046 typedef itk::SmartPointer<Self> Pointer;
00047 typedef itk::SmartPointer<const Self> ConstPointer;
00048
00050 itkNewMacro(Self);
00051
00053 itkTypeMacro(RegularSphereMeshSource, MeshSource);
00054
00056 typedef TOutputMesh OutputMeshType;
00057 typedef typename OutputMeshType::MeshTraits MeshTraits;
00058 typedef typename OutputMeshType::PointType PointType;
00059 typedef typename MeshTraits::PixelType PixelType;
00060
00062 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00063 typedef typename OutputMeshType::CellTraits CellTraits;
00064 typedef typename OutputMeshType::PointsContainerPointer PointsContainerPointer;
00065 typedef typename OutputMeshType::PointsContainer PointsContainer;
00066
00068 typedef itk::CellInterface<PixelType, CellTraits> CellInterfaceType;
00069 typedef itk::TriangleCell<CellInterfaceType> TriCellType;
00070 typedef typename TriCellType::SelfAutoPointer TriCellAutoPointer;
00071 typedef typename TriCellType::CellAutoPointer CellAutoPointer;
00072
00073 typedef std::pair<unsigned long,unsigned long> IndexPairType;
00074 typedef itk::MapContainer<IndexPairType, unsigned long> PointMapType;
00075 typedef typename PointType::VectorType VectorType;
00076
00077
00080 itkSetMacro(Resolution, unsigned int);
00081 itkGetMacro(Resolution, unsigned int);
00082
00084 itkSetMacro( Center, PointType );
00085 itkGetMacro( Center, PointType );
00086
00090 itkSetMacro( Scale, VectorType );
00091 itkGetMacro( Scale, VectorType );
00092
00093 protected:
00094 RegularSphereMeshSource();
00095 ~RegularSphereMeshSource() {}
00096 void PrintSelf(std::ostream& os, itk::Indent indent) const;
00097
00098 void GenerateData();
00099
00100 PointType Divide( const PointType & p1, const PointType & p2) const;
00101
00102 void AddCell( OutputMeshType * mesh, const unsigned long * pointIds, unsigned long idx);
00103
00105 PointType m_Center;
00106
00108 unsigned int m_Resolution;
00109
00111 VectorType m_Scale;
00112
00113
00114 private:
00115 RegularSphereMeshSource(const Self&);
00116 void operator=(const Self&);
00117 };
00118
00119
00120
00121 }
00122
00123 #include "itkRegularSphereMeshSource.txx"
00124
00125 #endif //_itkRegularSphereMeshSource_H