AGX Dynamics  2.37.3.2
PressureAtlas.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 AGXOSG_PRESSURE_ATLAS
18 #define AGXOSG_PRESSURE_ATLAS
19 
20 #include <agx/Referenced.h>
21 
22 #include <agxCollide/Trimesh.h>
23 
24 #include <agxOSG/export.h>
27 
28 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
29 #include <osg/Geometry>
30 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
31 
32 namespace agxOSG
33 {
34  class GeometryNode;
36 
37 
44  {
45  public:
46  PressureAtlas(const agxCollide::Trimesh* mesh, agx::Real texelsPerMeter);
47 
49 
58  bool registerPressureGenerator(agxOSG::PressureGenerator* generator);
59 
60 
77  void addPressure(const agx::Vec3& point, agx::UInt32 triangleIndex, agx::Real magnitude, agx::Real radius);
78 
83  void clearPressure();
84 
85 
93  bool isDirty() const;
94 
95 
102  bool isPressurized() const;
103 
104 
106 
107 
117  bool registerColorConverter(agxOSG::PressureToColorConverter* colorConverter);
118 
119 
130  bool unregisterColorConverter(agxOSG::PressureToColorConverter* colorConverter);
131 
132 
136  void updateColorImages();
137 
144  osg::Image* getPressureMap();
145 
146  const agxCollide::Trimesh* getPhysicsMesh();
147 
152  osg::Geometry* getGraphicsMesh();
153 
157  osg::Vec2Array& getTextureCoordinates();
158 
159 
160  agxOSG::GeometryNode* createAtlasRendering();
161 
162 
164  size_t getNumTriangles() const;
165 
170  size_t getNumVertices() const;
171 
172  size_t getVertexIndex(size_t triangleIndex, size_t localVertexIndex) const;
173 
174  protected:
175  virtual ~PressureAtlas() {}
176 
177  private:
178  void createGraphicsMesh();
179  osg::Geometry* createOsgMesh(const agxCollide::Trimesh* mesh);
180  void createAtlas();
181  // Hiding assignment
182  PressureAtlas& operator=(const PressureAtlas&) {return *this;}
183 
184 
185  agx::UInt32 nextTriangle();
186  void queuePartnersInRange(agxCollide::Mesh::Triangle& triangle, const agx::Vec3& point, agx::Real radiusSquared);
187  bool isInRange(const agx::Vec3& point, const agxCollide::Mesh::Triangle& triangle, agx::Real radiusSquared);
188  bool colorTriangle(const agxCollide::Mesh::Triangle& triangle, const agx::Vec3& point,
189  const agx::Real radius, const agx::Real radiusSquared,
190  const agx::Real centerMagnitude);
191 
192 
193  private:
194 
196  const agxCollide::TrimeshConstRef m_physicsMesh;
197 
199  osg::ref_ptr<osg::Geometry> m_graphicsMesh;
200 
202  agx::Real m_texelsPerMeter;
203 
209  osg::ref_ptr<osg::Image> m_pressureMap;
210 
215  PressureGeneratorRefVector m_pressureGenerators;
216 
221  PressureToColorConverterRefVector m_colorGenerators;
222 
223 
225  agx::HashSet<agx::UInt32> m_consideredTriangles;
226 
228  agx::Vector<agx::UInt32> m_queuedTriangles;
229 
234  bool m_dirty;
235 
240  bool m_pressurized;
241  };
242 
243 }
244 
245 #endif
246 
A pressure map for a single trimesh.
Definition: PressureAtlas.h:43
#define AGXOSG_EXPORT
Base class for types that want to supply force updates to a PressureAtlas.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Base class providing referencing counted objects.
Definition: Referenced.h:119
Class for more intuitive access to the Mesh&#39;s mesh data.
Definition: Mesh.h:78
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:41
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
double Real
Definition: Real.h:42
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
uint32_t UInt32
Definition: Integer.h:40