private void laplacianSmoothToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckAndWarnMeshExist())
            {
                return;
            }

            // JC: Note that this is not the g3.LaplacianMeshSmoother. I am not sure what that function does.
            // According to MeshLab, Laplacian smoothing means: for each vertex, calculate the average position with nearest vertex.


            // TODO(jiac5): a lot of optimization is needed here.
            List <g3.Vector3d> temp = new List <g3.Vector3d>(_mesh.VertexCount);

            for (int i = 0; i < _mesh.VertexCount; ++i)
            {
                temp.Add(new g3.Vector3d());
            }
            foreach (var v in _mesh.VertexIndices())
            {
                var avg   = new g3.Vector3d();
                int count = 0;
                foreach (var neighbor_v in _mesh.VtxVerticesItr(v))
                {
                    avg = avg + _mesh.GetVertex(neighbor_v);
                    count++;
                }
                avg     = avg / count;
                temp[v] = avg;
            }

            foreach (var v in _mesh.VertexIndices())
            {
                _mesh.SetVertex(v, temp[v]);
            }

            DrawMesh();
        }
Esempio n. 2
0
 public static Vector3d ToRhinoVector(this g3.Vector3d v)
 {
     return(new Vector3d(v.x, v.y, v.z));
 }
Esempio n. 3
0
 public static Point3d ToRhinoPoint(this g3.Vector3d v)
 {
     return(new Point3d(v.x, v.y, v.z));
 }