Пример #1
0
        private void parseParams(string param)
        {
            // Defaults.
            radius   = 1.0f;
            kx       = 1.0;
            dx       = 0.0;
            ky       = 1.0;
            dy       = 0.0;
            kz       = 1.0;
            dz       = 0.0;
            segments = 1000;

            Dictionary <string, string> p = Util.ParseKeyValueList(param);

            if (p.Count > 0)
            {
                // r=<double>
                Util.TryParse(p, "r", ref radius);

                // seg=<int>
                if (Util.TryParse(p, "seg", ref segments) &&
                    segments < 10)
                {
                    segments = 10;
                }

                // kx,dx,ky,dy,kz,dz .. frequencies and phase shifts.
                Util.TryParseRational(p, "kx", ref kx);
                Util.TryParseRational(p, "dx", ref dx);
                Util.TryParseRational(p, "ky", ref ky);
                Util.TryParseRational(p, "dy", ref dy);
                Util.TryParseRational(p, "kz", ref kz);
                Util.TryParseRational(p, "dz", ref dz);

                // ... you can add more parameters here ...
            }

            // Estimate of upper bound for 't'.
            maxT = 2.0 * Math.PI / Arith.GCD(Arith.GCD(kx, ky), kz);
        }
        private void parseParams(string param)
        {
            // Defaults.
            radius   = 1.0f;
            kx       = 1.0;
            dx       = 0.0;
            ky       = 1.0;
            dy       = 0.0;
            kz       = 1.0;
            dz       = 0.0;
            segments = 1000;

            Dictionary <string, string> p = Util.ParseKeyValueList(param);

            if (p.Count > 0)
            {
                // r=<double>
                Util.TryParse(p, "r", ref radius);

                // seg=<int>
                if (Util.TryParse(p, "seg", ref segments) &&
                    segments < 1)
                {
                    segments = 1;
                }

                // kx,dx,ky,dy,kz,dz .. frequencies and phase shifts.
                Util.TryParseRational(p, "kx", ref kx);
                Util.TryParseRational(p, "dx", ref dx);
                Util.TryParseRational(p, "ky", ref ky);
                Util.TryParseRational(p, "dy", ref dy);
                Util.TryParseRational(p, "kz", ref kz);
                Util.TryParseRational(p, "dz", ref dz);
                Util.TryParse(p, "bezier", ref bezier);
                Util.TryParse(p, "dragon", ref dragon);
                Util.TryParse(p, "tetrahedron", ref tetrahedron);
                Util.TryParse(p, "octahedron", ref octahedron);
                Util.TryParse(p, "koch", ref koch);
                Util.TryParse(p, "rose", ref rose);
                Util.TryParse(p, "spiral", ref spiral);
                Util.TryParse(p, "ratioZ", ref ratioZ);
                Util.TryParse(p, "noRatioZ", ref noRatioZ);
                Util.TryParse(p, "ratioX", ref ratioX);
                Util.TryParse(p, "noRatioX", ref noRatioX);
                Util.TryParse(p, "ratioY", ref ratioY);
                Util.TryParse(p, "noRatioY", ref noRatioY);
                if (Util.TryParse(p, "angle", ref paramAngle))
                {
                    paramAngle = paramAngle * Math.PI / 180.0;
                }


                if (Util.TryParse(p, "scale", ref scale))
                {
                    if (scale < 0)
                    {
                        scale = 1;
                    }
                }
                if (Util.TryParse(p, "n", ref n))
                {
                    if (n < 1)
                    {
                        n = 1;
                    }
                }
                if (Util.TryParse(p, "d", ref d))
                {
                    if (d < 1)
                    {
                        d = 1;
                    }
                }
                Util.TryParse(p, "rose", ref rose);

                if (Util.TryParse(p, "depth", ref depthParam))
                {
                    if (depthParam > 10 && (tetrahedron || koch))
                    {
                        depthParam = 10;
                    }
                }

                // ... you can add more parameters here ...
            }

            // Estimate of upper bound for 't'.
            maxT = 2.0 * Math.PI / Arith.GCD(Arith.GCD(kx, ky), kz);
        }