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
boundingbox.hpp
Go to the documentation of this file.
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-08-15
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 __BoundingBox_H
30 #define __BoundingBox_H 1
31 
32 #include <feel/feelalg/glas.hpp>
33 
34 namespace Feel
35 {
48 template<typename T = double>
50 {
51 public:
52 
53 
57 
58  typedef T value_type;
59  typedef typename node<T>::type node_type;
60  typedef typename matrix_node<T>::type matrix_node_type;
61 
63 
67 
68  BoundingBox( bool is_lin = true )
69  :
70  is_linear( is_lin )
71  {}
72  BoundingBox( BoundingBox const & bb )
73  :
74  is_linear( bb.is_linear ),
75  min( bb.min ),
76  max( bb.max )
77  {}
78  ~BoundingBox()
79  {}
80 
82 
86  void
87  make( matrix_node_type const& __ptab )
88  {
89  typename matrix_node_type::const_iterator2 it = __ptab.begin2();
90  typename matrix_node_type::const_iterator2 en = __ptab.end2();
91 
92  size_type P = __ptab.size1();
93 
94  min.resize( __ptab.size1() );
95  max.resize( __ptab.size1() );
96 
97  min = ublas::column( __ptab, 0 );
98  max = ublas::column( __ptab, 0 );
99 
100  ++it;
101 
102  typename node_type::iterator itmin = min.begin();
103  typename node_type::iterator itmax = max.begin();
104 
105  while ( it != en )
106  {
107  typename matrix_node_type::const_iterator1 it1 = it.begin();
108 
109  for ( size_type i = 0; i < P; ++i, ++it1 )
110  {
111  min[i] = std::min( min[i], *it1 );
112  max[i] = std::max( max[i], *it1 );
113  }
114 
115 #if 0
116  std::for_each( it.begin(), it.end(),
117  ( lambda::var( min[i] ) = std::min( lambda::var( min[i] ), lambda::_1 ),
118  lambda::var( max[i] ) = std::max( lambda::var( max[i] ), lambda::_1 ),
119  std::cout << "min: " << lambda::var( min ) << "\n",
120  std::cout << "max: " << lambda::var( max ) << "\n" ) );
121 #endif
122 
123  // enlarge the box for non-linear transformations
124  if ( !is_linear )
125  {
126  for ( size_type i = 0; i < P; ++i )
127  {
128  value_type e = ( max[i]-min[i] ) * 0.2;
129  min[i] -= e;
130  max[i] += e;
131  }
132  }
133 
134  ++it;
135  }
136 
137  }
138 
139 
141 
145 
146  bool isLinear() const
147  {
148  return is_linear;
149  }
150 
152 
156 
157 
159 
163 
164 
166 
167 
168  node_type min;
169  node_type max;
170  bool is_linear;
171 
172 };
173 }
174 #endif /* __BoundingBox_H */

Generated on Sun Oct 20 2013 08:24:54 for Feel++ by doxygen 1.8.4