VR-Forces 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 setObjectVertices(const std::vector<DtVector>& vertices) { throw DtUnimplementedMethod("bool setObjectVertices(const std::vector<DtVector>& vertices, DtVector& newGeometricCenter) is unimplemented."); };
124  virtual void setObjectVertices(const DtList& vertices) { throw DtUnimplementedMethod("bool setObjectVertices(const DtList& vertices, DtVector& newGeometricCenter) is unimplemented."); };
125 
126  virtual void addLocalVertex(const DtVector& vertex) { throw DtUnimplementedMethod("bool addLocalVertex(const DtVector& vertex) is unimplemented."); };
127  virtual void addLocalVertex(const DtVector& vertex, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool addLocalVertex(const DtVector& vertex, DtVector& newGeometricCenter) is unimplemented."); };
128  virtual void addWorldVertex(const DtVector& vertex, DtVector& newGeometricCenter) { throw DtUnimplementedMethod("bool addWorldVertex(const DtVector& vertex, DtVector& newGeometricCenter) is unimplemented."); };
129 
131  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_objectVerticesChanged;
132  };
133 
136  {
137  public:
139 
141  const DtVrfGeometryStateComponentData& frameState() const { return myData; };
143 
144  const DtLocalVertexList& localVertices() const;
145  DtLocalVertexList& localVertices();
146 
147  const DtVertexList& worldVertices() const;
148  DtVertexList& worldVertices();
149 
150  const DtLocalVertexList& objectVertices() const;
151  DtLocalVertexList& objectVertices();
152 
153  const Dt3dBoundingVolume& boundingVolume() const;
154  const DtVrfObjectGeometry& objectGeometry() const;
155  const bool closedFigure() const;
156  const bool ellipsoid() const;
157  const bool projection() const ;
158  void setClosedFigure(const bool& b);
159  void setEllipsoid(const bool& b);
160  void setProjection(const bool& b);
161  void setBoundingVolume(const Dt3dBoundingVolume& b);
162  void setHalfLengthWidthHeight(double l, double w, double h);
163  void setBoundingGeometryType(DtSimBoundingGeometry::DtSimBoundingGeometryType type);
164  void updateVertices();
165  bool calculateBodyCoordinates(DtLocalVertexList& newList) const;
166  void calculateLocalVertices(DtLocalVertexList& newList) const;
167  bool calculateWorldVertices(DtVertexList& newList) const;
168  void removeVertex(int);
169  const bool& objectVerticesChanged() const;
170  void setObjectVerticesChanged(const bool&);
171  const bool& worldVerticesChanged() const;
172  void setWorldVerticesChanged(const bool&);
173  double distSquaredTo(const DtVector& testPoint) const;
174  bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const;
175  bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
176  double worldDistSquaredTo(const DtVector& testPoint) const;
177  bool worldGetClosestVertex(const DtVector& point, DtVector& vertex) const;
178  bool worldGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
179  const DtSimBoundingGeometry& boundingGeometry() const;
180  void setObjectGeometry(const DtVrfObjectGeometry&);
181  void setToObjectGeometry(DtVrfObjectGeometry&) const;
182  void setEngineeringArea(const DtVector&);
183 
184  virtual void setLocalVertices(const DtList& vertices, DtVector& newGeometricCenter);
185  virtual void setLocalVertices(const DtLocalVertexList& vertices, DtVector& newGeometricCenter);
186 
187  virtual void setWorldVertices(const std::vector<DtVector>& vertices, DtVector& newGeometricCenter);
188  virtual void setWorldVertices(const DtVertexList& vertices, DtVector& newGeometricCenter);
189  virtual void setWorldVertices(const DtList& vertices, DtVector& newGeometricCenter);
190 
191  virtual void setObjectVertices(const std::vector<DtVector>& vertices);
192  virtual void setObjectVertices(const DtList& vertices);
193 
194  virtual void addLocalVertex(const DtVector& vertex);
195  virtual void addLocalVertex(const DtVector& vertex, DtVector& newGeometricCenter);
196  virtual void addWorldVertex(const DtVector& vertex, DtVector& newGeometricCenter);
197 
199  virtual void makeWritable() {};
200 
202  virtual void makeReadOnly() {};
203 
204  bool needsUpdateVertices() const
205  {
206  return myNeedsUpdateVertices;
207  }
208 
210  {
211  myNeedsUpdateVertices = b;
212  }
213 
214  protected:
216  virtual void setPointRecordsIntoEnvironmental();
217 
218  protected:
225  };
226 
229  {
230  public:
233 
235  const DtVrfGeometryStateComponentData& frameState() const { return myData; };
236 
237  const Dt3dBoundingVolume& boundingVolume() const;
238  const DtLocalVertexList& localVertices() const;
239  const DtVertexList& worldVertices() const;
240  const DtLocalVertexList& objectVertices() const;
241  const bool closedFigure() const;
242  const bool ellipsoid() const;
243  const bool projection() const;
244  void updateVertices();
245  double distSquaredTo(const DtVector& testPoint) const;
246  bool localGetClosestVertex(const DtVector& point, DtVector& vertex) const;
247  bool localGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
248  double worldDistSquaredTo(const DtVector& testPoint) const;
249  bool worldGetClosestVertex(const DtVector& point, DtVector& vertex) const;
250  bool worldGetClosestLine(const DtVector& point, DtVector& linePt1, DtVector& linePt2) const;
251  const DtSimBoundingGeometry& boundingGeometry() const;
252  const DtVrfObjectGeometry& objectGeometry() const;
253  virtual void setToObjectGeometry(DtVrfObjectGeometry&) const;
254 
255  void setObjectVerticesChanged(const bool&);
256  const bool& objectVerticesChanged() const;
257 
258  void setWorldVerticesChanged(const bool&);
259  const bool& worldVerticesChanged() const;
260 
261  protected:
262  virtual void handleDataUpdated();
263  bool calculateBodyCoordinates(DtLocalVertexList& newList) const;
264  void calculateLocalVertices(DtLocalVertexList& newList) const;
265  bool calculateWorldVertices(DtVertexList& newList) const;
266 
267  protected:
269  void watchEnvironmentalChanges();
271  {
272  myData = data;
273  }
274 
275  protected:
278  unsigned int myCallbackHandle;
280  boost::signals2::scoped_connection myCompleteSetupConnection;
281 
282  private:
285  };
286 
290  {
291  public:
293 
294  bool isDoubleBuffered() { return true; };
295  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
296  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
297  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
298 
299  void updateDataStorage();
300 
302  virtual bool forceAdvance();
303 
304  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
305 
306  virtual void aboutToBeDeleted() override
307  {
309  myCurrentFrameState.aboutToBeDeleted();
310  myNextFrameState.aboutToBeDeleted();
311  }
312 
313  virtual void updateStateData(DtStateData* sd)
314  {
315  myCurrentFrameState.updateStateData(sd);
316  myNextFrameState.updateStateData(sd);
317  }
318 
319  virtual void advanceFrame();
320 
321  protected:
326  };
327 
331 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
const DtFrameStateInterface * currentFrameState() const
Definition: vrfGeometryStateComponent.h:295
Definition: stateDataTypes.h:23
const DtVrfGeometryStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: vrfGeometryStateComponent.h:235
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:313
#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 void setObjectVertices(const std::vector< DtVector > &vertices)
Definition: vrfGeometryStateComponent.h:123
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
virtual void setObjectVertices(const DtList &vertices)
Definition: vrfGeometryStateComponent.h:124
bool myWorldVerticesChanged
Definition: vrfGeometryStateComponent.h:221
Definition: stateComponent.h:266
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:127
3) Define the current frame class. This will be used for read access.
Definition: vrfGeometryStateComponent.h:228
DtVrfGeometryStateComponentData & frameState()
Definition: vrfGeometryStateComponent.h:142
DtVector myParentLocation
Definition: vrfGeometryStateComponent.h:325
virtual void setWorldVertices(const DtList &vertices, DtVector &newGeometricCenter)
Definition: vrfGeometryStateComponent.h:121
unsigned int myCallbackHandle
Definition: vrfGeometryStateComponent.h:278
bool isDoubleBuffered()
Definition: vrfGeometryStateComponent.h:294
#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:276
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:141
#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:202
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:222
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:323
DtVrfGeometryStateComponentData & operator=(const DtVrfGeometryStateComponentData &rhs)
Definition: vrfGeometryStateComponent.h:32
bool needsUpdateVertices() const
Definition: vrfGeometryStateComponent.h:204
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: vrfGeometryStateComponent.h:289
const DtLocationStateComponent * myLocationStateComponent
Definition: vrfGeometryStateComponent.h:324
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:339
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
DtVrfGeometryStateComponentCurrentFrame myCurrentFrameState
Definition: vrfGeometryStateComponent.h:322
void advanceFrame(const DtVrfGeometryStateComponentData &data)
Definition: vrfGeometryStateComponent.h:270
virtual DtFrameStateInterface * nextFrameState()
Definition: vrfGeometryStateComponent.h:296
UInt64 myEnvironmentInstanceHandle
Definition: vrfGeometryStateComponent.h:279
class DtVertexList:
Definition: vertexList.h:22
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
DtStateComponentCreator< DtVrfGeometryStateComponentImplementation > DtVrfGeometryStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: vrfGeometryStateComponent.h:330
void setNeedsUpdateVertices(bool b)
Definition: vrfGeometryStateComponent.h:209
virtual void addLocalVertex(const DtVector &vertex)
Definition: vrfGeometryStateComponent.h:126
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
#define UNDEFINED_RETURNREF_CONST_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:37
unsigned long long UInt64
Definition: stateDataTypes.h:17
virtual void aboutToBeDeleted()
bool myWorldVerticesChanged
Definition: vrfGeometryStateComponent.h:277
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:223
virtual void aboutToBeDeleted() override
Definition: vrfGeometryStateComponent.h:306
#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:199
DtStateData * myStateData
Definition: vrfGeometryStateComponent.h:219
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:297
boost::signals2::scoped_connection myCompleteSetupConnection
Definition: vrfGeometryStateComponent.h:280
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:284
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:224
Contains the DtStateComponent class declaration.
DtStateData * myStateData
Definition: vrfGeometryStateComponent.h:283
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:291
2) Define the next frame class. This will be used for write access.
Definition: vrfGeometryStateComponent.h:135
bool myObjectVerticesChanged
Definition: vrfGeometryStateComponent.h:220

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)