From fe3ad6ed34adb4906fb3738f4aa6dc4b32a1ea4a Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Fri, 11 Dec 2020 12:53:04 +0100 Subject: [PATCH] [A/IO] Substitute writePoints by output operator and GL::rotatePoints. --- Applications/FileIO/Gmsh/GMSHInterface.cpp | 32 +++++++++++----------- Applications/FileIO/Gmsh/GMSHInterface.h | 4 +-- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Applications/FileIO/Gmsh/GMSHInterface.cpp b/Applications/FileIO/Gmsh/GMSHInterface.cpp index b4f8ccc4083..13dad9fb999 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.cpp +++ b/Applications/FileIO/Gmsh/GMSHInterface.cpp @@ -33,6 +33,19 @@ namespace FileIO { namespace GMSH { +static std::ostream& operator<<(std::ostream& os, + std::vector<GMSHPoint*> const& points) +{ + for (auto& point : points) + { + if (point) + { + os << *point << "\n"; + } + } + return os; +} + GMSHInterface::GMSHInterface( GeoLib::GEOObjects& geo_objs, bool /*include_stations_as_constraints*/, GMSH::MeshDensityAlgorithm const mesh_density_algorithm, @@ -218,7 +231,9 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) } // *** finally write data :-) - writePoints(out); + GeoLib::rotatePoints(_inverse_rot_mat, _gmsh_pnts); + out << _gmsh_pnts; + std::size_t pnt_id_offset(_gmsh_pnts.size()); for (auto* polygon_tree : _polygon_tree_list) { @@ -239,20 +254,5 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) return 0; } -void GMSHInterface::writePoints(std::ostream& out) const -{ - for (auto& gmsh_pnt : _gmsh_pnts) - { - // reverse rotation - if (gmsh_pnt) - { - auto p = Eigen::Map<Eigen::Vector3d>( - const_cast<double*>(gmsh_pnt->getCoords())); - p = _inverse_rot_mat * p; - out << *gmsh_pnt << "\n"; - } - } -} - } // end namespace GMSH } // end namespace FileIO diff --git a/Applications/FileIO/Gmsh/GMSHInterface.h b/Applications/FileIO/Gmsh/GMSHInterface.h index 23dbf33f5be..e7d333c3a43 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.h +++ b/Applications/FileIO/Gmsh/GMSHInterface.h @@ -95,8 +95,6 @@ private: */ int writeGMSHInputFile(std::ostream & out); - void writePoints(std::ostream& out) const; - std::size_t _n_lines; std::size_t _n_plane_sfc; @@ -108,7 +106,7 @@ private: std::vector<GMSH::GMSHPoint*> _gmsh_pnts; std::unique_ptr<GMSH::GMSHMeshDensityStrategy> _mesh_density_strategy; - /// Holds the inverse rotation matrix. The matrix is used in writePoints() to + /// Holds the inverse rotation matrix. The matrix is used to /// revert the rotation done in writeGMSHInputFile(). Eigen::Matrix3d _inverse_rot_mat = Eigen::Matrix3d::Zero(); /// Signals if the input points should be rotated or projected to the -- GitLab