ug4
edge_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2015: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__LIB_GRID__EDGE_UTIL__
34 #define __H__LIB_GRID__EDGE_UTIL__
35 
36 #include "face_util.h"
37 #include "lib_grid/grid/grid.h"
43 
44 namespace ug
45 {
55 // GetEdgeIndex
57 
60 UG_API int GetEdgeIndex(Face* f, Edge* e);
61 
63 // GetEdgeIndex
65 
68 UG_API int GetEdgeIndex(Volume* vol, Edge* e);
69 
70 
72 
78 UG_API
79 bool IsBoundaryEdge(Grid& grid, Edge* e,
80  Grid::face_traits::callback funcIsSurfFace);
81 
82 
85 
89 UG_API bool IsBoundaryEdge2D(Grid& grid, Edge* e);
90 
93 
101 UG_API bool IsBoundaryEdge3D(Grid& grid, Edge* e);
102 
105 UG_API bool LiesOnBoundary(Grid& grid, Edge* e);
106 
108 // GetAssociatedFaces
110 
118 UG_API
119 int GetAssociatedFaces(Face** facesOut, Grid& grid,
120  Edge* e, int maxNumFaces);
121 
123 // NumAssociatedFaces
125 
130 UG_API
131 int NumAssociatedFaces(Grid& grid, Edge* e);
132 
135 UG_API
136 Edge* GetConnectingEdge(Grid& grid, Face* f1, Face* f2);
137 
138 
141 template <class face_iter_t>
143  std::vector<Edge*>& edgesOut,
144  Grid& g,
145  face_iter_t facesBegin,
146  face_iter_t facesEnd);
147 
150 
152 template <class TAAPosVRT>
153 UG_API
154 inline number EdgeLengthSq(const EdgeVertices* e, TAAPosVRT& aaPos);
155 
158 
160 template <class TAAPosVRT>
161 UG_API
162 inline number EdgeLength(const EdgeVertices* e, TAAPosVRT& aaPos);
163 
165 // CalculateNormal
167 
183 UG_API
184 int CalculateNormal(vector3& vNormOut, Grid& grid, Edge* e,
185  Grid::AttachmentAccessor<Vertex, APosition>& aaPos,
186  Grid::AttachmentAccessor<Face, ANormal>* paaNormFACE = NULL);
187 
189 // CalculateNormal
191 
207 UG_API
208 int CalculateNormalNoNormalize(vector3& vNormOut, Grid& grid, Edge* e,
209  Grid::VertexAttachmentAccessor<APosition>& aaPos,
210  Grid::FaceAttachmentAccessor<ANormal>* paaNormFACE = NULL);
211 
213 // CollapseEdge
215 
224 UG_API
225 bool CollapseEdge(Grid& grid, Edge* e, Vertex* newVrt);
226 
228 // EdgeCollapseIsValid
230 
234 UG_API
235 bool EdgeCollapseIsValid(Grid& grid, Edge* e);
236 
237 
239 // SplitEdge
241 
247 template<class TVertex>
248 TVertex* SplitEdge(Grid& grid, Edge* e, bool bConservative = false);
249 
251 // SplitEdge
253 
267 template<class TVertex>
268 TVertex* SplitEdge(Grid& destGrid, Grid& srcGrid, Edge* e,
269  AVertex* paAssociatedVertices = NULL,
270  bool bConservative = false);
271 
273 // SwapEdge
275 
282 UG_API
283 Edge* SwapEdge(Grid& grid, Edge* e);
284 
286 // CreateEdgeSplitGeometry
288 
299 UG_API
300 bool CreateEdgeSplitGeometry(Grid& destGrid, Grid& srcGrid, Edge* e,
301  Vertex* newVertex,
302  AVertex* paAssociatedVertices = NULL);
303 
304 
307 template<class TVertexPositionAttachmentAccessor>
308 UG_API
309 typename TVertexPositionAttachmentAccessor::ValueType
310 CalculateCenter(const Edge* e, TVertexPositionAttachmentAccessor& aaPosVRT);
311 
312 
315 
318 template<class TAAPosVRT, class TAAWeightVRT>
319 UG_API
320 typename TAAPosVRT::ValueType
321 CalculateCenter(const EdgeVertices* e, TAAPosVRT& aaPos, TAAWeightVRT& aaWeight);
322 
323 
326 
328 UG_API
329 bool CutEdgesWithPlane(Selector& sel, const vector3& p, const vector3& n,
330  APosition& aPos = aPosition);
331 
333 // FixOrientation
335 
348 template <class TEdgeIterator>
349 UG_API
350 void FixEdgeOrientation(Grid& grid, TEdgeIterator edgesBegin,
351  TEdgeIterator edgesEnd);
352 
355 
375 template <class TEdgeIterator>
376 UG_API
377 void AdjustEdgeOrientationToFaceOrientation(Grid& grid, TEdgeIterator edgesBegin,
378  TEdgeIterator edgesEnd);
379 
380 template <class TEdgeIterator>
381 UG_API
382 void AdjustEdgeOrientationToFaceOrientation(Grid& grid, TEdgeIterator edgesBegin,
383  TEdgeIterator edgesEnd,
384  Grid::face_traits::callback considerFace);
385 
391 
398 template <class TEdgeIterator, class TAAPosVRT>
399 UG_API
400 Edge* FindShortestEdge(TEdgeIterator edgesBegin, TEdgeIterator edgesEnd,
401  TAAPosVRT& aaPos);
402 
406 //template <class TEdgeIterator>
407 //UG_API
408 //void RemoveDoubleEdges(Grid& grid, TEdgeIterator edgesBegin, TEdgeIterator edgesEnd);
409 
411 
416 template <class EdgeIterator, class TAAPos>
417 UG_API
418 void MinimizeEdgeLength_SwapsOnly(Grid& grid, EdgeIterator edgesBegin,
419  EdgeIterator edgesEnd, TAAPos& aaPos);
420 
423 
426 template <class vector_t, class TAAPos>
427 UG_API bool
428 ContainsPoint(const EdgeVertices* e, const vector_t& p, TAAPos aaPos);
429 
432 
437 template <class TAAPosVRT>
438 number CalculateAverageEdgeLength(Grid& grid, TAAPosVRT& aaPos);
439 
441 
442 }// end of namespace
443 
446 // include template-methods implementations
447 #include "edge_util_impl.hpp"
448 
449 #endif
int GetEdgeIndex(Face *f, Edge *e)
returns the index at which edge e is found in the given object
Definition: edge_util.cpp:50
Edge * SwapEdge(Grid &grid, Edge *e)
swaps e and thus reconnects its two adjacent triangles.
Definition: edge_util.cpp:793
TVertex * SplitEdge(Grid &grid, Edge *e, bool bConservative=false)
inserts new triangles and one new vertex by splitting the specified edge.
Definition: edge_util_impl.hpp:89
bool LiesOnBoundary(Grid &grid, Edge *e)
returns true, if the edge lies on a 2d or 3d boundary
Definition: edge_util.cpp:169
bool CollapseEdge(Grid &grid, Edge *e, Vertex *newVrt)
Collapses the specified edge performs local grid restructuring.
Definition: edge_util.cpp:403
void GetInnerEdgesOfFaceSoup(std::vector< Edge * > &edgesOut, Grid &g, face_iter_t facesBegin, face_iter_t facesEnd)
Definition: edge_util_impl.hpp:47
UG_API void MinimizeEdgeLength_SwapsOnly(Grid &grid, EdgeIterator edgesBegin, EdgeIterator edgesEnd, TAAPos &aaPos)
Transforms the given edge-set so that the sum of the length the edges is minimized.
Definition: edge_util_impl.hpp:419
int NumAssociatedFaces(Grid &grid, Edge *e)
returns the number of associated faces of the given edge
Definition: edge_util.cpp:247
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
number CalculateAverageEdgeLength(Grid &grid, TAAPosVRT &aaPos)
Returns the average length of edges in the given grid.
Definition: edge_util_impl.hpp:523
bool CreateEdgeSplitGeometry(Grid &destGrid, Grid &srcGrid, Edge *e, Vertex *newVertex, AVertex *paAssociatedVertices)
given an edge and a vertex (the split-vertex) this method constructs the split-geometry.
Definition: edge_util.cpp:591
UG_API Edge * FindShortestEdge(TEdgeIterator edgesBegin, TEdgeIterator edgesEnd, TAAPosVRT &aaPos)
Returns the shortest edge in a list of edges.
Definition: edge_util_impl.hpp:304
bool IsBoundaryEdge2D(Grid &grid, Edge *e)
returns whether an edge lies on the boundary of a 2D grid.
Definition: edge_util.cpp:112
int GetAssociatedFaces(Face **facesOut, Grid &grid, Edge *e, int maxNumFaces)
writes associated faces of e to facesOut.
Definition: edge_util.cpp:186
UG_API void AdjustEdgeOrientationToFaceOrientation(Grid &grid, TEdgeIterator edgesBegin, TEdgeIterator edgesEnd)
Orientates boundary edges in the given edge set to the orientation of associated faces.
Definition: edge_util_impl.hpp:256
bool CutEdgesWithPlane(Selector &sel, const vector3 &p, const vector3 &n, APosition &aPos)
refines all edges in sel which cut the given plane.
Definition: edge_util.cpp:868
UG_API number EdgeLengthSq(const EdgeVertices *e, TAAPosVRT &aaPos)
Calculates the squared length of the given edge.
Definition: edge_util_impl.hpp:73
bool EdgeCollapseIsValid(Grid &grid, Edge *e)
Checks if an edge-collapse would invalidate the current topology.
Definition: edge_util.cpp:527
UG_API void FixEdgeOrientation(Grid &grid, TEdgeIterator edgesBegin, TEdgeIterator edgesEnd)
creates uniform orientation of neighboured edges.
Definition: edge_util_impl.hpp:199
bool IsBoundaryEdge(Grid &grid, Edge *e, Grid::face_traits::callback funcIsSurfFace)
returns true if the edge is connected to exactly one surface face.
Definition: edge_util.cpp:78
Edge * GetConnectingEdge(Grid &grid, Face *f1, Face *f2)
Definition: edge_util.cpp:298
bool IsBoundaryEdge3D(Grid &grid, Edge *e)
returns whether an edge lies on the boundary of a 3D grid.
Definition: edge_util.cpp:139
int CalculateNormalNoNormalize(vector3 &vNormOut, Grid &grid, Edge *e, Grid::VertexAttachmentAccessor< APosition > &aaPos, Grid::FaceAttachmentAccessor< ANormal > *paaNormFACE)
Calculates the normal of the given edge.
Definition: edge_util.cpp:358
UG_API number EdgeLength(const EdgeVertices *e, TAAPosVRT &aaPos)
Calculates the length of the given edge.
Definition: edge_util_impl.hpp:80
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
#define UG_API
Definition: ug_config.h:65
double number
Definition: types.h:124
void CalculateCenter(vector_t &centerOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition: math_util_impl.hpp:98
MathVector< 3, number > vector3
a 3d vector
Definition: ugmath_types.h:72
the ug namespace
ElementStorage< Edge >::SectionContainer::iterator EdgeIterator
Definition: grid_base_object_traits.h:76
Attachment< Vertex * > AVertex
Definition: common_attachments.h:64
APosition3 APosition
Definition: common_attachments.h:76
APosition aPosition("position", true)
The standard 3d position type.
Definition: common_attachments.h:84
boost::function< bool(base_object *)> callback
callback type for the elements base type.
Definition: grid.h:150