Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes
faceTriangulation Class Reference

Triangulation of faces. Handles concave polygons as well (inefficiently) More...

Inheritance diagram for faceTriangulation:
Inheritance graph
[legend]
Collaboration diagram for faceTriangulation:
Collaboration graph
[legend]

Public Member Functions

 faceTriangulation ()
 Construct null. More...
 
 faceTriangulation (const pointField &points, const face &f, const bool fallBack=false)
 Construct from face and points. Decomposition based on average. More...
 
 faceTriangulation (const pointField &points, const face &f, const vector &n, const bool fallBack=false)
 Construct from face and points and user supplied (unit) normal. More...
 
 faceTriangulation (Istream &)
 Construct from Istream. More...
 
- Public Member Functions inherited from List
 List ()
 Null constructor. More...
 
 List (const label)
 Construct with given size. More...
 
 List (const label, const T &)
 Construct with given size and value for all elements. More...
 
 List (const List< T > &)
 Copy constructor. More...
 
 List (const Xfer< List< T > > &)
 Construct by transferring the parameter contents. More...
 
 List (List< T > &, bool reUse)
 Construct as copy or re-use as specified. More...
 
 List (const UList< T > &, const labelUList &mapAddressing)
 Construct as subset. More...
 
template<class InputIterator >
 List (InputIterator first, InputIterator last)
 Construct given start and end iterators. More...
 
template<unsigned Size>
 List (const FixedList< T, Size > &)
 Construct as copy of FixedList<T, Size> More...
 
 List (const PtrList< T > &)
 Construct as copy of PtrList<T> More...
 
 List (const SLList< T > &)
 Construct as copy of SLList<T> More...
 
 List (const UIndirectList< T > &)
 Construct as copy of UIndirectList<T> More...
 
 List (const BiIndirectList< T > &)
 Construct as copy of BiIndirectList<T> More...
 
 List (Istream &)
 Construct from Istream. More...
 
autoPtr< List< T > > clone () const
 Clone. More...
 
 ~List ()
 Destructor. More...
 
label size () const
 Return the number of elements in the UList. More...
 
void resize (const label)
 Alias for setSize(const label) More...
 
void resize (const label, const T &)
 Alias for setSize(const label, const T&) More...
 
void setSize (const label)
 Reset size of List. More...
 
void setSize (const label, const T &)
 Reset size of List and value for new elements. More...
 
void clear ()
 Clear the list, i.e. set size to zero. More...
 
void append (const T &)
 Append an element at the end of the list. More...
 
void append (const UList< T > &)
 Append a List at the end of this list. More...
 
void append (const UIndirectList< T > &)
 Append a UIndirectList at the end of this list. More...
 
void transfer (List< T > &)
 Transfer the contents of the argument List into this list. More...
 
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
void transfer (DynamicList< T, SizeInc, SizeMult, SizeDiv > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (SortableList< T > &)
 Transfer the contents of the argument List into this list. More...
 
Xfer< List< T > > xfer ()
 Transfer contents to the Xfer container. More...
 
TnewElmt (const label)
 Return subscript-checked element of UList. More...
 
void operator= (const UList< T > &)
 Assignment from UList operator. Takes linear time. More...
 
void operator= (const List< T > &)
 Assignment operator. Takes linear time. More...
 
void operator= (const SLList< T > &)
 Assignment from SLList operator. Takes linear time. More...
 
void operator= (const UIndirectList< T > &)
 Assignment from UIndirectList operator. Takes linear time. More...
 
void operator= (const BiIndirectList< T > &)
 Assignment from BiIndirectList operator. Takes linear time. More...
 
void operator= (const T &)
 Assignment of all entries to the given value. More...
 
template<class T >
 List (const label s)
 
template<class T >
 List (const label s, const T &a)
 
template<class T >
 List (const List< T > &a)
 
template<class T >
 List (const Xfer< List< T > > &lst)
 
template<class T >
 List (List< T > &a, bool reUse)
 
template<class T >
 List (const UList< T > &a, const labelUList &map)
 
template<class T >
 List (const PtrList< T > &lst)
 
template<class T >
 List (const SLList< T > &lst)
 
template<class T >
 List (const UIndirectList< T > &lst)
 
template<class T >
 List (const BiIndirectList< T > &lst)
 
template<class T >
void transfer (List< T > &a)
 
template<class T >
void transfer (SortableList< T > &a)
 
template<class T >
 List ()
 
template<class T >
 List (Istream &is)
 

Private Member Functions

bool split (const bool fallBack, const pointField &points, const face &f, const vector &normal, label &triI)
 Split face f into triangles. Handles all simple (convex & concave) More...
 

Static Private Member Functions

static label right (const label size, label i)
 Edge to the right of face vertex i. More...
 
static label left (const label size, label i)
 Edge to the left of face vertex i. More...
 
static tmp< vectorFieldcalcEdges (const face &, const pointField &)
 Calculate normalized edge vectors. More...
 
static void calcHalfAngle (const vector &normal, const vector &e0, const vector &e1, scalar &cosHalfAngle, scalar &sinHalfAngle)
 Calculates half angle components of angle from e0 to e1. More...
 
static pointHit rayEdgeIntersect (const vector &normal, const point &rayOrigin, const vector &rayDir, const point &p1, const point &p2, scalar &posOnEdge)
 Calculate intersection point between edge p1-p2 and ray (in 2D). More...
 
static bool triangleContainsPoint (const vector &n, const point &p0, const point &p1, const point &p2, const point &pt)
 
static void findDiagonal (const pointField &points, const face &f, const vectorField &edges, const vector &normal, const label startIndex, label &index1, label &index2)
 Starting from startIndex find diagonal. Return in index1, index2. More...
 
static label findStart (const face &f, const vectorField &edges, const vector &normal)
 Find label of vertex to start splitting from. This will be the. More...
 

Static Private Attributes

static const scalar edgeRelTol = 1e-6
 Relative tolerance on edge. More...
 

Additional Inherited Members

- Public Types inherited from List
typedef SubList< TsubList
 Declare type of subList. More...
 
- Static Public Member Functions inherited from List
static const List< T > & null ()
 Return a null List. More...
 
- Protected Member Functions inherited from List
void size (const label)
 Override size to be inconsistent with allocated storage. More...
 

Detailed Description

Triangulation of faces. Handles concave polygons as well (inefficiently)

Works by trying to subdivide the face at the vertex with 'flattest' internal angle (i.e. closest to 180 deg).

Based on routine 'Diagonal' in

    "Efficient Triangulation of Simple Polygons"
    Godfried Toussaint, McGill University.

After construction is the list of triangles the face is decomposed into. (Or empty list if no valid triangulation could be found).

Source files

Definition at line 65 of file faceTriangulation.H.

Constructor & Destructor Documentation

◆ faceTriangulation() [1/4]

Construct null.

Definition at line 602 of file faceTriangulation.C.

◆ faceTriangulation() [2/4]

faceTriangulation ( const pointField points,
const face f,
const bool  fallBack = false 
)

Construct from face and points. Decomposition based on average.

normal. After construction *this is size 0 or holds the triangles. If fallBack and triangulation fails does naive triangulation and never returns 0 size.

Definition at line 610 of file faceTriangulation.C.

References f(), Foam::mag(), points, and setSize().

Here is the call graph for this function:

◆ faceTriangulation() [3/4]

faceTriangulation ( const pointField points,
const face f,
const vector n,
const bool  fallBack = false 
)

Construct from face and points and user supplied (unit) normal.

After construction *this is size 0 or holds the triangles. If fallBack and triangulation fails does naive triangulation and never returns 0 size.

Definition at line 634 of file faceTriangulation.C.

References f(), n, points, and setSize().

Here is the call graph for this function:

◆ faceTriangulation() [4/4]

Construct from Istream.

Definition at line 655 of file faceTriangulation.C.

Member Function Documentation

◆ right()

Foam::label right ( const label  size,
label  i 
)
staticprivate

Edge to the right of face vertex i.

Definition at line 36 of file faceTriangulation.C.

◆ left()

Foam::label left ( const label  size,
label  i 
)
staticprivate

Edge to the left of face vertex i.

Definition at line 43 of file faceTriangulation.C.

◆ calcEdges()

Foam::tmp< Foam::vectorField > calcEdges ( const face f,
const pointField points 
)
staticprivate

Calculate normalized edge vectors.

Definition at line 52 of file faceTriangulation.C.

References f(), forAll, Foam::mag(), points, and List::size().

Here is the call graph for this function:

◆ calcHalfAngle()

void calcHalfAngle ( const vector normal,
const vector e0,
const vector e1,
scalar &  cosHalfAngle,
scalar &  sinHalfAngle 
)
staticprivate

Calculates half angle components of angle from e0 to e1.

in plane given by normal.

Definition at line 77 of file faceTriangulation.C.

References Foam::cos(), Foam::max(), Foam::min(), Foam::sin(), and Foam::sqrt().

Here is the call graph for this function:

◆ rayEdgeIntersect()

Foam::pointHit rayEdgeIntersect ( const vector normal,
const point rayOrigin,
const vector rayDir,
const point p1,
const point p2,
scalar &  posOnEdge 
)
staticprivate

Calculate intersection point between edge p1-p2 and ray (in 2D).

Return true and intersection point if intersection between p1 and p2.

Definition at line 108 of file faceTriangulation.C.

References Foam::mag(), plane::normalIntersect(), PointHit::setDistance(), PointHit::setHit(), PointHit::setPoint(), and y.

Here is the call graph for this function:

◆ triangleContainsPoint()

bool triangleContainsPoint ( const vector n,
const point p0,
const point p1,
const point p2,
const point pt 
)
staticprivate

Definition at line 154 of file faceTriangulation.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and n.

Here is the call graph for this function:

◆ findDiagonal()

void findDiagonal ( const pointField points,
const face f,
const vectorField edges,
const vector normal,
const label  startIndex,
label index1,
label index2 
)
staticprivate

Starting from startIndex find diagonal. Return in index1, index2.

Index1 always startIndex except when convex polygon

Definition at line 185 of file faceTriangulation.C.

References Foam::cos(), PointHit::distance(), f(), PointHit::hit(), Foam::mag(), points, List::size(), and Vector< scalar >::zero.

Here is the call graph for this function:

◆ findStart()

Foam::label findStart ( const face f,
const vectorField edges,
const vector normal 
)
staticprivate

Find label of vertex to start splitting from. This will be the.

vertex with edge angle: 1] flattest concave angle 2] flattest convex angle if no concave angles.

Definition at line 352 of file faceTriangulation.C.

References Foam::cos(), f(), forAll, and List::size().

Here is the call graph for this function:

◆ split()

bool split ( const bool  fallBack,
const pointField points,
const face f,
const vector normal,
label triI 
)
private

Split face f into triangles. Handles all simple (convex & concave)

polygons. Returns false if could not produce valid split.

Definition at line 407 of file faceTriangulation.C.

References Foam::abort(), Foam::cos(), Foam::diff(), Foam::endl(), f(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::nl, points, List::size(), and WarningInFunction.

Here is the call graph for this function:

Field Documentation

◆ edgeRelTol

const Foam::scalar edgeRelTol = 1e-6
staticprivate

Relative tolerance on edge.

Definition at line 72 of file faceTriangulation.H.


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