示例#1
0
文件: Sail.cs 项目: GabeTesta/Warps
        void CreateSpokes()
        {
            const int NGIR = 5;
            const int NANG = 5;
            Vect2[] uv = new Vect2[2];
            CurveGroup group;
            //for (int nLu = 0; nLu < 1; nLu++)
            for (int nGir = 0; nGir < NGIR; nGir++)
            {
                group = new CurveGroup(string.Format("Spokes[{0}]", nGir), this);
                //group = new CurveGroup(string.Format("Spokes[{0}][{1}]", nLu, nGir), S);

                uv[0] = new Vect2(-0.3, BLAS.interpolant(nGir, NGIR));
                //uv[1-nLu] = new Vect2(1,0);

                for (int nAng = 0; nAng < NANG; nAng++)
                {
                    uv[1] = new Vect2(1.3, BLAS.interpolant(nAng, NANG));

                    MouldCurve g = new MouldCurve(string.Format(group.Label + "[{0}]", nAng), this, null);
                    g.Fit(uv[0], uv[1]);
                    group.Add(g);
                }
                Add(group);
            }
        }
示例#2
0
文件: Sail.cs 项目: GabeTesta/Warps
        IGroup[] CreateInnerGirths()
        {
            CurveGroup outer = FindGroup("Outer") as CurveGroup;
            if (outer == null)
                outer = CreateOuterCurves() as CurveGroup;

            IGroup[] girvir = new IGroup[2];
            //SurfaceCurve gir = null;
            for (int i = 0; i < 2; i++)
            {
                CurveGroup girths = new CurveGroup(i == 0 ? "Girths" : "Virths", this);
                for (double dg = 0.0; dg < 1; dg += 0.1)
                {
                    IFitPoint[] gir = new IFitPoint[2];
                    gir[1] = new CurvePoint(1, outer[2 * i + 1], dg);

                    //gir[1] = new FixedPoint(.3, .3);
                    if (i == 0)
                        gir[0] = new SlidePoint(0, outer[2 * i], dg);
                    else
                        gir[0] = new CurvePoint(0, outer[2 * i], dg);

                    MouldCurve girth = new MouldCurve(String.Format("{0}ir-{1:##0}%", i == 0 ? "G" : "V", dg * 100), this, null);
                    girth.Fit(gir);
                    girths.Add(girth);
                }
                Add(girths);
                girvir[i] = girths;
            }
            return girvir;
        }
示例#3
0
文件: Sail.cs 项目: GabeTesta/Warps
        public IGroup CreateOuterCurves()
        {
            if (FindGroup("Outer") != null)
                return FindGroup("Outer");

            CurveGroup outer = new CurveGroup("Outer", this);
            //int nLayer = View.AddLayer("Outer", Color.MistyRose, true);
            FixedPoint[] corners = new FixedPoint[4];
            corners[0] = new FixedPoint(0, 0);
            corners[1] = new FixedPoint(0, 1);
            corners[2] = new FixedPoint(1, 1);
            corners[3] = new FixedPoint(1, 0);
            FixedPoint middle = new FixedPoint(0.5, 0.5);

            FixedPoint[] lu = new FixedPoint[] { new FixedPoint(corners[0]), new FixedPoint(corners[1]) };
            FixedPoint[] hd = new FixedPoint[] { new FixedPoint(corners[1]), new FixedPoint(corners[2]) };
            FixedPoint[] le = new FixedPoint[] { new FixedPoint(corners[3]), new FixedPoint(corners[2]) };
            FixedPoint[] ft = new FixedPoint[] { new FixedPoint(corners[0]), new FixedPoint(corners[3]) };

            outer.Add(new MouldCurve("Luff", this, lu));
            outer.Add(new MouldCurve("Leech", this, le));
            outer.Add(new MouldCurve("Head", this, hd));
            outer.Add(new MouldCurve("Foot", this, ft));

            Add(outer);

            return outer;
            //LinearPath[] paths = new LinearPath[4];
            //Entity[] es;
            //for (int i = 0; i < 4; i++)
            //{
            //	Color c = Color.FromArgb(255 * (i % 2), 122 * (i % 3), 85 * i);
            //	//	LinearPath p = new LinearPath(GetPathPoints(outer[i], 100));
            //	//p.LayerIndex = nLayer;
            //	es = outer[i].CreateEntity(false);
            //	foreach (Entity e in es)
            //	{
            //		e.LayerIndex = nLayer;
            //		View.Add(e);
            //	}
            //	//m_viewleft.Entities.Add(new PointCloud(GetPoints(outer[i].xFits), 5f, Color.Tomato));

            //}
            //s.Layout.Add(outer);

            ////SurfaceCurve gir = null;
            //for (int i = 0; i < 2; i++)
            //{
            //	CurveGroup girths = new CurveGroup(i == 0 ? "Girths" : "Virths", s);
            //	nLayer = View.AddLayer(girths.Label, i == 0 ? Color.SteelBlue : Color.IndianRed, i == 0);
            //	for (double dg = 0.0; dg < 1; dg += 0.1)
            //	{
            //		IFitPoint[] gir = new IFitPoint[2];
            //		gir[1] = new CurvePoint(1, outer[2 * i + 1], dg);

            //		//gir[1] = new FixedPoint(.3, .3);
            //		if (i == 0)
            //			gir[0] = new SlidePoint(0, outer[2 * i], dg);
            //		else
            //			gir[0] = new CurvePoint(0, outer[2 * i], dg);

            //		Geodesic girth = new Geodesic(String.Format("{0}ir-{1:##0}%", i == 0 ? "G" : "V", dg * 100), s, gir);
            //		if (girth.xGeos != null)
            //		{
            //			//gir = girth;
            //			//m_viewleft.Entities.Add(new LinearPath(GetPathPoints(girth, 100), Color.DarkGoldenrod));
            //			//LinearPath p = new LinearPath(GetPathPoints(girth, 100));
            //			//p.LayerIndex = nLayer;
            //			es = girth.CreateEntity(false);
            //			foreach (Entity e in es)
            //			{
            //				e.LayerIndex = nLayer;
            //				View.Add(e);
            //			}
            //			//m_viewleft.Entities.Add(new PointCloud(GetPoints(girth.xGeos), 5f, Color.Tomato));
            //			girths.Add(girth);
            //		}
            //	}
            //	s.Layout.Add(girths);
            //}

            //CurveGroup mid = new CurveGroup("Mids", s);
            //nLayer = View.AddLayer("Mids", Color.GreenYellow, true);
            //SurfaceCurve x = new SurfaceCurve("CtoH", s, new IFitPoint[] { corners[1], middle, new CurvePoint(1, outer["Leech"], 0.0) });
            //mid.Add(x);
            //es = x.CreateEntity(false);
            //foreach (Entity e in es)
            //{
            //	e.LayerIndex = nLayer;
            //	View.Add(e);
            //}

            //s.Layout.Add(mid);
        }
示例#4
0
文件: Sail.cs 项目: GabeTesta/Warps
        IGroup[] CreateInnerCurves()
        {
            CurveGroup outer = FindGroup("Outer") as CurveGroup;
            if (outer == null)
                outer = CreateOuterCurves() as CurveGroup;

            IGroup[] rets = new IGroup[2];
            //SurfaceCurve gir = null;
            for (int i = 0; i < 2; i++)
            {
                CurveGroup curves = new CurveGroup(i == 0 ? "Horiz" : "Verts", this);
                for (double dg = 0.0; dg < 1; dg += 0.1)
                {
                    IFitPoint[] gir = new IFitPoint[2];
                    gir[1] = new CurvePoint(1, outer[2 * i + 1], dg);

                    //gir[1] = new FixedPoint(.3, .3);

                    gir[0] = new CurvePoint(0, outer[2 * i], dg);

                    MouldCurve curve = new MouldCurve(String.Format("{0}ec-{1:##0}%", i == 0 ? "S" : "V", dg * 100), this, null);
                    curve.Fit(gir);
                    curves.Add(curve);
                }
                Add(curves);
                rets[i] = curves;
            }
            return rets;
        }
示例#5
0
        private void helpToolStripButton_Click(object sender, EventArgs e)
        {
            if (ActiveSail == null)
                return;

            if (Tree.SelectedTag != null)
            {
                IRebuild tag = Tree.SelectedTag as IRebuild;
                List<IRebuild> rebuilds = new List<IRebuild>();
                if (tag != null)
                    tag.GetParents(ActiveSail, rebuilds);

                StringBuilder sb = new StringBuilder();
                foreach (IRebuild rb in rebuilds)
                    sb.AppendLine(rb.Label);
                MessageBox.Show(sb.ToString());
                return;
            }

            VariableGroup varGroup = new VariableGroup("Vars", ActiveSail);
            varGroup.Add(new Equation("yarScale", 1.0));
            varGroup.Add(new Equation("yarnDPI", "yarScale * 12780"));
            varGroup.Add(new Equation("targetScale", 1.0));
            varGroup.Add(new Equation("targetDPI", "targetScale * 14416"));
            ActiveSail.Add(varGroup);

            UpdateViews(ActiveSail.CreateOuterCurves());

            //Geodesic geo = new Geodesic("Geo", ActiveSail, new IFitPoint[] { new FixedPoint(.1, .1), new FixedPoint(.1, .9) });
            MouldCurve v1 = new MouldCurve("v1", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(.3, .4), new FixedPoint(.1, .8), new FixedPoint(0, 1) });

            MouldCurve v2 = new MouldCurve("v2", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(0, 1) });

            MouldCurve v3 = new MouldCurve("v3", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(.95, .25), new FixedPoint(.9, .55), new FixedPoint(.65, .85), new FixedPoint(0, 1) });
            //MouldCurve v4 = new MouldCurve("v4", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(.8, .5), new FixedPoint(1, 1) });
            //MouldCurve v5 = new MouldCurve("v5", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(1, 1) });
            CurveGroup grp = new CurveGroup("Warps", ActiveSail);
            grp.Add(v1);
            grp.Add(v2);
            grp.Add(v3);
            grp.Add(new MouldCurve("g3", ActiveSail,
                new IFitPoint[] {
                    new FixedPoint(0,0),
                    new SlidePoint(v1, 0),
                    new FixedPoint(1,.5) }));
            grp.Add(new MouldCurve("g4", ActiveSail,
                new IFitPoint[] {
                    new FixedPoint(1, 0),
                    new FixedPoint(.4, .4),
                    new FixedPoint(.3, .7),
                    new FixedPoint(0,1)}));
            //grp.Add(v4);
            //grp.Add(v5);
            //grp.Add(guide);

            CurveGroup guides = new CurveGroup("Guides", ActiveSail);
            GuideComb guide = new GuideComb("Guide", ActiveSail,
                new IFitPoint[] {
                    new FixedPoint(0, .5),
                    new SlidePoint(v2, .5),
                    new FixedPoint(1, .5) },
                new Vect2[] {
                    new Vect2(0, 1),
                    new Vect2(.3, .55),
                    new Vect2(.5, .5),
                    new Vect2(.7, .55),
                    new Vect2(1, 1) });
            guides.Add(guide);

            YarnGroup yar = new YarnGroup("yar1", ActiveSail, varGroup["yarnDPI"], varGroup["targetDPI"]);
            yar.Warps.Add((ActiveSail.FindGroup("Outer") as CurveGroup)[0]);
            yar.Warps.Add((ActiveSail.FindGroup("Outer") as CurveGroup)[1]);
            yar.Guide = guide;
            yar.DensityPos = new List<double>() { 0.2, 0.8 };
            ActiveSail.Add(grp);
            ActiveSail.Add(guides);
            ActiveSail.Add(yar);
            UpdateViews(grp);
            UpdateViews(guides);

            //YarnGroup LuYar = new YarnGroup("LuYar", ActiveSail, 12780);
            //LuYar.DensityPos.AddRange(new double[] { 0.25, 0.5, 0.75 });
            //LuYar.YarnsUpdated += LuYar_YarnsUpdated;
            ////if (LuYar.LayoutYarns(new List<MouldCurve>() { lu, mi, le }, guide, 14416) > 0)
            ////DateTime now = DateTime.Now;
            ////LuYar.LayoutYarns(grp, guide, 14416, LuYar.SpreadYarnsAlongGuide);
            ////TimeSpan gde = DateTime.Now - now;
            ////now = DateTime.Now;

            ////LuYar.LayoutYarns(grp, guide, 14416, LuYar.SpreadYarnsAcrossWarps);
            ////TimeSpan wrps = DateTime.Now - now;
            ////now = DateTime.Now;
            ////MessageBox.Show(string.Format("AcrossWarps: {0}\nAlongGuide: {1}", wrps.TotalMilliseconds, gde.TotalMilliseconds));

            UpdateViews(guides);
            UpdateViews(grp);
            yar.Update(ActiveSail);
            UpdateViews(yar);
            //if (LuYar.LayoutYarns(grp, guide, 14416) > 0
            //	|| MessageBox.Show(String.Format("Failed to match Target Dpi\nTarget: {0}\nAchieved: {1}\nContinue Anyway?", LuYar.TargetDpi, LuYar.AchievedDpi), "Yarn Generation Failed", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes )
            //	ActiveSail.Add(LuYar);

            ////Yarns.YarnGroup LeYar = new Yarns.YarnGroup("LeYar", ActiveSail, 12780);
            ////if (LeYar.LayoutYarns(new List<MouldCurve>() { mi, le }, guide, 14416) > 0)
            ////	ActiveSail.Add(LeYar);

            ////Rebuild(null);

            //UpdateViews(LuYar);
            //Rebuild(grp);
            //Rebuild(grp);
            //Rebuild(guides);
            //Rebuild(LuYar);
            View.Refresh();
            ActiveSail.Rebuild(null);
        }