Example #1
0
    void ToExpressionSet(ExpressionSet es)
    {
        //ExpressionSet es = new ExpressionSet();

        List <string> tokens = ExpressionParser.Parse(xInput.text);

        es.AddExpression("X", new Expression(tokens));
        tokens = ExpressionParser.Parse(yInput.text);
        es.AddExpression("Y", new Expression(tokens));
        tokens = ExpressionParser.Parse(zInput.text);
        es.AddExpression("Z", new Expression(tokens));

        if (uInput != null)
        {
            es.AddRange("u", ToRangePair(uInput.text));
        }
        if (vInput != null)
        {
            es.AddRange("v", ToRangePair(vInput.text));
        }
        if (wInput != null)
        {
            es.AddRange("w", ToRangePair(wInput.text));
        }
        if (tInput != null)
        {
            es.AddRange("t", ToRangePair(tInput.text));
        }

        //return es;
    }
Example #2
0
    public void LoadSavedExpressionSets(List <ExpressionSet> expressionSets)
    {
        List <ExpressionSet> ess = new List <ExpressionSet>();

        for (int i = 0; i < expressionSets.Count; i++)
        {
            ess.Add(expressionSets[i].DeepCopy());
            ess[ess.Count - 1].CompileAll();
        }

        //var expression = new Dictionary<string, object>();
        var expressionString = "";

        foreach (var es in ess)
        {
            foreach (var e in es.expressions)
            {
                expressionString += e.Value.AKExpression.ToString() + "\n";
            }
        }
        //expression["expression"] = expressionString;
        StatisticsTracking.InstantEvent("Load Expression", expressionString);

        paramSurface.expressionSets = ess;
        pieceWiseControl.ForceNumberOfTabs(ess.Count);
        expressionSet = paramSurface.expressionSets[0];
        calcInput.ChangeOutput(expressionSet.expressions["X"]);
        if (boundsManager != null)
        {
            boundsManager.UpdateButtonText();
        }
        inputReceived = true;
    }
Example #3
0
 void ExpressionSetToText(ExpressionSet es)
 {
     if (xInput != null)
     {
         xInput.text = es.expressions["X"].expression;
     }
     if (yInput != null)
     {
         yInput.text = es.expressions["Y"].expression;
     }
     if (zInput != null)
     {
         zInput.text = es.expressions["Z"].expression;
     }
     if (uInput != null)
     {
         uInput.text = RangePairToText(es.ranges["u"]);
     }
     if (vInput != null)
     {
         vInput.text = RangePairToText(es.ranges["v"]);
     }
     if (wInput != null)
     {
         wInput.text = RangePairToText(es.ranges["w"]);
     }
     if (tInput != null)
     {
         tInput.text = RangePairToText(es.ranges["t"]);
     }
 }
Example #4
0
 public void initialize()
 {
     es = new ExpressionSet();
     es.expressions[ExpressionSet.ExpOptions.X].tokens = new List <string>
     {
         "y"
     };
     es.expressions[ExpressionSet.ExpOptions.Y].tokens = new List <string>
     {
         "-x"
     };
     es.expressions[ExpressionSet.ExpOptions.Z].tokens = new List <string>
     {
         "0"
     };
     es.ranges["t"].Min.tokens = new List <string>
     {
         "-", "5", "0"
     };
     es.ranges["t"].Max.tokens = new List <string>
     {
         "5", "0"
     };
     currExpression = es.expressions[ExpressionSet.ExpOptions.X];
     currText       = xText;
     index          = currExpression.tokens.Count;
     isReady        = true;
     xText.text     = displayText(es.expressions[ExpressionSet.ExpOptions.X].tokens, es.expressions[ExpressionSet.ExpOptions.X].tokens.Count, false);
     yText.text     = displayText(es.expressions[ExpressionSet.ExpOptions.Y].tokens, es.expressions[ExpressionSet.ExpOptions.Y].tokens.Count, false);
     zText.text     = displayText(es.expressions[ExpressionSet.ExpOptions.Z].tokens, es.expressions[ExpressionSet.ExpOptions.Z].tokens.Count, false);
     tminText.text  = displayText(es.ranges["t"].Min.tokens, es.ranges["t"].Min.tokens.Count, false);
     tmaxText.text  = displayText(es.ranges["t"].Max.tokens, es.ranges["t"].Max.tokens.Count, false);
     currText.text  = displayText(currExpression.tokens, index, true);
 }
Example #5
0
        public void DtoToSmartPlaylist()
        {
            var dto = new SmartPlaylistDto();

            dto.Id   = "87ccaa10-f801-4a7a-be40-46ede34adb22";
            dto.Name = "Foo";
            dto.User = "******";

            var es = new ExpressionSet();

            es.Expressions = new List <Expression>
            {
                new Expression("foo", "bar", "biz")
            };
            dto.ExpressionSets = new List <ExpressionSet>
            {
                es
            };
            dto.Order = new OrderDto
            {
                Name = "Release Date Descending"
            };
            SmartPlaylist smart_playlist = new SmartPlaylist(dto);

            Assert.Equal(1000, smart_playlist.MaxItems);
            Assert.Equal("87ccaa10-f801-4a7a-be40-46ede34adb22", smart_playlist.Id);
            Assert.Equal("Foo", smart_playlist.Name);
            Assert.Equal("Rob", smart_playlist.User);
            Assert.Equal("foo", smart_playlist.ExpressionSets[0].Expressions[0].MemberName);
            Assert.Equal("bar", smart_playlist.ExpressionSets[0].Expressions[0].Operator);
            Assert.Equal("biz", smart_playlist.ExpressionSets[0].Expressions[0].TargetValue);
            Assert.Equal("PremiereDateOrderDesc", smart_playlist.Order.GetType().Name);
        }
Example #6
0
        public ExpressionSet First(List <ExpressionDefinition> expressionDefinitions)
        {
            ExpressionSet result = new ExpressionSet();

            bool previousCanBeEmpty = true;

            foreach (ExpressionDefinition expressionDefinition in expressionDefinitions)
            {
                if (previousCanBeEmpty)
                {
                    ExpressionSet first = expressionDefinition.First();
                    result.AddRangeUnique(first.Where(x => x.TokenType != TokenType.EmptyString));

                    if (!first.Any(x => x.TokenType == TokenType.EmptyString))
                    {
                        previousCanBeEmpty = false;
                        break;
                    }
                }
            }

            if (previousCanBeEmpty)
            {
                result.Add(new TerminalExpressionDefinition {
                    TokenType = TokenType.EmptyString
                });
            }

            return(result);
        }
Example #7
0
    private ThreadHelper SetupSolver(ExpressionSet es)
    {
        ThreadHelper threadHelper = new ThreadHelper();

        threadHelper.parameterMin   = new Dictionary <string, float>();
        threadHelper.parameterMax   = new Dictionary <string, float>();
        threadHelper.solver         = new AK.ExpressionSolver();
        threadHelper.expressionList = new List <AK.Expression>();

        foreach (string name in es.ranges.Keys)
        {
            threadHelper.parameterMin[name] = (float)threadHelper.solver.EvaluateExpression(es.ranges[name].Min.expression);
            float range = es.ranges[name].Max.Value - es.ranges[name].Min.Value;
            if (es.ranges[name].Min.Exclusive)
            {
                threadHelper.parameterMin[name] += exclusiveModifier * range;
            }
            threadHelper.parameterMax[name] = (float)threadHelper.solver.EvaluateExpression(es.ranges[name].Max.expression);
            if (es.ranges[name].Max.Exclusive)
            {
                threadHelper.parameterMax[name] -= exclusiveModifier * range;
            }
            threadHelper.solver.SetGlobalVariable(name, threadHelper.parameterMin[name]);
        }

        foreach (ExpressionSet.ExpOptions op in es.expressions.Keys)
        {
            Expression    ex  = es.expressions[op];
            AK.Expression exp = threadHelper.solver.SymbolicateExpression(ex.expression);

            threadHelper.expressionList.Add(exp);
        }

        return(threadHelper);
    }
Example #8
0
    public Vector3 findXYZ(Vector3 uvw)
    {
        Vector3       output = new Vector3();
        ExpressionSet es     = calcManager.expressionSet;
        float         scale  = calcManager.paramSurface.currentScale;

        foreach (string key in es.expressions.Keys)
        {
            AK.ExpressionSolver solver = es.solver;
            if (es.ranges.ContainsKey("u"))
            {
                solver.SetGlobalVariable("u", uvw.x);
            }
            if (es.ranges.ContainsKey("v"))
            {
                solver.SetGlobalVariable("v", uvw.y);
            }
            if (es.ranges.ContainsKey("w"))
            {
                solver.SetGlobalVariable("w", uvw.z);
            }
        }
        if (es.IsCompiled())
        {
            output.x = (float)es.expressions["X"].AKExpression.Evaluate();
            output.y = (float)es.expressions["Y"].AKExpression.Evaluate();
            output.z = (float)es.expressions["Z"].AKExpression.Evaluate();
        }
        return(output * scale);
    }
    public void ChangeFace(SkinnedMeshRenderer smr, string setName)
    {
        ExpressionSet expressionSet = null;
        int           num           = 0;

        while (expressionSet == null && num < expression.Length)
        {
            if (expression[num].name == setName)
            {
                expressionSet = expression[num];
            }
            num++;
        }
        curExprSet = expressionSet;
        if (curExprSet == null)
        {
            Debug.LogError("ERROR, Fail to get Expression Set for " + setName);
        }
        else
        {
            smrFace      = smr;
            smr.material = curExprSet.material[(int)curExpression];
        }
        SetExpression(EXPRESSION.DEFAULT);
    }
Example #10
0
 public void ChangeExpressionSet(ExpressionSet ES)
 {
     expressionSet = ES;
     calcInput.ChangeOutput(expressionSet.expressions[X]);
     manageText();
     if (boundsManager != null)
     {
         boundsManager.UpdateButtonText();
     }
 }
Example #11
0
    public ExpressionSet ShallowCopy()
    {
        ExpressionSet newEs = new ExpressionSet();

        newEs.expressions = new Dictionary <string, Expression>(expressions);
        newEs.ranges      = new Dictionary <string, RangePair>((Dictionary <string, RangePair>)ranges);
        newEs.expValidity = new Dictionary <string, bool>(expValidity);

        return(newEs);
    }
Example #12
0
 public static ExpressionSet FixRules(ExpressionSet rules)
 {
     foreach (var rule in rules.Expressions)
     {
         if (rule.MemberName == "PremiereDate")
         {
             var somedate = DateTime.Parse(rule.TargetValue);
             rule.TargetValue = ConvertToUnixTimestamp(somedate).ToString();
         }
     }
     return(rules);
 }
Example #13
0
        //public IEnumerable<DocumentModel> SimplePassthroughQueryDocumentWithPath(string filename, string subject)
        //{

        //    List<DocumentModel> documentModels = new List<DocumentModel>();
        //    QueryResult queryResult;
        //    try
        //    {
        //        string queryString = "select dm_document.r_object_id, dm_document.subject, dm_document.a_content_type,dm_document.object_name,dm_format.dos_extension from dm_document,dm_format where  dm_document.a_content_type = dm_format.name";

        //        if ((!String.IsNullOrEmpty(filename)) && (!String.IsNullOrEmpty(subject)))
        //        {
        //            queryString = queryString + " and upper(object_name) like '%" + filename.ToUpper() + "%' and upper(subject) like '%" + subject.ToUpper() + "%'";
        //        }
        //        if ((!String.IsNullOrEmpty(filename)) && (String.IsNullOrEmpty(subject)))
        //        {
        //            queryString = queryString + " and upper(object_name) like '%" + filename.ToUpper() + "%'";
        //        }
        //        if ((String.IsNullOrEmpty(filename)) && (!String.IsNullOrEmpty(subject)))
        //        {
        //            queryString = queryString + " and upper(subject) like '%" + subject.ToUpper() + "%'";
        //        }
        //        int startingIndex = 0;
        //        int maxResults = 60;
        //        int maxResultsPerSource = 20;

        //        PassthroughQuery q = new PassthroughQuery();
        //        q.QueryString = queryString;
        //        q.AddRepository(DefaultRepository);

        //        QueryExecution queryExec = new QueryExecution(startingIndex,
        //                                                      maxResults,
        //                                                      maxResultsPerSource);
        //        queryExec.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY;

        //        queryResult = searchService.Execute(q, queryExec, null);

        //        QueryStatus queryStatus = queryResult.QueryStatus;
        //        RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0];
        //        if (repStatusInfo.Status == Status.FAILURE)
        //        {
        //            //  Console.WriteLine(repStatusInfo.ErrorTrace);
        //            documentModels.Add(new DocumentModel() { ObjectId = "0", ObjectName = repStatusInfo.ErrorMessage, Subject = repStatusInfo.ErrorTrace });
        //        }
        //        //Console.WriteLine("Query returned result successfully.");
        //        DataPackage dp = queryResult.DataPackage;
        //        //Console.WriteLine("DataPackage contains " + dp.DataObjects.Count + " objects.");
        //        foreach (DataObject dObj in dp.DataObjects)
        //        {
        //            PropertySet docProperties = dObj.Properties;
        //            String objectId = dObj.Identity.GetValueAsString();
        //            String docName = docProperties.Get("object_name").GetValueAsString();
        //            String Extension = docProperties.Get("dos_extension").GetValueAsString();
        //            string repName = dObj.Identity.RepositoryName;
        //            string docsubject = docProperties.Get("subject").GetValueAsString();
        //            //Console.WriteLine("RepositoryName: " + repName + " ,Document: " + objectId + " ,Name:" + docName + " ,Subject:" + docsubject);

        //            documentModels.Add(new DocumentModel() { ObjectId = objectId, ObjectName = docName+"."+Extension , Subject = docsubject });

        //        }
        //    }
        //    catch (Exception ex)
        //    {

        //        documentModels.Add(new DocumentModel() { ObjectId = "1", ObjectName = "SampleFile.txt", Subject = "This is a Sample" });
        //    }

        //    return documentModels;
        //}
        public void SimpleStructuredQuery(String docName)
        {
            String repoName = DefaultRepository;

            Console.WriteLine("Called SimpleStructuredQuery - " + DefaultRepository);
            PropertyProfile propertyProfile = new PropertyProfile();

            propertyProfile.FilterMode = PropertyFilterMode.IMPLIED;
            OperationOptions operationOptions = new OperationOptions();

            operationOptions.Profiles.Add(propertyProfile);

            // Create query
            StructuredQuery q = new StructuredQuery();

            q.AddRepository(repoName);
            q.ObjectType       = "dm_document";
            q.IsIncludeHidden  = true;
            q.IsDatabaseSearch = true;
            ExpressionSet expressionSet = new ExpressionSet();

            expressionSet.AddExpression(new PropertyExpression("object_name",
                                                               Condition.CONTAINS,
                                                               docName));
            q.RootExpressionSet = expressionSet;

            // Execute Query
            int            startingIndex       = 0;
            int            maxResults          = 60;
            int            maxResultsPerSource = 20;
            QueryExecution queryExec           = new QueryExecution(startingIndex,
                                                                    maxResults,
                                                                    maxResultsPerSource);
            QueryResult queryResult = searchService.Execute(q, queryExec, operationOptions);

            QueryStatus          queryStatus   = queryResult.QueryStatus;
            RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0];

            if (repStatusInfo.Status == Status.FAILURE)
            {
                Console.WriteLine(repStatusInfo.ErrorTrace);
                throw new Exception("Query failed to return result.");
            }
            Console.WriteLine("Query returned result successfully.");

            // print results
            Console.WriteLine("DataPackage contains " + queryResult.DataObjects.Count + " objects.");
            foreach (DataObject dataObject in queryResult.DataObjects)
            {
                Console.WriteLine(dataObject.Identity.GetValueAsString());
            }
        }
    internal DensityKeyboardInputResponder(TextMesh x, TextMesh y, TextMesh z, TextMesh tmin, TextMesh tmax)
    {
        es = new ExpressionSet();
        // xText = x;
        // yText = y;
        // zText = z;
        // tminText = tmin;
        // tmaxText = tmax;
        dens = CustomDensityPlot.SampleDensity.HIGH;

        currExpression = es.expressions["X"];
        // currText = xText;
    }
    internal VectorKeyboardInputResponder(TextMesh x, TextMesh y, TextMesh z, TextMesh tmin, TextMesh tmax)
    {
        es       = new ExpressionSet();
        xText    = x;
        yText    = y;
        zText    = z;
        tminText = tmin;
        tmaxText = tmax;
        dens     = CustomVectorField.SampleDensity.LOW;

        currExpression = es.expressions["X"];
        currText       = xText;
    }
Example #16
0
 public SerializableExpressionSet(ExpressionSet es)
 {
     rangeKeys = new string[es.ranges.Count];
     es.ranges.Keys.CopyTo(rangeKeys, 0);
     foreach (string key in rangeKeys)
     {
         rangePairs.Add(new SerializableRangePair(es.ranges[key]));
     }
     ExpressionKeys = new string[es.expressions.Count];
     es.expressions.Keys.CopyTo(ExpressionKeys, 0);
     foreach (string key in ExpressionKeys)
     {
         ExpressionValues.Add(es.expressions[key].rawText);
     }
 }
    // Use this for initialization
    void Start()
    {
        es = new ExpressionSet();
        es.expressions["X"].tokens = new List <string>
        {
            //2Pz
            //"(","1","/","4","*","1","/","2","^","(","1","/","2",")","*","1","/","pi","^","(","1","/","2",")",
            //"*","z","*","e","^","(","-","1","*","(","x","^","2","+","y","^","2","+","z","^","2",")","/","2",")",")","^","2"
            //3Pz
            "(", "2", "^", "(", "1", "/", "2", ")", "*", "1", "/", "8", "1", "*", "1", "/", "pi", "^", "(", "1", "/", "2", ")", "*",
            "(", "6", "-", "(", "x", "^", "2", "+", "y", "^", "2", "+", "z", "^", "2", ")", "^", "(", "1", "/", "2", ")", ")",
            "*", "z", "*", "e", "^", "(", "-", "1", "*", "(", "x", "^", "2", "+", "y", "^", "2", "+", "z", "^", "2", ")", "^", "(", "1", "/", "2", ")", "/", "3", ")", ")", "^", "2"
            //3Dz2
            //"(","1","/","81","*","1","/","6","^","(","1","/","2",")","*","1","/","pi","^","(","1","/","2",")",
            //"*","(","3","*","z","^","2","-","x","^","2","+","y","^","2","+","z","^","2",")",
            //"*","e","^","(","-","1","*","(","x","^","2","+","y","^","2","+","z","^","2",")","/","3",")",")","^","2"
        };
        es.expressions["Y"].tokens = new List <string>
        {
            "0"
        };
        es.expressions["Z"].tokens = new List <string>
        {
            "0"
        };
        es.AddRange("x");
        es.AddRange("y");
        es.AddRange("z");
        es.ranges["t"].Min.tokens = new List <string>
        {
            "-", "5", "0"
        };
        es.ranges["t"].Max.tokens = new List <string>
        {
            "5", "0"
        };
        densityPreset.Initialize(this);
        //print("START");
        // responder = new DensityKeyboardInputResponder(xInputbox, yInputbox, zInputbox, tminInput, tmaxInput);
        // keyboard.RegisterResponder(responder);

        //responder.initialize();
        //print(responder);
    }
 public void initialize()
 {
     es = new ExpressionSet();
     es.expressions["X"].tokens = new List <string>
     {
         //2Pz
         //"(","1","/","4","*","1","/","2","^","(","1","/","2",")","*","1","/","pi","^","(","1","/","2",")",
         //"*","z","*","e","^","(","-","1","*","(","x","^","2","+","y","^","2","+","z","^","2",")","/","2",")",")","^","2"
         //3Pz
         "(", "2", "^", "(", "1", "/", "2", ")", "*", "1", "/", "8", "1", "*", "1", "/", "pi", "^", "(", "1", "/", "2", ")", "*",
         "(", "6", "-", "(", "x", "^", "2", "+", "y", "^", "2", "+", "z", "^", "2", ")", "^", "(", "1", "/", "2", ")", ")",
         "*", "z", "*", "e", "^", "(", "-", "1", "*", "(", "x", "^", "2", "+", "y", "^", "2", "+", "z", "^", "2", ")", "^", "(", "1", "/", "2", ")", "/", "3", ")", ")", "^", "2"
         //3Dz2
         //"(","1","/","81","*","1","/","6","^","(","1","/","2",")","*","1","/","pi","^","(","1","/","2",")",
         //"*","(","3","*","z","^","2","-","x","^","2","+","y","^","2","+","z","^","2",")",
         //"*","e","^","(","-","1","*","(","x","^","2","+","y","^","2","+","z","^","2",")","/","3",")",")","^","2"
     };
     es.expressions["Y"].tokens = new List <string>
     {
         "0"
     };
     es.expressions["Z"].tokens = new List <string>
     {
         "0"
     };
     es.ranges["t"].Min.tokens = new List <string>
     {
         "-", "5", "0"
     };
     es.ranges["t"].Max.tokens = new List <string>
     {
         "5", "0"
     };
     currExpression = es.expressions["X"];
     // currText = xText;
     index   = currExpression.tokens.Count;
     isReady = true;
     // xText.text = displayText(es.expressions[ExpressionSet.ExpOptions.X].tokens, es.expressions[ExpressionSet.ExpOptions.X].tokens.Count, false);
     // yText.text = displayText(es.expressions[ExpressionSet.ExpOptions.Y].tokens, es.expressions[ExpressionSet.ExpOptions.Y].tokens.Count, false);
     // zText.text = displayText(es.expressions[ExpressionSet.ExpOptions.Z].tokens, es.expressions[ExpressionSet.ExpOptions.Z].tokens.Count, false);
     // tminText.text = displayText(es.ranges["t"].Min.tokens, es.ranges["t"].Min.tokens.Count, false);
     // tmaxText.text = displayText(es.ranges["t"].Max.tokens, es.ranges["t"].Max.tokens.Count, false);
     // currText.text = displayText(currExpression.tokens, index, true);
 }
Example #19
0
    public void LoadSavedExpressionSets(List <ExpressionSet> expressionSets)
    {
        List <ExpressionSet> ess = new List <ExpressionSet>();

        for (int i = 0; i < expressionSets.Count; i++)
        {
            ess.Add(expressionSets[i].DeepCopy());
            ess[ess.Count - 1].CompileAll();
        }
        paramSurface.expressionSets = ess;
        pieceWiseControl.ForceNumberOfTabs(ess.Count);
        expressionSet = paramSurface.expressionSets[0];
        calcInput.ChangeOutput(expressionSet.expressions[X]);
        if (boundsManager != null)
        {
            boundsManager.UpdateButtonText();
        }
        inputReceived = true;
    }
Example #20
0
        public ItemSet Closure()
        {
            if (_closure != null)
            {
                return(_closure);
            }

            _closure = new ItemSet(new List <Item> {
                Clone()
            });

            List <ExpressionDefinition> tail = WithoutActions().Skip(DotIndex + 1).ToList();

            if (Lookahead != null)
            {
                tail.AddRange(Lookahead);
            }

            ExpressionSet firstTail = First(tail);

            if (ExpressionAfterDot is NonTerminalExpressionDefinition a)
            {
                foreach (Production production in Grammar.Instance)
                {
                    if (production.Identifier == a.Identifier)
                    {
                        foreach (SubProduction subProduction in production)
                        {
                            foreach (TerminalExpressionDefinition ted in firstTail)
                            {
                                Item itemToAdd = new Item(subProduction, 0, new HashSet <TerminalExpressionDefinition> {
                                    ted
                                });
                                _closure.Add(itemToAdd);
                            }
                        }
                    }
                }
            }

            return(_closure);
        }
Example #21
0
    public ExpressionSet DeepCopy()
    {
        ExpressionSet newEs = new ExpressionSet();

        newEs.expressions = new Dictionary <string, Expression>();
        foreach (string key in expressions.Keys)
        {
            newEs.expressions.Add(key, new Expression(expressions[key]));
        }

        newEs.ranges = new Dictionary <string, RangePair>();
        foreach (string key in ranges.Keys)
        {
            newEs.ranges.Add(key, new RangePair(ranges[key]));
        }

        newEs.expValidity = new Dictionary <string, bool>(expValidity);

        return(newEs);
    }
    // Update is called once per frame
    void Update()
    {
        if (responder.isReady)
        {
            responder.isReady = false;

            //vectorField.expressionX = compileTokens(responder.xExpression);
            //vectorField.expressionY = compileTokens(responder.yExpression);
            //vectorField.expressionZ = compileTokens(responder.zExpression);
            vectorField.dens = responder.dens;
            es             = responder.es;
            vectorField.es = responder.es.ShallowCopy();
            vectorField.UpdateFunctions();

            if (flowline != null)
            {
                flowline.t_min = compileTokens(responder.es.ranges["t"].Min.tokens);
                flowline.t_max = compileTokens(responder.es.ranges["t"].Max.tokens);
                flowline.ForceUpdate();
            }
            overlayUpdate = true;
        }
    }
Example #23
0
    public Vector3 findXYZ(Vector3 uvw)
    {
        Vector3       output = new Vector3();
        ExpressionSet es     = calcManager.expressionSet;
        float         scale  = calcManager.paramSurface.currentScale;

        foreach (ExpressionSet.ExpOptions key in es.expressions.Keys)
        {
            AK.ExpressionSolver solver = es.solver;
            if (es.ranges.ContainsKey("t"))
            {
                solver.SetGlobalVariable("t", uvw.x);
            }
        }
        if (es.expressions[X].AKExpression != null &&
            es.expressions[Y].AKExpression != null &&
            es.expressions[Z].AKExpression != null)
        {
            output.x = (float)es.expressions[X].AKExpression.Evaluate();
            output.y = (float)es.expressions[Y].AKExpression.Evaluate();
            output.z = (float)es.expressions[Z].AKExpression.Evaluate();
        }
        return(output * scale);
    }
Example #24
0
        private ExpressionSet SetSearchExpressionSet(IEnumerable<KeyValuePair<string, string>> searchCriteria)
        {
            var expressionSet = new ExpressionSet();

            foreach (var criteria in searchCriteria)
            {
                expressionSet.AddExpression(new PropertyExpression(criteria.Key, Condition.EQUAL, criteria.Value));
            }

            return expressionSet;
        }
Example #25
0
    internal void ThreadedEvaluate(List <int[]> samples, ExpressionSet expressionSet, int TID)
    {
        Dictionary <string, AK.Variable> vars = new Dictionary <string, AK.Variable>();
        int depth = expressionSet.ranges.Count;
        int width = (int)Mathf.Pow(particlesPerES, 1f / (float)depth);

        System.Random rand = new System.Random();

        ThreadHelper threadHelper = SetupSolver(expressionSet);

        Dictionary <int, string> indexedParam = new Dictionary <int, string>();
        int k = 0;

        foreach (string name in expressionSet.ranges.Keys)
        {
            AK.Variable var = threadHelper.solver.GetGlobalVariable(name);
            indexedParam.Add(k, name);
            vars[name] = var;
            k++;
        }

        int iterations = Math.Min(particlesPerES - samples.Count * TID, samples.Count);

        Particle[] particles = new Particle[iterations];
        for (int i = 0; i < iterations; i++)
        {
            int[] arr = samples[i];
            for (int j = 0; j < depth; j++)
            {
                int         val  = arr[j];
                string      name = indexedParam[j];
                AK.Variable var  = vars[name];

                var.value = threadHelper.parameterMin[name] + (float)val / (width - 1) * (threadHelper.parameterMax[name] - threadHelper.parameterMin[name]);
            }

            float x = (float)threadHelper.expressionList[0].Evaluate();
            float z = (float)threadHelper.expressionList[1].Evaluate();
            float y = (float)threadHelper.expressionList[2].Evaluate();

            lock (lck)
            {
                maxRange = (Mathf.Abs(x) > maxRange) ? Mathf.Abs(x) : maxRange;
                maxRange = (Mathf.Abs(y) > maxRange) ? Mathf.Abs(y) : maxRange;
                maxRange = (Mathf.Abs(z) > maxRange) ? Mathf.Abs(z) : maxRange;
            }

            particles[i]          = new Particle();
            particles[i].position = new Vector3(x, y, z);
            Vector3 vel = new Vector3();
            vel.x = 0.5f - (float)rand.NextDouble();
            vel.y = 0.5f - (float)rand.NextDouble();
            vel.z = 0.5f - (float)rand.NextDouble();
            vel   = 0.1f * Vector3.Normalize(vel);
            particles[i].velocity = vel;
        }
        lock (lck)
        {
            threadResults.Add(particles);
        }
    }
Example #26
0
    IEnumerator SetupParticles()
    {
        calculating = true;
        lck         = new object();
        maxRange    = Mathf.NegativeInfinity;

        if (anim != null)
        {
            StopCoroutine(anim);
        }

        int totalFrames           = 30;
        int defaultParticlesPerES = particleCount / expressionSets.Count;
        //number of frames used for each expression set.
        int framesPerES = totalFrames / expressionSets.Count;

        num_threads = SystemInfo.processorCount;
        int missingParticles = 0;

        threadResults = new List <Particle[]>();

        int expressionNumber = 0;

        foreach (ExpressionSet es in expressionSets)
        {
            particlesPerES   = defaultParticlesPerES + missingParticles;
            missingParticles = 0;
            expressionNumber++;
            //soft copy of the expressionSet. Do not edit actual expressions using this.
            ExpressionSet expressionSet = es.ShallowCopy();
            //remove unused parameters
            string[] keys = new string[expressionSet.ranges.Keys.Count];
            expressionSet.ranges.Keys.CopyTo(keys, 0);
            foreach (string op in keys)
            {
                bool used = false;
                foreach (ExpressionSet.ExpOptions key in expressionSet.expressions.Keys)
                {
                    if (expressionSet.expressions[key].tokens.Contains(op))
                    {
                        used = true;
                    }
                }
                if (!used && expressionSet.ranges.Count > 1)
                {
                    expressionSet.RemoveRange(op);
                }
            }

            int          depth        = expressionSet.ranges.Count;
            int          width        = (int)Mathf.Pow(particlesPerES, 1f / (float)depth);
            List <int[]> samples      = SetupSamples(depth, width);
            int          thread_chunk = Mathf.CeilToInt(samples.Count / 4);
            missingParticles += particlesPerES - samples.Count;

            Thread[] threads = new Thread[num_threads];
            int      t       = 0;
            for (t = 0; t < num_threads; t++)
            {
                int tc   = t;
                int TIDc = tc;


                threads[t] = new Thread(() => ThreadedEvaluate(samples.GetRange(tc * thread_chunk, Math.Min(thread_chunk, samples.Count - tc * thread_chunk)), expressionSet, TIDc));
                threads[t].Start();
            }
            while (framesPerES-- != 0)
            {
                yield return(null);
            }
            for (t = 0; t < num_threads; t++)
            {
                threads[t].Join();
            }
            framesPerES = totalFrames / expressionSets.Count;
        }
        List <Particle> temp = new List <Particle>();

        foreach (Particle[] array in threadResults)
        {
            temp.AddRange(array);
        }
        Particle lastParticle = temp[temp.Count - 1];

        for (int i = 0; i < missingParticles; i++)
        {
            temp.Add(lastParticle);
        }
        dest = temp.ToArray();
        for (int i = 0; i < dest.Length; i++)
        {
            Vector3 pos = (maxRange == 0) ? Vector3.zero : dest[i].position * 10f / maxRange;
            dest[i].position = pos;
            dest[i].color    = new Color(Mathf.Pow((pos.x + 10) / 20, 2), Mathf.Pow((pos.y + 10) / 20, 2), Mathf.Pow((pos.z + 10) / 20, 2));
        }

        xAxis.Max = maxRange; xAxis.Min = -maxRange;
        yAxis.Max = maxRange; yAxis.Min = -maxRange;
        zAxis.Max = maxRange; zAxis.Min = -maxRange;

        currentScale = (maxRange == 0) ? 0 : 10 / maxRange;

        pBuffer.GetData(particles);
        sBuffer.SetData(particles);
        dBuffer.SetData(dest);
        animProgress = 0;
        calculating  = false;
    }
Example #27
0
    protected void HandleInput(string source)
    {
        List <string> x;
        List <string> y;
        List <string> z;
        List <string> umin = ExpressionParser.Parse("");
        List <string> umax = ExpressionParser.Parse("");
        List <string> tmin = ExpressionParser.Parse("");
        List <string> tmax = ExpressionParser.Parse("");
        List <string> vmin = ExpressionParser.Parse("");
        List <string> vmax = ExpressionParser.Parse("");
        List <string> wmin = ExpressionParser.Parse("");
        List <string> wmax = ExpressionParser.Parse("");

        ExpressionSet expressionSet = densManager.es;

        switch (source)
        {
        default:
            x    = ExpressionParser.Parse("0");
            y    = ExpressionParser.Parse("0");
            z    = ExpressionParser.Parse("0");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("0");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("0");
            print("unknown preset pressed");
            break;

        // Orbitals
        case "1S":
            x = ExpressionParser.Parse("(1.772454*e^(-1*(x^2+y^2+z^2)^(1/2)))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(3);
            densManager.setSleepInterval(126);
            break;

        case "2S":
            x = ExpressionParser.Parse("(0.099735*(2-(x^2+y^2+z^2)^(1/2))*e^(-1*((x^2+y^2+z^2)^(1/2))/2))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(10);
            densManager.setSleepInterval(63);
            break;

        case "2Pz":
            x = ExpressionParser.Parse("(0.099735*z*e^(-1*((x^2+y^2+z^2)^(1/2))/2))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(12);
            densManager.setSleepInterval(63);
            break;

        case "3S":
            x = ExpressionParser.Parse("(0.004021*(27-18*(x^2+y^2+z^2)^(1/2)+2*(x^2+y^2+z^2))*e^(-1*((x^2+y^2+z^2)^(1/2))/3))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(20);
            densManager.setSleepInterval(42);
            break;

        case "3Pz":
            x = ExpressionParser.Parse("(0.004925*(6-(x^2+y^2+z^2)^(1/2))*z*e^(-1*((x^2+y^2+z^2)^(1/2))/3))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(22);
            densManager.setSleepInterval(63);
            break;

        case "3Dz\x00B2":
            goto case "3Dz2";

        case "3Dz2":
            x = ExpressionParser.Parse("(0.002844*(3*z^2-(x^2+y^2+z^2))*e^(-1*((x^2+y^2+z^2)^(1/2))/3))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(24);
            densManager.setSleepInterval(63);
            break;

        case "3Dxy":
            x = ExpressionParser.Parse("(0.009850*x*y*e^(-1*((x^2+y^2+z^2)^(1/2))/3))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(24);
            densManager.setSleepInterval(63);
            break;

        case "4S":
            x = ExpressionParser.Parse("(0.006965*(1-0.75*(x^2+y^2+z^2)^(1/2)+0.125*(x^2+y^2+z^2)-0.005208*(x^2+y^2+z^2)^(3/2))*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(30);
            densManager.setSleepInterval(42);
            break;

        case "4Pz":
            x = ExpressionParser.Parse("(0.039424*(1-0.25*(x^2+y^2+z^2)^(1/2)+0.0125*(x^2+y^2+z^2))*z*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(34);
            densManager.setSleepInterval(42);
            break;

        case "4Dz\x00B2":
            goto case "4Dz2";

        case "4Dz2":
            x = ExpressionParser.Parse("(0.002204*(3*z^2-0.25*z^2*(x^2+y^2+z^2)^(1/2)-(x^2+y^2+z^2)+0.083333*(x^2+y^2+z^2)^(3/2))*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(40);
            densManager.setSleepInterval(21);
            break;

        case "4Dxy":
            x = ExpressionParser.Parse("(0.003817*x*y*(1-0.083333*(x^2+y^2+z^2)^(1/2))*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(40);
            densManager.setSleepInterval(42);
            break;

        case "4Fz\x00B3":
            goto case "4Fz3";

        case "4Fz3":
            x = ExpressionParser.Parse("(0.000082*z*(5*z^2-3*(x^2+y^2+z^2))*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(40);
            densManager.setSleepInterval(63);
            break;

        case "4Fxz\x00B2":
            goto case "4Fxz2";

        case "4Fxz2":
            x = ExpressionParser.Parse("(0.000101*x*(5*z^2-(x^2+y^2+z^2))*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(40);
            densManager.setSleepInterval(63);
            break;

        case "4Fxyz":
            x = ExpressionParser.Parse("(0.000636*x*y*z*e^(-1*((x^2+y^2+z^2)^(1/2))/4))^2");
            y = ExpressionParser.Parse("0");
            z = ExpressionParser.Parse("0");
            densManager.setRange(40);
            densManager.setSleepInterval(63);
            break;
        }

        expressionSet.AddExpression("X", x);
        expressionSet.AddExpression("Y", y);
        expressionSet.AddExpression("Z", z);
        expressionSet.AddRange("t", tmin, tmax);
        expressionSet.AddRange("u", umin, umax);
        expressionSet.AddRange("v", vmin, vmax);
        expressionSet.AddRange("w", wmin, wmax);
        densManager.PresetPressed();
    }
Example #28
0
    protected void HandleInput(string source)
    {
        List <string> x;
        List <string> y;
        List <string> z;
        List <string> umin = ExpressionParser.Parse("");
        List <string> umax = ExpressionParser.Parse("");
        List <string> tmin = ExpressionParser.Parse("");
        List <string> tmax = ExpressionParser.Parse("");
        List <string> vmin = ExpressionParser.Parse("");
        List <string> vmax = ExpressionParser.Parse("");
        List <string> wmin = ExpressionParser.Parse("");
        List <string> wmax = ExpressionParser.Parse("");

        ExpressionSet expressionSet = calcManager.expressionSet;

        switch (source)
        {
        default:
            x    = ExpressionParser.Parse("0");
            y    = ExpressionParser.Parse("0");
            z    = ExpressionParser.Parse("0");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("0");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("0");
            print("unknown preset pressed");
            break;

        //R1 -> R1
        case "Cinquefoil Knot":
            x    = ExpressionParser.Parse("cos(t)*(2-cos(2*t/5))");
            y    = ExpressionParser.Parse("sin(t)*(2-cos(2*t/5))");
            z    = ExpressionParser.Parse("-sin(2*t/5)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("10*pi");
            break;

        case "Circle":
            x    = ExpressionParser.Parse("cos(t)");
            y    = ExpressionParser.Parse("sin(t)");
            z    = ExpressionParser.Parse("0");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2pi");
            break;

        case "Sphere Outline":
            x    = ExpressionParser.Parse("sin(t)*cos(32*t)");
            y    = ExpressionParser.Parse("sin(t)*sin(32*t)");
            z    = ExpressionParser.Parse("cos(t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("pi");
            break;

        case "Hypocloid":
            x    = ExpressionParser.Parse("cos(t)^3");
            y    = ExpressionParser.Parse("sin(t)^3");
            z    = ExpressionParser.Parse("0");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("4pi");
            break;

        case "Hypocloid Surface":
            x    = ExpressionParser.Parse("10*cos(t*32)^3");
            y    = ExpressionParser.Parse("10*sin(t*32)^3");
            z    = ExpressionParser.Parse("t-2*pi");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("4pi");
            break;

        case "Trefoil Knot":
            x    = ExpressionParser.Parse("sin(t)+2*sin(2*t)");
            y    = ExpressionParser.Parse("cos(t)-2*cos(2*t)");
            z    = ExpressionParser.Parse("-sin(3*t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2*pi");
            break;

        case "Turnip":
            x    = ExpressionParser.Parse("(sin(t/16)^2)*cos(8*t)*8*pi");
            y    = ExpressionParser.Parse("(sin(t/16))^2*sin(8*t)*8*pi");
            z    = ExpressionParser.Parse("8*pi-t");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("16pi");
            break;

        case "Wavy Surface":
            x    = ExpressionParser.Parse("(sin(t/2)^(1/2)*cos(256*t)*pi)");
            y    = ExpressionParser.Parse("(sin(t/2))^(1/2)*sin(64*t)*pi");
            z    = ExpressionParser.Parse("pi-t");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2pi");
            break;

        case "High-res Sphere":
            x    = ExpressionParser.Parse("sin(t)*cos(1024*t)");
            y    = ExpressionParser.Parse("sin(t)*sin(1024*t)");
            z    = ExpressionParser.Parse("cos(t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("pi");
            break;

        //R2->R3
        case "Astroidal Ellipse":
            x    = ExpressionParser.Parse("(2*cos(u)*cos(v))^3");
            y    = ExpressionParser.Parse("(2*sin(u)*cos(v))^3");
            z    = ExpressionParser.Parse("(2*sin(v))^3");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Bumpy Sphere":
            x    = ExpressionParser.Parse("5*sin(u)*sin(v)+cos(30*v)*0.15");
            y    = ExpressionParser.Parse("5*cos(u)*sin(v)+cos(30*u)*0.15");
            z    = ExpressionParser.Parse("5*cos(v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("pi");
            break;

        case "Dini's Surface":
            x    = ExpressionParser.Parse("3*cos(u)*sin(v)");
            y    = ExpressionParser.Parse("3*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("3*(cos(v)+log(tan(0.5*v)))+0.4*u");
            umin = ExpressionParser.Parse("-4*pi");
            umax = ExpressionParser.Parse("4*pi");
            vmin = ExpressionParser.Parse("0.005");
            vmax = ExpressionParser.Parse("3.135");
            break;

        case "Figure-8":
            x    = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*cos(u)");
            y    = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*sin(u)");
            z    = ExpressionParser.Parse("sin(u/2)*sin(v)-cos(u/2)*sin(2*v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Gray's Surface":
            x    = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*cos(u/2)");
            y    = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*sin(u/2)");
            z    = ExpressionParser.Parse("sin(3*u/2)*sin(v)+cos(3*u/2)*sin(2*v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("4*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Knot":
            x    = ExpressionParser.Parse("3*sin(3*u)/2+cos(v)))");
            y    = ExpressionParser.Parse("3*(sin(u)+2*sin(2*u))/(2+cos(v+pi*2/3))");
            z    = ExpressionParser.Parse("3/2*(cos(u)-2*cos(2*u))*(2+cos(v))*(2+cos(v+pi*2/3))/4");
            umin = ExpressionParser.Parse("-pi");
            umax = ExpressionParser.Parse("2pi");
            vmin = ExpressionParser.Parse("-pi");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Mobius":
            x    = ExpressionParser.Parse("(5+u*cos(0.5*v))*cos(v)");
            y    = ExpressionParser.Parse("(5+u*cos(0.5*v))*sin(v)");
            z    = ExpressionParser.Parse("u*sin(0.5*v)");
            umin = ExpressionParser.Parse("-1");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Radial Wave":
            x    = ExpressionParser.Parse("u");
            y    = ExpressionParser.Parse("v");
            z    = ExpressionParser.Parse("cos((u^2+v^2)^0.5)");
            umin = ExpressionParser.Parse("-10");
            umax = ExpressionParser.Parse("10");
            vmin = ExpressionParser.Parse("-10");
            vmax = ExpressionParser.Parse("10");
            break;

        case "Torus":
            x    = ExpressionParser.Parse("(5+cos(v))*cos(u)");
            y    = ExpressionParser.Parse("(5+cos(v))*sin(u)");
            z    = ExpressionParser.Parse("sin(v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        //R3->R3
        case "Cone":
            x    = ExpressionParser.Parse("ucos(v)w");
            y    = ExpressionParser.Parse("usin(v)w");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Cube":
            x    = ExpressionParser.Parse("u");
            y    = ExpressionParser.Parse("v");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Cylinder":
            x    = ExpressionParser.Parse("ucos(v)");
            y    = ExpressionParser.Parse("usin(v)");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Sphere":
            x    = ExpressionParser.Parse("ucos(v)sin(w)");
            y    = ExpressionParser.Parse("usin(v)sin(w)");
            z    = ExpressionParser.Parse("ucos(w)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("2pi");
            break;

        case "Tetrahedron":
            x    = ExpressionParser.Parse("u(1-v)");
            y    = ExpressionParser.Parse("uv(1-w)");
            z    = ExpressionParser.Parse("uvw");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        // Orbitals
        case "S":
            x    = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Px":
            x    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Py":
            x    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Pz":
            x    = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dz\x00B2":
            goto case "Dz2";

        case "Dz2":
            x    = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dxz":
            x    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dyz":
            x    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dxy":
            x    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dx\x00B2-y\x00B2":
            goto case "Dx2-y2";

        case "Dx2-y2":
            x    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fz\x00B3":
            goto case "Fz3";

        case "Fz3":
            x    = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fxz\x00B2":
            goto case "Fxz2";

        case "Fxz2":
            x    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fyz\x00B2":
            goto case "Fyz2";

        case "Fyz2":
            x    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fxyz":
            x    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fz\x0028x\x00B2-y\x00B2\x0029":
            goto case "Fzx2y2";

        case "Fzx2y2":
            x    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fx\x0028x\x00B2-3y\x00B2\x0029":
            goto case "Fxx23y2";

        case "Fxx23y2":
            x    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fy\x00283x\x00B2-y\x00B2\x0029":
            goto case "Fy3x2y2";

        case "Fy3x2y2":
            x    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;
        }

        expressionSet.AddExpression("X", x);
        expressionSet.AddExpression("Y", y);
        expressionSet.AddExpression("Z", z);
        expressionSet.AddRange("t", tmin, tmax);
        expressionSet.AddRange("u", umin, umax);
        expressionSet.AddRange("v", vmin, vmax);
        expressionSet.AddRange("w", wmin, wmax);
        calcManager.PresetPressed();
    }
Example #29
0
        /// <summary>
        /// Ricerca fulltext nell'oggetto document
        ///
        /// nb: da fare anche ricerca allegati
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public ArrayList FullTextSearch(ref FullTextSearchContext context)
        {
            ArrayList result = new ArrayList();

            try
            {
                List <string> fullTextResult = null;

                if (context.SearchResultList != null && context.SearchResultList.Length > 0)
                {
                    // Ricerca già effettuata, reperimento dall'oggetto di contesto
                    // dei risultati precedenti evitando così una dispendiosa
                    // chiamata al sistema documentale
                    fullTextResult = new List <string>(context.SearchResultList);
                }
                else
                {
                    StructuredQuery strQuery = new StructuredQuery();

                    strQuery.AddRepository(DctmConfigurations.GetRepositoryName());
                    strQuery.ObjectType = ObjectTypes.DOCUMENTO;

                    strQuery.IsDatabaseSearch     = false;
                    strQuery.IsIncludeAllVersions = false;
                    strQuery.IsIncludeHidden      = false;

                    // Inserisce nella ricerca il solo cabinet dell'amministrazione
                    RepositoryScope repositoryScope = new RepositoryScope();
                    repositoryScope.RepositoryName = DctmConfigurations.GetRepositoryName();
                    repositoryScope.LocationPath   = DocsPaAdminCabinet.getRootAmministrazione(this.InfoUtente);
                    repositoryScope.IsDescend      = true;
                    strQuery.Scopes.Add(repositoryScope);

                    ExpressionSet set = new ExpressionSet();
                    set.AddExpression(new FullTextExpression(context.TextToSearch));
                    strQuery.RootExpressionSet = set;

                    // Query execution
                    int            startIndex = (context.RequestedPageNumber * PAGE_SIZE) - PAGE_SIZE;
                    int            maxResults = this.GetMaxRowCount();
                    QueryExecution queryExec  = new QueryExecution(startIndex, maxResults, maxResults);

                    ISearchService searchService = DctmServiceFactory.GetServiceInstance <ISearchService>(this.InfoUtente.dst);
                    QueryResult    queryResult   = searchService.Execute(strQuery, queryExec, null);

                    QueryStatus          queryStatus   = queryResult.QueryStatus;
                    RepositoryStatusInfo repStatusInfo = queryResult.QueryStatus.RepositoryStatusInfos[0];

                    if (repStatusInfo.Status == Status.FAILURE)
                    {
                        throw new ApplicationException("QueryResult: Status.FAILURE");
                    }

                    fullTextResult = new List <string>();

                    foreach (DataObject dataObject in queryResult.DataObjects)
                    {
                        // Reperimento docnumber
                        string docNumber = dataObject.Properties.Get(TypeDocumento.DOC_NUMBER).GetValueAsString();

                        if (!fullTextResult.Contains(docNumber)) // Eliminazione dei risultati duplicati
                        {
                            fullTextResult.Add(docNumber);
                        }
                    }

                    context.SearchResultList = fullTextResult.ToArray();
                    context.TotalPageNumber  = (fullTextResult.Count / PAGE_SIZE);
                    context.TotalRecordCount = fullTextResult.Count;
                }

                // Paginazione dei risultati
                if (fullTextResult != null && fullTextResult.Count > 0)
                {
                    int startIndex = (context.RequestedPageNumber * PAGE_SIZE) - PAGE_SIZE;
                    int count      = PAGE_SIZE;
                    if (fullTextResult.Count < count)
                    {
                        count = fullTextResult.Count;
                    }
                    List <string> pageContent = fullTextResult.GetRange(startIndex, count);
                    result = this.GetDocuments(pageContent.ToArray(), InfoUtente);
                }
            }
            catch (Exception ex)
            {
                result.Clear();
                logger.Debug(string.Format("Errore in Documentum.FullTextSearch:\n{0}", ex.ToString()));
            }

            return(result);
        }
        public void SimpleStructuredQuery(String docName)
        {
            String repoName = DefaultRepository;

            PropertyProfile propertyProfile = new PropertyProfile();
            propertyProfile.FilterMode = PropertyFilterMode.IMPLIED;
            OperationOptions operationOptions = new OperationOptions();
            operationOptions.Profiles.Add(propertyProfile);

            // Create query
            StructuredQuery q = new StructuredQuery();
            q.AddRepository(repoName);
            q.ObjectType = "dm_document";
            q.IsIncludeHidden = true;
            q.IsDatabaseSearch = true;
            ExpressionSet expressionSet = new ExpressionSet();
            expressionSet.AddExpression(new PropertyExpression("object_name",
                                                               Condition.CONTAINS,
                                                               docName));
            q.RootExpressionSet = expressionSet;

            // Execute Query
            int startingIndex = 0;
            int maxResults = 60;
            int maxResultsPerSource = 20;
            QueryExecution queryExec = new QueryExecution(startingIndex,
                                                          maxResults,
                                                          maxResultsPerSource);
            QueryResult queryResult = searchService.Execute(q, queryExec, operationOptions);

            QueryStatus queryStatus = queryResult.QueryStatus;
            RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0];
            if (repStatusInfo.Status == Status.FAILURE)
            {
                Console.WriteLine(repStatusInfo.ErrorTrace);
                throw new Exception("Query failed to return result.");
            }
            Console.WriteLine("Query returned result successfully.");

            // print results
            Console.WriteLine("DataPackage contains " + queryResult.DataObjects.Count + " objects.");
            foreach (DataObject dataObject in queryResult.DataObjects)
            {
                Console.WriteLine(dataObject.Identity.GetValueAsString());
            }
        }
Example #31
0
    protected void HandleInput(string source)
    {
        List <string> x;
        List <string> y;
        List <string> z;
        List <string> umin = ExpressionParser.Parse("");
        List <string> umax = ExpressionParser.Parse("");
        List <string> tmin = ExpressionParser.Parse("");
        List <string> tmax = ExpressionParser.Parse("");
        List <string> vmin = ExpressionParser.Parse("");
        List <string> vmax = ExpressionParser.Parse("");
        List <string> wmin = ExpressionParser.Parse("");
        List <string> wmax = ExpressionParser.Parse("");

        ExpressionSet expressionSet = calcManager.expressionSet;

        switch (source)
        {
        default:
            x    = ExpressionParser.Parse("0.75*sin(2*pi*v)");
            y    = ExpressionParser.Parse("sin(pi*u)*(1.5+0.75*cos(2*pi*v))");
            z    = ExpressionParser.Parse("cos(pi*u)*(1.5+0.75*cos(2*pi*v))");
            umin = ExpressionParser.Parse("1.5");
            umax = ExpressionParser.Parse("2.5");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");

            List <string> x2    = ExpressionParser.Parse("0.75*cos(pi*u)");
            List <string> y2    = ExpressionParser.Parse("0.75*sin(pi*u)*cos(2*pi*v)+2.4");
            List <string> z2    = ExpressionParser.Parse("0.75*sin(pi*u)*sin(2*pi*v)+2.6");
            List <string> umin2 = ExpressionParser.Parse("0");
            List <string> umax2 = ExpressionParser.Parse("1");
            List <string> vmin2 = ExpressionParser.Parse("0");
            List <string> vmax2 = ExpressionParser.Parse("1");

            List <string> x3    = ExpressionParser.Parse("0.75*sin(2*pi*u)");
            List <string> y3    = ExpressionParser.Parse("0.75*cos(2*pi*u)+1.5*cos(pi/8*v)");
            List <string> z3    = ExpressionParser.Parse("-1.5*sin(pi/8*v)");
            List <string> umin3 = ExpressionParser.Parse("0");
            List <string> umax3 = ExpressionParser.Parse("1");
            List <string> vmin3 = ExpressionParser.Parse("0");
            List <string> vmax3 = ExpressionParser.Parse("1");

            List <string> x4    = ExpressionParser.Parse("0.75*sin(2*pi*u)");
            List <string> y4    = ExpressionParser.Parse("0.75*cos(2*pi*u)-1.5*cos(pi/8*v)");
            List <string> z4    = ExpressionParser.Parse("-1.5*sin(pi/8*v)");
            List <string> umin4 = ExpressionParser.Parse("0");
            List <string> umax4 = ExpressionParser.Parse("1");
            List <string> vmin4 = ExpressionParser.Parse("0");
            List <string> vmax4 = ExpressionParser.Parse("1");

            Expression X  = new Expression(x);
            Expression Y  = new Expression(y);
            Expression Z  = new Expression(z);
            Expression X2 = new Expression(x2);
            Expression Y2 = new Expression(y2);
            Expression Z2 = new Expression(z2);
            Expression X3 = new Expression(x3);
            Expression Y3 = new Expression(y3);
            Expression Z3 = new Expression(z3);
            Expression X4 = new Expression(x4);
            Expression Y4 = new Expression(y4);
            Expression Z4 = new Expression(z4);

            Range            zeroRange    = new Range(ExpressionParser.Parse("0"));
            Range            oneRange     = new Range(ExpressionParser.Parse("1"));
            Range            onePointFive = new Range(ExpressionParser.Parse("1.5"));
            Range            twoPointFive = new Range(ExpressionParser.Parse("2.5"));
            RangePair        zeroToZero   = new RangePair(zeroRange, zeroRange);
            RangePair        zeroToOne    = new RangePair(zeroRange, oneRange);
            List <RangePair> rangePairs   = new List <RangePair>()
            {
                zeroToZero, new RangePair(onePointFive, twoPointFive), zeroToOne, zeroToOne
            };
            List <RangePair> rangePairs2 = new List <RangePair>()
            {
                zeroToZero, zeroToOne, zeroToOne, zeroToZero
            };
            ExpressionSet expSet = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs, new string[] { "X", "Y", "Z" }, new List <Expression>()
            {
                X, Y, Z
            });
            ExpressionSet expSet2 = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs2, new string[] { "X", "Y", "Z" }, new List <Expression>()
            {
                X2, Y2, Z2
            });
            ExpressionSet expSet3 = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs2, new string[] { "X", "Y", "Z" }, new List <Expression>()
            {
                X3, Y3, Z3
            });
            ExpressionSet expSet4 = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs2, new string[] { "X", "Y", "Z" }, new List <Expression>()
            {
                X4, Y4, Z4
            });

            List <ExpressionSet> nanomeLogo = new List <ExpressionSet>()
            {
                expSet, expSet2, expSet3, expSet4
            };
            CalcManager.Instance.LoadSavedExpressionSets(nanomeLogo);
            print("unknown preset pressed");
            return;

        //R1 -> R1
        case "Cinquefoil Knot":
            x    = ExpressionParser.Parse("cos(t)*(2-cos(2*t/5))");
            y    = ExpressionParser.Parse("sin(t)*(2-cos(2*t/5))");
            z    = ExpressionParser.Parse("-sin(2*t/5)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("10*pi");
            break;

        case "Circle":
            x    = ExpressionParser.Parse("cos(t)");
            y    = ExpressionParser.Parse("sin(t)");
            z    = ExpressionParser.Parse("0");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2pi");
            break;

        case "Sphere Outline":
            x    = ExpressionParser.Parse("sin(t)*cos(32*t)");
            y    = ExpressionParser.Parse("sin(t)*sin(32*t)");
            z    = ExpressionParser.Parse("cos(t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("pi");
            break;

        case "Hypocloid":
            x    = ExpressionParser.Parse("cos(t)^3");
            y    = ExpressionParser.Parse("sin(t)^3");
            z    = ExpressionParser.Parse("0");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("4pi");
            break;

        case "Hypocloid Surface":
            x    = ExpressionParser.Parse("10*cos(t*32)^3");
            y    = ExpressionParser.Parse("10*sin(t*32)^3");
            z    = ExpressionParser.Parse("t-2*pi");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("4pi");
            break;

        case "Trefoil Knot":
            x    = ExpressionParser.Parse("sin(t)+2*sin(2*t)");
            y    = ExpressionParser.Parse("cos(t)-2*cos(2*t)");
            z    = ExpressionParser.Parse("-sin(3*t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2*pi");
            break;

        case "Turnip":
            x    = ExpressionParser.Parse("(sin(t/16)^2)*cos(8*t)*8*pi");
            y    = ExpressionParser.Parse("(sin(t/16))^2*sin(8*t)*8*pi");
            z    = ExpressionParser.Parse("8*pi-t");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("16pi");
            break;

        case "Wavy Surface":
            x    = ExpressionParser.Parse("(sin(t/2)^(1/2)*cos(256*t)*pi)");
            y    = ExpressionParser.Parse("(sin(t/2))^(1/2)*sin(64*t)*pi");
            z    = ExpressionParser.Parse("pi-t");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2pi");
            break;

        case "High-res Sphere":
            x    = ExpressionParser.Parse("sin(t)*cos(1024*t)");
            y    = ExpressionParser.Parse("sin(t)*sin(1024*t)");
            z    = ExpressionParser.Parse("cos(t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("pi");
            break;

        //R2->R3
        case "Astroidal Ellipse":
            x    = ExpressionParser.Parse("(2*cos(u)*cos(v))^3");
            y    = ExpressionParser.Parse("(2*sin(u)*cos(v))^3");
            z    = ExpressionParser.Parse("(2*sin(v))^3");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Bumpy Sphere":
            x    = ExpressionParser.Parse("5*sin(u)*sin(v)+cos(30*v)*0.15");
            y    = ExpressionParser.Parse("5*cos(u)*sin(v)+cos(30*u)*0.15");
            z    = ExpressionParser.Parse("5*cos(v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("pi");
            break;

        case "Dini's Surface":
            x    = ExpressionParser.Parse("3*cos(u)*sin(v)");
            y    = ExpressionParser.Parse("3*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("3*(cos(v)+log(tan(0.5*v)))+0.4*u");
            umin = ExpressionParser.Parse("-4*pi");
            umax = ExpressionParser.Parse("4*pi");
            vmin = ExpressionParser.Parse("0.005");
            vmax = ExpressionParser.Parse("3.135");
            break;

        case "Figure-8":
            x    = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*cos(u)");
            y    = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*sin(u)");
            z    = ExpressionParser.Parse("sin(u/2)*sin(v)-cos(u/2)*sin(2*v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Gray's Surface":
            x    = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*cos(u/2)");
            y    = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*sin(u/2)");
            z    = ExpressionParser.Parse("sin(3*u/2)*sin(v)+cos(3*u/2)*sin(2*v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("4*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Knot":
            x    = ExpressionParser.Parse("3*sin(3*u)/2+cos(v)))");
            y    = ExpressionParser.Parse("3*(sin(u)+2*sin(2*u))/(2+cos(v+pi*2/3))");
            z    = ExpressionParser.Parse("3/2*(cos(u)-2*cos(2*u))*(2+cos(v))*(2+cos(v+pi*2/3))/4");
            umin = ExpressionParser.Parse("-pi");
            umax = ExpressionParser.Parse("2pi");
            vmin = ExpressionParser.Parse("-pi");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Mobius":
            x    = ExpressionParser.Parse("(5+u*cos(0.5*v))*cos(v)");
            y    = ExpressionParser.Parse("(5+u*cos(0.5*v))*sin(v)");
            z    = ExpressionParser.Parse("u*sin(0.5*v)");
            umin = ExpressionParser.Parse("-1");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Radial Wave":
            x    = ExpressionParser.Parse("u");
            y    = ExpressionParser.Parse("v");
            z    = ExpressionParser.Parse("cos((u^2+v^2)^0.5)");
            umin = ExpressionParser.Parse("-10");
            umax = ExpressionParser.Parse("10");
            vmin = ExpressionParser.Parse("-10");
            vmax = ExpressionParser.Parse("10");
            break;

        case "Torus":
            x    = ExpressionParser.Parse("(5+cos(v))*cos(u)");
            y    = ExpressionParser.Parse("(5+cos(v))*sin(u)");
            z    = ExpressionParser.Parse("sin(v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        //R3->R3
        case "Cone":
            x    = ExpressionParser.Parse("ucos(v)w");
            y    = ExpressionParser.Parse("usin(v)w");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Cube":
            x    = ExpressionParser.Parse("u");
            y    = ExpressionParser.Parse("v");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Cylinder":
            x    = ExpressionParser.Parse("ucos(v)");
            y    = ExpressionParser.Parse("usin(v)");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Sphere":
            x    = ExpressionParser.Parse("ucos(v)sin(w)");
            y    = ExpressionParser.Parse("usin(v)sin(w)");
            z    = ExpressionParser.Parse("ucos(w)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("2pi");
            break;

        case "Tetrahedron":
            x    = ExpressionParser.Parse("u(1-v)");
            y    = ExpressionParser.Parse("uv(1-w)");
            z    = ExpressionParser.Parse("uvw");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        // Orbitals
        case "S":
            x    = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Px":
            x    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Py":
            x    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Pz":
            x    = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dz\x00B2":
            goto case "Dz2";

        case "Dz2":
            x    = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dxz":
            x    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dyz":
            x    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dxy":
            x    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Dx\x00B2-y\x00B2":
            goto case "Dx2-y2";

        case "Dx2-y2":
            x    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fz\x00B3":
            goto case "Fz3";

        case "Fz3":
            x    = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fxz\x00B2":
            goto case "Fxz2";

        case "Fxz2":
            x    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fyz\x00B2":
            goto case "Fyz2";

        case "Fyz2":
            x    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fxyz":
            x    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fz\x0028x\x00B2-y\x00B2\x0029":
            goto case "Fzx2y2";

        case "Fzx2y2":
            x    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fx\x0028x\x00B2-3y\x00B2\x0029":
            goto case "Fxx23y2";

        case "Fxx23y2":
            x    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Fy\x00283x\x00B2-y\x00B2\x0029":
            goto case "Fy3x2y2";

        case "Fy3x2y2":
            x    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*sin(u)*cos(v)");
            y    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*cos(u)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;
        }

        expressionSet.AddExpression("X", x);
        expressionSet.AddExpression("Y", y);
        expressionSet.AddExpression("Z", z);
        expressionSet.AddRange("t", tmin, tmax);
        expressionSet.AddRange("u", umin, umax);
        expressionSet.AddRange("v", vmin, vmax);
        expressionSet.AddRange("w", wmin, wmax);
        calcManager.PresetPressed();
    }
Example #32
0
    protected void HandleInput(string source)
    {
        List <string> x;
        List <string> y;
        List <string> z;
        List <string> umin = ExpressionParser.Parse("");
        List <string> umax = ExpressionParser.Parse("");
        List <string> tmin = ExpressionParser.Parse("");
        List <string> tmax = ExpressionParser.Parse("");
        List <string> vmin = ExpressionParser.Parse("");
        List <string> vmax = ExpressionParser.Parse("");
        List <string> wmin = ExpressionParser.Parse("");
        List <string> wmax = ExpressionParser.Parse("");

        ExpressionSet expressionSet = calcManager.expressionSet;

        switch (source)
        {
        default:
            x    = ExpressionParser.Parse("0");
            y    = ExpressionParser.Parse("0");
            z    = ExpressionParser.Parse("0");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("0");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("0");
            print("unknown preset pressed");
            break;

        //R1 -> R1
        case "Cinquefoil Knot":
            x    = ExpressionParser.Parse("cos(t)*(2-cos(2*t/5))");
            y    = ExpressionParser.Parse("sin(t)*(2-cos(2*t/5))");
            z    = ExpressionParser.Parse("-sin(2*t/5)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("10*pi");
            break;

        case "Circle":
            x    = ExpressionParser.Parse("cos(t)");
            y    = ExpressionParser.Parse("sin(t)");
            z    = ExpressionParser.Parse("0");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2pi");
            break;

        case "Sphere Outline":
            x    = ExpressionParser.Parse("sin(t)*cos(32*t)");
            y    = ExpressionParser.Parse("sin(t)*sin(32*t)");
            z    = ExpressionParser.Parse("cos(t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("pi");
            break;

        case "Hypocloid":
            x    = ExpressionParser.Parse("cos(t)^3");
            y    = ExpressionParser.Parse("sin(t)^3");
            z    = ExpressionParser.Parse("0");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("4pi");
            break;

        case "Hypocloid Surface":
            x    = ExpressionParser.Parse("10*cos(t*32)^3");
            y    = ExpressionParser.Parse("10*sin(t*32)^3");
            z    = ExpressionParser.Parse("t-2*pi");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("4pi");
            break;

        case "Trefoil Knot":
            x    = ExpressionParser.Parse("sin(t)+2*sin(2*t)");
            y    = ExpressionParser.Parse("cos(t)-2*cos(2*t)");
            z    = ExpressionParser.Parse("-sin(3*t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2*pi");
            break;

        case "Turnip":
            x    = ExpressionParser.Parse("(sin(t/16)^2)*cos(8*t)*8*pi");
            y    = ExpressionParser.Parse("(sin(t/16))^2*sin(8*t)*8*pi");
            z    = ExpressionParser.Parse("8*pi-t");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("16pi");
            break;

        case "Wavy Surface":
            x    = ExpressionParser.Parse("(sin(t/2)^(1/2)*cos(256*t)*pi)");
            y    = ExpressionParser.Parse("(sin(t/2))^(1/2)*sin(64*t)*pi");
            z    = ExpressionParser.Parse("pi-t");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("2pi");
            break;

        case "High-res Sphere":
            x    = ExpressionParser.Parse("sin(t)*cos(1024*t)");
            y    = ExpressionParser.Parse("sin(t)*sin(1024*t)");
            z    = ExpressionParser.Parse("cos(t)");
            tmin = ExpressionParser.Parse("0");
            tmax = ExpressionParser.Parse("pi");
            break;

        //R2->R3
        case "Astroidal Ellipse":
            x    = ExpressionParser.Parse("(2*cos(u)*cos(v))^3");
            y    = ExpressionParser.Parse("(2*sin(u)*cos(v))^3");
            z    = ExpressionParser.Parse("(2*sin(v))^3");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Bumpy Sphere":
            x    = ExpressionParser.Parse("5*sin(u)*sin(v)+cos(30*v)*0.15");
            y    = ExpressionParser.Parse("5*cos(u)*sin(v)+cos(30*u)*0.15");
            z    = ExpressionParser.Parse("5*cos(v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("pi");
            break;

        case "Dini's Surface":
            x    = ExpressionParser.Parse("3*cos(u)*sin(v)");
            y    = ExpressionParser.Parse("3*sin(u)*sin(v)");
            z    = ExpressionParser.Parse("3*(cos(v)+log(tan(0.5*v)))+0.4*u");
            umin = ExpressionParser.Parse("-4*pi");
            umax = ExpressionParser.Parse("4*pi");
            vmin = ExpressionParser.Parse("0.005");
            vmax = ExpressionParser.Parse("3.135");
            break;

        case "Figure-8":
            x    = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*cos(u)");
            y    = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*sin(u)");
            z    = ExpressionParser.Parse("sin(u/2)*sin(v)-cos(u/2)*sin(2*v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Gray's Surface":
            x    = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*cos(u/2)");
            y    = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*sin(u/2)");
            z    = ExpressionParser.Parse("sin(3*u/2)*sin(v)+cos(3*u/2)*sin(2*v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("4*pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Knot":
            x    = ExpressionParser.Parse("3*sin(3*u)/2+cos(v)))");
            y    = ExpressionParser.Parse("3*(sin(u)+2*sin(2*u))/(2+cos(v+pi*2/3))");
            z    = ExpressionParser.Parse("3/2*(cos(u)-2*cos(2*u))*(2+cos(v))*(2+cos(v+pi*2/3))/4");
            umin = ExpressionParser.Parse("-pi");
            umax = ExpressionParser.Parse("2pi");
            vmin = ExpressionParser.Parse("-pi");
            vmax = ExpressionParser.Parse("2pi");
            break;

        case "Mobius":
            x    = ExpressionParser.Parse("(5+u*cos(0.5*v))*cos(v)");
            y    = ExpressionParser.Parse("(5+u*cos(0.5*v))*sin(v)");
            z    = ExpressionParser.Parse("u*sin(0.5*v)");
            umin = ExpressionParser.Parse("-1");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2*pi");
            break;

        case "Radial Wave":
            x    = ExpressionParser.Parse("u");
            y    = ExpressionParser.Parse("v");
            z    = ExpressionParser.Parse("cos((u^2+v^2)^0.5)");
            umin = ExpressionParser.Parse("-10");
            umax = ExpressionParser.Parse("10");
            vmin = ExpressionParser.Parse("-10");
            vmax = ExpressionParser.Parse("10");
            break;

        case "Torus":
            x    = ExpressionParser.Parse("(5+cos(v))*cos(u)");
            y    = ExpressionParser.Parse("(5+cos(v))*sin(u)");
            z    = ExpressionParser.Parse("sin(v)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("2pi");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            break;

        //R3->R3
        case "Cone":
            x    = ExpressionParser.Parse("ucos(v)w");
            y    = ExpressionParser.Parse("usin(v)w");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Cube":
            x    = ExpressionParser.Parse("u");
            y    = ExpressionParser.Parse("v");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Cylinder":
            x    = ExpressionParser.Parse("ucos(v)");
            y    = ExpressionParser.Parse("usin(v)");
            z    = ExpressionParser.Parse("w");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;

        case "Sphere":
            x    = ExpressionParser.Parse("ucos(v)sin(w)");
            y    = ExpressionParser.Parse("usin(v)sin(w)");
            z    = ExpressionParser.Parse("ucos(w)");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("2pi");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("2pi");
            break;

        case "Tetrahedron":
            x    = ExpressionParser.Parse("u(1-v)");
            y    = ExpressionParser.Parse("uv(1-w)");
            z    = ExpressionParser.Parse("uvw");
            umin = ExpressionParser.Parse("0");
            umax = ExpressionParser.Parse("1");
            vmin = ExpressionParser.Parse("0");
            vmax = ExpressionParser.Parse("1");
            wmin = ExpressionParser.Parse("0");
            wmax = ExpressionParser.Parse("1");
            break;
        }

        expressionSet.AddExpression(ExpressionSet.ExpOptions.X, x);
        expressionSet.AddExpression(ExpressionSet.ExpOptions.Y, y);
        expressionSet.AddExpression(ExpressionSet.ExpOptions.Z, z);
        expressionSet.AddRange("t", tmin, tmax);
        expressionSet.AddRange("u", umin, umax);
        expressionSet.AddRange("v", vmin, vmax);
        expressionSet.AddRange("w", wmin, wmax);
        calcManager.PresetPressed();
    }