ug4
ug::Heightfield Class Reference

#include <heightfield_util.h>

Public Member Functions

void blur (number alpha, size_t numIterations)
 Smoothens the field by adjusting the value of each pixel towards the average of its neighbours. More...
 
const vector2cell_size () const
 
std::pair< int, int > coordinate_to_index (number x, number y) const
 returns the index-tuple of the closest field-entry More...
 
bool eliminate_invalid_cells ()
 eliminates invalid cells by repeatedly filling those cells with averages of neighboring cells More...
 
vector2 extent () const
 returns the x- and y-extent of the heightfield More...
 
Field< number > & field ()
 
const Field< number > & field () const
 
 Heightfield ()
 
vector2 index_to_coordinate (int ix, int iy) const
 returns the coordinate of the given cell (specified through an index-tuple) More...
 
void move (const vector2 &v)
 
number no_data_value () const
 
const vector2offset () const
 
void set_cell_size (const vector2 &s)
 
void set_no_data_value (number val)
 
void set_offset (const vector2 &o)
 
number interpolate (number x, number y, int interpOrder) const
 returns the interpolated value at the given location. More...
 
number interpolate (const vector2 &c, int interpOrder) const
 returns the interpolated value at the given location. More...
 
number interpolate (number x, number y) const
 returns the interpolated value at the given location. More...
 
number interpolate (const vector2 &c) const
 returns the interpolated value at the given location. More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

vector2 m_cellSize
 
Field< numberm_field
 
number m_noDataValue
 
vector2 m_offset
 

Friends

class boost::serialization::access
 

Detailed Description

A heightfield represents a grid of number-values together with descriptors for the cell dimensions and the total offset. You can manually create heightfields or load them from a file. Given a heightfield you may create a quad/tri grid or extract the heightfields boundary into a grid. Have a look at field_util.h, too, which declares some useful functions (e.g. blurring).

See also
LoadHeightfieldFromASC, CreateGridFromField, CreateGridFromFieldBoundary

Constructor & Destructor Documentation

◆ Heightfield()

ug::Heightfield::Heightfield ( )

Member Function Documentation

◆ blur()

void ug::Heightfield::blur ( number  alpha,
size_t  numIterations 
)

Smoothens the field by adjusting the value of each pixel towards the average of its neighbours.

References alpha, ug::BlurField(), field(), and no_data_value().

◆ cell_size()

◆ coordinate_to_index()

std::pair< int, int > ug::Heightfield::coordinate_to_index ( number  x,
number  y 
) const

returns the index-tuple of the closest field-entry

References m_cellSize, and m_offset.

Referenced by interpolate(), ug::RasterLayers::remove_small_holes(), and ug::SnapToHorizontalRaster().

◆ eliminate_invalid_cells()

bool ug::Heightfield::eliminate_invalid_cells ( )

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

The field has to contain at least one valid cell. If it doesn't, false is returned.

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

◆ extent()

vector2 ug::Heightfield::extent ( ) const

returns the x- and y-extent of the heightfield

References ug::Field< T >::height(), m_cellSize, m_field, and ug::Field< T >::width().

◆ field() [1/2]

◆ field() [2/2]

const Field<number>& ug::Heightfield::field ( ) const
inline

References m_field.

◆ index_to_coordinate()

vector2 ug::Heightfield::index_to_coordinate ( int  ix,
int  iy 
) const

◆ interpolate() [1/4]

number ug::Heightfield::interpolate ( const vector2 c) const
inline

returns the interpolated value at the given location.

returns the interpolated value at the given location. Through 'interpOrder' one may specify the order of interpolation:

  • 0: piecewise constant (nearest entry)
  • 1: linear
Todo:
: add a method 'set_interpolation_method' to also support bilinear- or spline-interpolation

References interpolate().

◆ interpolate() [2/4]

number ug::Heightfield::interpolate ( const vector2 c,
int  interpOrder 
) const
inline

returns the interpolated value at the given location.

returns the interpolated value at the given location. Through 'interpOrder' one may specify the order of interpolation:

  • 0: piecewise constant (nearest entry)
  • 1: linear
Todo:
: add a method 'set_interpolation_method' to also support bilinear- or spline-interpolation

References interpolate().

◆ interpolate() [3/4]

number ug::Heightfield::interpolate ( number  x,
number  y 
) const
inline

returns the interpolated value at the given location.

returns the interpolated value at the given location. Through 'interpOrder' one may specify the order of interpolation:

  • 0: piecewise constant (nearest entry)
  • 1: linear
Todo:
: add a method 'set_interpolation_method' to also support bilinear- or spline-interpolation

References interpolate().

◆ interpolate() [4/4]

number ug::Heightfield::interpolate ( number  x,
number  y,
int  interpOrder 
) const

returns the interpolated value at the given location.

returns the interpolated value at the given location. Through 'interpOrder' one may specify the order of interpolation:

  • 0: piecewise constant (nearest entry)
  • 1: linear
Todo:
: add a method 'set_interpolation_method' to also support bilinear- or spline-interpolation

References ug::Field< T >::at(), coordinate_to_index(), ug::Field< T >::height(), m_cellSize, m_field, m_noDataValue, m_offset, UG_THROW, and ug::Field< T >::width().

Referenced by ug::ExtrudeLayersMixed(), interpolate(), ug::RasterLayers::invalidate_flat_cells(), and ug::RasterLayers::snap_cells_to_higher_layers().

◆ move()

void ug::Heightfield::move ( const vector2 v)
inline

References m_offset.

◆ no_data_value()

◆ offset()

const vector2& ug::Heightfield::offset ( ) const
inline

◆ serialize()

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

◆ set_cell_size()

void ug::Heightfield::set_cell_size ( const vector2 s)
inline

References m_cellSize, and s.

Referenced by ug::LoadHeightfieldFromASC().

◆ set_no_data_value()

void ug::Heightfield::set_no_data_value ( number  val)
inline

References m_noDataValue.

Referenced by ug::LoadHeightfieldFromASC().

◆ set_offset()

void ug::Heightfield::set_offset ( const vector2 o)
inline

References m_offset.

Referenced by ug::LoadHeightfieldFromASC().

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Member Data Documentation

◆ m_cellSize

◆ m_field

Field<number> ug::Heightfield::m_field
private

Referenced by extent(), field(), interpolate(), and serialize().

◆ m_noDataValue

number ug::Heightfield::m_noDataValue
private

◆ m_offset

vector2 ug::Heightfield::m_offset
private

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