Arches 1.0
MaterialStack Class Reference

Material stack for the Arches model. More...

#include <arches.h>

Public Member Functions

 MaterialStack ()
 Creates an empty material stack.
 
 ~MaterialStack ()
 Empty.
 
const MaterialBoxat (int i) const
 Access to the i-th layer.
 
MaterialBoxat (int i)
 Access to the i-th layer.
 
int Size () const
 Returns the number of layers in the stack.
 
void CheckLayersHeight (int=0)
 Permet de decaler eventuellement les hauteurs min et max de chaque couche de la pile. On doit partir d'un endroit dont on est sur de la hauteur max !
 
TypeMater GetMaterial (int) const
 Returns the material type at a given height in the stack.
 
int MaxLayerHeight (int) const
 Get the maximum height of the layer at a given height.
 
int Memory () const
 Compute the amount of memory used by the material stack.
 
void AddMaterialAt (int, int, TypeMater)
 Adds a given amount of material at a given height.
 
void RemoveMaterial (TypeMater)
 Removes all material from a material stack.
 
int FindLayer (int, TypeMater) const
 Finds the location of a given material layer in the material stack.
 
bool CheckMaterialInside (int, int, TypeMater) const
 Checks if a some given material exists within a given height span.
 
void AddMaterialOnTop (TypeMater, int)
 Adds a given material to the top of a material stack.
 
void AddRockLayer (int, int)
 Adds rock which replaces any other existing material.
 
void RemoveRockLayer (int, int)
 Removes rock.
 
void AddOnGroundRock (int, int)
 Add rock to the ground.
 
void RemoveOnGroundRock (int, int)
 Remove rock on the ground.
 
void AddOnCeilRock (int, int)
 Adds rock to the ceiling.
 
void RemoveOnCeilRock (int, int)
 Removes rock above a given height.
 
void AddToHeightRock (int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT>
 
void RemoveToHeightRock (int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT>
 
void RemoveSandLayer (int, int)
 Remove a complete sand layer.
 
int positionToAddSand (int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter du sable.
 
void RemoveStoneLayer (int, int)
 Remove a stone layer.
 
int positionToAddStone (int) const
 Find the highest elevation to add rock.
 
void RemoveEarthAt (int, int)
 Removes some soil at a given height.
 
void RemoveStoneAt (int, int)
 Removes some stone at a given height.
 
void RemoveSandAt (int, int)
 Remove sand at a given elevation.
 
void RemoveSnowAt (int, int)
 Remove Snow.
 
void RemoveWaterAt (int, int)
 Remove water.
 
void RemoveEarthLayer (int, int)
 Remove earth.
 
int positionToAddEarth (int) const
  <FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter du Earth.
 
void RemoveSnowLayer (int, int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT>
 
int positionToAddSnow (int) const
  <FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter du Snow.
 
void RemoveWaterLayer (int, int)
 Remove water.
 
QVector< int > remplirCouchesWATER (int, int, int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT> Rempli de l'eau dans l'interval [hmin,hmax]. Rempli jusqu'a hauteurMaxEau si hMax et hauteurMaxEau est dans le meme layer.
 
int positionToAddWater (int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter de l'eau.
 
QVector< int > getLayerWater (int, int)
  <FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche les layers d'eau entre deux hauteurs.
 
int getMaxWaterHeight (int)
 Get the maximum water elevation.
 
int truncationWaterHeight (int, int)
 Clamp the water height.
 
int FreeHeight (int) const
 Compute the amount of free space above a given height position in the material stack.
 
const int GetLayerIndexFromHeight (int) const
 Given an integer input height, get the corresponding layer index.
 
void OrderStack ()
 Sorts a material stack so that material layers should be in the right order.
 
void ErosionRock (int, int, bool, double, double)
 Erode and transform rock in sand and stone.
 
void Discretisation (int, int, int &, int &)
  <FONT COLOR="AA2222"><B>Warning</B></FONT>
 
int findPositionAir (int) const
 Find air layer.
 
int GetHeight () const
 Return the maximum height of a material stack.
 
TypeMater GetHighestNonAirMaterial () const
 Returns the highest material type of the stack different from air.
 
void FindAirLayers (QVector< int > &) const
 Find air layer is a material stack.
 

Protected Member Functions

void InsertBetweenLayers (int, int, TypeMater)
 Insert a given material thickness between two existing layers. This function also checks that sand or stones fall underwater or in the air.
 

Protected Attributes

QVector< MaterialBoxstack
 The material stack itself.
 

Static Protected Attributes

static const short sizeZ = 10000
 Maximum material stack size, coded as a static short integer.
 

Detailed Description

Material stack for the Arches model.

Member Function Documentation

◆ AddMaterialAt()

void MaterialStack::AddMaterialAt ( int e,
int h,
TypeMater t )

Adds a given amount of material at a given height.

Parameters
eThickness.
hHeight.
tMaterial type.

References GetLayerIndexFromHeight(), and InsertBetweenLayers().

Referenced by Arches::AddGaussian(), ErosionRock(), Arches::StabilizeEarthStack(), Arches::StabilizeSandStack(), Arches::StabilizeSnowStack(), and Arches::StabilizeStoneStack().

◆ AddMaterialOnTop()

void MaterialStack::AddMaterialOnTop ( TypeMater t,
int e )

Adds a given material to the top of a material stack.

Sand and stones fall underwater if the top of the material stack is water.

Parameters
tMaterial type.
eThickness.

References at(), MaterialBox::GetB(), GetHeight(), MaterialBox::GetMaterial(), MaterialBox::SetB(), sizeZ, and stack.

Referenced by Arches::Arches(), InsertBetweenLayers(), and Arches::LoadArchesCube().

◆ AddOnCeilRock()

void MaterialStack::AddOnCeilRock ( int ajout,
int z )

Adds rock to the ceiling.

Parameters
ajoutEpaisseur de roche a ajouter.
zPosition en dessus de laquelle l'ajout va avoir lieu.

References MaterialBox::AIR, at(), MaterialBox::GetAB(), GetLayerIndexFromHeight(), GetMaterial(), OrderStack(), MaterialBox::ROCK, MaterialBox::SetA(), MaterialBox::SetB(), MaterialBox::SetMaterial(), and Size().

◆ AddOnGroundRock()

void MaterialStack::AddOnGroundRock ( int epaisseur,
int position )

Add rock to the ground.

Parameters
epaisseur: Epaisseur de roche a ajouter.
position: Position en dessous de laquelle l'ajout va avoir lieu.

References MaterialBox::AIR, at(), CheckLayersHeight(), MaterialBox::GetAB(), GetHeight(), GetLayerIndexFromHeight(), MaterialBox::GetMaterial(), GetMaterial(), OrderStack(), MaterialBox::ROCK, MaterialBox::SetB(), Size(), sizeZ, and stack.

Referenced by Arches::AddOnGroundRock(), and AddToHeightRock().

◆ AddRockLayer()

void MaterialStack::AddRockLayer ( int hMin,
int hMax )

◆ CheckLayersHeight()

void MaterialStack::CheckLayersHeight ( int deb = 0)

Permet de decaler eventuellement les hauteurs min et max de chaque couche de la pile. On doit partir d'un endroit dont on est sur de la hauteur max !

Parameters
deb: position de la couche de debut de la zone a eventuellement decaler.

References at(), MaterialBox::GetAB(), MaterialBox::GetB(), MaterialBox::SetA(), MaterialBox::SetB(), and stack.

Referenced by AddOnGroundRock(), and RemoveOnGroundRock().

◆ CheckMaterialInside()

bool MaterialStack::CheckMaterialInside ( int a,
int b,
TypeMater t ) const

Checks if a some given material exists within a given height span.

Parameters
a,bHeights.
tMaterial type.

References at(), GetHeight(), GetLayerIndexFromHeight(), GetMaterial(), and Size().

◆ ErosionRock()

void MaterialStack::ErosionRock ( int z,
int e,
bool status,
double pSand,
double pStone )

Erode and transform rock in sand and stone.

Parameters
zInput height
eThickness
statusIndication sur la transformation de la pierre en matiere
pSandPourcentage de transformation en sable.
pStonePourcentage de transformation en pierre.

References AddMaterialAt(), at(), MaterialBox::GetA(), MaterialBox::GetB(), GetLayerIndexFromHeight(), RemoveRockLayer(), MaterialBox::SAND, Size(), and MaterialBox::STONE.

◆ FindAirLayers()

void MaterialStack::FindAirLayers ( QVector< int > & indexes) const

Find air layer is a material stack.

Parameters
indexesArray storing the indexes of air layers.

References MaterialBox::AIR, at(), GetMaterial(), and stack.

◆ FindLayer()

int MaterialStack::FindLayer ( int position,
TypeMater t ) const

Finds the location of a given material layer in the material stack.

Parameters
positionSearches under this height.
tMaterial type.
Returns
Returns the index of the corresponding material layer in the stack is the material exists, otherwise returns -1.

References at(), GetLayerIndexFromHeight(), GetMaterial(), and Size().

Referenced by Arches::IsEarthStackUnstable(), Arches::IsSandStackUnstable(), Arches::isSnowStackUnstable(), Arches::IsStoneStackUnstable(), Arches::StabilizeEarthStack(), Arches::StabilizeSandStack(), Arches::StabilizeSnowStack(), and Arches::StabilizeStoneStack().

◆ findPositionAir()

int MaterialStack::findPositionAir ( int position) const

Find air layer.

Parameters
positionStarting elevation.

References MaterialBox::AIR, at(), MaterialBox::GetA(), GetHeight(), GetLayerIndexFromHeight(), GetMaterial(), and Size().

◆ FreeHeight()

int MaterialStack::FreeHeight ( int h) const

◆ GetHighestNonAirMaterial()

TypeMater MaterialStack::GetHighestNonAirMaterial ( ) const

Returns the highest material type of the stack different from air.

If the stack is empty, the function returns air.

References MaterialBox::AIR, at(), MaterialBox::GetMaterial(), and stack.

◆ GetLayerIndexFromHeight()

◆ getLayerWater()

QVector< int > MaterialStack::getLayerWater ( int hMin,
int hMax )

<FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche les layers d'eau entre deux hauteurs.

Parameters
hMin: Hauteur minimum du layer.
hMax: Hauteur maximum du layer.
Returns
Ensemble de layer compris entre hmin et hmax.

References at(), GetLayerIndexFromHeight(), GetMaterial(), Size(), and MaterialBox::WATER.

◆ GetMaterial()

◆ getMaxWaterHeight()

int MaterialStack::getMaxWaterHeight ( int c)

Get the maximum water elevation.

Parameters
cColumn.

References at(), MaterialBox::GetA(), MaterialBox::GetB(), GetHeight(), GetMaterial(), Size(), and MaterialBox::WATER.

◆ InsertBetweenLayers()

void MaterialStack::InsertBetweenLayers ( int i,
int e,
TypeMater t )
protected

Insert a given material thickness between two existing layers. This function also checks that sand or stones fall underwater or in the air.

Parameters
iLayer index where insertion will be performed.
eThickness.
tMaterial type.
Returns
This function returns a layer index: all layers under this index are consistent, whereas layers above should be checked.

References AddMaterialOnTop(), MaterialBox::AIR, at(), MaterialBox::GetA(), MaterialBox::GetAB(), GetMaterial(), OrderStack(), MaterialBox::ROCK, MaterialBox::SetA(), MaterialBox::SetMaterial(), Size(), and stack.

Referenced by AddMaterialAt().

◆ MaxLayerHeight()

int MaterialStack::MaxLayerHeight ( int z) const

Get the maximum height of the layer at a given height.

Parameters
zThe height parameter which is passed as an integer.

References at(), MaterialBox::GetB(), GetHeight(), and stack.

Referenced by Arches::SmoothZone().

◆ OrderStack()

void MaterialStack::OrderStack ( )

◆ positionToAddEarth()

int MaterialStack::positionToAddEarth ( int position) const

<FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter du Earth.

Parameters
position: Position de depart de la recherche.
Returns
Hauteur maximale pour ajouter du Earth.

References MaterialBox::AIR, at(), MaterialBox::EARTH, MaterialBox::GetB(), GetLayerIndexFromHeight(), GetMaterial(), and Size().

Referenced by Arches::IsEarthStackUnstable(), and Arches::StabilizeEarthStack().

◆ positionToAddSand()

int MaterialStack::positionToAddSand ( int position)

<FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter du sable.

Parameters
position: Position de depart de la recherche.
Returns
Hauteur maximale pour ajouter du sable.

References MaterialBox::AIR, at(), MaterialBox::GetB(), GetLayerIndexFromHeight(), GetMaterial(), MaterialBox::SAND, and Size().

Referenced by Arches::IsSandStackUnstable(), and Arches::StabilizeSandStack().

◆ positionToAddSnow()

int MaterialStack::positionToAddSnow ( int position) const

<FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter du Snow.

Parameters
position: Position de depart de la recherche.
Returns
Hauteur maximale pour ajouter du Snow.

References MaterialBox::AIR, at(), MaterialBox::GetB(), GetLayerIndexFromHeight(), GetMaterial(), Size(), and MaterialBox::SNOW.

Referenced by Arches::isSnowStackUnstable(), and Arches::StabilizeSnowStack().

◆ positionToAddStone()

int MaterialStack::positionToAddStone ( int position) const

Find the highest elevation to add rock.

Parameters
positionStarting position.
Returns
Maximal height.

References MaterialBox::AIR, at(), MaterialBox::b, GetLayerIndexFromHeight(), Size(), and MaterialBox::STONE.

Referenced by Arches::IsStoneStackUnstable(), and Arches::StabilizeStoneStack().

◆ positionToAddWater()

int MaterialStack::positionToAddWater ( int position)

<FONT COLOR="AA2222"><B>Warning</B></FONT> Recherche la hauteur maximale pour ajouter de l'eau.

Parameters
position: Position de depart de la recherche.
Returns
Hauteur maximale pour ajouter de l'eau.

References MaterialBox::AIR, at(), MaterialBox::GetB(), GetLayerIndexFromHeight(), GetMaterial(), Size(), and MaterialBox::WATER.

◆ RemoveEarthAt()

void MaterialStack::RemoveEarthAt ( int e,
int h )

◆ RemoveEarthLayer()

void MaterialStack::RemoveEarthLayer ( int hMin,
int hMax )

◆ RemoveMaterial()

void MaterialStack::RemoveMaterial ( TypeMater t)

Removes all material from a material stack.

The algorithm first converts sand layers into air and then reorders the different layers if need be.

Note that the material should not be rock.

Parameters
tMaterial type.

References MaterialBox::AIR, at(), GetMaterial(), OrderStack(), MaterialBox::SetMaterial(), and Size().

Referenced by Arches::RemoveMaterial().

◆ RemoveOnCeilRock()

void MaterialStack::RemoveOnCeilRock ( int ajout,
int position )

Removes rock above a given height.

Parameters
ajoutAmount of rock.
positionStarting elevation.

References MaterialBox::AIR, at(), MaterialBox::GetA(), MaterialBox::GetAB(), GetLayerIndexFromHeight(), GetMaterial(), OrderStack(), MaterialBox::ROCK, MaterialBox::SetA(), MaterialBox::SetMaterial(), Size(), and stack.

◆ RemoveOnGroundRock()

void MaterialStack::RemoveOnGroundRock ( int t,
int z )

Remove rock on the ground.

Parameters
tThickness of rock that will be removed
zHeight where rock is going to be removed

References MaterialBox::AIR, at(), CheckLayersHeight(), MaterialBox::GetAB(), MaterialBox::GetB(), GetLayerIndexFromHeight(), GetMaterial(), OrderStack(), MaterialBox::ROCK, MaterialBox::SetB(), MaterialBox::SetMaterial(), Size(), and stack.

Referenced by Arches::RemoveOnGroundRock(), and RemoveToHeightRock().

◆ RemoveRockLayer()

void MaterialStack::RemoveRockLayer ( int hMin,
int hMax )

◆ RemoveSandAt()

void MaterialStack::RemoveSandAt ( int t,
int position )

Remove sand at a given elevation.

Parameters
tSand thickness.
positionPosition where sand will be removed.

References MaterialBox::AIR, at(), MaterialBox::GetAB(), MaterialBox::GetB(), GetLayerIndexFromHeight(), GetMaterial(), OrderStack(), MaterialBox::ROCK, MaterialBox::SAND, MaterialBox::SetB(), MaterialBox::SetMaterial(), Size(), and stack.

Referenced by Arches::RemoveGaussian(), and Arches::StabilizeSandStack().

◆ RemoveSandLayer()

void MaterialStack::RemoveSandLayer ( int hMin,
int hMax )

◆ RemoveSnowAt()

void MaterialStack::RemoveSnowAt ( int t,
int p )

◆ RemoveStoneAt()

void MaterialStack::RemoveStoneAt ( int e,
int h )

◆ RemoveStoneLayer()

void MaterialStack::RemoveStoneLayer ( int hMin,
int hMax )

◆ RemoveWaterAt()

void MaterialStack::RemoveWaterAt ( int t,
int position )

◆ RemoveWaterLayer()

void MaterialStack::RemoveWaterLayer ( int hMin,
int hMax )

◆ remplirCouchesWATER()

QVector< int > MaterialStack::remplirCouchesWATER ( int hMin,
int hMax,
int hauteurMaxEau )

<FONT COLOR="AA2222"><B>Warning</B></FONT> Rempli de l'eau dans l'interval [hmin,hmax]. Rempli jusqu'a hauteurMaxEau si hMax et hauteurMaxEau est dans le meme layer.

Parameters
hMin: hauteur minimum de remplissage.
hMax: hauteur maximum de remplissage.
hauteurMaxEau: hauteur maximal de remplissage de l'eau si hMax est dans le meme layer.
Returns
Retourne les nouveaux layer d'eau.

References MaterialBox::AIR, at(), MaterialBox::GetB(), GetHeight(), GetLayerIndexFromHeight(), GetMaterial(), MaterialBox::SetB(), MaterialBox::SetMaterial(), Size(), stack, and MaterialBox::WATER.

◆ truncationWaterHeight()

int MaterialStack::truncationWaterHeight ( int c,
int h )

Clamp the water height.

Parameters
cColumn.
hMinimum elevation.

References at(), MaterialBox::GetB(), GetMaterial(), RemoveWaterAt(), Size(), and MaterialBox::WATER.