cctw  0.2.1
cctwchunkquick.h
Go to the documentation of this file.
1 
2 /*
3  * cctwchunkquick.h
4  *
5  * Created on: May 12, 2014
6  * Author: wozniak
7  */
8 
9 #ifndef CCTWCHUNKQUICK_H
10 #define CCTWCHUNKQUICK_H
11 
12 #include <assert.h>
13 #include <stdlib.h>
14 #include <stdio.h>
15 
16 static inline void
17 assignToChunk(CctwIntVector3D &outputChunkSize,
18  int ix, int iy, int iz, double value,
20 {
21  int y = outputChunkSize.y();
22  int z = outputChunkSize.z();
23  int index = ix*y*z + iy*z + iz;
24 
25  // printf("assignToChunk: %p(%i,%i,%i)[%i] = %0.3f\n", chunk, ix, iy, iz, index, value);
26  chunk[index] = (CctwChunkedData::MergeDataType) value;
27 }
28 
29 static inline CctwChunkedData::MergeDataType*
30 makeChunk(CctwIntVector3D &outputChunkSize)
31 {
32  int x = outputChunkSize.x();
33  int y = outputChunkSize.y();
34  int z = outputChunkSize.z();
35 
36  int length = x*y*z*sizeof(CctwChunkedData::MergeDataType);
37 
38  // printf("makeChunk: %i\n", length);
40  (CctwChunkedData::MergeDataType*) malloc(length);
41  assert(result != NULL);
42  for (int i = 0; i < x; i++)
43  for (int j = 0; j < y; j++)
44  for (int m = 0; m < z; m++)
45  assignToChunk(outputChunkSize, i, j, m, 0, result);
46 
47  // printf("makeChunk: done.\n");
48  return result;
49 }
50 
51 #endif
static CctwChunkedData::MergeDataType * makeChunk(CctwIntVector3D &outputChunkSize)
static void assignToChunk(CctwIntVector3D &outputChunkSize, int ix, int iy, int iz, double value, CctwChunkedData::MergeDataType *chunk)
T x() const
Definition: cctwvector3d.h:17
T z() const
Definition: cctwvector3d.h:19
T y() const
Definition: cctwvector3d.h:18