private SDMinVertex getWeightedVertex(Polyline polyline, int pathIndex, int pointIndex) { SDMinVertex result = new SDMinVertex(); result.PathIndex = pathIndex; result.PointIndex = pointIndex; result.Weight = getVertexWeight(polyline, pathIndex, pointIndex); BoundingRectangle br = new PointD(polyline.Paths[pathIndex].Vertices[pointIndex]).GetBoundingRectangle(); br.Grow(PlanimetryAlgorithms.Tolerance); result.BoundingRectangle = br; return(result); }
private List <SDMinVertex> getWeightedVertices(Polyline polyline) { List <SDMinVertex> result = new List <SDMinVertex>(); for (int i = 0; i < polyline.Paths.Count; i++) { for (int j = 0; j < polyline.Paths[i].Vertices.Count; j++) { if (j != 0 && j != polyline.Paths[i].Vertices.Count - 1) { SDMinVertex vertex = getWeightedVertex(polyline, i, j); vertex.Previous = result[result.Count - 1]; vertex.Previous.Next = vertex; result.Add(vertex); } else { SDMinVertex vertex = new SDMinVertex(); vertex.PathIndex = i; vertex.PointIndex = j; BoundingRectangle br = new PointD(polyline.Paths[i].Vertices[j]).GetBoundingRectangle(); br.Grow(PlanimetryAlgorithms.Tolerance); vertex.BoundingRectangle = br; vertex.Weight = double.PositiveInfinity; if (j != 0) { vertex.Previous = result[result.Count - 1]; vertex.Previous.Next = vertex; } result.Add(vertex); } } } Comparison <SDMinVertex> comparision = delegate(SDMinVertex weight1, SDMinVertex weight2) { if (double.IsInfinity(weight1.Weight) && double.IsInfinity(weight2.Weight)) { return(0); } if (double.IsInfinity(weight1.Weight)) { return(1); } if (double.IsInfinity(weight2.Weight)) { return(-1); } if (weight1 == weight2) { return(0); } return(weight1.Weight > weight2.Weight ? 1 : -1); }; // sort list result.Sort(comparision); return(result); }
private List<SDMinVertex> getWeightedVertices(Polyline polyline) { List<SDMinVertex> result = new List<SDMinVertex>(); for (int i = 0; i < polyline.Paths.Count; i++) for (int j = 0; j < polyline.Paths[i].Vertices.Count; j++) if (j != 0 && j != polyline.Paths[i].Vertices.Count - 1) { SDMinVertex vertex = getWeightedVertex(polyline, i, j); vertex.Previous = result[result.Count - 1]; vertex.Previous.Next = vertex; result.Add(vertex); } else { SDMinVertex vertex = new SDMinVertex(); vertex.PathIndex = i; vertex.PointIndex = j; BoundingRectangle br = new PointD(polyline.Paths[i].Vertices[j]).GetBoundingRectangle(); br.Grow(PlanimetryAlgorithms.Tolerance); vertex.BoundingRectangle = br; vertex.Weight = double.PositiveInfinity; if (j != 0) { vertex.Previous = result[result.Count - 1]; vertex.Previous.Next = vertex; } result.Add(vertex); } Comparison<SDMinVertex> comparision = delegate(SDMinVertex weight1, SDMinVertex weight2) { if(double.IsInfinity(weight1.Weight) && double.IsInfinity(weight2.Weight)) return 0; if (double.IsInfinity(weight1.Weight)) return 1; if (double.IsInfinity(weight2.Weight)) return -1; if (weight1 == weight2) return 0; return weight1.Weight > weight2.Weight ? 1 : -1; }; // sort list result.Sort(comparision); return result; }
private SDMinVertex getWeightedVertex(Polyline polyline, int pathIndex, int pointIndex) { SDMinVertex result = new SDMinVertex(); result.PathIndex = pathIndex; result.PointIndex = pointIndex; result.Weight = getVertexWeight(polyline, pathIndex, pointIndex); BoundingRectangle br = new PointD(polyline.Paths[pathIndex].Vertices[pointIndex]).GetBoundingRectangle(); br.Grow(PlanimetryAlgorithms.Tolerance); result.BoundingRectangle = br; return result; }