Flow along mesh?

Hi guys,
With the “flow along Surface” command lines or other geometry can be projected from a flat to a 3D geometry

Is it possible to do the same thing with meshes?
The 2D mesh could be for example the extracted UV mesh from the 3D mesh.

Is there a 3rd party app, script or something which offers this?

Cheers,
Norbert

Hi @Norbert,

you might try _Squish to create the flattened version of your 3D mesh. Then draw eg. some curves on the 2D mesh and use _Squishback to transform them back to the 3D mesh.

c.

1 Like

Hi Clement,

right I have totally forgotten the Squish command.

Thank you!
Norbert

@clement 'm playing arround with this and I find that with _squishback it is only possible to “flow” curves and points.
Is it possible to flow objects such as polysurfaces or meshes with other tools? I also find that the flatten mesh that squish creates is often distorted and bends over itself creating very unlikely results.

I find that the mesh that creates _Unwrap to apply a texture map is very much precise, but we can only use this mesh to apply texture mapping, right? It could be great to get this mesh and work with it to flow objects along the original mesh. I don’t know If I am missing something.

Maybe @pascal could help. If you need an example file I can attach.

Thanks.

Hello - I don’t know of any tool for that. I think you can get the unwrap meshes though, if you want just the meshes, with ExtractUVMesh

-Pascal

@kiwi, if you can post an example it would help.

For better squish results it helps if the 3d mesh is tesselated homogeneous, which means, all triangles should have roughly the same edge length.
_
c.

I have a similar question, starting from a mesh1, I ExtractUVMesh.
Then I want to place some geometry on the extracted uv mesh and “flow” it back to mesh1.

Can this be done?

despite _Squish there is no native command which does it. What kind of geometry you are trying to remap ?

btw. in case of polylines you might try MapMesh using NGon in GH:

_
c.

2 Likes

Hi @clement , thanks for the advice.
I would like to remap all kinds of geometry.

ExtractUVMesh creates very accurate mesh, and it can also be further adjusted in the UV editor.
So I’m wandering:
If a texture can be mapped this way, why not geometry?
Why is squishback constrained to use the output of squish?

It feels like some sort of “flow along mesh” could be made possible.

Maybe because the texture is flat but deformable. To make this with 3d geometries they must be deformable too. Imagine you would flow a line from the flat 2d mesh to the deformed 3d mesh. In order to make the line follow the deformation it is required to add points to the line and change it, eg. into a curve. If you just remap the line end points, there will be no deformation, the line stays rigid.

Transfer these thoughts to various 3d geometries, eg. curves, planar surfaces, boxes, complex polysurfaces, meshes and subd objs. Some object types may be easy to remap, eg. meshes and subd, some require to increase geometric density to be deformable…

Maybe post an example file of what you’re trying to flow including the source and target mesh.

_
c.

Here’s an example of what I want to flow including reference and target meshes.
ExtractUVMesh flow to mesh.3dm (5.2 MB)

Hi @Bogdan_Chipara, a combination of the 2 meshes as in your example will not work because both need to be topologically identical. Your 3d and 2d mesh properties reveal below information:

3D >> Open double precision polygon mesh: 18039 vertices, 19015 faces (303 n-gons)
2D >> Open polygon mesh: 10419 vertices, 19015 faces

To fix this, i repaired the 3D mesh using these commands:

  1. _ExtractNonManifoldMeshEdges, the remove that hanging face
  2. _Join the extracted remains to the large 3D mesh
  3. _Weld with 180° to get rid of the many naked edges
  4. _TriangulateMesh
  5. _Unwrap using ARAP and a vertical symmetry plane
  6. _ExtractUVMesh to get the 2D mesh

This results in the following:

3D >> Open double precision polygon mesh: 10418 vertices, 20123 faces with normals
2D >> Open polygon mesh: 10418 vertices, 20123 faces

Since you only try to remap polylines, the NGon PlugIn for GH should do what you want.

BogdanMeshRemap.3dm (2.2 MB)
BogdanMeshRemap.gh (20.3 KB)

You can also use curves, just pull them to the source mesh to create polylines…
_
c.

1 Like

Thanks @clement ,
I see it working, and also good tutorial for preparing the mesh for Ngon.

Have to say I am still disappointed that I cannot do this using Rhino only, as initially suggested in the first post, using something like Flow along mesh. Especially because I see how Squishback works and it should be adapted to work between any meshes with same topology.

Installing NGon with one hundred functions just to use one is a bit of a disadvantage.
And obviously this is restricted to curves, another disadvantage.

But, since MapMesh was programmed for a plugin, it seems that one can program it independently, no?

image
image

MeshMap has been a function in Kangaroo for many years, and as it is preinstalled you don’t need to add any plugins:


meshmap.gh (1.3 MB)

2 Likes

Thank you @DanielPiker !
Does it work with 3D geometry also?

Not MeshMap, but the PolyPrism method used in MorphToMesh should, I’ll make an example.

Yes, please make an example, this topic needs it . Thank you!


MeshMap_Thick.gh (1.3 MB)

5 Likes

Fabulous @DanielPiker !
Thanks again.

Now… this is obviously very useful for all kinds of applications…
Can McNeel integrate your beautiful code in Rhino, and make a tool out of it, for easy usage?

A tool that works with curves, meshes and surfaces… called FlowAlongMesh

// Grasshopper Script Instance
// By Daniel Piker 250604
#region Usings
#r "Kangaroo2Component.dll"
using Kangaroo2Component.UtilityComponents;
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Threading.Tasks;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
#endregion

public class Script_Instance : GH_ScriptInstance
{
    #region Notes
    /* 
      Members:
        RhinoDoc RhinoDocument
        GH_Document GrasshopperDocument
        IGH_Component Component
        int Iteration

      Methods (Virtual & overridable):
        Print(string text)
        Print(string format, params object[] args)
        Reflect(object obj)
        Reflect(object obj, string method_name)
    */
    #endregion

    private void RunScript(
		Mesh M1,
		Mesh M2,
		List<Point3d> Pts,
		double thickness,
		ref object a,
		ref object b)
    {       
        Mesh offset = M2.DuplicateMesh();
        OffsetMesh(ref offset, thickness);
        Point3d[] ptsIn = Pts.ToArray();
        Point3d[] ptsOut = new Point3d[ptsIn.Length];

        Parallel.For(0, ptsIn.Length,i =>
        {
            Point3d Pt = ptsIn[i];
            MeshPoint mp = M1.ClosestMeshPoint(Pt,0);
            Point3f pa,pb,pc,pd;
            M1.Faces.GetFaceVertices(mp.FaceIndex, out pa, out pb, out pc, out pd);
            Polyline refPoly = new Polyline(new Point3d[4]{pa,pb,pc,pa});
            M2.Faces.GetFaceVertices(mp.FaceIndex, out pa, out pb, out pc, out pd);
            Polyline inner = new Polyline(new Point3d[4]{pa,pb,pc,pa});
            offset.Faces.GetFaceVertices(mp.FaceIndex, out pa, out pb, out pc, out pd);
            Polyline outer = new Polyline(new Point3d[4]{pa,pb,pc,pa});
            var morph = new MorphToMesh.PolyPrism(refPoly, inner, outer);
            ptsOut[i] = morph.MorphPoint(Pt);
        });
        a= ptsOut;
    }

    void OffsetMesh(ref Mesh M, double d)
{
  M.Normals.ComputeNormals();
  var normals = M.Normals.ToFloatArray();
  for (int i = 0; i < M.Vertices.Count; i++)
  {
    double dist = d;    
    M.Vertices.SetVertex(i,
      M.Vertices[i].X + dist * normals[3 * i],
      M.Vertices[i].Y + dist * normals[3 * i + 1],
      M.Vertices[i].Z + dist * normals[3 * i + 2]);
  }
}
}

Actually I just looked at the code again and realised I was overcomplicating things. The ‘PolyPrism’ method I used there was originally written to work with polygons of any number of sides, but in cases like this we know we have triangles so can do it more easily.
Here’s an updated version that will take any geometry as input:
MeshMap_Thick2.gh (1.3 MB)

3 Likes