├── .clang-format ├── .gitignore ├── .workonrc.products ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── Makefile.config.example ├── README.md ├── docker ├── Dockerfile.centos7 ├── Dockerfile.debian └── README.md ├── src ├── SeExpr2 │ ├── CMakeLists.txt │ ├── Context.cpp │ ├── Context.h │ ├── ContextUtils.cpp │ ├── ContextUtils.h │ ├── Curve.cpp │ ├── Curve.h │ ├── Evaluator.h │ ├── ExprBuiltins.cpp │ ├── ExprBuiltins.h │ ├── ExprConfig.h.in │ ├── ExprEnv.cpp │ ├── ExprEnv.h │ ├── ExprFunc.cpp │ ├── ExprFunc.h │ ├── ExprFuncStandard.cpp │ ├── ExprFuncStandard.h │ ├── ExprFuncX.cpp │ ├── ExprFuncX.h │ ├── ExprLLVM.h │ ├── ExprLLVMAll.h │ ├── ExprLLVMCodeGeneration.cpp │ ├── ExprMultiExpr.cpp │ ├── ExprMultiExpr.h │ ├── ExprNode.cpp │ ├── ExprNode.h │ ├── ExprParser.h │ ├── ExprParser.y │ ├── ExprParserLex.l │ ├── ExprPatterns.h │ ├── ExprType.h │ ├── ExprWalker.cpp │ ├── ExprWalker.h │ ├── Expression.cpp │ ├── Expression.h │ ├── Interpreter.cpp │ ├── Interpreter.h │ ├── Mutex.h │ ├── Noise.cpp │ ├── Noise.h │ ├── NoiseTables.h │ ├── Platform.cpp │ ├── Platform.h │ ├── SeContext.cpp │ ├── SeContext.h │ ├── SeExprMacros.h │ ├── StringUtils.h │ ├── UI │ │ ├── BasicExpression.cpp │ │ ├── BasicExpression.h │ │ ├── CMakeLists.txt │ │ ├── ControlSpec.cpp │ │ ├── ControlSpec.h │ │ ├── EditMain.cpp │ │ ├── Editable.h │ │ ├── EditableExpression.cpp │ │ ├── EditableExpression.h │ │ ├── ExprBrowser.cpp │ │ ├── ExprBrowser.h │ │ ├── ExprColorCurve.cpp │ │ ├── ExprColorCurve.h │ │ ├── ExprColorSwatch.cpp │ │ ├── ExprColorSwatch.h │ │ ├── ExprCompletionModel.cpp │ │ ├── ExprCompletionModel.h │ │ ├── ExprControl.cpp │ │ ├── ExprControl.h │ │ ├── ExprControlCollection.cpp │ │ ├── ExprControlCollection.h │ │ ├── ExprCurve.cpp │ │ ├── ExprCurve.h │ │ ├── ExprDeepWater.cpp │ │ ├── ExprDeepWater.h │ │ ├── ExprDialog.cpp │ │ ├── ExprDialog.h │ │ ├── ExprEditor.cpp │ │ ├── ExprEditor.h │ │ ├── ExprFileDialog.cpp │ │ ├── ExprFileDialog.h │ │ ├── ExprGrapher2d.cpp │ │ ├── ExprGrapher2d.h │ │ ├── ExprHelp.h │ │ ├── ExprHighlighter.h │ │ ├── ExprMain.cpp │ │ ├── ExprPopupDoc.cpp │ │ ├── ExprPopupDoc.h │ │ ├── ExprShortEdit.cpp │ │ ├── ExprShortEdit.h │ │ ├── ExprSpecParser.y │ │ ├── ExprSpecParserLex.l │ │ ├── ExprSpecType.h │ │ ├── SeExpr2Editor.sip │ │ ├── __init__.py │ │ └── generated │ │ │ └── .gitignore │ ├── VarBlock.h │ ├── Vec.h │ ├── generated │ │ └── .gitignore │ └── parser │ │ ├── ASTNode.h │ │ ├── SeExprLex.cpp │ │ ├── SeExprLex.h │ │ ├── SeExprParse.cpp │ │ └── SeExprParse.h ├── build │ ├── build-info │ ├── macros.cmake │ ├── seexpr2-config.cmake │ └── seexpr2.pc.in ├── demos │ ├── CMakeLists.txt │ ├── asciiCalculator.cpp │ ├── asciiGraph.cpp │ ├── imageEditor │ │ ├── CMakeLists.txt │ │ ├── ImageEditorDialog.h │ │ ├── fbm.se │ │ ├── imageEditor.cpp │ │ ├── noise.se │ │ ├── noisecolor1.se │ │ ├── noisecolor2.se │ │ ├── raytrace.se │ │ └── sinc.se │ ├── imageSynth │ │ ├── CMakeLists.txt │ │ ├── examples │ │ │ ├── 111.se │ │ │ ├── fbm.se │ │ │ ├── noise.se │ │ │ ├── noisecolor1.se │ │ │ ├── noisecolor2.se │ │ │ ├── paint3d_test │ │ │ │ ├── RemapShadowContribution.se │ │ │ │ ├── bark_eucalyptusColor.se │ │ │ │ ├── bark_eucalyptusDisp.se │ │ │ │ ├── blackToWhite.se │ │ │ │ ├── candycane.se │ │ │ │ ├── color_noise.se │ │ │ │ ├── dither_with_gamma.se │ │ │ │ ├── freakles.se │ │ │ │ ├── lines.se │ │ │ │ ├── rope_Basic.se │ │ │ │ ├── scaleTool.se │ │ │ │ ├── select_byColorDark.se │ │ │ │ ├── select_byThreshold.se │ │ │ │ ├── textureI_nstancerCircular.se │ │ │ │ ├── texture_Instancer.se │ │ │ │ ├── texture_Tiler.se │ │ │ │ ├── threads.se │ │ │ │ ├── threshold.se │ │ │ │ ├── uv_testPattern.se │ │ │ │ ├── wood_Nicks.se │ │ │ │ └── xyz_colorNoise.se │ │ │ ├── raytrace.se │ │ │ ├── run.sh │ │ │ ├── sinc.se │ │ │ └── test.se │ │ ├── imageSynth.cpp │ │ └── imageSynthForPaint3d.cpp │ ├── llvmtest.cpp │ ├── rman2 │ │ ├── CMakeLists.txt │ │ ├── camera.rib │ │ ├── geometry.rib │ │ ├── immutable_hash_map.h │ │ ├── light.rib │ │ ├── main.rib │ │ ├── plane.rib │ │ ├── seop.cpp │ │ ├── test.rib │ │ ├── testdisp.sl │ │ └── testse.sl │ ├── segraph │ │ ├── GrapherExpr.h │ │ └── segraph.cpp │ └── segraph2 │ │ ├── CMakeLists.txt │ │ ├── Functions.cpp │ │ ├── Functions.h │ │ ├── Graph.cpp │ │ ├── Graph.h │ │ ├── GraphWindow.cpp │ │ ├── GraphWindow.h │ │ └── main.cpp ├── doc │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── Se_voronoi_1.png │ ├── Se_voronoi_2.png │ ├── Se_voronoi_3.png │ ├── Se_voronoi_4.png │ ├── Se_voronoi_5.png │ ├── license.txt │ ├── main.txt │ ├── plugins.txt │ ├── seexprlogo.png │ ├── summer-documentation │ │ ├── TODO-overview.txt │ │ ├── Wishlist-overview.txt │ │ ├── comment-overview.txt │ │ ├── overview.txt │ │ ├── pattern-matching-overview.txt │ │ ├── regression-tester-overview.txt │ │ ├── type-system-overview.txt │ │ ├── user-defined-function-overview.txt │ │ └── walker-overview.txt │ ├── tutorial.txt │ ├── ui_addWidget.png │ ├── ui_browser.png │ ├── ui_editor1.png │ ├── ui_emptyLayout.png │ ├── ui_final.png │ ├── ui_preview.png │ ├── uitutorial.txt │ ├── userdoc.txt │ └── varblocks.txt ├── py │ ├── CMakeLists.txt │ ├── SeExprPy.cpp │ ├── __init__.py │ ├── example.py │ ├── parseAll.py │ └── utils.py ├── tests │ ├── BlockTests.cpp │ ├── CMakeLists.txt │ ├── SeTests.h │ ├── TypeBuilder.h │ ├── TypeIterator.h │ ├── TypePrinter.cpp │ ├── TypePrinter.h │ ├── VarBlockExample.cpp │ ├── basic.cpp │ ├── basicPython.py │ ├── dirtSimple.cpp │ ├── genImageTestFile.py │ ├── htmlReport.py │ ├── imageTests.cpp │ ├── imageTestsReport.py │ ├── imageTestsReportNew.py │ ├── imagediff.py │ ├── llvmtest.se │ ├── llvmtest.str.se │ ├── llvmtest.test.se │ ├── multiTests.cpp │ ├── shortEdit.py │ ├── simpleEditor.py │ ├── string.cpp │ ├── testmain.cpp │ ├── typeTests.cpp │ └── typeTests.h └── utils │ ├── CMakeLists.txt │ ├── eval.cpp │ ├── listVar.cpp │ └── patterns.cpp └── windows7 ├── README ├── SeExpr └── generated │ ├── ExprParser.cpp │ ├── ExprParser.tab.h │ ├── ExprParserLex.cpp │ ├── ExprParserLexIn.cpp │ ├── SeExprParser.cpp │ ├── SeExprParser.tab.h │ └── SeExprParserLex.cpp ├── SeExprEditor └── generated │ ├── SeExprSpecParser.cpp │ ├── SeExprSpecParser.tab.h │ └── SeExprSpecParserLex.cpp └── ui └── generated ├── ExprSpecParser.cpp ├── ExprSpecParser.tab.h ├── ExprSpecParserLex.cpp └── ExprSpecParserLexIn.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: "Google" 3 | AccessModifierOffset: -2 4 | AlignEscapedNewlinesLeft: true 5 | AlignTrailingComments: true 6 | AllowAllParametersOfDeclarationOnNextLine: false 7 | AllowShortIfStatementsOnASingleLine: true 8 | ConstructorInitializerIndentWidth: 4 9 | AllowShortLoopsOnASingleLine: true 10 | AlwaysBreakBeforeMultilineStrings: true 11 | AlwaysBreakTemplateDeclarations: true 12 | BinPackParameters: false 13 | BreakBeforeBraces: Attach 14 | BreakConstructorInitializersBeforeComma: false 15 | ColumnLimit: 120 16 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 17 | Cpp11BracedListStyle: true 18 | IndentCaseLabels: true 19 | IndentFunctionDeclarationAfterType: true 20 | IndentWidth: 4 21 | MaxEmptyLinesToKeep: 1 22 | SpaceAfterControlStatementKeyword: true 23 | SpaceBeforeAssignmentOperators: true 24 | SpaceInEmptyParentheses: false 25 | SpacesBeforeTrailingComments: 2 26 | SpacesInAngles: false 27 | SpacesInCStyleCastParentheses: false 28 | SpacesInParentheses: false 29 | UseTab: Never 30 | PointerBindsToType: true 31 | #DerivePointerAlignment: false 32 | #AllowShortCaseLabelsOnASingleLine: true 33 | 34 | ... 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *# 3 | .DS_Store 4 | /build 5 | /Linux-* 6 | /Darwin-* 7 | /src/SeExpr2/parser 8 | /src/SeExprEditor/generated 9 | /env* 10 | CMakeCache.txt 11 | CMakeLists.txt.user 12 | CMakeSettings.json 13 | .vs 14 | .vscode 15 | -------------------------------------------------------------------------------- /.workonrc.products: -------------------------------------------------------------------------------- 1 | seexpr2 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We welcome pull requests with code improvements from anyone, as long as they are consistent with our design philosophy, and are code reviewed and tested. 4 | 5 | Please refer to our 'wishlist' issues for [needed code improvements][wishlist]. 6 | [wishlist]: https://github.com/wdas/SeExpr/issues?q=is%3Aissue+is%3Aopen+label%3Awishlist 7 | 8 | To work in the SeExpr code base: 9 | 10 | Fork, then clone the repo: 11 | 12 | git clone git@github.com:your-username/SeExpr. 13 | 14 | Set up your machine: 15 | 16 | cd SeExpr 17 | make install 18 | 19 | Make sure the tests pass: 20 | 21 | tbd 22 | 23 | Make your change. Add tests for your change. Make the tests pass: 24 | 25 | tbd 26 | 27 | Push to your fork and [submit a pull request][pr]. 28 | 29 | [pr]: https://github.com/wdas/SeExpr/compare/ 30 | 31 | We will strive to at least comment on pull requests within three business days. We may suggest some changes or improvements or alternatives. 32 | 33 | Some things that will increase the chance that your pull request is accepted: 34 | 35 | * Address issues tagged in our 'wishlist' 36 | * Write tests. 37 | * Comment code changes. 38 | * Write a good commit message. 39 | 40 | # Additional Resources 41 | 42 | * [Doxygen classes](http://wdas.github.io/SeExpr/doxygen/) 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Disney Enterprises, Inc. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License 5 | and the following modification to it: Section 6 Trademarks. 6 | deleted and replaced with: 7 | 8 | 6. Trademarks. This License does not grant permission to use the 9 | trade names, trademarks, service marks, or product names of the 10 | Licensor and its affiliates, except as required for reproducing 11 | the content of the NOTICE file. 12 | 13 | You may obtain a copy of the License at 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | -include Makefile.config 2 | 3 | # External commands 4 | CMAKE ?= cmake 5 | CLANG_FORMAT ?= clang-format 6 | FIND ?= find 7 | MKDIR ?= mkdir -p 8 | PYTHON ?= python 9 | RM_R ?= rm -fr 10 | XARGS ?= xargs 11 | 12 | ## Path and build flags 13 | FLAVOR ?= optimize 14 | BUILD = build/$(FLAVOR) 15 | #prefix ?= /usr/local 16 | #libdir ?= lib 17 | 18 | ## Temporary staging directory 19 | # DESTDIR = 20 | ## Specified by `git make-pkg` when building .pkg files 21 | # mac_pkg = 22 | 23 | ifdef prefix 24 | CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=$(prefix) 25 | endif 26 | ifdef libdir 27 | CMAKE_ARGS += -DCMAKE_INSTALL_LIBDIR=$(libdir) 28 | endif 29 | ifdef FLAVOR 30 | CMAKE_ARGS += -DFLAVOR=$(FLAVOR) 31 | endif 32 | 33 | CMAKE_FILES += Makefile 34 | CMAKE_FILES += $(wildcard CMakeLists.txt */*/CMakeLists.txt) 35 | 36 | export ARGS 37 | export CXX 38 | export DESTDIR 39 | export prefix 40 | 41 | all: $(BUILD) 42 | $(MAKE) -C $(BUILD) $@ 43 | 44 | install: all 45 | $(MAKE) -C $(BUILD) $@ 46 | 47 | test: install 48 | $(MAKE) -C $(BUILD) $@ 49 | 50 | clean: 51 | $(RM_R) $(BUILD) Linux-* Darwin-* 52 | 53 | $(BUILD): $(CMAKE_FILES) 54 | mkdir -p $(BUILD) 55 | cd $(BUILD) && $(CMAKE) $(CMAKE_ARGS) $(EXTRA_CMAKE_ARGS) ../.. 56 | touch $@ 57 | rm -f build/compile_commands.json 58 | ln -s $(FLAVOR)/compile_commands.json build/compile_commands.json 59 | 60 | format: 61 | git ls-files '*.cpp' '*.h' | $(XARGS) $(CLANG_FORMAT) -i 62 | 63 | precommit: format 64 | -------------------------------------------------------------------------------- /Makefile.config.example: -------------------------------------------------------------------------------- 1 | # Copy this file to "Makefile.config" to set default build flags 2 | 3 | uname_S := $(shell uname -s) 4 | 5 | # Example Linux config 6 | ifeq ($(uname_S),Linux) 7 | 8 | ifdef RP_gtest 9 | EXTRA_CMAKE_ARGS += -DGTEST_DIR=$(RP_gtest) 10 | else 11 | EXTRA_CMAKE_ARGS += -DGTEST_DIR=/usr 12 | endif 13 | 14 | # only build animlib if soure directory exists and env var set 15 | CE_dir = $(wildcard "src/ui/CE") 16 | ifneq ("$(CE_dir)", "") 17 | ifdef RP_animlib 18 | EXTRA_CMAKE_ARGS += -DANIMLIB_DIR=$(RP_animlib) 19 | endif 20 | endif 21 | 22 | ifdef RP_boost_disney 23 | EXTRA_CMAKE_ARGS += -DBOOST_DIR=$(RP_boost_disney) 24 | EXTRA_CMAKE_ARGS += -DBOOST_INCLUDE_DIR=$(RP_boost_disney)/include/boost-disney 25 | endif 26 | 27 | ifdef RP_derr 28 | EXTRA_CMAKE_ARGS += -DDERR_DIR=$(RP_derr) 29 | endif 30 | 31 | ifdef RP_dmsg 32 | EXTRA_CMAKE_ARGS += -DDMSG_DIR=$(RP_dmsg) 33 | endif 34 | 35 | ifdef RP_libpng 36 | EXTRA_CMAKE_ARGS += -DPNG_DIR=$(RP_libpng) 37 | endif 38 | 39 | ifdef RP_llvm_disney 40 | EXTRA_CMAKE_ARGS += -DLLVM_DIR=$(RP_llvm_disney) 41 | EXTRA_CMAKE_ARGS += -DLLVM_INCLUDE_DIR=$(RP_llvm_disney)/include 42 | endif 43 | 44 | ifdef RP_qdgui 45 | EXTRA_CMAKE_ARGS += -DQDGUI_DIR=$(RP_qdgui) 46 | endif 47 | 48 | ifdef RP_qt5 49 | EXTRA_CMAKE_ARGS += -DENABLE_QT5=true 50 | endif 51 | 52 | ifdef RP_pyqt5 53 | EXTRA_CMAKE_ARGS += -DPYQT_SIP_DIR=$(RP_pyqt5)/share/sip/PyQt5 54 | endif 55 | 56 | ifdef RP_pyqt4 57 | EXTRA_CMAKE_ARGS += -DPYQT_SIP_DIR=$(RP_pyqt4)/share/sip 58 | endif 59 | endif 60 | 61 | 62 | # Example Darwin config 63 | ifeq ($(uname_S),Darwin) 64 | EXTRA_CMAKE_ARGS += -DBOOST_DIR=/usr/local 65 | EXTRA_CMAKE_ARGS += -DENABLE_LLVM_BACKEND=ON 66 | EXTRA_CMAKE_ARGS += -DLLVM_DIR=$(HOME)/code/llvm-inst/share/llvm/cmake 67 | EXTRA_CMAKE_ARGS += -DGTEST_DIR=$(HOME)/code/gtest-inst/ 68 | EXTRA_CMAKE_ARGS += -DCUSTOM_PYTHON_FRAMEWORK="-m64 -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -L/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -ldl" 69 | EXTRA_CMAKE_ARGS += -DUSE_PYTHON=OFF 70 | endif 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | =================================================================== 2 | 3 | For info on using new v3 features and porting your code, see: 4 | 5 | http://wdas.github.io/SeExpr/doxygen/html/SeExpr_FAQ.html 6 | 7 | =================================================================== 8 | 9 | 10 | # SeExpr - An embeddable expression evaluation engine 11 | 12 | 13 | ## Super impatient CMake building and installing guide 14 | 15 | ```bash 16 | $ git clone https://github.com/wdas/SeExpr 17 | $ cd SeExpr 18 | $ mkdir build 19 | $ cd build 20 | $ cmake ../ 21 | $ make doc # optional make documentation 22 | $ make install 23 | ``` 24 | 25 | You can try the test application asciiGraph which is a simple 26 | function grapher... e.g. 27 | ```bash 28 | ./asciiGraph "x^3-8*x" 29 | ``` 30 | 31 | ## Getting started 32 | 33 | Examining the demo applications in src/demo is a great way to see 34 | some usage examples of the library. The basic strategy is to subclass 35 | the Expression class and implement the methods that describe what 36 | extra functions and variables your expression evaluation will need 37 | 38 | Be sure to check out the doxygen pages for an API overview: 39 | http://wdas.github.io/SeExpr/doxygen/ 40 | http://wdas.github.io/SeExpr/doxygen/v1 (for older documentation) 41 | 42 | ## Source code overview 43 | 44 | ``` 45 | src/ 46 | SeExpr2/ Library code 47 | ui/ User Interface components for editing 48 | demos/ Demo Applications 49 | tests/ Regression Tests 50 | doc/ Doxygen generation 51 | ``` 52 | 53 | ## SeExpr Developers 54 | 55 | * David Aguilar 56 | * Janet Berlin 57 | * Brent Burley 58 | * Lawrence Chai 59 | * Noah Kagan 60 | * Jared Reisweber 61 | * Andrew Selle 62 | * Dan Teece 63 | * Tom Thompson 64 | 65 | Walt Disney Animation Studios 66 | -------------------------------------------------------------------------------- /docker/Dockerfile.centos7: -------------------------------------------------------------------------------- 1 | FROM centos:centos7 2 | RUN yum install -y git-all 3 | RUN yum install -y gcc gcc-c++ flex bison 4 | RUN yum install -y make cmake 5 | RUN yum install -y llvm-devel 6 | RUN yum install -y boost-python boost-devel 7 | RUN yum install -y sip-devel 8 | USER nobody 9 | -------------------------------------------------------------------------------- /docker/Dockerfile.debian: -------------------------------------------------------------------------------- 1 | FROM debian:testing 2 | RUN apt-get update 3 | RUN apt-get install -y build-essential 4 | RUN apt-get install -y flex bison 5 | RUN apt-get install -y cmake 6 | RUN apt-get install -y llvm-dev 7 | RUN apt-get install -y libboost-dev libboost-python-dev 8 | USER nobody 9 | -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | Docker images for SeExpr 2 | 3 | Docker can be used to build development environments to validate 4 | builds using different Linux distributions. 5 | 6 | Centos7: 7 | 8 | # Build the centos7 development environment 9 | docker build --rm --tag seexpr:centos7 --file docker/Dockerfile.centos7 . 10 | 11 | # Execute a shell inside the docker environment 12 | docker run --rm --tty --interactive --volume "$PWD":/src --workdir /src --user "$UID:$GROUPS" seexpr:centos7 13 | 14 | Debian: 15 | # Build the debian development environment 16 | docker build --rm --tag seexpr:debian --file docker/Dockerfile.debian . 17 | 18 | # Execute a shell inside the docker environment 19 | docker run --rm --tty --interactive --volume "$PWD":/src --workdir /src --user "$UID:$GROUPS" seexpr:debian 20 | -------------------------------------------------------------------------------- /src/SeExpr2/Context.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include "Context.h" 18 | 19 | using namespace SeExpr2; 20 | 21 | Context::Context(const Context* parent) : _parent(parent) {} 22 | 23 | void Context::setParameter(const std::string& parameterName, const std::string& value) { 24 | _parameters[parameterName] = value; 25 | } 26 | 27 | Context* Context::createChildContext() const { return new Context(this); } 28 | 29 | Context& Context::global() { 30 | static Context context(0); 31 | return context; 32 | } 33 | -------------------------------------------------------------------------------- /src/SeExpr2/Context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace SeExpr2 { 23 | 24 | class Context { 25 | public: 26 | /// Lookup a Context parameter by name. 27 | bool lookupParameter(const std::string& parameterName, std::string& value) const { 28 | ParameterMap::const_iterator it = _parameters.find(parameterName); 29 | if (it != _parameters.end()) { 30 | value = it->second; 31 | return true; 32 | } else if (_parent) 33 | return _parent->lookupParameter(parameterName, value); 34 | else 35 | return false; 36 | } 37 | /// Set a parameter. NOTE: this must be done when no threads are accessing lookupParameter for safety 38 | void setParameter(const std::string& parameterName, const std::string& value); 39 | /// Create a context that is a child of this context 40 | Context* createChildContext() const; 41 | 42 | // Parent access uses pointers as it is acceptable to set/get a NULL parent 43 | void setParent(const Context* context) { _parent = context; } 44 | const Context* getParent() const { return _parent; } 45 | 46 | bool hasContext(const Context* context) const { 47 | if (this == context) return true; 48 | if (_parent) return _parent->hasContext(context); 49 | return false; 50 | } 51 | 52 | /// The global default context of the seexpr 53 | static Context& global(); 54 | 55 | private: 56 | /// Private constructor and un-implemented default/copy/assignment 57 | /// (it is required that we derive from the global context via createChildContext) 58 | Context(const Context&); 59 | Context& operator=(const Context&); 60 | 61 | Context(const Context* parent); 62 | /// The parent scope 63 | const Context* _parent; 64 | 65 | // TODO: Use std::map until C++11 is ubiq. 66 | typedef std::map ParameterMap; 67 | /// Attribute/value pairs 68 | ParameterMap _parameters; 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /src/SeExpr2/ContextUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include "ContextUtils.h" 19 | #include "Context.h" 20 | 21 | namespace SeExpr2 { 22 | 23 | namespace /* anonymous */ { 24 | const std::string disableThreading = "disableThreading"; 25 | } // namespace anonymous 26 | 27 | void ContextUtils::DisableThreading(Context& context) { context.setParameter(disableThreading, "true"); } 28 | 29 | bool ContextUtils::IsThreading(const Context& context) { 30 | bool isThreading = true; 31 | 32 | std::string result; 33 | if (context.lookupParameter(disableThreading, result) && result == "true") { 34 | isThreading = false; 35 | } 36 | 37 | return isThreading; 38 | } 39 | 40 | } // namespace SeExpr2 41 | -------------------------------------------------------------------------------- /src/SeExpr2/ContextUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | namespace SeExpr2 { 20 | 21 | class Context; 22 | 23 | class ContextUtils { 24 | public: 25 | static void DisableThreading(Context& context); 26 | static bool IsThreading(const Context& context); 27 | }; 28 | 29 | } // namespace SeExpr2 30 | -------------------------------------------------------------------------------- /src/SeExpr2/Curve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | #include "Vec.h" 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace SeExpr2 { 26 | 27 | //! Interpolation curve class for double->double and double->Vec3D 28 | /** Interpolation curve class for mapping from double -> double or double -> Vec3D 29 | Subject to some interpolation points. 30 | 31 | Each segment is interpolated according to the interpolation type specified on the 32 | left control point. Interpolation types supported are members of InterpType 33 | below. 34 | 35 | Valid instantiation types for this are double, or Vec3D 36 | */ 37 | template 38 | class Curve { 39 | mutable int cacheCV; 40 | 41 | public: 42 | //! Supported interpolation types 43 | enum InterpType { 44 | kNone = 0, 45 | kLinear, 46 | kSmooth, 47 | kSpline, 48 | kMonotoneSpline 49 | }; 50 | struct CV { 51 | CV(double pos, const T& val, InterpType type) : _pos(pos), _val(val), _interp(type) {} 52 | 53 | double _pos; 54 | T _val, _deriv; 55 | InterpType _interp; 56 | }; 57 | 58 | private: 59 | std::vector _cvData; 60 | bool prepared; 61 | 62 | public: 63 | Curve(); 64 | 65 | //! Adds a point to the curve 66 | void addPoint(double position, const T& val, InterpType type); 67 | 68 | //! Prepares points for evaluation (sorts and computes boundaries, clamps extrema) 69 | void preparePoints(); 70 | 71 | //! Evaluates curve and returns full value 72 | T getValue(const double param) const; 73 | 74 | //! Evaluates curve for a sub-component of the interpolation values 75 | //! must call preparePoints() before this is ok to call 76 | double getChannelValue(const double param, int channel) const; 77 | 78 | //! Returns the control point that is less than the parameter, unless there is no 79 | //! point, in which case it returns the right point or nothing 80 | CV getLowerBoundCV(const double param) const; 81 | 82 | //! Returns whether the given interpolation type is supported 83 | static bool interpTypeValid(InterpType interp); 84 | 85 | //! CV Parameter ordering (cv1._pos < cv2._pos) 86 | static bool cvLessThan(const CV& cv1, const CV& cv2); 87 | 88 | private: 89 | //! Performs hermite derivative clamping in canonical space 90 | void clampCurveSegment(const T& delta, T& d1, T& d2); 91 | 92 | //! Returns a component of the given value 93 | static double comp(const T& val, const int i); 94 | }; 95 | } 96 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprConfig.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | // This should be substituted externally by CMake 20 | #if @SEEXPR_ENABLE_LLVM_BACKEND@ 21 | # define SEEXPR_ENABLE_LLVM 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprLLVM.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | #include "ExprConfig.h" 20 | 21 | #ifdef SEEXPR_ENABLE_LLVM 22 | #include 23 | namespace llvm { 24 | class Value; 25 | class Type; 26 | class Module; 27 | class Function; 28 | } 29 | typedef llvm::Value* LLVM_VALUE; 30 | typedef llvm::IRBuilder<>& LLVM_BUILDER; 31 | #define LLVM_BODY const 32 | #else 33 | typedef double LLVM_VALUE; 34 | typedef double LLVM_BUILDER; 35 | #define LLVM_BODY \ 36 | { return 0; } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprLLVMAll.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | #include "ExprConfig.h" 20 | #include "ExprLLVM.h" 21 | 22 | #ifdef SEEXPR_ENABLE_LLVM 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include "llvm/IR/Verifier.h" 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #endif 53 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprMultiExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include "Expression.h" 18 | 19 | namespace SeExpr2 { 20 | 21 | class DExpression; 22 | class GlobalVal; 23 | class Expressions; 24 | 25 | typedef std::set::iterator VariableHandle; 26 | typedef std::set::iterator VariableSetHandle; 27 | typedef std::set::iterator ExprHandle; 28 | typedef std::pair > ExprEvalHandle; 29 | 30 | class DExpression : public Expression { 31 | Expressions& context; 32 | 33 | public: 34 | DExpression(const std::string& varName, 35 | Expressions& context, 36 | const std::string& e, 37 | const ExprType& type = ExprType().FP(3), 38 | EvaluationStrategy be = defaultEvaluationStrategy); 39 | 40 | mutable std::set operandExprs; 41 | mutable std::set operandVars; 42 | 43 | GlobalVal* val; 44 | const std::string& name() const; 45 | ExprVarRef* resolveVar(const std::string& name) const; 46 | void eval(); 47 | }; 48 | 49 | class Expressions { 50 | std::set exprToEval; 51 | std::set exprEvaled; 52 | 53 | public: 54 | std::set AllExprs; 55 | std::set AllExternalVars; 56 | 57 | // Expressions(int numberOfEvals=1); 58 | Expressions() {} 59 | ~Expressions(); 60 | 61 | VariableHandle addExternalVariable(const std::string& variableName, ExprType seTy); 62 | ExprHandle addExpression(const std::string& varName, ExprType seTy, const std::string& expr); 63 | 64 | VariableSetHandle getLoopVarSetHandle(VariableHandle vh); 65 | void setLoopVariable(VariableSetHandle handle, double* values, unsigned dim); 66 | void setLoopVariable(VariableSetHandle handle, double value) { setLoopVariable(handle, &value, 1); } 67 | void setLoopVariable(VariableSetHandle handle, const char* values); 68 | 69 | void setVariable(VariableHandle handle, double* values, unsigned dim); 70 | void setVariable(VariableHandle handle, double value) { setVariable(handle, &value, 1); } 71 | void setVariable(VariableHandle handle, const char* values); 72 | 73 | bool isValid() const; 74 | void getErrors(std::vector& errors) const; 75 | // bool isVariableUsed(VariableHandle variableHandle) const; 76 | 77 | ExprEvalHandle getExprEvalHandle(ExprHandle eh); 78 | const std::vector& evalFP(ExprEvalHandle eeh); 79 | const char* evalStr(ExprEvalHandle eeh); 80 | 81 | void resetEval() { 82 | exprToEval.clear(); 83 | exprEvaled.clear(); 84 | } 85 | 86 | void reset() { 87 | resetEval(); 88 | AllExprs.clear(); 89 | AllExternalVars.clear(); 90 | } 91 | }; 92 | } 93 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef ExprParser_h 18 | #define ExprParser_h 19 | 20 | #ifndef MAKEDEPEND 21 | #include 22 | #endif 23 | 24 | namespace SeExpr2 { 25 | class ExprNode; 26 | class Expression; 27 | bool ExprParse(SeExpr2::ExprNode*& parseTree, 28 | std::string& error, 29 | int& errorStart, 30 | int& errorEnd, 31 | std::vector >& _comments, 32 | const SeExpr2::Expression* expr, 33 | const char* str, 34 | bool wantVec = true); 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprWalker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef MAKEDEPEND 18 | #include 19 | #include 20 | #include 21 | #endif 22 | 23 | #include "ExprNode.h" 24 | #include "ExprPatterns.h" 25 | #include "ExprWalker.h" 26 | 27 | namespace SeExpr2 { 28 | 29 | template 30 | void Walker::walk(T_NODE* examinee) { 31 | _examiner->reset(); 32 | internalWalk(examinee); 33 | }; 34 | 35 | template 36 | void Walker::internalWalk(T_NODE* examinee) { 37 | /// If examine returns false, do not recurse 38 | if (_examiner->examine(examinee)) walkChildren(examinee); 39 | _examiner->post(examinee); 40 | }; 41 | 42 | template 43 | void Walker::walkChildren(T_NODE* parent) { 44 | for (int i = 0; i < parent->numChildren(); i++) internalWalk(parent->child(i)); 45 | }; 46 | 47 | template class Walker; 48 | template class Walker; 49 | } 50 | -------------------------------------------------------------------------------- /src/SeExpr2/ExprWalker.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #ifndef ExprWalker_h 19 | #define ExprWalker_h 20 | 21 | namespace SeExpr2 { 22 | 23 | template 24 | struct ADD_CONST { 25 | typedef T TYPE; 26 | }; 27 | template 28 | struct ADD_CONST { 29 | typedef const T TYPE; 30 | }; 31 | 32 | template 33 | class Examiner { 34 | public: 35 | typedef typename ADD_CONST::TYPE T_NODE; 36 | 37 | virtual bool examine(T_NODE* examinee) = 0; 38 | virtual void post(T_NODE* examinee) {}; // TODO: make this pure virt 39 | virtual void reset() = 0; 40 | }; 41 | 42 | template 43 | class Walker { 44 | public: 45 | typedef Examiner T_EXAMINER; 46 | typedef typename T_EXAMINER::T_NODE T_NODE; 47 | 48 | Walker(T_EXAMINER* examiner) : _examiner(examiner) { 49 | _examiner->reset(); 50 | }; 51 | 52 | /// Preorder walk 53 | void walk(T_NODE* examinee); 54 | 55 | protected: 56 | void internalWalk(T_NODE* examinee); 57 | void walkChildren(T_NODE* parent); 58 | 59 | private: 60 | T_EXAMINER* _examiner; 61 | }; 62 | 63 | typedef Examiner ConstExaminer; 64 | typedef Walker ConstWalker; 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /src/SeExpr2/Mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef Mutex_h 18 | #define Mutex_h 19 | 20 | // #define DEBUG_THREADING 21 | 22 | #include "Platform.h" 23 | 24 | /** For internal use only */ 25 | namespace SeExprInternal2 { 26 | #ifndef NDEBUG 27 | template 28 | class DebugLock : public T { 29 | public: 30 | DebugLock() : _locked(0) {} 31 | void lock() { 32 | T::lock(); 33 | _locked = 1; 34 | } 35 | void unlock() { 36 | assert(_locked); 37 | _locked = 0; 38 | T::unlock(); 39 | } 40 | bool locked() { return _locked != 0; } 41 | 42 | private: 43 | int _locked; 44 | }; 45 | #endif 46 | 47 | /** Automatically acquire and release lock within enclosing scope. */ 48 | template 49 | class AutoLock { 50 | public: 51 | AutoLock(T& m) : _m(m) { _m.lock(); } 52 | ~AutoLock() { _m.unlock(); } 53 | 54 | private: 55 | T& _m; 56 | }; 57 | 58 | #ifndef NDEBUG 59 | // add debug wrappers to mutex and spinlock 60 | typedef DebugLock<_Mutex> Mutex; 61 | typedef DebugLock<_SpinLock> SpinLock; 62 | #else 63 | typedef _Mutex Mutex; 64 | typedef _SpinLock SpinLock; 65 | #endif 66 | 67 | typedef AutoLock AutoMutex; 68 | typedef AutoLock AutoSpin; 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/SeExpr2/Noise.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _noise_h_ 18 | #define _noise_h_ 19 | namespace SeExpr2 { 20 | 21 | //! One octave of non-periodic Perlin noise 22 | template 23 | void Noise(const T* in, T* out); 24 | 25 | //! One octave of periodic noise 26 | //! period gives the integer period before tiles repease 27 | template 28 | void PNoise(const T* in, const int* period, T* out); 29 | 30 | //! Fractional Brownian Motion. If turbulence is true then turbulence computed. 31 | template 32 | void FBM(const T* in, T* out, int octaves, T lacunarity, T gain); 33 | 34 | //! Cellular noise with input and output dimensionality 35 | template 36 | void CellNoise(const T* in, T* out); 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/SeExpr2/Platform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | /** @file Platform.cpp 19 | @brief Platform-specific classes, functions, and includes' implementations. 20 | */ 21 | 22 | #include "Platform.h" 23 | 24 | #if defined(WINDOWS) 25 | 26 | #define _CRT_NONSTDC_NO_DEPRECATE 1 27 | #define _CRT_SECURE_NO_DEPRECATE 1 28 | #define NOMINMAX 1 29 | 30 | // windows - defined for both Win32 and Win64 31 | #define WIN32_LEAN_AND_MEAN 32 | #define VC_EXTRALEAN 33 | #include 34 | 35 | namespace SeExpr2 { 36 | 37 | __int64 Timer::time() { 38 | LARGE_INTEGER perfCounter; 39 | QueryPerformanceCounter(&perfCounter); 40 | return perfCounter.QuadPart; 41 | } 42 | 43 | Timer::Timer() : started(false) { 44 | // get the timer frequency 45 | LARGE_INTEGER frequency; 46 | QueryPerformanceFrequency(&frequency); 47 | ticksPerSeconds = frequency.QuadPart; 48 | } 49 | 50 | void Timer::start() { 51 | started = true; 52 | startTime = this->time(); 53 | } 54 | 55 | long Timer::elapsedTime() { 56 | stopTime = this->time(); 57 | return static_cast(((stopTime - startTime) * 1000000) / ticksPerSeconds); 58 | } 59 | 60 | } 61 | 62 | namespace SeExprInternal2 { 63 | 64 | /* 65 | * Mutex/SpinLock classes 66 | */ 67 | 68 | _Mutex::_Mutex() { 69 | _mutex = CreateMutex(NULL, FALSE, NULL); 70 | } 71 | 72 | _Mutex::~_Mutex() { 73 | CloseHandle(_mutex); 74 | } 75 | 76 | void _Mutex::lock() { 77 | WaitForSingleObject(_mutex, INFINITE); 78 | } 79 | 80 | void _Mutex::unlock() { 81 | ReleaseMutex(_mutex); 82 | } 83 | 84 | _SpinLock::_SpinLock() { 85 | _spinlock = new CRITICAL_SECTION; 86 | InitializeCriticalSection(reinterpret_cast(_spinlock)); 87 | } 88 | 89 | _SpinLock::~_SpinLock() { 90 | DeleteCriticalSection(reinterpret_cast(_spinlock)); 91 | delete _spinlock; 92 | _spinlock = nullptr; 93 | } 94 | 95 | void _SpinLock::lock() { 96 | EnterCriticalSection(reinterpret_cast(_spinlock)); 97 | } 98 | 99 | void _SpinLock::unlock() { 100 | LeaveCriticalSection(reinterpret_cast(_spinlock)); 101 | } 102 | 103 | } 104 | 105 | #endif // defined(WINDOWS) 106 | -------------------------------------------------------------------------------- /src/SeExpr2/SeContext.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include "SeContext.h" 18 | 19 | SeContext::SeContext(const SeContext* parent) : _parent(parent) {} 20 | 21 | void SeContext::setParameter(const std::string& parameterName, const std::string& value) { 22 | _parameters[parameterName] = value; 23 | } 24 | 25 | SeContext* SeContext::createChildContext() const { return new SeContext(this); } 26 | 27 | SeContext& SeContext::global() { 28 | static SeContext context(0); 29 | return context; 30 | } -------------------------------------------------------------------------------- /src/SeExpr2/SeContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | class SeContext { 23 | public: 24 | /// Lookup a SeContext parameter by name. 25 | bool lookupParameter(const std::string& parameterName, std::string& value) const { 26 | ParameterMap::const_iterator it = _parameters.find(parameterName); 27 | if (it != _parameters.end()) { 28 | value = it->second; 29 | return true; 30 | } else if (_parent) 31 | return _parent->lookupParameter(parameterName, value); 32 | else 33 | return false; 34 | } 35 | /// Set a parameter. NOTE: this must be done when no threads are accessing lookupParameter for safety 36 | void setParameter(const std::string& parameterName, const std::string& value); 37 | /// Create a context that is a child of this context 38 | SeContext* createChildContext() const; 39 | 40 | // Parent access uses pointers as it is acceptable to set/get a NULL parent 41 | void setParent(const SeContext* context) { _parent = context; } 42 | const SeContext* getParent() const { return _parent; } 43 | 44 | bool hasContext(const SeContext* context) const { 45 | if (this == context) return true; 46 | if (_parent) return _parent->hasContext(context); 47 | return false; 48 | } 49 | 50 | /// The global default context of the seexpr 51 | static SeContext& global(); 52 | 53 | private: 54 | /// Private constructor and un-implemented default/copy/assignment 55 | /// (it is required that we derive from the global context via createChildContext) 56 | SeContext(const SeContext&); 57 | SeContext& operator=(const SeContext&); 58 | 59 | SeContext(const SeContext* parent); 60 | /// The parent scope 61 | const SeContext* _parent; 62 | 63 | // TODO: Use std::map until C++11 is ubiq. 64 | typedef std::map ParameterMap; 65 | /// Attribute/value pairs 66 | ParameterMap _parameters; 67 | }; 68 | -------------------------------------------------------------------------------- /src/SeExpr2/SeExprMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #ifndef SeExprMacros_h 19 | #define SeExprMacros_h 20 | 21 | #define UNUSED(x) (void)(x) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/SeExpr2/StringUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef StringUtils_h 18 | #define StringUtils_h 19 | 20 | #include 21 | 22 | //! Unescape a few common special characters in the input @p string and return 23 | //! the result as a new one. 24 | inline std::string unescapeString(const std::string& string) { 25 | std::string output(string); 26 | int index = 0; 27 | bool special = false; 28 | for (char c : string) { 29 | if (special == true) { 30 | special = false; 31 | switch (c) { 32 | case 'n': output[index++] = '\n'; break; 33 | case 'r': output[index++] = '\r'; break; 34 | case 't': output[index++] = '\t'; break; 35 | case '\\': output[index++] = '\\'; break; 36 | case '"': output[index++] = '\"'; break; 37 | default: 38 | // leave the escape sequence as it was 39 | output[index++] = '\\'; 40 | output[index++] = c; 41 | } 42 | } else { 43 | if (c == '\\') { 44 | special = true; 45 | } else { 46 | output[index++] = c; 47 | } 48 | } 49 | } 50 | output.resize(index); 51 | return output; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/BasicExpression.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * @file BasicExpression.cpp 18 | * @brief A basic expression context for the expression previewer 19 | * @author aselle 20 | */ 21 | 22 | #include "BasicExpression.h" 23 | 24 | BasicExpression::BasicExpression(const std::string& expr, const SeExpr2::ExprType& type) 25 | : Expression(expr, type), dummyFunc(dummyFuncX, 0, 16) {} 26 | 27 | BasicExpression::~BasicExpression() { clearVars(); } 28 | 29 | template 30 | void deleteAndClear(T_MAP& map) { 31 | for (typename T_MAP::iterator i = map.begin(); i != map.end(); ++i) delete i->second; 32 | map.clear(); 33 | } 34 | 35 | void BasicExpression::clearVars() { 36 | deleteAndClear(varmap); 37 | funcmap.clear(); 38 | } 39 | 40 | void BasicExpression::setExpr(const std::string& str) { 41 | clearVars(); 42 | Expression::setExpr(str); 43 | } 44 | 45 | SeExpr2::ExprVarRef* BasicExpression::resolveVar(const std::string& name) const { 46 | if (name == "u") 47 | return &u; 48 | else if (name == "v") 49 | return &v; 50 | else if (name == "P") 51 | return &P; 52 | else { 53 | // make a variable to resolve any unknown 54 | VARMAP::iterator i = varmap.find(name); 55 | if (i != varmap.end()) 56 | return i->second; 57 | else { 58 | varmap[name] = new VectorRef(); 59 | return varmap[name]; 60 | } 61 | } 62 | } 63 | 64 | SeExpr2::ExprFunc* BasicExpression::resolveFunc(const std::string& name) const { 65 | // check if it is builtin so we get proper behavior 66 | if (SeExpr2::ExprFunc::lookup(name)) return 0; 67 | 68 | funcmap[name] = true; 69 | return &dummyFunc; 70 | } 71 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/EditMain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include "SeExprEdDialog.h" 23 | 24 | int main(int argc, char *argv[]) { 25 | QApplication app(argc, argv); 26 | SeExprEdDialog dialog(0); 27 | dialog.setWindowTitle("Expression Editor"); 28 | dialog.show(); 29 | 30 | if (argc < 2 || std::string(argv[1]) != "-automatedTest") { 31 | if (dialog.exec() == QDialog::Accepted) 32 | std::cerr << "returned expression: " << dialog.getExpressionString() << std::endl; 33 | } else { 34 | std::string str = "$u + $v"; 35 | dialog.setExpressionString(str); 36 | if (dialog.getExpressionString() != str) { 37 | std::cerr << "test failed: " << dialog.getExpressionString() << " != " << str << std::endl; 38 | return 1; 39 | } 40 | } 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/EditableExpression.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * @file EditableExpression.h 18 | * @author Andrew Selle 19 | */ 20 | #ifndef __EditableExpression__ 21 | #define __EditableExpression__ 22 | 23 | #include 24 | #include 25 | 26 | class Editable; 27 | 28 | /// Factors a SeExpr into an editable expression with controls (i.e. value boxes, curve boxes) 29 | class EditableExpression { 30 | std::string _expr; // original full expression 31 | typedef std::vector Editables; 32 | std::vector _editables; // control that can edit the expression 33 | std::vector _variables; 34 | 35 | public: 36 | EditableExpression(); 37 | ~EditableExpression(); 38 | 39 | /// Set's expressions and parses it into "control editable form" 40 | void setExpr(const std::string& expr); 41 | 42 | /// Return a reconstructed expression using all the editable's current values 43 | std::string getEditedExpr() const; 44 | 45 | /// Check if the other editable expression has editables that all match i.e. the controls are same 46 | bool controlsMatch(const EditableExpression& other) const; 47 | 48 | /// Update the string refered to into the controls (this is only valid if controlsmatch) 49 | void updateString(const EditableExpression& other); 50 | 51 | /// Access an editable parameter 52 | Editable* operator[](const int i) { return _editables[i]; } 53 | 54 | /// Return the count of editable parameters 55 | size_t size() const { return _editables.size(); } 56 | 57 | /// Get list of commentsø 58 | const std::vector& getVariables() const { return _variables; } 59 | 60 | private: 61 | /// clean memeory 62 | void cleanup(); 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprBrowser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * @file ExprBrowser.h 18 | * @brief Browser for a library of expressions from a tree of files 19 | * @author aselle 20 | */ 21 | #ifndef ExprBrowser_h 22 | #define ExprBrowser_h 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | class QLineEdit; 32 | class QTreeWidget; 33 | class QTreeView; 34 | class QTreeWidgetItem; 35 | class QTextBrowser; 36 | class ExprEditor; 37 | class QSortFilterProxyModel; 38 | class QDir; 39 | 40 | class ExprTreeModel; 41 | class ExprTreeFilterModel; 42 | 43 | class ExprBrowser : public QWidget { 44 | Q_OBJECT 45 | 46 | ExprEditor* editor; 47 | QList labels; 48 | QList paths; 49 | ExprTreeModel* treeModel; 50 | ExprTreeFilterModel* proxyModel; 51 | QTreeView* treeNew; 52 | QLineEdit* exprFilter; 53 | std::string _userExprDir; 54 | std::string _localExprDir; 55 | std::string _context; 56 | std::string _searchPath; 57 | bool _applyOnSelect; 58 | 59 | public: 60 | ExprBrowser(QWidget* parent, ExprEditor* editor); 61 | ~ExprBrowser(); 62 | void addPath(const std::string& name, const std::string& path); 63 | std::string getSelectedPath(); 64 | void selectPath(const char* path); 65 | void addUserExpressionPath(const std::string& context); 66 | bool getExpressionDirs(); 67 | bool getExpressionDirs(const std::string& context); 68 | void setSearchPath(const QString& context, const QString& path); 69 | void expandAll(); 70 | void expandToDepth(int depth); 71 | void setApplyOnSelect(bool on) { _applyOnSelect = on; } 72 | public 73 | slots: 74 | void handleSelection(const QModelIndex& current, const QModelIndex& previous); 75 | void update(); 76 | void clear(); 77 | void clearSelection(); 78 | void saveExpression(); 79 | void saveLocalExpressionAs(); 80 | void saveExpressionAs(); 81 | private 82 | slots: 83 | void clearFilter(); 84 | void filterChanged(const QString& str); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprColorSwatch.h: -------------------------------------------------------------------------------- 1 | #ifndef _ExprColorSwatch_h_ 2 | #define _ExprColorSwatch_h_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class QGridLayout; 11 | 12 | class ExprColorFrame : public QFrame { 13 | Q_OBJECT 14 | public: 15 | ExprColorFrame(SeExpr2::Vec3d value, QWidget *parent = nullptr); 16 | ~ExprColorFrame() {} 17 | 18 | void setValue(const SeExpr2::Vec3d &value); 19 | SeExpr2::Vec3d getValue() const; 20 | bool selected() { 21 | return _selected; 22 | }; 23 | 24 | protected: 25 | virtual void paintEvent(QPaintEvent *event); 26 | virtual void mouseReleaseEvent(QMouseEvent *event); 27 | 28 | private 29 | slots: 30 | void deleteSwatchMenu(const QPoint &pos); 31 | 32 | signals: 33 | void selValChangedSignal(SeExpr2::Vec3d value); 34 | void swatchChanged(QColor color); 35 | void deleteSwatch(ExprColorFrame *swatch); 36 | 37 | private: 38 | SeExpr2::Vec3d _value; 39 | QColor _color; 40 | bool _selected; 41 | }; 42 | 43 | // Simple color widget with or without index label 44 | class ExprColorWidget : public QWidget { 45 | Q_OBJECT 46 | public: 47 | ExprColorWidget(SeExpr2::Vec3d value, int index, bool indexLabel, QWidget *parent); 48 | ExprColorFrame *getColorFrame(); 49 | 50 | private: 51 | ExprColorFrame *_colorFrame; 52 | }; 53 | 54 | class ExprColorSwatchWidget : public QWidget { 55 | Q_OBJECT 56 | 57 | public: 58 | ExprColorSwatchWidget(bool indexLabel=false, QWidget *parent = nullptr); 59 | ~ExprColorSwatchWidget() {} 60 | 61 | // Convenience Functions 62 | void addSwatch(SeExpr2::Vec3d &val, int index = -1); 63 | void setSwatchColor(int index, QColor color); 64 | QColor getSwatchColor(int index); 65 | 66 | private 67 | slots: 68 | void addNewColor(); 69 | void removeSwatch(ExprColorFrame *); 70 | void internalSwatchChanged(QColor color); 71 | 72 | signals: 73 | void selValChangedSignal(SeExpr2::Vec3d val); 74 | void swatchChanged(int index, SeExpr2::Vec3d val); 75 | void swatchAdded(int index, SeExpr2::Vec3d val); 76 | void swatchRemoved(int index); 77 | 78 | private: 79 | QGridLayout *_gridLayout; 80 | int _columns; 81 | bool _indexLabel; 82 | }; 83 | #endif 84 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprCompletionModel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * @file ExprCompletionModel.h 18 | * @brief Provides a model for providing completion items 19 | * @author aselle 20 | */ 21 | 22 | #ifndef ExprCompletionModel_h 23 | #define ExprCompletionModel_h 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class ExprCompletionModel : public QAbstractItemModel // ItemModel 31 | { 32 | public: 33 | // clear/add functions (these are ones that will be resolved with resolveFunc() 34 | void clearFunctions(); 35 | void addFunction(const QString& function, const QString& docString); 36 | 37 | // clear/add user variables (these are ones that will be resolved with resolveVar() 38 | void clearVariables(); 39 | void addVariable(const QString& str, const QString& comment); 40 | 41 | // add extras 42 | void syncExtras(const ExprCompletionModel& otherModel); 43 | 44 | ExprCompletionModel(QObject* parent = 0); 45 | 46 | QModelIndex index(int row, int column, const QModelIndex&) const { return createIndex(row, column, nullptr); } 47 | 48 | QModelIndex parent(const QModelIndex&) const { return QModelIndex(); } 49 | 50 | int rowCount(const QModelIndex& parent = QModelIndex()) const { 51 | Q_UNUSED(parent); 52 | int count = builtins.size() + functions.size() + variables.size() + local_variables.size(); 53 | return count; 54 | } 55 | 56 | int columnCount(const QModelIndex& parent) const { 57 | Q_UNUSED(parent); 58 | return 2; 59 | } 60 | 61 | QString getFirstLine(const std::string& all) const { 62 | size_t newline = all.find("\n"); 63 | if (newline != std::string::npos) 64 | return QString(all.substr(0, newline).c_str()); 65 | else 66 | return QString(all.c_str()); 67 | } 68 | 69 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; 70 | 71 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const { 72 | Q_UNUSED(orientation); 73 | if (role == Qt::DisplayRole) 74 | return QVariant(""); 75 | else if (role == Qt::SizeHintRole) { 76 | if (section == 0) 77 | return QVariant(QSize(100, 1)); 78 | else 79 | return QVariant(QSize(200, 1)); 80 | } else 81 | return QVariant(); 82 | } 83 | std::vector local_variables; // only the expression editor itself should modify these 84 | 85 | QString getDocString(const QString& s); 86 | 87 | private: 88 | static std::vector builtins; 89 | std::vector functions, functions_comment; 90 | std::map functionNameToFunction; 91 | std::vector variables, variables_comment; 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprDialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * @file ExprDialog.h 18 | * @brief A basic editor/browser/previewer for expression editing 19 | * @author jlacewel 20 | */ 21 | #ifndef _MY_EXPR_EDITOR_H 22 | #define _MY_EXPR_EDITOR_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | #include "ExprEditor.h" 39 | 40 | class ExprGrapherWidget; 41 | class ExprBrowser; 42 | class QTabWidget; 43 | 44 | class ExprDialog : public QDialog { 45 | Q_OBJECT 46 | 47 | public: 48 | ExprEditor* editor; 49 | ExprBrowser* browser; 50 | 51 | private: 52 | ExprGrapherWidget* grapher; 53 | QLabel* previewCommentLabel; 54 | QPushButton* acceptButton; 55 | QPushButton* cancelButton; 56 | ExprControlCollection* controls; 57 | 58 | QPushButton* applyButton, *previewButton, *saveButton, *saveAsButton; 59 | QPushButton* saveLocalButton, *clearButton; 60 | QLineEdit* helpFindBox; 61 | QTimer* showEditorTimer; 62 | QTextBrowser* helpBrowser; 63 | QTextCursor cursor; 64 | QString prevFind; 65 | int _currentEditorIdx; 66 | 67 | public: 68 | ExprDialog(QWidget* parent=nullptr); 69 | 70 | std::string getExpressionString() { return editor->getExpr(); } 71 | 72 | void setExpressionString(const std::string& str) { 73 | clearExpression(); 74 | editor->setExpr(str, /*apply*/ true); 75 | } 76 | 77 | void show(); 78 | int exec(); 79 | 80 | // Show the Nth editor dialog 81 | void showEditor(int idx); 82 | 83 | private: 84 | void setupHelp(QTabWidget* tab); 85 | 86 | protected: 87 | void keyPressEvent(QKeyEvent* event); 88 | void findHelper(QTextDocument::FindFlags flags); 89 | void closeEvent(QCloseEvent* event); 90 | 91 | signals: 92 | void preview(); 93 | void expressionApplied(); 94 | void dialogClosed(); 95 | private 96 | slots: 97 | void previewExpression(); 98 | void verifiedApply(); 99 | void verifiedAccept(); 100 | void findNextInHelp(); 101 | void findPrevInHelp(); 102 | void _showEditor(); 103 | public 104 | slots: 105 | 106 | void applyExpression(); 107 | 108 | void clearExpression(); 109 | 110 | void reject(); 111 | }; 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprGrapher2d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * @file ExprGrapher2d.h 18 | * @brief A 2d image graph view for expression editing previewing 19 | * @author jlacewel 20 | */ 21 | #ifndef ExprGrapher2d_h 22 | #define ExprGrapher2d_h 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "BasicExpression.h" 30 | 31 | class ExprGrapherWidget; 32 | class QLineEdit; 33 | 34 | class ExprGrapherView : public QGLWidget { 35 | Q_OBJECT; 36 | ExprGrapherWidget& widget; 37 | 38 | public: 39 | ExprGrapherView(ExprGrapherWidget& widget, QWidget* parent, int width, int height); 40 | virtual ~ExprGrapherView(); 41 | 42 | void update(); 43 | void setWindow(float xmin, float xmax, float ymin, float ymax, float z); 44 | void getWindow(float& xmin, float& xmax, float& ymin, float& ymax, float& z); 45 | 46 | protected: 47 | void clear(); 48 | void paintGL(); 49 | void mousePressEvent(QMouseEvent* event); 50 | void mouseReleaseEvent(QMouseEvent* event); 51 | void mouseMoveEvent(QMouseEvent* event); 52 | int event_oldx, event_oldy; 53 | 54 | signals: 55 | void scaleValueManipulated(); 56 | void clicked(); 57 | 58 | private: 59 | float* _image; 60 | int _width; 61 | int _height; 62 | 63 | float xmin, xmax, ymin, ymax, z; 64 | float dx, dy; 65 | 66 | bool scaling, translating; 67 | }; 68 | 69 | class ExprGrapherWidget : public QWidget { 70 | Q_OBJECT 71 | QLineEdit* scale; 72 | 73 | public: 74 | ExprGrapherView* view; 75 | BasicExpression expr; 76 | 77 | ExprGrapherWidget(QWidget* parent, int width, int height); 78 | 79 | void update(); 80 | signals: 81 | void preview(); 82 | private 83 | slots: 84 | void scaleValueEdited(); 85 | void scaleValueManipulated(); 86 | void forwardPreview(); 87 | }; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprHelp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #if 0 18 | header 19 | 20 | QTextBrowser* helpBrowser; 21 | 22 | constructor 23 | 24 | QWidget* browserspace = new QWidget(tab); 25 | helpBrowser = new QTextBrowser(browserspace); 26 | tab->addTab(browserspace, "Help"); 27 | char * path = getenv("RP_SeExpr2"); 28 | if (path) 29 | helpBrowser->setSource(QString("%1/share/doc/SeExpr2/SeExpressions.html").arg(path)); 30 | 31 | QPushButton* backPb = new QPushButton("Back"); 32 | backPb->setEnabled(false); 33 | QPushButton* forwardPb = new QPushButton("Forward"); 34 | forwardPb->setEnabled(false); 35 | 36 | QVBoxLayout * helpLayout = new QVBoxLayout(browserspace); 37 | QHBoxLayout * helpPbLayout = new QHBoxLayout; 38 | helpLayout->addLayout(helpPbLayout); 39 | helpPbLayout->addWidget(backPb); 40 | helpPbLayout->addWidget(forwardPb); 41 | helpPbLayout->addItem(new QSpacerItem(0,0, QSizePolicy::MinimumExpanding, 42 | QSizePolicy::Minimum)); 43 | helpLayout->addWidget(helpBrowser, /*stretch*/ true); 44 | helpBrowser->setMinimumHeight(120); 45 | 46 | // wire up help browser forward/back buttons 47 | connect(backPb, SIGNAL(clicked()), helpBrowser, SLOT(backward())); 48 | connect(forwardPb, SIGNAL(clicked()), helpBrowser, SLOT(forward())); 49 | connect(helpBrowser, SIGNAL(backwardAvailable(bool)), backPb, SLOT(setEnabled(bool))); 50 | connect(helpBrowser, SIGNAL(forwardAvailable(bool)), forwardPb, SLOT(setEnabled(bool))); 51 | #endif 52 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprMain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include "ExprDialog.h" 23 | 24 | int main(int argc, char *argv[]) { 25 | QApplication app(argc, argv); 26 | ExprDialog dialog(0); 27 | dialog.setWindowTitle("Expression Editor 2"); 28 | dialog.show(); 29 | 30 | if (argc < 2 || std::string(argv[1]) != "-automatedTest") { 31 | if (dialog.exec() == QDialog::Accepted) 32 | std::cerr << "returned expression: " << dialog.getExpressionString() << std::endl; 33 | } else { 34 | std::string str = "$u + $v"; 35 | dialog.setExpressionString(str); 36 | if (dialog.getExpressionString() != str) { 37 | std::cerr << "test failed: " << dialog.getExpressionString() << " != " << str << std::endl; 38 | return 1; 39 | } 40 | } 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprPopupDoc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include "ExprPopupDoc.h" 18 | #include 19 | #include 20 | 21 | ExprPopupDoc::ExprPopupDoc(QWidget* parent, const QPoint& placecr, const QString& msg) { 22 | Q_UNUSED(parent); 23 | label = new QLabel(msg); 24 | QHBoxLayout* layout = new QHBoxLayout; 25 | setLayout(layout); 26 | layout->addWidget(label); 27 | 28 | setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | 29 | Qt::X11BypassWindowManagerHint); 30 | setAttribute(Qt::WA_ShowWithoutActivating); 31 | setFocusPolicy(Qt::NoFocus); 32 | move(placecr); 33 | raise(); 34 | show(); 35 | } 36 | 37 | void ExprPopupDoc::mousePressEvent(QMouseEvent* event) { 38 | Q_UNUSED(event); 39 | hide(); 40 | } 41 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprPopupDoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _ExprPopupDoc_h_ 18 | #define _ExprPopupDoc_h 19 | 20 | #include 21 | 22 | class QLabel; 23 | class ExprPopupDoc : public QWidget { 24 | Q_OBJECT; 25 | 26 | public: 27 | QLabel* label; 28 | ExprPopupDoc(QWidget* parent, const QPoint& cr, const QString& msg); 29 | 30 | protected: 31 | void mousePressEvent(QMouseEvent* event); 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/ExprSpecType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _ExprSpecType_h_ 18 | #define _ExprSpecType_h_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | /// Mini parse tree node... Only represents literals, and lists of literals 27 | struct ExprSpecNode { 28 | int startPos, endPos; 29 | 30 | ExprSpecNode(int startPos, int endPos) : startPos(startPos), endPos(endPos) {} 31 | 32 | virtual ~ExprSpecNode() {} 33 | }; 34 | 35 | struct ExprSpecScalarNode : public ExprSpecNode { 36 | double v; 37 | 38 | ExprSpecScalarNode(int startPos, int endPos, double scalar) : ExprSpecNode(startPos, endPos), v(scalar) {} 39 | }; 40 | 41 | struct ExprSpecVectorNode : public ExprSpecNode { 42 | SeExpr2::Vec3d v; 43 | ExprSpecVectorNode(int startPos, int endPos, ExprSpecNode* x, ExprSpecNode* y, ExprSpecNode* z) 44 | : ExprSpecNode(startPos, endPos) { 45 | v = SeExpr2::Vec3d(static_cast(x)->v, 46 | static_cast(y)->v, 47 | static_cast(z)->v); 48 | } 49 | }; 50 | 51 | struct ExprSpecListNode : public ExprSpecNode { 52 | std::vector nodes; 53 | ExprSpecListNode(int startPos, int endPos) : ExprSpecNode(startPos, endPos) {} 54 | 55 | void add(ExprSpecNode* node) { 56 | startPos = std::min(node->startPos, startPos); 57 | endPos = std::max(node->endPos, endPos); 58 | nodes.push_back(node); 59 | } 60 | }; 61 | 62 | struct ExprSpecStringNode : public ExprSpecNode { 63 | std::string v; 64 | ExprSpecStringNode(int startPos, int endPos, const char* s) : ExprSpecNode(startPos, endPos), v(s) {} 65 | }; 66 | 67 | struct ExprSpecCurveNode : public ExprSpecNode { 68 | ExprSpecNode* args; 69 | ExprSpecCurveNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {} 70 | }; 71 | 72 | struct ExprSpecCCurveNode : public ExprSpecNode { 73 | ExprSpecNode* args; 74 | ExprSpecCCurveNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {} 75 | }; 76 | 77 | struct ExprSpecAnimCurveNode : public ExprSpecNode { 78 | ExprSpecNode* args; 79 | ExprSpecAnimCurveNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {} 80 | }; 81 | 82 | struct ExprSpecColorSwatchNode : public ExprSpecNode { 83 | ExprSpecNode* args; 84 | ExprSpecColorSwatchNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {} 85 | }; 86 | 87 | struct ExprSpecDeepWaterNode : public ExprSpecNode { 88 | ExprSpecNode* args; 89 | ExprSpecDeepWaterNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {} 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/__init__.py: -------------------------------------------------------------------------------- 1 | ## 2 | # @file __init__.py 3 | # @brief Package definition for expreditor api. 4 | # 5 | # CONFIDENTIAL INFORMATION: This software is the confidential and 6 | # proprietary information of Walt Disney Animation Studios ("WDAS"). 7 | # This software may not be used, disclosed, reproduced or distributed 8 | # for any purpose without prior written authorization and license 9 | # from WDAS. Reproduction of any section of this software must include 10 | # this legend and all copyright notices. 11 | # Copyright Disney Enterprises, Inc. All rights reserved. 12 | # 13 | # 14 | 15 | -------------------------------------------------------------------------------- /src/SeExpr2/UI/generated/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /src/SeExpr2/generated/.gitignore: -------------------------------------------------------------------------------- 1 | *.cpp 2 | *.h 3 | -------------------------------------------------------------------------------- /src/SeExpr2/parser/SeExprParse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include "SeExprParse.h" 18 | #include "ASTNode.h" 19 | 20 | // typedef std::unique_ptr ASTPtr; 21 | 22 | //#ifdef TEST_PARSER 23 | 24 | int main(int argc, char* argv[]) { 25 | std::ifstream ifs(argv[1]); 26 | std::string content((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); 27 | // std::cerr<<"PARSING! '"< parser(content); 29 | try { 30 | auto tree = parser.parse(); 31 | tree->print(std::cout, 0, &content); 32 | } 33 | catch (const ParseError& e) { 34 | std::cerr << "parse error: " << e._errorStr << std::endl; 35 | } 36 | return 0; 37 | } 38 | //#endif 39 | -------------------------------------------------------------------------------- /src/build/build-info: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | import os 5 | import sys 6 | 7 | # Some Mac OS X Python installs are busted and cannot import sysconfig without 8 | # this workaround... 9 | if 'MACOSX_DEPLOYMENT_TARGET' in os.environ: 10 | del os.environ['MACOSX_DEPLOYMENT_TARGET'] 11 | from distutils import sysconfig as sc 12 | 13 | import sipconfig 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser() 17 | subp = parser.add_subparsers() 18 | 19 | callbacks = ( 20 | ('python-ver', python_ver), 21 | ('python-site', python_site), 22 | ('python-inc', python_inc), 23 | ('pyqt4-sip', pyqt4_sip), 24 | ('pyqt4-sip-flags', pyqt4_sip_flags), 25 | ('pyqt5-sip-flags', pyqt5_sip_flags), 26 | ('sip-inc', sip_inc), 27 | ) 28 | 29 | for (name, func) in callbacks: 30 | subparser = subp.add_parser(name) 31 | subparser.set_defaults(func=func) 32 | 33 | args = parser.parse_args() 34 | print(args.func(args)) 35 | 36 | return 0 37 | 38 | 39 | def lib(args): 40 | """Return the architecture-specific library directory 41 | 42 | """ 43 | return os.path.basename(sc.get_config_var('LIBDIR')) 44 | 45 | 46 | def python_ver(args): 47 | return sc.get_python_version() 48 | 49 | 50 | def python_inc(args): 51 | return sc.get_config_var('CONFINCLUDEPY') 52 | 53 | 54 | def python_site(args): 55 | ver = python_ver(args) 56 | return os.path.join(lib(args), 'python' + ver, 'site-packages') 57 | 58 | 59 | def pyqt4_sip(args): 60 | from PyQt4 import pyqtconfig 61 | pkg_cfg = pyqtconfig._pkg_config 62 | return pkg_cfg['pyqt_sip_dir'] 63 | 64 | 65 | def pyqt5_sip_flags(args): 66 | import PyQt5.Qt 67 | return PyQt5.Qt.PYQT_CONFIGURATION['sip_flags'] 68 | 69 | 70 | def pyqt4_sip_flags(args): 71 | from PyQt4 import pyqtconfig 72 | pkg_cfg = pyqtconfig._pkg_config 73 | return pkg_cfg['pyqt_sip_flags'] 74 | 75 | 76 | def sip_inc(args): 77 | pkg_cfg = sipconfig._pkg_config 78 | return pkg_cfg['sip_inc_dir'] 79 | 80 | 81 | if __name__ == '__main__': 82 | sys.exit(main()) 83 | -------------------------------------------------------------------------------- /src/build/macros.cmake: -------------------------------------------------------------------------------- 1 | 2 | macro(BuildParserScanner FLEX_L_PREFIX BISON_Y_PREFIX PARSER_PREFIX GENERATED_CPPS PREGENERATED_PREFIX) 3 | ## find our parser generators 4 | find_program(BISON_EXE bison) 5 | find_program(FLEX_EXE flex) 6 | find_program(SED_EXE sed) 7 | 8 | if((BISON_EXE STREQUAL "BISON_EXE-NOTFOUND") OR (FLEX_EXE STREQUAL "FLEX_EXE-NOTFOUND") OR (SED_EXE STREQUAL "SED_EXE-NOTFOUND")) 9 | # don't have flex/bison/sed, use pregenerated versions 10 | set (${GENERATED_CPPS} ${PREGENERATED_ROOT}/${PREGENERATED_PREFIX}/generated/${BISON_Y_PREFIX}.cpp ${PREGENERATED_ROOT}/${PREGENERATED_PREFIX}/generated/${FLEX_L_PREFIX}.cpp ) 11 | else ((BISON_EXE STREQUAL "BISON_EXE-NOTFOUND") OR (FLEX_EXE STREQUAL "FLEX_EXE-NOTFOUND") OR (SED_EXE STREQUAL "SED_EXE-NOTFOUND")) 12 | ## build the parser from the flex/yacc sources 13 | 14 | ADD_CUSTOM_COMMAND( 15 | SOURCE "${FLEX_L_PREFIX}.l" 16 | COMMAND "flex" 17 | ARGS "-o${FLEX_L_PREFIX}In.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/${FLEX_L_PREFIX}.l" 18 | OUTPUT ${FLEX_L_PREFIX}In.cpp 19 | DEPENDS ${FLEX_L_PREFIX}.l 20 | ) 21 | 22 | ADD_CUSTOM_COMMAND( 23 | SOURCE "${FLEX_L_PREFIX}In.cpp" 24 | COMMAND "sed" 25 | ARGS -e "'s/${PARSER_PREFIX}wrap(n)/${PARSER_PREFIX}wrap()/g'" -e "'s/yy/${PARSER_PREFIX}/g'" -e "'s/YY/${PARSER_PREFIX}YY/g'" ${FLEX_L_PREFIX}In.cpp | tee ${FLEX_L_PREFIX}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/generated/${FLEX_L_PREFIX}.cpp > /dev/null 26 | OUTPUT ${FLEX_L_PREFIX}.cpp 27 | DEPENDS ${FLEX_L_PREFIX}In.cpp 28 | ) 29 | 30 | ADD_CUSTOM_COMMAND( 31 | SOURCE "${BISON_Y_PREFIX}.y" 32 | COMMAND "bison" 33 | ARGS "--defines" "--verbose" "--fixed-output-files" "-p" "${PARSER_PREFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/${BISON_Y_PREFIX}.y" 34 | OUTPUT y.tab.c y.tab.h 35 | DEPENDS ${BISON_Y_PREFIX}.y 36 | ) 37 | 38 | ADD_CUSTOM_COMMAND( 39 | SOURCE "y.tab.h" 40 | COMMAND "sed" 41 | ARGS -e "'s/yy/${PARSER_PREFIX}/g'" -e "'s/YY/${PARSER_PREFIX}YY/g'" y.tab.h | tee ${BISON_Y_PREFIX}.tab.h ${CMAKE_CURRENT_SOURCE_DIR}/generated/${BISON_Y_PREFIX}.tab.h > /dev/null 42 | OUTPUT ${BISON_Y_PREFIX}.tab.h 43 | DEPENDS y.tab.h 44 | ) 45 | 46 | ADD_CUSTOM_COMMAND( 47 | SOURCE "y.tab.c" 48 | COMMAND "sed" 49 | ARGS -e "'s/yy/${PARSER_PREFIX}/g'" -e "'s/YY/${PARSER_PREFIX}YY/g'" y.tab.c | tee ${BISON_Y_PREFIX}.cpp "${CMAKE_CURRENT_SOURCE_DIR}/generated/${BISON_Y_PREFIX}.cpp" > /dev/null 50 | OUTPUT ${BISON_Y_PREFIX}.cpp 51 | DEPENDS y.tab.c ${BISON_Y_PREFIX}.tab.h 52 | ) 53 | 54 | ## set build files 55 | set (${GENERATED_CPPS} ${FLEX_L_PREFIX}.cpp ${BISON_Y_PREFIX}.cpp) 56 | #add_custom_target(run ALL DEPENDS ${${GENERATED_CPPS}}) 57 | endif( (BISON_EXE STREQUAL "BISON_EXE-NOTFOUND") OR (FLEX_EXE STREQUAL "FLEX_EXE-NOTFOUND") OR (SED_EXE STREQUAL "SED_EXE-NOTFOUND")) 58 | 59 | 60 | endmacro() 61 | -------------------------------------------------------------------------------- /src/build/seexpr2-config.cmake: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-exports.cmake") 4 | 5 | set(@PROJECT_NAME@_FOUND TRUE) 6 | -------------------------------------------------------------------------------- /src/build/seexpr2.pc.in: -------------------------------------------------------------------------------- 1 | # pkg-config file for seexpr2 2 | prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@CMAKE_INSTALL_PKGCONFIG_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_PKGCONFIG_INCLUDEDIR@ 5 | 6 | Name: seexpr2 7 | Description: SeExpr v2 Library 8 | Version: 1.0.0 9 | Cflags: -I${includedir} 10 | Libs: -L${libdir} 11 | -------------------------------------------------------------------------------- /src/demos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/../SeExpr2) 17 | 18 | add_executable(asciiGraph2 "asciiGraph.cpp") 19 | target_link_libraries(asciiGraph2 SeExpr2) 20 | install(TARGETS asciiGraph2 DESTINATION ${CMAKE_INSTALL_BINDIR}) 21 | 22 | add_executable(asciiCalc2 "asciiCalculator.cpp") 23 | target_link_libraries(asciiCalc2 SeExpr2) 24 | install(TARGETS asciiCalc2 DESTINATION ${CMAKE_INSTALL_BINDIR}) 25 | 26 | # TODO re-enable 27 | add_subdirectory(imageSynth) 28 | add_subdirectory(imageEditor) 29 | #add_subdirectory(segraph) 30 | #add_subdirectory(rman) 31 | 32 | #if (ENABLE_LLVM_BACKEND) 33 | # add_executable(llvmtest "llvmtest.cpp") 34 | # target_link_libraries(llvmtest ${SEEXPR_LIBRARIES}) 35 | # install(TARGETS llvmtest DESTINATION ${CMAKE_INSTALL_BINDIR}) 36 | #endif() 37 | -------------------------------------------------------------------------------- /src/demos/imageEditor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | # Set application root dir for use inside the source code. 18 | add_definitions(-DIMAGE_EDITOR_ROOT="${CMAKE_INSTALL_PREFIX}") 19 | 20 | if (ENABLE_QT5) 21 | find_package(Qt5 COMPONENTS Core Gui Widgets) # find and setup Qt5 for this project 22 | include_directories(${Qt5Core_INCLUDE_DIRS} 23 | ${Qt5Gui_INCLUDE_DIRS} 24 | ${Qt5OpenGL_INCLUDE_DIRS}) 25 | else() 26 | find_package(Qt4 COMPONENTS QtCore QtGui) 27 | include_directories(${QT_INCLUDE_DIR} 28 | ${QT_INCLUDE_DIR}/QtCore 29 | ${QT_INCLUDE_DIR}/QtGui) 30 | endif() 31 | 32 | if (NOT PNG_DIR) 33 | find_package(PNG QUIET) 34 | endif() 35 | 36 | if(Qt5_FOUND OR QT4_FOUND) 37 | if(PNG_FOUND) 38 | set(imageEditor_MOC_HDRS ImageEditorDialog.h) 39 | set(imageEditor_CPPS imageEditor.cpp) 40 | 41 | if (ENABLE_QT5) 42 | qt5_wrap_cpp(imageEditor_MOC_SRCS ${imageEditor_MOC_HDRS}) 43 | else() 44 | qt4_wrap_cpp(imageEditor_MOC_SRCS ${imageEditor_MOC_HDRS}) 45 | endif() 46 | 47 | add_executable(imageEditor2 ${imageEditor_CPPS} ${imageEditor_MOC_SRCS}) 48 | 49 | if (ENABLE_QT5) 50 | target_link_libraries(imageEditor2 Qt5::Core) 51 | target_link_libraries(imageEditor2 Qt5::Gui) 52 | target_link_libraries(imageEditor2 Qt5::Widgets) 53 | else() 54 | target_link_libraries(imageEditor2 ${QT_QTCORE_LIBRARY}) 55 | target_link_libraries(imageEditor2 ${QT_QTGUI_LIBRARY}) 56 | endif() 57 | 58 | target_link_libraries(imageEditor2 ${SEEXPR_LIBRARIES}) 59 | target_link_libraries(imageEditor2 ${SEEXPR_EDITOR_LIBRARIES}) 60 | 61 | include_directories(SYSTEM ${PNG_INCLUDE_DIR}) 62 | target_link_libraries(imageEditor2 ${PNG_LIBRARIES}) 63 | install(TARGETS imageEditor2 DESTINATION ${CMAKE_INSTALL_BINDIR}) 64 | endif() 65 | endif() 66 | 67 | install(FILES fbm.se noisecolor1.se noisecolor2.se noise.se raytrace.se sinc.se 68 | DESTINATION share/SeExpr2/expressions) 69 | -------------------------------------------------------------------------------- /src/demos/imageEditor/ImageEditorDialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | /** 19 | @file ImageEditorDialog.h 20 | */ 21 | 22 | #include 23 | 24 | class QLabel; 25 | class ExprEditor; 26 | class ImageSynthesizer; 27 | 28 | class ImageEditorDialog : public QDialog { 29 | Q_OBJECT 30 | public: 31 | ImageEditorDialog(QWidget *parent = 0); 32 | 33 | private: 34 | QLabel *_imageLabel; 35 | ExprEditor *_editor; 36 | ImageSynthesizer *_imageSynthesizer; 37 | private 38 | slots: 39 | void applyExpression(); 40 | }; 41 | -------------------------------------------------------------------------------- /src/demos/imageEditor/fbm.se: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | fbm([10*$u,10*$v,.5]) 18 | -------------------------------------------------------------------------------- /src/demos/imageEditor/noise.se: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | noise(10*$u,10*$v) 18 | -------------------------------------------------------------------------------- /src/demos/imageEditor/noisecolor1.se: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | $val=noise(10*$u,10*$v); 18 | $color=ccurve($val, 19 | 0.000, [1.000, 1.000, 0.498], 4, 20 | 0.590, [0.333, 0.000, 0.000], 4, 21 | 0.665, [1.000, 1.000, 0.000], 4); 22 | 23 | $color 24 | -------------------------------------------------------------------------------- /src/demos/imageEditor/noisecolor2.se: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | $val=voronoi(5*[$u,$v,.5],4,.6,.2); 18 | $color=ccurve($val, 19 | 0.000, [0.141, 0.059, 0.051], 4, 20 | 0.185, [0.302, 0.176, 0.122], 4, 21 | 0.301, [0.651, 0.447, 0.165], 4, 22 | 0.462, [0.976, 0.976, 0.976], 4); 23 | $color 24 | -------------------------------------------------------------------------------- /src/demos/imageEditor/raytrace.se: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | $Cs=[1.000, 0.000, 1.000]; # Sphere Color 18 | $L1=norm([-1.3,-.3,0]); # Light Direction 1 19 | $L2=norm([.8,-1,-1]); # Light Direction 2 20 | $sp=[0.000, 0.000, -3.000]; # Sphere center 21 | $d=norm([$u-.5,$v-.5,-1]); # ray direction 22 | $o=[0.000, 0.000, 0.000]; # ray origin 23 | $r=1.000; # sphere radius 24 | # quadratic coefficients 25 | $a=dot($d,$d); 26 | $ominussp=$o-$sp; 27 | $b=2*dot($d,$ominussp); 28 | $c=dot($ominussp,$ominussp)-$r*$r; 29 | # discriminant 30 | $disc=$b*$b-4*$a*$c; 31 | $color=0.000; 32 | if($disc>0){ # two hit case 33 | # minimum ray parameter 34 | $t=min((-$b+sqrt($disc))/(2*$a),(-$b-sqrt($disc))/(2*$a))[0]; 35 | if($t>=0){ # if we are in front of camera 36 | $Pintersect=$o+$d*$t; # point of intersection 37 | $N=norm($Pintersect-$sp); # intersection normal 38 | # lighting 39 | $H1=(-$L1+-$d)/length($L1+$d); 40 | $color=max(dot($N,-$L1),0)*($Cs*.3+.5*max(0,dot($H1,$N))^80); 41 | $H2=(-$L2+-$d)/length($L2+$d); 42 | $color+=max(dot($N,-$L2),0)*($Cs*.3+.5*max(0,dot($H2,$N))^80); 43 | } 44 | } 45 | # return color 46 | $color 47 | -------------------------------------------------------------------------------- /src/demos/imageEditor/sinc.se: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | x=u-.5; 18 | y=v-.5; 19 | dist=x*x+y*y; 20 | sin(dist*300)*cnoise(5*[$u,$v,0]) 21 | 22 | -------------------------------------------------------------------------------- /src/demos/imageSynth/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | if (NOT PNG_DIR) 17 | find_package(PNG QUIET) 18 | endif() 19 | if (PNG_FOUND) 20 | include_directories(SYSTEM ${PNG_INCLUDE_DIR}) 21 | 22 | add_executable(imageSynth2 "imageSynth.cpp") 23 | target_link_libraries(imageSynth2 ${PNG_LIBRARIES} ${SEEXPR_LIBRARIES}) 24 | install(TARGETS imageSynth2 DESTINATION bin) 25 | 26 | add_executable(imageSynthPaint3d2 "imageSynthForPaint3d.cpp") 27 | target_link_libraries(imageSynthPaint3d2 ${PNG_LIBRARIES} ${SEEXPR_LIBRARIES}) 28 | install(TARGETS imageSynthPaint3d2 DESTINATION bin) 29 | install(DIRECTORY examples DESTINATION share/SeExpr2/demos/imageSynth 30 | USE_SOURCE_PERMISSIONS) 31 | endif() 32 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/111.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | [1,1,1] -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/fbm.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | fbm([10*$u,10*$v,.5]) 17 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/noise.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | noise(10*$u,10*$v) 17 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/noisecolor1.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $val=noise(10*$u,10*$v); 17 | $color=ccurve($val, 18 | 0.000, [1.000, 1.000, 0.498], 4, 19 | 0.590, [0.333, 0.000, 0.000], 4, 20 | 0.665, [1.000, 1.000, 0.000], 4); 21 | 22 | $color 23 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/noisecolor2.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $val=voronoi(5*[$u,$v,.5],4,.6,.2); 17 | $color=ccurve($val, 18 | 0.000, [0.141, 0.059, 0.051], 4, 19 | 0.185, [0.302, 0.176, 0.122], 4, 20 | 0.301, [0.651, 0.447, 0.165], 4, 21 | 0.462, [0.976, 0.976, 0.976], 4); 22 | $color 23 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/RemapShadowContribution.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | $newShadow =curve($Cs, 0.000, 0.000, 3, 1.000, 1.000, 3); 18 | $newShadow 19 | 20 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/bark_eucalyptusColor.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $freq_fine = 0.700; #0.00,1.00 17 | $freq_coarse = 0.000; # 0,100 18 | $X = 1.000; #0.00,10.00 19 | $Y = 1; #0.00,10.00 20 | $Z = 1; #0.00,10.00 21 | $frequency = ($freq_fine+$freq_coarse) * [$X,$Y/5,$Z]; 22 | $Strength = 0.175; 23 | $Contrast = 0.287; 24 | $Color = 1.000; #0,1 25 | $Type=2.000; #1,5 26 | $Jitter=1.000; 27 | $fbmScale=1.000; 28 | $fbmOctaves=3.000; #1,32 29 | $fbmLacunarity=2.000; #1.00,8.00 30 | $fbmGain=0.000; 31 | $R=0.275;#0.0,1 32 | $G=0.350;#0.0,1 33 | $B=0.387;#0.0,1 34 | 35 | $Cnew = choose($Color, 36 | voronoi($P*$frequency,$Type,$Jitter,$fbmScale,$fbmOctaves,$fbmLacunarity,$fbmGain), 37 | cvoronoi($P*$frequency,$Type,$Jitter,$fbmScale,$fbmOctaves,$fbmLacunarity,$fbmGain)) 38 | -> contrast($Contrast); 39 | $Cnew = floor($Cnew * 7 + 0.5) / 7; 40 | mix([$R,$G,$B],$Cnew,$Strength)->invert() 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/bark_eucalyptusDisp.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $freq_fine = 0.700; #0.00,1.00 17 | $freq_coarse = 0.000; # 0,100 18 | $X = 1.000; #0.00,10.00 19 | $Y = 1; #0.00,10.00 20 | $Z = 1; #0.00,10.00 21 | $frequency = ($freq_fine+$freq_coarse) * [$X,$Y/5,$Z]; 22 | $Strength = 1.000; 23 | $Contrast = 0.287; 24 | $Color = 0.000; #0,1 25 | $Type=2.000; #1,5 26 | $Jitter=1.000; 27 | $fbmScale=1.000; 28 | $fbmOctaves=3.000; #1,32 29 | $fbmLacunarity=2.000; #1.00,8.00 30 | $fbmGain=0.000; 31 | 32 | $Cnew = choose($Color, 33 | voronoi($P*$frequency,$Type,$Jitter,$fbmScale,$fbmOctaves,$fbmLacunarity,$fbmGain), 34 | cvoronoi($P*$frequency,$Type,$Jitter,$fbmScale,$fbmOctaves,$fbmLacunarity,$fbmGain)) 35 | -> contrast($Contrast); 36 | $Cnew = floor($Cnew * 7 + 0.5) / 7; 37 | mix($Cs,$Cnew,$Strength)->invert() 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/blackToWhite.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $Cs ? $Cs : 1 -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/candycane.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $freq =0.904; # 0,10.00 17 | 18 | $amp =0.602; # 0,10.00 19 | 20 | $P = $P + (noise($P*$freq)-.5)*$amp; 21 | 22 | $x = $P[0]; $y = $P[2]; $z = $P[1]; 23 | 24 | $rho = ($x > 0 && $y >= 0) ? atan($y/$x): 25 | 26 | ($x > 0 && $y < 0) ? atan($y/$x) + 2*PI : 27 | 28 | ($x <0) ? atan($y/$x) + PI : 29 | 30 | ($x == 0 && $y > 0) ? PI/2: 31 | 32 | ($x == 0 && $y < 0) ? 3*PI/2: 0; 33 | 34 | $rho = $rho/(PI*2); 35 | 36 | $theta = atan(sqrt( pow($x,2)+pow($y,2)) / $z); 37 | 38 | $theta = $theta/ (PI/2); 39 | 40 | $x = $rho; $y = ($P[1] - 7.048) / (18.072); 41 | 42 | $stripes =1.000; # 1,10 43 | 44 | $midpoint =0.289; 45 | 46 | $slope =5.060; #0,10.00 47 | 48 | $y = $y * $slope; 49 | 50 | $mask = (($x + $y)*$stripes) %1; 51 | 52 | $mask = $mask > $midpoint; 53 | 54 | $Cout =$mask; 55 | 56 | $Cout -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/color_noise.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $adjustHue = 0.000; #0.0,1.0 17 | $adjustSat = 0.000; #0.0, 1.0 18 | $adjustVal = 0.000; #0.0, 1.0 19 | 20 | $freq_fine = 0.700; #0.00,1.00 21 | $freq_coarse = 0.000; # 0,100 22 | $X = 1.000; #0.00,10.00 23 | $Y = 1; #0.00,10.00 24 | $Z = 1; #0.00,10.00 25 | $frequency = ($freq_fine+$freq_coarse) * [$X,$Y,$Z]; 26 | $Strength=1.000; 27 | $Contrast = 1.000; 28 | 29 | 30 | $Chsv = rgbtohsl($Cs); 31 | $Cnoise = 2 * (noise($P*$frequency)-> contrast($Contrast)) - 1; 32 | $Chsvout = [fmod($Chsv[0] + $Cnoise[0] * $adjustHue * 0.5, 1.0), 33 | $Chsv[1] + $Cnoise[1] * ((($Cnoise[1] < 0) && ($Chsv[1] < $adjustSat)) ? $Chsv[1] : $adjustSat), 34 | $Chsv[2] + $Cnoise[2] * ((($Cnoise[2] < 0) && ($Chsv[2] < $adjustVal)) ? $Chsv[2] : $adjustVal)]; 35 | $Chsvout = hsltorgb($Chsvout); 36 | mix($Cs,$Chsvout,$Strength) 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/dither_with_gamma.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | gamma($Cs,0.7)->rand() 17 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/freakles.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $scale =3.000; # 1, 100 17 | $blend =0.503; #.001, 1 18 | $rotate =[0.000, 0.000, 0.000]; #-180,180 19 | $trans =[0.000, 0.000, 0.000];#-10,10. 20 | $Strength=1.000; 21 | $Cnew=triplanar('/jobs2/VDEV/scembali/paint3d/TEXTURES/tiled/freckles.tif', $scale, $blend, $rotate, $trans); 22 | mix($Cs,$Cnew,$Strength) 23 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/lines.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | $length_xyz =1.000; #0,2 18 | $width1_xyz =1.000; #0,2 19 | $width2_xyz =2.000; #0,2 20 | 21 | $x1 = choose($width1_xyz/2,$P[0],$P[1],$P[2]); 22 | $y1 = choose($width2_xyz/2,$P[0],$P[1],$P[2]); 23 | $ss = choose($length_xyz/2,$P[0],$P[1],$P[2]); 24 | 25 | $x = $x1; 26 | $y = $y1; 27 | 28 | $tt = ($x > 0 && $y >= 0) ? atan($y/$x): 29 | ($x > 0 && $y < 0) ? atan($y/$x) + 2*PI : 30 | ($x <0) ? atan($y/$x) + PI : 31 | ($x == 0 && $y > 0) ? PI/2: 32 | ($x == 0 && $y < 0) ? 3*PI/2: 0; 33 | $tt = $tt/(2*PI); 34 | 35 | $twist =200.000; # 1,200.00 36 | $threadCount =1.000; #1,20.00 37 | $grooveShape =3.487; #0.1,10.00 38 | $disp = ($ss*$threadCount - $tt*$twist)%1; 39 | $disp = (($disp -.5)*2) -> abs() -> pow($grooveShape) -> invert(); 40 | 41 | $disp 42 | 43 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/rope_Basic.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | $length_xyz = 0; #0,2 18 | $width1_xyz = 1; #0,2 19 | $width2_xyz = 2; #0,2 20 | 21 | $x1 = choose($width1_xyz/2,$P[0],$P[1],$P[2]); 22 | $y1 = choose($width2_xyz/2,$P[0],$P[1],$P[2]); 23 | $ss = choose($length_xyz/2,$P[0],$P[1],$P[2]); 24 | 25 | $x = $x1; 26 | $y = $y1; 27 | 28 | $tt = ($x > 0 && $y >= 0) ? atan($y/$x): 29 | ($x > 0 && $y < 0) ? atan($y/$x) + 2*PI : 30 | ($x <0) ? atan($y/$x) + PI : 31 | ($x == 0 && $y > 0) ? PI/2: 32 | ($x == 0 && $y < 0) ? 3*PI/2: 0; 33 | $tt = $tt/(2*PI); 34 | 35 | $twist =1.000; # 1,200.00 36 | $threadCount =1.000; #1,20.00 37 | $grooveShape =2.000; #0.1,10.00 38 | $disp = ($ss*$threadCount - $tt*$twist)%1; 39 | $disp = (($disp -.5)*2) -> abs() -> pow($grooveShape) -> invert(); 40 | 41 | $disp 42 | 43 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/scaleTool.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $direction=3.000; #0,3 17 | $units=1.000;#0.001,10.0; # number of units per ramp. 18 | $units=1/$units; 19 | 20 | 21 | $P = $P * $units; 22 | #$P[1]%1 < $cutoff 23 | $w =0.609; 24 | $w = ($direction==0) ? $P[0]%1 : $w; 25 | $w = ($direction==1) ? $P[1]%1 : $w; 26 | $w = ($direction==2) ? $P[2]%1 : $w; 27 | $w = ($direction==3) ? 1-($P[0]%1)*($P[1]%1)*($P[2]%1) : $w; 28 | $w 29 | 30 | #1-($P[0]%1)*($P[1]%1)*($P[2]%1) 31 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/select_byColorDark.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $threshold=0.500; 17 | $Cs<$threshold 18 | 19 | # "Select Faces by Color - Dark" -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/select_byThreshold.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $threshold=0.154; 17 | $Cs>$threshold 18 | 19 | # "Select Faces by Color - Light" 20 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/texture_Tiler.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | 18 | # Texture Tiler 19 | 20 | # Adrienne Othon Dec 23, 2004 21 | 22 | # A user specified texture is mapped within each grid cell. 23 | # It's the user's job to provide a texture that is tileable 24 | # for the results to look good. The grid may be scaled and/or 25 | # rotated. 26 | # The pattern generated is projected along x axis onto the model. 27 | 28 | 29 | 30 | 31 | #------------------------------------------------------ 32 | # grid xform params: 33 | $scale = 1; #size of the grid 34 | $scaley = 1; #scale the grid along y (vertical) 35 | $scalez = 1; #scale the grid along z (horizontal) 36 | $angle = 0.000; #0.0,360.0 degrees 37 | 38 | #scale (size) of the texture. compute coordinate within this cell 39 | $scaletex = 1; 40 | $scaletexy = 1; 41 | $scaletexz = 1; 42 | $jitter = 0; 43 | 44 | $translatey = 0; #-5.0,5.0 45 | $translatez = 0; #-5.0,5.0 46 | #### 47 | 48 | ## noise (warp) 49 | $noiseamount = 0; 50 | $noisefreq = 2; 51 | 52 | 53 | $scale = max($scale,.001); 54 | $scaley = max($scaley,.001); 55 | $scalez = max($scalez,.001); 56 | $scaletex = max($scaletex,.001); 57 | $scaletexy = max($scaletexy,.001); 58 | $scaletexz = max($scaletexz,.001); 59 | 60 | #deg -> rad 61 | $angle=$angle*3.14159/180; 62 | 63 | $cos = cos($angle); 64 | $sin = sin($angle); 65 | 66 | $P1 = ($P + [0,-$translatey,$translatez])/[1,$scaley,$scalez]/$scale; 67 | 68 | #rotate, to create staggered, brick-type grid 69 | $P1 = [0, $cos*$P1[1] + $sin*$P1[2], -$sin*$P1[1]+$cos*$P1[2]]; 70 | 71 | 72 | 73 | # add noise to P1 (add warp): 74 | $P1 = $P1 + $noiseamount*(cnoise($P1*$noisefreq)-.5); 75 | 76 | 77 | 78 | ##............. translation jitter (no rotation jitter implemented here), scale the texture .............. 79 | 80 | $frac = $P1 - floor($P1); 81 | 82 | # i needa little function to do the following: 83 | $frac1 = ($frac - [.5,.5,.5])/$scaletex; 84 | $frac1y = [0,$cos,-$sin]; # get axes, [rot matrix] * [0,1,0] 85 | $frac1z = [0,$sin,$cos]; # get axes, [rot matrix] * [0,0,1] 86 | $frac1y = dot($frac1y,$frac1)*$frac1y; # project onto axes 87 | $frac1z = dot($frac1z,$frac1)*$frac1z; # project onto axes 88 | $frac1y = $frac1y / $scaletexy; #scale along axes 89 | $frac1z = $frac1z / $scaletexz; #scale along axes 90 | $frac1 = $frac1y + $frac1z + [.5,.5,.5] + $jitter*(ccellnoise($P1)-[.5,.5,.5]); #combine components, .5 center 91 | 92 | $y = $frac1[1]; 93 | $z = $frac1[2]; 94 | $test = ($y < 0 || $y > 1 || $z < 0 || $z > 1); 95 | 96 | map("/home/fahome/aothon/misc/fishscale_1.tif",$z,$y) 97 | 98 | 99 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/threads.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | $length_uvxyz =1.000; # 0,4 18 | $circ_uvxyz =0.000; # 0,4 19 | 20 | $ss = choose($length_uvxyz/4,$u,$v,$P[0],$P[1],$P[2]); 21 | $tt = choose($circ_uvxyz/4,$u,$v,$P[0],$P[1],$P[2]); 22 | 23 | #$ss = $u; 24 | #$tt = $v; 25 | $twist =10.000; # 1,200 26 | $threadCount =14.000; #1,20 27 | $grooveShape =2.000; #0.1,10.00 28 | $disp = ($ss*$threadCount - $tt*$twist)%1; 29 | $disp = (($disp -.5)*2) -> abs() -> pow($grooveShape) -> invert(); 30 | 31 | $disp 32 | 33 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/threshold.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $threshold=0.000;#0.0,1.0 17 | ($Cs<=$threshold) ? 0 : $Cs 18 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/uv_testPattern.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $sizeU = 1;#1:10 17 | $sizeV = 2.000;#1:10 18 | $rangeMult = 100; 19 | $sizeU = $sizeU * $rangeMult; 20 | $sizeV = $sizeV * $rangeMult; 21 | $Ct = sin($u*$sizeU) * sin($v*$sizeV); 22 | $Ct = ($Ct * [1,0,0] * $u) + 23 | ($Ct * [0,0,1] * $v); 24 | $Ct 25 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/wood_Nicks.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $freq_fine = 0.000; #0.00,1.00 17 | $freq_coarse = 1.000; # 0,100 18 | $X = 1.000; #0.00,10.00 19 | $Y = 1.000; #0.00,10.00 20 | $Z = 1.000; #0.00,10.00 21 | $frequency = ($freq_fine+$freq_coarse) * [$X,$Y,$Z]; 22 | $Strength = 1.000; 23 | $Contrast = 0.500; 24 | $fbmOctaves=6.000; #1,32 25 | $fbmLacunarity=4.000; #1.00,8.00 26 | $fbmGain=0.805; 27 | 28 | $Cnew = 29 | turbulence($P*$frequency,$fbmOctaves,$fbmLacunarity,$fbmGain) 30 | -> contrast($Contrast) 31 | -> clamp(0.25, 0.75); 32 | mix($Cs,$Cnew,$Strength) 33 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/paint3d_test/xyz_colorNoise.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $xScale=1.000; 17 | $yScale=1.000; 18 | $zScale=1.000; 19 | cnoise([$P*10*$xScale,$P*10*$yScale,$P*10*$zScale]) 20 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/raytrace.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | $Cs=[1.000, 0.000, 1.000]; # Sphere Color 17 | $L1=norm([-1.3,-.3,0]); # Light Direction 1 18 | $L2=norm([.8,-1,-1]); # Light Direction 2 19 | $sp=[0.000, 0.000, -3.000]; # Sphere center 20 | $d=norm([$u-.5,$v-.5,-1]); # ray direction 21 | $o=[0.000, 0.000, 0.000]; # ray origin 22 | $r=1.000; # sphere radius 23 | # quadratic coefficients 24 | $a=dot($d,$d); 25 | $ominussp=$o-$sp; 26 | $b=2*dot($d,$ominussp); 27 | $c=dot($ominussp,$ominussp)-$r*$r; 28 | # discriminant 29 | $disc=$b*$b-4*$a*$c; 30 | $color=[0.0,0.0,0.0]; 31 | if($disc>0){ # two hit case 32 | # minimum ray parameter 33 | $t=min((-$b+sqrt($disc))/(2*$a),(-$b-sqrt($disc))/(2*$a))[0]; 34 | if($t>=0){ # if we are in front of camera 35 | $Pintersect=$o+$d*$t; # point of intersection 36 | $N=norm($Pintersect-$sp); # intersection normal 37 | # lighting 38 | $H1=(-$L1+-$d)/length($L1+$d); 39 | $color=max(dot($N,-$L1),0)*(Cs*.3+.5*max(0,dot($H1,$N))^80); 40 | $H2=(-$L2+-$d)/length($L2+$d); 41 | $color+=max(dot($N,-$L2),0)*($Cs*.3+.5*max(0,dot($H2,$N))^80); 42 | } 43 | } 44 | # return color 45 | $color 46 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/run.sh: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | RES=256 18 | for i in *.se; do 19 | FNAME=`basename $i .se`.png; 20 | echo Generating $FNAME; 21 | imageSynth $FNAME $RES $RES $i; 22 | done 23 | -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/sinc.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | x=u-.5; 17 | y=v-.5; 18 | dist=x*x+y*y; 19 | a=sin(dist*300)*cnoise(5*[$u,$v,0]); 20 | #[a,a,a] 21 | a -------------------------------------------------------------------------------- /src/demos/imageSynth/examples/test.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | x=u-.5; 17 | y=v-.5; 18 | dist=x*x+y*y; 19 | t = dist*300; 20 | t2 = t*t; 21 | t3 = t*t*t; 22 | t5 = t3 * t2; 23 | t7 = t5 * t2; 24 | sinApprox = (t-t3/6+t5/120-t7/5040); 25 | a=sinApprox ; 26 | [a,a,a] -------------------------------------------------------------------------------- /src/demos/llvmtest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace std; 24 | using namespace SeExpr2; 25 | 26 | class llvmexpr : public Expression { 27 | public: 28 | //! Constructor that takes the expression to parse 29 | llvmexpr(const std::string &expr, const ExprType &type = ExprType().FP(3)) : Expression(expr, type) {} 30 | }; 31 | 32 | // TODO: turn off parsing output. 33 | int main(int argc, char *argv[]) { 34 | if (argc < 2) { 35 | std::cerr << "need a filename as argument\n"; 36 | return 1; 37 | } 38 | 39 | // Test fp 40 | std::string line; 41 | std::ifstream FSProfileData(argv[1], std::ifstream::in); 42 | while (std::getline(FSProfileData, line)) { 43 | if (!line.size() || line.at(0) == ';') continue; 44 | 45 | string::size_type start = line.find_first_of('"'); 46 | ++start; 47 | string::size_type end = line.find_last_of('"'); 48 | string exprStr(line, start, end - start); 49 | 50 | std::cout << left << "\n"; 51 | std::istringstream iss(string(line, end + 1), std::istringstream::in); 52 | int dim = 0; 53 | iss >> dim; 54 | std::cout << "exprStr: " << exprStr << std::endl; 55 | std::cout << "dim: " << dim << std::endl; 56 | 57 | llvmexpr expr(exprStr, ExprType().FP(dim)); 58 | if (!expr.isValid()) { 59 | std::cerr << expr.parseError() << std::endl; 60 | assert(false); 61 | } 62 | 63 | const double *result = expr.evalFP(); 64 | 65 | for (int i = 0; i < dim; ++i) std::cout << result[i] << ' '; 66 | std::cout << std::endl; 67 | } 68 | 69 | if (!argv[2]) return 0; 70 | FSProfileData.close(); 71 | 72 | // Test string 73 | FSProfileData.open(argv[2], std::ifstream::in); 74 | while (std::getline(FSProfileData, line)) { 75 | if (!line.size() || line.at(0) == ';') continue; 76 | 77 | std::cout << "exprStr: " << line << std::endl; 78 | llvmexpr expr(line, ExprType().String()); 79 | if (!expr.isValid()) { 80 | std::cerr << expr.parseError() << std::endl; 81 | assert(false); 82 | } 83 | 84 | const char *result = expr.evalStr(); 85 | 86 | std::cout << result; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/demos/rman2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | # Non optimal, can't figure out better way right now 17 | set(RMANTREE_TEST $ENV{RMANTREE} CACHE STRING stuff FORCE) 18 | string(COMPARE EQUAL "${RMANTREE_TEST}" "" RMAN_SET) 19 | 20 | if (NOT ${RMAN_SET}) 21 | include_directories($ENV{RMANTREE}/include) 22 | link_directories($ENV{RMANTREE}/lib) 23 | 24 | add_library(SeExprOp2 SHARED seop.cpp) 25 | target_link_libraries(SeExprOp2 prman ${SEEXPR_LIBRARIES}) 26 | install(TARGETS SeExprOp2 DESTINATION prman) 27 | 28 | foreach (SHADER_BASENAME testdisp testse) 29 | set(SHADER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SHADERSOURCE}) 30 | add_custom_command( 31 | SOURCE ${SHADER_FILE}.sl 32 | COMMAND shader 33 | ARGS -o ${SHADER_FILE}.slo ${SHADER_FILE}.sl 34 | OUTPUT ${SHADER_FILE}.slo 35 | DEPENDS ${SHADER_FILE}.sl SeExprOp2) 36 | 37 | add_custom_target( 38 | shader-${SHADER_BASENAME} ALL 39 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_BASENAME}.slo) 40 | 41 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_BASENAME}.slo 42 | DESTINATION prman) 43 | endforeach() 44 | 45 | file(GLOB ribs "*.rib") 46 | install(FILES ${ribs} DESTINATION prman) 47 | endif() 48 | -------------------------------------------------------------------------------- /src/demos/rman2/camera.rib: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Clipping .01 100 17 | Projection "perspective" "fov" [54.4216] 18 | ScreenWindow -1.16857 1.16857 -1 1 19 | Rotate 0 0 0 1 20 | Scale 1 1 -1 21 | ConcatTransform [0.995755 -0.052756 0.075424 0.000000 0.000000 0.819438 0.573168 0.000000 -0.092043 -0.570735 0.815960 0.000000 -0.007945 -0.000000 -6.952593 1.000000 ] 22 | -------------------------------------------------------------------------------- /src/demos/rman2/immutable_hash_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef immutable_hash_map_h 18 | #define immutable_hash_map_h 19 | 20 | // a simple hash map optimized for simple, immutable data 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | template 27 | class immutable_hash_map { 28 | public: 29 | std::vector _keys; 30 | std::vector _values; 31 | int _size; 32 | int _mask; 33 | 34 | immutable_hash_map(key_type* keys, value_type* values, int size) : _size(size) { 35 | if (size <= 0) { 36 | _keys.resize(1, ""); 37 | _values.resize(1); 38 | _mask = 0; 39 | return; 40 | } 41 | 42 | // build table, size = (nearest power of two >= size*2) 43 | int table_size = 1 << int(ceil(log(size * 2) * (1 / M_LN2))); 44 | _mask = table_size - 1; 45 | 46 | _keys.resize(table_size); 47 | _values.resize(table_size); 48 | 49 | key_type* kp = keys, *end = kp + size; 50 | value_type* vp = values; 51 | while (kp != end) { 52 | int pos = find(*kp); 53 | _keys[pos] = *kp++; 54 | _values[pos] = *vp++; 55 | } 56 | } 57 | 58 | const value_type& operator[](const key_type& key) const { return _values[find(key)]; } 59 | 60 | int size() const { return _size; } 61 | 62 | private: 63 | int find(const key_type& key) const { 64 | uint32_t hash = intptr_t(key) ^ (intptr_t(key) >> 32); 65 | // hash function from Thomas Wang (wang@cup.hp.com) 66 | hash = ~hash + (hash << 15); 67 | hash = hash ^ (hash >> 12); 68 | hash = hash + (hash << 2); 69 | hash = hash ^ (hash >> 4); 70 | hash = hash * 2057; 71 | hash = hash ^ (hash >> 16); 72 | while (1) { 73 | int pos = hash & _mask; 74 | const key_type& k = _keys[pos]; 75 | if (k == key || !k) return pos; // found key or blank 76 | hash++; // collision, keep looking 77 | } 78 | } 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/demos/rman2/light.rib: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | 17 | TransformBegin 18 | Scale 1 1 -1 19 | ConcatTransform [0.995755 -0.052756 0.075424 0.000000 0.000000 0.819438 0.573168 0.000000 -0.092043 -0.570735 0.815960 0.000000 -0.007945 -0.000000 -6.952593 1.000000 ] 20 | ConcatTransform [ -1 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 1 ] 21 | LightSource "shadowdistant" "light" "uniform float intensity" [1] #"shadowname" "raytrace" 22 | TransformEnd 23 | LightSource "ambientlight" "light" "uniform float intensity" [.01] 24 | 25 | # Attribute "trace" "bias" [.1] 26 | #Attribute "visibility" "trace" [1] 27 | #Attribute "shade" "transmissionhitmode" ["primitive"] 28 | #Attribute "visibility" "int transmission" [1] 29 | # Attribute "visibility" "int diffuse" [1] 30 | # Attribute "visibility" "int specular" [1] 31 | # Attribute "visibility" "int transmission" [0] 32 | 33 | -------------------------------------------------------------------------------- /src/demos/rman2/main.rib: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | version 3.04 17 | Sides 2 18 | Display "p3dRender.tif" "it" "rgba" 19 | Option "searchpath" "shader" [".:/home/fahome/aselle/paint3d/render/:/disney/shows/SHOW/sa/shared/paint3d/render/:/usr/local/pixar/prman-15.2/lib/shaders/"] 20 | ShadingRate 2 21 | Option "texture" "enable lerp" [1] 22 | ShadingInterpolation "smooth" 23 | Attribute "derivatives" "centered" [1] 24 | PixelSamples 3 3 25 | PixelFilter "mitchell" 4 4 26 | Format 818 700 1 27 | FrameBegin 1 28 | ReadArchive "camera.rib" 29 | WorldBegin 30 | ReadArchive "light.rib" 31 | 32 | 33 | Displacement "testdisp" 34 | "string DispExpr" "0" #.2*fbm(2*Pw)" 35 | Surface "testse" 36 | "string CExpr" ["\ 37 | lookup=fbm([5,5,5]*Pw/1,1);\ 38 | color=ccurve(lookup, 0.000, [0.635, 0.243, 0.047], 4, 0.341, [0.953, 1.000, 0.000], 4, 0.405, [0.635, 0.243, 0.047], 4, 0.474, [0.635, 0.243, 0.047], 4, 0.532, [0.635, 0.502, 0.282], 4, 0.601, [0.635, 0.243, 0.047], 4);\ 39 | color "] 40 | 41 | "string OExpr" "1" 42 | 43 | Attribute "visibility" "int transmission" [1] 44 | ReadArchive "geometry.rib" 45 | 46 | TransformBegin 47 | Displacement "testdisp" 48 | "string DispExpr" "0" 49 | Surface "testse" 50 | "string CExpr" ["vals=Pw%[100,100,100]/100; smoothstep(min(min(vals[0],1-vals[0]),min(vals[2],1-vals[2])),.05,.15)*fbm(Pw/30)"] 51 | 52 | Translate 0 0 0 53 | Scale .01 .01 .01 54 | Attribute "visibility" "int transmission" [1] 55 | ReadArchive "plane.rib" 56 | TransformEnd 57 | WorldEnd 58 | FrameEnd 59 | -------------------------------------------------------------------------------- /src/demos/rman2/test.rib: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | version 3.04 17 | Sides 2 18 | Display "test.tif" "it" "rgba" 19 | Option "searchpath" "shader" ["."] 20 | -------------------------------------------------------------------------------- /src/demos/rman2/testdisp.sl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | plugin "libSeExprOp2.so"; 19 | 20 | displacement testdisp( 21 | uniform string DispExpr="0"; 22 | ) 23 | { 24 | normal Nobj=transform("object",N); 25 | normal Nn=normalize(Nobj); 26 | color res=0; 27 | uniform float used[]; 28 | uniform string varNames="(error) Pw P N"; 29 | point Pw=transform("world",P); 30 | point Pobj=transform("object",P); 31 | varying color varValues[]={color(Pw),color(Pobj),color(Nobj)}; 32 | 33 | uniform float DispExprHandle=SeExprBind(DispExpr,varNames,used); 34 | color disp=0; 35 | SeExprEval(DispExprHandle,varValues,disp); 36 | 37 | Pobj+=Nn*disp[0]; 38 | // recompute position and normal 39 | point Ptmp=transform("object","current",Pobj); 40 | normal Ntmp=-calculatenormal(Ptmp); 41 | N=Ntmp; 42 | P=Ptmp; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/demos/rman2/testse.sl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | plugin "libSeExprOp2"; 19 | 20 | //! Shader that allows an expression for color and opacitry 21 | surface testse( 22 | uniform string CExpr="[1,1,1]"; 23 | uniform string OExpr="1"; 24 | ) 25 | { 26 | // Compute some useful quantities 27 | normal Nn=normalize(N); 28 | normal Nobj=transform("object",Nn); 29 | point Pw=transform("world",P); 30 | point Pobj=transform("object",P); 31 | 32 | // This will store which variables are used, but we don't care in this example 33 | uniform float used[]; 34 | 35 | // We bind Pw, P and N, Cs, Os 36 | uniform string varNames="(error) Pw P N Cs Os"; 37 | varying color varValues[]={color(Pw),color(Pobj),color(Nobj),Cs,Os}; 38 | 39 | // Evaluate color and put into Ci 40 | uniform float CExprHandle=SeExprBind(CExpr,varNames,used); 41 | SeExprEval(CExprHandle,varValues,Ci); 42 | 43 | // Evaluate color and put into Oi 44 | uniform float OExprHandle=SeExprBind(OExpr,varNames,used); 45 | SeExprEval(OExprHandle,varValues,Oi); 46 | 47 | // Final diffuse ligthign 48 | normal Nf=faceforward(Nn,I); 49 | Ci=Ci*(diffuse(Nf)+ambient())*Oi; 50 | } 51 | -------------------------------------------------------------------------------- /src/demos/segraph/GrapherExpr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _GrapherExpr_ 18 | #define _GrapherExpr_ 19 | #include 20 | 21 | //! Simple variable that just returns its internal value 22 | struct SimpleVar : public SeExprScalarVarRef { 23 | double val; // independent variable 24 | void eval(const SeExprVarNode* /*node*/, SeVec3d& result) { result[0] = val; } 25 | }; 26 | 27 | //! Simple expression class to support our function grapher 28 | class GrapherExpr : public SeExpression { 29 | const std::map& vars; 30 | 31 | public: 32 | //! Constructor that takes the expression to parse 33 | GrapherExpr(const std::string& expr, const std::map& vars) 34 | : SeExpression(expr), vars(vars) {} 35 | 36 | //! set the independent variable 37 | void setX(double x_input) { x.val = x_input; } 38 | 39 | private: 40 | //! independent variable 41 | mutable SimpleVar x; 42 | 43 | //! resolve function that only supports one external variable 'x' 44 | SeExprVarRef* resolveVar(const std::string& name) const { 45 | // check my internal variable 46 | if (name == "x") return &x; 47 | // check external variable table 48 | std::map::const_iterator i = vars.find(name); 49 | if (i != vars.end()) return const_cast(&i->second); 50 | // nothing found 51 | return 0; 52 | } 53 | }; 54 | #endif 55 | -------------------------------------------------------------------------------- /src/demos/segraph/segraph.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include 18 | #include "GraphWindow.h" 19 | #include 20 | #include 21 | #include 22 | 23 | int main(int argc, char* argv[]) { 24 | QApplication app(argc, argv); 25 | GraphWindow* graph = new GraphWindow; 26 | graph->show(); 27 | app.exec(); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/demos/segraph2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | if (ENABLE_QT5) 17 | find_package(Qt5 COMPONENTS Core Gui Widgets) # find and setup Qt5 for this project 18 | include_directories(${Qt5Core_INCLUDE_DIRS} 19 | ${Qt5Gui_INCLUDE_DIRS} 20 | ${Qt5OpenGL_INCLUDE_DIRS}) 21 | else() 22 | find_package(Qt4 COMPONENTS QtCore QtGui) 23 | include_directories(${QT_INCLUDE_DIR} 24 | ${QT_INCLUDE_DIR}/QtCore 25 | ${QT_INCLUDE_DIR}/QtGui) 26 | endif() 27 | 28 | if(Qt5_FOUND OR QT4_FOUND) 29 | set(segraph_MOC_HDRS Graph.h GraphWindow.h Functions.h) 30 | set(segraph_CPPS main.cpp Graph.cpp GraphWindow.cpp Functions.cpp) 31 | 32 | if (ENABLE_QT5) 33 | qt5_wrap_cpp(segraph_MOC_SRCS ${segraph_MOC_HDRS}) 34 | else() 35 | qt4_wrap_cpp(segraph_MOC_SRCS ${segraph_MOC_HDRS}) 36 | endif() 37 | 38 | add_executable(segraph2 ${segraph_CPPS} ${segraph_MOC_SRCS}) 39 | install(TARGETS segraph2 DESTINATION demo) 40 | 41 | if (ENABLE_QT5) 42 | target_link_libraries(segraph Qt5::Core) 43 | target_link_libraries(segraph Qt5::Gui) 44 | target_link_libraries(segraph Qt5::Widgets) 45 | else() 46 | target_link_libraries(segraph2 ${QT_QTCORE_LIBRARY}) 47 | target_link_libraries(segraph2 ${QT_QTGUI_LIBRARY}) 48 | endif() 49 | 50 | target_link_libraries(segraph2 ${SEEXPR_LIBRARIES}) 51 | endif() 52 | -------------------------------------------------------------------------------- /src/demos/segraph2/Functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ #ifndef _Functions_h_ 17 | #define _Functions_h_ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | //! Simple variable that just returns its internal value 26 | struct SimpleVar : public ExprVarRef { 27 | double val; // independent variable 28 | 29 | SimpleVar() : ExprVarRef(ExprType().FP(1).Varying()), val(0.0) {} 30 | 31 | void eval(double* result) { result[0] = val; } 32 | 33 | void eval(char** result) {} 34 | }; 35 | 36 | //! Model representing all the functions that the grapher handles 37 | class GrapherExpr; 38 | class Functions : public QAbstractTableModel { 39 | Q_OBJECT; 40 | 41 | //! List of expression classes 42 | std::vector functions; 43 | //! Expression strings 44 | std::vector strings; 45 | //! Whether item is selected 46 | std::vector selected; 47 | //! Extra variables 48 | std::map variables; 49 | 50 | public: 51 | Functions(); 52 | ~Functions(); 53 | //! Sets up a function for evaluation 54 | void setupFunction(const std::string& s, GrapherExpr** exprDest); 55 | //! Adds a function given a qstring 56 | void addFunction(const QString& s); 57 | //! Evaluates functionId given at independent variable x 58 | bool isValid(int functionId) const; 59 | //! Evaluates functionId given at independent variable x 60 | double eval(int functionId, double x) const; 61 | //! Returns true if the given functionId is selected 62 | bool isSelected(unsigned int functionId) const; 63 | //! Sets if the given functionId is selected 64 | void setSelected(unsigned int functionId, bool val); 65 | //! Gets a list of all selection functions 66 | void getSelected(std::vector& selectedFunctions) const; 67 | //! Set the time 68 | void setVar(const std::string& name, const double val); 69 | 70 | /************************************************** 71 | * Items below implement the QAbstractItemModel 72 | *************************************************/ 73 | int rowCount(const QModelIndex&) const; 74 | int columnCount(const QModelIndex&) const; 75 | QColor getColor(const int row) const; 76 | QVariant data(const QModelIndex& index, int role) const; 77 | QVariant headerData(int column, Qt::Orientation orient, int role) const; 78 | bool setData(const QModelIndex& index, const QVariant& value, int role); 79 | Qt::ItemFlags flags(const QModelIndex& index) const; 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/demos/segraph2/GraphWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _GraphWindow_h_ 18 | #define _GraphWindow_h_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Functions.h" 32 | #include "Graph.h" 33 | 34 | //! Main window that contains graph widget and function list 35 | class GraphWindow : public QFrame { 36 | Q_OBJECT; 37 | 38 | public: 39 | Graph* graph; 40 | QLineEdit* edit; 41 | Functions* functions; 42 | QTableView* table; 43 | QPushButton* rootbutton, *minbutton, *maxbutton; 44 | QSlider* timeSlider; 45 | QStatusBar* status; 46 | GraphWindow(QWidget* parent = 0); 47 | ~GraphWindow(); 48 | private 49 | slots: 50 | //! Add new function when it is entered into the add box 51 | void addNewFunction(); 52 | //! Start finding a numeric quantity after button clicked 53 | void findRootOrExtrema(); 54 | //! Update the selection in the internal model 55 | void selectionChanged(const QItemSelection& selected, const QItemSelection& unselected); 56 | //! Update time 57 | void updateTime(); 58 | 59 | private: 60 | float time; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/demos/segraph2/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include 18 | #include "GraphWindow.h" 19 | #include 20 | #include 21 | #include 22 | 23 | int main(int argc, char* argv[]) { 24 | QApplication app(argc, argv); 25 | GraphWindow* graph = new GraphWindow; 26 | graph->show(); 27 | app.exec(); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | find_package(Doxygen) 17 | if (DOXYGEN_FOUND AND NOT WIN32) 18 | configure_file("Doxyfile.in" "Doxyfile" @ONLY) 19 | file(GLOB (DOCUMENTED_FILES ../SeExpr2/*.h)) 20 | 21 | set(DOXYGEN ${DOXYGEN_EXECUTABLE}) 22 | add_custom_command( 23 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen.txt 24 | COMMAND ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile >doxygen.txt 25 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 26 | DEPENDS Doxyfile.in) 27 | 28 | add_custom_target(doc ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doxygen.txt) 29 | 30 | install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" DESTINATION ${DOC_DIR}) 31 | install(FILES userdoc.txt DESTINATION ${DOC_DIR} RENAME SeExpressions.html) 32 | 33 | file(GLOB "*.png" PNG_FILES) 34 | install(FILES ${PNG_FILES} DESTINATION ${DOC_DIR}) 35 | endif() 36 | -------------------------------------------------------------------------------- /src/doc/Se_voronoi_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/Se_voronoi_1.png -------------------------------------------------------------------------------- /src/doc/Se_voronoi_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/Se_voronoi_2.png -------------------------------------------------------------------------------- /src/doc/Se_voronoi_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/Se_voronoi_3.png -------------------------------------------------------------------------------- /src/doc/Se_voronoi_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/Se_voronoi_4.png -------------------------------------------------------------------------------- /src/doc/Se_voronoi_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/Se_voronoi_5.png -------------------------------------------------------------------------------- /src/doc/license.txt: -------------------------------------------------------------------------------- 1 |
 2 | Copyright Disney Enterprises, Inc.  All rights reserved.
 3 | 
 4 | Licensed under the Apache License, Version 2.0 (the "License");
 5 | you may not use this file except in compliance with the License
 6 | and the following modification to it: Section 6 Trademarks.
 7 | deleted and replaced with:
 8 | 
 9 | 6. Trademarks. This License does not grant permission to use the
10 | trade names, trademarks, service marks, or product names of the
11 | Licensor and its affiliates, except as required for reproducing
12 | the content of the NOTICE file.
13 | 
14 | You may obtain a copy of the License at
15 | 
16 | http://www.apache.org/licenses/LICENSE-2.0 17 | -------------------------------------------------------------------------------- /src/doc/main.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * \cond 3 | * Copyright Disney Enterprises, Inc. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License 7 | * and the following modification to it: Section 6 Trademarks. 8 | * deleted and replaced with: 9 | * 10 | * 6. Trademarks. This License does not grant permission to use the 11 | * trade names, trademarks, service marks, or product names of the 12 | * Licensor and its affiliates, except as required for reproducing 13 | * the content of the NOTICE file. 14 | * 15 | * You may obtain a copy of the License at 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * \endcond 18 | * \mainpage SeExpr 19 | * \image html seexprlogo.png 20 | * \section maindoc User and Programmer Tutorials 21 | * - \subpage userdoc 22 | * - \subpage plugins - Custom Function Plugins 23 | * - New v3 FAQ 24 | * \section demos Demo Applications 25 | * - \subpage mytut (code at asciiGraph.cpp) 26 | * - \subpage uitut (code at imageEditor.cpp) 27 | * - Image Synthesizer (at imageSynth.cpp) 28 | * - SeGrapher Qt Grapher (at demos/segraph) 29 | * - Renderman Shadeop (at demos/rman) 30 | * - \subpage varblocks 31 | * \section mainapi Main API pages 32 | * - Expression - Main class to parse a single expression 33 | * - ExprVarRef - Binding of an external variable to an expression context. 34 | * - ExprFunc - Define a custom function that calls C++ code 35 | * - ExprFuncX - Manual argument parsing C++ code 36 | * - ExprFuncNode - Node that calls a function (needed for SeExprFuncX arg parsing) 37 | * \section useful Useful classes and functions 38 | * - Vec - Class to hold and manipulate n-dimensional vectors 39 | * - ExprBuiltins.h - Useful builtin functions that are also available in C++ 40 | * - SeExpr2::Curve - Hermite interpolation curve. 41 | * 42 | * \section internals Internals 43 | * - ExprNode - Parse Tree Node 44 | * - ExprParser - Entry point to bison/flex parser 45 | * 46 | * \section Other 47 | * - \subpage license 48 | * - Older Documentation (v1-v2) 49 | */ 50 | 51 | /** 52 | \page mytut Simple ASCII Grapher Tutorial 53 | \htmlinclude tutorial.txt 54 | */ 55 | /** 56 | \page uitut Image Editor Tutorial 57 | \htmlinclude uitutorial.txt 58 | */ 59 | /** 60 | \page varblocks Using Variable Blocks 61 | \htmlinclude varblocks.txt 62 | */ 63 | /** 64 | \page userdoc User Documentation 65 | \htmlinclude userdoc.txt 66 | */ 67 | /** 68 | \page plugins SeExpr Plugins 69 | \htmlinclude plugins.txt 70 | */ 71 | /** 72 | \page license License 73 | \htmlinclude license.txt 74 | */ 75 | -------------------------------------------------------------------------------- /src/doc/seexprlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/seexprlogo.png -------------------------------------------------------------------------------- /src/doc/summer-documentation/TODO-overview.txt: -------------------------------------------------------------------------------- 1 | Work that needs to be done on SeExpr soon: 2 | 3 | Function defintions need to be added to global scope so that they can be used in final block (and other function defintions). 4 | 5 | Function declaration parameters need to have optional '$' (currently '$' is required). This requires a slight change to parser. 6 | 7 | Nodes should keep wanted type from prep. By keeping the wanted type, each node can do promotion/demotion at execution easily. 8 | 9 | Sanity checks for changes between version 1 and version 2 of SeExpr need to be added. 10 | 11 | Interpreted execution of SeExpr 2.0 needs to be implemented. 12 | 13 | LLVM compilation of SeExpr 2.0 needs to be implemented. 14 | -------------------------------------------------------------------------------- /src/doc/summer-documentation/Wishlist-overview.txt: -------------------------------------------------------------------------------- 1 | These are future tasks to be done on SeExpr 2.0. They currently have a low priority, especially compared to the items in the TODO list. 2 | 3 | Error recovery/reporting in parser. Currently the parser dies on an error without reporting what went wrong, which makes debugging difficult. 4 | 5 | String operations (concatenation, substring operations, etc.). Currently planned to be added as constant or uniform operations. This restriction (no varying execution) keeps string operations fairly efficient. 6 | 7 | Loops. Certain uses of SeExpr could benefit greatly from allowing a loop construct. However, there are concerns that including loops would slow down execution in unexpected ways. 8 | 9 | Splice notation. Example: $v[0..2]. Allowing splicing simplifies changing the length of a vector; however, it is unclear if there is any clear use. 10 | 11 | Reorder/limit operator: .xyz .zyx .xxx (reorder/repeat different elements of vector). Like splicing, reordering elements could be useful, but there is no obvious current need for it. 12 | 13 | Adding library-like programs to be included. Allowing user-defined functions as a library and not just at the beginning of a program could be useful when such user-defined functions are used in multiple programs, but currently there is no immediate use. 14 | 15 | Multiple return values. Allowing functions and whole SeExpr programs to return multiple values can simply programs. However, the syntax for returning multiple values could make programs returning multiple values unreadable. The current proposed syntax is to change final expressions (in function bodies and at the end of programs) to list return values, enclosed by parentheses and delimited by commas. 16 | 17 | Currently, all functions return the varying lifetime. Future expansions, such as uniform only string operatioins would not work well (if at all) with this. 18 | 19 | Add lifetime qualifier to user-defined functions: 20 | def FLOAT foo(FLOAT $a, FLOAT $b) { $a + $b } CONSTANT 21 | This addition would allow for explicit control of when functions could execute. It would help debugging programs that are not as efficient as desired or expected. 22 | -------------------------------------------------------------------------------- /src/doc/summer-documentation/comment-overview.txt: -------------------------------------------------------------------------------- 1 | Currently in SeExpr, comments are parsed only to expose them to the SeExpression object parsing the SeExpr program. 2 | 3 | After a successful parse, the start and end positions of all the comments in order are available via the member function of the class SeExpression, getComments. The function getComments returns a vector of pairs of integers. The first integer of each pair refers to the start position of a comment, and the second integer refers to the end position of that comment. 4 | 5 | The original program can be accessed via the member function of the class SeExpression, getExpr. The start and end positions of the comments in getComments refer to offsets from the start of the string returned by the member function getExpr. -------------------------------------------------------------------------------- /src/doc/summer-documentation/pattern-matching-overview.txt: -------------------------------------------------------------------------------- 1 | In the directory, src/SeExprEditor/, the files SeControlSpec.h and SeControlSpec.cpp contain the SpecExaminer class, which is an examiner class, which uses the Walker class (in SeExprWalker.h) to find certain patterns with a SeExprNode parse tree. 2 | 3 | The patterns matched are: 4 | 5 | Scalar assignment. Something of the form: $v = 0; 6 | Vector assignment. Something of the form: $v = [1,2,3]; 7 | Curve assignment. Something of the form: $v = curve($a, $x1, $y1, $z1, ..., $xn, $yn, $zn) 8 | Curve assignment. Something of the form: $v = ccurve($a, $x1, $y1, $z1, ..., $xn, $yn, $zn) 9 | Strings. Something of the form: "filename or other string literal" 10 | 11 | The intended use of this examiner is to match comments to specific parts of a SeExpr program. This allows a gui interface to change the program without the user directly interacting with the code of the program. 12 | 13 | An example for using this examiner can be found in tests/patterns.cpp. -------------------------------------------------------------------------------- /src/doc/summer-documentation/regression-tester-overview.txt: -------------------------------------------------------------------------------- 1 | The regression tester in tests/TypeTester.cpp is designed to test the type check system within the preparation functions, prep() in the SeExprNode parse trees (in SeExprNode.cpp). 2 | 3 | The function, test, checks that the actual type of a single given SeExpr program matches what is expected. (The parameters of test are poorly named.) It's output to std::cout and std::cerr depend on the verbosity level and the results of the test. If the test fails, regardless of the verbosity level, "Failed check." is given to std::cerr. The higher the verbosity level (currently up to 3), the more information is given to std::cout and std::cerr. 4 | 5 | The functions, testSingle, testDouble, and testTriple, use the function test to run through many possiblities of types checking against a given function for the desired results. The function testSingle changes the type of the variable $v. The function testDouble changes the type of the variables, $x and $y. The function testTriple changes the type of the variables, $x, $y, and $z. 6 | 7 | The functions, testSingle, testDouble, and testTriple, first test the primary types. They use FLOAT, FLOAT[2], FLOAT[3], STRING, and ERROR to test the primary types. A cross-product approach is used for testDouble and testTriple to test all possible combinations of types. After testing all combinations of primary types, each function tests all possible lifetime qualifiers (constant, uniform, varying and error) with the primary type as FLOAT. 8 | 9 | The functions, testOne, testTwo, and testThree, provide syntactic sugar for testSingle, testDouble, and testTriple. Each call to testOne ultimately calls the function test 9 (5^1 + 4^1) times. Each call to testTwo ultimately calls the function test 41 (5^2 + 4^2) times. Each call to testThree ultimately calls the function test 189 (5^3 + 4^3) times. 10 | -------------------------------------------------------------------------------- /src/doc/summer-documentation/user-defined-function-overview.txt: -------------------------------------------------------------------------------- 1 | In SeExpr 2.0, users can define functions within a SeExpr program for use within that program. There are several restrictions on the definitions and use of these functions to keep SeExpr programs human-readable and to simplify compilation. 2 | 3 | The syntax of an externally defined function is as follows: 4 | extern RETURN_TYPE function_name(ARG_TYPE_1, ..., ARG_TYPE_N) 5 | where the capitalized terms are SeExpr types. 6 | 7 | For example: 8 | extern FLOAT sin(FLOAT) 9 | is a valid declaration for an external definition of the sin function. 10 | 11 | The syntax of a function definition is as follows: 12 | def RETURN_TYPE function_name(ARG_TYPE_1 arg1, ..., ARG_TYPE_N argn) { assigns; expr } 13 | where the capitalized therms are SeExpr types. 14 | 15 | For both function declarations and function definitions, there is no limit on the number of arguments. A function with no arguments can only return a constant value (see below for the explanation why this is so). 16 | 17 | The body of a function definition,"{ assigns; expr }", has two parts, its assignment statements, assigns, and its final expression, expr. When a function is called, any parameters it has are bound in the local scope. Then the assignment statements are executed in order. Lastly, the final expression is evaluated and its value is returned. 18 | 19 | The return type, RETURN_TYPE, in a function defintion is optional, since the type of the value returned by the function can be inferred from the expression, expr. Including the return type helps clarify the cause of any type errors. In an externally defined function declaration, the return type, RETURN_TYPE, is required. 20 | 21 | Restrictions: 22 | 23 | Since the return type, RETURN_TYPE, is used for type checking, no promotion or demotion is possible in a function definition. Therefore the return type, RETURN_TYPE, and the type of the final expression, expr, must match exactly. 24 | 25 | Each user-defined function only has access to its own parameters. No user-defined function has access to any global variables or parameters. So a function with no parameters has no values that can change, and can only return a fixed, or constant, value. Also, no function can modify any variables outside of itself. 26 | 27 | Every user-defined function can call functions defined before itself within its body. A user-defined function cannot call itself. A user-defined function cannot call a function defined after itself. 28 | 29 | Once a function has been defined, its name cannot be used again for any function definition or declaration. 30 | 31 | The above restrictions were designed intentionally so that recursion and side-effects are impossible. Besides simplifying compilation and guaranteeing termination of every valid SeExpr program, these restrictions keep SeExpr programs from having unintended or unexpected behavior. 32 | -------------------------------------------------------------------------------- /src/doc/summer-documentation/walker-overview.txt: -------------------------------------------------------------------------------- 1 | The walker/examiner classes are a generalized way of visiting each node of an SeExprNode parse tree. 2 | 3 | To write a new examiner, simply write a class, T, that inherents publicly from the Examiner class in SeExprWalker.h and provide definitions for the abstract member functions, examine and reset. The abstract base class Examiner and the class Walker have a template parameter, which is a boolean. If the template parameter is true, any walk of a SeExprNode parse tree will only have constant access to the tree. If the template parameter is false (the default), every walk of a SeExprNode parse tree will be able to modify the parse tree however it wants. 4 | 5 | The member function, reset(), clears any internal state in the new examiner class, T. So if there is no state (data members that change throughout examining multiple nodes in the same parse tree), reset can be any empty function. However, since the walk member function of Walker returns void, there must be some side effects somewhere (in the examiner, in the parse tree, or globally) for walk to do anything other than be an expensive no-op. 6 | 7 | The other member function, examine(SeExprNode * n), examines the given node, n, and does whatever is appropriate for this visit. The return value of examine is a boolean: If the children of n are to be examined using the function examine, then examine(n) should return true. If examine has internally examined n's children, or if n's children don't need to be examined at all, then examine(n) should return false. 8 | 9 | To use an examiner, T, first initialize an instance, e, of the examiner class, T. Then initialize an instance, w, of the desired walker (const or nonconst) passing a pointer to the instance of the examiner, e. Finally, call the walk member function from the walker, w, passing the parse tree, t, to walk as the call's only parameter. In C++ pseudo-code: 10 | 11 | T e = T(); 12 | Walker w = Walker(&e); 13 | w.walk(t); 14 | 15 | The current implementation of walker only does a pre-order traversal of a parse tree. So the root node of the tree is examined first. If the examine call returned true, each of its children are examined recursively. For example, consider the tree: 16 | 17 | a 18 | / | \ 19 | b c d 20 | / \ | 21 | e f g 22 | 23 | An pre-order traversal of this tree examines a, b, e, f, c, d, and g, in that order. 24 | 25 | Other examination orders are possibly but currently pre-order traversal is the only one implemented. 26 | -------------------------------------------------------------------------------- /src/doc/ui_addWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/ui_addWidget.png -------------------------------------------------------------------------------- /src/doc/ui_browser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/ui_browser.png -------------------------------------------------------------------------------- /src/doc/ui_editor1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/ui_editor1.png -------------------------------------------------------------------------------- /src/doc/ui_emptyLayout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/ui_emptyLayout.png -------------------------------------------------------------------------------- /src/doc/ui_final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/ui_final.png -------------------------------------------------------------------------------- /src/doc/ui_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/SeExpr/80fa99cccc85060513642033a896cc50abf2a05c/src/doc/ui_preview.png -------------------------------------------------------------------------------- /src/doc/varblocks.txt: -------------------------------------------------------------------------------- 1 | 17 | 18 |

You can still define resolveVar() and resolveFunc() methods in your custom expression classes, but you now also have the option to use variable blocks instead. These are useful for re-using variables and managing thread evaluation. 19 | 20 | Within your custom expression class, you would skip the usual resolveVar() and resolveFunc() implementations: 21 | 22 |

23 | class MyExpr:public SeExpr2::Expression {
24 | 
25 | // These are now optional:
26 | //   resolveVar()
27 | //   resolveFunc()
28 | };
29 | 
30 | 31 | 32 |

Here's how you might write an example function to run an expression that uses variable blocks. This example assumes you have a particle data struct p, with numParticles, numAttributes. A variable block contains variable names and types, but doesn't care what the values are. 33 | 34 |

35 | void f(const std::string& s, MyParticleData* p, int outputDim=3){
36 | 
37 |     // set up the bindings for each of the particle attributes
38 |     SeExpr2::VarBlockCreator blockCreator;
39 |     std::vector variableHandles;
40 |     std::vector attrs;
41 |     for(int i=0; inumAttrs(); i++) {
42 |         MyParticleAttr attr;
43 |         p->getAttrInfo(i,attr);
44 |         attrs.push_back(attr);
45 |         int handle = blockCreator.registerVariable(attr.name,
46 |                                                    TypeVec(attr.dim));
47 |         variableHandles.push_back(handle);
48 |     }
49 | 
50 |     // set up binding for the output
51 |     int outputVariableHandle=blockCreator.registerVariable("__output",
52 |                                                            TypeVec(outputDim));
53 | 
54 |     // make an expression with the appropriate bindings
55 |     MyExpr e(s);
56 |     e.setDesiredType(TypeVec(outputDim));
57 |     e.setVarBlockCreator(&blockCreator);
58 |     if(!e.isValid()) throw std::runtime_error(e.parseError()):
59 | 
60 |     // create the variable block, set up pointers to data
61 |     SeExpr2::VarBlock block = blockCreator.create();
62 |     for(int i=0; inumAttrs(); i++) {
63 |         block.Pointer(variableHandles[i]) = p->data(attrs[i]);
64 |     }
65 |     std::vector outputData(p->numParticles()*outputDim);
66 |     block.Pointer(outputVariableHandle)=outputData.data();
67 | 
68 |     // evaluate multiple expressions at once; inlines expressions
69 |     e.evalMultiple(&block, outputVariableHandle, 0, p->numParticles());
70 | }
71 | 
72 | 73 | To parallelize evaluation per particle, a simple parallel_for can be used: 74 |
75 |     // evaluate multiple expressions at once, inlines expressions
76 |     tbb::parallel_for(blocked_range(0,p->numParticles()),[](blocked_range r)) {
77 |         VarBlock myBlock=block.clone(); //should be cheap
78 |         e.evalMultiple(&myblock, outputVariableHandle, r.start, r.end);
79 |     }
80 | 
81 | -------------------------------------------------------------------------------- /src/py/__init__.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | """ 18 | SeExprPy Python Bindings of SeExprPy 19 | 20 | Getting more help: 21 | 22 | help(SeExprPy._SeExprPy) 23 | - to get info core classes 24 | help(SeExprPy.utils) 25 | - interesting helper functions/classes 26 | 27 | """ 28 | 29 | from __future__ import absolute_import 30 | import sys 31 | 32 | from .core import AST as _AST, ASTHandle, ASTType 33 | from .utils import ( 34 | getComment, Edits, traverseCallback, traverseFilter, printTree 35 | ) 36 | 37 | _PY2 = sys.version_info[0] == 2 38 | try: 39 | ustr = unicode 40 | except NameError: 41 | ustr = str 42 | 43 | 44 | def _encode(obj, encoding='utf-8'): 45 | # The Python2 Boost.Python API requires byte strings 46 | if _PY2 and isinstance(obj, ustr): 47 | value = obj.encode(encoding) 48 | else: 49 | value = obj 50 | return value 51 | 52 | 53 | # Override AST to handle unicode vs. str constructor values 54 | class AST(_AST): 55 | def __init__(self, string): 56 | super(AST, self).__init__(_encode(string)) 57 | -------------------------------------------------------------------------------- /src/py/example.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | import SeExprPy 18 | import sys 19 | 20 | if __name__=="__main__": 21 | s=""" 22 | # a cool expression 23 | a=3; 24 | if(a>5){ 25 | b=10; 26 | }else if(a>10){ 27 | b=20; 28 | } 29 | c+=10+P; 30 | map("lame.png") 31 | +map("foo.png", 32 | map("blah.png"))+f(g(3,"test"),h("lame")) 33 | """ 34 | expr=SeExprPy.AST(s) 35 | edits=SeExprPy.Edits(s) 36 | def editAllMapsToHavePrefix(node,childs): 37 | if node.type==SeExprPy.ASTType.Call: # check node is a call 38 | if node.value=="map": # check if the call is map 39 | if childs[0].type==SeExprPy.ASTType.String: # check if the first argument is a string 40 | edits.addEdit(childs[0],"testo/%s"%childs[0].value) # add to the edit structure 41 | SeExprPy.traverseCallback(expr.root(),editAllMapsToHavePrefix) 42 | SeExprPy.printTree(expr,s) 43 | print(edits.makeNewString()) 44 | 45 | print "--All Function calls----------------------------" 46 | def printAllFunctionsAndTheirArguments(node,childs): 47 | if node.type==SeExprPy.ASTType.Call: 48 | print "%s"%node.value 49 | idx=0 50 | for child in childs: 51 | if child.type==SeExprPy.ASTType.Num: 52 | edits.addEdit(child,child.value*4) 53 | print " Argument %2d %-15s %r"%(idx,child.type,child.value) 54 | idx+=1 55 | SeExprPy.traverseCallback(expr.root(),printAllFunctionsAndTheirArguments) 56 | 57 | print "--All Variables----------------------------" 58 | def printAllVariableReferences(node,childs): 59 | if node.type==SeExprPy.ASTType.Var: 60 | print "reference %s"%node.value 61 | elif node.type==SeExprPy.ASTType.Assign: 62 | print "assign %s"%node.value 63 | SeExprPy.traverseCallback(expr.root(),printAllVariableReferences) 64 | -------------------------------------------------------------------------------- /src/py/parseAll.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | import os 18 | import sys 19 | import SeExprPy 20 | path="/disney/shows/SHOW/sa/shared/paint3d/expressions/" 21 | 22 | success=0 23 | failed=0 24 | total=0 25 | 26 | def parseFile(filename): 27 | global success,failed,total 28 | try: 29 | SeExprPy.AST(open(filename).read()) 30 | success+=1 31 | except RuntimeError as e: 32 | print "Parse error in %s"%filename 33 | print "%s"%e 34 | failed+=1 35 | total+=1 36 | 37 | if len(sys.argv)==2: 38 | parseFile(sys.argv[1]) 39 | else: 40 | for root,dirs,files in os.walk(path): 41 | for f in files: 42 | if f.endswith(".se"): 43 | #print f 44 | filename=os.path.join(root,f) 45 | parseFile(filename) 46 | 47 | 48 | print "Parsed %d Success %d Failure %d"%(total,success,failed) -------------------------------------------------------------------------------- /src/tests/SeTests.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Disney Enterprises, Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License 6 | * and the following modification to it: Section 6 Trademarks. 7 | * deleted and replaced with: 8 | * 9 | * 6. Trademarks. This License does not grant permission to use the 10 | * trade names, trademarks, service marks, or product names of the 11 | * Licensor and its affiliates, except as required for reproducing 12 | * the content of the NOTICE file. 13 | * 14 | * You may obtain a copy of the License at 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _SeTests_h_ 18 | #define _SeTests_h_ 19 | 20 | #include 21 | 22 | #define SE_TEST_ASSERT(x) \ 23 | if (!(x)) std::cerr << "Test " << #x << " failed at " << __FILE__ << ":" << __LINE__ << std::endl; 24 | 25 | #define SE_TEST_ASSERT_EQUAL(actual, expected) \ 26 | if ((actual) != (expected)) \ 27 | std::cerr << "Test failed at " << __FILE__ << ":" << __LINE__ << " value expected '" << (expected) << " got " \ 28 | << "'" << (actual) << "'" << std::endl; 29 | 30 | #define SE_TEST_ASSERT_VECTOR_EQUAL(actual, expected) \ 31 | if ((actual)[0] != (expected)[0]) \ 32 | std::cerr << "Test failed at " << __FILE__ << ":" << __LINE__ << " first value expected '" << (expected) \ 33 | << " got " \ 34 | << "'" << (actual) << "'" << std::endl; \ 35 | if ((actual)[1] != (expected)[1]) \ 36 | std::cerr << "Test failed at " << __FILE__ << ":" << __LINE__ << " second value expected '" << (expected) \ 37 | << " got " \ 38 | << "'" << (actual) << "'" << std::endl; \ 39 | if ((actual)[2] != (expected)[2]) \ 40 | std::cerr << "Test failed at " << __FILE__ << ":" << __LINE__ << " third value expected '" << (expected) \ 41 | << " got " \ 42 | << "'" << (actual) << "'" << std::endl; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/tests/TypePrinter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "ExprWalker.h" 23 | #include "ExprNode.h" 24 | #include "ExprFunc.h" 25 | #include "TypeBuilder.h" 26 | #include "TypePrinter.h" 27 | 28 | using namespace SeExpr2; 29 | 30 | //! Simple expression class to print out all intermediate types 31 | class TypePrinterExpr : public TypeBuilderExpr { 32 | public: 33 | TypePrinterExpr() : TypeBuilderExpr(), _examiner(), _walker(&_examiner) {}; 34 | 35 | TypePrinterExpr(const std::string& e) : TypeBuilderExpr(e), _examiner(), _walker(&_examiner) {}; 36 | 37 | inline void walk() { 38 | if (_parseTree) _walker.walk(_parseTree); 39 | }; 40 | 41 | private: 42 | TypePrintExaminer _examiner; 43 | SeExpr2::ConstWalker _walker; 44 | 45 | protected: 46 | ExprVarRef* resolveVar(const std::string& name) const { 47 | return TypeBuilderExpr::resolveVar(name); 48 | }; 49 | 50 | ExprFunc* resolveFunc(const std::string& name) const { return TypeBuilderExpr::resolveFunc(name); } 51 | }; 52 | 53 | void get_or_quit(std::string& str) { 54 | getline(std::cin, str); 55 | 56 | if (std::cin.eof()) exit(0); 57 | }; 58 | 59 | int main(int argc, char* argv[]) { 60 | TypePrinterExpr expr; 61 | std::string str; 62 | bool givenTest = false; 63 | 64 | if (argc == 2) { 65 | givenTest = true; 66 | str = argv[1]; 67 | }; 68 | 69 | if (givenTest) { 70 | expr.setExpr(str); 71 | if (expr.isValid()) { 72 | std::cout << "Expression types:" << std::endl; 73 | } else 74 | std::cerr << "Expression failed: " << expr.parseError() << std::endl; 75 | } else { 76 | std::cout << "SeExpr Basic Pattern Matcher (Iteractive Mode):"; 77 | 78 | while (true) { 79 | std::cout << std::endl << "> "; 80 | 81 | get_or_quit(str); 82 | expr.setExpr(str); 83 | bool valid = expr.isValid(); 84 | std::cout << "Expression types:" << std::endl; 85 | expr.walk(); 86 | if (!valid) 87 | std::cerr << "Expression failed: " << expr.parseError() << std::endl; 88 | else if (expr.returnType().isFP() && expr.returnType().dim() <= 16) { 89 | 90 | const double* res = expr.evalFP(); 91 | for (int i = 0; i < expr.returnType().dim(); i++) { 92 | std::cerr << res[i] << " "; 93 | } 94 | std::cerr << std::endl; 95 | } else { 96 | std::cerr << "can't eval things that are not FP[<=16]" << std::endl; 97 | } 98 | } 99 | } 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /src/tests/TypePrinter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef _TypePrinter_h_ 18 | #define _TypePrinter_h_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace SeExpr2; 26 | 27 | /** 28 | @file TypePrinter.cpp 29 | */ 30 | 31 | class TypePrintExaminer : public SeExpr2::Examiner { 32 | public: 33 | virtual bool examine(const ExprNode* examinee); 34 | virtual void reset() {}; 35 | }; 36 | 37 | bool TypePrintExaminer::examine(const ExprNode* examinee) { 38 | const ExprNode* curr = examinee; 39 | int depth = 0; 40 | char buf[1024]; 41 | while (curr != 0) { 42 | depth++; 43 | curr = curr->parent(); 44 | } 45 | sprintf(buf, "%*s", depth * 2, " "); 46 | std::cout << buf << "'" << examinee->toString() << "' " << typeid(*examinee).name() 47 | << " type=" << examinee->type().toString() << std::endl; 48 | 49 | return true; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/tests/basicPython.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import absolute_import, division, unicode_literals 3 | import sys 4 | import unittest 5 | 6 | try: 7 | import SeExprPy 8 | except ImportError: 9 | sys.stderr.write( 10 | 'WARNING: SeExprPy is not importable: Python support is disabled\n') 11 | sys.exit(0) 12 | 13 | 14 | MAP_EXPR = """ 15 | # a cool expression 16 | a = 3; 17 | if (a > 5) { 18 | b = 10; 19 | } else if (a > 10) { 20 | b = 20; 21 | } 22 | c += 10 + P; 23 | 24 | # note: intentional use of different quotes 25 | map("a.png") + map('b.png') + map("c.png") 26 | """ 27 | 28 | 29 | class SeExprTestCase(unittest.TestCase): 30 | """Basic SeExpr python tests""" 31 | 32 | def test_core_namespace(self): 33 | self.assertTrue(hasattr(SeExprPy, 'core')) 34 | 35 | def test_utils_namespace(self): 36 | self.assertTrue(hasattr(SeExprPy, 'utils')) 37 | 38 | def test_AST(self, expr=MAP_EXPR): 39 | ast = SeExprPy.AST(expr) 40 | edits = SeExprPy.Edits(expr) 41 | maps = [] 42 | 43 | def collect_maps(node, childs): 44 | # check node is a call 45 | if node.type == SeExprPy.ASTType.Call: 46 | # check if the call is map 47 | if node.value == 'map': 48 | # check if the first argument is a string 49 | if childs[0].type == SeExprPy.ASTType.String: 50 | maps.append(childs[0].value) 51 | 52 | SeExprPy.traverseCallback(ast.root(), collect_maps) 53 | 54 | expect_maps = ['a.png', 'b.png', 'c.png'] 55 | self.assertEqual(expect_maps, maps) 56 | 57 | def test_AST_bytes(self): 58 | self.test_AST(expr=MAP_EXPR.encode('utf-8')) 59 | 60 | 61 | if __name__ == '__main__': 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /src/tests/dirtSimple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace SeExpr2; 26 | int main() { 27 | Expression e("1+2"); 28 | 29 | if (!e.isValid()) { 30 | throw std::runtime_error(e.parseError()); 31 | } 32 | e.debugPrintParseTree(); 33 | e.debugPrintLLVM(); 34 | const double* val = e.evalFP(); 35 | std::cout << "val is " << val[0] << std::endl; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/genImageTestFile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | 18 | import sys 19 | import os 20 | import re 21 | 22 | ################################### 23 | def printUsage(): 24 | print("Usage: genImageTestFile.py ") 25 | print(" traverse given dir for expr examples, write tests to outfile\n") 26 | print(" ex: genImageTestFile.py ./src/demos/imageSynth/examples src/tests/testSeExprExamples.cpp") 27 | sys.exit() 28 | 29 | 30 | def translate(string): 31 | """strip out invalid chars""" 32 | return string.replace('&', '').replace('.', '').replace('#', '') 33 | 34 | ################################### 35 | 36 | ### MAIN ### 37 | 38 | if len(sys.argv) < 3: 39 | printUsage() 40 | 41 | # get args 42 | rootdir = sys.argv[1] 43 | outfile = sys.argv[2] 44 | 45 | # open outfile 46 | f = open(outfile, 'w') 47 | f.write("#include \n") 48 | f.write("void evalExpressionFile(const char *filepath);\n") 49 | 50 | for dir_name, sub_dirs, se_files in os.walk(rootdir): 51 | for se_file in se_files: 52 | fullpath = os.path.join(dir_name, se_file) 53 | # use parent_dir and gparent_dir for test name to avoid duplicates 54 | (head, parent_dir) = os.path.split(dir_name) 55 | (head, gparent_dir) = os.path.split(head) 56 | (filename,ext) = os.path.splitext(se_file) 57 | filename = translate(filename) 58 | if(re.match('\.se$', ext)): 59 | f.write("TEST(" + parent_dir.lstrip('.') +'_' + gparent_dir.lstrip('.') + ", " + filename + ")") 60 | f.write("{") 61 | f.write(" evalExpressionFile(\"" + fullpath + "\");") 62 | f.write("}\n") 63 | 64 | f.close() 65 | -------------------------------------------------------------------------------- /src/tests/imageTestsReport.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # Copyright Disney Enterprises, Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License 6 | # and the following modification to it: Section 6 Trademarks. 7 | # deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the 10 | # trade names, trademarks, service marks, or product names of the 11 | # Licensor and its affiliates, except as required for reproducing 12 | # the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the License at 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | 18 | import sys 19 | import os 20 | import re 21 | import subprocess 22 | # test_case[test_name] = [v1 time, v2 time, llvm time] 23 | test_case={} 24 | 25 | # Get list of all tests to loop over 26 | 27 | fpData=open("data.csv","w") 28 | fpLog=open("data.log","w") 29 | 30 | 31 | v2=os.path.join(os.environ["RP_seexpr2"],"share/test/SeExpr2/") 32 | v1 = os.path.join(os.environ["RP_SeExpr"],"share/test/SeExpr/") 33 | #print v1 34 | filterExpr="" 35 | if len(sys.argv)==2: 36 | filterExpr=sys.argv[1] 37 | 38 | 39 | group = "" 40 | with os.popen(v2+"/testmain2 --gtest_list_tests") as pipe: 41 | for line in pipe: 42 | line = (line).strip() 43 | if(line.endswith('.')): 44 | group = line 45 | else: 46 | if filterExpr == "" or (group+line).find(filterExpr)!=-1: 47 | test_case[group+line] = [-1,-1,-1] 48 | 49 | # Execute each test case using v1, v2, v2-LLVM binaries 50 | if not v1: 51 | sys.exit() 52 | 53 | def runAndParseTest(cmd): 54 | fpLog.write("==================================================================\n") 55 | fpLog.write(cmd+"\n") 56 | fpLog.write("==================================================================\n") 57 | #print cmd 58 | process=subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,shell=True) 59 | pipe=iter(process.stdout.readline,b"") 60 | for line in pipe: 61 | fpLog.write(line) 62 | line = (line).strip() 63 | if re.search('OK', line): 64 | (prefix, time) = re.split('\(', line) 65 | return (time.strip('\)').strip('ms')) 66 | 67 | return -1 68 | 69 | idx=0 70 | N=len(test_case) 71 | for test in test_case: 72 | # test time in v 73 | test_case[test][0]=runAndParseTest(v1+"/testmain --gtest_filter="+test) 74 | test_case[test][1]=runAndParseTest("SE_EXPR_EVAL=INTERPRETER "+v2+"/testmain2 --gtest_filter="+test) 75 | test_case[test][2]=runAndParseTest("SE_EXPR_EVAL=LLVM "+v2+"/testmain2 --gtest_filter="+test) 76 | 77 | fpData.write(test+","+str(test_case[test][0])+","+str(test_case[test][1])+','+str(test_case[test][2])+"\n") 78 | idx+=1 79 | data=test_case[test] 80 | print "%5d/%5d (%10s,%10s,%10s) %s "%(idx,N,data[0],data[1],data[2],test) 81 | 82 | -------------------------------------------------------------------------------- /src/tests/llvmtest.str.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | "hihaoma" 17 | if(8==8){file = "yes";}else{file="no";} file -------------------------------------------------------------------------------- /src/tests/llvmtest.test.se: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | ;"enfade(1,2,3,4,5,6)" 1 -------------------------------------------------------------------------------- /src/tests/multiTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #include 18 | #include 19 | #include "ExprMultiExpr.h" 20 | 21 | using ::testing::ElementsAre; 22 | using namespace SeExpr2; 23 | 24 | TEST(MultiTests, ParabolaCubicE1) { 25 | Expressions ee; 26 | 27 | VariableHandle xHandle = ee.addExternalVariable("x", ExprType().FP(1).Varying()); 28 | VariableHandle vHandle = ee.addExternalVariable("v", ExprType().FP(3).Varying()); 29 | 30 | ExprHandle parabola = ee.addExpression("parabola", ExprType().FP(3).Varying(), "x*x"); 31 | ExprHandle cubic = ee.addExpression("cubic", ExprType().FP(3).Varying(), "parabola*v"); 32 | ExprHandle e1 = ee.addExpression("e1", ExprType().FP(3).Varying(), "cubic*parabola+x+1"); 33 | 34 | ASSERT_TRUE(ee.isValid()); 35 | 36 | // VariableSetHandle xSHandle = ee.getLoopVarSetHandle(xHandle); 37 | VariableSetHandle vSHandle = ee.getLoopVarSetHandle(vHandle); 38 | ExprEvalHandle Scubic = ee.getExprEvalHandle(cubic); 39 | EXPECT_EQ(Scubic.second.size(), (unsigned int)1); 40 | 41 | // ExprEvalHandle Se1 = ee.getExprEvalHandle(e1); 42 | // std::cout << "size of Se1 is " << Se1.second.size() << std::endl; 43 | 44 | ee.setVariable(xHandle, 8); 45 | 46 | double xmax = 100; 47 | double xmin = 1; 48 | double npoints = 1000; 49 | // double dx = (xmax-xmin) / (npoints-1); 50 | for (int i = 0; i < npoints; i++) { 51 | // ee.setVariable(xSHandle, i*dx+xmin); 52 | double myints[] = {2.0, 3.0, 4.0}; 53 | ee.setLoopVariable(vSHandle, myints, 3); 54 | std::vector xCubed = ee.evalFP(Scubic); 55 | EXPECT_THAT(xCubed, ElementsAre(128, 192, 256)); 56 | // EXPECT_EQ(xCubed[0], 128); 57 | // EXPECT_EQ(xCubed[1], 192); 58 | // EXPECT_EQ(xCubed[2], 256); 59 | 60 | // std::vector xe1 = ee.evalFP(Se1); 61 | // std::cout << xe1[0] << "," 62 | // << xe1[1] << "," 63 | // << xe1[2] << std::endl; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/tests/shortEdit.py: -------------------------------------------------------------------------------- 1 | from PyQt4 import QtCore, QtGui 2 | 3 | import sys, os 4 | # sys.settrace # uncomment to use gdb for debugging 5 | 6 | from SeExpr.expreditor import SeExprEdShortEdit 7 | 8 | class ShortEditWindow(QtGui.QMainWindow): 9 | 10 | def __init__(self, parent=None): 11 | QtGui.QMainWindow.__init__(self, parent) 12 | self.setObjectName("ShortEditWindow") 13 | self.setWindowTitle("Test ShortEdit Widget") 14 | 15 | mainWidget = QtGui.QWidget() 16 | mainLayout = QtGui.QVBoxLayout() 17 | mainWidget.setLayout(mainLayout) 18 | self.setCentralWidget(mainWidget) 19 | 20 | label = QtGui.QLabel("Test SeExprEdShortEdit:") 21 | expr = SeExprEdShortEdit(parent) 22 | expr.setExpressionString("$var0 = [1,0,0]; $var0"); 23 | 24 | mainLayout.addWidget(label) 25 | mainLayout.addWidget(expr) 26 | 27 | 28 | if __name__ == "__main__": 29 | app = QtGui.QApplication( sys.argv ) 30 | mainWin = ShortEditWindow() 31 | mainWin.show() 32 | sys.exit( app.exec_() ) 33 | -------------------------------------------------------------------------------- /src/tests/simpleEditor.py: -------------------------------------------------------------------------------- 1 | from PyQt4 import QtCore, QtGui 2 | 3 | from SeExpr.expreditor import SeExprEdControlCollection 4 | from SeExpr.expreditor import SeExprEditor 5 | from SeExpr.expreditor import SeExprEdBrowser 6 | 7 | class ImageEditorWindow(QtGui.QMainWindow): 8 | 9 | def __init__(self, parent=None): 10 | QtGui.QMainWindow.__init__(self, parent) 11 | self.setObjectName("ImageEditorWindow") 12 | self.setWindowTitle("Image Editor") 13 | 14 | mainWidget = QtGui.QWidget() 15 | mainLayout = QtGui.QVBoxLayout() 16 | mainWidget.setLayout(mainLayout) 17 | self.setCentralWidget(mainWidget) 18 | 19 | # Expression controls 20 | controls = SeExprEdControlCollection() 21 | scrollArea = QtGui.QScrollArea(mainWidget) 22 | scrollArea.setMinimumHeight(100) 23 | scrollArea.setFixedWidth(450) 24 | scrollArea.setWidgetResizable(True) 25 | scrollArea.setWidget(controls) 26 | 27 | # Expression editor 28 | editor = SeExprEditor(mainWidget, controls) 29 | 30 | # Expression browser 31 | browser = SeExprEdBrowser(mainWidget, editor) 32 | 33 | mainLayout.addWidget(scrollArea) 34 | mainLayout.addWidget(browser) 35 | mainLayout.addWidget(editor) 36 | 37 | 38 | 39 | if __name__ == "__main__": 40 | import sys, os 41 | app = QtGui.QApplication( sys.argv ) 42 | mainWin = ImageEditorWindow() 43 | mainWin.show() 44 | sys.exit( app.exec_() ) 45 | 46 | -------------------------------------------------------------------------------- /src/tests/testmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | using ::testing::InitGoogleTest; 23 | 24 | int main(int argc, char **argv) { 25 | int result = 0; 26 | 27 | { 28 | InitGoogleTest(&argc, argv); 29 | result = RUN_ALL_TESTS(); 30 | SeExpr2::ExprFunc::cleanup(); 31 | } 32 | return result; 33 | } 34 | -------------------------------------------------------------------------------- /src/tests/typeTests.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | #ifndef TYPETESTS_H 18 | #define TYPETESTS_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "TypeBuilder.h" 29 | #include "TypePrinter.h" 30 | 31 | using namespace SeExpr2; 32 | 33 | /** 34 | @file typeTests.h 35 | */ 36 | //! Simple expression class to check all final types of tests 37 | class TypeTesterExpr : public TypeBuilderExpr { 38 | public: 39 | typedef ExprType (*FindResultOne)(const ExprType &); 40 | typedef ExprType (*FindResultTwo)(const ExprType &, const ExprType &); 41 | typedef ExprType (*FindResultThree)(const ExprType &, const ExprType &, const ExprType &); 42 | 43 | TypePrintExaminer _examiner; 44 | SeExpr2::ConstWalker _walker; 45 | 46 | TypeTesterExpr() : TypeBuilderExpr(), _walker(&_examiner) {}; 47 | 48 | TypeTesterExpr(const std::string &e) : TypeBuilderExpr(e), _walker(&_examiner) {}; 49 | 50 | virtual ExprVarRef *resolveVar(const std::string &name) const { 51 | return TypeBuilderExpr::resolveVar(name); 52 | }; 53 | 54 | ExprFunc *resolveFunc(const std::string &name) const { 55 | return TypeBuilderExpr::resolveFunc(name); 56 | }; 57 | 58 | void doTest(const std::string &testStr, ExprType expectedResult, ExprType actualResult); 59 | 60 | void testOneVar(const std::string &testStr, 61 | // SingleWholeTypeIterator::ProcType proc); 62 | ExprType (*proc)(const ExprType &)); 63 | 64 | void testTwoVars(const std::string &testStr, 65 | // DoubleWholeTypeIterator::ProcType proc); 66 | ExprType (*proc)(const ExprType &, const ExprType &)); 67 | }; 68 | 69 | #endif // TYPETESTS_H 70 | -------------------------------------------------------------------------------- /src/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Disney Enterprises, Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License 5 | # and the following modification to it: Section 6 Trademarks. 6 | # deleted and replaced with: 7 | # 8 | # 6. Trademarks. This License does not grant permission to use the 9 | # trade names, trademarks, service marks, or product names of the 10 | # Licensor and its affiliates, except as required for reproducing 11 | # the content of the NOTICE file. 12 | # 13 | # You may obtain a copy of the License at 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/../SeExpr2) 17 | 18 | foreach(item eval listVar) 19 | add_executable("${item}" "${item}.cpp") 20 | target_link_libraries("${item}" ${SEEXPR_LIBRARIES}) 21 | install(TARGETS "${item}" DESTINATION share/SeExpr2/utils) 22 | endforeach() 23 | -------------------------------------------------------------------------------- /src/utils/eval.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License 6 | and the following modification to it: Section 6 Trademarks. 7 | deleted and replaced with: 8 | 9 | 6. Trademarks. This License does not grant permission to use the 10 | trade names, trademarks, service marks, or product names of the 11 | Licensor and its affiliates, except as required for reproducing 12 | the content of the NOTICE file. 13 | 14 | You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | using namespace SeExpr2; 26 | 27 | class Expr : public Expression { 28 | public: 29 | void walk() {} 30 | 31 | struct Var : public ExprVarRef { 32 | Var() : ExprVarRef(ExprType().Varying().FP(3)) {} 33 | double val; 34 | void eval(double* result) { 35 | for (int k = 0; k < 3; k++) result[k] = val; 36 | } 37 | void eval(const char** result) { assert(false); } 38 | }; 39 | mutable Var X; 40 | 41 | struct VarStr : public ExprVarRef { 42 | VarStr() : ExprVarRef(ExprType().Varying().String()) {} 43 | void eval(double* result) { assert(false); } 44 | 45 | void eval(const char** resultStr) { resultStr[0] = "testo"; } 46 | }; 47 | mutable VarStr s; 48 | 49 | ExprVarRef* resolveVar(const std::string& name) const { 50 | std::cerr << "trying to resolve " << name << std::endl; 51 | if (name == "X") return &X; 52 | if (name == "s") return &s; 53 | return 0; 54 | } 55 | }; 56 | 57 | int main(int argc, char* argv[]) { 58 | std::cerr << "fun fun" << std::endl; 59 | Expr expr; 60 | expr.setExpr(argv[1]); 61 | if (!expr.isValid()) { 62 | std::cerr << "parse error " << expr.parseError() << std::endl; 63 | } else { 64 | // pre eval 65 | std::cerr << "pre eval interp" << std::endl; 66 | expr.debugPrintInterpreter(); 67 | std::cerr << "starting eval interp" << std::endl; 68 | 69 | // expr._interpreter->print(); 70 | double sum = 0; 71 | // for(int i=0;i<200000000;i++){ 72 | for (int i = 0; i < 5; i++) { 73 | std::cerr << "eval iter " << i << " "; 74 | expr.X.val = (double)i; 75 | const double* d = expr.evalFP(); 76 | for (int k = 0; k < expr.returnType().dim(); k++) std::cerr << d[k] << " "; 77 | std::cerr << std::endl; 78 | sum += d[0]; 79 | } 80 | std::cerr << "sum " << sum << std::endl; 81 | expr.debugPrintInterpreter(); 82 | } 83 | 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /windows7/README: -------------------------------------------------------------------------------- 1 | Because there are some known problems with building bison / flex files 2 | on Windows, this directory contains needed files built on Linux that 3 | work with a Windows 7 / Visual Studio 2010 build. 4 | 5 | Copy the files in SeExpr\generated\* and ui\generated\* to 6 | their respective "src" sub-directories. 7 | 8 | Here is a tree listing of what's in this sub-directory: 9 | 10 | windows7/ 11 | ├── README 12 | ├── SeExpr 13 | │ └── generated 14 | │ ├── ExprParser.cpp 15 | │ ├── ExprParserLex.cpp 16 | │ └── ExprParser.tab.h 17 | └── ui 18 | └── generated 19 | ├── ExprSpecParser.cpp 20 | ├── ExprSpecParserLex.cpp 21 | └── ExprSpecParser.tab.h 22 | --------------------------------------------------------------------------------