diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 99536b2847c7cd5ebc32c0fc3deb04f358aaf124..c5e4c8d797cfd812ade93ac8dbcbd9de1d3b7dd2 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -181,92 +181,6 @@ ProjectData::~ProjectData() delete m; } -void ProjectData::addMesh(MeshLib::Mesh* mesh) -{ - std::string name = mesh->getName(); - isMeshNameUniqueAndProvideUniqueName(name); - mesh->setName(name); - _mesh_vec.push_back(mesh); -} - -std::vector<MeshLib::Mesh*>::const_iterator ProjectData::findMeshByName( - std::string const& name) const -{ - return const_cast<ProjectData&>(*this).findMeshByName(name); -} - -std::vector<MeshLib::Mesh*>::iterator ProjectData::findMeshByName( - std::string const& name) -{ - return std::find_if(_mesh_vec.begin(), _mesh_vec.end(), - [&name](MeshLib::Mesh* mesh) { - return mesh && (name == mesh->getName()); - }); -} - -const MeshLib::Mesh* ProjectData::getMesh(const std::string& name) const -{ - auto it = findMeshByName(name); - return (it == _mesh_vec.end() ? nullptr : *it); -} - -bool ProjectData::removeMesh(const std::string& name) -{ - bool mesh_found = false; - auto it = findMeshByName(name); - while (it != _mesh_vec.end()) - { - delete *it; - *it = nullptr; - it = findMeshByName(name); - mesh_found = true; - } - - _mesh_vec.erase(std::remove(_mesh_vec.begin(), _mesh_vec.end(), nullptr), - _mesh_vec.end()); - return mesh_found; -} - -bool ProjectData::meshExists(const std::string& name) const -{ - return findMeshByName(name) != _mesh_vec.end(); -} - -bool ProjectData::isMeshNameUniqueAndProvideUniqueName(std::string& name) const -{ - int count(0); - bool isUnique(false); - std::string cpName; - - while (!isUnique) - { - isUnique = true; - cpName = name; - - count++; - // If the original name already exists we start to add numbers to name - // for - // as long as it takes to make the name unique. - if (count > 1) - cpName = cpName + "-" + std::to_string(count); - - for (auto mesh : _mesh_vec) - if (cpName == mesh->getName()) - isUnique = false; - } - - // At this point cpName is a unique name and isUnique is true. - // If cpName is not the original name, "name" is changed and isUnique is set - // to false, - // indicating that a vector with the original name already exists. - if (count > 1) - { - isUnique = false; - name = cpName; - } - return isUnique; -} - void ProjectData::parseProcessVariables( BaseLib::ConfigTree const& process_variables_config) { diff --git a/Applications/ApplicationsLib/ProjectData.h b/Applications/ApplicationsLib/ProjectData.h index b5cd4d44ead7a0da4a22bfd317bc11151c31996d..bdcd239da1a07b656b966a46c8e0fc9e7c2f25f7 100644 --- a/Applications/ApplicationsLib/ProjectData.h +++ b/Applications/ApplicationsLib/ProjectData.h @@ -75,27 +75,6 @@ public: /// Returns the GEOObjects containing all points, polylines and surfaces. GeoLib::GEOObjects* getGEOObjects() { return _geoObjects; } - /// Adds a new mesh under a (possibly new) unique name. - /// \attention This might change the given mesh's name. - void addMesh(MeshLib::Mesh* mesh); - - /// Returns the mesh with the given name or a \c nullptr if the mesh was not - /// found. - const MeshLib::Mesh* getMesh(const std::string& name) const; - - /// Returns all the meshes with their respective names - /// \attention This method should be used only by methods garanteeing - /// read-only access to the meshes. - /// \todo This method breaks encapsulation. - const std::vector<MeshLib::Mesh*>& getMeshObjects() const - { - return _mesh_vec; - } - - /// Deletes all meshes with the given name and removes them from the list of - /// saved meshes. If any mesh was found for removal, true is returned and - /// false otherwise. - bool removeMesh(const std::string& name); // // Process interface @@ -110,20 +89,6 @@ public: TimeLoop& getTimeLoop() { return *_time_loop; } private: - /// Checks if a mesh with the same name exists and provides a unique name in - /// case of already existing mesh. Returns true if the mesh name is unique. - /// Returns false and changes the provided name to a unique name otherwise. - bool isMeshNameUniqueAndProvideUniqueName(std::string& name) const; - - /// Returns true if a mesh with the same name exists and false otherwise. - bool meshExists(const std::string& name) const; - - /// Returns an iterator to the first found mesh with the given name. - std::vector<MeshLib::Mesh*>::const_iterator findMeshByName( - std::string const& name) const; - std::vector<MeshLib::Mesh*>::iterator findMeshByName( - std::string const& name); - /// Parses the process variables configuration and creates new variables for /// each variable entry passing the corresponding subtree to the process /// variable constructor.