Grasshopper

algorithmic modeling for Rhino

mesh edge topology: how does it work? how is that sorted when offseting a mesh?

Hi to everybody,

I am creating a solid mesh with c# just offseting topside and bottomside a central mesh.

When I am doing this the vertex and face list index remain consistent with the original central surface, but this is not happening with the edge mesh list!

In fact when I want to create mesh faces (the side mesh faces to close the boundaries surfaces) I can see (and I have tested/x2 checked within GH), that the corrispondent top edge and bottom edge of a determinated face are not coincident.

How can I assign a consistent index list to the top and bottom mesh edge list?

How the edge topology is assigned?

I post here the code, FYI, even I do not think that can help to find the problem.

And 2 screenshot to show you the problem.

            double thickness = new double();
            if (!DA.GetData(0, ref thickness)) return;
            
            Mesh baseMesh = new Mesh();
            if (!DA.GetData(1, ref baseMesh)) return;

            List<Plane> localCSPlanes = new List<Plane>();
            if (!DA.GetDataList<Plane> (2, localCSPlanes)) return;

            List<Mesh> solidMesh = new List<Mesh>();
            List<Point3d> meshFaceCenterPlus = new List<Point3d>();
            List<Point3d> meshFaceCenterMinus = new List<Point3d>();
            List<Plane> localCSPlanesPlus = new List<Plane>();
            List<Plane> localCSPlanesMinus = new List<Plane>();
            List<Line> edgeMeshPlusLine = new List<Line>();
            List<Line> edgeMeshMinusLine = new List<Line>();

            Mesh offsetPlus = baseMesh.Offset(0.5*thickness, false);
            Mesh offsetMinus = baseMesh.Offset(-0.5 * thickness, false);

            Mesh recMesh = new Mesh();

            solidMesh.Add(offsetPlus);
            solidMesh.Add(offsetMinus);
            
            //This for-cycle creates a index-consistent list of plus-offset mesh face center points and local coordinate system mesh planes.
            int nFcsPl = offsetPlus.Faces.Count;
            int nEdg = offsetPlus.TopologyEdges.Count;

            for (int i = 0; i <= nFcsPl - 1; i++)
            {
                meshFaceCenterPlus.Add(new Point3d(offsetPlus.Faces.GetFaceCenter(i)));
                localCSPlanesPlus.Add(new Plane(offsetPlus.Faces.GetFaceCenter(i), localCSPlanes[i].XAxis, localCSPlanes[i].YAxis));
            }
          
            //This for-cycle creates a index-consistent list of minus-offset mesh face center points and local coordinate system mesh planes.
            int nFcsMn = offsetMinus.Faces.Count;
            int nEdgMn = offsetMinus.TopologyEdges.Count;

            for (int i = 0; i <= nFcsMn - 1; i++)
            {
                meshFaceCenterMinus.Add(new Point3d(offsetMinus.Faces.GetFaceCenter(i)));
                localCSPlanesMinus.Add(new Plane(offsetMinus.Faces.GetFaceCenter(i), localCSPlanes[i].XAxis, localCSPlanes[i].YAxis));               
            }

            for (int i = 0; i <= nEdg - 1; i++)
            {

                Line lineRecPlus = offsetPlus.TopologyEdges.EdgeLine(i);
                edgeMeshPlusLine.Add(lineRecPlus);

                Point3d recPointA = lineRecPlus.From;
                recMesh.Vertices.Add(recPointA);

                Point3d recPointB = lineRecPlus.To;
                recMesh.Vertices.Add(recPointB);

                Line lineRecMinus = offsetMinus.TopologyEdges.EdgeLine(i);
                edgeMeshMinusLine.Add(lineRecMinus);

                Point3d recPointC = lineRecMinus.To;
                recMesh.Vertices.Add(recPointC);

                Point3d recPointD = lineRecMinus.From;
                recMesh.Vertices.Add(recPointD);

                recMesh.Faces.AddFace(0 + 4 * i, 1 + 4 * i, 2 + 4 * i, 3 + 4 * i);
           

NOTE: I know how to create a solid from a single mesh surface, but this is not what I want now, because I have to sort (for further purpose) the solid mesh in top, bottom and side faces.

Thanks a lot for your help!

cheers,

matteo

Views: 4571

Attachments:

Replies to This Discussion

Could you explain or show roughly your workflow?

My guess would be that a conversion step is losing the information.

From Plankton you can get an actual index for the start and end vertex of each edge, so you know that wherever you move the vertex points, that edge will always go between them.

With a face-vertex mesh you just have a list of vertices and then for each face a list of indices, and there are multiple possibilities for how you extract from that a list of edges.

Hi Daniel,

sure:

I've recorded 100 meshes from a Kangaroo simulation (rigid folding). Then I retrieve one and the same index of mesh edge with the component from Plankton.Demo0.2.0 from different meshes of this set. The same index gives me different positions of edges / adjacent vertices.

The geometry input / output of Kangaroo were the vertices, and I assembled each mesh from these particles. The mesh vertices and faces have the same order in all the meshes.

Also now sometimes the compoment turns red and doesn't work, but that didn't happen before.

I guess I should use the actual Plankton components right?

Attachments:

I see. You're starting with Rhino meshes, so the edge information is not there explicitly to begin with, but is being extracted.

Once you create a Plankton mesh, the edge ordering is preserved through whatever you do to it or its vertices as long as it remains a Plankton mesh, but because a Rhino mesh doesn't contain an edge ordering, it has to create one when it converts, using only the information available, and this won't necessarily be the one you are after.

So what I would suggest in this situation is to store a list of vertices for each iteration of the Kangaroo simulation, and rebuild the meshes from these new positions and the original connectivity information.

Oookay, I think I got it. So this is what I have been doing the reconstruct the mesh after Kangaroo:

The meshes coming out of this had been recorded and formed the input of the former script I showed you.

But rather than "Deconstruct Mesh" - "Construct Mesh" from GH, I should use Plankton to deconstruct - reconstruct the mesh right?

(replying to my own comment, as Ning won't allow me to reply to yours)

Yes - the important thing is to get the connectivity information just once, before it has gone into Kangaroo.

This reminds me - it would be good to add a simple ConstructPlankton component that can take the topology from one Plankton mesh and apply it to a different set of vertices.

In this case though, I think the simplest thing to do would be to just get your edges as lines in the beginning, and put them into the Geometry input. If you need both the mesh and the edges, you can use Entwine and Explode:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service