/// <summary> /// draws a list of <see cref="xyzArray"/>.The first array is the outer contur the other are holes. /// </summary> /// <param name="Loxyz">a list of <see cref="xyzArray"/></param> public void drawPolyPolyLine(Loxyz Loxyz) { Object Handle = null; if ((RenderKind == RenderKind.SnapBuffer)) { Handle = Selector.RegisterSnapItem(new PolyPolyLineSnappItem3D(Loxyz)); } if ((PolygonMode == PolygonMode.Fill) && (Loxyz.planar)) { Loxy L = Loxyz.ToLoxy(); PushMatrix(); MulMatrix(Loxyz.Base.ToMatrix()); drawFilledArray2d(this, L); PopMatrix(); if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } return; } for (int i = 0; i < Loxyz.Count; i++) { Primitives3d.drawArrayLined(this, Loxyz[i]); } if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } }
Loxy getLoxy(double UpDown, ref Base Base) { Loxy Result = new Loxy(); if ((Curvextruders != null) && (Curvextruders.Count > 0) && (Curvextruders[0].Count > 3)) { xyzArray A = new xyzArray(); for (int j = 0; j < Curvextruders[0].Count; j++) { A.Add(Curvextruders[0][j].Value(0, UpDown)); } xyz N = A.normal(); Base = Base.DoComplete(Curvextruders[0][0].Value(0, UpDown), N); for (int i = 0; i < Curvextruders.Count; i++) { xyArray _A = new xyArray(); Result.Add(_A); for (int j = 0; j < Curvextruders[i].Count; j++) { xy P = Base.Relativ(Curvextruders[i][j].Value(0, UpDown)).toXY(); _A.Add(P); } if (_A.Count > 0) { _A.Add(_A[0]); } } } return(Result); }
/// <summary> /// draws a 2d-polygon, which is stored in Array. See also <see cref="xyArray"/>. /// </summary> /// <param name="Array"><see cref="xyArray"/>.</param> public void drawPolyLine(xyArray Array) { Object Handle = null; if ((RenderKind == RenderKind.SnapBuffer)) { Handle = Selector.RegisterSnapItem(new PolyLineSnappItem(Array)); } if (PolygonMode == PolygonMode.Fill) { Loxy L = new Loxy(); L.Add(Array); drawFilledArray2d(this, L); if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } if (PolygonMode == PolygonMode.Fill) { return; } } Primitives2d.drawArrayLined(this, Array); if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } }
/// <summary> /// draws a 3d-polygon, which is stored in Array. See also <see cref="xyzArray"/> if the <see cref="OpenGlDevice.PolygonMode"/> = <b>Fill</b> and the array is planar then /// the polygon is drawn as filled polygon else as a lined polygon. /// </summary> /// <param name="Array"><see cref="xyzArray"/>hollds the array information</param> public void drawPolyLine(xyzArray Array) { Object Handle = null; if ((RenderKind == RenderKind.SnapBuffer)) { Handle = Selector.RegisterSnapItem(new PolyLineSnappItem3D(Array)); } if ((PolygonMode == PolygonMode.Fill) && (Array.Count > 2) && (Array.planar)) { Loxy L = new Loxy(); PushMatrix(); MulMatrix(Array.Base.ToMatrix()); xyArray A = Array.ToxyArray(); L.Add(A); drawFilledArray2d(this, L); PopMatrix(); if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } if (PolygonMode == PolygonMode.Fill) { return; } } Primitives3d.drawArrayLined(this, Array); if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } }
/// <summary> /// Set operations are applied. See also <see cref="SetOperations"/> and <see cref="Loxy.SetOperation(SetOperations, Loxy)"/> /// </summary> /// <param name="Operation">Setoperation</param> /// <param name="Clip">the other loca</param> /// <returns>the settheoretical Loxy.</returns> public Loxy SetOperation(SetOperations Operation, Loca Clip) { Loxy L = ToLoxy(); Loxy LClip = Clip.ToLoxy(); return(L.SetOperation(Operation, LClip)); }
private Loxy FromClipperLoxy(List <List <IntPoint> > Src) { Loxy Result = new Loxy(); for (int i = 0; i < Src.Count; i++) { Result.Add(FromClipperPoly(Src[i])); } return(Result); }
private List <List <IntPoint> > ToClipperPoly(Loxy Src) { List <List <IntPoint> > Result = new List <List <IntPoint> >(); for (int i = 0; i < Src.Count; i++) { Result.Add(ToClipperPoly(Src[i])); } return(Result); }
/// <summary> /// draws a list of 2d-curve lists. See also <see cref="Loca"/>. /// </summary> /// <param name="Loca">list of curve lists.</param> public void drawPolyPolyCurve(Loca Loca) { Loxy L = new Loxy(); for (int i = 0; i < Loca.Count; i++) { L.Add(Loca[i].getxyArray()); } _drawPolyPolyCurve(L, Loca, 1); }
void CheckLoxy() { Base DownBase = Base.UnitBase; Base UpBase = Base.UnitBase; DownLoxy = getLoxy(0, ref DownBase); UpLoxy = getLoxy(1, ref UpBase); DownBase.BaseZ = DownBase.BaseZ * (-1); UpMatrix = UpBase.ToMatrix(); DownMatrix = DownBase.ToMatrix(); }
/// <summary> /// converts the loca to a <see cref="Loxy"/> /// </summary> /// <returns></returns> public Loxy ToLoxy() { Loxy Result = new Loxy(); for (int i = 0; i < Count; i++) { CurveArray CA = this[i]; Result.Add(CA.getxyArray()); } return(Result); }
/// <summary> /// Set operations are applied <see cref="SetOperations"/> /// </summary> /// <param name="Operation">Setoperation</param> /// <param name="Clip">the other Loxy</param> /// <returns>the result of the setoperation</returns> public Loxy SetOperation(SetOperations Operation, Loxy Clip) { List <List <IntPoint> > Me = ToClipperPoly(this); List <List <IntPoint> > Second = ToClipperPoly(Clip); Clipper c = new Clipper(); c.AddPaths(Me, PolyType.ptSubject, true); c.AddPaths(Second, PolyType.ptClip, true); List <List <IntPoint> > Solution = new List <List <IntPoint> >(); c.Execute((ClipType)Operation, Solution, PolyFillType.pftNonZero, PolyFillType.pftNonZero); return(FromClipperLoxy(Solution)); }
void _drawPolyPolyCurve(Loxy L, Loca Loca, int id) { Object Handle = null; if (PolygonMode == PolygonMode.Fill) { if ((RenderKind == RenderKind.SnapBuffer)) { Handle = Selector.RegisterSnapItem(getSI(id, Loca, L, -1)); } drawFilledArray2d(this, L); if ((RenderKind == RenderKind.SnapBuffer)) { MeshCreator.Renew(); Selector.UnRegisterSnapItem(Handle); } return; } if ((RenderKind == RenderKind.SnapBuffer)) { SnappItem S = (getSI(id, Loca, L, -1)); Handle = Selector.RegisterSnapItem(S); } { for (int i = 0; i < L.Count; i++) { //IndexType[] Indices = new IndexType[L[i].Count]; //for (int k = 0;k < L[i].Count; k++) //{ // Indices[k] = k; //} //xyzf[] Points = new xyzf[L[i].Count]; //for (int k = 0; k < L[i].Count; k++) //{ // Points[k] = new xyzf((float)L[i][k].X, (float)L[i][k].y, 0f); //} //Primitives3d.drawTriangles(this,Indices, Points, null, null, null); ////if ((RenderKind == RenderKind.SnapBuffer)) //// Selector.ToSnapBuffer((uint)i); Primitives2d.drawArrayLined(this, L[i]); } } if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } }
SnappItem getSI(int id, Loca Loca, Loxy Loxy, int path) { if (id == 0) { PolyPolyLineSnappItem SI = new PolyPolyLineSnappItem(Loxy); SI.Path = path; return(SI); } else { PolyPolyCurveSnappItem SI = new PolyPolyCurveSnappItem(Loca); SI.Path = path; return(SI); } }
/// <summary> /// restricted the <see cref="Loxyz"/> to a <see cref="Loxy"/> by omitting the z-value. /// </summary> /// <returns>a <see cref="Loxy"/></returns> public Loxy ToLoxy() { Loxy result = new Loxy(); for (int i = 0; i < Count; i++) { xyArray A = new xyArray(this[i].Count); for (int j = 0; j < A.Count; j++) { A[j] = Base.Relativ(this[i][j]).toXY(); } result.Add(A); } return(result); }
/// <summary> /// a constructor with a <see cref="Loxy"/> L and a <see cref="Height"/>. /// </summary> /// <param name="L"></param> /// <param name="Height"></param> public DiscreteExtrude(Loxy L, double Height) : base() { this.Polygon = L; this.Height = Height; Refresh(); }
/// <summary> /// draws a list of <see cref="xyArray"/>s. /// </summary> /// <param name="Loxy">is a <see cref="Loxy"/>, which will be drawn.</param> public void drawPolyPolyLine(Loxy Loxy) { _drawPolyPolyCurve(Loxy, null, 0); }
private void drawFilledArray2d(OpenGlDevice Device, Loxy L) { if (L.Count == 0) { return; } double xMax = -10000000; double yMax = -10000000; double xMin = 10000000; double yMin = 10000000; if ((Device.texture != null) && (Device.texture.SoBigAsPossible != Drawing3d.Texture.BigAsPosible.None)) { for (int i = 0; i < L[0].Count; i++) { if (L[0][i].X > xMax) { xMax = L[0][i].X; } if (L[0][i].X < xMin) { xMin = L[0][i].X; } if (L[0][i].Y > yMax) { yMax = L[0][i].Y; } if (L[0][i].Y < yMin) { yMin = L[0][i].Y; } } } double xDiff = xMax - xMin; double yDiff = yMax - yMin; List <IndexType> Indices = new List <IndexType>(); xyf[] Points = null; L.TriAngulation(Indices, ref Points); xyf[] Texture = new xyf[Points.Length]; float Aspectx = 1; float Aspecty = 1; if ((Device.texture != null) && (Device.texture.SoBigAsPossible != Drawing3d.Texture.BigAsPosible.None)) { if (Device.texture.Bitmap != null) { double w = (float)Device.texture.Bitmap.Width / Device.PixelsPerUnit; double h = (float)Device.texture.Bitmap.Height / Device.PixelsPerUnit; if (Device.texture.KeepAspect) { if (Device.texture.SoBigAsPossible == Drawing3d.Texture.BigAsPosible.Height) { Aspectx = (float)(h / w); } else { Aspecty = (float)(w / h); } } } for (int i = 0; i < Points.Length; i++) { if (Device.texture.KeepAspect) { if (Aspecty != 1) { Texture[i] = new xyf((Points[i].x - (float)xMin) / (float)(xDiff), (Points[i].y - (float)yMin) / (float)(xDiff / Aspecty)); } if (Aspectx != 1) { Texture[i] = new xyf((Points[i].x - (float)xMin) / (float)(yDiff / Aspectx), (Points[i].y - (float)yMin) / (float)(yDiff)); } } else { Texture[i] = new xyf((Points[i].x - (float)xMin) / (float)(xDiff), (Points[i].y - (float)yMin) / (float)(yDiff)); } } } else { for (int i = 0; i < Points.Length; i++) { Texture[i] = Points[i] + Points[0] * (-1); } } Primitives2d.drawTriangles2d(Device, Indices, Points, Texture); }