private void buttonCopyObjects_Click(object sender, EventArgs e)
        {
            if (copyDialog.ShowDialog(Main.main) == DialogResult.Cancel)
            {
                return;
            }
            int numberOfCopies = (int)copyDialog.numericCopies.Value;

            List <STL> newSTL = new List <STL>();

            foreach (STL act in listSTLObjects.SelectedItems)
            {
                STL last = act;
                for (int i = 0; i < numberOfCopies; i++)
                {
                    STL stl = last.copySTL();
                    last = stl;
                    newSTL.Add(stl);
                }
            }
            foreach (STL stl in newSTL)
            {
                listSTLObjects.Items.Add(stl);
                cont.models.AddLast(stl);
            }
            if (copyDialog.checkAutoposition.Checked)
            {
                Autoposition();
            }
            Main.main.threedview.UpdateChanges();
        }
Пример #2
0
 /// <summary>
 /// Exports all meshes found in MeshFilter and SkinnedMeshRenderer components attached to the supplied game objects (or their children) to a text based stl file at specified file path.
 /// </summary>
 /// <param name="gameObjects">Game objects.</param>
 /// <param name="filePath">File path.</param>
 public static void ExportText(GameObject[] gameObjects, string filePath)
 {
     Mesh[]      meshes;
     Matrix4x4[] matrices;
     STL.GetMeshesAndMatrixes(gameObjects, out meshes, out matrices);
     ExportText(meshes, matrices, filePath);
 }
Пример #3
0
        private static void ShapewaysPolytopes()
        {
            VEF loader = new VEF();

            loader.Load(@"C:\Users\roice\Documents\projects\vZome\VefProjector\data\24cell-cellFirst.vef");

            int divisions = 25;

            Shapeways mesh = new Shapeways();

            //int count = 0;
            foreach (GraphEdge edge in loader.Edges)
            {
                Segment seg = Segment.Line(
                    loader.Vertices[edge.V1].ConvertToReal(),
                    loader.Vertices[edge.V2].ConvertToReal());
                Vector3D[] points = seg.Subdivide(divisions);

                bool shrink = true;
                ProjectAndAddS3Points(mesh, points, shrink);

                //if( count++ > 10 )
                //	break;
            }

            STL.SaveMeshToSTL(mesh.Mesh, @"D:\p4\R3\sample\out1.stl");
        }
Пример #4
0
        private void CopyObjects()
        {
            if (copyDialog.ShowDialog(Main.main) == DialogResult.Cancel)
            {
                return;
            }
            int numberOfCopies = (int)copyDialog.numericCopies.Value;

            List <STL> newSTL = new List <STL>();

            foreach (STL act in Main.main.listSTLObjects.SelectedItems)
            {
                STL last = act;
                for (int i = 0; i < numberOfCopies; i++)
                {
                    STL stl = last.copySTL();
                    last = stl;
                    newSTL.Add(stl);
                }
            }
            foreach (STL stl in newSTL)
            {
                Main.main.listSTLObjects.Items.Add(stl);
                Main.main.fileAddOrRemove.StleditorView.models.AddLast(stl);
            }
            if (copyDialog.checkAutoposition.Checked)
            {
                Autoposition();
            }
            Main.main.threedview.UpdateChanges();
        }
Пример #5
0
        public static void GenCapWithHole()
        {
            Shapeways mesh = new Shapeways();

            double overallScale = 12.5;                 // 2.5 cm = 1 in diameter

            // Make hole 2 mm
            double startAngle = Math.Asin(2.0 / 2 / overallScale);
            double endAngle   = Math.PI / 8;            // Slightly larger than hole above.

            int    div      = 75;
            double angleInc = (endAngle - startAngle) / div;

            for (int i = 0; i < div; i++)
            {
                double   angle1 = startAngle + angleInc * i;
                double   angle2 = startAngle + angleInc * (i + 1);
                Vector3D s1 = new Vector3D(0, 0, 1), s2 = new Vector3D(0, 0, 1);
                s1.RotateAboutAxis(new Vector3D(0, 1, 0), angle1);
                s2.RotateAboutAxis(new Vector3D(0, 1, 0), angle2);

                Vector3D p1 = s1 * (1 + SizeFunc(s1, overallScale));
                Vector3D p2 = s2 * (1 + SizeFunc(s2, overallScale));
                Vector3D n1 = s1 * (1 - SizeFunc(s1, overallScale));
                Vector3D n2 = s2 * (1 - SizeFunc(s2, overallScale));

                List <Vector3D> pointsP1 = new List <Vector3D>();
                List <Vector3D> pointsP2 = new List <Vector3D>();
                List <Vector3D> pointsN1 = new List <Vector3D>();
                List <Vector3D> pointsN2 = new List <Vector3D>();
                for (int j = 0; j < div; j++)
                {
                    pointsP1.Add(p1);
                    pointsP2.Add(p2);
                    pointsN1.Add(n1);
                    pointsN2.Add(n2);
                    p1.RotateAboutAxis(new Vector3D(0, 0, 1), 2 * Math.PI / div);
                    p2.RotateAboutAxis(new Vector3D(0, 0, 1), 2 * Math.PI / div);
                    n1.RotateAboutAxis(new Vector3D(0, 0, 1), 2 * Math.PI / div);
                    n2.RotateAboutAxis(new Vector3D(0, 0, 1), 2 * Math.PI / div);
                }

                mesh.AddSegment(pointsP1.ToArray(), pointsP2.ToArray());
                mesh.AddSegment(pointsN2.ToArray(), pointsN1.ToArray());
                if (i == 0)
                {
                    mesh.AddSegment(pointsN1.ToArray(), pointsP1.ToArray());
                }
                if (i == div - 1)
                {
                    mesh.AddSegment(pointsP2.ToArray(), pointsN2.ToArray());
                }
            }

            mesh.Mesh.Scale(overallScale);

            string outputFileName = @"d:\temp\cap_with_hole.stl";

            STL.SaveMeshToSTL(mesh.Mesh, outputFileName);
        }
Пример #6
0
        //Loads stl,  makes computations ("classify" each facet), then removes the facet data from memory.
        private void process_stl_async(string stl_location, int process_count)
        {
            //Build all threads, start. (This snippet may be worth saving?)
            Thread[] threads = new Thread[process_count];
            thread_signin = new bool[process_count];
            for (int i = 0; i < process_count; i++)
            {
                //Lambda expressions pass by reference. Dereferencing is necessary here.
                int dereference_i = i;

                threads[i] = new Thread(() => process_stl_singleprocess(dereference_i, process_count));
            }
            foreach (Thread t in threads)
            {
                t.Start();
            }
            //Wait for all threads to complete.
            while (!MathTools.CheckAll(thread_signin))
            {
                Thread.Sleep(1);
            }
            temp_facet_data = null;

            //Combine tables and reduce.
            lookup_table = StlClassificationTable.CombineReduce(volatile_tables);
        }
Пример #7
0
        public void listSTLObjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateEnabled();
            STL stl = (STL)Main.main.listSTLObjects.SelectedItem;

            foreach (STL s in Main.main.fileAddOrRemove.StleditorView.models)
            {
                s.Selected = Main.main.listSTLObjects.SelectedItems.Contains(s);
            }
            if (Main.main.listSTLObjects.SelectedItems.Count > 1)
            {
                stl = null;
            }
            if (stl != null)
            {
                this.xRotateControl.Value = (decimal)stl.Rotation.x;
                this.yRotateControl.Value = (decimal)stl.Rotation.y;
                this.zRotateControl.Value = (decimal)stl.Rotation.z;
                textScaleX.Text           = stl.Scale.x.ToString(GCode.format);
                textScaleY.Text           = stl.Scale.y.ToString(GCode.format);
                textScaleZ.Text           = stl.Scale.z.ToString(GCode.format);
                this.xTransValue.Value    = (decimal)stl.Position.x;
                this.yTranNum.Value       = (decimal)stl.Position.y;
                this.zTransNum.Value      = (decimal)stl.Position.z;
                checkScaleAll.Checked     = (stl.Scale.x == stl.Scale.y && stl.Scale.x == stl.Scale.z);
            }
            //Main.main.threedview.UpdateChanges();
            Main.main.mainUpdaterHelper.UpdateEverythingInMain();
        }
        private void listSTLObjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateEnabled();
            STL stl = (STL)listSTLObjects.SelectedItem;

            foreach (STL s in cont.models)
            {
                s.Selected = listSTLObjects.SelectedItems.Contains(s);
            }
            if (listSTLObjects.SelectedItems.Count > 1)
            {
                stl = null;
            }
            if (stl != null)
            {
                textRotX.Text         = stl.Rotation.x.ToString(GCode.format);
                textRotY.Text         = stl.Rotation.y.ToString(GCode.format);
                textRotZ.Text         = stl.Rotation.z.ToString(GCode.format);
                textScaleX.Text       = stl.Scale.x.ToString(GCode.format);
                textScaleY.Text       = stl.Scale.y.ToString(GCode.format);
                textScaleZ.Text       = stl.Scale.z.ToString(GCode.format);
                textTransX.Text       = stl.Position.x.ToString(GCode.format);
                textTransY.Text       = stl.Position.y.ToString(GCode.format);
                textTransZ.Text       = stl.Position.z.ToString(GCode.format);
                checkScaleAll.Checked = (stl.Scale.x == stl.Scale.y && stl.Scale.x == stl.Scale.z);
            }
            Main.main.threedview.UpdateChanges();
        }
Пример #9
0
    static void ExportSTL(bool isBinary)
    {
        // get selected meshes //
        Mesh[]      meshes;
        Matrix4x4[] matrices;
        STL.GetMeshesAndMatrixes(Selection.gameObjects, out meshes, out matrices);

        // display dialog if nothing no meshes are selected //
        if (meshes.Length == 0)
        {
            EditorUtility.DisplayDialog("Nothing to export", "Select one or more GameObjects with MeshFilter or SkinnedMeshRenderer components attached.", "Close");
            return;
        }

        // display dialog to get save path //
        string filePath = EditorUtility.SaveFilePanel("Save STL file", DefaultDirectory(), DeafultFileName(), "stl");

        // export //
        if (isBinary)
        {
            STL.ExportBinary(meshes, matrices, filePath);
        }
        else
        {
            STL.ExportText(meshes, matrices, filePath);
        }

        // display feedback //
        string meshesPlural = meshes.Length == 1 ? "mesh" : "meshes";

        EditorUtility.DisplayDialog("STL export complete", "Exported " + meshes.Length + " Unity " + meshesPlural + " combined in a STL file.", "Close");
    }
Пример #10
0
        public static double[] GetBoundsFromSingleStl(string filename)
        {
            STL    body = new STL(filename);
            double xmin = double.PositiveInfinity;
            double ymin = double.PositiveInfinity;
            double zmin = double.PositiveInfinity;
            double xmax = double.NegativeInfinity;
            double ymax = double.NegativeInfinity;
            double zmax = double.NegativeInfinity;

            for (int i = 0; i < body.FacetCount; i++)
            {
                double local_xmin = MathTools.GetMin(body[i].V1.X, body[i].V2.X, body[i].V3.X);
                double local_ymin = MathTools.GetMin(body[i].V1.Y, body[i].V2.Y, body[i].V3.Y);
                double local_zmin = MathTools.GetMin(body[i].V1.Z, body[i].V2.Z, body[i].V3.Z);
                double local_xmax = MathTools.GetMax(body[i].V1.X, body[i].V2.X, body[i].V3.X);
                double local_ymax = MathTools.GetMax(body[i].V1.Y, body[i].V2.Y, body[i].V3.Y);
                double local_zmax = MathTools.GetMax(body[i].V1.Z, body[i].V2.Z, body[i].V3.Z);
                xmin = local_xmin < xmin ? local_xmin : xmin;
                ymin = local_ymin < ymin ? local_ymin : ymin;
                zmin = local_zmin < zmin ? local_zmin : zmin;
                xmax = local_xmax > xmax ? local_xmax : xmax;
                ymax = local_ymax > ymax ? local_ymax : ymax;
                zmax = local_zmax > zmax ? local_zmax : zmax;
            }
            return(new double[] { xmin, xmax, ymin, ymax, zmin, zmax });
        }
Пример #11
0
        private static void HopfFibration(Tiling tiling)
        {
            int       segDivisions = 10;
            Shapeways mesh         = new Shapeways();

            HashSet <Vector3D> done = new HashSet <Vector3D>();

            foreach (Tile tile in tiling.Tiles)
            {
                foreach (Segment seg in tile.Boundary.Segments)
                {
                    if (done.Contains(seg.Midpoint))
                    {
                        continue;
                    }

                    // Subdivide the segment, and project points to S2.
                    Vector3D[] points = seg.Subdivide(segDivisions).Select(v => Spherical2D.PlaneToSphere(v)).ToArray();
                    foreach (Vector3D point in points)
                    {
                        Vector3D[] circlePoints = OneHopfCircle(point);
                        ProjectAndAddS3Points(mesh, circlePoints, shrink: false);
                    }

                    done.Add(seg.Midpoint);
                }
            }

            STL.SaveMeshToSTL(mesh.Mesh, @"D:\p4\R3\sample\out1.stl");
        }
Пример #12
0
        public static void EdgesToStl(H3.Cell.Edge[] edges)
        {
            Shapeways mesh = new Shapeways();

            int divisions = 25;

            foreach (H3.Cell.Edge edge in edges)
            {
                Segment seg = Segment.Line(
                    Sterographic.R3toS3(edge.Start),
                    Sterographic.R3toS3(edge.End));
                Vector3D[] points = seg.Subdivide(divisions);

                ProjectAndAddS3Points(mesh, points);
            }

            for (int i = 0; i < mesh.Mesh.Triangles.Count; i++)
            {
                mesh.Mesh.Triangles[i] = new Mesh.Triangle(
                    SphericalModels.StereoToEqualVolume(mesh.Mesh.Triangles[i].a),
                    SphericalModels.StereoToEqualVolume(mesh.Mesh.Triangles[i].b),
                    SphericalModels.StereoToEqualVolume(mesh.Mesh.Triangles[i].c));
            }

            STL.SaveMeshToSTL(mesh.Mesh, @"output.stl");
        }
        /// <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");
            }
        }
Пример #14
0
        public void ExportToTextSTL()
        {
            string filePath = DefaultDirectory() + "/stl_example_text.stl";

            STL.ExportText(objects, filePath);
            Debug.Log("Exported " + objectCount + " objects to text based STL file." + System.Environment.NewLine + filePath);
        }
Пример #15
0
        public void ExportToBinarySTL()
        {
            string filePath = DefaultDirectory() + "/stl_example_binary.stl";

            STL.ExportBinary(objects, filePath);
            Debug.Log("Exported " + objectCount + " objects to binary STL file." + System.Environment.NewLine + filePath);
        }
Пример #16
0
        public static void GenEuclidean()
        {
            Shapeways mesh = new Shapeways();
            HashSet <H3.Cell.Edge> completed = new HashSet <H3.Cell.Edge>();

            int count = 5;

            for (int i = -count; i < count; i++)
            {
                for (int j = -count; j < count; j++)
                {
                    for (int k = -count; k < count; k++)
                    {
                        // Offset
                        double io = i + 0.5;
                        double jo = j + 0.5;
                        double ko = k + 0.5;

                        // Do every edge emanating from this point.
                        AddEuclideanEdge(mesh, completed, new Vector3D(io, jo, ko), new Vector3D(io + 1, jo, ko));
                        AddEuclideanEdge(mesh, completed, new Vector3D(io, jo, ko), new Vector3D(io - 1, jo, ko));
                        AddEuclideanEdge(mesh, completed, new Vector3D(io, jo, ko), new Vector3D(io, jo + 1, ko));
                        AddEuclideanEdge(mesh, completed, new Vector3D(io, jo, ko), new Vector3D(io, jo - 1, ko));
                        AddEuclideanEdge(mesh, completed, new Vector3D(io, jo, ko), new Vector3D(io, jo, ko + 1));
                        AddEuclideanEdge(mesh, completed, new Vector3D(io, jo, ko), new Vector3D(io, jo, ko - 1));
                    }
                }
            }

            STL.SaveMeshToSTL(mesh.Mesh, "d:\\temp\\434.stl");
        }
Пример #17
0
    protected override void LoadModel(ModelMsg obj)
    {
        ReleaseOld();
        totle++;
        ModelMsg mm = obj;

        string stlpath = Tool.LocalModelonSavePath + mm.pdata.ID + Tool.STLfiledir;// mm.pdata.LocalUserModelPath;//

        if (!Tool.CheckFileExist(stlpath))
        {
            Debug.LogError("根据ID查找模型 不存在,加载默认模型");
        }
        GameObject realmodel = new GameObject("UserImprot" + totle, typeof(STL));

        realmodel.transform.SetParent(transform);

        STL stlloalder = realmodel.GetComponent <STL>();

        stlloalder.CreateInstance(stlpath, str => { }, go =>
        {
            AdjustmentChild(go, PlayerDataCenter.Instance.MaterialMap[Tool.MatarialsUse.UserimportModel]);
            LoadGizmopointer(mm.pointmap, go.transform, SelfPointMode);
            go.transform.SetParent(realmodel.transform);
            go.transform.localScale = Vector3.one * Tool.UserImportScaler;
        });
        lastrealmodel = realmodel;
    }
Пример #18
0
        private void cla_SelectedIndexChanged(object sender, EventArgs e)
        {
            Double PL = 150, CL, STL;

            CL            = Convert.ToDouble(cla.Text);
            STL           = PL * CL;
            textBox4.Text = STL.ToString();
        }
Пример #19
0
        private static void HopfFibration(Tiling tiling)
        {
            int       segDivisions    = 10;
            int       circleDivisions = 125;
            Shapeways mesh            = new Shapeways();

            HashSet <Vector3D> done = new HashSet <Vector3D>();

            foreach (Tile tile in tiling.Tiles)
            {
                foreach (Segment seg in tile.Boundary.Segments)
                {
                    if (done.Contains(seg.Midpoint))
                    {
                        continue;
                    }

                    // Subdivide the segment, and project points to S2.
                    Vector3D[] points = seg.Subdivide(segDivisions).Select(v => Spherical2D.PlaneToSphere(v)).ToArray();
                    foreach (Vector3D point in points)
                    {
                        // Get the hopf circle and add to mesh.
                        // http://en.wikipedia.org/wiki/Hopf_fibration#Explicit_formulae
                        double a      = point.X;
                        double b      = point.Y;
                        double c      = point.Z;
                        double factor = 1 / (Math.Sqrt(1 + c));
                        if (Tolerance.Equal(c, -1))
                        {
                            continue;
                        }

                        List <Vector3D> circlePoints = new List <Vector3D>();
                        double          angleInc     = 2 * Math.PI / circleDivisions;
                        double          angle        = 0;
                        for (int i = 0; i <= circleDivisions; i++)
                        {
                            double sinTheta = Math.Sin(angle);
                            double cosTheta = Math.Cos(angle);
                            circlePoints.Add(new Vector3D(
                                                 (1 + c) * cosTheta,
                                                 a * sinTheta - b * cosTheta,
                                                 a * cosTheta + b * sinTheta,
                                                 (1 + c) * sinTheta));

                            angle += angleInc;
                        }

                        bool shrink = false;
                        ProjectAndAddS3Points(mesh, circlePoints.ToArray(), shrink);
                    }

                    done.Add(seg.Midpoint);
                }
            }

            STL.SaveMeshToSTL(mesh.Mesh, @"D:\p4\R3\sample\out1.stl");
        }
Пример #20
0
 public STLMeasuringTool_MultiThread(STL STL2Measure, List <PointD> P, List <Vector> N, int ThreadNumber, EventHandler OnFinish, STLMeasuringTool objSTLMeasurement)
 {
     this.STL2Measure                 = STL2Measure;
     this.MeasurePoints               = P;
     this.MeasurePointNormals         = N;
     this.ThreadNumber                = ThreadNumber;
     this.OnFinish                   += OnFinish;
     this.STLMeasurentReferenceObject = objSTLMeasurement;
 }
Пример #21
0
        public static void Dini()
        {
            Mesh mesh = Mesh.MakeEdgeMesh(3, 7);

            //m_mesh.Scale( 5 );
            //mesh.Rotate( Math.PI / 4 );
            mesh = Surface.Dini(mesh);
            STL.SaveMeshToSTL(mesh, "dini.stl");
        }
Пример #22
0
    public static void ExportTextSTL()
    {
        // get selected meshes //
        GameObject[]      objects    = Selection.gameObjects;
        List <MeshFilter> filterList = new List <MeshFilter>();

        for (int g = 0; g < objects.Length; g++)
        {
            MeshFilter[] filters = objects[g].GetComponentsInChildren <MeshFilter>();
            for (int f = 0; f < filters.Length; f++)
            {
                if (filters[f] != null)
                {
                    filterList.Add(filters[f]);
                }
            }
        }

        // display dialog if nothing no meshes are selected //
        if (filterList.Count == 0)
        {
            EditorUtility.DisplayDialog("Nothing to export", "Select one or more GameObjects with MeshFilter components attached.", "Close");
            return;
        }

        // get default directory //
        string defaultDirectory = "";

        if (Application.platform == RuntimePlatform.OSXEditor)
        {
            defaultDirectory = System.Environment.GetEnvironmentVariable("HOME") + "/Desktop";
        }
        else
        {
            defaultDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
        }

        // get default file name //
        string defaultName = DateTimeCode();

        if (Application.loadedLevelName != "")
        {
            defaultName = Application.loadedLevelName + " " + defaultName;
        }

        // display dialog to get save path //
        string filePath = EditorUtility.SaveFilePanel("Save binary STL file", defaultDirectory, defaultName, "stl");

        // export //
        STL.ExportText(filterList.ToArray(), filePath);

        // display feedback //
        string meshesPlural = filterList.Count == 1 ? "mesh" : "meshes";

        EditorUtility.DisplayDialog("STL export complete", "Exported " + filterList.Count + " Unity " + meshesPlural + " combined in a text based STL file.", "Close");
    }
Пример #23
0
    void LoadUserImprot(string message)
    {
        SetLastInactive();
        userimport = new GameObject("UserImport" + userimporottaltol);
        OBJLoader  = userimport.AddComponent <OBJ>();
        STLLoader  = userimport.AddComponent <STL>();
        Dictionary <int, string> map = MSGCenter.UnFormatMessage(message);
        //string[] s = message.Split('*');
        string serverpath = map[1];

        if (map.ContainsKey(2))
        {
            string md5 = map[2];
            CreatModel(md5);
        }
        if (serverpath.IsObj())
        {
            TTUIPage.ShowPage <UINotice>("请使用stl格式的模型");
            //pcpath = "file:///" + pcpath;
            //try
            //{
            //    OBJLoader.Load(pcpath, (result) =>
            //    {
            //        MatchingModelNormal(userimport,v, hasposvalue);
            //        userimport.AddComponent<MeshCollider>();
            //        MSGCenter.Execute(Enums.ModelPath.Result.ToString(), result );
            //    });
            //}
            //catch (System.Exception e)
            //{
            //    MSGCenter.Execute(Enums.ModelPath.Result.ToString(), e.ToString() );
            //    throw;
            //}
        }
        else if (serverpath.IsStl())
        {
            string stlpath = Tool.LocalModelonSavePath + PlayerDataCenter.Currentillnessdata.ID + ".stl";// mm.pdata.LocalUserModelPath;//
            if (!Tool.CheckFileExist(stlpath))
            {
                MyWebRequest.Instance.DownloadFileFromWed(serverpath, Tool.LocalModelonSavePath, PlayerDataCenter.Currentillnessdata.ID + ".stl"
                                                          , (suc, str) =>
                {
                    TTUIPage.ShowPage <UINotice>(Tool.DownloadDir + str);
                    if (suc)
                    {
                        TTUIPage.ClosePage <UINotice>();
                        CreatStlInstance(stlpath);
                    }
                });
            }
            else
            {
                CreatStlInstance(stlpath);
            }
        }
    }
Пример #24
0
 public StlClassifier(string _stl_location, int _bin_count)
 {
     //build bounds...
     bin_count       = _bin_count;
     stl_location    = _stl_location;
     temp_facet_data = new STL(_stl_location);
     bounds          = get_bounds();
     classifier      = new GridClassifier(bin_count, bounds);
     lookup_table    = new StlClassificationTable(bin_count);
 }
Пример #25
0
 /// <summary>
 /// 模擬P40量測類別的建構式
 /// </summary>
 /// <param name="STL2Measure">欲量測的STL</param>
 /// <param name="TopoFace1">第一拓樸面</param>
 /// <param name="TopoFace2">第二拓樸面</param>
 /// <param name="PitchPoint1">第一拓樸面的PitchPoint</param>
 /// <param name="PitchPoint2">第二拓樸面的PitchPoint</param>
 /// <param name="ThreadNumber">執行緒數目</param>
 /// <param name="OnFinish">計算完成時的後續動作</param>
 public STLMeasuringTool_P40_SingleTooth(STL STL2Measure, TopoFace TopoFace1, TopoFace TopoFace2, PointD PitchPoint1, PointD PitchPoint2, int ThreadNumber, EventHandler OnFinish)
 {
     this.STL2Measure  = STL2Measure;
     this.TopoFace1    = TopoFace1;
     this.TopoFace2    = TopoFace2;
     this.PitchPoint1  = PitchPoint1;
     this.PitchPoint2  = PitchPoint2;
     this.ThreadNumber = ThreadNumber;
     this.OnFinish    += OnFinish;
 }
Пример #26
0
        /// <summary>
        /// 執行緒結束時觸發此事件
        /// </summary>

        public STLMeasuringTool_P40(
            STL STL2Measure,
            List <TopoFace[]> topoFaces,
            List <PointD[]> pitchPoints
            )
        {
            this.STL2Measure = STL2Measure;
            this.TopoFaces   = topoFaces;
            this.PitchPoints = pitchPoints;
        }
Пример #27
0
        public SmileStlExporter(string outputFileName, string comment)
        {
            var fullPath = Path.GetFullPath(outputFileName);

            this.directory = Path.GetDirectoryName(fullPath);
            this.writer    = new StreamWriter(outputFileName);
            //this.binaryWriter = new BinaryWriter(writer);

            this.stlExporter = new STL();
            faces            = new List <Facet>();
        }
Пример #28
0
        private void textRotZ_TextChanged(object sender, EventArgs e)
        {
            STL stl = (STL)listSTLObjects.SelectedItem;

            if (stl == null)
            {
                return;
            }
            float.TryParse(textRotZ.Text, NumberStyles.Float, GCode.format, out stl.Rotation.z);
            cont.UpdateChanges();
        }
Пример #29
0
        public void ExportToTextSTL()
        {
            string filePath = DefaultDirectory() + "/stl_example_text.stl";
            bool   asASCII  = true;
            bool   success  = STL.Export(_objects, filePath, asASCII);

            if (success)
            {
                Debug.Log("Exported " + objectCount + " objects to text based STL file." + System.Environment.NewLine + filePath);
            }
        }
        private void textRotY_TextChanged(object sender, EventArgs e)
        {
            STL stl = (STL)listSTLObjects.SelectedItem;

            if (stl == null)
            {
                return;
            }
            float.TryParse(textRotY.Text, NumberStyles.Float, GCode.format, out stl.Rotation.y);
            updateSTLState(stl);
            Main.main.threedview.UpdateChanges();
        }
Пример #31
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;
 }
Пример #32
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;
         }
     }
 }
Пример #33
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);
         }
 }
Пример #34
0
        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;
        }
Пример #35
0
        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;
        }
Пример #36
0
        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);
            }
        }
Пример #37
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);
     }
 }
Пример #38
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 (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");
     }
 }
Пример #39
0
 /// <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");
     }
 }
Пример #40
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);
            }
        }
Пример #41
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");
     }
 }
Пример #42
0
 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;
 }
Пример #43
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;
         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);
     }
 }
Пример #44
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();
 }
Пример #45
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;
 }