Beispiel #1
0
        public void test_tenon_methods()
        {
            CompoundSolid sol = Builtin_Solids.CreateCube("c", 5).ToCompoundSolid();
            CompoundSolid t1  = wood.Tenon(sol, sol.FindFace("c.top").MainLoop[0], new xy(1, 2), new xyz(3, 1, 1), "t1");

            Assert.IsTrue(fp.eq_volume(t1.Volume(), 125 - 25 + 3));
            t1.DoGeomChecks();
        }
Beispiel #2
0
        public void test1()
        {
            Solid s1  = Builtin_Solids.CreateCube("s1", 5);
            bsp3d bsp = new bsp3d(s1);

            Assert.AreEqual(PointInPoly.Inside, bsp.PointInPolyhedron(new xyz(1, 1, -1)));
            Assert.AreEqual(PointInPoly.Outside, bsp.PointInPolyhedron(new xyz(6, 6, -6)));
        }
Beispiel #3
0
        public void test_subtract_self()
        {
            Solid c1      = Builtin_Solids.CreateCube("c1", 5);
            Solid nothing = bool3d.Subtract(c1, c1);

            Assert.AreEqual(0, nothing.Faces.Count);
            Assert.AreEqual(0, nothing.Vertices.Count);
            Assert.AreEqual(0, nothing.Edges.Count);
        }
Beispiel #4
0
        public void test_drill_and_mortise_intersect()
        {
            CompoundSolid sol = Builtin_Solids.CreateCube("c", 5).ToCompoundSolid();

            sol = wood.Drill(sol, sol.FindFace("c.top").FindEdge("end1"), 2.5, 2.5, 1, 0, 0, 4, 8, "d1");
            sol = wood.Mortise(sol, sol.FindFace("c.end1").FindEdge("top"), new xy(1, 1), new xyz(3, 3, 8), "m");

            sol.DoGeomChecks();
        }
Beispiel #5
0
        public void test_tenon_tetrahedron()
        {
            CompoundSolid sol = (CompoundSolid)Builtin_Solids.CreateTetrahedron("t", 10);
            Face          f   = sol[0].Faces[0];
            HalfEdge      he  = f.MainLoop[0];

            sol = wood.Tenon_OneCutMethod(sol, he, new xy(3, 3), new xyz(1, 1, 1), "t1");
            sol.DoGeomChecks();
        }
Beispiel #6
0
        public void test_cut_with_overlaps()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = Builtin_Solids.CreateCube("s2", 8);

            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
        }
Beispiel #7
0
        public void test_lop_off_half_a_cube()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = Builtin_Solids.CreateCube("s2", 20);

            s2.Translate(7, -2, -2);
            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
        }
Beispiel #8
0
        public void test_rot_cube(double rot)
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = Builtin_Solids.CreateCube("s2", 8);

            s2.Rotate_Deg(rot, new xyz(0, 0, 0), new xyz(0, 0, 1));
            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
        }
Beispiel #9
0
        public void test_three_mortises_in_a_cube()
        {
            CompoundSolid sol = Builtin_Solids.CreateCube("c", 5).ToCompoundSolid();

            sol = wood.Mortise(sol, sol.FindFace("c.top").FindEdge("end1"), new xy(1, 1), new xyz(3, 3, 8), "m1");
            sol = wood.Mortise(sol, sol.FindFace("c.right").FindEdge("top"), new xy(1, 1), new xyz(3, 3, 8), "m2");
            sol = wood.Mortise(sol, sol.FindFace("c.end1").FindEdge("top"), new xy(1, 1), new xyz(3, 3, 8), "m3");

            sol.DoGeomChecks();
        }
Beispiel #10
0
        public void cylinder_1()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = wood.CreateCylinder("cyl", 4, 20, 30);

            s2.Translate(0, -1, -3);

            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
        }
Beispiel #11
0
        public void rotated_cube_30_outdent()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = Builtin_Solids.CreateCube("s2", 8);

            s2.Rotate_Deg(30, new xyz(0, 0, 0), new xyz(0, 0, 1));
            s2.Translate(0, 0, -1);
            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
        }
Beispiel #12
0
        public void test_seginside_thing()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut2", 6, 6, 6);

            s2.Translate(2, 2, -1);
            Solid s3 = bool3d.Subtract(s1, s2);

            bsp3d bsp = new bsp3d(s3);

            bool b = s3.SegmentInside(bsp, new xyz(5, 2, 2), new xyz(8, 2, 2));
        }
Beispiel #13
0
        public void test_subtract_mortise()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = Builtin_Solids.CreateCube("s2", 4);

            s2.Translate(2, 2, -2);

            double volume1 = s1.Volume();
            Solid  s3      = bool3d.Subtract(s1, s2);
            double volume2 = s3.Volume();

            s3.DoGeomChecks();
            Assert.Less(volume2, volume1);
        }
Beispiel #14
0
        public void test_subtract_through_mortise()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut", 2, 2, 20);

            s2.Translate(2, 2, -2);

            double volume1 = s1.Volume();
            Solid  s3      = bool3d.Subtract(s1, s2);
            double volume2 = s3.Volume();

            s3.DoGeomChecks();
            Assert.Less(volume2, volume1);
        }
Beispiel #15
0
        public void test_two_mortises_connect_harder()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut2", 6, 6, 6);

            s2.Translate(2, 2, -1);
            Solid sj = bool3d.Subtract(s1, s2);

            Solid s3 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut3", 6, 6, 6);

            s3.Translate(5, 2, 2);
            Solid sk = bool3d.Subtract(sj, s3);

            sk.DoGeomChecks();
        }
Beispiel #16
0
        public void test_subtract_nothing_4()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = Builtin_Solids.CreateCube("s2", 10);

            s2.Translate(50, 0, 0);

            const double vol = 10 * 10 * 10;

            Assert.IsTrue(fp.eq_volume(s1.Volume(), vol));
            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
            Assert.IsTrue(fp.eq_volume(s3.Volume(), vol));
        }
Beispiel #17
0
        public void test_two_through_mortises_same_face()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut", 2, 2, 20);

            s2.Translate(2, 2, -2);
            Solid s3 = bool3d.Subtract(s1, s2);

            Solid s4 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut2", 2, 2, 20);

            s4.Translate(7, 7, -2);
            Solid s5 = bool3d.Subtract(s3, s4);

            s5.DoGeomChecks();
        }
Beispiel #18
0
        public void test_subtract()
        {
            Solid  s1      = Builtin_Solids.CreateCube("s1", 10);
            double volume1 = s1.Volume();
            Solid  s2      = Builtin_Solids.CreateCube("s2", 8);

            s2.Translate(4, 4, -4);

            Solid s3 = bool3d.Subtract(s1, s2);

            s3.DoGeomChecks();
            double volume2 = s3.Volume();

            Assert.IsTrue(fp.eq_volume(volume2, 784));
            Assert.AreEqual(9, s3.Faces.Count);
        }
Beispiel #19
0
        public void test_two_mortises_that_connect()
        {
            Solid s1 = Builtin_Solids.CreateCube("s1", 10);
            Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut", 6, 6, 6);

            s2.Translate(2, 2, -1);

            Solid s3 = bool3d.Subtract(s1, s2);

            Solid s4 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut2", 6, 6, 6);

            s4.Translate(5, 3, 2);

            Solid s5 = bool3d.Subtract(s3, s4);

            s5.DoGeomChecks();
        }
Beispiel #20
0
        public void test_dado_and_through_mortise()
        {
            for (int i = 0; i < 10; i++)
            {
                Solid s1 = Builtin_Solids.CreateCube("s1", 10);
                Solid s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut_s2", 2, 2, 20);
                s2.Translate(2, -1, -2);

                Solid s3 = bool3d.Subtract(s1, s2);

                Solid s4 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "cut_s4", 2, 2, 20);
                s4.Translate(7, 7, -2);

                Solid s5 = bool3d.Subtract(s3, s4);
                s5.DoGeomChecks();
            }
        }
Beispiel #21
0
        public void test_overlapping_mortises()
        {
            Solid s1 = Builtin_Solids.CreateCube("c1", 8);

            Solid s2a = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "s2a", 2, 2, 12);

            s2a.Translate(1, 1, 0);

            Solid s3 = bool3d.Subtract(s1, s2a);

            Assert.IsTrue(fp.eq_volume(s3.Volume(), 8 * 8 * 8 - 2 * 2 * 8));

            Solid s2b = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "s2b", 2, 2, 12);

            s2b.Translate(2, 2, 1);
            Solid s4 = bool3d.Subtract(s3, s2b);

            Assert.IsTrue(fp.eq_volume(s4.Volume(), 8 * 8 * 8 - 2 * 2 * 8 - 2 * 2 * 8 + 1 * 1 * 8));
        }
Beispiel #22
0
        public void test_cube()
        {
            Solid         s1  = Builtin_Solids.CreateCube("s1", 5);
            bsp3d         bsp = new bsp3d(s1);
            BoundingBox3d bb  = BoundingBox3d.FromArrayOfPoints(s1.Vertices);

            foreach (xyz v in s1.Vertices)
            {
                Assert.AreEqual(PointInPoly.Coincident, bsp.PointInPolyhedron(v));
                Assert.IsTrue(bb.PointInside(v));
            }
            foreach (Face f in s1.Faces)
            {
                xyz v = f.GetCenter();
                xyz n = f.UnitNormal();
                Assert.AreEqual(PointInPoly.Coincident, bsp.PointInPolyhedron(v));
                Assert.AreEqual(PointInPoly.Outside, bsp.PointInPolyhedron(v + n));
                Assert.AreEqual(PointInPoly.Inside, bsp.PointInPolyhedron(v - n));
                Assert.IsTrue(bb.PointInside(v));
                Assert.IsFalse(bb.PointInside(v + n));
                Assert.IsTrue(bb.PointInside(v - n));
            }
            foreach (Face f in s1.Faces)
            {
                foreach (HalfEdge h in f.MainLoop)
                {
                    xyz v = h.Center();
                    xyz n = h.GetInwardNormal();
                    Assert.IsTrue(bb.PointInside(v));
                    Assert.IsTrue(bb.PointInside(v + n));
                    Assert.IsFalse(bb.PointInside(v - n));
                    Assert.AreEqual(PointInPoly.Coincident, bsp.PointInPolyhedron(v));
                    Assert.AreEqual(PointInPoly.Coincident, bsp.PointInPolyhedron(v + n));
                    Assert.AreEqual(PointInPoly.Outside, bsp.PointInPolyhedron(v - n));
                }
            }
            Assert.AreEqual(PointInPoly.Inside, bsp.PointInPolyhedron(s1.GetCenter()));
            Assert.IsTrue(bb.PointInside(s1.GetCenter()));
        }
Beispiel #23
0
        public void test_tenon_formerly_1cut()
        {
            CompoundSolid sol = Builtin_Solids.CreateCube("c", 5).ToCompoundSolid();

            sol = wood.Tenon(sol, sol.FindFace("c.top").MainLoop[0], new xy(1, 2), new xyz(3, 1, 1), "t1");
            Assert.IsTrue(fp.eq_volume(sol.Volume(), 125 - 25 + 3));

            sol = Builtin_Solids.CreateCube("c", 5).ToCompoundSolid();
            Face f = sol[0].Faces[3];

            sol = wood.Tenon(sol, sol.FindFace("c.top").MainLoop[0], new xy(1, 2), new xyz(3, 1, 1), "t2");
            Assert.IsTrue(fp.eq_volume(sol.Volume(), 125 - 25 + 3));

            sol = Builtin_Solids.CreateCube("c", 5).ToCompoundSolid();
            Solid cut = Builtin_Solids.CreateCube("d", 5);

            cut.Translate(3, 3, -1);
            sol = bool3d.Subtract(sol, cut);

            sol = wood.Tenon(sol, sol.FindFace("c.top").MainLoop[0], new xy(1, 1), new xyz(1, 1, 1), "t3");
            sol.DoGeomChecks();
        }
Beispiel #24
0
        public void test_CheckIfTwoSolidsShareAnySpace()
        {
            Solid s1;
            Solid s2;

            // two identical cubes
            s1 = Builtin_Solids.CreateCube("c1", 5);
            s1.Translate(-(s1.board_origin.x), -(s1.board_origin.y), -(s1.board_origin.z));

            s2 = Builtin_Solids.CreateCube("c2", 5);
            check_share(s1, s2, true);

            // offset and overlapping
            s2.Translate(1, 1, 1);
            check_share(s1, s2, true);

            // too far apart
            s2.Translate(9, 9, 9);
            check_share(s1, s2, false);

            // sharing a face
            s2 = Builtin_Solids.CreateCube("c2", 5);
            s2.Translate(5, 0, 0);
            check_share(s1, s2, false);

            // sharing an edge
            s2 = Builtin_Solids.CreateCube("c2", 5);
            s2.Translate(5, 5, 0);
            check_share(s1, s2, false);

            // sharing one vertex
            s2 = Builtin_Solids.CreateCube("c2", 5);
            s2.Translate(5, 5, 5);
            check_share(s1, s2, false);

            // one smaller, inside the other, sharing faces
            s2 = Builtin_Solids.CreateCube("c2", 3);
            s2.Translate(-(s2.board_origin.x), -(s2.board_origin.y), -(s2.board_origin.z));
            check_share(s1, s2, true);

            // inside the other, not touching
            s2.Translate(1, 1, 1);
            check_share(s1, s2, true);

            s2 = Builtin_Solids.CreatePyramid("c2", 3, 5);
            check_share(s1, s2, true);
            s2.Translate(1, 1, 0);
            check_share(s1, s2, true);
            s2.Translate(0, 0, -5);
            check_share(s1, s2, false);
            s2.Translate(0, 0, 0.25);
            check_share(s1, s2, true);

            s2 = Builtin_Solids.CreatePyramid("c2", 3, 6);
            check_share(s1, s2, true);
            s2.Translate(1, 1, -0.5);
            check_share(s1, s2, true);

            // long stick and a cube
            s2 = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "c2", 2, 2, 12);
            check_share(s1, s2, true);
            s2.Translate(0, 0, -1);
            check_share(s1, s2, true);
            s2.Translate(1, 1, 0);
            check_share(s1, s2, true);

            Plan p = test_plan.CreateCubeIntoHole();

            p.Execute();
            s1 = p.Result.FindSub("c");
            s2 = p.Result.FindSub("b");
            check_share(s1, s2, false);
        }