public static VsObject Prism(VsPolygon3 bs, double thickness) { VsObject ret = new VsObject(); Matrix44 m = new Matrix44(); ret.Add(new VsPolygon3(bs)); m.SetTMat(0.0D, 0.0D, thickness); VsPolygon3 p = (VsPolygon3)bs.Transform(m); int n = bs.pol.NVertex(); for (int i = 0; i < n; i++) { int j = i + 1; if (j >= n) { j = 0; } Polygon3D temp = new Polygon3D(); temp.AddVertex(new Vector3D(bs.pol.GetVertex(i))); temp.AddVertex(new Vector3D(p.pol.GetVertex(i))); temp.AddVertex(new Vector3D(p.pol.GetVertex(j))); temp.AddVertex(new Vector3D(bs.pol.GetVertex(j))); ret.Add(new VsPolygon3(temp, new Material(bs.mate))); } p.pol.Reverse(); ret.Add(p); return(ret); }
public static VsObject Pyramid(VsPolygon3 bs, Vector3D top) { VsObject ret = new VsObject(); Matrix44 m = new Matrix44(); ret.Add(new VsPolygon3(bs)); int n = bs.pol.NVertex(); for (int i = 0; i < n; i++) { int j = i + 1; if (j >= n) { j = 0; } Polygon3D temp = new Polygon3D(); temp.AddVertex(new Vector3D(bs.pol.GetVertex(j))); temp.AddVertex(new Vector3D(bs.pol.GetVertex(i))); temp.AddVertex(new Vector3D(top)); ret.Add(new VsPolygon3(temp, new Material(bs.mate))); } return(ret); }
public void Set(VsObject vso) { for (int i = 0; i < vso.element.Count; i++) { Add(Jp.Maker1.Vsys3.Tools.VsElementFactory.CreateElement(vso.GetElement(i))); } }
public virtual VsElement Transform(Matrix44 mat) { VsObject ret = new VsObject(); for (int i = 0; i < Size(); i++) { ret.Add(GetElement(i).Transform(mat)); } return(ret); }
public static VsObject XzGlid(double y, double x0, double z0, double x1, double z1, double xstep, double zstep, Color col) { VsObject ret = new VsObject(); for (double x = x0; x <= x1; x += xstep) { ret.Add(new VsSegment(x, y, z0, x, y, z1, col)); } for (double z = z0; z <= z1; z += zstep) { ret.Add(new VsSegment(x0, y, z, x1, y, z, col)); } return(ret); }
public static VsObject XyGlid(double z, double x0, double y0, double x1, double y1, double xstep, double ystep, Color col) { VsObject ret = new VsObject(); for (double x = x0; x <= x1; x += xstep) { ret.Add(new VsSegment(x, y0, z, x, y1, z, col)); } for (double y = y0; y <= y1; y += ystep) { ret.Add(new VsSegment(x0, y, z, x1, y, z, col)); } return(ret); }
public VsObject Copy() { VsObject ret = new VsObject(); for (int i = 0; i < Size(); i++) { VsElement temp = Jp.Maker1.Vsys3.Tools.VsElementFactory.CreateElement(GetElement(i)); if (temp != null) { ret.Add(temp); } } return(ret); }
public override void Add(VsElement elem) { if (!elem.ElemType().Equals("VsObject")) { base.Add(Jp.Maker1.Vsys3.Tools.VsElementFactory.CreateElement(elem)); AddDrawOrder(); } else { VsObject vso = (VsObject)elem; for (int i = 0; i < vso.element.Count; i++) { Add(vso.GetElement(i)); } } }
public static VsElement CreateElement(VsElement elem) { VsElement ret = null; String type = elem.ElemType(); if (type.Equals("VsPoint")) { ret = new VsPoint((VsPoint)elem); } else if (type.Equals("VsPolygon")) { ret = new VsPolygon((VsPolygon)elem); } else if (type.Equals("VsPolygon2")) { ret = new VsPolygon2((VsPolygon2)elem); } else if (type.Equals("VsPolygon3")) { ret = new VsPolygon3((VsPolygon3)elem); } else if (type.Equals("VsPolygon4")) { ret = new VsPolygon4((VsPolygon4)elem); } else if (type.Equals("VsSegment")) { ret = new VsSegment((VsSegment)elem); } else if (type.Equals("VsString")) { ret = new VsString((VsString)elem); } else if (type.Equals("VsString2")) { ret = new VsString2((VsString2)elem); } else if (type.Equals("VsObject")) { ret = new VsObject((VsObject)elem); } return(ret); }
public FormUnitFile(VsObjectList list, Uri codeBase, String fmuFilePath, String mdfFilePath) { name = null; vertex = new ArrayList(); fvno = new ArrayList(); obj0 = new VsObject(); name = null; vertex = new ArrayList(); fvno = new ArrayList(); obj0 = new VsObject(); //Uri fmuURL = null; //Uri mdfURL = null; //try //{ // fmuURL = new Uri(codeBase, fmuFilePath); // mdfURL = new Uri(codeBase, mdfFilePath); //} //catch (Exception e) //{ // Console.Error.WriteLine(e.StackTrace); //} System.Console.Out.WriteLine(fmuFilePath + " " + mdfFilePath); mdf = new MaterialDefinitionFile(mdfFilePath); Open(fmuFilePath); for (; Vs_read_form_unit(false); list.Add(name, GetVsObject())) { ; } //for (; Vs_read_form_unit(false); ) //{ // VsObject obj = GetVsObject(); // list.Add(name, GetVsObject()); //} Close(); }
public static VsObject Qube(int r, int g, int b, double shadeRate) { VsObject ret = new VsObject(); VsPolygon a = Square(r, g, b); Matrix44 m = new Matrix44(); m.SetTMat(0.0D, 0.0D, -0.5D); a = (VsPolygon)a.Transform(m); ret.Add(a); m.SetRyMat(MathTool.DegToRad(180.0D)); ret.Add(a.Transform(m)); double k = 1.0D - shadeRate; if (k < 0.0D) { k = 0.0D; } a.col = Color.FromArgb((int)(r * k), (int)(g * k), (int)(b * k)); m.SetRyMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRyMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); k = 1.0D - shadeRate * 2.0D; if (k < 0.0D) { k = 0.0D; } a.col = Color.FromArgb((int)(r * k), (int)(g * k), (int)(b * k)); m.SetRxMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRxMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); return(ret); }
public static VsObject QubeM(Material mate) { VsObject ret = new VsObject(); VsPolygon3 a = SquareM(mate); Matrix44 m = new Matrix44(); m.SetTMat(0.0D, 0.0D, -0.5D); a = (VsPolygon3)a.Transform(m); ret.Add(a); m.SetRyMat(MathTool.DegToRad(180.0D)); ret.Add(a.Transform(m)); m.SetRyMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRyMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); m.SetRxMat(MathTool.DegToRad(90.0D)); ret.Add(a.Transform(m)); m.SetRxMat(MathTool.DegToRad(-90.0D)); ret.Add(a.Transform(m)); return(ret); }
public void Add(String id, VsObject obj) { list.Add(id, obj); //ILOG.J2CsMapping.Collections.Collections.Put(list, id, obj); }
private bool Vs_read_form_unit(bool message_mode) { int head_read_order = 0; name = null; vertex = new ArrayList(); fvno = new ArrayList(); obj0 = new VsObject(); depth_sort_sw = 1; scale = 1.0D; while (true) { int c = ReadSkipSpace(); if (c == -1) { if (head_read_order != 0) { System.Console.Out.WriteLine("エラー: 形状フォーム読み込み中に EOF が表れました.vs_read_form_unit()\n"); } return(false); } if ((char)c == '#') { ReadLine(); } else { String command = ((char)c + ReadAWord()).ToUpper(); if (head_read_order == 0) { if (!command.Equals("FORM_UNIT")) { System.Console.Out.WriteLine("エラー: [FORM_UNIT]コマンド以外のコマンド[" + command + "]が最初に表れました.vs_read_form_unit()"); return(false); } name = ReadAWord(); if (message_mode) { System.Console.Out.WriteLine("----------------------------------------"); System.Console.Out.WriteLine("FORM UNIT '" + name + "' READING..."); } head_read_order++; } else if (head_read_order == 1) { if (!command.Equals("DEPTH_SORT")) { System.Console.Out.WriteLine("エラー: [DEPTH_SORT]コマンド以外のコマンド[" + command + "]が2番目に表れました.vs_read_form_unit()"); return(false); } String buf = ReadAWord().ToUpper(); if (buf.Equals("ON")) { depth_sort_sw = 1; head_read_order++; } else if (buf.Equals("OFF")) { depth_sort_sw = 0; head_read_order++; } else { System.Console.Out.WriteLine("エラー: [DEPTH_SORT]コマンドに不当なパラメータ[" + buf + "]が指定されました.vs_read_form_unit()"); return(false); } } else if (head_read_order == 2) { if (!command.Equals("SCALE")) { System.Console.Out.WriteLine("エラー: [SCALE]コマンド以外のコマンド[" + command + "]が3番目に表れました.vs_read_form_unit()"); return(false); } scale = ReadDouble(); if (scale == 0.0D) { System.Console.Out.WriteLine("エラー: [SCALE]コマンド: ゼロが設定されました.vs_read_form_unit()"); return(false); } head_read_order++; } else { if (command.Equals("FORM_END")) { break; } if (command.Equals("VERTEX")) { c = ReadSkipSpace(); if ((char)c != '{') { System.Console.Out.WriteLine("エラー: [VERTEX]コマンド:{ が無いか,または { の前に空白が有りません.vs_read_form_unit()"); return(false); } int check = Vs_read_vertexs(); if (check == -1) { System.Console.Out.WriteLine("エラー: [VERTEX]コマンド: ブロック内文法エラー.vs_read_form_unit()"); return(false); } } else if (command.Equals("POINT")) { String id = ReadAWord(); Color col = mdf.GetColor(id); if (col == null) { System.Console.Out.WriteLine("エラー: [POINT]コマンド: 存在しないマテリアルIDが指定されています.vs_read_form_unit()"); return(false); } ArrayList p = Vs_read_points(); if (p.Count != 1) { System.Console.Out .WriteLine("エラー: [POINT]コマンド: 頂点数が1になっていません.vs_read_form_unit()"); return(false); } obj0.Add(new VsPoint((Vector3D)vertex[((Int32)p[0])], col)); } else if (command.Equals("LINE")) { String id_0 = ReadAWord(); Color col_1 = mdf.GetColor(id_0); if (col_1 == null) { System.Console.Out.WriteLine("エラー: [LINE]コマンド: 存在しないマテリアルIDが指定されています.vs_read_form_unit()"); return(false); } ArrayList p_2 = Vs_read_points(); if (p_2.Count != 2) { System.Console.Out.WriteLine("エラー: [LINE]コマンド: 頂点数が2になっていません.vs_read_form_unit()"); return(false); } Vector3D p0 = new Vector3D((Vector3D)vertex[((Int32)p_2[0])]); Vector3D p1 = new Vector3D((Vector3D)vertex[((Int32)p_2[1])]); obj0.Add(new VsSegment(p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, col_1)); } else if (command.Equals("POLYGON_2")) { String id1 = ReadAWord(); String id2 = ReadAWord(); String type1 = mdf.GetType(id1); String type2 = mdf.GetType(id2); if (!type1.Equals(type2)) { System.Console.Out.WriteLine("エラー: [POLYGON_2]コマンド: 表裏のマテリアルIDが異なっています.vs_read_form_unit()"); return(false); } Color col_3; Color colB; Material mate = null; Material mateB = null; if (type1.Equals("Color")) { col_3 = mdf.GetColor(id1); } else if (type1.Equals("Material")) { mate = mdf.GetMaterial(id1); } if (type2.Equals("Color")) { colB = mdf.GetColor(id2); } else if (type2.Equals("Material")) { mateB = mdf.GetMaterial(id2); } //if (((col_3 == null) && (mate == null)) || ((colB == null) && (mateB == null))) { System.Console.Out.WriteLine("エラー: [POLYGON_2]コマンド: 存在しないマテリアルIDが指定されています.vs_read_form_unit()"); return(false); } ArrayList p_4 = Vs_read_points(); if (p_4.Count < 3) { System.Console.Out .WriteLine("エラー: [POLYGON_2]コマンド: 頂点数が3以下です.vs_read_form_unit()"); return(false); } if (type1.Equals("Color")) { VsPolygon2 pp = new VsPolygon2(); pp.col = col_3; pp.colB = colB; for (int i = 0; i < p_4.Count; i++) { Vector3D ppp = new Vector3D((Vector3D)vertex[((Int32)p_4[i])]); pp.pol.AddVertex(ppp); } obj0.Add(pp); } else { VsPolygon4 pp_5 = new VsPolygon4(); pp_5.mate = mate; pp_5.mateB = mateB; for (int i_6 = 0; i_6 < p_4.Count; i_6++) { Vector3D ppp_7 = new Vector3D((Vector3D)vertex[((Int32)p_4[i_6])]); pp_5.pol.AddVertex(ppp_7); } obj0.Add(pp_5); } } else if (command.Equals("POLYGON_1")) { String id_8 = ReadAWord(); String type = mdf.GetType(id_8); Color col_9; Material mate_10 = null; if (type.Equals("Color")) { col_9 = mdf.GetColor(id_8); } else if (type.Equals("Material")) { mate_10 = mdf.GetMaterial(id_8); } //if ((col_9 == null) && (mate_10 == null)) { System.Console.Out.WriteLine("エラー: [POLYGON_1]コマンド: 存在しないマテリアルIDが指定されています.vs_read_form_unit()"); return(false); } ArrayList p_11 = Vs_read_points(); if (p_11.Count < 3) { System.Console.Out.WriteLine("エラー: [POLYGON_1]コマンド: 頂点数が3以下です.vs_read_form_unit()"); return(false); } if (type.Equals("Color")) { VsPolygon pp_12 = new VsPolygon(); pp_12.col = col_9; for (int i_13 = 0; i_13 < p_11.Count; i_13++) { Vector3D ppp_14 = new Vector3D((Vector3D)vertex[((Int32)p_11[i_13])]); pp_12.pol.AddVertex(ppp_14); } obj0.Add(pp_12); } else { VsPolygon3 pp_15 = new VsPolygon3(); pp_15.mate = mate_10; for (int i_16 = 0; i_16 < p_11.Count; i_16++) { Vector3D ppp_17 = new Vector3D((Vector3D)vertex[((Int32)p_11[i_16])]); pp_15.pol.AddVertex(ppp_17); } obj0.Add(pp_15); } } else if (command.Equals("POLYLINE")) { String id_18 = ReadAWord(); Color col_19 = mdf.GetColor(id_18); if (col_19 == null) { System.Console.Out.WriteLine("エラー: [POLYLINE]コマンド: 存在しないマテリアルIDが指定されています.vs_read_form_unit()"); return(false); } ArrayList p_20 = Vs_read_points(); if (p_20.Count < 2) { System.Console.Out.WriteLine("エラー: [POLYLINE]コマンド: 頂点数が2以下です.vs_read_form_unit()"); return(false); } for (int i_21 = 0; i_21 < p_20.Count - 1; i_21++) { Vector3D p0_22 = new Vector3D((Vector3D)vertex[((Int32)p_20[i_21])]); Vector3D p1_23 = new Vector3D((Vector3D)vertex[((Int32)p_20[i_21 + 1])]); obj0.Add(new VsSegment(p0_22.x, p0_22.y, p0_22.z, p1_23.x, p1_23.y, p1_23.z, col_19)); } } else { System.Console.Out.WriteLine("エラー: 不当なコマンド[" + command + "]が現れました.vs_read_form_unit()"); return(false); } } } } if (message_mode) { String command_24; int c_25; System.Console.Out.WriteLine("<FORM UNIT> NAME:[" + name + "]"); System.Console.Out.WriteLine(" DEPTH SORT SW:[" + depth_sort_sw + "] SCALE FACTOR:[" + scale + "]"); System.Console.Out.WriteLine("NUMBER of VERTEX:[" + vertex.Count + "]"); System.Console.Out.WriteLine("VERTEX:"); for (int i_26 = 0; i_26 < vertex.Count; i_26++) { String vtxId = DispFormat.Lpad(((Int32)fvno[i_26]).ToString(), 3); if (vtxId.Equals("-99")) { vtxId = " "; } System.Console.Out.Write(" " + vtxId + " : "); ((Vector3D)vertex[i_26]).PrintPos(); System.Console.Out.WriteLine(""); } obj0.Print(); System.Console.Out.WriteLine("NUMBER of ELEMENT:" + obj0.element.Count); System.Console.Out.WriteLine("-----------------------------------------------\n"); } return(true); }
public VsObject(VsObject vsobj) { type = "VsObject"; element = new ArrayList(100); Set(vsobj); }