public void Draw(Sierpinski t, ref List<Entity> ents, int maxDepth = 15) { if (t.depth > maxDepth) return; else { ents.Add(t.Triangle); foreach (Sierpinski tri in t.GetTriangles()) Draw(tri, ref ents, maxDepth); } }
public Sierpinski[] GetTriangles() { Point2d MidAB = MidPoint(A, B), MidBC = MidPoint(B, C), MidAC = MidPoint(A, C); Sierpinski t1 = new Sierpinski(A, MidAB, MidAC), t2 = new Sierpinski(B, MidAB, MidBC), t3 = new Sierpinski(C, MidAC, MidBC); t1.depth = depth + 1; t2.depth = depth + 1; t3.depth = depth + 1; return new Sierpinski[] { t1, t2, t3 }; }
public void DrawTriangle() { Point3d insPt; Double size; if (Lab2.Selector.Point("Punto de inserción", out insPt) && Lab2.Selector.Double("El tamaño del triangulo", out size)) { Sierpinski triangle = new Sierpinski(insPt, size); List<Entity> ents = new List<Entity>(); triangle.Draw(triangle, ref ents, 5); Lab3.DBMan.Draw(ents.ToArray()); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("Total de triangulos", ents.Count); } }