Example #1
0
        public static Slice GetSlice(this Model model, float z, SlicerOptions options)
        {
            Slice slice = new Slice();

            foreach (Facet facet in model.Facets)
            {
                PlanePosition position = facet.GetPlanePosition(z);
                if (position == PlanePosition.Intersect)
                {
                    List <Vector3> points = facet.GetSection(z);
                    if (points.Count == 2)
                    {
                        slice.AddSection(points[0], points[1], facet.Normal);
                    }
                }
            }
            slice.Join();
            slice.Simplify(options.Slice.SimplifyDistance);
            if (options.Slice.Flatten)
            {
                slice.Flatten(options.Slice.FlattenTolerance);
            }
            return(slice);
        }
Example #2
0
        public void AddSection()
        {
            slice.AddSection(Vector3.Zero, Vector3.UnitX, Vector3.UnitY);

            Assert.AreEqual(1, slice.Parts.Count);
            Assert.AreEqual(2, slice.Parts[0].Points.Count);
            Assert.AreEqual(2, slice.Parts[0].Normals.Count);
        }