Skip to content
Snippets Groups Projects
Commit 5ed90b5b authored by Luc Hermitte's avatar Luc Hermitte
Browse files

ENH: complete VLVPointIterator

parent 1ace9d99
No related branches found
No related tags found
1 merge request!1Resolve "Adapt DiapOTB SARCartesianMeanEstimation to keep shadows"
......@@ -862,13 +862,6 @@ SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TF
auto const* input = this->GetInput();
auto const nBands = input->GetNumberOfComponentsPerPixel();
InputIterator InIt_UL(input, inputRegionForThread);
InputIterator InIt_UR(input, inputRegionForThread);
InputIterator InIt_LR(input, inputRegionForThread);
InputIterator InIt_LL(input, inputRegionForThread);
InputIterator * tabInIt[] = { &InIt_UL, &InIt_UR, &InIt_LR, &InIt_LL};
auto const& in_size = inputRegionForThread.GetSize();
auto const& in_index = inputRegionForThread.GetIndex();
auto const in_sizeX = in_size[0];
......@@ -919,15 +912,6 @@ SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TF
ImageInSubPixelType const lo_margin = ind_Line_Into_SARGeo - margin;
ImageInSubPixelType const hi_margin = ind_Line_Into_SARGeo + margin;
///////////////////////////// Polygon Construction and Check intersection /////////////////////////
InIt_UL.GoToBegin();
InIt_UR.GoToBegin();
InIt_LR.GoToBegin();
InIt_LL.GoToBegin();
// Put each Iterator to this start line
// +1 line for LL and for LR
InIt_LL.NextLine();
InIt_LR.NextLine();
int countDEMLine = 0;
......@@ -938,21 +922,12 @@ SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TF
return VLVPointIterator<ImageInSubPixelType const>(in_data + nBands*dx + dy*in_line_off, nBands);
};
InIt_UR.GoToBeginOfLine();
InIt_UL.GoToBeginOfLine();
InIt_LR.GoToBeginOfLine();
InIt_LL.GoToBeginOfLine();
// Put each Iterator to this start colunm
// +1 colunm for UR and LR
++InIt_UR;
++InIt_LR;
// For each column
for (unsigned dx = 0 ; dx < in_sizeX -1 ; ++dx)
{
auto pt_UL = point(dx, dy);
auto const UL_line = InIt_UL.Get()[1];
auto const UL_line = pt_UL[1];
// Protect Memory access and input access
static_assert(std::is_same<decltype(UL_line), decltype(lo_margin)>::value, "no convertion!!!");
......@@ -961,28 +936,21 @@ SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TF
auto const pt_UR = point(dx+1, dy );
auto const pt_LL = point(dx , dy+1);
auto const pt_LR = point(dx+1, dy+1);
VLVPointIterator<ImageInSubPixelType const> tabInPt[] = { pt_UL, pt_UR, pt_LR, pt_LL};
assert(&InIt_UR.Get()[0] == in_data + nBands*(dx+1) + dy*in_line_off);
assert(&InIt_LR.Get()[0] == in_data + nBands*(dx+1) + (dy+1)*in_line_off);
assert(&InIt_LL.Get()[0] == in_data + nBands*dx + (dy+1)*in_line_off);
assert(&pt_UR[0] == &InIt_UR.Get()[0]);
assert(&pt_LL[0] == &InIt_LL.Get()[0]);
assert(&pt_LR[0] == &InIt_LR.Get()[0]);
auto const UL_col = InIt_UL.Get()[0];
auto const UR_col = InIt_UR.Get()[0];
auto const LR_col = InIt_LR.Get()[0];
auto const LL_col = InIt_LL.Get()[0];
auto const UL_col = pt_UL[0];
auto const UR_col = pt_UR[0];
auto const LR_col = pt_LR[0];
auto const LL_col = pt_LL[0];
// Check if No Data
if (!(UL_col == nodata || UR_col == nodata || LR_col == nodata
|| LL_col == nodata))
{
// Determine if intersection
auto const UR_line = InIt_UR.Get()[1];
auto const LR_line = InIt_LR.Get()[1];
auto const LL_line = InIt_LL.Get()[1];
auto const UR_line = pt_UR[1];
auto const LR_line = pt_LR[1];
auto const LL_line = pt_LL[1];
// Pixel of otb::VectorImage (input) : 4 Components : C, L, Z and Y
int i_InSideUp, i_InSideDown, i_OutSideUp, i_OutSideDown;
......@@ -1004,19 +972,14 @@ SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TF
if (hasIntersection)
{
// Store the polygons
Polygon_SideInUp_VecLine [countDEMLine].push_back(tabInIt[i_InSideUp] ->Get());
Polygon_SideInDown_VecLine [countDEMLine].push_back(tabInIt[i_InSideDown] ->Get());
Polygon_SideOutUp_VecLine [countDEMLine].push_back(tabInIt[i_OutSideUp] ->Get());
Polygon_SideOutDown_VecLine[countDEMLine].push_back(tabInIt[i_OutSideDown]->Get());
Polygon_SideInUp_VecLine [countDEMLine].push_back(*tabInPt[i_InSideUp]);
Polygon_SideInDown_VecLine [countDEMLine].push_back(*tabInPt[i_InSideDown]);
Polygon_SideOutUp_VecLine [countDEMLine].push_back(*tabInPt[i_OutSideUp]);
Polygon_SideOutDown_VecLine[countDEMLine].push_back(*tabInPt[i_OutSideDown]);
}
}
}
// Next Column For input
++InIt_UL;
++InIt_UR;
++InIt_LR;
++InIt_LL;
} // End colunms (input)
......@@ -1033,12 +996,6 @@ SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TF
++countDEMLine;
// Next Line For input
InIt_UL.NextLine();
InIt_UR.NextLine();
InIt_LR.NextLine();
InIt_LL.NextLine();
} // End of lines (input)
///////////////////////////// Scan of all selected polygons to extract wanted data //////////////
......
......@@ -98,6 +98,8 @@ struct VLVPointIterator
return itk::VariableLengthVector<typename std::remove_cv<T>::type>(m_p, m_nb_bands);
}
decltype(auto) data() const noexcept { return m_p; }
// itk::VariableLengthVector<typename std::remove_cv<T>::type> operator*() noexcept {
// return itk::VariableLengthVector<T>(m_p, m_nb_bands);
// }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment