Skip to content
Snippets Groups Projects
Commit 9f4823d8 authored by Gaetan Bricteux's avatar Gaetan Bricteux
Browse files

plugin to cut mesh

parent fb26ae54
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ set(SRC
Bubbles.cpp NearToFarField.cpp
DiscretizationError.cpp
Scal2Vec.cpp
CutMesh.cpp
)
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
......
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include "CutMesh.h"
#include "GModel.h"
#include "gmshLevelset.h"
StringXNumber CutMeshOptions_Number[] = {
{GMSH_FULLRC, "View", NULL, -1.},
{GMSH_FULLRC, "Split", NULL, 0.},
{GMSH_FULLRC, "SaveTri", NULL, 0.}
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutMeshPlugin() {
return new GMSH_CutMeshPlugin();
}
}
std::string GMSH_CutMeshPlugin::getHelp() const
{
return "Plugin(CutMesh) cuts the mesh of the current GModel with "
"the zero value of the levelset defined with the view 'View'."
"Sub-elements are created in the new model (polygons in 2D and "
"polyhedra in 3D) and border elements are created on the zero-levelset.\n\n"
"If `Split' is nonzero, the plugin splits the mesh"
"along the edges of the cut elements in the positive side.\n\n"
"If 'SaveTri' is nonzero, the sub-elements are saved as simplices.\n\n"
"Plugin(CutMesh) creates one new GModel.";
}
int GMSH_CutMeshPlugin::getNbOptions() const
{
return sizeof(CutMeshOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_CutMeshPlugin::getOption(int iopt)
{
return &CutMeshOptions_Number[iopt];
}
void GMSH_CutMeshPlugin::run(){
int iView = (int)CutMeshOptions_Number[0].def;
if(iView < 0)
iView = PView::list.size() - 1;
gLevelsetPostView *gLs = new gLevelsetPostView(iView);
int split = (int)CutMeshOptions_Number[1].def;
int saveTri = (int)CutMeshOptions_Number[2].def;
GModel *gm = GModel::current();
gm->buildCutGModel(gLs, !split, saveTri);
}
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#ifndef _CUTMESH_H_
#define _CUTMESH_H_
#include "Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutMeshPlugin();
}
class GMSH_CutMeshPlugin : public GMSH_MeshPlugin
{
public:
GMSH_CutMeshPlugin(){}
std::string getName() const { return "CutMesh"; }
std::string getShortHelp() const
{
return "Cut mesh along a levelset";
}
std::string getHelp() const;
std::string getAuthor() const { return "G. Bricteux"; }
int getNbOptions() const;
StringXNumber* getOption(int iopt);
void run();
};
#endif
......@@ -183,6 +183,10 @@ PView *GMSH_DistancePlugin::execute(PView *v)
std::vector<GEntity*> _entities;
GModel::current()->getEntities(_entities);
if(!_entities.size() || !_entities[_entities.size()-1]->getMeshElement(0)){
Msg::Error("This plugin needs a mesh !");
return view;
}
GEntity* ge = _entities[_entities.size()-1];
int integrationPointTetra[2];
integrationPointTetra[0]=0;
......@@ -195,11 +199,6 @@ PView *GMSH_DistancePlugin::execute(PView *v)
int order=ge->getMeshElement(0)->getPolynomialOrder();
int totNumNodes = totNodes+ge->getNumMeshElements()*integrationPointTetra[order-1];
if (totNumNodes ==0) {
Msg::Error("This plugin needs a mesh !");
return view;
}
std::vector<SPoint3> pts;
std::vector<double> distances;
std::vector<MVertex* > pt2Vertex;
......
......@@ -124,4 +124,10 @@ class GMSH_SolverPlugin : public GMSH_Plugin
virtual bool GL_enhanceLine(int CurveId, Vertex *v1, Vertex *v2) { return false; }
};
class GMSH_MeshPlugin : public GMSH_Plugin
{
inline GMSH_PLUGIN_TYPE getType() const { return GMSH_Plugin::GMSH_MESH_PLUGIN; }
virtual void run() {}
};
#endif
......@@ -55,6 +55,7 @@
#include "NearToFarField.h"
#include "DiscretizationError.h"
#include "Scal2Vec.h"
#include "CutMesh.h"
// for testing purposes only :-)
#undef HAVE_DLOPEN
......@@ -256,6 +257,10 @@ void PluginManager::registerDefaultPlugins()
#if defined(HAVE_ANN)
allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("NearestNeighbor", GMSH_RegisterNearestNeighborPlugin()));
#endif
#if defined(HAVE_DINTEGRATION)
allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("CutMesh", GMSH_RegisterCutMeshPlugin()));
#endif
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment