ug4
face util

contains methods to manipulate faces More...

Functions

template<class TIterator >
UG_API number ug::AreaFaceQuality (TIterator facesBegin, TIterator facesEnd, Grid::VertexAttachmentAccessor< APosition > &aaPos)
 returns a value between 0 (bad) and 1 (good) that describes the quality of the area. More...
 
template<class TAAPosVRT , class TAAWeightVRT >
UG_API TAAPosVRT::ValueType ug::CalculateCenter (const FaceVertices *f, TAAPosVRT &aaPos, TAAWeightVRT &aaWeight)
 returns the weighted center of the vertices of the given face More...
 
void ug::CalculateFaceNormals (Grid &grid, const FaceIterator &facesBegin, const FaceIterator &facesEnd, AVector3 &aPos, AVector3 &aNorm)
 calculates the normal of each face. Presumes that all faces are flat. More...
 
void ug::CalculateNormal (vector3 &vNormOut, const FaceVertices *face, Grid::AttachmentAccessor< Vertex, APosition > &aaPos)
 calculates the normal of the given face More...
 
void ug::CalculateNormalNoNormalize (vector3 &vNormOut, FaceVertices *face, Grid::AttachmentAccessor< Vertex, APosition > &aaPos)
 calculates the normal of the given face More...
 
bool ug::CompareVertices (const FaceVertices *fv1, const FaceVertices *fv2)
 Checks whether fv1 and fv2 contain the same vertices. More...
 
template<class vector_t , class TAAPos >
UG_API bool ug::ContainsPoint (const FaceVertices *f, const vector_t &p, TAAPos aaPos)
 Returns true if the given point lies inside the given face. More...
 
template<class TAAPosVRT >
UG_API number ug::FaceArea (FaceVertices *f, TAAPosVRT &aaPos)
 Returns the area of a convex face. More...
 
template<class TIterator , class TAAPosVRT >
UG_API number ug::FaceArea (TIterator facesBegin, TIterator facesEnd, TAAPosVRT &aaPos)
 Returns the area sum of convex faces. More...
 
bool ug::FaceContains (Face *f, EdgeVertices *ev)
 returns true if the given face contains the two given vertices More...
 
bool ug::FaceContains (FaceVertices *f, Vertex *v)
 returns true if the given face contains the given vertex More...
 
number ug::FaceQuality (FaceVertices *f, Grid::VertexAttachmentAccessor< APosition > aaPos)
 a simple measure for the quality of a face More...
 
template<class TIterator , class TAAPosVRT >
UG_API Faceug::FindSmallestFace (TIterator facesBegin, TIterator facesEnd, TAAPosVRT &aaPos)
 Returns the face with the smallest area. More...
 
int ug::GetFaceIndex (Volume *vol, Face *f)
 returns the index at which face f is found in the given object More...
 
void ug::GetNeighbours (std::vector< Face * > &vFacesOut, Grid &grid, Face *f, int side, bool clearContainer=true)
 collects neighbours of the given side of a face. More...
 
Vertexug::GetVertex (Face *f, size_t i)
 returns the i'th vertex of a face More...
 
void ug::InsertCenterVertex (Grid &g, Face *f, Vertex *vrt, bool eraseOldFace)
 Refines the face by connecting its sides with the new center. More...
 
template<class TFace >
UG_API bool ug::IsBoundaryFace3D (Grid &grid, TFace *f)
 A wrapper for IsVolumeBoundaryFace. More...
 
template<class TAAPosVRT >
UG_API bool ug::IsDegenerated (Face *f, TAAPosVRT &aaPos, number threshold=SMALL)
 returns true if the given face is degenerated. More...
 
bool ug::IsVolumeBoundaryFace (Grid &grid, ConstrainedFace *f)
 returns true if the given face is a boundary face. More...
 
bool ug::IsVolumeBoundaryFace (Grid &grid, ConstrainingFace *f)
 returns true if the given face is a boundary face. More...
 
bool ug::IsVolumeBoundaryFace (Grid &grid, Face *f)
 returns true if the given face is a boundary face. More...
 
template<class TFace >
UG_API bool ug::LiesOnBoundary (Grid &grid, TFace *f)
 A wrapper for IsVolumeBoundaryFace. More...
 
int ug::NumAssociatedVolumes (Grid &grid, Face *f)
 returns the number of associated volumes of the specified face More...
 
template<class TAAPosVRT >
UG_API int ug::PointFaceTest (vector3 &v, Face *f, TAAPosVRT &aaPos)
 
template<class TTriangleIterator , class TAAPosVRT >
UG_API bool ug::ProjectPointToSurface (vector3 &vOut, const vector3 &v, const vector3 &n, TTriangleIterator trisBegin, TTriangleIterator trisEnd, TAAPosVRT &aaPos, bool compareNormals=false)
 
number ug::TriangleQuality (vector3 &v1, vector3 &v2, vector3 &v3)
 a simple measure for the quality of a triangle More...
 
UG_API void ug::Triangulate (Grid &grid, Grid::VertexAttachmentAccessor< APosition > *paaPos=NULL)
 
void ug::Triangulate (Grid &grid, Quadrilateral *q, Grid::VertexAttachmentAccessor< APosition > *paaPos=NULL)
 removes the quadrilateral and replaces it by two triangles. More...
 
void ug::Triangulate (Grid &grid, QuadrilateralIterator iterBegin, QuadrilateralIterator iterEnd, Grid::VertexAttachmentAccessor< APosition > *paaPos=NULL)
 replaces all specified quadrilaterals by triangles. More...
 
template<class TVertexPositionAttachmentAccessor >
UG_API TVertexPositionAttachmentAccessor::ValueType ug::CalculateCenter (const FaceVertices *f, TVertexPositionAttachmentAccessor &aaPosVRT)
 calculates the center of a face. More...
 

Detailed Description

contains methods to manipulate faces

Function Documentation

◆ AreaFaceQuality()

template<class TIterator >
UG_API number ug::AreaFaceQuality ( TIterator  facesBegin,
TIterator  facesEnd,
Grid::VertexAttachmentAccessor< APosition > &  aaPos 
)

returns a value between 0 (bad) and 1 (good) that describes the quality of the area.

returns the worst FaceQuality of the faces between facesBegin and FacesEnd. TIterator has to be an iterator with a value-type compatible to Face*.

References ug::FaceQuality().

◆ CalculateCenter() [1/2]

template<class TAAPosVRT , class TAAWeightVRT >
UG_API TAAPosVRT::ValueType ug::CalculateCenter ( const FaceVertices f,
TAAPosVRT &  aaPos,
TAAWeightVRT &  aaWeight 
)

returns the weighted center of the vertices of the given face

TAAWeightVRT has to be an attachment to the vertices of the grid in which f is contained, with ValueType number (or compatible).

References ug::FaceVertices::num_vertices(), ug::VecScale(), ug::VecScaleAppend(), ug::VecSet(), and ug::FaceVertices::vertices().

◆ CalculateCenter() [2/2]

template<class TVertexPositionAttachmentAccessor >
UG_API TVertexPositionAttachmentAccessor::ValueType ug::CalculateCenter ( const FaceVertices f,
TVertexPositionAttachmentAccessor &  aaPosVRT 
)

calculates the center of a face.

TVertexPositionAttachmentAccessor has to be an AttachmentAccessor, where AttachmentAccessor::ValueType is a vector-type compatible to the lgmath vector descriptor. The accessor has to access an attachment of the vertices, to which f refers.

References ug::FaceVertices::num_vertices(), ug::VecAdd(), ug::VecScale(), ug::VecSet(), and ug::FaceVertices::vertices().

◆ CalculateFaceNormals()

void ug::CalculateFaceNormals ( Grid grid,
const FaceIterator facesBegin,
const FaceIterator facesEnd,
AVector3 aPos,
AVector3 aNorm 
)

calculates the normal of each face. Presumes that all faces are flat.

aPos has to be attached to the vertices of the grid. aPos should contain the position data. Normals will be written to aNorm (face attachment).

References ug::Grid::attach_to_faces(), ug::CalculateNormal(), ug::Grid::has_face_attachment(), and ug::Grid::has_vertex_attachment().

◆ CalculateNormal()

UG_API void ug::CalculateNormal ( vector3 vNormOut,
const FaceVertices face,
Grid::AttachmentAccessor< Vertex, APosition > &  aaPos 
)

calculates the normal of the given face

aaPos has to be a valid positition-attachment-accessor to the vertices of the grid which contains the face. if the face contains less than 3 vertices (0, 0, 0) will be written to vNormOut (this should never happen!). For triangles the normal is calculated using the standard cross-product. for quadrilaterals the normals of the two sub-triangles (0, 1, 2) and (2, 3, 0) is calculated and averaged. If the face contains more than 4 vertices the normal of the first sub-triangle is returned.

Performs normalization on the calcluated normals.

References ug::CalculateTriangleNormal(), ug::CalculateTriangleNormalNoNormalize(), ug::FaceVertices::num_vertices(), ug::VecAdd(), ug::VecNormalize(), and ug::FaceVertices::vertex().

Referenced by ug::CalculateFaceNormals().

◆ CalculateNormalNoNormalize()

UG_API void ug::CalculateNormalNoNormalize ( vector3 vNormOut,
FaceVertices face,
Grid::AttachmentAccessor< Vertex, APosition > &  aaPos 
)

calculates the normal of the given face

aaPos has to be a valid positition-attachment-accessor to the vertices of the grid which contains the face. if the face contains less than 3 vertices (0, 0, 0) will be written to vNormOut (this should never happen!). For triangles the normal is calculated using the standard cross-product. for quadrilaterals the normals of the two sub-triangles (0, 1, 2) and (2, 3, 0) is calculated and averaged. If the face contains more than 4 vertices the normal of the first sub-triangle is returned.

performs no normalization on the calculated normals

References ug::CalculateTriangleNormalNoNormalize(), ug::FaceVertices::num_vertices(), ug::VecAdd(), ug::VecScale(), and ug::FaceVertices::vertex().

◆ CompareVertices()

◆ ContainsPoint()

template<class vector_t , class TAAPos >
UG_API bool ug::ContainsPoint ( const FaceVertices f,
const vector_t &  p,
TAAPos  aaPos 
)

Returns true if the given point lies inside the given face.

Note
The method only works properly, if the point and the face are located in the same x-y-plane.

References ug::FaceVertices::num_vertices(), p, ug::PointIsInsideQuadrilateral(), ug::PointIsInsideTriangle(), UG_THROW, and ug::FaceVertices::vertex().

◆ FaceArea() [1/2]

template<class TAAPosVRT >
UG_API number ug::FaceArea ( FaceVertices f,
TAAPosVRT &  aaPos 
)

Returns the area of a convex face.

References ug::FaceVertices::num_vertices(), ug::TriangleArea(), and ug::FaceVertices::vertex().

◆ FaceArea() [2/2]

template<class TIterator , class TAAPosVRT >
UG_API number ug::FaceArea ( TIterator  facesBegin,
TIterator  facesEnd,
TAAPosVRT &  aaPos 
)

Returns the area sum of convex faces.

References ug::FaceArea().

◆ FaceContains() [1/2]

UG_API bool ug::FaceContains ( Face f,
EdgeVertices ev 
)

◆ FaceContains() [2/2]

bool ug::FaceContains ( FaceVertices f,
Vertex v 
)

returns true if the given face contains the given vertex

returns true if the given face contains exactly the same points as the given descriptor.

returns true if the given face contains the given vertex

References ug::FaceVertices::num_vertices(), and ug::FaceVertices::vertices().

Referenced by ug::CollectFaces().

◆ FaceQuality()

UG_API number ug::FaceQuality ( FaceVertices f,
Grid::VertexAttachmentAccessor< APosition aaPos 
)

a simple measure for the quality of a face

returns a value between 0 and 1, where 1 indicates a good quality and 0 a bad. This method checks the dot-products of edges at the corners. The worst one (closest to 1 or -1) determines the quality.

See also
TriangleQuality

References ug::FaceVertices::num_vertices(), ug::VecDot(), ug::VecLength(), ug::VecScale(), ug::VecSubtract(), and ug::FaceVertices::vertex().

Referenced by ug::AreaFaceQuality(), ug::AssignSubsetsByQuality(), and ug::ReplaceByQuadrilaterals_EdgeBased().

◆ FindSmallestFace()

template<class TIterator , class TAAPosVRT >
UG_API Face* ug::FindSmallestFace ( TIterator  facesBegin,
TIterator  facesEnd,
TAAPosVRT &  aaPos 
)

Returns the face with the smallest area.

Make sure that TIterator::value_type equals Face* and that aaPos operates on the grid from which the faces were taken.

References ug::FaceArea().

◆ GetFaceIndex()

UG_API int ug::GetFaceIndex ( Volume vol,
Face f 
)

returns the index at which face f is found in the given object

returns -1 if the face was not found.

References ug::CompareVertices(), ug::Volume::face_desc(), and ug::Volume::num_faces().

Referenced by ug::CreateHexahedronFromPrisms(), and ug::IRefiner::get_local_face_mark().

◆ GetNeighbours()

UG_API void ug::GetNeighbours ( std::vector< Face * > &  vFacesOut,
Grid grid,
Face f,
int  side,
bool  clearContainer = true 
)

collects neighbours of the given side of a face.

collects all faces that are adjacent to the given side of f.

References ug::CollectFaces(), ug::Grid::enable_options(), ug::FACEOPT_AUTOGENERATE_EDGES, ug::Grid::get_edge(), LOG, and ug::Grid::option_is_enabled().

Referenced by ug::AssignRegionToSubset(), ug::CalculateSmoothManifoldPosInParentLevelButterflyScheme(), and ug::FixFaceOrientation().

◆ GetVertex()

Vertex * ug::GetVertex ( Face f,
size_t  i 
)
inline

returns the i'th vertex of a face

This function simply returns the i'th vertex of a face

References boost::num_vertices(), UG_ASSERT, and ug::FaceVertices::vertex().

◆ InsertCenterVertex()

UG_API void ug::InsertCenterVertex ( Grid g,
Face f,
Vertex vrt,
bool  eraseOldFace 
)

Refines the face by connecting its sides with the new center.

Make sure that the specified vertex is belongs to the specified grid, and that its position lies inside the specified face (self-intersections would occur if it would lie outside). The original face may optionally be deleted.

References ug::Grid::create(), ug::Face::edge_desc(), ug::Grid::erase(), ug::Face::num_edges(), and ug::EdgeVertices::vertex().

◆ IsBoundaryFace3D()

template<class TFace >
UG_API bool ug::IsBoundaryFace3D ( Grid grid,
TFace *  f 
)

A wrapper for IsVolumeBoundaryFace.

References ug::IsVolumeBoundaryFace().

Referenced by ug::CalculateBoundaryVertexNormal3D(), ug::IsBoundaryEdge3D(), and ug::LiesOnBoundary().

◆ IsDegenerated()

template<class TAAPosVRT >
UG_API bool ug::IsDegenerated ( Face f,
TAAPosVRT &  aaPos,
number  threshold = SMALL 
)

returns true if the given face is degenerated.

Faces are degenerated if at least one edge is shorter than the given threshold.

References ug::FaceVertices::num_vertices(), ug::VecDistanceSq(), and ug::FaceVertices::vertex().

Referenced by ug::SelectLinkedFlatAndDegeneratedFaces().

◆ IsVolumeBoundaryFace() [1/3]

UG_API bool ug::IsVolumeBoundaryFace ( Grid grid,
ConstrainedFace f 
)

returns true if the given face is a boundary face.

Overload for ConstrainedFace. A face is regarded as a boundary face if it is adjacent to exactly one volume.

References ug::CollectVolumes().

◆ IsVolumeBoundaryFace() [2/3]

UG_API bool ug::IsVolumeBoundaryFace ( Grid grid,
ConstrainingFace f 
)

returns true if the given face is a boundary face.

Overload for ConstrainedFace. A face is regarded as a boundary face if it is adjacent to exactly one volume.

References ug::CollectVolumes().

◆ IsVolumeBoundaryFace() [3/3]

UG_API bool ug::IsVolumeBoundaryFace ( Grid grid,
Face f 
)

returns true if the given face is a boundary face.

A face is regarded as a boundary face if it is adjacent to exactly one volume.

Please note that overloads of this function for Constrained- and ConstrainingFaces exist.

References ug::NumAssociatedVolumes().

Referenced by ug::AssignInnerAndBoundarySubsets(), ug::IsBoundaryFace3D(), and ug::IsBoundaryVertex3D().

◆ LiesOnBoundary()

template<class TFace >
UG_API bool ug::LiesOnBoundary ( Grid grid,
TFace *  f 
)

A wrapper for IsVolumeBoundaryFace.

References ug::IsBoundaryFace3D().

◆ NumAssociatedVolumes()

int ug::NumAssociatedVolumes ( Grid grid,
Face f 
)

◆ PointFaceTest()

template<class TAAPosVRT >
UG_API int ug::PointFaceTest ( vector3 v,
Face f,
TAAPosVRT &  aaPos 
)

returns 1 if a point lies in front of a face, 0 if it lies on the face and -1 if it lies behind the face. TAAPosVRT has to be an AttachmentAccessor compatible type that operates on vector3.

References ug::CalculateNormal(), ug::VecDot(), ug::VecSubtract(), and ug::FaceVertices::vertex().

Referenced by ug::CreatePrism(), ug::CreatePyramid(), and ug::CreateTetrahedron().

◆ ProjectPointToSurface()

template<class TTriangleIterator , class TAAPosVRT >
UG_API bool ug::ProjectPointToSurface ( vector3 vOut,
const vector3 v,
const vector3 n,
TTriangleIterator  trisBegin,
TTriangleIterator  trisEnd,
TAAPosVRT &  aaPos,
bool  compareNormals = false 
)

◆ TriangleQuality()

UG_API number ug::TriangleQuality ( vector3 v1,
vector3 v2,
vector3 v3 
)

a simple measure for the quality of a triangle

returns a value between 0 and 1, where 1 indicates a good quality and 0 a bad. This method checks the dot-products of edges at the corners. The worst one (closest to 1 or -1) determines the quality.

See also
FaceQuality

References ug::VecDot(), ug::VecNormalize(), ug::VecScale(), and ug::VecSubtract().

Referenced by ug::Triangulate().

◆ Triangulate() [1/3]

void ug::Triangulate ( Grid grid,
Grid::VertexAttachmentAccessor< APosition > *  paaPos = NULL 
)
inline

◆ Triangulate() [2/3]

UG_API void ug::Triangulate ( Grid grid,
Quadrilateral q,
Grid::VertexAttachmentAccessor< APosition > *  paaPos = NULL 
)

removes the quadrilateral and replaces it by two triangles.

if paaPos is set to NULL, the quadrilateral will be splitted along the edge between the first and the third vertex. If paaPos points to a position-attachment-accessor, then the new edge will be chosen so that the worst triangle-quality is better.

References ug::CalculateVertexNormal(), ug::Grid::create(), ug::Grid::erase(), ug::SMALL, ug::TriangleQuality(), ug::VecDot(), and ug::CustomQuadrilateral< ConcreteQuadrilateralType, BaseClass, RefTriType, RefQuadType >::vertex().

Referenced by ug::AdaptSurfaceGridToCylinder(), ug::AdjustEdgeLength(), ug::ExtrudeLayersMixed(), ug::MultiEdgeSplit(), ug::PerformTetrahedralization(), and ug::Triangulate().

◆ Triangulate() [3/3]

UG_API void ug::Triangulate ( Grid grid,
QuadrilateralIterator  iterBegin,
QuadrilateralIterator  iterEnd,
Grid::VertexAttachmentAccessor< APosition > *  paaPos = NULL 
)

replaces all specified quadrilaterals by triangles.

if paaPos is set to NULL, the quadrilaterals will be splitted along the edge between their first and their third vertex. If paaPos points to a position-attachment-accessor, then the new edge will be chosen so that the worst triangle-quality is better.