private void CalcBoundBox() { lbCount.Text = string.Format("Count : {0} EA", vizcore3d.Model.SpaceSearch.ModelCount); VIZCore3D.NET.Data.BoundBox3D ModelBoundBox = vizcore3d.Model.SpaceSearch.GetModelBoundBox(); lbMinX.Text = Convert.ToInt64(ModelBoundBox.MinX).ToString("n0"); lbMinY.Text = Convert.ToInt64(ModelBoundBox.MinY).ToString("n0"); lbMinZ.Text = Convert.ToInt64(ModelBoundBox.MinZ).ToString("n0"); lbMaxX.Text = Convert.ToInt64(ModelBoundBox.MaxX).ToString("n0"); lbMaxY.Text = Convert.ToInt64(ModelBoundBox.MaxY).ToString("n0"); lbMaxZ.Text = Convert.ToInt64(ModelBoundBox.MaxZ).ToString("n0"); VIZCore3D.NET.Data.Vertex3D center = ModelBoundBox.GetCenter(); txtCenterX.Text = Convert.ToInt64(center.X).ToString(); txtCenterY.Text = Convert.ToInt64(center.Y).ToString(); txtCenterZ.Text = Convert.ToInt64(center.Z).ToString(); this.tbX.Scroll -= new System.EventHandler(this.tbX_Scroll); this.tbY.Scroll -= new System.EventHandler(this.tbY_Scroll); this.tbZ.Scroll -= new System.EventHandler(this.tbZ_Scroll); tbX.Minimum = tbY.Minimum = tbZ.Minimum = 0; tbX.Maximum = tbY.Maximum = tbZ.Maximum = 100; tbX.Value = tbY.Value = tbZ.Value = 50; this.tbX.Scroll += new System.EventHandler(this.tbX_Scroll); this.tbY.Scroll += new System.EventHandler(this.tbY_Scroll); this.tbZ.Scroll += new System.EventHandler(this.tbZ_Scroll); }
private void btnImportModel_Click(object sender, EventArgs e) { vizcore3d.Model.Close(); List <VIZCore3D.NET.Data.StreamData> stream = new List <VIZCore3D.NET.Data.StreamData>(); for (int i = 0; i < lvItems.Items.Count; i++) { ListViewItem lvi = lvItems.Items[i]; string name = lvi.SubItems[1].Text; string viz1 = string.Format("{0}\\{1}\\{1}.viz", txtPath.Text, name); string viz2 = string.Format("{0}\\{1}\\{1}_OUTSIDE.viz", txtPath.Text, name); string viz3 = string.Format("{0}\\{1}\\{1}_SIMPLIFIED.viz", txtPath.Text, name); if (rbModelVIZ.Checked == true) { stream.Add(new Data.StreamData(System.IO.File.ReadAllBytes(viz1), name)); } else if (rbModelOutside.Checked == true) { stream.Add(new Data.StreamData(System.IO.File.ReadAllBytes(viz2), name)); } else if (rbModelSimplified.Checked == true) { stream.Add(new Data.StreamData(System.IO.File.ReadAllBytes(viz3), name)); } } vizcore3d.Model.AddStream(stream); MODEL_BOUNDBOX = vizcore3d.Model.BoundBox; }
private void btnAlignCenterBlock_Click(object sender, EventArgs e) { LOADER_NODES = GetNode("LOADER"); BLOCK_NODES = GetNode("BLK"); FindItems(); vizcore3d.BeginUpdate(); // 블록 작업베이스 회전 vizcore3d.Object3D.Transform.Rotate(BLOCK_NODES, 90, 0, 0, true, false); // 가운데 정렬 VIZCore3D.NET.Data.BoundBox3D loader_bbox = vizcore3d.Object3D.GeometryProperty.FromNode(LOADER_NODES).GetBoundBox(); VIZCore3D.NET.Data.BoundBox3D block_bbox = vizcore3d.Object3D.GeometryProperty.FromNode(BLOCK_NODES).GetBoundBox(); vizcore3d.Object3D.Transform.MoveTo( BLOCK_NODES , loader_bbox.CenterX , loader_bbox.CenterY , block_bbox.CenterZ ); vizcore3d.EndUpdate(); }
private void AddTextDock4() { List <VIZCore3D.NET.Data.Node> items = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "GROUND_03" }, false, false, false, false, true, false); if (items.Count == 0) { return; } VIZCore3D.NET.Data.BoundBox3D boundbox = vizcore3d.Object3D.GeometryProperty.FromNode(items, false).GetBoundBox(); VIZCore3D.NET.Data.Vertex3D center = new VIZCore3D.NET.Data.Vertex3D(); center.X = boundbox.MaxX - 48000.0f; center.Y = boundbox.MaxY - 10000.0f; center.Z = boundbox.MaxZ + 11.0f; vizcore3d.TextDrawing.Add( center , new VIZCore3D.NET.Data.Vector3D(1, 0, 0) /* X+ 방향으로 텍스트가 표시 */ , new VIZCore3D.NET.Data.Vector3D(0, 1, 0) /* 텍스트의 위쪽 방향 : Z+에서 볼때, Y+가 위쪽 임. */ , 10000 , 100 , Color.Black , "VIZCore3D.NET" ); }
private void btnClear_Click(object sender, EventArgs e) { vizcore3d.Model.SpaceSearch.Clear(); lbCount.Text = string.Format("Count : {0} EA", vizcore3d.Model.SpaceSearch.ModelCount); VIZCore3D.NET.Data.BoundBox3D ModelBoundBox = vizcore3d.Model.SpaceSearch.GetModelBoundBox(); lbMinX.Text = "0"; lbMinY.Text = "0"; lbMinZ.Text = "0"; lbMaxX.Text = "0"; lbMaxY.Text = "0"; lbMaxZ.Text = "0"; txtCenterX.Text = "0"; txtCenterY.Text = "0"; txtCenterZ.Text = "0"; this.tbX.Scroll -= new System.EventHandler(this.tbX_Scroll); this.tbY.Scroll -= new System.EventHandler(this.tbY_Scroll); this.tbZ.Scroll -= new System.EventHandler(this.tbZ_Scroll); tbX.Minimum = tbY.Minimum = tbZ.Minimum = 0; tbX.Maximum = tbY.Maximum = tbZ.Maximum = 100; tbX.Value = tbY.Value = tbZ.Value = 50; this.tbX.Scroll += new System.EventHandler(this.tbX_Scroll); this.tbY.Scroll += new System.EventHandler(this.tbY_Scroll); this.tbZ.Scroll += new System.EventHandler(this.tbZ_Scroll); }
private void btnModelCenter_Click(object sender, EventArgs e) { VIZCore3D.NET.Data.BoundBox3D boundingBox = vizcore3d.Model.BoundBox; txtModelCenter.Text = boundingBox.GetCenter().ToString(); }
private void DrawArrow() { vizcore3d.ShapeDrawing.Clear(); if (ckEnableLine.Checked == false) { return; } List <VIZCore3D.NET.Data.Node> nodes = vizcore3d.Object3D.FromIndex(0).GetChildObject3d(VIZCore3D.NET.Data.Object3DChildOption.CHILD_ONLY); if (nodes.Count == 0) { return; } List <VIZCore3D.NET.Data.BoundBox3D> boudBox = new List <VIZCore3D.NET.Data.BoundBox3D>(); for (int i = 0; i < nodes.Count; i++) { VIZCore3D.NET.Data.Node item = nodes[i]; if (item.ChildCount == 0) { continue; } if (item.Visible == false) { continue; } VIZCore3D.NET.Data.BoundBox3D boundBox = item.GetBoundBoxAABB(); boudBox.Add(boundBox); } vizcore3d.BeginUpdate(); for (int i = 0; i < boudBox.Count; i++) { List <VIZCore3D.NET.Data.Vertex3DItemCollection> vitems = new List <VIZCore3D.NET.Data.Vertex3DItemCollection>(); VIZCore3D.NET.Data.Vertex3DItemCollection vcoll = new VIZCore3D.NET.Data.Vertex3DItemCollection(); if (i < boudBox.Count - 1) { VIZCore3D.NET.Data.BoundBox3D box1 = boudBox[i + 0]; VIZCore3D.NET.Data.BoundBox3D box2 = boudBox[i + 1]; vcoll.Add(box1.GetCenter()); vcoll.Add(box2.GetCenter()); vitems.Add(vcoll); //vizcore3d.ShapeDrawing.AddArrow(vitems, 1, Color.Black, Color.Red, 2, 10, true); //vizcore3d.ShapeDrawing.AddArrow(vitems, 1, 1000.0f, 1000.0f, Color.Black, Color.Red, 2, 10, true); vizcore3d.ShapeDrawing.AddArrow(vitems, 1, box1.MaxLength, box2.MaxLength, Color.Black, Color.Red, 2, 10, true); } } vizcore3d.EndUpdate(); }
private List <VIZCore3D.NET.Data.Vertex3DItemCollection> GetVertexList() { List <VIZCore3D.NET.Data.Vertex3DItemCollection> vertex = new List <VIZCore3D.NET.Data.Vertex3DItemCollection>(); VIZCore3D.NET.Data.BoundBox3D boundbox = vizcore3d.Object3D.GeometryProperty.FromSelectedObject3D(false).GetBoundBox(); { Data.Vertex3DItemCollection item = new VIZCore3D.NET.Data.Vertex3DItemCollection(); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MinY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MaxY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MaxY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MinY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MinY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MinY, boundbox.MaxZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MaxY, boundbox.MaxZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MaxY, boundbox.MaxZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MinY, boundbox.MaxZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MinY, boundbox.MaxZ)); vertex.Add(item); } { VIZCore3D.NET.Data.Vertex3DItemCollection item = new VIZCore3D.NET.Data.Vertex3DItemCollection(); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MaxY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MinX, boundbox.MaxY, boundbox.MaxZ)); vertex.Add(item); } { VIZCore3D.NET.Data.Vertex3DItemCollection item = new VIZCore3D.NET.Data.Vertex3DItemCollection(); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MaxY, boundbox.MinZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MaxY, boundbox.MaxZ)); vertex.Add(item); } { VIZCore3D.NET.Data.Vertex3DItemCollection item = new VIZCore3D.NET.Data.Vertex3DItemCollection(); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MinY, boundbox.MaxZ)); item.Add(new VIZCore3D.NET.Data.Vertex3D(boundbox.MaxX, boundbox.MinY, boundbox.MinZ)); vertex.Add(item); } return(vertex); }
private VIZCore3D.NET.Data.BoundBox3D GetModelBoundBox() { VIZCore3D.NET.Data.BoundBox3D ModelBoundBox = new VIZCore3D.NET.Data.BoundBox3D(); foreach (string item in Models) { VIZCore3D.NET.Data.BoundBox3D mBox = VIZCore3D.NET.Manager.ModelManager.GetModelBoundBox(item); if (mBox.ResetData == false) ModelBoundBox.Set(mBox); } return ModelBoundBox; }
private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = vizcore3d.Model.OpenFilter; dlg.Multiselect = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } Models.Clear(); foreach (string item in dlg.FileNames) { Models.Add(item); } txtContentsWidth.ReadOnly = true; txtContentsHeight.ReadOnly = true; //VIZCore3D.NET.Data.BoundBox3D boundBox = GetModelBoundBox(); //float max = boundBox.MaxLengthXY * 0.6f; //txtContentsWidth.Text = max.ToString(); //txtContentsHeight.Text = max.ToString(); float lengthX = 0.0f; float lengthY = 0.0f; int nBoundCount = 0; foreach (string item in Models) { VIZCore3D.NET.Data.BoundBox3D mBox = VIZCore3D.NET.Manager.ModelManager.GetModelBoundBox(item); lengthX = Math.Max(lengthX, mBox.LengthX); lengthY = Math.Max(lengthY, mBox.LengthY); nBoundCount++; } if (nBoundCount != 0) { txtContentsWidth.Text = Convert.ToString(lengthX + 2000.0f); txtContentsHeight.Text = Convert.ToString(lengthY + 2000.0f); } }
private void btnView_Click(object sender, EventArgs e) { if (vizcore3d.Model.IsOpen() == false) { return; } List <VIZCore3D.NET.Data.Node> items = vizcore3d.Object3D.FromFilter(Data.Object3dFilter.ALL); lvNode.BeginUpdate(); lvNode.Items.Clear(); foreach (VIZCore3D.NET.Data.Node item in items) { VIZCore3D.NET.Data.BoundBox3D boundBox = item.GetGeometryProperty(false).GetBoundBox(); int meshCount = item.GetMeshCount(); float volume = 0.0f; float average_mesh = 0; if (meshCount != -1 && meshCount != 0) { volume = boundBox.LengthX * boundBox.LengthY * boundBox.LengthZ; average_mesh = Convert.ToInt32(volume / meshCount * 0.01); } else { continue; } ListViewItem lvi = new ListViewItem( new string[] { item.ID.ToString() , item.Index.ToString() , item.NodeName , string.Format("{0:#,0}", meshCount) , string.Format("{0:#,0}", (volume * 0.001f)) , string.Format("{0:#,0}", average_mesh) , boundBox.ToString() } ); lvi.Tag = item; lvNode.Items.Add(lvi); } lvNode.EndUpdate(); }
private void SetMaterialDock() { List <Data.Node> ground = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "GROUND" }, false, true, false, false, true, false); if (ground.Count == 0) { return; } List <Data.Node> items = vizcore3d.Object3D.GetChildObject3d(ground[0].Index, Data.Object3DChildOption.CHILD_ONLY); vizcore3d.ShapeDrawing.DepthTest = true; List <int> customBox = new List <int>(); foreach (Data.Node item in items) { VIZCore3D.NET.Data.BoundBox3D boundbox = vizcore3d.Object3D.GeometryProperty.FromIndex(item.Index).GetBoundBox(); boundbox.MaxZ = boundbox.MaxZ + 10.0f; int id = vizcore3d.ShapeDrawing.AddBox( boundbox , 1 , System.Drawing.Color.Gray , true ); customBox.Add(id); } string image = @"D:\\Concrete-Texture.jpg"; if (MaterialID == -1) { MaterialID = vizcore3d.Object3D.Material.Add(image); } foreach (int item in customBox) { vizcore3d.ShapeDrawing.SetMaterial(item, MaterialID); } }
private void btnLineCenter_Click(object sender, EventArgs e) { vizcore3d.ShapeDrawing.Clear(); List <VIZCore3D.NET.Data.Node> nodes = vizcore3d.Object3D.FromIndex(0).GetChildObject3d(VIZCore3D.NET.Data.Object3DChildOption.CHILD_ONLY); if (nodes.Count == 0) { return; } List <VIZCore3D.NET.Data.Vertex3D> center = new List <VIZCore3D.NET.Data.Vertex3D>(); foreach (VIZCore3D.NET.Data.Node item in nodes) { if (item.ChildCount == 0) { continue; } if (item.Visible == false) { continue; } VIZCore3D.NET.Data.BoundBox3D boundBox = item.GetBoundBoxAABB(); center.Add(boundBox.GetCenter()); } //if (center.Count > 0) // vizcore3d.ShapeDrawing.AddVertex(center, 0, Color.Red, 3, 3, true); for (int i = 0; i < center.Count; i++) { List <VIZCore3D.NET.Data.Vertex3DItemCollection> vitems = new List <VIZCore3D.NET.Data.Vertex3DItemCollection>(); VIZCore3D.NET.Data.Vertex3DItemCollection vcoll = new VIZCore3D.NET.Data.Vertex3DItemCollection(); if (i < center.Count - 1) { vcoll.Add(center[i + 0]); vcoll.Add(center[i + 1]); vitems.Add(vcoll); vizcore3d.ShapeDrawing.AddLine(vitems, 1, Color.Red, 2, true); } } }
private void ShowFiles(string path) { string[] file = System.IO.Directory.GetFiles(path, "*.viz", System.IO.SearchOption.TopDirectoryOnly); ImageList imgList = new ImageList(); imgList.ImageSize = new Size(90, 90); lvFiles.BeginUpdate(); lvFiles.Items.Clear(); lvFiles.LargeImageList = imgList; lvFiles.SmallImageList = imgList; lvFiles.StateImageList = imgList; for (int i = 0; i < file.Length; i++) { string name = System.IO.Path.GetFileName(file[i]); string ext = System.IO.Path.GetExtension(file[i]).ToUpper(); if (ext == ".VIZXML") { continue; } System.Drawing.Image img = VIZCore3D.NET.Manager.ModelManager.GetModelThumbnail(file[i]); if (img != null) { imgList.Images.Add(name, img); } VIZCore3D.NET.Data.BoundBox3D box = VIZCore3D.NET.Manager.ModelManager.GetModelBoundBox(file[i]); ListViewItem lvi = new ListViewItem(new string[] { "", name, box.ToStringMin(), box.ToStringMax() }); if (img != null) { lvi.ImageKey = name; } lvi.Tag = file[i]; lvFiles.Items.Add(lvi); } lvFiles.EndUpdate(); }
/// <summary> /// 개체 선택 이벤트 /// </summary> /// <param name="sender">sender</param> /// <param name="e">Event Args</param> private void Object3D_OnSelectedObject3D(object sender, VIZCore3D.NET.Event.EventManager.SelectedObject3DEventArgs e) { if (e.Node.Count > 0) { // 선택된 개체가 있음 //MessageBox.Show(e.Node.Count.ToString()); if (EnableMessage == true) { vizcore3d.BeginUpdate(); Data.Object3DProperty prop = vizcore3d.Object3D.GeometryProperty.FromIndex(e.Node[0].Index, true); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_01, string.Format("Name : {0}", e.Node[0].NodeName), 5, 5, VIZCore3D.NET.Data.FontSize.Size_14_Bold, Color.Red); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_02, string.Format("Path : {0}", prop.AssemblyPath), 5, 20, VIZCore3D.NET.Data.FontSize.Size_14, Color.Orange); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_03, string.Format("Center : {0}", prop.CenterPoint.ToString()), 5, 35, VIZCore3D.NET.Data.FontSize.Size_14, Color.Yellow); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_04, string.Format("Min. : {0}", prop.MinPoint.ToString()), 5, 50, VIZCore3D.NET.Data.FontSize.Size_14, Color.Green); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_05, string.Format("Max. : {0}", prop.MaxPoint.ToString()), 5, 65, VIZCore3D.NET.Data.FontSize.Size_14, Color.Blue); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_06, string.Format("Mass : {0}", prop.Mass), 5, 80, VIZCore3D.NET.Data.FontSize.Size_14, Color.Indigo); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_07, string.Format("Area : {0}", prop.SurfaceArea), 5, 95, VIZCore3D.NET.Data.FontSize.Size_14, Color.Purple); vizcore3d.EndUpdate(); } } else { //모든 개체 선택 해제 if (EnableMessage == true) { vizcore3d.BeginUpdate(); vizcore3d.View.Message.Clear(); VIZCore3D.NET.Data.BoundBox3D bbox = vizcore3d.Model.BoundBox; vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_01, string.Format("Min. X : {0}", bbox.MinX), 5, 5, VIZCore3D.NET.Data.FontSize.Size_14, Color.Red); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_02, string.Format("Min. Y : {0}", bbox.MinY), 5, 20, VIZCore3D.NET.Data.FontSize.Size_14, Color.Orange); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_03, string.Format("Min. Z : {0}", bbox.MinZ), 5, 35, VIZCore3D.NET.Data.FontSize.Size_14, Color.Yellow); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_04, string.Format("Max. X : {0}", bbox.MaxX), 5, 50, VIZCore3D.NET.Data.FontSize.Size_14, Color.Green); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_05, string.Format("Max. Y : {0}", bbox.MaxY), 5, 65, VIZCore3D.NET.Data.FontSize.Size_14, Color.Blue); vizcore3d.View.Message.Show(VIZCore3D.NET.Data.MessageId.ID_06, string.Format("Max. Z : {0}", bbox.MaxZ), 5, 80, VIZCore3D.NET.Data.FontSize.Size_14, Color.Indigo); vizcore3d.EndUpdate(); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (vizcore3d.Model.IsOpen() == false) { return; } if (vizcore3d.Section.Sections.Count != 0) { vizcore3d.Section.Clear(); } if (rbSection.Checked == true) { if (ckMulti.Checked == false) { VIZCore3D.NET.Data.Section section = vizcore3d.Section.Add(false, Data.Axis.X); //vizcore3d.Section.Clipping = Manager.SectionManager.ClippingTypes.ONE_WAY_CLIPPING; //vizcore3d.View.MoveCamera(Data.CameraDirection.X_MINUS); } else { float offset = Convert.ToSingle(txtOffset.Text); VIZCore3D.NET.Data.BoundBox3D boundBox = vizcore3d.Model.BoundBox; float length = boundBox.LengthX; float unit = length / offset; vizcore3d.BeginUpdate(); for (int i = 1; i < Convert.ToInt32(unit); i++) { VIZCore3D.NET.Data.Section section = vizcore3d.Section.Add(false, Data.Axis.X); float[] pos = vizcore3d.Section.GetCenterPosition(section.ID, -1); vizcore3d.Section.SetCenterPosition(section.ID, -1, boundBox.MinX + (offset * i), pos[1], pos[2]); } vizcore3d.EndUpdate(); } } else if (rbSectionBox.Checked == true) { VIZCore3D.NET.Data.Section section = vizcore3d.Section.AddBox(false, 0); } DrawLine(); }
private void btnGetZoneObjects_Click(object sender, EventArgs e) { if (SelectionBoxID == -1) { return; } if (cbFilter.SelectedIndex == -1) { return; } VIZCore3D.NET.Data.BoundBox3D box = vizcore3d.SelectionBox.GetItem(SelectionBoxID).BoundBox; VIZCore3D.NET.Data.BoundBoxSearchOption option = (Data.BoundBoxSearchOption)cbFilter.SelectedIndex; List <VIZCore3D.NET.Data.Node> items = vizcore3d.Object3D.FromZone(box, option); dataGridNode.DataSource = items; gbObjects.Text = string.Format("Objects - {0:N0}", items.Count); }
// ================================================ // Bounding Box // ================================================ private void btnBoxAdd_Click(object sender, EventArgs e) { if (vizcore3dMain.Model.IsOpen() == false) { return; } vizcore3dMain.SelectionBox.Clear(); BoxKey = new Dictionary <int, string>(); int xCount = Convert.ToInt32(txtBoxX.Text); int yCount = Convert.ToInt32(txtBoxY.Text); int zCount = Convert.ToInt32(txtBoxZ.Text); VIZCore3D.NET.Data.BoundBox3D box = vizcore3dMain.Model.BoundBox; float xWidth = box.LengthX / xCount; float yWidth = box.LengthY / yCount; float zWidth = box.LengthZ / zCount; vizcore3dMain.BeginUpdate(); for (int x = 0; x < xCount; x++) { for (int y = 0; y < yCount; y++) { for (int z = 0; z < zCount; z++) { string title = string.Format("선택상자 - {0}/{1}/{2}", x + 1, y + 1, z + 1); string label = string.Format("{0}/{1}/{2}", x + 1, y + 1, z + 1); VIZCore3D.NET.Data.Vertex3D min = new Data.Vertex3D( box.MinX + (xWidth * x) , box.MinY + (yWidth * y) , box.MinZ + (zWidth * z) ); VIZCore3D.NET.Data.Vertex3D max = new Data.Vertex3D( min.X + xWidth , min.Y + yWidth , min.Z + zWidth ); VIZCore3D.NET.Data.BoundBox3D selectionbox = new Data.BoundBox3D(min, max); int id = vizcore3dMain.SelectionBox.Add( selectionbox , Color.FromArgb(10, Color.White) , Color.Black , title ); //vizcore3dMain.SelectionBox.SetLabel(id, label); BoxKey.Add(id, string.Format("{0}-{1}-{2}", x + 1, y + 1, z + 1)); } // z } // y } // x vizcore3dMain.EndUpdate(); CreateGridView(); }
private void btnApply_Click(object sender, EventArgs e) { InitModelTransform(); vizcore3d.View.EnableAnimation = false; //vizcore3d.View.Projection = VIZCore3D.NET.Data.Projections.Perspective; //vizcore3d.View.FitToView(); vizcore3d.View.FOV = 74.0f; // 45 ~ 74 float height = Convert.ToSingle(txtHeight.Text) * 1000.0f; float distance = 1000.0f; if (rbDistance10.Checked == true) { distance *= 10; } else if (rbDistance13.Checked == true) { distance *= 13; } else if (rbDistance16.Checked == true) { distance *= 16; } else if (rbDistance19.Checked == true) { distance *= 19; } else if (rbDistance25.Checked == true) { distance *= 25; } float angle = 0.0f; if (rbAngle42.Checked == true) { angle = 42.6f; } if (rbAngle38.Checked == true) { angle = 38.4f; } if (rbAngle35.Checked == true) { angle = 35.6f; } if (rbAngle33.Checked == true) { angle = 33.7f; } if (rbAngle30.Checked == true) { angle = 30.1f; } int transform = Convert.ToInt32(cbTransform.Text); /* * // Camera Position * VIZCore3D.NET.Data.Vertex3D v = new VIZCore3D.NET.Data.Vertex3D(0, distance, height); * * // Move Camera * vizcore3d.View.MoveCamera(v, 0.0f, false); * * // Rotate Camera * vizcore3d.View.RotateCameraByAxis( * VIZCore3D.NET.Data.BaseAxis.WORLD * , VIZCore3D.NET.Data.Axis.X * , VIZCore3D.NET.Data.Directions.PLUS * , angle); * * // Rotate Model * vizcore3d.Object3D.Transform.Rotate(new List<int>() { 0 }, 0, 0, transform, true, false); */ // Camera Position VIZCore3D.NET.Data.Vector3D camera = vizcore3d.View.GetCameraEyePosition(); // Model Center VIZCore3D.NET.Data.BoundBox3D boundBox = vizcore3d.Model.BoundBox; VIZCore3D.NET.Data.Vertex3D position = new VIZCore3D.NET.Data.Vertex3D( camera.X , camera.Y - distance , camera.Z - (boundBox.LengthZ * 0.5f) - height //, boundBox.MinZ - height ); vizcore3d.Object3D.Transform.MoveTo( new List <int>() { 0 } , position ); // Rotate Camera /* * vizcore3d.View.RotateCameraByAxis( * VIZCore3D.NET.Data.BaseAxis.LOCAL * , VIZCore3D.NET.Data.Axis.X * , VIZCore3D.NET.Data.Directions.MINUS * , angle); */ //vizcore3d.View.RotateCameraByAxis( // VIZCore3D.NET.Data.BaseAxis.WORLD // , VIZCore3D.NET.Data.Axis.X // , VIZCore3D.NET.Data.Directions.PLUS // , angle); //vizcore3d.View.RotateCameraByScreenAxis(-angle, 0, 0); // Rotate Model vizcore3d.Object3D.Transform.Rotate(new List <int>() { 0 }, 0, 0, -transform, true, false); }
private void PlaceModel() { vizcore3d.BeginUpdate(); int contentsColumn = Convert.ToInt32(txtContentsColumn.Text); // 4.0f; int contentsRow = Convert.ToInt32(txtContentsRow.Text); // 5.0f; int count = contentsColumn * contentsRow; if (Models.Count < count) { vizcore3d.Model.Add(Models); } else { List <string> subModel = new List <string>(); for (int i = 0; i < count; i++) { subModel.Add(Models[i]); } vizcore3d.Model.Add(subModel); Models = subModel; } for (int i = 0; i < count; i++) { if (Models.Count - 1 < i) { continue; } // MODEL NAME string name = System.IO.Path.GetFileNameWithoutExtension(Models[i]).ToUpper(); // MODEL BOUNDBOX VIZCore3D.NET.Data.BoundBox3D boundBox = VIZCore3D.NET.Manager.ModelManager.GetModelBoundBox(Models[i]); List <VIZCore3D.NET.Data.Node> node = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { name }, false, true, false, false, true, false); if (node.Count == 0) { continue; } string spaceName = string.Format("MODEL_{0:D2}", i + 1); if (SpaceManager.ContainsKey(spaceName) == false) { continue; } VIZCore3D.NET.Data.BoundBox3D modelBoundBox = SpaceManager[spaceName]; vizcore3d.Object3D.Transform.Move( new int[] { node[0].Index } , modelBoundBox.CenterX - boundBox.CenterX , modelBoundBox.CenterY - boundBox.CenterY , modelBoundBox.CenterZ - boundBox.CenterZ + (ckModelISO.Checked == false ? boundBox.LengthZ * 0.5f : boundBox.LengthZ * 3.0f) , false ); if (ckModelISO.Checked == true) { vizcore3d.Object3D.Select(node, true); vizcore3d.Object3D.Transform.Rotate( new VIZCore3D.NET.Data.Vertex3D(50.0f, -40.0f, -30.0f) , true ); vizcore3d.Object3D.Select(node, false); } } vizcore3d.View.MoveCamera(VIZCore3D.NET.Data.CameraDirection.Z_PLUS); vizcore3d.View.Navigation = VIZCore3D.NET.Data.NavigationModes.PAN; vizcore3d.View.SetRenderMode(VIZCore3D.NET.Data.RenderModes.SMOOTH_EDGE); vizcore3d.EndUpdate(); vizcore3d.View.FitToView(); }
private void MakeDashboard() { float contentsColumn = Convert.ToSingle(txtContentsColumn.Text); // 4.0f; float contentsRow = Convert.ToSingle(txtContentsRow.Text); // 5.0f; float titleHeight = Convert.ToSingle(txtTitleHeight.Text); // 3000.0f; float subTitleHeight = Convert.ToSingle(txtSubTitleHeight.Text); // 2000.0f; float contentsWidth = Convert.ToSingle(txtContentsWidth.Text); // 15000.0f; float contentsHeight = Convert.ToSingle(txtContentsHeight.Text); // 15000.0f; vizcore3d.Model.Close(); SpaceManager.Clear(); VIZCore3D.NET.Manager.PrimitiveObject root = vizcore3d.Primitive.AddNode("DASHBOARD"); VIZCore3D.NET.Manager.PrimitiveObject title = root.AddNode("TITLE", 3); { VIZCore3D.NET.Manager.PrimitiveBox box = new VIZCore3D.NET.Manager.PrimitiveBox(); VIZCore3D.NET.Data.Vertex3D min = new VIZCore3D.NET.Data.Vertex3D(0, 0, -500); VIZCore3D.NET.Data.Vertex3D max = new VIZCore3D.NET.Data.Vertex3D(contentsColumn * contentsWidth, -titleHeight, 0); VIZCore3D.NET.Data.BoundBox3D boundbox = new VIZCore3D.NET.Data.BoundBox3D(min, max); SpaceManager.Add("TITLE", boundbox); box.SetMinMaxPoints(boundbox); title.AddPrimitive(box); } VIZCore3D.NET.Manager.PrimitiveObject contents = root.AddNode("CONTENTS", 10); VIZCore3D.NET.Manager.PrimitiveObject group = contents.AddNode("GROUP", 4); VIZCore3D.NET.Manager.PrimitiveObject model = contents.AddNode("MODEL", 10); { int ID = 1; for (int i = 0; i < contentsRow; i++) { for (int j = 0; j < contentsColumn; j++) { { VIZCore3D.NET.Manager.PrimitiveObject groupItem = group.AddNode(string.Format("GROUP_{0:D2}", ID), 4); // Title VIZCore3D.NET.Manager.PrimitiveBox groupTitleBox = new Manager.PrimitiveBox(); VIZCore3D.NET.Data.Vertex3D min = new VIZCore3D.NET.Data.Vertex3D( j * contentsWidth , -titleHeight - (i * (subTitleHeight + contentsHeight)) , -500 ); VIZCore3D.NET.Data.Vertex3D max = new VIZCore3D.NET.Data.Vertex3D( (j + 1) * contentsWidth , -titleHeight - (i * (subTitleHeight + contentsHeight)) - subTitleHeight , 0 ); VIZCore3D.NET.Data.BoundBox3D groupBoundBox = new VIZCore3D.NET.Data.BoundBox3D(min, max); SpaceManager.Add(string.Format("GROUP_{0:D2}", ID), groupBoundBox); groupTitleBox.SetMinMaxPoints(groupBoundBox); groupItem.AddPrimitive(groupTitleBox); } { VIZCore3D.NET.Manager.PrimitiveObject modelItem = model.AddNode(string.Format("MODEL_{0:D2}", ID), 10); // Thumbnail VIZCore3D.NET.Manager.PrimitiveBox thumbnailBox = new VIZCore3D.NET.Manager.PrimitiveBox(); VIZCore3D.NET.Data.Vertex3D min = new VIZCore3D.NET.Data.Vertex3D( j * contentsWidth , -titleHeight - (i * (subTitleHeight + contentsHeight)) - subTitleHeight , -500 ); VIZCore3D.NET.Data.Vertex3D max = new VIZCore3D.NET.Data.Vertex3D( (j + 1) * contentsWidth , -titleHeight - ((i + 1) * (subTitleHeight + contentsHeight)) , 0 ); VIZCore3D.NET.Data.BoundBox3D thumbnailBoundBox = new VIZCore3D.NET.Data.BoundBox3D(min, max); SpaceManager.Add(string.Format("MODEL_{0:D2}", ID), thumbnailBoundBox); thumbnailBox.SetMinMaxPoints(thumbnailBoundBox); modelItem.AddPrimitive(thumbnailBox); } ID++; } } } { vizcore3d.TextDrawing.Clear(); { VIZCore3D.NET.Data.BoundBox3D boundbox = SpaceManager["TITLE"]; VIZCore3D.NET.Data.Vertex3D center = new VIZCore3D.NET.Data.Vertex3D(); center.X = boundbox.MinX + (boundbox.LengthX * 0.5f); center.Y = boundbox.MinY + (boundbox.LengthY * 0.5f); center.Z = boundbox.MaxZ; vizcore3d.TextDrawing.Add( center , new VIZCore3D.NET.Data.Vertex3D(1, 0, 0) /* X+ 방향으로 텍스트가 표시 */ , new VIZCore3D.NET.Data.Vertex3D(0, 1, 0) /* 텍스트의 위쪽 방향 : Z+에서 볼때, Y+가 위쪽 임. */ , 2000 , Color.Black , txtTitle.Text ); } { foreach (KeyValuePair <string, Data.BoundBox3D> item in SpaceManager) { if (item.Key.Contains("GROUP_") == false) { continue; } VIZCore3D.NET.Data.Vertex3D center = new VIZCore3D.NET.Data.Vertex3D(); center.X = item.Value.MinX + (contentsWidth * 0.5f); center.Y = item.Value.MinY + (item.Value.LengthY * 0.5f); center.Z = item.Value.MaxZ; vizcore3d.TextDrawing.Add( center , new VIZCore3D.NET.Data.Vertex3D(1, 0, 0) /* X+ 방향으로 텍스트가 표시 */ , new VIZCore3D.NET.Data.Vertex3D(0, 1, 0) /* 텍스트의 위쪽 방향 : Z+에서 볼때, Y+가 위쪽 임. */ , 1000 , Color.Black , item.Key.Replace("GROUP", "MODEL") ); } } } vizcore3d.Primitive.OpenModel("BAY_BLOCK"); if (Models.Count != 0) { PlaceModel(); } else { vizcore3d.View.MoveCamera(VIZCore3D.NET.Data.CameraDirection.Z_PLUS); vizcore3d.View.Navigation = VIZCore3D.NET.Data.NavigationModes.PAN; vizcore3d.View.SetRenderMode(VIZCore3D.NET.Data.RenderModes.SMOOTH_EDGE); vizcore3d.View.FitToView(); } }
private void btnCreate_Click(object sender, EventArgs e) { if (vizcore3d.Model.IsOpen() == false) { return; } vizcore3d.SelectionBox.Clear(); int xCount = Convert.ToInt32(txtCountX.Text); int yCount = Convert.ToInt32(txtCountY.Text); int zCount = Convert.ToInt32(txtCountZ.Text); VIZCore3D.NET.Data.BoundBox3D box = vizcore3d.Model.BoundBox; float xWidth = box.LengthX / xCount; float yWidth = box.LengthY / yCount; float zWidth = box.LengthZ / zCount; vizcore3d.BeginUpdate(); for (int x = 0; x < xCount; x++) { for (int y = 0; y < yCount; y++) { for (int z = 0; z < zCount; z++) { string title = string.Format("선택상자 - {0}/{1}/{2}", x + 1, y + 1, z + 1); string label = string.Format("{0}/{1}/{2}", x + 1, y + 1, z + 1); VIZCore3D.NET.Data.Vertex3D min = new Data.Vertex3D( box.MinX + (xWidth * x) , box.MinY + (yWidth * y) , box.MinZ + (zWidth * z) ); VIZCore3D.NET.Data.Vertex3D max = new Data.Vertex3D( min.X + xWidth , min.Y + yWidth , min.Z + zWidth ); VIZCore3D.NET.Data.BoundBox3D selectionbox = new Data.BoundBox3D(min, max); int id = vizcore3d.SelectionBox.Add( selectionbox , GetTransparencyColor(Color.FromArgb(100, 255, 255, 255)) , GetTransparencyColor(Color.Black) , title ); vizcore3d.SelectionBox.SetLabel(id, label); } // z } // y } // x vizcore3d.EndUpdate(); vizcore3d.SelectionBox.MouseSelectionMode = true; }
private void Object3D_OnObject3DSelected(object sender, Event.EventManager.Object3DSelectedEventArgs e) { if (e.Node.Count == 0) { txtNodeIndex.Text = String.Empty; btnNodeColor.BackColor = Color.FromKnownColor(KnownColor.Control); txtBodyIndex.Text = String.Empty; btnBodyColor.BackColor = Color.FromKnownColor(KnownColor.Control); txtLengthXCube.Text = String.Empty; txtLengthYCube.Text = String.Empty; txtLengthZCube.Text = String.Empty; txtMatrix11.Text = "1"; txtMatrix12.Text = "0"; txtMatrix13.Text = "0"; txtMatrix41.Text = "0"; txtMatrix21.Text = "0"; txtMatrix22.Text = "1"; txtMatrix23.Text = "0"; txtMatrix42.Text = "0"; txtMatrix31.Text = "0"; txtMatrix32.Text = "0"; txtMatrix33.Text = "1"; txtMatrix43.Text = "0"; } else { txtNodeIndex.Text = e.Node[0].Index.ToString(); btnNodeColor.BackColor = vizcore3d.Object3D.Color.GetColor(e.Node[0].Index); txtBodyIndex.Text = Convert.ToString(e.Node[0].Index + 1); btnBodyColor.BackColor = vizcore3d.Object3D.Color.GetColor(e.Node[0].Index); VIZCore3D.NET.Data.BoundBox3D boundBox = e.Node[0].GetGeometryProperty().GetBoundBox(); txtLengthXCube.Text = boundBox.LengthX.ToString(); txtLengthYCube.Text = boundBox.LengthY.ToString(); txtLengthZCube.Text = boundBox.LengthZ.ToString(); if (rbCylinderXAxis.Checked == true) { txtCylinderRadius.Text = Convert.ToString(boundBox.LengthZ * 0.5f); } else if (rbCylinderYAxis.Checked == true) { txtCylinderRadius.Text = Convert.ToString(boundBox.LengthX * 0.5f); } else if (rbCylinderZAxis.Checked == true) { txtCylinderRadius.Text = Convert.ToString(boundBox.LengthY * 0.5f); } if (tabPrimitive.SelectedIndex == 0) { txtMatrix11.Text = "1"; txtMatrix12.Text = "0"; txtMatrix13.Text = "0"; txtMatrix21.Text = "0"; txtMatrix22.Text = "1"; txtMatrix23.Text = "0"; txtMatrix31.Text = "0"; txtMatrix32.Text = "0"; txtMatrix33.Text = "1"; txtMatrix41.Text = boundBox.CenterX.ToString(); txtMatrix42.Text = boundBox.CenterY.ToString(); txtMatrix43.Text = boundBox.CenterZ.ToString(); } else if (tabPrimitive.SelectedIndex == 1) { VIZCore3D.NET.Data.Vertex3D cyliCenter = new Data.Vertex3D( boundBox.CenterX , boundBox.CenterY , boundBox.CenterZ ); VIZCore3D.NET.Data.Vertex3D min = cyliCenter.Clone(); VIZCore3D.NET.Data.Vertex3D max = cyliCenter.Clone(); if (rbCylinderXAxis.Checked == true) { min.X = boundBox.MinX; max.X = boundBox.MaxX; txtCylinderHeight.Text = boundBox.LengthX.ToString(); } else if (rbCylinderYAxis.Checked == true) { min.Y = boundBox.MinY; max.Y = boundBox.MaxY; txtCylinderHeight.Text = boundBox.LengthY.ToString(); } else if (rbCylinderZAxis.Checked == true) { min.Z = boundBox.MinZ; max.Z = boundBox.MaxZ; txtCylinderHeight.Text = boundBox.LengthZ.ToString(); } VIZCore3D.NET.Manager.PrimitiveCylinder cyli = new Manager.PrimitiveCylinder(); cyli.Set2Point(min, max, Convert.ToSingle(txtCylinderRadius.Text)); txtMatrix11.Text = cyli.Matrix[0].ToString(); txtMatrix12.Text = cyli.Matrix[1].ToString(); txtMatrix13.Text = cyli.Matrix[2].ToString(); txtMatrix21.Text = cyli.Matrix[4].ToString(); txtMatrix22.Text = cyli.Matrix[5].ToString(); txtMatrix23.Text = cyli.Matrix[6].ToString(); txtMatrix31.Text = cyli.Matrix[8].ToString(); txtMatrix32.Text = cyli.Matrix[9].ToString(); txtMatrix33.Text = cyli.Matrix[10].ToString(); txtMatrix41.Text = cyli.Matrix[3].ToString(); txtMatrix42.Text = cyli.Matrix[7].ToString(); txtMatrix43.Text = cyli.Matrix[11].ToString(); } } }
private void CreateGridView() { vizcore3dGrid.BeginUpdate(); int rootIndex = vizcore3dGrid.Model.NewEmptyModel("GRID"); int xCount = Convert.ToInt32(txtBoxX.Text); int yCount = Convert.ToInt32(txtBoxY.Text); int zCount = Convert.ToInt32(txtBoxZ.Text); VIZCore3D.NET.Data.BoundBox3D box = vizcore3dMain.Model.BoundBox; float xWidth = box.LengthX / xCount; float yWidth = box.LengthY / yCount; float zWidth = box.LengthZ / zCount; for (int z = zCount; z > 0; z--) { string assemblyName = string.Format("Z-AXIS-#{0}", z); VIZCore3D.NET.Data.Node assemblyNode = vizcore3dGrid.Structure.CreateNode( rootIndex /* Parent Node Index */ , VIZCore3D.NET.Data.NodeKind.ASSEMBLY /* Node Kind */ , assemblyName /* Node Name */ ); foreach (KeyValuePair <int, string> item in BoxKey) { string zLabel = item.Value.Substring(item.Value.Length - 1); if (zLabel != z.ToString()) { continue; } string partName = item.Value; VIZCore3D.NET.Data.Node partNode = vizcore3dGrid.Structure.CreateNode( assemblyNode.Index /* Parent Node Index */ , VIZCore3D.NET.Data.NodeKind.PART /* Node Kind */ , partName /* Node Name */ ); string bodyName = string.Format("BODY-{0}", item.Value); int bodyId = vizcore3dGrid.Structure.CreateBody( partNode.Index /* Parent Node Index */ , bodyName /* Node Name */ ); int bodyIndex = vizcore3dGrid.Object3D.GetBodyIndex(bodyId); VIZCore3D.NET.Data.SelectionBox selectionBox = vizcore3dMain.SelectionBox.GetItem(item.Key); List <float> length = new List <float>() { selectionBox.BoundBox.LengthX , selectionBox.BoundBox.LengthY , selectionBox.BoundBox.LengthZ }; VIZCore3D.NET.Data.Matrix3D matrix = new VIZCore3D.NET.Data.Matrix3D(); matrix.SetTranslate(selectionBox.BoundBox.GetCenter().ToVector3D()); vizcore3dGrid.MeshEdit.AddPrimitiveBox( bodyIndex /* Body Node Index */ , length /* Length */ , matrix /* Matrix */ , Color.White /* Color */ , false /* Rebuild Data */ ); } } vizcore3dGrid.Structure.RebuildData(); vizcore3dGrid.View.SilhouetteEdge = true; vizcore3dGrid.View.XRay.Enable = true; vizcore3dGrid.View.ResetView(); vizcore3dGrid.EndUpdate(); }