Recently I am working as a data scientist at a start-up company in Washington D.C. metro area. Our company is doing new generation manufacturing which involves CNC machining and 3-D Printing.
Customers upload CAD files of the parts they want to build and we (develop team) wrote an engine analyzing the geometry features of the parts and using those geometry variables to predict the quote pricing(which also involves machine learning at certain point).
One big issue is to find parts that contains unmachinable corners (those corners with an infinite radius) and hidden surfaces (surfaces cannot be reached by either the bottom or the side of the machining tools).
To find those unmachinable features, we have to find invisible sides from all the directions. So hidden surface removal is playing an important role.
For the need of quick implement, we referred to the paper: Direct Visibility of Points Sets, which is really a quick and dirty way and works for most of the time. However,
this method would result in false positives at inner corner regions so are “diminished” by the visible and side points by threshold.
So I am currently implement other algorithms which enables the GPU working, such as simple ray tracing which is also called ray casting and z buffering. Here I wanna make a summary on all these visible surface determination algorithms I have learned about recently.
First of all, there are generally two types of approaches:
- Object precision (space)
Algorithms do their work on the objects themselves before they are converted to pixels in the frame buffer. The resolution of the display device is irrelevant here as this calculation is done at the mathematical level of the objects
Seudocode:
for each object a in the scene
determine which parts of object a are visible
(involves comparing the polyons in object a to other polygons in a
and to polygons in every other object in the scene)
- Image precision (space)
Algorithms do their work as the objects are being converted to pixels in the frame buffer. The resolution of the display device is important here as this is done on a pixel by pixel basis.
Seudocode:
for each pixel in the frame buffer
determine which polygon is closest to the viewer at that pixel location
colour the pixel with the colour of that polygon at that location
In most game development cases, the visible surface determination uses the method of image precision which relies on the pixels. However, I think in our manufacturing purpose implementation, we have to do it in object precision.
Object VS. Image Precision
Object Space Algorithms
- Operate on geometric primitives
- For each object in the scene, compute the part of it which isn’t obscured by any other object
- Must perform tests at high precision
- Resulting information is resolution-independent
Complexity
- Must compare every pair of objects, so O(n2) for n objects
- For an m∗m display, have to fill in colors for m2 pixels
- Overall complexity can be O(kobjn2+kdispm2)
- Best for scenes with few polygons or resolution-independent output
Implementation
- Difficult to implement
- Must carefully control numerical error
Image Space Algorithms
- Operate on pixels
- For each pixels in the scene, find the object closest to the COP which intersects the projector through that pixel, them draw
- Perform tests at device resolution, result works only for that resolution
- Complexity
- Naive approach checks all n objects at every pixel, then O(nm