summaryrefslogtreecommitdiff
path: root/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp')
-rw-r--r--plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp b/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp
index a31961447a..3b577cbd0a 100644
--- a/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp
+++ b/plugins/AdvaImg/src/FreeImageToolkit/MultigridPoissonSolver.cpp
@@ -68,7 +68,7 @@ static void fmg_restrict(FIBITMAP *UC, FIBITMAP *UF, int nc) {
// 0.5 * UF(row_uf, col_uf) + 0.125 * [ UF(row_uf+1, col_uf) + UF(row_uf-1, col_uf) + UF(row_uf, col_uf+1) + UF(row_uf, col_uf-1) ]
float *uc_pixel = uc_scan + col_uc;
const float *uf_center = uf_scan + col_uf;
- *uc_pixel = 0.5F * *uf_center + 0.125F * ( *(uf_center + uf_pitch) + *(uf_center - uf_pitch) + *(uf_center + 1) + *(uf_center - 1));
+ *uc_pixel = 0.5F * *uf_center + 0.125F * ( *(uf_center + uf_pitch) + *(uf_center - uf_pitch) + *(uf_center + 1) + *(uf_center - 1) );
}
uc_scan += uc_pitch;
}
@@ -158,8 +158,8 @@ static void fmg_prolongate(FIBITMAP *UF, FIBITMAP *UC, int nf) {
for(row_uf = 1; row_uf < nf-1; row_uf += 2) {
float *uf_scan = uf_bits + row_uf * uf_pitch;
for (col_uf = 0; col_uf < nf; col_uf += 2) {
- // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf+1, col_uf) + UF(row_uf-1, col_uf))
- uf_scan[col_uf] = 0.5F * ( *(uf_scan + uf_pitch + col_uf) + *(uf_scan - uf_pitch + col_uf));
+ // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf+1, col_uf) + UF(row_uf-1, col_uf) )
+ uf_scan[col_uf] = 0.5F * ( *(uf_scan + uf_pitch + col_uf) + *(uf_scan - uf_pitch + col_uf) );
}
}
}
@@ -168,7 +168,7 @@ static void fmg_prolongate(FIBITMAP *UF, FIBITMAP *UC, int nf) {
float *uf_scan = uf_bits;
for(row_uf = 0; row_uf < nf; row_uf++) {
for (col_uf = 1; col_uf < nf-1; col_uf += 2) {
- // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf, col_uf+1) + UF(row_uf, col_uf-1))
+ // calculate UF(row_uf, col_uf) = 0.5 * ( UF(row_uf, col_uf+1) + UF(row_uf, col_uf-1) )
uf_scan[col_uf] = 0.5F * ( uf_scan[col_uf + 1] + uf_scan[col_uf - 1] );
}
uf_scan += uf_pitch;
@@ -311,7 +311,7 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) {
#define _CREATE_ARRAY_GRID_(array, array_size) \
array = (FIBITMAP**)malloc(array_size * sizeof(FIBITMAP*));\
- if (!array) throw(1);\
+ if(!array) throw(1);\
memset(array, 0, array_size * sizeof(FIBITMAP*))
#define _FREE_ARRAY_GRID_(array, array_size) \
@@ -351,7 +351,7 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) {
// allocate storage for r.h.s. on grid (ng - 2) ...
IRHO[ngrid] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IRHO[ngrid]) throw(1);
+ if(!IRHO[ngrid]) throw(1);
// ... and fill it by restricting from the fine grid
fmg_restrict(IRHO[ngrid], U, nn);
@@ -361,16 +361,16 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) {
nn = nn/2 + 1;
ngrid--;
IRHO[ngrid] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IRHO[ngrid]) throw(1);
+ if(!IRHO[ngrid]) throw(1);
fmg_restrict(IRHO[ngrid], IRHO[ngrid+1], nn);
}
nn = 3;
IU[0] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IU[0]) throw(1);
+ if(!IU[0]) throw(1);
IRHS[0] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IRHS[0]) throw(1);
+ if(!IRHS[0]) throw(1);
// initial solution on coarsest grid
fmg_solve(IU[0], IRHO[0]);
@@ -384,11 +384,11 @@ static BOOL fmg_mglin(FIBITMAP *U, int n, int ncycle) {
nn = 2*nn - 1;
IU[j] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IU[j]) throw(1);
+ if(!IU[j]) throw(1);
IRHS[j] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IRHS[j]) throw(1);
+ if(!IRHS[j]) throw(1);
IRES[j] = FreeImage_AllocateT(FIT_FLOAT, nn, nn);
- if (!IRES[j]) throw(1);
+ if(!IRES[j]) throw(1);
fmg_prolongate(IU[j], IU[j-1], nn);
@@ -464,7 +464,7 @@ where j is such that 2^j is the nearest larger dimension corresponding to MAX(im
*/
FIBITMAP* DLL_CALLCONV
FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle) {
- if (!FreeImage_HasPixels(Laplacian)) return NULL;
+ if(!FreeImage_HasPixels(Laplacian)) return NULL;
int width = FreeImage_GetWidth(Laplacian);
int height = FreeImage_GetHeight(Laplacian);
@@ -473,7 +473,7 @@ FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle) {
int n = MAX(width, height);
int size = 0;
while((n >>= 1) > 0) size++;
- if ((1 << size) < MAX(width, height)) {
+ if((1 << size) < MAX(width, height)) {
size++;
}
// size must be of the form 2^j + 1 for some integer j
@@ -481,7 +481,7 @@ FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle) {
// allocate a temporary square image I
FIBITMAP *I = FreeImage_AllocateT(FIT_FLOAT, size, size);
- if (!I) return NULL;
+ if(!I) return NULL;
// copy Laplacian into I and shift pixels to create a boundary
FreeImage_Paste(I, Laplacian, 1, 1, 255);