33 #ifndef __H__LIB_GRID__EDGE_UTIL_IMPL__
34 #define __H__LIB_GRID__EDGE_UTIL_IMPL__
41 #include "../orientation_util.h"
46 template <
class face_iter_t>
48 std::vector<Edge*>& edgesOut,
50 face_iter_t facesBegin,
57 for(face_iter_t fiter = facesBegin; fiter != facesEnd; ++fiter)
60 for(
size_t i = 0; i < edges.
size(); ++i)
64 for(map<Edge*, int>::iterator iter = m.begin(); iter != m.end(); ++iter)
67 edgesOut.push_back(iter->first);
72 template <
class TAAPosVRT>
79 template <
class TAAPosVRT>
88 template<
class TVertex>
91 return SplitEdge<TVertex>(grid, grid, e, NULL, bConservative);
97 template<
class TVertex>
103 if(&destGrid == &srcGrid)
104 newVertex = *destGrid.
create<TVertex>(e);
106 newVertex = *destGrid.
create<TVertex>();
117 std::vector<Face*> vFaces;
121 for(std::vector<Face*>::iterator iter = vFaces.begin();
122 iter != vFaces.end(); ++iter)
124 srcGrid.
erase(*iter);
133 std::vector<Volume*> vVolumes;
137 for(std::vector<Volume*>::iterator iter = vVolumes.begin();
138 iter != vVolumes.end(); ++iter)
140 srcGrid.
erase(*iter);
153 destGrid.
erase(newVertex);
157 template<
class TVertexPositionAttachmentAccessor>
158 typename TVertexPositionAttachmentAccessor::ValueType
161 typename TVertexPositionAttachmentAccessor::ValueType v;
175 template<
class TAAPosVRT,
class TAAWeightVRT>
177 typename TAAPosVRT::ValueType
180 typename TAAPosVRT::ValueType v;
181 typedef typename TAAWeightVRT::ValueType weight_t;
187 weight_t w0 = aaWeight[e->
vertex(0)];
188 weight_t w1 = aaWeight[e->
vertex(1)];
198 template <
class TEdgeIterator>
200 TEdgeIterator edgesEnd)
206 for(TEdgeIterator iter = edgesBegin; iter != edgesEnd; ++iter)
209 stack<Edge*> candidates;
212 for(TEdgeIterator iter = edgesBegin; iter != edgesEnd; ++iter)
217 candidates.push(*iter);
219 while(!candidates.empty()){
220 Edge* e = candidates.top();
224 for(
size_t i = 0; i < 2; ++i){
254 template <
class TEdgeIterator>
257 TEdgeIterator edgesEnd)
261 for(TEdgeIterator iter = edgesBegin; iter != edgesEnd; ++iter){
273 template <
class TEdgeIterator>
276 TEdgeIterator edgesEnd,
283 for(TEdgeIterator iter = edgesBegin; iter != edgesEnd; ++iter){
287 size_t numConsidered = 0;
289 for(
size_t i = 0; i < faces.
size(); ++i){
290 if(considerFace(faces[i])){
303 template <
class TEdgeIterator,
class TAAPosVRT>
309 if(edgesBegin == edgesEnd)
314 Edge* shortestEdge = *edgesBegin;
318 for(; edgesBegin != edgesEnd; ++edgesBegin){
319 Edge* curEdge = *edgesBegin;
321 if(curLen < shortestLen){
322 shortestEdge = curEdge;
323 shortestLen = curLen;
331 template <
class TEdgeIterator,
class TAAPosVRT>
337 if(edgesBegin == edgesEnd)
342 Edge* longestEdge = *edgesBegin;
346 for(; edgesBegin != edgesEnd; ++edgesBegin){
347 Edge* curEdge = *edgesBegin;
349 if(curLen > longestLen){
350 longestEdge = curEdge;
418 template <
class EdgeIterator,
class TAAPos>
429 queue<Edge*> candidates;
438 for(
EdgeIterator iter = edgesBegin; iter != edgesEnd; ++iter){
439 aaIsCandidate[*iter] = 1;
440 candidates.push(*iter);
444 while(!candidates.empty()){
445 Edge* e = candidates.front();
447 aaIsCandidate[e] = 0;
483 if(oldDot * newDot < 0){
490 UG_ASSERT(e,
"SwapEdge did not produce a new edge.");
494 for(
size_t i = 0; i < 2; ++i){
496 for(
size_t j = 0; j < edges.size(); ++j){
497 if(edges[j] != e && (!aaIsCandidate[edges[j]])){
498 candidates.push(edges[j]);
499 aaIsCandidate[edges[j]] = 1;
511 template <
class vector_t,
class TAAPos>
518 return (fabs(
p.x() - center) < rad +
SMALL);
522 template <
class TAAPosVRT>
528 for (; eit != eit_end; ++eit) {
Base-class for edges.
Definition: grid_base_objects.h:397
holds the vertices of an Edge or an EdgeDescriptor.
Definition: grid_base_objects.h:362
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
void set_num_vertices(uint numVertices)
Definition: grid_base_objects.h:705
void set_vertex(uint index, Vertex *vrt)
Definition: grid_base_objects.h:706
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
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
EdgeContainer::iterator AssociatedEdgeIterator
used to iterate over associated edges of vertices, faces and volumes
Definition: grid.h:249
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
AssociatedEdgeIterator associated_edges_begin(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:882
bool option_is_enabled(uint option) const
see set_options for a description of valid parameters.
Definition: grid.cpp:721
void unmark(GridObject *obj)
unmarks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:808
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
AssociatedEdgeIterator associated_edges_end(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:892
void attach_to_edges_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid.h:756
void mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
void flip_orientation(Edge *e)
flips the orientation of an edge.
Definition: grid.cpp:535
void erase(GridObject *geomObj)
Definition: grid.cpp:459
void begin_marking()
begin marking.
Definition: grid.cpp:1262
geometry_traits< TGeomObj >::iterator begin()
Definition: grid_impl.hpp:164
void detach_from_edges(IAttachment &attachment)
Definition: grid.h:788
void associated_elements(traits< Vertex >::secure_container &elemsOut, TElem *e)
Puts all elements of type TAss which are contained in 'e' or which contain 'e' into elemsOut.
Definition: grid_impl.hpp:466
size_t num_edges() const
Definition: grid.h:552
geometry_traits< TGeomObj >::iterator create(GridObject *pParent=NULL)
create a custom element.
Definition: grid_impl.hpp:69
geometry_traits< TGeomObj >::iterator end()
Definition: grid_impl.hpp:175
Container which holds an array of pointers.
Definition: pointer_const_array.h:84
size_t size() const
returns the size of the associated array.
Definition: pointer_const_array_impl.hpp:106
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
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
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 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
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
UG_API number EdgeLengthSq(const EdgeVertices *e, TAAPosVRT &aaPos)
Calculates the squared length of the given edge.
Definition: edge_util_impl.hpp:73
UG_API void FixEdgeOrientation(Grid &grid, TEdgeIterator edgesBegin, TEdgeIterator edgesEnd)
creates uniform orientation of neighboured edges.
Definition: edge_util_impl.hpp:199
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
void CollectVolumes(std::vector< Volume * > &vVolumesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all volumes that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:592
void CollectFaces(std::vector< Face * > &vFacesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all faces that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:458
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
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 number VertexDistanceSq(Vertex *v0, Vertex *v1, TAAPos &aaPos)
Returns the squared distance between two vertices.
Definition: vertex_util_impl.hpp:47
Vertex * GetConnectedVertex(Edge *e, Vertex *v)
returns the vertex that is connected to v via e.
Definition: vertex_util.cpp:78
@ VOLOPT_AUTOGENERATE_EDGES
Definition: grid_constants.h:82
@ VOLOPT_AUTOGENERATE_FACES
Definition: grid_constants.h:83
@ FACEOPT_AUTOGENERATE_EDGES
Definition: grid_constants.h:71
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_API
Definition: ug_config.h:65
double number
Definition: types.h:124
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
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
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
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
int num_vertices(ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:70
Definition: smart_pointer.h:814
const number SMALL
Definition: math_constants.h:41
Edge * FindLongestEdge(TEdgeIterator edgesBegin, TEdgeIterator edgesEnd, TAAPosVRT &aaPos)
Definition: edge_util_impl.hpp:332
ElementStorage< Edge >::SectionContainer::iterator EdgeIterator
Definition: grid_base_object_traits.h:76
ElementStorage< Edge >::SectionContainer::const_iterator ConstEdgeIterator
Definition: grid_base_object_traits.h:77
bool EdgeOrientationMatches(EdgeVertices *ev, Face *f)
checks if the edge-orientation of the edge and the face matches.
Definition: orientation_util.cpp:37
boost::function< bool(base_object *)> callback
callback type for the elements base type.
Definition: grid.h:150