Revision: 6190 http://sourceforge.net/p/jump-pilot/code/6190 Author: michaudm Date: 2019-07-28 09:10:02 +0000 (Sun, 28 Jul 2019) Log Message: ----------- GraphToolBox : improve meanwidth computation in 0.6.3
Modified Paths: -------------- plug-ins/GraphToolboxPlugin/trunk/build.xml plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/GraphExtension.java plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/SkeletonPlugIn.java Modified: plug-ins/GraphToolboxPlugin/trunk/build.xml =================================================================== --- plug-ins/GraphToolboxPlugin/trunk/build.xml 2019-06-25 17:20:20 UTC (rev 6189) +++ plug-ins/GraphToolboxPlugin/trunk/build.xml 2019-07-28 09:10:02 UTC (rev 6190) @@ -17,7 +17,7 @@ <property name="dist" value="dist" /> <property name="javadoc" value="javadoc" /> - <property name="version" value="0.6.2" /> + <property name="version" value="0.6.3" /> <!-- =================================================================== --> <!-- Defines the classpath used for compilation and test. --> Modified: plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/GraphExtension.java =================================================================== --- plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/GraphExtension.java 2019-06-25 17:20:20 UTC (rev 6189) +++ plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/GraphExtension.java 2019-07-28 09:10:02 UTC (rev 6190) @@ -35,8 +35,9 @@ * <li>CycleFinderPlugIn : computes a graph from a linear network and find base cycles</li> * </ul> * @author Michaël Michaud - * @version 0.6.2 (2019-05-22) + * @version 0.6.3 (2019-06-24) */ +//version 0.6.3 (2019-06-24) SkeletonPlugIn : improve meanWidth calculation //version 0.6.2 (2019-05-22) fix bug in SkeletonPlugIn : incorrect relativeMinForkLength //version 0.6.1 (2018-06-17) refactor to use AbstractPlugIn parameters in GraphNodesPlugIn //version 0.6.0 (2018-06-12) refactor to use AbstractPlugIn parameters in SkeletonPlugIn @@ -62,7 +63,7 @@ } public String getVersion() { - return "0.6.1 (2018-06-17)"; + return "0.6.3 (2019-06-24)"; } public void configure(PlugInContext context) throws Exception { Modified: plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/SkeletonPlugIn.java =================================================================== --- plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/SkeletonPlugIn.java 2019-06-25 17:20:20 UTC (rev 6189) +++ plug-ins/GraphToolboxPlugin/trunk/src/fr/michaelm/jump/plugin/graph/SkeletonPlugIn.java 2019-07-28 09:10:02 UTC (rev 6190) @@ -1,6 +1,7 @@ package fr.michaelm.jump.plugin.graph; import com.vividsolutions.jts.algorithm.MCPointInRing; +import com.vividsolutions.jts.algorithm.MinimumDiameter; import com.vividsolutions.jts.algorithm.distance.DistanceToPoint; import com.vividsolutions.jts.algorithm.distance.PointPairDistance; import com.vividsolutions.jts.densify.Densifier; @@ -66,6 +67,8 @@ private static String DISPLAY_VORONOI_EDGES = I18NPlug.getI18N("SkeletonPlugIn.display-voronoi-edges"); private static String DESCRIPTION = I18NPlug.getI18N("SkeletonPlugIn.description"); + double SQRT2 = Math.sqrt(2.0); + // default external parameters { addParameter(P_LAYER_NAME, null); @@ -204,7 +207,7 @@ } catch (Exception e) { context.getWorkbenchFrame().warnUser(e.getMessage()); } - newFeature.setAttribute("mean_width", meanWidth); + newFeature.setAttribute("mean_width", getDoubleParam(P_MEAN_WIDTH)); newFeature.setAttribute("min_width", getDoubleParam(P_MIN_WIDTH)); newFeature.setAttribute("min_fork_length", getMinForkLength()); g = skeletonize(g, edges); @@ -234,7 +237,6 @@ // This method must be called only once per object private Geometry computeParams(Geometry geometry) { meanWidth = getMeanWidth(geometry); - double SQRT2 = Math.sqrt(2.0); if (meanWidth==0) meanWidth = geometry.getLength()/geometry.getNumPoints()/5; if (getBooleanParam(P_AUTO_WIDTH)) { // Iterative function to find the minimal width of the polygon @@ -282,7 +284,12 @@ return ((length / 2.0) - Math.sqrt(val)) / 2.0; } else { //diamètre du disque de même surface, sur une surface ramassée - return 2.0 * Math.sqrt(area / Math.PI); + //return 2.0 * Math.sqrt(area / Math.PI); + //improve width calculation for compact geometries + MinimumDiameter diameter = new MinimumDiameter(g); + Geometry minRectangle = diameter.getMinimumRectangle(); + double ratio = Math.sqrt(minRectangle.getArea()/g.getArea()); + return diameter.getLength()/ratio; } } else return 0d; } _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel