33 #ifndef __H__LIB_GRID__MISC_UTIL__IMPL__
34 #define __H__LIB_GRID__MISC_UTIL__IMPL__
49 template <
class TElem>
57 typedef typename TElem::side side_t;
64 for(
size_t i1 = 0; i1 < sides1.
size(); ++i1){
65 for(
size_t i2 = 0; i2 < sides2.
size(); ++i2){
66 if(sides1[i1] == sides2[i2])
77 template<
class TAAPosVRT>
80 typename TAAPosVRT::ValueType
89 UG_THROW(
"Unknown geometric-object type.");
93 template<
class TAAPosVRT,
class TAAWeightVRT>
96 typename TAAPosVRT::ValueType
98 TAAWeightVRT& aaWeight)
110 UG_THROW(
"Unknown geometric-object type.");
117 template <
class TIterator,
class TAAPosVRT>
118 typename TAAPosVRT::ValueType
122 typename TAAPosVRT::ValueType center;
124 for(TIterator iter = begin; iter != end; ++iter, ++counter)
135 template<
class TElem,
class TVertexPositionAttachmentAccessor>
139 TVertexPositionAttachmentAccessor& aaPosVRT)
141 if(iterBegin == iterEnd)
145 TElem* bestElem = *iter;
149 while(iter != iterEnd)
152 if(distSq < bestDistSq)
165 template<
class vector_t,
class TIterator,
class TAAPos>
167 TIterator begin, TIterator end,
176 vMinOut = vMaxOut = aaPos[
GetVertex(*begin, 0)];
178 const int dim = vector_t::Size;
182 for(TIterator iter = begin; iter != end; ++iter){
185 for(
size_t i_vrt = 0; i_vrt <
NumVertices(elem); ++i_vrt){
186 for(
int i = 0; i <
dim; ++i){
187 vector_t& v = aaPos[
GetVertex(elem, i_vrt)];
188 if(v[i] < vMinOut[i])
190 else if(v[i] > vMaxOut[i])
199 template <
class TElemPtr1,
class TElemPtr2>
204 for(
size_t i = 0; i < elem1->num_vertices(); ++i)
205 grid.
mark(elem1->vertex(i));
209 for(
size_t i = 0; i < elem2->num_vertices(); ++i){
221 template <
class TElem>
226 while(iterBegin != iterEnd)
228 TElem* e = *iterBegin;
236 template <
class TElem>
242 while(iterBegin != iterEnd)
244 aaInt[*iterBegin] = index++;
251 template <
class TElem,
class TAAPos>
260 for(
size_t i = 0; i < vVert.
size(); ++i)
261 for(
size_t j = i+1; j < vVert.
size(); ++j)
262 max = std::max(max,
VecDistanceSq(aaPos[vVert[i]], aaPos[vVert[j]]));
267 template <
class TAAPos>
277 default:
UG_THROW(
"ElementDiameterSq: Element type not found.")
281 template <
class TElem,
class TAAPos>
289 template <
class TAAPos,
class TIterator>
291 TIterator iter, TIterator iterEnd)
294 for(; iter != iterEnd; ++iter)
303 return std::sqrt(max);
306 template <
class TAAPos,
class TIterator>
308 TIterator iter, TIterator iterEnd)
310 number min = std::numeric_limits<number>::max();
311 for(; iter != iterEnd; ++iter)
320 return std::sqrt(min);
324 template <
class TElem1,
class TElem2,
class TAAPos>
325 typename TAAPos::ValueType
328 typedef typename TAAPos::ValueType vector_t;
337 template <
class TElem1,
class TElem2,
class TAAPos>
341 const typename TAAPos::ValueType& dir,
345 typedef typename TAAPos::ValueType vector_t;
349 return (minAngle <= angle) && (maxAngle >= angle);
Definition: pcl_process_communicator.h:70
void allreduce(const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
performs MPI_Allreduce on the processes of the communicator.
Definition: pcl_process_communicator.cpp:318
Base-class for edges.
Definition: grid_base_objects.h:397
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
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
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 erase(GridObject *geomObj)
Definition: grid.cpp:459
void begin_marking()
begin marking.
Definition: grid.cpp:1262
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
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
virtual int base_object_id() const =0
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
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
Definition: grid_base_object_traits.h:68
number ElementDiameter(const TElem &elem, TDomain &domain)
returns the maximal distance between to element vertices
number ElementDiameterSq(const TElem &elem, TDomain &domain)
returns the maximal squared distance between to element vertices
number MinElementDiameter(TDomain &domain, int level)
returns the minimal diameter of all elements between iterBegin and iterEnd.
Definition: domain_util.cpp:113
number MaxElementDiameter(TDomain &domain, int level)
returns the maximal diameter of all elements between iterBegin and iterEnd.
Definition: domain_util.cpp:104
void AssignIndices(TIterator begin, TIterator end, TAAInt &aaInt, int baseIndex=0)
assigns indices to the elements between begin and end.
Definition: attachment_util_impl.hpp:178
UG_API void EraseElements(Grid &grid, typename geometry_traits< TElem >::iterator iterBegin, typename geometry_traits< TElem >::iterator iterEnd)
erases all elements between iterBegin and iterEnd.
Definition: misc_util_impl.hpp:222
UG_API TElem * FindClosestByCoordinate(const typename TVertexPositionAttachmentAccessor::ValueType &coord, typename geometry_traits< TElem >::iterator iterBegin, typename geometry_traits< TElem >::iterator iterEnd, TVertexPositionAttachmentAccessor &aaPosVRT)
returns the element of the given type, whose center is closest to coord.
Definition: misc_util_impl.hpp:136
TAAPos::ValueType GetDirection(TElem1 *e1, TElem2 *e2, const TAAPos &aaPos)
Returns the direction from the center of e1 to the center of e2.
Definition: misc_util_impl.hpp:326
UG_API TAAPosVRT::ValueType CalculateGridObjectCenter(const GridObject *o, TAAPosVRT &aaPosVRT)
calculates the center for arbitrary geometric object
Definition: misc_util_impl.hpp:81
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 TElem::side * GetSharedSide(Grid &grid, TElem *e1, TElem *e2)
returns the shared side between the two elements or NULL if no such side exists.
Definition: misc_util_impl.hpp:52
bool CheckDirection(TElem1 *e1, TElem2 *e2, const TAAPos &aaPos, const typename TAAPos::ValueType &dir, number minAngle, number maxAngle)
Checks whether the center of e2 can be reached from the center of e1 in the given direction.
Definition: misc_util_impl.hpp:338
Vertex * GetVertex(Vertex *v, size_t i)
returns the i'th vertex of a vertex
Definition: grid_util_impl.hpp:99
size_t NumVertices(Vertex *elem)
Returns the number of vertices of the given geometric object.
Definition: grid_util_impl.hpp:123
#define PCL_RO_MAX
Definition: pcl_methods.h:61
#define PCL_RO_MIN
Definition: pcl_methods.h:62
#define UG_THROW(msg)
Definition: error.h:57
#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
TNumber rad_to_deg(TNumber rad)
Definition: math_util_impl.hpp:58
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
vector_t::value_type VecAngle(const vector_t &v1, const vector_t &v2)
returns the angle between two vectors in radiants
Definition: math_vector_functions_common_impl.hpp:401
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
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
@ VOLUME
Definition: grid_base_objects.h:63
@ VERTEX
Definition: grid_base_objects.h:60
@ EDGE
Definition: grid_base_objects.h:61
@ FACE
Definition: grid_base_objects.h:62
T value_type
Definition: sparsematrix_interface.h:2