AGX Dynamics 2.42.3.0
Loading...
Searching...
No Matches
MergeSplitParallelReferencedDataKernel.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20
21#include <agx/Kernel.h>
22
23namespace 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();
36 const agxSDK::MergeSplitHandler& handler,
37 const agxSDK::MergeSplitPostSolveData& postSolveData ) = 0;
38 virtual void onPostExecute();
39
40 protected:
42
44 const T* getData() const;
45
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 ),
65 std::bind( &MergeSplitParallelReferencedDataKernel<T>::getNumElements, this ) ),
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}
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:52
Base class for a merge split algorithm handling a set of merged bodies.
virtual void onEntityPtr(agxData::EntityPtr ptr, const agxSDK::MergeSplitHandler &handler, const agxSDK::MergeSplitPostSolveData &postSolveData)=0
Representation of a name string.
Definition: Name.h:33
A range job executes a kernel implementation on a subset of the data.
Definition: Job.h:282
IndexRange & range()
Definition: Job.h:629
void execute()
Execute the task.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
uint64_t UInt
Definition: Integer.h:27
STL namespace.