Copyright (C) 2008- 2011 Thomas Boudier
This file is part of mcib3d
mcib3d is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
public static java.util.List smooth(java.util.List orig,
If the Content instance wraps a mesh, smooth it by the
fraction K (0, 1).
public static java.util.List smooth2(java.util.List<Point3f> orig,
Implemented Blender-style vertex smoothing.
See Blender's file editmesh_mods.c, at function
"static int smooth_vertex(bContext *C, wmOperator *op)"
What it does:
1. For each unique edge, compute the average of both vertices
and store it in a Point3f. Also increment a counter for each
vertex indicating that it has been part of an averaging operation.
If the vertex is again part of an averaging operation, just add
the new average to the existing one.
2. For each unique vertex, computer a factor as 0.5/count, where
count is the number of times that the vertex has been part
of an averaging operation. Then set the value of the vertex
to 0.5 times the original coordinates, plus the factor times
the cumulative average coordinates.
The result is beautifully smoothed meshes that don't shrink noticeably.
All kudos to Blender's authors. Thanks for sharing with GPL license.
Taken from ImageJ 3D Viewer