/// <summary> /// Calculates the partial uDerivation /// </summary> /// <param name="u">first parameter</param> /// <param name="v">second parameter</param> /// <returns>value of the partial uDerivation</returns> public override xyz uDerivation(double u, double v) { return(Base.Absolut(Curve.Derivation(u).toXYZ())); }
/// <summary> /// overrides the <see cref="CustomEntity.OnDraw(OpenGlDevice)"/> method. /// </summary> /// <param name="Device"></param> protected override void OnDraw(OpenGlDevice Device) { base.OnDraw(Device); if (Transverse == null) { return; } if (Transverse.Count == 0) { return; } for (int i = 1; i > 0; i--) { if (Trace[i].dist(Trace[i - 1]) < Utils.epsilon) { Trace.RemoveAt(i); } } if ((Trace.Count == 3) && (Trace.Closed())) { Trace.RemoveAt(2); } if (Trace.Count <= 1) { return; } // if (Trace.Count <= 1) return; xyz Basey = new xyz(0, 0, 0); if (Trace.Count == 2) { Basey = new xyz(0, 0, -1); if ((Basey & (Trace[1] - Trace[0])).length() < 0.000001) { Basey = new xyz(0, -1, 0); } } else { Basey = (((Trace[2] - Trace[1]) & (Trace[0] - Trace[1]))).normalized() * (-1); } for (int i = 0; i < Trace.Count - 1; i++) { xyz N1, N2; if (i == 0) { if (Trace.Closed()) { N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[Trace.Count - 2] - Trace[i]).normalized(); } else { N1 = (Trace[i + 1] - Trace[i]).normalized(); } if ((i + 2) == Trace.Count) { N2 = (Trace[i] - Trace[i + 1]).normalized() & Basey; } else { N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized(); } } else if (i == (Trace.Count - 2)) { N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized(); if (Trace.Closed()) { N2 = (Trace[i] - Trace[0]).normalized() - (Trace[1] - Trace[0]).normalized(); } else { N2 = (Trace[i] - Trace[Trace.Count - 1]).normalized(); } } else { N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized(); N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized(); } if (Trace.Count == 2) { N1 = Trace[1] - Trace[0]; N2 = Trace[0] - Trace[1]; } Plane P1 = new Plane(Trace[i], N1.normalized()); Plane P2 = new Plane(Trace[i + 1], N2.normalized()); if (i > 0) { Basey = Matrix.Mirror(P1) * Basey - Matrix.Mirror(P1) * new xyz(0, 0, 0); } Base B = new Base(); B.BaseO = Trace[i]; B.BaseZ = (Trace[i + 1] - Trace[i]).normalized(); B.BaseY = Basey.normalized(); B.BaseX = (B.BaseY & B.BaseZ).normalized(); B.BaseY = B.BaseZ & B.BaseX * (-1); Matrix BInvert = B.ToMatrix().invert(); Plane DownPlane = BInvert * P1; Plane UpPlane = BInvert * P2; Device.PushMatrix(); Device.MulMatrix(B.ToMatrix()); for (int m = 0; m < Transverse.Count; m++) { for (int n = 0; n < Transverse[m].Count; n++) { CurveExtruder CE = new CurveExtruder(); CE.Height = -1; CE.DownPlane = BInvert * P1; CE.UpPlane = BInvert * P2; CE.Curve = Transverse[m][n]; CE.Paint(Device); if (Device.RenderKind == RenderKind.SnapBuffer) { SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1]; if (SI != null) { SI.OfObject = this; } } } } double L = (Trace[i + 1] - Trace[i]).length(); if ((i == 0) && (CloseFirst)) { Device.drawPolyPolyCurve(Transverse); } if ((i == Trace.Count - 2) && (CloseLast)) { Device.PushMatrix(); Device.MulMatrix(Matrix.Translation(new xyz(0, 0, L))); Device.drawPolyPolyCurve(Transverse); Device.PopMatrix(); } Device.PopMatrix(); } }
/// <summary> /// creates a <see cref="Face"/> for a <see cref="Solid"/> in the <see cref="Model.Solid"/>. /// The Curves are all <see cref="Line3D"/>. The <see cref="Face"/> is plane and has as <see cref="Face.Surface"/> a <see cref="PlaneSurface"/>. /// </summary> /// <param name="Solid">is the target in which the <see cref="Face"/> will be posed.</param> /// <param name="Bounds">contains the <see cref="Vertex3d"/> for the <see cref="Line3D"/>.</param> /// <returns>a <see cref="Face"/></returns> public static Face SolidPlane(Solid Solid, Vertex3dArray_2 Bounds) { if (Bounds.Count == 0) { return(null); } xyz N = new xyz(0, 0, 0); xyz P = Bounds[0][0].Value; for (int i = 1; i < Bounds[0].Count - 1; i++) { xyz A = Bounds[0][i].Value; xyz B = Bounds[0][i + 1].Value; xyz M = N; N = N + ((A - P) & (B - P)); } N = N.normalized() * (-1); Base Base = Base.UnitBase; Base.BaseO = P; Base.BaseZ = N; if ((Base.BaseZ & new xyz(1, 0, 0)).dist(xyz.Null) > 0.01) { Base.BaseY = (Base.BaseZ & (new xyz(1, 0, 0))).normalized(); Base.BaseX = Base.BaseY & Base.BaseZ; } else { Base.BaseY = (Base.BaseZ & (new xyz(0, 1, 0))).normalized(); Base.BaseX = Base.BaseY & Base.BaseZ; } PlaneSurface Surface = new PlaneSurface(); Surface.Base = Base; //------------------------------------- //-------- Create the Face Face Result = new Face(); // ---- With Plane Surface Result.Surface = Surface; if (Solid != null) { Solid.FaceList.Add(Result); } //----- Set the Edges for (int i = 0; i < Bounds.Count; i++) { EdgeLoop Edgeloop = new EdgeLoop(); Result.Bounds.Add(Edgeloop); for (int j = 0; j < Bounds[i].Count; j++) { Vertex3d A = Bounds[i][j]; Vertex3d B = null; if (j == Bounds[i].Count - 1) { B = Bounds[i][0]; } else { B = Bounds[i][j + 1]; } Edge E = Edge.SolidEdge(Solid, Result, A, B, new Line3D(A.Value, B.Value)); Edgeloop.Add(E); } } Result.RefreshParamCurves(); return(Result); }