/// <inheritdoc /> public bool Equals([AllowNull] ContourCarpet other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( Visible == other.Visible || Visible != null && Visible.Equals(other.Visible) ) && ( ShowLegend == other.ShowLegend || ShowLegend != null && ShowLegend.Equals(other.ShowLegend) ) && ( LegendGroup == other.LegendGroup || LegendGroup != null && LegendGroup.Equals(other.LegendGroup) ) && ( Opacity == other.Opacity || Opacity != null && Opacity.Equals(other.Opacity) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( UId == other.UId || UId != null && UId.Equals(other.UId) ) && ( Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids) ) && ( Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData) ) && ( Meta == other.Meta || Meta != null && Meta.Equals(other.Meta) ) && ( Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray) ) && ( Stream == other.Stream || Stream != null && Stream.Equals(other.Stream) ) && ( UiRevision == other.UiRevision || UiRevision != null && UiRevision.Equals(other.UiRevision) ) && ( Carpet == other.Carpet || Carpet != null && Carpet.Equals(other.Carpet) ) && ( Equals(Z, other.Z) || Z != null && other.Z != null && Z.SequenceEqual(other.Z) ) && ( Equals(A, other.A) || A != null && other.A != null && A.SequenceEqual(other.A) ) && ( A0 == other.A0 || A0 != null && A0.Equals(other.A0) ) && ( DA == other.DA || DA != null && DA.Equals(other.DA) ) && ( Equals(B, other.B) || B != null && other.B != null && B.SequenceEqual(other.B) ) && ( B0 == other.B0 || B0 != null && B0.Equals(other.B0) ) && ( Db == other.Db || Db != null && Db.Equals(other.Db) ) && ( Equals(Text, other.Text) || Text != null && other.Text != null && Text.SequenceEqual(other.Text) ) && ( Equals(HoverText, other.HoverText) || HoverText != null && other.HoverText != null && HoverText.SequenceEqual(other.HoverText) ) && ( Transpose == other.Transpose || Transpose != null && Transpose.Equals(other.Transpose) ) && ( AType == other.AType || AType != null && AType.Equals(other.AType) ) && ( BType == other.BType || BType != null && BType.Equals(other.BType) ) && ( FillColor == other.FillColor || FillColor != null && FillColor.Equals(other.FillColor) ) && ( AutoContour == other.AutoContour || AutoContour != null && AutoContour.Equals(other.AutoContour) ) && ( NContours == other.NContours || NContours != null && NContours.Equals(other.NContours) ) && ( Contours == other.Contours || Contours != null && Contours.Equals(other.Contours) ) && ( Line == other.Line || Line != null && Line.Equals(other.Line) ) && ( ZAuto == other.ZAuto || ZAuto != null && ZAuto.Equals(other.ZAuto) ) && ( ZMin == other.ZMin || ZMin != null && ZMin.Equals(other.ZMin) ) && ( ZMax == other.ZMax || ZMax != null && ZMax.Equals(other.ZMax) ) && ( ZMid == other.ZMid || ZMid != null && ZMid.Equals(other.ZMid) ) && ( ColorScale == other.ColorScale || ColorScale != null && ColorScale.Equals(other.ColorScale) ) && ( AutoColorScale == other.AutoColorScale || AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale) ) && ( ReverseScale == other.ReverseScale || ReverseScale != null && ReverseScale.Equals(other.ReverseScale) ) && ( ShowScale == other.ShowScale || ShowScale != null && ShowScale.Equals(other.ShowScale) ) && ( ColorBar == other.ColorBar || ColorBar != null && ColorBar.Equals(other.ColorBar) ) && ( ColorAxis == other.ColorAxis || ColorAxis != null && ColorAxis.Equals(other.ColorAxis) ) && ( XAxis == other.XAxis || XAxis != null && XAxis.Equals(other.XAxis) ) && ( YAxis == other.YAxis || YAxis != null && YAxis.Equals(other.YAxis) ) && ( IdsSrc == other.IdsSrc || IdsSrc != null && IdsSrc.Equals(other.IdsSrc) ) && ( CustomDataSrc == other.CustomDataSrc || CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc) ) && ( MetaSrc == other.MetaSrc || MetaSrc != null && MetaSrc.Equals(other.MetaSrc) ) && ( ZSrc == other.ZSrc || ZSrc != null && ZSrc.Equals(other.ZSrc) ) && ( ASrc == other.ASrc || ASrc != null && ASrc.Equals(other.ASrc) ) && ( BSrc == other.BSrc || BSrc != null && BSrc.Equals(other.BSrc) ) && ( TextSrc == other.TextSrc || TextSrc != null && TextSrc.Equals(other.TextSrc) ) && ( HoverTextSrc == other.HoverTextSrc || HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc) )); }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (ShowLegend != null) { hashCode = hashCode * 59 + ShowLegend.GetHashCode(); } if (LegendGroup != null) { hashCode = hashCode * 59 + LegendGroup.GetHashCode(); } if (Opacity != null) { hashCode = hashCode * 59 + Opacity.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (UId != null) { hashCode = hashCode * 59 + UId.GetHashCode(); } if (Ids != null) { hashCode = hashCode * 59 + Ids.GetHashCode(); } if (CustomData != null) { hashCode = hashCode * 59 + CustomData.GetHashCode(); } if (Meta != null) { hashCode = hashCode * 59 + Meta.GetHashCode(); } if (MetaArray != null) { hashCode = hashCode * 59 + MetaArray.GetHashCode(); } if (Stream != null) { hashCode = hashCode * 59 + Stream.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (Carpet != null) { hashCode = hashCode * 59 + Carpet.GetHashCode(); } if (Z != null) { hashCode = hashCode * 59 + Z.GetHashCode(); } if (A != null) { hashCode = hashCode * 59 + A.GetHashCode(); } if (A0 != null) { hashCode = hashCode * 59 + A0.GetHashCode(); } if (DA != null) { hashCode = hashCode * 59 + DA.GetHashCode(); } if (B != null) { hashCode = hashCode * 59 + B.GetHashCode(); } if (B0 != null) { hashCode = hashCode * 59 + B0.GetHashCode(); } if (Db != null) { hashCode = hashCode * 59 + Db.GetHashCode(); } if (Text != null) { hashCode = hashCode * 59 + Text.GetHashCode(); } if (HoverText != null) { hashCode = hashCode * 59 + HoverText.GetHashCode(); } if (Transpose != null) { hashCode = hashCode * 59 + Transpose.GetHashCode(); } if (AType != null) { hashCode = hashCode * 59 + AType.GetHashCode(); } if (BType != null) { hashCode = hashCode * 59 + BType.GetHashCode(); } if (FillColor != null) { hashCode = hashCode * 59 + FillColor.GetHashCode(); } if (AutoContour != null) { hashCode = hashCode * 59 + AutoContour.GetHashCode(); } if (NContours != null) { hashCode = hashCode * 59 + NContours.GetHashCode(); } if (Contours != null) { hashCode = hashCode * 59 + Contours.GetHashCode(); } if (Line != null) { hashCode = hashCode * 59 + Line.GetHashCode(); } if (ZAuto != null) { hashCode = hashCode * 59 + ZAuto.GetHashCode(); } if (ZMin != null) { hashCode = hashCode * 59 + ZMin.GetHashCode(); } if (ZMax != null) { hashCode = hashCode * 59 + ZMax.GetHashCode(); } if (ZMid != null) { hashCode = hashCode * 59 + ZMid.GetHashCode(); } if (ColorScale != null) { hashCode = hashCode * 59 + ColorScale.GetHashCode(); } if (AutoColorScale != null) { hashCode = hashCode * 59 + AutoColorScale.GetHashCode(); } if (ReverseScale != null) { hashCode = hashCode * 59 + ReverseScale.GetHashCode(); } if (ShowScale != null) { hashCode = hashCode * 59 + ShowScale.GetHashCode(); } if (ColorBar != null) { hashCode = hashCode * 59 + ColorBar.GetHashCode(); } if (ColorAxis != null) { hashCode = hashCode * 59 + ColorAxis.GetHashCode(); } if (XAxis != null) { hashCode = hashCode * 59 + XAxis.GetHashCode(); } if (YAxis != null) { hashCode = hashCode * 59 + YAxis.GetHashCode(); } if (IdsSrc != null) { hashCode = hashCode * 59 + IdsSrc.GetHashCode(); } if (CustomDataSrc != null) { hashCode = hashCode * 59 + CustomDataSrc.GetHashCode(); } if (MetaSrc != null) { hashCode = hashCode * 59 + MetaSrc.GetHashCode(); } if (ZSrc != null) { hashCode = hashCode * 59 + ZSrc.GetHashCode(); } if (ASrc != null) { hashCode = hashCode * 59 + ASrc.GetHashCode(); } if (BSrc != null) { hashCode = hashCode * 59 + BSrc.GetHashCode(); } if (TextSrc != null) { hashCode = hashCode * 59 + TextSrc.GetHashCode(); } if (HoverTextSrc != null) { hashCode = hashCode * 59 + HoverTextSrc.GetHashCode(); } return(hashCode); } }
public int CountVertices() { return(Contours.Select(contour => contour.Vertices.Count).Sum()); }
private void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e) { Contours.Clear(); m_openedPath = null; }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (ShowLegend != null) { hashCode = hashCode * 59 + ShowLegend.GetHashCode(); } if (LegendGroup != null) { hashCode = hashCode * 59 + LegendGroup.GetHashCode(); } if (Opacity != null) { hashCode = hashCode * 59 + Opacity.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (UId != null) { hashCode = hashCode * 59 + UId.GetHashCode(); } if (Ids != null) { hashCode = hashCode * 59 + Ids.GetHashCode(); } if (CustomData != null) { hashCode = hashCode * 59 + CustomData.GetHashCode(); } if (Meta != null) { hashCode = hashCode * 59 + Meta.GetHashCode(); } if (MetaArray != null) { hashCode = hashCode * 59 + MetaArray.GetHashCode(); } if (HoverInfo != null) { hashCode = hashCode * 59 + HoverInfo.GetHashCode(); } if (HoverInfoArray != null) { hashCode = hashCode * 59 + HoverInfoArray.GetHashCode(); } if (HoverLabel != null) { hashCode = hashCode * 59 + HoverLabel.GetHashCode(); } if (Stream != null) { hashCode = hashCode * 59 + Stream.GetHashCode(); } if (Transforms != null) { hashCode = hashCode * 59 + Transforms.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (Z != null) { hashCode = hashCode * 59 + Z.GetHashCode(); } if (X != null) { hashCode = hashCode * 59 + X.GetHashCode(); } if (X0 != null) { hashCode = hashCode * 59 + X0.GetHashCode(); } if (DX != null) { hashCode = hashCode * 59 + DX.GetHashCode(); } if (Y != null) { hashCode = hashCode * 59 + Y.GetHashCode(); } if (Y0 != null) { hashCode = hashCode * 59 + Y0.GetHashCode(); } if (Dy != null) { hashCode = hashCode * 59 + Dy.GetHashCode(); } if (Text != null) { hashCode = hashCode * 59 + Text.GetHashCode(); } if (HoverText != null) { hashCode = hashCode * 59 + HoverText.GetHashCode(); } if (Transpose != null) { hashCode = hashCode * 59 + Transpose.GetHashCode(); } if (XType != null) { hashCode = hashCode * 59 + XType.GetHashCode(); } if (YType != null) { hashCode = hashCode * 59 + YType.GetHashCode(); } if (ZHoverFormat != null) { hashCode = hashCode * 59 + ZHoverFormat.GetHashCode(); } if (HoverTemplate != null) { hashCode = hashCode * 59 + HoverTemplate.GetHashCode(); } if (HoverTemplateArray != null) { hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode(); } if (HoverOnGaps != null) { hashCode = hashCode * 59 + HoverOnGaps.GetHashCode(); } if (ConnectGaps != null) { hashCode = hashCode * 59 + ConnectGaps.GetHashCode(); } if (FillColor != null) { hashCode = hashCode * 59 + FillColor.GetHashCode(); } if (AutoContour != null) { hashCode = hashCode * 59 + AutoContour.GetHashCode(); } if (NContours != null) { hashCode = hashCode * 59 + NContours.GetHashCode(); } if (Contours != null) { hashCode = hashCode * 59 + Contours.GetHashCode(); } if (Line != null) { hashCode = hashCode * 59 + Line.GetHashCode(); } if (ZAuto != null) { hashCode = hashCode * 59 + ZAuto.GetHashCode(); } if (ZMin != null) { hashCode = hashCode * 59 + ZMin.GetHashCode(); } if (ZMax != null) { hashCode = hashCode * 59 + ZMax.GetHashCode(); } if (ZMid != null) { hashCode = hashCode * 59 + ZMid.GetHashCode(); } if (ColorScale != null) { hashCode = hashCode * 59 + ColorScale.GetHashCode(); } if (AutoColorScale != null) { hashCode = hashCode * 59 + AutoColorScale.GetHashCode(); } if (ReverseScale != null) { hashCode = hashCode * 59 + ReverseScale.GetHashCode(); } if (ShowScale != null) { hashCode = hashCode * 59 + ShowScale.GetHashCode(); } if (ColorBar != null) { hashCode = hashCode * 59 + ColorBar.GetHashCode(); } if (ColorAxis != null) { hashCode = hashCode * 59 + ColorAxis.GetHashCode(); } if (XCalendar != null) { hashCode = hashCode * 59 + XCalendar.GetHashCode(); } if (YCalendar != null) { hashCode = hashCode * 59 + YCalendar.GetHashCode(); } if (XAxis != null) { hashCode = hashCode * 59 + XAxis.GetHashCode(); } if (YAxis != null) { hashCode = hashCode * 59 + YAxis.GetHashCode(); } if (IdsSrc != null) { hashCode = hashCode * 59 + IdsSrc.GetHashCode(); } if (CustomDataSrc != null) { hashCode = hashCode * 59 + CustomDataSrc.GetHashCode(); } if (MetaSrc != null) { hashCode = hashCode * 59 + MetaSrc.GetHashCode(); } if (HoverInfoSrc != null) { hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode(); } if (ZSrc != null) { hashCode = hashCode * 59 + ZSrc.GetHashCode(); } if (XSrc != null) { hashCode = hashCode * 59 + XSrc.GetHashCode(); } if (YSrc != null) { hashCode = hashCode * 59 + YSrc.GetHashCode(); } if (TextSrc != null) { hashCode = hashCode * 59 + TextSrc.GetHashCode(); } if (HoverTextSrc != null) { hashCode = hashCode * 59 + HoverTextSrc.GetHashCode(); } if (HoverTemplateSrc != null) { hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode(); } return(hashCode); } }
public void Add(Contour c) { Contours.Add(c); }
public List <double> GetAllCellLength() { return((from contour in Contours.ToArrayOfArray() select new VectorOfPoint(contour) into tempVector select CvInvoke.MinAreaRect(tempVector) into tempRect select tempRect.Size.Height).Select(dummy => (double)dummy).ToList()); }
public void PointsInputHandler(object sender, MouseEventArgs e) { Contour currentContour = Contours.FirstOrDefault(x => !x.IsCompleted); if (currentContour == null) { currentContour = new Contour(Contours.Count + 1); Contours.Add(currentContour); } var newPoint = new Point(e.X, _drawer.CanvasHeight - e.Y) { Index = _lastPointIndex + 1 }; if (currentContour.Head == null) { currentContour.Add(newPoint); _drawer.DrawPoints(Pens.Black, newPoint); //Ekaterina _drawer.RefreshImage(); //end Ekaterina _lastPointIndex++; } else { if (currentContour.Tail == null) { var newLineSegment = new LineSegment(currentContour.Head, newPoint); if (Contours.Where(x => x != currentContour).Any(x => x.IntersectsWithLineSegment(newLineSegment, IntersectionCheckOptions.WithEdgePoints)) || currentContour.IntersectsWithLineSegment(newLineSegment, IntersectionCheckOptions.WithoutEdgePoints)) { MessageBox.Show(ErrorMessageBoxMessage, ErrorMessageBoxTitle); } else { currentContour.Add(newPoint); _drawer.DrawLineSegments(Pens.Black, newLineSegment); _lastPointIndex++; } } else { var newLineSegment = new LineSegment(currentContour.Tail, newPoint); if (Contours.Where(x => x != currentContour).Any(x => x.IntersectsWithLineSegment(newLineSegment, IntersectionCheckOptions.WithEdgePoints)) || currentContour.IntersectsWithLineSegment(newLineSegment, IntersectionCheckOptions.WithoutEdgePoints)) { MessageBox.Show(ErrorMessageBoxMessage, ErrorMessageBoxTitle); } else { currentContour.Add(newPoint); if (!currentContour.IsCompleted) { _drawer.DrawLineSegments(Pens.Black, newLineSegment); _lastPointIndex++; } else { _drawer.DrawLineSegments(Pens.Black, new LineSegment(currentContour.Tail, currentContour.Head)); } } } } if (currentContour.IsCompleted) { _tabControlHelper.CreatePageForContour(currentContour); } }
public bool Equals([AllowNull] Histogram2DContour other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) && (Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) && (ShowLegend == other.ShowLegend && ShowLegend != null && other.ShowLegend != null && ShowLegend.Equals(other.ShowLegend)) && (LegendGroup == other.LegendGroup && LegendGroup != null && other.LegendGroup != null && LegendGroup.Equals(other.LegendGroup)) && (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) && (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) && (UId == other.UId && UId != null && other.UId != null && UId.Equals(other.UId)) && (Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids)) && (Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData)) && (Meta == other.Meta && Meta != null && other.Meta != null && Meta.Equals(other.Meta)) && (Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray)) && (HoverInfo == other.HoverInfo && HoverInfo != null && other.HoverInfo != null && HoverInfo.Equals(other.HoverInfo)) && (Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray)) && (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) && (Stream == other.Stream && Stream != null && other.Stream != null && Stream.Equals(other.Stream)) && (Equals(Transforms, other.Transforms) || Transforms != null && other.Transforms != null && Transforms.SequenceEqual(other.Transforms)) && (UiRevision == other.UiRevision && UiRevision != null && other.UiRevision != null && UiRevision.Equals(other.UiRevision)) && (Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X)) && (Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y)) && (Equals(Z, other.Z) || Z != null && other.Z != null && Z.SequenceEqual(other.Z)) && (Marker == other.Marker && Marker != null && other.Marker != null && Marker.Equals(other.Marker)) && (HistNorm == other.HistNorm && HistNorm != null && other.HistNorm != null && HistNorm.Equals(other.HistNorm)) && (HistFunc == other.HistFunc && HistFunc != null && other.HistFunc != null && HistFunc.Equals(other.HistFunc)) && (NBinsX == other.NBinsX && NBinsX != null && other.NBinsX != null && NBinsX.Equals(other.NBinsX)) && (XBins == other.XBins && XBins != null && other.XBins != null && XBins.Equals(other.XBins)) && (NBinsY == other.NBinsY && NBinsY != null && other.NBinsY != null && NBinsY.Equals(other.NBinsY)) && (YBins == other.YBins && YBins != null && other.YBins != null && YBins.Equals(other.YBins)) && (AutoBinX == other.AutoBinX && AutoBinX != null && other.AutoBinX != null && AutoBinX.Equals(other.AutoBinX)) && (AutoBinY == other.AutoBinY && AutoBinY != null && other.AutoBinY != null && AutoBinY.Equals(other.AutoBinY)) && (BinGroup == other.BinGroup && BinGroup != null && other.BinGroup != null && BinGroup.Equals(other.BinGroup)) && (XBinGroup == other.XBinGroup && XBinGroup != null && other.XBinGroup != null && XBinGroup.Equals(other.XBinGroup)) && (YBinGroup == other.YBinGroup && YBinGroup != null && other.YBinGroup != null && YBinGroup.Equals(other.YBinGroup)) && (AutoContour == other.AutoContour && AutoContour != null && other.AutoContour != null && AutoContour.Equals(other.AutoContour)) && (NContours == other.NContours && NContours != null && other.NContours != null && NContours.Equals(other.NContours)) && (Contours == other.Contours && Contours != null && other.Contours != null && Contours.Equals(other.Contours)) && (Line == other.Line && Line != null && other.Line != null && Line.Equals(other.Line)) && (ZHoverFormat == other.ZHoverFormat && ZHoverFormat != null && other.ZHoverFormat != null && ZHoverFormat.Equals(other.ZHoverFormat)) && (HoverTemplate == other.HoverTemplate && HoverTemplate != null && other.HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate)) && (Equals(HoverTemplateArray, other.HoverTemplateArray) || HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray)) && (ZAuto == other.ZAuto && ZAuto != null && other.ZAuto != null && ZAuto.Equals(other.ZAuto)) && (ZMin == other.ZMin && ZMin != null && other.ZMin != null && ZMin.Equals(other.ZMin)) && (ZMax == other.ZMax && ZMax != null && other.ZMax != null && ZMax.Equals(other.ZMax)) && (ZMid == other.ZMid && ZMid != null && other.ZMid != null && ZMid.Equals(other.ZMid)) && (ColorScale == other.ColorScale && ColorScale != null && other.ColorScale != null && ColorScale.Equals(other.ColorScale)) && (AutoColorScale == other.AutoColorScale && AutoColorScale != null && other.AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale)) && (ReverseScale == other.ReverseScale && ReverseScale != null && other.ReverseScale != null && ReverseScale.Equals(other.ReverseScale)) && (ShowScale == other.ShowScale && ShowScale != null && other.ShowScale != null && ShowScale.Equals(other.ShowScale)) && (ColorBar == other.ColorBar && ColorBar != null && other.ColorBar != null && ColorBar.Equals(other.ColorBar)) && (ColorAxis == other.ColorAxis && ColorAxis != null && other.ColorAxis != null && ColorAxis.Equals(other.ColorAxis)) && (XCalendar == other.XCalendar && XCalendar != null && other.XCalendar != null && XCalendar.Equals(other.XCalendar)) && (YCalendar == other.YCalendar && YCalendar != null && other.YCalendar != null && YCalendar.Equals(other.YCalendar)) && (XAxis == other.XAxis && XAxis != null && other.XAxis != null && XAxis.Equals(other.XAxis)) && (YAxis == other.YAxis && YAxis != null && other.YAxis != null && YAxis.Equals(other.YAxis)) && (IdsSrc == other.IdsSrc && IdsSrc != null && other.IdsSrc != null && IdsSrc.Equals(other.IdsSrc)) && (CustomDataSrc == other.CustomDataSrc && CustomDataSrc != null && other.CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc)) && (MetaSrc == other.MetaSrc && MetaSrc != null && other.MetaSrc != null && MetaSrc.Equals(other.MetaSrc)) && (HoverInfoSrc == other.HoverInfoSrc && HoverInfoSrc != null && other.HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc)) && (XSrc == other.XSrc && XSrc != null && other.XSrc != null && XSrc.Equals(other.XSrc)) && (YSrc == other.YSrc && YSrc != null && other.YSrc != null && YSrc.Equals(other.YSrc)) && (ZSrc == other.ZSrc && ZSrc != null && other.ZSrc != null && ZSrc.Equals(other.ZSrc)) && (HoverTemplateSrc == other.HoverTemplateSrc && HoverTemplateSrc != null && other.HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc))); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (ShowLegend != null) { hashCode = hashCode * 59 + ShowLegend.GetHashCode(); } if (LegendGroup != null) { hashCode = hashCode * 59 + LegendGroup.GetHashCode(); } if (Opacity != null) { hashCode = hashCode * 59 + Opacity.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (UId != null) { hashCode = hashCode * 59 + UId.GetHashCode(); } if (Ids != null) { hashCode = hashCode * 59 + Ids.GetHashCode(); } if (CustomData != null) { hashCode = hashCode * 59 + CustomData.GetHashCode(); } if (Meta != null) { hashCode = hashCode * 59 + Meta.GetHashCode(); } if (MetaArray != null) { hashCode = hashCode * 59 + MetaArray.GetHashCode(); } if (HoverInfo != null) { hashCode = hashCode * 59 + HoverInfo.GetHashCode(); } if (HoverInfoArray != null) { hashCode = hashCode * 59 + HoverInfoArray.GetHashCode(); } if (HoverLabel != null) { hashCode = hashCode * 59 + HoverLabel.GetHashCode(); } if (Stream != null) { hashCode = hashCode * 59 + Stream.GetHashCode(); } if (Transforms != null) { hashCode = hashCode * 59 + Transforms.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (X != null) { hashCode = hashCode * 59 + X.GetHashCode(); } if (Y != null) { hashCode = hashCode * 59 + Y.GetHashCode(); } if (Z != null) { hashCode = hashCode * 59 + Z.GetHashCode(); } if (Marker != null) { hashCode = hashCode * 59 + Marker.GetHashCode(); } if (HistNorm != null) { hashCode = hashCode * 59 + HistNorm.GetHashCode(); } if (HistFunc != null) { hashCode = hashCode * 59 + HistFunc.GetHashCode(); } if (NBinsX != null) { hashCode = hashCode * 59 + NBinsX.GetHashCode(); } if (XBins != null) { hashCode = hashCode * 59 + XBins.GetHashCode(); } if (NBinsY != null) { hashCode = hashCode * 59 + NBinsY.GetHashCode(); } if (YBins != null) { hashCode = hashCode * 59 + YBins.GetHashCode(); } if (AutoBinX != null) { hashCode = hashCode * 59 + AutoBinX.GetHashCode(); } if (AutoBinY != null) { hashCode = hashCode * 59 + AutoBinY.GetHashCode(); } if (BinGroup != null) { hashCode = hashCode * 59 + BinGroup.GetHashCode(); } if (XBinGroup != null) { hashCode = hashCode * 59 + XBinGroup.GetHashCode(); } if (YBinGroup != null) { hashCode = hashCode * 59 + YBinGroup.GetHashCode(); } if (AutoContour != null) { hashCode = hashCode * 59 + AutoContour.GetHashCode(); } if (NContours != null) { hashCode = hashCode * 59 + NContours.GetHashCode(); } if (Contours != null) { hashCode = hashCode * 59 + Contours.GetHashCode(); } if (Line != null) { hashCode = hashCode * 59 + Line.GetHashCode(); } if (ZHoverFormat != null) { hashCode = hashCode * 59 + ZHoverFormat.GetHashCode(); } if (HoverTemplate != null) { hashCode = hashCode * 59 + HoverTemplate.GetHashCode(); } if (HoverTemplateArray != null) { hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode(); } if (ZAuto != null) { hashCode = hashCode * 59 + ZAuto.GetHashCode(); } if (ZMin != null) { hashCode = hashCode * 59 + ZMin.GetHashCode(); } if (ZMax != null) { hashCode = hashCode * 59 + ZMax.GetHashCode(); } if (ZMid != null) { hashCode = hashCode * 59 + ZMid.GetHashCode(); } if (ColorScale != null) { hashCode = hashCode * 59 + ColorScale.GetHashCode(); } if (AutoColorScale != null) { hashCode = hashCode * 59 + AutoColorScale.GetHashCode(); } if (ReverseScale != null) { hashCode = hashCode * 59 + ReverseScale.GetHashCode(); } if (ShowScale != null) { hashCode = hashCode * 59 + ShowScale.GetHashCode(); } if (ColorBar != null) { hashCode = hashCode * 59 + ColorBar.GetHashCode(); } if (ColorAxis != null) { hashCode = hashCode * 59 + ColorAxis.GetHashCode(); } if (XCalendar != null) { hashCode = hashCode * 59 + XCalendar.GetHashCode(); } if (YCalendar != null) { hashCode = hashCode * 59 + YCalendar.GetHashCode(); } if (XAxis != null) { hashCode = hashCode * 59 + XAxis.GetHashCode(); } if (YAxis != null) { hashCode = hashCode * 59 + YAxis.GetHashCode(); } if (IdsSrc != null) { hashCode = hashCode * 59 + IdsSrc.GetHashCode(); } if (CustomDataSrc != null) { hashCode = hashCode * 59 + CustomDataSrc.GetHashCode(); } if (MetaSrc != null) { hashCode = hashCode * 59 + MetaSrc.GetHashCode(); } if (HoverInfoSrc != null) { hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode(); } if (XSrc != null) { hashCode = hashCode * 59 + XSrc.GetHashCode(); } if (YSrc != null) { hashCode = hashCode * 59 + YSrc.GetHashCode(); } if (ZSrc != null) { hashCode = hashCode * 59 + ZSrc.GetHashCode(); } if (HoverTemplateSrc != null) { hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode(); } return(hashCode); } }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (LegendGroup != null) { hashCode = hashCode * 59 + LegendGroup.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (UId != null) { hashCode = hashCode * 59 + UId.GetHashCode(); } if (Ids != null) { hashCode = hashCode * 59 + Ids.GetHashCode(); } if (CustomData != null) { hashCode = hashCode * 59 + CustomData.GetHashCode(); } if (Meta != null) { hashCode = hashCode * 59 + Meta.GetHashCode(); } if (MetaArray != null) { hashCode = hashCode * 59 + MetaArray.GetHashCode(); } if (HoverLabel != null) { hashCode = hashCode * 59 + HoverLabel.GetHashCode(); } if (Stream != null) { hashCode = hashCode * 59 + Stream.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (Z != null) { hashCode = hashCode * 59 + Z.GetHashCode(); } if (X != null) { hashCode = hashCode * 59 + X.GetHashCode(); } if (Y != null) { hashCode = hashCode * 59 + Y.GetHashCode(); } if (Text != null) { hashCode = hashCode * 59 + Text.GetHashCode(); } if (TextArray != null) { hashCode = hashCode * 59 + TextArray.GetHashCode(); } if (HoverText != null) { hashCode = hashCode * 59 + HoverText.GetHashCode(); } if (HoverTextArray != null) { hashCode = hashCode * 59 + HoverTextArray.GetHashCode(); } if (HoverTemplate != null) { hashCode = hashCode * 59 + HoverTemplate.GetHashCode(); } if (HoverTemplateArray != null) { hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode(); } if (ConnectGaps != null) { hashCode = hashCode * 59 + ConnectGaps.GetHashCode(); } if (SurfaceColor != null) { hashCode = hashCode * 59 + SurfaceColor.GetHashCode(); } if (CAuto != null) { hashCode = hashCode * 59 + CAuto.GetHashCode(); } if (CMin != null) { hashCode = hashCode * 59 + CMin.GetHashCode(); } if (CMax != null) { hashCode = hashCode * 59 + CMax.GetHashCode(); } if (CMid != null) { hashCode = hashCode * 59 + CMid.GetHashCode(); } if (ColorScale != null) { hashCode = hashCode * 59 + ColorScale.GetHashCode(); } if (AutoColorScale != null) { hashCode = hashCode * 59 + AutoColorScale.GetHashCode(); } if (ReverseScale != null) { hashCode = hashCode * 59 + ReverseScale.GetHashCode(); } if (ShowScale != null) { hashCode = hashCode * 59 + ShowScale.GetHashCode(); } if (ColorBar != null) { hashCode = hashCode * 59 + ColorBar.GetHashCode(); } if (ColorAxis != null) { hashCode = hashCode * 59 + ColorAxis.GetHashCode(); } if (Contours != null) { hashCode = hashCode * 59 + Contours.GetHashCode(); } if (HideSurface != null) { hashCode = hashCode * 59 + HideSurface.GetHashCode(); } if (LightPosition != null) { hashCode = hashCode * 59 + LightPosition.GetHashCode(); } if (Lighting != null) { hashCode = hashCode * 59 + Lighting.GetHashCode(); } if (Opacity != null) { hashCode = hashCode * 59 + Opacity.GetHashCode(); } if (OpacityScale != null) { hashCode = hashCode * 59 + OpacityScale.GetHashCode(); } if (HoverInfo != null) { hashCode = hashCode * 59 + HoverInfo.GetHashCode(); } if (HoverInfoArray != null) { hashCode = hashCode * 59 + HoverInfoArray.GetHashCode(); } if (ShowLegend != null) { hashCode = hashCode * 59 + ShowLegend.GetHashCode(); } if (XCalendar != null) { hashCode = hashCode * 59 + XCalendar.GetHashCode(); } if (YCalendar != null) { hashCode = hashCode * 59 + YCalendar.GetHashCode(); } if (ZCalendar != null) { hashCode = hashCode * 59 + ZCalendar.GetHashCode(); } if (Scene != null) { hashCode = hashCode * 59 + Scene.GetHashCode(); } if (IdsSrc != null) { hashCode = hashCode * 59 + IdsSrc.GetHashCode(); } if (CustomDataSrc != null) { hashCode = hashCode * 59 + CustomDataSrc.GetHashCode(); } if (MetaSrc != null) { hashCode = hashCode * 59 + MetaSrc.GetHashCode(); } if (ZSrc != null) { hashCode = hashCode * 59 + ZSrc.GetHashCode(); } if (XSrc != null) { hashCode = hashCode * 59 + XSrc.GetHashCode(); } if (YSrc != null) { hashCode = hashCode * 59 + YSrc.GetHashCode(); } if (TextSrc != null) { hashCode = hashCode * 59 + TextSrc.GetHashCode(); } if (HoverTextSrc != null) { hashCode = hashCode * 59 + HoverTextSrc.GetHashCode(); } if (HoverTemplateSrc != null) { hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode(); } if (SurfaceColorSrc != null) { hashCode = hashCode * 59 + SurfaceColorSrc.GetHashCode(); } if (HoverInfoSrc != null) { hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode(); } return(hashCode); } }
/// <inheritdoc /> public bool Equals([AllowNull] Surface other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( Visible == other.Visible || Visible != null && Visible.Equals(other.Visible) ) && ( LegendGroup == other.LegendGroup || LegendGroup != null && LegendGroup.Equals(other.LegendGroup) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( UId == other.UId || UId != null && UId.Equals(other.UId) ) && ( Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids) ) && ( Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData) ) && ( Meta == other.Meta || Meta != null && Meta.Equals(other.Meta) ) && ( Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray) ) && ( HoverLabel == other.HoverLabel || HoverLabel != null && HoverLabel.Equals(other.HoverLabel) ) && ( Stream == other.Stream || Stream != null && Stream.Equals(other.Stream) ) && ( UiRevision == other.UiRevision || UiRevision != null && UiRevision.Equals(other.UiRevision) ) && ( Equals(Z, other.Z) || Z != null && other.Z != null && Z.SequenceEqual(other.Z) ) && ( Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X) ) && ( Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y) ) && ( Text == other.Text || Text != null && Text.Equals(other.Text) ) && ( Equals(TextArray, other.TextArray) || TextArray != null && other.TextArray != null && TextArray.SequenceEqual(other.TextArray) ) && ( HoverText == other.HoverText || HoverText != null && HoverText.Equals(other.HoverText) ) && ( Equals(HoverTextArray, other.HoverTextArray) || HoverTextArray != null && other.HoverTextArray != null && HoverTextArray.SequenceEqual(other.HoverTextArray) ) && ( HoverTemplate == other.HoverTemplate || HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate) ) && ( Equals(HoverTemplateArray, other.HoverTemplateArray) || HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray) ) && ( ConnectGaps == other.ConnectGaps || ConnectGaps != null && ConnectGaps.Equals(other.ConnectGaps) ) && ( Equals(SurfaceColor, other.SurfaceColor) || SurfaceColor != null && other.SurfaceColor != null && SurfaceColor.SequenceEqual(other.SurfaceColor) ) && ( CAuto == other.CAuto || CAuto != null && CAuto.Equals(other.CAuto) ) && ( CMin == other.CMin || CMin != null && CMin.Equals(other.CMin) ) && ( CMax == other.CMax || CMax != null && CMax.Equals(other.CMax) ) && ( CMid == other.CMid || CMid != null && CMid.Equals(other.CMid) ) && ( ColorScale == other.ColorScale || ColorScale != null && ColorScale.Equals(other.ColorScale) ) && ( AutoColorScale == other.AutoColorScale || AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale) ) && ( ReverseScale == other.ReverseScale || ReverseScale != null && ReverseScale.Equals(other.ReverseScale) ) && ( ShowScale == other.ShowScale || ShowScale != null && ShowScale.Equals(other.ShowScale) ) && ( ColorBar == other.ColorBar || ColorBar != null && ColorBar.Equals(other.ColorBar) ) && ( ColorAxis == other.ColorAxis || ColorAxis != null && ColorAxis.Equals(other.ColorAxis) ) && ( Contours == other.Contours || Contours != null && Contours.Equals(other.Contours) ) && ( HideSurface == other.HideSurface || HideSurface != null && HideSurface.Equals(other.HideSurface) ) && ( LightPosition == other.LightPosition || LightPosition != null && LightPosition.Equals(other.LightPosition) ) && ( Lighting == other.Lighting || Lighting != null && Lighting.Equals(other.Lighting) ) && ( Opacity == other.Opacity || Opacity != null && Opacity.Equals(other.Opacity) ) && ( OpacityScale == other.OpacityScale || OpacityScale != null && OpacityScale.Equals(other.OpacityScale) ) && ( HoverInfo == other.HoverInfo || HoverInfo != null && HoverInfo.Equals(other.HoverInfo) ) && ( Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray) ) && ( ShowLegend == other.ShowLegend || ShowLegend != null && ShowLegend.Equals(other.ShowLegend) ) && ( XCalendar == other.XCalendar || XCalendar != null && XCalendar.Equals(other.XCalendar) ) && ( YCalendar == other.YCalendar || YCalendar != null && YCalendar.Equals(other.YCalendar) ) && ( ZCalendar == other.ZCalendar || ZCalendar != null && ZCalendar.Equals(other.ZCalendar) ) && ( Scene == other.Scene || Scene != null && Scene.Equals(other.Scene) ) && ( IdsSrc == other.IdsSrc || IdsSrc != null && IdsSrc.Equals(other.IdsSrc) ) && ( CustomDataSrc == other.CustomDataSrc || CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc) ) && ( MetaSrc == other.MetaSrc || MetaSrc != null && MetaSrc.Equals(other.MetaSrc) ) && ( ZSrc == other.ZSrc || ZSrc != null && ZSrc.Equals(other.ZSrc) ) && ( XSrc == other.XSrc || XSrc != null && XSrc.Equals(other.XSrc) ) && ( YSrc == other.YSrc || YSrc != null && YSrc.Equals(other.YSrc) ) && ( TextSrc == other.TextSrc || TextSrc != null && TextSrc.Equals(other.TextSrc) ) && ( HoverTextSrc == other.HoverTextSrc || HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc) ) && ( HoverTemplateSrc == other.HoverTemplateSrc || HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc) ) && ( SurfaceColorSrc == other.SurfaceColorSrc || SurfaceColorSrc != null && SurfaceColorSrc.Equals(other.SurfaceColorSrc) ) && ( HoverInfoSrc == other.HoverInfoSrc || HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc) )); }
public void Update() { ResetNodesState(); // Сброс состояния нод, присвоение им номеров foreach (Connector connector in Connectors) { if (connector.NodeA.Connections.Count == 1 && connector.NodeB.Connections.Count > 1 || connector.NodeA.Connections.Count > 1 && connector.NodeB.Connections.Count == 1) { throw new WrongSchemeException("Unconnected pin found!"); } } ContoursSearch(); // Получаем список замкнутых контуров if (Contours.Count < 1) { return; } if (Contours.Count == 1) { if (Contours.First().Connectors.Count(i => i is Battery) != 1) { throw new WrongSchemeException("Check layout! Wrong batteries amount!"); } Battery bat = Contours.First().Connectors.First(i => i is Battery) as Battery; ElementsChain batChain = new ElementsChain(new Node[] { bat.NodeA, bat.NodeB }); double amp = bat.Eds / Contours.First().Connectors.Sum(i => i.Resistance) * Contours.First().SameDirected(batChain); Contours.First().RunElectricCurrent(amp); return; } ChainsSerach(); // Получаем список цепей UpdateChainNumbers(); Rule1Count = Nodes.Count(i => i.Connections.Count > 2) - 1; // Количество уравнений по первому правилу int matrixSize = Chains.Count; // Размер матрицы (количество неизвестных) CountMatrix = new double[matrixSize, matrixSize]; // Матрица для левой части уравнений resultVector = new double[matrixSize]; // Вектор для правой части уравнений for (int i = 0; i < matrixSize; i++) // Уравнение { for (int j = 0; j < matrixSize; j++) // Неизвестная { if (i < Rule1Count) // Первое правило { Node curNode = Nodes // Следующая по списку нода с >2 ног .Where(nd => nd.Connections.Count > 2) .ElementAt(i); CountMatrix[i, j] = Chains[j].GetCurrentDirection(curNode); } else // Второе правило { // Если контур включает в себя хотябы один коннектор из цепочки, то он включает в себя всю цепочку if (Contours[i - Rule1Count].Connectors.Contains(Chains[j].Connectors.First())) { CountMatrix[i, j] = Chains[j].GetResistance() * Contours[i - Rule1Count].SameDirected(Chains[j]); } } } resultVector[i] = i < Rule1Count ? 0 : Contours[i - Rule1Count].GetEds(); // Результирующий вектор (0 или сумма ЭДС) } KramerCounter kc = new KramerCounter(CountMatrix, resultVector); // Крамер double[] xv = kc.Answer; for (int i = 0; i < xv.Length; i++) { Chains[i].RunElectricCurrent(-xv[i]); } Fire("Quations", "DisplayMatrix"); }
public Contour GetSingleContour() { if (Contours.Count == 0) { throw new Exception("Контуры отсутствуют"); } if (!AllContoursAreCompleted) { throw new Exception("Все контуры должны быть замкнуты!"); } var boundingBoxes = new Dictionary <int, BoundingBox>(); for (int i = 0; i < Contours.Count; i++) { boundingBoxes.Add(i, Contours[i].GetBoundingBox()); } var largestBox = boundingBoxes.FirstOrDefault(x => boundingBoxes.Where(y => y.Key != x.Key).All(y => x.Value.Contains(y.Value))); var restBoxes = boundingBoxes.Where(x => x.Key != largestBox.Key).ToArray(); if (largestBox.Value == null) { throw new Exception("Контуры не образуют единой области. Дальнейшие вычисления невозможны"); } if (restBoxes.Any(x => restBoxes.Where(y => y.Key != x.Key).Any(y => x.Value.Contains(y.Value)))) { throw new Exception("Вложенность дырок недопустима. Дальнейшие вычисления невозможны"); } var largestContour = Contours[largestBox.Key]; largestContour.OrientCounterclockwise(); for (int i = 0; i < Contours.Count; i++) { if (i != largestBox.Key) { var contour = Contours[i]; contour.OrientClockwise(); var nearestPoints = largestContour.ToDictionary(x => x, x => contour.ToDictionary(y => y, y => Math.Sqrt(Math.Pow(x.X - y.X, 2) + Math.Pow(x.Y - y.Y, 2))).OrderBy(r => r.Value).First()). OrderBy(r => r.Value.Value).First(); int largeContourPointIndex = nearestPoints.Key.Index; int contourPointIndex = nearestPoints.Value.Key.Index; for (int j = 0; j < contour.Count - contourPointIndex + 1; j++) { Point pt = contour[contourPointIndex - 1 + j].Clone(); pt.Index = largeContourPointIndex + 1 + j; largestContour.Insert(pt.Index - 1, pt); } for (int j = 0; j < contourPointIndex; j++) { Point pt = contour[j].Clone(); pt.Index = largeContourPointIndex + contour.Count - contourPointIndex + j + 2; largestContour.Insert(pt.Index - 1, pt); } Point self = largestContour[largeContourPointIndex - 1].Clone(); int offset = self.Index + contour.Count + 2; self.Index = offset; largestContour.Insert(self.Index - 1, self); for (int j = offset; j < largestContour.Count; j++) { largestContour[j].Index = j + 1; } } } largestContour.Index = 1; Contours.Clear(); Contours.Add(largestContour); return(largestContour); }
public List <(Point, double)> GetAllCellLengthWithCenterPoint() { return((from contour in Contours.ToArrayOfArray() select new VectorOfPoint(contour) into tempVector let moment = CvInvoke.Moments(tempVector) let cx = moment.M10 / moment.M00 let cy = moment.M01 / moment.M00 let tempPoint = new Point((int)cx, (int)cy) let tempRect = CvInvoke.MinAreaRect(tempVector) select(tempPoint, tempRect.Size.Height)).Select(dummy => ((Point, double))dummy).ToList()); }
public void Reset() { Contours.Clear(); _lastPointIndex = 0; }
private void pictureBox1_Paint (object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; TContourEdit contour = new TContourEdit(); Random random = new Random(); int countPoint=0; //List<Point> points = new List<Point>(); for (int i=0; i<2; i++) { TContourBitEdit contourBitEdit = new TContourBitEdit(); //for(int y=10; y<100; y*=2) //{ // int ran = random.Next(100); // contourBitEdit.AddPoint(ran + y*3, i * 2 + ran, 0); // // points.Add(new Point(ran + y * 3, i * 2 + ran)); // countPoint++; //} if(i==0) { contourBitEdit.AddPoint(10, 5, 0); contourBitEdit.AddPoint(10, 50, 0); contourBitEdit.AddPoint(50, 100, 0); } if(i==1) { contourBitEdit.AddPoint(150, 150, 0); contourBitEdit.AddPoint(150, 50, 0); contourBitEdit.AddPoint(100, 10, 0); } if (i % 2 != 0) contourBitEdit.SetClosed(true); else contourBitEdit.SetClosed(false); contour.AddContourBit(contourBitEdit); } GraphicsPath path = new GraphicsPath(); for(int i=0; i< contour.GetContourBitCount(); i++) { Point[] points = new Point[contour.GetContourBit(i).GetPointCount()]; for (int y = 0; y < contour.GetContourBit(i).GetPointCount(); y++) { Point newpoint = new Point((int)contour.GetContourBit(i).GetPoint(y).GetX(), (int)contour.GetContourBit(i).GetPoint(y).GetY()); points[y] = newpoint; } path.AddLines(points); } Pen myWind = new Pen(Color.Black); g.DrawPath(myWind, path); TRect_Float rect_Float = new TRect_Float(); rect_Float.X1 = 10; rect_Float.X2 = 100; rect_Float.Y1 = 10; rect_Float.Y2 = 100; myWind = new Pen(Color.Red); g.DrawRectangle(myWind, new Rectangle((int)rect_Float.TrectAngle()[0].GetX() ,(int)rect_Float.TrectAngle()[0].GetY(), (int)rect_Float.TrectAngle()[2].GetX(), (int)rect_Float.TrectAngle()[2].GetY())); Contours contours = new Contours (); contours.AddContour(contour); IContour contour1 = contour.CutContoursByWindow(contours, rect_Float); }
public override void UpdateMesh(ProjectPolygon[] p) { ProjectPolygons = p; PlaneSurface ps = new PlaneSurface() { Position = Location, Normal = Axis }; var bs = ps.GetBasis(); var vec0 = bs[0] * Radius; //stage1 //check nesting List <ProjectPolygon> tops = new List <ProjectPolygon>(); foreach (var item in ProjectPolygons) { bool good = true; foreach (var item2 in ProjectPolygons) { if (item == item2) { continue; } var pnts2 = item2.Points.ToArray(); if (GeometryUtils.pnpoly(pnts2, item.Points[0].X, item.Points[0].Y)) { good = false; break; } } if (good) { tops.Add(item); } } List <Vector2d[]> triangls = new List <Vector2d[]>(); double step = AngleStep / 180f * Math.PI; //extract 3d contours Contours.Clear(); foreach (var item in tops) { var cc = new Contour3d(); Contours.Add(cc); var maxy = item.Points.Max(z => z.Y) + 1; var miny = item.Points.Min(z => z.Y) - 1; for (int i = 0; i < item.Points.Count; i++) { var p0 = item.Points[i]; var p1 = item.Points[(i + 1) % item.Points.Count]; double last = 0; List <Vector2d> cutPoints = new List <Vector2d>(); List <Vector2d> tempPoints = new List <Vector2d>(); cutPoints.Add(p0); while (true) { var p00 = last; var p11 = p00 + step; last += step; p00 = Math.Min(p00, 10 * Math.PI * 2); p11 = Math.Min(p11, 10 * Math.PI * 2); if (Math.Abs(p00 - p11) < 1e-8) { break; } Vector2d ret1 = Vector2d.Zero; if (GeometryUtils.IntersectSegments(p0, p1, new Vector2d(p11, miny), new Vector2d(p11, maxy), ref ret1)) { tempPoints.Add(ret1); } } tempPoints.Add(p1); while (tempPoints.Any()) { var fr = tempPoints.OrderBy(z => (z - cutPoints.Last()).Length).First(); cutPoints.Add(fr); tempPoints.Remove(fr); } for (int j = 0; j < cutPoints.Count; j++) { var ang = cutPoints[j].X; var mtr = Matrix4d.CreateFromAxisAngle(Axis, -ang); var rot0 = Vector3d.Transform(vec0 + Axis * cutPoints[j].Y * Lenght, mtr); cc.Points.Add(Location + rot0); } } } foreach (var item in tops) { List <ProjectPolygon> holes = new List <ProjectPolygon>(); var pnts2 = item.Points.ToArray(); foreach (var xitem in ProjectPolygons.Except(tops)) { if (GeometryUtils.pnpoly(pnts2, xitem.Points[0].X, xitem.Points[0].Y)) { holes.Add(xitem); } } PolyBoolCS.PolyBool pb = new PolyBoolCS.PolyBool(); PolyBoolCS.Polygon p1 = new PolyBoolCS.Polygon(); var pl1 = new PolyBoolCS.PointList(); p1.regions = new List <PolyBoolCS.PointList>(); pl1.AddRange(item.Points.Select(z => new PolyBoolCS.Point(z.X, z.Y)).ToArray()); p1.regions.Add(pl1); var maxy = pl1.Max(z => z.y) + 1; var miny = pl1.Min(z => z.y) - 1; double last = 0; while (true) //for (double i = step; i < (Math.PI * 2); i += step) { var p0 = last; var p11 = p0 + step; last += step; p0 = Math.Min(p0, 10 * Math.PI * 2); p11 = Math.Min(p11, 10 * Math.PI * 2); if (Math.Abs(p0 - p11) < 1e-8) { break; } PolyBoolCS.Polygon p2 = new PolyBoolCS.Polygon(); p2.regions = new List <PolyBoolCS.PointList>(); var pl2 = new PolyBoolCS.PointList(); pl2.Add(new PolyBoolCS.Point(p0, miny)); pl2.Add(new PolyBoolCS.Point(p0, maxy)); pl2.Add(new PolyBoolCS.Point(p11, maxy)); pl2.Add(new PolyBoolCS.Point(p11, miny)); p2.regions.Add(pl2); if (holes.Any(z => GeometryUtils.AlmostEqual(z.Area(), 0))) { throw new GeomPadException("zero area contour detected"); } var res = pb.intersect(p1, p2); if (res.regions.Any()) { foreach (var region in res.regions) { var triangls2 = GeometryUtils.TriangulateWithHoles( new[] { region.Select(z => new Vector2d(z.x, z.y)).ToArray() } , holes.Select(z => z.Points.ToArray()).ToArray(), true); triangls.AddRange(triangls2); } } } } //stage2 List <TriangleInfo> tt = new List <TriangleInfo>(); foreach (var item in triangls) { TriangleInfo tin = new TriangleInfo(); List <VertexInfo> v = new List <VertexInfo>(); foreach (var d in item) { var ang = d.X; var mtr = Matrix4d.CreateFromAxisAngle(Axis, -ang); var rot0 = Vector3d.Transform(vec0 + Axis * d.Y * Lenght, mtr); v.Add(new VertexInfo() { Position = Location + rot0 }); } var v01 = v[1].Position - v[0].Position; var v11 = v[2].Position - v[0].Position; var crs = Vector3d.Cross(v01, v11).Normalized(); if (double.IsNaN(crs.X)) { throw new GeomPadException("normal is NaN"); } foreach (var item0 in v) { item0.Normal = crs; } tin.Vertices = v.ToArray(); tt.Add(tin); } Mesh = new Mesh() { Triangles = tt }; }
/// <inheritdoc /> public bool Equals([AllowNull] Contour other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( Visible == other.Visible || Visible != null && Visible.Equals(other.Visible) ) && ( ShowLegend == other.ShowLegend || ShowLegend != null && ShowLegend.Equals(other.ShowLegend) ) && ( LegendGroup == other.LegendGroup || LegendGroup != null && LegendGroup.Equals(other.LegendGroup) ) && ( Opacity == other.Opacity || Opacity != null && Opacity.Equals(other.Opacity) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( UId == other.UId || UId != null && UId.Equals(other.UId) ) && ( Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids) ) && ( Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData) ) && ( Meta == other.Meta || Meta != null && Meta.Equals(other.Meta) ) && ( Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray) ) && ( HoverInfo == other.HoverInfo || HoverInfo != null && HoverInfo.Equals(other.HoverInfo) ) && ( Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray) ) && ( HoverLabel == other.HoverLabel || HoverLabel != null && HoverLabel.Equals(other.HoverLabel) ) && ( Stream == other.Stream || Stream != null && Stream.Equals(other.Stream) ) && ( Equals(Transforms, other.Transforms) || Transforms != null && other.Transforms != null && Transforms.SequenceEqual(other.Transforms) ) && ( UiRevision == other.UiRevision || UiRevision != null && UiRevision.Equals(other.UiRevision) ) && ( Equals(Z, other.Z) || Z != null && other.Z != null && Z.SequenceEqual(other.Z) ) && ( Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X) ) && ( X0 == other.X0 || X0 != null && X0.Equals(other.X0) ) && ( DX == other.DX || DX != null && DX.Equals(other.DX) ) && ( Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y) ) && ( Y0 == other.Y0 || Y0 != null && Y0.Equals(other.Y0) ) && ( Dy == other.Dy || Dy != null && Dy.Equals(other.Dy) ) && ( Equals(Text, other.Text) || Text != null && other.Text != null && Text.SequenceEqual(other.Text) ) && ( Equals(HoverText, other.HoverText) || HoverText != null && other.HoverText != null && HoverText.SequenceEqual(other.HoverText) ) && ( Transpose == other.Transpose || Transpose != null && Transpose.Equals(other.Transpose) ) && ( XType == other.XType || XType != null && XType.Equals(other.XType) ) && ( YType == other.YType || YType != null && YType.Equals(other.YType) ) && ( ZHoverFormat == other.ZHoverFormat || ZHoverFormat != null && ZHoverFormat.Equals(other.ZHoverFormat) ) && ( HoverTemplate == other.HoverTemplate || HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate) ) && ( Equals(HoverTemplateArray, other.HoverTemplateArray) || HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray) ) && ( HoverOnGaps == other.HoverOnGaps || HoverOnGaps != null && HoverOnGaps.Equals(other.HoverOnGaps) ) && ( ConnectGaps == other.ConnectGaps || ConnectGaps != null && ConnectGaps.Equals(other.ConnectGaps) ) && ( FillColor == other.FillColor || FillColor != null && FillColor.Equals(other.FillColor) ) && ( AutoContour == other.AutoContour || AutoContour != null && AutoContour.Equals(other.AutoContour) ) && ( NContours == other.NContours || NContours != null && NContours.Equals(other.NContours) ) && ( Contours == other.Contours || Contours != null && Contours.Equals(other.Contours) ) && ( Line == other.Line || Line != null && Line.Equals(other.Line) ) && ( ZAuto == other.ZAuto || ZAuto != null && ZAuto.Equals(other.ZAuto) ) && ( ZMin == other.ZMin || ZMin != null && ZMin.Equals(other.ZMin) ) && ( ZMax == other.ZMax || ZMax != null && ZMax.Equals(other.ZMax) ) && ( ZMid == other.ZMid || ZMid != null && ZMid.Equals(other.ZMid) ) && ( ColorScale == other.ColorScale || ColorScale != null && ColorScale.Equals(other.ColorScale) ) && ( AutoColorScale == other.AutoColorScale || AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale) ) && ( ReverseScale == other.ReverseScale || ReverseScale != null && ReverseScale.Equals(other.ReverseScale) ) && ( ShowScale == other.ShowScale || ShowScale != null && ShowScale.Equals(other.ShowScale) ) && ( ColorBar == other.ColorBar || ColorBar != null && ColorBar.Equals(other.ColorBar) ) && ( ColorAxis == other.ColorAxis || ColorAxis != null && ColorAxis.Equals(other.ColorAxis) ) && ( XCalendar == other.XCalendar || XCalendar != null && XCalendar.Equals(other.XCalendar) ) && ( YCalendar == other.YCalendar || YCalendar != null && YCalendar.Equals(other.YCalendar) ) && ( XAxis == other.XAxis || XAxis != null && XAxis.Equals(other.XAxis) ) && ( YAxis == other.YAxis || YAxis != null && YAxis.Equals(other.YAxis) ) && ( IdsSrc == other.IdsSrc || IdsSrc != null && IdsSrc.Equals(other.IdsSrc) ) && ( CustomDataSrc == other.CustomDataSrc || CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc) ) && ( MetaSrc == other.MetaSrc || MetaSrc != null && MetaSrc.Equals(other.MetaSrc) ) && ( HoverInfoSrc == other.HoverInfoSrc || HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc) ) && ( ZSrc == other.ZSrc || ZSrc != null && ZSrc.Equals(other.ZSrc) ) && ( XSrc == other.XSrc || XSrc != null && XSrc.Equals(other.XSrc) ) && ( YSrc == other.YSrc || YSrc != null && YSrc.Equals(other.YSrc) ) && ( TextSrc == other.TextSrc || TextSrc != null && TextSrc.Equals(other.TextSrc) ) && ( HoverTextSrc == other.HoverTextSrc || HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc) ) && ( HoverTemplateSrc == other.HoverTemplateSrc || HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc) )); }