Ejemplo n.º 1
0
        public void CanCreateFromRhinoMesh()
        {
            // 1. get/create rhino mesh

            Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh();
            mesh.Vertices.Add(0.0, 0.0, 1.0); //0
            mesh.Vertices.Add(1.0, 0.0, 1.0); //1
            mesh.Vertices.Add(2.0, 0.0, 1.0); //2
            mesh.Vertices.Add(3.0, 0.0, 0.0); //3
            mesh.Vertices.Add(0.0, 1.0, 1.0); //4
            mesh.Vertices.Add(1.0, 1.0, 2.0); //5
            mesh.Vertices.Add(2.0, 1.0, 1.0); //6
            mesh.Vertices.Add(3.0, 1.0, 0.0); //7
            mesh.Vertices.Add(0.0, 2.0, 1.0); //8
            mesh.Vertices.Add(1.0, 2.0, 1.0); //9
            mesh.Vertices.Add(2.0, 2.0, 1.0); //10
            mesh.Vertices.Add(3.0, 2.0, 1.0); //11

            mesh.Faces.AddFace(0, 1, 5, 4);
            mesh.Faces.AddFace(1, 2, 6, 5);
            mesh.Faces.AddFace(2, 3, 7, 6);
            mesh.Faces.AddFace(4, 5, 9, 8);
            mesh.Faces.AddFace(5, 6, 10, 9);
            mesh.Faces.AddFace(6, 7, 11, 10);
            mesh.Normals.ComputeNormals();
            mesh.Compact();

            // 2. call BmMesh(Mesh) constructor

            Mesh polymesh = new Mesh(mesh);

            // 3. compare number of vertex/face elements
            // 4. compare number of halfedges against no. required for no. faces
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Mesh mesh = null;

            if (!DA.GetData(0, ref mesh))
            {
                return;
            }

            int n       = mesh.Vertices.Count;
            var points  = new Point3d[n];
            var normals = new Vector3d[n];

            for (int i = 0; i < n; i++)
            {
                points[i]  = mesh.Vertices[i].Position;
                normals[i] = mesh.Vertices[i].Normal;
            }

            DA.SetDataList(0, points);
            DA.SetDataList(2, normals);

            //DA.SetDataList(0, mesh.Vertices.Select(v => v.Position));
            //DA.SetDataList(1, mesh.Vertices.Select(v => v.Normal));
        }
Ejemplo n.º 3
0
        public static SharpSLO.Types.Molecular ToMolecular(this Buckminster.Types.Mesh mesh)
        {
            var molecular = new SharpSLO.Types.Molecular(mesh.Vertices.Count);

            foreach (var vertex in mesh.Vertices.Select(v => v.Position))
            {
                molecular.Add(vertex.X, vertex.Y, vertex.Z);
            }

            Dictionary <string, int> vlookup = new Dictionary <string, int>();

            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                vlookup.Add(mesh.Vertices[i].Name, i);
            }

            foreach (var edge in mesh.Halfedges.GetUnique())
            {
                molecular.Add(vlookup[edge.Vertex.Name], vlookup[edge.Prev.Vertex.Name]);
            }

            return(molecular);
        }