Skip to content

Commit

Permalink
some cleanups:
Browse files Browse the repository at this point in the history
- macros TRUE/FALSE to keywords true/false
- replace boolean comparison (x==true => x / x==false => !x)
- return(x); => return x;


git-svn-id: http://svn.osgeo.org/qgis/trunk@13380 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 25, 2010
1 parent 2480fce commit b40868c
Show file tree
Hide file tree
Showing 68 changed files with 341 additions and 399 deletions.
48 changes: 24 additions & 24 deletions src/analysis/interpolation/DualEdgeTriangulation.cc
Expand Up @@ -767,7 +767,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
{continue;}

//check, if the edge belongs to a flat triangle, remove this later
if ( control2[i] == false )
if ( !control2[i] )
{
double p1, p2, p3;
if ( mHalfEdge[i]->getPoint() != -1 && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 && mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint() != -1 )
Expand All @@ -792,7 +792,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
control2[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()] = true;
}//end of the section, which has to be removed later

if ( control[i] == true )//check, if edge has already been drawn
if ( control[i] )//check, if edge has already been drawn
{continue;}

//draw the edge;
Expand Down Expand Up @@ -830,7 +830,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
{continue;}

//check, if the edge belongs to a flat triangle, remove this section later
if ( control2[i] == false )
if ( !control2[i] )
{
double p1, p2, p3;
if ( mHalfEdge[i]->getPoint() != -1 && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 && mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint() != -1 )
Expand All @@ -856,7 +856,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
}//end of the section, which has to be removed later


if ( control[i] == true )//check, if edge has already been drawn
if ( control[i] )//check, if edge has already been drawn
{continue;}

//draw the edge
Expand Down Expand Up @@ -944,7 +944,7 @@ QList<int>* DualEdgeTriangulation::getSurroundingTriangles( int pointno )
vlist->append( mHalfEdge[nextedge]->getPoint() );//add the number of the endpoint of the second edge to the value list
nextnextedge = mHalfEdge[nextedge]->getNext();
vlist->append( mHalfEdge[nextnextedge]->getPoint() );//add the number of endpoint of the third edge to the value list
if ( mHalfEdge[nextnextedge]->getBreak() == true )//add, whether the third edge is a breakline or not
if ( mHalfEdge[nextnextedge]->getBreak() )//add, whether the third edge is a breakline or not
{
vlist->append( -10 );
}
Expand Down Expand Up @@ -1606,7 +1606,7 @@ void DualEdgeTriangulation::eliminateHorizontalTriangles()

for ( int i = 0; i <= mHalfEdge.count() - 1; i++ )
{
if ( control[i] == true )//edge has already been examined
if ( control[i] )//edge has already been examined
{
continue;
}
Expand Down Expand Up @@ -1666,7 +1666,7 @@ void DualEdgeTriangulation::eliminateHorizontalTriangles()
continue;
}
}
if ( swaped == false )
if ( !swaped )
{
delete[] control;
break;
Expand All @@ -1691,7 +1691,7 @@ void DualEdgeTriangulation::ruppertRefinement()
//first, go through all the forced edges and subdivide if they are encroached by a point
bool stop = false;//flag to ensure that the for-loop is repeated until no half edge is split any more

while ( stop == false )
while ( !stop )
{
stop = true;
int nhalfedges = mHalfEdge.count();
Expand Down Expand Up @@ -1736,7 +1736,7 @@ void DualEdgeTriangulation::ruppertRefinement()
bool twoforcededges;//flag to decide, if edges should be added to the maps. Do not add them if true


if (( mHalfEdge[i]->getForced() == true || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() == true || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
if (( mHalfEdge[i]->getForced() || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
{
twoforcededges = true;
}
Expand Down Expand Up @@ -1853,7 +1853,7 @@ void DualEdgeTriangulation::ruppertRefinement()
//don't put the edges on the maps if two segments are forced or on a hull
bool twoforcededges1, twoforcededges2, twoforcededges3;//flag to indicate, if angle1, angle2 and angle3 are between forced edges or hull edges

if (( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) )
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
Expand All @@ -1862,7 +1862,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges1 = false;
}

if (( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) )
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
Expand All @@ -1871,7 +1871,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges2 = false;
}

if (( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) )
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
Expand Down Expand Up @@ -2024,7 +2024,7 @@ void DualEdgeTriangulation::ruppertRefinement()

for ( std::set<int>::iterator it = influenceedges.begin(); it != influenceedges.end(); ++it )
{
if (( mHalfEdge[*it]->getForced() == true || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
if (( mHalfEdge[*it]->getForced() || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
{
//split segment
QgsDebugMsg( "segment split" );
Expand Down Expand Up @@ -2063,7 +2063,7 @@ void DualEdgeTriangulation::ruppertRefinement()



if (( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) )
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
Expand All @@ -2072,7 +2072,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges1 = false;
}

if (( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) )
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
Expand All @@ -2081,7 +2081,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges2 = false;
}

if (( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) )
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
Expand Down Expand Up @@ -2197,7 +2197,7 @@ void DualEdgeTriangulation::ruppertRefinement()
} //end fast method


if ( encroached == true )
if ( encroached )
{
continue;
}
Expand Down Expand Up @@ -2228,7 +2228,7 @@ void DualEdgeTriangulation::ruppertRefinement()
flag = true;
}
}
if ( flag == false )
if ( !flag )
{
QgsDebugMsg( "point is not present in the triangulation" );
}
Expand Down Expand Up @@ -2279,7 +2279,7 @@ void DualEdgeTriangulation::ruppertRefinement()
//todo: put all three edges on the dontexamine list if two edges are forced or convex hull edges
bool twoforcededges1, twoforcededges2, twoforcededges3;

if (( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) )
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
Expand All @@ -2288,7 +2288,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges1 = false;
}

if (( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) )
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
Expand All @@ -2297,7 +2297,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges2 = false;
}

if (( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) )
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
Expand Down Expand Up @@ -2424,7 +2424,7 @@ void DualEdgeTriangulation::ruppertRefinement()
bool DualEdgeTriangulation::swapPossible( unsigned int edge )
{
//test, if edge belongs to a forced edge
if ( mHalfEdge[edge]->getForced() == true )
if ( mHalfEdge[edge]->getForced() )
{
return false;
}
Expand Down Expand Up @@ -2926,7 +2926,7 @@ bool DualEdgeTriangulation::saveToTAFF( QString filename ) const

for ( unsigned int i = 0; i < mHalfEdge.count(); i++ )
{
if ( cont[i] == true )
if ( cont[i] )
{
continue;
}
Expand Down Expand Up @@ -3276,7 +3276,7 @@ void DualEdgeTriangulation::evaluateInfluenceRegion( Point3D* point, int edge, s
return;
}

if ( mHalfEdge[edge]->getForced() == false && !edgeOnConvexHull( edge ) )
if ( !mHalfEdge[edge]->getForced() && !edgeOnConvexHull( edge ) )
{
//test, if point is in the circle through both endpoints of edge and the endpoint of edge->dual->next->point
if ( MathUtils::inCircle( point, mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()], mPointVector[mHalfEdge[edge]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()] ) )
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/interpolation/MathUtils.cc
Expand Up @@ -102,7 +102,7 @@ double MathUtils::calcBernsteinPoly( int n, int i, double t )
return 0;
}

return( lower( n, i )*power( t, i )*power(( 1 - t ), ( n - i ) ) );
return lower( n, i )*power( t, i )*power(( 1 - t ), ( n - i ) );
}

double MathUtils::cFDerBernsteinPoly( int n, int i, double t )
Expand Down Expand Up @@ -265,7 +265,7 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
aValue = aValue - (( bx * bx + by * by ) * triArea( p1, p3, testp ) );
aValue = aValue + (( cx * cx + cy * cy ) * triArea( p1, p2, testp ) );
aValue = aValue - (( px * px + py * py ) * triArea( p1, p2, p3 ) );
//return(aValue>0.0);
//return aValue>0.0;
if ( aValue > tolerance )
{
return true;
Expand All @@ -277,7 +277,7 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
else//point is approximately on the circle
{
//cout << "aValue " << aValue << endl << flush;
//return(aValue>0.0);
//return aValue>0.0;
return false;
}
}
Expand Down Expand Up @@ -324,7 +324,7 @@ double MathUtils::leftOf( Point3D* thepoint, Point3D* p1, Point3D* p2 )
double f3 = thepoint->getY() - p1->getY();
double f4 = p2->getX() - p1->getX();
return f1*f2 - f3*f4;
//return(thepoint->getX()-p1->getX())*(p2->getY()-p1->getY())-(thepoint->getY()-p1->getY())*(p2->getX()-p1->getX());//calculating the vectorproduct
//return thepoint->getX()-p1->getX())*(p2->getY()-p1->getY())-(thepoint->getY()-p1->getY())*(p2->getX()-p1->getX();//calculating the vectorproduct
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions src/analysis/interpolation/NormVecDecorator.cc
Expand Up @@ -82,7 +82,7 @@ int NormVecDecorator::addPoint( Point3D* p )

bool NormVecDecorator::calcNormal( double x, double y, Vector3D* result )
{
if ( alreadyestimated == false )
if ( !alreadyestimated )
{
estimateFirstDerivatives();
alreadyestimated = true;
Expand All @@ -102,7 +102,7 @@ bool NormVecDecorator::calcNormal( double x, double y, Vector3D* result )

bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector3D* result )
{
if ( alreadyestimated == false )
if ( !alreadyestimated )
{
estimateFirstDerivatives();
alreadyestimated = true;
Expand Down Expand Up @@ -186,9 +186,9 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
lfirstbp = p3;
}

if ( p2 == ffirstbp && p3 == lfirstbp && firstrun == false )//we are back at the first breakline
if ( p2 == ffirstbp && p3 == lfirstbp && !firstrun )//we are back at the first breakline
{
if ( pointfound == false )//the point with coordinates x, y was in no triangle
if ( !pointfound )//the point with coordinates x, y was in no triangle
{
QgsDebugMsg( "warning: point (x,y) was in no triangle" );
return false;
Expand All @@ -197,7 +197,7 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
break;
}

if ( numberofbreaks > 0 && pointfound == true )//we found the second break line and the point is between the first and the second
if ( numberofbreaks > 0 && pointfound )//we found the second break line and the point is between the first and the second
{
result->standardise();
numberofbreaks++;//to make the distinction between endpoints and points on a breakline easier
Expand Down Expand Up @@ -234,7 +234,7 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
bool NormVecDecorator::calcPoint( double x, double y, Point3D* result )
{

if ( alreadyestimated == false )
if ( !alreadyestimated )
{
estimateFirstDerivatives();
alreadyestimated = true;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsninecellfilter.cpp
Expand Up @@ -220,7 +220,7 @@ GDALDriverH QgsNineCellFilter::openOutputDriver()
}

driverMetadata = GDALGetMetadata( outputDriver, NULL );
if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, FALSE ) )
if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
{
return NULL; //driver exist, but it does not support the create operation
}
Expand Down
14 changes: 3 additions & 11 deletions src/app/composer/qgscomposerpicturewidget.cpp
Expand Up @@ -447,7 +447,7 @@ void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
{
continue;
}

//add directory itself
mSearchDirectoriesComboBox->addItem( svgDirectory.absolutePath() );
addDirectoryToPreview( svgDirectory.absolutePath() );
Expand Down Expand Up @@ -475,19 +475,11 @@ bool QgsComposerPictureWidget::testSvgFile( const QString& filename ) const
}

QSvgRenderer svgRenderer( filename );
if ( svgRenderer.isValid() )
{
return true;
}
return false;
return svgRenderer.isValid();
}

bool QgsComposerPictureWidget::testImageFile( const QString& filename ) const
{
QString formatName = QString( QImageReader::imageFormat( filename ) );
if ( !formatName.isEmpty() )
{
return true; //file is in a supported pixel format
}
return false;
return !formatName.isEmpty(); //file is in a supported pixel format
}

0 comments on commit b40868c

Please sign in to comment.