libMesh
mesh_inserter_iterator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 #include "libmesh/libmesh_config.h"
24 
25 #ifdef LIBMESH_ENABLE_DEPRECATED
26 
27 // Local includes
28 #include "libmesh/mesh_base.h"
29 
30 // C++ includes
31 #include <iterator>
32 
33 namespace libMesh
34 {
35 
36 // Forward declarations
37 class Elem;
38 class Node;
39 class Point;
40 
54 template <typename T>
56 {
57  using iterator_category = std::output_iterator_tag;
58  using value_type = T;
59  using difference_type = std::ptrdiff_t;
60  using pointer = T*;
61  using reference = T&;
62 
63  mesh_inserter_iterator (MeshBase & m) : mesh(m) { libmesh_deprecated(); }
64 
65  void operator=(Elem * e) { mesh.add_elem(e); }
66 
67  void operator=(Node * n) { mesh.insert_node(n); }
68 
69  void operator=(Point * p) { mesh.add_point(*p); }
70 
72  {
73  return *this;
74  }
75 
77  {
78  return mesh_inserter_iterator(*this);
79  }
80 
81  // We don't return a reference-to-T here because we don't want to
82  // construct one or have any of its methods called. We just want
83  // to allow the returned object to be able to do mesh insertions
84  // with operator=().
85  mesh_inserter_iterator & operator*() { return *this; }
86 private:
87 
89 };
90 
91 } // namespace libMesh
92 
93 #endif // LIBMESH_ENABLE_DEPRECATED
94 #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:94
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:74
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
virtual Node * insert_node(Node *n)=0
This method is deprecated.
std::output_iterator_tag iterator_category
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:39