AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParticleFilters.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 
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 
32 
37  typedef std::function<ParticleRenderFilter*()> ParticleFilterConstructor;
39  {
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 
73 
80 
86 
92 
98  bool particleRenderFilterExists(const agx::String& name);
99 
106  void setFilterThresholdScalar(agx::Real threshold);
107 
115 
119  void resetParticleFilterState(agx::ParticleSystem * system) const;
120 
121  protected:
123 
124  void initStandardFilters();
125 
127  // Variables
129  protected:
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:
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:
245  };
246 
248  {
249  return ParticleFilterMode{ ParticleRenderFilter::PARTICLEFILTER_NONE_NAME, []{ return nullptr; }, "" };
250  }
251 }
252 
253 #endif /*AGXQT_QTOSGUTILS_H*/
ParticleFilterConstructor m_constructor
ParticleRenderFilter(const agx::Name &name)
#define AGXQT_EXPORT
ParticleRenderFilterModeVector getAvailableParticleRenderModes() const
Returns the ParticleFilterMode structs added to the manager.
std::function< ParticleRenderFilter *()> ParticleFilterConstructor
Struct containing information and constructors for a specific particle filter, that removes rendering...
agx::Name getName() const
Returns the name type identifier for the ParticleFilter.
ParticleFilterMode getActiveParticleRenderFilterMode() const
Returns the ParticleFilterMode struct for the active filter in the manager.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:62
bool operator==(const ParticleFilterMode &rhs)
This is a class that filters particles from contact energy.
virtual void preRender(agx::ParticleSystem *system) override
Execute on particles before rendering.
agx::Vector< ParticleFilterMode > ParticleRenderFilterModeVector
This is a class that filters particles from certain criteria.
Base class providing referencing counted objects.
Definition: Referenced.h:113
static const char *const PARTICLEFILTER_NONE_NAME
void setFilterThresholdScalar(agx::Real threshold)
Sets the filter threshold of the ParticleRenderFilter.
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...
void postRender(agx::ParticleSystem *system)
Execute after render state.
virtual void postRender(agx::ParticleSystem *system) override
Execute after render state.
void preRender(agx::ParticleSystem *system)
Execute on particles before rendering.
ParticleFilterMode AGXQT_EXPORT createNoneParticleFilterMode()
ParticleColorModeTable m_availableParticleFilters
void resetParticleFilterState(agx::ParticleSystem *system) const
Resets the filtered state in the particle system.
LambdaParticleRenderFilter(const agx::Name &name, const ParticleFilterFunction &function)
virtual void postRender(agx::ParticleSystem *system) override
Execute after render state.
void filterParticle(agx::Physics::ParticlePtr ptr, bool shouldFilter)
void setScalarRenderThreshold(agx::Real scalarThreshold)
Sets the filter threshold of the ParticleRenderFilter.
bool particleRenderFilterExists(const agx::String &name)
Returns true/false if an ParticleRenderFilter with given name identifier exists in the manager...
virtual void preRender(agx::ParticleSystem *system)=0
Execute on particles before rendering.
void setActiveParticleRenderFilter(ParticleFilterMode mode)
Switches active particle render filter based on a ParticleFilter mode.
double Real
Definition: Real.h:42
void setActiveParticleRenderFilterFromString(const agx::String &name)
Switches active particle render filter based on name identifier.
virtual void preRender(agx::ParticleSystem *system) override
Execute on particles before rendering.
ParticleRenderFilter * m_activeParticleFilter
virtual void preRender(agx::ParticleSystem *system) override
Execute on particles before rendering.
Inheritance with partial specialization due to bug with ref_ptr containers.
virtual void postRender(agx::ParticleSystem *system) override
Execute after render state.
agx::Real getFilterThresholdScalar() const
Returns the filter threshold of the ParticleRenderFilter.
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
virtual void postRender(agx::ParticleSystem *system)=0
Execute after render state.