public List <ObjectLinePiece> slice(List <ObjectLinePiece> lps, PlaneBorder aPlaneBorder)
        {
            List <ObjectLinePiece> retSlices = new List <ObjectLinePiece>();

            foreach (ObjectLinePiece anObjectLinePiece in lps)
            {
                Line sectLine = anObjectLinePiece.lp.toLine();
                //Console.WriteLine("FOO"+aPlaneBorder.getNormal().dotProduct(sectLine.direction));
                if (Math.Abs(aPlaneBorder.getNormal().dotProduct(sectLine.direction)) < MainClass.SIGNIFICANTLY_SMALL)
                {
                    //Console.WriteLine("BAR");
                    retSlices.Add(anObjectLinePiece);
                    continue;             // line is within the plane, does not intersect. Continue for iLimitBorder loop
                }
                Scientrace.Location node = aPlaneBorder.lineThroughPlane(sectLine);
                if (node == null)
                {
                    Console.WriteLine("WARNING, NODE=null: " + aPlaneBorder.ToString() + " vs. " + sectLine.ToString());
                    continue;             // somehow the line didn't go through the plane in the end... strange..
                }
                // fill return-list
                retSlices.AddRange(this.toOLP(anObjectLinePiece.lp.sliceIfBetween(node), "0 0.2 0.5 1", anObjectLinePiece.o3d));
            }
            return(retSlices);
        }
Пример #2
0
        public Intersection intersectsObject(Trace trace, Object3d o3dWithThisBorder)
        {
            PlaneBorder aBorder = this;

            if (trace.traceline.direction.dotProduct(aBorder.getNormal()) == 0)
            {
                return(Intersection.notIntersect(o3dWithThisBorder));        //trace is parallel to plane, will not intersect.
            }
            Scientrace.Location intersectLoc = aBorder.intersectsAt(trace.traceline);

            if (intersectLoc == null)
            {
                return(Intersection.notIntersect(o3dWithThisBorder));        //trace is parallel to plane, will not intersect.
            }
            return(new Intersection(true, o3dWithThisBorder, intersectLoc, new Scientrace.FlatShape2d(this.tPlane), null, this.contains(trace.traceline.startingpoint)));
        }