33 #ifndef __H__LIB_GRID__VERTEX_UTIL_IMPL__
34 #define __H__LIB_GRID__VERTEX_UTIL_IMPL__
39 #include "../trees/kd_tree_static.h"
46 template <
class TAAPos>
53 template <
class TAAPos>
60 template <
class TAAPosVRT>
69 iter != iterEnd; iter++)
80 template <
class TAAPosVRT>
93 std::vector<Face*> faces;
97 for(
size_t i_face = 0; i_face < faces.size(); ++i_face){
98 Face* f = faces[i_face];
100 for(
size_t i_side = 0; i_side < f->
num_sides(); ++i_side){
109 nOut.x() += aaPos[ed.
vertex(1)].y() - aaPos[ed.
vertex(0)].y();
110 nOut.y() += aaPos[ed.
vertex(0)].x() - aaPos[ed.
vertex(1)].x();
119 template <
class TAAPosVRT>
131 std::vector<Volume*> vols;
135 for(
size_t i_vol = 0; i_vol < vols.size(); ++i_vol){
138 for(
size_t i_side = 0; i_side < v->
num_sides(); ++i_side){
159 template <
class TVrtIter,
class TAPosition>
162 typename TAPosition::ValueType& vMaxOut,
163 TVrtIter vrtsBegin, TVrtIter vrtsEnd,
166 size_t dim = TAPosition::ValueType::Size;
168 if(vrtsBegin != vrtsEnd)
170 vMinOut = aaPos[*vrtsBegin];
173 for(TVrtIter iter = vrtsBegin; iter != vrtsEnd; ++iter)
175 for(
size_t i = 0; i <
dim; ++i){
176 vMinOut[i] = std::min(vMinOut[i], aaPos[*iter][i]);
177 vMaxOut[i] = std::max(vMaxOut[i], aaPos[*iter][i]);
184 template<
class TVertexPositionAttachmentAccessor>
186 typename TVertexPositionAttachmentAccessor::ValueType
192 template<
class TAAPosVRT,
class TAAWeightVRT>
194 typename TAAPosVRT::ValueType
201 template <
class TVrtIter,
class TAPosition>
202 typename TAPosition::ValueType
206 typename TAPosition::ValueType vMin, vMax;
208 typename TAPosition::ValueType vRet;
214 template <
class TVrtIter,
class TAPosition>
215 typename TAPosition::ValueType
219 typename TAPosition::ValueType v;
222 for(TVrtIter iter = vrtsBegin; iter != vrtsEnd; ++iter)
234 template <
class TVrtIterator>
236 TVrtIterator vrtsEnd)
238 if(vrtsBegin == vrtsEnd)
243 while(vrtsBegin != vrtsEnd){
254 template <
int dim,
class TVrtIterator>
265 RemoveDoubles<dim>(grid, iterBegin, iterEnd, aaPos, threshold);
268 template <
int dim,
class TVrtIterator,
class TAAPos>
270 const TVrtIterator& iterEnd,
282 AVertexList aVertexList;
291 for(TVrtIterator iter = iterBegin; iter != iterEnd; ++iter)
296 threshold *= threshold;
297 std::vector<Vertex*> neighbours;
299 for(TVrtIterator iter = iterBegin; iter != iterEnd; ++iter)
311 if(
VecDistanceSq(aaPos[neighbours.back()], aaPos[v]) < threshold)
318 if(!neighbours.empty())
320 for(std::vector<Vertex*>::iterator nIter = neighbours.begin();
321 nIter != neighbours.end(); ++nIter)
330 aaVL[v].push_back(nv);
348 TVrtIterator iter = iterBegin;
349 while(iter != iterEnd)
354 std::list<Vertex*>::iterator nIter = aaVL[v].begin();
355 while(nIter != aaVL[v].end())
373 template<
class TAAPos>
inline
382 template<
class TIterator,
class TAAPos>
386 for(TIterator iter = vrtsBegin; iter != vrtsEnd; ++iter)
391 template<
class TIterator,
class TAAPos>
inline
392 void MoveVertices(TIterator vrtsBegin, TIterator vrtsEnd, TAAPos aaPos,
393 const typename TAAPos::ValueType& offset)
395 for(TIterator iter = vrtsBegin; iter != vrtsEnd; ++iter)
396 aaPos[*iter] += offset;
400 template <
class vector_t,
class TAAPos>
404 const vector_t& pv = aaPos[v];
405 for(
size_t i = 0; i < vector_t::Size; ++i){
412 template <
size_t dim>
416 if (ncoords <= 0)
return -1;
421 for (
size_t i=1; i<ncoords; ++i)
424 if(distSq < bestDistSq)
A generic specialization of IAttachment.
Definition: attachment_pipe.h:263
Can be used to store information about an edge and to construct an edge.
Definition: grid_base_objects.h:464
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:366
Can be queried for the edges and vertices of a face.
Definition: grid_base_objects.h:684
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
virtual EdgeDescriptor edge_desc(int index) const
returns the i-th edge of the face.
Definition: grid_base_objects.h:537
uint num_sides() const
Definition: grid_base_objects.h:546
the generic attachment-accessor for access to grids attachment pipes.
Definition: grid.h:182
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
AssociatedFaceIterator associated_faces_begin(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:944
Edge * get_edge(Vertex *v1, Vertex *v2)
returns the edge between v1 and v2, if it exists. Returns NULL if not.
Definition: grid.cpp:1069
Face * get_face(const FaceVertices &fv)
returns the face that is described by fv.
Definition: grid.cpp:1135
size_t num_vertices() const
Definition: grid.h:551
void detach_from_vertices(IAttachment &attachment)
Definition: grid.h:787
AssociatedFaceIterator associated_faces_end(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:954
bool has_vertex_attachment(IAttachment &attachment)
Definition: grid.h:798
void attach_to_vertices(IAttachment &attachment, bool passOnValues)
Definition: grid.h:728
FaceContainer::iterator AssociatedFaceIterator
used to iterate over associated faces of vertices, edges and volumes
Definition: grid.h:251
organizes vertices in a binary-tree structure. Only for static use!
Definition: kd_tree_static.h:85
bool get_neighbourhood(std::vector< Vertex * > &vrtsOut, typename TPositionAttachment::ValueType &pos, int numClosest)
Definition: kd_tree_static_impl.hpp:104
bool create_from_grid(Grid &grid, TVrtIterator vrtsBegin, TVrtIterator vrtsEnd, TPositionAttachment &aPos, int maxTreeDepth, int splitThreshold, KDSplitDimension splitDimension=KDSD_LARGEST)
Definition: kd_tree_static_impl.hpp:75
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
virtual FaceDescriptor face_desc(int index) const
Definition: grid_base_objects.h:784
uint num_sides() const
Definition: grid_base_objects.h:787
bool EdgeContains(EdgeVertices *e, Vertex *vrt)
Definition: grid_util_impl.hpp:45
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
bool IsBoundaryEdge2D(Grid &grid, Edge *e)
returns whether an edge lies on the boundary of a 2D grid.
Definition: edge_util.cpp:112
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 IsBoundaryFace3D(Grid &grid, TFace *f)
A wrapper for IsVolumeBoundaryFace.
Definition: face_util.h:151
bool FaceContains(Face *f, EdgeVertices *ev)
returns true if the given face contains the two given vertices
Definition: grid_util.cpp:561
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
@ KDSD_LARGEST
Definition: kd_tree_static.h:64
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
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
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
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
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
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
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
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
#define UG_API
Definition: ug_config.h:65
unsigned int uint
Definition: types.h:114
double number
Definition: types.h:124
void MatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication.
Definition: math_matrix_vector_functions_common_impl.hpp:49
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
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 VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
void VecNormalize(vector_t &vOut, const vector_t &v)
scales a vector_t to unit length
Definition: math_vector_functions_common_impl.hpp:501
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
MathVector< 3, number > vector3
a 3d vector
Definition: ugmath_types.h:72
vector_t::value_type VecDistance(const vector_t &v1, const vector_t &v2)
returns the distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:375
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
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