diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/01-cmake-multi-platform.yml similarity index 62% rename from .github/workflows/cmake-multi-platform.yml rename to .github/workflows/01-cmake-multi-platform.yml index 167b85f..0576c90 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/01-cmake-multi-platform.yml @@ -40,88 +40,131 @@ jobs: steps: - - name: (1) Checkout - uses: actions/checkout@v3 + + - name: (1.1) Install Qt + uses: jurplel/install-qt-action@v3 + with: + tools: 'tools_qtcreator,qt.tools.qtcreator' - - name: (2b) Install UG4 - ugcore + - name: (1.2) Check content + if: startsWith(matrix.os, 'windows') == true + run: | + dir ..\Qt\5.15.2\msvc2019_64 + dir ..\Qt\5.15.2\msvc2019_64\bin + dir ..\Qt\5.15.2\msvc2019_64\lib + + - name: (2.0) Checkout self. + uses: actions/checkout@v4 + + - name: (2.1) Install UG4 - ugcore uses: actions/checkout@v4 with: repository: UG4/ugcore.git path: ug4-git/ugcore ref: master - - name: (2b) Install UG4 - plugin_ProMesh + - name: (2.2) Install UG4 - plugin_ProMesh uses: actions/checkout@v4 with: repository: UG4/plugin_ProMesh.git path: ug4-git/plugins/ProMesh ref: master - - name: (2b) Install UG4 - plugin_LuaShell + - name: (2.3) Install UG4 - plugin_LuaShell uses: actions/checkout@v4 with: repository: UG4/plugin_LuaShell.git path: ug4-git/plugins/LuaShell ref: master - - name: (2b) Install UG4 - external_BoostForUG4 + - name: (2.4) Install UG4 - external_BoostForUG4 uses: actions/checkout@v4 with: repository: UG4/external_BoostForUG4.git path: ug4-git/externals/BoostForUG4 ref: master - - name: (2b) Install UG4/tool_tetgen.git + - name: (2.5) Install UG4 - external_EigenForUG4 + uses: actions/checkout@v4 + with: + repository: UG4/external_EigenForUG4.git + path: ug4-git/externals/EigenForUG4 + ref: master + + - name: (2.6) Install UG4/tool_tetgen.git uses: actions/checkout@v4 with: repository: UG4/tool_tetgen.git path: ug4-git/tools/tetgen ref: master - - - name: (2b) Build UG4/tool_tetgen.git + + - name: (3) Build UG4 & tetgen run: | - cmake -B ug4-git/tools/tetgen/build -S ug4-git/tools/tetgen - cmake --build ug4-git/tools/tetgen/build --target tetgen --config Release + cmake -B ug4-git/build -S ug4-git/ugcore -DTARGET=libgrid -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release -DProMesh=ON -DLuaShell=ON -DPARALLEL=OFF -Dtetgen=ON -DDIM=3 + cmake --build ug4-git/build --config ${{ matrix.build_type }} + + + #- name: (2b) Build UG4/tool_tetgen.git + # run: | + # cmake -B ug4-git/tools/tetgen/build -S ug4-git/tools/tetgen + # cmake --build ug4-git/tools/tetgen/build --target tetgen --config Release - - name: (2b) Copy tetgen + - name: (3) Move content if: startsWith(matrix.os, 'windows') == true - run: | - mkdir ug4-git\bin - copy ug4-git\tools\tetgen\build\Release\tetgen.exe ug4-git\bin\tetgen.exe + run: | + dir ug4-git + dir ug4-git\ugcore + move ug4-git\ugcore\bin ug4-git + move ug4-git\ugcore\lib ug4-git + dir ug4-git dir ug4-git\bin - - - name: (2b) Install Qt - uses: jurplel/install-qt-action@v3 - + dir ug4-git\lib + # mkdir ug4-git\bin + # copy ug4-git\tools\tetgen\build\Release\tetgen.exe ug4-git\bin\tetgen.exe + - - name: (2b) Install GL develop + - name: (5) Install GL develop if: startsWith(matrix.os, 'ubuntu') == true run: sudo apt-get install -y libgl-dev freeglut3-dev - - name: (3) Set reusable strings + - name: (6) Set reusable strings # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. id: strings shell: bash run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - name: (4) Configure CMake + - name: (7) Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: > cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DUG_ROOT_PATH=/home/runner/work/ProMesh/ProMesh/ug4-git + -DUG_ROOT_PATH=${{ github.workspace }}/ug4-git -S ${{ github.workspace }} - - name: (5) Build +# -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} +# -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} +# -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + + + + - name: (8.1) Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - name: (6) Test + - name: (8.2) Fix content + run: | + ..\Qt\5.15.2\msvc2019_64\bin\windeployqt.exe ${{ github.workspace }}\build\Release + + + - name: (9) Artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.os }} + path: ${{ github.workspace }}/build # or path/to/artifact + + - name: (10) Test working-directory: ${{ steps.strings.outputs.build-output-dir }} # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail diff --git a/.github/workflows/02-build-installer.yml b/.github/workflows/02-build-installer.yml new file mode 100644 index 0000000..35a1ae0 --- /dev/null +++ b/.github/workflows/02-build-installer.yml @@ -0,0 +1,60 @@ +name: Build installer + +on: + workflow_dispatch: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + + installer-build: + name: Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + # os: [ubuntu-latest, windows-latest] + os: [windows-latest] + build_type: [Release] + + steps: + - name: (0) Checkout self. + uses: actions/checkout@v4 + + - name: (1) Artifacts + uses: actions/download-artifact@v4 + with: + name: artifacts-${{matrix.os}} + path: artifacts + github-token: ${{ github.token }} + repository: ${{ github.repository }} + run-id: 12359566993 + + - name: (2) Move dir. + if: startsWith( ${{ matrix.os }}, "windows-latest") + run: Move-Item -Path artifacts/Release -Destination deployment/win64/artifacts + + - name: (3) Create installer + if: startsWith( ${{ matrix.os }}, "windows-latest") + uses: joncloud/makensis-action@v4.1 + with: + script-file: "deployment/win64/promesh4-installer.nsi" + arguments: "/V3" + + - name: (4) Artifacts + if: startsWith( ${{ matrix.os }}, "windows-latest") + uses: actions/upload-artifact@v4 + with: + name: ProMesh4-Installer-${{ matrix.os }} + path: ${{ github.workspace }}/deployment/win64/ProMesh4-Installer.exe # or path/to/artifact + diff --git a/.github/workflows/03-update-assets.yml b/.github/workflows/03-update-assets.yml new file mode 100644 index 0000000..2645555 --- /dev/null +++ b/.github/workflows/03-update-assets.yml @@ -0,0 +1,83 @@ +on: + workflow_dispatch: + push: + # Sequence of patterns matched against refs/tags + #tags: + # - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Upload Release Asset +jobs: + build: + name: Upload Release Asset for ${{ matrix.os }} + + runs-on: ubuntu-latest + + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + matrix: + os: [windows-latest] + build_type: [Release] + + steps: + - name: Checkout self + uses: actions/checkout@v4 + + - name: Download pre-packed asset + uses: actions/download-artifact@v4 + with: + # name: ProMesh4-Installer-${{matrix.os}} + name: ProMesh4-Installer-windows-latest + # path: $GITHUB_WORKSPACE + github-token: ${{ github.token }} + repository: ${{ github.repository }} + run-id: 12355131211 + + - name: Download pre-packed artifact + run: ls . + + #- name: Download pre-packed artifact + # run: ls ./assets + + # Fetch the latest release from GitHub API + - name: Get latest release + id: get_release + run: | + latest_release=$(curl -s \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/releases/latest) + echo "::set-output name=upload_url::$(echo $latest_release | jq -r .upload_url | sed -e "s/{?name,label}//")" + + # - name: Create Release + # id: create_release + # uses: actions/create-release@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # tag_name: ${{ github.ref }} + # release_name: Release ${{ github.ref }} + # draft: false + # prerelease: false + + - name: Test + run: echo "URL=${{ steps.get_release.outputs.upload_url }}" + + #- name: Upload Release Binary + # id: upload-release-asset + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ steps.get_release.outputs.upload_url }} + # #upload_url: ${{ steps.create_release.outputs.upload_url }} + # asset_path: ./ProMesh4-Installer.exe + # asset_name: promesh_setup_win64.exe + # asset_content_type: application/octet-stream + + - name: Upload Release Binary + uses: AButler/upload-release-assets@v3.0 + with: + files: "./ProMesh4-Installer.exe" + repo-token: ${{ secrets.GITHUB_TOKEN }} + release-tag: v0.0.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index f90f022..1f3a607 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2008-2015: G-CSC, Goethe University Frankfurt # Copyright (c) 2006-2008: Steinbeis Forschungszentrum (STZ Ölbronn) # Copyright (c) 2006-2015: Sebastian Reiter -# Author: Sebastian Reiter +# Author: Sebastian Reiter, small modifications Markus Knodel # # This file is part of ProMesh. # @@ -64,6 +64,7 @@ set(ProMeshSRC src/app.cpp src/tools/tetgen_tools.cpp src/tools/tool_dialog.cpp src/tools/tool_frac_to_layer.cpp + src/tools/tool_frac_to_layer_arte.cpp src/tools/tool_manager.cpp src/util/file_util.cpp src/util/qstring_util.cpp @@ -262,11 +263,11 @@ else(UNIX) if(MINGW) # resource compilation for MINGW ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ProMeshIcon.o - COMMAND windres.exe -I${CMAKE_SOURCE_DIR}/deploy_data -i${CMAKE_SOURCE_DIR}/deploy_data/ProMeshIcon.rc + COMMAND windres.exe -I${CMAKE_SOURCE_DIR}/deployment/data -i${CMAKE_SOURCE_DIR}/deployment/data/ProMeshIcon.rc -o ${CMAKE_CURRENT_BINARY_DIR}/ProMeshIcon.o ) ADD_EXECUTABLE(ProMesh4 WIN32 ${allSources} ProMeshIcon.o) else(MINGW) - ADD_EXECUTABLE(ProMesh4 WIN32 ${allSources} ${CMAKE_SOURCE_DIR}/deploy_data/ProMeshIcon.rc) + ADD_EXECUTABLE(ProMesh4 WIN32 ${allSources} ${CMAKE_SOURCE_DIR}/deployment/data/ProMeshIcon.rc) endif(MINGW) endif(UNIX) diff --git a/bundle_app b/deployment/bundle-app-macos similarity index 100% rename from bundle_app rename to deployment/bundle-app-macos diff --git a/deploy_data/AppIcon.icns b/deployment/data/AppIcon.icns similarity index 100% rename from deploy_data/AppIcon.icns rename to deployment/data/AppIcon.icns diff --git a/deploy_data/Info.plist b/deployment/data/Info.plist similarity index 100% rename from deploy_data/Info.plist rename to deployment/data/Info.plist diff --git a/deploy_data/ProMeshIcon.ico b/deployment/data/ProMeshIcon.ico similarity index 100% rename from deploy_data/ProMeshIcon.ico rename to deployment/data/ProMeshIcon.ico diff --git a/deploy_data/ProMeshIcon.png b/deployment/data/ProMeshIcon.png similarity index 100% rename from deploy_data/ProMeshIcon.png rename to deployment/data/ProMeshIcon.png diff --git a/deploy_data/ProMeshIcon.rc b/deployment/data/ProMeshIcon.rc similarity index 100% rename from deploy_data/ProMeshIcon.rc rename to deployment/data/ProMeshIcon.rc diff --git a/deployment/win64/promesh4-installer.nsi b/deployment/win64/promesh4-installer.nsi new file mode 100644 index 0000000..d3f04ac --- /dev/null +++ b/deployment/win64/promesh4-installer.nsi @@ -0,0 +1,125 @@ +;-------------------------------- + +; The name of the installer +Name ProMesh4 + +; The file to write +OutFile "ProMesh4-Installer.exe" + +; The default installation directory +InstallDir $PROGRAMFILES64\ProMesh4 + +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM "SOFTWARE\G-CSC\ProMesh4" "Install_Dir" + +; Request application privileges for Windows Vista +RequestExecutionLevel admin + +Icon "..\data\ProMeshIcon.ico" + +LicenseBkColor /windows +LicenseData "..\..\LICENSE" + +XPStyle on +ManifestSupportedOS all + +;-------------------------------- + +; Pages + +Page license +Page directory +Page components +Page instfiles + +UninstPage uninstConfirm +UninstPage instfiles + +;-------------------------------- + +; The stuff to install +Section ProMesh4 (required)" + + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $INSTDIR + + ; Put file there + File "artifacts\ProMesh4.exe" + File "artifacts\\*.dll" + + SetOutPath $INSTDIR\platforms + File "artifacts\platforms\*.dll" + + SetOutPath $INSTDIR\tools + File "artifacts\tools\*.exe" + ; File "artifacts\tools\*LICENSE" + + SetOutPath $INSTDIR\translations + File "artifacts\translations\*" + + SetOutPath $INSTDIR\imageformats + File "artifacts\imageformats\*" + + SetOutPath $INSTDIR\iconengines + File "artifacts\iconengines\*" + + SetOutPath $INSTDIR + + + ; Write the installation path into the registry + WriteRegStr HKLM SOFTWARE\G-CSC\ProMesh4 "Install_Dir" "$INSTDIR" + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\G-CSC\ProMesh4" "DisplayName" "ProMesh4" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\G-CSC\ProMesh4" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\G-CSC\ProMesh4" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\G-CSC\ProMesh4" "NoRepair" 1 + WriteUninstaller "uninstall.exe" + +SectionEnd + +; Optional section (can be disabled by the user) +Section "Programs Shortcut" + CreateDirectory "$SMPROGRAMS\ProMesh4" + CreateShortcut "$SMPROGRAMS\ProMesh4\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 + CreateShortcut "$SMPROGRAMS\ProMesh4\ProMesh4.lnk" "$INSTDIR\ProMesh4.exe" "" "$INSTDIR\ProMesh4.exe" 0 +SectionEnd + +Section "Start Menu Shortcut" + CreateShortcut "$STARTMENU\ProMesh4.lnk" "$INSTDIR\ProMesh4.exe" "" "$INSTDIR\ProMesh4.exe" 0 +SectionEnd + +Section "Desktop Shortcut" + CreateShortcut "$DESKTOP\ProMesh4.lnk" "$INSTDIR\ProMesh4.exe" "" "$INSTDIR\ProMesh4.exe" 0 +SectionEnd + + +;-------------------------------- + +; Uninstaller + +Section "Uninstall" + + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\G-CSC\ProMesh4" + DeleteRegKey HKLM SOFTWARE\G-CSC\ProMesh4 + + ; Remove files and uninstaller + Delete $INSTDIR\ProMesh4.exe + Delete $INSTDIR\*.dll + RMDir /r /REBOOTOK $INSTDIR\platforms + Delete $INSTDIR\uninstall.exe + + ; Remove shortcuts, if any + Delete "$SMPROGRAMS\ProMesh4\*.*" + Delete "$STARTMENU\ProMesh4.lnk" + Delete "$DESKTOP\ProMesh4.lnk" + + ; Remove directories used + RMDir "$SMPROGRAMS\ProMesh4" + RMDir "$INSTDIR" + +SectionEnd diff --git a/src/tools/fracture_tools.cpp b/src/tools/fracture_tools.cpp index 1634418..1175402 100644 --- a/src/tools/fracture_tools.cpp +++ b/src/tools/fracture_tools.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2008-2015: G-CSC, Goethe University Frankfurt * Copyright (c) 2006-2008: Steinbeis Forschungszentrum (STZ Ölbronn) * Copyright (c) 2006-2015: Sebastian Reiter - * Author: Sebastian Reiter + * Author: Sebastian Reiter, modified by Markus Knodel * * This file is part of ProMesh. * @@ -30,8 +30,13 @@ #include "app.h" #include "standard_tools.h" #include "tool_frac_to_layer.h" +#include "tool_frac_to_layer_arte.h" #include "tooltips.h" +#include "lib_grid/algorithms/extrusion/expand_layers_arte.h" +#include "lib_grid/algorithms/extrusion/expand_layers_arte3D.h" + + using namespace std; using namespace ug; @@ -67,6 +72,178 @@ class ToolExpandLayers2d : public ITool } }; +//////////////////////////////////////////////////////////////////// + + +class ToolExpandLayers2dArte : public ITool +{ +public: + void execute(LGObject* obj, QWidget* widget) + { + using namespace ug; + +// UG_LOG("Test execute" << std::endl); + + FracToLayerWidgetArte* dlg = dynamic_cast(widget); + + if(dlg->numEntries() == 0){ + UG_LOG("No entries selected. Aborting 'Expand Layers 2d'.\n"); + return; + } + + Grid& grid = obj->grid(); + SubsetHandler& sh = obj->subset_handler(); + +// UG_LOG("Expand" << std::endl); + + ExpandFractures2dArte(grid, sh, dlg->entries(), dlg->diamondsUseTriangles(), + dlg->establishDiamonds()); + + // done + obj->geometry_changed(); + } + + const char* get_name() {return "Expand Layers 2d Arte";} + const char* get_tooltip() {return TOOLTIP_EXPAND_LAYERS_2D_ARTE;} + const char* get_group() {return "Remeshing | Layers";} + + QWidget* get_dialog(QWidget* parent) + { +// UG_LOG("Get dialog" << std::endl); + return new FracToLayerWidgetArte(get_name(), parent, this); +// return new FracToLayerWidget(get_name(), parent, this); + } +}; + +//////////////////////////////////////////////////////////////////// + +class ToolExpandLayers3dArte : public ITool +{ +public: + void execute(LGObject* obj, QWidget* widget) + { + using namespace ug; + +// UG_LOG("Test execute" << std::endl); + + FracToLayerWidgetArte* dlg = dynamic_cast(widget); + + if(dlg->numEntries() == 0){ + UG_LOG("No entries selected. Aborting 'Expand Layers 2d'.\n"); + return; + } + + Grid& grid = obj->grid(); + SubsetHandler& sh = obj->subset_handler(); + +// UG_LOG("Expand" << std::endl); + + ExpandFractures3dArte(grid, sh, dlg->entries(), dlg->diamondsUseTriangles(), + dlg->establishDiamonds()); + + // done + obj->geometry_changed(); + } + + const char* get_name() {return "Expand Layers 3d Arte";} + const char* get_tooltip() {return TOOLTIP_EXPAND_LAYERS_3D_ARTE;} + const char* get_group() {return "Remeshing | Layers";} + + QWidget* get_dialog(QWidget* parent) + { +// UG_LOG("Get dialog" << std::endl); + return new FracToLayerWidgetArte(get_name(), parent, this); +// return new FracToLayerWidget(get_name(), parent, this); + } +}; + + +#if 0 +template +class ToolExpandLayersArte : public ITool +{ +private: + + int D = dim; + +public: + ToolExpandLayersArte() {}; + + void execute(LGObject* obj, QWidget* widget) + { + using namespace ug; + +// UG_LOG("Test execute" << std::endl); + + FracToLayerWidgetArte* dlg = dynamic_cast(widget); + + if(dlg->numEntries() == 0){ + UG_LOG("No entries selected. Aborting 'Expand Layers templ'.\n"); + return; + } + + Grid& grid = obj->grid(); + SubsetHandler& sh = obj->subset_handler(); + +// UG_LOG("Expand" << std::endl); + + if constexpr ( D == 2 ) + { + ExpandFractures2dArte(grid, sh, dlg->entries(), dlg->diamondsUseTriangles(), + dlg->establishDiamonds()); + } + else if constexpr ( D == 3 ) + { + ExpandFractures2dArte(grid, sh, dlg->entries(), dlg->diamondsUseTriangles(), + dlg->establishDiamonds()); + + } + else + { + UG_THROW("wrong dimension for expand tool " << D << std::endl); + } + + + // done + obj->geometry_changed(); + } + + const char* get_name() {return "Expand Layers " + D + "d Arte";} + + const char* get_tooltip() + { + if constexpr ( D == 2 ) + { + return TOOLTIP_EXPAND_LAYERS_2D_ARTE; + } + else if constexpr ( D == 3 ) + { + return TOOLTIP_EXPAND_LAYERS_3D_ARTE; + } + else + { + UG_THROW("wrong dimension for expand tool " << D << std::endl); + + return false; + } + + return {}; + } + + const char* get_group() {return "Remeshing | Layers";} + + QWidget* get_dialog(QWidget* parent) + { +// UG_LOG("Get dialog" << std::endl); + return new FracToLayerWidgetArte(get_name(), parent, this); +// return new FracToLayerWidget(get_name(), parent, this); + } + +}; +#endif + +//////////////////////////////////////////////////////////////////// + class ToolExpandLayers3d : public ITool { public: @@ -246,6 +423,12 @@ void RegisterFracToLayerTools(ToolManager* toolMgr) //toolMgr->register_tool(new ToolFracToLayer); toolMgr->register_tool(new ToolExpandLayers2d); toolMgr->register_tool(new ToolExpandLayers3d); + toolMgr->register_tool(new ToolExpandLayers2dArte); + toolMgr->register_tool(new ToolExpandLayers3dArte); + +// toolMgr->register_tool(new ToolExpandLayersArte<2>); +// toolMgr->register_tool(new ToolExpandLayersArte<3>); + } diff --git a/src/tools/grid_generation_tools.cpp b/src/tools/grid_generation_tools.cpp index 570947b..eeae880 100644 --- a/src/tools/grid_generation_tools.cpp +++ b/src/tools/grid_generation_tools.cpp @@ -35,6 +35,8 @@ #include "tooltips.h" #include "../scene/csg_object.h" #include "script_tools.h" +#include "lib_grid/file_io/file_io_vtu.h" + //#include "lib_discretization/spatial_discretization/disc_util/finite_volume_output.h" @@ -595,12 +597,48 @@ class ToolCreateDualGrid : public ITool }; */ +class IdentifierVtuROI : public ITool +{ + public: + void execute(LGObject* obj, QWidget* widget){ + using namespace std; + using namespace ug; + + ToolWidget* dlg = dynamic_cast(widget); + + // get parameters + QString objName = "regions"; + + if(dlg){ + objName = dlg->to_string(0); + } + + ug::GridReaderVTU::setRegionOfInterestIdentifier( objName.toLocal8Bit().constData() ); + } + + const char* get_name() {return "Identify vtu ROI";} + const char* get_tooltip() {return "identification of ROI name";} + const char* get_group() {return "Grid Generation";} + bool accepts_null_object_ptr() {return true;} + + QWidget* get_dialog(QWidget* parent){ + ToolWidget *dlg = new ToolWidget(get_name(), parent, this, + IDB_APPLY | IDB_OK | IDB_CLOSE); + // The name of the new mesh + dlg->addTextBox(tr("name:"), "regions"); + return dlg; + } +}; + + void PreRegisterGridGenerationTools(ToolManager* toolMgr) { toolMgr->register_tool(new ToolNewMesh); // toolMgr->register_tool(new ToolNewCSGObject); toolMgr->register_tool(new ToolNewMeshFromSelection); toolMgr->register_tool(new ToolMergeMeshes); + + toolMgr->register_tool(new IdentifierVtuROI); } void PostRegisterGridGenerationTools(ToolManager* toolMgr) diff --git a/src/tools/tool_frac_to_layer.cpp b/src/tools/tool_frac_to_layer.cpp index 2baf994..f9b5794 100644 --- a/src/tools/tool_frac_to_layer.cpp +++ b/src/tools/tool_frac_to_layer.cpp @@ -251,4 +251,4 @@ newSubsetIndexChanged(int newInd){ if((curInd >= 0) && curInd < (int)m_entries.size()){ m_entries[curInd].newSubsetIndex = newInd; } -} \ No newline at end of file +} diff --git a/src/tools/tool_frac_to_layer.h b/src/tools/tool_frac_to_layer.h index 5e82655..1f4f4a5 100644 --- a/src/tools/tool_frac_to_layer.h +++ b/src/tools/tool_frac_to_layer.h @@ -33,6 +33,7 @@ #include "app.h" #include "standard_tools.h" #include "lib_grid/algorithms/extrusion/expand_layers.h" +//#include "lib_grid/algorithms/extrusion/expand_layers_arte.h" class FracToLayerWidget : public QWidget { @@ -76,6 +77,9 @@ class FracToLayerWidget : public QWidget QCheckBox* m_cbExpandOuterBounds; QSpinBox* m_qNewSubset; SubsetEntryVec m_entries; + + FracToLayerWidget(QWidget* parent ) : QWidget(parent) {}; + }; #endif // TOOL_FRAC_TO_LAYER_H diff --git a/src/tools/tool_frac_to_layer_arte.cpp b/src/tools/tool_frac_to_layer_arte.cpp new file mode 100644 index 0000000..66d5b75 --- /dev/null +++ b/src/tools/tool_frac_to_layer_arte.cpp @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2008-2015: G-CSC, Goethe University Frankfurt + * Copyright (c) 2006-2008: Steinbeis Forschungszentrum (STZ Ölbronn) + * Copyright (c) 2006-2015: Sebastian Reiter + * Author: Markus Knodel + * + * This file is part of ProMesh. + * + * ProMesh is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License version 3 (as published by the + * Free Software Foundation) with the following additional attribution + * requirements (according to LGPL/GPL v3 §7): + * + * (1) The following notice must be displayed in the Appropriate Legal Notices + * of covered and combined works: "Based on ProMesh (www.promesh3d.com)". + * + * (2) The following bibliography is recommended for citation and must be + * preserved in all covered files: + * "Reiter, S. and Wittum, G. ProMesh -- a flexible interactive meshing software + * for unstructured hybrid grids in 1, 2, and 3 dimensions. In preparation." + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "tool_frac_to_layer_arte.h" + +FracToLayerWidgetArte:: +FracToLayerWidgetArte(const QString& name, QWidget* parent, + ITool* tool) : + FracToLayerWidget(parent) +{ +// UG_LOG("construct FAA" << std::endl); + + m_tool = tool; + m_object = NULL; + QString title = name; + title.append(": "); + +// create the layouts + QVBoxLayout* vLayout = new QVBoxLayout(this); + +// UG_LOG("construct FA 1" << std::endl); + + +//// add a checkbox that allows to choose whether we have to create degenerated fractures +// m_cbCreateDegenerated = new QCheckBox(this); +// m_cbCreateDegenerated->setText(tr("degenerated layers")); +// m_cbCreateDegenerated->setChecked(false); +// vLayout->addWidget(m_cbCreateDegenerated); +// +// UG_LOG("construct FA 1a" << std::endl); + +// +//// add a checkbox that allows to choose whether we expand fractures at inner boundaries +// m_cbExpandOuterBounds = new QCheckBox(this); +// m_cbExpandOuterBounds->setText(tr("expand outer boundaries")); +// m_cbExpandOuterBounds->setText(tr("blubb")); +// m_cbExpandOuterBounds->setChecked(true); +// vLayout->addWidget(m_cbExpandOuterBounds); + + // add a checkbox that allows to choose whether the diamonds should use only triangles + m_useTrianglesInDiamons = new QCheckBox(this); + +// UG_LOG("construct FA X 1" << std::endl); + + m_useTrianglesInDiamons->setText(tr("triangles in diamonds")); + +// UG_LOG("construct FA X 2" << std::endl); + + m_useTrianglesInDiamons->setChecked(false); + +// UG_LOG("construct FA X 3" << std::endl); + + vLayout->addWidget(m_useTrianglesInDiamons); + +// UG_LOG("construct FA 2" << std::endl); + + // add a checkbox that allows to choose whether we want to have diamonds + m_establishDiamonds = new QCheckBox(this); + m_establishDiamonds->setText(tr("establish diamonds")); + m_establishDiamonds->setChecked(true); + vLayout->addWidget(m_establishDiamonds); +// +// UG_LOG("construct FA 3" << std::endl); + + +// create a hbox-layout for the add-button + QHBoxLayout* hAddLayout = new QHBoxLayout(); + vLayout->addLayout(hAddLayout); + + QPushButton* btnAdd = new QPushButton(tr("add subset"), this); + connect(btnAdd, SIGNAL(clicked()), this, SLOT(addClicked())); + + m_qSubsetIndex = new QSpinBox(this); + m_qSubsetIndex->setRange(0, 1e+9); + m_qSubsetIndex->setValue(0); + m_qSubsetIndex->setSingleStep(1); + hAddLayout->addWidget(btnAdd); + hAddLayout->addWidget(m_qSubsetIndex); + +// UG_LOG("construct FA Spin" << std::endl); + + +// create a list box + m_listWidget = new QListWidget(this); + vLayout->addWidget(m_listWidget); + connect(m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + this, SLOT(currentItemChanged(QListWidgetItem*,QListWidgetItem*))); + +// create the layout for the input boxes + QFormLayout* formLayout = new QFormLayout(); + formLayout->setSpacing(5); + formLayout->setHorizontalSpacing(10); + formLayout->setVerticalSpacing(8); + vLayout->addLayout(formLayout); + +// create the input boxes + m_qWidth = new QDoubleSpinBox(this); + m_qWidth->setValue(0.01); + m_qWidth->setDecimals(9); + m_qWidth->setRange(0, 1e+9); + m_qWidth->setSingleStep(0.01); + connect(m_qWidth, SIGNAL(valueChanged(double)), this, SLOT(widthChanged(double))); + formLayout->addRow(tr("layer-width:"), m_qWidth); + + m_qNewSubset = new QSpinBox(this); + m_qNewSubset->setValue(0); + m_qNewSubset->setRange(0, 1e+9); + m_qNewSubset->setSingleStep(1); + formLayout->addRow(tr("new subset:"), m_qNewSubset); + connect(m_qNewSubset, SIGNAL(valueChanged(int)), this, SLOT(newSubsetIndexChanged(int))); + +// create ok and cancel buttons + QHBoxLayout* hDoneLayout = new QHBoxLayout(); + vLayout->addLayout(hDoneLayout); + + QPushButton* btnApply = new QPushButton(tr("Apply"), this); + connect(btnApply, SIGNAL(clicked()), this, SLOT(applyClicked())); + hDoneLayout->addWidget(btnApply); + + QPushButton* btnClear = new QPushButton(tr("Clear"), this); + connect(btnClear, SIGNAL(clicked()), this, SLOT(clearClicked())); + hDoneLayout->addWidget(btnClear); + + hDoneLayout->addStretch(); + +// UG_LOG("End construct FA" << std::endl); + +} + +FracToLayerWidgetArte:: +~FracToLayerWidgetArte() {} + +//const FracToLayerWidget::SubsetEntryVec& FracToLayerWidget:: +//entries() const +//{return m_entries;} +// +//size_t FracToLayerWidget:: +//numEntries() const +//{return m_entries.size();} +// +//const FracToLayerWidget::SubsetEntry& FracToLayerWidget:: +//entry(size_t index) const +//{return m_entries.at(index);} +// +bool FracToLayerWidgetArte:: +degenerated_fractures() const +{ + return false; +} + +bool FracToLayerWidgetArte:: +expand_outer_boundaries() const +{ + return false; +} + +bool FracToLayerWidgetArte::diamondsUseTriangles() const +{ + return m_useTrianglesInDiamons->isChecked(); +} + +bool FracToLayerWidgetArte::establishDiamonds() const +{ + return m_establishDiamonds->isChecked(); +} + + +//void FracToLayerWidget:: +//addClicked() +//{ +// if(!m_object){ +// m_object = app::getActiveObject(); +// if(m_object){ +// QString title = this->windowTitle(); +// title.append(m_object->name()); +// this->setWindowTitle(title); +// } +// else{ +// QMessageBox msg(this); +// msg.setText(tr("WARNING: Can't operate on invalid object.\n" +// "Please select a valid object in the scene inspector first.")); +// msg.exec(); +// return; +// } +// } +// +// if(m_object != app::getActiveObject()){ +// QMessageBox msg(this); +// msg.setText(tr("WARNING: The active object has changed. Clear will be " +// "performed before the subset is added.")); +// msg.exec(); +// clearClicked(); +// m_object = app::getActiveObject(); +// } +// +//// add a new entry - if it not already exists +// int si = m_qSubsetIndex->value(); +// +// for(size_t i = 0; i < m_entries.size(); ++i){ +// if(m_entries[i].subsetIndex == si){ +// QMessageBox msg(this); +// msg.setText(tr("WARNING: Entry already exists.")); +// msg.exec(); +// return; +// } +// } +// +//// make sure that the entry is valid +// if((si < 0) || (si >= m_object->num_subsets())){ +// QMessageBox msg(this); +// msg.setText(tr("WARNING: Invalid subset index.")); +// msg.exec(); +// return; +// } +// +// m_entries.push_back(SubsetEntry(si, 0, 0)); +// QString itemName = QString::number(si); +// itemName.append(": ").append(m_object->get_subset_name(si)); +// QListWidgetItem*nItem = new QListWidgetItem(itemName, m_listWidget); +// m_listWidget->setCurrentItem(nItem); +//} +// +void FracToLayerWidgetArte:: +applyClicked() +{ + if(m_object != app::getActiveObject()){ + QMessageBox msg(this); + msg.setText(tr("Sorry - the active object is not the same as the" + " one for which the subsets were added. Aborting.")); + msg.exec(); + return; + } + +// if degenerated is set to true, then all widths are set to 0 +// if(degenerated_fractures()){ +// for(size_t i = 0; i < m_entries.size(); ++i){ +// m_entries[i].width = 0; +// } +// } + +// now run the tool + try{ + m_tool->execute(m_object, this); + } + catch(ug::UGError error){ + UG_LOG("Execution of tool " << m_tool->get_name() << " failed with the following message:\n"); + UG_LOG(" " << error.get_msg() << std::endl); + } +} +// +//void FracToLayerWidget:: +//clearClicked() +//{ +// m_entries.clear(); +// m_listWidget->clear(); +// m_object = NULL; +//} +// +//void FracToLayerWidget:: +//currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous) +//{ +//// update input windows +//// get the current index +// int curInd = m_listWidget->currentIndex().row(); +// if((curInd >= 0) && curInd < (int)m_entries.size()){ +// m_qWidth->setValue(m_entries[curInd].width); +// m_qNewSubset->setValue(m_entries[curInd].newSubsetIndex); +// } +//} +// +//void FracToLayerWidget:: +//widthChanged(double width){ +// int curInd = m_listWidget->currentIndex().row(); +// if((curInd >= 0) && curInd < (int)m_entries.size()){ +// m_entries[curInd].width = width; +// } +//} +// +//void FracToLayerWidget:: +//newSubsetIndexChanged(int newInd){ +// int curInd = m_listWidget->currentIndex().row(); +// if((curInd >= 0) && curInd < (int)m_entries.size()){ +// m_entries[curInd].newSubsetIndex = newInd; +// } +//} diff --git a/src/tools/tool_frac_to_layer_arte.h b/src/tools/tool_frac_to_layer_arte.h new file mode 100644 index 0000000..c10ed37 --- /dev/null +++ b/src/tools/tool_frac_to_layer_arte.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2008-2015: G-CSC, Goethe University Frankfurt + * Copyright (c) 2006-2008: Steinbeis Forschungszentrum (STZ Ölbronn) + * Copyright (c) 2006-2015: Sebastian Reiter + * Author: Markus Knodel + * + * This file is part of ProMesh. + * + * ProMesh is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License version 3 (as published by the + * Free Software Foundation) with the following additional attribution + * requirements (according to LGPL/GPL v3 §7): + * + * (1) The following notice must be displayed in the Appropriate Legal Notices + * of covered and combined works: "Based on ProMesh (www.promesh3d.com)". + * + * (2) The following bibliography is recommended for citation and must be + * preserved in all covered files: + * "Reiter, S. and Wittum, G. ProMesh -- a flexible interactive meshing software + * for unstructured hybrid grids in 1, 2, and 3 dimensions. In preparation." + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#ifndef TOOL_FRAC_TO_LAYER_ARTE_H +#define TOOL_FRAC_TO_LAYER_ARTE_H + +#include +#include +#include "app.h" +#include "standard_tools.h" +//#include "lib_grid/algorithms/extrusion/expand_layers.h" +#include "tool_frac_to_layer.h" +//#include "lib_grid/algorithms/extrusion/expand_layers_arte.h" + +class FracToLayerWidgetArte : public FracToLayerWidget +{ + Q_OBJECT + +// public: +// typedef ug::FractureInfo SubsetEntry; +// typedef std::vector SubsetEntryVec; + + public: + FracToLayerWidgetArte(const QString& name, QWidget* parent, ITool* tool); + virtual ~FracToLayerWidgetArte(); + +// const SubsetEntryVec& entries() const; +// size_t numEntries() const; +// const SubsetEntry& entry(size_t index) const; + + bool degenerated_fractures() const; + bool expand_outer_boundaries() const; + + bool diamondsUseTriangles() const; + bool establishDiamonds() const; + + protected slots:; +// void addClicked(); + + void applyClicked(); + + +// protected slots:; +// void addClicked(); +// +// void applyClicked(); +// +// void clearClicked(); +// +// void currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous); +// +// void widthChanged(double width); +// +// void newSubsetIndexChanged(int newInd); +// +// protected: +// LGObject* m_object; +// ITool* m_tool; +// QListWidget* m_listWidget; +// QSpinBox* m_qSubsetIndex; +// QDoubleSpinBox* m_qWidth; +// QCheckBox* m_cbCreateDegenerated; +// QCheckBox* m_cbExpandOuterBounds; +// QSpinBox* m_qNewSubset; +// SubsetEntryVec m_entries; + + protected: + + QCheckBox* m_useTrianglesInDiamons; + QCheckBox* m_establishDiamonds; + +}; + +#endif // TOOL_FRAC_TO_LAYER_ARTE_H