Page 1 of 1

BUG! in Shape.isInside

Posted: Wed Oct 20, 2021 10:35 am
by ebrahim raeyat
to produce:

Code: Select all

l = Part.Line(App.Vector(0, 0, 0), App.Vector(1, 0, 0))
e = Part.Edge(l)
p = App.Vector(2, 0, 0)
e.isInside(p, .1, True)
It must be False, but it is True. Thanks.

Code: Select all

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)

Re: BUG! in Shape.isInside

Posted: Sat Oct 23, 2021 4:25 am
by ickby
It is not a bug. A part line is a geometric object describing a line, hence is of infinite length. The two points you give to the constructor are two points it oaases through. Hence the edge you created like this is also infinite, and hence the point you check for is on the edge. You can see that the edge is like this by checking its length and it's vertexes (it hasn't any)

To make a finite edge you need to either pass the lines parametric coordinate range you want to use to the constructor Part.Edge(l, 0, 1) or use Part.LineSegment, which is a finite geometric entity by default.

Re: BUG! in Shape.isInside

Posted: Sat Oct 23, 2021 11:22 am
by ebrahim raeyat
ickby wrote: Sat Oct 23, 2021 4:25 am It is not a bug. A part line is a geometric object describing a line, hence is of infinite length. The two points you give to the constructor are two points it oaases through. Hence the edge you created like this is also infinite, and hence the point you check for is on the edge. You can see that the edge is like this by checking its length and it's vertexes (it hasn't any)

To make a finite edge you need to either pass the lines parametric coordinate range you want to use to the constructor Part.Edge(l, 0, 1) or use Part.LineSegment, which is a finite geometric entity by default.
Thanks, but it does not matter what is the point or finite or infinite, it gives me True in all cases, can you please test it?

Code: Select all

>>> import Part
>>> l = Part.LineSegment(App.Vector(0, 0, 0), App.Vector(1, 0, 0))
>>> e = Part.Edge(l)
>>> p = App.Vector(2, 0, 0)
>>> e.isInside(p, .1, True)
True
>>> p = App.Vector(2, 1, 0)
>>> e.isInside(p, .1, True)
True
>>> 

Re: BUG! in Shape.isInside

Posted: Sat Oct 23, 2021 11:57 am
by ickby
Ah ok i only checked the initial example... That is strange. I'm not at my pc for a few days, so unfortunately cannot dig for the reason.

But maybe the problem lies also with the edge itself: I think a edge cannot be infinite by definition, and the fact that it has no vertexes may hint to an invalid edge. Maybe that is something to check.

Re: BUG! in Shape.isInside

Posted: Sat Oct 23, 2021 1:58 pm
by wmayer
Internally the class BRepClass3d_SolidClassifier is used.

When looking at the class interface it accepts everywhere a TopoDS_Shape and doesn't enforce a TopoDS_Solid as one would assume according to the class name.

Doing some tests it works as expected for:

solids

Code: Select all

box=Part.makeBox(1,1,1)
box.isInside(App.Vector(1,1,1), 0.01, True) # => True (OK)
box.isInside(App.Vector(1,1,1.1), 0.01, True) # => False (OK)
and faces

Code: Select all

face = Part.Face(Part.Plane())
face.isInside(App.Vector(0,0,0), 0.01, True) # => True (OK)
face.isInside(App.Vector(0,0,0.1), 0.01, True) # => False (OK)
but not for edges or vertexes. So, I am not sure for which shape types it is supposed to work.

Re: BUG! in Shape.isInside

Posted: Sat Oct 23, 2021 2:39 pm
by wmayer

Re: BUG! in Shape.isInside

Posted: Sat Oct 23, 2021 7:31 pm
by ebrahim raeyat
wmayer wrote: Sat Oct 23, 2021 2:39 pm git commit 398381c16e
Thanks wmayer.

Re: BUG! in Shape.isInside

Posted: Sat Dec 04, 2021 3:08 am
by MRx
Hi,

seems like there's another bug here.
cQn2x6.png
cQn2x6.png (7.24 KiB) Viewed 4303 times
isInside returns true for both the inside and the outside Vertex.

Code: Select all

>>> Gui.Selection.getSelectionEx()[0].SubObjects[0].isInside(FreeCAD.Vector(213.546,-27.3265,-3.3), 0.005, True)
True <<-- should be false
OS: macOS 10.15
Word size of FreeCAD: 64-bit
Version: 0.20.26549 (Git)
Build type: Release
Branch: master
Hash: 92a8e0e3d8f3845e5007f95f4c94bf1c83f50ff6
Python version: 3.9.0
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.0
Locale: English/Germany (en_DE)