GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
itkConvertMeshesToLabelImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 #ifndef __itkConvertMeshesToLabelImageFilter_h
35 #define __itkConvertMeshesToLabelImageFilter_h
36 
37 #ifdef _MSC_VER
38 #pragma warning ( disable : 4786 )
39 #endif
40 
41 #include "itkImageToImageFilter.h"
42 #include "itkImage.h"
43 
44 #include "itkImageRegionIteratorWithIndex.h"
45 #include "itkRegionOfInterestImageFilter.h"
46 #include "itkQuadEdgeMesh.h"
47 #include "itkTriangleMeshToBinaryImageFilter.h"
48 #include "itkVector.h"
49 
50 #include <fstream>
51 #include "itkMultiThreader.h"
52 
53 namespace itk
54 {
55 
56 template< class TImage,
57  class TMesh = QuadEdgeMesh< typename TImage::PointType::CoordRepType,
58  TImage::ImageDimension > >
59 class ConvertMeshesToLabelImageFilter : public Object
60 {
61 public:
63  typedef Object Superclass;
64  typedef SmartPointer<Self> Pointer;
65  typedef SmartPointer<const Self> ConstPointer;
66 
67  itkStaticConstMacro ( ImageDimension, unsigned int, TImage::ImageDimension );
68 
71 
74 
76  typedef TImage ImageType;
77  typedef typename ImageType::Pointer ImagePointer;
78  typedef typename ImageType::ConstPointer ImageConstPointer;
79  typedef typename ImageType::IndexType IndexType;
80  typedef typename IndexType::IndexValueType IndexValueType;
81  typedef typename ImageType::PixelType PixelType;
82  typedef typename ImageType::SizeType SizeType;
83  typedef typename SizeType::SizeValueType SizeValueType;
84  typedef typename ImageType::RegionType RegionType;
85  typedef typename ImageType::SpacingType SpacingType;
86  typedef typename ImageType::PointType PointType;
87  typedef typename PointType::CoordRepType CoordType;
88 
89  typedef TMesh MeshType;
90  typedef typename MeshType::Pointer MeshPointer;
91  typedef std::vector< MeshPointer > MeshVectorType;
92 
93  typedef RegionOfInterestImageFilter< ImageType, ImageType > ROIFilterType;
94  typedef typename ROIFilterType::Pointer ROIFilterPointer;
95 
96  typedef ImageRegionIterator< ImageType > IteratorType;
97  typedef ImageRegionIteratorWithIndex< ImageType > IndexIteratorType;
98 
99  typedef TriangleMeshToBinaryImageFilter< MeshType, ImageType > MeshToImageFilterType;
100  typedef typename MeshToImageFilterType::Pointer MeshToImageFilterPointer;
101 
102  typedef MultiThreader ThreaderType;
103  typedef typename ThreaderType::Pointer ThreaderPointer;
104 
105  itkSetObjectMacro( Input , ImageType );
106  itkGetConstMacro( NumberOfMeshes, size_t );
107 
108 #ifdef ITKv4
109  itkGetConstMacro( NumberOfThreads, ThreadIdType );
110  itkSetMacro( NumberOfThreads, ThreadIdType );
111 #else
112  itkGetConstMacro( NumberOfThreads, int );
113  itkSetMacro( NumberOfThreads, int );
114 #endif
115 
116  void SetMeshes( const MeshVectorType& iMeshes );
117 
118  void Update();
119 
120 protected:
123  void PrintSelf(std::ostream& os, Indent indent) const;
124  void ThreadedExtractMesh( const unsigned int& startLabel,
125  const unsigned int& endLabel );
126 
127  static ITK_THREAD_RETURN_TYPE ThreaderCallback(void * arg);
128 
130  {
132  };
133 
135 #ifdef ITKv4
136  ThreadIdType m_NumberOfThreads;
137 #else
139 #endif
140 
142 
144 
145  void GenerateData();
146 
147 private:
149  void operator=(const Self&);
150 };
151 
152 } // end namespace itk
153 
154 #include "itkConvertMeshesToLabelImageFilter.txx"
155 
156 #endif
TriangleMeshToBinaryImageFilter< MeshType, ImageType > MeshToImageFilterType
itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension)
void PrintSelf(std::ostream &os, Indent indent) const
void ThreadedExtractMesh(const unsigned int &startLabel, const unsigned int &endLabel)
itkTypeMacro(ConvertMeshesToLabelImageFilter, Object)
ImageRegionIteratorWithIndex< ImageType > IndexIteratorType
RegionOfInterestImageFilter< ImageType, ImageType > ROIFilterType
void SetMeshes(const MeshVectorType &iMeshes)
itkSetMacro(NumberOfThreads, int)
static ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg)
itkGetConstMacro(NumberOfMeshes, size_t)