Hi FreeCAD Forumer
I'm looking for and good and efficient answer to the subject question
In my first approach by using vertex.distToSHape(face) a good solution was found :
*** TEST distToShape | face_name:Face45 | dist:(2.595767256003112e-05, [(Vector (-22.0812, -11.1074, 16.2178), Vector (-22.08122421877031, -11.107390659125876, 16.2178))], [('Vertex', 0, None, 'Face', 0, (4.330483527529996, -9.762040895517398))])
The code work fine in Windows7.FreeCAD 0.17 ,,, but ,,, in Ubuntu.FreeCAD 0.18 the result is different :
*** TEST I distToShape | face_name:Face45 | dist:(3.1644938021069278, [(Vector (-22.0812, -11.1074, 16.2178), Vector (-23.2199680025423, -14.0598952938081, 16.2178))], [('Vertex', 0, None, 'Edge', 1, 9.762040895517398)])
May be shape.distToShape(shape) was changed ...
so the question is : is there a way to make distToShape return the entity 'Face' as the old implementation ?
... or is there a way to detect if a point is on face ?
Thank you
Cristian
Is Point on Face ?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- cristian.a73
- Posts: 41
- Joined: Wed Jul 18, 2018 4:15 pm
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Is Point on Face ?
How about myFace.isInside(myPoint, tolerance, true)?cristian.a73 wrote: ↑Sat Oct 13, 2018 11:10 am ... or is there a way to detect if a point is on face ?
"isInside"
- Checks whether a point is inside or outside the shape. isInside(App.Vector, float, Boolean) => Boolean
The App.Vector is the point you want to check if it's inside or not
float gives the tolerance
Boolean indicates if the point lying directly on a face is considered to be inside or not
- cristian.a73
- Posts: 41
- Joined: Wed Jul 18, 2018 4:15 pm
Re: Is Point on Face ?
Thank you wandererfan for yout suggestion, it was my very first method...wandererfan wrote: ↑Sat Oct 13, 2018 12:40 pm How about myFace.isInside(myPoint, tolerance, true)?
"isInside"
- Checks whether a point is inside or outside the shape. isInside(App.Vector, float, Boolean) => Boolean
The App.Vector is the point you want to check if it's inside or not
float gives the tolerance
Boolean indicates if the point lying directly on a face is considered to be inside or not
... the proble is isInside doesn't work as apsected : see the log :
Code: Select all
>>> p2 = FreeCAD.Vector(112.216,115.785,10.7989)
>>> vx2 = Part.Vertex(p2)
>>> f.isInside(p2, 0.1, True)
False
>>> vx2.distToShape(f)
(0.00288570504590466, [(Vector (112.216, 115.785, 10.7989), Vector (112.21469374568731, 115.785, 10.79632687091607))], [('Vertex', 0, None, 'Face', 0, (0.7778714902086804, 143.14689910059903))])
a point may be inside the shape, or on the shape's faces, but out of the target face
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Is Point on Face ?
then, use f.Faces[index_of_your_target_face].isInside(…)cristian.a73 wrote: ↑Sat Oct 13, 2018 1:07 pm point may be inside the shape, or on the shape's faces, but out of the target face
- cristian.a73
- Posts: 41
- Joined: Wed Jul 18, 2018 4:15 pm
Re: Is Point on Face ?
thank you but it doesn't work :
Code: Select all
>>> vx2.distToShape(f)
(0.00288570504590466, [(Vector (112.216, 115.785, 10.7989), Vector (112.21469374568731, 115.785, 10.79632687091607))], [('Vertex', 0, None, 'Face', 0, (0.7778714902086804, 143.14689910059903))])
>>> f.Faces[0].isInside(vx2.Point, 0.1, True)
False
>>> f.Faces
[<Face object at 14BF9488>]
Code: Select all
>>> vx2.distToShape(obj.Shape.Faces[3])
(0.00288570504590466, [(Vector (112.216, 115.785, 10.7989), Vector (112.21469374568731, 115.785, 10.79632687091607))], [('Vertex', 0, None, 'Face', 0, (0.7778714902086804, 143.14689910059903))])
>>> obj.Shape.Faces[3].isInside(vx2.Point, 0.1, True)
False
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Is Point on Face ?
I tried, and it appeared to work. But then I tried checking if it respects tolerance, and it looks like it doesn't.
My face lies on XY plane, and covers the origin. I tried raising the point (increase Z). And only if Z is < 1e-12, it returned True. Both argument tolerance and shape tolerance are ignored. 1e-12 is a value known as Presicion::Angular in opencascade, btw.
- cristian.a73
- Posts: 41
- Joined: Wed Jul 18, 2018 4:15 pm
Re: Is Point on Face ?
May be different implementation give discontinuous results...i've tested it on windows 0.17 and ubuntu 0.18 on a bspline surfaceDeepSOIC wrote: ↑Sat Oct 13, 2018 6:57 pm I tried, and it appeared to work. But then I tried checking if it respects tolerance, and it looks like it doesn't.
My face lies on XY plane, and covers the origin. I tried raising the point (increase Z). And only if Z is < 1e-12, it returned True. Both argument tolerance and shape tolerance are ignored. 1e-12 is a value known as Presicion::Angular in opencascade, btw.