Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8542

Vertex Numbering and Mesh Mapping

$
0
0

Hello All,

I’m working on a numerical procedure with meshes and lines. I retrieve a number of meshes and lines, each one with some properties (density, initial stresses, etc). What I need is to have a unique Vertice List containing all meshes and lines vertices, and apply to each mesh face and line the corresponding indice of the new Vertice List. My latest strategy was to create a empty Point List and loop for all mesh faces and lines, adding the vertices that are not contained in the point list yet. However for large problems it is highly time consuming. Here is the routine for the meshes (lines are very similar), where Node is a class that contain a Point3D and a indice and NFD is a class that contains three nodes (triangular mesh face) and its properties:

List<Point3d> points = new List<Point3d>();
List<Node> nodes = new List<Node>();
int id=0;
foreach (NFD nfdens in nfd)
        {
            foreach (Node node in nfdens.nodes)
            {
                if (node.point.DistanceTo(Rhino.Collections.Point3dList.ClosestPointInList(points,node.point))>0.001)
                {
                    points.Add(node.point);
                    nodes.Add(node);
                    node.index = id;
                    id++;
                }
                else
                {
                    int idx = Rhino.Collections.Point3dList.ClosestIndexInList(points, node.point);
                    node.index = idx;
                }
            }
        }

Now I got the ideia to use the Append and CombineIdentical Methods in Mesh class on RhinoCommon, so I would retrieve directly the vertices of the joined meshes, and them i just do the older checking for the lines. However as my meshes have diferrent properties attached to each one, I would need something to map the older mesh vertex indices to the new ones. Any ideia on doing that? Or even a better way of doing this? (Ideally I would like to minimize the bandwidth of the adjency matrix of the Graph containg the lines and mesh edges as edges and the nodes as vertexes)
Here is the code i’m thinking of by now:

List<Mesh> meshes = new List<Mesh>();
Mesh overallmesh= new Mesh();
foreach (NFD n in nfd)
         {
              meshes.Add(mesh);
          }
  overallmesh.Append(meshes);
  overallmesh.Vertices.CombineIdentical(true, true);
  //Apply the line routine
  //Retrieve the new Node List
  //Retrieve mapping from the original elements vertexes to the new Node List

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 8542

Trending Articles