33 #ifndef __H__LIB_GRID__FACE_UTIL_IMPL__
34 #define __H__LIB_GRID__FACE_UTIL_IMPL__
42 template <
class TIterator>
47 if(facesBegin == facesEnd)
55 for(; facesBegin != facesEnd; ++facesBegin){
75 template<
class TVertexPositionAttachmentAccessor>
76 typename TVertexPositionAttachmentAccessor::ValueType
80 typename TVertexPositionAttachmentAccessor::ValueType v;
87 for(
size_t i = 0; i < numVrts; ++i)
89 VecAdd(v, v, aaPosVRT[vrts[i]]);
101 template<
class TAAPosVRT,
class TAAWeightVRT>
103 typename TAAPosVRT::ValueType
107 typename TAAPosVRT::ValueType v;
108 typedef typename TAAWeightVRT::ValueType weight_t;
115 weight_t totalWeight = 0;
116 for(
uint i = 0; i < numVrts; ++i)
118 weight_t w = aaWeight[vrts[i]];
131 template <
class vector_t,
class TAAPos>
145 <<
" vertices encountered in ContainsPoint(...).");
152 template <
class TTriangleIterator,
class TAAPosVRT>
154 TTriangleIterator trisBegin, TTriangleIterator trisEnd,
155 TAAPosVRT& aaPos,
bool compareNormals)
161 for(TTriangleIterator iter = trisBegin; iter != trisEnd; ++iter)
185 if(distance < bestDist){
200 template <
class TAAPosVRT>
217 template <
class TAAPosVRT>
220 number threshSQ = threshold * threshold;
223 for(
size_t i = 0; i < numVrts; ++i){
234 template <
class TAAPosVRT>
247 template <
class TIterator,
class TAAPosVRT>
252 for (; facesBegin != facesEnd; ++facesBegin)
253 sum +=
FaceArea(*facesBegin, aaPos);
259 template <
class TIterator,
class TAAPosVRT>
264 if(facesBegin == facesEnd)
268 Face* smallestFace = *facesBegin;
272 for(; facesBegin != facesEnd; ++facesBegin){
273 Face* curFace = *facesBegin;
275 if(curArea < smallestArea){
276 smallestFace = curFace;
277 smallestArea = curArea;
virtual Vertex * vertex(size_t index) const
Definition: grid_objects_2d.h:120
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
Definition: grid_base_objects.h:483
virtual ConstVertexArray vertices() const
Definition: grid_base_objects.h:487
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:486
virtual size_t num_vertices() const
Definition: grid_base_objects.h:488
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
geometry_traits< TGeomObj >::iterator begin()
Definition: grid_impl.hpp:164
geometry_traits< TGeomObj >::iterator end()
Definition: grid_impl.hpp:175
Vertex *const * ConstVertexArray
Definition: grid_base_objects.h:319
a face with four points.
Definition: grid_objects_2d.h:323
the most simple form of a face
Definition: grid_objects_2d.h:174
static number FaceArea(TDomain &dom, ISubsetHandler &sh, int si, size_t lvl)
Definition: domain_bridge.cpp:262
int CalculateNormal(vector3 &vNormOut, Grid &grid, Edge *e, Grid::AttachmentAccessor< Vertex, APosition > &aaPos, Grid::AttachmentAccessor< Face, ANormal > *paaNormFACE)
Calculates the normal of the given edge.
Definition: edge_util.cpp:314
UG_API bool ContainsPoint(const EdgeVertices *e, const vector_t &p, TAAPos aaPos)
Returns true if the given point lies on the given edge.
Definition: edge_util_impl.hpp:513
UG_API bool IsDegenerated(Face *f, TAAPosVRT &aaPos, number threshold=SMALL)
returns true if the given face is degenerated.
Definition: face_util_impl.hpp:218
number FaceQuality(FaceVertices *f, Grid::VertexAttachmentAccessor< APosition > aaPos)
a simple measure for the quality of a face
Definition: face_util.cpp:203
UG_API number 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.
Definition: face_util_impl.hpp:43
UG_API int PointFaceTest(vector3 &v, Face *f, TAAPosVRT &aaPos)
Definition: face_util_impl.hpp:201
UG_API bool ProjectPointToSurface(vector3 &vOut, const vector3 &v, const vector3 &n, TTriangleIterator trisBegin, TTriangleIterator trisEnd, TAAPosVRT &aaPos, bool compareNormals=false)
Definition: face_util_impl.hpp:153
void Triangulate(Grid &grid, Quadrilateral *q, Grid::VertexAttachmentAccessor< APosition > *paaPos)
removes the quadrilateral and replaces it by two triangles.
Definition: face_util.cpp:273
UG_API Face * FindSmallestFace(TIterator facesBegin, TIterator facesEnd, TAAPosVRT &aaPos)
Returns the face with the smallest area.
Definition: face_util_impl.hpp:260
#define UG_THROW(msg)
Definition: error.h:57
#define UG_API
Definition: ug_config.h:65
unsigned int uint
Definition: types.h:114
double number
Definition: types.h:124
number TriangleArea(const vector_t &p1, const vector_t &p2, const vector_t &p3)
calculates the are of the triangle defined by p1, p2 and p3
Definition: math_util_impl.hpp:914
bool PointIsInsideQuadrilateral(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Returns true if the point lies inside or on the boundary of a quadrilateral.
Definition: math_util_impl.hpp:1040
bool PointIsInsideTriangle(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2)
Returns true if the point lies inside or on the boundary of a triangle.
Definition: math_util_impl.hpp:971
void CalculateCenter(vector_t ¢erOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition: math_util_impl.hpp:98
number DistancePointToTriangle(vector_t &vOut, number &bc1Out, number &bc2Out, const vector_t &p, const vector_t &v1, const vector_t &v2, const vector_t &v3, const vector_t &n)
calculates the minimal distance of a point to a triangle.
Definition: math_util_impl.hpp:243
void VecScaleAppend(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1)
Scales a Vector and adds it to a second vector.
Definition: math_vector_functions_common_impl.hpp:126
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
void CalculateTriangleNormalNoNormalize(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (no normalization is performed).
Definition: math_vector_functions_common_impl.hpp:514
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition: math_vector_functions_common_impl.hpp:226
vector_t::value_type VecDistanceSq(const vector_t &v1, const vector_t &v2)
returns the squared distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:351
void VecAdd(vector_t &vOut, const vector_t &v1, const vector_t &v2)
adds two MathVector<N>s and stores the result in a third one
Definition: math_vector_functions_common_impl.hpp:185
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
scales a MathVector<N>
Definition: math_vector_functions_common_impl.hpp:252
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
returns the dot-product of two vector_ts
Definition: math_vector_functions_common_impl.hpp:385