This file is indexed.

/usr/include/sofa/component/topology/PointSubset.h is in libsofa1-dev 1.0~beta4-9.

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
220
221
222
223
224
225
226
227
228
229
230
231
232
/******************************************************************************
*       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 4      *
*                (c) 2006-2009 MGH, INRIA, USTL, UJF, CNRS                    *
*                                                                             *
* This library 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 2.1 of the License, or (at     *
* your option) any later version.                                             *
*                                                                             *
* This library 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 this library; if not, write to the Free Software Foundation,     *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
*******************************************************************************
*                               SOFA :: Modules                               *
*                                                                             *
* Authors: The SOFA Team and external contributors (see Authors.txt)          *
*                                                                             *
* Contact information: contact@sofa-framework.org                             *
******************************************************************************/
#ifndef SOFA_COMPONENT_TOPOLOGY_POINTSUBSET_H
#define SOFA_COMPONENT_TOPOLOGY_POINTSUBSET_H

#include <sofa/helper/vector.h>
#include <sofa/component/component.h>
#include <list>
#include <iostream>

namespace sofa
{
	namespace core{ namespace componentmodel{ namespace topology{ class TopologyChange; }}}

namespace component
{

namespace topology
{

	/** \brief Basic test function for a new element in the point subset : do not accept any new point by returning false
	*
	*/
	inline bool ps_testNewPointFunc(int , void* , 
									const sofa::helper::vector< unsigned int > &,
									const sofa::helper::vector< double       > &)
	{
		return false;
	}

	/** \brief Basic removal function for a point in the array  : do nothing.
	*
	*/
	inline void ps_removeFunc(int , void* )
	{
		return;
	}

	/** \brief A class for storing indices of points as to define a subset of the DOFs. Automatically manages topology changes.
	*
	* This class is a wrapper of class helper::vector that is made to take care transparently of all topology changes that might
	* happen (non exhaustive list: points added, removed, fused, renumbered).
	*/
	class SOFA_COMPONENT_TOPOLOGY_API PointSubset 
	{
	public:
		// forwardinging Commonvector methods and typdefs
		typedef  helper::vector<unsigned int>::value_type                value_type;
		typedef  helper::vector<unsigned int>::pointer                   pointer;
		typedef  helper::vector<unsigned int>::reference                 reference;
		typedef  helper::vector<unsigned int>::const_reference           const_reference;
		typedef  helper::vector<unsigned int>::size_type                 size_type;
		typedef  helper::vector<unsigned int>::difference_type          difference_type;
		typedef  helper::vector<unsigned int>::iterator                  iterator;
		typedef  helper::vector<unsigned int>::const_iterator            const_iterator;
		typedef  helper::vector<unsigned int>::reverse_iterator          reverse_iterator;
		typedef  helper::vector<unsigned int>::const_reverse_iterator    const_reverse_iterator;

	public:
		/// Optionnaly takes 2 parameters, a creation and a destruction function that will be called when adding/deleting elements.
		PointSubset( bool (*testNewPointFunc)(int, void*, const sofa::helper::vector< unsigned int > &, const sofa::helper::vector< double >&)=ps_testNewPointFunc, 
					void* testParam  = (void*)NULL, 
					void (*removeFunc)(int, void*) = ps_removeFunc, 
					void* removeParam = (void*)NULL ) 
		: m_testNewPointFunc(testNewPointFunc), 
		m_removalFunc(removeFunc), m_testParam(testParam), m_removeParam(removeParam), lastPointIndex(0)
		{}

		/// Handle PointSetTopology related events, ignore others.
		void handleTopologyEvents( std::list< const core::componentmodel::topology::TopologyChange *>::const_iterator changeIt, 
								std::list< const core::componentmodel::topology::TopologyChange *>::const_iterator &end,
								const unsigned int totalPointSetArraySize);

		// defining operators so that pointSubset can be used in a Data (see Data class).
		friend SOFA_COMPONENT_TOPOLOGY_API std::ostream& operator<< (std::ostream& ostream, const PointSubset& pointSubset);
		friend SOFA_COMPONENT_TOPOLOGY_API std::istream& operator>> (std::istream& i,             PointSubset& pointSubset);

		void setTestFunction(bool (*testNewPointFunc )(int, void*, const sofa::helper::vector< unsigned int > &, 
														const sofa::helper::vector< double >& )) 
		{
			m_testNewPointFunc=testNewPointFunc;
		}

		void setRemovalFunction( void (*removeFunc)(int, void*) ) 
		{
			m_removalFunc=removeFunc;
		}

		void setRemovalParameter( void* removeParam ) 
		{
			m_removeParam=removeParam;
		}

		void setTestParameter( void* testParam ) 
		{
			m_testParam=testParam;
		}

		const helper::vector< unsigned int > & getArray() const { return m_subset; }

		iterator begin() { return m_subset.begin(); }

		iterator end() {return m_subset.end(); }

		const_iterator begin() const { return m_subset.begin(); }

		const_iterator end() const { return m_subset.end(); }

		reverse_iterator rbegin() { return m_subset.rbegin(); }

		reverse_iterator rend() { return m_subset.rend(); }

		const_reverse_iterator rbegin() const { return m_subset.rbegin(); }

		const_reverse_iterator rend() const { return m_subset.rend(); }

		size_type size() const { return m_subset.size(); }

		size_type max_size() const { return m_subset.max_size(); }

		size_type capacity() const { return m_subset.capacity(); }

		bool empty() const { return m_subset.empty(); }

		reference operator[]( size_type n ) { return m_subset[n]; }

		const_reference operator[]( size_type i ) const { return m_subset[i]; }

		//        PointSubset& operator=( const sofa::helper::vector<unsigned int> & vector ) { m_subset( vector ); return *this; }

		//        PointSubset& operator=( const PointSubset& pointSubset ) { m_subset( pointSubset.m_subset ); return *this; }

		void reserve( size_t n ) { m_subset.reserve( n ); }

		reference front() { return m_subset.front(); }

		const_reference front() const { return m_subset.front(); }

		reference back() { return m_subset.back(); }

		const_reference back() const { return m_subset.back(); }

		void push_back( const unsigned int  t ) { m_subset.push_back( t ); }

		void pop_back() { m_subset.pop_back(); }

		void swap( helper::vector<unsigned int> &vector ) { m_subset.swap( vector ); }

		void swap( PointSubset &pointSubset) { m_subset.swap( pointSubset.m_subset ); }

		void clear() { m_subset.clear(); }

		void resize( size_t n ) { m_subset.resize( n ); }

	private:
		/// Swaps values at indices i1 and i2.
		void swap( unsigned int i1, unsigned int i2 );

		/// Add some values. Values are added at the end of the vector.
		void add( unsigned int nbPoints, 
				const sofa::helper::vector< sofa::helper::vector< unsigned int > >& ancestors,
				const sofa::helper::vector< sofa::helper::vector< double       > >& coefs);

		/// Remove the values corresponding to the points removed.
		void remove( const sofa::helper::vector<unsigned int> &index );

		/// Reorder the values.
		void renumber( const sofa::helper::vector<unsigned int> &index );

		void setTotalPointSetArraySize(const unsigned int s) { lastPointIndex=s-1; }

	private:
		/// Actual point subset stored.
		helper::vector< unsigned int > m_subset;

		/// test function, called when new points are created.
		bool (*m_testNewPointFunc)(int, void*, const sofa::helper::vector< unsigned int > &, const sofa::helper::vector< double >&);

		/// Removal function, called when points in the subset are removed 
		void (*m_removalFunc)(int, void*);

		/** Parameter to be passed to test function.
		*
		* Warning : construction and destruction of this object is not of the responsibility of pointSubset.
		*/
		void* m_testParam;

		/** Parameter to be passed to removal function.
		*
		* Warning : construction and destruction of this object is not of the responsibility of pointSubset.
		*/
		void* m_removeParam;

		/// to handle properly the removal of items, the container must know the index of the last element
		unsigned int lastPointIndex;
	};

	/// Needed to be compliant with Datas.
	SOFA_COMPONENT_TOPOLOGY_API std::ostream& operator<< (std::ostream& os, const PointSubset& pointSubset);

	/// Needed to be compliant with Datas.
	SOFA_COMPONENT_TOPOLOGY_API std::istream& operator>>(std::istream& i, PointSubset& pointSubset);

} // namespace topology

} // namespace component

} // namespace sofa

#endif // _POINTSUBSET_H_