libMesh
mesh_inserter_iterator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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/mesh_base.h"
25 
26 // C++ includes
27 #include <iterator>
28 
29 namespace libMesh
30 {
31 
32 // Forward declarations
33 class Elem;
34 class Node;
35 class Point;
36 
48 template <typename T>
50  : std::iterator<std::output_iterator_tag, T>
51 {
53 
54  void operator=(Elem * e) { mesh.add_elem(e); }
55 
56  void operator=(Node * n) { mesh.insert_node(n); }
57 
58  void operator=(Point * p) { mesh.add_point(*p); }
59 
61  return *this;
62  }
63 
65  return mesh_inserter_iterator(*this);
66  }
67 
68  // We don't return a reference-to-T here because we don't want to
69  // construct one or have any of its methods called. We just want
70  // to allow the returned object to be able to do mesh insertions
71  // with operator=().
72  mesh_inserter_iterator & operator*() { return *this; }
73 private:
74 
76 };
77 
78 } // namespace libMesh
79 
80 
81 #endif // LIBMESH_MESH_INSERTER_ITERATOR_H
libMesh::mesh_inserter_iterator::mesh
MeshBase & mesh
Definition: mesh_inserter_iterator.h:75
libMesh::mesh_inserter_iterator::mesh_inserter_iterator
mesh_inserter_iterator(MeshBase &m)
Definition: mesh_inserter_iterator.h:52
libMesh::mesh_inserter_iterator::operator*
mesh_inserter_iterator & operator*()
Definition: mesh_inserter_iterator.h:72
libMesh::mesh_inserter_iterator::operator=
void operator=(Node *n)
Definition: mesh_inserter_iterator.h:56
libMesh::mesh_inserter_iterator::operator++
mesh_inserter_iterator operator++(int)
Definition: mesh_inserter_iterator.h:64
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::mesh_inserter_iterator::operator++
mesh_inserter_iterator & operator++()
Definition: mesh_inserter_iterator.h:60
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::Node
A Node is like a Point, but with more information.
Definition: node.h:52
libMesh::mesh_inserter_iterator::operator=
void operator=(Point *p)
Definition: mesh_inserter_iterator.h:58
libMesh::MeshBase::insert_node
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...
libMesh::mesh_inserter_iterator
A class for templated methods that expect output iterator arguments, which adds objects to the Mesh.
Definition: mesh_inserter_iterator.h:49
libMesh::MeshBase::add_elem
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::mesh_inserter_iterator::operator=
void operator=(Elem *e)
Definition: mesh_inserter_iterator.h:54
libMesh::MeshBase::add_point
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.