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] ) ) ); } }
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 MgridNeighborhood_hd::find_neighbors( const Geovalue& center ) { appli_assert( center.grid() == grid_ ); _mcursor = dynamic_cast<EGridCursor*>(grid_->cursor()); appli_assert(_mcursor); // This is exactly the same function as // Rgrid_ellips_neighborhood::find_neighbors, except that the condition // for a node to be a neighbor is that it contains a hard-data neighbors_.clear(); if( !property_ ) return; center_ = center; center_.set_property_array( property_ ); Grid_template::const_iterator it = geom_.begin(); Grid_template::const_iterator end = geom_.end(); GsTLGridNode loc; _mcursor->coords( center.node_id(), loc[0], loc[1], loc[2] ); // "already_found" is the number of neighbors already found int already_found=0; if( includes_center_ && center_.is_harddata() ) { neighbors_.push_back( center_ ); already_found++; } while( it != end && already_found < max_neighbors_ ) { GsTLGridNode node = loc + (*it); GsTLInt node_id = _mcursor->node_id( node[0], node[1], node[2] ); if( node_id < 0 ) { it++; continue; } if( property_->is_harddata( node_id ) ) { neighbors_.push_back( Geovalue( grid_, property_, node_id ) ); already_found++; } it++; } }
//Helper function for rasterize without rotation void HalfEllipsoid::do_rotation( location_3d<int> loc, location_3d<int> cen, float angle, std::vector<Geovalue> &gbRaster, GsTLGridProperty *propTi ) { location_3d<int> loc_new = rotate_loc( loc, cen, angle ); if ( cursor_->check_triplet( loc_new[0], loc_new[1], loc_new[2] ) ) { euclidean_vector_3d<int> res = loc_new-cen; //Check if point is outside the ellipse if ( !outside( res ) ) { if ( cursor_->check_triplet( loc[0], loc[1], loc[2] ) ) { int cur_node_id = cursor_->node_id( loc[0], loc[1], loc[2] ); gbRaster.push_back( Geovalue( grid_, propTi, cur_node_id ) ); } } } }
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] ) ) ); } }
//Helper function for rasterize with built-in rotation void HalfEllipsoid::do_rotation( location_3d<int> loc, location_3d<int> cen, float angle, std::vector<Geovalue> &gbRaster, GsTLGridProperty *propTi, std::vector<float> &facies_props, int &total_nodes ) { location_3d<int> loc_new = rotate_loc( loc, cen, angle ); if ( cursor_->check_triplet( loc_new[0], loc_new[1], loc_new[2] ) ) { euclidean_vector_3d<int> res = loc_new-cen; //Check if point is outside the ellipse if ( !outside( res ) ) { if ( cursor_->check_triplet( loc[0], loc[1], loc[2] ) ) { int cur_node_id = cursor_->node_id( loc[0], loc[1], loc[2] ); gbRaster.push_back( Geovalue( grid_, propTi, cur_node_id ) ); //Update proportion of the different facies in the rotated raster int cur_index = propTi->get_value( cur_node_id ); gstl_assert( ( cur_index >= 0 ) && ( cur_index < facies_props.size() ) ); facies_props[ cur_index ]++; total_nodes++; } } } }
void Rgrid_ellips_neighborhood_hd::find_neighbors( const Geovalue& center ) { // This is exactly the same function as // Rgrid_ellips_neighborhood::find_neighbors, except that the condition // for a node to be a neighbor is that it contains a hard-data neighbors_.clear(); if( !property_ ) return; center_ = center; // center_.set_property_array( property_ ); // "already_found" is the number of neighbors already found int already_found=0; // loc will store the i,j,k coordinates of the center, node_id is the // center's node-id. They will be computed differently, whether "center" // and *this both refer to the same grid or not. GsTLGridNode loc; GsTLInt node_id = -1; if( center.grid() != grid_ ) { // "center" and "*this" do not refer to the same grid bool ok = grid_->geometry()->grid_coordinates( loc, center.location() ); if( !ok ) return; if( includes_center_ ) //GsTLInt id = cursor_.node_id( loc[0], loc[1], loc[2] ); node_id = cursor_.node_id( loc[0], loc[1], loc[2] ); } else { // "center" and "*this" both refer to the same grid cursor_.coords( center.node_id(), loc[0], loc[1], loc[2] ); node_id = center.node_id(); } if( includes_center_ && property_->is_informed( node_id ) ) { neighbors_.push_back( Geovalue( grid_, property_, node_id ) ); already_found++; } // Visit each node defined by the window ("geom_") // For each node, check if the node is inside the grid. // If it is and it contains a data value, add it to the list of // neighbors Grid_template::const_iterator it = geom_.begin(); Grid_template::const_iterator end = geom_.end(); while( it != end && already_found < max_neighbors_ ) { GsTLGridNode node = loc + (*it); GsTLInt node_id = cursor_.node_id( node[0], node[1], node[2] ); if( node_id < 0 ) { // The node does not belong to the grid: skip it it++; continue; } if( property_->is_harddata( node_id ) ) { // The node is informed: get the corresponding geovalue and add it // to the list of neighbors neighbors_.push_back( Geovalue( grid_, property_, node_id ) ); already_found++; } it++; } }
void MgridNeighborhood::find_neighbors( const Geovalue& center ) { _mcursor = dynamic_cast<EGridCursor*>(grid_->cursor()); appli_assert(_mcursor); neighbors_.clear(); if( !property_ ) return; center_ = center; // center_.set_property_array( property_ ); // "already_found" is the number of neighbors already found int already_found=0; // loc will store the i,j,k coordinates of the center, node_id is the // center's node-id. They will be computed differently, whether "center" // and *this both refer to the same grid or not. GsTLGridNode loc; GsTLInt node_id = -1; if( center.grid() != grid_ ) { // "center" and "*this" do not refer to the same grid bool ok = grid_->geometry()->grid_coordinates( loc, center.location() ); if( !ok ) return; if( includes_center_ ) { GsTLInt id = _mcursor->node_id( loc[0], loc[1], loc[2] ); if (id == -1) return; } } else { // "center" and "*this" both refer to the same grid _mcursor->coords( center.node_id(), loc[0], loc[1], loc[2] ); node_id = center.node_id(); /* appli_message("center node id : " << center.node_id() << ", loc: " << loc[0] << "," << loc[1] << "," << loc[2] << ". Id: " << _mcursor->node_id(loc[0],loc[1],loc[2]) << "\n"); */ } if( includes_center_ && property_->is_informed( node_id ) ) { neighbors_.push_back( Geovalue( grid_, property_, node_id ) ); already_found++; } // Visit each node defined by the window ("geom_") // For each node, check if the node is inside the grid. // If it is and it contains a data value, add it to the list of // neighbors Grid_template::const_iterator it = geom_.begin(); Grid_template::const_iterator end = geom_.end(); while( it != end && already_found < max_neighbors_ ) { GsTLGridNode node = loc + (*it); GsTLInt node_id = _mcursor->node_id( node[0], node[1], node[2] ); if( node_id < 0 ) { // The node does not belong to the grid: skip it it++; continue; } if( property_->is_informed( node_id ) ) { // The node is informed: get the corresponding geovalue and add it // to the list of neighbors neighbors_.push_back( Geovalue( grid_, property_, node_id ) ); already_found++; } it++; } }