<commit_before>#+SETUPFILE: "setup.org"
#+TITLE:          thi.ng/morphogen

* About the project
** Injected properties                                             :noexport:
#+BEGIN_SRC clojure :exports none :noweb-ref version
0.1.0-SNAPSHOT
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb-ref project-url
https://github.com/thi-ng/morphogen
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb-ref gen-source-path
target/classes
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb-ref gen-test-path
target/test-classes
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb yes :noweb-ref cljs-artefact-path
target/morphogen-<<version>>.js
#+END_SRC

** TODO Overview

3D form evolution through treebased transformations

** Status

ALPHA quality, work in progress

** TODO Example usage

#+BEGIN_SRC clojure
  (require 'thi.ng.morphogen.core)

  ;; TODO some magic
#+END_SRC

** License

This project is open source and licensed under the [[http://www.apache.org/licenses/LICENSE-2.0][Apache Software License 2.0]].

** Dependencies
*** Runtime
**** [[https://github.com/clojure/clojure][Clojure]]
#+BEGIN_SRC clojure :noweb-ref dep-clj
[org.clojure/clojure "1.6.0-RC1"]
#+END_SRC
**** [[https://github.com/clojure/clojurescript][ClojureScript]]
#+BEGIN_SRC clojure :noweb-ref dep-cljs
[org.clojure/clojurescript "0.0-2156"]
#+END_SRC
**** [[https://github.com/thi-ng/geom][thi.ng/geom]]
#+BEGIN_SRC clojure :noweb-ref dep-geom
[thi.ng/geom "0.2.1-SNAPSHOT"]
#+END_SRC

*** Development
**** [[https://github.com/cemerick/austin][Austin]]
#+BEGIN_SRC clojure :noweb-ref dep-austin
[com.cemerick/austin "0.1.4"]
#+END_SRC
**** [[https://github.com/lynaghk/cljx][Cljx]]
#+BEGIN_SRC clojure :noweb-ref dep-cljx
[com.keminglabs/cljx "0.3.2"]
#+END_SRC
**** [[https://github.com/hugoduncan/criterium][Criterium]]
#+BEGIN_SRC clojure :noweb-ref dep-criterium
[criterium "0.4.1"]
#+END_SRC
**** [[https://github.com/cemerick/clojurescript.test][clojurescript.test]]
#+BEGIN_SRC clojure :noweb-ref dep-cljs-test
[com.cemerick/clojurescript.test "0.2.2"]
#+END_SRC
**** [[https://github.com/emezeske/lein-cljsbuild][Cljsbuild]]
#+BEGIN_SRC clojure :noweb-ref dep-cljsbuild
[lein-cljsbuild "1.0.2"]
#+END_SRC

** Contributors

| *Name*          | *Role*                          | *Website*                  |
|-----------------+---------------------------------+----------------------------|
| [[<EMAIL>][<NAME>]] | initiator & principal developer | http://postspectacular.com |
|                 |                                 | http://thi.ng              |

** Release history

| *Version* | *Released* | *Description*      | *Lein coordinates*           | *Tagged Github URL* |
|-----------+------------+--------------------+------------------------------+---------------------|
|     0.1.0 | pending    | 1st public release | =[thi.ng/morphogen "0.1.0"]= |                     |

** Leiningen coordinates
#+BEGIN_SRC clojure :noweb yes :noweb-ref lein-coords
  [thi.ng/morphogen <<version>>]
#+END_SRC

** Building this project

This project is written in a literate programming format and requires
[[https://www.gnu.org/software/emacs/][Emacs]] & [[http://orgmode.org][Org-mode]] to generate usable source code in [[https://github.com/lynaghk/cljx][CLJX]] form. Assuming
both tools are installed, the easiest way to generate a working
project is via command line (make sure =emacs= is on your path or else
edit its path in =tangle.sh=):

#+BEGIN_SRC bash
  git clone https://github.com/thi-ng/morphogen.git
  cd morphogen
  ./tangle.sh src/*.org test/*.org
#+END_SRC

Tangling is the process of extracting & combining source blocks from
=.org= files into an actual working project/source tree. This project
currently consists of 26 namespaces and 6500+ lines of code, the
tangling of which takes approx. 20 secs.

Once tangling is complete, you can =cd= into the generated project
directory (=babel=) and then use =lein= as usual.

*** Testing

The =project.clj= file defines an alias to trigger a complete build &
tests for both CLJ & CLJS versions.

#+BEGIN_SRC bash
  cd babel
  lein cleantest
#+END_SRC

To build the Clojurescript version simply run =lein cljsbuild test=
from the same directory. A small HTML harness for the resulting JS
file is also located in that folder (=babel/index.html=), allowing for
further experimentation in the browser.

*** Working with the REPL

Since the generated =project.clj= (see below) includes REPL hooks for
CLJX, editing files in Org-mode, then re-loading & testing changes is
quite trivial. Simply launch a REPL (via =lein= or Emacs) as usual.
Everytime you've made changes to an =.org= file, re-tangle it from
Emacs (=C-c C-v t=) or =tangle.sh=, then reload the namespace in the
REPL via =(require 'thi.ng.morphogen... :reload)= or similar.

** Leiningen project file                                          :noexport:
#+BEGIN_SRC clojure :tangle ../babel/project.clj :noweb yes :mkdirp yes :padline no
  (defproject thi.ng/morphogen "<<version>>"
    :description "3d form evolution through treebased transformations"
    :url "<<project-url>>"
    :license {:name "Apache Software License 2.0"
	      :url "http://www.apache.org/licenses/LICENSE-2.0"}
    :dependencies [<<dep-clj>>
		   <<dep-geom>>]

    :source-paths ["src/cljx"]
    :test-paths ["<<gen-test-path>>"]

    :profiles {:dev {:dependencies [<<dep-cljs>>
				    <<dep-criterium>>]
		     :plugins [<<dep-cljx>>
			       <<dep-cljsbuild>>
			       <<dep-cljs-test>>
			       <<dep-austin>>]
		     :hooks [cljx.hooks]
		     :aliases {"cleantest" ["do" "clean," "test," "cljsbuild" "test"]}}}

    :cljx {:builds [{:source-paths ["src/cljx"]
		     :output-path "<<gen-source-path>>"
		     :rules :clj}
		    {:source-paths ["src/cljx"]
		     :output-path "<<gen-source-path>>"
		     :rules :cljs}
		    {:source-paths ["test/cljx"]
		     :output-path "<<gen-test-path>>"
		     :rules :clj}
		    {:source-paths ["test/cljx"]
		     :output-path "<<gen-test-path>>"
		     :rules :cljs}]}

    :cljsbuild {:builds [{:source-paths ["<<gen-source-path>>" "<<gen-test-path>>"]
			  :id "simple"
			  :compiler {:output-to "<<cljs-artefact-path>>"
				     :optimizations :whitespace
				     :pretty-print true}}]
		:test-commands {"unit-tests" ["phantomjs" :runner "<<cljs-artefact-path>>"]}})
#+END_SRC

** ClojureScript HTML harness                                      :noexport:
#+BEGIN_SRC html :tangle ../babel/index.html :noweb yes :mkdirp yes :padline no
  <!DOCTYPE html5>
  <html lang="en">
    <head>
      <title><<lein-coords>> test</title>
    </head>
    <body>
      <script type="text/javascript" src="<<cljs-artefact-path>>"></script>
    </body>
  </html>
#+END_SRC
** Accessing library version during runtime<commit_msg>add project overview, add luxor as dev dependency, cleanup formatting<commit_after>#+SETUPFILE: "setup.org"
#+TITLE:          thi.ng/morphogen

* About the project
** Injected properties                                             :noexport:
#+BEGIN_SRC clojure :exports none :noweb-ref version
0.1.0-SNAPSHOT
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb-ref project-url
https://github.com/thi-ng/morphogen
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb-ref gen-source-path
target/classes
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb-ref gen-test-path
target/test-classes
#+END_SRC
#+BEGIN_SRC clojure :exports none :noweb yes :noweb-ref cljs-artefact-path
target/morphogen-<<version>>.js
#+END_SRC

** Overview

Declarative 3D form evolution through tree-based transformations.

[[../assets/img/20140321-morphogen-1300spp-agfa-optima200.jpg]]

This project is part of the [[https://github.com/thi-ng/][thi.ng]] collection of Clojure &
Clojurescript libraries and is written in a literate programming
style. Building on top of its sister [[https://github.com/thi-ng/geom][geom]] library, *morphogen*
provides a set of extensible building blocks to generate complex 3d
structures in a declarative style. [[http://en.wikipedia.org/wiki/Morphogenesis][Morphogensis]], as one of the
fundamental processes in developmental biology, is used as the guiding
metaphor for the design approach and the tools defined in this
library: A purposely small number of spatial transformers (currently
only: subdivision, reflection, extrusion) can be encoded as a
(potentially) deeply nested tree and are then recursively applied to a
single, basic 3d seed form (e.g. a cube) to evolve it. This tree of
operators fulfills a similar role as DNA does in nature, but can also
be understood as the AST of a program. The operators themselves are
context free, i.e. they have no direct relationship to the geometric
elements they operate on, nor do they need to be aware of their
position in the tree. In fact, the tree of operators is entirely
distinct from any geometries. When the tree is walked & applied to the
seed form, a second tree of mesh elements is being constructed.
Technically, the operators are pure functions, simply producing a
sequence of new geometry nodes. This combination enables the
declarative approach to tree building and the formulation, extraction
and injection of sub-trees and therefore the definition of a re-usable
vocabulary of higher order operators, with the intention to include
some of them in the library as development progresses.

A more detailed description of all elements and the overall
architecture can be found in the [[file:core.org][core namespace]] of this library.

** Status

ALPHA quality, work in progress. This project is actively being worked
on and will receive daily updates over the next couple of months.

** Example usage

Again, since operators are only depending on the basic topology (but
*not* the position, size or orientation) of the seed form, even this
small number of operators can already produce a vast number of
outcomes. The repo contains a [[file:examples.org][file with documented examples]] which can
be run from the REPL and export meshes in Stanford PLY format.

** License

This project is open source and licensed under the [[http://www.apache.org/licenses/LICENSE-2.0][Apache Software License 2.0]].

** Dependencies
*** Runtime
**** [[https://github.com/clojure/clojure][Clojure]]
#+BEGIN_SRC clojure :noweb-ref dep-clj
[org.clojure/clojure "1.6.0-RC1"]
#+END_SRC
**** [[https://github.com/clojure/clojurescript][ClojureScript]]
#+BEGIN_SRC clojure :noweb-ref dep-cljs
[org.clojure/clojurescript "0.0-2156"]
#+END_SRC
**** [[https://github.com/thi-ng/geom][thi.ng/geom]]
#+BEGIN_SRC clojure :noweb-ref dep-geom
[thi.ng/geom "0.2.1-SNAPSHOT"]
#+END_SRC

*** Development
**** [[https://github.com/thi-ng/luxor][thi.ng/luxor]]
#+BEGIN_SRC clojure :noweb-ref dep-luxor
[thi.ng/luxor "0.2.1-SNAPSHOT"]
#+END_SRC
**** [[https://github.com/cemerick/austin][Austin]]
#+BEGIN_SRC clojure :noweb-ref dep-austin
[com.cemerick/austin "0.1.4"]
#+END_SRC
**** [[https://github.com/lynaghk/cljx][Cljx]]
#+BEGIN_SRC clojure :noweb-ref dep-cljx
[com.keminglabs/cljx "0.3.2"]
#+END_SRC
**** [[https://github.com/hugoduncan/criterium][Criterium]]
#+BEGIN_SRC clojure :noweb-ref dep-criterium
[criterium "0.4.1"]
#+END_SRC
**** [[https://github.com/cemerick/clojurescript.test][clojurescript.test]]
#+BEGIN_SRC clojure :noweb-ref dep-cljs-test
[com.cemerick/clojurescript.test "0.2.2"]
#+END_SRC
**** [[https://github.com/emezeske/lein-cljsbuild][Cljsbuild]]
#+BEGIN_SRC clojure :noweb-ref dep-cljsbuild
[lein-cljsbuild "1.0.2"]
#+END_SRC

** Contributors

| *Name*          | *Role*                          | *Website*                  |
|-----------------+---------------------------------+----------------------------|
| [[<EMAIL>][<NAME>]] | initiator & principal developer | http://postspectacular.com |
|                 |                                 | http://thi.ng              |

** Release history

| *Version* | *Released* | *Description*      | *Lein coordinates*           | *Tagged Github URL* |
|-----------+------------+--------------------+------------------------------+---------------------|
|     0.1.0 | pending    | 1st public release | =[thi.ng/morphogen "0.1.0"]= |                     |

** Leiningen coordinates
#+BEGIN_SRC clojure :noweb yes :noweb-ref lein-coords
  [thi.ng/morphogen <<version>>]
#+END_SRC

** Building this project

This project is written in a literate programming format and requires
[[https://www.gnu.org/software/emacs/][Emacs]] & [[http://orgmode.org][Org-mode]] to generate usable source code in [[https://github.com/lynaghk/cljx][CLJX]] form. Assuming
both tools are installed, the easiest way to generate a working
project is via command line (make sure =emacs= is on your path or else
edit its path in =tangle.sh=):

#+BEGIN_SRC bash
  git clone https://github.com/thi-ng/morphogen.git
  cd morphogen
  ./tangle.sh src/*.org test/*.org
#+END_SRC

Tangling is the process of extracting & combining source blocks from
=.org= files into an actual working project/source tree. This project
currently consists of 26 namespaces and 6500+ lines of code, the
tangling of which takes approx. 20 secs.

Once tangling is complete, you can =cd= into the generated project
directory (=babel=) and then use =lein= as usual.

*** Testing

The =project.clj= file defines an alias to trigger a complete build &
tests for both CLJ & CLJS versions.

#+BEGIN_SRC bash
  cd babel
  lein cleantest
#+END_SRC

To build the Clojurescript version simply run =lein cljsbuild test=
from the same directory. A small HTML harness for the resulting JS
file is also located in that folder (=babel/index.html=), allowing for
further experimentation in the browser.

*** Working with the REPL

Since the generated =project.clj= (see below) includes REPL hooks for
CLJX, editing files in Org-mode, then re-loading & testing changes is
quite trivial. Simply launch a REPL (via =lein= or Emacs) as usual.
Everytime you've made changes to an =.org= file, re-tangle it from
Emacs (=C-c C-v t=) or =tangle.sh=, then reload the namespace in the
REPL via =(require 'thi.ng.morphogen... :reload)= or similar.

** Leiningen project file                                          :noexport:
#+BEGIN_SRC clojure :tangle ../babel/project.clj :noweb yes :mkdirp yes :padline no
  (defproject thi.ng/morphogen "<<version>>"
    :description "3d form evolution through tree-based transformations"
    :url "<<project-url>>"
    :license {:name "Apache Software License 2.0"
              :url "http://www.apache.org/licenses/LICENSE-2.0"}
    :dependencies [<<dep-clj>>
                   <<dep-geom>>]
  
    :source-paths ["src/cljx"]
    :test-paths ["<<gen-test-path>>"]
  
    :profiles {:dev {:dependencies [<<dep-luxor>>
                                    <<dep-cljs>>
                                    <<dep-criterium>>]
                     :plugins [<<dep-cljx>>
                               <<dep-cljsbuild>>
                               <<dep-cljs-test>>
                               <<dep-austin>>]
                     :hooks [cljx.hooks]
                     :aliases {"cleantest" ["do" "clean," "test," "cljsbuild" "test"]}}}
  
    :cljx {:builds [{:source-paths ["src/cljx"]
                     :output-path "<<gen-source-path>>"
                     :rules :clj}
                    {:source-paths ["src/cljx"]
                     :output-path "<<gen-source-path>>"
                     :rules :cljs}
                    {:source-paths ["test/cljx"]
                     :output-path "<<gen-test-path>>"
                     :rules :clj}
                    {:source-paths ["test/cljx"]
                     :output-path "<<gen-test-path>>"
                     :rules :cljs}]}
  
    :cljsbuild {:builds [{:source-paths ["<<gen-source-path>>" "<<gen-test-path>>"]
                          :id "simple"
                          :compiler {:output-to "<<cljs-artefact-path>>"
                                     :optimizations :whitespace
                                     :pretty-print true}}]
                :test-commands {"unit-tests" ["phantomjs" :runner "<<cljs-artefact-path>>"]}})
#+END_SRC

** ClojureScript HTML harness                                      :noexport:
#+BEGIN_SRC html :tangle ../babel/index.html :noweb yes :mkdirp yes :padline no
  <!DOCTYPE html5>
  <html lang="en">
    <head>
      <title><<lein-coords>> test</title>
    </head>
    <body>
      <script type="text/javascript" src="<<cljs-artefact-path>>"></script>
    </body>
  </html>
#+END_SRC
** Accessing library version during runtime
{'fraction_non_alphanumeric': 0.15526970450822158, 'fraction_numerical': 0.00813057460105576, 'mean_word_length': 2.8536357259761513, 'pattern_counts': {'":': 0, '<': 123, '<?xml version=': 0, '>': 123, 'https://': 27, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '451927', 'n_tokens_mistral': 5572, 'n_tokens_neox': 5228, 'n_words': 1534}