Skip to content

Commit 621ee62

Browse files
author
jef
committed
semi-automatic indentation update
git-svn-id: http://svn.osgeo.org/qgis/trunk@12177 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 0d3681a commit 621ee62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+13794
-13349
lines changed

src/core/pal/costcalculator.cpp

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace pal
1919
{
2020

21-
void CostCalculator::addObstacleCostPenalty(LabelPosition* lp, PointSet* feat)
21+
void CostCalculator::addObstacleCostPenalty( LabelPosition* lp, PointSet* feat )
2222
{
2323
int n = 0;
2424
double dist;
@@ -69,7 +69,7 @@ namespace pal
6969
std::cout << "LabelPosition for feat: " << lPos[0]->feature->uid << std::endl;
7070
#endif
7171

72-
for ( i = 0;i < nblp;i++ )
72+
for ( i = 0; i < nblp; i++ )
7373
setCandidateCostFromPolygon( lPos[i], obstacles, bbx, bby );
7474

7575
// lPos with big values came fisrts (value = min distance from label to Polygon's Perimeter)
@@ -94,7 +94,7 @@ namespace pal
9494

9595
// adjust cost => the best is 0.0001, the worst is 0.0021
9696
// others are set proportionally between best and worst
97-
for ( i = 0;i < max_p;i++ )
97+
for ( i = 0; i < max_p; i++ )
9898
{
9999
#ifdef _DEBUG_
100100
std::cout << " lpos[" << i << "] = " << lPos[i]->cost;
@@ -136,7 +136,7 @@ namespace pal
136136

137137
delete extent;
138138

139-
lp->feature->getBoundingBox(amin, amax);
139+
lp->feature->getBoundingBox( amin, amax );
140140

141141
obstacles->Search( amin, amax, LabelPosition::polygonObstacleCallback, pCost );
142142

@@ -146,53 +146,53 @@ namespace pal
146146
}
147147

148148

149-
int CostCalculator::finalizeCandidatesCosts( Feats* feat, int max_p, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] )
150-
{
151-
// If candidates list is smaller than expected
152-
if ( max_p > feat->nblp )
153-
max_p = feat->nblp;
154-
//
155-
// sort candidates list, best label to worst
156-
sort(( void** ) feat->lPos, feat->nblp, LabelPosition::costGrow );
157-
158-
// try to exclude all conflitual labels (good ones have cost < 1 by pruning)
159-
double discrim = 0.0;
160-
int stop;
161-
do
162-
{
163-
discrim += 1.0;
164-
for ( stop = 0;stop < feat->nblp && feat->lPos[stop]->getCost() < discrim;stop++ );
165-
}
166-
while ( stop == 0 && discrim < feat->lPos[feat->nblp-1]->getCost() + 2.0 );
149+
int CostCalculator::finalizeCandidatesCosts( Feats* feat, int max_p, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] )
150+
{
151+
// If candidates list is smaller than expected
152+
if ( max_p > feat->nblp )
153+
max_p = feat->nblp;
154+
//
155+
// sort candidates list, best label to worst
156+
sort(( void** ) feat->lPos, feat->nblp, LabelPosition::costGrow );
157+
158+
// try to exclude all conflitual labels (good ones have cost < 1 by pruning)
159+
double discrim = 0.0;
160+
int stop;
161+
do
162+
{
163+
discrim += 1.0;
164+
for ( stop = 0; stop < feat->nblp && feat->lPos[stop]->getCost() < discrim; stop++ );
165+
}
166+
while ( stop == 0 && discrim < feat->lPos[feat->nblp-1]->getCost() + 2.0 );
167167

168-
if ( discrim > 1.5 )
169-
{
170-
int k;
171-
for ( k = 0;k < stop;k++ )
172-
feat->lPos[k]->setCost( 0.0021 );
173-
}
168+
if ( discrim > 1.5 )
169+
{
170+
int k;
171+
for ( k = 0; k < stop; k++ )
172+
feat->lPos[k]->setCost( 0.0021 );
173+
}
174174

175-
if ( max_p > stop )
176-
max_p = stop;
175+
if ( max_p > stop )
176+
max_p = stop;
177177

178178
#ifdef _DEBUG_FULL_
179-
std::cout << "Nblabel kept for feat " << feat->feature->uid << "/" << feat->feature->layer->name << ": " << max_p << "/" << feat->nblp << std::endl;
179+
std::cout << "Nblabel kept for feat " << feat->feature->uid << "/" << feat->feature->layer->name << ": " << max_p << "/" << feat->nblp << std::endl;
180180
#endif
181181

182-
// Sets costs for candidates of polygon
182+
// Sets costs for candidates of polygon
183183

184-
if ( feat->feature->getGeosType() == GEOS_POLYGON )
185-
{
186-
int arrangement = feat->feature->getLayer()->getArrangement();
187-
if ( arrangement == P_FREE || arrangement == P_HORIZ )
188-
setPolygonCandidatesCost( stop, (LabelPosition**) feat->lPos, max_p, obstacles, bbx, bby );
189-
}
184+
if ( feat->feature->getGeosType() == GEOS_POLYGON )
185+
{
186+
int arrangement = feat->feature->getLayer()->getArrangement();
187+
if ( arrangement == P_FREE || arrangement == P_HORIZ )
188+
setPolygonCandidatesCost( stop, ( LabelPosition** ) feat->lPos, max_p, obstacles, bbx, bby );
189+
}
190190

191-
// add size penalty (small lines/polygons get higher cost)
192-
feat->feature->addSizePenalty(max_p, feat->lPos, bbx, bby);
191+
// add size penalty (small lines/polygons get higher cost)
192+
feat->feature->addSizePenalty( max_p, feat->lPos, bbx, bby );
193193

194-
return max_p;
195-
}
194+
return max_p;
195+
}
196196

197197

198198

@@ -216,7 +216,7 @@ namespace pal
216216
*/
217217

218218
double alpha = lp->getAlpha();
219-
for ( i = 0;i < 8;i++, alpha += M_PI / 4 )
219+
for ( i = 0; i < 8; i++, alpha += M_PI / 4 )
220220
{
221221
dist[i] = DBL_MAX;
222222
ok[i] = false;
@@ -256,7 +256,7 @@ namespace pal
256256

257257
int i = ( int )( beta / a45 );
258258

259-
for ( int j = 0;j < 2;j++, i = ( i + 1 ) % 8 )
259+
for ( int j = 0; j < 2; j++, i = ( i + 1 ) % 8 )
260260
{
261261
double rx, ry;
262262
rx = px - rpy[i] + py;
@@ -284,11 +284,11 @@ namespace pal
284284
int nbP = ( pset->type == GEOS_POLYGON ? pset->nbPoints : pset->nbPoints - 1 );
285285
double min_dist = DBL_MAX;
286286

287-
for ( i = 0;i < nbP;i++ )
287+
for ( i = 0; i < nbP; i++ )
288288
{
289289
j = ( i + 1 ) % pset->nbPoints;
290290

291-
for ( k = 0;k < 8;k++ )
291+
for ( k = 0; k < 8; k++ )
292292
{
293293
double ix, iy;
294294
if ( computeSegIntersection( px, py, rpx[k], rpy[k], pset->x[i], pset->y[i], pset->x[j], pset->y[j], &ix, &iy ) )
@@ -318,7 +318,7 @@ namespace pal
318318
{
319319
int i;
320320

321-
for ( i = 0;i < 8;i++ )
321+
for ( i = 0; i < 8; i++ )
322322
{
323323
/*
324324
if ( i == 0 || i == 4 ) // horizontal directions

src/core/pal/costcalculator.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ namespace pal
99

1010
class CostCalculator
1111
{
12-
public:
13-
/** increase candidate's cost according to its collision with passed feature */
14-
static void addObstacleCostPenalty(LabelPosition* lp, PointSet* feat);
12+
public:
13+
/** increase candidate's cost according to its collision with passed feature */
14+
static void addObstacleCostPenalty( LabelPosition* lp, PointSet* feat );
1515

16-
static void setPolygonCandidatesCost( int nblp, LabelPosition **lPos, int max_p, RTree<PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
16+
static void setPolygonCandidatesCost( int nblp, LabelPosition **lPos, int max_p, RTree<PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
1717

18-
/** Set cost to the smallest distance between lPos's centroid and a polygon stored in geoetry field */
19-
static void setCandidateCostFromPolygon( LabelPosition* lp, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
18+
/** Set cost to the smallest distance between lPos's centroid and a polygon stored in geoetry field */
19+
static void setCandidateCostFromPolygon( LabelPosition* lp, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
2020

21-
/** sort candidates by costs, skip the worse ones, evaluate polygon candidates */
22-
static int finalizeCandidatesCosts( Feats* feat, int max_p, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
21+
/** sort candidates by costs, skip the worse ones, evaluate polygon candidates */
22+
static int finalizeCandidatesCosts( Feats* feat, int max_p, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
2323
};
2424

2525
/**

src/core/pal/feature.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace pal
8484
extractCoords( geom );
8585

8686
holeOf = NULL;
87-
for ( int i = 0;i < nbHoles;i++ )
87+
for ( int i = 0; i < nbHoles; i++ )
8888
{
8989
holes[i]->holeOf = this;
9090
}
@@ -97,7 +97,7 @@ namespace pal
9797

9898
if ( holes )
9999
{
100-
for ( int i = 0; i < nbHoles;i++ )
100+
for ( int i = 0; i < nbHoles; i++ )
101101
delete holes[i];
102102
delete [] holes;
103103
holes = NULL;
@@ -130,7 +130,7 @@ namespace pal
130130
nbHoles = GEOSGetNumInteriorRings( geom );
131131
holes = new PointSet*[nbHoles];
132132

133-
for ( i = 0;i < nbHoles;i++ )
133+
for ( i = 0; i < nbHoles; i++ )
134134
{
135135
holes[i] = new PointSet();
136136
holes[i]->holeOf = NULL;
@@ -145,7 +145,7 @@ namespace pal
145145

146146
coordSeq = GEOSGeom_getCoordSeq( interior );
147147

148-
for ( j = 0;j < holes[i]->nbPoints;j++ )
148+
for ( j = 0; j < holes[i]->nbPoints; j++ )
149149
{
150150
GEOSCoordSeq_getX( coordSeq, j, &holes[i]->x[j] );
151151
GEOSCoordSeq_getY( coordSeq, j, &holes[i]->y[j] );
@@ -182,7 +182,7 @@ namespace pal
182182
x = new double[nbPoints];
183183
y = new double[nbPoints];
184184

185-
for ( i = 0;i < nbPoints;i++ )
185+
for ( i = 0; i < nbPoints; i++ )
186186
{
187187
GEOSCoordSeq_getX( coordSeq, i, &x[i] );
188188
GEOSCoordSeq_getY( coordSeq, i, &y[i] );
@@ -202,7 +202,7 @@ namespace pal
202202
bool *ok = new bool[new_nbPoints];
203203
int i, j;
204204

205-
for ( i = 0;i < nbPoints;i++ )
205+
for ( i = 0; i < nbPoints; i++ )
206206
{
207207
ok[i] = true;
208208
j = ( i + 1 ) % nbPoints;
@@ -219,7 +219,7 @@ namespace pal
219219
{
220220
double *new_x = new double[new_nbPoints];
221221
double *new_y = new double[new_nbPoints];
222-
for ( i = 0, j = 0;i < nbPoints;i++ )
222+
for ( i = 0, j = 0; i < nbPoints; i++ )
223223
{
224224
if ( ok[i] )
225225
{
@@ -359,7 +359,7 @@ namespace pal
359359

360360
*lPos = new LabelPosition *[nbp];
361361

362-
for ( i = 0, alpha = M_PI / 4;i < nbp;i++, alpha += beta )
362+
for ( i = 0, alpha = M_PI / 4; i < nbp; i++, alpha += beta )
363363
{
364364
lx = x;
365365
ly = y;
@@ -508,7 +508,7 @@ namespace pal
508508
ad = new double[nbPoints];
509509

510510
ll = 0.0; // line length
511-
for ( i = 0;i < line->nbPoints - 1;i++ )
511+
for ( i = 0; i < line->nbPoints - 1; i++ )
512512
{
513513
if ( i == 0 )
514514
ad[i] = 0;
@@ -601,7 +601,7 @@ namespace pal
601601
if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) )
602602
positions->push_back( new LabelPosition( i, bx + cos( beta ) *distlabel , by + sin( beta ) *distlabel, xrm, yrm, alpha, cost, this ) ); // Line
603603
if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) )
604-
positions->push_back( new LabelPosition( i, bx - cos( beta ) * ( distlabel + yrm ) , by - sin( beta ) * ( distlabel + yrm ), xrm, yrm, alpha, cost, this ) ); // Line
604+
positions->push_back( new LabelPosition( i, bx - cos( beta ) *( distlabel + yrm ) , by - sin( beta ) *( distlabel + yrm ), xrm, yrm, alpha, cost, this ) ); // Line
605605
if ( flags & FLAG_ON_LINE )
606606
positions->push_back( new LabelPosition( i, bx - yrm*cos( beta ) / 2, by - yrm*sin( beta ) / 2, xrm, yrm, alpha, cost, this ) ); // Line
607607
}
@@ -1041,11 +1041,11 @@ namespace pal
10411041
int max_try = 10;
10421042
do
10431043
{
1044-
for ( bbid = 0;bbid < j;bbid++ )
1044+
for ( bbid = 0; bbid < j; bbid++ )
10451045
{
10461046
CHullBox *box = boxes[bbid];
10471047

1048-
if (( box->length * box->width ) > ( xmax - xmin ) * ( ymax - ymin ) *5 )
1048+
if (( box->length * box->width ) > ( xmax - xmin ) *( ymax - ymin ) *5 )
10491049
{
10501050
std::cout << "Very Large BBOX (should never occurs : bug-report please)" << std::endl;
10511051
std::cout << " Box size: " << box->length << "/" << box->width << std::endl;
@@ -1058,7 +1058,7 @@ namespace pal
10581058

10591059
#ifdef _DEBUG_FULL_
10601060
std::cout << "New BBox : " << bbid << std::endl;
1061-
for ( i = 0;i < 4;i++ )
1061+
for ( i = 0; i < 4; i++ )
10621062
{
10631063
std::cout << box->x[i] << "\t" << box->y[i] << std::endl;
10641064
}
@@ -1136,9 +1136,9 @@ namespace pal
11361136
px0 -= ceil( px0 / dx ) * dx;
11371137
py0 -= ceil( py0 / dy ) * dy;
11381138

1139-
for ( px = px0;px <= box->width;px += dx )
1139+
for ( px = px0; px <= box->width; px += dx )
11401140
{
1141-
for ( py = py0;py <= box->length;py += dy )
1141+
for ( py = py0; py <= box->length; py += dy )
11421142
{
11431143

11441144
rx = cos( box->alpha ) * px + cos( box->alpha - M_PI / 2 ) * py;
@@ -1170,12 +1170,12 @@ namespace pal
11701170
nbp = positions->size();
11711171

11721172
( *lPos ) = new LabelPosition*[nbp];
1173-
for ( i = 0;i < nbp;i++ )
1173+
for ( i = 0; i < nbp; i++ )
11741174
{
11751175
( *lPos )[i] = positions->pop_front();
11761176
}
11771177

1178-
for ( bbid = 0;bbid < j;bbid++ )
1178+
for ( bbid = 0; bbid < j; bbid++ )
11791179
{
11801180
delete boxes[bbid];
11811181
}
@@ -1203,13 +1203,13 @@ namespace pal
12031203
std::cout << "Type: " << type << std::endl;
12041204
if ( x && y )
12051205
{
1206-
for ( i = 0;i < nbPoints;i++ )
1206+
for ( i = 0; i < nbPoints; i++ )
12071207
std::cout << x[i] << ", " << y[i] << std::endl;
12081208
std::cout << "Obstacle: " << nbHoles << std::endl;
1209-
for ( i = 0;i < nbHoles;i++ )
1209+
for ( i = 0; i < nbHoles; i++ )
12101210
{
12111211
std::cout << " obs " << i << std::endl;
1212-
for ( j = 0;j < holes[i]->nbPoints;j++ )
1212+
for ( j = 0; j < holes[i]->nbPoints; j++ )
12131213
{
12141214
std::cout << holes[i]->x[j] << ";" << holes[i]->y[j] << std::endl;
12151215
}
@@ -1281,7 +1281,7 @@ namespace pal
12811281
int rnbp = nbp;
12821282

12831283
// purge candidates that are outside the bbox
1284-
for ( i = 0;i < nbp;i++ )
1284+
for ( i = 0; i < nbp; i++ )
12851285
{
12861286
if ( !( *lPos )[i]->isIn( bbox ) )
12871287
{
@@ -1296,7 +1296,7 @@ namespace pal
12961296

12971297
sort(( void** )( *lPos ), nbp, LabelPosition::costGrow );
12981298

1299-
for ( i = rnbp;i < nbp;i++ )
1299+
for ( i = rnbp; i < nbp; i++ )
13001300
{
13011301
delete( *lPos )[i];
13021302
}

0 commit comments

Comments
 (0)