Example #1
0
        /*public string convertMath(string prgfun)
         * {
         *
         * }*/

        public bool CreateModel(Device Device, float RA, float RB, float A, float B, float H, int NHX, int NHY, float HWX, float HWY, float SizeRebroX, float SizeRebroY, ProgibFunctionDelegate ProgibFunction, int dummy, float scaleCoeff, string prgfun)
        {
            try
            {
                #region создание сетки прогибов
                List <Vector3> Progibs = new List <Vector3>();
                List <float>   xpoints = new List <float>();
                List <float>   ypoints = new List <float>();
                float          xstep   = A / 180;
                float          ystep   = B / 180;
                for (float x = 0; x <= A; x += xstep)
                {
                    xpoints.Add(x);
                }
                for (float y = 0; y <= B; y += ystep)
                {
                    ypoints.Add(y);
                }

                float propusk = (A - NHX * SizeRebroX) / (NHX + 1);
                for (int i = 0; i < NHX; i++)
                {
                    float x = (i + 1) * propusk + i * SizeRebroX;
                    if (!xpoints.Contains(x))
                    {
                        xpoints.Add(x);
                    }
                    x = (i + 1) * propusk + i * SizeRebroX + SizeRebroX / 2;
                    if (!xpoints.Contains(x))
                    {
                        xpoints.Add(x);
                    }
                    x = (i + 1) * propusk + i * SizeRebroX + SizeRebroX;
                    if (!xpoints.Contains(x))
                    {
                        xpoints.Add(x);
                    }
                }
                propusk = (B - NHY * SizeRebroY) / (NHY + 1);
                for (int i = 0; i < NHY; i++)
                {
                    float y = (i + 1) * propusk + i * SizeRebroY;
                    if (!ypoints.Contains(y))
                    {
                        ypoints.Add(y);
                    }
                    y = (i + 1) * propusk + i * SizeRebroY + SizeRebroY / 2;
                    if (!ypoints.Contains(y))
                    {
                        ypoints.Add(y);
                    }
                    y = (i + 1) * propusk + i * SizeRebroY + SizeRebroY;
                    if (!ypoints.Contains(y))
                    {
                        ypoints.Add(y);
                    }
                }
                xpoints.Sort();
                ypoints.Sort();

                AssemblyGenerator assgen = new AssemblyGenerator(prgfun);
                foreach (float x in xpoints)
                {
                    foreach (float y in ypoints)
                    {
                        float rfv = (float)(assgen.Function(x, y) * scaleCoeff);
                        if (ProgibFunction != null)
                        {
                            Progibs.Add(new Vector3(x, y, rfv));
                        }
                        else
                        {
                            Progibs.Add(new Vector3(x, y, 0));
                        }
                    }
                }
                //int ttyt;
                //ttyt = 123;
                #endregion

                return(CreateModel(Device, RA, RB, A, B, H, NHX, NHY, HWX, HWY, SizeRebroX, SizeRebroY, Progibs, scaleCoeff, prgfun));
            }
            catch
            {
                return(false);
            }
        }
        public bool CreateModel(Device Device, float RadiusY, float SizeX, float SizeYAngle, float SizeZ, int NHX, int NHY, float HWX, float HWY, float SizeRebroX, float SizeRebroYAngle, ProgibFunctionDelegate ProgibFunction, int dummy, float scaleCoeff, string prgfun)
        {
            try
            {
                #region создание сетки прогибов
                List <Vector3> Progibs = new List <Vector3>();
                List <float>   xpoints = new List <float>();
                List <float>   ypoints = new List <float>();
                float          xstep   = SizeX / 180;
                float          ystep   = SizeYAngle / 180;
                for (float x = 0; x <= SizeX; x += xstep)
                {
                    xpoints.Add(x);
                }
                for (float y = 0; y <= SizeYAngle; y += ystep)
                {
                    ypoints.Add(y);
                }

                float propusk = (SizeX - NHX * SizeRebroX) / (NHX + 1);
                for (int i = 0; i < NHX; i++)
                {
                    float x = (i + 1) * propusk + i * SizeRebroX;
                    if (!xpoints.Contains(x))
                    {
                        xpoints.Add(x);
                    }
                    x = (i + 1) * propusk + i * SizeRebroX + SizeRebroX / 2;
                    if (!xpoints.Contains(x))
                    {
                        xpoints.Add(x);
                    }
                    x = (i + 1) * propusk + i * SizeRebroX + SizeRebroX;
                    if (!xpoints.Contains(x))
                    {
                        xpoints.Add(x);
                    }
                }
                propusk = (SizeYAngle - NHY * SizeRebroYAngle) / (NHY + 1);
                for (int i = 0; i < NHY; i++)
                {
                    float y = (i + 1) * propusk + i * SizeRebroYAngle;
                    if (!ypoints.Contains(y))
                    {
                        ypoints.Add(y);
                    }
                    y = (i + 1) * propusk + i * SizeRebroYAngle + SizeRebroYAngle / 2;
                    if (!ypoints.Contains(y))
                    {
                        ypoints.Add(y);
                    }
                    y = (i + 1) * propusk + i * SizeRebroYAngle + SizeRebroYAngle;
                    if (!ypoints.Contains(y))
                    {
                        ypoints.Add(y);
                    }
                }
                xpoints.Sort();
                ypoints.Sort();

                for (int i = 0; i < ypoints.Count; i++)
                {
                    ypoints[i] -= (SizeYAngle / 2);
                }

                AssemblyGenerator assgen = new AssemblyGenerator(prgfun);
                foreach (float x in xpoints)
                {
                    foreach (float y in ypoints)
                    {
                        float rfv = (float)(assgen.Function(x, y + (SizeYAngle / 2)) * scaleCoeff);
                        if (ProgibFunction != null)
                        {
                            Progibs.Add(new Vector3(x, y, rfv));
                        }
                        else
                        {
                            Progibs.Add(new Vector3(x, y, 0));
                        }
                    }
                }
                #endregion

                return(CreateModel(Device, RadiusY, SizeX, SizeYAngle, SizeZ, NHX, NHY, HWX, HWY, SizeRebroX, SizeRebroYAngle, Progibs, scaleCoeff, prgfun));
            }
            catch
            {
                return(false);
            }
        }