ug4
ug::RasterLayers Class Reference

#include <raster_layer_util.h>

Classes

struct  layer_t
 

Public Types

typedef RasterLayerDesc LayerDesc
 
typedef SPRasterLayerDesc SPLayerDesc
 

Public Member Functions

void blur_layers (number alpha, size_t numIterations)
 smoothens the values in each layer by averaging with neighboured values More...
 
void construct_relative_to_global_height_table (size_t iterations, number alpha)
 Prepares a table for better 'relative_to_global_height' values in invalid inner regions. More...
 
void eliminate_invalid_cells ()
 eliminates invalid cells by filling those cells with averages of neighboring valid cells More...
 
bool empty () const
 
std::pair< int, int > get_layer_indices (const vector3 &c) const
 returns an index-pair of the layers above and below the specified point More...
 
Heightfieldheightfield (size_t i)
 
const Heightfieldheightfield (size_t i) const
 
void invalidate_flat_cells ()
 invalidates cells in lower levels which are too close to valid cells in higher levels More...
 
void invalidate_relative_to_global_height_table ()
 invalidates the table construced by 'construct_relative_to_global_height_table' More...
 
void invalidate_small_lenses (number minArea)
 invalidates cells that belong to a small lense regarding its horizontal area More...
 
layer_tlayer (size_t i)
 
const layer_tlayer (size_t i) const
 
void load_from_files (const std::vector< std::string > &filenames, number minLayerHeight)
 loads raster data from a list of .asc files. More...
 
number min_height (size_t i) const
 
size_t num_layers () const
 
layer_toperator[] (size_t i)
 
const layer_toperator[] (size_t i) const
 
number relative_to_global_height (const vector2 &c, number relHeight) const
 transforms a relative height to an absolute height for a given x-y-coordinate. More...
 
number relative_to_global_height_simple (const vector2 &c, number relHeight) const
 transforms a relative height to an absolute height for a given x-y-coordinate. More...
 
void remove_small_holes (number maxArea)
 removes small holes by expanding the layer in those regions to the specified height More...
 
void resize (size_t newSize)
 
void set_min_height (size_t i, number h)
 
size_t size () const
 
void snap_cells_to_higher_layers ()
 sets invalid or flat cells to the value of the corresponding cell in the level above More...
 
const layer_ttop () const
 
std::pair< int, numbertrace_line_down (const vector2 &c, size_t firstLayer) const
 finds the first valid value at the given x-y-coordinate starting at the specified layer moving downwards. More...
 
std::pair< int, numbertrace_line_up (const vector2 &c, size_t firstLayer) const
 finds the first valid value at the given x-y-coordinate starting at the specified layer moving downwards. More...
 
void load_from_files (const std::vector< LayerDesc > &layerDescs)
 loads raster data from a list of .asc files. More...
 
void load_from_files (const std::vector< SPLayerDesc > &layerDescs)
 loads raster data from a list of .asc files. More...
 

Private Member Functions

template<class Archive >
void load (Archive &ar, const unsigned int version)
 
template<class Archive >
void save (Archive &ar, const unsigned int version) const
 
number upper_lower_dist_relation (Field< number > &lower, Field< number > &middle, Field< number > &upper, size_t ix, size_t iy)
 returns dist(middle, upper, ix, iy) / dist(lower, upper, ix, iy) More...
 

Private Attributes

std::vector< SmartPtr< layer_t > > m_layers
 
std::vector< SmartPtr< Heightfield > > m_relativeToGlobalHeights
 

Friends

class boost::serialization::access
 

Member Typedef Documentation

◆ LayerDesc

◆ SPLayerDesc

Member Function Documentation

◆ blur_layers()

void ug::RasterLayers::blur_layers ( number  alpha,
size_t  numIterations 
)

smoothens the values in each layer by averaging with neighboured values

References alpha, and ug::BlurField().

◆ construct_relative_to_global_height_table()

void ug::RasterLayers::construct_relative_to_global_height_table ( size_t  iterations,
number  alpha 
)

Prepares a table for better 'relative_to_global_height' values in invalid inner regions.

Constructs a table in which interior no-data-values are replaced by a a relaxed value, computed through smoothing the relative distances to the upper and lower layers of local neighbor cells.

Note
if the underlying layers have been changed or new ones have been added, this method has to be called again to reflect those changes in the constructed table.
Parameters
iterationsthe number of relaxation iterations (e.g. 1000)
alphathe relative amount of how much a value may change in each iteration (between 0 and 1, e.g. 0.5)

References alpha, ug::Field< T >::at(), ug::Heightfield::field(), ug::Field< T >::height(), ug::Heightfield::index_to_coordinate(), ug::CellIdx::ix, ug::CellIdx::iy, make_sp(), ug::Heightfield::no_data_value(), and ug::Field< T >::width().

◆ eliminate_invalid_cells()

void ug::RasterLayers::eliminate_invalid_cells ( )

eliminates invalid cells by filling those cells with averages of neighboring valid cells

References ug::EliminateInvalidCells(), ug::Heightfield::field(), and ug::Heightfield::no_data_value().

◆ empty()

bool ug::RasterLayers::empty ( ) const
inline

References m_layers.

Referenced by ug::SnapToHorizontalRaster().

◆ get_layer_indices()

std::pair< int, int > ug::RasterLayers::get_layer_indices ( const vector3 c) const

returns an index-pair of the layers above and below the specified point

If there is no layer above or below, the associated component of the returned is set to -1.

◆ heightfield() [1/2]

Heightfield& ug::RasterLayers::heightfield ( size_t  i)
inline

◆ heightfield() [2/2]

const Heightfield& ug::RasterLayers::heightfield ( size_t  i) const
inline

◆ invalidate_flat_cells()

void ug::RasterLayers::invalidate_flat_cells ( )

◆ invalidate_relative_to_global_height_table()

void ug::RasterLayers::invalidate_relative_to_global_height_table ( )

invalidates the table construced by 'construct_relative_to_global_height_table'

Use this method if you want to make sure that no special table is used during 'relative_to_global_height'.

◆ invalidate_small_lenses()

void ug::RasterLayers::invalidate_small_lenses ( number  minArea)

invalidates cells that belong to a small lense regarding its horizontal area

References ug::Heightfield::cell_size(), ug::Heightfield::field(), and ug::InvalidateSmallLenses().

◆ layer() [1/2]

layer_t& ug::RasterLayers::layer ( size_t  i)
inline

◆ layer() [2/2]

const layer_t& ug::RasterLayers::layer ( size_t  i) const
inline

References m_layers.

◆ load()

template<class Archive >
void ug::RasterLayers::load ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

◆ load_from_files() [1/3]

void ug::RasterLayers::load_from_files ( const std::vector< LayerDesc > &  layerDescs)

loads raster data from a list of .asc files.

layerDescs.front() represents the bottom of the lowest layer. layerDescs.top() represents the terrain surface. All data inbetween is interpreted as sorted layer-bottoms from bottom to top.

References ug::LoadHeightfieldFromASC(), and resize().

◆ load_from_files() [2/3]

void ug::RasterLayers::load_from_files ( const std::vector< SPLayerDesc > &  layerDescs)

loads raster data from a list of .asc files.

layerDescs.front() represents the bottom of the lowest layer. layerDescs.top() represents the terrain surface. All data inbetween is interpreted as sorted layer-bottoms from bottom to top.

References end_for, and for_each_in_vec.

◆ load_from_files() [3/3]

void ug::RasterLayers::load_from_files ( const std::vector< std::string > &  filenames,
number  minLayerHeight 
)

loads raster data from a list of .asc files.

filenames.front() represents the bottom of the lowest layer. filenames.top() represents the terrain surface. All data inbetween is interpreted as sorted layer-bottoms from bottom to top.

Parameters
minLayerHeightIf the height of the layer at a given point is smaller than this value, then the layer is considered to be non-existant at this point (i.e. has a hole)

References end_for, and for_each_in_vec.

◆ min_height()

number ug::RasterLayers::min_height ( size_t  i) const
inline

◆ num_layers()

size_t ug::RasterLayers::num_layers ( ) const
inline

References m_layers.

Referenced by ug::ExtrudeLayers(), and ug::ExtrudeLayersMixed().

◆ operator[]() [1/2]

layer_t& ug::RasterLayers::operator[] ( size_t  i)
inline

References m_layers.

◆ operator[]() [2/2]

const layer_t& ug::RasterLayers::operator[] ( size_t  i) const
inline

References m_layers.

◆ relative_to_global_height()

number ug::RasterLayers::relative_to_global_height ( const vector2 c,
number  relHeight 
) const

transforms a relative height to an absolute height for a given x-y-coordinate.

relative height is a value between 0 and #numLayers-1. if it is an integer value the returned height will match the height of the associated layer. If not or if the value would be invalid, it the non-integer fraction is used to interpolate between the next higher and the next lower level.

Note
if 'construct_relative_to_global_height_table' was called before this method, a more sophisticated height-value computation is performed in inner invalid cells. This is especially useful if a pure prism geometry was constructed from layers with holes.

References ug::SMALL.

Referenced by ug::ExtrudeLayers(), and ug::ProjectToLayer().

◆ relative_to_global_height_simple()

number ug::RasterLayers::relative_to_global_height_simple ( const vector2 c,
number  relHeight 
) const

transforms a relative height to an absolute height for a given x-y-coordinate.

This method works similar to the original 'relative_to_global_height', however, it always works on the orignal layer data and follows an equal distances approach for no-data-cells. It thus ignores tables constructed through 'construct_relative_to_global_height_table'. If the former method hasn't been called or if 'invalidate_relative_to_global_height_table' has been called, this method will do the same as 'relative_to_global_height'.

References ug::SMALL, and UG_COND_THROW.

◆ remove_small_holes()

◆ resize()

void ug::RasterLayers::resize ( size_t  newSize)

References make_sp().

◆ save()

template<class Archive >
void ug::RasterLayers::save ( Archive &  ar,
const unsigned int  version 
) const
inlineprivate

◆ set_min_height()

void ug::RasterLayers::set_min_height ( size_t  i,
number  h 
)
inline

◆ size()

size_t ug::RasterLayers::size ( ) const
inline

◆ snap_cells_to_higher_layers()

void ug::RasterLayers::snap_cells_to_higher_layers ( )

sets invalid or flat cells to the value of the corresponding cell in the level above

This method is somehow antithetical to 'invalidate_flat_cells', since it reassigns values to invalid cells which are shadowed by valid cells.

References ug::Field< T >::at(), ug::Heightfield::field(), ug::Field< T >::height(), ug::Heightfield::index_to_coordinate(), ug::Heightfield::interpolate(), ug::Heightfield::no_data_value(), and ug::Field< T >::width().

◆ top()

const layer_t& ug::RasterLayers::top ( ) const
inline

◆ trace_line_down()

std::pair< int, number > ug::RasterLayers::trace_line_down ( const vector2 c,
size_t  firstLayer 
) const

finds the first valid value at the given x-y-coordinate starting at the specified layer moving downwards.

returns a pair containing the layer-index in which the valid value was found (first) and the value at the given coordinate in that layer. Returns -1 if no such layer was found.

Referenced by ug::ExtrudeLayers().

◆ trace_line_up()

std::pair< int, number > ug::RasterLayers::trace_line_up ( const vector2 c,
size_t  firstLayer 
) const

finds the first valid value at the given x-y-coordinate starting at the specified layer moving downwards.

returns a pair containing the layer-index in which the valid value was found (first) and the value at the given coordinate in that layer. Returns -1 if no such layer was found.

Referenced by ug::ExtrudeLayers().

◆ upper_lower_dist_relation()

number ug::RasterLayers::upper_lower_dist_relation ( Field< number > &  lower,
Field< number > &  middle,
Field< number > &  upper,
size_t  ix,
size_t  iy 
)
private

returns dist(middle, upper, ix, iy) / dist(lower, upper, ix, iy)

If dist(lower, upper, ix, iy) == 0, 0 is returned.

References ug::Field< T >::at().

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Member Data Documentation

◆ m_layers

std::vector<SmartPtr<layer_t> > ug::RasterLayers::m_layers
private

◆ m_relativeToGlobalHeights

std::vector<SmartPtr<Heightfield> > ug::RasterLayers::m_relativeToGlobalHeights
private

In this array, interior pixels with no-data-value are replaced by a relaxed value, computed through smoothing the relative distances to the upper and lower layers of local neighbor cells. This array has to be constructed explicitely through a call to 'construct_relative_to_global_height_table'.

Referenced by load(), and save().


The documentation for this class was generated from the following files: