/// <summary> /// Adding new vertex if it still doesn't exist in graph. /// </summary> /// <param name="newVertex"></param> private void AddVertex(Vertex newVertex) { if (!Vertexes.Contains(newVertex)) { Vertexes.Add(newVertex); } }
/// <summary> /// Открытие карты, загрузка из БД /// </summary> /// <param name="act"></param> /// <returns></returns> public DialogResult Open(Act act) { ConductingForm sa = new ConductingForm(act); sa.ShowDialog(); if (sa.DialogResult == DialogResult.OK) { Vertexes vert = new Vertexes(); Edges edg = new Edges(); Image image = DAO.LoadMap(sa.nameMap, out vert, out edg) as Image; Init(img: image); Map.vertexes = vert; Map.edges = edg; Map.vertexes.RePaint += MakeMap.ViewPort.Invalidate; Map.edges.RePaint += MakeMap.ViewPort.Invalidate; ToolStripMenuItem_Save.Enabled = true; ToolStripMenuItem_SaveAs.Enabled = true; ToolStripMenuItem_ChooseSubstrate.Enabled = true; } MakeMap.ViewPort.StatusLabel.Text = "Карта открыта"; return(sa.DialogResult); }
public static ulong AddHatchImageToFigure(vdDocument activeDocument, Vertexes vertexs, string toolTip, string imagePath, double hatchScale, vdXProperties xProperties) { //We will create a vdPolyline object and add it to the Active Layout which is the basic Model Layout always existing in a Document. VectorDraw.Professional.vdFigures.vdPolyline onepoly = new VectorDraw.Professional.vdFigures.vdPolyline(); //We set the document where the polyline is going to be added.This is important for the vdPolyline in order to obtain initial properties with setDocumentDefaults. onepoly.SetUnRegisterDocument(activeDocument); onepoly.setDocumentDefaults(); onepoly.ToolTip = toolTip; if (null != xProperties && xProperties.Count > 0) { for (int i = 0; i < xProperties.Count; i++) { onepoly.XProperties.AddItem(xProperties[i]); } } onepoly.VertexList = vertexs; onepoly.Flag = VectorDraw.Professional.Constants.VdConstPlineFlag.PlFlagCLOSE; //Initialize the hatch properties object. onepoly.HatchProperties = new VectorDraw.Professional.vdObjects.vdHatchProperties(); //And change it's properties onepoly.HatchProperties.FillMode = VectorDraw.Professional.Constants.VdConstFill.VdFillModeImage; onepoly.HatchProperties.HatchScale = hatchScale; onepoly.HatchProperties.DrawBoundary = false; string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + imagePath; onepoly.HatchProperties.HatchImage = activeDocument.Images.Add(path); activeDocument.ActiveLayOut.Entities.AddItem(onepoly); return(onepoly.Handle.Value); }
public void Fill() { if (Width == 0 || Height == 0) { return; } Vertexes.Add(TopLeft); Vertexes.Add(new Point() { X = TopLeft.X + Width, Y = TopLeft.Y, }); Vertexes.Add(new Point() { X = TopLeft.X + Width, Y = TopLeft.Y + Height, }); Vertexes.Add(new Point() { X = TopLeft.X, Y = TopLeft.Y + Height, }); }
/// <summary> /// Получение матрицы стоимости /// </summary> /// <param name="parents">Матрица предков</param> /// <param name="arrayOfID">Массив ID вершин (для восстановления не по порядку из коллекции)</param> /// <param name="vertexes">Коллекция вершин</param> /// <param name="edges">Коллекция дуг</param> /// <param name="criterial">Критерий поиска</param> /// <param name="driver">Водитель</param> /// <returns></returns> private double[,] GetMatrixWay(out long[,] parents, out long[] arrayOfID, Vertexes vertexes, Edges edges, Main.Criterial criterial, Driver.Driver driver) { int count = vertexes.GetCountElements(); double[,] array = new double[count, count]; parents = new long[count, count]; arrayOfID = new long[count]; List <Vertex> vertexList = vertexes.List; for (int i = 0; i < count; i++) { for (int j = 0; j < count; j++) { if (i == j) { array[i, j] = 0; } else { Edge edge = GetEdge(vertexList[i], vertexList[j], edges); array[i, j] = (edge != null) ? edge.GetCriterialValue(criterial, driver) : Double.MaxValue; //Текущее значение матрицы = критерий текущей дуги parents[i, j] = i; } } arrayOfID[i] = vertexList[i].ID; } return(array); }
private void SendVertex() { for (int i = 0; i < N; i++) { Vertexes.Add(i + 1); } }
public override Vertex <TVertex> AddVertex() //добавление вершины { var v = new Vertex <TVertex>(); v.Index = CurrentIndex; var M = Matrix; Matrix = new Edge <TEdge, TWeight, TVertex> [Vertexes.Count + 1, Vertexes.Count + 1]; for (int i = 0; i < Vertexes.Count; i++) { { for (int j = 0; j < Vertexes.Count; j++) { if (j == Vertexes.Count || i == Vertexes.Count) { Matrix[i, j] = null; } Matrix[i, j] = M[i, j]; } } } CurrentIndex++; Vertexes.Add(v); return(v); }
protected void BuildEndCapNoCutNoHollow(bool top) { float z = top ? 0.5f : -0.5f; for (int i = 0; i < OuterFaces.Length; i++) { int pointCount = OuterFaces[i].GetNumPoints(); if (pointCount > 0) { for (int j = 0; j < pointCount - 1; j++) { Vector3 first = OuterFaces[i].GetRawVertex(j); first.Z = z; Vector3 second = OuterFaces[i].GetRawVertex(j + 1); second.Z = z; Vector3 center = new Vector3(0, 0, z); float transformRatio = top ? 1 : 0; // Apply the transformation to each vertex first = Transform(first, transformRatio); second = Transform(second, transformRatio); center = Transform(center, transformRatio); Vertexes.Add(new VertexPositionColor(first, color)); Vertexes.Add(new VertexPositionColor(second, color)); Vertexes.Add(new VertexPositionColor(center, color)); } } } }
protected void BuildEndCapCutNoHollow(bool top) { float z = top ? 0.5f : -0.5f; for (int i = FirstOuterFace; i <= LastOuterFace; i++) { int pointCount = OuterFaces[i].GetNumPoints(); for (int j = 0; j < pointCount - 1; j++) { Vector3 first = OuterFaces[i].GetRawVertex(j); first.Z = z; Vector3 second = OuterFaces[i].GetRawVertex(j + 1); second.Z = z; Vector3 center = new Vector3(0, 0, z); // TODO: Texturemapping stuff //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (p1.x + 0.5), p1.y + 0.5)); //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (p2.x + 0.5), p2.y + 0.5)); float transformRatio = top ? 1 : 0; first = Transform(first, transformRatio); second = Transform(second, transformRatio); center = Transform(center, transformRatio); Vertexes.Add(new VertexPositionColor(first, color)); Vertexes.Add(new VertexPositionColor(second, color)); Vertexes.Add(new VertexPositionColor(center, color)); } } }
// Заполнение таблицы отчета private void Report_Load(object sender, EventArgs e) { reportTable.Rows.Clear(); //добавление строк и столбцов for (int i = 0; i < Vertexes.Count(); i++) { reportTable.Columns.Add(Vertexes[i].Name, Vertexes[i].Name); } for (int j = 0; j < Vertexes[0].Values.Count(); j++) { if (Vertexes[0].Values.Count() > reportTable.RowCount) { reportTable.Rows.Add(); } } //вывод значений концептов for (int i = 0; i < Vertexes.Count(); i++) { for (int j = 0; j < Vertexes[0].Values.Count(); j++) { reportTable[0, j].Value = j; reportTable[i + 1, j].Value = Math.Round(Vertexes[i].Values[j], 3); } } DrawChartGraph(); }
public static ulong AddRectImageHatch(LJJSPoint leftBottomInsertPt, double rectHeigh, double rectWidth, string imagePath, double hatchScale, List <StrValueProperty> additionImageLst) { vdXProperties tmppro = new vdXProperties(); gPoint leftBottomPt = new gPoint(leftBottomInsertPt.XValue, leftBottomInsertPt.YValue); gPoint leftTopPt = new gPoint(leftBottomInsertPt.XValue, leftBottomInsertPt.YValue + DrawCommonData.DirectionUp * rectHeigh); gPoint rightBottomPt = new gPoint(leftBottomInsertPt.XValue + rectWidth * DrawCommonData.DirectionRight, leftBottomInsertPt.YValue); gPoint rightTopPt = new gPoint(leftBottomInsertPt.XValue + rectWidth * DrawCommonData.DirectionRight, leftBottomInsertPt.YValue + DrawCommonData.DirectionUp * rectHeigh); Vertexes hatchRect = new Vertexes(); hatchRect.Add(leftBottomPt); hatchRect.Add(leftTopPt); hatchRect.Add(rightTopPt); hatchRect.Add(rightBottomPt); if (null != additionImageLst && additionImageLst.Count > 0) { for (int i = 0; i < additionImageLst.Count; i++) { StrValueProperty tmp = additionImageLst[i]; if (!string.IsNullOrEmpty(tmp.PropertyName) && !string.IsNullOrEmpty(tmp.PropertyValue)) { vdXProperty tmpproperty = new vdXProperty(); tmpproperty.Name = tmp.PropertyName; tmpproperty.PropValue = tmp.PropertyValue; tmppro.AddItem(tmpproperty); } } } return(VectorDrawHelper.AddHatchImageToFigure(DrawCommonData.activeDocument, hatchRect, "", imagePath, hatchScale, tmppro)); }
/// <summary> /// Поиск оптимального маршрута /// /// Route.Way содержит путь, null, если пути нет /// Route.Value - цена маршрута /// </summary> /// <param name="vertColl">Коллекция вершин</param> /// <param name="edgColl">Коллекция дуг</param> /// <param name="criterial">Критерий поиска</param> /// <param name="driver">Водитель</param> public void FindMinLengthWay(Vertexes vertColl, Edges edgColl, Main.Criterial criterial, Driver.Driver driver) { CurrentDriver = new Driver.Driver(driver.FIO, driver.IsViolateTL, driver.Car); long[,] parents; long[] IDs; long fromVertex = 0, toVertex = 0; for (int i = 0; i < Map.vertexes.GetCountElements(); i++) { if (Map.vertexes.GetElement(i).ID == Start.ID) { fromVertex = i; } if (Map.vertexes.GetElement(i).ID == End.ID) { toVertex = i; } } double[,] matrix = GetMatrixWay(out parents, out IDs, vertColl, edgColl, criterial, driver); int size = (int)Math.Sqrt(matrix.Length); for (int k = 0; k < size; ++k) { for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) { if (matrix[i, k] < Double.MaxValue && matrix[k, j] < Double.MaxValue && matrix[i, k] + matrix[k, j] < matrix[i, j]) { matrix[i, j] = matrix[i, k] + matrix[k, j]; parents[i, j] = parents[k, j]; } } } } if (matrix[fromVertex, toVertex] == Double.MaxValue) //Путь не найден { Way = null; } else { Criterial = criterial; List <long> wayList = GetWay(fromVertex, toVertex, parents); Way = new List <long>(wayList.Count); for (int i = 0; i < wayList.Count; i++) { Way.Add(IDs[wayList[i]]); } Value = matrix[fromVertex, toVertex]; } }
public void Dispose() { Vertexes.Dispose(); FaceIndexes.Dispose(); TriangleOrder.Dispose(); Normals.Dispose(); Tangents.Dispose(); Uvs.Dispose(); }
public static Vertexes GetVertexesFromPoints(List<PointData> points) { Vertexes vtxs = new Vertexes(); gPoints gps = new gPoints(); points.ForEach(pt => gps.Add(new gPoint(pt.X, pt.Y, pt.Z))); gps.RemoveEqualPoints(0.01); vtxs.AddRange(gps); return vtxs; }
/// <summary> /// Loads the grapth. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns></returns> public string LoadGrapth(string fileName) { List <Vertex> vertexs = Vertexes.Load(fileName); TempData["vertex"] = vertexs; string jsonResult = string.Format("{{\"city\":{0},\"connections\":{1}}}", (new City()).LoadMap(vertexs), (new Connections()).LoadConnections(vertexs)); return(jsonResult); }
/// <summary> /// 填充参数 /// </summary> /// <param name="args">The args.</param> /// <returns></returns> public override Dictionary <string, string> FillArgs(Dictionary <string, string> args) { args = base.FillArgs(args); args["coord_type_input"] = CoordTypeInput.ToString(); if (Vertexes?.Any() == true) { args["vertexes"] = string.Join(";", Vertexes.Select(o => $"{o?.Latitude ?? 0},{o?.Longitude ?? 0}")); } return(args); }
List <CPTStype> chainage_points = null; //Store all Chainage Points public frm_Process_Terrain_Survey_data(vdPolyline pl) { InitializeComponent(); exe_path = Application.StartupPath; this.vd_pl = pl; this.ptCords = vd_pl.VertexList; this.checkMasterString_.Checked = false; this.checkMasterString_.Visible = false; }
public void AddVertex(string Name) { var node = new Node(Name); if (!Vertexes.ContainsKey(Name) && Vertexes != null) { Vertexes.Add(Name, node); } ; }
public override bool DeleteVertex(Vertex <TVertex> vertex) //TODO: delete all edges { int i; for (i = 0; i < Adj.Count; i++) { if (Adj[i].AdjIndex == vertex.Index) { break; } } if (i == Adj.Count && Adj[i].AdjIndex != vertex.Index) { return(false); //не нашли вершину } if (Oriented) //если ориентированный, удаляем список, проходим по всем спискам в поисках ребер { EdgesCount = EdgesCount - Adj[i].Length; Adj.Remove(Adj[i]); //удалили вершину for (int j = 0; j < Adj.Count; j++) //ищем и удаляем ребра { for (var q = Adj[j].Head; q != null; q = q.Next) { if (q == null) { break; } // Adj[i].DeleteNode(q.AdjEdge.Vertex1, vertex); //Adj[i].DeleteNode(q.AdjEdge.Vertex2, vertex); DeleteEdge(q.AdjEdge.Vertex1, vertex); // DeleteEdge(q.AdjEdge.Vertex2, vertex); } // Adj[j].DeleteNode(vertex); } Vertexes.Remove(vertex); return(true); } else //если неориентированный, удаляем обратные ребра, потом удаляем строчку { for (var q = Adj[i].Head; q != null; q = q.Next) { if (q == null) { break; } DeleteEdge(q.AdjEdge.Vertex1, q.AdjEdge.Vertex2); //удаляем ребра // DeleteEdge(q.AdjEdge.Vertex2, q.AdjEdge.Vertex1); } Adj.Remove(Adj[i]); Vertexes.Remove(vertex); return(true); } }
/// <summary> /// 填充参数 /// </summary> /// <param name="args">原有参数</param> /// <returns>填充后的参数</returns> public override Dictionary <string, string> FillArgs(Dictionary <string, string> args) { args = base.FillArgs(args); if (Vertexes?.Any() == true) { var vs = string.Join(";", Vertexes.Select(o => $"{o?.Latitude},{o?.Longitude}")); args["vertexes"] = vs; } args["offset"] = offset.ToString(); return(args); }
public void Fit(Vector fitVector) { if (this.InnerParts.Any()) { InnerParts.ForEach(x => x.Fit(fitVector)); } else { Vertexes.ForEach(x => x.Sum(fitVector)); } }
public WorkingArea Clone() { WorkingArea newWorkingArea = new WorkingArea(); newWorkingArea.Description = Description; newWorkingArea.Name = Name; newWorkingArea.Id = Id; newWorkingArea.Vertexes = Vertexes.Select(x => x.Clone()).ToList(); return(newWorkingArea); }
public void Reverse() { Point3d _pt = Vertexes.Last <Point3d>(); Vertexes[Vertexes.Count - 1] = Vertexes[0]; Vertexes[0] = _pt; if (Type == AvailableTypes.ARC) { IsClockWise = !IsClockWise; } }
public override bool DeleteVertex(Vertex <TVertex> vertex) { var M = Matrix; int deletedE = 0; Matrix = new Edge <TEdge, TWeight, TVertex> [Vertexes.Count - 1, Vertexes.Count - 1]; int im = 0, jm = 0; // int i, j = 0; int ii = 0, jj = 0; for (int i = 0; i < Vertexes.Count; i++, im++) { if (i == Vertexes.IndexOf(vertex)) //если дошли до строчки, которой не будет { ii = i; i++; } jm = 0; for (int j = 0; j < Vertexes.Count; j++, jm++) { if (j == Vertexes.IndexOf(vertex)) //если дошли до столбца, которого не будет { jj = j; j++; } Matrix[im, jm] = M[i, j]; } } for (int s = 0; s < Vertexes.Count; s++) { if (M[ii, s] != null) { deletedE++; } } for (int s1 = 0; s1 < Vertexes.Count; s1++) { if (M[s1, jj] != null) { deletedE++; } } if (Oriented == false) { deletedE = deletedE / 2; } EdgesCount = EdgesCount - deletedE; return(Vertexes.Remove(vertex)); }
public override List <Vertex> Adj(int vertexIndex) { List <Vertex> vertexes = new List <Vertex>(); var adjIndics = _adjacencyList[vertexIndex]; foreach (var i in adjIndics) { var vertex = Vertexes.First(x => x.Index == i); vertexes.Add(vertex); } return(vertexes); }
public static void AddAreaHatch(vdDocument activeDocument, List <LJJSPoint> fillArea, LJJSHatch ljjsHatch) { Vertexes vts = new Vertexes(); if (null != fillArea && fillArea.Count > 2) { for (int i = 0; i < fillArea.Count; i++) { vts.Add(new gPoint(fillArea[i].XValue, fillArea[i].YValue)); } VectorDrawHatchHelper.AddAreaHatch(activeDocument, ljjsHatch, vts); } }
public override Vertex <TVertex> AddVertex() //добавление вершины { var v = new Vertex <TVertex>(); v.Index = CurrentIndex; Vertexes.Add(v); var A = new AdjList <TVertex, TEdge, TData, TWeight>(); A.AdjIndex = CurrentIndex; Adj.Add(A); CurrentIndex++; return(v); }
public static void VerSolidArrow(LJJSPoint basePoint, double width, double height, int direction) { Vertexes controlPtCollection = new Vertexes(); gPoint pt2 = new gPoint(basePoint.XValue + width, basePoint.YValue); gPoint pt3 = new gPoint(basePoint.XValue, basePoint.YValue + direction * height); gPoint pt4 = new gPoint(basePoint.XValue - width, basePoint.YValue); controlPtCollection.Add(FigureStrucConvert.ConvertLJJSPointToGPoint(basePoint)); controlPtCollection.Add(pt2); controlPtCollection.Add(pt3); controlPtCollection.Add(pt4); // VectorDrawHelper.BuildSpineWithSolidHatch(DrawCommonData.activeDocument, controlPtCollection, VectorDraw.Professional.Constants.VdConstPlineFlag.PlFlagCLOSE, VectorDraw.Professional.Constants.VdConstSplineFlag.SFlagSTANDARD, Color.Black.ToArgb(), ""); }
protected void BuildSideVertexes(CrossSection[] crossSection, int transforms) { float transformOffset = 1.0f / (float)transforms; float currentOffset = -0.5f; for (int i = 0; i < transforms; i++) { for (int j = 0; j < crossSection.Length; j++) { int pointCount = crossSection[j].GetNumPoints(); if (pointCount > 0) { for (int k = 0; k < pointCount - 1; k++) { Vector3 lower1, lower2, upper1, upper2; float lowerRatio = (float)i / (float)transforms; float upperRatio = (float)(i + 1) / (float)transforms; lower1 = crossSection[j].GetRawVertex(k); lower2 = crossSection[j].GetRawVertex(k + 1); lower1.Z = currentOffset; lower2.Z = currentOffset; upper1 = lower1; upper2 = lower2; upper1.Z = currentOffset + transformOffset; upper2.Z = currentOffset + transformOffset; lower1 = Transform(lower1, lowerRatio); lower2 = Transform(lower2, lowerRatio); upper1 = Transform(upper1, upperRatio); upper2 = Transform(upper2, upperRatio); Vertexes.Add(new VertexPositionColor(lower1, color)); Vertexes.Add(new VertexPositionColor(lower2, color)); Vertexes.Add(new VertexPositionColor(upper2, color)); Vertexes.Add(new VertexPositionColor(lower1, color)); Vertexes.Add(new VertexPositionColor(upper2, color)); Vertexes.Add(new VertexPositionColor(upper1, color)); } } } currentOffset += transformOffset; } }
public void NormalizeVertexes() { if (Vertexes.Count > 0) { float minimumY = Vertexes.Select(vertex => vertex.Y).Min(); float minimumX = Vertexes.Select(vertex => vertex.X).Min(); foreach (Point point in Vertexes) { point.Y = point.Y - minimumY; point.X = point.X - minimumX; } } }