コード例 #1
0
        /// <summary>
        /// Check whether this room contains a given point.
        /// </summary>
        public static bool RoomContains(this Room r, XYZ p1)
        {
            bool        ret = false;
            var         p   = MaakPuntArray(r);
            PointInPoly pp  = new PointInPoly();

            ret = pp.PolyGonContains(p, p1);
            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// Check whether this area contains a given point.
        /// </summary>
        public static bool AreaContains(this Area a, XYZ p1)
        {
            bool        ret = false;
            var         p   = MaakPuntArray(a);
            PointInPoly pp  = new PointInPoly();

            ret = pp.PolyGonContains(p, p1);
            return(ret);
        }
コード例 #3
0
        public void TestPointInPolyNonZero_Extended_Robust()
        {
            Circle2 c    = new Circle2(new Point2d(0, 0), 5);
            double  tmin = c.TMin;
            double  tmax = c.TMax;
            double  tinc = (tmax - tmin) / 5;
            Point2d p0   = c.GetPosition(tmin);
            Point2d p1   = c.GetPosition(tmin + tinc);
            Point2d p2   = c.GetPosition(tmin + 2 * tinc);
            Point2d p3   = c.GetPosition(tmin + 3 * tinc);
            Point2d p4   = c.GetPosition(tmin + 4 * tinc);

            IList <Point2d> points = DuplicatePoints(AsList(p0, p2, p4, p1, p3));

            PointInPoly pip1 = PolygonUtils.PointInPolyNonZero(points, new Point2d(4, 0), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip1);

            PointInPoly pip2 = PolygonUtils.PointInPolyNonZero(points, new Point2d(-2, 2), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip2);

            PointInPoly pip3 = PolygonUtils.PointInPolyNonZero(points, new Point2d(-2, -2), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip3);

            PointInPoly pip4 = PolygonUtils.PointInPolyNonZero(points, new Point2d(0, 0), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip4);

            PointInPoly pip5 = PolygonUtils.PointInPolyNonZero(points, new Point2d(10, 0), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Outside, pip5);

            PointInPoly pip6 = PolygonUtils.PointInPolyNonZero(points, new Point2d(4, 3), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Outside, pip6);

            PointInPoly pip7 = PolygonUtils.PointInPolyNonZero(points, new Point2d(4, -3), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Outside, pip7);

            PointInPoly pip8 = PolygonUtils.PointInPolyNonZero(points, new Point2d(1, 1), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip8);

            PointInPoly pip9 = PolygonUtils.PointInPolyNonZero(points, new Point2d(1, -1), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.Inside, pip9);

            PointInPoly pip10 = PolygonUtils.PointInPolyNonZero(points, p4.Add(p1.Sub(p4).Unit.Mul(0.7)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip10);

            PointInPoly pip11 = PolygonUtils.PointInPolyNonZero(points, p4.Add(p1.Sub(p4).Unit.Mul(0.3)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip11);

            PointInPoly pip12 = PolygonUtils.PointInPolyNonZero(points, p1.Add(p3.Sub(p1).Unit.Mul(0.7)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip12);

            PointInPoly pip13 = PolygonUtils.PointInPolyNonZero(points, p1.Add(p3.Sub(p1).Unit.Mul(0.3)), true, true, MathUtils.EPSILON);

            Assert.AreEqual(PointInPoly.On, pip13);
        }
コード例 #4
0
ファイル: bool3d.cs プロジェクト: thild/sawdust
        public static void PartitionFace_RemoveObvious(List <seg3d> segs, Face f1, Solid s2, bsp3d bsp2, bool reverse)
        {
            List <seg3d> rm = new List <seg3d>();

            foreach (seg3d s in segs)
            {
                PointInPoly pip_a = bsp2.PointInPolyhedron(s.a);
                if (pip_a == PointInPoly.Coincident)
                {
                    break;
                }
                PointInPoly pip_b = bsp2.PointInPolyhedron(s.b);
                if (pip_b == PointInPoly.Coincident)
                {
                    break;
                }

                if (pip_a != pip_b)
                {
                    break;
                }

#if false // coverage says this never gets hit
                bool bNone = true;
                foreach (Face f2 in s2.Faces)
                {
                    if (f2.SegmentTouches(s))
                    {
                        // coverage says this line is never hit
                        // which may mean this entire check is
                        // unneeded.
                        bNone = false;
                        break;
                    }
                }
                if (bNone)
#endif
                {
                    bool bKeep = false;
                    if (s2.PointInside(bsp2, s.b))
                    {
                        bKeep = false;
                    }
                    else
                    {
                        bKeep = true;
                    }
                    if (reverse)
                    {
                        bKeep = !bKeep;
                    }
                    if (!bKeep)
                    {
                        rm.Add(s);
                    }
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
        }