SDA (SDA flex)  7.2
Simulation of Diffusional Association
Loading...
Searching...
No Matches
DTGrid2D.hpp
Go to the documentation of this file.
1
8#ifndef DTGRID2D_HPP_
9#define DTGRID2D_HPP_
10#include "./ArrayReg.hpp"
11#include "./ArrayPrs.hpp"
12#include "./ArrayPtr.hpp"
13#include "DTGrid1D.hpp"
14//template<typename T, typename K>
15//class DTGrid1D;
16template<typename T,typename K>
17class DTGrid2D {
18
20
21private:
22
26
28
32
33 // WARNING!!! definining the variables below in here instead of in functions is not parallel-safe!
34 /*
35 //Private members for use inside accessxy! Do not use outside this function!
36 typename ArrayPrs <K>::PairArray * coord2;
37 typename ArrayPrs <K>::PairArray ** ptt2;
38 typename ArrayPrs <K>::PairArray * coo2;
39 K checkpoint_21;
40 K checkpoint_22;
41 K countdown_2;
42 bool key2;
43 short skey2;
44 */
45
46protected:
47 template <class M, class H>
48 friend class DTGrid3D;
49 friend class DTGrid3Dex;
50 template <class M, class H>
51 friend class DTGrid1D;
52
53 void set_value_list_2D(K*,int);
54 void set_ycoord_list(K*,int);
55 void set_ptr_list_2D(K*,int);
56
57 void set_projection1D(K*, K*, K*, int, int, int);
58 //typedef ArrayPrs <K>* newtype;
59
60 typename ArrayPrs <K>::PairArray * accessxy(int, int);
61 void getVoxelyz(T*, int, int, int, typename ArrayPrs <K>::PairArray *);
62
64};
65
67template <typename T, typename K>
69 delete proj1D;
70 delete Value_List_2D;
71 delete Ycoord_List;
72 delete Ptr_List_2D;
73}
74
76
82template <typename T, typename K>
84 Value_List_2D = new (std::nothrow) ArrayPrs <K>;
85 Value_List_2D->Set_Pair_Array_Values(values,length);
86 Length_of_Value_List_2D = length;
87}
88
90
95template <typename T, typename K>
97 Ycoord_List = new (std::nothrow) ArrayPrs <K>;
98 Ycoord_List->Set_Pair_Array_Values(values,length);
99 Length_of_Ycoord_List = length;
100}
101
103
108template <typename T, typename K>
110 Ptr_List_2D = new (std::nothrow) ArrayPtr <T,K>;
111 Ptr_List_2D->Set_Pointer_Array_Values(Value_List_2D->PArray,values,Length_of_Value_List_2D,length);
112 Length_of_Ptr_List_2D = length;
113}
114
116
125template <typename T, typename K>
127 proj1D = new (std::nothrow) DTGrid1D <T,K>;
128 proj1D->set_value_list_1D(values1,length1);
129 proj1D->set_xcoord_list(values2,length2);
130 proj1D->set_ptr_list_1D(values3,length3);
131}
132
134
137/*template <typename T, typename K>
138void DTGrid2D<T,K>::Reset_pointers_2D(void){
139 Value_List_2D->Reset_Set_Pair_Array_Values();
140 Ycoord_List->Reset_Set_Pair_Array_Values();
141 Ptr_List_2D->Reset_Set_Pointer_Array_Values();
142 proj1D->Reset_pointers_1D();
143}*/
144
146
152template <typename T, typename K>
154
155 // Call the DTGrid1D random access function.
156 typename ArrayPrs <K>::PairArray * coord2 = proj1D->accessx(a);
157
158 // Return NULL if recursive function call returns NULL.
159 if (coord2 == NULL) return NULL;
160
161 bool key2 = false; // a local logical operation variable.
162
163 K checkpoint_21 = coord2->v2; // the index of the first connected component in a tubular grid in the yCoord array.
164 K checkpoint_22 = (coord2+1)->v2; // the index of the last connected component in a tubular grid in the yCoord array.
165 K countdown_2 = checkpoint_22 - checkpoint_21; // Determine the number of connected components in the corresponding 2D tubular grid.
166
167 // Return NULL when no connected component found
168 if (countdown_2 == 0){ return NULL;}
169
170 typename ArrayPrs <K>::PairArray ** ptt2 = Ptr_List_2D->PtrArray+checkpoint_21; // a temporary pointer to store an acc array member.
171 typename ArrayPrs <K>::PairArray * coo2 = Ycoord_List->PArray+checkpoint_21; // a temporary pointer to store an yCoord array pair.
172
173 // iterate over the connected components in DTGrid2D
174 for (; countdown_2 >= 1; countdown_2--){
175 // check whether index b is inside one of the connected components using the yCoord index array.
176 key2 = b>=coo2->v1 ? (b<=coo2->v2 ? true : false) : false;
177 if (key2 == true){
178 return *(ptt2)+b-coo2->v1;
179 }
180 else {
181 // increment the pointers to the next connected component
182 ++ptt2;
183 ++coo2;
184 continue;
185 }
186 }
187 return NULL;
188}
189
190/*template <typename T, typename K>
191void DTGrid2D<T,K>::getVoxelyz(T * Voxel, int x, int b, int c, typename ArrayPrs <K>::PairArray * coord2){
192
193 short skey2 = 0;
194 int binc = b+1;
195
196 K checkpoint_21 = coord2->v2;
197 K checkpoint_22 = (coord2+1)->v2;
198 K countdown_2 = checkpoint_22 - checkpoint_21;
199
200 if (countdown_2 == 0){ return 0;}
201
202 typename ArrayPrs <K>::PairArray ** ptt2 = Ptr_List_2D->PtrArray+checkpoint_21;
203 typename ArrayPrs <K>::PairArray * coo2 = Ycoord_List->PArray+checkpoint_21;
204
205 for (; countdown_2 >= 1; countdown_2--){
206 skey2 = b>=coo2->v1 ? (binc<=coo2->v2 ? 1 : 2 ) : (binc>=coo2->v1 ? 3 : 0);
207 switch (skey2)
208 {
209 case 0:
210 ++ptt2;
211 ++coo2;
212 break;
213 case 1:
214 getVoxelz(Voxel, x,0,c, *(ptt2)+b-coo2->v1);
215 //++b;
216 getVoxelz(Voxel, x,1,c, *(ptt2)+binc-coo2->v1);
217 return;
218 case 2:
219 getVoxelz(Voxel, x,0,c, *(ptt2)+b-coo2->v1);
220 return;
221 case 3:
222 getVoxelz(Voxel, x,1,c, *(ptt2)+binc-coo2->v1);
223 return;
224 }
225 }
226 return;
227}*/
228
229#endif /* DTGRID2D_HPP_ */
Define the array for storing pairs of indices.
Define the array for storing pointers into ArrayPrs.
Define arrays of regular type used in any of the DT-Grid layers.
Define the 1D DT-Grid class and group its functions.
Definition DTGrid1D.hpp:13
Definition DTGrid2D.hpp:17
~DTGrid2D()
DTGrid3D destructor.
Definition DTGrid2D.hpp:68
void set_projection1D(K *, K *, K *, int, int, int)
proj2D setup
Definition DTGrid2D.hpp:126
ArrayPrs< K >::PairArray * accessxy(int, int)
Reset pointers that temporarily store addresses for random access. Similar to that for DT-Grid3D.
Definition DTGrid2D.hpp:153
ArrayPrs< K > * Ycoord_List
Definition DTGrid2D.hpp:24
ArrayPtr< T, K > * Ptr_List_2D
Definition DTGrid2D.hpp:25
void getVoxelyz(T *, int, int, int, typename ArrayPrs< K >::PairArray *)
DTGrid1D< T, K > * proj1D
Definition DTGrid2D.hpp:27
int Length_of_Ycoord_List
Definition DTGrid2D.hpp:30
int Length_of_Ptr_List_2D
Definition DTGrid2D.hpp:31
void set_ptr_list_2D(K *, int)
acc (2D) array setup
Definition DTGrid2D.hpp:109
void Reset_pointers_2D(void)
int Length_of_Value_List_2D
Definition DTGrid2D.hpp:29
ArrayPrs< K > * Value_List_2D
Definition DTGrid2D.hpp:23
void set_ycoord_list(K *, int)
yCoord array setup
Definition DTGrid2D.hpp:96
void set_value_list_2D(K *, int)
DTGrid2D 'value' array setup.
Definition DTGrid2D.hpp:83
Definition DTGrid3D.hpp:65
Definition DTGrid3Dex.hpp:73
Imprint/Privacy