pysdic.compute_visibility#

compute_visibility(mesh, integration_points, camera, *, warp_by=None, tolerance=None)[source]#

Check which integration points of a 3D surface mesh are visible by a camera.

A point is visible if:

  1. it is located in the mesh and its projection is in the domain of the centers of the pixels, \(x \in [0, W - 1]\) and \(y \in [0, H - 1]\), where the image can be interpolated (for a pysdic.View, its gray level must also be finite, i.e. in the ROI of the image);

  2. it is not hidden by the mesh: the first intersection of the ray of the camera through the point (computed with the extrinsic transformation only, see below) with the mesh is not before the point, up to tolerance.

The ray is obtained without the distortion and the intrinsic transformation: the point is mapped to its normalized point by the extrinsic transformation, and the ray of the extrinsic transformation through this normalized point (extrinsic.compute_rays) passes exactly through the point. The first intersection of the ray with the deformed mesh (see pysdic.Mesh.cast_rays()) is compared with the point: the point is hidden if the intersection is closer to the origin of the ray. A ray missing the mesh (possible for a ray exactly on an edge of the triangles used by Open3D) hides nothing. The points behind the camera are not visible (their ray does not pass through them).

Note

This function is a safeguard, not called by the operators of the SDIC: check the visibility of the integration points before building a term, and remove the hidden ones.

Important

Requires the optional package open3d (pip install open3d), a 3D surface mesh and a camera with 3D world points.

Parameters:
  • mesh (pysdic.Mesh) – The 3D surface mesh (with an element type).

  • integration_points (pysdic.IntegrationPoints) – The points to check, consistent with the mesh.

  • camera (Union[pysdic.Camera, pysdic.View]) – The camera, or a view (its camera and the ROI of its image).

  • warp_by (Optional[Union[str, ArrayLike]], optional) – The displacement of the vertices (name of a vertex property or array of shape \((N_v, 3)\)), e.g. the displacement of a frame of an analysis.

  • tolerance (Optional[Real], optional) – The margin on the distances along the ray: the point is hidden if the first intersection is closer than the point by more than tolerance. Also the maximum distance between the point and its ray. By default, \(10^{-6}\) times the diagonal of the bounding box of the (deformed) vertices.

Returns:

A boolean array of shape \((N_p,)\), True for the visible points.

Return type:

numpy.ndarray

Raises:
  • TypeError – If an input has a wrong type.

  • ValueError – If the mesh is not a 3D surface mesh, the points are not consistent with the mesh, or the camera does not use 3D world points.