Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkTriangleMeshToBinaryImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkTriangleMeshToBinaryImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/07/09 18:42:36 $
00007   Version:   $Revision: 1.7 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkTriangleMeshToBinaryImageFilter_h
00018 #define __itkTriangleMeshToBinaryImageFilter_h
00019 
00020 #include "itkImageSource.h"
00021 
00022 #include <itkMesh.h>
00023 #include <itkLineCell.h>
00024 #include <itkPolygonCell.h>
00025 #include <itkVertexCell.h>
00026 #include <itkMapContainer.h>
00027 #include <itkVectorContainer.h>
00028 #include <itkVector.h>
00029 #include <itkPoint.h>
00030 #include <itkArray.h>
00031 #include "itkAutomaticTopologyMeshSource.h"
00032 #include "itkPointSet.h"
00033 
00034 #include <vector>
00035 
00036 namespace itk
00037 {
00038 
00039   class Point1D  
00040     {
00041     public:
00042       double x;
00043       int   sign;
00044      
00045       Point1D(){};
00046       Point1D(const double p, const int s)
00047         {
00048         x = p;
00049         sign = s;
00050         };
00051       Point1D(const Point1D &point)
00052         {
00053         x = point.x;
00054         sign = point.sign;
00055         };
00056       double getX() const
00057         {
00058         return x;
00059         };
00060       int  getSign() const
00061         {
00062         return sign;
00063         };     
00064   
00065     };
00072 template <class TInputMesh, class TOutputImage>
00073 class ITK_EXPORT TriangleMeshToBinaryImageFilter : public ImageSource<TOutputImage>
00074 {
00075 public:
00077   typedef TriangleMeshToBinaryImageFilter  Self;
00078   typedef ImageSource<TOutputImage>  Superclass;
00079   typedef SmartPointer<Self>  Pointer;
00080   typedef SmartPointer<const Self>  ConstPointer;
00081   typedef typename TOutputImage::IndexType  IndexType;
00082   typedef typename TOutputImage::SizeType   SizeType;
00083   typedef TOutputImage  OutputImageType;
00084   typedef typename OutputImageType::Pointer OutputImagePointer;
00085   typedef typename OutputImageType::ValueType  ValueType;
00086   typedef typename OutputImageType::SpacingType SpacingType;
00087   
00089   itkNewMacro(Self);
00090   
00092   itkTypeMacro(TriangleMeshToBinaryImageFilter,ImageSource);
00093 
00095   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00096 
00098   typedef TInputMesh                             InputMeshType;
00099   typedef typename InputMeshType::Pointer        InputMeshPointer;
00100   typedef typename InputMeshType::PointType                       InputPointType;
00101   typedef typename InputMeshType::PixelType                       InputPixelType;
00102   typedef typename InputMeshType::MeshTraits::CellTraits          InputCellTraitsType;
00103   typedef typename InputMeshType::CellType                        CellType;
00104   typedef typename InputMeshType::CellsContainerPointer           CellsContainerPointer;
00105   typedef typename InputMeshType::CellsContainerIterator          CellsContainerIterator;
00106 
00107   typedef typename InputMeshType::PointsContainer                 InputPointsContainer;
00108   typedef typename InputPointsContainer::Pointer                  InputPointsContainerPointer;
00109   typedef typename InputPointsContainer::Iterator                 InputPointsContainerIterator;
00110   
00111   typedef itk::PointSet < double , 3 > PointSetType;
00112   
00113   typedef PointSetType::PointsContainer      PointsContainer;
00114   
00115 
00116   typedef itk::Point < double, 3> PointType;
00117   typedef itk::Point < double, 2> Point2DType;
00118   
00119   typedef itk::Array<double> DoubleArrayType;
00120 
00121   typedef std::vector< Point1D >  Point1DVector;
00122   typedef std::vector< std::vector< Point1D> > Point1DArray;
00123 
00124   typedef std::vector< Point2DType >       Point2DVector;
00125   typedef std::vector< std::vector< Point2DType > >       Point2DArray;
00126 
00127   typedef std::vector< PointType >       PointVector;
00128   typedef std::vector< std::vector< PointType > >       PointArray;
00129 
00130   typedef std::vector< int > StencilIndexVector;
00135   itkSetMacro(Spacing, SpacingType);
00136   virtual void SetSpacing( const double spacing[3] );
00137   virtual void SetSpacing( const float spacing[3] );
00138   itkGetConstReferenceMacro(Spacing, SpacingType);
00139 
00145   itkSetMacro(InsideValue, ValueType);
00146   itkGetMacro(InsideValue, ValueType);
00147 
00153   itkSetMacro(OutsideValue, ValueType);
00154   itkGetMacro(OutsideValue, ValueType);
00155 
00160   itkSetMacro(Origin, PointType);
00161   virtual void SetOrigin( const double origin[3] );
00162   virtual void SetOrigin( const float origin[3] );
00163   itkGetConstReferenceMacro(Origin, PointType);
00164   
00166   itkSetMacro(Index,IndexType);
00167   itkGetMacro(Index,IndexType);
00168 
00170   itkSetMacro(Size,SizeType);
00171   itkGetMacro(Size,SizeType);
00172 
00174   void SetInput(InputMeshType *input);
00175 
00177   InputMeshType * GetInput(void);
00178   InputMeshType * GetInput(unsigned int idx);
00179 
00180   /* Set the tolerance for doing spatial searches of the polydata. */
00181   itkSetMacro(Tolerance, double);
00182   itkGetMacro(Tolerance, double);
00183     
00184 protected:
00185   TriangleMeshToBinaryImageFilter();
00186   ~TriangleMeshToBinaryImageFilter();
00187 
00188   virtual void GenerateOutputInformation(){}; // do nothing
00189   virtual void GenerateData();
00190 
00191   virtual void RasterizeTriangles();
00192   static int PolygonToImageRaster( PointVector coords, Point1DArray & zymatrix, int extent[6]);
00193   
00194   
00195   IndexType    m_Index;
00196   SizeType     m_Size;
00197   SpacingType  m_Spacing;
00198   PointType    m_Origin; //start value
00199   double       m_Tolerance;
00200   ValueType    m_InsideValue;
00201   ValueType    m_OutsideValue;
00202   StencilIndexVector  StencilIndex;
00203 
00204   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00205 
00206 private:
00207   TriangleMeshToBinaryImageFilter(const Self&); //purposely not implemented
00208   void operator=(const Self&); //purposely not implemented
00209 
00210   static bool ComparePoints2D(Point2DType a, Point2DType b);
00211   static bool ComparePoints1D(Point1D a, Point1D b);
00212 };
00213 
00214 } // end namespace itk
00215 
00216 #ifndef ITK_MANUAL_INSTANTIATION
00217 #include "itkTriangleMeshToBinaryImageFilter.txx"
00218 #endif
00219 
00220 #endif

Generated at Thu May 25 00:09:46 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000