Пример #1
0
		public void MakeSureEdgeEven(ref Section section, CutType cutType)
		{
            if (cutType == CutType.Horizontal && !section.IsTopEven())
                Cut(section, m_parameters.CutOffLeft - m_parameters.CutterThickness, cutType, out section);
            else if (cutType == CutType.Vertical && !section.IsLeftEven())
                Cut(section, m_parameters.CutOffLeft - m_parameters.CutterThickness, cutType, out section);
		}
Пример #2
0
        private void RecursiveLoadSections(Denisenko.Cutting.Section section, Boolean transpose)
        {
            if (section.NestedSections.Count == 0)
            {
                Section sec = new Section();

                switch (section.SectionType)
                {
                case SectionType.Element:
                    sec.Brush = Brushes.SlateBlue;
                    break;

                case SectionType.Remain:
                    sec.Brush = Brushes.Red;
                    break;

                case SectionType.Scrap:
                    break;

                case SectionType.Free:
                    sec.Brush = Brushes.Silver;
                    break;

                case SectionType.Cut:
                    if (section.Width > section.Height)
                    {
                        sec.Brush = Brushes.DarkCyan;
                    }
                    else
                    {
                        sec.Brush = Brushes.Cyan;
                    }
                    break;
                }

                if (transpose)
                {
                    sec.X      = (Single)section.Y;
                    sec.Y      = (Single)section.X;
                    sec.Width  = (Single)section.Height;
                    sec.Height = (Single)section.Width;
                }
                else
                {
                    sec.X      = (Single)section.X;
                    sec.Y      = (Single)section.Y;
                    sec.Width  = (Single)section.Width;
                    sec.Height = (Single)section.Height;
                }
                sec.SourceSection = section;
                m_sections.Add(sec);
            }
            else
            {
                foreach (Denisenko.Cutting.Section nestedSection in section.NestedSections)
                {
                    RecursiveLoadSections(nestedSection, transpose);
                }
            }
        }
Пример #3
0
        public Section Cut(Section section, Decimal size, CutType cutType, out Section remain)
		{
			if(section.CutType != cutType)
			{
				section = CreateNestedSection(section, cutType);
			}
            Section result = SplitSection(section, size, cutType, out remain);
            Changed();
            return result;
		}
Пример #4
0
 public CuttingScheme(CuttingScheme orig)
 {
     m_rootSection = new Section(orig.m_rootSection, null, this);
     if (orig.m_parameters != null)
     {
         m_parameters = orig.m_parameters.Clone();
     }
     if (orig.m_material != null)
     {
         m_material = (Material)orig.m_material.Clone();
     }
     if (orig.m_sheet != null)
     {
         m_sheet = (Sheet)orig.m_sheet.Clone();
     }
 }
Пример #5
0
		/*
		 * Предыдущая секция нужна в случае если конвертитуется обрезок, т.к.
		 * его размер должен включать размер реза, который находится перед ним.
		 */
		private Lane ConvertSection(Section input, Section prevSection, Section nextSection)
		{
			Lane result = new Lane();
			result.Size = input.Size;
			switch (input.SectionType)
			{
				case SectionType.Cut:
					result.LaneType = LaneType.Cut;
                    result.SizeType = SizeType.Automatic;
                    break;
				case SectionType.Element:
                    result.LaneType = LaneType.Detail;
                    result.SizeType = SizeType.Changeable;
                    result.Name = DetailNameFixer.Convert(Transliterator.Convert(input.Label));
                    break;
				case SectionType.NewLine:
                    result.LaneType = LaneType.Lane;
                    result.SizeType = SizeType.Changeable;
                    break;
				case SectionType.Remain:
                    result.LaneType = LaneType.Rest;
                    result.SizeType = SizeType.Changeable;
                    break;
				case SectionType.Scrap:
                    result.LaneType = LaneType.Cutoff;
                    result.SizeType = SizeType.Automatic;
					if (prevSection != null && prevSection.SectionType == SectionType.Cut)
						result.Size = input.Size + prevSection.Size;
					if (nextSection != null && nextSection.SectionType == SectionType.Cut)
						result.Size = input.Size + nextSection.Size;
					break;
				case SectionType.Free:
                    result.LaneType = LaneType.Cutoff;
                    result.SizeType = SizeType.Automatic;
                    if (prevSection != null && prevSection.SectionType == SectionType.Cut)
						result.Size = input.Size + prevSection.Size;
					if (nextSection != null && nextSection.SectionType == SectionType.Cut)
						result.Size = input.Size + nextSection.Size;
					break;
			}
			return result;
		}
	unsafe private void Recursive(_Layout * input, Section output)
	{
        CutType cutType = input->along == 0 ? CutType.Vertical : CutType.Horizontal;
		m_result.MakeSureEdgeEven(ref output, cutType);

        for (uint i = 0; i < (uint)input->num_elements; i++)
        {
            if (input->elements[i].type == (int)ElementType.Cut)
                continue;
            else if (input->elements[i].type == (int)ElementType.Remain)
                continue;
            var this_sec = m_result.Cut(output, _GuillotineApi.FromScaled(input->elements[i].size), cutType, out output);
            if (input->elements[i].type == (int)ElementType.Rect)
            {
                m_result.MarkAsPart(this_sec);
            }
            else if (input->elements[i].type == (int)ElementType.SubLayout)
            {
                Recursive(input->elements[i].layout, this_sec);
            }
        }
	}
Пример #7
0
		internal Section(Section original, Section parent, CuttingScheme scheme)
		{
            m_data = original.m_data;

            m_nestedSections = new LinkedList<Section>();
            foreach (Section nsec in original.m_nestedSections)
            {
                m_nestedSections.AddLast(new Section(nsec, this, scheme));
            }
            m_parent = parent;
            m_scheme = scheme;
		}
Пример #8
0
		public CuttingScheme()
		{
			m_rootSection = new Section(this);
		}
Пример #9
0
		/*public Section Cut(Decimal size, out Section remain)
		{
			throw new NotImplementedException();
		}

		public Section CutPart(Section section, Part part, CutType cutType, out Section remain)
		{
			throw new NotImplementedException();
		}

		public Section CutPart(Part part, out Section remain)
		{
			throw new NotImplementedException();
		}*/

		public void MarkAsPart(Section section)
		{
            section.m_data.m_sectionType = SectionType.Element;
		}
Пример #10
0
		private void RecursiveAddStatistics(ref Statistics statistics, Section section)
		{
			Double sectionSquare = (Double)section.Width * (Double)section.Height;
			if (section.SectionType == SectionType.Cut)
			{
				statistics.DustSquare += sectionSquare;
				statistics.CutsCount++;
			}
			else if(section.SectionType == SectionType.Element)
			{
				statistics.DetailsSquare += sectionSquare;
				statistics.DetailsCount++;
			}
			else if (section.SectionType == SectionType.Remain)
			{
				statistics.RemainsSquare += sectionSquare;
				statistics.RemainsCount++;
			}
			else if (section.SectionType == SectionType.Scrap)
			{
				statistics.ScrapsSquare += sectionSquare;
				statistics.ScrapsCount++;
			}
			else if (section.SectionType == SectionType.Free)
			{
				statistics.UndefinitesSquare += sectionSquare;
				statistics.UndefinitesCount++;
			}
			foreach(Section nested in section.NestedSections)
			{
				RecursiveAddStatistics(ref statistics, nested);
			}
		}
Пример #11
0
		private Section CreateNestedSection(Section section, CutType cutType)
		{
			Section result = new Section(this);
            result.m_data.m_x = section.m_data.m_x;
            result.m_data.m_y = section.m_data.m_y;
            result.m_data.m_width = section.m_data.m_width;
            result.m_data.m_height = section.m_data.m_height;
            result.m_data.m_cutType = cutType;
			result.m_parent = section;
            result.m_data.m_topEven = section.m_data.m_topEven;
            result.m_data.m_leftEven = section.m_data.m_leftEven;
            result.m_data.m_bottomEven = section.m_data.m_bottomEven;
            result.m_data.m_rightEven = section.m_data.m_rightEven;
            result.m_data.m_sectionType = SectionType.Free;
            section.m_data.m_sectionType = SectionType.NewLine;
			section.NestedSections.AddLast(result);
			return result;
		}
Пример #12
0
		private Section SplitSection(Section section, Decimal size, CutType cutType, out Section remain)
		{
			Debug.Assert(cutType == section.CutType);

            // создаём и инициализируем 3 новые подсекции, одна типа разрез и две свободные
            // в случае если для остатка не остаётся места то будет создано лишь 2 секции
			Section cut = new Section(this);
			cut.m_parent = section.m_parent;
            cut.m_data.m_cutType = cutType;
            cut.m_data.m_sectionType = SectionType.Cut;
			if(cutType == CutType.Horizontal)
			{
                if (size > section.m_data.m_height)
				{
					throw new Exception("Section is too small");
				}
                cut.m_data.m_x = section.m_data.m_x;
                cut.m_data.m_y = section.m_data.m_y + size;
                cut.m_data.m_width = section.m_data.m_width;
                cut.m_data.m_height = Math.Min(m_parameters.CutterThickness, section.m_data.m_height - size);
                decimal remainHeight = section.m_data.m_height - size - m_parameters.CutterThickness;
                if (remainHeight > decimal.Zero)
                {
                    remain = new Section(this);
                    remain.m_data.m_topEven = true;
                    remain.m_data.m_bottomEven = section.m_data.m_bottomEven;
                    remain.m_data.m_leftEven = section.m_data.m_leftEven;
                    remain.m_data.m_rightEven = section.m_data.m_rightEven;
                    remain.m_data.m_x = section.m_data.m_x;
                    remain.m_data.m_y = section.m_data.m_y + size + m_parameters.CutterThickness;
                    remain.m_data.m_width = section.m_data.m_width;
                    remain.m_data.m_height = remainHeight;
                }
                else
                {
                    remain = null;
                }
                section.m_data.m_bottomEven = true;
                section.m_data.m_height = size;
			}
			else // Vertical
			{
                if (size > section.m_data.m_width)
				{
					throw new Exception("Section is too small");
				}
                cut.m_data.m_x = section.m_data.m_x + size;
                cut.m_data.m_y = section.m_data.m_y;
                cut.m_data.m_width = Math.Min(m_parameters.CutterThickness, section.m_data.m_width - size);
                cut.m_data.m_height = section.m_data.m_height;
                decimal remainWidth = section.m_data.m_width - size - m_parameters.CutterThickness;
                if (remainWidth > decimal.Zero)
                {
                    remain = new Section(this);
                    remain.m_data.m_leftEven = true;
                    remain.m_data.m_rightEven = section.m_data.m_rightEven;
                    remain.m_data.m_topEven = section.m_data.m_topEven;
                    remain.m_data.m_bottomEven = section.m_data.m_bottomEven;
                    remain.m_data.m_x = section.m_data.m_x + size + m_parameters.CutterThickness;
                    remain.m_data.m_y = section.m_data.m_y;
                    remain.m_data.m_width = remainWidth;
                    remain.m_data.m_height = section.m_data.m_height;
                }
                else
                {
                    remain = null;
                }
                section.m_data.m_rightEven = true;
                section.m_data.m_width = size;
			}

            // заменяем ту секцию, которую мы разрезали на новую, отрезанную секцию
            // и вставляем 2 оставшиеся секции после неё в списоке подсекций родительской секции
            section.m_parent.NestedSections.AddAfter(section.m_parent.NestedSections.Find(section), cut);
			if (remain != null)
			{
                remain.m_data.m_cutType = cutType;
                remain.m_data.m_sectionType = SectionType.Free;
                remain.m_parent = section.m_parent;
                section.m_parent.NestedSections.AddAfter(section.m_parent.NestedSections.Find(cut), remain);
			}

			return section;
		}