This file is indexed.

/usr/include/dolfin/mesh/MeshEntityIterator.h is in libdolfin-dev 1.4.0+dfsg-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// Copyright (C) 2006-2008 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Andre Massing 2009
//
// First added:  2006-05-09
// Last changed: 2013-04-23

#ifndef __MESH_ENTITY_ITERATOR_H
#define __MESH_ENTITY_ITERATOR_H

#include "Mesh.h"
#include "MeshEntity.h"

namespace dolfin
{

  /// MeshEntityIterator provides a common iterator for mesh entities
  /// over meshes, boundaries and incidence relations. The basic use
  /// is illustrated below.
  ///
  /// *Example*
  ///
  ///     The following example shows how to iterate over all mesh entities
  ///     of a mesh of topological dimension dim:
  ///
  ///     .. code-block:: c++
  ///
  ///         for (MeshEntityIterator e(mesh, dim); !e.end(); ++e)
  ///         {
  ///           e->foo();
  ///         }
  ///
  ///     The following example shows how to iterate over mesh entities of
  ///     topological dimension dim connected (incident) to some mesh entity f:
  ///
  ///     .. code-block:: c++
  ///
  ///         for (MeshEntityIterator e(f, dim); !e.end(); ++e)
  ///         {
  ///           e->foo();
  ///         }
  ///
  /// In addition to the general iterator, a set of specific named iterators
  /// are provided for entities of type _Vertex_, _Edge_, _Face_, _Facet_
  /// and _Cell_. These iterators are defined along with their respective
  /// classes.

  class MeshEntityIterator
  {
  public:

    /// Default constructor
    MeshEntityIterator() : _pos(0), pos_end(0), index(0) {}

    /// Create iterator for mesh entities over given topological dimension
    MeshEntityIterator(const Mesh& mesh, std::size_t dim)
      : _entity(), _pos(0), pos_end(mesh.size(dim)), index(0)
    {
      // Check if mesh is empty
      if (mesh.num_vertices() == 0)
        return;

      // Initialize mesh entity
      _entity.init(mesh, dim, 0);

      // Update end position if entities need to be generated first
      if (pos_end == 0)
        pos_end = mesh.init(dim);
    }

    /// Create iterator for entities of given dimension connected to
    /// given entity
    MeshEntityIterator(const MeshEntity& entity, std::size_t dim)
      : _entity(entity.mesh(), dim, 0), _pos(0), index(0)
    {
      // Get connectivity
      const MeshConnectivity& c = entity.mesh().topology()(entity.dim(), dim);

      // Compute connectivity if empty
      if (c.empty())
        entity.mesh().init(entity.dim(), dim);

      // Get size and index map
      if (c.empty())
      {
        pos_end = 0;
        index = 0;
      }
      else
      {
        pos_end = c.size(entity.index());
        index = c(entity.index());
      }
    }

    /// Copy constructor
    MeshEntityIterator(const MeshEntityIterator& it)
      : _entity(it._entity), _pos(it._pos), pos_end(it.pos_end),
      index(it.index) {}

    /// Destructor
    virtual ~MeshEntityIterator() {}

    /// Step to next mesh entity (prefix increment)
    MeshEntityIterator& operator++()
    {
      ++_pos;
      return *this;
    }

    /// Step to the previous mesh entity (prefix decrease)
    MeshEntityIterator& operator--()
    {
      --_pos;
      return *this;
    }

    /// Return current position
    std::size_t pos() const
    { return _pos; }

    /// Comparison operator
    bool operator==(const MeshEntityIterator& it) const
    {
      // Use const_cast to use operator* inside comparison, which
      // automatically updates the entity index corresponding to pos
      // *before* comparison (since update of entity delays until
      // request for entity)
      return ((const_cast<MeshEntityIterator *>(this))->operator*()
            == (const_cast<MeshEntityIterator *>(&it))->operator*()
            && _pos == it._pos && index == it.index);
    }

    /// Comparison operator
    bool operator!=(const MeshEntityIterator & it) const
    { return !operator==(it); }

    /// Dereference operator
    MeshEntity& operator*()
    { return *operator->(); }

    /// Member access operator
    MeshEntity* operator->()
    { _entity._local_index = (index ? index[_pos] : _pos); return &_entity; }

    /// Check if iterator has reached the end
    bool end() const
    { return _pos >= pos_end; }

    /// Provide a safeguard iterator pointing beyond the end of an
    /// iteration process, either iterating over the mesh /or incident
    /// entities. Added to be bit more like STL iterators, since many
    /// algorithms rely on a kind of beyond iterator.
    MeshEntityIterator end_iterator()
    {
      MeshEntityIterator
      sg(*this);
      sg.set_end();
      return sg;
    }

    // Note: Not a subclass of Variable for efficiency!
    // Commented out to avoid warning about shadowing str() for MeshEntity
    // Return informal string representation (pretty-print)
    // std::string str(bool verbose) const;

  private:

    // Set pos to end position. To create a kind of mesh.end() iterator.
    void set_end()
    { _pos = pos_end; }

    // Mesh entity
    MeshEntity _entity;

    // Current position
    std::size_t _pos;

    // End position
    std::size_t pos_end;

    // Mapping from pos to index (if any)
    const unsigned int* index;

  };

}

#endif