Hello,
I am newbie using boost library.
I have tried to use boost::minmax_element to calculate bounding box of
2D Points,
but I failed...
Here is some code:
struct S2DPoint { int x; int y; };
typedef std::vector<S2DPoint > Poly;
Poly vect;
...
std::pair result =
boost::minmax_element(poly.begin(), poly.end());
this code does not compiles I need to define BinaryPredicate..
My code with out boost looks:
bool CalcPolyMinMax(const S2DPoint poly[], int nCount,
S2DPoint &ptMin,
S2DPoint &ptMax)
{
if ( nCount < 1 )
{
return false;
}
ptMin = poly[0];
ptMax = poly[0];
S2DPoint pt;
for ( int i1 = 0; i1 < nCount; ++i1 )
{
pt = poly[i1];
UpdateMinMaxPoints(ptMin, ptMax, pt);
}
return true;
}
void UpdateMinMaxPoints(S2DPoint &ptMin, S2DPoint &ptMax, const S2DPoint
&pt)
{
if ( ptMin.x > pt.x )
{
ptMin.x = pt.x;
}
if ( ptMax.x < pt.x )
{
ptMax.x = pt.x;
}
if ( ptMin.y > pt.y )
{
ptMin.y = pt.y;
}
if ( ptMax.y < pt.y )
{
ptMax.y = pt.y;
}
}
Question:
How to transform UpdateMinMaxPoints function to the BinaryPredicate?
Thanks,
Tomas