# Shrink Wrap with Kangaroo

Hello,samplewrap.3dm (6.5 MB)

1.gh (41.5 KB)
2.gh (37.5 KB)

I am new to Grasshopper and I am struggling with shrink wrapping object. If someone can help me with this issue, it would be great! Since I do not know how to write my own definition, I found two definitions that gives me the result that looks close but they all still have some problems. In the image I attached, the one on the very left is closest to what I want although I need the edges to be sharper. And that is what was included in the Rhino file that I downloaded from Forum with the definition. However, when I use the same definition ([1.gh) and bake it, the middle one in the image is what I am getting which is way too tensile. And I also found another definition (2.gh) and I could get the result on the very right. This one on the other hand is not tensile at all but I could get sharp edges. Since I am completely new to Grasshopper, I could not figure out the problems. If someone knows how to solve it, please let me know! @laurent_delrieu

Thank you very much

shrinkwrap_sharp.gh (24.2 KB)

Here’s a go at this with the current Kangaroo, also using MeshEdit to make the convex hull to start with and Weaverbird.
It’s still not perfect - edges that are part of the input geometry and the convex hull stay crisp, but it can still end up rounding other edges inside as it shrinks.
I’d like to improve this, but I think it will need some slightly different way of finding the collisions, and/or remeshing while shrinking.

8 Likes

this is very cool Daniel, I noticed that the convex edged that stay crisp are also the ones that have a row of points (red) along them, and the ones that get ‘eroded’ or undefined are the ones that do not have these points. I’m not familiar with Kangaroo yet, is this a solver problem or an input problem?

1 Like

The remeshing step after taking the convex hull can keep sharp the mesh edges which are on sharp edges of the hull. Then in the relaxation these points can be kept on those edges.

However, as the mesh shrinks it can collide with new parts of the solid being wrapped, with sharp edges that weren’t part of the convex hull.
Since it is only the points of the wrapper mesh that are being checked for collisions, mesh edges can still end up passing through the solid.
Ideally we’d check for collisions of the edges or faces of the wrapper mesh with the solid, and then split or flip those triangles to make new crisp edges form as needed. It gets a bit complex, but I think could be a route towards the kind of crisp shrinkwrapping that magics can do.
There was some nice work on this kind of approach for cloth simulation in last year’s SIGGRAPH:

Some day I’ll have a go at making something more like this.

Thank you very much for the reply. But I am getting an error message next to the right most mesh command saying that data conversion failed from line to mesh. And also, do I have to set my objects in the Brep? once I do that, the grasshopper goes Not Responding. I am trying to Set Multiple Breps with complex and large size. Is that maybe why the grasshopper goes not responding? Because my final purpose was to wrap my building which would be complex and multiple objects. Please let me know what I should do. Thank you very much!

that makes sense Daniel, thanks for the explanation. Having a solution where no points/edges touch the input mesh would be ideal. Even having a nominal offset amount, so instead of the wrinkwrap touching, it can stay always away by a keep-out distance. Than can also be controlled by offsetting the input mesh I guess, but when those are complex and non-manifold, or have self intersections, the mesh offset fails.

This error is due to the output from the Solver consisting of my than just a mesh (mesh and lines). If you use the ‘explode tree’ component, and then plug the second output (consisting of only the mesh) into the mesh component, it will clear that error.

You can plug your Breps into the first component…replacing the boxed-shaped brep that’s already in there. As for your Breps…it would probably be best to use one singular, closed Brep that’s a simplified form from your building.

Thank you very much Ahnjoe94

hello, I used this definition days ago, but suddenly it is not working…?

I thought maybe it was a problem with the definition I had been working on, but I just redownloaded the one on this forum, and same problem.

I had been working on it on a different computer, but my Rhino is updated, I have all the components the definition required.

Hi,
Have you changed the starting geometry referenced from Rhino?
What is the error message on the Convex Hull component?

Yes, I changed it.

The error message was:

1. Solution exception:Could not load file or assembly ‘Plankton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.

Actually today, I downloaded Plankton version 4.0 specifically, and now the definition works but the shrink wrap is still not as ‘slack’ or stretchy as it was. It’s pretty rigid, like it stopped at wbTriangles in the definition. Also Rhino gets a LOT slower/just freaks out and goes non-responsive for a good 3 minutes once I set a new brep for the definition.

What my wrap looked like:

Now w/ Plankton 4:

Dear dan,
I also have some problem. It appears that Simple remesh is installed !
but then when I restart the rhino it wants me to download it does not show, and I can’t find component anywhere on the web to download it manually.

Hi, were you able to solve the issue with the error message? I have the same error message on the convex hull with rhino 7… I also tried with Plankton 4.0 and end up with similar results.

Hi,
Was anyone able to solve the error message on the convex hull command? I tried replacing the original plankton .gha with plankton v4 but nothing has changed.

I’m on rhino 7, the definition works fine except for that small error.

Daniel, thank you for the amazing script and custom goal.
Do you think there is some way to make it work for this set of branches in 3d space?
Basically I have joined the branches and a interior mesh but the branches for some reason are not detected. Is that because the subdivision of the wrapper is too big? Or is there something I can do in code to enhance the detection of this relatively small volumes compared to the bigger mesh of the interior?

Hi @ankere

For something like this where the parts are spiky and very thin relative to the overall volume I think a different approach might be needed. The point-solid or edge-solid collision approaches above probably won’t work here.
Can you describe a bit what you have and what end result you are after?
Is the input a collection of closed manifold meshes?
Do you need a specific topology for the resulting mesh?
Do you want to to fit the shape tightly everywhere or are you looking for something that forms webs or curved regions between the branches?

I’m writing a tool that would combine branches into shell like structures as part of PhD work. I used a custom made equations and ipopt solver for this results (but probably would switch to Kangaroo2 in the future as there are too many problems with my implementation). Here is a bit idealised sample without the spiking parts which would be there in some cases:

Basically, I want to wrap this structure with something like semi-transparent elastic (cloth?) material and then calculate the total area needed for quantity estimations.

Topology is not as important as the final result looks that should look realistic without sharp edges. Ideally a tight, one shell surface fit is best for this case, but I am also really interested if it’s possible to form find something in-between the branches that can act as structure or panel? Do you think this is solvable?

The meshes were processed and are all closed, went trough Mesh Repair but some could contain very few (4-10) non manifold edges or other problems even after the repair but I had no time to fix manually all. Scale is real size (mm). I can send a sample file if you think that can help?

Here’s an updated version of the approach using the convex hull like I posted further up this thread.
The outermost spikes are the ones that tend most to slide through the mesh, so here it anchors all the points which lie on the hull.

shrinkwrap_branches.gh (80.8 KB)
There’s still the possibility that other spikes which are internal to the original hull end up poking through as the fabric shrinks, but it’s a start.

2 Likes

Wow thanks for the fast answer Daniel!
Somehow it gives an error on the TriRemesh - `Invalid cast: Point » GeometryBase` which is quite strange as all points are valid and the convex hull is working without any errors. I tried to convert to Point class that is derived from the GeometryBase or even cast to it but still shows the same error It also does the same error on your sample so it must be some library mismatch? If anyone has ideas please share.

That sounds like a bug which was in previous versions of the component, but is fixed now. If you update to a more current service release it should work.

2 Likes