public virtual void Draw(Graphics g) { if (pol.NVertex() >= 3) { //g.SetColor(col); int[] ix = pol.IxArray(); int[] iy = pol.IyArray(); int n = ix.Length; //g.FillPolygon(ix, iy, n); } }
public virtual void Draw(Graphics g) { if ((pol.NVertex() >= 3) && (faceflag)) { // g.SetColor(col); int[] ix = pol.IxArray(); int[] iy = pol.IyArray(); int n = ix.Length; g.FillPolygon(new SolidBrush(col), pol.xyArray()); } }
public Polygon3D Vs_polygon_clip_3df(Polygon3D poly) { Polygon3D s = new Polygon3D(); Polygon3D r = new Polygon3D(); s.SetPol(poly); double zmin = s.ZMin(); double zmax = s.ZMax(); if (zmax < 0.10000000000000001D) { return(r); } if (zmin >= 0.10000000000000001D) { r.SetPol(poly); return(r); } for (int i = 0; i < s.NVertex(); i++) { int j; if (i == s.NVertex() - 1) { j = 0; } else { j = i + 1; } double xi = s.GetVertex(i).x; double yi = s.GetVertex(i).y; double zi = s.GetVertex(i).z; double xj = s.GetVertex(j).x; double yj = s.GetVertex(j).y; double zj = s.GetVertex(j).z; if (zi >= 0.10000000000000001D) { r.AddVertex(new Vector3D(xi, yi, zi)); if (zj < 0.10000000000000001D) { double t = (0.10000000000000001D - zi) / (zj - zi); r.AddVertex(new Vector3D(xi + (xj - xi) * t, yi + (yj - yi) * t, 0.10000000000000001D)); } } else if (zj >= 0.10000000000000001D) { double t_0 = (0.10000000000000001D - zi) / (zj - zi); r.AddVertex(new Vector3D(xi + (xj - xi) * t_0, yi + (yj - yi) * t_0, 0.10000000000000001D)); } } return(r); }
public void SetPol(Polygon3D pl) { for (int i = 0; i < pl.NVertex(); i++) { AddVertex(new Vector3D(pl.GetVertex(i))); } }
public Polygon3D(Polygon3D pl) { MAX_VERTEX = 64; vertex = new Vector3D[64]; n_vertex = 0; for (int i = 0; i < pl.NVertex(); i++) { AddVertex(new Vector3D(pl.GetVertex(i))); } }
public Polygon3D Vs_polygon_clip_2d(Polygon3D poly) { Polygon3D s = new Polygon3D(); Polygon3D r = new Polygon3D(); double vxmin = vp_xmin - 0.40000000000000002D; double vymin = vp_ymin - 0.40000000000000002D; double vxmax = vp_xmax + 0.40000000000000002D; double vymax = vp_ymax + 0.40000000000000002D; s.SetPol(poly); double xmin = poly.XMin(); double xmax = poly.XMax(); double ymin = poly.YMin(); double ymax = poly.YMax(); if (xmax < vxmin || xmin > vxmax || ymax < vymin || ymin > vymax) { return(r); } if (xmin >= vxmin && xmax <= vxmax && ymin >= vymin && ymax <= vymax) { r.SetPol(poly); return(r); } if (xmin >= vxmin) { r.SetPol(s); } else { for (int i = 0; i < s.NVertex(); i++) { int j; if (i == s.NVertex() - 1) { j = 0; } else { j = i + 1; } double xi = s.GetVertex(i).x; double yi = s.GetVertex(i).y; double xj = s.GetVertex(j).x; double yj = s.GetVertex(j).y; if (xi >= vxmin) { r.AddVertex(new Vector3D(xi, yi, 0.0D)); if (xj < vxmin) { r.AddVertex(new Vector3D(vxmin, yi + ((yj - yi) * (vxmin - xi)) / (xj - xi), 0.0D)); } } else if (xj >= vxmin) { r.AddVertex(new Vector3D(vxmin, yi + ((yj - yi) * (vxmin - xi)) / (xj - xi), 0.0D)); } } } s = new Polygon3D(); if (ymin >= vymin) { s.SetPol(r); } else { for (int i_0 = 0; i_0 < r.NVertex(); i_0++) { int j_1; if (i_0 == r.NVertex() - 1) { j_1 = 0; } else { j_1 = i_0 + 1; } double xi_2 = r.GetVertex(i_0).x; double yi_3 = r.GetVertex(i_0).y; double xj_4 = r.GetVertex(j_1).x; double yj_5 = r.GetVertex(j_1).y; if (yi_3 >= vymin) { s.AddVertex(new Vector3D(xi_2, yi_3, 0.0D)); if (yj_5 < vymin) { s.AddVertex(new Vector3D(xi_2 + ((xj_4 - xi_2) * (vymin - yi_3)) / (yj_5 - yi_3), vymin, 0.0D)); } } else if (yj_5 >= vymin) { s.AddVertex(new Vector3D(xi_2 + ((xj_4 - xi_2) * (vymin - yi_3)) / (yj_5 - yi_3), vymin, 0.0D)); } } } r = new Polygon3D(); if (xmax <= vxmax) { r.SetPol(s); } else { for (int i_6 = 0; i_6 < s.NVertex(); i_6++) { int j_7; if (i_6 == s.NVertex() - 1) { j_7 = 0; } else { j_7 = i_6 + 1; } double xi_8 = s.GetVertex(i_6).x; double yi_9 = s.GetVertex(i_6).y; double xj_10 = s.GetVertex(j_7).x; double yj_11 = s.GetVertex(j_7).y; if (xi_8 <= vxmax) { r.AddVertex(new Vector3D(xi_8, yi_9, 0.0D)); if (xj_10 > vxmax) { r.AddVertex(new Vector3D(vxmax, yi_9 + ((yj_11 - yi_9) * (vxmax - xi_8)) / (xj_10 - xi_8), 0.0D)); } } else if (xj_10 <= vxmax) { r.AddVertex(new Vector3D(vxmax, yi_9 + ((yj_11 - yi_9) * (vxmax - xi_8)) / (xj_10 - xi_8), 0.0D)); } } } s = new Polygon3D(); if (ymax <= vymax) { s.SetPol(r); } else { for (int i_12 = 0; i_12 < r.NVertex(); i_12++) { int j_13; if (i_12 == r.NVertex() - 1) { j_13 = 0; } else { j_13 = i_12 + 1; } double xi_14 = r.GetVertex(i_12).x; double yi_15 = r.GetVertex(i_12).y; double xj_16 = r.GetVertex(j_13).x; double yj_17 = r.GetVertex(j_13).y; if (yi_15 <= vymax) { s.AddVertex(new Vector3D(xi_14, yi_15, 0.0D)); if (yj_17 > vymax) { s.AddVertex(new Vector3D(xi_14 + ((xj_16 - xi_14) * (vymax - yi_15)) / (yj_17 - yi_15), vymax, 0.0D)); } } else if (yj_17 <= vymax) { s.AddVertex(new Vector3D(xi_14 + ((xj_16 - xi_14) * (vymax - yi_15)) / (yj_17 - yi_15), vymax, 0.0D)); } } } return(s); }