AGX Dynamics  2.37.2.0
ParticleFilters.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 AGXQT_FILTER_H
18 #define AGXQT_FILTER_H
19 
20 #include <agx/config/AGX_USE_KEYSHOT.h>
21 #include <agxQt/export.h>
22 #include <agx/Referenced.h>
24 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
26 
27 namespace agxQt
28 {
29 
30  // Forward declaration
32 
37  typedef std::function<ParticleRenderFilter*()> ParticleFilterConstructor;
39  {
41  ParticleFilterConstructor m_constructor;
43 
44  bool operator==(const ParticleFilterMode& rhs) { return m_id == rhs.m_id; }
45  };
47 
54  {
55  public:
57 
58  public:
60 
62  void preRender(agx::ParticleSystem * system);
63 
65  void postRender(agx::ParticleSystem * system);
66 
72  void setActiveParticleRenderFilterFromString(const agx::String& name);
73 
79  void setActiveParticleRenderFilter(ParticleFilterMode mode);
80 
85  ParticleFilterMode getActiveParticleRenderFilterMode() const;
86 
91  ParticleRenderFilterModeVector getAvailableParticleRenderModes() const;
92 
98  bool particleRenderFilterExists(const agx::String& name);
99 
106  void setFilterThresholdScalar(agx::Real threshold);
107 
114  agx::Real getFilterThresholdScalar() const;
115 
119  void resetParticleFilterState(agx::ParticleSystem * system) const;
120 
121  protected:
123 
124  void initStandardFilters();
125 
127  // Variables
129  protected:
130  ParticleColorModeTable m_availableParticleFilters;
133  };
134 
142  {
143  public:
144  static const char * const PARTICLEFILTER_NONE_NAME;
145 
146  public:
148  virtual void preRender(agx::ParticleSystem * system) = 0;
149 
151  virtual void postRender(agx::ParticleSystem * system) = 0;
152 
159  void setScalarRenderThreshold(agx::Real scalarThreshold);
160 
166  agx::Name getName() const;
167 
168  protected:
169  ParticleRenderFilter(const agx::Name& name);
170 
171  void filterParticle(agx::Physics::ParticlePtr ptr, bool shouldFilter);
172 
173  virtual ~ParticleRenderFilter();
174 
176  // Variables
178  protected:
181  };
182 
184 
189  {
190  public:
192 
193  virtual void preRender(agx::ParticleSystem * system) override;
194 
195  virtual void postRender(agx::ParticleSystem * system) override;
196 
197  protected:
199  };
200 
205  {
206  public:
208 
209  virtual void preRender(agx::ParticleSystem * system) override;
210 
211  virtual void postRender(agx::ParticleSystem * system) override;
212 
213  protected:
214  virtual ~ParticleVelocityRenderFilter();
215 
217  // Variables
219  protected:
220  };
221 
226  {
227  public:
228  typedef std::function<bool(agx::ParticleSystem*, agx::Physics::ParticlePtr)> ParticleFilterFunction;
229 
230  public:
231  LambdaParticleRenderFilter(const agx::Name& name, const ParticleFilterFunction& function);
232 
233  virtual void preRender(agx::ParticleSystem * system) override;
234 
235  virtual void postRender(agx::ParticleSystem * system) override;
236 
237  protected:
238  virtual ~LambdaParticleRenderFilter();
239 
241  // Variables
243  protected:
244  ParticleFilterFunction m_filterFunction;
245  };
246 
248  {
249  return ParticleFilterMode{ ParticleRenderFilter::PARTICLEFILTER_NONE_NAME, []{ return nullptr; }, "" };
250  }
251 }
252 
253 #endif /*AGXQT_QTOSGUTILS_H*/
ParticleFilterConstructor m_constructor
#define AGXQT_EXPORT
std::function< ParticleRenderFilter *()> ParticleFilterConstructor
Struct containing information and constructors for a specific particle filter, that removes rendering...
Contains classes/utility functions for connecting AGX to QT with OSG.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:59
bool operator==(const ParticleFilterMode &rhs)
This is a class that filters particles from contact energy.
agx::Vector< ParticleFilterMode > ParticleRenderFilterModeVector
This is a class that filters particles from certain criteria.
Base class providing referencing counted objects.
Definition: Referenced.h:119
static const char *const PARTICLEFILTER_NONE_NAME
std::function< bool(agx::ParticleSystem *, agx::Physics::ParticlePtr)> ParticleFilterFunction
A basic particle system that contains all the storages and buffers required for basic operation and a...
ParticleFilterMode AGXQT_EXPORT createNoneParticleFilterMode()
ParticleColorModeTable m_availableParticleFilters
agx::Name getName() const
Returns the name type identifier for the ParticleFilter.
double Real
Definition: Real.h:42
ParticleRenderFilter * m_activeParticleFilter
Inheritance with partial specialization due to bug with ref_ptr containers.
ParticleFilterFunction m_filterFunction
Pointer to a entity instance of type Physics.Particle.
This is a base abstract class for filtering particles.
This is a class that filters particles from certain criteria.
agx::HashTable< agx::Name, ParticleFilterMode > ParticleColorModeTable