/** * Determines whether two polyshapes describe the same region. * <p> * Two polyshapes are equal iff they have the same mask type, boundary type, * dimensions and vertices. * </p> * * @param polyshape1 * The first polyshape to compare. * @param polyshape2 * The second polyshape to compare. * @return True iff the polyshapes describe the same region. */ static boolean equals( final Polyshape polyshape1, final Polyshape polyshape2 ) { if ( polyshape1 == null && polyshape2 == null ) return true; if ( polyshape1 == null || polyshape2 == null || !Masks.sameTypesAndDimensions( polyshape1, polyshape2 ) ) return false; // Ensure same vertices in same order. final List< RealLocalizable > vertices1 = polyshape1.vertices(); final List< RealLocalizable > vertices2 = polyshape2.vertices(); for ( final Pair< RealLocalizable, RealLocalizable > pair : new IterablePair<>( vertices1, vertices2 ) ) if ( !Util.locationsEqual( pair.getA(), pair.getB() ) ) return false; return true; } }