private void getPositionSetFormDBFToolStripMenuItem_Click(object sender, EventArgs e) { IPositionSet_Connected positionSet_Connected = ConvertDBFToPositionSet_Connected(""); positionSetContainer.AddPositionSet(positionSet_Connected); Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected); PainterDialog painterDialog = new PainterDialog(); painterDialog.Layers.Add(layer_PositionSet_Connected); painterDialog.Show(); }
private void button1_Click(object sender, EventArgs e) { PainterDialog painterDialog = new PainterDialog(); distributionStyle dStyle = distributionStyle.Uniform; int pointNum = 10000; RandomPositionSet_InFixedDistribution randomPositionSet = new RandomPositionSet_InFixedDistribution(pointNum, dStyle); //new ConfiguratedByForm(randomPositionSet); randomPositionSet.ConfiguratedByGUI(); randomPositionSet.Produce(); painterDialog.Clear(); painterDialog.DrawPositionSet(randomPositionSet); }
public static void lanch(IConvexHullEngine chEngine, IPositionSet ps) { PainterDialog painterDialog = new PainterDialog(); //求解凸包并作图 IPositionSet cps = chEngine.ConvexHull(ps); painterDialog.FillPolygon = true; painterDialog.Clear(); painterDialog.DrawPositionSet(ps); painterDialog.DrawConvexHull(cps); painterDialog.Show(); //测试凸包正确性 report = new CHTestAndReport(); ConvexHullCompare CHCompare = new ConvexHullCompare(ps, cps, (new QuickHull()).ConvexHull(ps)); CHCompare.Compare(); report.content = CHCompare.GetReport(); report.Show(); }
private void button1_Click(object sender, EventArgs e) { PainterDialog painterDialog = new PainterDialog(); RandomPositionSet_InFixedDistribution randomPositionSet = new RandomPositionSet_InFixedDistribution(); new ConfiguratedByForm(randomPositionSet); randomPositionSet.Produce(); QuickHull quickHull = new QuickHull(); IPositionSet convexHull = quickHull.ConvexHull(randomPositionSet); painterDialog.Clear(); painterDialog.DrawConvexHull(convexHull); IPosition p = PositionSetAttribute.GetGravityCenter(convexHull); List <IPosition> pl = new List <IPosition>(); pl.Add(p); painterDialog.DrawPath(new PositionSet_ImplementByIEnumerableTemplate(pl)); }
public static void lanch(IConvexHullEngine chEngine, int pointCount, float min, float max) { //求解凸包并作图 //IPositionSet ps = testData(); IPositionSet ps = new RandomPositionSet(pointCount, min, max); //System.Console.Out.WriteLine("position set:"); //printPositionSet(ps); IPositionSet cps = chEngine.ConvexHull(ps); //System.Console.Out.WriteLine("Jarvis Match:"); //printPositionSet(cps); PainterDialog.Clear(); PainterDialog.DrawPositionSet(ps); PainterDialog.DrawConvexHull(cps); PainterDialog.Show(); AnalyzeReport report = new AnalyzeReport(); //测试点集引用 cps.InitToTraverseSet(); ps.InitToTraverseSet(); bool correct = true; while (correct && cps.NextPosition()) { IPosition cp = cps.GetPosition(); bool find = false; ps.InitToTraverseSet(); while (!find && ps.NextPosition()) { IPosition p = ps.GetPosition(); if (cp == p) { find = true; } } if (!find) { correct = false; } } report.content += "引用测试:" + (correct ? "正确" : "错误") + "\n"; //测试凸包 if (correct) { report.content += "凸包正确性测试:\n"; IPositionSet cps_ref = (new QuickHull()).ConvexHull(ps); // System.Console.Out.WriteLine("Quick Hull:"); // printPositionSet(cps_ref); IPosition[] cpa = (IPosition[])(cps.ToArray()); IPosition[] cpa_ref = (IPosition[])(cps_ref.ToArray()); if (cpa.Length != cpa_ref.Length) { report.content += "数目不等"; correct = false; } if (correct) { int n = cpa.Length; int m = 0; int p = 0; for (; p < n; p++) { if (cpa[0] == cpa_ref[p]) { break; } } if (p == n) { correct = false; report.content += "发生错误!"; } if (correct) { for (int i = 0; i < n; i++) { if (cpa[i] == cpa_ref[(p + i + n) % n]) { m++; } } int tm = 0; for (int i = 0; i < n; i++) { if (cpa[i] == cpa_ref[(p - i + n) % n]) { tm++; } } if (tm > m) { m = tm; } report.content += "正确率:" + m.ToString() + "/" + n.ToString(); if (m == n) { report.content += "正确!"; } else { report.content += "不正确!"; } } } } report.Show(); }
private void TestBotton_Click(object sender, EventArgs e) { PainterDialog painterDialog = new PainterDialog(); RandomPositionSet_Connected_Config config = new RandomPositionSet_Connected_Config(); new ConfiguratedByForm(config); IPositionSet_ConnectedEdit pSet = config.Produce(); painterDialog.DrawPositionSet_Connected(pSet); M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2m_Creater_ForGeneralM2MStruture.PartType = typeof(Part_Multi); m2m_Creater_ForGeneralM2MStruture.SetPointInPartFactor(10); m2m_Creater_ForGeneralM2MStruture.SetUnitNumInGridLength(4); IM2MStructure m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(pSet); m2mStructure.Preprocessing(pSet); painterDialog.DrawM2MStructure(m2mStructure); BuildPartSetConnectionForM2MStructure buildPartSetConnectionForM2MStructure = new BuildPartSetConnectionForM2MStructure(); buildPartSetConnectionForM2MStructure.GetPartSetInSpecificLevel += delegate(ILevel level, int levelSequence, IPositionSet positionSet) { List <IPosition_Connected> position_ConnectedList = new List <IPosition_Connected>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { IPart_Multi partMulti = (IPart_Multi)positionSet.GetPosition(); IEnumerable <IPart_Connected> part_ConnectedEnumerable = partMulti.GetSubPartSet(); foreach (IPart_Connected part in part_ConnectedEnumerable) { position_ConnectedList.Add((IPosition_Connected)part); } } PositionSet_Connected positionSet_Connected = new PositionSet_Connected(position_ConnectedList); Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected); layer_PositionSet_Connected.SetPositionSetTransformByM2MLevel(level); painterDialog.Layers.Add(layer_PositionSet_Connected); painterDialog.Show(); }; buildPartSetConnectionForM2MStructure.TraversalEveryLevelAndBuild(m2mStructure); for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++) { ILevel level = m2mStructure.GetLevel(levelSequence); IPart rootPart = m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0); IPositionSet positionSet = m2mStructure.GetDescendentPositionSetByAncestorPart(levelSequence, rootPart, 0); List <IPosition_Connected> position_ConnectedList = new List <IPosition_Connected>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { if (positionSet.GetPosition() is IPart_Multi) { IPart_Multi partMulti = (IPart_Multi)positionSet.GetPosition(); IEnumerable <IPart_Connected> part_ConnectedEnumerable = partMulti.GetSubPartSet(); foreach (IPart_Connected part in part_ConnectedEnumerable) { position_ConnectedList.Add((IPosition_Connected)part); } } else { position_ConnectedList.Add((IPosition_Connected)positionSet.GetPosition()); } } PositionSet_Connected positionSet_Connected = new PositionSet_Connected(position_ConnectedList); Layer_PositionSet_Connected layer_PartSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected); //layer_PartSet_Connected.MainColor //layer_PartSet_Connected.Active = true; layer_PartSet_Connected.SetPositionSetTransformByM2MLevel(level); painterDialog.Layers.Add(layer_PartSet_Connected); } painterDialog.Show(); //painterDialog.Show(); }