AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
Trimesh.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXCOLLIDE_TRIMESH_H
18#define AGXCOLLIDE_TRIMESH_H
19
21
23#include <agxCollide/Mesh.h>
24
26
27#include <agxData/LocalVector.h>
28
29
30
31namespace agxCollide
32{
34
40 {
41 public:
42
51 CLOCKWISE_ORIENTATION = 0x1,
64 NO_WARNINGS = 0x10,
69 TERRAIN = 0x20,
74 REMOVE_DUPLICATE_VERTICES = 0x40,
79 RECALCULATE_NORMALS_GIVEN_FIRST_TRIANGLE = 0x80
80 };
81
82
84 // Trimesh member declarations //
86
87 // Constructors //
88
131 const agx::Vec3Vector* vertices, const agx::UInt32Vector* indices,
132 const char* sourceName, uint32_t optionsMask = Trimesh::REMOVE_DUPLICATE_VERTICES, agx::Real bottomMargin = 0);
133
134 // Accessors //
135
143 virtual void calculatePossibleTriangleOverlapsAlongLineSegment(
144 const agx::Vec3& segmentStartLocal,
145 const agx::Vec3& segmentEndLocal,
146 agx::UInt32Vector& triangleIndices) const override;
147
155 virtual void calculatePossibleTriangleOverlapsAlongLineSegment(
156 const agx::Vec3& segmentStartLocal,
157 const agx::Vec3& segmentEndLocal,
158 agxData::LocalVector<agx::UInt32>& triangleIndices) const override;
159
160 virtual Shape* clone() const override;
161
170
180
189 void updateMeshGeometry(bool showWarnings, bool recalculateMassProperties = true);
190
192 uint32_t getOptionsMask() const;
193
196
202 const agx::String& getWarnings() const;
203
207 bool isShallowCopy() const;
208
213
215
216 private:
218 Trimesh();
219
221 Trimesh(const Trimesh& trimesh);
222
224 Trimesh& operator=(const Trimesh& trimesh);
225
243 void addConstructionData(const agx::Vec3Vector* vertices,
244 const agx::UInt32Vector* indices,
245 const char* sourceName,
246 uint32_t optionsMask);
247
252 void finalize(const char* sourceName, bool showWarnings, uint32_t optionsMask);
253
258 void flipNormal(const size_t triangleIndex);
259
263 bool getTriangleHalfEdgePartnerTriangleIndexAndLocalEdgeIndex(const size_t triangleIndex, const size_t localEdgeIndex, size_t& neighborIndex, size_t& neighborLocalEdgeIndex);
264
265
266
267 protected:
271 void calculateMassProperties(bool showWarnings);
272
280 void finalizeMeshTopology(bool showWarnings, uint32_t optionsMask);
281
284 const char* sourceName, uint32_t optionsMask = 0);
285
288
289 // Sets the values in a shallow-copy way.
290 void setValuesAsShallowCopy(const Trimesh* other);
291
293 virtual ~Trimesh();
294
296 virtual void updateBvhTree() override;
297
298
299 protected:
304
305 };
306
307
308 // Implementations
309
311 const agx::Vec3& segmentStartLocal,
312 const agx::Vec3& segmentEndLocal,
313 agx::UInt32Vector& triangleIndices) const
314 {
315 this->getBvhTree()->findCollisionWithLineSegment(segmentStartLocal, segmentEndLocal, triangleIndices);
316 }
317
318
319
321 const agx::Vec3& segmentStartLocal,
322 const agx::Vec3& segmentEndLocal,
323 agxData::LocalVector<agx::UInt32>& triangleIndices) const
324 {
325 this->getBvhTree()->findCollisionWithLineSegment(segmentStartLocal, segmentEndLocal, triangleIndices);
326 }
327
328}
329
330#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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
#define AGXPHYSICS_EXPORT
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Definition: Mesh.h:70
const AabbTree * getBvhTree() const
Definition: Mesh.h:883
Base class for a shape.
Definition: Shape.h:58
Type
Define the type of a Shape.
Definition: Shape.h:62
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:40
virtual ~Trimesh()
Hiding destructor.
agx::ref_ptr< const Trimesh > m_shallowCopySource
Definition: Trimesh.h:303
const Trimesh * getShallowCopySource()
virtual void updateBvhTree() override
Update the bounding volume hierarchy. Internal method.
TrimeshOptionsFlags
Parameters for trimesh creation from data set.
Definition: Trimesh.h:46
void calculateMassProperties(bool showWarnings)
Calculates mass properties.
Trimesh * deepCopy() const
Creates a new Trimesh which copies data from this one.
void finalizeMeshTopology(bool showWarnings, uint32_t optionsMask)
Finalizes the mesh topology, including mesh legality checks as well as normal and maximum error bound...
const agx::String & getSourceName() const
Gets source name used when creating (can be interesting for debugging meshes).
void updateMeshGeometry(bool showWarnings, bool recalculateMassProperties=true)
Updates the mesh geometry data like normals or edge convexity.
uint32_t getOptionsMask() const
Gets option mask used when creating (can be interesting for debugging meshes).
uint32_t m_optionsMask
Definition: Trimesh.h:302
agx::String m_warnings
Definition: Trimesh.h:301
bool isShallowCopy() const
Trimesh * shallowCopy() const
Creates a new Trimesh which shares data with this one.
virtual Shape * clone() const override
Create a clone.
virtual void calculatePossibleTriangleOverlapsAlongLineSegment(const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, agx::UInt32Vector &triangleIndices) const override
Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a ...
Definition: Trimesh.h:310
agx::String m_sourceName
Definition: Trimesh.h:300
void setValuesAsShallowCopy(const Trimesh *other)
Trimesh(Type type, agx::Physics::Geometry::ShapePtr entity)
Hiding default constructor for child classes.
const agx::String & getWarnings() const
Gets warnings occurring when creating (can be interesting for debugging meshes).
Trimesh(Type type, agx::Physics::Geometry::ShapePtr entity, const agx::Vec3Vector *vertices, const agx::UInt32Vector *indices, const char *sourceName, uint32_t optionsMask=0)
Hidden, should only be called by child classes.
Trimesh(const agx::Vec3Vector *vertices, const agx::UInt32Vector *indices, const char *sourceName, uint32_t optionsMask=Trimesh::REMOVE_DUPLICATE_VERTICES, agx::Real bottomMargin=0)
Constructs a new Trimesh object from a vector of vertices and indices each.
Local scope vector.
Definition: LocalVector.h:44
Pointer to a entity instance of type Physics.Geometry.Shape.
Definition: ShapeEntity.h:196
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
This namespace consists of a set of classes for handling geometric intersection tests including boole...
double Real
Definition: Real.h:41