Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.FixedU (double, double, double)"/>
        /// </summary>
        /// <param name="u"></param>
        /// <param name="vmin"></param>
        /// <param name="vmax"></param>
        /// <returns></returns>
        public override ICurve FixedU(double u, double vmin, double vmax)
        {
            ICurve2D btr       = basisCurve2D.Trim(GetPos(vmin), GetPos(vmax));
            ICurve   b3d       = btr.MakeGeoObject(Plane.XYPlane) as ICurve;
            ModOp    rot       = ModOp.Rotate(1, (SweepAngle)u);
            ModOp    movePitch = ModOp.Translate(0, pitch * u / (Math.PI * 2.0), 0);

            return(b3d.CloneModified(toSurface * movePitch * rot));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetProjectedCurve (ICurve, double)"/>
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="precision"></param>
        /// <returns></returns>
        public override ICurve2D GetProjectedCurve(ICurve curve, double precision)
        {
            // Hier muss beachtet werden, dass dieses PlaneSurface Objekt ein anderes uv System haben kann als
            // Plane, also begeben wir uns in das Unit System
            if (curve is InterpolatedDualSurfaceCurve)
            {
                return(base.GetProjectedCurve(curve, precision));
            }
            ICurve crvunit = curve.CloneModified(toUnitPlane);

            return(crvunit.GetProjectedCurve(Plane.XYPlane));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.Make3dCurve (ICurve2D)"/>
 /// </summary>
 /// <param name="curve2d"></param>
 /// <returns></returns>
 public override ICurve Make3dCurve(ICurve2D curve2d)
 {
     if (curve2d is Curve2DAspect)
     {
         ICurve res = (curve2d as Curve2DAspect).Get3DCurve(this);
         if (res != null)
         {
             return(res);
         }
     }
     if (curve2d is ProjectedCurve pc)
     {
         if (pc.Surface is SurfaceOfLinearExtrusion)
         {
             BoundingRect otherBounds = new BoundingRect(PositionOf(pc.Surface.PointAt(pc.StartPoint)), PositionOf(pc.Surface.PointAt(pc.EndPoint)));
             if (pc.Surface.SameGeometry(pc.GetExtent(), this, otherBounds, Precision.eps, out ModOp2D notneeded))
             {
                 return(pc.Curve3DFromParams); // if trimmed or reversed still returns the correct 3d curve (but trimmed and/or reversed)
             }
         }
     }
     if (curve2d is Line2D)
     {
         Line2D      l2d = curve2d as Line2D;
         GeoVector2D dir = l2d.EndPoint - l2d.StartPoint;
         if (Math.Abs(dir.x) < Precision.eps)
         {   // das Ergebnis ist eine Mantel-Linie
             Line res = Line.Construct();
             res.StartPoint = PointAt(l2d.StartPoint);
             res.EndPoint   = PointAt(l2d.EndPoint);
             return(res);
         }
         else if (Math.Abs(dir.y) < Precision.eps)
         {
             // Basiskurve bzw. Abschnitt derselben
             ModOp  move = ModOp.Translate(l2d.StartPoint.y * direction);
             ICurve res  = basisCurve.CloneModified(move);
             double sp   = (l2d.StartPoint.x - curveStartParameter) / (curveEndParameter - curveStartParameter);
             double ep   = (l2d.EndPoint.x - curveStartParameter) / (curveEndParameter - curveStartParameter);
             //double sp = l2d.StartPoint.x;
             //double ep = l2d.EndPoint.x;
             if (!(basisCurve is BSpline))
             {   // hier geht auch Verlängern
                 if (sp > ep)
                 {
                     res.Reverse();
                     if (ep != 0.0 || sp != 1.0)
                     {
                         res.Trim(1.0 - sp, 1.0 - ep);
                     }
                 }
                 else
                 {
                     if (sp != 0.0 || ep != 1.0)
                     {
                         res.Trim(sp, ep);
                     }
                 }
             }
             else
             {
                 if (sp > 1.0 && ep > 1.0)
                 {
                     return(null);
                 }
                 if (sp < 0.0 && ep < 0.0)
                 {
                     return(null);
                 }
                 if (sp > ep)
                 {
                     res.Reverse();
                     if (ep != 0.0 || sp != 1.0)
                     {
                         res.Trim(1.0 - sp, 1.0 - ep);
                     }
                 }
                 else
                 {
                     if (sp != 0.0 || ep != 1.0)
                     {
                         res.Trim(sp, ep);
                     }
                 }
             }
             return(res);
         }
     }
     if (curve2d is BSpline2D)
     {
         BSpline2D  b2d    = (curve2d as BSpline2D);
         int        numpts = b2d.Poles.Length * b2d.Degree;
         GeoPoint[] pts    = new GeoPoint[numpts + 1];
         for (int i = 0; i <= numpts; ++i)
         {
             pts[i] = PointAt(b2d.PointAt((double)i / (double)numpts));
         }
         BSpline b3d = BSpline.Construct();
         b3d.ThroughPoints(pts, b2d.Degree, false);
         return(b3d);
     }
     return(base.Make3dCurve(curve2d));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.Modify (ModOp)"/>
 /// </summary>
 /// <param name="m"></param>
 public override void Modify(ModOp m)
 {
     firstCurve  = firstCurve.CloneModified(m);
     secondCurve = secondCurve.CloneModified(m);
 }