void Rgrid_window_neighborhood::find_all_neighbors( const Geovalue& center ) {
  size_ = -1;
  center_ = center;
  center_.set_property_array( property_ );

  neighbors_.clear();
  if( !property_ ) return;

  SGrid_cursor cursor( *grid_->cursor() );
  GsTLInt i,j,k;
  cursor.coords( center.node_id(), i,j,k ); 
  GsTLGridNode center_location( i,j,k );

  if( geom_.size() == 0 ) return;

  Grid_template::iterator begin = geom_.begin();
  Grid_template::iterator bound = geom_.end()-1;

  for( ; begin != bound+1 ; ++begin ) {
    GsTLGridNode node = center_location + (*begin);
    neighbors_.push_back( Geovalue( grid_, property_, 
				    cursor_.node_id( node[0], node[1],
						     node[2] ) )
			  );
  }
}
Пример #2
0
void MgridWindowNeighborhood::find_all_neighbors( const Geovalue& center ) {
  size_ = -1;
  center_ = center;
  center_.set_property_array( property_ );

  _mcursor = dynamic_cast<EGridCursor*>(grid_->cursor());

  neighbors_.clear();
  if( !property_ ) return;

  //SGrid_cursor cursor( *grid_->cursor() );
  GsTLInt i,j,k;
  _mcursor->coords( center.node_id(), i,j,k ); 
  GsTLGridNode center_location( i,j,k );

  if( geom_.size() == 0 ) return;

  Grid_template::iterator begin = geom_.begin();
  Grid_template::iterator bound = geom_.end()-1;

  for( ; begin != bound+1 ; ++begin ) {
    GsTLGridNode node = center_location + (*begin);
	if (_mcursor->node_id( node[0], node[1], node[2] ) < 0)
		continue;
    neighbors_.push_back( Geovalue( grid_, property_, 
				    _mcursor->node_id( node[0], node[1],
						     node[2] ) )
			  );
  }
}
void Rgrid_window_neighborhood::find_neighbors( const Geovalue& center ) {
  size_ = -1;
  center_ = center;
  center_.set_property_array( property_ );

  neighbors_.clear();
  if( !property_ ) return;

  SGrid_cursor cursor( *grid_->cursor() );
  GsTLInt i,j,k;
  cursor.coords( center.node_id(), i,j,k ); 
  GsTLGridNode center_location( i,j,k );

  if( geom_.size() == 0 ) return;

  Grid_template::iterator begin = geom_.begin();
  Grid_template::iterator bound = geom_.end()-1;
  /* nico: old code, remove if new works properly
  while (bound != begin-1) {
    GsTLGridNode p = center_location + (*bound);
    if( !grid_->contains( p ) ) {
      bound--;
      continue;
    }
    if( grid_->is_informed( p ) )
      break;
    else
      bound--;
  }
  */

  while (bound != begin) {
    GsTLGridNode p = center_location + (*bound);
    GsTLInt node_id = cursor.node_id( p[0], p[1], p[2] );
    if( node_id < 0 ) {
      bound--;
      continue;
    }
    if( property_->is_informed( node_id ) )
      break;
    else
      bound--;
  }

  // Need to place the bound at one pass the actual end point
  bound++;

  for( ; begin != bound; ++begin ) {
    GsTLGridNode node = center_location + (*begin);
    neighbors_.push_back( Geovalue( grid_, property_, 
				    cursor_.node_id( node[0], node[1],
						     node[2] ) )
			  );
    //neighbors_.push_back( grid_->geovalue( center_location + (*begin) ) );
  }
}
void MgridWindowNeighborhood::find_neighbors( const Geovalue& center ) {
  size_ = -1;
  center_ = center;
  center_.set_property_array( property_ );

  _mcursor = dynamic_cast<MaskedGridCursor*>(grid_->cursor());
  neighbors_.clear();
  if( !property_ ) return;

  //SGrid_cursor cursor( *grid_->cursor() );
  GsTLInt i,j,k;
  _mcursor->coords( center.node_id(), i,j,k ); 
  GsTLGridNode center_location( i,j,k );

  if( geom_.size() == 0 ) return;

  Grid_template::iterator begin = geom_.begin();
  Grid_template::iterator bound = geom_.end()-1;

  while (bound != begin) {
    GsTLGridNode p = center_location + (*bound);
    GsTLInt node_id = _mcursor->node_id( p[0], p[1], p[2] );
    if( node_id < 0 ) {
      bound--;
      continue;
    }
    if( property_->is_informed( node_id ) )
      break;
    else
      bound--;
  }

  bound++;
  for( ; begin != bound ; ++begin ) {
    GsTLGridNode node = center_location + (*begin);
	  if (_mcursor->node_id( node[0], node[1], node[2] ) < 0)
		  continue;
    neighbors_.push_back( Geovalue( grid_, property_, 
				    _mcursor->node_id( node[0], node[1],
						     node[2] ) )
			  );
  }
}