This file is indexed.

/usr/include/claw/impl/rectangle.tpp is in libclaw-dev 1.7.4-2.

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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/*
  CLAW - a C++ Library Absolutely Wonderful

  CLAW is a free library without any particular aim but being useful to 
  anyone.

  Copyright (C) 2005-2011 Julien Jorge

  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 St, Fifth Floor, Boston, MA  02110-1301  USA

  contact: julien.jorge@gamned.org
*/
/**
 * \file rectangle.tpp
 * \brief Implementation of claw::math::rectangle class.
 * \author Julien Jorge
 */
#include <algorithm>

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor.
 */
template<class T>
claw::math::rectangle<T>::rectangle()
{

} // rectangle::rectangle() [constructor]

/*----------------------------------------------------------------------------*/
/**
 * \brief Copy constructor.
 * \param that Rectangle to copy from.
 */
template<class T>
template<class U>
claw::math::rectangle<T>::rectangle( const rectangle<U>& that )
  : position(that.position), width(that.width), height(that.height)
{

} // rectangle::rectangle() [copy constructor]

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor from a box.
 * \param that The box to copy from.
 */
template<class T>
template<class U>
claw::math::rectangle<T>::rectangle( const box_2d<U>& that )
  : position(that.left(), that.top()), width(that.width()),
    height(that.height())
{

} // rectangle::rectangle() [copy constructor]

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor with initialization.
 * \param _x Rectangle's X-coordinate.
 * \param _y Rectangle's Y-coordinate.
 * \param _width Rectangle's width.
 * \param _height Rectangle's height.
 */
template<class T>
claw::math::rectangle<T>::rectangle
( const value_type& _x, const value_type& _y,
  const value_type& _width, const value_type& _height )
  : position(_x, _y), width(_width), height(_height)
{

} // rectangle::rectangle() [constructor with values]

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor with initialization.
 * \param pos The position of the rectangle.
 * \param _width Rectangle's width.
 * \param _height Rectangle's height.
 */
template<class T>
template<typename U>
claw::math::rectangle<T>::rectangle
( const coordinate_2d<U>& pos, const value_type& _width,
  const value_type& _height )
  : position(pos), width(_width), height(_height)
{
  
} // rectangle::rectangle() [constructor from position and size]

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor with initialization.
 * \param pos The position of the rectangle.
 * \param size The size of the rectangle.
 */
template<class T>
template<typename U>
claw::math::rectangle<T>::rectangle
( const coordinate_2d<U>& pos, const coordinate_2d<U>& size )
  : position(pos), width(size.x), height(size.y)
{
  
} // rectangle::rectangle() [constructor from position and size]

/*----------------------------------------------------------------------------*/
/**
 * \brief Get a copy of the rectangle by converting its members to a given type.
 *
 * Consider the following code:
 *
 * <tt> rectangle<float> a;
 *
 * ...
 *
 * rectangle<int> b(a); </tt>
 *
 * The copy constructor will be called, and your compiler should print some
 * warnings in your console. These warnings have a meaning, so we don't want to
 * make them disapear by adding explicit type conversion inside the rectangle
 * class nor adding a cast operator that will be used silently by the compiler.
 *
 * If you really want to convert the type, this method will explicitly cast the
 * member variables.
 */
template<class T>
template<typename U>
claw::math::rectangle<U> claw::math::rectangle<T>::cast_value_type_to() const
{
  return claw::math::rectangle<U>
    ( position.template cast_value_type_to<U>(), (U)width, (U)height );
} // rectangle::cast_value_type_to()

/*----------------------------------------------------------------------------*/
/**
 * \brief Tell if this rectangle equals an other rectangle.
 * \param that The rectangle to compare to.
 */
template<class T>
bool claw::math::rectangle<T>::operator==( const self_type& that ) const
{
  return (position == that.position) && (width == that.width)
    && (height == that.height);
} // rectangle::operator==()

/*----------------------------------------------------------------------------*/
/**
 * \brief Tell if this rectangle equals an other rectangle.
 * \param that The rectangle to compare to.
 */
template<class T>
bool claw::math::rectangle<T>::operator!=( const self_type& that ) const
{
  return !(*this == that);
} // rectangle::operator!=()

/*----------------------------------------------------------------------------*/
/**
 * \brief Calculate the rectangle's area.
 */
template<class T>
typename claw::math::rectangle<T>::value_type
claw::math::rectangle<T>::area() const
{
  return width * height;
} // rectangle::area()

/*----------------------------------------------------------------------------*/
/**
 * \brief Tell if a point is in a rectangle.
 * \param p The supposed included point.
 */
template<class T>
bool
claw::math::rectangle<T>::includes( const coordinate_2d<value_type>& p ) const
{
  return (position.x <= p.x) && (right() >= p.x)
    && (position.y <= p.y) && (bottom() >= p.y);
} // rectangle::includes()

/*----------------------------------------------------------------------------*/
/**
 * \brief Tell if a rectangle is in a rectangle.
 * \param r The supposed included rectangle.
 */
template<class T>
bool claw::math::rectangle<T>::includes( const self_type& r ) const
{
  box_2d<value_type> his_box(r);

  return includes(his_box.first_point) && includes(his_box.second_point);
} // rectangle::includes() [rectangle]

/*----------------------------------------------------------------------------*/
/**
 * \brief Tell if there is an intersection of two rectangles.
 * \param r The supposed intersecting rectangle.
 */
template<class T>
bool claw::math::rectangle<T>::intersects( const self_type& r ) const
{
  return (right() >= r.position.x)
    && (r.right() >= position.x) 
    && (bottom() >= r.position.y)
    && (r.bottom() >= position.y);
} // rectangle::intersects()

/*----------------------------------------------------------------------------*/
/**
 * \brief Intersection of two rectangles.
 * \param r The supposed intersecting rectangle.
 */
template<class T>
claw::math::rectangle<T>
claw::math::rectangle<T>::intersection( const self_type& r ) const
{
  self_type result;

  if ( intersects(r) )
    {
      x_intersection(r, result);
      y_intersection(r, result);
    }

  return result;
} // rectangle::intersection()

/*----------------------------------------------------------------------------*/
/**
 * \brief Get the smallest rectangle bounding both this rectangle and another
 *        one.
 * \param r The other rectangle.
 */
template<class T>
claw::math::rectangle<T>
claw::math::rectangle<T>::join( const self_type& r ) const
{
  const T result_left = std::min( left(), r.left() );
  const T result_top = std::min( top(), r.top() );
  const T result_bottom = std::max( bottom(), r.bottom() );
  const T result_right = std::max( right(), r.right() );

  return self_type
    ( result_left, result_top, result_right - result_left,
      result_bottom - result_top );
} // rectangle::join()

/*----------------------------------------------------------------------------*/
/**
 * \brief set new position and size to the rectangle.
 * \param new_x New x-coordinate.
 * \param new_y New y-coordinate.
 * \param new_width New width.
 * \param new_height New height.
 */
template<class T>
void claw::math::rectangle<T>::set
( const value_type& new_x, const value_type& new_y,
  const value_type& new_width, const value_type& new_height )
{
  position.x = new_x;
  position.y = new_y;
  width = new_width;
  height = new_height;
} // rectangle::set()

/*----------------------------------------------------------------------------*/
/**
 * \brief Get the x-coordinate of the left edge.
 */
template<class T>
typename claw::math::rectangle<T>::value_type
claw::math::rectangle<T>::left() const
{
  return position.x;
} // rectangle::left()

/*----------------------------------------------------------------------------*/
/**
 * \brief Get the x-coordinate of the right edge.
 */
template<class T>
typename claw::math::rectangle<T>::value_type
claw::math::rectangle<T>::right() const
{
  return position.x + width;
} // rectangle::right()

/*----------------------------------------------------------------------------*/
/**
 * \brief Get the y-coordinate of the bottom edge.
 */
template<class T>
typename claw::math::rectangle<T>::value_type
claw::math::rectangle<T>::bottom() const
{
  return position.y + height;
} // rectangle::bottom()

/*----------------------------------------------------------------------------*/
/**
 * \brief Get the y-coordinate of the top edge.
 */
template<class T>
typename claw::math::rectangle<T>::value_type
claw::math::rectangle<T>::top() const
{
  return position.y;
} // rectangle::top()

/*----------------------------------------------------------------------------*/
/**
 * \brief Get the size of the rectangle.
 */
template<class T>
claw::math::coordinate_2d< typename claw::math::rectangle<T>::value_type >
claw::math::rectangle<T>::size() const
{
  return claw::math::coordinate_2d<value_type>(width, height);
} // rectangle::size()

/*----------------------------------------------------------------------------*/
/**
 * \brief X-intersection of two rectangles.
 * \pre There is an intersection between this and r.
 * \post result's x and width fields are filled.
 */
template<class T>
void claw::math::rectangle<T>::x_intersection
( const self_type& r, self_type& result ) const
{
  if (position.x <= r.position.x)
    {
      result.position.x = r.position.x;

      if (right() >= r.right())
        result.width = r.width;
      else
        result.width = right() - r.position.x;
    }
  else
    r.x_intersection(*this, result);

} // rectangle::x_intersection()

/*----------------------------------------------------------------------------*/
/**
 * \brief Y-intersection of two rectangles.
 * \pre There is an intersection between this and r.
 * \post result's y and height fields are filled.
 */
template<class T>
void claw::math::rectangle<T>::y_intersection
( const self_type& r, self_type& result ) const
{
  if (position.y <= r.position.y)
    {
      result.position.y = r.position.y;

      if (bottom() >= r.bottom())
        result.height = r.height;
      else
        result.height = bottom() - r.position.y;
    }
  else
    r.y_intersection(*this, result);

} // rectangle::y_intersection()