示例#1
0
        protected override bool CutCurveHullDetailed(double tolerance,
                                                     out IList <double[]> limits,
                                                     out NearSegment hullStartNear,
                                                     out NearSegment hullEndNear,
                                                     out bool coincident)
        {
            if (!Hull.Segment.IsLinear || !Neighbor.Segment.IsLinear)
            {
                throw new NotImplementedException("Not implemented for non linear segments");
            }

            coincident = IsCoincident(tolerance, out hullStartNear, out hullEndNear);

            HullCutResult hullCut = CutHullHullDetailed();
            double        tMax    = hullCut.Max;
            double        tMin    = hullCut.Min;

            limits = new List <double[]>();
            if (tMin < tMax)
            {
                limits.Add(new[] { tMin, tMax });
            }

            return(limits.Count > 0);
        }
示例#2
0
        private HullCutResult CutHullHullDetailed()
        {
            var    result = new HullCutResult();
            double tMin   = double.MaxValue;
            double tMax   = double.MinValue;

            foreach (HullLine hullPart in GetLineHullParts(Geom.L0, Hull))
            {
                double tMinPart = double.MaxValue;
                double tMaxPart = double.MinValue;

                var simple = hullPart as HullLineSimple;
                var arc    = hullPart as HullLineArc;
                var line   = hullPart as HullLineLine;

                foreach (IHullPart neighborPart in GetNeighborHullParts(Geom.L1, Neighbor))
                {
                    bool   intersects;
                    double tMinNb = double.MaxValue;
                    double tMaxNb = double.MinValue;

                    if (simple != null)
                    {
                        intersects = neighborPart.Cut(simple, ref tMinNb, ref tMaxNb);
                    }
                    else if (arc != null)
                    {
                        intersects = neighborPart.Cut(arc, ref tMinNb, ref tMaxNb);
                    }
                    else if (line != null)
                    {
                        intersects = neighborPart.Cut(line, ref tMinNb, ref tMaxNb);
                    }
                    else
                    {
                        throw new NotImplementedException(hullPart.GetType().ToString());
                    }

                    if (intersects)
                    {
                        if (tMinNb < tMinPart)
                        {
                            result.MinCutPart = neighborPart.CutPart;
                            tMinPart          = tMinNb;
                        }

                        if (tMaxNb > tMaxPart)
                        {
                            result.MaxCutPart = neighborPart.CutPart;
                            tMaxPart          = tMaxNb;
                        }
                    }
                }

                tMin = Math.Min(tMin, tMinPart);
                tMax = Math.Max(tMax, tMaxPart);
            }

            result.Min = tMin;
            result.Max = tMax;
            return(result);
        }