ug4
|
#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 | |
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. | |
void | eliminate_invalid_cells () |
eliminates invalid cells by filling those cells with averages of neighboring valid cells | |
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 | |
Heightfield & | heightfield (size_t i) |
const Heightfield & | heightfield (size_t i) const |
void | invalidate_flat_cells () |
invalidates cells in lower levels which are too close to valid cells in higher levels | |
void | invalidate_relative_to_global_height_table () |
invalidates the table construced by 'construct_relative_to_global_height_table' | |
void | invalidate_small_lenses (number minArea) |
invalidates cells that belong to a small lense regarding its horizontal area | |
layer_t & | layer (size_t i) |
const layer_t & | layer (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. | |
number | min_height (size_t i) const |
size_t | num_layers () const |
layer_t & | operator[] (size_t i) |
const layer_t & | operator[] (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. | |
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. | |
void | remove_small_holes (number maxArea) |
removes small holes by expanding the layer in those regions to the specified height | |
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 | |
const layer_t & | top () const |
std::pair< int, number > | 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. | |
std::pair< int, number > | 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. | |
void | load_from_files (const std::vector< LayerDesc > &layerDescs) |
loads raster data from a list of .asc files. | |
void | load_from_files (const std::vector< SPLayerDesc > &layerDescs) |
loads raster data from a list of .asc files. | |
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) | |
Private Attributes | |
std::vector< SmartPtr< layer_t > > | m_layers |
std::vector< SmartPtr< Heightfield > > | m_relativeToGlobalHeights |
Friends | |
class | boost::serialization::access |
void ug::RasterLayers::blur_layers | ( | number | alpha, |
size_t | numIterations | ||
) |
smoothens the values in each layer by averaging with neighboured values
References ug::BlurField(), heightfield(), and size().
Referenced by ug::bridge::RegisterGridBridge_Layers().
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.
iterations | the number of relaxation iterations (e.g. 1000) |
alpha | the relative amount of how much a value may change in each iteration (between 0 and 1, e.g. 0.5) |
References ug::Field< T >::at(), ug::Heightfield::field(), ug::Field< T >::height(), heightfield(), ug::Heightfield::index_to_coordinate(), ug::CellIdx::ix, ug::CellIdx::iy, layer(), m_layers, m_relativeToGlobalHeights, make_sp(), ug::RasterLayers::layer_t::minHeight, ug::Heightfield::no_data_value(), relative_to_global_height_simple(), trace_line_up(), upper_lower_dist_relation(), and ug::Field< T >::width().
Referenced by ug::bridge::RegisterGridBridge_Layers().
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(), heightfield(), ug::Heightfield::no_data_value(), and size().
Referenced by ug::bridge::RegisterGridBridge_Layers().
|
inline |
References m_layers.
Referenced by ug::SnapToHorizontalRaster().
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.
References trace_line_down().
|
inline |
References ug::RasterLayers::layer_t::heightfield, and layer().
Referenced by blur_layers(), construct_relative_to_global_height_table(), eliminate_invalid_cells(), ug::ExtrudeLayersMixed(), invalidate_flat_cells(), invalidate_small_lenses(), load_from_files(), ug::MeshLayerBoundaries(), ug::MeshLayers(), remove_small_holes(), snap_cells_to_higher_layers(), trace_line_down(), and trace_line_up().
|
inline |
References ug::RasterLayers::layer_t::heightfield, and layer().
void ug::RasterLayers::invalidate_flat_cells | ( | ) |
invalidates cells in lower levels which are too close to valid cells in higher levels
References ug::Field< T >::at(), ug::Heightfield::field(), ug::Field< T >::height(), heightfield(), ug::Heightfield::index_to_coordinate(), ug::Heightfield::interpolate(), min_height(), ug::Heightfield::no_data_value(), size(), and ug::Field< T >::width().
Referenced by ug::bridge::RegisterGridBridge_Layers().
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'.
References m_relativeToGlobalHeights.
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(), heightfield(), ug::InvalidateSmallLenses(), and size().
Referenced by ug::bridge::RegisterGridBridge_Layers().
|
inline |
References m_layers.
Referenced by construct_relative_to_global_height_table(), heightfield(), heightfield(), min_height(), ug::ProjectToLayer(), and set_min_height().
|
inlineprivate |
References m_layers, m_relativeToGlobalHeights, and make_sp().
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 heightfield(), ug::LoadHeightfieldFromASC(), min_height(), resize(), and set_min_height().
Referenced by load_from_files(), load_from_files(), and ug::bridge::RegisterGridBridge_Layers().
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, for_each_in_vec, and load_from_files().
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.
minLayerHeight | If 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, for_each_in_vec, and load_from_files().
|
inline |
References layer(), and ug::RasterLayers::layer_t::minHeight.
Referenced by ug::ExtrudeLayers(), ug::ExtrudeLayersMixed(), invalidate_flat_cells(), load_from_files(), remove_small_holes(), and snap_cells_to_higher_layers().
|
inline |
References m_layers.
Referenced by ug::ExtrudeLayers(), ug::ExtrudeLayersMixed(), and relative_to_global_height_simple().
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.
References m_relativeToGlobalHeights, relative_to_global_height_simple(), and ug::SMALL.
Referenced by ug::ExtrudeLayers(), and ug::ProjectToLayer().
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 num_layers(), ug::SMALL, trace_line_down(), trace_line_up(), and UG_COND_THROW.
Referenced by construct_relative_to_global_height_table(), and relative_to_global_height().
void ug::RasterLayers::remove_small_holes | ( | number | maxArea | ) |
removes small holes by expanding the layer in those regions to the specified height
References ug::Field< T >::at(), ug::Heightfield::cell_size(), ug::Heightfield::coordinate_to_index(), ug::Heightfield::field(), ug::Field< T >::fill_all(), ug::Field< T >::height(), heightfield(), ug::Heightfield::index_to_coordinate(), min_height(), ug::Heightfield::no_data_value(), ug::Field< T >::resize_no_copy(), size(), trace_line_up(), and ug::Field< T >::width().
Referenced by ug::bridge::RegisterGridBridge_Layers().
void ug::RasterLayers::resize | ( | size_t | newSize | ) |
References m_layers, make_sp(), and size().
Referenced by load_from_files().
|
inlineprivate |
References m_layers, and m_relativeToGlobalHeights.
|
inline |
References layer(), and ug::RasterLayers::layer_t::minHeight.
Referenced by load_from_files().
|
inline |
References m_layers.
Referenced by blur_layers(), eliminate_invalid_cells(), ug::ExtrudeLayers(), ug::ExtrudeLayersMixed(), invalidate_flat_cells(), invalidate_small_lenses(), ug::MeshLayerBoundaries(), ug::MeshLayers(), ug::ProjectToLayer(), remove_small_holes(), resize(), snap_cells_to_higher_layers(), and trace_line_up().
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(), heightfield(), ug::Heightfield::index_to_coordinate(), ug::Heightfield::interpolate(), min_height(), ug::Heightfield::no_data_value(), size(), and ug::Field< T >::width().
Referenced by ug::bridge::RegisterGridBridge_Layers().
|
inline |
References m_layers.
Referenced by ug::ExtrudeLayers(), ug::ExtrudeLayersMixed(), and ug::SnapToHorizontalRaster().
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.
References heightfield(), and ug::Heightfield::interpolate().
Referenced by ug::ExtrudeLayers(), get_layer_indices(), and relative_to_global_height_simple().
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.
References heightfield(), ug::Heightfield::interpolate(), and size().
Referenced by construct_relative_to_global_height_table(), ug::ExtrudeLayers(), relative_to_global_height_simple(), and remove_small_holes().
|
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().
Referenced by construct_relative_to_global_height_table().
|
friend |
Referenced by construct_relative_to_global_height_table(), empty(), layer(), layer(), load(), num_layers(), operator[](), operator[](), resize(), save(), size(), and top().
|
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 construct_relative_to_global_height_table(), invalidate_relative_to_global_height_table(), load(), relative_to_global_height(), and save().