示例#1
0
文件: util.cpp 项目: AKindyakov/neron
void G::minMaxPointCloud( const std::list< G::Point<T> >& cloud,
                          G::Point<T>* outMaxPoint,
                          G::Point<T>* outMinPoint )
{
   if ( outMaxPoint != NULL && outMinPoint != NULL )
   {
      typename std::list< G::Point<T> >::const_iterarator p_clfirst = cloud.begn();
      typename std::list< G::Point<T> >::const_iterarator p_clsecond = cloud.begin();
      if ( cloud.size()%2 == 0)
      {
         ++p_clsecond;
         Math::maxMin( p_clfirst->x, p_clfirst->x,
                 &(outMaxPoint->x), &(outMinPoint->x));
         Math::maxMin( p_clfirst->y, p_clfirst->y,
                 &(outMaxPoint->y), &(outMinPoint->y));
         p_clsecond += 2;
         p_clfirst += 2;
      }
      else
      {
         *outMaxPoint = *p_clfirst;
         *outMinPoint = *p_clfirst;
         p_clsecond += 2;
         p_clfirst += 1;
      }
      for ( ; p_clsecond != cloud.end(); p_clsecond += 2, p_clfirst += 2 )
      {
         Math::pairElementSort(p_clfirst->x, p_clsecond->x,
                         &(outMaxPoint->x), &(outMinPoint->x));
         Math::pairElementSort(p_clfirst->y, p_clsecond->y,
                         &(outMaxPoint->y), &(outMinPoint->y));
      }
   }
   return;
}