            (org.gavrog.joss.dsyms.generators DefineBranching2d))
   (:gen-class))
 
+(defn minimal? [ds] (.isMinimal ds))
+
 (defn self-dual? [ds] (= ds (.dual ds)))
 
+(defn euclidean? [ds] (= (curvature ds 1) 0))
+
 (defn proto-euclidean? [ds] (>= (curvature ds 1) 0))
+
+(defn face-sizes [ds]
+  (map #(.m ds 0 1 %) (orbit-reps ds [0 1])))
+
+(defn good-face-sizes? [ds]
+  (let [t (face-sizes ds)]
+    (and (<= (count (unique t)) 2) (some #(= 3 %) t))))
 
 (defn andp [& preds]
   (fn [& args]

(ns org.gavrog.clojure.selfdual2d
  (:use (org.gavrog.clojure [util :only [unique]]
                            [delaney :only [s v size dim curvature]]))
  (:import (org.gavrog.jane.fpgroups SmallActionsIterator)
           (org.gavrog.jane.numbers Whole)
           (org.gavrog.joss.dsyms.basic DSymbol)

    (filter (andp self-dual? proto-euclidean?)
            (map #(.flat (DSCover. G %))
                 (SmallActionsIterator. (.getPresentation G) max-size false)))))

;; All self-dual, 2d euclidean tilings with only two face sizes and at least
;; one triangle.
(defn d-syms [max-size]
  (for [dset (d-sets max-size)
        dsym (lazy-seq (DefineBranching2d. dset 3 3 Whole/ZERO))
        :when ((andp self-dual? minimal? euclidean? good-face-sizes?) dsym)]
    dsym))
