mesh_inserter_iterator.h
Go to the documentation of this file.
1 
2 // The libMesh Finite Element Library.
3 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
4 
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 
19 
20 
21 #ifndef LIBMESH_MESH_INSERTER_ITERATOR_H
22 #define LIBMESH_MESH_INSERTER_ITERATOR_H
23 
24 // Local includes
25 #include "libmesh/elem.h"
26 #include "libmesh/mesh_base.h"
27 #include "libmesh/node.h"
28 
29 // C++ includes
30 #include <iterator>
31 
32 namespace libMesh
33 {
34 
35 // A class for templated methods that expect output iterator
36 // arguments, which adds objects to the Mesh.
37 // Although any mesh_inserter_iterator can add any object, we
38 // template it around object type so that type inference and
39 // iterator_traits will work.
40 template <typename T>
42  : std::iterator<std::output_iterator_tag, T>
43 {
45 
46  void operator=(Elem* e) { mesh.add_elem(e); }
47 
48  void operator=(Node* n) { mesh.insert_node(n); }
49 
50  void operator=(Point* p) { mesh.add_point(*p); }
51 
53  return *this;
54  }
55 
57  return mesh_inserter_iterator(*this);
58  }
59 
60  // We don't return a reference-to-T here because we don't want to
61  // construct one or have any of its methods called. We just want
62  // to allow the returned object to be able to do mesh insertions
63  // with operator=().
64  mesh_inserter_iterator& operator*() { return *this; }
65 private:
66 
68 };
69 
70 } // namespace libMesh
71 
72 
73 #endif // LIBMESH_MESH_INSERTER_ITERATOR_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo