Cube intersect point cloud

  3d, c++, geometry, math, point-cloud-library

I have a set of point clouds and a cube that cuts a mesh, I would like to know the math behind or the way to get the points that intersect that cube or plane.

similar to the following figure
enter image description here

Source: Windows Questions C++