@@ -83,15 +83,15 @@ public :
8383 /* *
8484 * Constructor - initialize mesh with size of 0,0,0
8585 */
86- MeshData () { initialize (0 , 0 , 0 ); }
86+ MeshData () { init (0 , 0 , 0 ); }
8787
8888 /* *
8989 * Constructor - initialize initial size of mesh to provided values
9090 * @param aSizeOfY
9191 * @param aSizeOfX
9292 * @param aSizeOfZ
9393 */
94- MeshData (int aSizeOfY, int aSizeOfX, int aSizeOfZ) { initialize (aSizeOfY, aSizeOfX, aSizeOfZ); }
94+ MeshData (int aSizeOfY, int aSizeOfX, int aSizeOfZ) { init (aSizeOfY, aSizeOfX, aSizeOfZ); }
9595
9696 /* *
9797 * Constructor - creates mesh with provided dimentions initialized to aInitVal
@@ -100,7 +100,7 @@ public :
100100 * @param aSizeOfZ
101101 * @param aInitVal - initial value of all elements
102102 */
103- MeshData (int aSizeOfY, int aSizeOfX, int aSizeOfZ, T aInitVal) { initialize (aSizeOfY, aSizeOfX, aSizeOfZ, aInitVal); }
103+ MeshData (int aSizeOfY, int aSizeOfX, int aSizeOfZ, T aInitVal) { init (aSizeOfY, aSizeOfX, aSizeOfZ, aInitVal); }
104104
105105 /* *
106106 * Move constructor
@@ -133,7 +133,7 @@ public :
133133 */
134134 template <typename U>
135135 MeshData (const MeshData<U> &aMesh, bool aShouldCopyData) {
136- initialize (aMesh.y_num , aMesh.x_num , aMesh.z_num );
136+ init (aMesh.y_num , aMesh.x_num , aMesh.z_num );
137137 if (aShouldCopyData) std::copy (aMesh.mesh .begin (), aMesh.mesh .end (), mesh.begin ());
138138 }
139139
@@ -143,7 +143,7 @@ public :
143143 * @return created object by value
144144 */
145145 template <typename U>
146- MeshData<U> to_type () const {
146+ MeshData<U> toType () const {
147147 MeshData<U> new_value (y_num, x_num, z_num);
148148 std::copy (mesh.begin (), mesh.end (), new_value.mesh .begin ());
149149 return new_value;
@@ -171,7 +171,7 @@ public :
171171 * @param z
172172 * @return element @(y, x, z)
173173 */
174- T& access_no_protection (size_t y, size_t x, size_t z) {
174+ T& at (size_t y, size_t x, size_t z) {
175175 size_t idx = z * x_num * y_num + x * y_num + y;
176176 return mesh[idx];
177177 }
@@ -184,7 +184,7 @@ public :
184184 * @param aNumberOfBlocks in how many chunks copy will be done
185185 */
186186 template <typename U>
187- void block_copy_data (const MeshData<U> &aInputMesh, unsigned int aNumberOfBlocks = 8 ) {
187+ void copyFromMesh (const MeshData<U> &aInputMesh, unsigned int aNumberOfBlocks = 8 ) {
188188 aNumberOfBlocks = std::min ((unsigned int )z_num, aNumberOfBlocks);
189189 unsigned int numOfElementsPerBlock = z_num/aNumberOfBlocks;
190190
@@ -213,7 +213,7 @@ public :
213213 * @param aInitVal
214214 * NOTE: If mesh was already created only added elements (new size > old size) will be initialize with aInitVal
215215 */
216- void initialize (int aSizeOfY, int aSizeOfX, int aSizeOfZ, T aInitVal) {
216+ void init (int aSizeOfY, int aSizeOfX, int aSizeOfZ, T aInitVal) {
217217 y_num = aSizeOfY;
218218 x_num = aSizeOfX;
219219 z_num = aSizeOfZ;
@@ -246,8 +246,8 @@ public :
246246 * @param aInputMesh
247247 */
248248 template <typename S>
249- void initialize (const MeshData<S>& aInputMesh) {
250- initialize (aInputMesh.y_num , aInputMesh.x_num , aInputMesh.z_num );
249+ void init (const MeshData<S> & aInputMesh) {
250+ init (aInputMesh.y_num , aInputMesh.x_num , aInputMesh.z_num );
251251 }
252252
253253 /* *
@@ -256,7 +256,7 @@ public :
256256 * @param aSizeOfX
257257 * @param aSizeOfZ
258258 */
259- void initialize (int aSizeOfY, int aSizeOfX, int aSizeOfZ) {
259+ void init (int aSizeOfY, int aSizeOfX, int aSizeOfZ) {
260260 y_num = aSizeOfY;
261261 x_num = aSizeOfX;
262262 z_num = aSizeOfZ;
@@ -272,12 +272,12 @@ public :
272272 * @param aSizeOfX
273273 * @param aSizeOfZ
274274 */
275- void preallocate (int aSizeOfY, int aSizeOfX, int aSizeOfZ) {
275+ void initDownsampled (int aSizeOfY, int aSizeOfX, int aSizeOfZ) {
276276 const int z_num_ds = ceil (1.0 *aSizeOfZ/2.0 );
277277 const int x_num_ds = ceil (1.0 *aSizeOfX/2.0 );
278278 const int y_num_ds = ceil (1.0 *aSizeOfY/2.0 );
279279
280- initialize (y_num_ds, x_num_ds, z_num_ds);
280+ init (y_num_ds, x_num_ds, z_num_ds);
281281 }
282282
283283 /* *
@@ -287,12 +287,12 @@ public :
287287 * @param aSizeOfZ
288288 * @param aInitVal
289289 */
290- void preallocate (int aSizeOfY, int aSizeOfX, int aSizeOfZ, T aInitVal) {
290+ void initDownsampled (int aSizeOfY, int aSizeOfX, int aSizeOfZ, T aInitVal) {
291291 const int z_num_ds = ceil (1.0 *aSizeOfZ/2.0 );
292292 const int x_num_ds = ceil (1.0 *aSizeOfX/2.0 );
293293 const int y_num_ds = ceil (1.0 *aSizeOfY/2.0 );
294294
295- initialize (y_num_ds, x_num_ds, z_num_ds, aInitVal);
295+ init (y_num_ds, x_num_ds, z_num_ds, aInitVal);
296296 }
297297
298298 /* *
@@ -316,7 +316,7 @@ public :
316316 * @param aNumberOfBlocks - in how many chunks copy will be done
317317 */
318318 template <typename U, typename R>
319- void initWithUnaryOp (const MeshData<U> &aInputMesh, R aOp, size_t aNumberOfBlocks = 10 ) {
319+ void copyFromMeshWithUnaryOp (const MeshData<U> &aInputMesh, R aOp, size_t aNumberOfBlocks = 10 ) {
320320 aNumberOfBlocks = std::min (aInputMesh.z_num , (size_t )aNumberOfBlocks);
321321 size_t numOfElementsPerBlock = aInputMesh.z_num /aNumberOfBlocks;
322322
@@ -345,13 +345,13 @@ public :
345345 * @param aIdx
346346 * @return
347347 */
348- std::string getIdx ( uint64_t aIdx) const {
348+ std::string getStrIndex ( size_t aIdx) const {
349349 if (aIdx < 0 || aIdx >= mesh.size ()) return " (ErrIdx)" ;
350- uint64_t z = aIdx / (x_num * y_num);
350+ size_t z = aIdx / (x_num * y_num);
351351 aIdx -= z * (x_num * y_num);
352- uint64_t x = aIdx / y_num;
352+ size_t x = aIdx / y_num;
353353 aIdx -= x * y_num;
354- uint64_t y = aIdx;
354+ size_t y = aIdx;
355355 std::ostringstream outputStr;
356356 outputStr << " (" << y << " , " << x << " , " << z << " )" ;
357357 return outputStr.str ();
@@ -371,31 +371,31 @@ public :
371371
372372
373373template <typename T, typename S, typename R, typename C>
374- void down_sample (const MeshData<T>& aInput, MeshData<S>& aOutput, R reduce, C constant_operator, bool aInitializeOutput = false ) {
375- const int64_t z_num = aInput.z_num ;
376- const int64_t x_num = aInput.x_num ;
377- const int64_t y_num = aInput.y_num ;
374+ void downsample (const MeshData<T> & aInput, MeshData<S> & aOutput, R reduce, C constant_operator, bool aInitializeOutput = false ) {
375+ const size_t z_num = aInput.z_num ;
376+ const size_t x_num = aInput.x_num ;
377+ const size_t y_num = aInput.y_num ;
378378
379379 // downsampled dimensions twice smaller (rounded up)
380- const int64_t z_num_ds = ( int64_t ) ceil (z_num/2.0 );
381- const int64_t x_num_ds = ( int64_t ) ceil (x_num/2.0 );
382- const int64_t y_num_ds = ( int64_t ) ceil (y_num/2.0 );
380+ const size_t z_num_ds = ceil (z_num/2.0 );
381+ const size_t x_num_ds = ceil (x_num/2.0 );
382+ const size_t y_num_ds = ceil (y_num/2.0 );
383383
384384 APRTimer timer;
385385 timer.verbose_flag = false ;
386386
387387 if (aInitializeOutput) {
388388 timer.start_timer (" downsample_initalize" );
389- aOutput.initialize (y_num_ds, x_num_ds, z_num_ds);
389+ aOutput.init (y_num_ds, x_num_ds, z_num_ds);
390390 timer.stop_timer ();
391391 }
392392
393393 timer.start_timer (" downsample_loop" );
394394 #ifdef HAVE_OPENMP
395395 #pragma omp parallel for default(shared)
396396 #endif
397- for (int64_t z = 0 ; z < z_num_ds; ++z) {
398- for (int64_t x = 0 ; x < x_num_ds; ++x) {
397+ for (size_t z = 0 ; z < z_num_ds; ++z) {
398+ for (size_t x = 0 ; x < x_num_ds; ++x) {
399399
400400 // shifted +1 in original inMesh space
401401 const int64_t shx = std::min (2 *x + 1 , x_num - 1 );
@@ -404,7 +404,7 @@ void down_sample(const MeshData<T>& aInput, MeshData<S>& aOutput, R reduce, C co
404404 const ArrayWrapper<T> &inMesh = aInput.mesh ;
405405 ArrayWrapper<S> &outMesh = aOutput.mesh ;
406406
407- for (int64_t y = 0 ; y < y_num_ds; ++y) {
407+ for (size_t y = 0 ; y < y_num_ds; ++y) {
408408 const int64_t shy = std::min (2 *y + 1 , y_num - 1 );
409409 const int64_t idx = z * x_num_ds * y_num_ds + x * y_num_ds + y;
410410 outMesh[idx] = constant_operator (
@@ -425,15 +425,15 @@ void down_sample(const MeshData<T>& aInput, MeshData<S>& aOutput, R reduce, C co
425425}
426426
427427template <typename T>
428- void downsample_pyrmaid (MeshData<T> &original_image, std::vector<MeshData<T>> &downsampled, size_t l_max, size_t l_min) {
428+ void downsamplePyrmaid (MeshData<T> &original_image, std::vector<MeshData<T>> &downsampled, size_t l_max, size_t l_min) {
429429 downsampled.resize (l_max + 1 ); // each level is kept at same index
430430 downsampled.back ().swap (original_image); // put original image at l_max index
431431
432432 // calculate downsampled in range (l_max, l_min]
433433 auto sum = [](const float x, const float y) -> float { return x + y; };
434434 auto divide_by_8 = [](const float x) -> float { return x/8.0 ; };
435435 for (int level = l_max; level > l_min; --level) {
436- down_sample (downsampled[level], downsampled[level - 1 ], sum, divide_by_8, true );
436+ downsample (downsampled[level], downsampled[level - 1 ], sum, divide_by_8, true );
437437 }
438438}
439439
0 commit comments