v2.0.0
Loading...
Searching...
No Matches
fwd_thread_arg.cpp
Go to the documentation of this file.
1//=============================================================================================================
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "fwd_thread_arg.h"
44#include "fwd_coil_set.h"
45#include "fwd_bem_model.h"
46#include "fwd_comp_data.h"
47
48#ifndef TRUE
49#define TRUE 1
50#endif
51
52#ifndef FALSE
53#define FALSE 0
54#endif
55
56#ifndef FAIL
57#define FAIL -1
58#endif
59
60#ifndef OK
61#define OK 0
62#endif
63
64#define FREE_80(x) if ((char *)(x) != NULL) free((char *)(x))
65
66#define FREE_CMATRIX_80(m) mne_free_cmatrix_80((m))
67
68void mne_free_cmatrix_80 (float **m)
69{
70 if (m) {
71 FREE_80(*m);
72 FREE_80(m);
73 }
74}
75
76//=============================================================================================================
77// USED NAMESPACES
78//=============================================================================================================
79
80using namespace Eigen;
81using namespace FWDLIB;
82using namespace MNELIB;
83
84//=============================================================================================================
85// DEFINE MEMBER METHODS
86//=============================================================================================================
87
89:res (NULL)
90,res_grad (NULL)
91,off (0)
92,field_pot (NULL)
93,vec_field_pot (NULL)
94,field_pot_grad(NULL)
95,coils_els (NULL)
96,client (NULL)
97,s (NULL)
99,stat (FAIL)
100,comp (-1)
101{
102}
103
104//=============================================================================================================
105
109
110//=============================================================================================================
111
113/*
114 * Create a duplicate to make the data structure thread safe
115 * Do not duplicate read-only parts of the relevant structures
116 */
117{
119
120 *res = *one;
121 if (bem_model) {
122 FwdBemModel* new_bem = new FwdBemModel;
123 FwdBemModel* orig_bem = (FwdBemModel*)res->client;
124
125 *new_bem = *orig_bem;
126 new_bem->v0 = NULL;
127 res->client = new_bem;
128 }
129 return res;
130}
131
132//=============================================================================================================
133
135{
136 if (!one){
137 qDebug("Pointer passed is null. Returning early.");
138 return;
139 }
140 if (bem_model) {
141 FwdBemModel* bem = (FwdBemModel*) one->client;
142 FREE_80(bem->v0);
143 FREE_80(bem);
144 }
145 one->client = NULL;
146 if(one)
147 delete one;
148}
149
150//=============================================================================================================
151
153/*
154 * Create a duplicate to make the data structure thread safe
155 * Do not duplicate read-only parts of the relevant structures
156 */
157{
159 FwdCompData* orig = (FwdCompData*)one->client;
160 FwdCompData* comp = NULL;
161
162 *res = *one;
163 res->client = comp = new FwdCompData;
164 *comp = *orig;
165 comp->work = NULL;
166 comp->vec_work = NULL;
167 comp->set = orig->set ? new MNECTFCompDataSet(*(orig->set)) : NULL;
168
169 if (bem_model) {
170 FwdBemModel* new_bem = new FwdBemModel();
171 FwdBemModel* orig_bem = (FwdBemModel*)comp->client;
172
173 *new_bem = *orig_bem;
174 new_bem->v0 = NULL;
175 comp->client = new_bem;
176 }
177 return res;
178}
179
180//=============================================================================================================
181
183
184{
185 if (!one){
186 qDebug("Pointer passed is null. Returning early.");
187 return;
188 }
189
191
192 FREE_80(comp->work);
193 FREE_CMATRIX_80(comp->vec_work);
194 if(comp->set)
195 delete comp->set;
196
197 if (bem_model) {
198 FwdBemModel* bem = (FwdBemModel*)comp->client;
199 FREE_80(bem->v0);
200 FREE_80(bem);
201 }
202 FREE_80(comp);
203 one->client = NULL;
204 if(one)
205 delete one;
206}
MNESourceSpace class declaration.
FwdCompData class declaration.
#define FALSE
#define FAIL
FwdCoilSet class declaration.
#define FREE_CMATRIX_80(m)
void mne_free_cmatrix_80(float **m)
#define FREE_80(x)
Fwd Thread Argument (FwdThreadArg) class declaration.
FwdBemModel class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
Forward modelling (BEM, MEG/EEG lead fields).
Definition compute_fwd.h:95
Holds the BEM model definition.
This structure is used in the compensated field calculations.
MNELIB::MNECTFCompDataSet * set
fwdFieldGradFunc field_pot_grad
static void free_meg_multi_thread_duplicate(FwdThreadArg *one, bool bem_model)
static FwdThreadArg * create_eeg_multi_thread_duplicate(FwdThreadArg *one, bool bem_model)
static void free_eeg_multi_thread_duplicate(FwdThreadArg *one, bool bem_model)
fwdVecFieldFunc vec_field_pot
static FwdThreadArg * create_meg_multi_thread_duplicate(FwdThreadArg *one, bool bem_model)
MNELIB::MNESourceSpace * s
Collection of CTF third-order gradient compensation operators.