18 #ifndef __otbPointSetToDeformationFieldGenerator_txx
19 #define __otbPointSetToDeformationFieldGenerator_txx
29 template <
class TPo
intSet,
class TDeformationField>
33 this->SetNumberOfRequiredInputs(1);
34 m_MetricThreshold = 0.;
35 m_OutputSize.Fill(100);
36 m_OutputSpacing.Fill(1.);
37 m_OutputOrigin.Fill(0.);
45 template <
class TPo
intSet,
class TDeformationField>
56 template <
class TPo
intSet,
class TDeformationField>
64 template <
class TPo
intSet,
class TDeformationField>
70 typename DeformationFieldType::RegionType largest;
71 largest.SetSize(m_OutputSize);
74 largest.SetIndex(index);
75 outputPtr->SetRegions(largest);
76 outputPtr->SetSpacing(m_OutputSpacing);
77 outputPtr->SetOrigin(m_OutputOrigin);
79 outputPtr->SetNumberOfComponentsPerPixel(2);
87 template <
class TPo
intSet,
class TDeformationField>
100 typedef typename PointSetType::PointsContainer::ConstIterator PointSetIteratorType;
101 typedef typename PointSetType::PointsContainer PointsContainerType;
102 PointSetIteratorType it = this->GetPointSet()->GetPoints()->Begin();
103 for (; it != this->GetPointSet()->GetPoints()->End(); ++it)
106 p[0] = it.Value()[0];
107 p[1] = it.Value()[1];
108 if (vcl_abs(this->GetPointSet()->GetPointData()->GetElement(j)[0]) >= m_MetricThreshold)
111 distanceVector.push_back(EuclideanDistance(index, p));
112 sortVector.push_back(i);
113 indexVector.push_back(j);
119 ComparisonFunctorType comp;
121 sort(sortVector.begin(), sortVector.end(), comp);
124 unsigned int nbElements = (n < indexVector.size() ? n : indexVector.size());
126 for (i = 0; i < nbElements; ++i)
128 output.push_back(indexVector[sortVector[i]]);
133 template <
class TPo
intSet,
class TDeformationField>
141 return vcl_sqrt(vcl_pow(index[0] - p[0], 2) + vcl_pow(index[1] - p[1], 2));
146 template <
class TPo
intSet,
class TDeformationField>
151 Superclass::PrintSelf(os, indent);