AGX Dynamics  2.37.2.0
MeshData.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 AGXCOLLIDE_MESHDATA_H
18 #define AGXCOLLIDE_MESHDATA_H
19 
20 #include <agx/agx_vector_types.h>
21 #include <agx/ref_ptr.h>
23 #include <agx/SPDMatrix3x3.h>
24 #include <agxStream/Serializable.h>
25 
26 namespace agxCollide
27 {
39  {
40  public:
41  friend class Mesh;
42  friend class Trimesh;
43  friend class HeightField;
44  friend class Convex;
45 
46  MeshData();
47 
48  agx::Vec3Vector& getVertices();
49  const agx::Vec3Vector& getVertices() const ;
50 
51  agx::UInt32Vector& getIndices();
52  const agx::UInt32Vector& getIndices() const;
53 
54  size_t getNumTriangles() const;
55 
56  const BoundingAABB& getBound() const;
57 
59 
60  protected:
62  virtual ~MeshData();
63  protected:
66  BoundingAABB m_bound; // Double storing (also in shape entity), here it is only used for graphics.
68  };
69 
72 
73 
76  {
77  public:
78  friend class Mesh;
79  friend class Trimesh;
80  friend class HeightField;
81  friend class Convex;
82 
84 
86  CollisionMeshData* deepCopy() const;
87 
89  const agx::Vec3Vector& getNormals() const;
90 
91  const agx::Real32Vector& getTriangleMaximumEdgeLengths() const;
92 
93  const agx::UInt32Vector& getHalfEdges() const;
94 
95  agx::Real getTotalMaximumEdgeLength() const;
96 
97  bool isValid() const;
98 
99  bool hasHalfEdge() const;
100 
101  const agx::SPDMatrix3x3& getInertia() const;
102 
103  agx::Vec3 getCenter() const;
104 
105  agx::Real getVolume() const;
106 
107  agx::Real getBottomMargin() const;
108 
109  bool isTerrain() const;
110 
111  bool hasInternalCenterPoint() const;
112 
114 
115  protected:
117  virtual ~CollisionMeshData();
118 
119  protected:
120  // Everything here should be added to the deepCopy()-method.
129  bool m_valid;
130  bool m_closed;
134  };
135 
138 
139 
142  {
143  public:
144  friend class HeightField;
145 
147 
149  agx::Vec2 getSize() const { return m_size; }
150 
152  agx::Vec2u32 getResolution() const;
153 
155  HeightFieldMeshData* deepCopy() const;
156 
157  protected:
159  virtual ~HeightFieldMeshData();
160  protected:
161  // Everything here should be added to the deepCopy()-method.
165  agx::Vec2 m_invScale; // Cached inverses of m_scale.
169  bool m_dynamic; // Are we interested of mass properties?
170  };
171 
174 
175 
176 
177  // Implementations
178 
180  {
181  return m_vertices;
182  }
183 
184 
186  {
187  return m_vertices;
188  }
189 
190 
192  {
193  return m_indices;
194  }
195 
196 
198  {
199  return m_indices;
200  }
201 
202 
204  {
205  return m_numTriangles;
206  }
207 
208 
210  {
211  return m_bound;
212  }
213 
214 
215 }
216 
217 #endif
218 
agx::Vec3Vector m_normals
Definition: MeshData.h:121
agx::UInt32Vector m_boundIndices
Definition: MeshData.h:162
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Definition: Mesh.h:69
Class for data sharing only to be used by Mesh, its internal classes and children.
Definition: MeshData.h:75
This namespace consists of a set of classes for handling geometric intersection tests including boole...
agx::ref_ptr< const MeshData > ConstMeshDataRef
Definition: MeshData.h:71
size_t m_numTriangles
Definition: MeshData.h:67
#define m_size
Definition: Vector.h:429
#define AGXPHYSICS_EXPORT
A convex class for geometric intersection tests.
Definition: Convex.h:36
agx::SPDMatrix3x3 m_inertia
Definition: MeshData.h:124
Class for data sharing only to be used by HeightField.
Definition: MeshData.h:141
#define AGX_FORCE_INLINE
Definition: Object.h:59
Base class providing referencing counted objects.
Definition: Referenced.h:119
agx::ref_ptr< HeightFieldMeshData > HeightFieldMeshDataRef
Definition: MeshData.h:172
AGXMODEL_EXPORT agx::Vec3 getCenter(const agxCollide::Mesh::Triangle &triangle)
agx::ref_ptr< CollisionMeshData > CollisionMeshDataRef
Definition: MeshData.h:136
agx::Vec3Vector m_vertices
Definition: MeshData.h:64
size_t getNumTriangles() const
Definition: MeshData.h:203
agx::UInt32Vector & getIndices()
Definition: MeshData.h:191
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
const BoundingAABB & getBound() const
Definition: MeshData.h:209
agx::UInt32Vector m_indices
Definition: MeshData.h:65
agx::Real32Vector m_triangleMaximumEdgeLengths
Definition: MeshData.h:122
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
BoundingAABB m_bound
Definition: MeshData.h:66
agx::Vec2 getSize() const
Definition: MeshData.h:149
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agx::UInt32Vector m_halfEdges
Definition: MeshData.h:123
agx::ref_ptr< MeshData > MeshDataRef
Definition: MeshData.h:70
agx::ref_ptr< const CollisionMeshData > ConstCollisionMeshDataRef
Definition: MeshData.h:137
double Real
Definition: Real.h:42
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:37
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
Stores triangle mesh data as triangle lists, i.e.
Definition: MeshData.h:38
A HeightField is a collision shape that can be created from a grid structure, like an image...
agx::Vec3Vector & getVertices()
Definition: MeshData.h:179
agx::Real m_totalMaximumEdgeLength
Definition: MeshData.h:126
agx::ref_ptr< const HeightFieldMeshData > ConstHeightFieldMeshDataRef
Definition: MeshData.h:173