PARGEN, PTFUN1, and PTFUN2 corrected so that ex01.f can be successfully created.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 6 Feb 2018 21:48:38 +0000 (21:48 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 6 Feb 2018 21:48:38 +0000 (21:48 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15362 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/model/algorithms/SymmsIntegralMapping.java

index b5cdd47..5bf635c 100644 (file)
@@ -433,13 +433,14 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                int ORDSG[] = new int[1];\r
                double X = 0.0;\r
                double Y = 0.0;\r
-               double ALPHA, PI;\r
+               double ALPHA = 0.0;\r
+               double PI;\r
                // COMPLEX CENSY,RTUNI,U2\r
                double RTUNI[] = new double[2];\r
                double U2[] = new double[2];\r
                // CHARACTER TXT*72,TABC*6,FORTFL*72,CH*2,SIG(10)*2,WID(10)*2,REDD*6,\r
                // +FMT1*8,FMT2*9\r
-               String TXT;\r
+               String TXT = null;\r
                String CH;\r
                String SIG[] = new String[] { "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" };\r
                String WID[] = new String[] { "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };\r
@@ -589,12 +590,15 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                validInput = false;\r
                                while (!validInput) {\r
                                        System.out.println("ENTER THE TYPE OF ARC(1-4) for ARC NUMBER " + IA);\r
-                                       TYPE = input.nextInt();\r
-                                       if ((TYPE >= 1) && (TYPE <= 4)) {\r
-                                               validInput = true;\r
-                                       } else {\r
-                                               System.out.println("TYPE MUST BE BETWEEN 1 and 4");\r
+                                       try {\r
+                                           TYPE = input.nextInt();\r
+                                               if ((TYPE >= 1) && (TYPE <= 4)) {\r
+                                                       validInput = true;\r
+                                               } else {\r
+                                                       System.out.println("TYPE MUST BE BETWEEN 1 and 4");\r
+                                               }\r
                                        }\r
+                                       catch (Exception e) {};\r
                                } // while (!validInput)\r
                                if (TYPE == 1) {\r
                                        ARCTY[IA - 1] = TYPE;\r
@@ -637,8 +641,15 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                }\r
                                                catch (Exception e) {};\r
                                        }\r
-                                       System.out.println("What is the signed angle subtended at center (in units of PI)?");\r
-                                       ALPHA = input.nextDouble();\r
+                                       validInput = false;\r
+                                       while (!validInput) {\r
+                                               try {\r
+                                                    System.out.println("What is the signed angle subtended at center (in units of PI)?");\r
+                                                    ALPHA = input.nextDouble();\r
+                                                    validInput = true;\r
+                                               }\r
+                                               catch (Exception e) {};\r
+                                       }\r
                                        GMCO = GMCO + 1;\r
                                        PGM[IA - 1] = GMCO;\r
                                        RGM[GMCO - 1] = X;\r
@@ -695,10 +706,12 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                } else if (J == 2 && TYPE == 3) {\r
                                                        System.out.println("ENTER JAVA EXPRESSION WITH NO SPACES ENDING IN // FOR DPARFN");\r
                                                        System.out.println("PUT REAL PART ui IMAGINARY PART");\r
+                                                       System.out.println("ALTERNATIVELY JUST ENTER // FOR NUMERICAL DERIVATIVE");\r
                                                } else if (J == 1 && TYPE == 4) {\r
                                                        System.out.println("ENTER JAVA EXPRESSION WITH NO SPACES ENDING IN // FOR RADIUS");\r
                                                } else {\r
                                                        System.out.println("ENTER JAVA EXPRESSION WITH NO SPACES ENDING IN // FOR RADIUS DERIVATIVE");\r
+                                                       System.out.println("ALTERNATIVELY JUST ENTER // FOR NUMERICAL DERIVATIVE");\r
                                                }\r
                                                // Java does not allow operator overloading, so you can't do a cos(t)*sin(t) for complex t.\r
                                                System.out.println("Expand cos(complex T[]) as Math.cos(T[0])*Math.cosh(T[1]) - i*Math.sin(T[0])*Math.sinh(T[1])");\r
@@ -708,20 +721,23 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                PTX[IA - 1 + (J - 1) * MNARC] = TXCO;\r
                                                I = 1;\r
 \r
-                                               TXT = input.next();\r
                                                L = -1;\r
                                                while (L == -1) {\r
+                                                       TXT = input.next();\r
                                                        L = TXT.indexOf("//");\r
                                                        if (L == -1) {\r
-                                                               DEFN[TXCO - 1] = TABC + TXT;\r
+                                                               DEFN[TXCO - 1] = TXT;\r
                                                                I = I + 1;\r
                                                                TXCO = TXCO + 1;\r
                                                        } // if (L == -1)\r
                                                } // while (L == -1)\r
                                                NTX[IA - 1 + (J - 1) * MNARC] = I;\r
-                                               if (L == 0) {\r
-                                                       DEFN[TXCO - 1] = TABC;\r
+                                               if ((L == 0) && (I == 1)) {\r
+                                                       // If just // on first line, use numerical derivative for DPARFN or RADIUS DERIVATIVE in PTFUN2\r
+                                                       DEFN[TXCO - 1] = "";\r
                                                        NUMDER[IA - 1] = true;\r
+                                               } else if (L == 0) {\r
+                                                       DEFN[TXCO-1] = "";\r
                                                } else {\r
                                                        DEFN[TXCO - 1] = TXT.substring(0, L);\r
                                                }\r
@@ -1480,7 +1496,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
                                raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
 \r
-                               if (TXT[0].indexOf("ui") == 0) {\r
+                               if (TXT[0].toLowerCase().indexOf("ui") == 0) {\r
                                    raFile.writeBytes(PAD + VAR + "ANS[0] = 0.0;\n");\r
                                }\r
                                else {\r
@@ -1488,46 +1504,66 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        // multiple lines\r
                                        raFile.writeBytes(PAD + VAR + "ANS[0] = ");\r
                                        for (I = 1; I <= NTX; I++) {\r
-                                               int index = TXT[I - 1].indexOf("ui");\r
+                                               int index = TXT[I - 1].toLowerCase().indexOf("ui");\r
+                                               if (index == 0) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                                       break;\r
+                                               }\r
                                                String realString = null;\r
                                                if (index == -1) {\r
-                                                       realString = TXT[I - 1];\r
-                                               } else {\r
-                                                       realString = TXT[I - 1].substring(0, index);\r
+                                                       realString = TXT[I-1];\r
+                                               }\r
+                                               else {\r
+                                                       realString = TXT[I - 1].substring(0, index);    \r
+                                               }\r
+                                               if ((I > 1) && (realString != null) && (realString.length() != 0)) {\r
+                                                       raFile.writeBytes("\n" + PAD);\r
                                                }\r
-                                               if ((index == -1) || (index > 0)) {\r
-                                                       raFile.writeBytes(realString);\r
+                                               if ((realString != null) && (realString.length() != 0)) {\r
+                                                   raFile.writeBytes(realString);\r
                                                }\r
-                                               if (I == NTX) {\r
+                                               if ((I == NTX) || (index > 0)) {\r
                                                        raFile.writeBytes(";\n");\r
+                                                       break;\r
                                                }\r
                                        }\r
                                }\r
                                boolean uifound = false;\r
+                               String imagString = null;\r
+                               boolean firstImagStringWritten = false;\r
                                for (I = 1; I <= NTX; I++) {\r
-                                   if (TXT[I-1].indexOf("ui") >= 0) {\r
-                                       uifound = true;\r
+                                       if (!uifound) {\r
+                                       int index = TXT[I-1].toLowerCase().indexOf("ui");\r
+                                           if (index >= 0) {\r
+                                               uifound = true;\r
+                                               raFile.writeBytes(PAD + VAR + "ANS[1] = ");\r
+                                               if (index + 2 < TXT[I-1].length()) {\r
+                                                       imagString = TXT[I - 1].substring(index + 2);\r
+                                                           raFile.writeBytes(imagString);\r
+                                                           firstImagStringWritten = true;\r
+                                                           if (I == NTX) {\r
+                                                               raFile.writeBytes(";\n");\r
+                                                           }\r
+                                               } // if (index + 2 < TXT[I-1].length())\r
+                                           } // if (index >= 0)\r
+                                   } // if (!uifound) {\r
+                                   else {\r
+                                       imagString = TXT[I-1];\r
+                                       if (!firstImagStringWritten) {\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       else if ((imagString != null) && (imagString.length() != 0)) {\r
+                                           raFile.writeBytes(PAD + imagString);\r
+                                       }\r
+                                       firstImagStringWritten = true;\r
+                                           if (I == NTX) {\r
+                                               raFile.writeBytes(";\n");\r
+                                           }\r
                                    }\r
-                               }\r
+                               } // for (I = 1; I <= NTX; I++)\r
                                if (!uifound) {\r
                                    raFile.writeBytes(PAD + VAR + "ANS[1] = 0.0;\n");\r
                                }\r
-                               else {\r
-                               // NTX = 1 if statements are entered without newlines for\r
-                               // multiple lines\r
-                                       raFile.writeBytes(PAD + VAR + "ANS[1] = ");\r
-                                       for (I = 1; I <= NTX; I++) {\r
-                                               int index = TXT[I - 1].indexOf("ui");\r
-                                               String imagString = null;\r
-                                               if ((index >= 0) && (index + 2 < TXT[I - 1].length())) {\r
-                                                       imagString = TXT[I - 1].substring(index + 2);\r
-                                                       raFile.writeBytes(imagString);\r
-                                               }\r
-                                               if (I == NTX) {\r
-                                                       raFile.writeBytes(";\n");\r
-                                               }\r
-                                       }\r
-                               }\r
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 3)\r
                        else {\r
@@ -1536,7 +1572,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
                                raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
-                               if (TXT[0].indexOf("ui") == 0) {\r
+                               if (TXT[0].toLowerCase().indexOf("ui") == 0) {\r
                                    raFile.writeBytes(PAD + "ZRAD[0] = 0.0;\n");\r
                                }\r
                                else {\r
@@ -1544,46 +1580,66 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        // multiple lines\r
                                        raFile.writeBytes(PAD + "ZRAD[0] = ");\r
                                        for (I = 1; I <= NTX; I++) {\r
-                                               int index = TXT[I - 1].indexOf("ui");\r
+                                               int index = TXT[I - 1].toLowerCase().indexOf("ui");\r
+                                               if (index == 0) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                                       break;\r
+                                               }\r
                                                String realString = null;\r
                                                if (index == -1) {\r
-                                                       realString = TXT[I - 1];\r
-                                               } else {\r
-                                                       realString = TXT[I - 1].substring(0, index);\r
+                                                       realString = TXT[I-1];\r
                                                }\r
-                                               if ((index == -1) || (index > 0)) {\r
-                                                       raFile.writeBytes(realString);\r
+                                               else {\r
+                                                       realString = TXT[I - 1].substring(0, index);    \r
+                                               }\r
+                                               if ((I > 1) && (realString != null) && (realString.length() != 0)) {\r
+                                                       raFile.writeBytes("\n" + PAD);\r
+                                               }\r
+                                               if ((realString != null) && (realString.length() != 0)) {\r
+                                                   raFile.writeBytes(realString);\r
                                                }\r
-                                               if (I == NTX) {\r
+                                               if ((I == NTX) || (index > 0)) {\r
                                                        raFile.writeBytes(";\n");\r
+                                                       break;\r
                                                }\r
                                        }\r
                                }\r
                                boolean uifound = false;\r
+                               String imagString = null;\r
+                               boolean firstImagStringWritten = false;\r
                                for (I = 1; I <= NTX; I++) {\r
-                                   if (TXT[I-1].indexOf("ui") >= 0) {\r
-                                       uifound = true;\r
+                                       if (!uifound) {\r
+                                       int index = TXT[I-1].toLowerCase().indexOf("ui");\r
+                                           if (index >= 0) {\r
+                                               uifound = true;\r
+                                               raFile.writeBytes(PAD + "ZRAD[1] = ");\r
+                                               if (index + 2 < TXT[I-1].length()) {\r
+                                                       imagString = TXT[I - 1].substring(index + 2);\r
+                                                           raFile.writeBytes(imagString);\r
+                                                           firstImagStringWritten = true;\r
+                                                           if (I == NTX) {\r
+                                                               raFile.writeBytes(";\n");\r
+                                                           }\r
+                                               } // if (index + 2 < TXT[I-1].length())\r
+                                           } // if (index >= 0)\r
+                                   } // if (!uifound) {\r
+                                   else {\r
+                                       imagString = TXT[I-1];\r
+                                       if (!firstImagStringWritten) {\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       else if ((imagString != null) && (imagString.length() != 0)) {\r
+                                           raFile.writeBytes(PAD + imagString);\r
+                                       }\r
+                                       firstImagStringWritten = true;\r
+                                           if (I == NTX) {\r
+                                               raFile.writeBytes(";\n");\r
+                                           }\r
                                    }\r
-                               }\r
+                               } // for (I = 1; I <= NTX; I++)\r
                                if (!uifound) {\r
                                    raFile.writeBytes(PAD + "ZRAD[1] = 0.0;\n");\r
                                }\r
-                               else {\r
-                                       // NTX = 1 if statements are entered without newlines for\r
-                                       // multiple lines\r
-                                       raFile.writeBytes(PAD + "ZRAD[1] = ");\r
-                                       for (I = 1; I <= NTX; I++) {\r
-                                               int index = TXT[I - 1].indexOf("ui");\r
-                                               String imagString = null;\r
-                                               if ((index >= 0) && (index + 2 < TXT[I - 1].length())) {\r
-                                                       imagString = TXT[I - 1].substring(index + 2);\r
-                                                       raFile.writeBytes(imagString);\r
-                                               }\r
-                                               if (I == NTX) {\r
-                                                       raFile.writeBytes(";\n");\r
-                                               }\r
-                                       }\r
-                               }\r
                                raFile.writeBytes(PAD + VAR + "ANS[0] = ZRAD[0]*Math.exp(-T[1])*Math.cos(T[0]) - ZRAD[1]*Math.exp(-T[1])*Math.sin(T[0]);\n");\r
                                raFile.writeBytes(PAD + VAR + "ANS[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\n");\r
                                raFile.writeBytes("//\n");\r
@@ -1886,8 +1942,9 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 2)\r
                        else if (NUMDER) {\r
+                               // Use numerical derivative if no analytical expression is supplied for TYPE == 3 or TYPE == 4.\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes("      " + VAR + "ANS = ZDPARF(" + CHIA + "," + CHTT + ");\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS = ZDPARF(" + CHIA + "," + CHTT + ");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else if (NUMDER)\r
                        else if (TYPE == 3) {\r
@@ -1896,7 +1953,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0]*(" + HA + ");\n");\r
                                raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1]*(" + HA + ");\n");\r
-                               if (TXT2[0].indexOf("ui") == 0) {\r
+                               if (TXT2[0].toLowerCase().indexOf("ui") == 0) {\r
                                    raFile.writeBytes(PAD + VAR + "ANS[0] = 0.0;\n");\r
                                }\r
                                else {\r
@@ -1904,46 +1961,66 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        // multiple lines\r
                                        raFile.writeBytes(PAD + VAR + "ANS[0] = " + HA + "*(");\r
                                        for (I = 1; I <= NTX2; I++) {\r
-                                               int index = TXT2[I - 1].indexOf("ui");\r
+                                               int index = TXT2[I - 1].toLowerCase().indexOf("ui");\r
+                                               if (index == 0) {\r
+                                                       raFile.writeBytes(");\n");\r
+                                                       break;\r
+                                               }\r
                                                String realString = null;\r
                                                if (index == -1) {\r
-                                                       realString = TXT2[I - 1];\r
-                                               } else {\r
-                                                       realString = TXT2[I - 1].substring(0, index);\r
+                                                       realString = TXT2[I-1];\r
                                                }\r
-                                               if ((index == -1) || (index > 0)) {\r
-                                                       raFile.writeBytes(realString);\r
+                                               else {\r
+                                                       realString = TXT2[I - 1].substring(0, index);   \r
                                                }\r
-                                               if (I == NTX2) {\r
-                                                       raFile.writeBytes(");\n");\r
+                                               if ((I > 1) && (realString != null) && (realString.length() != 0)) {\r
+                                                       raFile.writeBytes("\n" + PAD);\r
+                                               }\r
+                                               if ((realString != null) && (realString.length() != 0)) {\r
+                                                   raFile.writeBytes(realString);\r
+                                               }\r
+                                               if ((I == NTX2) || (index > 0)) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                                       break;\r
                                                }\r
                                        }\r
                                }\r
                                boolean uifound = false;\r
+                               String imagString = null;\r
+                               boolean firstImagStringWritten = false;\r
                                for (I = 1; I <= NTX2; I++) {\r
-                                   if (TXT2[I-1].indexOf("ui") >= 0) {\r
-                                       uifound = true;\r
+                                       if (!uifound) {\r
+                                       int index = TXT2[I-1].toLowerCase().indexOf("ui");\r
+                                           if (index >= 0) {\r
+                                               uifound = true;\r
+                                               raFile.writeBytes(PAD + VAR + "ANS[1] = " + HA + "*(");\r
+                                               if (index + 2 < TXT2[I-1].length()) {\r
+                                                       imagString = TXT2[I - 1].substring(index + 2);\r
+                                                           raFile.writeBytes(imagString);\r
+                                                           firstImagStringWritten = true;\r
+                                                           if (I == NTX2) {\r
+                                                               raFile.writeBytes(");\n");\r
+                                                           }\r
+                                               } // if (index + 2 < TXT2[I-1].length())\r
+                                           } // if (index >= 0)\r
+                                   } // if (!uifound) {\r
+                                   else {\r
+                                       imagString = TXT2[I-1];\r
+                                       if (!firstImagStringWritten) {\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       else if ((imagString != null) && (imagString.length() != 0)) {\r
+                                           raFile.writeBytes(PAD + imagString);\r
+                                       }\r
+                                       firstImagStringWritten = true;\r
+                                           if (I == NTX2) {\r
+                                               raFile.writeBytes(");\n");\r
+                                           }\r
                                    }\r
-                               }\r
+                               } // for (I = 1; I <= NTX2; I++)\r
                                if (!uifound) {\r
                                    raFile.writeBytes(PAD + VAR + "ANS[1] = 0.0;\n");\r
                                }\r
-                               else {\r
-                               // NTX2 = 1 if statements are entered without newlines for\r
-                               // multiple lines\r
-                                       raFile.writeBytes(PAD + VAR + "ANS[1] = " + HA + "*(");\r
-                                       for (I = 1; I <= NTX2; I++) {\r
-                                               int index = TXT2[I - 1].indexOf("ui");\r
-                                               String imagString = null;\r
-                                               if ((index >= 0) && (index + 2 < TXT2[I - 1].length())) {\r
-                                                       imagString = TXT2[I - 1].substring(index + 2);\r
-                                                       raFile.writeBytes(imagString);\r
-                                               }\r
-                                               if (I == NTX2) {\r
-                                                       raFile.writeBytes(");\n");\r
-                                               }\r
-                                       }\r
-                               }\r
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 3)\r
                        else {\r
@@ -1952,55 +2029,76 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0]*(" + HA + ");\n");\r
                                raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1]*(" + HA + ");\n");\r
-                               if (TXT1[0].indexOf("ui") == 0) {\r
+                               if (TXT1[0].toLowerCase().indexOf("ui") == 0) {\r
                                    raFile.writeBytes(PAD + "ZRAD[0] = 0.0;\n");\r
                                }\r
                                else {\r
-                                       // NTX1 = 1 if statements are entered without newlines for\r
+                                       // NTX = 1 if statements are entered without newlines for\r
                                        // multiple lines\r
                                        raFile.writeBytes(PAD + "ZRAD[0] = ");\r
                                        for (I = 1; I <= NTX1; I++) {\r
-                                               int index = TXT1[I - 1].indexOf("ui");\r
+                                               int index = TXT1[I - 1].toLowerCase().indexOf("ui");\r
+                                               if (index == 0) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                                       break;\r
+                                               }\r
                                                String realString = null;\r
                                                if (index == -1) {\r
-                                                       realString = TXT1[I - 1];\r
-                                               } else {\r
-                                                       realString = TXT1[I - 1].substring(0, index);\r
+                                                       realString = TXT1[I-1];\r
                                                }\r
-                                               if ((index == -1) || (index > 0)) {\r
-                                                       raFile.writeBytes(realString);\r
+                                               else {\r
+                                                       realString = TXT1[I - 1].substring(0, index);   \r
+                                               }\r
+                                               if ((I > 1) && (realString != null) && (realString.length() != 0)) {\r
+                                                       raFile.writeBytes("\n" + PAD);\r
+                                               }\r
+                                               if ((realString != null) && (realString.length() != 0)) {\r
+                                                   raFile.writeBytes(realString);\r
                                                }\r
-                                               if (I == NTX1) {\r
+                                               if ((I == NTX1) || (index > 0)) {\r
                                                        raFile.writeBytes(";\n");\r
+                                                       break;\r
                                                }\r
                                        }\r
                                }\r
                                boolean uifound = false;\r
+                               String imagString = null;\r
+                               boolean firstImagStringWritten = false;\r
                                for (I = 1; I <= NTX1; I++) {\r
-                                   if (TXT1[I-1].indexOf("ui") >= 0) {\r
-                                       uifound = true;\r
+                                       if (!uifound) {\r
+                                       int index = TXT1[I-1].toLowerCase().indexOf("ui");\r
+                                           if (index >= 0) {\r
+                                               uifound = true;\r
+                                               raFile.writeBytes(PAD + "ZRAD[1] = ");\r
+                                               if (index + 2 < TXT1[I-1].length()) {\r
+                                                       imagString = TXT1[I - 1].substring(index + 2);\r
+                                                           raFile.writeBytes(imagString);\r
+                                                           firstImagStringWritten = true;\r
+                                                           if (I == NTX1) {\r
+                                                               raFile.writeBytes(";\n");\r
+                                                           }\r
+                                               } // if (index + 2 < TXT1[I-1].length())\r
+                                           } // if (index >= 0)\r
+                                   } // if (!uifound) {\r
+                                   else {\r
+                                       imagString = TXT1[I-1];\r
+                                       if (!firstImagStringWritten) {\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       else if ((imagString != null) && (imagString.length() != 0)) {\r
+                                           raFile.writeBytes(PAD + imagString);\r
+                                       }\r
+                                       firstImagStringWritten = true;\r
+                                           if (I == NTX1) {\r
+                                               raFile.writeBytes(";\n");\r
+                                           }\r
                                    }\r
-                               }\r
+                               } // for (I = 1; I <= NTX1; I++)\r
                                if (!uifound) {\r
                                    raFile.writeBytes(PAD + "ZRAD[1] = 0.0;\n");\r
                                }\r
-                               else {\r
-                                       // NTX1 = 1 if statements are entered without newlines for\r
-                                       // multiple lines\r
-                                       raFile.writeBytes(PAD + "ZRAD[1] = ");\r
-                                       for (I = 1; I <= NTX1; I++) {\r
-                                               int index = TXT1[I - 1].indexOf("ui");\r
-                                               String imagString = null;\r
-                                               if ((index >= 0) && (index + 2 < TXT1[I - 1].length())) {\r
-                                                       imagString = TXT1[I - 1].substring(index + 2);\r
-                                                       raFile.writeBytes(imagString);\r
-                                               }\r
-                                               if (I == NTX1) {\r
-                                                       raFile.writeBytes(";\n");\r
-                                               }\r
-                                       }\r
-                               }\r
-                               if (TXT2[0].indexOf("ui") == 0) {\r
+                               \r
+                               if (TXT2[0].toLowerCase().indexOf("ui") == 0) {\r
                                    raFile.writeBytes(PAD + "ZDER[0] = 0.0;\n");\r
                                }\r
                                else {\r
@@ -2008,46 +2106,68 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        // multiple lines\r
                                        raFile.writeBytes(PAD + "ZDER[0] = ");\r
                                        for (I = 1; I <= NTX2; I++) {\r
-                                               int index = TXT2[I - 1].indexOf("ui");\r
+                                               int index = TXT2[I - 1].toLowerCase().indexOf("ui");\r
+                                               if (index == 0) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                                       break;\r
+                                               }\r
                                                String realString = null;\r
                                                if (index == -1) {\r
-                                                       realString = TXT2[I - 1];\r
-                                               } else {\r
-                                                       realString = TXT2[I - 1].substring(0, index);\r
+                                                       realString = TXT2[I-1];\r
+                                               }\r
+                                               else {\r
+                                                       realString = TXT2[I - 1].substring(0, index);   \r
                                                }\r
-                                               if ((index == -1) || (index > 0)) {\r
-                                                       raFile.writeBytes(realString);\r
+                                               if ((I > 1) && (realString != null) && (realString.length() != 0)) {\r
+                                                       raFile.writeBytes("\n" + PAD);\r
                                                }\r
-                                               if (I == NTX2) {\r
+                                               if ((realString != null) && (realString.length() != 0)) {\r
+                                                   raFile.writeBytes(realString);\r
+                                               }\r
+                                               if ((I == NTX2) || (index > 0)) {\r
                                                        raFile.writeBytes(";\n");\r
+                                                       break;\r
                                                }\r
                                        }\r
                                }\r
                                uifound = false;\r
+                               imagString = null;\r
+                               firstImagStringWritten = false;\r
                                for (I = 1; I <= NTX2; I++) {\r
-                                   if (TXT2[I-1].indexOf("ui") >= 0) {\r
-                                       uifound = true;\r
+                                       if (!uifound) {\r
+                                       int index = TXT2[I-1].toLowerCase().indexOf("ui");\r
+                                           if (index >= 0) {\r
+                                               uifound = true;\r
+                                               raFile.writeBytes(PAD + "ZDER[1] = ");\r
+                                               if (index + 2 < TXT2[I-1].length()) {\r
+                                                       imagString = TXT2[I - 1].substring(index + 2);\r
+                                                           raFile.writeBytes(imagString);\r
+                                                           firstImagStringWritten = true;\r
+                                                           if (I == NTX2) {\r
+                                                               raFile.writeBytes(";\n");\r
+                                                           }\r
+                                               } // if (index + 2 < TXT2[I-1].length())\r
+                                           } // if (index >= 0)\r
+                                   } // if (!uifound) {\r
+                                   else {\r
+                                       imagString = TXT2[I-1];\r
+                                       if (!firstImagStringWritten) {\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       else if ((imagString != null) && (imagString.length() != 0)) {\r
+                                           raFile.writeBytes(PAD + imagString);\r
+                                       }\r
+                                       firstImagStringWritten = true;\r
+                                           if (I == NTX2) {\r
+                                               raFile.writeBytes(";\n");\r
+                                           }\r
                                    }\r
-                               }\r
+                               } // for (I = 1; I <= NTX2; I++)\r
                                if (!uifound) {\r
                                    raFile.writeBytes(PAD + "ZDER[1] = 0.0;\n");\r
                                }\r
-                               else {\r
-                                       // NTX2 = 1 if statements are entered without newlines for\r
-                                       // multiple lines\r
-                                       raFile.writeBytes(PAD + "ZDER[1] = ");\r
-                                       for (I = 1; I <= NTX2; I++) {\r
-                                               int index = TXT2[I - 1].indexOf("ui");\r
-                                               String imagString = null;\r
-                                               if ((index >= 0) && (index + 2 < TXT2[I - 1].length())) {\r
-                                                       imagString = TXT2[I - 1].substring(index + 2);\r
-                                                       raFile.writeBytes(imagString);\r
-                                               }\r
-                                               if (I == NTX2) {\r
-                                                       raFile.writeBytes(";\n");\r
-                                               }\r
-                                       }\r
-                               }\r
+                               \r
+                               \r
                                raFile.writeBytes(PAD + VAR + "ANS[0] = ((ZDER[0] - ZRAD[1])* Math.cos(T[0]) - (ZRAD[0] + ZDER[1])* Math.sin(T[0]))*Math.exp(-T[1])*(" + HA + ");\n");\r
                                raFile.writeBytes(PAD + VAR + "ANS[1] = ((ZDER[0] - ZRAD[1])* Math.sin(T[0]) + (ZRAD[0] + ZDER[1])* Math.cos(T[0]))*Math.exp(-T[1])*(" + HA + ");\n");\r
                                raFile.writeBytes("//\n");\r