// Use this for initialization void Start() { var t = GameObject.FindObjectsOfType <ComboBox>(); foreach (var cutObject in CutObjectManager.Get.CutObjects) { listViewUI.Add(cutObject.name); } if (comboBox.ListView.DataSource.Count == 0) { for (CutType type = CutType.Plane; type <= CutType.None; type++) { string value2 = type.ToString(); comboBox.ListView.Add(value2); } } CutObjectAlphaSlider.value = CutObject.CutObjectAlphaStatic; //if (comboBox2.ListView.DataSource.Count == 0) //{ // comboBox2.ListView.Add("Show Current"); // comboBox2.ListView.Add("Show All"); // comboBox2.ListView.Add("Hide All"); //} //comboBox2.Set("Show Current", false); }
public void Update() { if (CutObjectAlpha != _cutObjectAlpha) { _cutObjectAlpha = CutObjectAlpha; CutObjectAlphaStatic = CutObjectAlpha; } if (CutObjectAlphaStatic != CutObjectAlpha) { _cutObjectAlpha = CutObjectAlphaStatic; CutObjectAlpha = CutObjectAlphaStatic; } if (CutType != PreviousCutType || gameObject.GetComponent <MeshFilter>().sharedMesh == null) { SetMesh(); PreviousCutType = CutType; } if (previousHiddenValue != Hidden) { SetHidden(Hidden); previousHiddenValue = Hidden; } //SetHidden(Hidden); //if (CutObjectAlpha == 0) SetHidden(true); GetComponent <MeshRenderer>().sharedMaterial.SetFloat("_CutObjectAlpha", CutObjectAlphaStatic); }
/*public void MarkAsRemain(Section section) { throw new NotImplementedException(); }*/ public static CutType Rotate(CutType cutType) { if(cutType == CutType.Vertical) return CutType.Horizontal; else return CutType.Vertical; }
private CutRouteAction(Session session, ParameterizedLocation parameterizedLocation, DateTime?time, CutType cutType) { this.session = session; this.parameterizedLocation = parameterizedLocation; this.cutType = cutType; this.time = time; }
private void ReadCuttingObjectProperties() { if (cuttingGameObject == null) { stop = true; return; } stop = !cuttingGameObject.enabled || !(Application.isPlaying || cuttingGameObject.cutInEditMode) || cuttingGameObject.cutType == CutType.None; normal = cuttingGameObject.transform.TransformVector(new Vector3(0, 0, -1)); position = cuttingGameObject.transform.position; cuttingGameObject = cuttingGameObject.GetComponent <CuttingObject>(); cuttingGameObject.Subscribe(this); cutType = cuttingGameObject.cutType; if (cutType == CutType.Sphere) { sphereRadius = cuttingGameObject.sphereRadius; } }
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); }
public void MouseMove(MouseEventArgs e) { _fantom.BelongsTo = _link.CurrentCutting; CuttingControl.PointInfo pi = _link.CurrentCutting.QueryPointInfo(e.X, e.Y); bool loDiag = pi.TransX - pi.TransY - _cx + _cy < 0; bool loRevDiag = -pi.TransX - pi.TransY + _cx + _cy < 0; if (loDiag && loRevDiag || !loDiag && !loRevDiag) { _fantom.X = _vert.X; _fantom.Y = _vert.Y; _fantom.Width = _vert.Width; _fantom.Height = _vert.Height; _choosenCut = CutType.Vertical; } else { _fantom.X = _horz.X; _fantom.Y = _horz.Y; _fantom.Width = _horz.Width; _fantom.Height = _horz.Height; _choosenCut = CutType.Horizontal; } _link.CurrentCutting.CurrentCutFantom = _fantom; }
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); } } }
/// <summary> /// Cut the paper. /// </summary> public static void Cut(this IPrinter printer, CutType type = CutType.Partial) { if (printer == null) { throw new ArgumentNullException(nameof(printer)); } printer.Print(new Cut(type)); }
public static PrintableBuilder Cut(this PrintableBuilder builder, CutType type = CutType.Partial) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Add(new Cut(type))); }
public static Cut RandomCut() { double r = RandomGen.RANDOM_GEN.NextDouble(); CutType cType = CutType.SwellRight; if (r < 0.1) { cType = CutType.BleedAboveLeft; } else if (r < 0.2) { cType = CutType.BleedAboveRight; } else if (r < 0.3) { cType = CutType.BleedBelowLeft; } else if (r < 0.4) { cType = CutType.BleedBelowRight; } else if (r < 0.5) { cType = CutType.InjuredJaw; } else if (r < 0.6) { cType = CutType.InjuredNose; } else if (r < 0.8) { cType = CutType.SwellLeft; } CutSeverity severity = CutSeverity.Low; if (cType != CutType.SwellLeft && cType != CutType.SwellRight) { if (RandomGen.CheckRandom(2d / 3)) { severity = CutSeverity.Low; } else if (RandomGen.CheckRandom(2d / 3)) { severity = CutSeverity.Medium; } else if (RandomGen.CheckRandom(2d / 3)) { severity = CutSeverity.High; } else { severity = CutSeverity.Critical; } } return(new Cut(cType, severity)); }
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; }
/// <summary> /// 要截取的字节数 /// </summary> /// <param name="value">输入的字符串</param> /// <param name="length">限定长度</param> /// <param name="ellipsis">是否需要省略号,true--需要,false--不需要</param> /// <param name="cuttype">截取类型 Varchar,NVarchar</param> /// <returns>截取后的字符串,如果是NVarchar--则20个字节就会有10个字符,Varchar--20个字节会有>=10个字符</returns> public static string CutString(string value, int length, bool ellipsis, CutType cuttype) { if (length < 0) { length = 0; } if (value == null) { return(""); } value = value.Trim(); if (value.Length == 0) { return(string.Empty); } if (cuttype == CutType.NVarchar) { if (value.Length > length / 2) { value = value.Substring(0, length / 2); if (ellipsis) { return(value + ".."); } } } else { //没想到这种方法是最高效的 int len = value.Length; int i = 0; for (; i < length && i < len; ++i) { if ((int)(value[i]) > 0xFF) { --length; } } if (length < i && i > 0) { length = i - 1; if (ellipsis) { return(value.Substring(0, length) + ".."); } return(value.Substring(0, length)); } else if (length > len) { length = len; } return(value.Substring(0, length)); } return(value); }
/*public void MarkAsRemain(Section section) * { * throw new NotImplementedException(); * }*/ public static CutType Rotate(CutType cutType) { if (cutType == CutType.Vertical) { return(CutType.Horizontal); } else { return(CutType.Vertical); } }
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); } }
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); }
public ActionResult Edit(CutType cutType) { if (ModelState.IsValid) { cutType.IsDeleted = false; UnitOfWork.CutTypeRepository.Update(cutType); UnitOfWork.Save(); return(RedirectToAction("Index")); } return(View(cutType)); }
// ******** Misc CutType GetCutTypeFromName(string name) { for (CutType type = CutType.Plane; type <= CutType.None; type++) { if (name == type.ToString()) { return(type); } } throw new Exception("Cut type not found"); }
public Note(NoteData data, CutType cut, NoteCutInfo _info, int _multiplier) : this(data, cut) { multiplier = _multiplier; info = _info; if (/*info != null && */ info.swingRatingCounter != null) { timeDependence = Math.Abs(info.cutNormal.z); // info.swingRatingCounter.UnregisterDidFinishReceiver(new WaitForSwing(this)); info.swingRatingCounter.RegisterDidFinishReceiver(new WaitForSwing(this)); } }
public ActionResult Create(CutType cutType) { if (ModelState.IsValid) { cutType.IsDeleted = false; cutType.CreationDate = DateTime.Now; cutType.Id = Guid.NewGuid(); UnitOfWork.CutTypeRepository.Insert(cutType); UnitOfWork.Save(); return(RedirectToAction("Index")); } return(View(cutType)); }
// GET: CutTypes/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CutType cutType = UnitOfWork.CutTypeRepository.GetById(id.Value); if (cutType == null) { return(HttpNotFound()); } return(View(cutType)); }
public CutLapsData Cut(DateTime time, CutType cutType) { var cutLapsData = new CutLapsData(); switch (cutType) { case CutType.Before: foreach (var l in this) { if (l.Time <= time) { cutLapsData.CutLaps.Add(l); } } foreach (var l in cutLapsData.CutLaps) { Remove(l); } if (cutLapsData.CutLaps.Count > 0) { var newLap = new Lap(time, LapType.Start); Add(newLap); cutLapsData.AddedLaps.Add(newLap); } break; case CutType.After: foreach (var l in this) { if (l.Time >= time) { cutLapsData.CutLaps.Add(l); } } foreach (var l in cutLapsData.CutLaps) { Remove(l); } if (cutLapsData.CutLaps.Count > 0) { var newLap = new Lap(time, LapType.Stop); Add(newLap); cutLapsData.AddedLaps.Add(newLap); } break; } return(cutLapsData); }
public void Update() { if (CutType != PreviousCutType || gameObject.GetComponent <MeshFilter>().sharedMesh == null) { SetMesh(); PreviousCutType = CutType; } if (Hidden != previousHiddenValue) { previousHiddenValue = Hidden; SetHidden(Hidden); } GetComponent <MeshRenderer>().sharedMaterial.SetFloat("_CutObjectAlpha", CutObjectAlpha); }
/// <summary> /// 要截取的字节数 /// </summary> /// <param name="input">输入的字符串</param> /// <param name="length">限定长度</param> /// <param name="ellipsis">是否需要省略号,true--需要,false--不需要</param> /// <param name="cuttype">截取类型</param> /// <returns>截取后的字符串,如果是NVarchar--则20个字节就会有10个字符,Varchar--20个字节会有>=10个字符</returns> public static string CutString(string input, int length, bool ellipsis, CutType cuttype) { input = input.Trim(); if (input.Length == 0) { return(string.Empty); } if (cuttype == CutType.NVarchar) { if (input.Length > length / 2) { input = input.Substring(0, length / 2); if (ellipsis) { return(input + ".."); } } } else { Encoding encode = Encoding.GetEncoding("gbk"); string resultString = string.Empty; byte[] myByte = encode.GetBytes(input); if (myByte.Length > length) { resultString = encode.GetString(myByte, 0, length); string lastChar = resultString.Substring(resultString.Length - 1, 1); if (lastChar.Equals(input.Substring(resultString.Length - 1, 1))) { //如果截取后最后一个字符与原始输入字符串中同一位置的字符相等,则表示截取完成 input = resultString; } else { //如果不相等,则减去一个字节再截取 input = encode.GetString(myByte, 0, length - 1); } if (ellipsis) { return(input + ".."); } return(input); } } return(input); }
/// <summary> /// 要截取的字节数 /// </summary> /// <param name="input">输入的字符串</param> /// <param name="length">限定长度</param> /// <param name="ellipsis">是否需要省略号,true--需要,false--不需要</param> /// <param name="cuttype">截取类型</param> /// <returns>截取后的字符串,如果是NVarchar--则20个字节就会有10个字符,Varchar--20个字节会有>=10个字符</returns> public static string CutString(string input, int length, bool ellipsis, CutType cuttype) { input = input.Trim(); if (input.Length == 0) { return string.Empty; } if (cuttype == CutType.NVarchar) { if (input.Length > length / 2) { input = input.Substring(0, length / 2); if (ellipsis) { return input + ".."; } } } else { Encoding encode = Encoding.GetEncoding("gbk"); string resultString = string.Empty; byte[] myByte = encode.GetBytes(input); if (myByte.Length > length) { resultString = encode.GetString(myByte, 0, length); string lastChar = resultString.Substring(resultString.Length - 1, 1); if (lastChar.Equals(input.Substring(resultString.Length - 1, 1))) { //如果截取后最后一个字符与原始输入字符串中同一位置的字符相等,则表示截取完成 input = resultString; } else { //如果不相等,则减去一个字节再截取 input = encode.GetString(myByte, 0, length - 1); } if (ellipsis) { return input + ".."; } return input; } } return input; }
public static CutType RotateCut(CutType cutType) { if (cutType == CutType.Horizontal) { return CutType.Vertical; } else if (cutType == CutType.Vertical) { return CutType.Horizontal; } else { Debug.Fail("Invalid parameter in function RotateCut"); return CutType.Undefined; /*throw InvalidArgumentException();*/ } }
public static CutType RotateCut(CutType cutType) { if (cutType == CutType.Horizontal) { return(CutType.Vertical); } else if (cutType == CutType.Vertical) { return(CutType.Horizontal); } else { Debug.Fail("Invalid parameter in function RotateCut"); return(CutType.Undefined); /*throw InvalidArgumentException();*/ } }
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); }
public void AddTextureDeathParticles(Vector2 cutPosition, CutType typeOfCut) { switch (typeOfCut) { case CutType.HORIZONTAL: break; case CutType.VERTICAL: break; case CutType.DIAGONALPOSITIVE: break; case CutType.DIAGONALNEGATIVE: break; } //add two particles with the split texture. //particleList.addSpriteReuse(); }
public CutHandlesData Cut(ParameterizedLocation parameterizedLocation, CutType cutType) { CutHandlesData cutHandlesData = new CutHandlesData(); cutHandlesData.CutParamaterizedLocation = parameterizedLocation; cutHandlesData.CutType = cutType; switch (cutType) { case CutType.Before: foreach (Handle h in this) { if (h.ParameterizedLocation < parameterizedLocation) { cutHandlesData.CutHandles.Add(h); } } foreach (Handle h in cutHandlesData.CutHandles) { Remove(h); } foreach (Handle h in this) { h.ParameterizedLocation -= parameterizedLocation; } break; case CutType.After: foreach (Handle h in this) { if (h.ParameterizedLocation > parameterizedLocation) { cutHandlesData.CutHandles.Add(h); } } foreach (Handle h in cutHandlesData.CutHandles) { Remove(h); } break; } return(cutHandlesData); }
private Note(NoteData data, CutType cut) { if (data.colorType == ColorType.ColorB) { noteType = BSDNoteType.right; } else if (data.colorType == ColorType.ColorA) { noteType = BSDNoteType.left; } score = new int[] { 0, 0, 0 }; index = data.lineIndex + 4 * (int)data.noteLineLayer; time = data.time; id = actualId; actualId++; noteDirection = data.cutDirection; cutType = cut; }
public void CutTheTree(Fir aim, CutType type) { aim.Cut(type); Console.WriteLine("Срубил он нашу ёлочку"); switch (type) { case CutType.Fully: Console.WriteLine("Под самый корешок."); break; case CutType.Half: Console.WriteLine("Как получилось."); break; case CutType.Partially: Console.WriteLine("Только обрезал."); break; default: Console.WriteLine("Ещё как-то"); break; } }
/// <summary> /// Initializes a new instance of the <see cref="Harvest"/> struct for a diameter limit cut. /// </summary> /// <param name='ids'> /// Identifiers. /// </param> /// <param name='duration'> /// Duration. /// </param> /// <param name='diameterLimit'> /// Diameter limit. /// </param> /// <param name='cutDirection'> /// Cut direction. /// </param> public Harvest(int[] ids, int duration, int diameterLimit, DiameterLimitCutDirection cutDirection) { this.ids = ids; this.duration = duration; this.cutType = CutType.DiameterLimitCut; this.diameterLimit = diameterLimit; this.diameterLimitCutDirection = cutDirection; }
public CutRouteData Cut(ParameterizedLocation parameterizedLocation, CutType cutType) { var cutRoute = new CutRouteData { CutType = cutType }; switch (cutType) { case CutType.Before: cutRoute.Segments.AddRange(segments.GetRange(0, parameterizedLocation.SegmentIndex)); if (!parameterizedLocation.IsNode) { // cut between two waypoints: create cut waypoint Waypoint cutWaypoint = CreateWaypointFromParameterizedLocation(parameterizedLocation); var rs = new RouteSegment(); segments.RemoveRange(0, parameterizedLocation.SegmentIndex); rs.Waypoints.AddRange(segments[0].Waypoints.GetRange(0, (int)parameterizedLocation.Ceiling().Value)); cutRoute.Segments.Add(rs); segments[0].Waypoints.RemoveRange(0, (int)parameterizedLocation.Ceiling().Value); segments[0].Waypoints.Insert(0, cutWaypoint); cutRoute.WaypointInsertedAtCut = cutWaypoint; } else { // cut exactly at a waypoint var rs = new RouteSegment(); segments.RemoveRange(0, parameterizedLocation.SegmentIndex); rs.Waypoints.AddRange(segments[0].Waypoints.GetRange(0, (int)parameterizedLocation.Value)); cutRoute.Segments.Add(rs); segments[0].Waypoints.RemoveRange(0, (int)parameterizedLocation.Value); } // handle map readings nicely if (waypointAttributeExists[WaypointAttribute.MapReadingDuration] && segments[0].FirstWaypoint.MapReadingState == MapReadingState.Reading) { segments[0].FirstWaypoint.MapReadingState = MapReadingState.StartReading; } break; case CutType.After: if (parameterizedLocation.SegmentIndex < segments.Count - 1) { cutRoute.Segments.AddRange(segments.GetRange(parameterizedLocation.SegmentIndex + 1, segments.Count - 1 - parameterizedLocation.SegmentIndex)); segments.RemoveRange(parameterizedLocation.SegmentIndex + 1, segments.Count - 1 - parameterizedLocation.SegmentIndex); } var i = (int)parameterizedLocation.Ceiling().Value; int count = segments[parameterizedLocation.SegmentIndex].Waypoints.Count; if (!parameterizedLocation.IsNode) { // cut between two waypoints: create cut waypoint Waypoint cutWaypoint = CreateWaypointFromParameterizedLocation(parameterizedLocation); var rs = new RouteSegment(); rs.Waypoints.AddRange(segments[parameterizedLocation.SegmentIndex].Waypoints.GetRange(i, count - i)); cutRoute.Segments.Insert(0, rs); segments[parameterizedLocation.SegmentIndex].Waypoints.RemoveRange(i, count - i); segments[parameterizedLocation.SegmentIndex].Waypoints.Insert(i, cutWaypoint); cutRoute.WaypointInsertedAtCut = cutWaypoint; } else { // cut exactly at a waypoint var rs = new RouteSegment(); rs.Waypoints.AddRange(segments[parameterizedLocation.SegmentIndex].Waypoints.GetRange(i + 1, count - 1 - i)); cutRoute.Segments.Insert(0, rs); segments[parameterizedLocation.SegmentIndex].Waypoints.RemoveRange(i + 1, count - 1 - i); } // handle map readings nicely var lastWaypoint = segments[segments.Count - 1].LastWaypoint; if (waypointAttributeExists[WaypointAttribute.MapReadingDuration] && lastWaypoint.MapReadingState == MapReadingState.Reading) { lastWaypoint.MapReadingState = MapReadingState.EndReading; } break; } return cutRoute; }
public void Update () { if (CutObjectAlpha != _cutObjectAlpha) { _cutObjectAlpha = CutObjectAlpha; CutObjectAlphaStatic = CutObjectAlpha; } if (CutObjectAlphaStatic != CutObjectAlpha) { _cutObjectAlpha = CutObjectAlphaStatic; CutObjectAlpha = CutObjectAlphaStatic; } if (CutType != PreviousCutType || gameObject.GetComponent<MeshFilter>().sharedMesh == null) { SetMesh(); PreviousCutType = CutType; } if (previousHiddenValue != Hidden) { SetHidden(Hidden); previousHiddenValue = Hidden; } //SetHidden(Hidden); //if (CutObjectAlpha == 0) SetHidden(true); GetComponent<MeshRenderer>().sharedMaterial.SetFloat("_CutObjectAlpha", CutObjectAlphaStatic); }
/// <summary> /// Initializes a new instance of the <see cref="Harvest"/> struct for a q ratio cut. /// </summary> /// <param name='ids'> /// Identifiers. /// </param> /// <param name='duration'> /// Duration. /// </param> /// <param name='qRatio'> /// Q ratio. /// </param> /// <param name='targetBasalArea'> /// Target basal area. /// </param> public Harvest(int[] ids, int duration, float qRatio, float targetBasalArea) { this.ids = ids; this.duration = duration; this.cutType = CutType.QRatioCut; this.qRatio = qRatio; this.basalArea = targetBasalArea; }
public CutPaper(CutType type = CutType.Partial) { _type = type; }
public Cutter(CutType _type = CutType.Simple) { CutType = _type; }
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; }
public void Update () { if (CutType != PreviousCutType || gameObject.GetComponent<MeshFilter>().sharedMesh == null) { SetMesh(); PreviousCutType = CutType; } if (Hidden != previousHiddenValue) { previousHiddenValue = Hidden; SetHidden(Hidden); } GetComponent<MeshRenderer>().sharedMaterial.SetFloat("_CutObjectAlpha", CutObjectAlpha); }
/// <summary> /// Displays the cut selector. /// </summary> protected void DisplayCutSelector() { // determine trees to be included in cut int[] treesToCut = new int[m_actualFrequencyDistributionOfSelectedTiles.Length]; int[] treesToKeep = new int[m_actualFrequencyDistributionOfSelectedTiles.Length]; ComputeTreesToBeCut(m_knownFrequencyDistributionOfSelectedTiles, out treesToCut, out treesToKeep); // histogram GUILayout.BeginHorizontal(); { GUILayout.Label("Forest Profile:", m_mainText); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("({0} Acres)", ResourceTileSelection.GetCurrent().Count()), m_mainTextAlt); } GUILayout.EndHorizontal(); //display the graph based on surveyed area if(ResourceTileSelection.GetCurrent().Count() <= 0) { GUILayout.TextArea("\n\n", m_styles.largeTextDark); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.TextArea("Please select tile(s) to get your graph. ", m_styles.largeTextHighlighted); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.TextArea("\n\n", m_styles.largeTextDark); } else{ DisplayHistogram(treesToKeep, treesToCut, m_refreshDownloadProgress); } //check for surveyed land status bool needMoreSurvey = false; for(int num=0; num < ResourceTile.treeSizeClassCount; num++){ if(m_actualFrequencyDistributionOfSelectedTiles[num]!= m_knownFrequencyDistributionOfSelectedTiles[num]){ needMoreSurvey = true; break; } } if(needMoreSurvey){ GUILayout.TextArea("Your selected land are not fully surveyed!",m_styles.mediumTextHighlighted); } m_styles.DrawLine( GUIStyles.LineDirection.Horizontal, GUIStyles.LineColor.Medium ); // cut selector GUILayout.BeginHorizontal(); { GUILayout.Label("Configure Cut:", m_mainText); m_cutType = (CutType)GUILayout.SelectionGrid( (int)m_cutType, StringHelpers.GetEnumNamesAsCamelCase(typeof(CutType)), 1, m_button ); } GUILayout.EndHorizontal(); // parameters to tune switch (m_cutType) { case CutType.DiameterLimitCut: GUILayout.BeginHorizontal(); { GUILayout.Label("Target Diameter:", m_mainText); GUILayout.Label(string.Format("{0}\"", m_diameterLimit), m_mainTextAlt); GUILayout.FlexibleSpace(); m_diameterLimit = ResourceTile.treeSizeClassInterval*(int)GUILayout.HorizontalSlider( (1f/ResourceTile.treeSizeClassInterval)*m_diameterLimit, 1f, ResourceTile.treeSizeClassCount, GUILayout.Width(m_sliderWidth) ); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Direction:", m_mainText); GUILayout.Label(m_diameterLimitDirection.ToString(), m_mainTextAlt); GUILayout.FlexibleSpace(); m_diameterLimitDirection = (DiameterLimitCutDirection)Mathf.Sign(GUILayout.HorizontalSlider((float)m_diameterLimitDirection, -1f, 1f, GUILayout.Width(m_sliderWidth))); } GUILayout.EndHorizontal(); break; case CutType.QRatioCut: GUILayout.BeginHorizontal(); { GUILayout.Label("Target Basal Area:", m_mainText); GUILayout.Label(string.Format("{0:0} sq ft/acre", m_basalArea), m_mainTextAlt); GUILayout.FlexibleSpace(); m_basalArea = GUILayout.HorizontalSlider(m_basalArea, 0f, 200f, GUILayout.Width(m_sliderWidth)); m_basalArea -= m_basalArea%m_basalAreaSliderSnap; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Q-Ratio:", m_mainText); GUILayout.Label(string.Format("{0:0.00}", m_qRatio), m_mainTextAlt); GUILayout.FlexibleSpace(); m_qRatio = GUILayout.HorizontalSlider(m_qRatio, 1f, 2f, GUILayout.Width(m_sliderWidth)); m_qRatio -= m_qRatio%m_qRatioSliderSnap; } GUILayout.EndHorizontal(); break; } GUILayout.FlexibleSpace(); }
public void ChoosenCut(CutType cutType) { decimal cutLength; decimal cut2Length; bool takeCutted; bool take2Cutted; _link.CurrentCutting.MakeUndoPoint(); // сделать снимок текущего состояния для возможности отката if (cutType == CutType.Horizontal) { if (_loY) { cutLength = (decimal)_fantom.Height; takeCutted = true; } else { cutLength = _currentSection.Height - (decimal)_fantom.Height - 4; takeCutted = false; } if (_loX) { cut2Length = (decimal)_fantom.Width; take2Cutted = true; } else { cut2Length = _currentSection.Width - (decimal)_fantom.Width - 4; take2Cutted = false; } } else { if (_loX) { cutLength = (decimal)_fantom.Width; takeCutted = true; } else { cutLength = _currentSection.Width - (decimal)_fantom.Width - 4; takeCutted = false; } if (_loY) { cut2Length = (decimal)_fantom.Height; take2Cutted = true; } else { cut2Length = _currentSection.Height - (decimal)_fantom.Height - 4; take2Cutted = false; } } Section remain; Section cutted = _link.CurrentCutting.DataSource.Cut(_currentSection, cutLength, cutType, out remain); Section secondCutSec; if (takeCutted) { secondCutSec = cutted; } else { secondCutSec = remain; } cutted = _link.CurrentCutting.DataSource.Cut(secondCutSec, cut2Length, Utils.RotateCut(cutType), out remain); if (take2Cutted) { cutted.SectionType = SectionType.Element; } else { remain.SectionType = SectionType.Element; } _link._state = this; }
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; }
/// <summary> /// CalculateCuttingCircles /// </summary> private List <Circle> CalculateCuttingCircles(Curve curve, Polyline polyline, int[] indices, Plane plane, double radius, CutType cutType) { var circles = new List <Circle>(); if (null == curve || null == polyline || null == indices) { return(circles); } for (var i = 0; i < indices.Length; i++) { var current = indices[i]; int prev, next; if (current == 0) { prev = polyline.Count - 1; next = current + 1; } else if (current == polyline.Count - 1) { prev = current - 1; next = 0; } else { prev = current - 1; next = current + 1; } var dir0 = polyline[prev] - polyline[current]; var dir1 = polyline[next] - polyline[current]; if (cutType == CutType.Corner) { dir0.Unitize(); dir1.Unitize(); var dir = 0.5 * (dir0 + dir1); dir.Unitize(); dir *= radius; var circle_plane = plane; circle_plane.Origin = polyline[current]; var circle = new Circle(circle_plane, radius); var xform = Transform.Translation(dir); circle.Transform(xform); circles.Add(circle); } if (cutType == CutType.Bottom || cutType == CutType.BottomAndSide) { dir0.Unitize(); dir1.Unitize(); var dir = Vector3d.Unset; dir0 *= 2.1 * Tolerance; var point = polyline[prev] + dir0; if (PointContainment.Inside == curve.Contains(point, plane, Tolerance)) { dir = dir0; } else { dir1 *= 2.1 * Tolerance; point = polyline[next] + dir1; if (PointContainment.Inside == curve.Contains(point, plane, Tolerance)) { dir = dir1; } } if (dir.IsValid) { dir.Unitize(); dir *= radius; var circle_plane = plane; circle_plane.Origin = polyline[current]; var circle = new Circle(circle_plane, radius); var xform = Transform.Translation(dir); circle.Transform(xform); circles.Add(circle); } } if (cutType == CutType.Side || cutType == CutType.BottomAndSide) { dir0.Unitize(); dir1.Unitize(); var dir = Vector3d.Unset; dir0 *= 2.1 * Tolerance; var point = polyline[prev] + dir0; if (PointContainment.Inside != curve.Contains(point, plane, Tolerance)) { dir = dir0; } else { dir1 *= 2.1 * Tolerance; point = polyline[next] + dir1; if (PointContainment.Inside != curve.Contains(point, plane, Tolerance)) { dir = dir1; } } if (dir.IsValid) { dir.Unitize(); dir *= radius; var circle_plane = plane; circle_plane.Origin = polyline[current]; var circle = new Circle(circle_plane, radius); var xform = Transform.Translation(dir); circle.Transform(xform); circles.Add(circle); } } } return(circles); }
/// <summary> /// Initializes a new instance of the <see cref="Harvest"/> struct for a clearcut. /// </summary> /// <param name='ids'> /// Identifiers. /// </param> /// <param name='duration'> /// Duration. /// </param> public Harvest(int[] ids, int duration) { this.ids = ids; this.duration = duration; this.cutType = CutType.Clearcut; }