AGXDynamics  2.35.0.3
ConvexFactory.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 #pragma once
18 
19 #include <agx/agxPhysics_export.h>
20 #include <agx/Referenced.h>
21 #include <agx/Vector.h>
22 #include <agxCollide/Convex.h>
23 #include <agxIO/MeshReader.h>
24 #include <agx/agx_vector_types.h>
25 #include <agx/debug.h>
26 
27 namespace agxCollide
28 {
29 
31 
41  {
42  public:
43 
44  struct Parameters : public agx::Referenced
45  {
46  };
49 
50  struct VHACDParameters : public Parameters
51  {
53  uint32_t resolution = 50;
54 
56  double concavity = 0.0025;
57 
59  uint32_t planeDownsampling = 4;
60 
62  uint32_t convexhullDownsampling = 4;
63 
65  double alpha = 0.05;
66 
68  double beta = 0.05;
69 
71  bool pca = false;
72 
74  uint32_t mode = 0; // 0: voxel-based (recommended), 1: tetrahedron-based
75 
76  // Controls the maximum number of triangles per convex - hull. Default 64, range: [0, 1024]
77  uint32_t maxNumVerticesPerConvex = 64;
78 
80  double minVolumePerConvex = 0.0001;
81 
82  bool convexhullApproximation = true;
83 
85  uint32_t maxConvexHulls = 1024;
86  };
89 
90 
92  ConvexFactory( );
93 
97  size_t build( const agx::Vec3Vector& vertices,
98  const agx::UInt32Vector& indices,
99  const Parameters* parameters = nullptr,
100  const agx::Matrix3x3& transformation = agx::Matrix3x3(),
101  const agx::Vec3& translation = agx::Vec3()
102  );
103 
109  size_t build( const agxIO::MeshReader *reader,
110  const Parameters* parameters = nullptr,
111  const agx::Matrix3x3& transformation = agx::Matrix3x3(),
112  const agx::Vec3& translation = agx::Vec3()
113  );
114 
116  const ConvexRefVector& getConvexShapes() const;
117 
119  agxCollide::ConvexRef getShape(size_t i);
120 
122  size_t getNumShapes() const;
123 
124  protected:
125  virtual ~ConvexFactory( );
126 
127  private:
128 
129  size_t buildImplementation(const agx::Vec3Vector& vertices,
130  const agx::UInt32Vector& indices,
131  const VHACDParameters* parameters,
132  const agx::Matrix3x3& transformation = agx::Matrix3x3(),
133  const agx::Vec3& translation = agx::Vec3()
134  );
135 
136  agxIO::MeshReaderRef m_reader;
137 
138  ConvexRefVector m_convexShapes;
139 
140  ParametersConstRef m_parameters;
141  };
142 }
143 
144 
145 
agxPhysics_export.h
Referenced.h
Vector.h
agxCollide::ConvexFactory::ParametersRef
agx::ref_ptr< Parameters > ParametersRef
Definition: ConvexFactory.h:47
agx::Vector< agxCollide::ConvexRef >
agxCollide::ConvexFactory::ParametersConstRef
agx::ref_ptr< const Parameters > ParametersConstRef
Definition: ConvexFactory.h:48
agxCollide::ConvexFactory::Parameters
Definition: ConvexFactory.h:44
agxCollide::ConvexFactory::VHACDParametersConstRef
agx::ref_ptr< const VHACDParameters > VHACDParametersConstRef
Definition: ConvexFactory.h:88
agxCollide::ConvexFactory::VHACDParametersRef
agx::ref_ptr< VHACDParameters > VHACDParametersRef
Definition: ConvexFactory.h:87
MeshReader.h
agx::VectorPOD< Vec3 >
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
Convex.h
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxCollide::AGX_DECLARE_POINTER_TYPES
AGX_DECLARE_POINTER_TYPES(SpaceListener)
agxCollide::ConvexRefVector
agx::Vector< agxCollide::ConvexRef > ConvexRefVector
Definition: ConvexFactory.h:30
agxCollide::ConvexFactory::VHACDParameters
Definition: ConvexFactory.h:50
agxCollide::ConvexFactory
Class for creating convex meshes from a set of vertices and indices.
Definition: ConvexFactory.h:40
agx::Vec3T< Real >
agx::Matrix3x3T< Real >
agxIO::MeshReader
Class for reading a mesh object from file and extracting vertices, normals and indices for collision ...
Definition: MeshReader.h:82
agx_vector_types.h
debug.h