示例#1
0
        private void SetupDebugConsole()
        {
            if (UseConsole)
            {
                DOut.PrintF  = Console.Write;
                DOut.PrintLn = Console.WriteLine;

                DOut.pl("DOut's output setting is Console");

                //DClient = new DebugClient();

                ////if (DClient.IsValid)
                //{
                //    DOut.PrintFunc = DClient.Write;
                //    DOut.PrintLnFunc = DClient.WriteLine;

                //    DOut.pl("DOut's output setting is DebugServer");
                //}
            }
            else
            {
                MainWindow wnd = (MainWindow)MainWindow;
                DOut.PrintF  = wnd.GetBuiltinConsole().Print;
                DOut.PrintLn = wnd.GetBuiltinConsole().PrintLn;
            }
        }
示例#2
0
        public bool InsPointToLastSelectedSeg()
        {
            if (LastSelSegment == null)
            {
                return(false);
            }

            MarkSegment seg = LastSelSegment.Value;

            CadFigure fig = DB.GetFigure(seg.FigureID);

            if (fig == null)
            {
                return(false);
            }

            if (fig.Type != CadFigure.Types.POLY_LINES)
            {
                return(false);
            }

            bool handle = false;

            handle |= fig.GetPointAt(seg.PtIndexA).IsHandle;
            handle |= fig.GetPointAt(seg.PtIndexB).IsHandle;

            if (handle)
            {
                return(false);
            }

            int ins  = 0;
            int ins0 = Math.Min(seg.PtIndexA, seg.PtIndexB);
            int ins1 = Math.Max(seg.PtIndexA, seg.PtIndexB);

            if (ins0 == 0 && ins1 == fig.PointCount - 1)
            {
                ins = ins1 + 1;
            }
            else
            {
                ins = ins1;
            }

            DOut.pl($"ins={ins} pcnt={fig.PointCount}");

            fig.InsertPointAt(ins, (CadVertex)LastDownPoint);

            ClearSelection();

            fig.SelectPointAt(ins, true);

            return(true);
        }
示例#3
0
        public void PrintPage(PlotterController pc, Graphics printerGraphics, CadSize2D pageSize, CadSize2D deviceSize)
        {
            DOut.pl($"Dev Width:{deviceSize.Width} Height:{deviceSize.Height}");
#if PRINT_WITH_GL_ONLY
            Bitmap bmp = GetPrintableBmp(pc, pageSize, deviceSize);
            printerGraphics.DrawImage(bmp, 0, 0);
#elif PRINT_WITH_GDI_ONLY
            PrintPageGDI(printerGraphics, pageSize, deviceSize);
#else
            PrintPageSwitch(pc, printerGraphics, pageSize, deviceSize);
#endif
        }
示例#4
0
        public FlexArray <int> GetOuterEdge()
        {
            // Pairを持たないHalfEdgeのリストを作成
            List <HalfEdge> heList = new List <HalfEdge>();

            ForEachHalfEdge(he => {
                if (he.Pair == null)
                {
                    heList.Add(he);
                }
            });

            FlexArray <int> ret = new FlexArray <int>();

            if (heList.Count <= 1)
            {
                return(ret);
            }

            int s = FindMaxDistantHalfEdge(CadVertex.Zero, heList);

            if (s == -1)
            {
                DOut.pl("HeModel.GetOuterEdge not found start HalfEdge");
                return(ret);
            }


            int      t   = s;
            HalfEdge whe = heList[t];

            int vi = whe.Vertex;

            heList.RemoveAt(t);

            while (true)
            {
                ret.Add(vi);
                vi = whe.Next.Vertex;

                t = FindHalfEdge(vi, heList);

                if (t == -1)
                {
                    break;
                }

                whe = heList[t];
                heList.RemoveAt(t);
            }

            return(ret);
        }
示例#5
0
        private void testSvg()
        {
            List <CadFigure> figList = Controller.DB.GetSelectedFigList();

            SvgExporter svgExporter = new SvgExporter();

            XDocument doc = svgExporter.ToSvg(figList,
                                              Controller.DC,
                                              Controller.PageSize.Width,
                                              Controller.PageSize.Height);

            DOut.pl(doc.ToString());
            doc.Save(@"f:\work2\test.svg");
        }
示例#6
0
        public ConsoleCommand(string input)
        {
            // Ugly regex to split string on spaces, but preserve quoted text intact:
            var stringArray =
                Regex.Split(input,
                            "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");

            _arguments = new List <string>();
            for (int i = 0; i < stringArray.Length; i++)
            {
                // The first element is always the command:
                if (i == 0)
                {
                    this.Name = stringArray[i];

                    // Set the default:
                    this.LibraryClassName = "Application";
                    string[] s = DOut.FirstToCapital(stringArray[0].Split('.'));
                    if (s.Length == 2)
                    {
                        this.LibraryClassName = s[0];
                        this.Name             = s[1];
                    }
                    else if (s.Length == 1)
                    {
                        this.Name = s[0];
                    }
                }
                else
                {
                    var    inputArgument = stringArray[i];
                    string argument      = inputArgument;

                    // Is the argument a quoted text string?
                    var regex = new Regex("\"(.*?)\"", RegexOptions.Singleline);
                    var match = regex.Match(inputArgument);

                    if (match.Captures.Count > 0)
                    {
                        // Get the unquoted text:
                        var captureQuotedText = new Regex("[^\"]*[^\"]");
                        var quoted            = captureQuotedText.Match(match.Captures[0].Value);
                        argument = quoted.Captures[0].Value;
                    }
                    _arguments.Add(argument);
                }
            }
        }
示例#7
0
        public static CadData?Load(string fname)
        {
            FileStream fs = new FileStream(fname, FileMode.Open, FileAccess.Read);

            byte[] sign = new byte[Sign.Length];

            fs.Read(sign, 0, Sign.Length);

            if (!Sign.SequenceEqual <byte>(sign))
            {
                fs.Close();
                return(null);
            }

            byte[] version = new byte[Version.Length];

            fs.Read(version, 0, Version.Length);

            byte[] data = new byte[fs.Length - Sign.Length - Version.Length];

            fs.Read(data, 0, data.Length);

            fs.Close();

            DOut.pl($"MpCadFile.Load {fname} {VersionStr(version)}");

            if (IsVersion(version, 1, 0, 0, 0))
            {
                return(null);
            }
            else if (IsVersion(version, 1, 0, 0, 1))
            {
                MpCadData_v1001 mpdata = MessagePackSerializer.Deserialize <MpCadData_v1001>(data);
                return(MpUtil_v1001.CreateCadData_v1001(mpdata));
            }
            else if (IsVersion(version, 1, 0, 0, 2))
            {
                MpCadData_v1002 mpdata = MessagePackSerializer.Deserialize <MpCadData_v1002>(data);
                return(MpUtil_v1002.CreateCadData_v1002(mpdata));
            }

            return(null);
        }
示例#8
0
        private void test009()
        {
            DrawContext dc = Controller.DC;

            CadObjectDB db = Controller.DB;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            int i        = 0;
            int layerCnt = db.LayerList.Count;

            for (; i < layerCnt; i++)
            {
                CadLayer layer = db.LayerList[i];

                int j      = 0;
                int figCnt = layer.FigureList.Count;

                for (; j < figCnt; j++)
                {
                    CadFigure fig = layer.FigureList[j];

                    int k    = 0;
                    int pcnt = fig.PointList.Count;

                    for (; k < pcnt; k++)
                    {
                        CadVertex p  = fig.PointList[k];
                        CadVertex sp = dc.WorldPointToDevPoint(p);
                    }
                }
            }

            sw.Stop();
            DOut.pl(sw.ElapsedMilliseconds.ToString() + " milli sec");
        }
示例#9
0
        static void Main(string[] args)
        {
            var parenRef = new GenericClass <Parent>();
            var childRef = new GenericClass <Child>();

            IIn <Child> Ci = parenRef;
            I <Parent>  p  = parenRef;

            IOut <Parent> Po = childRef;
            I <Child>     c  = childRef;



            DOut <Parent> DGetP = GetParent;
            DOut <Child>  DGetC = GetChild;

            DGetP = DGetC;

            DIn <Parent> DSetP = SetParent;
            DIn <Child>  DSetC = SetChild;

            DSetC = DSetP;
        }
示例#10
0
        public void RemoveVertexs(List <int> idxList)
        {
            int[] indexMap = new int[VertexStore.Count];

            for (int i = 0; i < idxList.Count; i++)
            {
                indexMap[idxList[i]] = -1;
            }

            int r = 0;

            for (int i = 0; i < VertexStore.Count; i++)
            {
                if (indexMap[i] != -1)
                {
                    indexMap[i] = r;
                    r++;
                }
            }

            ForEachHalfEdge(he =>
            {
                he.Vertex = indexMap[he.Vertex];
                if (he.Vertex == -1)
                {
                    DOut.pl("HeModel.RemoveVertexs error. he.Vertex == -1");
                }
            });

            for (int i = VertexStore.Count - 1; i >= 0; i--)
            {
                if (indexMap[i] == -1)
                {
                    VertexStore.RemoveAt(i);
                }
            }
        }