GCOP  1.0
Public Member Functions | Static Public Member Functions | Public Attributes
gcop::Dem Class Reference

#include <dem.h>

List of all members.

Public Member Functions

 Dem ()
 Dem (const char *fname, double cs=1.0, double ds=1.0, const double *o=0)
 Dem (double w, double h, double cs=1.0, double ds=1.0, const double *o=0)
 Dem (const Dem &dem)
virtual ~Dem ()
virtual bool IsValid (double x, double y) const
virtual double Get (double x, double y) const
double GetNormal (double n[3], double x, double y) const
const double * GetNormal (double x, double y) const
virtual void Get (double *p, int i, int j) const
void Set (int i, int j, double z)
void Set (double x, double y, double z, double s=0)
void Clear ()
void Scale (double s)
bool Inside (double x, double y, double z) const
void Load (const char *fname)
const double * GetNormal (int i, int j) const
void ComputeNormals ()
void Dilate (double r, bool cube=true)
void AddBoundary (double h)
void Convolve (double sigma, bool cn=true, double thresh=0)
void Point2Index (int &i, int &j, double x, double y) const
void Index2Point (double &x, double &y, int i, int j) const

Static Public Member Functions

static double bilinterp (const double *z, int w, int h, double xi, double yi, double eps=1e-10)

Public Attributes

double w
 width
double h
 height
double cs
 cell size
double ds
 data scale (height scale)
double o [3]
 origin
int ni
 number of rows
int nj
 number of columns
double * data
 raw data (could be postprocessed)
double * odata
 original raw data
double * normals
 normals
double eps
 numerical tolerance for interpolation

Detailed Description

Digital Elevation Map (Dem).

Author: Marin Kobilarov -- Copyright (C) 2004


Constructor & Destructor Documentation

Dem::Dem ( )

References o.

Dem::Dem ( const char *  fname,
double  cs = 1.0,
double  ds = 1.0,
const double *  o = 0 
)

Initialize the Dem using a PPM file.

Parameters:
fnamename of PPM file
cscell size
dsdata size
oorigin - a 3x1 array (optional)

References ComputeNormals(), Load(), and odata.

Dem::Dem ( double  w,
double  h,
double  cs = 1.0,
double  ds = 1.0,
const double *  o = 0 
)

Initialize an empty (flat) Dem with predefined width and height

Parameters:
wwidth
hheight
cscell size
dsdata size
oorigin - a 3x1 array (optional)

References data, ni, nj, normals, and odata.

Dem::Dem ( const Dem dem)

Copy construcor

Parameters:
demDEM

References data, ni, nj, normals, o, and odata.

Dem::~Dem ( ) [virtual]

References data, normals, and odata.


Member Function Documentation

void Dem::AddBoundary ( double  h)

Adds a boundary of height h around the whole Dem

Parameters:
hheight

References data, h, ni, and nj.

double Dem::bilinterp ( const double *  z,
int  w,
int  h,
double  xi,
double  yi,
double  eps = 1e-10 
) [static]

Helper for interpolation

References eps.

Referenced by Get(), and GetNormal().

void Dem::Clear ( )

Clears the whole dem

References data, ni, and nj.

Compute all normals once the Dem is loaded and ready

References CROSS, Get(), MINUS3, ni, nj, NORM3, and normals.

Referenced by Convolve(), Dem(), and Dilate().

void Dem::Convolve ( double  sigma,
bool  cn = true,
double  thresh = 0 
)

Apply Gaussian convolution filter with std deviation sigma

Parameters:
sigmastandard deviation (sigma=0) has no effect
cnflag to recompute normals (set to false in order to speedup processing when computing normals is not necessary)
onlyconsider values above thresh

References ComputeNormals(), cs, data, ni, nj, and odata.

void Dem::Dilate ( double  r,
bool  cube = true 
)

Dilate the DEM

Parameters:
rdistance (radius of ball, or half side-length of cube)
cubewhether to use cube or ball

References ComputeNormals(), cs, data, ni, nj, and odata.

double Dem::Get ( double  x,
double  y 
) const [virtual]

Get evelation at point (x,y)

Parameters:
xx-coordinate
yy-coordinate
Returns:
height

References bilinterp(), cs, data, h, IsValid(), ni, nj, and o.

Referenced by ComputeNormals(), gcop::DemView::Init(), Inside(), gcop::PqpDem< T, _nx, _nu, _np >::PqpDem(), and gcop::DemView::RenderFrame().

void Dem::Get ( double *  p,
int  i,
int  j 
) const [virtual]

Get point p=(x,y,z) corresponding to indices (i,j)

Parameters:
ppoint 3x1 array
ii-index
jj-index

References cs, data, h, ni, nj, and o.

double Dem::GetNormal ( double  n[3],
double  x,
double  y 
) const

Give both the elevation and the normal n at point (x,y)

Parameters:
nnormal
xx-coordinate
yy-coordinate
Returns:
z-coordinate (elevation)

References bilinterp(), cs, data, h, IsValid(), ni, nj, normals, o, and SET3.

const double * Dem::GetNormal ( double  x,
double  y 
) const

Return pointer to the normal at point (x,y)

Parameters:
xx-coordinate
yy-coordinate
Returns:
pointer to normal

References cs, h, IsValid(), nj, normals, and o.

const double * Dem::GetNormal ( int  i,
int  j 
) const

Get the normal at point (i,j)

Parameters:
ii-index
jj-index
Returns:
pointer to 3x1 array with the normal vector

References nj, and normals.

void Dem::Index2Point ( double &  x,
double &  y,
int  i,
int  j 
) const

References cs, h, and o.

Referenced by gcop::Body3dDemController< nu >::GetTraj().

bool Dem::Inside ( double  x,
double  y,
double  z 
) const

Checks if point (x,y,z) is insize (under the surface) of the Dem

Parameters:
xx-coordinate
yy-coordinate
zz-coordinate
Returns:
true if Get(x,y) > z

References Get(), and IsValid().

bool gcop::Dem::IsValid ( double  x,
double  y 
) const [inline, virtual]

Is point (x,y) valid, i.e. within the map bounds

Parameters:
xx-position
yy-position
Returns:
true if valid

References eps, h, o, and w.

Referenced by Get(), GetNormal(), Inside(), and Set().

void Dem::Load ( const char *  fname)

Load the Dem from a PPM file

Parameters:
fnamefile name

References cs, data, ds, h, ni, nj, normals, and w.

Referenced by Dem().

void Dem::Point2Index ( int &  i,
int &  j,
double  x,
double  y 
) const

References cs, h, and o.

Referenced by gcop::Body3dDemController< nu >::GetTraj().

void Dem::Scale ( double  s)

References data, ni, and nj.

void Dem::Set ( int  i,
int  j,
double  z 
)

Set height at point at index (i,j)

Parameters:
ii-index
jj-index
zheight

References data, ni, and nj.

void Dem::Set ( double  x,
double  y,
double  z,
double  s = 0 
)

Set height at point (x,y)

Parameters:
xx-coordinate
yy-coordinate
zheight
ssize of point - optionally instead of setting single point one case set a square of points to height z, effectively creating a prallellepiped at point (x,y) with side s and height z

References cs, data, eps, h, IsValid(), nj, and o.


Member Data Documentation

double gcop::Dem::cs
double* gcop::Dem::data

raw data (could be postprocessed)

Referenced by AddBoundary(), Clear(), Convolve(), Dem(), Dilate(), Get(), GetNormal(), Load(), Scale(), Set(), and ~Dem().

double gcop::Dem::ds

data scale (height scale)

Referenced by Load().

numerical tolerance for interpolation

Referenced by bilinterp(), IsValid(), and Set().

double gcop::Dem::h
double gcop::Dem::o[3]

original raw data

Referenced by Convolve(), Dem(), Dilate(), and ~Dem().

double gcop::Dem::w

width

Referenced by IsValid(), Load(), and gcop::DemView::RenderFrame().


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