Sample
단면으로 클리핑된 부재의 Edge 데이터 목록 반환
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
VIZCore3D.NET.Data.Section section = vizcore3d.Section.SelectedItem;
if (section == null) return;
if (section.SectionType
== VIZCore3D.NET.Manager.SectionManager.SectionTypes.SECTION)
{
VIZCore3D.NET.Data.SectionPlaneEdgeCollection items
= vizcore3d.Section.GetClippedEdge(section.ID, -1);
foreach (VIZCore3D.NET.Data.SectionPlaneEdge edge in items)
{
System.Diagnostics.Trace.WriteLine(
string.Format(
"P1:{0}, P2:{1}, C:{2}"
, edge.Postion1.ToString()
, edge.Postion2.ToString()
, edge.Color.ToArgb().ToString()
)
);
}
}
else if (section.SectionType
== VIZCore3D.NET.Manager.SectionManager.SectionTypes.SECTION_BOX)
{
for (int i = 0; i < 6; i++)
{
VIZCore3D.NET.Data.SectionPlaneEdgeCollection items
= vizcore3d.Section.GetClippedEdge(section.ID, i);
foreach (VIZCore3D.NET.Data.SectionPlaneEdge edge in items)
{
System.Diagnostics.Trace.WriteLine(
string.Format(
"P1:{0}, P2:{1}, C:{2}"
, edge.Postion1.ToString()
, edge.Postion2.ToString()
, edge.Color.ToArgb().ToString()
)
);
}
}
}
}
Toolbar 메뉴 클릭 이벤트 추가
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
// Add Event
vizcore3d.OnToolbarItemClicked += VIZCore3D_OnToolbarItemClicked;
}
private void VIZCore3D_OnToolbarItemClicked(object sender, Event.ToolbarItemClickedEventArgs e)
{
if(e.Item == VIZCore3D.NET.Data.ToolbarItems.MAIN_SAVE_VIZ
|| e.Item == VIZCore3D.NET.Data.ToolbarItems.MAIN_SAVEAS_VIZ)
{
// Disable Menu :: Save
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
Sky, Sea 렌더링 개선
private void btnSetMaterialSea_Click(object sender, EventArgs e)
{
vizcore3d.BeginUpdate();
Data.BoundBox3D boundbox = vizcore3d.Model.BoundBox;
// SEA(바다) 커스텀 개체 추가
int customSeaId = vizcore3d.ShapeDrawing.AddSea(
boundbox.MinZ - 10.0f /* 높이 : Z축 */
, true /* Visible */
);
// 기본 리소스 (SEA Material) 복사
int material = vizcore3d.Object3D.Material.Copy(VIZCore3D.NET.Data.ResourceMaterials.SEA);
Color color = Color.FromArgb(127, 255, 255, 255);
// 리소스 색상 변경
vizcore3d.Object3D.Material.SetColor(material, color);
// 수정된 리소스 (Material) 를 기존 커스텀 개체에 지정
vizcore3d.ShapeDrawing.SetMaterial(customSeaId, material);
vizcore3d.EndUpdate();
}
private void btnSky_Click(object sender, EventArgs e)
{
vizcore3d.View.EnableSkyBox = true;
}
두 부재의 공유 Surface의 Normal Vector 반환 API
private void btnGetNormalVector_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(txtPart1.Text) == true) return;
if (String.IsNullOrEmpty(txtPart2.Text) == true) return;
VIZCore3D.NET.Data.ConnectedSurfaceNormalVectorItem item
= vizcore3d.GeometryUtility.GetConnectedSurfaceNormalVector(
Convert.ToInt32(txtPart1.Text)
, Convert.ToInt32(txtPart2.Text)
);
AddResult(item, true, false);
txtPart1.Text = String.Empty;
txtPart2.Text = String.Empty;
}
private void btnReset_Click(object sender, EventArgs e)
{
txtPart1.Text = String.Empty;
txtPart2.Text = String.Empty;
}
private void AddResult(VIZCore3D.NET.Data.ConnectedSurfaceNormalVectorItem item, bool note, bool nv)
{
VIZCore3D.NET.Data.Node node1 = vizcore3d.Object3D.FromIndex(item.Index1);
VIZCore3D.NET.Data.Node node2 = vizcore3d.Object3D.FromIndex(item.Index2);
string no = Convert.ToString(lvResult.Items.Count + 1);
ListViewItem lvi = new ListViewItem(
new string[]
{
no
, node1.Index.ToString()
, node2.Index.ToString()
, node1.NodeName
, node2.NodeName
, item.Normal.ToString()
, item.Projection1.ToString()
, item.Projection2.ToString()
}
);
lvi.Tag = item;
if (item.Normal.Z > 0)
lvi.BackColor = Color.Yellow;
lvResult.Items.Add(lvi);
if (note == true)
{
VIZCore3D.NET.Data.MultiColorText text = new Data.MultiColorText();
text.AddLine(string.Format("NO. : {0}", no), Color.Purple);
text.AddLine(string.Format("NODE #1 : {0}", node1.NodeName), Color.Black);
text.AddLine(string.Format("NODE #2 : {0}", node2.NodeName), Color.Blue);
text.AddLine(string.Format("N/V : {0}", item.Normal.ToString()), Color.Red);
VIZCore3D.NET.Data.Vertex3D pos
= new VIZCore3D.NET.Data.Vertex3D(
item.Projection1.X + 500
, item.Projection1.Y + 500
, item.Projection1.Z + 3500
);
vizcore3d.Review.Note.AddNoteSurface(text, pos, item.Projection1);
}
if(nv == true)
{
if (Convert.ToInt32(item.Normal.X) != 0
|| Convert.ToInt32(item.Normal.Y) != 0
|| Convert.ToInt32(item.Normal.Z) != 0) return;
vizcore3d.ShapeDrawing.AddVertex(
new List<VIZCore3D.NET.Data.Vertex3D>()
{
item.TestPosition
}
, 0
, Color.Blue
, 10
, 10
, true
);
}
}
개체 분해 시, 크기 비율에 따른 자동 분해 API
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
AddGroup(0);
DisassemblyByRate(0.5f);
}
private void AddGroup(int groupKind)
{
int index = groupKind;
List<VIZCore3D.NET.Data.Node> items = null;
if (index == 0) // Children of Root
{
items = vizcore3d.Object3D.GetChildObject3d(
0 /* Root Node Index */
, VIZCore3D.NET.Data.Object3DChildOption.CHILD_ONLY /* Sub Node */
);
}
else if (index == 1) // Part (Leaf Node)
{
items = vizcore3d.Object3D.FromFilter(Data.Object3dFilter.PART);
}
else if (index == 2) // Leaf Assembly
{
items = vizcore3d.Object3D.FromFilter(Data.Object3dFilter.LEAF_ASSEMBLY);
}
else if (index == 3) // Parent of Leaf Assembly
{
items = vizcore3d.Object3D.FromFilter(Data.Object3dFilter.PARENT_LEAF_ASSEMBLY);
}
if (items == null) return;
for (int i = 0; i < items.Count; i++)
{
bool result = vizcore3d.Object3D.Disassembly.AddGroup(
i /* ID : 0 ~ */
, items[i].Index /* NODE INDEX */
, true /* Recursive */
);
}
}
private void DisassemblyByRate(float rate)
{
vizcore3d.Object3D.Disassembly.DisassembleBySphereCenterDistanceRate(true, rate);
}
Frame (SHIPGRID) 에서 Offset으로 위치 조회 시, 소수점 이하 연산에서 발생할 수 있는 오류 수정
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
if (vizcore3d.Model.IsOpen() == false) return;
if (vizcore3d.Frame.HasFrame == false) return;
VIZCore3D.NET.Data.FramePosition framePt
= vizcore3d.Frame.GetPosition(Data.Axis.X, "FR", 10, -0.12f);
if (framePt.ValidData == true)
MessageBox.Show(framePt.Position.ToString());
}
Brewer Palettes Color 지원용 Utility 클래스를 활용하여 색상 변경
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
int root = 0;
List<VIZCore3D.NET.Data.Node> nodes =
vizcore3d.Object3D.FromIndex(root)
.GetChildObject3d(VIZCore3D.NET.Data.Object3DChildOption.CHILD_ONLY);
if (nodes.Count == 0) return;
VIZCore3D.NET.Utility.ColorBrewerPalettesHelper color
= new VIZCore3D.NET.Utility.ColorBrewerPalettesHelper();
vizcore3d.BeginUpdate();
for (int i = 0; i < nodes.Count; i++)
{
VIZCore3D.NET.Data.Node node = nodes[i];
vizcore3d.Object3D.Color.SetColor(
new List<VIZCore3D.NET.Data.Node>() { node }
, color.GetPaletteColor(i)
);
}
vizcore3d.EndUpdate();
}
Frame (SHIP GRID) XML 파일 형식
<?xml version="1.0" encoding="utf-8"?>
<Frame>
<Grid Axis="X" Name="FR">
<Item ID="0" Offset="0"/>
<Item ID="1" Offset="1000"/>
<Item ID="2" Offset="2000"/>
<Item ID="3" Offset="3000"/>
<Item ID="4" Offset="4000"/>
</Grid>
<Grid Axis="Y" Name="LP">
<Item ID="0" Offset="0"/>
<Item ID="1" Offset="1000"/>
<Item ID="2" Offset="2000"/>
<Item ID="3" Offset="3000"/>
<Item ID="4" Offset="4000"/>
</Grid>
<Grid Axis="Z" Name="LP">
<Item ID="0" Offset="0"/>
<Item ID="1" Offset="1000"/>
<Item ID="2" Offset="2000"/>
<Item ID="3" Offset="3000"/>
<Item ID="4" Offset="4000"/>
</Grid>
</Frame>
측정 오스냅(Object snap) 색상 변경 API
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
VIZCore3D.NET.Data.MeasureStyle style =
vizcore3d.Review.Measure.GetStyle();
style.OsnapColor = Color.Red;
style.OsnapPreselectColor = Color.Blue;
style.OsnapPreselectEdgeColor = Color.Yellow;
vizcore3d.Review.Measure.SetStyle(style);
}
두 개의 라인을 이루는 4개의 정점이 평행하게 배치 할 수 있는 Matrix 계산
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
// 이동되어야 할 라인
VIZCore3D.NET.Data.Vertex3D v1
= new VIZCore3D.NET.Data.Vertex3D(-24.85, 254.20, 500);
VIZCore3D.NET.Data.Vertex3D v2
= new VIZCore3D.NET.Data.Vertex3D(-450, -650, 500);
// 고정 라인
VIZCore3D.NET.Data.Vertex3D v3
= new VIZCore3D.NET.Data.Vertex3D(500, 500, 500);
VIZCore3D.NET.Data.Vertex3D v4
= new VIZCore3D.NET.Data.Vertex3D(500, -500, 500);
// 이동 및 회전 매트릭스 계산
VIZCore3D.NET.Data.Matrix3D matrix
= vizcore3d.GeometryUtility.GetMatrixToMoveTo2PointParallelTo2Point(
v1 /* 이동될 라인 시작점 */
, v2 /* 이동될 라인 끝점 */
, v3 /* 기준선 라인 시작점 */
, v4 /* 기준선 라인 끝점 */
, 1000.0f /* 오프셋 */
);
// 이동될 라인을 포함한 부재 검색
List<VIZCore3D.NET.Data.Node> nodes = vizcore3d.Object3D.Find.QuickSearch("BOX2", true);
if (nodes.Count == 0) return;
// 부재 이동 및 회전
nodes[0].TrasformByRawMatrix(matrix);
}
화살표 그리기 함수 추가
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example1(VIZCore3D.NET.Data.Node blk1, VIZCore3D.NET.Data.Node blk2)
{
List<VIZCore3D.NET.Data.Vertex3DItemCollection> items
= new List<VIZCore3D.NET.Data.Vertex3DItemCollection>();
VIZCore3D.NET.Data.Vertex3DItemCollection collection
= new VIZCore3D.NET.Data.Vertex3DItemCollection();
collection.Add(blk1.GetCenter());
collection.Add(blk2.GetCenter());
items.Add(collection);
int groupId = 1;
float thickness = 1.0f;
float arrowSize = 3.0f;
int arrowId = vizcore3d.ShapeDrawing.AddArrow(
items
, groupId
, Color.Black
, Color.Red
, thickness
, arrowSize
, true
);
}
private void Example2(VIZCore3D.NET.Data.Node blk1, VIZCore3D.NET.Data.Node blk2)
{
List<VIZCore3D.NET.Data.Vertex3DItemCollection> items
= new List<VIZCore3D.NET.Data.Vertex3DItemCollection>();
VIZCore3D.NET.Data.Vertex3DItemCollection collection
= new VIZCore3D.NET.Data.Vertex3DItemCollection();
collection.Add(blk1.GetCenter());
collection.Add(blk2.GetCenter());
items.Add(collection);
int groupId = 1;
float thickness = 1.0f;
float arrowSize = 3.0f;
int arrowId = vizcore3d.ShapeDrawing.AddArrow(
items
, groupId
, 1000.0f
, 1000.0f
, Color.Black
, Color.Red
, thickness
, arrowSize
, true
);
}