<p>It might be a bit of an overkill, but you could use spatial partitioning, such as Octrees. </p>

<p>Once you have it built, you can start evaluating partitions, given a max depth level of your choice, and form bounding volumes with the vertices inside each partition.</p>

<p>You can test all of your shapes for each partition and choose the one that approximates the best all vertices you are enclosing in it (you can measure this by, for example, the volume which, while enclosing all vertices, takes up the less volume).</p>

<p>PS: I've never tried anything like this, is purely theoretical</p>

CC BY-SA 3.0
2018-04-11T23:36:27.537Z
2018-04-11T23:36:27.537Z
Nadir
<p>I have a complex geometry mesh object, which is an irregular shape.</p>

<p>I want to redraw that complex geometry mesh object using multiple simple primitive shapes.</p>

<p>For example, I want to use cuboid, sphere and cylinder to represent a complex geometry mesh object.</p>

<p>I am given only the vertices points, triangular of that complex geometry mesh.</p>

<p>How do I decompose the geometry shape into cuboid, sphere, cylinder.</p>

<p>Please ask if you need details.
Thank you.</p>

CC BY-SA 3.0
2018-04-11T14:24:56.737Z
You can't necessarily decompose a mesh into cuboids, spheres, and cylinders. You can decompose it into triangles, though.
Dan Hulme
CC BY-SA 3.0
2018-04-11T14:42:14.520Z
@DanHulme, why I cannot decompose mesh into cuboids, spheres, cylinder?
user2150279
CC BY-SA 3.0
2018-04-11T15:11:38.007Z
Because not all solids can be expressed as the union of finitely many cuboids, spheres, and cylinders.
Dan Hulme
<mesh>
How to decompose a complex mesh to simple geometry shape programmatically?
user2150279
# How to decompose a complex mesh to simple geometry shape programmatically?

(Asked by: username_0 on 2018-04-11)

I have a complex geometry mesh object, which is an irregular shape.

I want to redraw that complex geometry mesh object using multiple simple primitive shapes.

For example, I want to use cuboid, sphere and cylinder to represent a complex geometry mesh object.

I am given only the vertices points, triangular of that complex geometry mesh.

How do I decompose the geometry shape into cuboid, sphere, cylinder.

Please ask if you need details.
Thank you.

**Tags:** mesh

> **Comments:**
> **username_1**: You can't necessarily decompose a mesh into cuboids, spheres, and cylinders. You can decompose it into triangles, though.  
> **username_0**: @username_1, why I cannot decompose mesh into cuboids, spheres, cylinder?  
> **username_1**: Because not all solids can be expressed as the union of finitely many cuboids, spheres, and cylinders.  

---

## 1 answers

### Answer by username_2 on 2018-04-11. Score: 2

It might be a bit of an overkill, but you could use spatial partitioning, such as Octrees.

Once you have it built, you can start evaluating partitions, given a max depth level of your choice, and form bounding volumes with the vertices inside each partition.

You can test all of your shapes for each partition and choose the one that approximates the best all vertices you are enclosing in it (you can measure this by, for example, the volume which, while enclosing all vertices, takes up the less volume).

PS: I've never tried anything like this, is purely theoretical


---

