コード例 #1
0
 public ThreeDControl()
 {
     models = new LinkedList<ThreeDModel>();
     InitializeComponent();
     toolAutoupdate.Visible = autoupdateable;
     toolStripClear.Visible = autoupdateable;
     Application.Idle += Application_Idle;
     STL m1 = new STL();
     viewCenter = new Vector3(0, 0, 0);
     rotX = 20;
     userPosition = new Vector3(0, -2f * ps.PrintAreaDepth, 0.0f * ps.PrintAreaHeight);
     gl.MouseWheel += gl_MouseWheel;
 }
コード例 #2
0
 private void buttonAddSTL_Click(object sender, EventArgs e)
 {
     if (openFileSTL.ShowDialog() == DialogResult.OK)
     {
         STL stl = new STL();
         stl.Load(openFileSTL.FileName);
         if (stl.list.Count > 0)
         {
             listSTLObjects.Items.Add(stl);
             cont.models.AddLast(stl);
             listSTLObjects.SelectedItem = stl;
         }
     }
 }
コード例 #3
0
 public void openAndAddObject(string file)
 {
     STL stl = new STL();
         stl.Load(file);
         stl.Center(Main.printerSettings.PrintAreaWidth / 2, Main.printerSettings.PrintAreaDepth / 2);
         stl.Land();
         if (stl.list.Count > 0)
         {
             listSTLObjects.Items.Add(stl);
             cont.models.AddLast(stl);
             listSTLObjects.SelectedItem = stl;
             stl.addAnimation(new DropAnimation("drop"));
             updateSTLState(stl);
         }
 }
コード例 #4
0
ファイル: BlockBatchView.cs プロジェクト: veggielane/BlockRTS
        public void Load()
        {
            _shader = _assets.Shader<BlockShaderProgram>();

            var stl = new STL("chamfer_cube.stl", Color.Yellow);
            var cubedata = new List<float>();

            foreach (var vertex in stl.ToMesh().Vertices)
            {
                cubedata.Add((float)vertex.Position.X);
                cubedata.Add((float)vertex.Position.Y);
                cubedata.Add((float)vertex.Position.Z);
            }
            foreach (var vertex in stl.ToMesh().Vertices)
            {
                cubedata.Add((float)vertex.Normal.X);
                cubedata.Add((float)vertex.Normal.Y);
                cubedata.Add((float)vertex.Normal.Z);
            }

            _squareVertices = cubedata.ToArray();

            GL.GenVertexArrays(1, out _squareVao);
            GL.GenBuffers(1, out _squareVbo);
            GL.BindVertexArray(_squareVao);
            GL.BindBuffer(BufferTarget.ArrayBuffer, _squareVbo);

            GL.EnableVertexAttribArray(0);
            GL.EnableVertexAttribArray(1);
            GL.EnableVertexAttribArray(2);
            GL.EnableVertexAttribArray(3);
            GL.EnableVertexAttribArray(4);

            GL.Arb.VertexAttribDivisor(2, 1);//position
            GL.Arb.VertexAttribDivisor(3, 1);//rotation
            GL.Arb.VertexAttribDivisor(4, 1);//color

            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.VertexAttribPointer(2, 3, VertexAttribPointerType.Float, false, 11 * sizeof(float), _squareVertices.Length * sizeof(float));
            GL.VertexAttribPointer(3, 4, VertexAttribPointerType.Float, false, 11 * sizeof(float), (_squareVertices.Length + 3) * sizeof(float));
            GL.VertexAttribPointer(4, 4, VertexAttribPointerType.Float, false, 11 * sizeof(float), (_squareVertices.Length + 3 + 4) * sizeof(float));

            Loaded = true;
        }
コード例 #5
0
ファイル: PlanetView.cs プロジェクト: veggielane/ORTS
        public void Load()
        {
            //GL.PolygonMode(MaterialFace.FrontAndBack,PolygonMode.Line);
            var model = new STL("Models/test-bin.stl", STLFormat.Binary);
            GL.NewList(list, ListMode.Compile);
            GL.Begin(BeginMode.Triangles);

            foreach (var element in model.Elements)
            {
                GL.Normal3(element.Normal.ToVector3());
                GL.Vertex3(element.P1.ToVector3());
                GL.Vertex3(element.P2.ToVector3());
                GL.Vertex3(element.P3.ToVector3());
            }

            GL.End();
            GL.EndList();
               Loaded = true;
        }
コード例 #6
0
 public ThreeDControl()
 {
     models = new LinkedList<ThreeDModel>();
     InitializeComponent();
     toolStripClear.Visible = autoupdateable;
     //Application.Idle += Application_Idle;
     STL m1 = new STL();
     viewCenter = new Vector3(0, 0, 0);
     rotX = 20;
     userPosition = new Vector3(0, -1.7f * (float)Math.Sqrt(ps.PrintAreaDepth*ps.PrintAreaDepth+ps.PrintAreaWidth*ps.PrintAreaWidth), 0.0f * ps.PrintAreaHeight);
     gl.MouseWheel += gl_MouseWheel;
     // Controls.Remove(gl);
     timer.Start();
 }
コード例 #7
0
ファイル: STLComposer.cs プロジェクト: adambyram/pimaker
 /// <summary>
 /// Checks the state of the object.
 /// If it is outside print are it starts pulsing
 /// </summary>
 public void updateSTLState(STL stl)
 {
     FormPrinterSettings ps = Main.printerSettings;
     stl.UpdateBoundingBox();
     if (stl.xMin < ps.BedLeft || stl.yMin < ps.BedFront || stl.zMin < -0.001 || stl.xMax > ps.BedLeft+Main.printerSettings.PrintAreaWidth ||
         stl.yMax > ps.BedFront+Main.printerSettings.PrintAreaDepth || stl.zMax > Main.printerSettings.PrintAreaHeight)
     {
         stl.outside = true;
         if (Main.threeDSettings.pulseOutside.Checked && !stl.hasAnimationWithName("pulse"))
             stl.addAnimation(new PulseAnimation("pulse", 0.03, 0.03, 0.03, 0.3));
     }
     else
     {
         stl.outside = false;
         stl.removeAnimationWithName("pulse");
     }
 }
コード例 #8
0
ファイル: STLComposer.cs プロジェクト: shmorgan/Repetier-Host
 /// <summary>
 /// Checks the state of the object.
 /// If it is outside print are it starts pulsing
 /// </summary>
 public void updateSTLState(STL stl)
 {
     stl.UpdateBoundingBox();
     if (stl.xMin < 0 || stl.yMin < 0 || stl.zMin < -0.001 || stl.xMax > Main.printerSettings.PrintAreaWidth ||
         stl.yMax > Main.printerSettings.PrintAreaDepth || stl.zMax > Main.printerSettings.PrintAreaHeight)
     {
         if (!stl.hasAnimationWithName("pulse"))
             stl.addAnimation(new PulseAnimation("pulse", 0.05, 0.05, 0.05, 0.5));
     }
     else
     {
         stl.removeAnimationWithName("pulse");
     }
 }
コード例 #9
0
ファイル: Model.cs プロジェクト: Khalefa/models
        private void decompose(int n, int freq, double[] season_)
        {
            int swindow = 10 * n + 1;
            stllib.STL stl = new STL();
            double[] seaonal = new double[freq];
            int[] count = new int[freq];
            int limit = (int)Math.Ceiling((double)n / freq);
            this.freq = freq;
            this.len = n;
            unsafe
            {
                double* y = (double*)utils.Memory.Alloc(sizeof(double) * n);
                double* t = (double*)utils.Memory.Alloc(sizeof(double) * n);
                double* s = (double*)utils.Memory.Alloc(sizeof(double) * n);
                for (int i = 0; i < n; i++) y[i] = ts.data[i];
                stl.compute(y, n, freq, swindow, t, s);
                int k = 0;
                if (type == ModelType.Explicit || type == ModelType.Implicit)
                {
                    values = new double[limit];
                    for (int i = 0; i < limit; i++)
                    {
                        double t1 = 0;
                        double t2 = 0;
                        int l = 0;
                        for (int j = 0; j < freq; j++)
                        {
                            if (k == n) break;
                            l++;
                            k++;
                            t1 += ts.data[j + i * freq];
                            t2 += y[j + i * freq];
                        }
                        t1 /= l;
                        t2 /= l;
                        values[i] = (t2 + t1) / 2;
                    }
                }
                if (type == ModelType.Implicit)
                {
                    double[] x = ChebyshevReg.Solve(values);
                    values = new double[2];
                    values[0] = x[0];
                    values[1] = x[1];
                }
                else if (type == ModelType.Trend)
                {
                    double[] t_ = new double[n];
                    for (int i = 0; i < n; i++)
                    {
                        t_[i] = t[i];
                    }

                    double[] x = ChebyshevReg.Solve(t_);
                    values = new double[2];
                    values[0] = x[0];
                    values[1] = x[1];
                }
                //make seaonality perfect
                for (int i = 0; i < n; i++)
                {
                    seaonal[i % freq] += s[i];
                    count[i % freq]++;
                }
                for (int i = 0; i < freq; i++)
                {
                    season_[i] = seaonal[i % freq] / count[i % freq];
                }

                trend = new double[n];
                errors = new double[n];
                for (int i = 0; i < n; i++)
                {
                    trend[i] = t[i];
                    errors[i] = ts.data[i] - (t[i] + s[i % freq]);
                }

                utils.Memory.Free(y);
                utils.Memory.Free(s);
                utils.Memory.Free(t);
            }
        }
コード例 #10
0
ファイル: Slic3r.cs プロジェクト: RoyOnWheels/Repetier-Host
 public bool RunSliceNew(string file, float centerx, float centery)
 {
     if (procConvert != null)
     {
         MessageBox.Show(Trans.T("L_LAST_SLICE_RUNNING"), Trans.T("L_ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     string exe = findSlic3rExecutable();
     if (exe == null)
     {
         MessageBox.Show(Trans.T("L_SLIC3R_NOT_FOUND"), Trans.T("L_ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     FormPrinterSettings ps = Main.printerSettings;
     SlicingInfo.Start("Slic3r");
     SlicingInfo.SetAction(Trans.T("L_ANALYSING_STL"));
     try
     {
         STL stl = new STL();
         stl.Load(file);
         stl.UpdateBoundingBox();
         if (stl.xMin > ps.BedLeft && stl.yMin > ps.BedFront && stl.xMax < ps.BedLeft + ps.PrintAreaWidth && stl.yMax < ps.BedFront+ps.PrintAreaDepth)
         {
             // User assigned valid position, so we use this
             centerx = stl.xMin + (stl.xMax - stl.xMin) / 2;
             centery = stl.yMin + (stl.yMax - stl.yMin) / 2;
         }
         stl.Clear();
     }
     catch (Exception e)
     {
         Main.conn.log(e.ToString(), false, 2);
         SlicingInfo.Stop();
         return false;
     }
     SlicingInfo.SetAction(Trans.T("L_SLICING_STL"));
     string dir = Main.globalSettings.Workdir;
     string config = dir + Path.DirectorySeparatorChar + "slic3r.ini";
     string cdir = Main.main.slicerPanel.slic3rDirectory;
     IniFile ini = new IniFile();
     BasicConfiguration b = BasicConfiguration.basicConf;
     string fPrinter = cdir + Path.DirectorySeparatorChar + "print"+Path.DirectorySeparatorChar + b.Slic3rPrintSettings + ".ini";
     ini.read(fPrinter);
     IniFile ini2 = new IniFile();
     ini2.read(cdir + Path.DirectorySeparatorChar + "printer" +Path.DirectorySeparatorChar+ b.Slic3rPrinterSettings + ".ini");
     IniFile ini3 = new IniFile();
     ini3.read(cdir + Path.DirectorySeparatorChar + "filament"+Path.DirectorySeparatorChar + b.Slic3rFilamentSettings + ".ini");
     IniFile ini3_2 = new IniFile();
     ini3_2.read(cdir + Path.DirectorySeparatorChar + "filament" + Path.DirectorySeparatorChar + b.Slic3rFilament2Settings + ".ini");
     IniFile ini3_3 = new IniFile();
     ini3_3.read(cdir + Path.DirectorySeparatorChar + "filament" + Path.DirectorySeparatorChar + b.Slic3rFilament3Settings + ".ini");
     ini3.merge(ini3_2);
     ini3.merge(ini3_3);
     ini.add(ini2);
     ini.add(ini3);
     ini.flatten();
     ini.write(config);
     procConvert = new Process();
     try
     {
         string basedir = (string)Main.main.repetierKey.GetValue("installPath", "");
         /*string exname = "slic3r.exe";
         if (Environment.OSVersion.Platform == PlatformID.Unix)
             exname = "slic3r.pl";
         if (Main.IsMac)
             exname = "MacOS" + Path.DirectorySeparatorChar + "slic3r";
         string exe = basedir + Path.DirectorySeparatorChar + "Slic3r" + Path.DirectorySeparatorChar + exname;
         if (File.Exists(BasicConfiguration.basicConf.Slic3rExecutable))
             exe = BasicConfiguration.basicConf.Slic3rExecutable;*/
         slicefile = file;
         string target = StlToGCode(file);
         if (File.Exists(target))
             File.Delete(target);
         procConvert.EnableRaisingEvents = true;
         procConvert.Exited += new EventHandler(ConversionExited);
         procConvert.StartInfo.FileName = Main.IsMono ? exe : wrapQuotes(exe);
         StringBuilder sb = new StringBuilder();
         sb.Append("--load ");
         sb.Append(wrapQuotes(config));
         sb.Append(" --print-center ");
         sb.Append(centerx.ToString("0", GCode.format));
         sb.Append(",");
         sb.Append(centery.ToString("0", GCode.format));
         sb.Append(" -o ");
         sb.Append(wrapQuotes(StlToGCode(file)));
         sb.Append(" ");
         sb.Append(wrapQuotes(file));
         procConvert.StartInfo.Arguments = sb.ToString();
         procConvert.StartInfo.UseShellExecute = false;
         procConvert.StartInfo.RedirectStandardOutput = true;
         procConvert.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler);
         procConvert.StartInfo.RedirectStandardError = true;
         procConvert.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler);
         procConvert.Start();
         // Start the asynchronous read of the standard output stream.
         procConvert.BeginOutputReadLine();
         procConvert.BeginErrorReadLine();
         //Main.main.tab.SelectedTab = Main.main.tabPrint;
     }
     catch (Exception e)
     {
         Main.conn.log(e.ToString(), false, 2);
     }
     return true;
 }
コード例 #11
0
 /// <summary>
 /// Checks the state of the object.
 /// If it is outside print are it starts pulsing
 /// </summary>
 public void updateSTLState(STL stl)
 {
     FormPrinterSettings ps = Main.printerSettings;
     stl.UpdateBoundingBox();
     if (!ps.PointInside(stl.xMin, stl.yMin, stl.zMin) ||
         !ps.PointInside(stl.xMax, stl.yMin, stl.zMin) ||
         !ps.PointInside(stl.xMin, stl.yMax, stl.zMin) ||
         !ps.PointInside(stl.xMax, stl.yMax, stl.zMin) ||
         !ps.PointInside(stl.xMin, stl.yMin, stl.zMax) ||
         !ps.PointInside(stl.xMax, stl.yMin, stl.zMax) ||
         !ps.PointInside(stl.xMin, stl.yMax, stl.zMax) ||
         !ps.PointInside(stl.xMax, stl.yMax, stl.zMax))
     {
         stl.outside = true;
         if (Main.threeDSettings.pulseOutside.Checked && !stl.hasAnimationWithName("pulse"))
             stl.addAnimation(new PulseAnimation("pulse", 0.03, 0.03, 0.03, 0.3));
     }
     else
     {
         stl.outside = false;
         stl.removeAnimationWithName("pulse");
     }
 }
コード例 #12
0
        public void RunSliceExternal(string file, float centerx, float centery)
        {
            if (procConvert != null)
            {
                MessageBox.Show("Last slice job still running. Slicing of new job is canceled.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            SlicingInfo.Start("External Slic3r");
            SlicingInfo.SetAction("Analyzing STL file ...");
            try
            {
                STL stl = new STL();
                stl.Load(file);
                stl.UpdateBoundingBox();
                if (stl.xMin > 0 && stl.yMin > 0 && stl.xMax < Main.printerSettings.PrintAreaWidth && stl.yMax < Main.printerSettings.PrintAreaDepth)
                {
                    // User assigned valid position, so we use this
                    centerx = stl.xMin + (stl.xMax - stl.xMin) / 2;
                    centery = stl.yMin + (stl.yMax - stl.yMin) / 2;
                }
                stl.Clear();
            }
            catch (Exception e)
            {
                Main.conn.log(e.ToString(), false, 2);
                SlicingInfo.Stop();
                return;
            }
            SlicingInfo.SetAction("Slicing STL file ...");
            procConvert = new Process();
            try
            {
                string basedir = (string)Main.main.repetierKey.GetValue("installPath", "");
                string exname = "slic3r.exe";
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                    exname = "bin" + Path.DirectorySeparatorChar + "slic3r";
                if (Main.IsMac)
                    exname = "MacOS" + Path.DirectorySeparatorChar + "slic3r";
                string exe = basedir + Path.DirectorySeparatorChar + "Slic3r" + Path.DirectorySeparatorChar + exname;
                if (File.Exists(BasicConfiguration.basicConf.ExternalSlic3rPath))
                    exe = BasicConfiguration.basicConf.ExternalSlic3rPath;

                slicefile = file;
                string target = StlToGCode(file);
                if (File.Exists(target))
                    File.Delete(target);
                procConvert.EnableRaisingEvents = true;
                procConvert.Exited += new EventHandler(ConversionExited);
                procConvert.StartInfo.FileName = Main.IsMono ? exe : wrapQuotes(exe);
                StringBuilder sb = new StringBuilder();
                sb.Append("--load ");
                sb.Append(wrapQuotes(BasicConfiguration.basicConf.ExternalSlic3rIniFile));
                sb.Append(" --print-center ");
                sb.Append(centerx.ToString("0", GCode.format));
                sb.Append(",");
                sb.Append(centery.ToString("0", GCode.format));
                sb.Append(" -o ");
                sb.Append(wrapQuotes(StlToGCode(file)));
                sb.Append(" ");
                sb.Append(wrapQuotes(file));
                procConvert.StartInfo.Arguments = sb.ToString();
                procConvert.StartInfo.UseShellExecute = false;
                procConvert.StartInfo.RedirectStandardOutput = true;
                procConvert.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler);
                procConvert.StartInfo.RedirectStandardError = true;
                procConvert.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler);
                procConvert.Start();
                // Start the asynchronous read of the standard output stream.
                procConvert.BeginOutputReadLine();
                procConvert.BeginErrorReadLine();
                //Main.main.tab.SelectedTab = Main.main.tabPrint;
            }
            catch (Exception e)
            {
                Main.conn.log(e.ToString(), false, 2);
            }
        }
コード例 #13
0
 public void RunSlice(string file,float centerx,float centery)
 {
     if (procConvert != null)
     {
         MessageBox.Show("Last slice job still running. Slicing of new job is canceled.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     SlicingInfo.Start("Slic3r");
     SlicingInfo.SetAction("Analyzing STL file ...");
     try
     {
         STL stl = new STL();
         stl.Load(file);
         stl.UpdateBoundingBox();
         if (stl.xMin > 0 && stl.yMin > 0 && stl.xMax < Main.printerSettings.PrintAreaWidth && stl.yMax < Main.printerSettings.PrintAreaDepth)
         {
             // User assigned valid position, so we use this
             centerx = stl.xMin + (stl.xMax - stl.xMin) / 2;
             centery = stl.yMin + (stl.yMax - stl.yMin) / 2;
         }
         stl.Clear();
     }
     catch (Exception e)
     {
         Main.conn.log(e.ToString(), false, 2);
         SlicingInfo.Stop();
         return;
     }
     SlicingInfo.SetAction("Slicing STL file ...");
     procConvert = new Process();
     try
     {
     string basedir = (string)Main.main.repetierKey.GetValue("installPath","");
     string exname = "slic3r.exe";
     if (Environment.OSVersion.Platform == PlatformID.Unix)
             exname = "bin"+Path.DirectorySeparatorChar+"slic3r";
     if (Main.IsMac)
         exname = "MacOS" + Path.DirectorySeparatorChar + "slic3r";
     string exe = basedir + Path.DirectorySeparatorChar + "Slic3r" + Path.DirectorySeparatorChar + exname;
         slicefile = file;
         string target = StlToGCode(file);
         if (File.Exists(target))
             File.Delete(target);
         procConvert.EnableRaisingEvents = true;
         procConvert.Exited += new EventHandler(ConversionExited);
         procConvert.StartInfo.FileName = Main.IsMono ? exe : wrapQuotes(exe);
         StringBuilder sb = new StringBuilder();
         sb.Append("--nozzle-diameter ");
         sb.Append(textNozzleDiameter.Text);
         sb.Append(" ");
         sb.Append(" -o ");
         sb.Append(wrapQuotes(StlToGCode(file)));
         sb.Append(" ");
         if (checkRelativeE.Checked)
             sb.Append("--use-relative-e-distances ");
         if (checkComments.Checked)
             sb.Append("--gcode-comments ");
        // else
        //     sb.Append("--gcode-comments 0 ");
         sb.Append("-j ");
         sb.Append(textNumberOfThreads.Text);
         if (checkRandomizeStartingPoints.Checked)
             sb.Append(" --randomize-start");
         sb.Append(" --z-offset ");
         sb.Append(textZOffset.Text);
         sb.Append(" --filament-diameter ");
         sb.Append(textDiameter.Text);
         sb.Append(" --extrusion-multiplier ");
         sb.Append(textPackingDensity.Text);
         sb.Append(" --temperature ");
         sb.Append(textTemperature.Text);
         sb.Append(" --infill-speed ");
         sb.Append(textPrintFeedrate.Text);
         sb.Append(" --solid-infill-speed ");
         sb.Append(textSolidInfillSpeed.Text);
         sb.Append(" --travel-speed ");
         sb.Append(textTravelFeedrate.Text);
         sb.Append(" --bridge-speed ");
         sb.Append(textBridgeSpeed.Text);
         sb.Append(" --perimeter-speed ");
         sb.Append(textPerimeterFeedrate.Text);
         sb.Append(" --small-perimeter-speed ");
         sb.Append(textSmallPerimeterSpeed.Text);
         sb.Append(" --bridge-flow-ratio ");
         sb.Append(textBridgeFlowRatio.Text);
         sb.Append(" --layer-height ");
         sb.Append(textLayerHeight.Text);
         sb.Append(" --first-layer-speed ");
         sb.Append(textFirstLayerSpeed.Text);
         sb.Append(" --first-layer-height ");
         sb.Append(textFirstLayerHeight.Text);
         sb.Append(" --infill-every-layers ");
         sb.Append(textInfillEvery.Text);
         sb.Append(" --perimeters ");
         sb.Append(textPerimeters.Text);
         sb.Append(" --solid-layers ");
         sb.Append(textSolidLayers.Text);
         sb.Append(" --fill-density ");
         sb.Append(textFillDensity.Text);
         sb.Append(" --fill-angle ");
         sb.Append(textFillAngle.Text);
         sb.Append(" --fill-pattern ");
         sb.Append(comboFillPattern.SelectedItem);
         sb.Append(" --solid-fill-pattern ");
         sb.Append(comboSolidFillPattern.SelectedItem);
         sb.Append(" --retract-length ");
         sb.Append(textRetLength.Text);
         sb.Append(" --retract-speed ");
         sb.Append(textRetSpeed.Text);
         sb.Append(" --retract-restart-extra ");
         sb.Append(textRetExtraDistance.Text);
         sb.Append(" --retract-before-travel ");
         sb.Append(textRetMinTravel.Text);
         sb.Append(" --retract-lift ");
         sb.Append(textRetLift.Text);
         sb.Append(" --skirts ");
         sb.Append(textSkirtLoops.Text);
         sb.Append(" --skirt-distance ");
         sb.Append(textSkirtDistance.Text);
         sb.Append(" --skirt-height ");
         sb.Append(textSkirtHeight.Text);
         sb.Append(" --extrusion-width ");
         sb.Append(textExtrusionWidth.Text);
         sb.Append(" --brim-width ");
         sb.Append(textBrim.Text);
         sb.Append(" --support-material-threshold ");
         sb.Append(textOverhangTreshold.Text);
         sb.Append(" --support-material-pattern ");
         sb.Append(comboSupportPattern.SelectedItem);
         sb.Append(" --support-material-spacing ");
         sb.Append(textPatternSpacing.Text);
         sb.Append(" --support-material-angle ");
         sb.Append(textPatternAngle.Text);
         sb.Append(" --print-center ");
         sb.Append(centerx.ToString("0",GCode.format));
         sb.Append(",");
         sb.Append(centery.ToString("0", GCode.format));
         if (checkEnableCooling.Checked)
         {
             sb.Append(" --cooling --bridge-fan-speed ");
             sb.Append(textCoolBridgeFanSpeed.Text);
             sb.Append(" --disable-fan-first-layers ");
             sb.Append(textCoolDisableLayer.Text);
             sb.Append(" --fan-below-layer-time ");
             sb.Append(textCoolEnableBelow.Text);
             sb.Append(" --max-fan-speed ");
             sb.Append(textCoolMaxFanSpeed.Text);
             sb.Append(" --min-fan-speed ");
             sb.Append(textCoolMinFanSpeed.Text);
             sb.Append(" --min-print-speed ");
             sb.Append(textCoolMinPrintSpeed.Text);
             sb.Append(" --slowdown-below-layer-time ");
             sb.Append(textCoolSlowDownBelow.Text);
         }
         if (checkGenerateSupportMaterial.Checked)
         {
             sb.Append(" --support-material --support-material-tool " + comboSupportMaterialTool.SelectedIndex);
         }
         sb.Append(" --gcode-flavor ");
         switch (comboGCodeFlavor.SelectedIndex)
         {
             case 0:
             default:
                 sb.Append("reprap");
                 break;
             case 1:
                 sb.Append("teacup");
                 break;
             case 2:
                 sb.Append("makerbot");
                 break;
             case 3:
                 sb.Append("mach3");
                 break;
             case 4:
                 sb.Append("no-extrusion");
                 break;
         }
         sb.Append(" --first-layer-temperature ");
         sb.Append(textFirstLayerTemperature.Text);
         sb.Append(" --bed-temperature ");
         sb.Append(textBedTemperature.Text);
         sb.Append(" --first-layer-bed-temperature ");
         sb.Append(textFirstLayerBedTemperature.Text);
         if (checkFanAlwaysEnabled.Checked)
         {
             sb.Append(" --fan-always-on");
         }
         sb.Append(" --start-gcode ");
         sb.Append(wrapQuotes(basedir+Path.DirectorySeparatorChar+"empty.txt"));
         sb.Append(" --end-gcode ");
         sb.Append(wrapQuotes(basedir+Path.DirectorySeparatorChar+"empty.txt"));
         sb.Append(" ");
         sb.Append(wrapQuotes(file));
         Main.conn.log(sb.ToString(), false, 3);
         procConvert.StartInfo.Arguments = sb.ToString();
         procConvert.StartInfo.UseShellExecute = false;
         procConvert.StartInfo.RedirectStandardOutput = true;
         procConvert.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler);
         procConvert.StartInfo.RedirectStandardError = true;
         procConvert.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler);
         procConvert.Start();
         // Start the asynchronous read of the standard output stream.
         procConvert.BeginOutputReadLine();
         procConvert.BeginErrorReadLine();
         //Main.main.tab.SelectedTab = Main.main.tabPrint;
     }
     catch (Exception e)
     {
         Main.conn.log(e.ToString(), false, 2);
     }
 }
コード例 #14
0
ファイル: Slic3r.cs プロジェクト: asheikh91/Repetier-Host
 public void RunSlice(string file,float centerx,float centery)
 {
     if (procConvert != null)
     {
         MessageBox.Show("Last slice job still running. Slicing of new job is canceled.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     SlicingInfo.Start("Slic3r");
     SlicingInfo.SetAction("Analyzing STL file ...");
     try
     {
         STL stl = new STL();
         stl.Load(file);
         stl.UpdateBoundingBox();
         if (stl.xMin > 0 && stl.yMin > 0 && stl.xMax < Main.printerSettings.PrintAreaWidth && stl.yMax < Main.printerSettings.PrintAreaDepth)
         {
             // User assigned valid position, so we use this
             centerx = stl.xMin + (stl.xMax - stl.xMin) / 2;
             centery = stl.yMin + (stl.yMax - stl.yMin) / 2;
         }
         stl.Clear();
     }
     catch (Exception e)
     {
         Main.conn.log(e.ToString(), false, 2);
         SlicingInfo.Stop();
         return;
     }
     SlicingInfo.SetAction("Slicing STL file ...");
     procConvert = new Process();
     try
     {
     string basedir = (string)Main.main.repetierKey.GetValue("installPath","");
     string exname = "slic3r.exe";
     if (Environment.OSVersion.Platform == PlatformID.Unix)
             exname = "bin"+Path.DirectorySeparatorChar+"slic3r";
     if (Main.IsMac)
         exname = "MacOS" + Path.DirectorySeparatorChar + "slic3r";
     string exe = basedir + Path.DirectorySeparatorChar + "Slic3r" + Path.DirectorySeparatorChar + exname;
         slicefile = file;
         procConvert.EnableRaisingEvents = true;
         procConvert.Exited += new EventHandler(ConversionExited);
         procConvert.StartInfo.FileName = Main.IsMono ? exe : wrapQuotes(exe);
         StringBuilder sb = new StringBuilder();
         sb.Append("--nozzle-diameter ");
         sb.Append(textNozzleDiameter.Text);
         sb.Append(" ");
         if (checkNoExtrusion.Checked)
             sb.Append("--no-extrusion ");
         if (checkRelativeE.Checked)
             sb.Append("--use-relative-e-distances ");
         if (checkComments.Checked)
             sb.Append("--gcode-comments ");
        // else
        //     sb.Append("--gcode-comments 0 ");
         sb.Append("--z-offset ");
         sb.Append(textZOffset.Text);
         sb.Append(" --filament-diameter ");
         sb.Append(textDiameter.Text);
         sb.Append(" --extrusion-multiplier ");
         sb.Append(textPackingDensity.Text);
         sb.Append(" --temperature ");
         sb.Append(textTemperature.Text);
         sb.Append(" --infill-speed ");
         sb.Append(textPrintFeedrate.Text);
         sb.Append(" --solid-infill-speed ");
         sb.Append(textSolidInfillSpeed.Text);
         sb.Append(" --travel-speed ");
         sb.Append(textTravelFeedrate.Text);
         sb.Append(" --bridge-speed ");
         sb.Append(textBridgeSpeed.Text);
         sb.Append(" --perimeter-speed ");
         sb.Append(textPerimeterFeedrate.Text);
         sb.Append(" --small-perimeter-speed ");
         sb.Append(textSmallPerimeterSpeed.Text);
         sb.Append(" --bottom-layer-speed-ratio ");
         sb.Append(textBottomLayerRatio.Text);
         sb.Append(" --bridge-flow-ratio ");
         sb.Append(textBridgeFlowRatio.Text);
         sb.Append(" --layer-height ");
         sb.Append(textLayerHeight.Text);
         sb.Append(" --infill-every-layers ");
         sb.Append(textInfillEvery.Text);
         sb.Append(" --perimeters ");
         sb.Append(textPerimeters.Text);
         sb.Append(" --solid-layers ");
         sb.Append(textSolidLayers.Text);
         sb.Append(" --fill-density ");
         sb.Append(textFillDensity.Text);
         sb.Append(" --fill-angle ");
         sb.Append(textFillAngle.Text);
         sb.Append(" --fill-pattern ");
         sb.Append(comboFillPattern.Text);
         sb.Append(" --solid-fill-pattern ");
         sb.Append(comboSolidFillPattern.Text);
         sb.Append(" --retract-length ");
         sb.Append(textRetLength.Text);
         sb.Append(" --retract-speed ");
         sb.Append(textRetSpeed.Text);
         sb.Append(" --retract-restart-extra ");
         sb.Append(textRetExtraDistance.Text);
         sb.Append(" --retract-before-travel ");
         sb.Append(textRetMinTravel.Text);
         sb.Append(" --retract-lift ");
         sb.Append(textRetLift.Text);
         sb.Append(" --skirts ");
         sb.Append(textSkirtLoops.Text);
         sb.Append(" --skirt-distance ");
         sb.Append(textSkirtDistance.Text);
         sb.Append(" --skirt-height ");
         sb.Append(textSkirtHeight.Text);
         sb.Append(" --extrusion-width-ratio ");
         sb.Append(textExtrusionWidthRatio.Text);
         sb.Append(" --print-center ");
         sb.Append(centerx.ToString("0",GCode.format));
         sb.Append(",");
         sb.Append(centery.ToString("0", GCode.format));
         sb.Append(" --start-gcode ");
         sb.Append(wrapQuotes(basedir+Path.DirectorySeparatorChar+"empty.txt"));
         sb.Append(" --end-gcode ");
         sb.Append(wrapQuotes(basedir+Path.DirectorySeparatorChar+"empty.txt"));
         sb.Append(" ");
         sb.Append(wrapQuotes(file));
         procConvert.StartInfo.Arguments = sb.ToString();
         procConvert.StartInfo.UseShellExecute = false;
         procConvert.StartInfo.RedirectStandardOutput = true;
         procConvert.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler);
         procConvert.StartInfo.RedirectStandardError = true;
         procConvert.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler);
         procConvert.Start();
         // Start the asynchronous read of the standard output stream.
         procConvert.BeginOutputReadLine();
         procConvert.BeginErrorReadLine();
         //Main.main.tab.SelectedTab = Main.main.tabPrint;
     }
     catch (Exception e)
     {
         Main.conn.log(e.ToString(), false, 2);
     }
 }
コード例 #15
0
 public STL GetSTL(string name)
 {
     STL result;
     if (!this.STLs.Contains(name))
     {
         STL sTL = new STL();
         sTL.Load(ContentManager.rootPath + name, ClientType.IROSE);
         this.STLs.Add(name, sTL);
         result = sTL;
     }
     else
     {
         result = (STL)this.STLs[name];
     }
     return result;
 }