private void button2_Click(object sender, EventArgs e) { //产生随机点集: RandomPositionSet_InFixedDistribution randomPositionSet_InFixedDistribution = new RandomPositionSet_InFixedDistribution(); randomPositionSet_InFixedDistribution.PointNum = 10000; randomPositionSet_InFixedDistribution.DistributionStyle = distributionStyle.ClusterGaussianDistribution; new ConfiguratedByForm(randomPositionSet_InFixedDistribution); randomPositionSet_InFixedDistribution.Produce(); IPositionSetEdit set = randomPositionSet_InFixedDistribution; runDemo(set); }
public PositionSet_Cloned(IPositionSet positionSet) { List <IPosition> positionList = new List <IPosition>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { positionList.Add(new Position_Point(positionSet.GetPosition().GetX(), positionSet.GetPosition().GetY())); } this.positionSetEdit = new PositionSetEdit_ImplementByICollectionTemplate(positionList); this.positionSet = positionSetEdit; }
public IPositionSet CollisionDetection(PositionSetEditSet bgPositionSet, IPositionSetEdit objPositionSet) { PreProcess(bgPositionSet); float delta = 0; while (true) { IPositionSetEdit obj = new PositionSetEdit_ImplementByICollectionTemplate(); objPositionSet.InitToTraverseSet(); while (objPositionSet.NextPosition()) { obj.AddPosition(new Position_Point(objPositionSet.GetPosition().GetX(), objPositionSet.GetPosition().GetY() - delta)); } Collide(obj); delta += 0.2f; } return(null); //return QueryConvexHull(); }
private void OnGetSearchPart(ILevel level, int levelSequence, IPart part) { lock (layers) { if (SearchPartSetLayer == null) { SearchPartSet = new PositionSetEdit_ImplementByICollectionTemplate(); SearchPartSetLayer = new Layer_M2MPartSetInSpecificLevel(level, SearchPartSet); SearchPartSetLayer.MainColor = Color.Blue; SearchPartSetLayer.Active = true; layers.Add(SearchPartSetLayer); } SearchPartSet.AddPosition(part); SearchPartSetLayer.PositionSet = SearchPartSet; } flowControlerForm.BeginInvoke(Update); flowControlerForm.SuspendAndRecordWorkerThread(); }
private void OnCurrentNearestPointChanged(IPosition point) { lock (layers) { if (shrinkBoundPointSetLayer == null) { shrinkBoundPointSet = new PositionSetEdit_ImplementByICollectionTemplate(); shrinkBoundPointSetLayer = new Layer_PositionSet_Point(shrinkBoundPointSet); shrinkBoundPointSetLayer.Active = true; shrinkBoundPointSetLayer.Point.PointRadius = 3; shrinkBoundPointSetLayer.Point.IsDrawPointBorder = true; shrinkBoundPointSetLayer.Point.PointColor = Color.Red; layers.Add(shrinkBoundPointSetLayer); } shrinkBoundPointSet.AddPosition(point); shrinkBoundPointSetLayer.PositionSet = shrinkBoundPointSet; } flowControlerForm.BeginInvoke(Update); flowControlerForm.SuspendAndRecordWorkerThread(); }
private void OnGetComparedPoint(IPosition point) { lock (layers) { if (ComparedPointLayer == null) { ComparedPointSet = new PositionSetEdit_ImplementByICollectionTemplate(); ComparedPointLayer = new Layer_PositionSet_Point(ComparedPointSet); ComparedPointLayer.Active = true; ComparedPointLayer.Point.PointRadius = 2; ComparedPointLayer.Point.IsDrawPointBorder = true; ComparedPointLayer.Point.PointColor = Color.Goldenrod; layers.Add(ComparedPointLayer); } ComparedPointSet.AddPosition(point); ComparedPointLayer.PositionSet = ComparedPointSet; } flowControlerForm.BeginInvoke(Update); flowControlerForm.SuspendAndRecordWorkerThread(); }
public IPositionSet QueryConvexHull() { #region code for algorithm demo if (GetChildPositionSetInSpecificLevelOfConvexHull != null) { GetChildPositionSetInSpecificLevelOfConvexHull(m2mStructure.GetLevel(1), 1, m2mStructure.GetChildPositionSetByParentPart(0, m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0))); } #endregion IPositionSet PositionSetInConvexHull = convexHullEngine.ConvexHull( m2mStructure.GetChildPositionSetByParentPart(0, m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0))); for (int i = 1; i < m2mStructure.GetLevelNum(); i++) { ILevel currentLevel = m2mStructure.GetLevel(i); #region code for algorithm demo if (GetConvexHullPositionSetInSpecificLevel != null) { GetConvexHullPositionSetInSpecificLevel(currentLevel, i, PositionSetInConvexHull); } #endregion tempChildPositionList = new List <IPosition>(); tempChildPositionList.Capacity = 4 * PositionSetInConvexHull.GetNum(); PositionSetInConvexHull.InitToTraverseSet(); IPosition hullStartPoint = null; IPosition temp1 = null; IPosition temp2 = null; if (PositionSetInConvexHull.NextPosition()) { temp1 = PositionSetInConvexHull.GetPosition(); hullStartPoint = temp1; AddChildPositionSetToList(i, temp1); #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { linePositionSetInSpecificLevel = new PositionSetEdit_ImplementByICollectionTemplate(); linePositionSetInSpecificLevel.AddPosition(new Position_Point(temp1.GetX(), temp1.GetY())); } #endregion } #region code for algorithm demo if (GetRepresentativeHullInSpecificLevel != null) { representativeHull = new PositionSetEdit_ImplementByICollectionTemplate(); } #endregion bool isWaitingLastPoint = true; //遍历该层凸包的每个分块,以确定下一层的候选分块 while (true) { if (isWaitingLastPoint) { if (PositionSetInConvexHull.NextPosition() == false) { isWaitingLastPoint = false; temp2 = hullStartPoint; } else { temp2 = PositionSetInConvexHull.GetPosition(); AddChildPositionSetToList(i, temp2); } } else { break; } IPosition start = new Position_Point(currentLevel.ConvertRealValueToRelativeValueX(((IPart)temp1).GetRandomOneFormDescendantPoint().GetX()), currentLevel.ConvertRealValueToRelativeValueY(((IPart)temp1).GetRandomOneFormDescendantPoint().GetY())); IPosition end = new Position_Point(currentLevel.ConvertRealValueToRelativeValueX(((IPart)temp2).GetRandomOneFormDescendantPoint().GetX()), currentLevel.ConvertRealValueToRelativeValueY(((IPart)temp2).GetRandomOneFormDescendantPoint().GetY())); IPositionSet tempPositionSet = writeLineInGridEngine.WriteLineInGrid(currentLevel.GetGridWidth(), currentLevel.GetGridHeight(), start, end); #region code for algorithm demo if (GetRepresentativeHullInSpecificLevel != null) { representativeHull.AddPosition(start); representativeHull.AddPosition(end); GetRepresentativeHullInSpecificLevel(m2mStructure.GetLevel(i), i, representativeHull); } #endregion tempPositionSet.InitToTraverseSet(); while (tempPositionSet.NextPosition()) { IPosition tempPosition = tempPositionSet.GetPosition(); IPart tempPart = currentLevel.GetPartRefByPartIndex(currentLevel.ConvertRelativeValueToPartSequenceX(tempPosition.GetX()), currentLevel.ConvertRelativeValueToPartSequenceY(tempPosition.GetY())); #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { linePositionSetInSpecificLevel.AddPosition(new Position_Point(currentLevel.ConvertRelativeValueToPartSequenceX(tempPosition.GetX()) , currentLevel.ConvertRelativeValueToPartSequenceY(tempPosition.GetY()))); } #endregion if (tempPart != null) { AddChildPositionSetToList(i, tempPart); } } #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { if (isWaitingLastPoint) { linePositionSetInSpecificLevel.AddPosition(new Position_Point(temp2.GetX(), temp2.GetY())); } } #endregion #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { GetLinePositionSetInSpecificLevel(m2mStructure.GetLevel(i), i, linePositionSetInSpecificLevel); } #endregion temp1 = temp2; } IPositionSet ChildPositionSetInConvexHull = new PositionSetEdit_ImplementByICollectionTemplate(tempChildPositionList); #region code for algorithm demo if (GetChildPositionSetInSpecificLevelOfConvexHull != null) { if (i < m2mStructure.GetLevelNum() - 1) { GetChildPositionSetInSpecificLevelOfConvexHull(m2mStructure.GetLevel(i + 1), i + 1, ChildPositionSetInConvexHull); } } #endregion PositionSetInConvexHull = convexHullEngine.ConvexHull(ChildPositionSetInConvexHull); } #region code for algorithm demo if (GetRealConvexHull != null) { GetRealConvexHull(PositionSetInConvexHull); } #endregion return(PositionSetInConvexHull); }
public void AddPositionSet(IPositionSetEdit positionSetEdit) { positionSetList.Add(positionSetEdit); }