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

  • up

    This comment was deleted

    1
    • up

      matteo

      Hi to everybody,

      I have solved it! :) i have created the solid mesh.

      but still remain the question (it seems strange to me) of inconsistency between face vertex topology and edge vertex topology. Why is that? It seems an unecessary complication!

      thanks for the answer

      Matteo

      • up

        Benjamin Felbrich

        Hi Matteo,

        I just came across the same issue. When simulating moving/changing mesh shapes in Kangaroo:

        Though The Vertex and Face Lists remain the same, The Mesh Edge List seem to jitter the indeces.

        In both, Weaverbird's and GH's Mesh edge component this appears.

        Do you (or anyone else) know more about how these commends sort the mesh edges? Maybe they sort them by the coordinates of their center points or something????

        14