/*************************************************************************** * Copyright (C) 2007 by Abderrahman Taha * * * * * * This program 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 2 of the License, or * * (at your option) any later version. * * * * This program 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 this program;if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "ParisoMathObject.h" #include #include //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// ParisoMathObject::ParisoMathObject(){ pariso.EquationsNumber = 0; EquationsNames.append(";Icosahedron;"); EquationsNames.append(";pseudo_Duplin;"); EquationsNames.append(";pseudo_Torus;"); EquationsNames.append(";Bugs;"); EquationsNames.append(";DifferenceSpheres;"); EquationsNames.append(";BlendSpheres;"); EquationsNames.append(";Holes;"); EquationsNames.append(";Gyroid;"); EquationsNames.append(";Diamand;"); EquationsNames.append(";Tetrahedral;"); EquationsNames.append(";DuplinCyclides;"); EquationsNames.append(";Hyperboloid;"); EquationsNames.append(";Hyperbolic;"); EquationsNames.append(";Sinus;"); EquationsNames.append(";Octahedron;"); EquationsNames.append(";UnionSpheres;"); EquationsNames.append(";IntersectSpheres;"); EquationsNames.append(";Blobs;"); EquationsNames.append(";Virus;"); EquationsNames.append(";BlobySchwartz;"); EquationsNames.append(";Blobs_2;"); EquationsNames.append(";OrthoCircle;"); EquationsNames.append(";CubeSphere;"); EquationsNames.append(";CubeSphere_2;"); EquationsNames.append(";Holes_2;"); EquationsNames.append(";Virus_2;"); EquationsNames.append(";Schwartz;"); EquationsNames.append(";Schwartz_Morph;"); EquationsNames.append(";Blob_Morph;"); EquationsNames.append(";Torus;"); EquationsNames.append(";TwoCylinderBlend;"); EquationsNames.append(";BlendThreeCylinder;"); EquationsNames.append(";Sphere;"); EquationsNames.append(";RoundCube;"); EquationsNames.append(";Toupie;"); EquationsNames.append(";Chmutov;"); EquationsNames.append(";Chmutov_2;"); EquationsNames.append(";Clebsch;"); EquationsNames.append(";DingDong;"); EquationsNames.append(";Trap;"); EquationsNames.append(";Cube;"); EquationsNames.append(";Drope;"); EquationsNames.append(";Leminescape;"); EquationsNames.append(";Klein;"); EquationsNames.append(";Chain;"); EquationsNames.append(";Chain_2;"); EquationsNames.append(";TickIso;"); EquationsNames.append(";TickIso_1;"); EquationsNames.append(";CloseIso;"); EquationsNames.append(";CloseIso_1;"); EquationsNames.append(";CloseIso_2;"); EquationsNames.append(";Warning;"); }; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// ParisoMathObject::~ParisoMathObject(){ }; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// void ParisoMathObject::DrawIsoSurface(){ }; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// void ParisoMathObject::LoadScript (QString filename, int type){ int current = 0, currentfunction = 0, separator =0; QString name, line, function, xlimit, ylimit, zlimit, ulimit, vlimit, xmin, xmax, ymin, ymax, zmin, zmax, umin, umax, vmin, vmax, Xfct, Yfct, Zfct, condition, Au, Bu, Cu, Duv, Euv, Fuv, comments, fctcomts, cndcomments; static int equationsNumber=0; //static int previousequationsNumber=0; QFile file( filename ); if(type == 1) { if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); while ( !stream.atEnd() ) { line = (stream.readLine()).simplifyWhiteSpace();// line of text excluding '\n' if (line.contains("F():")) currentfunction = 1; else if (line.contains("[x]:")) currentfunction = 2; else if (line.contains("[y]:")) currentfunction = 3; else if (line.contains("[z]:")) currentfunction = 4; else if (line.contains("Cnd:")) currentfunction = 5; else if (line.contains("A[u]:")) currentfunction = 6; else if (line.contains("B[u]:")) currentfunction = 7; else if (line.contains("C[u]:")) currentfunction = 8; else if (line.contains("D[u,v]:")) currentfunction = 9; else if (line.contains("E[u,v]:")) currentfunction = 10; else if (line.contains("F[u,v]:")) currentfunction = 11; else if (line.contains("#")) currentfunction = 12; else if (line.contains("/*")) currentfunction = 13; else if (line.contains("*/")) currentfunction = 14; else if (line.contains("Name:")) currentfunction = 15; else if (line.contains(";")) currentfunction = 16; else currentfunction = 18; switch(currentfunction) { case 1: function = line.remove(0, 4);current = 1;break; case 2: xlimit = line.remove(0, 4);current = 2;break; case 3: ylimit = line.remove(0, 4);current = 3;break; case 4: zlimit = line.remove(0, 4);current = 4;break; case 5: condition = line.remove(0, 4);current = 5;break; case 6: Au = line.remove(0, 5);current = 6;break; case 7: Bu = line.remove(0, 5);current = 7;break; case 8: Cu = line.remove(0, 5);current = 8;break; case 9: Duv = line.remove(0, 7);current = 9;break; case 10: Euv = line.remove(0, 7);current =10;break; case 11: Fuv = line.remove(0, 7);current =11;break; case 12: comments = line+"\n"; current =12;break; case 13: fctcomts = line+"\n"; current =13;break; case 14: fctcomts += line+"\n"; current =14;break; case 15: name = line.remove(0, 5);current =15;break; case 16: // Save the equation: name = name.simplifyWhiteSpace(); if( EquationsNames.contains(";"+name+";") == 0){ pariso.EquationsNumber = equationsNumber + 1; (name != "") ? pariso.FunctionsNames[equationsNumber]= name : pariso.FunctionsNames[equationsNumber] = QString::number(pariso.EquationsNumber); EquationsNames.append(";"+pariso.FunctionsNames[equationsNumber]+";"); pariso.FunctionsInfos[equationsNumber] = comments; pariso.FunctionsEquations[equationsNumber] = fctcomts+"\n"+(function.simplifyWhiteSpace()); pariso.FunctionsConditions[equationsNumber] = condition; xlimit = xlimit.simplifyWhiteSpace(); separator = xlimit.find(","); xmin = xlimit.left(separator); xmax = xlimit.remove(xmin+","); pariso.xlimitinfsup[0][equationsNumber] = xmin.simplifyWhiteSpace(); pariso.xlimitinfsup[1][equationsNumber] = xmax.simplifyWhiteSpace(); ylimit = ylimit.simplifyWhiteSpace(); separator = ylimit.find(","); ymin = ylimit.left(separator); ymax = ylimit.remove(ymin+","); pariso.ylimitinfsup[0][equationsNumber] = ymin.simplifyWhiteSpace(); pariso.ylimitinfsup[1][equationsNumber] = ymax.simplifyWhiteSpace(); zlimit = zlimit.simplifyWhiteSpace(); separator = zlimit.find(","); zmin = zlimit.left(separator); zmax = zlimit.remove(zmin+","); pariso.zlimitinfsup[0][equationsNumber] = zmin.simplifyWhiteSpace(); pariso.zlimitinfsup[1][equationsNumber] = zmax.simplifyWhiteSpace(); equationsNumber++; } else { /* QMessageBox message; message.setText(tr(QString("The name \""+name+"\" is already used..."))); message.adjustSize (); message.exec(); */ } current =16; // Init all Parameters fo new formula: name = comments = fctcomts = condition = ""; xmin = xmax = ymin = ymax = zmin = zmax = ""; xlimit = ylimit = zlimit = ""; break; case 18: if (current == 1) function += line; else if (current == 2) xlimit += line; else if (current == 3) ylimit += line; else if (current == 4) zlimit += line; else if (current == 5) condition += line; else if (current == 6) Au += line; else if (current == 7) Bu += line; else if (current == 8) Cu += line; else if (current == 9) Duv += line; else if (current == 10) Euv += line; else if (current == 11) Fuv += line; else if (current == 12) comments += line; else if (current == 13) fctcomts += line+"\n"; else if (current == 14) fctcomts += line; else if (current == 15) name += line; else if (current == 16); break; } } file.close(); /* pariso.EquationsNumber = equationsNumber + 1; pariso.FunctionsNames[equationsNumber] = name; pariso.FunctionsInfos[equationsNumber] = comments; pariso.FunctionsEquations[equationsNumber] = fctcomts+"\n"+(function.simplifyWhiteSpace()); pariso.FunctionsConditions[equationsNumber] = condition; xlimit = xlimit.simplifyWhiteSpace(); separator = xlimit.find(","); xmin = xlimit.left(separator); xmax = xlimit.remove(xmin+","); pariso.xlimitinfsup[0][equationsNumber] = xmin.simplifyWhiteSpace(); pariso.xlimitinfsup[1][equationsNumber] = xmax.simplifyWhiteSpace(); ylimit = ylimit.simplifyWhiteSpace(); separator = ylimit.find(","); ymin = ylimit.left(separator); ymax = ylimit.remove(ymin+","); pariso.ylimitinfsup[0][equationsNumber] = ymin.simplifyWhiteSpace(); pariso.ylimitinfsup[1][equationsNumber] = ymax.simplifyWhiteSpace(); zlimit = zlimit.simplifyWhiteSpace(); separator = zlimit.find(","); zmin = zlimit.left(separator); zmax = zlimit.remove(zmin+","); pariso.zlimitinfsup[0][equationsNumber] = zmin.simplifyWhiteSpace(); pariso.zlimitinfsup[1][equationsNumber] = zmax.simplifyWhiteSpace(); */ } } else if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); while ( !stream.atEnd() ) { line = stream.readLine();// line of text excluding '\n' if (line.contains("X():")) currentfunction = 1; else if (line.contains("Y():")) currentfunction = 2; else if (line.contains("Z():")) currentfunction = 3; else if (line.contains("[u]:")) currentfunction = 4; else if (line.contains("[v]:")) currentfunction = 5; else if (!line.contains("#")) currentfunction = 6; else currentfunction = 7; switch(currentfunction) { case 1: Xfct = line.remove(0, 4);current = 1;break; case 2: Yfct = line.remove(0, 4);current = 2;break; case 3: Zfct = line.remove(0, 4);current = 3;break; case 4: ulimit = line.remove(0, 4);current = 4;break; case 5: vlimit = line.remove(0, 4);current = 5;break; case 6: if (current == 1) Xfct += line; else if (current == 2) Yfct += line; else if (current == 3) Zfct += line; else if (current == 4) ulimit += line; else if (current == 5) vlimit += line; break; case 7: break; } } file.close(); pariso.XFunctionsEquations[0] = Xfct.simplifyWhiteSpace(); pariso.YFunctionsEquations[0] = Yfct.simplifyWhiteSpace(); pariso.ZFunctionsEquations[0] = Zfct.simplifyWhiteSpace(); ulimit = ulimit.simplifyWhiteSpace(); separator = ulimit.find(","); umin = ulimit.left(separator); umax = ulimit.remove(umin+","); pariso.ulimitinfsup[0][0] = umin.simplifyWhiteSpace(); pariso.ulimitinfsup[1][0] = umax.simplifyWhiteSpace(); vlimit = vlimit.simplifyWhiteSpace(); separator = vlimit.find(","); vmin = vlimit.left(separator); vmax = vlimit.remove(vmin+","); pariso.vlimitinfsup[0][0] = vmin.simplifyWhiteSpace(); pariso.vlimitinfsup[1][0] = vmax.simplifyWhiteSpace(); } }; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// void ParisoMathObject::ExecuteScript(){ }; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// QString ParisoMathObject::ChangeScript(QString result, QString name, QString CND, QString* limits, QString* uservariables){ QString FinalText, isofct, comment, tmp; int startcomment, endcomment, length; if(limits == NULL) { result = result.replace("[x,y]","xy"); result = result.replace("[x,z]","xz"); result = result.replace("[y,z]","yz"); result = result.replace("[y,x]","yx"); result = result.replace("[z,x]","zx"); result = result.replace("[z,y]","zy"); result = result.replace("[",""); result = result.replace("]",""); result = result.replace("f(x,y,z)=",""); startcomment = result.find("/*"); endcomment = result.find("*/"); result = result.remove(startcomment, endcomment - startcomment +2); return(result); } else { //Name: FinalText += "Name: "+name+"\n"; // User defined variables: if(!(uservariables[0]== "") || !(uservariables[1]== "") || !(uservariables[2]== "") || !(uservariables[3]== "") || !(uservariables[4]== "") || !(uservariables[5]== "") ){ FinalText += "# User defined variables for calcul optimisation:\n"; if(uservariables[0]!="") FinalText += "A[u]: "+uservariables[0]+"\n"; if(uservariables[1]!="") FinalText += "B[u]: "+uservariables[1]+"\n"; if(uservariables[2]!="") FinalText += "C[u]: "+uservariables[2]+"\n"; if(uservariables[3]!="") FinalText += "D[u,v]: "+uservariables[3]+"\n"; if(uservariables[4]!="") FinalText += "E[u,v]: "+uservariables[4]+"\n"; if(uservariables[5]!="") FinalText += "F[u,v]: "+uservariables[5]+"\n"; FinalText +="\n"; } // Main isosurface formulas: //FinalText += "# Isosurface formulas:\n"; length = result.length(); startcomment = result.find("/*"); endcomment = result.find("*/"); tmp = result; isofct = (tmp.remove(startcomment,endcomment-startcomment+2)); tmp = result; comment = tmp.remove(isofct); if(comment != "") FinalText += comment+"\n"; FinalText += "F(): "+isofct.remove("\n")+"\n"; // Domaine definition: FinalText += "[x]: "+limits[0]+" , "+limits[1]+"\n"; FinalText += "[y]: "+limits[2]+" , "+limits[3]+"\n"; FinalText += "[z]: "+limits[4]+" , "+limits[5]+"\n"; //Condition: if(CND != "") { //FinalText += "#Condition:\n"; FinalText += "Cnd: "+CND+"\n"; } FinalText += ";"; return(FinalText); } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// void ParisoMathObject::LookForIsosurfaceEquation(QString choix){ if(choix == QString("Icosahedron")) { Isosurface[0] = QString("if( (x^2 + y^2 +z^2 < 35), 2 - (cos(x + (1+sqrt(5))/2*y) + cos(x - (1+sqrt(5))/2*y) + cos(y + (1+sqrt(5))/2*z) + cos(y - (1+sqrt(5))/2*z) + cos(z - (1+sqrt(5))/2*x) + cos(z + (1+sqrt(5))/2*x)) , 1)"); Isosurface[1] = "-5.5"; Isosurface[2] = "-5.5"; Isosurface[3] = "-5.5"; Isosurface[4] = "5.5"; Isosurface[5] = "5.5"; Isosurface[6] = "5.5"; } else if(choix == QString("pseudo_Duplin")) { Isosurface[0] = "(2^2 - 0^2 - (2 + 2.1)^2) * (2^2 - 0^2 - (2 - 2.1)^2)*(((x/0.6)/3.9)^4+(y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))^4+(y*sin(0.575383*(x/0.6)) + z*cos(0.575383*(x/0.6)))^4)+ 2*((2^2 - 0^2 - (2 + 2.1)^2 )*(2^2 - 0^2 - (2 - 2.1)^2)* (((x/0.6)/3.9)^2 * (y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))^2+((x/0.6)/3.9)^2 * (y*sin(0.575383*(x/0.6)) + z*cos(0.575383*(x/0.6)))^2+(y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))^2 * (y*sin(0.575383*(x/0.6)) + z*cos(0.575383*(x/0.6)))^2))+2* 2^2 *((-0^2-2^2+2^2+2.1^2)* (2 *((x/0.6)/3.9) *2+2* (y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))* 0-2^2)-4*0 *2.1^2 *(y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6))))*(((x/0.6)/3.9)^2+(y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))^2+(y*sin(0.575383*(x/0.6)) + z*cos(0.575383*(x/0.6)))^2)+ 4 * 2^4 * (2 *((x/0.6)/3.9)+0 *(y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6))))* (-2^2+0 * (y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))+2 * ((x/0.6)/3.9))+4* 2^4 * 2.1^2 * (y*cos(0.575383*(x/0.6)) - z*sin(0.575383*(x/0.6)))^2+2^8"; Isosurface[1] = "-2*3.9*0.6"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2.2*3.9*0.6"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("pseudo_Torus")) { Isosurface[0] = "(sqrt((x/2.7)*(x/2.7)+(y*sin(0.436332*x) + z*cos(0.436332*x))*(y*sin(0.436332*x) + z*cos(0.436332*x)))-3)^2 + (y*cos(0.436332*x) - z*sin(0.436332*x))*(y*cos(0.436332*x) - z*sin(0.436332*x)) - 1"; Isosurface[1] = "-4*2.7"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4*2.7"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("Bugs")) { Isosurface[0] = "min( ((x*cos(0.866646*y) - z*sin(0.866646*y))-0.7)*((x*cos(0.866646*y) - z*sin(0.866646*y))-0.7) + (y/2.9)*(y/2.9) + (x*sin(0.866646*y) + z*cos(0.866646*y))*(x*sin(0.866646*y) + z*cos(0.866646*y)) - 1, ((x*cos(0.866646*y) - z*sin(0.866646*y))+0.5)*((x*cos(0.866646*y) - z*sin(0.866646*y))+0.5) + (y/2.9)*(y/2.9) + (x*sin(0.866646*y) + z*cos(0.866646*y))*(x*sin(0.866646*y) + z*cos(0.866646*y)) - 1)"; Isosurface[1] = "-2"; Isosurface[2] = "-2*2.9*1"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2*2.9*1"; Isosurface[6] = "2"; } else if(choix == QString("DifferenceSpheres")) { Isosurface[0] = "((x-0.7)*(x-0.7) + y*y + z*z - 1)*min( (x-0.7)*(x-0.7) + y*y + z*z - 1, (x+0.3)*(x+0.3) + y*y + z*z - 1) +0.02"; Isosurface[1] = "-2"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "0.1"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("BlendSpheres")) { Isosurface[0] = "((x-0.9)*(x-0.9) + y*y + z*z - 1)*((x+0.9)*(x+0.9) + y*y + z*z - 1) -0.3"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Holes")) { Isosurface[0] = "3*(cos(x) + cos(y) + cos(z)) + 4* cos(x) * cos(y) * cos(z)"; Isosurface[1] = "-3"; Isosurface[2] = "-3"; Isosurface[3] = "-3"; Isosurface[4] = "3"; Isosurface[5] = "3"; Isosurface[6] = "3"; } else if(choix == QString("Gyroid")) { Isosurface[0] = "cos(x) * sin(y) + cos(y) * sin(z) + cos(z) * sin(x)"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("Diamand")) { Isosurface[0] = "sin(x) *sin(y) *sin(z) +sin(x) * cos(y) * cos(z) +cos(x) * sin(y) * cos(z) + cos(x) * cos(y) * sin(z)"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("Tetrahedral")) { Isosurface[0] = "(x^2 + y^2 + z^2)^2 + 8*x*y*z - 10*(x^2 + y^2 + z^2) + 25"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("DuplinCyclides")) { Isosurface[0] = "(2^2 - 0^2 - (2 + 2.1)^2) * (2^2 - 0^2 - (2 - 2.1)^2)*(x^4+y^4+z^4)+ 2*((2^2 - 0^2 - (2 + 2.1)^2 )*(2^2 - 0^2 - (2 - 2.1)^2)* (x^2 * y^2+x^2 * z^2+y^2 * z^2))+2* 2^2 *((-0^2-2^2+2^2+2.1^2)* (2 *x *2+2* y* 0-2^2)-4*0 *2.1^2 *y)*(x^2+y^2+z^2)+ 4 * 2^4 * (2 *x+0 *y)* (-2^2+0 * y+2 * x)+4* 2^4 * 2.1^2 * y^2+2^8"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-1.3"; Isosurface[4] = "2.2"; Isosurface[5] = "2"; Isosurface[6] = "1.3"; } else if(choix == QString("Hyperboloid")) { Isosurface[0] = "x^2 + y^2 - z^2 -0.3"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-1.8"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "1.8"; } else if(choix == QString("Hyperbolic")) { Isosurface[0] = "x*x + y - z*z"; Isosurface[1] = "-1"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "1"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("Sinus")) { Isosurface[0] = "sin(pi*((x)^2+(y)^2))/2 +z"; Isosurface[1] = "-1"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "1"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("Octahedron")) { Isosurface[0] = "abs(x)+abs(y)+abs(z) - 1"; Isosurface[1] = "-1"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "1"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("UnionSpheres")) { Isosurface[0] = "min( (x-0.7)*(x-0.7) + y*y + z*z - 1, (x+0.5)*(x+0.5) + y*y + z*z - 1)"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("IntersectSpheres")) { Isosurface[0] = "max( (x-0.7)*(x-0.7) + y*y + z*z - 1, (x+0.5)*(x+0.5) + y*y + z*z - 1)"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Blobs")) { Isosurface[0] = "x^2 + y ^2 + z^2 +cos(4*x)+cos(4*y)+cos(4*z)-0.2"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Blobs_2")) { Isosurface[0] = "x^2 + y ^2 + z^2 +sin(4*x) + sin(4*y) + sin(4*z) -1"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("OrthoCircle")) { Isosurface[0] = "((x^2 + y^2 - 1)^2 + z^2)* ((y^2 + z^2 - 1)^2 + x^2)* ((z^2 + x^2 - 1)^2 + y^2) - 0.075^2 *(1 + 3* (x^2 + y^2 + z^2))"; Isosurface[1] = "-1.5"; Isosurface[2] = "-1.5"; Isosurface[3] = "-1.5"; Isosurface[4] = "1.5"; Isosurface[5] = "1.5"; Isosurface[6] = "1.5"; } else if(choix == QString("CubeSphere")) { Isosurface[0] = " ((1/2.3)^2 *(x^2 + y^2 + z^2))^-6 + ( (1/2)^8 * (x^8 + y^8 + z^8) )^6 -1"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("CubeSphere_2")) { Isosurface[0] = "12 - ((1/2.3)^2 *(x^2 + y^2 + z^2))^-6 - ( (1/2)^8 * (x^8 + y^8 + z^8) )^6"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Holes_2")) { Isosurface[0] = "sin(4*x) + sin(4*y) + sin(4*z) + 4*x*y*z"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Virus_2")) { Isosurface[0] = "cos(x) + cos(y) + cos(z) - 1"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("Schwartz")) { Isosurface[0] = "/* \n\ Author: Schwartz ... \n\ */\n -(cos(x) + cos(y) + cos(z))"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("Schwartz_Morph")) { Isosurface[0] = "/* \n This example is to demonstrate the Morph effect \n*/\n\ -(cos(x) + cos(y) + cos(z) - t)"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("Blob_Morph")) { Isosurface[0] = "/* \n This example is to demonstrate the Morph effect \n*/\n\ ((x-0.9*2*t)*(x-0.9*2*t)+y*y+z*z-1)*((x+0.9*2*t)*(x+0.9*2*t)+y*y+z*z -1)-0.3"; Isosurface[1] = "-3"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "3"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Torus")) { Isosurface[0] = "(sqrt(x*x+y*y)-3)^2 + z*z - 1"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-1"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "1"; } else if(choix == QString("TwoCylinderBlend")) { Isosurface[0] = "(x^2 + y^2 - 1) * ( x^2 + z^2 - 1) - 1"; Isosurface[1] = "-3"; Isosurface[2] = "-3"; Isosurface[3] = "-3"; Isosurface[4] = "3"; Isosurface[5] = "3"; Isosurface[6] = "3"; } else if(choix == QString("BlendThreeCylinder")) { Isosurface[0] = "(x^2 + y^2 - 1) * ( x^2 + z^2 - 1)* ( y^2 + z^2 - 1) - 1"; Isosurface[1] = "-3"; Isosurface[2] = "-3"; Isosurface[3] = "-3"; Isosurface[4] = "3"; Isosurface[5] = "3"; Isosurface[6] = "3"; } else if(choix == QString("Sphere")) { Isosurface[0] = "x*x + y*y + z*z - 1"; Isosurface[1] = "-1"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "1"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("RoundCube")) { Isosurface[0] = "x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Toupie")) { Isosurface[0] = "(sqrt(x*x+y*y)-3)^3 + z*z - 1"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-6"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "6"; } else if(choix == QString("Chmutov")) { Isosurface[0] = "x^4 + y^4 + z^4 - (x^2 + y^2 + z^2-0.3)"; Isosurface[1] = "-1.5"; Isosurface[2] = "-1.5"; Isosurface[3] = "-1.5"; Isosurface[4] = "1.5"; Isosurface[5] = "1.5"; Isosurface[6] = "1.5"; } else if(choix == QString("Chmutov_2")) { Isosurface[0] = "2*(x^2*(3-4*x^2)^2+y^2*(3-4*y^2)^2+z^2*(3-4*z^2)^2) -3"; Isosurface[1] = "-1.3"; Isosurface[2] = "-1.3"; Isosurface[3] = "-1.3"; Isosurface[4] = "1.3"; Isosurface[5] = "1.3"; Isosurface[6] = "1.3"; } else if(choix == QString("Clebsch")) { Isosurface[0] = "81*(x^3+y^3+z^3)-189*(x^2*y+x^2*z+y^2*x+y^2*z+z^2*x+z^2*y) +54*x*y*z+126*(x*y+x*z+y*z)-9*(x^2+y^2+z^2)-9*(x+y+z)+1"; Isosurface[1] = "-1"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "1"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("DingDong")) { Isosurface[0] = "x^2 +y^2 -(1-z)*z^2"; Isosurface[1] = "-1.5"; Isosurface[2] = "-1.5"; Isosurface[3] = "-1"; Isosurface[4] = "1.5"; Isosurface[5] = "1.5"; Isosurface[6] = "1"; } else if(choix == QString("Trap")) { Isosurface[0] = "(x^8 + z^30 + y^8 - (x^4 + z^50 + y^4 -0.3))*(x^2 + y^2 + z^2 -0.5)"; Isosurface[1] = "-1.2"; Isosurface[2] = "-1.3"; Isosurface[3] = "-1.5"; Isosurface[4] = "1.2"; Isosurface[5] = "1.3"; Isosurface[6] = "1.5"; } else if(choix == QString("Cube")) { Isosurface[0] = "x^100 + y^100 + z^100 -1"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Drope")) { Isosurface[0] = "z - 4*x*exp(-x^2-y^2)"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-1.7"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "1.7"; } else if(choix == QString("Leminescape")) { Isosurface[0] = "4*x^2*(x^2+y^2+z^2+z)+y^2*(y^2+z^2-1)"; Isosurface[1] = "-0.5"; Isosurface[2] = "-1"; Isosurface[3] = "-1"; Isosurface[4] = "0.5"; Isosurface[5] = "1"; Isosurface[6] = "1"; } else if(choix == QString("Klein")) { Isosurface[0] = "(x^2+y^2+z^2+2*y-1)*((x^2+y^2+z^2-2*y-1)^2-8*z^2)+16*x*z*(x^2+y^2+z^2-2*y-1)"; Isosurface[1] = "-3"; Isosurface[2] = "-3.1"; Isosurface[3] = "-4"; Isosurface[4] = "3"; Isosurface[5] = "3.1"; Isosurface[6] = "4"; } else if(choix == QString("Chain_2")) { Isosurface[0] = "/* \n By replacing \":\" by the operator \"*\", we obtain ONE unique isosurface composed of six Torus \n */ \n\ ((sqrt(x*x+y*y)-3)^2 + z*z - 0.4) *\n\ ((sqrt((x-4.5)*(x-4.5)+z*z)-3)^2 + y*y - 0.4) *\n\ ((sqrt((x+4.5)*(x+4.5)+z*z)-3)^2 + y*y - 0.4 ) *\n\ ((sqrt((y+4.5)*(y+4.5)+z*z)-3)^2 + x*x - 0.4 ) *\n\ ((sqrt((y-4.5)*(y-4.5)+z*z)-3)^2 + x*x - 0.4 ) *\n\ ((sqrt(x*x+y*y)-5)^2 + z*z - 0.4)"; Isosurface[1] = "-8.2"; Isosurface[2] = "-8.2"; Isosurface[3] = "-4"; Isosurface[4] = "8.2"; Isosurface[5] = "8.2"; Isosurface[6] = "4"; } else if(choix == QString("Chain")) { Isosurface[0] = "/* \n Another example made by six independants Isosurfaces (Torus) \n */ \n\ ((sqrt(x*x+y*y)-3)^2 + z*z - 0.4) :\n\ ((sqrt((x-4.5)*(x-4.5)+z*z)-3)^2 + y*y - 0.4) :\n\ ((sqrt((x+4.5)*(x+4.5)+z*z)-3)^2 + y*y - 0.4 ) :\n\ ((sqrt((y+4.5)*(y+4.5)+z*z)-3)^2 + x*x - 0.4 ) :\n\ ((sqrt((y-4.5)*(y-4.5)+z*z)-3)^2 + x*x - 0.4 ) :\n\ ((sqrt(x*x+y*y)-5)^2 + z*z - 0.4) :"; Isosurface[1] = "-8.2"; Isosurface[2] = "-8.2"; Isosurface[3] = "-4"; Isosurface[4] = "8.2"; Isosurface[5] = "8.2"; Isosurface[6] = "4"; } else if(choix == QString("Virus")) { Isosurface[0] = "/* \n This example was obtained by using the above formula ! \n */ \n\ -(x^2 + y ^2 + z^2) +cos(5*x)*cos(5*y)*cos(5*z)+0.215"; Isosurface[1] = "-.8"; Isosurface[2] = "-.8"; Isosurface[3] = "-.8"; Isosurface[4] = ".8"; Isosurface[5] = ".8"; Isosurface[6] = ".8"; } else if(choix == QString("BlobySchwartz")) { Isosurface[0] = "/* \n We can even obtain a smoothly closed Schwartz Isosurface... \n */ \n\ -(x^2 + y ^2 + z^2) +cos(5*x)+cos(5*y)+cos(5*z) -.1"; Isosurface[1] = "-2"; Isosurface[2] = "-2"; Isosurface[3] = "-2"; Isosurface[4] = "2"; Isosurface[5] = "2"; Isosurface[6] = "2"; } else if(choix == QString("Warning")) { Isosurface[0] = "/*\n This Example is to show how to draw multiple Isosurfaces by using the separator \":\"\n*/\n\ \ -x^2 + y^2/3 - z^2 +0.1 :\n\ x^2/3 - y^2 - z^2 +0.1 :\n\ -x^2 - y^2 + z^2/3 +0.1 :\n\ x^2 + y^2 + z^2 - 2 :"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("TickIso")) { Isosurface[0] = "/*\n\ To make \"tick\" isosurfaces, you can use this general method:\n\ G[x, y, z] = F[x, y, z] * F[x - (T/R)*dF()/dx, y - (T/R)*dF()/dy, z - (T/R)*df()/dz]\n\ dF()/dx == partial derivative of F() to the variable x.\n\ F[x, y, z] : The original Isosurface formula.\n\ G[x, y, z] : The new Isosurface formula.\n\ R = sqrt[(dF()/dx)^2 + (dF()/dy)^2 + (dF()/dz)^2]\n\ T = Tickness value\n\ Applied to Schwartz (F[]= cos(x) + cos(y) + cos(z) , T = 1/2) ,we obtain the following formula:\n\ */\n\ (cos(x) + cos(y) + cos(z))*(\n\ (\n\ cos(x + sin(x)/(2*sqrt(sin(x)^2 + sin(y)^2 + sin(z)^2))) +\n\ cos(y + sin(y)/(2*sqrt(sin(x)^2 + sin(y)^2 + sin(z)^2))) +\n\ cos(z + sin(z)/(2*sqrt(sin(x)^2 + sin(y)^2 + sin(z)^2)))\n\ )\n\ )"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("CloseIso")) { Isosurface[0] = "/*\n\ To make a closed Isosurface, you can use the \"if\" instruction like in this example with Schwartz :\n\ if(\n\ (x^10 + y^10 +z^10 < 200000), // We use a Cube as a condition\n\ -(cos(x) + cos(y) + cos(z) ) , // Schwartz\n\ (x^10 + y^10 +z^10 - 200000 ) // Cube\n\ */\n\ if((x^10 + y^10 +z^10 < 200000),\n\ -(cos(x) + cos(y) + cos(z) ) ,\n\ (x^10 + y^10 +z^10 - 200000))"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("CloseIso_1")) { Isosurface[0] = "/*\n\ Another closed isosurface but in this case we consider the outside volume\n\ delimited by the Schwartz surface.\n\ The \"outside\" volume is defined by deleting the signe \"-\"\n\ */\n\ if((x^10 + y^10 +z^10 < 100000), (cos(x) + cos(y) + cos(z) ) , (x^10 + y^10 +z^10 - 100000))"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("CloseIso_2")) { Isosurface[0] = "/*\n\ And now, to make a tick and closed Schwartz Isosurface, we use the two formulas described above :\n\ */\n\ if((x^10 + y^10 +z^10 < 3*(3.5^10)),\n\ (cos(x) + cos(y) + cos(z))*((cos(x + sin(x)/(2*sqrt(sin(x)^2 + sin(y)^2 + sin(z)^2))) +cos(y + sin(y)/(2*sqrt(sin(x)^2 + sin(y)^2 + sin(z)^2))) +cos(z + sin(z)/(2*sqrt(sin(x)^2 + sin(y)^2 + sin(z)^2))))) ,\n\ (x^10 + y^10 +z^10 - 3*(3.5^10)))"; Isosurface[1] = "-4"; Isosurface[2] = "-4"; Isosurface[3] = "-4"; Isosurface[4] = "4"; Isosurface[5] = "4"; Isosurface[6] = "4"; } else if(choix == QString("ChmutySchwartz")) { Isosurface[0] = "/*\n\ We used Schwartz formula to make a parametrable Chmutov-like isosurface:\n\ -------------- ChmutySchwartz ------------\n\ (x^N + y ^N + z^N) - (cos(m*7*x) + cos(n*7*y) + cos(k*7*z)) + l\n\ ------------------------------------------\n\ N : Even integer > 4 --> Sharpness of edges.\n\ n, m, k : integers --> number of holes.\n\ l : Real number [-3,1] --> Thickness\n\ */\n\ (x^16 + y ^16 + z^16 ) -(cos(7*x) +cos(7*y) +cos(7*z)) -.1"; Isosurface[1] = "-1.1"; Isosurface[2] = "-1.1"; Isosurface[3] = "-1.1"; Isosurface[4] = "1.1"; Isosurface[5] = "1.1"; Isosurface[6] = "1.1"; } else{ int i, currentIso=0; for(i=0;i