HyperspaceExplorer 0.7.1
|
An alternative hypersponge implementation with removal of duplicate faces. More...
#include <Sponge.h>
Public Member Functions | |
AltSponge (unsigned _level=1, unsigned _distance=2, double _rad=0.8, VecMath::Vector< 4 > _center=VecMath::Vector< 4 >(0., 0., 0., 0.)) | |
AltSponge constructor. | |
virtual std::string | getFunctionName () const |
virtual void | SetParameters (const ParameterMap &parms) |
Set parameters to the Displayable. | |
virtual std::string | description () |
Protected Member Functions | |
virtual void | Initialize () |
Actually creates the Hypercube. | |
virtual unsigned long | MemRequired (unsigned) |
return the approximate amount of memory needed to display a sponge of current level and given distance | |
void | reduceVertices () |
Remove all duplicate vertices, leaving only unique values. | |
void | removeDuplicateSurfaces () |
Remove all duplicate surfaces. | |
void | renumberSurfaces (unsigned original_vertex, unsigned duplicate_vertex) |
When a duplicate vertex is removed, let all surfaces referencing it point to the original vertex. | |
void | X_push_back (const VecMath::Vector< 4 > &x) |
This function actually creates the hypersponge. | |
Protected Attributes | |
unsigned | Level |
Level of the hypersponge. | |
int | distance |
max. distance (see Initialize()) | |
double | rad |
radius, more correctly size, of the sponge | |
VecMath::Vector< 4 > | center |
center of the sponge |
An alternative hypersponge implementation with removal of duplicate faces.
AltSponge::AltSponge | ( | unsigned | _level = 1 , |
unsigned | _distance = 2 , |
||
double | _rad = 0.8 , |
||
VecMath::Vector< 4 > | _center = VecMath::Vector<4>(0., 0.,0., 0.) |
||
) |
AltSponge constructor.
Construct a Hypersponge of level level
.
_level | hypersponge level |
_distance | distance of subcubes to center to be counted as part of the fractal
|
_rad | side_length/2 |
_center | center |
_level | Level of recursion used in creating the Sponge |
_distance | see Initialize() |
_rad | Size of the Sponge - _rad is half the side length |
_center | Center point of the Sponge |
References Displayable::declareParameter(), and Initialize().
virtual std::string AltSponge::description | ( | ) | [inline, virtual] |
Reimplemented from Hypercube.
References std::ends(), and Level.
virtual std::string AltSponge::getFunctionName | ( | ) | const [inline, virtual] |
Reimplemented from Hypercube.
void AltSponge::Initialize | ( | void | ) | [protected, virtual] |
Actually creates the Hypercube.
sets up the vertices of the Hypercube in X
[], then sets up the surfaces of the Hypercube by declaring the appropriate squares as a list in Surface
[][].
Reimplemented from Hypercube.
References abs(), VecMath::MultiDimensionalVector< T, D >::begin(), begin(), center, cerr, distance, VecMath::MultiDimensionalVector< T, D >::end(), end(), endl(), VecMath::MultiDimensionalVector< T, D >::erase(), fabs(), std::find(), find(), Loki::SingletonHolder< T, CreationPolicy >::Instance(), Level, pow(), VecMath::MultiDimensionalVector< T, D >::push_back(), VecMath::MultiDimensionalVector< T, D >::resize(), std::vector< _Tp, _Alloc >::size(), VertexHolder< 4, 1, double >::X(), and X_push_back().
Referenced by AltSponge().
unsigned long AltSponge::MemRequired | ( | unsigned | distance | ) | [protected, virtual] |
return the approximate amount of memory needed to display a sponge of current level
and given distance
distance | see Initialize() |
void AltSponge::renumberSurfaces | ( | unsigned | original_vertex, |
unsigned | duplicate_vertex | ||
) | [protected] |
When a duplicate vertex is removed, let all surfaces referencing it point to the original vertex.
Also, all vertices after the removed one are shifted up by one element, so the surfaces pointing to them must be updated too.
original_vertex | The vertex, first in the vertex array, that is kept. |
duplicate_vertex | The removed vertex. |
virtual void AltSponge::SetParameters | ( | const ParameterMap & | ) | [inline, virtual] |
Set parameters to the Displayable.
Reimplemented from Hypercube.
References std::map< _Key, _Tp, _Compare, _Alloc >::begin(), std::cerr, distance, std::map< _Key, _Tp, _Compare, _Alloc >::end(), Level, rad, Displayable::setParameter(), and ParameterMap::toString().
void AltSponge::X_push_back | ( | const VecMath::Vector< 4 > & | x | ) | [protected] |
This function actually creates the hypersponge.
It views it as an assembly of smaller sponges, slicing the sponge in three sub-sponges in every one of the four dimensions, and then taking away some of the resulting 81 smaller sub-sponges.
distance
is zero, it only removes the sub-sponge with distance 0 from the center, i.e. the one at the center. distance
is one, it only removes the sub-sponges with distance <= 1, amounting to nine removed sub-sponges. The three- dimensional surface of the hypercube enveloping the sponge is not breached, because the surface of a hypercube is two units away from the center, instead of one unit, as in 3D. distance
= 2, the holes reach the hypercubes surface, giving an object analogous to the three-dimensional Menger Sponge. distance
= 3, only the 16 corners of the hypercube remain, giving four-dimensional fractal dust.If the level
of the sponge is 1, the sub-sponges are hypercubes. Otherwise, they are Hypersponges with a level
reduced by 1.
References Loki::SingletonHolder< T, CreationPolicy >::Instance(), Object::setX(), and VertexHolder< 4, 1, double >::X().
Referenced by Initialize().