├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE.md ├── README.md ├── compile_on_mingw64.sh ├── curvislice.bat ├── curvislice.sh ├── get_started_mingw64.sh ├── libs └── tclap │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── NEWS │ ├── README │ └── include │ └── tclap │ ├── Arg.h │ ├── ArgException.h │ ├── ArgTraits.h │ ├── CmdLine.h │ ├── CmdLineInterface.h │ ├── CmdLineOutput.h │ ├── Constraint.h │ ├── DocBookOutput.h │ ├── HelpVisitor.h │ ├── IgnoreRestVisitor.h │ ├── MultiArg.h │ ├── MultiSwitchArg.h │ ├── OptionalUnlabeledTracker.h │ ├── StandardTraits.h │ ├── StdOutput.h │ ├── SwitchArg.h │ ├── UnlabeledMultiArg.h │ ├── UnlabeledValueArg.h │ ├── ValueArg.h │ ├── ValuesConstraint.h │ ├── VersionVisitor.h │ ├── Visitor.h │ ├── XorHandler.h │ └── ZshCompletionOutput.h ├── luaGenerator.bat ├── luaGenerator.sh ├── models ├── FoilCutter.stl ├── airfoil.stl ├── anklebase_small.stl ├── car_med.stl └── wing.stl ├── pack_release.bat ├── resources ├── ankle.png ├── car.png ├── curvi │ ├── features.lua │ └── printer.lua ├── nozzle-clearance.jpg └── wing.png ├── src ├── MeshFormat_msh.cpp ├── MeshFormat_msh.h ├── TetMesh.cpp ├── TetMesh.h ├── config.h.in ├── gcode.cpp ├── gcode.h ├── helpers.h ├── main.cpp ├── thicknesses.h └── uncurve.cpp ├── toTetmesh.bat ├── toTetmesh.sh └── tools ├── icesl ├── assets │ ├── Cousine-Regular.ttf │ └── NotoSansCJKtc-Medium.ttf ├── bin │ ├── IceSL-slicer │ ├── IceSL-slicer.exe │ └── README.txt ├── icesl-libs │ ├── icesl-deprecated_64.luac │ └── icesl-stdlib_64.luac ├── icesl-printers │ └── fff │ │ └── curvi │ │ ├── features.lua │ │ └── printer.lua ├── settings_curvi.xml ├── settings_curvi_a8.xml ├── settings_curvi_delta.xml ├── settings_curvi_fig.xml ├── settings_curvi_um2.xml └── settings_curvi_um2_no_iron.xml ├── tetviz ├── .gitattributes ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── TetViz.exe ├── libs │ └── CMakeLists.txt └── src │ ├── CMakeLists.txt │ ├── TetMesh.cpp │ ├── TetMesh.h │ ├── TetViz.cpp │ ├── TetViz.h │ ├── gcode.cpp │ ├── gcode.h │ ├── shade.fp │ ├── shade.vp │ ├── slicerror.fp │ └── slicerror.vp └── tetwild-windows ├── TetWild.exe ├── libgmp-10.dll └── libmpfr-4.dll /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | build/ 3 | lib/ 4 | 5 | *.gcode 6 | *.msh 7 | *.csv 8 | 9 | models/ 10 | !models/**.stl 11 | 12 | settings.lua -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/LibSL-small"] 2 | path = libs/LibSL-small 3 | url = https://github.com/sylefeb/LibSL-small.git 4 | branch = CurviSlice 5 | [submodule "libs/SolverWrapper"] 6 | path = libs/SolverWrapper 7 | url = https://github.com/bedela-Epitech/SolverWrapper.git 8 | branch = master 9 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################### 2 | 3 | cmake_minimum_required(VERSION 2.6) 4 | project(curvislice) 5 | 6 | add_subdirectory(libs/SolverWrapper) 7 | add_subdirectory(libs/LibSL-small) 8 | 9 | INCLUDE_DIRECTORIES( 10 | ${PROJECT_SOURCE_DIR}/libs/tclap/include/ 11 | ${PROJECT_SOURCE_DIR}/libs/SolverWrapper/include/ 12 | ${PROJECT_SOURCE_DIR}/libs/SolverWrapper/src/ 13 | ${PROJECT_SOURCE_DIR}/libs/LibSL-small/src/ 14 | ${PROJECT_SOURCE_DIR}/libs/LibSL-small/src/LibSL/ 15 | ) 16 | 17 | SET(LibSL_small 18 | libs/LibSL-small/src/LibSL/System/System.cpp 19 | libs/LibSL-small/src/LibSL/CppHelpers/CppHelpers.cpp 20 | libs/LibSL-small/src/LibSL/StlHelpers/StlHelpers.cpp 21 | libs/LibSL-small/src/LibSL/Image/Image.cpp 22 | libs/LibSL-small/src/LibSL/Math/Vertex.cpp 23 | libs/LibSL-small/src/LibSL/Math/Math.cpp 24 | libs/LibSL-small/src/LibSL/Mesh/Mesh.cpp 25 | libs/LibSL-small/src/LibSL/Mesh/MeshFormat_stl.cpp 26 | libs/LibSL-small/src/LibSL/Mesh/VertexFormat_dynamic.cpp 27 | ) 28 | 29 | set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") 30 | 31 | #################################### 32 | 33 | ADD_EXECUTABLE(curvislice_osqp 34 | src/main.cpp 35 | src/gcode.h 36 | src/gcode.cpp 37 | src/helpers.h 38 | src/TetMesh.h 39 | src/TetMesh.cpp 40 | src/thicknesses.h 41 | src/MeshFormat_msh.h 42 | src/MeshFormat_msh.cpp 43 | ${LibSL_small} 44 | ) 45 | 46 | INSTALL( 47 | TARGETS curvislice_osqp 48 | RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin 49 | ) 50 | 51 | INSTALL(FILES ${CMAKE_BINARY_DIR}/libs/SolverWrapper/lib/osqp/out/libosqp.dll DESTINATION ${CMAKE_SOURCE_DIR}/bin) 52 | 53 | set_target_properties(curvislice_osqp 54 | PROPERTIES 55 | CXX_STANDARD 17 56 | CXX_EXTENSIONS OFF 57 | ) 58 | 59 | target_link_libraries(curvislice_osqp SolverWrapper) 60 | 61 | target_compile_options(curvislice_osqp PRIVATE -DOSQP) 62 | 63 | #################################### 64 | 65 | if (BUILD_WITH_GRB) 66 | ADD_EXECUTABLE(curvislice_grb 67 | src/main.cpp 68 | src/gcode.h 69 | src/gcode.cpp 70 | src/helpers.h 71 | src/TetMesh.h 72 | src/TetMesh.cpp 73 | src/thicknesses.h 74 | src/MeshFormat_msh.h 75 | src/MeshFormat_msh.cpp 76 | ) 77 | 78 | INSTALL( 79 | TARGETS curvislice_grb 80 | RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin 81 | ) 82 | 83 | set_target_properties(curvislice_grb 84 | PROPERTIES 85 | CXX_STANDARD 17 86 | CXX_EXTENSIONS OFF 87 | ) 88 | 89 | target_link_libraries(curvislice_grb SolverWrapper) 90 | 91 | target_compile_options(curvislice_grb PRIVATE -DGRB) 92 | target_compile_definitions(curvislice_grb PUBLIC "-DHAS_GUROBI") 93 | endif(BUILD_WITH_GRB) 94 | 95 | #################################### 96 | 97 | ADD_EXECUTABLE(uncurve 98 | src/uncurve.cpp 99 | src/gcode.h 100 | src/gcode.cpp 101 | src/TetMesh.h 102 | src/TetMesh.cpp 103 | src/thicknesses.h 104 | src/MeshFormat_msh.h 105 | src/MeshFormat_msh.cpp 106 | ${LibSL_small} 107 | ) 108 | 109 | INSTALL( 110 | TARGETS uncurve 111 | RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin 112 | ) 113 | 114 | set_target_properties(uncurve 115 | PROPERTIES 116 | CXX_STANDARD 17 117 | CXX_EXTENSIONS OFF 118 | ) 119 | 120 | target_link_libraries(uncurve SolverWrapper) 121 | 122 | if(BUILD_WITH_GRB) 123 | target_compile_options(uncurve PRIVATE -DGRB) 124 | else(BUILD_WITH_GRB) 125 | target_compile_options(uncurve PRIVATE -DOSQP) 126 | endif(BUILD_WITH_GRB) 127 | 128 | #################################### 129 | 130 | if(WIN32) 131 | if (BUILD_WITH_GRB) 132 | target_link_libraries(curvislice_grb shlwapi) 133 | endif(BUILD_WITH_GRB) 134 | target_link_libraries(curvislice_osqp shlwapi) 135 | target_link_libraries(uncurve shlwapi) 136 | endif(WIN32) 137 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CurviSlicer 2 | 3 | CurviSlicer is research project about achieving curved printing on standard, off-the-shelf, 3-axis FDM printers. 4 | Our goal is to improve surface quality and accuracy by curving the layers not only at the top, but also throughout the part. This reduces internal porosity and fragilities, and allows to accurately position the top curved surfaces. 5 | 6 | The image below compares adaptive slicing with flat layers (top) to the same number of layers using CurviSlicer (bottom). The adaptive slicer concentrates the thin slices around the car hood (as it should) but then it has to use thick slices everywhere else. Instead, CurviSlicer outputs curved slices that nicely follow the car outlines. These are roughly the same print time. 7 | 8 | ![](resources/car.png "Comparing flat and curved layers.") 9 | 10 | The method was developed by an international team of researchers: Jimmy Etienne, Nicolas Ray, Daniele Panozzo, Samuel Hornus, Charlie C.L. Wang, Jonàs Martínez, Sara Mcmains, Marc Alexa, Brian Wyvill and Sylvain Lefebvre ; you can [find the academic paper here](https://hal.archives-ouvertes.fr/hal-02120033/document). 11 | The work finds its origin in a brainstorm session during the 2018 Computational Geometry workshop at the Bellairs Research Institute, co-organized by Sue Whitesides and Sylvain Lazard. 12 | 13 | The implementation was done by Jimmy Etienne and Sylvain Lefebvre, with guidance from colleagues. Adrien Bedel helped greatly to modify the code to support OSQP. 14 | Please don't expect high quality, production ready code, this is a research prototype. The code depends on many other great projects such as [TetWild](https://github.com/Yixin-Hu/TetWild) and [OSQP](https://github.com/oxfordcontrol/osqp). 15 | 16 | ## Important notes 17 | 18 | > **1.** The original implementation in the paper uses the [Gurobi](https://www.gurobi.com/) commercial solver. This initial implementation is in the SIGGRAPH 2019 branch. **Please use it for reproducibility of the paper results (speed and quality)**. The master branch is modified to use OSQP and while it works great, there are differences and limitations compared to the Gurobi version. 19 | 20 | > **2.** This is a research prototype. It is not polished, and has several technical limitations and glitches. 21 | 22 | # How to use (Windows) 23 | 24 | This repository is meant to be built from source, and includes Windows binaries of some required external tools. The following described the build process using MinGW/MSYS2 for Windows. 25 | 26 | ## 1- IceSL 27 | 28 | Install the latest version of [IceSL](https://icesl.loria.fr/download/). 29 | 30 | ## 2- MinGW 31 | 32 | Install [MSYS2](https://www.msys2.org/), please make sure to follow all installation steps including the update instructions. 33 | 34 | Open a MinGW64 shell (be sure to select *64* not *32*). 35 | 36 | ## 3- Get this repository locally 37 | 38 | From the shell: 39 | 40 | ```git clone --recurse-submodules https://github.com/mfx-inria/curvislicer.git``` 41 | 42 | This will automatically download other repositories: 43 | SolverWrapper (wrapper API around Gurobi and OSQP), 44 | OSQP, LibSL-small. 45 | 46 | ## 4- Install the special printer profile 47 | 48 | Copy the folder [curvi](resources/curvi) (in the /resources folder) into the IceSL printer profiles folder ; on Windows this is **%appdata%/IceSL/icesl-printers/fff/** 49 | 50 | ## 5- Build 51 | 52 | From the MinGW64 shell, enter 53 | `./get_started_mingw64.sh` 54 | 55 | > By default, the OSQP solver version will be built. If you want to use Gurobi instead, you'll have to enable the CMake flag "BUILD_WITH_GRB" and choose the "GRB_VERSION" (and quite obviously you need to have Gurobi installed with a license). 56 | 57 | ## 6- Run 58 | 59 | From the MinGW64 shell run (parameters are optional): 60 | 61 | ```./curvislice.bat [stl_filename]``` 62 | 63 | It will automagically generate a G-code file. 64 | 65 | For example, a great starting point is to simply run 66 | 67 | ```./curvislice.bat models/wing.stl``` 68 | 69 | The GCode is then found in `models/wing.gcode` 70 | 71 | > To try with your own model, place it in `models` and run the same command line. 72 | 73 | # How to use (Linux) 74 | 75 | There is not reason this would not work under Linux, but we did not have time to make the scripts and the build system for all dependencies. Contributions are welcome! 76 | 77 | You can follow the Windows procedure, but will have to manually compile dependencies (TetWild) and create shell scripts from the Windows batch files. 78 | 79 | # Printing 80 | 81 | > **Caution, this software generates complex curved trajectories that may result in collisions between the printer carriage and the print. This could damage your printer.** 82 | 83 | The produced GCode is standard Marlin style for 1.75 mm filament and 0.4 mm nozzle. 84 | Note that it has **no header and no footer**. These you will have to add manually to fit your printer. Also please make sur the produced GCode properly fits your bed as we use an 'average' print bed configuration. 85 | 86 | In our experience the GCode prints best on delta-style printers, as the Z axis is comparably efficient to the X,Y axes. On other types of printers some adaptation of flow is required ; our tool **uncurve** has some command line parameters for this purpose, but these are mostly experimental. 87 | 88 | *We are expecting a certain clearance around the nozzle, so make sure there is space around -- basically a 45 degree cone going up from the nozzle tip on at least 5 centimeters, but larger parts may require more clearance. The angle to optimize for can be controlled from the command line.* 89 | 90 | ![](https://github.com/mfx-inria/curvislicer/blob/master/resources/nozzle-clearance.jpg "Typical space required around the nozzle.") 91 | 92 | # Slicing parameters 93 | 94 | We slice with IceSL using default parameters that may not be best for your models. 95 | You can change these parameters by opening IceSL, selecting the *curvi* printer, 96 | changing parameters and slicing any object (slicing will save the settings for next time). 97 | 98 | We encourage you to play with ironing and the type of top covers (curved covers or zigzag covers). 99 | 100 | # Integrating in another slicer 101 | 102 | CurviSlicer was developed using IceSL, however it can easily be used with different slicers. 103 | The optimizer generates a model that has to be sliced 'flat'. The model is called *after.stl* 104 | and can be found in the sub-directory having the name of your model and created during processing. 105 | 106 | However the slicer has to output a special GCode format, see *printer.lua* in the *curvi* printer profile directory (in /resources). Our tool *uncurve* also needs to know how the 3D mesh spatially relates to the trajectories produced by the slicer, as well as the layer thickness. 107 | This requires two special lines at the top, here is an example: 108 | ``` 109 | o X-10.3 Y-5.7 Z0.0 110 | t 0.2 111 | ``` 112 | Here, it means that given a trajectory point, we have to add the offset (-10.3,-5.7,0) to 113 | locate this same point in the input 3D model space. The line starting with *t* gives the slicing layer height. 114 | 115 | You are welcome to use CurviSlicer within the scope of the license (see below). Please cite our paper in your publications and the credits of your software! 116 | 117 | ``` 118 | @article{curvislicer, 119 | author = {Etienne, Jimmy and Ray, Nicolas and Panozzo, Daniele and Hornus, Samuel and Wang, Charlie C. L. and Mart\'{\i}nez, Jon\`{a}s and McMains, Sara and Alexa, Marc and Wyvill, Brian and Lefebvre, Sylvain}, 120 | title = {CurviSlicer: Slightly Curved Slicing for 3-Axis Printers}, 121 | year = {2019}, 122 | volume = {38}, 123 | number = {4}, 124 | journal = {ACM Transactions on Graphics}, 125 | articleno = {Article 81}, 126 | numpages = {11}, 127 | } 128 | ``` 129 | 130 | ### License 131 | 132 | [Affero GPL 3.0](https://www.gnu.org/licenses/agpl-3.0.en.html) 133 | -------------------------------------------------------------------------------- /compile_on_mingw64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir BUILD 4 | cd BUILD 5 | 6 | /mingw64/bin/cmake -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" .. 7 | mingw32-make install 8 | 9 | cd .. 10 | -------------------------------------------------------------------------------- /curvislice.bat: -------------------------------------------------------------------------------- 1 | REM @echo off 2 | 3 | set gurobi=0 4 | 5 | set volumic=0 6 | set nozzle=0.4 7 | set layer=0.3 8 | set filament=1.75 9 | set ironing=0 10 | set model= 11 | 12 | set arg=none 13 | 14 | for %%A in (%*) do call :Loop %%A 15 | goto :EndLoop 16 | 17 | :Loop 18 | if "%arg%" EQU "none" ( 19 | set arg=%1 20 | ) else ( 21 | set %arg%=%1 22 | set arg=none 23 | ) 24 | goto :End 25 | 26 | :EndLoop 27 | if "%arg%" EQU "none" ( 28 | echo Error in arguments 29 | exit 30 | ) 31 | 32 | set path=%arg% 33 | for %%f in ("%path%") do set model=%%~dpnf 34 | set model=%model:\=/% 35 | 36 | echo %model% 37 | 38 | echo Generate tetmesh "from %model%.stl" ... 39 | call toTetmesh.bat %model% 40 | echo Done! 41 | 42 | echo Optimize... 43 | 44 | if "%gurobi%" EQU "1" ( 45 | .\bin\curvislice_grb.exe %model%.msh -l %layer% 46 | ) else ( 47 | .\bin\curvislice_osqp.exe %model%.msh -l %layer% 48 | ) 49 | echo Done! 50 | 51 | echo Prepare lua for IceSL 52 | call luaGenerator.bat %model% %volumic% %nozzle% %layer% %filament% %ironing% 53 | 54 | if not exist %appdata%\IceSL\icesl-printers\fff\curvi ( 55 | echo Create 'curvi' printer profile for IceSL 56 | mkdir "%appdata%\IceSL\icesl-printers\fff\curvi" 57 | copy /Y resources\curvi\features.lua "%appdata%\IceSL\icesl-printers\fff\curvi\" 58 | copy /Y resources\curvi\printer.lua "%appdata%\IceSL\icesl-printers\fff\curvi\" 59 | ) 60 | 61 | set ODIR=%CD% 62 | .\tools\icesl\bin\icesl-slicer.exe settings.lua --service 63 | chdir /d %ODIR% 64 | 65 | echo Uncurve %model% 66 | .\bin\uncurve.exe -l %layer% --gcode %model% 67 | 68 | echo " 69 | echo " 70 | echo " 71 | echo " 72 | echo " ______ __ __ __ 73 | echo " / \ / | / |/ | 74 | echo "/$$$$$$ | __ __ ______ __ __ $$/ _______ $$ |$$/ _______ ______ 75 | echo "$$ | $$/ / | / | / \ / \ / |/ | / |$$ |/ | / | / \ 76 | echo "$$ | $$ | $$ |/$$$$$$ |$$ \ /$$/ $$ |/$$$$$$$/ $$ |$$ |/$$$$$$$/ /$$$$$$ | 77 | echo "$$ | __ $$ | $$ |$$ | $$/ $$ /$$/ $$ |$$ \ $$ |$$ |$$ | $$ $$ | 78 | echo "$$ \__/ |$$ \__$$ |$$ | $$ $$/ $$ | $$$$$$ |$$ |$$ |$$ \_____ $$$$$$$$/ 79 | echo "$$ $$/ $$ $$/ $$ | $$$/ $$ |/ $$/ $$ |$$ |$$ |$$ | 80 | echo " $$$$$$/ $$$$$$/ $$/ $/ $$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$$$$$$/ 81 | 82 | echo "=================================================================================== 83 | echo "==> 84 | echo " Gcode generated at: %model%.gcode 85 | echo "==> 86 | echo "=================================================================================== 87 | 88 | :End 89 | -------------------------------------------------------------------------------- /curvislice.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gurobi=0 3 | 4 | volumic=0 5 | nozzle=0.4 6 | layer=0.3 7 | filament=1.75 8 | ironing=0 9 | model= 10 | 11 | 12 | arg="none" 13 | 14 | for elem in $* 15 | do 16 | if [ $arg = "none" ] 17 | then 18 | arg=$elem 19 | else 20 | eval "$arg=$elem" 21 | arg="none" 22 | fi 23 | done 24 | 25 | if [ $arg = "none" ] 26 | then 27 | echo Error in arguments 28 | exit 29 | fi 30 | 31 | model=${arg%.*} 32 | 33 | echo Generate tetmesh "from $model.stl" ... 34 | ./toTetmesh.sh $model 35 | echo Done! 36 | 37 | echo Optimize... 38 | 39 | if [ $gurobi = "1" ] 40 | then 41 | ./bin/curvislice_grb $model.msh -l $layer 42 | else 43 | ./bin/curvislice_osqp $model.msh -l $layer 44 | fi 45 | echo Done! 46 | 47 | echo Prepare lua for IceSL 48 | ./luaGenerator.sh $model $volumic $nozzle $layer $filament $ironing 49 | 50 | if [ -e "~/.icesl/icesl-printers/fff/curvi" ] 51 | then 52 | echo "'curvi' printer profile already exist" 53 | else 54 | echo Create 'curvi' printer profile for IceSL 55 | cp -r "./resources/curvi" "~/icesl/icesl-printers/fff/curvi" 56 | fi 57 | 58 | ./tools/icesl/bin/icesl-slicer settings.lua --service 59 | 60 | ./bin/uncurve -l $layer --gcode $model 61 | 62 | clear 63 | 64 | echo ' ______ __ __ __ ' 65 | echo ' / \ / | / |/ | ' 66 | echo '/$$$$$$ | __ __ ______ __ __ $$/ _______ $$ |$$/ _______ ______ ' 67 | echo '$$ | $$/ / | / | / \ / \ / |/ | / |$$ |/ | / | / \ ' 68 | echo '$$ | $$ | $$ |/$$$$$$ |$$ \ /$$/ $$ |/$$$$$$$/ $$ |$$ |/$$$$$$$/ /$$$$$$ |' 69 | echo '$$ | __ $$ | $$ |$$ | $$/ $$ /$$/ $$ |$$ \ $$ |$$ |$$ | $$ $$ |' 70 | echo '$$ \__/ |$$ \__$$ |$$ | $$ $$/ $$ | $$$$$$ |$$ |$$ |$$ \_____ $$$$$$$$/ ' 71 | echo '$$ $$/ $$ $$/ $$ | $$$/ $$ |/ $$/ $$ |$$ |$$ |$$ |' 72 | echo ' $$$$$$/ $$$$$$/ $$/ $/ $$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$$$$$$/ ' 73 | 74 | echo '===================================================================================' 75 | echo '==>' 76 | echo " Gcode generated at: $model.gcode" 77 | echo '==>' 78 | echo '=================================================================================== -------------------------------------------------------------------------------- /get_started_mingw64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "--------------------------------------------------------------------" 3 | echo "This script installs all necessary packages and compiles" 4 | echo "Please refer to the script source code to see the list of packages" 5 | echo "--------------------------------------------------------------------" 6 | 7 | read -p "Please type 'y' to go ahead, any other key to exit: " -n 1 -r 8 | if [[ ! $REPLY =~ ^[Yy]$ ]] 9 | then 10 | echo 11 | echo "Exiting." 12 | exit 13 | fi 14 | 15 | pacman -S --noconfirm --needed git 16 | echo -e "\nInstalling compilation packages for building\n" 17 | pacman -S --noconfirm --needed wget ${MINGW_PACKAGE_PREFIX}-cmake ${MINGW_PACKAGE_PREFIX}-gcc ${MINGW_PACKAGE_PREFIX}-make 18 | 19 | ./compile_on_mingw64.sh 20 | -------------------------------------------------------------------------------- /libs/tclap/AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | original author: Michael E. Smoot 3 | invaluable contributions: Daniel Aarno 4 | more contributions: Erik Zeek 5 | more contributions: Fabien Carmagnac (Tinbergen-AM) 6 | outstanding editing: Carol Smoot 7 | -------------------------------------------------------------------------------- /libs/tclap/COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2003 Michael E. Smoot 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | 25 | 26 | -------------------------------------------------------------------------------- /libs/tclap/INSTALL: -------------------------------------------------------------------------------- 1 | Basic Installation 2 | ================== 3 | 4 | These are generic installation instructions. 5 | 6 | The `configure' shell script attempts to guess correct values for 7 | various system-dependent variables used during compilation. It uses 8 | those values to create a `Makefile' in each directory of the package. 9 | It may also create one or more `.h' files containing system-dependent 10 | definitions. Finally, it creates a shell script `config.status' that 11 | you can run in the future to recreate the current configuration, a file 12 | `config.cache' that saves the results of its tests to speed up 13 | reconfiguring, and a file `config.log' containing compiler output 14 | (useful mainly for debugging `configure'). 15 | 16 | If you need to do unusual things to compile the package, please try 17 | to figure out how `configure' could check whether to do them, and mail 18 | diffs or instructions to the address given in the `README' so they can 19 | be considered for the next release. If at some point `config.cache' 20 | contains results you don't want to keep, you may remove or edit it. 21 | 22 | The file `configure.in' is used to create `configure' by a program 23 | called `autoconf'. You only need `configure.in' if you want to change 24 | it or regenerate `configure' using a newer version of `autoconf'. 25 | 26 | The simplest way to compile this package is: 27 | 28 | 1. `cd' to the directory containing the package's source code and type 29 | `./configure' to configure the package for your system. If you're 30 | using `csh' on an old version of System V, you might need to type 31 | `sh ./configure' instead to prevent `csh' from trying to execute 32 | `configure' itself. 33 | 34 | Running `configure' takes awhile. While running, it prints some 35 | messages telling which features it is checking for. 36 | 37 | 2. Type `make' to compile the package. 38 | 39 | 3. Optionally, type `make check' to run any self-tests that come with 40 | the package. 41 | 42 | 4. Type `make install' to install the programs and any data files and 43 | documentation. 44 | 45 | 5. You can remove the program binaries and object files from the 46 | source code directory by typing `make clean'. To also remove the 47 | files that `configure' created (so you can compile the package for 48 | a different kind of computer), type `make distclean'. There is 49 | also a `make maintainer-clean' target, but that is intended mainly 50 | for the package's developers. If you use it, you may have to get 51 | all sorts of other programs in order to regenerate files that came 52 | with the distribution. 53 | 54 | Compilers and Options 55 | ===================== 56 | 57 | Some systems require unusual options for compilation or linking that 58 | the `configure' script does not know about. You can give `configure' 59 | initial values for variables by setting them in the environment. Using 60 | a Bourne-compatible shell, you can do that on the command line like 61 | this: 62 | CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure 63 | 64 | Or on systems that have the `env' program, you can do it like this: 65 | env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 66 | 67 | Compiling For Multiple Architectures 68 | ==================================== 69 | 70 | You can compile the package for more than one kind of computer at the 71 | same time, by placing the object files for each architecture in their 72 | own directory. To do this, you must use a version of `make' that 73 | supports the `VPATH' variable, such as GNU `make'. `cd' to the 74 | directory where you want the object files and executables to go and run 75 | the `configure' script. `configure' automatically checks for the 76 | source code in the directory that `configure' is in and in `..'. 77 | 78 | If you have to use a `make' that does not supports the `VPATH' 79 | variable, you have to compile the package for one architecture at a time 80 | in the source code directory. After you have installed the package for 81 | one architecture, use `make distclean' before reconfiguring for another 82 | architecture. 83 | 84 | Installation Names 85 | ================== 86 | 87 | By default, `make install' will install the package's files in 88 | `/usr/local/bin', `/usr/local/man', etc. You can specify an 89 | installation prefix other than `/usr/local' by giving `configure' the 90 | option `--prefix=PATH'. 91 | 92 | You can specify separate installation prefixes for 93 | architecture-specific files and architecture-independent files. If you 94 | give `configure' the option `--exec-prefix=PATH', the package will use 95 | PATH as the prefix for installing programs and libraries. 96 | Documentation and other data files will still use the regular prefix. 97 | 98 | In addition, if you use an unusual directory layout you can give 99 | options like `--bindir=PATH' to specify different values for particular 100 | kinds of files. Run `configure --help' for a list of the directories 101 | you can set and what kinds of files go in them. 102 | 103 | If the package supports it, you can cause programs to be installed 104 | with an extra prefix or suffix on their names by giving `configure' the 105 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 106 | 107 | Optional Features 108 | ================= 109 | 110 | Some packages pay attention to `--enable-FEATURE' options to 111 | `configure', where FEATURE indicates an optional part of the package. 112 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 113 | is something like `gnu-as' or `x' (for the X Window System). The 114 | `README' should mention any `--enable-' and `--with-' options that the 115 | package recognizes. 116 | 117 | For packages that use the X Window System, `configure' can usually 118 | find the X include and library files automatically, but if it doesn't, 119 | you can use the `configure' options `--x-includes=DIR' and 120 | `--x-libraries=DIR' to specify their locations. 121 | 122 | Specifying the System Type 123 | ========================== 124 | 125 | There may be some features `configure' can not figure out 126 | automatically, but needs to determine by the type of host the package 127 | will run on. Usually `configure' can figure that out, but if it prints 128 | a message saying it can not guess the host type, give it the 129 | `--host=TYPE' option. TYPE can either be a short name for the system 130 | type, such as `sun4', or a canonical name with three fields: 131 | CPU-COMPANY-SYSTEM 132 | 133 | See the file `config.sub' for the possible values of each field. If 134 | `config.sub' isn't included in this package, then this package doesn't 135 | need to know the host type. 136 | 137 | If you are building compiler tools for cross-compiling, you can also 138 | use the `--target=TYPE' option to select the type of system they will 139 | produce code for and the `--build=TYPE' option to select the type of 140 | system on which you are compiling the package. 141 | 142 | Sharing Defaults 143 | ================ 144 | 145 | If you want to set default values for `configure' scripts to share, 146 | you can create a site shell script called `config.site' that gives 147 | default values for variables like `CC', `cache_file', and `prefix'. 148 | `configure' looks for `PREFIX/share/config.site' if it exists, then 149 | `PREFIX/etc/config.site' if it exists. Or, you can set the 150 | `CONFIG_SITE' environment variable to the location of the site script. 151 | A warning: not all `configure' scripts look for a site script. 152 | 153 | Operation Controls 154 | ================== 155 | 156 | `configure' recognizes the following options to control how it 157 | operates. 158 | 159 | `--cache-file=FILE' 160 | Use and save the results of the tests in FILE instead of 161 | `./config.cache'. Set FILE to `/dev/null' to disable caching, for 162 | debugging `configure'. 163 | 164 | `--help' 165 | Print a summary of the options to `configure', and exit. 166 | 167 | `--quiet' 168 | `--silent' 169 | `-q' 170 | Do not print messages saying which checks are being made. To 171 | suppress all normal output, redirect it to `/dev/null' (any error 172 | messages will still be shown). 173 | 174 | `--srcdir=DIR' 175 | Look for the package's source code in directory DIR. Usually 176 | `configure' can determine that directory automatically. 177 | 178 | `--version' 179 | Print the version of Autoconf used to generate the `configure' 180 | script, and exit. 181 | 182 | `configure' also accepts some other, not widely useful, options. 183 | -------------------------------------------------------------------------------- /libs/tclap/NEWS: -------------------------------------------------------------------------------- 1 | 2 | 4/3/03 - Checked in a good sized update that move support of the library 3 | closer to that of the POSIX/GNU standards. Switches can now be combined into 4 | single arguments, -- is supported and MultiArgs now allow for multiple labeled 5 | args. I've also changed things a bit by subclassing MultiArg and ValueArg 6 | to get unlabeled versions of these classes. I think this is a bit cleaner 7 | design, despite two new classes. 8 | 9 | 1/7/04 - ... and with great trepidation, I release 0.9.6. Loads of changes. 10 | The big change is that you can now define the delimiter used to separate 11 | argument flags and argument values. So if you prefer arguments of the style 12 | "-s=asdf" instead of "-s asdf", you can do so. I've also fixed a number of 13 | warnings generated and fixed a few pathologic bugs related to combined 14 | switches. That said, I suspect that there may be a few significant bugs 15 | in this release that I haven't uncovered yet. Please let me know ASAP if 16 | you find any. 17 | 18 | 2/6/04 - Another big release: 0.9.7. First is a bugfix submitted by 19 | Matthias Stiller that specializes the _extractValue method in a couple of 20 | places that allows strings with spaces to be correctly read by tclap. A 21 | second bug found by John Ling has been fixed so that exceptions are thrown 22 | if more than one value is parsed from a single arg or if the second value 23 | parsed is invalid. A big new feature has been added that allows args to 24 | be xor'd. This means that two (or more) args can be specified such that 25 | one and only one of the args is required. If a second arg is found an 26 | exception is thrown. See the manual for details. As always, let me know 27 | if you run into any problems. 28 | 29 | 2/10/04 - A minor release: 0.9.8. A couple of bug fixes for 0.9.7 are 30 | included and a feature has been added that allows Args to be specified 31 | without short options, meaning the user is forced to use only long options. 32 | This is useful for programs with more options than map sensibly to single 33 | chars. 34 | 35 | 7/3/04 - Added a new constructor and handling to the various value args 36 | that allows the user to provide a list of values that the input arg values 37 | should be restricted to. 38 | 39 | 8/9/04 - Created a function to print the output nicely, meaning line wraps 40 | are handled somewhat sensibly now. Also changed error handling slightly. 41 | Instead of printing the entire usage, I just print a short usage. If 42 | someone really hates this, its easy to change back. Let me know if this 43 | causes problems. I think this equals release 0.9.9! 44 | 45 | 10/19/04 - A number of changes that should substantially improve the library. 46 | The most important being that we've moved the implementation of the library 47 | entirely into the header files. This means there is no longer a library to 48 | complile against, you simply have to #include . New 49 | constructors have been added to the various Arg classes that allow them to 50 | be constructed with a CmdLine reference so that you no longer need to call 51 | the add method if you prefer it that way. The output generated by the library 52 | has been confined to a few methods in the CmdLine class. This means to 53 | generate different output you can extend CmdLine and override the offending 54 | methods. A number of style changes have been made in the code base to 55 | conform better to C++ best practices. A thoughtful user has contributed 56 | project files for the building the examples Microsoft Visual Studio. See 57 | the README file in the msc directory for more details 58 | 59 | And so we have release 1.0! 60 | 61 | 10/30/04 - A few bugfixes. Now checking for include.h before including it. 62 | This will help Windows users who don't have it. Also changed test1 so that 63 | it doesn't use toupper, which apparently causes problem for non-ASCII 64 | character sets. 65 | 66 | 10/31/04 - A few more tweaks, none of which should be noticeable to people 67 | who are already using the lib without trouble. Maybe I shouldn't release 68 | things early in the morning! Also note that manual.html is now generated 69 | from manual.xml. If you have your own docbook xsl style that you prefer, 70 | then have at it. 71 | 72 | 12/3/04 - Some minor bug fixes including the removal of the two stage name 73 | lookup ifdefs which means that the software should work out of the box 74 | for gcc 3.4+. Isolated output in a separate class that should make 75 | customization of output easier. I also included a rudimentary output class 76 | that generated a (bad) Docbook command summary when used. 77 | 78 | 1/4/05 - Several bug fixes, but no new features. Fixed a bug when mandatory 79 | long args and unlabeled args were used together and weren't working properly. 80 | Now they can be used together. Fixed another bug in spacePrint where long 81 | program names caused an infinite loop. Finally, fixed a small memory leak. 82 | 83 | 1/6/05 - Fixed a bug where setting the output object for a CmdLine didn't 84 | register for version or usage generation. Doh! Created a Constraint interface 85 | that should facilitate the creation of different constraints on Args. 86 | This has involved changing the constructor interface, so if you've been using 87 | allowed lists, you'll need to make a small modification to your existing code. 88 | See examples/test6.cpp for details. 89 | 90 | 9/26/09 - Whoa, long break. Primarily a bug-fix release, but we did switch 91 | to using traits, which necessitates the minor version bump. Take a look 92 | at test11.cpp and test12.cpp for examples on using ArgTraits for extending 93 | tclap for different types. 94 | 95 | 4/16/11 - Another long break! Several minor bug and memory leak fixes. 96 | -------------------------------------------------------------------------------- /libs/tclap/README: -------------------------------------------------------------------------------- 1 | 2 | TCLAP - Templatized Command Line Argument Parser 3 | 4 | This is a simple C++ library that facilitates parsing command line 5 | arguments in a type independent manner. It doesn't conform exactly 6 | to either the GNU or POSIX standards, although it is close. See 7 | docs/manual.html for descriptions of how things work or look at the 8 | simple examples in the examples dir. 9 | 10 | To find out what the latest changes are read the NEWS file in this directory. 11 | 12 | 13 | Any and all feedback is welcome to: Mike Smoot 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/ArgException.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgException.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_ARG_EXCEPTION_H 25 | #define TCLAP_ARG_EXCEPTION_H 26 | 27 | #include 28 | #include 29 | 30 | namespace TCLAP { 31 | 32 | /** 33 | * A simple class that defines and argument exception. Should be caught 34 | * whenever a CmdLine is created and parsed. 35 | */ 36 | class ArgException : public std::exception 37 | { 38 | public: 39 | 40 | /** 41 | * Constructor. 42 | * \param text - The text of the exception. 43 | * \param id - The text identifying the argument source. 44 | * \param td - Text describing the type of ArgException it is. 45 | * of the exception. 46 | */ 47 | ArgException( const std::string& text = "undefined exception", 48 | const std::string& id = "undefined", 49 | const std::string& td = "Generic ArgException") 50 | : std::exception(), 51 | _errorText(text), 52 | _argId( id ), 53 | _typeDescription(td) 54 | { } 55 | 56 | /** 57 | * Destructor. 58 | */ 59 | virtual ~ArgException() throw() { } 60 | 61 | /** 62 | * Returns the error text. 63 | */ 64 | std::string error() const { return ( _errorText ); } 65 | 66 | /** 67 | * Returns the argument id. 68 | */ 69 | std::string argId() const 70 | { 71 | if ( _argId == "undefined" ) 72 | return " "; 73 | else 74 | return ( "Argument: " + _argId ); 75 | } 76 | 77 | /** 78 | * Returns the arg id and error text. 79 | */ 80 | const char* what() const throw() 81 | { 82 | static std::string ex; 83 | ex = _argId + " -- " + _errorText; 84 | return ex.c_str(); 85 | } 86 | 87 | /** 88 | * Returns the type of the exception. Used to explain and distinguish 89 | * between different child exceptions. 90 | */ 91 | std::string typeDescription() const 92 | { 93 | return _typeDescription; 94 | } 95 | 96 | 97 | private: 98 | 99 | /** 100 | * The text of the exception message. 101 | */ 102 | std::string _errorText; 103 | 104 | /** 105 | * The argument related to this exception. 106 | */ 107 | std::string _argId; 108 | 109 | /** 110 | * Describes the type of the exception. Used to distinguish 111 | * between different child exceptions. 112 | */ 113 | std::string _typeDescription; 114 | 115 | }; 116 | 117 | /** 118 | * Thrown from within the child Arg classes when it fails to properly 119 | * parse the argument it has been passed. 120 | */ 121 | class ArgParseException : public ArgException 122 | { 123 | public: 124 | /** 125 | * Constructor. 126 | * \param text - The text of the exception. 127 | * \param id - The text identifying the argument source 128 | * of the exception. 129 | */ 130 | ArgParseException( const std::string& text = "undefined exception", 131 | const std::string& id = "undefined" ) 132 | : ArgException( text, 133 | id, 134 | std::string( "Exception found while parsing " ) + 135 | std::string( "the value the Arg has been passed." )) 136 | { } 137 | }; 138 | 139 | /** 140 | * Thrown from CmdLine when the arguments on the command line are not 141 | * properly specified, e.g. too many arguments, required argument missing, etc. 142 | */ 143 | class CmdLineParseException : public ArgException 144 | { 145 | public: 146 | /** 147 | * Constructor. 148 | * \param text - The text of the exception. 149 | * \param id - The text identifying the argument source 150 | * of the exception. 151 | */ 152 | CmdLineParseException( const std::string& text = "undefined exception", 153 | const std::string& id = "undefined" ) 154 | : ArgException( text, 155 | id, 156 | std::string( "Exception found when the values ") + 157 | std::string( "on the command line do not meet ") + 158 | std::string( "the requirements of the defined ") + 159 | std::string( "Args." )) 160 | { } 161 | }; 162 | 163 | /** 164 | * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g. 165 | * same flag as another Arg, same name, etc. 166 | */ 167 | class SpecificationException : public ArgException 168 | { 169 | public: 170 | /** 171 | * Constructor. 172 | * \param text - The text of the exception. 173 | * \param id - The text identifying the argument source 174 | * of the exception. 175 | */ 176 | SpecificationException( const std::string& text = "undefined exception", 177 | const std::string& id = "undefined" ) 178 | : ArgException( text, 179 | id, 180 | std::string("Exception found when an Arg object ")+ 181 | std::string("is improperly defined by the ") + 182 | std::string("developer." )) 183 | { } 184 | 185 | }; 186 | 187 | class ExitException { 188 | public: 189 | ExitException(int estat) : _estat(estat) {} 190 | 191 | int getExitStatus() const { return _estat; } 192 | 193 | private: 194 | int _estat; 195 | }; 196 | 197 | } // namespace TCLAP 198 | 199 | #endif 200 | 201 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/ArgTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_ARGTRAITS_H 27 | #define TCLAP_ARGTRAITS_H 28 | 29 | namespace TCLAP { 30 | 31 | // We use two empty structs to get compile type specialization 32 | // function to work 33 | 34 | /** 35 | * A value like argument value type is a value that can be set using 36 | * operator>>. This is the default value type. 37 | */ 38 | struct ValueLike { 39 | typedef ValueLike ValueCategory; 40 | virtual ~ValueLike() {} 41 | }; 42 | 43 | /** 44 | * A string like argument value type is a value that can be set using 45 | * operator=(string). Usefull if the value type contains spaces which 46 | * will be broken up into individual tokens by operator>>. 47 | */ 48 | struct StringLike { 49 | virtual ~StringLike() {} 50 | }; 51 | 52 | /** 53 | * A class can inherit from this object to make it have string like 54 | * traits. This is a compile time thing and does not add any overhead 55 | * to the inherenting class. 56 | */ 57 | struct StringLikeTrait { 58 | typedef StringLike ValueCategory; 59 | virtual ~StringLikeTrait() {} 60 | }; 61 | 62 | /** 63 | * A class can inherit from this object to make it have value like 64 | * traits. This is a compile time thing and does not add any overhead 65 | * to the inherenting class. 66 | */ 67 | struct ValueLikeTrait { 68 | typedef ValueLike ValueCategory; 69 | virtual ~ValueLikeTrait() {} 70 | }; 71 | 72 | /** 73 | * Arg traits are used to get compile type specialization when parsing 74 | * argument values. Using an ArgTraits you can specify the way that 75 | * values gets assigned to any particular type during parsing. The two 76 | * supported types are StringLike and ValueLike. 77 | */ 78 | template 79 | struct ArgTraits { 80 | typedef typename T::ValueCategory ValueCategory; 81 | virtual ~ArgTraits() {} 82 | //typedef ValueLike ValueCategory; 83 | }; 84 | 85 | #endif 86 | 87 | } // namespace 88 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/CmdLineInterface.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: CmdLineInterface.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_COMMANDLINE_INTERFACE_H 24 | #define TCLAP_COMMANDLINE_INTERFACE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | namespace TCLAP { 34 | 35 | class Arg; 36 | class CmdLineOutput; 37 | class XorHandler; 38 | 39 | /** 40 | * The base class that manages the command line definition and passes 41 | * along the parsing to the appropriate Arg classes. 42 | */ 43 | class CmdLineInterface 44 | { 45 | public: 46 | 47 | /** 48 | * Destructor 49 | */ 50 | virtual ~CmdLineInterface() {} 51 | 52 | /** 53 | * Adds an argument to the list of arguments to be parsed. 54 | * \param a - Argument to be added. 55 | */ 56 | virtual void add( Arg& a )=0; 57 | 58 | /** 59 | * An alternative add. Functionally identical. 60 | * \param a - Argument to be added. 61 | */ 62 | virtual void add( Arg* a )=0; 63 | 64 | /** 65 | * Add two Args that will be xor'd. 66 | * If this method is used, add does 67 | * not need to be called. 68 | * \param a - Argument to be added and xor'd. 69 | * \param b - Argument to be added and xor'd. 70 | */ 71 | virtual void xorAdd( Arg& a, Arg& b )=0; 72 | 73 | /** 74 | * Add a list of Args that will be xor'd. If this method is used, 75 | * add does not need to be called. 76 | * \param xors - List of Args to be added and xor'd. 77 | */ 78 | virtual void xorAdd( std::vector& xors )=0; 79 | 80 | /** 81 | * Parses the command line. 82 | * \param argc - Number of arguments. 83 | * \param argv - Array of arguments. 84 | */ 85 | virtual void parse(int argc, const char * const * argv)=0; 86 | 87 | /** 88 | * Parses the command line. 89 | * \param args - A vector of strings representing the args. 90 | * args[0] is still the program name. 91 | */ 92 | void parse(std::vector& args); 93 | 94 | /** 95 | * Returns the CmdLineOutput object. 96 | */ 97 | virtual CmdLineOutput* getOutput()=0; 98 | 99 | /** 100 | * \param co - CmdLineOutput object that we want to use instead. 101 | */ 102 | virtual void setOutput(CmdLineOutput* co)=0; 103 | 104 | /** 105 | * Returns the version string. 106 | */ 107 | virtual std::string& getVersion()=0; 108 | 109 | /** 110 | * Returns the program name string. 111 | */ 112 | virtual std::string& getProgramName()=0; 113 | 114 | /** 115 | * Returns the argList. 116 | */ 117 | virtual std::list& getArgList()=0; 118 | 119 | /** 120 | * Returns the XorHandler. 121 | */ 122 | virtual XorHandler& getXorHandler()=0; 123 | 124 | /** 125 | * Returns the delimiter string. 126 | */ 127 | virtual char getDelimiter()=0; 128 | 129 | /** 130 | * Returns the message string. 131 | */ 132 | virtual std::string& getMessage()=0; 133 | 134 | /** 135 | * Indicates whether or not the help and version switches were created 136 | * automatically. 137 | */ 138 | virtual bool hasHelpAndVersion()=0; 139 | 140 | /** 141 | * Resets the instance as if it had just been constructed so that the 142 | * instance can be reused. 143 | */ 144 | virtual void reset()=0; 145 | }; 146 | 147 | } //namespace 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/CmdLineOutput.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: CmdLineOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_CMDLINEOUTPUT_H 24 | #define TCLAP_CMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | class CmdLineInterface; 36 | class ArgException; 37 | 38 | /** 39 | * The interface that any output object must implement. 40 | */ 41 | class CmdLineOutput 42 | { 43 | 44 | public: 45 | 46 | /** 47 | * Virtual destructor. 48 | */ 49 | virtual ~CmdLineOutput() {} 50 | 51 | /** 52 | * Generates some sort of output for the USAGE. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c)=0; 56 | 57 | /** 58 | * Generates some sort of output for the version. 59 | * \param c - The CmdLine object the output is generated for. 60 | */ 61 | virtual void version(CmdLineInterface& c)=0; 62 | 63 | /** 64 | * Generates some sort of output for a failure. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure( CmdLineInterface& c, 69 | ArgException& e )=0; 70 | 71 | }; 72 | 73 | } //namespace TCLAP 74 | #endif 75 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/Constraint.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Constraint.h 5 | * 6 | * Copyright (c) 2005, Michael E. Smoot 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_CONSTRAINT_H 23 | #define TCLAP_CONSTRAINT_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * The interface that defines the interaction between the Arg and Constraint. 36 | */ 37 | template 38 | class Constraint 39 | { 40 | 41 | public: 42 | /** 43 | * Returns a description of the Constraint. 44 | */ 45 | virtual std::string description() const =0; 46 | 47 | /** 48 | * Returns the short ID for the Constraint. 49 | */ 50 | virtual std::string shortID() const =0; 51 | 52 | /** 53 | * The method used to verify that the value parsed from the command 54 | * line meets the constraint. 55 | * \param value - The value that will be checked. 56 | */ 57 | virtual bool check(const T& value) const =0; 58 | 59 | /** 60 | * Destructor. 61 | * Silences warnings about Constraint being a base class with virtual 62 | * functions but without a virtual destructor. 63 | */ 64 | virtual ~Constraint() { ; } 65 | }; 66 | 67 | } //namespace TCLAP 68 | #endif 69 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/DocBookOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: DocBookOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_DOCBOOKOUTPUT_H 24 | #define TCLAP_DOCBOOKOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that generates DocBook output for usage() method for the 41 | * given CmdLine and its Args. 42 | */ 43 | class DocBookOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | /** 49 | * Prints the usage to stdout. Can be overridden to 50 | * produce alternative behavior. 51 | * \param c - The CmdLine object the output is generated for. 52 | */ 53 | virtual void usage(CmdLineInterface& c); 54 | 55 | /** 56 | * Prints the version to stdout. Can be overridden 57 | * to produce alternative behavior. 58 | * \param c - The CmdLine object the output is generated for. 59 | */ 60 | virtual void version(CmdLineInterface& c); 61 | 62 | /** 63 | * Prints (to stderr) an error message, short usage 64 | * Can be overridden to produce alternative behavior. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure(CmdLineInterface& c, 69 | ArgException& e ); 70 | 71 | protected: 72 | 73 | /** 74 | * Substitutes the char r for string x in string s. 75 | * \param s - The string to operate on. 76 | * \param r - The char to replace. 77 | * \param x - What to replace r with. 78 | */ 79 | void substituteSpecialChars( std::string& s, char r, std::string& x ); 80 | void removeChar( std::string& s, char r); 81 | void basename( std::string& s ); 82 | 83 | void printShortArg(Arg* it); 84 | void printLongArg(Arg* it); 85 | 86 | char theDelimiter; 87 | }; 88 | 89 | 90 | inline void DocBookOutput::version(CmdLineInterface& _cmd) 91 | { 92 | std::cout << _cmd.getVersion() << std::endl; 93 | } 94 | 95 | inline void DocBookOutput::usage(CmdLineInterface& _cmd ) 96 | { 97 | std::list argList = _cmd.getArgList(); 98 | std::string progName = _cmd.getProgramName(); 99 | std::string xversion = _cmd.getVersion(); 100 | theDelimiter = _cmd.getDelimiter(); 101 | XorHandler xorHandler = _cmd.getXorHandler(); 102 | std::vector< std::vector > xorList = xorHandler.getXorList(); 103 | basename(progName); 104 | 105 | std::cout << "" << std::endl; 106 | std::cout << "" << std::endl << std::endl; 108 | 109 | std::cout << "" << std::endl; 110 | 111 | std::cout << "" << std::endl; 112 | std::cout << "" << progName << "" << std::endl; 113 | std::cout << "1" << std::endl; 114 | std::cout << "" << std::endl; 115 | 116 | std::cout << "" << std::endl; 117 | std::cout << "" << progName << "" << std::endl; 118 | std::cout << "" << _cmd.getMessage() << "" << std::endl; 119 | std::cout << "" << std::endl; 120 | 121 | std::cout << "" << std::endl; 122 | std::cout << "" << std::endl; 123 | 124 | std::cout << "" << progName << "" << std::endl; 125 | 126 | // xor 127 | for ( int i = 0; (unsigned int)i < xorList.size(); i++ ) 128 | { 129 | std::cout << "" << std::endl; 130 | for ( ArgVectorIterator it = xorList[i].begin(); 131 | it != xorList[i].end(); it++ ) 132 | printShortArg((*it)); 133 | 134 | std::cout << "" << std::endl; 135 | } 136 | 137 | // rest of args 138 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 139 | if ( !xorHandler.contains( (*it) ) ) 140 | printShortArg((*it)); 141 | 142 | std::cout << "" << std::endl; 143 | std::cout << "" << std::endl; 144 | 145 | std::cout << "" << std::endl; 146 | std::cout << "Description" << std::endl; 147 | std::cout << "" << std::endl; 148 | std::cout << _cmd.getMessage() << std::endl; 149 | std::cout << "" << std::endl; 150 | std::cout << "" << std::endl; 151 | 152 | std::cout << "" << std::endl; 153 | std::cout << "Options" << std::endl; 154 | 155 | std::cout << "" << std::endl; 156 | 157 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 158 | printLongArg((*it)); 159 | 160 | std::cout << "" << std::endl; 161 | std::cout << "" << std::endl; 162 | 163 | std::cout << "" << std::endl; 164 | std::cout << "Version" << std::endl; 165 | std::cout << "" << std::endl; 166 | std::cout << xversion << std::endl; 167 | std::cout << "" << std::endl; 168 | std::cout << "" << std::endl; 169 | 170 | std::cout << "" << std::endl; 171 | 172 | } 173 | 174 | inline void DocBookOutput::failure( CmdLineInterface& _cmd, 175 | ArgException& e ) 176 | { 177 | static_cast(_cmd); // unused 178 | std::cout << e.what() << std::endl; 179 | throw ExitException(1); 180 | } 181 | 182 | inline void DocBookOutput::substituteSpecialChars( std::string& s, 183 | char r, 184 | std::string& x ) 185 | { 186 | size_t p; 187 | while ( (p = s.find_first_of(r)) != std::string::npos ) 188 | { 189 | s.erase(p,1); 190 | s.insert(p,x); 191 | } 192 | } 193 | 194 | inline void DocBookOutput::removeChar( std::string& s, char r) 195 | { 196 | size_t p; 197 | while ( (p = s.find_first_of(r)) != std::string::npos ) 198 | { 199 | s.erase(p,1); 200 | } 201 | } 202 | 203 | inline void DocBookOutput::basename( std::string& s ) 204 | { 205 | size_t p = s.find_last_of('/'); 206 | if ( p != std::string::npos ) 207 | { 208 | s.erase(0, p + 1); 209 | } 210 | } 211 | 212 | inline void DocBookOutput::printShortArg(Arg* a) 213 | { 214 | std::string lt = "<"; 215 | std::string gt = ">"; 216 | 217 | std::string id = a->shortID(); 218 | substituteSpecialChars(id,'<',lt); 219 | substituteSpecialChars(id,'>',gt); 220 | removeChar(id,'['); 221 | removeChar(id,']'); 222 | 223 | std::string choice = "opt"; 224 | if ( a->isRequired() ) 225 | choice = "plain"; 226 | 227 | std::cout << "acceptsMultipleValues() ) 229 | std::cout << " rep='repeat'"; 230 | 231 | 232 | std::cout << '>'; 233 | if ( !a->getFlag().empty() ) 234 | std::cout << a->flagStartChar() << a->getFlag(); 235 | else 236 | std::cout << a->nameStartString() << a->getName(); 237 | if ( a->isValueRequired() ) 238 | { 239 | std::string arg = a->shortID(); 240 | removeChar(arg,'['); 241 | removeChar(arg,']'); 242 | removeChar(arg,'<'); 243 | removeChar(arg,'>'); 244 | arg.erase(0, arg.find_last_of(theDelimiter) + 1); 245 | std::cout << theDelimiter; 246 | std::cout << "" << arg << ""; 247 | } 248 | std::cout << "" << std::endl; 249 | 250 | } 251 | 252 | inline void DocBookOutput::printLongArg(Arg* a) 253 | { 254 | std::string lt = "<"; 255 | std::string gt = ">"; 256 | 257 | std::string desc = a->getDescription(); 258 | substituteSpecialChars(desc,'<',lt); 259 | substituteSpecialChars(desc,'>',gt); 260 | 261 | std::cout << "" << std::endl; 262 | 263 | if ( !a->getFlag().empty() ) 264 | { 265 | std::cout << "" << std::endl; 266 | std::cout << "" << std::endl; 269 | std::cout << "" << std::endl; 270 | } 271 | 272 | std::cout << "" << std::endl; 273 | std::cout << "" << std::endl; 287 | std::cout << "" << std::endl; 288 | 289 | std::cout << "" << std::endl; 290 | std::cout << "" << std::endl; 291 | std::cout << desc << std::endl; 292 | std::cout << "" << std::endl; 293 | std::cout << "" << std::endl; 294 | 295 | std::cout << "" << std::endl; 296 | } 297 | 298 | } //namespace TCLAP 299 | #endif 300 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/HelpVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: HelpVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_HELP_VISITOR_H 23 | #define TCLAP_HELP_VISITOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor object that calls the usage method of the given CmdLineOutput 33 | * object for the specified CmdLine object. 34 | */ 35 | class HelpVisitor: public Visitor 36 | { 37 | private: 38 | /** 39 | * Prevent accidental copying. 40 | */ 41 | HelpVisitor(const HelpVisitor& rhs); 42 | HelpVisitor& operator=(const HelpVisitor& rhs); 43 | 44 | protected: 45 | 46 | /** 47 | * The CmdLine the output will be generated for. 48 | */ 49 | CmdLineInterface* _cmd; 50 | 51 | /** 52 | * The output object. 53 | */ 54 | CmdLineOutput** _out; 55 | 56 | public: 57 | 58 | /** 59 | * Constructor. 60 | * \param cmd - The CmdLine the output will be generated for. 61 | * \param out - The type of output. 62 | */ 63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) 64 | : Visitor(), _cmd( cmd ), _out( out ) { } 65 | 66 | /** 67 | * Calls the usage method of the CmdLineOutput for the 68 | * specified CmdLine. 69 | */ 70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } 71 | 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: IgnoreRestVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 24 | #define TCLAP_IGNORE_REST_VISITOR_H 25 | 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Vistor that tells the CmdLine to begin ignoring arguments after 33 | * this one is parsed. 34 | */ 35 | class IgnoreRestVisitor: public Visitor 36 | { 37 | public: 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | IgnoreRestVisitor() : Visitor() {} 43 | 44 | /** 45 | * Sets Arg::_ignoreRest. 46 | */ 47 | void visit() { Arg::beginIgnoring(); } 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/MultiArg.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * file: MultiArg.h 4 | * 5 | * Copyright (c) 2003, Michael E. Smoot . 6 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_MULTIPLE_ARGUMENT_H 24 | #define TCLAP_MULTIPLE_ARGUMENT_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | /** 34 | * An argument that allows multiple values of type T to be specified. Very 35 | * similar to a ValueArg, except a vector of values will be returned 36 | * instead of just one. 37 | */ 38 | template 39 | class MultiArg : public Arg 40 | { 41 | public: 42 | typedef std::vector container_type; 43 | typedef typename container_type::iterator iterator; 44 | typedef typename container_type::const_iterator const_iterator; 45 | 46 | protected: 47 | 48 | /** 49 | * The list of values parsed from the CmdLine. 50 | */ 51 | std::vector _values; 52 | 53 | /** 54 | * The description of type T to be used in the usage. 55 | */ 56 | std::string _typeDesc; 57 | 58 | /** 59 | * A list of constraint on this Arg. 60 | */ 61 | Constraint* _constraint; 62 | 63 | /** 64 | * Extracts the value from the string. 65 | * Attempts to parse string as type T, if this fails an exception 66 | * is thrown. 67 | * \param val - The string to be read. 68 | */ 69 | void _extractValue( const std::string& val ); 70 | 71 | /** 72 | * Used by XorHandler to decide whether to keep parsing for this arg. 73 | */ 74 | bool _allowMore; 75 | 76 | public: 77 | 78 | /** 79 | * Constructor. 80 | * \param flag - The one character flag that identifies this 81 | * argument on the command line. 82 | * \param name - A one word name for the argument. Can be 83 | * used as a long flag on the command line. 84 | * \param desc - A description of what the argument is for or 85 | * does. 86 | * \param req - Whether the argument is required on the command 87 | * line. 88 | * \param typeDesc - A short, human readable description of the 89 | * type that this object expects. This is used in the generation 90 | * of the USAGE statement. The goal is to be helpful to the end user 91 | * of the program. 92 | * \param v - An optional visitor. You probably should not 93 | * use this unless you have a very good reason. 94 | */ 95 | MultiArg( const std::string& flag, 96 | const std::string& name, 97 | const std::string& desc, 98 | bool req, 99 | const std::string& typeDesc, 100 | Visitor* v = NULL); 101 | 102 | /** 103 | * Constructor. 104 | * \param flag - The one character flag that identifies this 105 | * argument on the command line. 106 | * \param name - A one word name for the argument. Can be 107 | * used as a long flag on the command line. 108 | * \param desc - A description of what the argument is for or 109 | * does. 110 | * \param req - Whether the argument is required on the command 111 | * line. 112 | * \param typeDesc - A short, human readable description of the 113 | * type that this object expects. This is used in the generation 114 | * of the USAGE statement. The goal is to be helpful to the end user 115 | * of the program. 116 | * \param parser - A CmdLine parser object to add this Arg to 117 | * \param v - An optional visitor. You probably should not 118 | * use this unless you have a very good reason. 119 | */ 120 | MultiArg( const std::string& flag, 121 | const std::string& name, 122 | const std::string& desc, 123 | bool req, 124 | const std::string& typeDesc, 125 | CmdLineInterface& parser, 126 | Visitor* v = NULL ); 127 | 128 | /** 129 | * Constructor. 130 | * \param flag - The one character flag that identifies this 131 | * argument on the command line. 132 | * \param name - A one word name for the argument. Can be 133 | * used as a long flag on the command line. 134 | * \param desc - A description of what the argument is for or 135 | * does. 136 | * \param req - Whether the argument is required on the command 137 | * line. 138 | * \param constraint - A pointer to a Constraint object used 139 | * to constrain this Arg. 140 | * \param v - An optional visitor. You probably should not 141 | * use this unless you have a very good reason. 142 | */ 143 | MultiArg( const std::string& flag, 144 | const std::string& name, 145 | const std::string& desc, 146 | bool req, 147 | Constraint* constraint, 148 | Visitor* v = NULL ); 149 | 150 | /** 151 | * Constructor. 152 | * \param flag - The one character flag that identifies this 153 | * argument on the command line. 154 | * \param name - A one word name for the argument. Can be 155 | * used as a long flag on the command line. 156 | * \param desc - A description of what the argument is for or 157 | * does. 158 | * \param req - Whether the argument is required on the command 159 | * line. 160 | * \param constraint - A pointer to a Constraint object used 161 | * to constrain this Arg. 162 | * \param parser - A CmdLine parser object to add this Arg to 163 | * \param v - An optional visitor. You probably should not 164 | * use this unless you have a very good reason. 165 | */ 166 | MultiArg( const std::string& flag, 167 | const std::string& name, 168 | const std::string& desc, 169 | bool req, 170 | Constraint* constraint, 171 | CmdLineInterface& parser, 172 | Visitor* v = NULL ); 173 | 174 | /** 175 | * Handles the processing of the argument. 176 | * This re-implements the Arg version of this method to set the 177 | * _value of the argument appropriately. It knows the difference 178 | * between labeled and unlabeled. 179 | * \param i - Pointer the the current argument in the list. 180 | * \param args - Mutable list of strings. Passed from main(). 181 | */ 182 | virtual bool processArg(int* i, std::vector& args); 183 | 184 | /** 185 | * Returns a vector of type T containing the values parsed from 186 | * the command line. 187 | */ 188 | const std::vector& getValue(); 189 | 190 | /** 191 | * Returns an iterator over the values parsed from the command 192 | * line. 193 | */ 194 | const_iterator begin() const { return _values.begin(); } 195 | 196 | /** 197 | * Returns the end of the values parsed from the command 198 | * line. 199 | */ 200 | const_iterator end() const { return _values.end(); } 201 | 202 | /** 203 | * Returns the a short id string. Used in the usage. 204 | * \param val - value to be used. 205 | */ 206 | virtual std::string shortID(const std::string& val="val") const; 207 | 208 | /** 209 | * Returns the a long id string. Used in the usage. 210 | * \param val - value to be used. 211 | */ 212 | virtual std::string longID(const std::string& val="val") const; 213 | 214 | /** 215 | * Once we've matched the first value, then the arg is no longer 216 | * required. 217 | */ 218 | virtual bool isRequired() const; 219 | 220 | virtual bool allowMore(); 221 | 222 | virtual void reset(); 223 | 224 | private: 225 | /** 226 | * Prevent accidental copying 227 | */ 228 | MultiArg(const MultiArg& rhs); 229 | MultiArg& operator=(const MultiArg& rhs); 230 | 231 | }; 232 | 233 | template 234 | MultiArg::MultiArg(const std::string& flag, 235 | const std::string& name, 236 | const std::string& desc, 237 | bool req, 238 | const std::string& typeDesc, 239 | Visitor* v) : 240 | Arg( flag, name, desc, req, true, v ), 241 | _values(std::vector()), 242 | _typeDesc( typeDesc ), 243 | _constraint( NULL ), 244 | _allowMore(false) 245 | { 246 | _acceptsMultipleValues = true; 247 | } 248 | 249 | template 250 | MultiArg::MultiArg(const std::string& flag, 251 | const std::string& name, 252 | const std::string& desc, 253 | bool req, 254 | const std::string& typeDesc, 255 | CmdLineInterface& parser, 256 | Visitor* v) 257 | : Arg( flag, name, desc, req, true, v ), 258 | _values(std::vector()), 259 | _typeDesc( typeDesc ), 260 | _constraint( NULL ), 261 | _allowMore(false) 262 | { 263 | parser.add( this ); 264 | _acceptsMultipleValues = true; 265 | } 266 | 267 | /** 268 | * 269 | */ 270 | template 271 | MultiArg::MultiArg(const std::string& flag, 272 | const std::string& name, 273 | const std::string& desc, 274 | bool req, 275 | Constraint* constraint, 276 | Visitor* v) 277 | : Arg( flag, name, desc, req, true, v ), 278 | _values(std::vector()), 279 | _typeDesc( constraint->shortID() ), 280 | _constraint( constraint ), 281 | _allowMore(false) 282 | { 283 | _acceptsMultipleValues = true; 284 | } 285 | 286 | template 287 | MultiArg::MultiArg(const std::string& flag, 288 | const std::string& name, 289 | const std::string& desc, 290 | bool req, 291 | Constraint* constraint, 292 | CmdLineInterface& parser, 293 | Visitor* v) 294 | : Arg( flag, name, desc, req, true, v ), 295 | _values(std::vector()), 296 | _typeDesc( constraint->shortID() ), 297 | _constraint( constraint ), 298 | _allowMore(false) 299 | { 300 | parser.add( this ); 301 | _acceptsMultipleValues = true; 302 | } 303 | 304 | template 305 | const std::vector& MultiArg::getValue() { return _values; } 306 | 307 | template 308 | bool MultiArg::processArg(int *i, std::vector& args) 309 | { 310 | if ( _ignoreable && Arg::ignoreRest() ) 311 | return false; 312 | 313 | if ( _hasBlanks( args[*i] ) ) 314 | return false; 315 | 316 | std::string flag = args[*i]; 317 | std::string value = ""; 318 | 319 | trimFlag( flag, value ); 320 | 321 | if ( argMatches( flag ) ) 322 | { 323 | if ( Arg::delimiter() != ' ' && value == "" ) 324 | throw( ArgParseException( 325 | "Couldn't find delimiter for this argument!", 326 | toString() ) ); 327 | 328 | // always take the first one, regardless of start string 329 | if ( value == "" ) 330 | { 331 | (*i)++; 332 | if ( static_cast(*i) < args.size() ) 333 | _extractValue( args[*i] ); 334 | else 335 | throw( ArgParseException("Missing a value for this argument!", 336 | toString() ) ); 337 | } 338 | else 339 | _extractValue( value ); 340 | 341 | /* 342 | // continuing taking the args until we hit one with a start string 343 | while ( (unsigned int)(*i)+1 < args.size() && 344 | args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && 345 | args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) 346 | _extractValue( args[++(*i)] ); 347 | */ 348 | 349 | _alreadySet = true; 350 | _checkWithVisitor(); 351 | 352 | return true; 353 | } 354 | else 355 | return false; 356 | } 357 | 358 | /** 359 | * 360 | */ 361 | template 362 | std::string MultiArg::shortID(const std::string& val) const 363 | { 364 | static_cast(val); // Ignore input, don't warn 365 | return Arg::shortID(_typeDesc) + " ... "; 366 | } 367 | 368 | /** 369 | * 370 | */ 371 | template 372 | std::string MultiArg::longID(const std::string& val) const 373 | { 374 | static_cast(val); // Ignore input, don't warn 375 | return Arg::longID(_typeDesc) + " (accepted multiple times)"; 376 | } 377 | 378 | /** 379 | * Once we've matched the first value, then the arg is no longer 380 | * required. 381 | */ 382 | template 383 | bool MultiArg::isRequired() const 384 | { 385 | if ( _required ) 386 | { 387 | if ( _values.size() > 1 ) 388 | return false; 389 | else 390 | return true; 391 | } 392 | else 393 | return false; 394 | 395 | } 396 | 397 | template 398 | void MultiArg::_extractValue( const std::string& val ) 399 | { 400 | try { 401 | T tmp; 402 | ExtractValue(tmp, val, typename ArgTraits::ValueCategory()); 403 | _values.push_back(tmp); 404 | } catch( ArgParseException &e) { 405 | throw ArgParseException(e.error(), toString()); 406 | } 407 | 408 | if ( _constraint != NULL ) 409 | if ( ! _constraint->check( _values.back() ) ) 410 | throw( CmdLineParseException( "Value '" + val + 411 | "' does not meet constraint: " + 412 | _constraint->description(), 413 | toString() ) ); 414 | } 415 | 416 | template 417 | bool MultiArg::allowMore() 418 | { 419 | bool am = _allowMore; 420 | _allowMore = true; 421 | return am; 422 | } 423 | 424 | template 425 | void MultiArg::reset() 426 | { 427 | Arg::reset(); 428 | _values.clear(); 429 | } 430 | 431 | } // namespace TCLAP 432 | 433 | #endif 434 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/MultiSwitchArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: MultiSwitchArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek. 9 | * All rights reverved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | 25 | #ifndef TCLAP_MULTI_SWITCH_ARG_H 26 | #define TCLAP_MULTI_SWITCH_ARG_H 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | /** 36 | * A multiple switch argument. If the switch is set on the command line, then 37 | * the getValue method will return the number of times the switch appears. 38 | */ 39 | class MultiSwitchArg : public SwitchArg 40 | { 41 | protected: 42 | 43 | /** 44 | * The value of the switch. 45 | */ 46 | int _value; 47 | 48 | /** 49 | * Used to support the reset() method so that ValueArg can be 50 | * reset to their constructed value. 51 | */ 52 | int _default; 53 | 54 | public: 55 | 56 | /** 57 | * MultiSwitchArg constructor. 58 | * \param flag - The one character flag that identifies this 59 | * argument on the command line. 60 | * \param name - A one word name for the argument. Can be 61 | * used as a long flag on the command line. 62 | * \param desc - A description of what the argument is for or 63 | * does. 64 | * \param init - Optional. The initial/default value of this Arg. 65 | * Defaults to 0. 66 | * \param v - An optional visitor. You probably should not 67 | * use this unless you have a very good reason. 68 | */ 69 | MultiSwitchArg(const std::string& flag, 70 | const std::string& name, 71 | const std::string& desc, 72 | int init = 0, 73 | Visitor* v = NULL); 74 | 75 | 76 | /** 77 | * MultiSwitchArg constructor. 78 | * \param flag - The one character flag that identifies this 79 | * argument on the command line. 80 | * \param name - A one word name for the argument. Can be 81 | * used as a long flag on the command line. 82 | * \param desc - A description of what the argument is for or 83 | * does. 84 | * \param parser - A CmdLine parser object to add this Arg to 85 | * \param init - Optional. The initial/default value of this Arg. 86 | * Defaults to 0. 87 | * \param v - An optional visitor. You probably should not 88 | * use this unless you have a very good reason. 89 | */ 90 | MultiSwitchArg(const std::string& flag, 91 | const std::string& name, 92 | const std::string& desc, 93 | CmdLineInterface& parser, 94 | int init = 0, 95 | Visitor* v = NULL); 96 | 97 | 98 | /** 99 | * Handles the processing of the argument. 100 | * This re-implements the SwitchArg version of this method to set the 101 | * _value of the argument appropriately. 102 | * \param i - Pointer the the current argument in the list. 103 | * \param args - Mutable list of strings. Passed 104 | * in from main(). 105 | */ 106 | virtual bool processArg(int* i, std::vector& args); 107 | 108 | /** 109 | * Returns int, the number of times the switch has been set. 110 | */ 111 | int getValue(); 112 | 113 | /** 114 | * Returns the shortID for this Arg. 115 | */ 116 | std::string shortID(const std::string& val) const; 117 | 118 | /** 119 | * Returns the longID for this Arg. 120 | */ 121 | std::string longID(const std::string& val) const; 122 | 123 | void reset(); 124 | 125 | }; 126 | 127 | ////////////////////////////////////////////////////////////////////// 128 | //BEGIN MultiSwitchArg.cpp 129 | ////////////////////////////////////////////////////////////////////// 130 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, 131 | const std::string& name, 132 | const std::string& desc, 133 | int init, 134 | Visitor* v ) 135 | : SwitchArg(flag, name, desc, false, v), 136 | _value( init ), 137 | _default( init ) 138 | { } 139 | 140 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, 141 | const std::string& name, 142 | const std::string& desc, 143 | CmdLineInterface& parser, 144 | int init, 145 | Visitor* v ) 146 | : SwitchArg(flag, name, desc, false, v), 147 | _value( init ), 148 | _default( init ) 149 | { 150 | parser.add( this ); 151 | } 152 | 153 | inline int MultiSwitchArg::getValue() { return _value; } 154 | 155 | inline bool MultiSwitchArg::processArg(int *i, std::vector& args) 156 | { 157 | if ( _ignoreable && Arg::ignoreRest() ) 158 | return false; 159 | 160 | if ( argMatches( args[*i] )) 161 | { 162 | // so the isSet() method will work 163 | _alreadySet = true; 164 | 165 | // Matched argument: increment value. 166 | ++_value; 167 | 168 | _checkWithVisitor(); 169 | 170 | return true; 171 | } 172 | else if ( combinedSwitchesMatch( args[*i] ) ) 173 | { 174 | // so the isSet() method will work 175 | _alreadySet = true; 176 | 177 | // Matched argument: increment value. 178 | ++_value; 179 | 180 | // Check for more in argument and increment value. 181 | while ( combinedSwitchesMatch( args[*i] ) ) 182 | ++_value; 183 | 184 | _checkWithVisitor(); 185 | 186 | return false; 187 | } 188 | else 189 | return false; 190 | } 191 | 192 | inline std::string 193 | MultiSwitchArg::shortID(const std::string& val) const 194 | { 195 | return Arg::shortID(val) + " ... "; 196 | } 197 | 198 | inline std::string 199 | MultiSwitchArg::longID(const std::string& val) const 200 | { 201 | return Arg::longID(val) + " (accepted multiple times)"; 202 | } 203 | 204 | inline void 205 | MultiSwitchArg::reset() 206 | { 207 | MultiSwitchArg::_value = MultiSwitchArg::_default; 208 | } 209 | 210 | ////////////////////////////////////////////////////////////////////// 211 | //END MultiSwitchArg.cpp 212 | ////////////////////////////////////////////////////////////////////// 213 | 214 | } //namespace TCLAP 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/OptionalUnlabeledTracker.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: OptionalUnlabeledTracker.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H 25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H 26 | 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | class OptionalUnlabeledTracker 32 | { 33 | 34 | public: 35 | 36 | static void check( bool req, const std::string& argName ); 37 | 38 | static void gotOptional() { alreadyOptionalRef() = true; } 39 | 40 | static bool& alreadyOptional() { return alreadyOptionalRef(); } 41 | 42 | private: 43 | 44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; } 45 | }; 46 | 47 | 48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) 49 | { 50 | if ( OptionalUnlabeledTracker::alreadyOptional() ) 51 | throw( SpecificationException( 52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", 53 | argName ) ); 54 | 55 | if ( !req ) 56 | OptionalUnlabeledTracker::gotOptional(); 57 | } 58 | 59 | 60 | } // namespace TCLAP 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/StandardTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StandardTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_STANDARD_TRAITS_H 27 | #define TCLAP_STANDARD_TRAITS_H 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include // To check for long long 31 | #endif 32 | 33 | // If Microsoft has already typedef'd wchar_t as an unsigned 34 | // short, then compiles will break because it's as if we're 35 | // creating ArgTraits twice for unsigned short. Thus... 36 | #ifdef _MSC_VER 37 | #ifndef _NATIVE_WCHAR_T_DEFINED 38 | #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 39 | #endif 40 | #endif 41 | 42 | namespace TCLAP { 43 | 44 | // ====================================================================== 45 | // Integer types 46 | // ====================================================================== 47 | 48 | /** 49 | * longs have value-like semantics. 50 | */ 51 | template<> 52 | struct ArgTraits { 53 | typedef ValueLike ValueCategory; 54 | }; 55 | 56 | /** 57 | * ints have value-like semantics. 58 | */ 59 | template<> 60 | struct ArgTraits { 61 | typedef ValueLike ValueCategory; 62 | }; 63 | 64 | /** 65 | * shorts have value-like semantics. 66 | */ 67 | template<> 68 | struct ArgTraits { 69 | typedef ValueLike ValueCategory; 70 | }; 71 | 72 | /** 73 | * chars have value-like semantics. 74 | */ 75 | template<> 76 | struct ArgTraits { 77 | typedef ValueLike ValueCategory; 78 | }; 79 | 80 | #ifdef HAVE_LONG_LONG 81 | /** 82 | * long longs have value-like semantics. 83 | */ 84 | template<> 85 | struct ArgTraits { 86 | typedef ValueLike ValueCategory; 87 | }; 88 | #endif 89 | 90 | // ====================================================================== 91 | // Unsigned integer types 92 | // ====================================================================== 93 | 94 | /** 95 | * unsigned longs have value-like semantics. 96 | */ 97 | template<> 98 | struct ArgTraits { 99 | typedef ValueLike ValueCategory; 100 | }; 101 | 102 | /** 103 | * unsigned ints have value-like semantics. 104 | */ 105 | template<> 106 | struct ArgTraits { 107 | typedef ValueLike ValueCategory; 108 | }; 109 | 110 | /** 111 | * unsigned shorts have value-like semantics. 112 | */ 113 | template<> 114 | struct ArgTraits { 115 | typedef ValueLike ValueCategory; 116 | }; 117 | 118 | /** 119 | * unsigned chars have value-like semantics. 120 | */ 121 | template<> 122 | struct ArgTraits { 123 | typedef ValueLike ValueCategory; 124 | }; 125 | 126 | // Microsoft implements size_t awkwardly. 127 | #if defined(_MSC_VER) && defined(_M_X64) 128 | /** 129 | * size_ts have value-like semantics. 130 | */ 131 | template<> 132 | struct ArgTraits { 133 | typedef ValueLike ValueCategory; 134 | }; 135 | #endif 136 | 137 | 138 | #ifdef HAVE_LONG_LONG 139 | /** 140 | * unsigned long longs have value-like semantics. 141 | */ 142 | template<> 143 | struct ArgTraits { 144 | typedef ValueLike ValueCategory; 145 | }; 146 | #endif 147 | 148 | // ====================================================================== 149 | // Float types 150 | // ====================================================================== 151 | 152 | /** 153 | * floats have value-like semantics. 154 | */ 155 | template<> 156 | struct ArgTraits { 157 | typedef ValueLike ValueCategory; 158 | }; 159 | 160 | /** 161 | * doubles have value-like semantics. 162 | */ 163 | template<> 164 | struct ArgTraits { 165 | typedef ValueLike ValueCategory; 166 | }; 167 | 168 | // ====================================================================== 169 | // Other types 170 | // ====================================================================== 171 | 172 | /** 173 | * bools have value-like semantics. 174 | */ 175 | template<> 176 | struct ArgTraits { 177 | typedef ValueLike ValueCategory; 178 | }; 179 | 180 | 181 | /** 182 | * wchar_ts have value-like semantics. 183 | */ 184 | #ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 185 | template<> 186 | struct ArgTraits { 187 | typedef ValueLike ValueCategory; 188 | }; 189 | #endif 190 | 191 | /** 192 | * Strings have string like argument traits. 193 | */ 194 | template<> 195 | struct ArgTraits { 196 | typedef StringLike ValueCategory; 197 | }; 198 | 199 | template 200 | void SetString(T &dst, const std::string &src) 201 | { 202 | dst = src; 203 | } 204 | 205 | } // namespace 206 | 207 | #endif 208 | 209 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/StdOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StdOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_STDCMDLINEOUTPUT_H 24 | #define TCLAP_STDCMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that isolates any output from the CmdLine object so that it 41 | * may be easily modified. 42 | */ 43 | class StdOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | /** 49 | * Prints the usage to stdout. Can be overridden to 50 | * produce alternative behavior. 51 | * \param c - The CmdLine object the output is generated for. 52 | */ 53 | virtual void usage(CmdLineInterface& c); 54 | 55 | /** 56 | * Prints the version to stdout. Can be overridden 57 | * to produce alternative behavior. 58 | * \param c - The CmdLine object the output is generated for. 59 | */ 60 | virtual void version(CmdLineInterface& c); 61 | 62 | /** 63 | * Prints (to stderr) an error message, short usage 64 | * Can be overridden to produce alternative behavior. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure(CmdLineInterface& c, 69 | ArgException& e ); 70 | 71 | protected: 72 | 73 | /** 74 | * Writes a brief usage message with short args. 75 | * \param c - The CmdLine object the output is generated for. 76 | * \param os - The stream to write the message to. 77 | */ 78 | void _shortUsage( CmdLineInterface& c, std::ostream& os ) const; 79 | 80 | /** 81 | * Writes a longer usage message with long and short args, 82 | * provides descriptions and prints message. 83 | * \param c - The CmdLine object the output is generated for. 84 | * \param os - The stream to write the message to. 85 | */ 86 | void _longUsage( CmdLineInterface& c, std::ostream& os ) const; 87 | 88 | /** 89 | * This function inserts line breaks and indents long strings 90 | * according the params input. It will only break lines at spaces, 91 | * commas and pipes. 92 | * \param os - The stream to be printed to. 93 | * \param s - The string to be printed. 94 | * \param maxWidth - The maxWidth allowed for the output line. 95 | * \param indentSpaces - The number of spaces to indent the first line. 96 | * \param secondLineOffset - The number of spaces to indent the second 97 | * and all subsequent lines in addition to indentSpaces. 98 | */ 99 | void spacePrint( std::ostream& os, 100 | const std::string& s, 101 | int maxWidth, 102 | int indentSpaces, 103 | int secondLineOffset ) const; 104 | 105 | }; 106 | 107 | 108 | inline void StdOutput::version(CmdLineInterface& _cmd) 109 | { 110 | std::string progName = _cmd.getProgramName(); 111 | std::string xversion = _cmd.getVersion(); 112 | 113 | std::cout << std::endl << progName << " version: " 114 | << xversion << std::endl << std::endl; 115 | } 116 | 117 | inline void StdOutput::usage(CmdLineInterface& _cmd ) 118 | { 119 | std::cout << std::endl << "USAGE: " << std::endl << std::endl; 120 | 121 | _shortUsage( _cmd, std::cout ); 122 | 123 | std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl; 124 | 125 | _longUsage( _cmd, std::cout ); 126 | 127 | std::cout << std::endl; 128 | 129 | } 130 | 131 | inline void StdOutput::failure( CmdLineInterface& _cmd, 132 | ArgException& e ) 133 | { 134 | std::string progName = _cmd.getProgramName(); 135 | 136 | std::cerr << "PARSE ERROR: " << e.argId() << std::endl 137 | << " " << e.error() << std::endl << std::endl; 138 | 139 | if ( _cmd.hasHelpAndVersion() ) 140 | { 141 | std::cerr << "Brief USAGE: " << std::endl; 142 | 143 | _shortUsage( _cmd, std::cerr ); 144 | 145 | std::cerr << std::endl << "For complete USAGE and HELP type: " 146 | << std::endl << " " << progName << " --help" 147 | << std::endl << std::endl; 148 | } 149 | else 150 | usage(_cmd); 151 | 152 | throw ExitException(1); 153 | } 154 | 155 | inline void 156 | StdOutput::_shortUsage( CmdLineInterface& _cmd, 157 | std::ostream& os ) const 158 | { 159 | std::list argList = _cmd.getArgList(); 160 | std::string progName = _cmd.getProgramName(); 161 | XorHandler xorHandler = _cmd.getXorHandler(); 162 | std::vector< std::vector > xorList = xorHandler.getXorList(); 163 | 164 | std::string s = progName + " "; 165 | 166 | // first the xor 167 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 168 | { 169 | s += " {"; 170 | for ( ArgVectorIterator it = xorList[i].begin(); 171 | it != xorList[i].end(); it++ ) 172 | s += (*it)->shortID() + "|"; 173 | 174 | s[s.length()-1] = '}'; 175 | } 176 | 177 | // then the rest 178 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 179 | if ( !xorHandler.contains( (*it) ) ) 180 | s += " " + (*it)->shortID(); 181 | 182 | // if the program name is too long, then adjust the second line offset 183 | int secondLineOffset = static_cast(progName.length()) + 2; 184 | if ( secondLineOffset > 75/2 ) 185 | secondLineOffset = static_cast(75/2); 186 | 187 | spacePrint( os, s, 75, 3, secondLineOffset ); 188 | } 189 | 190 | inline void 191 | StdOutput::_longUsage( CmdLineInterface& _cmd, 192 | std::ostream& os ) const 193 | { 194 | std::list argList = _cmd.getArgList(); 195 | std::string message = _cmd.getMessage(); 196 | XorHandler xorHandler = _cmd.getXorHandler(); 197 | std::vector< std::vector > xorList = xorHandler.getXorList(); 198 | 199 | // first the xor 200 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 201 | { 202 | for ( ArgVectorIterator it = xorList[i].begin(); 203 | it != xorList[i].end(); 204 | it++ ) 205 | { 206 | spacePrint( os, (*it)->longID(), 75, 3, 3 ); 207 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); 208 | 209 | if ( it+1 != xorList[i].end() ) 210 | spacePrint(os, "-- OR --", 75, 9, 0); 211 | } 212 | os << std::endl << std::endl; 213 | } 214 | 215 | // then the rest 216 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 217 | if ( !xorHandler.contains( (*it) ) ) 218 | { 219 | spacePrint( os, (*it)->longID(), 75, 3, 3 ); 220 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); 221 | os << std::endl; 222 | } 223 | 224 | os << std::endl; 225 | 226 | spacePrint( os, message, 75, 3, 0 ); 227 | } 228 | 229 | inline void StdOutput::spacePrint( std::ostream& os, 230 | const std::string& s, 231 | int maxWidth, 232 | int indentSpaces, 233 | int secondLineOffset ) const 234 | { 235 | int len = static_cast(s.length()); 236 | 237 | if ( (len + indentSpaces > maxWidth) && maxWidth > 0 ) 238 | { 239 | int allowedLen = maxWidth - indentSpaces; 240 | int start = 0; 241 | while ( start < len ) 242 | { 243 | // find the substring length 244 | // int stringLen = std::min( len - start, allowedLen ); 245 | // doing it this way to support a VisualC++ 2005 bug 246 | using namespace std; 247 | int stringLen = min( len - start, allowedLen ); 248 | 249 | // trim the length so it doesn't end in middle of a word 250 | if ( stringLen == allowedLen ) 251 | while ( stringLen >= 0 && 252 | s[stringLen+start] != ' ' && 253 | s[stringLen+start] != ',' && 254 | s[stringLen+start] != '|' ) 255 | stringLen--; 256 | 257 | // ok, the word is longer than the line, so just split 258 | // wherever the line ends 259 | if ( stringLen <= 0 ) 260 | stringLen = allowedLen; 261 | 262 | // check for newlines 263 | for ( int i = 0; i < stringLen; i++ ) 264 | if ( s[start+i] == '\n' ) 265 | stringLen = i+1; 266 | 267 | // print the indent 268 | for ( int i = 0; i < indentSpaces; i++ ) 269 | os << " "; 270 | 271 | if ( start == 0 ) 272 | { 273 | // handle second line offsets 274 | indentSpaces += secondLineOffset; 275 | 276 | // adjust allowed len 277 | allowedLen -= secondLineOffset; 278 | } 279 | 280 | os << s.substr(start,stringLen) << std::endl; 281 | 282 | // so we don't start a line with a space 283 | while ( s[stringLen+start] == ' ' && start < len ) 284 | start++; 285 | 286 | start += stringLen; 287 | } 288 | } 289 | else 290 | { 291 | for ( int i = 0; i < indentSpaces; i++ ) 292 | os << " "; 293 | os << s << std::endl; 294 | } 295 | } 296 | 297 | } //namespace TCLAP 298 | #endif 299 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/SwitchArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: SwitchArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_SWITCH_ARG_H 25 | #define TCLAP_SWITCH_ARG_H 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * A simple switch argument. If the switch is set on the command line, then 36 | * the getValue method will return the opposite of the default value for the 37 | * switch. 38 | */ 39 | class SwitchArg : public Arg 40 | { 41 | protected: 42 | 43 | /** 44 | * The value of the switch. 45 | */ 46 | bool _value; 47 | 48 | /** 49 | * Used to support the reset() method so that ValueArg can be 50 | * reset to their constructed value. 51 | */ 52 | bool _default; 53 | 54 | public: 55 | 56 | /** 57 | * SwitchArg constructor. 58 | * \param flag - The one character flag that identifies this 59 | * argument on the command line. 60 | * \param name - A one word name for the argument. Can be 61 | * used as a long flag on the command line. 62 | * \param desc - A description of what the argument is for or 63 | * does. 64 | * \param def - The default value for this Switch. 65 | * \param v - An optional visitor. You probably should not 66 | * use this unless you have a very good reason. 67 | */ 68 | SwitchArg(const std::string& flag, 69 | const std::string& name, 70 | const std::string& desc, 71 | bool def = false, 72 | Visitor* v = NULL); 73 | 74 | 75 | /** 76 | * SwitchArg constructor. 77 | * \param flag - The one character flag that identifies this 78 | * argument on the command line. 79 | * \param name - A one word name for the argument. Can be 80 | * used as a long flag on the command line. 81 | * \param desc - A description of what the argument is for or 82 | * does. 83 | * \param parser - A CmdLine parser object to add this Arg to 84 | * \param def - The default value for this Switch. 85 | * \param v - An optional visitor. You probably should not 86 | * use this unless you have a very good reason. 87 | */ 88 | SwitchArg(const std::string& flag, 89 | const std::string& name, 90 | const std::string& desc, 91 | CmdLineInterface& parser, 92 | bool def = false, 93 | Visitor* v = NULL); 94 | 95 | 96 | /** 97 | * Handles the processing of the argument. 98 | * This re-implements the Arg version of this method to set the 99 | * _value of the argument appropriately. 100 | * \param i - Pointer the the current argument in the list. 101 | * \param args - Mutable list of strings. Passed 102 | * in from main(). 103 | */ 104 | virtual bool processArg(int* i, std::vector& args); 105 | 106 | /** 107 | * Checks a string to see if any of the chars in the string 108 | * match the flag for this Switch. 109 | */ 110 | bool combinedSwitchesMatch(std::string& combined); 111 | 112 | /** 113 | * Returns bool, whether or not the switch has been set. 114 | */ 115 | bool getValue(); 116 | 117 | virtual void reset(); 118 | 119 | private: 120 | /** 121 | * Checks to see if we've found the last match in 122 | * a combined string. 123 | */ 124 | bool lastCombined(std::string& combined); 125 | 126 | /** 127 | * Does the common processing of processArg. 128 | */ 129 | void commonProcessing(); 130 | }; 131 | 132 | ////////////////////////////////////////////////////////////////////// 133 | //BEGIN SwitchArg.cpp 134 | ////////////////////////////////////////////////////////////////////// 135 | inline SwitchArg::SwitchArg(const std::string& flag, 136 | const std::string& name, 137 | const std::string& desc, 138 | bool default_val, 139 | Visitor* v ) 140 | : Arg(flag, name, desc, false, false, v), 141 | _value( default_val ), 142 | _default( default_val ) 143 | { } 144 | 145 | inline SwitchArg::SwitchArg(const std::string& flag, 146 | const std::string& name, 147 | const std::string& desc, 148 | CmdLineInterface& parser, 149 | bool default_val, 150 | Visitor* v ) 151 | : Arg(flag, name, desc, false, false, v), 152 | _value( default_val ), 153 | _default(default_val) 154 | { 155 | parser.add( this ); 156 | } 157 | 158 | inline bool SwitchArg::getValue() { return _value; } 159 | 160 | inline bool SwitchArg::lastCombined(std::string& combinedSwitches ) 161 | { 162 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 163 | if ( combinedSwitches[i] != Arg::blankChar() ) 164 | return false; 165 | 166 | return true; 167 | } 168 | 169 | inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches ) 170 | { 171 | // make sure this is actually a combined switch 172 | if ( combinedSwitches.length() > 0 && 173 | combinedSwitches[0] != Arg::flagStartString()[0] ) 174 | return false; 175 | 176 | // make sure it isn't a long name 177 | if ( combinedSwitches.substr( 0, Arg::nameStartString().length() ) == 178 | Arg::nameStartString() ) 179 | return false; 180 | 181 | // make sure the delimiter isn't in the string 182 | if ( combinedSwitches.find_first_of( Arg::delimiter() ) != std::string::npos ) 183 | return false; 184 | 185 | // ok, we're not specifying a ValueArg, so we know that we have 186 | // a combined switch list. 187 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 188 | if ( _flag.length() > 0 && 189 | combinedSwitches[i] == _flag[0] && 190 | _flag[0] != Arg::flagStartString()[0] ) 191 | { 192 | // update the combined switches so this one is no longer present 193 | // this is necessary so that no unlabeled args are matched 194 | // later in the processing. 195 | //combinedSwitches.erase(i,1); 196 | combinedSwitches[i] = Arg::blankChar(); 197 | return true; 198 | } 199 | 200 | // none of the switches passed in the list match. 201 | return false; 202 | } 203 | 204 | inline void SwitchArg::commonProcessing() 205 | { 206 | if ( _xorSet ) 207 | throw(CmdLineParseException( 208 | "Mutually exclusive argument already set!", toString())); 209 | 210 | if ( _alreadySet ) 211 | throw(CmdLineParseException("Argument already set!", toString())); 212 | 213 | _alreadySet = true; 214 | 215 | if ( _value == true ) 216 | _value = false; 217 | else 218 | _value = true; 219 | 220 | _checkWithVisitor(); 221 | } 222 | 223 | inline bool SwitchArg::processArg(int *i, std::vector& args) 224 | { 225 | if ( _ignoreable && Arg::ignoreRest() ) 226 | return false; 227 | 228 | // if the whole string matches the flag or name string 229 | if ( argMatches( args[*i] ) ) 230 | { 231 | commonProcessing(); 232 | 233 | return true; 234 | } 235 | // if a substring matches the flag as part of a combination 236 | else if ( combinedSwitchesMatch( args[*i] ) ) 237 | { 238 | // check again to ensure we don't misinterpret 239 | // this as a MultiSwitchArg 240 | if ( combinedSwitchesMatch( args[*i] ) ) 241 | throw(CmdLineParseException("Argument already set!", 242 | toString())); 243 | 244 | commonProcessing(); 245 | 246 | // We only want to return true if we've found the last combined 247 | // match in the string, otherwise we return true so that other 248 | // switches in the combination will have a chance to match. 249 | return lastCombined( args[*i] ); 250 | } 251 | else 252 | return false; 253 | } 254 | 255 | inline void SwitchArg::reset() 256 | { 257 | Arg::reset(); 258 | _value = _default; 259 | } 260 | ////////////////////////////////////////////////////////////////////// 261 | //End SwitchArg.cpp 262 | ////////////////////////////////////////////////////////////////////// 263 | 264 | } //namespace TCLAP 265 | 266 | #endif 267 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/UnlabeledMultiArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: UnlabeledMultiArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot. 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H 24 | #define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * Just like a MultiArg, except that the arguments are unlabeled. Basically, 36 | * this Arg will slurp up everything that hasn't been matched to another 37 | * Arg. 38 | */ 39 | template 40 | class UnlabeledMultiArg : public MultiArg 41 | { 42 | 43 | // If compiler has two stage name lookup (as gcc >= 3.4 does) 44 | // this is requried to prevent undef. symbols 45 | using MultiArg::_ignoreable; 46 | using MultiArg::_hasBlanks; 47 | using MultiArg::_extractValue; 48 | using MultiArg::_typeDesc; 49 | using MultiArg::_name; 50 | using MultiArg::_description; 51 | using MultiArg::_alreadySet; 52 | using MultiArg::toString; 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param name - The name of the Arg. Note that this is used for 59 | * identification, not as a long flag. 60 | * \param desc - A description of what the argument is for or 61 | * does. 62 | * \param req - Whether the argument is required on the command 63 | * line. 64 | * \param typeDesc - A short, human readable description of the 65 | * type that this object expects. This is used in the generation 66 | * of the USAGE statement. The goal is to be helpful to the end user 67 | * of the program. 68 | * \param ignoreable - Whether or not this argument can be ignored 69 | * using the "--" flag. 70 | * \param v - An optional visitor. You probably should not 71 | * use this unless you have a very good reason. 72 | */ 73 | UnlabeledMultiArg( const std::string& name, 74 | const std::string& desc, 75 | bool req, 76 | const std::string& typeDesc, 77 | bool ignoreable = false, 78 | Visitor* v = NULL ); 79 | /** 80 | * Constructor. 81 | * \param name - The name of the Arg. Note that this is used for 82 | * identification, not as a long flag. 83 | * \param desc - A description of what the argument is for or 84 | * does. 85 | * \param req - Whether the argument is required on the command 86 | * line. 87 | * \param typeDesc - A short, human readable description of the 88 | * type that this object expects. This is used in the generation 89 | * of the USAGE statement. The goal is to be helpful to the end user 90 | * of the program. 91 | * \param parser - A CmdLine parser object to add this Arg to 92 | * \param ignoreable - Whether or not this argument can be ignored 93 | * using the "--" flag. 94 | * \param v - An optional visitor. You probably should not 95 | * use this unless you have a very good reason. 96 | */ 97 | UnlabeledMultiArg( const std::string& name, 98 | const std::string& desc, 99 | bool req, 100 | const std::string& typeDesc, 101 | CmdLineInterface& parser, 102 | bool ignoreable = false, 103 | Visitor* v = NULL ); 104 | 105 | /** 106 | * Constructor. 107 | * \param name - The name of the Arg. Note that this is used for 108 | * identification, not as a long flag. 109 | * \param desc - A description of what the argument is for or 110 | * does. 111 | * \param req - Whether the argument is required on the command 112 | * line. 113 | * \param constraint - A pointer to a Constraint object used 114 | * to constrain this Arg. 115 | * \param ignoreable - Whether or not this argument can be ignored 116 | * using the "--" flag. 117 | * \param v - An optional visitor. You probably should not 118 | * use this unless you have a very good reason. 119 | */ 120 | UnlabeledMultiArg( const std::string& name, 121 | const std::string& desc, 122 | bool req, 123 | Constraint* constraint, 124 | bool ignoreable = false, 125 | Visitor* v = NULL ); 126 | 127 | /** 128 | * Constructor. 129 | * \param name - The name of the Arg. Note that this is used for 130 | * identification, not as a long flag. 131 | * \param desc - A description of what the argument is for or 132 | * does. 133 | * \param req - Whether the argument is required on the command 134 | * line. 135 | * \param constraint - A pointer to a Constraint object used 136 | * to constrain this Arg. 137 | * \param parser - A CmdLine parser object to add this Arg to 138 | * \param ignoreable - Whether or not this argument can be ignored 139 | * using the "--" flag. 140 | * \param v - An optional visitor. You probably should not 141 | * use this unless you have a very good reason. 142 | */ 143 | UnlabeledMultiArg( const std::string& name, 144 | const std::string& desc, 145 | bool req, 146 | Constraint* constraint, 147 | CmdLineInterface& parser, 148 | bool ignoreable = false, 149 | Visitor* v = NULL ); 150 | 151 | /** 152 | * Handles the processing of the argument. 153 | * This re-implements the Arg version of this method to set the 154 | * _value of the argument appropriately. It knows the difference 155 | * between labeled and unlabeled. 156 | * \param i - Pointer the the current argument in the list. 157 | * \param args - Mutable list of strings. Passed from main(). 158 | */ 159 | virtual bool processArg(int* i, std::vector& args); 160 | 161 | /** 162 | * Returns the a short id string. Used in the usage. 163 | * \param val - value to be used. 164 | */ 165 | virtual std::string shortID(const std::string& val="val") const; 166 | 167 | /** 168 | * Returns the a long id string. Used in the usage. 169 | * \param val - value to be used. 170 | */ 171 | virtual std::string longID(const std::string& val="val") const; 172 | 173 | /** 174 | * Opertor ==. 175 | * \param a - The Arg to be compared to this. 176 | */ 177 | virtual bool operator==(const Arg& a) const; 178 | 179 | /** 180 | * Pushes this to back of list rather than front. 181 | * \param argList - The list this should be added to. 182 | */ 183 | virtual void addToList( std::list& argList ) const; 184 | }; 185 | 186 | template 187 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 188 | const std::string& desc, 189 | bool req, 190 | const std::string& typeDesc, 191 | bool ignoreable, 192 | Visitor* v) 193 | : MultiArg("", name, desc, req, typeDesc, v) 194 | { 195 | _ignoreable = ignoreable; 196 | OptionalUnlabeledTracker::check(true, toString()); 197 | } 198 | 199 | template 200 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 201 | const std::string& desc, 202 | bool req, 203 | const std::string& typeDesc, 204 | CmdLineInterface& parser, 205 | bool ignoreable, 206 | Visitor* v) 207 | : MultiArg("", name, desc, req, typeDesc, v) 208 | { 209 | _ignoreable = ignoreable; 210 | OptionalUnlabeledTracker::check(true, toString()); 211 | parser.add( this ); 212 | } 213 | 214 | 215 | template 216 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 217 | const std::string& desc, 218 | bool req, 219 | Constraint* constraint, 220 | bool ignoreable, 221 | Visitor* v) 222 | : MultiArg("", name, desc, req, constraint, v) 223 | { 224 | _ignoreable = ignoreable; 225 | OptionalUnlabeledTracker::check(true, toString()); 226 | } 227 | 228 | template 229 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 230 | const std::string& desc, 231 | bool req, 232 | Constraint* constraint, 233 | CmdLineInterface& parser, 234 | bool ignoreable, 235 | Visitor* v) 236 | : MultiArg("", name, desc, req, constraint, v) 237 | { 238 | _ignoreable = ignoreable; 239 | OptionalUnlabeledTracker::check(true, toString()); 240 | parser.add( this ); 241 | } 242 | 243 | 244 | template 245 | bool UnlabeledMultiArg::processArg(int *i, std::vector& args) 246 | { 247 | 248 | if ( _hasBlanks( args[*i] ) ) 249 | return false; 250 | 251 | // never ignore an unlabeled multi arg 252 | 253 | 254 | // always take the first value, regardless of the start string 255 | _extractValue( args[(*i)] ); 256 | 257 | /* 258 | // continue taking args until we hit the end or a start string 259 | while ( (unsigned int)(*i)+1 < args.size() && 260 | args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && 261 | args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) 262 | _extractValue( args[++(*i)] ); 263 | */ 264 | 265 | _alreadySet = true; 266 | 267 | return true; 268 | } 269 | 270 | template 271 | std::string UnlabeledMultiArg::shortID(const std::string& val) const 272 | { 273 | static_cast(val); // Ignore input, don't warn 274 | return std::string("<") + _typeDesc + "> ..."; 275 | } 276 | 277 | template 278 | std::string UnlabeledMultiArg::longID(const std::string& val) const 279 | { 280 | static_cast(val); // Ignore input, don't warn 281 | return std::string("<") + _typeDesc + "> (accepted multiple times)"; 282 | } 283 | 284 | template 285 | bool UnlabeledMultiArg::operator==(const Arg& a) const 286 | { 287 | if ( _name == a.getName() || _description == a.getDescription() ) 288 | return true; 289 | else 290 | return false; 291 | } 292 | 293 | template 294 | void UnlabeledMultiArg::addToList( std::list& argList ) const 295 | { 296 | argList.push_back( const_cast(static_cast(this)) ); 297 | } 298 | 299 | } 300 | 301 | #endif 302 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/UnlabeledValueArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: UnlabeledValueArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_UNLABELED_VALUE_ARGUMENT_H 25 | #define TCLAP_UNLABELED_VALUE_ARGUMENT_H 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | 34 | namespace TCLAP { 35 | 36 | /** 37 | * The basic unlabeled argument that parses a value. 38 | * This is a template class, which means the type T defines the type 39 | * that a given object will attempt to parse when an UnlabeledValueArg 40 | * is reached in the list of args that the CmdLine iterates over. 41 | */ 42 | template 43 | class UnlabeledValueArg : public ValueArg 44 | { 45 | 46 | // If compiler has two stage name lookup (as gcc >= 3.4 does) 47 | // this is requried to prevent undef. symbols 48 | using ValueArg::_ignoreable; 49 | using ValueArg::_hasBlanks; 50 | using ValueArg::_extractValue; 51 | using ValueArg::_typeDesc; 52 | using ValueArg::_name; 53 | using ValueArg::_description; 54 | using ValueArg::_alreadySet; 55 | using ValueArg::toString; 56 | 57 | public: 58 | 59 | /** 60 | * UnlabeledValueArg constructor. 61 | * \param name - A one word name for the argument. Note that this is used for 62 | * identification, not as a long flag. 63 | * \param desc - A description of what the argument is for or 64 | * does. 65 | * \param req - Whether the argument is required on the command 66 | * line. 67 | * \param value - The default value assigned to this argument if it 68 | * is not present on the command line. 69 | * \param typeDesc - A short, human readable description of the 70 | * type that this object expects. This is used in the generation 71 | * of the USAGE statement. The goal is to be helpful to the end user 72 | * of the program. 73 | * \param ignoreable - Allows you to specify that this argument can be 74 | * ignored if the '--' flag is set. This defaults to false (cannot 75 | * be ignored) and should generally stay that way unless you have 76 | * some special need for certain arguments to be ignored. 77 | * \param v - Optional Vistor. You should leave this blank unless 78 | * you have a very good reason. 79 | */ 80 | UnlabeledValueArg( const std::string& name, 81 | const std::string& desc, 82 | bool req, 83 | T value, 84 | const std::string& typeDesc, 85 | bool ignoreable = false, 86 | Visitor* v = NULL); 87 | 88 | /** 89 | * UnlabeledValueArg constructor. 90 | * \param name - A one word name for the argument. Note that this is used for 91 | * identification, not as a long flag. 92 | * \param desc - A description of what the argument is for or 93 | * does. 94 | * \param req - Whether the argument is required on the command 95 | * line. 96 | * \param value - The default value assigned to this argument if it 97 | * is not present on the command line. 98 | * \param typeDesc - A short, human readable description of the 99 | * type that this object expects. This is used in the generation 100 | * of the USAGE statement. The goal is to be helpful to the end user 101 | * of the program. 102 | * \param parser - A CmdLine parser object to add this Arg to 103 | * \param ignoreable - Allows you to specify that this argument can be 104 | * ignored if the '--' flag is set. This defaults to false (cannot 105 | * be ignored) and should generally stay that way unless you have 106 | * some special need for certain arguments to be ignored. 107 | * \param v - Optional Vistor. You should leave this blank unless 108 | * you have a very good reason. 109 | */ 110 | UnlabeledValueArg( const std::string& name, 111 | const std::string& desc, 112 | bool req, 113 | T value, 114 | const std::string& typeDesc, 115 | CmdLineInterface& parser, 116 | bool ignoreable = false, 117 | Visitor* v = NULL ); 118 | 119 | /** 120 | * UnlabeledValueArg constructor. 121 | * \param name - A one word name for the argument. Note that this is used for 122 | * identification, not as a long flag. 123 | * \param desc - A description of what the argument is for or 124 | * does. 125 | * \param req - Whether the argument is required on the command 126 | * line. 127 | * \param value - The default value assigned to this argument if it 128 | * is not present on the command line. 129 | * \param constraint - A pointer to a Constraint object used 130 | * to constrain this Arg. 131 | * \param ignoreable - Allows you to specify that this argument can be 132 | * ignored if the '--' flag is set. This defaults to false (cannot 133 | * be ignored) and should generally stay that way unless you have 134 | * some special need for certain arguments to be ignored. 135 | * \param v - Optional Vistor. You should leave this blank unless 136 | * you have a very good reason. 137 | */ 138 | UnlabeledValueArg( const std::string& name, 139 | const std::string& desc, 140 | bool req, 141 | T value, 142 | Constraint* constraint, 143 | bool ignoreable = false, 144 | Visitor* v = NULL ); 145 | 146 | 147 | /** 148 | * UnlabeledValueArg constructor. 149 | * \param name - A one word name for the argument. Note that this is used for 150 | * identification, not as a long flag. 151 | * \param desc - A description of what the argument is for or 152 | * does. 153 | * \param req - Whether the argument is required on the command 154 | * line. 155 | * \param value - The default value assigned to this argument if it 156 | * is not present on the command line. 157 | * \param constraint - A pointer to a Constraint object used 158 | * to constrain this Arg. 159 | * \param parser - A CmdLine parser object to add this Arg to 160 | * \param ignoreable - Allows you to specify that this argument can be 161 | * ignored if the '--' flag is set. This defaults to false (cannot 162 | * be ignored) and should generally stay that way unless you have 163 | * some special need for certain arguments to be ignored. 164 | * \param v - Optional Vistor. You should leave this blank unless 165 | * you have a very good reason. 166 | */ 167 | UnlabeledValueArg( const std::string& name, 168 | const std::string& desc, 169 | bool req, 170 | T value, 171 | Constraint* constraint, 172 | CmdLineInterface& parser, 173 | bool ignoreable = false, 174 | Visitor* v = NULL); 175 | 176 | /** 177 | * Handles the processing of the argument. 178 | * This re-implements the Arg version of this method to set the 179 | * _value of the argument appropriately. Handling specific to 180 | * unlabled arguments. 181 | * \param i - Pointer the the current argument in the list. 182 | * \param args - Mutable list of strings. 183 | */ 184 | virtual bool processArg(int* i, std::vector& args); 185 | 186 | /** 187 | * Overrides shortID for specific behavior. 188 | */ 189 | virtual std::string shortID(const std::string& val="val") const; 190 | 191 | /** 192 | * Overrides longID for specific behavior. 193 | */ 194 | virtual std::string longID(const std::string& val="val") const; 195 | 196 | /** 197 | * Overrides operator== for specific behavior. 198 | */ 199 | virtual bool operator==(const Arg& a ) const; 200 | 201 | /** 202 | * Instead of pushing to the front of list, push to the back. 203 | * \param argList - The list to add this to. 204 | */ 205 | virtual void addToList( std::list& argList ) const; 206 | 207 | }; 208 | 209 | /** 210 | * Constructor implemenation. 211 | */ 212 | template 213 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 214 | const std::string& desc, 215 | bool req, 216 | T val, 217 | const std::string& typeDesc, 218 | bool ignoreable, 219 | Visitor* v) 220 | : ValueArg("", name, desc, req, val, typeDesc, v) 221 | { 222 | _ignoreable = ignoreable; 223 | 224 | OptionalUnlabeledTracker::check(req, toString()); 225 | 226 | } 227 | 228 | template 229 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 230 | const std::string& desc, 231 | bool req, 232 | T val, 233 | const std::string& typeDesc, 234 | CmdLineInterface& parser, 235 | bool ignoreable, 236 | Visitor* v) 237 | : ValueArg("", name, desc, req, val, typeDesc, v) 238 | { 239 | _ignoreable = ignoreable; 240 | OptionalUnlabeledTracker::check(req, toString()); 241 | parser.add( this ); 242 | } 243 | 244 | /** 245 | * Constructor implemenation. 246 | */ 247 | template 248 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 249 | const std::string& desc, 250 | bool req, 251 | T val, 252 | Constraint* constraint, 253 | bool ignoreable, 254 | Visitor* v) 255 | : ValueArg("", name, desc, req, val, constraint, v) 256 | { 257 | _ignoreable = ignoreable; 258 | OptionalUnlabeledTracker::check(req, toString()); 259 | } 260 | 261 | template 262 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 263 | const std::string& desc, 264 | bool req, 265 | T val, 266 | Constraint* constraint, 267 | CmdLineInterface& parser, 268 | bool ignoreable, 269 | Visitor* v) 270 | : ValueArg("", name, desc, req, val, constraint, v) 271 | { 272 | _ignoreable = ignoreable; 273 | OptionalUnlabeledTracker::check(req, toString()); 274 | parser.add( this ); 275 | } 276 | 277 | /** 278 | * Implementation of processArg(). 279 | */ 280 | template 281 | bool UnlabeledValueArg::processArg(int *i, std::vector& args) 282 | { 283 | 284 | if ( _alreadySet ) 285 | return false; 286 | 287 | if ( _hasBlanks( args[*i] ) ) 288 | return false; 289 | 290 | // never ignore an unlabeled arg 291 | 292 | _extractValue( args[*i] ); 293 | _alreadySet = true; 294 | return true; 295 | } 296 | 297 | /** 298 | * Overriding shortID for specific output. 299 | */ 300 | template 301 | std::string UnlabeledValueArg::shortID(const std::string& val) const 302 | { 303 | static_cast(val); // Ignore input, don't warn 304 | return std::string("<") + _typeDesc + ">"; 305 | } 306 | 307 | /** 308 | * Overriding longID for specific output. 309 | */ 310 | template 311 | std::string UnlabeledValueArg::longID(const std::string& val) const 312 | { 313 | static_cast(val); // Ignore input, don't warn 314 | 315 | // Ideally we would like to be able to use RTTI to return the name 316 | // of the type required for this argument. However, g++ at least, 317 | // doesn't appear to return terribly useful "names" of the types. 318 | return std::string("<") + _typeDesc + ">"; 319 | } 320 | 321 | /** 322 | * Overriding operator== for specific behavior. 323 | */ 324 | template 325 | bool UnlabeledValueArg::operator==(const Arg& a ) const 326 | { 327 | if ( _name == a.getName() || _description == a.getDescription() ) 328 | return true; 329 | else 330 | return false; 331 | } 332 | 333 | template 334 | void UnlabeledValueArg::addToList( std::list& argList ) const 335 | { 336 | argList.push_back( const_cast(static_cast(this)) ); 337 | } 338 | 339 | } 340 | #endif 341 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/ValuesConstraint.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ValuesConstraint.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_VALUESCONSTRAINT_H 24 | #define TCLAP_VALUESCONSTRAINT_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #ifdef HAVE_CONFIG_H 31 | #include 32 | #else 33 | #define HAVE_SSTREAM 34 | #endif 35 | 36 | #if defined(HAVE_SSTREAM) 37 | #include 38 | #elif defined(HAVE_STRSTREAM) 39 | #include 40 | #else 41 | #error "Need a stringstream (sstream or strstream) to compile!" 42 | #endif 43 | 44 | namespace TCLAP { 45 | 46 | /** 47 | * A Constraint that constrains the Arg to only those values specified 48 | * in the constraint. 49 | */ 50 | template 51 | class ValuesConstraint : public Constraint 52 | { 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param allowed - vector of allowed values. 59 | */ 60 | ValuesConstraint(std::vector& allowed); 61 | 62 | /** 63 | * Virtual destructor. 64 | */ 65 | virtual ~ValuesConstraint() {} 66 | 67 | /** 68 | * Returns a description of the Constraint. 69 | */ 70 | virtual std::string description() const; 71 | 72 | /** 73 | * Returns the short ID for the Constraint. 74 | */ 75 | virtual std::string shortID() const; 76 | 77 | /** 78 | * The method used to verify that the value parsed from the command 79 | * line meets the constraint. 80 | * \param value - The value that will be checked. 81 | */ 82 | virtual bool check(const T& value) const; 83 | 84 | protected: 85 | 86 | /** 87 | * The list of valid values. 88 | */ 89 | std::vector _allowed; 90 | 91 | /** 92 | * The string used to describe the allowed values of this constraint. 93 | */ 94 | std::string _typeDesc; 95 | 96 | }; 97 | 98 | template 99 | ValuesConstraint::ValuesConstraint(std::vector& allowed) 100 | : _allowed(allowed), 101 | _typeDesc("") 102 | { 103 | for ( unsigned int i = 0; i < _allowed.size(); i++ ) 104 | { 105 | 106 | #if defined(HAVE_SSTREAM) 107 | std::ostringstream os; 108 | #elif defined(HAVE_STRSTREAM) 109 | std::ostrstream os; 110 | #else 111 | #error "Need a stringstream (sstream or strstream) to compile!" 112 | #endif 113 | 114 | os << _allowed[i]; 115 | 116 | std::string temp( os.str() ); 117 | 118 | if ( i > 0 ) 119 | _typeDesc += "|"; 120 | _typeDesc += temp; 121 | } 122 | } 123 | 124 | template 125 | bool ValuesConstraint::check( const T& val ) const 126 | { 127 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) 128 | return false; 129 | else 130 | return true; 131 | } 132 | 133 | template 134 | std::string ValuesConstraint::shortID() const 135 | { 136 | return _typeDesc; 137 | } 138 | 139 | template 140 | std::string ValuesConstraint::description() const 141 | { 142 | return _typeDesc; 143 | } 144 | 145 | 146 | } //namespace TCLAP 147 | #endif 148 | 149 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/VersionVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: VersionVisitor.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_VERSION_VISITOR_H 25 | #define TCLAP_VERSION_VISITOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Vistor that will call the version method of the given CmdLineOutput 35 | * for the specified CmdLine object and then exit. 36 | */ 37 | class VersionVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying 42 | */ 43 | VersionVisitor(const VersionVisitor& rhs); 44 | VersionVisitor& operator=(const VersionVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine of interest. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output is generated for. 63 | * \param out - The type of output. 64 | */ 65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the version method of the output object using the 70 | * specified CmdLine. 71 | */ 72 | void visit() { 73 | (*_out)->version(*_cmd); 74 | throw ExitException(0); 75 | } 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Visitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VISITOR_H 24 | #define TCLAP_VISITOR_H 25 | 26 | namespace TCLAP { 27 | 28 | /** 29 | * A base class that defines the interface for visitors. 30 | */ 31 | class Visitor 32 | { 33 | public: 34 | 35 | /** 36 | * Constructor. Does nothing. 37 | */ 38 | Visitor() { } 39 | 40 | /** 41 | * Destructor. Does nothing. 42 | */ 43 | virtual ~Visitor() { } 44 | 45 | /** 46 | * Does nothing. Should be overridden by child. 47 | */ 48 | virtual void visit() { } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/XorHandler.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: XorHandler.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_XORHANDLER_H 24 | #define TCLAP_XORHANDLER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * This class handles lists of Arg's that are to be XOR'd on the command 36 | * line. This is used by CmdLine and you shouldn't ever use it. 37 | */ 38 | class XorHandler 39 | { 40 | protected: 41 | 42 | /** 43 | * The list of of lists of Arg's to be or'd together. 44 | */ 45 | std::vector< std::vector > _orList; 46 | 47 | public: 48 | 49 | /** 50 | * Constructor. Does nothing. 51 | */ 52 | XorHandler( ) : _orList(std::vector< std::vector >()) {} 53 | 54 | /** 55 | * Add a list of Arg*'s that will be orred together. 56 | * \param ors - list of Arg* that will be xor'd. 57 | */ 58 | void add( std::vector& ors ); 59 | 60 | /** 61 | * Checks whether the specified Arg is in one of the xor lists and 62 | * if it does match one, returns the size of the xor list that the 63 | * Arg matched. If the Arg matches, then it also sets the rest of 64 | * the Arg's in the list. You shouldn't use this. 65 | * \param a - The Arg to be checked. 66 | */ 67 | int check( const Arg* a ); 68 | 69 | /** 70 | * Returns the XOR specific short usage. 71 | */ 72 | std::string shortUsage(); 73 | 74 | /** 75 | * Prints the XOR specific long usage. 76 | * \param os - Stream to print to. 77 | */ 78 | void printLongUsage(std::ostream& os); 79 | 80 | /** 81 | * Simply checks whether the Arg is contained in one of the arg 82 | * lists. 83 | * \param a - The Arg to be checked. 84 | */ 85 | bool contains( const Arg* a ); 86 | 87 | std::vector< std::vector >& getXorList(); 88 | 89 | }; 90 | 91 | 92 | ////////////////////////////////////////////////////////////////////// 93 | //BEGIN XOR.cpp 94 | ////////////////////////////////////////////////////////////////////// 95 | inline void XorHandler::add( std::vector& ors ) 96 | { 97 | _orList.push_back( ors ); 98 | } 99 | 100 | inline int XorHandler::check( const Arg* a ) 101 | { 102 | // iterate over each XOR list 103 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 104 | { 105 | // if the XOR list contains the arg.. 106 | ArgVectorIterator ait = std::find( _orList[i].begin(), 107 | _orList[i].end(), a ); 108 | if ( ait != _orList[i].end() ) 109 | { 110 | // first check to see if a mutually exclusive switch 111 | // has not already been set 112 | for ( ArgVectorIterator it = _orList[i].begin(); 113 | it != _orList[i].end(); 114 | it++ ) 115 | if ( a != (*it) && (*it)->isSet() ) 116 | throw(CmdLineParseException( 117 | "Mutually exclusive argument already set!", 118 | (*it)->toString())); 119 | 120 | // go through and set each arg that is not a 121 | for ( ArgVectorIterator it = _orList[i].begin(); 122 | it != _orList[i].end(); 123 | it++ ) 124 | if ( a != (*it) ) 125 | (*it)->xorSet(); 126 | 127 | // return the number of required args that have now been set 128 | if ( (*ait)->allowMore() ) 129 | return 0; 130 | else 131 | return static_cast(_orList[i].size()); 132 | } 133 | } 134 | 135 | if ( a->isRequired() ) 136 | return 1; 137 | else 138 | return 0; 139 | } 140 | 141 | inline bool XorHandler::contains( const Arg* a ) 142 | { 143 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 144 | for ( ArgVectorIterator it = _orList[i].begin(); 145 | it != _orList[i].end(); 146 | it++ ) 147 | if ( a == (*it) ) 148 | return true; 149 | 150 | return false; 151 | } 152 | 153 | inline std::vector< std::vector >& XorHandler::getXorList() 154 | { 155 | return _orList; 156 | } 157 | 158 | 159 | 160 | ////////////////////////////////////////////////////////////////////// 161 | //END XOR.cpp 162 | ////////////////////////////////////////////////////////////////////// 163 | 164 | } //namespace TCLAP 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /libs/tclap/include/tclap/ZshCompletionOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ZshCompletionOutput.h 6 | * 7 | * Copyright (c) 2006, Oliver Kiddle 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H 24 | #define TCLAP_ZSHCOMPLETIONOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that generates a Zsh completion function as output from the usage() 41 | * method for the given CmdLine and its Args. 42 | */ 43 | class ZshCompletionOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | ZshCompletionOutput(); 49 | 50 | /** 51 | * Prints the usage to stdout. Can be overridden to 52 | * produce alternative behavior. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c); 56 | 57 | /** 58 | * Prints the version to stdout. Can be overridden 59 | * to produce alternative behavior. 60 | * \param c - The CmdLine object the output is generated for. 61 | */ 62 | virtual void version(CmdLineInterface& c); 63 | 64 | /** 65 | * Prints (to stderr) an error message, short usage 66 | * Can be overridden to produce alternative behavior. 67 | * \param c - The CmdLine object the output is generated for. 68 | * \param e - The ArgException that caused the failure. 69 | */ 70 | virtual void failure(CmdLineInterface& c, 71 | ArgException& e ); 72 | 73 | protected: 74 | 75 | void basename( std::string& s ); 76 | void quoteSpecialChars( std::string& s ); 77 | 78 | std::string getMutexList( CmdLineInterface& _cmd, Arg* a ); 79 | void printOption( Arg* it, std::string mutex ); 80 | void printArg( Arg* it ); 81 | 82 | std::map common; 83 | char theDelimiter; 84 | }; 85 | 86 | ZshCompletionOutput::ZshCompletionOutput() 87 | : common(std::map()), 88 | theDelimiter('=') 89 | { 90 | common["host"] = "_hosts"; 91 | common["hostname"] = "_hosts"; 92 | common["file"] = "_files"; 93 | common["filename"] = "_files"; 94 | common["user"] = "_users"; 95 | common["username"] = "_users"; 96 | common["directory"] = "_directories"; 97 | common["path"] = "_directories"; 98 | common["url"] = "_urls"; 99 | } 100 | 101 | inline void ZshCompletionOutput::version(CmdLineInterface& _cmd) 102 | { 103 | std::cout << _cmd.getVersion() << std::endl; 104 | } 105 | 106 | inline void ZshCompletionOutput::usage(CmdLineInterface& _cmd ) 107 | { 108 | std::list argList = _cmd.getArgList(); 109 | std::string progName = _cmd.getProgramName(); 110 | std::string xversion = _cmd.getVersion(); 111 | theDelimiter = _cmd.getDelimiter(); 112 | basename(progName); 113 | 114 | std::cout << "#compdef " << progName << std::endl << std::endl << 115 | "# " << progName << " version " << _cmd.getVersion() << std::endl << std::endl << 116 | "_arguments -s -S"; 117 | 118 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 119 | { 120 | if ( (*it)->shortID().at(0) == '<' ) 121 | printArg((*it)); 122 | else if ( (*it)->getFlag() != "-" ) 123 | printOption((*it), getMutexList(_cmd, *it)); 124 | } 125 | 126 | std::cout << std::endl; 127 | } 128 | 129 | inline void ZshCompletionOutput::failure( CmdLineInterface& _cmd, 130 | ArgException& e ) 131 | { 132 | static_cast(_cmd); // unused 133 | std::cout << e.what() << std::endl; 134 | } 135 | 136 | inline void ZshCompletionOutput::quoteSpecialChars( std::string& s ) 137 | { 138 | size_t idx = s.find_last_of(':'); 139 | while ( idx != std::string::npos ) 140 | { 141 | s.insert(idx, 1, '\\'); 142 | idx = s.find_last_of(':', idx); 143 | } 144 | idx = s.find_last_of('\''); 145 | while ( idx != std::string::npos ) 146 | { 147 | s.insert(idx, "'\\'"); 148 | if (idx == 0) 149 | idx = std::string::npos; 150 | else 151 | idx = s.find_last_of('\'', --idx); 152 | } 153 | } 154 | 155 | inline void ZshCompletionOutput::basename( std::string& s ) 156 | { 157 | size_t p = s.find_last_of('/'); 158 | if ( p != std::string::npos ) 159 | { 160 | s.erase(0, p + 1); 161 | } 162 | } 163 | 164 | inline void ZshCompletionOutput::printArg(Arg* a) 165 | { 166 | static int count = 1; 167 | 168 | std::cout << " \\" << std::endl << " '"; 169 | if ( a->acceptsMultipleValues() ) 170 | std::cout << '*'; 171 | else 172 | std::cout << count++; 173 | std::cout << ':'; 174 | if ( !a->isRequired() ) 175 | std::cout << ':'; 176 | 177 | std::cout << a->getName() << ':'; 178 | std::map::iterator compArg = common.find(a->getName()); 179 | if ( compArg != common.end() ) 180 | { 181 | std::cout << compArg->second; 182 | } 183 | else 184 | { 185 | std::cout << "_guard \"^-*\" " << a->getName(); 186 | } 187 | std::cout << '\''; 188 | } 189 | 190 | inline void ZshCompletionOutput::printOption(Arg* a, std::string mutex) 191 | { 192 | std::string flag = a->flagStartChar() + a->getFlag(); 193 | std::string name = a->nameStartString() + a->getName(); 194 | std::string desc = a->getDescription(); 195 | 196 | // remove full stop and capitalisation from description as 197 | // this is the convention for zsh function 198 | if (!desc.compare(0, 12, "(required) ")) 199 | { 200 | desc.erase(0, 12); 201 | } 202 | if (!desc.compare(0, 15, "(OR required) ")) 203 | { 204 | desc.erase(0, 15); 205 | } 206 | size_t len = desc.length(); 207 | if (len && desc.at(--len) == '.') 208 | { 209 | desc.erase(len); 210 | } 211 | if (len) 212 | { 213 | desc.replace(0, 1, 1, tolower(desc.at(0))); 214 | } 215 | 216 | std::cout << " \\" << std::endl << " '" << mutex; 217 | 218 | if ( a->getFlag().empty() ) 219 | { 220 | std::cout << name; 221 | } 222 | else 223 | { 224 | std::cout << "'{" << flag << ',' << name << "}'"; 225 | } 226 | if ( theDelimiter == '=' && a->isValueRequired() ) 227 | std::cout << "=-"; 228 | quoteSpecialChars(desc); 229 | std::cout << '[' << desc << ']'; 230 | 231 | if ( a->isValueRequired() ) 232 | { 233 | std::string arg = a->shortID(); 234 | arg.erase(0, arg.find_last_of(theDelimiter) + 1); 235 | if ( arg.at(arg.length()-1) == ']' ) 236 | arg.erase(arg.length()-1); 237 | if ( arg.at(arg.length()-1) == ']' ) 238 | { 239 | arg.erase(arg.length()-1); 240 | } 241 | if ( arg.at(0) == '<' ) 242 | { 243 | arg.erase(arg.length()-1); 244 | arg.erase(0, 1); 245 | } 246 | size_t p = arg.find('|'); 247 | if ( p != std::string::npos ) 248 | { 249 | do 250 | { 251 | arg.replace(p, 1, 1, ' '); 252 | } 253 | while ( (p = arg.find_first_of('|', p)) != std::string::npos ); 254 | quoteSpecialChars(arg); 255 | std::cout << ": :(" << arg << ')'; 256 | } 257 | else 258 | { 259 | std::cout << ':' << arg; 260 | std::map::iterator compArg = common.find(arg); 261 | if ( compArg != common.end() ) 262 | { 263 | std::cout << ':' << compArg->second; 264 | } 265 | } 266 | } 267 | 268 | std::cout << '\''; 269 | } 270 | 271 | inline std::string ZshCompletionOutput::getMutexList( CmdLineInterface& _cmd, Arg* a) 272 | { 273 | XorHandler xorHandler = _cmd.getXorHandler(); 274 | std::vector< std::vector > xorList = xorHandler.getXorList(); 275 | 276 | if (a->getName() == "help" || a->getName() == "version") 277 | { 278 | return "(-)"; 279 | } 280 | 281 | std::ostringstream list; 282 | if ( a->acceptsMultipleValues() ) 283 | { 284 | list << '*'; 285 | } 286 | 287 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 288 | { 289 | for ( ArgVectorIterator it = xorList[i].begin(); 290 | it != xorList[i].end(); 291 | it++) 292 | if ( a == (*it) ) 293 | { 294 | list << '('; 295 | for ( ArgVectorIterator iu = xorList[i].begin(); 296 | iu != xorList[i].end(); 297 | iu++ ) 298 | { 299 | bool notCur = (*iu) != a; 300 | bool hasFlag = !(*iu)->getFlag().empty(); 301 | if ( iu != xorList[i].begin() && (notCur || hasFlag) ) 302 | list << ' '; 303 | if (hasFlag) 304 | list << (*iu)->flagStartChar() << (*iu)->getFlag() << ' '; 305 | if ( notCur || hasFlag ) 306 | list << (*iu)->nameStartString() << (*iu)->getName(); 307 | } 308 | list << ')'; 309 | return list.str(); 310 | } 311 | } 312 | 313 | // wasn't found in xor list 314 | if (!a->getFlag().empty()) { 315 | list << "(" << a->flagStartChar() << a->getFlag() << ' ' << 316 | a->nameStartString() << a->getName() << ')'; 317 | } 318 | 319 | return list.str(); 320 | } 321 | 322 | } //namespace TCLAP 323 | #endif 324 | -------------------------------------------------------------------------------- /luaGenerator.bat: -------------------------------------------------------------------------------- 1 | REM call luaGenerator.bat %model% %volumic% %nozzle% %layer% %filament% %ironing% 2 | 3 | @echo off 4 | @echo set_setting_value('printer', 'curvi')> settings.lua 5 | 6 | @echo set_setting_value('filament_diameter_mm_0', %5)>> settings.lua 7 | @echo set_setting_value('nozzle_diameter_mm_0', %3)>> settings.lua 8 | @echo set_setting_value('z_layer_height_mm', %4)>> settings.lua 9 | @echo set_setting_value('gcode_volumic', %2)>> settings.lua 10 | 11 | @echo emit(load('%1/after.stl'))>> settings.lua 12 | 13 | @echo set_service('FilamentSlicer')>> settings.lua 14 | @echo run_service('%1.gcode')>> settings.lua 15 | -------------------------------------------------------------------------------- /luaGenerator.sh: -------------------------------------------------------------------------------- 1 | #luaGenerator.sh %model% %volumic% %nozzle% %layer% %filament% %ironing% 2 | 3 | echo "set_setting_value('printer', 'curvi')"> settings.lua 4 | 5 | echo "set_setting_value('filament_diameter_mm_0', $5)">> settings.lua 6 | echo "set_setting_value('nozzle_diameter_mm_0', $3)">> settings.lua 7 | echo "set_setting_value('z_layer_height_mm', $4)">> settings.lua 8 | echo "set_setting_value('gcode_volumic', $2)">> settings.lua 9 | 10 | echo "emit(load('$1/after.stl'))">> settings.lua 11 | 12 | echo "set_service('FilamentSlicer')">> settings.lua 13 | echo "run_service('$1.gcode')">> settings.lua 14 | -------------------------------------------------------------------------------- /models/FoilCutter.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/models/FoilCutter.stl -------------------------------------------------------------------------------- /models/airfoil.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/models/airfoil.stl -------------------------------------------------------------------------------- /models/anklebase_small.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/models/anklebase_small.stl -------------------------------------------------------------------------------- /models/car_med.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/models/car_med.stl -------------------------------------------------------------------------------- /models/wing.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/models/wing.stl -------------------------------------------------------------------------------- /pack_release.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set zip_name=curvislice 4 | 5 | set bin_folder="bin" 6 | set icesl_folder="tools/icesl" 7 | set tetwild_folder="tools/tetwild-windows" 8 | set profile_folder="resources/curvi" 9 | set models_folder="models" 10 | 11 | set curvi_script="curvislice.bat" 12 | set lua_script="luaGenerator.bat" 13 | set grb_script="optimize_grb.bat" 14 | set osqp_script="optimize_osqp.bat" 15 | set tetmesh_script="toTetmesh.bat" 16 | 17 | set _7zip="C:\Program Files\7-Zip\7z.exe" 18 | 19 | echo Zipping ... 20 | 21 | %_7zip% a -tzip "%zip_name%.zip" %bin_folder% %icesl_folder% %tetwild_folder% %profile_folder% %models_folder% %curvi_script% %lua_script% %grb_script% %osqp_script% %tetmesh_script% 22 | 23 | echo Done ! 24 | echo Release Zip is %zip_name%.zip -------------------------------------------------------------------------------- /resources/ankle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/resources/ankle.png -------------------------------------------------------------------------------- /resources/car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/resources/car.png -------------------------------------------------------------------------------- /resources/curvi/features.lua: -------------------------------------------------------------------------------- 1 | version = 2 2 | 3 | bed_size_x_mm = 220 4 | bed_size_y_mm = 220 5 | bed_size_z_mm = 240 6 | nozzle_diameter_mm_0 = 0.4 7 | 8 | extruder_count = 1 9 | 10 | z_offset = 0.0 11 | 12 | priming_mm_per_sec = 40 13 | 14 | z_layer_height_mm_min = 0.01 15 | z_layer_height_mm_max = 10.0 16 | 17 | print_speed_mm_per_sec_min = 5 18 | print_speed_mm_per_sec_max = 80 19 | 20 | bed_temp_degree_c = 50 21 | bed_temp_degree_c_min = 0 22 | bed_temp_degree_c_max = 120 23 | 24 | perimeter_print_speed_mm_per_sec_min = 5 25 | perimeter_print_speed_mm_per_sec_max = 80 26 | 27 | first_layer_print_speed_mm_per_sec = 10 28 | first_layer_print_speed_mm_per_sec_min = 1 29 | first_layer_print_speed_mm_per_sec_max = 80 30 | 31 | for i=0,63,1 do 32 | _G['filament_diameter_mm_'..i] = 1.75 33 | _G['filament_priming_mm_'..i] = 4.0 34 | _G['extruder_temp_degree_c_' ..i] = 210 35 | _G['extruder_temp_degree_c_'..i..'_min'] = 150 36 | _G['extruder_temp_degree_c_'..i..'_max'] = 270 37 | _G['extruder_mix_count_'..i] = 1 38 | end 39 | 40 | add_checkbox_setting('gcode_volumic','volumic') 41 | -------------------------------------------------------------------------------- /resources/curvi/printer.lua: -------------------------------------------------------------------------------- 1 | version = 2 2 | 3 | function comment(text) 4 | output('; ' .. text) 5 | end 6 | 7 | extruder_e = 0 8 | extruder_e_restart = 0 9 | 10 | function prep_extruder(extruder) 11 | end 12 | 13 | function header() 14 | output('o X ' .. gcode_to_model_x .. ' Y ' .. gcode_to_model_y .. ' Z ' .. gcode_to_model_z) 15 | output('t ' .. z_layer_height_mm) 16 | end 17 | 18 | function footer() 19 | end 20 | 21 | function layer_start(zheight) 22 | output(';()') 23 | if layer_id == 0 then 24 | output('G0 F600 Z' .. ff(zheight)) 25 | else 26 | output('G0 F100 Z' .. ff(zheight)) 27 | end 28 | -- output('G1 Z' .. f(zheight)) 29 | end 30 | 31 | function layer_stop() 32 | comment('') 33 | end 34 | 35 | function retract(extruder,e) 36 | -- speed = priming_mm_per_sec * 60; 37 | -- letter = 'E' 38 | -- output('G1 F' .. speed .. ' ' .. letter .. f(e - len - extruder_e_restart)) 39 | output('R') 40 | return e 41 | end 42 | 43 | function prime(extruder,e) 44 | -- speed = priming_mm_per_sec * 60; 45 | -- letter = 'E' 46 | -- output('G1 F' .. speed .. ' ' .. letter .. f(e + len - extruder_e_restart)) 47 | output('P') 48 | return e 49 | end 50 | 51 | current_extruder = 0 52 | current_frate = 0 53 | 54 | function select_extruder(extruder) 55 | end 56 | 57 | function swap_extruder(from,to,x,y,z) 58 | end 59 | 60 | function move_xyz(x,y,z) 61 | output('G1 X' .. f(x) .. ' Y' .. f(y) .. ' Z' .. f(z+z_offset)) 62 | end 63 | 64 | function move_xyze(x,y,z,e) 65 | to_mm_cube = 1.0 66 | if gcode_ultimaker2 then 67 | r = filament_diameter_mm[extruders[0]] / 2 68 | to_mm_cube = 3.14159 * r * r 69 | end 70 | if traveling == 1 then 71 | traveling = 0 -- start path 72 | if path_is_perimeter then output(';perimeter') 73 | elseif path_is_shell then output(';shell') 74 | elseif path_is_infill then output(';infill') 75 | elseif path_is_raft then output(';raft') 76 | elseif path_is_brim then output(';brim') 77 | elseif path_is_shield then output(';shield') 78 | elseif path_is_support then output(';support') 79 | elseif path_is_tower then output(';tower') 80 | elseif path_is_ironing then output(';ironing') 81 | end 82 | end 83 | 84 | extruder_e = e 85 | letter = 'E' 86 | instr = 'G' 87 | if path_is_ironing then 88 | instr = 'I' 89 | end 90 | if z == current_z then 91 | output(instr .. '1 F' .. f(current_frate) .. ' X' .. f(x) .. ' Y' .. f(y) .. ' ' .. letter .. ff((e-extruder_e_restart)*to_mm_cube)) 92 | else 93 | output(instr .. '1 F' .. f(current_frate) .. ' X' .. f(x) .. ' Y' .. f(y) .. ' Z' .. ff(z) .. ' ' .. letter .. ff((e-extruder_e_restart)*to_mm_cube)) 94 | current_z = z 95 | end 96 | end 97 | 98 | function move_e(e) 99 | to_mm_cube = 1.0 100 | if gcode_ultimaker2 then 101 | r = filament_diameter_mm[extruders[0]] / 2 102 | to_mm_cube = 3.14159 * r * r 103 | end 104 | extruder_e = e 105 | letter = 'E' 106 | output('G1 ' .. letter .. f((e - extruder_e_restart)*to_mm_cube)) 107 | end 108 | 109 | function set_feedrate(feedrate) 110 | current_frate = feedrate 111 | end 112 | 113 | function extruder_start() 114 | end 115 | 116 | function extruder_stop() 117 | end 118 | 119 | function progress(percent) 120 | end 121 | 122 | function set_extruder_temperature(extruder,temperature) 123 | end 124 | 125 | function set_fan_speed(speed) 126 | end 127 | -------------------------------------------------------------------------------- /resources/nozzle-clearance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/resources/nozzle-clearance.jpg -------------------------------------------------------------------------------- /resources/wing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/resources/wing.png -------------------------------------------------------------------------------- /src/MeshFormat_msh.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This work and all associated files are under the 3 | 4 | GNU AFFERO GENERAL PUBLIC LICENSE 5 | Version 3, 19 November 2007 6 | 7 | A copy of the license full text is included in 8 | the distribution, please refer to it for details. 9 | 10 | (c) Jimmy Etienne and Sylvain Lefebvre 11 | */ 12 | 13 | //--------------------------------------------------------------------------- 14 | #include "LibSL.precompiled.h" 15 | //--------------------------------------------------------------------------- 16 | 17 | #include "MeshFormat_msh.h" 18 | using namespace LibSL::Mesh; 19 | 20 | #include 21 | using namespace LibSL::Errors; 22 | #include 23 | using namespace LibSL::Memory::Array; 24 | #include 25 | using namespace LibSL::Memory::Pointer; 26 | #include 27 | using namespace LibSL::Math; 28 | #include 29 | using namespace LibSL::CppHelpers; 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | //--------------------------------------------------------------------------- 37 | 38 | #define NAMESPACE LibSL::Mesh 39 | 40 | //--------------------------------------------------------------------------- 41 | 42 | /// Declaring a global will automatically register the plugin 43 | namespace { 44 | NAMESPACE::MeshFormat_msh s_Msh; /// FIXME: this mechanism does not work with VC++ 45 | } /// see also MeshFormatManager constructor 46 | 47 | //--------------------------------------------------------------------------- 48 | 49 | NAMESPACE::MeshFormat_msh::MeshFormat_msh() 50 | { 51 | try { 52 | // register plugin 53 | MESH_FORMAT_MANAGER.registerPlugin(this); 54 | } catch (LibSL::Errors::Fatal& e) { 55 | std::cerr << e.message() << std::endl; 56 | } 57 | } 58 | 59 | //--------------------------------------------------------------------------- 60 | 61 | using namespace std; 62 | 63 | //--------------------------------------------------------------------------- 64 | 65 | void parseWhiteSpace(ifstream& stream) { 66 | char next = stream.peek(); 67 | while (next == '\n' || next == ' ' || next == '\t' || next == '\r') { 68 | stream.get(); 69 | next = stream.peek(); 70 | } 71 | } 72 | 73 | void parseMeshFormat(ifstream& stream, MeshFormat_msh::msh_format_info& format) { 74 | stream >> format.version_number; 75 | parseWhiteSpace(stream); 76 | stream >> format.binary; 77 | parseWhiteSpace(stream); 78 | stream >> format.data_size; 79 | parseWhiteSpace(stream); 80 | 81 | if (format.binary) { // binary 82 | int check = 1; 83 | stream.read(reinterpret_cast(&check), sizeof(int)); 84 | sl_assert(check == 1); // make sure the file is compatible (little or big endian) 85 | } 86 | } 87 | 88 | void parsePhysicalNames(ifstream& stream, MeshFormat_msh::msh_format_info& format) 89 | { 90 | } 91 | 92 | void parseNodes(ifstream& stream, MeshFormat_msh::msh_format_info& format) 93 | { 94 | uint nb_nodes; 95 | stream >> nb_nodes; 96 | parseWhiteSpace(stream); 97 | 98 | int num_i; 99 | double xyz[3]; 100 | 101 | if (format.binary) { 102 | ForIndex(i, nb_nodes) { 103 | stream.read(reinterpret_cast(&num_i), sizeof(int)); 104 | stream.read(reinterpret_cast(&xyz), sizeof(xyz)); 105 | format.nodes.emplace_back(v3f(xyz[0], xyz[1], xyz[2])); 106 | } 107 | } else { 108 | ForIndex (i, nb_nodes) { 109 | char trash; 110 | stream >> num_i; 111 | stream >> xyz[0] >> trash >> xyz[1] >> trash >> xyz[2]; 112 | parseWhiteSpace(stream); 113 | } 114 | } 115 | } 116 | 117 | void parseElements(ifstream& stream, MeshFormat_msh::msh_format_info& format) 118 | { 119 | uint nb_elements; 120 | stream >> nb_elements; 121 | parseWhiteSpace(stream); 122 | 123 | int header[3]; 124 | uint nb_elems = 0; 125 | while (nb_elems < nb_elements) 126 | { 127 | 128 | if (format.binary) { 129 | stream.read(reinterpret_cast(&header), sizeof(header)); 130 | } else { 131 | stream >> header[0]; 132 | parseWhiteSpace(stream); 133 | } 134 | 135 | int elem_size = 0; 136 | 137 | switch (header[0]) { 138 | case 1: // 2-node line 139 | break; 140 | case 2: // 3-node triangle 141 | elem_size = 3; 142 | break; 143 | case 3: // 4-node quadrangle 144 | elem_size = 4; 145 | break; 146 | case 4: // 4-node tetrahedron 147 | elem_size = 4; 148 | break; 149 | case 5: // 8-node hexahedron 150 | break; 151 | case 6: 152 | break; 153 | } 154 | 155 | for (int elem = 0; elem < header[1]; elem++) { 156 | for (int tag = 0; tag < header[2]; tag++) { 157 | int data; 158 | stream.read(reinterpret_cast(&data), sizeof(data)); 159 | } 160 | int num_i; 161 | stream.read(reinterpret_cast(&num_i), sizeof(num_i)); 162 | 163 | int data[4]; 164 | stream.read(reinterpret_cast(&data), sizeof(data)); 165 | vector elems; 166 | 167 | ForIndex (i, elem_size) { 168 | elems.emplace_back(data[i]); 169 | } 170 | format.elements.emplace_back(elems); 171 | } 172 | nb_elems += header[1]; 173 | } 174 | } 175 | 176 | void parseElementData(ifstream& stream, MeshFormat_msh::msh_format_info& format) { 177 | MeshFormat_msh::msh_entity_data element; 178 | 179 | { 180 | uint nb_string_tags; 181 | stream >> nb_string_tags; 182 | std::string tag; 183 | ForIndex(i, nb_string_tags) { 184 | string str; 185 | do { 186 | stream >> str; 187 | tag += (tag.empty() ? "" : " ") + str; 188 | } while (str.at(str.size() - 1) != '\"'); 189 | ; 190 | element.string_tags.emplace_back(tag); 191 | parseWhiteSpace(stream); 192 | } 193 | } 194 | { 195 | uint nb_real_tags; 196 | stream >> nb_real_tags; 197 | float tag; 198 | ForIndex(i, nb_real_tags) { 199 | stream >> tag; 200 | element.real_tags.emplace_back(tag); 201 | parseWhiteSpace(stream); 202 | } 203 | } 204 | { 205 | uint nb_int_tags; 206 | stream >> nb_int_tags; 207 | int tag; 208 | ForIndex(i, nb_int_tags) { 209 | stream >> tag; 210 | element.integer_tags.emplace_back(tag); 211 | parseWhiteSpace(stream); 212 | } 213 | } 214 | 215 | size_t nb_values = element.integer_tags[1]; 216 | size_t nb_elems = element.integer_tags[2]; 217 | 218 | size_t num_bytes = (nb_values * format.data_size + 4) * nb_elems; 219 | char* data = new char[num_bytes]; 220 | stream.read(data, num_bytes); 221 | 222 | 223 | ForIndex(i, nb_elems) { 224 | size_t base_idx = i * (4 + nb_values * format.data_size); 225 | int elem = (*reinterpret_cast(&data[base_idx])) - 1; 226 | base_idx += 4; 227 | 228 | vector values(nb_values); 229 | ForIndex(j, nb_values) { 230 | values[j] = (*reinterpret_cast(&data[base_idx + j * format.data_size])); 231 | } 232 | element.values.emplace(elem, values); 233 | } 234 | format.element_data.emplace_back(element); 235 | } 236 | 237 | 238 | 239 | 240 | void parseNodeData(ifstream& stream, MeshFormat_msh::msh_format_info& format) { 241 | MeshFormat_msh::msh_entity_data node_data; 242 | 243 | { 244 | uint nb_string_tags; 245 | stream >> nb_string_tags; 246 | std::string tag; 247 | ForIndex(i, nb_string_tags) { 248 | string str; 249 | do { 250 | stream >> str; 251 | tag += (tag.empty() ? "" : " ") + str; 252 | } while (str.at(str.size() - 1) != '\"'); 253 | ; 254 | node_data.string_tags.emplace_back(tag); 255 | parseWhiteSpace(stream); 256 | } 257 | } 258 | { 259 | uint nb_real_tags; 260 | stream >> nb_real_tags; 261 | float tag; 262 | ForIndex(i, nb_real_tags) { 263 | stream >> tag; 264 | node_data.real_tags.emplace_back(tag); 265 | parseWhiteSpace(stream); 266 | } 267 | } 268 | { 269 | uint nb_int_tags; 270 | stream >> nb_int_tags; 271 | int tag; 272 | ForIndex(i, nb_int_tags) { 273 | stream >> tag; 274 | node_data.integer_tags.emplace_back(tag); 275 | parseWhiteSpace(stream); 276 | } 277 | } 278 | 279 | size_t nb_values = node_data.integer_tags[1]; 280 | size_t nb_nodes = node_data.integer_tags[2]; 281 | 282 | size_t num_bytes = (nb_values * format.data_size + 4) * nb_nodes; 283 | char* data = new char[num_bytes]; 284 | stream.read(data, num_bytes); 285 | 286 | ForIndex (i, nb_nodes) { 287 | int node = *reinterpret_cast(&data[i*(4 + nb_values * format.data_size)]); 288 | node -= 1; 289 | size_t base_idx = i * (4 + nb_values * format.data_size) + 4; 290 | 291 | vector values(nb_values); 292 | ForIndex (j, nb_values) { 293 | values[j] = (*reinterpret_cast(&data[base_idx + j * format.data_size])); 294 | } 295 | 296 | node_data.values.emplace(node, values); 297 | } 298 | 299 | format.node_data.emplace_back(node_data); 300 | } 301 | //--------------------------------------------------------------------------- 302 | 303 | void NAMESPACE::MeshFormat_msh::parse(const char *fname) 304 | { 305 | LIBSL_BEGIN; 306 | // open file 307 | FILE *f = NULL; 308 | fopen_s(&f, fname, "rb"); 309 | if (f == NULL) { 310 | throw Fatal("[MeshFormat_msh::load] - file '%s' not found", fname); 311 | } 312 | 313 | ifstream stream(fname, ios::binary); 314 | 315 | std::string blockname, blockend; 316 | while (!stream.eof()) { 317 | stream >> blockname; 318 | 319 | if (blockname == "$MeshFormat") { 320 | parseMeshFormat(stream, m_format); 321 | stream >> blockend; 322 | sl_assert(blockend == "$EndMeshFormat"); 323 | } else if (blockname == "$PhysicalNames") { 324 | parsePhysicalNames(stream, m_format); 325 | stream >> blockend; 326 | sl_assert(blockend == "$EndPhysicalNames"); 327 | } else if (blockname == "$Nodes") { 328 | parseNodes(stream, m_format); 329 | stream >> blockend; 330 | sl_assert(blockend == "$EndNodes"); 331 | } else if (blockname == "$Elements") { 332 | parseElements(stream, m_format); 333 | stream >> blockend; 334 | sl_assert(blockend == "$EndElements"); 335 | } else if (blockname == "$ElementData") { 336 | parseElementData(stream, m_format); 337 | stream >> blockend; 338 | sl_assert(blockend == "$EndElementData"); 339 | } else if (blockname == "$NodeData") { 340 | parseNodeData(stream, m_format); 341 | stream >> blockend; 342 | sl_assert(blockend == "$EndNodeData"); 343 | } else { 344 | cerr << "Unknown block : " << blockname << endl; 345 | // TODO: READ UNTIL END OF BLOCK 346 | stream >> blockend; 347 | sl_assert(blockend == "$End" + blockname.substr(1, blockname.size() - 1)); 348 | } 349 | parseWhiteSpace(stream); 350 | } 351 | fclose(f); 352 | LIBSL_END; 353 | } 354 | 355 | 356 | NAMESPACE::TriangleMesh* NAMESPACE::MeshFormat_msh::load(const char *fname) const 357 | { 358 | MeshFormat_msh msh; 359 | msh.parse(fname); 360 | 361 | msh_format_info format = msh.m_format; 362 | 363 | set tris; 364 | map srfTris; 365 | 366 | // faces 367 | uint fi = 0; 368 | ForArray(format.elements, n_tet) { // TODO: manage non tet 369 | ForIndex(off, 4) { 370 | uint A = format.elements.at(n_tet)[(off + 0) % 4] - 1; 371 | uint B = format.elements.at(n_tet)[(off + 1) % 4] - 1; 372 | uint C = format.elements.at(n_tet)[(off + 2) % 4] - 1; 373 | 374 | if (A > B) std::swap(A, B); 375 | if (B > C) std::swap(B, C); 376 | if (A > B) std::swap(A, B); 377 | 378 | // extract the surface 379 | v3u t(A, B, C); 380 | 381 | auto it_ = tris.find(t); 382 | if (it_ == tris.end()) { 383 | tris.insert(t); 384 | 385 | fi++; 386 | } 387 | 388 | auto it = srfTris.find(t); 389 | if (it == srfTris.end()) { 390 | srfTris.insert_or_assign(t, fi); 391 | } else { 392 | srfTris.erase(it); 393 | } 394 | 395 | } 396 | } 397 | 398 | TriangleMesh_generic *mesh 399 | = new TriangleMesh_generic(format.nodes.size(), tris.size(), 1 , AutoPtr(MVF::make())); 400 | 401 | //vertices 402 | ForArray (format.nodes, n_ver) { 403 | v3f pos = format.nodes.at(n_ver); 404 | mesh->vertexAt(n_ver).pos = pos; 405 | } 406 | 407 | // tris 408 | fi = 0; 409 | for (auto it : tris) { 410 | mesh->triangleAt(fi) = it; 411 | fi++; 412 | } 413 | 414 | //surface tris 415 | uint si = 0; 416 | TriangleMesh::t_SurfaceNfo srf; 417 | srf.triangleIds.allocate(srfTris.size()); 418 | for(auto it : srfTris) { 419 | srf.triangleIds[si] = it.second; 420 | si++; 421 | } 422 | mesh->surfaceAt(0) = srf; 423 | 424 | // done 425 | return mesh; 426 | } 427 | 428 | //--------------------------------------------------------------------------- 429 | 430 | void NAMESPACE::MeshFormat_msh::save(const char *fname,const NAMESPACE::TriangleMesh *mesh) const 431 | { 432 | } 433 | 434 | //--------------------------------------------------------------------------- 435 | -------------------------------------------------------------------------------- /src/MeshFormat_msh.h: -------------------------------------------------------------------------------- 1 | /* 2 | This work and all associated files are under the 3 | 4 | GNU AFFERO GENERAL PUBLIC LICENSE 5 | Version 3, 19 November 2007 6 | 7 | A copy of the license full text is included in 8 | the distribution, please refer to it for details. 9 | 10 | (c) Jimmy Etienne and Sylvain Lefebvre 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace LibSL { 20 | namespace Mesh { 21 | 22 | class MeshFormat_msh : public TriangleMeshFormat_plugin 23 | { 24 | 25 | public: 26 | typedef struct 27 | { 28 | LibSL::Math::v3f pos; 29 | LibSL::Math::v3f nrm; 30 | } t_VertexData; 31 | 32 | typedef MVF2(mvf_position_3f, mvf_normal_3f) t_VertexFormat; 33 | 34 | typedef struct 35 | { 36 | std::vector string_tags; // [name of the post-processing view, name of the interpolation scheme, ???] 37 | std::vector real_tags; // [time value, ???] 38 | std::vector integer_tags; // [time step index, number of field components (1, 3 or 9), number of entities, partition index, ???] 39 | 40 | std::map> values; // entity number : [value1, value2, ...] 41 | 42 | } msh_entity_data; 43 | 44 | 45 | typedef struct 46 | { 47 | std::vector string_tags; // [name of the post-processing view, name of the interpolation scheme, ???] 48 | std::vector real_tags; // [time value, ???] 49 | std::vector integer_tags; // [time step index, number of field components (1, 3 or 9), number of elements, partition index, ???] 50 | 51 | std::map>> values; // element number : 52 | 53 | } msh_element_node_data; 54 | 55 | 56 | typedef struct 57 | { 58 | float version_number; 59 | bool binary; // 0 = ASCII, 1 = binary 60 | 61 | uint data_size = 0; 62 | uint number_of_nodes_per_element; 63 | uint element_type; 64 | 65 | std::vector nodes; 66 | std::vector> elements; 67 | 68 | std::vector node_data; 69 | std::vector element_data; 70 | std::vector element_node_data; 71 | 72 | } msh_format_info; 73 | 74 | public: 75 | MeshFormat_msh(); 76 | void parse(const char *); 77 | void save(const char *,const TriangleMesh *) const; 78 | TriangleMesh *load(const char *) const; 79 | const char *signature() const {return "msh";} 80 | 81 | public: 82 | mutable std::vector m_meshes; 83 | mutable std::vector> m_surfaces; 84 | msh_format_info m_format; 85 | }; 86 | 87 | } //namespace LibSL::Mesh 88 | } //namespace LibSL 89 | 90 | // ------------------------------------------------------ 91 | -------------------------------------------------------------------------------- /src/TetMesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | This work and all associated files are under the 3 | 4 | GNU AFFERO GENERAL PUBLIC LICENSE 5 | Version 3, 19 November 2007 6 | 7 | A copy of the license full text is included in 8 | the distribution, please refer to it for details. 9 | 10 | (c) Jimmy Etienne and Sylvain Lefebvre 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "MeshFormat_msh.h" 23 | 24 | using namespace LibSL::Math; 25 | using namespace std; 26 | 27 | 28 | typedef Tuple M3x3; 29 | 30 | class TetMesh 31 | { 32 | private : 33 | AutoPtr m_mesh; 34 | 35 | vector> m_tetrahedrons; 36 | vector m_vertices; 37 | vector m_triangles; 38 | vector m_surfaces; 39 | 40 | map> m_tet_neighborhood; 41 | map> m_tri_neighborhood; 42 | map> m_ver_to_tris; 43 | public: 44 | TetMesh(); 45 | TetMesh(TetMesh*); 46 | ~TetMesh(); 47 | 48 | static TetMesh* load(const char *fname); 49 | static void save(const char *fname, TetMesh *mesh); 50 | 51 | size_t numVertices(); 52 | v3f& vertexAt(uint n); 53 | 54 | size_t numTetrahedrons(); 55 | bool isInside(uint t); 56 | v4u& tetrahedronAt(uint t); 57 | vector& tet_neighbours(uint t); 58 | vector& tri_neighbours(uint t); 59 | vector ver_neighbours(uint t); 60 | 61 | uint getTetrahedronSurface(uint t); 62 | 63 | size_t numTriangles(); 64 | v3u& triangleAt(uint t); 65 | 66 | size_t numSurfaces(); 67 | v3u& surfaceTriangleAt(uint s); 68 | 69 | 70 | M3x3 getGradientMatrix(uint t); 71 | AABox getBBox(); 72 | 73 | void reorientSurface(); 74 | 75 | }; 76 | -------------------------------------------------------------------------------- /src/config.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SRC_PATH "@CMAKE_SOURCE_DIR@" 4 | -------------------------------------------------------------------------------- /src/gcode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This work and all associated files are under the 3 | 4 | GNU AFFERO GENERAL PUBLIC LICENSE 5 | Version 3, 19 November 2007 6 | 7 | A copy of the license full text is included in 8 | the distribution, please refer to it for details. 9 | 10 | (c) Jimmy Etienne and Sylvain Lefebvre 11 | */ 12 | 13 | #include "gcode.h" 14 | 15 | // -------------------------------------------------------------- 16 | 17 | typedef LibSL::BasicParser::BufferStream t_stream; 18 | typedef LibSL::BasicParser::Parser t_parser; 19 | typedef AutoPtr t_stream_ptr; 20 | typedef AutoPtr t_parser_ptr; 21 | 22 | // -------------------------------------------------------------- 23 | 24 | t_stream_ptr g_Stream; 25 | t_parser_ptr g_Parser; 26 | 27 | v4f g_Pos(0.0f); 28 | v4f g_Offset(0.0f); 29 | float g_Speed = 20.0f; 30 | int g_Line = 0; 31 | const char *g_GCode = NULL; 32 | bool g_GCodeError = false; 33 | bool g_DoPrime = false; 34 | bool g_DoRetract = false; 35 | bool g_Ironing = false; 36 | float g_LayerThickness = -1.0f; 37 | v3f g_GCodeOffset(0.0f); 38 | 39 | // -------------------------------------------------------------- 40 | 41 | void gcode_start(const char *gcode) 42 | { 43 | g_GCode = gcode; 44 | g_Stream = t_stream_ptr(new t_stream(g_GCode,(uint)strlen(g_GCode)+1)); 45 | g_Parser = t_parser_ptr(new t_parser(*g_Stream,false)); 46 | g_Pos = 0.0f; 47 | g_Offset = 0.0f; 48 | g_Speed = 20.0f; 49 | g_Line = 0; 50 | g_GCodeError = false; 51 | g_DoPrime = false; 52 | g_DoRetract = false; 53 | g_LayerThickness = -1.0f; 54 | 55 | int c; 56 | while (!g_Parser->eof()) { 57 | g_Line++; 58 | 59 | c = g_Parser->readChar(); 60 | c = tolower(c); 61 | if (c == 'o') { 62 | while (!g_Parser->eof()) { 63 | c = g_Parser->readChar(); 64 | if (c == '\n') break; 65 | if (c == ';') { 66 | g_Parser->reachChar('\n'); 67 | break; 68 | } 69 | c = tolower(c); 70 | float f = g_Parser->readFloat(); 71 | if (c >= 'x' && c <= 'z') { 72 | g_GCodeOffset[c - 'x'] = f; 73 | } 74 | } 75 | // break; 76 | } 77 | if (c == 't') { 78 | g_LayerThickness = g_Parser->readFloat(); 79 | // done with header! 80 | g_Parser->reachChar('\n'); 81 | break; 82 | } 83 | } 84 | } 85 | 86 | // -------------------------------------------------------------- 87 | 88 | void gcode_reset() 89 | { 90 | sl_assert(g_GCode != NULL); 91 | g_Stream = t_stream_ptr(new t_stream(g_GCode, (uint)strlen(g_GCode) + 1)); 92 | g_Parser = t_parser_ptr(new t_parser(*g_Stream, false)); 93 | g_Pos = 0.0f; 94 | g_Offset = 0.0f; 95 | g_Speed = 20.0f; 96 | g_Line = 0; 97 | g_GCodeError = false; 98 | g_DoPrime = false; 99 | g_DoRetract = false; 100 | g_LayerThickness = -1.0f; 101 | } 102 | 103 | // -------------------------------------------------------------- 104 | 105 | v3f gcode_offset() 106 | { 107 | return g_GCodeOffset; 108 | } 109 | 110 | // -------------------------------------------------------------- 111 | 112 | bool gcode_advance() 113 | { 114 | if (g_GCodeError) return false; 115 | int c; 116 | g_DoPrime = false; 117 | g_DoRetract = false; 118 | while (!g_Parser->eof()) { 119 | g_Line ++; 120 | c = g_Parser->readChar(); 121 | c = tolower(c); 122 | if (c == 'p') { 123 | // prime 124 | g_Parser->reachChar('\n'); 125 | g_DoPrime = true; 126 | break; 127 | } else if (c == 'r') { 128 | // retract 129 | g_Parser->reachChar('\n'); 130 | g_DoRetract = true; 131 | break; 132 | } else if (c == 'g' || c == 'i') { // 'i' for ironing 133 | int n = g_Parser->readInt(); 134 | if (n == 0 || n == 1) { // G0 G1 135 | g_Ironing = (c == 'i'); 136 | while (!g_Parser->eof()) { 137 | c = g_Parser->readChar(); 138 | if (c == '\n') break; 139 | if (c == ';') { 140 | g_Parser->reachChar('\n'); 141 | break; 142 | } 143 | c = tolower(c); 144 | float f = g_Parser->readFloat(); 145 | if (c >= 'x' && c <= 'z') { 146 | g_Pos[c - 'x'] = f + g_Offset[c - 'x']; 147 | } else if (c == 'e') { 148 | g_Pos[3] = f + g_Offset[3]; 149 | } else if (c == 'f') { 150 | g_Speed = f / 60.0f; 151 | } else if (c >= 'a' && c <= 'f') { 152 | // TODO mixing ratios 153 | } else { 154 | g_GCodeError = true; 155 | return false; 156 | } 157 | } 158 | break; // done advancing 159 | } else if (n == 92) { // G92 160 | while (!g_Parser->eof()) { 161 | c = g_Parser->readChar(); 162 | if (c == '\n') break; 163 | c = tolower(c); 164 | float f = g_Parser->readFloat(); 165 | if (c >= 'x' && c <= 'z') { 166 | g_Offset[c - 'x'] = g_Pos[c - 'x'] - f; 167 | } else if (c == 'e') { 168 | g_Offset[3] = g_Pos[3] - f; 169 | } 170 | } 171 | } else if (n == 10) { // G10 172 | g_Parser->reachChar('\n'); 173 | } else if (n == 11) { // G11 174 | g_Parser->reachChar('\n'); 175 | } else { // other => ignore 176 | g_Parser->reachChar('\n'); 177 | } 178 | } else if (c == 'm') { 179 | int n = g_Parser->readInt(); 180 | g_Parser->reachChar('\n'); 181 | } else if (c == '\n') { 182 | // do nothing 183 | } else if (c == '<') { 184 | g_Parser->reachChar('\n'); 185 | } else if (c == ';' || c == 'o') { 186 | g_Parser->reachChar('\n'); 187 | } else if (c == '\r') { 188 | g_Parser->reachChar('\n'); 189 | } else if (c == '\0' || c == -1) { 190 | return false; 191 | } else { 192 | g_GCodeError = true; 193 | return false; 194 | } 195 | } 196 | return !g_Parser->eof(); 197 | } 198 | 199 | // -------------------------------------------------------------- 200 | 201 | v4f gcode_next_pos() 202 | { 203 | return g_Pos; 204 | } 205 | 206 | // -------------------------------------------------------------- 207 | 208 | float gcode_speed() 209 | { 210 | return g_Speed; 211 | } 212 | 213 | // -------------------------------------------------------------- 214 | 215 | int gcode_line() 216 | { 217 | return g_Line; 218 | } 219 | 220 | // -------------------------------------------------------------- 221 | 222 | bool gcode_error() 223 | { 224 | return g_GCodeError; 225 | } 226 | 227 | // -------------------------------------------------------------- 228 | 229 | bool gcode_do_prime() 230 | { 231 | return g_DoPrime; 232 | } 233 | 234 | // -------------------------------------------------------------- 235 | 236 | bool gcode_do_retract() 237 | { 238 | return g_DoRetract; 239 | } 240 | 241 | // -------------------------------------------------------------- 242 | 243 | float gcode_layer_thickness() 244 | { 245 | return g_LayerThickness; 246 | } 247 | 248 | // -------------------------------------------------------------- 249 | 250 | bool gcode_is_ironing() 251 | { 252 | return g_Ironing; 253 | } 254 | 255 | // -------------------------------------------------------------- 256 | -------------------------------------------------------------------------------- /src/gcode.h: -------------------------------------------------------------------------------- 1 | // SL 2018-07-03 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | // start interpreting the gcode 9 | void gcode_start(const char *gcode); 10 | 11 | v3f gcode_offset(); 12 | 13 | // advances to the next position 14 | // return false if none exists (end of gcode) 15 | bool gcode_advance(); 16 | 17 | // returns the next position to reach (x,y,z,e) 18 | v4f gcode_next_pos(); 19 | 20 | // returns the speed in mm/sec 21 | float gcode_speed(); 22 | 23 | // return current line in gcode stream 24 | int gcode_line(); 25 | 26 | // restart from scratch 27 | void gcode_reset(); 28 | 29 | // returns true in a reading error occured 30 | bool gcode_error(); 31 | 32 | // returns true if has to prime 33 | bool gcode_do_prime(); 34 | 35 | // returns true if has to retract 36 | bool gcode_do_retract(); 37 | 38 | // returns true if ironing is active 39 | bool gcode_is_ironing(); 40 | 41 | // returns the layer thickness 42 | float gcode_layer_thickness(); 43 | -------------------------------------------------------------------------------- /src/helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | This work and all associated files are under the 3 | 4 | GNU AFFERO GENERAL PUBLIC LICENSE 5 | Version 3, 19 November 2007 6 | 7 | A copy of the license full text is included in 8 | the distribution, please refer to it for details. 9 | 10 | (c) Jimmy Etienne and Sylvain Lefebvre 11 | */ 12 | 13 | #include 14 | // -------------------------------------------------------------- 15 | // -------------- FUNCTIONS / HELPERS ---------------------- 16 | // -------------------------------------------------------------- 17 | 18 | // ScTP computes the scalar triple product 19 | #define ScTP(a, b, c) dot(a, cross(b,c)) 20 | 21 | // -------------------------------------------------------------- 22 | 23 | float tetrahedron_signed_volume(const Tuple& tet) 24 | { 25 | v3f vab = tet[1] - tet[0]; 26 | v3f vac = tet[2] - tet[0]; 27 | v3f vad = tet[3] - tet[0]; 28 | 29 | return 1.0F / 6.0F * ScTP(vab, vac, vad); 30 | } 31 | 32 | // -------------------------------------------------------------- 33 | 34 | float tetrahedron_signed_volume(TetMesh& mesh, const v4u& tet) 35 | { 36 | return tetrahedron_signed_volume(Tuple(mesh.vertexAt(tet[0]), mesh.vertexAt(tet[1]), mesh.vertexAt(tet[2]), mesh.vertexAt(tet[3]))); 37 | } 38 | 39 | // -------------------------------------------------------------- 40 | 41 | float tetrahedron_volume(const Tuple& tet) 42 | { 43 | return abs(tetrahedron_signed_volume(tet)); 44 | } 45 | 46 | // -------------------------------------------------------------- 47 | 48 | float tetrahedron_volume(TetMesh& mesh, const v4u& tet) 49 | { 50 | return tetrahedron_volume(Tuple(mesh.vertexAt(tet[0]), mesh.vertexAt(tet[1]), mesh.vertexAt(tet[2]), mesh.vertexAt(tet[3]))); 51 | } 52 | 53 | // -------------------------------------------------------------- 54 | 55 | v4f tetrahedron_barycenter_coefs(const Tuple& tet, v3f pt) 56 | { 57 | v3f vap = pt - tet[0]; 58 | v3f vbp = pt - tet[1]; 59 | 60 | v3f vab = tet[1] - tet[0]; 61 | v3f vac = tet[2] - tet[0]; 62 | v3f vad = tet[3] - tet[0]; 63 | 64 | v3f vbc = tet[2] - tet[1]; 65 | v3f vbd = tet[3] - tet[1]; 66 | 67 | float va = 1.0F / 6.0F * ScTP(vbp, vbd, vbc); 68 | float vb = 1.0F / 6.0F * ScTP(vap, vac, vad); 69 | float vc = 1.0F / 6.0F * ScTP(vap, vad, vab); 70 | float vd = 1.0F / 6.0F * ScTP(vap, vab, vac); 71 | 72 | return v4f(va, vb, vc, vd) / tetrahedron_volume(tet); 73 | } 74 | 75 | // -------------------------------------------------------------- 76 | 77 | float triangle_area(const Tuple& tri) 78 | { 79 | v3d vab = tri[1] - tri[0]; 80 | v3d vac = tri[2] - tri[0]; 81 | 82 | float v = 1.0F / 2.0F * length(cross(vab, vac)); 83 | 84 | return abs(v); 85 | } 86 | 87 | // -------------------------------------------------------------- 88 | 89 | float triangle_area(TetMesh& mesh, const v3u& tri) 90 | { 91 | return triangle_area(Tuple(v3d(mesh.vertexAt(tri[0])), v3d(mesh.vertexAt(tri[1])), v3d(mesh.vertexAt(tri[2])))); 92 | } 93 | 94 | // -------------------------------------------------------------- 95 | 96 | float triangle_area_xy(const Tuple& tri) 97 | { 98 | v3d vab = tri[1] - tri[0]; 99 | v3d vac = tri[2] - tri[0]; 100 | vab[2] = 0.0F; vac[2] = 0.0F; 101 | float v = 1.0F / 2.0F * length(cross(vab, vac)); 102 | return abs(v); 103 | } 104 | 105 | // -------------------------------------------------------------- 106 | 107 | double triangle_area_xy(TetMesh& mesh, const v3u& tri) 108 | { 109 | return triangle_area_xy(Tuple(v3d(mesh.vertexAt(tri[0])), v3d(mesh.vertexAt(tri[1])), v3d(mesh.vertexAt(tri[2])))); 110 | } 111 | 112 | // -------------------------------------------------------------- 113 | 114 | float component_area(TetMesh& mesh, const vector& surfaces) 115 | { 116 | float area = 0.0F; 117 | for (int surface : surfaces) { 118 | area += triangle_area(mesh, mesh.surfaceTriangleAt(surface)); 119 | } 120 | return area; 121 | } 122 | 123 | // -------------------------------------------------------------- 124 | 125 | template 126 | Tuple, 3> tetrahedron_gradient(TetMesh& mesh, map& h, const Array& mats, uint t) 127 | { 128 | v4u tet = mesh.tetrahedronAt(t); 129 | 130 | T_var ha = h[tet[0]]; 131 | T_var hb = h[tet[1]]; 132 | T_var hc = h[tet[2]]; 133 | T_var hd = h[tet[3]]; 134 | 135 | SLRExpr dhdx = (ha - hd) * mats[t][0] 136 | + (hb - hd) * mats[t][1] 137 | + (hc - hd) * mats[t][2]; 138 | 139 | SLRExpr dhdy = (ha - hd) * mats[t][3] 140 | + (hb - hd) * mats[t][4] 141 | + (hc - hd) * mats[t][5]; 142 | 143 | SLRExpr dhdz = (ha - hd) * mats[t][6] 144 | + (hb - hd) * mats[t][7] 145 | + (hc - hd) * mats[t][8]; 146 | 147 | return Tuple, 3>(dhdx, dhdy, dhdz); 148 | } 149 | 150 | // -------------------------------------------------------------- 151 | 152 | template < class T_Graph > 153 | class TestFlattened 154 | { 155 | private: 156 | const set& flats; 157 | public: 158 | TestFlattened(const set& flats_) : flats(flats_) {} 159 | bool operator()(const T_Graph& graph, LibSL::DataStructures::t_NodeId node) const 160 | { 161 | return (flats.find(node) != flats.end()); 162 | } 163 | }; 164 | 165 | // --------------------------------------------------------------- 166 | 167 | void connected_components(TetMesh& mesh, const set& surfaces_to_flatten, vector >& _comps) 168 | { 169 | typedef LibSL::DataStructures::Graph t_Graph; 170 | t_Graph g; 171 | ForIndex(v, mesh.numSurfaces()) { 172 | g.addNode(v); 173 | } 174 | ForIndex(v, mesh.numSurfaces()) { 175 | vector neighs = mesh.tri_neighbours(v); 176 | for (auto n : neighs) { 177 | g.addEdge(v, n, Loki::NullType()); 178 | } 179 | } 180 | LibSL::DataStructures::GraphAlgorithms::ConnectedComponents, TestFlattened> comps; 181 | Array visited; 182 | vector connected; 183 | _comps.clear(); 184 | while (comps.enumerateConnectedComponents(g, visited, connected, 185 | LibSL::DataStructures::GraphAlgorithms::DefaultEdgeTester(), 186 | TestFlattened(surfaces_to_flatten))) { 187 | _comps.push_back(vector()); 188 | for (auto n : connected) { 189 | _comps.back().push_back(n); 190 | } 191 | } 192 | } 193 | 194 | // --------------------------------------------------------------- 195 | 196 | double triangle_non_flatness(v3u tri, SLRModel *model) 197 | { 198 | double va = model->getVarByName(sprint("z_%03d", tri[0])).get(); 199 | double vb = model->getVarByName(sprint("z_%03d", tri[1])).get(); 200 | double vc = model->getVarByName(sprint("z_%03d", tri[2])).get(); 201 | double non_flatness = max((va - vb)*(va - vb), max((va - vc)*(va - vc), (vb - vc)*(vb - vc))); 202 | return non_flatness; 203 | } 204 | 205 | // -------------------------------------------------------------- 206 | 207 | double component_non_flatness(TetMesh& mesh, const std::vector& tris, SLRModel *model, double max_admissible) 208 | { 209 | double non_flatness = 0.0, max_non_flatness = 0.0; 210 | double comp_area = 0.0; 211 | for (auto t : tris) { 212 | v3u tri = mesh.surfaceTriangleAt(t); 213 | double ta = triangle_area_xy(mesh, tri); 214 | double nftri = triangle_non_flatness(tri, model); 215 | max_non_flatness = max(max_non_flatness, nftri); 216 | non_flatness += nftri * ta; 217 | comp_area += ta; 218 | } 219 | if (max_non_flatness > max_admissible) { 220 | return max_non_flatness; 221 | } else { 222 | return non_flatness / comp_area; 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /src/thicknesses.h: -------------------------------------------------------------------------------- 1 | // ------------------ VARIABLES ---------------------------- 2 | 3 | float min_thickness = 0.1f; // tau min : minimum thickness (constraint) 4 | float max_thickness = 0.6f; // tau max : maximum thickness (constraint) 5 | 6 | const float default_layer_thickness = 0.6f; // tau 7 | 8 | // 0.2 [0.05-0.3] 9 | 10 | // 0.7 [0.3-0.9] 11 | 12 | // also edit: mesh.bat , settings_curvi.xml 13 | 14 | // -------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /toTetmesh.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set a=%1 3 | set a=%a:/=\% 4 | 5 | if not exist %a%.msh ( 6 | .\tools\tetwild-windows\TetWild.exe --save-mid-result 2 %a%.stl -e 0.025 --targeted-num-v 1000 --is-laplacian 7 | move "%a%__mid2.000000.msh" "%a%.msh" 8 | ) 9 | -------------------------------------------------------------------------------- /toTetmesh.sh: -------------------------------------------------------------------------------- 1 | if [ -e "$1.msh" ] 2 | then 3 | echo "msh already generated" 4 | else 5 | ./tools/tetwild/TetWild --save-mid-result 2 $1.stl -e 0.025 --targeted-num-v 1000 --is-laplacian 6 | mv "$1__mid2.000000.msh" "$1.msh" 7 | fi 8 | -------------------------------------------------------------------------------- /tools/icesl/assets/Cousine-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/icesl/assets/Cousine-Regular.ttf -------------------------------------------------------------------------------- /tools/icesl/assets/NotoSansCJKtc-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/icesl/assets/NotoSansCJKtc-Medium.ttf -------------------------------------------------------------------------------- /tools/icesl/bin/IceSL-slicer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/icesl/bin/IceSL-slicer -------------------------------------------------------------------------------- /tools/icesl/bin/IceSL-slicer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/icesl/bin/IceSL-slicer.exe -------------------------------------------------------------------------------- /tools/icesl/bin/README.txt: -------------------------------------------------------------------------------- 1 | This is a special version of IceSL, customized for the project. 2 | -------------------------------------------------------------------------------- /tools/icesl/icesl-libs/icesl-deprecated_64.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/icesl/icesl-libs/icesl-deprecated_64.luac -------------------------------------------------------------------------------- /tools/icesl/icesl-libs/icesl-stdlib_64.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/icesl/icesl-libs/icesl-stdlib_64.luac -------------------------------------------------------------------------------- /tools/icesl/icesl-printers/fff/curvi/features.lua: -------------------------------------------------------------------------------- 1 | version = 2 2 | 3 | bed_size_x_mm = 220 4 | bed_size_y_mm = 220 5 | bed_size_z_mm = 240 6 | nozzle_diameter_mm_0 = 0.4 7 | 8 | extruder_count = 1 9 | 10 | z_offset = 0.0 11 | 12 | priming_mm_per_sec = 40 13 | 14 | 15 | z_layer_height_mm = 0.3 16 | z_layer_height_mm_min = 0.01 17 | z_layer_height_mm_max = 10.0 18 | 19 | print_speed_mm_per_sec_min = 5 20 | print_speed_mm_per_sec_max = 80 21 | 22 | bed_temp_degree_c = 50 23 | bed_temp_degree_c_min = 0 24 | bed_temp_degree_c_max = 120 25 | 26 | perimeter_print_speed_mm_per_sec_min = 5 27 | perimeter_print_speed_mm_per_sec_max = 80 28 | 29 | first_layer_print_speed_mm_per_sec = 10 30 | first_layer_print_speed_mm_per_sec_min = 1 31 | first_layer_print_speed_mm_per_sec_max = 80 32 | 33 | for i=0,63,1 do 34 | _G['filament_diameter_mm_'..i] = 1.75 35 | _G['filament_priming_mm_'..i] = 4.0 36 | _G['extruder_temp_degree_c_' ..i] = 210 37 | _G['extruder_temp_degree_c_'..i..'_min'] = 150 38 | _G['extruder_temp_degree_c_'..i..'_max'] = 270 39 | _G['extruder_mix_count_'..i] = 1 40 | end 41 | 42 | add_checkbox_setting('gcode_ultimaker2','ultimaker2') 43 | add_checkbox_setting('gcode_delta','delta') 44 | -------------------------------------------------------------------------------- /tools/icesl/icesl-printers/fff/curvi/printer.lua: -------------------------------------------------------------------------------- 1 | version = 2 2 | 3 | function comment(text) 4 | output('; ' .. text) 5 | end 6 | 7 | extruder_e = 0 8 | extruder_e_restart = 0 9 | 10 | function prep_extruder(extruder) 11 | end 12 | 13 | function header() 14 | output('o X ' .. gcode_to_model_x .. ' Y ' .. gcode_to_model_y .. ' Z ' .. gcode_to_model_z) 15 | output('t ' .. z_layer_height_mm) 16 | end 17 | 18 | function footer() 19 | end 20 | 21 | function layer_start(zheight) 22 | output(';()') 23 | if layer_id == 0 then 24 | output('G0 F600 Z' .. ff(zheight)) 25 | else 26 | output('G0 F100 Z' .. ff(zheight)) 27 | end 28 | -- output('G1 Z' .. f(zheight)) 29 | end 30 | 31 | function layer_stop() 32 | comment('') 33 | end 34 | 35 | function retract(extruder,e) 36 | -- speed = priming_mm_per_sec * 60; 37 | -- letter = 'E' 38 | -- output('G1 F' .. speed .. ' ' .. letter .. f(e - len - extruder_e_restart)) 39 | output('R') 40 | return e 41 | end 42 | 43 | function prime(extruder,e) 44 | -- speed = priming_mm_per_sec * 60; 45 | -- letter = 'E' 46 | -- output('G1 F' .. speed .. ' ' .. letter .. f(e + len - extruder_e_restart)) 47 | output('P') 48 | return e 49 | end 50 | 51 | current_extruder = 0 52 | current_frate = 0 53 | 54 | function select_extruder(extruder) 55 | end 56 | 57 | function swap_extruder(from,to,x,y,z) 58 | end 59 | 60 | function move_xyz(x,y,z) 61 | output('G1 X' .. f(x) .. ' Y' .. f(y) .. ' Z' .. f(z+z_offset)) 62 | end 63 | 64 | function move_xyze(x,y,z,e) 65 | to_mm_cube = 1.0 66 | if gcode_ultimaker2 then 67 | r = filament_diameter_mm[extruders[0]] / 2 68 | to_mm_cube = 3.14159 * r * r 69 | end 70 | if traveling == 1 then 71 | traveling = 0 -- start path 72 | if path_is_perimeter then output(';perimeter') 73 | elseif path_is_shell then output(';shell') 74 | elseif path_is_infill then output(';infill') 75 | elseif path_is_raft then output(';raft') 76 | elseif path_is_brim then output(';brim') 77 | elseif path_is_shield then output(';shield') 78 | elseif path_is_support then output(';support') 79 | elseif path_is_tower then output(';tower') 80 | elseif path_is_ironing then output(';ironing') 81 | end 82 | end 83 | 84 | extruder_e = e 85 | letter = 'E' 86 | instr = 'G' 87 | if path_is_ironing then 88 | instr = 'I' 89 | end 90 | if z == current_z then 91 | output(instr .. '1 F' .. f(current_frate) .. ' X' .. f(x) .. ' Y' .. f(y) .. ' ' .. letter .. ff((e-extruder_e_restart)*to_mm_cube)) 92 | else 93 | output(instr .. '1 F' .. f(current_frate) .. ' X' .. f(x) .. ' Y' .. f(y) .. ' Z' .. ff(z) .. ' ' .. letter .. ff((e-extruder_e_restart)*to_mm_cube)) 94 | current_z = z 95 | end 96 | end 97 | 98 | function move_e(e) 99 | to_mm_cube = 1.0 100 | if gcode_ultimaker2 then 101 | r = filament_diameter_mm[extruders[0]] / 2 102 | to_mm_cube = 3.14159 * r * r 103 | end 104 | extruder_e = e 105 | letter = 'E' 106 | output('G1 ' .. letter .. f((e - extruder_e_restart)*to_mm_cube)) 107 | end 108 | 109 | function set_feedrate(feedrate) 110 | current_frate = feedrate 111 | end 112 | 113 | function extruder_start() 114 | end 115 | 116 | function extruder_stop() 117 | end 118 | 119 | function progress(percent) 120 | end 121 | 122 | function set_extruder_temperature(extruder,temperature) 123 | end 124 | 125 | function set_fan_speed(speed) 126 | end 127 | -------------------------------------------------------------------------------- /tools/tetviz/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /tools/tetviz/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | !TetViz.exe -------------------------------------------------------------------------------- /tools/tetviz/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "LibSL"] 2 | path = libs/LibSL 3 | url = https://github.com/JuDePom/LibSL 4 | -------------------------------------------------------------------------------- /tools/tetviz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 | 3 | if (WIN32) 4 | ADD_DEFINITIONS(-DWIN32) 5 | endif (WIN32) 6 | 7 | ADD_SUBDIRECTORY(libs) 8 | ADD_SUBDIRECTORY(src) 9 | 10 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") -------------------------------------------------------------------------------- /tools/tetviz/TetViz.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/tetviz/TetViz.exe -------------------------------------------------------------------------------- /tools/tetviz/libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 | 3 | ADD_SUBDIRECTORY(LibSL) -------------------------------------------------------------------------------- /tools/tetviz/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 | 3 | ADD_EXECUTABLE( TetViz 4 | TetViz.h 5 | TetViz.cpp 6 | shade.fp 7 | shade.vp 8 | shade.h 9 | slicerror.fp 10 | slicerror.vp 11 | slicerror.h 12 | gcode.h 13 | gcode.cpp 14 | TetMesh.h 15 | TetMesh.cpp 16 | ) 17 | 18 | TARGET_LINK_LIBRARIES(TetViz 19 | LibSL 20 | LibSL_gl4 21 | ) 22 | 23 | AUTO_BIND_SHADERS( 24 | shade 25 | slicerror 26 | ) 27 | 28 | INSTALL(TARGETS TetViz 29 | RUNTIME DESTINATION ${CMAKE_SOURCE_DIR} 30 | ) 31 | -------------------------------------------------------------------------------- /tools/tetviz/src/TetMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | using namespace LibSL::Math; 13 | using namespace std; 14 | 15 | 16 | typedef Tuple M3x3; 17 | 18 | class TetMesh 19 | { 20 | private : 21 | AutoPtr m_mesh; 22 | 23 | vector> m_tetrahedrons; 24 | vector m_vertices; 25 | vector m_triangles; 26 | vector m_surfaces; 27 | 28 | map> m_tet_neighborhood; 29 | map> m_tri_neighborhood; 30 | map> m_ver_to_tris; 31 | public: 32 | TetMesh(); 33 | TetMesh(TetMesh*); 34 | ~TetMesh(); 35 | 36 | static TetMesh* load(const char *fname); 37 | static void save(const char *fname, TetMesh *mesh); 38 | 39 | size_t numVertices(); 40 | v3f& vertexAt(uint n); 41 | 42 | size_t numTetrahedrons(); 43 | bool isInside(uint t); 44 | v4u& tetrahedronAt(uint t); 45 | vector& tet_neighbours(uint t); 46 | vector& tri_neighbours(uint t); 47 | vector ver_neighbours(uint t); 48 | 49 | uint getTetrahedronSurface(uint t); 50 | 51 | size_t numTriangles(); 52 | v3u& triangleAt(uint t); 53 | 54 | size_t numSurfaces(); 55 | v3u& surfaceTriangleAt(uint s); 56 | 57 | 58 | M3x3 getGradientMatrix(uint t); 59 | AABox getBBox(); 60 | 61 | void reorientSurface(); 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /tools/tetviz/src/TetViz.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "imgui\imgui.h" 7 | #define IMGUI_DEFINE_MATH_OPERATORS true 8 | #include "imgui\imgui_internal.h" 9 | 10 | class TetViz{ 11 | private: 12 | TetViz & operator= (const TetViz&) {}; 13 | TetViz(const TetViz&) {}; 14 | 15 | static TetViz *s_instance; 16 | TetViz(); 17 | ~TetViz() {} 18 | 19 | public: 20 | static void TetViz::launch(); 21 | 22 | static TetViz *Instance() { 23 | if (!s_instance) 24 | s_instance = new TetViz; 25 | return s_instance; 26 | } 27 | 28 | 29 | protected: 30 | const float ZN = 1.0f; 31 | const float ZF = 2000.0f; 32 | 33 | public: 34 | /** 35 | * Called at each frame 36 | */ 37 | static void mainRender(); 38 | 39 | /** 40 | * Called on resize 41 | * @param width the new width 42 | * @param height the new height 43 | */ 44 | static void mainOnResize(uint _width, uint _height); 45 | 46 | 47 | /** 48 | * Called when a key is pressed 49 | * @param k the typed character 50 | */ 51 | static void mainKeyPressed(uchar _k); 52 | static void mainScanCodePressed(uint _sc); 53 | static void mainScanCodeUnpressed(uint _sc); 54 | static void mainMouseMoved(uint _x, uint _y); 55 | static void mainMousePressed(uint _x, uint _y, uint _button, uint _flags); 56 | 57 | 58 | 59 | 60 | 61 | bool draw(); 62 | 63 | private: 64 | ImVec2 m_size; 65 | Trackball m_Trackball; 66 | }; -------------------------------------------------------------------------------- /tools/tetviz/src/gcode.cpp: -------------------------------------------------------------------------------- 1 | #include "gcode.h" 2 | 3 | // -------------------------------------------------------------- 4 | 5 | typedef LibSL::BasicParser::BufferStream t_stream; 6 | typedef LibSL::BasicParser::Parser t_parser; 7 | typedef AutoPtr t_stream_ptr; 8 | typedef AutoPtr t_parser_ptr; 9 | 10 | // -------------------------------------------------------------- 11 | 12 | t_stream_ptr g_Stream; 13 | t_parser_ptr g_Parser; 14 | 15 | v4f g_Pos(0.0f); 16 | v4f g_Offset(0.0f); 17 | float g_Speed = 20.0f; 18 | int g_Line = 0; 19 | const char *g_GCode = NULL; 20 | bool g_GCodeError = false; 21 | 22 | v3f g_GCodeOffset(0.0f); 23 | 24 | // -------------------------------------------------------------- 25 | 26 | void gcode_start(const char *gcode) 27 | { 28 | g_GCode = gcode; 29 | g_Stream = t_stream_ptr(new t_stream(g_GCode,(uint)strlen(g_GCode)+1)); 30 | g_Parser = t_parser_ptr(new t_parser(*g_Stream,false)); 31 | g_Pos = 0.0f; 32 | g_Offset = 0.0f; 33 | g_Speed = 20.0f; 34 | g_Line = 0; 35 | g_GCodeError = false; 36 | 37 | int c; 38 | while (!g_Parser->eof()) { 39 | g_Line++; 40 | 41 | c = g_Parser->readChar(); 42 | c = tolower(c); 43 | if (c == 'o') { 44 | while (!g_Parser->eof()) { 45 | c = g_Parser->readChar(); 46 | if (c == '\n') break; 47 | if (c == ';') { 48 | g_Parser->reachChar('\n'); 49 | break; 50 | } 51 | c = tolower(c); 52 | float f = g_Parser->readFloat(); 53 | if (c >= 'x' && c <= 'z') { 54 | g_GCodeOffset[c - 'x'] = f; 55 | } 56 | } 57 | break; 58 | } 59 | 60 | 61 | } 62 | } 63 | 64 | // -------------------------------------------------------------- 65 | 66 | void gcode_reset() 67 | { 68 | sl_assert(g_GCode != NULL); 69 | g_Stream = t_stream_ptr(new t_stream(g_GCode, (uint)strlen(g_GCode) + 1)); 70 | g_Parser = t_parser_ptr(new t_parser(*g_Stream, false)); 71 | g_Pos = 0.0f; 72 | g_Offset = 0.0f; 73 | g_Speed = 20.0f; 74 | g_Line = 0; 75 | g_GCodeError = false; 76 | } 77 | 78 | // -------------------------------------------------------------- 79 | v3f gcode_offset() { 80 | return g_GCodeOffset; 81 | } 82 | // -------------------------------------------------------------- 83 | 84 | bool gcode_advance() 85 | { 86 | if (g_GCodeError) return false; 87 | int c; 88 | while (!g_Parser->eof()) { 89 | g_Line ++; 90 | c = g_Parser->readChar(); 91 | c = tolower(c); 92 | if (c == 'g') { 93 | int n = g_Parser->readInt(); 94 | if (n == 0 || n == 1) { // G0 G1 95 | while (!g_Parser->eof()) { 96 | c = g_Parser->readChar(); 97 | if (c == '\n') break; 98 | if (c == ';') { 99 | g_Parser->reachChar('\n'); 100 | break; 101 | } 102 | c = tolower(c); 103 | float f = g_Parser->readFloat(); 104 | if (c >= 'x' && c <= 'z') { 105 | g_Pos[c - 'x'] = f + g_Offset[c - 'x']; 106 | } else if (c == 'e') { 107 | g_Pos[3] = f + g_Offset[3]; 108 | } else if (c == 'f') { 109 | g_Speed = f / 60.0f; 110 | } else if (c >= 'a' && c <= 'f') { 111 | // TODO mixing ratios 112 | } else { 113 | g_GCodeError = true; 114 | return false; 115 | } 116 | } 117 | break; // done advancing 118 | } else if (n == 92) { // G92 119 | while (!g_Parser->eof()) { 120 | c = g_Parser->readChar(); 121 | if (c == '\n') break; 122 | c = tolower(c); 123 | float f = g_Parser->readFloat(); 124 | if (c >= 'x' && c <= 'z') { 125 | g_Offset[c - 'x'] = g_Pos[c - 'x'] - f; 126 | } else if (c == 'e') { 127 | g_Offset[3] = g_Pos[3] - f; 128 | } 129 | } 130 | } else if (n == 10) { // G10 131 | g_Parser->reachChar('\n'); 132 | } else if (n == 11) { // G11 133 | g_Parser->reachChar('\n'); 134 | } else { // other => ignore 135 | g_Parser->reachChar('\n'); 136 | } 137 | } else if (c == 'm') { 138 | int n = g_Parser->readInt(); 139 | g_Parser->reachChar('\n'); 140 | } else if (c == '\n') { 141 | // do nothing 142 | } else if (c == '<') { 143 | g_Parser->reachChar('\n'); 144 | } else if (c == ';' || c == 'o') { 145 | g_Parser->reachChar('\n'); 146 | } else if (c == '\r') { 147 | g_Parser->reachChar('\n'); 148 | } else if (c == '\0' || c == -1) { 149 | return false; 150 | } else { 151 | g_GCodeError = true; 152 | return false; 153 | } 154 | } 155 | return !g_Parser->eof(); 156 | } 157 | 158 | // -------------------------------------------------------------- 159 | 160 | v4f gcode_next_pos() 161 | { 162 | return g_Pos; 163 | } 164 | 165 | // -------------------------------------------------------------- 166 | 167 | float gcode_speed() 168 | { 169 | return g_Speed; 170 | } 171 | 172 | // -------------------------------------------------------------- 173 | 174 | int gcode_line() 175 | { 176 | return g_Line; 177 | } 178 | 179 | // -------------------------------------------------------------- 180 | 181 | bool gcode_error() 182 | { 183 | return g_GCodeError; 184 | } 185 | 186 | // -------------------------------------------------------------- 187 | -------------------------------------------------------------------------------- /tools/tetviz/src/gcode.h: -------------------------------------------------------------------------------- 1 | // SL 2018-07-03 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | // start interpreting the gcode 8 | void gcode_start(const char *gcode); 9 | 10 | v3f gcode_offset(); 11 | 12 | // advances to the next position 13 | // return false if none exists (end of gcode) 14 | bool gcode_advance(); 15 | 16 | // returns the next position to reach (x,y,z,e) 17 | v4f gcode_next_pos(); 18 | 19 | // returns the speed in mm/sec 20 | float gcode_speed(); 21 | 22 | // return current line in gcode stream 23 | int gcode_line(); 24 | 25 | // restart from scratch 26 | void gcode_reset(); 27 | 28 | // returns true in a reading error occured 29 | bool gcode_error(); 30 | -------------------------------------------------------------------------------- /tools/tetviz/src/shade.fp: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | #extension GL_ARB_shader_image_load_store : enable 3 | #extension GL_ARB_gpu_shader5 : enable 4 | 5 | in float v_h; 6 | in float v_grad_h_z; 7 | 8 | in float v_z; 9 | 10 | in vec3 v_pos; 11 | in float v_widding; 12 | 13 | uniform int u_drawing_mesh; 14 | uniform float u_v_h_min; 15 | 16 | uniform float u_base_thickness; 17 | uniform float u_thickness; 18 | 19 | uniform int u_SequenceLength; 20 | layout(r32f) coherent uniform imageBuffer u_Sequence; 21 | 22 | vec2 findSlice(float z) 23 | { 24 | int l = 0; 25 | int r = u_SequenceLength; 26 | for (int i = 0; i < 64; i++) { 27 | // read sequence 28 | int m = min((l + r) / 2, u_SequenceLength - 1); 29 | vec2 slice_nfo; 30 | slice_nfo.x = imageLoad(u_Sequence, m * 2 + 0).x; 31 | slice_nfo.y = imageLoad(u_Sequence, m * 2 + 1).x; 32 | if (z >= slice_nfo.x && z < slice_nfo.x + slice_nfo.y) { 33 | return slice_nfo; 34 | } 35 | if (z < slice_nfo.x) { 36 | r = m; 37 | } else { 38 | l = m; 39 | } 40 | } 41 | int last = u_SequenceLength - 1; 42 | return vec2(imageLoad(u_Sequence, last * 2 + 0).x, imageLoad(u_Sequence, last * 2 + 1).x); 43 | } 44 | 45 | void main() 46 | { 47 | float t = fract(v_h / 5); 48 | 49 | vec3 dpdx = dFdx(v_pos); 50 | vec3 dpdy = dFdy(v_pos); 51 | vec3 nrm = normalize( cross(dpdx,dpdy)); 52 | 53 | if (u_drawing_mesh == 1) { 54 | 55 | if (u_SequenceLength > 0) { 56 | 57 | vec2 slice = findSlice(v_h); 58 | gl_FragColor = (slice.y / u_base_thickness) * vec4(1.0 - abs(0.5 - ((v_h - slice.x) / slice.y)) * 2.0); 59 | 60 | } else { 61 | 62 | gl_FragColor = v_grad_h_z * (u_thickness / u_base_thickness) * vec4(1.0 - abs(0.5 - fract((v_h - u_v_h_min) / u_thickness)) * 2.0); 63 | 64 | } 65 | 66 | } else { 67 | 68 | if (v_widding > 0.5) { 69 | if (t < 0.5) { 70 | gl_FragColor = vec4(0.8, 0.4, 0.6, 0)*(0.5+0.5*nrm.z); 71 | } else { 72 | gl_FragColor = vec4(0, 1, 1, 0)*(0.5 + 0.5*nrm.z); 73 | } 74 | } else { 75 | if (t < 0.5) { 76 | gl_FragColor = vec4(0.4, 0.8, 0.6, 0)*nrm.z; 77 | } else { 78 | gl_FragColor = vec4(0.2, 1, 0.6, 0)*nrm.z; 79 | } 80 | } 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tools/tetviz/src/shade.vp: -------------------------------------------------------------------------------- 1 | 2 | uniform mat4 u_matrix; 3 | uniform mat4 u_model; 4 | 5 | attribute float a_h; 6 | attribute float a_grad_h_z; 7 | attribute float a_widding; 8 | 9 | varying float v_h; 10 | varying float v_grad_h_z; 11 | 12 | varying float v_z; 13 | 14 | varying vec3 v_pos; 15 | varying float v_widding; 16 | 17 | uniform float u_ClipY; 18 | uniform int u_ClipDir; 19 | uniform int u_Deform; 20 | 21 | void main() 22 | { 23 | v_h = a_h; 24 | v_grad_h_z = a_grad_h_z; 25 | v_z = gl_Vertex.z; 26 | 27 | v_widding = a_widding; 28 | 29 | vec4 pos; 30 | if (u_Deform == 1) { 31 | pos = vec4(gl_Vertex.xy,v_h,1.0); 32 | } else { 33 | pos = vec4(gl_Vertex.xyz,1.0); 34 | } 35 | 36 | v_pos = (u_model * pos).xyz; 37 | gl_Position = u_matrix * pos; 38 | if (a_widding == 0) { 39 | gl_ClipDistance[0] = 1.0; 40 | } else { 41 | gl_ClipDistance[0] = u_ClipDir * (-pos.y + u_ClipY); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tools/tetviz/src/slicerror.fp: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | #extension GL_ARB_shader_image_load_store : enable 3 | #extension GL_ARB_gpu_shader5 : enable 4 | 5 | uniform uint u_ScreenW; 6 | uniform float u_v_h_min; 7 | uniform int u_SequenceLength; 8 | 9 | layout(r32ui) coherent uniform uimageBuffer u_Errors; 10 | layout(r32f) coherent uniform imageBuffer u_Sequence; 11 | 12 | in float v_h; 13 | in float v_grad_h_z; 14 | 15 | uniform float u_base_thickness; 16 | uniform float u_thickness; 17 | 18 | vec2 findSlice(float z) 19 | { 20 | int l = 0; 21 | int r = u_SequenceLength; 22 | for (int i = 0 ; i < 64 ; i++) { 23 | // read sequence 24 | int m = min((l+r)/2,u_SequenceLength-1); 25 | vec2 slice_nfo; 26 | slice_nfo.x = imageLoad(u_Sequence,m*2+0).x; 27 | slice_nfo.y = imageLoad(u_Sequence,m*2+1).x; 28 | if (z >= slice_nfo.x && z < slice_nfo.x + slice_nfo.y) { 29 | return slice_nfo; 30 | } 31 | if (z < slice_nfo.x) { 32 | r = m; 33 | } else { 34 | l = m; 35 | } 36 | } 37 | int last = u_SequenceLength-1; 38 | return vec2(imageLoad(u_Sequence,last*2+0).x,imageLoad(u_Sequence,last*2+1).x); 39 | } 40 | 41 | void main() 42 | { 43 | float normalized_distance = 0.0; 44 | 45 | if (u_SequenceLength > 0) { 46 | 47 | vec2 slice = findSlice( v_h ); 48 | normalized_distance = (slice.y / u_base_thickness) * (1.0 - abs(0.5 - ( (v_h-slice.x) / slice.y) ) * 2.0); 49 | 50 | } else { 51 | 52 | normalized_distance = v_grad_h_z * (u_thickness / u_base_thickness) * (1.0 - abs(0.5 - fract( (v_h-u_v_h_min) / u_thickness) ) * 2.0); 53 | 54 | } 55 | 56 | uint ptr = uint(gl_FragCoord.x) + uint(gl_FragCoord.y) * u_ScreenW; 57 | uint fxp_distance = uint(normalized_distance * 4096.0); 58 | imageAtomicAdd( u_Errors, int(ptr), fxp_distance ); 59 | 60 | gl_FragColor = vec4( normalized_distance ); 61 | } 62 | -------------------------------------------------------------------------------- /tools/tetviz/src/slicerror.vp: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | in vec4 mvf_vertex; // LibSL takes care of vertex attributes 'mvf_*' (normal,color0,texcoord0,etc.) 4 | in float a_h; 5 | in float a_grad_h_z; 6 | 7 | out float v_h; 8 | out float v_grad_h_z; 9 | 10 | uniform mat4 u_matrix; 11 | 12 | void main() 13 | { 14 | v_h = a_h; 15 | v_grad_h_z = a_grad_h_z; 16 | gl_Position = u_matrix * mvf_vertex; 17 | } 18 | -------------------------------------------------------------------------------- /tools/tetwild-windows/TetWild.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/tetwild-windows/TetWild.exe -------------------------------------------------------------------------------- /tools/tetwild-windows/libgmp-10.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/tetwild-windows/libgmp-10.dll -------------------------------------------------------------------------------- /tools/tetwild-windows/libmpfr-4.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfx-inria/curvislicer/1ea03fef94328a7c36f835be6ebc18ba690e22d3/tools/tetwild-windows/libmpfr-4.dll --------------------------------------------------------------------------------