예제 #1
0
        //  private List<int> _filledTetrahedron = new List<int>();


        /// <summary>
        ///
        /// </summary>
        private void Start()
        {
            Angle.fillAmount = 0;
            _mesh            = _growthMesh.Value;
            ValidateMesh();

            var faces = _mesh.Faces;

            // add all faces to the growth list
            for (int i = 0; i < faces.Count; i++)
            {
                _growthFaces.Add(i);
            }

            var edges = _mesh.Edges;

            // add all edges to the fill queue
            for (int i = 0; i < edges.Count; i++)
            {
                _fillEdges.Enqueue(i);
            }

            // fill initial
            Fill();
        }
예제 #2
0
        /// <summary>
        /// Labels vertices as 0 = interior, 1 = seam, 2 = corner
        /// </summary>
        private static int[] GetVertexLabels(HeMesh3d mesh, List <V> corners)
        {
            var verts   = mesh.Vertices;
            var labels  = new int[verts.Count];
            int currTag = TagSeams(mesh, corners);

            // label known corners
            foreach (var v in corners)
            {
                labels[v] = 2;
            }

            // set vertex labels based on the number of incident seam edges
            for (int i = 0; i < verts.Count; i++)
            {
                var v = verts[i];
                if (v.IsUnused || labels[i] == 2)
                {
                    continue;
                }

                // count number of tagged edges
                int ne = 0;
                foreach (var he in v.OutgoingHalfedges)
                {
                    if (he.Tag == currTag)
                    {
                        if (++ne > 2)
                        {
                            break;
                        }
                    }
                }

                // assign vertex label
                if (v.IsBoundary)
                {
                    if (ne > 0)
                    {
                        labels[i] = 2;
                        corners.Add(v);
                    }
                }
                else
                {
                    if (ne == 2)
                    {
                        labels[i] = 1;
                    }
                    else if (ne > 2)
                    {
                        labels[i] = 2;
                        corners.Add(v);
                    }
                }
            }

            return(labels);
        }
예제 #3
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="mesh"></param>
            /// <param name="path"></param>
            public static void WriteToJson(HeMesh3d mesh, string path)
            {
                WriteToJson <HeMesh3d.Vertex, HeMesh3d.Halfedge, HeMesh3d.Face, double[], double[], double[]>(mesh, path, ToJson);

                double[] ToJson(HeMesh3d.Vertex vertex)
                {
                    var p = vertex.Position;
                    var n = vertex.Normal;

                    return(new double[] { p.X, p.Y, p.Z, n.X, n.Y, n.Z });
                }
            }
예제 #4
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="path"></param>
            /// <param name="mesh"></param>
            public static void ReadFromJson(string path, HeMesh3d mesh)
            {
                ReadFromJson <HeMesh3d.Vertex, HeMesh3d.Halfedge, HeMesh3d.Face, double[], double[], double[]>(path, mesh, FromJson);

                void FromJson(HeMesh3d.Vertex vertex, double[] values)
                {
                    vertex.Position = new Vector3d(
                        values[0],
                        values[1],
                        values[2]);

                    vertex.Normal = new Vector3d(
                        values[3],
                        values[4],
                        values[5]);
                }
            }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        Mesh SolveInstanceImpl(HeMesh3d mesh, IReadOnlyList <Color> colors, Intervald interval, out Intervald range)
        {
            var verts = mesh.Vertices;
            var faces = mesh.Faces;

            var planarDev = new double[faces.Count];

            mesh.GetFacePlanarity(v => v.Position, (f, t) => planarDev[f] = t);

            // get planarity range
            range = new Intervald(planarDev);
            if (!interval.IsValid)
            {
                interval = range;
            }

            // create new mesh
            return(mesh.ToPolySoup(f => colors.Lerp(interval.Normalize(planarDev[f]))));
        }
예제 #6
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            HeMesh3d     mesh   = null;
            List <Color> colors = new List <Color>();

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

            int last   = colors.Count - 1;
            var result = mesh.ToPolySoup(f => colors[Math.Min(f, last)]);

            DA.SetData(0, new GH_Mesh(result));
        }
예제 #7
0
        /// <inheritdoc />
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_HeMesh3d hemGoo = null;

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

            int start = -1;

            if (!DA.GetData(1, ref start))
            {
                return;
            }

            List <double> factors = new List <double>();

            DA.GetDataList(2, factors);

            var mesh = new HeMesh3d(hemGoo.Value);
            var f    = mesh.Faces[start];

            // ensures mesh is unrollable
            HeMeshUnroller.DetachFaceCycles(mesh, f);

            // perform unroll
            var unrolled = new Vec3d[mesh.Vertices.Count];
            var last     = factors.Count - 1;

            HeMeshUnroller.Unroll(mesh, f, (v, p) => unrolled[v] = p, he => factors[Math.Min(he >> 1, last)]);

            // set vertex attributes
            var fn = f.GetNormal(v => v.Position);

            mesh.Vertices.Action(v =>
            {
                v.Position = unrolled[v];
                v.Normal   = fn;
            });

            DA.SetData(0, new GH_HeMesh3d(mesh));
        }
예제 #8
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            HeMesh3d     mesh     = null;
            List <Color> colors   = new List <Color>();
            Interval     interval = new Interval();

            if (!DA.GetData(0, ref mesh))
            {
                return;
            }
            if (!DA.GetDataList(1, colors))
            {
                return;
            }
            DA.GetData(2, ref interval);

            var dispMesh = SolveInstanceImpl(mesh, colors, interval, out Intervald range);

            DA.SetData(0, new GH_Mesh(dispMesh));
            DA.SetData(1, new GH_Interval(range));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="mesh"></param>
 /// <returns></returns>
 public abstract MeshField3d <T> Create(HeMesh3d mesh);
예제 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mesh"></param>
 public MeshVertexVectorField(HeMesh3d mesh)
     : base(mesh)
 {
 }
예제 #11
0
        private Mesh _queryMesh; // triangulated query mesh


        /// <summary>
        ///
        /// </summary>
        /// <param name="mesh"></param>
        public MeshField(HeMesh3d mesh)
        {
            _mesh = mesh;
            RebuildQueryMesh();
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="mesh"></param>
 public MeshVertexScalarField(HeMesh3d mesh)
     : base(mesh)
 {
 }
예제 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 public MeshVertexField(MeshVertexField other)
 {
     _mesh      = other._mesh;
     _queryMesh = other._queryMesh;
 }
예제 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mesh"></param>
 public MeshScalarField(HeMesh3d mesh)
     : base(mesh)
 {
 }
예제 #15
0
 public WallSystem(HeMesh3d _inputHeMesh)
 {
     spaceGraph = _inputHeMesh;
     walls      = new List <Wall>();
 }