I've met the same problem some time ago. I needed to make a thin relief on a large wood board which is slightly warped. The relief hieght was 0.6 mm while the heights of board corners differ by more than 1.5 mm.
We need to scan the surface and fit the toolpath on this surface to get a modified toolpath for actual machining.
The straight way is to get a point cloud, convert it to a surface (such as stl file, in MeshLab or so), import it into ArtCam and get a composite relief, then redo the toolpath. It looks too complex - our machine operators would prefer a single-click procedure.
I couldn't found any suitable solution after comprehensive search in internet, so I decided to make the program by myself. Once complete, the result was perfect!
Bad news that I cannot share it for now (I'm bound with an agreement) but there's a small chance we will distribute it later for a small fee.
Now I can just present the general ideas.
First, I get a "height map" of a surface by means of a contact probe and Mach3's Digitizing Wizard. I get an array of Z values in a rectangular grid. The steps may be large comparing to that for common 3D scanning - say, a few inches, depending on the curvature of the surface.
Next, the program reads this file and fills the internal XY matrix with Z values. The most tricky task is to get the steps by X and Y and the grid dimensions by analyzing the XY pairs. Also, I need to define the "base point" where the correction must be zero - this is the point where I will set the tool height. Having set it, I calculate the Z for this point and subtract it from every Z value in the matrix.
Finally, I read the existing G-Code files and modify them (actually I make copies) so that the Z coordinates would change according to the surface.
For each given point, I find the 3 nearest points frim the grid, build a plane through these points and get the Z coordinate for the required point. These are common math which can be easily found in any handbook on computational geometry. The modification itself is performed line by line by simple string substitution - it there is any Z in a line, it's replaced; if there is no Z but any of X or Y exists, the Z is appended.
Please feel free to ask questions if anyone will try to implement something of this kind.