private double AngleBetween2Lines(clsEntity Entity1_In, clsEntity Entity2_In) //=========================================================================== { const double pc_Rad2Deg = 180.0 / Math.PI; double angle1 = Math.Atan2(Entity1_In.Begin_Pt.Y - Entity1_In.End_Pt.Y, Entity1_In.Begin_Pt.X - Entity1_In.End_Pt.X); double angle2 = Math.Atan2(Entity2_In.Begin_Pt.Y - Entity2_In.End_Pt.Y, Entity2_In.Begin_Pt.X - Entity2_In.End_Pt.X); return((angle1 - angle2) * pc_Rad2Deg); }
private void Calc_LineSlope(clsEntity Entity_In, ref double Slope_Out) //==================================================================== { //double pcInfinity_Slope = 99.99F; double pEntityIn_Denominator = (Entity_In.End_Pt.X - Entity_In.Begin_Pt.X); if (Math.Abs(pEntityIn_Denominator - 0.0) < modMain.gcEPS) { Slope_Out = 90.0; } else { Slope_Out = (Entity_In.End_Pt.Y - Entity_In.Begin_Pt.Y) / pEntityIn_Denominator; } }
private List <clsEntity> ArrangeEntityCW(List <clsEntity> EntityList_In) //========================================================= { List <clsEntity> EntityList = new List <clsEntity>(); clsEntity pEntity = new clsEntity(); pEntity = EntityList_In[0]; EntityList.Add(pEntity); for (int i = 1; i < EntityList_In.Count; i++) { for (int j = 0; j < EntityList_In.Count; j++) { if ((Math.Abs(EntityList_In[j].Begin_Pt.X - pEntity.End_Pt.X) < modMain.gcEPS && Math.Abs(EntityList_In[j].Begin_Pt.Y - pEntity.End_Pt.Y) < modMain.gcEPS) && (!(Math.Abs(EntityList_In[j].End_Pt.X - pEntity.Begin_Pt.X) < modMain.gcEPS) && !(Math.Abs(EntityList_In[j].End_Pt.Y - pEntity.Begin_Pt.Y) < modMain.gcEPS))) { pEntity = new clsEntity(); pEntity.Begin_Pt = EntityList_In[j].Begin_Pt; pEntity.End_Pt = EntityList_In[j].End_Pt; pEntity.G_Code = EntityList_In[j].G_Code; EntityList.Add(pEntity); break; } else if ((Math.Abs(EntityList_In[j].End_Pt.X - pEntity.End_Pt.X) < modMain.gcEPS && Math.Abs(EntityList_In[j].End_Pt.Y - pEntity.End_Pt.Y) < modMain.gcEPS) && (!(Math.Abs(EntityList_In[j].Begin_Pt.X - pEntity.Begin_Pt.X) < modMain.gcEPS) && !(Math.Abs(EntityList_In[j].Begin_Pt.Y - pEntity.Begin_Pt.Y) < modMain.gcEPS))) { pEntity = new clsEntity(); pEntity.Begin_Pt = EntityList_In[j].End_Pt; pEntity.End_Pt = EntityList_In[j].Begin_Pt; pEntity.G_Code = EntityList_In[j].G_Code; EntityList.Add(pEntity); break; } } } return(EntityList); }
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); }
//==================================================================== private void Calc_LineSlope(clsEntity Entity_In, ref double Slope_Out) { //double pcInfinity_Slope = 99.99F; double pEntityIn_Denominator = (Entity_In.End_Pt.X - Entity_In.Begin_Pt.X); if (Math.Abs(pEntityIn_Denominator - 0.0) < modMain.gcEPS) { Slope_Out = 90.0; } else { Slope_Out = (Entity_In.End_Pt.Y - Entity_In.Begin_Pt.Y) / pEntityIn_Denominator; } }
//=========================================================================== private double AngleBetween2Lines(clsEntity Entity1_In, clsEntity Entity2_In) { const double pc_Rad2Deg = 180.0 / Math.PI; double angle1 = Math.Atan2(Entity1_In.Begin_Pt.Y - Entity1_In.End_Pt.Y, Entity1_In.Begin_Pt.X - Entity1_In.End_Pt.X); double angle2 = Math.Atan2(Entity2_In.Begin_Pt.Y - Entity2_In.End_Pt.Y, Entity2_In.Begin_Pt.X - Entity2_In.End_Pt.X); return (angle1 - angle2) * pc_Rad2Deg; }