diff --git a/common/pmmc.h b/common/pmmc.h index 3c178223..6937bbf5 100644 --- a/common/pmmc.h +++ b/common/pmmc.h @@ -301,7 +301,7 @@ char triTable[256][16] = {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}}; //-------------------------------------------------------------------------------------------------------- -class TriLinearPoly{ +class TriLinPoly{ /* Compute a tri-linear polynomial within a given cube (i,j,k) x (i+1,j+1,k+1) * Values are provided at the corners in CubeValues * x,y,z must be defined on [0,1] where the length of the cube edge is one @@ -309,34 +309,40 @@ class TriLinearPoly{ int ic,jc,kc; double a,b,c,d,e,f,g,h; double x,y,z; - DoubleArray CubeValues; public: - TriLinearPoly(){ - CubeValues.New(2,2,2); + DoubleArray Corners; + + TriLinPoly(){ + Corners.New(2,2,2); } + // Assign the polynomial within a cube void assign(DoubleArray &A, int i, int j, int k){ + // Save the cube indices ic=i; jc=j; kc=k; - CubeValues(0,0,0) = A(i,j,k); - CubeValues(1,0,0) = A(i+1,j,k); - CubeValues(0,1,0) = A(i,j+1,k); - CubeValues(1,1,0) = A(i+1,j+1,k); - CubeValues(0,0,1) = A(i,j,k+1); - CubeValues(1,0,1) = A(i+1,j,k+1); - CubeValues(0,1,1) = A(i,j+1,k+1); - CubeValues(1,1,1) = A(i+1,j+1,k+1); + // local copy of the cube values + Corners(0,0,0) = A(i,j,k); + Corners(1,0,0) = A(i+1,j,k); + Corners(0,1,0) = A(i,j+1,k); + Corners(1,1,0) = A(i+1,j+1,k); + Corners(0,0,1) = A(i,j,k+1); + Corners(1,0,1) = A(i+1,j,k+1); + Corners(0,1,1) = A(i,j+1,k+1); + Corners(1,1,1) = A(i+1,j+1,k+1); - a = CubeValues(0,0,0); - b = CubeValues(1,0,0)-a; - c = CubeValues(0,1,0)-a; - d = CubeValues(0,0,1)-a; - e = CubeValues(1,1,0)-a-b-c; - f = CubeValues(1,0,1)-a-b-d; - g = CubeValues(0,1,1)-a-c-d; - h = CubeValues(1,1,1)-a-b-c-d-e-f-g; + // coefficients of the tri-linear approximation + a = Corners(0,0,0); + b = Corners(1,0,0)-a; + c = Corners(0,1,0)-a; + d = Corners(0,0,1)-a; + e = Corners(1,1,0)-a-b-c; + f = Corners(1,0,1)-a-b-d; + g = Corners(0,1,1)-a-c-d; + h = Corners(1,1,1)-a-b-c-d-e-f-g; } + // Evaluate the polynomial at a point double eval(Point P){ double returnValue; x = P.x - 1.0*ic; @@ -345,6 +351,7 @@ public: returnValue = a + b*x + c*y+d*z + e*x*y + f*x*z + g*y*z + h*x*y*z; return returnValue; } + }; //-------------------------------------------------------------------------------------------------------- inline int ComputeBlob(IntArray &blobs, int &nblobs, int &ncubes, IntArray &indicator, @@ -4243,50 +4250,76 @@ inline void pmmc_CurveCurvature(DoubleArray &f, DoubleArray &s, DTMutableList