-
Notifications
You must be signed in to change notification settings - Fork 50
Add indicator field #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lhy11009
wants to merge
1
commit into
GeodynamicWorldBuilder:main
Choose a base branch
from
lhy11009:indicator_field
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add indicator field #886
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
94 changes: 94 additions & 0 deletions
94
include/world_builder/features/oceanic_plate_models/indicator/depth_range.h
This file contains hidden or 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,94 @@ | ||
| /* | ||
| Copyright (C) 2018-2026 by the authors of the World Builder code. | ||
|
|
||
| This file is part of the World Builder. | ||
|
|
||
| This program is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published | ||
| by the Free Software Foundation, either version 2 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| 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 Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #ifndef WORLD_BUILDER_FEATURES_OCEANIC_PLATE_MODELS_INDICATOR_DEPTH_RANGE_H | ||
| #define WORLD_BUILDER_FEATURES_OCEANIC_PLATE_MODELS_INDICATOR_DEPTH_RANGE_H | ||
|
|
||
|
|
||
| #include "world_builder/features/oceanic_plate_models/indicator/interface.h" | ||
| #include "world_builder/features/feature_utilities.h" | ||
| #include "world_builder/objects/surface.h" | ||
|
|
||
| namespace WorldBuilder | ||
| { | ||
| namespace Features | ||
| { | ||
| using namespace FeatureUtilities; | ||
| namespace OceanicPlateModels | ||
| { | ||
| namespace Indicator | ||
| { | ||
| /** | ||
| * This class represents a oceanic plate and can implement submodules | ||
| * for indicator. These submodules determine what | ||
| * the returned indicator of the indicator functions of this class will be. | ||
| */ | ||
| class DepthRange final: public Interface | ||
| { | ||
| public: | ||
| /** | ||
| * constructor | ||
| */ | ||
| DepthRange(WorldBuilder::World *world); | ||
|
|
||
| /** | ||
| * Destructor | ||
| */ | ||
| ~DepthRange() override final; | ||
|
|
||
| /** | ||
| * declare and read in the world builder file into the parameters class | ||
| */ | ||
| static | ||
| void declare_entries(Parameters &prm, const std::string &parent_name = ""); | ||
|
|
||
| /** | ||
| * declare and read in the world builder file into the parameters class | ||
| */ | ||
| void parse_entries(Parameters &prm, const std::vector<Point<2>> &coordinates) override final; | ||
|
|
||
|
|
||
| /** | ||
| * Returns a indicator based on the given position, depth in the model, | ||
| * and current indicator | ||
| */ | ||
| double get_indicator(const Point<3> &position, | ||
| const Objects::NaturalCoordinate &position_in_natural_coordinates, | ||
| const double depth, | ||
| const unsigned int indicator_number, | ||
| double indicator, | ||
| const double feature_min_depth, | ||
| const double feature_max_depth) const override final; | ||
|
|
||
|
|
||
| private: | ||
| // depth-range indicator submodule parameters | ||
| double min_depth; | ||
| Objects::Surface min_depth_surface; | ||
| double max_depth; | ||
| Objects::Surface max_depth_surface; | ||
| std::vector<unsigned int> indicators; | ||
| Operations operation; | ||
| }; | ||
| } // namespace Indicator | ||
| } // namespace OceanicPlateModels | ||
| } // namespace Features | ||
| } // namespace WorldBuilder | ||
|
|
||
| #endif | ||
169 changes: 169 additions & 0 deletions
169
include/world_builder/features/oceanic_plate_models/indicator/interface.h
This file contains hidden or 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,169 @@ | ||
| /* | ||
| Copyright (C) 2018-2026 by the authors of the World Builder code. | ||
|
|
||
| This file is part of the World Builder. | ||
|
|
||
| This program is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published | ||
| by the Free Software Foundation, either version 2 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| 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 Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #ifndef WORLD_BUILDER_FEATURES_OCEANIC_PLATE_MODELS_INDICATOR_INTERFACE_H | ||
| #define WORLD_BUILDER_FEATURES_OCEANIC_PLATE_MODELS_INDICATOR_INTERFACE_H | ||
|
|
||
|
|
||
| #include "world_builder/parameters.h" | ||
| #include "world_builder/objects/natural_coordinate.h" | ||
|
|
||
|
|
||
| namespace WorldBuilder | ||
| { | ||
| class World; | ||
| class Parameters; | ||
| template <unsigned int dim> class Point; | ||
|
|
||
| /** | ||
| * This class is an interface for the specific plate tectonic feature classes, | ||
| * such as oceanic plate, oceanic plate and subduction zone. | ||
| */ | ||
| namespace Features | ||
| { | ||
|
|
||
| namespace OceanicPlateModels | ||
| { | ||
| namespace Indicator | ||
| { | ||
| class ObjectFactory; | ||
|
|
||
| class Interface | ||
| { | ||
| public: | ||
| /** | ||
| * constructor | ||
| */ | ||
| Interface(); | ||
|
|
||
| /** | ||
| * Destructor | ||
| */ | ||
| virtual | ||
| ~Interface(); | ||
|
|
||
| /** | ||
| * declare and read in the world builder file into the parameters class | ||
| */ | ||
| static | ||
| void declare_entries(Parameters &prm, | ||
| const std::string &parent_name, | ||
| const std::vector<std::string> &required_entries); | ||
|
|
||
| /** | ||
| * declare and read in the world builder file into the parameters class | ||
| */ | ||
| virtual | ||
| void parse_entries(Parameters &prm, const std::vector<Point<2>> &coordinates) = 0; | ||
|
|
||
|
|
||
| /** | ||
| * takes indicator and position and returns a indicator. | ||
| */ | ||
| virtual | ||
| double get_indicator(const Point<3> &position, | ||
| const Objects::NaturalCoordinate &position_in_natural_coordinates, | ||
| const double depth, | ||
| const unsigned int indicator_number, | ||
| double indicator, | ||
| const double feature_min_depth, | ||
| const double feature_max_depth) const = 0; | ||
| /** | ||
| * A function to register a new type. This is part of the automatic | ||
| * registration of the object factory. | ||
| */ | ||
| static void registerType(const std::string &name, | ||
| void ( * /*declare_entries*/)(Parameters &, const std::string &), | ||
| ObjectFactory *factory); | ||
|
|
||
|
|
||
| /** | ||
| * A function to create a new type. This is part of the automatic | ||
| * registration of the object factory. | ||
| */ | ||
| static std::unique_ptr<Interface> create(const std::string &name, WorldBuilder::World *world); | ||
|
|
||
| /** | ||
| * Returns the name of the plugin | ||
| */ | ||
| std::string get_name() const | ||
| { | ||
| return name; | ||
| }; | ||
|
|
||
| protected: | ||
| /** | ||
| * A pointer to the world class to retrieve variables. | ||
| */ | ||
| WorldBuilder::World *world; | ||
|
|
||
| /** | ||
| * The name of the feature type. | ||
| */ | ||
| std::string name; | ||
|
|
||
| private: | ||
| static std::map<std::string, ObjectFactory *> &get_factory_map() | ||
| { | ||
| static std::map<std::string, ObjectFactory *> factories; | ||
| return factories; | ||
| } | ||
|
|
||
| static std::map<std::string, void ( *)(Parameters &,const std::string &)> &get_declare_map() | ||
| { | ||
| static std::map<std::string, void ( *)(Parameters &,const std::string &)> declares; | ||
| return declares; | ||
| } | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * A class to create new objects | ||
| */ | ||
| class ObjectFactory | ||
| { | ||
| public: | ||
| virtual std::unique_ptr<Interface> create(World *world) = 0; | ||
| }; | ||
|
|
||
| /** | ||
| * A macro which should be in every derived cpp file to automatically | ||
| * register it. Because this is a library, we need some extra measures | ||
| * to ensure that the static variable is actually initialized. | ||
| */ | ||
| #define WB_REGISTER_FEATURE_OCEANIC_PLATE_INDICATOR_MODEL(classname,name) \ | ||
| class classname##Factory : public ObjectFactory { \ | ||
| public: \ | ||
| classname##Factory() \ | ||
| { \ | ||
| Interface::registerType(#name, classname::declare_entries, this); \ | ||
| } \ | ||
| std::unique_ptr<Interface> create(World *world) override final { \ | ||
| return std::unique_ptr<Interface>(new classname(world)); \ | ||
| } \ | ||
| }; \ | ||
| static classname##Factory global_##classname##Factory; | ||
|
|
||
| } // namespace Indicator | ||
| } // namespace OceanicPlateModels | ||
| } // namespace Features | ||
| } // namespace WorldBuilder | ||
|
|
||
| #endif |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.