ViennaGrid - The Vienna Grid Library
2.1.0
|
00001 #ifndef VIENNAGRID_ELEMENT_VIEW_HPP 00002 #define VIENNAGRID_ELEMENT_VIEW_HPP 00003 00004 /* ======================================================================= 00005 Copyright (c) 2011-2014, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 00009 ----------------- 00010 ViennaGrid - The Vienna Grid Library 00011 ----------------- 00012 00013 License: MIT (X11), see file LICENSE in the base directory 00014 ======================================================================= */ 00015 00016 00017 #include "viennagrid/element/element.hpp" 00018 #include "viennagrid/mesh/mesh.hpp" 00019 00024 namespace viennagrid 00025 { 00026 namespace result_of 00027 { 00028 00030 template <typename something, 00031 typename element_type_or_tag, 00032 typename view_container_tag = std_deque_tag> 00033 struct element_view 00034 { 00035 typedef typename element_range<something, element_type_or_tag>::type::base_container_type base_container_type; 00036 typedef typename result_of::view<base_container_type, view_container_tag>::type type; 00037 }; 00038 00040 template <typename something, 00041 typename element_type_or_tag, 00042 typename view_container_tag = std_deque_tag> 00043 struct const_element_view 00044 { 00045 typedef typename const_element_range<something, element_type_or_tag>::type::base_container_type base_container_type; 00046 typedef typename result_of::view<const base_container_type, view_container_tag>::type type; 00047 }; 00048 00049 } 00050 00052 template<typename element_type_or_tag, typename something> 00053 typename result_of::element_view<something, element_type_or_tag>::type 00054 element_view( something & s ) 00055 { 00056 typedef typename result_of::element_tag<element_type_or_tag>::type element_tag; 00057 typedef typename result_of::element<something, element_tag>::type element_type; 00058 00059 typename result_of::element_view<something, element_tag>::type view_obj; 00060 view_obj.set_base_container( viennagrid::get<element_type>( s.element_collection() ) ); 00061 00062 return view_obj; 00063 } 00064 00065 00067 template<typename element_type_or_tag, typename something, typename functor> 00068 typename result_of::element_view<something, element_type_or_tag>::type 00069 element_view( something & s, functor f ) 00070 { 00071 typedef typename result_of::element_tag<element_type_or_tag>::type element_tag; 00072 00073 typedef typename result_of::element_range<something, element_tag>::type RangeType; 00074 typedef typename result_of::iterator<RangeType>::type IteratorType; 00075 00076 RangeType range = viennagrid::elements<element_tag>(s); 00077 00078 typename result_of::element_view<something, element_tag>::type view_obj; 00079 view_obj.set_base_container( *range.get_base_container() ); 00080 00081 for ( IteratorType it = range.begin(); it != range.end(); ++it ) 00082 { 00083 if ( f(*it) ) 00084 view_obj.insert_handle( it.handle() ); 00085 } 00086 00087 return view_obj; 00088 } 00089 00091 template<typename element_type_or_tag, typename something, typename functor> 00092 typename result_of::const_element_view<something, element_type_or_tag>::type 00093 element_view( something const & s, functor f ) 00094 { 00095 typedef typename result_of::element_tag<element_type_or_tag>::type element_tag; 00096 00097 typedef typename result_of::const_element_range<something, element_tag>::type RangeType; 00098 typedef typename result_of::iterator<RangeType>::type IteratorType; 00099 00100 RangeType range = viennagrid::elements<element_tag>(s); 00101 00102 typename result_of::element_view<something, element_tag>::type view_obj; 00103 view_obj.set_base_container( *range.get_base_container() ); 00104 00105 for ( IteratorType it = range.begin(); it != range.end(); ++it ) 00106 { 00107 if ( f(*it) ) 00108 view_obj.insert_handle( it.handle() ); 00109 } 00110 00111 return view_obj; 00112 } 00113 00114 } 00115 00116 00117 #endif