コード例 #1
0
ファイル: clsEntity.cs プロジェクト: anirbanmete/Project_EHRT
        public static double GetDistance_BetwnPts(modMain.myPoint pPt1_In, modMain.myPoint pPt2_In)
        //===================================================================================
        {
            double pDistance = Math.Sqrt(Math.Pow((pPt2_In.X - pPt1_In.X), 2) +
                                         Math.Pow((pPt2_In.Y - pPt1_In.Y), 2));

            return(pDistance);
        }
コード例 #2
0
        private List <clsEntity> ReadDXFLayer(string FileName_In, string LayerName_In)
        //===========================================================================
        {
            StreamReader pSR  = new StreamReader(FileName_In);
            string       pstr = "";

            pstr = pSR.ReadLine();
            List <clsEntity> pEntityList = new List <clsEntity>();


            while (pstr != null)
            {
                pstr = pstr.Trim();
                if (pstr == LayerName_In)
                {
                    pstr = pSR.ReadLine().Trim();

                    while (pstr != "0")
                    {
                        //if (pstr.Contains("62"))
                        //{
                        //    pSR.ReadLine();
                        //    pstr = pSR.ReadLine();
                        //}
                        //if (pstr.Contains("100"))
                        //{
                        pstr = pSR.ReadLine().Trim();             //....AcDbLine

                        if (pstr.Contains("AcDbLine"))
                        {
                            clsEntity       pEntity = new clsEntity();
                            modMain.myPoint pPt1    = new modMain.myPoint();
                            modMain.myPoint pPt2    = new modMain.myPoint();
                            pstr = pSR.ReadLine();
                            if (pstr.Contains("10"))
                            {
                                pPt1.X = Convert.ToDouble(pSR.ReadLine());
                            }
                            pstr = pSR.ReadLine();
                            if (pstr.Contains("20"))
                            {
                                pPt1.Y = Convert.ToDouble(pSR.ReadLine());
                            }
                            pEntity.Begin_Pt = pPt1;

                            pSR.ReadLine();
                            pSR.ReadLine();

                            pstr = pSR.ReadLine();
                            if (pstr.Contains("11"))
                            {
                                pPt2.X = Convert.ToDouble(pSR.ReadLine());
                            }
                            pstr = pSR.ReadLine();
                            if (pstr.Contains("21"))
                            {
                                pPt2.Y = Convert.ToDouble(pSR.ReadLine());
                            }
                            pEntity.End_Pt = pPt2;
                            pEntity.G_Code = 1;
                            pEntityList.Add(pEntity);
                        }
                        //}
                    }
                }
                pstr = pSR.ReadLine();
            }

            pSR.Close();

            return(pEntityList);
        }
コード例 #3
0
ファイル: clsEntity.cs プロジェクト: anirbanmete/Project_EHRT
        //===============

        public modMain.myPoint CenterPt_Arc()
        //=====================================
        {
            modMain.myPoint[] pTempCenPt = new modMain.myPoint[4];
            modMain.myPoint   pCenPt;
            pCenPt.X = 0.0F;
            pCenPt.Y = 0.0F;

            if (mG_Code == 2)
            {
                pTempCenPt[0].X = mBegin_Pt.X + mI_Code;
                pTempCenPt[0].Y = mBegin_Pt.Y + mJ_Code;

                pTempCenPt[1].X = mBegin_Pt.X + mI_Code;
                pTempCenPt[1].Y = mBegin_Pt.Y - mJ_Code;

                pTempCenPt[2].X = mBegin_Pt.X - mI_Code;
                pTempCenPt[2].Y = mBegin_Pt.Y + mJ_Code;

                pTempCenPt[3].X = mBegin_Pt.X - mI_Code;
                pTempCenPt[3].Y = mBegin_Pt.Y - mJ_Code;

                for (int pIndx = 0; pIndx < 4; pIndx++)
                {
                    double pTemp1 = Math.Pow(mEnd_Pt.Y - pTempCenPt[pIndx].Y, 2.0F) + Math.Pow(mEnd_Pt.X - pTempCenPt[pIndx].X, 2.0F);
                    double pTemp2 = Math.Pow(mBegin_Pt.Y - pTempCenPt[pIndx].Y, 2.0F) + Math.Pow(mBegin_Pt.X - pTempCenPt[pIndx].X, 2.0F);

                    if (Math.Abs(pTemp1 - pTemp2) < mcEPS)
                    {
                        //....Center Point of the Arc.
                        pCenPt.X = pTempCenPt[pIndx].X;
                        pCenPt.Y = pTempCenPt[pIndx].Y;
                        break;
                    }
                }
            }

            else if (mG_Code == 3)
            {
                pTempCenPt[0].X = mBegin_Pt.X + mI_Code;
                pTempCenPt[0].Y = mBegin_Pt.Y + mJ_Code;

                pTempCenPt[1].X = mBegin_Pt.X + mI_Code;
                pTempCenPt[1].Y = mBegin_Pt.Y - mJ_Code;

                pTempCenPt[2].X = mBegin_Pt.X - mI_Code;
                pTempCenPt[2].Y = mBegin_Pt.Y + mJ_Code;

                pTempCenPt[3].X = mBegin_Pt.X - mI_Code;
                pTempCenPt[3].Y = mBegin_Pt.Y - mJ_Code;

                for (int pIndx = 0; pIndx < 4; pIndx++)
                {
                    double pTemp1 = Math.Pow((mEnd_Pt.Y - pTempCenPt[pIndx].Y), 2.0F) + Math.Pow((mEnd_Pt.X - pTempCenPt[pIndx].X), 2.0F);
                    double pTemp2 = Math.Pow((mBegin_Pt.Y - pTempCenPt[pIndx].Y), 2.0F) + Math.Pow((mBegin_Pt.X - pTempCenPt[pIndx].X), 2.0F);

                    if (Math.Abs(pTemp1 - pTemp2) < mcEPS)
                    {
                        //....Center Point of the Arc.
                        pCenPt.X = pTempCenPt[pIndx].X;
                        pCenPt.Y = pTempCenPt[pIndx].Y;
                        break;
                    }
                }
            }

            return(pCenPt);
        }