Sample
Panorama - Add Custom Object (Poly Line)
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example1()
{
List<Data.Vertex3D> position1 = new List<Data.Vertex3D>();
for (int i = 0; i <= 360; i += 10)
{
float fAngleX = i;
float fAngleY = 0;
position1.Add(new Data.Vertex3D(fAngleX, fAngleY, 0.0f));
}
vizcore3d.Panorama.CustomObject.AddPolyLine(position1, Color.Red, 1.0f);
}
private void Example2()
{
List<Data.Vertex3D> position1 = new List<Data.Vertex3D> ();
for (int i = -90; i <= 90; i++)
{
float fAngleX = 0;
float fAngleY = i;
position1.Add(new Data.Vertex3D(fAngleX, fAngleY, 0.0f));
}
Color color = Color.FromArgb(255, 255, 128, 0);
vizcore3d.Panorama.CustomObject.AddPolyLine(position1, color, 1.0f);
}
Panorama - Add Custom Object (Text)
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example1()
{
vizcore3d.BeginUpdate();
for (int i = 0; i < 360; i += 10)
{
float fAngleX = i;
float fAngleY = 2.0f;
string text = string.Format("{0}", i);
Color color = Color.FromArgb(255, 0, 255, 0);
vizcore3d.Panorama.CustomObject.AddText(text, Data.FontSizeKind.SIZE12, color, fAngleX, fAngleY);
}
vizcore3d.EndUpdate();
}
private void Example2()
{
vizcore3d.BeginUpdate();
for (int i = -80; i < 80; i += 10)
{
float fAngleX = 2.0f;
float fAngleY = i;
string text = string.Format("{0}", i);
Color color = Color.FromArgb(255, 0, 0, 255);
vizcore3d.Panorama.CustomObject.AddText(text, Data.FontSizeKind.SIZE12, color, fAngleX, fAngleY);
}
vizcore3d.EndUpdate();
}
Object3DManager.IsChildObject3d
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
int parentIndex = 4;
int childIndex = 100;
bool result = vizcore3d.Object3D.IsChildObject3d(parentIndex, childIndex);
if (result == true)
System.Console.WriteLine("Index is a child.");
else
System.Console.WriteLine("Index is not a child.");
}
UDAManager.ContainsNode
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
string key = "TYPE";
string val = "PIPE";
List<int> node = new List<int>() { 1, 4, 5, 7, 9, 100, 200 };
Dictionary<int, bool> result =
vizcore3d.Object3D.UDA.ContainsNode(
key /* UDA::KEY */
, val /* UDA::VALUE */
, node /* Node List */
, true /* True(Bottom Up), False(Current Node Index) */
);
foreach (KeyValuePair<int, bool> item in result)
{
if(item.Value == true)
{
System.Console.WriteLine("Contain");
}
else
{
System.Console.WriteLine("Does Not Contain");
}
}
}
UDAManager.Add
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
int nodeIndex = 5;
Dictionary<string, string> property = new Dictionary<string, string>();
property.Add("TYPE", "PIPE");
property.Add("SYSTEM", "GENERAL SERVICE LINE");
property.Add("SERVICE", "GENERAL SERVICE LINE");
property.Add("PRESS", "3.00");
property.Add("TEMP", "32.00");
vizcore3d.Object3D.UDA.Add(
nodeIndex /* NODE INDEX */
, property /* UDA */
, false /* RECURSIVE */
);
}
UDAManager.Add
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
List<int> node = new List<int>() { 4, 10, 20, 30 };
Dictionary<string, string> property = new Dictionary<string, string>();
property.Add("TYPE", "PIPE");
property.Add("SYSTEM", "GENERAL SERVICE LINE");
property.Add("SERVICE", "GENERAL SERVICE LINE");
property.Add("PRESS", "3.00");
property.Add("TEMP", "32.00");
vizcore3d.Object3D.UDA.Add(
node /* NODE INDEX */
, property /* UDA */
, false /* RECURSIVE */
);
}
UDAManager.Add
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
if (vizcore3d.Model.IsOpen() == false) return;
StringBuilder sb = new StringBuilder();
string path = vizcore3d.Model.Files[0];
sb.AppendLine(string.Format("File : {0}", path));
List<VIZCore3D.NET.Data.Node> nodes =
vizcore3d.Object3D.FromFilter(Data.Object3dFilter.ALL);
sb.AppendLine(string.Format("Count : {0}", nodes.Count));
VIZCore3D.NET.Data.UserDefineAttributeCollection udac =
new Data.UserDefineAttributeCollection();
foreach (VIZCore3D.NET.Data.Node node in nodes)
{
if (node.Index == 0) continue;
VIZCore3D.NET.Data.UserDefineAttributeItem uda =
new Data.UserDefineAttributeItem();
uda.NodeId.Add(node.ID);
for (int i = 0; i < 10; i++)
{
string key = String.Empty;
string val = String.Empty;
switch (i)
{
case 0:
{
key = "NAME";
val = node.NodeName;
}
break;
case 1:
{
key = "ID";
val = node.ID.ToString();
}
break;
case 2:
{
key = "INDEX";
val = node.Index.ToString();
}
break;
case 3:
{
key = "PARENT";
val = node.ParentIndex.ToString();
}
break;
case 4:
{
key = "TYPE";
val = node.Kind.ToString();
}
break;
case 5:
{
key = "CHILD";
val = node.ChildCount.ToString();
}
break;
case 6:
{
key = "DEPTH";
val = node.Depth.ToString();
}
break;
case 7:
{
key = "UDA#1";
val = string.Format("{0}-{1}", node.ID, node.NodeName);
}
break;
case 8:
{
key = "UDA#2";
val = string.Format("{0}-{1}", node.Index, node.NodeName);
}
break;
case 9:
{
key = "UDA#3";
val = string.Format("{0}-{1}", node.ParentIndex, node.NodeName);
}
break;
default:
break;
}
if (uda.Property.ContainsKey(key) == false)
uda.Property.Add(key, val);
}
udac.Items.Add(uda);
}
string output = string.Format(
"{0}\\{1}_Attribute.viz"
, System.IO.Path.GetDirectoryName(path)
, System.IO.Path.GetFileNameWithoutExtension(path)
);
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
vizcore3d.Object3D.UDA.Add(
path /* INPUT VIZ */
, output /* OUTPUT VIZ */
, udac /* UDA Collection */
);
sw.Stop();
sb.AppendLine(
string.Format(
"ElapsedMilliseconds : {0:#,0}"
, sw.ElapsedMilliseconds
)
);
MessageBox.Show(sb.ToString(), "VIZCore3D.NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
UDAManager.GetNodes
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
if (vizcore3d.Model.IsOpen() == false) return;
// 대분류 - TYPE : PIPE
List<VIZCore3D.NET.Data.Node> pipe =
vizcore3d.Object3D.UDA.GetNodes(
"TYPE" /* KEY */
, "PIPE" /* VALUE */
);
// 상세분류 - SERVICE : BILGE & GENERAL SERVICE LINE
List<VIZCore3D.NET.Data.Node> service =
vizcore3d.Object3D.UDA.GetNodes(
"SERVICE" /* KEY */
, "BILGE & GENERAL SERVICE LINE" /* VALUE */
, pipe /* 검색 대상 노드 */
, true /* 포함(미포함) */
);
}
Object3DManager.GetPartialNode / Object3DManager.FillNodeData
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
// 어셈블리 노드 목록
List<VIZCore3D.NET.Data.Node> items = vizcore3d.Object3D.GetPartialNode(true, false, false);
List<VIZCore3D.NET.Data.Node> result = new List<VIZCore3D.NET.Data.Node>();
// 필터링
foreach (VIZCore3D.NET.Data.Node item in items)
{
string[] vals = item.SplitNodeName("/");
if (vals.Length != 4) continue;
result.Add(item);
}
// 노드의 부가정보 채우기 : Index 및 Node Name만 필요한 경우, 호출 불필요.
result = vizcore3d.Object3D.FillNodeData(result);
}