Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
selector_interface_impl.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-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__LIBGRID__SELECTOR_INTERFACE_IMPL__
34#define __H__LIBGRID__SELECTOR_INTERFACE_IMPL__
35
36namespace ug
37{
38inline bool
40{
41 return (m_supportedElements & shElements) == shElements;
42}
43
44template <class TElem>
45inline void ISelector::select(TElem* elem, byte status){
46 if(status != 0){
47 if(!is_selected(elem)){
48 add_to_list(elem);
49 }
50 mark_selected(elem, status);
51 }
52 else
53 deselect(elem);
54}
55
56inline void ISelector::select(GridObject* elem, byte status){
57 int elemID = elem->base_object_id();
58 switch(elemID){
59 case VERTEX:
60 select(static_cast<Vertex*>(elem), status);
61 break;
62 case EDGE:
63 select(static_cast<Edge*>(elem), status);
64 break;
65 case FACE:
66 select(static_cast<Face*>(elem), status);
67 break;
68 case VOLUME:
69 select(static_cast<Volume*>(elem), status);
70 break;
71 default:
72 LOG(" ERROR: Bad Element Type in ISelector::select. Aborting.\n");
73 assert(0);
74 break;
75 }
76}
77
78template <class TIterator>
79inline void ISelector::select(TIterator iterBegin, TIterator iterEnd, byte status)
80{
81 while(iterBegin != iterEnd){
82 select(*iterBegin, status);
83 iterBegin++;
84 }
85}
86
87
88template <class TElem>
89inline void ISelector::deselect(TElem* elem){
90 if(is_selected(elem)){
91 erase_from_list(elem);
92 mark_deselected(elem);
93 }
94}
95
97 int elemID = elem->base_object_id();
98 switch(elemID){
99 case VERTEX:
100 deselect(static_cast<Vertex*>(elem));
101 break;
102 case EDGE:
103 deselect(static_cast<Edge*>(elem));
104 break;
105 case FACE:
106 deselect(static_cast<Face*>(elem));
107 break;
108 case VOLUME:
109 deselect(static_cast<Volume*>(elem));
110 break;
111 }
112}
113
114template <class TIterator>
115inline void ISelector::deselect(TIterator iterBegin, TIterator iterEnd)
116{
117 while(iterBegin != iterEnd){
118 typename TIterator::value_type val = *iterBegin;
119 ++iterBegin;
120 deselect(val);
121 }
122}
123
124
126 int elemID = elem->base_object_id();
127 switch(elemID){
128 case VERTEX:
129 return get_selection_status(static_cast<Vertex*>(elem));
130 case EDGE:
131 return get_selection_status(static_cast<Edge*>(elem));
132 case FACE:
133 return get_selection_status(static_cast<Face*>(elem));
134 case VOLUME:
135 return get_selection_status(static_cast<Volume*>(elem));
136 }
137 return 0;
138}
139
140}// end of namespace
141
142#endif
Base-class for edges.
Definition grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
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
bool is_selected(TElem *elem) const
returns true if an element is selected
Definition selector_interface.h:215
virtual void add_to_list(Vertex *elem)=0
virtual void erase_from_list(Vertex *elem)=0
void select(GridObject *elem, byte status)
selects an element
Definition selector_interface_impl.hpp:56
byte get_selection_status(GridObject *elem) const
returns the selection state of the specified elelent
Definition selector_interface_impl.hpp:125
bool elements_are_supported(uint shElements) const
returns true if the given element-types are supported.
Definition selector_interface_impl.hpp:39
void mark_deselected(Vertex *elem)
Definition selector_interface.h:368
void mark_selected(Vertex *elem, byte status)
Definition selector_interface.h:363
uint m_supportedElements
Definition selector_interface.h:389
void deselect(GridObject *elem)
Definition selector_interface_impl.hpp:96
Base-class for all vertex-types.
Definition grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
#define LOG(msg)
Definition common.h:60
unsigned int uint
Definition types.h:114
the ug namespace
@ 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