diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java index 34212160c9a1a4318c281f8e599fa8b6d3f9dbf1..061747d636ea20dab131d5484ff7110b16efab8b 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/ConstructionRound.java @@ -146,10 +146,10 @@ public abstract class ConstructionRound } } - protected ArrayList< Surface > constructSurfaces( OSEListArray oseLists, int lineLength ) + protected ArrayList< Surface > constructSurfaces( OSEListArray oseLists, int lineLength, int surfaceMaxSize ) { SurfacesConstruction construction = - new SurfacesConstruction( oseLists, lineLength, overlap, connexityRate, surfaceMinSizeFactor ); + new SurfacesConstruction( oseLists, lineLength, overlap, connexityRate, surfaceMinSizeFactor, surfaceMaxSize ); construction.buildAllSurfaces(); int tempSmallSurfaceCount = construction.getSmallSurfaceCount(); smallSurfacesCount += tempSmallSurfaceCount; diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/FirstRoundConstruction.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/FirstRoundConstruction.java index 6f8d0459915e0db9e62b7d793328f249ed71911a..da670b61b32ef38a75d1b8998be69dda36ae1f14 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/FirstRoundConstruction.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/FirstRoundConstruction.java @@ -66,6 +66,7 @@ public class FirstRoundConstruction extends ConstructionRound public void process() throws NoSurfaceFoundException { + int surfaceMaxSize = maximums.length * maximums[0].length; LOGGER.debug( "Processing..." ); /* OSE construction according to the dimension considered */ long startOseConstructionTime = System.currentTimeMillis(); @@ -76,7 +77,7 @@ public class FirstRoundConstruction extends ConstructionRound LOGGER.debug( "Starting surface construction..." ); int lineLength = maximums[ 0 ].length; long startSurfacesConstructionTime = System.currentTimeMillis(); - this.getSurfaces().addAll( constructSurfaces( oseLists, lineLength ) ); + this.getSurfaces().addAll( constructSurfaces( oseLists, lineLength, surfaceMaxSize) ); long stopSurfacesConstructionTime = System.currentTimeMillis(); this.setConstructionProcessingTime( stopSurfacesConstructionTime - startSurfacesConstructionTime ); LOGGER.debug( "Finalizing : {} surfaces", this.getSurfaces().size() ); diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/SecondRoundConstruction.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/SecondRoundConstruction.java index 42f483b9212a0b038f2bf9770543f2899455393e..7fbf3ed3b78b1263208a564abed65dda2bc895a1 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/SecondRoundConstruction.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/SecondRoundConstruction.java @@ -98,7 +98,9 @@ public class SecondRoundConstruction extends ConstructionRound if ( surface.hasDuplicate() )// CoordinateList instead of Coordinate { LOGGER.debug( "Surface with duplicates to process." ); + Pixels[][] maximums = rebuildMaximums( surface ); + int surfaceMaxSize = maximums.length * maximums[0].length; /* OSE construction according to the dimension considered */ long startOseConstructionTime = System.currentTimeMillis(); OSEListArray oseLists = constructOSE( maximums ); @@ -107,7 +109,7 @@ public class SecondRoundConstruction extends ConstructionRound int lineLength = maximums[ 0 ].length; long startSurfacesConstructionTime = System.currentTimeMillis(); - ArrayList< Surface > temps = constructSurfaces( oseLists, lineLength ); + ArrayList< Surface > temps = constructSurfaces( oseLists, lineLength, surfaceMaxSize); long stopSurfacesConstructionTime = System.currentTimeMillis(); tempSurfaceTime += stopSurfacesConstructionTime - startSurfacesConstructionTime; if ( temps.isEmpty() ) diff --git a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/surface/SurfacesConstruction.java b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/surface/SurfacesConstruction.java index 76ce149004f12f086136b4019d8ff73ef8319f20..a2a5ceef57708a29153feabc4fb4ee08b0085a5f 100644 --- a/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/surface/SurfacesConstruction.java +++ b/src/main/java/fr/pasteur/ida/zellige/steps/construction/rounds/surface/SurfacesConstruction.java @@ -53,19 +53,21 @@ public class SurfacesConstruction private final int overlap; private int smallSurfaceCount; private final double surfaceMinSizeFactor; + private final int surfaceMaxSize; - public SurfacesConstruction( OSEListArray oseLists, int width, int overlap, double connexity, double surfaceMinSizeFactor ) + public SurfacesConstruction( OSEListArray oseLists, int width, int overlap, double connexity, double surfaceMinSizeFactor, int surfaceMaxSize ) { this.oseListArray = oseLists; this.width = width; this.connexity = connexity; this.overlap = overlap; this.surfaceMinSizeFactor = surfaceMinSizeFactor; + this.surfaceMaxSize = surfaceMaxSize; } - public static ArrayList< Surface > run( OSEListArray oseListArray, int surfaceLineLength, int overlap, double connexity, double surfaceMinSizeFactor ) + public static ArrayList< Surface > run( OSEListArray oseListArray, int width, int overlap, double connexity, double surfaceMinSizeFactor, int surfaceMaxSize ) { - SurfacesConstruction reconstruction = new SurfacesConstruction( oseListArray, surfaceLineLength, overlap, connexity, surfaceMinSizeFactor ); + SurfacesConstruction reconstruction = new SurfacesConstruction( oseListArray, width, overlap, connexity, surfaceMinSizeFactor, surfaceMaxSize ); reconstruction.buildAllSurfaces(); return reconstruction.constructedSurfaces; } @@ -73,6 +75,7 @@ public class SurfacesConstruction public void buildAllSurfaces() { + LOGGER.debug("Surface min size= {}", surfaceMaxSize * surfaceMinSizeFactor ); while ( true ) { // All the OSLists are set to "not visited". @@ -97,9 +100,10 @@ public class SurfacesConstruction * @param surface the surface to check. */ private void checkSurface( Surface surface ) - { - if ( surface.getSize() >= width * oseListArray.getLength() * surfaceMinSizeFactor ) + {LOGGER.debug("****************Surface size = {}", surface.getSize()); + if ( surface.getSize() >= surfaceMaxSize * surfaceMinSizeFactor ) { + constructedSurfaces.add( surface ); } else