Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
regiontree.hpp
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-02-01
7 
8  Copyright (C) 2005,2006 EPFL
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __RegionTree_H
30 #define __RegionTree_H 1
31 
32 #include <deque>
33 #include <set>
34 #include <vector>
35 
36 #include <boost/shared_ptr.hpp>
37 
38 
39 #include <feel/feelcore/feel.hpp>
40 #include <feel/feelcore/traits.hpp>
41 #include <feel/feelalg/glas.hpp>
42 
43 namespace Feel
44 {
52 {
53 public:
54 
55 
59 
60  typedef node<double>::type node_type;
61 
62  struct box_index_type
63  {
64  size_type id;
65  node_type min, max;
66  };
67 
68  typedef std::deque<box_index_type> box_container_type;
69  typedef std::vector<const box_index_type*> pbox_container_type;
70  typedef std::set<const box_index_type*> pbox_set_type;
71 
72  struct element_base;
73 
74 
76 
80 
81  RegionTree()
82  :
83  M_root( 0 )
84  {}
85 
86  ~RegionTree()
87  {
88  destroy();
89  }
90 
92 
96 
97 
99 
103 
104  size_type nbBoxes() const
105  {
106  return M_boxes.size();
107  }
108 
109 
111 
115 
116 
118 
122 
129  void addBox( node_type min, node_type max, size_type id=size_type( -1 ) );
130 
134  void clear()
135  {
136  destroy();
137  M_boxes.clear();
138  }
139 
140 
141  void findIntersectingBoxes( const node_type& bmin, const node_type& bmax, pbox_set_type& boxlst );
142  void findContainingBoxes( const node_type& bmin, const node_type& bmax, pbox_set_type& boxlst );
143  void findContainedBoxes( const node_type& bmin, const node_type& bmax, pbox_set_type& boxlst );
144  void findBoxesAtPoint( const node_type& P, pbox_set_type& boxlst );
145 
146  void findIntersectingBoxes( const node_type& bmin, const node_type& bmax, std::vector<size_type>& idvec );
147  void findContainingBoxes( const node_type& bmin, const node_type& bmax, std::vector<size_type>& idvec );
148  void findContainedBoxes( const node_type& bmin, const node_type& bmax, std::vector<size_type>& idvec );
149  void findBoxesAtPoint( const node_type& P, std::vector<size_type>& idvec );
150  void dump();
151 
153 
154 
155 
156 protected:
157 
158 private:
159 
160 
161 
162 
163  void operator=( const RegionTree& ) {} /* non-copiable */
164  RegionTree( const RegionTree& ) {} /*non-copiable */
165 
166  void build();
167  void destroy();
168 
169  static void toIdVector( pbox_set_type const& bs, std::vector<size_type>& idvec );
170 
171  element_base* M_root;
172 
173  box_container_type M_boxes;
174 };
175 
182 
188 typedef boost::shared_ptr<region_tree_type> region_tree_ptrtype;
189 
190 }
191 #endif /* __RegionTree_H */

Generated on Sun Oct 20 2013 08:25:04 for Feel++ by doxygen 1.8.4