SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FData.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 ///
30 /// @file FData.h
31 /// @author Martin Cole
32 /// @date Wed Apr 28 09:45:51 2004
33 ///
34 /// @brief Taken from old LatVolField.h ...
35 
36 
37 #ifndef CORE_CONTAINERS_FDATA_H
38 #define CORE_CONTAINERS_FDATA_H 1
39 
45 #include <Core/Containers/Array3.h>
46 #include <Core/Containers/Array2.h>
47 #include <Core/Math/MiscMath.h>
48 
50 #include <string>
51 
52 namespace SCIRun {
53 
54 template <class Data, class Msh>
55 class FData3d : public Array3<Data> {
56 public:
57  typedef Data value_type;
58  typedef Data * iterator;
59  typedef const Data * const_iterator;
60 
61  iterator begin() { return &(*this)(0,0,0); }
62  iterator end() { return &((*this)(this->dim1()-1,this->dim2()-1,this->dim3()-1))+1; }
63  const_iterator begin() const { return &(*this)(0,0,0); }
64  const_iterator end() const { return &((*this)(this->dim1()-1,this->dim2()-1,this->dim3()-1))+1; }
65 
66 
67  FData3d() : Array3<Data>() {}
68  FData3d(int) : Array3<Data>() {}
69  FData3d(const FData3d& data) : Array3<Data>(data) {}
70  virtual ~FData3d();
71 
72  const value_type &operator[](typename Msh::Cell::index_type idx) const
73  { return operator()(idx.k_,idx.j_,idx.i_); }
74  const value_type &operator[](typename Msh::Face::index_type idx) const
75  { return operator()(0, 0, idx); }
76  const value_type &operator[](typename Msh::Edge::index_type idx) const
77  { return operator()(0, 0, idx); }
78  const value_type &operator[](typename Msh::Node::index_type idx) const
79  { return operator()(idx.k_,idx.j_,idx.i_); }
81  { return Array3<Data>::operator()(idx); }
82 
84  { return operator()(idx.k_,idx.j_,idx.i_); }
86  { return operator()(0, 0, idx); }
88  { return operator()(0, 0, idx); }
90  { return operator()(idx.k_,idx.j_,idx.i_); }
92  { return Array3<Data>::operator()(idx); }
93 
94  void resize(const typename Msh::Node::size_type &size)
95  { Array3<Data>::resize(size.k_, size.j_, size.i_); Array3<Data>::zero(); }
96  void resize(const typename Msh::Edge::size_type &size)
97  { Array3<Data>::resize(1, 1, size); Array3<Data>::zero(); }
98  void resize(const typename Msh::Face::size_type &size)
99  { Array3<Data>::resize(1, 1, size); Array3<Data>::zero(); }
100  void resize(const typename Msh::Cell::size_type &size)
101  { Array3<Data>::resize(size.k_, size.j_, size.i_); Array3<Data>::zero(); }
102  void resize(const size_t size)
103  { Array3<Data>::resize(1,1,size); Array3<Data>::zero(); }
104 
105  unsigned int size() const { return this->dim1() * this->dim2() * this->dim3(); }
106 
107  static const std::string type_name(int n = -1);
108  const TypeDescription* get_type_description(int n) const;
109 };
110 
111 
112 template <class Data, class Msh>
114 {
115 }
116 
117 
118 template <class Data, class Msh>
119 const std::string
121 {
122  ASSERT((n >= -1) && n <= 2);
123  if (n == -1)
124  {
125  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1), type_name(2));
126  return name;
127  }
128  else if (n == 0)
129  {
130  return "FData3d";
131  }
132  else if (n == 1)
133  {
134  return find_type_name(static_cast<Data *>(0));
135  }
136  else
137  {
138  return find_type_name(static_cast<Msh *>(0));
139  }
140 }
141 
142 template <class Data, class Msh>
143 const TypeDescription*
145 {
146  ASSERT((n >= -1) && n <= 2);
147 
148  static std::string name(type_name(0));
149  static std::string namesp("SCIRun");
150  static std::string path(__FILE__);
151  const TypeDescription *sub1 = get_type_description(static_cast<Data*>(0));
152  const TypeDescription *sub2 = get_type_description(static_cast<Msh*>(0));
153 
154  if (n == -1) {
155  static TypeDescription* tdn1 = 0;
156  if (tdn1 == 0) {
158  (*subs)[0] = sub1;
159  (*subs)[1] = sub2;
160  tdn1 = new TypeDescription(name, subs, path, namesp,
162  }
163  return tdn1;
164  }
165  else if(n == 0) {
166  static TypeDescription* tdn0 = 0;
167  if (tdn0 == 0) {
168  tdn0 = new TypeDescription(name, 0, path, namesp,
170  }
171  return tdn0;
172  }
173  else if(n == 1) {
174  return sub1;
175  }
176  return sub2;
177 }
178 
179 template <class Data, class Msh>
180 const TypeDescription*
182 {
183  static std::string name(FData3d<Data, Msh>::type_name(0));
184  static std::string namesp("SCIRun");
185  static std::string path(__FILE__);
186  const TypeDescription *sub1 = get_type_description(static_cast<Data*>(0));
187  const TypeDescription *sub2 = SCIRun::get_type_description(static_cast<Msh*>(0));
188 
189  static TypeDescription* tdn1 = 0;
190  if (tdn1 == 0) {
192  (*subs)[0] = sub1;
193  (*subs)[1] = sub2;
194  tdn1 = new TypeDescription(name, subs, path, namesp,
196  }
197  return tdn1;
198 }
199 
200 
201 
202 template <class Data, class Msh>
203 class FData2d : public Array2<Data> {
204 public:
205  typedef Data value_type;
206  typedef Data * iterator;
207  typedef Data const * const_iterator;
208 
209  iterator begin() { return &(*this)(0,0); }
210  iterator end() { return &((*this)(this->dim1()-1,this->dim2()-1))+1; }
211  const_iterator begin() const { return &(*this)(0,0); }
212  const_iterator end() const { return &((*this)(this->dim1()-1,this->dim2()-1))+1; }
213 
214  FData2d() : Array2<Data>() {}
215  FData2d(int) : Array2<Data>() {}
216  FData2d(const FData2d& data) : Array2<Data>(data) {}
217  virtual ~FData2d();
218 
219  const value_type &operator[](typename Msh::Cell::index_type idx) const
220  { return operator()(0, idx); }
221  const value_type &operator[](typename Msh::Face::index_type idx) const
222  { return operator()(idx.j_, idx.i_); }
223  const value_type &operator[](typename Msh::Edge::index_type idx) const
224  { return operator()(0, idx); }
225  const value_type &operator[](typename Msh::Node::index_type idx) const
226  { return operator()(idx.j_, idx.i_); }
228  { return Array2<Data>::operator()(static_cast<unsigned int>(idx)); }
229 
231  { return operator()(0, idx); }
233  { return operator()(idx.j_, idx.i_); }
235  { return operator()(0, idx); }
237  { return operator()(idx.j_, idx.i_); }
239  { return Array2<Data>::operator()(static_cast<unsigned int>(idx)); }
240 
241  void resize(const typename Msh::Node::size_type &size)
242  { Array2<Data>::resize(size.j_, size.i_); Array2<Data>::zero(); }
243  void resize(const typename Msh::Edge::size_type &size)
245  void resize(const typename Msh::Face::size_type &size)
246  { Array2<Data>::resize(size.j_, size.i_); Array2<Data>::zero(); }
247  void resize(const typename Msh::Cell::size_type &size)
249  void resize(const size_t size)
251 
252  unsigned int size() const { return this->dim1() * this->dim2(); }
253 
254  static const std::string type_name(int n = -1);
255 };
256 
257 
258 template <class Data, class Msh>
260 {
261 }
262 
263 
264 template <class Data, class Msh>
265 const std::string
267 {
268  ASSERT((n >= -1) && n <= 2);
269  if (n == -1)
270  {
271  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1), type_name(2));
272  return name;
273  }
274  else if (n == 0)
275  {
276  return "FData2d";
277  }
278  else if (n == 1)
279  {
280  return find_type_name(static_cast<Data *>(0));
281  }
282  else
283  {
284  return find_type_name(static_cast<Msh *>(0));
285  }
286 }
287 
288 template <class Data, class Msh>
289 const TypeDescription*
291 {
292  static std::string name(FData2d<Data, Msh>::type_name(0));
293  static std::string namesp("SCIRun");
294  static std::string path(__FILE__);
295  const TypeDescription *sub1 = get_type_description(static_cast<Data*>(0));
296  const TypeDescription *sub2 = get_type_description(static_cast<Msh*>(0));
297 
298  static TypeDescription* tdn1 = 0;
299  if (tdn1 == 0) {
301  (*subs)[0] = sub1;
302  (*subs)[1] = sub2;
303  tdn1 = new TypeDescription(name, subs, path, namesp,
305  }
306  return tdn1;
307 }
308 
309 
310 
311 
312 
313 
314 
315 template <class Data>
316 class FData1d : public Array1<Data> {
317 public:
318  // import index_type
321 
322  typedef Data value_type;
323  typedef Data * iterator;
324  typedef Data const * const_iterator;
325 
326  iterator begin() { return &(*this)(0); }
327  iterator end() { return &((*this)(this->dim1()-1))+1; }
328  const_iterator begin() const { return &(*this)(0); }
329  const_iterator end() const { return &((*this)(this->dim1()-1))+1; }
330 
331  FData1d() : Array1<Data>() {}
332  FData1d(int) : Array1<Data>() {}
334  virtual ~FData1d();
335 
336  const value_type &operator[](index_type idx) const
337  { return operator()(idx); }
339  { return operator()(idx); }
340 
341  void resize(const size_type size)
342  { Array1<Data>::resize(size); }
343 
344  size_type size() const { return this->dim1(); }
345 
346  static const std::string type_name(int n = -1);
347 };
348 
349 
350 template <class Data>
352 {
353 }
354 
355 
356 template <class Data>
357 const std::string
359 {
360  ASSERT((n >= -1) && n <= 2);
361  if (n == -1)
362  {
363  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
364  return name;
365  }
366  else if (n == 0)
367  {
368  return "FData1d";
369  }
370  else
371  {
372  return find_type_name(static_cast<Data *>(0));
373  }
374 }
375 
376 template <class Data>
377 const TypeDescription*
379 {
380  static std::string name(FData1d<Data>::type_name(0));
381  static std::string namesp("SCIRun");
382  static std::string path(__FILE__);
383  const TypeDescription *sub1 = get_type_description(static_cast<Data*>(0));
384 
385  static TypeDescription* tdn1 = 0;
386  if (tdn1 == 0)
387  {
389  (*subs)[0] = sub1;
390  tdn1 = new TypeDescription(name, subs, path, namesp,
392  }
393  return tdn1;
394 }
395 
396 
397 } // end namespace SCIRun
398 
399 #endif // Containers_FData_h
400 
static const std::string type_name(int n=-1)
Definition: FData.h:266
FData1d(const FData1d &data)
Definition: FData.h:333
const value_type & operator[](typename Msh::Node::index_type idx) const
Definition: FData.h:225
const value_type & operator[](typename Msh::Edge::index_type idx) const
Definition: FData.h:76
Data const * const_iterator
Definition: FData.h:207
FData2d()
Definition: FData.h:214
const value_type & operator[](VMesh::index_type idx) const
Definition: FData.h:227
iterator begin()
Definition: FData.h:326
Definition: TypeDescription.h:51
specializations of template&lt;class T&gt; find_type_name() function for build-in and simple types not deri...
FData1d(int)
Definition: FData.h:332
value_type & operator[](typename Msh::Face::index_type idx)
Definition: FData.h:85
value_type & operator[](VMesh::index_type idx)
Definition: FData.h:91
value_type & operator[](typename Msh::Edge::index_type idx)
Definition: FData.h:234
void resize(const typename Msh::Node::size_type &size)
Definition: FData.h:94
FData1d()
Definition: FData.h:331
const Data * const_iterator
Definition: FData.h:59
value_type & operator[](typename Msh::Node::index_type idx)
Definition: FData.h:89
Definition: FData.h:55
size_t dim2() const
Definition: Array3.h:109
const_iterator end() const
Definition: FData.h:329
const value_type & operator[](typename Msh::Face::index_type idx) const
Definition: FData.h:221
FData3d(int)
Definition: FData.h:68
size_type size() const
Definition: FData.h:344
void resize(const typename Msh::Cell::size_type &size)
Definition: FData.h:100
Definition: TypeDescription.h:45
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
Utility for specifying data invariants (Assertions)
const_iterator begin() const
Definition: FData.h:63
Data * iterator
Definition: FData.h:206
value_type & operator[](typename Msh::Cell::index_type idx)
Definition: FData.h:230
#define ASSERT(condition)
Definition: Assert.h:110
iterator begin()
Definition: FData.h:209
size_t dim3() const
Definition: Array3.h:110
Data value_type
Definition: FData.h:57
iterator end()
Definition: FData.h:62
static const std::string type_name(int n=-1)
Definition: FData.h:358
void resize(const typename Msh::Face::size_type &size)
Definition: FData.h:98
size_t dim1() const
Returns number of rows.
Definition: Array2.h:97
const string find_type_name(float *)
Definition: TypeName.cc:63
Array1< Data >::index_type index_type
Definition: FData.h:319
const_iterator begin() const
Definition: FData.h:328
const value_type & operator[](typename Msh::Cell::index_type idx) const
Definition: FData.h:219
FData2d(const FData2d &data)
Definition: FData.h:216
Data value_type
Definition: FData.h:322
void resize(size_t size1, size_t size2, size_t size3)
Definition: Array3.h:77
static const std::string type_name(int n=-1)
Definition: FData.h:120
const char * name[]
Definition: BoostGraphExampleTests.cc:87
void resize(const size_t size)
Definition: FData.h:249
long long size_type
Definition: Types.h:40
virtual ~FData1d()
Definition: FData.h:351
dictionary data
Definition: eabLatVolData.py:11
value_type & operator[](index_type idx)
Definition: FData.h:338
unsigned int size() const
Definition: FData.h:252
const_iterator end() const
Definition: FData.h:64
virtual ~FData3d()
Definition: FData.h:113
FData3d()
Definition: FData.h:67
const value_type & operator[](index_type idx) const
Definition: FData.h:336
const value_type & operator[](typename Msh::Face::index_type idx) const
Definition: FData.h:74
value_type & operator[](VMesh::index_type idx)
Definition: FData.h:238
FData3d(const FData3d &data)
Definition: FData.h:69
void resize(const typename Msh::Node::size_type &size)
Definition: FData.h:241
const Data & operator()(index_type d1, index_type d2) const
Definition: Array2.h:85
value_type & operator[](typename Msh::Node::index_type idx)
Definition: FData.h:236
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
Array1< Data >::size_type size_type
Definition: FData.h:320
const_iterator begin() const
Definition: FData.h:211
void resize(const typename Msh::Edge::size_type &size)
Definition: FData.h:243
void resize(const size_type size)
Definition: FData.h:341
iterator end()
Definition: FData.h:327
Data * iterator
Definition: FData.h:58
value_type & operator[](typename Msh::Cell::index_type idx)
Definition: FData.h:83
Definition: Array2.h:51
const value_type & operator[](typename Msh::Node::index_type idx) const
Definition: FData.h:78
const value_type & operator[](typename Msh::Edge::index_type idx) const
Definition: FData.h:223
size_t dim1() const
Definition: Array3.h:108
Definition: FData.h:203
const value_type & operator[](VMesh::index_type idx) const
Definition: FData.h:80
long long index_type
Definition: Types.h:39
value_type & operator[](typename Msh::Face::index_type idx)
Definition: FData.h:232
void resize(size_t size1, size_t size2)
Definition: Array2.h:64
Data value_type
Definition: FData.h:205
value_type & operator[](typename Msh::Edge::index_type idx)
Definition: FData.h:87
void resize(const typename Msh::Cell::size_type &size)
Definition: FData.h:247
const Data & operator()(size_t i1, size_t i2, size_t i3) const
Definition: Array3.h:98
const TypeDescription * get_type_description(int n) const
Definition: FData.h:144
Data const * const_iterator
Definition: FData.h:324
FData2d(int)
Definition: FData.h:215
int n
Definition: eab.py:9
size_t dim2() const
Returns number of cols.
Definition: Array2.h:101
Definition: FData.h:316
Interface to dynamic 3D array class.
virtual ~FData2d()
Definition: FData.h:259
const value_type & operator[](typename Msh::Cell::index_type idx) const
Definition: FData.h:72
Definition: Array1.h:51
void resize(const typename Msh::Face::size_type &size)
Definition: FData.h:245
Definition: Array3.h:64
void resize(const size_t size)
Definition: FData.h:102
iterator begin()
Definition: FData.h:61
Mesh::index_type index_type
VIRTUAL INTERFACE.
Definition: VMesh.h:63
Data * iterator
Definition: FData.h:323
unsigned int size() const
Definition: FData.h:105
const_iterator end() const
Definition: FData.h:212
iterator end()
Definition: FData.h:210
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
void resize(const typename Msh::Edge::size_type &size)
Definition: FData.h:96
Interface to dynamic 2D array class.