From cf9fa39db43f24390856d1ba444854996fa89710 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Thu, 18 Jun 2015 09:41:04 +0200 Subject: [PATCH] [GL] NULL -> nullptr. --- GeoLib/AnalyticalGeometry.cpp | 2 +- GeoLib/AnalyticalGeometry.h | 2 +- GeoLib/GEOObjects.h | 6 ++-- GeoLib/Grid.h | 16 +++++----- GeoLib/MinimalBoundingSphere.cpp | 2 +- GeoLib/Polyline.cpp | 2 +- GeoLib/QuadTree.h | 54 ++++++++++++++++---------------- GeoLib/SensorData.cpp | 2 +- GeoLib/Station.cpp | 18 ++++++----- GeoLib/StationBorehole.cpp | 14 ++++----- GeoLib/Surface.cpp | 2 +- 11 files changed, 61 insertions(+), 59 deletions(-) diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 33ba8391632..7f434c398d2 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -372,7 +372,7 @@ void computeRotationMatrixToXZ(MathLib::Vector3 const& plane_normal, MathLib::De void rotatePoints(MathLib::DenseMatrix<double> const& rot_mat, std::vector<GeoLib::Point*> &pnts) { - double* tmp (NULL); + double* tmp (nullptr); const std::size_t n_pnts(pnts.size()); for (std::size_t k(0); k < n_pnts; k++) { tmp = rot_mat * pnts[k]->getCoords(); diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index 8faa7059387..5a35a98f098 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -258,7 +258,7 @@ bool lineSegmentIntersect (const GeoLib::Point& a, const GeoLib::Point& b, /** * Calculates the intersection points of a line PQ and a triangle ABC. * This method requires ABC to be counterclockwise and PQ to point downward. - * @return Intersection point or NULL if there is no intersection. + * @return Intersection point or nullptr if there is no intersection. */ GeoLib::Point* triangleLineIntersection(MathLib::Point3d const& a, MathLib::Point3d const& b, MathLib::Point3d const& c, MathLib::Point3d const& p, MathLib::Point3d const& q); diff --git a/GeoLib/GEOObjects.h b/GeoLib/GEOObjects.h index 993a9705a5f..fc1b13a67e8 100644 --- a/GeoLib/GEOObjects.h +++ b/GeoLib/GEOObjects.h @@ -71,7 +71,7 @@ public: */ virtual void addPointVec(std::vector<Point*>* points, std::string &name, - std::map<std::string, std::size_t>* pnt_names = NULL, + std::map<std::string, std::size_t>* pnt_names = nullptr, double eps = sqrt(std::numeric_limits<double>::epsilon())); /** @@ -119,7 +119,7 @@ public: */ virtual void addPolylineVec(std::vector<Polyline*>* lines, const std::string &name, - std::map<std::string,std::size_t>* ply_names = NULL); + std::map<std::string,std::size_t>* ply_names = nullptr); /** copies the pointers to the polylines in the vector to the PolylineVec with provided name. * the pointers are managed by the GEOObjects, i.e. GEOObjects will delete the Polylines at the @@ -161,7 +161,7 @@ public: /** Adds a vector of surfaces with the given name to GEOObjects. */ virtual void addSurfaceVec(std::vector<Surface*>* surfaces, const std::string &name, - std::map<std::string, std::size_t>* sfc_names = NULL); + std::map<std::string, std::size_t>* sfc_names = nullptr); /** * Copies the surfaces in the vector to the SurfaceVec with the given name. diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h index fade0d7de46..ed9f2a2e548 100644 --- a/GeoLib/Grid.h +++ b/GeoLib/Grid.h @@ -125,11 +125,11 @@ public: * distance. A pointer to this object is returned. * * If there is not such a point, i.e., all the searched grid cells do not contain any - * POINT object a NULL pointer is returned. + * POINT object a nullptr pointer is returned. * * @param pnt a field that holds the coordinates of the point * @return a pointer to the point with the smallest distance within the grid cells that are - * outlined above or NULL + * outlined above or nullptr */ POINT* getNearestPoint(POINT const& pnt) const { @@ -137,7 +137,7 @@ public: getGridCoords(pnt, coords); double sqr_min_dist (MathLib::sqrDist(this->_min_pnt, this->_max_pnt)); - POINT* nearest_pnt(NULL); + POINT* nearest_pnt(nullptr); double dists[6]; getPointCellBorderDistances(pnt, dists, coords); @@ -155,10 +155,10 @@ public: } else { // search in all border cells for at least one neighbor double sqr_min_dist_tmp; - POINT * nearest_pnt_tmp(NULL); + POINT * nearest_pnt_tmp(nullptr); std::size_t offset(1); - while (nearest_pnt == NULL) { + while (nearest_pnt == nullptr) { std::size_t tmp_coords[3]; if (coords[0] < offset) { tmp_coords[0] = 0; @@ -478,7 +478,7 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const points->push_back(new GeoLib::Point(llf[0]+i*dx, llf[1]+(j+1)*dy, llf[2]+(k+1)*dz)); points->push_back(new GeoLib::Point(llf[0]+(i+1)*dx, llf[1]+(j+1)*dy, llf[2]+(k+1)*dz)); points->push_back(new GeoLib::Point(llf[0]+(i+1)*dx, llf[1]+j*dy, llf[2]+(k+1)*dz)); - geo_obj->addPointVec(points, grid_names[grid_names.size()-1], NULL); + geo_obj->addPointVec(points, grid_names[grid_names.size()-1], nullptr); std::vector<GeoLib::Polyline*>* plys ( new std::vector<GeoLib::Polyline*>); @@ -514,8 +514,8 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const ply5->addPoint(7); plys->push_back(ply5); - geo_obj->addPolylineVec(plys, - grid_names[grid_names.size() - 1], NULL); + geo_obj->addPolylineVec(plys, grid_names[grid_names.size() - 1], + nullptr); } } } diff --git a/GeoLib/MinimalBoundingSphere.cpp b/GeoLib/MinimalBoundingSphere.cpp index da7758fbafd..881454f2a71 100644 --- a/GeoLib/MinimalBoundingSphere.cpp +++ b/GeoLib/MinimalBoundingSphere.cpp @@ -188,7 +188,7 @@ std::vector<MathLib::Point3d*>* MinimalBoundingSphere::getRandomSpherePoints(std { std::vector<MathLib::Point3d*> *pnts = new std::vector<MathLib::Point3d*>; pnts->reserve(n_points); - srand ( static_cast<unsigned>(time(NULL)) ); + srand ( static_cast<unsigned>(time(nullptr)) ); for (std::size_t k(0); k<n_points; ++k) { diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index 8fa1bd522e0..6561ea3c44e 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -332,7 +332,7 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & if (!ply_found) { ERR("Error in Polyline::contructPolylineFromSegments() - Not all segments are connected."); - new_ply = NULL; + new_ply = nullptr; break; } } diff --git a/GeoLib/QuadTree.h b/GeoLib/QuadTree.h index 15eaab984d3..9099588ac70 100644 --- a/GeoLib/QuadTree.h +++ b/GeoLib/QuadTree.h @@ -49,14 +49,14 @@ public: * @param ur upper right point of the square */ QuadTree(POINT const& ll, POINT const& ur, std::size_t max_points_per_node) : - _father (NULL), _ll (ll), _ur (ur), _depth (0), _is_leaf (true), + _father (nullptr), _ll (ll), _ur (ur), _depth (0), _is_leaf (true), _max_points_per_node (max_points_per_node) { assert (_max_points_per_node > 0); // init childs for (std::size_t k(0); k < 4; k++) - _childs[k] = NULL; + _childs[k] = nullptr; if ((_ur[0] - _ll[0]) > (_ur[1] - _ll[1])) _ur[1] = _ll[1] + _ur[0] - _ll[0]; @@ -141,28 +141,28 @@ public: // check if north neighbor has to be refined QuadTree<POINT>* north_neighbor (node->getNorthNeighbor()); - if (north_neighbor != NULL) + if (north_neighbor != nullptr) if (north_neighbor->getDepth() < node->getDepth ()) if (north_neighbor->isLeaf()) leaf_list.push_back (north_neighbor); // check if west neighbor has to be refined QuadTree<POINT>* west_neighbor (node->getWestNeighbor()); - if (west_neighbor != NULL) + if (west_neighbor != nullptr) if (west_neighbor->getDepth() < node->getDepth ()) if (west_neighbor->isLeaf()) leaf_list.push_back (west_neighbor); // check if south neighbor has to be refined QuadTree<POINT>* south_neighbor (node->getSouthNeighbor()); - if (south_neighbor != NULL) + if (south_neighbor != nullptr) if (south_neighbor->getDepth() < node->getDepth ()) if (south_neighbor->isLeaf()) leaf_list.push_back (south_neighbor); // check if east neighbor has to be refined QuadTree<POINT>* east_neighbor (node->getEastNeighbor()); - if (east_neighbor != NULL) + if (east_neighbor != nullptr) if (east_neighbor->getDepth() < node->getDepth ()) if (east_neighbor->isLeaf()) leaf_list.push_back (east_neighbor); @@ -268,8 +268,8 @@ private: QuadTree<POINT>* getNorthNeighbor () const { - if (this->_father == NULL) // root of QuadTree - return NULL; + if (this->_father == nullptr) // root of QuadTree + return nullptr; if (this->_father->isChild (this, Quadrant::SW)) return this->_father->getChild (Quadrant::NW); @@ -277,8 +277,8 @@ private: return this->_father->getChild (Quadrant::NE); QuadTree<POINT>* north_neighbor (this->_father->getNorthNeighbor ()); - if (north_neighbor == NULL) - return NULL; + if (north_neighbor == nullptr) + return nullptr; if (north_neighbor->isLeaf()) return north_neighbor; @@ -290,8 +290,8 @@ private: QuadTree<POINT>* getSouthNeighbor () const { - if (this->_father == NULL) // root of QuadTree - return NULL; + if (this->_father == nullptr) // root of QuadTree + return nullptr; if (this->_father->isChild (this, Quadrant::NW)) return this->_father->getChild (Quadrant::SW); @@ -299,8 +299,8 @@ private: return this->_father->getChild (Quadrant::SE); QuadTree<POINT>* south_neighbor (this->_father->getSouthNeighbor ()); - if (south_neighbor == NULL) - return NULL; + if (south_neighbor == nullptr) + return nullptr; if (south_neighbor->isLeaf()) return south_neighbor; @@ -312,8 +312,8 @@ private: QuadTree<POINT>* getEastNeighbor () const { - if (this->_father == NULL) // root of QuadTree - return NULL; + if (this->_father == nullptr) // root of QuadTree + return nullptr; if (this->_father->isChild (this, Quadrant::NW)) return this->_father->getChild (Quadrant::NE); @@ -321,8 +321,8 @@ private: return this->_father->getChild (Quadrant::SE); QuadTree<POINT>* east_neighbor (this->_father->getEastNeighbor ()); - if (east_neighbor == NULL) - return NULL; + if (east_neighbor == nullptr) + return nullptr; if (east_neighbor->isLeaf()) return east_neighbor; @@ -334,8 +334,8 @@ private: QuadTree<POINT>* getWestNeighbor () const { - if (this->_father == NULL) // root of QuadTree - return NULL; + if (this->_father == nullptr) // root of QuadTree + return nullptr; if (this->_father->isChild (this, Quadrant::NE)) return this->_father->getChild (Quadrant::NW); @@ -343,8 +343,8 @@ private: return this->_father->getChild (Quadrant::SW); QuadTree<POINT>* west_neighbor (this->_father->getWestNeighbor ()); - if (west_neighbor == NULL) - return NULL; + if (west_neighbor == nullptr) + return nullptr; if (west_neighbor->isLeaf()) return west_neighbor; @@ -372,7 +372,7 @@ private: { // init childs for (std::size_t k(0); k < 4; k++) - _childs[k] = NULL; + _childs[k] = nullptr; } void splitNode () @@ -407,7 +407,7 @@ private: bool needToRefine (QuadTree<POINT>* node) { QuadTree<POINT>* north_neighbor (node->getNorthNeighbor ()); - if (north_neighbor != NULL) + if (north_neighbor != nullptr) { if (north_neighbor->getDepth() == node->getDepth()) if (!north_neighbor->isLeaf ()) @@ -420,7 +420,7 @@ private: } QuadTree<POINT>* west_neighbor (node->getWestNeighbor ()); - if (west_neighbor != NULL) + if (west_neighbor != nullptr) { if (west_neighbor->getDepth() == node->getDepth()) if (!west_neighbor->isLeaf ()) @@ -433,7 +433,7 @@ private: } QuadTree<POINT>* south_neighbor (node->getSouthNeighbor ()); - if (south_neighbor != NULL) + if (south_neighbor != nullptr) { if (south_neighbor->getDepth() == node->getDepth()) if (!south_neighbor->isLeaf()) @@ -446,7 +446,7 @@ private: } QuadTree<POINT>* east_neighbor (node->getEastNeighbor ()); - if (east_neighbor != NULL) + if (east_neighbor != nullptr) { if (east_neighbor->getDepth() == node->getDepth()) if (!east_neighbor->isLeaf ()) diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index 44cdc197d23..47130763a7c 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -82,7 +82,7 @@ const std::vector<float>* SensorData::getTimeSeries(SensorDataType time_series_n return _data_vecs[i]; } ERR("Error in SensorData::getTimeSeries() - Time series \"%d\" not found.", time_series_name); - return NULL; + return nullptr; } std::string SensorData::getDataUnit(SensorDataType time_series_name) const diff --git a/GeoLib/Station.cpp b/GeoLib/Station.cpp index 3b2f1169aad..87660f029c7 100644 --- a/GeoLib/Station.cpp +++ b/GeoLib/Station.cpp @@ -30,16 +30,18 @@ namespace GeoLib { Station::Station(double x, double y, double z, std::string name) : - Point (x,y,z), _name(name), _type(Station::StationType::STATION), _station_value(0.0), _sensor_data(NULL) + Point (x,y,z), _name(name), _type(Station::StationType::STATION), + _station_value(0.0), _sensor_data(nullptr) {} Station::Station(Point* coords, std::string name) : - Point (*coords), _name(name), _type(Station::StationType::STATION), _station_value(0.0), _sensor_data(NULL) + Point (*coords), _name(name), _type(Station::StationType::STATION), + _station_value(0.0), _sensor_data(nullptr) {} Station::Station(Station const& src) : Point(src.getCoords()), _name(src._name), _type(src._type), - _station_value(src._station_value), _sensor_data(NULL) + _station_value(src._station_value), _sensor_data(nullptr) {} Station::~Station() @@ -56,17 +58,17 @@ Station* Station::createStation(const std::string & line) if (fields.size() >= 3) { it = fields.begin(); - station->_name = *it; - (*station)[0] = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), NULL); - (*station)[1] = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), NULL); + station->_name = *it; + (*station)[0] = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), nullptr); + (*station)[1] = strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), nullptr); if (++it != fields.end()) - (*station)[2] = strtod((BaseLib::replaceString(",", ".", *it)).c_str(), NULL); + (*station)[2] = strtod((BaseLib::replaceString(",", ".", *it)).c_str(), nullptr); } else { INFO("Station::createStation() - Unexpected file format."); delete station; - return NULL; + return nullptr; } return station; } diff --git a/GeoLib/StationBorehole.cpp b/GeoLib/StationBorehole.cpp index e836f4f5b0d..b2e8ff56745 100644 --- a/GeoLib/StationBorehole.cpp +++ b/GeoLib/StationBorehole.cpp @@ -207,17 +207,17 @@ StationBorehole* StationBorehole::createStation(const std::string &line) StationBorehole* borehole = new StationBorehole(); std::list<std::string> fields = BaseLib::splitString(line, '\t'); - if (fields.size() >= 5) + if (fields.size() >= 5) { - borehole->_name = fields.front(); + borehole->_name = fields.front(); fields.pop_front(); - (*borehole)[0] = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); + (*borehole)[0] = strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr); fields.pop_front(); - (*borehole)[1] = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); + (*borehole)[1] = strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr); fields.pop_front(); - (*borehole)[2] = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); + (*borehole)[2] = strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr); fields.pop_front(); - borehole->_depth = strtod((BaseLib::replaceString(",", ".", fields.front())).c_str(), NULL); + borehole->_depth = strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr); fields.pop_front(); if (fields.empty()) borehole->_date = 0; @@ -231,7 +231,7 @@ StationBorehole* StationBorehole::createStation(const std::string &line) { WARN("Station::createStation() - Unexpected file format."); delete borehole; - return NULL; + return nullptr; } return borehole; } diff --git a/GeoLib/Surface.cpp b/GeoLib/Surface.cpp index 1889b8698e5..a68de11567f 100644 --- a/GeoLib/Surface.cpp +++ b/GeoLib/Surface.cpp @@ -65,7 +65,7 @@ Surface* Surface::createSurface(const Polyline &ply) { if (!ply.isClosed()) { WARN("Error in Surface::createSurface() - Polyline is not closed."); - return NULL; + return nullptr; } if (ply.getNumberOfPoints() > 2) { -- GitLab