Arches 1.0
|
The core layered data-structure of the Arches model. More...
#include <arches.h>
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 MaterialStack & | at (int, int) const |
Access to a material stack. | |
MaterialStack & | at (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< MaterialStack > | materialScene |
Material stack array. | |
QVector< int > | ustack |
Set of potentially unstable stacks. | |
The core layered data-structure of the Arches model.
The data structure is defined as a two dimensional array of MaterialStack.
Arches::Arches | ( | const double & | x, |
const double & | y, | ||
const double & | z ) |
Creates a flat terrain.
x | length (in meters). |
y | width (in meters). |
z | height of the terrain. |
References Array2::Array2(), Box2::Box2(), materialScene, Array2::ny, MaterialBox::ROCK, ScaleXY, and ScaleZ.
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.
heightmap | Image. |
h | Scaling factor. |
References MaterialStack::AddMaterialOnTop(), Array2::Array2(), at(), Box2::Box2(), materialScene, Array2::ny, MaterialBox::ROCK, ScaleXY, and ScaleZ.
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.
c | Center of the gaussian distribution. |
r | Radius. |
e | Thickness. |
References MaterialStack::AddMaterialAt(), Array2::ArrayVertex(), at(), Box2::Box2(), ConvertHeight(), Quadric::Smooth(), StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().
void Arches::AddOnGroundRock | ( | const Vector & | c, |
const double & | r, | ||
const double & | e, | ||
bool | stable ) |
Add some rock to the current layer.
c | Center. |
r | Radius. |
e | Thickness. |
stable | Stability. |
References MaterialStack::AddOnGroundRock(), Array2::ArrayVertex(), at(), ScaleZ, Quadric::Smooth(), StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().
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.
c | Center. |
r | Radius. |
stable | Stability. |
References MaterialStack::AddRockLayer(), Array2::ArrayVertex(), at(), ScaleZ, StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().
|
inline |
Access to a material stack.
i,j | Coordinates of the stack. |
References materialScene, and Array2::VertexIndex().
|
inline |
Access to a material stack.
i,j | Coordinates of the stack. |
References materialScene, and Array2::VertexIndex().
Referenced by AddGaussian(), AddOnGroundRock(), AddRockSphere(), Arches(), CheckMaterialInside(), DeleteSmallElements(), findThicknessEmptyness(), GetBox(), GetBoxTight(), GetMaterial(), HorizontalSurfaceRock(), Intersect(), IsEarthStackUnstable(), IsSandStackUnstable(), isSnowStackUnstable(), IsStoneStackUnstable(), LoadArchesCube(), MaterialAnalysis(), Memory(), RemoveGaussian(), RemoveMaterial(), RemoveMaterialSphere(), RemoveOnGroundRock(), SaveArchesCube(), SmoothZone(), StabilizeEarthStack(), StabilizeSandStack(), StabilizeSnowStack(), StabilizeStoneStack(), and SurfaceAnalysis().
bool Arches::CheckMaterialInside | ( | const Box & | b, |
TypeMater | t ) const |
Check if a given material exists within a given box.
b | The box. |
t | Material index. |
References at(), Box2::b, Box2::Box2(), CheckMaterialInside(), ScaleZ, and Array2::VertexIntegerArea().
Referenced by CheckMaterialInside().
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.
p | Vector. |
r | Radius. |
x,y | Integer coordinates of the corresponding material stack. |
z | Height. |
ir | Integer radius. |
view | Intersection of the terrain with the disk region. |
References Convert(), Array2::ny, and ScaleXY.
void Arches::Convert | ( | const Vector & | u, |
int & | x, | ||
int & | y, | ||
int & | z ) const |
Convert a point into integer coordinates.
u | Vector. |
x,y | Integer coordinates of the corresponding material stack. |
z | Integer elevation. |
References ScaleXY, and ScaleZ.
Referenced by Convert(), GetMaterial(), Intersect(), and SmoothZone().
int Arches::ConvertHeight | ( | const double & | z | ) | const |
Convert a point into integer coordinates.
u | Vector. |
x,y | Integer coordinates of the corresponding material stack. |
z | Integer elevation. |
References ScaleZ.
Referenced by AddGaussian(), and RemoveGaussian().
void Arches::DeleteSmallElements | ( | const Vector & | c, |
double | r, | ||
const double & | lntensity ) |
Remove small material blocks inside a given region.
c | Center. |
r | Radius. |
lntensity | Maximum thickness for material blocks. |
References MaterialBox::AIR, Array2::ArrayVertex(), at(), MaterialStack::at(), Box2::Box2(), MaterialBox::GetAB(), MaterialStack::GetHeight(), MaterialStack::GetLayerIndexFromHeight(), MaterialBox::GetMaterial(), MaterialStack::OrderStack(), MaterialBox::ROCK, MaterialBox::SetMaterial(), and Array2::VertexIntegerArea().
Box Arches::GetBox | ( | ) | const |
Compute the bounding box of the scene.
References Array2::GetBox(), ScaleZ, and Box2::ToBox().
Referenced by Intersect(), MaterialAnalysis(), and SurfaceAnalysis().
|
inline |
Get the box representing the k-th material of the column (i,j).
i,j | Material stack. |
k | Material layer. |
References at(), MaterialStack::at(), Box2::b, MaterialBox::GetA(), MaterialBox::GetB(), ScaleXY, and ScaleZ.
Box Arches::GetBoxTight | ( | ) | const |
Compute the (tight) bounding box of the scene.
This function analyzes all material stacks.
References at(), Array2::GetBox(), Math::Max(), Array2::ny, ScaleZ, and Box2::ToBox().
TypeMater Arches::GetMaterial | ( | const Vector & | p | ) |
Return the type of material at a given point.
p | Point. |
References MaterialBox::AIR, at(), Convert(), MaterialStack::GetMaterial(), materialScene, Array2::ny, and MaterialBox::ROCK.
Referenced by Intersect(), StabilizeEarthStack(), StabilizeSandStack(), StabilizeSnowStack(), and StabilizeStoneStack().
Compute the intersection between a ray and the terrain.
ray | The ray. |
q | Returned intersection point. |
References MaterialBox::AIR, at(), Box2::b, Convert(), Ray::Direction(), GetBox(), GetMaterial(), Array2::ny, Ray::Origin(), ScaleXY, and ScaleZ.
bool Arches::IsEarthStackUnstable | ( | int | x, |
int | y ) const |
Check if earth layer is stable.
x,y | Stack position. |
References at(), MaterialStack::at(), MaterialBox::EARTH, EarthAngle, MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetB(), Array2::OutsideVertexIndex(), and MaterialStack::positionToAddEarth().
Referenced by StabilizeEarthStack().
bool Arches::IsSandStackUnstable | ( | int | x, |
int | y ) |
Verify if some sand in the stack is unstable.
x,y | Point on the terrain. |
References at(), MaterialStack::at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetB(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddSand(), MaterialBox::SAND, and SandAngle.
Referenced by StabilizeSandStack().
bool Arches::isSnowStackUnstable | ( | int | x, |
int | y ) const |
Check if snow layer is stable.
x,y | Stack position. |
References at(), MaterialStack::at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetB(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddSnow(), MaterialBox::SNOW, and SnowAngle.
Referenced by StabilizeSnowStack().
bool Arches::IsStoneStackUnstable | ( | int | x, |
int | y ) const |
Check if rocks are unstable.
x,y | Point on the terrain. |
References at(), MaterialStack::at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetB(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddStone(), MaterialBox::STONE, and StoneAngle.
Referenced by StabilizeStoneStack().
void Arches::LoadArchesCube | ( | std::ifstream & | fichier | ) |
Load material stacks from file.
fichier | File. |
References MaterialStack::AddMaterialOnTop(), at(), Box2::b, materialScene, Array2::ny, and ScaleXY.
int Arches::MaterialAnalysis | ( | const Box & | box, |
double | x[8] ) const |
Compute the volume of the different materials inside a given input cubic volume.
box | The box, which should be completely inside the bounding box of the terrain. |
x | Materials. |
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().
int Arches::Memory | ( | ) | const |
Compute the memory used for representing the scene.
References at(), materialScene, MaterialStack::Memory(), and Array2::ny.
void Arches::RemoveGaussian | ( | TypeMater | t, |
const Vector & | c, | ||
const double & | r, | ||
const double & | e, | ||
bool | stable ) |
Removes some material on a more dense material layer using a Gaussian distribution.
c | Center of the gaussian distribution. |
r | Radius |
e | Thickness |
References Array2::ArrayVertex(), at(), Box2::Box2(), ConvertHeight(), MaterialBox::EARTH, MaterialStack::RemoveEarthAt(), MaterialStack::RemoveSandAt(), MaterialStack::RemoveSnowAt(), MaterialStack::RemoveStoneAt(), MaterialStack::RemoveWaterAt(), MaterialBox::SAND, Quadric::Smooth(), MaterialBox::SNOW, StabilizeAllMaterial(), MaterialBox::STONE, ustack, Array2::VertexIntegerArea(), and MaterialBox::WATER.
void Arches::RemoveMaterial | ( | TypeMater | t | ) |
Remove the given material.
t | Material type. |
References at(), Array2::ny, and MaterialStack::RemoveMaterial().
void Arches::RemoveMaterialSphere | ( | TypeMater | t, |
const Vector & | c, | ||
double | r, | ||
bool | s ) |
Remove some material within a given sphere.
This function will locally changes the material, possibly erasing any previously existing material.
c | Center. |
r | Radius. |
t | Material type. |
s | Stabilization. |
References Array2::ArrayVertex(), at(), Box2::Box2(), MaterialBox::EARTH, MaterialStack::RemoveEarthLayer(), MaterialStack::RemoveRockLayer(), MaterialStack::RemoveSandLayer(), MaterialStack::RemoveSnowLayer(), MaterialStack::RemoveStoneLayer(), MaterialStack::RemoveWaterLayer(), MaterialBox::ROCK, MaterialBox::SAND, ScaleZ, MaterialBox::SNOW, StabilizeAllMaterial(), MaterialBox::STONE, ustack, Array2::VertexIntegerArea(), and MaterialBox::WATER.
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.
c | Center of the gaussian distribution. |
r | Radius. |
t | Thickness. |
stable | Stabilization flag: stabilize material if set to true. |
References Array2::ArrayVertex(), at(), MaterialStack::RemoveOnGroundRock(), ScaleZ, Quadric::Smooth(), StabilizeAllMaterial(), ustack, and Array2::VertexIntegerArea().
void Arches::SaveArchesCube | ( | std::ofstream & | fichier | ) |
Save material stacks to file.
fichier | File. |
References at(), MaterialStack::at(), MaterialBox::GetAB(), MaterialStack::GetHeight(), MaterialBox::GetMaterial(), Array2::ny, ScaleXY, ScaleZ, and MaterialStack::Size().
void Arches::SmoothZone | ( | const Vector & | c, |
const double & | r, | ||
const double & | lntensity ) |
Smooth the terrain in a sphere domain.
c | Center. |
r | Radius. |
lntensity | Intensity. |
References MaterialStack::AddRockLayer(), MaterialBox::AIR, Array2::ArrayVertex(), at(), MaterialStack::at(), Convert(), MaterialBox::GetAB(), MaterialStack::GetHeight(), MaterialStack::GetLayerIndexFromHeight(), MaterialBox::GetMaterial(), MaterialStack::GetMaterial(), MaterialStack::MaxLayerHeight(), Array2::ny, MaterialStack::OrderStack(), MaterialStack::RemoveRockLayer(), MaterialBox::ROCK, ScaleXY, MaterialBox::SetMaterial(), and Math::Sqr().
void Arches::StabilizeEarthStack | ( | int | x, |
int | y ) |
Stabilizes the earth layer of a given stack.
x,y | Stack position. |
References MaterialStack::AddMaterialAt(), at(), MaterialStack::at(), MaterialBox::EARTH, EarthAngle, MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetA(), MaterialBox::GetB(), GetMaterial(), IsEarthStackUnstable(), Array2::ny, MaterialStack::positionToAddEarth(), MaterialStack::RemoveEarthAt(), MaterialBox::ROCK, and ustack.
Referenced by StabilizeAllMaterial().
void Arches::StabilizeSandStack | ( | int | x, |
int | y ) |
Stabilize all the sand contains in the stack.
x,y | Point on the terrain. |
References MaterialStack::AddMaterialAt(), at(), MaterialStack::at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetA(), MaterialBox::GetB(), GetMaterial(), IsSandStackUnstable(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddSand(), MaterialStack::RemoveSandAt(), MaterialBox::ROCK, MaterialBox::SAND, SandAngle, and ustack.
Referenced by StabilizeAllMaterial().
void Arches::StabilizeSnowStack | ( | int | x, |
int | y ) |
Stabilizes the snow layer of a stack.
x,y | Stack position. |
References MaterialStack::AddMaterialAt(), at(), MaterialStack::at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetA(), MaterialBox::GetB(), GetMaterial(), isSnowStackUnstable(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddSnow(), MaterialStack::RemoveSnowAt(), MaterialBox::ROCK, MaterialBox::SNOW, SnowAngle, and ustack.
Referenced by StabilizeAllMaterial().
void Arches::StabilizeStoneStack | ( | int | x, |
int | y ) |
Stabilise rocks.
x,y | Point on the terrain. |
References MaterialStack::AddMaterialAt(), at(), MaterialStack::at(), MaterialStack::FindLayer(), MaterialStack::FreeHeight(), MaterialBox::GetA(), MaterialBox::GetB(), GetMaterial(), IsStoneStackUnstable(), Array2::OutsideVertexIndex(), MaterialStack::positionToAddStone(), MaterialStack::RemoveStoneAt(), MaterialBox::ROCK, MaterialBox::STONE, StoneAngle, and ustack.
Referenced by StabilizeAllMaterial().
|
protected |
Compute the area of every different material in contact with air within the input cubic volume.
box | Volume. |
x | Array 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.