/// <summary> /// Create all objects for sculpture generation on a project /// </summary> /// <param name="proj">project to edit</param> /// <param name="gs">generated sculpture</param> public void CreateProjectObject(Project proj, GeneratedSculpture gs) { Granne.Init(); SortedSet <Granne> set = this.SortGranne(this.GenerateGrannes()); uint trueWidth = 0, trueHeight = 0; uint countX = 0, countY = 0; if (Granne.TrueRectangle.Width > 0) { trueWidth = (uint)Granne.TrueRectangle.Width; } if (Granne.TrueRectangle.Height > 0) { trueHeight = (uint)Granne.TrueRectangle.Height; } if (Granne.Size.Width > 0) { countX = (uint)Granne.Size.Width; } if (Granne.Size.Height > 0) { countY = (uint)Granne.Size.Height; } Granne[,] tab2D = new Granne[countX, countY]; foreach (Granne g in set) { g.InsertIntoArray(tab2D); } gs.CreateDestination(proj, trueWidth, trueHeight, countX, countY); this.FillObjects(proj, gs, tab2D); }
/// <summary> /// Copy constructor /// </summary> /// <param name="gs">generated sculpture to copy</param> private GeneratedSculpture(GeneratedSculpture gs) { this.Type = ExtensionMethods.CloneThis(gs.Type); this.Name = ExtensionMethods.CloneThis(gs.Name); this.SecondObject = ExtensionMethods.CloneThis(gs.SecondObject); this.Destination = ExtensionMethods.CloneThis(gs.Destination); foreach (RefObject r in gs.Objects) { this.Objects.Add(r.Clone() as RefObject); } foreach (CadreModel cm in gs.RemainerModels) { this.RemainerModels.Add(cm.Clone() as CadreModel); } }
/// <summary> /// Fill objects /// </summary> /// <param name="proj">project to edit</param> /// <param name="gs">generated sculpture</param> /// <param name="tab">two dimensional tabular granne</param> private void FillObjects(Project proj, GeneratedSculpture gs, Granne[,] tab) { List <AreaSizedRectangle> list = new List <AreaSizedRectangle>(); gs.RemainerModels.Clear(); gs.Objects.Clear(); for (int y = 0; y < tab.GetLength(1); ++y) { for (int x = 0; x < tab.GetLength(0); ++x) { if (tab[x, y] != null) { gs.GenerateContent(list, tab[x, y]); tab[x, y].InsertModel(gs.RemainerModels); gs.Objects.Add(tab[x, y].CreateRefObject(proj)); } } } gs.GenerateContent(list); }
/// <summary> /// Clone this object /// </summary> /// <returns>cloned object</returns> public object Clone() { GeneratedSculpture newObject = new GeneratedSculpture(this); return(newObject); }