This file is indexed.

/usr/include/tulip/cxx/Circle.cxx is in libtulip-dev 3.1.2-2.3ubuntu3.

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
//-*-c++-*-
/**
 Authors: David Auber, Patrick Mary, Morgan Mathiaut
 from the LaBRI Visualization Team
 Email : auber@tulip-software.org
 Last modification : 13/03/2009 
 This program 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.
*/
#include <stdlib.h>

template<typename Obj>
tlp::Circle<Obj> & tlp::Circle<Obj>::merge(const tlp::Circle<Obj> &c) {
  Vector<Obj,2> p1(*this);
  Vector<Obj,2> p2(c);
  Vector<Obj,2> c12=p2-p1;
  double norm=c12.norm();
  if (norm < 0.0000001) {
    if (radius<c.radius)
      return (*this)=c;
    else
      return *this;
  }
  double dx=c12[0]/norm;
  double dy=c12[1]/norm;
  p1[0]-=dx*radius;
  p1[1]-=dy*radius;
  p2[0]+=dx*c.radius;
  p2[1]+=dy*c.radius;
  Obj tmpDist=p1.dist(p2)/2.;
  if ( (tmpDist<radius) || (tmpDist<c.radius)) {
    if (radius>c.radius) 
      return *this; 
    else
      return (*this)=c; 
  }
  else {
    p1+=p2;
    p1/=2.;
    (*this)[0]=p1[0];
    (*this)[1]=p1[1];
    radius=tmpDist;
    return *this;
  }
}

template<typename Obj>
bool tlp::Circle<Obj>::isIncludeIn(const tlp::Circle<Obj> &c) const {
  Vector<Obj,2> dir=c-*this;
  return (dir.norm()+radius)<=c.radius;
}

template<typename Obj>
tlp::Circle<Obj> tlp::enclosingCircle(const tlp::Circle<Obj> &c1,const tlp::Circle<Obj> &c2) {
  Vector<Obj,2> dir=c2-c1;
  Obj n=dir.norm();
  if (n==0)
    return Circle<Obj>(c1, std::max(c1.radius,  c2.radius));
  dir/=n;
  Vector<Obj,2> ext1=c1-dir*c1.radius;
  Vector<Obj,2> ext2=c2+dir*c2.radius;
  return Circle<Obj>((ext1+ext2)/Obj(2),(ext2-ext1).norm()/Obj(2));
}

template<typename Obj>
tlp::Circle<Obj> tlp::lazyEnclosingCircle(const std::vector<tlp::Circle<Obj> > & circles) {
  //compute bounding box of a
  tlp::Vector<Obj,4> boundingBox;
  //  for (int i=0;i<4;++i) boundingBox[i]=0;
  typename std::vector< tlp::Circle<Obj> >::const_iterator it=circles.begin();
  boundingBox[0]=(*it)[0]-(*it).radius;
  boundingBox[1]=(*it)[1]-(*it).radius;
  boundingBox[2]=(*it)[0]+(*it).radius;
  boundingBox[3]=(*it)[1]+(*it).radius;
  ++it;
  for (;it!=circles.end();++it) {
    boundingBox[0] = std::min(boundingBox[0] , ((*it)[0]-(*it).radius));
    boundingBox[1] = std::min(boundingBox[1] , ((*it)[1]-(*it).radius));
    boundingBox[2] = std::max(boundingBox[2] , ((*it)[0]+(*it).radius));
    boundingBox[3] = std::max(boundingBox[3] , ((*it)[1]+(*it).radius));
  }

  tlp::Vector<Obj,2> center;
  center[0]=(boundingBox[0]+boundingBox[2])/2.;
  center[1]=(boundingBox[1]+boundingBox[3])/2.;
  Obj radius = std::max( (boundingBox[2]-boundingBox[0])/2., (boundingBox[3]-boundingBox[1])/2. );
  tlp::Circle<Obj> result(center,radius);
  //compute circle hull
  for (typename std::vector< tlp::Circle<Obj> >::const_iterator it=circles.begin();it!=circles.end();++it) 
    result.merge(*it);
 
  return result;
}

template<typename Obj>
tlp::Circle<Obj> tlp::enclosingCircle(const std::vector<tlp::Circle<Obj> > & circles) {
  class OptimumCircleHull {
    const std::vector<tlp::Circle<Obj> > *circles;
    std::vector<unsigned> enclosedCircles;
    unsigned first,last;
    unsigned b1,b2;
    tlp::Circle<Obj> result;
    
    static tlp::Circle<Obj> enclosingCircle(const tlp::Circle<Obj> &c1,const tlp::Circle<Obj> &c2,const tlp::Circle<Obj> &c3) {
      Obj a1 = c1[0];
      Obj b1 = c1[1];
      Obj r1 = c1.radius;
      Obj a2 = c2[0];
      Obj b2 = c2[1];
      Obj r2 = c2.radius;
      Obj a3 = c3[0];
      Obj b3 = c3[1];
      Obj r3 = c3.radius;
      Obj b = -b1*r2*a1*a1*b3+a3*a3*r2*r2*r2+b2*b2*r3*r3*r3+b1*b1*r3*r3*r3+b1*b1*r2*r2*r2+r1*r1*r1*b3*b3+r1*r1*r1*b2*b2+r2*r2*r2*b3*b3
	+a1*a1*r3*r3*r3+a2*a2*r1*r1*r1+a2*a2*r3*r3*r3+a1*a1*r2*r2*r2+a3*a3*r1*r1*r1-b2*b2*r3*a3*a3-b2*b2*r3*b3*b3-2*b2*r3*r3*r3*b1
	-b1*b1*r3*a3*a3-b1*b1*r3*b3*b3-b1*b1*r2*a2*a2+2*b1*b1*r2*b3*b3-b1*b1*r2*r3*r3-r1*b3*b3*b3*b2+r1*b3*b3*b3*b1
	+2*r1*b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a2*r3*r3-a1*a2*a2-a1*b2*b2-a3*a1*a1)/(a2*b3+a3*b1-a2*b1-a1*b3+a1*b2-a3*b2);
      Obj x = 0.5*(-a1*a1*b3+a1*a1*b2+2*R*r2*b3+b1*a3*a3+b1*b3*b3+2*b1*R*r3-2*R*r1*b3+2*R*r1*b2+b1*r2*r2
		      -b2*a3*a3-b2*b3*b3+b2*r3*r3-2*b2*R*r3-b1*r3*r3-r2*r2*b3+a2*a2*b3-r1*r1*b2-b1*b2*b2+b1*b1*b2-b1*b1*b3
		      -b1*a2*a2+b2*b2*b3+r1*r1*b3-2*b1*R*r2)/(a2*b3+a3*b1-a2*b1-a1*b3+a1*b2-a3*b2);
      return  tlp::Circle<Obj>(x,y,R);
    }

    void process2() {
      if (isEmpty()) {
	result=tlp::enclosingCircle((*circles)[b1],(*circles)[b2]);
      } else {
	unsigned selectedCircle=popBack();
	process2();
	if (!(*circles)[selectedCircle].isIncludeIn(result)) {
	  result=enclosingCircle((*circles)[b1],(*circles)[b2],(*circles)[selectedCircle]);
	  pushFront(selectedCircle);
	} else {
	  pushBack(selectedCircle);
	}
      }
    }
    
    void process1() {
      if (isEmpty()) {
	result=(*circles)[b1];
      } else {
	unsigned selectedCircle=popBack();
	process1();
	if (!(*circles)[selectedCircle].isIncludeIn(result)) {
	  b2=selectedCircle;
	  process2();
	  pushFront(selectedCircle);
	} else {
	  pushBack(selectedCircle);
	}
      }
    }
    void process0() {
      if (isEmpty()) {
	result=Circle<Obj>(0,0,0);
      } else {
	unsigned selectedCircle=popBack();
	process0();
	if (!(*circles)[selectedCircle].isIncludeIn(result)) {
	  b1=selectedCircle;
	  process1();
	  pushFront(selectedCircle);
	} else {
	  pushBack(selectedCircle);
	}
      }
    }
    bool isEmpty() const {
      return first==(last+1)%enclosedCircles.size();
    }
    void pushFront(unsigned c) {
      first=(first+enclosedCircles.size()-1)%enclosedCircles.size();
      enclosedCircles[first]=c;
    }
    unsigned popBack() {
      unsigned result=enclosedCircles[last];
      last=(last+enclosedCircles.size()-1)%enclosedCircles.size();
      return result;
    }
    void pushBack(unsigned c) {
      last=(last+1)%enclosedCircles.size();
      enclosedCircles[last]=c;
    }
  public:
    tlp::Circle<Obj> operator()(const std::vector<tlp::Circle<Obj> > &circlesSet) {
      circles=&circlesSet;
      enclosedCircles.resize(circlesSet.size()+1);
      first=0;
      last=circlesSet.size()-1;
      for (unsigned i=0;i<circlesSet.size();++i) 
	enclosedCircles[i]=i;
      for (unsigned i=circlesSet.size();i>0;) {
	unsigned idx=(unsigned)(1.0*rand()*i/RAND_MAX);
	--i;
	std::swap(enclosedCircles[idx],enclosedCircles[i]);
      }
      process0();
      return result;
    }
  };
  return OptimumCircleHull()(circles);
}

template <typename Obj>
std::ostream& tlp::operator<<(std::ostream &os,const tlp::Circle<Obj> &a) {
  os << "((" << a[0] << "," <<  a[1] << ")," << a.radius << ")";
  return os;
}