コード例 #1
0
ファイル: test_bool3d.cs プロジェクト: thild/sawdust
        public void test_cuts_naming()
        {
            for (int i = 0; i < 100; i++)
            {
                Solid s1 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "b1", 10, 24, 2);
                Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.PLYWOOD_OAK), "cut", 14, 2, 2);
                s2.Translate(-1, 8, 1);
                Solid s3 = bool3d.Subtract(s1, s2);

                Face f = s3.FindFace("btop");
                Assert.IsNull(f);

                Face f1 = s3.FindFace("top_1");
                Face f2 = s3.FindFace("top_2");

                Assert.IsNotNull(f1);
                Assert.IsNotNull(f2);

                //ut.DumpPoly3d("f1", f1.MainLoop.CollectAllVertices());
                //ut.DumpPoly3d("f2", f2.MainLoop.CollectAllVertices());

                PointFaceIntersection pfi1 = f1.CalcPointFaceIntersection(new xyz(0, 0, 0));
                Assert.AreEqual(PointFaceIntersection.OnEdge, pfi1);

                PointFaceIntersection pfi2 = f2.CalcPointFaceIntersection(new xyz(0, 0, 0));
                Assert.AreEqual(PointFaceIntersection.None, pfi2);
            }
        }
コード例 #2
0
ファイル: bool3d.cs プロジェクト: thild/sawdust
        public static void PartitionFace_HandleCoplanarStuff(List <seg3d> segs, Face f1, Solid s2, bool reverse)
        {
            List <seg3d> rm = new List <seg3d>();

#if false // I think we *should* need this, but coverage says it never gets hit, so I am removing it for now.
            foreach (seg3d s in segs)
            {
                PointFaceIntersection pfi_a = f1.CalcPFI(s.a);
                PointFaceIntersection pfi_b = f1.CalcPFI(s.b);

                if (
                    (
                        (pfi_a == PointFaceIntersection.None) &&
                        (pfi_b == PointFaceIntersection.OnEdge)
                    )
                    ||
                    (
                        (pfi_a == PointFaceIntersection.OnEdge) &&
                        (pfi_b == PointFaceIntersection.None)
                    )
                    )
                {
                    rm.Add(s);
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
#endif

            if (segs.Count > 0)
            {
                rm.Clear();
                xyz n1 = f1.UnitNormal();
                for (int ndx_f2 = 0; ndx_f2 < s2.Faces.Count; ndx_f2++)
                {
                    Face f2 = s2.Faces[ndx_f2];
                    if (
                        fp.eq_unitvec(f2.UnitNormal(), n1) &&
                        f1.IsCoPlanarWith(f2)
                        )
                    {
                        foreach (seg3d s in segs)
                        {
                            PointFaceIntersection pfi_a = f2.CalcPFI(s.a);
                            PointFaceIntersection pfi_b = f2.CalcPFI(s.b);

                            if (
                                (
                                    (pfi_a == PointFaceIntersection.Inside) &&
                                    (pfi_b == PointFaceIntersection.OnEdge)
                                )
                                ||
                                (
                                    (pfi_a == PointFaceIntersection.OnEdge) &&
                                    (pfi_b == PointFaceIntersection.Inside)
                                )
                                )
                            {
                                rm.Add(s);
                            }
                        }
                    }
                }
                foreach (seg3d s in rm)
                {
                    segs.Remove(s);
                }
            }
        }