예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="g">granne source</param>
 private Granne(Granne g)
 {
     this.model     = g.model.Clone() as CadreModel;
     this.indexX    = g.indexX; this.indexY = g.indexY;
     this.sizeX     = g.sizeX; this.sizeY = g.sizeY;
     this.shiftLeft = g.shiftLeft; this.shiftRight = g.shiftRight;
     this.shiftTop  = g.shiftTop; this.shiftBottom = g.shiftBottom;
 }
예제 #3
0
 /// <summary>
 /// Compares two grannes by vertical index
 /// return 1 if g1 >= g2 else -1
 /// </summary>
 /// <param name="g1"></param>
 /// <param name="g2"></param>
 /// <returns></returns>
 public static int VerticalComparer(Granne g1, Granne g2)
 {
     if (g1.indexY >= g2.indexY)
     {
         return(1);
     }
     else
     {
         return(-1);
     }
 }
예제 #4
0
 /// <summary>
 /// Compares two grannes by horizontal index
 /// return 1 if g1 >= g2 else -1
 /// </summary>
 /// <param name="g1">granne 1</param>
 /// <param name="g2">granne 2</param>
 /// <returns>1 or -1</returns>
 public static int HorizontalComparer(Granne g1, Granne g2)
 {
     if (g1.indexX >= g2.indexX)
     {
         return(1);
     }
     else
     {
         return(-1);
     }
 }
예제 #5
0
        /// <summary>
        /// Generate grannes
        /// </summary>
        /// <returns>hash set of granne</returns>
        private HashSet <Granne> GenerateGrannes()
        {
            Granne.Init();
            Granne.ComputeGranne(this.Cadres);
            HashSet <Granne> grannes = new HashSet <Granne>();

            foreach (CadreModel c in this.Cadres)
            {
                Granne.SetTrueRect(c.WidthPosition, c.HeightPosition, c.WidthPosition + c.Width, c.HeightPosition + c.Height);
            }
            foreach (CadreModel c in this.Cadres)
            {
                grannes.Add(new Granne(c, c.WidthPosition, c.HeightPosition, c.Width, c.Height));
            }
            return(grannes);
        }
예제 #6
0
 /// <summary>
 /// Generate content
 /// </summary>
 /// <param name="list">list of sized rectangle</param>
 /// <param name="g">granne to generate</param>
 internal void GenerateContent(List <AreaSizedRectangle> list, Granne g)
 {
     if (this.Type == RefObject.MasterPage)
     {
         MasterPage mp = this.Destination;
         list.Add(g.ConvertToDrawingRectangle());
     }
     else if (this.Type == RefObject.Page)
     {
         MasterPage mp = this.SecondObject;
         list.Add(g.ConvertToDrawingRectangle());
     }
     else if (this.Type == RefObject.MasterObject)
     {
         MasterObject mo = this.Destination;
         list.Add(g.ConvertToDrawingRectangle());
     }
     else if (this.Type == RefObject.Tool)
     {
         MasterObject mo = this.SecondObject;
         list.Add(g.ConvertToDrawingRectangle());
     }
 }
예제 #7
0
        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns>cloned object</returns>
        public object Clone()
        {
            Granne newObject = new Granne(this);

            return(newObject);
        }
예제 #8
0
 /// <summary>
 /// Compute for all cadre model
 /// to select the minimum size cadre model
 /// </summary>
 /// <param name="list">list of cadre model</param>
 public static void ComputeGranne(List <CadreModel> list)
 {
     Granne.SetMinGranne(list.Min(a => a.Width), list.Min(a => a.Height));
 }