AGX Dynamics  2.38.0.2
WindAndWaterUtils.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXMODEL_WINDANDWATERUTILS_H
18 #define AGXMODEL_WINDANDWATERUTILS_H
19 
20 #include <agxModel/export.h>
21 
22 #include <agx/Vector.h>
23 #include <agx/Vec3.h>
24 
25 namespace agxModel
26 {
31  {
33 
37  agx::Bool isBelowSurface() const;
38 
42  agx::Bool isOnSurface( agx::Real threshold = agx::REAL_SQRT_EPSILON ) const;
43 
47  agx::Real totalPressure() const;
48 
55  };
56 
61  {
63 
64  enum State
65  {
66  BELOW_SURFACE = 1 << 0,
67  ABOVE_SURFACE = 1 << 1,
68  CLIPPED = 1 << 2,
69  CALCULATIONS_ENABLE = 1 << 3
70  };
71 
75  agx::Real calculateArea() const;
76 
80  agx::Vec3 calculateNormal() const;
81 
85  agx::Bool isClipped() const;
86 
90  agx::Bool isBelowSurface() const;
91 
95  agx::Bool isCalculationsEnable() const;
96 
97 
103  const agxModel::VertexData& getVertex( size_t i ) const;
104 
105 #ifndef SWIG
106  agxModel::VertexData vertices[ 3 ];
107 #endif
111  };
112 
117  {
119 
125  const TriangleData& getClipped( size_t i ) const;
126 
127 #ifndef SWIG
128  agx::UInt vertexIndices[ 3 ];
130 #endif
131  };
132 
134  {
135  return heightFromSurface < agx::Real( 0 );
136  }
137 
138  AGX_FORCE_INLINE agx::Bool VertexData::isOnSurface( agx::Real threshold /* = agx::REAL_SQRT_EPSILON */ ) const
139  {
140  return heightFromSurface > -threshold && heightFromSurface < threshold;
141  }
142 
144  {
145  return pressure + dynamicPressure;
146  }
147 
149  {
150  return (state & BELOW_SURFACE) != 0;
151  }
152 
154  {
155  return (state & CLIPPED) != 0;
156  }
157 
159  {
160  return (state & CALCULATIONS_ENABLE) != 0;
161  }
162 
163  inline const VertexData& TriangleData::getVertex( size_t i ) const
164  {
165  return vertices[ i ];
166  }
167 
168  inline const TriangleData& GlobalTriangleData::getClipped( size_t i ) const
169  {
170  agxAssert( isClipped() && i < 3u );
171  return clipped[ i ];
172  }
173 }
174 
175 #endif // AGXMODEL_WINDANDWATERUTILS_H
agx::REAL_SQRT_EPSILON
const AGXCORE_EXPORT Real REAL_SQRT_EPSILON
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agxModel::TriangleData::worldNormal
agx::Vec3 worldNormal
Normal to this triangle given in world coordinate system.
Definition: WindAndWaterUtils.h:108
agx::Real
double Real
Definition: Real.h:42
agxModel::VertexData::dynamicPressure
agx::Real dynamicPressure
Hydro- or aerostatic dynamic (drag, lift etc) pressure.
Definition: WindAndWaterUtils.h:54
Vector.h
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agx::Vector< GlobalTriangleData >
agxModel::VertexData::totalPressure
agx::Real totalPressure() const
Definition: WindAndWaterUtils.h:143
agxModel::VertexData::worldPosition
agx::Vec3 worldPosition
World position of this vertex.
Definition: WindAndWaterUtils.h:49
export.h
agxModel::VertexData::isOnSurface
agx::Bool isOnSurface(agx::Real threshold=agx::REAL_SQRT_EPSILON) const
Definition: WindAndWaterUtils.h:138
agxModel::VertexData
Vertex data for all global vertices in a mesh.
Definition: WindAndWaterUtils.h:30
agxModel::TriangleData::isBelowSurface
agx::Bool isBelowSurface() const
Definition: WindAndWaterUtils.h:148
agxAssert
#define agxAssert(expr)
Definition: debug.h:143
agxModel::GlobalTriangleData
Global triangle data (mapped with agxCollide::Mesh object) holding vertex indices.
Definition: WindAndWaterUtils.h:116
agx::VectorPOD< VertexData >
agxModel::TriangleData::vertices
agxModel::VertexData vertices[3]
Vertices of this triangle.
Definition: WindAndWaterUtils.h:106
agxModel::TriangleData::State
State
Definition: WindAndWaterUtils.h:64
agxModel::GlobalTriangleData::Container
agx::Vector< GlobalTriangleData > Container
Definition: WindAndWaterUtils.h:118
agxModel::TriangleData::getVertex
const agxModel::VertexData & getVertex(size_t i) const
There are three vertices in this triangle.
Definition: WindAndWaterUtils.h:163
Vec3.h
agxModel::VertexData::worldVelocityOfMedium
agx::Vec3 worldVelocityOfMedium
Velocity of the medium this vertex is in (water current or wind velocity).
Definition: WindAndWaterUtils.h:51
agxModel::TriangleData::state
agx::Int32 state
Current state of this triangle.
Definition: WindAndWaterUtils.h:110
agxModel::GlobalTriangleData::getClipped
const TriangleData & getClipped(size_t i) const
If isClipped() == true, access i'th clipped triangle (three of them).
Definition: WindAndWaterUtils.h:168
agxModel::TriangleData::BELOW_SURFACE
@ BELOW_SURFACE
Definition: WindAndWaterUtils.h:66
agxModel::TriangleData::CALCULATIONS_ENABLE
@ CALCULATIONS_ENABLE
Definition: WindAndWaterUtils.h:69
agxModel::VertexData::worldVelocity
agx::Vec3 worldVelocity
Velocity of this vertex given in world coordinate system.
Definition: WindAndWaterUtils.h:50
agxModel::TriangleData::area
agx::Real area
Area of this triangle.
Definition: WindAndWaterUtils.h:109
agx::Bool
bool Bool
Definition: Integer.h:40
agxModel::VertexData::pressure
agx::Real pressure
Hydro- or aerostatic pressure.
Definition: WindAndWaterUtils.h:53
agxModel::TriangleData::isClipped
agx::Bool isClipped() const
Definition: WindAndWaterUtils.h:153
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxModel::VertexData::heightFromSurface
agx::Real heightFromSurface
Height from surface, negative if below the surface.
Definition: WindAndWaterUtils.h:52
agxModel::TriangleData::isCalculationsEnable
agx::Bool isCalculationsEnable() const
Definition: WindAndWaterUtils.h:158
agx::Vec3T< Real >
agxModel::VertexData::isBelowSurface
agx::Bool isBelowSurface() const
Definition: WindAndWaterUtils.h:133
agxModel::TriangleData::Container
agx::VectorPOD< TriangleData > Container
Definition: WindAndWaterUtils.h:62
agx::Int32
int32_t Int32
Definition: Integer.h:37
agxModel::TriangleData
Triangle data for a normal or a clipped triangle.
Definition: WindAndWaterUtils.h:60
agxModel::GlobalTriangleData::clipped
agxModel::TriangleData::Container clipped
Container with clipped triangles if this global triangle has been clipped.
Definition: WindAndWaterUtils.h:129
agxModel::TriangleData::CLIPPED
@ CLIPPED
Definition: WindAndWaterUtils.h:68
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxModel::VertexData::Container
agx::VectorPOD< VertexData > Container
Definition: WindAndWaterUtils.h:32