volume* Volume::createFloatVolume(volume* iVolume) { INFO("Creating FLAT FLOAT32 volume : " + STRG( "[" ) + ITS( iVolume->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iVolume->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iVolume->sizeZ ) + STRG( "]" )); /* @ Allocating float flat array */ float* flatVol_float = (float*) malloc (sizeof(float*) * iVolume->sizeX * iVolume->sizeY * iVolume->sizeZ); /* @ Type conversion */ for (int i = 0; i < iVolume->sizeX * iVolume->sizeY * iVolume->sizeZ; i++) flatVol_float[i] = (float) (unsigned char) iVolume->ptrVol_char[i]; /* @ linking the float array to the original volume structure */ iVolume->ptrVol_float = flatVol_float; INFO("Freeing the BYTE volume"); /* @ freeing the BYTE volume */ free((iVolume->ptrVol_char)); INFO("Creating FLAT FLOAT32 volume DONE"); return iVolume; }
void Volume::extractSubVolume(char*** originalCubeVol, char*** finalCubeVol, const subVolDim* iSubVolDim) { /* @ Calculating the sub volume dimensions */ const int finalSize_X = iSubVolDim->max_X - iSubVolDim->min_X; const int finalSize_Y = iSubVolDim->max_Y - iSubVolDim->min_Y; const int finalSize_Z = iSubVolDim->max_Z - iSubVolDim->min_Z; INFO("Extracting SUB-VOLUME with dimensions : " + STRG( "[" ) + ITS( finalSize_X ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( finalSize_Y ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( finalSize_Y ) + STRG( "]" )); for (int i = 0; i < finalSize_X; i++) { for (int j = 0; j < finalSize_Y; j++) { for (int k = 0; k < finalSize_Z; k++) { finalCubeVol[i][j][k] = originalCubeVol [(iSubVolDim->min_X) + i] [(iSubVolDim->min_Y) + j] [(iSubVolDim->min_Z) + k]; } } } INFO("Extracting SUB-VOLUME DONE"); }
void Volume::packCubeVolume(char*** cubeVolume, volume* iVolume) { INFO("Packing FLAT volume in CUBE array : " + STRG( "[" ) + ITS( iVolume->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iVolume->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iVolume->sizeZ ) + STRG( "]" )); int voxel = 0; for (int i = 0; i < iVolume->sizeX; i++) { for (int j = 0; j < iVolume->sizeY; j++) { for (int k = 0; k < iVolume->sizeZ; k++) { cubeVolume[i][j][k] = iVolume->ptrVol_char[voxel]; voxel++; } } } INFO("Packing FLAT volume in CUBE array DONE"); }
#define optList_isBool(i) \ (optList[i].flag & Opt_Boolean) #define optList_isReverse(i) \ (optList[i].flag & Opt_Reverse) #define optList_size() \ (sizeof(optList) / sizeof(optList[0])) static const struct { const unsigned long flag; /* Option flag */ const int doff; /* data offset */ const char *kw; /* keyword */ const char *opt; /* option */ const char *arg; /* argument */ const char *desc; /* description */ } optList[] = { STRG(Rs_display_name, NULL, "d", NULL, NULL), /* short form */ STRG(Rs_display_name, NULL, "display", "string", "X server to contact"), STRG(Rs_term_name, "termName", "tn", "string", "value of the TERM environment variable"), STRG(Rs_geometry, NULL, "g", NULL, NULL), /* short form */ STRG(Rs_geometry, "geometry", "geometry", "geometry", "size (in characters) and position"), SWCH("C", Opt_console, "intercept console messages"), SWCH("iconic", Opt_iconic, "start iconic"), SWCH("ic", Opt_iconic, NULL), /* short form */ BOOL(Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, "reverse video"), BOOL(Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"), BOOL(Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, "jump scrolling"), #ifdef HAVE_SCROLLBARS BOOL(Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"),
(optList[i].flag & Optflag_Reverse) #define optList_isInfo(i) \ (optList[i].flag & Optflag_Info) static const struct { const uint8_t index; /* Option index */ const uint8_t flag; /* Option flag */ const int16_t doff; /* resource value index or -1 */ const char *kw; /* keyword */ const char *opt; /* option */ const char *arg; /* argument */ const char *desc; /* description */ } optList[] = { STRG (Rs_display_name, NULL, "d", NULL, NULL), /* short form */ STRG (Rs_display_name, NULL, "display", "string", "X server to contact"), STRG (Rs_term_name, "termName", "tn", "string", "value of the TERM environment variable"), STRG (Rs_geometry, NULL, "g", NULL, NULL), /* short form */ STRG (Rs_geometry, "geometry", "geometry", "geometry", "size (in characters) and position"), SWCH ("C", Opt_console, 0, "intercept console messages"), SWCH ("iconic", Opt_iconic, 0, "start iconic"), SWCH ("ic", Opt_iconic, 0, NULL), /* short form */ STRG (Rs_chdir, "chdir", "cd", "string", "start shell in this directory"), SWCH ("dockapp", Opt_dockapp, 0, "start as dockapp"), BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, 0, "reverse video"), BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, 0, "login shell"), STRG (Rs_multiClickTime, "multiClickTime", "mc", "number", "maximum time (in ms) between multi-click selections"), BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"), BOOL (Rs_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"), BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, 0, "tab characters are pastable"),
void Volume::unifyVolumeDim(volume* iVolume) { int eMaxDim = 0; if (iVolume->sizeX >= iVolume->sizeY && iVolume->sizeZ >= iVolume->sizeZ) eMaxDim = iVolume->sizeX; else if (iVolume->sizeY >= iVolume->sizeX && iVolume->sizeY >= iVolume->sizeZ) eMaxDim = iVolume->sizeY; else eMaxDim = iVolume->sizeZ; INFO("MAX DIMENSION : " + ITS(eMaxDim)); /* @ Adjusting the power of two dimension condition */ int eUnifiedDim = 0; if (eMaxDim <= 16) eUnifiedDim = 16; else if (eMaxDim <= 32) eUnifiedDim = 32; else if (eMaxDim <= 64) eUnifiedDim = 64; else if (eMaxDim <= 128) eUnifiedDim = 128; else if (eMaxDim <= 256) eUnifiedDim = 256; else if (eMaxDim <= 512) eUnifiedDim = 512; else if (eMaxDim <= 1024) eUnifiedDim = 1024; else if (eMaxDim <= 2048) eUnifiedDim = 2048; else if (eMaxDim <= 4096) eUnifiedDim = 4096; else if (eMaxDim <= 8192) eUnifiedDim = 8192; INFO("FINAL UNIFIED VOLUME DIMENSION : " + ITS(eUnifiedDim)); /* Calculating the zero-padded area */ int eX_Pad = (eUnifiedDim - iVolume->sizeX) / 2; int eY_Pad = (eUnifiedDim - iVolume->sizeY) / 2; int eZ_Pad = (eUnifiedDim - iVolume->sizeZ) / 2; INFO("Orginal volume dimensions : " + STRG( "[" ) + ITS( iVolume->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iVolume->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iVolume->sizeZ ) + STRG( "]" )); INFO("PADDING : " + STRG( "[" ) + ITS( eX_Pad ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( eY_Pad ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( eZ_Pad ) + STRG( "]" )); /* @ Creating a new flat array for the UNIFIED volume */ char* eUnfiromFlatVolume = (char*) malloc (sizeof(char) * eUnifiedDim * eUnifiedDim * eUnifiedDim); // Setting the unified volume for (int i = 0; i < iVolume->sizeX; i++) for (int j = 0; j < iVolume->sizeY; j++) for(int k = 0; k < iVolume->sizeZ; k++) { int oldIndex = (k * iVolume->sizeX * iVolume->sizeY) + (j * iVolume->sizeX) + i; int newIndex = ((k + eZ_Pad) * eUnifiedDim * eUnifiedDim) + ((j + eY_Pad) * eUnifiedDim) + (i + eX_Pad); eUnfiromFlatVolume [newIndex] = iVolume->ptrVol_char[oldIndex]; } /* @ Freeing the original input array */ free(iVolume->ptrVol_char); /* @ Poiting to the new UNIFIED flat array */ iVolume->ptrVol_char = eUnfiromFlatVolume; /* @ Adjusting the new volume parameters */ iVolume->sizeX = eUnifiedDim; iVolume->sizeY = eUnifiedDim; iVolume->sizeZ = eUnifiedDim; iVolume->sizeUni = eUnifiedDim; }
volume* Volume::extractFinalVolume(volume* iOriginaVol, const subVolDim* iSubVolDim) { INFO("Extracting SUB-VOLUME to be processed in a SINGLE thread"); INFO("Allocating CUBE array for the original volume : " + STRG( "[" ) + ITS( iOriginaVol->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iOriginaVol->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iOriginaVol->sizeZ ) + STRG( "]" )); /* @ Allocating cube array for the original volume */ char*** originalCubeVol = Volume::allocCubeVolume_char (iOriginaVol->sizeX, iOriginaVol->sizeY, iOriginaVol->sizeZ); INFO("Packing the FLAT array in the CUBE "); /* @ Packing the original flat volume in the cube */ Volume::packCubeVolume(originalCubeVol, iOriginaVol); /* @ Allocating the final volume */ volume* iFinalSubVolume = (volume*) malloc (sizeof(volume)); iFinalSubVolume->sizeX = iSubVolDim->max_X - iSubVolDim->min_X; iFinalSubVolume->sizeY = iSubVolDim->max_Y - iSubVolDim->min_Y; iFinalSubVolume->sizeZ = iSubVolDim->max_Z - iSubVolDim->min_Z; if (iFinalSubVolume->sizeX == iFinalSubVolume->sizeY && iFinalSubVolume->sizeX == iFinalSubVolume->sizeZ) { INFO("Final SUB-VOLUME has unified dimensions " + ITS(iFinalSubVolume->sizeX)); iFinalSubVolume->sizeUni = iFinalSubVolume->sizeZ; } else { INFO("Final SUB-VOLUME DOESN'T have unified dimensions " + ITS(iFinalSubVolume->sizeX)); EXIT(0); } iFinalSubVolume->ptrVol_char = (char*) malloc (sizeof(char) * iFinalSubVolume->sizeX * iFinalSubVolume->sizeY * iFinalSubVolume->sizeZ); INFO("Allocating CUBE array for the final SUB-VOLUME: " + STRG( "[" ) + ITS( iFinalSubVolume->sizeX ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iFinalSubVolume->sizeY ) + STRG( "]" ) + " x " + STRG( "[" ) + ITS( iFinalSubVolume->sizeZ ) + STRG( "]" )); /* @ Allocating the final cube volume "SUB-VOLUME" */ char*** finalCubeVol = Volume::allocCubeVolume_char (iFinalSubVolume->sizeX, iFinalSubVolume->sizeY, iFinalSubVolume->sizeZ); INFO("Extractng the SUB-VOLUME"); /* @ Extractig the SUB-VOLUME */ Volume::extractSubVolume(originalCubeVol, finalCubeVol, iSubVolDim); for (int y = 0; y < iFinalSubVolume->sizeY; y++) { for (int x = 0; x < iFinalSubVolume->sizeY; x++) free(originalCubeVol[y][x]); free(originalCubeVol[y]); } free(originalCubeVol); originalCubeVol = NULL; /* @ Dellocating the original cube volume */ // FREE_MEM_3D_CHAR(originalCubeVol, iOriginaVol->sizeX, iOriginaVol->sizeY, iOriginaVol->sizeZ); /* @ Packing the final cube volume in the flat array */ Volume::packFlatVolume(iFinalSubVolume, finalCubeVol); for (int y = 0; y < iFinalSubVolume->sizeY; y++) { for (int x = 0; x < iFinalSubVolume->sizeY; x++) free(finalCubeVol[y][x]); free(finalCubeVol[y]); } free(finalCubeVol); finalCubeVol = NULL; //FREE_MEM_3D_CHAR(finalCubeVol, iFinalSubVolume->sizeX, iFinalSubVolume->sizeY, iFinalSubVolume->sizeZ); INFO("Final volume extraction DONE"); return iFinalSubVolume; }