Various utility classes for generic programming. More...
Namespaces | |
namespace | Shapes |
This namespace contains various shapes. | |
Classes | |
class | Buffer |
A ranged checked array. More... | |
class | CircIterator |
Creates a circular iterator from a range of forward iterators. More... | |
class | Color |
A utility class to encapsulate color data. More... | |
class | Contour |
Contour utility class. More... | |
struct | CrossProductType< 2, T > |
For 2d -> a scalar. More... | |
struct | CrossProductType< 3, T > |
For 3d -> a vector. More... | |
class | FileObject |
This class is the base class for any object that might be watched by the WatchDog. More... | |
class | Function |
A utility class for functions. More... | |
class | GraphInset |
Class used to draw a graph of time stamped data in the model window. More... | |
class | KeyFramer |
Class describing the evolution of a bspline surface through time. More... | |
class | Materials |
A utility class for materials. More... | |
class | Matrix |
Class representing a fixed-size matrix. More... | |
class | Palette |
A utility class for palettes. More... | |
class | Parms |
A utility class to parse L-Studio like parameter files. More... | |
class | Point |
A 3D point/vector class. More... | |
class | range |
Class representing a range of values from two iterators. More... | |
class | refpair |
Class used to hold references for the util::tie() function. More... | |
class | SelectMemberIterator |
Iterate over a container of structure, dereferencing only a member of it. More... | |
struct | set_vector |
Define a class using (small) vectors as unordered sets. More... | |
class | Tensor |
A growth tensor class. More... | |
class | Texture1D |
A utility class for one-dimensional textures. More... | |
class | Texture2D |
A utility class for two-dimensional textures. More... | |
class | Vector |
Vector class supporting all classic classic vector operations. More... | |
class | WatchDog |
Watch the modifications of file objects for you. More... | |
Typedefs | |
typedef Color< double > | Colord |
typedef Color< float > | Colorf |
Functions | |
void | __assert_fail (const QString &assertion, const char *file, unsigned int line, const char *function) |
void | __assert_fail_txt (const QString &assertion, const char *file, unsigned int line, const char *function) |
std::string | absoluteDir (std::string filename, std::string current_dir=std::string()) |
Returns the absolute path of filename . | |
bool | approx (double v1, double v2, double abs_epsilon=VVE_EPSILON, double rel_epsilon=VVE_REL_EPSILON) |
Test if v1 == v2, with floating point error. | |
template<class T > | |
T | clamp (const T &val, const T &min, const T &max) |
A function to clamp a value to a range. | |
void | convertFromQColor (Color< long long > &c, const QColor &col) |
void | convertFromQColor (Color< long > &c, const QColor &col) |
void | convertFromQColor (Color< int > &c, const QColor &col) |
void | convertFromQColor (Color< short > &c, const QColor &col) |
void | convertFromQColor (Color< char > &c, const QColor &col) |
void | convertFromQColor (Color< unsigned long long > &c, const QColor &col) |
void | convertFromQColor (Color< unsigned long > &c, const QColor &col) |
void | convertFromQColor (Color< unsigned int > &c, const QColor &col) |
void | convertFromQColor (Color< unsigned short > &c, const QColor &col) |
void | convertFromQColor (Color< unsigned char > &c, const QColor &col) |
void | convertFromQColor (Color< long double > &c, const QColor &col) |
void | convertFromQColor (Color< double > &c, const QColor &col) |
void | convertFromQColor (Color< float > &c, const QColor &col) |
template<class T > | |
Color< T > | convertHSVtoRGB (T h, T s, T v) |
Return a color based on HSV values. | |
QColor | convertToQColor (const Color< long long > &c) |
QColor | convertToQColor (const Color< long > &c) |
QColor | convertToQColor (const Color< int > &c) |
QColor | convertToQColor (const Color< short > &c) |
QColor | convertToQColor (const Color< char > &c) |
QColor | convertToQColor (const Color< unsigned long long > &c) |
QColor | convertToQColor (const Color< unsigned long > &c) |
QColor | convertToQColor (const Color< unsigned int > &c) |
QColor | convertToQColor (const Color< unsigned short > &c) |
QColor | convertToQColor (const Color< unsigned char > &c) |
QColor | convertToQColor (const Color< long double > &c) |
QColor | convertToQColor (const Color< double > &c) |
QColor | convertToQColor (const Color< float > &c) |
std::string | demangle (std::string s) |
Demangle all the words in the string. | |
template<size_t dim> | |
Vector< dim, double > | gaussRan (const Vector< dim, double > &mean, const Vector< dim, double > &sigma) |
Generate a random vector with gaussian distribution. | |
double | gaussRan (double mean, double sigma) |
Generate a random number with gaussian distribution. | |
bool | greater (double v1, double v2, double abs_epsilon=VVE_EPSILON, double rel_epsilon=VVE_REL_EPSILON) |
Test if v1 > v2, with floating point error. | |
bool | less (double v1, double v2, double abs_epsilon=VVE_EPSILON, double rel_epsilon=VVE_REL_EPSILON) |
Test if v1 < v2, with floating point error. | |
template<typename Iterator > | |
range< Iterator > | make_range (const std::pair< Iterator, Iterator > &p) |
Function to create a range from a pair of iterators. | |
template<typename Iterator > | |
range< Iterator > | make_range (const Iterator &first, const Iterator &last) |
Function to create a range from two iterators. | |
template<size_t dim, typename T , typename T1 > | |
Vector< dim, T > | map (T(*fct)(const T1 &), const Vector< dim, T1 > &v) |
template<size_t dim, typename T , typename T1 > | |
Vector< dim, T > | map (const T &(*fct)(const T1 &), const Vector< dim, T1 > &v) |
template<size_t dim, typename T > | |
Vector< dim, T > | map (T(*fct)(T), const Vector< dim, T > &v) |
template<size_t dim, typename T > | |
Vector< dim, T > | map (T(*fct)(const T &), const Vector< dim, T > &v) |
template<size_t dim, typename T > | |
Vector< dim, T > | map (const T &(*fct)(const T &), const Vector< dim, T > &v) |
template<size_t nRows, typename T > | |
T | matrix_minor (const Matrix< nRows, nRows, T > &mat, size_t i, size_t j) |
template<typename T > | |
T | maximum (const T &a, const T &b) |
Return the maximum of two values. | |
template<typename T > | |
T | minimum (const T &a, const T &b) |
Return the minimum of two values. | |
bool | notequal (double v1, double v2, double abs_epsilon=VVE_EPSILON, double rel_epsilon=VVE_REL_EPSILON) |
Test if v1 != v2, with floating point error. | |
template<class T > | |
Point< T > | operator* (const T &s, const Point< T > &p) |
Scalar multiplication operator. | |
template<class T > | |
Point< T > | operator* (const Point< T > &p, const T &s) |
Scalar multiplication operator. | |
template<class T > | |
std::ostream & | operator<< (std::ostream &os, Tensor< T > &tensor) |
template<class T , unsigned int size> | |
std::ostream & | operator<< (std::ostream &os, Buffer< T, size > &b) |
Stream output to the array. | |
template<class T > | |
std::istream & | operator>> (std::istream &is, Tensor< T > &tensor) |
QTextStream & | operator>> (QTextStream &ss, bool b) |
template<class T , unsigned int size> | |
std::istream & | operator>> (std::istream &is, Buffer< T, size > &b) |
Stream input to the array. | |
QString | qdemangle (std::string s) |
Demangle all the words in the string. | |
template<size_t dim> | |
Vector< dim, double > | ran (const Vector< dim, double > &V) |
Generate a random vector uniformely distributed between Vector(0) and V. | |
double | ran (double M) |
Generate a random number uniformely distributed between 0 and M. | |
template<size_t dim> | |
Vector< dim, long int > | random (const Vector< dim, long int > &n) |
Returns a vector of random numbers. | |
long int | random (long int n) |
Returns a random number between 0 and n (excluded), for n <= RAND_MAX. | |
long int | random () |
Returns a random number between 0 and RAND_MAX. | |
template<typename T > | |
bool | range_c (const T &min, const T &max, const T &val) |
Check if a value is in a C-style range (closed on lower bound and open on the upper). | |
template<typename T > | |
bool | range_closed (const T &min, const T &max, const T &val) |
Check if a value is in an closed range. | |
template<typename T > | |
bool | range_open (const T &min, const T &max, const T &val) |
Check if a value is in an open range. | |
template<size_t dim, class T > | |
bool | serialization (storage::VVEStorage &store, Vector< dim, T > &vec) |
template<size_t nRows, size_t nCols, typename T > | |
bool | serialization (storage::VVEStorage &store, Matrix< nRows, nCols, T > &mat) |
void | sran (unsigned int seed) |
Initialize the random number generator. | |
unsigned int | sran_time () |
Initialize the random number with the current time of the day (in microsecond). | |
template<typename T , typename U > | |
refpair< T, U > | tie (T &x, U &y) |
Tie two variables to the values of a pair. | |
Variables | |
QTextStream | err (stderr) |
QTextStream | out (stdout) |
Various utility classes for generic programming.
Namespace containing all the utility classes.
std::string util::absoluteDir | ( | std::string | filename, | |
std::string | current_dir = std::string() | |||
) |
Returns the absolute path of filename
.
If filename
is not already absolute, it is considered relative to current_dir
.
bool util::approx | ( | double | v1, | |
double | v2, | |||
double | abs_epsilon = VVE_EPSILON , |
|||
double | rel_epsilon = VVE_REL_EPSILON | |||
) | [inline] |
Test if v1 == v2, with floating point error.
Definition at line 45 of file floats.h.
Referenced by notequal().
T util::clamp | ( | const T & | val, | |
const T & | min, | |||
const T & | max | |||
) | [inline] |
A function to clamp a value to a range.
val | The start value. | |
min | The minimum value of the range. | |
max | The maximum value of the range. |
If min
is more than max
, the function returns max
.
Color<T> util::convertHSVtoRGB | ( | T | h, | |
T | s, | |||
T | v | |||
) | [inline] |
Return a color based on HSV values.
Definition at line 194 of file color.h.
References util::Color< T >::a(), util::Color< T >::b(), util::Color< T >::g(), and util::Color< T >::r().
00194 { 00195 // based on Jo's code in medit 00196 00197 Color<T> rgb; 00198 rgb.a(1.0); 00199 00200 while (h > 360.0) h -= 360.0; 00201 while (h < 0.0) h += 360.0; 00202 00203 h /= 60.0; 00204 00205 int i = int(h); 00206 00207 double f = h - i; 00208 double p = v * (1 - s); 00209 double q = v * (1 - (s * f)); 00210 double t = v * (1 - (s * (1 - f))); 00211 00212 switch (i) { 00213 case 0: rgb.r(v); rgb.g(t); rgb.b(p); break; 00214 case 1: rgb.r(q); rgb.g(v); rgb.b(p); break; 00215 case 2: rgb.r(p); rgb.g(v); rgb.b(t); break; 00216 case 3: rgb.r(p); rgb.g(q); rgb.b(v); break; 00217 case 4: rgb.r(t); rgb.g(p); rgb.b(v); break; 00218 case 5: rgb.r(v); rgb.g(p); rgb.b(q); break; 00219 } 00220 00221 return rgb; 00222 }
std::string util::demangle | ( | std::string | s | ) |
Demangle all the words in the string.
Vector<dim,double> util::gaussRan | ( | const Vector< dim, double > & | mean, | |
const Vector< dim, double > & | sigma | |||
) | [inline] |
Generate a random vector with gaussian distribution.
mean | Vector with mean of the gaussian distribution for each dimension | |
sigma | Vector with standard deviation of the gaussian distribution for each dimension |
Definition at line 61 of file random.h.
References gaussRan().
00062 { 00063 Vector<dim,double> result; 00064 for(size_t i = 0 ; i < dim ; ++i) 00065 result[i] = gaussRan(mean[i], sigma[i]); 00066 return result; 00067 }
double util::gaussRan | ( | double | mean, | |
double | sigma | |||
) |
Generate a random number with gaussian distribution.
mean | Mean of the gaussian distribution | |
sigma | Standard deviation of the gaussian distribution |
Referenced by gaussRan().
bool util::greater | ( | double | v1, | |
double | v2, | |||
double | abs_epsilon = VVE_EPSILON , |
|||
double | rel_epsilon = VVE_REL_EPSILON | |||
) | [inline] |
bool util::less | ( | double | v1, | |
double | v2, | |||
double | abs_epsilon = VVE_EPSILON , |
|||
double | rel_epsilon = VVE_REL_EPSILON | |||
) | [inline] |
range<Iterator> util::make_range | ( | const std::pair< Iterator, Iterator > & | p | ) | [inline] |
range<Iterator> util::make_range | ( | const Iterator & | first, | |
const Iterator & | last | |||
) | [inline] |
Function to create a range from two iterators.
Definition at line 170 of file range.h.
Referenced by graph::VVGraph< VertexContent, EdgeContent, compact >::iNeighbors(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::iNeighbors(), graph::VVGraph< VertexContent, EdgeContent, compact >::neighbors(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::neighbors(), graph::VVBiGraph< typename cell::content_t, typename junction::content_t >::vertices1(), and graph::VVBiGraph< typename cell::content_t, typename junction::content_t >::vertices2().
T util::maximum | ( | const T & | a, | |
const T & | b | |||
) | [inline] |
T util::minimum | ( | const T & | a, | |
const T & | b | |||
) | [inline] |
bool util::notequal | ( | double | v1, | |
double | v2, | |||
double | abs_epsilon = VVE_EPSILON , |
|||
double | rel_epsilon = VVE_REL_EPSILON | |||
) | [inline] |
Point<T> util::operator* | ( | const T & | s, | |
const Point< T > & | p | |||
) | [inline] |
Point<T> util::operator* | ( | const Point< T > & | p, | |
const T & | s | |||
) | [inline] |
Scalar multiplication operator.
p | The point to scale. | |
s | The scaling value. |
Definition at line 62 of file point.h.
References util::Vector< 3, T >::Vector().
std::ostream& util::operator<< | ( | std::ostream & | os, | |
Buffer< T, size > & | b | |||
) | [inline] |
Stream output to the array.
os | The output stream. | |
b | The Buffer object to read from. |
The following stream output writes 'size' elements, assuming that elements are seperated by a single space. For this to work, T must have an implemented output stream operator.
std::istream& util::operator>> | ( | std::istream & | is, | |
Buffer< T, size > & | b | |||
) | [inline] |
Stream input to the array.
is | The input stream. | |
b | The Buffer object to write into. |
The following stream input reads 'size' elements, assuming that elements are seperated by whitespace as defined by std::ws. For this to work, T must have an implemented input stream operator.
QString util::qdemangle | ( | std::string | s | ) |
Demangle all the words in the string.
Vector<dim,double> util::ran | ( | const Vector< dim, double > & | V | ) | [inline] |
double util::ran | ( | double | M | ) |
Generate a random number uniformely distributed between 0 and M.
Referenced by ran().
Vector<dim,long int> util::random | ( | const Vector< dim, long int > & | n | ) | [inline] |
Returns a vector of random numbers.
n | Vector with the maximum number for each dimension |
Definition at line 96 of file random.h.
References random().
00097 { 00098 Vector<dim,double> result; 00099 for(size_t i = 0 ; i < dim ; ++i) 00100 result[i] = random(n[i]); 00101 return result; 00102 }
long int util::random | ( | long int | n | ) |
Returns a random number between 0 and n (excluded), for n <= RAND_MAX.
Vector< dim, long int > util::random | ( | ) | [inline] |
Returns a random number between 0 and RAND_MAX.
Returns a vector of random numbers between 0 and RAND_MAX.
Definition at line 78 of file random.h.
Referenced by random().
00079 { 00080 Vector<dim,double> result; 00081 for(size_t i = 0 ; i < dim ; ++i) 00082 result[i] = random(); 00083 return result; 00084 }
bool util::range_c | ( | const T & | min, | |
const T & | max, | |||
const T & | val | |||
) | [inline] |
bool util::range_closed | ( | const T & | min, | |
const T & | max, | |||
const T & | val | |||
) | [inline] |
bool util::range_open | ( | const T & | min, | |
const T & | max, | |||
const T & | val | |||
) | [inline] |
void util::sran | ( | unsigned int | seed | ) |
Initialize the random number generator.
unsigned int util::sran_time | ( | ) |
Initialize the random number with the current time of the day (in microsecond).
refpair<T, U> util::tie | ( | T & | x, | |
U & | y | |||
) | [inline] |
Tie two variables to the values of a pair.
Example:
std::pair<int,double> p(1,2.5); int a; double b; util::tie(a,b) = p;
At the end, a
is 1
and b
is 2.5
Definition at line 73 of file tie.h.
Referenced by graph::VVGraph< VertexContent, EdgeContent, compact >::insert(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::insert(), graph::VVGraph< VertexContent, EdgeContent, compact >::insertEdge(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::insertEdge(), graph::VVGraph< VertexContent, EdgeContent, compact >::insertEdges(), graph::VVGraph< VertexContent, EdgeContent, compact >::replace(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::replace(), graph::VVGraph< VertexContent, EdgeContent, compact >::spliceAfter(), graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::spliceAfter(), graph::VVGraph< VertexContent, EdgeContent, compact >::spliceBefore(), and graph::VVBiGraph< Vertex1Content, Vertex2Content, Edge1Content, Edge2Content_, compact >::spliceBefore().