AGX Dynamics  2.35.0.1
ExecuteFilter.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 #ifndef AGXSDK_EXECUTE_FILTER_H
18 #define AGXSDK_EXECUTE_FILTER_H
19 
20 #include <agx/agxPhysics_export.h>
21 
22 #include <agx/Referenced.h>
24 #include <agxCollide/Contacts.h>
25 
26 
27 namespace agxSDK
28 {
30 
35  {
36  public:
44  virtual bool match(const agxCollide::GeometryContact& gc) const;
45 
52  virtual bool match(const agxCollide::GeometryPair& geometryPair) const;
53 
58  virtual bool match(const agxCollide::Geometry* geometry1, const agxCollide::Geometry* geometry2) const;
59 
60  protected:
65 
69  virtual ~ExecuteFilter();
70  };
71 
72 
73 
75  template <typename T>
76  inline bool matchFilter(const agxCollide::Geometry*, const T*);
77 
82  template <typename T1, typename T2>
84  {
85  public:
90  ExecuteFilterT( const T1* t1, const T2* t2 = nullptr );
91 
93  virtual bool match( const agxCollide::Geometry*, const agxCollide::Geometry* ) const override;
94 
96 
97  protected:
98  virtual ~ExecuteFilterT();
99 
100 
101  protected:
104  };
105 
106 
108 
109 
111  {
112  return match(gc.geometry(0), gc.geometry(1));
113  }
114 
115 
117  {
118  return match(geometryPair.first, geometryPair.second);
119  }
120 
122  {
123  return false;
124  }
125 
126 
127  template <typename T1, typename T2>
128  ExecuteFilterT<T1, T2>::ExecuteFilterT( const T1* t1, const T2* t2 )
129  : m_t1( t1 ), m_t2( t2 )
130  {
131  }
132 
133 
134  template <typename T1, typename T2>
136  {
137  const bool f =
138  (matchFilter(geo1, m_t1.get()) && matchFilter(geo2, m_t2.get())) || // Both match
139  (matchFilter(geo2, m_t1.get()) && matchFilter(geo1, m_t2.get())); // Both match
140 
141  return f;
142  }
143 
144 
145  template<typename T1, typename T2>
147  {
148  }
149 
150 
151 } // namespace agxSDK
152 
153 #endif
154 
155 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXPHYSICS_EXPORT
A contact between two geometries.
Definition: Contacts.h:270
agxCollide::Geometry * geometry(size_t ith)
Definition: Contacts.h:636
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
Templated version of ExecuteFilter, for objects which contain geometries and inherit from agx::Refere...
Definition: ExecuteFilter.h:84
ExecuteFilterT(const T1 *t1, const T2 *t2=nullptr)
Create an ExecuteFilter with one or two conditions.
agx::ref_ptr< const T2 > m_t2
virtual bool match(const agxCollide::GeometryContact &gc) const
Called when narrow phase tests have determined overlap (when we have detailed intersection between th...
agx::ref_ptr< const T1 > m_t1
Abstract base class that implements a filter that selects which events should trigger a Listener.
Definition: ExecuteFilter.h:35
virtual ~ExecuteFilter()
Destructor.
virtual bool match(const agxCollide::GeometryContact &gc) const
Called when narrow phase tests have determined overlap (when we have detailed intersection between th...
ExecuteFilter()
Default, hidden constructor.
Base class providing referencing counted objects.
Definition: Referenced.h:114
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:66
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
bool matchFilter(const agxCollide::Geometry *geo, const agxSDK::Assembly *a)