This file is indexed.

/usr/include/avogadro/neighborlist.h is in libavogadro-dev 1.0.3-10.1+b2.

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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*********************************************************************
  NeighborList - NeighborList class

  Copyright (C) 2009 by Tim Vandermeersch

  This file is part of the Avogadro molecular editor project.
  For more information, see <http://avogadro.openmolecules.net/>

  Avogadro is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  Avogadro 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  02110-1301, USA.
***********************************************************************/

#ifndef NEIGHBORLIST_H
#define NEIGHBORLIST_H

#include <avogadro/molecule.h>

#include <Eigen/Core>

namespace Avogadro
{
  /**
   * @class NeighborList neighborlist.h <avogadro/neighborlist.h>
   * @brief A list container for finding spatial neighbors of atoms
   * @author Tim Vandermeersch
   *
   * NeighborList can be used for finding non-bonded interactions between
   * pairs of atoms.
   * Based on:
   * Near-neighbor calculations using a modified cell-linked list method
   * Mattson, W.; B. M. Rice (1999). "Near-neighbor calculations using a
   * modified cell-linked list method". Computer Physics Communications
   * 119: 135.
   *
   * http://dx.doi.org/10.1016/S0010-4655%2898%2900203-3
   *
   */
  class Atom;

  class A_EXPORT NeighborList
  {
    private:
      typedef std::vector<Atom*>::iterator atom_iter;

    public:
      /**
       * Constructor to include all atoms.
       * @param mol The molecule containing the atoms
       * @param rcut The cut-off distance.
       * @param boxSize The number of cells per rcut distance.
       */
      NeighborList(Molecule *mol, double rcut, bool periodic = false, int boxSize = 1);
      /**
       * Construcor.
       * @param atoms The atoms
       * @param rcut The cut-off distance.
       * @param periodic Use periodic boundary conditions.
       * @param The number of cells per rcut distance. 
       */
      NeighborList(const QList<Atom*> &atoms, double rcut, bool periodic = false, int boxSize = 1);

      /**
       * Update the cells. While minimizing or running MD simulations,
       * atoms move and can go from on cell into the next. This function
       * should be called every 10-20 iterations to make sure the cells
       * stay accurate.
       */
      void update();
      /**
       * Get the near-neighbor atoms for @p atom. The squared distance is
       * checked and is cached for later use (see r2() function).
       *
       * Note: Atoms in relative 1-2 and 1-3 positions are not returned.
       * The @p atom itself isn't added to the list.
       *
       * @param atom The atom for which to return the near-neighbors
       * @return The near-neighbors for @p atom
       */
      QList<Atom*> nbrs(Atom *atom, bool uniqueOnly = true);
      /**
       * Get the near-neighbor atoms around @p pos. The squared distance is
       * checked and is cached for later use (see r2() function).
       *
       * @param pos The position for which to return the near-neighbors
       * @return The near-neighbors for @p atom
       */
      QList<Atom*> nbrs(const Eigen::Vector3f *pos);
      /**
       * Get the cached squared distance from the atom last used to call
       * nbrs to the atom with @p index in the returned vector.
       * @param index The index for the atom in the vector of atoms returned by nbrs().
       * @return The cached squared distance.
       */
      inline double r2(unsigned int index) const
      {
        return m_r2.at(index);
      }

    private:
      inline unsigned int ghostIndex(int i, int j, int k) const
      {
        i += m_boxSize + 1;
        j += m_boxSize + 1;
        k += m_boxSize + 1;
        return i + j * m_ghostX + k * m_ghostXY;
      }

      inline unsigned int ghostIndex(const Eigen::Vector3i &index) const
      {
        return ghostIndex(index.x(), index.y(), index.z());
      }

      inline unsigned int cellIndex(int i, int j, int k) const
      {
        return i + j * m_dim.x() + k * m_xyDim;
      }

      inline unsigned int cellIndex(const Eigen::Vector3i &index) const
      {
        return index.x() + index.y() * m_dim.x() + index.z() * m_xyDim;
      }


      inline unsigned int cellIndex(const Eigen::Vector3d &pos) const
      {
        return cellIndex( int(floor( (pos.x() - m_min.x()) / m_edgeLength )),
                          int(floor( (pos.y() - m_min.y()) / m_edgeLength )),
                          int(floor( (pos.z() - m_min.z()) / m_edgeLength )) );
      }

      inline Eigen::Vector3i cellIndexes(const Eigen::Vector3d *pos) const
      {
        Eigen::Vector3i index;
        index.x() = int(floor( (pos->x() - m_min.x()) / m_edgeLength ));
        index.y() = int(floor( (pos->y() - m_min.y()) / m_edgeLength ));
        index.z() = int(floor( (pos->z() - m_min.z()) / m_edgeLength ));
        return index;
      }

      /**
       * @param i Index for the first atom (indexed from 1)
       * @param j Index for the first atom (indexed from 1)
       * @return True if atoms with index @p i and @p j are bonded (1-2)
       */
      inline bool IsOneTwo(unsigned int i, unsigned int j) const
      {
        std::vector<unsigned int>::const_iterator iter;
        for (iter = m_oneTwo.at(i).begin(); iter != m_oneTwo.at(i).end(); ++iter)
          if (*iter == j)
            return true;

        return false;
      }

      /**
       * @param i Index for the first atom (indexed from 1)
       * @param j Index for the first atom (indexed from 1)
       * @return True if atoms with index @p i and @p j are in a 1-3 position
       */
      inline bool IsOneThree(unsigned int i, unsigned int j) const
      {
        std::vector<unsigned int>::const_iterator iter;
        for (iter = m_oneThree.at(i).begin(); iter != m_oneThree.at(i).end(); ++iter)
          if (*iter == j)
            return true;

        return false;
      }

      /**
       * Initialize the 1-2 and 1-3 cache.
       */
      void initOneTwo();
      void initCells();
      void updateCells();
      void initOffsetMap();
      void initGhostMap(bool periodic = false);
      bool insideShpere(const Eigen::Vector3i &index);

      QList<Atom*>                        m_atoms;
      double                              m_rcut, m_rcut2;
      double                              m_edgeLength;
      int                                 m_boxSize;
      int                                 m_updateCounter;


      Eigen::Vector3d                     m_min, m_max;
      Eigen::Vector3i                     m_dim;
      int                                 m_xyDim;
      std::vector<std::vector<Atom*> >    m_cells;

      std::vector<Eigen::Vector3i>        m_offsetMap;
      std::vector<Eigen::Vector3i>        m_ghostMap;
      int                                 m_ghostX;
      int                                 m_ghostXY;

      std::vector<double>                 m_r2;

      std::vector<std::vector<unsigned int> > m_oneTwo;
      std::vector<std::vector<unsigned int> > m_oneThree;
  };

} // end namespace OpenBabel

//! \brief NeighborList class

#endif