개정판 c4ba621d
Feature: LengthToleranceRatio, 중첩 블럭 깨는 로직 추가
Change-Id: Ieed4c92f4e9ea0a1752e72b259b53d8eb9e0b979
ID2.Manager/ID2.Manager.Compare/Controls/Verification.cs | ||
---|---|---|
36 | 36 |
private static Color DiffColor = Color.Yellow; |
37 | 37 |
|
38 | 38 |
private static double Tolerance = 0; |
39 |
private static double LengthToleranceRatio { get; set; } = 0.1; |
|
39 | 40 |
#endregion |
40 | 41 |
|
41 | 42 |
private RadProgressBarElement _progressBar = null; |
... | ... | |
315 | 316 |
} |
316 | 317 |
} |
317 | 318 |
|
319 |
string _LengthToleranceRatio = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Length Tolerance Ratio"); |
|
320 |
if (!string.IsNullOrEmpty(_LengthToleranceRatio)) |
|
321 |
{ |
|
322 |
LengthToleranceRatio = Convert.ToDouble(_LengthToleranceRatio); |
|
323 |
} |
|
324 |
|
|
318 | 325 |
#region Except Layer를 로딩한다. |
319 | 326 |
LoadLayerSettings(); |
320 | 327 |
#endregion |
... | ... | |
402 | 409 |
} |
403 | 410 |
} |
404 | 411 |
|
412 |
private List<Entity> ExplodeBlockReference(Design design, BlockReference blkref, string LayerName, Color color) |
|
413 |
{ |
|
414 |
var res = new List<Entity>(); |
|
415 |
|
|
416 |
var entities = blkref.Explode(design.Blocks); |
|
417 |
foreach (var ent in entities) ent.LayerName = LayerName; |
|
418 |
entities.ToList().ForEach(y => |
|
419 |
{ |
|
420 |
if (y is LinearPath lp) |
|
421 |
{ |
|
422 |
int count = Convert.ToInt32(lp.Vertices.Length); |
|
423 |
for (int i = 0; i < count - 1; ++i) |
|
424 |
{ |
|
425 |
var line = new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1]) |
|
426 |
{ |
|
427 |
LayerName = lp.LayerName, |
|
428 |
LineWeight = lp.LineWeight, |
|
429 |
LineTypeMethod = colorMethodType.byEntity, |
|
430 |
Color = Verification.AutoCADColor, |
|
431 |
ColorMethod = colorMethodType.byEntity |
|
432 |
}; |
|
433 |
res.Add(line); |
|
434 |
} |
|
435 |
} |
|
436 |
else if(y is BlockReference subblkref) |
|
437 |
{ |
|
438 |
res.AddRange(ExplodeBlockReference(design, subblkref, LayerName, color)); |
|
439 |
} |
|
440 |
}); |
|
441 |
|
|
442 |
var attributes = blkref.Attributes; |
|
443 |
foreach (var ent in entities.Where(y => y is devDept.Eyeshot.Entities.Attribute)) |
|
444 |
{ |
|
445 |
var txt = ent as devDept.Eyeshot.Entities.Attribute; |
|
446 |
txt.LayerName = LayerName; |
|
447 |
txt.Color = color; |
|
448 |
txt.ColorMethod = colorMethodType.byEntity; |
|
449 |
KeyValuePair<string, AttributeReference>? kp = attributes.FirstOrDefault(z => z.Key == txt.TextString); |
|
450 |
if (kp.HasValue) txt.TextString = (kp.Value.Value) != null ? kp.Value.Value.Value : string.Empty; |
|
451 |
} |
|
452 |
|
|
453 |
res.AddRange(entities.Where(y => |
|
454 |
{ |
|
455 |
if (y is devDept.Eyeshot.Entities.Attribute attr && string.IsNullOrEmpty(attr.TextString)) return false; |
|
456 |
if (y is devDept.Eyeshot.Entities.Text text && string.IsNullOrEmpty(text.TextString)) return false; |
|
457 |
if (y is BlockReference subblkref && subblkref.BlockName == "PORT") return false; |
|
458 |
if (y is LinearPath) return false; |
|
459 |
return true; |
|
460 |
})); |
|
461 |
|
|
462 |
blkref.Attributes.Clear(); |
|
463 |
blkref.UpdateBoundingBox(new TraversalParams(design)); |
|
464 |
|
|
465 |
return res; |
|
466 |
} |
|
467 |
|
|
405 | 468 |
/// <summary> |
406 | 469 |
/// 주어진 도면의 원본과 AVEVA를 비교한다. |
407 | 470 |
/// </summary> |
... | ... | |
425 | 488 |
ent.Translate(-min.X, -min.Y); |
426 | 489 |
} |
427 | 490 |
ra.AddToScene(design); |
491 |
design.Entities.RemoveAll(x => Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible)); |
|
428 | 492 |
} |
429 | 493 |
catch (Exception ex) |
430 | 494 |
{ |
... | ... | |
543 | 607 |
{ |
544 | 608 |
if (x is BlockReference blkref) |
545 | 609 |
{ |
546 |
var entities = blkref.Explode(design.Blocks); |
|
547 |
foreach (var ent in entities) ent.LayerName = Verification.AutoCADLayer; |
|
548 |
entities.ToList().ForEach(y => |
|
549 |
{ |
|
550 |
if (y is LinearPath lp) |
|
551 |
{ |
|
552 |
int count = Convert.ToInt32(lp.Vertices.Length); |
|
553 |
for (int i = 0; i < count - 1; ++i) |
|
554 |
{ |
|
555 |
var line = new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1]) |
|
556 |
{ |
|
557 |
LayerName = lp.LayerName, |
|
558 |
LineWeight = lp.LineWeight, |
|
559 |
LineTypeMethod = colorMethodType.byEntity, |
|
560 |
Color = Verification.AutoCADColor, |
|
561 |
ColorMethod = colorMethodType.byEntity |
|
562 |
}; |
|
563 |
AddEntities.Add(line); |
|
564 |
} |
|
565 |
} |
|
566 |
}); |
|
567 |
|
|
568 |
var attributes = blkref.Attributes; |
|
569 |
foreach (var ent in entities.Where(y => y is devDept.Eyeshot.Entities.Attribute)) |
|
570 |
{ |
|
571 |
var txt = ent as devDept.Eyeshot.Entities.Attribute; |
|
572 |
txt.LayerName = Verification.AutoCADLayer; |
|
573 |
txt.Color = Verification.AutoCADColor; |
|
574 |
txt.ColorMethod = colorMethodType.byEntity; |
|
575 |
KeyValuePair<string, AttributeReference>? kp = attributes.FirstOrDefault(z => z.Key == txt.TextString); |
|
576 |
if (kp.HasValue) txt.TextString = (kp.Value.Value) != null ? kp.Value.Value.Value : string.Empty; |
|
577 |
} |
|
578 |
|
|
579 |
AddEntities.AddRange(entities.Where(y => |
|
580 |
{ |
|
581 |
if (y is devDept.Eyeshot.Entities.Attribute attr && string.IsNullOrEmpty(attr.TextString)) return false; |
|
582 |
if (y is devDept.Eyeshot.Entities.Text text && string.IsNullOrEmpty(text.TextString)) return false; |
|
583 |
if (y is LinearPath) return false; |
|
584 |
return true; |
|
585 |
})); |
|
586 |
|
|
587 |
blkref.Attributes.Clear(); |
|
588 |
blkref.UpdateBoundingBox(new TraversalParams(design)); |
|
610 |
AddEntities.AddRange(ExplodeBlockReference(design, blkref, Verification.AutoCADLayer, Verification.AutoCADColor)); |
|
589 | 611 |
} |
590 | 612 |
}); |
591 | 613 |
|
592 | 614 |
design.Entities.RemoveAll(x => (x is BlockReference) || Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible)); |
593 | 615 |
design.Entities.AddRange(AddEntities); |
616 |
|
|
617 |
#region 눈에 보이지 않는 라인은 제거 |
|
618 |
design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001); |
|
619 |
#endregion |
|
594 | 620 |
#endregion |
595 | 621 |
|
596 | 622 |
ColorEntities(design, design.Entities, Verification.AutoCADColor); |
... | ... | |
679 | 705 |
} |
680 | 706 |
ra.AddToScene(design); |
681 | 707 |
|
708 |
#region 불필요한 블럭들은 제거 |
|
709 |
design.Entities.RemoveAll(x => x is BlockReference blkref && (blkref.BlockName == "LBRK" || |
|
710 |
blkref.BlockName == "PSNODE" || blkref.BlockName == "PENODE" || blkref.BlockName.StartsWith("ARROW"))); |
|
711 |
#endregion |
|
712 |
|
|
682 | 713 |
#region 블럭을 깸 |
683 | 714 |
design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList().ForEach(x => |
684 | 715 |
{ |
685 | 716 |
if(x is BlockReference blkref) |
686 | 717 |
{ |
687 |
var attributes = blkref.Attributes; |
|
688 |
var entities = blkref.Explode(design.Blocks); |
|
689 |
entities.ToList().ForEach(y => |
|
690 |
{ |
|
691 |
if (y is LinearPath lp) |
|
692 |
{ |
|
693 |
int count = Convert.ToInt32(lp.Vertices.Length); |
|
694 |
for (int i = 0; i < count - 1; ++i) |
|
695 |
{ |
|
696 |
var line = new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1]) |
|
697 |
{ |
|
698 |
LayerName = Verification.AVEVALayer, |
|
699 |
LineWeight = lp.LineWeight, |
|
700 |
LineTypeMethod = colorMethodType.byEntity, |
|
701 |
Color = Verification.AVEVAColor, |
|
702 |
ColorMethod = colorMethodType.byEntity |
|
703 |
}; |
|
704 |
AddEntities.Add(line); |
|
705 |
} |
|
706 |
} |
|
707 |
else |
|
708 |
{ |
|
709 |
y.LayerName = Verification.AVEVALayer; |
|
710 |
y.Color = Verification.AVEVAColor; |
|
711 |
y.ColorMethod = colorMethodType.byEntity; |
|
712 |
} |
|
713 |
}); |
|
714 |
|
|
715 |
foreach (var ent in entities.Where(y => y is devDept.Eyeshot.Entities.Attribute)) |
|
716 |
{ |
|
717 |
var txt = ent as devDept.Eyeshot.Entities.Attribute; |
|
718 |
txt.LayerName = Verification.AVEVALayer; |
|
719 |
txt.Color = Verification.AVEVAColor; |
|
720 |
txt.ColorMethod = colorMethodType.byEntity; |
|
721 |
KeyValuePair<string, AttributeReference>? kp = attributes.FirstOrDefault(z => z.Key == txt.TextString); |
|
722 |
if (kp.HasValue) txt.TextString = (kp.Value.Value) != null ? kp.Value.Value.Value : string.Empty; |
|
723 |
} |
|
724 |
|
|
725 |
AddEntities.AddRange(entities.Where(y => |
|
726 |
{ |
|
727 |
if (y is devDept.Eyeshot.Entities.Attribute attr && string.IsNullOrEmpty(attr.TextString)) return false; |
|
728 |
if (y is devDept.Eyeshot.Entities.Text text && string.IsNullOrEmpty(text.TextString)) return false; |
|
729 |
if (y is LinearPath) return false; |
|
730 |
return true; |
|
731 |
})); |
|
732 |
blkref.Attributes.Clear(); |
|
733 |
blkref.UpdateBoundingBox(new TraversalParams(design)); |
|
718 |
AddEntities.AddRange(ExplodeBlockReference(design, blkref, Verification.AVEVALayer, Verification.AVEVAColor)); |
|
734 | 719 |
} |
735 | 720 |
}); |
736 | 721 |
design.Entities.RemoveAll(x => |
... | ... | |
740 | 725 |
design.Entities.AddRange(AddEntities); |
741 | 726 |
#endregion |
742 | 727 |
|
743 |
ColorEntities(design, design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList(), Verification.AVEVAColor); |
|
744 |
|
|
745 |
#region 블럭 이름이 PSNODE, PENODE인 블럭은 보이지 않도록 한다. |
|
746 |
design.Entities.ForEach(x => |
|
747 |
{ |
|
748 |
if (x is BlockReference blkref && (blkref.BlockName == "PSNODE" || blkref.BlockName == "PENODE" || |
|
749 |
blkref.BlockName.StartsWith("ARROW"))) |
|
750 |
blkref.Visible = false; |
|
751 |
}); |
|
728 |
#region 눈에 보이지 않는 라인은 제거 |
|
729 |
design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001); |
|
752 | 730 |
#endregion |
753 | 731 |
|
732 |
ColorEntities(design, design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList(), Verification.AVEVAColor); |
|
733 |
|
|
754 | 734 |
design.SetView(viewType.Top); |
755 | 735 |
design.ZoomFit(); |
756 | 736 |
design.Invalidate(); |
... | ... | |
826 | 806 |
equalEntitiesInV1[j] = i; |
827 | 807 |
equalEntitiesInV2[j] = true; |
828 | 808 |
foundEqual = true; |
829 |
|
|
830 |
design2.Entities.Remove(entVp2); |
|
831 | 809 |
break; |
832 | 810 |
} |
833 | 811 |
} |
... | ... | |
839 | 817 |
var origin = new devDept.Geometry.Point2D(entVp1.BoxMin.X - 1, entVp1.BoxMin.Y - 1); |
840 | 818 |
double width = entVp1.BoxMax.X - entVp1.BoxMin.X; |
841 | 819 |
double height = entVp1.BoxMax.Y - entVp1.BoxMin.Y; |
842 |
var rect = new devDept.Eyeshot.OrientedBoundingRect(origin, width + 2, height + 2); |
|
843 |
DiffRegions.Add(rect); |
|
820 |
if (Math.Abs(width) != double.PositiveInfinity && Math.Abs(height) != double.PositiveInfinity) |
|
821 |
{ |
|
822 |
var rect = new devDept.Eyeshot.OrientedBoundingRect(origin, width + 2, height + 2); |
|
823 |
DiffRegions.Add(rect); |
|
824 |
} |
|
844 | 825 |
#endregion |
845 | 826 |
} |
846 | 827 |
} |
... | ... | |
855 | 836 |
var origin = new devDept.Geometry.Point2D(AVEVAEntities[j].BoxMin.X - 1, AVEVAEntities[j].BoxMin.Y - 1); |
856 | 837 |
double width = AVEVAEntities[j].BoxMax.X - AVEVAEntities[j].BoxMin.X; |
857 | 838 |
double height = AVEVAEntities[j].BoxMax.Y - AVEVAEntities[j].BoxMin.Y; |
858 |
var rect = new devDept.Eyeshot.OrientedBoundingRect(origin, width + 2, height + 2); |
|
859 |
DiffRegions.Add(rect); |
|
839 |
if (Math.Abs(width) != double.PositiveInfinity && Math.Abs(height) != double.PositiveInfinity) |
|
840 |
{ |
|
841 |
var rect = new devDept.Eyeshot.OrientedBoundingRect(origin, width + 2, height + 2); |
|
842 |
DiffRegions.Add(rect); |
|
843 |
} |
|
860 | 844 |
#endregion |
861 | 845 |
} |
862 | 846 |
} |
... | ... | |
970 | 954 |
revcloud.LayerName = Verification.RevCloudLayer; |
971 | 955 |
revcloud.Color = Verification.RevCloudColor; |
972 | 956 |
revcloud.ColorMethod = colorMethodType.byEntity; |
957 |
revcloud.LineWeight = 10; |
|
958 |
revcloud.LineWeightMethod = colorMethodType.byEntity; |
|
973 | 959 |
design.Entities.Add(revcloud); |
974 | 960 |
} |
975 | 961 |
|
... | ... | |
1043 | 1029 |
return true; |
1044 | 1030 |
} |
1045 | 1031 |
} |
1046 |
else if (ent1 is PlanarEntity pe1 && ent2 is PlanarEntity pe2)
|
|
1032 |
else if (ent1 is PlanarEntity && ent2 is PlanarEntity)
|
|
1047 | 1033 |
{ |
1048 | 1034 |
if (ent1 is Arc arc1 && ent2 is Arc arc2) |
1049 | 1035 |
{ |
... | ... | |
1091 | 1077 |
return true; |
1092 | 1078 |
} |
1093 | 1079 |
} |
1094 |
#region 해치는 삽입점만 비교
|
|
1080 |
#region 해치는 중점만 비교
|
|
1095 | 1081 |
else if (ent1 is Hatch hatch1 && ent2 is Hatch hatch2) |
1096 | 1082 |
{ |
1097 | 1083 |
var center1 = (hatch1.BoxMin + hatch1.BoxMax) * 0.5; |
... | ... | |
1213 | 1199 |
var dir2 = line2.Direction; |
1214 | 1200 |
dir2.Normalize(); |
1215 | 1201 |
if (devDept.Geometry.Vector3D.AreParallel(dir1, dir2, 0.1) && |
1216 |
Math.Abs(line1.Length() - line2.Length()) <= 0.1 &&
|
|
1202 |
Math.Abs(line1.Length() - line2.Length()) <= line1.Length() * LengthToleranceRatio &&
|
|
1217 | 1203 |
line1.MidPoint.DistanceTo(line2.MidPoint) <= Verification.Tolerance |
1218 | 1204 |
) |
1219 | 1205 |
{ |
내보내기 Unified diff