Ejemplo n.º 1
0
  inline bool                  
  pointmesh2d<point_t>::equals ( pointmesh2d const& o, value_type const& epsilon ) const
  {
    /*if ( o.size() != size() || _points.empty() ) {
      return false;
    } 
    else */
    {
      // heuristic : if min + max + mean + #poinst meshes are equal
      point_type mean_a = std::accumulate ( _points.begin(),     _points.end(), point_type() );
      point_type mean_b = std::accumulate ( o._points.begin(), o._points.end(), point_type() );

      axis_aligned_boundingbox<point_type> box_a ( _points.begin(),     _points.end() );
      axis_aligned_boundingbox<point_type> box_b ( o._points.begin(), o._points.end() );

      return mean_a.distance(mean_b) < epsilon &&
             box_a.min.distance(box_b.min) < epsilon &&
             box_a.max.distance(box_b.max) < epsilon;
    }
  }
Ejemplo n.º 2
0
bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const
{
    BOX2I box_a( aSeg.A, aSeg.B - aSeg.A );
    BOX2I::ecoord_type dist_sq = (BOX2I::ecoord_type) aClearance * aClearance;

    for( int i = 0; i < SegmentCount(); i++ )
    {
        const SEG& s = CSegment( i );
        BOX2I box_b( s.A, s.B - s.A );

        BOX2I::ecoord_type d = box_a.SquaredDistance( box_b );

        if( d < dist_sq )
        {
            if( s.Collide( aSeg, aClearance ) )
                return true;
        }
    }

    return false;
}