ug4
Loading...
Searching...
No Matches
vertex_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__VERTEX_UTIL__
34#define __H__LIB_GRID__VERTEX_UTIL__
35
36#include <vector>
37#include "lib_grid/grid/grid.h"
42#include "common/math/ugmath.h"
43
44namespace ug
45{
56// GetVertexIndex
58
61UG_API int GetVertexIndex(EdgeVertices* e, Vertex* v);
62
64// GetVertexIndex
66
69UG_API int GetVertexIndex(FaceVertices* f, Vertex* v);
70
72// GetVertexIndex
74
77UG_API int GetVertexIndex(VolumeVertices* vol, Vertex* v);
78
80// GetConnectedVertex
82
85UG_API Vertex* GetConnectedVertex(Edge* e, Vertex* v);
86
88// GetConnectedVertex
90UG_API Vertex* GetConnectedVertex(EdgeVertices* e, Face* f);
91
93// GetConnectedVertexIndex
95UG_API int GetConnectedVertexIndex(Face* f, const EdgeDescriptor& ed);
96UG_API int GetConnectedVertexIndex(Face* f, const EdgeVertices* e);
97
100
101UG_API Edge* GetConnectedEdge(Grid& g, Vertex* vrt, Face* tri);
102
103
106UG_API Vertex* GetSharedVertex(IVertexGroup* vrts0, IVertexGroup* vrts1);
107
110
111size_t GetSharedVertices(
112 std::vector<Vertex*>& vrtsOut,
113 IVertexGroup* vrts0,
114 IVertexGroup* vrts1);
115
118size_t NumSharedVertices(IVertexGroup* vrts0, IVertexGroup* vrts1);
119
122UG_API
123int NumAssociatedEdges(Grid& grid, Vertex* v);
124
127UG_API
128int NumAssociatedFaces(Grid& grid, Vertex* v);
129
131// CollectSurfaceNeighborsSorted
133
140UG_API
141bool CollectSurfaceNeighborsSorted(std::vector<Vertex*>& vNeighborsOut,
142 Grid& grid, Vertex* v);
143
146template <class TAAPos>
147UG_API
148number VertexDistanceSq(Vertex* v0, Vertex* v1, TAAPos& aaPos);
149
152template <class TAAPos>
153UG_API
154number VertexDistance(Vertex* v0, Vertex* v1, TAAPos& aaPos);
155
157// FindVertexByCoordiante
159
162UG_API
163Vertex* FindVertexByCoordiante(vector3& coord, VertexIterator iterBegin,
164 VertexIterator iterEnd,
165 Grid::VertexAttachmentAccessor<APosition>& aaPos);
166
168
169template <size_t dim>
170int FindVertexByCoordinate(const MathVector<dim>& coord, size_t ncoords, const MathVector<dim> vCoords[]);
171
174
178template <class TAAPosVRT>
179UG_API
180void CalculateVertexNormal(vector3& nOut, Grid& grid, Vertex* vrt,
181 TAAPosVRT& aaPos);
182
185
197template <class TAAPosVRT>
198UG_API
199void CalculateBoundaryVertexNormal2D(typename TAAPosVRT::ValueType& nOut,
200 Grid& grid, Vertex* vrt,
201 TAAPosVRT& aaPos);
202
205
215template <class TAAPosVRT>
216UG_API
217void CalculateBoundaryVertexNormal3D(vector3& nOut, Grid& grid, Vertex* vrt,
218 TAAPosVRT& aaPos);
219
221// CalculateVertexNormals
223
228UG_API
229bool CalculateVertexNormals(Grid& grid, APosition& aPos, ANormal& aNorm);
230
231UG_API
232bool CalculateVertexNormals(Grid& grid,
233 Grid::AttachmentAccessor<Vertex, APosition>& aaPos,
234 Grid::AttachmentAccessor<Vertex, ANormal>& aaNorm);
235
239// CalculateBoundingBox
241
242template <class TVrtIter, class TAPosition>
243UG_API
244void
245CalculateBoundingBox(typename TAPosition::ValueType& vMinOut,
246 typename TAPosition::ValueType& vMaxOut,
247 TVrtIter vrtsBegin, TVrtIter vrtsEnd,
248 Grid::AttachmentAccessor<Vertex, TAPosition>& aaPos);
249
251// CalculateCenter
253
256template <class TVrtIter, class TAPosition>
257UG_API
258typename TAPosition::ValueType
259CalculateCenter(TVrtIter vrtsBegin, TVrtIter vrtsEnd,
260 Grid::AttachmentAccessor<Vertex, TAPosition>& aaPos);
261
263// CalculateBarycenter
265template <class TVrtIter, class TAPosition>
266UG_API
267typename TAPosition::ValueType
268CalculateBarycenter(TVrtIter vrtsBegin, TVrtIter vrtsEnd,
269 Grid::VertexAttachmentAccessor<TAPosition>& aaPos);
270
272// MergeVertices
274
279UG_API
280void MergeVertices(Grid& grid, Vertex* v1, Vertex* v2);
281
284
286template <class TVrtIterator>
287UG_API
288Vertex* MergeMultipleVertices(Grid& grid, TVrtIterator vrtsBegin,
289 TVrtIterator vrtsEnd);
290
292// RemoveDoubles
294
302template <int dim, class TVrtIterator>
303UG_API
304void RemoveDoubles(Grid& grid, const TVrtIterator& iterBegin,
305 const TVrtIterator& iterEnd, Attachment<MathVector<dim> >& aPos,
306 number threshold);
307
308template <int dim, class TVrtIterator, class TAAPos>
309UG_API
310void RemoveDoubles(Grid& grid, const TVrtIterator& iterBegin,
311 const TVrtIterator& iterEnd,
312 TAAPos aaPos,
313 number threshold);
318
322UG_API
323bool IsBoundaryVertex1D(Grid& grid, Vertex* v,
324 Grid::edge_traits::callback cbConsiderEdge = ConsiderAll());
325
328
333UG_API bool IsBoundaryVertex2D(Grid& grid, Vertex* v);
334
337
342UG_API bool IsBoundaryVertex3D(Grid& grid, Vertex* v);
343
346UG_API bool LiesOnBoundary(Grid& grid, Vertex* v);
347
349// IsRegularSurfaceVertex
351
357UG_API bool IsRegularSurfaceVertex(Grid& grid, Vertex* v);
358
360
366UG_API
367void MarkFixedCreaseVertices(Grid& grid, SubsetHandler& sh,
368 int creaseSI, int fixedSI);
369
372
375template<class TVertexPositionAttachmentAccessor>
376UG_API
377inline
378typename TVertexPositionAttachmentAccessor::ValueType
379CalculateCenter(const Vertex* v, TVertexPositionAttachmentAccessor& aaPosVRT);
380
381template<class TAAPosVRT, class TAAWeightVRT>
382UG_API
383typename TAAPosVRT::ValueType
384CalculateCenter(const Vertex* v, TAAPosVRT& aaPos, TAAWeightVRT& aaWeight);
390template<class TAAPos> inline
391UG_API
392void TransformVertex(Vertex* vrt, matrix33& m, TAAPos& aaPos);
393
396template<class TIterator, class TAAPos> inline
397UG_API
398void TransformVertices(TIterator vrtsBegin, TIterator vrtsEnd,
399 matrix33& m, TAAPos& aaPos);
400
403template<class TIterator, class TAAPos> inline
404void MoveVertices(TIterator vrtsBegin, TIterator vrtsEnd, TAAPos aaPos,
405 const typename TAAPos::ValueType& offset);
406
409
413template <class vector_t, class TAAPos>
414UG_API bool
415ContainsPoint(const Vertex* v, const vector_t& p, TAAPos aaPos);
416
418
419}// end of namespace
420
422// include implementation
423#include "vertex_util_impl.hpp"
424
425#endif
bool LiesOnBoundary(Grid &grid, Edge *e)
returns true, if the edge lies on a 2d or 3d boundary
Definition edge_util.cpp:169
int NumAssociatedFaces(Grid &grid, Edge *e)
returns the number of associated faces of the given edge
Definition edge_util.cpp:247
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 size_t NumSharedVertices(Grid &grid, TElemPtr1 elem1, TElemPtr2 elem2)
returns the number of vertices that are shared by two objects
Definition misc_util_impl.hpp:200
UG_API void TransformVertices(TIterator vrtsBegin, TIterator vrtsEnd, matrix33 &m, TAAPos &aaPos)
transforms all given vertices by a given matrix
Definition vertex_util_impl.hpp:383
bool IsRegularSurfaceVertex(Grid &grid, Vertex *v)
returns true if the vertex lies inside a regular surface
Definition vertex_util.cpp:601
Vertex * GetSharedVertex(IVertexGroup *vrts0, IVertexGroup *vrts1)
returns the first vertex of vrts0 that is also contained in vrts1 (or NULL if no such vertex exists)
Definition vertex_util.cpp:134
UG_API void RemoveDoubles(Grid &grid, const TVrtIterator &iterBegin, const TVrtIterator &iterEnd, Attachment< MathVector< dim > > &aPos, number threshold)
merges all vertices that are closer to each other than the specified threshold.
Definition vertex_util_impl.hpp:255
UG_API number VertexDistance(Vertex *v0, Vertex *v1, TAAPos &aaPos)
Returns the distance between two vertices.
Definition vertex_util_impl.hpp:54
bool IsBoundaryVertex2D(Grid &grid, Vertex *v)
returns whether a vertex lies on the boundary of a 2D grid.
Definition vertex_util.cpp:531
bool IsBoundaryVertex1D(Grid &grid, Vertex *v, Grid::edge_traits::callback cbConsiderEdge)
returns whether a vertex lies on the boundary of a polygonal chain.
Definition vertex_util.cpp:504
int NumAssociatedEdges(Grid &grid, Vertex *v)
returns the number of associated edges of the given vertex
Definition vertex_util.cpp:200
Edge * GetConnectedEdge(Grid &g, Vertex *vrt, Face *tri)
returns the edge in the triangle tri, which does not contain vrt.
Definition vertex_util.cpp:121
Vertex * FindVertexByCoordiante(vector3 &coord, VertexIterator iterBegin, VertexIterator iterEnd, Grid::VertexAttachmentAccessor< APosition > &aaPos)
returns the vertex that is the closest to the given coordinate
Definition vertex_util.cpp:317
UG_API void CalculateBoundaryVertexNormal3D(vector3 &nOut, Grid &grid, Vertex *vrt, TAAPosVRT &aaPos)
calculates the normal of a boundary vertex using associated volumes
Definition vertex_util_impl.hpp:120
bool CollectSurfaceNeighborsSorted(std::vector< Vertex * > &vNeighborsOut, Grid &grid, Vertex *v)
Collects neighbor-vertices in either clockwise or counter clockwise order.
Definition vertex_util.cpp:217
void MoveVertices(TIterator vrtsBegin, TIterator vrtsEnd, TAAPos aaPos, const typename TAAPos::ValueType &offset)
moves vertices by the specified offset
Definition vertex_util_impl.hpp:392
void MergeVertices(Grid &grid, Vertex *v1, Vertex *v2)
merges two vertices and restructures the adjacent elements.
Definition vertex_util.cpp:395
size_t GetSharedVertices(std::vector< Vertex * > &vrtsOut, IVertexGroup *vrts0, IVertexGroup *vrts1)
fills a vector with the vertices that are both contained in vrts0 and vrts1.
Definition vertex_util.cpp:154
bool IsBoundaryVertex3D(Grid &grid, Vertex *v)
returns true if a vertex lies on the boundary of a 3D grid.
Definition vertex_util.cpp:558
UG_API Vertex * MergeMultipleVertices(Grid &grid, TVrtIterator vrtsBegin, TVrtIterator vrtsEnd)
Merges all vertices between the given iterators into a single vertex.
Definition vertex_util_impl.hpp:235
UG_API void CalculateVertexNormal(vector3 &nOut, Grid &grid, Vertex *vrt, TAAPosVRT &aaPos)
calculates the normal of a vertex using associated faces
Definition vertex_util_impl.hpp:61
UG_API void TransformVertex(Vertex *vrt, matrix33 &m, TAAPos &aaPos)
transforms a vertex by a given matrix
Definition vertex_util_impl.hpp:374
int GetConnectedVertexIndex(Face *f, const EdgeDescriptor &ed)
returns the index of the first vertex that is contained in the specified face and is not contained in...
Definition vertex_util.cpp:101
int GetVertexIndex(EdgeVertices *e, Vertex *v)
returns the index at which vertex v is found in the given edge
Definition vertex_util.cpp:44
UG_API TAPosition::ValueType CalculateBarycenter(TVrtIter vrtsBegin, TVrtIter vrtsEnd, Grid::VertexAttachmentAccessor< TAPosition > &aaPos)
calculates the barycenter of a set of vertices
Definition vertex_util_impl.hpp:216
UG_API number VertexDistanceSq(Vertex *v0, Vertex *v1, TAAPos &aaPos)
Returns the squared distance between two vertices.
Definition vertex_util_impl.hpp:47
bool CalculateVertexNormals(Grid &grid, Grid::AttachmentAccessor< Vertex, APosition > &aaPos, Grid::AttachmentAccessor< Vertex, ANormal > &aaNorm)
calculates the normals of all vertices in grid and stores them in aNorm.
Definition vertex_util.cpp:345
int FindVertexByCoordinate(const MathVector< dim > &coord, size_t ncoords, const MathVector< dim > vCoords[])
returns (non-unique?) index of closest vertex
Definition vertex_util_impl.hpp:413
UG_API void CalculateBoundaryVertexNormal2D(typename TAAPosVRT::ValueType &nOut, Grid &grid, Vertex *vrt, TAAPosVRT &aaPos)
calculates the normal of a boundary vertex using associated faces
Definition vertex_util_impl.hpp:81
Vertex * GetConnectedVertex(Edge *e, Vertex *v)
returns the vertex that is connected to v via e.
Definition vertex_util.cpp:78
void MarkFixedCreaseVertices(Grid &grid, SubsetHandler &sh, int creaseSI, int fixedSI)
Definition vertex_util.cpp:615
#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
MathMatrix< 3, 3, number > matrix33
a 3x3 matrix
Definition ugmath_types.h:81
the ug namespace
ElementStorage< Vertex >::SectionContainer::iterator VertexIterator
This Iterator will be used as base-class for iterators of specialized geometric objects.
Definition grid_base_object_traits.h:73
GridSubsetHandler SubsetHandler
Definition subset_handler_grid.h:376
APosition3 APosition
Definition common_attachments.h:76
ANormal3 ANormal
Definition common_attachments.h:77
AABox< typename TAAPos::ValueType > CalculateBoundingBox(Vertex *e, TAAPos aaPos)
calculates the smallest axis aligned box that contains the given vertex
Definition bounding_box_util.h:43
boost::function< bool(base_object *)> callback
callback type for the elements base type.
Definition grid.h:150