VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vrfGeometryStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
12 #include <vrfutil/vertexList.h>
13 namespace makVrf
14 {
15  class DtLocationStateComponent;
16 
18  {
20  : myLocalVertices("local")
21  , myWorldVertices("world")
22  {
23  }
24 
26  : myObjectGeometry(orig.myObjectGeometry)
27  {
28  myLocalVertices = orig.myLocalVertices;
29  myWorldVertices = orig.myWorldVertices;
30  }
31 
33  {
34  myObjectGeometry = rhs.myObjectGeometry;
35  myLocalVertices = rhs.myLocalVertices;
36  myWorldVertices = rhs.myWorldVertices;
37 
38  return *this;
39  }
40 
41 
42  DEFINE_REF_ACCESSORS(DtVrfObjectGeometry, objectGeometry, ObjectGeometry)
43  DEFINE_REF_ACCESSORS(DtLocalVertexList, localVertices, LocalVertices)
44  DEFINE_REF_ACCESSORS(DtVertexList, worldVertices, WorldVertices)
45 
46  protected:
47  DtVrfObjectGeometry myObjectGeometry;
48  DtLocalVertexList myLocalVertices;
49  DtVertexList myWorldVertices;
50  };
51 
55  {
56  public:
58 
60  : DtFrameStateInterface(storage)
61  {
62  }
63 
69  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, closedFigure, ClosedFigure)
70  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, ellipsoid, Ellipsoid)
71  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, projection, Projection)
72  UNDEFINED_RETURNREF_CONST_ACCESSOR(Dt3dBoundingVolume, boundingVolume)
73  UNDEFINED_MUTATOR_WITH_ARGS(BoundingVolume, const Dt3dBoundingVolume& b)
74  UNDEFINED_MUTATOR_WITH_ARGS(HalfLengthWidthHeight, double l, double w, double h)
75  UNDEFINED_MUTATOR_WITH_ARGS(BoundingGeometryType, DtSimBoundingGeometry::DtSimBoundingGeometryType type)
76  UNDEFINED_MUTATOR_WITH_ARGS(EngineeringArea, const DtVector&)
77  UNDEFINED_METHOD(void, updateVertices)
78  UNDEFINED_METHOD(void, removeVertex, int)
79  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, objectVerticesChanged, ObjectVerticesChanged)
80  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, worldVerticesChanged, WorldVerticesChanged)
81  UNDEFINED_METHOD(void, setObjectGeometry, const DtVrfObjectGeometry&)
82  virtual const DtSimBoundingGeometry& localBoundingGeometry() const { return boundingGeometry(); };
83  virtual const DtSimBoundingGeometry& worldBoundingGeometry() const { return boundingGeometry(); };
84  virtual void setToObjectGeometry(DtVrfObjectGeometry&) const { throw DtUnimplementedMethod("void setToObjectGeometry(DtVrfObjectGeometry&) const is unimplemented."); };
85 
89  virtual double distSquaredTo(const DtVector& testPoint) const { throw DtUnimplementedMethod("double distSquaredTo(const DtVector& testPoint) const is unimplemented."); };
90 
93  virtual bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const { throw DtUnimplementedMethod("bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const is unimplemented."); };
94 
99  virtual bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const { throw DtUnimplementedMethod("bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const is unimplemented."); };
100 
104  virtual double worldDistSquaredTo(const DtVector& testPoint) const { throw DtUnimplementedMethod("double distSquaredTo(const DtVector& testPoint) const is unimplemented."); };
105 
108  virtual bool worldGetClosestVertex(const DtVector& point, DtVector& vertex) const { throw DtUnimplementedMethod("bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const is unimplemented."); };
109 
114  virtual bool worldGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const { throw DtUnimplementedMethod("bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const is unimplemented."); };
115 
116  virtual void setLocalVertices(const DtList& vertices, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool setVertices(const DtList& vertices, DtVector& newGeometricCenter) is unimplemented."); };
117  virtual void setLocalVertices(const DtLocalVertexList& vertices, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool setLocalVertices(const DtVertexList& vertices, DtVector& newGeometricCenter) is unimplemented."); };
118 
119  virtual void setWorldVertices(const std::vector<DtVector>& vertices, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool setWorldVertices(const std::vector<DtVector>& vertices, DtVector& newGeometricCenter) is unimplemented."); };
120  virtual void setWorldVertices(const DtVertexList& vertices, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool setWorldVertices(const DtVertexList& vertices, DtVector& newGeometricCenter) is unimplemented."); };
121  virtual void setWorldVertices(const DtList& vertices, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool setWorldVertices(const DtList& vertices, DtVector& newGeometricCenter) is unimplemented."); };
122 
123  virtual void addLocalVertex(const DtVector& vertex) { throw DtUnimplementedMethod("bool addLocalVertex(const DtVector& vertex) is unimplemented."); };
124  virtual void addLocalVertex(const DtVector& vertex, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool addLocalVertex(const DtVector& vertex, DtVector& newGeometricCenter) is unimplemented."); };
125  virtual void addWorldVertex(const DtVector& vertex, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool addWorldVertex(const DtVector& vertex, DtVector& newGeometricCenter) is unimplemented."); };
126 
128  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_objectVerticesChanged;
129  };
130 
133  {
134  public:
136 
138  const DtVrfGeometryStateComponentData& frameState() const { return myData; };
140 
141  const DtLocalVertexList& localVertices() const;
142  DtLocalVertexList& localVertices();
143 
144  const DtVertexList& worldVertices() const;
145  DtVertexList& worldVertices();
146 
147  const DtLocalVertexList& objectVertices() const;
148  DtLocalVertexList& objectVertices();
149 
150  const Dt3dBoundingVolume& boundingVolume() const;
151  const DtVrfObjectGeometry& objectGeometry() const;
152  const bool closedFigure() const;
153  const bool ellipsoid() const;
154  const bool projection() const ;
155  void setClosedFigure(const bool& b);
156  void setEllipsoid(const bool& b);
157  void setProjection(const bool& b);
158  void setBoundingVolume(const Dt3dBoundingVolume& b);
159  void setHalfLengthWidthHeight(double l, double w, double h);
160  void setBoundingGeometryType(DtSimBoundingGeometry::DtSimBoundingGeometryType type);
161  void updateVertices();
162  bool calculateBodyCoordinates(DtLocalVertexList& newList) const;
163  void calculateLocalVertices(DtLocalVertexList& newList) const;
164  bool calculateWorldVertices(DtVertexList& newList) const;
165  void removeVertex(int);
166  const bool& objectVerticesChanged() const;
167  void setObjectVerticesChanged(const bool&);
168  const bool& worldVerticesChanged() const;
169  void setWorldVerticesChanged(const bool&);
170  double distSquaredTo(const DtVector& testPoint) const;
171  bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const;
172  bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
173  double worldDistSquaredTo(const DtVector& testPoint) const;
174  bool worldGetClosestVertex(const DtVector& point, DtVector& vertex) const;
175  bool worldGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
176  const DtSimBoundingGeometry& boundingGeometry() const;
177  void setObjectGeometry(const DtVrfObjectGeometry&);
178  void setToObjectGeometry(DtVrfObjectGeometry&) const;
179  void setEngineeringArea(const DtVector&);
180 
181  virtual void setLocalVertices(const DtList& vertices, DtVector& newGeometricCenter);
182  virtual void setLocalVertices(const DtLocalVertexList& vertices, DtVector& newGeometricCenter);
183 
184  virtual void setWorldVertices(const std::vector<DtVector>& vertices, DtVector& newGeometricCenter);
185  virtual void setWorldVertices(const DtVertexList& vertices, DtVector& newGeometricCenter);
186  virtual void setWorldVertices(const DtList& vertices, DtVector& newGeometricCenter);
187 
188  virtual void addLocalVertex(const DtVector& vertex);
189  virtual void addLocalVertex(const DtVector& vertex, DtVector& newGeometricCenter);
190  virtual void addWorldVertex(const DtVector& vertex, DtVector& newGeometricCenter);
191 
193  virtual void makeWritable() {};
194 
196  virtual void makeReadOnly() {};
197 
198  bool needsUpdateVertices() const
199  {
200  return myNeedsUpdateVertices;
201  }
202 
204  {
205  myNeedsUpdateVertices = b;
206  }
207 
208  protected:
210  virtual void setPointRecordsIntoEnvironmental();
211 
212  protected:
219  };
220 
223  {
224  public:
227 
229  const DtVrfGeometryStateComponentData& frameState() const { return myData; };
230 
231  const Dt3dBoundingVolume& boundingVolume() const;
232  const DtLocalVertexList& localVertices() const;
233  const DtVertexList& worldVertices() const;
234  const DtLocalVertexList& objectVertices() const;
235  const bool closedFigure() const;
236  const bool ellipsoid() const;
237  const bool projection() const;
238  void updateVertices();
239  double distSquaredTo(const DtVector& testPoint) const;
240  bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const;
241  bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
242  double worldDistSquaredTo(const DtVector& testPoint) const;
243  bool worldGetClosestVertex(const DtVector& point, DtVector& vertex) const;
244  bool worldGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
245  const DtSimBoundingGeometry& boundingGeometry() const;
246  const DtVrfObjectGeometry& objectGeometry() const;
247  virtual void setToObjectGeometry(DtVrfObjectGeometry&) const;
248 
249  void setObjectVerticesChanged(const bool&);
250  const bool& objectVerticesChanged() const;
251 
252  void setWorldVerticesChanged(const bool&);
253  const bool& worldVerticesChanged() const;
254 
255  protected:
256  virtual void handleDataUpdated();
257  bool calculateBodyCoordinates(DtLocalVertexList& newList) const;
258  void calculateLocalVertices(DtLocalVertexList& newList) const;
259  bool calculateWorldVertices(DtVertexList& newList) const;
260 
261  protected:
263  void watchEnvironmentalChanges();
265  {
266  myData = data;
267  }
268 
269  protected:
272  unsigned int myCallbackHandle;
274  boost::signals2::scoped_connection myCompleteSetupConnection;
275 
276  private:
279  };
280 
284  {
285  public:
287 
288  bool isDoubleBuffered() { return true; };
289  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
290  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
291  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
292 
293  void updateDataStorage();
294 
296  virtual bool forceAdvance();
297 
298  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
299 
300  virtual void aboutToBeDeleted() override
301  {
303  myCurrentFrameState.aboutToBeDeleted();
304  myNextFrameState.aboutToBeDeleted();
305  }
306 
307  virtual void updateStateData(DtStateData* sd)
308  {
309  myCurrentFrameState.updateStateData(sd);
310  myNextFrameState.updateStateData(sd);
311  }
312 
313  virtual void advanceFrame();
314 
315  protected:
320  };
321 
325 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
const DtFrameStateInterface * currentFrameState() const
Definition: vrfGeometryStateComponent.h:289
Definition: stateDataTypes.h:23
const DtVrfGeometryStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: vrfGeometryStateComponent.h:229
virtual const DtSimBoundingGeometry & worldBoundingGeometry() const
Definition: vrfGeometryStateComponent.h:83
virtual void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: vrfGeometryStateComponent.h:307
#define UNDEFINED_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:68
virtual void setToObjectGeometry(DtVrfObjectGeometry &) const
Definition: vrfGeometryStateComponent.h:84
DtVrfGeometryStateComponentData(const DtVrfGeometryStateComponentData &orig)
Definition: vrfGeometryStateComponent.h:25
virtual bool localGetClosestVertex(const DtVector &point, DtVector &vertex) const
Determines the closest vertex in the object’s geometry to a given point, in local coordinates.
Definition: vrfGeometryStateComponent.h:93
DtLocalVertexList myLocalVertices
Definition: vrfGeometryStateComponent.h:48
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
Class Description: DtSimBoundingGeometry describes on objects bounding volume or bounding area (or no...
Definition: simBoundingGeometry.h:57
virtual void setLocalVertices(const DtLocalVertexList &vertices, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:117
bool myWorldVerticesChanged
Definition: vrfGeometryStateComponent.h:215
Definition: stateComponent.h:257
virtual bool worldGetClosestLine(const DtVector &point, DtVector &linePt1, DtVector &linePt2) const
Determines the closest line segment in the object’s geometry to a given point, in world coordinates...
Definition: vrfGeometryStateComponent.h:114
virtual void addLocalVertex(const DtVector &vertex, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:124
3) Define the current frame class. This will be used for read access.
Definition: vrfGeometryStateComponent.h:222
DtVrfGeometryStateComponentData & frameState()
Definition: vrfGeometryStateComponent.h:139
DtVector myParentLocation
Definition: vrfGeometryStateComponent.h:319
virtual void setWorldVertices(const DtList &vertices, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:121
unsigned int myCallbackHandle
Definition: vrfGeometryStateComponent.h:272
bool isDoubleBuffered()
Definition: vrfGeometryStateComponent.h:288
#define UNDEFINED_MUTATOR_WITH_ARGS(Set,...)
Definition: doubleBufferedDataStorage.h:47
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
Definition: vrfGeometryStateComponent.h:17
bool myObjectVerticesChanged
Definition: vrfGeometryStateComponent.h:270
const DtVrfGeometryStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: vrfGeometryStateComponent.h:138
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:34
virtual double worldDistSquaredTo(const DtVector &testPoint) const
Returns the squared distance from a given point in world coordinates, to the object. If the object has more than two vertices (that is, more than one line segment), it acts on the closest line segment.
Definition: vrfGeometryStateComponent.h:104
virtual void makeReadOnly()
Override to make component read-only.
Definition: vrfGeometryStateComponent.h:196
virtual bool localGetClosestLine(const DtVector &point, DtVector &linePt1, DtVector &linePt2) const
Determines the closest line segment in the object’s geometry to a given point, in local coordinates...
Definition: vrfGeometryStateComponent.h:99
bool myNeedsUpdateVertices
Definition: vrfGeometryStateComponent.h:216
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: vrfGeometryStateComponent.h:54
DtVrfGeometryStateComponentNextFrame myNextFrameState
Definition: vrfGeometryStateComponent.h:317
DtVrfGeometryStateComponentData & operator=(const DtVrfGeometryStateComponentData &rhs)
Definition: vrfGeometryStateComponent.h:32
bool needsUpdateVertices() const
Definition: vrfGeometryStateComponent.h:198
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: vrfGeometryStateComponent.h:283
const DtLocationStateComponent * myLocationStateComponent
Definition: vrfGeometryStateComponent.h:318
virtual void setWorldVertices(const DtVertexList &vertices, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:120
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:219
DtVrfGeometryStateComponentCurrentFrame myCurrentFrameState
Definition: vrfGeometryStateComponent.h:316
void advanceFrame(const DtVrfGeometryStateComponentData &data)
Definition: vrfGeometryStateComponent.h:264
virtual DtFrameStateInterface * nextFrameState()
Definition: vrfGeometryStateComponent.h:290
UInt64 myEnvironmentInstanceHandle
Definition: vrfGeometryStateComponent.h:273
class DtVertexList:
Definition: vertexList.h:22
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:370
DtStateComponentCreator< DtVrfGeometryStateComponentImplementation > DtVrfGeometryStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: vrfGeometryStateComponent.h:324
void setNeedsUpdateVertices(bool b)
Definition: vrfGeometryStateComponent.h:203
virtual void addLocalVertex(const DtVector &vertex)
Definition: vrfGeometryStateComponent.h:123
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
#define UNDEFINED_RETURNREF_CONST_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:37
virtual void aboutToBeDeleted()
bool myWorldVerticesChanged
Definition: vrfGeometryStateComponent.h:271
DtSimBoundingGeometryType
Definition: simBoundingGeometry.h:61
This class maintains a rectangular bounding volume and an ordered list of vertices describing the phy...
Definition: vrfObjectGeometry.h:39
UInt64 myLastRecordAdd
Definition: vrfGeometryStateComponent.h:217
virtual void aboutToBeDeleted() override
Definition: vrfGeometryStateComponent.h:300
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
#define DEFINE_REF_ACCESSORS(ReturnType, Method, Member)
Definition: doubleBufferedDataStorage.h:13
DtVrfObjectGeometry myObjectGeometry
Definition: vrfGeometryStateComponent.h:47
DtVertexList myWorldVertices
Definition: vrfGeometryStateComponent.h:49
virtual void makeWritable()
Override to make component writable.
Definition: vrfGeometryStateComponent.h:193
DtStateData * myStateData
Definition: vrfGeometryStateComponent.h:213
virtual double distSquaredTo(const DtVector &testPoint) const
Returns the squared distance from a given point in local coordinates, to the object. If the object has more than two vertices (that is, more than one line segment), it acts on the closest line segment.
Definition: vrfGeometryStateComponent.h:89
virtual const DtFrameStateInterface * nextFrameState() const
Definition: vrfGeometryStateComponent.h:291
boost::signals2::scoped_connection myCompleteSetupConnection
Definition: vrfGeometryStateComponent.h:274
virtual void setLocalVertices(const DtList &vertices, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:116
DtVrfGeometryStateComponentData()
Definition: vrfGeometryStateComponent.h:19
#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
DtVrfGeometryStateComponentData myData
Definition: vrfGeometryStateComponent.h:278
virtual bool worldGetClosestVertex(const DtVector &point, DtVector &vertex) const
Determines the closest vertex in the object’s geometry to a given point, in world coordinates.
Definition: vrfGeometryStateComponent.h:108
class DtLocalVertexList:
Definition: localVertexList.h:20
DtVrfGeometryStateComponentData myData
Definition: vrfGeometryStateComponent.h:218
Contains the DtStateComponent class declaration.
DtStateData * myStateData
Definition: vrfGeometryStateComponent.h:277
virtual void setWorldVertices(const std::vector< DtVector > &vertices, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:119
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:282
2) Define the next frame class. This will be used for write access.
Definition: vrfGeometryStateComponent.h:132
bool myObjectVerticesChanged
Definition: vrfGeometryStateComponent.h:214

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)