Skip to content

Commit b9c6857

Browse files
author
jef
committedNov 18, 2009
semi-automatic indentation update
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12177 c8812cc2-4d05-0410-92ff-de0c093fc19c

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
/**

0 commit comments

Comments
 (0)
Please sign in to comment.