示例#1
0
        public static float AutoScale(this ObjectDimensions dimensions, float maxSize)
        {
            float   scale = 0f;
            Vector3 size  = dimensions.Size;

            scale = GetScaleByComponent(scale, size.X, maxSize);
            scale = GetScaleByComponent(scale, size.Y, maxSize);
            scale = GetScaleByComponent(scale, size.Z, maxSize);
            if (scale == 0f)
            {
                scale = 1f;
            }
            return(scale);
        }
示例#2
0
        public static Slice GetSkirt(this Model model, float scale, SlicerOptions options)
        {
            Slice            slice         = new Slice();
            SlicePart        part          = new SlicePart();
            ObjectDimensions dimensions    = model.Dimensions;
            Vector3          minPoint      = dimensions.MinPoint;
            Vector3          maxPoint      = dimensions.MaxPoint;
            float            skirtDistance = options.Skirt.Distance / scale;
            float            skirtZ        = dimensions.MinPoint.Z + options.Printer.ExtruderDiameter / 2;

            part.Points.Add(new Vector3(minPoint.X - skirtDistance / 2, minPoint.Y - skirtDistance, skirtZ)); // 0
            part.Normals.Add(-Vector3.UnitY);

            part.Points.Add(new Vector3(maxPoint.X + skirtDistance / 2, minPoint.Y - skirtDistance, skirtZ)); // 1
            part.Normals.Add((Vector3.UnitX - Vector3.UnitY).Normalized());

            part.Points.Add(new Vector3(maxPoint.X + skirtDistance, minPoint.Y - skirtDistance / 2, skirtZ)); // 2
            part.Normals.Add(Vector3.UnitX);

            part.Points.Add(new Vector3(maxPoint.X + skirtDistance, maxPoint.Y + skirtDistance / 2, skirtZ)); // 3
            part.Normals.Add((Vector3.UnitX + Vector3.UnitY).Normalized());

            part.Points.Add(new Vector3(maxPoint.X + skirtDistance / 2, maxPoint.Y + skirtDistance, skirtZ)); // 4
            part.Normals.Add(Vector3.UnitY);

            part.Points.Add(new Vector3(minPoint.X - skirtDistance / 2, maxPoint.Y + skirtDistance, skirtZ)); // 5
            part.Normals.Add((-Vector3.UnitX + Vector3.UnitY).Normalized());

            part.Points.Add(new Vector3(minPoint.X - skirtDistance, maxPoint.Y + skirtDistance / 2, skirtZ)); // 6
            part.Normals.Add(-Vector3.UnitX);

            part.Points.Add(new Vector3(minPoint.X - skirtDistance, minPoint.Y - skirtDistance / 2, skirtZ)); // 7
            part.Normals.Add((-Vector3.UnitX - Vector3.UnitY).Normalized());

            part.Closed = true;
            slice.Parts.Add(part);
            return(slice);
        }