mesh_inserter_iterator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_MESH_INSERTER_ITERATOR_H
21 #define LIBMESH_MESH_INSERTER_ITERATOR_H
22 
23 // Local includes
24 #include "libmesh/elem.h"
25 #include "libmesh/mesh_base.h"
26 #include "libmesh/node.h"
27 
28 // C++ includes
29 #include <iterator>
30 
31 namespace libMesh
32 {
33 
45 template <typename T>
47  : std::iterator<std::output_iterator_tag, T>
48 {
50 
51  void operator=(Elem * e) { mesh.add_elem(e); }
52 
53  void operator=(Node * n) { mesh.insert_node(n); }
54 
55  void operator=(Point * p) { mesh.add_point(*p); }
56 
58  return *this;
59  }
60 
62  return mesh_inserter_iterator(*this);
63  }
64 
65  // We don't return a reference-to-T here because we don't want to
66  // construct one or have any of its methods called. We just want
67  // to allow the returned object to be able to do mesh insertions
68  // with operator=().
69  mesh_inserter_iterator & operator*() { return *this; }
70 private:
71 
73 };
74 
75 } // namespace libMesh
76 
77 
78 #endif // LIBMESH_MESH_INSERTER_ITERATOR_H
mesh_inserter_iterator & operator*()
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:100
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
mesh_inserter_iterator operator++(int)
Base class for Mesh.
Definition: mesh_base.h:77
virtual Elem * add_elem(Elem *e)=0
virtual Node * insert_node(Node *n)=0
An output iterator for use with packed_range functions.
mesh_inserter_iterator & operator++()
A geometric point in (x,y,z) space.
Definition: point.h:38