FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
environmentmodels::VisualBakedScalarField Class Reference

#include <VisualBakedScalarField.h>

+ Inheritance diagram for environmentmodels::VisualBakedScalarField:
+ Collaboration diagram for environmentmodels::VisualBakedScalarField:

Public Member Functions

void FinalSetup (const double T, const double *const X, ISimObjectCreator *Creator) override
 
void OdeFcn (const double T, const double *const X, double *const XDot) const override
 No state; the ODE function is a no-op.
 

Protected Member Functions

 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 ValidateGridCounts (ISimObjectCreator *Creator, const int counts[3], const std::string &extentParameterName) const
 
bool MaskInaccurate () const
 
environment::field::ScalarField & Field () const
 

Detailed Description

Base class for visualisers that evaluate a scalar field once and let the GPU read it.

Owns everything the plane and the volume visualisers share: the XML parameters naming the field and its colour, visible and alpha ranges; the Spacing xor Resolution rule; resolving the field through the Environment Provider; deriving an encoding range, probing the field when the configuration states none; baking; uploading the bake; and cloning the material each instance writes its uniforms on.

The lifecycle split is deliberate and load-bearing. FinalSetup runs before RenderInit and is compiled in both builds, so every failure that does not need Ogre - a missing field, a time-dependent field without VisualiseAsConstant, an oversized grid - is detected in the constructor or in FinalSetup and is therefore reachable in the no-visualisation build.

Note
Derived classes own their geometry and release it in their own destructor; this class releases only the cloned material and the baked textures.

Constructor & Destructor Documentation

◆ VisualBakedScalarField()

environmentmodels::VisualBakedScalarField::VisualBakedScalarField ( std::string  SimObjectName,
ISimObjectCreator *  Creator,
int  numAxes 
)
protected

Read the shared XML parameters.

Parameters
[in]SimObjectNameUnique name for this simulation object.
[in]CreatorObject creator/registry.
[in]numAxesAxes the derived visualiser samples: 2 for a plane, 3 for a volume. Decides the length of Spacing and Resolution.
Exceptions
std::runtime_errorwhen both Spacing and Resolution are configured, or when FieldName is missing.

Member Function Documentation

◆ Field()

environment::field::ScalarField & environmentmodels::VisualBakedScalarField::Field ( ) const
protected

The resolved scalar field.

Returns
Reference to the field held since FinalSetup.
Exceptions
std::runtime_errorwhen called before FinalSetup.

◆ FinalSetup()

void environmentmodels::VisualBakedScalarField::FinalSetup ( const double  T,
const double *const  X,
ISimObjectCreator *  Creator 
)
override

Resolve the Environment Provider and the scalar field.

Parameters
[in]TSimulation time [s].
[in]XState vector.
[in]CreatorObject creator/registry.
Exceptions
std::runtime_errorwhen the Environment resource is absent, when no field named FieldName is registered, or when the field is not time-invariant and VisualiseAsConstant was not set.
Note
Not guarded by FH_VISUALIZATION, so these failures are reachable headless.

◆ MaskInaccurate()

bool environmentmodels::VisualBakedScalarField::MaskInaccurate ( ) const
inlineprotected

Whether a cell the field flagged as inaccurate is masked.

Returns
True unless ShowExtrapolated was set.

◆ ResolveCounts()

void environmentmodels::VisualBakedScalarField::ResolveCounts ( const double  extent[3],
std::size_t  budget,
int  counts[3] 
) const
protected

Turn the configured spacing or resolution into per-axis sample counts.

Uses Resolution when configured, Spacing when that is configured instead, and otherwise derives a spacing that lands near budget cells.

Parameters
[in]extentEdge length of each axis of the sampling box [m].
[in]budgetTarget cell count used when neither parameter is configured.
[out]countsResulting samples along each axis; each at least 1.

◆ ValidateGridCounts()

void environmentmodels::VisualBakedScalarField::ValidateGridCounts ( ISimObjectCreator *  Creator,
const int  counts[3],
const std::string &  extentParameterName 
) const
protected

Fail on a grid the render system could not hold.

Parameters
[in]CreatorObject creator/registry, used to report the failing parameter.
[in]countsSamples along each axis.
[in]extentParameterNameParameter naming the size of the sampled region - BoxSize for a volume, Size for a plane. It is blamed only when neither Spacing nor Resolution is configured, because the grid is then derived from that extent and no grid parameter exists to blame.
Exceptions
std::runtime_errorwhen the grid exceeds util::kMaxBakeCells, or when an axis exceeds util::kMaxAxisSize2D for a two-axis visualiser or util::kMaxAxisSize3D for a three-axis one.
Note
The cap follows the visualiser, not the counts: a volume one cell deep is still a 3-D texture and is held to the 3-D caps.
The baker checks the same caps. This check exists to name the parameter the user would change, which is why the derived case is reported differently: it must not blame a parameter that is absent from the input.

The documentation for this class was generated from the following file: