public void PreProcess(IPositionSet positionSet) { #region code for algorithm demo if (GetPositionSetToGetConvexHull != null) { GetPositionSetToGetConvexHull(positionSet); } #endregion //请在这里改变不同的m2mStructure实现。 M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2m_Creater_ForGeneralM2MStruture.SetPointInPartFactor(set_pointInPartFactor); m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(positionSet); m2mStructure.Preprocessing(positionSet); #region code for algorithm demo if (GetM2MStructure != null) { GetM2MStructure(m2mStructure); } #endregion }
//初始化地图,在地图被更改之后调用 public void InitEngineForMap(IPositionSet_Connected mapPositionSet_Connected) { this.mapPositionSet_Connected = mapPositionSet_Connected; M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2m_Creater_ForGeneralM2MStruture.PartType = typeof(Part_Multi); m2m_Creater_ForGeneralM2MStruture.SetPointInPartFactor(50); m2m_Creater_ForGeneralM2MStruture.SetUnitNumInGridLength(3); m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(mapPositionSet_Connected); m2mStructure.Preprocessing(mapPositionSet_Connected); BuildPartSetConnectionForM2MStructure buildPartSetConnectionForM2MStructure = new BuildPartSetConnectionForM2MStructure(); buildPartSetConnectionForM2MStructure.TraversalEveryLevelAndBuild(m2mStructure); #region code for algorithm demo if (GetM2MStructureInPreprocess != null) { GetM2MStructureInPreprocess(m2mStructure); } #endregion int num = (int)(Math.Sqrt((double)mapPositionSet_Connected.GetNum())); path = new List <IPosition_Connected>(num * 2); if (num > 0) { open = new PriorityQueue <IPosition_Connected>(num * 4, com); } else { open = new PriorityQueue <IPosition_Connected>(com); } }
private void TestForViewer(object sender, EventArgs e) { painterDialog.Show(); painterDialog.Reset(); painterDialog.HoldOnMode(); RandomPositionSet_InFixedDistribution randomPositionSet1 = new RandomPositionSet_InFixedDistribution (10000, distributionStyle.GaussianDistribution); new ConfiguratedByForm(randomPositionSet1); randomPositionSet1.Produce(); RandomPositionSet_InFixedDistribution randomPositionSet2 = new RandomPositionSet_InFixedDistribution (10000, distributionStyle.LaplaceDistribution); new ConfiguratedByForm(randomPositionSet2); randomPositionSet2.Produce(); M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); IM2MStructure m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(randomPositionSet2); m2mStructure.Preprocessing(randomPositionSet2); painterDialog.Clear(); painterDialog.DrawPositionSet(randomPositionSet1); painterDialog.DrawPositionSet(randomPositionSet2); painterDialog.DrawM2MLevel(m2mStructure.GetLevel(m2mStructure.GetLevelNum() - 1)); painterDialog.DrawM2MStructure(m2mStructure); Layer_PositionSet layer = new Layer_PositionSet_Point(GetRamSet2()); layer.SetPositionSetTransformByM2MLevel(m2mStructure.GetLevel(m2mStructure.GetLevelNum() - 1)); //painterDialog.Painter.Layers.Add(layer); painterDialog.Show(); painterDialog.Clear(); painterDialog.DrawPath(GetRamSet(1000, 800)); painterDialog.DrawPositionSet(GetRamSet(500, 400)); painterDialog.DrawConvexHull(GetRamSet2()); painterDialog.DrawSquareFrame(GetRamSet(500, 400)); painterDialog.Show(); painterDialog.Reset(); }
public void PreProcess(PositionSetEditSet pointList) { #region code for algorithm demo if (GetPositionSetToGetConvexHull != null) { GetPositionSetToGetConvexHull(pointList); } #endregion //请在这里改变不同的m2mStructure实现。 M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(pointList, levelNum); PositionSetEdit_ImplementByICollectionTemplate positionSet = new PositionSetEdit_ImplementByICollectionTemplate(); ILevel bottomLevel = m2mStructure.GetLevel(m2mStructure.GetLevelNum() - 1); for (int i = 0; i < pointList.GetPositionSetNum(); i++) { IPosition start = new Position_Point(); IPosition end = new Position_Point(); IPosition first = new Position_Point(); IPositionSet positionListTemp = pointList.GetNthPositionSet(i); positionListTemp.InitToTraverseSet(); if (positionListTemp.NextPosition()) { start = new Position_Point(bottomLevel.ConvertRealValueToRelativeValueX(positionListTemp.GetPosition().GetX()), bottomLevel.ConvertRealValueToRelativeValueY(positionListTemp.GetPosition().GetY())); first = start; positionSet.AddPosition(start); } while (positionListTemp.NextPosition()) { end = new Position_Point(bottomLevel.ConvertRealValueToRelativeValueX(positionListTemp.GetPosition().GetX()), bottomLevel.ConvertRealValueToRelativeValueY(positionListTemp.GetPosition().GetY())); IPositionSet positionSetTemp = writeLineInGridEngine.WriteLineInGrid(bottomLevel.GetGridWidth(), bottomLevel.GetGridHeight(), start, end); if (positionSetTemp != null) { positionSetTemp.InitToTraverseSet(); while (positionSetTemp.NextPosition()) { positionSet.AddPosition(positionSetTemp.GetPosition()); } } start = end; positionSet.AddPosition(start); } IPositionSet positionSetTemp2 = writeLineInGridEngine.WriteLineInGrid(bottomLevel.GetGridWidth(), bottomLevel.GetGridHeight(), end, first); if (positionSetTemp2 != null) { positionSetTemp2.InitToTraverseSet(); while (positionSetTemp2.NextPosition()) { positionSet.AddPosition(positionSetTemp2.GetPosition()); } } } m2mStructure.Preprocessing(positionSet); #region code for algorithm demo if (GetM2MStructure != null) { GetM2MStructure(m2mStructure); } #endregion }
private void preProcessForPositionSetConnectedToolStripMenuItem_Click(object sender, EventArgs e) { IPositionSet_Connected pSet = (IPositionSet_Connected)positionSetContainer.GetPositionSet(); LayersExOptDlg layers = new LayersExOptDlg(); LayersPainterForm layersPainterForm = new LayersPainterForm(layers); LayersPaintedControl layersPaintedControl = layersPainterForm.LayersPaintedControl; LayersEditedControl layersEditedControl = new LayersEditedControl(); layersEditedControl.Dock = DockStyle.Top; layersEditedControl.LayersPaintedControl = layersPaintedControl; layersPainterForm.Controls.Add(layersEditedControl); Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(pSet); layer_PositionSet_Connected.Point.PointColor = Color.Yellow; layer_PositionSet_Connected.Connection.LineColor = Color.Blue; layer_PositionSet_Connected.Connection.LineWidth = 0.6f; layer_PositionSet_Connected.Point.PointRadius = 1.2f; layers.Add(layer_PositionSet_Connected); layer_PositionSet_Connected.SpringLayerRepresentationChangedEvent(layer_PositionSet_Connected); M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2m_Creater_ForGeneralM2MStruture.PartType = typeof(Part_Multi); m2m_Creater_ForGeneralM2MStruture.SetPointInPartFactor(50); m2m_Creater_ForGeneralM2MStruture.SetUnitNumInGridLength(3); IM2MStructure m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(pSet); m2mStructure.Preprocessing(pSet); BuildPartSetConnectionForM2MStructure buildPartSetConnectionForM2MStructure = new BuildPartSetConnectionForM2MStructure(); buildPartSetConnectionForM2MStructure.TraversalEveryLevelAndBuild(m2mStructure); layers.Add(new Layer_M2MStructure(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()) //{ // position_ConnectedList.Add((IPosition_Connected)positionSet.GetPosition()); //} //PositionSet_Connected positionSet_Connected = new PositionSet_Connected(position_ConnectedList); Layer_PartSet_Connected layer_PartSet_Connected = new Layer_PartSet_Connected(m2mStructure, levelSequence); //layer_PartSet_Connected.MainColor //layer_PartSet_Connected.Active = true; //layer_PartSet_Connected.SetPositionSetTransformByM2MLevel(level); layers.Add(layer_PartSet_Connected); } layersPainterForm.ShowDialog(); }
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(); }