# 3D OBJECT SLICING ALGORITHM

Hi all,

I need to perform 3D objects slicing, as is shown on image gray object will be sliced depending on blue plane position, in some cases front plane side will remain in others back plane side will remain of gray object. To simplify the scene I used cube and plane but my real scene objects and slicing plane might be a bit more complex.

Any algorithm to perform this will be appreciated.

Regards,

I would do the following:
for each triangle in the triangle mesh:

• find out how many points of the triangle are on the visible side
• if there are no points on the visible side:
• ignore this triangle
• if there is one point on the visible side:
• find the intersection points of the two lines that connect the visible point with the invisible ones with the cutting plane
• add the triangle that is defined by the visible point and the intersection points to the new mesh
• if there are two points on the visible side:
• find the intersection points of the two lines that connect the invisible point with the visible ones with the cutting plane
• add the triangle that is defined by the first visible point and the two intersetion points to the new mesh
• add the triangle that is defined by both visible points and the intersection point belonging to the second visible point to the new mesh
• if there are three points on the visible side:
• copy this triangle to the new mesh

this will give you the cut open mesh half on the visible side. if you want the mesh to be closed where the plane cut it, you need to:
add all intersection points into a list, keeping track of the pairs (you always get either no or two intersection points)
order that list in counter-clockwise direction without changing the pairs (x)
triagonalize the created polygons
add the new triangles to the triangle list

x:
randomly pick one of the points from the pairs (A)
add it to a point list
add the one who is in a pair with this point (B)
search all remaining pairs for one starting with point B and add the second point in that pair © to the list
search all remaining pairs for one starting with point C and add the second point in that pair (D) to the list

no points left? you’re done.
points left, but you already reached the point you randomly picked in the beginning? randomly pick another point and start again.

that’s basically connecting a lot of small lines to one or more polylines. the area inside those polylines are the polygons you have to triagonalize in the next step.

I hope that’s understandable and helps

glitch here is that :gray object’s not a mesh here it’s tesselated polygon?

Any suggestion?

I’m not sure whether I understand you correctly, what kind of data do you have that you could work with on your CPU?

sorry I wasn’t verbose

for gray object, base contours/polygon vertex data

for plane, vertex data

If it’s a polygon, then it can be split up into triangles so you could just use the algorithm I posted above.
Or is it a polygon and you map a function, texture, whatever onto it and thereby change its “height” (called displacement mapping, if I remember correctly)?