VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
subsurfaceStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
12 #include <vrfutil/rwWindLevels.h>
13 #include <tbb/spin_rw_mutex.h>
14 
15 namespace makVrf
16 {
17 
19  {
21  : myDepth(0.)
22  , myPermeability(0.)
23  , myThickness(0.)
24  , myPriority(0)
25  {
26 
27  };
28  DtVrfSubsurfaceLayer(double depth, double thickness, double permeability, int priority)
29  : myDepth(depth)
30  , myThickness(thickness)
31  , myPermeability(permeability)
32  , myPriority(priority)
33  {
34 
35  };
37  {
38  *this = orig;
39  };
40 
42  {
43  {
44  myDepth = orig.myDepth;
45  myPermeability = orig.myPermeability;
46  myPriority = orig.myPriority;
47  myThickness = orig.myThickness;
48  }
49  return *this;
50  };
51 
52  bool operator<(const DtVrfSubsurfaceLayer& other) const
53  {
54  return myDepth < other.myDepth;
55  };
56 
57  bool operator==(const DtVrfSubsurfaceLayer& other) const
58  {
59  return (myDepth == other.myDepth
60  && myPriority == other.myPriority
61  && myThickness == other.myThickness
62  && myPermeability == other.myPermeability);
63  };
64  bool operator!=(const DtVrfSubsurfaceLayer& other) const
65  {
66  return !(*this == other);
67  };
68  ACCESSOR_MUTATOR_MEMBER(double, depth, Depth);
69  ACCESSOR_MUTATOR_MEMBER(double, thickness, Thickness);
70  ACCESSOR_MUTATOR_MEMBER(double, permeability, Permeability);
71  ACCESSOR_MUTATOR_MEMBER(int, priority, Priority);
72  };
73 
74  typedef std::multiset<DtVrfSubsurfaceLayer> DtVrfSubsurfaceLayerSet;
75 
76 
79  {
81  : myUnderwaterVisibility(0.)
82  , mySubsurfaceLayers()
83  , myAmbientWaterTemperature(0.)
84  , myPriority(0)
85  {};
86 
88  {
89  *this = orig;
90  };
91 
93  {
94  {
95  myUnderwaterVisibility = orig.myUnderwaterVisibility;
96  mySubsurfaceLayers = orig.mySubsurfaceLayers;
97  myAmbientWaterTemperature = orig.myAmbientWaterTemperature;
98  myPriority = orig.myPriority;
99  }
100  return *this;
101  };
102 
103  ACCESSOR_MUTATOR_MEMBER(double, underwaterVisibility, UnderwaterVisibility);
104  ACCESSOR_MUTATOR_MEMBER(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
105  ACCESSOR_MUTATOR_MEMBER(double, ambientWaterTemperature, AmbientWaterTemperature);
106  ACCESSOR_MUTATOR_MEMBER(unsigned int, priority, Priority);
107  };
108 
112  {
113  public:
115 
117  : DtFrameStateInterface(storage)
118  {
119  }
120 
121  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, underwaterVisibility, UnderwaterVisibility);
122  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
123  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer1Depth, ThermoclineLayer1Depth);
124  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer1Thickness, ThermoclineLayer1Thickness);
125  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer1Permeability, ThermoclineLayer1Permeability);
126  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer2Depth, ThermoclineLayer2Depth);
127  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer2Thickness, ThermoclineLayer2Thickness);
128  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer2Permeability, ThermoclineLayer2Permeability);
129  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer3Depth, ThermoclineLayer3Depth);
130  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer3Thickness, ThermoclineLayer3Thickness);
131  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer3Permeability, ThermoclineLayer3Permeability);
132  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer4Depth, ThermoclineLayer4Depth);
133  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer4Thickness, ThermoclineLayer4Thickness);
134  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer4Permeability, ThermoclineLayer4Permeability);
135  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer5Depth, ThermoclineLayer5Depth);
136  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer5Thickness, ThermoclineLayer5Thickness);
137  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer5Permeability, ThermoclineLayer5Permeability);
138  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, ambientWaterTemperature, AmbientWaterTemperature);
139  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, priority, Priority);
140 
141  virtual void addSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToAdd) { throw DtUnimplementedMethod("addSubsurfaceLayer is not implemented by this class."); };
142  virtual void removeSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToRemove) { throw DtUnimplementedMethod("removeSubsurfaceLayer is not implemented by this class."); };
143 
144  void setIsRemoteComponent(bool b) { myIsRemoteComponent = b; };
145 
146  protected:
147  bool myIsRemoteComponent = false;
148  };
149 
150 #define THERMOCLINE_GETTER(number, Accessor, Setter) \
151  const double thermoclineLayer##number####Setter() const override \
152  { \
153  const unsigned indexToUse = number - 1; \
154  DtVrfSubsurfaceLayer dummy; \
155  thermoclineLayer(indexToUse, dummy); \
156  return dummy.Accessor(); \
157  };
158 
159 #define THERMOCLINE_SETTER(number, Accessor, Setter) \
160  void setThermoclineLayer##number####Setter( const double& Accessor ) override \
161  { \
162  const unsigned indexToUse = number - 1; \
163  DtVrfSubsurfaceLayer dummy; \
164  thermoclineLayer(indexToUse, dummy); \
165  if (dummy.Accessor() != Accessor) \
166  { \
167  dummy.set##Setter(Accessor); \
168  markModified(); \
169  setThermoclineLayerByIndex(dummy, indexToUse); \
170  } \
171  };
172 
173 #define THERMOCLINE_SETTER_GETTER(number, Accessor, Setter) \
174  THERMOCLINE_GETTER(number, Accessor, Setter); \
175  THERMOCLINE_SETTER(number, Accessor, Setter);
176 
177 
178 
179 #define NEXTFRAME_ACCESSOR_MUTATOR_(MemberType, Accessor, MutatorAndMember) \
180  public: \
181  const MemberType Accessor() const override { return frameState().Accessor(); }; \
182  void set##MutatorAndMember(const MemberType& v) override { if (frameState().Accessor() != v) { markModified(); frameState().set##MutatorAndMember(v); } };
183 
185  class DT_DLL_vrfStateData DtSubsurfaceStateComponentNextFrame : public DtStateComponentNextFrameTemplate< DtSubsurfaceStateComponent, DtSubsurfaceStateComponentData >
186  {
187  public:
190  {
191 
192  };
194 
195  NEXTFRAME_ACCESSOR_MUTATOR(double, underwaterVisibility, UnderwaterVisibility);
196  NEXTFRAME_ACCESSOR_BY_REF_MUTATOR(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
197  NEXTFRAME_ACCESSOR_MUTATOR(double, ambientWaterTemperature, AmbientWaterTemperature);
198  NEXTFRAME_ACCESSOR_MUTATOR(int, priority, Priority);
199 
200  THERMOCLINE_SETTER_GETTER(1, depth, Depth);
201  THERMOCLINE_SETTER_GETTER(1, thickness, Thickness);
202  THERMOCLINE_SETTER_GETTER(1, permeability, Permeability);
203 
204  THERMOCLINE_SETTER_GETTER(2, depth, Depth);
205  THERMOCLINE_SETTER_GETTER(2, thickness, Thickness);
206  THERMOCLINE_SETTER_GETTER(2, permeability, Permeability);
207 
208  THERMOCLINE_SETTER_GETTER(3, depth, Depth);
209  THERMOCLINE_SETTER_GETTER(3, thickness, Thickness);
210  THERMOCLINE_SETTER_GETTER(3, permeability, Permeability);
211 
212  THERMOCLINE_SETTER_GETTER(4, depth, Depth);
213  THERMOCLINE_SETTER_GETTER(4, thickness, Thickness);
214  THERMOCLINE_SETTER_GETTER(4, permeability, Permeability);
215 
216  THERMOCLINE_SETTER_GETTER(5, depth, Depth);
217  THERMOCLINE_SETTER_GETTER(5, thickness, Thickness);
218  THERMOCLINE_SETTER_GETTER(5, permeability, Permeability);
219 
220  virtual void addSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToAdd) override;
221  virtual void removeSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToAdd) override;
222  protected:
223  bool thermoclineLayer(unsigned int index, DtVrfSubsurfaceLayer& layer) const;
224  bool removeThermoclineLayer(unsigned int index, DtVrfSubsurfaceLayer& layer);
225  void setThermoclineLayerByIndex(DtVrfSubsurfaceLayer layer, unsigned int index);
226 
227  protected:
228  mutable tbb::spin_rw_mutex myMutex;
229  };
230 
232  class DT_DLL_vrfStateData DtSubsurfaceStateComponentCurrentFrame : public DtStateComponentCurrentFrameTemplate< DtSubsurfaceStateComponent, DtSubsurfaceStateComponentNextFrame, DtSubsurfaceStateComponentData>
233  {
234  public:
237  {
238  };
239 
240  CURRENTFRAME_ACCESSOR(double, underwaterVisibility, UnderwaterVisibility);
241  CURRENTFRAME_ACCESSOR_BY_REF(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
242  CURRENTFRAME_ACCESSOR(double, ambientWaterTemperature, AmbientWaterTemperature);
243  CURRENTFRAME_ACCESSOR(int, priority, Priority);
244 
245 
246 
247  THERMOCLINE_GETTER(1, depth, Depth);
248  THERMOCLINE_GETTER(1, thickness, Thickness);
249  THERMOCLINE_GETTER(1, permeability, Permeability);
250 
251  THERMOCLINE_GETTER(2, depth, Depth);
252  THERMOCLINE_GETTER(2, thickness, Thickness);
253  THERMOCLINE_GETTER(2, permeability, Permeability);
254 
255  THERMOCLINE_GETTER(3, depth, Depth);
256  THERMOCLINE_GETTER(3, thickness, Thickness);
257  THERMOCLINE_GETTER(3, permeability, Permeability);
258 
259  THERMOCLINE_GETTER(4, depth, Depth);
260  THERMOCLINE_GETTER(4, thickness, Thickness);
261  THERMOCLINE_GETTER(4, permeability, Permeability);
262 
263  THERMOCLINE_GETTER(5, depth, Depth);
264  THERMOCLINE_GETTER(5, thickness, Thickness);
265  THERMOCLINE_GETTER(5, permeability, Permeability);
266 
267  protected:
268  bool thermoclineLayer(unsigned int index, DtVrfSubsurfaceLayer& layer) const;
269  };
270 
274 
278 
279 }
Definition: stateDataTypes.h:23
virtual void removeSubsurfaceLayer(const DtVrfSubsurfaceLayer &layerToRemove)
Definition: subsurfaceStateComponent.h:142
bool operator==(const DtVrfSubsurfaceLayer &other) const
Definition: subsurfaceStateComponent.h:57
DtVrfSubsurfaceLayer(const DtVrfSubsurfaceLayer &orig)
Definition: subsurfaceStateComponent.h:36
Definition: stateComponentImplementationTemplate.h:68
Definition: stateComponent.h:269
#define NEXTFRAME_ACCESSOR_BY_REF_MUTATOR(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:57
DtSubsurfaceStateComponentData()
Definition: subsurfaceStateComponent.h:80
virtual ~DtSubsurfaceStateComponentNextFrame() override
Definition: subsurfaceStateComponent.h:193
#define THERMOCLINE_GETTER(number, Accessor, Setter)
Definition: subsurfaceStateComponent.h:150
0) Define the State Component Data. This struct replaces the legion stuff
Definition: subsurfaceStateComponent.h:78
#define CURRENTFRAME_ACCESSOR_BY_REF(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:64
#define CURRENTFRAME_ACCESSOR(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:61
bool operator<(const DtVrfSubsurfaceLayer &other) const
Definition: subsurfaceStateComponent.h:52
Definition: stateComponentImplementationTemplate.h:87
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
#define NEXTFRAME_ACCESSOR_MUTATOR(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:49
DtSubsurfaceStateComponentCurrentFrame(DtStateData *sd)
Definition: subsurfaceStateComponent.h:235
2) Define the next frame class. This will be used for write access.
Definition: subsurfaceStateComponent.h:185
1) Define the interface class that will be used to represent the next and current frames...
Definition: subsurfaceStateComponent.h:111
DtVrfSubsurfaceLayer()
Definition: subsurfaceStateComponent.h:20
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
DtSubsurfaceStateComponentNextFrame(DtStateData *sd)
Definition: subsurfaceStateComponent.h:188
DtStateComponentCreator< DtSubsurfaceStateComponentImplementation > DtSubsurfaceStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: subsurfaceStateComponent.h:277
bool operator!=(const DtVrfSubsurfaceLayer &other) const
Definition: subsurfaceStateComponent.h:64
virtual void addSubsurfaceLayer(const DtVrfSubsurfaceLayer &layerToAdd)
Definition: subsurfaceStateComponent.h:141
DtVrfSubsurfaceLayer(double depth, double thickness, double permeability, int priority)
Definition: subsurfaceStateComponent.h:28
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
Definition: subsurfaceStateComponent.h:18
#define ACCESSOR_MUTATOR_MEMBER(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:25
DtSubsurfaceStateComponentData & operator=(const DtSubsurfaceStateComponentData &orig)
Definition: subsurfaceStateComponent.h:92
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:26
std::multiset< DtVrfSubsurfaceLayer > DtVrfSubsurfaceLayerSet
Definition: subsurfaceStateComponent.h:74
#define THERMOCLINE_SETTER_GETTER(number, Accessor, Setter)
Definition: subsurfaceStateComponent.h:173
3) Define the current frame class. This will be used for read access.
Definition: subsurfaceStateComponent.h:232
tbb::spin_rw_mutex myMutex
Definition: subsurfaceStateComponent.h:228
DtSubsurfaceStateComponentData(const DtSubsurfaceStateComponentData &orig)
Definition: subsurfaceStateComponent.h:87
Contains the DtStateComponent class declaration.
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
Definition: stateComponentImplementationTemplate.h:135
ACCESSOR_MUTATOR_MEMBER(double, depth, Depth)
DtVrfSubsurfaceLayer & operator=(const DtVrfSubsurfaceLayer &orig)
Definition: subsurfaceStateComponent.h:41
void setIsRemoteComponent(bool b)
Definition: subsurfaceStateComponent.h:144

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)