Esempio n. 1
0
        /// <summary>
        /// Обрабатывает объекты и готовит их на лазер
        /// </summary>
        /// <param name="canvas">Отправляемое рабочее поле</param>
        /// <returns>N_{i,degree}(step)</returns>
        public async static void Worker(CadCanvas canvas)
        {
            Processing = true;
            LObjectList dotList = new LObjectList();

            foreach (object obj in canvas.Children)
            {
                if (obj is CadObject cadObject && cadObject.Render == true)
                {
                    dotList.AddRange(SendProcessor.GetPoint(cadObject, false));
                    //dotList.AddRange(cadObject.GetTransformPoint(false));
                }
            }
            LObjectList outList = new LObjectList();

            if (canvas.Masks.Count > 0)
            {
                foreach (LQube lRect in canvas.Masks)
                {
                    outList.AddRange(lRect.CutByRect(dotList));
                }
            }
            else
            {
                outList = dotList;
            }

            Processing = false;

            MonchaHub.MainFrame = outList;
        }
Esempio n. 2
0
        /// <summary>
        /// Get point from inner object
        /// </summary>
        /// <param name="cadObject">inner object</param>
        /// <returns>Object collection</returns>
        public static LObjectList GetPoint(CadObject cadObject, bool InGroup)
        {
            LObjectList lObjectList = new LObjectList();

            switch (cadObject)
            {
            case CadAnchor cadDot:
                if (cadObject.DataContext is MonchaDeviceMesh deviceMesh)
                {
                    if (MonchaDeviceMesh.ClbrForm == CalibrationForm.cl_Dot)
                    {
                        lObjectList.Add(new LObject()
                        {
                            Points = new List <LPoint3D>()
                            {
                                cadDot.GetPoint.GetMLpoint3D
                            }, MeshType = cadDot.MeshType
                        });
                    }
                    if (MonchaDeviceMesh.ClbrForm == CalibrationForm.cl_Rect)
                    {
                        lObjectList.AddRange(CalibrationRect(deviceMesh, cadDot.GetPoint, cadDot.MeshType));
                    }
                    if (MonchaDeviceMesh.ClbrForm == CalibrationForm.cl_miniRect)
                    {
                        lObjectList.AddRange(CalibrationMiniRect(deviceMesh, cadDot.GetPoint, cadDot.MeshType));
                    }
                    if (MonchaDeviceMesh.ClbrForm == CalibrationForm.cl_Cross)
                    {
                        lObjectList.AddRange(CalibrationCross(deviceMesh, cadDot.GetPoint, cadDot.MeshType));
                    }
                    if (MonchaDeviceMesh.ClbrForm == CalibrationForm.cl_HLine)
                    {
                        lObjectList.AddRange(CalibrationLineH(deviceMesh, cadDot.GetPoint, cadDot.MeshType));
                    }
                    if (MonchaDeviceMesh.ClbrForm == CalibrationForm.cl_WLine)
                    {
                        lObjectList.AddRange(CalibrationLineW(deviceMesh, cadDot.GetPoint, cadDot.MeshType));
                    }
                }
                else
                {
                    lObjectList.Add(new LObject()
                    {
                        Points = new List <LPoint3D>()
                        {
                            cadDot.GetPoint.GetMLpoint3D
                        },
                        MeshType = cadDot.MeshType
                    });
                }

                break;

            case CadGeometry cadGeometry:
                lObjectList.AddRange(cadGeometry.GetTransformPoint());
                break;

            case CadLine cadLine:
                lObjectList.Add(new LObject()
                {
                    Points = new List <LPoint3D>()
                    {
                        cadLine.P1,
                        cadLine.P2
                    },
                    ProjectionSetting = cadLine.ProjectionSetting,
                    MeshType          = cadLine.MeshType
                });
                break;

            case CadRectangle cadRectangle:
                lObjectList.Add(new LObject()
                {
                    Points = new List <LPoint3D>()
                    {
                        cadRectangle.LRect.P1,
                        new LPoint3D(cadRectangle.LRect.P2.MX, cadRectangle.LRect.P1.MY),
                        cadRectangle.LRect.P2,
                        new LPoint3D(cadRectangle.LRect.P1.MX, cadRectangle.LRect.P2.MY),
                    },
                    ProjectionSetting = cadRectangle.ProjectionSetting,
                    Closed            = true,
                    MeshType          = cadRectangle.MeshType
                });
                break;

            case CadObjectsGroup cadObjectsGroup:
                foreach (CadObject obj in cadObjectsGroup)
                {
                    obj.ProjectionSetting = cadObjectsGroup.ProjectionSetting != MonchaHub.ProjectionSetting ? cadObjectsGroup.ProjectionSetting : null;
                    lObjectList.AddRange(GetPoint(obj, true));
                }
                break;
            }

            return(lObjectList);


            LObjectList CalibrationCross(MonchaDeviceMesh monchaDeviceMesh, LPoint3D lPoint3D, MeshType meshType)
            {
                Tuple <int, int> tuple = monchaDeviceMesh.CoordinatesOf(lPoint3D);
                int height             = monchaDeviceMesh.GetLength(0) - 1;
                int width = monchaDeviceMesh.GetLength(1) - 1;


                //Vertical
                LObject Line1 = new LObject()
                {
                    MeshType = meshType
                };

                for (int i = 0; i <= width; i += 1)
                {
                    Line1.Add(monchaDeviceMesh[tuple.Item2, i].GetMLpoint3D);
                }

                //Vertical

                //Horizontal
                LObject Line2 = new LObject()
                {
                    MeshType = meshType
                };

                for (int i = 0; i <= height; i += 1)
                {
                    Line2.Add(monchaDeviceMesh[i, tuple.Item1].GetMLpoint3D);
                }

                return(new LObjectList()
                {
                    Line2,
                    Line1
                });
            }

            LObjectList CalibrationRect(MonchaDeviceMesh monchaDeviceMesh, LPoint3D lPoint3D, MeshType meshType)
            {
                Tuple <int, int> tuple = monchaDeviceMesh.CoordinatesOf(lPoint3D);
                int height             = monchaDeviceMesh.GetLength(0) - 1;
                int width = monchaDeviceMesh.GetLength(1) - 1;

                //Vertical
                LObject Line1H = GetLine(tuple.Item1, tuple.Item2, true);
                //Horizontal
                LObject Line1W = GetLine(tuple.Item1, height - tuple.Item2, false);
                //Vertical
                LObject Line2H = GetLine(width - tuple.Item1, height - tuple.Item2, true);
                //Horizontal
                LObject Line2W = GetLine(width - tuple.Item1, tuple.Item2, false);

                return(new LObjectList()
                {
                    Line1H,
                    Line1W,
                    Line2H,
                    Line2W
                });


                LObject GetLine(int xpos, int ypos, bool Vertical)
                {
                    LObject Line = new LObject()
                    {
                        MeshType = meshType
                    };

                    if (Vertical == true)
                    {
                        int ypos2 = height - ypos;

                        int delta = ypos > ypos2 ? -1 : 1;

                        for (int i = 0; i <= Math.Abs(ypos2 - ypos); i += 1)
                        {
                            Line.Add(monchaDeviceMesh[ypos + (i * delta), xpos].GetMLpoint3D);
                        }
                    }
                    else
                    {
                        int xpos2 = width - xpos;

                        int delta = xpos > xpos2 ? -1 : 1;

                        for (int i = 0; i <= Math.Abs(xpos2 - xpos); i += 1)
                        {
                            Line.Add(monchaDeviceMesh[ypos, xpos + (i * delta)].GetMLpoint3D);
                        }
                    }

                    return(Line);
                }
            }

            LObjectList CalibrationMiniRect(MonchaDeviceMesh monchaDeviceMesh, LPoint3D lPoint3D, MeshType meshType)
            {
                Tuple <int, int> tuple = monchaDeviceMesh.CoordinatesOf(lPoint3D);
                int height             = monchaDeviceMesh.GetLength(0) - 1;
                int width = monchaDeviceMesh.GetLength(1) - 1;

                return(new LObjectList()
                {
                    new LObject()
                    {
                        Points = new List <LPoint3D>()
                        {
                            monchaDeviceMesh[tuple.Item2, tuple.Item1].GetMLpoint3D,
                            monchaDeviceMesh[tuple.Item2, tuple.Item1 + (tuple.Item1 < width ? 1 : -1)].GetMLpoint3D,
                            monchaDeviceMesh[tuple.Item2 + (tuple.Item2 < height ? 1 : -1), tuple.Item1 + (tuple.Item1 < width ? 1 : -1)].GetMLpoint3D,
                            monchaDeviceMesh[tuple.Item2 + (tuple.Item2 < height ? 1 : -1), tuple.Item1].GetMLpoint3D
                        },
                        Closed = true,
                        MeshType = meshType
                    }
                });
            }

            LObjectList CalibrationLineH(MonchaDeviceMesh monchaDeviceMesh, LPoint3D lPoint3D, MeshType meshType)
            {
                Tuple <int, int> tuple = monchaDeviceMesh.CoordinatesOf(lPoint3D);
                int height             = monchaDeviceMesh.GetLength(0) - 1;
                int width = monchaDeviceMesh.GetLength(1) - 1;


                //Height
                LObject Line = new LObject()
                {
                    MeshType = meshType
                };

                for (int i = 0; i <= height; i += 1)
                {
                    Line.Add(monchaDeviceMesh[i, tuple.Item1].GetMLpoint3D);
                }

                return(new LObjectList()
                {
                    Line,
                });
            }

            LObjectList CalibrationLineW(MonchaDeviceMesh monchaDeviceMesh, LPoint3D lPoint3D, MeshType meshType)
            {
                Tuple <int, int> tuple = monchaDeviceMesh.CoordinatesOf(lPoint3D);
                int height             = monchaDeviceMesh.GetLength(0) - 1;
                int width = monchaDeviceMesh.GetLength(1) - 1;

                //width
                LObject Line = new LObject()
                {
                    MeshType = meshType
                };

                for (int i = 0; i <= width; i += 1)
                {
                    Line.Add(monchaDeviceMesh[tuple.Item2, i].GetMLpoint3D);
                }



                return(new LObjectList()
                {
                    Line
                });
            }
        }