Skip to content

Commit

Permalink
Mesh: add gmsh for remeshing a mesh created from CAD
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 20, 2020
1 parent 274b74b commit a3bf3d1
Show file tree
Hide file tree
Showing 6 changed files with 726 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Mod/Mesh/Gui/CMakeLists.txt
Expand Up @@ -37,6 +37,7 @@ set(Mesh_MOC_HDRS
MeshEditor.h
PropertyEditorMesh.h
RemoveComponents.h
RemeshGmsh.h
SegmentationBestFit.h
Selection.h
)
Expand All @@ -51,6 +52,7 @@ set(Dialogs_UIC_SRCS
DlgSettingsImportExport.ui
DlgSmoothing.ui
RemoveComponents.ui
RemeshGmsh.ui
Segmentation.ui
SegmentationBestFit.ui
Selection.ui
Expand Down Expand Up @@ -79,6 +81,9 @@ SET(Dialogs_SRCS
RemoveComponents.ui
RemoveComponents.cpp
RemoveComponents.h
RemeshGmsh.ui
RemeshGmsh.cpp
RemeshGmsh.h
Segmentation.ui
Segmentation.cpp
Segmentation.h
Expand Down
35 changes: 35 additions & 0 deletions src/Mod/Mesh/Gui/Command.cpp
Expand Up @@ -72,6 +72,7 @@
#include "DlgEvaluateMeshImp.h"
#include "DlgRegularSolidImp.h"
#include "RemoveComponents.h"
#include "RemeshGmsh.h"
#include "DlgSmoothing.h"
#include "ViewProviderMeshFaceSet.h"
#include "ViewProviderCurvature.h"
Expand Down Expand Up @@ -1261,6 +1262,39 @@ bool CmdMeshRemoveComponents::isActive(void)

//--------------------------------------------------------------------------------------

DEF_STD_CMD_A(CmdMeshRemeshGmsh)

CmdMeshRemeshGmsh::CmdMeshRemeshGmsh()
: Command("Mesh_RemeshGmsh")
{
sAppModule = "Mesh";
sGroup = QT_TR_NOOP("Mesh");
sMenuText = QT_TR_NOOP("Refinement...");
sToolTipText = QT_TR_NOOP("Refine existing mesh");
sStatusTip = QT_TR_NOOP("Refine existing mesh");
sWhatsThis = "Mesh_RemeshGmsh";
//sPixmap = "Mesh_RemeshGmsh";
}

void CmdMeshRemeshGmsh::activated(int)
{
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
if (!dlg) {
std::vector<Mesh::Feature*> mesh = getSelection().getObjectsOfType<Mesh::Feature>();
if (mesh.size() != 1)
return;
dlg = new MeshGui::TaskRemeshGmsh(mesh.front());
}
Gui::Control().showDialog(dlg);
}

bool CmdMeshRemeshGmsh::isActive(void)
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
}

//--------------------------------------------------------------------------------------

DEF_STD_CMD_A(CmdMeshRemoveCompByHand)

CmdMeshRemoveCompByHand::CmdMeshRemoveCompByHand()
Expand Down Expand Up @@ -1812,6 +1846,7 @@ void CreateMeshCommands(void)
rcCmdMgr.addCommand(new CmdMeshBuildRegularSolid());
rcCmdMgr.addCommand(new CmdMeshFillupHoles());
rcCmdMgr.addCommand(new CmdMeshRemoveComponents());
rcCmdMgr.addCommand(new CmdMeshRemeshGmsh());
rcCmdMgr.addCommand(new CmdMeshFillInteractiveHole());
rcCmdMgr.addCommand(new CmdMeshRemoveCompByHand());
rcCmdMgr.addCommand(new CmdMeshFromGeometry());
Expand Down

5 comments on commit a3bf3d1

@berndhahnebach
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wwmayer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@berndhahnebach have you watched the talk of C. Geuzaine about gmsh at the FOSDEM? One of the things he was talking about is the new remeshing function introduced with v4.5.
This commit is using this feature for meshes generated from CAD models to do a refinement with well-formed triangles.

Now there are two things I would like to know but couldn't figure out yet:

  • the remesh function is able to split a model into sub-parts by detecting a network of curves and surfaces. This information would be quite helpful to know for the reverse engineering wb but I don't know how to save and access it.
  • there is also a recombine function (which already existed in older versions) where you can create a nice mesh from an input mesh with ugly triangles. In the doc some examples from CT scans are shown that apparently create ugly triangles and with gmsh this can be fixed.
    However in all my tests I got either bad results or gmsh even crashed

Any idea how to do this? FYI, I am quite new to gmsh

@berndhahnebach
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets continue in the Forum werner. There are some people in FEM around who do know Gmsh better than me. To be honest I am not that good at meshing. I just get my gometry meshed but my geometry is simple. What realy interests me is quad meshing but this is another story ... https://forum.freecadweb.org/viewtopic.php?f=18&t=43608

@wwmayer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx

@luzpaz
Copy link
Contributor

@luzpaz luzpaz commented on a3bf3d1 Feb 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.