Cube Class Reference

#include <Cube.hpp>

Inheritance diagram for Cube:

Inheritance graph
[legend]
Collaboration diagram for Cube:

Collaboration graph
[legend]

List of all members.

Public Types

enum  ShapeType {
  sphere = 1, cylinder = 2, cone = 3, cube = 4,
  plane = 5, torus = 6, union_ = 7, difference = 8,
  intersection = 9, not_ = 10, infiniteCylinder = 11, infiniteCone = 12,
  analytic = 13
}
typedef std::vector
< ConstReferenceCounting
< Transform > > 
TransformationsList

Public Member Functions

const real_t & lowerCorner (const size_t &i) const
const real_t & higherCorner (const size_t &i) const
 Cube (const Vertex &a, const Vertex &b)
 Cube (const Cube &C)
 ~Cube ()
ReferenceCounting< ShapegetCopy () const
const TransformationsListtransformationsList () const
void setTransformationsList (const TransformationsList &l)
bool inside (const TinyVector< 3, real_t > &x) const
const ShapeTypetype () const
size_t numberOfTransformations () const
void setTransformation (const Transform &t)
TinyVector< 3, real_t > inverseTransformation (const size_t &i, const TinyVector< 3, real_t > &x) const
void parseTransform (const parsetrans &trans)

Protected Member Functions

bool __inShape (const TinyVector< 3, real_t > &x) const
std::ostream & __put (std::ostream &os) const
ReferenceCounting< Shape__getCopy () const

Protected Attributes

const ShapeType __type
TransformationsList __trans

Private Attributes

const Vertex __lower
const Vertex __higher

Friends

std::ostream & operator<< (std::ostream &os, const Shape &shape)


Detailed Description

Definition at line 33 of file Cube.hpp.


Member Typedef Documentation

typedef std::vector<ConstReferenceCounting<Transform> > Shape::TransformationsList [inherited]

Definition at line 61 of file Shape.hpp.


Member Enumeration Documentation

enum Shape::ShapeType [inherited]

This is the list of identifiers used for shapes. Identifiers are mean to be explicit ...

  • union_ is used instead of 'union' because 'union' is a C++ keyword.
  • not_ is used instead of 'not' because 'not' is a C++ keyword.
Enumerator:
sphere 
cylinder 
cone 
cube 
plane 
torus 
union_ 
difference 
intersection 
not_ 
infiniteCylinder 
infiniteCone 
analytic 

Definition at line 45 of file Shape.hpp.

00045                  { 
00046     sphere          = 1,
00047     cylinder        = 2,
00048     cone            = 3,
00049     cube            = 4,
00050     plane           = 5,
00051     torus           = 6,
00052     union_          = 7,    
00053     difference      = 8,
00054     intersection    = 9,
00055     not_            =10,
00056     infiniteCylinder=11,
00057     infiniteCone    =12,
00058     analytic        =13
00059   };


Constructor & Destructor Documentation

Cube::Cube ( const Vertex a,
const Vertex b 
)

Builds a Cube based on vertices a and b

Parameters:
a first vertex
b second vertex

Definition at line 23 of file Cube.cpp.

Referenced by __getCopy().

00025   : Shape(cube),
00026     __lower(std::min (a.x(), b.x()),
00027             std::min (a.y(), b.y()),
00028             std::min (a.z(), b.z())),
00029     __higher(std::max (a.x(), b.x()),
00030              std::max (a.y(), b.y()),
00031              std::max (a.z(), b.z()))
00032 {
00033   ;
00034 }

Cube::Cube ( const Cube C  ) 

Copy constructor

Parameters:
C given cube

Definition at line 37 of file Cube.cpp.

00038   : Shape(C),
00039     __lower (C.__lower),
00040     __higher(C.__higher)
00041 {
00042   ;
00043 }

Cube::~Cube (  )  [inline]

Destructor

Definition at line 119 of file Cube.hpp.

00120   {
00121     ;
00122   }


Member Function Documentation

bool Cube::__inShape ( const TinyVector< 3, real_t > &  x  )  const [inline, protected, virtual]

returns true if a point is inside the shape.

Parameters:
x point to test
Returns:
true if x is inside the shape

Implements Shape.

Definition at line 48 of file Cube.hpp.

References __higher, __lower, Vertex::x(), Vertex::y(), and Vertex::z().

00049   {
00050     return ((x[0] <= __higher.x()) and
00051             (x[1] <= __higher.y()) and
00052             (x[2] <= __higher.z()) and
00053             (x[0] >= __lower.x())  and
00054             (x[1] >= __lower.y())  and
00055             (x[2] >= __lower.z()));
00056   }

Here is the call graph for this function:

std::ostream & Cube::__put ( std::ostream &  os  )  const [protected, virtual]

Prints the Cube to a stream

Parameters:
os given stream
Returns:
os

Implements Shape.

Definition at line 46 of file Cube.cpp.

References __higher, __lower, Shape::__trans, and Shape::numberOfTransformations().

00047 {
00048   os << "box {\n" << __lower
00049      << ", " << __higher << '\n';
00050   for (size_t i=0; i<numberOfTransformations(); ++i)
00051     os << __trans[i]->povWrite() << '\n';
00052   os << "}\n";
00053 
00054   return os;
00055 }

Here is the call graph for this function:

ReferenceCounting< Shape > Cube::__getCopy (  )  const [protected, virtual]

gets a copy of the Cube

Returns:
deep copy of the cube

Implements Shape.

Definition at line 58 of file Cube.cpp.

References Cube().

00059 {
00060   return new Cube(*this);
00061 }

Here is the call graph for this function:

const real_t& Cube::lowerCorner ( const size_t &  i  )  const [inline]

Gets lower corner's i th coordinate

Parameters:
i coorinate number
Returns:
coordinate value

Definition at line 82 of file Cube.hpp.

References __lower.

Referenced by Plane::Plane().

00083   {
00084     return __lower[i];
00085   }

const real_t& Cube::higherCorner ( const size_t &  i  )  const [inline]

Gets higher corner's i th coordinate

Parameters:
i coorinate number
Returns:
coordinate value

Definition at line 94 of file Cube.hpp.

References __higher.

Referenced by Plane::Plane().

00095   {
00096     return __higher[i];
00097   }

ReferenceCounting<Shape> Shape::getCopy (  )  const [inline, inherited]

Creates a copy of the shape

Returns:
copy of the shape

Definition at line 100 of file Shape.hpp.

References Shape::__getCopy(), Shape::__trans, and Shape::transformationsList().

00101   {
00102     ReferenceCounting<Shape> shape = this->__getCopy();
00103     TransformationsList transformationsList;
00104     for (TransformationsList::const_iterator i=__trans.begin();
00105          i != __trans.end(); ++i) {
00106       const ConstReferenceCounting<Transform>& t = *i;
00107       transformationsList.push_back(t->getCopy());
00108     }
00109     shape->setTransformationsList(transformationsList);
00110 
00111     return shape;
00112   }

Here is the call graph for this function:

const TransformationsList& Shape::transformationsList (  )  const [inline, inherited]

read only Access to the transformation lists

Returns:
__trans

Definition at line 119 of file Shape.hpp.

References Shape::__trans.

Referenced by SurfaceMeshGenerator::Internals::__generateMesh(), Shape::getCopy(), InfiniteCone::InfiniteCone(), InfiniteCylinder::InfiniteCylinder(), ObjectTransformer::operator()(), and Plane::Plane().

00120   {
00121     return __trans;
00122   }

void Shape::setTransformationsList ( const TransformationsList l  )  [inline, inherited]

sets the transformation list

Definition at line 128 of file Shape.hpp.

References Shape::__trans.

Referenced by InfiniteCone::InfiniteCone(), InfiniteCylinder::InfiniteCylinder(), and Plane::Plane().

00129   {
00130     __trans = l;
00131   }

bool Shape::inside ( const TinyVector< 3, real_t > &  x  )  const [inline, inherited]

Checks if a point is in the shape

Parameters:
x the point
Returns:
true if $ x\in S $

Definition at line 140 of file Shape.hpp.

References Shape::__inShape(), Shape::inverseTransformation(), and Shape::numberOfTransformations().

Referenced by SurfaceMeshGenerator::Internals::__createSurface(), SurfaceMeshGenerator::Internals::__createTrianglesIntersection(), ConformTransformationQ1Hexahedron::__inside(), and SurfaceMeshGenerator::Internals::__splitEdge().

00141   {
00142     TinyVector<3,real_t> X = x;
00143     for (size_t i = numberOfTransformations()-1; i<numberOfTransformations(); --i)
00144       X = inverseTransformation(i, X);
00145     return this->__inShape(X);
00146   }

Here is the call graph for this function:

const ShapeType& Shape::type (  )  const [inline, inherited]

Read only access to the type of the shape

Returns:
__type

Definition at line 153 of file Shape.hpp.

References Shape::__type.

Referenced by Domain::__buildReferenceAssociation().

00154   { 
00155     return __type;
00156   }

size_t Shape::numberOfTransformations (  )  const [inline, inherited]

Gets the number of transformations applied to the shape

Returns:
number of transformations

Definition at line 163 of file Shape.hpp.

References Shape::__trans.

Referenced by Union::__put(), Sphere::__put(), Not::__put(), Intersection::__put(), Difference::__put(), Cylinder::__put(), __put(), and Shape::inside().

00164   {
00165     return __trans.size();
00166   }

void Shape::setTransformation ( const Transform t  )  [inherited]

Adds a transformation to the shape

Parameters:
t given transformation

Definition at line 30 of file Shape.cpp.

References Shape::__trans, and Transform::getCopy().

Referenced by Shape::parseTransform().

00031 {
00032   __trans.push_back(T.getCopy());
00033 }

Here is the call graph for this function:

TinyVector<3, real_t> Shape::inverseTransformation ( const size_t &  i,
const TinyVector< 3, real_t > &  x 
) const [inline, inherited]

Applies inverse of transformation i to the point x.

Parameters:
i number of the transformation
x the point to inverse
Returns:
the inverse

Definition at line 183 of file Shape.hpp.

References Shape::__trans.

Referenced by Shape::inside().

00185   {
00186     return __trans[i]->inverse(x);
00187   }

void Shape::parseTransform ( const parsetrans trans  )  [inherited]

Builds the transformations vector using informations stored in trans.

Parameters:
trans transformation parser

Definition at line 41 of file Shape.cpp.

References parsetrans::mat, matrix, parsetrans::number, rotation, scale, Shape::setTransformation(), translation, ErrorHandler::unexpected, and parsetrans::vect.

00042 {
00043   for (int i=0; i<trans.number ; i++) {
00044     switch (trans.type[i]) {
00045     case matrix: {
00046       TransformMatrix M(trans.mat);
00047       this->setTransformation(M);
00048       break;
00049     }
00050     case rotation: {
00051       TinyVector<3> v( trans.vect[0][i],
00052                        trans.vect[1][i],
00053                        trans.vect[2][i]);
00054       Rotation R(v);
00055       this->setTransformation(R);
00056       break;
00057     }
00058     case translation: {
00059       TinyVector<3> v( trans.vect[0][i],
00060                        trans.vect[1][i],
00061                        trans.vect[2][i]);
00062       Translation T(v);
00063       this->setTransformation(T);
00064       break;
00065     }
00066     case scale: {
00067       TinyVector<3> v( trans.vect[0][i],
00068                        trans.vect[1][i],
00069                        trans.vect[2][i]);
00070       Scale S(v);
00071       this->setTransformation(S);
00072       break;
00073     }
00074     default: {
00075       throw ErrorHandler(__FILE__,__LINE__,
00076                          "unknown transformation",
00077                          ErrorHandler::unexpected);
00078     }
00079     }
00080   }
00081 }

Here is the call graph for this function:


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Shape shape 
) [friend, inherited]

Prints a shape to a stream

Parameters:
os stream
shape shape
Returns:
os

Definition at line 35 of file Shape.cpp.

00036 {
00037   return shape.__put(os);
00038 }


Member Data Documentation

const Vertex Cube::__lower [private]

lower corner

Definition at line 37 of file Cube.hpp.

Referenced by __inShape(), __put(), and lowerCorner().

const Vertex Cube::__higher [private]

higher corner

Definition at line 38 of file Cube.hpp.

Referenced by __inShape(), __put(), and higherCorner().

const ShapeType Shape::__type [protected, inherited]

Type of the transformation

Definition at line 64 of file Shape.hpp.

Referenced by Shape::type().

TransformationsList Shape::__trans [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Wed Nov 19 00:05:29 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6