From a4cf5c61383940e2e66252dfea4fa2ed814f7aac Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 11 Apr 2021 10:59:48 +0200 Subject: [PATCH] [MaL] Make id member private. Protected write acs. Move common setID() member from derived classes into the base class allows for making the _id member private. Access through getID() in two occasions for in gmsh and gocad IO interface functions. --- Applications/FileIO/Gmsh/GMSHPoint.cpp | 3 ++- Applications/FileIO/GocadIO/GocadNode.h | 2 +- GeoLib/Point.h | 2 -- MathLib/Point3dWithID.h | 4 ++++ MeshLib/Node.h | 3 --- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Applications/FileIO/Gmsh/GMSHPoint.cpp b/Applications/FileIO/Gmsh/GMSHPoint.cpp index 026575f8c30..e128e0ffac8 100644 --- a/Applications/FileIO/Gmsh/GMSHPoint.cpp +++ b/Applications/FileIO/Gmsh/GMSHPoint.cpp @@ -25,7 +25,8 @@ GMSHPoint::GMSHPoint(GeoLib::Point const& pnt, std::size_t id, void GMSHPoint::write(std::ostream& os) const { - os << "Point(" << _id << ") = {" << _x[0] << ", " << _x[1] << ", " << _x[2]; + os << "Point(" << getID() << ") = {" << _x[0] << ", " << _x[1] << ", " + << _x[2]; if (fabs(_mesh_density) > std::numeric_limits<double>::epsilon()) { os << ", " << _mesh_density << "};"; diff --git a/Applications/FileIO/GocadIO/GocadNode.h b/Applications/FileIO/GocadIO/GocadNode.h index de8ed4b1c35..9c6b066baa9 100644 --- a/Applications/FileIO/GocadIO/GocadNode.h +++ b/Applications/FileIO/GocadIO/GocadNode.h @@ -97,7 +97,7 @@ public: OGS_FATAL( "GocadNode {:d}: Could not found face indicator for face set " "{:d}", - _id, face_set_number); + getID(), face_set_number); } return it->second; } diff --git a/GeoLib/Point.h b/GeoLib/Point.h index a245e755bc3..4e5772d3a03 100644 --- a/GeoLib/Point.h +++ b/GeoLib/Point.h @@ -56,8 +56,6 @@ public: protected: friend PointVec; - /// Resets the id. - void setID(std::size_t id) { _id = id; } }; } // namespace GeoLib diff --git a/MathLib/Point3dWithID.h b/MathLib/Point3dWithID.h index 340f6e24021..d0b58041775 100644 --- a/MathLib/Point3dWithID.h +++ b/MathLib/Point3dWithID.h @@ -61,6 +61,10 @@ public: std::size_t getID() const { return _id; } protected: + /// Sets the ID of a node to the given value. + void setID(std::size_t id) { _id = id; } + +private: std::size_t _id; }; diff --git a/MeshLib/Node.h b/MeshLib/Node.h index 2d61e6631d8..e9a8123d2ca 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -89,9 +89,6 @@ protected: _connected_nodes = connected_nodes; } - /// Sets the ID of a node to the given value. - void setID(std::size_t id) { _id = id; } - std::vector<Node*> _connected_nodes; std::vector<Element*> _elements; }; /* class */ -- GitLab