-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid double computations (#378 | gridedit 1336)
- Loading branch information
1 parent
d381024
commit 0a58be0
Showing
29 changed files
with
1,829 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
libs/MeshKernelApi/include/MeshKernelApi/ApiCache/BoundariesAsPolygonCache.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//---- GPL --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) Stichting Deltares, 2011-2024. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// contact: [email protected] | ||
// Stichting Deltares | ||
// P.O. Box 177 | ||
// 2600 MH Delft, The Netherlands | ||
// | ||
// All indications and logos of, and references to, "Delft3D" and "Deltares" | ||
// are registered trademarks of Stichting Deltares, and remain the property of | ||
// Stichting Deltares. All rights reserved. | ||
// | ||
//------------------------------------------------------------------------------ | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cstring> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "MeshKernelApi/ApiCache/CachedPointValues.hpp" | ||
#include "MeshKernelApi/GeometryList.hpp" | ||
#include "MeshKernelApi/Utils.hpp" | ||
|
||
namespace meshkernelapi | ||
{ | ||
|
||
/// @brief Cache boundary polygon points | ||
class BoundariesAsPolygonCache : public CachedPointValues | ||
{ | ||
public: | ||
/// @brief Constructor | ||
BoundariesAsPolygonCache(const int lowerLeftN, | ||
const int lowerLeftM, | ||
const int upperRightN, | ||
const int upperRightM, | ||
const std::vector<meshkernel::Point>& boundaryPoints); | ||
|
||
/// @brief Determine if current options match those used to construct the object | ||
bool ValidOptions(const int lowerLeftN, | ||
const int lowerLeftM, | ||
const int upperRightN, | ||
const int upperRightM) const; | ||
|
||
private: | ||
int m_lowerLeftNValue = -1; ///< Initial lower left N value | ||
int m_lowerLeftMValue = -1; ///< Initial lower left M value | ||
int m_upperRightNValue = -1; ///< Initial upper right N value | ||
int m_upperRightMValue = -1; ///< Initial upper right M value | ||
}; | ||
|
||
} // namespace meshkernelapi |
64 changes: 64 additions & 0 deletions
64
libs/MeshKernelApi/include/MeshKernelApi/ApiCache/CachedIntegerValues.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//---- GPL --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) Stichting Deltares, 2011-2024. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// contact: [email protected] | ||
// Stichting Deltares | ||
// P.O. Box 177 | ||
// 2600 MH Delft, The Netherlands | ||
// | ||
// All indications and logos of, and references to, "Delft3D" and "Deltares" | ||
// are registered trademarks of Stichting Deltares, and remain the property of | ||
// Stichting Deltares. All rights reserved. | ||
// | ||
//------------------------------------------------------------------------------ | ||
|
||
#pragma once | ||
|
||
#include <cstring> | ||
#include <vector> | ||
|
||
namespace meshkernelapi | ||
{ | ||
/// @brief Caches x- and y-coordinate values for various algorithms | ||
class CachedIntegerValues | ||
{ | ||
public: | ||
/// @brief Default constructor | ||
CachedIntegerValues() {} | ||
|
||
/// @brief Construct with point values | ||
CachedIntegerValues(const std::vector<int>& values); | ||
|
||
/// @brief Destructor | ||
virtual ~CachedIntegerValues() = default; | ||
|
||
/// @brief Number of points saved | ||
int Size() const | ||
{ | ||
return static_cast<int>(m_values.size()); | ||
} | ||
|
||
/// @brief Copy cached points to geometry | ||
void Copy(int* buffer) const; | ||
|
||
protected: | ||
/// @brief Reset the saved integer values. | ||
void Reset(std::vector<int>&& values); | ||
|
||
private: | ||
std::vector<int> m_values; ///< integer values | ||
}; | ||
} // namespace meshkernelapi |
70 changes: 70 additions & 0 deletions
70
libs/MeshKernelApi/include/MeshKernelApi/ApiCache/CachedPointValues.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//---- GPL --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) Stichting Deltares, 2011-2024. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// contact: [email protected] | ||
// Stichting Deltares | ||
// P.O. Box 177 | ||
// 2600 MH Delft, The Netherlands | ||
// | ||
// All indications and logos of, and references to, "Delft3D" and "Deltares" | ||
// are registered trademarks of Stichting Deltares, and remain the property of | ||
// Stichting Deltares. All rights reserved. | ||
// | ||
//------------------------------------------------------------------------------ | ||
|
||
#pragma once | ||
|
||
#include <cstring> | ||
#include <vector> | ||
|
||
#include "MeshKernel/Point.hpp" | ||
|
||
#include "MeshKernelApi/GeometryList.hpp" | ||
|
||
namespace meshkernelapi | ||
{ | ||
/// @brief Caches x- and y-coordinate values for various algorithms | ||
class CachedPointValues | ||
{ | ||
public: | ||
/// @brief Default constructor | ||
CachedPointValues() {} | ||
|
||
/// @brief Construct with point values | ||
CachedPointValues(const std::vector<meshkernel::Point>& coordinates); | ||
|
||
/// @brief Destructor | ||
virtual ~CachedPointValues() = default; | ||
|
||
/// @brief Number of points saved | ||
int Size() const | ||
{ | ||
return static_cast<int>(m_coordsX.size()); | ||
} | ||
|
||
/// @brief Copy cached points to geometry | ||
void Copy(const GeometryList& geometry) const; | ||
|
||
protected: | ||
/// @brief Reset the saved coordinate values. | ||
void Reset(std::vector<double>&& xValues, | ||
std::vector<double>&& yValues); | ||
|
||
private: | ||
std::vector<double> m_coordsX; ///< x-coordinate values | ||
std::vector<double> m_coordsY; ///< y-coordinate values | ||
}; | ||
} // namespace meshkernelapi |
62 changes: 62 additions & 0 deletions
62
libs/MeshKernelApi/include/MeshKernelApi/ApiCache/FacePolygonPropertyCache.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//---- GPL --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) Stichting Deltares, 2011-2024. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// contact: [email protected] | ||
// Stichting Deltares | ||
// P.O. Box 177 | ||
// 2600 MH Delft, The Netherlands | ||
// | ||
// All indications and logos of, and references to, "Delft3D" and "Deltares" | ||
// are registered trademarks of Stichting Deltares, and remain the property of | ||
// Stichting Deltares. All rights reserved. | ||
// | ||
//------------------------------------------------------------------------------ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "MeshKernel/Mesh2D.hpp" | ||
|
||
#include "MeshKernelApi/ApiCache/CachedPointValues.hpp" | ||
|
||
namespace meshkernelapi | ||
{ | ||
/// @brief Cache node values of faces | ||
class FacePolygonPropertyCache : public CachedPointValues | ||
{ | ||
|
||
public: | ||
/// @brief Constructor | ||
FacePolygonPropertyCache(const int propertyValue, | ||
const double minValue, | ||
const double maxValue, | ||
const meshkernel::Mesh2D& mesh, | ||
const int validSize, | ||
const std::vector<bool>& filterMask); | ||
|
||
/// @brief Determine if current options match those used to construct the object | ||
bool ValidOptions(const int propertyValue, | ||
const double minValue, | ||
const double maxValue) const; | ||
|
||
private: | ||
int m_propertyValue = 0; ///< Initial property value | ||
double m_minimumValue = meshkernel::constants::missing::doubleValue; ///< Initial minimum value | ||
double m_maximumValue = meshkernel::constants::missing::doubleValue; ///< Initial maximum value | ||
}; | ||
|
||
} // namespace meshkernelapi |
48 changes: 48 additions & 0 deletions
48
libs/MeshKernelApi/include/MeshKernelApi/ApiCache/HangingEdgeCache.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//---- GPL --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) Stichting Deltares, 2011-2024. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// contact: [email protected] | ||
// Stichting Deltares | ||
// P.O. Box 177 | ||
// 2600 MH Delft, The Netherlands | ||
// | ||
// All indications and logos of, and references to, "Delft3D" and "Deltares" | ||
// are registered trademarks of Stichting Deltares, and remain the property of | ||
// Stichting Deltares. All rights reserved. | ||
// | ||
//------------------------------------------------------------------------------ | ||
|
||
#pragma once | ||
|
||
#include <cstring> | ||
#include <vector> | ||
|
||
#include "MeshKernel/Point.hpp" | ||
|
||
#include "MeshKernelApi/ApiCache/CachedIntegerValues.hpp" | ||
|
||
namespace meshkernelapi | ||
{ | ||
|
||
/// @brief Cache edge indices for hanging nodes/edges | ||
class HangingEdgeCache : public CachedIntegerValues | ||
{ | ||
public: | ||
/// @brief Constructor | ||
HangingEdgeCache(const std::vector<meshkernel::UInt>& edgeIds); | ||
}; | ||
|
||
} // namespace meshkernelapi |
Oops, something went wrong.