diff --git a/pypore3d/LICENSE b/pypore3d/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..335ea9d070ad1c319906aeff798584ded23c7387 --- /dev/null +++ b/pypore3d/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2018 The Python Packaging Authority + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/pypore3d/P3D_Blob/p3dBlob.h b/pypore3d/P3D_Blob/p3dBlob.h index c14d749f626db0fe1fd9cc7acd29e97a503f06a6..d47a516d0d7ddf00845fabf2f9a5d9d772ebac7e 100644 --- a/pypore3d/P3D_Blob/p3dBlob.h +++ b/pypore3d/P3D_Blob/p3dBlob.h @@ -9,8 +9,8 @@ extern "C" { #ifndef P3D_BLOB_DEFINED #define P3D_BLOB_DEFINED -#define P3D_FALSE -1 -#define P3D_TRUE 1 +#define P3D_FALSE -1 +#define P3D_TRUE 1 #define P3D_ERROR 0 #define P3D_MEM_ERROR NULL /* Leave it NULL to simplify tests */ @@ -36,7 +36,7 @@ extern "C" { #ifndef P3D_BLOB_MACROS #define P3D_BLOB_MACROS - #define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) + #define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) #define MIN(x,y) (((x) < (y))?(x):(y)) #define MAX(x,y) (((x) > (y))?(x):(y)) @@ -60,6 +60,9 @@ extern "C" { double* sphericity; double* extent; double* volume; + double* Centroid_x; + double* Centroid_y; + double* Centroid_z; } BlobStats; typedef struct { @@ -91,7 +94,7 @@ extern "C" { int p3dBlobAnalysis( unsigned char* in_im, BlobStats* out_stats, - unsigned char* blob_im, // OUT: Balls image + unsigned char* blob_im, // OUT: Balls image unsigned char* star_im, // OUT: Balls image const int dimx, const int dimy, @@ -100,6 +103,7 @@ extern "C" { const int conn, const int max_rot, const int skip_borders, + const int isSaveBlobs, int (*wr_log)(const char*, ...) ); @@ -154,7 +158,7 @@ extern "C" { const int dimy, const int dimz, const int stepsize, // IN: stepsize for porosity - const int centerx, // IN: X coordinate for the center of REV (-1 for + const int centerx, // IN: X coordinate for the center of REV (-1 for // automatic determination of the center) const int centery, // IN: Y coordinate for the center of REV const int centerz, // IN: Z coordinate for the center of REV @@ -176,6 +180,7 @@ extern "C" { int p3dBlobLabeling_ushort( unsigned char* in_im, unsigned short* out_im, + char* filename, const int dimx, const int dimy, const int dimz, @@ -184,10 +189,11 @@ extern "C" { const int skip_borders, int (*wr_log)(const char*, ...) ); - + int p3dBlobLabeling_uint( unsigned char* in_im, unsigned int* out_im, + char* filename, const int dimx, const int dimy, const int dimz, @@ -240,4 +246,4 @@ extern "C" { #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/pypore3d/P3D_Blob/p3dBlobAnalysis.c b/pypore3d/P3D_Blob/p3dBlobAnalysis.c index c2018e920c0b32877edb911f5271101fbe3a8d1c..b9fbcbabf510c35d61b5faad250f51f6113c0df0 100644 --- a/pypore3d/P3D_Blob/p3dBlobAnalysis.c +++ b/pypore3d/P3D_Blob/p3dBlobAnalysis.c @@ -18,6 +18,152 @@ #include "Common/p3dConnectedComponentsLabeling.h" #include "Common/p3dUtils.h" +int p3dWriteRaw8_local( + unsigned char* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing 8-bit RAW file %s ...", filename); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + + return 0; + } + + /* Write raw data to file: */ + if (fwrite(in_im, sizeof (unsigned char), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return 0; + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()) ; + } + + + // Return OK: + return P3D_SUCCESS; +} + + +int p3dWriteRaw32_local( + unsigned int* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + const int flagLittle, + const int flagSigned, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + int* s_tmp_im = NULL; + unsigned int* us_tmp_im = NULL; + int ct; + + // Start tracking computational time: + + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing unsigned integer 32-bit RAW file %s ...", filename); + if (flagSigned == P3D_TRUE) + wr_log("\tSigned/Unsigned: Signed."); + else + wr_log("\tSigned/Unsigned: Unsigned."); + if (flagLittle == P3D_TRUE) + wr_log("\tLittle/Big Endian: Little."); + else + wr_log("\tLittle/Big Endian: Big."); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + in_im = NULL; + + return 0; + } + + /* Read data signed/unsigned: */ + if (flagSigned == P3D_TRUE) { + s_tmp_im = (int*) malloc(dimx * dimy * dimz * sizeof (int)); + + /* Convert to signed: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (flagLittle == P3D_FALSE) + { + //s_tmp_im[ct] = _EndianSwapInt((int) (in_im[ct] - UINT_MAX / 2)); + } + else + { + s_tmp_im[ct] = (int) (in_im[ct] - UINT_MAX / 2); + } + } + + /* Write raw data to file: */ + //fwrite(s_tmp_im, sizeof (short), dimx*dimy, fvol); + if (fwrite(s_tmp_im, sizeof (int), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return 0; + } + + /* Free: */ + free(s_tmp_im); + } else { + /* Swap endian if necessary: */ + if (flagLittle == P3D_FALSE) { + us_tmp_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int)); + + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + //us_tmp_im[ct] = _EndianSwapUnsignedInt(in_im[ct]); + } + + //fwrite(us_tmp_im, sizeof (unsigned short), dimx*dimy, fvol); + if (fwrite(us_tmp_im, sizeof (unsigned int), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return 0; + } + + free(us_tmp_im); + } else { + fwrite(in_im, sizeof (unsigned int), dimx * dimy * dimz, fvol); + } + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + return P3D_SUCCESS; +} + + void _drawline(unsigned char* in_im, unsigned int* lbl_im, unsigned int curr_lbl, @@ -64,7 +210,7 @@ void _drawline(unsigned char* in_im, normr_1 = r_1 / r_2; } - // Make sure signs are correct: + // Make sure signs are correct: normr_0 = (r_0 > 0) ? fabs(normr_0) : (-fabs(normr_0)); normr_1 = (r_1 > 0) ? fabs(normr_1) : (-fabs(normr_1)); normr_2 = (r_2 > 0) ? fabs(normr_2) : (-fabs(normr_2)); @@ -83,10 +229,10 @@ void _drawline(unsigned char* in_im, prec_y = y; prec_z = z; - // Explore the incremental and decremental sides while edges of + // Explore the incremental and decremental sides while edges of // VOI are reached: - // Explore the incremental and decremental sides while edges of + // Explore the incremental and decremental sides while edges of // mask are reached of image edges are reached: // Explore the incremental versus while edges of VOI are reached: @@ -174,11 +320,13 @@ int p3dBlobAnalysis( const int conn, const int max_rot, const int skip_borders, + //const bool isSaveBlobs, + const int isSaveBlobs, int (*wr_log)(const char*, ...) - ) { + ) { unsigned int* dt_im; - unsigned int* lbl_im; + unsigned int* lbl_im; int i, j, k; int a, b, c; int dist_x, dist_y, dist_z; @@ -225,7 +373,9 @@ int p3dBlobAnalysis( unsigned char prec_status, curr_status; unsigned int iseed; time_t t; - + + //unsigned char* centroid_im; + // Start tracking computational time: if (wr_log != NULL) { p3dResetStartTime(); @@ -254,17 +404,19 @@ int p3dBlobAnalysis( // Get connected components labeled image and allocate memory for related image: P3D_MEM_TRY(lbl_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); P3D_TRY(p3dConnectedComponentsLabeling_uint(in_im, lbl_im, &num_el, &volumes, &bbs, - dimx, dimy, dimz, conn, P3D_FALSE, skip_borders)); + dimx, dimy, dimz, conn, P3D_FALSE, skip_borders)); - if (blob_im == NULL) { + //if (blob_im == NULL) { // amal free_flag = P3D_TRUE; P3D_MEM_TRY(blob_im = (unsigned char*) calloc(dimx * dimy * dimz, sizeof (unsigned char))); - } + //P3D_MEM_TRY(centroid_im = (unsigned char*) calloc(dimx * dimy * dimz, sizeof (unsigned char))); + + //} if (wr_log != NULL) { wr_log("\tBlob labeling successfully performed."); } - + // Allocate memory for output stats: out_stats->blobCount = num_el; @@ -278,6 +430,10 @@ int p3dBlobAnalysis( out_stats->l_min = (double*) malloc(num_el * sizeof (double)); out_stats->l_max = (double*) malloc(num_el * sizeof (double)); out_stats->sphericity = (double*) malloc(num_el * sizeof (double)); + out_stats->Centroid_x = (double*)malloc(num_el * sizeof(double)); + out_stats->Centroid_y = (double*)malloc(num_el * sizeof(double)); + out_stats->Centroid_z = (double*)malloc(num_el * sizeof(double)); + rot_theta = (double*) malloc(max_rot * sizeof (double)); rot_phi = (double*) malloc(max_rot * sizeof (double)); @@ -292,6 +448,9 @@ int p3dBlobAnalysis( out_stats->l_min = NULL; out_stats->l_max = NULL; out_stats->sphericity = NULL; + out_stats->Centroid_x = NULL; + out_stats->Centroid_y = NULL; + out_stats->Centroid_z = NULL; } @@ -319,8 +478,9 @@ int p3dBlobAnalysis( // Init counters: max_sph = 0; + /// - /// Apply the "star" algorithm in order to get the minimum + /// Apply the "star" algorithm in order to get the minimum /// and maximum axis length: /// @@ -352,7 +512,7 @@ int p3dBlobAnalysis( srand(iseed); // For each of the max_rot direction computed: - for (ct_rot = 0; ct_rot < max_rot; ct_rot++) + for (ct_rot = 0; ct_rot < max_rot; ct_rot++) { rot_theta[ct_rot] = (rand() / ((double) RAND_MAX + 1)) * M_PI; rot_phi[ct_rot] = (rand() / ((double) RAND_MAX + 1)) * M_PI; @@ -381,7 +541,7 @@ int p3dBlobAnalysis( normr_1 = r_1 / r_2; } - // Make sure signs are correct: + // Make sure signs are correct: normr_0 = (r_0 > 0) ? fabs(normr_0) : (-fabs(normr_0)); normr_1 = (r_1 > 0) ? fabs(normr_1) : (-fabs(normr_1)); normr_2 = (r_2 > 0) ? fabs(normr_2) : (-fabs(normr_2)); @@ -389,7 +549,7 @@ int p3dBlobAnalysis( x = cen_i; y = cen_j; z = cen_k; - + // Reset status: prec_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; @@ -400,10 +560,10 @@ int p3dBlobAnalysis( prec_y = y; prec_z = z; - // Explore the incremental and decremental sides while edges of + // Explore the incremental and decremental sides while edges of // VOI are reached: - // Explore the incremental and decremental sides while edges of + // Explore the incremental and decremental sides while edges of // mask are reached of image edges are reached: // Explore the incremental versus while edges of VOI are reached: @@ -488,7 +648,29 @@ int p3dBlobAnalysis( // ------------------------------------------------------------ - // Extract minimum and maximum length from the array + // Calculate the Centroid: + double total_x = 0.0, total_y = 0.0, total_z = 0.0; + double num_voxels = 0.0; + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) { + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) { + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (lbl_im[I(i, j, k, dimx, dimy)] == curr_lbl) { + total_x += i; + total_y += j; + total_z += k; + num_voxels += 1.0; + } + } + } + } + + out_stats->Centroid_x[ct] = total_x / num_voxels; + out_stats->Centroid_y[ct] = total_y / num_voxels; + out_stats->Centroid_z[ct] = total_z / num_voxels; + + //centroid_im[I((int)out_stats->Centroid_x[ct], (int)out_stats->Centroid_y[ct], (int)out_stats->Centroid_z[ct], dimx, dimy)] = 255; + + // Extract minimum and maximum length from the array // of all the considered lengths: l_max = 0.0; max_idx = 0; @@ -546,7 +728,7 @@ int p3dBlobAnalysis( rad = (int) (sqrt((double) max_sph)); // Fill the ball (if required as output): - if (free_flag == P3D_FALSE) { + //if (free_flag == P3D_FALSE) { //amal for (c = (max_k - rad); c <= (max_k + rad); c++) for (b = (max_j - rad); b <= (max_j + rad); b++) for (a = (max_i - rad); a <= (max_i + rad); a++) { @@ -561,7 +743,7 @@ int p3dBlobAnalysis( blob_im [ I(a, b, c, dimx, dimy) ] = OBJECT; } } - } + //} //printf("ct: %d - i: %d - j: %d - k: %d - rad: %d\n",ct,max_i,max_j,max_k,rad); @@ -569,7 +751,7 @@ int p3dBlobAnalysis( /// - /// Volume: + /// Volume: /// out_stats->volume[ct] = volumes[ct]*(voxelsize * voxelsize * voxelsize); @@ -581,7 +763,7 @@ int p3dBlobAnalysis( } /// - /// Diameter of the maximum inscribed sphere: + /// Diameter of the maximum inscribed sphere: /// if (max_sph != 0) { out_stats->max_sph[ct] = 2.0 * sqrt((double) max_sph) * voxelsize; @@ -603,8 +785,8 @@ int p3dBlobAnalysis( /// /// Extent parameter, i.e. the ratio between the volume of the - /// blob and the volume of the minimum bounding box (the - /// smallest parallelepiped oriented according to image axis + /// blob and the volume of the minimum bounding box (the + /// smallest parallelepiped oriented according to image axis /// containing the blob). /// bb_vol = ((double) dist_x) * ((double) dist_y) * ((double) dist_z); @@ -612,7 +794,7 @@ int p3dBlobAnalysis( out_stats->extent[ct] = volumes[ct] / bb_vol; else out_stats->extent[ct] = 0.0; - + } @@ -726,8 +908,18 @@ int p3dBlobAnalysis( wr_log("Pore3D - Blob analysis performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); } - // Release resources: - if (free_flag == P3D_TRUE) free(blob_im); + if (isSaveBlobs>0) + { + p3dWriteRaw8_local(blob_im, "eq_circle_img.raw", dimx, dimy,dimz,NULL,NULL); + p3dWriteRaw32_local(lbl_im, "label_img_32.raw", dimx, dimy,dimz,0,0,NULL,NULL); + + } + + //p3dWriteRaw8_local(centroid_im, "centroid_im.raw", dimx, dimy,dimz,0,0,NULL,NULL); + + //free(centroid_im); + // Release resources: + if (free_flag == P3D_TRUE) free(blob_im); //amal if (dt_im != NULL) free(dt_im); if (lbl_im != NULL) free(lbl_im); if (volumes != NULL) free(volumes); @@ -747,8 +939,8 @@ MEM_ERROR: wr_log("Pore3D - Not enough (contiguous) memory or maximum number of blobs reached. Program will exit."); } - // Release resources: - if (free_flag == P3D_TRUE) free(blob_im); + // Release resources: + // if (free_flag == P3D_TRUE) free(blob_im); //amal if (dt_im != NULL) free(dt_im); if (lbl_im != NULL) free(lbl_im); if (volumes != NULL) free(volumes); diff --git a/pypore3d/P3D_Blob/p3dBlobLabeling.c b/pypore3d/P3D_Blob/p3dBlobLabeling.c index 1f4e6e723f0174bc3bcbf75f1251697342e0ab05..ac1cbe146cf7db7412c05dd24cb28cd5304c99af 100644 --- a/pypore3d/P3D_Blob/p3dBlobLabeling.c +++ b/pypore3d/P3D_Blob/p3dBlobLabeling.c @@ -8,13 +8,162 @@ #include "p3dTime.h" #include "Common/p3dConnectedComponentsLabeling.h" -#include "Common/p3dUtils.h" +#include "Common/p3dUtils.h"out_rev + +int p3dWriteRaw8_local1( + unsigned char* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing 8-bit RAW file %s ...", filename); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + + return 0; + } + + /* Write raw data to file: */ + if (fwrite(in_im, sizeof (unsigned char), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return 0; + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()) ; + } + + + // Return OK: + return P3D_SUCCESS; +} + +int p3dWriteRaw32_local1( + unsigned int* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + const int flagLittle, + const int flagSigned, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + int* s_tmp_im = NULL; + unsigned int* us_tmp_im = NULL; + int ct; + + // Start tracking computational time: + + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing unsigned integer 32-bit RAW file %s ...", filename); + if (flagSigned == P3D_TRUE) + wr_log("\tSigned/Unsigned: Signed."); + else + wr_log("\tSigned/Unsigned: Unsigned."); + if (flagLittle == P3D_TRUE) + wr_log("\tLittle/Big Endian: Little."); + else + wr_log("\tLittle/Big Endian: Big."); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + in_im = NULL; + + return 0; + } + + /* Read data signed/unsigned: */ + if (flagSigned == P3D_TRUE) { + s_tmp_im = (int*) malloc(dimx * dimy * dimz * sizeof (int)); + + /* Convert to signed: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (flagLittle == P3D_FALSE) + { + //s_tmp_im[ct] = _EndianSwapInt((int) (in_im[ct] - UINT_MAX / 2)); + } + else + { + s_tmp_im[ct] = (int) (in_im[ct] - UINT_MAX / 2); + } + } + + /* Write raw data to file: */ + //fwrite(s_tmp_im, sizeof (short), dimx*dimy, fvol); + if (fwrite(s_tmp_im, sizeof (int), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return 0; + } + + /* Free: */ + free(s_tmp_im); + } else { + /* Swap endian if necessary: */ + if (flagLittle == P3D_FALSE) { + us_tmp_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int)); + + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + //us_tmp_im[ct] = _EndianSwapUnsignedInt(in_im[ct]); + } + + //fwrite(us_tmp_im, sizeof (unsigned short), dimx*dimy, fvol); + if (fwrite(us_tmp_im, sizeof (unsigned int), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return 0; + } + + free(us_tmp_im); + } else { + fwrite(in_im, sizeof (unsigned int), dimx * dimy * dimz, fvol); + } + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + return P3D_SUCCESS; +} + // Wrapper for the extern: + + int p3dBlobLabeling_ushort( unsigned char* in_im, unsigned short* out_im, + char* filename, const int dimx, const int dimy, const int dimz, @@ -59,6 +208,9 @@ MEM_ERROR: wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); } + if (filename!=NULL) + p3dWriteRaw8_local1(out_im, filename, dimx, dimy,dimz,0,0,NULL,NULL); + // Return OK: return P3D_ERROR; } @@ -66,6 +218,7 @@ MEM_ERROR: int p3dBlobLabeling_uint( unsigned char* in_im, unsigned int* out_im, + char* filename, const int dimx, const int dimy, const int dimz, @@ -91,15 +244,16 @@ int p3dBlobLabeling_uint( wr_log("\tBorders skipped. "); } - - P3D_TRY( p3dConnectedComponentsLabeling_uint(in_im, out_im, NULL, NULL, NULL, dimx, dimy, dimz, - conn, random_lbl, skip_borders) ); + P3D_MEM_TRY(out_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); + P3D_TRY( p3dConnectedComponentsLabeling_uint(in_im, out_im, NULL, NULL, NULL, dimx, dimy, dimz,conn, random_lbl, skip_borders) ); // Print elapsed time (if required): if (wr_log != NULL) { wr_log("Pore3D - Blob labeling performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); } - + + if (filename!=NULL) + p3dWriteRaw32_local1(out_im, filename, dimx, dimy,dimz,0,0,NULL,NULL); // Return OK: return P3D_SUCCESS; diff --git a/pypore3d/README.md b/pypore3d/README.md new file mode 100644 index 0000000000000000000000000000000000000000..30fd944a6f840f161f02b500e41ca58657061b94 --- /dev/null +++ b/pypore3d/README.md @@ -0,0 +1,6 @@ +#Pore3D python wrappers + +PyPore3D: An open source software tool for imaging data processing and analysis of porous and multiphase media + +Information is found in the gitlab link: +https://gitlab.elettra.eu/amal.abouelhassan/pypore3d \ No newline at end of file diff --git a/pypore3d/p3dBlobPy.py b/pypore3d/p3dBlobPy.py index e7cc5a61b12798b82b7f30e58948de936c4a17db..bfd578ddde91f10379b2fb7504c031281cc11bfe 100644 --- a/pypore3d/p3dBlobPy.py +++ b/pypore3d/p3dBlobPy.py @@ -109,7 +109,7 @@ def py_p3dAnisotropyAnalysis(image_data, dimx, dimy, dimz = 0, resolution = 1.0) return out_AnisotropyStats #Blob labeling -def py_p3dBlobLabeling(image_data, dimx, dimy, dimz = 0, conn3D = CONN6 ): +def py_p3dBlobLabeling(image_data, dimx, dimy, dimz = 0, label_image_file =None, conn3D = CONN6 ): """ Performs connected components (blobs) labeling using the algorithm proposed in [1]. @@ -151,10 +151,10 @@ def py_p3dBlobLabeling(image_data, dimx, dimy, dimz = 0, conn3D = CONN6 ): py_printErrorMessage(-3) return - out_image = malloc_ushort(dimx*dimy*dimz) + out_image = malloc_uint(dimx*dimy*dimz) skip_borders = 1 rand = 0 - err_code = p3dBlobLabeling_ushort(image_data, out_image, dimx,dimy,dimz,conn3D, rand , skip_borders, None) + err_code = p3dBlobLabeling_uint(image_data, out_image, label_image_file, dimx,dimy,dimz,conn3D, rand , skip_borders, None) py_printErrorMessage(err_code) return out_image @@ -181,6 +181,8 @@ def py_p3dGetMaxVolumeBlob3D(image_data, dimx, dimy, dimz = 0, conn3D = CONN6): dimx,dimy,dimz: three variables representing the dimensions of image to read. + label_image_file: the name of the file which will store a 32-bit raw image represnting the labeled blobs. If no file name is provided, the image will not be saved. + conn3D: The desired connectivity, i.e. 6, 18 or 26 for 3D images. The default connectivity is 6 for three dimensional images. """ @@ -440,7 +442,7 @@ def py_p3dMinVolumeFilter3D(image_data, dimx, dimy, dimz = 0, min_vol = 5, conn # Blob Analysis -def py_p3dBlobAnalysis(image_data, dimx, dimy, dimz = 0, blob_im = None, star_im = None, resolution = 1.0, conn = 6, blob_analysis_file = "blob_analysis.txt"): +def py_p3dBlobAnalysis(image_data, dimx, dimy, dimz = 0, resolution = 1.0, conn = 6, blob_analysis_file = "blob_analysis.txt", isSavedBlob=0): """ Performs a series of direct 3D analysis suitable for porous media having isolated pores. If the pore space is formed by an isolated set of “blobs†(connected components), a series of descriptors for size and shape of each “blob†can be computed. The analysis is based on the concept of connected com- ponents and their labeling (see py_p3dBlobLabeling_8). @@ -485,6 +487,10 @@ def py_p3dBlobAnalysis(image_data, dimx, dimy, dimz = 0, blob_im = None, star_im conn: Specify the desired connectivity: 6 (default), 18 or 26. blob_analysis_file: tab-delimeted file where the results of the blob statiscs are saved. If no name is specified, the file will be saved under the name "blob_analysis.txt" in the default folder location. + + isSavedBlob: if the flag is set to 0, no image files are saved. If it is set to any value greater than 0, two files will be saved: + label_img_32.raw: a 32-bit raw file representing the labels of the blobs + eq_circle_img.raw: an 8-bit raw file represnting the eq-circle of every detected blob Remarks: --------- @@ -511,7 +517,7 @@ def py_p3dBlobAnalysis(image_data, dimx, dimy, dimz = 0, blob_im = None, star_im borders = P3D_FALSE; else : borders = P3D_TRUE; - err_code = p3dBlobAnalysis(image_data, out_BlobStat, blob_im, star_im, dimx,dimy,dimz,resolution,conn,max_rot,borders, None) + err_code = p3dBlobAnalysis(image_data, out_BlobStat, None, None, dimx,dimy,dimz,resolution,conn,max_rot,borders,isSavedBlob, None) py_printErrorMessage(err_code) PrintBlobStruct(out_BlobStat, blob_analysis_file) return out_BlobStat diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxList.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxList.c new file mode 100644 index 0000000000000000000000000000000000000000..df2994a6f100235ff3f70372fa529b892570ba95 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxList.c @@ -0,0 +1,119 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dBoundingBoxList.h" +#include "p3dUtils.h" + +void bb_list_init (bb_list_t *list) +{ + *list = NULL; +} + +int bb_list_add (bb_list_t *list, bb_t item) +{ + bb_list_elem_t* new_l; + + // Alloc memory for the new item: + new_l = (bb_list_elem_t*) malloc (sizeof(bb_list_elem_t)); + + // Push item into queue: + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_TRUE; +} + + +int bb_list_isempty (bb_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + +// List is deleted after conversion: +bb_t* bb_list_toarray (bb_list_t *list, unsigned int numel ) +{ + bb_list_elem_t* tmp_l; + + bb_t* v; + unsigned int i; + + v = (bb_t*) calloc ( (unsigned int) numel, sizeof(bb_t)); + + // Convert list to array: + for (i = (unsigned int) (numel - 1); i > 0; i = (unsigned int) (i - 1) ) + { + if (list != NULL) + { + v[i] = (*list)->elem; + + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + + // Last element: + if (list != NULL) + { + v[0] = (*list)->elem; + + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + return v; +} + +void bb_list_clear (bb_list_t *list) +{ + bb_list_elem_t* tmp_l; + + // Scan whole list: + while( *list != NULL ) + { + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + // Final assignment for safety: + *list = NULL; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxList.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxList.h new file mode 100644 index 0000000000000000000000000000000000000000..784edf88b7924c189c5e7d705f42406cd7857f12 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxList.h @@ -0,0 +1,64 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dBoundingBoxT.h" + +/********************************************************************* + * + * uint_list_t type definitions. + * + *********************************************************************/ +#ifndef BB_L_DEFINED + #define BB_L_DEFINED + + struct bb_lelem_t { + bb_t elem; + struct bb_lelem_t *next; + }; + + typedef struct bb_lelem_t bb_list_elem_t; + + typedef bb_list_elem_t* bb_list_t; + +#endif +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void bb_list_init (bb_list_t *list); + +int bb_list_add (bb_list_t *list, bb_t item); + +int bb_list_isempty(bb_list_t list); + +bb_t* bb_list_toarray (bb_list_t *list, unsigned int numel ); + +void bb_list_clear (bb_list_t *list); + + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxT.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxT.h new file mode 100644 index 0000000000000000000000000000000000000000..8efa4476d888a285cc75d4f0cb6677c4292421cc --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dBoundingBoxT.h @@ -0,0 +1,47 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/********************************************************************* + * + * bb_t type definitions (bounding box). + * + *********************************************************************/ + +#ifndef BB_T_DEFINED + +typedef struct { + int min_x; + int max_x; + int min_y; + int max_y; + int min_z; + int max_z; +} bb_t; + +#endif + +#define BB_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling.h new file mode 100644 index 0000000000000000000000000000000000000000..ad867803b040cd2e48af4bbfe157f91ccbac9cb7 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling.h @@ -0,0 +1,101 @@ + +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/************************************************************************ + * CCL3 Performs connected component labeling of a 3D binary volume. + * CCL3 performs connected component labeling of a 3D binary volume + * using 26-connectivity for object voxels and 6-connectivity for + * background voxels. The algorithm uses a flexible tradeoff between + * speed and memory by means of parameter SIZE. + * + * LB = CCL3(VOI) apply the fastest connected component labeling (i.e. + * SIZE = 3). + * + * LB = CCL3(VOI, SIZE) apply connected component labeling using the + * specified SIZE for the sub-volume scanning (see references). + * + * Class Support + * ------------- + * The input volume VOI must be logical. SIZE must be an odd value greater + * than 3. + * + * Remarks + * ------- + * The SIZE parameters controls the tradeoff between computational time + * and memory occupation. The fastest execution requires SIZE = 3. + * + * Example + * ------------ + * + * lbl = ccl3(voi); + * + * References + * ---------- + * [1] Q. Hu et al. Fast connected-component labeling in + * three-dimensional binary images based on iterative recursion. + * Computer Vision and Image Understanding, 99(2005):414-434, 2005. + + + * Author: Brun Francesco + * Date: 10 may 2008 + + ************************************************************************/ +#include <limits.h> + +#include "p3dBoundingBoxT.h" +//#include "p3dUIntList.h" //amal + +int p3dConnectedComponentsLabeling_ushort ( + unsigned char* in_rev, + unsigned short* out_rev, + unsigned int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, + const int skip_borders + ); + +int p3dConnectedComponentsLabeling_uint ( + unsigned char* in_rev, + unsigned int* out_rev, + unsigned int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, + const int skip_borders + ); + + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_uint.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_uint.c new file mode 100644 index 0000000000000000000000000000000000000000..38ea888ab0cfda4d7f501772545b2e037ccc8149 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_uint.c @@ -0,0 +1,810 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/************************************************************************ + * CCL3 Performs connected component labeling of a 3D binary volume. + * CCL3 performs connected component labeling of a 3D binary volume + * using 26-connectivity for object voxels and 6-connectivity for + * background voxels. The algorithm uses a flexible tradeoff between + * speed and memory by means of parameter SIZE. + * + * LB = CCL3(VOI) apply the fastest connected component labeling (i.e. + * SIZE = 3). + * + * LB = CCL3(VOI, SIZE) apply connected component labeling using the + * specified SIZE for the sub-volume scanning (see references). + * + * Class Support + * ------------- + * The input volume VOI must be logical. SIZE must be an odd value greater + * than 3. + * + * Remarks + * ------- + * The SIZE parameters controls the tradeoff between computational time + * and memory occupation. The fastest execution requires SIZE = 3. + * + * Example + * ------------ + * + * lbl = ccl3(voi); + * + * References + * ---------- + * [1] Q. Hu et al. Fast connected-component labeling in + * three-dimensional binary images based on iterative recursion. + * Computer Vision and Image Understanding, 99(2005):414-434, 2005. + + + * Author: Brun Francesco - Universit� degli studi di Trieste + * Date: 10 may 2008 + + ************************************************************************/ +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <omp.h> + +#include "p3dCoordsQueue.h" +#include "p3dUIntList.h" +#include "p3dBoundingBoxList.h" +#include "p3dUtils.h" + + +#define ON_LABEL 1 // ON Value: +#define FIRST_LABEL 3 // First label: +#define TEMP_LABEL 2 // Temporary label: +#define RAND_OFF 4500 + +void putCoordsInQueue_uint( + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned int m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + coords_t tmp_coords; // Temporary coords + + + // If we're on an object voxel: + if (out_rev[ I(i, j, k, dimx, dimy) ] == ON_LABEL) { + // Check if this is the last step: + if (ct == (win_size - 2)) { + // Border voxels are set to m: + out_rev[ I(i, j, k, dimx, dimy) ] = m; + + // A border voxel is pushed into queue: + tmp_coords.x = i; + tmp_coords.y = j; + tmp_coords.z = k; + coords_queue_push(queue, tmp_coords); + } else { + // Mark voxel for further scan: + out_rev[ I(i, j, k, dimx, dimy) ] = TEMP_LABEL; + } + } +} + +void conn_fun6_uint( + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned int m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + c = k - 1; + b = j; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +void conn_fun18_uint( + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned int m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + // Perform 6-connectivity: + conn_fun6_uint(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 12 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + +} + +void conn_fun26_uint( + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned int m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + // Perform 18-connectivity: + conn_fun18_uint(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 8 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j - 1; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j - 1; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i - 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i + 1; + putCoordsInQueue_uint(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +int first_unlabeled_uint( + unsigned int* lbl, + const int nRows, + const int nCols, + const int nPlanes, + const int winsize, + coords_t* coords + ) { + int i, j, k; + int off; + + off = winsize / 2; // integer division: + + // Volume scanning: + for (k = off; k < (nPlanes - off); k++) + for (j = off; j < (nCols - off); j++) + for (i = off; i < (nRows - off); i++) { + if (lbl[ I(i, j, k, nRows, nCols) ] == ON_LABEL) { + coords->x = i; + coords->y = j; + coords->z = k; + return P3D_TRUE; + } + } + + return P3D_FALSE; +} + +/*int _p3dConnectedComponentsLabeling( + unsigned char* in_rev, + unsigned short* out_rev, + int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int skip_borders + ) { + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + int win_size; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + uint_list_t vol_list; // List for region volume counting + bb_list_t bb_list; // List for bounding boxes + bb_t curr_bb; + + unsigned short m; // Current label + int ct, offset; // Counter for local subvolume size + int a, b, c; + int i, j, k; + int m_ct; // Counter for volume counting + int lbl_ct; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + const int a_rad = 1; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev; + unsigned short* tmp_out_rev; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t * queue // FIFO data structure for coords storage + ); + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + win_size = 3; + + // Set the correct type of connectivity based on input parameter: + if (conn == CONN6) + conn_fun = conn_fun6; + else if (conn == CONN18) + conn_fun = conn_fun18; + else // default: + conn_fun = conn_fun26; + + // Apply algorithm: + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Initialize input: + P3D_TRY(tmp_in_rev = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + p3dZeroPadding3D_uchar2uchar(in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad); + + + // Initialize output label volume with ON_LABEL on non-zero values + // of input volume: + P3D_TRY(tmp_out_rev = (unsigned short*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned short))); + +#pragma omp parallel for + for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) + tmp_out_rev[ct] = (tmp_in_rev[ct]) ? ON_LABEL : 0; + + + + // Initialize variables: + coords_queue_init(&queue); + uint_list_init(&vol_list); + bb_list_init(&bb_list); + + + m = FIRST_LABEL; + lbl_ct = 0; + + + // While not all voxels are labeled: + while (first_unlabeled(tmp_out_rev, a_dimx, a_dimy, a_dimz, win_size, &coords) == P3D_TRUE) { + // Re-init counter for current connected component: + m_ct = 0; + + // Init bounding box: + curr_bb.max_x = 0; + curr_bb.max_y = 0; + curr_bb.max_z = 0; + curr_bb.min_x = INT_MAX; + curr_bb.min_y = INT_MAX; + curr_bb.min_z = INT_MAX; + + // Push the first unlabeled object voxel into queue: + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while (coords_queue_isempty(queue) == P3D_FALSE) { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x, coords.y, coords.z, a_dimx, a_dimy) ] = TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) + for (j = (coords.y - offset); j <= (coords.y + offset); j++) + for (i = (coords.x - offset); i <= (coords.x + offset); i++) { + + if (tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] == TEMP_LABEL) { + // Perform 6-, 18-, or 26-connectivity: + conn_fun(tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, m, &queue); + + // A voxels previously marked is set to m: + tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] = m; + + // Define bounding box: + curr_bb.max_x = MAX(curr_bb.max_x, i - a_rad); + curr_bb.max_y = MAX(curr_bb.max_y, j - a_rad); + curr_bb.max_z = MAX(curr_bb.max_z, k - a_rad); + curr_bb.min_x = MIN(curr_bb.min_x, i - a_rad); + curr_bb.min_y = MIN(curr_bb.min_y, j - a_rad); + curr_bb.min_z = MIN(curr_bb.min_z, k - a_rad); + + // Increment counter for region volume: + m_ct++; + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + + + // Skip object if required: + if ((skip_borders == P3D_TRUE) && ((curr_bb.min_x == 0) || (curr_bb.min_y == 0) + || (curr_bb.min_z == 0) || (curr_bb.max_x == (dimx - 1)) + || (curr_bb.max_y == (dimy - 1)) || (curr_bb.max_z == (dimz - 1)))) { + // Restore OBJECT label instead of current label: +#pragma omp parallel for private(a,b) + for (c = curr_bb.min_z; c <= curr_bb.max_z; c++) + for (b = curr_bb.min_y; b <= curr_bb.max_y; b++) + for (a = curr_bb.min_x; a <= curr_bb.max_x; a++) { + if (tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] == m) { + tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] = USHRT_MAX; // Object + } + } + } else { + // Save connected component volume: + uint_list_add(&vol_list, m_ct); + bb_list_add(&bb_list, curr_bb); + + + // Increment counter (it is equal to (m - 3) if labels are NOT randomly assigned): + m++; + lbl_ct++; + } + } + + // Return number of connected components labeled: + if (numOfConnectedComponents != NULL) + *numOfConnectedComponents = lbl_ct; + + + // Return the array of volumes for each connected component. + // (The list is deleted after this operation): + if (volumes != NULL) + (*volumes) = uint_list_toarray(&vol_list, lbl_ct); + else + uint_list_clear(&vol_list); + + if (boundingBoxes != NULL) + (*boundingBoxes) = bb_list_toarray(&bb_list, lbl_ct); + else + bb_list_clear(&bb_list); + + + // Crop output: + p3dCrop3D_uint2ushort(tmp_out_rev, out_rev, a_dimx, a_dimy, a_dimz, a_rad); + + + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code: + return P3D_MEM_ERROR; +}*/ + +int p3dConnectedComponentsLabeling_uint( + unsigned char* in_rev, + unsigned int* out_rev, + unsigned int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, + const int skip_borders + ) { + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + int win_size; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + uint_list_t vol_list; // List for region volume counting + bb_list_t bb_list; // List for bounding boxes + bb_t curr_bb; + + unsigned int m; // Current label + int ct, offset; // Counter for local subvolume size + int a, b, c; + int i, j, k; + unsigned int m_ct; // Counter for volume counting + unsigned int lbl_ct; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + const int a_rad = 1; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev; + unsigned int* tmp_out_rev; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned int m, + coords_queue_t * queue // FIFO data structure for coords storage + ); + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + win_size = 3; + + // Set the correct type of connectivity based on input parameter: + if (conn == CONN6) + conn_fun = conn_fun6_uint; + else if (conn == CONN18) + conn_fun = conn_fun18_uint; + else // default: + conn_fun = conn_fun26_uint; + + // Apply algorithm: + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Initialize input: + P3D_TRY(tmp_in_rev = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + p3dZeroPadding3D_uchar2uchar(in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad); + + + // Initialize output label volume with ON_LABEL on non-zero values + // of input volume: + P3D_TRY(tmp_out_rev = (unsigned int*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned int))); + +#pragma omp parallel for + for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) + tmp_out_rev[ct] = (tmp_in_rev[ct] == OBJECT) ? ON_LABEL : 0; + + + + + // Initialize variables: + coords_queue_init(&queue); + uint_list_init(&vol_list); + bb_list_init(&bb_list); + + // Initialize label counter: + if (random_lbl == P3D_TRUE) { + m = (unsigned int) (rand() % (UINT_MAX - 2 * RAND_OFF) + RAND_OFF); + } else { + m = FIRST_LABEL; + } + lbl_ct = 0; + + // While not all voxels are labeled: + while (first_unlabeled_uint(tmp_out_rev, a_dimx, a_dimy, a_dimz, win_size, &coords) == P3D_TRUE) { + // Re-init counter for current connected component: + m_ct = 0; + + // Init bounding box: + curr_bb.max_x = 0; + curr_bb.max_y = 0; + curr_bb.max_z = 0; + curr_bb.min_x = INT_MAX; + curr_bb.min_y = INT_MAX; + curr_bb.min_z = INT_MAX; + + // Push the first unlabeled object voxel into queue: + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while (coords_queue_isempty(queue) == P3D_FALSE) { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x, coords.y, coords.z, a_dimx, a_dimy) ] = TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) + for (j = (coords.y - offset); j <= (coords.y + offset); j++) + for (i = (coords.x - offset); i <= (coords.x + offset); i++) { + + if (tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] == TEMP_LABEL) { + // Perform 6-, 18-, or 26-connectivity: + conn_fun(tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, m, &queue); + + // A voxels previously marked is set to m: + tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] = m; + + // Define bounding box: + curr_bb.max_x = MAX(curr_bb.max_x, i - a_rad); + curr_bb.max_y = MAX(curr_bb.max_y, j - a_rad); + curr_bb.max_z = MAX(curr_bb.max_z, k - a_rad); + curr_bb.min_x = MIN(curr_bb.min_x, i - a_rad); + curr_bb.min_y = MIN(curr_bb.min_y, j - a_rad); + curr_bb.min_z = MIN(curr_bb.min_z, k - a_rad); + + // Increment counter for region volume: + m_ct = (unsigned int) (m_ct + 1); + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + + + // Skip object if required: + if ((skip_borders == P3D_TRUE) && ((curr_bb.min_x == 0) || (curr_bb.min_y == 0) + || (curr_bb.min_z == 0) || (curr_bb.max_x == (dimx - 1)) + || (curr_bb.max_y == (dimy - 1)) || (curr_bb.max_z == (dimz - 1)))) { + // Restore OBJECT label instead of current label: +#pragma omp parallel for private(a,b) + for (c = curr_bb.min_z; c <= curr_bb.max_z; c++) + for (b = curr_bb.min_y; b <= curr_bb.max_y; b++) + for (a = curr_bb.min_x; a <= curr_bb.max_x; a++) { + if (tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] == m) { + tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] = UINT_MAX; // Object + } + } + } else { + // Save connected component volume: + uint_list_add(&vol_list, m_ct); + bb_list_add(&bb_list, curr_bb); + + // Increment label for next connected component: + if (random_lbl == P3D_TRUE) { + m = (unsigned int) (rand() % (UINT_MAX - 2 * RAND_OFF) + RAND_OFF); + } else { + m++; + } + + // Increment counter (it is equal to (m - 3) if labels are NOT randomly assigned): + lbl_ct = (unsigned int) (lbl_ct + 1); + if (lbl_ct == UINT_MAX) + goto MEM_ERROR; + } + } + + // Return number of connected components labeled: + if (numOfConnectedComponents != NULL) + *numOfConnectedComponents = lbl_ct; + + + // Return the array of volumes for each connected component. + // (The list is deleted after this operation): + if (volumes != NULL) + (*volumes) = uint_list_toarray(&vol_list, lbl_ct); + else + uint_list_clear(&vol_list); + + + if (boundingBoxes != NULL) + (*boundingBoxes) = bb_list_toarray(&bb_list, lbl_ct); + else + bb_list_clear(&bb_list); + + // Crop output: + p3dCrop3D_uint2uint(tmp_out_rev, out_rev, a_dimx, a_dimy, a_dimz, a_rad); + + + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + if (volumes != NULL) + (*volumes) = uint_list_toarray(&vol_list, lbl_ct); + else + uint_list_clear(&vol_list); + + if (boundingBoxes != NULL) + (*boundingBoxes) = bb_list_toarray(&bb_list, lbl_ct); + else + bb_list_clear(&bb_list); + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code: + return P3D_ERROR; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_ushort.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_ushort.c new file mode 100644 index 0000000000000000000000000000000000000000..aa1b5c0ce2ad2424b3e509aa567bc115955b58c3 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_ushort.c @@ -0,0 +1,814 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +/************************************************************************ + * CCL3 Performs connected component labeling of a 3D binary volume. + * CCL3 performs connected component labeling of a 3D binary volume + * using 26-connectivity for object voxels and 6-connectivity for + * background voxels. The algorithm uses a flexible tradeoff between + * speed and memory by means of parameter SIZE. + * + * LB = CCL3(VOI) apply the fastest connected component labeling (i.e. + * SIZE = 3). + * + * LB = CCL3(VOI, SIZE) apply connected component labeling using the + * specified SIZE for the sub-volume scanning (see references). + * + * Class Support + * ------------- + * The input volume VOI must be logical. SIZE must be an odd value greater + * than 3. + * + * Remarks + * ------- + * The SIZE parameters controls the tradeoff between computational time + * and memory occupation. The fastest execution requires SIZE = 3. + * + * Example + * ------------ + * + * lbl = ccl3(voi); + * + * References + * ---------- + * [1] Q. Hu et al. Fast connected-component labeling in + * three-dimensional binary images based on iterative recursion. + * Computer Vision and Image Understanding, 99(2005):414-434, 2005. + + + * Author: Brun Francesco - Universit� degli studi di Trieste + * Date: 10 may 2008 + + ************************************************************************/ +#include <stdlib.h> +#include <limits.h> +#include <omp.h> + +#include "p3dCoordsQueue.h" +#include "p3dUIntList.h" +#include "p3dBoundingBoxList.h" +#include "p3dUtils.h" + + +#define ON_LABEL 1 // ON Value: +#define FIRST_LABEL 3 // First label: +#define TEMP_LABEL 2 // Temporary label: +#define RAND_OFF 4500 + +void putCoordsInQueue_ushort( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + coords_t tmp_coords; // Temporary coords + + + // If we're on an object voxel: + if (out_rev[ I(i, j, k, dimx, dimy) ] == ON_LABEL) { + // Check if this is the last step: + if (ct == (win_size - 2)) { + // Border voxels are set to m: + out_rev[ I(i, j, k, dimx, dimy) ] = m; + + // A border voxel is pushed into queue: + tmp_coords.x = i; + tmp_coords.y = j; + tmp_coords.z = k; + coords_queue_push(queue, tmp_coords); + } else { + // Mark voxel for further scan: + out_rev[ I(i, j, k, dimx, dimy) ] = TEMP_LABEL; + } + } +} + +void conn_fun6_ushort( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + c = k - 1; + b = j; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +void conn_fun18_ushort( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + // Perform 6-connectivity: + conn_fun6_ushort(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 12 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + +} + +void conn_fun26_ushort( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + // Perform 18-connectivity: + conn_fun18_ushort(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 8 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j - 1; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j - 1; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i - 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i + 1; + putCoordsInQueue_ushort(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +int first_unlabeled_ushort( + unsigned short* lbl, + const int nRows, + const int nCols, + const int nPlanes, + const int winsize, + coords_t* coords + ) { + int i, j, k; + int off; + + off = winsize / 2; // integer division: + + // Volume scanning: + for (k = off; k < (nPlanes - off); k++) + for (j = off; j < (nCols - off); j++) + for (i = off; i < (nRows - off); i++) { + if (lbl[ I(i, j, k, nRows, nCols) ] == ON_LABEL) { + coords->x = i; + coords->y = j; + coords->z = k; + return P3D_TRUE; + } + } + + return P3D_FALSE; +} + +/*int _p3dConnectedComponentsLabeling( + unsigned char* in_rev, + unsigned short* out_rev, + int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int skip_borders + ) { + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + int win_size; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + uint_list_t vol_list; // List for region volume counting + bb_list_t bb_list; // List for bounding boxes + bb_t curr_bb; + + unsigned short m; // Current label + int ct, offset; // Counter for local subvolume size + int a, b, c; + int i, j, k; + int m_ct; // Counter for volume counting + int lbl_ct; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + const int a_rad = 1; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev; + unsigned short* tmp_out_rev; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t * queue // FIFO data structure for coords storage + ); + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + win_size = 3; + + // Set the correct type of connectivity based on input parameter: + if (conn == CONN6) + conn_fun = conn_fun6; + else if (conn == CONN18) + conn_fun = conn_fun18; + else // default: + conn_fun = conn_fun26; + + // Apply algorithm: + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Initialize input: + P3D_TRY(tmp_in_rev = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + p3dZeroPadding3D_uchar2uchar(in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad); + + + // Initialize output label volume with ON_LABEL on non-zero values + // of input volume: + P3D_TRY(tmp_out_rev = (unsigned short*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned short))); + +#pragma omp parallel for + for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) + tmp_out_rev[ct] = (tmp_in_rev[ct]) ? ON_LABEL : 0; + + + + // Initialize variables: + coords_queue_init(&queue); + uint_list_init(&vol_list); + bb_list_init(&bb_list); + + + m = FIRST_LABEL; + lbl_ct = 0; + + + // While not all voxels are labeled: + while (first_unlabeled(tmp_out_rev, a_dimx, a_dimy, a_dimz, win_size, &coords) == P3D_TRUE) { + // Re-init counter for current connected component: + m_ct = 0; + + // Init bounding box: + curr_bb.max_x = 0; + curr_bb.max_y = 0; + curr_bb.max_z = 0; + curr_bb.min_x = INT_MAX; + curr_bb.min_y = INT_MAX; + curr_bb.min_z = INT_MAX; + + // Push the first unlabeled object voxel into queue: + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while (coords_queue_isempty(queue) == P3D_FALSE) { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x, coords.y, coords.z, a_dimx, a_dimy) ] = TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) + for (j = (coords.y - offset); j <= (coords.y + offset); j++) + for (i = (coords.x - offset); i <= (coords.x + offset); i++) { + + if (tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] == TEMP_LABEL) { + // Perform 6-, 18-, or 26-connectivity: + conn_fun(tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, m, &queue); + + // A voxels previously marked is set to m: + tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] = m; + + // Define bounding box: + curr_bb.max_x = MAX(curr_bb.max_x, i - a_rad); + curr_bb.max_y = MAX(curr_bb.max_y, j - a_rad); + curr_bb.max_z = MAX(curr_bb.max_z, k - a_rad); + curr_bb.min_x = MIN(curr_bb.min_x, i - a_rad); + curr_bb.min_y = MIN(curr_bb.min_y, j - a_rad); + curr_bb.min_z = MIN(curr_bb.min_z, k - a_rad); + + // Increment counter for region volume: + m_ct++; + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + + + // Skip object if required: + if ((skip_borders == P3D_TRUE) && ((curr_bb.min_x == 0) || (curr_bb.min_y == 0) + || (curr_bb.min_z == 0) || (curr_bb.max_x == (dimx - 1)) + || (curr_bb.max_y == (dimy - 1)) || (curr_bb.max_z == (dimz - 1)))) { + // Restore OBJECT label instead of current label: +#pragma omp parallel for private(a,b) + for (c = curr_bb.min_z; c <= curr_bb.max_z; c++) + for (b = curr_bb.min_y; b <= curr_bb.max_y; b++) + for (a = curr_bb.min_x; a <= curr_bb.max_x; a++) { + if (tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] == m) { + tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] = USHRT_MAX; // Object + } + } + } else { + // Save connected component volume: + uint_list_add(&vol_list, m_ct); + bb_list_add(&bb_list, curr_bb); + + + // Increment counter (it is equal to (m - 3) if labels are NOT randomly assigned): + m++; + lbl_ct++; + } + } + + // Return number of connected components labeled: + if (numOfConnectedComponents != NULL) + *numOfConnectedComponents = lbl_ct; + + + // Return the array of volumes for each connected component. + // (The list is deleted after this operation): + if (volumes != NULL) + (*volumes) = uint_list_toarray(&vol_list, lbl_ct); + else + uint_list_clear(&vol_list); + + if (boundingBoxes != NULL) + (*boundingBoxes) = bb_list_toarray(&bb_list, lbl_ct); + else + bb_list_clear(&bb_list); + + + // Crop output: + p3dCrop3D_ushort2ushort(tmp_out_rev, out_rev, a_dimx, a_dimy, a_dimz, a_rad); + + + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code: + return P3D_MEM_ERROR; +}*/ + +int p3dConnectedComponentsLabeling_ushort( + unsigned char* in_rev, + unsigned short* out_rev, + unsigned int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, + const int skip_borders + ) { + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + int win_size; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + uint_list_t vol_list; // List for region volume counting + bb_list_t bb_list; // List for bounding boxes + bb_t curr_bb; + + unsigned short m; // Current label + int ct, offset; // Counter for local subvolume size + int a, b, c; + int i, j, k; + int m_ct; // Counter for volume counting + int lbl_ct; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + const int a_rad = 1; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev; + unsigned short* tmp_out_rev; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t * queue // FIFO data structure for coords storage + ); + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + win_size = 3; + + // Set the correct type of connectivity based on input parameter: + if (conn == CONN6) + conn_fun = conn_fun6_ushort; + else if (conn == CONN18) + conn_fun = conn_fun18_ushort; + else // default: + conn_fun = conn_fun26_ushort; + + // Apply algorithm: + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Initialize input: + P3D_TRY(tmp_in_rev = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + p3dZeroPadding3D_uchar2uchar(in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad); + + + // Initialize output label volume with ON_LABEL on non-zero values + // of input volume: + P3D_TRY(tmp_out_rev = (unsigned short*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned short))); + +#pragma omp parallel for + for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) + tmp_out_rev[ct] = (tmp_in_rev[ct] == OBJECT) ? ON_LABEL : 0; + + + + + // Initialize variables: + coords_queue_init(&queue); + uint_list_init(&vol_list); + bb_list_init(&bb_list); + + + // Initialize label counter: + if (random_lbl == P3D_TRUE) { + m = (unsigned short) (rand() % (USHRT_MAX - 2 * RAND_OFF) + RAND_OFF); + } else { + m = FIRST_LABEL; + } + lbl_ct = 0; + + // While not all voxels are labeled: + while (first_unlabeled_ushort(tmp_out_rev, a_dimx, a_dimy, a_dimz, win_size, &coords) == P3D_TRUE) { + // Re-init counter for current connected component: + m_ct = 0; + + // Init bounding box: + curr_bb.max_x = 0; + curr_bb.max_y = 0; + curr_bb.max_z = 0; + curr_bb.min_x = INT_MAX; + curr_bb.min_y = INT_MAX; + curr_bb.min_z = INT_MAX; + + // Push the first unlabeled object voxel into queue: + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while (coords_queue_isempty(queue) == P3D_FALSE) { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x, coords.y, coords.z, a_dimx, a_dimy) ] = TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) + for (j = (coords.y - offset); j <= (coords.y + offset); j++) + for (i = (coords.x - offset); i <= (coords.x + offset); i++) { + + if (tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] == TEMP_LABEL) { + // Perform 6-, 18-, or 26-connectivity: + conn_fun(tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, m, &queue); + + // A voxels previously marked is set to m: + tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] = m; + + // Define bounding box: + curr_bb.max_x = MAX(curr_bb.max_x, i - a_rad); + curr_bb.max_y = MAX(curr_bb.max_y, j - a_rad); + curr_bb.max_z = MAX(curr_bb.max_z, k - a_rad); + curr_bb.min_x = MIN(curr_bb.min_x, i - a_rad); + curr_bb.min_y = MIN(curr_bb.min_y, j - a_rad); + curr_bb.min_z = MIN(curr_bb.min_z, k - a_rad); + + // Increment counter for region volume: + m_ct++; + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + + + // Skip object if required: + if ((skip_borders == P3D_TRUE) && ((curr_bb.min_x == 0) || (curr_bb.min_y == 0) + || (curr_bb.min_z == 0) || (curr_bb.max_x == (dimx - 1)) + || (curr_bb.max_y == (dimy - 1)) || (curr_bb.max_z == (dimz - 1)))) { + // Restore OBJECT label instead of current label: +#pragma omp parallel for private(a,b) + for (c = curr_bb.min_z; c <= curr_bb.max_z; c++) + for (b = curr_bb.min_y; b <= curr_bb.max_y; b++) + for (a = curr_bb.min_x; a <= curr_bb.max_x; a++) { + if (tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] == m) { + tmp_out_rev[ I(a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy) ] = USHRT_MAX; // Object + } + } + } else { + // Save connected component volume: + uint_list_add(&vol_list, m_ct); + bb_list_add(&bb_list, curr_bb); + + // Increment label for next connected component: + if (random_lbl == P3D_TRUE) { + m = (unsigned short) (rand() % (USHRT_MAX - 2 * RAND_OFF) + RAND_OFF); + } else { + m++; + } + + // Increment counter (it is equal to (m - 3) if labels are NOT randomly assigned): + lbl_ct++; + if (lbl_ct == USHRT_MAX) + goto MEM_ERROR; + } + } + + // Return number of connected components labeled: + if (numOfConnectedComponents != NULL) + *numOfConnectedComponents = lbl_ct; + + + // Return the array of volumes for each connected component. + // (The list is deleted after this operation): + if (volumes != NULL) + (*volumes) = uint_list_toarray(&vol_list, lbl_ct); + else + uint_list_clear(&vol_list); + + if (boundingBoxes != NULL) + (*boundingBoxes) = bb_list_toarray(&bb_list, lbl_ct); + else + bb_list_clear(&bb_list); + + + // Crop output: + p3dCrop3D_ushort2ushort(tmp_out_rev, out_rev, a_dimx, a_dimy, a_dimz, a_rad); + + + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Return the array of volumes for each connected component. + // (The list is deleted after this operation): + if (volumes != NULL) + (*volumes) = uint_list_toarray(&vol_list, lbl_ct); + else + uint_list_clear(&vol_list); + + if (boundingBoxes != NULL) + (*boundingBoxes) = bb_list_toarray(&bb_list, lbl_ct); + else + bb_list_clear(&bb_list); + + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code: + return P3D_ERROR; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsList.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsList.c new file mode 100644 index 0000000000000000000000000000000000000000..bb5cd39598a9cd7770bbbf2055a17650b77977c5 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsList.c @@ -0,0 +1,123 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dCoordsList.h" +#include "p3dUtils.h" + + +void coords_list_init (coords_list_t *list) +{ + *list = NULL; +} + +int coords_list_push (coords_list_t *list, coords_t item) +{ + coords_list_elem_t* new_l; + + /* Allocate memory for the new item: */ + new_l = (coords_list_elem_t*) malloc (sizeof(coords_list_elem_t)); + if ( new_l == NULL ) return P3D_ERROR; + + /* Push item into list: */ + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_SUCCESS; +} + +coords_t coords_list_pop (coords_list_t *list) +{ + coords_list_elem_t* tmp_l; + coords_t tmp_coords; + + + + /* Perform deletion: */ + tmp_coords = (*list)->elem; + + /* Save temporary pointer to the element to delete: */ + tmp_l = *list; + + /* The list will point on the next element: */ + (*list) = (*list)->next; + + /* Delete first element using the previously set + temporary pointer: */ + free(tmp_l); + + /* Return coordinates: */ + return tmp_coords; +} + + +int coords_list_isempty (coords_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + + +coords_t* coords_list_toarray (coords_list_t *list, int numel ) +{ + coords_list_elem_t* tmp_l; + + + coords_t* v; + int i; + + /* Allocate memory for output array: */ + v = (coords_t*) malloc (numel*sizeof(coords_t)); + + if ( v != NULL ) + { + /* Convert list to array: */ + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->elem; + + /* Perform deletion: */ + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + else + { + /* Delete list in any case: */ + while ( list != NULL ) + coords_list_pop ( list ); + } + + return v; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsList.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsList.h new file mode 100644 index 0000000000000000000000000000000000000000..020f4ba947a5fb9567f202b21b28df8df9b1ec2e --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsList.h @@ -0,0 +1,140 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +/******************************************************************************** + * File: p3dCoords_list.h + * + * Description: Header file for the implementation of the dynamic structure + * with LIFO (Last-In-First-Out) policy (list or stack) + * containing CoordsT elements (see p3dCoordsT.h) + * Duplicate elements allowed. + * + * Interfaces: coords_list_init + * coords_list_push + * coords_list_pop + * coords_list_isempty + * coords_list_toarray + * + * Author: FB + * + * Last Modified: + * + * Copyright (C) 2009 Sincrotrone Trieste S.C.p.A. - All rights reserved. + ********************************************************************************/ +#include "p3dCoordsT.h" + +/* + Type definitions: +*/ + +#ifndef COORDS_LIST_T_DEFINED + #define COORDS_LIST_T_DEFINED + + struct coords_lelem_t { + coords_t elem; + struct coords_lelem_t *next; + }; + + typedef struct coords_lelem_t coords_list_elem_t; + + typedef coords_list_elem_t* coords_list_t; + +#endif + +/* + Interfaces: +*/ + +/******************************************************************************** + * Function: coords_list_init + * + * Description: Initialize the specified parameter to NULL. + * + * Input(s): coords_list_t* - The list to initialize + * + * Output: No return type + ********************************************************************************/ +void coords_list_init ( coords_list_t* ); + +/******************************************************************************** + * Function: coords_list_push + * + * Description: Push the specified element into the list. + * + * Input(s): coords_list_t* - The list to extend + * coords_t - The element to push into the list + * + * Output: P3D_SUCCESS if element successfully pushed into the list + * P3D_MEM_ERROR if there is not enough memory for the additional + * element + ********************************************************************************/ +int coords_list_push ( coords_list_t*, coords_t ); + +/******************************************************************************** + * Function: coords_list_pop + * + * Description: Pop an element from the list according to the LIFO policy. + * + * Input(s): coords_list_t* - The list to reduce + * + * Output: coords_t - The popped element + ********************************************************************************/ +coords_t coords_list_pop ( coords_list_t* ); + +/******************************************************************************** + * Function: coords_list_isempty + * + * Description: Return P3D_TRUE if the specified list is empty + * + * Input(s): coords_list_t* - The list to query + * + * Output: P3D_TRUE if the list is empty + * P3D_FALSE if there is at least one element into the list + ********************************************************************************/ +int coords_list_isempty ( coords_list_t ); + +/******************************************************************************** + * Function: coords_list_toarray + * + * Description: Convert the dynamic structure to a static array. The length + * of the array should be known a-priori and specified in input. + * List is deleted after this operation. Run-time error occurs if + * the caller specify a number of elements greater than the real + * value. Memory leak occurs if the caller specify a number of + * elements lower than the real value. + * + * Input(s): coords_list_t* - The list to convert + * int - The number of list elements + * + * Output: The pointer to the array or NULL if there is not enough + * (contiguous) memory for the array (list is deleted in any + * case). + ********************************************************************************/ +coords_t* coords_list_toarray ( coords_list_t*, int ); + + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsQueue.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsQueue.c new file mode 100644 index 0000000000000000000000000000000000000000..3e2110757939ee23ce3e3daa59934b6a8e595ce9 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsQueue.c @@ -0,0 +1,89 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> + +#include "p3dCoordsQueue.h" +#include "p3dUtils.h" + +void coords_queue_init (coords_queue_t *queue) +{ + queue->head = NULL; + queue->tail = NULL; +} + +void coords_queue_push (coords_queue_t *queue, coords_t elem) +{ + coords_queue_elem_t *new_q; + + // Alloc memory for the new item: + new_q = (coords_queue_elem_t *) malloc (sizeof(coords_queue_elem_t)); + + // Push item into queue: + new_q->item = elem; + new_q->next = NULL; + + // Handle first element pushed: + if (queue->tail != NULL) + { + queue->tail->next = new_q; + queue->tail = queue->tail->next; + } + else + { + queue->tail = new_q; + queue->head = queue->tail; + } +} + +coords_t coords_queue_pop (coords_queue_t *queue) +{ + coords_t elem; + coords_queue_elem_t *temp; + + // Pop item from queue: + elem = queue->head->item; + + // Free memory: + temp = queue->head; + queue->head = queue->head->next; + free(temp); + + // Handle last element popped: + if (queue->head == NULL) + { + queue->tail = NULL; + } + + // Return the item previously popped: + return elem; +} + +int coords_queue_isempty (coords_queue_t queue) +{ + return ( ((queue.head == NULL) && (queue.tail == NULL)) ? P3D_TRUE : P3D_FALSE ); +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsQueue.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsQueue.h new file mode 100644 index 0000000000000000000000000000000000000000..b9ef828c205ff86ef5662b41bbaee1b2c712d7f6 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsQueue.h @@ -0,0 +1,67 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +#include "p3dCoordsT.h" + +/********************************************************************* + * + * coords_queue_t type definitions. Do NOT modify. coords_queue_t implements a FIFO + * policy: elements are pushed into the tail and popped from the head. + * + *********************************************************************/ + +#ifndef COORDS_Q_DEFINED + #define COORDS_Q_DEFINED + + struct coords_qelem_t { + coords_t item; + struct coords_qelem_t *next; + }; + + typedef struct coords_qelem_t coords_queue_elem_t; + + typedef struct { + coords_queue_elem_t *tail; + coords_queue_elem_t *head; + } coords_queue_t; + +#endif +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void coords_queue_init (coords_queue_t *queue); + +void coords_queue_push(coords_queue_t *queue, coords_t elem); + +coords_t coords_queue_pop(coords_queue_t *queue); + +int coords_queue_isempty(coords_queue_t queue); + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsT.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsT.h new file mode 100644 index 0000000000000000000000000000000000000000..822742e0b3907a62ff13e95451fe9a200c7bda52 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dCoordsT.h @@ -0,0 +1,49 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +/* + Type definitions: +*/ + +#ifndef COORDS_T_DEFINED + +typedef struct { + int x; + int y; + int z; +} coords_t; + +typedef struct { + double x; + double y; + double z; +} fcoords_t; + +#endif + +#define COORDS_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dDoubleList.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dDoubleList.c new file mode 100644 index 0000000000000000000000000000000000000000..a1045a7c83cc33741565340774363d9fcbbd2f5d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dDoubleList.c @@ -0,0 +1,84 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dDoubleList.h" +#include "p3dUtils.h" + +void double_list_init (double_list_t *list) +{ + *list = NULL; +} + +void double_list_add (double_list_t *list, double elem) +{ + double_list_elem_t* new_l; + + // Alloc memory for the new item: + new_l = (double_list_elem_t*) malloc (sizeof(double_list_elem_t)); + + // Push item into queue: + new_l->ct = elem; + new_l->next = *list; + + *list = new_l; +} + + +int double_list_isempty (double_list_t list) +{ + return ( ( list == NULL )? P3D_TRUE : P3D_FALSE ); +} + +// List is deleted after conversion: +double* double_list_toarray (double_list_t *list, int numel ) +{ + double_list_elem_t* tmp_l; + + + double* v; + int i; + + v = (double*) malloc (numel*sizeof(double)); + + // Convert list to array: + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->ct; + + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + return v; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dDoubleList.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dDoubleList.h new file mode 100644 index 0000000000000000000000000000000000000000..873626397fe2585b7d5d48ab134e10e4e89157e1 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dDoubleList.h @@ -0,0 +1,57 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/********************************************************************* + * + * double_list_t type definitions. + * + *********************************************************************/ + +struct double_lelem_t { + double ct; + struct double_lelem_t *next; +}; + +typedef struct double_lelem_t double_list_elem_t; + +typedef double_list_elem_t* double_list_t; + + +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void double_list_init (double_list_t *list); + +void double_list_add(double_list_t *list, double item); + +int double_list_isempty(double_list_t list); + +double* double_list_toarray (double_list_t *list, int numel ); + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dFCoordsList.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dFCoordsList.c new file mode 100644 index 0000000000000000000000000000000000000000..768cdecd7f15133acbde9912ec1da0940def2a01 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dFCoordsList.c @@ -0,0 +1,121 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dFCoordsList.h" +#include "p3dUtils.h" + +void fcoords_list_init (fcoords_list_t *list) +{ + *list = NULL; +} + +int fcoords_list_push (fcoords_list_t *list, fcoords_t item) +{ + fcoords_list_elem_t* new_l; + + /* Allocate memory for the new item: */ + new_l = (fcoords_list_elem_t*) malloc (sizeof(fcoords_list_elem_t)); + if ( new_l == NULL ) return P3D_ERROR; + + /* Push item into list: */ + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_SUCCESS; +} + +fcoords_t fcoords_list_pop (fcoords_list_t *list) +{ + fcoords_list_elem_t* tmp_l; + fcoords_t tmp_coords; + + + + /* Perform deletion: */ + tmp_coords = (*list)->elem; + + /* Save temporary pointer to the element to delete: */ + tmp_l = *list; + + /* The list will point on the next element: */ + (*list) = (*list)->next; + + /* Delete first element using the previously set + temporary pointer: */ + free(tmp_l); + + /* Return coordinates: */ + return tmp_coords; +} + + +int fcoords_list_isempty (fcoords_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + + +fcoords_t* fcoords_list_toarray (fcoords_list_t *list, int numel ) +{ + fcoords_list_elem_t* tmp_l; + + + fcoords_t* v; + int i; + + /* Allocate memory for output array: */ + v = (fcoords_t*) malloc (numel*sizeof(fcoords_t)); + + if ( v != NULL ) + { + /* Convert list to array: */ + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->elem; + + /* Perform deletion: */ + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + else + { + /* Delete list in any case: */ + while ( list != NULL ) + fcoords_list_pop ( list ); + } + + return v; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dFCoordsList.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dFCoordsList.h new file mode 100644 index 0000000000000000000000000000000000000000..bba97e02b6c4a58c64ffd51380af5bbe1d345013 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dFCoordsList.h @@ -0,0 +1,139 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/******************************************************************************** + * File: p3dCoords_list.h + * + * Description: Header file for the implementation of the dynamic structure + * with LIFO (Last-In-First-Out) policy (list or stack) + * containing CoordsT elements (see p3dCoordsT.h) + * Duplicate elements allowed. + * + * Interfaces: coords_list_init + * coords_list_push + * coords_list_pop + * coords_list_isempty + * coords_list_toarray + * + * Author: FB + * + * Last Modified: + * + * Copyright (C) 2009 Sincrotrone Trieste S.C.p.A. - All rights reserved. + ********************************************************************************/ +#include "p3dCoordsT.h" + +/* + Type definitions: +*/ + +#ifndef FCOORDS_LIST_T_DEFINED + #define FCOORDS_LIST_T_DEFINED + + struct fcoords_lelem_t { + fcoords_t elem; + struct fcoords_lelem_t *next; + }; + + typedef struct fcoords_lelem_t fcoords_list_elem_t; + + typedef fcoords_list_elem_t* fcoords_list_t; + +#endif + +/* + Interfaces: +*/ + +/******************************************************************************** + * Function: fcoords_list_init + * + * Description: Initialize the specified parameter to NULL. + * + * Input(s): fcoords_list_t* - The list to initialize + * + * Output: No return type + ********************************************************************************/ +void fcoords_list_init ( fcoords_list_t* ); + +/******************************************************************************** + * Function: fcoords_list_push + * + * Description: Push the specified element into the list. + * + * Input(s): fcoords_list_t* - The list to extend + * fcoords_t - The element to push into the list + * + * Output: P3D_SUCCESS if element successfully pushed into the list + * P3D_MEM_ERROR if there is not enough memory for the additional + * element + ********************************************************************************/ +int fcoords_list_push ( fcoords_list_t*, fcoords_t ); + +/******************************************************************************** + * Function: fcoords_list_pop + * + * Description: Pop an element from the list according to the LIFO policy. + * + * Input(s): fcoords_list_t* - The list to reduce + * + * Output: fcoords_t - The popped element + ********************************************************************************/ +fcoords_t fcoords_list_pop ( fcoords_list_t* ); + +/******************************************************************************** + * Function: coords_list_isempty + * + * Description: Return P3D_TRUE if the specified list is empty + * + * Input(s): coords_list_t* - The list to query + * + * Output: P3D_TRUE if the list is empty + * P3D_FALSE if there is at least one element into the list + ********************************************************************************/ +int fcoords_list_isempty ( fcoords_list_t ); + +/******************************************************************************** + * Function: fcoords_list_toarray + * + * Description: Convert the dynamic structure to a static array. The length + * of the array should be known a-priori and specified in input. + * List is deleted after this operation. Run-time error occurs if + * the caller specify a number of elements greater than the real + * value. Memory leak occurs if the caller specify a number of + * elements lower than the real value. + * + * Input(s): fcoords_list_t* - The list to convert + * int - The number of list elements + * + * Output: The pointer to the array or NULL if there is not enough + * (contiguous) memory for the array (list is deleted in any + * case). + ********************************************************************************/ +fcoords_t* fcoords_list_toarray ( fcoords_list_t*, int ); + + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dSquaredEuclideanDT.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dSquaredEuclideanDT.c new file mode 100644 index 0000000000000000000000000000000000000000..9eccec8749e1d153a4fb55fb60551e7c54727cf2 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dSquaredEuclideanDT.c @@ -0,0 +1,420 @@ +/* +* p3dSquaredEuclideanDistanceTransform +* +* Computes the squared Euclidean distance transform of the input volume. For +* each non-zero voxel in input image, the distance transform assigns a number +* that is the squared distance between that voxel and the nearest zero pixel +* (background). The squared Euclidean distance transform is a non-approximated +* Euclidean distance metric. +* +* Remarks +* ------- +* Computational cost is O(N^3) for a NxNxN input volume. Memory +* requirement is two internal volumes of a NxNxN and two linear arrays of N +* elements, i.e. O(N^3) of type int. Current implementation uses int elements, +* therefore (for most compilers) memory requirement is 8 x O(N^3) the size of +* input volume. +* +* References +* ---------- +* [1] T. Hirata. "A unified linear-time algorithm for computing distance +* maps", Information Processing Letters, 58(3):129-133, May 1996. +* +* [2] A. Meijster, J.B.T.M. Roerdink and W. H. Hesselink. "A general +* algorithm for computing distance transforms in linear time", +* Mathematical Morphology and its Applications to Image and Signal +* Processing, pp. 331-340. Kluwer, 2000. +* + +* +* Copyright 2008, SYRMEP Group - Sincrotrone Trieste S.C.p.A. +* +* Author: Brun Francesco +* Version: 1.0 +* Date: 19 june 2008 +* +*/ +#include <stdlib.h> +#include <limits.h> +#include <omp.h> + +#include "p3dSquaredEuclideanDT.h" +#include "p3dUtils.h" + +// Set a signed integer type able to get over 65.535 and the +// maximum value representable (INF) with this specified type +// (see <limits.h>). These settings depends on the specific +// compilator used. +//typedef int int; +#define INF INT_MAX + +/* ------------------- + * Mathematical operators with INF management. + * ------------------- */ + +/** + ************************************************** + * @b sum + * @param a int number with INF + * @param b int number with INF + * @return The sum of a and b handling INF + **************************************************/ +int sum( int a, int b ) +{ + if ((a == INF) || (b == INF)) + return INF; + else + return a + b; +} + +/** + ************************************************** + * @b prod + * @param a long number with INF + * @param b long number with INF + * @return The product of a and b handling INF + **************************************************/ +int prod( int a, int b ) +{ + if ((a == INF) || (b == INF)) + return INF; + else + return a * b; +} +/** + ************************************************** + * @b opp + * @param a long number with INF + * @return The opposite of a handling INF + **************************************************/ +int opp( int a ) +{ + if (a == INF) + return INF; + else + return -a; +} + +/** + ************************************************** + * @b intdivint + * @param divid long number with INF + * @param divis long number with INF + * @return The division (integer) of divid out of divis handling INF + **************************************************/ +int intdivint( int divid, int divis ) +{ + if (divis == 0) + return INF; + if (divid == INF) + return INF; + else + return divid / divis; +} + +/* ------------------- + * Mathematical operators for the parabola definition. + * ------------------- */ + +/** + ************************************************** + * @b f + * @param x + * @param i + * @param gi2 + * @return Definition of a parabola + **************************************************/ +int f( int x, int i, int gi2 ) +{ + return sum((x-i)*(x-i), gi2); +} + +/** + ************************************************** + * @b sep + * @param i + * @param u + * @param gi2 + * @param gu2 + * @return The abscissa of the intersection point between two parabolas + **************************************************/ +int sep( int i, int u, int gi2, int gu2 ) +{ + return intdivint(sum( sum((long) (u*u - i*i),gu2), opp(gi2) ), 2*(u-i)); +} + + + +/* ------------------- + * Steps of distance transform algorithm. + * ------------------- */ + + +/** + ************************************************** + * @b stepX + * @param voi input volume + * @param sdt_x DT along the x-direction + **************************************************/ +int stepX ( const unsigned char* voi, + int* sdt_x, + const int NRows, + const int NCols, + const int NPlanes + ) +{ + int x,y,z; + + for (z = 0; z < NPlanes; z++) + for (y = 0; y < NCols ; y++) + { + if (voi[ I(0,y,z,NRows,NCols) ] == 0) + sdt_x[ I(0,y,z,NRows,NCols) ] = 0; + else + sdt_x[ I(0,y,z,NRows,NCols) ] = INF; + + // Forward scan + for (x = 1; x < NRows; x++) + if (voi[ I(x,y,z,NRows,NCols) ] == 0) + sdt_x[ I(x,y,z,NRows,NCols) ] = 0; + else + sdt_x[ I(x,y,z,NRows,NCols) ] = sum(1, sdt_x[ I(x-1,y,z,NRows,NCols)] ); + + //Backward scan + for (x = NRows-2; x >= 0; x--) + if (sdt_x[ I(x+1,y,z,NRows,NCols) ] < sdt_x[ I(x,y,z,NRows,NCols) ]) + sdt_x[ I(x,y,z,NRows,NCols) ] = sum(1, sdt_x[ I(x+1,y,z,NRows,NCols) ]); + } + + // Return success code: + return P3D_SUCCESS; +} + +/** + ************************************************** + * @b stepY + * @param sdt_x the DT along the x-direction + * @param sdt_xy the DT in the xy-slices + **************************************************/ +int stepY ( const int* sdt_x, + int* sdt_xy, + const int NRows, + const int NCols, + const int NPlanes + ) +{ + + int* s; // Center of the upper envelope parabolas + int* t; // Separating index between 2 upper envelope + // parabolas + int q; + int w; + + int x,z,u; + + + P3D_TRY ( s = (int*) calloc(NCols, sizeof(int)) ); + P3D_TRY ( t = (int*) calloc(NCols, sizeof(int)) ); + + + for (z = 0; z < NPlanes; z++) + for (x = 0; x < NRows; x++) + { + q = 0; + s[0] = 0; + t[0] = 0; + + //Forward scanning: + for (u=1; u < NCols ; u++) + { + while ((q >= 0) && + ( f(t[q],s[q],prod(sdt_x[ I(x,s[q],z,NRows,NCols) ],sdt_x[ I(x,s[q],z,NRows,NCols) ])) > + f(t[q],u,prod(sdt_x[ I(x,u,z,NRows,NCols) ],sdt_x[ I(x,u,z,NRows,NCols) ]))) ) + q--; + + if (q<0) + { + q=0; + s[0]=u; + } + else + { + w = 1 + sep(s[q],u, + prod(sdt_x[ I(x,s[q],z,NRows,NCols) ],sdt_x[ I(x,s[q],z,NRows,NCols) ]), + prod(sdt_x[ I(x,u,z,NRows,NCols) ],sdt_x[ I(x,u,z,NRows,NCols) ])); + + if (w < NCols) + { + q++; + s[q]=u; + t[q]=w; + } + } + } + + //Backward scanning: + for (u = NCols-1; u >= 0; --u) + { + sdt_xy[ I(x,u,z,NRows,NCols) ] = f(u,s[q],prod(sdt_x[ I(x,s[q],z,NRows,NCols) ],sdt_x[ I(x,s[q],z,NRows,NCols) ])); + if (u==t[q]) + q--; + } + } + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return error code: + return P3D_MEM_ERROR; +} + +/** + ************************************************** + * @b stepZ + * @param sdt_xy the DT in the xy-slices + * @param sdt_xyz the final DT + **************************************************/ +int stepZ ( const int* sdt_xy, + int* sdt_xyz, + const int NRows, + const int NCols, + const int NPlanes + ) +{ + + int* s; // Center of the upper envelope parabolas + int* t; // Separating index between 2 upper envelope + // parabolas + int q; + int w; + + int x,y,u; + + + P3D_TRY ( s = (int*) calloc(NPlanes, sizeof(int)) ); + P3D_TRY ( t = (int*) calloc(NPlanes, sizeof(int)) ); + + + for (y = 0; y < NCols; y++) + for (x = 0; x < NRows; x++) + { + q = 0; + s[0] = 0; + t[0] = 0; + + //Forward scanning: + for ( u = 1; u < NPlanes ; u++ ) + { + while ((q >= 0) && + (f(t[q],s[q], sdt_xy[ I(x,y,s[q],NRows,NCols) ]) > + f(t[q],u,sdt_xy[ I(x,y,u,NRows,NCols) ])) ) + q--; + + if (q < 0) + { + q = 0; + s[0] = u; + } + else + { + w = 1 + sep(s[q], u, + sdt_xy[ I(x,y,s[q],NRows,NCols) ], + sdt_xy[ I(x,y,u,NRows,NCols) ]); + + if (w < NPlanes) + { + q++; + s[q]=u; + t[q]=w; + } + } + } + + //Backward scanning: + for (u = NPlanes-1; u >= 0; --u) + { + sdt_xyz[ I(x,y,u,NRows,NCols) ] = f(u,s[q],sdt_xy[ I(x,y,s[q],NRows,NCols) ]); + if ( u == t[q] ) + q--; + } + } + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return error code: + return P3D_MEM_ERROR; +} + + +/************************************************************************ + * DT3 - Entry point: + * + * + ************************************************************************/ +int p3dSquaredEuclideanDT( + unsigned char* in_rev, + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz + ) +{ + // Temporary values and volume: + int* tmp_rev; + int* tmp_out_rev; + + // Counter: + int i; + + // Allocate temporary output: + P3D_TRY ( tmp_out_rev = (int*) malloc(dimx*dimy*dimz*sizeof(int)) ); + P3D_TRY ( tmp_rev = (int*) malloc( dimx*dimy*dimz*sizeof(int) ) ); + + // Compute transform: + P3D_TRY ( stepX ( in_rev, tmp_out_rev, dimx, dimy, dimz ) ); + P3D_TRY ( stepY ( tmp_out_rev, tmp_rev, dimx, dimy, dimz ) ); + P3D_TRY ( stepZ ( tmp_rev, tmp_out_rev, dimx, dimy, dimz ) ); + + // Cast output from int to unsigned short: + for ( i = 0; i < (dimx*dimy*dimz); i++) + out_rev[i] = (tmp_out_rev[i] > USHRT_MAX) ? USHRT_MAX : (unsigned short) ( tmp_out_rev[i] ); + + + // Free allocated memory: + if ( tmp_rev != NULL ) free(tmp_rev); + if ( tmp_out_rev != NULL ) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free allocated memory: + if ( tmp_rev != NULL ) free(tmp_rev); + if ( tmp_out_rev != NULL ) free(tmp_out_rev); + + // Return error: + return P3D_MEM_ERROR; +} + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dSquaredEuclideanDT.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dSquaredEuclideanDT.h new file mode 100644 index 0000000000000000000000000000000000000000..4b7f04f1f3d29447d771c9bab4d3ad4772f5cb0e --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dSquaredEuclideanDT.h @@ -0,0 +1,50 @@ +/* +* p3dSquaredEuclideanDistanceTransform +* +* Computes the squared Euclidean distance transform of the input volume. For +* each non-zero voxel in input image, the distance transform assigns a number +* that is the squared distance between that voxel and the nearest zero pixel +* (background). The squared Euclidean distance transform is a non-approximated +* Euclidean distance metric. +* +* Remarks +* ------- +* Computational cost is O(N^3) for a NxNxN input volume. Memory +* requirement is three extra volumes of a NxNxN and two linear arrays of N +* elements, i.e. O(N^3). Current implementation uses unsigned short elements +* (see compiler specifications). +* +* References +* ---------- +* [1] T. Hirata. "A unified linear-time algorithm for computing distance +* maps", Information Processing Letters, 58(3):129-133, May 1996. +* +* [2] A. Meijster, J.B.T.M. Roerdink and W. H. Hesselink. "A general +* algorithm for computing distance transforms in linear time", +* Mathematical Morphology and its Applications to Image and Signal +* Processing, pp. 331-340. Kluwer, 2000. +* + +* +* Copyright 2008, SYRMEP Group - Sincrotrone Trieste S.C.p.A. +* +* Author: Brun Francesco +* Version: 1.0 +* Date: 19 june 2008 +* +*/ + + + +/************************************************************************ + * DT3 - Entry point: + * + * + ************************************************************************/ +int p3dSquaredEuclideanDT( + unsigned char* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz + ); diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dUIntList.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dUIntList.c new file mode 100644 index 0000000000000000000000000000000000000000..bfba54bab960ff27e55ffd64b67b3dbcb242bb76 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dUIntList.c @@ -0,0 +1,117 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dUIntList.h" +#include "p3dUtils.h" + +void uint_list_init (uint_list_t *list) +{ + *list = NULL; +} + +void uint_list_add (uint_list_t *list, unsigned int elem) +{ + uint_list_elem_t* new_l; + + // Alloc memory for the new item: + new_l = (uint_list_elem_t*) malloc (sizeof(uint_list_elem_t)); + + // Push item into queue: + new_l->ct = elem; + new_l->next = *list; + + *list = new_l; +} + + +int uint_list_isempty (uint_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + +// List is deleted after conversion: +unsigned int* uint_list_toarray (uint_list_t *list, unsigned int numel ) +{ + uint_list_elem_t* tmp_l; + + unsigned int* v; + unsigned int i; + + v = (unsigned int*) calloc ( numel, sizeof(unsigned int)); + + // Convert list to array: + for (i = (unsigned int) (numel - 1); i > 0; i = (unsigned int) (i-1) ) + { + if (list != NULL) + { + v[i] = (*list)->ct; + + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + + // Last element: + if (list != NULL) + { + v[0] = (*list)->ct; + + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + return v; +} + +void uint_list_clear (uint_list_t *list) +{ + uint_list_elem_t* tmp_l; + + // Scan whole list: + while( *list != NULL ) + { + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + // Final assignment for safety: + *list = NULL; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dUIntList.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dUIntList.h new file mode 100644 index 0000000000000000000000000000000000000000..07c5f083738a55671143a66247527bced835d0e5 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dUIntList.h @@ -0,0 +1,60 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +/********************************************************************* + * + * uint_list_t type definitions. + * + *********************************************************************/ + +struct uint_lelem_t { + unsigned int ct; + struct uint_lelem_t *next; +}; + +typedef struct uint_lelem_t uint_list_elem_t; + +typedef uint_list_elem_t* uint_list_t; + + +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void uint_list_init (uint_list_t *list); + +void uint_list_add(uint_list_t *list, unsigned int ct); + +int uint_list_isempty(uint_list_t list); + +unsigned int* uint_list_toarray (uint_list_t *list, unsigned int numel ); + +void uint_list_clear (uint_list_t *list); + diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dUtils.c b/pypore3d/pypore3d/P3D_Blob/Common/p3dUtils.c new file mode 100644 index 0000000000000000000000000000000000000000..7617b6904b24fc3c671a0383bf43fd096ee17212 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dUtils.c @@ -0,0 +1,1419 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +#include <string.h> +#include <omp.h> + +#include "p3dUtils.h" + + + +int findNeighbor ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + coords_t* coords + ) +{ + int a,b,c; + int ct = 0; + + // 6-connection: + c = k - 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + + // On k plane: + c = k; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + // Return number of voxels in the neighborhood: + return ct; +} + +// Return the number of voxels in the neighborhood: +int countNeighbors ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c; + int ct = 0; + + // 6-connection: + c = k - 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + + // On k plane: + c = k; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + // Return number of voxels in the neighborhood: + return ct; +} + +/** + * Octree_labeling [Lee94] + * This is a recursive method that calulates the number of connected + * components in the 3D neighbourhood after the center pixel would + * have been removed. + */ +void Octree_labeling(int octant, int label, int *cube) +{ + // check if there are points in the octant with value 1 + if( octant==1 ) + { + // set points in this octant to current label + // and recurseive labeling of adjacent octants + if( cube[0] == 1 ) + cube[0] = label; + if( cube[1] == 1 ) + { + cube[1] = label; + Octree_labeling( 2, label, cube); + } + if( cube[3] == 1 ) + { + cube[3] = label; + Octree_labeling( 3, label, cube); + } + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + } + if( cube[9] == 1 ) + { + cube[9] = label; + Octree_labeling( 5, label, cube); + } + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 7, label, cube); + } + } + if( octant==2 ) + { + if( cube[1] == 1 ) + { + cube[1] = label; + Octree_labeling( 1, label, cube); + } + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + } + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[2] == 1 ) + cube[2] = label; + if( cube[5] == 1 ) + { + cube[5] = label; + Octree_labeling( 4, label, cube); + } + if( cube[11] == 1 ) + { + cube[11] = label; + Octree_labeling( 6, label, cube); + } + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 4, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 8, label, cube); + } + } + if( octant==3 ) + { + if( cube[3] == 1 ) + { + cube[3] = label; + Octree_labeling( 1, label, cube); + } + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 4, label, cube); + } + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[6] == 1 ) + cube[6] = label; + if( cube[7] == 1 ) + { + cube[7] = label; + Octree_labeling( 4, label, cube); + } + if( cube[14] == 1 ) + { + cube[14] = label; + Octree_labeling( 7, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 4, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + } + if( octant==4 ) + { + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 3, label, cube); + } + if( cube[5] == 1 ) + { + cube[5] = label; + Octree_labeling( 2, label, cube); + } + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[7] == 1 ) + { + cube[7] = label; + Octree_labeling( 3, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[8] == 1 ) + cube[8] = label; + if( cube[16] == 1 ) + { + cube[16] = label; + Octree_labeling( 8, label, cube); + } + } + if( octant==5 ) + { + if( cube[9] == 1 ) + { + cube[9] = label; + Octree_labeling( 1, label, cube); + } + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[17] == 1 ) + cube[17] = label; + if( cube[18] == 1 ) + { + cube[18] = label; + Octree_labeling( 6, label, cube); + } + if( cube[20] == 1 ) + { + cube[20] = label; + Octree_labeling( 7, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 6, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + } + if( octant==6 ) + { + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 5, label, cube); + } + if( cube[11] == 1 ) + { + cube[11] = label; + Octree_labeling( 2, label, cube); + } + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[18] == 1 ) + { + cube[18] = label; + Octree_labeling( 5, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 5, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[19] == 1 ) + cube[19] = label; + if( cube[22] == 1 ) + { + cube[22] = label; + Octree_labeling( 8, label, cube); + } + } + if( octant==7 ) + { + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 5, label, cube); + } + if( cube[14] == 1 ) + { + cube[14] = label; + Octree_labeling( 3, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[20] == 1 ) + { + cube[20] = label; + Octree_labeling( 5, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[23] == 1 ) + cube[23] = label; + if( cube[24] == 1 ) + { + cube[24] = label; + Octree_labeling( 8, label, cube); + } + } + if( octant==8 ) + { + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[16] == 1 ) + { + cube[16] = label; + Octree_labeling( 4, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[22] == 1 ) + { + cube[22] = label; + Octree_labeling( 6, label, cube); + } + if( cube[24] == 1 ) + { + cube[24] = label; + Octree_labeling( 7, label, cube); + } + if( cube[25] == 1 ) + cube[25] = label; + } +} + + + + +int isSimplePoint( + unsigned char* in_rev, // IN: Input (binary) original volume + const int dimx, + const int dimy, + const int dimz, + const int x, + const int y, + const int z + ) +{ + // copy neighbors for labeling + int cube[26]; + int i = 0; + int label = 2; // set initial label + + int a,b,c; + + /*for( i = 0; i < 13; i++ ) // i = 0..12 -> cube[0..12] + cube[i] = neighbors[i];*/ + + // From 0 to 8: + c = z - 1; + for ( b = (y - 1); b <= (y + 1); b++ ) + for ( a = (x - 1); a <= (x + 1); a++ ) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + // From 9 to 11: + c = z; + b = y - 1; + for (a = (x - 1); a <= (x + 1); a++) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + // The 12th: + c = z; + b = y; + a = x - 1; + + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + + // i != 13 : ignore center pixel when counting (see [Lee94]) + /*for( i = 14; i < 27; i++ ) // i = 14..26 -> cube[13..25] + cube[i-1] = neighbors[i];*/ + + // The 14th: + c = z; + b = y; + a = x + 1; + + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + + // From 15 to 18: + c = z; + b = y + 1; + for (a = (x - 1); a <= (x + 1); a++) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + // From 19 to 27: + c = z + 1; + for ( b = (y - 1); b <= (y + 1); b++ ) + for ( a = (x - 1); a <= (x + 1); a++ ) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + + + // for all points in the neighborhood + for( i = 0; i < 26; i++ ) + { + if( cube[i]==1 ) // voxel has not been labelled yet + { + // start recursion with any octant that contains the point i + switch( i ) + { + case 0: + case 1: + case 3: + case 4: + case 9: + case 10: + case 12: + Octree_labeling(1, label, cube ); + break; + case 2: + case 5: + case 11: + case 13: + Octree_labeling(2, label, cube ); + break; + case 6: + case 7: + case 14: + case 15: + Octree_labeling(3, label, cube ); + break; + case 8: + case 16: + Octree_labeling(4, label, cube ); + break; + case 17: + case 18: + case 20: + case 21: + Octree_labeling(5, label, cube ); + break; + case 19: + case 22: + Octree_labeling(6, label, cube ); + break; + case 23: + case 24: + Octree_labeling(7, label, cube ); + break; + case 25: + Octree_labeling(8, label, cube ); + break; + } + label++; + if( label-2 >= 2 ) + { + return P3D_FALSE; + } + } + } + //return label-2; in [Lee94] if the number of connected components would be needed + return P3D_TRUE; +} + + +int p3dCrop3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCrop3D_ushort2ushort ( + unsigned short* in_rev, + unsigned short* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCrop3D_uint2uint ( + unsigned int* in_rev, + unsigned int* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCrop3D_float2float ( + float* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; + +} + +int p3dZeroPadding3D_uchar2float ( + unsigned char* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + // Set to zero all values: + memset( out_rev, 0, a_dimx*a_dimy*a_dimz*sizeof(float) ); + + + // Copy original (internal) values: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) + out_rev[ I( i + size, j + size, k + size, a_dimx, a_dimy ) ] = + (float) (in_rev[ I( i, j, k, dimx, dimy ) ]); + + // Return OK: + return P3D_SUCCESS; +} + + +int p3dZeroPadding3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + // Set to zero all values: + memset( out_rev, 0, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + + + // Copy original (internal) values: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) + out_rev[ I( i + size, j + size, k + size, a_dimx, a_dimy ) ] = + in_rev[ I( i, j, k, dimx, dimy ) ]; + + // Return OK: + return P3D_SUCCESS; +} + + +int p3dReplicatePadding3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k,ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + + // Perform first zero padding: + p3dZeroPadding3D_uchar2uchar (in_rev, out_rev, dimx, dimy, dimz, size); + + + // Replicate border values: + for (ct = size; ct > 0; ct--) + { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) + for (j = ct; j < (a_dimy - ct); j++) + { + out_rev[ I( i, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, j, ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( i, j, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) + for (k = ct; k < (a_dimz - ct); k++) + { + out_rev[ I( ct - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I( ct, j, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, j, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, j, k, a_dimx, a_dimy ) ]; + } + + for (i = ct; i < (a_dimx - ct); i++) + for (k = ct; k < (a_dimz - ct); k++) + { + out_rev[ I( i, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( i, ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - ct, k, a_dimx, a_dimy ) ]; + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) + { + out_rev[ I( i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, ct, ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( i, ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, a_dimy - 1 - ct, ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) + { + out_rev[ I( ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( ct, j, ct, a_dimx, a_dimy ) ]; + out_rev[ I( ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( ct, j, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( a_dimx - 1 - ct, j, ct, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) + { + out_rev[ I( ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( ct, ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + out_rev[ I( ct, a_dimy - 1 - ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy ) ]; + } + + // Corners: + + out_rev[ I( ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( ct, ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + + out_rev[ I( a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + + } + + // Return OK: + return P3D_SUCCESS; +} + +double interpolation ( + float* gvf, + int dimx, + int dimy, + int dimz, + const double x, + const double y, + const double z + ) +{ + double alpha, beta, gamma; + + alpha = x - (int) (x); + beta = y - (int) (y); + gamma = z - (int) (z); + + + return (gvf [ I( (int) (x), (int) (y), (int) (z), dimx, dimy) ]*(1-alpha)*(1-beta)*(1-gamma) + + gvf [ I( (int) (x), (int) (y), (int) (z+1), dimx, dimy) ]*(1-alpha)*(1-beta)*gamma + + gvf [ I( (int) (x), (int) (y+1), (int) (z), dimx, dimy) ]*(1-alpha)*beta*(1-gamma) + + gvf [ I( (int) (x+1), (int) (y), (int) (z), dimx, dimy) ]*alpha*(1-beta)*(1-gamma) + + gvf [ I( (int) (x+1), (int) (y), (int) (z+1), dimx, dimy) ]*alpha*(1-beta)*gamma + + gvf [ I( (int) (x+1), (int) (y+1), (int) (z), dimx, dimy) ]*alpha*beta*(1-gamma) + + gvf [ I( (int) (x), (int) (y+1), (int) (z+1), dimx, dimy) ]*(1-alpha)*beta*gamma + + gvf [ I( (int) (x+1), (int) (y+1), (int) (z+1), dimx, dimy) ]*(alpha*beta*gamma)); +} + + + + + + + + + + +int isBoundary ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c; + + c = k - 1; b = j; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k + 1; b = j; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j - 1; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j + 1; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j; a = i - 1; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j; a = i + 1; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + return P3D_FALSE; +} + +int isFullNeighborhood ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c; + + // Neighbors touched by interpolation: + c = k + 1; b = j; a = i; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k; b = j + 1; a = i; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k; b = j; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k + 1; b = j + 1; a = i; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k; b = j + 1; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k + 1; b = j; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k + 1; b = j + 1; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + + // No BACKGROUND voxel found: + return P3D_TRUE; +} + + +int p3dSpecialPadding3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + + // Set to zero all values: + memset( out_rev, 0, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + + + // Copy original (internal) values converting 255 to 1: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) + if ( in_rev[ I( i, j, k, dimx, dimy ) ] == OBJECT ) + out_rev[ I( i + size, j + size, k + size, a_dimx, a_dimy ) ] = 1; + + + + // Replicate border values: + + // Faces: + /*for (i = size; i < (a_dimx - size); i++) + for (j = size; j < (a_dimy - size); j++) + { + out_rev[ I( i, j, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, j, size, a_dimx, a_dimy ) ]; + out_rev[ I( i, j, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( i, j, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + } + + for (j = size; j < (a_dimy - size); j++) + for (k = size; k < (a_dimz - size); k++) + { + out_rev[ I( size - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I( size, j, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, j, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, j, k, a_dimx, a_dimy ) ]; + } + + for (i = size; i < (a_dimx - size); i++) + for (k = size; k < (a_dimz - size); k++) + { + out_rev[ I( i, size - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( i, size, k, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - size, k, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - size, k, a_dimx, a_dimy ) ]; + } + + // Edges: + + for (i = size; i < (a_dimx - size); i++) + { + out_rev[ I( i, size - 1, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, size, size, a_dimx, a_dimy ) ]; + out_rev[ I( i, size - 1, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( i, size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - size, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, a_dimy - 1 - size, size, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - size, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + } + + for (j = size; j < (a_dimy - size); j++) + { + out_rev[ I( size - 1, j, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( size, j, size, a_dimx, a_dimy ) ]; + out_rev[ I( size - 1, j, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( size, j, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, j, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( a_dimx - 1 - size, j, size, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, j, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, j, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + } + + for (k = size; k < (a_dimz - size); k++) + { + out_rev[ I( size - 1, size - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( size, size, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, size - 1, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, size, k, a_dimx, a_dimy ) ]; + out_rev[ I( size - 1, a_dimy - size, k, a_dimx, a_dimy) ] = + out_rev[ I( size, a_dimy - 1 - size, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, a_dimy - size, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, a_dimy - 1 - size, k, a_dimx, a_dimy ) ]; + } + + // Corners: + + out_rev[ I( size - 1, size - 1, size - 1, a_dimx, a_dimy)] = + out_rev[ I( size, size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - size, size - 1, size - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( size - 1, a_dimy - size, size - 1, a_dimx, a_dimy)] = + out_rev[ I( size, a_dimy - 1 - size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( size - 1, size - 1, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( size, size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + + + out_rev[ I( a_dimx - size, a_dimy - size, size - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, a_dimy - 1 - size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( size - 1, a_dimy - size, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( size, a_dimy - 1 - size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - size, size - 1, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - size, a_dimy - size, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, a_dimy - 1 - size, a_dimz - 1 - size, a_dimx, a_dimy ) ];*/ + + + // Return OK: + return P3D_SUCCESS; +} diff --git a/pypore3d/pypore3d/P3D_Blob/Common/p3dUtils.h b/pypore3d/pypore3d/P3D_Blob/Common/p3dUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..659f85dc65572dc5549d3dca072faf5467db7889 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/Common/p3dUtils.h @@ -0,0 +1,243 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + + +#include <limits.h> + +#include "p3dCoordsList.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* + Constants: +*/ +#ifndef P3D_BLOB_DEFINED +#define P3D_BLOB_DEFINED + + #define P3D_FALSE -1 + #define P3D_TRUE 1 + + #define P3D_ERROR 0 + #define P3D_MEM_ERROR NULL /* Leave it NULL for simplify tests */ + #define P3D_SUCCESS 2 /* Any number */ + + #define BACKGROUND 0 + #define OBJECT UCHAR_MAX + + // Constants for 3D connectivity: + #define CONN6 711 + #define CONN18 712 + #define CONN26 713 + + // Constants for GVF Skeletonization - critical point classification: + #define CPT_SADDLE 200 + #define CPT_ATTRACTING_NODE 225 + #define CPT_REPELLING_NODE 250 + + // This is the size of the step used to advance to the next position + // when following the vector field (0.2 seems to be the best value + // and it should be multiplied for the scale factor in case of down- + // sampling): + #define STEP_SIZE 0.2 + + // This is the distance used to check if current point is close to a + // skeleton point or a critical point (0.2 seems to be the best value + // and it should be multiplied for the scale factor in case of down- + // sampling): + #define CLOSENESS 0.2 + + #define MIN_LENGTH 2.0 + +#endif + +/* + Macros: +*/ + +#ifndef P3D_BLOB_MACROS + #define P3D_BLOB_MACROS + + #define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) + #define MIN(x,y) (((x) < (y))?(x):(y)) + #define MAX(x,y) (((x) > (y))?(x):(y)) + + #define EPSILON 1E-3 /* Do not modify: 1E-3 is fair */ + #define EQUAL(n1, n2) (IS_ZERO((n1) - (n2))) + #define IS_ZERO(n) (((n) < EPSILON) && ((n) > -EPSILON)) + + #define SIGN(n) (IS_ZERO(n) ? 0 : ((n) < 0.00 ? -1 : 1)) + + + /* A sort of TRY-CATCH constructor: */ + #define P3D_MEM_TRY( function ) if ( ((function) == P3D_MEM_ERROR) ) { goto MEM_ERROR; } + #define P3D_TRY( function ) if ( ((function) == P3D_ERROR) ) { goto MEM_ERROR; } + +#endif + +/* + Functions: +*/ +int findNeighbor ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + coords_t* coords + ); + +int countNeighbors ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ); + + +int isSimplePoint( + unsigned char* im, // IN: Input (binary) original volume + const int dimx, + const int dimy, + const int dimz, + const int x, + const int y, + const int z + ); + +int p3dCrop3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dCrop3D_ushort2ushort ( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dCrop3D_uint2uint ( + unsigned int* in_rev, + unsigned int* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ); + +int p3dCrop3D_float2float ( + float* in_im, + float* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dZeroPadding3D_uchar2float ( + unsigned char* in_im, + float* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + + +int p3dZeroPadding3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dReplicatePadding3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +double interpolation ( + float* gvf, + int dimx, + int dimy, + int dimz, + const double x, + const double y, + const double z + ); + +int isBoundary ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ); + +int isFullNeighborhood ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ); + +int p3dSpecialPadding3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +#ifdef __cplusplus + } +#endif \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/_p3dTime.c b/pypore3d/pypore3d/P3D_Blob/_p3dTime.c new file mode 100644 index 0000000000000000000000000000000000000000..5535cb06ef7db49f05ee483b5d0617a84a02b46e --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/_p3dTime.c @@ -0,0 +1,68 @@ +#include <stdio.h> + +#include "p3dTime.h" + +int p3dTime_min = 0; +double p3dTime_sec = 0.0; + +#ifndef _WINDOWS + //#include <sys/time.h> + +// static struct timeval p3dTime_tv; + static unsigned long p3dTime_startTime, p3dTime_crtTime; +#else + #include <windows.h> + #include <time.h> + + DWORD p3dTime_startTime, p3dTime_crtTime; +#endif + + +void p3dResetStartTime() +{ + #ifdef _WINDOWS + p3dTime_startTime = GetTickCount(); + p3dTime_crtTime = GetTickCount(); + #else + //gettimeofday(&p3dTime_tv, NULL); + //p3dTime_startTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); + #endif + + p3dTime_crtTime = p3dTime_startTime; +} + +double p3dGetElapsedTime () +{ + #ifdef _WINDOWS + p3dTime_crtTime = GetTickCount(); + #else + //gettimeofday(&p3dTime_tv, NULL); + // p3dTime_crtTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); + #endif + + // Return time in seconds: + return ((p3dTime_crtTime - p3dTime_startTime)/1000.0); +} + +int p3dGetElapsedTime_min () +{ + #ifdef _WINDOWS + p3dTime_crtTime = GetTickCount(); + #else + //gettimeofday(&p3dTime_tv, NULL); + //p3dTime_crtTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); + #endif + + // Return time in seconds: + p3dTime_sec = ((p3dTime_crtTime - p3dTime_startTime)/1000.0); + p3dTime_min = (int) (p3dTime_sec / 60.0); + p3dTime_sec = p3dTime_sec - p3dTime_min*60.0; + + return p3dTime_min; +} + +double p3dGetElapsedTime_sec () +{ + return p3dTime_sec; +} + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dAnisotropyAnalysis.c b/pypore3d/pypore3d/P3D_Blob/p3dAnisotropyAnalysis.c new file mode 100644 index 0000000000000000000000000000000000000000..4790fd1d58dc1ae3baeaff2bb9e282062327abc7 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dAnisotropyAnalysis.c @@ -0,0 +1,1366 @@ +#include <omp.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <time.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + + +#define MAXROT 512 /* The maximum # of MIL rotations */ +#define MAXPOINTS 1024 + +#define FOO_I(i,j,N) ( (j)*(N) + (i) ) + +#define BAD 1 +#define GOOD 0 +#define ABEND 1 + + +#define EIGVALS(i,j) *(eigvals+(i)*dim+(j)) +#define EIGVECS(i,j) *(eigvecs+(i)*dim+(j)) +#define A(X,Y) *(a + (X)*dim + (Y)) +#define A_IN(X,Y) *(in + (X)*dim + (Y)) +#define BIGNUM 1.0E15 + +/* The next four subroutines are used with permission of Triaxis, Inc, +Los Alamos, NM 87544. They are from Version 2.0 of their Math++ library */ + +/********************************************************************** + * Copyright (c) Triakis, Inc. 1989 * + * * + * Function: linSystemSolve * + * * + * Version: 2.0 * + * * + * Purpose: Solution of linear system: Ax = b. * + * Used in conjunction with function linLuDecomp. * + * Not used if linLuDecomp has detected a singularity. * + * * + * linSystemSolve does the forward elimination * + * and back substitution. Splitting the process into * + * two parts allows solutions for multiple b vectors * + * with a minimum of recomputation. * + * * + * Returns: Status ( 0 = success and 1 = failure ). * + * * + * Call: linSystemSolve( dim, n, a, b, pivot ); * + * * + * input: * + * * + * dim = Maximum dimension of A in main. * + * n = order of matrix. * + * a = Triangularized matrix obtained from linLuDecomp. * + * b = Right hand side vector. * + * pivot = Pivot vector obtained from linLuDecomp. * + * * + * output: * + * * + * b = solution vector, x. * + * * + * External functions: * + * none. * + * * + * Algorithm: Forsythe, Malcolm, and Moler from the text * + * "Computer Methods for Mathematical Computations", * + * 1977, Prentice Hall. * + * * + * Coded in structured 'C' by Tim Julian and Eric Blommer. * + * * + **********************************************************************/ + + +int linSystemSolve(int dim, int order, double* a, double* b, int* pivot) { + + int i, + k, + m; + double temp; + + /* Forward elimination, trivial case. */ + if (order == 1) { + if (A(0, 0) == 0.0) { + return BAD; + } else { + b[0] /= A(0, 0); + return GOOD; + } + } + /* Forward elimination, non-trivial case. */ + for (k = 0; k < order - 1; ++k) { + m = pivot[k]; + temp = b[m]; + b[m] = b[k]; + b[k] = temp; + for (i = k + 1; i < order; ++i) { + b[i] += A(i, k) * temp; + } + } + /* Back substitution */ + for (k = order - 1; k >= 0; --k) { + if (A(k, k) == 0) { + return BAD; + } + b[k] /= A(k, k); + temp = -b[k]; + for (i = 0; i < k; ++i) { + b[i] += A(i, k) * temp; + } + } + + return GOOD; + +} /* End linSystemSolve */ + +/********************************************************************** + * Copyright (c) Triakis, Inc. 1989 * + * * + * Function: linLuDecomp * + * * + * Version: 2.0 * + * * + * Purpose: Decomposes a real general matrix by LU decomposition * + * and estimates the condition of the matrix. * + * * + * Function linSystemSolve computes solution to linear * + * systems after decomposition by this function. * + * * + * Returns: Condnum = An estimate of the condition number of "A". * + * A good rule of thumb in using condnum is that by taking * + * the log10 of the condnum and subtracting that value * + * from the number of double precision significant digits * + * availible, the remainder is the approximate number of * + * significant digits in your answer. * + * Condnum is set to 3.33e+33 if exact singularity * + * is detected. * + * * + * Call: status = linLuDecomp( dim, order, a, pivot, &condnum ); * + * * + * input: * + * dim = Maximum dimensioned columns of "A". * + * order = Order of the matrix (actual size of "A"). * + * a = Square matrix to be decomposed. * + * * + * output: * + * a = Contains an upper triangular matrix u and a * + * lower triangular matrix of multipliers. * + * condnum = An estimate of the condition number of A. * + * For the linear system A*x = b, changes in A and b * + * may cause changes condnum times as large in x. * + * Condnum is set to 3.33e+33 if exact singularity * + * is detected. * + * pivot = The pivot vector. * + * pivot[i] is the index of the ith pivot row. * + * pivot[order-1] is (-1) ** (number of interchanges) * + * * + * External functions: * + * linSystemSolve(), * + * fabs(), * + * calloc(), * + * free(). * + * * + * Algorithm: Forsythe, Malcolm, and Moler from the text * + * "Computer Methods for Mathematical Computations", * + * 1977, Prentice Hall( pages 30 - 62 ). * + * Also see the text "Linpack Users' Guide" by Dongarra, * + * Moler, Bunch, and Stewart, 1979 by Siam. * + * ( pages 1.1 - 1.34 and source listings in back ) * + * Note the routines dgeco, dgefa, dgedi, dgesl, * + * ddot, idamax, dscal, daxpy, and dasum. * + * Corresponding single precision routines are sgeco, * + * sgefa, sgedi, sgesl, sdot, isamax, sscal, saxpy, * + * and sasum. * + * * + * Misc: The determinant of A can be obtained on output by * + * det_a = pivot[order-1] * A(0,0) * A(1,1) * * + * ... * A(order-1,order-1). * + * See the book Computer Methods for Mathematical * + * Computations by Forsythe, Malcolm and Moler * + * pages 30 - 62 for further explanation. * + * * + * Coded in structured 'C' by Tim Julian and Eric Blommer. * + * * + **********************************************************************/ + + +int linLuDecomp(int dim, int order, double* a, int* pivot, double* condnum) { + /* Local variable declarations. */ + double *work, + ek, + temp, + anorm, + ynorm, + znorm; + int i, + j, + k, + kplus1, + m, + flag; + /* Function declarations. */ + //char *calloc (); + //int linSystemSolve (); + + /* Check that "a" matrix order not larger than maximum size */ + if (order > dim) { + (void) fprintf(stderr, " In linLuDecomp: order > Max. dim.\n"); + (void) exit(ABEND); + } + /* Check that "a" matrix order not smaller than one. */ + if (order < 1) { + (void) fprintf(stderr, " In linLuDecomp: order < 1\n"); + (void) exit(ABEND); + } + + /* Dynamically allocate work vector appropriate for problem. */ + if ((work = (double *) calloc(order, sizeof (double))) == NULL) { + (void) fprintf(stderr, " In linLuDecomp: can't allocate work vector.\n"); + (void) exit(ABEND); + } + + pivot[order - 1] = 1; + /* Treat the trivial case. */ + if (order == 1) { + if (A(0, 0) != 0.0) { + *condnum = 1.0; + free(work); + return GOOD; + } else { + /* Exact singularity detected for trivial case */ + *condnum = 3.33e33; + free(work); + return BAD; + } + } + /* Compute the 1-norm of matrix 'a'. */ + /* The 1-norm of matrix 'a' is defined as the largest */ + /* sum of the absolute values of each of the elements */ + /* of a single column vector across all column vectors. */ + anorm = 0.0; + for (j = 0; j < order; ++j) { + temp = 0.0; + for (i = 0; i < order; ++i) { + temp += fabs(A(i, j)); + } + if (temp > anorm) { + anorm = temp; + } + } + /* Gaussian elimination with partial pivoting. */ + /* See Linpack function dgefa or sgefa */ + for (k = 0; k < order - 1; ++k) { + kplus1 = k + 1; + /* Find pivot. */ + m = k; + for (i = kplus1; i < order; ++i) { + if (fabs(A(i, k)) > fabs(A(m, k))) { + m = i; + } + } + pivot[k] = m; + /* See Linpack function dgedi or sgedi */ + if (m != k) { + pivot[order - 1] = -pivot[order - 1]; + } + /* Skip step if pivot is zero. */ + if (A(m, k) != 0.0) { + + if (m != k) { + temp = A(m, k); + A(m, k) = A(k, k); + A(k, k) = temp; + } + /* Compute multipliers. */ + temp = -1.0 / A(k, k); + + for (i = kplus1; i < order; ++i) { + A(i, k) *= temp; + } + /* Row elimination with column indexing */ + for (j = kplus1; j < order; ++j) { + temp = A(m, j); + A(m, j) = A(k, j); + A(k, j) = temp; + if (temp != 0.0) { + for (i = kplus1; i < order; ++i) { + A(i, j) += A(i, k) * temp; + } + } + } + } + } /* End k loop. */ + /* Calculate condition number of matrix. */ + /* condnum = (1-norm of a)*(an estimate of 1-norm of a-inverse) */ + /* Estimate obtained by one step of inverse iteration for the */ + /* small singular vector. This involves solving two systems */ + /* of equations, (a-transpose)*y = e and a*z = y where e */ + /* is a vector of +1 or -1 chosen to cause growth in y. */ + /* Estimate = (1-norm of z)/(1-norm of y) */ + /* First, solve (a-transpose)*y = e */ + for (k = 0; k < order; ++k) { + temp = 0.0; + if (k != 0) { + for (i = 0; i < k - 1; ++i) { + temp += A(i, k) * work[i]; + } + } + if (temp < 0.0) { + ek = -1.0; + } else { + ek = 1.0; + } + if (A(k, k) == 0.0) { + /* Exact singularity detected for non-trivial case */ + *condnum = 3.33e33; + free(work); + return BAD; + } + work[k] = -(ek + temp) / A(k, k); + } + for (k = order - 2; k >= 0; --k) { + temp = 0.0; + for (i = k + 1; i < order; ++i) { + temp += A(i, k) * work[k]; + } + work[k] = temp; + m = pivot[k]; + if (m != k) { + temp = work[m]; + work[m] = work[k]; + work[k] = temp; + } + } + + ynorm = 0.0; + for (i = 0; i < order; ++i) { + ynorm += fabs(work[i]); + } + /* Solve a*z = y. */ + flag = linSystemSolve(dim, order, a, work, pivot); + if (flag == 1) { + (void) fprintf(stderr, "In linLuDecomp: error detected in function linSystemSolve.\n"); + (void) exit(ABEND); + } + + znorm = 0.0; + for (i = 0; i < order; ++i) { + znorm += fabs(work[i]); + } + /* Estimate condition number. */ + *condnum = anorm * znorm / ynorm; + if (*condnum < 1.0) { + *condnum = 1.0; + } + + free(work); + + return GOOD; + +} /* End linLuDecomp */ + +/********************************************************************** + * Copyright (c) Triakis, Inc. 1989 * + * * + * Function: linInverseMatrix * + * * + * Version: 2.0 * + * * + * Purpose: Determines the inverse of a matrix via LU decomposition.* + * * + * Returns: Nothing of value. * + * * + * Call: linInverseMatrix( dim, order, a, in ); * + * * + * input: * + * dim = maximum dimensioned columns of "A". * + * order = order of the matrix (actual size of "A"). * + * a = square matrix to be decomposed. * + * * + * output: * + * in = Inverse of matrix "a". * + * * + * External functions: * + * linSystemSolve(), * + * linLuDecomp(), * + * calloc(), * + * free(). * + * * + * Algorithm: Tim Julian and Eric Blommer. * + * * + **********************************************************************/ + + +void linInverseMatrix(int dim, int order, double* a, double* in) { + int i, + j; /* work variables */ + int status; /* return flag to check functions */ + int *pivot; /* pivoting from function linLuDecomp */ + //int linLuDecomp (); /* decompose matrix a into LU matrix */ + //int linSystemSolve (); /* solve system of simultaneous eqns. */ + double *b; /* B vector */ + double condnum; /* matrix condition number */ + //char *calloc (); + + if (order > dim) { + (void) fprintf(stderr, "Inverse: order is greater than dim!\n"); + (void) exit(ABEND); + } + + /* allocate work vectors */ + + if ((b = (double *) calloc(order, sizeof (double))) == NULL) { + (void) fprintf(stderr, " In linInverseMatrix, can't allocate b vector.\n"); + (void) exit(ABEND); + } + + if ((pivot = (int *) calloc(order, sizeof (int))) == NULL) { + (void) fprintf(stderr, " In linInverseMatrix, can't allocate pivot vector.\n"); + (void) exit(ABEND); + } + + /* Initialize data values */ + condnum = 0.0; + + /* decompose matrix */ + status = linLuDecomp(dim, order, a, pivot, &condnum); + + if (status == 1) { + (void) fprintf(stderr, "In Inverse, error detected in function linLuDecomp.\n"); + (void) exit(ABEND); + } + + if (condnum > BIGNUM) { + (void) fprintf(stderr, "Inverse: Matrix singular to double precision.\n"); + (void) fprintf(stderr, "Condition number : %e\n", condnum); + (void) exit(ABEND); + } + /* backsolve matrix */ + for (i = 0; i < order; ++i) { + for (j = 0; j < order; ++j) { + if (j == i) { + b[j] = 1.0; + } else { + b[j] = 0.0; + } + } + status = linSystemSolve(dim, order, a, b, pivot); + + if (status == 1) { + (void) fprintf(stderr, "In Inverse, error detected in function linSystemSolve.\n"); + (void) exit(ABEND); + } + for (j = 0; j < order; ++j) { + A_IN(j, i) = b[j]; + } + } + + free(b); + free(pivot); + +} /* end linInverseMatrix */ + +/********************************************************************** + * Copyright (c) Triakis, Inc. 1989 * + * * + * Function: eigJacobi * + * * + * Version: 2.0 * + * * + * Purpose: Computes the eigenvalues and eigenvectors of a real * + * symmetric matrix via the Jacobi method. * + * * + * Returns: status = (0 = success, 1 = failure) * + * * + * Call: status = eigJacobi( d, e1, e2, o, e, it, mit ), where:* + * * + * input: * + * d = maximum dimension of matrix eigenvalue matrix * + * e1 = eigenvalue matrix. * + * e2 = eigenvector matrix. * + * o = order of the matrices * + * e = convergence criterion * + * mit = maximum number of iterations allowed * + * * + * output: * + * e1 = eigenvalue matrix. * + * e2 = eigenvector matrix. * + * it = actual number of iterations * + * * + * External functions: * + * fabs(), * + * calloc(), * + * free(), * + * sqrt(). * + * * + * Author(s): Tim Julian and Eric Blommer * + * * + * Misc: None. * + * * + * Coded in structured 'C' by Tim Julian and Eric Blommer. * + * * + **********************************************************************/ + + + +int eigJacobi(int dim, + double* eigvals, + double* eigvecs, + int order, + double eps, + int* numiters, + int maxiters) { + + double vo, + f, + u, + uf, + alpha, + beta, + c, + s; + double *temp1, + *temp2, + *temp3; + int i, + j, + l, + m, + p, + q; + //char *calloc (); + + /* dynamically allocate temporary vectors */ + if ((temp1 = (double *) calloc(dim, sizeof (double))) == NULL) { + (void) fprintf(stderr, "Can't allocate vector temp1\n"); + (void) exit(ABEND); + } + + if ((temp2 = (double *) calloc(dim, sizeof (double))) == NULL) { + (void) fprintf(stderr, "Can't allocate vector temp2\n"); + (void) exit(ABEND); + } + + if ((temp3 = (double *) calloc(dim, sizeof (double))) == NULL) { + (void) fprintf(stderr, "Can't allocate vector temp3\n"); + (void) exit(ABEND); + } + + /* make identity matrix */ + for (i = 0; i < order; ++i) + for (j = 0; j <= i; ++j) { + if (i == j) { + EIGVECS(i, j) = 1.0; + } else { + EIGVECS(i, j) = EIGVECS(j, i) = 0.0; + } + } + + + vo = 0.0; + + for (i = 0; i < order; ++i) + for (j = 0; j < order; ++j) { + if (i != j) { + vo += EIGVALS(i, j) * EIGVALS(i, j); + } + } + + + u = sqrt(vo) / (double) order; + uf = eps * u; + + for (uf = eps * u; uf < u; u /= order) { + for (l = 0; l < order - 1; ++l) { + for (m = l + 1; m < order; ++m) { + if (fabs(EIGVALS(l, m)) >= u) { + p = l; + q = m; + for (i = 0; i < order; ++i) { + temp1[i] = EIGVALS(p, i); + temp2[i] = EIGVALS(i, p); + temp3[i] = EIGVECS(i, p); + } + + f = EIGVALS(p, p); + alpha = 0.5 * (EIGVALS(p, p) - EIGVALS(q, q)); + beta = sqrt(EIGVALS(p, q) * EIGVALS(p, q) + alpha * alpha); + c = sqrt(0.5 + fabs(alpha) / (2.0 * beta)); + s = alpha * (-EIGVALS(p, q)) / (2.0 * beta * fabs(alpha) * c); + + for (j = 0; j < order; ++j) { + if (j != p) { + if (j != q) { + EIGVALS(p, j) = c * EIGVALS(p, j) - s * EIGVALS(q, j); + EIGVALS(q, j) = s * temp1[j] + c * EIGVALS(q, j); + EIGVALS(j, p) = c * EIGVALS(j, p) - s * EIGVALS(j, q); + EIGVALS(j, q) = s * temp2[j] + c * EIGVALS(j, q); + } + } + EIGVECS(j, p) = c * EIGVECS(j, p) - s * EIGVECS(j, q); + EIGVECS(j, q) = s * temp3[j] + c * EIGVECS(j, q); + } + + EIGVALS(p, p) = c * c * EIGVALS(p, p) + s * s * + EIGVALS(q, q) - 2.0 * c * s * EIGVALS(p, q); + EIGVALS(q, q) = s * s * f + c * c * EIGVALS(q, q) + + 2.0 * c * s * EIGVALS(p, q); + EIGVALS(p, q) = 0.0; + EIGVALS(q, p) = 0.0; + + if (++*numiters > maxiters) { + (void) fprintf(stderr, "number of iterations exceeded %d", maxiters); + return BAD; + } + } + } + } + } + + free(temp1); + free(temp2); + free(temp3); + + return GOOD; + +} /* end eigJacobi */ + + +/************************************************************************/ +/* */ +/* Software to perform three-dimensional stereology. The methods */ +/* are based on a three-dimensional version of the directed secant */ +/* algorithm (Saltykov, 1958). 3-D mean intercept length vectors, */ +/* MIL(theta,phi), are calculated and fit to an ellipsoid from */ +/* which the three principal MIL vectors are determined. */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* Function: _getMILs */ +/* */ +/* Function to scan the image v_array using a three-dimensional */ +/* version of the directed secant method. The image is scanned by */ +/* a 3-D test grid at randomly determined orientations. The */ +/* orientations are defined by spherical angles (theta, phi). */ +/* Theta is the rotation about the x-axis and phi is the rotation */ +/* about the z-axis. Based on the threshold value, the image is */ +/* converted to a binary format and the bone volume fraction is */ +/* determined. The image is then systematically scanned and */ +/* intersections are recorded when the binary value of the current */ +/* voxel differs from the binary value of the previous voxel. */ +/* Standard morphology parameters are calculated based on the */ +/* parallel plate model: */ +/* BV/TV = # bone voxels/total # voxels in test sphere */ +/* Tb.N = total # intersections/total length of test lines */ +/* Tb.Th = BV/TV / Tb.N */ +/* Tb.Sp = (1-BV/TV) / Tb.N */ +/* BS/BV = 2 * Tb.N / BV/TV */ +/* Three-dimensional mean intercept length vectors are calculated */ +/* for each rotation as: */ +/* MIL(theta, phi) = (BV/TV) / ((1/2) * #intersections */ +/* per unit test line length) */ +/* */ + +/************************************************************************/ + +void _getMILs( + unsigned char* in_im, // A_IN: Input segmented (binary) volume + unsigned char* msk_im, + double* rot_theta, // OUT: rotations in THETA angle + double* rot_phi, // OUT: rotations in PHI angle + double* mil, // OUT: Mean Intercept Lengths + const unsigned int dimx, + const unsigned int dimy, + const unsigned int dimz, + const double voxelsize + ) { + int i; + double s; + + // Indexes for volume scanning: + double x, y, z; + double prec_x, prec_y, prec_z; + + double end_x1, end_y1, end_z1; + double end_x2, end_y2, end_z2; + int start_x, start_y, start_z; + + + // Test line direction vectors: + double r_0, r_1, r_2; + double normr_0, normr_1, normr_2; + int ct; + + // Variables for length management: + double length, tot_length; + double bvf; // Bone Volume Fraction (i.e. BV/TV) + double intersect_ct; + + /*double t_totlength, t_intersect_ct; + double pl, sv, tb, tpd, tps;*/ + + unsigned char prec_status, curr_status; + unsigned int iseed; + time_t tt; + + + // Variables for rotation cycle: + int ct_rot; + + // Init random seeds: + iseed = (unsigned int) time(&tt); + srand(iseed); + + + // Get BV/TV: + s = 0.0; +#pragma omp parallel for reduction (+ : s) + for (i = 0; i < (int) (dimx * dimy * dimz); i++) + if (in_im[i] == OBJECT) s++; + + bvf = s / ((double) (dimx * dimy * dimz)); + + /*t_totlength = 0.0; + t_intersect_ct = 0.0;*/ + + // For each rotations: +#pragma omp parallel for private( ct, tot_length, intersect_ct, start_x, start_y, start_z, x, y, z, prec_x, prec_y, prec_z, end_x1, end_y1, end_z1, end_x2, end_y2, end_z2, prec_status, curr_status, length, r_0, r_1, r_2, normr_0, normr_1, normr_2 ) + for (ct_rot = 0; ct_rot < MAXROT; ct_rot++) { + rot_theta[ct_rot] = (rand() / ((double) RAND_MAX + 1)) * M_PI; + rot_phi[ct_rot] = (rand() / ((double) RAND_MAX + 1)) * M_PI; + + /*fprintf(stderr, "rot_theta[ct_rot]: %0.5f\n", rot_theta[ct_rot]); + fprintf(stderr, "rot_phi[ct_rot]: %0.5f\n", rot_phi[ct_rot]);*/ + + // Define direction vector (versor): + r_0 = cos(rot_phi[ct_rot]) * sin(rot_theta[ct_rot]); + r_1 = sin(rot_phi[ct_rot]) * sin(rot_theta[ct_rot]); + r_2 = cos(rot_theta[ct_rot]); + + // Normalize direction vector to +1 for the maximum component, + // doing so we can save iteration on next cycle: + if ((fabs(r_0) >= fabs(r_1)) && (fabs(r_0) >= fabs(r_2))) { + normr_0 = 1.0; + normr_1 = r_1 / r_0; + normr_2 = r_2 / r_0; + } else if ((fabs(r_1) >= fabs(r_0)) && (fabs(r_1) >= fabs(r_2))) { + normr_1 = 1.0; + normr_0 = r_0 / r_1; + normr_2 = r_2 / r_1; + } else { + normr_2 = 1.0; + normr_0 = r_0 / r_2; + normr_1 = r_1 / r_2; + } + + // Make sure signs are correct: + normr_0 = (r_0 > 0) ? fabs(normr_0) : (-fabs(normr_0)); + normr_1 = (r_1 > 0) ? fabs(normr_1) : (-fabs(normr_1)); + normr_2 = (r_2 > 0) ? fabs(normr_2) : (-fabs(normr_2)); + + + tot_length = 0.0; + intersect_ct = 0.0; + + for (ct = 0; ct < MAXPOINTS; ct++) { + start_x = (int) (rand() / (((double) RAND_MAX + 1) / dimx)); + start_y = (int) (rand() / (((double) RAND_MAX + 1) / dimy)); + start_z = (int) (rand() / (((double) RAND_MAX + 1) / dimz)); + + // Check if inside MSK (if mask): + if (msk_im != NULL) + { + if (msk_im[ I(start_x, start_y, start_z, dimx, dimy)] == BACKGROUND) + { + continue; + } + + } + + x = start_x; + y = start_y; + z = start_z; + + // Reset status: + prec_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the incremental and decremental sides while edges of + // VOI are reached: + if (msk_im == NULL) { + // Explore the incremental versus while edges of VOI are reached: + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz)) { + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + intersect_ct++; + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x + normr_0; + y = y + normr_1; + z = z + normr_2; + } + + // Get end point of the test line: + end_x1 = prec_x; + end_y1 = prec_y; + end_z1 = prec_z; + + // Reset "center" of the line: + x = start_x; + y = start_y; + z = start_z; + + // Reset status: + prec_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the decremental versus while edges of VOI are reached: + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz)) { + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + intersect_ct++; + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x - normr_0; + y = y - normr_1; + z = z - normr_2; + } + + // Get the other end point of the test line: + end_x2 = prec_x; + end_y2 = prec_y; + end_z2 = prec_z; + } else { + // Explore the incremental and decremental sides while edges of + // mask are reached of image edges are reached: + + // Explore the incremental versus while edges of VOI are reached: + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz) && + (msk_im[ I((int) x, (int) y, (int) z, dimx, dimy)] == OBJECT) + ) { + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + intersect_ct++; + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x + normr_0; + y = y + normr_1; + z = z + normr_2; + } + + // Get end point of the test line: + end_x1 = prec_x; + end_y1 = prec_y; + end_z1 = prec_z; + + // Reset "center" of the line: + x = start_x; + y = start_y; + z = start_z; + + // Reset status: + prec_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the decremental versus while edges of VOI are reached: + while ( (x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz) && + (msk_im[ I((int) x, (int) y, (int) z, dimx, dimy)] == OBJECT) + ) { + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + intersect_ct++; + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x - normr_0; + y = y - normr_1; + z = z - normr_2; + } + + // Get the other end point of the test line: + end_x2 = prec_x; + end_y2 = prec_y; + end_z2 = prec_z; + + } + + // Get distance: + length = (end_x1 - end_x2)*(end_x1 - end_x2) + + (end_y1 - end_y2)*(end_y1 - end_y2) + + (end_z1 - end_z2)*(end_z1 - end_z2); + length = sqrt(length); + + // Add current length to array for this grid: + tot_length += length*voxelsize; + } + + // Save current MIL: + mil[ ct_rot ] = (2.0 * bvf) * (tot_length / intersect_ct); + + /*t_totlength += tot_length; + t_intersect_ct += intersect_ct;*/ + + } // end for each rotation + + /*pl = t_intersect_ct / t_totlength; + + sv = 2 * pl / bvf; // BS/BV, [mm^2 mm^-3] + tb = bvf / pl; // Tb.Th, [mm] + tpd = pl; // Tb.N, [mm^-1] + tps = (1.0-bvf)/pl; // Tb.Sp, [mm] */ + +} + +/************************************************************************/ +/* Function: _MILs2fit() */ +/* */ +/* This function fits the 3-D MIL data to an ellipsoid, and */ +/* determines the goodness of the fit. These methods are based on */ +/* 2-D methods of Whitehouse (JMicroscopy 101:153-168, 1974) and */ +/* Harrigan and Mann (JMatSci 19:761-767, 1984). The approach is */ +/* to plot the locus of the end points of the MIL vectors issuing */ +/* from a common center and fit them to an ellipsoid of general */ +/* formula: */ +/* */ +/* A*n1^2 + B*n2^2 + C*n3^2 + D*n1*n2 + E*n1*n3 + F*n2*n3 = 1/L^2 */ +/* */ +/* where L is the length of the MIL, ni are the direction cosines */ +/* between L and the base vectors in an arbitrary coordinate */ +/* system and A...F are the ellipsoid coefficients. */ +/* */ +/* For this code, a multivariable linear least squares fitting */ +/* technique is used to fit the data by solving the linear system */ +/* A * x = b, where A contains the projection data for each */ +/* rotation, x is a column vector of the ellipsoid coefficients */ +/* and b is a column vector of 1/L^2, where L is the magnitude of */ +/* the MIL vector. The solution is formulated as: */ +/* */ +/* x = (At * A)^-1 * At * b */ +/* */ + +/************************************************************************/ +void _MILs2fit( + double* rot_theta, // A_IN: rotations in THETA angle + double* rot_phi, // A_IN: rotations in PHI angle + double* mil, // A_IN: Mean Intercept Lengths + double* xvector // OUT: vector of six ellipsoid coefficients + ) { + double x, y, z; /* direction vector projections */ + double a[MAXROT][6]; /* A matrix */ + double at[6][MAXROT]; /* A transpose (At) */ + //double ata[6][6]; /* A transpose * A (AtA) */ + //double atai[6][6]; /* inverse of AtA (AtA)^-1 */ + double* ata; + double* atai; + double c[6][MAXROT]; /* (AtA)^-1 * At */ + double b[MAXROT]; // vector of 1/(MIL)^2 + + /*double bmn, bfitmn; // mean of measured and fit b + double bfit[MAXROT]; // b vector based on fit + double expdif, expfit, expsqr; // stats for measured data + double fitsqr, fitdif; // stats for fit data */ + + int i, j, k; // loop variables + int degree = 6; // degree of vectors (6) + + + // Allocate memory: + ata = (double*) calloc(6 * 6, sizeof (double)); + atai = (double*) calloc(6 * 6, sizeof (double)); + + // Initialize the matrices: + /*#pragma omp parallel for private( j ) + for ( i = 0; i < degree; i++ ) + for ( j = 0; j < degree; j++ ) + { + ata[i][j] = 0.0; + atai[i][j] = 0.0; + }*/ + +#pragma omp parallel for private( i ) + for (k = 0; k < MAXROT; k++) + for (i = 0; i < degree; i++) + c[i][k] = 0.0; + + for (i = 0; i < degree; i++) + xvector[i] = 0.0; + + + // Determine A and b matrices of Ax = b: +#pragma omp parallel for private( x, y, z ) + for (i = 0; i < MAXROT; i++) { + x = cos(rot_phi[i]) * sin(rot_theta[i]); + y = sin(rot_phi[i]) * sin(rot_theta[i]); + z = cos(rot_theta[i]); + + a[i][0] = x * x; + a[i][1] = y * y; + a[i][2] = z * z; + a[i][3] = x * y; + a[i][4] = y * z; + a[i][5] = x * z; + + b[i] = 1.0 / (*(mil + i) * *(mil + i)); + } + + // Determine At of AtAx = Atb: +#pragma omp parallel for + for (i = 0; i < MAXROT; i++) { + at[0][i] = a[i][0]; + at[1][i] = a[i][1]; + at[2][i] = a[i][2]; + at[3][i] = a[i][3]; + at[4][i] = a[i][4]; + at[5][i] = a[i][5]; + } + + // Multiply At * A: +#pragma omp parallel for private( i, j ) + for (k = 0; k < MAXROT; k++) + for (j = 0; j < degree; j++) + for (i = 0; i < degree; i++) + //ata[i][j] += at[i][k]*a[k][j]; + ata[ FOO_I(i, j, 6) ] += at[i][k] * a[k][j]; + + // Find inverse of AtA: + linInverseMatrix(degree, degree, ata, atai); + + // Multiply (AtA)^-1 * At : +#pragma omp parallel for private( i, j ) + for (k = 0; k < MAXROT; k++) + for (j = 0; j < degree; j++) + for (i = 0; i < degree; i++) + //c[i][k] += atai[i][j]*at[j][k]; + c[i][k] += atai[ FOO_I(i, j, 6) ] * at[j][k]; + + // Multiply (AtA)^-1 * At * b: +#pragma omp parallel for private( i ) + for (k = 0; k < MAXROT; k++) + for (i = 0; i < degree; i++) + xvector[i] += c[i][k] * b[k]; + + // Release resources: + if (ata != NULL) free(ata); + if (atai != NULL) free(atai); + + /* + // Determine the goodness of fit. Begin by calculating the sum of the + // square of the residuals. + sqres = 0.0; + + for(i=0;i<MAXROT;i++) { + bfit[i] = xvector[0]*a[i][0] + xvector[1]*a[i][1] + + xvector[2]*a[i][2] + xvector[3]*a[i][3] + + xvector[4]*a[i][4] + xvector[5]*a[i][5]; + + sqres += pow((b[i] - bfit[i]), 2.0); + } + + // Find the mean of b[] and bfit[] + bmn = 0.0; + bfitmn = 0.0; + + for(i=0; i<MAXROT; i++) { + bmn += b[i]; + bfitmn += bfit[i]; + } + + bmn /= (double)MAXROT; + bfitmn /= (double)MAXROT; + + // Find the variance of the error in the ellipsoid fit: + variance = sqres / (double)(MAXROT - 6 - 1); + stdev = sqrt(variance); + + // Calculate the correlation coefficients: + expfit=0.0; + expsqr=0.0; + fitsqr=0.0; + + for ( i = 0; i < MAXROT; i++ ) + { + expdif = b[i] - bmn; + fitdif = bfit[i] - bfitmn; + expfit += expdif * fitdif; + expsqr += expdif * expdif; + fitsqr += fitdif * fitdif; + } + + // Avoid division by zero: + if(( expsqr < 0.0) || (fitsqr < 0.0) ) + corr = 1.0; + else + corr = expfit / sqrt(expsqr*fitsqr);*/ +} + + +/************************************************************************/ +/* Function: _getDegreesOfAnisotropy */ +/* */ +/* This function defines the MIL tensor based on the ellipsoid fit */ +/* and determines the principal eigenvectors and eigenvalues, */ +/* which are used to define the principal MIL vector orientations */ +/* and magnitudes, respectively. The MIL tensor assumes material */ +/* orthotropy and is defined as (Harrigan and Mann, JMatSci */ +/* 19:761-767, 1984): */ +/* */ +/* | ae de/2 ee/2 | */ +/* M = | de/2 be fe/2 | */ +/* | ee/2 fe/2 ce | */ +/* where ae, be, ..,fe are the ellipsoid coefficients */ +/* */ +/* The orientations of the principal MILs are defined by spherical */ +/* angles, a and b, where a and b correspond to theta and phi, */ +/* respectively. The magnitudes of the principal MILs are */ +/* calculated as the inverse of the square root of the absolute */ +/* values of the eigenvalues. */ +/* */ +/* The three degrees of anisotropy are defined according to Benn, */ +/* Journ Sed Res., 64(4): 910 (1994) as: */ +/* I = t3/t1 */ +/* E = 1 - t2/t1 */ +/* where the isotropy index I measures the similarity of a fabric to */ +/* a uniform distribution and varies between 0 (all observations */ +/* confined to a single plane or axis) and 1 (perfect isotropy). The */ +/* elongation index E measures the preferred orientation of a fabric */ +/* in the V1/V2 plane and varies between 0 (no preferred orientation */ +/* and 1 (a perfect preferred orientation with all observations */ +/* parallel. */ +/* */ + +/************************************************************************/ +int _getDegreesOfAnisotropy( + double* coeffs, // A_IN: vector of six ellipsoid coefficients + double* degI, // OUT: isotropy index I + double* degE, // OUT: elongation index E + int (*wr_log)(const char*, ...) + ) { + double eps = 1.0E-6; /* convergence criterion */ + + double prin1, prin2, prin3; /* principal MIL vectors */ + double min_prin, med_prin, max_prin; + double orient1a, orient1b; /* orientation of 1st principal */ + double orient2a, orient2b; /* orientation of 2nd principal */ + double orient3a, orient3b; /* orientation of 3rd principal */ + double prinmn; /* mean principal value of MIL */ + + double eigvals[9]; + double eigvecs[9]; + + int dim = 3; /* dimension of evalue and evector v_array*/ + int order = 3; /* order of matrices */ + int numiters = 0; /* number of iterations required */ + int maxiters = 50; /* maximum number of iterations allowed */ + int status; /* status returned by eigJacobi */ + + // Return ellipse coefficients through external variables: + double ae = coeffs[0]; + double be = coeffs[1]; + double ce = coeffs[2]; + double de = coeffs[3]; + double ee = coeffs[4]; + double fe = coeffs[5]; + + /* Create the MIL tensor */ + *(eigvals + 0) = ae; + *(eigvals + 1) = de / 2.0; + *(eigvals + 2) = fe / 2.0; + *(eigvals + 3) = de / 2.0; + *(eigvals + 4) = be; + *(eigvals + 5) = ee / 2.0; + *(eigvals + 6) = fe / 2.0; + *(eigvals + 7) = ee / 2.0; + *(eigvals + 8) = ce; + + /* Calculate the eigenvalues and eigenvectors of the matrix/tensor */ + status = eigJacobi(dim, eigvals, eigvecs, order, eps, &numiters, maxiters); + if (status == 1) return P3D_ERROR; + + /* Determine the angles of orientation for the structure */ + orient1a = atan2(*(eigvecs + 6), sqrt(pow(*(eigvecs + 0), 2.0) + pow(*(eigvecs + 3), 2.0))); + orient1b = atan2(*(eigvecs + 3), *(eigvecs + 0)); + + orient2a = atan2(*(eigvecs + 7), sqrt(pow(*(eigvecs + 1), 2.0) + pow(*(eigvecs + 4), 2.0))); + orient2b = atan2(*(eigvecs + 4), *(eigvecs + 1)); + + orient3a = atan2(*(eigvecs + 8), sqrt(pow(*(eigvecs + 2), 2.0) + pow(*(eigvecs + 5), 2.0))); + orient3b = atan2(*(eigvecs + 5), *(eigvecs + 2)); + + /* Convert the angles from radians -> degrees */ + orient1a *= (180.0 / M_PI); + if (orient1a < 0.0) orient1a += 180.0; + orient1b *= (180.0 / M_PI); + if (orient1b < 0.0) orient1b += 180.0; + orient2a *= (180.0 / M_PI); + if (orient2a < 0.0) orient2a += 180.0; + orient2b *= (180.0 / M_PI); + if (orient2b < 0.0) orient2b += 180.0; + orient3a *= (180.0 / M_PI); + if (orient3a < 0.0) orient3a += 180.0; + orient3b *= (180.0 / M_PI); + if (orient3b < 0.0) orient3b += 180.0; + + /* Determine the principal values */ + prin1 = 1.000 / sqrt(fabs(*(eigvals + 0))); + prin2 = 1.000 / sqrt(fabs(*(eigvals + 4))); + prin3 = 1.000 / sqrt(fabs(*(eigvals + 8))); + + /* Normalize principal values: */ + prinmn = prin1 + prin2 + prin3; + + prin1 = prin1 / prinmn; + prin2 = prin2 / prinmn; + prin3 = prin3 / prinmn; + + // Find minimum (t1), medium (t2) and maximum (t3) normalized principal value: + min_prin = MIN(MIN(prin1, prin2), prin3); + max_prin = MAX(MAX(prin1, prin2), prin3); + + if ((prin1 != min_prin) && (prin1 != max_prin)) med_prin = prin1; + if ((prin2 != min_prin) && (prin2 != max_prin)) med_prin = prin2; + if ((prin3 != min_prin) && (prin3 != max_prin)) med_prin = prin3; + + // Compute degrees of anisotropy: + *degI = (min_prin / max_prin); // I = t3 / t1 + *degE = 1 - (med_prin / max_prin); // E = 1 - t2 / t1 + // DA = t1 / t3 + + if (wr_log != NULL) { + wr_log("\tPore3D - Anisotropy analysis verbose mode: "); + wr_log("\t\t Principal MILs: %.4lf\t%.4lf\t%.4lf", prin1, prin2, prin3); + wr_log("\t\t Orientation 1 (theta,phi): (%.2lf, %.2lf)", orient1a, orient1b); + wr_log("\t\t Orientation 2 (theta,phi): (%.2lf, %.2lf)", orient2a, orient2b); + wr_log("\t\t Orientation 3 (theta,phi): (%.2lf, %.2lf)", orient3a, orient3b); + wr_log("\t"); + wr_log("\t\t Ellipsoid fit parameters:"); + wr_log("\t\t\t ae = %.4lf\tbe = %.4lf\tce = %.4lf", ae, be, ce); + wr_log("\t\t\t de = %.4lf\tee = %.4lf\tfe = %.4lf", de, ee, fe); + wr_log("\t\t Eigenvalues:"); + wr_log("\t\t \t%.4lf\t%.4lf\t%.4lf", *(eigvals + 0), *(eigvals + 4), *(eigvals + 8)); + wr_log("\t\t Eigenvectors:"); + wr_log("\t\t \tE-vector 1: (%.4lf,%.4lf,%.4lf)", *(eigvecs + 0), *(eigvecs + 3), *(eigvecs + 6)); + wr_log("\t\t \tE-vector 2: (%.4lf,%.4lf,%.4lf)", *(eigvecs + 1), *(eigvecs + 4), *(eigvecs + 7)); + wr_log("\t\t \tE-vector 3: (%.4lf,%.4lf,%.4lf)", *(eigvecs + 2), *(eigvecs + 5), *(eigvecs + 8)); + } + + // Return success: + return P3D_SUCCESS; +} + +int p3dAnisotropyAnalysis( + unsigned char* in_im, + unsigned char* msk_im, + AnisotropyStats* out_stats, + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, + const int verbose, + int (*wr_log)(const char*, ...) + ) { + double* rot_theta = (double *) malloc(MAXROT * sizeof (double)); + double* rot_phi = (double *) malloc(MAXROT * sizeof (double)); + double* mil = (double *) malloc(MAXROT * sizeof (double)); + double* coeffs = (double *) malloc(6 * sizeof (double)); + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing anisotropy analysis..."); + wr_log("\tAdopted voxelsize: %0.6f mm.", voxelsize); + } + + // Call routine to determine MILs based on random rotations: + _getMILs(in_im, msk_im, rot_theta, rot_phi, mil, dimx, dimy, dimz, voxelsize); + + /* Call routine to determine the best fit ellipsoid equation for data */ + _MILs2fit(rot_theta, rot_phi, mil, coeffs); + + /* Call routine to calculate the properties of the ellipsoid tensor */ + if (verbose == P3D_TRUE) + _getDegreesOfAnisotropy(coeffs, &(out_stats->I), &(out_stats->E), wr_log); + else + _getDegreesOfAnisotropy(coeffs, &(out_stats->I), &(out_stats->E), NULL); + + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tIsotropy index (I): %0.3f [-].", out_stats->I); + wr_log("\tElongation index (E): %0.3f [-].", out_stats->E); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Anisotropy analysis computed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + // Release resources: + free(rot_theta); + free(rot_phi); + free(mil); + free(coeffs); + + // Return OK: + return P3D_SUCCESS; + +} + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dBasicAnalysis.c b/pypore3d/pypore3d/P3D_Blob/p3dBasicAnalysis.c new file mode 100644 index 0000000000000000000000000000000000000000..6a753a6ab7e6089306b2ddb4d6a9bbaa0d350542 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dBasicAnalysis.c @@ -0,0 +1,323 @@ +#include <omp.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +/* given a 3-dimensional binary image bin_image of size n[0..2], + the image is convolved with a filter mask F and + the grey-tone histogram h[0..255] of the convolved image is returned + */ +void ghist( + unsigned char* im, + double* h, // h = (double *) calloc ( (UCHAR_MAX+1)*sizeof(double) ); + int dimx, + int dimy, + int dimz + ) { + int i, j, k; + int l; + int ct; + + // Convert image to int: + unsigned char* tmp_im = (unsigned char*) malloc(dimx * dimy * dimz * sizeof (unsigned char)); + + #pragma omp parallel for private( ct ) + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + tmp_im [ ct ] = (im [ ct ] == OBJECT) ? 1 : 0; + + // Compute histogram: + for (i = 0; i < (dimx - 1); i++) { + for (j = 0; j < (dimy - 1); j++) { + l = tmp_im[ I(i, j, 0, dimx, dimy) ] + (tmp_im[ I(i + 1, j, 0, dimx, dimy) ] << 1) + + (tmp_im[ I(i, j + 1, 0, dimx, dimy) ] << 2) + (tmp_im[ I(i + 1, j + 1, 0, dimx, dimy) ] << 3); + + for (k = 0; k < (dimz - 1); k++) { + l += (tmp_im[ I(i, j, k + 1, dimx, dimy) ] << 4) + (tmp_im[ I(i + 1, j, k + 1, dimx, dimy) ] << 5) + + (tmp_im[ I(i, j + 1, k + 1, dimx, dimy) ] << 6) + (tmp_im[ I(i + 1, j + 1, k + 1, dimx, dimy) ] << 7); + + h[l] = h[l] + 1.0; + l >>= 4; + } + } + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + +} + +/* returns an estimate of the volume fraction V_V from the vector h[0..255] + of absolute frequencies of neighborhood configurations of a binary image + */ +double volfrac(double *h) { + int l; + double iVol = 0.0; + double iVol1 = 0.0; + + //#pragma omp parallel reduction (+ : iVol, iVol1) + for (l = 0; l <= UCHAR_MAX; l++) { + iVol += h[l]; + if (l == (l | 1)) + iVol1 += h[l]; + } + + return iVol1 / iVol; +} + +/* returns the specific surface area S_V from the gray-tone histogram h[0..255], + the grid spacing Delta[0..2] is input + */ +double specsurf(double* h, double* Delta) { + int kl[13][2] = { + {1, 2}, + {1, 4}, + {1, 16}, + {1, 8}, + {2, 4}, + {1, 32}, + {2, 16}, + {1, 64}, + {4, 16}, + {1, 128}, + {2, 64}, + {4, 32}, + {8, 16} + }; + double c[13] = {0.045778, 0.045778, 0.045778, 0.036981, 0.036981, 0.036981, + 0.036981, 0.036981, 0.036981, 0.035196, 0.035196, 0.035196, + 0.035196}; + double S_V = 0.0; + int l, ny; + double iVol = 0.0; + double r[13]; + + r[0] = Delta[0]; + r[1] = Delta[1]; + r[2] = Delta[2]; + r[3] = r[4] = sqrt(Delta[0] * Delta[0] + Delta[1] * Delta[1]); + r[5] = r[6] = sqrt(Delta[0] * Delta[0] + Delta[2] * Delta[2]); + r[7] = r[8] = sqrt(Delta[1] * Delta[1] + Delta[2] * Delta[2]); + r[9] = r[10] = r[11] = r[12] = sqrt(Delta[0] * Delta[0] + Delta[1] * Delta[1] + Delta[2] * Delta[2]); + + //#pragma omp parallel for private ( ny ) reduction (+ : iVol, S_V) + for (l = 0; l <= UCHAR_MAX; l++) { + iVol += h[l]; + + for (ny = 0; ny < 13; ny++) + S_V += h[l] * c[ny] / r[ny]*((l == (l | kl[ny][0]))*(0 == (l & kl[ny][1])) + +(l == (l | kl[ny][1]))*(0 == (l & kl[ny][0]))); + } + + return 4.0 * S_V / iVol; +} + +/* returns the specific integral of mean curvature M_V from the gray-tone + histogram h[0..255], the grid spacing Delta[0..2] is input + */ +double specimc(double *h, double *Delta) { + int kr[9][4] = { + {1, 2, 4, 8}, + {1, 2, 16, 32}, + {1, 4, 16, 64}, + {1, 2, 64, 128}, + {4, 16, 8, 32}, + {1, 32, 4, 128}, + {2, 8, 16, 64}, + {2, 4, 32, 64}, + {1, 16, 8, 128} + }; + int kt[8][3] = { + {1, 64, 32}, + {2, 16, 128}, + {8, 64, 32}, + {4, 16, 128}, + {2, 4, 128}, + {8, 1, 64}, + {2, 4, 16}, + {8, 1, 32} + }; + double c[13] = {0.045778, 0.045778, 0.045778, 0.036981, 0.036981, 0.036981, + 0.036981, 0.036981, 0.036981, 0.035196, 0.035196, 0.035196, + 0.035196}; + double delta01 = sqrt(Delta[0] * Delta[0] + Delta[1] * Delta[1]); + double delta02 = sqrt(Delta[0] * Delta[0] + Delta[2] * Delta[2]); + double delta12 = sqrt(Delta[1] * Delta[1] + Delta[2] * Delta[2]); + double s = (delta01 + delta02 + delta12) / 2; + double a[13]; + double M_V = 0.0; + int ir, l, ny; + double iVol = 0.0; + + a[0] = Delta[0] * Delta[1]; + a[1] = Delta[0] * Delta[2]; + a[2] = Delta[1] * Delta[2]; + a[3] = a[4] = Delta[2] * delta01; + a[5] = a[6] = Delta[1] * delta02; + a[7] = a[8] = Delta[0] * delta12; + a[9] = a[10] = a[11] = a[12] = 2 * sqrt(s * (s - delta01)*(s - delta02)*(s - delta12)); + + //#pragma omp parallel for private ( ny, ir ) reduction (+ : iVol, M_V) + for (l = 0; l <= UCHAR_MAX; l++) { + iVol += h[l]; + + for (ny = 0; ny < 9; ny++) + for (ir = 0; ir < 4; ir++) + M_V += (double) h[l] * c[ny] / (4.0 * a[ny]) + *((l == (l | kr[ny][ir]))*(0 == (l & kr[ny][(ir + 1) % 4])) + *(0 == (l & kr[ny][(ir + 2) % 4]))*(0 == (l & kr[ny][(ir + 3) % 4])) + -(l == (l | kr[ny][ir]))*(l == (l | kr[ny][(ir + 1) % 4])) + *(l == (l | kr[ny][(ir + 2) % 4]))*(0 == (l & kr[ny][(ir + 3) % 4]))); + + for (ny = 9; ny < 13; ny++) + for (ir = 0; ir < 3; ir++) + M_V += (double) h[l] * c[ny] / (3.0 * a[ny]) + *((l == (l | kt[ny - 9][ir]))*(0 == (l & kt[ny - 9][(ir + 1) % 3])) + *(0 == (l & kt[ny - 9][(ir + 2) % 3])) + -(l == (l | kt[ny - 5][ir]))*(l == (l | kt[ny - 5][(ir + 1) % 3])) + *(0 == (l & kt[ny - 5][(ir + 2) % 3]))); + } + + return 4.0 * M_PI * M_V / iVol; +} + +/* returns the specific Euler Characteristic C_V from the vector h[0..255] + of absolute freqencies, the lattice distances Delta[0..2] are input + */ +double euler(double *h, double *Delta) { + int l; + double iChi = 0.0; + double iVol = 0.0; + + int iu[256] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0.. 15 + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, // 16.. 31 + 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, // 32.. 47 + 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, // 48.. 63 + 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, // 64.. 79 + 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, // 80.. 95 + -1, 0, -1, 0, -1, 0, 0, 0, -2, 0, -1, 0, -1, 0, 0, 0, // 96..111 + 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, // 112..127 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 128..143 + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, // 144..159 + 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, // 160..175 + 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, // 176..191 + 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, // 192..207 + 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, // 208..223 + -1, 0, -1, 0, -1, 0, 0, 0, -2, 0, -1, 0, -1, 0, 0, 0, // 224..239 + 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0 // 240..255 + }; + + //#pragma omp parallel for reduction (+ : iChi, iVol) + for (l = 0; l <= UCHAR_MAX; l++) { + iChi += iu[l] * h[l]; + iVol += h[l]; + } + + return iChi / (iVol * Delta[0] * Delta[1] * Delta[2]); +} + +/* returns the specific integral of total curvature K_V from the vector h[0..255] +of absolute freqencies, the lattice distances Delta[0..2] are input*/ +double euler_plus(double *h, double *Delta) { + int l; + double iChi = 0.0; + double iVol = 0.0; + + int iv[256] = {0, 3, 3, 0, 3, 0, -6, -3, 3, -6, 0, -3, 0, -3, -3, 0, // 0.. 15 + 3, 0, -6, -3, -6, -3, -3, -6, -12, -8, -8, -6, -8, -6, 0, -3, // 16.. 31 + 3, -6, 0, -3, -12, -8, -8, -6, -6, -3, -3, -6, -8, 0, -6, -3, // 32.. 47 + 0, -3, -3, 0, -8, -6, 0, -3, -8, 0, -6, -3, 0, 3, 3, 0, // 48.. 63 + 3, -6, -12, -8, 0, -3, -8, -6, -6, -3, -8, 0, -3, -6, -6, -3, // 64.. 79 + 0, -3, -8, -6, -3, 0, 0, -3, -8, 0, 0, 3, -6, -3, 3, 0, // 80.. 95 + -6, -3, -8, 0, -8, 0, 0, 3, -3, 12, 0, 9, 0, 9, 3, 6, // 96..111 + -3, -6, -6, -3, -6, -3, 3, 0, 0, 9, 3, 6, 3, 6, 6, 3, // 112..127 + 3, -12, -6, -8, -6, -8, -3, 0, 0, -8, -3, -6, -3, -6, -6, -3, // 128..143 + -6, -8, -3, 0, -3, 0, 12, 9, -8, 0, 0, 3, 0, 3, 9, 6, // 144..159 + 0, -8, -3, -6, -8, 0, 0, 3, -3, 0, 0, -3, -6, 3, -3, 0, // 160..175 + -3, -6, -6, -3, 0, 3, 9, 6, -6, 3, -3, 0, 3, 6, 6, 3, // 176..191 + 0, -8, -8, 0, -3, -6, 0, 3, -3, 0, -6, 3, 0, -3, -3, 0, // 192..207 + -3, -6, 0, 3, -6, -3, 9, 6, -6, 3, 3, 6, -3, 0, 6, 3, // 208..223 + -3, 0, -6, 3, -6, 3, 3, 6, -6, 9, -3, 6, -3, 6, 0, 3, // 224..239 + 0, -3, -3, 0, -3, 0, 6, 3, -3, 6, 0, 3, 0, 3, 3, 0 // 240..255 + }; + + for (l = 0; l <= UCHAR_MAX; l++) { + iChi += iv[l] * h[l]; + iVol += h[l]; + } + + return M_PI / 6 * iChi / (iVol * Delta[0] * Delta[1] * Delta[2]); +} + +int p3dBasicAnalysis( + unsigned char* in_im, // IN: Input segmented (binary) volume + BasicStats* out_stats, // OUT: Basic characteristics + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, // IN: voxel resolution + int (*wr_log)(const char*, ...) + ) +{ + + // Allocate memory for temporary variables: + double* h = (double *) calloc((UCHAR_MAX + 1), sizeof (double)); + double* delta = (double *) malloc(3 * sizeof (double)); + delta[0] = voxelsize; + delta[1] = voxelsize; + delta[2] = voxelsize; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing basic analysis..."); + wr_log("\tAdopted voxelsize: %0.6f mm.", voxelsize); + } + + + // Compute histogram: + ghist(in_im, h, dimx, dimy, dimz); + + // Compute density: + out_stats->Vv = volfrac(h); + + // Compute specific surface volume: + out_stats->Sv = specsurf(h, delta); + + // Compute the specific integral of mean curvature: + out_stats->Mv = specimc(h, delta); + + // Compute the euler characteristic (related to specific + // integral of total curvature): + out_stats->Cv = euler(h, delta); + + + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tDensity (Vv): %0.3f [-].", out_stats->Vv); + wr_log("\tSpecific Surface Area (Sv): %0.3f [mm^-1].", out_stats->Sv); + wr_log("\tIntegral of Mean Curvature (Mv): %0.3f [mm^-2].", out_stats->Mv); + wr_log("\tEuler characteristic (Cv): %0.3f [mm^-3].", out_stats->Cv); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Basic analysis computed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (h != NULL) free(h); + if (delta != NULL) free(delta); + + // Return OK: + return P3D_SUCCESS; + +} diff --git a/pypore3d/pypore3d/P3D_Blob/p3dBlob.def b/pypore3d/pypore3d/P3D_Blob/p3dBlob.def new file mode 100644 index 0000000000000000000000000000000000000000..4ac7620bef92edc35e4ca2095796036f263f65a7 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dBlob.def @@ -0,0 +1,24 @@ +LIBRARY P3DBLOB +EXPORTS + p3dAnisotropyAnalysis @1 + p3dBasicAnalysis @2 + p3dBlobAnalysis @3 + p3dBlobLabeling_ushort @4 + p3dBlobLabeling_uint @5 + + p3dChamferDT @6 + + p3dGetMaxVolumeBlob3D @7 + p3dGetMinVolumeBlob3D @8 + + p3dMinVolumeFilter3D @9 + + p3dMorphometricAnalysis @10 + p3dREVEstimation @11 + + p3dSquaredEuclideanDT @12 + p3dTextureAnalysis @13 + + + + \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/p3dBlob.h b/pypore3d/pypore3d/P3D_Blob/p3dBlob.h new file mode 100644 index 0000000000000000000000000000000000000000..c14d749f626db0fe1fd9cc7acd29e97a503f06a6 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dBlob.h @@ -0,0 +1,243 @@ +#ifdef __cplusplus +extern "C" { +#endif + + + /* + Constants: + */ +#ifndef P3D_BLOB_DEFINED +#define P3D_BLOB_DEFINED + +#define P3D_FALSE -1 +#define P3D_TRUE 1 + +#define P3D_ERROR 0 +#define P3D_MEM_ERROR NULL /* Leave it NULL to simplify tests */ +#define P3D_SUCCESS 2 /* Any number */ + +#define BACKGROUND 0 +#define OBJECT UCHAR_MAX + +#define CONN4 611 +#define CONN8 612 + + // Constants for 3D connectivity: +#define CONN6 711 +#define CONN18 712 +#define CONN26 713 + +#endif + + /* + Macros: + */ + +#ifndef P3D_BLOB_MACROS +#define P3D_BLOB_MACROS + + #define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) + #define MIN(x,y) (((x) < (y))?(x):(y)) + #define MAX(x,y) (((x) > (y))?(x):(y)) + + /* A sort of TRY-CATCH constructor: */ + #define P3D_MEM_TRY( function ) if ( ((function) == P3D_MEM_ERROR) ) { goto MEM_ERROR; } + #define P3D_TRY( function ) if ( ((function) == P3D_ERROR) ) { goto MEM_ERROR; } +#endif + +#ifndef P3D_BLOB_STRUCTS_DEFINED +#define P3D_BLOB_STRUCTS_DEFINED + + // Struct for results of connected components analysis: + + typedef struct { + double* aspect_ratio; + unsigned int blobCount; + double* max_sph; + double* eq_sph; + double* l_min; + double* l_max; + double* sphericity; + double* extent; + double* volume; + } BlobStats; + + typedef struct { + double BvTv; + double BsBv; + double TbN; + double TbTh; + double TbSp; + } MorphometricStats; + + typedef struct { + double I; // Isotropy Index; + double E; // Elongation Index; + } AnisotropyStats; + + typedef struct { + double Vv; + double Cv; + double Mv; + double Sv; + } BasicStats; + + typedef struct { + double FD; + } TextureStats; + +#endif + + int p3dBlobAnalysis( + unsigned char* in_im, + BlobStats* out_stats, + unsigned char* blob_im, // OUT: Balls image + unsigned char* star_im, // OUT: Balls image + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, // IN: spatial resolution + const int conn, + const int max_rot, + const int skip_borders, + int (*wr_log)(const char*, ...) + ); + + int p3dBasicAnalysis( + unsigned char* in_im, + BasicStats* out_stats, + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, + int (*wr_log)(const char*, ...) + ); + + int p3dTextureAnalysis( + unsigned char* in_im, + TextureStats* out_stats, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ); + + int p3dAnisotropyAnalysis( + unsigned char* in_im, + unsigned char* msk_im, + AnisotropyStats* out_stats, + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, + const int verbose, + int (*wr_log)(const char*, ...) + ); + + int p3dMorphometricAnalysis( + unsigned char* in_im, // IN: Input segmented (binary) volume + unsigned char* msk_im, + MorphometricStats* out_stats, // OUT: Trabecular statistics + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, // IN: voxel resolution + int (*wr_log)(const char*, ...) + ); + + int p3dREVEstimation( + unsigned char* in_rev, // IN: binary volume + double** porosity, // OUT: array of porosity for the related cube side + unsigned int** cubeEdges, // OUT: array of length of the side of the REV cube + unsigned int* numel, // OUT: length of the arrays + const int dimx, + const int dimy, + const int dimz, + const int stepsize, // IN: stepsize for porosity + const int centerx, // IN: X coordinate for the center of REV (-1 for + // automatic determination of the center) + const int centery, // IN: Y coordinate for the center of REV + const int centerz, // IN: Z coordinate for the center of REV + int (*wr_log)(const char*, ...) + ); + + int p3dChamferDT( + unsigned char* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int w1, + const int w2, + const int w3, + int (*wr_log)(const char*, ...) + ); + + int p3dBlobLabeling_ushort( + unsigned char* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, // Flag for random labels + const int skip_borders, + int (*wr_log)(const char*, ...) + ); + + int p3dBlobLabeling_uint( + unsigned char* in_im, + unsigned int* out_im, + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, // Flag for random labels + const int skip_borders, + int (*wr_log)(const char*, ...) + ); + + + int p3dGetMaxVolumeBlob3D( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + int conn, + int (*wr_log)(const char*, ...) + ); + + int p3dGetMinVolumeBlob3D( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + int conn, + int (*wr_log)(const char*, ...) + ); + + int p3dMinVolumeFilter3D( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int min_volume, + int conn, + int (*wr_log)(const char*, ...) + ); + + int p3dSquaredEuclideanDT( + unsigned char* in_rev, + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Blob/p3dBlobAnalysis.c b/pypore3d/pypore3d/P3D_Blob/p3dBlobAnalysis.c new file mode 100644 index 0000000000000000000000000000000000000000..c2018e920c0b32877edb911f5271101fbe3a8d1c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dBlobAnalysis.c @@ -0,0 +1,764 @@ +#include <omp.h> + + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <time.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#include "Common/p3dBoundingBoxList.h" +#include "Common/p3dConnectedComponentsLabeling.h" +#include "Common/p3dUtils.h" + +void _drawline(unsigned char* in_im, + unsigned int* lbl_im, + unsigned int curr_lbl, + unsigned char* out_im, + const double theta, const double phi, + const int cen_i, const int cen_j, const int cen_k, + const int dimx, const int dimy, const int dimz, + unsigned char lbl) { + // Indexes for volume scanning: + double x, y, z; + double prec_x, prec_y, prec_z; + + double end_x1, end_y1, end_z1; + double end_x2, end_y2, end_z2; + + + unsigned char prec_status, curr_status; + + // Test line direction vectors: + double r_0, r_1, r_2; + double normr_0, normr_1, normr_2; + + /*fprintf(stderr, "rot_theta[ct_rot]: %0.5f\n", rot_theta[ct_rot]); + fprintf(stderr, "rot_phi[ct_rot]: %0.5f\n", rot_phi[ct_rot]);*/ + + // Define direction vector (versor): + r_0 = cos(phi) * sin(theta); + r_1 = sin(phi) * sin(theta); + r_2 = cos(theta); + + // Normalize direction vector to +1 for the maximum component, + // doing so we can save iteration on next cycle: + if ((fabs(r_0) >= fabs(r_1)) && (fabs(r_0) >= fabs(r_2))) { + normr_0 = 1.0; + normr_1 = r_1 / r_0; + normr_2 = r_2 / r_0; + } else if ((fabs(r_1) >= fabs(r_0)) && (fabs(r_1) >= fabs(r_2))) { + normr_1 = 1.0; + normr_0 = r_0 / r_1; + normr_2 = r_2 / r_1; + } else { + normr_2 = 1.0; + normr_0 = r_0 / r_2; + normr_1 = r_1 / r_2; + } + + // Make sure signs are correct: + normr_0 = (r_0 > 0) ? fabs(normr_0) : (-fabs(normr_0)); + normr_1 = (r_1 > 0) ? fabs(normr_1) : (-fabs(normr_1)); + normr_2 = (r_2 > 0) ? fabs(normr_2) : (-fabs(normr_2)); + + + x = cen_i; + y = cen_j; + z = cen_k; + + // Reset status: + prec_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the incremental and decremental sides while edges of + // VOI are reached: + + // Explore the incremental and decremental sides while edges of + // mask are reached of image edges are reached: + + // Explore the incremental versus while edges of VOI are reached: + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz) && + (lbl_im[ I((int) x, (int) y, (int) z, dimx, dimy) ] == curr_lbl) + ) { + out_im[ I((int) x, (int) y, (int) z, dimx, dimy)] = lbl; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the background save coords: + if (curr_status != prec_status) { + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x + normr_0; + y = y + normr_1; + z = z + normr_2; + } + + // Get end point of the test line: + end_x1 = prec_x; + end_y1 = prec_y; + end_z1 = prec_z; + + // Reset "center" of the line: + x = cen_i; + y = cen_j; + z = cen_k; + + // Reset status: + prec_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the decremental versus while edges of VOI are reached: + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz) && + (lbl_im[ I((int) x, (int) y, (int) z, dimx, dimy) ] == curr_lbl) + ) { + + out_im[ I((int) x, (int) y, (int) z, dimx, dimy)] = lbl; + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x - normr_0; + y = y - normr_1; + z = z - normr_2; + } + + // Get the other end point of the test line: + end_x2 = prec_x; + end_y2 = prec_y; + end_z2 = prec_z; + +} + +int p3dBlobAnalysis( + unsigned char* in_im, // IN: Input segmented (binary) volume + BlobStats* out_stats, // OUT: Statistics + unsigned char* blob_im, // OUT: Balls image + unsigned char* star_im, // OUT: Balls image + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, // IN: spatial resolution + const int conn, + const int max_rot, + const int skip_borders, + int (*wr_log)(const char*, ...) + ) { + + unsigned int* dt_im; + unsigned int* lbl_im; + int i, j, k; + int a, b, c; + int dist_x, dist_y, dist_z; + int delta; + unsigned int ct; + int rad; + int max_i, max_j, max_k; + double cen_i, cen_j, cen_k, cen_ct; + bb_t curr_bb; + + double* v_length = NULL; + double* rot_theta = NULL; + double* rot_phi = NULL; + + int free_flag = P3D_FALSE; + unsigned int num_el; + unsigned int curr_lbl; + unsigned int max_sph = 0; + int ct_rot; + unsigned int* volumes; + bb_t* bbs; + + double mean, mean_sq; + double bb_vol; + double l_min, l_max; + int min_idx, max_idx; + + // Indexes for volume scanning: + double x, y, z; + double prec_x, prec_y, prec_z; + + double end_x1, end_y1, end_z1; + double end_x2, end_y2, end_z2; + + + // Test line direction vectors: + double r_0, r_1, r_2; + double normr_0, normr_1, normr_2; + + // Variables for length management: + double length; + + + unsigned char prec_status, curr_status; + unsigned int iseed; + time_t t; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing blob analysis..."); + wr_log("\tAdopted voxelsize: %0.6f mm.", voxelsize); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + if (skip_borders == P3D_TRUE) + wr_log("\tBorders skipped. "); + wr_log("\tNumber of random orientations: %d.", max_rot); + } + + // Get distance transform and allocate memory for related image: + P3D_MEM_TRY(dt_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); + p3dSquaredEuclideanDT(in_im, dt_im, dimx, dimy, dimz, NULL); + + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tDistance transform successfully computed."); + } + + // Get connected components labeled image and allocate memory for related image: + P3D_MEM_TRY(lbl_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); + P3D_TRY(p3dConnectedComponentsLabeling_uint(in_im, lbl_im, &num_el, &volumes, &bbs, + dimx, dimy, dimz, conn, P3D_FALSE, skip_borders)); + + if (blob_im == NULL) { + free_flag = P3D_TRUE; + P3D_MEM_TRY(blob_im = (unsigned char*) calloc(dimx * dimy * dimz, sizeof (unsigned char))); + } + + if (wr_log != NULL) { + wr_log("\tBlob labeling successfully performed."); + } + + + // Allocate memory for output stats: + out_stats->blobCount = num_el; + + if (num_el > 0) { + out_stats->volume = (double*) malloc(num_el * sizeof (double)); + out_stats->aspect_ratio = (double*) malloc(num_el * sizeof (double)); + out_stats->extent = (double*) malloc(num_el * sizeof (double)); + out_stats->eq_sph = (double*) malloc(num_el * sizeof (double)); + out_stats->max_sph = (double*) malloc(num_el * sizeof (double)); + out_stats->l_min = (double*) malloc(num_el * sizeof (double)); + out_stats->l_max = (double*) malloc(num_el * sizeof (double)); + out_stats->sphericity = (double*) malloc(num_el * sizeof (double)); + + rot_theta = (double*) malloc(max_rot * sizeof (double)); + rot_phi = (double*) malloc(max_rot * sizeof (double)); + v_length = (double*) malloc(max_rot * sizeof (double)); + + } else { + out_stats->volume = NULL; + out_stats->aspect_ratio = NULL; + out_stats->extent = NULL; + out_stats->eq_sph = NULL; + out_stats->max_sph = NULL; + out_stats->l_min = NULL; + out_stats->l_max = NULL; + out_stats->sphericity = NULL; + } + + + + // Scanning volume determining values for further use in stats computing: + //#pragma omp parallel for private ( curr_bb, curr_lbl, max_sph, i, j, k, a, b, c, dist_x, dist_y, dist_z, dist_min, dist_max, max_i, max_j, max_k, rad, delta ) + for (ct = (unsigned int) 0; ct < num_el; ct = (unsigned int) (ct+1)) { + // Get bounding box: + curr_bb.min_x = bbs[ct].min_x; + curr_bb.max_x = bbs[ct].max_x; + curr_bb.min_y = bbs[ct].min_y; + curr_bb.max_y = bbs[ct].max_y; + curr_bb.min_z = bbs[ct].min_z; + curr_bb.max_z = bbs[ct].max_z; + + // Compute distances in three directions: + dist_x = curr_bb.max_x - curr_bb.min_x + 1; + dist_y = curr_bb.max_y - curr_bb.min_y + 1; + dist_z = curr_bb.max_z - curr_bb.min_z + 1; + + + // Set current label: + curr_lbl = (unsigned int) (ct + 3); + + // Init counters: + max_sph = 0; + + /// + /// Apply the "star" algorithm in order to get the minimum + /// and maximum axis length: + /// + + // Scan bounding box to first get the baricenter: + cen_i = 0.0; + cen_j = 0.0; + cen_k = 0.0; + cen_ct = 0.0; + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (lbl_im[ I(i, j, k, dimx, dimy) ] == curr_lbl) { + // Compute the center of mass: + cen_i = cen_i + (double) i; + cen_j = cen_j + (double) j; + cen_k = cen_k + (double) k; + cen_ct = cen_ct + 1.0; + } + } + + cen_i = cen_i / cen_ct; + cen_j = cen_j / cen_ct; + cen_k = cen_k / cen_ct; + + // --------------------------------------------------------------- + + // Now apply the "star" algorithm: + iseed = (unsigned int) time(&t); + srand(iseed); + + // For each of the max_rot direction computed: + for (ct_rot = 0; ct_rot < max_rot; ct_rot++) + { + rot_theta[ct_rot] = (rand() / ((double) RAND_MAX + 1)) * M_PI; + rot_phi[ct_rot] = (rand() / ((double) RAND_MAX + 1)) * M_PI; + + /*fprintf(stderr, "rot_theta[ct_rot]: %0.5f\n", rot_theta[ct_rot]); + fprintf(stderr, "rot_phi[ct_rot]: %0.5f\n", rot_phi[ct_rot]);*/ + + // Define direction vector (versor): + r_0 = cos(rot_phi[ct_rot]) * sin(rot_theta[ct_rot]); + r_1 = sin(rot_phi[ct_rot]) * sin(rot_theta[ct_rot]); + r_2 = cos(rot_theta[ct_rot]); + + // Normalize direction vector to +1 for the maximum component, + // doing so we can save iteration on next cycle: + if ((fabs(r_0) >= fabs(r_1)) && (fabs(r_0) >= fabs(r_2))) { + normr_0 = 1.0; + normr_1 = r_1 / r_0; + normr_2 = r_2 / r_0; + } else if ((fabs(r_1) >= fabs(r_0)) && (fabs(r_1) >= fabs(r_2))) { + normr_1 = 1.0; + normr_0 = r_0 / r_1; + normr_2 = r_2 / r_1; + } else { + normr_2 = 1.0; + normr_0 = r_0 / r_2; + normr_1 = r_1 / r_2; + } + + // Make sure signs are correct: + normr_0 = (r_0 > 0) ? fabs(normr_0) : (-fabs(normr_0)); + normr_1 = (r_1 > 0) ? fabs(normr_1) : (-fabs(normr_1)); + normr_2 = (r_2 > 0) ? fabs(normr_2) : (-fabs(normr_2)); + + x = cen_i; + y = cen_j; + z = cen_k; + + + // Reset status: + prec_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; + curr_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the incremental and decremental sides while edges of + // VOI are reached: + + // Explore the incremental and decremental sides while edges of + // mask are reached of image edges are reached: + + // Explore the incremental versus while edges of VOI are reached: + while ( (((int) (x + 0.5)) >= 0) && (((int) (x + 0.5)) < dimx) && + (((int) (y + 0.5)) >= 0) && (((int) (y + 0.5)) < dimy) && + (((int) (z + 0.5)) >= 0) && (((int) (z + 0.5)) < dimz) && + (lbl_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ] == curr_lbl) + ) { + curr_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; + + // If we reach the background save coords: + if (curr_status != prec_status) { + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x + normr_0; + y = y + normr_1; + z = z + normr_2; + } + + // Get end point of the test line: + end_x1 = prec_x; + end_y1 = prec_y; + end_z1 = prec_z; + + // Reset "center" of the line: + x = cen_i; + y = cen_j; + z = cen_k; + + // Reset status: + prec_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; + curr_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; + + // Init variables: + prec_x = x; + prec_y = y; + prec_z = z; + + // Explore the decremental versus while edges of VOI are reached: + while ( (((int) (x + 0.5)) >= 0) && (((int) (x + 0.5)) < dimx) && + (((int) (y + 0.5)) >= 0) && (((int) (y + 0.5)) < dimy) && + (((int) (z + 0.5)) >= 0) && (((int) (z + 0.5)) < dimz) && + (lbl_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ] == curr_lbl) + ) { + curr_status = in_im[ I((int) (x + 0.5), (int) (y + 0.5), (int) (z + 0.5), dimx, dimy) ]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + prec_status = curr_status; + } + + prec_x = x; + prec_y = y; + prec_z = z; + + x = x - normr_0; + y = y - normr_1; + z = z - normr_2; + } + + // Get the other end point of the test line: + end_x2 = prec_x; + end_y2 = prec_y; + end_z2 = prec_z; + + //} + + // Get distance: + length = (end_x1 - end_x2)*(end_x1 - end_x2) + + (end_y1 - end_y2)*(end_y1 - end_y2) + + (end_z1 - end_z2)*(end_z1 - end_z2); + length = sqrt(length) + 1.0; + + // Add current length to array for this grid: + v_length[ct_rot] = length*voxelsize; + } + + // ------------------------------------------------------------ + + // Extract minimum and maximum length from the array + // of all the considered lengths: + l_max = 0.0; + max_idx = 0; + l_min = (double) (UINT_MAX); + min_idx = 0; + for (i = 0; i < max_rot; i++) { + if (v_length[i] > l_max) { + l_max = v_length[i]; + max_idx = i; + } + if (v_length[i] < l_min) { + l_min = v_length[i]; + min_idx = i; + } + } + + out_stats->l_max[ct] = l_max; + out_stats->l_min[ct] = l_min; + + // Draw the axis lines (if required): + if (star_im != NULL) { + // Draw minor axis with label 2: + _drawline(in_im, lbl_im, curr_lbl, star_im, rot_theta[min_idx], rot_phi[min_idx], + (int) cen_i, (int) cen_j, (int) cen_k, dimx, dimy, dimz, 2); + // Draw major axis with label 3: + _drawline(in_im, lbl_im, curr_lbl, star_im, rot_theta[max_idx], rot_phi[max_idx], + (int) cen_i, (int) cen_j, (int) cen_k, dimx, dimy, dimz, 3); + // Draw center of mass with label 1: + star_im[ I( (int) cen_i, (int) cen_j, (int) cen_k, dimx, dimy) ] = 1; + } + + /// + /// Maximal sphere part: + /// + + // Scan bounding box: + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) { + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) { + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (lbl_im[ I(i, j, k, dimx, dimy) ] == curr_lbl) { + // Compute maximum inscribed sphere: + if (dt_im[ I(i, j, k, dimx, dimy) ] > max_sph) { + max_sph = dt_im[ I(i, j, k, dimx, dimy) ]; + + max_i = i; + max_j = j; + max_k = k; + } + } + } + } + } + + // Get the radius: + rad = (int) (sqrt((double) max_sph)); + + // Fill the ball (if required as output): + if (free_flag == P3D_FALSE) { + for (c = (max_k - rad); c <= (max_k + rad); c++) + for (b = (max_j - rad); b <= (max_j + rad); b++) + for (a = (max_i - rad); a <= (max_i + rad); a++) { + // We are scanning the bounding box, so we need to be sure + // if current position (a,b,c) is inside the ball: + delta = ((a - max_i)*(a - max_i) + (b - max_j)*(b - max_j) + + (c - max_k)*(c - max_k)); + + if ((a >= 0) && (b >= 0) && (c >= 0) && + (a < dimx) && (b < dimy) && (c < dimz) && + (delta <= (rad * rad))) { + blob_im [ I(a, b, c, dimx, dimy) ] = OBJECT; + } + } + } + + //printf("ct: %d - i: %d - j: %d - k: %d - rad: %d\n",ct,max_i,max_j,max_k,rad); + + // Set ouput parameters: + + + /// + /// Volume: + /// + out_stats->volume[ct] = volumes[ct]*(voxelsize * voxelsize * voxelsize); + + // Aspect ratio (avoiding division by zero): + if (out_stats->l_max[ct] != 0) { + out_stats->aspect_ratio[ct] = out_stats->l_min[ct] / ((double) out_stats->l_max[ct]); + } else { + out_stats->aspect_ratio[ct] = 0; + } + + /// + /// Diameter of the maximum inscribed sphere: + /// + if (max_sph != 0) { + out_stats->max_sph[ct] = 2.0 * sqrt((double) max_sph) * voxelsize; + } else { + out_stats->max_sph[ct] = 0.0; + } + + /// + /// Equivalent diameter, i.e. the diameter of a sphere with + /// the same volume as the blob, computed exploiting the + /// inverse formula of the volume of a sphere: + /// + out_stats->eq_sph[ct] = 2 * pow((3.0 * out_stats->volume[ct] ) / (4.0 * M_PI), 1 / 3.0); + + /// + /// Sphericity: + /// + out_stats->sphericity[ct] = out_stats->max_sph[ct] / out_stats->eq_sph[ct]; + + /// + /// Extent parameter, i.e. the ratio between the volume of the + /// blob and the volume of the minimum bounding box (the + /// smallest parallelepiped oriented according to image axis + /// containing the blob). + /// + bb_vol = ((double) dist_x) * ((double) dist_y) * ((double) dist_z); + if (bb_vol > 0) + out_stats->extent[ct] = volumes[ct] / bb_vol; + else + out_stats->extent[ct] = 0.0; + + + } + + // Print out number of connected components and mean values of parameters: + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tNumber of identified blobs: %d. ", out_stats->blobCount); + + if (num_el > 0) { + // Compute mean +/- std values of volume: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->volume[ct]); + mean_sq += (double) (out_stats->volume[ct] * out_stats->volume[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tVolumes: %0.3f +/- %0.3f [mm^3].", mean, sqrt(mean_sq)); + + // Compute mean +/- std values of l_min: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->l_min[ct]); + mean_sq += (double) (out_stats->l_min[ct] * out_stats->l_min[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tMinor axis length: %0.3f +/- %0.3f [mm].", mean, sqrt(mean_sq)); + + // Compute mean +/- std values of l_max: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->l_max[ct]); + mean_sq += (double) (out_stats->l_max[ct] * out_stats->l_max[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tMajor axis length: %0.3f +/- %0.3f [mm].", mean, sqrt(mean_sq)); + + // Compute mean +/- std values of aspect ratio: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->aspect_ratio[ct]); + mean_sq += (double) (out_stats->aspect_ratio[ct] * out_stats->aspect_ratio[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tAspect ratio: %0.3f +/- %0.3f [-].", mean, sqrt(mean_sq)); + + // Compute mean +/- std values of d_max: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->max_sph[ct]); + mean_sq += (double) (out_stats->max_sph[ct] * out_stats->max_sph[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tDiameter of maximal inscribed sphere: %0.3f +/- %0.3f [mm].", mean, sqrt(mean_sq)); + + // Compute mean +/- std values of d_eq: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->eq_sph[ct]); + mean_sq += (double) (out_stats->eq_sph[ct] * out_stats->eq_sph[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tDiameter of equivalent sphere: %0.3f +/- %0.3f [mm].", mean, mean_sq); + + // Compute mean +/- std values of sphericity: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->sphericity[ct]); + mean_sq += (double) (out_stats->sphericity[ct] * out_stats->sphericity[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tSphericity: %0.3f +/- %0.3f [-].", mean, sqrt(mean_sq)); + + // Compute mean +/- std values of extent: + mean = 0.0; + mean_sq = 0.0; + for (ct = (unsigned int) 0; ct < out_stats->blobCount; ct = (unsigned int) (ct + 1)) { + mean += (double) (out_stats->extent[ct]); + mean_sq += (double) (out_stats->extent[ct] * out_stats->extent[ct]); + } + mean = mean / ((double) (out_stats->blobCount)); + mean_sq = mean_sq / ((double) (out_stats->blobCount)) - mean*mean; + + wr_log("\tExtent: %0.3f +/- %0.3f [-].", mean, sqrt(mean_sq)); + } + } + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Blob analysis performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (free_flag == P3D_TRUE) free(blob_im); + if (dt_im != NULL) free(dt_im); + if (lbl_im != NULL) free(lbl_im); + if (volumes != NULL) free(volumes); + if (bbs != NULL) free(bbs); + + if (rot_theta != NULL) free(rot_theta); + if (rot_phi != NULL) free(rot_phi); + if (v_length != NULL) free(v_length); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory or maximum number of blobs reached. Program will exit."); + } + + // Release resources: + if (free_flag == P3D_TRUE) free(blob_im); + if (dt_im != NULL) free(dt_im); + if (lbl_im != NULL) free(lbl_im); + if (volumes != NULL) free(volumes); + if (bbs != NULL) free(bbs); + + if (rot_theta != NULL) free(rot_theta); + if (rot_phi != NULL) free(rot_phi); + if (v_length != NULL) free(v_length); + + // Return OK: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Blob/p3dBlobLabeling.c b/pypore3d/pypore3d/P3D_Blob/p3dBlobLabeling.c new file mode 100644 index 0000000000000000000000000000000000000000..1f4e6e723f0174bc3bcbf75f1251697342e0ab05 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dBlobLabeling.c @@ -0,0 +1,117 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#include "Common/p3dConnectedComponentsLabeling.h" +#include "Common/p3dUtils.h" + +// Wrapper for the extern: + +int p3dBlobLabeling_ushort( + unsigned char* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, // Flag for random labels + const int skip_borders, + int (*wr_log)(const char*, ...) + ) { + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing blob labeling..."); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + if (random_lbl == P3D_TRUE) + wr_log("\tRandom labels used. "); + if (skip_borders == P3D_TRUE) + wr_log("\tBorders skipped. "); + } + + + P3D_TRY( p3dConnectedComponentsLabeling_ushort(in_im, out_im, NULL, NULL, NULL, dimx, dimy, dimz, + conn, random_lbl, skip_borders)); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Blob labeling performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Return OK: + return P3D_ERROR; +} + +int p3dBlobLabeling_uint( + unsigned char* in_im, + unsigned int* out_im, + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int random_lbl, // Flag for random labels + const int skip_borders, + int (*wr_log)(const char*, ...) + ) { + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing blob labeling..."); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + if (random_lbl == P3D_TRUE) + wr_log("\tRandom labels used. "); + if (skip_borders == P3D_TRUE) + wr_log("\tBorders skipped. "); + } + + + P3D_TRY( p3dConnectedComponentsLabeling_uint(in_im, out_im, NULL, NULL, NULL, dimx, dimy, dimz, + conn, random_lbl, skip_borders) ); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Blob labeling performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Return OK: + return P3D_ERROR; + +} + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dChamferDT.c b/pypore3d/pypore3d/P3D_Blob/p3dChamferDT.c new file mode 100644 index 0000000000000000000000000000000000000000..e42487bac2ef93602e2e941e41446dc393ee64db --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dChamferDT.c @@ -0,0 +1,480 @@ +/* + * p3dChamferDistanceTransform + * + * Computes the Chamfer distance transform of the input volume. For each + * non-zero voxel in input image, the distance transform assigns a number + * that is the distance between that voxel and the nearest zero pixel + * (background). The Chamfer distance transform is an integer approximation + * for the Euclidean distance metric. + * + * Remarks + * ------- + * Current implementation uses <1,1,1> weights. See [1] for details. + * Computational cost is O(N^3) for a NxNxN input volume. Memory + * requirement is two extra volumes of a NxNxN, i.e. O(N^3). Current + * implementation uses unsigned short elements (see compiler specifications). + * + * References + * ---------- + * [1] Gunilla Borgefors. "On Digital Distance Transforms in Three Dimensions", + * Computer Vision and Image Understanding, Vol. 64, No. 3, pp. 368-376, 1996. + * + +/****/ +/* Separare i tre casi "cityblock", "chessboard" e "euclidean". C'e da usare + la connettivit� 6 per cityblock riscrivendo le funzioni in modo da tenere + conto solo della connettivit� 6. + */ +/***/ + + +/* + * Copyright 2008, SYRMEP Group - Sincrotrone Trieste S.C.p.A. + * + * Author: Brun Francesco + * Version: 1.0 + * Date: 19 june 2008 + * + */ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + + +#define INF USHRT_MAX // infinity + +unsigned short minOfPrevious13( + unsigned char* in_rev, + unsigned short* out_rev, + unsigned short* weights, + const int x, + const int y, + const int z, + const int dimx, + const int dimy, + const int dimz + ) { + int a, b, c; + + // Temporary values: + unsigned short tmp, min; + + // Initialize current minimum: + min = INF; + + + // Computes the sums of the values of the 13 already visited + // neighbors (in direct order) and the corresponding local + // distances: + + // From 0 to 8: + c = z - 1; + for (b = (y - 1); b <= (y + 1); b++) + for (a = (x - 1); a <= (x + 1); a++) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + // From 9 to 11: + c = z; + b = y - 1; + for (a = (x - 1); a <= (x + 1); a++) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + // The 12th: + c = z; + b = y; + a = x - 1; + + + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + + // Return the minimum of the 13 sums: + return min; +} + +unsigned short minOfPrevious14( + unsigned short* out_rev, + unsigned short* weights, + const int x, + const int y, + const int z, + const int dimx, + const int dimy, + const int dimz + ) { + int a, b, c; + + // Temporary values: + unsigned short tmp, min; + + + // Initialize current minimum: + min = out_rev[ I(x, y, z, dimx, dimy) ]; + + // Computes the sums of the values of the 14 already visited + // neighbors (in reverse order plus the center voxel) and the + // corresponding local distances: + + // From 0 to 8: + c = z + 1; + for (b = (y + 1); b >= (y - 1); b--) + for (a = (x + 1); a >= (x - 1); a--) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + // From 9 to 11: + c = z; + b = y + 1; + for (a = (x + 1); a >= (x - 1); a--) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + + if (tmp < min) { + min = tmp; + } + } + // The 12th voxel: + c = z; + b = y; + a = x + 1; + + + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + + + // The center voxel (without a sum): + if (out_rev[ I(x, y, z, dimx, dimy) ] < min) { + min = tmp; + } + + // Return minimum: + return min; + +} + +unsigned short minOfPrevious13_bt( + unsigned char* in_rev, + unsigned short* out_rev, + unsigned short* weights, + const int x, + const int y, + const int z, + const int dimx, + const int dimy, + const int dimz + ) { + int a, b, c; + + // Temporary values: + unsigned short tmp, min; + + // Initialize current minimum: + min = INF; + + + // Computes the sums of the values of the 13 already visited + // neighbors (in direct order) and the corresponding local + // distances: + + // From 0 to 8: + c = z - 1; + for (b = (y - 1); b <= (y + 1); b++) + for (a = (x - 1); a <= (x + 1); a++) { + // If inside volume margins: + if ((a >= 0) && (a < dimx) && + (b >= 0) && (b < dimy) && + (c >= 0) && (c < dimz)) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + } + // From 9 to 11: + c = z; + b = y - 1; + for (a = (x - 1); a <= (x + 1); a++) { + // If inside volume margins: + if ((a >= 0) && (a < dimx) && + (b >= 0) && (b < dimy) && + (c >= 0) && (c < dimz)) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + } + // The 12th: + c = z; + b = y; + a = x - 1; + + // If inside volume margins: + if ((a >= 0) && (a < dimx) && + (b >= 0) && (b < dimy) && + (c >= 0) && (c < dimz)) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + + // Return the minimum of the 13 sums: + return min; +} + +unsigned short minOfPrevious14_bt( + unsigned short* out_rev, + unsigned short* weights, + const int x, + const int y, + const int z, + const int dimx, + const int dimy, + const int dimz + ) { + int a, b, c; + + // Temporary values: + unsigned short tmp, min; + + + // Initialize current minimum: + min = out_rev[ I(x, y, z, dimx, dimy) ]; + + // Computes the sums of the values of the 14 already visited + // neighbors (in reverse order plus the center voxel) and the + // corresponding local distances: + + // From 0 to 8: + c = z + 1; + for (b = (y + 1); b >= (y - 1); b--) + for (a = (x + 1); a >= (x - 1); a--) { + // If inside volume margins: + if ((a >= 0) && (a < dimx) && + (b >= 0) && (b < dimy) && + (c >= 0) && (c < dimz)) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + } + // From 9 to 11: + c = z; + b = y + 1; + for (a = (x + 1); a >= (x - 1); a--) { + // If inside volume margins: + if ((a >= 0) && (a < dimx) && + (b >= 0) && (b < dimy) && + (c >= 0) && (c < dimz)) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + + if (tmp < min) { + min = tmp; + } + } + } + // The 12th voxel: + c = z; + b = y; + a = x + 1; + + // If inside volume margins: + if ((a >= 0) && (a < dimx) && + (b >= 0) && (b < dimy) && + (c >= 0) && (c < dimz)) { + tmp = out_rev[ I(a, b, c, dimx, dimy) ] + + weights[ I((a - x) + 1, (b - y) + 1, (c - z) + 1, 3, 3) ]; + + if (tmp < min) { + min = tmp; + } + } + + // The center voxel (without a sum): + if (out_rev[ I(x, y, z, dimx, dimy) ] < min) { + min = tmp; + } + + // Return minimum: + return min; + +} + +/** + * p3dChamferDistanceTransform + * + * Computes the Chamfer distance transform of the input volume. + * + */ +int p3dChamferDT( + unsigned char* in_rev, + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int w1, + const int w2, + const int w3, + int (*wr_log)(const char*, ...) + ) { + + // Counters: + int i; + int x, y, z; + + + // Temporary values: + unsigned short weights[27]; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Computing Chamfer distance transform..."); + wr_log("\tWeights: [%d,%d,%d].", w1, w2, w3); + } + + // Apply algorithm: + + i = 0; + // z = -1 : + weights[i++] = (unsigned short) w3; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w3; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w1; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w3; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w3; + // z = 0 : + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w1; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w1; + weights[i++] = (unsigned short) 0; + weights[i++] = (unsigned short) w1; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w1; + weights[i++] = (unsigned short) w2; + // z = 1 : + weights[i++] = (unsigned short) w3; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w3; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w1; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w3; + weights[i++] = (unsigned short) w2; + weights[i++] = (unsigned short) w3; + + + // Start forward scanning of padded volume: + for (z = 0; z < dimz; z++) + for (y = 0; y < dimy; y++) + for (x = 0; x < dimx; x++) { + // If input REV is not zero: + if (in_rev[ I(x, y, z, dimx, dimy) ]) { + // For performance reasons a distinction is made between + // internal voxels and border voxels: + if ((x >= 1) && (x < (dimx - 1)) && + (y >= 1) && (y < (dimy - 1)) && + (z >= 1) && (z < (dimz - 1))) { + // Computes the sums of the values of the 13 already visited + // neighbors (in direct order) and the corresponding local + // distances. The new voxel value is the minimum of the 13 sums: + out_rev[ I(x, y, z, dimx, dimy) ] = + minOfPrevious13(in_rev, out_rev, weights, x, y, z, dimx, dimy, dimz); + + } else { + // The new voxel value is the minimum of the sums of + // neighborhood already visited voxels within volume: + out_rev[ I(x, y, z, dimx, dimy) ] = + minOfPrevious13_bt(in_rev, out_rev, weights, x, y, z, dimx, dimy, dimz); + } + } else { + // Set output voxel to zero: + out_rev[ I(x, y, z, dimx, dimy) ] = 0; + } + } + + + // Start backward scanning of 1-voxel zero-padded volume: + for (z = (dimz - 1); z >= 0; z--) + for (y = (dimy - 1); y >= 0; y--) + for (x = (dimx - 1); x >= 0; x--) { + // If input REV (output REV of previous step) is not zero: + if (out_rev[ I(x, y, z, dimx, dimy) ]) { + // For performance reasons a distinction is made between + // internal voxels and border voxels: + if ((x >= 1) && (x < (dimx - 1)) && + (y >= 1) && (y < (dimy - 1)) && + (z >= 1) && (z < (dimz - 1))) { + // Computes the sums of the values of the 14 already visited + // neighbors (in reverse order plus the center voxel) and the + // corresponding local distances. The new voxel value is the + // minimum of the 14 sums: + out_rev[ I(x, y, z, dimx, dimy) ] = + minOfPrevious14(out_rev, weights, x, y, z, dimx, dimy, dimz); + } else { + // The new voxel value is the minimum of the sum of the 14 + // already visited neighbors voxels within volumes: + out_rev[ I(x, y, z, dimx, dimy) ] = + minOfPrevious14_bt(out_rev, weights, x, y, z, dimx, dimy, dimz); + } + } + } + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Chamfer distance transform computed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +} + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dGetMaxVolumeBlob.c b/pypore3d/pypore3d/P3D_Blob/p3dGetMaxVolumeBlob.c new file mode 100644 index 0000000000000000000000000000000000000000..d3de45cc4533a3b6f6373f42428352cf405d47e5 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dGetMaxVolumeBlob.c @@ -0,0 +1,111 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#include "Common/p3dConnectedComponentsLabeling.h" +#include "Common/p3dUtils.h" + +int p3dGetMaxVolumeBlob3D( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + int conn, + int (*wr_log)(const char*, ...) + ) { + unsigned int* lbl_rev; + + unsigned int* volumes; + unsigned int lbl; + unsigned int num_el; + + int i, j, k; + + unsigned int lbl_max; + unsigned int vol_max; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Extracting blob having maximum volume..."); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + } + + // Initialize output cloning input: + memcpy(out_rev, in_rev, dimx * dimy * dimz * sizeof (unsigned char)); + + // Allocate memory for labels: + P3D_MEM_TRY( lbl_rev = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); + + // Perform connected component labeling: + P3D_TRY( p3dConnectedComponentsLabeling_uint(in_rev, lbl_rev, &num_el, &volumes, NULL, dimx, + dimy, dimz, conn, P3D_FALSE, P3D_FALSE)); + + + lbl_max = 0; + vol_max = 0; + + // For each connected component labeled: + for (lbl = 0; lbl < num_el; lbl++) { + if (volumes[lbl] > vol_max) { + lbl_max = lbl; + vol_max = volumes[lbl]; + } + } + + // Remove connected component: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) { + // Labels start from 3: + if (lbl_rev[ I(i, j, k, dimx, dimy) ] != (lbl_max + 3)) { + out_rev[ I(i, j, k, dimx, dimy) ] = 0; + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tPore3D - The volume of extracted blob is %d voxels.", vol_max); + wr_log("Pore3D - Blob having maximum area extracted successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (lbl_rev != NULL) free(lbl_rev); + if (volumes != NULL) free(volumes); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if (lbl_rev != NULL) free(lbl_rev); + if (volumes != NULL) free(volumes); + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Return OK: + return P3D_ERROR; + +} + + + + + + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dGetMinVolumeBlob.c b/pypore3d/pypore3d/P3D_Blob/p3dGetMinVolumeBlob.c new file mode 100644 index 0000000000000000000000000000000000000000..931b4bb4aeebbcd099351f757457f0df2b3156b0 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dGetMinVolumeBlob.c @@ -0,0 +1,117 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#include "Common/p3dConnectedComponentsLabeling.h" +#include "Common/p3dUtils.h" + +int p3dGetMinVolumeBlob3D( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + int conn, + int (*wr_log)(const char*, ...) + ) { + unsigned int* lbl_rev; + + unsigned int* volumes; + unsigned int lbl; + unsigned int num_el; + + int i, j, k; + + unsigned int lbl_min; + unsigned int vol_min; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Extracting blob having minimum volume..."); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + } + // Initialize output cloning input: + memcpy(out_rev, in_rev, dimx * dimy * dimz * sizeof (unsigned char)); + + // Allocate memory for labels: + P3D_MEM_TRY(lbl_rev = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); + + // Perform connected component labeling: + P3D_TRY(p3dConnectedComponentsLabeling_uint(in_rev, lbl_rev, &num_el, &volumes, NULL, dimx, + dimy, dimz, conn, P3D_FALSE, P3D_FALSE)); + + + lbl_min = 0; + vol_min = UINT_MAX; + + // For each connected component labeled: + for (lbl = 0; lbl < num_el; lbl++) { + if (volumes[lbl] < vol_min) { + lbl_min = lbl; + vol_min = volumes[lbl]; + } + } + + // Remove connected component: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) { + // Labels start from 3: + if (lbl_rev[ I(i, j, k, dimx, dimy) ] != (lbl_min + 3)) { + out_rev[ I(i, j, k, dimx, dimy) ] = 0; + } + } + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tPore3D - The volume of extracted blob is %d voxels.", vol_min); + wr_log("Pore3D - Blob having minimum area extracted successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (lbl_rev != NULL) free(lbl_rev); + if (volumes != NULL) free(volumes); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if (lbl_rev != NULL) free(lbl_rev); + if (volumes != NULL) free(volumes); + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Return OK: + return P3D_ERROR; + +} + + + + + + + + + + + + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dMinVolumeFilter.c b/pypore3d/pypore3d/P3D_Blob/p3dMinVolumeFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..b032af151b7c21e0ccf800b93cff96363ca65515 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dMinVolumeFilter.c @@ -0,0 +1,138 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#include "Common/p3dConnectedComponentsLabeling.h" +#include "Common/p3dUtils.h" + + +int p3dMinVolumeFilter3D( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int min_volume, + int conn, + int (*wr_log)(const char*, ...) + ) { + unsigned int* lbl_im; + + unsigned int* volumes; + bb_t* bbs; + + bb_t curr_bb; + unsigned short curr_lbl; + unsigned int num_el; + + int i, j, k, ccl_removed_ct; + + unsigned int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Removing blobs having volume below %d voxels...", min_volume); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + } + + // Initialize output cloning input: + memcpy(out_im, in_im, dimx * dimy * dimz * sizeof (unsigned char)); + + + // Allocate memory for labels: + P3D_MEM_TRY(lbl_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int))); + + // Perform connected component labeling: + P3D_TRY(p3dConnectedComponentsLabeling_uint(in_im, lbl_im, &num_el, &volumes, &bbs, dimx, + dimy, dimz, conn, P3D_FALSE, P3D_FALSE)); + + + // Init counter: + ccl_removed_ct = 0; + + // For each connected component labeled: +#pragma omp parallel for private(i, j, k, curr_lbl, curr_bb) + for (ct = 0; ct < num_el; ct++) { + // If volume of connected component is below minimum volume: + if (volumes[ct] < (unsigned int) min_volume) { + // Get bounding box: + curr_bb.min_x = bbs[ct].min_x; + curr_bb.max_x = bbs[ct].max_x; + curr_bb.min_y = bbs[ct].min_y; + curr_bb.max_y = bbs[ct].max_y; + curr_bb.min_z = bbs[ct].min_z; + curr_bb.max_z = bbs[ct].max_z; + + // Set current label: + curr_lbl = ct + 3; + + // Scan bounding box: + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (lbl_im[ I(i, j, k, dimx, dimy) ] == curr_lbl) { + out_im[ I(i, j, k, dimx, dimy) ] = 0; + } + } + + // Keep trace of connected components removed: + ccl_removed_ct++; + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tPore3D - %d of %d blobs removed.", ccl_removed_ct, num_el); + wr_log("Pore3D - Removal of blobs having volume below %d voxels performed successfully in %dm%0.3fs.", min_volume, p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (lbl_im != NULL) free(lbl_im); + if (volumes != NULL) free(volumes); + if (bbs != NULL) free(bbs); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if (lbl_im != NULL) free(lbl_im); + if (volumes != NULL) free(volumes); + if (bbs != NULL) free(bbs); + + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Return OK: + return P3D_ERROR; + +} + + + + + + + + + + + + + + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dMorphometricAnalysis.c b/pypore3d/pypore3d/P3D_Blob/p3dMorphometricAnalysis.c new file mode 100644 index 0000000000000000000000000000000000000000..3c50892117108b71235ea6fe4479bcb34078240a --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dMorphometricAnalysis.c @@ -0,0 +1,400 @@ +#include <omp.h> + +#define _USE_MATH_DEFINES +#include <math.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <time.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#define GRIDPOINTS 1024 +#define MAXROT 128 +#define BORDER 1 + +/*int p3dComputeFragmentationIndex( + unsigned char* in_im, // IN: Input segmented (binary) volume + double* fri, // OUT: Fragmentation Index + const unsigned int dimx, + const unsigned int dimy, + const unsigned int dimz, + const double voxelsize // IN: voxel resolution + ) +{ + unsigned int a_dimx, a_dimy, a_dimz; + unsigned int a_rad; + + unsigned int i,j,k; + unsigned int x,y,z; + double vol1, surf1; // To avoid oveflow problem + double vol2, surf2; // To avoid oveflow problem + + unsigned short* dt_im; // Squared Euclidean DT of input REV + unsigned char* tmp_im; // Temporary dilated version of input image + unsigned char* dil_im; // Dilated version of input image + + + // Init variables: + a_rad = 1; // 1 voxel padding and also dilation + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad*2; + a_dimy = dimy + a_rad*2; + a_dimz = dimz + a_rad*2; + + // Try to allocate memory for distance transform: + dt_im = (unsigned short*) malloc(dimx*dimy*dimz*sizeof(unsigned short)); + if ( dt_im == NULL ) goto ON_MEM_ERROR; + + // Try to allocate memory for temporary dilated transform: + tmp_im = (unsigned char*) calloc(a_dimx*a_dimy*a_dimz,sizeof(unsigned char)); + if ( tmp_im == NULL ) goto ON_MEM_ERROR; + + // Try to allocate memory for dilated transform: + dil_im = (unsigned char*) malloc(dimx*dimy*dimz*sizeof(unsigned char)); + if ( dil_im == NULL ) goto ON_MEM_ERROR; + + + // Determining distance transform: + p3dSquaredEuclideanDT(in_im, dt_im, dimx, dimy, dimz, NULL); + + // Scanning volume determining values for further use in stats computing: + vol1 = 0.0; + surf1 = 0.0; + for( k = 0; k < dimz; k++ ) + for( j = 0; j < dimy; j++ ) + for( i = 0; i < dimx; i++ ) + { + if ( in_im[ I(i,j,k,dimx,dimy) ] == OBJECT ) + vol1 = vol1 + 1.0; + + if ( dt_im[ I(i,j,k,dimx,dimy) ] == BORDER ) + surf1 = surf1 + 1.0; + } + + + // Compute dilation: + for( k = a_rad; k < (a_dimz - a_rad); k++ ) + for( j = a_rad; j < (a_dimy - a_rad); j++ ) + for( i = a_rad; i < (a_dimx - a_rad); i++ ) + { + if ( in_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] == OBJECT ) + { + // Dilate voxel filling the neighborhood in tmp_im: + for (z = (k - a_rad); z <= (k + a_rad); z++) + for (y = (j - a_rad); y <= (j + a_rad); y++) + for (x = (i - a_rad); x <= (i + a_rad); x++) + { + tmp_im[ I(x,y,z,a_dimx,a_dimy) ] = OBJECT; + } + } + } + + + // Crop tmp_im: + p3dCrop(tmp_im, dil_im, a_dimx, a_dimy, a_dimz, a_rad); + + // Determining distance transform of dilated image: + p3dSquaredEuclideanDT(dil_im, dt_im, dimx, dimy, dimz, NULL); + + // Scanning volume determining values for further use: + vol2 = 0.0; + surf2 = 0.0; + for( k = 0; k < dimz; k++ ) + for( j = 0; j < dimy; j++ ) + for( i = 0; i < dimx; i++ ) + { + if ( tmp_im[ I(i,j,k,dimx,dimy) ] == OBJECT ) + vol2 = vol2 + 1.0; + + if ( dt_im[ I(i,j,k,dimx,dimy) ] == BORDER ) + surf2 = surf2 + 1.0; + } + + + // Compute fragmentation index: + *fri = ( (surf1 - surf2) / (vol1 - vol2) ) / voxelsize; + + + // Release resources: + if ( dt_im != NULL) free(dt_im); + if ( tmp_im != NULL) free(tmp_im); + if ( dil_im != NULL) free(dil_im); + + // Return OK: + return P3D_SUCCESS; + +ON_MEM_ERROR: + + // Free resources: + if ( dt_im != NULL) free(dt_im); + if ( tmp_im != NULL) free(tmp_im); + if ( dil_im != NULL) free(dil_im); + + return P3D_ERROR; +}*/ + + +int p3dMorphometricAnalysis( + unsigned char* in_im, // IN: Input segmented (binary) volume + unsigned char* msk_im, + MorphometricStats* out_stats, // OUT: Trabecular statistics + const int dimx, + const int dimy, + const int dimz, + const double voxelsize, // IN: voxel resolution + int (*wr_log)(const char*, ...) + ) { + + unsigned int s, t; + int i; + + // Indexes for volume scanning: + double x, y, z; + double x_prec, y_prec, z_prec; + + int end_x, end_y, end_z; + int curr_x, curr_y, curr_z; + + + // Test line direction vectors: + double r[3], norm_r[3]; + int ct; + + // Variables for length management: + double length; + double bvf; // Bone Volume Fraction (i.e. BV/TV) + + long intersect_ct; + unsigned char prec_status, curr_status; + + double tot_length; + double tot_intersect_ct; // WARNING: Should be a long but a double + // is used to avoid overflow problem. + + double pl; + double rot_theta, rot_phi; + + double sv; // BS/BV [mm^2 mm^-3] + double tb; // Tb.Th [mm] + double tpd; // Tb.N [mm^-1] + double tps; // Tb.Sp [mm] + + + unsigned int iseed; + time_t tt; + + + // Variables for rotation cycle: + int ct_rot; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing standard morphometric analysis..."); + wr_log("\tAdopted voxelsize: %0.6f mm.", voxelsize); + } + + // Init random seeds: + iseed = (unsigned int) time(&tt); + srand(iseed); + + // Get BV/TV: + if (msk_im == NULL) { + s = 0; + for (i = 0; i < (dimx * dimy * dimz); i++) + if (in_im[i] == OBJECT) s++; + + bvf = s / ((double) (dimx * dimy * dimz)); + } else { + s = 0; + t = 0; + for (i = 0; i < (dimx * dimy * dimz); i++) { + if (msk_im[i] == OBJECT) { + t++; + if (in_im[i] == OBJECT) s++; + } + } + + bvf = s / ((double) t); + } + + // Reset counters: + tot_length = 0.0; + tot_intersect_ct = 0.0; + + // Explore VOI on the random points: + for (i = 0; i < GRIDPOINTS; i++) { + curr_x = (int) (rand() / (((double) RAND_MAX + 1) / dimx)); + curr_y = (int) (rand() / (((double) RAND_MAX + 1) / dimy)); + curr_z = (int) (rand() / (((double) RAND_MAX + 1) / dimz)); + + // Check if inside MSK (if mask): + if (msk_im != NULL) { + if (msk_im[ I(curr_x, curr_y, curr_z, dimx, dimy)] == BACKGROUND) { + continue; + } + + } + + // Skip point if we aren't into the marrow: + if (in_im[ I(curr_x, curr_y, curr_z, dimx, dimy) ] == BACKGROUND) { + // For each of the max_rot direction computed: + for (ct_rot = 0; ct_rot < MAXROT; ct_rot++) { + x = curr_x; + y = curr_y; + z = curr_z; + + rot_theta = ((double) rand() / (double) RAND_MAX) * M_PI; + rot_phi = ((double) rand() / (double) RAND_MAX) * M_PI; + + // Define direction vector (versor): + r[0] = cos(rot_phi) * sin(rot_theta); + r[1] = sin(rot_phi) * sin(rot_theta); + r[2] = cos(rot_theta); + + // Normalize direction vector to +1 for the maximum component, + // doing so we can save iteration on next cycle: + if ((fabs(r[0]) >= fabs(r[1])) && (fabs(r[0]) >= fabs(r[2]))) { + norm_r[0] = 1.0; + norm_r[1] = r[1] / r[0]; + norm_r[2] = r[2] / r[0]; + } else if ((fabs(r[1]) >= fabs(r[0])) && (fabs(r[1]) >= fabs(r[2]))) { + norm_r[1] = 1.0; + norm_r[0] = r[0] / r[1]; + norm_r[2] = r[2] / r[1]; + } else { + norm_r[2] = 1.0; + norm_r[0] = r[0] / r[2]; + norm_r[1] = r[1] / r[2]; + } + + // Make sure signs are correct: + for (ct = 0; ct < 3; ct++) { + if (r[ct] > 0) + norm_r[ct] = fabs(norm_r[ct]); + else + norm_r[ct] = (-fabs(norm_r[ct])); + } + + x_prec = x; + y_prec = y; + z_prec = z; + + // Reset status: + intersect_ct = 0; + prec_status = 0; // false + curr_status = 0; // false + + // Explore the incremental versus while edges of VOI are + // reached: + if (msk_im == NULL) { + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz)) { + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + intersect_ct++; + prec_status = curr_status; + } + + x_prec = x; + y_prec = y; + z_prec = z; + + x = x + norm_r[0]; + y = y + norm_r[1]; + z = z + norm_r[2]; + } + } else { + while ((x >= 0) && (x < dimx) && + (y >= 0) && (y < dimy) && + (z >= 0) && (z < dimz) && + (msk_im[ I((int) x, (int) y, (int) z, dimx, dimy)] == OBJECT) + ) { + + curr_status = in_im[ I((int) x, (int) y, (int) z, dimx, dimy)]; + + // If we reach the object save coords: + if (curr_status != prec_status) { + intersect_ct++; + prec_status = curr_status; + } + + x_prec = x; + y_prec = y; + z_prec = z; + + x = x + norm_r[0]; + y = y + norm_r[1]; + z = z + norm_r[2]; + } + + } + + // We complete the cycle so save end coords: + end_x = (int) x_prec; + end_y = (int) y_prec; + end_z = (int) z_prec; + + + // Get distance: + length = (end_x - curr_x)*(end_x - curr_x) + + (end_y - curr_y)*(end_y - curr_y) + + (end_z - curr_z)*(end_z - curr_z); + length = sqrt(length); + + // Add current length to array for this "porus": + tot_length += length; + tot_intersect_ct += (double) (intersect_ct); + + } // end loop on each rotation + } // end if we are on a "porus" + } + + + pl = tot_intersect_ct / tot_length; + + // Prepare output results: + sv = 2 * pl / bvf; // BS/BV [mm^2 mm^-3] = [mm^-1] + tb = bvf / pl; // Tb.Th [mm] + tpd = pl; // Tb.N [mm^-1] + tps = (1.0 - bvf) / pl; // Tb.Sp [mm] + + // Filling the returned struct: + out_stats->BvTv = bvf; + out_stats->BsBv = sv / voxelsize; + out_stats->TbTh = tb * voxelsize; + out_stats->TbSp = tps * voxelsize; + out_stats->TbN = tpd / voxelsize; + + //p3dComputeFragmentationIndex ( in_im, &out_stats->FrI, dimx, dimy, dimz, voxelsize ); + + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tBone Volume / Total Volume (BV/TV): %0.3f [-].", out_stats->BvTv); + wr_log("\tBone Surface / Bone Volume (BS/BV): %0.3f [mm^-1].", out_stats->BsBv); + wr_log("\tTrabecular Number (Tb.N): %0.3f [mm^-1].", out_stats->TbN); + wr_log("\tTrabecular Thickness (Tb.Th): %0.3f [mm].", out_stats->TbTh); + wr_log("\tTrabecular Separation (Tb.Sp): %0.3f [mm].", out_stats->TbSp); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Morphometric analysis computed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; +} + + + + + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dREVEstimation.c b/pypore3d/pypore3d/P3D_Blob/p3dREVEstimation.c new file mode 100644 index 0000000000000000000000000000000000000000..84118f7c088493fc0f21eec3b4a8d51d6b91006c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dREVEstimation.c @@ -0,0 +1,123 @@ +#include <omp.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +#include "Common/p3dUIntList.h" +#include "Common/p3dDoubleList.h" + +#define BACKGROUND 0 + +int p3dREVEstimation( + unsigned char* in_rev, // IN: binary volume + double** porosity, // OUT: array of porosity for the related cube side + unsigned int** cubeEdges, // OUT: array of length of the side of the REV cube + unsigned int* numel, // OUT: length of the arrays + const int dimx, + const int dimy, + const int dimz, + const int stepsize, // IN: stepsize for porosity + const int centerx, // IN: X coordinate for the center of REV (-1 for + // automatic determination of the center) + const int centery, // IN: Y coordinate for the center of REV + const int centerz, // IN: Z coordinate for the center of REV + int (*wr_log)(const char*, ...) + ) { + + int i, j, k; + int porosityct; + int step; + int cen_x, cen_y, cen_z; + + double_list_t porosity_list; + uint_list_t edges_list; + int arrayct; + + // Initialize lists: + double_list_init(&porosity_list); + uint_list_init(&edges_list); + + // Initialize step: + step = stepsize; + arrayct = 0; + + // Determine the center of the REV: + if (centerx == -1) { + // Automatic determination of the center: + cen_x = dimx / 2; + cen_y = dimy / 2; + cen_z = dimz / 2; + } else { + // Assign values from input parameters: + cen_x = (int) centerx; + cen_y = (int) centery; + cen_z = (int) centerz; + } + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Estimating the REV on a porosity-basis..."); + wr_log("\tCenter: [ %d, %d, %d].", cen_x, cen_y, cen_z); + wr_log("\tStepsize: %d [voxels].", stepsize); + } + + // Loop until boundaries reached: + while (((cen_x - step / 2) > 0) && + ((cen_y - step / 2) > 0) && + ((cen_z - step / 2) > 0) && + ((cen_z + step / 2) < dimz) && + ((cen_y + step / 2) < dimy) && + ((cen_x + step / 2) < dimx) + ) { + porosityct = 0; + + for (k = (cen_z - step / 2); k < (cen_z + step / 2); k++) + for (j = (cen_y - step / 2); j < (cen_y + step / 2); j++) + for (i = (cen_x - step / 2); i < (cen_x + step / 2); i++) { + if (in_rev[ I(i, j, k, dimx, dimy) ] == 0) { + porosityct++; + } + } + + + // Put porosity in the list: + double_list_add(&porosity_list, (double) (porosityct / (step * step * step * 1.0))); + + // Put stepsize in the list: + uint_list_add(&edges_list, (unsigned int) (step + 0)); + + // Increment array counter: + arrayct++; + + // Increase stepsize: + step = step + stepsize; + } + + + // Return lists converted to array: + *porosity = double_list_toarray(&porosity_list, arrayct); + *cubeEdges = uint_list_toarray(&edges_list, arrayct); + *numel = arrayct; + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - REV estimation performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +} + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dSquaredEuclideanDT.c b/pypore3d/pypore3d/P3D_Blob/p3dSquaredEuclideanDT.c new file mode 100644 index 0000000000000000000000000000000000000000..6fafb4ce0df92997d61d9abd79c4739a8bce3aeb --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dSquaredEuclideanDT.c @@ -0,0 +1,427 @@ +/* + * p3dSquaredEuclideanDistanceTransform + * + * Computes the squared Euclidean distance transform of the input volume. For + * each non-zero voxel in input image, the distance transform assigns a number + * that is the squared distance between that voxel and the nearest zero pixel + * (background). The squared Euclidean distance transform is a non-approximated + * Euclidean distance metric. + * + * Remarks + * ------- + * Computational cost is O(N^3) for a NxNxN input volume. Memory + * requirement is three extra volumes of a NxNxN and two linear arrays of N + * elements, i.e. O(N^3). Current implementation uses unsigned short elements + * (see compiler specifications). + * + * References + * ---------- + * [1] T. Hirata. "A unified linear-time algorithm for computing distance + * maps", Information Processing Letters, 58(3):129-133, May 1996. + * + * [2] A. Meijster, J.B.T.M. Roerdink and W. H. Hesselink. "A general + * algorithm for computing distance transforms in linear time", + * Mathematical Morphology and its Applications to Image and Signal + * Processing, pp. 331-340. Kluwer, 2000. + * + + * + * Copyright 2008, SYRMEP Group - Sincrotrone Trieste S.C.p.A. + * + * Author: Brun Francesco + * Version: 1.0 + * Date: 19 june 2008 + * + */ +#include <omp.h> + + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + + +// Set a signed integer type able to get over 65.535 and the +// maximum value representable (INF) with this specified type +// (see <limits.h>). These settings depends on the specific +// compilator used. +//typedef int int; +#define INF INT_MAX + +/* ------------------- + * Mathematical operators with INF management. + * ------------------- */ + +/** + ************************************************** + * @b sum + * @param a int number with INF + * @param b int number with INF + * @return The sum of a and b handling INF + **************************************************/ +int sum(int a, int b) { + if ((a == INF) || (b == INF)) + return INF; + else + return a + b; +} + +/** + ************************************************** + * @b prod + * @param a long number with INF + * @param b long number with INF + * @return The product of a and b handling INF + **************************************************/ +int prod(int a, int b) { + if ((a == INF) || (b == INF)) + return INF; + else + return a * b; +} + +/** + ************************************************** + * @b opp + * @param a long number with INF + * @return The opposite of a handling INF + **************************************************/ +int opp(int a) { + if (a == INF) + return INF; + else + return -a; +} + +/** + ************************************************** + * @b intdivint + * @param divid long number with INF + * @param divis long number with INF + * @return The division (integer) of divid out of divis handling INF + **************************************************/ +int intdivint(int divid, int divis) { + if (divis == 0) + return INF; + if (divid == INF) + return INF; + else + return divid / divis; +} + +/* ------------------- + * Mathematical operators for the parabola definition. + * ------------------- */ + +/** + ************************************************** + * @b f + * @param x + * @param i + * @param gi2 + * @return Definition of a parabola + **************************************************/ +int f(int x, int i, int gi2) { + return sum((x - i)*(x - i), gi2); +} + +/** + ************************************************** + * @b sep + * @param i + * @param u + * @param gi2 + * @param gu2 + * @return The abscissa of the intersection point between two parabolas + **************************************************/ +int sep(int i, int u, int gi2, int gu2) { + return intdivint(sum(sum((long) (u * u - i * i), gu2), opp(gi2)), 2 * (u - i)); +} + + + +/* ------------------- + * Steps of distance transform algorithm. + * ------------------- */ + +/** + ************************************************** + * @b stepX + * @param voi input volume + * @param sdt_x DT along the x-direction + **************************************************/ +int stepX(const unsigned char* voi, + int* sdt_x, + int NRows, + int NCols, + int NPlanes, + int (*wr_log)(const char*, ...) + ) { + int x, y, z; + + for (z = 0; z < NPlanes; z++) + for (y = 0; y < NCols; y++) { + if (voi[ I(0, y, z, NRows, NCols) ] == 0) + sdt_x[ I(0, y, z, NRows, NCols) ] = 0; + else + sdt_x[ I(0, y, z, NRows, NCols) ] = INF; + + // Forward scan + for (x = 1; x < NRows; x++) + if (voi[ I(x, y, z, NRows, NCols) ] == 0) + sdt_x[ I(x, y, z, NRows, NCols) ] = 0; + else + sdt_x[ I(x, y, z, NRows, NCols) ] = sum(1, sdt_x[ I(x - 1, y, z, NRows, NCols)]); + + //Backward scan + for (x = NRows - 2; x >= 0; x--) + if (sdt_x[ I(x + 1, y, z, NRows, NCols) ] < sdt_x[ I(x, y, z, NRows, NCols) ]) + sdt_x[ I(x, y, z, NRows, NCols) ] = sum(1, sdt_x[ I(x + 1, y, z, NRows, NCols) ]); + } + + // Return success code: + return P3D_SUCCESS; +} + +/** + ************************************************** + * @b stepY + * @param sdt_x the DT along the x-direction + * @param sdt_xy the DT in the xy-slices + **************************************************/ +int stepY(const int* sdt_x, + int* sdt_xy, + int NRows, + int NCols, + int NPlanes, + int (*wr_log)(const char*, ...) + ) { + + int* s; // Center of the upper envelope parabolas + int* t; // Separating index between 2 upper envelope + // parabolas + int q; + int w; + + int x, z, u; + + + + P3D_MEM_TRY(s = (int*) calloc(NCols, sizeof (int))); + P3D_MEM_TRY(t = (int*) calloc(NCols, sizeof (int))); + + for (z = 0; z < NPlanes; z++) + for (x = 0; x < NRows; x++) { + q = 0; + s[0] = 0; + t[0] = 0; + + //Forward scanning: + for (u = 1; u < NCols; u++) { + while ((q >= 0) && + (f(t[q], s[q], prod(sdt_x[ I(x, s[q], z, NRows, NCols) ], sdt_x[ I(x, s[q], z, NRows, NCols) ])) > + f(t[q], u, prod(sdt_x[ I(x, u, z, NRows, NCols) ], sdt_x[ I(x, u, z, NRows, NCols) ])))) + q--; + + if (q < 0) { + q = 0; + s[0] = u; + } else { + w = 1 + sep(s[q], u, + prod(sdt_x[ I(x, s[q], z, NRows, NCols) ], sdt_x[ I(x, s[q], z, NRows, NCols) ]), + prod(sdt_x[ I(x, u, z, NRows, NCols) ], sdt_x[ I(x, u, z, NRows, NCols) ])); + + if (w < NCols) { + q++; + s[q] = u; + t[q] = w; + } + } + } + + //Backward scanning: + for (u = NCols - 1; u >= 0; --u) { + sdt_xy[ I(x, u, z, NRows, NCols) ] = f(u, s[q], prod(sdt_x[ I(x, s[q], z, NRows, NCols) ], sdt_x[ I(x, s[q], z, NRows, NCols) ])); + if (u == t[q]) + q--; + } + } + + // Free memory: + if (s != NULL) free(s); + if (t != NULL) free(t); + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free allocated memory: + if (s != NULL) free(s); + if (t != NULL) free(t); + + // Return OK: + return P3D_ERROR; +} + +/** + ************************************************** + * @b stepZ + * @param sdt_xy the DT in the xy-slices + * @param sdt_xyz the final DT + **************************************************/ +int stepZ(const int* sdt_xy, + int* sdt_xyz, + int NRows, + int NCols, + int NPlanes, + int (*wr_log)(const char*, ...) + ) { + + int* s; // Center of the upper envelope parabolas + int* t; // Separating index between 2 upper envelope + // parabolas + int q; + int w; + + int x, y, u; + + + P3D_MEM_TRY(s = (int*) calloc(NPlanes, sizeof (int))); + P3D_MEM_TRY(t = (int*) calloc(NPlanes, sizeof (int))); + + + for (y = 0; y < NCols; y++) + for (x = 0; x < NRows; x++) { + q = 0; + s[0] = 0; + t[0] = 0; + + //Forward scanning: + for (u = 1; u < NPlanes; u++) { + while ((q >= 0) && + (f(t[q], s[q], sdt_xy[ I(x, y, s[q], NRows, NCols) ]) > + f(t[q], u, sdt_xy[ I(x, y, u, NRows, NCols) ]))) + q--; + + if (q < 0) { + q = 0; + s[0] = u; + } else { + w = 1 + sep(s[q], u, + sdt_xy[ I(x, y, s[q], NRows, NCols) ], + sdt_xy[ I(x, y, u, NRows, NCols) ]); + + if (w < NPlanes) { + q++; + s[q] = u; + t[q] = w; + } + } + } + + //Backward scanning: + for (u = NPlanes - 1; u >= 0; --u) { + sdt_xyz[ I(x, y, u, NRows, NCols) ] = f(u, s[q], sdt_xy[ I(x, y, s[q], NRows, NCols) ]); + if (u == t[q]) + q--; + } + } + + // Free memory: + if (s != NULL) free(s); + if (t != NULL) free(t); + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free allocated memory: + if (s != NULL) free(s); + if (t != NULL) free(t); + + // Return OK: + return P3D_ERROR; +} + +/************************************************************************ + * DT3 - Entry point: + * + * + ************************************************************************/ +int p3dSquaredEuclideanDT( + unsigned char* in_rev, + unsigned int* out_rev, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) { + // Temporary values and volume: + int* tmp_rev; + int* tmp_out_rev; + + // Counter: + int i; + + int err_code; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Computing Squared Euclidean Distance Transform..."); + } + + // Allocate temporary output: + P3D_MEM_TRY(tmp_out_rev = (int*) malloc(dimx * dimy * dimz * sizeof (int))); + + // Initialize temporary: + P3D_MEM_TRY(tmp_rev = (int*) malloc(dimx * dimy * dimz * sizeof (int))); + + // Compute transform: + P3D_TRY(err_code = stepX(in_rev, tmp_out_rev, dimx, dimy, dimz, wr_log)); + P3D_TRY(err_code = stepY(tmp_out_rev, tmp_rev, dimx, dimy, dimz, wr_log)); + P3D_TRY(err_code = stepZ(tmp_rev, tmp_out_rev, dimx, dimy, dimz, wr_log)); + + // Cast output from int to unsigned int: + for (i = 0; i < (dimx * dimy * dimz); i++) + out_rev[i] = (tmp_out_rev[i] > UINT_MAX) ? UINT_MAX : (unsigned int) (tmp_out_rev[i]); + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Squared Euclidean Distance Transform computed successfully in %0.3f sec.", p3dGetElapsedTime()); + } + + // Free allocated memory: + if (tmp_rev != NULL) free(tmp_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free allocated memory: + if (tmp_rev != NULL) free(tmp_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_ERROR; + +} + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dTextureAnalysis.c b/pypore3d/pypore3d/P3D_Blob/p3dTextureAnalysis.c new file mode 100644 index 0000000000000000000000000000000000000000..2388ec0ffc3dcf2da3736fb6b05bcb35a03f90be --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dTextureAnalysis.c @@ -0,0 +1,184 @@ +#include <omp.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +#include <stdio.h> + +#include "p3dBlob.h" +#include "p3dTime.h" + +int _p3dCheckForObjectVoxel( + unsigned char* in_im, // IN: Input segmented (binary) volume + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int size + ) { + int x, y, z; + + // Check if there is an OBJECT pixel within box (excluding partial boxes): + /*if ( ((k + size - 1) < dimz ) && + ((j + size - 1) < dimy ) && + ((i + size - 1) < dimx ) ) + { + for (z = (int) (k + size - 1); z >= (int) k; z--) + for (y = (int) (j + size - 1); y >= (int) j; y--) + for (x = (int) (i + size - 1); x >= (int) i; x--) + { + if ( in_im[ I(x,y,z,dimx,dimy)] == OBJECT ) + { + return 1; // true + } + } + }*/ + + // Check if there is an OBJECT pixel within box (including partial boxes): + for (z = k; ((z < (k + size - 1)) && (z < dimz)); z++) + for (y = j; ((y < (j + size - 1)) && (y < dimz)); y++) + for (x = i; ((x < (i + size - 1)) && (x < dimz)); x++) { + if (in_im[ I(x, y, z, dimx, dimy)] == OBJECT) { + return 1; // true + } + } + + return 0; // false; +} + +int p3dBoxCountingFractalDimension( + unsigned char* in_im, // IN: Input segmented (binary) volume + double* fd, // OUT: Box Counting Fractal Dimension + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) { + + int i, j, k, ct; + int size, boxct; + + int min_dim, max_box; + + double sizes_avg, boxes_avg, sizes_sum, boxes_sum; + double cross, r; + + double* sizes; + double* boxes; + + + // Determine maximum box size in order to have more than one boxes for + // the greater step size. For instance using a maximum step size of 128 + // for a 300x300x300 volume will result for sure in 4 full box e 5 + // partial boxes for the 128 step size. This situation affects the + // accuracy of results. + min_dim = MIN(MIN(dimx, dimy), dimz); + max_box = (int) (log((double) min_dim) / log(2.0) + 0.5) - 1; + + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tMinimum box side adopted: 2"); + wr_log("\tMaximum box side adopted: %d. ",(int) ((pow(2, (double) max_box)))); + } + + sizes = (double*) malloc(max_box * sizeof (double)); + boxes = (double*) malloc(max_box * sizeof (double)); + + sizes_avg = 0; + boxes_avg = 0; + + // For each size: + for (ct = 0; ct < max_box; ct++) { + // Get current size: + size = (int) (pow((double) 2.0, (double) ct + 1)); + + // Reset box counter: + boxct = 0; + + // Image scanning: +#pragma omp parallel for private(i, j) reduction (+ : boxct) + for (k = 0; k < dimz; k = k + size) + for (j = 0; j < dimy; j = j + size) + for (i = 0; i < dimx; i = i + size) { + // If there's a ON pixel within box increment counter: + if (_p3dCheckForObjectVoxel(in_im, (int) dimx, (int) dimy, (int) dimz, i, j, k, size) == 1) + boxct++; + } + + // Set total number of boxes to vectors: + sizes[ct] = -log((double) size); + boxes[ct] = log((double) boxct); + + sizes_avg += sizes[ct]; + boxes_avg += boxes[ct]; + } + + sizes_avg /= (double) (max_box); + boxes_avg /= (double) (max_box); + + sizes_sum = 0; + boxes_sum = 0; + cross = 0; + + // Compute sum of squares: + for (ct = 0; ct < max_box; ct++) { + cross += (boxes[ct] - boxes_avg)*(sizes[ct] - sizes_avg); + boxes_sum += (boxes[ct] - boxes_avg)*(boxes[ct] - boxes_avg); + sizes_sum += (sizes[ct] - sizes_avg)*(sizes[ct] - sizes_avg); + } + + // Compute correlation coefficient and fractal dimension: + r = cross / sqrt(boxes_sum * sizes_sum); + *fd = r * sqrt(boxes_sum) / sqrt(sizes_sum); + + // Release resources: + if (sizes != NULL) free(sizes); + if (boxes != NULL) free(boxes); + + // Return OK: + return P3D_SUCCESS; +} + + +int p3dTextureAnalysis( + unsigned char* in_im, // IN: Input segmented (binary) volume + TextureStats* out_stats, // OUT: Texture statistics + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) { + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing texture analysis..."); + + } + + p3dBoxCountingFractalDimension(in_im, &(out_stats->FD), dimx, dimy, dimz, wr_log); + + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tFractal dimension (box counting) (FD): %0.3f [-].", out_stats->FD); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Texture analysis performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; +} + + + + + diff --git a/pypore3d/pypore3d/P3D_Blob/p3dTime.h b/pypore3d/pypore3d/P3D_Blob/p3dTime.h new file mode 100644 index 0000000000000000000000000000000000000000..8bb29440ed2ef2a2f06d01bf53912123a4921b04 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Blob/p3dTime.h @@ -0,0 +1,4 @@ +void p3dResetStartTime (); +double p3dGetElapsedTime(); +int p3dGetElapsedTime_min(); +double p3dGetElapsedTime_sec(); diff --git a/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsQueue.c b/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsQueue.c new file mode 100644 index 0000000000000000000000000000000000000000..24375d567c2dede350b4adb242b96043a93ee01d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsQueue.c @@ -0,0 +1,82 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> + +#include "../p3dFilt.h" +#include "p3dCoordsQueue.h" + +void coords_queue_init(coords_queue_t *queue) { + queue->head = NULL; + queue->tail = NULL; +} + +void coords_queue_push(coords_queue_t *queue, coords_t elem) { + + coords_queue_elem_t *new_q; + + // Alloc memory for the new item: + new_q = (coords_queue_elem_t *) malloc(sizeof (coords_queue_elem_t)); + + // Push item into queue: + new_q->item = elem; + new_q->next = NULL; + + // Handle first element pushed: + if (queue->tail != NULL) { + queue->tail->next = new_q; + queue->tail = queue->tail->next; + } else { + queue->tail = new_q; + queue->head = queue->tail; + } +} + +coords_t coords_queue_pop(coords_queue_t *queue) { + coords_t elem; + coords_queue_elem_t *temp; + + // Pop item from queue: + elem = queue->head->item; + + // Free memory: + temp = queue->head; + queue->head = queue->head->next; + free(temp); + + // Handle last element popped: + if (queue->head == NULL) { + queue->tail = NULL; + } + + // Return the item previously popped: + return elem; +} + +int coords_queue_isempty(coords_queue_t queue) { + return ( ((queue.head == NULL) && (queue.tail == NULL)) ? P3D_TRUE : P3D_FALSE); +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsQueue.h b/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsQueue.h new file mode 100644 index 0000000000000000000000000000000000000000..9e29945539b0fad0f92ed1e18df5fb5f583e1ad8 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsQueue.h @@ -0,0 +1,68 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dCoordsT.h" + +/********************************************************************* + * + * coords_queue_t type definitions. Do NOT modify. coords_queue_t implements a FIFO + * policy: elements are pushed into the tail and popped from the head. + * + *********************************************************************/ + +#ifndef COORDS_Q_DEFINED + #define COORDS_Q_DEFINED + + struct coords_qelem_t { + coords_t item; + struct coords_qelem_t *next; + }; + + typedef struct coords_qelem_t coords_queue_elem_t; + + struct coords_q_t{ + coords_queue_elem_t *tail; + coords_queue_elem_t *head; + }; + + typedef struct coords_q_t coords_queue_t; + +#endif +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void coords_queue_init (coords_queue_t *queue); + +void coords_queue_push(coords_queue_t *queue, coords_t elem); + +coords_t coords_queue_pop(coords_queue_t *queue); + +int coords_queue_isempty(coords_queue_t queue); + diff --git a/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsT.h b/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsT.h new file mode 100644 index 0000000000000000000000000000000000000000..917aa1f57aec52e006d8b43fa0d0ba31569ecf2d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/Common/p3dCoordsT.h @@ -0,0 +1,48 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/* + Type definitions: +*/ + +#ifndef COORDS_T_DEFINED + +typedef struct { + int x; + int y; + int z; +} coords_t; + +typedef struct { + double x; + double y; + double z; +} fcoords_t; + +#endif + +#define COORDS_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.c b/pypore3d/pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.c new file mode 100644 index 0000000000000000000000000000000000000000..8603c3412a47eba6ce590e362eb98a960119af10 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.c @@ -0,0 +1,466 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <limits.h> +#include <omp.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include "../p3dFilt.h" + +#define PI 3.1415926535897932384626433 + +/*int _isPath(char* path) +{ + struct stat statbuf; + + if ( stat(path, &statbuf) == -1 ) + return -1; + else + return S_ISDIR(statbuf.st_mode); +}*/ + +double _cubic(double x) { + double z = 0; + double a = 1; // a = 0.5 for less sharpening + + // Absolute value: + if (x < 0) + x = -x; + + // Apply polinomial definition: + if (x < 1) + z = (-a + 2) * x * x * x + (a - 3) * x * x + 1; + else if (x < 2) + z = -a * x * x * x + 5 * a * x * x - 8 * a * x + 4 * a; + + return z; +} +// Should be thread-safe + +unsigned char p3dBicubicInterpolation_8( + unsigned char* in_im, + int dimx, + int dimy, + double x0, + double y0 + ) { + int u0 = (int) x0; + int v0 = (int) y0; + int i, j; + int v; + double p; + int u, tmpu, tmpv; + + double q = 0; + + for (j = -1; j <= 2; j++) { + v = v0 + j; + p = 0; + for (i = -1; i <= 2; i++) { + u = u0 + i; + tmpu = u; + tmpv = v; + + // Replicate padding for X and Y direction: + if (u < 0) + tmpu = 0; + if (u > ((int) dimx - 1)) + tmpu = (int) dimx - 1; + if (v < 0) + tmpv = 0; + if (v > ((int) dimy - 1)) + tmpv = (int) dimy - 1; + + p = p + in_im[ I2(tmpu, tmpv, dimx) ] * _cubic(x0 - u); + } + q = q + p * _cubic(y0 - v); + } + + q = q + 0.5; + + // Check intensity boundary: + if (q < 0.0) q = 0.0; + if (q >= UCHAR_MAX) q = UCHAR_MAX; + + return (unsigned char) q; +} + + + +// Should be thread-safe + +unsigned short p3dBicubicInterpolation_16( + unsigned short* in_im, + int dimx, + int dimy, + double x0, + double y0 + ) { + int u0 = (int) x0; + int v0 = (int) y0; + + int i, j; + int u, tmpu, tmpv; + int v; + double p; + + double q = 0; + + for (j = -1; j <= 2; j++) { + v = v0 + j; + p = 0; + for (i = -1; i <= 2; i++) { + u = u0 + i; + tmpu = u; + tmpv = v; + + // Replicate padding for X and Y direction: + if (u < 0) + tmpu = 0; + if (u > ((int) dimx - 1)) + tmpu = (int) dimx - 1; + if (v < 0) + tmpv = 0; + if (v > ((int) dimy - 1)) + tmpv = (int) dimy - 1; + + p = p + in_im[ I2(tmpu, tmpv, dimx) ] * _cubic(x0 - u); + } + q = q + p * _cubic(y0 - v); + } + + q = q + 0.5; + + // Check intensity boundary: + if (q < 0.0) q = 0.0; + if (q >= USHRT_MAX) q = USHRT_MAX; + + return (unsigned short) q; +} + + + +// Should be thread-safe + +unsigned char p3dBicubicInterpolation_p2c_8( + unsigned char* in_im, + int dimx, + int dimy, + double x0, + double y0 + ) { + int u0 = (int) x0; + int v0 = (int) y0; + int u, tmpu, tmpv; + int v; + double p; + int i, j; + + double q = 0; + + for (j = -1; j <= 2; j++) { + v = v0 + j; + p = 0; + for (i = -1; i <= 2; i++) { + u = u0 + i; + tmpu = u; + tmpv = v; + + // Replicate padding for X direction and circular padding for Y + // direction: + if (u < 0) + tmpu = 0; + if (u > ((int) dimx - 1)) + tmpu = (int) dimx - 1; + if (v < 0) + tmpv = v + (int) dimy; + if (v > ((int) dimy - 1)) + tmpv = v - (int) dimy; + + p = p + in_im[ I2(tmpu, tmpv, dimx) ] * _cubic(x0 - u); + } + q = q + p * _cubic(y0 - v); + } + + q = q + 0.5; + + // Check intensity boundary: + if (q < 0.0) q = 0.0; + if (q >= UCHAR_MAX) q = UCHAR_MAX; + + return (unsigned char) q; +} + + +// Should be thread-safe + +unsigned short p3dBicubicInterpolation_p2c_16( + unsigned short* in_im, + int dimx, + int dimy, + double x0, + double y0 + ) { + int u0 = (int) x0; + int v0 = (int) y0; + int i, j; + int u, v, tmpu, tmpv; + double p; + + double q = 0; + + for (j = -1; j <= 2; j++) { + v = v0 + j; + p = 0; + for (i = -1; i <= 2; i++) { + u = u0 + i; + tmpu = u; + tmpv = v; + + // Replicate padding for X direction and circular padding for Y + // direction: + if (u < 0) + tmpu = 0; + if (u > ((int) dimx - 1)) + tmpu = (int) dimx - 1; + if (v < 0) + tmpv = v + (int) dimy; + if (v > ((int) dimy - 1)) + tmpv = v - (int) dimy; + + p = p + in_im[ I2(tmpu, tmpv, dimx) ] * _cubic(x0 - u); + } + q = q + p * _cubic(y0 - v); + } + + q = q + 0.5; + + // Check intensity boundary: + if (q < 0.0) q = 0.0; + if (q >= USHRT_MAX) q = USHRT_MAX; + + return (unsigned short) q; +} + + +// A square image with dimensions POLARX x POLARX is returned. Due to the fact +// the POLARX is not known a priori, memory image is allocated within this +// procedure so parameter OUT_IM should be passed as reference. The out parameter +// POLARX should be used for further handling of OUT_IM. + +void p3dCartesian2polar_8( + unsigned char* in_im, // IN: input image in cartesian coordinates + unsigned char** out_im, // OUT: output image in polar coordinates + const int dimx, // IN: width of input image + const int dimy, // IN: heigth of input image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const double precision, + int* polarX // OUT: side of the square image returned as output + ) { + int i, j; + double r, phi; + double x, y; + + double r1, r2, r3, r4; + + + // Find the greatest radius: + + // Top-Left Corner (0,0): + r1 = sqrt((centerX - 0)*(centerX - 0) + (centerY - 0)*(centerY - 0)); + // Top-Right Corner (widthInitial, 0): + r2 = sqrt((centerX - dimx)*(centerX - dimx) + (centerY - 0)*(centerY - 0)); + // Bottom-Left Corner (0, heightInitial): + r3 = sqrt((centerX - 0)*(centerX - 0) + (centerY - dimy)*(centerY - dimy)); + // Bottom-Right Corner (widthInitial , heightInitial): + r4 = sqrt((centerX - dimx)*(centerX - dimx) + (centerY - dimy)*(centerY - dimy)); + + + // The greatest radius is the semi-width of the polar image: + *polarX = (int) (precision * (MAX(MAX(MAX(r1, r2), r3), r4) + 0.5)); + + // Now that we know dimensions, allocate memory: + (*out_im) = (unsigned char*) calloc((*polarX)*(*polarX), sizeof (unsigned char)); + + + // Fill the polar grid: +#pragma omp parallel for private(i, r, phi, x, y) + for (j = 0; j < (*polarX); j++) + for (i = 0; i < (*polarX); i++) { + // Get [r,phi]: + r = (double) (i); + phi = ((double) (j) / (*polarX)) * PI * 2; + + // Get [x,y] from [r,phi]: + x = r * cos(phi) + centerX; + y = r * sin(phi) + centerY; + + + // Perform bicubic interpolation: + (*out_im)[ I2(i, j, (*polarX)) ] = p3dBicubicInterpolation_8(in_im, dimx, dimy, x, y); + + } + +} + +void p3dCartesian2polar_16( + unsigned short* in_im, // IN: input image in cartesian coordinates + unsigned short** out_im, // OUT: output image in polar coordinates + const int dimx, // IN: width of input image + const int dimy, // IN: heigth of input image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const double precision, + int* polarX // OUT: side of the square image returned as output + ) { + int i, j; + double r, phi; + double x, y; + + double r1, r2, r3, r4; + + + // Find the greatest radius: + + // Top-Left Corner (0,0): + r1 = sqrt((centerX - 0)*(centerX - 0) + (centerY - 0)*(centerY - 0)); + // Top-Right Corner (widthInitial, 0): + r2 = sqrt((centerX - dimx)*(centerX - dimx) + (centerY - 0)*(centerY - 0)); + // Bottom-Left Corner (0, heightInitial): + r3 = sqrt((centerX - 0)*(centerX - 0) + (centerY - dimy)*(centerY - dimy)); + // Bottom-Right Corner (widthInitial , heightInitial): + r4 = sqrt((centerX - dimx)*(centerX - dimx) + (centerY - dimy)*(centerY - dimy)); + + + // The greatest radius is the semi-width of the polar image: + *polarX = (int) (precision * (MAX(MAX(MAX(r1, r2), r3), r4) + 0.5)); + + // Now that we know dimensions, allocate memory: + (*out_im) = (unsigned short*) calloc((*polarX)*(*polarX), sizeof (unsigned short)); + + + // Fill the polar grid: +#pragma omp parallel for private(i, r, phi, x, y) + for (j = 0; j < (*polarX); j++) + for (i = 0; i < (*polarX); i++) { + // Get [r,phi]: + r = (double) (i); + phi = ((double) (j) / (*polarX)) * PI * 2; + + // Get [x,y] from [r,phi]: + x = r * cos(phi) + centerX; + y = r * sin(phi) + centerY; + + + // Perform bicubic interpolation: + (*out_im)[ I2(i, j, (*polarX)) ] = p3dBicubicInterpolation_16(in_im, dimx, dimy, x, y); + + } + +} + + + +// For coherence with dual procedure CARTESIAN2POLAR memory image is allocated +// within this procedure so parameter OUT_IM should be passed as reference. + +void p3dPolar2cartesian_8( + unsigned char* in_im, // IN: input image in polar coordinates + unsigned char** out_im, // OUT: output image in cartesian coordinates + const int polarX, // IN: side of the square of polar image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const int original_dimx, // IN: width of the output cartesian image + const int original_dimy // IN: heigth of the output cartesian image + ) { + double r, phi; + int i, j; + double x, y; + + // Allocate memory: + (*out_im) = (unsigned char*) calloc(original_dimx*original_dimy, sizeof (unsigned char)); + + // Fill the cartesian grid: +#pragma omp parallel for private(i, r, phi, x, y) + for (j = 0; j < original_dimy; j++) + for (i = 0; i < original_dimx; i++) { + x = (double) (i) - centerX; + y = (double) (j) - centerY; + + // Get [r,phi] from [x,y]: + r = sqrt(x * x + y * y); + phi = (atan2(y, x) * polarX) / (PI * 2); // Degree unit + if (phi < 0) + phi += polarX; + + // Perform bicubic interpolation: + (*out_im)[ I2(i, j, original_dimx) ] = p3dBicubicInterpolation_p2c_8(in_im, polarX, polarX, r, phi); + + } +} + +void p3dPolar2cartesian_16( + unsigned short* in_im, // IN: input image in polar coordinates + unsigned short** out_im, // OUT: output image in cartesian coordinates + const int polarX, // IN: side of the square of polar image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const int original_dimx, // IN: width of the output cartesian image + const int original_dimy // IN: heigth of the output cartesian image + ) { + double r, phi; + int i, j; + double x, y; + + // Allocate memory: + (*out_im) = (unsigned short*) calloc(original_dimx*original_dimy, sizeof (unsigned short)); + + // Fill the cartesian grid: +#pragma omp parallel for private(i, r, phi, x, y) + for (j = 0; j < original_dimy; j++) + for (i = 0; i < original_dimx; i++) { + x = (double) (i) - centerX; + y = (double) (j) - centerY; + + // Get [r,phi] from [x,y]: + r = sqrt(x * x + y * y); + phi = (atan2(y, x) * polarX) / (PI * 2); // Degree unit + if (phi < 0) + phi += polarX; + + // Perform bicubic interpolation: + (*out_im)[ I2(i, j, original_dimx) ] = p3dBicubicInterpolation_p2c_16(in_im, polarX, polarX, r, phi); + + } +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.h b/pypore3d/pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.h new file mode 100644 index 0000000000000000000000000000000000000000..25fc90d535aac30de2978adc52d90dc499ad7913 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.h @@ -0,0 +1,79 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +// A square image with dimensions POLARX x POLARX is returned. Due to the fact +// the POLARX is not known a priori, memory image is allocated within this +// procedure so parameter OUT_IM should be passed as reference. The out parameter +// POLARX should be used for further handling of OUT_IM. + +//int _isPath(char* ); amal + +void p3dCartesian2polar_8( + unsigned char* in_im, // IN: input image in cartesian coordinates + unsigned char** out_im, // OUT: output image in polar coordinates + const int dimx, // IN: width of input image + const int dimy, // IN: heigth of input image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const double precision, + int* polarX // OUT: side of the square image returned as output + ); + +void p3dCartesian2polar_16( + unsigned short* in_im, // IN: input image in cartesian coordinates + unsigned short** out_im, // OUT: output image in polar coordinates + const int dimx, // IN: width of input image + const int dimy, // IN: heigth of input image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const double precision, + int* polarX // OUT: side of the square image returned as output + ); + + +// For coherence with dual procedure CARTESIAN2POLAR memory image is allocated +// within this procedure so parameter OUT_IM should be passed as reference. + +void p3dPolar2cartesian_8( + unsigned char* in_im, // IN: input image in polar coordinates + unsigned char** out_im, // OUT: output image in cartesian coordinates + const int polarX, // IN: side of the square of polar image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const int original_dimx, // IN: width of the output cartesian image + const int original_dimy // IN: heigth of the output cartesian image + ); + +void p3dPolar2cartesian_16( + unsigned short* in_im, // IN: input image in polar coordinates + unsigned short** out_im, // OUT: output image in cartesian coordinates + const int polarX, // IN: side of the square of polar image + const double centerX, // IN: X coordinate for center of polar transform + const double centerY, // IN: Y coordinate for center of polar transform + const int original_dimx, // IN: width of the output cartesian image + const int original_dimy // IN: heigth of the output cartesian image + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/_p3dTime.c b/pypore3d/pypore3d/P3D_Filt/_p3dTime.c new file mode 100644 index 0000000000000000000000000000000000000000..abb61ac19fe064d9416cb6e64829feea88645f4e --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/_p3dTime.c @@ -0,0 +1,68 @@ +#include <stdio.h> + +#include "p3dTime.h" + +int p3dTime_min = 0; +double p3dTime_sec = 0.0; + +#ifndef _WINDOWS +//#include <sys/time.h> + +//static struct timeval p3dTime_tv; +static unsigned long p3dTime_startTime, p3dTime_crtTime; +#else +#include <windows.h> +#include <time.h> + +DWORD p3dTime_startTime, p3dTime_crtTime; +#endif + + +void p3dResetStartTime() +{ +#ifdef _WINDOWS + p3dTime_startTime = GetTickCount(); + p3dTime_crtTime = GetTickCount(); +#else + //gettimeofday(&p3dTime_tv, NULL); + //p3dTime_startTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); +#endif + + p3dTime_crtTime = p3dTime_startTime; +} + +double p3dGetElapsedTime () +{ +#ifdef _WINDOWS + p3dTime_crtTime = GetTickCount(); +#else +// gettimeofday(&p3dTime_tv, NULL); +// p3dTime_crtTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); +#endif + + // Return time in seconds: + return 0;//((p3dTime_crtTime - p3dTime_startTime)/1000.0); +} + +int p3dGetElapsedTime_min () +{ +#ifdef _WINDOWS + p3dTime_crtTime = GetTickCount(); +#else +// gettimeofday(&p3dTime_tv, NULL); +// p3dTime_crtTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); +#endif + + // Return time in seconds: + p3dTime_sec = ((p3dTime_crtTime - p3dTime_startTime)/1000.0); + p3dTime_min = (int) (p3dTime_sec / 60.0); + p3dTime_sec = p3dTime_sec - p3dTime_min*60.0; + + return p3dTime_min; +} + +double p3dGetElapsedTime_sec () +{ + return p3dTime_sec; +} + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dAnisotropicDiffusionFilter.c b/pypore3d/pypore3d/P3D_Filt/p3dAnisotropicDiffusionFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..65ec2a2d546d2e2bda55f4097c8b540f8c73a244 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dAnisotropicDiffusionFilter.c @@ -0,0 +1,1716 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <pthread.h> +#include <limits.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +#define clamp(a, b1, b2) min(max(a, b1), b2); +#define absd(a) ((a)>(-a)?(a):(-a)) +#define pow2(a) (a*a) +#define pow4(a) (pow2(a)*pow2(a)) +#define n 3 +#define inv3 0.3333333333333333 +#define root3 1.7320508075688772 +#ifndef min +#define min(a,b) ((a) < (b) ? (a): (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a): (b)) +#endif + +struct options { + double T; + double dt; + double sigma; + double rho; + double C; + double m; + double alpha; + int eigenmode; + double lambda_e; + double lambda_h; + double lambda_c; +}; + +__inline int mindex3(int x, int y, int z, int sizx, int sizy) { + return z * sizx * sizy + y * sizx + x; +} + +float * mallocf(int a) { + float *ptr = (float*) calloc(a, sizeof (float)); + //if (ptr == NULL) { mexErrMsgTxt("Out of Memory"); } + return ptr; +} + +void GaussianFiltering3D_float( + float* in_im, + float* out_im, + int* dimsI, + double sigma, + double size + ) +{ + // Padded input and related dims: + float* tmp_im = NULL; + float* kernel = NULL; + + int dimx = dimsI[0]; + int dimy = dimsI[1]; + int dimz = dimsI[2]; + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct, a_rad, a_size; + double d; + double f, sum, sum_w; + + // Set kernel size and variance: + if (size < 1.0) + a_rad = 1*3; + else + a_rad = (int) (ceil(size / 2.0)*3); + a_size = 2 * a_rad + 1; + + d = (2.0 * sigma * sigma); + + + // Compute dimensions of padded volume: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + + // Initialize input: + tmp_im = (float*) malloc(a_dimx*a_dimy*a_dimz*sizeof (float)); + kernel = (float*) malloc(a_size*sizeof(float)); + + _p3dReplicatePadding3D_float(in_im, tmp_im, dimx, dimy, dimz, a_rad); + + ct = 0; + sum_w = 0.0; + + // Create gausssian kernel: + for (x = (-a_rad); x <= a_rad; x++) { + + f = (x)*(x) / d; + kernel[ct] = (float) (exp(-f)); + sum_w = sum_w + kernel[ct++]; + } + ct = 0; + + // Normalize kernel + for (x = (-a_rad); x <= a_rad; x++) + kernel[ct] = kernel[ct++]/ ((float) sum_w); + + // X-direction scanning +#pragma omp parallel for private(i, j, x, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (x = (i - a_rad); x <= (i + a_rad); x++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(x, j, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + } + } + + // Y-direction scanning +#pragma omp parallel for private(i, j, y, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (y = (j - a_rad); y <= (j + a_rad); y++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(i, y, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + } + } + + // Z-direction scanning +#pragma omp parallel for private(i, j, z, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(i, j, z, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + out_im[ I(i-a_rad, j-a_rad, k-a_rad, dimx, dimy) ] = (float) sum; + } + } + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); +} + +void gradient3Dx_float(float *I, int *sizeI, float *Ix) { + + int x, y, z; + int xp, xn, yp, yn; + int i; + int indexn, indexc, indexp; + float *Irow, *Islices; + int nSlice; + int offsetz, offset_slice; + int slice_select = 0; + int slice_select_p1 = 0; + int slice_select_p2 = 0; + + const float smoothfilter[3] = {0.187500f, 0.625000f, 0.187500f}; + const float derivafilter[3] = {-0.5f, 0.0f, 0.5f}; + + nSlice = sizeI[0] * sizeI[1]; + Islices = mallocf(4 * nSlice); + Irow = mallocf(sizeI[0]); + + //#pragma omp parallel for private (offsetz, offset_slice, y, yn, yp, indexn, indexc, indexp, x, xn, xp, i, slice_selec slice_select_p1, slice_select_p2) + for (z = 0; z < sizeI[2]; z++) { + + offsetz = nSlice*z; + offset_slice = nSlice*slice_select; + + for (y = 0; y < sizeI[1]; y++) { + /* Smooth y - direction */ + yn = max(y - 1, 0); + yp = min(y + 1, sizeI[1] - 1); + + indexn = yn * sizeI[0] + offsetz; + indexc = y * sizeI[0] + offsetz; + indexp = yp * sizeI[0] + offsetz; + + for (x = 0; x < sizeI[0]; x++) { + Irow[x] = smoothfilter[0] * I[indexn + x]; + Irow[x] += smoothfilter[1] * I[indexc + x]; + Irow[x] += smoothfilter[2] * I[indexp + x]; + } + + indexc = y * sizeI[0] + offset_slice; + /* Gradient in x - direction */ + for (x = 0; x < sizeI[0]; x++) { + xn = max(x - 1, 0); + xp = min(x + 1, sizeI[0] - 1); + Islices[indexc + x] = derivafilter[0] * Irow[xn] + derivafilter[1] * Irow[x] + derivafilter[2] * Irow[xp]; + } + } + + /* Smooth in z - direction */ + if (z == 1) /* Forward */ { + indexn = slice_select_p1*nSlice; + indexc = slice_select_p1*nSlice; + indexp = slice_select*nSlice; + for (i = 0; i < nSlice; i++) { + Ix[i] = smoothfilter[0] * Islices[i + indexn] + smoothfilter[1] * Islices[i + indexc] + smoothfilter[2] * Islices[i + indexp]; + } + } else if (z > 1) /* Central */ { + indexn = slice_select_p2*nSlice; + indexc = slice_select_p1*nSlice; + indexp = slice_select*nSlice; + offsetz = nSlice * (z - 1); + for (i = 0; i < nSlice; i++) { + Ix[offsetz + i] = smoothfilter[0] * Islices[i + indexn] + smoothfilter[1] * Islices[i + indexc] + smoothfilter[2] * Islices[i + indexp]; + } + } + + if (z == (sizeI[2] - 1)) /* Backward */ { + indexn = slice_select_p1*nSlice; + indexc = slice_select*nSlice; + indexp = slice_select*nSlice; + offsetz = nSlice*z; + for (i = 0; i < nSlice; i++) { + Ix[offsetz + i] = smoothfilter[0] * Islices[i + indexn] + smoothfilter[1] * Islices[i + indexc] + smoothfilter[2] * Islices[i + indexp]; + } + } + + slice_select_p2 = slice_select_p1; + slice_select_p1 = slice_select; + slice_select++; + if (slice_select > 3) { + slice_select = 0; + } + + } + free(Irow); + free(Islices); + +} + +void gradient3Dy_float(float *I, int *sizeI, float *Iy) { + int x, y, z; + int xp, xn, yp, yn; + int i; + int indexn, indexc, indexp; + float *Irow, *Islices; + int nSlice; + int offsetz, offset_slice; + int slice_select = 0, slice_select_p1 = 0, slice_select_p2 = 0; + + const float smoothfilter[3] = {0.187500f, 0.625000f, 0.187500f}; + const float derivafilter[3] = {-0.5f, 0.0f, 0.5f}; + + nSlice = sizeI[0] * sizeI[1]; + Islices = mallocf(4 * nSlice); + Irow = mallocf(sizeI[0]); + + for (z = 0; z < sizeI[2]; z++) { + offsetz = nSlice*z; + offset_slice = nSlice*slice_select; + + for (y = 0; y < sizeI[1]; y++) { + /* Smooth y - direction */ + yn = max(y - 1, 0); + yp = min(y + 1, sizeI[1] - 1); + + indexn = yn * sizeI[0] + offsetz; + indexc = y * sizeI[0] + offsetz; + indexp = yp * sizeI[0] + offsetz; + + for (x = 0; x < sizeI[0]; x++) { + Irow[x] = derivafilter[0] * I[indexn + x]; + Irow[x] += derivafilter[1] * I[indexc + x]; + Irow[x] += derivafilter[2] * I[indexp + x]; + } + + indexc = y * sizeI[0] + offset_slice; + /* Gradient in x - direction */ + for (x = 0; x < sizeI[0]; x++) { + xn = max(x - 1, 0); + xp = min(x + 1, sizeI[0] - 1); + Islices[indexc + x] = smoothfilter[0] * Irow[xn] + smoothfilter[1] * Irow[x] + smoothfilter[2] * Irow[xp]; + } + } + + /* Smooth in z - direction */ + if (z == 1) /* Forward */ { + indexn = slice_select_p1*nSlice; + indexc = slice_select_p1*nSlice; + indexp = slice_select*nSlice; + for (i = 0; i < nSlice; i++) { + Iy[i] = smoothfilter[0] * Islices[i + indexn] + smoothfilter[1] * Islices[i + indexc] + smoothfilter[2] * Islices[i + indexp]; + } + } else if (z > 1) /* Central */ { + indexn = slice_select_p2*nSlice; + indexc = slice_select_p1*nSlice; + indexp = slice_select*nSlice; + offsetz = nSlice * (z - 1); + for (i = 0; i < nSlice; i++) { + Iy[offsetz + i] = smoothfilter[0] * Islices[i + indexn] + smoothfilter[1] * Islices[i + indexc] + smoothfilter[2] * Islices[i + indexp]; + } + } + + if (z == (sizeI[2] - 1)) /* Backward */ { + indexn = slice_select_p1*nSlice; + indexc = slice_select*nSlice; + indexp = slice_select*nSlice; + offsetz = nSlice*z; + for (i = 0; i < nSlice; i++) { + Iy[offsetz + i] = smoothfilter[0] * Islices[i + indexn] + smoothfilter[1] * Islices[i + indexc] + smoothfilter[2] * Islices[i + indexp]; + } + } + + slice_select_p2 = slice_select_p1; + slice_select_p1 = slice_select; + slice_select++; + if (slice_select > 3) { + slice_select = 0; + } + } + free(Irow); + free(Islices); +} + +void gradient3Dz_float(float *I, int *sizeI, float *Iz) { + int x, y, z; + int xp, xn, yp, yn; + int i; + int indexn, indexc, indexp; + float *Irow, *Islices; + int nSlice; + int offsetz, offset_slice; + int slice_select = 0, slice_select_p1 = 0, slice_select_p2 = 0; + + const float smoothfilter[3] = {0.187500f, 0.625000f, 0.187500f}; + const float derivafilter[3] = {-0.5f, 0.0f, 0.5f}; + + nSlice = sizeI[0] * sizeI[1]; + Islices = mallocf(4 * nSlice); + Irow = mallocf(sizeI[0]); + + for (z = 0; z < sizeI[2]; z++) { + offsetz = nSlice*z; + offset_slice = nSlice*slice_select; + + for (y = 0; y < sizeI[1]; y++) { + /* Smooth y - direction */ + yn = max(y - 1, 0); + yp = min(y + 1, sizeI[1] - 1); + + indexn = yn * sizeI[0] + offsetz; + indexc = y * sizeI[0] + offsetz; + indexp = yp * sizeI[0] + offsetz; + + for (x = 0; x < sizeI[0]; x++) { + Irow[x] = smoothfilter[0] * I[indexn + x]; + Irow[x] += smoothfilter[1] * I[indexc + x]; + Irow[x] += smoothfilter[2] * I[indexp + x]; + } + + indexc = y * sizeI[0] + offset_slice; + /* Gradient in x - direction */ + for (x = 0; x < sizeI[0]; x++) { + xn = max(x - 1, 0); + xp = min(x + 1, sizeI[0] - 1); + Islices[indexc + x] = smoothfilter[0] * Irow[xn] + smoothfilter[1] * Irow[x] + smoothfilter[2] * Irow[xp]; + } + } + + /* Smooth in z - direction */ + if (z == 1) /* Forward */ { + indexn = slice_select_p1*nSlice; + indexc = slice_select_p1*nSlice; + indexp = slice_select*nSlice; + for (i = 0; i < nSlice; i++) { + Iz[i] = derivafilter[0] * Islices[i + indexn] + derivafilter[1] * Islices[i + indexc] + derivafilter[2] * Islices[i + indexp]; + } + } else if (z > 1) /* Central */ { + indexn = slice_select_p2*nSlice; + indexc = slice_select_p1*nSlice; + indexp = slice_select*nSlice; + offsetz = nSlice * (z - 1); + for (i = 0; i < nSlice; i++) { + Iz[offsetz + i] = derivafilter[0] * Islices[i + indexn] + derivafilter[1] * Islices[i + indexc] + derivafilter[2] * Islices[i + indexp]; + } + } + + if (z == (sizeI[2] - 1)) /* Backward */ { + indexn = slice_select_p1*nSlice; + indexc = slice_select*nSlice; + indexp = slice_select*nSlice; + offsetz = nSlice*z; + for (i = 0; i < nSlice; i++) { + Iz[offsetz + i] = derivafilter[0] * Islices[i + indexn] + derivafilter[1] * Islices[i + indexc] + derivafilter[2] * Islices[i + indexp]; + } + } + + slice_select_p2 = slice_select_p1; + slice_select_p1 = slice_select; + slice_select++; + if (slice_select > 3) { + slice_select = 0; + } + + } + free(Irow); + free(Islices); +} + +void StructureTensor3D(float *ux, float *uy, float *uz, float **J, int *dimsu, double rho) { + int npixelsu; + int i; + float *Jxx, *Jxy, *Jxz, *Jyy, *Jyz, *Jzz; /* Structure tensor */ + + npixelsu = dimsu[0] * dimsu[1] * dimsu[2]; + + Jxx = mallocf(npixelsu); + Jyy = mallocf(npixelsu); + Jzz = mallocf(npixelsu); + Jxy = mallocf(npixelsu); + Jxz = mallocf(npixelsu); + Jyz = mallocf(npixelsu); + + /* J(grad u_sigma) */ +#pragma omp parallel for + for (i = 0; i < npixelsu; i++) { + Jxx[i] = ux[i] * ux[i]; + Jxy[i] = ux[i] * uy[i]; + Jxz[i] = ux[i] * uz[i]; + Jyy[i] = uy[i] * uy[i]; + Jyz[i] = uy[i] * uz[i]; + Jzz[i] = uz[i] * uz[i]; + } + + /* Do the gaussian smoothing */ + J[0] = mallocf(npixelsu); + GaussianFiltering3D_float(Jxx, J[0], dimsu, rho, 4 * rho); + free(Jxx); + J[1] = mallocf(npixelsu); + GaussianFiltering3D_float(Jyy, J[1], dimsu, rho, 4 * rho); + free(Jyy); + J[2] = mallocf(npixelsu); + GaussianFiltering3D_float(Jzz, J[2], dimsu, rho, 4 * rho); + free(Jzz); + J[3] = mallocf(npixelsu); + GaussianFiltering3D_float(Jxy, J[3], dimsu, rho, 4 * rho); + free(Jxy); + J[4] = mallocf(npixelsu); + GaussianFiltering3D_float(Jxz, J[4], dimsu, rho, 4 * rho); + free(Jxz); + J[5] = mallocf(npixelsu); + GaussianFiltering3D_float(Jyz, J[5], dimsu, rho, 4 * rho); + free(Jyz); +} + +/* domain Java Matrix library JAMA. */ +static double hypot2(double x, double y) { + return sqrt(x * x + y * y); +} + +/* Symmetric Householder reduction to tridiagonal form. */ +static void tred2(double V[n][n], double d[n], double e[n]) { + + /* This is derived from the Algol procedures tred2 by */ + /* Bowdler, Martin, Reinsch, and Wilkinson, Handbook for */ + /* Auto. Comp., Vol.ii-Linear Algebra, and the corresponding */ + /* Fortran subroutine in EISPACK. */ + int i, j, k; + double scale; + double f, g, h; + double hh; + for (j = 0; j < n; j++) { + d[j] = V[n - 1][j]; + } + + /* Householder reduction to tridiagonal form. */ + + for (i = n - 1; i > 0; i--) { + /* Scale to avoid under/overflow. */ + scale = 0.0; + h = 0.0; + for (k = 0; k < i; k++) { + scale = scale + fabs(d[k]); + } + if (scale == 0.0) { + e[i] = d[i - 1]; + for (j = 0; j < i; j++) { + d[j] = V[i - 1][j]; + V[i][j] = 0.0; + V[j][i] = 0.0; + } + } else { + + /* Generate Householder vector. */ + + for (k = 0; k < i; k++) { + d[k] /= scale; + h += d[k] * d[k]; + } + f = d[i - 1]; + g = sqrt(h); + if (f > 0) { + g = -g; + } + e[i] = scale * g; + h = h - f * g; + d[i - 1] = f - g; + for (j = 0; j < i; j++) { + e[j] = 0.0; + } + + /* Apply similarity transformation to remaining columns. */ + + for (j = 0; j < i; j++) { + f = d[j]; + V[j][i] = f; + g = e[j] + V[j][j] * f; + for (k = j + 1; k <= i - 1; k++) { + g += V[k][j] * d[k]; + e[k] += V[k][j] * f; + } + e[j] = g; + } + f = 0.0; + for (j = 0; j < i; j++) { + e[j] /= h; + f += e[j] * d[j]; + } + hh = f / (h + h); + for (j = 0; j < i; j++) { + e[j] -= hh * d[j]; + } + for (j = 0; j < i; j++) { + f = d[j]; + g = e[j]; + for (k = j; k <= i - 1; k++) { + V[k][j] -= (f * e[k] + g * d[k]); + } + d[j] = V[i - 1][j]; + V[i][j] = 0.0; + } + } + d[i] = h; + } + + /* Accumulate transformations. */ + + for (i = 0; i < n - 1; i++) { + V[n - 1][i] = V[i][i]; + V[i][i] = 1.0; + h = d[i + 1]; + if (h != 0.0) { + for (k = 0; k <= i; k++) { + d[k] = V[k][i + 1] / h; + } + for (j = 0; j <= i; j++) { + g = 0.0; + for (k = 0; k <= i; k++) { + g += V[k][i + 1] * V[k][j]; + } + for (k = 0; k <= i; k++) { + V[k][j] -= g * d[k]; + } + } + } + for (k = 0; k <= i; k++) { + V[k][i + 1] = 0.0; + } + } + for (j = 0; j < n; j++) { + d[j] = V[n - 1][j]; + V[n - 1][j] = 0.0; + } + V[n - 1][n - 1] = 1.0; + e[0] = 0.0; +} + +/* Symmetric tridiagonal QL algorithm. */ +static void tql2(double V[n][n], double d[n], double e[n]) { + + /* This is derived from the Algol procedures tql2, by */ + /* Bowdler, Martin, Reinsch, and Wilkinson, Handbook for */ + /* Auto. Comp., Vol.ii-Linear Algebra, and the corresponding */ + /* Fortran subroutine in EISPACK. */ + + int i, j, k, l, m; + double f; + double tst1; + double eps; + int iter; + double g, p, r; + double dl1, h, c, c2, c3, el1, s, s2; + + for (i = 1; i < n; i++) { + e[i - 1] = e[i]; + } + e[n - 1] = 0.0; + + f = 0.0; + tst1 = 0.0; + eps = pow(2.0, -52.0); + for (l = 0; l < n; l++) { + + /* Find small subdiagonal element */ + + tst1 = max(tst1, fabs(d[l]) + fabs(e[l])); + m = l; + while (m < n) { + if (fabs(e[m]) <= eps * tst1) { + break; + } + m++; + } + + /* If m == l, d[l] is an eigenvalue, */ + /* otherwise, iterate. */ + + if (m > l) { + iter = 0; + do { + iter = iter + 1; /* (Could check iteration count here.) */ + /* Compute implicit shift */ + g = d[l]; + p = (d[l + 1] - g) / (2.0 * e[l]); + r = hypot2(p, 1.0); + if (p < 0) { + r = -r; + } + d[l] = e[l] / (p + r); + d[l + 1] = e[l] * (p + r); + dl1 = d[l + 1]; + h = g - d[l]; + for (i = l + 2; i < n; i++) { + d[i] -= h; + } + f = f + h; + /* Implicit QL transformation. */ + p = d[m]; + c = 1.0; + c2 = c; + c3 = c; + el1 = e[l + 1]; + s = 0.0; + s2 = 0.0; + for (i = m - 1; i >= l; i--) { + c3 = c2; + c2 = c; + s2 = s; + g = c * e[i]; + h = c * p; + r = hypot2(p, e[i]); + e[i + 1] = s * r; + s = e[i] / r; + c = p / r; + p = c * d[i] - s * g; + d[i + 1] = h + s * (c * g + s * d[i]); + /* Accumulate transformation. */ + for (k = 0; k < n; k++) { + h = V[k][i + 1]; + V[k][i + 1] = s * V[k][i] + c * h; + V[k][i] = c * V[k][i] - s * h; + } + } + p = -s * s2 * c3 * el1 * e[l] / dl1; + e[l] = s * p; + d[l] = c * p; + + /* Check for convergence. */ + } while (fabs(e[l]) > eps * tst1); + } + d[l] = d[l] + f; + e[l] = 0.0; + } + + /* Sort eigenvalues and corresponding vectors. */ + for (i = 0; i < n - 1; i++) { + k = i; + p = d[i]; + for (j = i + 1; j < n; j++) { + if (d[j] < p) { + k = j; + p = d[j]; + } + } + if (k != i) { + d[k] = d[i]; + d[i] = p; + for (j = 0; j < n; j++) { + p = V[j][i]; + V[j][i] = V[j][k]; + V[j][k] = p; + } + } + } +} + +void roots3(double d[3], double c0, double c1, double c2) { + double c2Div3, aDiv3, mbDiv2, q, magnitude, angle, cs, sn; + + /* Solve the roots of y^3 + c2 * y^2 + c1 *y + c0 */ + c2Div3 = -c2*inv3; + aDiv3 = (c1 + c2 * c2Div3) * inv3; + if (aDiv3 > 0.0) { + aDiv3 = 0.0; + } + mbDiv2 = 0.5 * (-c0 + c2Div3 * (2.0 * c2Div3 * c2Div3 - c1)); + q = mbDiv2 * mbDiv2 + aDiv3 * aDiv3*aDiv3; + if (q > 0.0) { + q = 0.0; + } + magnitude = sqrt(-aDiv3); + angle = atan2(sqrt(-q), mbDiv2) * inv3; + cs = cos(angle); + sn = sin(angle); + d[0] = c2Div3 + 2.0 * magnitude*cs; + d[1] = c2Div3 - magnitude * (cs + root3 * sn); + d[2] = c2Div3 - magnitude * (cs - root3 * sn); +} + +int fast_eigen3x3(double A[3][3], double V[3][3], double d[3]) { + const double smallv = 1e-12; + double c0, c1, c2; + int check; + double l1, l2, l3; + double t; + double a1, a2, a3, b1, b2; + double da[3]; + check = (absd(A[0][1]) < smallv)+(absd(A[0][2]) < smallv)+(absd(A[1][2]) < smallv); + if (check > 1) { + return 0; + } + + /* 0 = - det (A - yI) = y^3 + c2 * y^2 + c1 *y + c0 */ + c0 = -(A[0][0] * A[1][1] * A[2][2] + 2 * A[0][1] * A[0][2] * A[1][2] - A[0][0] * pow2(A[1][2]) - A[1][1] * pow2(A[0][2]) - A[2][2] * pow2(A[0][1])); + c1 = A[0][0] * A[1][1] - pow2(A[0][1]) + A[0][0] * A[2][2] - pow2(A[0][2]) + A[1][1] * A[2][2] - pow2(A[1][2]); + c2 = -(A[0][0] + A[1][1] + A[2][2]); + + /* Solve the roots of y^3 + c2 * y^2 + c1 *y + c0 */ + roots3(d, c0, c1, c2); + + da[0] = absd(d[0]); + da[1] = absd(d[1]); + da[2] = absd(d[2]); + /* Sort eigenvalues */ + if (da[0] >= da[1]) { + if (da[0] > da[2]) { + t = d[0]; + d[0] = d[2]; + d[2] = t; + t = da[0]; + da[0] = da[2]; + da[2] = t; + } + } else if (da[1] > da[2]) { + t = d[1]; + d[1] = d[2]; + d[2] = t; + t = da[1]; + da[1] = da[2]; + da[2] = t; + + } + + if (da[0] >= da[1]) { + t = d[0]; + d[0] = d[1]; + d[1] = t; + t = da[0]; + da[0] = da[1]; + da[1] = t; + } + + if ((da[1] - da[0]) < smallv) { + return 0; + } + if ((da[2] - da[1]) < smallv) { + return 0; + } + + /* Calculate eigen vectors */ + a1 = A[0][1] * A[1][2]; + a2 = A[0][1] * A[0][2]; + a3 = pow2(A[0][1]); + + b1 = A[0][0] - d[0]; + b2 = A[1][1] - d[0]; + V[0][0] = a1 - A[0][2] * b2; + V[1][0] = a2 - A[1][2] * b1; + V[2][0] = b1 * b2 - a3; + + b1 = A[0][0] - d[1]; + b2 = A[1][1] - d[1]; + V[0][1] = a1 - A[0][2] * b2; + V[1][1] = a2 - A[1][2] * b1; + V[2][1] = b1 * b2 - a3; + + b1 = A[0][0] - d[2]; + b2 = A[1][1] - d[2]; + V[0][2] = a1 - A[0][2] * b2; + V[1][2] = a2 - A[1][2] * b1; + V[2][2] = b1 * b2 - a3; + + + /* Eigen vector normalization */ + l1 = sqrt(pow2(V[0][0]) + pow2(V[1][0]) + pow2(V[2][0])); + l2 = sqrt(pow2(V[0][1]) + pow2(V[1][1]) + pow2(V[2][1])); + l3 = sqrt(pow2(V[0][2]) + pow2(V[1][2]) + pow2(V[2][2])); + + /* Detect fail : eigenvectors with only zeros */ + if (l1 < smallv) { + return 0; + } + if (l2 < smallv) { + return 0; + } + if (l3 < smallv) { + return 0; + } + + V[0][0] /= l1; + V[0][1] /= l2; + V[0][2] /= l3; + V[1][0] /= l1; + V[1][1] /= l2; + V[1][2] /= l3; + V[2][0] /= l1; + V[2][1] /= l2; + V[2][2] /= l3; + + /* Succes */ + return 1; +} + +void eigen_decomposition(double A[n][n], double V[n][n], double d[n]) { + double e[n]; + double da[3]; + double dt, dat; + double vet[3]; + int i, j; + + if (fast_eigen3x3(A, V, d)) { + return; + } + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + V[i][j] = A[i][j]; + } + } + tred2(V, d, e); + tql2(V, d, e); + + /* Sort the eigen values and vectors by abs eigen value */ + da[0] = absd(d[0]); + da[1] = absd(d[1]); + da[2] = absd(d[2]); + if ((da[0] >= da[1]) && (da[0] > da[2])) { + dt = d[2]; + dat = da[2]; + vet[0] = V[0][2]; + vet[1] = V[1][2]; + vet[2] = V[2][2]; + d[2] = d[0]; + da[2] = da[0]; + V[0][2] = V[0][0]; + V[1][2] = V[1][0]; + V[2][2] = V[2][0]; + d[0] = dt; + da[0] = dat; + V[0][0] = vet[0]; + V[1][0] = vet[1]; + V[2][0] = vet[2]; + } else if ((da[1] >= da[0]) && (da[1] > da[2])) { + dt = d[2]; + dat = da[2]; + vet[0] = V[0][2]; + vet[1] = V[1][2]; + vet[2] = V[2][2]; + d[2] = d[1]; + da[2] = da[1]; + V[0][2] = V[0][1]; + V[1][2] = V[1][1]; + V[2][2] = V[2][1]; + d[1] = dt; + da[1] = dat; + V[0][1] = vet[0]; + V[1][1] = vet[1]; + V[2][1] = vet[2]; + } + if (da[0] > da[1]) { + dt = d[1]; + dat = da[1]; + vet[0] = V[0][1]; + vet[1] = V[1][1]; + vet[2] = V[2][1]; + d[1] = d[0]; + da[1] = da[0]; + V[0][1] = V[0][0]; + V[1][1] = V[1][0]; + V[2][1] = V[2][0]; + d[0] = dt; + da[0] = dat; + V[0][0] = vet[0]; + V[1][0] = vet[1]; + V[2][0] = vet[2]; + } +} + +void diffusion_scheme_3D_rotation_invariance(float *u, float *u_new, int *dimsu, float *Dxx, float *Dxy, float *Dxz, float *Dyy, float *Dyz, float *Dzz, double dt_d) { + float *j1, *j2, *j3, *ud, *du; + int npixels; + float dt = 0.5f; + int i; + int x, y, z, index; + + dt = (float) dt_d; + npixels = dimsu[0] * dimsu[1] * dimsu[2]; + + j1 = mallocf(npixels); + j2 = mallocf(npixels); + j3 = mallocf(npixels); + ud = mallocf(npixels); + + /* 3 : Calculate the flux components */ + /* j1 = Dxx .* ux + Dxy .*uy + Dxz .*uz; */ + /* j2 = Dxy .* ux + Dyy .*uy + Dyz .*uz; */ + /* j3 = Dxz .* ux + Dyz .*uy + Dzz .*uz; */ + + gradient3Dx_float(u, dimsu, ud); +#pragma omp parallel for + for (i = 0; i < npixels; i++) { + j1[i] = Dxx[i] * ud[i]; + j2[i] = Dxy[i] * ud[i]; + j3[i] = Dxz[i] * ud[i]; + } + gradient3Dy_float(u, dimsu, ud); +#pragma omp parallel for + for (i = 0; i < npixels; i++) { + j1[i] += Dxy[i] * ud[i]; + j2[i] += Dyy[i] * ud[i]; + j3[i] += Dyz[i] * ud[i]; + } + gradient3Dz_float(u, dimsu, ud); +#pragma omp parallel for + for (i = 0; i < npixels; i++) { + j1[i] += Dxz[i] * ud[i]; + j2[i] += Dyz[i] * ud[i]; + j3[i] += Dzz[i] * ud[i]; + } + + /*j1(:,:,1)=0; j1(:,:,end)=0; j1(:,1,:)=0; j1(:,end,:)=0; j1(1,:,:)=0; j1(end,:,:)=0; */ + /*j2(:,:,1)=0; j2(:,:,end)=0; j2(:,1,:)=0; j2(:,end,:)=0; j2(1,:,:)=0; j2(end,:,:)=0; */ + /*j3(:,:,1)=0; j3(:,:,end)=0; j3(:,1,:)=0; j3(:,end,:)=0; j3(1,:,:)=0; j3(end,:,:)=0; */ + +#pragma omp parallel for private (x, index) + for (y = 0; y < dimsu[1]; y++) { + for (x = 0; x < dimsu[0]; x++) { + index = mindex3(x, y, 0, dimsu[0], dimsu[1]); + j1[index] = 0; + j2[index] = 0; + j3[index] = 0; + index = mindex3(x, y, dimsu[2] - 1, dimsu[0], dimsu[1]); + j1[index] = 0; + j2[index] = 0; + j3[index] = 0; + } + } + +#pragma omp parallel for private(x,index) + for (z = 0; z < dimsu[2]; z++) { + for (x = 0; x < dimsu[0]; x++) { + index = mindex3(x, 0, z, dimsu[0], dimsu[1]); + j1[index] = 0; + j2[index] = 0; + j3[index] = 0; + index = mindex3(x, dimsu[1] - 1, z, dimsu[0], dimsu[1]); + j1[index] = 0; + j2[index] = 0; + j3[index] = 0; + } + } + +#pragma omp parallel for private(y,index) + for (z = 0; z < dimsu[2]; z++) { + for (y = 0; y < dimsu[1]; y++) { + index = mindex3(0, y, z, dimsu[0], dimsu[1]); + j1[index] = 0; + j2[index] = 0; + j3[index] = 0; + index = mindex3(dimsu[0] - 1, y, z, dimsu[0], dimsu[1]); + j1[index] = 0; + j2[index] = 0; + j3[index] = 0; + } + } + + /* 4 : Calculate ... by means of the optimized derivative filters */ + /* du = derivatives(j1,'x')+derivatives(j2,'y')+derivatives(j3,'z'); */ + du = mallocf(npixels); + gradient3Dx_float(j1, dimsu, du); + gradient3Dy_float(j2, dimsu, ud); +#pragma omp parallel for + for (i = 0; i < npixels; i++) { + du[i] += ud[i]; + } + gradient3Dz_float(j3, dimsu, ud); +#pragma omp parallel for + for (i = 0; i < npixels; i++) { + du[i] += ud[i]; + } + + /* Free memory */ + free(j1); + free(j2); + free(j3); + free(ud); + + /* 5 : Update in an explicit way. */ + /* u=u+du*dt; */ + +#pragma omp parallel for + for (i = 0; i < npixels; i++) { + u_new[i] += u[i] + du[i] * dt; + } + + /* Free memory */ + free(du); +} + +void StructureTensor2DiffusionTensorThread(float **Args) { + + /* Matrices of Eigenvector calculation */ + double Ma[3][3]; + double Davec[3][3]; + double Daeig[3]; + + /* Eigenvector and eigenvalues as scalars */ + double mu1, mu2, mu3, v1x, v1y, v1z, v2x, v2y, v2z, v3x, v3y, v3z; + + /* Magnitude of gradient */ + float *gradA; + + /* Amplitudes of diffustion tensor */ + double lambda1, lambda2, lambda3; + double lambdac1, lambdac2, lambdac3; + double lambdae1, lambdae2, lambdae3; + + /* Eps for finite values */ + const float eps = (float) 1e-20; + + /* Loop variable */ + int i; + + /* Number of pixels */ + int npixels = 1; + + /* The diffusion tensors and structure tensors */ + float *Jxx, *Jxy, *Jxz, *Jyy, *Jyz, *Jzz; + float *Dxx, *Dxy, *Dxz, *Dyy, *Dyz, *Dzz; + + int dimsu[3]; + float *dimsu_f, *constants_f, *Nthreads_f, *ThreadID_f; + + /* Number of threads */ + int ThreadOffset, Nthreads; + + /* Constants */ + double C, m, alpha, lambda_h, lambda_e, lambda_c; + + /* Choice of eigenvalue equation */ + int eigenmode; + + /* Temporary variables */ + double di, epsilon, xi; + + //float **Args = (float**) Args_void; + + Jxx = Args[0]; + Jxy = Args[1]; + Jxz = Args[2]; + Jyy = Args[3]; + Jyz = Args[4]; + Jzz = Args[5]; + Dxx = Args[6]; + Dxy = Args[7]; + Dxz = Args[8]; + Dyy = Args[9]; + Dyz = Args[10]; + Dzz = Args[11]; + gradA = Args[12]; + dimsu_f = Args[13]; + constants_f = Args[14]; + ThreadID_f = Args[15]; + Nthreads_f = Args[16]; + + for (i = 0; i < 3; i++) { + dimsu[i] = (int) dimsu_f[i]; + } + eigenmode = (int) constants_f[0]; + C = (double) constants_f[1]; + m = (double) constants_f[2]; + alpha = (double) constants_f[3]; + lambda_e = (double) constants_f[4]; + lambda_h = (double) constants_f[5]; + lambda_c = (double) constants_f[6]; + + + ThreadOffset = (int) ThreadID_f[0]; + Nthreads = (int) Nthreads_f[0]; + + npixels = dimsu[0] * dimsu[1] * dimsu[2]; + + for (i = ThreadOffset; i < npixels; i = i + Nthreads) { + /* Calculate eigenvectors and values of local Hessian */ + Ma[0][0] = (double) Jxx[i] + eps; + Ma[0][1] = (double) Jxy[i]; + Ma[0][2] = (double) Jxz[i]; + Ma[1][0] = (double) Jxy[i]; + Ma[1][1] = (double) Jyy[i] + eps; + Ma[1][2] = (double) Jyz[i]; + Ma[2][0] = (double) Jxz[i]; + Ma[2][1] = (double) Jyz[i]; + Ma[2][2] = (double) Jzz[i] + eps; + eigen_decomposition(Ma, Davec, Daeig); + + /* Convert eigenvector and eigenvalue matrices back to scalar variables */ + mu1 = Daeig[2]; + mu2 = Daeig[1]; + mu3 = Daeig[0]; + v1x = Davec[0][0]; + v1y = Davec[1][0]; + v1z = Davec[2][0]; + v2x = Davec[0][1]; + v2y = Davec[1][1]; + v2z = Davec[2][1]; + v3x = Davec[0][2]; + v3y = Davec[1][2]; + v3z = Davec[2][2]; + + /* Scaling of diffusion tensor */ + if (eigenmode == 0) /* Weickert line shaped */ { + di = (mu1 - mu3); + if ((di < eps) && (di>-eps)) { + lambda1 = alpha; + } else { + lambda1 = alpha + (1.0 - alpha) * exp(-C / pow(di, (2.0 * m))); + } + lambda2 = alpha; + lambda3 = alpha; + } else if (eigenmode == 1) /* Weickert plane shaped */ { + di = (mu1 - mu3); + if ((di < eps) && (di>-eps)) { + lambda1 = alpha; + } else { + lambda1 = alpha + (1.0 - alpha) * exp(-C / pow(di, (2.0 * m))); + } + di = (mu2 - mu3); + if ((di < eps) && (di>-eps)) { + lambda2 = alpha; + } else { + lambda2 = alpha + (1.0 - alpha) * exp(-C / pow(di, (2.0 * m))); + } + lambda3 = alpha; + } else if (eigenmode == 2) /* EED */ { + if (gradA[i] < eps) { + lambda3 = 1; + } else { + lambda3 = 1 - exp(-3.31488 / pow4(gradA[i] / pow2(lambda_e))); + } + lambda2 = 1; + lambda1 = 1; + } else if (eigenmode == 3) /* CED */ { + lambda3 = alpha; + lambda2 = alpha; + if ((mu2 < eps) && (mu2>-eps)) { + lambda1 = 1; + } else if ((mu3 < eps) && (mu3>-eps)) { + lambda1 = 1; + } else { + lambda1 = alpha + (1.0 - alpha) * exp(-0.6931 * pow2(lambda_c) / pow4(mu2 / (alpha + mu3))); + } + } else if (eigenmode == 4) /* Hybrid Diffusion with Continous Switch */ { + if (gradA[i] < eps) { + lambdae3 = 1; + } else { + lambdae3 = 1 - exp(-3.31488 / pow4(gradA[i] / pow2(lambda_e))); + } + lambdae2 = 1; + lambdae1 = 1; + + lambdac3 = alpha; + lambdac2 = alpha; + if ((mu2 < eps) && (mu2>-eps)) { + lambdac1 = 1; + } else if ((mu3 < eps) && (mu3>-eps)) { + lambdac1 = 1; + } else { + lambdac1 = alpha + (1.0 - alpha) * exp(-0.6931 * pow2(lambda_c) / pow4(mu2 / (alpha + mu3))); + } + + xi = ((mu1 / (alpha + mu2)) - (mu2 / (alpha + mu3))); + di = 2.0 * pow4(lambda_h); + epsilon = exp(mu2 * (pow2(lambda_h)*(xi - absd(xi)) - 2.0 * mu3) / di); + + + lambda1 = (1 - epsilon) * lambdac1 + epsilon * lambdae1; + lambda2 = (1 - epsilon) * lambdac2 + epsilon * lambdae2; + lambda3 = (1 - epsilon) * lambdac3 + epsilon * lambdae3; + } + + + + /* Construct the diffusion tensor */ + Dxx[i] = (float) (lambda1 * v1x * v1x + lambda2 * v2x * v2x + lambda3 * v3x * v3x); + Dyy[i] = (float) (lambda1 * v1y * v1y + lambda2 * v2y * v2y + lambda3 * v3y * v3y); + Dzz[i] = (float) (lambda1 * v1z * v1z + lambda2 * v2z * v2z + lambda3 * v3z * v3z); + Dxy[i] = (float) (lambda1 * v1x * v1y + lambda2 * v2x * v2y + lambda3 * v3x * v3y); + Dxz[i] = (float) (lambda1 * v1x * v1z + lambda2 * v2x * v2z + lambda3 * v3x * v3z); + Dyz[i] = (float) (lambda1 * v1y * v1z + lambda2 * v2y * v2z + lambda3 * v3y * v3z); + } + + /* explicit end thread, helps to ensure proper recovery of resources allocated for the thread */ + + pthread_exit(NULL); + +} + +void StructureTensor2DiffusionTensor(float *Jxx, float *Jxy, float *Jxz, float *Jyy, float *Jyz, float *Jzz, float *Dxx, float *Dxy, float *Dxz, float *Dyy, float *Dyz, float *Dzz, float *gradA, int *dimsu, int eigenmode, double C, double m, double alpha, double lambda_e, double lambda_h, double lambda_c) { + + + /* ID of Threads */ + float **ThreadID; + float *ThreadID1; + float ***ThreadArgs; + float **ThreadArgs1; + float Nthreads_f[1] = {0}; + float dimsu_f[3]; + float constants_f[7]; + int Nthreads; + int i; + + pthread_t *ThreadList; + + Nthreads = 1;//omp_get_num_procs( ); //amal + Nthreads_f[0] = (float) Nthreads; + for (i = 0; i < 3; i++) { + dimsu_f[i] = (float) dimsu[i]; + } + constants_f[0] = (float) eigenmode; + constants_f[1] = (float) C; + constants_f[2] = (float) m; + constants_f[3] = (float) alpha; + constants_f[4] = (float) lambda_e; + constants_f[5] = (float) lambda_h; + constants_f[6] = (float) lambda_c; + + /* Reserve room for handles of threads in ThreadList */ + ThreadList = (pthread_t*) malloc(Nthreads * sizeof ( pthread_t)); + ThreadID = (float **) malloc(Nthreads * sizeof (float *)); + ThreadArgs = (float ***) malloc(Nthreads * sizeof (float **)); + + for (i = 0; i < Nthreads; i++) { + /* Make Thread ID */ + ThreadID1 = (float *) malloc(1 * sizeof (float)); + ThreadID1[0] = (float) i; + ThreadID[i] = ThreadID1; + + /* Make Thread Structure */ + ThreadArgs1 = (float **) malloc(17 * sizeof ( float *)); + ThreadArgs1[0] = Jxx; + ThreadArgs1[1] = Jxy; + ThreadArgs1[2] = Jxz; + ThreadArgs1[3] = Jyy; + ThreadArgs1[4] = Jyz; + ThreadArgs1[5] = Jzz; + ThreadArgs1[6] = Dxx; + ThreadArgs1[7] = Dxy; + ThreadArgs1[8] = Dxz; + ThreadArgs1[9] = Dyy; + ThreadArgs1[10] = Dyz; + ThreadArgs1[11] = Dzz; + ThreadArgs1[12] = gradA; + ThreadArgs1[13] = dimsu_f; + ThreadArgs1[14] = constants_f; + ThreadArgs1[15] = ThreadID[i]; + ThreadArgs1[16] = Nthreads_f; + + /* Start a Thread */ + ThreadArgs[i] = ThreadArgs1; + pthread_create((pthread_t*) & ThreadList[i], NULL, (void *) &StructureTensor2DiffusionTensorThread, ThreadArgs[i]); + + } + + for (i = 0; i < Nthreads; i++) { + pthread_join(ThreadList[i], NULL); + } + + for (i = 0; i < Nthreads; i++) { + free(ThreadArgs[i]); + free(ThreadID[i]); + } + + free(ThreadArgs); + free(ThreadID); + free(ThreadList); + +} + +int _p3dAnisotropicDiffusionFilter3D_float( + float* u, + float* u_new, + const int dimx, + const int dimy, + const int dimz, + const double lambda, + const int m, + const double sigma, + const int iter, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + /* Options structure variables */ + struct options Options; + + /* Size input image volume */ + int ndimsu; + int dimsu[3]; + int npixelsu; + int i, ct; + + float *usigma; /* Gaussian filtered image volume */ + float *ux, *uy, *uz, *gradA; /* Gradients of smoothed image */ + float *Jxx, *Jxy, *Jxz, *Jyy, *Jyz, *Jzz, *J[6]; /* Structure tensor */ + float *Dxx, *Dxy, *Dxz, *Dyy, *Dyz, *Dzz; /* Diffusion tensor */ + + ndimsu = 3; + dimsu[0] = dimx; + dimsu[1] = dimy; + dimsu[2] = dimz; + npixelsu = dimsu[0] * dimsu[1] * dimsu[2]; + + Options.T = iter; // ok... call it iteration + Options.dt = 0.24; // below 0.25 for stability //fix + Options.sigma = sigma; // ok... call it sigma + Options.rho = 1.0; // fix + Options.C = 1e-10; // fix + Options.m = m; // ok... call it mu + Options.alpha = 0.01; // fix + Options.eigenmode = 2; // only 4 and 2 with standard parameters below!!!!!!!!! //fix on 2 + Options.lambda_e = lambda; // ok... call it lambda + Options.lambda_h = 0.01; //delete + Options.lambda_c = 0.5; //delete + + for (ct = 0; ct < Options.T; ct++) { + + memset(u_new, 0, dimx * dimy * dimz * sizeof (float)); + + /* Gaussian Filtering of input image volume*/ + usigma = mallocf(npixelsu); + //wr_log("Eseguo il gaussian filtering 3D..."); + GaussianFiltering3D_float(u, usigma, dimsu, Options.sigma, 4 * Options.sigma); + //wr_log("Done!\n"); + + /* Calculate the image gradients of the smoothed image volume */ + ux = mallocf(npixelsu); + uy = mallocf(npixelsu); + uz = mallocf(npixelsu); + + //wr_log("Eseguo il calcolo dei gradienti..."); + gradient3Dx_float(usigma, dimsu, ux); + //wr_log("Done x!\n"); + gradient3Dy_float(usigma, dimsu, uy); + //wr_log("Done y!\n"); + gradient3Dz_float(usigma, dimsu, uz); + //wr_log("Done z!\n"); + + /* remove usigma from memory */ + free(usigma); + + /* Compute the 3D structure tensors J of the image */ + // wr_log("Calcolato StructureTensor3D.\n"); + StructureTensor3D(ux, uy, uz, J, dimsu, Options.rho); + //wr_log("Done!\n"); + + Jxx = J[0]; + Jyy = J[1]; + Jzz = J[2]; + Jxy = J[3]; + Jxz = J[4]; + Jyz = J[5]; + + /* calculate gradient magnitude */ + gradA = mallocf(npixelsu); + +#pragma omp parallel for + for (i = 0; i < npixelsu; i++) { + gradA[i] = ux[i] * ux[i] + uy[i] * uy[i] + uz[i] * uz[i]; + } + + /* remove gradients from memory */ + free(ux); + free(uy); + free(uz); + + /* Structure to Diffusion Tensor Weickert */ + Dxx = mallocf(npixelsu); + Dyy = mallocf(npixelsu); + Dzz = mallocf(npixelsu); + Dxy = mallocf(npixelsu); + Dxz = mallocf(npixelsu); + Dyz = mallocf(npixelsu); + + StructureTensor2DiffusionTensor(Jxx, Jxy, Jxz, Jyy, Jyz, Jzz, Dxx, Dxy, Dxz, Dyy, Dyz, Dzz, gradA, dimsu, Options.eigenmode, Options.C, Options.m, Options.alpha, Options.lambda_e, Options.lambda_h, Options.lambda_c); + //wr_log("Calcolato StructureTensor2DiffusionTensor.\n"); + /* Gradient Magnitude no longer needed */ + free(gradA); + /* remove structure tensor from memory */ + free(Jxx); + free(Jyy); + free(Jzz); + free(Jxy); + free(Jxz); + free(Jyz); + + /* Perform the image diffusion */ + diffusion_scheme_3D_rotation_invariance(u, u_new, dimsu, Dxx, Dxy, Dxz, Dyy, Dyz, Dzz, Options.dt); + //wr_log("Calcolato diffusion_scheme_3D_rotation_invariance.\n"); + + /* remove diffusion tensor from memory */ + free(Dxx); + free(Dyy); + free(Dzz); + free(Dxy); + free(Dxz); + free(Dyz); + + // Prepare for next step: + memcpy(u, u_new, dimx * dimy * dimz * sizeof (float)); + } + + return P3D_SUCCESS; +} + +int p3dAnisotropicDiffusionFilter3D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int m, + const double lambda, + const double sigma, + const int iter, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + float* u = NULL; + float* u_new = NULL; + + //float u_min = UCHAR_MAX; + //float u_max = 0; + + //float u_new_min = UCHAR_MAX; + //float u_new_max = 0; + + int ct, i, j, k; + const int a_rad = 3; + int a_dimx, a_dimy, a_dimz; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying anisotropic diffusion filter..."); + wr_log("\tLambda: %0.3f.", lambda); + wr_log("\tMu: %d.", m); + wr_log("\tSigma: %0.3f.", sigma); + wr_log("\tNumber of iterations: %d.", iter); + } + + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Allocate memory: + P3D_MEM_TRY(u = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + P3D_MEM_TRY(u_new = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + + _p3dReplicatePadding3D_uchar2float(in_im, u, dimx, dimy, dimz, a_rad); + + // Convert the input: +#pragma omp parallel for + for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) { + u[ct] = u[ct] / UCHAR_MAX; + //u_min = MIN(u_min, u[ct]); + //u_max = MAX(u_max, u[ct]); + } + + // Call the 32 bit version: + P3D_TRY(_p3dAnisotropicDiffusionFilter3D_float(u, + u_new, + a_dimx, + a_dimy, + a_dimz, + lambda, + m, + sigma, + iter, + wr_log, + wr_progress + )); + + // Convert the input: + /*for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) { + u_new_min = MIN(u_new_min, u_new[ct]); + u_new_max = MAX(u_new_max, u_new[ct]); + }*/ + + + // Rescale output: +#pragma omp parallel for private(i,j) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + // out_im[I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy)] = (unsigned char) + //((u_new[I(i, j, k, a_dimx, a_dimy)] - u_new_min) / ( + //(u_new_max - u_new_min))*(u_max - u_min)) + u_min; + if (u_new[ I(i, j, k, a_dimx, a_dimy)] >= 1.0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = UCHAR_MAX; + else if (u_new[ I(i, j, k, a_dimx, a_dimy)] <= 0.0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = 0; + else + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = + (unsigned char) (u_new[ I(i, j, k, a_dimx, a_dimy)] * UCHAR_MAX); + } + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Anisotropic diffusion filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (u != NULL) free(u); + if (u_new != NULL) free(u_new); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (u != NULL) free(u); + if (u_new != NULL) free(u_new); + + // Return error: + return P3D_ERROR; + +} + +int p3dAnisotropicDiffusionFilter3D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int m, + const double lambda, + const double sigma, + const int iter, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + float* u = NULL; + float* u_new = NULL; + + //float u_min = UCHAR_MAX; + //float u_max = 0; + + //float u_new_min = UCHAR_MAX; + //float u_new_max = 0; + + int ct, i, j, k; + const int a_rad = 1; + int a_dimx, a_dimy, a_dimz; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying anisotropic diffusion filter..."); + wr_log("\tLambda: %0.3f", lambda); + wr_log("\tMu: %d.", m); + wr_log("\tSigma: %0.3f.", sigma); + wr_log("\tNumber of iterations: %d.", iter); + } + + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Allocate memory: + P3D_MEM_TRY(u = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + P3D_MEM_TRY(u_new = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + + P3D_TRY(_p3dReplicatePadding3D_ushort2float(in_im, u, dimx, dimy, dimz, a_rad)); + + // Convert the input: +#pragma omp parallel for + for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) { + u[ct] = u[ct] / USHRT_MAX; + //u_min = MIN(u_min, u[ct]); + //u_max = MAX(u_max, u[ct]); + } + + // Call the 32 bit version: + P3D_TRY(_p3dAnisotropicDiffusionFilter3D_float(u, + u_new, + a_dimx, + a_dimy, + a_dimz, + lambda, + m, + sigma, + iter, + wr_log, + wr_progress + )); + + // Convert the input: + /*for (ct = 0; ct < (a_dimx * a_dimy * a_dimz); ct++) { + u_new_min = MIN(u_new_min, u_new[ct]); + u_new_max = MAX(u_new_max, u_new[ct]); + }*/ + + // Rescale output: +#pragma omp parallel for private(i,j) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + // out_im[I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy)] = (unsigned char) + //((u_new[I(i, j, k, a_dimx, a_dimy)] - u_new_min) / ( + //(u_new_max - u_new_min))*(u_max - u_min)) + u_min; + if (u_new[ I(i, j, k, a_dimx, a_dimy)] >= 1.0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = USHRT_MAX; + else if (u_new[ I(i, j, k, a_dimx, a_dimy)] <= 0.0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = 0; + else + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = + (unsigned short) (u_new[ I(i, j, k, a_dimx, a_dimy)] * USHRT_MAX); + } + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Anisotropic diffusion filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (u != NULL) free(u); + if (u_new != NULL) free(u_new); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (u != NULL) free(u); + if (u_new != NULL) free(u_new); + + // Return error: + return P3D_ERROR; + +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dBilateralFilter.c b/pypore3d/pypore3d/P3D_Filt/p3dBilateralFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..b4fc7e3903869c8a2081917f94d0b82fc4e9599b --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dBilateralFilter.c @@ -0,0 +1,271 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +int p3dBilateralFilter3D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + const double sigma_d, + const double sigma_r, + const int iter, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Temporary padded input-volume: + unsigned char* tmp_im; + unsigned char* tmp_im2; + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct; + + // Variables for computing gaussian kernel: + int a_rad; + + // Variables for filter management: + double w, sum_f, sum_fi; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying bilateral filter..."); + wr_log("\tKernel size: %d.", size); + wr_log("\tDomain sigma: %0.3f.", sigma_d); + wr_log("\tRange sigma: %0.3f.", sigma_r); + wr_log("\tNumber of iterations: %d.", iter); + } + + + // Init variables: + a_rad = size / 2; // integer division + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Try to allocate memory: + P3D_MEM_TRY(tmp_im = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + P3D_MEM_TRY(tmp_im2 = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + P3D_TRY(p3dReplicatePadding3D_8(in_im, tmp_im, dimx, dimy, dimz, a_rad, NULL, NULL)); + + for (ct = 0; ct < iter; ct++) { + // Volume scanning: + #pragma omp parallel for private(i, j, x, y, z, sum_f, sum_fi, w) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + // Init variables: + sum_f = 0.0; + sum_fi = 0.0; + + // Convolve (i,j,k) voxel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + for (y = (j - a_rad); y <= (j + a_rad); y++) { + for (x = (i - a_rad); x <= (i + a_rad); x++) { + // Gaussian intensity weights: + w = exp(-( + (tmp_im[ I(x, y, z, a_dimx, a_dimy) ] - tmp_im [ I(i, j, k, a_dimx, a_dimy) ])* + (tmp_im[ I(x, y, z, a_dimx, a_dimy) ] - tmp_im [ I(i, j, k, a_dimx, a_dimy) ]) / + (2.0 * sigma_r * sigma_r)) + - ((x - i)*(x - i) + (y - j)*(y - j) + (z - k)*(z - k)) / (2.0 * sigma_d * sigma_d) + ); + + // Bilateral filter response: + sum_f += w; + sum_fi += w * tmp_im[ I(x, y, z, a_dimx, a_dimy) ]; + } + } + } + + // Set out voxel: + if ((sum_fi / sum_f) < 0) + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = 0; + else if ((sum_fi / sum_f) > UCHAR_MAX) + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = UCHAR_MAX; + else + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = (unsigned char) (sum_fi / sum_f); + } + } + } + + // Prepare for next iteration: + memcpy(tmp_im, tmp_im2, a_dimx * a_dimy * a_dimz * sizeof (unsigned char)); + } + + // Crop image: + P3D_TRY(p3dCrop3D_8(tmp_im2, out_im, a_dimx, a_dimy, a_dimz, a_rad, NULL, NULL)); + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Bilateral filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + // Return error: + return P3D_ERROR; + +} + +int p3dBilateralFilter3D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + const double sigma_d, + const double sigma_r, + const int iter, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Temporary padded input-volume: + unsigned short* tmp_im; + unsigned short* tmp_im2; + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct; + + // Variables for computing gaussian kernel: + int a_rad; + + // Variables for filter management: + double w, sum_f, sum_fi; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying bilateral filter..."); + wr_log("\tKernel size: %d.", size); + wr_log("\tDomain sigma: %0.3f.", sigma_d); + wr_log("\tRange sigma: %0.3f.", sigma_r); + wr_log("\tNumber of iterations: %d.", iter); + } + + + // Init variables: + a_rad = size / 2; // integer division + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Try to allocate memory: + P3D_MEM_TRY(tmp_im = (unsigned short*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned short))); + P3D_MEM_TRY(tmp_im2 = (unsigned short*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned short))); + P3D_TRY(p3dReplicatePadding3D_16(in_im, tmp_im, dimx, dimy, dimz, a_rad, NULL, NULL)); + + for (ct = 0; ct < iter; ct++) { + // Volume scanning: + #pragma omp parallel for private(i, j, x, y, z, sum_f, sum_fi, w) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + // Init variables: + sum_f = 0.0; + sum_fi = 0.0; + + // Convolve (i,j,k) voxel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + for (y = (j - a_rad); y <= (j + a_rad); y++) { + for (x = (i - a_rad); x <= (i + a_rad); x++) { + // Gaussian intensity weights: + w = exp(-( + (tmp_im[ I(x, y, z, a_dimx, a_dimy) ] - tmp_im [ I(i, j, k, a_dimx, a_dimy) ])* + (tmp_im[ I(x, y, z, a_dimx, a_dimy) ] - tmp_im [ I(i, j, k, a_dimx, a_dimy) ]) / + (2.0 * sigma_r * sigma_r)) + - ((x - i)*(x - i) + (y - j)*(y - j) + (z - k)*(z - k)) / (2.0 * sigma_d * sigma_d) + ); + + // Bilateral filter response: + sum_f += w; + sum_fi += w * tmp_im[ I(x, y, z, a_dimx, a_dimy) ]; + } + } + } + + // Set out voxel: + if ((sum_fi / sum_f) < 0) + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = 0; + else if ((sum_fi / sum_f) > USHRT_MAX) + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = USHRT_MAX; + else + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = (unsigned short) (sum_fi / sum_f); + } + } + } + + // Prepare for next iteration: + memcpy(tmp_im, tmp_im2, a_dimx * a_dimy * a_dimz * sizeof (unsigned short)); + } + + // Crop image: + P3D_TRY(p3dCrop3D_16(tmp_im2, out_im, a_dimx, a_dimy, a_dimz, a_rad, NULL, NULL)); + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Bilateral filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + // Return error: + return P3D_ERROR; + +} + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dBoinHaibelRingRemover.c b/pypore3d/pypore3d/P3D_Filt/p3dBoinHaibelRingRemover.c new file mode 100644 index 0000000000000000000000000000000000000000..83e647c1afba044957be1ecc17baf843e424bb5c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dBoinHaibelRingRemover.c @@ -0,0 +1,318 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <limits.h> +#include <omp.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" +#include "Common/p3dRingRemoverCommon.h" + +#define EPS 0.0001 + +#define P3DBOINHAIBELRINGREMOVER_ELEM_SWAP(a,b) { register double t=(a);(a)=(b);(b)=t; } +#define P3DBOINHAIBELRINGREMOVER_MEDIAN(a,n) _p3dBoinHaibelRingRemover_kth_smallest(a,n,((n)/2)) + +double _p3dBoinHaibelRingRemover_kth_smallest(double* a, int n, int k) { + register int i, j, l, m; + register double x; + + l = 0; + m = n - 1; + while (l < m) { + x = a[k]; + i = l; + j = m; + do { + while (a[i] < x) i++; + while (x < a[j]) j--; + if (i <= j) { + P3DBOINHAIBELRINGREMOVER_ELEM_SWAP(a[i], a[j]); + i++; + j--; + } + } while (i <= j); + if (j < k) l = i; + if (k < i) m = j; + } + return a[k]; +} + + +// This procedure removes ring artifacts from CT images. + +int p3dBoinHaibelRingRemover2D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const double centerX, + const double centerY, + const int winsize, // IN: width of the moving average + const int iterations, // IN: filter can be re-iterated + const double precision, + int (*wr_log)(const char*, ...) + ) +{ + int i, j; // generic counters + int k, tmp_k; + int sum; + + double tmp_val; + + // Polar images: + unsigned char* p_in_im; // no need for malloc + unsigned char* c_out_im; // no need for malloc + + int p_dim, ct, it_ct; + + // Artifacts vectors: + double* glob_art; + double* v; + + // STEP2: Transform in polar coordinates. Remember that memory allocation + // for output images is performed within the procedure. + + p3dCartesian2polar_8(in_im, &p_in_im, dimx, dimy, centerX, centerY, precision, &p_dim); + + // STEP3: Artifact template selection. + + // Allocate dynamic memory: + + // Now that we know the dimensions of polar image we can allocate + // the global artifacts correction vector: + glob_art = (double*) calloc(p_dim, sizeof (double)); + + // Allocate memory for the column: + // v = (double*) malloc(row_ct * sizeof (double)); + + for (it_ct = 0; it_ct < iterations; it_ct++) { + // Compute median for each column and store the value in the + // artifact vector: + #pragma omp parallel for private(k, sum) + for (j = 0; j < p_dim; j++) { + // Fill the column array: + sum = 0; + + for (k = 0; k < p_dim; k++) { + sum = sum + p_in_im[ I2(j, k, p_dim) ]; + } + + // Put the sum in artifact vector: + glob_art[j] = sum; + } + + // Free memory for the column: + // Cycle for each element in line to compute moving average: + #pragma omp parallel for private(v, ct, k, tmp_k) + for (j = 0; j < p_dim; j++) { + /*sum = 0; + + // Moving average: + for (k = ( j - (win_size / 2)); k < ( j + (win_size / 2)); k++) + { + tmp_k = k; + + // Replicate padding: + if (tmp_k < 0) tmp_k = 0; + if (tmp_k > (p_dim - 1)) tmp_k = p_dim - 1; + + sum = sum + glob_art[ tmp_k ]; + } + + // Moving average: + glob_art[j] = (sum / win_size) / (glob_art[j] + EPS);*/ + + // Allocate memory for the column: + v = (double*) malloc(winsize * sizeof (double)); + ct = 0; + + for (k = (j - (winsize / 2)); k < (j + (winsize / 2)); k++) { + tmp_k = k; + + // Replicate padding: + if (tmp_k < 0) tmp_k = 0; + if (tmp_k > (p_dim - 1)) tmp_k = p_dim - 1; + + v[ct++] = glob_art[ tmp_k ]; + } + + glob_art[j] = (P3DBOINHAIBELRINGREMOVER_MEDIAN(v, winsize) / (glob_art[j] + EPS)); + + // Free memory for the column: + free(v); + } + + + // The artifact template vector is multiplied for each + // row of the polar image P: + #pragma omp parallel for private(i, tmp_val) + for (j = 0; j < p_dim; j++) { + for (i = 0; i < p_dim; i++) { + // Take care of intensity bounds: + tmp_val = p_in_im[ I2(i, j, p_dim) ] * glob_art[i]; + + if (tmp_val < 0.0) tmp_val = 0.0; + if (tmp_val > UCHAR_MAX) tmp_val = UCHAR_MAX; + + p_in_im[ I2(i, j, p_dim) ] = (unsigned char) tmp_val; + } + } + } + + //p3dWriteRaw8 ( p_in_im, "C:\\p_out_im.raw", p_dim, p_dim, 1, printf ); + + // Return in cartesian coordinates: + p3dPolar2cartesian_8(p_in_im, &c_out_im, p_dim, centerX, centerY, dimx, dimy); + + // Copy C_OUT_IM to the output of the procedure: + memcpy(out_im, c_out_im, dimx * dimy * sizeof (unsigned char)); + + // Free memory: + free(glob_art); + + free(p_in_im); + free(c_out_im); + + return P3D_SUCCESS; + +} + +int p3dBoinHaibelRingRemover2D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const double centerX, + const double centerY, + const int winsize, // IN: width of the moving average + const int iterations, // IN: filter can be re-iterated + const double precision, + int (*wr_log)(const char*, ...) + ) +{ + int i, j; // generic counters + int k, tmp_k; + int sum; + + double tmp_val; + + // Polar images: + unsigned short* p_in_im; // no need for malloc + unsigned short* c_out_im; // no need for malloc + + int p_dim, ct, it_ct; + + // Artifacts vectors: + double* glob_art; + double* v; + + // STEP2: Transform in polar coordinates. Remember that memory allocation + // for output images is performed within the procedure. + + p3dCartesian2polar_16(in_im, &p_in_im, dimx, dimy, centerX, centerY, precision, &p_dim); + + // STEP3: Artifact template selection. + + // Allocate dynamic memory: + + // Now that we know the dimensions of polar image we can allocate + // the global artifacts correction vector: + glob_art = (double*) calloc(p_dim, sizeof (double)); + + // Allocate memory for the column: + // v = (double*) malloc(row_ct * sizeof (double)); + + // Compute median for each column and store the value in the + // artifact vector: + + for (it_ct = 0; it_ct < iterations; it_ct++) { + #pragma omp parallel for private(k, sum) + for (j = 0; j < p_dim; j++) { + // Fill the column array: + sum = 0; + + for (k = 0; k < p_dim; k++) { + sum = sum + p_in_im[ I2(j, k, p_dim) ]; + } + + // Put the sum in artifact vector: + glob_art[j] = sum; + } + + // Free memory for the column: + // Cycle for each element in line to compute moving average: + #pragma omp parallel for private(v, ct, k, tmp_k) + for (j = 0; j < p_dim; j++) { + /*sum = 0; + + // Moving average: + for (k = ( j - (win_size / 2)); k < ( j + (win_size / 2)); k++) + { + tmp_k = k; + + // Replicate padding: + if (tmp_k < 0) tmp_k = 0; + if (tmp_k > (p_dim - 1)) tmp_k = p_dim - 1; + + sum = sum + glob_art[ tmp_k ]; + } + + // Moving average: + glob_art[j] = (sum / win_size) / (glob_art[j] + EPS);*/ + + // Allocate memory for the column: + v = (double*) malloc(winsize * sizeof (double)); + ct = 0; + + for (k = (j - (winsize / 2)); k < (j + (winsize / 2)); k++) { + tmp_k = k; + + // Replicate padding: + if (tmp_k < 0) tmp_k = 0; + if (tmp_k > (p_dim - 1)) tmp_k = p_dim - 1; + + v[ct++] = glob_art[ tmp_k ]; + } + + glob_art[j] = (P3DBOINHAIBELRINGREMOVER_MEDIAN(v, winsize) / (glob_art[j] + EPS)); + + // Free memory for the column: + free(v); + } + + + // The artifact template vector is multiplied for each + // row of the polar image P: + #pragma omp parallel for private(i, tmp_val) + for (j = 0; j < p_dim; j++) { + for (i = 0; i < p_dim; i++) { + // Take care of intensity bounds: + tmp_val = p_in_im[ I2(i, j, p_dim) ] * glob_art[i]; + + if (tmp_val < 0.0) tmp_val = 0.0; + if (tmp_val > USHRT_MAX) tmp_val = USHRT_MAX; + + p_in_im[ I2(i, j, p_dim) ] = (unsigned short) tmp_val; + } + } + } + + //p3dWriteRaw8 ( p_in_im, "C:\\p_out_im.raw", p_dim, p_dim, 1, printf ); + + // Return in cartesian coordinates: + p3dPolar2cartesian_16(p_in_im, &c_out_im, p_dim, centerX, centerY, dimx, dimy); + + // Copy C_OUT_IM to the output of the procedure: + memcpy(out_im, c_out_im, dimx * dimy * sizeof (unsigned short)); + + // Free memory: + free(glob_art); + + free(p_in_im); + free(c_out_im); + + return P3D_SUCCESS; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dClearBorderFilter.c b/pypore3d/pypore3d/P3D_Filt/p3dClearBorderFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..4cb40119de3e0ec19d7476533a4c7eec2eaff8d6 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dClearBorderFilter.c @@ -0,0 +1,512 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +#include "Common/p3dCoordsQueue.h" + +// Temporary label: +#define _P3DCLEARBORDERFILTER_TEMP_LABEL 2 + +void _p3dClearBorderFilter3D_putCoordsInQueue( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned char m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + coords_t tmp_coords; // Temporary coords + + + // If we're on an object voxel: + if (out_rev[ I(i, j, k, dimx, dimy) ] == OBJECT) { + // Check if this is the last step: + if (ct == (win_size - 2)) { + // Border voxels are set to m: + out_rev[ I(i, j, k, dimx, dimy) ] = m; + + // A border voxel is pushed into queue: + tmp_coords.x = i; + tmp_coords.y = j; + tmp_coords.z = k; + coords_queue_push(queue, tmp_coords); + } else { + // Mark voxel for further scan: + out_rev[ I(i, j, k, dimx, dimy) ] = _P3DCLEARBORDERFILTER_TEMP_LABEL; + } + } +} + +void _p3dClearBorderFilter3D_conn_fun6( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned char m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + int a, b, c; + + c = k - 1; + b = j; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +void _p3dClearBorderFilter3D_conn_fun18( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned char m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + int a, b, c; + + // Perform 6-connectivity: + _p3dClearBorderFilter3D_conn_fun6(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 12 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +void _p3dClearBorderFilter3D_conn_fun26( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned char m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + int a, b, c; + + // Perform 18-connectivity: + _p3dClearBorderFilter3D_conn_fun18(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 8 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j - 1; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j - 1; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i - 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i + 1; + _p3dClearBorderFilter3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +int _p3dClearBorderFilter3D_first_unlabeled( + unsigned char* in_im, + int dimx, + int dimy, + int dimz, + int winsize, + coords_t* coords + ) +{ + int i, j, k; + int off; + + off = winsize / 2; // integer division: + + // Scan faces: + for (i = off; i < (dimx - off); i++) { + for (j = off; j < (dimy - off); j++) { + if (in_im[ I(i, j, off, dimx, dimy) ] == OBJECT) { + coords->x = i; + coords->y = j; + coords->z = off; + + return P3D_TRUE; + } + + if (in_im[ I(i, j, dimz - off - 1, dimx, dimy) ] == OBJECT) { + coords->x = i; + coords->y = j; + coords->z = dimz - off - 1; + + return P3D_TRUE; + } + } + } + + for (j = off; j < (dimy - off); j++) { + for (k = off; k < (dimz - off); k++) { + if (in_im[ I(off, j, k, dimx, dimy) ] == OBJECT) { + coords->x = off; + coords->y = j; + coords->z = k; + + return P3D_TRUE; + } + if (in_im[ I(dimx - off - 1, j, k, dimx, dimy) ] == OBJECT) { + coords->x = dimx - off - 1; + coords->y = j; + coords->z = k; + + return P3D_TRUE; + } + } + } + + + for (i = off; i < (dimx - off); i++) { + for (k = off; k < (dimz - off); k++) { + if (in_im[ I(i, off, k, dimx, dimy) ] == OBJECT) { + coords->x = i; + coords->y = off; + coords->z = k; + + return P3D_TRUE; + } + if (in_im[ I(i, dimy - off - 1, k, dimx, dimy) ] == OBJECT) { + coords->x = i; + coords->y = dimy - off - 1; + coords->z = k; + + return P3D_TRUE; + } + } + } + + return P3D_FALSE; +} + + +int p3dClearBorderFilter3D( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int conn, + int (*wr_log)(const char*, ...) + ) +{ + + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + int win_size = 3; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + + unsigned int m; // Counter for number of connected components removed + int ct, offset; // Counter for local subvolume size + int i, j, k; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev; + unsigned char* tmp_out_rev; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned char m, + coords_queue_t * queue // FIFO data structure for coords storage + ); + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying clear border filter..."); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + } + + + // Set the correct type of connectivity based on input parameter: + if (conn == CONN6) + conn_fun = _p3dClearBorderFilter3D_conn_fun6; + else if (conn == CONN18) + conn_fun = _p3dClearBorderFilter3D_conn_fun18; + else // default: + conn_fun = _p3dClearBorderFilter3D_conn_fun26; + + + // Apply algorithm: + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Initialize input: + tmp_in_rev = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char)); + if (tmp_in_rev == NULL) goto MEM_ERROR; + + p3dZeroPadding3D_8(in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad, NULL, NULL); + + // Initialize output filtered volume with a copy of input volume: + tmp_out_rev = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char)); + if (tmp_out_rev == NULL) goto MEM_ERROR; + + memcpy(tmp_out_rev, tmp_in_rev, a_dimx * a_dimy * a_dimz * sizeof (unsigned char)); + + + // Initialize variables: + coords_queue_init(&queue); + + // Initialize label counter: + m = 1; + + // While not all voxels are labeled: + while (_p3dClearBorderFilter3D_first_unlabeled(tmp_out_rev, a_dimx, a_dimy, a_dimz, win_size, &coords) == P3D_TRUE) { + + // Push the first unlabeled object voxel into queue: + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while (coords_queue_isempty(queue) == P3D_FALSE) { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x, coords.y, coords.z, a_dimx, a_dimy) ] = _P3DCLEARBORDERFILTER_TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) { + for (j = (coords.y - offset); j <= (coords.y + offset); j++) { + for (i = (coords.x - offset); i <= (coords.x + offset); i++) { + if (tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] == _P3DCLEARBORDERFILTER_TEMP_LABEL) { + // Perform 6-, 18-, or 26-connectivity: + conn_fun(tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, BACKGROUND, &queue); + + // A voxels previously marked is set to background: + tmp_out_rev[ I(i, j, k, a_dimx, a_dimy) ] = BACKGROUND; + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + } + } + + // Increment label for next connected component: + m++; + } + + // Print out the number of connected components removed: + if (wr_log != NULL) { + wr_log("\t%d blobs removed.", MAX(0,(m-3))); + } + + // Crop output: + p3dCrop3D_8(tmp_out_rev, out_rev, a_dimx, a_dimy, a_dimz, a_rad, NULL, NULL); + + + // Print out the elapsed time: + if (wr_log != NULL) { + wr_log("Pore3D - Clear border filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory if previous malloc were successfully: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code and exit: + return P3D_ERROR; + +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dCreateBinaryShapes.c b/pypore3d/pypore3d/P3D_Filt/p3dCreateBinaryShapes.c new file mode 100644 index 0000000000000000000000000000000000000000..15e94cfa614fcfe2f4601e18d931a48bf17d00a2 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dCreateBinaryShapes.c @@ -0,0 +1,157 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +/// To be implemented for square, rectangular, circle.... At first: circle + +int p3dCreateBinaryCircle( + unsigned char* out_im, + const int dimx, + const int dimy, + const int cenx, + const int ceny, + const int radius, + int (*wr_log)(const char*, ...) + ) +{ + int i, j; + + // Log a message: + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Creating binary circle..."); + wr_log("\tCenter: [%d, %d].", cenx, ceny); + wr_log("\tRadius: %d.", radius); + } + + + // Remove connected component: + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + // Labels start from 3: + if (sqrt((double) ((i - cenx)*(i - cenx)+(j - ceny)*(j - ceny))) <= radius) { + out_im[ I2(i, j, dimx) ] = OBJECT; + } else { + out_im[ I2(i, j, dimx) ] = BACKGROUND; + } + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Binary circle created successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCreateBinaryCylinder( + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int cenx, + const int ceny, + const int radius, + int (*wr_log)(const char*, ...) + ) +{ + int i, j, k; + + // Log a message and start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Creating binary cylinder..."); + wr_log("\tCenter: [%d, %d].", cenx, ceny); + wr_log("\tRadius: %d.", radius); + } + + + // Remove connected component: + #pragma omp parallel for private(i, j) + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + if (sqrt((double) ((i - cenx)*(i - cenx)+(j - ceny)*(j - ceny))) <= radius) { + out_im[ I(i, j, k, dimx, dimy) ] = OBJECT; + } else { + out_im[ I(i, j, k, dimx, dimy) ] = BACKGROUND; + } + } + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Binary cylinder created successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +} + +int p3dCreateBinarySphere( + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int cenx, + const int ceny, + const int cenz, + const int radius, + int (*wr_log)(const char*, ...) + ) +{ + int i, j, k; + + + // Log a message: + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Creating binary sphere..."); + wr_log("\tCenter: [%d, %d, %d].", cenx, ceny, cenz); + wr_log("\tRadius: %d.", radius); + } + + + // Remove connected component: + #pragma omp parallel for private(i, j) + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + if (sqrt((double) ((i - cenx)*(i - cenx)+(j - ceny)*(j - ceny)+(k - cenz)*(k - cenz))) <= radius) { + out_im[ I(i, j, k, dimx, dimy) ] = OBJECT; + } else { + out_im[ I(i, j, k, dimx, dimy) ] = BACKGROUND; + } + } + } + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Binary sphere created successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +} + + + + + + + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dCrop.c b/pypore3d/pypore3d/P3D_Filt/p3dCrop.c new file mode 100644 index 0000000000000000000000000000000000000000..86ec3371f190a5feb431e3c004d8ea8a9aef124a --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dCrop.c @@ -0,0 +1,125 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +int p3dCrop2D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, // ncols + const int dimy, // nrows + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy; + int i, j; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size * 2; + a_dimy = dimy - size * 2; + + // Copy original (internal) values: + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_im[ I2(i, j, a_dimx) ] = in_im[ I2(i + size, j + size, dimx) ]; + + return P3D_SUCCESS; + +} + +int p3dCrop2D_16( + unsigned short* in_rev, + unsigned short* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy; + int i, j; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size * 2; + a_dimy = dimy - size * 2; + + // Copy original (internal) values: + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I2(i, j, a_dimx) ] = in_rev[ I2(i + size, j + size, dimx) ]; + + return P3D_SUCCESS; +} + +int p3dCrop3D_8( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size * 2; + a_dimy = dimy - size * 2; + a_dimz = dimz - size * 2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I(i, j, k, a_dimx, a_dimy) ] = + in_rev[ I(i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCrop3D_16( + unsigned short* in_rev, + unsigned short* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size * 2; + a_dimy = dimy - size * 2; + a_dimz = dimz - size * 2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I(i, j, k, a_dimx, a_dimy) ] = + in_rev[ I(i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dFilt.def b/pypore3d/pypore3d/P3D_Filt/p3dFilt.def new file mode 100644 index 0000000000000000000000000000000000000000..1ad9ee8789761928c5f70858747570a2af091c87 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dFilt.def @@ -0,0 +1,81 @@ +LIBRARY P3DFILT +EXPORTS + p3dAnisotropicDiffusionFilter3D_8 @1 + p3dAnisotropicDiffusionFilter3D_16 @2 + + p3dBilateralFilter3D_8 @3 + p3dBilateralFilter3D_16 @4 + + p3dReadRaw8 @5 + p3dReadRaw16 @6 + p3dWriteRaw8 @7 + p3dWriteRaw16 @8 + p3dWriteRaw32 @9 + p3dWriteRaw32f @10 + + p3dBoinHaibelRingRemover2D_8 @11 + p3dBoinHaibelRingRemover2D_16 @12 + + p3dClearBorderFilter3D @13 + + p3dCreateBinaryCircle @14 + p3dCreateBinaryCylinder @15 + p3dCreateBinarySphere @16 + + p3dCrop2D_8 @17 + p3dCrop2D_16 @18 + p3dCrop3D_8 @19 + p3dCrop3D_16 @20 + + p3dFrom16To8 @21 + + p3dGaussianFilter3D_8 @22 + p3dGaussianFilter3D_16 @23 + + p3dGetRegionByCoords3D @24 + + p3dHuangYagerThresholding_8 @25 + p3dHuangYagerThresholding_16 @26 + + p3dJohannsenThresholding_8 @27 + p3dJohannsenThresholding_16 @28 + + p3dKapurThresholding_8 @29 + p3dKapurThresholding_16 @30 + + p3dKittlerThresholding_8 @31 + p3dKittlerThresholding_16 @32 + + p3dMeanFilter3D_8 @33 + p3dMeanFilter3D_16 @34 + + p3dMedianFilter3D_8 @35 + p3dMedianFilter3D_16 @36 + + p3dOtsuThresholding_8 @37 + p3dOtsuThresholding_16 @38 + + p3dZeroPadding2D_8 @39 + p3dZeroPadding2D_16 @40 + p3dZeroPadding3D_8 @41 + p3dZeroPadding3D_16 @42 + + p3dReplicatePadding2D_8 @43 + p3dReplicatePadding2D_16 @44 + p3dReplicatePadding3D_8 @45 + p3dReplicatePadding3D_16 @46 + + p3dPunThresholding_8 @47 + p3dPunThresholding_16 @48 + + p3dRidlerThresholding_8 @49 + p3dRidlerThresholding_16 @50 + + p3dSijbersPostnovRingRemover2D_8 @51 + p3dSijbersPostnovRingRemover2D_16 @52 + + + + + + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dFilt.h b/pypore3d/pypore3d/P3D_Filt/p3dFilt.h new file mode 100644 index 0000000000000000000000000000000000000000..e0c6a49d90ef66c2d29849ed83de21fb1a34756d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dFilt.h @@ -0,0 +1,143 @@ +#ifdef __cplusplus +extern "C" { +#endif + + + /* + Constants: + */ +#ifndef P3D_FILT_DEFINED +#define P3D_FILT_DEFINED + +#define P3D_FALSE -1 +#define P3D_TRUE 1 + +#define P3D_ERROR 0 +#define P3D_MEM_ERROR NULL /* Leave it NULL for simplify tests */ +#define P3D_IO_ERROR 1 +#define P3D_SUCCESS 2 /* Any number */ + +#define BACKGROUND 0 +#define OBJECT UCHAR_MAX + + // Constants for 3D connectivity: +#define CONN6 711 +#define CONN18 712 +#define CONN26 713 + +#endif + + /* + Macros: + */ + +#ifndef P3D_MACROS +#define P3D_MACROS + +#define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) +#define I2(i,j,N) ( (j)*(N) + (i) ) + + +#define MIN(x,y) (((x) < (y))?(x):(y)) +#define MAX(x,y) (((x) > (y))?(x):(y)) + + /* A sort of TRY-CATCH constructor: */ +#define P3D_MEM_TRY( function ) if ( ((function) == P3D_MEM_ERROR) ) { goto MEM_ERROR; } +#define P3D_TRY( function ) if ( ((function) == P3D_ERROR) ) { goto MEM_ERROR; } +#define ELEM_SWAP(a,b) { register double t=(a);(a)=(b);(b)=t; } +#endif + + // Input - output: + int p3dReadRaw8(char*, unsigned char*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dReadRaw16(char*, unsigned short*, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dWriteRaw8(unsigned char*, char*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dWriteRaw16(unsigned short*, char*, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dWriteRaw32(unsigned int*, char*, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dWriteRaw32f(float*, char*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + // Utils: + int p3dCrop2D_8(unsigned char*, unsigned char*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dCrop2D_16(unsigned short*, unsigned short*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dCrop3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dCrop3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dZeroPadding2D_8(unsigned char*, unsigned char*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dZeroPadding2D_16(unsigned short*, unsigned short*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dZeroPadding3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dZeroPadding3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dReplicatePadding2D_8(unsigned char*, unsigned char*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dReplicatePadding2D_16(unsigned short*, unsigned short*, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dReplicatePadding3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dReplicatePadding3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int _p3dZeroPadding3D_float( float*, float*, const int, const int, const int, const int ); + int _p3dReplicatePadding3D_float( float*, float*, const int, const int, const int, const int ); + int _p3dZeroPadding3D_uchar2float( unsigned char*, float*, const int, const int, const int, const int ); + int _p3dReplicatePadding3D_uchar2float( unsigned char*, float*, const int, const int, const int, const int ); + int _p3dZeroPadding3D_ushort2float( unsigned short*, float*, const int, const int, const int, const int ); + int _p3dReplicatePadding3D_ushort2float( unsigned short*, float*, const int, const int, const int, const int ); + + + // Basic Filters: + int p3dAnisotropicDiffusionFilter3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, const double, const double, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dAnisotropicDiffusionFilter3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, const double, const double, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dBilateralFilter3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, const double, const double, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dBilateralFilter3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, const double, const double, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dGaussianFilter3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, const double, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dGaussianFilter3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, const double, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dMeanFilter3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dMeanFilter3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dMedianFilter3D_8(unsigned char*, unsigned char*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dMedianFilter3D_16(unsigned short*, unsigned short*, const int, const int, const int, const int, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dBoinHaibelRingRemover2D_8(unsigned char*, unsigned char*, const int, const int, const double, const double, const int, const int, const double, int (*wr_log)(const char*, ...)); + int p3dBoinHaibelRingRemover2D_16(unsigned short*, unsigned short*, const int, const int, const double, const double, const int, const int, const double, int (*wr_log)(const char*, ...)); + + int p3dSijbersPostnovRingRemover2D_8(unsigned char*, unsigned char*, const int, const int, const double, const double, const int, const double, const int, const double, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dSijbersPostnovRingRemover2D_16(unsigned short*, unsigned short*, const int, const int, const double, const double, const int, const double, const int, const double, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + + // Segmentation: + int p3dKittlerThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dKittlerThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dOtsuThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dOtsuThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dPunThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dPunThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dRidlerThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dRidlerThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dKapurThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dKapurThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dJohannsenThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dJohannsenThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + int p3dHuangYagerThresholding_8(unsigned char*, unsigned char*, const int, const int, const int, unsigned char*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + int p3dHuangYagerThresholding_16(unsigned short*, unsigned char*, const int, const int, const int, unsigned short*, int (*wr_log)(const char*, ...), int (*wr_progress)(const int, ...)); + + + // Binary: + int p3dClearBorderFilter3D(unsigned char*, unsigned char*, const int, const int, const int, const int, int (*wr_log)(const char*, ...)); + int p3dGetRegionByCoords3D(unsigned char*, unsigned char*, const int, const int, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...)); + + int p3dCreateBinaryCircle(unsigned char*, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...)); + int p3dCreateBinaryCylinder(unsigned char*, const int, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...)); + int p3dCreateBinarySphere(unsigned char*, const int, const int, const int, const int, const int, const int, const int, int (*wr_log)(const char*, ...)); + + + // Utils: + int p3dFrom16To8(unsigned short*, unsigned char*,const int, const int, const int, unsigned short, unsigned short, int (*wr_log)(const char*, ...),int (*wr_progress)(const int, ...)); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dFrom16To8.c b/pypore3d/pypore3d/P3D_Filt/p3dFrom16To8.c new file mode 100644 index 0000000000000000000000000000000000000000..1ee82cc2c0e24153345a9cb1527dbd5569a14437 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dFrom16To8.c @@ -0,0 +1,50 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <limits.h> +#include <omp.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +int p3dFrom16To8( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short min, + unsigned short max, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + double new_min = 0.0; + double new_max = UCHAR_MAX * 1.0; + double tmpval; + int i; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Rescaling and converting image from 16-bit to 8-bit format..."); + wr_log("\tMin/max values to rescale into [0,255] range: [%d.%d].", min, max); + } + +#pragma omp parallel for private (tmpval) + for (i = 0; i < (dimx * dimy * dimz); i++) { + tmpval = (in_im[i] - min) / ((max - min) * 1.0)*(new_max - new_min); + if (tmpval > new_max) tmpval = new_max; + if (tmpval < new_min) tmpval = new_min; + out_im[i] = (unsigned char) (tmpval); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Image rescaled and converted successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + + } + + // Return OK: + return P3D_SUCCESS; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dGaussianFilter.c b/pypore3d/pypore3d/P3D_Filt/p3dGaussianFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..c8f77aaa8da67650292b759b8a8ffd04089d0ab9 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dGaussianFilter.c @@ -0,0 +1,328 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +int p3dGaussianFilter3D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + const double sigma, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Padded input and related dims: + float* tmp_im = NULL; + float* kernel = NULL; + + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct, a_rad, a_size; + double d; + double f, sum, sum_w; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying gaussian filter..."); + wr_log("\tKernel size: %d.", size); + wr_log("\tSigma: %0.3f.", sigma); + } + + // Set kernel size and variance: + if (size < 1.0) + a_rad = 1; + else + a_rad = (int) (ceil(size / 2.0)); + a_size = 2 * a_rad + 1; + + d = (2.0 * sigma * sigma); + + + // Compute dimensions of padded volume: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + + // Initialize input: + P3D_MEM_TRY(tmp_im = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + P3D_MEM_TRY(kernel = (float*) malloc(a_size * sizeof (float))); + + P3D_TRY(_p3dReplicatePadding3D_uchar2float(in_im, tmp_im, dimx, dimy, dimz, a_rad)); + + ct = 0; + sum_w = 0.0; + + // Create gausssian kernel: + for (x = (-a_rad); x <= a_rad; x++) { + + f = (x)*(x) / d; + kernel[ct] = (float) (exp(-f)); + sum_w = sum_w + kernel[ct++]; + } + ct = 0; + // Normalize kernel + for (x = (-a_rad); x <= a_rad; x++) + kernel[ct] = kernel[ct++]/ ( (float) sum_w ); + + // X-direction scanning +#pragma omp parallel for private(i, j, x, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (x = (i - a_rad); x <= (i + a_rad); x++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(x, j, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + } + } + + // Y-direction scanning +#pragma omp parallel for private(i, j, y, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (y = (j - a_rad); y <= (j + a_rad); y++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(i, y, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + + // Z-direction scanning +#pragma omp parallel for private(i, j, z, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(i, j, z, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + if (sum < 0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = 0; + else if (sum > UCHAR_MAX) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = UCHAR_MAX; + else + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = (unsigned char) sum; + + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Gaussian filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return error: + return P3D_ERROR; + +} + +int p3dGaussianFilter3D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + const double sigma, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Padded input and related dims: + float* tmp_im = NULL; + float* kernel = NULL; + + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct, a_rad, a_size; + double d; + double f, sum, sum_w; + + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying gaussian filter..."); + wr_log("\tKernel size: %d.", size); + wr_log("\tSigma: %0.3f.", sigma); + } + + // Set kernel size and variance: + if (size < 1.0) + a_rad = 1; + else + a_rad = (int) (ceil(size / 2.0)); + a_size = 2 * a_rad + 1; + + d = (2.0 * sigma * sigma); + + + // Compute dimensions of padded volume: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + + // Initialize input: + P3D_MEM_TRY(tmp_im = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + P3D_MEM_TRY(kernel = (float*) malloc(a_size * sizeof (float))); + + P3D_TRY(_p3dReplicatePadding3D_ushort2float(in_im, tmp_im, dimx, dimy, dimz, a_rad)); + + ct = 0; + sum_w = 0.0; + + // Create gausssian kernel: + for (x = (-a_rad); x <= a_rad; x++) { + + f = (x)*(x) / d; + kernel[ct] = (float) (exp(-f)); + sum_w = sum_w + kernel[ct++]; + } + ct = 0; + // Normalize kernel + for (x = (-a_rad); x <= a_rad; x++) + kernel[ct] = kernel[ct++]/ ((float) sum_w); + + // X-direction scanning +#pragma omp parallel for private(i, j, x, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (x = (i - a_rad); x <= (i + a_rad); x++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(x, j, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + + // Y-direction scanning +#pragma omp parallel for private(i, j, y, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (y = (j - a_rad); y <= (j + a_rad); y++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(i, y, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + + // Z-direction scanning +#pragma omp parallel for private(i, j, z, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + // Gausssian kernel: + sum = sum + kernel[ct++] * tmp_im[ I(i, j, z, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + if (sum < 0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = 0; + else if (sum > USHRT_MAX) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = USHRT_MAX; + else + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = (unsigned short) sum; + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Gaussian filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dGetRegionByCoords.c b/pypore3d/pypore3d/P3D_Filt/p3dGetRegionByCoords.c new file mode 100644 index 0000000000000000000000000000000000000000..d7f687078a64e0501e83006650902aab6dad798b --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dGetRegionByCoords.c @@ -0,0 +1,462 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +#include "Common/p3dCoordsQueue.h" + +// Temporary label: +#define _GETREGIONBYCOORDS_TEMP_LABEL 2 +#define _GETREGIONBYCOORDS_DEF_LABEL 1 + +void _p3dGetRegionByCoords3D_putCoordsInQueue( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + coords_t tmp_coords; // Temporary coords + + + // If we're on an object voxel: + if (out_rev[ I(i, j, k, dimx, dimy) ] == OBJECT) { + // Check if this is the last step: + if (ct == (win_size - 2)) { + // Border voxels are set to m: + out_rev[ I(i, j, k, dimx, dimy) ] = (unsigned char) m; + + // A border voxel is pushed into queue: + tmp_coords.x = i; + tmp_coords.y = j; + tmp_coords.z = k; + coords_queue_push(queue, tmp_coords); + } else { + // Mark voxel for further scan: + out_rev[ I(i, j, k, dimx, dimy) ] = _GETREGIONBYCOORDS_TEMP_LABEL; + } + } +} + +void _p3dGetRegionByCoords3D_conn_fun6( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + c = k - 1; + b = j; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + +void _p3dGetRegionByCoords3D_conn_fun18( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + // Perform 6-connectivity: + _p3dGetRegionByCoords3D_conn_fun6(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 12 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j - 1; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k; + b = j + 1; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + +} + +void _p3dGetRegionByCoords3D_conn_fun26( + unsigned char* out_rev, + int dimx, + int dimy, + int dimz, + int i, + int j, + int k, + int ct, + int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) { + int a, b, c; + + // Perform 18-connectivity: + _p3dGetRegionByCoords3D_conn_fun18(out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue); + + // Do other 8 tests: + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j - 1; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k - 1; + b = j + 1; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j - 1; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i - 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + + c = k + 1; + b = j + 1; + a = i + 1; + _p3dGetRegionByCoords3D_putCoordsInQueue(out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue); + +} + + +int p3dGetRegionByCoords3D ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int x, + const int y, + const int z, + const int conn, + int (*wr_log)(const char*, ...) + ) +{ + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + int win_size; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + int ct, offset; // Counter for local subvolume size + int i,j,k; + int a,b,c; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev = NULL; + unsigned char* tmp_out_rev = NULL; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned char*, + int, + int, + int, + int, + int, + int, + int, + int, + unsigned short, + coords_queue_t* // FIFO data structure for coords storage + ); + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + win_size = 3; + + + // Set the correct type of connectivity based on input parameter: + if ( conn == CONN6 ) + conn_fun = _p3dGetRegionByCoords3D_conn_fun6; + else if ( conn == CONN18 ) + conn_fun = _p3dGetRegionByCoords3D_conn_fun18; + else // default: + conn_fun = _p3dGetRegionByCoords3D_conn_fun26; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying blob extraction..."); + wr_log("\tExtracting blob including voxel [%d,%d,%d]...",x,y,z); + if (conn == CONN6) + wr_log("\t6-connectivity used. "); + else if (conn == CONN18) + wr_log("\t18-connectivity used. "); + else // default: + wr_log("\t26-connectivity used. "); + } + + + // Apply algorithm: + if ( in_rev[ I(x, y, z, dimx, dimy) ] == UCHAR_MAX ) + { + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad*2; + a_dimy = dimy + a_rad*2; + a_dimz = dimz + a_rad*2; + + // Initialize input: + tmp_in_rev = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + if ( tmp_in_rev == NULL ) goto MEM_ERROR; + + p3dZeroPadding3D_8 ( in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad, NULL, NULL ); + + // Initialize output volume with a copy of input volume: + tmp_out_rev = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + if ( tmp_out_rev == NULL ) goto MEM_ERROR; + + memcpy(tmp_out_rev,tmp_in_rev,a_dimx*a_dimy*a_dimz*sizeof(unsigned char)); + + + // Initialize variables: + coords_queue_init(&queue); + + + // Push the user specified object voxel into queue: + coords.z = z + a_rad; + coords.y = y + a_rad; + coords.x = x + a_rad; + + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while(coords_queue_isempty(queue) == P3D_FALSE) + { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x,coords.y,coords.z,a_dimx,a_dimy) ] = _GETREGIONBYCOORDS_TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) + { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) + for (j = (coords.y - offset); j <= (coords.y + offset); j++) + for (i = (coords.x - offset); i <= (coords.x + offset); i++) + { + + if (tmp_out_rev[ I(i,j,k,a_dimx,a_dimy) ] == _GETREGIONBYCOORDS_TEMP_LABEL) + { + // Perform 6-, 18-, or 26-connectivity: + conn_fun ( tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, BACKGROUND, &queue ); + + // A voxels previously marked is set to background: + tmp_out_rev[ I(i,j,k,a_dimx,a_dimy) ] = _GETREGIONBYCOORDS_DEF_LABEL; + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + + + // Crop output: +#pragma omp parallel for private(a,b) + for( c = 0; c < dimz; c++ ) + for( b = 0; b < dimy; b++ ) + for( a = 0; a < dimx; a++ ) + { + // Assign OBJECT value to output: + out_rev[ I(a,b,c,dimx,dimy) ] = ( tmp_out_rev[ I( a + a_rad, b + a_rad, c + a_rad, a_dimx, a_dimy ) ] + == _GETREGIONBYCOORDS_DEF_LABEL ) ? (unsigned char) (OBJECT) : (unsigned char) (BACKGROUND); + } + + } + else + { + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tWARNING - The specified voxel does not belong to a blob."); + } +#pragma omp parallel for + for (a = 0; a < dimx*dimy*dimz; a++) + { + out_rev[a] = in_rev[a]; + } + } + + // Print out the elapsed time: + if (wr_log != NULL) { + wr_log("Pore3D - Blob extraction command applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + // Free memory: + if ( tmp_in_rev != NULL ) free(tmp_in_rev); + if ( tmp_out_rev != NULL ) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + + + // Free memory if previous malloc were successfully: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code and exit: + return P3D_ERROR; + +} + + + + + + + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dHuangYagerThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dHuangYagerThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..2d5f83dd54f19b73782b560df0b6584a439f74ba --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dHuangYagerThresholding.c @@ -0,0 +1,343 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +double _p3dHuangYagerThresholding_Ux(int g, int u0, int u1, int t) { + double ux, x; + + if (g <= t) { + x = 1.0 + ((double) abs(g - u0)) / 255.0; + ux = 1.0 / x; + } else { + x = 1.0 + ((double) abs(g - u1)) / 255.0; + ux = 1.0 / x; + } + //if (ux < 0.5 || ux > 1.0) + //printf("Ux = %f\n", ux); + return ux; +} + +double _p3dHuangYagerThresholding_Ux16(int g, int u0, int u1, int t) { + double ux, x; + + if (g <= t) { + x = 1.0 + ((double) abs(g - u0)) / 65535.0; + ux = 1.0 / x; + } else { + x = 1.0 + ((double) abs(g - u1)) / 65535.0; + ux = 1.0 / x; + } + //if (ux < 0.5 || ux > 1.0) + //printf("Ux = %f\n", ux); + return ux; +} + +double _p3dHuangYagerThresholding_yager(int u0, int u1, int t) { + int i; + double x, sum = 0.0; + + for (i = 0; i < 256; i++) { + x = _p3dHuangYagerThresholding_Ux(i, u0, u1, t); + x = x * (1.0 - x); + sum += x*x; + } + x = (double) sqrt((double) sum); + return x; +} + +double _p3dHuangYagerThresholding_yager16(int u0, int u1, int t) { + int i; + double x, sum = 0.0; + + for (i = 0; i < 65536; i++) { + x = _p3dHuangYagerThresholding_Ux16(i, u0, u1, t); + x = x * (1.0 - x); + sum += x*x; + } + x = (double) sqrt((double) sum); + return x; +} + +int p3dHuangYagerThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double *S, *Sbar, *W, *Wbar; + double *hist, *F, maxv = 0.0, delta, sum, minsum; + int i, t, tbest = -1, u0, u1; + int start, end; + + int ct; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Huang's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(hist = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + P3D_MEM_TRY(S = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(Sbar = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(W = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(Wbar = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + hist[in_im[ ct ]] = hist[in_im[ ct ]] + 1.0; + + + /* Find cumulative histogram */ + S[0] = hist[0]; + W[0] = 0; + for (i = 1; i <= UCHAR_MAX; i++) { + S[i] = S[i - 1] + hist[i]; + W[i] = i * hist[i] + W[i - 1]; + } + + /* Cumulative reverse histogram */ + Sbar[UCHAR_MAX] = 0; + Wbar[UCHAR_MAX] = 0; + for (i = (UCHAR_MAX - 1); i >= 0; i--) { + Sbar[i] = Sbar[i + 1] + hist[i + 1]; + Wbar[i] = Wbar[i + 1] + (i + 1) * hist[i + 1]; + } + + for (t = 1; t < UCHAR_MAX; t++) { + if (hist[t] == 0.0) continue; + if (S[t] == 0.0) continue; + if (Sbar[t] == 0.0) continue; + + /* Means */ + u0 = (int) (W[t] / S[t] + 0.5); + u1 = (int) (Wbar[t] / Sbar[t] + 0.5); + + /* Fuzziness measure */ + F[t] = _p3dHuangYagerThresholding_yager(u0, u1, t) / (dimx * dimy * dimz); + + /* Keep the minimum fuzziness */ + if (F[t] > maxv) + maxv = F[t]; + if (tbest < 0) + tbest = t; + else if (F[t] < F[tbest]) tbest = t; + } + + /* Find best out of a range of thresholds */ + delta = F[tbest] + (maxv - F[tbest])*0.05; /* 5% */ + start = (int) (tbest - delta); + if (start <= 0) + start = 1; + end = (int) (tbest + delta); + if (end >= UCHAR_MAX) + end = (UCHAR_MAX - 1); + minsum = UINT_MAX; + + for (i = start; i <= end; i++) { + sum = hist[i - 1] + hist[i] + hist[i + 1]; + if (sum < minsum) { + t = i; + minsum = sum; + } + } + + *thresh = (unsigned char) t; + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Free memory: + free(hist); + free(S); + free(Sbar); + free(W); + free(Wbar); + free(F); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + free(hist); + free(S); + free(Sbar); + free(W); + free(Wbar); + free(F); + + // Return error: + return P3D_ERROR; + + +} + +int p3dHuangYagerThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double *S, *Sbar, *W, *Wbar; + double *hist, *F, maxv = 0.0, delta, sum, minsum; + int i, t, tbest = -1, u0, u1; + int start, end; + + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Huang's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(hist = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + P3D_MEM_TRY(S = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(Sbar = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(W = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(Wbar = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + hist[in_im[ ct ]] = hist[in_im[ ct ]] + 1.0; + + + /* Find cumulative histogram */ + S[0] = hist[0]; + W[0] = 0; + for (i = 1; i <= USHRT_MAX; i++) { + S[i] = S[i - 1] + hist[i]; + W[i] = i * hist[i] + W[i - 1]; + } + + /* Cumulative reverse histogram */ + Sbar[USHRT_MAX] = 0; + Wbar[USHRT_MAX] = 0; + for (i = (USHRT_MAX - 1); i >= 0; i--) { + Sbar[i] = Sbar[i + 1] + hist[i + 1]; + Wbar[i] = Wbar[i + 1] + (i + 1) * hist[i + 1]; + } + + for (t = 1; t < USHRT_MAX; t++) { + if (hist[t] == 0.0) continue; + if (S[t] == 0.0) continue; + if (Sbar[t] == 0.0) continue; + + /* Means */ + u0 = (int) (W[t] / S[t] + 0.5); + u1 = (int) (Wbar[t] / Sbar[t] + 0.5); + + /* Fuzziness measure */ + F[t] = _p3dHuangYagerThresholding_yager16(u0, u1, t) / (dimx * dimy * dimz); + + /* Keep the minimum fuzziness */ + if (F[t] > maxv) + maxv = F[t]; + if (tbest < 0) + tbest = t; + else if (F[t] < F[tbest]) tbest = t; + } + + /* Find best out of a range of thresholds */ + delta = F[tbest] + (maxv - F[tbest])*0.05; /* 5% */ + start = (int) (tbest - delta); + if (start <= 0) + start = 1; + end = (int) (tbest + delta); + if (end >= USHRT_MAX) + end = (USHRT_MAX - 1); + minsum = UINT_MAX; + + for (i = start; i <= end; i++) { + sum = hist[i - 1] + hist[i] + hist[i + 1]; + if (sum < minsum) { + t = i; + minsum = sum; + } + } + + *thresh = (unsigned short) t; + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Free memory: + free(hist); + free(S); + free(Sbar); + free(W); + free(Wbar); + free(F); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + free(hist); + free(S); + free(Sbar); + free(W); + free(Wbar); + free(F); + + // Return error: + return (int) P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dIORaw.c b/pypore3d/pypore3d/P3D_Filt/p3dIORaw.c new file mode 100644 index 0000000000000000000000000000000000000000..811c2ce24439ae513cf65fa82a929770e234f400 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dIORaw.c @@ -0,0 +1,470 @@ +#include <stdlib.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +short _EndianSwapSignedShort(short s) { + unsigned char b1, b2; + + b1 = s & 255; + b2 = (s >> 8) & 255; + + return (b1 << 8) +b2; +} + +unsigned short _EndianSwapUnsignedShort(unsigned short s) { + unsigned char b1, b2; + + b1 = s & 255; + b2 = (s >> 8) & 255; + + return (b1 << 8) +b2; +} + +unsigned int _EndianSwapUnsignedInt( unsigned int val ) +{ + val = ((val << 8) & 0xFF00FF00 ) | ((val >> 8) & 0xFF00FF ); + return (val << 16) | (val >> 16); +} + +int _EndianSwapInt( int val ) +{ + val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF ); + return (val << 16) | ((val >> 16) & 0xFFFF); +} + + + +int p3dReadRaw8( + char* filename, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Reading RAW file %s ...", filename); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "rb")) == NULL) { + printf("Cannot open input file %s.", filename); + out_im = NULL; + + return P3D_IO_ERROR; + } + + /* Read raw data from file: */ + if (fread(out_im, sizeof (unsigned char), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on reading file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file read successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()) ; + } + + + // Return OK: + return P3D_SUCCESS; +} + +int p3dWriteRaw8( + unsigned char* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing 8-bit RAW file %s ...", filename); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Write raw data to file: */ + if (fwrite(in_im, sizeof (unsigned char), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()) ; + } + + + // Return OK: + return P3D_SUCCESS; +} + +int p3dReadRaw16( + char* filename, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int flagLittle, + const int flagSigned, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + short* s_tmp_im = NULL; + unsigned short* us_tmp_im = NULL; + int ct; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Reading RAW file %s ...", filename); + if (flagSigned == P3D_TRUE) + wr_log("\tSigned/Unsigned: Signed."); + else + wr_log("\tSigned/Unsigned: Unsigned."); + if (flagLittle == P3D_TRUE) + wr_log("\tLittle/Big Endian: Little."); + else + wr_log("\tLittle/Big Endian: Big."); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "rb")) == NULL) { + wr_log("Pore3D - IO error: cannot open input file %s. Program will exit.", filename); + out_im = NULL; + + return P3D_IO_ERROR; + } + + + /* Read data signed/unsigned: */ + if (flagSigned == P3D_TRUE) { + s_tmp_im = (short*) malloc(dimx * dimy * dimz * sizeof (short)); + + /* Read raw data from file: */ + if (fread(s_tmp_im, sizeof (short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on reading file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Convert to unsigned: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (flagLittle == P3D_FALSE) { + out_im[ct] = (unsigned short) (_EndianSwapSignedShort(s_tmp_im[ct]) + USHRT_MAX / 2); + } else { + out_im[ct] = (unsigned short) (s_tmp_im[ct] + USHRT_MAX / 2); + } + } + + /* Free: */ + free(s_tmp_im); + } else { + /* Swap endian if necessary: */ + if (flagLittle == P3D_FALSE) { + us_tmp_im = (unsigned short*) malloc(dimx * dimy * dimz * sizeof (unsigned short)); + + /* Read raw data from file: */ + if (fread(us_tmp_im, sizeof (unsigned short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on reading file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + out_im[ct] = (unsigned short) (_EndianSwapUnsignedShort(us_tmp_im[ct])); + } + + /* Free: */ + free(us_tmp_im); + } else { + if (fread(out_im, sizeof (unsigned short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on reading file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + } + } + + + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file read successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + // Return OK: + return P3D_SUCCESS; + +} + +int p3dWriteRaw16( + unsigned short* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + const int flagLittle, + const int flagSigned, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + short* s_tmp_im = NULL; + unsigned short* us_tmp_im = NULL; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing 16-bit RAW file %s ...", filename); + if (flagSigned == P3D_TRUE) + wr_log("\tSigned/Unsigned: Signed."); + else + wr_log("\tSigned/Unsigned: Unsigned."); + if (flagLittle == P3D_TRUE) + wr_log("\tLittle/Big Endian: Little."); + else + wr_log("\tLittle/Big Endian: Big."); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + in_im = NULL; + + return P3D_IO_ERROR; + } + + /* Read data signed/unsigned: */ + if (flagSigned == P3D_TRUE) { + s_tmp_im = (short*) malloc(dimx * dimy * dimz * sizeof (short)); + + /* Convert to signed: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (flagLittle == P3D_FALSE) { + s_tmp_im[ct] = _EndianSwapSignedShort((short) (in_im[ct] - USHRT_MAX / 2)); + } else { + s_tmp_im[ct] = (short) (in_im[ct] - USHRT_MAX / 2); + } + } + + /* Write raw data to file: */ + //fwrite(s_tmp_im, sizeof (short), dimx*dimy, fvol); + if (fwrite(s_tmp_im, sizeof (short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Free: */ + free(s_tmp_im); + } else { + /* Swap endian if necessary: */ + if (flagLittle == P3D_FALSE) { + us_tmp_im = (unsigned short*) malloc(dimx * dimy * dimz * sizeof (unsigned short)); + + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + us_tmp_im[ct] = _EndianSwapUnsignedShort(in_im[ct]); + } + + //fwrite(us_tmp_im, sizeof (unsigned short), dimx*dimy, fvol); + if (fwrite(us_tmp_im, sizeof (unsigned short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + free(us_tmp_im); + } else { + fwrite(in_im, sizeof (unsigned short), dimx * dimy * dimz, fvol); + } + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + return P3D_SUCCESS; +} + +int p3dWriteRaw32( + unsigned int* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + const int flagLittle, + const int flagSigned, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + int* s_tmp_im = NULL; + unsigned int* us_tmp_im = NULL; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing unsigned integer 32-bit RAW file %s ...", filename); + if (flagSigned == P3D_TRUE) + wr_log("\tSigned/Unsigned: Signed."); + else + wr_log("\tSigned/Unsigned: Unsigned."); + if (flagLittle == P3D_TRUE) + wr_log("\tLittle/Big Endian: Little."); + else + wr_log("\tLittle/Big Endian: Big."); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + in_im = NULL; + + return P3D_IO_ERROR; + } + + /* Read data signed/unsigned: */ + if (flagSigned == P3D_TRUE) { + s_tmp_im = (int*) malloc(dimx * dimy * dimz * sizeof (int)); + + /* Convert to signed: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (flagLittle == P3D_FALSE) { + s_tmp_im[ct] = _EndianSwapInt((int) (in_im[ct] - UINT_MAX / 2)); + } else { + s_tmp_im[ct] = (int) (in_im[ct] - UINT_MAX / 2); + } + } + + /* Write raw data to file: */ + //fwrite(s_tmp_im, sizeof (short), dimx*dimy, fvol); + if (fwrite(s_tmp_im, sizeof (int), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Free: */ + free(s_tmp_im); + } else { + /* Swap endian if necessary: */ + if (flagLittle == P3D_FALSE) { + us_tmp_im = (unsigned int*) malloc(dimx * dimy * dimz * sizeof (unsigned int)); + + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + us_tmp_im[ct] = _EndianSwapUnsignedInt(in_im[ct]); + } + + //fwrite(us_tmp_im, sizeof (unsigned short), dimx*dimy, fvol); + if (fwrite(us_tmp_im, sizeof (unsigned int), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + free(us_tmp_im); + } else { + fwrite(in_im, sizeof (unsigned int), dimx * dimy * dimz, fvol); + } + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + return P3D_SUCCESS; +} + + +int p3dWriteRaw32f( + float* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + FILE* fvol; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing float 32-bit RAW file %s ...", filename); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Write raw data to file: */ + if (fwrite(in_im, sizeof (float), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_IO_ERROR; + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + return P3D_SUCCESS; +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dJohannsenThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dJohannsenThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..439eef18f9803a0267b6c84f498383d98977aa34 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dJohannsenThresholding.c @@ -0,0 +1,241 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dFilt.h" +#include "p3dTime.h" +#define _USE_MATH_DEFINES +#include <math.h> + +double _p3dJohannsenThresholding_entropy(double h) { + if (h > 0.0) + return (-h * log(h)); + else return 0.0; +} + +double _p3dJohannsenThresholding_dlog(double x) { + if (x > 0.0) return log(x); + else return 0.0; +} + +int p3dJohannsenThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double *prob = NULL; + double *Pt = NULL; + double *F = NULL; + double *Pq = NULL; + int i, t, start, end; + double Sb, Sw; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Johannsen's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(prob = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + P3D_MEM_TRY(Pt = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(Pq = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= UCHAR_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute the factors */ + Pt[0] = prob[0]; + Pq[0] = 1.0 - Pt[0]; + for (i = 1; i <= UCHAR_MAX; i++) { + Pt[i] = Pt[i - 1] + prob[i]; + Pq[i] = 1.0 - Pt[i - 1]; + } + + start = 0; + while (prob[start++] <= 0.0); + end = UCHAR_MAX; + while (prob[end--] <= 0.0); + + /* Calculate the function to be minimized at all levels */ + t = -1; + for (i = start; i <= end; i++) { + if (prob[i] <= 0.0) continue; + Sb = _p3dJohannsenThresholding_dlog(Pt[i]) + (1.0 / Pt[i])* + (_p3dJohannsenThresholding_entropy(prob[i]) + _p3dJohannsenThresholding_entropy(Pt[i - 1])); + Sw = _p3dJohannsenThresholding_dlog(Pq[i]) + (1.0 / Pq[i])* + (_p3dJohannsenThresholding_entropy(prob[i]) + _p3dJohannsenThresholding_entropy(Pq[i + 1])); + F[i] = Sb + Sw; + if (t < 0) t = i; + else if (F[i] < F[t]) t = i; + } + + + *thresh = (unsigned char) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + if (Pq != NULL) free(Pq); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + if (Pq != NULL) free(Pq); + + // Return error: + return (int) P3D_MEM_ERROR; + +} + +int p3dJohannsenThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double *prob = NULL; + double *Pt = NULL; + double *F = NULL; + double *Pq = NULL; + int i, t, start, end; + double Sb, Sw; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Johannsen's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(prob = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + P3D_MEM_TRY(Pt = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(Pq = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= USHRT_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute the factors */ + Pt[0] = prob[0]; + Pq[0] = 1.0 - Pt[0]; + for (i = 1; i <= USHRT_MAX; i++) { + Pt[i] = Pt[i - 1] + prob[i]; + Pq[i] = 1.0 - Pt[i - 1]; + } + + start = 0; + while (prob[start++] <= 0.0); + end = USHRT_MAX; + while (prob[end--] <= 0.0); + + /* Calculate the function to be minimized at all levels */ + t = -1; + for (i = start; i <= end; i++) { + if (prob[i] <= 0.0) continue; + Sb = _p3dJohannsenThresholding_dlog(Pt[i]) + (1.0 / Pt[i])* + (_p3dJohannsenThresholding_entropy(prob[i]) + _p3dJohannsenThresholding_entropy(Pt[i - 1])); + Sw = _p3dJohannsenThresholding_dlog(Pq[i]) + (1.0 / Pq[i])* + (_p3dJohannsenThresholding_entropy(prob[i]) + _p3dJohannsenThresholding_entropy(Pq[i + 1])); + F[i] = Sb + Sw; + if (t < 0) t = i; + else if (F[i] < F[t]) t = i; + } + + + *thresh = (unsigned short) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + if (Pq != NULL) free(Pq); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + if (Pq != NULL) free(Pq); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dKapurThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dKapurThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..101edd4d583edc690491fab3a3d3da3d9a3e4dc0 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dKapurThresholding.c @@ -0,0 +1,213 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +#define _USE_MATH_DEFINES +#include <math.h> + +double _p3dKapurThresholding_entropy(double *h, int a, double p) { + if (h[a] > 0.0 && p > 0.0) + return -(h[a] / p * log((double) (h[a]) / p)); + return 0.0; +} + + +int p3dKapurThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double* prob; + double *Pt, *F; + double Hb, Hw; + + int i, j, ct, t; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Kapur's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(Pt = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(prob = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= UCHAR_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute the factors */ + Pt[0] = prob[0]; + for (i = 1; i <= UCHAR_MAX; i++) + Pt[i] = Pt[i - 1] + prob[i]; + + /* Calculate the function to be maximized at all levels */ + t = 0; + for (i = 0; i <= UCHAR_MAX; i++) { + Hb = Hw = 0.0; + for (j = 0; j <= UCHAR_MAX; j++) + if (j <= i) + Hb += _p3dKapurThresholding_entropy(prob, j, Pt[i]); + else + Hw += _p3dKapurThresholding_entropy(prob, j, 1.0 - Pt[i]); + + F[i] = Hb + Hw; + if (i > 0 && F[i] > F[t]) t = i; + } + + *thresh = (unsigned char) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Return error: + return P3D_ERROR; + +} + +int p3dKapurThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double* prob; + double *Pt, *F; + double Hb, Hw; + + int i, j, ct, t; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Kapur's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(Pt = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(prob = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= USHRT_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute the factors */ + Pt[0] = prob[0]; + for (i = 1; i <= USHRT_MAX; i++) + Pt[i] = Pt[i - 1] + prob[i]; + + /* Calculate the function to be maximized at all levels */ + t = 0; + for (i = 0; i <= USHRT_MAX; i++) { + Hb = Hw = 0.0; + for (j = 0; j <= USHRT_MAX; j++) + if (j <= i) + Hb += _p3dKapurThresholding_entropy(prob, j, Pt[i]); + else + Hw += _p3dKapurThresholding_entropy(prob, j, 1.0 - Pt[i]); + + F[i] = Hb + Hw; + if (i > 0 && F[i] > F[t]) t = i; + } + + + + *thresh = (unsigned short) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dKittlerThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dKittlerThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..63d59e23e23ce529eff3d5f3534640df75c5dac9 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dKittlerThresholding.c @@ -0,0 +1,274 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +double _p3dKittlerTresholding_log(double x) { + if (x > 0.0) + return log(x); + else + return 0.0; +} + +double _p3dKittlerTresholding_P1(int t, double* h) { + long i; + double sum; + + sum = 0.0; + for (i = 0; i <= t; i++) + sum += h[i]; + + return sum; +} + +double _p3dKittlerTresholding_P2(int t, double* h, int hist_length) { + long i; + double sum; + + sum = 0.0; + for (i = t + 1; i <= hist_length; i++) + sum += h[i]; + + return sum; +} + +double _p3dKittlerTresholding_u1(int t, double* h) { + int i; + double sum, p; + + sum = 0.0; + p = _p3dKittlerTresholding_P1(t, h); + if (p <= 0.0) + return 0.0; + + for (i = 0; i <= t; i++) + sum += h[i] * i; + + return sum / p; +} + +double _p3dKittlerTresholding_u2(int t, double* h, int hist_length) { + int i; + double sum, p; + + sum = 0.0; + p = _p3dKittlerTresholding_P2(t, h, hist_length); + if (p <= 0.0) + return 0.0; + + for (i = t + 1; i <= hist_length; i++) + sum += h[i] * i; + + return sum / p; +} + +double _p3dKittlerTresholding_s1(int t, double* h) { + int i; + double sum, p, u, x; + + sum = 0.0; + p = _p3dKittlerTresholding_P1(t, h); + + if (p <= 0.0) + return 0.0; + + u = _p3dKittlerTresholding_u1(t, h); + for (i = 0; i <= t; i++) { + x = (i - u)*(i - u); + sum += x * h[i]; + } + + return sum / p; +} + +double _p3dKittlerTresholding_s2(int t, double* h, int hist_length) { + int i; + double sum, p, u, x; + + sum = 0.0; + p = _p3dKittlerTresholding_P2(t, h, hist_length); + + if (p <= 0.0) + return 0.0; + + u = _p3dKittlerTresholding_u2(t, h, hist_length); + for (i = t + 1; i <= hist_length; i++) { + x = (i - u)*(i - u); + sum += x * h[i]; + } + + return sum / p; +} + +double _p3dKittlerTresholding_J(int t, double* h, int hist_length) { + double a, b, c, d, x1; + + a = _p3dKittlerTresholding_P1(t, h); + b = _p3dKittlerTresholding_s1(t, h); + c = _p3dKittlerTresholding_P2(t, h, hist_length); + d = _p3dKittlerTresholding_s2(t, h, hist_length); + + x1 = 1.0 + 2.0 * (a * _p3dKittlerTresholding_log(b) + c * _p3dKittlerTresholding_log(d)) - + 2.0 * (a * _p3dKittlerTresholding_log(a) + c * _p3dKittlerTresholding_log(c)); + + return x1; +} + +int p3dKittlerThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) { + + double* prob; + double* F; + int i, ct; + int tbest = 0; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Kittler and Illingworth method..."); + } + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(prob = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + P3D_MEM_TRY(F = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + + /* Compute thresholding according to Kittler's minimum error thresholding: */ + for (i = 1; i <= UCHAR_MAX; i++) { + F[i] = _p3dKittlerTresholding_J(i, prob, UCHAR_MAX); + if (F[i] < F[tbest]) + tbest = i; + } + + *thresh = (unsigned char) tbest; + + + /* Threshold image: */ + //#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + // Free memory: + if (prob != NULL) free(prob); + if (F != NULL) free(F); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (F != NULL) free(F); + + // Return error: + return P3D_ERROR; + +} + +int p3dKittlerThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) { + + double* prob; + double* F; + int i, ct; + int tbest = 0; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Kittler and Illingworth method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(prob = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + P3D_MEM_TRY(F = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + + /* Compute thresholding according to Kittler's minimum error thresholding: */ + for (i = 1; i <= USHRT_MAX; i++) { + F[i] = _p3dKittlerTresholding_J(i, prob, USHRT_MAX); + if (F[i] < F[tbest]) + tbest = i; + } + + *thresh = (unsigned short) tbest; + + /* Threshold image: */ + //#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (prob != NULL) free(prob); + if (F != NULL) free(F); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (F != NULL) free(F); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dMeanFilter.c b/pypore3d/pypore3d/P3D_Filt/p3dMeanFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..b824841993f4c4a9a8a994bfd0e874c6a0fd11f8 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dMeanFilter.c @@ -0,0 +1,309 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#define _USE_MATH_DEFINES +#include <math.h> +#include <limits.h> //amal + +#include "p3dFilt.h" +#include "p3dTime.h" + + +int p3dMeanFilter3D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Padded input and related dims: + float* tmp_im = NULL; + float* kernel = NULL; + + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct, a_rad, a_size; + double sum, sum_w; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying mean filter..."); + wr_log("\tKernel size: %d.", size); + } + + // Set kernel size and variance: + if (size < 1.0) + a_rad = 1; + else + a_rad = (int) (ceil(size / 2.0)); + a_size = 2 * a_rad + 1; + + + // Compute dimensions of padded volume: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + + // Initialize input: + P3D_MEM_TRY(tmp_im = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + P3D_MEM_TRY(kernel = (float*) malloc(a_size * sizeof (float))); + + P3D_TRY(_p3dReplicatePadding3D_uchar2float(in_im, tmp_im, dimx, dimy, dimz, a_rad)); + + ct = 0; + sum_w = 0.0; + + // Create mean kernel: + for (x = (-a_rad); x <= a_rad; x++) { + + kernel[ct] = 1.0; + sum_w = sum_w + kernel[ct++]; + } + ct = 0; + // Normalize kernel + for (x = (-a_rad); x <= a_rad; x++) + kernel[ct] = kernel[ct++]/ ( (float) sum_w ); + + // X-direction scanning +#pragma omp parallel for private(i, j, x, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (x = (i - a_rad); x <= (i + a_rad); x++) { + sum = sum + kernel[ct++] * tmp_im[ I(x, j, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + } + } + + // Y-direction scanning +#pragma omp parallel for private(i, j, y, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (y = (j - a_rad); y <= (j + a_rad); y++) { + sum = sum + kernel[ct++] * tmp_im[ I(i, y, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + + // Z-direction scanning +#pragma omp parallel for private(i, j, z, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + sum = sum + kernel[ct++] * tmp_im[ I(i, j, z, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + if (sum < 0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = 0; + else if (sum > UCHAR_MAX) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = UCHAR_MAX; + else + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = (unsigned char) sum; + + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Mean filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return error: + return P3D_ERROR; + +} + +int p3dMeanFilter3D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Padded input and related dims: + float* tmp_im = NULL; + float* kernel = NULL; + + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int ct, a_rad, a_size; + double sum, sum_w; + + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying mean filter..."); + wr_log("\tKernel size: %d.", size); + } + + // Set kernel size and variance: + if (size < 1.0) + a_rad = 1; + else + a_rad = (int) (ceil(size / 2.0)); + a_size = 2 * a_rad + 1; + + // Compute dimensions of padded volume: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + + // Initialize input: + P3D_MEM_TRY(tmp_im = (float*) malloc(a_dimx * a_dimy * a_dimz * sizeof (float))); + P3D_MEM_TRY(kernel = (float*) malloc(a_size * sizeof (float))); + + P3D_TRY(_p3dReplicatePadding3D_ushort2float(in_im, tmp_im, dimx, dimy, dimz, a_rad)); + + ct = 0; + sum_w = 0.0; + + // Create mean kernel: + for (x = (-a_rad); x <= a_rad; x++) { + kernel[ct] = 1.0; + sum_w = sum_w + kernel[ct++]; + } + ct = 0; + // Normalize kernel: + for (x = (-a_rad); x <= a_rad; x++) + kernel[ct] = kernel[ct++]/ ((float) sum_w); + + // X-direction scanning +#pragma omp parallel for private(i, j, x, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (x = (i - a_rad); x <= (i + a_rad); x++) { + sum = sum + kernel[ct++] * tmp_im[ I(x, j, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + + // Y-direction scanning +#pragma omp parallel for private(i, j, y, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (y = (j - a_rad); y <= (j + a_rad); y++) { + sum = sum + kernel[ct++] * tmp_im[ I(i, y, k, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (float) sum; + } + + // Z-direction scanning +#pragma omp parallel for private(i, j, z, sum, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + sum = 0.0; + ct = 0; + + // Process kernel: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + sum = sum + kernel[ct++] * tmp_im[ I(i, j, z, a_dimx, a_dimy) ]; + } + + // Set out voxel with the mean of the sorted temporary array: + if (sum < 0) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = 0; + else if (sum > USHRT_MAX) + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = USHRT_MAX; + else + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = (unsigned short) sum; + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Mean filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (kernel != NULL) free(kernel); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dMedianFilter.c b/pypore3d/pypore3d/P3D_Filt/p3dMedianFilter.c new file mode 100644 index 0000000000000000000000000000000000000000..abfe0ed1404479583c33b47a0a74544c052d480d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dMedianFilter.c @@ -0,0 +1,288 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <limits.h> +#include <omp.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + + + + +int p3dMedianFilter3D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Padded input and related dims: + unsigned char* tmp_im; + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int pr = 0; + + // Variables for computing kernel: + int a_rad, ct; + + // Temporary array: + unsigned int* hist; + unsigned int sum; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying median filter..."); + wr_log("\tKernel size: %d.", size); + } + + + // Init variables: + a_rad = size / 2; // integer division + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Get the replicate padded input: + P3D_MEM_TRY(tmp_im = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + P3D_TRY(p3dReplicatePadding3D_8(in_im, tmp_im, dimx, dimy, dimz, a_rad, NULL, NULL)); + + + // Volume scanning: +#pragma omp parallel for private(i, j, x, y, z, ct, sum, hist) reduction( + : pr) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + // Allocate and initialize to zero kernel histogram: + hist = (unsigned int*) calloc((UCHAR_MAX + 1), sizeof (unsigned int)); + + // Compute histogram for first step: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + for (y = (j - a_rad); y <= (j + a_rad); y++) { + for (x = 0; x <= (2 * a_rad); x++) { + hist[tmp_im[ I(x, y, z, a_dimx, a_dimy) ]]++; + } + } + } + + + // Compute median: + ct = -1; + sum = 0; + while (sum <= ((unsigned int) ((size * size * size) / 2))) { + sum += hist[++ct]; + } + + // Set out voxel with the median: + out_im[ I(0, j - a_rad, k - a_rad, dimx, dimy) ] = ct; + + // Increase progress counter: + pr++; + + + // Scan along x dimension: + for (i = (a_rad + 1); i < (a_dimx - a_rad); i++) { + // Update "sliding" histogram: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + for (y = (j - a_rad); y <= (j + a_rad); y++) { + hist[tmp_im[ I(i - a_rad - 1, y, z, a_dimx, a_dimy) ]]--; + hist[tmp_im[ I(i + a_rad, y, z, a_dimx, a_dimy) ]]++; + } + } + + // Compute median: + ct = -1; + sum = 0; + while (sum <= ( (unsigned int) (((size * size * size) / 2)))) { + sum += hist[++ct]; + } + + // Set out voxel with the median: + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = ct; + + // Increase progress counter: + pr++; + } + + // Clear histogram: + if (hist != NULL) free(hist); + } + + // Update any progress bar: + if (wr_progress != NULL) wr_progress((int) ((double) (pr) / (dimx * dimy * dimz)*100 + 0.5)); + } + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Median filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + + // Return error: + return P3D_ERROR; + +} + + +int p3dMedianFilter3D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + // Padded input and related dims: + unsigned short* tmp_im; + + int a_dimx, a_dimy, a_dimz; + int i, j, k; + int x, y, z; + int pr = 0; + + // Variables for computing kernel: + int a_rad, ct; + + // Temporary array: + unsigned int* hist; + unsigned int sum; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying median filter..."); + wr_log("\tKernel size: %d.", size); + } + + + // Init variables: + a_rad = size / 2; // integer division + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + // Get the replicate padded input: + P3D_MEM_TRY(tmp_im = (unsigned short*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned short))); + P3D_TRY(p3dReplicatePadding3D_16(in_im, tmp_im, dimx, dimy, dimz, a_rad, NULL, NULL)); + + + // Volume scanning: +#pragma omp parallel for private(i, j, x, y, z, ct, sum, hist) reduction( + : pr) + for (k = a_rad; k < (a_dimz - a_rad); k++) { + for (j = a_rad; j < (a_dimy - a_rad); j++) { + // Allocate and initialize to zero kernel histogram: + hist = (unsigned int*) calloc((USHRT_MAX + 1), sizeof (unsigned int)); + + // Compute histogram for first step: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + for (y = (j - a_rad); y <= (j + a_rad); y++) { + for (x = 0; x <= (2 * a_rad); x++) { + hist[tmp_im[ I(x, y, z, a_dimx, a_dimy) ]]++; + } + } + } + + + // Compute median: + ct = -1; + sum = 0; + while (sum <= ((unsigned int) ((size * size * size) / 2))) { + sum += hist[++ct]; + } + + // Set out voxel with the median: + out_im[ I(0, j - a_rad, k - a_rad, dimx, dimy) ] = ct; + + // Increase progress counter: + pr++; + + + // Scan along x dimension: + for (i = (a_rad + 1); i < (a_dimx - a_rad); i++) { + // Update "sliding" histogram: + for (z = (k - a_rad); z <= (k + a_rad); z++) { + for (y = (j - a_rad); y <= (j + a_rad); y++) { + hist[tmp_im[ I(i - a_rad - 1, y, z, a_dimx, a_dimy) ]]--; + hist[tmp_im[ I(i + a_rad, y, z, a_dimx, a_dimy) ]]++; + } + } + + // Compute median: + ct = -1; + sum = 0; + while (sum <= ( (unsigned int) (((size * size * size) / 2)))) { + sum += hist[++ct]; + } + + // Set out voxel with the median: + out_im[ I(i - a_rad, j - a_rad, k - a_rad, dimx, dimy) ] = ct; + + // Increase progress counter: + pr++; + } + + // Clear histogram: + if (hist != NULL) free(hist); + } + + // Update any progress bar: + if (wr_progress != NULL) wr_progress((int) ((double) (pr) / (dimx * dimy * dimz)*100 + 0.5)); + } + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Median filter applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + + // Return error: + return P3D_ERROR; + +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dOtsuThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dOtsuThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..5fd4ceebcb192fbe70f6d14ba31741e44563e84f --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dOtsuThresholding.c @@ -0,0 +1,241 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +double _p3dOtsuThresholding_w(double *p, int k) { + int i; + double x = 0.0; + + for (i = 0; i < k; i++) + x += p[i]; + + return x; +} + +double _p3dOtsuThresholding_u(double *p, int k) { + int i; + double x = 0.0; + + for (i = 0; i < k; i++) + x += (double) i * p[i]; + return x; +} + +double _p3dOtsuThresholding_nu(double *p, int k, double ut, double vt) { + double x, y; + + y = _p3dOtsuThresholding_w(p, k); + x = ut * y - _p3dOtsuThresholding_u(p, k); + x = x*x; + y = y * (1.0 - y); + if (y > 0) + x = x / y; + else + x = 0.0; + + return x / vt; +} + + +int p3dOtsuThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double* prob; + int i, j, k, m; + double y, z; + double ut, vt; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Otsu's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(prob = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= UCHAR_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute global mean: */ + ut = _p3dOtsuThresholding_u(prob, UCHAR_MAX); + + /* Copute global variance: */ + vt = 0.0; + for (i = 0; i <= UCHAR_MAX; i++) + vt += (i - ut)*(i - ut) * prob[i]; + + j = -1; + k = -1; + for (i = 0; i <= UCHAR_MAX; i++) { + if ((j < 0) && (prob[i] > 0.0)) + /* First index handling: */ + j = i; + if (prob[i] > 0.0) + /* Last index handling: */ + k = i; + } + z = -1.0; + m = -1; + for (i = j; i <= k; i++) { + /* Compute NU: */ + y = _p3dOtsuThresholding_nu(prob, i, ut, vt); + /* Check if it is the biggest and save value: */ + if (y >= z) { + z = y; + m = i; + } + } + + *thresh = (unsigned char) m; + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (prob != NULL) free(prob); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + + // Return error: + return P3D_ERROR; + +} + +int p3dOtsuThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double* prob; + int i, j, k, m; + double y, z; + double ut, vt; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Otsu's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(prob = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= USHRT_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute global mean: */ + ut = _p3dOtsuThresholding_u(prob, USHRT_MAX); + + /* Copute global variance: */ + vt = 0.0; + for (i = 0; i <= USHRT_MAX; i++) + vt += (i - ut)*(i - ut) * prob[i]; + + j = -1; + k = -1; + for (i = 0; i <= USHRT_MAX; i++) { + if ((j < 0) && (prob[i] > 0.0)) + /* First index handling: */ + j = i; + if (prob[i] > 0.0) + /* Last index handling: */ + k = i; + } + z = -1.0; + m = -1; + for (i = j; i <= k; i++) { + /* Compute NU: */ + y = _p3dOtsuThresholding_nu(prob, i, ut, vt); + /* Check if it is the biggest and save value: */ + if (y >= z) { + z = y; + m = i; + } + } + + *thresh = (unsigned short) m; + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (prob != NULL) free(prob); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dPadding.c b/pypore3d/pypore3d/P3D_Filt/p3dPadding.c new file mode 100644 index 0000000000000000000000000000000000000000..0eb1a8bdcb583f507ea5f64e7d484e1c3fbaf057 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dPadding.c @@ -0,0 +1,991 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +int p3dZeroPadding2D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, // ncols + const int dimy, // nrows + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy; + int i, j; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + + // Set to zero all values: + memset(out_im, 0, a_dimx * a_dimy * sizeof (unsigned char)); + + // Copy original (internal) values: + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_im[ I2(i + size, j + size, a_dimx) ] = in_im[ I2(i, j, dimx) ]; + } + } + + return P3D_SUCCESS; +} + +int p3dZeroPadding2D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, // ncols + const int dimy, // nrows + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy; + int i, j; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + + // Set to zero all values: + memset(out_im, 0, a_dimx * a_dimy * sizeof (unsigned short)); + + // Copy original (internal) values: + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_im[ I2(i + size, j + size, a_dimx) ] = in_im[ I2(i, j, dimx) ]; + } + } + + return P3D_SUCCESS; +} + +int p3dZeroPadding3D_8( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + // Set to zero all values: + memset(out_rev, 0, a_dimx * a_dimy * a_dimz * sizeof (unsigned char)); + + + // Copy original (internal) values: + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_rev[ I(i + size, j + size, k + size, a_dimx, a_dimy) ] = + in_rev[ I(i, j, k, dimx, dimy) ]; + } + } + } + + // Return OK: + return P3D_SUCCESS; +} + +int p3dZeroPadding3D_16( + unsigned short* in_rev, + unsigned short* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + // Set to zero all values: + memset(out_rev, 0, a_dimx * a_dimy * a_dimz * sizeof (unsigned short)); + + + // Copy original (internal) values: + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_rev[ I(i + size, j + size, k + size, a_dimx, a_dimy) ] = + in_rev[ I(i, j, k, dimx, dimy) ]; + } + } + } + + // Return OK: + return P3D_SUCCESS; +} + +int p3dReplicatePadding2D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, // ncols + const int dimy, // nrows + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy; + int i, j, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + + + // Perform first zero padding: + p3dZeroPadding2D_8(in_im, out_im, dimx, dimy, size, NULL, NULL); + + + // Replicate border values: + for (ct = size; ct > 0; ct--) { + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_im[ I2(i, ct - 1, a_dimx) ] = + out_im[ I2(i, ct, a_dimx) ]; + out_im[ I2(i, a_dimy - ct, a_dimx) ] = + out_im[ I2(i, a_dimy - 1 - ct, a_dimx) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_im[ I2(ct - 1, j, a_dimx) ] = + out_im[ I2(ct, j, a_dimx) ]; + out_im[ I2(a_dimx - ct, j, a_dimx) ] = + out_im[ I2(a_dimx - 1 - ct, j, a_dimx) ]; + } + + // Corners: + + out_im[ I2(ct - 1, ct - 1, a_dimx)] = + out_im[ I2(ct, ct, a_dimx) ]; + + out_im[ I2(a_dimx - ct, ct - 1, a_dimx)] = + out_im[ I2(a_dimx - 1 - ct, ct, a_dimx) ]; + + out_im[ I2(ct - 1, a_dimy - ct, a_dimx)] = + out_im[ I2(ct, a_dimy - 1 - ct, a_dimx) ]; + + out_im[ I2(a_dimx - ct, a_dimy - ct, a_dimx)] = + out_im[ I2(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimx) ]; + + } + + return P3D_SUCCESS; +} + +int p3dReplicatePadding2D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, // ncols + const int dimy, // nrows + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy; + int i, j, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + + + // Perform first zero padding: + p3dZeroPadding2D_16(in_im, out_im, dimx, dimy, size, NULL, NULL); + + + // Replicate border values: + for (ct = size; ct > 0; ct--) { + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_im[ I2(i, ct - 1, a_dimx) ] = + out_im[ I2(i, ct, a_dimx) ]; + out_im[ I2(i, a_dimy - ct, a_dimx) ] = + out_im[ I2(i, a_dimy - 1 - ct, a_dimx) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_im[ I2(ct - 1, j, a_dimx) ] = + out_im[ I2(ct, j, a_dimx) ]; + out_im[ I2(a_dimx - ct, j, a_dimx) ] = + out_im[ I2(a_dimx - 1 - ct, j, a_dimx) ]; + } + + // Corners: + + out_im[ I2(ct - 1, ct - 1, a_dimx)] = + out_im[ I2(ct, ct, a_dimx) ]; + + out_im[ I2(a_dimx - ct, ct - 1, a_dimx)] = + out_im[ I2(a_dimx - 1 - ct, ct, a_dimx) ]; + + out_im[ I2(ct - 1, a_dimy - ct, a_dimx)] = + out_im[ I2(ct, a_dimy - 1 - ct, a_dimx) ]; + + out_im[ I2(a_dimx - ct, a_dimy - ct, a_dimx)] = + out_im[ I2(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimx) ]; + + } + + return P3D_SUCCESS; + +} + +int p3dReplicatePadding3D_8( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + + // Perform first zero padding: + p3dZeroPadding3D_8(in_rev, out_rev, dimx, dimy, dimz, size, NULL, NULL); + + + // Replicate border values: + for (ct = size; ct > 0; ct--) { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) { + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(i, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + } + + for (j = ct; j < (a_dimy - ct); j++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, j, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, j, k, a_dimx, a_dimy) ]; + } + } + + for (i = ct; i < (a_dimx - ct); i++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(i, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I(i, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I(i, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_rev[ I(i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(a_dimx - 1 - ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + + // Corners: + + out_rev[ I(ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + out_rev[ I(a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + } + + // Return OK: + return P3D_SUCCESS; +} + +int p3dReplicatePadding3D_16( + unsigned short* in_rev, + unsigned short* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + + // Perform first zero padding: + p3dZeroPadding3D_16(in_rev, out_rev, dimx, dimy, dimz, size, NULL, NULL); + + + // Replicate border values: + for (ct = size; ct > 0; ct--) { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) { + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(i, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + } + + for (j = ct; j < (a_dimy - ct); j++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, j, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, j, k, a_dimx, a_dimy) ]; + } + } + + for (i = ct; i < (a_dimx - ct); i++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(i, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I(i, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I(i, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_rev[ I(i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(a_dimx - 1 - ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + + // Corners: + out_rev[ I(ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + out_rev[ I(a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + } + + // Return OK: + return P3D_SUCCESS; +} + + +int _p3dZeroPadding3D_float( + float* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + // Set to zero all values: + memset(out_rev, 0, a_dimx * a_dimy * a_dimz * sizeof (float)); + + + // Copy original (internal) values: + #pragma omp parallel for private(i, j) + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_rev[ I(i + size, j + size, k + size, a_dimx, a_dimy) ] = + (float) (in_rev[ I(i, j, k, dimx, dimy) ]); + } + } + } + + // Return OK: + return P3D_SUCCESS; +} + +int _p3dReplicatePadding3D_float( + float* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + + // Perform first zero padding: + _p3dZeroPadding3D_float(in_rev, out_rev, dimx, dimy, dimz, size); + + + // Replicate border values: + #pragma omp parallel for private(i, j, k) + for (ct = size; ct > 0; ct--) { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) { + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(i, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + } + + for (j = ct; j < (a_dimy - ct); j++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, j, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, j, k, a_dimx, a_dimy) ]; + } + } + + for (i = ct; i < (a_dimx - ct); i++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(i, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I(i, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I(i, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_rev[ I(i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(i, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I(a_dimx - 1 - ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + out_rev[ I(ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + + // Corners: + + out_rev[ I(ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + out_rev[ I(a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + } + + // Return OK: + return P3D_SUCCESS; +} + +int _p3dZeroPadding3D_uchar2float( + unsigned char* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + // Set to zero all values: + memset(out_rev, 0, a_dimx * a_dimy * a_dimz * sizeof (float)); + + + // Copy original (internal) values: + #pragma omp parallel for private(i, j) + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_rev[ I(i + size, j + size, k + size, a_dimx, a_dimy) ] = + (float) (in_rev[ I(i, j, k, dimx, dimy) ]); + } + } + } + + // Return OK: + return P3D_SUCCESS; +} + +int _p3dReplicatePadding3D_uchar2float( + unsigned char* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + + // Perform first zero padding: + _p3dZeroPadding3D_uchar2float(in_rev, out_rev, dimx, dimy, dimz, size); + + + // Replicate border values: + #pragma omp parallel for private(i, j, k) + for (ct = size; ct > 0; ct--) { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) { + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(i, j, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, j, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(i, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + } + + for (j = ct; j < (a_dimy - ct); j++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, j, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, j, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, k, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, j, k, a_dimx, a_dimy) ]; + } + } + + for (i = ct; i < (a_dimx - ct); i++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(i, ct - 1, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, k, a_dimx, a_dimy)] = + (float) out_rev[ I(i, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_rev[ I(i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(i, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(a_dimx - 1 - ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + + // Corners: + + out_rev[ I(ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + out_rev[ I(a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + } + + // Return OK: + return P3D_SUCCESS; +} + +int _p3dZeroPadding3D_ushort2float( + unsigned short* in_rev, + float* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + // Set to zero all values: + memset(out_rev, 0, a_dimx * a_dimy * a_dimz * sizeof (float)); + + + // Copy original (internal) values: + #pragma omp parallel for private(i, j) + for (k = 0; k < dimz; k++) { + for (j = 0; j < dimy; j++) { + for (i = 0; i < dimx; i++) { + out_rev[ I(i + size, j + size, k + size, a_dimx, a_dimy) ] = + (float) (in_rev[ I(i, j, k, dimx, dimy) ]); + } + } + } + + // Return OK: + return P3D_SUCCESS; +} + +int _p3dReplicatePadding3D_ushort2float( + unsigned short* in_rev, + float* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i, j, k, ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size * 2; + a_dimy = dimy + size * 2; + a_dimz = dimz + size * 2; + + + // Perform first zero padding: + _p3dZeroPadding3D_ushort2float(in_rev, out_rev, dimx, dimy, dimz, size); + + + // Replicate border values: + #pragma omp parallel for private(i, j, k) + for (ct = size; ct > 0; ct--) { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) { + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(i, j, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, j, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(i, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + } + + for (j = ct; j < (a_dimy - ct); j++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, j, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, j, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, k, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, j, k, a_dimx, a_dimy) ]; + } + } + + for (i = ct; i < (a_dimx - ct); i++) { + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(i, ct - 1, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, k, a_dimx, a_dimy)] = + (float) out_rev[ I(i, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) { + out_rev[ I(i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(i, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(i, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + out_rev[ I(i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) { + out_rev[ I(ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + (float) out_rev[ I(a_dimx - 1 - ct, j, ct, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) { + out_rev[ I(ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, ct, k, a_dimx, a_dimy) ]; + out_rev[ I(ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + (float) out_rev[ I(ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + out_rev[ I(a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy) ]; + } + + // Corners: + + out_rev[ I(ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + + out_rev[ I(a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy) ]; + + out_rev[ I(ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + out_rev[ I(a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + (float) out_rev[ I(a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy) ]; + + } + + // Return OK: + return P3D_SUCCESS; +} + diff --git a/pypore3d/pypore3d/P3D_Filt/p3dPunThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dPunThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..9db138eedb436c4d0a7601efbfd23e3ba7ac367e --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dPunThresholding.c @@ -0,0 +1,268 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +double _p3dPunThresholding_entropy(double *h, int a) { + if (h[a] > 0.0) + return -(h[a] * log((double) h[a])); + return 0.0; +} + +double _p3dPunThresholding_flog(double x) { + if (x <= 0.0) + return 0.0; + return log((double) x); +} + +double _p3dPunThresholding_maxtot(double *h, int i) { + double x; + int j; + + x = h[0]; + for (j = 1; j <= i; j++) + if (x < h[j]) + x = h[j]; + return x; +} + +double _p3dPunThresholding_maxfromt_8(double *h, int i) { + int j; + double x; + + x = h[i + 1]; + for (j = i + 2; j <= UCHAR_MAX; j++) + if (x < h[j]) + x = h[j]; + return x; +} + +double _p3dPunThresholding_maxfromt_16(double *h, int i) { + int j; + double x; + + x = h[i + 1]; + for (j = i + 2; j <= USHRT_MAX; j++) + if (x < h[j]) + x = h[j]; + return x; +} + + +int p3dPunThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + + double* prob = NULL; + double *Ht = NULL; + double *Pt = NULL; + double *F = NULL; + double HT, x, y, z, to, from; + int i, ct, t; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Pun's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(Ht = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(Pt = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(UCHAR_MAX + 1))); + P3D_MEM_TRY(prob = (double*) calloc((UCHAR_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= UCHAR_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute the factors */ + HT = Ht[0] = _p3dPunThresholding_entropy(prob, 0); + Pt[0] = prob[0]; + for (i = 1; i <= UCHAR_MAX; i++) { + Pt[i] = Pt[i - 1] + prob[i]; + x = _p3dPunThresholding_entropy(prob, i); + Ht[i] = Ht[i - 1] + x; + HT += x; + } + + /* Calculate the function to be maximized at all levels */ + t = 0; + for (i = 0; i <= UCHAR_MAX; i++) { + to = (_p3dPunThresholding_maxtot(prob, i)); + from = _p3dPunThresholding_maxfromt_8(prob, i); + if (to > 0.0 && from > 0.0) { + x = (Ht[i] / HT) * _p3dPunThresholding_flog(Pt[i]) / _p3dPunThresholding_flog(to); + y = 1.0 - (Ht[i] / HT); + z = _p3dPunThresholding_flog(1 - Pt[i]) / _p3dPunThresholding_flog(from); + } else x = y = z = 0.0; + F[i] = x + y*z; + if (i > 0 && F[i] > F[t]) t = i; + } + + *thresh = (unsigned char) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Ht != NULL) free(Ht); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Ht != NULL) free(Ht); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Return error: + return P3D_ERROR; + +} + +int p3dPunThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + double* prob = NULL; + double *Ht = NULL; + double *Pt = NULL; + double *F = NULL; + double HT, x, y, z, to, from; + int i, ct, t; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Pun's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + P3D_MEM_TRY(Ht = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(Pt = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(F = (double *) malloc(sizeof (double) *(USHRT_MAX + 1))); + P3D_MEM_TRY(prob = (double*) calloc((USHRT_MAX + 1), sizeof (double))); + + /* Compute image histogram: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + prob[in_im[ ct ]] = prob[in_im[ ct ]] + 1.0; + + /* Compute probabilities: */ + for (ct = 0; ct <= USHRT_MAX; ct++) + prob[ct] = prob[ct] / (double) (dimx * dimy * dimz); + + /* Compute the factors */ + HT = Ht[0] = _p3dPunThresholding_entropy(prob, 0); + Pt[0] = prob[0]; + for (i = 1; i <= USHRT_MAX; i++) { + Pt[i] = Pt[i - 1] + prob[i]; + x = _p3dPunThresholding_entropy(prob, i); + Ht[i] = Ht[i - 1] + x; + HT += x; + } + + /* Calculate the function to be maximized at all levels */ + t = 0; + for (i = 0; i <= USHRT_MAX; i++) { + to = (_p3dPunThresholding_maxtot(prob, i)); + from = _p3dPunThresholding_maxfromt_16(prob, i); + if (to > 0.0 && from > 0.0) { + x = (Ht[i] / HT) * _p3dPunThresholding_flog(Pt[i]) / _p3dPunThresholding_flog(to); + y = 1.0 - (Ht[i] / HT); + z = _p3dPunThresholding_flog(1 - Pt[i]) / _p3dPunThresholding_flog(from); + } else x = y = z = 0.0; + F[i] = x + y*z; + if (i > 0 && F[i] > F[t]) t = i; + } + + *thresh = (unsigned short) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Ht != NULL) free(Ht); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory: + if (prob != NULL) free(prob); + if (Ht != NULL) free(Ht); + if (Pt != NULL) free(Pt); + if (F != NULL) free(F); + + // Return error: + return P3D_ERROR; + +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dRidlerThresholding.c b/pypore3d/pypore3d/P3D_Filt/p3dRidlerThresholding.c new file mode 100644 index 0000000000000000000000000000000000000000..9deac68f62f5fce1c0d77de259e99ef33d706ff9 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dRidlerThresholding.c @@ -0,0 +1,158 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <omp.h> +#include <limits.h> + +#include "p3dFilt.h" +#include "p3dTime.h" + +int p3dRidlerThresholding_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned char* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) { + + double tt, tb, to, t2; + int t; + long N, no, nb; + + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Ridler's method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + N = dimx * dimy*dimz; + tb = 0.0; + to = 0.0; + no = 0; + for (ct = 0; ct < dimx * dimy * dimz; ct++) + to = to + (in_im[ct]); + tt = (to / (double) N); + + while (N) { + no = 0; + nb = 0; + tb = 0.0; + to = 0.0; + for (ct = 0; ct < dimx * dimy * dimz; ct++) { + if ((double) (in_im[ct]) >= tt) { + to = to + (double) (in_im[ct]); + no++; + } + else { + tb = tb + (double) (in_im[ct]); + nb++; + } + } + + if (no == 0) no = 1; + if (nb == 0) nb = 1; + t2 = (tb / (double) nb + to / (double) no) / 2.0; + if (t2 == tt) N = 0; + tt = t2; + } + t = (int) tt; + + *thresh = (unsigned char) t; + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; + +} + +int p3dRidlerThresholding_16( + unsigned short* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + unsigned short* thresh, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) { + + double tt, tb, to, t2; + int t; + long N, no, nb; + + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Thresholding image according to Ridler's iterative method..."); + } + + + /* Allocate and initialize to zero kernel histogram: */ + N = dimx * dimy*dimz; + tb = 0.0; + to = 0.0; + no = 0; + for (ct = 0; ct < dimx * dimy * dimz; ct++) + to = to + (in_im[ct]); + tt = (to / (double) N); + + while (N) { + no = 0; + nb = 0; + tb = 0.0; + to = 0.0; + for (ct = 0; ct < dimx * dimy * dimz; ct++) { + if ((double) (in_im[ct]) >= tt) { + to = to + (double) (in_im[ct]); + no++; + } + else { + tb = tb + (double) (in_im[ct]); + nb++; + } + } + + if (no == 0) no = 1; + if (nb == 0) nb = 1; + t2 = (tb / (double) nb + to / (double) no) / 2.0; + if (t2 == tt) N = 0; + tt = t2; + } + t = (int) tt; + + *thresh = (unsigned short) t; + + + +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) + out_im[ ct ] = (in_im[ ct ] > (*thresh)) ? OBJECT : BACKGROUND; + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("\tDetermined threshold: %d.", *thresh); + wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return success: + return P3D_SUCCESS; +} diff --git a/pypore3d/pypore3d/P3D_Filt/p3dSijbersPostnovRingRemover.c b/pypore3d/pypore3d/P3D_Filt/p3dSijbersPostnovRingRemover.c new file mode 100644 index 0000000000000000000000000000000000000000..7081d231af2cd68e89f8c16ae720efed44cb04fb --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dSijbersPostnovRingRemover.c @@ -0,0 +1,656 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <limits.h> +#include <omp.h> + +#include "p3dFilt.h" +#include "p3dTime.h" +#include "Common/p3dRingRemoverCommon.h" + +#define P3DISIJBERSPOSTNOV_RINGREMOVER_ELEM_SWAP(a,b) { register double t=(a);(a)=(b);(b)=t; } +#define P3DISIJBERSPOSTNOV_RINGREMOVER_MEDIAN(a,n) _p3dSijbersPostnovRingRemover_kth_smallest(a,n,((n)/2)) + +double _p3dSijbersPostnovRingRemover_kth_smallest(double* a, int n, int k) { + register int i, j, l, m; + register double x; + + l = 0; + m = n - 1; + while (l < m) { + x = a[k]; + i = l; + j = m; + do { + while (a[i] < x) i++; + while (x < a[j]) j--; + if (i <= j) { + P3DISIJBERSPOSTNOV_RINGREMOVER_ELEM_SWAP(a[i], a[j]); + i++; + j--; + } + } while (i <= j); + if (j < k) l = i; + if (k < i) m = j; + } + return a[k]; +} + +// Function used to perform quick sort of the array for the computation +// of the median (see q_sort function of standard library): + +/*int _cmp(const void *a, const void *b) { +const double *da = (const double *) a; +const double *db = (const double *) b; + +return (*da > *db) - (*da < *db); +}*/ + +// Should be thread-safe: + +int _getSums_8( + unsigned char* p_in_im, + unsigned char* mask_im, + unsigned char* p_mask_im, + int p_dim, + int i, + int j, + int winsize, + double* sum, + double* sqrsum + ) +{ + int k; + + // Init sums: + *sum = 0.0; + *sqrsum = 0.0; + + // Cycle for each element in line to compute mean and + // variance of the line. This computation is meaningless + // if line is not completely included into ROI. + for (k = i; k < (i + winsize); k++) { + + // Check if element is outside ROI: + if (mask_im != NULL) { + if (p_mask_im[ I2(k, j, p_dim) ] == 0) + // If element is outside ROI break computation to improve + // performance: + return 0; // false + } + + // Compute sums for further use in mean and variance + // computation: + *sum += p_in_im[ I2(k, j, p_dim) ]; + *sqrsum += p_in_im[ I2(k, j, p_dim) ] * p_in_im[ I2(k, j, p_dim) ]; + } + + return 1; // true +} + + + +// Should be thread-safe: + +int _getSums_16( + unsigned short* p_in_im, + unsigned char* mask_im, + unsigned char* p_mask_im, + int p_dim, + int i, + int j, + int winsize, + double* sum, + double* sqrsum + ) +{ + int k; + + // Init sums: + *sum = 0.0; + *sqrsum = 0.0; + + // Cycle for each element in line to compute mean and + // variance of the line. This computation is meaningless + // if line is not completely included into ROI. + for (k = i; k < (i + winsize); k++) { + + // Check if element is outside ROI: + if (mask_im != NULL) { + if (p_mask_im[ I2(k, j, p_dim) ] == 0) + // If element is outside ROI break computation to improve + // performance: + return 0; // false + } + + // Compute sums for further use in mean and variance + // computation: + *sum += p_in_im[ I2(k, j, p_dim) ]; + *sqrsum += p_in_im[ I2(k, j, p_dim) ] * p_in_im[ I2(k, j, p_dim) ]; + } + + return 1; // true +} + +// This procedure removes ring artifacts from CT images. + +int p3dSijbersPostnovRingRemover2D_8( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const double centerX, + const double centerY, + const int winsize, + const double in_thresh, + const int iterations, + const double precision, + unsigned char* mask_im, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int i, j, k, it_ct; // generic counters + double sum, sqrsum; + + double mean, variance; + double tmp_val; + double thresh = in_thresh*256.0; + + // Polar images: + unsigned char* p_in_im = NULL; // no need for malloc + unsigned char* p_mask_im = NULL; // no need for malloc + unsigned char* c_out_im = NULL; // no need for malloc + + int p_dim; + + // Matrix: + double* matrix; + int* matrix_mask; + double* column; + int ct; + int row_ct; + int prev_rowct; + + // Artifacts vectors: + double* loc_art; + double* glob_art; + int* glob_mask; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying Sijbers and Postnov ring remover..."); + wr_log("\tCenter of rings: [%0.1f,%0.1f].", centerX, centerY); + wr_log("\tWinsize: %d.", winsize); + wr_log("\tThreshold: %0.3f.", in_thresh); + wr_log("\tIterations: %d.", iterations); + if (mask_im != NULL) + wr_log("\tMask adopted."); + wr_log("\tPolar/Cartesian precision: %0.3f.", precision); + } + + + // STEP2: Transform in polar coordinates. Remember that memory allocation + // for output images is performed within the procedure. + + p3dCartesian2polar_8(in_im, &p_in_im, dimx, dimy, centerX, centerY, precision, &p_dim); + if (mask_im != NULL) { + p3dCartesian2polar_8(mask_im, &p_mask_im, dimx, dimy, centerX, centerY, precision, &p_dim); + } + + + + // STEP3: Artifact template selection. + + // Allocate dynamic memory: + loc_art = (double*) malloc(winsize * sizeof (double)); + + + // Matrix should be a dynamic structure (i.e. a list of array) but for + // performance reasons we adopt a matrix allocated with the maximum + // dimensions (worst case): + matrix = (double*) calloc(winsize*p_dim, sizeof (double)); + /**/matrix_mask = (int*) malloc(p_dim * sizeof (int)); + + // Now that we know the dimensions of polar image we can allocate + // the global artifacts vector: + glob_art = (double*) malloc(p_dim * sizeof (double)); + glob_mask = (int*) malloc(p_dim * sizeof (int)); + + for (it_ct = 0; it_ct < iterations; it_ct++) { + // Initializations at every iterations: + prev_rowct = 0; + memset(loc_art, 0, winsize * sizeof (double)); + memset(glob_art, 0, p_dim * sizeof (double)); + memset(glob_mask, 0, p_dim * sizeof (int)); // init to 0 (false) + + // Within a sliding window: + for (i = 0; i < (p_dim - winsize); i++) { + // Init counters: + ct = 0; + row_ct = 0; + + // Initialization of matrix mask: + /**/memset(matrix_mask, 0, p_dim * sizeof (int)); // init to 0 (false) + + // For each line of polar image: +#pragma omp parallel for private(sum, sqrsum, mean, variance, k) reduction (+ : row_ct) + for (j = 0; j < p_dim; j++) { + // If computation of sum and squared sum is meaningful: + if (_getSums_8(p_in_im, mask_im, p_mask_im, p_dim, i, j, winsize, &sum, &sqrsum)) { + // Compute mean and variance of the line: + mean = sum / winsize; + variance = sqrsum / winsize - mean*mean; + + // If variance is below threshold: + if ((variance < thresh) && (variance > 0)) { + // Set that current position in matrix is meaningful: + /**/matrix_mask[j] = 1; // true + + // For each element subtract mean and add the line + // to the matrix: + for (k = i; k < (i + winsize); k++) { + // Subtract mean from the line and add + // it to a matrix + /**///matrix[ct++] = p_in_im[ I(k,j,p_dim) ] - mean; + matrix[ I2(k - i, j, winsize) ] = p_in_im[ I2(k, j, p_dim) ] - mean; + } + + // Increment the number of lines that meets the + // homogeneity criterium: + row_ct++; + } + } + } + + + // Compute median for each column and store the value in the + // artifact vector for this sliding window: + + // Now that we know the number of rows that meets homogeneity + // criterium we can allocate memory for a column: + if (row_ct > 0) { + // Allocate memory for the column (no OpenMP): + //column = (double*) malloc( row_ct*sizeof(double) ); + +#pragma omp parallel for private(k, ct, column) + for (j = 0; j < winsize; j++) { + // Allocate memory for the column: + column = (double*) malloc(row_ct * sizeof (double)); + + // Fill the column array: + /*for ( k = 0; k < row_ct; k++ ) + { + column[k] = matrix[ I(j,k,winsize) ]; + }*/ + ct = 0; + for (k = 0; k < p_dim; k++) { + if (matrix_mask[k] == 1) + column[ct++] = matrix[ I2(j, k, winsize) ]; + } + + // Order the array: + /*qsort( column, row_ct, sizeof(double), _cmp); + + // Get the median and put in "local" artifact vector: + loc_art[j] = column[ row_ct / 2 ];*/ + loc_art[j] = P3DISIJBERSPOSTNOV_RINGREMOVER_MEDIAN(column, row_ct); + + // Free memory for the column: + free(column); + } + + // Free memory for the column (no OpenMP): + //free(column); + } + /*else + { + // Set to zero "local" artifact vector: + memset(loc_art,0,winsize*sizeof(double)); + }*/ + + + // Unwrap the "local" artifact vector of dimension W to the + // "global" artifact vector of dimension P_DIM using the rule + // based on number of rows that meet the homogeneity criterium: + for (k = 0; k < winsize; k++) { + if ((row_ct > prev_rowct) || (glob_mask[k] == 0)) { + glob_art[k + i] = loc_art[k]; + glob_mask[k + i] = 1; // true + } + } + + // Set the previous equal to the current: + prev_rowct = row_ct; + } + + // The "global" artifact template vector is subtracted from each + // row of the polar image P: + if (mask_im != NULL) { +#pragma omp parallel for private(i, tmp_val) + for (j = 0; j < p_dim; j++) { + for (i = 0; i < p_dim; i++) { + if (p_mask_im[ I2(i, j, p_dim) ] != 0) { + // Take care of intensity bounds: + tmp_val = p_in_im[ I2(i, j, p_dim) ] - glob_art[i]; + + if (tmp_val < 0.0) tmp_val = 0.0; + if (tmp_val > UCHAR_MAX) tmp_val = UCHAR_MAX; + + p_in_im[ I2(i, j, p_dim) ] = (unsigned char) tmp_val; + } + } + } + } else { +#pragma omp parallel for private(i, tmp_val) + for (j = 0; j < p_dim; j++) { + for (i = 0; i < p_dim; i++) { + // Take care of intensity bounds: + tmp_val = p_in_im[ I2(i, j, p_dim) ] - glob_art[i]; + + if (tmp_val < 0.0) tmp_val = 0.0; + if (tmp_val > UCHAR_MAX) tmp_val = UCHAR_MAX; + + p_in_im[ I2(i, j, p_dim) ] = (unsigned char) tmp_val; + } + } + } + } + + + + // Return in cartesian coordinates: + p3dPolar2cartesian_8(p_in_im, &c_out_im, p_dim, centerX, centerY, dimx, dimy); + + // Copy C_OUT_IM to the output of the procedure: + memcpy(out_im, c_out_im, dimx * dimy * sizeof (unsigned char)); + + // Free memory: + free(glob_art); + free(glob_mask); + free(loc_art); + free(matrix); + free(matrix_mask); + + free(p_in_im); + free(c_out_im); + + if (mask_im != NULL) { + free(p_mask_im); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Sijbers and Postnov ring remover applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + return P3D_SUCCESS; + +} + +int p3dSijbersPostnovRingRemover2D_16( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const double centerX, + const double centerY, + const int winsize, + const double in_thresh, + const int iterations, + const double precision, + const int bit12, + unsigned char* mask_im, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) +{ + int i, j, k, it_ct; // generic counters + double sum, sqrsum; + + double mean, variance; + double tmp_val; + double thresh; + + // Polar images: + unsigned short* p_in_im = NULL; // no need for malloc + unsigned char* p_mask_im = NULL; // no need for malloc + unsigned short* c_out_im = NULL; // no need for malloc + + int p_dim; + + // Matrix: + double* matrix; + int* matrix_mask; + double* column; + int ct; + int row_ct; + int prev_rowct = 0; + + // Artifacts vectors: + double* loc_art; + double* glob_art; + int* glob_mask; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Applying Sijbers and Postnov ring remover..."); + wr_log("\tCenter of rings: [%0.1f,%0.1f].", centerX, centerY); + wr_log("\tWinsize: %d.", winsize); + wr_log("\tThreshold: %0.3f.", in_thresh); + wr_log("\tIterations: %d.", iterations); + if (bit12 == P3D_TRUE) + wr_log("\t12-bit images flag: true."); + else + wr_log("\t12-bit images flag: false."); + if (mask_im != NULL) + wr_log("\tMask adopted."); + wr_log("\tPolar/Cartesian precision: %0.3f.", precision); + } + + // Set the correct threshold value: + if (bit12 == P3D_TRUE) + thresh = in_thresh * 4096.0; + else + thresh = in_thresh * 65536.0; + + + // STEP2: Transform in polar coordinates. Remember that memory allocation + // for output images is performed within the procedure. + + p3dCartesian2polar_16(in_im, &p_in_im, dimx, dimy, centerX, centerY, precision, &p_dim); + if (mask_im != NULL) { + p3dCartesian2polar_8(mask_im, &p_mask_im, dimx, dimy, centerX, centerY, precision, &p_dim); + } + + + // STEP3: Artifact template selection. + + // Allocate dynamic memory: + loc_art = (double*) calloc(winsize, sizeof (double)); + + + // Matrix should be a dynamic structure (i.e. a list of array) but for + // performance reasons we adopt a matrix allocated with the maximum + // dimensions (worst case): + matrix = (double*) calloc(winsize*p_dim, sizeof (double)); + /**/matrix_mask = (int*) malloc(p_dim * sizeof (int)); + + // Now that we know the dimensions of polar image we can allocate + // the global artifacts vector: + glob_art = (double*) malloc(p_dim * sizeof (double)); + glob_mask = (int*) malloc(p_dim * sizeof (int)); + + for (it_ct = 0; it_ct < iterations; it_ct++) { + // Initializations at every iterations: + prev_rowct = 0; + memset(loc_art, 0, winsize * sizeof (double)); + memset(glob_art, 0, p_dim * sizeof (double)); + memset(glob_mask, 0, p_dim * sizeof (int)); // init to 0 (false) + + // Within a sliding window: + for (i = 0; i < (p_dim - winsize); i++) { + // Init counters: + ct = 0; + row_ct = 0; + + // Initialization of matrix mask: + /**/memset(matrix_mask, 0, p_dim * sizeof (int)); // init to 0 (false) + + // For each line of polar image: +#pragma omp parallel for private(sum, sqrsum, mean, variance, k) reduction (+ : row_ct) + for (j = 0; j < p_dim; j++) { + // If computation of sum and squared sum is meaningful: + if (_getSums_16(p_in_im, mask_im, p_mask_im, p_dim, i, j, winsize, &sum, &sqrsum)) { + // Compute mean and variance of the line: + mean = sum / winsize; + variance = sqrsum / winsize - mean*mean; + + // If variance is below threshold: + if ((variance < thresh) && (variance > 0)) { + // Set that current position in matrix is meaningful: + /**/matrix_mask[j] = 1; // true + + // For each element subtract mean and add the line + // to the matrix: + for (k = i; k < (i + winsize); k++) { + // Subtract mean from the line and add + // it to a matrix + /**///matrix[ct++] = p_in_im[ I(k,j,p_dim) ] - mean; + matrix[ I2(k - i, j, winsize) ] = p_in_im[ I2(k, j, p_dim) ] - mean; + } + + // Increment the number of lines that meets the + // homogeneity criterium: + row_ct++; + } + } + } + + + // Compute median for each column and store the value in the + // artifact vector for this sliding window: + + // Now that we know the number of rows that meets homogeneity + // criterium we can allocate memory for a column: + if (row_ct > 0) { + // Allocate memory for the column (no OpenMP): + //column = (double*) malloc( row_ct*sizeof(double) ); + +#pragma omp parallel for private(k, ct, column) + for (j = 0; j < winsize; j++) { + // Allocate memory for the column: + column = (double*) malloc(row_ct * sizeof (double)); + + // Fill the column array: + /*for ( k = 0; k < row_ct; k++ ) + { + column[k] = matrix[ I(j,k,winsize) ]; + }*/ + ct = 0; + for (k = 0; k < p_dim; k++) { + if (matrix_mask[k] == 1) + column[ct++] = matrix[ I2(j, k, winsize) ]; + } + + // Order the array: + /*qsort( column, row_ct, sizeof(double), _cmp); + + // Get the median and put in "local" artifact vector: + loc_art[j] = column[ row_ct / 2 ];*/ + loc_art[j] = P3DISIJBERSPOSTNOV_RINGREMOVER_MEDIAN(column, row_ct); + + // Free memory for the column: + free(column); + } + + // Free memory for the column (no OpenMP): + //free(column); + } + /*else + { + // Set to zero "local" artifact vector: + memset(loc_art,0,winsize*sizeof(double)); + }*/ + + + // Unwrap the "local" artifact vector of dimension W to the + // "global" artifact vector of dimension P_DIM using the rule + // based on number of rows that meets the homogeneity criterium: + for (k = 0; k < winsize; k++) { + if ((row_ct > prev_rowct) || (glob_mask[k] == 0)) { + glob_art[k + i] = loc_art[k]; + glob_mask[k + i] = 1; // true + } + } + + // Set the previous equal to the current: + prev_rowct = row_ct; + } + + // The "global" artifact template vector is subtracted from each + // row of the polar image P: + if (mask_im != NULL) { +#pragma omp parallel for private(i, tmp_val) + for (j = 0; j < p_dim; j++) { + for (i = 0; i < p_dim; i++) { + if (p_mask_im[ I2(i, j, p_dim) ] != 0) { + // Take care of intensity bounds: + tmp_val = p_in_im[ I2(i, j, p_dim) ] - glob_art[i]; + + if (tmp_val < 0.0) tmp_val = 0.0; + if (tmp_val > USHRT_MAX) tmp_val = USHRT_MAX; + + p_in_im[ I2(i, j, p_dim) ] = (unsigned short) tmp_val; + } + } + } + } else { +#pragma omp parallel for private(i, tmp_val) + for (j = 0; j < p_dim; j++) { + for (i = 0; i < p_dim; i++) { + // Take care of intensity bounds: + tmp_val = p_in_im[ I2(i, j, p_dim) ] - glob_art[i]; + + if (tmp_val < 0.0) tmp_val = 0.0; + if (tmp_val > USHRT_MAX) tmp_val = USHRT_MAX; + + p_in_im[ I2(i, j, p_dim) ] = (unsigned short) tmp_val; + } + } + } + } + + + // Return in cartesian coordinates: + p3dPolar2cartesian_16(p_in_im, &c_out_im, p_dim, centerX, centerY, dimx, dimy); + + // Copy C_OUT_IM to the output of the procedure: + memcpy(out_im, c_out_im, dimx * dimy * sizeof (unsigned short)); + + // Free memory: + free(glob_art); + free(glob_mask); + free(loc_art); + free(matrix); + free(matrix_mask); + + free(p_in_im); + free(c_out_im); + + if (mask_im != NULL) { + free(p_mask_im); + } + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Sijbers and Postnov ring remover applied successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + return P3D_SUCCESS; + +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Filt/p3dTime.h b/pypore3d/pypore3d/P3D_Filt/p3dTime.h new file mode 100644 index 0000000000000000000000000000000000000000..8bb29440ed2ef2a2f06d01bf53912123a4921b04 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Filt/p3dTime.h @@ -0,0 +1,4 @@ +void p3dResetStartTime (); +double p3dGetElapsedTime(); +int p3dGetElapsedTime_min(); +double p3dGetElapsedTime_sec(); diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxList.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxList.c new file mode 100644 index 0000000000000000000000000000000000000000..56693626e14d57e471b38d7c47590e8b7eebf035 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxList.c @@ -0,0 +1,105 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dBoundingBoxList.h" +#include "p3dUtils.h" + +void bb_list_init (bb_list_t *list) +{ + *list = NULL; +} + +int bb_list_add (bb_list_t *list, bb_t item) +{ + bb_list_elem_t* new_l; + + // Alloc memory for the new item: + new_l = (bb_list_elem_t*) malloc (sizeof(bb_list_elem_t)); + + // Push item into queue: + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_TRUE; +} + + +int bb_list_isempty (bb_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + +// List is deleted after conversion: +bb_t* bb_list_toarray (bb_list_t *list, int numel ) +{ + bb_list_elem_t* tmp_l; + + + bb_t* v; + int i; + + v = (bb_t*) malloc (numel*sizeof(bb_t)); + + // Convert list to array: + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->elem; + + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + return v; +} + +void bb_list_clear (bb_list_t *list) +{ + bb_list_elem_t* tmp_l; + + // Scan whole list: + while( *list != NULL ) + { + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + // Final assignment for safety: + *list = NULL; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxList.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxList.h new file mode 100644 index 0000000000000000000000000000000000000000..2c7d4eec780de94faaab3488b226e075c3d57267 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxList.h @@ -0,0 +1,64 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dBoundingBoxT.h" + +/********************************************************************* + * + * uint_list_t type definitions. + * + *********************************************************************/ +#ifndef BB_L_DEFINED + #define BB_L_DEFINED + + struct bb_lelem_t { + bb_t elem; + struct bb_lelem_t *next; + }; + + typedef struct bb_lelem_t bb_list_elem_t; + + typedef bb_list_elem_t* bb_list_t; + +#endif +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void bb_list_init (bb_list_t *list); + +int bb_list_add (bb_list_t *list, bb_t item); + +int bb_list_isempty(bb_list_t list); + +bb_t* bb_list_toarray (bb_list_t *list, int numel ); + +void bb_list_clear (bb_list_t *list); + + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxT.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxT.h new file mode 100644 index 0000000000000000000000000000000000000000..8efa4476d888a285cc75d4f0cb6677c4292421cc --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dBoundingBoxT.h @@ -0,0 +1,47 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/********************************************************************* + * + * bb_t type definitions (bounding box). + * + *********************************************************************/ + +#ifndef BB_T_DEFINED + +typedef struct { + int min_x; + int max_x; + int min_y; + int max_y; + int min_z; + int max_z; +} bb_t; + +#endif + +#define BB_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.c new file mode 100644 index 0000000000000000000000000000000000000000..46421e04c0577d6cd7ec24a546908640b16a8ffa --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.c @@ -0,0 +1,626 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/************************************************************************ + * CCL3 Performs connected component labeling of a 3D binary volume. + * CCL3 performs connected component labeling of a 3D binary volume + * using 26-connectivity for object voxels and 6-connectivity for + * background voxels. The algorithm uses a flexible tradeoff between + * speed and memory by means of parameter SIZE. + * + * LB = CCL3(VOI) apply the fastest connected component labeling (i.e. + * SIZE = 3). + * + * LB = CCL3(VOI, SIZE) apply connected component labeling using the + * specified SIZE for the sub-volume scanning (see references). + * + * Class Support + * ------------- + * The input volume VOI must be logical. SIZE must be an odd value greater + * than 3. + * + * Remarks + * ------- + * The SIZE parameters controls the tradeoff between computational time + * and memory occupation. The fastest execution requires SIZE = 3. + * + * Example + * ------------ + * + * lbl = ccl3(voi); + * + * References + * ---------- + * [1] Q. Hu et al. Fast connected-component labeling in + * three-dimensional binary images based on iterative recursion. + * Computer Vision and Image Understanding, 99(2005):414-434, 2005. + + + * Author: Brun Francesco - Universit� degli studi di Trieste + * Date: 10 may 2008 + + ************************************************************************/ +#include <stdlib.h> +#include <limits.h> +#include <omp.h> + +#include "p3dCoordsQueue.h" +#include "p3dUIntList.h" +#include "p3dBoundingBoxList.h" +#include "p3dUtils.h" + + +#define ON_LABEL 1 // ON Value: +#define FIRST_LABEL 3 // First label: +#define TEMP_LABEL 2 // Temporary label: + + +void putCoordsInQueue ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + coords_t tmp_coords; // Temporary coords + + + // If we're on an object voxel: + if ( out_rev[ I(i,j,k,dimx,dimy) ] == ON_LABEL ) + { + // Check if this is the last step: + if ( ct == (win_size - 2)) + { + // Border voxels are set to m: + out_rev[ I(i,j,k,dimx,dimy) ] = m; + + // A border voxel is pushed into queue: + tmp_coords.x = i; + tmp_coords.y = j; + tmp_coords.z = k; + coords_queue_push(queue,tmp_coords); + } + else + { + // Mark voxel for further scan: + out_rev[ I(i,j,k,dimx,dimy) ] = TEMP_LABEL; + } + } +} + + + +void conn_fun6 ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + int a,b,c; + + c = k - 1; b = j; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j - 1; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j + 1; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + +} + + +void conn_fun18 ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + int a,b,c; + + // Perform 6-connectivity: + conn_fun6 (out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue ); + + // Do other 12 tests: + + // On k-1 plane: + c = k - 1; b = j - 1; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k - 1; b = j + 1; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k - 1; b = j; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k - 1; b = j; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j + 1; a = i; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + + // On k plane: + c = k; b = j - 1; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j - 1; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j + 1; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k; b = j + 1; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + +} + + +void conn_fun26 ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ) +{ + int a,b,c; + + // Perform 18-connectivity: + conn_fun18 (out_rev, dimx, dimy, dimz, i, j, k, ct, win_size, m, queue ); + + // Do other 8 tests: + + // On k-1 plane: + c = k - 1; b = j - 1; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k - 1; b = j - 1; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k - 1; b = j + 1; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k - 1; b = j + 1; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j - 1; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j + 1; a = i - 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + + c = k + 1; b = j + 1; a = i + 1; + putCoordsInQueue( out_rev, dimx, dimy, dimz, a, b, c, ct, win_size, m, queue ); + +} + + +int first_unlabeled ( + unsigned short* lbl, + const int nRows, + const int nCols, + const int nPlanes, + const int winsize, + coords_t* coords + ) +{ + int i,j,k; + int off; + + off = winsize / 2; // integer division: + + // Volume scanning: + for( k = off; k < (nPlanes - off); k++ ) + for( j = off; j < (nCols - off); j++ ) + for( i = off; i < (nRows - off); i++ ) + { + if (lbl[ I(i,j,k,nRows,nCols) ] == ON_LABEL) + { + coords->x = i; + coords->y = j; + coords->z = k; + return P3D_TRUE; + } + } + + return P3D_FALSE; +} + +int p3dConnectedComponentsLabeling ( + unsigned char* in_rev, + unsigned short* out_rev, + int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int skip_borders + ) +{ + // Size of local window (3 in current implementation). + // Modify this value with 5,7,... if memory problem + // occurs. Uncomment also some code (see further). + int win_size; + + coords_queue_t queue; // FIFO data structure for coords storage + coords_t coords; // Current coords + + uint_list_t vol_list; // List for region volume counting + bb_list_t bb_list; // List for bounding boxes + bb_t curr_bb; + + unsigned short m; // Current label + int ct, offset; // Counter for local subvolume size + int a,b,c; + int i,j,k; + int m_ct; // Counter for volume counting + int lbl_ct; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary input and output: + unsigned char* tmp_in_rev; + unsigned short* tmp_out_rev; + + // Pointer to a function for kind of connectivity: + void (*conn_fun) ( + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + const int ct, + const int win_size, + unsigned short m, + coords_queue_t* queue // FIFO data structure for coords storage + ); + + // The win_size parameters controls the tradeoff between computational time + // and memory occupation. The fastest execution requires win_size = 3. + win_size = 3; + + // Set the correct type of connectivity based on input parameter: + if ( conn == CONN6 ) + conn_fun = conn_fun6; + else if ( conn == CONN18 ) + conn_fun = conn_fun18; + else // default: + conn_fun = conn_fun26; + + // Apply algorithm: + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad*2; + a_dimy = dimy + a_rad*2; + a_dimz = dimz + a_rad*2; + + // Initialize input: + P3D_MEM_TRY ( tmp_in_rev = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + p3dZeroPadding3D_uchar2uchar ( in_rev, tmp_in_rev, dimx, dimy, dimz, a_rad); + + + // Initialize output label volume with ON_LABEL on non-zero values + // of input volume: + P3D_MEM_TRY ( tmp_out_rev = (unsigned short*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned short) ) ); + + #pragma omp parallel for + for (ct = 0; ct < (a_dimx*a_dimy*a_dimz); ct++) + tmp_out_rev[ct] = ( tmp_in_rev[ct] ) ? ON_LABEL : 0; + + + + // Initialize variables: + coords_queue_init(&queue); + uint_list_init(&vol_list); + bb_list_init(&bb_list); + + + m = FIRST_LABEL; + lbl_ct = 0; + + + // While not all voxels are labeled: + while( first_unlabeled(tmp_out_rev, a_dimx, a_dimy, a_dimz, win_size, &coords) == P3D_TRUE ) + { + // Re-init counter for current connected component: + m_ct = 0; + + // Init bounding box: + curr_bb.max_x = 0; + curr_bb.max_y = 0; + curr_bb.max_z = 0; + curr_bb.min_x = INT_MAX; + curr_bb.min_y = INT_MAX; + curr_bb.min_z = INT_MAX; + + // Push the first unlabeled object voxel into queue: + coords_queue_push(&queue, coords); + + // While the queue is not empty: + while( coords_queue_isempty(queue) == P3D_FALSE ) + { + // Pop the first element of the queue: + coords = coords_queue_pop(&queue); + + // Mark the extracted element: + tmp_out_rev[ I(coords.x,coords.y,coords.z,a_dimx,a_dimy) ] = TEMP_LABEL; + + // Perform sub-volume iterative scanning: + ct = 1; + while (ct < win_size) + { + offset = ct / 2; // integer division + + for (k = (coords.z - offset); k <= (coords.z + offset); k++) + for (j = (coords.y - offset); j <= (coords.y + offset); j++) + for (i = (coords.x - offset); i <= (coords.x + offset); i++) + { + + if (tmp_out_rev[ I(i,j,k,a_dimx,a_dimy) ] == TEMP_LABEL) + { + // Perform 6-, 18-, or 26-connectivity: + conn_fun ( tmp_out_rev, a_dimx, a_dimy, a_dimx, i, + j, k, ct, win_size, m, &queue ); + + // A voxels previously marked is set to m: + tmp_out_rev[ I(i,j,k,a_dimx,a_dimy) ] = m; + + // Define bounding box: + curr_bb.max_x = MAX( curr_bb.max_x, i - a_rad ); + curr_bb.max_y = MAX( curr_bb.max_y, j - a_rad ); + curr_bb.max_z = MAX( curr_bb.max_z, k - a_rad ); + curr_bb.min_x = MIN( curr_bb.min_x, i - a_rad ); + curr_bb.min_y = MIN( curr_bb.min_y, j - a_rad ); + curr_bb.min_z = MIN( curr_bb.min_z, k - a_rad ); + + // Increment counter for region volume: + m_ct++; + } + } + // Increase local sub-volume window: + ct = ct + 2; + } + } + + + // Skip object if required: + if ( ( skip_borders == P3D_TRUE ) && ( (curr_bb.min_x == 0) || (curr_bb.min_y == 0) + || (curr_bb.min_z == 0) || (curr_bb.max_x == (dimx - 1)) + || (curr_bb.max_y == (dimy - 1)) || (curr_bb.max_z == (dimz - 1)) ) ) + { + // Restore OBJECT label instead of current label: + #pragma omp parallel for private(a,b) + for ( c = curr_bb.min_z; c <= curr_bb.max_z; c++ ) + for ( b = curr_bb.min_y; b <= curr_bb.max_y; b++ ) + for ( a = curr_bb.min_x; a <= curr_bb.max_x; a++ ) + { + if( tmp_out_rev[ I(a+a_rad,b+a_rad,c+a_rad,a_dimx,a_dimy) ] == m ) + { + tmp_out_rev[ I(a+a_rad,b+a_rad,c+a_rad,a_dimx,a_dimy) ] = USHRT_MAX; // Object + } + } + } + else + { + // Save connected component volume: + uint_list_add( &vol_list, m_ct ); + bb_list_add( &bb_list, curr_bb ); + + + // Increment counter (it is equal to (m - 3) if labels are NOT randomly assigned): + m++; + lbl_ct++; + } + } + + // Return number of connected components labeled: + if ( numOfConnectedComponents != NULL ) + *numOfConnectedComponents = lbl_ct; + + + // Return the array of volumes for each connected component. + // (The list is deleted after this operation): + if ( volumes != NULL ) + (*volumes) = uint_list_toarray ( &vol_list, lbl_ct ); + else + uint_list_clear ( &vol_list ); + + if ( boundingBoxes != NULL ) + (*boundingBoxes) = bb_list_toarray ( &bb_list, lbl_ct ); + else + bb_list_clear ( &bb_list ); + + + // Crop output: + p3dCrop3D_ushort2ushort ( tmp_out_rev, out_rev, a_dimx, a_dimy, a_dimz, a_rad ); + + + + // Release resources: + if ( tmp_in_rev != NULL ) free(tmp_in_rev); + if ( tmp_out_rev != NULL ) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + if (tmp_in_rev != NULL) free(tmp_in_rev); + if (tmp_out_rev != NULL) free(tmp_in_rev); + + // Return error code: + return P3D_ERROR; +} + + + +int p3dGetMaxVolumeRegion ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + int conn + ) +{ + unsigned short* lbl_rev; + + unsigned int* volumes; + unsigned short lbl; + + int i,j,k, num_el; + + int lbl_max; + unsigned int vol_max; + + int err_code; + + // Initialize output by cloning input: + memcpy(out_rev, in_rev, dimx*dimy*dimz*sizeof(unsigned char)); + + // Allocate memory for labels REV: + lbl_rev = (unsigned short*) malloc (dimx*dimy*dimz*sizeof(unsigned short)); + + if ( lbl_rev == NULL ) + { + // Return error code and exit: + return P3D_ERROR; + } + + // Perform connected component labeling: + err_code = p3dConnectedComponentsLabeling ( in_rev, lbl_rev, &num_el, &volumes, NULL, dimx, + dimy, dimz, conn, P3D_FALSE); + + if ( err_code == P3D_ERROR ) + { + // Free memory if previous malloc were successfully: + if ( lbl_rev != NULL ) free ( lbl_rev ); + if ( volumes != NULL ) free ( volumes ); + + // Return error code and exit: + return P3D_ERROR; + } + + + lbl_max = 0; + vol_max = 0; + + // For each connected component labeled: + for ( lbl = 0; lbl < num_el; lbl++ ) + { + if (volumes[lbl] > vol_max) + { + lbl_max = lbl; + vol_max = volumes[lbl]; + } + } + + // Remove connected component: + for( k = 0; k < dimz; k++ ) + for( j = 0; j < dimy; j++ ) + for( i = 0; i < dimx; i++ ) + { + // Labels start from 3: + if (lbl_rev[ I(i,j,k,dimx,dimy) ] != (lbl_max + 3) ) + { + out_rev[ I(i,j,k,dimx,dimy) ] = 0; + } + } + + // Free memory: + if ( lbl_rev != NULL ) free ( lbl_rev ); + if ( volumes != NULL ) free ( volumes ); + + // Return OK: + return P3D_SUCCESS; +} diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.h new file mode 100644 index 0000000000000000000000000000000000000000..b4e8cbbf0a9f70a5d7bac4836b948f054505fd46 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.h @@ -0,0 +1,93 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/************************************************************************ + * CCL3 Performs connected component labeling of a 3D binary volume. + * CCL3 performs connected component labeling of a 3D binary volume + * using 26-connectivity for object voxels and 6-connectivity for + * background voxels. The algorithm uses a flexible tradeoff between + * speed and memory by means of parameter SIZE. + * + * LB = CCL3(VOI) apply the fastest connected component labeling (i.e. + * SIZE = 3). + * + * LB = CCL3(VOI, SIZE) apply connected component labeling using the + * specified SIZE for the sub-volume scanning (see references). + * + * Class Support + * ------------- + * The input volume VOI must be logical. SIZE must be an odd value greater + * than 3. + * + * Remarks + * ------- + * The SIZE parameters controls the tradeoff between computational time + * and memory occupation. The fastest execution requires SIZE = 3. + * + * Example + * ------------ + * + * lbl = ccl3(voi); + * + * References + * ---------- + * [1] Q. Hu et al. Fast connected-component labeling in + * three-dimensional binary images based on iterative recursion. + * Computer Vision and Image Understanding, 99(2005):414-434, 2005. + + + * Author: Brun Francesco - Universit� degli studi di Trieste + * Date: 10 may 2008 + + ************************************************************************/ +#include <limits.h> + +#include "p3dBoundingBoxT.h" + +int p3dConnectedComponentsLabeling ( + unsigned char* in_rev, + unsigned short* out_rev, + int* numOfConnectedComponents, // OUT: dim of arrays + unsigned int** volumes, // OUT: array of sizes (voxel counting) + bb_t** boundingBoxes, // OUT: array of bounding boxes + const int dimx, + const int dimy, + const int dimz, + const int conn, + const int skip_borders + ); + +int p3dGetMaxVolumeRegion ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, + const int dimy, + const int dimz, + int conn + ); + + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsList.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsList.c new file mode 100644 index 0000000000000000000000000000000000000000..41f59907142184c18b1ac8b9a1216eeee74594d4 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsList.c @@ -0,0 +1,122 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dCoordsList.h" +#include "p3dUtils.h" + + +void coords_list_init (coords_list_t *list) +{ + *list = NULL; +} + +int coords_list_push (coords_list_t *list, coords_t item) +{ + coords_list_elem_t* new_l; + + /* Allocate memory for the new item: */ + new_l = (coords_list_elem_t*) malloc (sizeof(coords_list_elem_t)); + if ( new_l == NULL ) return P3D_ERROR; + + /* Push item into list: */ + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_SUCCESS; +} + +coords_t coords_list_pop (coords_list_t *list) +{ + coords_list_elem_t* tmp_l; + coords_t tmp_coords; + + + + /* Perform deletion: */ + tmp_coords = (*list)->elem; + + /* Save temporary pointer to the element to delete: */ + tmp_l = *list; + + /* The list will point on the next element: */ + (*list) = (*list)->next; + + /* Delete first element using the previously set + temporary pointer: */ + free(tmp_l); + + /* Return coordinates: */ + return tmp_coords; +} + + +int coords_list_isempty (coords_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + + +coords_t* coords_list_toarray (coords_list_t *list, int numel ) +{ + coords_list_elem_t* tmp_l; + + + coords_t* v; + int i; + + /* Allocate memory for output array: */ + v = (coords_t*) malloc (numel*sizeof(coords_t)); + + if ( v != NULL ) + { + /* Convert list to array: */ + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->elem; + + /* Perform deletion: */ + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + else + { + /* Delete list in any case: */ + while ( list != NULL ) + coords_list_pop ( list ); + } + + return v; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsList.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsList.h new file mode 100644 index 0000000000000000000000000000000000000000..68bb3ebb8da970d1992f5270467dd771f8094513 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsList.h @@ -0,0 +1,136 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/******************************************************************************** + * File: p3dCoords_list.h + * + * Description: Header file for the implementation of the dynamic structure + * with LIFO (Last-In-First-Out) policy (list or stack) + * containing CoordsT elements (see p3dCoordsT.h) + * Duplicate elements allowed. + * + * Interfaces: coords_list_init + * coords_list_push + * coords_list_pop + * coords_list_isempty + * coords_list_toarray + * + * Author: FB + * + ********************************************************************************/ +#include "p3dCoordsT.h" + +/* + Type definitions: +*/ + +#ifndef COORDS_LIST_T_DEFINED + #define COORDS_LIST_T_DEFINED + + struct coords_lelem_t { + coords_t elem; + struct coords_lelem_t *next; + }; + + typedef struct coords_lelem_t coords_list_elem_t; + + typedef coords_list_elem_t* coords_list_t; + +#endif + +/* + Interfaces: +*/ + +/******************************************************************************** + * Function: coords_list_init + * + * Description: Initialize the specified parameter to NULL. + * + * Input(s): coords_list_t* - The list to initialize + * + * Output: No return type + ********************************************************************************/ +void coords_list_init ( coords_list_t* ); + +/******************************************************************************** + * Function: coords_list_push + * + * Description: Push the specified element into the list. + * + * Input(s): coords_list_t* - The list to extend + * coords_t - The element to push into the list + * + * Output: P3D_SUCCESS if element successfully pushed into the list + * P3D_MEM_ERROR if there is not enough memory for the additional + * element + ********************************************************************************/ +int coords_list_push ( coords_list_t*, coords_t ); + +/******************************************************************************** + * Function: coords_list_pop + * + * Description: Pop an element from the list according to the LIFO policy. + * + * Input(s): coords_list_t* - The list to reduce + * + * Output: coords_t - The popped element + ********************************************************************************/ +coords_t coords_list_pop ( coords_list_t* ); + +/******************************************************************************** + * Function: coords_list_isempty + * + * Description: Return P3D_TRUE if the specified list is empty + * + * Input(s): coords_list_t* - The list to query + * + * Output: P3D_TRUE if the list is empty + * P3D_FALSE if there is at least one element into the list + ********************************************************************************/ +int coords_list_isempty ( coords_list_t ); + +/******************************************************************************** + * Function: coords_list_toarray + * + * Description: Convert the dynamic structure to a static array. The length + * of the array should be known a-priori and specified in input. + * List is deleted after this operation. Run-time error occurs if + * the caller specify a number of elements greater than the real + * value. Memory leak occurs if the caller specify a number of + * elements lower than the real value. + * + * Input(s): coords_list_t* - The list to convert + * int - The number of list elements + * + * Output: The pointer to the array or NULL if there is not enough + * (contiguous) memory for the array (list is deleted in any + * case). + ********************************************************************************/ +coords_t* coords_list_toarray ( coords_list_t*, int ); + + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsQueue.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsQueue.c new file mode 100644 index 0000000000000000000000000000000000000000..3e2110757939ee23ce3e3daa59934b6a8e595ce9 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsQueue.c @@ -0,0 +1,89 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> + +#include "p3dCoordsQueue.h" +#include "p3dUtils.h" + +void coords_queue_init (coords_queue_t *queue) +{ + queue->head = NULL; + queue->tail = NULL; +} + +void coords_queue_push (coords_queue_t *queue, coords_t elem) +{ + coords_queue_elem_t *new_q; + + // Alloc memory for the new item: + new_q = (coords_queue_elem_t *) malloc (sizeof(coords_queue_elem_t)); + + // Push item into queue: + new_q->item = elem; + new_q->next = NULL; + + // Handle first element pushed: + if (queue->tail != NULL) + { + queue->tail->next = new_q; + queue->tail = queue->tail->next; + } + else + { + queue->tail = new_q; + queue->head = queue->tail; + } +} + +coords_t coords_queue_pop (coords_queue_t *queue) +{ + coords_t elem; + coords_queue_elem_t *temp; + + // Pop item from queue: + elem = queue->head->item; + + // Free memory: + temp = queue->head; + queue->head = queue->head->next; + free(temp); + + // Handle last element popped: + if (queue->head == NULL) + { + queue->tail = NULL; + } + + // Return the item previously popped: + return elem; +} + +int coords_queue_isempty (coords_queue_t queue) +{ + return ( ((queue.head == NULL) && (queue.tail == NULL)) ? P3D_TRUE : P3D_FALSE ); +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsQueue.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsQueue.h new file mode 100644 index 0000000000000000000000000000000000000000..1c19af26d39c27b0ec8a5073fe171d4287bb608c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsQueue.h @@ -0,0 +1,66 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dCoordsT.h" + +/********************************************************************* + * + * coords_queue_t type definitions. Do NOT modify. coords_queue_t implements a FIFO + * policy: elements are pushed into the tail and popped from the head. + * + *********************************************************************/ + +#ifndef COORDS_Q_DEFINED + #define COORDS_Q_DEFINED + + struct coords_qelem_t { + coords_t item; + struct coords_qelem_t *next; + }; + + typedef struct coords_qelem_t coords_queue_elem_t; + + typedef struct { + coords_queue_elem_t *tail; + coords_queue_elem_t *head; + } coords_queue_t; + +#endif +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void coords_queue_init (coords_queue_t *queue); + +void coords_queue_push(coords_queue_t *queue, coords_t elem); + +coords_t coords_queue_pop(coords_queue_t *queue); + +int coords_queue_isempty(coords_queue_t queue); + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsT.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsT.h new file mode 100644 index 0000000000000000000000000000000000000000..917aa1f57aec52e006d8b43fa0d0ba31569ecf2d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dCoordsT.h @@ -0,0 +1,48 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/* + Type definitions: +*/ + +#ifndef COORDS_T_DEFINED + +typedef struct { + int x; + int y; + int z; +} coords_t; + +typedef struct { + double x; + double y; + double z; +} fcoords_t; + +#endif + +#define COORDS_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dFCoordsList.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dFCoordsList.c new file mode 100644 index 0000000000000000000000000000000000000000..768cdecd7f15133acbde9912ec1da0940def2a01 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dFCoordsList.c @@ -0,0 +1,121 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dFCoordsList.h" +#include "p3dUtils.h" + +void fcoords_list_init (fcoords_list_t *list) +{ + *list = NULL; +} + +int fcoords_list_push (fcoords_list_t *list, fcoords_t item) +{ + fcoords_list_elem_t* new_l; + + /* Allocate memory for the new item: */ + new_l = (fcoords_list_elem_t*) malloc (sizeof(fcoords_list_elem_t)); + if ( new_l == NULL ) return P3D_ERROR; + + /* Push item into list: */ + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_SUCCESS; +} + +fcoords_t fcoords_list_pop (fcoords_list_t *list) +{ + fcoords_list_elem_t* tmp_l; + fcoords_t tmp_coords; + + + + /* Perform deletion: */ + tmp_coords = (*list)->elem; + + /* Save temporary pointer to the element to delete: */ + tmp_l = *list; + + /* The list will point on the next element: */ + (*list) = (*list)->next; + + /* Delete first element using the previously set + temporary pointer: */ + free(tmp_l); + + /* Return coordinates: */ + return tmp_coords; +} + + +int fcoords_list_isempty (fcoords_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + + +fcoords_t* fcoords_list_toarray (fcoords_list_t *list, int numel ) +{ + fcoords_list_elem_t* tmp_l; + + + fcoords_t* v; + int i; + + /* Allocate memory for output array: */ + v = (fcoords_t*) malloc (numel*sizeof(fcoords_t)); + + if ( v != NULL ) + { + /* Convert list to array: */ + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->elem; + + /* Perform deletion: */ + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + else + { + /* Delete list in any case: */ + while ( list != NULL ) + fcoords_list_pop ( list ); + } + + return v; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dFCoordsList.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dFCoordsList.h new file mode 100644 index 0000000000000000000000000000000000000000..f8a8605603859f2316ac631031fe1a8a097f7c0f --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dFCoordsList.h @@ -0,0 +1,136 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/******************************************************************************** + * File: p3dCoords_list.h + * + * Description: Header file for the implementation of the dynamic structure + * with LIFO (Last-In-First-Out) policy (list or stack) + * containing CoordsT elements (see p3dCoordsT.h) + * Duplicate elements allowed. + * + * Interfaces: coords_list_init + * coords_list_push + * coords_list_pop + * coords_list_isempty + * coords_list_toarray + * + * Author: FB + * + ********************************************************************************/ +#include "p3dCoordsT.h" + +/* + Type definitions: +*/ + +#ifndef FCOORDS_LIST_T_DEFINED + #define FCOORDS_LIST_T_DEFINED + + struct fcoords_lelem_t { + fcoords_t elem; + struct fcoords_lelem_t *next; + }; + + typedef struct fcoords_lelem_t fcoords_list_elem_t; + + typedef fcoords_list_elem_t* fcoords_list_t; + +#endif + +/* + Interfaces: +*/ + +/******************************************************************************** + * Function: fcoords_list_init + * + * Description: Initialize the specified parameter to NULL. + * + * Input(s): fcoords_list_t* - The list to initialize + * + * Output: No return type + ********************************************************************************/ +void fcoords_list_init ( fcoords_list_t* ); + +/******************************************************************************** + * Function: fcoords_list_push + * + * Description: Push the specified element into the list. + * + * Input(s): fcoords_list_t* - The list to extend + * fcoords_t - The element to push into the list + * + * Output: P3D_SUCCESS if element successfully pushed into the list + * P3D_MEM_ERROR if there is not enough memory for the additional + * element + ********************************************************************************/ +int fcoords_list_push ( fcoords_list_t*, fcoords_t ); + +/******************************************************************************** + * Function: fcoords_list_pop + * + * Description: Pop an element from the list according to the LIFO policy. + * + * Input(s): fcoords_list_t* - The list to reduce + * + * Output: fcoords_t - The popped element + ********************************************************************************/ +fcoords_t fcoords_list_pop ( fcoords_list_t* ); + +/******************************************************************************** + * Function: coords_list_isempty + * + * Description: Return P3D_TRUE if the specified list is empty + * + * Input(s): coords_list_t* - The list to query + * + * Output: P3D_TRUE if the list is empty + * P3D_FALSE if there is at least one element into the list + ********************************************************************************/ +int fcoords_list_isempty ( fcoords_list_t ); + +/******************************************************************************** + * Function: fcoords_list_toarray + * + * Description: Convert the dynamic structure to a static array. The length + * of the array should be known a-priori and specified in input. + * List is deleted after this operation. Run-time error occurs if + * the caller specify a number of elements greater than the real + * value. Memory leak occurs if the caller specify a number of + * elements lower than the real value. + * + * Input(s): fcoords_list_t* - The list to convert + * int - The number of list elements + * + * Output: The pointer to the array or NULL if there is not enough + * (contiguous) memory for the array (list is deleted in any + * case). + ********************************************************************************/ +fcoords_t* fcoords_list_toarray ( fcoords_list_t*, int ); + + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.c new file mode 100644 index 0000000000000000000000000000000000000000..4e048fce5e6589991100e53985f7a26d6b014810 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.c @@ -0,0 +1,448 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/* +* p3dSquaredEuclideanDistanceTransform +* +* Computes the squared Euclidean distance transform of the input volume. For +* each non-zero voxel in input image, the distance transform assigns a number +* that is the squared distance between that voxel and the nearest zero pixel +* (background). The squared Euclidean distance transform is a non-approximated +* Euclidean distance metric. +* +* Remarks +* ------- +* Computational cost is O(N^3) for a NxNxN input volume. Memory +* requirement is two internal volumes of a NxNxN and two linear arrays of N +* elements, i.e. O(N^3) of type int. Current implementation uses int elements, +* therefore (for most compilers) memory requirement is 8 x O(N^3) the size of +* input volume. +* +* References +* ---------- +* [1] T. Hirata. "A unified linear-time algorithm for computing distance +* maps", Information Processing Letters, 58(3):129-133, May 1996. +* +* [2] A. Meijster, J.B.T.M. Roerdink and W. H. Hesselink. "A general +* algorithm for computing distance transforms in linear time", +* Mathematical Morphology and its Applications to Image and Signal +* Processing, pp. 331-340. Kluwer, 2000. +* + +* +* Copyright 2008, SYRMEP Group - Sincrotrone Trieste S.C.p.A. +* +* Author: Brun Francesco +* Version: 1.0 +* Date: 19 june 2008 +* +*/ +#include <stdlib.h> +#include <limits.h> +#include <omp.h> + +#include "p3dSquaredEuclideanDT.h" +#include "p3dUtils.h" + +// Set a signed integer type able to get over 65.535 and the +// maximum value representable (INF) with this specified type +// (see <limits.h>). These settings depends on the specific +// compilator used. +typedef int int_type; +#define INF INT_MAX + +/* ------------------- + * Mathematical operators with INF management. + * ------------------- */ + +/** + ************************************************** + * @b sum + * @param a int_type number with INF + * @param b int_type number with INF + * @return The sum of a and b handling INF + **************************************************/ +int_type sum( int_type a, int_type b ) +{ + if ((a == INF) || (b == INF)) + return INF; + else + return a + b; +} + +/** + ************************************************** + * @b prod + * @param a long number with INF + * @param b long number with INF + * @return The product of a and b handling INF + **************************************************/ +int_type prod( int_type a, int_type b ) +{ + if ((a == INF) || (b == INF)) + return INF; + else + return a * b; +} +/** + ************************************************** + * @b opp + * @param a long number with INF + * @return The opposite of a handling INF + **************************************************/ +int_type opp( int_type a ) +{ + if (a == INF) + return INF; + else + return -a; +} + +/** + ************************************************** + * @b intdivint + * @param divid long number with INF + * @param divis long number with INF + * @return The division (integer) of divid out of divis handling INF + **************************************************/ +int_type intdivint( int_type divid, int_type divis ) +{ + if (divis == 0) + return INF; + if (divid == INF) + return INF; + else + return divid / divis; +} + +/* ------------------- + * Mathematical operators for the parabola definition. + * ------------------- */ + +/** + ************************************************** + * @b f + * @param x + * @param i + * @param gi2 + * @return Definition of a parabola + **************************************************/ +int_type f( int x, int i, int_type gi2 ) +{ + return sum((x-i)*(x-i), gi2); +} + +/** + ************************************************** + * @b sep + * @param i + * @param u + * @param gi2 + * @param gu2 + * @return The abscissa of the intersection point between two parabolas + **************************************************/ +int_type sep( int i, int u, int_type gi2, int_type gu2 ) +{ + return intdivint(sum( sum((long) (u*u - i*i),gu2), opp(gi2) ), 2*(u-i)); +} + + + +/* ------------------- + * Steps of distance transform algorithm. + * ------------------- */ + + +/** + ************************************************** + * @b stepX + * @param voi input volume + * @param sdt_x DT along the x-direction + **************************************************/ +int stepX ( const unsigned char* voi, + int_type* sdt_x, + const int NRows, + const int NCols, + const int NPlanes + ) +{ + int x,y,z; + + for (z = 0; z < NPlanes; z++) + for (y = 0; y < NCols ; y++) + { + if (voi[ I(0,y,z,NRows,NCols) ] == 0) + sdt_x[ I(0,y,z,NRows,NCols) ] = 0; + else + sdt_x[ I(0,y,z,NRows,NCols) ] = INF; + + // Forward scan + for (x = 1; x < NRows; x++) + if (voi[ I(x,y,z,NRows,NCols) ] == 0) + sdt_x[ I(x,y,z,NRows,NCols) ] = 0; + else + sdt_x[ I(x,y,z,NRows,NCols) ] = sum(1, sdt_x[ I(x-1,y,z,NRows,NCols)] ); + + //Backward scan + for (x = NRows-2; x >= 0; x--) + if (sdt_x[ I(x+1,y,z,NRows,NCols) ] < sdt_x[ I(x,y,z,NRows,NCols) ]) + sdt_x[ I(x,y,z,NRows,NCols) ] = sum(1, sdt_x[ I(x+1,y,z,NRows,NCols) ]); + } + + // Return success code: + return P3D_SUCCESS; +} + +/** + ************************************************** + * @b stepY + * @param sdt_x the DT along the x-direction + * @param sdt_xy the DT in the xy-slices + **************************************************/ +int stepY ( const int_type* sdt_x, + int_type* sdt_xy, + const int NRows, + const int NCols, + const int NPlanes + ) +{ + + int* s; // Center of the upper envelope parabolas + int* t; // Separating index between 2 upper envelope + // parabolas + int q; + int w; + + int x,z,u; + + + P3D_TRY ( s = (int*) calloc(NCols, sizeof(int)) ); + P3D_TRY ( t = (int*) calloc(NCols, sizeof(int)) ); + + + for (z = 0; z < NPlanes; z++) + for (x = 0; x < NRows; x++) + { + q = 0; + s[0] = 0; + t[0] = 0; + + //Forward scanning: + for (u=1; u < NCols ; u++) + { + while ((q >= 0) && + ( f(t[q],s[q],prod(sdt_x[ I(x,s[q],z,NRows,NCols) ],sdt_x[ I(x,s[q],z,NRows,NCols) ])) > + f(t[q],u,prod(sdt_x[ I(x,u,z,NRows,NCols) ],sdt_x[ I(x,u,z,NRows,NCols) ]))) ) + q--; + + if (q<0) + { + q=0; + s[0]=u; + } + else + { + w = 1 + sep(s[q],u, + prod(sdt_x[ I(x,s[q],z,NRows,NCols) ],sdt_x[ I(x,s[q],z,NRows,NCols) ]), + prod(sdt_x[ I(x,u,z,NRows,NCols) ],sdt_x[ I(x,u,z,NRows,NCols) ])); + + if (w < NCols) + { + q++; + s[q]=u; + t[q]=w; + } + } + } + + //Backward scanning: + for (u = NCols-1; u >= 0; --u) + { + sdt_xy[ I(x,u,z,NRows,NCols) ] = f(u,s[q],prod(sdt_x[ I(x,s[q],z,NRows,NCols) ],sdt_x[ I(x,s[q],z,NRows,NCols) ])); + if (u==t[q]) + q--; + } + } + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return error code: + return P3D_ERROR; +} + +/** + ************************************************** + * @b stepZ + * @param sdt_xy the DT in the xy-slices + * @param sdt_xyz the final DT + **************************************************/ +int stepZ ( const int_type* sdt_xy, + int_type* sdt_xyz, + const int NRows, + const int NCols, + const int NPlanes + ) +{ + + int* s; // Center of the upper envelope parabolas + int* t; // Separating index between 2 upper envelope + // parabolas + int q; + int w; + + int x,y,u; + + + P3D_TRY ( s = (int*) calloc(NPlanes, sizeof(int)) ); + P3D_TRY ( t = (int*) calloc(NPlanes, sizeof(int)) ); + + + for (y = 0; y < NCols; y++) + for (x = 0; x < NRows; x++) + { + q = 0; + s[0] = 0; + t[0] = 0; + + //Forward scanning: + for ( u = 1; u < NPlanes ; u++ ) + { + while ((q >= 0) && + (f(t[q],s[q], sdt_xy[ I(x,y,s[q],NRows,NCols) ]) > + f(t[q],u,sdt_xy[ I(x,y,u,NRows,NCols) ])) ) + q--; + + if (q < 0) + { + q = 0; + s[0] = u; + } + else + { + w = 1 + sep(s[q], u, + sdt_xy[ I(x,y,s[q],NRows,NCols) ], + sdt_xy[ I(x,y,u,NRows,NCols) ]); + + if (w < NPlanes) + { + q++; + s[q]=u; + t[q]=w; + } + } + } + + //Backward scanning: + for (u = NPlanes-1; u >= 0; --u) + { + sdt_xyz[ I(x,y,u,NRows,NCols) ] = f(u,s[q],sdt_xy[ I(x,y,s[q],NRows,NCols) ]); + if ( u == t[q] ) + q--; + } + } + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free memory: + if ( s != NULL ) free(s); + if ( t != NULL ) free(t); + + // Return error code: + return P3D_ERROR; +} + + +/************************************************************************ + * DT3 - Entry point: + * + * + ************************************************************************/ +int p3dSquaredEuclideanDT( + unsigned char* in_rev, + unsigned short* out_rev, + const int dimx, + const int dimy, + const int dimz + ) +{ + // Temporary values and volume: + int_type* tmp_rev; + int_type* tmp_out_rev; + + // Counter: + int i; + + + // Allocate temporary output: + P3D_TRY ( tmp_out_rev = (int_type*) malloc(dimx*dimy*dimz*sizeof(int_type)) ); + P3D_TRY ( tmp_rev = (int_type*) malloc( dimx*dimy*dimz*sizeof(int_type) ) ); + + // Compute transform: + P3D_TRY ( stepX ( in_rev, tmp_out_rev, dimx, dimy, dimz ) ); + P3D_TRY ( stepY ( tmp_out_rev, tmp_rev, dimx, dimy, dimz ) ); + P3D_TRY ( stepZ ( tmp_rev, tmp_out_rev, dimx, dimy, dimz ) ); + + // Cast output from int_type to unsigned short: + for ( i = 0; i < (dimx*dimy*dimz); i++) + out_rev[i] = (tmp_out_rev[i] > USHRT_MAX) ? USHRT_MAX : (unsigned short) ( tmp_out_rev[i] ); + + + // Free allocated memory: + if ( tmp_rev != NULL ) free(tmp_rev); + if ( tmp_out_rev != NULL ) free(tmp_out_rev); + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Free allocated memory: + if ( tmp_rev != NULL ) free(tmp_rev); + if ( tmp_out_rev != NULL ) free(tmp_out_rev); + + // Return error: + return P3D_ERROR; +} + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.h new file mode 100644 index 0000000000000000000000000000000000000000..baaa3a03cf5c006c41f40ca49ee9c6d6a6b6f5fb --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.h @@ -0,0 +1,77 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/* +* p3dSquaredEuclideanDistanceTransform +* +* Computes the squared Euclidean distance transform of the input volume. For +* each non-zero voxel in input image, the distance transform assigns a number +* that is the squared distance between that voxel and the nearest zero pixel +* (background). The squared Euclidean distance transform is a non-approximated +* Euclidean distance metric. +* +* Remarks +* ------- +* Computational cost is O(N^3) for a NxNxN input volume. Memory +* requirement is three extra volumes of a NxNxN and two linear arrays of N +* elements, i.e. O(N^3). Current implementation uses unsigned short elements +* (see compiler specifications). +* +* References +* ---------- +* [1] T. Hirata. "A unified linear-time algorithm for computing distance +* maps", Information Processing Letters, 58(3):129-133, May 1996. +* +* [2] A. Meijster, J.B.T.M. Roerdink and W. H. Hesselink. "A general +* algorithm for computing distance transforms in linear time", +* Mathematical Morphology and its Applications to Image and Signal +* Processing, pp. 331-340. Kluwer, 2000. +* + +* +* Copyright 2008, SYRMEP Group - Sincrotrone Trieste S.C.p.A. +* +* Author: Brun Francesco +* Version: 1.0 +* Date: 19 june 2008 +* +*/ + + + +/************************************************************************ + * DT3 - Entry point: + * + * + ************************************************************************/ +int p3dSquaredEuclideanDT( + unsigned char* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz + ); diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dThinning.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dThinning.c new file mode 100644 index 0000000000000000000000000000000000000000..5c597f1c51e48e5cb0dc4c03f139d4890b06029c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dThinning.c @@ -0,0 +1,750 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "p3dUtils.h" + +#define BORDER 100 // Custom label to mark a border voxel +#define SIMPLE 200 // Custom label to mark a simple voxel + + +#define UP_SOUTH 0 +#define NORTH_EAST 1 +#define WEST_DOWN 2 + +#define EAST_SOUTH 3 +#define UP_WEST 4 +#define NORTH_DOWN 5 + +#define SOUTH_WEST 6 +#define UP_NORTH 7 +#define EAST_DOWN 8 + +#define NORTH_WEST 9 +#define UP_EAST 10 +#define SOUTH_DOWN 11 + +#define UP 12 +#define DOWN 13 +#define EAST 14 +#define WEST 15 +#define NORTH 16 +#define SOUTH 17 + + +int checkTemplate ( int n[27] ) +{ + // T1 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) ) + && + ((n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE) && (n[I(2,2,1,3,3)] == P3D_FALSE) && + (n[I(0,2,2,3,3)] == P3D_FALSE) && (n[I(1,2,2,3,3)] == P3D_FALSE) && + (n[I(2,2,2,3,3)] == P3D_FALSE) ) + && + ((n[I(0,0,0,3,3)] == P3D_TRUE) || (n[I(1,0,0,3,3)] == P3D_TRUE) || + (n[I(2,0,0,3,3)] == P3D_TRUE) || (n[I(0,0,1,3,3)] == P3D_TRUE) || + (n[I(2,0,1,3,3)] == P3D_TRUE) || (n[I(0,0,2,3,3)] == P3D_TRUE) || + (n[I(1,0,2,3,3)] == P3D_TRUE) || (n[I(2,0,2,3,3)] == P3D_TRUE) || + (n[I(0,1,0,3,3)] == P3D_TRUE) || (n[I(1,1,0,3,3)] == P3D_TRUE) || + (n[I(2,1,0,3,3)] == P3D_TRUE) || (n[I(0,1,1,3,3)] == P3D_TRUE) || + (n[I(2,1,1,3,3)] == P3D_TRUE) || (n[I(0,1,2,3,3)] == P3D_TRUE) || + (n[I(1,1,2,3,3)] == P3D_TRUE) || (n[I(2,1,2,3,3)] == P3D_TRUE) ) + ) + { + return P3D_TRUE; + } + + // T2 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,1,2,3,3)] == P3D_TRUE)) + && + ((n[I(0,0,0,3,3)] == P3D_FALSE) && (n[I(1,0,0,3,3)] == P3D_FALSE) && + (n[I(2,0,0,3,3)] == P3D_FALSE) && (n[I(0,1,0,3,3)] == P3D_FALSE) && + (n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(2,1,0,3,3)] == P3D_FALSE) && + (n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE)) + && + ((n[I(0,0,1,3,3)] == P3D_TRUE) || (n[I(1,0,1,3,3)] == P3D_TRUE) || + (n[I(2,0,1,3,3)] == P3D_TRUE) || (n[I(0,1,1,3,3)] == P3D_TRUE) || + (n[I(2,1,1,3,3)] == P3D_TRUE) || (n[I(0,2,1,3,3)] == P3D_TRUE) || + (n[I(1,2,1,3,3)] == P3D_TRUE) || (n[I(2,2,1,3,3)] == P3D_TRUE) || + (n[I(0,0,2,3,3)] == P3D_TRUE) || (n[I(1,0,2,3,3)] == P3D_TRUE) || + (n[I(2,0,2,3,3)] == P3D_TRUE) || (n[I(0,1,2,3,3)] == P3D_TRUE) || + (n[I(2,1,2,3,3)] == P3D_TRUE) || (n[I(0,2,2,3,3)] == P3D_TRUE) || + (n[I(1,2,2,3,3)] == P3D_TRUE) || (n[I(2,2,2,3,3)] == P3D_TRUE)) + ) + { + return P3D_TRUE; + } + + // T3 + if(( (n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,2,3,3)] == P3D_TRUE) ) + && + ((n[I(0,0,0,3,3)] == P3D_FALSE) && (n[I(1,0,0,3,3)] == P3D_FALSE) && + (n[I(2,0,0,3,3)] == P3D_FALSE) && (n[I(0,1,0,3,3)] == P3D_FALSE) && + (n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(2,1,0,3,3)] == P3D_FALSE) && + (n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE) && (n[I(2,2,1,3,3)] == P3D_FALSE) && + (n[I(0,2,2,3,3)] == P3D_FALSE) && (n[I(1,2,2,3,3)] == P3D_FALSE) && + (n[I(2,2,2,3,3)] == P3D_FALSE) ) + && + ((n[I(0,0,1,3,3)] == P3D_TRUE) || (n[I(2,0,1,3,3)] == P3D_TRUE) || + (n[I(0,0,2,3,3)] == P3D_TRUE) || (n[I(2,0,2,3,3)] == P3D_TRUE) || + (n[I(0,1,1,3,3)] == P3D_TRUE) || (n[I(2,1,1,3,3)] == P3D_TRUE) || + (n[I(0,1,2,3,3)] == P3D_TRUE) || (n[I(2,1,2,3,3)] == P3D_TRUE) ) + ) + { + return P3D_TRUE; + } + + // T4 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(1,1,2,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(0,2,0,3,3)] == P3D_FALSE) && + (n[I(1,2,0,3,3)] == P3D_FALSE) && (n[I(2,2,0,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE) ) + && + /*!(n[0][1][0] && n[0][2][1]) + && + !(n[2][1][0] && n[2][2][1])*/ + ( (n[I(0,1,0,3,3)] == P3D_FALSE) || (n[I(0,2,1,3,3)] == P3D_FALSE) ) + && + ( (n[I(2,1,0,3,3)] == P3D_FALSE) || (n[I(2,2,1,3,3)] == P3D_FALSE) ) + ) + { + return P3D_TRUE; + } + + // T5 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(1,1,2,3,3)] == P3D_TRUE) && (n[I(2,2,0,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(0,2,0,3,3)] == P3D_FALSE) && + (n[I(1,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,1,3,3)] == P3D_FALSE) ) + && + ( (n[I(0,1,0,3,3)] == P3D_FALSE) || (n[I(0,2,1,3,3)] == P3D_FALSE) ) + && + (((n[I(2,1,0,3,3)] == P3D_FALSE) && (n[I(2,2,1,3,3)] == P3D_TRUE)) + || + ((n[I(2,1,0,3,3)] == P3D_TRUE) && (n[I(2,2,1,3,3)] == P3D_FALSE))) + ) + { + return P3D_TRUE; + } + + // T6 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(1,1,2,3,3)] == P3D_TRUE) && (n[I(0,2,0,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,1,3,3)] == P3D_FALSE) ) + && + (((n[I(0,1,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_TRUE)) || + ((n[I(0,1,0,3,3)] == P3D_TRUE) && (n[I(0,2,1,3,3)] == P3D_FALSE))) + && + //!(n[2][1][0] && n[2][2][1]) + ((n[I(2,1,0,3,3)] == P3D_FALSE) || (n[I(2,2,1,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + // T7 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(2,1,1,3,3)] == P3D_TRUE) && (n[I(1,1,2,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(0,2,0,3,3)] == P3D_FALSE) && + (n[I(1,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,1,3,3)] == P3D_FALSE)) + && + //!(n[0][1][0] && n[0][2][1]) + ((n[I(0,1,0,3,3)] == P3D_FALSE) || (n[I(0,2,1,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + // T8 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(0,1,1,3,3)] == P3D_TRUE) && (n[I(1,1,2,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,1,3,3)] == P3D_FALSE)) + && + ((n[I(2,1,0,3,3)] == P3D_FALSE) || (n[I(2,2,1,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + // T9 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(2,1,1,3,3)] == P3D_TRUE) && (n[I(1,1,2,3,3)] == P3D_TRUE) && + (n[I(0,2,0,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE)) + && + (((n[I(0,1,0,3,3)] == P3D_TRUE) && (n[I(0,2,1,3,3)] == P3D_FALSE)) || + ((n[I(0,1,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_TRUE))) + ) + { + return P3D_TRUE; + } + + // T10 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,1,3,3)] == P3D_TRUE) && + (n[I(0,1,1,3,3)] == P3D_TRUE) && (n[I(1,1,2,3,3)] == P3D_TRUE) && + (n[I(2,2,0,3,3)] == P3D_TRUE)) + && + ((n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) + && (n[I(1,2,1,3,3)] == P3D_FALSE)) + && + (((n[I(2,1,0,3,3)] == P3D_TRUE) && (n[I(2,2,1,3,3)] == P3D_FALSE)) || + ((n[I(2,1,0,3,3)] == P3D_FALSE) && (n[I(2,2,1,3,3)] == P3D_TRUE))) + ) + { + return P3D_TRUE; + } + + // T11 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(2,0,1,3,3)] == P3D_TRUE) && + (n[I(1,0,2,3,3)] == P3D_TRUE)) + && + ((n[I(0,0,0,3,3)] == P3D_FALSE) && (n[I(1,0,0,3,3)] == P3D_FALSE) && + (n[I(0,1,0,3,3)] == P3D_FALSE) && (n[I(1,1,0,3,3)] == P3D_FALSE) && + (n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE) && (n[I(2,2,1,3,3)] == P3D_FALSE) && + (n[I(0,2,2,3,3)] == P3D_FALSE) && (n[I(1,2,2,3,3)] == P3D_FALSE) && + (n[I(2,2,2,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + // T12 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(0,0,1,3,3)] == P3D_TRUE) && + (n[I(1,0,2,3,3)] == P3D_TRUE)) + && + ((n[I(1,0,0,3,3)] == P3D_FALSE) && (n[I(2,0,0,3,3)] == P3D_FALSE) && + (n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(2,1,0,3,3)] == P3D_FALSE) && + (n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE) && (n[I(2,2,1,3,3)] == P3D_FALSE) && + (n[I(0,2,2,3,3)] == P3D_FALSE) && (n[I(1,2,2,3,3)] == P3D_FALSE) && + (n[I(2,2,2,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + // T13 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,2,3,3)] == P3D_TRUE) && + (n[I(2,1,2,3,3)] == P3D_TRUE)) + && + ((n[I(0,0,0,3,3)] == P3D_FALSE) && (n[I(1,0,0,3,3)] == P3D_FALSE) && + (n[I(2,0,0,3,3)] == P3D_FALSE) && (n[I(0,1,0,3,3)] == P3D_FALSE) && + (n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(2,1,0,3,3)] == P3D_FALSE) && + (n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(0,2,1,3,3)] == P3D_FALSE) && + (n[I(1,2,1,3,3)] == P3D_FALSE) && (n[I(0,2,2,3,3)] == P3D_FALSE) && + (n[I(1,2,2,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + // T14 + if(((n[I(1,1,1,3,3)] == P3D_TRUE) && (n[I(1,0,2,3,3)] == P3D_TRUE) && + (n[I(0,1,2,3,3)] == P3D_TRUE)) + && + ((n[I(0,0,0,3,3)] == P3D_FALSE) && (n[I(1,0,0,3,3)] == P3D_FALSE) && + (n[I(2,0,0,3,3)] == P3D_FALSE) && (n[I(0,1,0,3,3)] == P3D_FALSE) && + (n[I(1,1,0,3,3)] == P3D_FALSE) && (n[I(2,1,0,3,3)] == P3D_FALSE) && + (n[I(0,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,0,3,3)] == P3D_FALSE) && + (n[I(2,2,0,3,3)] == P3D_FALSE) && (n[I(1,2,1,3,3)] == P3D_FALSE) && + (n[I(2,2,1,3,3)] == P3D_FALSE) && (n[I(1,2,2,3,3)] == P3D_FALSE) && + (n[I(2,2,2,3,3)] == P3D_FALSE)) + ) + { + return P3D_TRUE; + } + + return P3D_FALSE; +} + + + +void transformNeigh ( int n[27], int dir, int USn[27] ) +{ + int i, j, k; + int tmp[27]; + + switch(dir) { + case 0: //UP_SOUTH = 0, + // just copy + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,j,k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + + // The following cases are clearly rotations only + case 3: // EAST_SOUTH, + + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,j,k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + + case 6: // SOUTH_WEST, + + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(j,2-i,k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + + case 10: // UP_EAST, + + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(k,j,2-i,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + case 4: // UP_WEST, + + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(2-k,j,i,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + + case 11: // SOUTH_DOWN + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,2-j,k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + + case 7: // UP_NORTH, + + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,j,2-k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + break; + + case 5: // NORTH_DOWN, + + // OR - two reflections + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + tmp[I(i,j,2-k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + // 2 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,2-j,k,3,3)] = tmp[I(i,j,k,3,3)]; + } + } + } + break; + + case 8: // EAST_DOWN, + + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + tmp[I(k,j,2-i,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + // 2 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,2-j,k,3,3)] = tmp[I(i,j,k,3,3)]; + } + } + } + break; + + case 2: // WEST_DOWN, + // 1 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + tmp[I(2-k,j,i,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + // 2 + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(i,2-j,k,3,3)] = tmp[I(i,j,k,3,3)]; + } + } + } + break; + + case 1: //NORTH_EAST, + + // 1 - reflection + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + tmp[I(i,j,2-k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + // 2 - rotation + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(2-j,i,k,3,3)] = tmp[I(i,j,k,3,3)]; + } + } + } + break; + + case 9: // NORTH_WEST, + + // 1 - reflection + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + tmp[I(i,j,2-k,3,3)] = n[I(i,j,k,3,3)]; + } + } + } + // 2 - rotation + for(k=0; k < 3; k++) { + for(j=0; j < 3; j++) { + for(i=0; i < 3; i++) { + USn[I(j,2-i,k,3,3)] = tmp[I(i,j,k,3,3)]; + } + } + } + break; + + } +} + + +void markBoundary ( unsigned char *vol, int L, int M, int N, int dir ) +{ + int slsz = L*M; + int idx; + int i, j, k; + + + // neighbor index in 18 directions (only last 6 used) + int nb[18] = + { + +L - slsz, // UP_SOUTH, 0 + +slsz + 1, // NORTH_EAST, 1 + -1 - L, // WEST_DOWN, 2 + + +1 -slsz, // EAST_SOUTH, 3 + +L - 1, // UP_WEST, 4 + +slsz - L, // NORTH_DOWN, 5 + + -slsz - 1, // SOUTH_WEST, 6 + +L + slsz, // UP_NORTH, 7 + +1 - L, // EAST_DOWN, 8 + + +slsz - 1, // NORTH_WEST, 9 + +L + 1, // UP_EAST, 10 + -slsz - L, // SOUTH_DOWN,11 + + +L, // UP, 12 + -L, // DOWN, 13 + +1, // EAST, 14 + -1, // WEST, 15 + +slsz, // NORTH, 16 + -slsz // SOUTH, 17 + }; + + + for( k = 1; k < (N-1); k++ ) + for( j = 1; j < (M-1); j++ ) + for( i = 1; i < (L-1); i++ ) + { + idx = k*slsz + j*L + i; + + if( (vol[idx] == OBJECT) && ( vol[idx + nb[dir]] == 0) ) + { + vol[idx] = BORDER; + } + } +} + + + + + + + + + +void bufferizeNeigh ( unsigned char *vol, int idx, int nb[27], const int volNeigh[27] ) +{ + int nidx; + int i, j, k, ii; + + ii = 0; + for( k = 0; k < 3; k++ ) + for( j = 0; j < 3; j++ ) + for( i = 0; i < 3; i++ ) + { + nidx = idx + volNeigh[ii++]; + + nb[I(i,j,k,3,3)] = ( vol[nidx] != BACKGROUND ) ? P3D_TRUE : P3D_FALSE; + } +} + + +int p3dThinning ( + unsigned char* in_rev, + const int dimx, + const int dimy, + const int dimz + ) +{ + int nrDel; + + int dir; + int nb[27]; + int USn[27]; + int idx; + int i, j, k; + + // Initialize neighbors array: + const int volNeighbors[27] = + { + // lower plane + (-(dimx*dimy) -dimx -1), + (-(dimx*dimy) -dimx +0), + (-(dimx*dimy) -dimx +1), + (-(dimx*dimy) +0 -1), + (-(dimx*dimy) +0 +0), + (-(dimx*dimy) +0 +1), + (-(dimx*dimy) +dimx -1), + (-(dimx*dimy) +dimx +0), + (-(dimx*dimy) +dimx +1), + // same plane + (+0 -dimx -1), + (+0 -dimx +0), + (+0 -dimx +1), + (+0 +0 -1), + (+0 +0 +0), + (+0 +0 +1), + (+0 +dimx -1), + (+0 +dimx +0), + (+0 +dimx +1), + // upper plane + (+(dimx*dimy) -dimx -1), + (+(dimx*dimy) -dimx +0), + (+(dimx*dimy) -dimx +1), + (+(dimx*dimy) +0 -1), + (+(dimx*dimy) +0 +0), + (+(dimx*dimy) +0 +1), + (+(dimx*dimy) +dimx -1), + (+(dimx*dimy) +dimx +0), + (+(dimx*dimy) +dimx +1), + }; + + nrDel = 1; + + + // Loop until no more voxels can be deleted: + while( nrDel > 0 ) + { + nrDel = 0; + + // Perform the 12 sub-iteration thinning (in parallel ???) + //#pragma omp parallel for private(i, j, k, idx, nb, USn) reduction (+ : nrDel ) + for(dir = 0; dir < 12; dir++) + { + switch(dir) + { + case UP_SOUTH: + // UP + markBoundary(in_rev, dimx, dimy, dimz, UP); + // SOUTH + markBoundary(in_rev, dimx, dimy, dimz, SOUTH); + break; + case NORTH_EAST: + // NOTH + markBoundary(in_rev, dimx, dimy, dimz, NORTH); + // EAST + markBoundary(in_rev, dimx, dimy, dimz, EAST); + break; + case WEST_DOWN: + // WEST + markBoundary(in_rev, dimx, dimy, dimz, WEST); + // DOWN + markBoundary(in_rev, dimx, dimy, dimz, DOWN); + break; + case EAST_SOUTH: + // EAST + markBoundary(in_rev, dimx, dimy, dimz, EAST); + // SOUTH + markBoundary(in_rev, dimx, dimy, dimz, SOUTH); + break; + case UP_WEST: + // UP + markBoundary(in_rev, dimx, dimy, dimz, UP); + // WEST + markBoundary(in_rev, dimx, dimy, dimz, WEST); + break; + case NORTH_DOWN: + // NORTH + markBoundary(in_rev, dimx, dimy, dimz, NORTH); + // DOWN + markBoundary(in_rev, dimx, dimy, dimz, DOWN); + break; + case SOUTH_WEST: + // SOUTH + markBoundary(in_rev, dimx, dimy, dimz, SOUTH); + // WEST + markBoundary(in_rev, dimx, dimy, dimz, WEST); + break; + case UP_NORTH: + // UP + markBoundary(in_rev, dimx, dimy, dimz, UP); + // NORTH + markBoundary(in_rev, dimx, dimy, dimz, NORTH); + break; + case EAST_DOWN: + // EAST + markBoundary(in_rev, dimx, dimy, dimz, EAST); + // DOWN + markBoundary(in_rev, dimx, dimy, dimz, DOWN); + break; + case NORTH_WEST: + // NORTH + markBoundary(in_rev, dimx, dimy, dimz, NORTH); + // WEST + markBoundary(in_rev, dimx, dimy, dimz, WEST); + break; + case UP_EAST: + // UP + markBoundary(in_rev, dimx, dimy, dimz, UP); + // EAST + markBoundary(in_rev, dimx, dimy, dimz, EAST); + break; + case SOUTH_DOWN: + // SOUTH + markBoundary(in_rev, dimx, dimy, dimz, SOUTH); + // DOWN + markBoundary(in_rev, dimx, dimy, dimz, DOWN); + break; + } + + + // Check each boundary point and remove it if it macthes a template: + #pragma omp parallel for private(i, j, idx, nb, USn) reduction (+ : nrDel ) + for( k = 1; k < (dimz-1); k++ ) + for( j = 1; j < (dimy-1); j++ ) + for( i = 1; i < (dimx-1); i++ ) + { + idx = I(i,j,k,dimx,dimy); + + if( in_rev[ idx ] == BORDER ) + { + // Copy neighborhood into buffer: + bufferizeNeigh(in_rev, idx, nb, volNeighbors); + + transformNeigh(nb, dir, USn); + + if( checkTemplate(USn) == P3D_TRUE ) + { + // Mark as SIMPLE a point that can be removed: + in_rev[ idx ] = SIMPLE; + nrDel++; + } + } + } + + + // Reset all object voxels to OBJECT and delete simple points: + #pragma omp parallel for + for( idx = 0; idx < (dimx*dimy*dimz); idx++ ) + { + if(in_rev[idx] == SIMPLE) in_rev[idx] = BACKGROUND; + if(in_rev[idx] != BACKGROUND) in_rev[idx] = OBJECT; + } + } + } + + // Return OK: + return P3D_SUCCESS; +} + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dThinning.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dThinning.h new file mode 100644 index 0000000000000000000000000000000000000000..ff3de9d90a74c980e2a96597897e90746ca1376e --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dThinning.h @@ -0,0 +1,33 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +int p3dThinning ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dUIntList.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dUIntList.c new file mode 100644 index 0000000000000000000000000000000000000000..4134bc8a2ff2efd41e34ed025490a7ca64275eac --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dUIntList.c @@ -0,0 +1,103 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dUIntList.h" +#include "p3dUtils.h" + +void uint_list_init (uint_list_t *list) +{ + *list = NULL; +} + +void uint_list_add (uint_list_t *list, unsigned int elem) +{ + uint_list_elem_t* new_l; + + // Alloc memory for the new item: + new_l = (uint_list_elem_t*) malloc (sizeof(uint_list_elem_t)); + + // Push item into queue: + new_l->ct = elem; + new_l->next = *list; + + *list = new_l; +} + + +int uint_list_isempty (uint_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + +// List is deleted after conversion: +unsigned int* uint_list_toarray (uint_list_t *list, int numel ) +{ + uint_list_elem_t* tmp_l; + + + unsigned int* v; + int i; + + v = (unsigned int*) malloc (numel*sizeof(unsigned int)); + + // Convert list to array: + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->ct; + + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + return v; +} + +void uint_list_clear (uint_list_t *list) +{ + uint_list_elem_t* tmp_l; + + // Scan whole list: + while( *list != NULL ) + { + // Perform deletion: + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + + // Final assignment for safety: + *list = NULL; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dUIntList.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dUIntList.h new file mode 100644 index 0000000000000000000000000000000000000000..d81c9c5f7ea5961de9b34e1e231b9bb4c5c1798c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dUIntList.h @@ -0,0 +1,59 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/********************************************************************* + * + * uint_list_t type definitions. + * + *********************************************************************/ + +struct uint_lelem_t { + unsigned int ct; + struct uint_lelem_t *next; +}; + +typedef struct uint_lelem_t uint_list_elem_t; + +typedef uint_list_elem_t* uint_list_t; + + +/********************************************************************* + * + * Interface for the queue (FIFO). + * + *********************************************************************/ + +void uint_list_init (uint_list_t *list); + +void uint_list_add(uint_list_t *list, unsigned int ct); + +int uint_list_isempty(uint_list_t list); + +unsigned int* uint_list_toarray (uint_list_t *list, int numel ); + +void uint_list_clear (uint_list_t *list); + diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dUtils.c b/pypore3d/pypore3d/P3D_Skel/Common/p3dUtils.c new file mode 100644 index 0000000000000000000000000000000000000000..2479eeac23679fe21c7a34508849574dbb9dd9e6 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dUtils.c @@ -0,0 +1,1389 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <string.h> +#include <omp.h> + +#include "p3dUtils.h" + + + +int findNeighbor ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + coords_t* coords + ) +{ + int a,b,c; + int ct = 0; + + // 6-connection: + c = k - 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + + // On k plane: + c = k; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k - 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + c = k + 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + if (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) { + coords->x = a; + coords->y = b; + coords->z = c; + } + + // Return number of voxels in the neighborhood: + return ct; +} + +// Return the number of voxels in the neighborhood: +int countNeighbors ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c; + int ct = 0; + + // 6-connection: + c = k - 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j + 1; a = i; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + + // On k plane: + c = k; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k - 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + + // On k+1 plane: + c = k + 1; b = j - 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j - 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j + 1; a = i - 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + c = k + 1; b = j + 1; a = i + 1; + ct += (im[ I(a,b,c,dimx,dimy) ] != BACKGROUND) ? 1 : 0; + + // Return number of voxels in the neighborhood: + return ct; +} + +/** + * Octree_labeling [Lee94] + * This is a recursive method that calulates the number of connected + * components in the 3D neighbourhood after the center pixel would + * have been removed. + */ +void Octree_labeling(int octant, int label, int *cube) +{ + // check if there are points in the octant with value 1 + if( octant==1 ) + { + // set points in this octant to current label + // and recurseive labeling of adjacent octants + if( cube[0] == 1 ) + cube[0] = label; + if( cube[1] == 1 ) + { + cube[1] = label; + Octree_labeling( 2, label, cube); + } + if( cube[3] == 1 ) + { + cube[3] = label; + Octree_labeling( 3, label, cube); + } + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + } + if( cube[9] == 1 ) + { + cube[9] = label; + Octree_labeling( 5, label, cube); + } + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 7, label, cube); + } + } + if( octant==2 ) + { + if( cube[1] == 1 ) + { + cube[1] = label; + Octree_labeling( 1, label, cube); + } + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + } + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[2] == 1 ) + cube[2] = label; + if( cube[5] == 1 ) + { + cube[5] = label; + Octree_labeling( 4, label, cube); + } + if( cube[11] == 1 ) + { + cube[11] = label; + Octree_labeling( 6, label, cube); + } + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 4, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 8, label, cube); + } + } + if( octant==3 ) + { + if( cube[3] == 1 ) + { + cube[3] = label; + Octree_labeling( 1, label, cube); + } + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 4, label, cube); + } + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 5, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[6] == 1 ) + cube[6] = label; + if( cube[7] == 1 ) + { + cube[7] = label; + Octree_labeling( 4, label, cube); + } + if( cube[14] == 1 ) + { + cube[14] = label; + Octree_labeling( 7, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 4, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + } + if( octant==4 ) + { + if( cube[4] == 1 ) + { + cube[4] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 3, label, cube); + } + if( cube[5] == 1 ) + { + cube[5] = label; + Octree_labeling( 2, label, cube); + } + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[7] == 1 ) + { + cube[7] = label; + Octree_labeling( 3, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[8] == 1 ) + cube[8] = label; + if( cube[16] == 1 ) + { + cube[16] = label; + Octree_labeling( 8, label, cube); + } + } + if( octant==5 ) + { + if( cube[9] == 1 ) + { + cube[9] = label; + Octree_labeling( 1, label, cube); + } + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[17] == 1 ) + cube[17] = label; + if( cube[18] == 1 ) + { + cube[18] = label; + Octree_labeling( 6, label, cube); + } + if( cube[20] == 1 ) + { + cube[20] = label; + Octree_labeling( 7, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 6, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + } + if( octant==6 ) + { + if( cube[10] == 1 ) + { + cube[10] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 2, label, cube); + Octree_labeling( 5, label, cube); + } + if( cube[11] == 1 ) + { + cube[11] = label; + Octree_labeling( 2, label, cube); + } + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[18] == 1 ) + { + cube[18] = label; + Octree_labeling( 5, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 5, label, cube); + Octree_labeling( 7, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[19] == 1 ) + cube[19] = label; + if( cube[22] == 1 ) + { + cube[22] = label; + Octree_labeling( 8, label, cube); + } + } + if( octant==7 ) + { + if( cube[12] == 1 ) + { + cube[12] = label; + Octree_labeling( 1, label, cube); + Octree_labeling( 3, label, cube); + Octree_labeling( 5, label, cube); + } + if( cube[14] == 1 ) + { + cube[14] = label; + Octree_labeling( 3, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[20] == 1 ) + { + cube[20] = label; + Octree_labeling( 5, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 8, label, cube); + } + if( cube[23] == 1 ) + cube[23] = label; + if( cube[24] == 1 ) + { + cube[24] = label; + Octree_labeling( 8, label, cube); + } + } + if( octant==8 ) + { + if( cube[13] == 1 ) + { + cube[13] = label; + Octree_labeling( 2, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 6, label, cube); + } + if( cube[15] == 1 ) + { + cube[15] = label; + Octree_labeling( 3, label, cube); + Octree_labeling( 4, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[16] == 1 ) + { + cube[16] = label; + Octree_labeling( 4, label, cube); + } + if( cube[21] == 1 ) + { + cube[21] = label; + Octree_labeling( 5, label, cube); + Octree_labeling( 6, label, cube); + Octree_labeling( 7, label, cube); + } + if( cube[22] == 1 ) + { + cube[22] = label; + Octree_labeling( 6, label, cube); + } + if( cube[24] == 1 ) + { + cube[24] = label; + Octree_labeling( 7, label, cube); + } + if( cube[25] == 1 ) + cube[25] = label; + } +} + + + + +int isSimplePoint( + unsigned char* in_rev, // IN: Input (binary) original volume + const int dimx, + const int dimy, + const int dimz, + const int x, + const int y, + const int z + ) +{ + // copy neighbors for labeling + int cube[26]; + int i = 0; + int label = 2; // set initial label + + int a,b,c; + + /*for( i = 0; i < 13; i++ ) // i = 0..12 -> cube[0..12] + cube[i] = neighbors[i];*/ + + // From 0 to 8: + c = z - 1; + for ( b = (y - 1); b <= (y + 1); b++ ) + for ( a = (x - 1); a <= (x + 1); a++ ) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + // From 9 to 11: + c = z; + b = y - 1; + for (a = (x - 1); a <= (x + 1); a++) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + // The 12th: + c = z; + b = y; + a = x - 1; + + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + + // i != 13 : ignore center pixel when counting (see [Lee94]) + /*for( i = 14; i < 27; i++ ) // i = 14..26 -> cube[13..25] + cube[i-1] = neighbors[i];*/ + + // The 14th: + c = z; + b = y; + a = x + 1; + + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + + // From 15 to 18: + c = z; + b = y + 1; + for (a = (x - 1); a <= (x + 1); a++) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + // From 19 to 27: + c = z + 1; + for ( b = (y - 1); b <= (y + 1); b++ ) + for ( a = (x - 1); a <= (x + 1); a++ ) + { + cube[i++] = (in_rev[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + + + + // for all points in the neighborhood + for( i = 0; i < 26; i++ ) + { + if( cube[i]==1 ) // voxel has not been labelled yet + { + // start recursion with any octant that contains the point i + switch( i ) + { + case 0: + case 1: + case 3: + case 4: + case 9: + case 10: + case 12: + Octree_labeling(1, label, cube ); + break; + case 2: + case 5: + case 11: + case 13: + Octree_labeling(2, label, cube ); + break; + case 6: + case 7: + case 14: + case 15: + Octree_labeling(3, label, cube ); + break; + case 8: + case 16: + Octree_labeling(4, label, cube ); + break; + case 17: + case 18: + case 20: + case 21: + Octree_labeling(5, label, cube ); + break; + case 19: + case 22: + Octree_labeling(6, label, cube ); + break; + case 23: + case 24: + Octree_labeling(7, label, cube ); + break; + case 25: + Octree_labeling(8, label, cube ); + break; + } + label++; + if( label-2 >= 2 ) + { + return P3D_FALSE; + } + } + } + //return label-2; in [Lee94] if the number of connected components would be needed + return P3D_TRUE; +} + + +int p3dCrop3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCrop3D_ushort2ushort ( + unsigned short* in_rev, + unsigned short* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; +} + +int p3dCrop3D_float2float ( + float* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx - size*2; + a_dimy = dimy - size*2; + a_dimz = dimz - size*2; + + // Copy original (internal) values: + for (k = 0; k < a_dimz; k++) + for (j = 0; j < a_dimy; j++) + for (i = 0; i < a_dimx; i++) + out_rev[ I( i, j, k, a_dimx, a_dimy ) ] = + in_rev[ I( i + size, j + size, k + size, dimx, dimy) ]; + + // Return OK: + return P3D_SUCCESS; + +} + +int p3dZeroPadding3D_uchar2float ( + unsigned char* in_rev, + float* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + // Set to zero all values: + memset( out_rev, 0, a_dimx*a_dimy*a_dimz*sizeof(float) ); + + + // Copy original (internal) values: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) + out_rev[ I( i + size, j + size, k + size, a_dimx, a_dimy ) ] = + (float) (in_rev[ I( i, j, k, dimx, dimy ) ]); + + // Return OK: + return P3D_SUCCESS; +} + + +int p3dZeroPadding3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + // Set to zero all values: + memset( out_rev, 0, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + + + // Copy original (internal) values: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) + out_rev[ I( i + size, j + size, k + size, a_dimx, a_dimy ) ] = + in_rev[ I( i, j, k, dimx, dimy ) ]; + + // Return OK: + return P3D_SUCCESS; +} + + +int p3dReplicatePadding3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k,ct; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + + // Perform first zero padding: + p3dZeroPadding3D_uchar2uchar (in_rev, out_rev, dimx, dimy, dimz, size); + + + // Replicate border values: + for (ct = size; ct > 0; ct--) + { + // Faces: + + for (i = ct; i < (a_dimx - ct); i++) + for (j = ct; j < (a_dimy - ct); j++) + { + out_rev[ I( i, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, j, ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( i, j, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) + for (k = ct; k < (a_dimz - ct); k++) + { + out_rev[ I( ct - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I( ct, j, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, j, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, j, k, a_dimx, a_dimy ) ]; + } + + for (i = ct; i < (a_dimx - ct); i++) + for (k = ct; k < (a_dimz - ct); k++) + { + out_rev[ I( i, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( i, ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - ct, k, a_dimx, a_dimy ) ]; + } + + // Edges: + + for (i = ct; i < (a_dimx - ct); i++) + { + out_rev[ I( i, ct - 1, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, ct, ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( i, ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - ct, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, a_dimy - 1 - ct, ct, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + } + + for (j = ct; j < (a_dimy - ct); j++) + { + out_rev[ I( ct - 1, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( ct, j, ct, a_dimx, a_dimy ) ]; + out_rev[ I( ct - 1, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( ct, j, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, j, ct - 1, a_dimx, a_dimy) ] = + out_rev[ I( a_dimx - 1 - ct, j, ct, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, j, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, j, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + } + + for (k = ct; k < (a_dimz - ct); k++) + { + out_rev[ I( ct - 1, ct - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( ct, ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, ct - 1, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( ct - 1, a_dimy - ct, k, a_dimx, a_dimy) ] = + out_rev[ I( ct, a_dimy - 1 - ct, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - ct, a_dimy - ct, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, a_dimy - 1 - ct, k, a_dimx, a_dimy ) ]; + } + + // Corners: + + out_rev[ I( ct - 1, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( ct, ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - ct, ct - 1, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( ct - 1, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( ct - 1, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + + out_rev[ I( a_dimx - ct, a_dimy - ct, ct - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, a_dimy - 1 - ct, ct, a_dimx, a_dimy ) ]; + + out_rev[ I( ct - 1, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - ct, ct - 1, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - ct, a_dimy - ct, a_dimz - ct, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - ct, a_dimy - 1 - ct, a_dimz - 1 - ct, a_dimx, a_dimy ) ]; + + + } + + // Return OK: + return P3D_SUCCESS; +} + +double interpolation ( + float* gvf, + int dimx, + int dimy, + int dimz, + const double x, + const double y, + const double z + ) +{ + double alpha, beta, gamma; + + alpha = x - (int) (x); + beta = y - (int) (y); + gamma = z - (int) (z); + + + return (gvf [ I( (int) (x), (int) (y), (int) (z), dimx, dimy) ]*(1-alpha)*(1-beta)*(1-gamma) + + gvf [ I( (int) (x), (int) (y), (int) (z+1), dimx, dimy) ]*(1-alpha)*(1-beta)*gamma + + gvf [ I( (int) (x), (int) (y+1), (int) (z), dimx, dimy) ]*(1-alpha)*beta*(1-gamma) + + gvf [ I( (int) (x+1), (int) (y), (int) (z), dimx, dimy) ]*alpha*(1-beta)*(1-gamma) + + gvf [ I( (int) (x+1), (int) (y), (int) (z+1), dimx, dimy) ]*alpha*(1-beta)*gamma + + gvf [ I( (int) (x+1), (int) (y+1), (int) (z), dimx, dimy) ]*alpha*beta*(1-gamma) + + gvf [ I( (int) (x), (int) (y+1), (int) (z+1), dimx, dimy) ]*(1-alpha)*beta*gamma + + gvf [ I( (int) (x+1), (int) (y+1), (int) (z+1), dimx, dimy) ]*(alpha*beta*gamma)); +} + + + + + + + + + + +int isBoundary ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c; + + c = k - 1; b = j; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k + 1; b = j; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j - 1; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j + 1; a = i; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j; a = i - 1; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + c = k; b = j; a = i + 1; + if ( in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND ) return P3D_TRUE; + + return P3D_FALSE; +} + +int isFullNeighborhood ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c; + + // Neighbors touched by interpolation: + c = k + 1; b = j; a = i; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k; b = j + 1; a = i; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k; b = j; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k + 1; b = j + 1; a = i; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k; b = j + 1; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k + 1; b = j; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + c = k + 1; b = j + 1; a = i + 1; + if ( (in_im[ I(a,b,c,dimx,dimy) ] == BACKGROUND) || + (isBoundary( in_im, dimx, dimy, dimz, a, b, c ) == P3D_TRUE) ) return P3D_FALSE; + + + // No BACKGROUND voxel found: + return P3D_TRUE; +} + + +int p3dSpecialPadding3D_uchar2uchar ( + unsigned char* in_rev, + unsigned char* out_rev, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int size + ) +{ + int a_dimx, a_dimy, a_dimz; + int i,j,k; + + + // Compute dimensions of padded REV: + a_dimx = dimx + size*2; + a_dimy = dimy + size*2; + a_dimz = dimz + size*2; + + + // Set to zero all values: + memset( out_rev, 0, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + + + // Copy original (internal) values converting 255 to 1: + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) + if ( in_rev[ I( i, j, k, dimx, dimy ) ] == OBJECT ) + out_rev[ I( i + size, j + size, k + size, a_dimx, a_dimy ) ] = 1; + + + + // Replicate border values: + + // Faces: + /*for (i = size; i < (a_dimx - size); i++) + for (j = size; j < (a_dimy - size); j++) + { + out_rev[ I( i, j, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, j, size, a_dimx, a_dimy ) ]; + out_rev[ I( i, j, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( i, j, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + } + + for (j = size; j < (a_dimy - size); j++) + for (k = size; k < (a_dimz - size); k++) + { + out_rev[ I( size - 1, j, k, a_dimx, a_dimy) ] = + out_rev[ I( size, j, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, j, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, j, k, a_dimx, a_dimy ) ]; + } + + for (i = size; i < (a_dimx - size); i++) + for (k = size; k < (a_dimz - size); k++) + { + out_rev[ I( i, size - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( i, size, k, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - size, k, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - size, k, a_dimx, a_dimy ) ]; + } + + // Edges: + + for (i = size; i < (a_dimx - size); i++) + { + out_rev[ I( i, size - 1, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, size, size, a_dimx, a_dimy ) ]; + out_rev[ I( i, size - 1, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( i, size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - size, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( i, a_dimy - 1 - size, size, a_dimx, a_dimy ) ]; + out_rev[ I( i, a_dimy - size, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( i, a_dimy - 1 - size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + } + + for (j = size; j < (a_dimy - size); j++) + { + out_rev[ I( size - 1, j, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( size, j, size, a_dimx, a_dimy ) ]; + out_rev[ I( size - 1, j, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( size, j, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, j, size - 1, a_dimx, a_dimy) ] = + out_rev[ I( a_dimx - 1 - size, j, size, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, j, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, j, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + } + + for (k = size; k < (a_dimz - size); k++) + { + out_rev[ I( size - 1, size - 1, k, a_dimx, a_dimy) ] = + out_rev[ I( size, size, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, size - 1, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, size, k, a_dimx, a_dimy ) ]; + out_rev[ I( size - 1, a_dimy - size, k, a_dimx, a_dimy) ] = + out_rev[ I( size, a_dimy - 1 - size, k, a_dimx, a_dimy ) ]; + out_rev[ I( a_dimx - size, a_dimy - size, k, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, a_dimy - 1 - size, k, a_dimx, a_dimy ) ]; + } + + // Corners: + + out_rev[ I( size - 1, size - 1, size - 1, a_dimx, a_dimy)] = + out_rev[ I( size, size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - size, size - 1, size - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( size - 1, a_dimy - size, size - 1, a_dimx, a_dimy)] = + out_rev[ I( size, a_dimy - 1 - size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( size - 1, size - 1, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( size, size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + + + out_rev[ I( a_dimx - size, a_dimy - size, size - 1, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, a_dimy - 1 - size, size, a_dimx, a_dimy ) ]; + + out_rev[ I( size - 1, a_dimy - size, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( size, a_dimy - 1 - size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - size, size - 1, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, size, a_dimz - 1 - size, a_dimx, a_dimy ) ]; + + out_rev[ I( a_dimx - size, a_dimy - size, a_dimz - size, a_dimx, a_dimy)] = + out_rev[ I( a_dimx - 1 - size, a_dimy - 1 - size, a_dimz - 1 - size, a_dimx, a_dimy ) ];*/ + + + // Return OK: + return P3D_SUCCESS; +} diff --git a/pypore3d/pypore3d/P3D_Skel/Common/p3dUtils.h b/pypore3d/pypore3d/P3D_Skel/Common/p3dUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..cc4a70a4a503e62b20b83f124ac489862804eceb --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/Common/p3dUtils.h @@ -0,0 +1,243 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <limits.h> + +#include "p3dCoordsList.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* + Constants: +*/ +#ifndef P3D_SKEL_DEFINED + #define P3D_SKEL_DEFINED + + #define P3D_FALSE -1 + #define P3D_TRUE 1 + + #define P3D_ERROR 0 + #define P3D_MEM_ERROR NULL /* Leave it NULL for simplify tests */ + #define P3D_SUCCESS 2 /* Any number */ + + #define BACKGROUND 0 + #define OBJECT UCHAR_MAX + +#endif + +#ifndef P3D_GVF_DEFINED + #define P3D_GVF_DEFINED + + // Constants for 3D connectivity: + #define CONN6 711 + #define CONN18 712 + #define CONN26 713 + + // Constants for GVF Skeletonization - critical point classification: + #define CPT_SADDLE 200 + #define CPT_ATTRACTING_NODE 225 + #define CPT_REPELLING_NODE 250 + + // This is the size of the step used to advance to the next position + // when following the vector field (0.2 seems to be the best value + // and it should be multiplied for the scale factor in case of down- + // sampling): + #define STEP_SIZE 0.2 + + // This is the distance used to check if current point is close to a + // skeleton point or a critical point (0.2 seems to be the best value + // and it should be multiplied for the scale factor in case of down- + // sampling): + #define CLOSENESS 0.2 + + #define MIN_LENGTH 2.0 + +#endif + +/* + Macros: +*/ + +#ifndef P3D_GVF_MACROS + #define P3D_GVF_MACROS + + #define EPSILON 1E-3 /* Do not modify: 1E-3 is fair */ + #define EQUAL(n1, n2) (IS_ZERO((n1) - (n2))) + #define IS_ZERO(n) (((n) < EPSILON) && ((n) > -EPSILON)) + + #define SIGN(n) (IS_ZERO(n) ? 0 : ((n) < 0.00 ? -1 : 1)) + +#endif + +#ifndef P3D_SKEL_MACROS + #define P3D_SKEL_MACROS + + #define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) + #define MIN(x,y) (((x) < (y))?(x):(y)) + #define MAX(x,y) (((x) > (y))?(x):(y)) + + /* A sort of TRY-CATCH constructor: */ + #define P3D_MEM_TRY( function ) if ( (function) == P3D_MEM_ERROR) { goto MEM_ERROR; } + #define P3D_TRY( function ) if ( (function) == P3D_ERROR) { goto MEM_ERROR; } + + +#endif + +/* + Functions: +*/ +int findNeighbor ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + coords_t* coords + ); + +int countNeighbors ( + unsigned char* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ); + + +int isSimplePoint( + unsigned char* im, // IN: Input (binary) original volume + const int dimx, + const int dimy, + const int dimz, + const int x, + const int y, + const int z + ); + +int p3dCrop3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dCrop3D_ushort2ushort ( + unsigned short* in_im, + unsigned short* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dCrop3D_float2float ( + float* in_im, + float* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dZeroPadding3D_uchar2float ( + unsigned char* in_im, + float* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + + +int p3dZeroPadding3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +int p3dReplicatePadding3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +double interpolation ( + float* gvf, + int dimx, + int dimy, + int dimz, + const double x, + const double y, + const double z + ); + +int isBoundary ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ); + +int isFullNeighborhood ( + unsigned char* in_im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ); + +int p3dSpecialPadding3D_uchar2uchar ( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + const int size + ); + +#ifdef __cplusplus + } +#endif \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/_p3dComputeCoreSkeleton.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/_p3dComputeCoreSkeleton.c new file mode 100644 index 0000000000000000000000000000000000000000..cf22f5d2ecdb5cc289e62deb5ae7ef3edb779bb9 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/_p3dComputeCoreSkeleton.c @@ -0,0 +1,310 @@ +#include <math.h> +#include <string.h> + +#include "p3dComputeCoreSkeleton.h" + +#include "../Common/p3dCoordsT.h" +#include "../Common/p3dUtils.h" + +// +// Procedures +// + +int stabilityReached(fcoords_list_t segm_list, fcoords_t pt) { + fcoords_list_t tmp_list; + fcoords_t tmp_elem; + + // Scan list: + tmp_list = segm_list; + + // If input point is already present into the current skeleton segment probably we are + // chasing our own tail: + while (fcoords_list_isempty(tmp_list) == P3D_FALSE) { + // Get current element: + tmp_elem = tmp_list->elem; + + if (EQUAL(tmp_elem.x, pt.x) && + EQUAL(tmp_elem.y, pt.y) && + EQUAL(tmp_elem.z, pt.z)) + return P3D_TRUE; + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + +int skelPointReached( + fcoords_list_t* skel_point_list, + fcoords_t curr_crit_point, + fcoords_t pt, + const double close_dist + ) { + fcoords_list_t tmp_list; + fcoords_t tmp_point; + double a, b, c; + + + // Print critical points: + tmp_list = (*skel_point_list); + + // Scan list: + while (fcoords_list_isempty(tmp_list) == P3D_FALSE) { + // Get current element: + tmp_point = tmp_list->elem; + + // Skip current critical point (it would be better to test an ID...): + if (!(EQUAL(curr_crit_point.x, pt.x) && + EQUAL(curr_crit_point.y, pt.y) && + EQUAL(curr_crit_point.z, pt.z))) { + a = fabs(pt.x - tmp_point.x); + b = a + fabs(pt.y - tmp_point.y); + c = a + b + fabs(pt.z - tmp_point.z); + + if ((a < close_dist) && (b < close_dist) && (c < close_dist)) + return P3D_TRUE; + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + +int critPointReached( + crit_point_list_t crit_point_list, + fcoords_t curr_crit_point, + fcoords_t pt, + const double close_dist + ) { + crit_point_list_t tmp_list; + crit_point_t crit_point; + double a, b, c; + + // Print critical points: + tmp_list = crit_point_list; + + // Scan list: + while (crit_point_list_isempty(tmp_list) == P3D_FALSE) { + // Get current element: + crit_point = tmp_list->elem; + + // Skip current critical point (it would be better to test an ID...): + if (!(EQUAL(curr_crit_point.x, crit_point.x) && + EQUAL(curr_crit_point.y, crit_point.y) && + EQUAL(curr_crit_point.z, crit_point.z))) { + a = fabs(pt.x - crit_point.x); + b = a + fabs(pt.y - crit_point.y); + c = a + b + fabs(pt.z - crit_point.z); + + if ((a < close_dist) && (b < close_dist) && (c < close_dist)) + return P3D_TRUE; + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + +int followStreams( + fcoords_list_t* skel_point_list, + crit_point_list_t crit_point_list, + fcoords_t crit_point, + fcoords_t verse, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ) { + double out_x, out_y, out_z; + double len; + + fcoords_t fpoint1, fpoint2; + + fcoords_list_t tmp_list; + + + // Init list: + fcoords_list_init(&tmp_list); + + // Initialize starting point and put it into the temporary list for current segment: + fpoint1.x = crit_point.x; + fpoint1.y = crit_point.y; + fpoint1.z = crit_point.z; + + P3D_TRY(fcoords_list_push(&tmp_list, fpoint1)); + + // Initialize next point and put it into the temporary list for current segment: + fpoint2.x = crit_point.x + verse.x*step; + fpoint2.y = crit_point.y + verse.y*step; + fpoint2.z = crit_point.z + verse.z*step; + + + // Start following path until exit conditions: + // i. Critical point reached + // ii. Skeleton point reached + // iii. Stability reached (safety condition) + do { + + // Set current point and put it into list: + fpoint1.x = fpoint2.x; + fpoint1.y = fpoint2.y; + fpoint1.z = fpoint2.z; + + P3D_TRY(fcoords_list_push(&tmp_list, fpoint1)); + + // Interpolate gradient vector flow: + out_x = interpolation(gvf_x, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z); + out_y = interpolation(gvf_y, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z); + out_z = interpolation(gvf_z, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z); + + // Normalize: + len = sqrt((out_x * out_x) + (out_y * out_y) + (out_z * out_z)); + + if (len > 0.00) { + out_x = out_x / len; + out_y = out_y / len; + out_z = out_z / len; + } + + // Increment path following: + fpoint2.x = fpoint1.x + out_x*step; + fpoint2.y = fpoint1.y + out_y*step; + fpoint2.z = fpoint1.z + out_z*step; + } while ((skelPointReached(skel_point_list, crit_point, fpoint2, close_dist) == P3D_FALSE) && + (critPointReached(crit_point_list, crit_point, fpoint2, close_dist) == P3D_FALSE) && + (stabilityReached(tmp_list, fpoint2) == P3D_FALSE)); + + // Current segment is added to skeleton: + while (fcoords_list_isempty(tmp_list) == P3D_FALSE) { + P3D_TRY(fcoords_list_push(skel_point_list, fcoords_list_pop(&tmp_list))); + } + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources of temporary list: + while (fcoords_list_isempty(tmp_list) == P3D_FALSE) { + fcoords_list_pop(&tmp_list); + } + + return P3D_MEM_ERROR; +} + +int p3dComputeCoreSkeleton( + crit_point_list_t crit_point_list, + fcoords_list_t* skel_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ) { + crit_point_list_t tmp_list; + crit_point_t crit_point; + + fcoords_t verse; + fcoords_t point; + + // + // Following the streamlines starting at a saddle point in the direction of the + // positive eigenvector(s): + // + tmp_list = crit_point_list; + + // Scan list: + while (crit_point_list_isempty(tmp_list) == P3D_FALSE) { + // Get current critical point: + crit_point = tmp_list->elem; + + // If current critical point is a saddle point: + if (crit_point.type == CPT_SADDLE) { + + point.x = crit_point.x; + point.y = crit_point.y; + point.z = crit_point.z; + + // Get the direction pointed by the positive first eigenvector: + if (crit_point.eval0 > 0) { + + // UP direction given by the eigenvector: + verse.x = crit_point.evect0_x; + verse.y = crit_point.evect0_y; + verse.z = crit_point.evect0_z; + + P3D_TRY(followStreams(skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist)); + + // DOWN direction of the eigenvector: + verse.x = -crit_point.evect0_x; + verse.y = -crit_point.evect0_y; + verse.z = -crit_point.evect0_z; + + P3D_TRY(followStreams(skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist)); + } + + // Get the direction pointed by the positive second eigenvector: + if (crit_point.eval1 > 0) { + // UP direction given by the eigenvector: + verse.x = crit_point.evect1_x; + verse.y = crit_point.evect1_y; + verse.z = crit_point.evect1_z; + + P3D_TRY(followStreams(skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist)); + + // DOWN direction of the eigenvector: + verse.x = -crit_point.evect1_x; + verse.y = -crit_point.evect1_y; + verse.z = -crit_point.evect1_z; + + P3D_TRY(followStreams(skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist)); + } + + // Get the direction pointed by the positive third eigenvector: + if (crit_point.eval2 > 0) { + // UP direction given by the eigenvector: + verse.x = crit_point.evect2_x; + verse.y = crit_point.evect2_y; + verse.z = crit_point.evect2_z; + + P3D_TRY(followStreams(skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist)); + + // DOWN direction of the eigenvector: + verse.x = -crit_point.evect2_x; + verse.y = -crit_point.evect2_y; + verse.z = -crit_point.evect2_z; + + P3D_TRY(followStreams(skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist)); + } + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + return P3D_MEM_ERROR; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.c new file mode 100644 index 0000000000000000000000000000000000000000..857a10b488d06df5a25a2656110e8df6a41ddc7a --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.c @@ -0,0 +1,358 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <math.h> +#include <string.h> + +#include "p3dComputeCoreSkeleton.h" + +#include "../Common/p3dCoordsT.h" +#include "../Common/p3dUtils.h" + +// +// Procedures +// + +int stabilityReached ( fcoords_list_t segm_list, fcoords_t pt ) +{ + fcoords_list_t tmp_list; + fcoords_t tmp_elem; + + // Scan list: + tmp_list = segm_list; + + // If input point is already present into the current skeleton segment probably we are + // chasing our own tail: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + tmp_elem = tmp_list->elem; + + if ( EQUAL( tmp_elem.x, pt.x) && + EQUAL( tmp_elem.y, pt.y) && + EQUAL( tmp_elem.z, pt.z) ) + return P3D_TRUE; + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + + +int skelPointReached ( + fcoords_list_t* skel_point_list, + fcoords_t curr_crit_point, + fcoords_t pt, + const double close_dist + ) +{ + fcoords_list_t tmp_list; + fcoords_t tmp_point; + double a, b, c; + + + // Print critical points: + tmp_list = (*skel_point_list); + + // Scan list: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + tmp_point = tmp_list->elem; + + // Skip current critical point (it would be better to test an ID...): + if (!( EQUAL( curr_crit_point.x, pt.x) && + EQUAL( curr_crit_point.y, pt.y) && + EQUAL( curr_crit_point.z, pt.z) )) + { + a = fabs( pt.x - tmp_point.x ); + b = a + fabs( pt.y - tmp_point.y ); + c = a + b + fabs( pt.z - tmp_point.z ); + + if( (a < close_dist ) && ( b < close_dist ) && ( c < close_dist ) ) + return P3D_TRUE; + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + + +int critPointReached ( + crit_point_list_t crit_point_list, + fcoords_t curr_crit_point, + fcoords_t pt, + const double close_dist + ) +{ + crit_point_list_t tmp_list; + crit_point_t crit_point; + double a, b, c; + + // Print critical points: + tmp_list = crit_point_list; + + // Scan list: + while ( crit_point_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + crit_point = tmp_list->elem; + + // Skip current critical point (it would be better to test an ID...): + if (!( EQUAL( curr_crit_point.x, crit_point.x) && + EQUAL( curr_crit_point.y, crit_point.y) && + EQUAL( curr_crit_point.z, crit_point.z) )) + { + a = fabs( pt.x - crit_point.x ); + b = a + fabs( pt.y - crit_point.y ); + c = a + b + fabs( pt.z - crit_point.z ); + + if( (a < close_dist ) && ( b < close_dist ) && ( c < close_dist ) ) + return P3D_TRUE; + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + +int followStreams ( + fcoords_list_t* skel_point_list, + crit_point_list_t crit_point_list, + fcoords_t crit_point, + fcoords_t verse, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ) +{ + double out_x, out_y, out_z; + double len; + + fcoords_t fpoint1, fpoint2; + + fcoords_list_t tmp_list; + + + // Init list: + fcoords_list_init ( &tmp_list ); + + // Initialize starting point and put it into the temporary list for current segment: + fpoint1.x = crit_point.x; + fpoint1.y = crit_point.y; + fpoint1.z = crit_point.z; + + P3D_TRY ( fcoords_list_push( &tmp_list, fpoint1 ) ); + + // Initialize next point and put it into the temporary list for current segment: + fpoint2.x = crit_point.x + verse.x*step; + fpoint2.y = crit_point.y + verse.y*step; + fpoint2.z = crit_point.z + verse.z*step; + + + // Start following path until exit conditions: + // i. Critical point reached + // ii. Skeleton point reached + // iii. Stability reached (safety condition) + do { + + // Set current point and put it into list: + fpoint1.x = fpoint2.x; + fpoint1.y = fpoint2.y; + fpoint1.z = fpoint2.z; + + P3D_TRY ( fcoords_list_push( &tmp_list, fpoint1 ) ); + + // Interpolate gradient vector flow: + out_x = interpolation ( gvf_x, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z ); + out_y = interpolation ( gvf_y, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z ); + out_z = interpolation ( gvf_z, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z ); + + // Normalize: + len = sqrt((out_x * out_x) + (out_y * out_y) + (out_z * out_z)); + + if(len > 0.00) { + out_x = out_x / len; + out_y = out_y / len; + out_z = out_z / len; + } + + // Increment path following: + fpoint2.x = fpoint1.x + out_x*step; + fpoint2.y = fpoint1.y + out_y*step; + fpoint2.z = fpoint1.z + out_z*step; + } + while ( ( skelPointReached( skel_point_list, crit_point, fpoint2, close_dist ) == P3D_FALSE ) && + ( critPointReached( crit_point_list, crit_point, fpoint2, close_dist ) == P3D_FALSE ) && + ( stabilityReached( tmp_list, fpoint2 ) == P3D_FALSE ) ); + + // Current segment is added to skeleton: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + P3D_TRY ( fcoords_list_push( skel_point_list, fcoords_list_pop( &tmp_list ))); + } + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources of temporary list: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + fcoords_list_pop( &tmp_list ); + } + + return P3D_ERROR; +} + + +int p3dComputeCoreSkeleton ( + crit_point_list_t crit_point_list, + fcoords_list_t* skel_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ) +{ + crit_point_list_t tmp_list; + crit_point_t crit_point; + + fcoords_t verse; + fcoords_t point; + + // + // Following the streamlines starting at a saddle point in the direction of the + // positive eigenvector(s): + // + tmp_list = crit_point_list; + + // Scan list: + while ( crit_point_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current critical point: + crit_point = tmp_list->elem; + + // If current critical point is a saddle point: + if ( crit_point.type == CPT_SADDLE ) + { + + point.x = crit_point.x; + point.y = crit_point.y; + point.z = crit_point.z; + + // Get the direction pointed by the positive first eigenvector: + if( crit_point.eval0 > 0 ) + { + + // UP direction given by the eigenvector: + verse.x = crit_point.evect0_x; + verse.y = crit_point.evect0_y; + verse.z = crit_point.evect0_z; + + P3D_TRY ( followStreams ( skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist ) ); + + // DOWN direction of the eigenvector: + verse.x = - crit_point.evect0_x; + verse.y = - crit_point.evect0_y; + verse.z = - crit_point.evect0_z; + + P3D_TRY ( followStreams ( skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist ) ); + } + + // Get the direction pointed by the positive second eigenvector: + if( crit_point.eval1 > 0 ) + { + // UP direction given by the eigenvector: + verse.x = crit_point.evect1_x; + verse.y = crit_point.evect1_y; + verse.z = crit_point.evect1_z; + + P3D_TRY ( followStreams ( skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist )); + + // DOWN direction of the eigenvector: + verse.x = - crit_point.evect1_x; + verse.y = - crit_point.evect1_y; + verse.z = - crit_point.evect1_z; + + P3D_TRY ( followStreams ( skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist )); + } + + // Get the direction pointed by the positive third eigenvector: + if( crit_point.eval2 > 0 ) + { + // UP direction given by the eigenvector: + verse.x = crit_point.evect2_x; + verse.y = crit_point.evect2_y; + verse.z = crit_point.evect2_z; + + P3D_TRY ( followStreams ( skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist )); + + // DOWN direction of the eigenvector: + verse.x = - crit_point.evect2_x; + verse.y = - crit_point.evect2_y; + verse.z = - crit_point.evect2_z; + + P3D_TRY ( followStreams ( skel_point_list, crit_point_list, point, verse, gvf_x, gvf_y, + gvf_z, dimx, dimy, dimz, step, close_dist )); + } + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + return P3D_ERROR; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.h new file mode 100644 index 0000000000000000000000000000000000000000..1d92ae298483bfb38ec50d1b6dec0631e3c18415 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.h @@ -0,0 +1,43 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dCritPointList.h" + +#include "../Common/p3dFCoordsList.h" + +int p3dComputeCoreSkeleton ( + crit_point_list_t crit_point_list, + fcoords_list_t* skel_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.c new file mode 100644 index 0000000000000000000000000000000000000000..7f64b4181d2d671bde8296674b4856edca8e3757 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.c @@ -0,0 +1,1129 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <string.h> +#include <omp.h> +#include <math.h> +#include <float.h> + +#include "p3dComputeEigenVal.h" + +#define MAX_ITERATION 100 + +void Identity_Matrix(double *A, int n) +{ + int i,j; + + for (i = 0; i < n - 1; i++) { + *A++ = 1.0; + for (j = 0; j < n; j++) *A++ = 0.0; + } + *A = 1.0; +} + +void Row_Transformation(double *A, double x, int row1, int row2, int ncols) +{ + int i; + double *pA1, *pA2; + + if (row1 != row2) { + pA1 = A + row1 * ncols; + pA2 = A + row2 * ncols; + for (i = 0; i < ncols; i++) *pA2++ += x * *pA1++; + } + else { + pA1 = A + row1 * ncols; + for (i = 0; i < ncols; i++) *pA1++ += x * *pA1; + } +} + +void Column_Transformation(double *A, double x, int col1, int col2, + int nrows, int ncols) +{ + int i; + double *pA1, *pA2; + + if (col1 != col2) { + pA1 = A + col1; + pA2 = A + col2; + for (i = 0; i < nrows; pA1 += ncols, pA2 += ncols, i++) *pA2 += x * *pA1; + } + else { + pA1 = A + col1; + for (i = 0; i < nrows; pA1 += ncols, i++) *pA1 += x * *pA1; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// int Hessenberg_Form_Orthogonal(double *A, double *U, int n) // +// // +// Description: // +// This program transforms the square matrix A to a similar matrix in // +// Hessenberg form by a multiplying A on the right and left by a sequence // +// of Householder transformations. // +// Def: Two matrices A and B are said to be orthogonally similar if there// +// exists an orthogonal matrix U such that A U = U B. // +// Def A Hessenberg matrix is the sum of an upper triangular matrix and // +// a matrix all of whose components are 0 except possibly on its // +// subdiagonal. A Hessenberg matrix is sometimes said to be almost // +// upper triangular. // +// Def: A Householder transformation is an orthogonal transformation of // +// the form Q = I - 2 uu'/u'u, where u is a n x 1 column matrix and // +// ' denotes the transpose. // +// Thm: If Q is a Householder transformation then Q' = Q and Q' Q = I, // +// i.e. Q is a symmetric involution. // +// The algorithm proceeds by successivly selecting columns j = 0,...,n-3 // +// and then calculating the Householder transformation Q which annihilates// +// the components below the subdiagonal for that column and leaves the // +// previously selected columns invariant. The algorithm then updates // +// the matrix A, in place, by premultiplication by Q followed by // +// postmultiplication by Q. // +// If the j-th column of A is (a[0],...,a[n-1]), then choose u' = // +// (u[0],...,u[n-1]) by u[0] = 0, ... , u[j] = 0, u[j+2] = a[j+2],..., // +// u[n-1] = a[n-1]. The remaining component u[j+1] = a[j+1] - s, where // +// s^2 = a[j+1]^2 + ... + a[n-1]^2, and the choice of sign for s, // +// sign(s) = -sign(a[j+1]) maximizes the number of significant bits for // +// u[j+1]. // +// // +// Remark: If H = U' A U, where U is orthogonal, and if v is an eigen- // +// vector of H with eigenvalue x, then A U v = U H v = x U v, so that // +// U v is an eigenvector of A with corresponding eigenvalue x. // +// // +// Arguments: // +// double *A Pointer to the first element of the matrix A[n][n]. // +// The original matrix A is replaced with the orthogonally // +// similar matrix in Hessenberg form. // +// double *U Pointer to the first element of the matrix U[n][n]. The // +// orthogonal matrix which transforms the input matrix to // +// an orthogonally similar matrix in Hessenberg form. // +// int n The number of rows or columns of the matrix A. // +// // +// Return Values: // +// 0 Success // +// -1 Failure - Unable to allocate space for working storage. // +// // +// Example: // +// #define N // +// double A[N][N], U[N][N]; // +// // +// (your code to create the matrix A) // +// Hessenberg_Form_Orthogonal(&A[0][0], (double*) U, N); // +// // +//////////////////////////////////////////////////////////////////////////////// +// // +int Hessenberg_Form_Orthogonal(double *A, double *U, int n) +{ + int i, k, col; + double *u; + + double *p_row, *psubdiag; + double *pA, *pU; + double sss; // signed sqrt of sum of squares + double scale; + double innerproduct; + + // n x n matrices for which n <= 2 are already in Hessenberg form + + if (n <= 2) return 0; + + // Reserve auxillary storage, if unavailable, return an error + + u = (double *) malloc(n * sizeof(double)); + if (u == NULL) return -1; + + // For each column use a Householder transformation + // to zero all entries below the subdiagonal. + + for (psubdiag = A + n, col = 0; col < (n - 2); psubdiag += (n+1), col++) { + + // Calculate the signed square root of the sum of squares of the + // elements below the diagonal. + + for (pA = psubdiag, sss = 0.0, i = col + 1; i < n; pA += n, i++) + sss += *pA * *pA; + if (sss == 0.0) continue; + sss = sqrt(sss); + if ( *psubdiag >= 0.0 ) sss = -sss; + + // Calculate the Householder transformation Q = I - 2uu'/u'u. + + u[col + 1] = *psubdiag - sss; + *psubdiag = sss; + for (pA = psubdiag + n, i = col + 2; i < n; pA += n, i++) { + u[i] = *pA; + *pA = 0.0; + } + + // Premultiply A by Q + + scale = -1.0 / (sss * u[col+1]); + for (p_row = psubdiag - col, i = col + 1; i < n; i++) { + pA = A + n * (col + 1) + i; + for (innerproduct = 0.0, k = col + 1; k < n; pA += n, k++) + innerproduct += u[k] * *pA; + innerproduct *= scale; + for (pA = p_row + i, k = col + 1; k < n; pA += n, k++) + *pA -= u[k] * innerproduct; + } + + // Postmultiply QA by Q + + for (p_row = A, i = 0; i < n; p_row += n, i++) { + for (innerproduct = 0.0, k = col + 1; k < n; k++) + innerproduct += u[k] * *(p_row + k); + innerproduct *= scale; + for (k = col + 1; k < n; k++) + *(p_row + k) -= u[k] * innerproduct; + } + + // Postmultiply U by (I - 2uu') + + for (i = 0, pU = U; i < n; pU += n, i++) { + for (innerproduct = 0.0, k = col + 1; k < n; k++) + innerproduct += u[k] * *(pU + k); + innerproduct *= scale; + for (k = col + 1; k < n; k++) + *(pU + k) -= u[k] * innerproduct; + } + + } + + free(u); + + return 0; +} + + + + + +//////////////////////////////////////////////////////////////////////////////// +// static void One_Real_Eigenvalue( double Hrow[], double eigen_real[], // +// double eigen_imag[], int row, double shift) // +// // +// Arguments: // +// double Hrow[] // +// Pointer to the row "row" of the matrix in Hessenberg form. // +// double eigen_real[] // +// Array of the real parts of the eigenvalues. // +// double eigen_imag[] // +// Array of the imaginary parts of the eigenvalues. // +// int row // +// The row to which the pointer Hrow[] points of the matrix H. // +// double shift // +// The cumulative exceptional shift of the diagonal elements of // +// the matrix H. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void One_Real_Eigenvalue(double Hrow[], double eigen_real[], + double eigen_imag[], int row, double shift) +{ + Hrow[row] += shift; + eigen_real[row] = Hrow[row]; + eigen_imag[row] = 0.0; +} + + +//////////////////////////////////////////////////////////////////////////////// +// static void Update_Row(double *Hrow, double cos, double sin, int n, // +// int row) // +// // +// Description: // +// Update rows 'row' and 'row + 1' using the rotation matrix: // +// | cos sin | // +// |-sin cos |. // +// I.e. multiply the matrix H on the left by the identity matrix with // +// the 2x2 diagonal block starting at row 'row' replaced by the above // +// 2x2 rotation matrix. // +// // +// Arguments: // +// double Hrow[] // +// Pointer to the row "row" of the matrix in Hessenberg form. // +// double cos // +// Cosine of the rotation angle. // +// double sin // +// Sine of the rotation angle. // +// int n // +// The dimension of the matrix H. // +// int row // +// The row to which the pointer Hrow[] points of the matrix H // +// in Hessenberg form. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Update_Row(double *Hrow, double cos, double sin, int n, int row) +{ + double x; + double *Hnextrow = Hrow + n; + int i; + + for (i = row; i < n; i++) { + x = Hrow[i]; + Hrow[i] = cos * x + sin * Hnextrow[i]; + Hnextrow[i] = cos * Hnextrow[i] - sin * x; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// static void Update_Column(double* H, double cos, double sin, int n, // +// int col) // +// // +// Description: // +// Update columns 'col' and 'col + 1' using the rotation matrix: // +// | cos -sin | // +// | sin cos |. // +// I.e. multiply the matrix H on the right by the identity matrix with // +// the 2x2 diagonal block starting at row 'col' replaced by the above // +// 2x2 rotation matrix. // +// // +// Arguments: // +// double *H // +// Pointer to the matrix in Hessenberg form. // +// double cos // +// Cosine of the rotation angle. // +// double sin // +// Sine of the rotation angle. // +// int n // +// The dimension of the matrix H. // +// int col // +// The left-most column of the matrix H to update. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Update_Column(double* H, double cos, double sin, int n, int col) +{ + double x; + int i; + int next_col = col + 1; + + for (i = 0; i <= next_col; i++, H += n) { + x = H[col]; + H[col] = cos * x + sin * H[next_col]; + H[next_col] = cos * H[next_col] - sin * x; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// static void Update_Transformation(double *S, double cos, double sin, // +// int n, int k) // +// // +// Description: // +// Update columns 'k' and 'k + 1' using the rotation matrix: // +// | cos -sin | // +// | sin cos |. // +// I.e. multiply the matrix S on the right by the identity matrix with // +// the 2x2 diagonal block starting at row 'k' replaced by the above // +// 2x2 rotation matrix. // +// // +// Arguments: // +// double *S // +// Pointer to the row "row" of the matrix in Hessenberg form. // +// double cos // +// Pointer to the first element of the matrix in Hessenberg form. // +// double sin // +// Pointer to the first element of the transformation matrix. // +// int n // +// The dimensions of the matrix H and S. // +// int k // +// The row to which the pointer Hrow[] points of the matrix H. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Update_Transformation(double *S, double cos, double sin, + int n, int k) +{ + double x; + int i; + int k1 = k + 1; + + for (i = 0; i < n; i++, S += n) { + x = S[k]; + S[k] = cos * x + sin * S[k1]; + S[k1] = cos * S[k1] - sin * x; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// static void Two_Eigenvalues( double *H, double *S, double eigen_real[], // +// double eigen_imag[], int n, int row, double shift) // +// // +// Description: // +// Given the 2x2 matrix A = (a[i][j]), the characteristic equation is: // +// x^2 - Tr(A) x + Det(A) = 0, where Tr(A) = a[0][0] + a[1][1] and // +// Det(A) = a[0][0] * a[1][1] - a[0][1] * a[1][0]. // +// The solution for the eigenvalues x are: // +// x1 = (Tr(A) + sqrt( (Tr(A))^2 + 4 * a[0][1] * a[1][0] ) / 2 and // +// x2 = (Tr(A) - sqrt( (Tr(A))^2 + 4 * a[0][1] * a[1][0] ) / 2. // +// Let p = (a[0][0] - a[1][1]) / 2 and q = p^2 - a[0][1] * a[1][0], then // +// x1 = a[1][1] + p [+|-] sqrt(q) and x2 = a[0][0] + a[1][1] - x1. // +// Choose the sign [+|-] to be the sign of p. // +// If q > 0.0, then both roots are real and the transformation // +// | cos sin | | a[0][0] a[0][1] | | cos -sin | // +// |-sin cos | | a[1][0] a[1][1] | | sin cos | // +// where sin = a[1][0] / r, cos = ( p + sqrt(q) ) / r, where r > 0 is // +// determined sin^2 + cos^2 = 1 transforms the matrix A to an upper // +// triangular matrix with x1 the upper diagonal element and x2 the lower.// +// If q < 0.0, then both roots form a complex conjugate pair. // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// double *S // +// Pointer to the first element of the transformation matrix. // +// double eigen_real[] // +// Array of the real parts of the eigenvalues. // +// double eigen_imag[] // +// Array of the imaginary parts of the eigenvalues. // +// int n // +// The dimensions of the matrix H and S. // +// int row // +// The upper most row of the block diagonal 2 x 2 submatrix of H. // +// double shift // +// The cumulative exceptional shift of the diagonal elements of // +// the matrix H. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Two_Eigenvalues(double *H, double* S, double eigen_real[], + double eigen_imag[], int n, int row, double shift) +{ + double p, q, x, discriminant, r; + double cos, sin; + double *Hrow = H + n * row; + double *Hnextrow = Hrow + n; + int nextrow = row + 1; + + p = 0.5 * (Hrow[row] - Hnextrow[nextrow]); + x = Hrow[nextrow] * Hnextrow[row]; + discriminant = p * p + x; + Hrow[row] += shift; + Hnextrow[nextrow] += shift; + if (discriminant > 0.0) { // pair of real roots + q = sqrt(discriminant); + if (p < 0.0) q = p - q; else q += p; + eigen_real[row] = Hnextrow[nextrow] + q; + eigen_real[nextrow] = Hnextrow[nextrow] - x / q; + eigen_imag[row] = 0.0; + eigen_imag[nextrow] = 0.0; + r = sqrt(Hnextrow[row]*Hnextrow[row] + q * q); + sin = Hnextrow[row] / r; + cos = q / r; + Update_Row(Hrow, cos, sin, n, row); + Update_Column(H, cos, sin, n, row); + Update_Transformation(S, cos, sin, n, row); + } + else { // pair of complex roots + eigen_real[nextrow] = eigen_real[row] = Hnextrow[nextrow] + p; + eigen_imag[row] = sqrt(fabs(discriminant)); + eigen_imag[nextrow] = -eigen_imag[row]; + } +} + + + + +//////////////////////////////////////////////////////////////////////////////// +// static void Product_and_Sum_of_Shifts(double *H, int n, int max_row, // +// double* shift, double *trace, double *det, int iteration) // +// // +// Description: // +// Calculate the trace and determinant of the 2x2 matrix: // +// | H[k-1][k-1] H[k-1][k] | // +// | H[k][k-1] H[k][k] | // +// unless iteration = 0 (mod 10) in which case increment the shift and // +// decrement the first k elements of the matrix H, then fudge the trace // +// and determinant by trace = 3/2( |H[k][k-1]| + |H[k-1][k-2]| and // +// det = 4/9 trace^2. // +// // +// Arguments: // +// double *H // +// Pointer to the matrix H in Hessenberg form. // +// int n // +// The dimension of the matrix H. // +// int max_row // +// The maximum row of the block 2 x 2 diagonal matrix used to // +// estimate the two eigenvalues for the two implicit shifts. // +// double *shift // +// The cumulative exceptional shift of the diagonal elements of // +// the matrix H. Modified if an exceptional shift occurs. // +// double *trace // +// Returns the trace of the 2 x 2 block diagonal matrix starting // +// at the row/column max_row-1. For an exceptional shift, the // +// trace is set as described above. // +// double *det // +// Returns the determinant of the 2 x 2 block diagonal matrix // +// starting at the row/column max_row-1. For an exceptional shift,// +// the determinant is set as described above. // +// int iteration // +// Current iteration count. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Product_and_Sum_of_Shifts(double *H, int n, int max_row, + double* shift, double *trace, double *det, int iteration) +{ + double *pH = H + max_row * n; + double *p_aux; + int i; + int min_col = max_row - 1; + + if ( ( iteration % 10 ) == 0 ) { + *shift += pH[max_row]; + for (i = 0, p_aux = H; i <= max_row; p_aux += n, i++) + p_aux[i] -= pH[max_row]; + p_aux = pH - n; + *trace = fabs(pH[min_col]) + fabs(p_aux[min_col - 1]); + *det = *trace * *trace; + *trace *= 1.5; + } + else { + p_aux = pH - n; + *trace = p_aux[min_col] + pH[max_row]; + *det = p_aux[min_col] * pH[max_row] - p_aux[max_row] * pH[min_col]; + } +}; + + +//////////////////////////////////////////////////////////////////////////////// +// static int Two_Consecutive_Small_Subdiagonal(double* H, int min_row, // +// int max_row, int n, double trace, double det) // +// // +// Description: // +// To reduce the amount of computation in Francis' double QR step search // +// for two consecutive small subdiagonal elements from row nn to row m, // +// where m < nn. // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// int min_row // +// The row in which to end the search (search is from upwards). // +// int max_row // +// The row in which to begin the search. // +// int n // +// The dimension of H. // +// double trace // +// The trace of the lower 2 x 2 block diagonal matrix. // +// double det // +// The determinant of the lower 2 x 2 block diagonal matrix. // +// // +// Return Value: // +// Row with negligible subdiagonal element or min_row if none found. // +//////////////////////////////////////////////////////////////////////////////// +// // +static int Two_Consecutive_Small_Subdiagonal(double* H, int min_row, + int max_row, int n, double trace, double det) +{ + double x, y ,z, s; + double* pH; + int i, k; + + for (k = max_row - 2, pH = H + k * n; k >= min_row; pH -= n, k--) { + x = (pH[k] * ( pH[k] - trace ) + det) / pH[n+k] + pH[k+1]; + y = pH[k] + pH[n+k+1] - trace; + z = pH[n + n + k + 1]; + s = fabs(x) + fabs(y) + fabs(z); + x /= s; + y /= s; + z /= s; + if (k == min_row) break; + if ( (fabs(pH[k-1]) * (fabs(y) + fabs(z)) ) <= + DBL_EPSILON * fabs(x) * + (fabs(pH[k-1-n]) + fabs(pH[k]) + fabs(pH[n + k + 1])) ) break; + } + for (i = k+2, pH = H + i * n; i <= max_row; pH += n, i++) pH[i-2] = 0.0; + for (i = k+3, pH = H + i * n; i <= max_row; pH += n, i++) pH[i-3] = 0.0; + return k; +}; + + +//////////////////////////////////////////////////////////////////////////////// +// static void Double_QR_Step(double *H, int min_row, int max_row, // +// int min_col, double *S, int n) // +// // +// Description: // +// Perform Francis' double QR step from rows 'min_row' to 'max_row' // +// and columns 'min_col' to 'max_row'. // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// int min_row // +// The row in which to begin. // +// int max_row // +// The row in which to end. // +// int min_col // +// The column in which to begin. // +// double trace // +// The trace of the lower 2 x 2 block diagonal matrix. // +// double det // +// The determinant of the lower 2 x 2 block diagonal matrix. // +// double *S // +// Pointer to the first element of the transformation matrix. // +// int n // +// The dimensions of H and S. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Double_QR_Step(double *H, int min_row, int max_row, int min_col, + double trace, double det, double *S, int n) +{ + double s, x, y, z; + double a, b, c; + double *pH; + double *tH; + double *pS; + int i,j,k; + int last_test_row_col = max_row - 1; + + k = min_col; + pH = H + min_col * n; + a = (pH[k] * ( pH[k] - trace ) + det) / pH[n+k] + pH[k+1]; + b = pH[k] + pH[n+k+1] - trace; + c = pH[n + n + k + 1]; + s = fabs(a) + fabs(b) + fabs(c); + a /= s; + b /= s; + c /= s; + + for (; k <= last_test_row_col; k++, pH += n) { + if ( k > min_col ) { + c = (k == last_test_row_col) ? 0.0 : pH[n + n + k - 1]; + x = fabs(pH[k-1]) + fabs(pH[n + k - 1]) + fabs(c); + if ( x == 0.0 ) continue; + a = pH[k - 1] / x; + b = pH[n + k - 1] / x; + c /= x; + } + s = sqrt( a * a + b * b + c * c ); + if (a < 0.0) s = -s; + if ( k > min_col ) pH[k-1] = -s * x; + else if (min_row != min_col) pH[k-1] = -pH[k-1]; + a += s; + x = a / s; + y = b / s; + z = c / s; + b /= a; + c /= a; + + // Update rows k, k+1, k+2 + for (j = k; j < n; j++) { + a = pH[j] + b * pH[n+j]; + if ( k != last_test_row_col ) { + a += c * pH[n + n + j]; + pH[n + n + j] -= a * z; + } + pH[n + j] -= a * y; + pH[j] -= a * x; + } + + // Update column k+1 + + j = k + 3; + if (j > max_row) j = max_row; + for (i = 0, tH = H; i <= j; i++, tH += n) { + a = x * tH[k] + y * tH[k+1]; + if ( k != last_test_row_col ) { + a += z * tH[k+2]; + tH[k+2] -= a * c; + } + tH[k+1] -= a * b; + tH[k] -= a; + } + + // Update transformation matrix + + for (i = 0, pS = S; i < n; pS += n, i++) { + a = x * pS[k] + y * pS[k+1]; + if ( k != last_test_row_col ) { + a += z * pS[k+2]; + pS[k+2] -= a * c; + } + pS[k+1] -= a * b; + pS[k] -= a; + } + }; +} + +//////////////////////////////////////////////////////////////////////////////// +// static void Double_QR_Iteration(double *H, double *S, int min_row, // +// int max_row, int n, double* shift, int iteration) // +// // +// Description: // +// Calculate the trace and determinant of the 2x2 matrix: // +// | H[k-1][k-1] H[k-1][k] | // +// | H[k][k-1] H[k][k] | // +// unless iteration = 0 (mod 10) in which case increment the shift and // +// decrement the first k elements of the matrix H, then fudge the trace // +// and determinant by trace = 3/2( |H[k][k-1]| + |H[k-1][k-2]| and // +// det = 4/9 trace^2. // +// // +// Arguments: // +// double *H // +// Pointer to the matrix H in Hessenberg form. // +// double *S // +// Pointer to the transformation matrix S. // +// int min_row // +// The top-most row in which the off-diagonal element of H is // +// negligible. If no such row exists, then min_row = 0. // +// int max_row // +// The maximum row of the block 2 x 2 diagonal matrix used to // +// estimate the two eigenvalues for the two implicit shifts. // +// int n // +// The dimensions of the matrix H and S. // +// double *shift // +// The cumulative exceptional shift of the diagonal elements of // +// the matrix H. // +// int iteration // +// Current iteration count. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Double_QR_Iteration(double *H, double *S, int min_row, int max_row, + int n, double* shift, int iteration) +{ + int k; + double trace, det; + + Product_and_Sum_of_Shifts(H, n, max_row, shift, &trace, &det, iteration); + k = Two_Consecutive_Small_Subdiagonal(H, min_row, max_row, n, trace, det); + Double_QR_Step(H, min_row, max_row, k, trace, det, S, n); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// static void BackSubstitute_Real_Vector(double *H, double eigen_real[], // +// double eigen_imag[], int row, double zero_tolerance, int n) // +// // +// Description: // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// double eigen_real[] // +// The real part of an eigenvalue. // +// double eigen_imag[] // +// The imaginary part of an eigenvalue. // +// int row // +// double zero_tolerance // +// Zero substitute. To avoid dividing by zero. // +// int n // +// The dimension of H, eigen_real, and eigen_imag. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void BackSubstitute_Real_Vector(double *H, double eigen_real[], + double eigen_imag[], int row, double zero_tolerance, int n) +{ + double *pH; + double *pV; + double x; + double u[4]; + double v[2]; + int i,j,k; + + k = row; + pH = H + row * n; + pH[row] = 1.0; + for (i = row - 1, pH -= n; i >= 0; i--, pH -= n) { + u[0] = pH[i] - eigen_real[row]; + v[0] = pH[row]; + pV = H + n * k; + for (j = k; j < row; j++, pV += n) v[0] += pH[j] * pV[row]; + if ( eigen_imag[i] < 0.0 ) { + u[3] = u[0]; + v[1] = v[0]; + } else { + k = i; + if (eigen_imag[i] == 0.0) { + if (u[0] != 0.0) pH[row] = - v[0] / u[0]; + else pH[row] = - v[0] / zero_tolerance; + } else { + u[1] = pH[i+1]; + u[2] = pH[n+i]; + x = (eigen_real[i] - eigen_real[row]); + x *= x; + x += eigen_imag[i] * eigen_imag[i]; + pH[row] = (u[1] * v[1] - u[3] * v[0]) / x; + if ( fabs(u[1]) > fabs(u[3]) ) + pH[n+row] = -(v[0] + u[0] * pH[row]) / u[1]; + else + pH[n+row] = -(v[1] + u[2] * pH[row]) / u[3]; + } + } + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +// static void Complex_Division(double x, double y, double u, double v, // +// double* a, double* b) // +// // +// Description: // +// a + i b = (x + iy) / (u + iv) // +// = (x * u + y * v) / r^2 + i (y * u - x * v) / r^2, // +// where r^2 = u^2 + v^2. // +// // +// Arguments: // +// double x // +// Real part of the numerator. // +// double y // +// Imaginary part of the numerator. // +// double u // +// Real part of the denominator. // +// double v // +// Imaginary part of the denominator. // +// double *a // +// Real part of the quotient. // +// double *b // +// Imaginary part of the quotient. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Complex_Division(double x, double y, double u, double v, + double* a, double* b) +{ + double q = u*u + v*v; + + *a = (x * u + y * v) / q; + *b = (y * u - x * v) / q; +} +// static void BackSubstitute_Complex_Vector(double *H, double eigen_real[], // +// double eigen_imag[], int row, double zero_tolerance, int n) // +// // +// Description: // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// double eigen_real[] // +// The real part of an eigenvalue. // +// double eigen_imag[] // +// The imaginary part of an eigenvalue. // +// int row // +// double zero_tolerance // +// Zero substitute. To avoid dividing by zero. // +// int n // +// The dimension of H, eigen_real, and eigen_imag. // +//////////////////////////////////////////////////////////////////////////////// +// +static void BackSubstitute_Complex_Vector(double *H, double eigen_real[], + double eigen_imag[], int row, double zero_tolerance, int n) +{ + double *pH; + double *pV; + double x,y; + double u[4]; + double v[2]; + double w[2]; + int i,j,k; + + k = row - 1; + pH = H + n * row; + if ( fabs(pH[k]) > fabs(pH[row-n]) ) { + pH[k-n] = - (pH[row] - eigen_real[row]) / pH[k]; + pH[row-n] = -eigen_imag[row] / pH[k]; + } + else + Complex_Division(-pH[row-n], 0.0, + pH[k-n]-eigen_real[row], eigen_imag[row], &pH[k-n], &pH[row-n]); + pH[k] = 1.0; + pH[row] = 0.0; + for (i = row - 2, pH = H + n * i; i >= 0; pH -= n, i--) { + u[0] = pH[i] - eigen_real[row]; + w[0] = pH[row]; + w[1] = 0.0; + pV = H + k * n; + for (j = k; j < row; j++, pV+=n) { + w[0] += pH[j] * pV[row - 1]; + w[1] += pH[j] * pV[row]; + } + if (eigen_imag[i] < 0.0) { + u[3] = u[0]; + v[0] = w[0]; + v[1] = w[1]; + } else { + k = i; + if (eigen_imag[i] == 0.0) { + Complex_Division(-w[0], -w[1], u[0], eigen_imag[row], &pH[row-1], + &pH[row]); + } + else { + u[1] = pH[i+1]; + u[2] = pH[n + i]; + x = eigen_real[i] - eigen_real[row]; + y = 2.0 * x * eigen_imag[row]; + x = x * x + eigen_imag[i] * eigen_imag[i] + - eigen_imag[row] * eigen_imag[row]; + if ( x == 0.0 && y == 0.0 ) + x = zero_tolerance * ( fabs(u[0]) + fabs(u[1]) + fabs(u[2]) + + fabs(u[3]) + fabs(eigen_imag[row]) ); + Complex_Division(u[1]*v[0] - u[3] * w[0] + w[1] * eigen_imag[row], + u[1] * v[1] - u[3] * w[1] - w[0] * eigen_imag[row], + x, y, &pH[row-1], &pH[row]); + if ( fabs(u[1]) > (fabs(u[3]) + fabs(eigen_imag[row])) ) { + pH[n+row-1] = -w[0] - u[0] * pH[row-1] + + eigen_imag[row] * pH[row] / u[1]; + pH[n+row] = -w[1] - u[0] * pH[row] + - eigen_imag[row] * pH[row-1] / u[1]; + } + else { + Complex_Division(-v[0] - u[2] * pH[row-1], -v[1] - u[2]*pH[row], + u[3], eigen_imag[row], &pH[n+row-1], &pH[n+row]); + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// static void BackSubstitution(double *H, double eigen_real[], // +// double eigen_imag[], int n) // +// // +// Description: // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// double eigen_real[] // +// The real part of an eigenvalue. // +// double eigen_imag[] // +// The imaginary part of an eigenvalue. // +// int n // +// The dimension of H, eigen_real, and eigen_imag. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void BackSubstitution(double *H, double eigen_real[], + double eigen_imag[], int n) +{ + double zero_tolerance; + double *pH; + int i, j, row; + + // Calculate the zero tolerance + + pH = H; + zero_tolerance = fabs(pH[0]); + for (pH += n, i = 1; i < n; pH += n, i++) + for (j = i-1; j < n; j++) zero_tolerance += fabs(pH[j]); + zero_tolerance *= DBL_EPSILON; + + // Start Backsubstitution + + for (row = n-1; row >= 0; row--) { + if (eigen_imag[row] == 0.0) + BackSubstitute_Real_Vector(H, eigen_real, eigen_imag, row, + zero_tolerance, n); + else if ( eigen_imag[row] < 0.0 ) + BackSubstitute_Complex_Vector(H, eigen_real, eigen_imag, row, + zero_tolerance, n); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// static void Calculate_Eigenvectors(double *H, double *S, // +// double eigen_real[], double eigen_imag[], int n) // +// // +// Description: // +// Multiply by transformation matrix. // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the matrix in Hessenberg form. // +// double *S // +// Pointer to the first element of the transformation matrix. // +// double eigen_real[] // +// The real part of an eigenvalue. // +// double eigen_imag[] // +// The imaginary part of an eigenvalue. // +// int n // +// The dimension of H, S, eigen_real, and eigen_imag. // +//////////////////////////////////////////////////////////////////////////////// +// // +static void Calculate_Eigenvectors(double *H, double *S, double eigen_real[], + double eigen_imag[], int n) +{ + double* pH; + double* pS; + double x,y; + int i,j,k; + + for (k = n-1; k >= 0; k--) { + if (eigen_imag[k] < 0.0) { + for (i = 0, pS = S; i < n; pS += n, i++) { + x = 0.0; + y = 0.0; + for (j = 0, pH = H; j <= k; pH += n, j++) { + x += pS[j] * pH[k-1]; + y += pS[j] * pH[k]; + } + pS[k-1] = x; + pS[k] = y; + } + } else if (eigen_imag[k] == 0.0) { + for (i = 0, pS = S; i < n; i++, pS += n) { + x = 0.0; + for (j = 0, pH = H; j <= k; j++, pH += n) + x += pS[j] * pH[k]; + pS[k] = x; + } + } + } +} + + + + + +//////////////////////////////////////////////////////////////////////////////// +// int QR_Hessenberg_Matrix( double *H, double *S, double eigen_real[], // +// double eigen_imag[], int n, int max_iteration_count) // +// // +// Description: // +// This program calculates the eigenvalues and eigenvectors of a matrix // +// in Hessenberg form. This routine is adapted from the routine 'hql2' // +// appearing in 'Handbook for Automatic Computation, vol 2: Linear // +// Algebra' published by Springer Verlag (1971) edited by Wilkinson and // +// Reinsch, Contribution II/15 Eigenvectors of Real and Complex Matrices // +// by LR and QR Triangularizations by Peters and Wilkinson. // +// // +// Arguments: // +// double *H // +// Pointer to the first element of the real n x n matrix H in upper// +// Hessenberg form. // +// double *S // +// If H is the primary data matrix, the matrix S should be set // +// to the identity n x n identity matrix on input. If H is // +// derived from an n x n matrix A, then S should be the // +// transformation matrix such that AS = SH. On output, the i-th // +// column of S corresponds to the i-th eigenvalue if that eigen- // +// value is real and the i-th and (i+1)-st columns of S correspond // +// to the i-th eigenvector with the real part in the i-th column // +// and positive imaginary part in the (i+1)-st column if that // +// eigenvalue is complex with positive imaginary part. The // +// eigenvector corresponding to the eigenvalue with negative // +// imaginary part is the complex conjugate of the eigenvector // +// corresponding to the complex conjugate of the eigenvalue. // +// If on input, S was the identity matrix, then the columns are // +// the eigenvectors of H as described, if S was a transformation // +// matrix so that AS = SH, then the columns of S are the // +// eigenvectors of A as described. // +// double eigen_real[] // +// Upon return, eigen_real[i] will contain the real part of the // +// i-th eigenvalue. // +// double eigen_imag[] // +// Upon return, eigen_ima[i] will contain the imaginary part of // +// the i-th eigenvalue. // +// int n // +// The number of rows or columns of the upper Hessenberg matrix A. // +// int max_iteration_count // +// The maximum number of iterations to try to find an eigenvalue // +// before quitting. // +// // +// Return Values: // +// 0 Success // +// -1 Failure - Unable to find an eigenvalue within 'max_iteration_count' // +// iterations. // +// // +// Example: // +// #define N // +// #define MAX_ITERATION_COUNT // +// double H[N][N], S[N][N], eigen_real[N], eigen_imag[N]; // +// int k; // +// // +// (code to initialize H[N][N] and S[N][N]) // +// k = QR_Hessenberg_Matrix( (double*)H, (double*)S, eigen_real, // +// eigen_imag, N, MAX_ITERATION_COUNT); // +// if (k < 0) {printf("Failed"); exit(1);} // +//////////////////////////////////////////////////////////////////////////////// +// // +int p3dComputeEigenVal( + double *H, + double *S, + double eigen_real[], + double eigen_imag[], + int n + ) +{ + int i; + int row; + int iteration; + int found_eigenvalue; + double shift = 0.0; + double* pH; + //double* U; + + //U = (double *) malloc(n*n * sizeof(double)); + + + + //FB code: + Identity_Matrix(S, n); + if (Hessenberg_Form_Orthogonal(H, S, n) == -1 ) return -1; + //Identity_Matrix(S, n); + + + for ( row = n - 1; row >= 0; row--) { + found_eigenvalue = 0; + for (iteration = 1; iteration <= MAX_ITERATION; iteration++) { + + // Search for small subdiagonal element + + for (i = row, pH = H + row * n; i > 0; i--, pH -= n) + if (fabs(*(pH + i - 1 )) <= DBL_EPSILON * + ( fabs(*(pH - n + i - 1)) + fabs(*(pH + i)) ) ) break; + + // If the subdiagonal element on row "row" is small, then + // that row element is an eigenvalue. If the subdiagonal + // element on row "row-1" is small, then the eigenvalues + // of the 2x2 diagonal block consisting rows "row-1" and + // "row" are eigenvalues. Otherwise perform a double QR + // iteration. + + switch(row - i) { + case 0: // One real eigenvalue + One_Real_Eigenvalue(pH, eigen_real, eigen_imag, i, shift); + found_eigenvalue = 1; + break; + case 1: // Either two real eigenvalues or a complex pair + row--; + Two_Eigenvalues(H, S, eigen_real, eigen_imag, n, row, shift); + found_eigenvalue = 1; + break; + default: + Double_QR_Iteration(H, S, i, row, n, &shift, iteration); + } + if (found_eigenvalue) break; + } + if (iteration > MAX_ITERATION) return -1; + } + + BackSubstitution(H, eigen_real, eigen_imag, n); + Calculate_Eigenvectors(H, S, eigen_real, eigen_imag, n); + + return 0; +} + + + + diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.h new file mode 100644 index 0000000000000000000000000000000000000000..5be8bcac944e347e4827be9847f204875c17af1f --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.h @@ -0,0 +1,34 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +int p3dComputeEigenVal( + double *H, + double *S, + double eigen_re[], + double eigen_im[], + int n + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.c new file mode 100644 index 0000000000000000000000000000000000000000..46998818c0c04067f6e1781ced7f7c8faa66bb28 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.c @@ -0,0 +1,260 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <math.h> +#include <string.h> +#include <stdio.h> + +#include "p3dComputeHierarchicalSkeleton.h" +#include "p3dHighDivPointList.h" + +#include "../Common/p3dUtils.h" + + +// +// Procedures +// + +int _p3dComputeHierarchicalSkeleton_stabilityReached ( fcoords_list_t segm_list, fcoords_t pt ) +{ + fcoords_list_t tmp_list; + fcoords_t tmp_elem; + + // Scan list: + tmp_list = segm_list; + + // If input point is already present into the current skeleton segment probably we are + // chasing our own tail: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + tmp_elem = tmp_list->elem; + + if ( EQUAL( tmp_elem.x, pt.x) && + EQUAL( tmp_elem.y, pt.y) && + EQUAL( tmp_elem.z, pt.z) ) + return P3D_TRUE; + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + +int _p3dComputeHierarchicalSkeleton_skelPointReached ( + fcoords_list_t* skel_point_list, + fcoords_t orig_point, + fcoords_t pt, + const double close_dist + ) +{ + fcoords_list_t tmp_list; + fcoords_t tmp_point; + double a, b, c; + + + // Print critical points: + tmp_list = (*skel_point_list); + + // Scan list: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + tmp_point = tmp_list->elem; + + // Skip current critical point (it would be better to test an ID...): + if (!( EQUAL( orig_point.x, pt.x) && + EQUAL( orig_point.y, pt.y) && + EQUAL( orig_point.z, pt.z) )) + { + a = fabs( pt.x - tmp_point.x ); + b = a + fabs( pt.y - tmp_point.y ); + c = a + b + fabs( pt.z - tmp_point.z ); + + if( (a < close_dist ) && ( b < close_dist ) && ( c < close_dist ) ) + { + return P3D_TRUE; + } + } + + // The list will point to the next element: + tmp_list = tmp_list->next; + } + + return P3D_FALSE; +} + + + +int _p3dComputeHierarchicalSkeleton_followStreams ( + fcoords_list_t* skel_point_list, + fcoords_t point, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ) +{ + int flag; + + double out_x, out_y, out_z; + double len; + + fcoords_t fpoint1, fpoint2; + + fcoords_list_t tmp_list; + + + // Init list: + fcoords_list_init ( &tmp_list ); + + // Initialize starting point and put it into the temporary list for current segment: + fpoint2.x = point.x; + fpoint2.y = point.y; + fpoint2.z = point.z; + + // Start following path until exit conditions: + // i. Skeleton point reached + // ii. Stability reached (safety condition) + do { + + // Set current point and put it into list: + fpoint1.x = fpoint2.x; + fpoint1.y = fpoint2.y; + fpoint1.z = fpoint2.z; + + P3D_TRY ( fcoords_list_push( &tmp_list, fpoint1 ) ); + + // Interpolate gradient vector flow: + out_x = interpolation ( gvf_x, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z ); + out_y = interpolation ( gvf_y, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z ); + out_z = interpolation ( gvf_z, dimx, dimy, dimz, fpoint1.x, fpoint1.y, fpoint1.z ); + + // Normalize: + len = sqrt((out_x * out_x) + (out_y * out_y) + (out_z * out_z)); + + if(len > 0.00) { + out_x = out_x / len; + out_y = out_y / len; + out_z = out_z / len; + } + + // Increment path following: + fpoint2.x = fpoint1.x + out_x*step; + fpoint2.y = fpoint1.y + out_y*step; + fpoint2.z = fpoint1.z + out_z*step; + + flag = _p3dComputeHierarchicalSkeleton_skelPointReached( skel_point_list, point, fpoint2, close_dist ); + } + while ( ( flag == P3D_FALSE ) && + ( _p3dComputeHierarchicalSkeleton_stabilityReached( tmp_list, fpoint2 ) == P3D_FALSE ) ); + + + // Current segment is added to skeleton if long enough (spurious voxels may occur) + // and connected to core skeleton: + if ( ( flag == P3D_TRUE) && ( sqrt( (fpoint1.x - point.x) * (fpoint1.x - point.x) + + (fpoint1.y - point.y) * (fpoint1.y - point.y) + + (fpoint1.z - point.z) * (fpoint1.z - point.z)) > MIN_LENGTH ) ) + { + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + P3D_TRY ( fcoords_list_push( skel_point_list, fcoords_list_pop( &tmp_list ))); + } + } + /*else + printf("Qualcosa di diverso ho fatto!\n");*/ + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources of temporary list: + while ( fcoords_list_isempty( tmp_list ) == P3D_FALSE ) + { + fcoords_list_pop( &tmp_list ); + } + + return P3D_ERROR; +} + + +int p3dComputeHierarchicalSkeleton ( + highDiv_point_list_t* highDiv_point_list, + fcoords_list_t* skel_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ) +{ + highDiv_point_t point; + fcoords_t fpoint; + + // + // Following the streamlines starting at an high divergence point: + // + + // Scan list (list is deleted at the end of the loop): + while ( highDiv_point_list_isempty( *highDiv_point_list ) == P3D_FALSE ) + { + // Get current critical point: + point = highDiv_point_list_pop( highDiv_point_list ); + + // "Convert" highDiv_point_t to fcoords_point: + fpoint.x = point.x; + fpoint.y = point.y; + fpoint.z = point.z; + + P3D_TRY ( _p3dComputeHierarchicalSkeleton_followStreams ( skel_point_list, fpoint, gvf_x, gvf_y, gvf_z, + dimx, dimy, dimz, step, close_dist ) ); + } + + + // Return OK: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + while ( highDiv_point_list_isempty( *highDiv_point_list ) == P3D_FALSE ) + { + highDiv_point_list_pop( highDiv_point_list ); + } + + // Return error: + return P3D_ERROR; +} diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.h new file mode 100644 index 0000000000000000000000000000000000000000..8df0666c4f37e6227e4c7030a7006f92fe14bf53 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.h @@ -0,0 +1,42 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "../Common/p3dFCoordsList.h" +#include "p3dHighDivPointList.h" + +int p3dComputeHierarchicalSkeleton ( + highDiv_point_list_t* highDiv_point_list, + fcoords_list_t* skel_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double step, + const double close_dist + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.c new file mode 100644 index 0000000000000000000000000000000000000000..40e23de4eb7f65b2a3ec84a6c12de47e75f57f7d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.c @@ -0,0 +1,87 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dCritPointList.h" + +#include "../Common/p3dUtils.h" + +void crit_point_list_init (crit_point_list_t *list) +{ + *list = NULL; +} + +int crit_point_list_push (crit_point_list_t *list, crit_point_t item) +{ + crit_point_list_elem_t* new_l; + + + // Alloc memory for the new item: + new_l = (crit_point_list_elem_t*) malloc (sizeof(crit_point_list_elem_t)); + if ( new_l == NULL ) return P3D_ERROR; + + // Push item into queue: + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_SUCCESS; +} + +crit_point_t crit_point_list_pop (crit_point_list_t *list) +{ + crit_point_list_elem_t* tmp_l; + crit_point_t tmp_crit_point; + + + + // Perform deletion: + tmp_crit_point = (*list)->elem; + + // Save temporary pointer to the element to delete: + tmp_l = *list; + + // The list will point on the next element: + (*list) = (*list)->next; + + // Delete first element using the previously set + // temporary pointer: + free(tmp_l); + + // Return coordinates: + return tmp_crit_point; +} + + +int crit_point_list_isempty (crit_point_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.h new file mode 100644 index 0000000000000000000000000000000000000000..5d558f8113b2c045ba1743dfba1a4fdc6dd11b81 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.h @@ -0,0 +1,93 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/******************************************************************************** + * File: p3dCritPointList.h + * + * Description: Header file for the implementation of a dynamic structure + * with LIFO (Last-In-First-Out) policy (list or stack) + * containing CritPointT elements (see p3dCritPointT.h) + * Duplicate elements allowed. + * + * Interfaces: crit_point_list_init + * crit_point_list_push + * crit_point_list_pop + * crit_point_list_isempty + * crit_point_list_toarray + * + * Author: FB + * + ********************************************************************************/ +#include "p3dCritPointT.h" + +/* + Type definitions: +*/ + +#ifndef CRIT_POINT_LIST_T_DEFINED + #define CRIT_POINT_LIST_T_DEFINED + + struct crit_point_lelem_t { + crit_point_t elem; + struct crit_point_lelem_t *next; + }; + + typedef struct crit_point_lelem_t crit_point_list_elem_t; + + typedef crit_point_list_elem_t* crit_point_list_t; + +#endif + + + + +/* + Interfaces: +*/ + +void crit_point_list_init (crit_point_list_t *list); + +/******************************************************************************** + * Function: crit_point_list_push + * + * Description: Push the specified element into the list. + * + * Input(s): coords_list_t* - The list to extend + * coords_t - The element to push into the list + * + * Output: P3D_SUCCESS if element is successfully pushed into the list + * P3D_MEM_ERROR if there is not enough memory for the additional + * element + ********************************************************************************/ +int crit_point_list_push (crit_point_list_t *list, crit_point_t item); + +crit_point_t crit_point_list_pop (crit_point_list_t *list); + +int crit_point_list_isempty(crit_point_list_t list); + + + diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointT.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointT.h new file mode 100644 index 0000000000000000000000000000000000000000..6f342718867a36f39450520c8e9c3109e5582966 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointT.h @@ -0,0 +1,66 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/* + Type definitions: +*/ + +#ifndef CRIT_POINT_T_DEFINED + +typedef struct { + + /* Coordinates: */ + double x; + double y; + double z; + + /* Type { CPT_SADDLE | CPT_ATTRACTING_NODE | CPT_REPELLING_NODE } */ + int type; + + /* Eigenvalues: */ + double eval0; + double eval1; + double eval2; + + /* Eigenvectors: */ + double evect0_x; + double evect0_y; + double evect0_z; + + double evect1_x; + double evect1_y; + double evect1_z; + + double evect2_x; + double evect2_y; + double evect2_z; + +} crit_point_t; + +#endif + +#define CRIT_POINT_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.c new file mode 100644 index 0000000000000000000000000000000000000000..3cdcd9649532f0094eb667388e2047f5c97fda46 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.c @@ -0,0 +1,612 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <string.h> +#include <omp.h> +#include <math.h> + +#include "p3dCriticalPoints.h" +#include "p3dComputeEigenVal.h" + +#include "../Common/p3dUtils.h" + + +// +// Constants: +// +#define CELL_SUBDIVISION_FACTOR 1048576.00 +#define NR_OF_SIGN_CHANGES 3 + + + +int isChangeInSignNeighborhood ( + float* gvf, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) +{ + int a,b,c,s; + + // Initializations: + + s = SIGN( gvf[ I(i,j,k,dimx,dimy) ] ); + + // Check 8-neighborhood: + + c = k + 1; b = j; a = i; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + c = k; b = j + 1; a = i; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + c = k; b = j; a = i + 1; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + c = k + 1; b = j + 1; a = i; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + c = k + 1; b = j; a = i + 1; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + c = k; b = j + 1; a = i + 1; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + c = k + 1; b = j + 1; a = i + 1; + if ( SIGN( gvf[ I(a,b,c,dimx,dimy) ]) != s ) return P3D_TRUE; + + // No change in sign but sign is 0, return P3D_TRUE anyway: + if( s == 0 ) return P3D_TRUE; + + // No change in sign within neighborhood: + return P3D_FALSE; +} + + +int changeInSign( + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const int i, + const int j, + const int k + ) +{ + + int ct = 0; + + // Voxels having both positive and negative values for every + // vector component in its neighborhood are assumed to be + // critical points. If one component is 0 in all vectors, it + // should be considered as a change in sign. + + if( isChangeInSignNeighborhood( gvf_x, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) ct++; + if( isChangeInSignNeighborhood( gvf_y, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) ct++; + if( isChangeInSignNeighborhood( gvf_z, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) ct++; + + if( ct == NR_OF_SIGN_CHANGES ) return P3D_TRUE; + + return P3D_FALSE; +} + + + + + +int isChangeInSignNeighborhoodInterp ( + float* gvf, + const int dimx, + const int dimy, + const int dimz, + const double x, + const double y, + const double z, + const double cellsize + ) +{ + int s; + + // Initializations: + s = SIGN( interpolation ( gvf, dimx, dimy, dimz, x, y, z ) ); + + // Check 8-neighborhood: + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x + cellsize, y, z )) != s ) return P3D_TRUE; + + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x, y + cellsize, z )) != s ) return P3D_TRUE; + + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x, y, z + cellsize )) != s ) return P3D_TRUE; + + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x + cellsize, y + cellsize, z )) != s ) return P3D_TRUE; + + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x + cellsize, y, z + cellsize )) != s ) return P3D_TRUE; + + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x, y + cellsize, z + cellsize )) != s ) return P3D_TRUE; + + if ( SIGN( interpolation ( gvf, dimx, dimy, dimz, x + cellsize, y + cellsize, z + cellsize )) != s ) return P3D_TRUE; + + // No change in sign but sign is 0, return P3D_TRUE anyway: + if( s == 0 ) return P3D_TRUE; + + // No change in sign within neighborhood: + return P3D_FALSE; +} + + +int changeInSignInterp( + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + const double i, + const double j, + const double k, + const double cellsize + ) +{ + + int ct = 0; + + // Voxels having both positive and negative values for every + // vector component in its neighborhood are assumed to be + // critical points. If one component is 0 in all vectors, it + // should be considered as a change in sign. + + if( isChangeInSignNeighborhoodInterp( gvf_x, dimx, dimy, dimz, i, j, k, cellsize ) == P3D_TRUE ) ct++; + if( isChangeInSignNeighborhoodInterp( gvf_y, dimx, dimy, dimz, i, j, k, cellsize ) == P3D_TRUE ) ct++; + if( isChangeInSignNeighborhoodInterp( gvf_z, dimx, dimy, dimz, i, j, k, cellsize ) == P3D_TRUE ) ct++; + + if( ct == NR_OF_SIGN_CHANGES ) return P3D_TRUE; + + return P3D_FALSE; +} + + + + + + + + +int getCriticalPointInFloatCell ( + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, // ncols + const int dimy, // nrows + const int dimz, // nplanes + double x, + double y, + double z, + double cellsize, + crit_point_list_t* crit_point_list + ) +{ + crit_point_t crit_point; + double in_gvf_x, in_gvf_y, in_gvf_z; + int err_code; + + // Get the first sub-cell: + in_gvf_x = interpolation ( gvf_x, dimx, dimy, dimz, x, y, z ); + in_gvf_y = interpolation ( gvf_y, dimx, dimy, dimz, x, y, z ); + in_gvf_z = interpolation ( gvf_z, dimx, dimy, dimz, x, y, z ); + + + // If first vertex vector (coresponding to (x, y, z)) is (0, 0, 0) + // then return (x, y, z) as the critical point: + if ( (IS_ZERO(in_gvf_x)) && (IS_ZERO(in_gvf_y)) && (IS_ZERO(in_gvf_z)) ) + { + // Add critical point into list: + crit_point.x = x; + crit_point.y = y; + crit_point.z = z; + + P3D_TRY( crit_point_list_push ( crit_point_list, crit_point)); + + return P3D_TRUE; + } + else + { + // The cell is a candidate cell if there is a change of sign in one of the vector + // components among all eight vertices of the cell: + if ( changeInSignInterp( gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, x, y, z, cellsize) == P3D_TRUE ) + { + // Stop here if maximum subdivision reached and assume + // that the critical point is in the center of the cell: + if( cellsize <= (1.00 / CELL_SUBDIVISION_FACTOR) ) + { + // Add critical point into list: + crit_point.x = x + cellsize/ 2.0; + crit_point.y = y + cellsize/ 2.0; + crit_point.z = z + cellsize/ 2.0; + + P3D_TRY ( crit_point_list_push ( crit_point_list, crit_point )); + + return P3D_TRUE; + } + else + { + // We are on a candidate cell but it's not small enough, so we are + // dividing the cell in 8 subcells and try to find the critical point + // in one of the subcells (recursive programming used): + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x, y, z, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x + cellsize/2.0, y, z, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x, y + cellsize/2.0, z, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x + cellsize/2.0, y + cellsize/2.0, z, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x, y, z + cellsize/2.0, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x + cellsize/2.0, y, z + cellsize/2.0, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x, y + cellsize/2.0, z + cellsize/2.0, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, + x + cellsize/2.0, y + cellsize/2.0, z + cellsize/2.0, cellsize/2.0, crit_point_list ); + if ( err_code == P3D_TRUE ) return P3D_TRUE; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + } + } + } + + return P3D_FALSE; + +MEM_ERROR: + + return P3D_ERROR; +} + + + +int p3dGetCriticalPoints ( + unsigned char* in_im, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + crit_point_list_t* crit_point_list + ) +{ + int a_rad; + int i,j,k; + + crit_point_t crit_point; + + int err_code; + + + + a_rad = 1; // A critical point could not occur on boundaries. + + // + // Determine critical points according to the sign of GVF. + // + + for( k = a_rad; k < (dimz - a_rad); k++ ) + for( j = a_rad; j < (dimy - a_rad); j++ ) + for( i = a_rad; i < (dimx - a_rad); i++ ) + { + // Skip voxels on object boundary (6-connection used) : + if ( ( in_im[ I(i,j,k,dimx,dimy) ] != BACKGROUND ) && + ( isFullNeighborhood ( in_im, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) + ) + { + if( ( IS_ZERO( gvf_x[ I(i,j,k,dimx,dimy) ] )) && + ( IS_ZERO( gvf_y[ I(i,j,k,dimx,dimy) ] )) && + ( IS_ZERO( gvf_z[ I(i,j,k,dimx,dimy) ] )) ) + { + // Add critical point into list: + crit_point.x = (double) i; + crit_point.y = (double) j; + crit_point.z = (double) k; + + P3D_TRY ( crit_point_list_push ( crit_point_list, crit_point) ); + } + else if ( changeInSign( gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) + { + // Explore subcells: + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i, j, k, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i, j, k + 0.5, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i, j + 0.5, k, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i + 0.5, j, k, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i, j + 0.5, k + 0.5, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i + 0.5, j, k + 0.5, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i + 0.5, j + 0.5, k, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + + err_code = getCriticalPointInFloatCell (gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, i + 0.5, j + 0.5, k + 0.5, 0.5, crit_point_list ); + if ( err_code == P3D_TRUE ) continue; + if ( err_code == P3D_ERROR ) return P3D_ERROR; + } + } + } + + + // Return success code: + return P3D_SUCCESS; + +MEM_ERROR: + + return P3D_ERROR; +} + + +int p3dClassifyCriticalPoints ( + crit_point_list_t crit_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz + ) +{ + crit_point_list_t tmp_list; + crit_point_t crit_point; + + double i,j,k; + + double* in_gvf_x; + double* in_gvf_y; + double* in_gvf_z; + + + double* jacob; + double* eigvectors; + double* eigvals_re; + double* eigvals_im; + + + double vecLength; + double vdist = 1.00 / CELL_SUBDIVISION_FACTOR; + + + P3D_TRY ( jacob = (double*) malloc(9*sizeof(double))); + P3D_TRY ( eigvectors = (double*) malloc(9*sizeof(double))); + P3D_TRY ( eigvals_re = (double*) malloc(3*sizeof(double))); + P3D_TRY ( eigvals_im = (double*) malloc(3*sizeof(double))); + + + P3D_TRY ( in_gvf_x = (double*) malloc(6*sizeof(double))); + P3D_TRY ( in_gvf_y = (double*) malloc(6*sizeof(double))); + P3D_TRY ( in_gvf_z = (double*) malloc(6*sizeof(double))); + + + // Scan list: + tmp_list = crit_point_list; + + while ( crit_point_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + crit_point = tmp_list->elem; + + i = crit_point.x; + j = crit_point.y; + k = crit_point.z; + + // + // Classify the critical points as atracting/repelling nodes or saddles + // based on the real and imaginary part of the eigenvalues of the + // Jacobian matrix. + // + + // NOTE: same array used as input for Jacobian matrix and as output for + // eigenvalues + + // Interpolate values in the neighborhood: + in_gvf_x[0] = interpolation( gvf_x, dimx, dimy, dimz, i + vdist, j, k ); + in_gvf_x[1] = interpolation( gvf_x, dimx, dimy, dimz, i - vdist, j, k ); + in_gvf_x[2] = interpolation( gvf_x, dimx, dimy, dimz, i, j + vdist, k ); + in_gvf_x[3] = interpolation( gvf_x, dimx, dimy, dimz, i, j - vdist, k ); + in_gvf_x[4] = interpolation( gvf_x, dimx, dimy, dimz, i, j, k + vdist ); + in_gvf_x[5] = interpolation( gvf_x, dimx, dimy, dimz, i, j, k - vdist ); + + in_gvf_y[0] = interpolation( gvf_y, dimx, dimy, dimz, i + vdist, j, k ); + in_gvf_y[1] = interpolation( gvf_y, dimx, dimy, dimz, i - vdist, j, k ); + in_gvf_y[2] = interpolation( gvf_y, dimx, dimy, dimz, i, j + vdist, k ); + in_gvf_y[3] = interpolation( gvf_y, dimx, dimy, dimz, i, j - vdist, k ); + in_gvf_y[4] = interpolation( gvf_y, dimx, dimy, dimz, i, j, k + vdist ); + in_gvf_y[5] = interpolation( gvf_y, dimx, dimy, dimz, i, j, k - vdist ); + + in_gvf_z[0] = interpolation( gvf_z, dimx, dimy, dimz, i + vdist, j, k ); + in_gvf_z[1] = interpolation( gvf_z, dimx, dimy, dimz, i - vdist, j, k ); + in_gvf_z[2] = interpolation( gvf_z, dimx, dimy, dimz, i, j + vdist, k ); + in_gvf_z[3] = interpolation( gvf_z, dimx, dimy, dimz, i, j - vdist, k ); + in_gvf_z[4] = interpolation( gvf_z, dimx, dimy, dimz, i, j, k + vdist ); + in_gvf_z[5] = interpolation( gvf_z, dimx, dimy, dimz, i, j, k - vdist ); + + // Determine Jacobian matrix: + jacob[0] = (in_gvf_x[0] - in_gvf_x[1]) / (2.0 * vdist); + jacob[1] = (in_gvf_x[2] - in_gvf_x[3]) / (2.0 * vdist); + jacob[2] = (in_gvf_x[4] - in_gvf_x[5]) / (2.0 * vdist); + + jacob[3] = (in_gvf_y[0] - in_gvf_y[1]) / (2.0 * vdist); + jacob[4] = (in_gvf_y[2] - in_gvf_y[3]) / (2.0 * vdist); + jacob[5] = (in_gvf_y[4] - in_gvf_y[5]) / (2.0 * vdist); + + jacob[6] = (in_gvf_z[0] - in_gvf_z[1]) / (2.0 * vdist); + jacob[7] = (in_gvf_z[2] - in_gvf_z[3]) / (2.0 * vdist); + jacob[8] = (in_gvf_z[4] - in_gvf_z[5]) / (2.0 * vdist); + + // + // Calculate the eigenvalues and eigenvectors of the Jacobian matrix: + // + p3dComputeEigenVal( jacob, eigvectors, eigvals_re, eigvals_im, 3 ); + + + if( (eigvals_re[0] < 0.00) && (eigvals_re[1] < 0.00) && (eigvals_re[2] < 0.00) ) + { + // All real parts of the eigenvalues are negative => attracting node: + crit_point.type = CPT_ATTRACTING_NODE; + } + else + { + if( (eigvals_re[0] > 0.00) && (eigvals_re[1] > 0.00) && (eigvals_re[2] > 0.00)) + { + // All real parts of the eigenvalues are positive => repelling node: + crit_point.type = CPT_REPELLING_NODE; + } + else + { + // Two real parts of the eigenvalues are of one sign and the other + // has the opposite sign => this is a saddle point + crit_point.type = CPT_SADDLE; + } + } + + // Set eigenvalues: + crit_point.eval0 = eigvals_re[0]; + crit_point.eval1 = eigvals_re[1]; + crit_point.eval2 = eigvals_re[2]; + + // Set normalized eigenvectors: + vecLength = sqrt( eigvectors[0]*eigvectors[0] + + eigvectors[3]*eigvectors[3] + + eigvectors[6]*eigvectors[6] ); + if ( vecLength == 0.00 ) + { + vecLength = 1.00; + } + + crit_point.evect0_x = eigvectors[0] / vecLength; + crit_point.evect0_y = eigvectors[3] / vecLength; + crit_point.evect0_z = eigvectors[6] / vecLength; + + + + vecLength = sqrt( eigvectors[1]*eigvectors[1] + + eigvectors[4]*eigvectors[4] + + eigvectors[7]*eigvectors[7] ); + if(vecLength == 0.00) + { + vecLength = 1.00; + } + + crit_point.evect1_x = eigvectors[1] / vecLength; + crit_point.evect1_y = eigvectors[4] / vecLength; + crit_point.evect1_z = eigvectors[7] / vecLength; + + vecLength = sqrt( eigvectors[2]*eigvectors[2] + + eigvectors[5]*eigvectors[5] + + eigvectors[8]*eigvectors[8] ); + if(vecLength == 0.00) + { + vecLength = 1.00; + } + + crit_point.evect2_x = eigvectors[2] / vecLength; + crit_point.evect2_y = eigvectors[5] / vecLength; + crit_point.evect2_z = eigvectors[8] / vecLength; + + // Set crit_point to current element: + tmp_list->elem = crit_point; + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + // Release resources and return success: + + if ( in_gvf_x != NULL ) free( in_gvf_x ); + if ( in_gvf_y != NULL ) free( in_gvf_y ); + if ( in_gvf_z != NULL ) free( in_gvf_z ); + + if ( jacob != NULL ) free( jacob ); + if ( eigvectors != NULL ) free( eigvectors ); + if ( eigvals_re != NULL ) free( eigvals_re ); + if ( eigvals_im != NULL ) free( eigvals_im ); + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources and return error: + + if ( in_gvf_x != NULL ) free( in_gvf_x ); + if ( in_gvf_y != NULL ) free( in_gvf_y ); + if ( in_gvf_z != NULL ) free( in_gvf_z ); + + if ( jacob != NULL ) free( jacob ); + if ( eigvectors != NULL ) free( eigvectors ); + if ( eigvals_re != NULL ) free( eigvals_re ); + if ( eigvals_im != NULL ) free( eigvals_im ); + + return P3D_ERROR; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.h new file mode 100644 index 0000000000000000000000000000000000000000..103825cb4322b3dc48ec8a1d9a71aece2b2abd1c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.h @@ -0,0 +1,49 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dCritPointList.h" + +int p3dGetCriticalPoints ( + unsigned char* in_im, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + crit_point_list_t* crit_point_list + ); + +int p3dClassifyCriticalPoints ( + crit_point_list_t crit_point_list, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.c new file mode 100644 index 0000000000000000000000000000000000000000..de96afebff456d0d7f769b79561ff9c41f286af0 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.c @@ -0,0 +1,240 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <string.h> +#include <omp.h> +#include <math.h> + +#include "p3dGVF.h" + +#include "../Common/p3dUtils.h" + + +// +// In-line gradient computation: +// +double grad_x ( unsigned char* in_im, + const int dimx, const int dimy, const int dimz, + const int i, const int j, const int k ) +{ + return (0.5 * ( in_im[ I(i+1,j,k,dimx,dimy) ] - in_im[ I(i-1,j,k,dimx,dimy) ] )); +} +double grad_y ( unsigned char* in_im, + const int dimx, const int dimy, const int dimz, + const int i, const int j, const int k ) +{ + return (0.5 * ( in_im[ I(i,j+1,k,dimx,dimy) ] - in_im[ I(i,j-1,k,dimx,dimy) ] )); +} +double grad_z ( unsigned char* in_im, + const int dimx, const int dimy, const int dimz, + const int i, const int j, const int k ) +{ + return (0.5 * ( in_im[ I(i,j,k+1,dimx,dimy) ] - in_im[ I(i,j,k-1,dimx,dimy) ] )); +} +// +// In-line gradient magnitude computation: +// +double grad_mag ( unsigned char* in_im, + const int dimx, const int dimy, const int dimz, + const int i, const int j, const int k ) +{ + return ( grad_x(in_im,dimx,dimy,dimz,i,j,k)*grad_x(in_im,dimx,dimy,dimz,i,j,k) + + grad_y(in_im,dimx,dimy,dimz,i,j,k)*grad_y(in_im,dimx,dimy,dimz,i,j,k) + + grad_z(in_im,dimx,dimy,dimz,i,j,k)*grad_z(in_im,dimx,dimy,dimz,i,j,k) ); +} + +// +// In-line laplacian computation: +// +double lapl ( float* in_im, + const int dimx, const int dimy, const int dimz, + const int i, const int j, const int k) +{ + return ( (1.0/6.0) * ( in_im[ I(i-1,j,k,dimx,dimy) ] + + in_im[ I(i+1,j,k,dimx,dimy) ] + + in_im[ I(i,j-1,k,dimx,dimy) ] + + in_im[ I(i,j+1,k,dimx,dimy) ] + + in_im[ I(i,j,k-1,dimx,dimy) ] + + in_im[ I(i,j,k+1,dimx,dimy) ] ) - + in_im[ I(i,j,k,dimx,dimy) ] ); +} + + +int p3dGVF ( + unsigned char* in_im, + float* out_x, + float* out_y, + float* out_z, + const int dimx, + const int dimy, + const int dimz, + const double mu, + const double eps + ) +{ + int rad = 1; + int ct = 0; + + int i,j,k; + + double r; + float tmp_x, tmp_y, tmp_z; + double eps_x, eps_y, eps_z; + double loc_eps_x, loc_eps_y, loc_eps_z; + int stable_x, stable_y, stable_z; + + + // + // PHASE 1: Compute gradient (central difference used). + // + + #pragma omp parallel for private(i, j) + for( k = rad; k < (dimz - rad); k++ ) + for( j = rad; j < (dimy - rad); j++ ) + for( i = rad; i < (dimx - rad); i++ ) + { + if ( in_im[ I(i,j,k,dimx,dimy) ] != BACKGROUND ) + { + out_x[ I(i,j,k,dimx,dimy) ] = (float) (0.5 * ( (float) (in_im[ I(i+1,j,k,dimx,dimy) ]) + - (float) (in_im[ I(i-1,j,k,dimx,dimy) ]) )); + out_y[ I(i,j,k,dimx,dimy) ] = (float) (0.5 * ( (float) (in_im[ I(i,j+1,k,dimx,dimy) ]) + - (float) (in_im[ I(i,j-1,k,dimx,dimy) ]) )); + out_z[ I(i,j,k,dimx,dimy) ] = (float) (0.5 * ( (float) (in_im[ I(i,j,k+1,dimx,dimy) ]) + - (float) (in_im[ I(i,j,k-1,dimx,dimy) ]) )); + } + } + + // + // PHASE 2: Iteratively solve GVF: + // + + + // Solve GVF iteratively: + // + // gvf_x = gvf_x + mu*4*lapl( gvf_x ) - SqrMagf.*( gvf_x - grad_x ); + // gvf_y = gvf_y + mu*4*lapl( gvf_y ) - SqrMagf.*( gvf_x - grad_y ); + // gvf_z = gvf_z + mu*4*lapl( gvf_z ) - SqrMagf.*( gvf_z - grad_z ); + // + // mu = 0.15 with 500 iterations (Hassouna, 2009) + + stable_x = P3D_FALSE; + stable_y = P3D_FALSE; + stable_z = P3D_FALSE; + + + while ( (stable_x == P3D_FALSE) || (stable_y == P3D_FALSE) || (stable_z == P3D_FALSE) ) + { + eps_x = 0.0; + eps_y = 0.0; + eps_z = 0.0; + + #pragma omp parallel for private(i, j, tmp_x, tmp_y, tmp_z, loc_eps_x, loc_eps_y, loc_eps_z) + for( k = rad; k < (dimz - rad); k++ ) + { + loc_eps_x = 0.0; + loc_eps_y = 0.0; + loc_eps_z = 0.0; + + for( j = rad; j < (dimy - rad); j++ ) + for( i = rad; i < (dimx - rad); i++ ) + { + if (in_im[ I(i,j,k,dimx,dimy) ] != BACKGROUND ) + { + tmp_x = (float) (out_x[ I(i,j,k,dimx,dimy) ] + + mu*4.0*lapl(out_x,dimx,dimy,dimz,i,j,k) - grad_mag(in_im,dimx,dimy,dimz,i,j,k) * + (out_x[ I(i,j,k,dimx,dimy) ] - grad_x(in_im,dimx,dimy,dimz,i,j,k) )); + + tmp_y = (float) (out_y[ I(i,j,k,dimx,dimy) ] + + mu*4.0*lapl(out_y,dimx,dimy,dimz,i,j,k) - grad_mag(in_im,dimx,dimy,dimz,i,j,k) * + (out_y[ I(i,j,k,dimx,dimy) ] - grad_y(in_im,dimx,dimy,dimz,i,j,k) )); + + tmp_z = (float) (out_z[ I(i,j,k,dimx,dimy) ] + + mu*4.0*lapl(out_z,dimx,dimy,dimz,i,j,k) - grad_mag(in_im,dimx,dimy,dimz,i,j,k) * + (out_z[ I(i,j,k,dimx,dimy) ] - grad_z(in_im,dimx,dimy,dimz,i,j,k) )); + + // Compute differences: + loc_eps_x = MAX(loc_eps_x,fabs(tmp_x - out_x[ I(i,j,k,dimx,dimy) ])); + loc_eps_y = MAX(loc_eps_y,fabs(tmp_y - out_y[ I(i,j,k,dimx,dimy) ])); + loc_eps_z = MAX(loc_eps_z,fabs(tmp_z - out_z[ I(i,j,k,dimx,dimy) ])); + + // Assign values for this step: + out_x[ I(i,j,k,dimx,dimy) ] = tmp_x; + out_y[ I(i,j,k,dimx,dimy) ] = tmp_y; + out_z[ I(i,j,k,dimx,dimy) ] = tmp_z; + } + } + + #pragma omp critical + { + eps_x = MAX(eps_x,loc_eps_x); + eps_y = MAX(eps_y,loc_eps_y); + eps_z = MAX(eps_z,loc_eps_z); + } + } + + // Check for stability: + + // If at least one value has a difference from the + // previous step which is greater than EPS continue + // the iterations: + stable_x = (eps_x > eps) ? P3D_FALSE : P3D_TRUE; + stable_y = (eps_y > eps) ? P3D_FALSE : P3D_TRUE; + stable_z = (eps_z > eps) ? P3D_FALSE : P3D_TRUE; + + ct++; + } + + + // + // Normalize vectors flow: + // + + #pragma omp parallel for private(r) + for ( i = 0; i < (dimx*dimy*dimz); i++) + { + if( in_im[ i ] != BACKGROUND ) + { + r = out_x[ i ]*out_x[ i ] + + out_y[ i ]*out_y[ i ] + + out_z[ i ]*out_z[ i ]; + + if( r > 0.00 ) + { + r = sqrt(r); + + out_x[ i ] = (float) ( out_x[ i ] / r ); + out_y[ i ] = (float) ( out_y[ i ] / r ); + out_z[ i ] = (float) ( out_z[ i ] / r ); + } + } + } + + // Return the number of iterations: + return ct; +} + diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.h new file mode 100644 index 0000000000000000000000000000000000000000..b66accc021ba38aee8a924a27d26faa77ec36d73 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.h @@ -0,0 +1,38 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +int p3dGVF ( + unsigned char* in_im, + float* out_x, + float* out_y, + float* out_z, + const int dimx, + const int dimy, + const int dimz, + const double mu, + const double eps + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.c new file mode 100644 index 0000000000000000000000000000000000000000..e60e9beb02c93f54f52ce246613936381c9e5607 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.c @@ -0,0 +1,308 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <string.h> +#include <omp.h> +#include <math.h> +#include <limits.h> + +#include "p3dGetHighDivPoints.h" +#include "p3dHighDivPointList.h" + +#include "../Common/p3dUtils.h" + +#define SEARCH_GRID 1 +#define CELL_SIZE 1.00 / SEARCH_GRID + + +int _p3dGetHighDivPoints_cmp (const void *a, const void *b) +{ + const highDiv_point_t *da = (const highDiv_point_t *) a; + const highDiv_point_t *db = (const highDiv_point_t *) b; + + return (da->div > db->div) - (da->div < db->div); +} + +int _p3dGetHighDivPoints_pointIsCloseToGroup ( highDiv_point_t pt, highDiv_point_list_t list) +{ + highDiv_point_list_t tmp_list; + highDiv_point_t tmp_point; + + tmp_list = list; + + while ( highDiv_point_list_isempty( tmp_list ) == P3D_FALSE ) + { + // Get current element: + tmp_point = tmp_list->elem; + + if( (fabs( pt.x - tmp_point.x ) <= 1) && + (fabs( pt.y - tmp_point.y ) <= 1) && + (fabs( pt.z - tmp_point.z ) <= 1) ) + { + // Input point is "close" to a point already present into list: + return P3D_TRUE; + } + + // The list will point on the next element: + tmp_list = tmp_list->next; + } + + // The input point is not "close" to a point already present into list: + return P3D_FALSE; +} + + +int p3dGetHighDivPoints ( + unsigned char* in_im, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double thresh, + highDiv_point_list_t* highDiv_point_list + ) +{ + int a_rad; + int i, j, k; + int a, b, c; + double x, y, z; + + double* in_gvf_x; + double* in_gvf_y; + double* in_gvf_z; + + double maxDiv = LONG_MIN; + double minDiv = LONG_MAX; + double div; + double threshold; + + double vdist = (CELL_SIZE) / 2.00; + + highDiv_point_t highDivPoint; + highDiv_point_t* vtmp; + int ct_HighDivPoints = 0; + + + + + + P3D_TRY ( in_gvf_x = (double*) malloc(6*sizeof(double))); + P3D_TRY ( in_gvf_y = (double*) malloc(6*sizeof(double))); + P3D_TRY ( in_gvf_z = (double*) malloc(6*sizeof(double))); + + a_rad = 1; // An high divergence point could not occur on boundaries + + + // + // Compute divergence throughout the dataset: + // + for( k = a_rad; k < (dimz - a_rad); k++ ) + for( j = a_rad; j < (dimy - a_rad); j++ ) + for( i = a_rad; i < (dimx - a_rad); i++ ) + { + + // Skip voxels on object boundary (6-connection used): + if ( ( in_im[ I(i,j,k,dimx,dimy) ] != BACKGROUND ) && + ( isFullNeighborhood ( in_im, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) + ) + { + for ( c = 0; c < SEARCH_GRID; c++ ) + for ( b = 0; b < SEARCH_GRID; b++ ) + for ( a = 0; a < SEARCH_GRID; a++ ) + { + x = i + (a * CELL_SIZE); + y = j + (b * CELL_SIZE); + z = k + (c * CELL_SIZE); + + // Interpolate values in the neighborhood: + in_gvf_x[0] = interpolation( gvf_x, dimx, dimy, dimz, x + vdist, y, z ); + in_gvf_x[1] = interpolation( gvf_x, dimx, dimy, dimz, x - vdist, y, z ); + in_gvf_x[2] = interpolation( gvf_x, dimx, dimy, dimz, x, y + vdist, z ); + in_gvf_x[3] = interpolation( gvf_x, dimx, dimy, dimz, x, y - vdist, z ); + in_gvf_x[4] = interpolation( gvf_x, dimx, dimy, dimz, x, y, z + vdist ); + in_gvf_x[5] = interpolation( gvf_x, dimx, dimy, dimz, x, y, z - vdist ); + + in_gvf_y[0] = interpolation( gvf_y, dimx, dimy, dimz, x + vdist, y, z ); + in_gvf_y[1] = interpolation( gvf_y, dimx, dimy, dimz, x - vdist, y, z ); + in_gvf_y[2] = interpolation( gvf_y, dimx, dimy, dimz, x, y + vdist, z ); + in_gvf_y[3] = interpolation( gvf_y, dimx, dimy, dimz, x, y - vdist, z ); + in_gvf_y[4] = interpolation( gvf_y, dimx, dimy, dimz, x, y, z + vdist ); + in_gvf_y[5] = interpolation( gvf_y, dimx, dimy, dimz, x, y, z - vdist ); + + in_gvf_z[0] = interpolation( gvf_z, dimx, dimy, dimz, x + vdist, y, z ); + in_gvf_z[1] = interpolation( gvf_z, dimx, dimy, dimz, x - vdist, y, z ); + in_gvf_z[2] = interpolation( gvf_z, dimx, dimy, dimz, x, y + vdist, z ); + in_gvf_z[3] = interpolation( gvf_z, dimx, dimy, dimz, x, y - vdist, z ); + in_gvf_z[4] = interpolation( gvf_z, dimx, dimy, dimz, x, y, z + vdist ); + in_gvf_z[5] = interpolation( gvf_z, dimx, dimy, dimz, x, y, z - vdist ); + + + div = ( (in_gvf_x[0] - in_gvf_x[1]) + (in_gvf_y[2] - in_gvf_y[3]) + + (in_gvf_z[4] - in_gvf_z[5])) / (2.0 * vdist); + + // Add the point to the list + /*highDivPoint.x = x; + highDivPoint.y = y; + highDivPoint.z = z; + + highDivPoint.div = div; + + P3D_TRY ( highDiv_point_list_push( highDiv_point_list, highDivPoint ) ); + + ct_HighDivPoints++;*/ + + + if( div > maxDiv ) maxDiv = div; + if( div < minDiv ) minDiv = div; + } + } + } + + // case 1: + // take <perc> percent of the lowest negative value: + // !! have to change the comparison + threshold = maxDiv - minDiv; + threshold = thresh * threshold; + threshold = minDiv + threshold; + + + // + // Re-compute divergence throughout the dataset in order to save memory occupation: + // + for( k = a_rad; k < (dimz - a_rad); k++ ) + for( j = a_rad; j < (dimy - a_rad); j++ ) + for( i = a_rad; i < (dimx - a_rad); i++ ) + { + + // Skip voxels on object boundary (6-connection used): + if ( ( in_im[ I(i,j,k,dimx,dimy) ] != BACKGROUND ) && + ( isFullNeighborhood ( in_im, dimx, dimy, dimz, i, j, k ) == P3D_TRUE ) + ) + { + + for ( c = 0; c < SEARCH_GRID; c++ ) + for ( b = 0; b < SEARCH_GRID; b++ ) + for ( a = 0; a < SEARCH_GRID; a++ ) + { + x = i + (a * CELL_SIZE); + y = j + (b * CELL_SIZE); + z = k + (c * CELL_SIZE); + + // Interpolate values in the neighborhood: + in_gvf_x[0] = interpolation( gvf_x, dimx, dimy, dimz, x + vdist, y, z ); + in_gvf_x[1] = interpolation( gvf_x, dimx, dimy, dimz, x - vdist, y, z ); + in_gvf_x[2] = interpolation( gvf_x, dimx, dimy, dimz, x, y + vdist, z ); + in_gvf_x[3] = interpolation( gvf_x, dimx, dimy, dimz, x, y - vdist, z ); + in_gvf_x[4] = interpolation( gvf_x, dimx, dimy, dimz, x, y, z + vdist ); + in_gvf_x[5] = interpolation( gvf_x, dimx, dimy, dimz, x, y, z - vdist ); + + in_gvf_y[0] = interpolation( gvf_y, dimx, dimy, dimz, x + vdist, y, z ); + in_gvf_y[1] = interpolation( gvf_y, dimx, dimy, dimz, x - vdist, y, z ); + in_gvf_y[2] = interpolation( gvf_y, dimx, dimy, dimz, x, y + vdist, z ); + in_gvf_y[3] = interpolation( gvf_y, dimx, dimy, dimz, x, y - vdist, z ); + in_gvf_y[4] = interpolation( gvf_y, dimx, dimy, dimz, x, y, z + vdist ); + in_gvf_y[5] = interpolation( gvf_y, dimx, dimy, dimz, x, y, z - vdist ); + + in_gvf_z[0] = interpolation( gvf_z, dimx, dimy, dimz, x + vdist, y, z ); + in_gvf_z[1] = interpolation( gvf_z, dimx, dimy, dimz, x - vdist, y, z ); + in_gvf_z[2] = interpolation( gvf_z, dimx, dimy, dimz, x, y + vdist, z ); + in_gvf_z[3] = interpolation( gvf_z, dimx, dimy, dimz, x, y - vdist, z ); + in_gvf_z[4] = interpolation( gvf_z, dimx, dimy, dimz, x, y, z + vdist ); + in_gvf_z[5] = interpolation( gvf_z, dimx, dimy, dimz, x, y, z - vdist ); + + + div = ( (in_gvf_x[0] - in_gvf_x[1]) + (in_gvf_y[2] - in_gvf_y[3]) + + (in_gvf_z[4] - in_gvf_z[5])) / (2.0 * vdist); + + if( div <= threshold ) + { + // Add the point to the list + highDivPoint.x = x; + highDivPoint.y = y; + highDivPoint.z = z; + + highDivPoint.div = div; + + P3D_TRY ( highDiv_point_list_push( highDiv_point_list, highDivPoint ) ); + + ct_HighDivPoints++; + } + } + } + } + + // + // Convert to array the list of high divergence points: + // + P3D_TRY ( vtmp = highDiv_point_list_toarray ( highDiv_point_list, ct_HighDivPoints ) ); + + // + // Sort the array according to the divergence value; + // + qsort(vtmp, ct_HighDivPoints, sizeof(highDiv_point_t), _p3dGetHighDivPoints_cmp); + + + // + // Remove duplicate points according to a "closeness" criteria: + // + for( i = 0; i < ct_HighDivPoints; i++ ) + { + + /*if ( ( vtmp[i].div < threshold ) && ( _p3dGetHighDivPoints_pointIsCloseToGroup( + vtmp[i], *highDiv_point_list ) == P3D_FALSE ) )*/ + if ( _p3dGetHighDivPoints_pointIsCloseToGroup( vtmp[i], *highDiv_point_list ) == P3D_FALSE ) + { + // Add the point to the output list: + P3D_TRY ( highDiv_point_list_push ( highDiv_point_list, vtmp[i] ) ); + } + } + + + // Release resources: + if ( vtmp != NULL ) free ( vtmp ); + if ( in_gvf_x != NULL ) free ( in_gvf_x ); + if ( in_gvf_y != NULL ) free ( in_gvf_y ); + if ( in_gvf_z != NULL ) free ( in_gvf_z ); + + // Return success: + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources and return error: + if ( vtmp != NULL ) free (vtmp); + + if ( in_gvf_x != NULL ) free( in_gvf_x ); + if ( in_gvf_y != NULL ) free( in_gvf_y ); + if ( in_gvf_z != NULL ) free( in_gvf_z ); + + // Return error: + return P3D_ERROR; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.h new file mode 100644 index 0000000000000000000000000000000000000000..35bb72e85392715505a4662f4e5ba9b51588ffee --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.h @@ -0,0 +1,40 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include "p3dHighDivPointList.h" + +int p3dGetHighDivPoints ( + unsigned char* in_im, + float* gvf_x, + float* gvf_y, + float* gvf_z, + const int dimx, + const int dimy, + const int dimz, + const double thresh, + highDiv_point_list_t* highDiv_point_list + ); \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.c b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.c new file mode 100644 index 0000000000000000000000000000000000000000..24a35c80ac33989357892f9a427be7fabc392eb0 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.c @@ -0,0 +1,122 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +#include <stdlib.h> +#include <stdio.h> + +#include "p3dHighDivPointList.h" + +#include "../Common/p3dUtils.h" + +void highDiv_point_list_init (highDiv_point_list_t *list) +{ + *list = NULL; +} + +int highDiv_point_list_push (highDiv_point_list_t *list, highDiv_point_t item) +{ + highDiv_point_list_elem_t* new_l; + + + // Alloc memory for the new item: + new_l = (highDiv_point_list_elem_t*) malloc (sizeof(highDiv_point_list_elem_t)); + if ( new_l == NULL ) return P3D_ERROR; + + // Push item into queue: + new_l->elem = item; + new_l->next = *list; + + *list = new_l; + + return P3D_SUCCESS; +} + +highDiv_point_t highDiv_point_list_pop (highDiv_point_list_t *list) +{ + highDiv_point_list_elem_t* tmp_l; + highDiv_point_t tmp_point; + + + + // Perform deletion: + tmp_point = (*list)->elem; + + // Save temporary pointer to the element to delete: + tmp_l = *list; + + // The list will point on the next element: + (*list) = (*list)->next; + + // Delete first element using the previously set + // temporary pointer: + free(tmp_l); + + // Return coordinates: + return tmp_point; +} + + +int highDiv_point_list_isempty (highDiv_point_list_t list) +{ + return ( (list == NULL) ? P3D_TRUE : P3D_FALSE ); +} + +highDiv_point_t* highDiv_point_list_toarray (highDiv_point_list_t *list, int numel ) +{ + highDiv_point_list_elem_t* tmp_l; + + + highDiv_point_t* v; + int i; + + /* Allocate memory for output array: */ + v = (highDiv_point_t*) malloc (numel*sizeof(highDiv_point_t)); + + if ( v != NULL ) + { + /* Convert list to array: */ + for (i = (numel - 1); i >= 0; i-- ) + { + v[i] = (*list)->elem; + + /* Perform deletion: */ + tmp_l = *list; + + (*list) = (*list)->next; + + free(tmp_l); + } + } + else + { + /* Delete list in any case: */ + while ( list != NULL ) + highDiv_point_list_pop ( list ); + } + + return v; +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.h new file mode 100644 index 0000000000000000000000000000000000000000..91178556f1dbd1d786391ebac8277023c911f205 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.h @@ -0,0 +1,95 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/******************************************************************************** + * File: p3dHighDivPointList.h + * + * Description: Header file for the implementation of a dynamic structure + * with LIFO (Last-In-First-Out) policy (list or stack) + * containing CritPointT elements (see p3dCritPointT.h) + * Duplicate elements allowed. + * + * Interfaces: crit_point_list_init + * crit_point_list_push + * crit_point_list_pop + * crit_point_list_isempty + * crit_point_list_toarray + * + * Author: FB + * + ********************************************************************************/ +#include "p3dHighDivPointT.h" + +/* + Type definitions: +*/ + +#ifndef HIGHDIV_POINT_LIST_T_DEFINED + #define HIGHDIV_POINT_LIST_T_DEFINED + + struct highDiv_point_lelem_t { + highDiv_point_t elem; + struct highDiv_point_lelem_t *next; + }; + + typedef struct highDiv_point_lelem_t highDiv_point_list_elem_t; + + typedef highDiv_point_list_elem_t* highDiv_point_list_t; + +#endif + + + + +/* + Interfaces: +*/ + +void highDiv_point_list_init (highDiv_point_list_t *list); + +/******************************************************************************** + * Function: crit_point_list_push + * + * Description: Push the specified element into the list. + * + * Input(s): coords_list_t* - The list to extend + * coords_t - The element to push into the list + * + * Output: P3D_SUCCESS if element is successfully pushed into the list + * P3D_MEM_ERROR if there is not enough memory for the additional + * element + ********************************************************************************/ +int highDiv_point_list_push (highDiv_point_list_t *list, highDiv_point_t item); + +highDiv_point_t highDiv_point_list_pop (highDiv_point_list_t *list); + +int highDiv_point_list_isempty(highDiv_point_list_t list); + +highDiv_point_t* highDiv_point_list_toarray (highDiv_point_list_t *list, int numel ); + + + diff --git a/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointT.h b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointT.h new file mode 100644 index 0000000000000000000000000000000000000000..03614375ce5892276e14889768c9c1954edcff7c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointT.h @@ -0,0 +1,48 @@ +/***************************************************************************/ +/* (C) 2016 Elettra - Sincrotrone Trieste S.C.p.A.. All rights reserved. */ +/* */ +/* */ +/* This file is part of Pore3D, a software library for quantitative */ +/* analysis of 3D (volume) images. */ +/* */ +/* Pore3D is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation, either version 3 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* Pore3D is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */ +/* for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with Pore3D. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/***************************************************************************/ + +// +// Author: Francesco Brun +// Last modified: Sept, 28th 2016 +// + +/* + Type definitions: +*/ + +#ifndef HIGHDIV_POINT_T_DEFINED + +typedef struct { + + /* Coordinates: */ + double x; + double y; + double z; + + /* Divergence value */ + double div; + +} highDiv_point_t; + +#endif + +#define HIGHDIV_POINT_T_DEFINED \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/_p3dTime.c b/pypore3d/pypore3d/P3D_Skel/_p3dTime.c new file mode 100644 index 0000000000000000000000000000000000000000..ed1f24b9d76258df2247d00f8edbe2ff9932716c --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/_p3dTime.c @@ -0,0 +1,68 @@ +#include <stdio.h> + +#include "p3dTime.h" + +int p3dTime_min = 0; +double p3dTime_sec = 0.0; + +#ifndef _WINDOWS + //#include <sys/time.h> + + //static struct timeval p3dTime_tv; + static unsigned long p3dTime_startTime, p3dTime_crtTime; +#else + #include <windows.h> + #include <time.h> + + DWORD p3dTime_startTime, p3dTime_crtTime; +#endif + + +void p3dResetStartTime() +{ + #ifdef _WINDOWS + p3dTime_startTime = GetTickCount(); + p3dTime_crtTime = GetTickCount(); + #else + // gettimeofday(&p3dTime_tv, NULL); + // p3dTime_startTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); + #endif + + p3dTime_crtTime = p3dTime_startTime; +} + +double p3dGetElapsedTime () +{ + #ifdef _WINDOWS + p3dTime_crtTime = GetTickCount(); + #else + // gettimeofday(&p3dTime_tv, NULL); +// p3dTime_crtTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); + #endif + + // Return time in seconds: + return ((p3dTime_crtTime - p3dTime_startTime)/1000.0); +} + +int p3dGetElapsedTime_min () +{ + #ifdef _WINDOWS + p3dTime_crtTime = GetTickCount(); + #else +// gettimeofday(&p3dTime_tv, NULL); +// p3dTime_crtTime = (p3dTime_tv.tv_sec * 1000) + (p3dTime_tv.tv_usec / 1000); + #endif + + // Return time in seconds: + p3dTime_sec = ((p3dTime_crtTime - p3dTime_startTime)/1000.0); + p3dTime_min = (int) (p3dTime_sec / 60.0); + p3dTime_sec = p3dTime_sec - p3dTime_min*60.0; + + return p3dTime_min; +} + +double p3dGetElapsedTime_sec () +{ + return p3dTime_sec; +} + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dGVFSkeletonization.c b/pypore3d/pypore3d/P3D_Skel/p3dGVFSkeletonization.c new file mode 100644 index 0000000000000000000000000000000000000000..e63910b7c49c80aafa6149ce5baceab4b65fcef3 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dGVFSkeletonization.c @@ -0,0 +1,276 @@ +#include <stdlib.h> +#include <string.h> +#include <omp.h> +#include <limits.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdio.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "GVFSkeletonization/p3dGVF.h" +#include "GVFSkeletonization/p3dCriticalPoints.h" +#include "GVFSkeletonization/p3dHighDivPointList.h" +#include "GVFSkeletonization/p3dGetHighDivPoints.h" +#include "GVFSkeletonization/p3dComputeCoreSkeleton.h" +#include "GVFSkeletonization/p3dComputeHierarchicalSkeleton.h" + +#include "Common/p3dFCoordsList.h" +#include "Common/p3dThinning.h" +#include "Common/p3dUtils.h" + +int p3dGVFSkeletonization( + unsigned char* in_im, + unsigned char* skl_im, + const int dimx, + const int dimy, + const int dimz, + const double mu, + const double eps, + const double thresh, + const double scale, + int (*wr_log)(const char*, ...) + ) +{ + + int a_rad = 1; + int a_dimx, a_dimy, a_dimz; + int i, j, k; + + crit_point_list_t crit_point_list = NULL; + fcoords_list_t skel_point_list = NULL; + highDiv_point_list_t highDiv_point_list = NULL; + + int ct = 0; + + double step = STEP_SIZE; // default value + double close_dist = CLOSENESS; // default value + + fcoords_t tmp_coords; + int a, b, c; + + // Matrixes: + unsigned char* tmp_im; + float* gvf_x; + float* gvf_y; + float* gvf_z; + + // + // Initializations: + // + + double t1 = 0.0; + double t2 = 0.0; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Peforming GVF skeletonization..."); + wr_log("\tScaling factor: %0.3f.", scale); + wr_log("\tAdditional branches factor: %0.3f.", thresh); + wr_log("\tGradient Vector Flow (GVF) parameters: mu = %0.3f eps = %0.5f.", mu, eps); + wr_log("\t----"); + } + + // Init critical points list and skeleton points list: + crit_point_list_init(&crit_point_list); + fcoords_list_init(&skel_point_list); + highDiv_point_list_init(&highDiv_point_list); + + + + // + // PHASE 1 - Perform resampling (if needed): + // + + // Compute dimensions of resampled and padded volume: + a_dimx = (int) ((double) (dimx) * scale + 0.5) + a_rad * 2; + a_dimy = (int) ((double) (dimy) * scale + 0.5) + a_rad * 2; + a_dimz = (int) ((double) (dimz) * scale + 0.5) + a_rad * 2; + + // Reset output image: + memset(skl_im, 0, dimx * dimy * dimz * sizeof (unsigned char)); + + // Init gradient vector flow: + P3D_MEM_TRY(gvf_x = (float*) calloc(a_dimx * a_dimy*a_dimz, sizeof (float))); + P3D_MEM_TRY(gvf_y = (float*) calloc(a_dimx * a_dimy*a_dimz, sizeof (float))); + P3D_MEM_TRY(gvf_z = (float*) calloc(a_dimx * a_dimy*a_dimz, sizeof (float))); + + // Zero padding for temporary image (values 255 are replaced with 1): + P3D_MEM_TRY(tmp_im = (unsigned char*) calloc(a_dimx * a_dimy*a_dimz, sizeof (unsigned char))); + + //#pragma omp parallel for private(i, j) + for (k = a_rad; k < (a_dimz - a_rad); k++) + { + for (j = a_rad; j < (a_dimy - a_rad); j++) + { + for (i = a_rad; i < (a_dimx - a_rad); i++) { + a = (int) ((i - a_rad) / scale); + b = (int) ((j - a_rad) / scale); + c = (int) ((k - a_rad) / scale); + + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = (unsigned char) (in_im [ I(a, b, c, dimx, dimy) ] / 255.0); + } + } + } + + // Print elapsed time for this phase: + if (wr_log != NULL) { + t2 = p3dGetElapsedTime(); + wr_log("\tInitializations and re-scaling performed in %0.3f sec.", t2 - t1); + t1 = t2; + } + + // + // PHASE 2 - Compute gradient vector flow: + // + ct = p3dGVF(tmp_im, gvf_x, gvf_y, gvf_z, a_dimx, a_dimy, a_dimz, mu, eps); + + // Print elapsed time for this phase: + if (wr_log != NULL) { + t2 = p3dGetElapsedTime(); + wr_log("\tGradient vector flow (%d iterations) computed in %0.3f sec.", ct, t2 - t1); + t1 = t2; + } + + + // + // PHASE 3 - Assess critical points: + // + + // Get and classify critical points: + P3D_TRY(p3dGetCriticalPoints(tmp_im, gvf_x, gvf_y, gvf_z, a_dimx, a_dimy, a_dimz, &crit_point_list)); + P3D_TRY(p3dClassifyCriticalPoints(crit_point_list, gvf_x, gvf_y, gvf_z, a_dimx, a_dimy, a_dimz)); + + // Print elapsed time for this phase: + if (wr_log != NULL) { + t2 = p3dGetElapsedTime(); + wr_log("\tCritical points determined and classified in %0.3f sec.", t2 - t1); + t1 = t2; + } + + + // + // PHASE 4 - Compute core skeleton following gradient vector flow from saddle points: + // + + // Sub-voxel step-size and closeness criteria should be reduced in the case of downsampling: + if (scale < 0.0) step *= scale; + if (scale < 0.0) close_dist *= scale; + + P3D_TRY(p3dComputeCoreSkeleton(crit_point_list, &skel_point_list, gvf_x, gvf_y, gvf_z, + a_dimx, a_dimy, a_dimz, step, close_dist)); + + // Print elapsed time for this phase: + if (wr_log != NULL) { + t2 = p3dGetElapsedTime(); + wr_log("\tCore skeleton computed successfully in %0.3f sec.", t2 - t1); + t1 = t2; + } + + + // + // PHASE 5 - Add high divergence points: + // + if (fcoords_list_isempty(skel_point_list) == P3D_TRUE) { + if (wr_log != NULL) { + wr_log("\tWARNING: The core skeleton is empty!"); + } + } else if (thresh > 0.0) { + P3D_TRY(p3dGetHighDivPoints(tmp_im, gvf_x, gvf_y, gvf_z, a_dimx, a_dimy, a_dimz, thresh, &highDiv_point_list)); + P3D_TRY(p3dComputeHierarchicalSkeleton(&highDiv_point_list, &skel_point_list, gvf_x, gvf_y, gvf_z, + a_dimx, a_dimy, a_dimz, step, close_dist)); + + // Print elapsed time for this phase: + if (wr_log != NULL) { + t2 = p3dGetElapsedTime(); + wr_log("\tAdditional branches determined successfully in %0.3f sec.", t2 - t1); + t1 = t2; + } + } + + + // + // PHASE 6 - Discretize skeleton points to output matrix (paying attention to previous + // upsampling) and thinning: + // + if (fcoords_list_isempty(skel_point_list) == P3D_FALSE) { + // Perform voxelization: + while (fcoords_list_isempty(skel_point_list) == P3D_FALSE) { + tmp_coords = fcoords_list_pop(&skel_point_list); + + a = (int) ((tmp_coords.x + 0.5 - a_rad) / scale); + b = (int) ((tmp_coords.y + 0.5 - a_rad) / scale); + c = (int) ((tmp_coords.z + 0.5 - a_rad) / scale); + + skl_im[ I(a, b, c, dimx, dimy) ] = OBJECT; + } + + // Perform a thinning procedure in order to get a one-voxel thick output skeleton: + p3dThinning(skl_im, dimx, dimy, dimz); + + // Print elapsed time for this phase: + if (wr_log != NULL) { + t2 = p3dGetElapsedTime(); + wr_log("\tRe-scaling and voxelization performed in %0.3f sec.", t2 - t1); + t1 = t2; + + // Print total time: + wr_log("Pore3D - GVF skeleton computed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + //wr_log("Pore3D - GVF skeleton computed successfully in %0.3f sec.", p3dGetElapsedTime()); + } + } + + + // + // Release resources: + // + if (tmp_im != NULL) free(tmp_im); + if (gvf_x != NULL) free(gvf_x); + if (gvf_y != NULL) free(gvf_y); + if (gvf_z != NULL) free(gvf_z); + + // Ensure lists are deleted: + while (crit_point_list_isempty(crit_point_list) == P3D_FALSE) { + crit_point_list_pop(&crit_point_list); + } + while (fcoords_list_isempty(skel_point_list) == P3D_FALSE) { + fcoords_list_pop(&skel_point_list); + } + while (highDiv_point_list_isempty(highDiv_point_list) == P3D_FALSE) { + highDiv_point_list_pop(&highDiv_point_list); + } + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + if (gvf_x != NULL) free(gvf_x); + if (gvf_y != NULL) free(gvf_y); + if (gvf_z != NULL) free(gvf_z); + + // Ensure lists are deleted: + while (crit_point_list_isempty(crit_point_list) == P3D_FALSE) { + crit_point_list_pop(&crit_point_list); + } + while (fcoords_list_isempty(skel_point_list) == P3D_FALSE) { + fcoords_list_pop(&skel_point_list); + } + while (highDiv_point_list_isempty(highDiv_point_list) == P3D_FALSE) { + highDiv_point_list_pop(&highDiv_point_list); + } + + return P3D_ERROR; + +} \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/p3dIterativeSkeletonPruning.c b/pypore3d/pypore3d/P3D_Skel/p3dIterativeSkeletonPruning.c new file mode 100644 index 0000000000000000000000000000000000000000..29bdb2ac33d0bdecef3aa1e00ccb5eb271d80a11 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dIterativeSkeletonPruning.c @@ -0,0 +1,246 @@ +#include <stdlib.h> +#include <omp.h> +#include <string.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dUtils.h" + +#define VISITED 128 + +int p3dIterativeSkeletonPruning( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + const int thresh, + int (*wr_log)(const char*, ...) + ) +{ + coords_list_t list; // FIFO data structure for coords storage + coords_t coords; // Current coords + + int i,j,k; + int a,b,c; + int ct; + int pruned; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary input and output: + unsigned char* tmp_im; + unsigned char* tmp_im2; + + // Counters: + int neigh, length, noMoreChanges, curr_th; + + + // Start tracking computational time: + if (wr_log != NULL) + { + p3dResetStartTime(); + wr_log ("Pore3D - Performing iterative skeleton pruning..." ); + wr_log ("\tPruning threshold: %d voxels.", thresh ); + } + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad*2; + a_dimy = dimy + a_rad*2; + a_dimz = dimz + a_rad*2; + + // Initialize input: + P3D_MEM_TRY( tmp_im = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + P3D_TRY( p3dZeroPadding3D_uchar2uchar ( in_im, tmp_im, dimx, dimy, dimz, a_rad ) ); + + P3D_MEM_TRY( tmp_im2 = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + memcpy ( tmp_im2, tmp_im, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + + + // Initialize number of pruned objects: + pruned = 0; + + // Loop until user-specified thresh: + for ( curr_th = 1; curr_th <= thresh; curr_th++ ) + { + // Set the flag for iterative version of pruning: + noMoreChanges = 1; + + // Loop for iterations: + while ( noMoreChanges > 0) + { + // Clear the flag for iterations (it will be re-set if pruning occurs): + noMoreChanges = 0; + + // Volume scanning: + #pragma omp parallel for private(a, b, i, j, k, ct, coords, list, neigh, length) reduction ( + : noMoreChanges ) + for( c = a_rad; c < (a_dimz - a_rad); c++ ) { + for( b = a_rad; b < (a_dimy - a_rad); b++ ) { + for( a = a_rad; a < (a_dimx - a_rad); a++ ) { + // If we're on a skeleton voxel: + if ( tmp_im[ I( a, b, c, a_dimx, a_dimy ) ] == OBJECT ) + { + // Check Neighborhood: + ct = countNeighbors ( tmp_im, a_dimx, a_dimy, a_dimz, a, b, c ); + + // Is an end point? + if (ct == 1) + { + // Initialize variables: + coords_list_init(&list); + + // End point found: + coords.x = a; + coords.y = b; + coords.z = c; + + // Start tracking length: + length = 0; + + do + { + // Push the voxel into list: + coords_list_push(&list, coords); + + // Get coords: + k = coords.z; + j = coords.y; + i = coords.x; + + // Temporary delete voxel + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = BACKGROUND; + + // Determine number of neighbors: + neigh = findNeighbor(tmp_im, a_dimx, a_dimy, a_dimz, i, j, k, &coords); + + // Increment counter of branch length: + length++; + + } while ( neigh == 1 ); + + // At this point, we're on last voxel of node-to-end branch (ct > 1) or we + // completely scanned a end-to-end branch (ct == 0). In the first case we + // need to take care whether last voxel is a simple point or not: + if ( neigh > 1 ) + { + if ( isSimplePoint(tmp_im, a_dimx, a_dimy, a_dimz, i, j, k ) == P3D_FALSE ) + { + // Reset voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = OBJECT; + + // Remove coordinates from the list: + coords = coords_list_pop(&list); + + // Increment counter of branch length: + length--; + } + } + + + // Check if scanned branch needs to be pruned (negative condition): + if ( length > curr_th ) + { + // Restore branch: + while( coords_list_isempty(list) == P3D_FALSE ) + { + // Get coordinates from the list: + coords = coords_list_pop(&list); + + k = coords.z; + j = coords.y; + i = coords.x; + + // Re-assign voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = OBJECT; // NODE-TO-END Label + } + + // Set the endpoint as VISITED: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = VISITED; // END-POINT Label + } + else + { + // Changes performed: + noMoreChanges++; + + // Count the branches pruned: + pruned++; + + // Delete the branch from tmp2 and restore it from tmp1: + while( coords_list_isempty(list) == P3D_FALSE ) + { + // Get coordinates from the list: + coords = coords_list_pop(&list); + + k = coords.z; + j = coords.y; + i = coords.x; + + // Delete the voxel: + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = BACKGROUND; + + // Re-assign voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = OBJECT; + } + } + } // end of cycle on each endpoint + + // Is an isolated voxel? + else if (ct == 0) + { + // Isolated voxel removal: + tmp_im2[ I(a, b, c, a_dimx, a_dimy) ] = BACKGROUND; + } + } + } + } + } + + + // Copy tmp_im2 into tmp_im: + memcpy ( tmp_im, tmp_im2, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + } + } + + + // Crop output: + P3D_TRY( p3dCrop3D_uchar2uchar ( tmp_im2, out_im, a_dimx, a_dimy, a_dimz, a_rad ) ); + + // Print elapsed time (if required): + if (wr_log != NULL) + { + wr_log ("\tNumber of pruned branches: %d.", pruned ); + wr_log ("Pore3D - Iterative skeleton pruning performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if ( tmp_im != NULL ) free(tmp_im); + if ( tmp_im2 != NULL ) free(tmp_im2); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) + { + wr_log ("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free (tmp_im); + if (tmp_im2 != NULL) free (tmp_im2); + + + return P3D_ERROR; + +} + + + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dLKCSkeletonization.c b/pypore3d/pypore3d/P3D_Skel/p3dLKCSkeletonization.c new file mode 100644 index 0000000000000000000000000000000000000000..1777945b0a1cd0f3c2fbf24d3b3ed129e41e37fe --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dLKCSkeletonization.c @@ -0,0 +1,513 @@ +#include <stdlib.h> +#include <omp.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dCoordsList.h" +#include "Common/p3dUtils.h" + + +void fillEulerLUT ( int *LUT ) +{ + LUT[1] = 1; + LUT[3] = -1; + LUT[5] = -1; + LUT[7] = 1; + LUT[9] = -3; + LUT[11] = -1; + LUT[13] = -1; + LUT[15] = 1; + LUT[17] = -1; + LUT[19] = 1; + LUT[21] = 1; + LUT[23] = -1; + LUT[25] = 3; + LUT[27] = 1; + LUT[29] = 1; + LUT[31] = -1; + LUT[33] = -3; + LUT[35] = -1; + LUT[37] = 3; + LUT[39] = 1; + LUT[41] = 1; + LUT[43] = -1; + LUT[45] = 3; + LUT[47] = 1; + LUT[49] = -1; + LUT[51] = 1; + + LUT[53] = 1; + LUT[55] = -1; + LUT[57] = 3; + LUT[59] = 1; + LUT[61] = 1; + LUT[63] = -1; + LUT[65] = -3; + LUT[67] = 3; + LUT[69] = -1; + LUT[71] = 1; + LUT[73] = 1; + LUT[75] = 3; + LUT[77] = -1; + LUT[79] = 1; + LUT[81] = -1; + LUT[83] = 1; + LUT[85] = 1; + LUT[87] = -1; + LUT[89] = 3; + LUT[91] = 1; + LUT[93] = 1; + LUT[95] = -1; + LUT[97] = 1; + LUT[99] = 3; + LUT[101] = 3; + LUT[103] = 1; + + LUT[105] = 5; + LUT[107] = 3; + LUT[109] = 3; + LUT[111] = 1; + LUT[113] = -1; + LUT[115] = 1; + LUT[117] = 1; + LUT[119] = -1; + LUT[121] = 3; + LUT[123] = 1; + LUT[125] = 1; + LUT[127] = -1; + LUT[129] = -7; + LUT[131] = -1; + LUT[133] = -1; + LUT[135] = 1; + LUT[137] = -3; + LUT[139] = -1; + LUT[141] = -1; + LUT[143] = 1; + LUT[145] = -1; + LUT[147] = 1; + LUT[149] = 1; + LUT[151] = -1; + LUT[153] = 3; + LUT[155] = 1; + + LUT[157] = 1; + LUT[159] = -1; + LUT[161] = -3; + LUT[163] = -1; + LUT[165] = 3; + LUT[167] = 1; + LUT[169] = 1; + LUT[171] = -1; + LUT[173] = 3; + LUT[175] = 1; + LUT[177] = -1; + LUT[179] = 1; + LUT[181] = 1; + LUT[183] = -1; + LUT[185] = 3; + LUT[187] = 1; + LUT[189] = 1; + LUT[191] = -1; + LUT[193] = -3; + LUT[195] = 3; + LUT[197] = -1; + LUT[199] = 1; + LUT[201] = 1; + LUT[203] = 3; + LUT[205] = -1; + LUT[207] = 1; + + LUT[209] = -1; + LUT[211] = 1; + LUT[213] = 1; + LUT[215] = -1; + LUT[217] = 3; + LUT[219] = 1; + LUT[221] = 1; + LUT[223] = -1; + LUT[225] = 1; + LUT[227] = 3; + LUT[229] = 3; + LUT[231] = 1; + LUT[233] = 5; + LUT[235] = 3; + LUT[237] = 3; + LUT[239] = 1; + LUT[241] = -1; + LUT[243] = 1; + LUT[245] = 1; + LUT[247] = -1; + LUT[249] = 3; + LUT[251] = 1; + LUT[253] = 1; + LUT[255] = -1; +} + +/** + * Check for Euler invariance. (see [Lee94]) + */ +int isEulerInvariant( + unsigned char* in_im, // IN: Input (binary) original volume + const int dimx, + const int dimy, + const int dimz, + const int x, + const int y, + const int z, + const int *LUT + ) +{ + // calculate Euler characteristic for each octant and sum up + int EulerChar = 0; + unsigned char n; + + // copy neighbors for labeling + int neighbors[27]; + int a,b,c; + int i = 0; + + // Fill the neieghbors: + for ( c = (z - 1); c <= (z + 1); c++ ) { + for ( b = (y - 1); b <= (y + 1); b++ ) { + for ( a = (x - 1); a <= (x + 1); a++ ) { + neighbors[i++] = (in_im[ I( a, b, c, dimx, dimy ) ] == OBJECT) ? 1 : 0; + } + } + } + + + // Octant SWU + n = 1; + if( neighbors[24]==1 ) + n |= 128; + if( neighbors[25]==1 ) + n |= 64; + if( neighbors[15]==1 ) + n |= 32; + if( neighbors[16]==1 ) + n |= 16; + if( neighbors[21]==1 ) + n |= 8; + if( neighbors[22]==1 ) + n |= 4; + if( neighbors[12]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant SEU + n = 1; + if( neighbors[26]==1 ) + n |= 128; + if( neighbors[23]==1 ) + n |= 64; + if( neighbors[17]==1 ) + n |= 32; + if( neighbors[14]==1 ) + n |= 16; + if( neighbors[25]==1 ) + n |= 8; + if( neighbors[22]==1 ) + n |= 4; + if( neighbors[16]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant NWU + n = 1; + if( neighbors[18]==1 ) + n |= 128; + if( neighbors[21]==1 ) + n |= 64; + if( neighbors[9]==1 ) + n |= 32; + if( neighbors[12]==1 ) + n |= 16; + if( neighbors[19]==1 ) + n |= 8; + if( neighbors[22]==1 ) + n |= 4; + if( neighbors[10]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant NEU + n = 1; + if( neighbors[20]==1 ) + n |= 128; + if( neighbors[23]==1 ) + n |= 64; + if( neighbors[19]==1 ) + n |= 32; + if( neighbors[22]==1 ) + n |= 16; + if( neighbors[11]==1 ) + n |= 8; + if( neighbors[14]==1 ) + n |= 4; + if( neighbors[10]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant SWB + n = 1; + if( neighbors[6]==1 ) + n |= 128; + if( neighbors[15]==1 ) + n |= 64; + if( neighbors[7]==1 ) + n |= 32; + if( neighbors[16]==1 ) + n |= 16; + if( neighbors[3]==1 ) + n |= 8; + if( neighbors[12]==1 ) + n |= 4; + if( neighbors[4]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant SEB + n = 1; + if( neighbors[8]==1 ) + n |= 128; + if( neighbors[7]==1 ) + n |= 64; + if( neighbors[17]==1 ) + n |= 32; + if( neighbors[16]==1 ) + n |= 16; + if( neighbors[5]==1 ) + n |= 8; + if( neighbors[4]==1 ) + n |= 4; + if( neighbors[14]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant NWB + n = 1; + if( neighbors[0]==1 ) + n |= 128; + if( neighbors[9]==1 ) + n |= 64; + if( neighbors[3]==1 ) + n |= 32; + if( neighbors[12]==1 ) + n |= 16; + if( neighbors[1]==1 ) + n |= 8; + if( neighbors[10]==1 ) + n |= 4; + if( neighbors[4]==1 ) + n |= 2; + EulerChar += LUT[n]; + // Octant NEB + n = 1; + if( neighbors[2]==1 ) + n |= 128; + if( neighbors[1]==1 ) + n |= 64; + if( neighbors[11]==1 ) + n |= 32; + if( neighbors[10] == 1 ) + n |= 16; + if( neighbors[5] == 1 ) + n |= 8; + if( neighbors[4] == 1 ) + n |= 4; + if( neighbors[14] == 1 ) + n |= 2; + EulerChar += LUT[n]; + + if( EulerChar == 0 ) + return P3D_TRUE; + else + return P3D_FALSE; +} + +int p3dLKCSkeletonization( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) +{ + unsigned char* tmp_im = NULL; + + // Define Euler LUT: + int* eulerLUT = NULL; + + + // Padding/cropping size and dimensions + const int a_rad = 1; + const int a_dimx = dimx + a_rad*2; + const int a_dimy = dimy + a_rad*2; + const int a_dimz = dimz + a_rad*2; + + int unchangedBorders; + int isBorderPoint; + int currentBorder; + int noChange; + + int i,j,k; + int a,b,c; + + coords_t simple_point; + coords_list_t simple_point_list; + + + // Start tracking computational time: + if (wr_log != NULL) + { + p3dResetStartTime(); + wr_log ("Pore3D - Performing LKC skeletonization..." ); + } + + // Init output voume with input volume values zero padded: + P3D_MEM_TRY( eulerLUT = (int*) calloc(256,sizeof(int)) ); + P3D_MEM_TRY( tmp_im = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + P3D_TRY( p3dZeroPadding3D_uchar2uchar ( in_im, tmp_im, dimx, dimy, dimz, a_rad ) ); + + // Prepare Euler LUT: + fillEulerLUT( eulerLUT ); + + + // Loop through the image several times until there is no change. + + unchangedBorders = 0; + + // Loop until no change for all the six border types: + while( unchangedBorders < 6 ) + { + unchangedBorders = 0; + + #pragma omp parallel for private(i, j, k, simple_point_list, isBorderPoint, a, b, c, simple_point, noChange) reduction ( + : unchangedBorders) + for( currentBorder = 1; currentBorder <= 6; currentBorder++) + { + coords_list_init ( &simple_point_list ); + + // Loop through the image: + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) + { + // Check if point is foreground: + if ( tmp_im[ I(i,j,k,a_dimx,a_dimy)] == BACKGROUND) + { + continue; + } + + // Check 6-neighbors if point is a border point of type currentBorder + isBorderPoint = P3D_FALSE; + if( (currentBorder == 1) && ( tmp_im[ I(i - 1,j,k,a_dimx,a_dimy)] == BACKGROUND ) ) + isBorderPoint = P3D_TRUE; + if( (currentBorder == 2) && ( tmp_im[ I(i + 1,j,k,a_dimx,a_dimy)] == BACKGROUND ) ) + isBorderPoint = P3D_TRUE; + if( (currentBorder == 3) && ( tmp_im[ I(i,j - 1,k,a_dimx,a_dimy)] == BACKGROUND ) ) + isBorderPoint = P3D_TRUE; + if( (currentBorder == 4) && ( tmp_im[ I(i,j + 1,k,a_dimx,a_dimy)] == BACKGROUND ) ) + isBorderPoint = P3D_TRUE; + if( (currentBorder == 5) && ( tmp_im[ I(i,j,k - 1,a_dimx,a_dimy)] == BACKGROUND ) ) + isBorderPoint = P3D_TRUE; + if( (currentBorder == 6) && ( tmp_im[ I(i,j,k + 1,a_dimx,a_dimy)] == BACKGROUND ) ) + isBorderPoint = P3D_TRUE; + + if( isBorderPoint == P3D_FALSE) + { + continue; // current point is not deletable + } + + // Check if point is the end of an arc: + if ( countNeighbors( tmp_im, a_dimx, a_dimy, a_dimz, i, j, k ) == 1 ) + { + continue; + } + + // Check if point is Euler invariant: + if( isEulerInvariant( tmp_im, a_dimx, a_dimy, a_dimz, i, j, k, eulerLUT ) == P3D_FALSE) + { + continue; // current point is not deletable + } + + // Check if point is simple: + if( isSimplePoint( tmp_im, a_dimx, a_dimy, a_dimz, i, j, k ) == P3D_FALSE ) + { + continue; // current point is not deletable + } + + // Add current simple border point to a list for + // further sequential re-checking: + simple_point.x = i; + simple_point.y = j; + simple_point.z = k; + + coords_list_push ( &simple_point_list, simple_point ); + + } // end image iteration loop + + // sequential re-checking to preserve connectivity when + // deleting in a parallel way + noChange = P3D_TRUE; + + while ( coords_list_isempty( simple_point_list ) == P3D_FALSE ) + { + // 1. Set simple border point to BACKGROUND: + simple_point = coords_list_pop ( &simple_point_list); + + a = simple_point.x; + b = simple_point.y; + c = simple_point.z; + + tmp_im[ I(a,b,c,a_dimx,a_dimy) ] = BACKGROUND; + + // 2. Check if neighborhood is still connected: + if ( isSimplePoint ( tmp_im, a_dimx, a_dimy, a_dimz, a, b, c ) == P3D_FALSE ) + { + // We cannot delete current point, so reset: + tmp_im[ I(a,b,c,a_dimx,a_dimy) ] = OBJECT; + } + else + { + noChange = P3D_FALSE; + } + } + + if( noChange == P3D_TRUE ) + unchangedBorders++; + + } // end currentBorder for loop + } // end unchangedBorders while loop + + + // Crop output: + P3D_TRY( p3dCrop3D_uchar2uchar ( tmp_im, out_im, a_dimx, a_dimy, a_dimz, a_rad ) ); + + + + // Print elapsed time (if required): + if (wr_log != NULL) + { + wr_log ("Pore3D - LKC skeletonization performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if ( eulerLUT != NULL ) free ( eulerLUT ); + if ( tmp_im != NULL ) free( tmp_im ); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) + { + wr_log ("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if ( eulerLUT != NULL ) free ( eulerLUT ); + if ( tmp_im != NULL ) free(tmp_im); + + + return P3D_ERROR; + +} + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dSimpleSkeletonPruning.c b/pypore3d/pypore3d/P3D_Skel/p3dSimpleSkeletonPruning.c new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea0b138bed768958d3dc4ce47c5ffd9226e2d --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dSimpleSkeletonPruning.c @@ -0,0 +1,223 @@ +#include <stdlib.h> +#include <omp.h> +#include <string.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dUtils.h" + +#define VISITED 128 + + +int p3dSimpleSkeletonPruning( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + const int thresh, + int (*wr_log)(const char*, ...) + ) +{ + coords_list_t list; // FIFO data structure for coords storage + coords_t coords; // Current coords + + int i,j,k; + int a,b,c; + int ct; + int pruned; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary input and output: + unsigned char* tmp_im; + unsigned char* tmp_im2; + + // Counters: + int neigh, length; + + + // Start tracking computational time: + if (wr_log != NULL) + { + p3dResetStartTime(); + wr_log ("Pore3D - Performing simple skeleton pruning..." ); + wr_log ("\tPruning threshold: %d voxels.", thresh ); + } + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad*2; + a_dimy = dimy + a_rad*2; + a_dimz = dimz + a_rad*2; + + // Initialize input: + P3D_MEM_TRY( tmp_im = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + P3D_TRY( p3dZeroPadding3D_uchar2uchar ( in_im, tmp_im, dimx, dimy, dimz, a_rad ) ); + + P3D_MEM_TRY( tmp_im2 = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + memcpy ( tmp_im2, tmp_im, a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ); + + // Initialize number of pruned objects: + pruned = 0; + + // Volume scanning: + #pragma omp parallel for private(a, b, i, j, k, ct, coords, list, neigh, length) + for( c = a_rad; c < (a_dimz - a_rad); c++ ) + for( b = a_rad; b < (a_dimy - a_rad); b++ ) + for( a = a_rad; a < (a_dimx - a_rad); a++ ) + { + // If we're on a skeleton voxel: + if ( tmp_im[ I( a, b, c, a_dimx, a_dimy ) ] == OBJECT ) + { + // Check Neighborhood: + ct = countNeighbors ( tmp_im, a_dimx, a_dimy, a_dimz, a, b, c ); + + // Is an end point? + if (ct == 1) + { + // Initialize variables: + coords_list_init(&list); + + // End point found: + coords.x = a; + coords.y = b; + coords.z = c; + + // Start tracking length: + length = 0; + + do + { + // Push the voxel into list: + coords_list_push(&list, coords); + + // Get coords: + k = coords.z; + j = coords.y; + i = coords.x; + + // Temporary delete voxel + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = BACKGROUND; + + // Determine number of neighbors: + neigh = findNeighbor(tmp_im, a_dimx, a_dimy, a_dimz, i, j, k, &coords); + + // Increment counter of branch length: + length++; + + } while ( neigh == 1 ); + + // At this point, we're on last voxel of node-to-end branch (ct > 1) or we + // completely scanned a end-to-end branch (ct == 0). In the first case we + // need to take care whether last voxel is a simple point or not: + if ( neigh > 1 ) + { + if ( isSimplePoint(tmp_im, a_dimx, a_dimy, a_dimz, i, j, k ) == P3D_FALSE ) + { + // Reset voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = OBJECT; + + // Remove coordinates from the list: + coords = coords_list_pop(&list); + + // Increment counter of branch length: + length--; + } + } + + + // Check if scanned branch needs to be pruned (negative condition): + if ( length > thresh ) + { + // Restore branch: + while(coords_list_isempty(list) == P3D_FALSE) + { + // Get coordinates from the list: + coords = coords_list_pop(&list); + + k = coords.z; + j = coords.y; + i = coords.x; + + // Re-assign voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = OBJECT; // NODE-TO-END Label + } + + // Set the endpoint as VISITED: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = VISITED; // END-POINT Label + } + else + { + // Delete the branch from tmp2 and restore it from tmp1: + while(coords_list_isempty(list) == P3D_FALSE) + { + // Get coordinates from the list: + coords = coords_list_pop(&list); + + k = coords.z; + j = coords.y; + i = coords.x; + + // Delete the voxel: + tmp_im2[ I(i, j, k, a_dimx, a_dimy) ] = BACKGROUND; + + // Re-assign voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = OBJECT; + } + + // Count the branches pruned: + pruned++; + } + } // end of cycle on each endpoint + + // Is an isolated voxel? + else if (ct == 0) + { + // Isolated voxel removal: + tmp_im2[ I(a, b, c, a_dimx, a_dimy) ] = BACKGROUND; + } + } + } + + + // Crop output: + P3D_TRY( p3dCrop3D_uchar2uchar ( tmp_im2, out_im, a_dimx, a_dimy, a_dimz, a_rad ) ); + + // Print elapsed time (if required): + if (wr_log != NULL) + { + wr_log ("\tNumber of pruned branches: %d.", pruned ); + wr_log ("Pore3D - Simple skeleton pruning performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if ( tmp_im != NULL ) free(tmp_im); + if ( tmp_im2 != NULL ) free(tmp_im2); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) + { + wr_log ("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free (tmp_im); + if (tmp_im2 != NULL) free (tmp_im2); + + + return P3D_ERROR; +} + + + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dSkel.def b/pypore3d/pypore3d/P3D_Skel/p3dSkel.def new file mode 100644 index 0000000000000000000000000000000000000000..d0539b6d5c45b2f946d0827d4d5cdcf385921007 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dSkel.def @@ -0,0 +1,16 @@ +LIBRARY P3DSKEL +EXPORTS + p3dGVFSkeletonization @1 + p3dIterativeSkeletonPruning @2 + p3dLKCSkeletonization @3 + p3dSimpleSkeletonPruning @4 + p3dSkeletonAnalysis @5 + p3dSkeletonAnalysisFeasibility @6 + p3dSkeletonLabeling @7 + p3dThinningSkeletonization @8 + p3dUltimateSkeletonPruning @9 + + + + + \ No newline at end of file diff --git a/pypore3d/pypore3d/P3D_Skel/p3dSkel.h b/pypore3d/pypore3d/P3D_Skel/p3dSkel.h new file mode 100644 index 0000000000000000000000000000000000000000..6da5ed4765c3a819a05bcb035dbc7acf6a68edd7 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dSkel.h @@ -0,0 +1,218 @@ +#ifdef __cplusplus +extern "C" { +#endif + + + /* + Constants: + */ +#ifndef P3D_SKEL_DEFINED + #define P3D_SKEL_DEFINED + + #define P3D_FALSE -1 + #define P3D_TRUE 1 + + #define P3D_ERROR 0 + #define P3D_MEM_ERROR NULL /* Leave it NULL for simplify tests */ + #define P3D_SUCCESS 2 /* Any number */ + + #define BACKGROUND 0 + #define OBJECT UCHAR_MAX + + // Skeleton labels on OUT skeleton: + #define NODE_LABEL 1 + #define END_LABEL 2 + #define ISOLATED_LABEL 3 + #define NODETONODE_LABEL 4 + #define NODETOEND_LABEL 5 + #define ENDTOEND_LABEL 6 + +#endif + + /* + Macros: + */ + +#ifndef P3D_SKEL_MACROS + #define P3D_SKEL_MACROS + + #define I(i,j,k,N,M) ( (j)*(N) + (i) + (k)*(N)*(M) ) + #define I2(i,j,N) ( (j)*(N) + (i) ) + #define MIN(x,y) (((x) < (y))?(x):(y)) + #define MAX(x,y) (((x) > (y))?(x):(y)) + + /* A sort of TRY-CATCH constructor: */ + #define P3D_MEM_TRY( function ) if ( ((function) == P3D_MEM_ERROR) ) { goto MEM_ERROR; } + #define P3D_TRY( function ) if ( ((function) == P3D_ERROR) ) { goto MEM_ERROR; } + +#endif + +#ifndef P3D_SKEL_STRUCTS_DEFINED +#define P3D_SKEL_STRUCTS_DEFINED + + // Struct for results of skeleton analysis: + struct SkeletonStats { + + // Connectivity indexes: + double ConnectivityDensity; + int* CoordinationNumber; + + // END points: + unsigned short End_Counter; + double* End_Width; + + // END-TO-END branches: + unsigned short EndToEnd_Counter; + double* EndToEnd_Length; + double* EndToEnd_MaxWidth; // Max thickness + double* EndToEnd_MeanWidth; // Mean thickness + double* EndToEnd_MinWidth; // Throat size + + // NODE-TO-END branches: + unsigned short NodeToEnd_Counter; + double* NodeToEnd_Length; + double* NodeToEnd_MaxWidth; // Max thickness + double* NodeToEnd_MeanWidth; // Mean thickness + double* NodeToEnd_MinWidth; // Throat size + + // NODE-TO-NODE branches: + unsigned short NodeToNode_Counter; + double* NodeToNode_Length; + double* NodeToNode_MaxWidth; // Max thickness + double* NodeToNode_MeanWidth; // Mean thickness + double* NodeToNode_MinWidth; // Throat size + + // NODE points: + unsigned short Node_Counter; + double* Node_Width; + + // Tortuosity indexes: + /*unsigned short Tort_Counter; + double* Tort_X; + double* Tort_Y; + double* Tort_Z;*/ + }; + +#endif + + int p3dGVFSkeletonization ( + unsigned char* in_im, + unsigned char* skl_im, + const int dimx, + const int dimy, + const int dimz, + const double mu, + const double eps, + const double thresh, + const double scale, + int (*wr_log)(const char*, ...) + ); + + int p3dThinningSkeletonization( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ); + + int p3dLKCSkeletonization( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ); + + int p3dSimpleSkeletonPruning( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + const int thresh, + int (*wr_log)(const char*, ...) + ); + + int p3dIterativeSkeletonPruning( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + const int thresh, + int (*wr_log)(const char*, ...) + ); + + int p3dUltimateSkeletonPruning( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + const int iterative, + int (*wr_log)(const char*, ...) + ); + + int p3dSkeletonLabeling ( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ); + + int p3dSkeletonAnalysis( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned char* skl_im, // IN: Input (binary) skeleton of the segmented volume + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + unsigned char* nodes_im, // OUT: Image with maximal balls on skeleton node points + unsigned char* pores_im, // OUT: Image with maximal balls on pores + unsigned char* ends_im, // OUT: Image with maximal balls on skeleton end points + unsigned char* throats_im, // OUT: Image with maximal balls on skeleton throats + const int dimx, + const int dimy, + const int dimz, + const double merging_factor, + const int tortuosity_depth, + const double voxelsize, // IN: voxel resolution + int (*wr_log)(const char*, ...) + ); +/* // amal + int p3dSkeletonAnalysis_2( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned char* skl_im, // IN: Input (binary) skeleton of the segmented volume + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + unsigned char* nodes_im, // OUT: Image with maximal balls on skeleton node points + unsigned char* pores_im, // OUT: Image with maximal balls on pores + unsigned char* ends_im, // OUT: Image with maximal balls on skeleton end points + unsigned char* throats_im, // OUT: Image with maximal balls on skeleton throats + const int dimx, + const int dimy, + const int dimz, + const double merging_factor, + const int tortuosity_depth, + const double voxelsize, // IN: voxel resolution + int (*wr_log)(const char*, ...) + ); +*/ + int p3dSkeletonAnalysisFeasibility ( + unsigned char* in_im, // IN: binary volume + unsigned char* sk_im, // IN: skeleton mask + double* ratio, // OUT: percentage of total pore space occupied by the skeleton. + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ); + +#ifdef __cplusplus +} +#endif + + + + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dSkeletonAnalysis.c b/pypore3d/pypore3d/P3D_Skel/p3dSkeletonAnalysis.c new file mode 100644 index 0000000000000000000000000000000000000000..244d733c66145eac1e41a2f5e9c5925a37fba843 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dSkeletonAnalysis.c @@ -0,0 +1,2619 @@ +#include <omp.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <stdio.h> + +#include "p3dSkel.h" +#include "p3dTime.h" +//#include "p3dGraph.h" + +#include "Common/p3dBoundingBoxList.h" +#include "Common/p3dConnectedComponentsLabeling.h" +#include "Common/p3dSquaredEuclideanDT.h" +#include "Common/p3dUtils.h" +#include "Common/p3dThinning.h" + +int __p3dTmpWriteRaw8( + unsigned char* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz + ) { + FILE* fvol; + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + printf("Cannot open output file %s.", filename); + in_im = NULL; + + return P3D_ERROR; + } + + /* Write raw data to file: */ + fwrite(in_im, sizeof (unsigned char), dimx * dimy*dimz, fvol); + + /* Close file handler: */ + fclose(fvol); + + return P3D_SUCCESS; +} + +short _EndianSwapSignedShort(short s) { + unsigned char b1, b2; + + b1 = s & 255; + b2 = (s >> 8) & 255; + + return (b1 << 8) +b2; +} + +unsigned short _EndianSwapUnsignedShort(unsigned short s) { + unsigned char b1, b2; + + b1 = s & 255; + b2 = (s >> 8) & 255; + + return (b1 << 8) +b2; +} + +int __p3dTmpWriteRaw16( + unsigned short* in_im, + char* filename, + const int dimx, + const int dimy, + const int dimz, + const int flagLittle, + const int flagSigned, + int (*wr_log)(const char*, ...), + int (*wr_progress)(const int, ...) + ) { + FILE* fvol; + short* s_tmp_im = NULL; + unsigned short* us_tmp_im = NULL; + int ct; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Writing 16-bit RAW file %s ...", filename); + if (flagSigned == P3D_TRUE) + wr_log("\tSigned/Unsigned: Signed."); + else + wr_log("\tSigned/Unsigned: Unsigned."); + if (flagLittle == P3D_TRUE) + wr_log("\tLittle/Big Endian: Little."); + else + wr_log("\tLittle/Big Endian: Big."); + } + + /* Get a handler for the input file */ + if ((fvol = fopen(filename, "wb")) == NULL) { + wr_log("Pore3D - IO error: cannot open output file %s. Program will exit.", filename); + in_im = NULL; + + return P3D_ERROR; + } + + /* Read data signed/unsigned: */ + if (flagSigned == P3D_TRUE) { + s_tmp_im = (short*) malloc(dimx * dimy * dimz * sizeof (short)); + + /* Convert to signed: */ + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (flagLittle == P3D_FALSE) { + s_tmp_im[ct] = _EndianSwapSignedShort((short) (in_im[ct] - USHRT_MAX / 2)); + } else { + s_tmp_im[ct] = (short) (in_im[ct] - USHRT_MAX / 2); + } + } + + /* Write raw data to file: */ + //fwrite(s_tmp_im, sizeof (short), dimx*dimy, fvol); + if (fwrite(s_tmp_im, sizeof (short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_ERROR; + } + + /* Free: */ + free(s_tmp_im); + } else { + /* Swap endian if necessary: */ + if (flagLittle == P3D_FALSE) { + us_tmp_im = (unsigned short*) malloc(dimx * dimy * dimz * sizeof (unsigned short)); + + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + us_tmp_im[ct] = _EndianSwapUnsignedShort(in_im[ct]); + } + + //fwrite(us_tmp_im, sizeof (unsigned short), dimx*dimy, fvol); + if (fwrite(us_tmp_im, sizeof (unsigned short), dimx * dimy * dimz, fvol) < (dimx * dimy * dimz)) { + wr_log("Pore3D - IO error: error on writing file %s. Program will exit.", filename); + + return P3D_ERROR; + } + + free(us_tmp_im); + } else { + fwrite(in_im, sizeof (unsigned short), dimx * dimy * dimz, fvol); + } + } + + /* Close file handler: */ + fclose(fvol); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - RAW file written successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + return P3D_SUCCESS; +} + +/*float _dijsktra(float* cost, int dim, int source, int target) { + float* dist = NULL; + int* prev = NULL; + int* selected = NULL; + char* path = NULL; + + float min, d, out; + int i, m, start, ct; + + + P3D_TRY(dist = (float*) calloc(dim, sizeof (float))); + P3D_TRY(prev = (int*) calloc(dim, sizeof (int))); + P3D_TRY(selected = (int*) calloc(dim, sizeof (int))); + P3D_TRY(path = (char*) calloc(dim, sizeof (char))); + + for (i = 0; i < dim; i++) { + dist[i] = (float) _DIJKSTRA_IN; + prev[i] = (float) _DIJKSTRA_IN; + } + start = source; + selected[start] = 1; + dist[start] = 0.0; + + //while( selected[target] == 0 ) + ct = 0; + // To avoid infinite loop in case of "imperfect network" + while ((start != target) && (ct < (2 * dim))) { + min = (float) _DIJKSTRA_IN; + m = 0; + for (i = 0; i < dim; i++) { + if (selected[i] == 0) { + d = dist[start] + cost[ I2(start, i, dim) ]; + if (d < dist[i]) { + dist[i] = d; + prev[i] = start; + } + if (min > dist[i]) { + min = dist[i]; + m = i; + } + } + } + start = m; + selected[start] = 1; + ct++; + } + if (ct >= (dim * dim)) + out = -1.0; + else + out = dist[target]; + + if (dist != NULL) free(dist); + if (prev != NULL) free(prev); + if (selected != NULL) free(selected); + if (path != NULL) free(path); + + return out; + +MEM_ERROR: + + if (dist != NULL) free(dist); + if (prev != NULL) free(prev); + if (selected != NULL) free(selected); + if (path != NULL) free(path); + + return 0.0; +}*/ + +/*double _computeTortousity(float* tort_matrix, float* tort_array, int dim, + int source, int dest) { + float dist, real_dist; + float a1, a2, b1, b2, c1, c2; + //int i, j; + + // Get Euclidean distance: + a1 = tort_array [ I2(source, 0, dim) ]; + a2 = tort_array [ I2(dest, 0, dim) ]; + b1 = tort_array [ I2(source, 1, dim) ]; + b2 = tort_array [ I2(dest, 1, dim) ]; + c1 = tort_array [ I2(source, 2, dim) ]; + c2 = tort_array [ I2(dest, 2, dim) ]; + dist = (float) sqrt((a1 - a2)*(a1 - a2) + (b1 - b2)*(b1 - b2) + (c1 - c2)*(c1 - c2)); + + // Get real distance + real_dist = p3dShortestPath(tort_matrix, dim, source, dest); + //real_dist = _dijsktra(tort_matrix, dim, source, dest); + + /*printf("Branch [%0.1f,%0.1f,%0.1f] - [%0.1f,%0.1f,%0.1f] = %0.1f / %0.1f\n", + tort_array [ I2(source, 0, dim) ], + tort_array [ I2(source, 1, dim) ], + tort_array [ I2(source, 2, dim) ], + tort_array [ I2(dest, 0, dim) ], + tort_array [ I2(dest, 1, dim) ], + tort_array [ I2(dest, 2, dim) ], + real_dist, + dist + );*/ + + /*if ( fabs( real_dist + 1.0 ) < 1E-4) + return -1.0; + else + return real_dist / dist; +}*/ + +int _findNode( + unsigned short* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k + ) { + int a, b, c; + int ct = 0; + + // 6-connection: + c = k - 1; + b = j; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k - 1; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k - 1; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k - 1; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k - 1; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k - 1; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k - 1; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + c = k + 1; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + if (im[ I(a, b, c, dimx, dimy) ] != BACKGROUND) + return im[ I(a, b, c, dimx, dimy) ]; + + return BACKGROUND; +} + +int _countNeighbors( + unsigned short* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + unsigned short lbl + ) { + int a, b, c; + int ct = 0; + + // 6-connection: + c = k - 1; + b = j; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k - 1; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k - 1; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k - 1; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k - 1; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k - 1; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k - 1; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + c = k + 1; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) + ct += (im[ I(a, b, c, dimx, dimy) ] == lbl) ? 1 : 0; + + // Return number of voxels in the neighborhood: + return ct; +} + +int _findNeighbor( + unsigned short* im, + const int dimx, + const int dimy, + const int dimz, + const int i, + const int j, + const int k, + coords_t* coords + ) { + int a, b, c; + int ct = 0; + + // 6-connection: + c = k - 1; + b = j; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + // Do other 12 tests for 18-connection + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k - 1; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k - 1; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k - 1; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j + 1; + a = i; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + + // On k plane: + c = k; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + // Do other 8 tests for 26-connectivity + + // On k-1 plane: + c = k - 1; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k - 1; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k - 1; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k - 1; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + + // On k+1 plane: + c = k + 1; + b = j - 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j - 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j + 1; + a = i - 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + c = k + 1; + b = j + 1; + a = i + 1; + if ((c >= 0) && (c < dimz) && (b >= 0) && (b < dimy) && (a >= 0) && (a < dimx)) { + ct += (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) ? 1 : 0; + if (im[ I(a, b, c, dimx, dimy) ] == USHRT_MAX) { + coords->x = a; + coords->y = b; + coords->z = c; + } + } + + // Return number of voxels in the neighborhood: + return ct; +} + +int _p3dSkeletonAnalysis_EndPoints( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned short* dt_im, // IN: Input squared euclidean distance transform of vol_im + unsigned char* lbl_skl_im, // IN: Input labeled skeleton of the segmented volume + unsigned char* ends_im, // OUT: Image with maximal balls filled on endpoints + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + const int dimx, + const int dimy, + const int dimz, + const double voxelsize // IN: voxel resolution + ) { + unsigned short* tmp_im = NULL; + + double max_width; + + int cc_array_numel; + unsigned int* cc_array = NULL; + + bb_t* bbs = NULL; + bb_t curr_bb; + int ct, i, j, k, a, b, c; + int rad; + double delta; + + // Allocate memory: + P3D_MEM_TRY(tmp_im = (unsigned short*) calloc(dimx * dimy*dimz, sizeof (unsigned short))); + + // Fill the balls: +#pragma omp parallel for private(i, j, rad, a, b, c, delta) + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) { + if (lbl_skl_im[ I(i, j, k, dimx, dimy) ] == END_LABEL) { + // Get the radius: + rad = (int) (sqrt((double) dt_im [ I(i, j, k, dimx, dimy) ])); + + // Fill the ball: + for (c = k - rad; c <= k + rad; c++) + for (b = j - rad; b <= j + rad; b++) + for (a = i - rad; a <= i + rad; a++) { + // We are scanning the bounding box, so we need to be sure + // if current position (a,b,c) is inside the ball: + delta = sqrt((double) ((a - i)*(a - i) + (b - j)*(b - j) + + (c - k)*(c - k))); + + if ((a >= 0) && (b >= 0) && (c >= 0) && + (a < dimx) && (b < dimy) && (c < dimz) && + (delta < rad)) { + ends_im [ I(a, b, c, dimx, dimy) ] = OBJECT; + } + } + } + } + + + // Perform connected components labeling of END points: + P3D_TRY(p3dConnectedComponentsLabeling(ends_im, tmp_im, &cc_array_numel, &cc_array, &bbs, + dimx, dimy, dimz, CONN6, P3D_TRUE)); + + + + // If there are endpoints: + if (cc_array_numel != 0) { + // Allocate memory for the distribution of widths on endpoints: + P3D_MEM_TRY(out_stats->End_Width = (double*) malloc(cc_array_numel * sizeof (double))); + out_stats->End_Counter = cc_array_numel; + + // Compute max width on endpoints: + for (ct = 0; ct < cc_array_numel; ct++) { + curr_bb = bbs[ct]; + + max_width = 0.0; + + // Scan the bounding box for maximum value: + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (ends_im[ I(i, j, k, dimx, dimy) ] == OBJECT) { + max_width = MAX(max_width, (double) dt_im [ I(i, j, k, dimx, dimy) ]); + } + } + + + // Copy statistics to output structure: + out_stats->End_Width[ct] = 2 * sqrt(max_width) * voxelsize; + } + } else { + // Copy empty statistics to output structure: + out_stats->End_Counter = 0; + out_stats->End_Width = NULL; + } + + + + // Release resources: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + + return P3D_ERROR; +} + +int _p3dSkeletonAnalysis_NodePoints( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned short* dt_im, // IN: Input squared euclidean distance transform of vol_im + unsigned char* lbl_skl_im, // IN: Input labeled skeleton of the segmented volume + unsigned char* nodes_im, // OUT: Image with maximal balls filled on nodepoints + unsigned char* pores_im, // OUT: Image with only the maximal balls for pores + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + const int dimx, + const int dimy, + const int dimz, + const double merging_factor, + const double voxelsize // IN: voxel resolution + ) { + unsigned short* tmp_im = NULL; + unsigned short* tmp_roi = NULL; + + double max_width; + + int cc_array_numel; + int max_i, max_j, max_k; + unsigned int* cc_array = NULL; + + bb_t* bbs = NULL; + bb_t curr_bb; + int i, j, k, a, b, c; + int ct, rad, delta; + coords_t coords; + + int offset = 1; // Extra-marging for bounding box + + + // Allocate memory: + P3D_MEM_TRY(tmp_im = (unsigned short*) calloc(dimx * dimy*dimz, sizeof (unsigned short))); + P3D_MEM_TRY(tmp_roi = (unsigned short*) malloc(dimx * dimy * dimz * sizeof (unsigned short))); + + // A ball is filled on each node voxel. The radius of this ball is the value of + // the distance transform on the node voxel. While, in principle, the medialness + // property should guarantee that the node voxel lies on the center of the maximal + // inscribed sphere this is actually not true. Therefore, assuming the value of + // the distance transform in that voxel as pore thickness might lead to underestimated + // measurements. This will be fixed by the merging criterion and further processing. + + + // Scan the image and look for each node: +#pragma omp parallel for private(i, j, rad, a, b, c, delta) + for (k = 0; k < dimz; k++) + for (j = 0; j < dimy; j++) + for (i = 0; i < dimx; i++) { + if (lbl_skl_im[ I(i, j, k, dimx, dimy) ] == NODE_LABEL) { + // Now that we are on a node, get the radius. If a very small + // merging factor has been specified, rad could be too small. + // A radius lower than 1 is corrected to 1. + rad = (int) (merging_factor * sqrt((double) dt_im [ I(i, j, k, dimx, dimy) ])); + if (rad < 1) rad = 1; + + // Scan the "squared" bounding box: + for (c = k - rad; c <= k + rad; c++) { + for (b = j - rad; b <= j + rad; b++) { + for (a = i - rad; a <= i + rad; a++) { + // We are scanning the bounding box, so we need to be sure + // if current position (a,b,c) is inside the ball: + delta = (a - i)*(a - i) + (b - j)*(b - j) + (c - k)*(c - k); + + if ((a >= 0) && (b >= 0) && (c >= 0) && + (a < dimx) && (b < dimy) && (c < dimz) && + (delta <= rad * rad)) { + // Fill the ball: + nodes_im [ I(a, b, c, dimx, dimy) ] = OBJECT; + } + } + } + } + } + } + + // Now nodes_im contains the cluster of balls and some of these balls overlap as + // more than one node might occur within a pore. In order to correctly assess the + // number of pores, we assume a 1-1 correspondence of a cluster (set of overlapped + // balls) with a pore. We now count the number of clusters: + + P3D_TRY(p3dConnectedComponentsLabeling(nodes_im, tmp_im, &cc_array_numel, &cc_array, &bbs, + dimx, dimy, dimz, CONN6, P3D_TRUE)); + + // Now that we know the number of pores we can allocate memory: + if (cc_array_numel != 0) { + + // Start stuff for connectivity density: + out_stats->ConnectivityDensity = (double) (cc_array_numel); + + // Allocate memory for the pore-thickness distribution: + P3D_MEM_TRY(out_stats->Node_Width = (double*) malloc(cc_array_numel * sizeof (double))); + out_stats->Node_Counter = cc_array_numel; + + // Allocate memory for the coordination number distribution: + P3D_MEM_TRY(out_stats->CoordinationNumber = (int*) calloc(cc_array_numel, sizeof (int))); + + // Compute pore thickness distribution for each pore (i.e. cluster of balls): + for (ct = 0; ct < cc_array_numel; ct++) { + curr_bb = bbs[ct]; + + max_width = 0.0; + + // Reset the copy of the ROI of the bounding box: + memset(tmp_roi, 0, dimx * dimy * dimz * sizeof (unsigned short)); + + // Scan the bounding box of the cluster of balls: + for (k = (curr_bb.min_z - offset); k <= (curr_bb.max_z + offset); k++) { + for (j = (curr_bb.min_y - offset); j <= (curr_bb.max_y + offset); j++) { + for (i = (curr_bb.min_x - offset); i <= (curr_bb.max_x + offset); i++) { + if ((i >= 0) && (j >= 0) && (k >= 0) && + (i < dimx) && (j < dimy) && (k < dimz)) { + + if (tmp_im[ I(i, j, k, dimx, dimy) ] == ((unsigned short) (ct + 3))) { + // The maximum value of the distance transform is assumed as pore + // thickness. This value is not necessarily the value of the distance + // transform on one of the skeleton nodes that have originated the + // cluster. We should record also the position of this maximum. + if (((double) dt_im [ I(i, j, k, dimx, dimy) ]) > max_width) { + max_width = (double) dt_im [ I(i, j, k, dimx, dimy) ]; + max_i = i; + max_j = j; + max_k = k; + } + } + + // The following code is for further coordination number assessment: + + // Create a temporary copy of the ROI (initialized with the same dimension of the + // whole image for simplicity even if it's a waste of memory) of the bounding box. + // At this point, tmp_im is unsigned short with labeled nodes and lbl_skl_im is + // unsigned short with classification of branches. So the ROI is created with the + // labeled current node (direct copy from tmp_im) and NODE-TO-NODE and NODE-TO-END + // assigned to USHRT_MAX. + + if ((lbl_skl_im[ I(i, j, k, dimx, dimy) ] == NODETONODE_LABEL) || + (lbl_skl_im[ I(i, j, k, dimx, dimy) ] == NODETOEND_LABEL)) { + tmp_roi[ I(i, j, k, dimx, dimy) ] = USHRT_MAX; + } + + + if (tmp_im[ I(i, j, k, dimx, dimy) ] != BACKGROUND) + tmp_roi[ I(i, j, k, dimx, dimy) ] = tmp_im[ I(i, j, k, dimx, dimy) ]; + + } + } + } + } + + // Compute the coordination number re-scanning bounding box: + for (k = (curr_bb.min_z - offset); k <= (curr_bb.max_z + offset); k++) { + for (j = (curr_bb.min_y - offset); j <= (curr_bb.max_y + offset); j++) { + for (i = (curr_bb.min_x - offset); i <= (curr_bb.max_x + offset); i++) { + if ((i >= 0) && (j >= 0) && (k >= 0) && + (i < dimx) && (j < dimy) && (k < dimz)) { + // If a branch is found (USHRT_MAX voxel): + if (tmp_roi[ I(i, j, k, dimx, dimy) ] == USHRT_MAX) { + // Increment coordination number if the current node label is found in + // the neighborhood: + if (_countNeighbors(tmp_roi, dimx, dimy, dimz, i, j, k, + (unsigned short) (ct + 3)) >= 1) { + out_stats->CoordinationNumber[ct]++; + + // Remove current branch in order to avoid counting more than once + // non-perfect interconnections with the maximal ball (simple points + // occur): + tmp_roi[ I(i, j, k, dimx, dimy) ] = BACKGROUND; + + while (_findNeighbor(tmp_roi, dimx, dimy, dimz, i, j, k, &coords) != 0) { + a = i; + b = j; + c = k; + while (_findNeighbor(tmp_roi, dimx, dimy, dimz, a, b, c, &coords) != 0) { + a = coords.x; + b = coords.y; + c = coords.z; + tmp_roi[ I(a, b, c, dimx, dimy) ] = BACKGROUND; + } + } + } + } + } + } + } + } + + + // Create the pore image: + rad = (int) sqrt(max_width); + + // Scan the "squared" bounding box: + for (c = max_k - rad; c <= max_k + rad; c++) + for (b = max_j - rad; b <= max_j + rad; b++) + for (a = max_i - rad; a <= max_i + rad; a++) { + // We are scanning the bounding box, so we need to be sure + // if current position (a,b,c) is inside the ball: + delta = (a - max_i)*(a - max_i) + (b - max_j)*(b - max_j) + + (c - max_k)*(c - max_k); + + if ((a >= 0) && (b >= 0) && (c >= 0) && + (a < dimx) && (b < dimy) && (c < dimz) && + (delta <= rad * rad)) { + // Fill the ball: + pores_im [ I(a, b, c, dimx, dimy) ] = OBJECT; + } + } + + + // Copy statistics to output structure: + out_stats->Node_Width[ct] = 2 * sqrt(max_width) * voxelsize; + } + } else { + // Copy empty statistics to output structure: + out_stats->Node_Counter = 0; + out_stats->Node_Width = NULL; + out_stats->ConnectivityDensity = 0.0; + } + + + + // Release resources: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_roi != NULL) free(tmp_roi); + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_roi != NULL) free(tmp_roi); + + + return P3D_ERROR; +} + +int _p3dSkeletonAnalysis_NodeToNodeBranches( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned short* dt_im, // IN: Input squared euclidean distance transform of vol_im + unsigned char* lbl_skl_im, // IN: Input labeled skeleton of the segmented volume + unsigned char* nodes_im, // IN: Input image of identified nodes with merging criteria + struct SkeletonStats* out_stats, // IN/OUT: Skeleton statistics + unsigned char* throats_im, // OUT: Input image of identified throats with merging criteria + const int dimx, + const int dimy, + const int dimz, + const double voxelsize // IN: voxel resolution + ) { + unsigned char* tmp_im = NULL; + unsigned short* tmp_im2 = NULL; + + double min_width, mean_width, max_width, delta; + + unsigned int* cc_array = NULL; + int cc_array_numel; + + bb_t* bbs = NULL; + bb_t curr_bb; + + int ct, i, j, k, a, b, c, rad; + int min_coord_x, min_coord_y, min_coord_z; + + + // + // Isolate NODE-TO-NODE branches: + // + + // Allocate memory for temp image skeleton: + P3D_MEM_TRY(tmp_im = (unsigned char*) calloc(dimx * dimy*dimz, sizeof (unsigned char))); + P3D_MEM_TRY(tmp_im2 = (unsigned short*) calloc(dimx * dimy*dimz, sizeof (unsigned short))); + + + + // Create temporary matrix removing the filled nodes. Doing so, only the part of a + // branch outside nodes_im, i.e. the image with filled balls on skeleton nodes, is + // taken into acccount. +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (lbl_skl_im[ ct ] == NODETONODE_LABEL) { + tmp_im [ ct ] = OBJECT; + } + if (nodes_im[ ct ] == OBJECT) { + tmp_im [ ct ] = BACKGROUND; + } + } + + + // Perform connected components labeling of NODE-TO-NODE branches: + P3D_TRY(p3dConnectedComponentsLabeling(tmp_im, tmp_im2, &cc_array_numel, &cc_array, &bbs, + dimx, dimy, dimz, CONN26, P3D_TRUE)); + + // Tmp_im2 is no needed anymore: + if (tmp_im2 != NULL) free(tmp_im2); + tmp_im2 = NULL; + + if (cc_array_numel != 0) { + // Allocate memory for the distribution of widths on endpoints: + P3D_MEM_TRY(out_stats->NodeToNode_Length = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->NodeToNode_MinWidth = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->NodeToNode_MeanWidth = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->NodeToNode_MaxWidth = (double*) malloc(cc_array_numel * sizeof (double))); + + // Copy NODE-TO-END branches statistics to output structure: + out_stats->NodeToNode_Counter = cc_array_numel; + + // At this point connectivity density contains the number of node points, so + // it suffices to subtract the number of NODE-TO-NODE branches: + out_stats->ConnectivityDensity = out_stats->ConnectivityDensity - (double) (cc_array_numel); + + // Compute mean length on NODE-TO-NODE branches: + for (ct = 0; ct < cc_array_numel; ct++) { + curr_bb = bbs[ct]; + + min_width = LONG_MAX; + mean_width = 0.0; + max_width = LONG_MIN; + + // Scan the bounding box for minimum, mean and maximum value: + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (tmp_im[ I(i, j, k, dimx, dimy) ] == OBJECT) { + max_width = MAX(max_width, (double) dt_im [ I(i, j, k, dimx, dimy) ]); + mean_width += (double) dt_im [ I(i, j, k, dimx, dimy) ]; + + if ((double) (dt_im [ I(i, j, k, dimx, dimy) ]) < min_width) { + min_width = (double) (dt_im [ I(i, j, k, dimx, dimy) ]); + min_coord_x = i; + min_coord_y = j; + min_coord_z = k; + } + } + } + + // Get the radius: + rad = (int) (sqrt(min_width)); + + // Fill the ball on throat: + for (c = min_coord_z - rad; c <= min_coord_z + rad; c++) + for (b = min_coord_y - rad; b <= min_coord_y + rad; b++) + for (a = min_coord_x - rad; a <= min_coord_x + rad; a++) { + //skip_throat = FALSE; + + // We are scanning the bounding box, so we need to be sure + // if current position (a,b,c) is inside the ball: + delta = (double) ((a - min_coord_x)*(a - min_coord_x) + + (b - min_coord_y)*(b - min_coord_y) + (c - min_coord_z)*(c - min_coord_z)); + + if ((a >= 0) && (b >= 0) && (c >= 0) && + (a < dimx) && (b < dimy) && (c < dimz) && + (delta < min_width)) { + throats_im [ I(a, b, c, dimx, dimy) ] = OBJECT; + /*if ( ( a == 0 ) || ( b == 0 ) || ( c == 0 ) || + ( a == (dimx-1) ) || ( b == (dimy-1) ) || ( c == (dimz-1) ) ) + { + skip_throat = TRUE; + }*/ + } + } + + mean_width /= cc_array[ ct ]; + + // Copy NODE-TO-NODE branches statistics to output structure: + out_stats->NodeToNode_Length[ct] = cc_array[ ct ] * voxelsize; + out_stats->NodeToNode_MinWidth[ct] = 2 * sqrt(min_width) * voxelsize; + out_stats->NodeToNode_MeanWidth[ct] = 2 * sqrt(mean_width) * voxelsize; + out_stats->NodeToNode_MaxWidth[ct] = 2 * sqrt(max_width) * voxelsize; + } + } else { + // Copy NODE-TO-NODE branches statistics to output structure: + out_stats->NodeToNode_Counter = 0; + out_stats->NodeToNode_Length = NULL; + out_stats->NodeToNode_MinWidth = NULL; + out_stats->NodeToNode_MeanWidth = NULL; + out_stats->NodeToNode_MaxWidth = NULL; + } + + // TODO: Reshape arrays due to the skip_throat flag + + // Release resources after each call to _p3dConnectedComponentsLabeling: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources after each call to _p3dConnectedComponentsLabeling: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + return P3D_ERROR; +} + +int _p3dSkeletonAnalysis_NodeToEndBranches( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned short* dt_im, // IN: Input squared euclidean distance transform of vol_im + unsigned char* lbl_skl_im, // IN: Input labeled skeleton of the segmented volume + unsigned char* nodes_im, // IN: Input image of identified nodes with merging criteria + unsigned char* ends_im, // IN: Input image of identified nodes with merging criteria + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + const int dimx, + const int dimy, + const int dimz, + const double voxelsize // IN: voxel resolution + ) { + unsigned char* tmp_im = NULL; + unsigned short* tmp_im2 = NULL; + + double min_width, mean_width, max_width; + + unsigned int* cc_array = NULL; + int cc_array_numel; + + bb_t* bbs = NULL; + bb_t curr_bb; + + int ct, i, j, k; + + + // + // Isolate NODE-TO-NODE branches: + // + + // Allocate memory for temp image skeleton: + P3D_MEM_TRY(tmp_im = (unsigned char*) calloc(dimx * dimy*dimz, sizeof (unsigned char))); + P3D_MEM_TRY(tmp_im2 = (unsigned short*) calloc(dimx * dimy*dimz, sizeof (unsigned short))); + + + // Create temporary matrix removing the filled balls. Doing so, only the part of a + // branch outside nodes_im, i.e. the image with filled balls on skeleton nodes, and + // outside ends_im, i.e. the image with filled balls on skeleton ends, is taken into + // acccount. +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (lbl_skl_im[ ct ] == NODETOEND_LABEL) { + tmp_im [ ct ] = OBJECT; + } + if (nodes_im[ ct ] == OBJECT) { + tmp_im [ ct ] = BACKGROUND; + } + if (ends_im[ ct ] == OBJECT) { + tmp_im [ ct ] = BACKGROUND; + } + } + + + // Perform connected components labeling of NODE-TO-END branches: + P3D_TRY(p3dConnectedComponentsLabeling(tmp_im, tmp_im2, &cc_array_numel, &cc_array, &bbs, + dimx, dimy, dimz, CONN26, P3D_TRUE)); + + + if (cc_array_numel != 0) { + // Allocate memory for the distribution of widths on endpoints: + P3D_MEM_TRY(out_stats->NodeToEnd_Length = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->NodeToEnd_MinWidth = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->NodeToEnd_MeanWidth = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->NodeToEnd_MaxWidth = (double*) malloc(cc_array_numel * sizeof (double))); + + // Copy NODE-TO-END branches statistics to output structure: + out_stats->NodeToEnd_Counter = cc_array_numel; + + // Uncomment this line for taking into account NODE-TO-END branches + // in the computation of the connectivity density. However, taking into + // account only NODE-TO-NODE branches the connectivity density can be + // correctly interpreted as the number of redundant connections per + // volume element. + //out_stats->ConnectivityDensity = out_stats->ConnectivityDensity - cc_array_numel; + + + // Compute mean length on NODE-TO-NODE branches: + for (ct = 0; ct < cc_array_numel; ct++) { + curr_bb = bbs[ct]; + + min_width = LONG_MAX; + mean_width = 0.0; + max_width = LONG_MIN; + + // Scan the bounding box for minimum, mean and maximum value: + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (tmp_im[ I(i, j, k, dimx, dimy) ] == OBJECT) { + min_width = MIN(min_width, (double) dt_im [ I(i, j, k, dimx, dimy) ]); + max_width = MAX(max_width, (double) dt_im [ I(i, j, k, dimx, dimy) ]); + mean_width += (double) dt_im [ I(i, j, k, dimx, dimy) ]; + } + } + + mean_width /= cc_array[ ct ]; + + // Copy NODE-TO-NODE branches statistics to output structure: + out_stats->NodeToEnd_Length[ct] = cc_array[ ct ] * voxelsize; + out_stats->NodeToEnd_MinWidth[ct] = 2 * sqrt(min_width) * voxelsize; + out_stats->NodeToEnd_MeanWidth[ct] = 2 * sqrt(mean_width) * voxelsize; + out_stats->NodeToEnd_MaxWidth[ct] = 2 * sqrt(max_width) * voxelsize; + } + } else { + // Copy NODE-TO-NODE branches statistics to output structure: + out_stats->NodeToEnd_Counter = 0; + out_stats->NodeToEnd_Length = NULL; + out_stats->NodeToEnd_MinWidth = NULL; + out_stats->NodeToEnd_MeanWidth = NULL; + out_stats->NodeToEnd_MaxWidth = NULL; + } + + // Release resources after each call to _p3dConnectedComponentsLabeling: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources after each call to _p3dConnectedComponentsLabeling: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + return P3D_ERROR; +} + +int _p3dSkeletonAnalysis_EndToEndBranches( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned short* dt_im, // IN: Input squared euclidean distance transform of vol_im + unsigned char* lbl_skl_im, // IN: Input labeled skeleton of the segmented volume + unsigned char* ends_im, // IN: Input image of identified nodes with merging criteria + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + const int dimx, + const int dimy, + const int dimz, + const double voxelsize // IN: voxel resolution + ) { + unsigned char* tmp_im = NULL; + unsigned short* tmp_im2 = NULL; + + double min_width, mean_width, max_width; + + unsigned int* cc_array = NULL; + int cc_array_numel; + + bb_t* bbs = NULL; + bb_t curr_bb; + + int ct, i, j, k; + + + + + // + // Isolate END-TO-END branches: + // + + // Allocate memory for labeled skeleton: + P3D_MEM_TRY(tmp_im = (unsigned char*) malloc(dimx * dimy * dimz * sizeof (unsigned char))); + P3D_MEM_TRY(tmp_im2 = (unsigned short*) malloc(dimx * dimy * dimz * sizeof (unsigned short))); + + + // Set memory of tmp_im: + memset(tmp_im, BACKGROUND, dimx * dimy * dimz * sizeof (unsigned char)); + + + // Create temporary matrix removing the filled balls. Doing so, only the part of a + // branch outside ends_im, i.e. the image with filled balls on skeleton ends, is + // taken into acccount. +#pragma omp parallel for + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if (lbl_skl_im[ ct ] == ENDTOEND_LABEL) { + // Assign temporary image: + tmp_im [ ct ] = OBJECT; + } + if (ends_im[ ct ] == OBJECT) { + // Assign temporary image: + tmp_im [ ct ] = BACKGROUND; + } + } + + + // Perform connected components labeling of NODE-TO-NODE branches: + P3D_TRY(p3dConnectedComponentsLabeling(tmp_im, tmp_im2, &cc_array_numel, &cc_array, &bbs, + dimx, dimy, dimz, CONN26, P3D_TRUE)); + + + if (cc_array_numel != 0) { + // Allocate memory for the distribution of widths on endpoints: + P3D_MEM_TRY(out_stats->EndToEnd_Length = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->EndToEnd_MinWidth = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->EndToEnd_MeanWidth = (double*) malloc(cc_array_numel * sizeof (double))); + P3D_MEM_TRY(out_stats->EndToEnd_MaxWidth = (double*) malloc(cc_array_numel * sizeof (double))); + + // Copy NODE-TO-END branches statistics to output structure: + out_stats->EndToEnd_Counter = cc_array_numel; + + // Compute mean length on NODE-TO-NODE branches: + for (ct = 0; ct < cc_array_numel; ct++) { + curr_bb = bbs[ct]; + + min_width = LONG_MAX; + mean_width = 0.0; + max_width = LONG_MIN; + + // Scan the bounding box for minimum, mean and maximum value: + for (k = curr_bb.min_z; k <= curr_bb.max_z; k++) + for (j = curr_bb.min_y; j <= curr_bb.max_y; j++) + for (i = curr_bb.min_x; i <= curr_bb.max_x; i++) { + if (tmp_im[ I(i, j, k, dimx, dimy) ] == OBJECT) { + min_width = MIN(min_width, (double) dt_im [ I(i, j, k, dimx, dimy) ]); + max_width = MAX(max_width, (double) dt_im [ I(i, j, k, dimx, dimy) ]); + mean_width += (double) dt_im [ I(i, j, k, dimx, dimy) ]; + } + } + + mean_width /= cc_array[ ct ]; + + // Copy NODE-TO-NODE branches statistics to output structure: + out_stats->EndToEnd_Length[ct] = cc_array[ ct ] * voxelsize; + out_stats->EndToEnd_MinWidth[ct] = 2 * sqrt(min_width) * voxelsize; + out_stats->EndToEnd_MeanWidth[ct] = 2 * sqrt(mean_width) * voxelsize; + out_stats->EndToEnd_MaxWidth[ct] = 2 * sqrt(max_width) * voxelsize; + } + } else { + // Copy NODE-TO-NODE branches statistics to output structure: + out_stats->EndToEnd_Counter = 0; + out_stats->EndToEnd_Length = NULL; + out_stats->EndToEnd_MinWidth = NULL; + out_stats->EndToEnd_MeanWidth = NULL; + out_stats->EndToEnd_MaxWidth = NULL; + } + + // Release resources after each call to _p3dConnectedComponentsLabeling: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources after each call to _p3dConnectedComponentsLabeling: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + + return P3D_ERROR; +} + +int _p3dSkeletonAnalysis_Tortousity( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned short* dt_im, // IN: Input squared euclidean distance transform of vol_im + unsigned char* lbl_skl_im, // IN: Input labeled skeleton of the segmented volume + unsigned char* pores_im, // OUT: Image with only the maximal balls for pores + unsigned char* ends_im, // IN: Input image of identified nodes with merging criteria + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + const int dimx, + const int dimy, + const int dimz, + const int tortuosity_depth + ) { + + unsigned short* tmp_im = NULL; + unsigned short* tmp_im2 = NULL; + unsigned char* poresplusend_im = NULL; + + float* tort_matrix = NULL; + float* tort_array = NULL; + int* min_ct_array = NULL; + int* max_ct_array = NULL; + int* coord_array = NULL; + + double max_width, dist1, dist2; + + int cc_array_numel; + double cc_length; //, min, max; + int max_i, max_j, max_k; + unsigned int* cc_array = NULL; + + bb_t* bbs = NULL; + bb_t curr_bb, curr_bb2; + int i, j, k, a, b, c, r, s, t, ct/*, ct_num_nodes*/; + double cen_i, cen_j, cen_k; + int cen_ct; + coords_t coords; + + int other_lbl; + int offset = 1; // Extra-marging for bounding box + + int aa = 0; + //int flag; + int num_nodes = tortuosity_depth; + + + // Allocate memory: + P3D_MEM_TRY(poresplusend_im = (unsigned char*) calloc(dimx * dimy * dimz, sizeof (unsigned char))); + P3D_MEM_TRY(tmp_im = (unsigned short*) calloc(dimx * dimy * dimz, sizeof (unsigned short))); + P3D_MEM_TRY(tmp_im2 = (unsigned short*) calloc(dimx * dimy * dimz, sizeof (unsigned short))); + + // Create an additional image with pores and also ends: + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if ((pores_im[ ct ] != BACKGROUND) || (ends_im[ ct ] != BACKGROUND)) { + // Assign temporary image: + poresplusend_im[ ct ] = UCHAR_MAX; + } + } + /*for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if ((lbl_skl_im[ ct ] != NODE_LABEL) || (lbl_skl_im[ ct ] != END_LABEL)) { + // Assign temporary image: + poresplusend_im[ ct ] = UCHAR_MAX; + } + }*/ + + // Get a labeled image for the pores: + P3D_TRY(p3dConnectedComponentsLabeling(poresplusend_im, tmp_im, &cc_array_numel, &cc_array, &bbs, + dimx, dimy, dimz, CONN6, P3D_FALSE)); + //P3D_TRY(p3dConnectedComponentsLabeling(pores_im, tmp_im, &cc_array_numel, &cc_array, &bbs, + // dimx, dimy, dimz, CONN6, P3D_FALSE)); + + //__p3dTmpWriteRaw16 ( tmp_im, "R:\\TEMP\\Pipp_tmp.raw", dimx, dimy, dimz, P3D_TRUE, P3D_TRUE, NULL, NULL ); + + // Create a second temporary copy of the image. At this point, tmp_im is unsigned + // short with labeled pores and lbl_skl_im is unsigned short with classification + // of branches. Now, tmp_im2 is created with the labeled pores (direct copy from + // tmp_im) and NODE-TO-NODE and NODE-TO-END assigned to USHRT_MAX: + for (ct = 0; ct < (dimx * dimy * dimz); ct++) { + if ((lbl_skl_im[ ct ] == ENDTOEND_LABEL) || + (lbl_skl_im[ ct ] == NODETOEND_LABEL) || + (lbl_skl_im[ ct ] == NODETONODE_LABEL)) + //(lbl_skl_im[ ct ] == NODE_LABEL) ) + tmp_im2[ ct ] = USHRT_MAX; + if (tmp_im[ ct ] != BACKGROUND) + tmp_im2[ ct ] = tmp_im[ ct ]; + + } + + + // If there are pores: + if (cc_array_numel != 0) { + + // Allocate memory for saving the center of mass of each pore: + P3D_MEM_TRY(tort_matrix = (float*) calloc(cc_array_numel * cc_array_numel, sizeof (float))); + P3D_MEM_TRY(tort_array = (float*) calloc(cc_array_numel * 4, sizeof (float))); + P3D_MEM_TRY(coord_array = (int*) calloc(cc_array_numel, sizeof (int))); + + // For each pore: + for (ct = 0; ct < cc_array_numel; ct++) { + //for (ct = (cc_array_numel - 1); ct >= 0; ct--) { + + // Initialize the variable that will contain the value for thickness: + max_width = 0.0; + + // Get the current bounding box: + curr_bb = bbs[ct]; + + cen_i = 0; + cen_j = 0; + cen_k = 0; + cen_ct = 0; + + // Scan the bounding box of current pore: + for (k = (curr_bb.min_z - offset); k <= (curr_bb.max_z + offset); k++) + for (j = (curr_bb.min_y - offset); j <= (curr_bb.max_y + offset); j++) + for (i = (curr_bb.min_x - offset); i <= (curr_bb.max_x + offset); i++) { + if ((i >= 0) && (j >= 0) && (k >= 0) && + (i < dimx) && (j < dimy) && (k < dimz)) { + if (tmp_im[ I(i, j, k, dimx, dimy) ] == ((unsigned short) (ct + 3))) { + // The maximum value of the distance transform is assumed as pore + // thickness. This value is not necessarily the value of the distance + // transform on one of the skeleton nodes that have originated the + // cluster. We should record also the position of this maximum. + if (((float) (dt_im [ I(i, j, k, dimx, dimy) ])) > max_width) { + max_width = (float) dt_im [ I(i, j, k, dimx, dimy) ]; + max_i = i; + max_j = j; + max_k = k; + } + + // Compute also the center of mass of this pore: + cen_i += (float) i; + cen_j += (float) j; + cen_k += (float) k; + cen_ct++; + } + } + } + + // Baricenter: + cen_i = cen_i / ((float) (cen_ct)); + cen_j = cen_j / ((float) (cen_ct)); + cen_k = cen_k / ((float) (cen_ct)); + //printf("Baricenter1 = (%0.3f, %0.3f, %0.3f)\n", cen_i, cen_j, cen_k); + + tort_array[ I2(ct, 0, cc_array_numel) ] = (float) cen_i; + tort_array[ I2(ct, 1, cc_array_numel) ] = (float) cen_j; + tort_array[ I2(ct, 2, cc_array_numel) ] = (float) cen_k; + tort_array[ I2(ct, 3, cc_array_numel) ] = (float) max_width; + + // Compute the length for further assessment of tortuosity by re-scanning bounding box: + for (k = (curr_bb.min_z - offset); k <= (curr_bb.max_z + offset); k++) + for (j = (curr_bb.min_y - offset); j <= (curr_bb.max_y + offset); j++) + for (i = (curr_bb.min_x - offset); i <= (curr_bb.max_x + offset); i++) { + if ((i >= 0) && (j >= 0) && (k >= 0) && + (i < dimx) && (j < dimy) && (k < dimz)) { + // If a branch is found (USHRT_MAX voxel): + if (tmp_im2[ I(i, j, k, dimx, dimy) ] == USHRT_MAX) { + // Check if the branch voxel is connected to the pore ball: + if (_countNeighbors(tmp_im2, dimx, dimy, dimz, i, j, k, + (unsigned short) (ct + 3)) >= 1) { + // This counter is not coordination number because + // the branches are removed after their identification + // in order to speed up the computation: + coord_array[ct]++; + + // At this point we know the first skeleton voxel "in touch" + // with pore ball and we still know the baricenter, so let's + // compute the euclidean distance from this two points since + // this value could be greater than the size of the maximal ball: + //printf("Dist1 = (%d, %d, %d)\n", i, j, k); + dist1 = sqrt((i * 1.0 - cen_i)*(i * 1.0 - cen_i) + + (j * 1.0 - cen_j)*(j * 1.0 - cen_j) + + (k * 1.0 - cen_k)*(k * 1.0 - cen_k)); + + // Now that we are close to the border with current node, go + // and run along the branch, removing it in order to avoid + // counting the considered segment more than once: + tmp_im2[ I(i, j, k, dimx, dimy) ] = BACKGROUND; + + cc_length = 0.0; + + // Go until the end: + a = i; + b = j; + c = k; + while (_findNeighbor(tmp_im2, dimx, dimy, dimz, a, b, c, &coords) != 0) { + + // Count the length with Euclidean criteria: + cc_length += sqrt((double) ((a - coords.x)*(a - coords.x) + + (b - coords.y)*(b - coords.y) + + (c - coords.z)*(c - coords.z))); + //printf("cc_length = %0.3f\n", cc_length ); + + + a = coords.x; + b = coords.y; + c = coords.z; + tmp_im2[ I(a, b, c, dimx, dimy) ] = BACKGROUND; + } + + // At this point (a,b,c) are the coordinates of the last point + // "in touch" with the other pore ball. Again we have to compute + // the euclidean distance from this point and the baricenter of + // the destination pore since this value could be greater than + // the size of the maximal ball. So let's first compute the baricenter + // of the destination pore: + + // Get the destination pore: + other_lbl = _findNode(tmp_im2, dimx, dimy, dimz, a, b, c) - 3; + + // Get its bounding box: + curr_bb2 = bbs[other_lbl]; + + cen_i = 0; + cen_j = 0; + cen_k = 0; + cen_ct = 0; + + // Scan the bounding box of destination pore: + for (t = (curr_bb2.min_z - offset); t <= (curr_bb2.max_z + offset); t++) + for (s = (curr_bb2.min_y - offset); s <= (curr_bb2.max_y + offset); s++) + for (r = (curr_bb2.min_x - offset); r <= (curr_bb2.max_x + offset); r++) { + if ((r >= 0) && (s >= 0) && (t >= 0) && + (r < dimx) && (s < dimy) && (t < dimz)) { + if (tmp_im[ I(r, s, t, dimx, dimy) ] == ((unsigned short) (other_lbl + 3))) { + + // Compute also the center of mass of this pore: + cen_i += (float) r; + cen_j += (float) s; + cen_k += (float) t; + cen_ct++; + } + } + } + + cen_i = cen_i / ((float) (cen_ct)); + cen_j = cen_j / ((float) (cen_ct)); + cen_k = cen_k / ((float) (cen_ct)); + + // Compute the Euclidean distance: + //printf("Baricenter2 = (%0.3f, %0.3f, %0.3f)\n", cen_i, cen_j, cen_k); + //printf("Dist2 = (%d, %d, %d)\n", a, b, c); + dist2 = sqrt((a * 1.0 - cen_i)*(a * 1.0 - cen_i) + + (b * 1.0 - cen_j)*(b * 1.0 - cen_j) + + (c * 1.0 - cen_k)*(c * 1.0 - cen_k)); + + + + cc_length += (dist1 + dist2 + 2*sqrt(3.0)); + //wr_log("\tfrom: %d, to: %d, length: %0.3f + 0.3f + 0.3f\n", ct, other_lbl, cc_length, dist1, dist2); + //printf("from: %d, to: %d, length: %0.3f + %0.3f + %0.3f\n", ct, other_lbl, cc_length, dist1, dist2); + + if ( fabs(cc_length - 0.0) < 1E-4) + cc_length = 1.0; + + // Now add cc_length to output matrix: + if ((other_lbl != -3) && (ct != other_lbl)) { + if ( fabs(tort_matrix[ I2(ct, other_lbl, cc_array_numel) ] - 0.0) < 1E-4) { + tort_matrix[ I2(ct, other_lbl, cc_array_numel) ] = (float) cc_length; + //printf("%d - from: %d, to: %d, length: %0.3f\n", aa++, ct, other_lbl, cc_length); + } else { + if (cc_length < tort_matrix[ I2(ct, other_lbl, cc_array_numel) ]) { + tort_matrix[ I2(ct, other_lbl, cc_array_numel) ] = (float) cc_length; + //printf("%d - from: %d, to: %d, length: %0.3f\n", aa++, ct, other_lbl, cc_length); + } + //aa++; + } + } + } + } + } + } + + } + + // Correct tort_matrix and prepare it for Dijkstra: + for (i = 0; i < cc_array_numel; i++) { + for (j = 0; j < cc_array_numel; j++) { + if (i == j) { + tort_matrix[ I2(i, j, cc_array_numel) ] = 0.0; + } /*else { + if (abs(tort_matrix[ I2(i, j, cc_array_numel) ] - 0.0) < 1E-4) { + /*tort_matrix[ I2(i, j, cc_array_numel) ] += (float) sqrt(tort_array[ I2(i, 3, cc_array_numel) ] / 2.0); + tort_matrix[ I2(i, j, cc_array_numel) ] += (float) sqrt(tort_array[ I2(j, 3, cc_array_numel) ] / 2.0); + //tort_matrix[ I2( i, j, cc_array_numel) ]*= (float) 1.0; + } else { + tort_matrix[ I2(i, j, cc_array_numel) ] = (float) (_DIJKSTRA_IN); + } + }*/ + } + } + + // Make symmetric: + for (i = 0; i < cc_array_numel; i++) { + for (j = 0; j < cc_array_numel; j++) { + if ((j > i) && !((fabs(tort_matrix[ I2(i, j, cc_array_numel) ] - 0.0) < 1E-4))) { + tort_matrix[ I2(j, i, cc_array_numel) ] = tort_matrix[ I2(i, j, cc_array_numel) ]; + } + if ((j < i) && !((fabs(tort_matrix[ I2(i, j, cc_array_numel) ] - 0.0) < 1E-4))) { + tort_matrix[ I2(j, i, cc_array_numel) ] = tort_matrix[ I2(i, j, cc_array_numel) ]; + } + } + } + + //printf("Array of dim %d:\n", cc_array_numel); + /*for ( i = 0; i < cc_array_numel; i++ ) + { + printf("%0.1f %0.1f %0.1f - %0.1f\n", tort_array [ I2(i, 0, cc_array_numel) ], + tort_array [ I2(i, 1, cc_array_numel) ], tort_array [ I2(i, 2, cc_array_numel) ], + tort_array [ I2(i, 3, cc_array_numel) ] ); + } + + + fvol = fopen("R:\\TEMP\\matrix.dat", "wb"); + //printf("Matrix of %d x %d:\n", cc_array_numel, cc_array_numel); + for ( i = 0; i < cc_array_numel; i++ ) + { + for ( j = 0; j < cc_array_numel; j++ ) + { + if ( tort_matrix[ I2(i, j, cc_array_numel) ] == _DIJKSTRA_IN ) + { + //printf("-1.0 "); + fprintf(fvol,"%0.1f ",0.0); + //fwrite(-1.0f, sizeof (float), 1, fvol); + } + else + { + //printf("%0.1f "); + fprintf(fvol,"%0.1f ",tort_matrix[ I2(i, j, cc_array_numel) ]); + //fwrite( (float) (tort_matrix[ I2(i, j, cc_array_numel) ]), sizeof (float), 1, fvol); + } + } + //printf("\n"); + fprintf(fvol,"%s",";\n"); + } + fclose(fvol);*/ + + //out_stats->Tort_Z = _computeTortousity( tort_matrix, tort_array, cc_array_numel, 0, 5 ); + + // + // Compute actual tortuosity: + // + + // Check if tortousity depth is greater than the square of number of nodes: + /*num_nodes = (int) sqrt( (float) (MIN(num_nodes*num_nodes, cc_array_numel))); + out_stats->Tort_Counter = num_nodes*num_nodes; + + // Allocate memory: + P3D_MEM_TRY(min_ct_array = (int*) calloc(num_nodes, sizeof (int))); + P3D_MEM_TRY(max_ct_array = (int*) calloc(num_nodes, sizeof (int))); + + P3D_MEM_TRY(out_stats->Tort_X = (double*) calloc(out_stats->Tort_Counter, sizeof (double))); + P3D_MEM_TRY(out_stats->Tort_Y = (double*) calloc(out_stats->Tort_Counter, sizeof (double))); + P3D_MEM_TRY(out_stats->Tort_Z = (double*) calloc(out_stats->Tort_Counter, sizeof (double)));*/ + + + // + // Turtousity along X: + // + + // Get num_nodes minimum and maximum values along x (num_nodes is at + // least 1 and no more than a threshold): + /*for (ct_num_nodes = 0; ct_num_nodes < num_nodes; ct_num_nodes++) { + min = (float) (INT_MAX); + max = -1.0; + + // Scan the array: + for (ct = 0; ct < cc_array_numel; ct++) { + // Check if probable new min is actually one the previous mins: + flag = P3D_FALSE; + for (k = 0; k <= (ct_num_nodes - 1); k++) + if (min_ct_array[k] == ct) + flag = P3D_TRUE; + // If it's not a previous min save it: + if (flag == P3D_FALSE) { + if (tort_array[ I2(ct, 0, cc_array_numel) ] < min) { + min = tort_array[ I2(ct, 0, cc_array_numel) ]; + min_ct_array[ct_num_nodes] = ct; + } + } + // Check if probable new max is actually one the previous mins: + flag = P3D_FALSE; + for (k = 0; k <= (ct_num_nodes - 1); k++) + if (max_ct_array[k] == ct) + flag = P3D_TRUE; + // If it's not a previous max save it: + if (flag == P3D_FALSE) { + if (tort_array[ I2(ct, 0, cc_array_numel) ] > max) { + + max = tort_array[ I2(ct, 0, cc_array_numel) ]; + max_ct_array[ct_num_nodes] = ct; + } + } + } + } + + // Compute tortousity in X: + ct = 0; + for (i = 0; i < num_nodes; i++) { + for (j = 0; j < num_nodes; j++) { + out_stats->Tort_X[ct++] = _computeTortousity(tort_matrix, tort_array, + cc_array_numel, min_ct_array[i], max_ct_array[j]); + } + } + + + + // + // Tortousity along Y: + // + + // Get num_nodes minimum and maximum values along x (num_nodes is at + // least 1 and no more than a threshold): + // Get num_nodes minimum and maximum values along x (num_nodes is at + // least 1 and no more than a threshold): + for (ct_num_nodes = 0; ct_num_nodes < num_nodes; ct_num_nodes++) { + min = (float) (INT_MAX); + max = -1.0; + + // Scan the array: + for (ct = 0; ct < cc_array_numel; ct++) { + // Check if probable new min is actually one the previous mins: + flag = P3D_FALSE; + for (k = 0; k <= (ct_num_nodes - 1); k++) + if (min_ct_array[k] == ct) + flag = P3D_TRUE; + // If it's not a previous min save it: + if (flag == P3D_FALSE) { + if (tort_array[ I2(ct, 1, cc_array_numel) ] < min) { + min = tort_array[ I2(ct, 1, cc_array_numel) ]; + min_ct_array[ct_num_nodes] = ct; + } + } + // Check if probable new max is actually one the previous mins: + flag = P3D_FALSE; + for (k = 0; k <= (ct_num_nodes - 1); k++) + if (max_ct_array[k] == ct) + flag = P3D_TRUE; + // If it's not a previous max save it: + if (flag == P3D_FALSE) { + if (tort_array[ I2(ct, 1, cc_array_numel) ] > max) { + max = tort_array[ I2(ct, 1, cc_array_numel) ]; + max_ct_array[ct_num_nodes] = ct; + } + } + } + } + + // Compute tortousity in Y: + ct = 0; + for (i = 0; i < num_nodes; i++) + for (j = 0; j < num_nodes; j++) { + out_stats->Tort_Y[ct++] = _computeTortousity(tort_matrix, tort_array, + cc_array_numel, min_ct_array[i], max_ct_array[j]); + } + + + // + // Tortousity along Z: + // + + // Get num_nodes minimum and maximum values along Z (num_nodes is at + // least 1 and no more than a threshold): + for (ct_num_nodes = 0; ct_num_nodes < num_nodes; ct_num_nodes++) { + min = (float) (INT_MAX); + max = -1.0; + + // Scan the array: + for (ct = 0; ct < cc_array_numel; ct++) { + // Check if probable new min is actually one the previous mins: + flag = P3D_FALSE; + for (k = 0; k <= (ct_num_nodes - 1); k++) + if (min_ct_array[k] == ct) + flag = P3D_TRUE; + // If it's not a previous min save it: + if (flag == P3D_FALSE) { + if (tort_array[ I2(ct, 2, cc_array_numel) ] < min) { + min = tort_array[ I2(ct, 2, cc_array_numel) ]; + min_ct_array[ct_num_nodes] = ct; + } + } + // Check if probable new max is actually one the previous mins: + flag = P3D_FALSE; + for (k = 0; k <= (ct_num_nodes - 1); k++) + if (max_ct_array[k] == ct) + flag = P3D_TRUE; + // If it's not a previous max save it: + if (flag == P3D_FALSE) { + if (tort_array[ I2(ct, 2, cc_array_numel) ] > max) { + max = tort_array[ I2(ct, 2, cc_array_numel) ]; + max_ct_array[ct_num_nodes] = ct; + } + } + } + } + + + // Compute tortousity in Z: + ct = 0; + for (i = 0; i < num_nodes; i++) + for (j = 0; j < num_nodes; j++) + out_stats->Tort_Z[ct++] = _computeTortousity(tort_matrix, tort_array, + cc_array_numel, min_ct_array[i], max_ct_array[j]); + */ + + } else { + // Copy empty statistics to output structure: + out_stats->Node_Counter = 0; + out_stats->Node_Width = NULL; + out_stats->ConnectivityDensity = 0.0; + + /* out_stats->Tort_Counter = 0; + out_stats->Tort_X = NULL; + out_stats->Tort_Y = NULL; + out_stats->Tort_Z = NULL;*/ + } + + // Release resources: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + if (poresplusend_im != NULL) free(poresplusend_im); + if (tort_matrix != NULL) free(tort_matrix); + if (tort_array != NULL) free(tort_array); + if (min_ct_array != NULL) free(min_ct_array); + if (max_ct_array != NULL) free(max_ct_array); + if (coord_array != NULL) free(coord_array); + + return P3D_SUCCESS; + +MEM_ERROR: + + // Release resources: + if (cc_array != NULL) free(cc_array); + if (bbs != NULL) free(bbs); + if (tmp_im != NULL) free(tmp_im); + if (tmp_im2 != NULL) free(tmp_im2); + if (poresplusend_im != NULL) free(poresplusend_im); + if (tort_matrix != NULL) free(tort_matrix); + if (tort_array != NULL) free(tort_array); + if (min_ct_array != NULL) free(min_ct_array); + if (max_ct_array != NULL) free(max_ct_array); + if (coord_array != NULL) free(coord_array); + + return P3D_ERROR; +} + +int p3dSkeletonAnalysis( + unsigned char* vol_im, // IN: Input segmented (binary) volume + unsigned char* skl_im, // IN: Input (binary) skeleton of the segmented volume + struct SkeletonStats* out_stats, // OUT: Skeleton statistics + unsigned char* nodes_im, + unsigned char* pores_im, + unsigned char* ends_im, + unsigned char* throats_im, + const int dimx, + const int dimy, + const int dimz, + const double merging_factor, + const int tortuosity_depth, + const double voxelsize, // IN: voxel resolution + int (*wr_log)(const char*, ...) + ) +{ + + // Temporary matrices: + unsigned char* max_skl_im; + unsigned char* lbl_skl_im; + unsigned short* dt_im; + + double mean = 0.0; + double mean_sqr = 0.0; + double glob_mean = 0.0; + double glob_mean_sqr = 0.0; + int /*i,j,*/ct; + int flag_nodes_null = P3D_FALSE; + int flag_pores_null = P3D_FALSE; + int flag_ends_null = P3D_FALSE; + int flag_throats_null = P3D_FALSE; + + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Performing skeleton analysis..."); + wr_log("\tVoxelsize: %0.6f mm.", voxelsize); + wr_log("\tMerging factor: %0.2f.", merging_factor); + //wr_log("\tTortuosity depth: %d.", tortuosity_depth); + } + + + // Allocate memory: + if (nodes_im == NULL) { + flag_nodes_null = P3D_TRUE; + P3D_MEM_TRY(nodes_im = (unsigned char*) calloc(dimx * dimy*dimz, sizeof (unsigned char))); + } + if (pores_im == NULL) { + flag_pores_null = P3D_TRUE; + P3D_MEM_TRY(pores_im = (unsigned char*) calloc(dimx * dimy*dimz, sizeof (unsigned char))); + } + if (ends_im == NULL) { + flag_ends_null = P3D_TRUE; + P3D_MEM_TRY(ends_im = (unsigned char*) calloc(dimx * dimy*dimz, sizeof (unsigned char))); + } + if (throats_im == NULL) { + flag_throats_null = P3D_TRUE; + P3D_MEM_TRY(throats_im = (unsigned char*) calloc(dimx * dimy*dimz, sizeof (unsigned char))); + } + + P3D_MEM_TRY(dt_im = (unsigned short*) malloc(dimx * dimy * dimz * sizeof (unsigned short))); + P3D_MEM_TRY(max_skl_im = (unsigned char*) malloc(dimx * dimy * dimz * sizeof (unsigned char))); + P3D_MEM_TRY(lbl_skl_im = (unsigned char*) malloc(dimx * dimy * dimz * sizeof (unsigned char))); + + + // Compute distance transform for further use: + P3D_TRY(p3dSquaredEuclideanDT(vol_im, dt_im, dimx, dimy, dimz)); + + + // Ensure that only one skeleton image is presented (the maximum): + P3D_TRY(p3dGetMaxVolumeRegion(skl_im, max_skl_im, dimx, dimy, dimz, CONN26)); + P3D_TRY(p3dThinning(max_skl_im, dimx, dimy, dimz)); + + + // Perform skeleton labeling: + P3D_TRY(p3dSkeletonLabeling(max_skl_im, lbl_skl_im, dimx, dimy, dimz, NULL)); + + + // ANALYSIS STEP. Computes number and lengths of each identified component. + // This implementation uses connected component labeling for segments but + // also for nodes to mitigate thinning algorithm defects: + + + P3D_TRY(_p3dSkeletonAnalysis_EndPoints(vol_im, dt_im, lbl_skl_im, ends_im, out_stats, + dimx, dimy, dimz, voxelsize)); + P3D_TRY(_p3dSkeletonAnalysis_NodePoints(vol_im, dt_im, lbl_skl_im, nodes_im, pores_im, out_stats, + dimx, dimy, dimz, merging_factor, voxelsize)); + P3D_TRY(_p3dSkeletonAnalysis_NodeToNodeBranches(vol_im, dt_im, lbl_skl_im, nodes_im, + out_stats, throats_im, dimx, dimy, dimz, voxelsize)); + P3D_TRY(_p3dSkeletonAnalysis_NodeToEndBranches(vol_im, dt_im, lbl_skl_im, nodes_im, ends_im, + out_stats, dimx, dimy, dimz, voxelsize)); + P3D_TRY(_p3dSkeletonAnalysis_EndToEndBranches(vol_im, dt_im, lbl_skl_im, ends_im, + out_stats, dimx, dimy, dimz, voxelsize)); + //P3D_TRY(_p3dSkeletonAnalysis_Tortousity(vol_im, dt_im, lbl_skl_im, nodes_im, ends_im, + // out_stats, dimx, dimy, dimz, tortuosity_depth)); + + // Set connectivity index. At this point, out_stats->ConnectivityDensity contains the + // Euler number, i.e. nodes - branches (only NODE-TO-NODEs are considered). We need to + // compute the final connectivity index as (1 - Euler#)/Volume: + out_stats->ConnectivityDensity = (1.0 - out_stats->ConnectivityDensity) / + (dimx * voxelsize * dimy * voxelsize * dimz * voxelsize); + + + // Print out number of connected components and mean values of parameters: + if (wr_log != NULL) { + wr_log("\t----"); + wr_log("\tNumber of PORES: %d. ", out_stats->Node_Counter); + wr_log("\tNumber of ENDS: %d.", out_stats->End_Counter); + wr_log("\tNumber of NODE-TO-NODE branches (throats): %d.", out_stats->NodeToNode_Counter); + wr_log("\tNumber of NODE-TO-END branches: %d.", out_stats->NodeToEnd_Counter); + wr_log("\tNumber of END-TO-END branches: %d.", out_stats->EndToEnd_Counter); + wr_log("\t----"); + + + if (out_stats->Node_Counter > 0) { + // Compute mean values of volume: + mean = 0.0; + mean_sqr = 0.0; + for (ct = 0; ct < (out_stats->Node_Counter); ct++) { + mean_sqr += (double) (out_stats->Node_Width[ct] * out_stats->Node_Width[ct]); + mean += (double) (out_stats->Node_Width[ct]); + } + mean = mean / ((double) (out_stats->Node_Counter)); + mean_sqr = mean_sqr / ((double) (out_stats->Node_Counter)); + mean_sqr = mean_sqr - mean*mean; + + wr_log("\tPore size: %0.3f +/- %0.3f [mm].", mean, sqrt(mean_sqr)); + } + + if (out_stats->NodeToNode_Counter > 0) { + // Compute mean values of volume: + mean = 0.0; + mean_sqr = 0.0; + for (ct = 0; ct < out_stats->NodeToNode_Counter; ct++) { + mean_sqr += (double) (out_stats->NodeToNode_MinWidth[ct] * out_stats->NodeToNode_MinWidth[ct]); + mean = mean + (double) (out_stats->NodeToNode_MinWidth[ct]); + + //wr_log("\tThroat size: %0.3f +/- %0.3f [mm].", (double) (out_stats->NodeToNode_MinWidth[ct])); + } + mean = mean / ((double) (out_stats->NodeToNode_Counter)); + mean_sqr = mean_sqr / ((double) (out_stats->NodeToNode_Counter)); + mean_sqr = mean_sqr - mean*mean; + + wr_log("\tThroat size: %0.3f +/- %0.3f [mm].", mean, sqrt(mean_sqr)); + } + + if (out_stats->Node_Counter > 0) { + + wr_log("\tConnectivity density: %0.3f [mm^-3].", out_stats->ConnectivityDensity); + } + + if (out_stats->Node_Counter > 0) { + // Compute mean values of volume: + mean = 0.0; + mean_sqr = 0.0; + for (ct = 0; ct < (out_stats->Node_Counter); ct++) { + mean = mean + (double) (out_stats->CoordinationNumber[ct]); + mean_sqr += (double) (out_stats->CoordinationNumber[ct] * out_stats->CoordinationNumber[ct]*1.0); + //wr_log ("\t\tCoordination number: %d ", out_stats->CoordinationNumber[ct] ); + } + mean = mean / ((double) (out_stats->Node_Counter)); + mean_sqr = mean_sqr / ((double) (out_stats->Node_Counter)); + mean_sqr = mean_sqr - mean*mean; + + wr_log("\tCoordination number: %0.3f +/- %0.3f [-].", mean, sqrt(mean_sqr)); + } + + /*if (out_stats->NodeToNode_Counter > 0) { + + // Compute mean values of tortuosity: + glob_mean = 0.0; + glob_mean_sqr = 0.0; + mean = 0.0; + mean_sqr = 0.0; + i = 0; + j = 0; + for (ct = 0; ct < (out_stats->Tort_Counter); ct++) { + if (out_stats->Tort_X[ct] > -1.0) { + mean = mean + (double) (out_stats->Tort_X[ct]); + glob_mean += (double) (out_stats->Tort_X[ct]); + mean_sqr += (double) (out_stats->Tort_X[ct] * out_stats->Tort_X[ct]); + glob_mean_sqr += (double) (out_stats->Tort_X[ct] * out_stats->Tort_X[ct]); + i++; + j++; + } else { + //wr_log("\tWARNING: Unable to compute a tortuosity path."); + } + } + mean = mean / i; + mean_sqr = mean_sqr / i; + mean_sqr = sqrt(mean_sqr - mean * mean); + wr_log("\tTortuosity in X: %0.3f +/- %0.3f [-] (%d considered paths).", mean, mean_sqr, i); + + mean = 0.0; + mean_sqr = 0.0; + i = 0; + for (ct = 0; ct < (out_stats->Tort_Counter); ct++) { + if (out_stats->Tort_Y[ct] > -1.0) { + mean = mean + (double) (out_stats->Tort_Y[ct]); + glob_mean += (double) (out_stats->Tort_Y[ct]); + mean_sqr += (double) (out_stats->Tort_Y[ct] * out_stats->Tort_Y[ct]); + glob_mean_sqr += (double) (out_stats->Tort_Y[ct] * out_stats->Tort_Y[ct]); + i++; + j++; + } else { + //wr_log("\tWARNING: Unable to compute a tortuosity path."); + } + } + mean = mean / i; + mean_sqr = mean_sqr / i; + mean_sqr = sqrt(mean_sqr - mean * mean); + wr_log("\tTortuosity in Y: %0.3f +/- %0.3f [-] (%d considered paths).", mean, mean_sqr, i); + + + mean = 0.0; + mean_sqr = 0.0; + i = 0; + for (ct = 0; ct < (out_stats->Tort_Counter); ct++) { + if (out_stats->Tort_Z[ct] > -1.0) { + mean = mean + (double) (out_stats->Tort_Z[ct]); + glob_mean += (double) (out_stats->Tort_Z[ct]); + mean_sqr += (double) (out_stats->Tort_Z[ct] * out_stats->Tort_Z[ct]); + glob_mean_sqr += (double) (out_stats->Tort_Z[ct] * out_stats->Tort_Z[ct]); + i++; + j++; + } else { + //wr_log("\tWARNING: Unable to compute a tortuosity path."); + } + } + mean = mean / i; + mean_sqr = mean_sqr / i; + mean_sqr = sqrt(mean_sqr - mean * mean); + glob_mean = glob_mean / j; + glob_mean_sqr = glob_mean_sqr / j; + glob_mean_sqr = sqrt(glob_mean_sqr - glob_mean * glob_mean); + wr_log("\tTortuosity in Z: %0.3f +/- %0.3f [-] (%d considered paths).", mean, mean_sqr, i); + wr_log("\tGlobal tortuosity: %0.3f +/- %0.3f [-] (%d considered paths).", glob_mean, glob_mean_sqr, j); + }*/ + } + + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Skeleton analysis performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + + // Release resources: + if (dt_im != NULL) free(dt_im); + if (max_skl_im != NULL) free(max_skl_im); + if (lbl_skl_im != NULL) free(lbl_skl_im); + if (flag_nodes_null == P3D_TRUE) { + if (nodes_im != NULL) free(nodes_im); + nodes_im = NULL; + } + if (flag_ends_null == P3D_TRUE) { + if (ends_im != NULL) free(ends_im); + ends_im = NULL; + } + if (flag_throats_null == P3D_TRUE) { + if (throats_im != NULL) free(throats_im); + throats_im = NULL; + } + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + // Log a ERROR message: + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Free memory if previous malloc were successfully: + if (dt_im != NULL) free(dt_im); + if (max_skl_im != NULL) free(max_skl_im); + if (lbl_skl_im != NULL) free(lbl_skl_im); + if (flag_nodes_null == P3D_TRUE) { + if (nodes_im != NULL) free(nodes_im); + nodes_im = NULL; + } + if (flag_ends_null == P3D_TRUE) { + if (ends_im != NULL) free(ends_im); + ends_im = NULL; + } + if (flag_throats_null == P3D_TRUE) { + if (throats_im != NULL) free(throats_im); + throats_im = NULL; + } + + + // Return error code and exit: + return P3D_ERROR; + +} + + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dSkeletonAnalysisFeasibility.c b/pypore3d/pypore3d/P3D_Skel/p3dSkeletonAnalysisFeasibility.c new file mode 100644 index 0000000000000000000000000000000000000000..1c2c536779fcff687718dfbea42947e60b938046 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dSkeletonAnalysisFeasibility.c @@ -0,0 +1,70 @@ +#include <stdlib.h> +#include <omp.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dUtils.h" + + +int p3dSkeletonAnalysisFeasibility ( + unsigned char* in_im, // IN: binary volume + unsigned char* sk_im, // IN: skeleton mask + double* ratio, // OUT: percentage of total pore space + // occupied by the medial axis. + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) +{ + int i,j,k; + double porosityct; + double skeletonct; + + + // Start tracking computational time: + if (wr_log != NULL) + { + p3dResetStartTime(); + wr_log ("Pore3D - Computing skeleton analysis feasibility..." ); + } + + // Initialize variables: + porosityct = 0.0; + skeletonct = 0.0; + + // Scan volumes: + #pragma omp parallel for private(i, j) reduction (+ : porosityct, skeletonct ) + for( k = 0; k < dimz; k++ ) + for( j = 0; j < dimy; j++ ) + for( i = 0; i < dimx; i++ ) + { + if ( in_im[ I(i,j,k,dimx,dimy) ] == BACKGROUND ) + porosityct = porosityct + 1.0; + + if ( sk_im[ I(i,j,k,dimx,dimy) ] != BACKGROUND ) + skeletonct = skeletonct + 1.0; + } + + + // Return percentage of total pore space occupied by the medial axis: + *ratio = skeletonct / ((double) (porosityct)); + + if (wr_log != NULL) + { + wr_log ("\tPercentage of total space occupied by the skeleton [%]: %0.3f.", (*ratio * 100) ); + } + + + // Print elapsed time (if required): + if (wr_log != NULL) + { + wr_log ("Pore3D - Skeleton analysis feasibility computed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Return OK: + return P3D_SUCCESS; + +} + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dSkeletonLabeling.c b/pypore3d/pypore3d/P3D_Skel/p3dSkeletonLabeling.c new file mode 100644 index 0000000000000000000000000000000000000000..f779452ce22d8471ace64218f25ac509a2b2a9cd --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dSkeletonLabeling.c @@ -0,0 +1,208 @@ +#include <stdlib.h> +#include <omp.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dUtils.h" + +int p3dSkeletonLabeling( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) +{ + + coords_list_t list; // FIFO data structure for coords storage + coords_t coords; // Current coords + + int i, j, k; + int a, b, c; + int ct; + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary input and output: + unsigned char* tmp_im; + + // Counters: + int neigh, length; + + // Start tracking computational time: + if (wr_log != NULL) { + p3dResetStartTime(); + wr_log("Pore3D - Labeling the skeleton..."); + } + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad * 2; + a_dimy = dimy + a_rad * 2; + a_dimz = dimz + a_rad * 2; + + + // Initialize input: + P3D_MEM_TRY(tmp_im = (unsigned char*) malloc(a_dimx * a_dimy * a_dimz * sizeof (unsigned char))); + P3D_TRY(p3dZeroPadding3D_uchar2uchar(in_im, tmp_im, dimx, dimy, dimz, a_rad)); + + + // Volume scanning: +#pragma omp parallel for private(a, b, i, j, k, ct, coords, list, neigh, length) + for (c = a_rad; c < (a_dimz - a_rad); c++) + for (b = a_rad; b < (a_dimy - a_rad); b++) + for (a = a_rad; a < (a_dimx - a_rad); a++) { + // If we're on a skeleton voxel: + if (tmp_im[ I(a, b, c, a_dimx, a_dimy) ] == OBJECT) { + // Check Neighborhood: + ct = countNeighbors(tmp_im, a_dimx, a_dimy, a_dimz, a, b, c); + + // Is an end point? + if (ct == 1) { + // Initialize variables: + coords_list_init(&list); + + // End point found: + coords.x = a; + coords.y = b; + coords.z = c; + + // Start tracking length: + length = 0; + + do { + // Push the voxel into list: + coords_list_push(&list, coords); + + // Get coords: + k = coords.z; + j = coords.y; + i = coords.x; + + // Temporary delete voxel + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = BACKGROUND; + + // Determine number of neighbors: + neigh = findNeighbor(tmp_im, a_dimx, a_dimy, a_dimz, i, j, k, &coords); + + // Increment counter of branch length: + length++; + + } while (neigh == 1); + + // At this point, we're on last voxel of node-to-end branch (ct > 1) or we + // completely scanned a end-to-end branch (ct == 0). In the first case we + // need to take care whether last voxel is a simple point or not: + if (neigh > 1) { + // Assign last voxel to NODE label: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = NODE_LABEL; + + // Remove coordinates from the list: + coords = coords_list_pop(&list); + + // Assign NODETOEND labels: + while (coords_list_isempty(list) == P3D_FALSE) { + // Get coordinates from the list: + coords = coords_list_pop(&list); + + k = coords.z; + j = coords.y; + i = coords.x; + + // Re-assign voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = NODETOEND_LABEL; // NODE-TO-END Label + } + + // Set the endpoint as END_LABEL: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = END_LABEL; + } else { + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = END_LABEL; // END-POINT Label + + // Remove coordinates from the list: + coords = coords_list_pop(&list); + + // Restore ENDTOEND branch: + while (coords_list_isempty(list) == P3D_FALSE) { + // Get coordinates from the list: + coords = coords_list_pop(&list); + + k = coords.z; + j = coords.y; + i = coords.x; + + // Re-assign voxel: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = ENDTOEND_LABEL; + } + + // Set the endpoint as END_LABEL: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = END_LABEL; + } + }// end of cycle on each endpoint + + // Is an isolated voxel? + else if (ct == 0) { + // Isolated voxel removal: + tmp_im[ I(a, b, c, a_dimx, a_dimy) ] = ISOLATED_LABEL; + } + } + } + + // At this point we need to label NODETONODE branches and NODES: +#pragma omp parallel for private(i, j, ct) + for (k = a_rad; k < (a_dimz - a_rad); k++) + for (j = a_rad; j < (a_dimy - a_rad); j++) + for (i = a_rad; i < (a_dimx - a_rad); i++) { + if (tmp_im[ I(i, j, k, a_dimx, a_dimy) ] == OBJECT) { + // Check Neighborhood: + ct = countNeighbors(tmp_im, a_dimx, a_dimy, a_dimz, i, j, k); + + // Is a node voxel? + if (ct > 2) { + // Node point found: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = NODE_LABEL; + } + else { + // Node-to-Node voxel found: + tmp_im[ I(i, j, k, a_dimx, a_dimy) ] = NODETONODE_LABEL; + } + } + } + + + // Crop output: + P3D_TRY(p3dCrop3D_uchar2uchar(tmp_im, out_im, a_dimx, a_dimy, a_dimz, a_rad)); + + // Print elapsed time (if required): + if (wr_log != NULL) { + wr_log("Pore3D - Skeleton labeled successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + + // Return success: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) { + wr_log("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if (tmp_im != NULL) free(tmp_im); + + // Return error: + return P3D_ERROR; + +} + + + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dThinningSkeletonization.c b/pypore3d/pypore3d/P3D_Skel/p3dThinningSkeletonization.c new file mode 100644 index 0000000000000000000000000000000000000000..000c7d05fe5c94585c331b6854282f877c4221ba --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dThinningSkeletonization.c @@ -0,0 +1,79 @@ +#include <stdlib.h> +#include <omp.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dThinning.h" +#include "Common/p3dUtils.h" + + +int p3dThinningSkeletonization( + unsigned char* in_im, + unsigned char* out_im, + const int dimx, + const int dimy, + const int dimz, + int (*wr_log)(const char*, ...) + ) +{ + + unsigned char* tmp_im; + + // Padding/cropping size and dimensions + const int a_rad = 1; + const int a_dimx = dimx + a_rad*2; + const int a_dimy = dimy + a_rad*2; + const int a_dimz = dimz + a_rad*2; + + + // Start tracking computational time: + if (wr_log != NULL) + { + p3dResetStartTime(); + wr_log ("Pore3D - Performing thinning skeletonization..." ); + } + + + + // Init output voume with input volume values zero padded: + P3D_MEM_TRY( tmp_im = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + P3D_TRY( p3dZeroPadding3D_uchar2uchar ( in_im, tmp_im, dimx, dimy, dimz, a_rad ) ); + + // Call in-place version: + P3D_TRY( p3dThinning ( tmp_im, a_dimx, a_dimy, a_dimz ) ); + + // Crop output: + P3D_TRY( p3dCrop3D_uchar2uchar ( tmp_im, out_im, a_dimx, a_dimy, a_dimz, a_rad ) ); + + + + + // Print elapsed time (if required): + if (wr_log != NULL) + { + wr_log ("Pore3D - Thinning skeletonization performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if ( tmp_im != NULL ) free(tmp_im); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) + { + wr_log ("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if ( tmp_im != NULL ) free(tmp_im); + + + return P3D_ERROR; + +} + diff --git a/pypore3d/pypore3d/P3D_Skel/p3dTime.h b/pypore3d/pypore3d/P3D_Skel/p3dTime.h new file mode 100644 index 0000000000000000000000000000000000000000..8bb29440ed2ef2a2f06d01bf53912123a4921b04 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dTime.h @@ -0,0 +1,4 @@ +void p3dResetStartTime (); +double p3dGetElapsedTime(); +int p3dGetElapsedTime_min(); +double p3dGetElapsedTime_sec(); diff --git a/pypore3d/pypore3d/P3D_Skel/p3dUltimateSkeletonPruning.c b/pypore3d/pypore3d/P3D_Skel/p3dUltimateSkeletonPruning.c new file mode 100644 index 0000000000000000000000000000000000000000..ede2c475ee332e611e2903e176a35ce1e55c5a86 --- /dev/null +++ b/pypore3d/pypore3d/P3D_Skel/p3dUltimateSkeletonPruning.c @@ -0,0 +1,143 @@ +#include <stdlib.h> +#include <omp.h> + +#include "p3dSkel.h" +#include "p3dTime.h" + +#include "Common/p3dThinning.h" +#include "Common/p3dUtils.h" + + +int p3dUltimateSkeletonPruning( + unsigned char* in_im, // IN: Input (binary) skeleton + unsigned char* out_im, // OUT: Labeled skeleton + const int dimx, + const int dimy, + const int dimz, + const int iterative, + int (*wr_log)(const char*, ...) + ) +{ + int a,b,c; + + int noMoreChanges = P3D_FALSE; // Flag for iterative version of pruning + + // Dimensions for padded/cropped volumes: + int a_dimx, a_dimy, a_dimz; + int a_rad; + + // Padded and cropped temporary images: + unsigned char* tmp_im; + unsigned char* tmp_im2; + + + // Start tracking computational time: + if (wr_log != NULL) + { + p3dResetStartTime(); + wr_log ("Pore3D - Performing ultimate pruning..." ); + } + + // Create temporary input replicate-padded: + a_rad = 1; + + // Compute dimensions of padded REV: + a_dimx = dimx + a_rad*2; + a_dimy = dimy + a_rad*2; + a_dimz = dimz + a_rad*2; + + // Initialize input: + P3D_MEM_TRY( tmp_im = (unsigned char*) malloc( a_dimx*a_dimy*a_dimz*sizeof(unsigned char) ) ); + P3D_MEM_TRY( tmp_im2 = (unsigned char*) calloc( a_dimx*a_dimy*a_dimz,sizeof(unsigned char) ) ); + + P3D_TRY( p3dZeroPadding3D_uchar2uchar ( in_im, tmp_im2, dimx, dimy, dimz, a_rad ) ); + + + // Loop for iterations: + while ( noMoreChanges == P3D_FALSE) + { + noMoreChanges = P3D_TRUE; + + // Perform skeleton labeling: + P3D_TRY( p3dSkeletonLabeling ( tmp_im2, tmp_im, a_dimx, a_dimy, a_dimz, NULL ) ); + + // Volume scanning: + #pragma omp parallel for private(a, b) + for( c = a_rad; c < (a_dimz - a_rad); c++ ) + for( b = a_rad; b < (a_dimy - a_rad); b++ ) + for( a = a_rad; a < (a_dimx - a_rad); a++ ) + { + // If we're on a skeleton voxel different than one of a NODETOEND branch: + if ( ( tmp_im[ I( a, b, c, a_dimx, a_dimy ) ] != BACKGROUND ) && + ( tmp_im[ I( a, b, c, a_dimx, a_dimy ) ] != NODETOEND_LABEL ) ) + { + tmp_im2[ I( a, b, c, a_dimx, a_dimy) ] = OBJECT; + } + if ( tmp_im[ I( a, b, c, a_dimx, a_dimy ) ] == NODETOEND_LABEL ) + { + noMoreChanges = P3D_FALSE; + } + } + + // Remove isolated end points created by previous pruning: + #pragma omp parallel for private(a, b) + for( c = a_rad; c < (a_dimz - a_rad); c++ ) + for( b = a_rad; b < (a_dimy - a_rad); b++ ) + for( a = a_rad; a < (a_dimx - a_rad); a++ ) + { + // If we're on a skeleton voxel: + if ( tmp_im2[ I( a, b, c, a_dimx, a_dimy ) ] == OBJECT ) + { + // Check Neighborhood: + if ( countNeighbors ( tmp_im2, a_dimx, a_dimy, a_dimz, a, b, c ) == 0 ) + { + tmp_im2[ I( a, b, c, a_dimx, a_dimy ) ] = BACKGROUND; + } + } + } + + // Re-skeletonize: + p3dThinning ( tmp_im2, a_dimx, a_dimy, a_dimz ); + + // Avoid iterations if this option was undesidered: + if ( iterative == P3D_FALSE ) + noMoreChanges = P3D_TRUE; + + } + + // Crop output: + P3D_TRY( p3dCrop3D_uchar2uchar ( tmp_im2, out_im, a_dimx, a_dimy, a_dimz, a_rad ) ); + + + // Print elapsed time (if required): + if (wr_log != NULL) + { + wr_log ("Pore3D - Ultimate skeleton pruning performed successfully in %dm%0.3fs.", p3dGetElapsedTime_min(), p3dGetElapsedTime_sec()); + } + + // Release resources: + if ( tmp_im != NULL ) free(tmp_im); + if ( tmp_im2 != NULL ) free(tmp_im2); + + // Return OK: + return P3D_SUCCESS; + + +MEM_ERROR: + + if (wr_log != NULL) + { + wr_log ("Pore3D - Not enough (contiguous) memory. Program will exit."); + } + + // Release resources: + if ( tmp_im != NULL ) free ( tmp_im ); + if ( tmp_im2 != NULL ) free ( tmp_im2 ); + + + return P3D_ERROR; + +} + + + diff --git a/pypore3d/pypore3d/__init__.py b/pypore3d/pypore3d/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/pypore3d/pypore3d/p3dBlob.i b/pypore3d/pypore3d/p3dBlob.i new file mode 100644 index 0000000000000000000000000000000000000000..99bd8d2aca81c1db0948d87713578109d25395a5 --- /dev/null +++ b/pypore3d/pypore3d/p3dBlob.i @@ -0,0 +1,168 @@ + +%module p3dBlob + +%include typemaps.i +%include "exception.i" + + +%{ + #define SWIG_FILE_WITH_INIT + +#include <omp.h> + +#include "P3D_Blob/p3dBlob.h" +#include "P3D_Blob/p3dTime.h" +#include "P3D_Blob/Common/p3dBoundingBoxList.h" +#include "P3D_Blob/Common/p3dBoundingBoxT.h" +#include "P3D_Blob/Common/p3dConnectedComponentsLabeling.h" +#include "P3D_Blob/Common/p3dCoordsList.h" +#include "P3D_Blob/Common/p3dCoordsQueue.h" +#include "P3D_Blob/Common/p3dCoordsT.h" +#include "P3D_Blob/Common/p3dDoubleList.h" +#include "P3D_Blob/Common/p3dFCoordsList.h" +//#include "P3D_Blob/Common/p3dSquaredEuclideanDT.h" +#include "P3D_Blob/Common/p3dUIntList.h" +#include "P3D_Blob/Common/p3dUtils.h" + +#include <assert.h> +int myErr = 0; // flag to save error state + +%} + + + + +//////////////// +%include <cmalloc.i> +%include <cdata.i> +%allocators(unsigned char, uchar) +%allocators(unsigned short, ushort) +%allocators(double, doub) + +%allocators(BasicStats, BasicStat) +%allocators(AnisotropyStats, AnisotropyStat) +%allocators(MorphometricStats, MorphometricStat) +%allocators(TextureStats, TextureStat) +%allocators(BlobStats, BlobStat) + + + +//////////////// +%inline %{ + +//#include "P3D_Blob/p3dBlob.h" +#include <float.h> + +void PrintBlobStruct(BlobStats* out_stats, char* filename) +{ + // creating file pointer to work with files + FILE *fptr; + + // opening file in writing mode + fptr = fopen(filename, "w"); + + // exiting program + if (fptr == NULL) { + printf("Error!"); + exit(1); + } + + int Digs = FLT_DECIMAL_DIG; + + //fprintf(fptr, "Count:%d\n", out_stats->blobCount); + fprintf(fptr, "VOLUME,MAX_SPHERE,EQ_SPHERE,MIN_AXIS,MAX_AXIS,SPHERICITY,ASPECT_RATIO,Extent\n"); + for (int i = 0; i<out_stats->blobCount; i++) + { + + // adjust sphericity and aspect ration + //float sphericity = 0.0; + //if (out_stats->eq_sph[i]>=0.00000001) + // sphericity = out_stats->max_sph[i]/out_stats->eq_sph[i]; + //out_stats->sphericity[i] = sphericity; + + //float aspect_ratio = 0.0; + //if (out_stats->l_max[i]>=0.00000001) + // aspect_ratio = out_stats->l_min[i]/out_stats->l_max[i]; + //out_stats->aspect_ratio[i] = aspect_ratio ; + + //print to file + fprintf(fptr, "%.*e,", Digs, out_stats->volume[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->max_sph[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->eq_sph[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->l_min[i]); + fprintf(fptr, "%.*e,", Digs,out_stats->l_max[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->sphericity[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->aspect_ratio[i]); + fprintf(fptr, "%.*e\n", Digs, out_stats->extent[i]); + + + } + + + fclose(fptr); +} + + +void invert_vol(unsigned char* in_im, int dimx, int dimy, int dimz) +{ + for (int k = 0; k < dimz; k++) + for (int j = 0; j < dimy; j++) + for (int i = 0; i < dimx; i++) + { + + int ind = (i*dimz*dimy) + (j*dimz) + k; + in_im[ind] = 255 -in_im[ind]; + /* if (in_im[ind] >0) + in_im[ind] = 0; + else + in_im[ind] = 255 ; + */ + } +} + + +void invert_vol_16(unsigned short* in_im, int dimx, int dimy, int dimz) +{ + for (int k = 0; k < dimz; k++) + for (int j = 0; j < dimy; j++) + for (int i = 0; i < dimx; i++) + { + int ind = (i*dimz*dimy) + (j*dimz) + k; + in_im[ind] = (unsigned short) (255 -in_im[ind]); + /* + int ind = (i*dimz*dimy) + (j*dimz) + k; + if (in_im[ind] >0.0) + in_im[ind] = 0.0; + else + in_im[ind] = 1.0 ; + */ + } +} + + +%} + + + +//////////////// + + + +//////////////// +%include "P3D_Blob/p3dBlob.h" +%include "P3D_Blob/p3dTime.h" +%include "P3D_Blob/Common/p3dBoundingBoxList.h" +%include "P3D_Blob/Common/p3dBoundingBoxT.h" +%include "P3D_Blob/Common/p3dConnectedComponentsLabeling.h" +%include "P3D_Blob/Common/p3dCoordsList.h" +%include "P3D_Blob/Common/p3dCoordsQueue.h" +%include "P3D_Blob/Common/p3dCoordsT.h" +%include "P3D_Blob/Common/p3dDoubleList.h" +%include "P3D_Blob/Common/p3dFCoordsList.h" +/*%include "P3D_Blob/Common/p3dSquaredEuclideanDT.h"*/ +%include "P3D_Blob/Common/p3dUIntList.h" +%include "P3D_Blob/Common/p3dUtils.h" + + + + diff --git a/pypore3d/pypore3d/p3dBlob.py b/pypore3d/pypore3d/p3dBlob.py new file mode 100644 index 0000000000000000000000000000000000000000..b431317eade66afc3b22e8f8d088408f67888c03 --- /dev/null +++ b/pypore3d/pypore3d/p3dBlob.py @@ -0,0 +1,589 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 4.0.1 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +from sys import version_info as _swig_python_version_info +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") + +# Import the low-level C/C++ module +if __package__ or "." in __name__: + from . import _p3dBlob +else: + import _p3dBlob + +try: + import builtins as __builtin__ +except ImportError: + import __builtin__ + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) + else: + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr + + +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr + + +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper + + +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + + + +def cdata(ptr, nelements=1): + return _p3dBlob.cdata(ptr, nelements) + +def memmove(data, indata): + return _p3dBlob.memmove(data, indata) + +def malloc_uchar(*args): + return _p3dBlob.malloc_uchar(*args) + +def calloc_uchar(*args): + return _p3dBlob.calloc_uchar(*args) + +def realloc_uchar(ptr, nitems): + return _p3dBlob.realloc_uchar(ptr, nitems) + +def free_uchar(ptr): + return _p3dBlob.free_uchar(ptr) +sizeof_uchar = _p3dBlob.sizeof_uchar + +def malloc_ushort(*args): + return _p3dBlob.malloc_ushort(*args) + +def calloc_ushort(*args): + return _p3dBlob.calloc_ushort(*args) + +def realloc_ushort(ptr, nitems): + return _p3dBlob.realloc_ushort(ptr, nitems) + +def free_ushort(ptr): + return _p3dBlob.free_ushort(ptr) +sizeof_ushort = _p3dBlob.sizeof_ushort + +def malloc_doub(*args): + return _p3dBlob.malloc_doub(*args) + +def calloc_doub(*args): + return _p3dBlob.calloc_doub(*args) + +def realloc_doub(ptr, nitems): + return _p3dBlob.realloc_doub(ptr, nitems) + +def free_doub(ptr): + return _p3dBlob.free_doub(ptr) +sizeof_doub = _p3dBlob.sizeof_doub + +def malloc_BasicStat(*args): + return _p3dBlob.malloc_BasicStat(*args) + +def calloc_BasicStat(*args): + return _p3dBlob.calloc_BasicStat(*args) + +def realloc_BasicStat(ptr, nitems): + return _p3dBlob.realloc_BasicStat(ptr, nitems) + +def free_BasicStat(ptr): + return _p3dBlob.free_BasicStat(ptr) +sizeof_BasicStat = _p3dBlob.sizeof_BasicStat + +def malloc_AnisotropyStat(*args): + return _p3dBlob.malloc_AnisotropyStat(*args) + +def calloc_AnisotropyStat(*args): + return _p3dBlob.calloc_AnisotropyStat(*args) + +def realloc_AnisotropyStat(ptr, nitems): + return _p3dBlob.realloc_AnisotropyStat(ptr, nitems) + +def free_AnisotropyStat(ptr): + return _p3dBlob.free_AnisotropyStat(ptr) +sizeof_AnisotropyStat = _p3dBlob.sizeof_AnisotropyStat + +def malloc_MorphometricStat(*args): + return _p3dBlob.malloc_MorphometricStat(*args) + +def calloc_MorphometricStat(*args): + return _p3dBlob.calloc_MorphometricStat(*args) + +def realloc_MorphometricStat(ptr, nitems): + return _p3dBlob.realloc_MorphometricStat(ptr, nitems) + +def free_MorphometricStat(ptr): + return _p3dBlob.free_MorphometricStat(ptr) +sizeof_MorphometricStat = _p3dBlob.sizeof_MorphometricStat + +def malloc_TextureStat(*args): + return _p3dBlob.malloc_TextureStat(*args) + +def calloc_TextureStat(*args): + return _p3dBlob.calloc_TextureStat(*args) + +def realloc_TextureStat(ptr, nitems): + return _p3dBlob.realloc_TextureStat(ptr, nitems) + +def free_TextureStat(ptr): + return _p3dBlob.free_TextureStat(ptr) +sizeof_TextureStat = _p3dBlob.sizeof_TextureStat + +def malloc_BlobStat(*args): + return _p3dBlob.malloc_BlobStat(*args) + +def calloc_BlobStat(*args): + return _p3dBlob.calloc_BlobStat(*args) + +def realloc_BlobStat(ptr, nitems): + return _p3dBlob.realloc_BlobStat(ptr, nitems) + +def free_BlobStat(ptr): + return _p3dBlob.free_BlobStat(ptr) +sizeof_BlobStat = _p3dBlob.sizeof_BlobStat + +def PrintBlobStruct(out_stats, filename): + return _p3dBlob.PrintBlobStruct(out_stats, filename) + +def invert_vol(in_im, dimx, dimy, dimz): + return _p3dBlob.invert_vol(in_im, dimx, dimy, dimz) + +def invert_vol_16(in_im, dimx, dimy, dimz): + return _p3dBlob.invert_vol_16(in_im, dimx, dimy, dimz) +P3D_FALSE = _p3dBlob.P3D_FALSE +P3D_TRUE = _p3dBlob.P3D_TRUE +P3D_ERROR = _p3dBlob.P3D_ERROR +P3D_SUCCESS = _p3dBlob.P3D_SUCCESS +BACKGROUND = _p3dBlob.BACKGROUND +CONN4 = _p3dBlob.CONN4 +CONN8 = _p3dBlob.CONN8 +CONN6 = _p3dBlob.CONN6 +CONN18 = _p3dBlob.CONN18 +CONN26 = _p3dBlob.CONN26 +class BlobStats(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + aspect_ratio = property(_p3dBlob.BlobStats_aspect_ratio_get, _p3dBlob.BlobStats_aspect_ratio_set) + blobCount = property(_p3dBlob.BlobStats_blobCount_get, _p3dBlob.BlobStats_blobCount_set) + max_sph = property(_p3dBlob.BlobStats_max_sph_get, _p3dBlob.BlobStats_max_sph_set) + eq_sph = property(_p3dBlob.BlobStats_eq_sph_get, _p3dBlob.BlobStats_eq_sph_set) + l_min = property(_p3dBlob.BlobStats_l_min_get, _p3dBlob.BlobStats_l_min_set) + l_max = property(_p3dBlob.BlobStats_l_max_get, _p3dBlob.BlobStats_l_max_set) + sphericity = property(_p3dBlob.BlobStats_sphericity_get, _p3dBlob.BlobStats_sphericity_set) + extent = property(_p3dBlob.BlobStats_extent_get, _p3dBlob.BlobStats_extent_set) + volume = property(_p3dBlob.BlobStats_volume_get, _p3dBlob.BlobStats_volume_set) + + def __init__(self): + _p3dBlob.BlobStats_swiginit(self, _p3dBlob.new_BlobStats()) + __swig_destroy__ = _p3dBlob.delete_BlobStats + +# Register BlobStats in _p3dBlob: +_p3dBlob.BlobStats_swigregister(BlobStats) + +class MorphometricStats(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + BvTv = property(_p3dBlob.MorphometricStats_BvTv_get, _p3dBlob.MorphometricStats_BvTv_set) + BsBv = property(_p3dBlob.MorphometricStats_BsBv_get, _p3dBlob.MorphometricStats_BsBv_set) + TbN = property(_p3dBlob.MorphometricStats_TbN_get, _p3dBlob.MorphometricStats_TbN_set) + TbTh = property(_p3dBlob.MorphometricStats_TbTh_get, _p3dBlob.MorphometricStats_TbTh_set) + TbSp = property(_p3dBlob.MorphometricStats_TbSp_get, _p3dBlob.MorphometricStats_TbSp_set) + + def __init__(self): + _p3dBlob.MorphometricStats_swiginit(self, _p3dBlob.new_MorphometricStats()) + __swig_destroy__ = _p3dBlob.delete_MorphometricStats + +# Register MorphometricStats in _p3dBlob: +_p3dBlob.MorphometricStats_swigregister(MorphometricStats) + +class AnisotropyStats(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + I = property(_p3dBlob.AnisotropyStats_I_get, _p3dBlob.AnisotropyStats_I_set) + E = property(_p3dBlob.AnisotropyStats_E_get, _p3dBlob.AnisotropyStats_E_set) + + def __init__(self): + _p3dBlob.AnisotropyStats_swiginit(self, _p3dBlob.new_AnisotropyStats()) + __swig_destroy__ = _p3dBlob.delete_AnisotropyStats + +# Register AnisotropyStats in _p3dBlob: +_p3dBlob.AnisotropyStats_swigregister(AnisotropyStats) + +class BasicStats(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + Vv = property(_p3dBlob.BasicStats_Vv_get, _p3dBlob.BasicStats_Vv_set) + Cv = property(_p3dBlob.BasicStats_Cv_get, _p3dBlob.BasicStats_Cv_set) + Mv = property(_p3dBlob.BasicStats_Mv_get, _p3dBlob.BasicStats_Mv_set) + Sv = property(_p3dBlob.BasicStats_Sv_get, _p3dBlob.BasicStats_Sv_set) + + def __init__(self): + _p3dBlob.BasicStats_swiginit(self, _p3dBlob.new_BasicStats()) + __swig_destroy__ = _p3dBlob.delete_BasicStats + +# Register BasicStats in _p3dBlob: +_p3dBlob.BasicStats_swigregister(BasicStats) + +class TextureStats(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + FD = property(_p3dBlob.TextureStats_FD_get, _p3dBlob.TextureStats_FD_set) + + def __init__(self): + _p3dBlob.TextureStats_swiginit(self, _p3dBlob.new_TextureStats()) + __swig_destroy__ = _p3dBlob.delete_TextureStats + +# Register TextureStats in _p3dBlob: +_p3dBlob.TextureStats_swigregister(TextureStats) + + +def p3dBlobAnalysis(in_im, out_stats, blob_im, star_im, dimx, dimy, dimz, voxelsize, conn, max_rot, skip_borders, wr_log): + return _p3dBlob.p3dBlobAnalysis(in_im, out_stats, blob_im, star_im, dimx, dimy, dimz, voxelsize, conn, max_rot, skip_borders, wr_log) + +def p3dBasicAnalysis(in_im, out_stats, dimx, dimy, dimz, voxelsize, wr_log): + return _p3dBlob.p3dBasicAnalysis(in_im, out_stats, dimx, dimy, dimz, voxelsize, wr_log) + +def p3dTextureAnalysis(in_im, out_stats, dimx, dimy, dimz, wr_log): + return _p3dBlob.p3dTextureAnalysis(in_im, out_stats, dimx, dimy, dimz, wr_log) + +def p3dAnisotropyAnalysis(in_im, msk_im, out_stats, dimx, dimy, dimz, voxelsize, verbose, wr_log): + return _p3dBlob.p3dAnisotropyAnalysis(in_im, msk_im, out_stats, dimx, dimy, dimz, voxelsize, verbose, wr_log) + +def p3dMorphometricAnalysis(in_im, msk_im, out_stats, dimx, dimy, dimz, voxelsize, wr_log): + return _p3dBlob.p3dMorphometricAnalysis(in_im, msk_im, out_stats, dimx, dimy, dimz, voxelsize, wr_log) + +def p3dREVEstimation(in_rev, porosity, cubeEdges, numel, dimx, dimy, dimz, stepsize, centerx, centery, centerz, wr_log): + return _p3dBlob.p3dREVEstimation(in_rev, porosity, cubeEdges, numel, dimx, dimy, dimz, stepsize, centerx, centery, centerz, wr_log) + +def p3dChamferDT(in_im, out_im, dimx, dimy, dimz, w1, w2, w3, wr_log): + return _p3dBlob.p3dChamferDT(in_im, out_im, dimx, dimy, dimz, w1, w2, w3, wr_log) + +def p3dBlobLabeling_ushort(in_im, out_im, dimx, dimy, dimz, conn, random_lbl, skip_borders, wr_log): + return _p3dBlob.p3dBlobLabeling_ushort(in_im, out_im, dimx, dimy, dimz, conn, random_lbl, skip_borders, wr_log) + +def p3dBlobLabeling_uint(in_im, out_im, dimx, dimy, dimz, conn, random_lbl, skip_borders, wr_log): + return _p3dBlob.p3dBlobLabeling_uint(in_im, out_im, dimx, dimy, dimz, conn, random_lbl, skip_borders, wr_log) + +def p3dGetMaxVolumeBlob3D(in_rev, out_rev, dimx, dimy, dimz, conn, wr_log): + return _p3dBlob.p3dGetMaxVolumeBlob3D(in_rev, out_rev, dimx, dimy, dimz, conn, wr_log) + +def p3dGetMinVolumeBlob3D(in_rev, out_rev, dimx, dimy, dimz, conn, wr_log): + return _p3dBlob.p3dGetMinVolumeBlob3D(in_rev, out_rev, dimx, dimy, dimz, conn, wr_log) + +def p3dMinVolumeFilter3D(in_im, out_im, dimx, dimy, dimz, min_volume, conn, wr_log): + return _p3dBlob.p3dMinVolumeFilter3D(in_im, out_im, dimx, dimy, dimz, min_volume, conn, wr_log) + +def p3dSquaredEuclideanDT(in_rev, out_rev, dimx, dimy, dimz, wr_log): + return _p3dBlob.p3dSquaredEuclideanDT(in_rev, out_rev, dimx, dimy, dimz, wr_log) + +def p3dResetStartTime(): + return _p3dBlob.p3dResetStartTime() + +def p3dGetElapsedTime(): + return _p3dBlob.p3dGetElapsedTime() + +def p3dGetElapsedTime_min(): + return _p3dBlob.p3dGetElapsedTime_min() + +def p3dGetElapsedTime_sec(): + return _p3dBlob.p3dGetElapsedTime_sec() +class bb_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dBlob.bb_lelem_t_elem_get, _p3dBlob.bb_lelem_t_elem_set) + next = property(_p3dBlob.bb_lelem_t_next_get, _p3dBlob.bb_lelem_t_next_set) + + def __init__(self): + _p3dBlob.bb_lelem_t_swiginit(self, _p3dBlob.new_bb_lelem_t()) + __swig_destroy__ = _p3dBlob.delete_bb_lelem_t + +# Register bb_lelem_t in _p3dBlob: +_p3dBlob.bb_lelem_t_swigregister(bb_lelem_t) + + +def bb_list_init(list): + return _p3dBlob.bb_list_init(list) + +def bb_list_add(list, item): + return _p3dBlob.bb_list_add(list, item) + +def bb_list_isempty(list): + return _p3dBlob.bb_list_isempty(list) + +def bb_list_toarray(list, numel): + return _p3dBlob.bb_list_toarray(list, numel) + +def bb_list_clear(list): + return _p3dBlob.bb_list_clear(list) +class bb_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + min_x = property(_p3dBlob.bb_t_min_x_get, _p3dBlob.bb_t_min_x_set) + max_x = property(_p3dBlob.bb_t_max_x_get, _p3dBlob.bb_t_max_x_set) + min_y = property(_p3dBlob.bb_t_min_y_get, _p3dBlob.bb_t_min_y_set) + max_y = property(_p3dBlob.bb_t_max_y_get, _p3dBlob.bb_t_max_y_set) + min_z = property(_p3dBlob.bb_t_min_z_get, _p3dBlob.bb_t_min_z_set) + max_z = property(_p3dBlob.bb_t_max_z_get, _p3dBlob.bb_t_max_z_set) + + def __init__(self): + _p3dBlob.bb_t_swiginit(self, _p3dBlob.new_bb_t()) + __swig_destroy__ = _p3dBlob.delete_bb_t + +# Register bb_t in _p3dBlob: +_p3dBlob.bb_t_swigregister(bb_t) + + +def p3dConnectedComponentsLabeling_ushort(in_rev, out_rev, numOfConnectedComponents, volumes, boundingBoxes, dimx, dimy, dimz, conn, random_lbl, skip_borders): + return _p3dBlob.p3dConnectedComponentsLabeling_ushort(in_rev, out_rev, numOfConnectedComponents, volumes, boundingBoxes, dimx, dimy, dimz, conn, random_lbl, skip_borders) + +def p3dConnectedComponentsLabeling_uint(in_rev, out_rev, numOfConnectedComponents, volumes, boundingBoxes, dimx, dimy, dimz, conn, random_lbl, skip_borders): + return _p3dBlob.p3dConnectedComponentsLabeling_uint(in_rev, out_rev, numOfConnectedComponents, volumes, boundingBoxes, dimx, dimy, dimz, conn, random_lbl, skip_borders) +class coords_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dBlob.coords_lelem_t_elem_get, _p3dBlob.coords_lelem_t_elem_set) + next = property(_p3dBlob.coords_lelem_t_next_get, _p3dBlob.coords_lelem_t_next_set) + + def __init__(self): + _p3dBlob.coords_lelem_t_swiginit(self, _p3dBlob.new_coords_lelem_t()) + __swig_destroy__ = _p3dBlob.delete_coords_lelem_t + +# Register coords_lelem_t in _p3dBlob: +_p3dBlob.coords_lelem_t_swigregister(coords_lelem_t) + + +def coords_list_init(arg1): + return _p3dBlob.coords_list_init(arg1) + +def coords_list_push(arg1, arg2): + return _p3dBlob.coords_list_push(arg1, arg2) + +def coords_list_pop(arg1): + return _p3dBlob.coords_list_pop(arg1) + +def coords_list_isempty(arg1): + return _p3dBlob.coords_list_isempty(arg1) + +def coords_list_toarray(arg1, arg2): + return _p3dBlob.coords_list_toarray(arg1, arg2) +class coords_qelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + item = property(_p3dBlob.coords_qelem_t_item_get, _p3dBlob.coords_qelem_t_item_set) + next = property(_p3dBlob.coords_qelem_t_next_get, _p3dBlob.coords_qelem_t_next_set) + + def __init__(self): + _p3dBlob.coords_qelem_t_swiginit(self, _p3dBlob.new_coords_qelem_t()) + __swig_destroy__ = _p3dBlob.delete_coords_qelem_t + +# Register coords_qelem_t in _p3dBlob: +_p3dBlob.coords_qelem_t_swigregister(coords_qelem_t) + +class coords_queue_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + tail = property(_p3dBlob.coords_queue_t_tail_get, _p3dBlob.coords_queue_t_tail_set) + head = property(_p3dBlob.coords_queue_t_head_get, _p3dBlob.coords_queue_t_head_set) + + def __init__(self): + _p3dBlob.coords_queue_t_swiginit(self, _p3dBlob.new_coords_queue_t()) + __swig_destroy__ = _p3dBlob.delete_coords_queue_t + +# Register coords_queue_t in _p3dBlob: +_p3dBlob.coords_queue_t_swigregister(coords_queue_t) + + +def coords_queue_init(queue): + return _p3dBlob.coords_queue_init(queue) + +def coords_queue_push(queue, elem): + return _p3dBlob.coords_queue_push(queue, elem) + +def coords_queue_pop(queue): + return _p3dBlob.coords_queue_pop(queue) + +def coords_queue_isempty(queue): + return _p3dBlob.coords_queue_isempty(queue) +class coords_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dBlob.coords_t_x_get, _p3dBlob.coords_t_x_set) + y = property(_p3dBlob.coords_t_y_get, _p3dBlob.coords_t_y_set) + z = property(_p3dBlob.coords_t_z_get, _p3dBlob.coords_t_z_set) + + def __init__(self): + _p3dBlob.coords_t_swiginit(self, _p3dBlob.new_coords_t()) + __swig_destroy__ = _p3dBlob.delete_coords_t + +# Register coords_t in _p3dBlob: +_p3dBlob.coords_t_swigregister(coords_t) + +class fcoords_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dBlob.fcoords_t_x_get, _p3dBlob.fcoords_t_x_set) + y = property(_p3dBlob.fcoords_t_y_get, _p3dBlob.fcoords_t_y_set) + z = property(_p3dBlob.fcoords_t_z_get, _p3dBlob.fcoords_t_z_set) + + def __init__(self): + _p3dBlob.fcoords_t_swiginit(self, _p3dBlob.new_fcoords_t()) + __swig_destroy__ = _p3dBlob.delete_fcoords_t + +# Register fcoords_t in _p3dBlob: +_p3dBlob.fcoords_t_swigregister(fcoords_t) + +class double_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + ct = property(_p3dBlob.double_lelem_t_ct_get, _p3dBlob.double_lelem_t_ct_set) + next = property(_p3dBlob.double_lelem_t_next_get, _p3dBlob.double_lelem_t_next_set) + + def __init__(self): + _p3dBlob.double_lelem_t_swiginit(self, _p3dBlob.new_double_lelem_t()) + __swig_destroy__ = _p3dBlob.delete_double_lelem_t + +# Register double_lelem_t in _p3dBlob: +_p3dBlob.double_lelem_t_swigregister(double_lelem_t) + + +def double_list_init(list): + return _p3dBlob.double_list_init(list) + +def double_list_add(list, item): + return _p3dBlob.double_list_add(list, item) + +def double_list_isempty(list): + return _p3dBlob.double_list_isempty(list) + +def double_list_toarray(list, numel): + return _p3dBlob.double_list_toarray(list, numel) +class fcoords_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dBlob.fcoords_lelem_t_elem_get, _p3dBlob.fcoords_lelem_t_elem_set) + next = property(_p3dBlob.fcoords_lelem_t_next_get, _p3dBlob.fcoords_lelem_t_next_set) + + def __init__(self): + _p3dBlob.fcoords_lelem_t_swiginit(self, _p3dBlob.new_fcoords_lelem_t()) + __swig_destroy__ = _p3dBlob.delete_fcoords_lelem_t + +# Register fcoords_lelem_t in _p3dBlob: +_p3dBlob.fcoords_lelem_t_swigregister(fcoords_lelem_t) + + +def fcoords_list_init(arg1): + return _p3dBlob.fcoords_list_init(arg1) + +def fcoords_list_push(arg1, arg2): + return _p3dBlob.fcoords_list_push(arg1, arg2) + +def fcoords_list_pop(arg1): + return _p3dBlob.fcoords_list_pop(arg1) + +def fcoords_list_isempty(arg1): + return _p3dBlob.fcoords_list_isempty(arg1) + +def fcoords_list_toarray(arg1, arg2): + return _p3dBlob.fcoords_list_toarray(arg1, arg2) +class uint_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + ct = property(_p3dBlob.uint_lelem_t_ct_get, _p3dBlob.uint_lelem_t_ct_set) + next = property(_p3dBlob.uint_lelem_t_next_get, _p3dBlob.uint_lelem_t_next_set) + + def __init__(self): + _p3dBlob.uint_lelem_t_swiginit(self, _p3dBlob.new_uint_lelem_t()) + __swig_destroy__ = _p3dBlob.delete_uint_lelem_t + +# Register uint_lelem_t in _p3dBlob: +_p3dBlob.uint_lelem_t_swigregister(uint_lelem_t) + + +def uint_list_init(list): + return _p3dBlob.uint_list_init(list) + +def uint_list_add(list, ct): + return _p3dBlob.uint_list_add(list, ct) + +def uint_list_isempty(list): + return _p3dBlob.uint_list_isempty(list) + +def uint_list_toarray(list, numel): + return _p3dBlob.uint_list_toarray(list, numel) + +def uint_list_clear(list): + return _p3dBlob.uint_list_clear(list) + +def findNeighbor(im, dimx, dimy, dimz, i, j, k, coords): + return _p3dBlob.findNeighbor(im, dimx, dimy, dimz, i, j, k, coords) + +def countNeighbors(im, dimx, dimy, dimz, i, j, k): + return _p3dBlob.countNeighbors(im, dimx, dimy, dimz, i, j, k) + +def isSimplePoint(im, dimx, dimy, dimz, x, y, z): + return _p3dBlob.isSimplePoint(im, dimx, dimy, dimz, x, y, z) + +def p3dCrop3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dCrop3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size) + +def p3dCrop3D_ushort2ushort(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dCrop3D_ushort2ushort(in_im, out_im, dimx, dimy, dimz, size) + +def p3dCrop3D_uint2uint(in_rev, out_rev, dimx, dimy, dimz, size): + return _p3dBlob.p3dCrop3D_uint2uint(in_rev, out_rev, dimx, dimy, dimz, size) + +def p3dCrop3D_float2float(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dCrop3D_float2float(in_im, out_im, dimx, dimy, dimz, size) + +def p3dZeroPadding3D_uchar2float(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dZeroPadding3D_uchar2float(in_im, out_im, dimx, dimy, dimz, size) + +def p3dZeroPadding3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dZeroPadding3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size) + +def p3dReplicatePadding3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dReplicatePadding3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size) + +def interpolation(gvf, dimx, dimy, dimz, x, y, z): + return _p3dBlob.interpolation(gvf, dimx, dimy, dimz, x, y, z) + +def isBoundary(in_im, dimx, dimy, dimz, i, j, k): + return _p3dBlob.isBoundary(in_im, dimx, dimy, dimz, i, j, k) + +def isFullNeighborhood(in_im, dimx, dimy, dimz, i, j, k): + return _p3dBlob.isFullNeighborhood(in_im, dimx, dimy, dimz, i, j, k) + +def p3dSpecialPadding3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size): + return _p3dBlob.p3dSpecialPadding3D_uchar2uchar(in_im, out_im, dimx, dimy, dimz, size) + + diff --git a/pypore3d/pypore3d/p3dBlobPy.py b/pypore3d/pypore3d/p3dBlobPy.py new file mode 100644 index 0000000000000000000000000000000000000000..e7cc5a61b12798b82b7f30e58948de936c4a17db --- /dev/null +++ b/pypore3d/pypore3d/p3dBlobPy.py @@ -0,0 +1,520 @@ + +import pypore3d.p3d_common_lib +from pypore3d.p3d_common_lib import * + +import pypore3d.p3dBlob +from pypore3d.p3dBlob import * + + +################# + +#Basic analysis +def py_p3dBasicAnalysis(image_data, dimx, dimy, dimz = 0, resolution = 1.0): + """ + + Performs a series of direct 3D basic analysis for randomly distributed porous media. + + Syntax: + ------ + Result = py_p3dBasicAnalysis ( image_data, dimx, dimy, [dimz = value] [, resolution = value] ) + + Return Value: + ------------ + Performs a series of direct 3D basic analysis for randomly distributed porous media. Computed parameters are [1]: + + VV [-]: Density (VV). A measure of density based on the number of object voxels with respect to the total number of volume voxels. + + SV [mm-1]: Specific surface area (SV). A measure of the surface of the object with respect to the total volume. Tipically it is related to the mechanical properties of the object. + + MV [mm-2]: Integral of mean curvature (MV). A positive value implies the dominance of convex structures, while MV < 0 occurs in the case of predominance of concave structures. + + CV [mm-3]: Euler characteristic (ΧV). This is an index of connectivity of the object network. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + resolution: A decimal value representing the resolution of input image. If this value is not specified a voxelsize of 1.0 is assumed that means output values are expressed in voxel unit. + + References: + --------- + + [1] J. Ohser and F. Mücklich, Statistical Analysis of Microstructures in Materials Science. Wiley & Sons, 2000. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_BasicStats = BasicStats() + err_code = p3dBasicAnalysis(image_data,out_BasicStats,dimx,dimy,dimz, resolution, None) + py_printErrorMessage(err_code) + return out_BasicStats + +#Anisotrtopy analysis +def py_p3dAnisotropyAnalysis(image_data, dimx, dimy, dimz = 0, resolution = 1.0): + """ + + Returns a struct of parameters computed from input binary image. Computed parameters are [1]: + + Syntax: + ------ + Result = py_p3dAnisotropyAnalysis ( image_data, dimx, dimy, [dimz = value] [, resolution = value] [, details = boolean] ) + + Return Value: + ------------ + Performs a series of direct 3D basic analysis for randomly distributed porous media. Computed parameters are [1]: + + I [-]: sotropy index. It measures the similarity of a fabric to a uniform distribution and varies between 0 (all observation confined to a single plane or axis) and 1 (perfect isotropy) + + E [-]: Elongation index. It measures the preferred orientation of a fabric in the u1/u2 plane and varies between 0 (no preferred orientation) and 1 (a perfect preferred orientation with all observations parallel). + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + resolution: A decimal value representing the resolution of input image. If this value is not specified a voxelsize of 1.0 is assumed that means output values are expressed in voxel unit. + + + References: + ---------- + + [1] S.C. Cowin and A.J. Laborde, The relationship between the elasticity tensor and the fabric tensor. Mechanics of Materials, Vol. 4, No. 22, pp. 137-147, 1985. + + [2] S.C. Cowin, Wolff's law of trabecular architecture at remodeling equilibrium. Journal of Biomechanical Engineering, Vol. 108, No. 1, pp. 83-88, 1986. + + [3] W.J. Whitehouse, The quantitative morphology of anisotropic trabecular bone. Journal of Microscoscopy, Vol. 101, pp. 153-168, 1974. + + [4] T.P. Harrigan and R.W. Mann, Characterization of microstructural anisotropy in orthotropic materials using a second rank tensor. Journal of Material Science, Vol. 19, No. 3, pp. 761-767, 1984. + + [5] D. I. Benn, Fabric shape and the interpolation of sedimentary fabric data. Journal of Sedimentary Research, Vol. 64, No. 2, pp. 910-915, 1994. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_AnisotropyStats = AnisotropyStats() + im_dummy_mask = malloc_uchar(dimx*dimy*dimz) + im_dummy_mask = image_data + details = False + err_code = p3dAnisotropyAnalysis(image_data, None, out_AnisotropyStats, dimx, dimy, dimz, resolution, details , None) + py_printErrorMessage(err_code) + return out_AnisotropyStats + +#Blob labeling +def py_p3dBlobLabeling(image_data, dimx, dimy, dimz = 0, conn3D = CONN6 ): + """ + + Performs connected components (blobs) labeling using the algorithm proposed in [1]. + + Connected components labeling scans an image and groups its voxels into components based on voxel connectivity. Once all + groups have been determined, each voxels is labeled with a graylevel according to the component it was assigned to. + + Syntax: + ------ + Result = py_p3dBlobLabeling ( image_data, dimx, dimy, dimz [, conn3D = value] ) + + Return Value: + ------------ + Returns an image of type UINT with the same dimensions of input image in which each connected component is assigned a + different gray-level. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + conn3D: Specify the desired connectivity: 6 (default), 18 or 26 for 3D images. + + Remarks + ------- + No casting to 8-bit format is performed if less than 256 connected components are determined in an image. Returned output + remains in 16-bit format in any case. Obviously, this implies that no more than 65535 connected components may be recognized in + input image. + + References: + ---------- + + [1] Q. Hu et al., Fast connected-component labeling in three-dimensional binary images based on iterative recursion. Computer Vision and Image Understanding, Vol. 99, pp. 414-434, 2005. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + skip_borders = 1 + rand = 0 + err_code = p3dBlobLabeling_ushort(image_data, out_image, dimx,dimy,dimz,conn3D, rand , skip_borders, None) + py_printErrorMessage(err_code) + return out_image + +#Blob Get max +def py_p3dGetMaxVolumeBlob3D(image_data, dimx, dimy, dimz = 0, conn3D = CONN6): + """ + + Returns an image containing only the connected component (blob) of input binary image having the greatest volume. + + The algorithm performs a connected components labeling with contextually computation of the volume (or area for 2D images) of each component. An image containing the connected component having only the greatest volume is returned as output. + + Syntax: + ------ + Result = py_p3dGetMaxVolumeBlob3D ( image_data, dimx, dimy, [dimz = value] [, conn3D = value] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + conn3D: The desired connectivity, i.e. 6, 18 or 26 for 3D images. The default connectivity is 6 for three dimensional images. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dGetMaxVolumeBlob3D(image_data, out_image, dimx,dimy,dimz,conn3D, None) + py_printErrorMessage(err_code) + return out_image + +#Blob Get min +def py_p3dGetMinVolumeBlob3D(image_data, dimx, dimy, dimz = 0, conn3D = CONN6): + """ + + Returns an image containing only the connected component (blob) of input binary image having the minimum volume. + + The algorithm performs a connected components labeling with contextually computation of the volume (or area for 2D images) of each component. An image containing the connected component having only the greatest volume is returned as output. + + Syntax: + ------ + Result = py_p3dGetMinVolumeBlob3D ( image_data, dimx, dimy, [dimz = value] [, conn3D = value] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + conn3D: The desired connectivity, i.e. 6, 18 or 26 for 3D images. The default connectivity is 6 for three dimensional images. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dGetMinVolumeBlob3D(image_data, out_image, dimx,dimy,dimz,conn3D, None) + py_printErrorMessage(err_code) + return out_image + +#ChamferDT +def py_p3dChamferDT(image_data, dimx, dimy, dimz = 0, w1 = 3, w2 = 4, w3 = 5): + """ + In a distance transformed image, each object voxel has a value measuring the distance to the nearest background voxel. + + The distance transform (DT) is sometimes called "burn number distribution". Imagine that foreground regions in the input binary image are made of some uniform slow burning inflammable material. Then consider simultaneously starting a fire at all points on the boundary of a foreground region and letting the fire burn its way into the interior. Labeling each point in the interior with the amount of time that the fire took to first reach that point, means effectively computing the distance transform of that region. + + There are several different sorts of distance transform, depending upon which distance metric is being used to determine the distance between voxels. The different distance measures are achieved by using different sets of weights in a sequential scanning algorithm, as described in [1]. Not all combinations of local distances <w1,w2,w3> result in useful distance transforms. The most interesting weighted (or chamfer) distance transforms implemented in Pore3D are: + Cityblock (or "Manhattan") :<1,-,-> + Chessboard: <1,1,1> + Quasi-Euclidean: <3,4,5> + + Syntax: + ------ + Result = py_p3dChamferDT ( image_data, dimx, dimy, [dimz = value] [, w1 = value] [, w2 = value] [, w3 = value]) + + Return Value: + ------------ + Returns the distance transform image with the same dimensions of input image and type BYTE. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + w1, w2, w3: three integer values (default: [3,4,5]) representing the weights of the chamfer distance transform. + + References: + ---------- + [1] G. Borgefors, On Digital Distance Transforms in Three Dimensions, Computer Vision and Image Understanding, Vol. 64, No. 3, pp. 368-376, 1996. + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dChamferDT(image_data, out_image, dimx,dimy,dimz,w1, w2, w3, None) + py_printErrorMessage(err_code) + return out_image + +#SquaredEuclideanDT +def py_p3dSquaredEuclideanDT(image_data, dimx, dimy, dimz = 0): + """ + In a distance transformed image, each object voxel has a value measuring the distance to the nearest background voxel. + + The distance transform (DT) is sometimes called "burn number distribution". Imagine that foreground regions in the input binary image are made of some uniform slow burning inflammable material. Then consider simultaneously starting a fire at all points on the boundary of a foreground region and letting the fire burn its way into the interior. Labeling each point in the interior with the amount of time that the fire took to first reach that point, means effectively computing the distance transform of that region. + + There are several different sorts of distance transform, depending upon which distance metric is being used to determine the distance between voxels. The euclidean distance is the one adopted in p3dSquaredEuclideanDT and in order to avoid decimal number, squared values are returned. + + Syntax: + ------ + Result = py_p3dSquaredEuclideanDT ( image_data, dimx, dimy, [dimz = value]) + + Return Value: + ------------ + Returns the distance transform image with the same dimensions of input image and type UINT. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + References: + ---------- + + [1] T. Hirata. A unified linear-time algorithm for computing distance maps. Information Processing Letters, 58(3):129-133, May 1996. + + [2] A. Meijster, J.B.T.M. Roerdink and W. H. Hesselink. A general algorithm for computing distance transforms in linear time. Mathematical Morphology and its Applications to Image and Signal Processing, pp. 331-340. Kluwer, 2000. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dSquaredEuclideanDT(image_data, out_image, dimx, dimy, dimz, None) + py_printErrorMessage(err_code) + return out_image + +# Morphometric Analysis +def py_p3dMorphometricAnalysis(image_data, dimx, dimy, dimz, resolution = 1.0): + """ + Performs a series of direct 3D analysis suitable for trabecular-like porous media. + + Syntax: + ------ + Result = py_p3dMorphometricAnalysis ( image_data, dimx, dimy [, dimz = value] [,resolution = 1.0]) + + Return Value: + ------------ + Returns a struct of parameters computed from input binary image. The name of the fields of the struct are the ones according to "Bone ASBMR" [1] as follows: + + BVTV [-]: Bone Volume / Total Volume (BV/TV). The ratio of object voxels and the total number of voxels in the considered Volume of Interest (VOI). If no irregular VOI is defined, i.e. no mask parameter is applied, the output is identical to the parameter Density of the command p3dBasicAnalysis. + + TBTH [mm]: Trabecular thickness (Tb.Th). A measure of thickness of the solid phase objects obtained with a variation of the directed secant method exposed in [2], assuming the parallel plate model (see [3]). A similar but model-independent parameter can be extracted performing skeleton analysis. + + TBSP [mm]: Trabecular separation (Tb.Sp). A measure of separation of the solid phase objects (i.e. a measure of "thickness" of the void phase), obtained with a variation of the directed secant method exposed in [2], assuming the parallel plate model (see [3]). A similar but model-independent parameter can be extracted performing skeleton analysis. + + TBN [mm-1]: Trabecular number (Tb.N). A measure related to the number of traversals across a solid structure, tipically interpreted as a measure of architectural complexity. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + resolution: A decimal value representing the resolution of input image. If this value is not specified a voxelsize of 1.0 is assumed that means output values are expressed in voxel unit. + + References: + ---------- + + [1] A.M. Parfitt et al., Bone histomorphometry: Standardization of nomenclature, symbols and units, Journal of Bone and Mineral Research, Vol. 2, pp. 595-610, 1987. + + [2] C.A. Simmons and J.A. Hipp, Method-based differences in the automated analysis of the three-dimensional morphology of trabecular bone, Journal of Bone and Mineral Research, Vol. 12, No. 6, pp. 942-947, 1997 + + [3] A.P. Accardo et al., Medical imaging analysis of the three dimensional (3D) architecture of trabecular bone: techniques and their applications. Medical imaging system technology: analysis and computational methods, C.T. Leondes, World Scientific, 2005. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_MorphometricStat = MorphometricStats() + #mask_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dMorphometricAnalysis(image_data, None, out_MorphometricStat, dimx,dimy,dimz, resolution, None) + py_printErrorMessage(err_code) + return out_MorphometricStat + +# Texture Analysis +def py_p3dTextureAnalysis(image_data, dimx, dimy, dimz = 0): + """ + Computes a series of direct 3D textural measures. + + Syntax: + ------ + Result = py_p3dTextureAnalysis ( image_data, dimx, dimy [, dimz = value]) + + Return Value: + ------------ + Returns a struct of parameters computed from input binary image. The name of the fields of the struct is: + + FB [-]: Fractal dimension. A textural measure based on the fractal theory [1]. + + References: + ---------- + + [1] B. Mandelbrot The fractal geometry of nature. W.H. Freeman and Company, 1982. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_TextureStat = TextureStats() + err_code = p3dTextureAnalysis(image_data, out_TextureStat, dimx,dimy,dimz, None) + py_printErrorMessage(err_code) + return out_TextureStat + +# MinVolumeFilter +def py_p3dMinVolumeFilter3D(image_data, dimx, dimy, dimz = 0, min_vol = 5, conn = 6): + """ + Removes from a binary image all the connected components (blob) that have fewer than the specified number of voxels (or pixels). + + The algorithm starts performing a connected components labeling (see p3dBlobLabeling) with contextually computation of the volume of each component. Connected components having volume lower than the specified threshold are removed from the image. + + Syntax: + ------ + Result = py_p3dMinVolumeFilter3D ( image_data, dimx, dimy [, dimz = value] [, resolution = value]) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + min_vol: All connected components having volume (i.e. number of voxels) below this value will be removed (default = 5). + + conn: Specify the desired connectivity: 6 (default), 18 or 26. + + Remarks: + --------- + + Input binary image is assumed to have value 255 for object voxels (the blobs to characterize) and 0 for background. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + if conn == 6 : + conn = CONN6; + if conn == 18 : + conn = CONN18; + if conn == 26 : + conn = CONN26; + err_code = p3dMinVolumeFilter3D(image_data, out_image, dimx,dimy,dimz, min_vol, conn, None) + py_printErrorMessage(err_code) + return out_image + + +# Blob Analysis +def py_p3dBlobAnalysis(image_data, dimx, dimy, dimz = 0, blob_im = None, star_im = None, resolution = 1.0, conn = 6, blob_analysis_file = "blob_analysis.txt"): + """ + Performs a series of direct 3D analysis suitable for porous media having isolated pores. If the pore space is formed by an isolated set of “blobs†(connected components), a series of descriptors for size and shape of each “blob†can be computed. The analysis is based on the concept of connected com- ponents and their labeling (see py_p3dBlobLabeling_8). + + Syntax: + ------ + Result = py_p3dBlobAnalysis ( image_data, dimx, dimy [, dimz = value] [, blob_im = bytearray] [, star_im = bytearray] [, resolution = value] [, conn = value,] [blob_analysis_file = value]) + + Return Value: + ------------ + Returns a struct of parameters computed from input binary image. The fields are: + COUNT [-]: The number of identified blobs. + + VOLUME [mm3]: An array of length COUNT with the volume of each identified blob computed as the number of voxels rescaled according to the specified voxel size. + + MAX_SPHERE [mm]: An array of length COUNT with the diameter of the maximum inscribed sphere of each identified blob. It is computed as two times the maximum value of the Euclidean distance transform within the blob. + + EQ_SPHERE [mm]: An array of length COUNT with the diameter of the equivalent sphere, i.e. the diameter of a sphere with the same volume as the blob. It is computed exploiting the inverse formula of the volume of a sphere. + + MIN_AXIS [mm]: An array of length COUNT with the minor axis length, i.e. the length of the shortest segment among all the segments fully included into the blob and passing through its center of mass. The so-called “star†of segments from which selecting the shortest is generated using random orientations. The "star" image can be optionally returned as output in order to determine if more random segments have to be computed. + + MAX_AXIS [mm]: An array of length COUNT with the major axis length, i.e. the length of the longest segment among all the segments fully included into the blob and passing through its center of mass. + + SPHERICITY [-]: An array of length COUNT with the ratio of MAX_SPHERE and EQ_SPHERE for each blob. + + ASPECT_RATIO [-]: An array of length COUNT with the ratio of MIN_AXIS and MAX_AXIS for each blob. + + EXTENT [-]: An array of length COUNT with the ratio between the volume of the blob and the volume of the minimum bounding box, i.e. the smallest parallelepiped oriented according to image axis containing the blob. + + Arguments: + --------- + + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + blob_im: A 3D matrix of type BYTE with the same dimensions of input image with the maximal ball on each identified blob can be returned as output. The diameter of these balls are used for the assessment of Max_Sphere distribution. + + star_im: A 3D matrix of type BYTE with the same dimensions of input image with the minor and major axis for each blob can be returned as output. This image is labeled with gray level = 1 for the center of mass (center of the "star"), gray level = 2 for the minor axis and gray level = 3 for the major axis. + + resolution: A decimal value representing the voxel size of input image. If this value is not specified a voxelsize of 1.0 is assumed that means output values are expressed in voxel unit. + + conn: Specify the desired connectivity: 6 (default), 18 or 26. + + blob_analysis_file: tab-delimeted file where the results of the blob statiscs are saved. If no name is specified, the file will be saved under the name "blob_analysis.txt" in the default folder location. + + Remarks: + --------- + + Input binary image is assumed to have value 255 for object voxels (the blobs to characterize) and 0 for background. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_BlobStat = BlobStats() + max_rot = 1024 + skip_borders = 0 + + if conn == 6 : + conn = CONN6; + if conn == 18 : + conn = CONN18; + if conn == 26 : + conn = CONN26; + + if skip_borders == 0 : + borders = P3D_FALSE; + else : + borders = P3D_TRUE; + err_code = p3dBlobAnalysis(image_data, out_BlobStat, blob_im, star_im, dimx,dimy,dimz,resolution,conn,max_rot,borders, None) + py_printErrorMessage(err_code) + PrintBlobStruct(out_BlobStat, blob_analysis_file) + return out_BlobStat + + + diff --git a/pypore3d/pypore3d/p3dBlob_wrap.c b/pypore3d/pypore3d/p3dBlob_wrap.c new file mode 100644 index 0000000000000000000000000000000000000000..33a6accba2fddbee6816d6868da951318fb013ab --- /dev/null +++ b/pypore3d/pypore3d/p3dBlob_wrap.c @@ -0,0 +1,11771 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifndef SWIGPYTHON +#define SWIGPYTHON +#endif + +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + + +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include <math.h> +#endif + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include <Python.h> +# define _DEBUG 1 +#else +# include <Python.h> +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast(r) (r) +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *newstr = 0; + str = PyUnicode_AsUTF8String(str); + if (str) { + char *cstr; + Py_ssize_t len; + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + } + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#define Py_hash_t long +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + PyErr_Clear(); + Py_XINCREF(type); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); +#else + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# define SWIG_PYTHON_USE_GIL +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" +#endif + +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +} + +/* Unpack the argument tuple */ + +SWIGINTERN Py_ssize_t +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + Py_ssize_t i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + Py_ssize_t i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); + data->delargs = !(flags & (METH_O)); + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_repr(SwigPyObject *v) +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); + if (v->next) { + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ +SWIGRUNTIME PyObject * +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); + + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(type, value, traceback); + + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } + } + return obj; + } +} + +static PyMethodDef +swigobject_methods[] = { + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, + {0, 0, 0, 0} +}; + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#else + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +static PyObject *Swig_This_global = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + swig_cast_info *tc; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + return SWIG_OK; + } +} + +/* Convert a packed pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } + } + Py_DECREF(empty_args); + } +#else + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } +#endif + } + return inst; +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, "__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Python_DestroyModule(PyObject *obj) +{ + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + Swig_This_global = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCapsule_New((void*) descriptor, NULL, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + const char *errmesg = tmp ? tmp : "Invalid error message"; + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, errmesg); + } else { + PyErr_Format(type, "%s %s", errmesg, mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef SWIGPYTHON_BUILTIN +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; + +# ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +# else + if (!PyString_Check(name)) +# endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} +#endif + + +#ifdef __cplusplus +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + +#ifdef __cplusplus +} +#endif + + + #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_AnisotropyStats swig_types[0] +#define SWIGTYPE_p_BasicStats swig_types[1] +#define SWIGTYPE_p_BlobStats swig_types[2] +#define SWIGTYPE_p_MorphometricStats swig_types[3] +#define SWIGTYPE_p_TextureStats swig_types[4] +#define SWIGTYPE_p_bb_lelem_t swig_types[5] +#define SWIGTYPE_p_bb_t swig_types[6] +#define SWIGTYPE_p_char swig_types[7] +#define SWIGTYPE_p_coords_lelem_t swig_types[8] +#define SWIGTYPE_p_coords_qelem_t swig_types[9] +#define SWIGTYPE_p_coords_queue_t swig_types[10] +#define SWIGTYPE_p_coords_t swig_types[11] +#define SWIGTYPE_p_double swig_types[12] +#define SWIGTYPE_p_double_lelem_t swig_types[13] +#define SWIGTYPE_p_f_p_q_const__char_v_______int swig_types[14] +#define SWIGTYPE_p_fcoords_lelem_t swig_types[15] +#define SWIGTYPE_p_fcoords_t swig_types[16] +#define SWIGTYPE_p_float swig_types[17] +#define SWIGTYPE_p_p_bb_lelem_t swig_types[18] +#define SWIGTYPE_p_p_bb_t swig_types[19] +#define SWIGTYPE_p_p_coords_lelem_t swig_types[20] +#define SWIGTYPE_p_p_double swig_types[21] +#define SWIGTYPE_p_p_double_lelem_t swig_types[22] +#define SWIGTYPE_p_p_fcoords_lelem_t swig_types[23] +#define SWIGTYPE_p_p_uint_lelem_t swig_types[24] +#define SWIGTYPE_p_p_unsigned_int swig_types[25] +#define SWIGTYPE_p_uint_lelem_t swig_types[26] +#define SWIGTYPE_p_unsigned_char swig_types[27] +#define SWIGTYPE_p_unsigned_int swig_types[28] +#define SWIGTYPE_p_unsigned_short swig_types[29] +static swig_type_info *swig_types[31]; +static swig_module_info swig_module = {swig_types, 30, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery +#endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery + +/*----------------------------------------------- + @(target):= _p3dBlob.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__p3dBlob + +#else +# define SWIG_init init_p3dBlob + +#endif +#define SWIG_name "_p3dBlob" + +#define SWIGVERSION 0x040001 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + + #define SWIG_FILE_WITH_INIT + +#include <omp.h> + +#include "P3D_Blob/p3dBlob.h" +#include "P3D_Blob/p3dTime.h" +#include "P3D_Blob/Common/p3dBoundingBoxList.h" +#include "P3D_Blob/Common/p3dBoundingBoxT.h" +#include "P3D_Blob/Common/p3dConnectedComponentsLabeling.h" +#include "P3D_Blob/Common/p3dCoordsList.h" +#include "P3D_Blob/Common/p3dCoordsQueue.h" +#include "P3D_Blob/Common/p3dCoordsT.h" +#include "P3D_Blob/Common/p3dDoubleList.h" +#include "P3D_Blob/Common/p3dFCoordsList.h" +//#include "P3D_Blob/Common/p3dSquaredEuclideanDT.h" +#include "P3D_Blob/Common/p3dUIntList.h" +#include "P3D_Blob/Common/p3dUtils.h" + +#include <assert.h> +int myErr = 0; // flag to save error state + + + +#include <stdlib.h> + + +typedef struct SWIGCDATA { + char *data; + size_t len; +} SWIGCDATA; + + + + + + +static SWIGCDATA cdata_void(void *ptr, size_t nelements) + + + +{ + SWIGCDATA d; + d.data = (char *) ptr; + + + + d.len = nelements; + + return d; +} + + + + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 + } else if (PyInt_Check(obj)) { + if (val) *val = (double) PyInt_AsLong(obj); + return SWIG_OK; +#endif + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else +#endif + if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +#include <limits.h> +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} +#endif + + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + int res = SWIG_TypeError; +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + } +#endif + return res; +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +#if PY_VERSION_HEX >= 0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); +#else + return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); +#endif +#else + return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); +#endif + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else + if (PyUnicode_Check(obj)) +#endif +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; +#if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; +#endif + PyBytes_AsStringAndSize(obj, &cstr, &len); +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else + *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; +#endif + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + Py_XDECREF(obj); +#endif + return ret; + } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + +unsigned char *realloc_uchar(unsigned char *ptr, size_t nitems) + + + +{ + +return (unsigned char *) realloc(ptr, nitems*sizeof(unsigned char)); + + + +} + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long_SS_long (unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)(value)); +} +#endif + + +SWIGINTERNINLINE PyObject * +SWIG_From_size_t (size_t value) +{ +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + return SWIG_From_unsigned_SS_long ((unsigned long)(value)); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else { + /* assume sizeof(size_t) <= sizeof(unsigned long long) */ + return SWIG_From_unsigned_SS_long_SS_long ((unsigned long long)(value)); + } +#endif +} + + + +unsigned short *realloc_ushort(unsigned short *ptr, size_t nitems) + + + +{ + +return (unsigned short *) realloc(ptr, nitems*sizeof(unsigned short)); + + + +} + + + +double *realloc_doub(double *ptr, size_t nitems) + + + +{ + +return (double *) realloc(ptr, nitems*sizeof(double)); + + + +} + + + +BasicStats *realloc_BasicStat(BasicStats *ptr, size_t nitems) + + + +{ + +return (BasicStats *) realloc(ptr, nitems*sizeof(BasicStats)); + + + +} + + + +AnisotropyStats *realloc_AnisotropyStat(AnisotropyStats *ptr, size_t nitems) + + + +{ + +return (AnisotropyStats *) realloc(ptr, nitems*sizeof(AnisotropyStats)); + + + +} + + + +MorphometricStats *realloc_MorphometricStat(MorphometricStats *ptr, size_t nitems) + + + +{ + +return (MorphometricStats *) realloc(ptr, nitems*sizeof(MorphometricStats)); + + + +} + + + +TextureStats *realloc_TextureStat(TextureStats *ptr, size_t nitems) + + + +{ + +return (TextureStats *) realloc(ptr, nitems*sizeof(TextureStats)); + + + +} + + + +BlobStats *realloc_BlobStat(BlobStats *ptr, size_t nitems) + + + +{ + +return (BlobStats *) realloc(ptr, nitems*sizeof(BlobStats)); + + + +} + + + +//#include "P3D_Blob/p3dBlob.h" +#include <float.h> + +void PrintBlobStruct(BlobStats* out_stats, char* filename) +{ + // creating file pointer to work with files + FILE *fptr; + + // opening file in writing mode + fptr = fopen(filename, "w"); + + // exiting program + if (fptr == NULL) { + printf("Error!"); + exit(1); + } + + int Digs = FLT_DECIMAL_DIG; + + //fprintf(fptr, "Count:%d\n", out_stats->blobCount); + fprintf(fptr, "VOLUME,MAX_SPHERE,EQ_SPHERE,MIN_AXIS,MAX_AXIS,SPHERICITY,ASPECT_RATIO,Extent\n"); + for (int i = 0; i<out_stats->blobCount; i++) + { + + // adjust sphericity and aspect ration + //float sphericity = 0.0; + //if (out_stats->eq_sph[i]>=0.00000001) + // sphericity = out_stats->max_sph[i]/out_stats->eq_sph[i]; + //out_stats->sphericity[i] = sphericity; + + //float aspect_ratio = 0.0; + //if (out_stats->l_max[i]>=0.00000001) + // aspect_ratio = out_stats->l_min[i]/out_stats->l_max[i]; + //out_stats->aspect_ratio[i] = aspect_ratio ; + + //print to file + fprintf(fptr, "%.*e,", Digs, out_stats->volume[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->max_sph[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->eq_sph[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->l_min[i]); + fprintf(fptr, "%.*e,", Digs,out_stats->l_max[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->sphericity[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->aspect_ratio[i]); + fprintf(fptr, "%.*e\n", Digs, out_stats->extent[i]); + + + } + + + fclose(fptr); +} + + +void invert_vol(unsigned char* in_im, int dimx, int dimy, int dimz) +{ + for (int k = 0; k < dimz; k++) + for (int j = 0; j < dimy; j++) + for (int i = 0; i < dimx; i++) + { + + int ind = (i*dimz*dimy) + (j*dimz) + k; + in_im[ind] = 255 -in_im[ind]; + /* if (in_im[ind] >0) + in_im[ind] = 0; + else + in_im[ind] = 255 ; + */ + } +} + + +void invert_vol_16(unsigned short* in_im, int dimx, int dimy, int dimz) +{ + for (int k = 0; k < dimz; k++) + for (int j = 0; j < dimy; j++) + for (int i = 0; i < dimx; i++) + { + int ind = (i*dimz*dimy) + (j*dimz) + k; + in_im[ind] = (unsigned short) (255 -in_im[ind]); + /* + int ind = (i*dimz*dimy) + (j*dimz) + k; + if (in_im[ind] >0.0) + in_im[ind] = 0.0; + else + in_im[ind] = 1.0 ; + */ + } +} + + + + + + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else +#endif + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_unsigned_SS_int (unsigned int value) +{ + return PyInt_FromSize_t((size_t) value); +} + + + #define SWIG_From_double PyFloat_FromDouble + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_cdata(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + size_t arg2 = (size_t) 1 ; + int res1 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + SWIGCDATA result; + + if (!SWIG_Python_UnpackTuple(args, "cdata", 1, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cdata" "', argument " "1"" of type '" "void *""'"); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cdata" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = cdata_void(arg1,arg2); + resultobj = SWIG_FromCharPtrAndSize((&result)->data,(&result)->len); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_memmove(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + size_t arg3 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + size_t size2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "memmove", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "memmove" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, &size2, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "memmove" "', argument " "2"" of type '" "void const *""'"); + } + arg2 = (void *)(buf2); + arg3 = (size_t)(size2); + memmove(arg1,(void const *)arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + unsigned char *result = 0 ; + + arg1 = (size_t) sizeof(unsigned char); + if (!SWIG_Python_UnpackTuple(args, "malloc_uchar", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_uchar" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (unsigned char *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned char *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(unsigned char); + if (!SWIG_Python_UnpackTuple(args, "calloc_uchar", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_uchar" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_uchar" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (unsigned char *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_uchar", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_uchar" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (unsigned char *)realloc_uchar(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short *result = 0 ; + + arg1 = (size_t) sizeof(unsigned short); + if (!SWIG_Python_UnpackTuple(args, "malloc_ushort", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_ushort" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (unsigned short *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned short *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(unsigned short); + if (!SWIG_Python_UnpackTuple(args, "calloc_ushort", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_ushort" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_ushort" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (unsigned short *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned short *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_ushort", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_ushort" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (unsigned short *)realloc_ushort(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_doub(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + arg1 = (size_t) sizeof(double); + if (!SWIG_Python_UnpackTuple(args, "malloc_doub", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_doub" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (double *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_doub(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + double *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(double); + if (!SWIG_Python_UnpackTuple(args, "calloc_doub", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_doub" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_doub" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (double *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_doub(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double *arg1 = (double *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + double *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_doub", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_doub" "', argument " "1"" of type '" "double *""'"); + } + arg1 = (double *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_doub" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (double *)realloc_doub(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_doub(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double *arg1 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_doub" "', argument " "1"" of type '" "double *""'"); + } + arg1 = (double *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_BasicStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + BasicStats *result = 0 ; + + arg1 = (size_t) sizeof(BasicStats); + if (!SWIG_Python_UnpackTuple(args, "malloc_BasicStat", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_BasicStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (BasicStats *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BasicStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_BasicStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BasicStats *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(BasicStats); + if (!SWIG_Python_UnpackTuple(args, "calloc_BasicStat", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_BasicStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_BasicStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (BasicStats *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BasicStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_BasicStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BasicStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_BasicStat", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_BasicStat" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_BasicStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (BasicStats *)realloc_BasicStat(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BasicStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_BasicStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_BasicStat" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_AnisotropyStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + AnisotropyStats *result = 0 ; + + arg1 = (size_t) sizeof(AnisotropyStats); + if (!SWIG_Python_UnpackTuple(args, "malloc_AnisotropyStat", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_AnisotropyStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (AnisotropyStats *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_AnisotropyStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + AnisotropyStats *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(AnisotropyStats); + if (!SWIG_Python_UnpackTuple(args, "calloc_AnisotropyStat", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_AnisotropyStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_AnisotropyStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (AnisotropyStats *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_AnisotropyStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + AnisotropyStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_AnisotropyStat", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_AnisotropyStat" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_AnisotropyStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (AnisotropyStats *)realloc_AnisotropyStat(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_AnisotropyStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_AnisotropyStat" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_MorphometricStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + MorphometricStats *result = 0 ; + + arg1 = (size_t) sizeof(MorphometricStats); + if (!SWIG_Python_UnpackTuple(args, "malloc_MorphometricStat", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_MorphometricStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (MorphometricStats *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MorphometricStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_MorphometricStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + MorphometricStats *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(MorphometricStats); + if (!SWIG_Python_UnpackTuple(args, "calloc_MorphometricStat", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_MorphometricStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_MorphometricStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (MorphometricStats *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MorphometricStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_MorphometricStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + MorphometricStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_MorphometricStat", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_MorphometricStat" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_MorphometricStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (MorphometricStats *)realloc_MorphometricStat(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MorphometricStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_MorphometricStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_MorphometricStat" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_TextureStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + TextureStats *result = 0 ; + + arg1 = (size_t) sizeof(TextureStats); + if (!SWIG_Python_UnpackTuple(args, "malloc_TextureStat", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_TextureStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (TextureStats *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_TextureStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_TextureStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + TextureStats *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(TextureStats); + if (!SWIG_Python_UnpackTuple(args, "calloc_TextureStat", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_TextureStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_TextureStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (TextureStats *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_TextureStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_TextureStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + TextureStats *arg1 = (TextureStats *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + TextureStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_TextureStat", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_TextureStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_TextureStat" "', argument " "1"" of type '" "TextureStats *""'"); + } + arg1 = (TextureStats *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_TextureStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (TextureStats *)realloc_TextureStat(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_TextureStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_TextureStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + TextureStats *arg1 = (TextureStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_TextureStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_TextureStat" "', argument " "1"" of type '" "TextureStats *""'"); + } + arg1 = (TextureStats *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_BlobStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + BlobStats *result = 0 ; + + arg1 = (size_t) sizeof(BlobStats); + if (!SWIG_Python_UnpackTuple(args, "malloc_BlobStat", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_BlobStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (BlobStats *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BlobStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_BlobStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BlobStats *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(BlobStats); + if (!SWIG_Python_UnpackTuple(args, "calloc_BlobStat", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_BlobStat" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_BlobStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (BlobStats *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BlobStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_BlobStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BlobStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_BlobStat", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_BlobStat" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_BlobStat" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (BlobStats *)realloc_BlobStat(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BlobStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_BlobStat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_BlobStat" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PrintBlobStruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "PrintBlobStruct", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PrintBlobStruct" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PrintBlobStruct" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + PrintBlobStruct(arg1,arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_invert_vol(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "invert_vol", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "invert_vol" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "invert_vol" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "invert_vol" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "invert_vol" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + invert_vol(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_invert_vol_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "invert_vol_16", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "invert_vol_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "invert_vol_16" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "invert_vol_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "invert_vol_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + invert_vol_16(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_aspect_ratio_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_aspect_ratio_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_aspect_ratio_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_aspect_ratio_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->aspect_ratio = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_aspect_ratio_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_aspect_ratio_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->aspect_ratio); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_blobCount_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_blobCount_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_blobCount_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BlobStats_blobCount_set" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + if (arg1) (arg1)->blobCount = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_blobCount_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_blobCount_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (unsigned int) ((arg1)->blobCount); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_max_sph_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_max_sph_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_max_sph_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_max_sph_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->max_sph = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_max_sph_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_max_sph_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->max_sph); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_eq_sph_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_eq_sph_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_eq_sph_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_eq_sph_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->eq_sph = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_eq_sph_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_eq_sph_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->eq_sph); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_l_min_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_l_min_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_l_min_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_l_min_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->l_min = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_l_min_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_l_min_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->l_min); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_l_max_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_l_max_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_l_max_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_l_max_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->l_max = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_l_max_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_l_max_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->l_max); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_sphericity_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_sphericity_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_sphericity_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_sphericity_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->sphericity = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_sphericity_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_sphericity_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->sphericity); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_extent_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_extent_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_extent_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_extent_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->extent = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_extent_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_extent_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->extent); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_volume_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BlobStats_volume_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_volume_set" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "BlobStats_volume_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->volume = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BlobStats_volume_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BlobStats_volume_get" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + result = (double *) ((arg1)->volume); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_BlobStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_BlobStats", 0, 0, 0)) SWIG_fail; + result = (BlobStats *)calloc(1, sizeof(BlobStats)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BlobStats, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_BlobStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BlobStats *arg1 = (BlobStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BlobStats, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_BlobStats" "', argument " "1"" of type '" "BlobStats *""'"); + } + arg1 = (BlobStats *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *BlobStats_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_BlobStats, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *BlobStats_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_MorphometricStats_BvTv_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "MorphometricStats_BvTv_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_BvTv_set" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MorphometricStats_BvTv_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->BvTv = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_BvTv_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_BvTv_get" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + result = (double) ((arg1)->BvTv); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_BsBv_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "MorphometricStats_BsBv_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_BsBv_set" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MorphometricStats_BsBv_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->BsBv = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_BsBv_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_BsBv_get" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + result = (double) ((arg1)->BsBv); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_TbN_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "MorphometricStats_TbN_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_TbN_set" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MorphometricStats_TbN_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->TbN = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_TbN_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_TbN_get" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + result = (double) ((arg1)->TbN); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_TbTh_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "MorphometricStats_TbTh_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_TbTh_set" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MorphometricStats_TbTh_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->TbTh = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_TbTh_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_TbTh_get" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + result = (double) ((arg1)->TbTh); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_TbSp_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "MorphometricStats_TbSp_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_TbSp_set" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MorphometricStats_TbSp_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->TbSp = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MorphometricStats_TbSp_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MorphometricStats_TbSp_get" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + result = (double) ((arg1)->TbSp); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_MorphometricStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_MorphometricStats", 0, 0, 0)) SWIG_fail; + result = (MorphometricStats *)calloc(1, sizeof(MorphometricStats)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MorphometricStats, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_MorphometricStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + MorphometricStats *arg1 = (MorphometricStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_MorphometricStats, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MorphometricStats" "', argument " "1"" of type '" "MorphometricStats *""'"); + } + arg1 = (MorphometricStats *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *MorphometricStats_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_MorphometricStats, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *MorphometricStats_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_AnisotropyStats_I_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "AnisotropyStats_I_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnisotropyStats_I_set" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AnisotropyStats_I_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->I = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnisotropyStats_I_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnisotropyStats_I_get" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + result = (double) ((arg1)->I); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnisotropyStats_E_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "AnisotropyStats_E_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnisotropyStats_E_set" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AnisotropyStats_E_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->E = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnisotropyStats_E_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnisotropyStats_E_get" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + result = (double) ((arg1)->E); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_AnisotropyStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_AnisotropyStats", 0, 0, 0)) SWIG_fail; + result = (AnisotropyStats *)calloc(1, sizeof(AnisotropyStats)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_AnisotropyStats, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_AnisotropyStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + AnisotropyStats *arg1 = (AnisotropyStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AnisotropyStats, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_AnisotropyStats" "', argument " "1"" of type '" "AnisotropyStats *""'"); + } + arg1 = (AnisotropyStats *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *AnisotropyStats_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_AnisotropyStats, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *AnisotropyStats_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_BasicStats_Vv_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BasicStats_Vv_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Vv_set" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BasicStats_Vv_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->Vv = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Vv_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Vv_get" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + result = (double) ((arg1)->Vv); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Cv_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BasicStats_Cv_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Cv_set" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BasicStats_Cv_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->Cv = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Cv_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Cv_get" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + result = (double) ((arg1)->Cv); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Mv_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BasicStats_Mv_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Mv_set" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BasicStats_Mv_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->Mv = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Mv_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Mv_get" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + result = (double) ((arg1)->Mv); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Sv_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "BasicStats_Sv_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Sv_set" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BasicStats_Sv_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->Sv = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BasicStats_Sv_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicStats_Sv_get" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + result = (double) ((arg1)->Sv); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_BasicStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_BasicStats", 0, 0, 0)) SWIG_fail; + result = (BasicStats *)calloc(1, sizeof(BasicStats)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BasicStats, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_BasicStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + BasicStats *arg1 = (BasicStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BasicStats, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_BasicStats" "', argument " "1"" of type '" "BasicStats *""'"); + } + arg1 = (BasicStats *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *BasicStats_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_BasicStats, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *BasicStats_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_TextureStats_FD_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + TextureStats *arg1 = (TextureStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "TextureStats_FD_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_TextureStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TextureStats_FD_set" "', argument " "1"" of type '" "TextureStats *""'"); + } + arg1 = (TextureStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TextureStats_FD_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->FD = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TextureStats_FD_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + TextureStats *arg1 = (TextureStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_TextureStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TextureStats_FD_get" "', argument " "1"" of type '" "TextureStats *""'"); + } + arg1 = (TextureStats *)(argp1); + result = (double) ((arg1)->FD); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TextureStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + TextureStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_TextureStats", 0, 0, 0)) SWIG_fail; + result = (TextureStats *)calloc(1, sizeof(TextureStats)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_TextureStats, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_TextureStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + TextureStats *arg1 = (TextureStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_TextureStats, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_TextureStats" "', argument " "1"" of type '" "TextureStats *""'"); + } + arg1 = (TextureStats *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *TextureStats_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_TextureStats, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *TextureStats_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_p3dBlobAnalysis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + BlobStats *arg2 = (BlobStats *) 0 ; + unsigned char *arg3 = (unsigned char *) 0 ; + unsigned char *arg4 = (unsigned char *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + double arg8 ; + int arg9 ; + int arg10 ; + int arg11 ; + int (*arg12)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + int val11 ; + int ecode11 = 0 ; + PyObject *swig_obj[12] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBlobAnalysis", 12, 12, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBlobAnalysis" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BlobStats, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBlobAnalysis" "', argument " "2"" of type '" "BlobStats *""'"); + } + arg2 = (BlobStats *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dBlobAnalysis" "', argument " "3"" of type '" "unsigned char *""'"); + } + arg3 = (unsigned char *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dBlobAnalysis" "', argument " "4"" of type '" "unsigned char *""'"); + } + arg4 = (unsigned char *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBlobAnalysis" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBlobAnalysis" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBlobAnalysis" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBlobAnalysis" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dBlobAnalysis" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dBlobAnalysis" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + ecode11 = SWIG_AsVal_int(swig_obj[10], &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "p3dBlobAnalysis" "', argument " "11"" of type '" "int""'"); + } + arg11 = (int)(val11); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[11], (void**)(&arg12), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBlobAnalysis" "', argument " "12"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dBlobAnalysis(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBasicAnalysis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + BasicStats *arg2 = (BasicStats *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + double arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBasicAnalysis", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBasicAnalysis" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BasicStats, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBasicAnalysis" "', argument " "2"" of type '" "BasicStats *""'"); + } + arg2 = (BasicStats *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBasicAnalysis" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBasicAnalysis" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBasicAnalysis" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBasicAnalysis" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBasicAnalysis" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dBasicAnalysis(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dTextureAnalysis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + TextureStats *arg2 = (TextureStats *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dTextureAnalysis", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dTextureAnalysis" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_TextureStats, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dTextureAnalysis" "', argument " "2"" of type '" "TextureStats *""'"); + } + arg2 = (TextureStats *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dTextureAnalysis" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dTextureAnalysis" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dTextureAnalysis" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dTextureAnalysis" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dTextureAnalysis(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dAnisotropyAnalysis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + AnisotropyStats *arg3 = (AnisotropyStats *) 0 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + int arg8 ; + int (*arg9)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dAnisotropyAnalysis", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dAnisotropyAnalysis" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dAnisotropyAnalysis" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_AnisotropyStats, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dAnisotropyAnalysis" "', argument " "3"" of type '" "AnisotropyStats *""'"); + } + arg3 = (AnisotropyStats *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dAnisotropyAnalysis" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dAnisotropyAnalysis" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dAnisotropyAnalysis" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dAnisotropyAnalysis" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dAnisotropyAnalysis" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dAnisotropyAnalysis" "', argument " "9"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dAnisotropyAnalysis(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dMorphometricAnalysis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + MorphometricStats *arg3 = (MorphometricStats *) 0 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dMorphometricAnalysis", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dMorphometricAnalysis" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dMorphometricAnalysis" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_MorphometricStats, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dMorphometricAnalysis" "', argument " "3"" of type '" "MorphometricStats *""'"); + } + arg3 = (MorphometricStats *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dMorphometricAnalysis" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dMorphometricAnalysis" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dMorphometricAnalysis" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dMorphometricAnalysis" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMorphometricAnalysis" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dMorphometricAnalysis(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dREVEstimation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + double **arg2 = (double **) 0 ; + unsigned int **arg3 = (unsigned int **) 0 ; + unsigned int *arg4 = (unsigned int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int arg9 ; + int arg10 ; + int arg11 ; + int (*arg12)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + int val11 ; + int ecode11 = 0 ; + PyObject *swig_obj[12] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dREVEstimation", 12, 12, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dREVEstimation" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_double, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dREVEstimation" "', argument " "2"" of type '" "double **""'"); + } + arg2 = (double **)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dREVEstimation" "', argument " "3"" of type '" "unsigned int **""'"); + } + arg3 = (unsigned int **)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dREVEstimation" "', argument " "4"" of type '" "unsigned int *""'"); + } + arg4 = (unsigned int *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dREVEstimation" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dREVEstimation" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dREVEstimation" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dREVEstimation" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dREVEstimation" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dREVEstimation" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + ecode11 = SWIG_AsVal_int(swig_obj[10], &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "p3dREVEstimation" "', argument " "11"" of type '" "int""'"); + } + arg11 = (int)(val11); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[11], (void**)(&arg12), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dREVEstimation" "', argument " "12"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dREVEstimation(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dChamferDT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int (*arg9)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dChamferDT", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dChamferDT" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dChamferDT" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dChamferDT" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dChamferDT" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dChamferDT" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dChamferDT" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dChamferDT" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dChamferDT" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dChamferDT" "', argument " "9"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dChamferDT(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBlobLabeling_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int (*arg9)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBlobLabeling_ushort", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBlobLabeling_ushort" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBlobLabeling_ushort" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBlobLabeling_ushort" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBlobLabeling_ushort" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBlobLabeling_ushort" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBlobLabeling_ushort" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBlobLabeling_ushort" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBlobLabeling_ushort" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBlobLabeling_ushort" "', argument " "9"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dBlobLabeling_ushort(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBlobLabeling_uint(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned int *arg2 = (unsigned int *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int (*arg9)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBlobLabeling_uint", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBlobLabeling_uint" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBlobLabeling_uint" "', argument " "2"" of type '" "unsigned int *""'"); + } + arg2 = (unsigned int *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBlobLabeling_uint" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBlobLabeling_uint" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBlobLabeling_uint" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBlobLabeling_uint" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBlobLabeling_uint" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBlobLabeling_uint" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBlobLabeling_uint" "', argument " "9"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dBlobLabeling_uint(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetMaxVolumeBlob3D(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetMaxVolumeBlob3D", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGetMaxVolumeBlob3D" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dGetMaxVolumeBlob3D(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetMinVolumeBlob3D(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetMinVolumeBlob3D", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGetMinVolumeBlob3D" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dGetMinVolumeBlob3D(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dMinVolumeFilter3D(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dMinVolumeFilter3D", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dMinVolumeFilter3D" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dMinVolumeFilter3D" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dMinVolumeFilter3D" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dMinVolumeFilter3D" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dMinVolumeFilter3D" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dMinVolumeFilter3D" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dMinVolumeFilter3D" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMinVolumeFilter3D" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dMinVolumeFilter3D(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSquaredEuclideanDT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned int *arg2 = (unsigned int *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSquaredEuclideanDT", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSquaredEuclideanDT" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSquaredEuclideanDT" "', argument " "2"" of type '" "unsigned int *""'"); + } + arg2 = (unsigned int *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSquaredEuclideanDT" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSquaredEuclideanDT" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSquaredEuclideanDT" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSquaredEuclideanDT" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dSquaredEuclideanDT(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dResetStartTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "p3dResetStartTime", 0, 0, 0)) SWIG_fail; + p3dResetStartTime(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime", 0, 0, 0)) SWIG_fail; + result = (double)p3dGetElapsedTime(); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime_min(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime_min", 0, 0, 0)) SWIG_fail; + result = (int)p3dGetElapsedTime_min(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime_sec(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime_sec", 0, 0, 0)) SWIG_fail; + result = (double)p3dGetElapsedTime_sec(); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct bb_lelem_t *arg1 = (struct bb_lelem_t *) 0 ; + bb_t *arg2 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_lelem_t_elem_set" "', argument " "1"" of type '" "struct bb_lelem_t *""'"); + } + arg1 = (struct bb_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bb_lelem_t_elem_set" "', argument " "2"" of type '" "bb_t *""'"); + } + arg2 = (bb_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct bb_lelem_t *arg1 = (struct bb_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + bb_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_lelem_t_elem_get" "', argument " "1"" of type '" "struct bb_lelem_t *""'"); + } + arg1 = (struct bb_lelem_t *)(argp1); + result = (bb_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_bb_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct bb_lelem_t *arg1 = (struct bb_lelem_t *) 0 ; + struct bb_lelem_t *arg2 = (struct bb_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_lelem_t_next_set" "', argument " "1"" of type '" "struct bb_lelem_t *""'"); + } + arg1 = (struct bb_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_bb_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bb_lelem_t_next_set" "', argument " "2"" of type '" "struct bb_lelem_t *""'"); + } + arg2 = (struct bb_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct bb_lelem_t *arg1 = (struct bb_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct bb_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_lelem_t_next_get" "', argument " "1"" of type '" "struct bb_lelem_t *""'"); + } + arg1 = (struct bb_lelem_t *)(argp1); + result = (struct bb_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_bb_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_bb_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct bb_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_bb_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct bb_lelem_t *)calloc(1, sizeof(struct bb_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_bb_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_bb_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct bb_lelem_t *arg1 = (struct bb_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_bb_lelem_t" "', argument " "1"" of type '" "struct bb_lelem_t *""'"); + } + arg1 = (struct bb_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *bb_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_bb_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *bb_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_bb_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_list_t *arg1 = (bb_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_list_init" "', argument " "1"" of type '" "bb_list_t *""'"); + } + arg1 = (bb_list_t *)(argp1); + bb_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_list_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_list_t *arg1 = (bb_list_t *) 0 ; + bb_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bb_list_add", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_list_add" "', argument " "1"" of type '" "bb_list_t *""'"); + } + arg1 = (bb_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_bb_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bb_list_add" "', argument " "2"" of type '" "bb_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "bb_list_add" "', argument " "2"" of type '" "bb_t""'"); + } else { + arg2 = *((bb_t *)(argp2)); + } + } + result = (int)bb_list_add(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_list_t arg1 = (bb_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_list_isempty" "', argument " "1"" of type '" "bb_list_t""'"); + } + arg1 = (bb_list_t)(argp1); + result = (int)bb_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_list_t *arg1 = (bb_list_t *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + bb_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bb_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_list_toarray" "', argument " "1"" of type '" "bb_list_t *""'"); + } + arg1 = (bb_list_t *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_list_toarray" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + result = (bb_t *)bb_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_bb_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_list_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_list_t *arg1 = (bb_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_bb_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_list_clear" "', argument " "1"" of type '" "bb_list_t *""'"); + } + arg1 = (bb_list_t *)(argp1); + bb_list_clear(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_min_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_x_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_min_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->min_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_x_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->min_x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_max_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_x_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_max_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->max_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_x_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->max_x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_min_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_y_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_min_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->min_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_y_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->min_y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_max_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_y_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_max_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->max_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_y_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->max_y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_min_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_z_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_min_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->min_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_z_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->min_z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_max_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_z_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_max_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->max_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_z_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->max_z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_bb_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_bb_t", 0, 0, 0)) SWIG_fail; + result = (bb_t *)calloc(1, sizeof(bb_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_bb_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_bb_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_bb_t" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *bb_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_bb_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *bb_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_p3dConnectedComponentsLabeling_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + unsigned int *arg3 = (unsigned int *) 0 ; + unsigned int **arg4 = (unsigned int **) 0 ; + bb_t **arg5 = (bb_t **) 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + int arg9 ; + int arg10 ; + int arg11 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + int val11 ; + int ecode11 = 0 ; + PyObject *swig_obj[11] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dConnectedComponentsLabeling_ushort", 11, 11, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "3"" of type '" "unsigned int *""'"); + } + arg3 = (unsigned int *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "4"" of type '" "unsigned int **""'"); + } + arg4 = (unsigned int **)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "5"" of type '" "bb_t **""'"); + } + arg5 = (bb_t **)(argp5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + ecode11 = SWIG_AsVal_int(swig_obj[10], &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "p3dConnectedComponentsLabeling_ushort" "', argument " "11"" of type '" "int""'"); + } + arg11 = (int)(val11); + result = (int)p3dConnectedComponentsLabeling_ushort(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dConnectedComponentsLabeling_uint(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned int *arg2 = (unsigned int *) 0 ; + unsigned int *arg3 = (unsigned int *) 0 ; + unsigned int **arg4 = (unsigned int **) 0 ; + bb_t **arg5 = (bb_t **) 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + int arg9 ; + int arg10 ; + int arg11 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + int val11 ; + int ecode11 = 0 ; + PyObject *swig_obj[11] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dConnectedComponentsLabeling_uint", 11, 11, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "2"" of type '" "unsigned int *""'"); + } + arg2 = (unsigned int *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "3"" of type '" "unsigned int *""'"); + } + arg3 = (unsigned int *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "4"" of type '" "unsigned int **""'"); + } + arg4 = (unsigned int **)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "5"" of type '" "bb_t **""'"); + } + arg5 = (bb_t **)(argp5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + ecode11 = SWIG_AsVal_int(swig_obj[10], &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "p3dConnectedComponentsLabeling_uint" "', argument " "11"" of type '" "int""'"); + } + arg11 = (int)(val11); + result = (int)p3dConnectedComponentsLabeling_uint(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + coords_t *arg2 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_elem_set" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_lelem_t_elem_set" "', argument " "2"" of type '" "coords_t *""'"); + } + arg2 = (coords_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_elem_get" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + result = (coords_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + struct coords_lelem_t *arg2 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_next_set" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_lelem_t_next_set" "', argument " "2"" of type '" "struct coords_lelem_t *""'"); + } + arg2 = (struct coords_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct coords_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_next_get" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + result = (struct coords_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct coords_lelem_t *)calloc(1, sizeof(struct coords_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_lelem_t" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_init" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + coords_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + coords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "coords_list_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_push" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_coords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_list_push" "', argument " "2"" of type '" "coords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_list_push" "', argument " "2"" of type '" "coords_t""'"); + } else { + arg2 = *((coords_t *)(argp2)); + } + } + result = (int)coords_list_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_pop" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + result = coords_list_pop(arg1); + resultobj = SWIG_NewPointerObj((coords_t *)memcpy((coords_t *)calloc(1,sizeof(coords_t)),&result,sizeof(coords_t)), SWIGTYPE_p_coords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t arg1 = (coords_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_isempty" "', argument " "1"" of type '" "coords_list_t""'"); + } + arg1 = (coords_list_t)(argp1); + result = (int)coords_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + coords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "coords_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_toarray" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (coords_t *)coords_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_item_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + coords_t *arg2 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_qelem_t_item_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_item_set" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_qelem_t_item_set" "', argument " "2"" of type '" "coords_t *""'"); + } + arg2 = (coords_t *)(argp2); + if (arg1) (arg1)->item = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_item_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_item_get" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + result = (coords_t *)& ((arg1)->item); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + struct coords_qelem_t *arg2 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_qelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_next_set" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_qelem_t_next_set" "', argument " "2"" of type '" "struct coords_qelem_t *""'"); + } + arg2 = (struct coords_qelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct coords_qelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_next_get" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + result = (struct coords_qelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_qelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_qelem_t", 0, 0, 0)) SWIG_fail; + result = (struct coords_qelem_t *)calloc(1, sizeof(struct coords_qelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_qelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_qelem_t" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_qelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_qelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_qelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_queue_t_tail_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_queue_elem_t *arg2 = (coords_queue_elem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_t_tail_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_tail_set" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_t_tail_set" "', argument " "2"" of type '" "coords_queue_elem_t *""'"); + } + arg2 = (coords_queue_elem_t *)(argp2); + if (arg1) (arg1)->tail = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_t_tail_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_queue_elem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_tail_get" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = (coords_queue_elem_t *) ((arg1)->tail); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_t_head_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_queue_elem_t *arg2 = (coords_queue_elem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_t_head_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_head_set" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_t_head_set" "', argument " "2"" of type '" "coords_queue_elem_t *""'"); + } + arg2 = (coords_queue_elem_t *)(argp2); + if (arg1) (arg1)->head = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_t_head_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_queue_elem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_head_get" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = (coords_queue_elem_t *) ((arg1)->head); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_queue_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_queue_t", 0, 0, 0)) SWIG_fail; + result = (coords_queue_t *)calloc(1, sizeof(coords_queue_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_queue_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_queue_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_queue_t" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_queue_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_queue_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_queue_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_queue_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_init" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + coords_queue_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_push" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_coords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_push" "', argument " "2"" of type '" "coords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_queue_push" "', argument " "2"" of type '" "coords_t""'"); + } else { + arg2 = *((coords_t *)(argp2)); + } + } + coords_queue_push(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_pop" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = coords_queue_pop(arg1); + resultobj = SWIG_NewPointerObj((coords_t *)memcpy((coords_t *)calloc(1,sizeof(coords_t)),&result,sizeof(coords_t)), SWIGTYPE_p_coords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t arg1 ; + void *argp1 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_coords_queue_t, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_isempty" "', argument " "1"" of type '" "coords_queue_t""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_queue_isempty" "', argument " "1"" of type '" "coords_queue_t""'"); + } else { + arg1 = *((coords_queue_t *)(argp1)); + } + } + result = (int)coords_queue_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_x_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_x_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_y_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_y_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_z_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_z_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_t", 0, 0, 0)) SWIG_fail; + result = (coords_t *)calloc(1, sizeof(coords_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_t" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_fcoords_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_x_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_x_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_y_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_y_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_z_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_z_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_fcoords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_fcoords_t", 0, 0, 0)) SWIG_fail; + result = (fcoords_t *)calloc(1, sizeof(fcoords_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_fcoords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_fcoords_t" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *fcoords_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_fcoords_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *fcoords_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_double_lelem_t_ct_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct double_lelem_t *arg1 = (struct double_lelem_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "double_lelem_t_ct_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_lelem_t_ct_set" "', argument " "1"" of type '" "struct double_lelem_t *""'"); + } + arg1 = (struct double_lelem_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "double_lelem_t_ct_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->ct = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_double_lelem_t_ct_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct double_lelem_t *arg1 = (struct double_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_lelem_t_ct_get" "', argument " "1"" of type '" "struct double_lelem_t *""'"); + } + arg1 = (struct double_lelem_t *)(argp1); + result = (double) ((arg1)->ct); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_double_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct double_lelem_t *arg1 = (struct double_lelem_t *) 0 ; + struct double_lelem_t *arg2 = (struct double_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "double_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_lelem_t_next_set" "', argument " "1"" of type '" "struct double_lelem_t *""'"); + } + arg1 = (struct double_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "double_lelem_t_next_set" "', argument " "2"" of type '" "struct double_lelem_t *""'"); + } + arg2 = (struct double_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_double_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct double_lelem_t *arg1 = (struct double_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct double_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_lelem_t_next_get" "', argument " "1"" of type '" "struct double_lelem_t *""'"); + } + arg1 = (struct double_lelem_t *)(argp1); + result = (struct double_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_double_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct double_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_double_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct double_lelem_t *)calloc(1, sizeof(struct double_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_double_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct double_lelem_t *arg1 = (struct double_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_double_lelem_t" "', argument " "1"" of type '" "struct double_lelem_t *""'"); + } + arg1 = (struct double_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *double_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_double_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *double_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_double_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double_list_t *arg1 = (double_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_list_init" "', argument " "1"" of type '" "double_list_t *""'"); + } + arg1 = (double_list_t *)(argp1); + double_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_double_list_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double_list_t *arg1 = (double_list_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "double_list_add", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_list_add" "', argument " "1"" of type '" "double_list_t *""'"); + } + arg1 = (double_list_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "double_list_add" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + double_list_add(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_double_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double_list_t arg1 = (double_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_list_isempty" "', argument " "1"" of type '" "double_list_t""'"); + } + arg1 = (double_list_t)(argp1); + result = (int)double_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_double_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double_list_t *arg1 = (double_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + double *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "double_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_double_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "double_list_toarray" "', argument " "1"" of type '" "double_list_t *""'"); + } + arg1 = (double_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "double_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (double *)double_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + fcoords_t *arg2 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_elem_set" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fcoords_lelem_t_elem_set" "', argument " "2"" of type '" "fcoords_t *""'"); + } + arg2 = (fcoords_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + fcoords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_elem_get" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + result = (fcoords_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + struct fcoords_lelem_t *arg2 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_next_set" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_fcoords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fcoords_lelem_t_next_set" "', argument " "2"" of type '" "struct fcoords_lelem_t *""'"); + } + arg2 = (struct fcoords_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct fcoords_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_next_get" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + result = (struct fcoords_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_fcoords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_fcoords_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct fcoords_lelem_t *)calloc(1, sizeof(struct fcoords_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_fcoords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_fcoords_lelem_t" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *fcoords_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_fcoords_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *fcoords_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_fcoords_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_init" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + fcoords_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + fcoords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_list_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_push" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_fcoords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fcoords_list_push" "', argument " "2"" of type '" "fcoords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fcoords_list_push" "', argument " "2"" of type '" "fcoords_t""'"); + } else { + arg2 = *((fcoords_t *)(argp2)); + } + } + result = (int)fcoords_list_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + fcoords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_pop" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + result = fcoords_list_pop(arg1); + resultobj = SWIG_NewPointerObj((fcoords_t *)memcpy((fcoords_t *)calloc(1,sizeof(fcoords_t)),&result,sizeof(fcoords_t)), SWIGTYPE_p_fcoords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t arg1 = (fcoords_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_isempty" "', argument " "1"" of type '" "fcoords_list_t""'"); + } + arg1 = (fcoords_list_t)(argp1); + result = (int)fcoords_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + fcoords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_toarray" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (fcoords_t *)fcoords_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_ct_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "uint_lelem_t_ct_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_ct_set" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "uint_lelem_t_ct_set" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + if (arg1) (arg1)->ct = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_ct_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_ct_get" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + result = (unsigned int) ((arg1)->ct); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + struct uint_lelem_t *arg2 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "uint_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_next_set" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_uint_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "uint_lelem_t_next_set" "', argument " "2"" of type '" "struct uint_lelem_t *""'"); + } + arg2 = (struct uint_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct uint_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_next_get" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + result = (struct uint_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_uint_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_uint_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct uint_lelem_t *)calloc(1, sizeof(struct uint_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_uint_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_uint_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_uint_lelem_t" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *uint_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_uint_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *uint_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_uint_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_init" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + uint_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "uint_list_add", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_add" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "uint_list_add" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + uint_list_add(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t arg1 = (uint_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_isempty" "', argument " "1"" of type '" "uint_list_t""'"); + } + arg1 = (uint_list_t)(argp1); + result = (int)uint_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned int *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "uint_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_toarray" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "uint_list_toarray" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + result = (unsigned int *)uint_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_int, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_clear" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + uint_list_clear(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_findNeighbor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + coords_t *arg8 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + void *argp8 = 0 ; + int res8 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "findNeighbor", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "findNeighbor" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "findNeighbor" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "findNeighbor" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "findNeighbor" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "findNeighbor" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "findNeighbor" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "findNeighbor" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + res8 = SWIG_ConvertPtr(swig_obj[7], &argp8,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "findNeighbor" "', argument " "8"" of type '" "coords_t *""'"); + } + arg8 = (coords_t *)(argp8); + result = (int)findNeighbor(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_countNeighbors(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "countNeighbors", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "countNeighbors" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "countNeighbors" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "countNeighbors" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "countNeighbors" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "countNeighbors" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "countNeighbors" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "countNeighbors" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (int)countNeighbors(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_isSimplePoint(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "isSimplePoint", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "isSimplePoint" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "isSimplePoint" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "isSimplePoint" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "isSimplePoint" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "isSimplePoint" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "isSimplePoint" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "isSimplePoint" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (int)isSimplePoint(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop3D_uchar2uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop3D_uchar2uchar", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop3D_uchar2uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop3D_uchar2uchar" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop3D_uchar2uchar" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop3D_uchar2uchar" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop3D_uchar2uchar" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCrop3D_uchar2uchar" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dCrop3D_uchar2uchar(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop3D_ushort2ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop3D_ushort2ushort", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop3D_ushort2ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop3D_ushort2ushort" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop3D_ushort2ushort" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop3D_ushort2ushort" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop3D_ushort2ushort" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCrop3D_ushort2ushort" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dCrop3D_ushort2ushort(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop3D_uint2uint(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned int *arg1 = (unsigned int *) 0 ; + unsigned int *arg2 = (unsigned int *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop3D_uint2uint", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop3D_uint2uint" "', argument " "1"" of type '" "unsigned int *""'"); + } + arg1 = (unsigned int *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop3D_uint2uint" "', argument " "2"" of type '" "unsigned int *""'"); + } + arg2 = (unsigned int *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop3D_uint2uint" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop3D_uint2uint" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop3D_uint2uint" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCrop3D_uint2uint" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dCrop3D_uint2uint(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop3D_float2float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + float *arg1 = (float *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop3D_float2float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop3D_float2float" "', argument " "1"" of type '" "float *""'"); + } + arg1 = (float *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop3D_float2float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop3D_float2float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop3D_float2float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop3D_float2float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCrop3D_float2float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dCrop3D_float2float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dZeroPadding3D_uchar2float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dZeroPadding3D_uchar2float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dZeroPadding3D_uchar2float" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dZeroPadding3D_uchar2float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dZeroPadding3D_uchar2float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dZeroPadding3D_uchar2float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dZeroPadding3D_uchar2float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dZeroPadding3D_uchar2float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dZeroPadding3D_uchar2float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dZeroPadding3D_uchar2uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dZeroPadding3D_uchar2uchar", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dZeroPadding3D_uchar2uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dZeroPadding3D_uchar2uchar" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dZeroPadding3D_uchar2uchar" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dZeroPadding3D_uchar2uchar" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dZeroPadding3D_uchar2uchar" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dZeroPadding3D_uchar2uchar" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dZeroPadding3D_uchar2uchar(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReplicatePadding3D_uchar2uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReplicatePadding3D_uchar2uchar", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReplicatePadding3D_uchar2uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReplicatePadding3D_uchar2uchar" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReplicatePadding3D_uchar2uchar" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReplicatePadding3D_uchar2uchar" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReplicatePadding3D_uchar2uchar" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dReplicatePadding3D_uchar2uchar" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dReplicatePadding3D_uchar2uchar(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_interpolation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + float *arg1 = (float *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + double result; + + if (!SWIG_Python_UnpackTuple(args, "interpolation", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "interpolation" "', argument " "1"" of type '" "float *""'"); + } + arg1 = (float *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "interpolation" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "interpolation" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "interpolation" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "interpolation" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "interpolation" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "interpolation" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + result = (double)interpolation(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_isBoundary(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "isBoundary", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "isBoundary" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "isBoundary" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "isBoundary" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "isBoundary" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "isBoundary" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "isBoundary" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "isBoundary" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (int)isBoundary(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_isFullNeighborhood(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "isFullNeighborhood", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "isFullNeighborhood" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "isFullNeighborhood" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "isFullNeighborhood" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "isFullNeighborhood" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "isFullNeighborhood" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "isFullNeighborhood" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "isFullNeighborhood" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (int)isFullNeighborhood(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSpecialPadding3D_uchar2uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSpecialPadding3D_uchar2uchar", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSpecialPadding3D_uchar2uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSpecialPadding3D_uchar2uchar" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSpecialPadding3D_uchar2uchar" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSpecialPadding3D_uchar2uchar" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSpecialPadding3D_uchar2uchar" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dSpecialPadding3D_uchar2uchar" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dSpecialPadding3D_uchar2uchar(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, + { "cdata", _wrap_cdata, METH_VARARGS, NULL}, + { "memmove", _wrap_memmove, METH_VARARGS, NULL}, + { "malloc_uchar", _wrap_malloc_uchar, METH_VARARGS, NULL}, + { "calloc_uchar", _wrap_calloc_uchar, METH_VARARGS, NULL}, + { "realloc_uchar", _wrap_realloc_uchar, METH_VARARGS, NULL}, + { "free_uchar", _wrap_free_uchar, METH_O, NULL}, + { "malloc_ushort", _wrap_malloc_ushort, METH_VARARGS, NULL}, + { "calloc_ushort", _wrap_calloc_ushort, METH_VARARGS, NULL}, + { "realloc_ushort", _wrap_realloc_ushort, METH_VARARGS, NULL}, + { "free_ushort", _wrap_free_ushort, METH_O, NULL}, + { "malloc_doub", _wrap_malloc_doub, METH_VARARGS, NULL}, + { "calloc_doub", _wrap_calloc_doub, METH_VARARGS, NULL}, + { "realloc_doub", _wrap_realloc_doub, METH_VARARGS, NULL}, + { "free_doub", _wrap_free_doub, METH_O, NULL}, + { "malloc_BasicStat", _wrap_malloc_BasicStat, METH_VARARGS, NULL}, + { "calloc_BasicStat", _wrap_calloc_BasicStat, METH_VARARGS, NULL}, + { "realloc_BasicStat", _wrap_realloc_BasicStat, METH_VARARGS, NULL}, + { "free_BasicStat", _wrap_free_BasicStat, METH_O, NULL}, + { "malloc_AnisotropyStat", _wrap_malloc_AnisotropyStat, METH_VARARGS, NULL}, + { "calloc_AnisotropyStat", _wrap_calloc_AnisotropyStat, METH_VARARGS, NULL}, + { "realloc_AnisotropyStat", _wrap_realloc_AnisotropyStat, METH_VARARGS, NULL}, + { "free_AnisotropyStat", _wrap_free_AnisotropyStat, METH_O, NULL}, + { "malloc_MorphometricStat", _wrap_malloc_MorphometricStat, METH_VARARGS, NULL}, + { "calloc_MorphometricStat", _wrap_calloc_MorphometricStat, METH_VARARGS, NULL}, + { "realloc_MorphometricStat", _wrap_realloc_MorphometricStat, METH_VARARGS, NULL}, + { "free_MorphometricStat", _wrap_free_MorphometricStat, METH_O, NULL}, + { "malloc_TextureStat", _wrap_malloc_TextureStat, METH_VARARGS, NULL}, + { "calloc_TextureStat", _wrap_calloc_TextureStat, METH_VARARGS, NULL}, + { "realloc_TextureStat", _wrap_realloc_TextureStat, METH_VARARGS, NULL}, + { "free_TextureStat", _wrap_free_TextureStat, METH_O, NULL}, + { "malloc_BlobStat", _wrap_malloc_BlobStat, METH_VARARGS, NULL}, + { "calloc_BlobStat", _wrap_calloc_BlobStat, METH_VARARGS, NULL}, + { "realloc_BlobStat", _wrap_realloc_BlobStat, METH_VARARGS, NULL}, + { "free_BlobStat", _wrap_free_BlobStat, METH_O, NULL}, + { "PrintBlobStruct", _wrap_PrintBlobStruct, METH_VARARGS, NULL}, + { "invert_vol", _wrap_invert_vol, METH_VARARGS, NULL}, + { "invert_vol_16", _wrap_invert_vol_16, METH_VARARGS, NULL}, + { "BlobStats_aspect_ratio_set", _wrap_BlobStats_aspect_ratio_set, METH_VARARGS, NULL}, + { "BlobStats_aspect_ratio_get", _wrap_BlobStats_aspect_ratio_get, METH_O, NULL}, + { "BlobStats_blobCount_set", _wrap_BlobStats_blobCount_set, METH_VARARGS, NULL}, + { "BlobStats_blobCount_get", _wrap_BlobStats_blobCount_get, METH_O, NULL}, + { "BlobStats_max_sph_set", _wrap_BlobStats_max_sph_set, METH_VARARGS, NULL}, + { "BlobStats_max_sph_get", _wrap_BlobStats_max_sph_get, METH_O, NULL}, + { "BlobStats_eq_sph_set", _wrap_BlobStats_eq_sph_set, METH_VARARGS, NULL}, + { "BlobStats_eq_sph_get", _wrap_BlobStats_eq_sph_get, METH_O, NULL}, + { "BlobStats_l_min_set", _wrap_BlobStats_l_min_set, METH_VARARGS, NULL}, + { "BlobStats_l_min_get", _wrap_BlobStats_l_min_get, METH_O, NULL}, + { "BlobStats_l_max_set", _wrap_BlobStats_l_max_set, METH_VARARGS, NULL}, + { "BlobStats_l_max_get", _wrap_BlobStats_l_max_get, METH_O, NULL}, + { "BlobStats_sphericity_set", _wrap_BlobStats_sphericity_set, METH_VARARGS, NULL}, + { "BlobStats_sphericity_get", _wrap_BlobStats_sphericity_get, METH_O, NULL}, + { "BlobStats_extent_set", _wrap_BlobStats_extent_set, METH_VARARGS, NULL}, + { "BlobStats_extent_get", _wrap_BlobStats_extent_get, METH_O, NULL}, + { "BlobStats_volume_set", _wrap_BlobStats_volume_set, METH_VARARGS, NULL}, + { "BlobStats_volume_get", _wrap_BlobStats_volume_get, METH_O, NULL}, + { "new_BlobStats", _wrap_new_BlobStats, METH_NOARGS, NULL}, + { "delete_BlobStats", _wrap_delete_BlobStats, METH_O, NULL}, + { "BlobStats_swigregister", BlobStats_swigregister, METH_O, NULL}, + { "BlobStats_swiginit", BlobStats_swiginit, METH_VARARGS, NULL}, + { "MorphometricStats_BvTv_set", _wrap_MorphometricStats_BvTv_set, METH_VARARGS, NULL}, + { "MorphometricStats_BvTv_get", _wrap_MorphometricStats_BvTv_get, METH_O, NULL}, + { "MorphometricStats_BsBv_set", _wrap_MorphometricStats_BsBv_set, METH_VARARGS, NULL}, + { "MorphometricStats_BsBv_get", _wrap_MorphometricStats_BsBv_get, METH_O, NULL}, + { "MorphometricStats_TbN_set", _wrap_MorphometricStats_TbN_set, METH_VARARGS, NULL}, + { "MorphometricStats_TbN_get", _wrap_MorphometricStats_TbN_get, METH_O, NULL}, + { "MorphometricStats_TbTh_set", _wrap_MorphometricStats_TbTh_set, METH_VARARGS, NULL}, + { "MorphometricStats_TbTh_get", _wrap_MorphometricStats_TbTh_get, METH_O, NULL}, + { "MorphometricStats_TbSp_set", _wrap_MorphometricStats_TbSp_set, METH_VARARGS, NULL}, + { "MorphometricStats_TbSp_get", _wrap_MorphometricStats_TbSp_get, METH_O, NULL}, + { "new_MorphometricStats", _wrap_new_MorphometricStats, METH_NOARGS, NULL}, + { "delete_MorphometricStats", _wrap_delete_MorphometricStats, METH_O, NULL}, + { "MorphometricStats_swigregister", MorphometricStats_swigregister, METH_O, NULL}, + { "MorphometricStats_swiginit", MorphometricStats_swiginit, METH_VARARGS, NULL}, + { "AnisotropyStats_I_set", _wrap_AnisotropyStats_I_set, METH_VARARGS, NULL}, + { "AnisotropyStats_I_get", _wrap_AnisotropyStats_I_get, METH_O, NULL}, + { "AnisotropyStats_E_set", _wrap_AnisotropyStats_E_set, METH_VARARGS, NULL}, + { "AnisotropyStats_E_get", _wrap_AnisotropyStats_E_get, METH_O, NULL}, + { "new_AnisotropyStats", _wrap_new_AnisotropyStats, METH_NOARGS, NULL}, + { "delete_AnisotropyStats", _wrap_delete_AnisotropyStats, METH_O, NULL}, + { "AnisotropyStats_swigregister", AnisotropyStats_swigregister, METH_O, NULL}, + { "AnisotropyStats_swiginit", AnisotropyStats_swiginit, METH_VARARGS, NULL}, + { "BasicStats_Vv_set", _wrap_BasicStats_Vv_set, METH_VARARGS, NULL}, + { "BasicStats_Vv_get", _wrap_BasicStats_Vv_get, METH_O, NULL}, + { "BasicStats_Cv_set", _wrap_BasicStats_Cv_set, METH_VARARGS, NULL}, + { "BasicStats_Cv_get", _wrap_BasicStats_Cv_get, METH_O, NULL}, + { "BasicStats_Mv_set", _wrap_BasicStats_Mv_set, METH_VARARGS, NULL}, + { "BasicStats_Mv_get", _wrap_BasicStats_Mv_get, METH_O, NULL}, + { "BasicStats_Sv_set", _wrap_BasicStats_Sv_set, METH_VARARGS, NULL}, + { "BasicStats_Sv_get", _wrap_BasicStats_Sv_get, METH_O, NULL}, + { "new_BasicStats", _wrap_new_BasicStats, METH_NOARGS, NULL}, + { "delete_BasicStats", _wrap_delete_BasicStats, METH_O, NULL}, + { "BasicStats_swigregister", BasicStats_swigregister, METH_O, NULL}, + { "BasicStats_swiginit", BasicStats_swiginit, METH_VARARGS, NULL}, + { "TextureStats_FD_set", _wrap_TextureStats_FD_set, METH_VARARGS, NULL}, + { "TextureStats_FD_get", _wrap_TextureStats_FD_get, METH_O, NULL}, + { "new_TextureStats", _wrap_new_TextureStats, METH_NOARGS, NULL}, + { "delete_TextureStats", _wrap_delete_TextureStats, METH_O, NULL}, + { "TextureStats_swigregister", TextureStats_swigregister, METH_O, NULL}, + { "TextureStats_swiginit", TextureStats_swiginit, METH_VARARGS, NULL}, + { "p3dBlobAnalysis", _wrap_p3dBlobAnalysis, METH_VARARGS, NULL}, + { "p3dBasicAnalysis", _wrap_p3dBasicAnalysis, METH_VARARGS, NULL}, + { "p3dTextureAnalysis", _wrap_p3dTextureAnalysis, METH_VARARGS, NULL}, + { "p3dAnisotropyAnalysis", _wrap_p3dAnisotropyAnalysis, METH_VARARGS, NULL}, + { "p3dMorphometricAnalysis", _wrap_p3dMorphometricAnalysis, METH_VARARGS, NULL}, + { "p3dREVEstimation", _wrap_p3dREVEstimation, METH_VARARGS, NULL}, + { "p3dChamferDT", _wrap_p3dChamferDT, METH_VARARGS, NULL}, + { "p3dBlobLabeling_ushort", _wrap_p3dBlobLabeling_ushort, METH_VARARGS, NULL}, + { "p3dBlobLabeling_uint", _wrap_p3dBlobLabeling_uint, METH_VARARGS, NULL}, + { "p3dGetMaxVolumeBlob3D", _wrap_p3dGetMaxVolumeBlob3D, METH_VARARGS, NULL}, + { "p3dGetMinVolumeBlob3D", _wrap_p3dGetMinVolumeBlob3D, METH_VARARGS, NULL}, + { "p3dMinVolumeFilter3D", _wrap_p3dMinVolumeFilter3D, METH_VARARGS, NULL}, + { "p3dSquaredEuclideanDT", _wrap_p3dSquaredEuclideanDT, METH_VARARGS, NULL}, + { "p3dResetStartTime", _wrap_p3dResetStartTime, METH_NOARGS, NULL}, + { "p3dGetElapsedTime", _wrap_p3dGetElapsedTime, METH_NOARGS, NULL}, + { "p3dGetElapsedTime_min", _wrap_p3dGetElapsedTime_min, METH_NOARGS, NULL}, + { "p3dGetElapsedTime_sec", _wrap_p3dGetElapsedTime_sec, METH_NOARGS, NULL}, + { "bb_lelem_t_elem_set", _wrap_bb_lelem_t_elem_set, METH_VARARGS, NULL}, + { "bb_lelem_t_elem_get", _wrap_bb_lelem_t_elem_get, METH_O, NULL}, + { "bb_lelem_t_next_set", _wrap_bb_lelem_t_next_set, METH_VARARGS, NULL}, + { "bb_lelem_t_next_get", _wrap_bb_lelem_t_next_get, METH_O, NULL}, + { "new_bb_lelem_t", _wrap_new_bb_lelem_t, METH_NOARGS, NULL}, + { "delete_bb_lelem_t", _wrap_delete_bb_lelem_t, METH_O, NULL}, + { "bb_lelem_t_swigregister", bb_lelem_t_swigregister, METH_O, NULL}, + { "bb_lelem_t_swiginit", bb_lelem_t_swiginit, METH_VARARGS, NULL}, + { "bb_list_init", _wrap_bb_list_init, METH_O, NULL}, + { "bb_list_add", _wrap_bb_list_add, METH_VARARGS, NULL}, + { "bb_list_isempty", _wrap_bb_list_isempty, METH_O, NULL}, + { "bb_list_toarray", _wrap_bb_list_toarray, METH_VARARGS, NULL}, + { "bb_list_clear", _wrap_bb_list_clear, METH_O, NULL}, + { "bb_t_min_x_set", _wrap_bb_t_min_x_set, METH_VARARGS, NULL}, + { "bb_t_min_x_get", _wrap_bb_t_min_x_get, METH_O, NULL}, + { "bb_t_max_x_set", _wrap_bb_t_max_x_set, METH_VARARGS, NULL}, + { "bb_t_max_x_get", _wrap_bb_t_max_x_get, METH_O, NULL}, + { "bb_t_min_y_set", _wrap_bb_t_min_y_set, METH_VARARGS, NULL}, + { "bb_t_min_y_get", _wrap_bb_t_min_y_get, METH_O, NULL}, + { "bb_t_max_y_set", _wrap_bb_t_max_y_set, METH_VARARGS, NULL}, + { "bb_t_max_y_get", _wrap_bb_t_max_y_get, METH_O, NULL}, + { "bb_t_min_z_set", _wrap_bb_t_min_z_set, METH_VARARGS, NULL}, + { "bb_t_min_z_get", _wrap_bb_t_min_z_get, METH_O, NULL}, + { "bb_t_max_z_set", _wrap_bb_t_max_z_set, METH_VARARGS, NULL}, + { "bb_t_max_z_get", _wrap_bb_t_max_z_get, METH_O, NULL}, + { "new_bb_t", _wrap_new_bb_t, METH_NOARGS, NULL}, + { "delete_bb_t", _wrap_delete_bb_t, METH_O, NULL}, + { "bb_t_swigregister", bb_t_swigregister, METH_O, NULL}, + { "bb_t_swiginit", bb_t_swiginit, METH_VARARGS, NULL}, + { "p3dConnectedComponentsLabeling_ushort", _wrap_p3dConnectedComponentsLabeling_ushort, METH_VARARGS, NULL}, + { "p3dConnectedComponentsLabeling_uint", _wrap_p3dConnectedComponentsLabeling_uint, METH_VARARGS, NULL}, + { "coords_lelem_t_elem_set", _wrap_coords_lelem_t_elem_set, METH_VARARGS, NULL}, + { "coords_lelem_t_elem_get", _wrap_coords_lelem_t_elem_get, METH_O, NULL}, + { "coords_lelem_t_next_set", _wrap_coords_lelem_t_next_set, METH_VARARGS, NULL}, + { "coords_lelem_t_next_get", _wrap_coords_lelem_t_next_get, METH_O, NULL}, + { "new_coords_lelem_t", _wrap_new_coords_lelem_t, METH_NOARGS, NULL}, + { "delete_coords_lelem_t", _wrap_delete_coords_lelem_t, METH_O, NULL}, + { "coords_lelem_t_swigregister", coords_lelem_t_swigregister, METH_O, NULL}, + { "coords_lelem_t_swiginit", coords_lelem_t_swiginit, METH_VARARGS, NULL}, + { "coords_list_init", _wrap_coords_list_init, METH_O, NULL}, + { "coords_list_push", _wrap_coords_list_push, METH_VARARGS, NULL}, + { "coords_list_pop", _wrap_coords_list_pop, METH_O, NULL}, + { "coords_list_isempty", _wrap_coords_list_isempty, METH_O, NULL}, + { "coords_list_toarray", _wrap_coords_list_toarray, METH_VARARGS, NULL}, + { "coords_qelem_t_item_set", _wrap_coords_qelem_t_item_set, METH_VARARGS, NULL}, + { "coords_qelem_t_item_get", _wrap_coords_qelem_t_item_get, METH_O, NULL}, + { "coords_qelem_t_next_set", _wrap_coords_qelem_t_next_set, METH_VARARGS, NULL}, + { "coords_qelem_t_next_get", _wrap_coords_qelem_t_next_get, METH_O, NULL}, + { "new_coords_qelem_t", _wrap_new_coords_qelem_t, METH_NOARGS, NULL}, + { "delete_coords_qelem_t", _wrap_delete_coords_qelem_t, METH_O, NULL}, + { "coords_qelem_t_swigregister", coords_qelem_t_swigregister, METH_O, NULL}, + { "coords_qelem_t_swiginit", coords_qelem_t_swiginit, METH_VARARGS, NULL}, + { "coords_queue_t_tail_set", _wrap_coords_queue_t_tail_set, METH_VARARGS, NULL}, + { "coords_queue_t_tail_get", _wrap_coords_queue_t_tail_get, METH_O, NULL}, + { "coords_queue_t_head_set", _wrap_coords_queue_t_head_set, METH_VARARGS, NULL}, + { "coords_queue_t_head_get", _wrap_coords_queue_t_head_get, METH_O, NULL}, + { "new_coords_queue_t", _wrap_new_coords_queue_t, METH_NOARGS, NULL}, + { "delete_coords_queue_t", _wrap_delete_coords_queue_t, METH_O, NULL}, + { "coords_queue_t_swigregister", coords_queue_t_swigregister, METH_O, NULL}, + { "coords_queue_t_swiginit", coords_queue_t_swiginit, METH_VARARGS, NULL}, + { "coords_queue_init", _wrap_coords_queue_init, METH_O, NULL}, + { "coords_queue_push", _wrap_coords_queue_push, METH_VARARGS, NULL}, + { "coords_queue_pop", _wrap_coords_queue_pop, METH_O, NULL}, + { "coords_queue_isempty", _wrap_coords_queue_isempty, METH_O, NULL}, + { "coords_t_x_set", _wrap_coords_t_x_set, METH_VARARGS, NULL}, + { "coords_t_x_get", _wrap_coords_t_x_get, METH_O, NULL}, + { "coords_t_y_set", _wrap_coords_t_y_set, METH_VARARGS, NULL}, + { "coords_t_y_get", _wrap_coords_t_y_get, METH_O, NULL}, + { "coords_t_z_set", _wrap_coords_t_z_set, METH_VARARGS, NULL}, + { "coords_t_z_get", _wrap_coords_t_z_get, METH_O, NULL}, + { "new_coords_t", _wrap_new_coords_t, METH_NOARGS, NULL}, + { "delete_coords_t", _wrap_delete_coords_t, METH_O, NULL}, + { "coords_t_swigregister", coords_t_swigregister, METH_O, NULL}, + { "coords_t_swiginit", coords_t_swiginit, METH_VARARGS, NULL}, + { "fcoords_t_x_set", _wrap_fcoords_t_x_set, METH_VARARGS, NULL}, + { "fcoords_t_x_get", _wrap_fcoords_t_x_get, METH_O, NULL}, + { "fcoords_t_y_set", _wrap_fcoords_t_y_set, METH_VARARGS, NULL}, + { "fcoords_t_y_get", _wrap_fcoords_t_y_get, METH_O, NULL}, + { "fcoords_t_z_set", _wrap_fcoords_t_z_set, METH_VARARGS, NULL}, + { "fcoords_t_z_get", _wrap_fcoords_t_z_get, METH_O, NULL}, + { "new_fcoords_t", _wrap_new_fcoords_t, METH_NOARGS, NULL}, + { "delete_fcoords_t", _wrap_delete_fcoords_t, METH_O, NULL}, + { "fcoords_t_swigregister", fcoords_t_swigregister, METH_O, NULL}, + { "fcoords_t_swiginit", fcoords_t_swiginit, METH_VARARGS, NULL}, + { "double_lelem_t_ct_set", _wrap_double_lelem_t_ct_set, METH_VARARGS, NULL}, + { "double_lelem_t_ct_get", _wrap_double_lelem_t_ct_get, METH_O, NULL}, + { "double_lelem_t_next_set", _wrap_double_lelem_t_next_set, METH_VARARGS, NULL}, + { "double_lelem_t_next_get", _wrap_double_lelem_t_next_get, METH_O, NULL}, + { "new_double_lelem_t", _wrap_new_double_lelem_t, METH_NOARGS, NULL}, + { "delete_double_lelem_t", _wrap_delete_double_lelem_t, METH_O, NULL}, + { "double_lelem_t_swigregister", double_lelem_t_swigregister, METH_O, NULL}, + { "double_lelem_t_swiginit", double_lelem_t_swiginit, METH_VARARGS, NULL}, + { "double_list_init", _wrap_double_list_init, METH_O, NULL}, + { "double_list_add", _wrap_double_list_add, METH_VARARGS, NULL}, + { "double_list_isempty", _wrap_double_list_isempty, METH_O, NULL}, + { "double_list_toarray", _wrap_double_list_toarray, METH_VARARGS, NULL}, + { "fcoords_lelem_t_elem_set", _wrap_fcoords_lelem_t_elem_set, METH_VARARGS, NULL}, + { "fcoords_lelem_t_elem_get", _wrap_fcoords_lelem_t_elem_get, METH_O, NULL}, + { "fcoords_lelem_t_next_set", _wrap_fcoords_lelem_t_next_set, METH_VARARGS, NULL}, + { "fcoords_lelem_t_next_get", _wrap_fcoords_lelem_t_next_get, METH_O, NULL}, + { "new_fcoords_lelem_t", _wrap_new_fcoords_lelem_t, METH_NOARGS, NULL}, + { "delete_fcoords_lelem_t", _wrap_delete_fcoords_lelem_t, METH_O, NULL}, + { "fcoords_lelem_t_swigregister", fcoords_lelem_t_swigregister, METH_O, NULL}, + { "fcoords_lelem_t_swiginit", fcoords_lelem_t_swiginit, METH_VARARGS, NULL}, + { "fcoords_list_init", _wrap_fcoords_list_init, METH_O, NULL}, + { "fcoords_list_push", _wrap_fcoords_list_push, METH_VARARGS, NULL}, + { "fcoords_list_pop", _wrap_fcoords_list_pop, METH_O, NULL}, + { "fcoords_list_isempty", _wrap_fcoords_list_isempty, METH_O, NULL}, + { "fcoords_list_toarray", _wrap_fcoords_list_toarray, METH_VARARGS, NULL}, + { "uint_lelem_t_ct_set", _wrap_uint_lelem_t_ct_set, METH_VARARGS, NULL}, + { "uint_lelem_t_ct_get", _wrap_uint_lelem_t_ct_get, METH_O, NULL}, + { "uint_lelem_t_next_set", _wrap_uint_lelem_t_next_set, METH_VARARGS, NULL}, + { "uint_lelem_t_next_get", _wrap_uint_lelem_t_next_get, METH_O, NULL}, + { "new_uint_lelem_t", _wrap_new_uint_lelem_t, METH_NOARGS, NULL}, + { "delete_uint_lelem_t", _wrap_delete_uint_lelem_t, METH_O, NULL}, + { "uint_lelem_t_swigregister", uint_lelem_t_swigregister, METH_O, NULL}, + { "uint_lelem_t_swiginit", uint_lelem_t_swiginit, METH_VARARGS, NULL}, + { "uint_list_init", _wrap_uint_list_init, METH_O, NULL}, + { "uint_list_add", _wrap_uint_list_add, METH_VARARGS, NULL}, + { "uint_list_isempty", _wrap_uint_list_isempty, METH_O, NULL}, + { "uint_list_toarray", _wrap_uint_list_toarray, METH_VARARGS, NULL}, + { "uint_list_clear", _wrap_uint_list_clear, METH_O, NULL}, + { "findNeighbor", _wrap_findNeighbor, METH_VARARGS, NULL}, + { "countNeighbors", _wrap_countNeighbors, METH_VARARGS, NULL}, + { "isSimplePoint", _wrap_isSimplePoint, METH_VARARGS, NULL}, + { "p3dCrop3D_uchar2uchar", _wrap_p3dCrop3D_uchar2uchar, METH_VARARGS, NULL}, + { "p3dCrop3D_ushort2ushort", _wrap_p3dCrop3D_ushort2ushort, METH_VARARGS, NULL}, + { "p3dCrop3D_uint2uint", _wrap_p3dCrop3D_uint2uint, METH_VARARGS, NULL}, + { "p3dCrop3D_float2float", _wrap_p3dCrop3D_float2float, METH_VARARGS, NULL}, + { "p3dZeroPadding3D_uchar2float", _wrap_p3dZeroPadding3D_uchar2float, METH_VARARGS, NULL}, + { "p3dZeroPadding3D_uchar2uchar", _wrap_p3dZeroPadding3D_uchar2uchar, METH_VARARGS, NULL}, + { "p3dReplicatePadding3D_uchar2uchar", _wrap_p3dReplicatePadding3D_uchar2uchar, METH_VARARGS, NULL}, + { "interpolation", _wrap_interpolation, METH_VARARGS, NULL}, + { "isBoundary", _wrap_isBoundary, METH_VARARGS, NULL}, + { "isFullNeighborhood", _wrap_isFullNeighborhood, METH_VARARGS, NULL}, + { "p3dSpecialPadding3D_uchar2uchar", _wrap_p3dSpecialPadding3D_uchar2uchar, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + +static PyMethodDef SwigMethods_proxydocs[] = { + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_AnisotropyStats = {"_p_AnisotropyStats", "AnisotropyStats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BasicStats = {"_p_BasicStats", "BasicStats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BlobStats = {"_p_BlobStats", "BlobStats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_MorphometricStats = {"_p_MorphometricStats", "MorphometricStats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_TextureStats = {"_p_TextureStats", "TextureStats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_bb_lelem_t = {"_p_bb_lelem_t", "struct bb_lelem_t *|bb_list_elem_t *|bb_lelem_t *|bb_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_bb_t = {"_p_bb_t", "bb_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_lelem_t = {"_p_coords_lelem_t", "struct coords_lelem_t *|coords_list_elem_t *|coords_lelem_t *|coords_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_qelem_t = {"_p_coords_qelem_t", "struct coords_qelem_t *|coords_qelem_t *|coords_queue_elem_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_queue_t = {"_p_coords_queue_t", "coords_queue_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_t = {"_p_coords_t", "coords_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double_lelem_t = {"_p_double_lelem_t", "struct double_lelem_t *|double_list_elem_t *|double_lelem_t *|double_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__char_v_______int = {"_p_f_p_q_const__char_v_______int", "int (*)(char const *,...)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_fcoords_lelem_t = {"_p_fcoords_lelem_t", "struct fcoords_lelem_t *|fcoords_list_elem_t *|fcoords_lelem_t *|fcoords_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_fcoords_t = {"_p_fcoords_t", "fcoords_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_float = {"_p_float", "float *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_bb_lelem_t = {"_p_p_bb_lelem_t", "struct bb_lelem_t **|bb_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_bb_t = {"_p_p_bb_t", "bb_t **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_coords_lelem_t = {"_p_p_coords_lelem_t", "struct coords_lelem_t **|coords_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_double = {"_p_p_double", "double **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_double_lelem_t = {"_p_p_double_lelem_t", "struct double_lelem_t **|double_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_fcoords_lelem_t = {"_p_p_fcoords_lelem_t", "struct fcoords_lelem_t **|fcoords_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_uint_lelem_t = {"_p_p_uint_lelem_t", "struct uint_lelem_t **|uint_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_unsigned_int = {"_p_p_unsigned_int", "unsigned int **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_uint_lelem_t = {"_p_uint_lelem_t", "struct uint_lelem_t *|uint_list_elem_t *|uint_lelem_t *|uint_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_AnisotropyStats, + &_swigt__p_BasicStats, + &_swigt__p_BlobStats, + &_swigt__p_MorphometricStats, + &_swigt__p_TextureStats, + &_swigt__p_bb_lelem_t, + &_swigt__p_bb_t, + &_swigt__p_char, + &_swigt__p_coords_lelem_t, + &_swigt__p_coords_qelem_t, + &_swigt__p_coords_queue_t, + &_swigt__p_coords_t, + &_swigt__p_double, + &_swigt__p_double_lelem_t, + &_swigt__p_f_p_q_const__char_v_______int, + &_swigt__p_fcoords_lelem_t, + &_swigt__p_fcoords_t, + &_swigt__p_float, + &_swigt__p_p_bb_lelem_t, + &_swigt__p_p_bb_t, + &_swigt__p_p_coords_lelem_t, + &_swigt__p_p_double, + &_swigt__p_p_double_lelem_t, + &_swigt__p_p_fcoords_lelem_t, + &_swigt__p_p_uint_lelem_t, + &_swigt__p_p_unsigned_int, + &_swigt__p_uint_lelem_t, + &_swigt__p_unsigned_char, + &_swigt__p_unsigned_int, + &_swigt__p_unsigned_short, +}; + +static swig_cast_info _swigc__p_AnisotropyStats[] = { {&_swigt__p_AnisotropyStats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BasicStats[] = { {&_swigt__p_BasicStats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BlobStats[] = { {&_swigt__p_BlobStats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_MorphometricStats[] = { {&_swigt__p_MorphometricStats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_TextureStats[] = { {&_swigt__p_TextureStats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_bb_lelem_t[] = { {&_swigt__p_bb_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_bb_t[] = { {&_swigt__p_bb_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_lelem_t[] = { {&_swigt__p_coords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_qelem_t[] = { {&_swigt__p_coords_qelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_queue_t[] = { {&_swigt__p_coords_queue_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_t[] = { {&_swigt__p_coords_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double_lelem_t[] = { {&_swigt__p_double_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__char_v_______int[] = { {&_swigt__p_f_p_q_const__char_v_______int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_fcoords_lelem_t[] = { {&_swigt__p_fcoords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_fcoords_t[] = { {&_swigt__p_fcoords_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_bb_lelem_t[] = { {&_swigt__p_p_bb_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_bb_t[] = { {&_swigt__p_p_bb_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_coords_lelem_t[] = { {&_swigt__p_p_coords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_double[] = { {&_swigt__p_p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_double_lelem_t[] = { {&_swigt__p_p_double_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_fcoords_lelem_t[] = { {&_swigt__p_p_fcoords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_uint_lelem_t[] = { {&_swigt__p_p_uint_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_unsigned_int[] = { {&_swigt__p_p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_uint_lelem_t[] = { {&_swigt__p_uint_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_AnisotropyStats, + _swigc__p_BasicStats, + _swigc__p_BlobStats, + _swigc__p_MorphometricStats, + _swigc__p_TextureStats, + _swigc__p_bb_lelem_t, + _swigc__p_bb_t, + _swigc__p_char, + _swigc__p_coords_lelem_t, + _swigc__p_coords_qelem_t, + _swigc__p_coords_queue_t, + _swigc__p_coords_t, + _swigc__p_double, + _swigc__p_double_lelem_t, + _swigc__p_f_p_q_const__char_v_______int, + _swigc__p_fcoords_lelem_t, + _swigc__p_fcoords_t, + _swigc__p_float, + _swigc__p_p_bb_lelem_t, + _swigc__p_p_bb_t, + _swigc__p_p_coords_lelem_t, + _swigc__p_p_double, + _swigc__p_p_double_lelem_t, + _swigc__p_p_fcoords_lelem_t, + _swigc__p_p_uint_lelem_t, + _swigc__p_p_unsigned_int, + _swigc__p_uint_lelem_t, + _swigc__p_unsigned_char, + _swigc__p_unsigned_int, + _swigc__p_unsigned_short, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned statically to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); + + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString("<Swig global variables>"); +#else + return PyString_FromString("<Swig global variables>"); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; + if (PyType_Ready(&varlink_type) < 0) + return NULL; + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + memcpy(gv->name, name, size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *globals = 0; + if (!globals) { + globals = SWIG_newvarlink(); + } + return globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + memcpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + memcpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + + /* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md, *globals; + +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + SwigPyObject_own, + SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + PyTypeObject *swigpyobject; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + PyObject *self = 0; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + (void)self; + + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); + assert(metatype); +#endif + + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule(SWIG_name, SwigMethods); +#endif + + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + swigpyobject = SwigPyObject_TypeOnce(); + + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + + SWIG_Python_SetConstant(d, "sizeof_uchar",SWIG_From_size_t((size_t)(sizeof(unsigned char)))); + SWIG_Python_SetConstant(d, "sizeof_ushort",SWIG_From_size_t((size_t)(sizeof(unsigned short)))); + SWIG_Python_SetConstant(d, "sizeof_doub",SWIG_From_size_t((size_t)(sizeof(double)))); + SWIG_Python_SetConstant(d, "sizeof_BasicStat",SWIG_From_size_t((size_t)(sizeof(BasicStats)))); + SWIG_Python_SetConstant(d, "sizeof_AnisotropyStat",SWIG_From_size_t((size_t)(sizeof(AnisotropyStats)))); + SWIG_Python_SetConstant(d, "sizeof_MorphometricStat",SWIG_From_size_t((size_t)(sizeof(MorphometricStats)))); + SWIG_Python_SetConstant(d, "sizeof_TextureStat",SWIG_From_size_t((size_t)(sizeof(TextureStats)))); + SWIG_Python_SetConstant(d, "sizeof_BlobStat",SWIG_From_size_t((size_t)(sizeof(BlobStats)))); + SWIG_Python_SetConstant(d, "P3D_FALSE",SWIG_From_int((int)(-1))); + SWIG_Python_SetConstant(d, "P3D_TRUE",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, "P3D_ERROR",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, "P3D_SUCCESS",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, "BACKGROUND",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, "CONN4",SWIG_From_int((int)(611))); + SWIG_Python_SetConstant(d, "CONN8",SWIG_From_int((int)(612))); + SWIG_Python_SetConstant(d, "CONN6",SWIG_From_int((int)(711))); + SWIG_Python_SetConstant(d, "CONN18",SWIG_From_int((int)(712))); + SWIG_Python_SetConstant(d, "CONN26",SWIG_From_int((int)(713))); +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/pypore3d/pypore3d/p3dFilt.i b/pypore3d/pypore3d/p3dFilt.i new file mode 100644 index 0000000000000000000000000000000000000000..e1622bc8df7885f4c8b0bcc6247af89f95462501 --- /dev/null +++ b/pypore3d/pypore3d/p3dFilt.i @@ -0,0 +1,34 @@ +/* File: p3dMedianFilter.i */ +%module p3dFilt + +%include typemaps.i + +%{ + #define SWIG_FILE_WITH_INIT + +#include <omp.h> +/*#include "p3dTime.h"*/ +#include "P3D_Filt/p3dTime.h" +#include "P3D_Filt/p3dFilt.h" +#include "P3D_Filt/Common/p3dCoordsQueue.h" +#include "P3D_Filt/Common/p3dCoordsT.h" +#include "P3D_Filt/Common/p3dRingRemoverCommon.h" + +%} + +%include <cmalloc.i> +%include <cdata.i> + +%allocators(unsigned char, uchar) +%allocators(unsigned short, ushort) + +/*#include "p3dTime.h"*/ +%include "P3D_Filt/p3dTime.h" +%include "P3D_Filt/p3dFilt.h" +%include "P3D_Filt/Common/p3dCoordsQueue.h" +%include "P3D_Filt/Common/p3dCoordsT.h" +%include "P3D_Filt/Common/p3dRingRemoverCommon.h" + + + + diff --git a/pypore3d/pypore3d/p3dFilt.py b/pypore3d/pypore3d/p3dFilt.py new file mode 100644 index 0000000000000000000000000000000000000000..5e9d495a399503df18477b768d9502a07b483314 --- /dev/null +++ b/pypore3d/pypore3d/p3dFilt.py @@ -0,0 +1,370 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 4.0.1 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +from sys import version_info as _swig_python_version_info +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") + +# Import the low-level C/C++ module +if __package__ or "." in __name__: + from . import _p3dFilt +else: + import _p3dFilt + +try: + import builtins as __builtin__ +except ImportError: + import __builtin__ + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) + else: + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr + + +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr + + +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper + + +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + + + +def cdata(ptr, nelements=1): + return _p3dFilt.cdata(ptr, nelements) + +def memmove(data, indata): + return _p3dFilt.memmove(data, indata) + +def malloc_uchar(*args): + return _p3dFilt.malloc_uchar(*args) + +def calloc_uchar(*args): + return _p3dFilt.calloc_uchar(*args) + +def realloc_uchar(ptr, nitems): + return _p3dFilt.realloc_uchar(ptr, nitems) + +def free_uchar(ptr): + return _p3dFilt.free_uchar(ptr) +sizeof_uchar = _p3dFilt.sizeof_uchar + +def malloc_ushort(*args): + return _p3dFilt.malloc_ushort(*args) + +def calloc_ushort(*args): + return _p3dFilt.calloc_ushort(*args) + +def realloc_ushort(ptr, nitems): + return _p3dFilt.realloc_ushort(ptr, nitems) + +def free_ushort(ptr): + return _p3dFilt.free_ushort(ptr) +sizeof_ushort = _p3dFilt.sizeof_ushort + +def p3dResetStartTime(): + return _p3dFilt.p3dResetStartTime() + +def p3dGetElapsedTime(): + return _p3dFilt.p3dGetElapsedTime() + +def p3dGetElapsedTime_min(): + return _p3dFilt.p3dGetElapsedTime_min() + +def p3dGetElapsedTime_sec(): + return _p3dFilt.p3dGetElapsedTime_sec() +P3D_FALSE = _p3dFilt.P3D_FALSE +P3D_TRUE = _p3dFilt.P3D_TRUE +P3D_ERROR = _p3dFilt.P3D_ERROR +P3D_IO_ERROR = _p3dFilt.P3D_IO_ERROR +P3D_SUCCESS = _p3dFilt.P3D_SUCCESS +BACKGROUND = _p3dFilt.BACKGROUND +CONN6 = _p3dFilt.CONN6 +CONN18 = _p3dFilt.CONN18 +CONN26 = _p3dFilt.CONN26 + +def p3dReadRaw8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dReadRaw8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dReadRaw16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress): + return _p3dFilt.p3dReadRaw16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress) + +def p3dWriteRaw8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dWriteRaw8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dWriteRaw16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress): + return _p3dFilt.p3dWriteRaw16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress) + +def p3dWriteRaw32(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress): + return _p3dFilt.p3dWriteRaw32(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress) + +def p3dWriteRaw32f(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dWriteRaw32f(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dCrop2D_8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dCrop2D_8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dCrop2D_16(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dCrop2D_16(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dCrop3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dCrop3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dCrop3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dCrop3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dZeroPadding2D_8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dZeroPadding2D_8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dZeroPadding2D_16(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dZeroPadding2D_16(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dZeroPadding3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dZeroPadding3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dZeroPadding3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dZeroPadding3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dReplicatePadding2D_8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dReplicatePadding2D_8(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dReplicatePadding2D_16(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress): + return _p3dFilt.p3dReplicatePadding2D_16(arg1, arg2, arg3, arg4, arg5, wr_log, wr_progress) + +def p3dReplicatePadding3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dReplicatePadding3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dReplicatePadding3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dReplicatePadding3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def _p3dZeroPadding3D_float(arg1, arg2, arg3, arg4, arg5, arg6): + return _p3dFilt._p3dZeroPadding3D_float(arg1, arg2, arg3, arg4, arg5, arg6) + +def _p3dReplicatePadding3D_float(arg1, arg2, arg3, arg4, arg5, arg6): + return _p3dFilt._p3dReplicatePadding3D_float(arg1, arg2, arg3, arg4, arg5, arg6) + +def _p3dZeroPadding3D_uchar2float(arg1, arg2, arg3, arg4, arg5, arg6): + return _p3dFilt._p3dZeroPadding3D_uchar2float(arg1, arg2, arg3, arg4, arg5, arg6) + +def _p3dReplicatePadding3D_uchar2float(arg1, arg2, arg3, arg4, arg5, arg6): + return _p3dFilt._p3dReplicatePadding3D_uchar2float(arg1, arg2, arg3, arg4, arg5, arg6) + +def _p3dZeroPadding3D_ushort2float(arg1, arg2, arg3, arg4, arg5, arg6): + return _p3dFilt._p3dZeroPadding3D_ushort2float(arg1, arg2, arg3, arg4, arg5, arg6) + +def _p3dReplicatePadding3D_ushort2float(arg1, arg2, arg3, arg4, arg5, arg6): + return _p3dFilt._p3dReplicatePadding3D_ushort2float(arg1, arg2, arg3, arg4, arg5, arg6) + +def p3dAnisotropicDiffusionFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress): + return _p3dFilt.p3dAnisotropicDiffusionFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress) + +def p3dAnisotropicDiffusionFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress): + return _p3dFilt.p3dAnisotropicDiffusionFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress) + +def p3dBilateralFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress): + return _p3dFilt.p3dBilateralFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress) + +def p3dBilateralFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress): + return _p3dFilt.p3dBilateralFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log, wr_progress) + +def p3dGaussianFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress): + return _p3dFilt.p3dGaussianFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress) + +def p3dGaussianFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress): + return _p3dFilt.p3dGaussianFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress) + +def p3dMeanFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dMeanFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dMeanFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dMeanFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dMedianFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dMedianFilter3D_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dMedianFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dMedianFilter3D_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dBoinHaibelRingRemover2D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log): + return _p3dFilt.p3dBoinHaibelRingRemover2D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log) + +def p3dBoinHaibelRingRemover2D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log): + return _p3dFilt.p3dBoinHaibelRingRemover2D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log) + +def p3dSijbersPostnovRingRemover2D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, wr_log, wr_progress): + return _p3dFilt.p3dSijbersPostnovRingRemover2D_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, wr_log, wr_progress) + +def p3dSijbersPostnovRingRemover2D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, wr_log, wr_progress): + return _p3dFilt.p3dSijbersPostnovRingRemover2D_16(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, wr_log, wr_progress) + +def p3dKittlerThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dKittlerThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dKittlerThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dKittlerThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dOtsuThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dOtsuThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dOtsuThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dOtsuThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dPunThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dPunThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dPunThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dPunThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dRidlerThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dRidlerThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dRidlerThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dRidlerThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dKapurThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dKapurThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dKapurThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dKapurThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dJohannsenThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dJohannsenThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dJohannsenThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dJohannsenThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dHuangYagerThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dHuangYagerThresholding_8(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dHuangYagerThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress): + return _p3dFilt.p3dHuangYagerThresholding_16(arg1, arg2, arg3, arg4, arg5, arg6, wr_log, wr_progress) + +def p3dClearBorderFilter3D(arg1, arg2, arg3, arg4, arg5, arg6, wr_log): + return _p3dFilt.p3dClearBorderFilter3D(arg1, arg2, arg3, arg4, arg5, arg6, wr_log) + +def p3dGetRegionByCoords3D(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log): + return _p3dFilt.p3dGetRegionByCoords3D(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, wr_log) + +def p3dCreateBinaryCircle(arg1, arg2, arg3, arg4, arg5, arg6, wr_log): + return _p3dFilt.p3dCreateBinaryCircle(arg1, arg2, arg3, arg4, arg5, arg6, wr_log) + +def p3dCreateBinaryCylinder(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log): + return _p3dFilt.p3dCreateBinaryCylinder(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log) + +def p3dCreateBinarySphere(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, wr_log): + return _p3dFilt.p3dCreateBinarySphere(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, wr_log) + +def p3dFrom16To8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress): + return _p3dFilt.p3dFrom16To8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, wr_log, wr_progress) +class coords_qelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + item = property(_p3dFilt.coords_qelem_t_item_get, _p3dFilt.coords_qelem_t_item_set) + next = property(_p3dFilt.coords_qelem_t_next_get, _p3dFilt.coords_qelem_t_next_set) + + def __init__(self): + _p3dFilt.coords_qelem_t_swiginit(self, _p3dFilt.new_coords_qelem_t()) + __swig_destroy__ = _p3dFilt.delete_coords_qelem_t + +# Register coords_qelem_t in _p3dFilt: +_p3dFilt.coords_qelem_t_swigregister(coords_qelem_t) + +class coords_q_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + tail = property(_p3dFilt.coords_q_t_tail_get, _p3dFilt.coords_q_t_tail_set) + head = property(_p3dFilt.coords_q_t_head_get, _p3dFilt.coords_q_t_head_set) + + def __init__(self): + _p3dFilt.coords_q_t_swiginit(self, _p3dFilt.new_coords_q_t()) + __swig_destroy__ = _p3dFilt.delete_coords_q_t + +# Register coords_q_t in _p3dFilt: +_p3dFilt.coords_q_t_swigregister(coords_q_t) + + +def coords_queue_init(queue): + return _p3dFilt.coords_queue_init(queue) + +def coords_queue_push(queue, elem): + return _p3dFilt.coords_queue_push(queue, elem) + +def coords_queue_pop(queue): + return _p3dFilt.coords_queue_pop(queue) + +def coords_queue_isempty(queue): + return _p3dFilt.coords_queue_isempty(queue) +class coords_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dFilt.coords_t_x_get, _p3dFilt.coords_t_x_set) + y = property(_p3dFilt.coords_t_y_get, _p3dFilt.coords_t_y_set) + z = property(_p3dFilt.coords_t_z_get, _p3dFilt.coords_t_z_set) + + def __init__(self): + _p3dFilt.coords_t_swiginit(self, _p3dFilt.new_coords_t()) + __swig_destroy__ = _p3dFilt.delete_coords_t + +# Register coords_t in _p3dFilt: +_p3dFilt.coords_t_swigregister(coords_t) + +class fcoords_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dFilt.fcoords_t_x_get, _p3dFilt.fcoords_t_x_set) + y = property(_p3dFilt.fcoords_t_y_get, _p3dFilt.fcoords_t_y_set) + z = property(_p3dFilt.fcoords_t_z_get, _p3dFilt.fcoords_t_z_set) + + def __init__(self): + _p3dFilt.fcoords_t_swiginit(self, _p3dFilt.new_fcoords_t()) + __swig_destroy__ = _p3dFilt.delete_fcoords_t + +# Register fcoords_t in _p3dFilt: +_p3dFilt.fcoords_t_swigregister(fcoords_t) + + +def p3dCartesian2polar_8(in_im, out_im, dimx, dimy, centerX, centerY, precision, polarX): + return _p3dFilt.p3dCartesian2polar_8(in_im, out_im, dimx, dimy, centerX, centerY, precision, polarX) + +def p3dCartesian2polar_16(in_im, out_im, dimx, dimy, centerX, centerY, precision, polarX): + return _p3dFilt.p3dCartesian2polar_16(in_im, out_im, dimx, dimy, centerX, centerY, precision, polarX) + +def p3dPolar2cartesian_8(in_im, out_im, polarX, centerX, centerY, original_dimx, original_dimy): + return _p3dFilt.p3dPolar2cartesian_8(in_im, out_im, polarX, centerX, centerY, original_dimx, original_dimy) + +def p3dPolar2cartesian_16(in_im, out_im, polarX, centerX, centerY, original_dimx, original_dimy): + return _p3dFilt.p3dPolar2cartesian_16(in_im, out_im, polarX, centerX, centerY, original_dimx, original_dimy) + + diff --git a/pypore3d/pypore3d/p3dFiltPy.py b/pypore3d/pypore3d/p3dFiltPy.py new file mode 100644 index 0000000000000000000000000000000000000000..98f88d87ef2eab7b270c38861921409de9326f3f --- /dev/null +++ b/pypore3d/pypore3d/p3dFiltPy.py @@ -0,0 +1,567 @@ +import os.path + +import pypore3d.p3d_common_lib +from pypore3d.p3d_common_lib import * + +import pypore3d.p3dFilt +from pypore3d.p3dFilt import * + + +#read +def py_p3dReadRaw8(filename, dimx, dimy , dimz = 0): + """ + + Read a RAW image in 8-bit format from the specified file. + + Syntax: + ------ + Result = py_p3dReadRaw8 ( filename, dimx, dimy [, dimz = value]) + + Return Value: + ------------ + Returns a matrix of type BYTE with the dimensions specified in input representing the image read from disk. + + Arguments: + --------- + filename: A string with the filename with full path included. + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + Remarks: + ------- + Trying to read a RAW image stored in SIGNED format is in principle an error. + Also, using p3dReadRaw8 for a 16-bit RAW image results in a completely wrong output but,again, no error could + be detected. + Attention must be paid when using this function. Pore3D internally deals only with UNSIGNED format. + + """ + + if os.path.isfile(filename) == False: + py_printErrorMessage(-5) + return + + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + image_data = malloc_uchar(dimx*dimy*dimz) + err_code = p3dReadRaw8(filename, image_data,dimx,dimy,dimz, None, None); + py_printErrorMessage(err_code) + return image_data + +#write + +def py_p3dWriteRaw8(image_data, filename, dimx, dimy, dimz = 0): + """ + + Write a RAW image to the specified path using the specified file name (8-bit). + + Syntax: + ------ + Result = py_p3dWriteRaw8 ( image_data, filename, dimx, dimy [, dimz = value]) + + Return Value: + ------------ + No return value. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + filename: A string with the filename with full path included. + dimx,dimy,dimz: three variables representing the dimensions of image to read. + +""" + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + err_code = p3dWriteRaw8(image_data, filename,dimx,dimy,dimz, None, None); + py_printErrorMessage(err_code) + return image_data + +#Gaussian Filter +def py_p3dGaussianFilter8(image_data, dimx, dimy, dimz = 0, width =3 ,sigma = 1.0): + """ + + The gaussian smoothing operator is a 2-D convolution operator that is used to "blur" images and remove detail and noise. In this sense it is similar to the mean filter, but it uses a different kernel that represents the shape of a gaussian ("bell- shaped") hump. + + The effect of gaussian smoothing is to blur an image, in a similar fashion to the mean filter. The degree of smoothing is determined by the standard deviation of the gaussian. The gaussian outputs a "weighted average" of each pixel's neighborhood, with the average weighted more towards the value of the central pixels. This is in contrast to the mean filter's uniformly weighted average. Because of this, a gaussian provides gentler smoothing and preserves edges better than a similarly sized mean filter. + + Syntax: + ------ + Result = py_p3dGaussianFilter8 ( image_data, dimx, dimy [, dimz = value] [, width=value] [, sigma=value] ) + + Return Value: + ------------ + Returns a smoothed image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + width : An odd integer value in the range [3, 51] (default: 3) representing the side of the square (or cubic in case of 3D input) kernel. + + sigma=value : A decimal value greater than 0 (default: 1.0) representing the standard deviation of gaussian kernel. + + Remarks: + ------- + Often a 3x3 square kernel (or a 3x3x3 cubic kernel for 3D images) is used, although larger kernels (e.g. 5x5 squares or 5x5x5 cubes) can be used for more severe smoothing. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + +""" + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if width < 3 or width > 51 or (width % 2) == 0: + py_printErrorMessage(-4) + return + + if sigma < 0 : + py_printErrorMessage(-4) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dGaussianFilter3D_8(image_data,out_image,dimx,dimy,dimz, 3,1.0, None, None) + py_printErrorMessage(err_code) + return out_image + +# Mean Filter +def py_p3dMeanFilter8(image_data, dimx, dimy, dimz = 0, width =3): + """ + + Mean filtering is a simple way to smooth an image, i.e. reducing the amount of intensity variation between one pixel and its neighbors. It is often used to reduce noise in images. + + The idea of mean filtering is simply to replace each pixel value in an image with the average value of its neighbors, including itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings. Mean filtering is usually thought of as a convolution filter. Like other convolutions it is based around a kernel, which represents the size of the neighborhood to be taked into account when calculating the mean. + + Syntax: + ------ + Result = p3dMeanFilter ( image_data, dimx, dimy [, dimz = value] [, width=value] ) + + Return Value: + ------------ + Returns a smoothed image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + width : An odd integer value in the range [3, 51] (default: 3) representing the side of the square (or cubic in case of 3D input) kernel. + + Remarks: + ------- + Often a 3x3 kernel (or a 3x3x3 kernel for 3D images) is used, although larger kernels (e.g. 5x5 squares or 5x5x5 cubes) can be used for more severe smoothing. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if width < 3 or width > 51 or (width % 2) == 0: + py_printErrorMessage(-4) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dMeanFilter3D_8(image_data,out_image, dimx,dimy,dimz, width,None, None) + py_printErrorMessage(err_code) + return out_image + +# Median Filter +def py_p3dMedianFilter8(image_data, dimx, dimy, dimz = 0, width=3): + """ + + The median filter is normally used to reduce noise in an image, somewhat like the mean filter. However, it often does a better job than the mean filter of preserving useful detail in the image. + + Like the mean filter, the median filter considers each pixel in the image in turn and looks at its nearby neighbors to decide whether or not it is representative of its surroundings. Instead of simply replacing the pixel value with the mean of neighboring pixel values, it replaces it with the median of those values. In principle, the median is calculated by first sorting all the pixel values from the surrounding neighborhood into numerical order and then replacing the pixel being considered with the middle pixel value. + + The median filter has two main advantages over the mean filter: 1) the median is a more robust average than the mean and so a single very unrepresentative pixel in a neighborhood will not affect the median value significantly; 2) since the median value must actually be the value of one of the pixels in the neighborhood, the median filter does not create new unrealistic pixel values when the filter straddles an edge. For this reason the median filter is much better at preserving sharp edges than the mean filter. In general, the median filter allows a great deal of high spatial frequency detail to pass while remaining very effective at removing noise on images where less than half of the pixels in a smoothing neighborhood have been effected. As a consequence of this, median filtering can be less effective at removing noise from images corrupted with Gaussian noise. + + Syntax: + ------ + Result = p3dMedianFilter ( image_data, dimx, dimy [, dimz = value] [, width=value ] ) + + Return Value: + ------------ + Returns a smoothed image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx, dimy, dimz: three variables representing the dimensions of image to read. + + width: An odd integer value in the range [3, 51] (default: 3) representing the side of the square (or cubic in case of 3D input) kernel. + + Remarks: + ------- + Trying to read a RAW image stored in SIGNED format is in principle an error. + Also, using p3dReadRaw8 for a 16-bit RAW image results in a completely wrong output but, again, no error could be detected. + Attention #must be paid when using this function. Pore3D internally deals only with UNSIGNED format. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if width < 3 or width > 51 or (width % 2) == 0: + py_printErrorMessage(-4) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dMedianFilter3D_8(image_data,out_image, dimx,dimy,dimz, width,None, None) + py_printErrorMessage(err_code) + return out_image + +# AnisotropicDiffusionFilter +def py_p3dAnisotropicDiffusionFilter8(image_data, dimx, dimy, dimz = 0, m = 1, lambdaP = 0.01, sigma = 0.01, iterP = 10): + """ + + Performs edge preserving smoothing using edge-enhancing anisotropic diffusion [1]. + + Anisotropic diffusion is an edge preserving smoothing filter similar to bilateral filter. When used with very small diffusion parameters and long diffusion time, it is less sensitive to contrast but better preserves finer detailed structures in images. + + Syntax: + ------ + Result = py_p3dAnisotropicDiffusionFilter8 ( image_data, dimx, dimy [, dimz = value] [, m = value ] [, lambdaP = value ] [, sigma=value ] [, iterP=value ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + m: A integer value greater than 0 (default: 1) representing the standard deviation of the domain gaussian + + lambdaP: A decimal value greater than 0 (default: 0.01) representing the in the diffusion equation. Higher values imply faster diffusion with more smoothing of tiny details. + + sigma: A decimal value greater than 0 (default: 0.01) representing the in the diffusion equation. Higher values imply faster diffusion with more smoothing of tiny details. + + iterP: An integer value greater than 0 (default: 10) representing the diffusion time, i.e. the number of times the algorithm is iterated. + + Remarks: + ------- + Intensive memory occupation. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if m < 0: + py_printErrorMessage(-4) + return + + if lambdaP < 0: + py_printErrorMessage(-4) + return + + if sigma < 0: + py_printErrorMessage(-4) + return + + if iterP < 0: + py_printErrorMessage(-4) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dAnisotropicDiffusionFilter3D_8(image_data,out_image, dimx,dimy,dimz,m,lambdaP,sigma,iterP,None, None) + py_printErrorMessage(err_code) + return out_image + +# BilateralFilter +def py_p3dBilateralFilter8(image_data, dimx, dimy, dimz = 0, size = 3, sigma_d = 1.0, sigma_r = 3, iterations = 10): + """ + + Bilateral filtering smooths images while preserving edges, by means of a nonlinear combination of nearby image values.. + + The idea uderlying bilateral filtering is to do in the range of an image what traditional filter do in its domain. Two pixels (or voxels) can be close to one another, that is, occupy nearby spatial location, or they can be similar to one another, that is, have nearby values. Closeness refers to the vicinity in the domain, similarity to vicinity in the range. Traditional filtering is domain filtering and enforces closeness by weighing pixel (or voxel) values with coefficients that fall off with distance. Similarly, range filters average image values with weights that decay with dissimilarity. Range filters are nonlinear because their weights depend on image intensity. The combination of domain and range filtering is denoted as bilateral filtering [1]. + + Syntax: + ------ + Result = py_p3dBilateralFilter8 ( image_data, dimx, dimy [, dimz = value] [, size=value ] [,sigma_d =value ] [, sigma_r=value ] [, iterations=value ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + size: An odd integer value in the range [3, 51] (default: 3) representing the side of the cubic kernel. + + sigma_d: A decimal value greater than 0 (default: 1.0) representing the standard deviation of the domain gaussian. + + sigma_r: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the range gaussian. + + iterations: The number of times the algorithm is iterated (default: 10). + + Remarks: + ------- + Often a 3x3 square kernel (or a 3x3x3 cubic kernel for 3D images) is used, although larger kernels (e.g. 5x5 squares or 5x5x5 cubes) can be used for more severe smoothing. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if size < 3 or size > 51 or (size % 2) == 0: + py_printErrorMessage(-4) + return + + if sigma_d < 0: + py_printErrorMessage(-4) + return + + if sigma_r < 0: + py_printErrorMessage(-4) + return + + if iterations < 0: + py_printErrorMessage(-4) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dBilateralFilter3D_8(image_data,out_image, dimx,dimy,dimz,size,sigma_d,sigma_r,iter,None, None) + py_printErrorMessage(err_code) + return out_image + +# BoinHaibelRingRemover 2D only +def py_p3dBoinHaibelRingRemover8(image_data, dimx, dimy, centerX=0, centerY=0, winsize=0, iterations=0, precision=0): + """ + + Syntax: + ------ + Result = py_p3dBoinHaibelRingRemover8 ( image_data, dimx, dimy [, centerX=value ] [,centerY =value ] [, winsize=value ] [, iterations=value ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + centerX,centerY: + + winsize: + + iterations: + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy) + err_code = p3dBoinHaibelRingRemover2D_8(image_data,out_image, dimx,dimy,centerX,centerY,winsize,iterations, precision,None) + py_printErrorMessage(err_code) + return out_image + +# SijbersPostnovRingRemover 2D only +def py_p3dSijbersPostnovRingRemover8(image_data, dimx, dimy, centerX = 0, centerY = 0, winsize = 5, thresh = 1, iterations = 1, precision = 1.5, mask = None): + """ + + Reduce ring artifacts from reconstructed images using a modified J. Sijbers and A. Postnov algorithm [1]. + + The method is based on the observation that ring artifacts become straight vertical lines trasforming input image in polar coordinates where the center of the ring artifacts is assumed as the center of polar transformation. Within a sliding window a set of homogeneous rows of polar image is detected. Working on this set an artifact template is generated and used for the correction of the image. At the end, the image is transformed back into cartesian coordinates. + + Syntax: + ------ + Result = py_p3dSijbersPostnovRingRemover8 ( image_data, dimx, dimy [, mask= 2D image ] [, centerX=value ] [,centerY =value ] [, winsize=value ] [, thresh=value ][, iterations=1 ][, precision=value ] ) + + Return Value: + ------------ + Returns an image with the same dimensions and type of input image having ring artifacts removed. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + centerX,centerY: Coordinates of the center of ring artifacts. If this keyword is not setted the image center will be assumed as ring artifacts center (optimal condition). + + winsize: An odd integer value in the range [3, 201] (default: 51). representing the size of the sliding window used to scan the image. The purpose of the window is to detect homogeneous row segments. Therefore, the width should be chosen of adequate size in order to detect a sufficiently large number of homogeneous rows. + + tbresh: A decimal value greater than 0 representing the threshold value that classifies row segments as homogeneous or inhomogeneous. + The choice of Thresh depends on the severity of the line artifacts. The less pronounced the line artifacts, the smaller the value of threshold can be chosen, with a lower bound determined by the image noise variance. A good choice for Thresh is around 3 times the image noise variance (see further remarks for the estimation of noise variance). + + iterations: Filter could be applied iteratively the specified number of times (default: 1) greater than 0. It is equivalent to a iterative invocation of the filter but execution time is lower (filter remains in polar coordinates and performs the conversion to cartesian coordinates only at the end of last iteration). + + precision: The discrete polar-cartesian conversion could require a denser grid in order to avoid compromising structures far from ring artifacts center. Increasing the precision parameter (between 1.0 and 5.0) results in a more precise processing but more computational time is required. If no parameter is specified, the fastest filtering is performed (default: 1.5). + + mask :A 2D matrix (coherent with Image argument) of type BYTE having value 255 on pixel or voxel representing the region of interest and 0 elsewhere. Filtering will be applied only within the specified Mask resulting in a faster filter execution with better results in the vicinity of mask boundary. Mask could be omitted for objects having circular simmetry with baricenter that fits neatly the center of ring artifacts. Mask could be omitted also for less pronounced artifacts and for high porous objects. + + + Remarks: + ------- + Trying to read a RAW image stored in SIGNED format is in principle an error. + Also, using p3dReadRaw8 for a 16-bit RAW image results in a completely wrong output but, again, no error could be detected. + Attention #must be paid when using this function. Pore3D internally deals only with UNSIGNED format. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if winsize < 3 or winsize > 201 or (winsize % 2) == 0: + py_printErrorMessage(-4) + return + + if tbresh < 0: + py_printErrorMessage(-4) + return + + if iterations < 0: + py_printErrorMessage(-4) + return + + if precision < 1.0 or precision > 5.0: + py_printErrorMessage(-4) + return + + if centerX == 0: + centerX = dimx/2 + if centerY == 0: + centerY = dimy/2 + out_image = malloc_uchar(dimx*dimy) + err_code = p3dSijbersPostnovRingRemover2D_8(image_data,out_image, dimx,dimy,centerX,centerY,winsize,thresh,iterations, precision, mask, None,None) + py_printErrorMessage(err_code) + return out_image + +# ClearBorderFilter +def py_p3dClearBorderFilter8(image_data, dimx, dimy, dimz = 0, connIn = 6): + """ + + This filter suppresses connected components (blobs) connected to image margins. + + The algorithm starts performing a modified connected components labeling (see py_p3dBlobLabeling) starting from image margins. Each connected components found is "labeled" with background value, i.e. it is removed from image. + + Syntax: + ------ + Result = py_p3dClearBorderFilter8 (image_data, dimx, dimy [, dimz = value][,connIn = value]) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input image. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the binary input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + connIn: The desired connectivity, i.e. 6, 18 or 26 for 3D images. The default connectivity is 6 for three dimensional images. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + conn3D = 711 + if connIn == 6: + conn3D = 711 + elif connIn == 18: + conn3D = 712 + elif connIn == 26: + conn3D = 713 + else: + py_printErrorMessage(-4) + + + + err_code = p3dClearBorderFilter3D(image_data,out_image, dimx,dimy,dimz,conn3D,None) + py_printErrorMessage(err_code) + return out_image + +# AutoThresholding +def py_p3dAutoThresholding8(image_data, dimx, dimy, dimz = 0, methodNum = 1, thresh_val = 7): + """ + + Performs segmentation by thresholding using an automatically determined threshold according to one of the following methods: + + 1. Kittler and Illingworth: The method consists in arbitrarily dividing the histogram into two parts (the foreground and the background), modeling each part with a normal distribution, comparing the resulting model based on a mixture of these normal distribution with the original histogram and assuming as optimal the threshold that minimizes a criterion function based on the classification error probability [1]. + + 2. Otsu: The intra-class variance is computed, i.e., the weighted sum of the variances of each class (the background and the foreground) adopting the number of voxels in the class as a weight. Among all the possible thresholds, the optimal is the one that minimizes this intra-class variance [2]. + + 3.Pun: This method is based on entropic thresholding: an entropy-thresholded image is the one that preserves (as much as possible) the information contained in the original unthresholded image in terms of entropy [3]. + + 4.Ridler and Calvard: A unique threshold is assumed to be the average of the foreground and background class means. The means of the two parts can be evaluated only after the threshold is determined, but the threshold needs to be computed from the two means. Therefore, an iterative algorithm was suggested: first, an initial threshold is selected (the mean of the entire histogram is a sufficient starting point), then the two means for the two distributions on either side of the threshold are calculated. A new threshold is obtained by averaging these means and the process continues until the value of the threshold converges [4]. + + 5.Kapur et al.Kapur et al. improved the Pun's approach considering the image foreground and background as two different classes of events. It first measures the class entropies, which is interpreted as a measure of class compactness. When the sum of the two class entropies reaches its maximum, the image is said to be optimally thresholded [5]. + + 6.Tsai: The Tsai's method first computes gray-level moments from the input's histogram, and then obtains the threshold according to the principle [6]. + + Syntax: + ------ + Result = py_p3dAutoThresholding8 ( image_data, dimx, dimy [, dimz = value] [, methodNum = value] [, thresh_val = variable]) + + Return Value: + ------------ + Returns a volume with the same dimensions of input volume having value 255 on skeleton voxels and 0 elsewhere. + + Arguments: + --------- + image_data: A string with the filename with full path included. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + methodNum: The method (default: 1) for the automatic determination of the threshold. + + thresh_val: An output parameter that will contain the automatically computed threshold. This parameter will be in the range + [0, 255] for a byte image. + + References + --------- + [1] Kittler J, Illingworth J. Minimum error thresholding. Pattern Recogn. 1986;19:41-7. + [2] Otsu N. A threshold selection method from gray-level histograms. IEEE Trans Syst Man Cybern. 1979;9:62-6. + [3] Kapur JN, Sahoo PK, Wong AKC. A new method for gray-level picture thresholding using the entropy of the histogram. Graph Models Image Process. 1985;29:273-85. + [4] Tsai WH. Moment-preserving thresholding: a new approach. Graph Models Image Process. 1985;19:377-93. + [5] Ridler TW, Calvard S. Picture thresholding using an iterative selection method. IEEE Trans Syst Man Cybern. 1978;8:630-2. + [6] Pun T. Entropic thresholding: a new approach. Comp Graph Image Process. 1981;16:210-39. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if thresh_val < 6 or thresh_val > 255: + py_printErrorMessage(-4) + return + + thresh_val = 0 + out_image = malloc_uchar(dimx*dimy*dimz) + thresh_val = malloc_uchar(1) + if methodNum == 1: + err_code = p3dKittlerThresholding_8(image_data, out_image,dimx,dimy,dimz, thresh_val, None, None) + elif methodNum == 2: + err_code = p3dOtsuThresholding_8(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 3: + err_code = p3dPunThresholding_8(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 4: + err_code = p3dRidlerThresholding_8(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 5: + err_code = p3dKapurThresholding_8(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 6: + err_code = p3dJohannsenThresholding_8(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 7: + err_code = p3dHuangYagerThresholding_8(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + else: + err_code = p3dOtsuThresholding_8(image_data, out_image,dimx,dimy,dimz, thresh_val, None, None) + + py_printErrorMessage(err_code) + return out_image + + \ No newline at end of file diff --git a/pypore3d/pypore3d/p3dFiltPy_16.py b/pypore3d/pypore3d/p3dFiltPy_16.py new file mode 100644 index 0000000000000000000000000000000000000000..d42b39fad302d34513c61577c80903612808dc30 --- /dev/null +++ b/pypore3d/pypore3d/p3dFiltPy_16.py @@ -0,0 +1,530 @@ + +import os.path + +import pypore3d.p3d_common_lib +from pypore3d.p3d_common_lib import * + +import pypore3d.p3dFilt +from pypore3d.p3dFilt import * + + +#read +def py_p3dReadRaw16(filename, dimx, dimy, dimz = 0, big_endian = 0, is_signed = 0): + """ + + This function reads a RAW image in 16-bit format from the specified file. + + Syntax: + ------ + Result = py_p3dReadRaw16 ( filename, dimx, dimy, dimz [, big_endian = 0] [,is_signed = 0]) + + Return Value: + ------------ + Returns a matrix of type BYTE with the dimensions specified in input representing the image read from disk. + + Arguments: + --------- + filename: A string with the filename with full path included. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + is_unsigned: If a 16-bit image is passed as input (i.e. an UINT matrix) by default p3dReadRaw assumes that images are stored + in SIGNED format (is_unsigned = 0) . By specifying this keyword users can switch to UNSIGNED format. + + big_endian: If a 16-bit image is passed as input (i.e. an UINT matrix) by default p3dReadRaw assumes that images are stored in LITTLE ENDIAN format (big_endian = 0). By specifying this keyword users can switch to BIG ENDIAN format. Keyword is ignored in the case of a 8-bit input image (i.e. a BYTE matrix). + + Remarks: + ------- + Trying to read a RAW image stored in SIGNED format is in principle an error. + Also, using p3dReadRaw8 for a 16-bit RAW image results in a completely wrong output but, again, no error could be detected. + Attention #must be paid when using this function. Pore3D internally deals only with UNSIGNED format. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if os.path.isfile(filename) == False: + py_printErrorMessage(-5) + return + + image_data = malloc_ushort(dimx*dimy*dimz) + err_code = p3dReadRaw16(filename, image_data, dimx, dimy, dimz, 0, 0, None, None); + py_printErrorMessage(err_code) + return image_data + +#write +def py_p3dWriteRaw16(image_data, filename, dimx, dimy, dimz = 0, is_little = 1, is_signed = 0): + """ + + Write a RAW image to the specified path using the specified file name (16-bit). + + Syntax: + ------ + Result = py_p3dWriteRaw16(image_data, filename, dimx,dimy,dimz [, is_little = 1] [,is_signed = 0]) + + Return Value: + ------------ + No return value. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to write to disk. + + filename: A string with the filename with full path included. + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + is_unsigned: If a 16-bit image is passed as input (i.e. an Unsigned matrix) by default p3dWriteRaw assumes that images are stored + in SIGNED format (is_unsigned = 0) . By specifying this keyword users can switch to UNSIGNED format. + + is_little: If a 16-bit image is passed as input (i.e. an Unsigned Short matrix) by default p3dWriteRaw assumes that images are stored in LITTLE ENDIAN format . By specifying this keyword users can switch to BIG ENDIAN format. Keyword is ignored in the case of a 8-bit input image (i.e. a BYTE matrix) + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + #image_data = p3dFilt.malloc_uchar(dimx*dimy*dimz) + err_code = p3dWriteRaw16(image_data, filename,dimx,dimy,dimz, is_little, is_signed, None, None); + py_printErrorMessage(err_code) + return image_data + +def py_p3dAutoThresholding16(image_data, dimx, dimy , dimz = 0, methodNum = 1): + """ + + Performs segmentation by thresholding using an automatically determined threshold according to one of the following methods: + + 1. Kittler and Illingworth: The method consists in arbitrarily dividing the histogram into two parts (the foreground and the background), modeling each part with a normal distribution, comparing the resulting model based on a mixture of these normal distribution with the original histogram and assuming as optimal the threshold that minimizes a criterion function based on the classification error probability [1]. + + 2. Otsu: The intra-class variance is computed, i.e., the weighted sum of the variances of each class (the background and the foreground) adopting the number of voxels in the class as a weight. Among all the possible thresholds, the optimal is the one that minimizes this intra-class variance [2]. + + 3.Pun: This method is based on entropic thresholding: an entropy-thresholded image is the one that preserves (as much as possible) the information contained in the original unthresholded image in terms of entropy [3]. + + 4.Ridler and Calvard: A unique threshold is assumed to be the average of the foreground and background class means. The means of the two parts can be evaluated only after the threshold is determined, but the threshold needs to be computed from the two means. Therefore, an iterative algorithm was suggested: first, an initial threshold is selected (the mean of the entire histogram is a sufficient starting point), then the two means for the two distributions on either side of the threshold are calculated. A new threshold is obtained by averaging these means and the process continues until the value of the threshold converges [4]. + + 5.Kapur et al.Kapur et al. improved the Pun's approach considering the image foreground and background as two different classes of events. It first measures the class entropies, which is interpreted as a measure of class compactness. When the sum of the two class entropies reaches its maximum, the image is said to be optimally thresholded [5]. + + 6.Tsai: The Tsai's method first computes gray-level moments from the input's histogram, and then obtains the threshold according to the principle [6]. + + Syntax: + ------ + Result = py_p3dAutoThresholding8 ( image_data, dimx, dimy, dimz [, methodNum = value] [, thresh_val = variable]) + + Return Value: + ------------ + Returns a volume with the same dimensions of input volume having value 255 on skeleton voxels and 0 elsewhere. + + Arguments: + --------- + image_data: A string with the filename with full path included. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + methodNum: The method (default: 1) for the automatic determination of the threshold. + + thresh_val: An output parameter that will contain the automatically computed threshold. This parameter will be in the range + [0, 65535] for a 16-bit UINT imput image + + References + + [1] Kittler J, Illingworth J. Minimum error thresholding. Pattern Recogn. 1986;19:41-7. + [2] Otsu N. A threshold selection method from gray-level histograms. IEEE Trans Syst Man Cybern. 1979;9:62-6. + [3] Kapur JN, Sahoo PK, Wong AKC. A new method for gray-level picture thresholding using the entropy of the histogram. Graph Models Image Process. 1985;29:273-85. + [4] Tsai WH. Moment-preserving thresholding: a new approach. Graph Models Image Process. 1985;19:377-93. + [5] Ridler TW, Calvard S. Picture thresholding using an iterative selection method. IEEE Trans Syst Man Cybern. 1978;8:630-2. + [6] Pun T. Entropic thresholding: a new approach. Comp Graph Image Process. 1981;16:210-39. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + thresh_val = malloc_ushort(1) + if methodNum == 1: + err_code = p3dKittlerThresholding_16(image_data, out_image,dimx,dimy,dimz, thresh_val, None, None) + elif methodNum == 2: + err_code = p3dOtsuThresholding_16(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 3: + err_code = p3dPunThresholding_16(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 4: + err_code = p3dRidlerThresholding_16(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 5: + err_code = p3dKapurThresholding_16(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 6: + err_code = p3dJohannsenThresholding_16(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + elif methodNum == 7: + err_code = p3dHuangYagerThresholding_16(image_data, out_image,dimx,dimy,dimz,thresh_val, None, None) + else: + err_code = p3dOtsuThresholding_16(image_data, out_image,dimx,dimy,dimz, thresh_val, None, None) + + py_printErrorMessage(err_code) + return out_image + +#Gaussian Filter +def py_p3dGaussianFilter16(image_data, dimx, dimy, dimz = 0, width =3 ,sigma = 1.0): + """ + + The gaussian smoothing operator is a 2-D convolution operator that is used to "blur" images and remove detail and noise. In this sense it is similar to the mean filter, but it uses a different kernel that represents the shape of a gaussian ("bell- shaped") hump. + + The effect of gaussian smoothing is to blur an image, in a similar fashion to the mean filter. The degree of smoothing is determined by the standard deviation of the gaussian. The gaussian outputs a "weighted average" of each pixel's neighborhood, with the average weighted more towards the value of the central pixels. This is in contrast to the mean filter's uniformly weighted average. Because of this, a gaussian provides gentler smoothing and preserves edges better than a similarly sized mean filter. + + Syntax: + ------ + Result = py_p3dGaussianFilter16 ( image_data, dimx,dimy,dimz [, width=value] [, sigma=value] ) + + Return Value: + ------------ + Returns a smoothed image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type UINT representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + width : An odd integer value in the range [3, 51] (default: 3) representing the side of the square (or cubic in case of 3D input) kernel. + + sigma=value : A decimal value greater than 0 (default: 1.0) representing the standard deviation of gaussian kernel. + + Remarks: + ------- + Often a 3x3 square kernel (or a 3x3x3 cubic kernel for 3D images) is used, although larger kernels (e.g. 5x5 squares or 5x5x5 cubes) can be used for more severe smoothing. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + +""" + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if width < 3 or width > 51 or (width % 2) == 0: + py_printErrorMessage(-4) + return + + if sigma < 0 : + py_printErrorMessage(-4) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dGaussianFilter3D_16(image_data,out_image,dimx,dimy,dimz, 3,1.0, None, None) + py_printErrorMessage(err_code) + return out_image + +# Mean Filter +def py_p3dMeanFilter16(image_data, dimx, dimy, dimz = 0, width =3): + """ + + Mean filtering is a simple way to smooth an image, i.e. reducing the amount of intensity variation between one pixel and its neighbors. It is often used to reduce noise in images. + + The idea of mean filtering is simply to replace each pixel value in an image with the average value of its neighbors, including itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings. Mean filtering is usually thought of as a convolution filter. Like other convolutions it is based around a kernel, which represents the size of the neighborhood to be taked into account when calculating the mean. + + Syntax: + ------ + Result = py_p3dMeanFilter16 ( image_data, dimx,dimy,dimz [, width=value] ) + + Return Value: + ------------ + Returns a smoothed image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type UINT representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + width : An odd integer value in the range [3, 51] (default: 3) representing the side of the square (or cubic in case of 3D input) kernel. + + Remarks: + ------- + Often a 3x3 kernel (or a 3x3x3 kernel for 3D images) is used, although larger kernels (e.g. 5x5 squares or 5x5x5 cubes) can be used for more severe smoothing. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if width < 3 or width > 51 or (width % 2) == 0: + py_printErrorMessage(-4) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dMeanFilter3D_16(image_data,out_image, dimx,dimy,dimz, width,None, None) + py_printErrorMessage(err_code) + return out_image + +# Median Filter +def py_p3dMedianFilter16(image_data, dimx, dimy, dimz = 0, width=3): + """ + + The median filter is normally used to reduce noise in an image, somewhat like the mean filter. However, it often does a better job than the mean filter of preserving useful detail in the image. + + Like the mean filter, the median filter considers each pixel in the image in turn and looks at its nearby neighbors to decide whether or not it is representative of its surroundings. Instead of simply replacing the pixel value with the mean of neighboring pixel values, it replaces it with the median of those values. In principle, the median is calculated by first sorting all the pixel values from the surrounding neighborhood into numerical order and then replacing the pixel being considered with the middle pixel value. + + The median filter has two main advantages over the mean filter: 1) the median is a more robust average than the mean and so a single very unrepresentative pixel in a neighborhood will not affect the median value significantly; 2) since the median value must actually be the value of one of the pixels in the neighborhood, the median filter does not create new unrealistic pixel values when the filter straddles an edge. For this reason the median filter is much better at preserving sharp edges than the mean filter. In general, the median filter allows a great deal of high spatial frequency detail to pass while remaining very effective at removing noise on images where less than half of the pixels in a smoothing neighborhood have been effected. As a consequence of this, median filtering can be less effective at removing noise from images corrupted with Gaussian noise. + + Syntax: + ------ + Result = py_p3dMedianFilter16 ( image_data, dimx,dimy,dimz, [, width=value ] ) + + Return Value: + ------------ + Returns a smoothed image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type UINT representing the input image to filter. + + dimx, dimy, dimz: three variables representing the dimensions of image to read. + + width: An odd integer value in the range [3, 51] (default: 3) representing the side of the square (or cubic in case of 3D input) kernel. + + Remarks: + ------- + Trying to read a RAW image stored in SIGNED format is in principle an error. + Also, using p3dReadRaw8 for a 16-bit RAW image results in a completely wrong output but, again, no error could be detected. + Attention #must be paid when using this function. Pore3D internally deals only with UNSIGNED format. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if width < 3 or width > 51 or (width % 2) == 0: + py_printErrorMessage(-4) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dMedianFilter3D_16(image_data,out_image, dimx,dimy,dimz, width,None, None) + py_printErrorMessage(err_code) + return out_image + +# AnisotropicDiffusionFilter +def py_p3dAnisotropicDiffusionFilter16(image_data, dimx, dimy, dimz = 0, m = 1, lambdaP = 0.01, sigma = 0.01, iterP = 10): + """ + + Performs edge preserving smoothing using edge-enhancing anisotropic diffusion [1]. + + Anisotropic diffusion is an edge preserving smoothing filter similar to bilateral filter. When used with very small diffusion parameters and long diffusion time, it is less sensitive to contrast but better preserves finer detailed structures in images. + + Syntax: + ------ + Result = py_p3dAnisotropicDiffusionFilter16 ( image_data, dimx, dimy, dimz [, m = value ] [, lambdaP = value ] [, sigma=value ] [, iterP=value ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of UINT representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + m: A integer value greater than 0 (default: 1) representing the standard deviation of the domain gaussian + + lambdaP: A decimal value greater than 0 (default: 0.01) representing the in the diffusion equation. Higher values imply faster diffusion with more smoothing of tiny details. + + sigma: A decimal value greater than 0 (default: 0.01) representing the in the diffusion equation. Higher values imply faster diffusion with more smoothing of tiny details. + + iterP: An integer value greater than 0 (default: 10) representing the diffusion time, i.e. the number of times the algorithm is iterated. + + Remarks: + ------- + Intensive memory occupation. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if m < 0: + py_printErrorMessage(-4) + return + + if lambdaP < 0: + py_printErrorMessage(-4) + return + + if sigma < 0: + py_printErrorMessage(-4) + return + + if iterP < 0: + py_printErrorMessage(-4) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dAnisotropicDiffusionFilter3D_16(image_data,out_image, dimx,dimy,dimz,m,lambdaP,sigma,iterP,None, None) + py_printErrorMessage(err_code) + return out_image + +# BilateralFilter +def py_p3dBilateralFilter16(image_data, dimx, dimy, dimz = 0, size = 3, sigma_d = 1.0, sigma_r = 3, iterations = 10): + """ + + Bilateral filtering smooths images while preserving edges, by means of a nonlinear combination of nearby image values.. + + The idea uderlying bilateral filtering is to do in the range of an image what traditional filter do in its domain. Two pixels (or voxels) can be close to one another, that is, occupy nearby spatial location, or they can be similar to one another, that is, have nearby values. Closeness refers to the vicinity in the domain, similarity to vicinity in the range. Traditional filtering is domain filtering and enforces closeness by weighing pixel (or voxel) values with coefficients that fall off with distance. Similarly, range filters average image values with weights that decay with dissimilarity. Range filters are nonlinear because their weights depend on image intensity. The combination of domain and range filtering is denoted as bilateral filtering [1]. + + Syntax: + ------ + Result = py_p3dBilateralFilter16 ( image_data, dimx, dimy, dimz[, size=value ] [,sigma_d =value ] [, sigma_r=value ] [, iterations=value ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input images. + + Arguments: + --------- + image_data: A 2D or 3D matrix of type BYTE representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + size: An odd integer value in the range [3, 51] (default: 3) representing the side of the cubic kernel. + + sigma_d: A decimal value greater than 0 (default: 1.0) representing the standard deviation of the domain gaussian. + + sigma_r: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the range gaussian. + + iterations: The number of times the algorithm is iterated (default: 10). + + Remarks: + ------- + Often a 3x3 square kernel (or a 3x3x3 cubic kernel for 3D images) is used, although larger kernels (e.g. 5x5 squares or 5x5x5 cubes) can be used for more severe smoothing. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + if size < 3 or size > 51 or (size % 2) == 0: + py_printErrorMessage(-4) + return + + if sigma_d < 0: + py_printErrorMessage(-4) + return + + if sigma_r < 0: + py_printErrorMessage(-4) + return + + if iterations < 0: + py_printErrorMessage(-4) + return + + out_image = malloc_ushort(dimx*dimy*dimz) + err_code = p3dBilateralFilter3D_16(image_data,out_image, dimx, dimy, dimz,size,sigma_d,sigma_r,iter,None, None) + py_printErrorMessage(err_code) + return out_image + +# SijbersPostnovRingRemover 2D only +def py_p3dSijbersPostnovRingRemover16(image_data, dimx, dimy, centerX = 0, centerY = 0, winsize = 5, thresh = 1, iterations = 1, precision = 1.5 , is_bit12 = False, mask = None): + """ + + Reduce ring artifacts from reconstructed images using a modified J. Sijbers and A. Postnov algorithm [1]. + + The method is based on the observation that ring artifacts become straight vertical lines trasforming input image in polar coordinates where the center of the ring artifacts is assumed as the center of polar transformation. Within a sliding window a set of homogeneous rows of polar image is detected. Working on this set an artifact template is generated and used for the correction of the image. At the end, the image is transformed back into cartesian coordinates. + + Syntax: + ------ + Result = py_p3dSijbersPostnovRingRemover16 ( image_data, dimx, dimy, dimz [, mask= 2D image ] [, centerX=value ] [,centerY =value ] [, winsize=value ] [, thresh=value ][, iterations=1 ][, precision=value ] ) + + Return Value: + ------------ + Returns an image with the same dimensions and type of input image having ring artifacts removed. + + Arguments: + --------- + image_data: A 2D or 3D matrix of UINT representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + centerX,centerY: Coordinates of the center of ring artifacts. If this keyword is not setted the image center will be assumed as ring artifacts center (optimal condition). + + winsize: An odd integer value in the range [3, 201] (default: 51). representing the size of the sliding window used to scan the image. The purpose of the window is to detect homogeneous row segments. Therefore, the width should be chosen of adequate size in order to detect a sufficiently large number of homogeneous rows. + + thresh: A decimal value greater than 0 representing the threshold value that classifies row segments as homogeneous or inhomogeneous. + The choice of Thresh depends on the severity of the line artifacts. The less pronounced the line artifacts, the smaller the value of threshold can be chosen, with a lower bound determined by the image noise variance. A good choice for Thresh is around 3 times the image noise variance (see further remarks for the estimation of noise variance). + + iterations: Filter could be applied iteratively the specified number of times (default: 1). It is equivalent to a iterative invocation of the filter but execution time is lower (filter remains in polar coordinates and performs the conversion to cartesian coordinates only at the end of last iteration). + + precision: The discrete polar-cartesian conversion could require a denser grid in order to avoid compromising structures far from ring artifacts center. Increasing the precision parameter (between 1.0 and 5.0) results in a more precise processing but more computational time is required. If no parameter is specified, the fastest filtering is performed (default: 1.5). + + is_bit12: The THRESH value is normalized according to the input format. If the input format is 16-bit but the gray-level range is related to a 12-bit CCD camera, with this flag a correct normalization of the THRESH value is performed. + + mask :A 2D matrix (coherent with Image argument) of type BYTE having value 255 on pixel or voxel representing the region of interest and 0 elsewhere. Filtering will be applied only within the specified Mask resulting in a faster filter execution with better results in the vicinity of mask boundary. Mask could be omitted for objects having circular simmetry with baricenter that fits neatly the center of ring artifacts. Mask could be omitted also for less pronounced artifacts and for high porous objects. + + Remarks: + ------- + Trying to read a RAW image stored in SIGNED format is in principle an error. + Also, using p3dReadRaw8 for a 16-bit RAW image results in a completely wrong output but, again, no error could be detected. + Attention #must be paid when using this function. Pore3D internally deals only with UNSIGNED format. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-4) + return + + if winsize < 3 or winsize > 201 or (winsize % 2) == 0: + py_printErrorMessage(-4) + return + + if tbresh < 0: + py_printErrorMessage(-4) + return + + if iterations < 0: + py_printErrorMessage(-4) + return + + if precision < 1.0 or precision > 5.0: + py_printErrorMessage(-4) + return + + + if centerX == 0: + centerX = dimx/2 + if centerY == 0: + centerY = dimy/2 + out_image = malloc_ushort(dimx*dimy) + err_code = p3dSijbersPostnovRingRemover2D_16(image_data,out_image,dimx,dimy,centerX,centerY,winsize,thresh,iterations, precision, is_bit12, mask, None,None) + py_printErrorMessage(err_code) + return out_image + + +#From16To8 +def py_p3dFrom16To8(image_data16, dimx,dimy,dimz): +# SijbersPostnovRingRemover 2D only + """ + + Syntax: + ------ + Result = py_p3dSijbersPostnovRingRemover16 ( image_data, dimx, dimy, dimz [, mask= 2D image ] [, centerX=value ] [,centerY =value ] [, winsize=value ] [, thresh=value ][, iterations=1 ][, precision=value ] ) + + Return Value: + ------------ + Returns an image of type BYTE with the same dimensions as the input image. + + Arguments: + --------- + image_data: A 2D or 3D matrix of UINT representing the input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image8 = malloc_uchar(dimx*dimy*dimz) + err_code = p3dFrom16To8(image_data16,out_image8,dimx,dimy,dimz,dimx,dimy,None,None) + py_printErrorMessage(err_code) + return out_image8 + # CreateBinaryCircle + +# CreateBinaryCylinder + +# CreateBinarySphere + +# GetRegionByCoords diff --git a/pypore3d/pypore3d/p3dFilt_wrap.c b/pypore3d/pypore3d/p3dFilt_wrap.c new file mode 100644 index 0000000000000000000000000000000000000000..8540e8b18b54260c37fdab53b6a359e7cc25d049 --- /dev/null +++ b/pypore3d/pypore3d/p3dFilt_wrap.c @@ -0,0 +1,10161 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifndef SWIGPYTHON +#define SWIGPYTHON +#endif + +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + + +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include <math.h> +#endif + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include <Python.h> +# define _DEBUG 1 +#else +# include <Python.h> +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast(r) (r) +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *newstr = 0; + str = PyUnicode_AsUTF8String(str); + if (str) { + char *cstr; + Py_ssize_t len; + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + } + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#define Py_hash_t long +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + PyErr_Clear(); + Py_XINCREF(type); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); +#else + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# define SWIG_PYTHON_USE_GIL +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" +#endif + +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +} + +/* Unpack the argument tuple */ + +SWIGINTERN Py_ssize_t +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + Py_ssize_t i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + Py_ssize_t i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); + data->delargs = !(flags & (METH_O)); + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_repr(SwigPyObject *v) +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); + if (v->next) { + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ +SWIGRUNTIME PyObject * +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); + + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(type, value, traceback); + + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } + } + return obj; + } +} + +static PyMethodDef +swigobject_methods[] = { + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, + {0, 0, 0, 0} +}; + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#else + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +static PyObject *Swig_This_global = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + swig_cast_info *tc; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + return SWIG_OK; + } +} + +/* Convert a packed pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } + } + Py_DECREF(empty_args); + } +#else + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } +#endif + } + return inst; +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, "__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Python_DestroyModule(PyObject *obj) +{ + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + Swig_This_global = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCapsule_New((void*) descriptor, NULL, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + const char *errmesg = tmp ? tmp : "Invalid error message"; + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, errmesg); + } else { + PyErr_Format(type, "%s %s", errmesg, mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef SWIGPYTHON_BUILTIN +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; + +# ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +# else + if (!PyString_Check(name)) +# endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} +#endif + + +#ifdef __cplusplus +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + +#ifdef __cplusplus +} +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_char swig_types[0] +#define SWIGTYPE_p_coords_q_t swig_types[1] +#define SWIGTYPE_p_coords_qelem_t swig_types[2] +#define SWIGTYPE_p_coords_t swig_types[3] +#define SWIGTYPE_p_f_p_q_const__char_v_______int swig_types[4] +#define SWIGTYPE_p_f_q_const__int_v_______int swig_types[5] +#define SWIGTYPE_p_fcoords_t swig_types[6] +#define SWIGTYPE_p_float swig_types[7] +#define SWIGTYPE_p_int swig_types[8] +#define SWIGTYPE_p_p_unsigned_char swig_types[9] +#define SWIGTYPE_p_p_unsigned_short swig_types[10] +#define SWIGTYPE_p_unsigned_char swig_types[11] +#define SWIGTYPE_p_unsigned_int swig_types[12] +#define SWIGTYPE_p_unsigned_short swig_types[13] +static swig_type_info *swig_types[15]; +static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery +#endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery + +/*----------------------------------------------- + @(target):= _p3dFilt.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__p3dFilt + +#else +# define SWIG_init init_p3dFilt + +#endif +#define SWIG_name "_p3dFilt" + +#define SWIGVERSION 0x040001 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + + #define SWIG_FILE_WITH_INIT + +#include <omp.h> +/*#include "p3dTime.h"*/ +#include "P3D_Filt/p3dTime.h" +#include "P3D_Filt/p3dFilt.h" +#include "P3D_Filt/Common/p3dCoordsQueue.h" +#include "P3D_Filt/Common/p3dCoordsT.h" +#include "P3D_Filt/Common/p3dRingRemoverCommon.h" + + + +#include <stdlib.h> + + +typedef struct SWIGCDATA { + char *data; + size_t len; +} SWIGCDATA; + + + + + + +static SWIGCDATA cdata_void(void *ptr, size_t nelements) + + + +{ + SWIGCDATA d; + d.data = (char *) ptr; + + + + d.len = nelements; + + return d; +} + + + + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 + } else if (PyInt_Check(obj)) { + if (val) *val = (double) PyInt_AsLong(obj); + return SWIG_OK; +#endif + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else +#endif + if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +#include <limits.h> +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} +#endif + + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + int res = SWIG_TypeError; +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + } +#endif + return res; +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +#if PY_VERSION_HEX >= 0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); +#else + return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); +#endif +#else + return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); +#endif + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else + if (PyUnicode_Check(obj)) +#endif +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; +#if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; +#endif + PyBytes_AsStringAndSize(obj, &cstr, &len); +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else + *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; +#endif + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + Py_XDECREF(obj); +#endif + return ret; + } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + +unsigned char *realloc_uchar(unsigned char *ptr, size_t nitems) + + + +{ + +return (unsigned char *) realloc(ptr, nitems*sizeof(unsigned char)); + + + +} + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long_SS_long (unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)(value)); +} +#endif + + +SWIGINTERNINLINE PyObject * +SWIG_From_size_t (size_t value) +{ +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + return SWIG_From_unsigned_SS_long ((unsigned long)(value)); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else { + /* assume sizeof(size_t) <= sizeof(unsigned long long) */ + return SWIG_From_unsigned_SS_long_SS_long ((unsigned long long)(value)); + } +#endif +} + + + +unsigned short *realloc_ushort(unsigned short *ptr, size_t nitems) + + + +{ + +return (unsigned short *) realloc(ptr, nitems*sizeof(unsigned short)); + + + +} + + + #define SWIG_From_double PyFloat_FromDouble + + +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + + + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else +#endif + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > USHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned short)(v); + } + } + return res; +} + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_cdata(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + size_t arg2 = (size_t) 1 ; + int res1 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + SWIGCDATA result; + + if (!SWIG_Python_UnpackTuple(args, "cdata", 1, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cdata" "', argument " "1"" of type '" "void *""'"); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cdata" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = cdata_void(arg1,arg2); + resultobj = SWIG_FromCharPtrAndSize((&result)->data,(&result)->len); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_memmove(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + size_t arg3 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + size_t size2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "memmove", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "memmove" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, &size2, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "memmove" "', argument " "2"" of type '" "void const *""'"); + } + arg2 = (void *)(buf2); + arg3 = (size_t)(size2); + memmove(arg1,(void const *)arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + unsigned char *result = 0 ; + + arg1 = (size_t) sizeof(unsigned char); + if (!SWIG_Python_UnpackTuple(args, "malloc_uchar", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_uchar" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (unsigned char *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned char *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(unsigned char); + if (!SWIG_Python_UnpackTuple(args, "calloc_uchar", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_uchar" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_uchar" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (unsigned char *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_uchar", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_uchar" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (unsigned char *)realloc_uchar(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short *result = 0 ; + + arg1 = (size_t) sizeof(unsigned short); + if (!SWIG_Python_UnpackTuple(args, "malloc_ushort", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_ushort" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (unsigned short *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned short *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(unsigned short); + if (!SWIG_Python_UnpackTuple(args, "calloc_ushort", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_ushort" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_ushort" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (unsigned short *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned short *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_ushort", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_ushort" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (unsigned short *)realloc_ushort(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dResetStartTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "p3dResetStartTime", 0, 0, 0)) SWIG_fail; + p3dResetStartTime(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime", 0, 0, 0)) SWIG_fail; + result = (double)p3dGetElapsedTime(); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime_min(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime_min", 0, 0, 0)) SWIG_fail; + result = (int)p3dGetElapsedTime_min(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime_sec(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime_sec", 0, 0, 0)) SWIG_fail; + result = (double)p3dGetElapsedTime_sec(); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReadRaw8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReadRaw8", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReadRaw8" "', argument " "1"" of type '" "char *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReadRaw8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReadRaw8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReadRaw8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReadRaw8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReadRaw8" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReadRaw8" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dReadRaw8(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReadRaw16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg9)(int const,...) = (int (*)(int const,...)) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReadRaw16", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReadRaw16" "', argument " "1"" of type '" "char *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReadRaw16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReadRaw16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReadRaw16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReadRaw16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dReadRaw16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dReadRaw16" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReadRaw16" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReadRaw16" "', argument " "9"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dReadRaw16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dWriteRaw8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dWriteRaw8", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dWriteRaw8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dWriteRaw8" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dWriteRaw8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dWriteRaw8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dWriteRaw8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw8" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw8" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dWriteRaw8(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dWriteRaw16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg9)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dWriteRaw16", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dWriteRaw16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dWriteRaw16" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dWriteRaw16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dWriteRaw16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dWriteRaw16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dWriteRaw16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dWriteRaw16" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw16" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw16" "', argument " "9"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dWriteRaw16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dWriteRaw32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned int *arg1 = (unsigned int *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg9)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dWriteRaw32", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dWriteRaw32" "', argument " "1"" of type '" "unsigned int *""'"); + } + arg1 = (unsigned int *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dWriteRaw32" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dWriteRaw32" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dWriteRaw32" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dWriteRaw32" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dWriteRaw32" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dWriteRaw32" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw32" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw32" "', argument " "9"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dWriteRaw32(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dWriteRaw32f(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + float *arg1 = (float *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dWriteRaw32f", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dWriteRaw32f" "', argument " "1"" of type '" "float *""'"); + } + arg1 = (float *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dWriteRaw32f" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dWriteRaw32f" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dWriteRaw32f" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dWriteRaw32f" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw32f" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dWriteRaw32f" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dWriteRaw32f(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop2D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop2D_8", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop2D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop2D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop2D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop2D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop2D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop2D_8" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop2D_8" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dCrop2D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop2D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop2D_16", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop2D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop2D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop2D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop2D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop2D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop2D_16" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop2D_16" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dCrop2D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop3D_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCrop3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop3D_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop3D_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dCrop3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCrop3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCrop3D_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCrop3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCrop3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCrop3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCrop3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCrop3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCrop3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop3D_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCrop3D_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dCrop3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dZeroPadding2D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dZeroPadding2D_8", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dZeroPadding2D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dZeroPadding2D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dZeroPadding2D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dZeroPadding2D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dZeroPadding2D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding2D_8" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding2D_8" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dZeroPadding2D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dZeroPadding2D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dZeroPadding2D_16", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dZeroPadding2D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dZeroPadding2D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dZeroPadding2D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dZeroPadding2D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dZeroPadding2D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding2D_16" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding2D_16" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dZeroPadding2D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dZeroPadding3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dZeroPadding3D_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dZeroPadding3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dZeroPadding3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dZeroPadding3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dZeroPadding3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dZeroPadding3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dZeroPadding3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding3D_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding3D_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dZeroPadding3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dZeroPadding3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dZeroPadding3D_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dZeroPadding3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dZeroPadding3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dZeroPadding3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dZeroPadding3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dZeroPadding3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dZeroPadding3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding3D_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dZeroPadding3D_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dZeroPadding3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReplicatePadding2D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReplicatePadding2D_8", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReplicatePadding2D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReplicatePadding2D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReplicatePadding2D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReplicatePadding2D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReplicatePadding2D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding2D_8" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding2D_8" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dReplicatePadding2D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReplicatePadding2D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg7)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReplicatePadding2D_16", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReplicatePadding2D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReplicatePadding2D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReplicatePadding2D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReplicatePadding2D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReplicatePadding2D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding2D_16" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding2D_16" "', argument " "7"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dReplicatePadding2D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReplicatePadding3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReplicatePadding3D_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReplicatePadding3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReplicatePadding3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReplicatePadding3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReplicatePadding3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReplicatePadding3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dReplicatePadding3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding3D_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding3D_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dReplicatePadding3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dReplicatePadding3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dReplicatePadding3D_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dReplicatePadding3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dReplicatePadding3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dReplicatePadding3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dReplicatePadding3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dReplicatePadding3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dReplicatePadding3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding3D_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dReplicatePadding3D_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dReplicatePadding3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__p3dZeroPadding3D_float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + float *arg1 = (float *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_p3dZeroPadding3D_float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_p3dZeroPadding3D_float" "', argument " "1"" of type '" "float *""'"); + } + arg1 = (float *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_p3dZeroPadding3D_float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "_p3dZeroPadding3D_float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_p3dZeroPadding3D_float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "_p3dZeroPadding3D_float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "_p3dZeroPadding3D_float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)_p3dZeroPadding3D_float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__p3dReplicatePadding3D_float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + float *arg1 = (float *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_p3dReplicatePadding3D_float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_p3dReplicatePadding3D_float" "', argument " "1"" of type '" "float *""'"); + } + arg1 = (float *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_p3dReplicatePadding3D_float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "_p3dReplicatePadding3D_float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_p3dReplicatePadding3D_float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "_p3dReplicatePadding3D_float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "_p3dReplicatePadding3D_float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)_p3dReplicatePadding3D_float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__p3dZeroPadding3D_uchar2float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_p3dZeroPadding3D_uchar2float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_p3dZeroPadding3D_uchar2float" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_p3dZeroPadding3D_uchar2float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "_p3dZeroPadding3D_uchar2float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_p3dZeroPadding3D_uchar2float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "_p3dZeroPadding3D_uchar2float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "_p3dZeroPadding3D_uchar2float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)_p3dZeroPadding3D_uchar2float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__p3dReplicatePadding3D_uchar2float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_p3dReplicatePadding3D_uchar2float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_p3dReplicatePadding3D_uchar2float" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_p3dReplicatePadding3D_uchar2float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "_p3dReplicatePadding3D_uchar2float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_p3dReplicatePadding3D_uchar2float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "_p3dReplicatePadding3D_uchar2float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "_p3dReplicatePadding3D_uchar2float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)_p3dReplicatePadding3D_uchar2float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__p3dZeroPadding3D_ushort2float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_p3dZeroPadding3D_ushort2float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_p3dZeroPadding3D_ushort2float" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_p3dZeroPadding3D_ushort2float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "_p3dZeroPadding3D_ushort2float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_p3dZeroPadding3D_ushort2float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "_p3dZeroPadding3D_ushort2float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "_p3dZeroPadding3D_ushort2float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)_p3dZeroPadding3D_ushort2float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__p3dReplicatePadding3D_ushort2float(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + float *arg2 = (float *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_p3dReplicatePadding3D_ushort2float", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_p3dReplicatePadding3D_ushort2float" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_p3dReplicatePadding3D_ushort2float" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "_p3dReplicatePadding3D_ushort2float" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_p3dReplicatePadding3D_ushort2float" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "_p3dReplicatePadding3D_ushort2float" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "_p3dReplicatePadding3D_ushort2float" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)_p3dReplicatePadding3D_ushort2float(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dAnisotropicDiffusionFilter3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + double arg8 ; + int arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg11)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[11] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dAnisotropicDiffusionFilter3D_8", 11, 11, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[10], (void**)(&arg11), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dAnisotropicDiffusionFilter3D_8" "', argument " "11"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dAnisotropicDiffusionFilter3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dAnisotropicDiffusionFilter3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + double arg8 ; + int arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg11)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[11] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dAnisotropicDiffusionFilter3D_16", 11, 11, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[10], (void**)(&arg11), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dAnisotropicDiffusionFilter3D_16" "', argument " "11"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dAnisotropicDiffusionFilter3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBilateralFilter3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + double arg8 ; + int arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg11)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[11] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBilateralFilter3D_8", 11, 11, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBilateralFilter3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBilateralFilter3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBilateralFilter3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBilateralFilter3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBilateralFilter3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBilateralFilter3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBilateralFilter3D_8" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBilateralFilter3D_8" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dBilateralFilter3D_8" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBilateralFilter3D_8" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[10], (void**)(&arg11), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBilateralFilter3D_8" "', argument " "11"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dBilateralFilter3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBilateralFilter3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + double arg8 ; + int arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg11)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[11] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBilateralFilter3D_16", 11, 11, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBilateralFilter3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBilateralFilter3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBilateralFilter3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBilateralFilter3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBilateralFilter3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBilateralFilter3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBilateralFilter3D_16" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBilateralFilter3D_16" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dBilateralFilter3D_16" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBilateralFilter3D_16" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[10], (void**)(&arg11), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBilateralFilter3D_16" "', argument " "11"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dBilateralFilter3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGaussianFilter3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg9)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGaussianFilter3D_8", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGaussianFilter3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGaussianFilter3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGaussianFilter3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGaussianFilter3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGaussianFilter3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGaussianFilter3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGaussianFilter3D_8" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGaussianFilter3D_8" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGaussianFilter3D_8" "', argument " "9"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dGaussianFilter3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGaussianFilter3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + double arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg9)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGaussianFilter3D_16", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGaussianFilter3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGaussianFilter3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGaussianFilter3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGaussianFilter3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGaussianFilter3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGaussianFilter3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGaussianFilter3D_16" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGaussianFilter3D_16" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGaussianFilter3D_16" "', argument " "9"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dGaussianFilter3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dMeanFilter3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dMeanFilter3D_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dMeanFilter3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dMeanFilter3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dMeanFilter3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dMeanFilter3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dMeanFilter3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dMeanFilter3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMeanFilter3D_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMeanFilter3D_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dMeanFilter3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dMeanFilter3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dMeanFilter3D_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dMeanFilter3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dMeanFilter3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dMeanFilter3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dMeanFilter3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dMeanFilter3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dMeanFilter3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMeanFilter3D_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMeanFilter3D_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dMeanFilter3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dMedianFilter3D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dMedianFilter3D_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dMedianFilter3D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dMedianFilter3D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dMedianFilter3D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dMedianFilter3D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dMedianFilter3D_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dMedianFilter3D_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMedianFilter3D_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMedianFilter3D_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dMedianFilter3D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dMedianFilter3D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dMedianFilter3D_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dMedianFilter3D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dMedianFilter3D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dMedianFilter3D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dMedianFilter3D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dMedianFilter3D_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dMedianFilter3D_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMedianFilter3D_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dMedianFilter3D_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dMedianFilter3D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBoinHaibelRingRemover2D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + int arg7 ; + int arg8 ; + double arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + double val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBoinHaibelRingRemover2D_8", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_double(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "9"" of type '" "double""'"); + } + arg9 = (double)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBoinHaibelRingRemover2D_8" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dBoinHaibelRingRemover2D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dBoinHaibelRingRemover2D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + int arg7 ; + int arg8 ; + double arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + double val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dBoinHaibelRingRemover2D_16", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_double(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "9"" of type '" "double""'"); + } + arg9 = (double)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dBoinHaibelRingRemover2D_16" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dBoinHaibelRingRemover2D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSijbersPostnovRingRemover2D_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + int arg7 ; + double arg8 ; + int arg9 ; + double arg10 ; + unsigned char *arg11 = (unsigned char *) 0 ; + int (*arg12)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg13)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + double val10 ; + int ecode10 = 0 ; + void *argp11 = 0 ; + int res11 = 0 ; + PyObject *swig_obj[13] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSijbersPostnovRingRemover2D_8", 13, 13, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_double(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "10"" of type '" "double""'"); + } + arg10 = (double)(val10); + res11 = SWIG_ConvertPtr(swig_obj[10], &argp11,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res11)) { + SWIG_exception_fail(SWIG_ArgError(res11), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "11"" of type '" "unsigned char *""'"); + } + arg11 = (unsigned char *)(argp11); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[11], (void**)(&arg12), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "12"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[12], (void**)(&arg13), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSijbersPostnovRingRemover2D_8" "', argument " "13"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dSijbersPostnovRingRemover2D_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSijbersPostnovRingRemover2D_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + int arg7 ; + double arg8 ; + int arg9 ; + double arg10 ; + int arg11 ; + unsigned char *arg12 = (unsigned char *) 0 ; + int (*arg13)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg14)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + double val10 ; + int ecode10 = 0 ; + int val11 ; + int ecode11 = 0 ; + void *argp12 = 0 ; + int res12 = 0 ; + PyObject *swig_obj[14] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSijbersPostnovRingRemover2D_16", 14, 14, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_double(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "10"" of type '" "double""'"); + } + arg10 = (double)(val10); + ecode11 = SWIG_AsVal_int(swig_obj[10], &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "11"" of type '" "int""'"); + } + arg11 = (int)(val11); + res12 = SWIG_ConvertPtr(swig_obj[11], &argp12,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res12)) { + SWIG_exception_fail(SWIG_ArgError(res12), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "12"" of type '" "unsigned char *""'"); + } + arg12 = (unsigned char *)(argp12); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[12], (void**)(&arg13), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "13"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[13], (void**)(&arg14), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSijbersPostnovRingRemover2D_16" "', argument " "14"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dSijbersPostnovRingRemover2D_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dKittlerThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dKittlerThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dKittlerThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dKittlerThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dKittlerThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dKittlerThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dKittlerThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dKittlerThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKittlerThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKittlerThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dKittlerThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dKittlerThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dKittlerThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dKittlerThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dKittlerThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dKittlerThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dKittlerThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dKittlerThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dKittlerThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKittlerThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKittlerThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dKittlerThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dOtsuThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dOtsuThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dOtsuThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dOtsuThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dOtsuThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dOtsuThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dOtsuThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dOtsuThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dOtsuThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dOtsuThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dOtsuThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dOtsuThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dOtsuThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dOtsuThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dOtsuThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dOtsuThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dOtsuThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dOtsuThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dOtsuThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dOtsuThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dOtsuThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dOtsuThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dPunThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dPunThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dPunThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dPunThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dPunThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dPunThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dPunThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dPunThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dPunThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dPunThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dPunThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dPunThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dPunThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dPunThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dPunThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dPunThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dPunThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dPunThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dPunThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dPunThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dPunThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dPunThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dRidlerThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dRidlerThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dRidlerThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dRidlerThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dRidlerThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dRidlerThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dRidlerThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dRidlerThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dRidlerThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dRidlerThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dRidlerThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dRidlerThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dRidlerThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dRidlerThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dRidlerThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dRidlerThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dRidlerThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dRidlerThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dRidlerThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dRidlerThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dRidlerThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dRidlerThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dKapurThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dKapurThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dKapurThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dKapurThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dKapurThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dKapurThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dKapurThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dKapurThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKapurThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKapurThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dKapurThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dKapurThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dKapurThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dKapurThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dKapurThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dKapurThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dKapurThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dKapurThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dKapurThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKapurThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dKapurThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dKapurThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dJohannsenThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dJohannsenThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dJohannsenThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dJohannsenThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dJohannsenThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dJohannsenThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dJohannsenThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dJohannsenThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dJohannsenThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dJohannsenThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dJohannsenThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dJohannsenThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dJohannsenThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dJohannsenThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dJohannsenThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dJohannsenThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dJohannsenThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dJohannsenThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dJohannsenThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dJohannsenThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dJohannsenThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dJohannsenThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dHuangYagerThresholding_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned char *arg6 = (unsigned char *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dHuangYagerThresholding_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dHuangYagerThresholding_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dHuangYagerThresholding_8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dHuangYagerThresholding_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dHuangYagerThresholding_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dHuangYagerThresholding_8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dHuangYagerThresholding_8" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dHuangYagerThresholding_8" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dHuangYagerThresholding_8" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dHuangYagerThresholding_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dHuangYagerThresholding_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short *arg6 = (unsigned short *) 0 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg8)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dHuangYagerThresholding_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dHuangYagerThresholding_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dHuangYagerThresholding_16" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dHuangYagerThresholding_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dHuangYagerThresholding_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dHuangYagerThresholding_16" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dHuangYagerThresholding_16" "', argument " "6"" of type '" "unsigned short *""'"); + } + arg6 = (unsigned short *)(argp6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dHuangYagerThresholding_16" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dHuangYagerThresholding_16" "', argument " "8"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dHuangYagerThresholding_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dClearBorderFilter3D(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dClearBorderFilter3D", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dClearBorderFilter3D" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dClearBorderFilter3D" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dClearBorderFilter3D" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dClearBorderFilter3D" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dClearBorderFilter3D" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dClearBorderFilter3D" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dClearBorderFilter3D" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dClearBorderFilter3D(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetRegionByCoords3D(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetRegionByCoords3D", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGetRegionByCoords3D" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGetRegionByCoords3D" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGetRegionByCoords3D" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGetRegionByCoords3D" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGetRegionByCoords3D" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGetRegionByCoords3D" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGetRegionByCoords3D" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dGetRegionByCoords3D" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dGetRegionByCoords3D" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGetRegionByCoords3D" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dGetRegionByCoords3D(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCreateBinaryCircle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCreateBinaryCircle", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCreateBinaryCircle" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "p3dCreateBinaryCircle" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCreateBinaryCircle" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCreateBinaryCircle" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCreateBinaryCircle" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCreateBinaryCircle" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCreateBinaryCircle" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dCreateBinaryCircle(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCreateBinaryCylinder(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCreateBinaryCylinder", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCreateBinaryCylinder" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "p3dCreateBinaryCylinder" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCreateBinaryCylinder" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCreateBinaryCylinder" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCreateBinaryCylinder" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCreateBinaryCylinder" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dCreateBinaryCylinder" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCreateBinaryCylinder" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dCreateBinaryCylinder(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCreateBinarySphere(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int (*arg9)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dCreateBinarySphere", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCreateBinarySphere" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "p3dCreateBinarySphere" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCreateBinarySphere" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCreateBinarySphere" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCreateBinarySphere" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCreateBinarySphere" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dCreateBinarySphere" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dCreateBinarySphere" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dCreateBinarySphere" "', argument " "9"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dCreateBinarySphere(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dFrom16To8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + unsigned short arg6 ; + unsigned short arg7 ; + int (*arg8)(char const *,...) = (int (*)(char const *,...)) 0 ; + int (*arg9)(int const,...) = (int (*)(int const,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + unsigned short val6 ; + int ecode6 = 0 ; + unsigned short val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dFrom16To8", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dFrom16To8" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dFrom16To8" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dFrom16To8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dFrom16To8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dFrom16To8" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_unsigned_SS_short(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dFrom16To8" "', argument " "6"" of type '" "unsigned short""'"); + } + arg6 = (unsigned short)(val6); + ecode7 = SWIG_AsVal_unsigned_SS_short(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dFrom16To8" "', argument " "7"" of type '" "unsigned short""'"); + } + arg7 = (unsigned short)(val7); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[7], (void**)(&arg8), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dFrom16To8" "', argument " "8"" of type '" "int (*)(char const *,...)""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[8], (void**)(&arg9), SWIGTYPE_p_f_q_const__int_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dFrom16To8" "', argument " "9"" of type '" "int (*)(int const,...)""'"); + } + } + result = (int)p3dFrom16To8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_item_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + coords_t *arg2 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_qelem_t_item_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_item_set" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_qelem_t_item_set" "', argument " "2"" of type '" "coords_t *""'"); + } + arg2 = (coords_t *)(argp2); + if (arg1) (arg1)->item = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_item_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_item_get" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + result = (coords_t *)& ((arg1)->item); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + struct coords_qelem_t *arg2 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_qelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_next_set" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_qelem_t_next_set" "', argument " "2"" of type '" "struct coords_qelem_t *""'"); + } + arg2 = (struct coords_qelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct coords_qelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_next_get" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + result = (struct coords_qelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_qelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_qelem_t", 0, 0, 0)) SWIG_fail; + result = (struct coords_qelem_t *)calloc(1, sizeof(struct coords_qelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_qelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_qelem_t" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_qelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_qelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_qelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_q_t_tail_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_q_t *arg1 = (struct coords_q_t *) 0 ; + coords_queue_elem_t *arg2 = (coords_queue_elem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_q_t_tail_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_q_t_tail_set" "', argument " "1"" of type '" "struct coords_q_t *""'"); + } + arg1 = (struct coords_q_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_q_t_tail_set" "', argument " "2"" of type '" "coords_queue_elem_t *""'"); + } + arg2 = (coords_queue_elem_t *)(argp2); + if (arg1) (arg1)->tail = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_q_t_tail_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_q_t *arg1 = (struct coords_q_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_queue_elem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_q_t_tail_get" "', argument " "1"" of type '" "struct coords_q_t *""'"); + } + arg1 = (struct coords_q_t *)(argp1); + result = (coords_queue_elem_t *) ((arg1)->tail); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_q_t_head_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_q_t *arg1 = (struct coords_q_t *) 0 ; + coords_queue_elem_t *arg2 = (coords_queue_elem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_q_t_head_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_q_t_head_set" "', argument " "1"" of type '" "struct coords_q_t *""'"); + } + arg1 = (struct coords_q_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_q_t_head_set" "', argument " "2"" of type '" "coords_queue_elem_t *""'"); + } + arg2 = (coords_queue_elem_t *)(argp2); + if (arg1) (arg1)->head = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_q_t_head_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_q_t *arg1 = (struct coords_q_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_queue_elem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_q_t_head_get" "', argument " "1"" of type '" "struct coords_q_t *""'"); + } + arg1 = (struct coords_q_t *)(argp1); + result = (coords_queue_elem_t *) ((arg1)->head); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_q_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_q_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_q_t", 0, 0, 0)) SWIG_fail; + result = (struct coords_q_t *)calloc(1, sizeof(struct coords_q_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_q_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_q_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_q_t *arg1 = (struct coords_q_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_q_t" "', argument " "1"" of type '" "struct coords_q_t *""'"); + } + arg1 = (struct coords_q_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_q_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_q_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_q_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_queue_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_init" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + coords_queue_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_push" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_coords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_push" "', argument " "2"" of type '" "coords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_queue_push" "', argument " "2"" of type '" "coords_t""'"); + } else { + arg2 = *((coords_t *)(argp2)); + } + } + coords_queue_push(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_q_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_pop" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = coords_queue_pop(arg1); + resultobj = SWIG_NewPointerObj((coords_t *)memcpy((coords_t *)calloc(1,sizeof(coords_t)),&result,sizeof(coords_t)), SWIGTYPE_p_coords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t arg1 ; + void *argp1 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_coords_q_t, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_isempty" "', argument " "1"" of type '" "coords_queue_t""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_queue_isempty" "', argument " "1"" of type '" "coords_queue_t""'"); + } else { + arg1 = *((coords_queue_t *)(argp1)); + } + } + result = (int)coords_queue_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_x_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_x_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_y_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_y_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_z_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_z_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_t", 0, 0, 0)) SWIG_fail; + result = (coords_t *)calloc(1, sizeof(coords_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_t" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_fcoords_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_x_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_x_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_y_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_y_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_z_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_z_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_fcoords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_fcoords_t", 0, 0, 0)) SWIG_fail; + result = (fcoords_t *)calloc(1, sizeof(fcoords_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_fcoords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_fcoords_t" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *fcoords_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_fcoords_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *fcoords_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_p3dCartesian2polar_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char **arg2 = (unsigned char **) 0 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + int *arg8 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + void *argp8 = 0 ; + int res8 = 0 ; + PyObject *swig_obj[8] ; + + if (!SWIG_Python_UnpackTuple(args, "p3dCartesian2polar_8", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCartesian2polar_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCartesian2polar_8" "', argument " "2"" of type '" "unsigned char **""'"); + } + arg2 = (unsigned char **)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCartesian2polar_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCartesian2polar_8" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCartesian2polar_8" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCartesian2polar_8" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dCartesian2polar_8" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + res8 = SWIG_ConvertPtr(swig_obj[7], &argp8,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "p3dCartesian2polar_8" "', argument " "8"" of type '" "int *""'"); + } + arg8 = (int *)(argp8); + p3dCartesian2polar_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dCartesian2polar_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short **arg2 = (unsigned short **) 0 ; + int arg3 ; + int arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + int *arg8 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + void *argp8 = 0 ; + int res8 = 0 ; + PyObject *swig_obj[8] ; + + if (!SWIG_Python_UnpackTuple(args, "p3dCartesian2polar_16", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dCartesian2polar_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dCartesian2polar_16" "', argument " "2"" of type '" "unsigned short **""'"); + } + arg2 = (unsigned short **)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dCartesian2polar_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dCartesian2polar_16" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dCartesian2polar_16" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dCartesian2polar_16" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dCartesian2polar_16" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + res8 = SWIG_ConvertPtr(swig_obj[7], &argp8,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "p3dCartesian2polar_16" "', argument " "8"" of type '" "int *""'"); + } + arg8 = (int *)(argp8); + p3dCartesian2polar_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dPolar2cartesian_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char **arg2 = (unsigned char **) 0 ; + int arg3 ; + double arg4 ; + double arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + + if (!SWIG_Python_UnpackTuple(args, "p3dPolar2cartesian_8", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dPolar2cartesian_8" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dPolar2cartesian_8" "', argument " "2"" of type '" "unsigned char **""'"); + } + arg2 = (unsigned char **)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dPolar2cartesian_8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_double(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dPolar2cartesian_8" "', argument " "4"" of type '" "double""'"); + } + arg4 = (double)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dPolar2cartesian_8" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dPolar2cartesian_8" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dPolar2cartesian_8" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + p3dPolar2cartesian_8(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dPolar2cartesian_16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + unsigned short **arg2 = (unsigned short **) 0 ; + int arg3 ; + double arg4 ; + double arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + + if (!SWIG_Python_UnpackTuple(args, "p3dPolar2cartesian_16", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dPolar2cartesian_16" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dPolar2cartesian_16" "', argument " "2"" of type '" "unsigned short **""'"); + } + arg2 = (unsigned short **)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dPolar2cartesian_16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_double(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dPolar2cartesian_16" "', argument " "4"" of type '" "double""'"); + } + arg4 = (double)(val4); + ecode5 = SWIG_AsVal_double(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dPolar2cartesian_16" "', argument " "5"" of type '" "double""'"); + } + arg5 = (double)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dPolar2cartesian_16" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dPolar2cartesian_16" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + p3dPolar2cartesian_16(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, + { "cdata", _wrap_cdata, METH_VARARGS, NULL}, + { "memmove", _wrap_memmove, METH_VARARGS, NULL}, + { "malloc_uchar", _wrap_malloc_uchar, METH_VARARGS, NULL}, + { "calloc_uchar", _wrap_calloc_uchar, METH_VARARGS, NULL}, + { "realloc_uchar", _wrap_realloc_uchar, METH_VARARGS, NULL}, + { "free_uchar", _wrap_free_uchar, METH_O, NULL}, + { "malloc_ushort", _wrap_malloc_ushort, METH_VARARGS, NULL}, + { "calloc_ushort", _wrap_calloc_ushort, METH_VARARGS, NULL}, + { "realloc_ushort", _wrap_realloc_ushort, METH_VARARGS, NULL}, + { "free_ushort", _wrap_free_ushort, METH_O, NULL}, + { "p3dResetStartTime", _wrap_p3dResetStartTime, METH_NOARGS, NULL}, + { "p3dGetElapsedTime", _wrap_p3dGetElapsedTime, METH_NOARGS, NULL}, + { "p3dGetElapsedTime_min", _wrap_p3dGetElapsedTime_min, METH_NOARGS, NULL}, + { "p3dGetElapsedTime_sec", _wrap_p3dGetElapsedTime_sec, METH_NOARGS, NULL}, + { "p3dReadRaw8", _wrap_p3dReadRaw8, METH_VARARGS, NULL}, + { "p3dReadRaw16", _wrap_p3dReadRaw16, METH_VARARGS, NULL}, + { "p3dWriteRaw8", _wrap_p3dWriteRaw8, METH_VARARGS, NULL}, + { "p3dWriteRaw16", _wrap_p3dWriteRaw16, METH_VARARGS, NULL}, + { "p3dWriteRaw32", _wrap_p3dWriteRaw32, METH_VARARGS, NULL}, + { "p3dWriteRaw32f", _wrap_p3dWriteRaw32f, METH_VARARGS, NULL}, + { "p3dCrop2D_8", _wrap_p3dCrop2D_8, METH_VARARGS, NULL}, + { "p3dCrop2D_16", _wrap_p3dCrop2D_16, METH_VARARGS, NULL}, + { "p3dCrop3D_8", _wrap_p3dCrop3D_8, METH_VARARGS, NULL}, + { "p3dCrop3D_16", _wrap_p3dCrop3D_16, METH_VARARGS, NULL}, + { "p3dZeroPadding2D_8", _wrap_p3dZeroPadding2D_8, METH_VARARGS, NULL}, + { "p3dZeroPadding2D_16", _wrap_p3dZeroPadding2D_16, METH_VARARGS, NULL}, + { "p3dZeroPadding3D_8", _wrap_p3dZeroPadding3D_8, METH_VARARGS, NULL}, + { "p3dZeroPadding3D_16", _wrap_p3dZeroPadding3D_16, METH_VARARGS, NULL}, + { "p3dReplicatePadding2D_8", _wrap_p3dReplicatePadding2D_8, METH_VARARGS, NULL}, + { "p3dReplicatePadding2D_16", _wrap_p3dReplicatePadding2D_16, METH_VARARGS, NULL}, + { "p3dReplicatePadding3D_8", _wrap_p3dReplicatePadding3D_8, METH_VARARGS, NULL}, + { "p3dReplicatePadding3D_16", _wrap_p3dReplicatePadding3D_16, METH_VARARGS, NULL}, + { "_p3dZeroPadding3D_float", _wrap__p3dZeroPadding3D_float, METH_VARARGS, NULL}, + { "_p3dReplicatePadding3D_float", _wrap__p3dReplicatePadding3D_float, METH_VARARGS, NULL}, + { "_p3dZeroPadding3D_uchar2float", _wrap__p3dZeroPadding3D_uchar2float, METH_VARARGS, NULL}, + { "_p3dReplicatePadding3D_uchar2float", _wrap__p3dReplicatePadding3D_uchar2float, METH_VARARGS, NULL}, + { "_p3dZeroPadding3D_ushort2float", _wrap__p3dZeroPadding3D_ushort2float, METH_VARARGS, NULL}, + { "_p3dReplicatePadding3D_ushort2float", _wrap__p3dReplicatePadding3D_ushort2float, METH_VARARGS, NULL}, + { "p3dAnisotropicDiffusionFilter3D_8", _wrap_p3dAnisotropicDiffusionFilter3D_8, METH_VARARGS, NULL}, + { "p3dAnisotropicDiffusionFilter3D_16", _wrap_p3dAnisotropicDiffusionFilter3D_16, METH_VARARGS, NULL}, + { "p3dBilateralFilter3D_8", _wrap_p3dBilateralFilter3D_8, METH_VARARGS, NULL}, + { "p3dBilateralFilter3D_16", _wrap_p3dBilateralFilter3D_16, METH_VARARGS, NULL}, + { "p3dGaussianFilter3D_8", _wrap_p3dGaussianFilter3D_8, METH_VARARGS, NULL}, + { "p3dGaussianFilter3D_16", _wrap_p3dGaussianFilter3D_16, METH_VARARGS, NULL}, + { "p3dMeanFilter3D_8", _wrap_p3dMeanFilter3D_8, METH_VARARGS, NULL}, + { "p3dMeanFilter3D_16", _wrap_p3dMeanFilter3D_16, METH_VARARGS, NULL}, + { "p3dMedianFilter3D_8", _wrap_p3dMedianFilter3D_8, METH_VARARGS, NULL}, + { "p3dMedianFilter3D_16", _wrap_p3dMedianFilter3D_16, METH_VARARGS, NULL}, + { "p3dBoinHaibelRingRemover2D_8", _wrap_p3dBoinHaibelRingRemover2D_8, METH_VARARGS, NULL}, + { "p3dBoinHaibelRingRemover2D_16", _wrap_p3dBoinHaibelRingRemover2D_16, METH_VARARGS, NULL}, + { "p3dSijbersPostnovRingRemover2D_8", _wrap_p3dSijbersPostnovRingRemover2D_8, METH_VARARGS, NULL}, + { "p3dSijbersPostnovRingRemover2D_16", _wrap_p3dSijbersPostnovRingRemover2D_16, METH_VARARGS, NULL}, + { "p3dKittlerThresholding_8", _wrap_p3dKittlerThresholding_8, METH_VARARGS, NULL}, + { "p3dKittlerThresholding_16", _wrap_p3dKittlerThresholding_16, METH_VARARGS, NULL}, + { "p3dOtsuThresholding_8", _wrap_p3dOtsuThresholding_8, METH_VARARGS, NULL}, + { "p3dOtsuThresholding_16", _wrap_p3dOtsuThresholding_16, METH_VARARGS, NULL}, + { "p3dPunThresholding_8", _wrap_p3dPunThresholding_8, METH_VARARGS, NULL}, + { "p3dPunThresholding_16", _wrap_p3dPunThresholding_16, METH_VARARGS, NULL}, + { "p3dRidlerThresholding_8", _wrap_p3dRidlerThresholding_8, METH_VARARGS, NULL}, + { "p3dRidlerThresholding_16", _wrap_p3dRidlerThresholding_16, METH_VARARGS, NULL}, + { "p3dKapurThresholding_8", _wrap_p3dKapurThresholding_8, METH_VARARGS, NULL}, + { "p3dKapurThresholding_16", _wrap_p3dKapurThresholding_16, METH_VARARGS, NULL}, + { "p3dJohannsenThresholding_8", _wrap_p3dJohannsenThresholding_8, METH_VARARGS, NULL}, + { "p3dJohannsenThresholding_16", _wrap_p3dJohannsenThresholding_16, METH_VARARGS, NULL}, + { "p3dHuangYagerThresholding_8", _wrap_p3dHuangYagerThresholding_8, METH_VARARGS, NULL}, + { "p3dHuangYagerThresholding_16", _wrap_p3dHuangYagerThresholding_16, METH_VARARGS, NULL}, + { "p3dClearBorderFilter3D", _wrap_p3dClearBorderFilter3D, METH_VARARGS, NULL}, + { "p3dGetRegionByCoords3D", _wrap_p3dGetRegionByCoords3D, METH_VARARGS, NULL}, + { "p3dCreateBinaryCircle", _wrap_p3dCreateBinaryCircle, METH_VARARGS, NULL}, + { "p3dCreateBinaryCylinder", _wrap_p3dCreateBinaryCylinder, METH_VARARGS, NULL}, + { "p3dCreateBinarySphere", _wrap_p3dCreateBinarySphere, METH_VARARGS, NULL}, + { "p3dFrom16To8", _wrap_p3dFrom16To8, METH_VARARGS, NULL}, + { "coords_qelem_t_item_set", _wrap_coords_qelem_t_item_set, METH_VARARGS, NULL}, + { "coords_qelem_t_item_get", _wrap_coords_qelem_t_item_get, METH_O, NULL}, + { "coords_qelem_t_next_set", _wrap_coords_qelem_t_next_set, METH_VARARGS, NULL}, + { "coords_qelem_t_next_get", _wrap_coords_qelem_t_next_get, METH_O, NULL}, + { "new_coords_qelem_t", _wrap_new_coords_qelem_t, METH_NOARGS, NULL}, + { "delete_coords_qelem_t", _wrap_delete_coords_qelem_t, METH_O, NULL}, + { "coords_qelem_t_swigregister", coords_qelem_t_swigregister, METH_O, NULL}, + { "coords_qelem_t_swiginit", coords_qelem_t_swiginit, METH_VARARGS, NULL}, + { "coords_q_t_tail_set", _wrap_coords_q_t_tail_set, METH_VARARGS, NULL}, + { "coords_q_t_tail_get", _wrap_coords_q_t_tail_get, METH_O, NULL}, + { "coords_q_t_head_set", _wrap_coords_q_t_head_set, METH_VARARGS, NULL}, + { "coords_q_t_head_get", _wrap_coords_q_t_head_get, METH_O, NULL}, + { "new_coords_q_t", _wrap_new_coords_q_t, METH_NOARGS, NULL}, + { "delete_coords_q_t", _wrap_delete_coords_q_t, METH_O, NULL}, + { "coords_q_t_swigregister", coords_q_t_swigregister, METH_O, NULL}, + { "coords_q_t_swiginit", coords_q_t_swiginit, METH_VARARGS, NULL}, + { "coords_queue_init", _wrap_coords_queue_init, METH_O, NULL}, + { "coords_queue_push", _wrap_coords_queue_push, METH_VARARGS, NULL}, + { "coords_queue_pop", _wrap_coords_queue_pop, METH_O, NULL}, + { "coords_queue_isempty", _wrap_coords_queue_isempty, METH_O, NULL}, + { "coords_t_x_set", _wrap_coords_t_x_set, METH_VARARGS, NULL}, + { "coords_t_x_get", _wrap_coords_t_x_get, METH_O, NULL}, + { "coords_t_y_set", _wrap_coords_t_y_set, METH_VARARGS, NULL}, + { "coords_t_y_get", _wrap_coords_t_y_get, METH_O, NULL}, + { "coords_t_z_set", _wrap_coords_t_z_set, METH_VARARGS, NULL}, + { "coords_t_z_get", _wrap_coords_t_z_get, METH_O, NULL}, + { "new_coords_t", _wrap_new_coords_t, METH_NOARGS, NULL}, + { "delete_coords_t", _wrap_delete_coords_t, METH_O, NULL}, + { "coords_t_swigregister", coords_t_swigregister, METH_O, NULL}, + { "coords_t_swiginit", coords_t_swiginit, METH_VARARGS, NULL}, + { "fcoords_t_x_set", _wrap_fcoords_t_x_set, METH_VARARGS, NULL}, + { "fcoords_t_x_get", _wrap_fcoords_t_x_get, METH_O, NULL}, + { "fcoords_t_y_set", _wrap_fcoords_t_y_set, METH_VARARGS, NULL}, + { "fcoords_t_y_get", _wrap_fcoords_t_y_get, METH_O, NULL}, + { "fcoords_t_z_set", _wrap_fcoords_t_z_set, METH_VARARGS, NULL}, + { "fcoords_t_z_get", _wrap_fcoords_t_z_get, METH_O, NULL}, + { "new_fcoords_t", _wrap_new_fcoords_t, METH_NOARGS, NULL}, + { "delete_fcoords_t", _wrap_delete_fcoords_t, METH_O, NULL}, + { "fcoords_t_swigregister", fcoords_t_swigregister, METH_O, NULL}, + { "fcoords_t_swiginit", fcoords_t_swiginit, METH_VARARGS, NULL}, + { "p3dCartesian2polar_8", _wrap_p3dCartesian2polar_8, METH_VARARGS, NULL}, + { "p3dCartesian2polar_16", _wrap_p3dCartesian2polar_16, METH_VARARGS, NULL}, + { "p3dPolar2cartesian_8", _wrap_p3dPolar2cartesian_8, METH_VARARGS, NULL}, + { "p3dPolar2cartesian_16", _wrap_p3dPolar2cartesian_16, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + +static PyMethodDef SwigMethods_proxydocs[] = { + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_q_t = {"_p_coords_q_t", "struct coords_q_t *|coords_q_t *|coords_queue_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_qelem_t = {"_p_coords_qelem_t", "struct coords_qelem_t *|coords_qelem_t *|coords_queue_elem_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_t = {"_p_coords_t", "coords_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__char_v_______int = {"_p_f_p_q_const__char_v_______int", "int (*)(char const *,...)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_q_const__int_v_______int = {"_p_f_q_const__int_v_______int", "int (*)(int const,...)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_fcoords_t = {"_p_fcoords_t", "fcoords_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_float = {"_p_float", "float *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_unsigned_char = {"_p_p_unsigned_char", "unsigned char **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_unsigned_short = {"_p_p_unsigned_short", "unsigned short **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_char, + &_swigt__p_coords_q_t, + &_swigt__p_coords_qelem_t, + &_swigt__p_coords_t, + &_swigt__p_f_p_q_const__char_v_______int, + &_swigt__p_f_q_const__int_v_______int, + &_swigt__p_fcoords_t, + &_swigt__p_float, + &_swigt__p_int, + &_swigt__p_p_unsigned_char, + &_swigt__p_p_unsigned_short, + &_swigt__p_unsigned_char, + &_swigt__p_unsigned_int, + &_swigt__p_unsigned_short, +}; + +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_q_t[] = { {&_swigt__p_coords_q_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_qelem_t[] = { {&_swigt__p_coords_qelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_t[] = { {&_swigt__p_coords_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__char_v_______int[] = { {&_swigt__p_f_p_q_const__char_v_______int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_q_const__int_v_______int[] = { {&_swigt__p_f_q_const__int_v_______int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_fcoords_t[] = { {&_swigt__p_fcoords_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_unsigned_char[] = { {&_swigt__p_p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_unsigned_short[] = { {&_swigt__p_p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_char, + _swigc__p_coords_q_t, + _swigc__p_coords_qelem_t, + _swigc__p_coords_t, + _swigc__p_f_p_q_const__char_v_______int, + _swigc__p_f_q_const__int_v_______int, + _swigc__p_fcoords_t, + _swigc__p_float, + _swigc__p_int, + _swigc__p_p_unsigned_char, + _swigc__p_p_unsigned_short, + _swigc__p_unsigned_char, + _swigc__p_unsigned_int, + _swigc__p_unsigned_short, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned statically to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); + + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString("<Swig global variables>"); +#else + return PyString_FromString("<Swig global variables>"); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; + if (PyType_Ready(&varlink_type) < 0) + return NULL; + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + memcpy(gv->name, name, size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *globals = 0; + if (!globals) { + globals = SWIG_newvarlink(); + } + return globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + memcpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + memcpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + + /* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md, *globals; + +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + SwigPyObject_own, + SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + PyTypeObject *swigpyobject; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + PyObject *self = 0; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + (void)self; + + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); + assert(metatype); +#endif + + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule(SWIG_name, SwigMethods); +#endif + + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + swigpyobject = SwigPyObject_TypeOnce(); + + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + + SWIG_Python_SetConstant(d, "sizeof_uchar",SWIG_From_size_t((size_t)(sizeof(unsigned char)))); + SWIG_Python_SetConstant(d, "sizeof_ushort",SWIG_From_size_t((size_t)(sizeof(unsigned short)))); + SWIG_Python_SetConstant(d, "P3D_FALSE",SWIG_From_int((int)(-1))); + SWIG_Python_SetConstant(d, "P3D_TRUE",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, "P3D_ERROR",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, "P3D_IO_ERROR",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, "P3D_SUCCESS",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, "BACKGROUND",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, "CONN6",SWIG_From_int((int)(711))); + SWIG_Python_SetConstant(d, "CONN18",SWIG_From_int((int)(712))); + SWIG_Python_SetConstant(d, "CONN26",SWIG_From_int((int)(713))); +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/pypore3d/pypore3d/p3dSITKPy.py b/pypore3d/pypore3d/p3dSITKPy.py new file mode 100644 index 0000000000000000000000000000000000000000..d55959bb4d5063db1dca2f88dcd8c10f6a959c14 --- /dev/null +++ b/pypore3d/pypore3d/p3dSITKPy.py @@ -0,0 +1,565 @@ +import argparse +import SimpleITK as sitk +import os +import tempfile + + +import pypore3d.p3d_SITK_common_lib +from pypore3d.p3d_SITK_common_lib import * + +import pypore3d.p3d_SITK_read_raw +from pypore3d.p3d_SITK_read_raw import * + +import pypore3d.p3dFiltPy +from pypore3d.p3dFiltPy import py_p3dReadRaw8,py_p3dWriteRaw8 + + +########################################## Filters ########################################## +###### median filter +def py_p3d_SITK_Median(img, dimx,dimy,dimz, kWidth = 1): + img = p3d_to_sitk_file_format(img, dimx,dimy,dimz) + median_filter = sitk.MedianImageFilter() + median_filter.SetRadius(kWidth) + outImg = median_filter.Execute(img) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + + +###### Binary Dilation +def py_p3d_Dilate(input_image, dimx, dimy, dimz = 0, kWidth = 3): + """ + + Dilation is one of the two basic operators in the area of mathematical morphology. The basic effect of the operator on a binary image is to gradually enlarge the boundaries of regions of foreground voxels. Thus areas of foreground voxels grow in size while holes within those regions become smaller. + + Syntax: + ------ + Result = py_p3d_sitk_Dilate ( input_image, dimx, dimy [, dimz=0] [, kWidth =value ]) + + Return Value: + ------------ + Returns a dilated image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + kWidth: An odd integer value in the range [3, 51] (default: 3) representing the diameter of the spherical (or circular in case of 2D input) structuring element. + + Remarks: + ------- + Often a 3x3x3 structuring element (or a 3x3 for 2D images) is used, although larger kernels (e.g. a 5x5x5 element) can be used for more severe dilation. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + dilation_filter = sitk.BinaryDilateImageFilter() + dilation_filter.SetKernelRadius(kWidth) + dilation_filter.SetForegroundValue (255) + + outImg = dilation_filter.Execute(outImg) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### Binary Erosion +def py_p3d_Erode(input_image, dimx, dimy, dimz = 0, kWidth = 3): + """ + + Erosion is one of the two basic operators in the area of mathematical morphology. The basic effect of the operator on a binary image is to erode away the boundaries of regions of foreground voxels. Thus areas of foreground voxels shrink in size, and holes within those areas become larger. + + Syntax: + ------ + Result = py_p3d_sitk_Erode ( input_image, dimx, dimy[, dimz = 0 ] [, kWidth =value ]) + + Return Value: + ------------ + Returns a dilated image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the binary input image to filter. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + kWidth: An odd integer value in the range [3, 51] (default: 3) representing the diameter of the spherical (or circular in case of 2D input) structuring element. + + Remarks: + ------- + Often a 3x3x3 structuring element (or a 3x3 for 2D images) is used, although larger kernels (e.g. a 5x5x5 element) can be used for more severe erosion. Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx, dimy, dimz ) + erosion_filter = sitk.BinaryErodeImageFilter() + erosion_filter.SetKernelRadius(kWidth) + erosion_filter.SetForegroundValue (255) + + outImg = erosion_filter.Execute(outImg) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### HMinimaImageFilter +def py_p3d_HMinimaFilter(input_image, dimx, dimy, dimz = 0, height = 3): + """ + + Perform H-minima transform of input image, i.e. all minima in input image whose depth is less than the specified threshold are suppressed [1]. + + H-minima transformation is a mere application of the concept of morphological reconstruction [2]. By performing the morphological reconstruction using the input image as the mask image and the result of subtraction of the threshold value from the input image as the marker image the H-maxima transform is performed. The H-minima transformed image can be simply obtained by complementing both input and output image of the process. + + Syntax: + ------ + Result = py_p3d_HMinimaFilter ( input_image, dimx, dimy[, dimz = 0 ] [, threshold =value ]) + + Return Value: + ------------ + Returns the H-minima transformed image with the same dimensions and type of input image. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + height: Set the height that a local maximum must be above the local background (local contrast) in order to survive the processing. Local maxima below this value are replaced with an estimate of the local background. Default = 3 + + References + ---------- + + [1] P. Soille, Morphological Image Analysis: Principles and Applications, Springer-Verlag, 1999, pp. 170-171. + + [2] L. Vincent, Morphological Grayscale Reconstruction in Image Analysis: Applications and Efficient Algorithms, IEEE Transactions on Image Processing, Vol. 2, No. 2, pp. 176-201, 1993. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.HMinimaImageFilter() + Filter.SetHeight(threshold) + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### Mutli Thresholding +def py_p3d_MultiThresholding(input_image, dimx, dimy, dimz = 0, regionsNum = 2): + """ + + Performs multithresholding, + + Syntax: + ------ + Result = py_p3d_MultiThresholding ( input_image, dimx, dimy[, dimz = 0 ] [, regionsNum =value ]) + + Return Value: + ------------ + Returns segmented image with the same dimensions and type of input image. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + regionsNum: A number representing segments number. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + thresholdFilter = sitk.OtsuMultipleThresholdsImageFilter() + thresholdFilter.SetNumberOfThresholds(regionsNum) + outImg = thresholdFilter.Execute(outImg) + + rescaler = sitk.RescaleIntensityImageFilter() + rescaler.SetOutputMinimum(0) + rescaler.SetOutputMaximum(255) + + outImg = rescaler.Execute(outImg) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### GradientMagnitudeImageFilter +def py_p3d_GradientMagnitudeImageFilter(input_image, dimx, dimy, dimz = 0): + """ + + Performs GradientMagnitudeImageFilter, + + Syntax: + ------ + Result = py_p3d_GradientMagnitudeImageFilter ( input_image, dimx, dimy[, dimz = 0 ] ) + + Return Value: + ------------ + Returns filtered image with the same dimensions and type of input image. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.GradientMagnitudeImageFilter() + #Filter.SetUseImageSpacing (False) + + outImg = Filter.Execute(outImg) + #outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + + return outImg + + +###### CurvatureFlowImageFilter +def py_p3d_CurvatureFlowImageFilter(input_image, dimx, dimy, dimz = 0, time_step = 3.0, iterations= 3): + """ + + The sitk::CurvatureFlowImageFilter performs edge-preserving smoothing in a similar fashion to the classical anisotropic diffusion. + + The filter uses a level set formulation where the iso-intensity contours in a image are viewed as level sets, where pixels of a particular intensity form one level set. The level set function is then evolved under the control of a diffusion equation where the speed is proportional to the curvature of the contour. Areas of high curvature will diffuse faster than areas of low curvature. Hence, small jagged noise artifacts will disappear quickly, while large scale interfaces will be slow to evolve, thereby preserving sharp boundaries between objects. However, it should be noted that although the evolution at the boundary is slow, some diffusion still occur. + + Syntax: + ------ + Result = py_p3d_CurvatureFlowImageFilter ( input_image, dimx, dimy[, dimz = 0 ] [, iterations =value ]) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + iterations: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the domain gaussian. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.CurvatureFlowImageFilter() + Filter.SetNumberOfIterations(iterations) + Filter.SetTimeStep (time_step) + + outImg = Filter.Execute(outImg) + #outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + + +###### IsolatedConnectedImageFilter +def py_p3d_IsolatedConnectedImageFilter (input_image, dimx, dimy, dimz = 0): + """ + + Pore3D python wrapper for sitk.IsolatedConnectedImageFilter() + Details: https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1IsolatedConnectedImageFilter.html#details + + Syntax: + ------ + Result = py_p3d_IsolatedConnectedImageFilter ( input_image, dimx, dimy[ , dimz ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + """ + input_image = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.IsolatedConnectedImageFilter() + + #Filter = sitk.SetFindUpperThreshold (True) + #Filter = sitk.SetIsolatedValueTolerance (double IsolatedValueTolerance) + #Filter = sitk.SetLower (double Lower) + #Filter = sitk.SetReplaceValue (100) + #Filter = sitk.SetSeed1 (std::vector< unsigned int > Seed1) + #Filter = sitk.SetSeed2 (std::vector< unsigned int > Seed2) + #Filter = sitk.SetUpper (double Upper) + + outImg = Filter.Execute(input_image) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### NeighborhoodConnectedImageFilter +def py_p3d_NeighborhoodConnectedImageFilter(input_image, dimx, dimy, dimz = 0): + """ + + Pore3D python wrapper for sitk.NeighborhoodConnectedImageFilter() + + Syntax: + ------ + Result = py_p3d_NeighborhoodConnectedImageFilter ( input_image, dimx, dimy[ , dimz ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.NeighborhoodConnectedImageFilter() + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### ConnectedThresholdImageFilter +def py_p3d_ConnectedThresholdImageFilter(input_image, dimx, dimy, dimz = 0): + """ + + Pore3D python wrapper for sitk.ConnectedThresholdImageFilter() + + Syntax: + ------ + Result = py_p3d_ConnectedThresholdImageFilter ( input_image, dimx, dimy[ , dimz ] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.ConnectedThresholdImageFilter() + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +###### sitk_WatershedSegmentation_8 +def py_p3d_WatershedSegmentation(input_image, dimx, dimy, dimz = 0, level = 0, markWatershedLine = False, connected = False): + """ + + Pore3D python wrapper for sitk.MorphologicalWatershedImageFilter() + + Syntax: + ------ + Result = py_p3d_WatershedSegmentation ( input_image, dimx, dimy[ , dimz ] [, level = value] [, markWatershedLine = bool] [, connected = bool]) + + Return Value: + ------------ + Returns a segmented image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: AA 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + level: + + markWatershedLine: + + connected: + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.MorphologicalWatershedImageFilter() + Filter.SetFullyConnected(connected) + Filter.SetLevel(level) + Filter.SetMarkWatershedLine(markWatershedLine) + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + + +###### k means +def py_p3d_KMeansClustering(input_image, dimx, dimy, dimz = 0, segment_num = 1): + """ + + Performs K-means clustering multiphase segmentation. + + Classification includes a broad range of decision-theoretic approaches to the identification of images (or parts thereof). All classification algorithms are based on the assumption that the image in question depicts one or more features and that each of these features belongs to one of several distinct and exclusive classes. The classes may be specified a priori by the user (as in supervised classification) or automatically clustered (as in unsupervised classification) into sets of prototype classes, where the user merely specifies the number of desired categories. Within image processing context, classification should be thought as a multiphase segmentation process: in fact the classes are then used for generating a labeled image in which every voxel is assigned to one of the classes. + + The K-means algorithm converts an input image into vectors of equal size and then determines the k prototype mean vectors by minimizing of the sum of the squared distances from all points in a class to the class center. + + Syntax: + ------ + Result = py_p3d_KMeansClustering ( input_image, dimx, dimy[ , dimz ]) + + Return Value: + ------------ + Returns a segmented image of type BYTE with the same dimensions of input image. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + segment_num: number of segments + + """ + Img = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + #Img = Read_Raw8(file_name, [dimx,dimy,dimz]) + + #Filter1 = sitk.RelabelComponentImageFilter() + #Img = Filter1.Execute(Img) + + Filter = sitk.ScalarImageKmeansImageFilter() + Filter. SetUseNonContiguousLabels (True) + + if segment_num <=0: + print ("Error: segment_num must be greater than 0") + return + + shift_val = 250.0/segment_num + mean_val = 0.0 + initial_mean_vec = [] + for i in range(segment_num): + initial_mean_vec.append(mean_val) + mean_val = mean_val+shift_val + for i in range(segment_num): + print (initial_mean_vec[i]) + #initial_mean_vec = [0.0,50.0,100.0,150.0,200.0,250.0] + Filter.SetClassWithInitialMean(initial_mean_vec) + + outImg = Filter.Execute(Img) + + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + + +###### CurvatureAnisotropicDiffusionImageFilter (16 bit only) +def py_p3d_CurvatureAnisotropicDiffusionImageFilter(input_image, dimx, dimy, dimz = 0, conductance=7.0, iterations=1): + """ + + Performs anisotropic diffusion on an image using a modified curvature diffusion equation (MCDE). + + Qualitatively, MCDE compares well with other non-linear diffusion techniques. It is less sensitive to contrast than classic anisotropic diffusion and preserves finer detailed structures in images. Each iteration of the filter requires more computational time than the classic anisotropic diffusion, however. fewer iterations may be required to reach an acceptable solution. + + Syntax: + ------ + Result = py_p3d_CurvatureAnisotropicDiffusionImageFilter ( input_image, dimx, dimy[ , dimz ] [, conductance = value ] [, iterations = value ]) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + conductance: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the domain gaussian. + + iterations: An integer value greater than 0 (default: 3.0) representing the the diffusion time, i.e. the number of times the algorithm is iterated. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + #feature_img = sitk.GradientMagnitude(img) + Filter = sitk.CurvatureAnisotropicDiffusionImageFilter() + Filter.SetNumberOfIterations(iterations) + Filter.SetConductanceParameter (conductance) + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + + return outImg + +###### GradientAnisotropicDiffusionImageFilter(16 bit only) +def py_p3d_GradientAnisotropicDiffusionImageFilter(input_image, dimx, dimy, dimz = 0, conductance = 7.0, iterations = 1): + """ + + Pore3D python wrapper for sitk.GradientAnisotropicDiffusionImageFilter + + Syntax: + ------ + Result = py_p3d_GradientAnisotropicDiffusionImageFilter ( input_image, dimx, dimy[ , dimz ] [, conductance = value ] [, iterations = value] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + conductance: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the domain gaussian. + + iterations: An integer value greater than 0 (default: 3.0) representing the the diffusion time, i.e. the number of times the algorithm is iterated. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.GradientAnisotropicDiffusionImageFilter() + Filter.SetNumberOfIterations(iterations) + Filter.SetConductanceParameter (conductance) + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + + +###### MinMaxCurvatureFlowImageFilter (16 bit only) +def py_p3d_MinMaxCurvatureFlowImageFilter(input_image, dimx, dimy, dimz = 0, iterations = 3, width = 3): + """ + + The sitk::CurvatureFlowImageFilter performs edge-preserving smoothing applying a variant of the curvature flow algorithm where diffusion is turned on or off depending on the scale of the noise. + + The minimum-maximum variant of the curvature flow filter results in sharper edges than the application with the simple curvature flow with similar parametrization. + + Syntax: + ------ + Result = py_p3d_MinMaxCurvatureFlowImageFilter ( input_image, dimx, dimy[ , dimz ] [, iterations = value ] [, width = value] ) + + Return Value: + ------------ + Returns a filtered image with the same dimensions and type of input imaged. + + Arguments: + --------- + input_image: A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + iterations: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the domain gaussian. + + width: A decimal value greater than 0 (default: 3.0) representing the standard deviation of the domain gaussian. + + """ + outImg = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) + Filter = sitk.MinMaxCurvatureFlowImageFilter() + Filter.SetNumberOfIterations(iterations) + Filter.SetStencilRadius(width) + + outImg = Filter.Execute(outImg) + outImg = apply_rescaler(outImg, dimx,dimy,dimz) + outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + return outImg + +##### MinMaxCurvatureFlowImageFilter (16 bit only) +#def py_p3d_MinMaxCurvatureFlowImageFilter_16(input_image, dimx,dimy,dimz = 0, ITERATIONS=3, WIDTH = 3): +# +# input_image = p3d_to_sitk_file_format(input_image, dimx,dimy,dimz) +# Filter = sitk.MinMaxCurvatureFlowImageFilter() +# Filter.SetNumberOfIterations(ITERATIONS) +# Filter.SetStencilRadius(WIDTH) +# +# outImg = Filter.Execute(input_image) +# outImg = apply_rescaler(outImg, dimx,dimy,dimz) +# outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) +# return outImg + + + +#FUNCTION P3DCONFIDENCEREGIONGROWING 1 1 KEYWORD#S \ No newline at end of file diff --git a/pypore3d/pypore3d/p3dSITKPy_16.py b/pypore3d/pypore3d/p3dSITKPy_16.py new file mode 100644 index 0000000000000000000000000000000000000000..4d9de27860abf73138fa65959f24eafbed68db2e --- /dev/null +++ b/pypore3d/pypore3d/p3dSITKPy_16.py @@ -0,0 +1,117 @@ +import argparse +import SimpleITK as sitk +import os +import tempfile + + +import pypore3d.p3d_SITK_common_lib +from pypore3d.p3d_SITK_common_lib import * +from pypore3d.p3d_SITK_common_lib_16 import * + + +import pypore3d.p3d_SITK_read_raw +from pypore3d.p3d_SITK_read_raw import * + +import pypore3d.p3dFiltPy +from pypore3d.p3dFiltPy import py_p3dReadRaw8,py_p3dWriteRaw8 + +import pypore3d.p3dFiltPy_16 +from pypore3d.p3dFiltPy_16 import py_p3dReadRaw16,py_p3dWriteRaw16 + + +########################################## Filters ########################################## + + +def py_p3d_SITK_Median_16(img, dimx,dimy,dimz, kWidth = 1): + """ + """ + median_filter = sitk.MedianImageFilter() + median_filter.SetRadius(kWidth) + outImg = median_filter.Execute(img) + return outImg + + + + +###### sitk_WatershedSegmentation +###### sitk_WatershedSegmentation_16 +def py_p3d_WatershedSegmentation(dist_file_path, watershed_image_path, dimx, dimy, dimz = 0, level = 0, markWatershedLine = True, connected = False): + """ + Syntax: + ------ + Result = py_p3d_WatershedSegmentation ( dist_file_path, watershed_image_path, dimx, dimy [, dimz = value] [, level = value] [, markWatershedLine = value] [, connected = value]) + + Return Value: + ------------ + Returns the H-py_p3d_WatershedSegmentation transformed image with the same dimensions and type of input image. + + Arguments: + --------- + dist_file_path: File path storing A 2D or 3D matrix representing the input image. Usually it is a distance field image + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + markWatershedLine: Default = True + + connected: Default = True + + watershed_image_path: the path where the output image is written + """ + dist_img = Read_Raw16(dist_file_path, [dimx,dimy,dimz]) + + Filter = sitk.MorphologicalWatershedImageFilter() + Filter.SetFullyConnected(connected) + Filter.SetLevel(level) + Filter.SetMarkWatershedLine(markWatershedLine) + WS_Img = Filter.Execute(dist_img) + + out_file = watershed_image_path + '.mhd' + sitk.WriteImage(WS_Img,out_file) + return WS_Img + + +###### HMinimaImageFilter +def py_p3d_HMinimaFilter(input_file_path, output_image_path, dimx, dimy, dimz = 0, threshold = 3): + """ + + Perform H-minima transform of input image, i.e. all minima in input image whose depth is less than the specified threshold are suppressed [1]. + + H-minima transformation is a mere application of the concept of morphological reconstruction [2]. By performing the morphological reconstruction using the input image as the mask image and the result of subtraction of the threshold value from the input image as the marker image the H-maxima transform is performed. The H-minima transformed image can be simply obtained by complementing both input and output image of the process. + + Syntax: + ------ + Result = py_p3d_HMinimaFilter ( input_image, dimx, dimy[, dimz = 0 ] [, threshold =value ]) + + Return Value: + ------------ + Returns the H-minima transformed image with the same dimensions and type of input image. + + Arguments: + --------- + input_file_path: File path storing A 2D or 3D matrix of type BYTE representing the input image. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + threshold: Set the height that a local maximum must be above the local background (local contrast) in order to survive the processing. Local maxima below this value are replaced with an estimate of the local background. Default = 3 + + output_image_path: the path where the output image is written + + References + ---------- + + [1] P. Soille, Morphological Image Analysis: Principles and Applications, Springer-Verlag, 1999, pp. 170-171. + + [2] L. Vincent, Morphological Grayscale Reconstruction in Image Analysis: Applications and Efficient Algorithms, IEEE Transactions on Image Processing, Vol. 2, No. 2, pp. 176-201, 1993. + + """ + input_img = Read_Raw16(input_file_path, [dimx,dimy,dimz]) + Filter = sitk.HMinimaImageFilter() + Filter.SetHeight(threshold) + + outImg = Filter.Execute(input_img) + #outImg = apply_rescaler(outImg, dimx,dimy,dimz) + #outImg = sitk_to_p3d_file_format (outImg, dimx,dimy,dimz) + out_file = output_image_path + '.mhd' + sitk.WriteImage(outImg,out_file) + return outImg + diff --git a/pypore3d/pypore3d/p3dSkel.i b/pypore3d/pypore3d/p3dSkel.i new file mode 100644 index 0000000000000000000000000000000000000000..b448624e23075cb4ec7deca42715ffdf1214f144 --- /dev/null +++ b/pypore3d/pypore3d/p3dSkel.i @@ -0,0 +1,123 @@ +/* File: p3dMedianFilter.i */ +%module p3dSkel + +%include typemaps.i + +%{ + #define SWIG_FILE_WITH_INIT + +#include "P3D_Skel/p3dSkel.h" +#include "P3D_Skel/p3dTime.h" +#include "P3D_Skel/Common/p3dBoundingBoxT.h" +#include "P3D_Skel/Common/p3dConnectedComponentsLabeling.h" +#include "P3D_Skel/Common/p3dCoordsList.h" +#include "P3D_Skel/Common/p3dCoordsQueue.h" +#include "P3D_Skel/Common/p3dCoordsT.h" +#include "P3D_Skel/Common/p3dFCoordsList.h" +#include "P3D_Skel/Common/p3dSquaredEuclideanDT.h" +#include "P3D_Skel/Common/p3dThinning.h" +#include "P3D_Skel/Common/p3dUIntList.h" +#include "P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.h" +#include "P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.h" +#include "P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.h" +#include "P3D_Skel/GVFSkeletonization/p3dCriticalPoints.h" +#include "P3D_Skel/GVFSkeletonization/p3dCritPointList.h" +#include "P3D_Skel/GVFSkeletonization/p3dCritPointT.h" +#include "P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.h" +#include "P3D_Skel/GVFSkeletonization/p3dGVF.h" +#include "P3D_Skel/GVFSkeletonization/p3dHighDivPointList.h" +#include "P3D_Skel/GVFSkeletonization/p3dHighDivPointT.h" + + +%} + +%include <cmalloc.i> +%include <cdata.i> + +%allocators(unsigned char, uchar) +%allocators(unsigned short, ushort) +%allocators(struct SkeletonStats, PSkeletonStats) + +%inline %{ + + #include <float.h> + void PrintSkelStruct(struct SkeletonStats* out_stats, char* filename) + { + // creating file pointer to work with files + FILE *fptr; + + // opening file in writing mode + fptr = fopen(filename, "w"); + + // exiting program + if (fptr == NULL) { + printf("Error!"); + exit(1); + } + + int Digs = FLT_DECIMAL_DIG; + + fprintf(fptr, "End_Width\n"); + for (int i = 0; i<out_stats->End_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e\n", Digs, out_stats->End_Width[i]); + } + + + fprintf(fptr, "EndToEnd_Length,EndToEnd_MaxWidth,EndToEnd_MeanWidth,EndToEnd_MinWidth\n"); + for (int i = 0; i<out_stats->EndToEnd_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e,", Digs, out_stats->EndToEnd_Length[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->EndToEnd_MaxWidth[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->EndToEnd_MeanWidth[i]); + fprintf(fptr, "%.*e\n", Digs, out_stats->EndToEnd_MinWidth[i]); + } + + fprintf(fptr, "NodeToNode_Length,NodeToNode_MaxWidth,NodeToNode_MeanWidth,NodeToNode_MinWidth\n"); + for (int i = 0; i<out_stats->NodeToNode_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e,", Digs, out_stats->NodeToNode_Length[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->NodeToNode_MaxWidth[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->NodeToNode_MeanWidth[i]); + fprintf(fptr, "%.*e\n", Digs, out_stats->NodeToNode_MinWidth[i]); + } + + + fprintf(fptr, "Node_Width\n"); + for (int i = 0; i<out_stats->Node_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e\n", Digs, out_stats->Node_Width[i]); + } + + + fclose(fptr); + } +%} + + + +%include "P3D_Skel/p3dSkel.h" +%include "P3D_Skel/p3dTime.h" +%include "P3D_Skel/Common/p3dBoundingBoxT.h" +%include "P3D_Skel/Common/p3dConnectedComponentsLabeling.h" +%include "P3D_Skel/Common/p3dCoordsList.h" +%include "P3D_Skel/Common/p3dCoordsQueue.h" +%include "P3D_Skel/Common/p3dCoordsT.h" +%include "P3D_Skel/Common/p3dFCoordsList.h" +%include "P3D_Skel/Common/p3dSquaredEuclideanDT.h" +%include "P3D_Skel/Common/p3dThinning.h" +%include "P3D_Skel/Common/p3dUIntList.h" +%include "P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.h" +%include "P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.h" +%include "P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.h" +%include "P3D_Skel/GVFSkeletonization/p3dCriticalPoints.h" +%include "P3D_Skel/GVFSkeletonization/p3dCritPointList.h" +%include "P3D_Skel/GVFSkeletonization/p3dCritPointT.h" +%include "P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.h" +%include "P3D_Skel/GVFSkeletonization/p3dGVF.h" +%include "P3D_Skel/GVFSkeletonization/p3dHighDivPointList.h" +%include "P3D_Skel/GVFSkeletonization/p3dHighDivPointT.h" diff --git a/pypore3d/pypore3d/p3dSkel.py b/pypore3d/pypore3d/p3dSkel.py new file mode 100644 index 0000000000000000000000000000000000000000..b2ebeac0f04ca0b7bab9ebb1a06f5fb1114223ba --- /dev/null +++ b/pypore3d/pypore3d/p3dSkel.py @@ -0,0 +1,490 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 4.0.1 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +from sys import version_info as _swig_python_version_info +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") + +# Import the low-level C/C++ module +if __package__ or "." in __name__: + from . import _p3dSkel +else: + import _p3dSkel + +try: + import builtins as __builtin__ +except ImportError: + import __builtin__ + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) + else: + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr + + +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr + + +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper + + +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + + + +def cdata(ptr, nelements=1): + return _p3dSkel.cdata(ptr, nelements) + +def memmove(data, indata): + return _p3dSkel.memmove(data, indata) + +def malloc_uchar(*args): + return _p3dSkel.malloc_uchar(*args) + +def calloc_uchar(*args): + return _p3dSkel.calloc_uchar(*args) + +def realloc_uchar(ptr, nitems): + return _p3dSkel.realloc_uchar(ptr, nitems) + +def free_uchar(ptr): + return _p3dSkel.free_uchar(ptr) +sizeof_uchar = _p3dSkel.sizeof_uchar + +def malloc_ushort(*args): + return _p3dSkel.malloc_ushort(*args) + +def calloc_ushort(*args): + return _p3dSkel.calloc_ushort(*args) + +def realloc_ushort(ptr, nitems): + return _p3dSkel.realloc_ushort(ptr, nitems) + +def free_ushort(ptr): + return _p3dSkel.free_ushort(ptr) +sizeof_ushort = _p3dSkel.sizeof_ushort + +def malloc_PSkeletonStats(*args): + return _p3dSkel.malloc_PSkeletonStats(*args) + +def calloc_PSkeletonStats(*args): + return _p3dSkel.calloc_PSkeletonStats(*args) + +def realloc_PSkeletonStats(ptr, nitems): + return _p3dSkel.realloc_PSkeletonStats(ptr, nitems) + +def free_PSkeletonStats(ptr): + return _p3dSkel.free_PSkeletonStats(ptr) +sizeof_PSkeletonStats = _p3dSkel.sizeof_PSkeletonStats + +def PrintSkelStruct(out_stats, filename): + return _p3dSkel.PrintSkelStruct(out_stats, filename) +P3D_FALSE = _p3dSkel.P3D_FALSE +P3D_TRUE = _p3dSkel.P3D_TRUE +P3D_ERROR = _p3dSkel.P3D_ERROR +P3D_SUCCESS = _p3dSkel.P3D_SUCCESS +BACKGROUND = _p3dSkel.BACKGROUND +NODE_LABEL = _p3dSkel.NODE_LABEL +END_LABEL = _p3dSkel.END_LABEL +ISOLATED_LABEL = _p3dSkel.ISOLATED_LABEL +NODETONODE_LABEL = _p3dSkel.NODETONODE_LABEL +NODETOEND_LABEL = _p3dSkel.NODETOEND_LABEL +ENDTOEND_LABEL = _p3dSkel.ENDTOEND_LABEL +class SkeletonStats(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + ConnectivityDensity = property(_p3dSkel.SkeletonStats_ConnectivityDensity_get, _p3dSkel.SkeletonStats_ConnectivityDensity_set) + CoordinationNumber = property(_p3dSkel.SkeletonStats_CoordinationNumber_get, _p3dSkel.SkeletonStats_CoordinationNumber_set) + End_Counter = property(_p3dSkel.SkeletonStats_End_Counter_get, _p3dSkel.SkeletonStats_End_Counter_set) + End_Width = property(_p3dSkel.SkeletonStats_End_Width_get, _p3dSkel.SkeletonStats_End_Width_set) + EndToEnd_Counter = property(_p3dSkel.SkeletonStats_EndToEnd_Counter_get, _p3dSkel.SkeletonStats_EndToEnd_Counter_set) + EndToEnd_Length = property(_p3dSkel.SkeletonStats_EndToEnd_Length_get, _p3dSkel.SkeletonStats_EndToEnd_Length_set) + EndToEnd_MaxWidth = property(_p3dSkel.SkeletonStats_EndToEnd_MaxWidth_get, _p3dSkel.SkeletonStats_EndToEnd_MaxWidth_set) + EndToEnd_MeanWidth = property(_p3dSkel.SkeletonStats_EndToEnd_MeanWidth_get, _p3dSkel.SkeletonStats_EndToEnd_MeanWidth_set) + EndToEnd_MinWidth = property(_p3dSkel.SkeletonStats_EndToEnd_MinWidth_get, _p3dSkel.SkeletonStats_EndToEnd_MinWidth_set) + NodeToEnd_Counter = property(_p3dSkel.SkeletonStats_NodeToEnd_Counter_get, _p3dSkel.SkeletonStats_NodeToEnd_Counter_set) + NodeToEnd_Length = property(_p3dSkel.SkeletonStats_NodeToEnd_Length_get, _p3dSkel.SkeletonStats_NodeToEnd_Length_set) + NodeToEnd_MaxWidth = property(_p3dSkel.SkeletonStats_NodeToEnd_MaxWidth_get, _p3dSkel.SkeletonStats_NodeToEnd_MaxWidth_set) + NodeToEnd_MeanWidth = property(_p3dSkel.SkeletonStats_NodeToEnd_MeanWidth_get, _p3dSkel.SkeletonStats_NodeToEnd_MeanWidth_set) + NodeToEnd_MinWidth = property(_p3dSkel.SkeletonStats_NodeToEnd_MinWidth_get, _p3dSkel.SkeletonStats_NodeToEnd_MinWidth_set) + NodeToNode_Counter = property(_p3dSkel.SkeletonStats_NodeToNode_Counter_get, _p3dSkel.SkeletonStats_NodeToNode_Counter_set) + NodeToNode_Length = property(_p3dSkel.SkeletonStats_NodeToNode_Length_get, _p3dSkel.SkeletonStats_NodeToNode_Length_set) + NodeToNode_MaxWidth = property(_p3dSkel.SkeletonStats_NodeToNode_MaxWidth_get, _p3dSkel.SkeletonStats_NodeToNode_MaxWidth_set) + NodeToNode_MeanWidth = property(_p3dSkel.SkeletonStats_NodeToNode_MeanWidth_get, _p3dSkel.SkeletonStats_NodeToNode_MeanWidth_set) + NodeToNode_MinWidth = property(_p3dSkel.SkeletonStats_NodeToNode_MinWidth_get, _p3dSkel.SkeletonStats_NodeToNode_MinWidth_set) + Node_Counter = property(_p3dSkel.SkeletonStats_Node_Counter_get, _p3dSkel.SkeletonStats_Node_Counter_set) + Node_Width = property(_p3dSkel.SkeletonStats_Node_Width_get, _p3dSkel.SkeletonStats_Node_Width_set) + + def __init__(self): + _p3dSkel.SkeletonStats_swiginit(self, _p3dSkel.new_SkeletonStats()) + __swig_destroy__ = _p3dSkel.delete_SkeletonStats + +# Register SkeletonStats in _p3dSkel: +_p3dSkel.SkeletonStats_swigregister(SkeletonStats) + + +def p3dGVFSkeletonization(in_im, skl_im, dimx, dimy, dimz, mu, eps, thresh, scale, wr_log): + return _p3dSkel.p3dGVFSkeletonization(in_im, skl_im, dimx, dimy, dimz, mu, eps, thresh, scale, wr_log) + +def p3dThinningSkeletonization(in_im, out_im, dimx, dimy, dimz, wr_log): + return _p3dSkel.p3dThinningSkeletonization(in_im, out_im, dimx, dimy, dimz, wr_log) + +def p3dLKCSkeletonization(in_im, out_im, dimx, dimy, dimz, wr_log): + return _p3dSkel.p3dLKCSkeletonization(in_im, out_im, dimx, dimy, dimz, wr_log) + +def p3dSimpleSkeletonPruning(in_im, out_im, dimx, dimy, dimz, thresh, wr_log): + return _p3dSkel.p3dSimpleSkeletonPruning(in_im, out_im, dimx, dimy, dimz, thresh, wr_log) + +def p3dIterativeSkeletonPruning(in_im, out_im, dimx, dimy, dimz, thresh, wr_log): + return _p3dSkel.p3dIterativeSkeletonPruning(in_im, out_im, dimx, dimy, dimz, thresh, wr_log) + +def p3dUltimateSkeletonPruning(in_im, out_im, dimx, dimy, dimz, iterative, wr_log): + return _p3dSkel.p3dUltimateSkeletonPruning(in_im, out_im, dimx, dimy, dimz, iterative, wr_log) + +def p3dSkeletonLabeling(in_im, out_im, dimx, dimy, dimz, wr_log): + return _p3dSkel.p3dSkeletonLabeling(in_im, out_im, dimx, dimy, dimz, wr_log) + +def p3dSkeletonAnalysis(vol_im, skl_im, out_stats, nodes_im, pores_im, ends_im, throats_im, dimx, dimy, dimz, merging_factor, tortuosity_depth, voxelsize, wr_log): + return _p3dSkel.p3dSkeletonAnalysis(vol_im, skl_im, out_stats, nodes_im, pores_im, ends_im, throats_im, dimx, dimy, dimz, merging_factor, tortuosity_depth, voxelsize, wr_log) + +def p3dSkeletonAnalysisFeasibility(in_im, sk_im, ratio, dimx, dimy, dimz, wr_log): + return _p3dSkel.p3dSkeletonAnalysisFeasibility(in_im, sk_im, ratio, dimx, dimy, dimz, wr_log) + +def p3dResetStartTime(): + return _p3dSkel.p3dResetStartTime() + +def p3dGetElapsedTime(): + return _p3dSkel.p3dGetElapsedTime() + +def p3dGetElapsedTime_min(): + return _p3dSkel.p3dGetElapsedTime_min() + +def p3dGetElapsedTime_sec(): + return _p3dSkel.p3dGetElapsedTime_sec() +class bb_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + min_x = property(_p3dSkel.bb_t_min_x_get, _p3dSkel.bb_t_min_x_set) + max_x = property(_p3dSkel.bb_t_max_x_get, _p3dSkel.bb_t_max_x_set) + min_y = property(_p3dSkel.bb_t_min_y_get, _p3dSkel.bb_t_min_y_set) + max_y = property(_p3dSkel.bb_t_max_y_get, _p3dSkel.bb_t_max_y_set) + min_z = property(_p3dSkel.bb_t_min_z_get, _p3dSkel.bb_t_min_z_set) + max_z = property(_p3dSkel.bb_t_max_z_get, _p3dSkel.bb_t_max_z_set) + + def __init__(self): + _p3dSkel.bb_t_swiginit(self, _p3dSkel.new_bb_t()) + __swig_destroy__ = _p3dSkel.delete_bb_t + +# Register bb_t in _p3dSkel: +_p3dSkel.bb_t_swigregister(bb_t) + + +def p3dConnectedComponentsLabeling(in_rev, out_rev, numOfConnectedComponents, volumes, boundingBoxes, dimx, dimy, dimz, conn, skip_borders): + return _p3dSkel.p3dConnectedComponentsLabeling(in_rev, out_rev, numOfConnectedComponents, volumes, boundingBoxes, dimx, dimy, dimz, conn, skip_borders) + +def p3dGetMaxVolumeRegion(in_rev, out_rev, dimx, dimy, dimz, conn): + return _p3dSkel.p3dGetMaxVolumeRegion(in_rev, out_rev, dimx, dimy, dimz, conn) +class coords_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dSkel.coords_lelem_t_elem_get, _p3dSkel.coords_lelem_t_elem_set) + next = property(_p3dSkel.coords_lelem_t_next_get, _p3dSkel.coords_lelem_t_next_set) + + def __init__(self): + _p3dSkel.coords_lelem_t_swiginit(self, _p3dSkel.new_coords_lelem_t()) + __swig_destroy__ = _p3dSkel.delete_coords_lelem_t + +# Register coords_lelem_t in _p3dSkel: +_p3dSkel.coords_lelem_t_swigregister(coords_lelem_t) + + +def coords_list_init(arg1): + return _p3dSkel.coords_list_init(arg1) + +def coords_list_push(arg1, arg2): + return _p3dSkel.coords_list_push(arg1, arg2) + +def coords_list_pop(arg1): + return _p3dSkel.coords_list_pop(arg1) + +def coords_list_isempty(arg1): + return _p3dSkel.coords_list_isempty(arg1) + +def coords_list_toarray(arg1, arg2): + return _p3dSkel.coords_list_toarray(arg1, arg2) +class coords_qelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + item = property(_p3dSkel.coords_qelem_t_item_get, _p3dSkel.coords_qelem_t_item_set) + next = property(_p3dSkel.coords_qelem_t_next_get, _p3dSkel.coords_qelem_t_next_set) + + def __init__(self): + _p3dSkel.coords_qelem_t_swiginit(self, _p3dSkel.new_coords_qelem_t()) + __swig_destroy__ = _p3dSkel.delete_coords_qelem_t + +# Register coords_qelem_t in _p3dSkel: +_p3dSkel.coords_qelem_t_swigregister(coords_qelem_t) + +class coords_queue_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + tail = property(_p3dSkel.coords_queue_t_tail_get, _p3dSkel.coords_queue_t_tail_set) + head = property(_p3dSkel.coords_queue_t_head_get, _p3dSkel.coords_queue_t_head_set) + + def __init__(self): + _p3dSkel.coords_queue_t_swiginit(self, _p3dSkel.new_coords_queue_t()) + __swig_destroy__ = _p3dSkel.delete_coords_queue_t + +# Register coords_queue_t in _p3dSkel: +_p3dSkel.coords_queue_t_swigregister(coords_queue_t) + + +def coords_queue_init(queue): + return _p3dSkel.coords_queue_init(queue) + +def coords_queue_push(queue, elem): + return _p3dSkel.coords_queue_push(queue, elem) + +def coords_queue_pop(queue): + return _p3dSkel.coords_queue_pop(queue) + +def coords_queue_isempty(queue): + return _p3dSkel.coords_queue_isempty(queue) +class coords_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dSkel.coords_t_x_get, _p3dSkel.coords_t_x_set) + y = property(_p3dSkel.coords_t_y_get, _p3dSkel.coords_t_y_set) + z = property(_p3dSkel.coords_t_z_get, _p3dSkel.coords_t_z_set) + + def __init__(self): + _p3dSkel.coords_t_swiginit(self, _p3dSkel.new_coords_t()) + __swig_destroy__ = _p3dSkel.delete_coords_t + +# Register coords_t in _p3dSkel: +_p3dSkel.coords_t_swigregister(coords_t) + +class fcoords_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dSkel.fcoords_t_x_get, _p3dSkel.fcoords_t_x_set) + y = property(_p3dSkel.fcoords_t_y_get, _p3dSkel.fcoords_t_y_set) + z = property(_p3dSkel.fcoords_t_z_get, _p3dSkel.fcoords_t_z_set) + + def __init__(self): + _p3dSkel.fcoords_t_swiginit(self, _p3dSkel.new_fcoords_t()) + __swig_destroy__ = _p3dSkel.delete_fcoords_t + +# Register fcoords_t in _p3dSkel: +_p3dSkel.fcoords_t_swigregister(fcoords_t) + +class fcoords_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dSkel.fcoords_lelem_t_elem_get, _p3dSkel.fcoords_lelem_t_elem_set) + next = property(_p3dSkel.fcoords_lelem_t_next_get, _p3dSkel.fcoords_lelem_t_next_set) + + def __init__(self): + _p3dSkel.fcoords_lelem_t_swiginit(self, _p3dSkel.new_fcoords_lelem_t()) + __swig_destroy__ = _p3dSkel.delete_fcoords_lelem_t + +# Register fcoords_lelem_t in _p3dSkel: +_p3dSkel.fcoords_lelem_t_swigregister(fcoords_lelem_t) + + +def fcoords_list_init(arg1): + return _p3dSkel.fcoords_list_init(arg1) + +def fcoords_list_push(arg1, arg2): + return _p3dSkel.fcoords_list_push(arg1, arg2) + +def fcoords_list_pop(arg1): + return _p3dSkel.fcoords_list_pop(arg1) + +def fcoords_list_isempty(arg1): + return _p3dSkel.fcoords_list_isempty(arg1) + +def fcoords_list_toarray(arg1, arg2): + return _p3dSkel.fcoords_list_toarray(arg1, arg2) + +def p3dSquaredEuclideanDT(in_im, out_im, dimx, dimy, dimz): + return _p3dSkel.p3dSquaredEuclideanDT(in_im, out_im, dimx, dimy, dimz) + +def p3dThinning(im, dimx, dimy, dimz): + return _p3dSkel.p3dThinning(im, dimx, dimy, dimz) +class uint_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + ct = property(_p3dSkel.uint_lelem_t_ct_get, _p3dSkel.uint_lelem_t_ct_set) + next = property(_p3dSkel.uint_lelem_t_next_get, _p3dSkel.uint_lelem_t_next_set) + + def __init__(self): + _p3dSkel.uint_lelem_t_swiginit(self, _p3dSkel.new_uint_lelem_t()) + __swig_destroy__ = _p3dSkel.delete_uint_lelem_t + +# Register uint_lelem_t in _p3dSkel: +_p3dSkel.uint_lelem_t_swigregister(uint_lelem_t) + + +def uint_list_init(list): + return _p3dSkel.uint_list_init(list) + +def uint_list_add(list, ct): + return _p3dSkel.uint_list_add(list, ct) + +def uint_list_isempty(list): + return _p3dSkel.uint_list_isempty(list) + +def uint_list_toarray(list, numel): + return _p3dSkel.uint_list_toarray(list, numel) + +def uint_list_clear(list): + return _p3dSkel.uint_list_clear(list) + +def p3dComputeCoreSkeleton(crit_point_list, skel_point_list, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, step, close): + return _p3dSkel.p3dComputeCoreSkeleton(crit_point_list, skel_point_list, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, step, close) + +def p3dComputeEigenVal(H, S, eigen_re, eigen_im, n): + return _p3dSkel.p3dComputeEigenVal(H, S, eigen_re, eigen_im, n) + +def p3dComputeHierarchicalSkeleton(highDiv_point_list, skel_point_list, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, step, close_dist): + return _p3dSkel.p3dComputeHierarchicalSkeleton(highDiv_point_list, skel_point_list, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, step, close_dist) + +def p3dGetCriticalPoints(in_im, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, crit_point_list): + return _p3dSkel.p3dGetCriticalPoints(in_im, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, crit_point_list) + +def p3dClassifyCriticalPoints(crit_point_list, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz): + return _p3dSkel.p3dClassifyCriticalPoints(crit_point_list, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz) +class crit_point_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dSkel.crit_point_lelem_t_elem_get, _p3dSkel.crit_point_lelem_t_elem_set) + next = property(_p3dSkel.crit_point_lelem_t_next_get, _p3dSkel.crit_point_lelem_t_next_set) + + def __init__(self): + _p3dSkel.crit_point_lelem_t_swiginit(self, _p3dSkel.new_crit_point_lelem_t()) + __swig_destroy__ = _p3dSkel.delete_crit_point_lelem_t + +# Register crit_point_lelem_t in _p3dSkel: +_p3dSkel.crit_point_lelem_t_swigregister(crit_point_lelem_t) + + +def crit_point_list_init(list): + return _p3dSkel.crit_point_list_init(list) + +def crit_point_list_push(list, item): + return _p3dSkel.crit_point_list_push(list, item) + +def crit_point_list_pop(list): + return _p3dSkel.crit_point_list_pop(list) + +def crit_point_list_isempty(list): + return _p3dSkel.crit_point_list_isempty(list) +class crit_point_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dSkel.crit_point_t_x_get, _p3dSkel.crit_point_t_x_set) + y = property(_p3dSkel.crit_point_t_y_get, _p3dSkel.crit_point_t_y_set) + z = property(_p3dSkel.crit_point_t_z_get, _p3dSkel.crit_point_t_z_set) + type = property(_p3dSkel.crit_point_t_type_get, _p3dSkel.crit_point_t_type_set) + eval0 = property(_p3dSkel.crit_point_t_eval0_get, _p3dSkel.crit_point_t_eval0_set) + eval1 = property(_p3dSkel.crit_point_t_eval1_get, _p3dSkel.crit_point_t_eval1_set) + eval2 = property(_p3dSkel.crit_point_t_eval2_get, _p3dSkel.crit_point_t_eval2_set) + evect0_x = property(_p3dSkel.crit_point_t_evect0_x_get, _p3dSkel.crit_point_t_evect0_x_set) + evect0_y = property(_p3dSkel.crit_point_t_evect0_y_get, _p3dSkel.crit_point_t_evect0_y_set) + evect0_z = property(_p3dSkel.crit_point_t_evect0_z_get, _p3dSkel.crit_point_t_evect0_z_set) + evect1_x = property(_p3dSkel.crit_point_t_evect1_x_get, _p3dSkel.crit_point_t_evect1_x_set) + evect1_y = property(_p3dSkel.crit_point_t_evect1_y_get, _p3dSkel.crit_point_t_evect1_y_set) + evect1_z = property(_p3dSkel.crit_point_t_evect1_z_get, _p3dSkel.crit_point_t_evect1_z_set) + evect2_x = property(_p3dSkel.crit_point_t_evect2_x_get, _p3dSkel.crit_point_t_evect2_x_set) + evect2_y = property(_p3dSkel.crit_point_t_evect2_y_get, _p3dSkel.crit_point_t_evect2_y_set) + evect2_z = property(_p3dSkel.crit_point_t_evect2_z_get, _p3dSkel.crit_point_t_evect2_z_set) + + def __init__(self): + _p3dSkel.crit_point_t_swiginit(self, _p3dSkel.new_crit_point_t()) + __swig_destroy__ = _p3dSkel.delete_crit_point_t + +# Register crit_point_t in _p3dSkel: +_p3dSkel.crit_point_t_swigregister(crit_point_t) + + +def p3dGetHighDivPoints(in_im, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, thresh, highDiv_point_list): + return _p3dSkel.p3dGetHighDivPoints(in_im, gvf_x, gvf_y, gvf_z, dimx, dimy, dimz, thresh, highDiv_point_list) + +def p3dGVF(in_im, out_x, out_y, out_z, dimx, dimy, dimz, mu, eps): + return _p3dSkel.p3dGVF(in_im, out_x, out_y, out_z, dimx, dimy, dimz, mu, eps) +class highDiv_point_lelem_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + elem = property(_p3dSkel.highDiv_point_lelem_t_elem_get, _p3dSkel.highDiv_point_lelem_t_elem_set) + next = property(_p3dSkel.highDiv_point_lelem_t_next_get, _p3dSkel.highDiv_point_lelem_t_next_set) + + def __init__(self): + _p3dSkel.highDiv_point_lelem_t_swiginit(self, _p3dSkel.new_highDiv_point_lelem_t()) + __swig_destroy__ = _p3dSkel.delete_highDiv_point_lelem_t + +# Register highDiv_point_lelem_t in _p3dSkel: +_p3dSkel.highDiv_point_lelem_t_swigregister(highDiv_point_lelem_t) + + +def highDiv_point_list_init(list): + return _p3dSkel.highDiv_point_list_init(list) + +def highDiv_point_list_push(list, item): + return _p3dSkel.highDiv_point_list_push(list, item) + +def highDiv_point_list_pop(list): + return _p3dSkel.highDiv_point_list_pop(list) + +def highDiv_point_list_isempty(list): + return _p3dSkel.highDiv_point_list_isempty(list) + +def highDiv_point_list_toarray(list, numel): + return _p3dSkel.highDiv_point_list_toarray(list, numel) +class highDiv_point_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + x = property(_p3dSkel.highDiv_point_t_x_get, _p3dSkel.highDiv_point_t_x_set) + y = property(_p3dSkel.highDiv_point_t_y_get, _p3dSkel.highDiv_point_t_y_set) + z = property(_p3dSkel.highDiv_point_t_z_get, _p3dSkel.highDiv_point_t_z_set) + div = property(_p3dSkel.highDiv_point_t_div_get, _p3dSkel.highDiv_point_t_div_set) + + def __init__(self): + _p3dSkel.highDiv_point_t_swiginit(self, _p3dSkel.new_highDiv_point_t()) + __swig_destroy__ = _p3dSkel.delete_highDiv_point_t + +# Register highDiv_point_t in _p3dSkel: +_p3dSkel.highDiv_point_t_swigregister(highDiv_point_t) + + + diff --git a/pypore3d/pypore3d/p3dSkelPy.py b/pypore3d/pypore3d/p3dSkelPy.py new file mode 100644 index 0000000000000000000000000000000000000000..1e0ea5acd395a3916ed3f1fef19e03c6d9c7bd18 --- /dev/null +++ b/pypore3d/pypore3d/p3dSkelPy.py @@ -0,0 +1,270 @@ +import pypore3d.p3d_common_lib +from pypore3d.p3d_common_lib import * + +import pypore3d.p3dSkel +from pypore3d.p3dSkel import * + + + + +################## Skeletonization functions + +def py_p3dSkeletonLabeling(image_data, dimx, dimy, dimz = 0): + """ + + Scan the input skeleton assigning a different label to topological relevant voxels. On the assumption that input skeleton has the thinness property, i.e. is one-voxel wide, a labeling in terms of nodes and branches is possible. A more detailed labeling of skeleton branches is also possible identifying node-to-node, node-to-end and end-to-end branches. + + Syntax: + ------ + Result = py_p3dSkeletonLabeling ( image_data, dimx, dimy [, dimz = value]) + + Return Value: + ------------ + Returns an image of type BYTE with the same dimensions of input image in which each skeleton element is assigned a different gray-level according to the following codes: + Node voxel + + 1. A node voxel has more than two voxels in its neighborhood (End voxel) + 2. An end voxel has exactly one voxel in its neighborhood. (Isolated voxel) + 3. An isolated voxel has no voxels in its neighborhood. In principle, an isolated voxel occurs in the skeletonization of a perfect sphere however, practically, it should be interpreted as a spurious voxel. (Node-to-node branch) + 4. A node-to-node branch connects two node voxels. (Node-to-end branch) + 5. A node-to-end connects a node voxel with an end voxel. (End-to-end branch) + 6. An end-to-end branch connects two end voxels ("isolated" branch). + + Arguments: + --------- + image_data: A 3D matrix of type BYTE representing the binary skeleton image to label. The image should be organized having value 255 on skeleton voxels and zero elsewhere. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + """ + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dSkeletonLabeling(image_data,out_image,dimx,dimy,dimz, None) + py_printErrorMessage(err_code) + return out_image + +def py_p3dGVFSkeletonization(image_data, dimx, dimy, dimz = 0, mu= 0.15, eps= 1E-4, hierarc = 1.0, scale= 0.0): + """ + + Computes the skeleton of a 3D binary image using the Brun and Dreossi algorithm [1]. + + Syntax: + ------ + Result = py_p3dGVFSkeletonization ( image_data, dimx, dimy [, dimz = value] [, mu=value ] [, eps=value ] [, hierarc=value ] [, scale=value ]) + + Return Value: + ------------ + Returns a volume with the same dimensions of input volume having value 255 on skeleton voxels and 0 elsewhere. + + Arguments: + --------- + image_data: A 3D matrix of type BYTE. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + mu: A decimal value in the range [0.0 0.5] (default 0.15) that controls the computation of the Gradient Vector Flow (GVF) (see [1] for details). Changes in the MU value affect the "smoothness" of the output skeleton but poorly affects computational requirements. + + eps: A decimal value in the range [0.0 0.1] (default 1E-4) that controls the iterative process of the computation of the Gradient Vector Flow (GVF) (see [1] for details). An increase of this value (for instance EPS = 1E-3) greatly improves the computational performances but may affect the "quality" of the output skeleton. + + hierarc: By specifying a decimal value in the range [0.0 0.5] (default 0.0) additional node-to-end branches will be added in the output skeleton. The addition of more node-to-end branches requires additional computational time. + + scale: Since the algorithm internally operates on a continuous model, by specifying a SCALE value (default = 1.0) the discrete input volume can be downsampled or upsampled as an attempt to, respectively, simplify or enrich the output skeleton (which, however, will still be one voxel wide and with the same dimensions of the non-resampled input volume). The downsampling improves performances, while upsampling of the input volume might be useful in a limited resolution regime. + + Remarks: + ------- + Computational time depends on the "complexity" of the structure to skeletonize and not only on volume dimensions. Skeletonization with this method might require long computational time, especially in the last step of the process. + + References + ------- + [1] F. Brun and D. Dreossi, Efficient curve-skeleton computation for the analysis of biomedical 3D images, Biomedical Sciences Instrumentation, Vol. 46, pp. 475-80, 2010. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dGVFSkeletonization(image_data, out_image, dimx, dimy, dimz, mu, eps, hierarc, scale, None) + py_printErrorMessage(err_code) + return out_image + +def py_p3dLKCSkeletonization(image_data, dimx, dimy, dimz = 0): + """ + + Computes the skeleton of a 3D binary image using the Palágyi and Kuba algorithm [1]. + + Syntax: + ------ + Result = p3dPKSkeletonization ( image_data, dimx, dimy [, dimz = value] ) + + Return Value: + ------------ + Returns a volume with the same dimensions of input volume having value 255 on skeleton voxels and 0 elsewhere. + + Arguments: + --------- + image_data: A 3D matrix of type BYTE. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + Remarks: + ------- + The result is a homotopic one voxel thin skeleton without assurance of medialness. + + References + ------- + [1] [1] K. Palágyi and A. Kuba, A Parallel 3D 12-Subiteration Thinning Algorithm, Graphical Models and Image Processing, Vol. 61, pp. 199-221, 1999. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + err_code = p3dLKCSkeletonization(image_data,out_image,dimx,dimy,dimz, None) + py_printErrorMessage(err_code) + return out_image + +def py_p3dSkeletonAnalysis(image_data, skeleton_image, dimx, dimy, dimz = 0, nodes_im = None, pores_im= None, ends_im= None, throats_im= None, merging_factor= 0.85, tortuosity_depth= 3, resolution= 1.0, skel_stats_file = "skeleton_stats.txt"): + """ + Performs a series of analysis on the input volume based on its skeleton. + + By scanning the skeleton it is possible to extract the number of nodes and branches, length and thickness measures based on the concept of maximal inscribed sphere [1] as well as connectivity indexes. This approach is typically suitable for the analysis of porous media having an interconnected porous space. Conceptually, the nodes correspond to pore bodies and the branches of the pore space skeleton correspond to the channels (or paths) connecting the pores. Unfortunately, since operatively a node is a skeleton voxel with more than two voxels in its neighborhood (see p3dSkeletonLabeling), this 1-to-1 correspondence does not exist. In fact, while every channel has its corresponding branch in the skeleton, not every branch corresponds to a channel. Furthermore, while each pore body is represented by some nodes of the skeleton, several nodes may occur in the same pore body and these nodes are usually connected through very small (and therefore spurious) branches. A merging criterion is therefore required in order to merge nodes that occur within the same pore body and in order to avoid to consider the related spurious branches. + + The algorithm used in p3dSkeletonAnalysis merges two or more nodes if there is any overlap among the maximal spheres centered at the nodes. The set of these overlapped spheres (cluster of spheres) determines a subvolume within the pore body. The largest maximal sphere is then searched within the previously determined subvolume and it is assumed as the center of a pore. In order to tune the amount of merging, the user can control the size of the cluster of spheres via the MERGING_FACTOR parameter. + + Syntax: + ------ + Result = p3dSkeletonAnalysis ( image_data, skeleton_image, dimx, dimy [, dimz = value] [, nodes_im=bytearray] [, pores_im=bytearray] [, throats_im=bytearray] [, pores_im=bytearray][, merging_factor=value] [, tortuosity_depth=value] [, resolution=value,] [skel_stats_file = value] ) + + Return Value: + ------------ + Returns a struct of parameters. The name of the fields are: + CONNECTIVITY_DENSITY [mm-3]: A scalar value representing the number of redundant connections normalized to the total volume V. It is computed as (1 - ΧV )/V where ΧV = (n - b), being n the number of pores and b the number of node-to-node branches. + + COORDINATION_NUMBER [-]: An array of length PORES_COUNT containing the number of branches that spread out from each node. + + PORES_COUNT [-]: An integer value representing the number of pores determined after the application of the merging criterion. Therefore, it does not necessarly correspond to the number of skeleton nodes. + + PORES_WIDTH [mm]: An array of length PORES_COUNT containing the pore-size distribution computed as diameter of the maximal inscribed sphere for each pore. The center of the maximal sphere is affected by the merging criterion. + + ENDPOINTS_COUNT [-]: An integer value representing the number of skeleton end points. + + ENDPOINTS_WIDTH [mm]: An array of length ENDPOINTS_COUNT containing the width of each end point computed as the diameter of the maximal sphere centered on the end point. + + ENDTOEND_COUNT [-]: An integer value representing the number of end-to-end branches. + + ENDTOEND_LENGTH [mm]: An array of length ENDTOEND_COUNT containing the length of each end-to-end branch computed from the surface to the maximal sphere of an end point to the surface of the maximal sphere of the other end point. + + ENDTOEND_MEANWIDTH [mm]: An array of length ENDTOEND_COUNT containing the mean width of each endToEndBranches. The width is computed averaging the diameter of the maximal spheres of each branch voxel. + + ENDTOEND_MINWIDTH [mm]: An array of length ENDTOEND_COUNT containing the minimum width of each end-to-end branch. This value is the diameter of the smallest maximal spheres among all the maximal spheres centered on each branch voxel. + + ENDTOEND_MAXWIDTH [mm]: An array of length ENDTOEND_COUNT containing the maximum width of each end-to-end branch. This value is the diameter of the largest maximal spheres among all the maximal spheres centered on each branch voxel. + + NODETOEND_COUNT [-]: An integer value representing the number of node-to-end branches. + + NODETOEND_LENGTH [mm]: An array of length NODETOEND_COUNT containing the length of each node-to-end branch computed from the surface to the maximal sphere of the node point to the surface of the maximal sphere of the end point. + + NODETOEND_MEANWIDTH [mm]: An array of length NODETOEND_COUNT containing the mean width of each node-to-end branch. The width is computed averaging the diameter of the maximal spheres of each branch voxel. + + NODETOEND_MINWIDTH [mm]: An array of length NODETOEND_COUNT containing the minimum width of each node-to-end branch. This value is the diameter of the smallest maximal spheres among all the maximal spheres centered on each branch voxel. + + NODETOEND_MAXWIDTH [mm]: An array of length NODETOEND_COUNT containing the maximum width of each node-to-end branch. This value is the diameter of the largest maximal spheres among all the maximal spheres centered on each branch voxel. + + NODETONODE_COUNT [-]: An integer value representing the number of node-to-node branches. + + NODETONODE_LENGTH [mm]: An array of length NODETONODE_COUNT containing the length of each node-to-node branch computed from the surface of the maximal sphere inscribed within the pore to the surface of the maximal sphere of the other pore. + + NODETONODE_MEANWIDTH [mm]: An array of length NODETONODE_COUNT containing the mean width of each node-to-node branch. The width is computed averaging the diameter of the maximal spheres of each branch voxel. + + NODETONODE_MINWIDTH [mm]: An array of length NODETONODE_COUNT containing the minimum width of each node-to-node branch. This value is the diameter of the smallest maximal spheres among all the maximal spheres centered on each branch voxel. The smallest thickness along a node-to-node branch is usually defined as throat. + + NODETONODE_MAXWIDTH [mm]: An array of length NODETONODE_COUNT containing the maximum width of each node-to-node branch. This value is the diameter of the largest maximal spheres among all the maximal spheres centered on each branch voxel. + + Arguments: + --------- + image_data: A 3D matrix of type BYTE. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + SkelImage: A 3D matrix of type BYTE representing the skeleton of OrigImage. OrigImage and SkelImage should have same dimensions. + + nodes_im: Optionally, a 3D matrix of type BYTE with the same dimensions of input images having the filled and sometimes overlapping balls centered on each skeleton nodes can be returned as output. The size of these balls is tuned with the MERGING_FACTOR parameter. This volume is the starting point for the determination of the PORES_IM image. + + pores_im: Optionally, a 3D matrix of type BYTE with the same dimensions of input images having the maximal balls on each of what have been considered as pores can be returned as output. The diameter of these balls are used for the pore size distribution assessment. The center of each of these balls lies within the cluster of overlapped balls of nodes_im. + + throats_im: Optionally, a 3D matrix of type BYTE with the same dimensions of input images having the filled maximal balls on skeleton throats (i.e. the minimum thickness along a node-to-node branch) can be returned as output. + + throats_im: Optionally, a 3D matrix of type BYTE with the same dimensions of input images having the filled maximal balls on skeleton throats (i.e. the minimum thickness along a node-to-node branch) can be returned as output. + + merging_factor: A decimal value in the range [0.0,1.0] for reducing the size of the maximal balls to use for merging adjacent nodes (default 0.85). If the value 1.0 is specified too many skeleton nodes might be merged leading to inaccurate results. On the other hand, if a too small value is specified, spurious branches might be considered. + + resolution: A decimal value representing the resolution of input image. If this value is not specified a voxelsize of 1.0 is assumed that means output values are expressed in voxel unit. + + skel_stats_file: tab_delimeted/categorized file where output statistics are written. If no file address is specifed, the statustics will be saved in the default folder under the name "skeleton_stats.txt" + + Remarks: + ------- + The result is a homotopic one voxel thin skeleton without assurance of medialness. + + References + ------- + [1] K. Palágyi and A. Kuba, A Parallel 3D 12-Subiteration Thinning Algorithm, Graphical Models and Image Processing, Vol. 61, pp. 199-221, 1999. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + skeleton_stats = malloc_PSkeletonStats() + err_code=p3dSkeletonAnalysis(image_data,skeleton_image,skeleton_stats,nodes_im,pores_im,ends_im,throats_im,dimx,dimy,dimz,merging_factor,tortuosity_depth, resolution,None) + py_printErrorMessage(err_code) + PrintSkelStruct(skeleton_stats, skel_stats_file) + return skeleton_stats + + +def py_p3dSkeletonPruning(image_data, dimx, dimy, dimz = 0, thresh=3, ultimate = False, iterative = False): + """ + Prunes the skeleton by removing node-to-end branches. + + Skeleton pruning can be performed by simply fixing a threshold on the length (maximum number of voxels) of a node-to-end branch, therefore a node-to-end branch having a number of voxels below the specified value is removed from output skeleton. After first step of pruning, new node-to-end branches could be created and they could be considered spurious as well. If the ITERATIVE keyword is specified, the pruning algorithm iteratively scans for node-to-end branches after a first removal and it stops when no more changes are possibile. If the ULTIMATE keyword is specified all the node-to-end branches are removed from the skeleton independently from their length. If both ITERATIVE and ULTIMATE keywords are specified, only closed paths or end- to-end branches are preserved in the output skeleton. If the input skeleton does not feature closed paths or end-to-end branches, an application of the ULTIMATE and/or ITERATIVE keywords results in a blank output. + + Syntax: + ------ + Result = py_p3dSkeletonPruning ( image_data, dimx, dimy [, dimz = value] [,thresh=value] [,ultimate = bool] [,iterative = bool]) + + Return Value: + ------------ + Returns a volume with the same dimensions of input volume having value 255 on skeleton voxels and 0 elsewhere. + + Arguments: + --------- + image_data: A 3D matrix of type BYTE. + + dimx,dimy,dimz: three variables representing the dimensions of image to read. + + """ + if dimx == 0 or dimy == 0: + py_printErrorMessage(-3) + return + + out_image = malloc_uchar(dimx*dimy*dimz) + if iterative == True and ultimate == False: + print("p3dIterativeSkeletonPruning") + err_code = p3dIterativeSkeletonPruning (image_data, out_image,dimx,dimy,dimz, thresh, None ) + py_printErrorMessage(err_code) + return out_image + if ultimate == True: + print("p3dUltimateSkeletonPruning") + err_code = p3dUltimateSkeletonPruning (image_data, out_image, dimx,dimy,dimz, iterative, None ) + py_printErrorMessage(err_code) + return out_image + # Default: iterative == False and ultimate = False + print("p3dSimpleSkeletonPruning") + err_code = p3dSimpleSkeletonPruning(image_data, out_image,dimx,dimy,dimz, thresh, None ) + py_printErrorMessage(err_code) + return out_image + + + + diff --git a/pypore3d/pypore3d/p3dSkel_wrap.c b/pypore3d/pypore3d/p3dSkel_wrap.c new file mode 100644 index 0000000000000000000000000000000000000000..f7c8fcdddd7df549c4f9cea071e2c7720b61df2e --- /dev/null +++ b/pypore3d/pypore3d/p3dSkel_wrap.c @@ -0,0 +1,11298 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifndef SWIGPYTHON +#define SWIGPYTHON +#endif + +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + + +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include <math.h> +#endif + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include <Python.h> +# define _DEBUG 1 +#else +# include <Python.h> +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast(r) (r) +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *newstr = 0; + str = PyUnicode_AsUTF8String(str); + if (str) { + char *cstr; + Py_ssize_t len; + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + } + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#define Py_hash_t long +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + PyErr_Clear(); + Py_XINCREF(type); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); +#else + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# define SWIG_PYTHON_USE_GIL +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" +#endif + +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +} + +/* Unpack the argument tuple */ + +SWIGINTERN Py_ssize_t +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + Py_ssize_t i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + Py_ssize_t i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); + data->delargs = !(flags & (METH_O)); + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_repr(SwigPyObject *v) +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); + if (v->next) { + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ +SWIGRUNTIME PyObject * +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); + + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(type, value, traceback); + + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } + } + return obj; + } +} + +static PyMethodDef +swigobject_methods[] = { + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, + {0, 0, 0, 0} +}; + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#else + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +static PyObject *Swig_This_global = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + swig_cast_info *tc; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + return SWIG_OK; + } +} + +/* Convert a packed pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } + } + Py_DECREF(empty_args); + } +#else + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } +#endif + } + return inst; +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, "__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Python_DestroyModule(PyObject *obj) +{ + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + Swig_This_global = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCapsule_New((void*) descriptor, NULL, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + const char *errmesg = tmp ? tmp : "Invalid error message"; + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, errmesg); + } else { + PyErr_Format(type, "%s %s", errmesg, mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef SWIGPYTHON_BUILTIN +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; + +# ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +# else + if (!PyString_Check(name)) +# endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} +#endif + + +#ifdef __cplusplus +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + +#ifdef __cplusplus +} +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_SkeletonStats swig_types[0] +#define SWIGTYPE_p_bb_t swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_coords_lelem_t swig_types[3] +#define SWIGTYPE_p_coords_qelem_t swig_types[4] +#define SWIGTYPE_p_coords_queue_t swig_types[5] +#define SWIGTYPE_p_coords_t swig_types[6] +#define SWIGTYPE_p_crit_point_lelem_t swig_types[7] +#define SWIGTYPE_p_crit_point_t swig_types[8] +#define SWIGTYPE_p_double swig_types[9] +#define SWIGTYPE_p_f_p_q_const__char_v_______int swig_types[10] +#define SWIGTYPE_p_fcoords_lelem_t swig_types[11] +#define SWIGTYPE_p_fcoords_t swig_types[12] +#define SWIGTYPE_p_float swig_types[13] +#define SWIGTYPE_p_highDiv_point_lelem_t swig_types[14] +#define SWIGTYPE_p_highDiv_point_t swig_types[15] +#define SWIGTYPE_p_int swig_types[16] +#define SWIGTYPE_p_p_bb_t swig_types[17] +#define SWIGTYPE_p_p_coords_lelem_t swig_types[18] +#define SWIGTYPE_p_p_crit_point_lelem_t swig_types[19] +#define SWIGTYPE_p_p_fcoords_lelem_t swig_types[20] +#define SWIGTYPE_p_p_highDiv_point_lelem_t swig_types[21] +#define SWIGTYPE_p_p_uint_lelem_t swig_types[22] +#define SWIGTYPE_p_p_unsigned_int swig_types[23] +#define SWIGTYPE_p_uint_lelem_t swig_types[24] +#define SWIGTYPE_p_unsigned_char swig_types[25] +#define SWIGTYPE_p_unsigned_int swig_types[26] +#define SWIGTYPE_p_unsigned_short swig_types[27] +static swig_type_info *swig_types[29]; +static swig_module_info swig_module = {swig_types, 28, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery +#endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery + +/*----------------------------------------------- + @(target):= _p3dSkel.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__p3dSkel + +#else +# define SWIG_init init_p3dSkel + +#endif +#define SWIG_name "_p3dSkel" + +#define SWIGVERSION 0x040001 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + + #define SWIG_FILE_WITH_INIT + +#include "P3D_Skel/p3dSkel.h" +#include "P3D_Skel/p3dTime.h" +#include "P3D_Skel/Common/p3dBoundingBoxT.h" +#include "P3D_Skel/Common/p3dConnectedComponentsLabeling.h" +#include "P3D_Skel/Common/p3dCoordsList.h" +#include "P3D_Skel/Common/p3dCoordsQueue.h" +#include "P3D_Skel/Common/p3dCoordsT.h" +#include "P3D_Skel/Common/p3dFCoordsList.h" +#include "P3D_Skel/Common/p3dSquaredEuclideanDT.h" +#include "P3D_Skel/Common/p3dThinning.h" +#include "P3D_Skel/Common/p3dUIntList.h" +#include "P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.h" +#include "P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.h" +#include "P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.h" +#include "P3D_Skel/GVFSkeletonization/p3dCriticalPoints.h" +#include "P3D_Skel/GVFSkeletonization/p3dCritPointList.h" +#include "P3D_Skel/GVFSkeletonization/p3dCritPointT.h" +#include "P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.h" +#include "P3D_Skel/GVFSkeletonization/p3dGVF.h" +#include "P3D_Skel/GVFSkeletonization/p3dHighDivPointList.h" +#include "P3D_Skel/GVFSkeletonization/p3dHighDivPointT.h" + + + + +#include <stdlib.h> + + +typedef struct SWIGCDATA { + char *data; + size_t len; +} SWIGCDATA; + + + + + + +static SWIGCDATA cdata_void(void *ptr, size_t nelements) + + + +{ + SWIGCDATA d; + d.data = (char *) ptr; + + + + d.len = nelements; + + return d; +} + + + + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 + } else if (PyInt_Check(obj)) { + if (val) *val = (double) PyInt_AsLong(obj); + return SWIG_OK; +#endif + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else +#endif + if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +#include <limits.h> +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} +#endif + + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + int res = SWIG_TypeError; +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + } +#endif + return res; +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +#if PY_VERSION_HEX >= 0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); +#else + return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); +#endif +#else + return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); +#endif + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else + if (PyUnicode_Check(obj)) +#endif +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; +#if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; +#endif + PyBytes_AsStringAndSize(obj, &cstr, &len); +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else + *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; +#endif + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + Py_XDECREF(obj); +#endif + return ret; + } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + +unsigned char *realloc_uchar(unsigned char *ptr, size_t nitems) + + + +{ + +return (unsigned char *) realloc(ptr, nitems*sizeof(unsigned char)); + + + +} + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long_SS_long (unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)(value)); +} +#endif + + +SWIGINTERNINLINE PyObject * +SWIG_From_size_t (size_t value) +{ +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + return SWIG_From_unsigned_SS_long ((unsigned long)(value)); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else { + /* assume sizeof(size_t) <= sizeof(unsigned long long) */ + return SWIG_From_unsigned_SS_long_SS_long ((unsigned long long)(value)); + } +#endif +} + + + +unsigned short *realloc_ushort(unsigned short *ptr, size_t nitems) + + + +{ + +return (unsigned short *) realloc(ptr, nitems*sizeof(unsigned short)); + + + +} + + + +struct SkeletonStats *realloc_PSkeletonStats(struct SkeletonStats *ptr, size_t nitems) + + + +{ + +return (struct SkeletonStats *) realloc(ptr, nitems*sizeof(struct SkeletonStats)); + + + +} + + + + #include <float.h> + void PrintSkelStruct(struct SkeletonStats* out_stats, char* filename) + { + // creating file pointer to work with files + FILE *fptr; + + // opening file in writing mode + fptr = fopen(filename, "w"); + + // exiting program + if (fptr == NULL) { + printf("Error!"); + exit(1); + } + + int Digs = FLT_DECIMAL_DIG; + + fprintf(fptr, "End_Width\n"); + for (int i = 0; i<out_stats->End_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e\n", Digs, out_stats->End_Width[i]); + } + + + fprintf(fptr, "EndToEnd_Length,EndToEnd_MaxWidth,EndToEnd_MeanWidth,EndToEnd_MinWidth\n"); + for (int i = 0; i<out_stats->EndToEnd_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e,", Digs, out_stats->EndToEnd_Length[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->EndToEnd_MaxWidth[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->EndToEnd_MeanWidth[i]); + fprintf(fptr, "%.*e\n", Digs, out_stats->EndToEnd_MinWidth[i]); + } + + fprintf(fptr, "NodeToNode_Length,NodeToNode_MaxWidth,NodeToNode_MeanWidth,NodeToNode_MinWidth\n"); + for (int i = 0; i<out_stats->NodeToNode_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e,", Digs, out_stats->NodeToNode_Length[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->NodeToNode_MaxWidth[i]); + fprintf(fptr, "%.*e,", Digs, out_stats->NodeToNode_MeanWidth[i]); + fprintf(fptr, "%.*e\n", Digs, out_stats->NodeToNode_MinWidth[i]); + } + + + fprintf(fptr, "Node_Width\n"); + for (int i = 0; i<out_stats->Node_Counter; i++) + { + //print to file + fprintf(fptr, "%.*e\n", Digs, out_stats->Node_Width[i]); + } + + + fclose(fptr); + } + + + + + +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + + #define SWIG_From_double PyFloat_FromDouble + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > USHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned short)(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_short (unsigned short value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else +#endif + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_unsigned_SS_int (unsigned int value) +{ + return PyInt_FromSize_t((size_t) value); +} + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_cdata(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + size_t arg2 = (size_t) 1 ; + int res1 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + SWIGCDATA result; + + if (!SWIG_Python_UnpackTuple(args, "cdata", 1, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cdata" "', argument " "1"" of type '" "void *""'"); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cdata" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = cdata_void(arg1,arg2); + resultobj = SWIG_FromCharPtrAndSize((&result)->data,(&result)->len); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_memmove(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + size_t arg3 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + size_t size2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "memmove", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "memmove" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, &size2, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "memmove" "', argument " "2"" of type '" "void const *""'"); + } + arg2 = (void *)(buf2); + arg3 = (size_t)(size2); + memmove(arg1,(void const *)arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + unsigned char *result = 0 ; + + arg1 = (size_t) sizeof(unsigned char); + if (!SWIG_Python_UnpackTuple(args, "malloc_uchar", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_uchar" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (unsigned char *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned char *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(unsigned char); + if (!SWIG_Python_UnpackTuple(args, "calloc_uchar", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_uchar" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_uchar" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (unsigned char *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_uchar", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_uchar" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (unsigned char *)realloc_uchar(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_uchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_uchar" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short *result = 0 ; + + arg1 = (size_t) sizeof(unsigned short); + if (!SWIG_Python_UnpackTuple(args, "malloc_ushort", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_ushort" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (unsigned short *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned short *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(unsigned short); + if (!SWIG_Python_UnpackTuple(args, "calloc_ushort", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_ushort" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_ushort" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (unsigned short *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned short *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_ushort", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_ushort" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (unsigned short *)realloc_ushort(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_short, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_ushort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned short *arg1 = (unsigned short *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_ushort" "', argument " "1"" of type '" "unsigned short *""'"); + } + arg1 = (unsigned short *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_malloc_PSkeletonStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + struct SkeletonStats *result = 0 ; + + arg1 = (size_t) sizeof(struct SkeletonStats); + if (!SWIG_Python_UnpackTuple(args, "malloc_PSkeletonStats", 0, 1, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "malloc_PSkeletonStats" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + result = (struct SkeletonStats *)malloc(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SkeletonStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_calloc_PSkeletonStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t arg2 ; + size_t val1 ; + int ecode1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + struct SkeletonStats *result = 0 ; + + arg1 = 1; + arg2 = (size_t) sizeof(struct SkeletonStats); + if (!SWIG_Python_UnpackTuple(args, "calloc_PSkeletonStats", 0, 2, swig_obj)) SWIG_fail; + if (swig_obj[0]) { + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "calloc_PSkeletonStats" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = (size_t)(val1); + } + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "calloc_PSkeletonStats" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + } + result = (struct SkeletonStats *)calloc(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SkeletonStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_realloc_PSkeletonStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + struct SkeletonStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "realloc_PSkeletonStats", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "realloc_PSkeletonStats" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "realloc_PSkeletonStats" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (struct SkeletonStats *)realloc_PSkeletonStats(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SkeletonStats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_free_PSkeletonStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "free_PSkeletonStats" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PrintSkelStruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "PrintSkelStruct", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PrintSkelStruct" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PrintSkelStruct" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + PrintSkelStruct(arg1,arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_ConnectivityDensity_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_ConnectivityDensity_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_ConnectivityDensity_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SkeletonStats_ConnectivityDensity_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->ConnectivityDensity = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_ConnectivityDensity_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_ConnectivityDensity_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double) ((arg1)->ConnectivityDensity); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_CoordinationNumber_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + int *arg2 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_CoordinationNumber_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_CoordinationNumber_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_int, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_CoordinationNumber_set" "', argument " "2"" of type '" "int *""'"); + } + arg2 = (int *)(argp2); + if (arg1) (arg1)->CoordinationNumber = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_CoordinationNumber_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_CoordinationNumber_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (int *) ((arg1)->CoordinationNumber); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_End_Counter_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + unsigned short arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_End_Counter_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_End_Counter_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SkeletonStats_End_Counter_set" "', argument " "2"" of type '" "unsigned short""'"); + } + arg2 = (unsigned short)(val2); + if (arg1) (arg1)->End_Counter = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_End_Counter_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_End_Counter_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (unsigned short) ((arg1)->End_Counter); + resultobj = SWIG_From_unsigned_SS_short((unsigned short)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_End_Width_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_End_Width_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_End_Width_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_End_Width_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->End_Width = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_End_Width_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_End_Width_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->End_Width); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_Counter_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + unsigned short arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_EndToEnd_Counter_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_Counter_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SkeletonStats_EndToEnd_Counter_set" "', argument " "2"" of type '" "unsigned short""'"); + } + arg2 = (unsigned short)(val2); + if (arg1) (arg1)->EndToEnd_Counter = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_Counter_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_Counter_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (unsigned short) ((arg1)->EndToEnd_Counter); + resultobj = SWIG_From_unsigned_SS_short((unsigned short)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_Length_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_EndToEnd_Length_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_Length_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_EndToEnd_Length_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->EndToEnd_Length = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_Length_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_Length_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->EndToEnd_Length); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_MaxWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_EndToEnd_MaxWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_MaxWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_EndToEnd_MaxWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->EndToEnd_MaxWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_MaxWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_MaxWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->EndToEnd_MaxWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_MeanWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_EndToEnd_MeanWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_MeanWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_EndToEnd_MeanWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->EndToEnd_MeanWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_MeanWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_MeanWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->EndToEnd_MeanWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_MinWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_EndToEnd_MinWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_MinWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_EndToEnd_MinWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->EndToEnd_MinWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_EndToEnd_MinWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_EndToEnd_MinWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->EndToEnd_MinWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_Counter_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + unsigned short arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToEnd_Counter_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_Counter_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SkeletonStats_NodeToEnd_Counter_set" "', argument " "2"" of type '" "unsigned short""'"); + } + arg2 = (unsigned short)(val2); + if (arg1) (arg1)->NodeToEnd_Counter = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_Counter_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_Counter_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (unsigned short) ((arg1)->NodeToEnd_Counter); + resultobj = SWIG_From_unsigned_SS_short((unsigned short)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_Length_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToEnd_Length_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_Length_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToEnd_Length_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToEnd_Length = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_Length_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_Length_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToEnd_Length); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_MaxWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToEnd_MaxWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_MaxWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToEnd_MaxWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToEnd_MaxWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_MaxWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_MaxWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToEnd_MaxWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_MeanWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToEnd_MeanWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_MeanWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToEnd_MeanWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToEnd_MeanWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_MeanWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_MeanWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToEnd_MeanWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_MinWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToEnd_MinWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_MinWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToEnd_MinWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToEnd_MinWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToEnd_MinWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToEnd_MinWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToEnd_MinWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_Counter_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + unsigned short arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToNode_Counter_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_Counter_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SkeletonStats_NodeToNode_Counter_set" "', argument " "2"" of type '" "unsigned short""'"); + } + arg2 = (unsigned short)(val2); + if (arg1) (arg1)->NodeToNode_Counter = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_Counter_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_Counter_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (unsigned short) ((arg1)->NodeToNode_Counter); + resultobj = SWIG_From_unsigned_SS_short((unsigned short)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_Length_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToNode_Length_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_Length_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToNode_Length_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToNode_Length = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_Length_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_Length_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToNode_Length); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_MaxWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToNode_MaxWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_MaxWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToNode_MaxWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToNode_MaxWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_MaxWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_MaxWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToNode_MaxWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_MeanWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToNode_MeanWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_MeanWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToNode_MeanWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToNode_MeanWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_MeanWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_MeanWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToNode_MeanWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_MinWidth_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_NodeToNode_MinWidth_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_MinWidth_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_NodeToNode_MinWidth_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->NodeToNode_MinWidth = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_NodeToNode_MinWidth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_NodeToNode_MinWidth_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->NodeToNode_MinWidth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_Node_Counter_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + unsigned short arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_Node_Counter_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_Node_Counter_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SkeletonStats_Node_Counter_set" "', argument " "2"" of type '" "unsigned short""'"); + } + arg2 = (unsigned short)(val2); + if (arg1) (arg1)->Node_Counter = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_Node_Counter_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned short result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_Node_Counter_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (unsigned short) ((arg1)->Node_Counter); + resultobj = SWIG_From_unsigned_SS_short((unsigned short)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_Node_Width_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + double *arg2 = (double *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "SkeletonStats_Node_Width_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_Node_Width_set" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SkeletonStats_Node_Width_set" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + if (arg1) (arg1)->Node_Width = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SkeletonStats_Node_Width_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SkeletonStats_Node_Width_get" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + result = (double *) ((arg1)->Node_Width); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SkeletonStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_SkeletonStats", 0, 0, 0)) SWIG_fail; + result = (struct SkeletonStats *)calloc(1, sizeof(struct SkeletonStats)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SkeletonStats, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_SkeletonStats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct SkeletonStats *arg1 = (struct SkeletonStats *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SkeletonStats, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SkeletonStats" "', argument " "1"" of type '" "struct SkeletonStats *""'"); + } + arg1 = (struct SkeletonStats *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *SkeletonStats_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_SkeletonStats, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *SkeletonStats_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_p3dGVFSkeletonization(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + double arg6 ; + double arg7 ; + double arg8 ; + double arg9 ; + int (*arg10)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + double val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGVFSkeletonization", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGVFSkeletonization" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGVFSkeletonization" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGVFSkeletonization" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGVFSkeletonization" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGVFSkeletonization" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_double(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGVFSkeletonization" "', argument " "6"" of type '" "double""'"); + } + arg6 = (double)(val6); + ecode7 = SWIG_AsVal_double(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGVFSkeletonization" "', argument " "7"" of type '" "double""'"); + } + arg7 = (double)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dGVFSkeletonization" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_double(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dGVFSkeletonization" "', argument " "9"" of type '" "double""'"); + } + arg9 = (double)(val9); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[9], (void**)(&arg10), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dGVFSkeletonization" "', argument " "10"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dGVFSkeletonization(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dThinningSkeletonization(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dThinningSkeletonization", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dThinningSkeletonization" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dThinningSkeletonization" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dThinningSkeletonization" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dThinningSkeletonization" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dThinningSkeletonization" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dThinningSkeletonization" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dThinningSkeletonization(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dLKCSkeletonization(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dLKCSkeletonization", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dLKCSkeletonization" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dLKCSkeletonization" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dLKCSkeletonization" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dLKCSkeletonization" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dLKCSkeletonization" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dLKCSkeletonization" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dLKCSkeletonization(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSimpleSkeletonPruning(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSimpleSkeletonPruning", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSimpleSkeletonPruning" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSimpleSkeletonPruning" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSimpleSkeletonPruning" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSimpleSkeletonPruning" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSimpleSkeletonPruning" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dSimpleSkeletonPruning" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSimpleSkeletonPruning" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dSimpleSkeletonPruning(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dIterativeSkeletonPruning(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dIterativeSkeletonPruning", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dIterativeSkeletonPruning" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dIterativeSkeletonPruning" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dIterativeSkeletonPruning" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dIterativeSkeletonPruning" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dIterativeSkeletonPruning" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dIterativeSkeletonPruning" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dIterativeSkeletonPruning" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dIterativeSkeletonPruning(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dUltimateSkeletonPruning(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dUltimateSkeletonPruning", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dUltimateSkeletonPruning" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dUltimateSkeletonPruning" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dUltimateSkeletonPruning" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dUltimateSkeletonPruning" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dUltimateSkeletonPruning" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dUltimateSkeletonPruning" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dUltimateSkeletonPruning" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dUltimateSkeletonPruning(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSkeletonLabeling(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int (*arg6)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSkeletonLabeling", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSkeletonLabeling" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSkeletonLabeling" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSkeletonLabeling" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSkeletonLabeling" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSkeletonLabeling" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[5], (void**)(&arg6), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSkeletonLabeling" "', argument " "6"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dSkeletonLabeling(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSkeletonAnalysis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + struct SkeletonStats *arg3 = (struct SkeletonStats *) 0 ; + unsigned char *arg4 = (unsigned char *) 0 ; + unsigned char *arg5 = (unsigned char *) 0 ; + unsigned char *arg6 = (unsigned char *) 0 ; + unsigned char *arg7 = (unsigned char *) 0 ; + int arg8 ; + int arg9 ; + int arg10 ; + double arg11 ; + int arg12 ; + double arg13 ; + int (*arg14)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + void *argp7 = 0 ; + int res7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + double val11 ; + int ecode11 = 0 ; + int val12 ; + int ecode12 = 0 ; + double val13 ; + int ecode13 = 0 ; + PyObject *swig_obj[14] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSkeletonAnalysis", 14, 14, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSkeletonAnalysis" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSkeletonAnalysis" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_SkeletonStats, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dSkeletonAnalysis" "', argument " "3"" of type '" "struct SkeletonStats *""'"); + } + arg3 = (struct SkeletonStats *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dSkeletonAnalysis" "', argument " "4"" of type '" "unsigned char *""'"); + } + arg4 = (unsigned char *)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "p3dSkeletonAnalysis" "', argument " "5"" of type '" "unsigned char *""'"); + } + arg5 = (unsigned char *)(argp5); + res6 = SWIG_ConvertPtr(swig_obj[5], &argp6,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "p3dSkeletonAnalysis" "', argument " "6"" of type '" "unsigned char *""'"); + } + arg6 = (unsigned char *)(argp6); + res7 = SWIG_ConvertPtr(swig_obj[6], &argp7,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "p3dSkeletonAnalysis" "', argument " "7"" of type '" "unsigned char *""'"); + } + arg7 = (unsigned char *)(argp7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dSkeletonAnalysis" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dSkeletonAnalysis" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dSkeletonAnalysis" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + ecode11 = SWIG_AsVal_double(swig_obj[10], &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "p3dSkeletonAnalysis" "', argument " "11"" of type '" "double""'"); + } + arg11 = (double)(val11); + ecode12 = SWIG_AsVal_int(swig_obj[11], &val12); + if (!SWIG_IsOK(ecode12)) { + SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "p3dSkeletonAnalysis" "', argument " "12"" of type '" "int""'"); + } + arg12 = (int)(val12); + ecode13 = SWIG_AsVal_double(swig_obj[12], &val13); + if (!SWIG_IsOK(ecode13)) { + SWIG_exception_fail(SWIG_ArgError(ecode13), "in method '" "p3dSkeletonAnalysis" "', argument " "13"" of type '" "double""'"); + } + arg13 = (double)(val13); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[13], (void**)(&arg14), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSkeletonAnalysis" "', argument " "14"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dSkeletonAnalysis(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSkeletonAnalysisFeasibility(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + double *arg3 = (double *) 0 ; + int arg4 ; + int arg5 ; + int arg6 ; + int (*arg7)(char const *,...) = (int (*)(char const *,...)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSkeletonAnalysisFeasibility", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "3"" of type '" "double *""'"); + } + arg3 = (double *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[6], (void**)(&arg7), SWIGTYPE_p_f_p_q_const__char_v_______int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "p3dSkeletonAnalysisFeasibility" "', argument " "7"" of type '" "int (*)(char const *,...)""'"); + } + } + result = (int)p3dSkeletonAnalysisFeasibility(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dResetStartTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "p3dResetStartTime", 0, 0, 0)) SWIG_fail; + p3dResetStartTime(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime", 0, 0, 0)) SWIG_fail; + result = (double)p3dGetElapsedTime(); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime_min(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime_min", 0, 0, 0)) SWIG_fail; + result = (int)p3dGetElapsedTime_min(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetElapsedTime_sec(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetElapsedTime_sec", 0, 0, 0)) SWIG_fail; + result = (double)p3dGetElapsedTime_sec(); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_min_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_x_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_min_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->min_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_x_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->min_x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_max_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_x_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_max_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->max_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_x_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->max_x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_min_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_y_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_min_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->min_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_y_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->min_y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_max_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_y_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_max_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->max_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_y_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->max_y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_min_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_z_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_min_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->min_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_min_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_min_z_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->min_z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bb_t_max_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_z_set" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bb_t_max_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->max_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bb_t_max_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bb_t_max_z_get" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + result = (int) ((arg1)->max_z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_bb_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_bb_t", 0, 0, 0)) SWIG_fail; + result = (bb_t *)calloc(1, sizeof(bb_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_bb_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_bb_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bb_t *arg1 = (bb_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_bb_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_bb_t" "', argument " "1"" of type '" "bb_t *""'"); + } + arg1 = (bb_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *bb_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_bb_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *bb_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_p3dConnectedComponentsLabeling(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int *arg3 = (int *) 0 ; + unsigned int **arg4 = (unsigned int **) 0 ; + bb_t **arg5 = (bb_t **) 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + int arg9 ; + int arg10 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dConnectedComponentsLabeling", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dConnectedComponentsLabeling" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dConnectedComponentsLabeling" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dConnectedComponentsLabeling" "', argument " "3"" of type '" "int *""'"); + } + arg3 = (int *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_p_unsigned_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dConnectedComponentsLabeling" "', argument " "4"" of type '" "unsigned int **""'"); + } + arg4 = (unsigned int **)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_p_bb_t, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "p3dConnectedComponentsLabeling" "', argument " "5"" of type '" "bb_t **""'"); + } + arg5 = (bb_t **)(argp5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dConnectedComponentsLabeling" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dConnectedComponentsLabeling" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dConnectedComponentsLabeling" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dConnectedComponentsLabeling" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dConnectedComponentsLabeling" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + result = (int)p3dConnectedComponentsLabeling(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetMaxVolumeRegion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetMaxVolumeRegion", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGetMaxVolumeRegion" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGetMaxVolumeRegion" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dGetMaxVolumeRegion" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dGetMaxVolumeRegion" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGetMaxVolumeRegion" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGetMaxVolumeRegion" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + result = (int)p3dGetMaxVolumeRegion(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + coords_t *arg2 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_elem_set" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_lelem_t_elem_set" "', argument " "2"" of type '" "coords_t *""'"); + } + arg2 = (coords_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_elem_get" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + result = (coords_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + struct coords_lelem_t *arg2 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_next_set" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_lelem_t_next_set" "', argument " "2"" of type '" "struct coords_lelem_t *""'"); + } + arg2 = (struct coords_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct coords_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_lelem_t_next_get" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + result = (struct coords_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct coords_lelem_t *)calloc(1, sizeof(struct coords_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_lelem_t *arg1 = (struct coords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_lelem_t" "', argument " "1"" of type '" "struct coords_lelem_t *""'"); + } + arg1 = (struct coords_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_init" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + coords_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + coords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "coords_list_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_push" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_coords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_list_push" "', argument " "2"" of type '" "coords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_list_push" "', argument " "2"" of type '" "coords_t""'"); + } else { + arg2 = *((coords_t *)(argp2)); + } + } + result = (int)coords_list_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_pop" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + result = coords_list_pop(arg1); + resultobj = SWIG_NewPointerObj((coords_t *)memcpy((coords_t *)calloc(1,sizeof(coords_t)),&result,sizeof(coords_t)), SWIGTYPE_p_coords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t arg1 = (coords_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_isempty" "', argument " "1"" of type '" "coords_list_t""'"); + } + arg1 = (coords_list_t)(argp1); + result = (int)coords_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_list_t *arg1 = (coords_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + coords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "coords_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_coords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_list_toarray" "', argument " "1"" of type '" "coords_list_t *""'"); + } + arg1 = (coords_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (coords_t *)coords_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_item_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + coords_t *arg2 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_qelem_t_item_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_item_set" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_qelem_t_item_set" "', argument " "2"" of type '" "coords_t *""'"); + } + arg2 = (coords_t *)(argp2); + if (arg1) (arg1)->item = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_item_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_item_get" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + result = (coords_t *)& ((arg1)->item); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + struct coords_qelem_t *arg2 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_qelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_next_set" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_qelem_t_next_set" "', argument " "2"" of type '" "struct coords_qelem_t *""'"); + } + arg2 = (struct coords_qelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_qelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct coords_qelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_qelem_t_next_get" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + result = (struct coords_qelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_qelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_qelem_t", 0, 0, 0)) SWIG_fail; + result = (struct coords_qelem_t *)calloc(1, sizeof(struct coords_qelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_qelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct coords_qelem_t *arg1 = (struct coords_qelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_qelem_t" "', argument " "1"" of type '" "struct coords_qelem_t *""'"); + } + arg1 = (struct coords_qelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_qelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_qelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_qelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_queue_t_tail_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_queue_elem_t *arg2 = (coords_queue_elem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_t_tail_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_tail_set" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_t_tail_set" "', argument " "2"" of type '" "coords_queue_elem_t *""'"); + } + arg2 = (coords_queue_elem_t *)(argp2); + if (arg1) (arg1)->tail = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_t_tail_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_queue_elem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_tail_get" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = (coords_queue_elem_t *) ((arg1)->tail); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_t_head_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_queue_elem_t *arg2 = (coords_queue_elem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_t_head_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_head_set" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_coords_qelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_t_head_set" "', argument " "2"" of type '" "coords_queue_elem_t *""'"); + } + arg2 = (coords_queue_elem_t *)(argp2); + if (arg1) (arg1)->head = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_t_head_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_queue_elem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_t_head_get" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = (coords_queue_elem_t *) ((arg1)->head); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_qelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_queue_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_queue_t", 0, 0, 0)) SWIG_fail; + result = (coords_queue_t *)calloc(1, sizeof(coords_queue_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_queue_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_queue_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_queue_t" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_queue_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_queue_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_queue_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_coords_queue_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_init" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + coords_queue_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + coords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_queue_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_push" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_coords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "coords_queue_push" "', argument " "2"" of type '" "coords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_queue_push" "', argument " "2"" of type '" "coords_t""'"); + } else { + arg2 = *((coords_t *)(argp2)); + } + } + coords_queue_push(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t *arg1 = (coords_queue_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + coords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_queue_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_pop" "', argument " "1"" of type '" "coords_queue_t *""'"); + } + arg1 = (coords_queue_t *)(argp1); + result = coords_queue_pop(arg1); + resultobj = SWIG_NewPointerObj((coords_t *)memcpy((coords_t *)calloc(1,sizeof(coords_t)),&result,sizeof(coords_t)), SWIGTYPE_p_coords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_queue_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_queue_t arg1 ; + void *argp1 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_coords_queue_t, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_queue_isempty" "', argument " "1"" of type '" "coords_queue_t""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "coords_queue_isempty" "', argument " "1"" of type '" "coords_queue_t""'"); + } else { + arg1 = *((coords_queue_t *)(argp1)); + } + } + result = (int)coords_queue_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_x_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_x_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_x_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->x); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_y_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_y_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_y_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->y); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "coords_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_z_set" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "coords_t_z_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coords_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "coords_t_z_get" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + result = (int) ((arg1)->z); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_coords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_coords_t", 0, 0, 0)) SWIG_fail; + result = (coords_t *)calloc(1, sizeof(coords_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coords_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_coords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + coords_t *arg1 = (coords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_coords_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_coords_t" "', argument " "1"" of type '" "coords_t *""'"); + } + arg1 = (coords_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *coords_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_coords_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *coords_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_fcoords_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_x_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_x_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_y_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_y_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_z_set" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_t_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_t_z_get" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + result = (double) ((arg1)->z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_fcoords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_fcoords_t", 0, 0, 0)) SWIG_fail; + result = (fcoords_t *)calloc(1, sizeof(fcoords_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_fcoords_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_t *arg1 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_fcoords_t" "', argument " "1"" of type '" "fcoords_t *""'"); + } + arg1 = (fcoords_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *fcoords_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_fcoords_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *fcoords_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + fcoords_t *arg2 = (fcoords_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_elem_set" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_fcoords_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fcoords_lelem_t_elem_set" "', argument " "2"" of type '" "fcoords_t *""'"); + } + arg2 = (fcoords_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + fcoords_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_elem_get" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + result = (fcoords_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + struct fcoords_lelem_t *arg2 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_next_set" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_fcoords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fcoords_lelem_t_next_set" "', argument " "2"" of type '" "struct fcoords_lelem_t *""'"); + } + arg2 = (struct fcoords_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct fcoords_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_lelem_t_next_get" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + result = (struct fcoords_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_fcoords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_fcoords_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct fcoords_lelem_t *)calloc(1, sizeof(struct fcoords_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_fcoords_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct fcoords_lelem_t *arg1 = (struct fcoords_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_fcoords_lelem_t" "', argument " "1"" of type '" "struct fcoords_lelem_t *""'"); + } + arg1 = (struct fcoords_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *fcoords_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_fcoords_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *fcoords_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_fcoords_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_init" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + fcoords_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + fcoords_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_list_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_push" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_fcoords_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fcoords_list_push" "', argument " "2"" of type '" "fcoords_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fcoords_list_push" "', argument " "2"" of type '" "fcoords_t""'"); + } else { + arg2 = *((fcoords_t *)(argp2)); + } + } + result = (int)fcoords_list_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + fcoords_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_pop" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + result = fcoords_list_pop(arg1); + resultobj = SWIG_NewPointerObj((fcoords_t *)memcpy((fcoords_t *)calloc(1,sizeof(fcoords_t)),&result,sizeof(fcoords_t)), SWIGTYPE_p_fcoords_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t arg1 = (fcoords_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_isempty" "', argument " "1"" of type '" "fcoords_list_t""'"); + } + arg1 = (fcoords_list_t)(argp1); + result = (int)fcoords_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_fcoords_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + fcoords_list_t *arg1 = (fcoords_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + fcoords_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "fcoords_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fcoords_list_toarray" "', argument " "1"" of type '" "fcoords_list_t *""'"); + } + arg1 = (fcoords_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "fcoords_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (fcoords_t *)fcoords_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_fcoords_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dSquaredEuclideanDT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + unsigned short *arg2 = (unsigned short *) 0 ; + int arg3 ; + int arg4 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dSquaredEuclideanDT", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dSquaredEuclideanDT" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_short, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dSquaredEuclideanDT" "', argument " "2"" of type '" "unsigned short *""'"); + } + arg2 = (unsigned short *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dSquaredEuclideanDT" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dSquaredEuclideanDT" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dSquaredEuclideanDT" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + result = (int)p3dSquaredEuclideanDT(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dThinning(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dThinning", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dThinning" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "p3dThinning" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "p3dThinning" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "p3dThinning" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + result = (int)p3dThinning(arg1,arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_ct_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "uint_lelem_t_ct_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_ct_set" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "uint_lelem_t_ct_set" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + if (arg1) (arg1)->ct = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_ct_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_ct_get" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + result = (unsigned int) ((arg1)->ct); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + struct uint_lelem_t *arg2 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "uint_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_next_set" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_uint_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "uint_lelem_t_next_set" "', argument " "2"" of type '" "struct uint_lelem_t *""'"); + } + arg2 = (struct uint_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct uint_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_lelem_t_next_get" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + result = (struct uint_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_uint_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_uint_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct uint_lelem_t *)calloc(1, sizeof(struct uint_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_uint_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_uint_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct uint_lelem_t *arg1 = (struct uint_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_uint_lelem_t" "', argument " "1"" of type '" "struct uint_lelem_t *""'"); + } + arg1 = (struct uint_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *uint_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_uint_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *uint_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_uint_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_init" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + uint_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "uint_list_add", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_add" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "uint_list_add" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + uint_list_add(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t arg1 = (uint_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_isempty" "', argument " "1"" of type '" "uint_list_t""'"); + } + arg1 = (uint_list_t)(argp1); + result = (int)uint_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + unsigned int *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "uint_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_toarray" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "uint_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (unsigned int *)uint_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_int, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_uint_list_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint_list_t *arg1 = (uint_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_uint_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "uint_list_clear" "', argument " "1"" of type '" "uint_list_t *""'"); + } + arg1 = (uint_list_t *)(argp1); + uint_list_clear(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dComputeCoreSkeleton(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_list_t arg1 = (crit_point_list_t) 0 ; + fcoords_list_t *arg2 = (fcoords_list_t *) 0 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + float *arg5 = (float *) 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + double arg9 ; + double arg10 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + double val9 ; + int ecode9 = 0 ; + double val10 ; + int ecode10 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dComputeCoreSkeleton", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dComputeCoreSkeleton" "', argument " "1"" of type '" "crit_point_list_t""'"); + } + arg1 = (crit_point_list_t)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dComputeCoreSkeleton" "', argument " "2"" of type '" "fcoords_list_t *""'"); + } + arg2 = (fcoords_list_t *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dComputeCoreSkeleton" "', argument " "3"" of type '" "float *""'"); + } + arg3 = (float *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dComputeCoreSkeleton" "', argument " "4"" of type '" "float *""'"); + } + arg4 = (float *)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "p3dComputeCoreSkeleton" "', argument " "5"" of type '" "float *""'"); + } + arg5 = (float *)(argp5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dComputeCoreSkeleton" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dComputeCoreSkeleton" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dComputeCoreSkeleton" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_double(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dComputeCoreSkeleton" "', argument " "9"" of type '" "double""'"); + } + arg9 = (double)(val9); + ecode10 = SWIG_AsVal_double(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dComputeCoreSkeleton" "', argument " "10"" of type '" "double""'"); + } + arg10 = (double)(val10); + result = (int)p3dComputeCoreSkeleton(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dComputeEigenVal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double *arg1 = (double *) 0 ; + double *arg2 = (double *) 0 ; + double *arg3 ; + double *arg4 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dComputeEigenVal", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dComputeEigenVal" "', argument " "1"" of type '" "double *""'"); + } + arg1 = (double *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dComputeEigenVal" "', argument " "2"" of type '" "double *""'"); + } + arg2 = (double *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dComputeEigenVal" "', argument " "3"" of type '" "double []""'"); + } + arg3 = (double *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dComputeEigenVal" "', argument " "4"" of type '" "double []""'"); + } + arg4 = (double *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dComputeEigenVal" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + result = (int)p3dComputeEigenVal(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dComputeHierarchicalSkeleton(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_list_t *arg1 = (highDiv_point_list_t *) 0 ; + fcoords_list_t *arg2 = (fcoords_list_t *) 0 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + float *arg5 = (float *) 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + double arg9 ; + double arg10 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + double val9 ; + int ecode9 = 0 ; + double val10 ; + int ecode10 = 0 ; + PyObject *swig_obj[10] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dComputeHierarchicalSkeleton", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "1"" of type '" "highDiv_point_list_t *""'"); + } + arg1 = (highDiv_point_list_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_fcoords_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "2"" of type '" "fcoords_list_t *""'"); + } + arg2 = (fcoords_list_t *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "3"" of type '" "float *""'"); + } + arg3 = (float *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "4"" of type '" "float *""'"); + } + arg4 = (float *)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "5"" of type '" "float *""'"); + } + arg5 = (float *)(argp5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_double(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "9"" of type '" "double""'"); + } + arg9 = (double)(val9); + ecode10 = SWIG_AsVal_double(swig_obj[9], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "p3dComputeHierarchicalSkeleton" "', argument " "10"" of type '" "double""'"); + } + arg10 = (double)(val10); + result = (int)p3dComputeHierarchicalSkeleton(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGetCriticalPoints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + float *arg2 = (float *) 0 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + crit_point_list_t *arg8 = (crit_point_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + void *argp8 = 0 ; + int res8 = 0 ; + PyObject *swig_obj[8] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetCriticalPoints", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGetCriticalPoints" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGetCriticalPoints" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dGetCriticalPoints" "', argument " "3"" of type '" "float *""'"); + } + arg3 = (float *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dGetCriticalPoints" "', argument " "4"" of type '" "float *""'"); + } + arg4 = (float *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGetCriticalPoints" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGetCriticalPoints" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGetCriticalPoints" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + res8 = SWIG_ConvertPtr(swig_obj[7], &argp8,SWIGTYPE_p_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "p3dGetCriticalPoints" "', argument " "8"" of type '" "crit_point_list_t *""'"); + } + arg8 = (crit_point_list_t *)(argp8); + result = (int)p3dGetCriticalPoints(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dClassifyCriticalPoints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_list_t arg1 = (crit_point_list_t) 0 ; + float *arg2 = (float *) 0 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dClassifyCriticalPoints", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dClassifyCriticalPoints" "', argument " "1"" of type '" "crit_point_list_t""'"); + } + arg1 = (crit_point_list_t)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dClassifyCriticalPoints" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dClassifyCriticalPoints" "', argument " "3"" of type '" "float *""'"); + } + arg3 = (float *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dClassifyCriticalPoints" "', argument " "4"" of type '" "float *""'"); + } + arg4 = (float *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dClassifyCriticalPoints" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dClassifyCriticalPoints" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dClassifyCriticalPoints" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (int)p3dClassifyCriticalPoints(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct crit_point_lelem_t *arg1 = (struct crit_point_lelem_t *) 0 ; + crit_point_t *arg2 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_lelem_t_elem_set" "', argument " "1"" of type '" "struct crit_point_lelem_t *""'"); + } + arg1 = (struct crit_point_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "crit_point_lelem_t_elem_set" "', argument " "2"" of type '" "crit_point_t *""'"); + } + arg2 = (crit_point_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct crit_point_lelem_t *arg1 = (struct crit_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + crit_point_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_lelem_t_elem_get" "', argument " "1"" of type '" "struct crit_point_lelem_t *""'"); + } + arg1 = (struct crit_point_lelem_t *)(argp1); + result = (crit_point_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_crit_point_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct crit_point_lelem_t *arg1 = (struct crit_point_lelem_t *) 0 ; + struct crit_point_lelem_t *arg2 = (struct crit_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_lelem_t_next_set" "', argument " "1"" of type '" "struct crit_point_lelem_t *""'"); + } + arg1 = (struct crit_point_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_crit_point_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "crit_point_lelem_t_next_set" "', argument " "2"" of type '" "struct crit_point_lelem_t *""'"); + } + arg2 = (struct crit_point_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct crit_point_lelem_t *arg1 = (struct crit_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct crit_point_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_lelem_t_next_get" "', argument " "1"" of type '" "struct crit_point_lelem_t *""'"); + } + arg1 = (struct crit_point_lelem_t *)(argp1); + result = (struct crit_point_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_crit_point_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct crit_point_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_crit_point_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct crit_point_lelem_t *)calloc(1, sizeof(struct crit_point_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_crit_point_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_crit_point_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct crit_point_lelem_t *arg1 = (struct crit_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_crit_point_lelem_t" "', argument " "1"" of type '" "struct crit_point_lelem_t *""'"); + } + arg1 = (struct crit_point_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *crit_point_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_crit_point_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *crit_point_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_crit_point_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_list_t *arg1 = (crit_point_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_list_init" "', argument " "1"" of type '" "crit_point_list_t *""'"); + } + arg1 = (crit_point_list_t *)(argp1); + crit_point_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_list_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_list_t *arg1 = (crit_point_list_t *) 0 ; + crit_point_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_list_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_list_push" "', argument " "1"" of type '" "crit_point_list_t *""'"); + } + arg1 = (crit_point_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_crit_point_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "crit_point_list_push" "', argument " "2"" of type '" "crit_point_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "crit_point_list_push" "', argument " "2"" of type '" "crit_point_t""'"); + } else { + arg2 = *((crit_point_t *)(argp2)); + } + } + result = (int)crit_point_list_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_list_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_list_t *arg1 = (crit_point_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + crit_point_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_list_pop" "', argument " "1"" of type '" "crit_point_list_t *""'"); + } + arg1 = (crit_point_list_t *)(argp1); + result = crit_point_list_pop(arg1); + resultobj = SWIG_NewPointerObj((crit_point_t *)memcpy((crit_point_t *)calloc(1,sizeof(crit_point_t)),&result,sizeof(crit_point_t)), SWIGTYPE_p_crit_point_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_list_t arg1 = (crit_point_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_list_isempty" "', argument " "1"" of type '" "crit_point_list_t""'"); + } + arg1 = (crit_point_list_t)(argp1); + result = (int)crit_point_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_x_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_x_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_y_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_y_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_z_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_z_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_type_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_type_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_type_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_type_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->type = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_type_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_type_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (int) ((arg1)->type); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_eval0_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_eval0_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_eval0_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_eval0_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->eval0 = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_eval0_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_eval0_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->eval0); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_eval1_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_eval1_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_eval1_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_eval1_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->eval1 = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_eval1_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_eval1_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->eval1); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_eval2_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_eval2_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_eval2_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_eval2_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->eval2 = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_eval2_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_eval2_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->eval2); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect0_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect0_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect0_x_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect0_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect0_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect0_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect0_x_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect0_x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect0_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect0_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect0_y_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect0_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect0_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect0_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect0_y_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect0_y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect0_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect0_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect0_z_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect0_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect0_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect0_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect0_z_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect0_z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect1_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect1_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect1_x_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect1_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect1_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect1_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect1_x_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect1_x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect1_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect1_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect1_y_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect1_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect1_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect1_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect1_y_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect1_y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect1_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect1_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect1_z_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect1_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect1_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect1_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect1_z_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect1_z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect2_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect2_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect2_x_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect2_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect2_x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect2_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect2_x_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect2_x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect2_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect2_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect2_y_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect2_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect2_y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect2_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect2_y_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect2_y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect2_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "crit_point_t_evect2_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect2_z_set" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "crit_point_t_evect2_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->evect2_z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_crit_point_t_evect2_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "crit_point_t_evect2_z_get" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + result = (double) ((arg1)->evect2_z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_crit_point_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_crit_point_t", 0, 0, 0)) SWIG_fail; + result = (crit_point_t *)calloc(1, sizeof(crit_point_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_crit_point_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_crit_point_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + crit_point_t *arg1 = (crit_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_crit_point_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_crit_point_t" "', argument " "1"" of type '" "crit_point_t *""'"); + } + arg1 = (crit_point_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *crit_point_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_crit_point_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *crit_point_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_p3dGetHighDivPoints(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + float *arg2 = (float *) 0 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + double arg8 ; + highDiv_point_list_t *arg9 = (highDiv_point_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + void *argp9 = 0 ; + int res9 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGetHighDivPoints", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGetHighDivPoints" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGetHighDivPoints" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dGetHighDivPoints" "', argument " "3"" of type '" "float *""'"); + } + arg3 = (float *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dGetHighDivPoints" "', argument " "4"" of type '" "float *""'"); + } + arg4 = (float *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGetHighDivPoints" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGetHighDivPoints" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGetHighDivPoints" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dGetHighDivPoints" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + res9 = SWIG_ConvertPtr(swig_obj[8], &argp9,SWIGTYPE_p_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "p3dGetHighDivPoints" "', argument " "9"" of type '" "highDiv_point_list_t *""'"); + } + arg9 = (highDiv_point_list_t *)(argp9); + result = (int)p3dGetHighDivPoints(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_p3dGVF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + unsigned char *arg1 = (unsigned char *) 0 ; + float *arg2 = (float *) 0 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + double arg8 ; + double arg9 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + double val9 ; + int ecode9 = 0 ; + PyObject *swig_obj[9] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "p3dGVF", 9, 9, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "p3dGVF" "', argument " "1"" of type '" "unsigned char *""'"); + } + arg1 = (unsigned char *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "p3dGVF" "', argument " "2"" of type '" "float *""'"); + } + arg2 = (float *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "p3dGVF" "', argument " "3"" of type '" "float *""'"); + } + arg3 = (float *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "p3dGVF" "', argument " "4"" of type '" "float *""'"); + } + arg4 = (float *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "p3dGVF" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "p3dGVF" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "p3dGVF" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_double(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "p3dGVF" "', argument " "8"" of type '" "double""'"); + } + arg8 = (double)(val8); + ecode9 = SWIG_AsVal_double(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "p3dGVF" "', argument " "9"" of type '" "double""'"); + } + arg9 = (double)(val9); + result = (int)p3dGVF(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_lelem_t_elem_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct highDiv_point_lelem_t *arg1 = (struct highDiv_point_lelem_t *) 0 ; + highDiv_point_t *arg2 = (highDiv_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_lelem_t_elem_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_lelem_t_elem_set" "', argument " "1"" of type '" "struct highDiv_point_lelem_t *""'"); + } + arg1 = (struct highDiv_point_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "highDiv_point_lelem_t_elem_set" "', argument " "2"" of type '" "highDiv_point_t *""'"); + } + arg2 = (highDiv_point_t *)(argp2); + if (arg1) (arg1)->elem = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_lelem_t_elem_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct highDiv_point_lelem_t *arg1 = (struct highDiv_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + highDiv_point_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_lelem_t_elem_get" "', argument " "1"" of type '" "struct highDiv_point_lelem_t *""'"); + } + arg1 = (struct highDiv_point_lelem_t *)(argp1); + result = (highDiv_point_t *)& ((arg1)->elem); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_lelem_t_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct highDiv_point_lelem_t *arg1 = (struct highDiv_point_lelem_t *) 0 ; + struct highDiv_point_lelem_t *arg2 = (struct highDiv_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_lelem_t_next_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_lelem_t_next_set" "', argument " "1"" of type '" "struct highDiv_point_lelem_t *""'"); + } + arg1 = (struct highDiv_point_lelem_t *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_highDiv_point_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "highDiv_point_lelem_t_next_set" "', argument " "2"" of type '" "struct highDiv_point_lelem_t *""'"); + } + arg2 = (struct highDiv_point_lelem_t *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_lelem_t_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct highDiv_point_lelem_t *arg1 = (struct highDiv_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct highDiv_point_lelem_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_lelem_t_next_get" "', argument " "1"" of type '" "struct highDiv_point_lelem_t *""'"); + } + arg1 = (struct highDiv_point_lelem_t *)(argp1); + result = (struct highDiv_point_lelem_t *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_highDiv_point_lelem_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_highDiv_point_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct highDiv_point_lelem_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_highDiv_point_lelem_t", 0, 0, 0)) SWIG_fail; + result = (struct highDiv_point_lelem_t *)calloc(1, sizeof(struct highDiv_point_lelem_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_highDiv_point_lelem_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_highDiv_point_lelem_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct highDiv_point_lelem_t *arg1 = (struct highDiv_point_lelem_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_lelem_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_highDiv_point_lelem_t" "', argument " "1"" of type '" "struct highDiv_point_lelem_t *""'"); + } + arg1 = (struct highDiv_point_lelem_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *highDiv_point_lelem_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_highDiv_point_lelem_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *highDiv_point_lelem_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_highDiv_point_list_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_list_t *arg1 = (highDiv_point_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_list_init" "', argument " "1"" of type '" "highDiv_point_list_t *""'"); + } + arg1 = (highDiv_point_list_t *)(argp1); + highDiv_point_list_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_list_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_list_t *arg1 = (highDiv_point_list_t *) 0 ; + highDiv_point_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_list_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_list_push" "', argument " "1"" of type '" "highDiv_point_list_t *""'"); + } + arg1 = (highDiv_point_list_t *)(argp1); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_highDiv_point_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "highDiv_point_list_push" "', argument " "2"" of type '" "highDiv_point_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "highDiv_point_list_push" "', argument " "2"" of type '" "highDiv_point_t""'"); + } else { + arg2 = *((highDiv_point_t *)(argp2)); + } + } + result = (int)highDiv_point_list_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_list_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_list_t *arg1 = (highDiv_point_list_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + highDiv_point_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_list_pop" "', argument " "1"" of type '" "highDiv_point_list_t *""'"); + } + arg1 = (highDiv_point_list_t *)(argp1); + result = highDiv_point_list_pop(arg1); + resultobj = SWIG_NewPointerObj((highDiv_point_t *)memcpy((highDiv_point_t *)calloc(1,sizeof(highDiv_point_t)),&result,sizeof(highDiv_point_t)), SWIGTYPE_p_highDiv_point_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_list_isempty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_list_t arg1 = (highDiv_point_list_t) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_list_isempty" "', argument " "1"" of type '" "highDiv_point_list_t""'"); + } + arg1 = (highDiv_point_list_t)(argp1); + result = (int)highDiv_point_list_isempty(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_list_toarray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_list_t *arg1 = (highDiv_point_list_t *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + highDiv_point_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_list_toarray", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_highDiv_point_lelem_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_list_toarray" "', argument " "1"" of type '" "highDiv_point_list_t *""'"); + } + arg1 = (highDiv_point_list_t *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "highDiv_point_list_toarray" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (highDiv_point_t *)highDiv_point_list_toarray(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_t_x_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_x_set" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "highDiv_point_t_x_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->x = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_x_get" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + result = (double) ((arg1)->x); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_t_y_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_y_set" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "highDiv_point_t_y_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->y = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_y_get" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + result = (double) ((arg1)->y); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_z_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_t_z_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_z_set" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "highDiv_point_t_z_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->z = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_z_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_z_get" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + result = (double) ((arg1)->z); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_div_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "highDiv_point_t_div_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_div_set" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "highDiv_point_t_div_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + if (arg1) (arg1)->div = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_highDiv_point_t_div_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + double result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "highDiv_point_t_div_get" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + result = (double) ((arg1)->div); + resultobj = SWIG_From_double((double)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_highDiv_point_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "new_highDiv_point_t", 0, 0, 0)) SWIG_fail; + result = (highDiv_point_t *)calloc(1, sizeof(highDiv_point_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_highDiv_point_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_highDiv_point_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + highDiv_point_t *arg1 = (highDiv_point_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_highDiv_point_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_highDiv_point_t" "', argument " "1"" of type '" "highDiv_point_t *""'"); + } + arg1 = (highDiv_point_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *highDiv_point_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_highDiv_point_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *highDiv_point_t_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +static PyMethodDef SwigMethods[] = { + { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, + { "cdata", _wrap_cdata, METH_VARARGS, NULL}, + { "memmove", _wrap_memmove, METH_VARARGS, NULL}, + { "malloc_uchar", _wrap_malloc_uchar, METH_VARARGS, NULL}, + { "calloc_uchar", _wrap_calloc_uchar, METH_VARARGS, NULL}, + { "realloc_uchar", _wrap_realloc_uchar, METH_VARARGS, NULL}, + { "free_uchar", _wrap_free_uchar, METH_O, NULL}, + { "malloc_ushort", _wrap_malloc_ushort, METH_VARARGS, NULL}, + { "calloc_ushort", _wrap_calloc_ushort, METH_VARARGS, NULL}, + { "realloc_ushort", _wrap_realloc_ushort, METH_VARARGS, NULL}, + { "free_ushort", _wrap_free_ushort, METH_O, NULL}, + { "malloc_PSkeletonStats", _wrap_malloc_PSkeletonStats, METH_VARARGS, NULL}, + { "calloc_PSkeletonStats", _wrap_calloc_PSkeletonStats, METH_VARARGS, NULL}, + { "realloc_PSkeletonStats", _wrap_realloc_PSkeletonStats, METH_VARARGS, NULL}, + { "free_PSkeletonStats", _wrap_free_PSkeletonStats, METH_O, NULL}, + { "PrintSkelStruct", _wrap_PrintSkelStruct, METH_VARARGS, NULL}, + { "SkeletonStats_ConnectivityDensity_set", _wrap_SkeletonStats_ConnectivityDensity_set, METH_VARARGS, NULL}, + { "SkeletonStats_ConnectivityDensity_get", _wrap_SkeletonStats_ConnectivityDensity_get, METH_O, NULL}, + { "SkeletonStats_CoordinationNumber_set", _wrap_SkeletonStats_CoordinationNumber_set, METH_VARARGS, NULL}, + { "SkeletonStats_CoordinationNumber_get", _wrap_SkeletonStats_CoordinationNumber_get, METH_O, NULL}, + { "SkeletonStats_End_Counter_set", _wrap_SkeletonStats_End_Counter_set, METH_VARARGS, NULL}, + { "SkeletonStats_End_Counter_get", _wrap_SkeletonStats_End_Counter_get, METH_O, NULL}, + { "SkeletonStats_End_Width_set", _wrap_SkeletonStats_End_Width_set, METH_VARARGS, NULL}, + { "SkeletonStats_End_Width_get", _wrap_SkeletonStats_End_Width_get, METH_O, NULL}, + { "SkeletonStats_EndToEnd_Counter_set", _wrap_SkeletonStats_EndToEnd_Counter_set, METH_VARARGS, NULL}, + { "SkeletonStats_EndToEnd_Counter_get", _wrap_SkeletonStats_EndToEnd_Counter_get, METH_O, NULL}, + { "SkeletonStats_EndToEnd_Length_set", _wrap_SkeletonStats_EndToEnd_Length_set, METH_VARARGS, NULL}, + { "SkeletonStats_EndToEnd_Length_get", _wrap_SkeletonStats_EndToEnd_Length_get, METH_O, NULL}, + { "SkeletonStats_EndToEnd_MaxWidth_set", _wrap_SkeletonStats_EndToEnd_MaxWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_EndToEnd_MaxWidth_get", _wrap_SkeletonStats_EndToEnd_MaxWidth_get, METH_O, NULL}, + { "SkeletonStats_EndToEnd_MeanWidth_set", _wrap_SkeletonStats_EndToEnd_MeanWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_EndToEnd_MeanWidth_get", _wrap_SkeletonStats_EndToEnd_MeanWidth_get, METH_O, NULL}, + { "SkeletonStats_EndToEnd_MinWidth_set", _wrap_SkeletonStats_EndToEnd_MinWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_EndToEnd_MinWidth_get", _wrap_SkeletonStats_EndToEnd_MinWidth_get, METH_O, NULL}, + { "SkeletonStats_NodeToEnd_Counter_set", _wrap_SkeletonStats_NodeToEnd_Counter_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToEnd_Counter_get", _wrap_SkeletonStats_NodeToEnd_Counter_get, METH_O, NULL}, + { "SkeletonStats_NodeToEnd_Length_set", _wrap_SkeletonStats_NodeToEnd_Length_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToEnd_Length_get", _wrap_SkeletonStats_NodeToEnd_Length_get, METH_O, NULL}, + { "SkeletonStats_NodeToEnd_MaxWidth_set", _wrap_SkeletonStats_NodeToEnd_MaxWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToEnd_MaxWidth_get", _wrap_SkeletonStats_NodeToEnd_MaxWidth_get, METH_O, NULL}, + { "SkeletonStats_NodeToEnd_MeanWidth_set", _wrap_SkeletonStats_NodeToEnd_MeanWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToEnd_MeanWidth_get", _wrap_SkeletonStats_NodeToEnd_MeanWidth_get, METH_O, NULL}, + { "SkeletonStats_NodeToEnd_MinWidth_set", _wrap_SkeletonStats_NodeToEnd_MinWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToEnd_MinWidth_get", _wrap_SkeletonStats_NodeToEnd_MinWidth_get, METH_O, NULL}, + { "SkeletonStats_NodeToNode_Counter_set", _wrap_SkeletonStats_NodeToNode_Counter_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToNode_Counter_get", _wrap_SkeletonStats_NodeToNode_Counter_get, METH_O, NULL}, + { "SkeletonStats_NodeToNode_Length_set", _wrap_SkeletonStats_NodeToNode_Length_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToNode_Length_get", _wrap_SkeletonStats_NodeToNode_Length_get, METH_O, NULL}, + { "SkeletonStats_NodeToNode_MaxWidth_set", _wrap_SkeletonStats_NodeToNode_MaxWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToNode_MaxWidth_get", _wrap_SkeletonStats_NodeToNode_MaxWidth_get, METH_O, NULL}, + { "SkeletonStats_NodeToNode_MeanWidth_set", _wrap_SkeletonStats_NodeToNode_MeanWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToNode_MeanWidth_get", _wrap_SkeletonStats_NodeToNode_MeanWidth_get, METH_O, NULL}, + { "SkeletonStats_NodeToNode_MinWidth_set", _wrap_SkeletonStats_NodeToNode_MinWidth_set, METH_VARARGS, NULL}, + { "SkeletonStats_NodeToNode_MinWidth_get", _wrap_SkeletonStats_NodeToNode_MinWidth_get, METH_O, NULL}, + { "SkeletonStats_Node_Counter_set", _wrap_SkeletonStats_Node_Counter_set, METH_VARARGS, NULL}, + { "SkeletonStats_Node_Counter_get", _wrap_SkeletonStats_Node_Counter_get, METH_O, NULL}, + { "SkeletonStats_Node_Width_set", _wrap_SkeletonStats_Node_Width_set, METH_VARARGS, NULL}, + { "SkeletonStats_Node_Width_get", _wrap_SkeletonStats_Node_Width_get, METH_O, NULL}, + { "new_SkeletonStats", _wrap_new_SkeletonStats, METH_NOARGS, NULL}, + { "delete_SkeletonStats", _wrap_delete_SkeletonStats, METH_O, NULL}, + { "SkeletonStats_swigregister", SkeletonStats_swigregister, METH_O, NULL}, + { "SkeletonStats_swiginit", SkeletonStats_swiginit, METH_VARARGS, NULL}, + { "p3dGVFSkeletonization", _wrap_p3dGVFSkeletonization, METH_VARARGS, NULL}, + { "p3dThinningSkeletonization", _wrap_p3dThinningSkeletonization, METH_VARARGS, NULL}, + { "p3dLKCSkeletonization", _wrap_p3dLKCSkeletonization, METH_VARARGS, NULL}, + { "p3dSimpleSkeletonPruning", _wrap_p3dSimpleSkeletonPruning, METH_VARARGS, NULL}, + { "p3dIterativeSkeletonPruning", _wrap_p3dIterativeSkeletonPruning, METH_VARARGS, NULL}, + { "p3dUltimateSkeletonPruning", _wrap_p3dUltimateSkeletonPruning, METH_VARARGS, NULL}, + { "p3dSkeletonLabeling", _wrap_p3dSkeletonLabeling, METH_VARARGS, NULL}, + { "p3dSkeletonAnalysis", _wrap_p3dSkeletonAnalysis, METH_VARARGS, NULL}, + { "p3dSkeletonAnalysisFeasibility", _wrap_p3dSkeletonAnalysisFeasibility, METH_VARARGS, NULL}, + { "p3dResetStartTime", _wrap_p3dResetStartTime, METH_NOARGS, NULL}, + { "p3dGetElapsedTime", _wrap_p3dGetElapsedTime, METH_NOARGS, NULL}, + { "p3dGetElapsedTime_min", _wrap_p3dGetElapsedTime_min, METH_NOARGS, NULL}, + { "p3dGetElapsedTime_sec", _wrap_p3dGetElapsedTime_sec, METH_NOARGS, NULL}, + { "bb_t_min_x_set", _wrap_bb_t_min_x_set, METH_VARARGS, NULL}, + { "bb_t_min_x_get", _wrap_bb_t_min_x_get, METH_O, NULL}, + { "bb_t_max_x_set", _wrap_bb_t_max_x_set, METH_VARARGS, NULL}, + { "bb_t_max_x_get", _wrap_bb_t_max_x_get, METH_O, NULL}, + { "bb_t_min_y_set", _wrap_bb_t_min_y_set, METH_VARARGS, NULL}, + { "bb_t_min_y_get", _wrap_bb_t_min_y_get, METH_O, NULL}, + { "bb_t_max_y_set", _wrap_bb_t_max_y_set, METH_VARARGS, NULL}, + { "bb_t_max_y_get", _wrap_bb_t_max_y_get, METH_O, NULL}, + { "bb_t_min_z_set", _wrap_bb_t_min_z_set, METH_VARARGS, NULL}, + { "bb_t_min_z_get", _wrap_bb_t_min_z_get, METH_O, NULL}, + { "bb_t_max_z_set", _wrap_bb_t_max_z_set, METH_VARARGS, NULL}, + { "bb_t_max_z_get", _wrap_bb_t_max_z_get, METH_O, NULL}, + { "new_bb_t", _wrap_new_bb_t, METH_NOARGS, NULL}, + { "delete_bb_t", _wrap_delete_bb_t, METH_O, NULL}, + { "bb_t_swigregister", bb_t_swigregister, METH_O, NULL}, + { "bb_t_swiginit", bb_t_swiginit, METH_VARARGS, NULL}, + { "p3dConnectedComponentsLabeling", _wrap_p3dConnectedComponentsLabeling, METH_VARARGS, NULL}, + { "p3dGetMaxVolumeRegion", _wrap_p3dGetMaxVolumeRegion, METH_VARARGS, NULL}, + { "coords_lelem_t_elem_set", _wrap_coords_lelem_t_elem_set, METH_VARARGS, NULL}, + { "coords_lelem_t_elem_get", _wrap_coords_lelem_t_elem_get, METH_O, NULL}, + { "coords_lelem_t_next_set", _wrap_coords_lelem_t_next_set, METH_VARARGS, NULL}, + { "coords_lelem_t_next_get", _wrap_coords_lelem_t_next_get, METH_O, NULL}, + { "new_coords_lelem_t", _wrap_new_coords_lelem_t, METH_NOARGS, NULL}, + { "delete_coords_lelem_t", _wrap_delete_coords_lelem_t, METH_O, NULL}, + { "coords_lelem_t_swigregister", coords_lelem_t_swigregister, METH_O, NULL}, + { "coords_lelem_t_swiginit", coords_lelem_t_swiginit, METH_VARARGS, NULL}, + { "coords_list_init", _wrap_coords_list_init, METH_O, NULL}, + { "coords_list_push", _wrap_coords_list_push, METH_VARARGS, NULL}, + { "coords_list_pop", _wrap_coords_list_pop, METH_O, NULL}, + { "coords_list_isempty", _wrap_coords_list_isempty, METH_O, NULL}, + { "coords_list_toarray", _wrap_coords_list_toarray, METH_VARARGS, NULL}, + { "coords_qelem_t_item_set", _wrap_coords_qelem_t_item_set, METH_VARARGS, NULL}, + { "coords_qelem_t_item_get", _wrap_coords_qelem_t_item_get, METH_O, NULL}, + { "coords_qelem_t_next_set", _wrap_coords_qelem_t_next_set, METH_VARARGS, NULL}, + { "coords_qelem_t_next_get", _wrap_coords_qelem_t_next_get, METH_O, NULL}, + { "new_coords_qelem_t", _wrap_new_coords_qelem_t, METH_NOARGS, NULL}, + { "delete_coords_qelem_t", _wrap_delete_coords_qelem_t, METH_O, NULL}, + { "coords_qelem_t_swigregister", coords_qelem_t_swigregister, METH_O, NULL}, + { "coords_qelem_t_swiginit", coords_qelem_t_swiginit, METH_VARARGS, NULL}, + { "coords_queue_t_tail_set", _wrap_coords_queue_t_tail_set, METH_VARARGS, NULL}, + { "coords_queue_t_tail_get", _wrap_coords_queue_t_tail_get, METH_O, NULL}, + { "coords_queue_t_head_set", _wrap_coords_queue_t_head_set, METH_VARARGS, NULL}, + { "coords_queue_t_head_get", _wrap_coords_queue_t_head_get, METH_O, NULL}, + { "new_coords_queue_t", _wrap_new_coords_queue_t, METH_NOARGS, NULL}, + { "delete_coords_queue_t", _wrap_delete_coords_queue_t, METH_O, NULL}, + { "coords_queue_t_swigregister", coords_queue_t_swigregister, METH_O, NULL}, + { "coords_queue_t_swiginit", coords_queue_t_swiginit, METH_VARARGS, NULL}, + { "coords_queue_init", _wrap_coords_queue_init, METH_O, NULL}, + { "coords_queue_push", _wrap_coords_queue_push, METH_VARARGS, NULL}, + { "coords_queue_pop", _wrap_coords_queue_pop, METH_O, NULL}, + { "coords_queue_isempty", _wrap_coords_queue_isempty, METH_O, NULL}, + { "coords_t_x_set", _wrap_coords_t_x_set, METH_VARARGS, NULL}, + { "coords_t_x_get", _wrap_coords_t_x_get, METH_O, NULL}, + { "coords_t_y_set", _wrap_coords_t_y_set, METH_VARARGS, NULL}, + { "coords_t_y_get", _wrap_coords_t_y_get, METH_O, NULL}, + { "coords_t_z_set", _wrap_coords_t_z_set, METH_VARARGS, NULL}, + { "coords_t_z_get", _wrap_coords_t_z_get, METH_O, NULL}, + { "new_coords_t", _wrap_new_coords_t, METH_NOARGS, NULL}, + { "delete_coords_t", _wrap_delete_coords_t, METH_O, NULL}, + { "coords_t_swigregister", coords_t_swigregister, METH_O, NULL}, + { "coords_t_swiginit", coords_t_swiginit, METH_VARARGS, NULL}, + { "fcoords_t_x_set", _wrap_fcoords_t_x_set, METH_VARARGS, NULL}, + { "fcoords_t_x_get", _wrap_fcoords_t_x_get, METH_O, NULL}, + { "fcoords_t_y_set", _wrap_fcoords_t_y_set, METH_VARARGS, NULL}, + { "fcoords_t_y_get", _wrap_fcoords_t_y_get, METH_O, NULL}, + { "fcoords_t_z_set", _wrap_fcoords_t_z_set, METH_VARARGS, NULL}, + { "fcoords_t_z_get", _wrap_fcoords_t_z_get, METH_O, NULL}, + { "new_fcoords_t", _wrap_new_fcoords_t, METH_NOARGS, NULL}, + { "delete_fcoords_t", _wrap_delete_fcoords_t, METH_O, NULL}, + { "fcoords_t_swigregister", fcoords_t_swigregister, METH_O, NULL}, + { "fcoords_t_swiginit", fcoords_t_swiginit, METH_VARARGS, NULL}, + { "fcoords_lelem_t_elem_set", _wrap_fcoords_lelem_t_elem_set, METH_VARARGS, NULL}, + { "fcoords_lelem_t_elem_get", _wrap_fcoords_lelem_t_elem_get, METH_O, NULL}, + { "fcoords_lelem_t_next_set", _wrap_fcoords_lelem_t_next_set, METH_VARARGS, NULL}, + { "fcoords_lelem_t_next_get", _wrap_fcoords_lelem_t_next_get, METH_O, NULL}, + { "new_fcoords_lelem_t", _wrap_new_fcoords_lelem_t, METH_NOARGS, NULL}, + { "delete_fcoords_lelem_t", _wrap_delete_fcoords_lelem_t, METH_O, NULL}, + { "fcoords_lelem_t_swigregister", fcoords_lelem_t_swigregister, METH_O, NULL}, + { "fcoords_lelem_t_swiginit", fcoords_lelem_t_swiginit, METH_VARARGS, NULL}, + { "fcoords_list_init", _wrap_fcoords_list_init, METH_O, NULL}, + { "fcoords_list_push", _wrap_fcoords_list_push, METH_VARARGS, NULL}, + { "fcoords_list_pop", _wrap_fcoords_list_pop, METH_O, NULL}, + { "fcoords_list_isempty", _wrap_fcoords_list_isempty, METH_O, NULL}, + { "fcoords_list_toarray", _wrap_fcoords_list_toarray, METH_VARARGS, NULL}, + { "p3dSquaredEuclideanDT", _wrap_p3dSquaredEuclideanDT, METH_VARARGS, NULL}, + { "p3dThinning", _wrap_p3dThinning, METH_VARARGS, NULL}, + { "uint_lelem_t_ct_set", _wrap_uint_lelem_t_ct_set, METH_VARARGS, NULL}, + { "uint_lelem_t_ct_get", _wrap_uint_lelem_t_ct_get, METH_O, NULL}, + { "uint_lelem_t_next_set", _wrap_uint_lelem_t_next_set, METH_VARARGS, NULL}, + { "uint_lelem_t_next_get", _wrap_uint_lelem_t_next_get, METH_O, NULL}, + { "new_uint_lelem_t", _wrap_new_uint_lelem_t, METH_NOARGS, NULL}, + { "delete_uint_lelem_t", _wrap_delete_uint_lelem_t, METH_O, NULL}, + { "uint_lelem_t_swigregister", uint_lelem_t_swigregister, METH_O, NULL}, + { "uint_lelem_t_swiginit", uint_lelem_t_swiginit, METH_VARARGS, NULL}, + { "uint_list_init", _wrap_uint_list_init, METH_O, NULL}, + { "uint_list_add", _wrap_uint_list_add, METH_VARARGS, NULL}, + { "uint_list_isempty", _wrap_uint_list_isempty, METH_O, NULL}, + { "uint_list_toarray", _wrap_uint_list_toarray, METH_VARARGS, NULL}, + { "uint_list_clear", _wrap_uint_list_clear, METH_O, NULL}, + { "p3dComputeCoreSkeleton", _wrap_p3dComputeCoreSkeleton, METH_VARARGS, NULL}, + { "p3dComputeEigenVal", _wrap_p3dComputeEigenVal, METH_VARARGS, NULL}, + { "p3dComputeHierarchicalSkeleton", _wrap_p3dComputeHierarchicalSkeleton, METH_VARARGS, NULL}, + { "p3dGetCriticalPoints", _wrap_p3dGetCriticalPoints, METH_VARARGS, NULL}, + { "p3dClassifyCriticalPoints", _wrap_p3dClassifyCriticalPoints, METH_VARARGS, NULL}, + { "crit_point_lelem_t_elem_set", _wrap_crit_point_lelem_t_elem_set, METH_VARARGS, NULL}, + { "crit_point_lelem_t_elem_get", _wrap_crit_point_lelem_t_elem_get, METH_O, NULL}, + { "crit_point_lelem_t_next_set", _wrap_crit_point_lelem_t_next_set, METH_VARARGS, NULL}, + { "crit_point_lelem_t_next_get", _wrap_crit_point_lelem_t_next_get, METH_O, NULL}, + { "new_crit_point_lelem_t", _wrap_new_crit_point_lelem_t, METH_NOARGS, NULL}, + { "delete_crit_point_lelem_t", _wrap_delete_crit_point_lelem_t, METH_O, NULL}, + { "crit_point_lelem_t_swigregister", crit_point_lelem_t_swigregister, METH_O, NULL}, + { "crit_point_lelem_t_swiginit", crit_point_lelem_t_swiginit, METH_VARARGS, NULL}, + { "crit_point_list_init", _wrap_crit_point_list_init, METH_O, NULL}, + { "crit_point_list_push", _wrap_crit_point_list_push, METH_VARARGS, NULL}, + { "crit_point_list_pop", _wrap_crit_point_list_pop, METH_O, NULL}, + { "crit_point_list_isempty", _wrap_crit_point_list_isempty, METH_O, NULL}, + { "crit_point_t_x_set", _wrap_crit_point_t_x_set, METH_VARARGS, NULL}, + { "crit_point_t_x_get", _wrap_crit_point_t_x_get, METH_O, NULL}, + { "crit_point_t_y_set", _wrap_crit_point_t_y_set, METH_VARARGS, NULL}, + { "crit_point_t_y_get", _wrap_crit_point_t_y_get, METH_O, NULL}, + { "crit_point_t_z_set", _wrap_crit_point_t_z_set, METH_VARARGS, NULL}, + { "crit_point_t_z_get", _wrap_crit_point_t_z_get, METH_O, NULL}, + { "crit_point_t_type_set", _wrap_crit_point_t_type_set, METH_VARARGS, NULL}, + { "crit_point_t_type_get", _wrap_crit_point_t_type_get, METH_O, NULL}, + { "crit_point_t_eval0_set", _wrap_crit_point_t_eval0_set, METH_VARARGS, NULL}, + { "crit_point_t_eval0_get", _wrap_crit_point_t_eval0_get, METH_O, NULL}, + { "crit_point_t_eval1_set", _wrap_crit_point_t_eval1_set, METH_VARARGS, NULL}, + { "crit_point_t_eval1_get", _wrap_crit_point_t_eval1_get, METH_O, NULL}, + { "crit_point_t_eval2_set", _wrap_crit_point_t_eval2_set, METH_VARARGS, NULL}, + { "crit_point_t_eval2_get", _wrap_crit_point_t_eval2_get, METH_O, NULL}, + { "crit_point_t_evect0_x_set", _wrap_crit_point_t_evect0_x_set, METH_VARARGS, NULL}, + { "crit_point_t_evect0_x_get", _wrap_crit_point_t_evect0_x_get, METH_O, NULL}, + { "crit_point_t_evect0_y_set", _wrap_crit_point_t_evect0_y_set, METH_VARARGS, NULL}, + { "crit_point_t_evect0_y_get", _wrap_crit_point_t_evect0_y_get, METH_O, NULL}, + { "crit_point_t_evect0_z_set", _wrap_crit_point_t_evect0_z_set, METH_VARARGS, NULL}, + { "crit_point_t_evect0_z_get", _wrap_crit_point_t_evect0_z_get, METH_O, NULL}, + { "crit_point_t_evect1_x_set", _wrap_crit_point_t_evect1_x_set, METH_VARARGS, NULL}, + { "crit_point_t_evect1_x_get", _wrap_crit_point_t_evect1_x_get, METH_O, NULL}, + { "crit_point_t_evect1_y_set", _wrap_crit_point_t_evect1_y_set, METH_VARARGS, NULL}, + { "crit_point_t_evect1_y_get", _wrap_crit_point_t_evect1_y_get, METH_O, NULL}, + { "crit_point_t_evect1_z_set", _wrap_crit_point_t_evect1_z_set, METH_VARARGS, NULL}, + { "crit_point_t_evect1_z_get", _wrap_crit_point_t_evect1_z_get, METH_O, NULL}, + { "crit_point_t_evect2_x_set", _wrap_crit_point_t_evect2_x_set, METH_VARARGS, NULL}, + { "crit_point_t_evect2_x_get", _wrap_crit_point_t_evect2_x_get, METH_O, NULL}, + { "crit_point_t_evect2_y_set", _wrap_crit_point_t_evect2_y_set, METH_VARARGS, NULL}, + { "crit_point_t_evect2_y_get", _wrap_crit_point_t_evect2_y_get, METH_O, NULL}, + { "crit_point_t_evect2_z_set", _wrap_crit_point_t_evect2_z_set, METH_VARARGS, NULL}, + { "crit_point_t_evect2_z_get", _wrap_crit_point_t_evect2_z_get, METH_O, NULL}, + { "new_crit_point_t", _wrap_new_crit_point_t, METH_NOARGS, NULL}, + { "delete_crit_point_t", _wrap_delete_crit_point_t, METH_O, NULL}, + { "crit_point_t_swigregister", crit_point_t_swigregister, METH_O, NULL}, + { "crit_point_t_swiginit", crit_point_t_swiginit, METH_VARARGS, NULL}, + { "p3dGetHighDivPoints", _wrap_p3dGetHighDivPoints, METH_VARARGS, NULL}, + { "p3dGVF", _wrap_p3dGVF, METH_VARARGS, NULL}, + { "highDiv_point_lelem_t_elem_set", _wrap_highDiv_point_lelem_t_elem_set, METH_VARARGS, NULL}, + { "highDiv_point_lelem_t_elem_get", _wrap_highDiv_point_lelem_t_elem_get, METH_O, NULL}, + { "highDiv_point_lelem_t_next_set", _wrap_highDiv_point_lelem_t_next_set, METH_VARARGS, NULL}, + { "highDiv_point_lelem_t_next_get", _wrap_highDiv_point_lelem_t_next_get, METH_O, NULL}, + { "new_highDiv_point_lelem_t", _wrap_new_highDiv_point_lelem_t, METH_NOARGS, NULL}, + { "delete_highDiv_point_lelem_t", _wrap_delete_highDiv_point_lelem_t, METH_O, NULL}, + { "highDiv_point_lelem_t_swigregister", highDiv_point_lelem_t_swigregister, METH_O, NULL}, + { "highDiv_point_lelem_t_swiginit", highDiv_point_lelem_t_swiginit, METH_VARARGS, NULL}, + { "highDiv_point_list_init", _wrap_highDiv_point_list_init, METH_O, NULL}, + { "highDiv_point_list_push", _wrap_highDiv_point_list_push, METH_VARARGS, NULL}, + { "highDiv_point_list_pop", _wrap_highDiv_point_list_pop, METH_O, NULL}, + { "highDiv_point_list_isempty", _wrap_highDiv_point_list_isempty, METH_O, NULL}, + { "highDiv_point_list_toarray", _wrap_highDiv_point_list_toarray, METH_VARARGS, NULL}, + { "highDiv_point_t_x_set", _wrap_highDiv_point_t_x_set, METH_VARARGS, NULL}, + { "highDiv_point_t_x_get", _wrap_highDiv_point_t_x_get, METH_O, NULL}, + { "highDiv_point_t_y_set", _wrap_highDiv_point_t_y_set, METH_VARARGS, NULL}, + { "highDiv_point_t_y_get", _wrap_highDiv_point_t_y_get, METH_O, NULL}, + { "highDiv_point_t_z_set", _wrap_highDiv_point_t_z_set, METH_VARARGS, NULL}, + { "highDiv_point_t_z_get", _wrap_highDiv_point_t_z_get, METH_O, NULL}, + { "highDiv_point_t_div_set", _wrap_highDiv_point_t_div_set, METH_VARARGS, NULL}, + { "highDiv_point_t_div_get", _wrap_highDiv_point_t_div_get, METH_O, NULL}, + { "new_highDiv_point_t", _wrap_new_highDiv_point_t, METH_NOARGS, NULL}, + { "delete_highDiv_point_t", _wrap_delete_highDiv_point_t, METH_O, NULL}, + { "highDiv_point_t_swigregister", highDiv_point_t_swigregister, METH_O, NULL}, + { "highDiv_point_t_swiginit", highDiv_point_t_swiginit, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + +static PyMethodDef SwigMethods_proxydocs[] = { + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_SkeletonStats = {"_p_SkeletonStats", "struct SkeletonStats *|SkeletonStats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_bb_t = {"_p_bb_t", "bb_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_lelem_t = {"_p_coords_lelem_t", "struct coords_lelem_t *|coords_list_elem_t *|coords_lelem_t *|coords_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_qelem_t = {"_p_coords_qelem_t", "struct coords_qelem_t *|coords_qelem_t *|coords_queue_elem_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_queue_t = {"_p_coords_queue_t", "coords_queue_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_coords_t = {"_p_coords_t", "coords_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_crit_point_lelem_t = {"_p_crit_point_lelem_t", "struct crit_point_lelem_t *|crit_point_list_elem_t *|crit_point_lelem_t *|crit_point_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_crit_point_t = {"_p_crit_point_t", "crit_point_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__char_v_______int = {"_p_f_p_q_const__char_v_______int", "int (*)(char const *,...)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_fcoords_lelem_t = {"_p_fcoords_lelem_t", "struct fcoords_lelem_t *|fcoords_list_elem_t *|fcoords_lelem_t *|fcoords_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_fcoords_t = {"_p_fcoords_t", "fcoords_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_float = {"_p_float", "float *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_highDiv_point_lelem_t = {"_p_highDiv_point_lelem_t", "struct highDiv_point_lelem_t *|highDiv_point_list_elem_t *|highDiv_point_lelem_t *|highDiv_point_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_highDiv_point_t = {"_p_highDiv_point_t", "highDiv_point_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_bb_t = {"_p_p_bb_t", "bb_t **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_coords_lelem_t = {"_p_p_coords_lelem_t", "struct coords_lelem_t **|coords_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_crit_point_lelem_t = {"_p_p_crit_point_lelem_t", "struct crit_point_lelem_t **|crit_point_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_fcoords_lelem_t = {"_p_p_fcoords_lelem_t", "struct fcoords_lelem_t **|fcoords_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_highDiv_point_lelem_t = {"_p_p_highDiv_point_lelem_t", "struct highDiv_point_lelem_t **|highDiv_point_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_uint_lelem_t = {"_p_p_uint_lelem_t", "struct uint_lelem_t **|uint_list_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_unsigned_int = {"_p_p_unsigned_int", "unsigned int **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_uint_lelem_t = {"_p_uint_lelem_t", "struct uint_lelem_t *|uint_list_elem_t *|uint_lelem_t *|uint_list_t", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_SkeletonStats, + &_swigt__p_bb_t, + &_swigt__p_char, + &_swigt__p_coords_lelem_t, + &_swigt__p_coords_qelem_t, + &_swigt__p_coords_queue_t, + &_swigt__p_coords_t, + &_swigt__p_crit_point_lelem_t, + &_swigt__p_crit_point_t, + &_swigt__p_double, + &_swigt__p_f_p_q_const__char_v_______int, + &_swigt__p_fcoords_lelem_t, + &_swigt__p_fcoords_t, + &_swigt__p_float, + &_swigt__p_highDiv_point_lelem_t, + &_swigt__p_highDiv_point_t, + &_swigt__p_int, + &_swigt__p_p_bb_t, + &_swigt__p_p_coords_lelem_t, + &_swigt__p_p_crit_point_lelem_t, + &_swigt__p_p_fcoords_lelem_t, + &_swigt__p_p_highDiv_point_lelem_t, + &_swigt__p_p_uint_lelem_t, + &_swigt__p_p_unsigned_int, + &_swigt__p_uint_lelem_t, + &_swigt__p_unsigned_char, + &_swigt__p_unsigned_int, + &_swigt__p_unsigned_short, +}; + +static swig_cast_info _swigc__p_SkeletonStats[] = { {&_swigt__p_SkeletonStats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_bb_t[] = { {&_swigt__p_bb_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_lelem_t[] = { {&_swigt__p_coords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_qelem_t[] = { {&_swigt__p_coords_qelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_queue_t[] = { {&_swigt__p_coords_queue_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_coords_t[] = { {&_swigt__p_coords_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_crit_point_lelem_t[] = { {&_swigt__p_crit_point_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_crit_point_t[] = { {&_swigt__p_crit_point_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__char_v_______int[] = { {&_swigt__p_f_p_q_const__char_v_______int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_fcoords_lelem_t[] = { {&_swigt__p_fcoords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_fcoords_t[] = { {&_swigt__p_fcoords_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_highDiv_point_lelem_t[] = { {&_swigt__p_highDiv_point_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_highDiv_point_t[] = { {&_swigt__p_highDiv_point_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_bb_t[] = { {&_swigt__p_p_bb_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_coords_lelem_t[] = { {&_swigt__p_p_coords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_crit_point_lelem_t[] = { {&_swigt__p_p_crit_point_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_fcoords_lelem_t[] = { {&_swigt__p_p_fcoords_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_highDiv_point_lelem_t[] = { {&_swigt__p_p_highDiv_point_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_uint_lelem_t[] = { {&_swigt__p_p_uint_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_unsigned_int[] = { {&_swigt__p_p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_uint_lelem_t[] = { {&_swigt__p_uint_lelem_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_SkeletonStats, + _swigc__p_bb_t, + _swigc__p_char, + _swigc__p_coords_lelem_t, + _swigc__p_coords_qelem_t, + _swigc__p_coords_queue_t, + _swigc__p_coords_t, + _swigc__p_crit_point_lelem_t, + _swigc__p_crit_point_t, + _swigc__p_double, + _swigc__p_f_p_q_const__char_v_______int, + _swigc__p_fcoords_lelem_t, + _swigc__p_fcoords_t, + _swigc__p_float, + _swigc__p_highDiv_point_lelem_t, + _swigc__p_highDiv_point_t, + _swigc__p_int, + _swigc__p_p_bb_t, + _swigc__p_p_coords_lelem_t, + _swigc__p_p_crit_point_lelem_t, + _swigc__p_p_fcoords_lelem_t, + _swigc__p_p_highDiv_point_lelem_t, + _swigc__p_p_uint_lelem_t, + _swigc__p_p_unsigned_int, + _swigc__p_uint_lelem_t, + _swigc__p_unsigned_char, + _swigc__p_unsigned_int, + _swigc__p_unsigned_short, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned statically to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); + + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString("<Swig global variables>"); +#else + return PyString_FromString("<Swig global variables>"); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; + if (PyType_Ready(&varlink_type) < 0) + return NULL; + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + memcpy(gv->name, name, size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *globals = 0; + if (!globals) { + globals = SWIG_newvarlink(); + } + return globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + memcpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + memcpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + + /* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md, *globals; + +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + SwigPyObject_own, + SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + PyTypeObject *swigpyobject; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + PyObject *self = 0; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + (void)self; + + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); + assert(metatype); +#endif + + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule(SWIG_name, SwigMethods); +#endif + + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + swigpyobject = SwigPyObject_TypeOnce(); + + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + + SWIG_Python_SetConstant(d, "sizeof_uchar",SWIG_From_size_t((size_t)(sizeof(unsigned char)))); + SWIG_Python_SetConstant(d, "sizeof_ushort",SWIG_From_size_t((size_t)(sizeof(unsigned short)))); + SWIG_Python_SetConstant(d, "sizeof_PSkeletonStats",SWIG_From_size_t((size_t)(sizeof(struct SkeletonStats)))); + SWIG_Python_SetConstant(d, "P3D_FALSE",SWIG_From_int((int)(-1))); + SWIG_Python_SetConstant(d, "P3D_TRUE",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, "P3D_ERROR",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, "P3D_SUCCESS",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, "BACKGROUND",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, "NODE_LABEL",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, "END_LABEL",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, "ISOLATED_LABEL",SWIG_From_int((int)(3))); + SWIG_Python_SetConstant(d, "NODETONODE_LABEL",SWIG_From_int((int)(4))); + SWIG_Python_SetConstant(d, "NODETOEND_LABEL",SWIG_From_int((int)(5))); + SWIG_Python_SetConstant(d, "ENDTOEND_LABEL",SWIG_From_int((int)(6))); +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/pypore3d/pypore3d/p3d_SITK_common_lib.py b/pypore3d/pypore3d/p3d_SITK_common_lib.py new file mode 100644 index 0000000000000000000000000000000000000000..4f2235b0fe3861ab00955f191670f0f86a947ab1 --- /dev/null +++ b/pypore3d/pypore3d/p3d_SITK_common_lib.py @@ -0,0 +1,27 @@ + +import pypore3d.p3d_SITK_read_raw +from pypore3d.p3d_SITK_read_raw import * + +import pypore3d.p3dFiltPy +from pypore3d.p3dFiltPy import py_p3dReadRaw8,py_p3dWriteRaw8 + + +###### common 8 bit +def sitk_to_p3d_file_format (sitk_image, dimx, dimy, dimz): + sitk.WriteImage(sitk_image , "tempMeta.mhd") + im_P3D_format_out = py_p3dReadRaw8( 'tempMeta.raw', dimx,dimy,dimz) + os.remove('tempMeta.raw') + return im_P3D_format_out + +def p3d_to_sitk_file_format (p3d_image, dimx,dimy,dimz): + py_p3dWriteRaw8( p3d_image, 'tempOutMeta.raw',dimx,dimy,dimz) + im_SITK_format_out = Read_Raw8("tempOutMeta.raw", [dimx,dimy,dimz]) + os.remove('tempOutMeta.raw') + return im_SITK_format_out + +def apply_rescaler(filtered_img,dimx,dimy,dimz): + rescaler = sitk.RescaleIntensityImageFilter() + rescaler.SetOutputMinimum(0) + rescaler.SetOutputMaximum(255) + rescaledImg = rescaler.Execute(filtered_img) + return rescaledImg diff --git a/pypore3d/pypore3d/p3d_SITK_common_lib_16.py b/pypore3d/pypore3d/p3d_SITK_common_lib_16.py new file mode 100644 index 0000000000000000000000000000000000000000..581c89c0b8b0c244e7cb71a5dff023b48608bc9e --- /dev/null +++ b/pypore3d/pypore3d/p3d_SITK_common_lib_16.py @@ -0,0 +1,25 @@ + +import pypore3d.p3d_SITK_read_raw +from pypore3d.p3d_SITK_read_raw import * + +import pypore3d.p3dFiltPy +from pypore3d.p3dFiltPy import py_p3dReadRaw8,py_p3dWriteRaw8 + +import pypore3d.p3dFiltPy_16 +from pypore3d.p3dFiltPy_16 import py_p3dReadRaw16,py_p3dWriteRaw16 + + +###### common 16 bit +def sitk_to_p3d_file_format_16 (sitk_image, dimx,dimy,dimz): + sitk.WriteImage(sitk_image , "tempMeta.mhd") + im_P3D_format_out = py_p3dReadRaw16( 'tempMeta.raw', dimx,dimy,dimz) + os.remove('tempMeta.raw') + return im_P3D_format_out + +def p3d_to_sitk_file_format_16(p3d_image, dimx,dimy,dimz): + im_SITK_format_out = py_p3dWriteRaw16( p3d_image, 'tempOutMeta.raw',dimx,dimy,dimz) + im_SITK_format_out = Read_Raw16("tempOutMeta.raw", [dimx,dimy,dimz]) + os.remove('tempOutMeta.raw') + return im_SITK_format_out + + diff --git a/pypore3d/pypore3d/p3d_SITK_read_raw.py b/pypore3d/pypore3d/p3d_SITK_read_raw.py new file mode 100644 index 0000000000000000000000000000000000000000..3499c793e166647c2c1a8d2e5d6ed8a3bcd42f87 --- /dev/null +++ b/pypore3d/pypore3d/p3d_SITK_read_raw.py @@ -0,0 +1,205 @@ +import argparse +import SimpleITK as sitk +import os +import tempfile + +def Read_Raw8(binary_file_name, image_size, image_spacing=None,image_origin=None, big_endian=False): + + """ + Read a raw binary scalar image. + + Parameters + ---------- + binary_file_name (str): Raw, binary image file content. + image_size (tuple like): Size of image (e.g. [2048,2048]) + sitk_pixel_type (SimpleITK pixel type: Pixel type of data (e.g. + sitk.sitkUInt16). + image_spacing (tuple like): Optional image spacing, if none given assumed + to be [1]*dim. + image_origin (tuple like): Optional image origin, if none given assumed to + be [0]*dim. + big_endian (bool): Optional byte order indicator, if True big endian, else + little endian. + + Returns + ------- + SimpleITK image or None if fails. + """ + + sitk_pixel_type = sitk.sitkUInt8 + + pixel_dict = {sitk.sitkUInt8: 'MET_UCHAR', + sitk.sitkInt8: 'MET_CHAR', + sitk.sitkUInt16: 'MET_USHORT', + sitk.sitkInt16: 'MET_SHORT', + sitk.sitkUInt32: 'MET_UINT', + sitk.sitkInt32: 'MET_INT', + sitk.sitkUInt64: 'MET_ULONG_LONG', + sitk.sitkInt64: 'MET_LONG_LONG', + sitk.sitkFloat32: 'MET_FLOAT', + sitk.sitkFloat64: 'MET_DOUBLE'} + direction_cosine = ['1 0 0 1', '1 0 0 0 1 0 0 0 1', + '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1'] + dim = len(image_size) + header = ['ObjectType = Image\n'.encode(), + (f'NDims = {dim}\n').encode(), + ('DimSize = ' + ' '.join([str(v) for v in image_size]) + '\n') + .encode(), + ('ElementSpacing = ' + (' '.join([str(v) for v in image_spacing]) + if image_spacing else ' '.join( + ['1'] * dim)) + '\n').encode(), + ('Offset = ' + ( + ' '.join([str(v) for v in image_origin]) if image_origin + else ' '.join(['0'] * dim) + '\n')).encode(), + ('TransformMatrix = ' + direction_cosine[dim - 2] + '\n') + .encode(), + ('ElementType = ' + pixel_dict[sitk_pixel_type] + '\n').encode(), + 'BinaryData = True\n'.encode(), + ('BinaryDataByteOrderMSB = ' + str(big_endian) + '\n').encode(), + # ElementDataFile must be the last entry in the header + ('ElementDataFile = ' + os.path.abspath( + binary_file_name) + '\n').encode()] + + fp = tempfile.NamedTemporaryFile(suffix='.mhd', delete=False) + + print(header) + + # Not using the tempfile with a context manager and auto-delete + # because on windows we can't open the file a second time for ReadImage. + fp.writelines(header) + fp.close() + img = sitk.ReadImage(fp.name) + + os.remove(fp.name) + return img + + +def Read_Raw16(binary_file_name, image_size, image_spacing=None,image_origin=None, big_endian=False): + + """ + Read a 16-bit scalar image. + + Parameters + ---------- + binary_file_name (str): Raw, 16-bit image file content. + image_size (tuple like): Size of image (e.g. [2048,2048]) + sitk_pixel_type (SimpleITK pixel type: Pixel type of data (e.g. + sitk.sitkUInt16). + image_spacing (tuple like): Optional image spacing, if none given assumed + to be [1]*dim. + image_origin (tuple like): Optional image origin, if none given assumed to + be [0]*dim. + big_endian (bool): Optional byte order indicator, if True big endian, else + little endian. + + Returns + ------- + SimpleITK image or None if fails. + """ + + sitk_pixel_type = sitk.sitkUInt16 + + pixel_dict = {sitk.sitkUInt8: 'MET_UCHAR', + sitk.sitkInt8: 'MET_CHAR', + sitk.sitkUInt16: 'MET_USHORT', + sitk.sitkInt16: 'MET_SHORT', + sitk.sitkUInt32: 'MET_UINT', + sitk.sitkInt32: 'MET_INT', + sitk.sitkUInt64: 'MET_ULONG_LONG', + sitk.sitkInt64: 'MET_LONG_LONG', + sitk.sitkFloat32: 'MET_FLOAT', + sitk.sitkFloat64: 'MET_DOUBLE'} + direction_cosine = ['1 0 0 1', '1 0 0 0 1 0 0 0 1', + '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1'] + dim = len(image_size) + header = ['ObjectType = Image\n'.encode(), + (f'NDims = {dim}\n').encode(), + ('DimSize = ' + ' '.join([str(v) for v in image_size]) + '\n') + .encode(), + ('ElementSpacing = ' + (' '.join([str(v) for v in image_spacing]) + if image_spacing else ' '.join( + ['1'] * dim)) + '\n').encode(), + ('Offset = ' + ( + ' '.join([str(v) for v in image_origin]) if image_origin + else ' '.join(['0'] * dim) + '\n')).encode(), + ('TransformMatrix = ' + direction_cosine[dim - 2] + '\n') + .encode(), + ('ElementType = ' + pixel_dict[sitk_pixel_type] + '\n').encode(), + 'BinaryData = True\n'.encode(), + ('BinaryDataByteOrderMSB = ' + str(big_endian) + '\n').encode(), + # ElementDataFile must be the last entry in the header + ('ElementDataFile = ' + os.path.abspath( + binary_file_name) + '\n').encode()] + + fp = tempfile.NamedTemporaryFile(suffix='.mhd', delete=False) + + print(header) + + # Not using the tempfile with a context manager and auto-delete + # because on windows we can't open the file a second time for ReadImage. + fp.writelines(header) + fp.close() + img = sitk.ReadImage(fp.name) + + os.remove(fp.name) + return img + +###### + +def Read_Raw(binary_file_name, image_size, sitk_pixel_type = sitk.sitkUInt8): + pixel_dict = {sitk.sitkUInt8: 'MET_UCHAR', + sitk.sitkInt8: 'MET_CHAR', + sitk.sitkUInt16: 'MET_USHORT', + sitk.sitkInt16: 'MET_SHORT', + sitk.sitkUInt32: 'MET_UINT', + sitk.sitkInt32: 'MET_INT', + sitk.sitkUInt64: 'MET_ULONG_LONG', + sitk.sitkInt64: 'MET_LONG_LONG', + sitk.sitkFloat32: 'MET_FLOAT', + sitk.sitkFloat64: 'MET_DOUBLE'} + + image_spacing=None + image_origin=None + big_endian=False + direction_cosine = ['1 0 0 1', '1 0 0 0 1 0 0 0 1','1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1'] + dim = len(image_size) + header = ['ObjectType = Image\n'.encode(), + (f'NDims = {dim}\n').encode(), + ('DimSize = ' + ' '.join([str(v) for v in image_size]) + '\n') + .encode(), + ('ElementSpacing = ' + (' '.join([str(v) for v in image_spacing]) + if image_spacing else ' '.join( + ['1'] * dim)) + '\n').encode(), + ('Offset = ' + ( + ' '.join([str(v) for v in image_origin]) if image_origin + else ' '.join(['0'] * dim) + '\n')).encode(), + ('TransformMatrix = ' + direction_cosine[dim - 2] + '\n') + .encode(), + ('ElementType = ' + pixel_dict[sitk_pixel_type] + '\n').encode(), + 'BinaryData = True\n'.encode(), + ('BinaryDataByteOrderMSB = ' + str(big_endian) + '\n').encode(), + # ElementDataFile must be the last entry in the header + ('ElementDataFile = ' + os.path.abspath( + binary_file_name) + '\n').encode()] + + fp = tempfile.NamedTemporaryFile(suffix='.mhd', delete=False) + + print(header) + + # Not using the tempfile with a context manager and auto-delete + # because on windows we can't open the file a second time for ReadImage. + fp.writelines(header) + fp.close() + img = sitk.ReadImage(fp.name) + + os.remove(fp.name) + return img + + + + + + + + + diff --git a/pypore3d/pypore3d/p3d_common_lib.py b/pypore3d/pypore3d/p3d_common_lib.py new file mode 100644 index 0000000000000000000000000000000000000000..27828bc9cf95718ce614d5608163d80a928e5d46 --- /dev/null +++ b/pypore3d/pypore3d/p3d_common_lib.py @@ -0,0 +1,59 @@ +#import numpy as np + +################## constants +P3D_FALSE=-1 +P3D_TRUE=1 + +P3D_ERROR=0 +P3D_MEM_ERROR=None +P3D_SUCCESS=2 + +BACKGROUND=0 +#OBJECT=UCHAR_MAX + +CONN4=611 +CONN8=612 + +CONN6=711 +CONN18=712 +CONN26=713 + +################## error messages + +def py_printErrorMessage(err_code): + + string = "Success. \n" + + if err_code == 1 or err_code == 0: + string = "**ERROR** Error on code execution. \n" + + + if err_code == -2: + string = "**ERROR** Input argument IMAGE must be of type BYTE or UINT. \n" + + + if err_code == -3: + string = "**ERROR** Input argument IMAGE must be a 2D or 3D matrix. \n" + + if err_code == -4: + string = "**ERROR** Wrong argument values. Please call the help function for more information. \n" + + if err_code == -5: + string = "**ERROR** File does not exist. \n" + + + print (string) + +################# Common functions + +def py_from_16bit_to_8bit(input_image_16bit,dimx,dimy,dimz): + #output_image_8bit = np.arange(2**16, dtype='uint16') + display_min = 1000 + display_max = 10000 + output_image_8bit = np.array(input_image_16bit, copy=True) + output_image_8bit.clip(display_min, display_max, out=output_image_8bit) + output_image_8bit -= display_min + np.floor_divide(output_image_8bit, (display_max - display_min + 1) / 256, + out=output_image_8bit, casting='unsafe') + return output_image_8bit.astype(np.uint8) + diff --git a/pypore3d/setup.py b/pypore3d/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..b8c61483b8c3da331f005ddc2a2cd2fa3641a652 --- /dev/null +++ b/pypore3d/setup.py @@ -0,0 +1,125 @@ +import os +import setuptools +from setuptools import setup +from setuptools.extension import Extension + +with open("README.md", "r") as fh: + long_description = fh.read() + +this_dir = os.path.dirname(os.path.abspath(__file__)) + + +ext_modules = Extension( + name='pypore3d._p3dBlob', + include_dirs=[os.path.join(this_dir, 'pypore3d')], + sources=["pypore3d/p3dBlob.i", + "pypore3d/P3D_Blob/_p3dTime.c", + "pypore3d/P3D_Blob/p3dBasicAnalysis.c", + "pypore3d/P3D_Blob/p3dAnisotropyAnalysis.c", + "pypore3d/P3D_Blob/p3dBlobAnalysis.c" , + "pypore3d/P3D_Blob/p3dBlobLabeling.c", + "pypore3d/P3D_Blob/p3dChamferDT.c", + "pypore3d/P3D_Blob/p3dGetMaxVolumeBlob.c", + "pypore3d/P3D_Blob/p3dGetMinVolumeBlob.c", + "pypore3d/P3D_Blob/p3dMinVolumeFilter.c", + "pypore3d/P3D_Blob/p3dMorphometricAnalysis.c", + "pypore3d/P3D_Blob/p3dREVEstimation.c", + "pypore3d/P3D_Blob/p3dTextureAnalysis.c", + "pypore3d/P3D_Blob/Common/p3dBoundingBoxList.c", + "pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_uint.c", + "pypore3d/P3D_Blob/Common/p3dConnectedComponentsLabeling_ushort.c", + "pypore3d/P3D_Blob/Common/p3dCoordsList.c", + "pypore3d/P3D_Blob/Common/p3dCoordsQueue.c", + "pypore3d/P3D_Blob/Common/p3dDoubleList.c", + "pypore3d/P3D_Blob/Common/p3dFCoordsList.c", + "pypore3d/P3D_Blob/p3dSquaredEuclideanDT.c", + "pypore3d/P3D_Blob/Common/p3dUIntList.c", + "pypore3d/P3D_Blob/Common/p3dUtils.c" + +]) + + +ext_modules1 = Extension( + name='pypore3d._p3dSkel', + include_dirs=[os.path.join(this_dir, 'pypore3d')], + sources=["pypore3d/p3dSkel.i", + "pypore3d/P3D_Skel/Common/p3dBoundingBoxList.c", + "pypore3d/P3D_Skel/Common/p3dConnectedComponentsLabeling.c", + "pypore3d/P3D_Skel/Common/p3dCoordsList.c", + "pypore3d/P3D_Skel/Common/p3dCoordsQueue.c", + "pypore3d/P3D_Skel/Common/p3dFCoordsList.c", + "pypore3d/P3D_Skel/Common/p3dSquaredEuclideanDT.c", + "pypore3d/P3D_Skel/Common/p3dThinning.c", + "pypore3d/P3D_Skel/Common/p3dUIntList.c", + "pypore3d/P3D_Skel/Common/p3dUtils.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeCoreSkeleton.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeEigenVal.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dComputeHierarchicalSkeleton.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dCriticalPoints.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dCritPointList.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dGetHighDivPoints.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dGVF.c", + "pypore3d/P3D_Skel/GVFSkeletonization/p3dHighDivPointList.c", + "pypore3d/P3D_Skel/_p3dTime.c", + "pypore3d/P3D_Skel/p3dGVFSkeletonization.c", + "pypore3d/P3D_Skel/p3dIterativeSkeletonPruning.c", + "pypore3d/P3D_Skel/p3dLKCSkeletonization.c", + "pypore3d/P3D_Skel/p3dSimpleSkeletonPruning.c", + "pypore3d/P3D_Skel/p3dSkeletonAnalysis.c", + "pypore3d/P3D_Skel/p3dSkeletonAnalysisFeasibility.c", + "pypore3d/P3D_Skel/p3dSkeletonLabeling.c", + "pypore3d/P3D_Skel/p3dThinningSkeletonization.c", + "pypore3d/P3D_Skel/p3dUltimateSkeletonPruning.c"]) + + +ext_modules2 = Extension( + name='pypore3d._p3dFilt', + include_dirs=[os.path.join(this_dir, 'pypore3d')], + sources=["pypore3d/p3dFilt.i", + "pypore3d/P3D_Filt/p3dMedianFilter.c", + "pypore3d/P3D_Filt/_p3dTime.c", + "pypore3d/P3D_Filt/p3dMeanFilter.c", + "pypore3d/P3D_Filt/p3dBilateralFilter.c", + "pypore3d/P3D_Filt/p3dIORaw.c", + "pypore3d/P3D_Filt/p3dAnisotropicDiffusionFilter.c", + "pypore3d/P3D_Filt/p3dBoinHaibelRingRemover.c", + "pypore3d/P3D_Filt/p3dClearBorderFilter.c", + "pypore3d/P3D_Filt/p3dCreateBinaryShapes.c", + "pypore3d/P3D_Filt/p3dCrop.c", + "pypore3d/P3D_Filt/p3dFrom16To8.c", + "pypore3d/P3D_Filt/p3dGaussianFilter.c", + "pypore3d/P3D_Filt/p3dGetRegionByCoords.c", + "pypore3d/P3D_Filt/p3dHuangYagerThresholding.c", + "pypore3d/P3D_Filt/p3dJohannsenThresholding.c", + "pypore3d/P3D_Filt/p3dKapurThresholding.c", + "pypore3d/P3D_Filt/p3dKittlerThresholding.c", + "pypore3d/P3D_Filt/p3dOtsuThresholding.c", + "pypore3d/P3D_Filt/p3dPadding.c", + "pypore3d/P3D_Filt/p3dPunThresholding.c", + "pypore3d/P3D_Filt/p3dRidlerThresholding.c", + "pypore3d/P3D_Filt/p3dSijbersPostnovRingRemover.c", + "pypore3d/P3D_Filt/Common/p3dRingRemoverCommon.c", + "pypore3d/P3D_Filt/Common/p3dCoordsQueue.c"]) + +setup( +name = 'pypore3d', +version = '0.0.1', +author = 'Amal Aboulhassan', +author_email = "aboulhassan.amal@gmail.com", +description = "Pore3d with python wrappers", +long_description = long_description, +long_description_content_type = "text/markdown", +url = "https://gitlab.elettra.eu/amal.abouelhassan/pore3d_py", +packages=setuptools.find_packages(), +classifiers = + ["Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent"], +ext_modules=[ext_modules, ext_modules1, ext_modules2] +) + + +#package_dir = 'src', +#ext_modules=[src], +#zip_safe=False, +#include_package_data=True, \ No newline at end of file