示例#1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            DMesh3_goo dMsh_goo = null;
            double     w        = 1;

            DA.GetData(0, ref dMsh_goo);
            DA.GetData(1, ref w);

            DMesh3 dMsh_copy = new DMesh3(dMsh_goo.Value, true);

            LaplacianMeshDeformer deformer = new LaplacianMeshDeformer(dMsh_copy);

            foreach (int vid in dMsh_copy.VertexIndices())
            {
                if (deformer.IsConstrained(vid) == false)
                {
                    deformer.SetConstraint(vid, dMsh_copy.GetVertex(vid), w);
                }
            }

            bool success = deformer.SolveAndUpdateMesh();
            bool isValid = dMsh_copy.CheckValidity();

            if (!success)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Laplacian deform seems to have failed. Please check...");
            }

            if (!isValid)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Mesh seems to have been corrupted during smoothing. Please check...");
            }

            DA.SetData(0, dMsh_copy);
        }