Orfeo Toolbox  3.16
otbGISTableToLabelMapFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbGISTableToLabelMapFilter_txx
19 #define __otbGISTableToLabelMapFilter_txx
20 
22 #include "itkNumericTraits.h"
23 
24 namespace otb {
25 
26 template<class TGISTable, class TLabelMap>
29 {
30  m_BackgroundValue = itk::NumericTraits<OutputLabelMapPixelType>::max();
31  m_GISTableToVectorDataFilter = GISTableToVectorDataFilterType::New();
32  m_VectorDataToLabelMapFilter = VectorDataToLabelMapFilterType::New();
33 
34  m_VectorDataToLabelMapFilter->SetInput(m_GISTableToVectorDataFilter->GetOutput());
35 }
36 
37 template<class TGISTable, class TLabelMap>
38 void
41 {
42 // Process object is not const-correct so the const_cast is required here
44  const_cast<InputGISTableType *>(input));
45 }
46 
47 template<class TGISTable, class TLabelMap>
48 void
50 ::SetInput(unsigned int idx, const InputGISTableType *input)
51 {
52  // Process object is not const-correct so the const_cast is required here
54  const_cast<InputGISTableType *>(input));
55 }
56 
57 template<class TGISTable, class TLabelMap>
61 {
62  if (this->GetNumberOfInputs() < 1)
63  {
64  return 0;
65  }
66 
67  return static_cast<const TGISTable *>
69 }
70 
71 template<class TGISTable, class TLabelMap>
74 ::GetInput(unsigned int idx)
75 {
76  return static_cast<const TGISTable *>
77  (this->itk::ProcessObject::GetInput(idx));
78 }
79 
80 template<class TGISTable, class TLabelMap>
81 void
84 { /*
85  // call the superclass' implementation of this method
86  Superclass::GenerateInputRequestedRegion();
87 
88  // We need all the input.
89  InputImagePointer input = const_cast<InputImageType *>(this->GetInput());
90  if ( !input )
91  { return; }
92  input->SetRequestedRegion( input->GetLargestPossibleRegion() ); */
93 }
94 
95 /*
96 template<class TGISTable, class TLabelMap >
97 void
98 GISTableToLabelMapFilter<TGISTable, TLabelMap>
99 ::EnlargeOutputRequestedRegion(DataObject *)
100 {
101  this->GetOutput()
102  ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
103 }
104 */
105 
109 template <class TGISTable, class TLabelMap>
112 {
113  // we can't call the superclass method here.
114 
115  // get pointers to the input and output
116  const InputGISTableType * inputPtr = this->GetInput();
117  OutputLabelMapType * outputPtr = this->GetOutput();
118 
119  if (!inputPtr || !outputPtr)
120  {
121  return;
122  }
123 
124  // Set the size of the output region
125  typename OutputLabelMapType::RegionType outputLargestPossibleRegion;
126  outputLargestPossibleRegion.SetSize(m_Size);
127  outputLargestPossibleRegion.SetIndex(m_StartIndex);
128  outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion);
129 
130  //Set spacing and origin
131  outputPtr->SetSpacing(m_GISTableToVectorDataFilter->GetOutput()->GetSpacing());
132  outputPtr->SetOrigin(m_GISTableToVectorDataFilter->GetOutput()->GetOrigin());
133 
134 }
135 
136 template<class TGISTable, class TLabelMap>
137 void
140 {
141  // Allocate the output
142  this->AllocateOutputs();
143 
144 // std::cout << input->GetConnection()->GetDBName()<< std::endl;
145 // std::cout << input->GetTableName() << std::endl;
146  m_GISTableToVectorDataFilter->SetInput(this->GetInput());
147  //With set background to numericTrait::max() //TODO use the value set by the user
148  m_BackgroundValue = itk::NumericTraits<OutputLabelMapPixelType>::max();
149  m_VectorDataToLabelMapFilter->SetBackgroundValue(this->GetBackgroundValue());
150 
151  //Set size of the final image
152  m_VectorDataToLabelMapFilter->SetSize(m_Size);
153  m_VectorDataToLabelMapFilter->SetStartIndex(m_StartIndex);
154 
155  OutputLabelMapType * output = this->GetOutput();
156 
157  output = m_VectorDataToLabelMapFilter->GetOutput();
158 
159  m_VectorDataToLabelMapFilter->Update();
160 
161 }
162 
163 template<class TGISTable, class TLabelMap>
164 void
166 ::PrintSelf(std::ostream& os, itk::Indent indent) const
167 {
168  Superclass::PrintSelf(os, indent);
169 
170  os << indent << "GISTableToVectorData:" << this->m_GISTableToVectorDataFilter << std::endl;
171 
172 }
173 
174 } // end namespace otb
175 #endif

Generated at Sun May 19 2013 00:26:02 for Orfeo Toolbox with doxygen 1.8.3.1