Computes the intersections between the provided line and the faces of this Shape :param point: Base point for defining a line :param axis: Axis on which the line rests :param tol: Intersection tolerance :param direction: Valid values: "AlongAxis", "Opposite"
(
self,
point: VectorLike,
axis: VectorLike,
tol: float = 1e-4,
direction: Literal["AlongAxis", "Opposite"] | None = None,
)
| 1461 | return self._bool_op((self,), toIntersect, intersect_op) |
| 1462 | |
| 1463 | def facesIntersectedByLine( |
| 1464 | self, |
| 1465 | point: VectorLike, |
| 1466 | axis: VectorLike, |
| 1467 | tol: float = 1e-4, |
| 1468 | direction: Literal["AlongAxis", "Opposite"] | None = None, |
| 1469 | ) -> list[Face]: |
| 1470 | """ |
| 1471 | Computes the intersections between the provided line and the faces of this Shape |
| 1472 | |
| 1473 | :param point: Base point for defining a line |
| 1474 | :param axis: Axis on which the line rests |
| 1475 | :param tol: Intersection tolerance |
| 1476 | :param direction: Valid values: "AlongAxis", "Opposite"; |
| 1477 | If specified, will ignore all faces that are not in the specified direction |
| 1478 | including the face where the point lies if it is the case |
| 1479 | :returns: A list of intersected faces sorted by distance from point |
| 1480 | """ |
| 1481 | |
| 1482 | oc_point = ( |
| 1483 | gp_Pnt(*point.toTuple()) if isinstance(point, Vector) else gp_Pnt(*point) |
| 1484 | ) |
| 1485 | oc_axis = ( |
| 1486 | gp_Dir(Vector(axis).wrapped) |
| 1487 | if not isinstance(axis, Vector) |
| 1488 | else gp_Dir(axis.wrapped) |
| 1489 | ) |
| 1490 | |
| 1491 | line = gce_MakeLin(oc_point, oc_axis).Value() |
| 1492 | shape = self.wrapped |
| 1493 | |
| 1494 | intersectMaker = BRepIntCurveSurface_Inter() |
| 1495 | intersectMaker.Init(shape, line, tol) |
| 1496 | |
| 1497 | faces_dist = [] # using a list instead of a dictionary to be able to sort it |
| 1498 | while intersectMaker.More(): |
| 1499 | interPt = intersectMaker.Pnt() |
| 1500 | interDirMk = gce_MakeDir(oc_point, interPt) |
| 1501 | |
| 1502 | distance = oc_point.SquareDistance(interPt) |
| 1503 | |
| 1504 | # interDir is not done when `oc_point` and `oc_axis` have the same coord |
| 1505 | if interDirMk.IsDone(): |
| 1506 | interDir: Any = interDirMk.Value() |
| 1507 | else: |
| 1508 | interDir = None |
| 1509 | |
| 1510 | if direction == "AlongAxis": |
| 1511 | if ( |
| 1512 | interDir is not None |
| 1513 | and not interDir.IsOpposite(oc_axis, tol) |
| 1514 | and distance > tol |
| 1515 | ): |
| 1516 | faces_dist.append((intersectMaker.Face(), distance)) |
| 1517 | |
| 1518 | elif direction == "Opposite": |
| 1519 | if ( |
| 1520 | interDir is not None |