bool IsRenderedNode(Data.Node node) { var rendered = node.IsRendered.Value && node.DrawingValues.Type.Value != Data.RendererValues.ParamaterType.None; var hasSound = node.SoundValues.Type.GetValue() == Data.SoundValues.ParamaterType.Use; return(rendered || hasSound); }
private bool IsMovingStraight(Data.Node startNode, Data.Node endNode) { bool xConstant = startNode.Position.x == endNode.Position.x; bool yConstant = startNode.Position.y == endNode.Position.y; return(xConstant || yConstant); }
private NativeArray <Data.Node> GetNodes() { NativeArray <Data.Node> nativeNodeArray = new NativeArray <Data.Node>(Info.Map.Area, Allocator.TempJob); for (int x = -Info.Map.Size; x <= Info.Map.Size; x++) { for (int y = -Info.Map.Size; y <= Info.Map.Size; y++) { Data.Cell cell = mapSystem.GetCell(x, y); Data.Node node = new Data.Node { Index = cell.Index, PreviousIndex = -1, FCost = int.MaxValue, GCost = int.MaxValue, HCost = int.MaxValue, Position = cell.Position, Solid = cell.Solid, }; nativeNodeArray[node.Index] = node; } } return(nativeNodeArray); }
private void btnImportDump_Click(object sender, EventArgs e) { if (vizcore3d.Model.IsOpen() == false) { MessageBox.Show("모델 파일을 먼저 [열기] 하여 주시기 바랍니다.", "VIZCore3D.NET", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Dump 파일 선택"; dlg.Filter = "Attribute (*.att)|*.att|Text (*.txt)|*.txt"; if (dlg.ShowDialog() != DialogResult.OK) { return; } this.Cursor = Cursors.WaitCursor; AttributeHelper.ImportAttribute(new string[] { dlg.FileName }); if (AttributeHelper.AttributeList.Count == 0 || AttributeHelper.AttributeList[0].Count == 0) { MessageBox.Show("속성정보를 불러오지 못했습니다.", "VIZCore3D.NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int nodeCount = 0; int attCount = 0; Dictionary <string, Data.Node> nodes = vizcore3d.Object3D.GetNodePathMap(); foreach (ShxAttributeNode item in AttributeHelper.AttributeList[0]) { if (nodes.ContainsKey(item.NodePath) == false) { continue; } Data.Node node = nodes[item.NodePath]; nodeCount++; foreach (KeyValuePair <string, string> prop in item.Property) { if (String.IsNullOrEmpty(prop.Value) == true) { continue; } vizcore3d.Object3D.UDA.Add(node.Index, prop.Key, prop.Value, false); attCount++; } } MessageBox.Show(string.Format("RESULT - NODE : {0} / ATT. : {1}", nodeCount, attCount), "VIZCore3D.NET", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Cursor = Cursors.Default; }
private static Data.Node ParseOntologyLine(string line) { string[] parts = line.Split('\\'); string name = parts[0]; Data.Node node = new Data.Node(parts[0]); if (parts.Length > 1) node.AddChildren(parts[1].Split(',').ToList()); return node; }
private int GetIndexOfMinCostNode(NativeList <int> openList) { Data.Node lowestCostNode = Nodes[openList[0]]; for (int i = 1; i < openList.Length; i++) { Data.Node testNode = Nodes[openList[i]]; if (testNode.FCost < lowestCostNode.FCost) { lowestCostNode = testNode; } } return(lowestCostNode.Index); }
private string GetNodeName(int index, bool appendIndex) { if (index == -1) { return("-1"); } Data.Node node = vizcore3d.Object3D.FromIndex(index); if (appendIndex == true) { return(string.Format("{0} ({1})", node.NodeName, index)); } else { return(string.Format("{0}", node.NodeName)); } }
bool IsRenderedNodeGroup(Data.Node node) { if (IsRenderedNode(node)) { return(true); } foreach (var n in node.Children.Internal) { if (IsRenderedNodeGroup(n)) { return(true); } } return(false); }
private NativeList <int2> CalculatePath(Data.Node endNode) { if (endNode.PreviousIndex == -1) { return(new NativeList <int2>(Allocator.Temp)); } else { NativeList <int2> path = new NativeList <int2>(Allocator.Temp); path.Add(endNode.Position); for (Data.Node currentNode = endNode; currentNode.PreviousIndex != -1; currentNode = Nodes[currentNode.PreviousIndex]) { Data.Node previousNode = Nodes[currentNode.PreviousIndex]; path.Add(previousNode.Position); } return(path); } }
private void lvResult_SelectedIndexChanged(object sender, EventArgs e) { // 검색 결과 선택 if (lvResult.SelectedItems.Count == 0) { return; } ListViewItem lvi = lvResult.SelectedItems[0]; if (lvi == null) { return; } if (lvi.Tag == null) { return; } Data.Node node = (Data.Node)lvi.Tag; if (node == null) { return; } if (OnQuickSearchViewEvent == null) { return; } // 검색 결과 항목에 대한 파라미터 생성 QuickSearchViewEventArgs args = new QuickSearchViewEventArgs(); args.ResultNode = node; args.FlyToObject = ckFlyToObject.Checked; args.Xray = ckXray.Checked; // 이벤트 발생해서, 결과 조회 요청 OnQuickSearchViewEvent(this, args); }
public static Data.Dataset LoadHierarchicalDatasetFromTxt(string filePath, bool skipfirstAttribute) { StreamReader reader = new StreamReader(filePath); string datasetName = null; Data.Metadata metadata = null; Data.Dataset dataset = null; List<Data.Attribute> attributes = new List<Data.Attribute>(); List<Data.Example> examples = new List<Data.Example>(); List<Data.Node> nodes = new List<Data.Node>(); int attributeIndex = 0; int exampleIndex = 0; string mode = "start"; while (!reader.EndOfStream) { string line = reader.ReadLine(); if (!string.IsNullOrEmpty(line)) { if (line.Contains("%")) continue; if (line.Contains("@relation")) { datasetName = line.Substring(line.IndexOf(' ')).Trim(); datasetName = datasetName.Contains("-weka") ? datasetName.Substring(0, datasetName.IndexOf("-weka")) : datasetName; } else if (line.Contains("@attribute")) { Data.Attribute attribute = ParseAttributeLine(line, attributeIndex); if (attribute != null) { attributeIndex++; attributes.Add(attribute); } } else if (line.Contains("@ontology")) { mode = "ontolog"; } else if (line.Contains("@data")) { List<string> classValues = new List<string>(); int counter = 0; for(int i=1; i<nodes.Count;i++) { Data.Node node = nodes[i]; node.ValueIndex = counter; classValues.Add(node.Name); counter++; } Data.ClassHierarchy classHierarchy = new Data.ClassHierarchy(nodes.ToArray()); Data.HierarchicalAttribute target = new Data.HierarchicalAttribute("class", attributes.Count, classValues.ToArray(), classHierarchy); metadata = new Data.Metadata(datasetName, attributes.ToArray(), target,true); dataset = new Data.Dataset(metadata); mode = "data"; } else { if (mode == "ontolog") { Data.Node node = ParseOntologyLine(line); if (!nodes.Exists(n => n.Name == node.Name)) nodes.Add(node); } else { Data.Example example = ParseHierarchicalExampleLine(exampleIndex, line, dataset, skipfirstAttribute); exampleIndex++; examples.Add(example); } } } } dataset.SetExamples(examples.ToArray()); return dataset; }
public void Execute() { // Build Graph for (int i = 0; i < Nodes.Length; i++) { Data.Node node = Nodes[i]; node.HCost = CalculateHCost(node.Position, EndPosition); node.PreviousIndex = -1; Nodes[i] = node; } // Pathfinding NativeArray <int2> neighborOffsetArray = new NativeArray <int2>(8, Allocator.Temp); neighborOffsetArray[0] = new int2(+1, +0); neighborOffsetArray[1] = new int2(+1, +1); neighborOffsetArray[2] = new int2(+0, +1); neighborOffsetArray[3] = new int2(-1, +1); neighborOffsetArray[4] = new int2(-1, +0); neighborOffsetArray[5] = new int2(-1, -1); neighborOffsetArray[6] = new int2(+0, -1); neighborOffsetArray[7] = new int2(+1, -1); Data.Node startNode = Nodes[PositionToIndex(StartPosition, GridSize)]; startNode.GCost = 0; startNode.FCost = startNode.GCost + startNode.HCost; Nodes[startNode.Index] = startNode; int endNodeIndex = PositionToIndex(EndPosition, GridSize); NativeList <int> openList = new NativeList <int>(Allocator.Temp); NativeList <int> closedList = new NativeList <int>(Allocator.Temp); openList.Add(startNode.Index); while (openList.Length > 0) { int currentIndex = GetIndexOfMinCostNode(openList); Data.Node currentNode = Nodes[currentIndex]; if (currentIndex == endNodeIndex) { break; } for (int i = 0; i < openList.Length; i++) { if (openList[i] == currentIndex) { openList.RemoveAtSwapBack(i); break; } } closedList.Add(currentIndex); for (int i = 0; i < neighborOffsetArray.Length; i++) { int2 neighborPosition = currentNode.Position + neighborOffsetArray[i]; if (!OnGrid(neighborPosition, GridSize)) { continue; } Data.Node neighborNode = Nodes[PositionToIndex(neighborPosition, GridSize)]; if (closedList.Contains(neighborNode.Index)) { continue; } if (neighborNode.Solid) { continue; } int testNeighborGCost = currentNode.GCost + CalculateDistanceCost(currentNode.Position, neighborPosition); if (testNeighborGCost < neighborNode.GCost) { neighborNode.PreviousIndex = currentNode.Index; neighborNode.GCost = testNeighborGCost; neighborNode.HCost = CalculateHCost(neighborPosition, EndPosition); neighborNode.FCost = neighborNode.GCost + neighborNode.HCost; Nodes[neighborNode.Index] = neighborNode; if (!openList.Contains(neighborNode.Index)) { openList.Add(neighborNode.Index); } } } } Data.Node endNode = Nodes[endNodeIndex]; if (endNode.PreviousIndex == -1) { NativeList <int2> path = CalculatePath(endNode); path.Dispose(); } openList.Dispose(); closedList.Dispose(); }
public int CalculateHCost(Data.Node startNode, Data.Node endNode) { return(CalculateDistanceCost(startNode.Position, endNode.Position)); }
public int CalculateFCost(Data.Node startNode, Data.Node endNode) { return(startNode.GCost + CalculateHCost(startNode, endNode)); }
public int CalcuateGCost(Data.Node startNode, Data.Node endNode) { int additionalGCost = IsMovingStraight(startNode, endNode) ? Info.Path.StraightMoveCost : Info.Path.DiagonalMoveCost; return(startNode.GCost + additionalGCost); }
private void Object3D_OnSelectedObject3D(object sender, VIZCore3D.NET.Event.EventManager.SelectedObject3DEventArgs e) { if (e.Node.Count == 0) { return; } if (ckEnable.Checked == false) { return; } Data.Node node = vizcore3d.Object3D.FromIndex(e.Node[0].Index, true); // 현재 노트 스타일 가져오기 및 수정 Data.NoteStyle style = vizcore3d.Review.Note.GetStyle(); { // 화살표 색상 style.ArrowColor = Color.Black; // 화살표 두께 style.ArrowWidth = 10; // 배경 투명하게 처리 여부 style.BackgroudTransparent = ckTransparent.Checked; // 배경 색상 - 배경을 투명하게 처리할 경우, 적용되지 않음 style.BackgroundColor = Color.White; // 노트 글자 색상 style.FontColor = Color.Black; // 노트 글자 크기 style.FontSize = Data.FontSizeKind.SIZE18; // 노트 글자 굵게 표시 여부 style.FontBold = false; // 라인 색상 style.LineColor = Color.Red; // 라인 두께 style.LineWidth = 3; // 텍스트 상자 표시 여부 style.UseTextBox = true; // 라인과 텍스트 박스의 연결 위치 style.LinkArrowTailToText = Manager.NoteManager.LinkArrowTailToTextKind.OUTLINE; // 심볼 배경색 style.SymbolBackgroundColor = Color.Yellow; // 심볼 글자 색상 style.SymbolFontColor = Color.Black; // 심볼 글자 크기 style.SymbolFontSize = Data.FontSizeKind.SIZE16; // 심볼 글자 굵게 표시 여부 style.SymbolFontBold = true; // 심볼 위치 style.SymbolPosition = Manager.NoteManager.SymbolPositionKind.ARROW; // 심볼 크기 style.SymbolSize = 10; // 심볼 사용 유무 style.UseSymbol = ckUseSymbol.Checked; // 심볼 텍스트 style.SymbolText = Convert.ToString(vizcore3d.Review.Note.GetID().Count + 1); } // 색상 텍스트 생성 VIZCore3D.NET.Data.MultiColorText text = new Data.MultiColorText(); text.Add("MODEL : ", Color.Black); text.AddLine(string.Format("{0}", vizcore3d.Object3D.FromIndex(0).NodeName), Color.Red); text.Add("NAME : ", Color.Black); text.AddLine(node.NodeName, Color.Red); //{ // text.NewLine(); // // Geometry 속성 조회 // Data.Object3DProperty prop = vizcore3d.Object3D.GeometryProperty.FromIndex(e.Node[0].Index, false); // text.Add("Center : ", Color.Black); // text.AddLine(string.Format("{0}", prop.CenterPoint.ToString()), Color.Purple); // text.Add("Min. : ", Color.Black); // text.AddLine(string.Format("{0}", prop.MinPoint.ToString()), Color.Purple); // text.Add("Max. : ", Color.Black); // text.AddLine(string.Format("{0}", prop.MaxPoint.ToString()), Color.Purple); //} //{ // text.NewLine(); // // UDA(User Define Attribute) 조회 // Dictionary<string, string> uda = vizcore3d.Object3D.UDA.FromIndex(node.Index); // foreach (KeyValuePair<string, string> item in uda) // { // text.Add(string.Format("{0} : ", item.Key), Color.Red); // text.AddLine(string.Format("{0}", item.Value), Color.DarkGray); // } //} // 부재의 표면점 조회 Data.Vertex3D surfacePt = vizcore3d.Object3D.GetSurfaceVertexClosestToModelCenter(new List <int>() { node.Index }); // 화면 갱신 차단 vizcore3d.BeginUpdate(); // 노트 생성 vizcore3d.Review.Note.AddNoteSurface(text , new Data.Vertex3D(surfacePt.X + 2000.0f, surfacePt.Y, surfacePt.Z + 2000.0f) , surfacePt , style ); // 화면 갱신 차단 해제 vizcore3d.EndUpdate(); }
public static int EdgeToIndex(Data.Node node1, Data.Node node2) { return(node1.Index + Info.Map.Area * node2.Index); }