FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
VisualBakedScalarField.h
1#pragma once
2
8#include <ScalarFieldBake.h>
9#include <cstddef>
10#include <fhsim/simobject/SimObject.h>
11#include <memory>
12#include <string>
13
14namespace environment
15{
16class EnvironmentProvider;
17}
18
19#ifdef FH_VISUALIZATION
20# include "visual/BakedFieldTexture.h"
21
22# include <OgreMaterial.h>
23#endif
24
25namespace environmentmodels
26{
27
45class VisualBakedScalarField : public SimObject
46{
47public:
58 void FinalSetup(const double T, const double* const X, ISimObjectCreator* Creator) override;
59
61 void OdeFcn(const double T, const double* const X, double* const XDot) const override;
62
63protected:
73 VisualBakedScalarField(std::string SimObjectName, ISimObjectCreator* Creator, int numAxes);
74
77
87 void ResolveCounts(const double extent[3], std::size_t budget, int counts[3]) const;
88
108 void ValidateGridCounts(ISimObjectCreator* Creator, const int counts[3], const std::string& extentParameterName) const;
109
113 [[nodiscard]] bool MaskInaccurate() const { return !m_showExtrapolated; }
114
119 [[nodiscard]] environment::field::ScalarField& Field() const;
120
121#ifdef FH_VISUALIZATION
130 util::BakedField BakeOverBox(const util::SamplingBox& box);
131
138 void CreateTextures(const util::BakedField& baked);
139
151 void SwapTextures(std::unique_ptr<visual::BakedFieldTexture> textures);
152
159 Ogre::MaterialPtr CloneMaterial(const Ogre::String& baseMaterialName);
160
169 void ApplyMaterialSettings(double valueMin, double valueMax) const;
170
174 [[nodiscard]] const Ogre::MaterialPtr& Material() const { return m_material; }
175#endif
176
177private:
178 std::string m_fieldName;
179
180 int m_numAxes;
181 bool m_hasSpacing;
182 bool m_hasResolution;
183
184 double m_spacing[3];
185 int m_resolution[3];
186
187 double m_colorRange[2];
188 double m_visibleRange[2];
189 double m_alphaRange[2];
190
191 bool m_hasColorRange;
192 bool m_hasVisibleRange;
193 bool m_showExtrapolated;
194 bool m_visualiseAsConstant;
195
196 environment::EnvironmentProvider* m_pEnvironment;
197
198 std::shared_ptr<environment::field::ScalarField> m_field;
199
200 bool m_fieldIsThreadSafe;
201
202#ifdef FH_VISUALIZATION
203 std::unique_ptr<visual::BakedFieldTexture> m_texture;
204 Ogre::MaterialPtr m_material;
205#endif
206};
207
208} // namespace environmentmodels
Definition VisualBakedScalarField.h:46
environment::field::ScalarField & Field() const
void OdeFcn(const double T, const double *const X, double *const XDot) const override
No state; the ODE function is a no-op.
bool MaskInaccurate() const
Definition VisualBakedScalarField.h:113
void ValidateGridCounts(ISimObjectCreator *Creator, const int counts[3], const std::string &extentParameterName) const
VisualBakedScalarField(std::string SimObjectName, ISimObjectCreator *Creator, int numAxes)
~VisualBakedScalarField() override
Releases the cloned material and the baked textures.
void ResolveCounts(const double extent[3], std::size_t budget, int counts[3]) const
void FinalSetup(const double T, const double *const X, ISimObjectCreator *Creator) override
Environment SimObjects.
Definition Environment.h:25
A scalar field evaluated over a SamplingBox and encoded to 16-bit codes.
Definition ScalarFieldBake.h:52
Definition ScalarFieldBake.h:44