protected override void SolveInstance(IGH_DataAccess DA)
        {
            var list = new List<ITurtleMesh>();
            if (DA.GetDataList(0, list))
            {
                var nm = new TurtleMesh();

                for (int i = 0; i < list.Count; i++)
                {
                    if(list[i] != null)
                        nm.AppendOther(list[i]);
                }

                DA.SetData(0, nm);
            }
        }
        public static TurtleMesh ExtractTMesh(Curve c)
        {
            var m = new TurtleMesh();
            Polyline pl;
            c.TryGetPolyline(out pl);

            TurtleFace f = new TurtleFace(pl.Count - 1);

            for (int j = 0; j < pl.Count - 1; j++)
            {
                var v = pl[j];
                f.Add(m.VertexCount);
                m.AddVertex(new TurtleVertex((float)v.X, (float)v.Y, (float)v.Z));
            }
            m.AddFace(f);
            return m;
        }
Exemple #3
0
        public static TurtleMesh ExportFaceAt(ITurtleMesh m, int index)
        {
            var nm = new TurtleMesh();

            var f  = m.FaceAt(index);
            var nf = new TurtleFace(f.EdgesVerticesCount);

            for (int i = 0; i < f.EdgesVerticesCount; i++)
            {
                nm.AddVertex(new TurtleVertex(m.VertexAt(f[i])));
                nf.Add(i);
            }

            nm.AddFace(nf);

            return(nm);
        }
        public static TurtleMesh ExportFaceAt(ITurtleMesh m, int index)
        {
            var nm = new TurtleMesh();

            var f = m.FaceAt(index);
            var nf = new TurtleFace(f.EdgesVerticesCount);

            for (int i = 0; i < f.EdgesVerticesCount; i++)
            {
                nm.AddVertex(new TurtleVertex(m.VertexAt(f[i])));
                nf.Add(i);
            }

            nm.AddFace(nf);

            return nm;
        }
        public static ITurtleMesh ImportRhinoMesh(Mesh m)
        {
            var t = new TurtleMesh();

            var mv = m.Vertices;
            for (int i = 0; i < mv.Count; i++)
            {
                var v = mv[i];
                t.AddVertex(new TurtleVertex(v.X, v.Y, v.Z));
            }

            var mf = m.Faces;
            for (int i = 0; i < mf.Count; i++)
            {
                var f = mf[i];
                if(f.IsTriangle)
                    t.AddFace(new TurtleFace(f.A, f.B, f.C));
                else
                    t.AddFace(new TurtleFace(f.A, f.B, f.C, f.D));
            }

            return t;
        }