AGX Dynamics  2.37.3.2
ExecuteFilter.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 #pragma once
18 
19 #include <agx/agxPhysics_export.h>
20 
21 #include <agx/Referenced.h>
23 #include <agxCollide/Contacts.h>
24 
25 
26 namespace agxSDK
27 {
29 
34  {
35  public:
43  virtual bool match(const agxCollide::GeometryContact& gc) const;
44 
51  virtual bool match(const agxCollide::GeometryPair& geometryPair) const;
52 
57  virtual bool match(const agxCollide::Geometry* geometry1, const agxCollide::Geometry* geometry2) const;
58 
59  protected:
63  ExecuteFilter();
64 
68  virtual ~ExecuteFilter();
69  };
70 
71 
72 
74  template <typename T>
75  inline bool matchFilter(const agxCollide::Geometry*, const T*);
76 
81  template <typename T1, typename T2>
83  {
84  public:
89  ExecuteFilterT( const T1* t1, const T2* t2 = nullptr );
90 
92  virtual bool match( const agxCollide::Geometry*, const agxCollide::Geometry* ) const override;
93 
95 
96  protected:
97  virtual ~ExecuteFilterT();
98 
99 
100  protected:
103  };
104 
105 
107 
108 
110  {
111  return match(gc.geometry(0), gc.geometry(1));
112  }
113 
114 
116  {
117  return match(geometryPair.first, geometryPair.second);
118  }
119 
121  {
122  return false;
123  }
124 
125 
126  template <typename T1, typename T2>
127  ExecuteFilterT<T1, T2>::ExecuteFilterT( const T1* t1, const T2* t2 )
128  : m_t1( t1 ), m_t2( t2 )
129  {
130  }
131 
132 
133  template <typename T1, typename T2>
135  {
136  const bool f =
137  (matchFilter(geo1, m_t1.get()) && matchFilter(geo2, m_t2.get())) || // Both match
138  (matchFilter(geo2, m_t1.get()) && matchFilter(geo1, m_t2.get())); // Both match
139 
140  return f;
141  }
142 
143 
144  template<typename T1, typename T2>
146  {
147  }
148 
149 
150 } // namespace agxSDK
151 
virtual bool match(const agxCollide::Geometry *, const agxCollide::Geometry *) const override
Inherited from agxSDK::ExecuteFilter.
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
Definition: Geometry.h:66
Abstract base class that implements a filter that selects which events should trigger a Listener...
Definition: ExecuteFilter.h:33
A contact between two geometries.
Definition: Contacts.h:270
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
virtual bool match(const agxCollide::GeometryContact &gc) const
Called when narrow phase tests have determined overlap (when we have detailed intersection between th...
#define AGX_FORCE_INLINE
Definition: Object.h:59
Templated version of ExecuteFilter, for objects which contain geometries and inherit from agx::Refere...
Definition: ExecuteFilter.h:82
Base class providing referencing counted objects.
Definition: Referenced.h:119
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
T * get() const
Definition: ref_ptr.h:256
agx::ref_ptr< const T2 > m_t2
agx::ref_ptr< const T1 > m_t1
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
bool matchFilter(const agxCollide::Geometry *geo, const agxSDK::Assembly *a)
agxCollide::Geometry * geometry(size_t ith)
Definition: Contacts.h:637
ExecuteFilterT(const T1 *t1, const T2 *t2=nullptr)
Create an ExecuteFilter with one or two conditions.