diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-09-23 00:54:01 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-09-23 00:54:01 +0300 |
commit | bfb45a4f0003498a0832ba18f3739811ebd262b0 (patch) | |
tree | c23bf4b62eb6f57e028702c8a8f8604be3aded2b /UVtools.Core/Managers | |
parent | 981f3688ca3c1de2f67a873ff95f35fc8cb95207 (diff) |
Move lock to gain a parallel Mat Operation
Diffstat (limited to 'UVtools.Core/Managers')
-rw-r--r-- | UVtools.Core/Managers/IssueManager.cs | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/UVtools.Core/Managers/IssueManager.cs b/UVtools.Core/Managers/IssueManager.cs index 0ea0d39..4de0495 100644 --- a/UVtools.Core/Managers/IssueManager.cs +++ b/UVtools.Core/Managers/IssueManager.cs @@ -123,7 +123,7 @@ namespace UVtools.Core.Managers PrintHeightDetectionConfiguration printHeightConfig = null, bool emptyLayersConfig = true, OperationProgress progress = null) - { + { islandConfig ??= new IslandDetectionConfiguration(); overhangConfig ??= new OverhangDetectionConfiguration(); resinTrapConfig ??= new ResinTrapDetectionConfiguration(); @@ -321,8 +321,8 @@ namespace UVtools.Core.Managers if (pixels.Count > 0) { - AddIssue(new MainIssue(MainIssue.IssueType.TouchingBound, new IssueOfPoints(layer, pixels, - new Rectangle(minx, miny, maxx-minx+1, maxy-miny+1)))); + AddIssue(new MainIssue(MainIssue.IssueType.TouchingBound, new IssueOfPoints(layer, pixels, + new Rectangle(minx, miny, maxx - minx + 1, maxy - miny + 1)))); } } @@ -784,19 +784,20 @@ namespace UVtools.Core.Managers CvInvoke.BitwiseAnd(currentAirMap, currentContour, airOverlap); var overlapCount = CvInvoke.CountNonZero(airOverlap); - lock (SlicerFile[layerIndex].Mutex) + //lock (SlicerFile[layerIndex].Mutex) + //{ + if (overlapCount >= resinTrapConfig.RequiredBlackPixelsToDrain) { - if (overlapCount >= resinTrapConfig.RequiredBlackPixelsToDrain) - { - /* this contour does overlap air, add this it our air map */ - CvInvoke.BitwiseOr(currentContour, currentAirMap, currentAirMap); - /* Always add the removed contour to suctionTraps (even if we aren't reporting suction traps) - * This is because contours that are placed on here get removed from resin traps in the next stage - * if you don't put them here, they never get removed even if they should :) */ - - /* if we haven't defined a suctionTrap list for this layer, do so */ + /* this contour does overlap air, add this it our air map */ + CvInvoke.BitwiseOr(currentContour, currentAirMap, currentAirMap, currentContour); + /* Always add the removed contour to suctionTraps (even if we aren't reporting suction traps) + * This is because contours that are placed on here get removed from resin traps in the next stage + * if you don't put them here, they never get removed even if they should :) */ + /* if we haven't defined a suctionTrap list for this layer, do so */ + lock (SlicerFile[layerIndex].Mutex) + { /* since we know it isn't a resin trap, it becomes a suction trap */ suctionCups[layerIndex].Add(resinTraps[layerIndex][x]); @@ -827,19 +828,22 @@ namespace UVtools.Core.Managers resinTraps[item.layerIndex].Remove(item.contour); } } + group.Clear(); resinTrapGroups.Remove(group); break; - } } - /* to keep things tidy while we iterate resin traps, it will be left in the list for now, and removed later */ } - else - { - /* doesn't overlap by enough, remove from air map */ - CvInvoke.Subtract(currentAirMap, currentContour, currentAirMap); + /* to keep things tidy while we iterate resin traps, it will be left in the list for now, and removed later */ + } + else + { + /* doesn't overlap by enough, remove from air map */ + CvInvoke.Subtract(currentAirMap, currentContour, currentAirMap, currentContour); + lock (SlicerFile[layerIndex].Mutex) + { /* put it in a group of resin traps, used when a subsequent layer becomes a suction cup, it can convert any overlapping groups to suction cup */ /* select new LayerIssue(this[layerIndex], LayerIssue.IssueType.ResinTrap, area.Contour, area.BoundingRectangle)) */ var overlappingGroupIndexes = new List<int>(); @@ -847,7 +851,8 @@ namespace UVtools.Core.Managers { if (resinTrapGroups[groupIndex].Last().layerIndex != layerIndex + 1) continue; - if (EmguContours.ContoursIntersect(resinTrapGroups[groupIndex].Last().contour, resinTraps[layerIndex][x])) + if (EmguContours.ContoursIntersect(resinTrapGroups[groupIndex].Last().contour, + resinTraps[layerIndex][x])) { overlappingGroupIndexes.Add(groupIndex); } @@ -881,6 +886,7 @@ namespace UVtools.Core.Managers } } } + //} }); /* anything that converted to a suction trap needs to removed from resinTraps. Loop backwards so indexes don't shift */ |