Edge Class Reference

#include <Edge.hpp>

List of all members.

Public Types

enum  { NumberOfVertices = 2 }
typedef std::pair< Vertex
*, Vertex * > 
Pair

Public Member Functions

real_t lenght () const
const size_t & reference () const
size_t & reference ()
Vertexoperator() (const size_t &i)
const Vertexoperator() (const size_t &i) const
bool operator== (const Edge &e) const
bool operator< (const Edge &e) const
const Edgeoperator= (const Edge &e)
 operator Pair & ()
 Cast to a Edge::Pair.
 operator const Pair & () const
VertexfirstCommonVertex (const Edge::Pair &e) const
 Edge ()
 Edge (const Edge &E)
 Edge (const Vertex &v1, const Vertex &v2, const size_t &reference=0)
 Edge (const Edge::Pair &vp, const size_t &reference=0)
 ~Edge ()

Private Attributes

Edge::Pair __verticesPair
size_t __reference

Friends

std::ostream & operator<< (std::ostream &os, const Edge &e)
 Outputs the Edge e using the stream os.


Detailed Description

Definition at line 40 of file Edge.hpp.


Member Typedef Documentation

typedef std::pair<Vertex*, Vertex*> Edge::Pair

Definition at line 47 of file Edge.hpp.


Member Enumeration Documentation

anonymous enum

Enumerator:
NumberOfVertices 

Definition at line 43 of file Edge.hpp.

00043        {
00044     NumberOfVertices = 2
00045   };


Constructor & Destructor Documentation

Edge::Edge (  )  [inline]

Default constructor

Note:
do no initialization

Definition at line 204 of file Edge.hpp.

00205   {
00206     ;
00207   }

Edge::Edge ( const Edge E  )  [inline]

Copy constructor

Parameters:
E a given edge

Definition at line 214 of file Edge.hpp.

00215     : __verticesPair(E.__verticesPair),
00216       __reference(E.__reference)
00217   {
00218     ;
00219   }

Edge::Edge ( const Vertex v1,
const Vertex v2,
const size_t &  reference = 0 
) [inline]

Constructs an edge using two vertices

Parameters:
v1 the first vertex
v2 the second vertex
reference a given reference
Note:
if reference is not provided, it is set to 0

vertices are sorted to optimization purpose

Warning:
const_cast usage is not good for design

Definition at line 232 of file Edge.hpp.

References __verticesPair.

00234     : __reference(reference)
00235   {
00236     Vertex* V1 = const_cast<Vertex*>((&v1<&v2) ? &v1 : &v2);
00237     Vertex* V2 = const_cast<Vertex*>((&v1>&v2) ? &v1 : &v2);
00238     __verticesPair = Pair(V1, V2);
00239   }

Edge::Edge ( const Edge::Pair vp,
const size_t &  reference = 0 
) [inline]

Constructs an edge using a pair of vertices and a given reference

Parameters:
vp the pair of vertices
reference the givene reference

Definition at line 247 of file Edge.hpp.

00249     : __verticesPair(vp),
00250       __reference(reference)
00251   {
00252     ;
00253   }

Edge::~Edge (  )  [inline]

The destructor

Definition at line 259 of file Edge.hpp.

00260   {
00261     ;
00262   }


Member Function Documentation

real_t Edge::lenght (  )  const [inline]

Definition at line 54 of file Edge.hpp.

References __verticesPair.

00055   {
00056     return Norm(*__verticesPair.first - *__verticesPair.second);
00057   }

const size_t& Edge::reference (  )  const [inline]

Read-only access to the reference of the edge

Returns:
the reference

Definition at line 65 of file Edge.hpp.

References __reference.

Referenced by SurfaceMeshGenerator::Internals::__createSurface(), and SurfaceMeshGenerator::Internals::__createTriangleSurface().

00066   {
00067     return __reference;
00068   }

size_t& Edge::reference (  )  [inline]

Access to the reference of the edge

Returns:
the reference

Definition at line 76 of file Edge.hpp.

References __reference.

00077   {
00078     return __reference;
00079   }

Vertex& Edge::operator() ( const size_t &  i  )  [inline]

Access to the ith vertex of the edge

Returns:
the ith vertex

Definition at line 87 of file Edge.hpp.

References __verticesPair, and ASSERT.

00088   {
00089     ASSERT (i<2);
00090     switch(i) {
00091     case 0:
00092       return *(__verticesPair.first);
00093     case 1:
00094       return *(__verticesPair.second);
00095     }
00096     return *(__verticesPair.first); // Never reached
00097   }

const Vertex& Edge::operator() ( const size_t &  i  )  const [inline]

Access to the ith vertex of the edge

Returns:
the ith vertex

Definition at line 105 of file Edge.hpp.

References __verticesPair, and ASSERT.

00106   {
00107     ASSERT (i<2);
00108     switch(i) {
00109     case 0:
00110       return *(__verticesPair.first);
00111     case 1:
00112       return *(__verticesPair.second);
00113     }
00114     return *(__verticesPair.first); // Never reached
00115   }

bool Edge::operator== ( const Edge e  )  const [inline]

Returns true if edges have only same vertices

Parameters:
e another edge
Returns:
true if vertices are the same

Definition at line 124 of file Edge.hpp.

References __verticesPair.

00125   {
00126     return (__verticesPair==e.__verticesPair);
00127   }

bool Edge::operator< ( const Edge e  )  const [inline]

Sets an order for edges

Parameters:
e a given edge
Returns:
true is the edge is sort before the given one

Definition at line 136 of file Edge.hpp.

References __verticesPair.

00137   {
00138     if (__verticesPair.first == e.__verticesPair.first) {
00139       return (__verticesPair.second < e.__verticesPair.second);
00140     } else {
00141       return (__verticesPair.first < e.__verticesPair.first);
00142     }
00143   }

const Edge& Edge::operator= ( const Edge e  )  [inline]

Sets the current edge to a given one

Parameters:
e a given edge
Returns:
$ e := e' $

Definition at line 152 of file Edge.hpp.

References __reference, and __verticesPair.

00153   {
00154     __verticesPair = e.__verticesPair;
00155     __reference = e.__reference;
00156 
00157     return *this;
00158   }

Edge::operator Pair & (  )  [inline]

Cast to a Edge::Pair.

Definition at line 161 of file Edge.hpp.

References __verticesPair.

00162   {
00163     return __verticesPair;
00164   }

Edge::operator const Pair & (  )  const [inline]

Automatic cast to a Edge::Pair

Returns:
the vertices pair

Definition at line 172 of file Edge.hpp.

References __verticesPair.

00173   {
00174     return __verticesPair;
00175   }

Vertex* Edge::firstCommonVertex ( const Edge::Pair e  )  const [inline]

find first common vertex

Parameters:
e a given edge
Returns:
common vertex of two edges, 0 is none.

Definition at line 184 of file Edge.hpp.

References __verticesPair.

Referenced by MeshSimplifier::Internals< CellType >::__findCommonOther().

00185   {
00186     if ((__verticesPair.first == e.first)
00187         or (__verticesPair.first == e.second)) {
00188       return __verticesPair.first;
00189     }
00190 
00191     if ((__verticesPair.second == e.first)
00192         or (__verticesPair.second == e.second)) {
00193       return __verticesPair.second;
00194     }
00195 
00196     return 0;
00197   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Edge e 
) [friend]

Outputs the Edge e using the stream os.

Prints the edge to a given stream

Parameters:
os the given stream
e the edge to print
Returns:
the modified stream

Definition at line 23 of file Edge.cpp.

00024 {
00025   os << '(' << e(0)[0] << ' ' << e(0)[1] << ' ' << e(0)[2] << "),";
00026   os << '(' << e(1)[0] << ' ' << e(1)[1] << ' ' << e(1)[2] << ')';
00027 
00028   return os;
00029 }


Member Data Documentation

the two vertices defining the edge

Definition at line 49 of file Edge.hpp.

Referenced by Edge(), firstCommonVertex(), lenght(), operator const Pair &(), operator Pair &(), operator()(), operator<(), operator=(), and operator==().

size_t Edge::__reference [private]

the reference of the edge

Definition at line 51 of file Edge.hpp.

Referenced by operator=(), and reference().


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

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