I wrote an application to display tiff georeferenced where you can project misc other object, like polygons, lines, points. The idea is to find which squares of the heightfiled touched by the object you want to project (for lines and triangles).

For triangles i find the contours, then i use the osgUtil::Tesselator and use the mode equal 2 it’s like a And between 2 polygons. Then for the center of the triangle not touch by the contours i generate a quads from the heightfield directly. An improvement should be to replace the osgUtil::Tesselator by an efficient specialized clipper triangle/square
For lines it’s easy i just need to intersect each grid boundary with the line then i sort the result and project each interesection points to the corresponding triangle from the good square.
For points i just select to good square and the good triangle and i project on that triangle.
You can have a look to the code