diff --git a/Applications/DataExplorer/Base/OGSError.cpp b/Applications/DataExplorer/Base/OGSError.cpp index 8c2321f0c75df2efebf1f3309189142325a9a8cf..5f7a35e389ec2668001c4a8eb85ff11e07ed1ed2 100644 --- a/Applications/DataExplorer/Base/OGSError.cpp +++ b/Applications/DataExplorer/Base/OGSError.cpp @@ -41,8 +41,6 @@ bool OGSError::question(const QString &e, const QString &t) msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); - if (msgBox.exec() == QMessageBox::Ok) - return true; - return false; + return msgBox.exec() == QMessageBox::Ok; } diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp index 9619ef66f795ebcf51203700d526a454c69794b0..3aaaa8278cc0c0066e4e18fda19e026dcd3caffe 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp @@ -86,9 +86,8 @@ int VtkStationSource::RequestData( vtkInformation* request, break; } - bool isBorehole = - (static_cast<GeoLib::Station*>((*_stations)[0])->type() == - GeoLib::Station::StationType::BOREHOLE) ? true : false; + bool isBorehole = static_cast<GeoLib::Station*>((*_stations)[0])->type() == + GeoLib::Station::StationType::BOREHOLE; vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); vtkSmartPointer<vtkPolyData> output = diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index 7a7da444a98406f88437f415d1cd5e2859cf0a61..249dcc750469ed2870d66a4f128203cb13a52062 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -107,7 +107,7 @@ std::size_t TetGenInterface::getNFacets(std::ifstream &input) auto it = fields.begin(); const auto nFacets(BaseLib::str2number<std::size_t>(*it)); if (fields.size() > 1) - _boundary_markers = (BaseLib::str2number<std::size_t> (*(++it)) == 0) ? false : true; + _boundary_markers = BaseLib::str2number<std::size_t>(*(++it)) != 0; return nFacets; } return 0; @@ -293,7 +293,7 @@ bool TetGenInterface::parseNodesFileHeader(std::string &line, } n_attributes = BaseLib::str2number<std::size_t> (*(++it)); - boundary_markers = (*(++it) == "1") ? true : false; + boundary_markers = *(++it) == "1"; return true; } @@ -416,10 +416,7 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, pos_end = line.find_first_of(" \t\n", pos_beg); if (pos_end == std::string::npos) pos_end = line.size(); - if ((line.substr(pos_beg, pos_end - pos_beg)) == "1") - region_attribute = true; - else - region_attribute = false; + region_attribute = (line.substr(pos_beg, pos_end - pos_beg)) == "1"; return true; } diff --git a/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp b/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp index 78fdfbfc6e43a7b3ab7490f7cffa57e2b58a9a2a..2bb2ae9c878823a0f45dce82087840bda2b96327 100644 --- a/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp +++ b/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp @@ -214,14 +214,14 @@ int main (int argc, char* argv[]) fname += ".gml"; INFO("Writing to %s.", fname.c_str()); - convertPoints (dbf_handle, - fname, - x_id, - y_id, - z_id, - name_component_ids, - fname_base, - station == 0 ? true : false); + convertPoints(dbf_handle, + fname, + x_id, + y_id, + z_id, + name_component_ids, + fname_base, + station == 0); DBFClose (dbf_handle); INFO("\tok."); } else { diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 5c3d96996f1a6be46da2ad2db5010bfa6a70a61f..eea3e423d7563efb4c94899b4c234bd82b1a0b90 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -135,10 +135,7 @@ bool lineSegmentIntersect(GeoLib::LineSegment const& s0, std::size_t i) { // check if p is located at v=(a,b): (ap = t*v, t in [0,1]) - if (0.0 <= ap[i] / v[i] && ap[i] / v[i] <= 1.0) { - return true; - } - return false; + return 0.0 <= ap[i] / v[i] && ap[i] / v[i] <= 1.0; }; if (parallel(v,w)) { // original line segments (a,b) and (c,d) are parallel @@ -403,8 +400,7 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( auto isPointOnSegment = [](double q, double p0, double p1) { double const t((q - p0) / (p1 - p0)); - if (0 <= t && t <= 1) return true; - return false; + return 0 <= t && t <= 1; }; // check if c in (ab) diff --git a/GeoLib/IO/Legacy/OGSIOVer4.cpp b/GeoLib/IO/Legacy/OGSIOVer4.cpp index 4ce311cf2e12916d13c659dbe35d4eca431590fd..c845d6b11203e54cdbfeb8e43308c8f8e34cc27f 100644 --- a/GeoLib/IO/Legacy/OGSIOVer4.cpp +++ b/GeoLib/IO/Legacy/OGSIOVer4.cpp @@ -70,10 +70,7 @@ std::string readPoints(std::istream &in, std::vector<GeoLib::Point*>* pnt_vec, { if (cnt == 0) { - if (id == 0) - zero_based_indexing = true; - else - zero_based_indexing = false; + zero_based_indexing = id == 0; } pnt_vec->push_back(new GeoLib::Point(x, y, z, id)); @@ -519,10 +516,7 @@ bool readGLIFileV4(const std::string& fname, std::move(sfc_vec), unique_name, std::move(sfc_names)); // KR: insert into GEOObjects if not empty - if (errors.empty()) - return true; - - return false; + return errors.empty(); } std::size_t writeTINSurfaces(std::ofstream &os, GeoLib::SurfaceVec const* sfcs_vec, std::size_t sfc_count, std::string const& path) diff --git a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp index 07d82ce8fc11679263662c7ca8b10106b936ce0a..d6fd8122ec3f129ade02aaea9c7bbb942b800901 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp @@ -211,9 +211,8 @@ bool XmlStnInterface::write() root.setAttribute( "xsi:noNamespaceSchemaLocation", "http://www.opengeosys.org/images/xsd/OpenGeoSysSTN.xsd" ); const std::vector<GeoLib::Point*>* stations (_geo_objs.getStationVec(_exportName)); - bool isBorehole = - (static_cast<GeoLib::Station*>((*stations)[0])->type() == - GeoLib::Station::StationType::BOREHOLE) ? true : false; + bool isBorehole = static_cast<GeoLib::Station*>((*stations)[0])->type() == + GeoLib::Station::StationType::BOREHOLE; doc.appendChild(root); QDomElement stationListTag = doc.createElement("stationlist"); diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index 52b3d770bcff0ed3020f1983e625915a616afdd3..44449d4287855f32febda22a94c1045647193123 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -183,9 +183,9 @@ bool Polygon::containsSegment(GeoLib::LineSegment const& segment) const if (!isPntInPolygon(GeoLib::Point(0.5*(s[k][0]+s[k+1][0]), 0.5*(s[k][1]+s[k+1][1]), 0.5*(s[k][2]+s[k+1][2])))) return false; } - if (!isPntInPolygon(GeoLib::Point(0.5*(s[0][0]+b[0]), 0.5*(s[0][1]+b[1]), 0.5*(s[0][2]+b[2])))) - return false; - return true; + return isPntInPolygon(GeoLib::Point(0.5 * (s[0][0] + b[0]), + 0.5 * (s[0][1] + b[1]), + 0.5 * (s[0][2] + b[2]))); } bool Polygon::isPolylineInPolygon(const Polyline& ply) const diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index 0b0beb9e476b80929d0f6c4c0f61571d47e06c89..4f6eb04798c3e81b3aec0799d210824981c7bcb6 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -192,10 +192,7 @@ bool Polyline::isClosed() const if (_ply_pnt_ids.size() < 3) return false; - if (_ply_pnt_ids.front() == _ply_pnt_ids.back()) - return true; - - return false; + return _ply_pnt_ids.front() == _ply_pnt_ids.back(); } bool Polyline::isCoplanar() const diff --git a/GeoLib/Raster.cpp b/GeoLib/Raster.cpp index 8c2b5e8624608b4d13b9e83019422b8967be10ed..625d37dd808a027850a6b098c8dd3c26576168bd 100644 --- a/GeoLib/Raster.cpp +++ b/GeoLib/Raster.cpp @@ -175,10 +175,11 @@ double Raster::interpolateValueAtPoint(MathLib::Point3d const& pnt) const bool Raster::isPntOnRaster(MathLib::Point3d const& pnt) const { - if ((pnt[0]<_header.origin[0]) || (pnt[0]>_header.origin[0]+(_header.n_cols*_header.cell_size)) || - (pnt[1]<_header.origin[1]) || (pnt[1]>_header.origin[1]+(_header.n_rows*_header.cell_size))) - return false; - return true; + return !( + (pnt[0] < _header.origin[0]) || + (pnt[0] > _header.origin[0] + (_header.n_cols * _header.cell_size)) || + (pnt[1] < _header.origin[1]) || + (pnt[1] > _header.origin[1] + (_header.n_rows * _header.cell_size))); } } // end namespace GeoLib diff --git a/GeoLib/Triangle.cpp b/GeoLib/Triangle.cpp index 73294479d5b64c433a284445ea14684a2cd83ab5..1b6ec36420ee5d865b6c49c49ac89a6939bb6752 100644 --- a/GeoLib/Triangle.cpp +++ b/GeoLib/Triangle.cpp @@ -63,12 +63,8 @@ bool Triangle::containsPoint2D (Point const& pnt) const const double upper (1+delta); // check if u0 and u1 fulfills the condition (with some delta) - if (-delta <= y[0] && y[0] <= upper && -delta <= y[1] && y[1] <= upper && - y[0] + y[1] <= upper) - { - return true; - } - return false; + return -delta <= y[0] && y[0] <= upper && -delta <= y[1] && y[1] <= upper && + y[0] + y[1] <= upper; } void getPlaneCoefficients(Triangle const& tri, double c[3]) diff --git a/MathLib/GeometricBasics.cpp b/MathLib/GeometricBasics.cpp index 55c6be7083214cf18bf53b9bb20c24f2436e98f8..a80e22aaccc87004563c606fae227ed1a81ca5f1 100644 --- a/MathLib/GeometricBasics.cpp +++ b/MathLib/GeometricBasics.cpp @@ -73,9 +73,7 @@ bool isPointInTetrahedron(MathLib::Point3d const& p, MathLib::Point3d const& a, return false; // if p is on the same side of abc as d double const d4 (MathLib::orientation3d(p, a, b, c)); - if (!(d0_sign == (d4>=0) || std::abs(d4) < eps)) - return false; - return true; + return d0_sign == (d4 >= 0) || std::abs(d4) < eps; } return false; } @@ -164,9 +162,7 @@ bool barycentricPointInTriangle(MathLib::Point3d const& p, if (beta < -eps_pnt_out_of_tri || beta > 1 + eps_pnt_out_of_tri) return false; double const gamma(1 - alpha - beta); - if (gamma < -eps_pnt_out_of_tri || gamma > 1 + eps_pnt_out_of_tri) - return false; - return true; + return !(gamma < -eps_pnt_out_of_tri || gamma > 1 + eps_pnt_out_of_tri); } bool isPointInTriangleXY(MathLib::Point3d const& p, @@ -186,12 +182,7 @@ bool isPointInTriangleXY(MathLib::Point3d const& p, gauss.solve(mat, y, true); // check if u0 and u1 fulfills the condition - if (0 <= y[0] && y[0] <= 1 && 0 <= y[1] && y[1] <= 1 && y[0] + y[1] <= 1) - { - return true; - } - return false; - + return 0 <= y[0] && y[0] <= 1 && 0 <= y[1] && y[1] <= 1 && y[0] + y[1] <= 1; } bool dividedByPlane(const MathLib::Point3d& a, const MathLib::Point3d& b, diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp index cf8a1aa399718fc71caf506910c6409dc7b70eb3..a646656dfd541db45d46c4ec72a0ec56cbe05367 100644 --- a/MeshLib/Properties.cpp +++ b/MeshLib/Properties.cpp @@ -32,11 +32,7 @@ void Properties::removePropertyVector(std::string const& name) bool Properties::hasPropertyVector(std::string const& name) const { - auto it(_properties.find(name)); - if (it == _properties.end()) { - return false; - } - return true; + return _properties.find(name) != _properties.end(); } std::vector<std::string> Properties::getPropertyVectorNames() const diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp index ab6de3302ca0c853d78ebf4e029102c10a223f52..29600a819952605a9669b730bef056398eaa357e 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp @@ -68,7 +68,7 @@ void ConvergenceCriterionPerComponentResidual::checkResidual( bool satisfied_abs = true; // Make sure that in the first iteration the relative residual tolerance is // not satisfied. - bool satisfied_rel = _is_first_iteration ? false : true; + bool satisfied_rel = !_is_first_iteration; for (unsigned global_component = 0; global_component < _abstols.size(); ++global_component) diff --git a/Tests/GeoLib/TestLineSegmentIntersect2d.cpp b/Tests/GeoLib/TestLineSegmentIntersect2d.cpp index 285a476f394fc0268ca1e9bdedb5a206a5bc79b3..b04db18c06d2ca289431863c24eb576936dddc35 100644 --- a/Tests/GeoLib/TestLineSegmentIntersect2d.cpp +++ b/Tests/GeoLib/TestLineSegmentIntersect2d.cpp @@ -72,10 +72,7 @@ TEST_F(LineSegmentIntersect2dTest, RandomSegmentOrientationIntersecting) {(s0.getBeginPoint()[0] + s0.getEndPoint()[0]) / 2, (s0.getBeginPoint()[1] + s0.getEndPoint()[1]) / 2, 0.0}}}; const double sqr_dist(MathLib::sqrDist(ipnts[0], center)); - if (sqr_dist < std::numeric_limits<double>::epsilon()) - return true; - - return false; + return sqr_dist < std::numeric_limits<double>::epsilon(); } return ipnts.size() == 2; };