AGX Dynamics  2.37.2.0
MergeSplitParallelReferencedDataKernel.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 
20 
21 #include <agx/Kernel.h>
22 
23 namespace agxSDK
24 {
25  template<typename T>
27  {
28  public:
29  void execute( const T* data,
30  const agxSDK::MergeSplitHandler& handler,
31  const agxSDK::MergeSplitPostSolveData& postSolveData );
32 
33  protected:
34  virtual void onPreExecute();
35  virtual void onEntityPtr( agxData::EntityPtr ptr,
36  const agxSDK::MergeSplitHandler& handler,
37  const agxSDK::MergeSplitPostSolveData& postSolveData ) = 0;
38  virtual void onPostExecute();
39 
40  protected:
42 
43  agx::UInt getNumElements() const;
44  const T* getData() const;
45 
46  using agx::Task::execute;
47 
48  private:
49  void executeJob( const agx::RangeJob& job );
50 
51  private:
54 
55  private:
56  const T* m_data;
57  const MergeSplitHandler* m_handler;
58  const MergeSplitPostSolveData* m_postSolveData;
59  };
60 
61  template<typename T>
63  : LambdaKernel( name,
64  std::bind( &MergeSplitParallelReferencedDataKernel<T>::executeJob, this, std::placeholders::_1 ),
66  m_data( nullptr ),
67  m_handler( nullptr ),
68  m_postSolveData( nullptr )
69  {
70  }
71 
72  template<typename T>
74  {
75  return m_data != nullptr ? m_data->instance.size() : 0u;
76  }
77 
78  template<typename T>
80  {
81  return m_data;
82  }
83 
84  template<typename T>
86  {
87  }
88 
89  template<typename T>
91  const MergeSplitHandler& handler,
92  const MergeSplitPostSolveData& postSolveData )
93  {
94  m_data = data;
95  if ( m_data != nullptr ) {
96  m_handler = &handler;
97  m_postSolveData = &postSolveData;
98 
99  this->onPreExecute();
101  this->onPostExecute();
102  }
103 
104 
105  m_data = nullptr;
106  m_handler = nullptr;
107  m_postSolveData = nullptr;
108  }
109 
110  template<typename T>
112  {
113  }
114 
115  template<typename T>
117  {
118  for ( agx::UInt i = job.range().begin(), end = job.range().end(); i != end; ++i )
119  onEntityPtr( m_data->instance[ i ], *m_handler, *m_postSolveData );
120  }
121 }
IndexRange & range()
Definition: Job.h:631
LambdaKernel(const agx::Name &name, LambdaCallback lambdaCallback, DataSetSizeCallback sizeCallback)
Constructor.
Base class for a merge split algorithm handling a set of merged bodies.
void execute()
Execute the task.
STL namespace.
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51
virtual void onEntityPtr(agxData::EntityPtr ptr, const agxSDK::MergeSplitHandler &handler, const agxSDK::MergeSplitPostSolveData &postSolveData)=0
Representation of a name string.
Definition: Name.h:32
A range job executes a kernel implementation on a subset of the data.
Definition: Job.h:283
uint32_t UInt
Definition: Integer.h:34
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30