# Fixing Mesh Problem

Hello,
I have been trying to build a Grasshopper network that allows me to:

• Input a shape;
• Slice it by a plane such that the volume beneath the plane is 50% of the total volume;
• Rotate the object in 3D while keeping the 50% thing.

I was able to do that, but sometimes I encounter a problem I think related to the mesh:

1. This is an example where the mesh works:

2. This is an example where the mesh fails:

The program was supposed to give me two slices (upper and lower) but it is not working.

Files are attached.

I appreciate the help.

Thanks.
Fixing mesh problem.3dm (32.5 KB)
Fixing Mesh Problem.gh (32.3 KB)

Hi!
Your problem is the fact that you are trying to cut a mesh exactly alongside a loop of edges, so you are trying to “split in half” a lot of edges and vertexes…

This happens because you have a box with 10 faces as height, and splitting it exactly at half will result in a cutting plane exactly between 5th and 6th face, and there rhino go crazy.

Simple workaround: use a 11-face box.
11 is a prime number, it’s very unlikely you’ll encounter the same situation again…
Fixing Mesh Problem re.gh (22.5 KB)

Consider this:

Thanks for the reply and help.

I guessed it had to do with that, and I used to increase the faces to solve it for the cube.

However, the cube is only an example but I aim to put much more complex shapes. So there is a general way to solve the problem?

What are you after is called bounce solving. See attached as an entry level take on that matter.

Recursion_BounceTramboline_V2.gh (126.6 KB)

Looks like this previous discussion might be relevant

Hello Daniel, thanks for the reply.
I am actually experiencing the mesh problem with that network you created earlier.
It was extremely helpful, but the mesh problem always messes some values, and I am not able to correct it.

Thanks a lot!

Thanks a lot. I opened the code, and I am fully confused about it since I do not know C#
Does this code only work for cubes?

As you can see from the test Mesh … it works with any Mesh that is closed and valid (a manifold test is rather required as well). It could (with some lines more) work with any GeometryBase Type that is either a Mesh or a Brep (auto converted to Mesh). Obviously if the Mesh has 1Z Vertices … it’s a bit slow. In fact it could work with any Brep as well (but would be way slower - most notably if the Brep is a complex “blob”).

Notify if you want to work with Mesh Lists (a few mods are required for that).

BTW: You don’t need to know anything about C# mind.