Example #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);
        }