I am currently working on a script where I would like to determine if a point is on a face. Edges and Faces have the ability to perform projection efficiently using ParamAtPoint and PointAtParam, however it is possible for these projections to be created off of the face.
Right now I am performing a check using Ray Casting, but as soon as I put the code into a loop to check multiple points it quickly becomes unusable as it takes too long per iteration. The ray casting code looks like this:
`def check_if_point_is_on_face(point, face):
face_param = face.ParamAtPoint(point)
normal_vec = face.NormalAtParam(*face_param)
inward_vec = -Vector3D(*normal_vec)
shifted_point = shift_point_along_unit_vector(point, normal_vec, 0.001)
a_point = Point(list(shifted_point), 'm')
a_bound_vector = Ansys.Mechanical.Math.BoundVector(a_point, inward_vec)
cast_settings = Ansys.Mechanical.Selection.GeometryRayCastSettings()
cast_settings.MaxHits = 1
geom_hit = Ansys.Mechanical.Selection.SelectionHelper.CastRayOnGeometry(a_bound_vector, cast_settings)
if len(geom_hit) == 1:
if geom_hit[0].Entity.Id == face.Id:
return True
return False`
Any help to either understand how to make Ray Casting "Faster" or how to check whether a PointAtParam is actually on a face would be greatly appreciated!