Example #1
0
        public Dovetail(string _id, string _path1, string _path2, int _numtails, Inches _tailwidth_specified, CompoundSolid _cs1, Solid _s1, Face _f1, HalfEdge _he1, CompoundSolid _cs2, Solid _s2, Face _f2, HalfEdge _he2)
        {
            id    = _id;
            path1 = _path1;
            path2 = _path2;

            orig_cs1 = _cs1;

            orig_cs2 = _cs2;

            numtails = _numtails;

            boardwidth = _he1.Length();

            if (fp.eq_inches(_tailwidth_specified, 0))
            {
                tailwidth_bottom = boardwidth / (numtails * 2);
                gapwidth_bottom  = tailwidth_bottom;
            }
            else
            {
                tailwidth_bottom = _tailwidth_specified;
                gapwidth_bottom  = (boardwidth - numtails * tailwidth_bottom) / (numtails);
            }

            gapwidth_top  = gapwidth_bottom - 2 * (tailwidth_bottom / slope);
            tailwidth_top = tailwidth_bottom + 2 * (tailwidth_bottom / slope);
        }
Example #2
0
        public static void FindActualEdge(HalfEdge he, out HalfEdge he1, out double length)
        {
            EdgeLoop el  = he.face.GetEdgeLoopFor(he);
            int      ndx = el.IndexOf(he);

            while (true)
            {
                HalfEdge h = el[el.FixIndex(ndx - 1)];
                if (ut.PointsAreCollinear3d(h.from, h.to, he.to))
                {
                    ndx--;
                }
                else
                {
                    break;
                }
            }
            he1 = el[ndx];
            double len = he1.Length();

            while (true)
            {
                HalfEdge h = el[++ndx];
                if (ut.PointsAreCollinear3d(he1.from, he1.to, h.to))
                {
                    len += h.Length();
                }
                else
                {
                    break;
                }
            }
            length = len;
        }
Example #3
0
        private static void CreateFaceLabel(Viewport3D myVP, Face f, TranslateTransform3D ttmove)
        {
            HalfEdge he   = f.FindLongestEdge();
            xyz      p1   = he.Center();
            xyz      p2   = f.Measure(he, p1);
            xyz      v    = p2 - p1;
            double   dist = v.magnitude();
            xyz      c    = p1 + v / 2;

            c += f.UnitNormal() * .001;
            Point3D  center = wpfmisc.fixPoint(c);
            Vector3D over   = wpfmisc.fixVector(he.UnitVector());
            Vector3D up     = wpfmisc.fixVector(he.GetInwardNormal());

            double height;

            if (dist <= 1)
            {
                height = dist / 3;
            }
            else if (dist < 10)
            {
                height = 1;
            }
            else
            {
                height = 2;
            }

            // TODO the following isn't a very pretty hack
            if (f.name.Length * height > he.Length())
            {
                height = he.Length() / f.name.Length;
            }

            ModelVisual3D mv3d = wpfmisc.CreateTextLabel3D(f.name, Brushes.Black, false, height, center, over, up);

            if (ttmove != null)
            {
                mv3d.Transform = ttmove;
            }
            myVP.Children.Add(mv3d);
        }
Example #4
0
        public static CompoundSolid Tenon(CompoundSolid sol, HalfEdge he, xy pos, xyz size, string id)
        {
            Face f = he.face;

            EdgeLoop el  = he.face.GetEdgeLoopFor(he);
            int      ndx = el.IndexOf(he);

            ndx--;
            if (ndx < 0)
            {
                ndx += el.Count;
            }
            HalfEdge prevHe = el[ndx];

            if (!fp.eq_inches(pos.y, 0))
            {
                Solid cut = CreateCutter_Box(id, he, new xy(0, 0), new xyz(he.Length(), pos.y, size.z),
                                             new string[] { "NA_1", "NA_2", "NA_3", "frontshoulder", "NA_4", "front" });
                sol = bool3d.Subtract(sol, cut);
            }
            if (!fp.eq_inches(pos.x, 0))
            {
                Solid cut = CreateCutter_Box(id, he, new xy(0, pos.y), new xyz(pos.x, size.y, size.z),
                                             new string[] { "NA_1", "left", "NA_2", "leftshoulder", "NA_3", "NA_4" });
                sol = bool3d.Subtract(sol, cut);
            }
            if ((pos.y + size.y) < prevHe.Length())
            {
                Solid cut = CreateCutter_Box(id, he, new xy(0, pos.y + size.y), new xyz(he.Length(), prevHe.Length() - (pos.y + size.y), size.z),
                                             new string[] { "NA_1", "NA_2", "NA_3", "backshoulder", "back", "NA_4" });
                sol = bool3d.Subtract(sol, cut);
            }
            if ((pos.x + size.x) < he.Length())
            {
                Solid cut = CreateCutter_Box(id, he, new xy((pos.x + size.x), pos.y), new xyz(he.Length() - (pos.x + size.x), size.y, size.z),
                                             new string[] { "NA_1", "NA_2", "right", "rightshoulder", "NA_3", "NA_4" });
                sol = bool3d.Subtract(sol, cut);
            }
            return(sol);
        }
Example #5
0
        public void test_measure()
        {
            Solid    s  = wood.CreateBoard(BoardMaterial.Find(BoardMaterial.SOLID_OAK_RED), "a", 10, 24, 1);
            Face     f  = s.FindFace("top");
            HalfEdge he = f.FindLongestEdge();

            Assert.IsTrue(fp.eq_inches(24, he.Length()));
            xyz p1 = he.Center();
            xyz p2 = f.Measure(he, p1);
            xyz q  = p2 - p1;

            Assert.IsTrue(fp.eq_inches(10, q.magnitude()));

            CompoundSolid cs = wood.Mortise(s.ToCompoundSolid(), he, new xy(3, 3), new xyz(18, 4, 2), "m1");

            f = cs.FindFace("a.top");
            Assert.AreEqual(2, f.loops.Count);
            he = f.FindLongestEdge();
            Assert.IsTrue(fp.eq_inches(24, he.Length()));
            p1 = he.Center();
            p2 = f.Measure(he, p1);
            q  = p2 - p1;
            Assert.IsTrue(fp.eq_inches(3, q.magnitude()));
        }
Example #6
0
        public static CompoundSolid Dado(CompoundSolid sol, HalfEdge heParallel, Inches distFromParallelEdge, Inches width, Inches depth, string id)
        {
            Face f = heParallel.face;

            string[] fnames = new string[] {
                "top",
                "right",
                "left",
                "bottom",
                "side_above",
                "side_below"
            };

            // TODO should we move left or right further?  what if the dado needs to be longer than this edge?  or shorter?

            Solid cutter = CreateCutter_Box(id, heParallel, new xy(0, distFromParallelEdge), new xyz(heParallel.Length(), width, depth), fnames);

            return(bool3d.Subtract(sol, cutter));
        }