Project one mesh onto another mesh

I want to project the green mesh onto the red one:


Is it possible?
ProjectMesh.gh (55.0 KB)

That mesh doesnā€™t have enough vertices to match the shape of the target mesh closely. Assuming that is what you want, Iā€™d suggest populating the mesh with points > pull those points to the target mesh > make a new mesh from them like thisā€¦

If on the other hand you wanted to keep the same vertex count, you could do it this wayā€¦

I hope that helps.

Populating with points is not a solution. Only the necessary points should be added.

And second, Delaunay Mesh is not a solution either, because the original mesh could have holes inside. It consists in modifying the original mesh, but not creating a completely new one.

Anybody else?

I canā€™t believe such an easy problem canā€™t be solved by McNeel forum!

Nobody?

All things are relative.

For instance imagine having the Mesh Outline(s) (as Polyline(s) then as Curve(s)) and projecting it/them - IF possible - to the target (thereā€™s a RC Method available anyway PLUS other tricks if the target has weird Topology). Now the question is: do you want to split (so to speak) the target (thus having a result that is a ā€œportionā€ of the target) OR do business with the Mesh to project? - kinda a ā€œdrapeā€ thing (thatā€™s slightly more challenging notably if the target is weird).

Bad news: if Iā€™ll provide some indicative solution that would be done purely via code (C#) meaning either heaven or hell depending on your point of view.

I think thatā€™s enough. However, as you can see in the example, that outline can exceed the limits of the other mesh.

Thatā€™s not a big deal. But you havenā€™t answer the 1M question: what kind of result? a ā€œportionā€ of the target OR a draped (so to speak) Mesh? (kinda like the drape effect that K2 can do - see lotā€™s of examples around IF this is the desired result).

I donā€™t mind (if I have understood the question). Obtaining an individual mesh projected on the other one would be enough.

Thatā€™s in theory. If the Mesh (and the resulting projected Outline(s)/Crv(s)) are partially outside the target the result would be a collection of splitted pieces.

Anyway Iā€™m not in the practice right now. When back Iā€™ll post an indicative take on that matter - as a ā€œgeneral caseā€ as possible - where the Mesh yields a splitter that splits the target etc etc.

If one needs only the target pieces inside the splitter ā€¦ well ā€¦ that requires an elementary inclusion check (since the splitter is closed [derived from a Mesh from Brep ā€¦ derived using the CreateFromOffsetFace Method]).

BTW: Appears that the ā€œdrapeā€ approach is not the ideal way to cut the mustard assuming a weird/freaky target. So the Mesh acts like a cutter and the focus is on the target Mesh.

Thank you, I look forward to that indicative post.

Get a rather simple take on that puzzle. A K2 242 ā€œrelaxationā€ is included - but if you need an ā€œaccurateā€ rasult ā€¦ well ā€¦ disable it.

Mesh_ProjectToAnother_EntryLevel_V0.gh (350.9 KB)



It does not return the projected mesh. Notice that it crosses the target mesh multiple times. It should create new vertices to adapt perfectly to the target mesh.

Not quite.

The C# works by shooting a Ray3d from each Mesh Vertex to the target (given obviously a user defined Vector). Each shoot either yields a Point or null. So the ā€œhitā€ collection is a nullable one. The order is exactly the same as the one in Mesh Vertices.

Then for each Face in the Mesh ā€¦ if ALL the adjacent Vertices have corresponding (by index) non null hit Points ā€¦ then a new Mesh Face is created and added to the result Mesh.

Obviously the result is heavily related with the 2 Topologies AND the Ray3d direction. If you want a finer result subdivide the Mesh ā€¦ or the result (but the latter may be very tricky - general case: any Mesh pair VS any Ray3d etc etc).

It sounds like you might want to split the larger mesh by the naked perimeter of the smaller mesh? I donā€™t know if these methods are implemented in native Grasshopper, but one can certainly script them fairly easily:


240527_SplitMeshByMeshPerimeter_00.gh (62.6 KB)

Note that I moved the meshes to the origin, as mesh operations are prone to floating point issues.

2 Likes

Exactly what I needed. Thank you so much!

1 Like

Hello @AndersDeleuran .

Iā€™ve slightly modified your code to obtain all mesh fragments, but, in essence, the flow is the same.

Iā€™ve been trying to use that script inside a Hops component. However, the script gets stuck in the middle. I added two debug outputs (plcA and plcB).


image

As you can see, plcA output is ok, but not the same for plcB. Probably due to an error with rg.Curve.ProjectToMesh(plcA, MeshA, Vector, 0.001).

Does anybody know how to solve it? Any help would be appreciated
test_mesh.gh (501.7 KB)
test_mesh_Hops.gh (3.5 KB)

1 Like

Really nobody?

I just tried running the files and got the same result as you. I donā€™t really know anything about/use Hops, so Iā€™m afraid I can help debug why it might fail.