Beispiel #1
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.PositionOf (GeoPoint)"/>
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public override GeoPoint2D PositionOf(GeoPoint p)
 {
     if (toUnitPlane.IsNull)
     {
         toUnitPlane = fromUnitPlane.GetInverse();
     }
     return((toUnitPlane * p).To2D());
 }
Beispiel #2
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.ReverseOrientation ()"/>
 /// </summary>
 /// <returns></returns>
 public override ModOp2D ReverseOrientation()
 {   // x- und y-Achse vertauschen
     boxedSurfaceEx = null;
     fromUnitPlane  = fromUnitPlane * new ModOp(0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0);
     toUnitPlane    = fromUnitPlane.GetInverse();
     return(new ModOp2D(0, 1, 0, 1, 0, 0));
 }
Beispiel #3
0
        public PlaneSurface(GeoPoint location, GeoVector uDirection, GeoVector vDirection)
        {
            GeoVector zDirection = uDirection ^ vDirection;

            fromUnitPlane = new ModOp(uDirection, vDirection, zDirection, location);
            toUnitPlane   = fromUnitPlane.GetInverse();
        }
Beispiel #4
0
        internal PlaneSurface(GeoPoint p0, GeoPoint px, GeoPoint py)
        {   // px und py geben ein Rechtssystem für die Ebene, wird bei MakeBox so verwendet
            GeoVector dirx = px - p0;
            GeoVector diry = py - p0;

            fromUnitPlane = new ModOp(dirx, diry, dirx ^ diry, p0);
            toUnitPlane   = fromUnitPlane.GetInverse();
        }
Beispiel #5
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetOffsetSurface (double)"/>
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public override ISurface GetOffsetSurface(double offset)
        {
            GeoVector n = fromUnitPlane * GeoVector.ZAxis;

            n.Norm();
            ModOp newToUnit = toUnitPlane * ModOp.Translate(-offset * n);

            return(new PlaneSurface(newToUnit.GetInverse()));
        }
Beispiel #6
0
        public override void Intersect(ICurve curve, BoundingRect uvExtent, out GeoPoint[] ips, out GeoPoint2D[] uvOnFaces, out double[] uOnCurve3Ds)
        {
            if (curve is IExplicitPCurve3D && firstCurve is Line && secondCurve is Line)
            {
                if (Precision.SameDirection(firstCurve.StartDirection, secondCurve.StartDirection, false))
                {                                                                                                            // a simple plane
                    PlaneSurface pls = new PlaneSurface(firstCurve.StartPoint, firstCurve.EndPoint, secondCurve.StartPoint); // has the same uv system
                    pls.Intersect(curve, uvExtent, out ips, out uvOnFaces, out uOnCurve3Ds);
                    return;
                }
                else
                {
                    if (toUnit.IsNull)
                    {
                        lock (this)
                        {
                            if (toUnit.IsNull)
                            {
                                toUnit = ModOp.Fit(new GeoPoint[] { firstCurve.StartPoint, firstCurve.EndPoint, secondCurve.StartPoint, secondCurve.EndPoint },
                                                   new GeoPoint[] { new GeoPoint(0, 0, 0), new GeoPoint(1, 0, 0), new GeoPoint(0, 1, 0), new GeoPoint(1, 1, 1) }, true);
                            }
                        }
                    }
                    ModOp             fromUnit      = toUnit.GetInverse();
                    ICurve            unitCurve     = curve.CloneModified(toUnit);
                    ExplicitPCurve3D  explicitCurve = (unitCurve as IExplicitPCurve3D).GetExplicitPCurve3D();
                    GeoPoint[]        hypLineIsp    = implicitUnitHyperbolic.Intersect(explicitCurve, out double[] uc);
                    List <GeoPoint2D> luv           = new List <GeoPoint2D>();
                    List <double>     lu            = new List <double>();
                    List <GeoPoint>   lips          = new List <GeoPoint>();

                    for (int i = 0; i < hypLineIsp.Length; i++)
                    {
                        double u = unitCurve.PositionOf(hypLineIsp[i]); // explicitCurve doesn't necessary have the same u system as curve
                        if (u >= -1e-6 && u <= 1 + 1e-6)
                        {
                            GeoPoint2D uv = new GeoPoint2D(hypLineIsp[i].x, hypLineIsp[i].y);
                            if (BoundingRect.UnitBoundingRect.ContainsEps(uv, -0.001))
                            {
                                lu.Add(u);
                                luv.Add(uv);
                                lips.Add(fromUnit * hypLineIsp[i]);
                            }
                        }
                    }

                    uvOnFaces   = luv.ToArray();
                    uOnCurve3Ds = lu.ToArray();
                    ips         = lips.ToArray();
#if DEBUG
                    ++hitcount;
#endif
                    return;
                }
            }
            base.Intersect(curve, uvExtent, out ips, out uvOnFaces, out uOnCurve3Ds);
        }
Beispiel #7
0
        private double pitch;          // pitch in y direction relative to basisCurve2D

        // ACHTUNG: Achse und Kurve müssen in einer Ebene liegen, damit dieses Objekt mit seinem
        // OCas Partner kompatibel ist!
        internal HelicalSurface(ICurve2D basisCurve2D, double pitch, ModOp toSurface, double curveStartParameter, double curveEndParameter, double curveParameterOffset) : base()
        {
            this.basisCurve2D         = basisCurve2D;
            this.pitch                = pitch;
            this.toSurface            = toSurface;
            this.fromSurface          = toSurface.GetInverse();
            this.curveStartParameter  = curveStartParameter;
            this.curveEndParameter    = curveEndParameter;
            this.curveParameterOffset = curveParameterOffset;
        }
Beispiel #8
0
 protected HelicalSurface(SerializationInfo info, StreamingContext context) : base()
 {
     basisCurve2D        = info.GetValue("BasisCurve2D", typeof(ICurve2D)) as ICurve2D;
     pitch               = (double)info.GetValue("Pitch", typeof(double));
     toSurface           = (ModOp)info.GetValue("ToSurface", typeof(ModOp));
     fromSurface         = toSurface.GetInverse(); // müsste eigentlich da sein, da nur struct
     curveStartParameter = (double)info.GetValue("CurveStartParameter", typeof(double));
     curveEndParameter   = (double)info.GetValue("CurveEndParameter", typeof(double));
     try
     {
         curveParameterOffset = (double)info.GetValue("CurveParameterOffset", typeof(double));
     }
     catch (SerializationException)
     {
         curveParameterOffset = 0;
     }
 }
Beispiel #9
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.Modify (ModOp)"/>
 /// </summary>
 /// <param name="m"></param>
 public override void Modify(ModOp m)
 {
     boxedSurfaceEx = null;
     fromUnitPlane  = m * fromUnitPlane;
     toUnitPlane    = fromUnitPlane.GetInverse();
 }
Beispiel #10
0
 public PlaneSurface(Plane plane)
 {
     fromUnitPlane = new ModOp(plane.DirectionX, plane.DirectionY, plane.Normal, plane.Location);
     toUnitPlane   = fromUnitPlane.GetInverse();
 }
Beispiel #11
0
        private ModOp toUnitPlane;   // inverted fromUnitPlane

        internal PlaneSurface(ModOp m, BoundingRect?usedArea = null) : base(usedArea)
        {
            fromUnitPlane = m;
            toUnitPlane   = fromUnitPlane.GetInverse();
        }
Beispiel #12
0
        public HelicalSurface(ICurve basisCurve, GeoPoint axisLocation, GeoVector axisDirection, double pitch, double curveStartParameter, double curveEndParameter, GeoPoint?axisRefPoint = null) : base()
        {
            this.curveEndParameter   = curveEndParameter;
            this.curveStartParameter = curveStartParameter;
            this.pitch = pitch;
            // curveStartParameter und curveEndParameter haben folgenden Sinn:
            // der Aufrufer werwartet ein bestimmtes u/v System.
            // in u ist es die Kreisbewegung, in v ist es die Kurve (andersrum als bei SurfaceOfLinearExtrusion)
            // curveStartParameter und curveEndParameter definieren die Lage von v, die Lage von u ist durch die Ebene
            // bestimmt
            // finden der Hauptebene, in der alles stattfindet. Die ist gegeben durch die Achse und die Kurve
            Plane pln;

            if (axisRefPoint.HasValue)
            {
                GeoPoint cnt = Geometry.DropPL(axisRefPoint.Value, axisLocation, axisDirection);
                pln = new Plane(axisLocation, axisRefPoint.Value - cnt, axisDirection);
            }
            else
            {
                double ds = Geometry.DistPL(basisCurve.StartPoint, axisLocation, axisDirection);
                double de = Geometry.DistPL(basisCurve.EndPoint, axisLocation, axisDirection);
                if (ds > de && ds > Precision.eps)
                {
                    GeoPoint cnt = Geometry.DropPL(basisCurve.StartPoint, axisLocation, axisDirection);
                    pln = new Plane(axisLocation, basisCurve.StartPoint - cnt, axisDirection);
                }
                else if (de >= ds && de > Precision.eps)
                {
                    GeoPoint cnt = Geometry.DropPL(basisCurve.EndPoint, axisLocation, axisDirection);
                    pln = new Plane(axisLocation, basisCurve.EndPoint - cnt, axisDirection);
                }
                else if (basisCurve.GetPlanarState() == PlanarState.Planar)
                {
                    Plane     ppln = basisCurve.GetPlane();
                    GeoVector dirx = ppln.Normal ^ axisDirection; // richtig rum?
                    pln = new Plane(axisLocation, dirx, axisDirection);
                }
                else
                {   // es könnte sein, dass die ganze Fläche singulär ist
                    // dann kann man nichts machen, sollte aber nicht vorkommen
                    throw new SurfaceOfRevolutionException("Surface is invalid");
                }
            }
            // pln hat jetzt den Ursprung bei axisLocation, die y-Achse ist axisDirection und die x-Achse durch die
            // die Orientierung scheint mir noch fraglich, wierum wird gedreht, wierum läuft u
            // Kurve gegeben
            basisCurve2D = basisCurve.GetProjectedCurve(pln);
            // ACHTUNG "Parameterproblem": durch die Projektion der Kurve verschiebt sich bei Kreisen der Parameterraum
            // da 2D Kreise bzw. Bögen keine Achse haben und sich immer auf die X-Achse beziehen
            if (basisCurve2D is Arc2D)
            {
                curveParameterOffset = (basisCurve2D as Arc2D).StartParameter - this.curveStartParameter;
            }
            else if (basisCurve2D is BSpline2D)
            {   // beim BSpline fängt der Parameter im 3D bei knots[0] an, welches gleich this.curveStartParameter ist
                // curveParameterOffset = this.curveStartParameter;
                // wenn man einen geschlossenen Spline um eine Achse rotieren lässt
                // dann entsteht mit obiger Zeile ein Problem, mit dieser jedoch nicht:
                curveParameterOffset = (basisCurve2D as BSpline2D).Knots[0];
            }
            else
            {
                curveParameterOffset = 0.0;
            }
            toSurface = ModOp.Fit(new GeoPoint[] { GeoPoint.Origin, GeoPoint.Origin + GeoVector.XAxis, GeoPoint.Origin + GeoVector.YAxis },
                                  new GeoPoint[] { axisLocation, axisLocation + pln.DirectionX, axisLocation + pln.DirectionY }, false);
            fromSurface = toSurface.GetInverse();
        }
Beispiel #13
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.Modify (ModOp)"/>
 /// </summary>
 /// <param name="m"></param>
 public override void Modify(ModOp m)
 {
     boxedSurfaceEx = null;
     toSurface      = m * toSurface;
     fromSurface    = toSurface.GetInverse();
 }