An efficient approach for synthesizing irregularly shaped patterns based on 4D arrays