-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix BoundBox.is_inside
#828
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #828 +/- ##
=======================================
Coverage 96.09% 96.09%
=======================================
Files 24 24
Lines 8493 8493
=======================================
Hits 8161 8161
Misses 332 332 ☔ View full report in Codecov by Sentry. |
is "A is inside B" supposed to mean "B fully encloses A" or "A and B are overlapping"? edit: build123d/src/build123d/geometry.py Lines 1004 to 1005 in c0728e0
build123d/src/build123d/topology.py Lines 1350 to 1351 in c0728e0
build123d/src/build123d/topology.py Lines 6790 to 6793 in c0728e0
so basically The bounding box method does look more like an overlap test than a
|
@snoyer Putting aside the other With that in mind I agree that the current implementation in this PR should be renamed to EDIT: New proposed behavior bboxA.overlaps(bboxB) == bboxB.overlaps(bboxA) #i.e. they are always equivalent
bboxA.contains(bboxB) != bboxB.contains(bboxA) #i.e. they are never equivalent even if bboxA and bboxB are coincident I am open to input on the latter behavior as this is the most strict implementation. |
Assuming you mean bbox(A,B).contains(bbox(A,B)) == True # box contains itself
bbox(A,B).contains(bbox(A)) == True # box contains [the box of] any of its points
bbox(A,B).contains(bbox(B)) == True The same could be done for the overlapping to have: bbox(A,B).overlaps(B,C) == True # boxes have a common corner |
@snoyer Maybe this should be controllable by a boolean flag? It can be useful to differentiate these assumptions in practice when e.g. writing lambdas for filtering purposes. bboxA.contains(bboxA, inclusive=True) == True
bboxA.contains(bboxA, inclusive=False) == False and also: # when e.g. bboxB shares a corner, edge, or face with bboxA
bboxA.overlaps(bboxB, inclusive=True) == True
bboxA.overlaps(bboxB, inclusive=False) == False Is there a better name for the flag than |
could flip the boolean value and call it If you really need to have both versions of filter(mybox.contains_strictly, other_boxes) vs filter(lambda b: mybox.contains(b, inclusive=False), other_boxes) or filter(partial(mybox.contains, inclusive=False), other_boxes) Obviously this is all subjective API design choices and @gumyr's opinion would be more important than mine :) |
@snoyer Yeah I agree we need @gumyr to weigh in -- this PR discussion has grown a lot in scope from when it was simply trying to fix a broken method. I personally do not like having 4 separate methods for this, I prefer 2 methods with the flags with the I am convinced that having the effect of inclusive True/False is a useful distinction and should be available. Regardless I am not sure anyone has even tried to use the existing method given the bug that I discovered -- so at some point it is better to just move on to more important issues and add these small fixes/enhancements. |
The current assumption in the code is that objects on the edge of another object are "inside" it. Internally these two can be separated: solid_classifier.State() == ta.TopAbs_IN or solid_classifier.IsOnAFace() but I didn't see the value in that. However, I'm happy to have them separate if that's helpful. I like the proposed |
Regardless of which one(s) you decide to implement in
|
The old comparison was not working correctly per issue #827 so I fixed that and added a test that returns False too. This fixes issue #827.