Arches 1.0
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.
 
void LoadArchesCube (std::ifstream &)
 Load material stacks from file.
 
 Arches (const double &, const double &, const double &)
 Creates a flat terrain.
 
 Arches (const QImage &, const double &=50.0)
 Creates a terrain from greyscale image.
 
void AddOnGroundRock (const Vector &, const double &, const double &, bool)
 Add some rock to the current layer.
 
void RemoveOnGroundRock (const Vector &, const double &, const double &, bool)
 This function removes some rock to the current layer above the layer.
 
bool Intersect (const Ray &, Vector &) const
 Compute the intersection between a ray and the terrain.
 
const MaterialStackat (int, int) const
 Access to a material stack.
 
MaterialStackat (int, int)
 Access to a material stack.
 
void Convert (const Vector &, int &, int &, int &) const
 Convert a point into integer coordinates.
 
void Convert (const Vector &, const double &, int &, int &, int &, int &, QRect &) const
 Convert a circle into integer coordinates.
 
int ConvertHeight (const double &) const
 Convert a point into integer coordinates.
 
Box GetBox () const
 Compute the bounding box of the scene.
 
Box GetBoxTight () const
 Compute the (tight) bounding box of the scene.
 
Box GetBox (int, int, int) const
 Get the box representing the k-th material of the column (i,j).
 
int Memory () const
 Compute the memory used for representing the scene.
 
TypeMater GetMaterial (const Vector &)
 Return the type of material at a given point.
 
void StabilizeAllMaterial ()
 Stabilize all unstable materials in the scene.
 
bool IsSandStackUnstable (int, int)
 Verify if some sand in the stack is unstable.
 
void StabilizeSandStack (int, int)
 Stabilize all the sand contains in the stack.
 
bool IsStoneStackUnstable (int, int) const
 Check if rocks are unstable.
 
void StabilizeStoneStack (int, int)
 Stabilise rocks.
 
bool IsEarthStackUnstable (int, int) const
 Check if earth layer is stable.
 
void StabilizeEarthStack (int, int)
 Stabilizes the earth layer of a given stack.
 
bool isSnowStackUnstable (int, int) const
 Check if snow layer is stable.
 
void StabilizeSnowStack (int, int)
 Stabilizes the snow layer of a stack.
 
void RemoveMaterialSphere (TypeMater, const Vector &, double, bool)
 Remove some material within a given sphere.
 
void RemoveMaterial (TypeMater)
 Remove the given material.
 
bool CheckMaterialInside (const Box &, TypeMater) const
 Check if a given material exists within a given box.
 
void DeleteSmallElements (const Vector &, double, const double &)
 Remove small material blocks inside a given region.
 
void AddRockSphere (const Vector &, double, bool)
 Assign rock to a user specified sphere.
 
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.
 
void AddGaussian (TypeMater, const Vector &, const double &, const double &, bool)
 Adds some material on a more dense material layer using a Gaussian distribution.
 
void RemoveGaussian (TypeMater, const Vector &, const double &, const double &, bool)
 Removes some material on a more dense material layer using a Gaussian distribution.
 
int MaterialAnalysis (const Box &, double[8]) const
 Compute the volume of the different materials inside a given input cubic volume.
 

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.
 
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 Array2::Array2(), Box2::Box2(), materialScene, Array2::ny, MaterialBox::ROCK, ScaleXY, 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(), Array2::Array2(), at(), Box2::Box2(), materialScene, Array2::ny, MaterialBox::ROCK, ScaleXY, and ScaleZ.

Member Function Documentation

◆ AddGaussian()

void Arches::AddGaussian ( TypeMater t,
const Vector & c,
const double & r,
const double & e,
bool stable )

Adds some material on a more dense material layer using a Gaussian distribution.

Parameters
cCenter of the gaussian distribution.
rRadius.
eThickness.

References MaterialStack::AddMaterialAt(), Array2::ArrayVertex(), at(), Box2::Box2(), ConvertHeight(), Quadric::Smooth(), StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().

◆ 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]

◆ 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().

◆ ConvertHeight()

int Arches::ConvertHeight ( const double & z) const

Convert a point into integer coordinates.

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

References ScaleZ.

Referenced by AddGaussian(), and RemoveGaussian().

◆ 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 at(), MaterialStack::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 at(), MaterialStack::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, at(), MaterialStack::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.

◆ RemoveGaussian()

void Arches::RemoveGaussian ( TypeMater t,
const Vector & c,
const double & r,
const double & e,
bool stable )

◆ 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()

◆ StabilizeEarthStack()

◆ StabilizeSandStack()

◆ StabilizeSnowStack()

◆ StabilizeStoneStack()

◆ 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, at(), MaterialStack::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.