diff --git a/Applications/DataExplorer/DataView/CMakeLists.txt b/Applications/DataExplorer/DataView/CMakeLists.txt index 42ae72959334ebe37b938ecb901fb53ae4ea8808..1fbd3a7557a203d13822c8cbf4dd22c92e06774d 100644 --- a/Applications/DataExplorer/DataView/CMakeLists.txt +++ b/Applications/DataExplorer/DataView/CMakeLists.txt @@ -7,7 +7,6 @@ set( SOURCES DirectConditionGenerator.cpp ElementTreeModel.cpp ElementTreeView.cpp - GeoMapper.cpp GEOModels.cpp GeoOnMeshMappingDialog.cpp GeoTabWidget.cpp @@ -86,7 +85,6 @@ set( HEADERS CondItem.h DirectConditionGenerator.h CondObjectListItem.h - GeoMapper.h GeoObjectListItem.h GeoTreeItem.h ModelTreeItem.h @@ -146,6 +144,7 @@ include_directories( ${SOURCE_DIR_REL}/BaseLib ${SOURCE_DIR_REL}/MathLib ${SOURCE_DIR_REL}/GeoLib + ${SOURCE_DIR_REL}/MeshGeoToolsLib ${SOURCE_DIR_REL}/MeshLib ${SOURCE_DIR_REL}/FileIO ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h index 2b7a3bb17a3634ed37c02aff96e604ce9e62d329..1a066fd998ffbbee5ef8f814f9aff2dde57cc556 100644 --- a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h +++ b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h @@ -18,7 +18,7 @@ #include "ui_GeoOnMeshMapping.h" #include <QDialog> -#include "GeoMapper.h" +#include "MeshGeoToolsLib/GeoMapper.h" namespace MeshLib { class Mesh; diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index 0d40e6d45d027163f50674aed550b24e6495a11d..c35891dae4e996fac0ca1428037e8de6e0820c13 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -50,7 +50,7 @@ #include "SHPImportDialog.h" -#include "GeoMapper.h" +#include "MeshGeoToolsLib/GeoMapper.h" #include "OGSError.h" #include "VtkRaster.h" #include "RecentFiles.h" diff --git a/Applications/DataExplorer/DataView/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp similarity index 95% rename from Applications/DataExplorer/DataView/GeoMapper.cpp rename to MeshGeoToolsLib/GeoMapper.cpp index 0cdabd1fc80ea77d628c65b7e1436befb14db598..f61c516c0bb5e535c77048e76e1fcb75c1b9c0fd 100644 --- a/Applications/DataExplorer/DataView/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -17,21 +17,22 @@ #include "GeoMapper.h" +#include <algorithm> #include <numeric> #include "FileIO/AsciiRasterInterface.h" +#include "FileIO/readMeshFromFile.h" -#include "AABB.h" -#include "Mesh.h" -#include "Elements/Element.h" -#include "MeshLib/Node.h" -#include "MeshSurfaceExtraction.h" -#include "AnalyticalGeometry.h" -#include "PointWithID.h" -#include "Raster.h" -#include "readMeshFromFile.h" -#include "StationBorehole.h" +#include "GeoLib/AABB.h" +#include "GeoLib/AnalyticalGeometry.h" +#include "GeoLib/PointWithID.h" +#include "GeoLib/Raster.h" +#include "GeoLib/StationBorehole.h" +#include "MeshLib/Mesh.h" +#include "MeshLib/Elements/Element.h" +#include "MeshLib/Node.h" +#include "MeshLib/MeshSurfaceExtraction.h" GeoMapper::GeoMapper(GeoLib::GEOObjects &geo_objects, const std::string &geo_name) : _geo_objects(geo_objects), _geo_name(const_cast<std::string&>(geo_name)), _mesh(nullptr), _grid(nullptr), _raster(nullptr) @@ -83,6 +84,17 @@ void GeoMapper::mapOnMesh(const MeshLib::Mesh* mesh) } } +void GeoMapper::mapToConstantValue(double value) +{ + std::vector<GeoLib::Point*> const* points (this->_geo_objects.getPointVec(this->_geo_name)); + if (points == nullptr) + { + ERR ("Geometry \"%s\" not found.", this->_geo_name.c_str()); + return; + } + std::for_each(points->begin(), points->end(), [value](GeoLib::Point* pnt){ (*pnt)[2] = value; }); +} + void GeoMapper::mapData() { const std::vector<GeoLib::Point*> *points (this->_geo_objects.getPointVec(this->_geo_name)); diff --git a/Applications/DataExplorer/DataView/GeoMapper.h b/MeshGeoToolsLib/GeoMapper.h similarity index 66% rename from Applications/DataExplorer/DataView/GeoMapper.h rename to MeshGeoToolsLib/GeoMapper.h index 4167c7262a4363e3a106b56a10e486508009485c..fdb8b5f24087a3da95a1f72cec29cf6c02d7a543 100644 --- a/Applications/DataExplorer/DataView/GeoMapper.h +++ b/MeshGeoToolsLib/GeoMapper.h @@ -43,45 +43,54 @@ public: GeoMapper(GeoLib::GEOObjects &geo_objects, const std::string &geo_name); ~GeoMapper(); + /// Maps geometry based on a raster file void mapOnDEM(const std::string &file_name); + + /// Maps geometry based on a mesh file void mapOnMesh(const std::string &file_name); + + /// Maps geometry based on a mesh void mapOnMesh(const MeshLib::Mesh* mesh); + + /// Maps geometry to constant elevation value + void mapToConstantValue(double value); + void advancedMapOnMesh(const MeshLib::Mesh* mesh, const std::string &new_geo_name); private: - // Manages the mapping geometric data (points, stations, boreholes) on a raster or mesh. + /// Manages the mapping geometric data (points, stations, boreholes) on a raster or mesh. void mapData(); - // Returns a grid containing all mesh surface points with elevation=0 + /// Returns a grid containing all mesh surface points with elevation=0 GeoLib::Grid<GeoLib::PointWithID>* getFlatGrid(MeshLib::Mesh const*const mesh, std::vector<GeoLib::PointWithID*> sfc_pnts) const; - // Returns the elevation at Point (x,y) based on a mesh. This uses collision detection for triangles and nearest neighbor for quads. - // NOTE: This medhod only returns correct values if the node numbering of the elements is correct! + /// Returns the elevation at Point (x,y) based on a mesh. This uses collision detection for triangles and nearest neighbor for quads. + /// NOTE: This medhod only returns correct values if the node numbering of the elements is correct! double getMeshElevation(double x, double y, double min_val, double max_val) const; - // Returns the elevation at Point (x,y) based on a raster + /// Returns the elevation at Point (x,y) based on a raster float getDemElevation(GeoLib::Point const& pnt) const; - // Calculates the intersection of two lines embedded in the xy-plane + /// Calculates the intersection of two lines embedded in the xy-plane GeoLib::Point* calcIntersection(MathLib::Point3d const*const p1, MathLib::Point3d const*const p2, GeoLib::Point const*const q1, GeoLib::Point const*const q2) const; - // Returns the position of a point within a line-segment + /// Returns the position of a point within a line-segment unsigned getPointPosInLine(GeoLib::Polyline const*const line, unsigned start, unsigned end, GeoLib::Point const*const point, double eps) const; - // Returns the maximum segment length in a polyline vector + /// Returns the maximum segment length in a polyline vector double getMaxSegmentLength(const std::vector<GeoLib::Polyline*> &lines) const; - // Returns if a point p is within a bounding box defined by a and b + /// Returns if a point p is within a bounding box defined by a and b bool isPntInBoundingBox(double ax, double ay, double bx, double by, double px, double py) const; GeoLib::GEOObjects& _geo_objects; std::string& _geo_name; - // only necessary for mapping on mesh + /// only necessary for mapping on mesh MeshLib::Mesh* _mesh; GeoLib::Grid<GeoLib::PointWithID>* _grid; - // only necessary for mapping on DEM + /// only necessary for mapping on DEM GeoLib::Raster *_raster; };