In converting your 3D model to a set of points, you have thrown away the information required to find the intersection shapes. Walk the edge-face connectivity graph of your 3D model to find the edge-plane intersection points in order.
Assuming you have, or can construct, the 3d model topography (some number of vertices, edges between vertices, faces bound by edges):
- Iterate through the edge list until you find one that intersects the test plane, add it to a list
- Pick one of the faces that share this edge
- Iterate through the other edges of that face to find the next intersection, add it to the list
- Repeat for the other face that shares that edge until you arrive back at the starting edge
You've built an ordered list of edges that intersect the plane - it's trivial to linearly interpolate each edge to find the intersection points, in order, that form the intersection shape. Note that this process assumes that the face polygons are convex, which in your case they are.
If your volume is concave you'll have multiple discrete intersection shapes, and so you need to repeat this process until all edges have been examined.
There's some java code that does this here, and a rather nifty test application here.
Controls:
- 1-5 to change the test volume
- q and w to alter the number of query planes
- a, s, and d to alter the scan speed of the query planes
- left-click-drag to rotate the view
- right-click-drag to rotate the query planes
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…