public new object Clone() { CEntityLine entity; entity = new CEntityLine(); CloneEntity(entity); return(entity); }
private void BuildSquareList() { List <CEntityLine> lineList = new List <CEntityLine>(); foreach (object obj in EntityList) { if (obj is CEntityLine) { CEntityLine line = obj as CEntityLine; if (line != null) { lineList.Add(line); } } } foreach (CEntityLine line1 in lineList) { foreach (CEntityLine line2 in lineList) { if (line2.Y0 == line1.Y1 && line2.X0 == line1.X1) { foreach (CEntityLine line3 in lineList) { if (line3.Y0 == line2.Y1 && line3.X0 == line2.X1) { foreach (CEntityLine line4 in lineList) { if (line4.Y0 == line3.Y1 && line4.X0 == line3.X1) { //this would mark a parallagram or trapezoid as a rectangle. Needs modified for angles. //if (line1.Length == line2.Length && line1.Length == line3.Length && line1.Length == line4.Length) //{ double smallestX0 = line1.X0; if (line2.X0 < smallestX0) { smallestX0 = line2.X0; } if (line3.X0 < smallestX0) { smallestX0 = line3.X0; } if (line4.X0 < smallestX0) { smallestX0 = line4.X0; } double smallestY0 = line1.Y0; if (line2.Y0 < smallestY0) { smallestY0 = line2.Y0; } if (line3.Y0 < smallestY0) { smallestY0 = line3.Y0; } if (line4.Y0 < smallestY0) { smallestY0 = line4.Y0; } double largestX1 = line1.X1; if (line2.X1 > largestX1) { largestX1 = line2.X1; } if (line3.X1 > largestX1) { largestX1 = line3.X1; } if (line4.X1 > largestX1) { largestX1 = line4.X1; } double largestY1 = line1.Y1; if (line2.Y1 > largestY1) { largestY1 = line2.Y1; } if (line3.Y1 > largestY1) { largestY1 = line3.Y1; } if (line4.Y1 > largestY1) { largestY1 = line4.Y1; } if (!line1.PartOfComplexShape && !line2.PartOfComplexShape && !line3.PartOfComplexShape && !line4.PartOfComplexShape) { CEntityRectangle square = new CEntityRectangle(); square.Width = Math.Round(largestX1 - smallestX0, 3); square.Height = Math.Round(largestY1 - smallestY0, 3); square.CenterPoint_Horizontal = Math.Round(smallestX0 + (square.Width / 2), 3); square.CenterPoint_Vertical = Math.Round(smallestY0 + (square.Height / 2), 3); bool alreadyHave = false; foreach (object obj in m_SquaresList) { CEntityRectangle rect = obj as CEntityRectangle; if (rect.CenterPoint_Horizontal == square.CenterPoint_Horizontal && rect.CenterPoint_Vertical == square.CenterPoint_Vertical && rect.Width == square.Width) { alreadyHave = true; break; } } if (!alreadyHave) { if (square.Width == square.Height) { m_SquaresList.Add(square); } else { m_RectanglesList.Add(square); } } } //} } } } } } } } m_SquareListBuilt = true; }