private void Triangulate0011() { FeaturePoint f = cell.FeatureEW; FillAB(f); FillCD(f); }
private void Triangulate0100() { FeaturePoint f = cell.FeatureSE; FillACD(f); FillB(f); }
private void Triangulate0111() { FeaturePoint f = cell.FeatureSW; FillA(f); FillBCD(f); }
private void Triangulate0001() { FeaturePoint f = cell.FeatureNE; FillABC(f); FillD(f); }
private void FillCD(FeaturePoint f) { if (cell.c.Filled) { renderers[cell.c.state].FillCD(cell, f); } }
public void AdaptAssymetry( Dictionary <FeaturePoint, List <NeighboredSegmentsSubpart> > splittedParts) { foreach (KeyValuePair <FeaturePoint, List <NeighboredSegmentsSubpart> > pair in splittedParts) { var cap = new RoundCap(); FeaturePoint p = pair.Key; SideRowsDistance rowsDistance = _nearProvider.GetRowsDistance(p.Feature, p.TableIndex); List <NeighboredSegmentsSubpart> splitted = pair.Value; foreach (NeighboredSegmentsSubpart part in splitted) { foreach (SegmentParts segmentParts in part.SegmentNeighbors.Values) { foreach (SegmentPart segmentPart in segmentParts) { SegmentHull hull = CreateSegmentHull( (SegmentProxy)Assert.NotNull( segmentPart.SegmentProxy, "segmentproxy is null"), rowsDistance, cap, cap); var segNbPart = (SegmentPartWithNeighbor)segmentPart; AdaptAssymetry(rowsDistance, hull, segNbPart, cap); } } } } Drop0LengthParts(EnumSegmentParts(splittedParts.Values)); }
private void FillBCToD(FeaturePoint f) { if (cell.b.Filled) { renderers[cell.b.state].FillBCToD(cell, f); } }
//随机生成约束条件 //为了避免约束条件出现环,暂时定义只有排序靠前的点可以对后面的点进行约束 public void RandomConstraint() { Random random = new Random(); for (int i = 0; i < maxConstraint; i++) { Constraint constraint = new Constraint(); int a = random.Next(0, aFeaturePoint.Count - 1);//至少留出一个空位给b, 所以是aFeaturePoint.Count - 1 int b; do { b = random.Next(a, aFeaturePoint.Count); } while (b == a); if (random.NextDouble() < 0.5) { constraint.constraintRealtion = Constraint.relation.implied; } else { constraint.constraintRealtion = Constraint.relation.excluded; } constraint.indexA = a; constraint.indexB = b; aConstraint.Add(constraint); FeaturePoint ta = (FeaturePoint)aFeaturePoint[a]; FeaturePoint tb = (FeaturePoint)aFeaturePoint[b]; Console.WriteLine(ta.GetName() + " " + constraint.constraintRealtion.ToString() + " " + tb.GetName()); } }
public void RandomlyGenerate() { rootPoint = new FeaturePoint(null); rootPoint.Init(); aTerminatePoint.Add(rootPoint); Random random = new Random(); while (rootPoint.IsFull() == false) { //随机选择一个叶子节点 int i = random.Next(0, aTerminatePoint.Count); if (i == 0) { MessageBox.Show("队列已经空掉啦 到此为止咯"); return; } //将其复制给临时节点后,将其从队列里移除 FeaturePoint t = (FeaturePoint)aTerminatePoint[i]; aTerminatePoint.RemoveAt(i); t.Epoch(); foreach (FeaturePoint child in t.GetChildren()) { aTerminatePoint.Add(child); } } }
private static void AddJunctions( [NotNull] IDictionary <FeaturePoint, Dictionary <FeaturePoint, FeaturePoint> > jctDict, [NotNull] FeaturePoint j0, [NotNull] FeaturePoint j1) { Dictionary <FeaturePoint, FeaturePoint> junctionGroup; if (!jctDict.TryGetValue(j0, out junctionGroup)) { junctionGroup = new Dictionary <FeaturePoint, FeaturePoint>( new FeaturePointComparer()); jctDict.Add(j0, junctionGroup); } if (!junctionGroup.ContainsKey(j0)) { junctionGroup.Add(j0, j0); } if (!junctionGroup.ContainsKey(j1)) { junctionGroup.Add(j1, j1); } }
public bool HasConnectionBC(FeaturePoint fB, FeaturePoint fC) { bool flip = (b.state < a.state) == (b.state < d.state); if ( IsParallel(a.xNormal, b.yNormal, flip) || IsParallel(c.xNormal, a.yNormal, flip)) { return(true); } if (fB.exists) { if (fC.exists) { if (IsBelowLine(fC.position, a.XEdgePoint, fB.position)) { if (IsBelowLine(fC.position, fB.position, b.YEdgePoint) || IsBelowLine(fB.position, fC.position, a.YEdgePoint)) { return(true); } } else if (IsBelowLine(fC.position, fB.position, b.YEdgePoint) && IsBelowLine(fB.position, c.XEdgePoint, fC.position)) { return(true); } return(false); } return(IsBelowLine(fB.position, c.XEdgePoint, a.YEdgePoint)); } return(fC.exists && IsBelowLine(fC.position, a.XEdgePoint, b.YEdgePoint)); }
public bool HasConnectionAD(FeaturePoint fA, FeaturePoint fD) { bool flip = (a.state < b.state) == (a.state < c.state); if ( IsParallel(a.xNormal, a.yNormal, flip) || IsParallel(c.xNormal, b.yNormal, flip)) { return(true); } if (fA.exists) { if (fD.exists) { if (IsBelowLine(fA.position, b.YEdgePoint, fD.position)) { if (IsBelowLine(fA.position, fD.position, c.XEdgePoint) || IsBelowLine(fD.position, fA.position, a.XEdgePoint)) { return(true); } } else if (IsBelowLine(fA.position, fD.position, c.XEdgePoint) && IsBelowLine(fD.position, a.YEdgePoint, fA.position)) { return(true); } return(false); } return(IsBelowLine(fA.position, b.YEdgePoint, c.XEdgePoint)); } return(fD.exists && IsBelowLine(fD.position, a.YEdgePoint, a.XEdgePoint)); }
private void Triangulate0101() { FeaturePoint f = cell.FeatureNS; FillAC(f); FillBD(f); }
private void Triangulate0010() { FeaturePoint f = cell.FeatureNW; FillABD(f); FillC(f); }
private void Triangulate0120() { FeaturePoint fA = cell.FeatureSW, fB = cell.FeatureSE, fC = cell.FeatureNW, fD = cell.FeatureNE; if (cell.HasConnectionAD(fA, fD)) { fB.exists &= cell.IsInsideABD(fB.position); fC.exists &= cell.IsInsideACD(fC.position); FillADToB(fB); FillADToC(fC); FillB(fB); FillC(fC); } else if (cell.a.Filled || cell.HasConnectionBC(fB, fC)) { FillJoinedCorners(fA, fB, fC, fD); } else { FillB(fB); FillC(fC); } }
private void Triangulate0112() { FeaturePoint fA = cell.FeatureSW, fB = cell.FeatureSE, fC = cell.FeatureNW, fD = cell.FeatureNE; if (cell.HasConnectionBC(fB, fC)) { fA.exists &= cell.IsInsideABC(fA.position); fD.exists &= cell.IsInsideBCD(fD.position); FillA(fA); FillD(fD); FillBCToA(fA); FillBCToD(fD); } else if (cell.b.Filled || cell.HasConnectionAD(fA, fD)) { FillJoinedCorners(fA, fB, fC, fD); } else { FillA(fA); FillD(fD); } }
private void FillADToC(FeaturePoint f) { if (cell.a.Filled) { renderers[cell.a.state].FillADToC(cell, f); } }
public static FeaturePoint Average( FeaturePoint a, FeaturePoint b, FeaturePoint c) { FeaturePoint average; average.position = Vector2.zero; float features = 0f; if (a.exists) { average.position += a.position; features += 1f; } if (b.exists) { average.position += b.position; features += 1f; } if (c.exists) { average.position += c.position; features += 1f; } if (features > 0f) { average.position /= features; average.exists = true; } else { average.exists = false; } return(average); }
private void Triangulate0121() { FeaturePoint f = cell.FeatureNSW; FillA(f); FillBD(f); FillC(f); }
private void Triangulate0102() { FeaturePoint f = cell.FeatureNSE; FillAC(f); FillB(f); FillD(f); }
private void Triangulate0012() { FeaturePoint f = cell.FeatureNEW; FillAB(f); FillC(f); FillD(f); }
private void Triangulate0122() { FeaturePoint f = cell.FeatureSEW; FillA(f); FillB(f); FillCD(f); }
private bool Find([NotNull] FeaturePoint key, double fraction, [NotNull] Dictionary <FeaturePoint, SegmentInfo> flatEnds, out SegmentInfo segmentInfo) { return(flatEnds.TryGetValue( new FeaturePoint(key.Feature, key.TableIndex, key.Part, fraction), out segmentInfo)); }
private int CreateFlatEnds([NotNull] NeighboredSegmentsSubpart segmentsSubpartx, double rowDistance, [NotNull] Dictionary <FeaturePoint, SegmentInfo> flatEnds, [NotNull] ContinuationFinder continuationFinder, bool atStart) { var errorCount = 0; double sumLength = 0; SegmentProxyInfo first = null; foreach (SegmentProxyInfo info in GetSegmentProxies(segmentsSubpartx, continuationFinder, atStart)) { first = first ?? info; var segmentPartKey = new SegmentPart(info.SegmentProxy, 0, 1, complete: true); NeighboredSegmentsSubpart segmentsSubpart = info.Subpart; SegmentParts neighboredParts; segmentsSubpart.SegmentNeighbors.TryGetValue(segmentPartKey, out neighboredParts); var featurePointKey = new FeaturePoint( segmentsSubpart.BaseFeature, segmentsSubpart.TableIndex, segmentPartKey.PartIndex, segmentPartKey.SegmentIndex); SegmentInfo segmentInfo; if (!flatEnds.TryGetValue(featurePointKey, out segmentInfo)) { // TODO revise: neighboredParts can be null here, but SegmentInfo property is later expected to be NotNull segmentInfo = new SegmentInfo(neighboredParts); flatEnds.Add(featurePointKey, segmentInfo); } if (atStart) { segmentInfo.FlatStart = true; } else { segmentInfo.FlatEnd = true; } if (info != first) { errorCount += VerifyAngle(first, info, rowDistance, segmentsSubpart); } sumLength += info.SegmentProxy.Length; if (sumLength >= rowDistance) { break; } } return(errorCount); }
public FeaturePoint(FeaturePoint parent) { featureCount++; IsMandatory = false; if (parent == null)//这意味着这是根节点 { IsMandatory = true; name = "Root"; } }
/// <summary> /// Initializes a new instance of the <see cref="Feature"/> class. /// </summary> /// <param name="minPoint">The point for the lowest retention time of the feature.</param> /// <param name="maxPoint">The point for the highest retention time of the feature.</param> public Feature(FeaturePoint minPoint, FeaturePoint maxPoint) { MinPoint = minPoint; MaxPoint = maxPoint; AssociatedPrSms = new List <PrSm>(); AssociatedMs2 = new List <int>(); Rectangle = new Rect { X = (float)MinPoint.RetentionTime, Y = (float)MinPoint.Mass, Height = 1, Width = (float)(MaxPoint.RetentionTime - MinPoint.RetentionTime) }; }
/// <summary> /// Initializes a new instance of the <see cref="Feature"/> class. /// </summary> /// <param name="minPoint">The point for the lowest retention time of the feature.</param> /// <param name="maxPoint">The point for the highest retention time of the feature.</param> public Feature(FeaturePoint minPoint, FeaturePoint maxPoint) { this.MinPoint = minPoint; this.MaxPoint = maxPoint; this.AssociatedPrSms = new List <PrSm>(); this.AssociatedMs2 = new List <int>(); this.Rectangle = new RectangleF { X = (float)this.MinPoint.RetentionTime, Y = (float)this.MinPoint.Mass, Height = 1, Width = (float)(this.MaxPoint.RetentionTime - this.MinPoint.RetentionTime) }; }
public FeaturePoint(FeaturePoint parent) { featureCount++; IsMandatory = false; price = 0; performance = 0; if (parent == null)//这意味着这是根节点 { IsMandatory = true; SetName("Root"); } this.parent = parent; }
private void FillJoinedCorners( FeaturePoint fA, FeaturePoint fB, FeaturePoint fC, FeaturePoint fD) { FeaturePoint point = FeaturePoint.Average(fA, fB, fC, fD); if (!point.exists) { point.position = cell.AverageNESW; point.exists = true; } FillA(point); FillB(point); FillC(point); FillD(point); }
private SegmentPartWithNeighbor FindNeighbor( [NotNull] Dictionary <FeaturePoint, List <NeighboredSegmentsSubpart> > splittedParts, [NotNull] FeaturePoint segmentFeature, [NotNull] SegmentPartWithNeighbor segWithNb) { var neighborKey = new FeaturePoint(segWithNb.NeighborFeature, segWithNb.NeighborTableIndex, segWithNb.PartIndex, 0); List <NeighboredSegmentsSubpart> subparts; if (!splittedParts.TryGetValue(neighborKey, out subparts)) { return(null); } foreach (NeighboredSegmentsSubpart subpart in subparts) { if (subpart.FullMinFraction > segWithNb.NeighborProxy.SegmentIndex || subpart.FullMaxFraction < segWithNb.NeighborProxy.SegmentIndex) { continue; } foreach (SegmentParts segmentParts in subpart.SegmentNeighbors.Values) { foreach (SegmentPart segmentPart in segmentParts) { if (segmentPart.SegmentIndex != segWithNb.NeighborProxy.SegmentIndex) { continue; } var partWithNeighbor = (SegmentPartWithNeighbor)segmentPart; if (partWithNeighbor.NeighborFeature == segmentFeature.Feature && partWithNeighbor.NeighborTableIndex == segmentFeature.TableIndex && partWithNeighbor.NeighborProxy.PartIndex == segWithNb.PartIndex && partWithNeighbor.NeighborProxy.SegmentIndex == segWithNb.SegmentIndex) { return(partWithNeighbor); } } } } return(null); }
private GeometryGroup createFacePart(FeaturePoint[] featurePoints) { List<Point> points = new List<Point>(); foreach (FeaturePoint p in featurePoints) points.Add(GameUtils.convertToPoint(p, facePoints)); return connectPoints(points); }
/// <summary> /// Get a normalized position based on the input texture /// </summary> /// <param name="fp">Feature point to normalize</param> /// <returns>A normalized local point with XY coordinates</returns> Vector3 NormalizePoint(FeaturePoint fp) { if (DebugTexture == null) return Vector3.zero; return new Vector3(fp.x / (float)DebugTexture.width - 0.5f, (1-fp.y / (float)DebugTexture.height) - 0.5f, 0); }
/// <summary> /// Get the world position of a local space normalized point of a Quad /// </summary> /// <param name="fp"></param> /// <returns></returns> Vector3 GetWorldPoint(FeaturePoint fp) { Vector3 fpLocal = NormalizePoint(fp); return transform.TransformPoint(fpLocal); }
public static double getLength(FeaturePoint a, FeaturePoint b, EnumIndexableCollection<FeaturePoint, PointF> facePoints) { Point p1 = convertToPoint(a, facePoints); Point p2 = convertToPoint(b, facePoints); return (Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2))); }
/// <summary> /// Marks the Microsoft intermediate language (MSIL) stream's current position as a distinguished control flow point /// related to a "feature". /// </summary> /// <param name="featureId">An arbitrary non-<B>null</B> reference.</param> /// <remarks><seealso cref="IsFeatureControlFlowPrecedent"/></remarks> public void MarkFeature(object featureId) { if (featureId == null) throw new ArgumentNullException("featureId"); if (featurePoints == null) featurePoints = new Dictionary<object, FeaturePoint>(); featurePoints[featureId] = new FeaturePoint(unresolvedBranches); }
public static Point convertToPoint(FeaturePoint p, EnumIndexableCollection<FeaturePoint, PointF> facePoints) { return new Point(facePoints[p].X, facePoints[p].Y); }