libMesh
mesh_inserter_iterator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 Node is like a Point, but with more information.
Definition: node.h:52
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
The libMesh namespace provides an interface to certain functionality in the library.
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
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
mesh_inserter_iterator operator++(int)
This is the MeshBase class.
Definition: mesh_base.h:68
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
virtual Node * insert_node(Node *n)=0
Insert Node n into the Mesh at a location consistent with n->id(), allocating extra storage if necess...
A class for templated methods that expect output iterator arguments, which adds objects to the Mesh...
mesh_inserter_iterator & operator++()
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38