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 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... | |
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 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_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. More... | |
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. 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_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. More... | |
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. 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 |
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().
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 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().
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().
|
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.
|
inline |
References ug::RasterLayers::layer_t::heightfield, and layer().
Referenced by ug::ExtrudeLayersMixed(), ug::MeshLayerBoundaries(), and ug::MeshLayers().
|
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(), ug::Heightfield::index_to_coordinate(), ug::Heightfield::interpolate(), ug::Heightfield::no_data_value(), and ug::Field< T >::width().
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'.
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().
|
inline |
References m_layers.
Referenced by 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 ug::LoadHeightfieldFromASC(), and resize().
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.
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, and for_each_in_vec.
|
inline |
References layer(), and ug::RasterLayers::layer_t::minHeight.
Referenced by ug::ExtrudeLayers(), and ug::ExtrudeLayersMixed().
|
inline |
References m_layers.
Referenced by ug::ExtrudeLayers(), and ug::ExtrudeLayersMixed().
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 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 ug::SMALL, and UG_COND_THROW.
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(), ug::Heightfield::index_to_coordinate(), ug::Heightfield::no_data_value(), ug::Field< T >::resize_no_copy(), and ug::Field< T >::width().
void ug::RasterLayers::resize | ( | size_t | newSize | ) |
References make_sp().
|
inlineprivate |
References m_layers, and m_relativeToGlobalHeights.
|
inline |
References layer(), and ug::RasterLayers::layer_t::minHeight.
|
inline |
References m_layers.
Referenced by ug::ExtrudeLayers(), ug::ExtrudeLayersMixed(), ug::MeshLayerBoundaries(), ug::MeshLayers(), and ug::ProjectToLayer().
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().
|
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.
Referenced by ug::ExtrudeLayers().
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().
|
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().
|
friend |
Referenced by empty(), layer(), load(), num_layers(), operator[](), 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'.