BUG! in Shape.isInside

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Post Reply
User avatar
ebrahim raeyat
Posts: 494
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

BUG! in Shape.isInside

Post 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)
ickby
Veteran
Posts: 3099
Joined: Wed Oct 05, 2011 7:36 am

Re: BUG! in Shape.isInside

Post 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.
User avatar
ebrahim raeyat
Posts: 494
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: BUG! in Shape.isInside

Post 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
>>> 
ickby
Veteran
Posts: 3099
Joined: Wed Oct 05, 2011 7:36 am

Re: BUG! in Shape.isInside

Post 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.
wmayer
Founder
Posts: 17912
Joined: Thu Feb 19, 2009 10:32 am

Re: BUG! in Shape.isInside

Post 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.
wmayer
Founder
Posts: 17912
Joined: Thu Feb 19, 2009 10:32 am

Re: BUG! in Shape.isInside

Post by wmayer »

User avatar
ebrahim raeyat
Posts: 494
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: BUG! in Shape.isInside

Post by ebrahim raeyat »

wmayer wrote: Sat Oct 23, 2021 2:39 pm git commit 398381c16e
Thanks wmayer.
MRx
Posts: 287
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: BUG! in Shape.isInside

Post by MRx »

Hi,

seems like there's another bug here.
cQn2x6.png
cQn2x6.png (7.24 KiB) Viewed 669 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)
Attachments
isInsideBug.FCStd
(163.76 KiB) Downloaded 17 times
Post Reply