Example #1
0
  Space operator()( int color )
  {
    Space base, sub, margin;

    for ( typename Space::const_iterator it = base_.begin()
        ; it != base_.end(); ++it
        )
    {
      typename Space::const_point pt( it );

      if ( color_[ pt.index ] == color ) base.join( pt.element );
    }
    for ( typename Space::const_iterator it = base.begin()
        ; it != base.end(); ++it
        )
    {
      typename Space::const_point pt0( it );
#ifdef ELAI_USE_C11
      const Space&& adj = std::move( adjacent_( pt0.element ) );
#else
      const Space adj = adjacent_( pt0.element );
#endif

      sub.join( Element( pt0.element, color ) );
      for ( typename Space::const_iterator jt = adj.begin()
          ; jt != adj.end(); ++jt
          )
      {
        typename Space::const_point pt( jt );

        if ( base.contain( pt.element ) || margin.contain( Element( pt.element, color ) ) ) continue;

        int c = color_[ base_.index( pt.element ) ];

        margin.join( Element( pt.element, color ), Element( pt.element, c ) );
      }
    }

    return sub | margin;
  }
Example #2
0
  Family operator()( int color, const Space& sub )
  {
    Space base, margin;
    Family adjs;

    for ( typename Space::const_iterator it = base_.begin()
        ; it != base_.end(); ++it
        )
    {
      typename Space::const_point pt( it );

      if ( color_[ pt.index ] == color ) base.join( pt.element );
    }
    for ( typename Space::const_iterator it = base.begin()
        ; it != base.end(); ++it
        )
    {
      typename Space::const_point pt0( it );
#ifdef ELAI_USE_C11
      const Space&& adj = std::move( adjacent_( pt0.element ) );
#else
      const Space adj = adjacent_( pt0.element );
#endif
      Neighbour neigh( Element( pt0.element, color ) );

      for ( typename Space::const_iterator jt = adj.begin()
          ; jt != adj.end(); ++jt
          )
      {
        typename Space::const_point pt( jt );
        const Element pt1( pt.element, color );

        if ( !base.contain( pt.element ) && !margin.contain( pt.element ) )
          margin.join( pt.element, Element( pt.element, color ) ); // ( BASE, RECOLORED )
        if ( !sub.contain( pt1 ) ) continue;
        neigh.join( pt1 );
      }
      adjs.join( neigh );
    }
    for ( typename Space::const_marginal_iterator it = margin.internal_begin()
        ; it != margin.internal_end(); ++it
        )
    {
      typename Space::const_internal_point pt0( it );
#ifdef ELAI_USE_C11
      const Space&& adj = std::move( adjacent_( pt0.element ) );
#else
      const Space adj = adjacent_( pt0.internal ); // BASE ELEMENT
#endif
      Neighbour neigh( pt0.external ); // RECOLORED ELEMENT

      for ( typename Space::const_iterator jt = adj.begin(); jt != adj.end(); ++jt )
      {
        typename Space::const_point pt( jt );
        const Element pt1( pt.element, color );

        if ( !sub.contain( pt1 ) ) continue;
        neigh.join( pt1 );
      }
      adjs.join( neigh );
    }

    return adjs;
  }