Arches 1.0
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Arches Class Reference

The core layered data-structure of the Arches model. More...

#include <arches.h>

Inheritance diagram for Arches:
Array2 Box2

Public Member Functions

 Arches ()
 creates an empty model.
 
 ~Arches ()
 Empty.
 
void SaveArchesCube (std::ofstream &)
 Save material stacks to file. More...
 
void LoadArchesCube (std::ifstream &)
 Load material stacks from file. More...
 
 Arches (const double &, const double &, const double &)
 Creates a flat terrain. More...
 
 Arches (const QImage &, const double &=50.0)
 Creates a terrain from greyscale image. More...
 
void AddOnGroundRock (const Vector &, const double &, const double &, bool)
 Add some rock to the current layer. More...
 
void RemoveOnGroundRock (const Vector &, const double &, const double &, bool)
 This function removes some rock to the current layer above the layer. More...
 
bool Intersect (const Ray &, Vector &) const
 Compute the intersection between a ray and the terrain. More...
 
const MaterialStackat (int, int) const
 Access to a material stack. More...
 
MaterialStackat (int, int)
 Access to a material stack. More...
 
void Convert (const Vector &, int &, int &, int &) const
 Convert a point into integer coordinates. More...
 
void Convert (const Vector &, const double &, int &, int &, int &, int &, QRect &) const
 Convert a circle into integer coordinates. More...
 
Box GetBox () const
 Compute the bounding box of the scene. More...
 
Box GetBoxTight () const
 Compute the (tight) bounding box of the scene. More...
 
Box GetBox (int, int, int) const
 Get the box representing the k-th material of the column (i,j). More...
 
int Memory () const
 Compute the memory used for representing the scene. More...
 
TypeMater GetMaterial (const Vector &)
 Return the type of material at a given point. More...
 
void StabilizeAllMaterial ()
 Stabilize all unstable materials in the scene.
 
bool IsSandStackUnstable (int, int)
 Verify if some sand in the stack is unstable. More...
 
void StabilizeSandStack (int, int)
 Stabilize all the sand contains in the stack. More...
 
bool IsStoneStackUnstable (int, int) const
 Check if rocks are unstable. More...
 
void StabilizeStoneStack (int, int)
 Stabilise rocks. More...
 
bool IsEarthStackUnstable (int, int) const
 Check if earth layer is stable. More...
 
void StabilizeEarthStack (int, int)
 Stabilizes the earth layer of a given stack. More...
 
bool isSnowStackUnstable (int, int) const
 Check if snow layer is stable. More...
 
void StabilizeSnowStack (int, int)
 Stabilizes the snow layer of a stack. More...
 
void RemoveMaterialSphere (TypeMater, const Vector &, double, bool)
 Remove some material within a given sphere. More...
 
void RemoveMaterial (TypeMater)
 Remove the given material. More...
 
bool CheckMaterialInside (const Box &, TypeMater) const
 Check if a given material exists within a given box. More...
 
void DeleteSmallElements (const Vector &, double, const double &)
 Remove small material blocks inside a given region. More...
 
void AddRockSphere (const Vector &, double, bool)
 Assign rock to a user specified sphere. More...
 
void HorizontalSurfaceRock (Vector, double, double, int, double *)
 Create a flat bedrock surace.
 
void SmoothZone (const Vector &, const double &, const double &)
 Smooth the terrain in a sphere domain. More...
 
int MaterialAnalysis (const Box &, double[8]) const
 Compute the volume of the different materials inside a given input cubic volume. More...
 

Static Public Attributes

static const double ScaleXY = 0.1
 Universal horizontal scale, set to 10 cm.
 
static const double ScaleZ = 0.01
 Universal vertical scale, set to 1 cm.
 

Protected Member Functions

int SurfaceAnalysis (const Box &, double[8]) const
 Compute the area of every different material in contact with air within the input cubic volume. More...
 
int findThicknessEmptyness (int, int, int, int) const
 Calcul l'epaisseur d'air,de pierre ou d'eau dans la pile de position i j et dans l'intervalle hMin, hMax.
 

Protected Attributes

QVector< MaterialStackmaterialScene
 Material stack array.
 
QVector< int > ustack
 Set of potentially unstable stacks.
 

Static Protected Attributes

static const int SandAngle = 5
 Angle of respose for sand.
 
static const int SnowAngle = 15
 Angle of respose for snow.
 
static const int EarthAngle = 5
 Angle of respose for earth.
 
static const int StoneAngle = 8
 Angle of respose for stone.
 

Detailed Description

The core layered data-structure of the Arches model.

The data structure is defined as a two dimensional array of MaterialStack.

Date
Changed on 14.05.14

Constructor & Destructor Documentation

◆ Arches() [1/2]

Arches::Arches ( const double &  x,
const double &  y,
const double &  z 
)

Creates a flat terrain.

Parameters
xlength (in meters).
ywidth (in meters).
zheight of the terrain.

References materialScene, Array2::ny, MaterialBox::ROCK, and ScaleZ.

◆ Arches() [2/2]

Arches::Arches ( const QImage &  heightmap,
const double &  h = 50.0 
)

Creates a terrain from greyscale image.

This function involves a scaling factor which represents the size (in meters) of one grey level in the image. For importing an image from a file, simply rely on the QImage constructor with a file name as parameter.

Parameters
heightmapImage.
hScaling factor.

References MaterialStack::AddMaterialOnTop(), at(), materialScene, Array2::ny, MaterialBox::ROCK, and ScaleZ.

Member Function Documentation

◆ AddOnGroundRock()

void Arches::AddOnGroundRock ( const Vector c,
const double &  r,
const double &  e,
bool  stable 
)

Add some rock to the current layer.

Parameters
cCenter.
rRadius.
eThickness.
stableStability.

References MaterialStack::AddOnGroundRock(), Array2::ArrayVertex(), at(), ScaleZ, Quadric::Smooth(), StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().

◆ AddRockSphere()

void Arches::AddRockSphere ( const Vector c,
double  r,
bool  stable 
)

Assign rock to a user specified sphere.

This function will locally change the material, possibly erasing any previously existing material.

Parameters
cCenter.
rRadius.
stableStability.

References MaterialStack::AddRockLayer(), Array2::ArrayVertex(), at(), ScaleZ, StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().

◆ at() [1/2]

MaterialStack & Arches::at ( int  i,
int  j 
)
inline

Access to a material stack.

Parameters
i,jCoordinates of the stack.

References materialScene, and Array2::VertexIndex().

◆ at() [2/2]

const MaterialStack & Arches::at ( int  i,
int  j 
) const
inline

◆ CheckMaterialInside()

bool Arches::CheckMaterialInside ( const Box b,
TypeMater  t 
) const

Check if a given material exists within a given box.

Parameters
bThe box.
tMaterial index.

References at(), Box2::b, Box2::Box2(), CheckMaterialInside(), ScaleZ, and Array2::VertexIntegerArea().

Referenced by CheckMaterialInside().

◆ Convert() [1/2]

void Arches::Convert ( const Vector p,
const double &  r,
int &  x,
int &  y,
int &  z,
int &  ir,
QRect &  view 
) const

Convert a circle into integer coordinates.

Parameters
pVector.
rRadius.
x,yInteger coordinates of the corresponding material stack.
zHeight.
irInteger radius.
viewIntersection of the terrain with the disk region.

References Convert(), Array2::ny, and ScaleXY.

◆ Convert() [2/2]

void Arches::Convert ( const Vector u,
int &  x,
int &  y,
int &  z 
) const

Convert a point into integer coordinates.

Parameters
uVector.
x,yInteger coordinates of the corresponding material stack.
zInteger elevation.

References ScaleXY, and ScaleZ.

Referenced by Convert(), GetMaterial(), Intersect(), and SmoothZone().

◆ DeleteSmallElements()

void Arches::DeleteSmallElements ( const Vector c,
double  r,
const double &  lntensity 
)

◆ GetBox() [1/2]

Box Arches::GetBox ( ) const

Compute the bounding box of the scene.

See also
Arches::GetBoxTight()

References Array2::GetBox(), ScaleZ, and Box2::ToBox().

Referenced by Intersect(), MaterialAnalysis(), and SurfaceAnalysis().

◆ GetBox() [2/2]

Box Arches::GetBox ( int  i,
int  j,
int  k 
) const
inline

Get the box representing the k-th material of the column (i,j).

Parameters
i,jMaterial stack.
kMaterial layer.

References MaterialStack::at(), at(), Box2::b, MaterialBox::GetA(), MaterialBox::GetB(), ScaleXY, and ScaleZ.

◆ GetBoxTight()

Box Arches::GetBoxTight ( ) const

Compute the (tight) bounding box of the scene.

This function analyzes all material stacks.

See also
ArchesCube::GetBox()

References at(), Array2::GetBox(), Math::Max(), Array2::ny, ScaleZ, and Box2::ToBox().

◆ GetMaterial()

TypeMater Arches::GetMaterial ( const Vector p)

Return the type of material at a given point.

Parameters
pPoint.
Returns
The type of material.

References MaterialBox::AIR, at(), Convert(), MaterialStack::GetMaterial(), materialScene, Array2::ny, and MaterialBox::ROCK.

Referenced by Intersect(), StabilizeEarthStack(), StabilizeSandStack(), StabilizeSnowStack(), and StabilizeStoneStack().

◆ Intersect()

bool Arches::Intersect ( const Ray ray,
Vector q 
) const

Compute the intersection between a ray and the terrain.

Parameters
rayThe ray.
qReturned intersection point.
Returns
Boolean, true if intersection occured.

References MaterialBox::AIR, at(), Box2::b, Convert(), Ray::Direction(), GetBox(), GetMaterial(), Array2::ny, Ray::Origin(), ScaleXY, and ScaleZ.

◆ IsEarthStackUnstable()

bool Arches::IsEarthStackUnstable ( int  x,
int  y 
) const

◆ IsSandStackUnstable()

bool Arches::IsSandStackUnstable ( int  x,
int  y 
)

Verify if some sand in the stack is unstable.

Parameters
x,yPoint on the terrain.
Returns
The status of the sand stability of the stack.

References MaterialStack::at(), at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetB(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddSand(), MaterialBox::SAND, and SandAngle.

Referenced by StabilizeSandStack().

◆ isSnowStackUnstable()

bool Arches::isSnowStackUnstable ( int  x,
int  y 
) const

◆ IsStoneStackUnstable()

bool Arches::IsStoneStackUnstable ( int  x,
int  y 
) const

◆ LoadArchesCube()

void Arches::LoadArchesCube ( std::ifstream &  fichier)

Load material stacks from file.

Parameters
fichierFile.

References MaterialStack::AddMaterialOnTop(), at(), Box2::b, materialScene, Array2::ny, and ScaleXY.

◆ MaterialAnalysis()

int Arches::MaterialAnalysis ( const Box box,
double  x[8] 
) const

Compute the volume of the different materials inside a given input cubic volume.

Parameters
boxThe box, which should be completely inside the bounding box of the terrain.
xMaterials.
See also
ArchesCube::Value

References MaterialBox::AIR, MaterialStack::at(), at(), MaterialBox::EARTH, MaterialBox::GetA(), MaterialBox::GetB(), GetBox(), MaterialBox::GetMaterial(), Box::Intersect(), Box::Intersection(), Array2::ny, MaterialBox::ROCK, MaterialBox::SAND, ScaleXY, ScaleZ, MaterialStack::Size(), MaterialBox::STONE, and Box::Volume().

◆ Memory()

int Arches::Memory ( ) const

Compute the memory used for representing the scene.

Returns
Amount of memory.

References at(), materialScene, MaterialStack::Memory(), and Array2::ny.

◆ RemoveMaterial()

void Arches::RemoveMaterial ( TypeMater  t)

Remove the given material.

Parameters
tMaterial type.

References at(), Array2::ny, and MaterialStack::RemoveMaterial().

◆ RemoveMaterialSphere()

void Arches::RemoveMaterialSphere ( TypeMater  t,
const Vector c,
double  r,
bool  s 
)

◆ RemoveOnGroundRock()

void Arches::RemoveOnGroundRock ( const Vector c,
const double &  r,
const double &  t,
bool  stable 
)

This function removes some rock to the current layer above the layer.

Parameters
cCenter of the gaussian distribution.
rRadius.
tThickness.
stableStabilization flag: stabilize material if set to true.

References Array2::ArrayVertex(), at(), MaterialStack::RemoveOnGroundRock(), ScaleZ, Quadric::Smooth(), StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().

◆ SaveArchesCube()

void Arches::SaveArchesCube ( std::ofstream &  fichier)

◆ SmoothZone()

void Arches::SmoothZone ( const Vector c,
const double &  r,
const double &  lntensity 
)

◆ StabilizeEarthStack()

void Arches::StabilizeEarthStack ( int  x,
int  y 
)

◆ StabilizeSandStack()

void Arches::StabilizeSandStack ( int  x,
int  y 
)

◆ StabilizeSnowStack()

void Arches::StabilizeSnowStack ( int  x,
int  y 
)

◆ StabilizeStoneStack()

void Arches::StabilizeStoneStack ( int  x,
int  y 
)

◆ SurfaceAnalysis()

int Arches::SurfaceAnalysis ( const Box box,
double  x[8] 
) const
protected

Compute the area of every different material in contact with air within the input cubic volume.

Parameters
boxVolume.
xArray storing the area in contact with air for every material.

References MaterialBox::AIR, MaterialStack::at(), at(), findThicknessEmptyness(), MaterialBox::GetA(), MaterialBox::GetB(), GetBox(), MaterialStack::GetLayerIndexFromHeight(), MaterialBox::GetMaterial(), Box::Intersect(), Box::Intersection(), Array2::ny, ScaleXY, ScaleZ, MaterialStack::Size(), MaterialBox::STONE, and MaterialBox::WATER.