diff --git a/README.md b/README.md index 02908df..cc566f1 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,24 @@ # Koebe-Lib Development Environment -The purpose of this library is to support the creation of geometric constructions in the inversive -geometry of circles on the 2-sphere. The design of the code base was heavily influenced by Sherif Ghali's [Introduction to Geometric Computing](http://www.springer.com/us/book/9781848001145). This is an excellent reference for anyone interesting in coding a geometric library and gives a good overview of the various design decisions involved. Ghali also gives plenty of companion C++ code, which we referred to for coding several of the operations on various geometric objects and the structure of the `geometry.primitives` package is in line with Ghali's suggestion for how to structure such libraries. +The purpose of this library is to support the creation of geometric constructions in the inversive geometry of circles on the 2-sphere. +The design of the code base was heavily influenced by Sherif Ghali's [Introduction to Geometric Computing](http://www.springer.com/us/book/9781848001145). +This is an excellent reference for anyone interesting in coding a geometric library and gives a good overview of the various design decisions involved. +Ghali also gives plenty of companion C++ code, which we referred to for coding several of the operations on various geometric objects and the structure of the `geometry.primitives` package is in line with Ghali's suggestion for how to structure such libraries. -# App +# App -The code base also has one application (well, there are a few dummy ones that I need to remove/clean up) that is a first version of what I hope will eventually become a [GeoGebra](http://geogebra.org)-like application for inversive geometric constructions. That is the `SphericalSketch` found in the `sketches` package. This application loads a little bare-bones Python IDE and 3D view that allows a user to create and visualize geometric constructions on the fly. Eventually we will post some sample scripts somewhere in this repository. +The code base also has one application (well, there are a few dummy ones that I need to remove/clean up) that is a first version of what I hope will eventually become a [GeoGebra](http://geogebra.org)-like application for inversive geometric constructions. +That is the `SphericalSketch` found in the `sketches` package. +This application loads a little bare-bones Python IDE and 3D view that allows a user to create and visualize geometric constructions on the fly. +Eventually we will post some sample scripts somewhere in this repository. -# Codebase +# Codebase -This is a _very_ alpha-level release. I'm just getting started with this code base, and have some ideas for applications to build on top of it, but I decided to go ahead and release it, because some others are starting to use the code base and thus there needs to be a public repository. +This is a _very_ alpha-level release. +I'm just getting started with this code base, and have some ideas for applications to build on top of it, but I decided to go ahead and release it, because some others are starting to use the code base and thus there needs to be a public repository. -The codebase is written in Kotlin and is developed in JetBrain’s IDEA IntelliJ. - -Here is a set-up guide for getting a development environment up and running. - -The codebase has some weird dependencies. -They are all managed with Gradle and do not need to be retreived manually. +The codebase is written in Kotlin and is developed in JetBrain’s IntelliJ IDEA. +There are some weird dependencies, but they are all managed with Gradle and do not need to be retreived manually. - cpcore.jar 2.8 - Extracted from CirclePack [link](http://www.math.utk.edu/%7Ekens/CirclePack/downloads/) - jython-standalone 2.7.0 - [link](http://www.jython.org/downloads.html) @@ -26,70 +28,69 @@ They are all managed with Gradle and do not need to be retreived manually. - processing-core 3.3.6 - [link](https://processing.org/download/) - antlr4 4.7.1 - [link](https://www.antlr.org/download.html) -I have also included an ArcBall class that was converted to Kotlin and lightly modified. The -original can be found [here](https://github.com/RandomEtc/processing-arcball/). - -# Setting up the dev-environment. - -Dependency gathering and building is done with Gradle. -A local installation can be used, or a Gradle wrapper is available in the bin directory. -To use the wrapper substitute `../bin/gradlew` for `gradle` in the steps below. - -## Method 1: IntelliJ Project - -The goal of this method is to easily retrieve all dependency JARs and register them as dependencies in the IntelliJ project. -Building and Running is all done through IntelliJ's systems. - -### Step 1: Download dependencies -1. Clone the repo -2. In the `lib` directory run `gradle all` -3. This will download all dependencies to `/lib/jar` - -### Step 2: Create a new IntelliJ Project -1. Create a new project -2. Select 'Kotlin' in the left pane and 'Kotlin (JVM)' and click 'Next' -3. Name the project whatever you want, like 'Koebe-Lib' -4. Change the project location to the cloned repo and click 'Finish' - -### Step 3: Add dependencies to project -1. Open Project Structure dialog (Command+; or Ctrl+Shift+Alt+S) -2. Click 'Modules' and open the Dependencies tab -3. Click '+' and select 'JARs or directories...' -4. Select the `/lib/jar` folder -5. Click the 'Export' checkbox and click 'Apply' and 'OK' - -### Step 4: Create a runtime configuration. -1. Right click on the the `src/sketches/SphericalSketch.kt` file -2. Select the Run option - -## Method 2: Standalone Gradle build - -The goal of this method is to allow for building and running without using IntelliJ. - -### Configuration -All standalone building is done in the builder directory. -Configuration options are available in `settings.gradle` - -### Option 1: Build a JAR -1. From the `builder` directory run `gradle jar` -2. A standalone executable JAR will be built in `build/lib/koebelib.jar` -3. This can be run with `java -jar build/lib/koebelib.jar` - -### Option 2: Package a Distribution -1. From the `builder` directory run `gradle build` -2. A tarball and a zip file distribution will be built in `build/distibutions/koebelib.tar|zip` - -### Option 3: Install a Distribution -1. From the `builder` directory run `gradle install` -2. A distribution will be installed in `build/install/koebelib` -3. This can be run with the start script at `build/install/koebelib/bin/koebelib` - -### Option 4: Just compile (cannot be run) -1. From the `builder` directory run `gradle compileKotlin` - -#### Notes: -Because of how Gradle handles dependencies we cannot run the program from a gradle build -that has not been bundled in some form (ie options 1-3 above). -Attempting to use `gradle run` or other methods may result in missing native libraries. +I have also included an ArcBall class that was converted to Kotlin and lightly modified. The +original can be found [here](https://github.com/RandomEtc/processing-arcball/). + +# The dev-environment. + +Building and run configuration is all done through Gradle. +For use with IntelliJ IDEA the project should be imported as a Gradle project and built/run using the Gradle tasks. +Debugging through IntelliJ IDEA works as normal for Gradle tasks. +Tasks can be run with a local installation of Gradle, or using the included Gradle wrapper. +To use the wrapper substitute `./gradlew` for `gradle` in the examples below. + +### Configuration of run tasks +Configuration options are available in `settings.gradle` +Run configurations for new main classes can be created there. + +## Gradle tasks +Clone the repo. All Gradle tasks are run from the root of the repository. +View available tasks with the `gradle tasks` command. +The main tasks to use are described below. + +### Compile Kotlin +Run `gradle compileKotlin` +This compiles the source code with no additional actions taken. +This can be useful when just checking for compiler errors, but is generally not needed. + +### Generate ANTLR Grammar Sources +Run `gradle generateGrammarSource` +This will run ANTLR to generate source files for grammars in the `src/main/antlr/main` directory. +The files will be placed in `build/generated-src/antlr/main` if needed for reference. +This task is automatically run when compiling to make the ANTLR source available to the build. + +### Run the application +There are several run configurations available of the form `gradle run` +Each builds the application and runs their respective main class. + +### Build a JAR for distribution +Run `gradle jar` +A standalone executable 'fat' jar will be built in `build/lib/koebelib.jar` +This jar should be suitable for distribution as it includes all dependencies. +It can be run with `java -jar build/lib/koebelib.jar` +The main class is specified in `settings.gradle` or with the `-Pmain=` argument. + +### Cleanup the build directory +Run `gradle clean` +The build directory will be deleted. + +## Using IntelliJ IDEA + +1. Clone the repo. +2. Select import project in IntelliJ. +3. Select the `build.gradle` file from the cloned repo. +4. Configure import options. + - Check 'Use auto-import'. + - Uncheck 'Create separate module per source set' + - Select 'Use default gradle wrapper' or 'Use local gradle distribution' +5. Open the Gradle tool window. + - View > Tool Windows > Gradle +6. Select a run configuration + - Tasks > koebelib > run\ + +**_Disclaimer_** +Building the application and creating run configurations with IntelliJ's native tools may work. +It is, however, not supported and is not guaranteed to work in all cases. #koebe-lib + diff --git a/bin/gradle/wrapper/gradle-wrapper.jar b/bin/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 01b8bf6..0000000 Binary files a/bin/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e907781 --- /dev/null +++ b/build.gradle @@ -0,0 +1,95 @@ +plugins { + id 'com.google.osdetector' version '1.4.0' + id 'org.jetbrains.kotlin.jvm' version '1.3.21' + id 'antlr' +} + +// Set the main class for application and jar building +// - set in settings.gradle or +// defined with -Pmain= in build command +ext.mainClassName = project.findProperty('main') ?: gradle.ext.defaultClassName + +// Use maven central repository for dependencies +repositories { + mavenCentral() +} + +dependencies { + // Kotlin standard library + compile 'org.jetbrains.kotlin:kotlin-stdlib:1.3.21' + + // KoebeLib dependencies + compile files('lib/jar/cpcore.jar') + compile 'org.python:jython-standalone:2.7.0' + compile 'com.fifesoft:rsyntaxtextarea:2.6.1' + compile 'org.jogamp.jogl:jogl-all-main:2.3.2' + compile 'org.jogamp.gluegen:gluegen-rt-main:2.3.2' + compile ('org.processing:core:3.3.6') { + transitive = false + } + + // Antlr dependency + antlr 'org.antlr:antlr4:4.7.2' +} + +// Ensures that the lib/jar folder exists for downloading cpcore.jar +task chkLib { + doLast { + def f = new File('lib/jar/') + if (!f.exists()) { f.mkdirs() } + } +} + +// Downloads cpcore.jar on Linux systems +task get_nix(type:Exec, dependsOn:chkLib) { + workingDir 'lib/jar/' + commandLine '../getCirclePack.sh' +} + +// Downloads cpcore.jar on Windows systems +task get_win(type:Exec, dependsOn:chkLib) { + workingDir 'lib/jar/' + commandLine 'powershell', '-ExecutionPolicy', 'RemoteSigned', '-c', '../getCirclePack.ps1' +} + +// Detects operating system and downloads cpcore.jar +task get { + if (osdetector.os == 'windows') { + dependsOn get_win + } + else { + dependsOn get_nix + } +} + +// Only retrieve CirclePack cpcore.jar if not already done +def cpcore = new File('lib/jar/cpcore.jar') +get_nix.onlyIf { !cpcore.exists() } +get_win.onlyIf { !cpcore.exists() } + +// Can't compile without cpcore.jar +compileKotlin.dependsOn(get) +// Can't compile without Antlr grammar generated files +compileKotlin.dependsOn(generateGrammarSource) + +// Build a fat jar with main class defined earlier +jar { + manifest { + attributes 'Main-Class' : project.mainClassName + } + + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } +} + +// Dynamically build run configurations for configured classes +gradle.ext.drivers.each { name, className -> + tasks.register("run$name") + task "run$name" (type: JavaExec, dependsOn: jar, overwrite: true) { + description "Runs the ${name}.kt main class" + group "KoebeLib" + + main "$className" + classpath fileTree("$jar.destinationDir") + } +} + diff --git a/builder/build.gradle b/builder/build.gradle deleted file mode 100644 index 2a2c4bd..0000000 --- a/builder/build.gradle +++ /dev/null @@ -1,55 +0,0 @@ -plugins { - id 'org.jetbrains.kotlin.jvm' version '1.2.10' - id 'application' -} - -// Set the main class for application and jar building -// - set in settings.gradle or -// defined with -Pmain= in build command -mainClassName = project.findProperty('main') ?: gradle.ext.defaultClassName - -// Set default source path -sourceSets { - main.kotlin.srcDirs += '../src/' -} - -// Use maven central repository for dependencies -repositories { - mavenCentral() -} - -dependencies { - // Kotlin standard library - compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' - - // KoebeLib dependencies - compile files('../lib/jar/cpcore.jar') - compile 'org.antlr:antlr4:4.7.1' - compile 'org.python:jython-standalone:2.7.0' - compile 'com.fifesoft:rsyntaxtextarea:2.6.1' - compile 'org.jogamp.jogl:jogl-all-main:2.3.2' - compile 'org.jogamp.gluegen:gluegen-rt-main:2.3.2' - compile ('org.processing:core:3.3.6') { - transitive = false - } -} - -// Use lib gradle for downloading CirclePack cpcore.jar -task get(type:GradleBuild) { - setDir '../lib' - buildFile = '../lib/build.gradle' - tasks = ['get'] -} - -// Can't compile without cpcore.jar -compileKotlin.dependsOn(get) - -// Build jar with main class defined earlier -// Bundle all dependencies in the jar -jar { - manifest { - attributes 'Main-Class' : project['mainClassName'] - } - - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } -} diff --git a/builder/settings.gradle b/builder/settings.gradle deleted file mode 100644 index a213c6f..0000000 --- a/builder/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name='koebelib' - -// Define the default main class for the build -gradle.ext.defaultClassName = 'sketches.SphericalSketchKt' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..87b738c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/bin/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from bin/gradle/wrapper/gradle-wrapper.properties rename to gradle/wrapper/gradle-wrapper.properties index 933b647..44e7c4d 100644 --- a/bin/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip diff --git a/bin/gradlew b/gradlew similarity index 99% rename from bin/gradlew rename to gradlew index cccdd3d..af6708f 100755 --- a/bin/gradlew +++ b/gradlew @@ -28,7 +28,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" diff --git a/bin/gradlew.bat b/gradlew.bat similarity index 94% rename from bin/gradlew.bat rename to gradlew.bat index e95643d..0f8d593 100644 --- a/bin/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/lib/build.gradle b/lib/build.gradle deleted file mode 100644 index a5512ef..0000000 --- a/lib/build.gradle +++ /dev/null @@ -1,83 +0,0 @@ -plugins { - id 'com.google.osdetector' version '1.4.0' -} - -configurations { - copy -} - -repositories { - mavenCentral() -} - -// Library dependencies to download -dependencies { - copy 'org.antlr:antlr4:4.7.1' - copy 'org.python:jython-standalone:2.7.0' - copy 'com.fifesoft:rsyntaxtextarea:2.6.1' - copy 'org.jogamp.jogl:jogl-all-main:2.3.2' - copy 'org.jogamp.gluegen:gluegen-rt-main:2.3.2' - copy ('org.processing:core:3.3.6') { - transitive = false - } -} - -task chkJar { - group 'KoebeLib' - description 'Ensure that the jar directory exists' - - doLast { - def f = new File('../lib/jar') - if (!f.exists()) { f.mkdirs() } - } -} - -task get_nix(type:Exec, dependsOn:chkJar) { - group 'KoebeLib' - description 'Downloads CirclePack and extracts cpcore.jar; *nix' - - workingDir 'jar' - commandLine '../getCirclePack.sh' -} - -task get_win(type:Exec, dependsOn:chkJar) { - group 'KoebeLib' - description 'Downloads CirclePack and extracts cpcore.jar; Windows' - - workingDir 'jar' - commandLine 'powershell', '-ExecutionPolicy', 'RemoteSigned', '-c', '../getCirclePack.ps1' -} - -task get { - group 'KoebeLib' - description 'Detect OS for downloading CirclePack' - - if (osdetector.os == 'windows') { - dependsOn get_win - } - else { - dependsOn get_nix - } -} - -// Only retrieve CirclePack cpcore.jar if not alread done -def cpcore = new File('../lib/jar/cpcore.jar') -get_nix.onlyIf { !cpcore.exists() } -get_win.onlyIf { !cpcore.exists() } - -task copy(type:Copy) { - group 'KoebeLib' - description 'Copy dependencies managed in MavenCentral to jar directory' - - into './jar' - from configurations.copy -} - -// Aggregate all dependency managment -task all { - group 'KoebeLib' - description 'Downloads all dependencies to jar directory.' - - dependsOn copy - dependsOn get -} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..95dc5b4 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,13 @@ +rootProject.name='koebelib' + +// Define the default main class for the build +gradle.ext.defaultClassName = 'sketches.SphericalSketchKt' + +// Define the main classes that will have run tasks generated +gradle.ext.drivers = [ +// : , + "SphericalSketch": "sketches.SphericalSketchKt", + "ConstructionSketch": "sketches.ConstructionSketchKt", + "TileView": "tilings.applications.TileViewKt", + "TileSketch": "tilings.language.gui.TileSketchKt", +] diff --git a/src/geometry/construction/BasicAlgorithmsS2.kt b/src/geometry/construction/BasicAlgorithmsS2.kt deleted file mode 100644 index 1835ec7..0000000 --- a/src/geometry/construction/BasicAlgorithmsS2.kt +++ /dev/null @@ -1,58 +0,0 @@ -package geometry.construction - -import geometry.primitives.Spherical2.* - -/** - * Created by johnbowers on 5/28/17. - */ - -class ThreePointsToDiskS2() : IAlgorithm { - override fun run(node: ConstructionNode): DiskS2 { - - if (node.incoming.size != 3) - throw InvalidConstructionParametersException("ThreePointsToDiskS2 expects three PointS2s. ${node.incoming.size} given.") - - val p1 = node.incoming[0].getOutput() - val p2 = node.incoming[1].getOutput() - val p3 = node.incoming[2].getOutput() - if (p1 is PointS2 && p2 is PointS2 && p3 is PointS2) { - return DiskS2(p1, p2, p3) - } else { - throw InvalidConstructionParametersException("ThreePointsToDiskS2 expects three PointS2s.") - } - } -} - -class ThreeDisksToCPlaneS2() : IAlgorithm { - override fun run(node: ConstructionNode): CPlaneS2 { - - if (node.incoming.size != 3) - throw InvalidConstructionParametersException("ThreePointsToDiskS2 expects three PointS2s. ${node.incoming.size} given.") - - val disk1 = node.incoming[0].getOutput() - val disk2 = node.incoming[1].getOutput() - val disk3 = node.incoming[2].getOutput() - if (disk1 is DiskS2 && disk2 is DiskS2 && disk3 is DiskS2) { - return join(disk1, disk2, disk3) - } else { - throw InvalidConstructionParametersException("ThreeDisksToCPlaneS2 expects three DiskS2s.") - } - } -} - -class TwoPointsToCoaxialFamilyS2() : IAlgorithm { - override fun run(node: ConstructionNode): CoaxialFamilyS2 { - - if (node.incoming.size != 3) - throw InvalidConstructionParametersException("TwoPointsToCoaxialFamilyS2 expects two DiskS2s. ${node.incoming.size} given.") - - val disk1 = node.incoming[0].getOutput() - val disk2 = node.incoming[1].getOutput() - - if (disk1 is DiskS2 && disk2 is DiskS2) { - return CoaxialFamilyS2(disk1, disk2) - } else { - throw InvalidConstructionParametersException("TwoPointsToCoaxialFamilyS2 expects two DiskS2s.") - } - } -} \ No newline at end of file diff --git a/src/tilings/language/grammar/Escher.g4 b/src/main/antlr/tilings/language/grammar/Escher.g4 similarity index 97% rename from src/tilings/language/grammar/Escher.g4 rename to src/main/antlr/tilings/language/grammar/Escher.g4 index c656652..a7d16a8 100644 --- a/src/tilings/language/grammar/Escher.g4 +++ b/src/main/antlr/tilings/language/grammar/Escher.g4 @@ -1,5 +1,9 @@ grammar Escher ; +@header { + package tilings.language.grammar; +} + /* * Parser Rules */ diff --git a/src/com/processinghacks/arcball/Arcball.kt b/src/main/kotlin/com/processinghacks/arcball/Arcball.kt similarity index 100% rename from src/com/processinghacks/arcball/Arcball.kt rename to src/main/kotlin/com/processinghacks/arcball/Arcball.kt diff --git a/src/geometry/IO/CirclePackIO.kt b/src/main/kotlin/geometry/IO/CirclePackIO.kt similarity index 100% rename from src/geometry/IO/CirclePackIO.kt rename to src/main/kotlin/geometry/IO/CirclePackIO.kt diff --git a/src/geometry/IO/ConvexHullIO.kt b/src/main/kotlin/geometry/IO/ConvexHullIO.kt similarity index 100% rename from src/geometry/IO/ConvexHullIO.kt rename to src/main/kotlin/geometry/IO/ConvexHullIO.kt diff --git a/src/geometry/algorithms/BasicTriangulations.kt b/src/main/kotlin/geometry/algorithms/BasicTriangulations.kt similarity index 100% rename from src/geometry/algorithms/BasicTriangulations.kt rename to src/main/kotlin/geometry/algorithms/BasicTriangulations.kt diff --git a/src/geometry/algorithms/CirclePack.kt b/src/main/kotlin/geometry/algorithms/CirclePack.kt similarity index 100% rename from src/geometry/algorithms/CirclePack.kt rename to src/main/kotlin/geometry/algorithms/CirclePack.kt diff --git a/src/geometry/algorithms/ConvexHull.kt b/src/main/kotlin/geometry/algorithms/ConvexHull.kt similarity index 100% rename from src/geometry/algorithms/ConvexHull.kt rename to src/main/kotlin/geometry/algorithms/ConvexHull.kt diff --git a/src/geometry/algorithms/IncrementalConvexHull.kt b/src/main/kotlin/geometry/algorithms/IncrementalConvexHull.kt similarity index 100% rename from src/geometry/algorithms/IncrementalConvexHull.kt rename to src/main/kotlin/geometry/algorithms/IncrementalConvexHull.kt diff --git a/src/geometry/algorithms/InversiveVoronoi.kt b/src/main/kotlin/geometry/algorithms/InversiveVoronoi.kt similarity index 100% rename from src/geometry/algorithms/InversiveVoronoi.kt rename to src/main/kotlin/geometry/algorithms/InversiveVoronoi.kt diff --git a/src/geometry/algorithms/SoapBubbles.kt b/src/main/kotlin/geometry/algorithms/SoapBubbles.kt similarity index 100% rename from src/geometry/algorithms/SoapBubbles.kt rename to src/main/kotlin/geometry/algorithms/SoapBubbles.kt diff --git a/src/main/kotlin/geometry/construction/BasicAlgorithmsS2.kt b/src/main/kotlin/geometry/construction/BasicAlgorithmsS2.kt new file mode 100644 index 0000000..0635529 --- /dev/null +++ b/src/main/kotlin/geometry/construction/BasicAlgorithmsS2.kt @@ -0,0 +1,181 @@ +package geometry.construction + +import geometry.primitives.Euclidean3.VectorE3 +import geometry.primitives.Spherical2.* +import geometry.primitives.OrientedProjective3.LineOP3 +import java.awt.Point + +/** + * Created by johnbowers on 5/28/17. + */ + +class ThreePointsToDiskS2() : IAlgorithm { + override fun run(node: ConstructionNode): DiskS2 { + + if (node.incoming.size != 3) + throw InvalidConstructionParametersException("ThreePointsToDiskS2 expects three PointS2s. ${node.incoming.size} given.") + + val p1 = node.incoming[0].getOutput() + val p2 = node.incoming[1].getOutput() + val p3 = node.incoming[2].getOutput() + if (p1 is PointS2 && p2 is PointS2 && p3 is PointS2) { + return DiskS2(p1, p2, p3) + } else { + throw InvalidConstructionParametersException("ThreePointsToDiskS2 expects three PointS2s.") + } + } +} + +class ThreeDisksToCPlaneS2() : IAlgorithm { + override fun run(node: ConstructionNode): CPlaneS2 { + + if (node.incoming.size != 3) + throw InvalidConstructionParametersException("ThreePointsToDiskS2 expects three PointS2s. ${node.incoming.size} given.") + + val disk1 = node.incoming[0].getOutput() + val disk2 = node.incoming[1].getOutput() + val disk3 = node.incoming[2].getOutput() + if (disk1 is DiskS2 && disk2 is DiskS2 && disk3 is DiskS2) { + return join(disk1, disk2, disk3) + } else { + throw InvalidConstructionParametersException("ThreeDisksToCPlaneS2 expects three DiskS2s.") + } + } +} + +class TwoPointsToCoaxialFamilyS2() : IAlgorithm { + override fun run(node: ConstructionNode): CoaxialFamilyS2 { + + if (node.incoming.size != 3) + throw InvalidConstructionParametersException("TwoPointsToCoaxialFamilyS2 expects two DiskS2s. ${node.incoming.size} given.") + + val disk1 = node.incoming[0].getOutput() + val disk2 = node.incoming[1].getOutput() + + if (disk1 is DiskS2 && disk2 is DiskS2) { + return CoaxialFamilyS2(disk1, disk2) + } else { + throw InvalidConstructionParametersException("TwoPointsToCoaxialFamilyS2 expects two DiskS2s.") + } + } +} + +class TwoDisksPointCoaxialCircle() : IAlgorithm { + override fun run(node: ConstructionNode): DiskS2 { + if (node.incoming.size != 3) { + throw InvalidConstructionParametersException("TwoDisksPointCoaxialCircle expects two DiskS2s and one PointS2. ${node.incoming.size} given.") + + } + + val disk1 = node.incoming[0].getOutput() as DiskS2 + val disk2 = node.incoming[1].getOutput() as DiskS2 + val point = node.incoming[2].getOutput() as PointS2 + val pointVector = point.directionE3.v.normalize() + val a1 = disk1.a + val b1 = disk1.b + val c1 = disk1.c + val d1 = disk1.d + val a2 = disk2.a + val b2 = disk2.b + val c2 = disk2.c + val d2 = disk2.d + val x = pointVector.x + val y = pointVector.y + val z = pointVector.z + val w = 1 + + val a = a2 * (d1 * w + b1 * y + c1 * z) - a1 * (d2 * w + b2 * y + c2 * z) + val b = b2 * (d1 * w + a1 * x + c1 * z) - b1 * (d2 * w + a2 * x + c2 * z) + val c = c2 * (d1 * w + a1 * x + b1 * y) - c1 * (d2 * w + a2 * x + b2 * y) + val d = -a2 * d1 * x + d2 * (a1 * x + b1 * y + c1 * z) - d1 * (b2 * y + c2 * z) + + return DiskS2(a, b, c, d) + } +} + +//class TwoDisksIntersectionLine() : IAlgorithm { +// override fun run(node: ConstructionNode): LineOP3 { +// if (node.incoming.size != 3) { +// throw InvalidConstructionParametersException("TwoDisksPointHyperbolicCircle expects two DiskS2s and one PointS2. ${node.incoming.size} given.") +// } +// +// return LineOP3(0.0, 0.0, 0.0, 0.0) +// } +//} + +class TwoDisksIntersectionPoint() : IAlgorithm> { + override fun run(node: ConstructionNode>): List { + if (node.incoming.size < 2) { + throw InvalidConstructionParametersException("TwoDisksIntersectionPoint expects two DiskS2s. ${node.incoming.size} given.") + } + + val disk1 = node.incoming[0].getOutput() as DiskS2 + val disk2 = node.incoming[1].getOutput() as DiskS2 + + //disk1.dualPlaneOP3 + //disk2.dualPlaneOP3 + var isectPoints = LineOP3(disk1.dualPlaneOP3, disk2.dualPlaneOP3).getIntersectionWithUnit2Sphere().map { + p -> PointS2(p.toVectorE3()) + } + return isectPoints +// val disk1Normal = VectorE3(disk1.a, disk1.b, disk1.c) +// System.out.println("disk1Norm " + disk1Normal.x + " " + disk1Normal.y + " " + disk1Normal.z) +// val disk2Normal = VectorE3(disk2.a, disk2.b, disk2.c) +// System.out.println("disk2Norm " + disk2Normal.x + " " + disk2Normal.y + " " + disk2Normal.z) +// val intersectionNormal = disk1Normal.cross(disk2Normal) +// System.out.println("intersectNorm " + intersectionNormal.x + " " + intersectionNormal.y + " " + intersectionNormal.z) +// val point = pointOnPlanes(disk1, disk2) +// System.out.println("point " + point.x + " " + point.y + " " + point.z) +// +// val tValues = solveForTValues(intersectionNormal, point) +// +// val point1 = PointS2(point.x + tValues[0]*intersectionNormal.x, point.y + tValues[0]*intersectionNormal.y, +// point.z + tValues[0]*intersectionNormal.z) +// +// +// val point2 = PointS2(point.x + tValues[1]*intersectionNormal.x, point.y + tValues[1]*intersectionNormal.y, +// point.z + tValues[1]*intersectionNormal.z) +// +// var list = listOf(point1, point2) +// return list + + + } + + fun solveForTValues(intersectionNormal : VectorE3, point : PointS2) : MutableList{ + val bCoefficient = (2*point.x*intersectionNormal.x + 2*point.y*intersectionNormal.y + 2*point.z*intersectionNormal.z) + System.out.println("b " + bCoefficient) + val aCoefficient = intersectionNormal.x*intersectionNormal.x + intersectionNormal.y*intersectionNormal.y + + intersectionNormal.z*intersectionNormal.z + System.out.println("a " + aCoefficient) + val cCoefficient = point.x*point.x + point.y*point.y + point.z*point.z - 1 + System.out.println("c " + cCoefficient) + val denom = 2*aCoefficient + System.out.println("denom " + denom) + + var t1Numerator = -bCoefficient + Math.sqrt(Math.pow(bCoefficient,2.0) - 4*aCoefficient*cCoefficient) + System.out.println("t1Num " + t1Numerator ) + var t1 = t1Numerator/denom + System.out.println("t1 " + t1) + + var t2Numerator = -bCoefficient - Math.sqrt(Math.pow(bCoefficient,2.0) - 4*aCoefficient*cCoefficient) + System.out.println("t2Num " + t2Numerator ) + var t2 = t2Numerator/denom + System.out.println("t2 " + t2) + + var list = mutableListOf() + list.add(t1) + list.add(t2) + + return list + } + fun pointOnPlanes(disk1 : DiskS2, disk2 : DiskS2): PointS2 { + var numerator = -1*(disk1.d*disk2.a + disk1.a*disk2.d) + var denom = -1*(disk1.a*disk2.b + disk1.b*disk2.a) + var y = numerator/denom + var x = (-disk1.d - disk1.b*y)/disk1.a + + return PointS2(x, y, 0.0) + } + +} \ No newline at end of file diff --git a/src/geometry/construction/Construction.kt b/src/main/kotlin/geometry/construction/Construction.kt similarity index 70% rename from src/geometry/construction/Construction.kt rename to src/main/kotlin/geometry/construction/Construction.kt index dc9f222..c055e47 100644 --- a/src/geometry/construction/Construction.kt +++ b/src/main/kotlin/geometry/construction/Construction.kt @@ -22,25 +22,33 @@ class Construction { /** * @return The actual geometric objects used in this construction. These are sorted topologically based on construction dependencies. */ - fun getGeometricObjects() : MutableList { + fun getGeometricObjects(styles: HashMap? = null) : MutableList { val objList = mutableListOf() nodes.forEach { it.visited = false } - getSourceNodes().forEach { it.visit(objList) } + getSourceNodes().forEach { it.visit(objList, styles) } return objList } // Base constructions - fun makePointS2(x: Double, y: Double, z:Double) = BaseNode(this, PointS2(x, y, z)) + fun makePointS2(x: Double, y: Double, z:Double, style:Any? = null) = BaseNode(this, PointS2(x, y, z), style) // Other constructions fun makeDiskS2(p1: INode, p2: INode, p3: INode) = - ConstructionNode(this, listOf(p1, p2, p3), ThreePointsToDiskS2()) + ConstructionNode(this, listOf(p1, p2, p3), ThreePointsToDiskS2(), null) fun makeCoaxialFamilyS2(disk1: INode, disk2: INode) = - ConstructionNode(this, listOf(disk1, disk2), TwoPointsToCoaxialFamilyS2()) + ConstructionNode(this, listOf(disk1, disk2), TwoPointsToCoaxialFamilyS2(), null) fun makeCPlaneS2(disk1: INode, disk2: INode, disk3: INode) = - ConstructionNode(this, listOf(disk1, disk2, disk3), ThreeDisksToCPlaneS2()) + ConstructionNode(this, listOf(disk1, disk2, disk3), ThreeDisksToCPlaneS2(), null) + + fun makeIntersectionPoint(disk1: INode, disk2: INode) { + ConstructionNode>(this, listOf(disk1, disk2), TwoDisksIntersectionPoint(), null) + } + + fun makeCoaxialDisk(disk1 : INode, disk2: INode, point: INode) { + ConstructionNode(this, listOf(disk1, disk2, point), TwoDisksPointCoaxialCircle(), null) + } } @@ -50,14 +58,20 @@ interface INode { val outgoing : MutableList> var dirty : Boolean var visited : Boolean + var style : Any? fun getOutput() : OutputType - fun visit(objList: MutableList) { + fun visit(objList: MutableList, styles: HashMap? = null) { try { - objList.add(getOutput() as Any) + val geomObj = getOutput() + val style = this.style + objList.add(geomObj as Any) + if (styles != null && style != null) { + styles[geomObj] = style + } visited = true - outgoing.forEach { if (!it.visited && it.readyToOutputQ()) it.visit(objList) } + outgoing.forEach { if (!it.visited && it.readyToOutputQ()) it.visit(objList, styles) } } catch (e: InvalidConstructionParametersException) { e.printStackTrace() } @@ -70,11 +84,13 @@ interface INode { outgoing.forEach { it.dfsSetDirty() } } + } class BaseNode( override val construction: Construction, - var theObject: OutputType + var theObject: OutputType, + override var style : Any? = null ): INode { override var visited = false @@ -100,7 +116,8 @@ class BaseNode( class ConstructionNode( override val construction: Construction, val incoming: List>, - val algorithm: IAlgorithm + val algorithm: IAlgorithm, + override var style : Any? = null ): INode { override var visited = false diff --git a/src/geometry/construction/IAlgorithm.kt b/src/main/kotlin/geometry/construction/IAlgorithm.kt similarity index 100% rename from src/geometry/construction/IAlgorithm.kt rename to src/main/kotlin/geometry/construction/IAlgorithm.kt diff --git a/src/geometry/ds/dcel/DCEL.kt b/src/main/kotlin/geometry/ds/dcel/DCEL.kt similarity index 100% rename from src/geometry/ds/dcel/DCEL.kt rename to src/main/kotlin/geometry/ds/dcel/DCEL.kt diff --git a/src/geometry/ds/dcel/DCELH.kt b/src/main/kotlin/geometry/ds/dcel/DCELH.kt similarity index 100% rename from src/geometry/ds/dcel/DCELH.kt rename to src/main/kotlin/geometry/ds/dcel/DCELH.kt diff --git a/src/geometry/ds/dcel/DCEL_Operations.kt b/src/main/kotlin/geometry/ds/dcel/DCEL_Operations.kt similarity index 100% rename from src/geometry/ds/dcel/DCEL_Operations.kt rename to src/main/kotlin/geometry/ds/dcel/DCEL_Operations.kt diff --git a/src/geometry/ds/dcel/data/Basic2D.kt b/src/main/kotlin/geometry/ds/dcel/data/Basic2D.kt similarity index 100% rename from src/geometry/ds/dcel/data/Basic2D.kt rename to src/main/kotlin/geometry/ds/dcel/data/Basic2D.kt diff --git a/src/geometry/ds/dcel/io/STL.kt b/src/main/kotlin/geometry/ds/dcel/io/STL.kt similarity index 100% rename from src/geometry/ds/dcel/io/STL.kt rename to src/main/kotlin/geometry/ds/dcel/io/STL.kt diff --git a/src/geometry/origami/TwistAndShrink.kt b/src/main/kotlin/geometry/origami/TwistAndShrink.kt similarity index 100% rename from src/geometry/origami/TwistAndShrink.kt rename to src/main/kotlin/geometry/origami/TwistAndShrink.kt diff --git a/src/geometry/primitives/CommonOps.kt b/src/main/kotlin/geometry/primitives/CommonOps.kt similarity index 100% rename from src/geometry/primitives/CommonOps.kt rename to src/main/kotlin/geometry/primitives/CommonOps.kt diff --git a/src/geometry/primitives/CommonTypes.kt b/src/main/kotlin/geometry/primitives/CommonTypes.kt similarity index 100% rename from src/geometry/primitives/CommonTypes.kt rename to src/main/kotlin/geometry/primitives/CommonTypes.kt diff --git a/src/geometry/primitives/Euclidean2/BBoxE2.kt b/src/main/kotlin/geometry/primitives/Euclidean2/BBoxE2.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/BBoxE2.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/BBoxE2.kt diff --git a/src/geometry/primitives/Euclidean2/DiskE2.kt b/src/main/kotlin/geometry/primitives/Euclidean2/DiskE2.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/DiskE2.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/DiskE2.kt diff --git a/src/geometry/primitives/Euclidean2/PointE2.kt b/src/main/kotlin/geometry/primitives/Euclidean2/PointE2.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/PointE2.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/PointE2.kt diff --git a/src/geometry/primitives/Euclidean2/PolygonE2.kt b/src/main/kotlin/geometry/primitives/Euclidean2/PolygonE2.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/PolygonE2.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/PolygonE2.kt diff --git a/src/geometry/primitives/Euclidean2/Predicates.kt b/src/main/kotlin/geometry/primitives/Euclidean2/Predicates.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/Predicates.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/Predicates.kt diff --git a/src/geometry/primitives/Euclidean2/SegmentE2.kt b/src/main/kotlin/geometry/primitives/Euclidean2/SegmentE2.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/SegmentE2.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/SegmentE2.kt diff --git a/src/geometry/primitives/Euclidean2/VectorE2.kt b/src/main/kotlin/geometry/primitives/Euclidean2/VectorE2.kt similarity index 100% rename from src/geometry/primitives/Euclidean2/VectorE2.kt rename to src/main/kotlin/geometry/primitives/Euclidean2/VectorE2.kt diff --git a/src/geometry/primitives/Euclidean3/DirectionE3.kt b/src/main/kotlin/geometry/primitives/Euclidean3/DirectionE3.kt similarity index 100% rename from src/geometry/primitives/Euclidean3/DirectionE3.kt rename to src/main/kotlin/geometry/primitives/Euclidean3/DirectionE3.kt diff --git a/src/geometry/primitives/Euclidean3/DominantE3.kt b/src/main/kotlin/geometry/primitives/Euclidean3/DominantE3.kt similarity index 100% rename from src/geometry/primitives/Euclidean3/DominantE3.kt rename to src/main/kotlin/geometry/primitives/Euclidean3/DominantE3.kt diff --git a/src/geometry/primitives/Euclidean3/PlaneE3.kt b/src/main/kotlin/geometry/primitives/Euclidean3/PlaneE3.kt similarity index 100% rename from src/geometry/primitives/Euclidean3/PlaneE3.kt rename to src/main/kotlin/geometry/primitives/Euclidean3/PlaneE3.kt diff --git a/src/geometry/primitives/Euclidean3/PointE3.kt b/src/main/kotlin/geometry/primitives/Euclidean3/PointE3.kt similarity index 100% rename from src/geometry/primitives/Euclidean3/PointE3.kt rename to src/main/kotlin/geometry/primitives/Euclidean3/PointE3.kt diff --git a/src/geometry/primitives/Euclidean3/SegmentE3.kt b/src/main/kotlin/geometry/primitives/Euclidean3/SegmentE3.kt similarity index 100% rename from src/geometry/primitives/Euclidean3/SegmentE3.kt rename to src/main/kotlin/geometry/primitives/Euclidean3/SegmentE3.kt diff --git a/src/geometry/primitives/Euclidean3/VectorE3.kt b/src/main/kotlin/geometry/primitives/Euclidean3/VectorE3.kt similarity index 100% rename from src/geometry/primitives/Euclidean3/VectorE3.kt rename to src/main/kotlin/geometry/primitives/Euclidean3/VectorE3.kt diff --git a/src/geometry/primitives/ExtendedComplex/Complex.kt b/src/main/kotlin/geometry/primitives/ExtendedComplex/Complex.kt similarity index 100% rename from src/geometry/primitives/ExtendedComplex/Complex.kt rename to src/main/kotlin/geometry/primitives/ExtendedComplex/Complex.kt diff --git a/src/geometry/primitives/ExtendedComplex/ExtendedComplex.kt b/src/main/kotlin/geometry/primitives/ExtendedComplex/ExtendedComplex.kt similarity index 100% rename from src/geometry/primitives/ExtendedComplex/ExtendedComplex.kt rename to src/main/kotlin/geometry/primitives/ExtendedComplex/ExtendedComplex.kt diff --git a/src/geometry/primitives/ExtendedComplex/RiemannProjectedPoint.kt b/src/main/kotlin/geometry/primitives/ExtendedComplex/RiemannProjectedPoint.kt similarity index 100% rename from src/geometry/primitives/ExtendedComplex/RiemannProjectedPoint.kt rename to src/main/kotlin/geometry/primitives/ExtendedComplex/RiemannProjectedPoint.kt diff --git a/src/geometry/primitives/OrientedProjective2/CircleArcOP2.kt b/src/main/kotlin/geometry/primitives/OrientedProjective2/CircleArcOP2.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective2/CircleArcOP2.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective2/CircleArcOP2.kt diff --git a/src/geometry/primitives/OrientedProjective2/DiskOP2.kt b/src/main/kotlin/geometry/primitives/OrientedProjective2/DiskOP2.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective2/DiskOP2.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective2/DiskOP2.kt diff --git a/src/geometry/primitives/OrientedProjective2/LineOP2.kt b/src/main/kotlin/geometry/primitives/OrientedProjective2/LineOP2.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective2/LineOP2.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective2/LineOP2.kt diff --git a/src/geometry/primitives/OrientedProjective2/PointOP2.kt b/src/main/kotlin/geometry/primitives/OrientedProjective2/PointOP2.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective2/PointOP2.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective2/PointOP2.kt diff --git a/src/geometry/primitives/OrientedProjective2/VectorOP2.kt b/src/main/kotlin/geometry/primitives/OrientedProjective2/VectorOP2.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective2/VectorOP2.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective2/VectorOP2.kt diff --git a/src/geometry/primitives/OrientedProjective3/LineOP3.kt b/src/main/kotlin/geometry/primitives/OrientedProjective3/LineOP3.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective3/LineOP3.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective3/LineOP3.kt diff --git a/src/geometry/primitives/OrientedProjective3/PlaneOP3.kt b/src/main/kotlin/geometry/primitives/OrientedProjective3/PlaneOP3.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective3/PlaneOP3.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective3/PlaneOP3.kt diff --git a/src/geometry/primitives/OrientedProjective3/PointOP3.kt b/src/main/kotlin/geometry/primitives/OrientedProjective3/PointOP3.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective3/PointOP3.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective3/PointOP3.kt diff --git a/src/geometry/primitives/OrientedProjective3/VectorOP3.kt b/src/main/kotlin/geometry/primitives/OrientedProjective3/VectorOP3.kt similarity index 100% rename from src/geometry/primitives/OrientedProjective3/VectorOP3.kt rename to src/main/kotlin/geometry/primitives/OrientedProjective3/VectorOP3.kt diff --git a/src/geometry/primitives/Spherical2/CPlaneS2.kt b/src/main/kotlin/geometry/primitives/Spherical2/CPlaneS2.kt similarity index 100% rename from src/geometry/primitives/Spherical2/CPlaneS2.kt rename to src/main/kotlin/geometry/primitives/Spherical2/CPlaneS2.kt diff --git a/src/geometry/primitives/Spherical2/CircleArcS2.kt b/src/main/kotlin/geometry/primitives/Spherical2/CircleArcS2.kt similarity index 100% rename from src/geometry/primitives/Spherical2/CircleArcS2.kt rename to src/main/kotlin/geometry/primitives/Spherical2/CircleArcS2.kt diff --git a/src/geometry/primitives/Spherical2/CoaxialFamilyS2.kt b/src/main/kotlin/geometry/primitives/Spherical2/CoaxialFamilyS2.kt similarity index 100% rename from src/geometry/primitives/Spherical2/CoaxialFamilyS2.kt rename to src/main/kotlin/geometry/primitives/Spherical2/CoaxialFamilyS2.kt diff --git a/src/geometry/primitives/Spherical2/DiskS2.kt b/src/main/kotlin/geometry/primitives/Spherical2/DiskS2.kt similarity index 100% rename from src/geometry/primitives/Spherical2/DiskS2.kt rename to src/main/kotlin/geometry/primitives/Spherical2/DiskS2.kt diff --git a/src/geometry/primitives/Spherical2/IncidencePrimitives.kt b/src/main/kotlin/geometry/primitives/Spherical2/IncidencePrimitives.kt similarity index 100% rename from src/geometry/primitives/Spherical2/IncidencePrimitives.kt rename to src/main/kotlin/geometry/primitives/Spherical2/IncidencePrimitives.kt diff --git a/src/geometry/primitives/Spherical2/PointS2.kt b/src/main/kotlin/geometry/primitives/Spherical2/PointS2.kt similarity index 99% rename from src/geometry/primitives/Spherical2/PointS2.kt rename to src/main/kotlin/geometry/primitives/Spherical2/PointS2.kt index 02d1495..46dfddc 100644 --- a/src/geometry/primitives/Spherical2/PointS2.kt +++ b/src/main/kotlin/geometry/primitives/Spherical2/PointS2.kt @@ -19,6 +19,7 @@ class PointS2( val x: Double, val y:Double, val z:Double + ) { /* Constructors */ diff --git a/src/gui/ConstructionGUI.kt b/src/main/kotlin/gui/ConstructionGUI.kt similarity index 61% rename from src/gui/ConstructionGUI.kt rename to src/main/kotlin/gui/ConstructionGUI.kt index f558ecb..33e46d3 100644 --- a/src/gui/ConstructionGUI.kt +++ b/src/main/kotlin/gui/ConstructionGUI.kt @@ -1,10 +1,7 @@ package gui -import sketches.ConstructionSketch - import javax.swing.* import java.awt.* -import sketches.SphericalSketch import java.io.OutputStream import org.python.core.* @@ -15,8 +12,7 @@ import geometry.algorithms.* import org.fife.ui.rtextarea.* import org.fife.ui.rsyntaxtextarea.* -import sketches.ArcballTool -import sketches.PointEditorTool +import sketches.* /** * Created by browermb on 2/12/2018. @@ -28,6 +24,10 @@ class ConstructionGUI(val sketch : ConstructionSketch) : JFrame() { val arcballButton : JButton val pointButton : JButton val circleButton : JButton + val selectionButton : JButton + val intersectButton : JButton + val disksPointCoaxialDisk: JButton + val threeDiskCPlane : JButton init { // Build the GUI: @@ -44,10 +44,17 @@ class ConstructionGUI(val sketch : ConstructionSketch) : JFrame() { arcballButton = JButton("arcball") pointButton = JButton("point") circleButton = JButton("circle") + selectionButton = JButton("Select") + intersectButton = JButton("Intersection") + disksPointCoaxialDisk = JButton("CoaxialFamilyDisk") + threeDiskCPlane = JButton("3DiskCPlane") buttonFlowPanel.add(arcballButton) buttonFlowPanel.add(pointButton) buttonFlowPanel.add(circleButton) + buttonFlowPanel.add(selectionButton) + buttonFlowPanel.add(intersectButton) + buttonFlowPanel.add(disksPointCoaxialDisk) buttonPanel.add(buttonFlowPanel, BorderLayout.WEST) this.contentPane.add(buttonPanel, BorderLayout.PAGE_START) @@ -63,6 +70,22 @@ class ConstructionGUI(val sketch : ConstructionSketch) : JFrame() { circleButton.addActionListener { sketch.currentTool = PointEditorTool.CircleTool(sketch) } + + selectionButton.addActionListener { + sketch.currentTool = SelectionTool(sketch) + } + + intersectButton.addActionListener { + sketch.currentTool = IntersectionTool(sketch) + } + + disksPointCoaxialDisk.addActionListener { + sketch.currentTool = CoaxialPointTool(sketch) + } + + threeDiskCPlane.addActionListener { + sketch.currentTool = ThreeDiskCPlaneTool(sketch); + } } } diff --git a/src/gui/JythonFrame.kt b/src/main/kotlin/gui/JythonFrame.kt similarity index 100% rename from src/gui/JythonFrame.kt rename to src/main/kotlin/gui/JythonFrame.kt diff --git a/src/scripting/JythonBridge.kt b/src/main/kotlin/scripting/JythonBridge.kt similarity index 100% rename from src/scripting/JythonBridge.kt rename to src/main/kotlin/scripting/JythonBridge.kt diff --git a/src/sketches/BasicArcballSketch.kt b/src/main/kotlin/sketches/BasicArcballSketch.kt similarity index 100% rename from src/sketches/BasicArcballSketch.kt rename to src/main/kotlin/sketches/BasicArcballSketch.kt diff --git a/src/main/kotlin/sketches/ConstructionSketch.kt b/src/main/kotlin/sketches/ConstructionSketch.kt new file mode 100644 index 0000000..2aab25f --- /dev/null +++ b/src/main/kotlin/sketches/ConstructionSketch.kt @@ -0,0 +1,1207 @@ +package sketches + +import com.processinghacks.arcball.Arcball +import geometry.construction.Construction +import geometry.construction.BaseNode +import geometry.construction.INode +import geometry.ds.dcel.DCEL +import geometry.primitives.Euclidean2.DiskE2 +import geometry.primitives.Euclidean2.PointE2 +import geometry.primitives.Euclidean2.VectorE2 +import geometry.primitives.Euclidean3.DirectionE3 +import geometry.primitives.Euclidean3.PointE3 +import geometry.primitives.Euclidean3.VectorE3 +import geometry.primitives.OrientedProjective2.CircleArcOP2 +import geometry.primitives.OrientedProjective2.DiskOP2 +import geometry.primitives.OrientedProjective2.LineOP2 +import geometry.primitives.OrientedProjective2.PointOP2 +import geometry.primitives.OrientedProjective3.PointOP3 +import geometry.primitives.Spherical2.* +import geometry.primitives.inner_product +import gui.JythonFrame +import gui.ConstructionGUI +import processing.core.PApplet +import processing.event.MouseEvent + +import processing.core.PConstants +import processing.core.PGraphics.R +import processing.core.PMatrix3D +import processing.opengl.PGraphicsOpenGL +import java.awt.Button +import java.awt.Point +import java.io.PrintWriter + +import javax.swing.* + +/** + * Created by browermb on 7/27/2017. + */ + + +open class MouseTool { + var mouseDown = false + var startX = -1 + var startY = -1 + var dragged = false + + open fun mousePressed(mouseX: Int, mouseY: Int) { + mouseDown = true + dragged = false + startX = mouseX + startY = mouseY + } + + open fun mouseReleased(mouseX: Int, mouseY: Int) { + mouseDown = false + if (!dragged) { + mouseClicked(mouseX, mouseY) + } + dragged = false + } + + open fun mouseDragged(mouseX: Int, mouseY: Int) { + + } + + open fun mouseClicked(mouseX: Int, mouseY: Int) { + } + + open fun mouseMoved(mouseX: Int, mouseY: Int) { + if (mouseDown) { + val dx = mouseX - startX + val dy = mouseY - startY + + if ((dx * dx) + (dy * dy) >= 4) { + dragged = true + } + + if (dragged) { + this.mouseDragged(mouseX, mouseY) + } + } + } +} + +class ArcballTool(val arcball: Arcball?) : MouseTool() { + + override fun mousePressed(mouseX: Int, mouseY: Int) { + super.mousePressed(mouseX, mouseY) + arcball?.mousePressed() + } + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + arcball?.mousePressed() + } + override fun mouseDragged(mouseX: Int, mouseY: Int) { + arcball?.mouseDragged() + } + override fun mouseClicked(mouseX: Int, mouseY: Int) { + + } + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } +} + +class IntersectionTool(val sketch : ConstructionSketch ) : MouseTool() { + var selectedDisks = mutableListOf>() + + fun transform(mouseX: Int, mouseY: Int) : PointE3{ + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 + return inter + } else { + inter = new1 + direction * t0 + return inter + } + } + return PointE3() + } + + fun isIntersection(mouseX : Int, mouseY : Int, a : Double, b : Double, c : Double, d : Double) : Boolean { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + var rayOrigin = VectorE3(new1.x, new1.y, new1.z) + var worldOrigin = VectorE3(0.0, 0.0, 0.0) + var normalVector = VectorE3(a, b, c) + var denom = direction.dot(normalVector) + var t = ((worldOrigin - rayOrigin).dot(normalVector)) / denom + return t >= 0 + } + + return false; + } + + + override fun mousePressed(mouseX: Int, mouseY: Int) { + super.mousePressed(mouseX, mouseY) + var cursor = transform(mouseX, mouseY) + + if(cursor != null) { + for(node in sketch.construction.nodes) { + var output = node.getOutput() + if (output is DiskS2) { + var a = output.a + var b = output.b + var c = output.c + var d = output.d + if(isIntersection(mouseX, mouseY, a, b, c, d)) { + if(!selectedDisks.contains(node)) { + selectedDisks.add(node as INode) + break + } + } + } + } + } + + } + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + if(selectedDisks.size >= 2) { + var obj1 = selectedDisks[0] + var obj2 = selectedDisks[1] + sketch.construction.makeIntersectionPoint(obj1, obj2) + } + } + override fun mouseDragged(mouseX: Int, mouseY: Int) { + } + override fun mouseClicked(mouseX: Int, mouseY: Int) { + + } + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } +} +class SelectionTool(val sketch : ConstructionSketch) : MouseTool() { + fun transform(mouseX: Int, mouseY: Int) : PointE3{ + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 + return inter + } else { + inter = new1 + direction * t0 + return inter + } + } + return PointE3() + } + + fun isIntersection(mouseX : Int, mouseY : Int, a : Double, b : Double, c : Double, d : Double) : Boolean { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + var rayOrigin = VectorE3(new1.x, new1.y, new1.z) + var worldOrigin = VectorE3(0.0, 0.0, 0.0) + var normalVector = VectorE3(a, b, c) + var denom = direction.dot(normalVector) + var t = ((worldOrigin - rayOrigin).dot(normalVector)) / denom + return t >= 0 + } + + return false; + } + + + override fun mouseClicked(mouseX: Int, mouseY: Int) { + + } + + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } + + override fun mouseDragged(mouseX: Int, mouseY: Int) { + + } + + //TODO: need to get minimum distance and then set node also add a feature to select multiple things + override fun mousePressed(mouseX: Int, mouseY: Int) { + var cursor = transform(mouseX, mouseY) + + if(cursor!= null) { + for(node in sketch.construction.nodes) { + var output = node.getOutput() + if(output is PointS2) { + if (Math.abs(cursor.x.toFloat() - output.x) <= .1 + && Math.abs(cursor.y.toFloat() - output.y) <= .1 + && Math.abs(cursor.z.toFloat() - output.z) <= .1) { + //TODO: change the cursor so the point is visible when being dragged + node.style = Style(Color.noColor, Color(128.0.toFloat(), 0.0.toFloat(), 128.0.toFloat())) + break + } + } + if (output is DiskS2) { + var a = output.a + var b = output.b + var c = output.c + var d = output.d + if(isIntersection(mouseX, mouseY, a, b, c, d)) { + node.style = Style(Color(255.0.toFloat(), 255.0.toFloat(), 0.0.toFloat()), Color.noColor) + break + } + } + } + } + } + + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + } +} + +open class PointEditorTool(val sketch: ConstructionSketch) : MouseTool() { + + var selectedNode : INode<*>? = null; + + fun transform(mouseX: Int, mouseY: Int): PointE3 { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 + return inter + } else { + inter = new1 + direction * t0 + return inter + } + } + return PointE3() + } + + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } + + override fun mousePressed(mouseX: Int, mouseY: Int) { + super.mousePressed(mouseX, mouseY) + var cursor = transform(mouseX, mouseY) + if (cursor != null) { + + for (node in sketch.construction.nodes) { + if (node != null) { + var output = node.getOutput() + if (output is PointS2) { + //TODO: should change this so its the closet found point + if (Math.abs(cursor.x.toFloat() - output.x) <= .1 + && Math.abs(cursor.y.toFloat() - output.y) <= .1 + && Math.abs(cursor.z.toFloat() - output.z) <= .1) { + //TODO: change the cursor so the point is visible when being dragged + selectedNode = node + break + } + } + + } + } + } + } + + + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + } + + override fun mouseDragged(mouseX: Int, mouseY: Int) { + var cursor = transform(mouseX, mouseY) + if (cursor != null) { + var node = selectedNode + if (node is BaseNode<*>) { + node.resetBaseNodeWith(PointS2(cursor.x, cursor.y, cursor.z)) + } + } + } + override fun mouseClicked(mouseX: Int, mouseY: Int) { + var drawNode = true + var cursor = transform(mouseX, mouseY) + if (cursor != null) { + for (node in sketch.construction.nodes) { + if(node != null) { + var output = node.getOutput() + if (output is PointS2) { + //TODO: this needs to change so you get the closest one not the fist within a delta + if (Math.abs(cursor.x.toFloat() - output.x) <= .1 + && Math.abs(cursor.y.toFloat() - output.y) <= .1 + && Math.abs(cursor.z.toFloat() - output.z) <= .1) { + drawNode = false + break + } + } + } + } + if (drawNode) { + sketch.construction.makePointS2(cursor.x, cursor.y, cursor.z) + } + } + + } + + class CircleTool(val sketch: ConstructionSketch) : MouseTool() { + var selectedNode : INode<*>? = null; + var selectedNodes = mutableListOf>() + + fun transform(mouseX: Int, mouseY: Int): PointE3 { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 + return inter + } else { + inter = new1 + direction * t0 + return inter + } + } + return PointE3() + } + + + override fun mousePressed(mouseX: Int, mouseY: Int) { + super.mousePressed(mouseX, mouseY) + var cursor = transform(mouseX, mouseY) + if (cursor != null) { + for (node in sketch.construction.nodes) { + if (node != null) { + var output = node.getOutput() + if (output is PointS2) { + //TODO: should change this so its the closet found point + if (Math.abs(cursor.x.toFloat() - output.x) <= .1 + && Math.abs(cursor.y.toFloat() - output.y) <= .1 + && Math.abs(cursor.z.toFloat() - output.z) <= .1) { + + selectedNode = node + node.style = Style(Color.noColor, Color(255.0.toFloat(), 0.0.toFloat(), 0.0.toFloat())) + if(!selectedNodes.contains(selectedNode as INode<*>)) { + selectedNodes.add(selectedNode as INode<*>) + break + } + } + } + } + } + } + } + + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } + + override fun mouseClicked(mouseX: Int, mouseY: Int) { + + } + + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + if (selectedNodes.size >= 3) { + var obj1 = selectedNodes[0] + var obj2 = selectedNodes[1] + var obj3 = selectedNodes[2] + + @Suppress("UNCHECKED_CAST") + var node = sketch.construction.makeDiskS2( obj1 as INode, + obj2 as INode, + obj3 as INode) + selectedNodes.removeAll({true}) + + } + } + + } + } +open class CoaxialPointTool(val sketch: ConstructionSketch) : MouseTool() { + + var selectedNode : INode<*>? = null; + var selectedNodes = mutableListOf>() + + fun transform(mouseX: Int, mouseY: Int): PointE3 { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 + return inter + } else { + inter = new1 + direction * t0 + return inter + } + } + return PointE3() + } + + fun isIntersection(mouseX : Int, mouseY : Int, a : Double, b : Double, c : Double, d : Double) : Boolean { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + var rayOrigin = VectorE3(new1.x, new1.y, new1.z) + var worldOrigin = VectorE3(0.0, 0.0, 0.0) + var normalVector = VectorE3(a, b, c) + var denom = direction.dot(normalVector) + var t = ((worldOrigin - rayOrigin).dot(normalVector)) / denom + return t >= 0 + } + + return false; + } + + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } + + override fun mouseDragged(mouseX: Int, mouseY: Int) { + + } + + override fun mousePressed(mouseX: Int, mouseY: Int) { + super.mousePressed(mouseX, mouseY) + val cursor = transform(mouseX, mouseY) + if (cursor != null) { + var minDist = 100.0 + for (node in sketch.construction.nodes) { + if (node != null) { + val output = node.getOutput() + if (output is PointS2) { + val dist = Math.sqrt(Math.pow(output.x - cursor.x, 2.0) + Math.pow(output.y - cursor.y, 2.0) + + Math.pow(output.z - cursor.z, 2.0)) + if (dist < minDist) { + minDist = dist + selectedNode = node + } + } + if (output is DiskS2) { + val a = output.a + val b = output.b + val c = output.c + val d = output.d + if(isIntersection(mouseX, mouseY, a, b, c, d)) { + val center = output.centerE3 + val radius = output.radiusE3 + val diskDist = Math.sqrt(Math.pow(center.x - cursor.x, 2.0) + Math.pow(center.y - cursor.y, 2.0) + + Math.pow(center.z - cursor.z, 2.0)) - radius + if (diskDist < minDist) { + minDist = diskDist + selectedNode = node + } + } + } + } + } + + selectedNode?.style = Style(Color(200.0.toFloat(), 0.0f, 0.0f), Color(255.0.toFloat(), 0.0.toFloat(), 0.0.toFloat())) + if(!selectedNodes.contains(selectedNode)) { + selectedNodes.add(selectedNode as INode<*>) + } + } + } + + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + if (selectedNodes.size >= 3) { + var obj1 = selectedNodes[0] + var obj2 = selectedNodes[1] + var obj3 = selectedNodes[2] + + @Suppress("UNCHECKED_CAST") + var node = sketch.construction.makeCoaxialDisk( obj1 as INode, + obj2 as INode, + obj3 as INode) + + } + } +} + +open class ThreeDiskCPlaneTool(val sketch: ConstructionSketch) : MouseTool() { + var selectedNode : INode<*>? = null; + var selectedNodes = mutableListOf>() + + fun transform(mouseX: Int, mouseY: Int): PointE3 { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 + return inter + } else { + inter = new1 + direction * t0 + return inter + } + } + return PointE3() + } + + fun isIntersection(mouseX : Int, mouseY : Int, a : Double, b : Double, c : Double, d : Double) : Boolean { + val gl = sketch.g + if (gl is PGraphicsOpenGL) { + var Minv = PMatrix3D(gl.projmodelview) + Minv.invert() //PVM inverted + var mousex = (2.0f * mouseX) / sketch.width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / sketch.height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + var rayOrigin = VectorE3(new1.x, new1.y, new1.z) + var worldOrigin = VectorE3(0.0, 0.0, 0.0) + var normalVector = VectorE3(a, b, c) + var denom = direction.dot(normalVector) + var t = ((worldOrigin - rayOrigin).dot(normalVector)) / denom + return t >= 0 + } + + return false; + } + + override fun mouseMoved(mouseX: Int, mouseY: Int) { + super.mouseMoved(mouseX, mouseY) + } + + override fun mouseDragged(mouseX: Int, mouseY: Int) { + + } + + override fun mousePressed(mouseX: Int, mouseY: Int) { + super.mousePressed(mouseX, mouseY) + val cursor = transform(mouseX, mouseY) + if (cursor != null) { + var minDist = 100.0 + for (node in sketch.construction.nodes) { + if (node != null) { + val output = node.getOutput() + if (output is DiskS2) { + val a = output.a + val b = output.b + val c = output.c + val d = output.d + if(isIntersection(mouseX, mouseY, a, b, c, d)) { + val center = output.centerE3 + val radius = output.radiusE3 + val diskDist = Math.sqrt(Math.pow(center.x - cursor.x, 2.0) + Math.pow(center.y - cursor.y, 2.0) + + Math.pow(center.z - cursor.z, 2.0)) - radius + if (diskDist < minDist) { + minDist = diskDist + selectedNode = node + } + } + } + } + } + + selectedNode?.style = Style(Color(200.0.toFloat(), 0.0f, 0.0f), Color(255.0.toFloat(), 0.0.toFloat(), 0.0.toFloat())) + if(!selectedNodes.contains(selectedNode)) { + selectedNodes.add(selectedNode as INode<*>) + } + } + } + + override fun mouseReleased(mouseX: Int, mouseY: Int) { + super.mouseReleased(mouseX, mouseY) + if (selectedNodes.size >= 3) { + var obj1 = selectedNodes[0] + var obj2 = selectedNodes[1] + var obj3 = selectedNodes[2] + + @Suppress("UNCHECKED_CAST") + var node = sketch.construction.makeCPlaneS2( obj1 as INode, + obj2 as INode, + obj3 as INode) + + } + } +} + +open class ConstructionSketch : SphericalSketch() { + + var currentTool : MouseTool? = null; + + class ConstructionSketchViewSettings() { + var showBoundingBox = true + var showCircleCentersAndNormals = true + var showSphere = true + var showDualPoint = true + var showEuclideanDisks = false + } + + internal val constructFrame = ConstructionGUI(this); + /** + * Sets up the sketches.main graphics settings for the PApplet window + */ + override fun settings() { + size(600, 600, P3D) + smooth(4) + } + + /** + * Sets up the drawing canvas. + */ + override fun setup() { + super.setup() + constructFrame.setSize(200, 100) + constructFrame.setVisible(true) + constructFrame.pack() + + + } + + //for mouseClick() + var clicked = false; + var sphereCursor : PointS2? = null; + + /** + * The sketches.main drawing code, called in an infinite loop to continuously redraw the screen. + */ + override fun draw() { + update() + + background(255) + + beginCamera() + camera() + if (applyToCamera && arcball != null) { + translate((width / 2).toFloat(), (height / 2).toFloat()) + val axis = (arcball as Arcball).axis + rotate((arcball as Arcball).angle, axis.x, axis.y, -axis.z) + translate((-width / 2).toFloat(), (-height / 2).toFloat()) + } + endCamera() + + translate(width / 2.0f, height / 2.0f, 0.0f) + scale(1.0f, -1.0f, 1.0f); + scale(200.0f * zoom) + strokeWeight(0.005f / zoom) + + pushStyle() + + noStroke() + lights() + + if (viewSettings.showSphere) sphere(1.0f) + + // Draw the points + synchronized(constructionLock, { + val consStyles = HashMap() + listOf>( + construction.getGeometricObjects(consStyles), + objects + ).forEach { + list -> + list.forEach { + + val style = if (consStyles[it] is Style) consStyles[it] as Style else objectStyles[it] + + if(it is List<*>) { + it.forEach { + obj -> drawGeometricObjects(obj, style) + } + } else { + drawGeometricObjects(it, style) + } + + } + } + }) + + + + if (viewSettings.showBoundingBox) { + noFill() + stroke(0) + box(2.0f) + } + + popStyle() + val gl = this.g + if (gl is PGraphicsOpenGL) { + cursor(CROSS) + var Minv = PMatrix3D(gl.projmodelview) + //println(copyOfMatrix) + Minv.invert() //PVM inverted + //System.out.println("wdith " + width) + var mousex = (2.0f * mouseX) / width - 1.0f + var mousey = 1.0f - (2.0f * mouseY) / height + + var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 + var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 + + var new1 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() + ) + + var new2 = PointE3( + ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), + ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), + ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() + ) + + var direction = (new2 - new1).normalize() + + var l = PointE3.O - new1 + + var tca = l.dot(direction) + var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) + var thc = Math.sqrt(1 - d * d) + var t0 = tca - thc + var t1 = tca + thc + var inter = PointE3(0.0, 0.0, 0.0) + if (t0 > t1) { + inter = new1 + direction * t1 +// PointE3(newX1 + direction.x*t1, newY1 + t1*direction.y, newZ1 + t1*direction.z) + } else { + inter = new1 + direction * t0 +// inter = PointE3(newX1 + direction.x*t0, newY1 + t0*direction.y, newZ1 + t0*direction.z) + } + pushMatrix() // + translate(inter.x.toFloat(), inter.y.toFloat(), inter.z.toFloat()) //translates the origin + sphere(0.05f) + sphereCursor = PointS2(inter.x, inter.y, inter.z) + popMatrix() + var delta = .5 + listOf>(construction.getGeometricObjects(),objects).forEach{ + list -> list.forEach { + when(it) { + is PointS2 -> { + //println("it.x: " + it.x.toDouble() + " mousex: $mousex it.y: " + it.y.toDouble() + " mousey: $mousey") + if (Math.abs(it.x - mousex.toDouble()) <= delta && Math.abs(it.y - mousey.toDouble()) <= delta && clicked) { + var newIt = mouseDragged(it, inter) + list.remove(it) + list.add(newIt) + } + } + } + } + } + } + } + + fun drawGeometricObjects(it : Any?, style: Style?) { + when (it) { + is PointS2 -> { + if (style != null) style.set(this) + else { + noStroke() + fill(100.0f, 125.0f, 255.0f) + } + drawPointE3(it.directionE3.endPoint) + } + is PointE2 -> { + if (style != null) style.set(this) + else { + noStroke() + fill(100.0f, 125.0f, 255.0f) + } + drawPointE2(it) + } + is DiskOP2 -> { + if (style != null) style.set(this) + else { + stroke(0.0f, 0.0f, 0.0f) + noFill() + } + drawDiskOP2(it) + } + is LineOP2 -> { + if (style != null) style.set(this) + else { + stroke(0.0f, 0.0f, 0.0f) + noFill() + } + drawLineOP2(it) + } + is PointE3 -> { + if (style != null) style.set(this) + else { + noStroke() + fill(100.0f, 125.0f, 255.0f) + } + drawPointE3(it) + } + is PointOP2 -> { + if (style != null) style.set(this) + else { + noStroke() + fill(100.0f, 125.0f, 255.0f) + } + drawPointOP2(it) + } + + is PointOP3 -> { + if (style != null) style.set(this) + else { + noStroke() + fill(100.0f, 125.0f, 255.0f) + } + if (!it.isIdeal()) drawPointE3(it.toPointE3()) + } + is DiskS2 -> { + if (style != null) style.set(this) + else { + stroke(0) + } + drawCircleS2(it) + } + is DiskE2 -> { + if (style != null) style.set(this) + else { + stroke(0) + } + drawCircleE2(it) + } + is CircleArcOP2 -> { + if (style != null) style.set(this) + else { + stroke(0.0f, 0.0f, 255.0f) + } + drawCircleArcOP2(it) + if (style == null) { + noStroke() + fill(255.0f, 0.0f, 125.0f) + drawPointOP2(it.source) + drawPointOP2(it.target) + } + } + is CircleArcS2 -> { + if (style != null) style.set(this) + else { + stroke(0.0f, 0.0f, 255.0f) + } + drawCircleArcS2(it) + if (style == null) { + noStroke() + fill(255.0f, 0.0f, 125.0f) + drawPointE3(it.source.directionE3.endPoint) + drawPointE3(it.target.directionE3.endPoint) + } + } + is CPlaneS2 -> { + if (style != null) style.set(this) + else { + stroke(255.0f, 0.0f, 0.0f) + } + drawCircleS2(it.dualDiskS2) + } + is DCEL<*, *, *> -> { + if (style != null) style.set(this) + else { + stroke(0) + fill(255.0f, 255.0f, 255.0f) + } + drawDCEL(it) + } + else -> {} + } + } + + + + + /*** Mouse Handling Code ***/ + + fun mouseDragged(it : Any, inter : PointE3) : Any { + currentTool?.mouseDragged(mouseX, mouseY) + when(it) { + is PointS2 -> { + var newPoint = PointS2(inter.x, inter.y, inter.z) + return newPoint + } + } + return it + } + + override fun mouseMoved() { + currentTool?.mouseMoved(mouseX, mouseY) + } + + override fun mouseClicked() { + currentTool?.mouseClicked(mouseX, mouseY) + } + + override fun mousePressed() { + currentTool?.mousePressed(mouseX, mouseY) + } + + override fun mouseReleased() { + currentTool?.mouseReleased(mouseX, mouseY) + } + + override fun mouseDragged() { + currentTool?.mouseDragged(mouseX, mouseY) + } + + override fun mouseWheel(event: MouseEvent?) { + if (event != null) { + //val delta = if (event.count > 0) 1.01f else if (event.count < 0) 1.0f/1.01f else 1.0f + val delta = if (event.count > 0) + Math.pow(1.0005, event.count.toDouble()).toFloat() + else if (event.count < 0) + Math.pow(1.0005, event.count.toDouble()).toFloat() + else 1.0f + zoom *= delta + } + } + +} + +/** + * Start the sketch. + */ +fun main(passedArgs : Array) { + val appletArgs = arrayOf("sketches.ConstructionSketch") + if (passedArgs != null) { + PApplet.main(PApplet.concat(appletArgs, passedArgs)) + } else { + PApplet.main(appletArgs) + } +} \ No newline at end of file diff --git a/src/sketches/SphericalSketch.kt b/src/main/kotlin/sketches/SphericalSketch.kt similarity index 98% rename from src/sketches/SphericalSketch.kt rename to src/main/kotlin/sketches/SphericalSketch.kt index 79d63b2..5e4039e 100644 --- a/src/sketches/SphericalSketch.kt +++ b/src/main/kotlin/sketches/SphericalSketch.kt @@ -17,6 +17,7 @@ import geometry.construction.Construction import geometry.algorithms.incrConvexHull import geometry.algorithms.orientationPointOP3 import geometry.algorithms.addPoint +import geometry.construction.INode import geometry.ds.dcel.* import geometry.primitives.OrientedProjective2.* import geometry.primitives.isZero @@ -28,11 +29,11 @@ import processing.opengl.PGraphicsOpenGL import javax.swing.* -class Color(val x: Float, val y: Float, val z: Float, val a: Float = 255.0f) { +class Color(val r: Float, val g: Float, val b: Float, val a: Float = 255.0f) { companion object { val noColor = Color(-1.0f, -1.0f, -1.0f, -1.0f) } - override fun equals(c: Any?) = (c is Color && c.x == x && c.y == y && c.z == z && c.a == a) + override fun equals(c: Any?) = (c is Color && c.r == r && c.g == g && c.b == b && c.a == a) } class Style( @@ -40,10 +41,10 @@ class Style( val fill: Color? ) { fun set(p: PApplet) { - if (stroke != null && stroke != Color.noColor) p.stroke(stroke.x, stroke.y, stroke.z, stroke.a) + if (stroke != null && stroke != Color.noColor) p.stroke(stroke.r, stroke.g, stroke.b, stroke.a) else if (stroke == Color.noColor) p.noStroke() - if (fill != null && fill != Color.noColor) p.fill(fill.x, fill.y, fill.z, fill.a) + if (fill != null && fill != Color.noColor) p.fill(fill.r, fill.g, fill.b, fill.a) else if (fill == Color.noColor) p.noFill() } @@ -649,7 +650,7 @@ open class SphericalSketch : PApplet() { ).forEach { list -> list.forEach { - val style = objectStyles[it] + val style = if(it is INode<*>) it.style as Style? else objectStyles[it] when (it) { is PointS2 -> { if (style != null) style.set(this) @@ -802,6 +803,8 @@ open class SphericalSketch : PApplet() { /*** Mouse Handling Code ***/ + + override fun mousePressed() { arcball?.mousePressed() } @@ -838,4 +841,4 @@ fun main(passedArgs : Array) { } else { PApplet.main(appletArgs) } -} \ No newline at end of file +} diff --git a/src/sketches/SphericalSketchTestbed.kt b/src/main/kotlin/sketches/SphericalSketchTestbed.kt similarity index 100% rename from src/sketches/SphericalSketchTestbed.kt rename to src/main/kotlin/sketches/SphericalSketchTestbed.kt diff --git a/src/sketches/TriangulationSketch.kt b/src/main/kotlin/sketches/TriangulationSketch.kt similarity index 100% rename from src/sketches/TriangulationSketch.kt rename to src/main/kotlin/sketches/TriangulationSketch.kt diff --git a/src/sketches/VoronoiSketch.kt b/src/main/kotlin/sketches/VoronoiSketch.kt similarity index 100% rename from src/sketches/VoronoiSketch.kt rename to src/main/kotlin/sketches/VoronoiSketch.kt diff --git a/src/tilings/algorithms/ChairTile.kt b/src/main/kotlin/tilings/algorithms/ChairTile.kt similarity index 100% rename from src/tilings/algorithms/ChairTile.kt rename to src/main/kotlin/tilings/algorithms/ChairTile.kt diff --git a/src/tilings/algorithms/DCELTransform.kt b/src/main/kotlin/tilings/algorithms/DCELTransform.kt similarity index 100% rename from src/tilings/algorithms/DCELTransform.kt rename to src/main/kotlin/tilings/algorithms/DCELTransform.kt diff --git a/src/tilings/algorithms/EuclidPack.kt b/src/main/kotlin/tilings/algorithms/EuclidPack.kt similarity index 100% rename from src/tilings/algorithms/EuclidPack.kt rename to src/main/kotlin/tilings/algorithms/EuclidPack.kt diff --git a/src/tilings/algorithms/Triangulation.kt b/src/main/kotlin/tilings/algorithms/Triangulation.kt similarity index 100% rename from src/tilings/algorithms/Triangulation.kt rename to src/main/kotlin/tilings/algorithms/Triangulation.kt diff --git a/src/tilings/applications/TileView.kt b/src/main/kotlin/tilings/applications/TileView.kt similarity index 100% rename from src/tilings/applications/TileView.kt rename to src/main/kotlin/tilings/applications/TileView.kt diff --git a/src/tilings/ds/ChairTile.kt b/src/main/kotlin/tilings/ds/ChairTile.kt similarity index 100% rename from src/tilings/ds/ChairTile.kt rename to src/main/kotlin/tilings/ds/ChairTile.kt diff --git a/src/tilings/ds/EscherTile.kt b/src/main/kotlin/tilings/ds/EscherTile.kt similarity index 100% rename from src/tilings/ds/EscherTile.kt rename to src/main/kotlin/tilings/ds/EscherTile.kt diff --git a/src/tilings/ds/PentagonalTwistTile.kt b/src/main/kotlin/tilings/ds/PentagonalTwistTile.kt similarity index 100% rename from src/tilings/ds/PentagonalTwistTile.kt rename to src/main/kotlin/tilings/ds/PentagonalTwistTile.kt diff --git a/src/tilings/ds/Tile.kt b/src/main/kotlin/tilings/ds/Tile.kt similarity index 100% rename from src/tilings/ds/Tile.kt rename to src/main/kotlin/tilings/ds/Tile.kt diff --git a/src/tilings/ds/TilingData.kt b/src/main/kotlin/tilings/ds/TilingData.kt similarity index 100% rename from src/tilings/ds/TilingData.kt rename to src/main/kotlin/tilings/ds/TilingData.kt diff --git a/src/tilings/ds/Tree.kt b/src/main/kotlin/tilings/ds/Tree.kt similarity index 100% rename from src/tilings/ds/Tree.kt rename to src/main/kotlin/tilings/ds/Tree.kt diff --git a/src/tilings/language/algorithms/EscherDriver.kt b/src/main/kotlin/tilings/language/algorithms/EscherDriver.kt similarity index 100% rename from src/tilings/language/algorithms/EscherDriver.kt rename to src/main/kotlin/tilings/language/algorithms/EscherDriver.kt diff --git a/src/tilings/language/algorithms/LanguageDriver.kt b/src/main/kotlin/tilings/language/algorithms/LanguageDriver.kt similarity index 100% rename from src/tilings/language/algorithms/LanguageDriver.kt rename to src/main/kotlin/tilings/language/algorithms/LanguageDriver.kt diff --git a/src/tilings/language/algorithms/Subdivider.kt b/src/main/kotlin/tilings/language/algorithms/Subdivider.kt similarity index 100% rename from src/tilings/language/algorithms/Subdivider.kt rename to src/main/kotlin/tilings/language/algorithms/Subdivider.kt diff --git a/src/tilings/language/algorithms/Subdivider2.kt b/src/main/kotlin/tilings/language/algorithms/Subdivider2.kt similarity index 100% rename from src/tilings/language/algorithms/Subdivider2.kt rename to src/main/kotlin/tilings/language/algorithms/Subdivider2.kt diff --git a/src/tilings/language/algorithms/TileFactory.kt b/src/main/kotlin/tilings/language/algorithms/TileFactory.kt similarity index 100% rename from src/tilings/language/algorithms/TileFactory.kt rename to src/main/kotlin/tilings/language/algorithms/TileFactory.kt diff --git a/src/tilings/language/algorithms/planarDraw.py b/src/main/kotlin/tilings/language/algorithms/planarDraw.py similarity index 100% rename from src/tilings/language/algorithms/planarDraw.py rename to src/main/kotlin/tilings/language/algorithms/planarDraw.py diff --git a/src/tilings/language/ds/EscherProgramNew.kt b/src/main/kotlin/tilings/language/ds/EscherProgramNew.kt similarity index 100% rename from src/tilings/language/ds/EscherProgramNew.kt rename to src/main/kotlin/tilings/language/ds/EscherProgramNew.kt diff --git a/src/tilings/language/ds/MyEscherListener.kt b/src/main/kotlin/tilings/language/ds/MyEscherListener.kt similarity index 100% rename from src/tilings/language/ds/MyEscherListener.kt rename to src/main/kotlin/tilings/language/ds/MyEscherListener.kt diff --git a/src/tilings/language/ds/Subdivision.kt b/src/main/kotlin/tilings/language/ds/Subdivision.kt similarity index 100% rename from src/tilings/language/ds/Subdivision.kt rename to src/main/kotlin/tilings/language/ds/Subdivision.kt diff --git a/src/tilings/language/gui/EscherFrame.kt b/src/main/kotlin/tilings/language/gui/EscherFrame.kt similarity index 100% rename from src/tilings/language/gui/EscherFrame.kt rename to src/main/kotlin/tilings/language/gui/EscherFrame.kt diff --git a/src/tilings/language/gui/TileSketch.kt b/src/main/kotlin/tilings/language/gui/TileSketch.kt similarity index 100% rename from src/tilings/language/gui/TileSketch.kt rename to src/main/kotlin/tilings/language/gui/TileSketch.kt diff --git a/src/sketches/ConstructionSketch.kt b/src/sketches/ConstructionSketch.kt deleted file mode 100644 index 88f74a3..0000000 --- a/src/sketches/ConstructionSketch.kt +++ /dev/null @@ -1,595 +0,0 @@ -package sketches - -import com.processinghacks.arcball.Arcball -import geometry.construction.Construction -import geometry.construction.BaseNode -import geometry.construction.INode -import geometry.ds.dcel.DCEL -import geometry.primitives.Euclidean2.DiskE2 -import geometry.primitives.Euclidean2.PointE2 -import geometry.primitives.Euclidean2.VectorE2 -import geometry.primitives.Euclidean3.DirectionE3 -import geometry.primitives.Euclidean3.PointE3 -import geometry.primitives.Euclidean3.VectorE3 -import geometry.primitives.OrientedProjective2.CircleArcOP2 -import geometry.primitives.OrientedProjective2.DiskOP2 -import geometry.primitives.OrientedProjective2.LineOP2 -import geometry.primitives.OrientedProjective2.PointOP2 -import geometry.primitives.OrientedProjective3.PointOP3 -import geometry.primitives.Spherical2.* -import geometry.primitives.inner_product -import gui.JythonFrame -import gui.ConstructionGUI -import processing.core.PApplet -import processing.event.MouseEvent - -import processing.core.PConstants -import processing.core.PGraphics.R -import processing.core.PMatrix3D -import processing.opengl.PGraphicsOpenGL -import java.awt.Button -import java.awt.Point -import java.io.PrintWriter - -import javax.swing.* - -/** - * Created by browermb on 7/27/2017. - */ - -var circleTool = false - -interface MouseTool { - fun mousePressed(mouseX: Int, mouseY: Int) - fun mouseReleased(mouseX: Int, mouseY: Int) - fun mouseDragged(mouseX: Int, mouseY: Int) - fun mouseClicked(mouseX: Int, mouseY: Int) - -} - -class ArcballTool(val arcball: Arcball?) : MouseTool { - override fun mousePressed(mouseX: Int, mouseY: Int) { - arcball?.mousePressed() - } - override fun mouseReleased(mouseX: Int, mouseY: Int) { - arcball?.mouseReleased() - } - override fun mouseDragged(mouseX: Int, mouseY: Int) { - arcball?.mouseDragged() - } - override fun mouseClicked(mouseX: Int, mouseY: Int) { - - } -} - -open class PointEditorTool(val sketch: ConstructionSketch) : MouseTool { - // var selectedPoint : PointS2 = PointS2(0.0, 0.0, 0.0) //BaseNode = BaseNode(sketch.construction, PointS2(0.0, 0.0, 0.0)) - // var selectedPoints = mutableListOf()//mutableListOf>() - - var selectedNode : INode<*>? = null; - var selectedNodes = mutableListOf>() - - fun transform(mouseX: Int, mouseY: Int): PointE3 { - val gl = sketch.g - if (gl is PGraphicsOpenGL) { - var Minv = PMatrix3D(gl.projmodelview) - Minv.invert() //PVM inverted - //System.out.println("wdith " + width) - var mousex = (2.0f * mouseX) / sketch.width - 1.0f - var mousey = 1.0f - (2.0f * mouseY) / sketch.height - - var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 - var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 - - var new1 = PointE3( - ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), - ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), - ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() - ) - - var new2 = PointE3( - ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), - ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), - ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() - ) - - var direction = (new2 - new1).normalize() - - var l = PointE3.O - new1 - - var tca = l.dot(direction) - var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) - var thc = Math.sqrt(1 - d * d) - var t0 = tca - thc - var t1 = tca + thc - var inter = PointE3(0.0, 0.0, 0.0) - if (t0 > t1) { - inter = new1 + direction * t1 - return inter - } else { - inter = new1 + direction * t0 - return inter - } - } - return PointE3() - } - - override fun mousePressed(mouseX: Int, mouseY: Int) { - var cursor = transform(mouseX, mouseY) - if (cursor != null) { - //var pointClicked = PointS2(cursor.x, cursor.y, cursor.z) - - for (node in sketch.construction.nodes) { - if (node != null) { - var output = node.getOutput() - if (output is PointS2) { - //should change this so its the closet found point - if (Math.abs(cursor.x.toFloat() - output.x) <= .1 - && Math.abs(cursor.y.toFloat() - output.y) <= .1 - && Math.abs(cursor.z.toFloat() - output.z) <= .1) { -// selectedPoint = output -// selectedPoints.add(output); -// sketch.pointsDrawn.remove(selectedPoint) -// sketch.objects.remove(selectedPoint) - selectedNode = node - break - } - } - - } - } - } - } -// -// var iterator = sketch.pointsDrawn.listIterator() -// while (iterator.hasNext()) { -// var point = iterator.next() -// if (Math.abs(cursor.x.toFloat() - point.x) <= .1 -// && Math.abs(cursor.y.toFloat() - point.y) <= .1 -// && Math.abs(cursor.z.toFloat() - point.z) <= .1) { -// selectedPoint = point -// selectedPoints.add(point); -// sketch.pointsDrawn.remove(selectedPoint) -// sketch.objects.remove(selectedPoint) -// break -// } -// } - - - override fun mouseReleased(mouseX: Int, mouseY: Int) { - - } - - override fun mouseDragged(mouseX: Int, mouseY: Int) { - - var cursor = transform(mouseX, mouseY) - if (cursor != null) { - var node = selectedNode - if (node is BaseNode<*>) { - node.resetBaseNodeWith(PointS2(cursor.x, cursor.y, cursor.z)) - } - } - } - override fun mouseClicked(mouseX: Int, mouseY: Int) { - var drawNode = true - var cursor = transform(mouseX, mouseY) - if (cursor != null) { - //var pointClicked = PointS2(cursor.x, cursor.y, cursor.z) - for (node in sketch.construction.nodes) { - if(node != null) { - var output = node.getOutput() - if (output is PointS2) { - if (Math.abs(cursor.x.toFloat() - output.x) <= .1 - && Math.abs(cursor.y.toFloat() - output.y) <= .1 - && Math.abs(cursor.z.toFloat() - output.z) <= .1) { - drawNode = false - break - } - } - } - } - if (drawNode) { - sketch.construction.makePointS2(cursor.x, cursor.y, cursor.z) - } - } -// -// var iterator = sketch.pointsDrawn.listIterator() -// var drawPoint = true -// while (iterator.hasNext()) { -// var point = iterator.next() -// if (Math.abs(cursor.x.toFloat() - point.x) <= .1 -// && Math.abs(cursor.y.toFloat() - point.y) <= .1 -// && Math.abs(cursor.z.toFloat() - point.z) <= .1) { -// drawPoint = false; -// break -// } -// } -// if (drawPoint && keyCodes != 67) { -// sketch.objects.add(pointClicked) -// sketch.pointsDrawn.add(pointClicked) -// } -// } - } - - class CircleTool(sketch: ConstructionSketch) : MouseTool, PointEditorTool(sketch) { - - override fun mousePressed(mouseX: Int, mouseY: Int) { - var cursor = transform(mouseX, mouseY) - if (cursor != null) { - //var pointClicked = PointS2(cursor.x, cursor.y, cursor.z) - - for (node in sketch.construction.nodes) { - if (node != null) { - var output = node.getOutput() - if (output is PointS2) { - //should change this so its the closet found point - if (Math.abs(cursor.x.toFloat() - output.x) <= .1 - && Math.abs(cursor.y.toFloat() - output.y) <= .1 - && Math.abs(cursor.z.toFloat() - output.z) <= .1) { -// selectedPoint = output -// selectedPoints.add(output); -// sketch.pointsDrawn.remove(selectedPoint) -// sketch.objects.remove(selectedPoint) - selectedNode = node - break - } - } - - } - } - } - - selectedNodes.add(selectedNode as INode<*>) - } - override fun mouseReleased(mouseX: Int, mouseY: Int) { -// sketch.pointsDrawn.add(selectedPoint) - // sketch.objects.add(selectedPoint) - if (selectedNodes.size >= 3) { - var obj1 = selectedNodes[0] - var obj2 = selectedNodes[1] - var obj3 = selectedNodes[2] - - @Suppress("UNCHECKED_CAST") - sketch.construction.makeDiskS2( obj1 as INode, - obj2 as INode, - obj3 as INode) - -// var draw = DiskS2(selectedPoints.get(0), selectedPoints.get(1), selectedPoints.get(2)) -// sketch.objects.add(draw) -// selectedPoints.removeAt(0) -// selectedPoints.removeAt(0) -// selectedPoints.removeAt(0) - } - } - - } - } - - -open class ConstructionSketch : SphericalSketch() { - - var currentTool : MouseTool? = null; - - class ConstructionSketchViewSettings() { - var showBoundingBox = true - var showCircleCentersAndNormals = true - var showSphere = true - var showDualPoint = true - var showEuclideanDisks = false - } - - internal val constructFrame = ConstructionGUI(this); - /** - * Sets up the sketches.main graphics settings for the PApplet window - */ - override fun settings() { - size(600, 600, P3D) - smooth(4) - } - - /** - * Sets up the drawing canvas. - */ - override fun setup() { - super.setup() - constructFrame.setSize(200, 100) - constructFrame.setVisible(true) - constructFrame.pack() - - - } - - //val pointsDrawn = mutableListOf(); - //for mouseClick() - var clicked = false; - var sphereCursor : PointS2? = null; - - /** - * The sketches.main drawing code, called in an infinite loop to continuously redraw the screen. - */ - override fun draw() { - update() - - background(255) - - beginCamera() - camera() - if (applyToCamera && arcball != null) { - translate((width / 2).toFloat(), (height / 2).toFloat()) - val axis = (arcball as Arcball).axis - rotate((arcball as Arcball).angle, axis.x, axis.y, -axis.z) - translate((-width / 2).toFloat(), (-height / 2).toFloat()) - } - endCamera() - - translate(width / 2.0f, height / 2.0f, 0.0f) - scale(1.0f, -1.0f, 1.0f); - scale(200.0f * zoom) - strokeWeight(0.005f / zoom) - - pushStyle() - - noStroke() - lights() - - if (viewSettings.showSphere) sphere(1.0f) - - // Draw the points - synchronized(constructionLock, { - listOf>( - construction.getGeometricObjects(), - objects - ).forEach { - list -> - list.forEach { - val style = objectStyles[it] - when (it) { - is PointS2 -> { - if (style != null) style.set(this) - else { - noStroke() - fill(100.0f, 125.0f, 255.0f) - } - drawPointE3(it.directionE3.endPoint) - } - is PointE2 -> { - if (style != null) style.set(this) - else { - noStroke() - fill(100.0f, 125.0f, 255.0f) - } - drawPointE2(it) - } - is DiskOP2 -> { - if (style != null) style.set(this) - else { - stroke(0.0f, 0.0f, 0.0f) - noFill() - } - drawDiskOP2(it) - } - is LineOP2 -> { - if (style != null) style.set(this) - else { - stroke(0.0f, 0.0f, 0.0f) - noFill() - } - drawLineOP2(it) - } - is PointE3 -> { - if (style != null) style.set(this) - else { - noStroke() - fill(100.0f, 125.0f, 255.0f) - } - drawPointE3(it) - } - is PointOP2 -> { - if (style != null) style.set(this) - else { - noStroke() - fill(100.0f, 125.0f, 255.0f) - } - drawPointOP2(it) - } - - is PointOP3 -> { - if (style != null) style.set(this) - else { - noStroke() - fill(100.0f, 125.0f, 255.0f) - } - if (!it.isIdeal()) drawPointE3(it.toPointE3()) - } - is DiskS2 -> { - if (style != null) style.set(this) - else { - stroke(0) - } - drawCircleS2(it) - } - is DiskE2 -> { - if (style != null) style.set(this) - else { - stroke(0) - } - drawCircleE2(it) - } - is CircleArcOP2 -> { - if (style != null) style.set(this) - else { - stroke(0.0f, 0.0f, 255.0f) - } - drawCircleArcOP2(it) - if (style == null) { - noStroke() - fill(255.0f, 0.0f, 125.0f) - drawPointOP2(it.source) - drawPointOP2(it.target) - } - } - is CircleArcS2 -> { - if (style != null) style.set(this) - else { - stroke(0.0f, 0.0f, 255.0f) - } - drawCircleArcS2(it) - if (style == null) { - noStroke() - fill(255.0f, 0.0f, 125.0f) - drawPointE3(it.source.directionE3.endPoint) - drawPointE3(it.target.directionE3.endPoint) - } - } - is CPlaneS2 -> { - if (style != null) style.set(this) - else { - stroke(255.0f, 0.0f, 0.0f) - } - drawCircleS2(it.dualDiskS2) - } - is DCEL<*, *, *> -> { - if (style != null) style.set(this) - else { - stroke(0) - fill(255.0f, 255.0f, 255.0f) - } - drawDCEL(it) - } - else -> {} - } - } - } - }) - - - - if (viewSettings.showBoundingBox) { - noFill() - stroke(0) - box(2.0f) - } - - popStyle() - val gl = this.g - if (gl is PGraphicsOpenGL) { - cursor(CROSS) - var Minv = PMatrix3D(gl.projmodelview) - //println(copyOfMatrix) - Minv.invert() //PVM inverted - //System.out.println("wdith " + width) - var mousex = (2.0f * mouseX) / width - 1.0f - var mousey = 1.0f - (2.0f * mouseY) / height - - var w1 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m33 - var w2 = Minv.m30 * mousex + Minv.m31 * mousey + Minv.m32 + Minv.m33 - - var new1 = PointE3( - ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m03) / w1).toDouble(), - ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m13) / w1).toDouble(), - ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m23) / w1).toDouble() - ) - - var new2 = PointE3( - ((Minv.m00 * mousex + Minv.m01 * mousey + Minv.m02 + Minv.m03) / w2).toDouble(), - ((Minv.m10 * mousex + Minv.m11 * mousey + Minv.m12 + Minv.m13) / w2).toDouble(), - ((Minv.m20 * mousex + Minv.m21 * mousey + Minv.m22 + Minv.m23) / w2).toDouble() - ) - - var direction = (new2 - new1).normalize() - - var l = PointE3.O - new1 - - var tca = l.dot(direction) - var d = (Math.sqrt(l.normSq() - tca * tca))//(200.0*zoom) - var thc = Math.sqrt(1 - d * d) - var t0 = tca - thc - var t1 = tca + thc - var inter = PointE3(0.0, 0.0, 0.0) - if (t0 > t1) { - inter = new1 + direction * t1 -// PointE3(newX1 + direction.x*t1, newY1 + t1*direction.y, newZ1 + t1*direction.z) - } else { - inter = new1 + direction * t0 -// inter = PointE3(newX1 + direction.x*t0, newY1 + t0*direction.y, newZ1 + t0*direction.z) - } - pushMatrix() // - translate(inter.x.toFloat(), inter.y.toFloat(), inter.z.toFloat()) //translates the origin - sphere(0.05f) - sphereCursor = PointS2(inter.x, inter.y, inter.z) - popMatrix() - var delta = .5 - listOf>(construction.getGeometricObjects(),objects).forEach{ - list -> list.forEach { - when(it) { - is PointS2 -> { - //println("it.x: " + it.x.toDouble() + " mousex: $mousex it.y: " + it.y.toDouble() + " mousey: $mousey") - if (Math.abs(it.x - mousex.toDouble()) <= delta && Math.abs(it.y - mousey.toDouble()) <= delta && clicked) { - var newIt = mouseDragged(it, inter) - list.remove(it) - list.add(newIt) - } - } - } - } - } - } - } - - - - - /*** Mouse Handling Code ***/ - - fun mouseDragged(it : Any, inter : PointE3) : Any { - currentTool?.mouseDragged(mouseX, mouseY) - when(it) { - is PointS2 -> { - var newPoint = PointS2(inter.x, inter.y, inter.z) - return newPoint - } - } - return it - } - - override fun mouseClicked() { - currentTool?.mouseClicked(mouseX, mouseY) - } - - override fun mousePressed() { - currentTool?.mousePressed(mouseX, mouseY)//arcball?.mousePressed() - } - - override fun mouseReleased() { - currentTool?.mouseReleased(mouseX, mouseY) - } - - override fun mouseDragged() { - currentTool?.mouseDragged(mouseX, mouseY) - } - - override fun mouseWheel(event: MouseEvent?) { - if (event != null) { - //val delta = if (event.count > 0) 1.01f else if (event.count < 0) 1.0f/1.01f else 1.0f - val delta = if (event.count > 0) - Math.pow(1.0005, event.count.toDouble()).toFloat() - else if (event.count < 0) - Math.pow(1.0005, event.count.toDouble()).toFloat() - else 1.0f - zoom *= delta - } - } - -} - -/** - * Start the sketch. - */ -fun main(passedArgs : Array) { - val appletArgs = arrayOf("sketches.ConstructionSketch") - if (passedArgs != null) { - PApplet.main(PApplet.concat(appletArgs, passedArgs)) - } else { - PApplet.main(appletArgs) - } -} \ No newline at end of file diff --git a/src/tilings/language/grammar/Escher.interp b/src/tilings/language/grammar/Escher.interp deleted file mode 100644 index 2d68256..0000000 --- a/src/tilings/language/grammar/Escher.interp +++ /dev/null @@ -1,80 +0,0 @@ -token literal names: -null -'{' -',' -'}' -'(' -')' -'=' -'[' -']' -'.' -'vertex' -'face' -'GRAPH' -'CHILD' -'SUBDIVISION' -'TILETYPE' -'VERTEX' -'EDGE' -'tile' -'split' -'connect' -';' -null -null -null - -token symbolic names: -null -null -null -null -null -null -null -null -null -null -null -null -GRAPH -CHILD -SUBDIVISION -TILETYPE -VERTEX -EDGE -TILE -SPLIT -CONNECT -END -WHITESPACE -NUMBER -ID - -rule names: -file -mainline -subline -phrase -definition -tileDefinition -subdivisionDefinition -expression -function -tileFunction -splitFunction -connectFunction -assignment -vertexAssignment -edgeAssignment -childAssignment -graphAssignment -graphDeclaration -childList -node -face - - -atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 26, 198, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 3, 2, 6, 2, 46, 10, 2, 13, 2, 14, 2, 47, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 5, 5, 58, 10, 5, 3, 6, 3, 6, 5, 6, 62, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 7, 7, 70, 10, 7, 12, 7, 14, 7, 73, 11, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 6, 8, 81, 10, 8, 13, 8, 14, 8, 82, 3, 8, 3, 8, 3, 9, 3, 9, 5, 9, 89, 10, 9, 3, 10, 3, 10, 3, 10, 5, 10, 94, 10, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 5, 14, 122, 10, 14, 3, 15, 3, 15, 3, 15, 3, 15, 7, 15, 128, 10, 15, 12, 15, 14, 15, 131, 11, 15, 3, 15, 3, 15, 3, 15, 5, 15, 136, 10, 15, 5, 15, 138, 10, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 5, 16, 150, 10, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 6, 17, 158, 10, 17, 13, 17, 14, 17, 159, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20, 175, 10, 20, 12, 20, 14, 20, 178, 11, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 188, 10, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 5, 22, 196, 10, 22, 3, 22, 2, 2, 23, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 2, 2, 2, 194, 2, 45, 3, 2, 2, 2, 4, 49, 3, 2, 2, 2, 6, 52, 3, 2, 2, 2, 8, 57, 3, 2, 2, 2, 10, 61, 3, 2, 2, 2, 12, 63, 3, 2, 2, 2, 14, 76, 3, 2, 2, 2, 16, 88, 3, 2, 2, 2, 18, 93, 3, 2, 2, 2, 20, 95, 3, 2, 2, 2, 22, 102, 3, 2, 2, 2, 24, 111, 3, 2, 2, 2, 26, 121, 3, 2, 2, 2, 28, 123, 3, 2, 2, 2, 30, 139, 3, 2, 2, 2, 32, 151, 3, 2, 2, 2, 34, 163, 3, 2, 2, 2, 36, 168, 3, 2, 2, 2, 38, 170, 3, 2, 2, 2, 40, 181, 3, 2, 2, 2, 42, 189, 3, 2, 2, 2, 44, 46, 5, 4, 3, 2, 45, 44, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 45, 3, 2, 2, 2, 47, 48, 3, 2, 2, 2, 48, 3, 3, 2, 2, 2, 49, 50, 5, 8, 5, 2, 50, 51, 7, 23, 2, 2, 51, 5, 3, 2, 2, 2, 52, 53, 5, 16, 9, 2, 53, 54, 7, 23, 2, 2, 54, 7, 3, 2, 2, 2, 55, 58, 5, 10, 6, 2, 56, 58, 5, 16, 9, 2, 57, 55, 3, 2, 2, 2, 57, 56, 3, 2, 2, 2, 58, 9, 3, 2, 2, 2, 59, 62, 5, 12, 7, 2, 60, 62, 5, 14, 8, 2, 61, 59, 3, 2, 2, 2, 61, 60, 3, 2, 2, 2, 62, 11, 3, 2, 2, 2, 63, 64, 7, 17, 2, 2, 64, 65, 7, 26, 2, 2, 65, 66, 7, 3, 2, 2, 66, 71, 7, 25, 2, 2, 67, 68, 7, 4, 2, 2, 68, 70, 7, 25, 2, 2, 69, 67, 3, 2, 2, 2, 70, 73, 3, 2, 2, 2, 71, 69, 3, 2, 2, 2, 71, 72, 3, 2, 2, 2, 72, 74, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 74, 75, 7, 5, 2, 2, 75, 13, 3, 2, 2, 2, 76, 77, 7, 16, 2, 2, 77, 78, 7, 26, 2, 2, 78, 80, 7, 3, 2, 2, 79, 81, 5, 6, 4, 2, 80, 79, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 80, 3, 2, 2, 2, 82, 83, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 85, 7, 5, 2, 2, 85, 15, 3, 2, 2, 2, 86, 89, 5, 18, 10, 2, 87, 89, 5, 26, 14, 2, 88, 86, 3, 2, 2, 2, 88, 87, 3, 2, 2, 2, 89, 17, 3, 2, 2, 2, 90, 94, 5, 20, 11, 2, 91, 94, 5, 22, 12, 2, 92, 94, 5, 24, 13, 2, 93, 90, 3, 2, 2, 2, 93, 91, 3, 2, 2, 2, 93, 92, 3, 2, 2, 2, 94, 19, 3, 2, 2, 2, 95, 96, 7, 20, 2, 2, 96, 97, 7, 6, 2, 2, 97, 98, 7, 26, 2, 2, 98, 99, 7, 4, 2, 2, 99, 100, 7, 25, 2, 2, 100, 101, 7, 7, 2, 2, 101, 21, 3, 2, 2, 2, 102, 103, 7, 21, 2, 2, 103, 104, 7, 6, 2, 2, 104, 105, 5, 40, 21, 2, 105, 106, 7, 4, 2, 2, 106, 107, 5, 40, 21, 2, 107, 108, 7, 4, 2, 2, 108, 109, 7, 25, 2, 2, 109, 110, 7, 7, 2, 2, 110, 23, 3, 2, 2, 2, 111, 112, 7, 22, 2, 2, 112, 113, 7, 6, 2, 2, 113, 114, 5, 40, 21, 2, 114, 115, 7, 4, 2, 2, 115, 116, 5, 40, 21, 2, 116, 117, 7, 7, 2, 2, 117, 25, 3, 2, 2, 2, 118, 122, 5, 28, 15, 2, 119, 122, 5, 30, 16, 2, 120, 122, 5, 32, 17, 2, 121, 118, 3, 2, 2, 2, 121, 119, 3, 2, 2, 2, 121, 120, 3, 2, 2, 2, 122, 27, 3, 2, 2, 2, 123, 124, 7, 18, 2, 2, 124, 129, 7, 26, 2, 2, 125, 126, 7, 4, 2, 2, 126, 128, 7, 26, 2, 2, 127, 125, 3, 2, 2, 2, 128, 131, 3, 2, 2, 2, 129, 127, 3, 2, 2, 2, 129, 130, 3, 2, 2, 2, 130, 137, 3, 2, 2, 2, 131, 129, 3, 2, 2, 2, 132, 135, 7, 8, 2, 2, 133, 136, 5, 22, 12, 2, 134, 136, 5, 40, 21, 2, 135, 133, 3, 2, 2, 2, 135, 134, 3, 2, 2, 2, 136, 138, 3, 2, 2, 2, 137, 132, 3, 2, 2, 2, 137, 138, 3, 2, 2, 2, 138, 29, 3, 2, 2, 2, 139, 140, 7, 19, 2, 2, 140, 149, 7, 26, 2, 2, 141, 142, 7, 8, 2, 2, 142, 150, 5, 24, 13, 2, 143, 144, 7, 6, 2, 2, 144, 145, 5, 40, 21, 2, 145, 146, 7, 4, 2, 2, 146, 147, 5, 40, 21, 2, 147, 148, 7, 7, 2, 2, 148, 150, 3, 2, 2, 2, 149, 141, 3, 2, 2, 2, 149, 143, 3, 2, 2, 2, 150, 31, 3, 2, 2, 2, 151, 152, 7, 15, 2, 2, 152, 153, 7, 26, 2, 2, 153, 154, 7, 8, 2, 2, 154, 155, 7, 26, 2, 2, 155, 157, 7, 6, 2, 2, 156, 158, 5, 38, 20, 2, 157, 156, 3, 2, 2, 2, 158, 159, 3, 2, 2, 2, 159, 157, 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 161, 162, 7, 7, 2, 2, 162, 33, 3, 2, 2, 2, 163, 164, 7, 14, 2, 2, 164, 165, 7, 26, 2, 2, 165, 166, 7, 8, 2, 2, 166, 167, 5, 36, 19, 2, 167, 35, 3, 2, 2, 2, 168, 169, 5, 20, 11, 2, 169, 37, 3, 2, 2, 2, 170, 171, 7, 9, 2, 2, 171, 176, 5, 40, 21, 2, 172, 173, 7, 4, 2, 2, 173, 175, 5, 40, 21, 2, 174, 172, 3, 2, 2, 2, 175, 178, 3, 2, 2, 2, 176, 174, 3, 2, 2, 2, 176, 177, 3, 2, 2, 2, 177, 179, 3, 2, 2, 2, 178, 176, 3, 2, 2, 2, 179, 180, 7, 10, 2, 2, 180, 39, 3, 2, 2, 2, 181, 187, 7, 26, 2, 2, 182, 183, 7, 11, 2, 2, 183, 184, 7, 12, 2, 2, 184, 185, 7, 9, 2, 2, 185, 186, 7, 25, 2, 2, 186, 188, 7, 10, 2, 2, 187, 182, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 41, 3, 2, 2, 2, 189, 195, 7, 26, 2, 2, 190, 191, 7, 11, 2, 2, 191, 192, 7, 13, 2, 2, 192, 193, 7, 9, 2, 2, 193, 194, 7, 25, 2, 2, 194, 196, 7, 10, 2, 2, 195, 190, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 43, 3, 2, 2, 2, 18, 47, 57, 61, 71, 82, 88, 93, 121, 129, 135, 137, 149, 159, 176, 187, 195] \ No newline at end of file diff --git a/src/tilings/language/grammar/Escher.tokens b/src/tilings/language/grammar/Escher.tokens deleted file mode 100644 index 658598d..0000000 --- a/src/tilings/language/grammar/Escher.tokens +++ /dev/null @@ -1,45 +0,0 @@ -T__0=1 -T__1=2 -T__2=3 -T__3=4 -T__4=5 -T__5=6 -T__6=7 -T__7=8 -T__8=9 -T__9=10 -T__10=11 -GRAPH=12 -CHILD=13 -SUBDIVISION=14 -TILETYPE=15 -VERTEX=16 -EDGE=17 -TILE=18 -SPLIT=19 -CONNECT=20 -END=21 -WHITESPACE=22 -NUMBER=23 -ID=24 -'{'=1 -','=2 -'}'=3 -'('=4 -')'=5 -'='=6 -'['=7 -']'=8 -'.'=9 -'vertex'=10 -'face'=11 -'GRAPH'=12 -'CHILD'=13 -'SUBDIVISION'=14 -'TILETYPE'=15 -'VERTEX'=16 -'EDGE'=17 -'tile'=18 -'split'=19 -'connect'=20 -';'=21 diff --git a/src/tilings/language/grammar/EscherBaseListener.java b/src/tilings/language/grammar/EscherBaseListener.java deleted file mode 100644 index d052dc4..0000000 --- a/src/tilings/language/grammar/EscherBaseListener.java +++ /dev/null @@ -1,292 +0,0 @@ -package tilings.language.grammar; - -// Generated from Escher.g4 by ANTLR 4.7.1 - -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.tree.ErrorNode; -import org.antlr.v4.runtime.tree.TerminalNode; - -/** - * This class provides an empty implementation of {@link EscherListener}, - * which can be extended to create a listener which only needs to handle a subset - * of the available methods. - */ -public class EscherBaseListener implements EscherListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFile(EscherParser.FileContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFile(EscherParser.FileContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMainline(EscherParser.MainlineContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMainline(EscherParser.MainlineContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSubline(EscherParser.SublineContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSubline(EscherParser.SublineContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPhrase(EscherParser.PhraseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPhrase(EscherParser.PhraseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDefinition(EscherParser.DefinitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDefinition(EscherParser.DefinitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTileDefinition(EscherParser.TileDefinitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTileDefinition(EscherParser.TileDefinitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSubdivisionDefinition(EscherParser.SubdivisionDefinitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSubdivisionDefinition(EscherParser.SubdivisionDefinitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExpression(EscherParser.ExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExpression(EscherParser.ExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFunction(EscherParser.FunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFunction(EscherParser.FunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTileFunction(EscherParser.TileFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTileFunction(EscherParser.TileFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSplitFunction(EscherParser.SplitFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSplitFunction(EscherParser.SplitFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConnectFunction(EscherParser.ConnectFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConnectFunction(EscherParser.ConnectFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAssignment(EscherParser.AssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAssignment(EscherParser.AssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterVertexAssignment(EscherParser.VertexAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitVertexAssignment(EscherParser.VertexAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEdgeAssignment(EscherParser.EdgeAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEdgeAssignment(EscherParser.EdgeAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterChildAssignment(EscherParser.ChildAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitChildAssignment(EscherParser.ChildAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGraphAssignment(EscherParser.GraphAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGraphAssignment(EscherParser.GraphAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGraphDeclaration(EscherParser.GraphDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGraphDeclaration(EscherParser.GraphDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterChildList(EscherParser.ChildListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitChildList(EscherParser.ChildListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNode(EscherParser.NodeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNode(EscherParser.NodeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFace(EscherParser.FaceContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFace(EscherParser.FaceContext ctx) { } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitTerminal(TerminalNode node) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file diff --git a/src/tilings/language/grammar/EscherBaseVisitor.java b/src/tilings/language/grammar/EscherBaseVisitor.java deleted file mode 100644 index 4c62a94..0000000 --- a/src/tilings/language/grammar/EscherBaseVisitor.java +++ /dev/null @@ -1,162 +0,0 @@ -package tilings.language.grammar; - -// Generated from Escher.g4 by ANTLR 4.7.1 -import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; - -/** - * This class provides an empty implementation of {@link EscherVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public class EscherBaseVisitor extends AbstractParseTreeVisitor implements EscherVisitor { - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFile(EscherParser.FileContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMainline(EscherParser.MainlineContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSubline(EscherParser.SublineContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitPhrase(EscherParser.PhraseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDefinition(EscherParser.DefinitionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTileDefinition(EscherParser.TileDefinitionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSubdivisionDefinition(EscherParser.SubdivisionDefinitionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExpression(EscherParser.ExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFunction(EscherParser.FunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTileFunction(EscherParser.TileFunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSplitFunction(EscherParser.SplitFunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitConnectFunction(EscherParser.ConnectFunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAssignment(EscherParser.AssignmentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitVertexAssignment(EscherParser.VertexAssignmentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEdgeAssignment(EscherParser.EdgeAssignmentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitChildAssignment(EscherParser.ChildAssignmentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGraphAssignment(EscherParser.GraphAssignmentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGraphDeclaration(EscherParser.GraphDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitChildList(EscherParser.ChildListContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNode(EscherParser.NodeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFace(EscherParser.FaceContext ctx) { return visitChildren(ctx); } -} \ No newline at end of file diff --git a/src/tilings/language/grammar/EscherLexer.interp b/src/tilings/language/grammar/EscherLexer.interp deleted file mode 100644 index dcc774b..0000000 --- a/src/tilings/language/grammar/EscherLexer.interp +++ /dev/null @@ -1,91 +0,0 @@ -token literal names: -null -'{' -',' -'}' -'(' -')' -'=' -'[' -']' -'.' -'vertex' -'face' -'GRAPH' -'CHILD' -'SUBDIVISION' -'TILETYPE' -'VERTEX' -'EDGE' -'tile' -'split' -'connect' -';' -null -null -null - -token symbolic names: -null -null -null -null -null -null -null -null -null -null -null -null -GRAPH -CHILD -SUBDIVISION -TILETYPE -VERTEX -EDGE -TILE -SPLIT -CONNECT -END -WHITESPACE -NUMBER -ID - -rule names: -T__0 -T__1 -T__2 -T__3 -T__4 -T__5 -T__6 -T__7 -T__8 -T__9 -T__10 -LETTER -DIGIT -GRAPH -CHILD -SUBDIVISION -TILETYPE -VERTEX -EDGE -TILE -SPLIT -CONNECT -END -WHITESPACE -NUMBER -ID - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 26, 178, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 6, 13, 87, 10, 13, 13, 13, 14, 13, 88, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 6, 25, 160, 10, 25, 13, 25, 14, 25, 161, 3, 25, 3, 25, 3, 26, 6, 26, 167, 10, 26, 13, 26, 14, 26, 168, 3, 27, 3, 27, 3, 27, 7, 27, 174, 10, 27, 12, 27, 14, 27, 177, 11, 27, 2, 2, 28, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 2, 27, 2, 29, 14, 31, 15, 33, 16, 35, 17, 37, 18, 39, 19, 41, 20, 43, 21, 45, 22, 47, 23, 49, 24, 51, 25, 53, 26, 3, 2, 4, 4, 2, 67, 92, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 2, 180, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 3, 55, 3, 2, 2, 2, 5, 57, 3, 2, 2, 2, 7, 59, 3, 2, 2, 2, 9, 61, 3, 2, 2, 2, 11, 63, 3, 2, 2, 2, 13, 65, 3, 2, 2, 2, 15, 67, 3, 2, 2, 2, 17, 69, 3, 2, 2, 2, 19, 71, 3, 2, 2, 2, 21, 73, 3, 2, 2, 2, 23, 80, 3, 2, 2, 2, 25, 86, 3, 2, 2, 2, 27, 90, 3, 2, 2, 2, 29, 92, 3, 2, 2, 2, 31, 98, 3, 2, 2, 2, 33, 104, 3, 2, 2, 2, 35, 116, 3, 2, 2, 2, 37, 125, 3, 2, 2, 2, 39, 132, 3, 2, 2, 2, 41, 137, 3, 2, 2, 2, 43, 142, 3, 2, 2, 2, 45, 148, 3, 2, 2, 2, 47, 156, 3, 2, 2, 2, 49, 159, 3, 2, 2, 2, 51, 166, 3, 2, 2, 2, 53, 170, 3, 2, 2, 2, 55, 56, 7, 125, 2, 2, 56, 4, 3, 2, 2, 2, 57, 58, 7, 46, 2, 2, 58, 6, 3, 2, 2, 2, 59, 60, 7, 127, 2, 2, 60, 8, 3, 2, 2, 2, 61, 62, 7, 42, 2, 2, 62, 10, 3, 2, 2, 2, 63, 64, 7, 43, 2, 2, 64, 12, 3, 2, 2, 2, 65, 66, 7, 63, 2, 2, 66, 14, 3, 2, 2, 2, 67, 68, 7, 93, 2, 2, 68, 16, 3, 2, 2, 2, 69, 70, 7, 95, 2, 2, 70, 18, 3, 2, 2, 2, 71, 72, 7, 48, 2, 2, 72, 20, 3, 2, 2, 2, 73, 74, 7, 120, 2, 2, 74, 75, 7, 103, 2, 2, 75, 76, 7, 116, 2, 2, 76, 77, 7, 118, 2, 2, 77, 78, 7, 103, 2, 2, 78, 79, 7, 122, 2, 2, 79, 22, 3, 2, 2, 2, 80, 81, 7, 104, 2, 2, 81, 82, 7, 99, 2, 2, 82, 83, 7, 101, 2, 2, 83, 84, 7, 103, 2, 2, 84, 24, 3, 2, 2, 2, 85, 87, 9, 2, 2, 2, 86, 85, 3, 2, 2, 2, 87, 88, 3, 2, 2, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, 26, 3, 2, 2, 2, 90, 91, 4, 50, 59, 2, 91, 28, 3, 2, 2, 2, 92, 93, 7, 73, 2, 2, 93, 94, 7, 84, 2, 2, 94, 95, 7, 67, 2, 2, 95, 96, 7, 82, 2, 2, 96, 97, 7, 74, 2, 2, 97, 30, 3, 2, 2, 2, 98, 99, 7, 69, 2, 2, 99, 100, 7, 74, 2, 2, 100, 101, 7, 75, 2, 2, 101, 102, 7, 78, 2, 2, 102, 103, 7, 70, 2, 2, 103, 32, 3, 2, 2, 2, 104, 105, 7, 85, 2, 2, 105, 106, 7, 87, 2, 2, 106, 107, 7, 68, 2, 2, 107, 108, 7, 70, 2, 2, 108, 109, 7, 75, 2, 2, 109, 110, 7, 88, 2, 2, 110, 111, 7, 75, 2, 2, 111, 112, 7, 85, 2, 2, 112, 113, 7, 75, 2, 2, 113, 114, 7, 81, 2, 2, 114, 115, 7, 80, 2, 2, 115, 34, 3, 2, 2, 2, 116, 117, 7, 86, 2, 2, 117, 118, 7, 75, 2, 2, 118, 119, 7, 78, 2, 2, 119, 120, 7, 71, 2, 2, 120, 121, 7, 86, 2, 2, 121, 122, 7, 91, 2, 2, 122, 123, 7, 82, 2, 2, 123, 124, 7, 71, 2, 2, 124, 36, 3, 2, 2, 2, 125, 126, 7, 88, 2, 2, 126, 127, 7, 71, 2, 2, 127, 128, 7, 84, 2, 2, 128, 129, 7, 86, 2, 2, 129, 130, 7, 71, 2, 2, 130, 131, 7, 90, 2, 2, 131, 38, 3, 2, 2, 2, 132, 133, 7, 71, 2, 2, 133, 134, 7, 70, 2, 2, 134, 135, 7, 73, 2, 2, 135, 136, 7, 71, 2, 2, 136, 40, 3, 2, 2, 2, 137, 138, 7, 118, 2, 2, 138, 139, 7, 107, 2, 2, 139, 140, 7, 110, 2, 2, 140, 141, 7, 103, 2, 2, 141, 42, 3, 2, 2, 2, 142, 143, 7, 117, 2, 2, 143, 144, 7, 114, 2, 2, 144, 145, 7, 110, 2, 2, 145, 146, 7, 107, 2, 2, 146, 147, 7, 118, 2, 2, 147, 44, 3, 2, 2, 2, 148, 149, 7, 101, 2, 2, 149, 150, 7, 113, 2, 2, 150, 151, 7, 112, 2, 2, 151, 152, 7, 112, 2, 2, 152, 153, 7, 103, 2, 2, 153, 154, 7, 101, 2, 2, 154, 155, 7, 118, 2, 2, 155, 46, 3, 2, 2, 2, 156, 157, 7, 61, 2, 2, 157, 48, 3, 2, 2, 2, 158, 160, 9, 3, 2, 2, 159, 158, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 161, 159, 3, 2, 2, 2, 161, 162, 3, 2, 2, 2, 162, 163, 3, 2, 2, 2, 163, 164, 8, 25, 2, 2, 164, 50, 3, 2, 2, 2, 165, 167, 5, 27, 14, 2, 166, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 52, 3, 2, 2, 2, 170, 175, 5, 25, 13, 2, 171, 174, 5, 25, 13, 2, 172, 174, 5, 27, 14, 2, 173, 171, 3, 2, 2, 2, 173, 172, 3, 2, 2, 2, 174, 177, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 175, 176, 3, 2, 2, 2, 176, 54, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 8, 2, 88, 161, 168, 173, 175, 3, 8, 2, 2] \ No newline at end of file diff --git a/src/tilings/language/grammar/EscherLexer.java b/src/tilings/language/grammar/EscherLexer.java deleted file mode 100644 index e3e481e..0000000 --- a/src/tilings/language/grammar/EscherLexer.java +++ /dev/null @@ -1,167 +0,0 @@ -package tilings.language.grammar; - -// Generated from Escher.g4 by ANTLR 4.7.1 -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) -public class EscherLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, GRAPH=12, CHILD=13, SUBDIVISION=14, TILETYPE=15, VERTEX=16, - EDGE=17, TILE=18, SPLIT=19, CONNECT=20, END=21, WHITESPACE=22, NUMBER=23, - ID=24; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - public static final String[] ruleNames = { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "LETTER", "DIGIT", "GRAPH", "CHILD", "SUBDIVISION", "TILETYPE", - "VERTEX", "EDGE", "TILE", "SPLIT", "CONNECT", "END", "WHITESPACE", "NUMBER", - "ID" - }; - - private static final String[] _LITERAL_NAMES = { - null, "'{'", "','", "'}'", "'('", "')'", "'='", "'['", "']'", "'.'", "'vertex'", - "'face'", "'GRAPH'", "'CHILD'", "'SUBDIVISION'", "'TILETYPE'", "'VERTEX'", - "'EDGE'", "'tile'", "'split'", "'connect'", "';'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - "GRAPH", "CHILD", "SUBDIVISION", "TILETYPE", "VERTEX", "EDGE", "TILE", - "SPLIT", "CONNECT", "END", "WHITESPACE", "NUMBER", "ID" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public EscherLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "Escher.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getChannelNames() { return channelNames; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\32\u00b2\b\1\4\2"+ - "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+ - "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+ - "\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31"+ - "\t\31\4\32\t\32\4\33\t\33\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7"+ - "\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3"+ - "\f\3\f\3\f\3\f\3\r\6\rW\n\r\r\r\16\rX\3\16\3\16\3\17\3\17\3\17\3\17\3"+ - "\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3"+ - "\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3"+ - "\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3"+ - "\25\3\25\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3"+ - "\27\3\27\3\27\3\27\3\30\3\30\3\31\6\31\u00a0\n\31\r\31\16\31\u00a1\3\31"+ - "\3\31\3\32\6\32\u00a7\n\32\r\32\16\32\u00a8\3\33\3\33\3\33\7\33\u00ae"+ - "\n\33\f\33\16\33\u00b1\13\33\2\2\34\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n"+ - "\23\13\25\f\27\r\31\2\33\2\35\16\37\17!\20#\21%\22\'\23)\24+\25-\26/\27"+ - "\61\30\63\31\65\32\3\2\4\4\2C\\c|\5\2\13\f\17\17\"\"\2\u00b4\2\3\3\2\2"+ - "\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3"+ - "\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\35\3\2\2"+ - "\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2"+ - "\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2"+ - "\2\2\3\67\3\2\2\2\59\3\2\2\2\7;\3\2\2\2\t=\3\2\2\2\13?\3\2\2\2\rA\3\2"+ - "\2\2\17C\3\2\2\2\21E\3\2\2\2\23G\3\2\2\2\25I\3\2\2\2\27P\3\2\2\2\31V\3"+ - "\2\2\2\33Z\3\2\2\2\35\\\3\2\2\2\37b\3\2\2\2!h\3\2\2\2#t\3\2\2\2%}\3\2"+ - "\2\2\'\u0084\3\2\2\2)\u0089\3\2\2\2+\u008e\3\2\2\2-\u0094\3\2\2\2/\u009c"+ - "\3\2\2\2\61\u009f\3\2\2\2\63\u00a6\3\2\2\2\65\u00aa\3\2\2\2\678\7}\2\2"+ - "8\4\3\2\2\29:\7.\2\2:\6\3\2\2\2;<\7\177\2\2<\b\3\2\2\2=>\7*\2\2>\n\3\2"+ - "\2\2?@\7+\2\2@\f\3\2\2\2AB\7?\2\2B\16\3\2\2\2CD\7]\2\2D\20\3\2\2\2EF\7"+ - "_\2\2F\22\3\2\2\2GH\7\60\2\2H\24\3\2\2\2IJ\7x\2\2JK\7g\2\2KL\7t\2\2LM"+ - "\7v\2\2MN\7g\2\2NO\7z\2\2O\26\3\2\2\2PQ\7h\2\2QR\7c\2\2RS\7e\2\2ST\7g"+ - "\2\2T\30\3\2\2\2UW\t\2\2\2VU\3\2\2\2WX\3\2\2\2XV\3\2\2\2XY\3\2\2\2Y\32"+ - "\3\2\2\2Z[\4\62;\2[\34\3\2\2\2\\]\7I\2\2]^\7T\2\2^_\7C\2\2_`\7R\2\2`a"+ - "\7J\2\2a\36\3\2\2\2bc\7E\2\2cd\7J\2\2de\7K\2\2ef\7N\2\2fg\7F\2\2g \3\2"+ - "\2\2hi\7U\2\2ij\7W\2\2jk\7D\2\2kl\7F\2\2lm\7K\2\2mn\7X\2\2no\7K\2\2op"+ - "\7U\2\2pq\7K\2\2qr\7Q\2\2rs\7P\2\2s\"\3\2\2\2tu\7V\2\2uv\7K\2\2vw\7N\2"+ - "\2wx\7G\2\2xy\7V\2\2yz\7[\2\2z{\7R\2\2{|\7G\2\2|$\3\2\2\2}~\7X\2\2~\177"+ - "\7G\2\2\177\u0080\7T\2\2\u0080\u0081\7V\2\2\u0081\u0082\7G\2\2\u0082\u0083"+ - "\7Z\2\2\u0083&\3\2\2\2\u0084\u0085\7G\2\2\u0085\u0086\7F\2\2\u0086\u0087"+ - "\7I\2\2\u0087\u0088\7G\2\2\u0088(\3\2\2\2\u0089\u008a\7v\2\2\u008a\u008b"+ - "\7k\2\2\u008b\u008c\7n\2\2\u008c\u008d\7g\2\2\u008d*\3\2\2\2\u008e\u008f"+ - "\7u\2\2\u008f\u0090\7r\2\2\u0090\u0091\7n\2\2\u0091\u0092\7k\2\2\u0092"+ - "\u0093\7v\2\2\u0093,\3\2\2\2\u0094\u0095\7e\2\2\u0095\u0096\7q\2\2\u0096"+ - "\u0097\7p\2\2\u0097\u0098\7p\2\2\u0098\u0099\7g\2\2\u0099\u009a\7e\2\2"+ - "\u009a\u009b\7v\2\2\u009b.\3\2\2\2\u009c\u009d\7=\2\2\u009d\60\3\2\2\2"+ - "\u009e\u00a0\t\3\2\2\u009f\u009e\3\2\2\2\u00a0\u00a1\3\2\2\2\u00a1\u009f"+ - "\3\2\2\2\u00a1\u00a2\3\2\2\2\u00a2\u00a3\3\2\2\2\u00a3\u00a4\b\31\2\2"+ - "\u00a4\62\3\2\2\2\u00a5\u00a7\5\33\16\2\u00a6\u00a5\3\2\2\2\u00a7\u00a8"+ - "\3\2\2\2\u00a8\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9\64\3\2\2\2\u00aa"+ - "\u00af\5\31\r\2\u00ab\u00ae\5\31\r\2\u00ac\u00ae\5\33\16\2\u00ad\u00ab"+ - "\3\2\2\2\u00ad\u00ac\3\2\2\2\u00ae\u00b1\3\2\2\2\u00af\u00ad\3\2\2\2\u00af"+ - "\u00b0\3\2\2\2\u00b0\66\3\2\2\2\u00b1\u00af\3\2\2\2\b\2X\u00a1\u00a8\u00ad"+ - "\u00af\3\b\2\2"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/tilings/language/grammar/EscherLexer.tokens b/src/tilings/language/grammar/EscherLexer.tokens deleted file mode 100644 index 658598d..0000000 --- a/src/tilings/language/grammar/EscherLexer.tokens +++ /dev/null @@ -1,45 +0,0 @@ -T__0=1 -T__1=2 -T__2=3 -T__3=4 -T__4=5 -T__5=6 -T__6=7 -T__7=8 -T__8=9 -T__9=10 -T__10=11 -GRAPH=12 -CHILD=13 -SUBDIVISION=14 -TILETYPE=15 -VERTEX=16 -EDGE=17 -TILE=18 -SPLIT=19 -CONNECT=20 -END=21 -WHITESPACE=22 -NUMBER=23 -ID=24 -'{'=1 -','=2 -'}'=3 -'('=4 -')'=5 -'='=6 -'['=7 -']'=8 -'.'=9 -'vertex'=10 -'face'=11 -'GRAPH'=12 -'CHILD'=13 -'SUBDIVISION'=14 -'TILETYPE'=15 -'VERTEX'=16 -'EDGE'=17 -'tile'=18 -'split'=19 -'connect'=20 -';'=21 diff --git a/src/tilings/language/grammar/EscherListener.java b/src/tilings/language/grammar/EscherListener.java deleted file mode 100644 index 946ebf8..0000000 --- a/src/tilings/language/grammar/EscherListener.java +++ /dev/null @@ -1,221 +0,0 @@ -package tilings.language.grammar; - -// Generated from Escher.g4 by ANTLR 4.7.1 -import org.antlr.v4.runtime.tree.ParseTreeListener; - -/** - * This interface defines a complete listener for a parse tree produced by - * {@link EscherParser}. - */ -public interface EscherListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link EscherParser#file}. - * @param ctx the parse tree - */ - void enterFile(EscherParser.FileContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#file}. - * @param ctx the parse tree - */ - void exitFile(EscherParser.FileContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#mainline}. - * @param ctx the parse tree - */ - void enterMainline(EscherParser.MainlineContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#mainline}. - * @param ctx the parse tree - */ - void exitMainline(EscherParser.MainlineContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#subline}. - * @param ctx the parse tree - */ - void enterSubline(EscherParser.SublineContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#subline}. - * @param ctx the parse tree - */ - void exitSubline(EscherParser.SublineContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#phrase}. - * @param ctx the parse tree - */ - void enterPhrase(EscherParser.PhraseContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#phrase}. - * @param ctx the parse tree - */ - void exitPhrase(EscherParser.PhraseContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#definition}. - * @param ctx the parse tree - */ - void enterDefinition(EscherParser.DefinitionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#definition}. - * @param ctx the parse tree - */ - void exitDefinition(EscherParser.DefinitionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#tileDefinition}. - * @param ctx the parse tree - */ - void enterTileDefinition(EscherParser.TileDefinitionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#tileDefinition}. - * @param ctx the parse tree - */ - void exitTileDefinition(EscherParser.TileDefinitionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#subdivisionDefinition}. - * @param ctx the parse tree - */ - void enterSubdivisionDefinition(EscherParser.SubdivisionDefinitionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#subdivisionDefinition}. - * @param ctx the parse tree - */ - void exitSubdivisionDefinition(EscherParser.SubdivisionDefinitionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#expression}. - * @param ctx the parse tree - */ - void enterExpression(EscherParser.ExpressionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#expression}. - * @param ctx the parse tree - */ - void exitExpression(EscherParser.ExpressionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#function}. - * @param ctx the parse tree - */ - void enterFunction(EscherParser.FunctionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#function}. - * @param ctx the parse tree - */ - void exitFunction(EscherParser.FunctionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#tileFunction}. - * @param ctx the parse tree - */ - void enterTileFunction(EscherParser.TileFunctionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#tileFunction}. - * @param ctx the parse tree - */ - void exitTileFunction(EscherParser.TileFunctionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#splitFunction}. - * @param ctx the parse tree - */ - void enterSplitFunction(EscherParser.SplitFunctionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#splitFunction}. - * @param ctx the parse tree - */ - void exitSplitFunction(EscherParser.SplitFunctionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#connectFunction}. - * @param ctx the parse tree - */ - void enterConnectFunction(EscherParser.ConnectFunctionContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#connectFunction}. - * @param ctx the parse tree - */ - void exitConnectFunction(EscherParser.ConnectFunctionContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#assignment}. - * @param ctx the parse tree - */ - void enterAssignment(EscherParser.AssignmentContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#assignment}. - * @param ctx the parse tree - */ - void exitAssignment(EscherParser.AssignmentContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#vertexAssignment}. - * @param ctx the parse tree - */ - void enterVertexAssignment(EscherParser.VertexAssignmentContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#vertexAssignment}. - * @param ctx the parse tree - */ - void exitVertexAssignment(EscherParser.VertexAssignmentContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#edgeAssignment}. - * @param ctx the parse tree - */ - void enterEdgeAssignment(EscherParser.EdgeAssignmentContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#edgeAssignment}. - * @param ctx the parse tree - */ - void exitEdgeAssignment(EscherParser.EdgeAssignmentContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#childAssignment}. - * @param ctx the parse tree - */ - void enterChildAssignment(EscherParser.ChildAssignmentContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#childAssignment}. - * @param ctx the parse tree - */ - void exitChildAssignment(EscherParser.ChildAssignmentContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#graphAssignment}. - * @param ctx the parse tree - */ - void enterGraphAssignment(EscherParser.GraphAssignmentContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#graphAssignment}. - * @param ctx the parse tree - */ - void exitGraphAssignment(EscherParser.GraphAssignmentContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#graphDeclaration}. - * @param ctx the parse tree - */ - void enterGraphDeclaration(EscherParser.GraphDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#graphDeclaration}. - * @param ctx the parse tree - */ - void exitGraphDeclaration(EscherParser.GraphDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#childList}. - * @param ctx the parse tree - */ - void enterChildList(EscherParser.ChildListContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#childList}. - * @param ctx the parse tree - */ - void exitChildList(EscherParser.ChildListContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#node}. - * @param ctx the parse tree - */ - void enterNode(EscherParser.NodeContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#node}. - * @param ctx the parse tree - */ - void exitNode(EscherParser.NodeContext ctx); - /** - * Enter a parse tree produced by {@link EscherParser#face}. - * @param ctx the parse tree - */ - void enterFace(EscherParser.FaceContext ctx); - /** - * Exit a parse tree produced by {@link EscherParser#face}. - * @param ctx the parse tree - */ - void exitFace(EscherParser.FaceContext ctx); -} \ No newline at end of file diff --git a/src/tilings/language/grammar/EscherParser.java b/src/tilings/language/grammar/EscherParser.java deleted file mode 100644 index 7328455..0000000 --- a/src/tilings/language/grammar/EscherParser.java +++ /dev/null @@ -1,1526 +0,0 @@ -package tilings.language.grammar; - -// Generated from Escher.g4 by ANTLR 4.7.1 -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.misc.*; -import org.antlr.v4.runtime.tree.*; -import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) -public class EscherParser extends Parser { - static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, GRAPH=12, CHILD=13, SUBDIVISION=14, TILETYPE=15, VERTEX=16, - EDGE=17, TILE=18, SPLIT=19, CONNECT=20, END=21, WHITESPACE=22, NUMBER=23, - ID=24; - public static final int - RULE_file = 0, RULE_mainline = 1, RULE_subline = 2, RULE_phrase = 3, RULE_definition = 4, - RULE_tileDefinition = 5, RULE_subdivisionDefinition = 6, RULE_expression = 7, - RULE_function = 8, RULE_tileFunction = 9, RULE_splitFunction = 10, RULE_connectFunction = 11, - RULE_assignment = 12, RULE_vertexAssignment = 13, RULE_edgeAssignment = 14, - RULE_childAssignment = 15, RULE_graphAssignment = 16, RULE_graphDeclaration = 17, - RULE_childList = 18, RULE_node = 19, RULE_face = 20; - public static final String[] ruleNames = { - "file", "mainline", "subline", "phrase", "definition", "tileDefinition", - "subdivisionDefinition", "expression", "function", "tileFunction", "splitFunction", - "connectFunction", "assignment", "vertexAssignment", "edgeAssignment", - "childAssignment", "graphAssignment", "graphDeclaration", "childList", - "node", "face" - }; - - private static final String[] _LITERAL_NAMES = { - null, "'{'", "','", "'}'", "'('", "')'", "'='", "'['", "']'", "'.'", "'vertex'", - "'face'", "'GRAPH'", "'CHILD'", "'SUBDIVISION'", "'TILETYPE'", "'VERTEX'", - "'EDGE'", "'tile'", "'split'", "'connect'", "';'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - "GRAPH", "CHILD", "SUBDIVISION", "TILETYPE", "VERTEX", "EDGE", "TILE", - "SPLIT", "CONNECT", "END", "WHITESPACE", "NUMBER", "ID" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "Escher.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - public EscherParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - public static class FileContext extends ParserRuleContext { - public List mainline() { - return getRuleContexts(MainlineContext.class); - } - public MainlineContext mainline(int i) { - return getRuleContext(MainlineContext.class,i); - } - public FileContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_file; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterFile(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitFile(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitFile(this); - else return visitor.visitChildren(this); - } - } - - public final FileContext file() throws RecognitionException { - FileContext _localctx = new FileContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_file); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(43); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(42); - mainline(); - } - } - setState(45); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << CHILD) | (1L << SUBDIVISION) | (1L << TILETYPE) | (1L << VERTEX) | (1L << EDGE) | (1L << TILE) | (1L << SPLIT) | (1L << CONNECT))) != 0) ); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class MainlineContext extends ParserRuleContext { - public PhraseContext phrase() { - return getRuleContext(PhraseContext.class,0); - } - public TerminalNode END() { return getToken(EscherParser.END, 0); } - public MainlineContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_mainline; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterMainline(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitMainline(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitMainline(this); - else return visitor.visitChildren(this); - } - } - - public final MainlineContext mainline() throws RecognitionException { - MainlineContext _localctx = new MainlineContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_mainline); - try { - enterOuterAlt(_localctx, 1); - { - setState(47); - phrase(); - setState(48); - match(END); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class SublineContext extends ParserRuleContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode END() { return getToken(EscherParser.END, 0); } - public SublineContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_subline; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterSubline(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitSubline(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitSubline(this); - else return visitor.visitChildren(this); - } - } - - public final SublineContext subline() throws RecognitionException { - SublineContext _localctx = new SublineContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_subline); - try { - enterOuterAlt(_localctx, 1); - { - setState(50); - expression(); - setState(51); - match(END); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class PhraseContext extends ParserRuleContext { - public DefinitionContext definition() { - return getRuleContext(DefinitionContext.class,0); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public PhraseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_phrase; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterPhrase(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitPhrase(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitPhrase(this); - else return visitor.visitChildren(this); - } - } - - public final PhraseContext phrase() throws RecognitionException { - PhraseContext _localctx = new PhraseContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_phrase); - try { - setState(55); - _errHandler.sync(this); - switch (_input.LA(1)) { - case SUBDIVISION: - case TILETYPE: - enterOuterAlt(_localctx, 1); - { - setState(53); - definition(); - } - break; - case CHILD: - case VERTEX: - case EDGE: - case TILE: - case SPLIT: - case CONNECT: - enterOuterAlt(_localctx, 2); - { - setState(54); - expression(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class DefinitionContext extends ParserRuleContext { - public TileDefinitionContext tileDefinition() { - return getRuleContext(TileDefinitionContext.class,0); - } - public SubdivisionDefinitionContext subdivisionDefinition() { - return getRuleContext(SubdivisionDefinitionContext.class,0); - } - public DefinitionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_definition; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterDefinition(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitDefinition(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitDefinition(this); - else return visitor.visitChildren(this); - } - } - - public final DefinitionContext definition() throws RecognitionException { - DefinitionContext _localctx = new DefinitionContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_definition); - try { - setState(59); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TILETYPE: - enterOuterAlt(_localctx, 1); - { - setState(57); - tileDefinition(); - } - break; - case SUBDIVISION: - enterOuterAlt(_localctx, 2); - { - setState(58); - subdivisionDefinition(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class TileDefinitionContext extends ParserRuleContext { - public TerminalNode TILETYPE() { return getToken(EscherParser.TILETYPE, 0); } - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public List NUMBER() { return getTokens(EscherParser.NUMBER); } - public TerminalNode NUMBER(int i) { - return getToken(EscherParser.NUMBER, i); - } - public TileDefinitionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_tileDefinition; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterTileDefinition(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitTileDefinition(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitTileDefinition(this); - else return visitor.visitChildren(this); - } - } - - public final TileDefinitionContext tileDefinition() throws RecognitionException { - TileDefinitionContext _localctx = new TileDefinitionContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_tileDefinition); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(61); - match(TILETYPE); - setState(62); - match(ID); - setState(63); - match(T__0); - setState(64); - match(NUMBER); - setState(69); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__1) { - { - { - setState(65); - match(T__1); - setState(66); - match(NUMBER); - } - } - setState(71); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(72); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class SubdivisionDefinitionContext extends ParserRuleContext { - public TerminalNode SUBDIVISION() { return getToken(EscherParser.SUBDIVISION, 0); } - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public List subline() { - return getRuleContexts(SublineContext.class); - } - public SublineContext subline(int i) { - return getRuleContext(SublineContext.class,i); - } - public SubdivisionDefinitionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_subdivisionDefinition; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterSubdivisionDefinition(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitSubdivisionDefinition(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitSubdivisionDefinition(this); - else return visitor.visitChildren(this); - } - } - - public final SubdivisionDefinitionContext subdivisionDefinition() throws RecognitionException { - SubdivisionDefinitionContext _localctx = new SubdivisionDefinitionContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_subdivisionDefinition); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(74); - match(SUBDIVISION); - setState(75); - match(ID); - setState(76); - match(T__0); - setState(78); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(77); - subline(); - } - } - setState(80); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << CHILD) | (1L << VERTEX) | (1L << EDGE) | (1L << TILE) | (1L << SPLIT) | (1L << CONNECT))) != 0) ); - setState(82); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class ExpressionContext extends ParserRuleContext { - public FunctionContext function() { - return getRuleContext(FunctionContext.class,0); - } - public AssignmentContext assignment() { - return getRuleContext(AssignmentContext.class,0); - } - public ExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitExpression(this); - else return visitor.visitChildren(this); - } - } - - public final ExpressionContext expression() throws RecognitionException { - ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_expression); - try { - setState(86); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TILE: - case SPLIT: - case CONNECT: - enterOuterAlt(_localctx, 1); - { - setState(84); - function(); - } - break; - case CHILD: - case VERTEX: - case EDGE: - enterOuterAlt(_localctx, 2); - { - setState(85); - assignment(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class FunctionContext extends ParserRuleContext { - public TileFunctionContext tileFunction() { - return getRuleContext(TileFunctionContext.class,0); - } - public SplitFunctionContext splitFunction() { - return getRuleContext(SplitFunctionContext.class,0); - } - public ConnectFunctionContext connectFunction() { - return getRuleContext(ConnectFunctionContext.class,0); - } - public FunctionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_function; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterFunction(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitFunction(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitFunction(this); - else return visitor.visitChildren(this); - } - } - - public final FunctionContext function() throws RecognitionException { - FunctionContext _localctx = new FunctionContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_function); - try { - setState(91); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TILE: - enterOuterAlt(_localctx, 1); - { - setState(88); - tileFunction(); - } - break; - case SPLIT: - enterOuterAlt(_localctx, 2); - { - setState(89); - splitFunction(); - } - break; - case CONNECT: - enterOuterAlt(_localctx, 3); - { - setState(90); - connectFunction(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class TileFunctionContext extends ParserRuleContext { - public TerminalNode TILE() { return getToken(EscherParser.TILE, 0); } - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public TerminalNode NUMBER() { return getToken(EscherParser.NUMBER, 0); } - public TileFunctionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_tileFunction; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterTileFunction(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitTileFunction(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitTileFunction(this); - else return visitor.visitChildren(this); - } - } - - public final TileFunctionContext tileFunction() throws RecognitionException { - TileFunctionContext _localctx = new TileFunctionContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_tileFunction); - try { - enterOuterAlt(_localctx, 1); - { - setState(93); - match(TILE); - setState(94); - match(T__3); - setState(95); - match(ID); - setState(96); - match(T__1); - setState(97); - match(NUMBER); - setState(98); - match(T__4); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class SplitFunctionContext extends ParserRuleContext { - public TerminalNode SPLIT() { return getToken(EscherParser.SPLIT, 0); } - public List node() { - return getRuleContexts(NodeContext.class); - } - public NodeContext node(int i) { - return getRuleContext(NodeContext.class,i); - } - public TerminalNode NUMBER() { return getToken(EscherParser.NUMBER, 0); } - public SplitFunctionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_splitFunction; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterSplitFunction(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitSplitFunction(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitSplitFunction(this); - else return visitor.visitChildren(this); - } - } - - public final SplitFunctionContext splitFunction() throws RecognitionException { - SplitFunctionContext _localctx = new SplitFunctionContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_splitFunction); - try { - enterOuterAlt(_localctx, 1); - { - setState(100); - match(SPLIT); - setState(101); - match(T__3); - setState(102); - node(); - setState(103); - match(T__1); - setState(104); - node(); - setState(105); - match(T__1); - setState(106); - match(NUMBER); - setState(107); - match(T__4); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class ConnectFunctionContext extends ParserRuleContext { - public TerminalNode CONNECT() { return getToken(EscherParser.CONNECT, 0); } - public List node() { - return getRuleContexts(NodeContext.class); - } - public NodeContext node(int i) { - return getRuleContext(NodeContext.class,i); - } - public ConnectFunctionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_connectFunction; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterConnectFunction(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitConnectFunction(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitConnectFunction(this); - else return visitor.visitChildren(this); - } - } - - public final ConnectFunctionContext connectFunction() throws RecognitionException { - ConnectFunctionContext _localctx = new ConnectFunctionContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_connectFunction); - try { - enterOuterAlt(_localctx, 1); - { - setState(109); - match(CONNECT); - setState(110); - match(T__3); - setState(111); - node(); - setState(112); - match(T__1); - setState(113); - node(); - setState(114); - match(T__4); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class AssignmentContext extends ParserRuleContext { - public VertexAssignmentContext vertexAssignment() { - return getRuleContext(VertexAssignmentContext.class,0); - } - public EdgeAssignmentContext edgeAssignment() { - return getRuleContext(EdgeAssignmentContext.class,0); - } - public ChildAssignmentContext childAssignment() { - return getRuleContext(ChildAssignmentContext.class,0); - } - public AssignmentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_assignment; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterAssignment(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitAssignment(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitAssignment(this); - else return visitor.visitChildren(this); - } - } - - public final AssignmentContext assignment() throws RecognitionException { - AssignmentContext _localctx = new AssignmentContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_assignment); - try { - setState(119); - _errHandler.sync(this); - switch (_input.LA(1)) { - case VERTEX: - enterOuterAlt(_localctx, 1); - { - setState(116); - vertexAssignment(); - } - break; - case EDGE: - enterOuterAlt(_localctx, 2); - { - setState(117); - edgeAssignment(); - } - break; - case CHILD: - enterOuterAlt(_localctx, 3); - { - setState(118); - childAssignment(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class VertexAssignmentContext extends ParserRuleContext { - public TerminalNode VERTEX() { return getToken(EscherParser.VERTEX, 0); } - public List ID() { return getTokens(EscherParser.ID); } - public TerminalNode ID(int i) { - return getToken(EscherParser.ID, i); - } - public SplitFunctionContext splitFunction() { - return getRuleContext(SplitFunctionContext.class,0); - } - public NodeContext node() { - return getRuleContext(NodeContext.class,0); - } - public VertexAssignmentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_vertexAssignment; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterVertexAssignment(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitVertexAssignment(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitVertexAssignment(this); - else return visitor.visitChildren(this); - } - } - - public final VertexAssignmentContext vertexAssignment() throws RecognitionException { - VertexAssignmentContext _localctx = new VertexAssignmentContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_vertexAssignment); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(121); - match(VERTEX); - setState(122); - match(ID); - setState(127); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__1) { - { - { - setState(123); - match(T__1); - setState(124); - match(ID); - } - } - setState(129); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(135); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__5) { - { - setState(130); - match(T__5); - setState(133); - _errHandler.sync(this); - switch (_input.LA(1)) { - case SPLIT: - { - setState(131); - splitFunction(); - } - break; - case ID: - { - setState(132); - node(); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class EdgeAssignmentContext extends ParserRuleContext { - public TerminalNode EDGE() { return getToken(EscherParser.EDGE, 0); } - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public ConnectFunctionContext connectFunction() { - return getRuleContext(ConnectFunctionContext.class,0); - } - public List node() { - return getRuleContexts(NodeContext.class); - } - public NodeContext node(int i) { - return getRuleContext(NodeContext.class,i); - } - public EdgeAssignmentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_edgeAssignment; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterEdgeAssignment(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitEdgeAssignment(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitEdgeAssignment(this); - else return visitor.visitChildren(this); - } - } - - public final EdgeAssignmentContext edgeAssignment() throws RecognitionException { - EdgeAssignmentContext _localctx = new EdgeAssignmentContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_edgeAssignment); - try { - enterOuterAlt(_localctx, 1); - { - setState(137); - match(EDGE); - setState(138); - match(ID); - setState(147); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__5: - { - { - setState(139); - match(T__5); - setState(140); - connectFunction(); - } - } - break; - case T__3: - { - { - setState(141); - match(T__3); - setState(142); - node(); - setState(143); - match(T__1); - setState(144); - node(); - setState(145); - match(T__4); - } - } - break; - default: - throw new NoViableAltException(this); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class ChildAssignmentContext extends ParserRuleContext { - public TerminalNode CHILD() { return getToken(EscherParser.CHILD, 0); } - public List ID() { return getTokens(EscherParser.ID); } - public TerminalNode ID(int i) { - return getToken(EscherParser.ID, i); - } - public List childList() { - return getRuleContexts(ChildListContext.class); - } - public ChildListContext childList(int i) { - return getRuleContext(ChildListContext.class,i); - } - public ChildAssignmentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_childAssignment; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterChildAssignment(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitChildAssignment(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitChildAssignment(this); - else return visitor.visitChildren(this); - } - } - - public final ChildAssignmentContext childAssignment() throws RecognitionException { - ChildAssignmentContext _localctx = new ChildAssignmentContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_childAssignment); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(149); - match(CHILD); - setState(150); - match(ID); - setState(151); - match(T__5); - setState(152); - match(ID); - setState(153); - match(T__3); - setState(155); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(154); - childList(); - } - } - setState(157); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( _la==T__6 ); - setState(159); - match(T__4); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class GraphAssignmentContext extends ParserRuleContext { - public TerminalNode GRAPH() { return getToken(EscherParser.GRAPH, 0); } - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public GraphDeclarationContext graphDeclaration() { - return getRuleContext(GraphDeclarationContext.class,0); - } - public GraphAssignmentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_graphAssignment; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterGraphAssignment(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitGraphAssignment(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitGraphAssignment(this); - else return visitor.visitChildren(this); - } - } - - public final GraphAssignmentContext graphAssignment() throws RecognitionException { - GraphAssignmentContext _localctx = new GraphAssignmentContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_graphAssignment); - try { - enterOuterAlt(_localctx, 1); - { - setState(161); - match(GRAPH); - setState(162); - match(ID); - setState(163); - match(T__5); - setState(164); - graphDeclaration(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class GraphDeclarationContext extends ParserRuleContext { - public TileFunctionContext tileFunction() { - return getRuleContext(TileFunctionContext.class,0); - } - public GraphDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_graphDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterGraphDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitGraphDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitGraphDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final GraphDeclarationContext graphDeclaration() throws RecognitionException { - GraphDeclarationContext _localctx = new GraphDeclarationContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_graphDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(166); - tileFunction(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class ChildListContext extends ParserRuleContext { - public List node() { - return getRuleContexts(NodeContext.class); - } - public NodeContext node(int i) { - return getRuleContext(NodeContext.class,i); - } - public ChildListContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_childList; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterChildList(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitChildList(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitChildList(this); - else return visitor.visitChildren(this); - } - } - - public final ChildListContext childList() throws RecognitionException { - ChildListContext _localctx = new ChildListContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_childList); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(168); - match(T__6); - setState(169); - node(); - setState(174); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__1) { - { - { - setState(170); - match(T__1); - setState(171); - node(); - } - } - setState(176); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(177); - match(T__7); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class NodeContext extends ParserRuleContext { - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public TerminalNode NUMBER() { return getToken(EscherParser.NUMBER, 0); } - public NodeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_node; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterNode(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitNode(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitNode(this); - else return visitor.visitChildren(this); - } - } - - public final NodeContext node() throws RecognitionException { - NodeContext _localctx = new NodeContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_node); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(179); - match(ID); - setState(185); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__8) { - { - setState(180); - match(T__8); - setState(181); - match(T__9); - setState(182); - match(T__6); - setState(183); - match(NUMBER); - setState(184); - match(T__7); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class FaceContext extends ParserRuleContext { - public TerminalNode ID() { return getToken(EscherParser.ID, 0); } - public TerminalNode NUMBER() { return getToken(EscherParser.NUMBER, 0); } - public FaceContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_face; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).enterFace(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EscherListener ) ((EscherListener)listener).exitFace(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof EscherVisitor ) return ((EscherVisitor)visitor).visitFace(this); - else return visitor.visitChildren(this); - } - } - - public final FaceContext face() throws RecognitionException { - FaceContext _localctx = new FaceContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_face); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(187); - match(ID); - setState(193); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__8) { - { - setState(188); - match(T__8); - setState(189); - match(T__10); - setState(190); - match(T__6); - setState(191); - match(NUMBER); - setState(192); - match(T__7); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\32\u00c6\4\2\t\2"+ - "\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ - "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\3\2\6\2.\n\2\r\2\16\2/\3\3\3"+ - "\3\3\3\3\4\3\4\3\4\3\5\3\5\5\5:\n\5\3\6\3\6\5\6>\n\6\3\7\3\7\3\7\3\7\3"+ - "\7\3\7\7\7F\n\7\f\7\16\7I\13\7\3\7\3\7\3\b\3\b\3\b\3\b\6\bQ\n\b\r\b\16"+ - "\bR\3\b\3\b\3\t\3\t\5\tY\n\t\3\n\3\n\3\n\5\n^\n\n\3\13\3\13\3\13\3\13"+ - "\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3"+ - "\r\3\r\3\r\3\16\3\16\3\16\5\16z\n\16\3\17\3\17\3\17\3\17\7\17\u0080\n"+ - "\17\f\17\16\17\u0083\13\17\3\17\3\17\3\17\5\17\u0088\n\17\5\17\u008a\n"+ - "\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\5\20\u0096\n\20"+ - "\3\21\3\21\3\21\3\21\3\21\3\21\6\21\u009e\n\21\r\21\16\21\u009f\3\21\3"+ - "\21\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\24\3\24\3\24\3\24\7\24\u00af"+ - "\n\24\f\24\16\24\u00b2\13\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\5"+ - "\25\u00bc\n\25\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u00c4\n\26\3\26\2\2"+ - "\27\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*\2\2\2\u00c2\2-\3\2\2"+ - "\2\4\61\3\2\2\2\6\64\3\2\2\2\b9\3\2\2\2\n=\3\2\2\2\f?\3\2\2\2\16L\3\2"+ - "\2\2\20X\3\2\2\2\22]\3\2\2\2\24_\3\2\2\2\26f\3\2\2\2\30o\3\2\2\2\32y\3"+ - "\2\2\2\34{\3\2\2\2\36\u008b\3\2\2\2 \u0097\3\2\2\2\"\u00a3\3\2\2\2$\u00a8"+ - "\3\2\2\2&\u00aa\3\2\2\2(\u00b5\3\2\2\2*\u00bd\3\2\2\2,.\5\4\3\2-,\3\2"+ - "\2\2./\3\2\2\2/-\3\2\2\2/\60\3\2\2\2\60\3\3\2\2\2\61\62\5\b\5\2\62\63"+ - "\7\27\2\2\63\5\3\2\2\2\64\65\5\20\t\2\65\66\7\27\2\2\66\7\3\2\2\2\67:"+ - "\5\n\6\28:\5\20\t\29\67\3\2\2\298\3\2\2\2:\t\3\2\2\2;>\5\f\7\2<>\5\16"+ - "\b\2=;\3\2\2\2=<\3\2\2\2>\13\3\2\2\2?@\7\21\2\2@A\7\32\2\2AB\7\3\2\2B"+ - "G\7\31\2\2CD\7\4\2\2DF\7\31\2\2EC\3\2\2\2FI\3\2\2\2GE\3\2\2\2GH\3\2\2"+ - "\2HJ\3\2\2\2IG\3\2\2\2JK\7\5\2\2K\r\3\2\2\2LM\7\20\2\2MN\7\32\2\2NP\7"+ - "\3\2\2OQ\5\6\4\2PO\3\2\2\2QR\3\2\2\2RP\3\2\2\2RS\3\2\2\2ST\3\2\2\2TU\7"+ - "\5\2\2U\17\3\2\2\2VY\5\22\n\2WY\5\32\16\2XV\3\2\2\2XW\3\2\2\2Y\21\3\2"+ - "\2\2Z^\5\24\13\2[^\5\26\f\2\\^\5\30\r\2]Z\3\2\2\2][\3\2\2\2]\\\3\2\2\2"+ - "^\23\3\2\2\2_`\7\24\2\2`a\7\6\2\2ab\7\32\2\2bc\7\4\2\2cd\7\31\2\2de\7"+ - "\7\2\2e\25\3\2\2\2fg\7\25\2\2gh\7\6\2\2hi\5(\25\2ij\7\4\2\2jk\5(\25\2"+ - "kl\7\4\2\2lm\7\31\2\2mn\7\7\2\2n\27\3\2\2\2op\7\26\2\2pq\7\6\2\2qr\5("+ - "\25\2rs\7\4\2\2st\5(\25\2tu\7\7\2\2u\31\3\2\2\2vz\5\34\17\2wz\5\36\20"+ - "\2xz\5 \21\2yv\3\2\2\2yw\3\2\2\2yx\3\2\2\2z\33\3\2\2\2{|\7\22\2\2|\u0081"+ - "\7\32\2\2}~\7\4\2\2~\u0080\7\32\2\2\177}\3\2\2\2\u0080\u0083\3\2\2\2\u0081"+ - "\177\3\2\2\2\u0081\u0082\3\2\2\2\u0082\u0089\3\2\2\2\u0083\u0081\3\2\2"+ - "\2\u0084\u0087\7\b\2\2\u0085\u0088\5\26\f\2\u0086\u0088\5(\25\2\u0087"+ - "\u0085\3\2\2\2\u0087\u0086\3\2\2\2\u0088\u008a\3\2\2\2\u0089\u0084\3\2"+ - "\2\2\u0089\u008a\3\2\2\2\u008a\35\3\2\2\2\u008b\u008c\7\23\2\2\u008c\u0095"+ - "\7\32\2\2\u008d\u008e\7\b\2\2\u008e\u0096\5\30\r\2\u008f\u0090\7\6\2\2"+ - "\u0090\u0091\5(\25\2\u0091\u0092\7\4\2\2\u0092\u0093\5(\25\2\u0093\u0094"+ - "\7\7\2\2\u0094\u0096\3\2\2\2\u0095\u008d\3\2\2\2\u0095\u008f\3\2\2\2\u0096"+ - "\37\3\2\2\2\u0097\u0098\7\17\2\2\u0098\u0099\7\32\2\2\u0099\u009a\7\b"+ - "\2\2\u009a\u009b\7\32\2\2\u009b\u009d\7\6\2\2\u009c\u009e\5&\24\2\u009d"+ - "\u009c\3\2\2\2\u009e\u009f\3\2\2\2\u009f\u009d\3\2\2\2\u009f\u00a0\3\2"+ - "\2\2\u00a0\u00a1\3\2\2\2\u00a1\u00a2\7\7\2\2\u00a2!\3\2\2\2\u00a3\u00a4"+ - "\7\16\2\2\u00a4\u00a5\7\32\2\2\u00a5\u00a6\7\b\2\2\u00a6\u00a7\5$\23\2"+ - "\u00a7#\3\2\2\2\u00a8\u00a9\5\24\13\2\u00a9%\3\2\2\2\u00aa\u00ab\7\t\2"+ - "\2\u00ab\u00b0\5(\25\2\u00ac\u00ad\7\4\2\2\u00ad\u00af\5(\25\2\u00ae\u00ac"+ - "\3\2\2\2\u00af\u00b2\3\2\2\2\u00b0\u00ae\3\2\2\2\u00b0\u00b1\3\2\2\2\u00b1"+ - "\u00b3\3\2\2\2\u00b2\u00b0\3\2\2\2\u00b3\u00b4\7\n\2\2\u00b4\'\3\2\2\2"+ - "\u00b5\u00bb\7\32\2\2\u00b6\u00b7\7\13\2\2\u00b7\u00b8\7\f\2\2\u00b8\u00b9"+ - "\7\t\2\2\u00b9\u00ba\7\31\2\2\u00ba\u00bc\7\n\2\2\u00bb\u00b6\3\2\2\2"+ - "\u00bb\u00bc\3\2\2\2\u00bc)\3\2\2\2\u00bd\u00c3\7\32\2\2\u00be\u00bf\7"+ - "\13\2\2\u00bf\u00c0\7\r\2\2\u00c0\u00c1\7\t\2\2\u00c1\u00c2\7\31\2\2\u00c2"+ - "\u00c4\7\n\2\2\u00c3\u00be\3\2\2\2\u00c3\u00c4\3\2\2\2\u00c4+\3\2\2\2"+ - "\22/9=GRX]y\u0081\u0087\u0089\u0095\u009f\u00b0\u00bb\u00c3"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/tilings/language/grammar/EscherVisitor.java b/src/tilings/language/grammar/EscherVisitor.java deleted file mode 100644 index da25a91..0000000 --- a/src/tilings/language/grammar/EscherVisitor.java +++ /dev/null @@ -1,140 +0,0 @@ -package tilings.language.grammar; - -// Generated from Escher.g4 by ANTLR 4.7.1 -import org.antlr.v4.runtime.tree.ParseTreeVisitor; - -/** - * This interface defines a complete generic visitor for a parse tree produced - * by {@link EscherParser}. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public interface EscherVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link EscherParser#file}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFile(EscherParser.FileContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#mainline}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMainline(EscherParser.MainlineContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#subline}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSubline(EscherParser.SublineContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#phrase}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPhrase(EscherParser.PhraseContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#definition}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDefinition(EscherParser.DefinitionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#tileDefinition}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTileDefinition(EscherParser.TileDefinitionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#subdivisionDefinition}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSubdivisionDefinition(EscherParser.SubdivisionDefinitionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpression(EscherParser.ExpressionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#function}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunction(EscherParser.FunctionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#tileFunction}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTileFunction(EscherParser.TileFunctionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#splitFunction}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSplitFunction(EscherParser.SplitFunctionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#connectFunction}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitConnectFunction(EscherParser.ConnectFunctionContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#assignment}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssignment(EscherParser.AssignmentContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#vertexAssignment}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitVertexAssignment(EscherParser.VertexAssignmentContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#edgeAssignment}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEdgeAssignment(EscherParser.EdgeAssignmentContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#childAssignment}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitChildAssignment(EscherParser.ChildAssignmentContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#graphAssignment}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGraphAssignment(EscherParser.GraphAssignmentContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#graphDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGraphDeclaration(EscherParser.GraphDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#childList}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitChildList(EscherParser.ChildListContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#node}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNode(EscherParser.NodeContext ctx); - /** - * Visit a parse tree produced by {@link EscherParser#face}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFace(EscherParser.FaceContext ctx); -} \ No newline at end of file