query_pixelbuffer#
- ensight.query_pixelbuffer(x: int, y: int, x2: int = 2147483647, y2: int = 2147483647, parts_only: int = 0, deep_part_check: int = 0) List[Any] #
Find the EnSight objects under a point or for all the points in a rectangle.
This method allows the caller to probe the rendered pixel buffer and determine which EnSight objects are visible at a point or within a rectangle of pixels. The x and y coordinates within the rendering window must be specified in pixels.
0, 0
is the lower left corner of the window.ensight.objs.core.WINDOWSIZE[0]-1, ensight.objs.core.WINDOWSIZE[1]-1
is the upper-rightmost pixel. Specifying a rectangle of pixels is done by including x2 and y2 keyword arguments. Note that 2147483647 is treated as “undefined” for x2 and y2.The method can work in two ways, “Object mode” or “Part mode”. Object mode is selected by only passing the x and y single pick point and no other options. In this mode, the returned value is a list of lists. For example:
[[partobj, [x,y,z]], [partobj, [x,y,z]], [annotobj, [x,y,z]]]
For a part, the x,y,z coordinates are the location on the part in model space. For a 2D object like an annotation, x and y are the normalized screen coordinates and z is the normalized front clip plane. Note, this operation can be slow if a rectangle is specified.
Part mode is selected by specifying
parts_only=1
ordeep_part_check=1
. In part mode, the return value is a simple list of ENS_PART objects. This is normally done by interrogating the rendered pixels for the target parts. If deep_part_check is 1, it is computed by intersecting the geometry with the point or rectangle. This can pick parts hidden behind other parts.- Args:
- x:
The x position of the pixel to query (or a corner if x2 and y2 are specified).
- y:
The y position of the pixel to query (or a corner if x2 and y2 are specified).
- x2:
The x position of the other corner of the rectangle to query.
- y2:
The y position of the other corner of the rectangle to query.
- parts_only:
If set to 1, only x2 and y2 cannot be specified and the return value will be restricted to ENS_PART objects only. Note: no x,y,z location will be included in the return value if the option is selected.
- deep_part_check:
If set to 1, the returned set of ENS_PART objects will not be limited to the first part object hit in depth. Use this option if you want to return parts that might be occluded by parts that are closer to the viewer. Note: no x,y,z location will be included in the return value if the option is selected.
- Returns:
A list of objects that would be intersected by passing rays from the viewer though the selected pixel or block of pixels. The return value may or may not include the x,y,z coordinates (in data space) of the intersection.