コード例 #1
0
        private void SliceMesh(PrintMeshAssembly meshes, out PlanarSliceStack slices)
        {
            logger?.WriteLine("Slicing...");

            // Do slicing
            MeshPlanarSlicer slicer = new MeshPlanarSlicer()
            {
                LayerHeightMM = Settings.LayerHeightMM
            };

            slicer.Add(meshes);
            slices = slicer.Compute();
        }
コード例 #2
0
        protected virtual void SliceMesh(PrintMeshAssembly meshes, out PlanarSliceStack slices, double layerHeight)
        {
            logger?.WriteLine("Slicing...");

            // Do slicing
            MeshPlanarSlicer slicer = new MeshPlanarSlicer()
            {
                LayerHeightMM = layerHeight,
            };

            slicer.Add(meshes);
            slices = slicer.Compute();
        }
コード例 #3
0
        public GCodeFile GenerateGCode(IList <Tuple <DMesh3, TPrintSettings> > parts,
                                       TPrintSettings globalSettings,
                                       out IEnumerable <string> generationReport,
                                       Action <GCodeLine> gcodeLineReadyF = null,
                                       Action <string> progressMessageF   = null)
        {
            if (AcceptsParts == false && parts != null && parts.Count > 0)
            {
                throw new Exception("Must pass null or empty list of parts to generator that does not accept parts.");
            }

            // Create print mesh set
            PrintMeshAssembly meshes = new PrintMeshAssembly();

            foreach (var part in parts)
            {
                if (part.Item2 != null)
                {
                    throw new ArgumentException($"Entries for the `parts` arguments must have a null second item since this generator does not handle per-part settings.");
                }
                meshes.AddMesh(part.Item1, PrintMeshOptions.Default());
            }

            progressMessageF?.Invoke("Slicing...");

            // Do slicing
            MeshPlanarSlicer slicer = new MeshPlanarSlicer()
            {
                LayerHeightMM = globalSettings.LayerHeightMM
            };

            slicer.Add(meshes);
            PlanarSliceStack slices = slicer.Compute();

            // Run the print generator
            progressMessageF?.Invoke("Running print generator...");
            var printGenerator = new TPrintGenerator();
            AssemblerFactoryF overrideAssemblerF = globalSettings.AssemblerType();

            printGenerator.Initialize(meshes, slices, globalSettings, overrideAssemblerF);

            if (printGenerator.Generate())
            {
                generationReport = printGenerator.GenerationReport;
                return(printGenerator.Result);
            }
            else
            {
                throw new Exception("PrintGenerator failed to generate gcode!");
            }
        }