21 #ifndef otbVectorDataProjectionFilter_hxx
22 #define otbVectorDataProjectionFilter_hxx
25 #include "itkProgressReporter.h"
26 #include "itkMetaDataObject.h"
35 template <
class TInputVectorData,
class TOutputVectorData>
38 m_InputProjectionRef.clear();
39 m_OutputProjectionRef.clear();
40 m_InputSpacing.Fill(1);
41 m_InputOrigin.Fill(0);
42 m_OutputSpacing.Fill(1);
43 m_OutputOrigin.Fill(0);
48 template <
class TInputVectorData,
class TOutputVectorData>
51 itkDebugMacro(
"setting Spacing to " << spacing);
52 if (this->m_InputSpacing != spacing)
54 this->m_InputSpacing = spacing;
60 template <
class TInputVectorData,
class TOutputVectorData>
64 this->SetInputSpacing(s);
68 template <
class TInputVectorData,
class TOutputVectorData>
71 itk::Vector<float, 2> sf(spacing);
74 this->SetInputSpacing(s);
78 template <
class TInputVectorData,
class TOutputVectorData>
82 this->SetInputOrigin(p);
86 template <
class TInputVectorData,
class TOutputVectorData>
89 itk::Point<float, 2> of(origin);
92 this->SetInputOrigin(p);
96 template <
class TInputVectorData,
class TOutputVectorData>
99 itkDebugMacro(
"setting Spacing to " << spacing);
100 if (this->m_OutputSpacing != spacing)
102 this->m_OutputSpacing = spacing;
108 template <
class TInputVectorData,
class TOutputVectorData>
112 this->SetOutputSpacing(s);
116 template <
class TInputVectorData,
class TOutputVectorData>
119 itk::Vector<float, 2> sf(spacing);
122 this->SetOutputSpacing(s);
126 template <
class TInputVectorData,
class TOutputVectorData>
130 this->SetOutputOrigin(p);
134 template <
class TInputVectorData,
class TOutputVectorData>
137 itk::Point<float, 2> of(origin);
140 this->SetOutputOrigin(p);
143 template <
class TInputVectorData,
class TOutputVectorData>
146 Superclass::GenerateOutputInformation();
149 itk::MetaDataDictionary& dict = output->GetMetaDataDictionary();
157 template <
class TInputVectorData,
class TOutputVectorData>
162 itk::Point<double, 2> point;
163 point = m_Transform->TransformPoint(pointCoord);
170 template <
class TInputVectorData,
class TOutputVectorData>
174 typedef typename InputLineType::VertexListType::ConstPointer VertexListConstPointerType;
175 typedef typename InputLineType::VertexListConstIteratorType VertexListConstIteratorType;
176 VertexListConstPointerType vertexList = line->GetVertexList();
177 VertexListConstIteratorType it = vertexList->Begin();
178 typename OutputLineType::Pointer newLine = OutputLineType::New();
179 while (it != vertexList->End())
181 itk::Point<double, 2> point;
182 itk::ContinuousIndex<double, 2> index;
183 typename InputLineType::VertexType pointCoord = it.Value();
184 point = m_Transform->TransformPoint(pointCoord);
188 newLine->AddVertex(index);
199 template <
class TInputVectorData,
class TOutputVectorData>
203 typedef typename InputPolygonType::VertexListType::ConstPointer VertexListConstPointerType;
204 typedef typename InputPolygonType::VertexListConstIteratorType VertexListConstIteratorType;
205 VertexListConstPointerType vertexList = polygon->GetVertexList();
206 VertexListConstIteratorType it = vertexList->Begin();
207 typename OutputPolygonType::Pointer newPolygon = OutputPolygonType::New();
208 while (it != vertexList->End())
210 itk::Point<double, 2> point;
211 itk::ContinuousIndex<double, 2> index;
212 typename InputPolygonType::VertexType pointCoord = it.Value();
213 point = m_Transform->TransformPoint(pointCoord);
216 newPolygon->AddVertex(index);
226 template <
class TInputVectorData,
class TOutputVectorData>
232 for (
typename InputPolygonListType::ConstIterator it = polygonList->Begin(); it != polygonList->End(); ++it)
234 newPolygonList->PushBack(this->ProcessPolygon(it.Get()));
236 return newPolygonList;
242 template <
class TInputVectorData,
class TOutputVectorData>
245 m_Transform = InternalTransformType::New();
248 const itk::MetaDataDictionary& inputDict = input->GetMetaDataDictionary();
251 itk::MetaDataDictionary& outputDict = output->GetMetaDataDictionary();
253 m_Transform->SetInputImageMetadata(m_InputImageMetadata);
254 m_Transform->SetOutputImageMetadata(m_OutputImageMetadata);
256 if (m_InputProjectionRef.empty())
261 m_Transform->SetInputProjectionRef(m_InputProjectionRef);
262 m_Transform->SetOutputProjectionRef(m_OutputProjectionRef);
263 m_Transform->SetInputSpacing(m_InputSpacing);
264 m_Transform->SetInputOrigin(m_InputOrigin);
265 m_Transform->SetOutputSpacing(m_OutputSpacing);
266 m_Transform->SetOutputOrigin(m_OutputOrigin);
268 m_Transform->InstantiateTransform();
272 m_OutputProjectionRef = m_Transform->GetOutputProjectionRef();
275 if (!m_OutputProjectionRef.empty())
279 output->SetSpacing(m_OutputSpacing);
280 output->SetOrigin(m_OutputOrigin);
286 template <
class TInputVectorData,
class TOutputVectorData>
289 this->AllocateOutputs();
295 this->InstantiateTransform();
297 typedef typename OutputVectorDataType::DataTreePointerType OutputDataTreePointerType;
298 OutputDataTreePointerType tree = outputPtr->GetDataTree();
304 typedef typename OutputVectorDataType::DataNodePointerType OutputDataNodePointerType;
305 OutputDataNodePointerType newDataNode = OutputDataNodeType::New();
306 newDataNode->SetNodeType(inputRoot->Get()->GetNodeType());
307 newDataNode->SetNodeId(inputRoot->Get()->GetNodeId());
308 typename OutputInternalTreeNodeType::Pointer outputRoot = OutputInternalTreeNodeType::New();
309 outputRoot->Set(newDataNode);
310 tree->SetRoot(outputRoot);
314 this->ProcessNode(inputRoot, outputRoot);