Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • gmsh/gmsh
  • lrp/gmsh
  • nschloe/gmsh
  • romin.tomasetti/gmsh
4 results
Select Git revision
Show changes
Commits on Source (11047)
Showing with 3823 additions and 5343 deletions
---
BasedOnStyle: None
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,modernize-use-auto,modernize-use-nullptr'
CheckOptions:
- key: modernize-use-auto.MinTypeNameLength
value: 40
...
*.geo gitlab-language=cpp
bin*/
lib*/
build*/
install/
contrib/mobile/frameworks_*
contrib/3M
contrib/Parasolid
*.db
doc/cookbook/book
doc/doxygen/html
.DS_Store
*~
*.so
*.so.*
*.mod
*#
*.pyc
## CLion directories
.idea
cmake-build-*
# VS Code directories
.vscode/
# Python virtual environment
venv/
.venv/
# Gmsh - Copyright (C) 1997-2024 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file in the Gmsh root directory for license information.
# Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
variables:
EXTRA_OPTION: ""
.ssh_config: &ssh_config
before_script:
- echo "$SSH_TOKEN" > ~/.ssh/id_rsa
- echo "Host *" > ~/.ssh/config
- echo "StrictHostKeyChecking no" >> ~/.ssh/config
- chmod 700 ~/.ssh/id_rsa ~/.ssh/config
# ----------------------------------------------
# Continuous integration builds for all branches
# ----------------------------------------------
linux_ci:
image: onelab/ubuntu20.04
script:
- mkdir build
- cd build
- export CXXFLAGS=-Werror
- cmake ..
- make -j 8
- make doc
- ctest -j 8 --output-on-failure
- valgrind --leak-check=full --show-leak-kinds=definite,indirect --error-exitcode=0 ./gmsh ../tutorials/t5.geo -3
tags:
- linux64
- docker
except:
- tags
linux_compatibility_ci:
image: onelab/ubuntu20.04
script:
- mkdir build
- cd build
- cmake -DDEFAULT=0 ..
- make -j 8
- cmake -DENABLE_PARSER=1 ..
- make -j 8
- cmake -DENABLE_POST=1 ..
- make -j 8
- cmake -DENABLE_MESH=1 -DENABLE_BUILD_DYNAMIC=1 -DENABLE_PRIVATE_API=1 -DENABLE_EIGEN=0 -DENABLE_WRAP_PYTHON=1 -DENABLE_PETSC=1 ..
- make -j 8
tags:
- linux64
- docker
except:
- tags
windows_ci:
script:
- md build
- cd build
- c:\cygwin64\bin\bash -c "/usr/bin/cmake -DCMAKE_PREFIX_PATH='/usr/local/opencascade;/usr/local;/usr/x86_64-w64-mingw32/sys-root/mingw' -DCMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++.exe -DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe -DENABLE_OS_SPECIFIC_INSTALL=1 .. && ls"
- c:\cygwin64\bin\bash -c "/usr/bin/make -j 8"
- c:\cygwin64\bin\bash -c "/usr/bin/ctest -j 8 --output-on-failure && ls"
tags:
- windows64
- shared
except:
- tags
windows_msvc_ci:
script:
- md build
- cd build
- cmake -DENABLE_OPENMP=0 ..
- msbuild package.vcxproj
tags:
- windows64
- shared
except:
- tags
# ------------------------------------------
# Official Linux builds (master branch only)
# ------------------------------------------
.linux_official: &linux_official
only:
- master@gmsh/gmsh
<<: *ssh_config
script:
- mkdir build
- cd build
- cmake -DGMSH_HOST=gmsh.info -DENABLE_PETSC=1 -DPETSC_ARCH=real_mumps_seq -DPETSC_DIR=/petsc-3.14.4 ${EXTRA_OPTION} ..
- make package -j 8
- PKG=`ls gmsh-*.tar*`
- scp ${PKG} geuzaine@gmsh.info:.wwwgmsh/bin/Linux/${PKG/\.tar\.gz/\.tgz}
- ctest -j 8 --output-on-failure
tags:
- linux64
- docker
linux_official_snapshot:
image: onelab/debian.stretch.64bit
variables:
EXTRA_OPTION: "-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++"
<<: *linux_official
except:
- tags
linux_official_release:
image: onelab/debian.stretch.64bit
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1 -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++"
<<: *linux_official
only:
- /^gmsh_.*$/
linux-sdk_official_snapshot:
image: onelab/debian.stretch.64bit
variables:
EXTRA_OPTION: "-DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *linux_official
except:
- tags
artifacts:
paths:
- build/_CPack_Packages/
- build/version.txt
expire_in: 1day
linux-sdk_official_release:
image: onelab/debian.stretch.64bit
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *linux_official
only:
- /^gmsh_.*$/
artifacts:
paths:
- build/_CPack_Packages/
- build/version.txt
expire_in: 1day
linux-nox-sdk_official_snapshot:
image: onelab/debian.stretch.64bit
variables:
EXTRA_OPTION: "-DGMSH_EXTRA_VERSION=-nox -DENABLE_FLTK=0 -DENABLE_OCC_CAF=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *linux_official
except:
- tags
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
# --------------------------------------------
# Official Windows builds (master branch only)
# --------------------------------------------
.windows_official: &windows_official
only:
- master@gmsh/gmsh
script:
- md build
- cd build
- c:\cygwin64\bin\bash -c "/usr/bin/cmake -DGMSH_HOST=gmsh.info -DCMAKE_PREFIX_PATH='/usr/local;/usr/x86_64-w64-mingw32/sys-root/mingw' -DCMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++.exe -DCMAKE_Fortran_COMPILER=/usr/bin/x86_64-w64-mingw32-gfortran.exe -DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe -DENABLE_OS_SPECIFIC_INSTALL=1 -DENABLE_PETSC=1 -DPETSC_ARCH=real_mumps_seq -DPETSC_DIR=/home/geuzaine/src/petsc ${EXTRA_OPTION} .."
- c:\cygwin64\bin\bash -c "/usr/bin/make package -j 4"
- c:\cygwin64\bin\bash -c "/usr/bin/scp -o StrictHostKeyChecking=no -i /home/geuzaine/.ssh/id_rsa gmsh-*.zip geuzaine@gmsh.info:.wwwgmsh/bin/Windows/"
- c:\cygwin64\bin\bash -c "/usr/bin/ctest -j 4 --output-on-failure"
windows_official_snapshot:
<<: *windows_official
tags:
- windows64
- official
except:
- tags
windows_official_release:
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1"
<<: *windows_official
tags:
- windows64
- official
only:
- /^gmsh_.*$/
windows-sdk_official_snapshot:
variables:
EXTRA_OPTION: "-DENABLE_OS_SPECIFIC_INSTALL=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *windows_official
tags:
- windows64
- official
except:
- tags
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
windows-sdk_official_release:
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1 -DENABLE_OS_SPECIFIC_INSTALL=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *windows_official
tags:
- windows64
- official
only:
- /^gmsh_.*$/
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
# ------------------------------------------
# Official macOS builds (master branch only)
# ------------------------------------------
.macos_official: &macos_official
only:
- master@gmsh/gmsh
script:
- mkdir build
- cd build
- cmake -DGMSH_HOST=gmsh.info -DENABLE_CAIRO=0 -DENABLE_OS_SPECIFIC_INSTALL=1 -DENABLE_PETSC=1 -DPETSC_ARCH=real_mumps_seq -DPETSC_DIR=/Users/geuzaine/src/petsc ${EXTRA_OPTION} ..
- make package -j 4
- PKG=`ls gmsh-*.[dt][ma][gr]*`
- '[[ ${PKG} == *.dmg ]] && xcrun notarytool submit ${PKG} --key /Users/geuzaine/AuthKey_4R6P5NYF3T.p8 --key-id 4R6P5NYF3T --issuer 69a6de7c-0b3a-47e3-e053-5b8c7c11a4d1 --wait'
- '[[ ${PKG} == *.dmg ]] && xcrun stapler staple ${PKG}'
- scp ${PKG} geuzaine@gmsh.info:.wwwgmsh/bin/macOS/${PKG/\.tar\.gz/\.tgz}
- ctest -j 4 --output-on-failure
macosx_official_snapshot:
<<: *macos_official
tags:
- macos64
- official
except:
- tags
macosx_official_release:
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1"
<<: *macos_official
tags:
- macos64
- official
only:
- /^gmsh_.*$/
macosx-sdk_official_snapshot:
variables:
EXTRA_OPTION: "-DENABLE_OS_SPECIFIC_INSTALL=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *macos_official
tags:
- macos64
- official
except:
- tags
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
macosx-sdk_official_release:
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1 -DENABLE_OS_SPECIFIC_INSTALL=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *macos_official
tags:
- macos64
- official
only:
- /^gmsh_.*$/
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
macosarm_official_snapshot:
<<: *macos_official
tags:
- macos64arm
- official
except:
- tags
macosarm_official_release:
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1"
<<: *macos_official
tags:
- macos64arm
- official
only:
- /^gmsh_.*$/
macosarm-sdk_official_snapshot:
variables:
EXTRA_OPTION: "-DENABLE_OS_SPECIFIC_INSTALL=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *macos_official
tags:
- macos64arm
- official
except:
- tags
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
macosarm-sdk_official_release:
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1 -DENABLE_OS_SPECIFIC_INSTALL=0 -DENABLE_BUILD_DYNAMIC=1 -DINSTALL_SDK_README=1"
<<: *macos_official
tags:
- macos64arm
- official
only:
- /^gmsh_.*$/
artifacts:
paths:
- build/_CPack_Packages/
expire_in: 1day
# ----------------------------------------------
# Official source snapshots (master branch only)
# ----------------------------------------------
.source_official: &source_official
only:
- master@gmsh/gmsh
<<: *ssh_config
script:
- mkdir build_src
- cd build_src
- cmake ${EXTRA_OPTION} ..
- make package_source
- PKG=`ls gmsh-*.tar*`
- scp ${PKG} geuzaine@gmsh.info:.wwwgmsh/src/${PKG/\.tar\.gz/\.tgz}
tags:
- linux64
- docker
source_official_snapshot:
image: onelab/ubuntu20.04
<<: *source_official
except:
- tags
source_official_release:
image: onelab/ubuntu20.04
variables:
EXTRA_OPTION: "-DGMSH_RELEASE=1"
<<: *source_official
only:
- /^gmsh_.*$/
# ----------------------------------------------
# Official documentation (master branch only)
# ----------------------------------------------
doc_official_snapshot:
stage: .post
image: onelab/ubuntu20.04
only:
- master@gmsh/gmsh
<<: *ssh_config
script:
- mkdir build_doc
- cd build_doc
- cmake ..
- make doc
- scp gmsh-*-doc.tgz geuzaine@gmsh.info:.wwwgmsh/doc.tgz
- ssh geuzaine@gmsh.info "cd .wwwgmsh/dev && tar zxvf ../doc.tgz"
tags:
- linux64
- docker
except:
- tags
doc_official_release:
stage: .post
image: onelab/ubuntu20.04
only:
- master@gmsh/gmsh
<<: *ssh_config
script:
- mkdir build_doc
- cd build_doc
- cmake -DGMSH_RELEASE=1 ..
- make doc
- scp gmsh-*-doc.tgz geuzaine@gmsh.info:.wwwgmsh/doc.tgz
- ssh geuzaine@gmsh.info "cd .wwwgmsh && tar zxvf doc.tgz"
- scp ../doc/gmsh.html geuzaine@gmsh.info:.wwwgmsh/
tags:
- linux64
- docker
only:
- /^gmsh_.*$/
# ----------------------------------------------
# Cookbook
# ----------------------------------------------
doc_cookbook:
stage: .post
image: onelab/ubuntu20.04
only:
- gmsh/gmsh
<<: *ssh_config
script:
- mdbook build doc/cookbook
- scp -r doc/cookbook/book geuzaine@gmsh.info:.wwwgmsh/doc/cookbook
tags:
- linux64
- docker
# ----------------------------------------------
# PyPi package
# ----------------------------------------------
pypi_official_snapshot:
stage: .post
image: onelab/ubuntu20.04
only:
- master@gmsh/gmsh
<<: *ssh_config
dependencies:
- linux-sdk_official_snapshot
- linux-nox-sdk_official_snapshot
- windows-sdk_official_snapshot
- macosx-sdk_official_snapshot
- macosarm-sdk_official_snapshot
script:
- cd build
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Linux/TGZ/gmsh-git-Linux64-sdk/ manylinux_2_24_x86_64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Linux/TGZ/gmsh-nox-git-Linux64-sdk/ manylinux_2_24_x86_64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/CYGWIN/ZIP/gmsh-git-Windows64-sdk/ win_amd64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Darwin/TGZ/gmsh-git-MacOSX-sdk/ macosx_10_15_x86_64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Darwin/TGZ/gmsh-git-MacOSARM-sdk/ macosx_12_0_arm64
- scp gmsh-*.dev1+nox*.whl geuzaine@gmsh.info:.wwwgmsh/python-packages-dev-nox/gmsh/
- scp gmsh-*.dev1-*.whl geuzaine@gmsh.info:.wwwgmsh/python-packages-dev/gmsh/
tags:
- linux64
- docker
except:
- tags
pypi_official_release:
stage: .post
image: onelab/ubuntu20.04
only:
- master@gmsh/gmsh
<<: *ssh_config
dependencies:
- linux-sdk_official_release
- windows-sdk_official_release
- macosx-sdk_official_release
- macosarm-sdk_official_release
script:
- echo "[distutils]" > ~/.pypirc
- echo "index-servers = pypi" >> ~/.pypirc
- echo "[pypi]" >> ~/.pypirc
- echo "username = __token__" >> ~/.pypirc
- echo "password = $PYPI_TOKEN" >> ~/.pypirc
- cd build
- VERSION=`cat version.txt`
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Linux/TGZ/gmsh-${VERSION}-Linux64-sdk/ manylinux_2_24_x86_64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/CYGWIN/ZIP/gmsh-${VERSION}-Windows64-sdk/ win_amd64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Darwin/TGZ/gmsh-${VERSION}-MacOSX-sdk/ macosx_10_15_x86_64
- python3 ../utils/pypi/sdktowheel.py _CPack_Packages/Darwin/TGZ/gmsh-${VERSION}-MacOSARM-sdk/ macosx_12_0_arm64
- scp gmsh*.whl geuzaine@gmsh.info:.wwwgmsh/python-packages/gmsh/
- twine upload gmsh*.whl
- ssh geuzaine@gmsh.info "cd .wwwgmsh/bin/Linux && rm -f gmsh-stable-Linux64* && ln -s gmsh-${VERSION}-Linux64.tgz gmsh-stable-Linux64.tgz && ln -s gmsh-${VERSION}-Linux64-sdk.tgz gmsh-stable-Linux64-sdk.tgz"
- ssh geuzaine@gmsh.info "cd .wwwgmsh/bin/Windows && rm -f gmsh-stable-Windows64* && ln -s gmsh-${VERSION}-Windows64.zip gmsh-stable-Windows64.zip && ln -s gmsh-${VERSION}-Windows64-sdk.zip gmsh-stable-Windows64-sdk.zip"
- ssh geuzaine@gmsh.info "cd .wwwgmsh/bin/macOS && rm -f gmsh-stable-MacOSX* && ln -s gmsh-${VERSION}-MacOSX.dmg gmsh-stable-MacOSX.dmg && ln -s gmsh-${VERSION}-MacOSX-sdk.tgz gmsh-stable-MacOSX-sdk.tgz"
- ssh geuzaine@gmsh.info "cd .wwwgmsh/bin/macOS && rm -f gmsh-stable-MacOSARM* && ln -s gmsh-${VERSION}-MacOSARM.dmg gmsh-stable-MacOSARM.dmg && ln -s gmsh-${VERSION}-MacOSARM-sdk.tgz gmsh-stable-MacOSARM-sdk.tgz"
- ssh geuzaine@gmsh.info "cd .wwwgmsh/src && rm -f gmsh-stable-source.tgz && ln -s gmsh-${VERSION}-source.tgz gmsh-stable-source.tgz"
tags:
- linux64
- docker
only:
- /^gmsh_.*$/
This diff is collapsed.
This diff is collapsed.
Gmsh is copyright (C) 1997-2024
Christophe Geuzaine
<cgeuzaine at uliege.be>
and
Jean-Francois Remacle
<jean-francois.remacle at uclouvain.be>
Code contributions to Gmsh have been provided by David Colignon (colormaps),
Emilie Marchandise (old compound geometrical entities), Gaetan Bricteux (Gauss
integration and levelsets), Jacques Lechelle (DIFFPACK export), Jonathan
Lambrechts (mesh size fields, solver, Python wrappers), Jozef Vesely (old Tetgen
integration), Koen Hillewaert (high order elements, generalized periodic
meshes), Laurent Stainier (eigenvalue solvers, tensor display and help with
macOS port), Marc Ume (original list and tree code), Mark van Doesburg (old
OpenCASCADE face connection), Matt Gundry (Plot3d export), Matti Pellikka (cell
complex and homology solver), Nicolas Tardieu (help with Netgen integration),
Pascale Noyret (MED mesh IO), Pierre Badel (root finding and minimization), Ruth
Sabariego (pyramids), Stephen Guzik (old CGNS IO, old partitioning code),
Bastien Gorissen (parallel remote post-processing), Eric Bechet (solver), Gilles
Marckmann (camera and stero mode, X3D export), Ashish Negi (Netgen CAD healing),
Trevor Strickler (hybrid structured mesh coupling with pyramids), Amaury Johnen
(Bezier code, high-order element validity), Benjamin Ruard (old Java wrappers),
Maxime Graulich (iOS/Android port), Francois Henrotte (ONELAB metamodels),
Sebastian Eiser (PGF export), Alexis Salzman (compressed IO), Hang Si (TetGen/BR
boundary recovery code), Fernando Lorenzo (Tochnog export), Larry Price (Gambit
export), Anthony Royer (new partitioning code, MSH4 IO), Darcy Beurle (code
cleanup and performance improvements), Celestin Marot (HXT/tetMesh),
Pierre-Alexandre Beaufort (HXT/reparam), Zhidong Han (LSDYNA export), Ismail
Badia (hierarchical basis functions), Jeremy Theler (X3D export), Thomas
Toulorge (high order mesh optimizer, new CGNS IO), Max Orok (binary PLY), Marek
Wojciechowski (PyPi packaging), Maxence Reberol (automatic transfinite, quad
meshing tools), Michael Ermakov (Gambit IO, Fortran API, TransfiniteTri,
boundary layer fans), Alex Krasner (X3D export), Giannis Nikiteas (Fortran API),
Paul Sharp (Radioss export), Marco Failla (2D fillet/offset and API
additions). See comments in the sources for more information. If we forgot to
list your contributions please send us an email!
Thanks to the following folks who have contributed by providing fresh ideas on
theoretical or programming topics, who have sent patches, requests for changes
or improvements, or who gave us access to exotic machines for testing Gmsh: Juan
Abanto, Olivier Adam, Guillaume Alleon, Laurent Champaney, Pascal Dupuis,
Patrick Dular, Philippe Geuzaine, Johan Gyselinck, Francois Henrotte, Benoit
Meys, Nicolas Moes, Osamu Nakamura, Chad Schmutzer, Jean-Luc Fl'ejou, Xavier
Dardenne, Christophe Prud'homme, Sebastien Clerc, Jose Miguel Pasini, Philippe
Lussou, Jacques Kools, Bayram Yenikaya, Peter Hornby, Krishna Mohan Gundu,
Christopher Stott, Timmy Schumacher, Carl Osterwisch, Bruno Frackowiak, Philip
Kelleners, Romuald Conty, Renaud Sizaire, Michel Benhamou, Tom De Vuyst, Kris
Van den Abeele, Simon Vun, Simon Corbin, Thomas De-Soza, Marcus Drosson, Antoine
Dechaume, Jose Paulo Moitinho de Almeida, Thomas Pinchard, Corrado Chisari, Axel
Hackbarth, Peter Wainwright, Jiri Hnidek, Thierry Thomas, Konstantinos Poulios,
Laurent Van Miegroet, Shahrokh Ghavamian, Geordie McBain, Jose Paulo Moitinho de
Almeida, Guillaume Demesy, Wendy Merks-Swolfs, Cosmin Stefan Deaconu, Nigel
Nunn, Serban Georgescu, Julien Troufflard, Michele Mocciola, Matthijs Sypkens
Smit, Sauli Ruuska, Romain Boman, Fredrik Ekre, Mark Burton, Max Orok, Paul
Cristini, Isuru Fernando, Jose Paulo Moitinho de Almeida, Sophie Le Bras,
Alberto Escrig, Samy Mukadi, Peter Johnston, Bruno de Sousa Alves, Stefan
Bruens, Luca Verzeroli, Tristan Seidlhofer, Ding Jiaming, Joost Gevaert, Marcus
Calhoun-Lopez, Michel Zou, Sir Sunsheep, Mariano Forti, Walter Steffe, Nico
Schloemer, Simon Tournier, Alexandru Dadalau, Thomas Ulrich, Matthias Diener,
Jamie Border, Kenneth Jansen, Steven Masfaraud, Sai Sumanth Moturu, Arie
Westland, Andreas Farley, Mahesh Madhav, Zoltan Csati, Thierry Hocquellet,
Christophe Bourcier, Mattéo Couplet, Giuseppe Musacchio, Romin Tomasetti, Lin Qi
Chen, Tim Furlan, Matthias Lang, Tim Gabriel, Julien Chapelat, Boris Martin,
Thomas Pirottin, Kazuyoshi Furutaka, Mariusz Wozniak, Christophe Friebel,
Thierry Thomas, Joonas Haapsaari, Jani V"alimaa, Erik Schaubelt, Louis Denis,
Francis Franklin, Florian Blachère, Aleksandr Artemyev, Carlos Ballesteros,
Theodore Chang, Tom Gillam.
Special thanks to Bill Spitzak, Michael Sweet, Matthias Melcher, Greg Ercolano
and others for the Fast Light Tool Kit on which Gmsh's GUI is based. See
http://www.fltk.org for more info on this excellent object-oriented,
cross-platform toolkit. Special thanks also to EDF for funding the original
OpenCASCADE and MED integration in 2006-2007. Gmsh development was also
financially supported by the PRACE project funded in part by the EU's Horizon
2020 Research and Innovation programme (2014-2020) under grant agreement 823767.
The TetGen/BR code (src/mesh/tetgenBR.{cpp,h}) is copyright (c) 2016 Hang Si,
Weierstrass Institute for Applied Analysis and Stochatics. It is relicensed
under the terms of LICENSE.txt for use in Gmsh thanks to a Software License
Agreement between Weierstrass Institute for Applied Analysis and Stochastics and
GMESH SPRL.
The AVL tree code (src/common/avl.{cpp,h}) and the YUV image code
(src/graphics/gl2yuv.{cpp,h}) are copyright (C) 1988-1993, 1995 The Regents of
the University of California. Permission to use, copy, modify, and distribute
this software and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in supporting
documentation, and that the name of the University of California not be used in
advertising or publicity pertaining to distribution of the software without
specific, written prior permission. The University of California makes no
representations about the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
The picojson code (src/common/picojson.h) is Copyright 2009-2010 Cybozu Labs,
Inc., Copyright 2011-2014 Kazuho Oku, All rights reserved. Redistribution and
use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met: 1. Redistributions of source
code must retain the above copyright notice, this list of conditions and the
following disclaimer. 2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. THIS
SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The nanoflann code (src/numeric/nanoflann.hpp) is Copyright 2008-2009 Marius
Muja, 2008-2009 David G. Lowe, 2011-2016 Jose Luis Blanco. Redistribution and
use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met: 1. Redistributions of source
code must retain the above copyright notice, this list of conditions and the
following disclaimer. 2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution. THIS
SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
The trackball code (src/graphics/Trackball.{cpp.h}) is copyright (C) 1993, 1994,
Silicon Graphics, Inc. ALL RIGHTS RESERVED. Permission to use, copy, modify, and
distribute this software for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that both the
copyright notice and this permission notice appear in supporting documentation,
and that the name of Silicon Graphics, Inc. not be used in advertising or
publicity pertaining to distribution of the software without specific, written
prior permission.
The GIF and PPM routines (src/graphics/gl2gif.cpp) are based on code copyright
(C) 1989, 1991, Jef Poskanzer. Permission to use, copy, modify, and distribute
this software and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in supporting
documentation. This software is provided "as is" without express or implied
warranty.
The colorbar widget (src/fltk/colorbarWindow.cpp) was inspired by code from the
Vis5d program for visualizing five dimensional gridded data sets, copyright (C)
1990-1995, Bill Hibbard, Brian Paul, Dave Santek, and Andre Battaiola.
The libOL code (src/common/libol1.{c,h}) is Copyright 2012-2018 - by Loïc
Maréchal / INRIA. This program is a free software. You can redistribute it
and/or modify it under the terms of the MIT License as published by the Open
Source Initiative.
The Fast & memory efficient hashtable based on robin hood hashing
(src/common/robin_hood.h) is Copyright (c) 2018-2020 Martin Ankerl and is
licensed under the MIT License.
In addition, this version of Gmsh may contain the following contributed,
optional codes in the contrib/ directory, each governed by their own license:
* contrib/ANN copyright (C) 1997-2010 University of Maryland and Sunil Arya and
David Mount;
* contrib/gmm copyright (C) 2002-2008 Yves Renard;
* contrib/hxt - Copyright (C) 2017-2020 - Universite catholique de Louvain;
* contrib/kbipack copyright (C) 2005 Saku Suuriniemi;
* contrib/MathEx based in part on the work of the SSCILIB Library, copyright (C)
2000-2003 Sadao Massago;
* contrib/metis written by George Karypis (karypis at cs.umn.edu), copyright (C)
1995-2013 Regents of the University of Minnesota;
* contrib/mpeg_encode copyright (c) 1995 The Regents of the University of
California;
* contrib/Netgen copyright (C) 1994-2004 Joachim Sch"oberl;
* contrib/bamg from Freefem++ copyright (C) Frederic Hecht;
* contrib/ALGLIB (C) Sergey Bochkanov (ALGLIB project);
* contrib/blossom copyright (C) 1995-1997 Bill Cook et al.;
* contrib/bamg from Freefem++ copyright (C) Frederic Hecht;
* contrib/tinyxml2 from Lee Thomason;
* contrib/voro++ from Voro++ Copyright (c) 2008, The Regents of the University
of California, through Lawrence Berkeley National Laboratory (subject to
receipt of any required approvals from the U.S. Dept. of Energy). All rights
reserved;
* contrib/zipper from MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant -
version 1.1 64 bits from Mathias Svensson.
Check the configuration options to see which have been enabled.
# Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file for license information. Please report all
# bugs and problems to the public mailing list <gmsh@geuz.org>.
set(CTEST_PROJECT_NAME "Gmsh")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE_CDASH TRUE)
set(CTEST_DROP_SITE "onelab.info")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=Gmsh")
set(CTEST_TRIGGER_SITE "")
set(SITE ${GMSH_HOST})
set(BUILDNAME "${GMSH_OS}-${GMSH_PACKAGER}")
# Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file for license information. Please report all
# bugs and problems to the public mailing list <gmsh@geuz.org>.
set(SRC
Gmsh.cpp
GmshRemote.cpp
GmshMessage.cpp
gmshPopplerWrapper.cpp
Context.cpp
Options.cpp
CommandLine.cpp
OS.cpp
OpenFile.cpp
CreateFile.cpp
VertexArray.cpp
SmoothData.cpp
Octree.cpp
OctreeInternals.cpp
StringUtils.cpp
ListUtils.cpp
TreeUtils.cpp avl.cpp
MallocUtils.cpp
onelabUtils.cpp
GamePad.cpp
)
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
append_gmsh_src(Common "${SRC};${HDR}")
This diff is collapsed.
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _COMMAND_LINE_H_
#define _COMMAND_LINE_H_
#include <string>
int GetGmshMajorVersion();
int GetGmshMinorVersion();
int GetGmshPatchVersion();
const char *GetGmshExtraVersion();
const char *GetGmshVersion();
const char *GetGmshBuildDate();
const char *GetGmshBuildHost();
const char *GetGmshPackager();
const char *GetGmshBuildOS();
const char *GetGmshShortLicense();
const char *GetGmshBuildOptions();
std::vector<std::pair<std::string, std::string> > GetUsage();
std::vector<std::pair<std::string, std::string> > GetShortcutsUsage(const std::string &ctrl="");
std::vector<std::pair<std::string, std::string> > GetMouseUsage();
void PrintUsage(const std::string &name);
void GetOptions(int argc, char *argv[]);
#endif
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#include <stdlib.h>
#include <string.h>
#include "GmshConfig.h"
#include "Context.h"
#include "OS.h"
#include "GamePad.h"
#if defined(HAVE_FLTK)
#include <FL/Fl.H>
#endif
CTX::CTX() : gamepad(0)
{
// initialize everything that has no default value in DefaultOptions.h
short int word = 0x0001;
char *byte = (char*)&word;
bigEndian = (byte[0] ? 0 : 1);
const char *tmp;
if((tmp = GetEnvironmentVar("GMSH_HOME")))
homeDir = tmp;
#if defined(WIN32)
else if((tmp = GetEnvironmentVar("APPDATA")))
homeDir = tmp;
#else
else if((tmp = GetEnvironmentVar("HOME")))
homeDir = tmp;
#endif
else if((tmp = GetEnvironmentVar("TMP")))
homeDir = tmp;
else if((tmp = GetEnvironmentVar("TEMP")))
homeDir = tmp;
else
homeDir = "";
int len = homeDir.size();
if(len && homeDir[len - 1] != '/')
homeDir += "/";
batch = batchAfterMesh = 0;
outputFileName = "";
bgmFileName = "";
createAppendMeshStatReport = 0;
launchSolverAtStartup = -1;
lc = 1.;
min[0] = min[1] = min[2] = max[2] = 0.;
max[0] = max[1] = 1.; // for nice view when adding point in new model
cg[0] = cg[1] = cg[2] = 0.;
polygonOffset = 0;
printing = 0;
meshTimer[0] = meshTimer[1] = meshTimer[2] = 0.;
drawRotationCenter = 0;
pickElements = 0;
geom.draw = 1;
mesh.draw = 1;
post.draw = 1;
post.combineTime = 0; // try to combineTime views at startup
lock = 0; // very primitive locking
fileread=false;
#if defined(HAVE_FLTK)
glFontEnum = FL_HELVETICA;
#else
glFontEnum = -1;
#endif
forcedBBox = 0;
hideUnselected = 0;
numWindows = numTiles = 1;
deltaFontSize = 0;
recentFiles.resize(5);
mesh.optimizeLloyd = 0;
gamepad = 0;
// need to initialize these too, since the corresponding opt_XXX
// routine uses the current value to set "mesh.changed"
mesh.changed = 0;
mesh.qualityInf = mesh.qualitySup = mesh.qualityType = 0;
mesh.radiusInf = mesh.radiusSup = 0;
mesh.lines = mesh.triangles = mesh.tetrahedra = mesh.quadrangles = 0;
mesh.prisms = mesh.pyramids = mesh.hexahedra = 0;
mesh.volumesEdges = mesh.volumesFaces = mesh.surfacesEdges = mesh.surfacesFaces = 0;
mesh.volumesFaces = mesh.surfacesEdges = mesh.surfacesFaces = 0;
mesh.smoothInternalEdges = mesh.smoothNormals = mesh.reverseAllNormals = 0;
mesh.explode = mesh.angleSmoothNormals = 0.;
mesh.numSubEdges = 0;
mesh.colorCarousel = 0;
mesh.ignorePartBound = 0;
mesh.saveTri = 0;
color.mesh.tangents = color.mesh.tetrahedron = color.mesh.triangle = 0;
color.mesh.prism = color.mesh.pyramid = color.mesh.hexahedron = 0;
color.mesh.tangents = color.mesh.line = color.mesh.quadrangle = 0;
for (int i = 0; i < 20; i++)
color.mesh.carousel[i] = 0;
// added by Gauthier Becker (these are not initialized by default
// leading to valgrind error) Feel free to change the default values)
mesh.switchElementTags=0;
terminal=0;
}
CTX::~CTX()
{
if(gamepad) delete gamepad;
}
CTX *CTX::_instance = NULL;
CTX *CTX::instance()
{
if(!_instance) _instance = new CTX();
return _instance;
}
unsigned int CTX::packColor(int R, int G, int B, int A)
{
if(bigEndian)
return ( (unsigned int)((R)<<24 | (G)<<16 | (B)<<8 | (A)) );
else
return ( (unsigned int)((A)<<24 | (B)<<16 | (G)<<8 | (R)) );
}
int CTX::unpackRed(unsigned int X)
{
if(bigEndian)
return ( ( (X) >> 24 ) & 0xff );
else
return ( (X) & 0xff );
}
int CTX::unpackGreen(unsigned int X)
{
if(bigEndian)
return ( ( (X) >> 16 ) & 0xff );
else
return ( ( (X) >> 8 ) & 0xff );
}
int CTX::unpackBlue(unsigned int X)
{
if(bigEndian)
return ( ( (X) >> 8 ) & 0xff );
else
return ( ( (X) >> 16 ) & 0xff );
}
int CTX::unpackAlpha(unsigned int X)
{
if(bigEndian)
return ( (X) & 0xff );
else
return ( ( (X) >> 24 ) & 0xff );
}
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _CONTEXT_H_
#define _CONTEXT_H_
#include <vector>
#include <map>
#include <string>
#include "CGNSOptions.h"
#include "meshPartitionOptions.h"
class GamePad;
// The interface-independent context.
struct contextMeshOptions {
int draw, changed, light, lightTwoSide, lightLines, pointType;
int points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, pyramids;
int surfacesEdges, surfacesFaces, volumesEdges, volumesFaces, numSubEdges;
int pointsNum, linesNum, surfacesNum, volumesNum, qualityType, labelType;
int optimize, optimizeNetgen, optimizeLloyd, smoothCrossField, refineSteps, remove4triangles;
double normals, tangents, explode, angleSmoothNormals, allowSwapEdgeAngle;
double mshFileVersion, mshFilePartitioned, pointSize, lineWidth;
double qualityInf, qualitySup, radiusInf, radiusSup;
double scalingFactor, lcFactor, randFactor, lcIntegrationPrecision;
double lcMin, lcMax, toleranceEdgeLength, anisoMax, smoothRatio;
int lcFromPoints, lcFromCurvature, lcExtendFromBoundary;
int dual, voronoi, drawSkinOnly, colorCarousel, labelSampling;
int fileFormat, nbSmoothing, algo2d, algo3d, algoSubdivide;
int algoRecombine, recombineAll, recombine3DAll;
int remeshParam, remeshAlgo;
int order, secondOrderLinear, secondOrderIncomplete;
int secondOrderExperimental, meshOnlyVisible;
int smoothInternalEdges, minCircPoints, minCurvPoints;
int smoothNLayers;
double smoothDistoThreshold, smoothPoissonRatio;
int saveAll, saveTri, saveGroupsOfNodes, binary, bdfFieldFormat, saveParametric;
int smoothNormals, reverseAllNormals, zoneDefinition, clip;
int saveElementTagType;
int switchElementTags;
int multiplePasses;
int cgnsImportOrder;
std::map<int,int> algo2d_per_face;
std::map<int,int> curvature_control_per_face;
int bunin;
int ignorePartBound;
};
struct contextGeometryOptions {
int draw, light, lightTwoSide, points, lines, surfaces, volumes;
int pointsNum, linesNum, surfacesNum, volumesNum, labelType;
double pointSize, lineWidth, selectedPointSize, selectedLineWidth;
int pointType, lineType, surfaceType, numSubEdges;
int oldCircle, oldNewreg, oldRuledSurface;
int extrudeSplinePoints, extrudeReturnLateral;
double normals, tangents, scalingFactor;
int autoCoherence, highlightOrphans, clip, useTransform;
double tolerance, snap[3], transform[3][3], offset[3];
int occFixDegenerated, occFixSmallEdges, occFixSmallFaces;
int occSewFaces, occConnectFaces;
int copyMeshingMethod, exactExtrusion;
int matchGeomAndMesh;
int hideCompounds, orientedPhysicals;
};
class CTX {
private:
static CTX *_instance;
public:
CTX();
~CTX();
static CTX *instance();
public:
// files on the command line and various file names
std::vector<std::string> files;
std::string bgmFileName, outputFileName, defaultFileName, tmpFileName;
std::string sessionFileName, optionsFileName, errorFileName;
std::string meshStatReportFileName;
std::string argv0;
// the home directory
std::string homeDir;
// file history
std::vector<std::string> recentFiles;
// create mesh statistics report (0: do nothing, 1: create, 2: append)
int createAppendMeshStatReport;
// should we launch a solver at startup?
int launchSolverAtStartup ;
// save session/option file on exit?
int sessionSave, optionsSave;
// ask confirmation when overwriting files?
int confirmOverwrite;
// forced display host:0.0 under X11
std::string display;
// FLTK theme
std::string guiTheme;
// print messages on to the terminal?
int terminal;
// number of graphical windows/tiles
int numWindows, numTiles;
// text editor command (with included '%s')
std::string editor;
// pattern of files to watch out for
std::string watchFilePattern;
// show tootips in the GUI?
int tooltips;
// position and size of various windows in the GUI
int glPosition[2], glSize[2], msgSize, menuPosition[2], menuSize[2], detachedMenu;
int optPosition[2], visPosition[2], hotPosition[2], clipPosition[2], manipPosition[2];
int statPosition[2], ctxPosition[2];
int pluginPosition[2], pluginSize[2], fieldPosition[2], fieldSize[2];
int fileChooserPosition[2], extraPosition[2], extraSize[2];
// use the system menu bar on Mac OS X?
int systemMenuBar;
// batch mode (-4: lua session, -3: server daemon, -2: check coherence, -1: write
// geo, 0: full gfx, 1: 1D mesh, 2: 2D mesh, 3: 3D mesh, 4: adapt
// mesh, 5: refine mesh)
int batch;
// batch operations to apply after meshing (1: partition mesh)
int batchAfterMesh;
// initial menu (0: automatic, 1: geom, 2: mesh, 3: solver, 4: post)
int initialContext;
// never popup dialogs in scripts (use default values instead)?
int noPopup;
// make all windows "non modal"?
int nonModalWindows;
// clipping plane distance factor
double clipFactor;
// display border factor (0 = model fits window size exactly)
double displayBorderFactor;
// do or do not use the trackball for rotations
int useTrackball, trackballHyperbolicSheet;
// gamepad controller
GamePad *gamepad;
// point around which to rotate the scene
double rotationCenter[3];
// rotate around the center of mass instead of rotationCenter[]
int rotationCenterCg;
// "overall" x, y and z min used for drawing and lc computation
double min[3], max[3];
// "center of mass" of the current geometry, used for graphics only
double cg[3];
// characteristic length for the whole problem (never used in mesh
// generation ->only for geo/post)
double lc;
// double buffer/antialias/stereo graphics?
int db, antialiasing, stereo, camera ;
bool fileread; ;
double eye_sep_ratio,focallength_ratio,camera_aperture;
// orthogonal projection?
int ortho;
// draw the bounding boxes and the rot center?
int drawBBox, drawRotationCenter;
// draw simplified model during user interaction?
int fastRedraw;
// small axes options
int smallAxes, smallAxesSize, smallAxesPos[2];
// large axes options
int axes, axesAutoPosition, axesMikado, axesForceValue;
double axesPosition[6], axesValue[6], axesTics[3];
std::string axesLabel[3], axesFormat[3];
// simple dynamic lock (should be a mutex)
int lock;
// enable alpha blending?
int alpha;
// mouse2 zoom coefficient
double zoomFactor;
// draw background gradient?
int bgGradient;
// draw background image?
std::string bgImageFileName;
double bgImagePosition[2];
// fltk font size (and delta for palette windows)
int fontSize, deltaFontSize;
// font name, FLTK enum and size for opengl graphics
std::string glFont, glFontTitle;
int glFontEnum, glFontEnumTitle, glFontSize, glFontSizeTitle;
// point/line widths
double pointSize, lineWidth;
// light options
int light[6];
double lightPosition[6][4], shine, shineExponent;
// clipping plane options
double clipPlane[6][4];
int clipWholeElements, clipOnlyDrawIntersectingVolume, clipOnlyVolume;
// polygon offset options
int polygonOffset, polygonOffsetAlways;
double polygonOffsetFactor, polygonOffsetUnits;
// color scheme
int colorScheme;
// number of subdivisions for gluQuadrics
int quadricSubdivisions;
// vector display type and options (for normals, etc.)
int vectorType;
double arrowRelHeadRadius, arrowRelStemRadius, arrowRelStemLength;
// records cpu times for 1-D, 2-D and 3-D mesh generation
double meshTimer[3];
// dynamic variable tracking if the bbox is currently imposed
int forcedBBox;
// enable selection/hover/picking using the mouse
int mouseSelection, mouseHoverMeshes, pickElements;
// disable some warnings for expert users?
int expertMode;
// dynamic: equal to 1 while gmsh is printing
int printing;
// hide all unselected entities?
int hideUnselected;
// temporary storage of rotation, translation, scale (until the GUI
// is ready)
double tmpRotation[3], tmpTranslation[3], tmpScale[3], tmpQuaternion[4];
// geometry options
contextGeometryOptions geom;
// mesh options
contextMeshOptions mesh;
// FIXME: putting these in the mesh struct (where they belong) causes
// an LNK1179 error ("duplicate COMDAT") with MSVC...
meshPartitionOptions partitionOptions;
CGNSOptions cgnsOptions;
// post processing options
struct{
int draw, link, horizontalScales;
int smooth, animCycle, animStep, combineTime, combineRemoveOrig;
int fileFormat, plugins;
double animDelay;
}post;
// solver options
struct{
int plugins, listen;
double timeout;
std::string socketName;
std::string name[5], executable[5], remoteLogin[5];
int autoSaveDatabase, autoArchiveOutputFiles, autoMesh, autoMergeFile;
int autoHideNewViews, autoShowLastStep, autoCheck;
}solver;
// print options
struct{
int fileFormat, epsQuality, epsCompress, epsPS3Shading;
int epsOcclusionCulling, epsBestRoot;
double epsLineWidthFactor, epsPointSizeFactor;
int jpegQuality, jpegSmoothing, geoLabels, geoOnlyPhysicals;
int text, texAsEquation;
int gifDither, gifSort, gifInterlace, gifTransparent;
int posElementary, posElement, posGamma, posEta, posRho, posDisto;
int compositeWindows, deleteTmpFiles, background;
int width, height;
} print;
// color options
struct{
unsigned int bg, bgGrad, fg, text, axes, smallAxes;
unsigned int ambientLight[6], diffuseLight[6], specularLight[6];
struct{
unsigned int point, line, surface, volume;
unsigned int selection, highlight[3], projection;
unsigned int tangents, normals;
} geom;
struct{
unsigned int vertex, vertexSup, line, triangle, quadrangle;
unsigned int tetrahedron, hexahedron, prism, pyramid;
unsigned int carousel[20];
unsigned int tangents, normals;
} mesh;
} color;
// is the machine big-endian?
int bigEndian;
// how RGBA values are packed and unpacked into/from an unsigned integer to be
// fed to glColor4ubv (depends on machine byte ordering!):
unsigned int packColor(int R, int G, int B, int A);
int unpackRed(unsigned int X);
int unpackGreen(unsigned int X);
int unpackBlue(unsigned int X);
int unpackAlpha(unsigned int X);
};
#endif
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#include "GmshConfig.h"
#include "GmshMessage.h"
#include "GModel.h"
#include "GmshDefines.h"
#include "StringUtils.h"
#include "Context.h"
#include "Options.h"
#include "OS.h"
#if defined(HAVE_OPENGL)
#include "drawContext.h"
#endif
#if defined(HAVE_FLTK)
#include "FlGui.h"
#include "graphicWindow.h"
#include "gl2ps.h"
#include "gl2gif.h"
#include "gl2jpeg.h"
#include "gl2png.h"
#include "gl2ppm.h"
#include "gl2yuv.h"
#endif
int GetFileFormatFromExtension(const std::string &ext)
{
if (ext == ".geo") return FORMAT_GEO;
else if(ext == ".msh") return FORMAT_MSH;
else if(ext == ".pos") return FORMAT_POS;
else if(ext == ".opt") return FORMAT_OPT;
else if(ext == ".unv") return FORMAT_UNV;
else if(ext == ".vtk") return FORMAT_VTK;
else if(ext == ".txt") return FORMAT_TXT;
else if(ext == ".stl") return FORMAT_STL;
else if(ext == ".cgns") return FORMAT_CGNS;
else if(ext == ".med") return FORMAT_MED;
else if(ext == ".rmed") return FORMAT_RMED;
else if(ext == ".ir3") return FORMAT_IR3;
else if(ext == ".mesh") return FORMAT_MESH;
else if(ext == ".mail") return FORMAT_MAIL;
else if(ext == ".bdf") return FORMAT_BDF;
else if(ext == ".diff") return FORMAT_DIFF;
else if(ext == ".inp") return FORMAT_INP;
else if(ext == ".nas") return FORMAT_BDF;
else if(ext == ".p3d") return FORMAT_P3D;
else if(ext == ".wrl") return FORMAT_VRML;
else if(ext == ".vrml") return FORMAT_VRML;
else if(ext == ".ply2") return FORMAT_PLY2;
else if(ext == ".gif") return FORMAT_GIF;
else if(ext == ".jpg") return FORMAT_JPEG;
else if(ext == ".jpeg") return FORMAT_JPEG;
else if(ext == ".mpg") return FORMAT_MPEG;
else if(ext == ".mpeg") return FORMAT_MPEG;
else if(ext == ".png") return FORMAT_PNG;
else if(ext == ".ps") return FORMAT_PS;
else if(ext == ".eps") return FORMAT_EPS;
else if(ext == ".pdf") return FORMAT_PDF;
else if(ext == ".tex") return FORMAT_TEX;
else if(ext == ".svg") return FORMAT_SVG;
else if(ext == ".ppm") return FORMAT_PPM;
else if(ext == ".yuv") return FORMAT_YUV;
else if(ext == ".brep") return FORMAT_BREP;
else if(ext == ".step") return FORMAT_STEP;
else if(ext == ".stp") return FORMAT_STEP;
else if(ext == ".iges") return FORMAT_IGES;
else if(ext == ".igs") return FORMAT_IGES;
else return -1;
}
int GuessFileFormatFromFileName(const std::string &fileName)
{
std::string ext = SplitFileName(fileName)[2];
return GetFileFormatFromExtension(ext);
}
std::string GetDefaultFileName(int format)
{
std::vector<std::string> split = SplitFileName(GModel::current()->getFileName());
std::string name = split[0] + split[1];
switch(format){
case FORMAT_GEO: name += ".geo_unrolled"; break;
case FORMAT_MSH: name += ".msh"; break;
case FORMAT_POS: name += ".pos"; break;
case FORMAT_OPT: name += ".opt"; break;
case FORMAT_UNV: name += ".unv"; break;
case FORMAT_VTK: name += ".vtk"; break;
case FORMAT_STL: name += ".stl"; break;
case FORMAT_CGNS: name += ".cgns"; break;
case FORMAT_MED: name += ".med"; break;
case FORMAT_RMED: name += ".rmed"; break;
case FORMAT_IR3: name += ".ir3"; break;
case FORMAT_MESH: name += ".mesh"; break;
case FORMAT_MAIL: name += ".mail"; break;
case FORMAT_BDF: name += ".bdf"; break;
case FORMAT_DIFF: name += ".diff"; break;
case FORMAT_INP: name += ".inp"; break;
case FORMAT_P3D: name += ".p3d"; break;
case FORMAT_VRML: name += ".wrl"; break;
case FORMAT_PLY2: name += ".ply2"; break;
case FORMAT_GIF: name += ".gif"; break;
case FORMAT_JPEG: name += ".jpg"; break;
case FORMAT_MPEG: name += ".mpg"; break;
case FORMAT_PNG: name += ".png"; break;
case FORMAT_PS: name += ".ps"; break;
case FORMAT_EPS: name += ".eps"; break;
case FORMAT_PDF: name += ".pdf"; break;
case FORMAT_TEX: name += ".tex"; break;
case FORMAT_SVG: name += ".svg"; break;
case FORMAT_PPM: name += ".ppm"; break;
case FORMAT_YUV: name += ".yuv"; break;
case FORMAT_BREP: name += ".brep"; break;
case FORMAT_IGES: name += ".iges"; break;
case FORMAT_STEP: name += ".step"; break;
default: break;
}
return name;
}
#if defined(HAVE_FLTK)
static PixelBuffer *GetCompositePixelBuffer(GLenum format, GLenum type)
{
openglWindow *newg = 0;
if(CTX::instance()->print.width > 0 || CTX::instance()->print.height > 0){
GLint width = FlGui::instance()->getCurrentOpenglWindow()->w();
GLint height = FlGui::instance()->getCurrentOpenglWindow()->h();
if(CTX::instance()->print.width <= 0){
double w = width * CTX::instance()->print.height / (double)height;
width = (int)w;
height = CTX::instance()->print.height;
}
else if(CTX::instance()->print.height <= 0){
double h = height * CTX::instance()->print.width / (double)width;
height = (int)h;
width = CTX::instance()->print.width;
}
else{
width = CTX::instance()->print.width;
height = CTX::instance()->print.height;
}
newg = new openglWindow(100, 100, width, height);
int mode = FL_RGB | FL_DEPTH | (CTX::instance()->db ? FL_DOUBLE : FL_SINGLE);
if(CTX::instance()->antialiasing) mode |= FL_MULTISAMPLE;
newg->mode(mode);
newg->end();
newg->getDrawContext()->copyViewAttributes
(FlGui::instance()->getCurrentOpenglWindow()->getDrawContext());
newg->show();
openglWindow::setLastHandled(newg);
}
PixelBuffer *buffer;
if(newg || !CTX::instance()->print.compositeWindows){
GLint width = FlGui::instance()->getCurrentOpenglWindow()->w();
GLint height = FlGui::instance()->getCurrentOpenglWindow()->h();
buffer = new PixelBuffer(width, height, format, type);
buffer->fill(CTX::instance()->batch);
}
else{
graphicWindow *g = FlGui::instance()->graph[0];
for(unsigned int i = 1; i < FlGui::instance()->graph.size(); i++){
for(unsigned int j = 0; j < FlGui::instance()->graph[i]->gl.size(); j++){
if(FlGui::instance()->graph[i]->gl[j] ==
FlGui::instance()->getCurrentOpenglWindow()){
g = FlGui::instance()->graph[i];
break;
}
}
}
int ww = 0, hh = 0;
std::vector<PixelBuffer*> buffers;
for(unsigned int i = 0; i < g->gl.size(); i++){
openglWindow::setLastHandled(g->gl[i]);
buffer = new PixelBuffer(g->gl[i]->w(), g->gl[i]->h(), format, type);
buffer->fill(CTX::instance()->batch);
buffers.push_back(buffer);
ww = std::max(ww, g->gl[i]->x() + g->gl[i]->w());
hh = std::max(hh, g->gl[i]->y() + g->gl[i]->h());
}
buffer = new PixelBuffer(ww, hh, format, type);
for(unsigned int i = 0; i < g->gl.size(); i++){
buffer->copyPixels(g->gl[i]->x(), hh - g->gl[i]->h() - g->gl[i]->y(),
buffers[i]);
delete buffers[i];
}
}
if(newg){
openglWindow::setLastHandled(0);
newg->hide();
delete newg;
}
return buffer;
}
#endif
void CreateOutputFile(const std::string &fileName, int format, bool redraw)
{
std::string name = fileName;
if(name.empty()) name = GetDefaultFileName(format);
int oldFormat = CTX::instance()->print.fileFormat;
CTX::instance()->print.fileFormat = format;
CTX::instance()->printing = 1;
bool error = false;
if(redraw)
Msg::StatusBar(true, "Writing '%s'...", name.c_str());
switch (format) {
case FORMAT_AUTO:
CreateOutputFile(name, GuessFileFormatFromFileName(name), false);
break;
case FORMAT_OPT:
PrintOptions(0, GMSH_FULLRC, 1, 1, name.c_str());
break;
case FORMAT_MSH:
if(GModel::current()->getMeshPartitions().size() &&
CTX::instance()->mesh.mshFilePartitioned == 1)
GModel::current()->writePartitionedMSH
(name, CTX::instance()->mesh.binary, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.saveParametric, CTX::instance()->mesh.scalingFactor);
else if(GModel::current()->getMeshPartitions().size() &&
CTX::instance()->mesh.mshFilePartitioned == 2)
GModel::current()->writeMSH
(name, CTX::instance()->mesh.mshFileVersion,
CTX::instance()->mesh.binary, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.saveParametric, CTX::instance()->mesh.scalingFactor,
0, -1000);
else
GModel::current()->writeMSH
(name, CTX::instance()->mesh.mshFileVersion,
CTX::instance()->mesh.binary, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.saveParametric, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_STL:
GModel::current()->writeSTL
(name, CTX::instance()->mesh.binary, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_VRML:
GModel::current()->writeVRML
(name, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_PLY2:
GModel::current()->writePLY2(name);
break;
case FORMAT_UNV:
GModel::current()->writeUNV
(name, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.saveGroupsOfNodes,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_VTK:
GModel::current()->writeVTK
(name, CTX::instance()->mesh.binary, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.scalingFactor,
CTX::instance()->bigEndian);
break;
case FORMAT_MESH:
GModel::current()->writeMESH
(name, CTX::instance()->mesh.saveElementTagType,
CTX::instance()->mesh.saveAll, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_MAIL:
GModel::current()->writeMAIL
(name, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_IR3:
GModel::current()->writeIR3
(name, CTX::instance()->mesh.saveElementTagType,
CTX::instance()->mesh.saveAll, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_BDF:
GModel::current()->writeBDF
(name, CTX::instance()->mesh.bdfFieldFormat,
CTX::instance()->mesh.saveElementTagType, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_DIFF:
GModel::current()->writeDIFF
(name, CTX::instance()->mesh.binary, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_INP:
GModel::current()->writeINP
(name, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.saveGroupsOfNodes,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_P3D:
GModel::current()->writeP3D
(name, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_CGNS:
GModel::current()->writeCGNS
(name, CTX::instance()->mesh.zoneDefinition, CTX::instance()->cgnsOptions,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_MED:
GModel::current()->writeMED
(name, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_POS:
GModel::current()->writePOS
(name, CTX::instance()->print.posElementary,
CTX::instance()->print.posElement, CTX::instance()->print.posGamma,
CTX::instance()->print.posEta, CTX::instance()->print.posRho,
CTX::instance()->print.posDisto, CTX::instance()->mesh.saveAll,
CTX::instance()->mesh.scalingFactor);
break;
case FORMAT_GEO:
GModel::current()->writeGEO(name, CTX::instance()->print.geoLabels,
CTX::instance()->print.geoOnlyPhysicals);
break;
case FORMAT_BREP:
GModel::current()->writeOCCBREP(name);
break;
case FORMAT_STEP:
GModel::current()->writeOCCSTEP(name);
break;
#if defined(HAVE_FLTK)
case FORMAT_PPM:
case FORMAT_YUV:
case FORMAT_GIF:
case FORMAT_JPEG:
case FORMAT_PNG:
{
if(!FlGui::available()) break;
FILE *fp = fopen(name.c_str(), "wb");
if(!fp){
Msg::Error("Unable to open file '%s'", name.c_str());
error = true;
break;
}
PixelBuffer *buffer = GetCompositePixelBuffer(GL_RGB, GL_UNSIGNED_BYTE);
if(format == FORMAT_PPM)
create_ppm(fp, buffer);
else if(format == FORMAT_YUV)
create_yuv(fp, buffer);
else if(format == FORMAT_GIF)
create_gif(fp, buffer,
CTX::instance()->print.gifDither,
CTX::instance()->print.gifSort,
CTX::instance()->print.gifInterlace,
CTX::instance()->print.gifTransparent);
else if(format == FORMAT_JPEG)
create_jpeg(fp, buffer, CTX::instance()->print.jpegQuality,
CTX::instance()->print.jpegSmoothing);
else
create_png(fp, buffer, 100);
delete buffer;
fclose(fp);
}
break;
case FORMAT_PS:
case FORMAT_EPS:
case FORMAT_PDF:
case FORMAT_SVG:
{
if(!FlGui::available()) break;
FILE *fp = fopen(name.c_str(), "wb");
if(!fp){
Msg::Error("Unable to open file '%s'", name.c_str());
error = true;
break;
}
std::string base = SplitFileName(name)[1];
GLint width = FlGui::instance()->getCurrentOpenglWindow()->w();
GLint height = FlGui::instance()->getCurrentOpenglWindow()->h();
GLint viewport[4] = {0, 0, width, height};
PixelBuffer buffer(width, height, GL_RGB, GL_FLOAT);
if(CTX::instance()->print.epsQuality == 0)
buffer.fill(CTX::instance()->batch);
int psformat =
(format == FORMAT_PDF) ? GL2PS_PDF :
(format == FORMAT_PS) ? GL2PS_PS :
(format == FORMAT_SVG) ? GL2PS_SVG :
GL2PS_EPS;
int pssort =
(CTX::instance()->print.epsQuality == 3) ? GL2PS_NO_SORT :
(CTX::instance()->print.epsQuality == 2) ? GL2PS_BSP_SORT :
GL2PS_SIMPLE_SORT;
int psoptions =
GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT |
(CTX::instance()->print.epsOcclusionCulling ? GL2PS_OCCLUSION_CULL : 0) |
(CTX::instance()->print.epsBestRoot ? GL2PS_BEST_ROOT : 0) |
(CTX::instance()->print.background ? GL2PS_DRAW_BACKGROUND : 0) |
(CTX::instance()->print.epsCompress ? GL2PS_COMPRESS : 0) |
(CTX::instance()->print.epsPS3Shading ? 0 : GL2PS_NO_PS3_SHADING);
GLint buffsize = 0;
int res = GL2PS_OVERFLOW;
while(res == GL2PS_OVERFLOW) {
buffsize += 2048 * 2048;
gl2psBeginPage(base.c_str(), "Gmsh", viewport,
psformat, pssort, psoptions, GL_RGBA, 0, NULL,
15, 20, 10, buffsize, fp, base.c_str());
if(CTX::instance()->print.epsQuality == 0){
double modelview[16], projection[16];
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho((double)viewport[0], (double)viewport[2],
(double)viewport[1], (double)viewport[3], -1., 1.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRasterPos2d(0, 0);
gl2psDrawPixels(width, height, 0, 0, GL_RGB, GL_FLOAT, buffer.getPixels());
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(projection);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(modelview);
}
else{
buffer.fill(CTX::instance()->batch);
}
res = gl2psEndPage();
}
fclose(fp);
}
break;
case FORMAT_TEX:
{
if(!FlGui::available()) break;
FILE *fp = fopen(name.c_str(), "w");
if(!fp){
Msg::Error("Unable to open file '%s'", name.c_str());
error = true;
break;
}
std::string base = SplitFileName(name)[1];
GLint width = FlGui::instance()->getCurrentOpenglWindow()->w();
GLint height = FlGui::instance()->getCurrentOpenglWindow()->h();
GLint viewport[4] = {0, 0, width, height};
GLint buffsize = 0;
int res = GL2PS_OVERFLOW;
while(res == GL2PS_OVERFLOW) {
buffsize += 2048 * 2048;
gl2psBeginPage(base.c_str(), "Gmsh", viewport,
GL2PS_TEX, GL2PS_NO_SORT, GL2PS_NONE, GL_RGBA, 0, NULL,
0, 0, 0, buffsize, fp, base.c_str());
PixelBuffer buffer(width, height, GL_RGB, GL_UNSIGNED_BYTE);
int oldtext = CTX::instance()->print.text;
CTX::instance()->print.text = 1;
buffer.fill(CTX::instance()->batch);
CTX::instance()->print.text = oldtext;
res = gl2psEndPage();
}
fclose(fp);
}
break;
#if defined(HAVE_MPEG_ENCODE)
case FORMAT_MPEG:
{
std::string parFileName = CTX::instance()->homeDir + ".gmsh-mpeg_encode.par";
FILE *fp = fopen(parFileName.c_str(), "w");
if(!fp){
Msg::Error("Unable to open file '%s'", parFileName.c_str());
error = true;
break;
}
int numViews = (int)opt_post_nb_views(0, GMSH_GET, 0), numSteps = 0;
for(int i = 0; i < numViews; i++){
if(opt_view_visible(i, GMSH_GET, 0))
numSteps = std::max(numSteps,
(int)opt_view_nb_non_empty_timestep(i, GMSH_GET, 0));
}
std::vector<std::string> frames;
for(int i = 0; i < (CTX::instance()->post.animCycle ? numViews : numSteps);
i += CTX::instance()->post.animStep){
char tmp[256];
sprintf(tmp, ".gmsh-%06d.ppm", (int)frames.size());
frames.push_back(tmp);
}
status_play_manual(!CTX::instance()->post.animCycle, 0, false);
for(unsigned int i = 0; i < frames.size(); i++){
CreateOutputFile(CTX::instance()->homeDir + frames[i], FORMAT_PPM, false);
status_play_manual(!CTX::instance()->post.animCycle,
CTX::instance()->post.animStep, false);
}
int repeat = (int)(CTX::instance()->post.animDelay * 24);
if(repeat < 1) repeat = 1;
std::string pattern("I");
// including P frames would lead to smaller files, but the quality
// degradation is perceptible:
// for(int i = 1; i < repeat; i++) pattern += "P";
fprintf(fp, "PATTERN %s\nBASE_FILE_FORMAT PPM\nGOP_SIZE %d\n"
"SLICES_PER_FRAME 1\nPIXEL FULL\nRANGE 10\n"
"PSEARCH_ALG EXHAUSTIVE\nBSEARCH_ALG CROSS2\n"
"IQSCALE 1\nPQSCALE 1\nBQSCALE 25\nREFERENCE_FRAME DECODED\n"
"OUTPUT %s\nINPUT_CONVERT *\nINPUT_DIR %s\nINPUT\n",
pattern.c_str(), repeat, name.c_str(),
CTX::instance()->homeDir.c_str());
for(unsigned int i = 0; i < frames.size(); i++){
fprintf(fp, "%s", frames[i].c_str());
if(repeat > 1) fprintf(fp, " [1-%d]", repeat);
fprintf(fp, "\n");
}
fprintf(fp, "END_INPUT\n");
fclose(fp);
extern int mpeg_encode_main(int, char**);
char *args[] = {(char*)"gmsh", (char*)parFileName.c_str()};
try{
mpeg_encode_main(2, args);
}
catch (const char *msg){
Msg::Error("%s", msg);
error = true;
}
if(opt_print_delete_tmp_files(0, GMSH_GET, 0)){
UnlinkFile(parFileName);
for(unsigned int i = 0; i < frames.size(); i++)
UnlinkFile(CTX::instance()->homeDir + frames[i]);
}
}
break;
#endif
#endif
default:
Msg::Error("Unknown output file format");
error = true;
break;
}
CTX::instance()->print.fileFormat = oldFormat;
CTX::instance()->printing = 0;
if(redraw && !error)
Msg::StatusBar(true, "Done writing '%s'", name.c_str());
#if defined(HAVE_OPENGL)
if(redraw) drawContext::global()->draw();
#endif
}
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _CREATE_FILE_H_
#define _CREATE_FILE_H_
#include <string>
int GetFileFormatFromExtension(const std::string &fileName);
int GuessFileFormatFromFileName(const std::string &fileName);
std::string GetDefaultFileName(int format);
void CreateOutputFile(const std::string &fileName, int format, bool redraw=true);
#endif
This diff is collapsed.
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#include <string>
#include <time.h>
#include "GmshConfig.h"
#include "GmshVersion.h"
#include "GmshMessage.h"
#include "GmshDefines.h"
#include "GmshRemote.h"
#include "GModel.h"
#include "OpenFile.h"
#include "CreateFile.h"
#include "Options.h"
#include "CommandLine.h"
#include "OS.h"
#include "Context.h"
#include "robustPredicates.h"
#if defined(HAVE_POST)
#include "PView.h"
#endif
#if defined(HAVE_ONELAB)
#include "gmshLocalNetworkClient.h"
#endif
#if defined(HAVE_MESH)
#include "Generator.h"
#include "Field.h"
#include "meshPartition.h"
#endif
#if defined(HAVE_PLUGINS)
#include "PluginManager.h"
#endif
#if defined(HAVE_FLTK)
#include "FlGui.h"
#include "graphicWindow.h"
#include "drawContext.h"
#include "onelabGroup.h"
#endif
int GmshInitialize(int argc, char **argv)
{
static bool isInitialized = false;
if(isInitialized) return 1;
isInitialized = true;
#if defined(HAVE_FLTK)
RedirectIOToConsole();
#endif
// we need at least one model during option parsing
GModel *dummy = 0;
if(GModel::list.empty()) dummy = new GModel();
// Initialize messages (parallel stuff, etc.)
Msg::Init(argc, argv);
// Load default options
InitOptions(0);
// Read configuration files and command line options
GetOptions(argc, argv);
// Make sure we have enough resources (stack)
CheckResources();
#if defined(HAVE_PLUGINS)
// Initialize the default plugins
PluginManager::instance()->registerDefaultPlugins();
#endif
// Initialize robust predicates
robustPredicates::exactinit();
if(dummy) delete dummy;
return 1;
}
int GmshSetMessageHandler(GmshMessage *callback)
{
Msg::SetCallback(callback);
return 1;
}
GmshMessage *GmshGetMessageHandler()
{
return Msg::GetCallback();
}
int GmshSetBoundingBox(double xmin, double xmax,
double ymin, double ymax,
double zmin, double zmax)
{
SetBoundingBox(xmin, xmax, ymin, ymax, zmin, zmax);
return 1;
}
int GmshSetOption(const std::string &category, const std::string &name,
std::string value, int index)
{
return StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(), value);
}
int GmshSetOption(const std::string &category, const std::string &name,
double value, int index)
{
return NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(), value);
}
int GmshSetOption(const std::string &category, const std::string &name,
unsigned int value, int index)
{
return ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(), value);
}
int GmshGetOption(const std::string &category, const std::string &name,
std::string &value, int index)
{
return StringOption(GMSH_GET, category.c_str(), index, name.c_str(), value);
}
int GmshGetOption(const std::string &category, const std::string &name,
double &value, int index)
{
return NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), value);
}
int GmshGetOption(const std::string &category, const std::string &name,
unsigned int &value, int index)
{
return ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), value);
}
int GmshOpenProject(const std::string &fileName)
{
OpenProject(fileName);
return 1;
}
int GmshMergeFile(const std::string &fileName)
{
return MergeFile(fileName, true);
}
int GmshMergePostProcessingFile(const std::string &fileName)
{
return MergePostProcessingFile(fileName, CTX::instance()->solver.autoShowLastStep,
CTX::instance()->solver.autoHideNewViews, true);
}
int GmshWriteFile(const std::string &fileName)
{
CreateOutputFile(fileName, FORMAT_AUTO);
return 1;
}
int GmshFinalize()
{
return 1;
}
int GmshBatch()
{
Msg::Info("Running '%s' [Gmsh %s, %d node%s, max. %d thread%s]",
Msg::GetCommandLineArgs().c_str(), GMSH_VERSION,
Msg::GetCommSize(), Msg::GetCommSize() > 1 ? "s" : "",
Msg::GetMaxThreads(), Msg::GetMaxThreads() > 1 ? "s" : "");
Msg::Info("Started on %s", Msg::GetLaunchDate().c_str());
OpenProject(GModel::current()->getFileName());
bool open = false;
for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
if(CTX::instance()->files[i] == "-new")
new GModel();
else if(CTX::instance()->files[i] == "-merge")
open = false;
else if(CTX::instance()->files[i] == "-open")
open = true;
else if(open)
OpenProject(CTX::instance()->files[i]);
else
MergeFile(CTX::instance()->files[i]);
}
#if defined(HAVE_POST) && defined(HAVE_MESH)
if(!CTX::instance()->bgmFileName.empty()) {
MergeFile(CTX::instance()->bgmFileName);
if(PView::list.size())
GModel::current()->getFields()->setBackgroundMesh(PView::list.size() - 1);
else
Msg::Error("Invalid background mesh (no view)");
}
#endif
if(CTX::instance()->batch == -3){
GmshRemote();
}
else if(CTX::instance()->batch == -2){
GModel::current()->checkMeshCoherence(CTX::instance()->geom.tolerance);
}
else if(CTX::instance()->batch == -1){
CreateOutputFile(CTX::instance()->outputFileName,
CTX::instance()->outputFileName.empty() ? FORMAT_GEO :
FORMAT_AUTO);
}
else if(CTX::instance()->batch > 0){
#if defined(HAVE_MESH)
if(CTX::instance()->batch < 4)
GModel::current()->mesh(CTX::instance()->batch);
else if(CTX::instance()->batch == 4)
AdaptMesh(GModel::current());
else if(CTX::instance()->batch == 5)
RefineMesh(GModel::current(), CTX::instance()->mesh.secondOrderLinear);
#if defined(HAVE_CHACO) || defined(HAVE_METIS)
if(CTX::instance()->batchAfterMesh == 1){
if (CTX::instance()->partitionOptions.num_partitions > 1)
PartitionMesh(GModel::current(), CTX::instance()->partitionOptions);
if (CTX::instance()->partitionOptions.renumber)
RenumberMesh(GModel::current(), CTX::instance()->partitionOptions);
}
#endif
#endif
std::string name = CTX::instance()->outputFileName;
if(name.empty()){
if(CTX::instance()->mesh.fileFormat == FORMAT_AUTO)
name = GetDefaultFileName(FORMAT_MSH);
else
name = GetDefaultFileName(CTX::instance()->mesh.fileFormat);
}
CreateOutputFile(name, CTX::instance()->mesh.fileFormat);
}
#if defined(HAVE_FLTK) // FIXME this actually does not require the GUI
// launch solver (if requested)
solver_batch_cb(0, (void*)CTX::instance()->launchSolverAtStartup);
#endif
time_t now;
time(&now);
std::string currtime = ctime(&now);
currtime.resize(currtime.size() - 1);
Msg::Info("Stopped on %s", currtime.c_str());
return 1;
}
int GmshFLTK(int argc, char **argv)
{
#if defined(HAVE_FLTK) && defined(HAVE_POST)
// create the GUI
FlGui::instance(argc, argv);
// display GUI immediately for quick launch time
FlGui::instance()->check();
// open project file and merge all other input files
if(FlGui::getOpenedThroughMacFinder().empty()){
OpenProject(GModel::current()->getFileName());
bool open = false;
for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
if(CTX::instance()->files[i] == "-new"){
GModel::current()->setVisibility(0);
new GModel();
}
else if(CTX::instance()->files[i] == "-merge")
open = false;
else if(CTX::instance()->files[i] == "-open")
open = true;
else if(open)
OpenProject(CTX::instance()->files[i]);
else
MergeFile(CTX::instance()->files[i]);
}
}
else{
OpenProject(FlGui::getOpenedThroughMacFinder());
}
if(CTX::instance()->post.combineTime){
PView::combine(true, 2, CTX::instance()->post.combineRemoveOrig);
FlGui::instance()->updateViews();
}
// init first context
switch (CTX::instance()->initialContext) {
case 1: FlGui::instance()->openModule("Geometry"); break;
case 2: FlGui::instance()->openModule("Mesh"); break;
case 3: FlGui::instance()->openModule("Solver"); break;
case 4: FlGui::instance()->openModule("Post-processing"); break;
default: // automatic
if(PView::list.size()) FlGui::instance()->openModule("Post-processing");
break;
}
// read background mesh if any
if(!CTX::instance()->bgmFileName.empty()) {
MergeFile(CTX::instance()->bgmFileName);
if(PView::list.size())
GModel::current()->getFields()->setBackgroundMesh(PView::list.size() - 1);
else
Msg::Error("Invalid background mesh (no view)");
}
// listen to external solvers
if(CTX::instance()->solver.listen){
gmshLocalNetworkClient *c = new gmshLocalNetworkClient("Listen", "");
c->run();
}
// launch solver (if requested) and fill onelab tree
solver_cb(0, (void*)CTX::instance()->launchSolverAtStartup);
// loop
return FlGui::instance()->run();
#else
Msg::Error("GmshFLTK unavailable: please recompile with FLTK support");
return 0;
#endif
}
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _GMSH_H_
#define _GMSH_H_
#include <string>
#include "GmshMessage.h"
int GmshInitialize(int argc=0, char **argv=0);
int GmshSetMessageHandler(GmshMessage *callback);
GmshMessage *GmshGetMessageHandler();
int GmshSetBoundingBox(double xmin, double xmax,
double ymin, double ymax,
double zmin, double zmax);
int GmshSetOption(const std::string &category, const std::string &name,
std::string value, int index=0);
int GmshSetOption(const std::string &category, const std::string &name,
double value, int index=0);
int GmshSetOption(const std::string &category, const std::string &name,
unsigned int value, int index=0);
int GmshGetOption(const std::string &category, const std::string &name,
std::string &value, int index=0);
int GmshGetOption(const std::string &category, const std::string &name,
double &value, int index=0);
int GmshGetOption(const std::string &category, const std::string &name,
unsigned int &value, int index=0);
int GmshOpenProject(const std::string &fileName);
int GmshMergeFile(const std::string &fileName);
int GmshMergePostProcessingFile(const std::string &fileName);
int GmshWriteFile(const std::string &fileName);
int GmshFinalize();
int GmshBatch();
int GmshFLTK(int argc=0, char **argv=0);
#endif
// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _GMSH_CONFIG_H_
#define _GMSH_CONFIG_H_
#cmakedefine HAVE_3M
#cmakedefine HAVE_64BIT_SIZE_T
#cmakedefine HAVE_ACIS
#cmakedefine HAVE_ANN
#cmakedefine HAVE_BAMG
#cmakedefine HAVE_BFGS
#cmakedefine HAVE_BLAS
#cmakedefine HAVE_BLOSSOM
#cmakedefine HAVE_CHACO
#cmakedefine HAVE_DLOPEN
#cmakedefine HAVE_DINTEGRATION
#cmakedefine HAVE_FLTK
#cmakedefine HAVE_FOURIER_MODEL
#cmakedefine HAVE_GMM
#cmakedefine HAVE_GMP
#cmakedefine HAVE_KBIPACK
#cmakedefine HAVE_LAPACK
#cmakedefine HAVE_LIBCGNS
#cmakedefine HAVE_LIBJPEG
#cmakedefine HAVE_LIBPNG
#cmakedefine HAVE_LIBZ
#cmakedefine HAVE_LINUX_JOYSTICK
#cmakedefine HAVE_MATHEX
#cmakedefine HAVE_MED
#cmakedefine HAVE_MESH
#cmakedefine HAVE_METIS
#cmakedefine HAVE_MMG3D
#cmakedefine HAVE_MPEG_ENCODE
#cmakedefine HAVE_MPI
#cmakedefine HAVE_NATIVE_FILE_CHOOSER
#cmakedefine HAVE_NETGEN
#cmakedefine HAVE_NO_INTPTR_T
#cmakedefine HAVE_NO_SOCKLEN_T
#cmakedefine HAVE_NO_STDINT_H
#cmakedefine HAVE_NO_VSNPRINTF
#cmakedefine HAVE_OCC
#cmakedefine HAVE_ONELAB
#cmakedefine HAVE_ONELAB_METAMODEL
#cmakedefine HAVE_OPENGL
#cmakedefine HAVE_OPTHOM
#cmakedefine HAVE_OSMESA
#cmakedefine HAVE_PARSER
#cmakedefine HAVE_PETSC
#cmakedefine HAVE_PLUGINS
#cmakedefine HAVE_POST
#cmakedefine HAVE_POPPLER
#cmakedefine HAVE_QT
#cmakedefine HAVE_RTREE
#cmakedefine HAVE_SALOME
#cmakedefine HAVE_SLEPC
#cmakedefine HAVE_SOLVER
#cmakedefine HAVE_TAUCS
#cmakedefine HAVE_TETGEN
#cmakedefine HAVE_VORO3D
#define GMSH_CONFIG_OPTIONS "${GMSH_CONFIG_OPTIONS}"
${GMSH_CONFIG_PRAGMAS}
#endif