Commit ed95b8d5 by Christophe Geuzaine

Merge branch 'master' of http://gitlab.onelab.info/gmsh/gmsh

parents 80c3ba45 5bea37e1
Pipeline #304 passed with stage
in 8 minutes 55 seconds
......@@ -77,6 +77,7 @@ std::vector<std::pair<std::string, std::string> > GetUsage()
"p3d, diff, med, ...)"));
s.push_back(mp("-bin", "Use binary format when available"));
s.push_back(mp("-refine", "Perform uniform mesh refinement, then exit"));
s.push_back(mp("-reclassify", "Reclassify mesh, then exit"));
s.push_back(mp("-part int", "Partition after batch mesh generation"));
s.push_back(mp("-partWeight tri|quad|tet|prism|hex int", "Weight of a triangle/quad/etc. "
"during partitioning"));
......@@ -382,6 +383,10 @@ void GetOptions(int argc, char *argv[])
CTX::instance()->batch = 5;
i++;
}
else if(!strcmp(argv[i] + 1, "reclassify")) {
CTX::instance()->batch = 6;
i++;
}
else if(!strcmp(argv[i] + 1, "renumber")) {
CTX::instance()->batchAfterMesh = 1;
CTX::instance()->partitionOptions.renumber = 1;
......
......@@ -140,7 +140,7 @@ class CTX {
int highResolutionGraphics;
// 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)
// mesh, 5: refine mesh, 6: reclassify mesh)
int batch;
// batch operations to apply after meshing (1: partition mesh)
int batchAfterMesh;
......
......@@ -316,6 +316,8 @@ int GmshBatch()
AdaptMesh(GModel::current());
else if(CTX::instance()->batch == 5)
RefineMesh(GModel::current(), CTX::instance()->mesh.secondOrderLinear);
else if(CTX::instance()->batch == 6)
GModel::current()->classifyAllFaces();
#if defined(HAVE_CHACO) || defined(HAVE_METIS)
if(CTX::instance()->batchAfterMesh == 1){
if (CTX::instance()->partitionOptions.num_partitions > 1)
......
......@@ -20,18 +20,6 @@
#include "discreteEdge.h"
#include "discreteFace.h"
extern GEdge *getNewModelEdge(GFace *gf1, GFace *gf2,
std::map<std::pair<int, int>, GEdge*> &newEdges);
extern void recurClassifyEdges(MTri3 *t, std::map<MTriangle*, GFace*> &reverse,
std::map<MLine*, GEdge*, compareMLinePtr> &lines,
std::set<MLine*> &touched, std::set<MTri3*> &trisTouched,
std::map<std::pair<int, int>, GEdge*> &newEdges);
extern void recurClassify(MTri3 *t, GFace *gf,
std::map<MLine*, GEdge*, compareMLinePtr> &lines,
std::map<MTriangle*, GFace*> &reverse);
static void NoElementsSelectedMode(classificationEditor *e)
{
e->buttons[CLASS_BUTTON_SELECT_ELEMENTS]->activate();
......@@ -315,118 +303,8 @@ static void select_surfaces_cb(Fl_Widget *w, void *data)
static void classify_cb(Fl_Widget *w, void *data)
{
classificationEditor *e = (classificationEditor*)data;
std::map<MLine*, GEdge*, compareMLinePtr> lines;
for(GModel::eiter it = GModel::current()->firstEdge();
it != GModel::current()->lastEdge(); ++it){
for(unsigned int i = 0; i < (*it)->lines.size();i++)
lines[(*it)->lines[i]] = *it;
}
std::list<MTri3*> tris;
{
std::set<GFace*>::iterator it = e->faces.begin();
while(it != e->faces.end()){
GFace *gf = *it;
for(unsigned int i = 0; i < gf->triangles.size(); i++)
tris.push_back(new MTri3(gf->triangles[i], 0));
gf->triangles.clear();
++it;
}
}
if(tris.empty()) return;
connectTriangles(tris);
std::map<MTriangle*, GFace*> reverse;
// color all triangles
std::list<MTri3*> ::iterator it = tris.begin();
while(it != tris.end()){
if(!(*it)->isDeleted()){
discreteFace *gf = new discreteFace
(GModel::current(), GModel::current()->getMaxElementaryNumber(2) + 1);
recurClassify(*it, gf, lines, reverse);
GModel::current()->add(gf);
}
++it;
}
// color some lines
it = tris.begin();
while(it != tris.end()){
(*it)->setDeleted(false);
++it;
}
it = tris.begin();
// classify edges that are bound by different GFaces
std::map<std::pair<int, int>, GEdge*> newEdges;
std::set<MLine*> touched;
std::set<MTri3*> tritouched;
recurClassifyEdges(*it, reverse, lines, touched, tritouched, newEdges);
// check if new edges should not be splitted
// splitted if composed of several open or closed edges
for (std::map<std::pair<int, int>, GEdge*>::iterator it = newEdges.begin();
it != newEdges.end() ; ++it){
std::list<MLine*> segments;
for(unsigned int i = 0; i < it->second->lines.size(); i++)
segments.push_back(it->second->lines[i]);
while (!segments.empty()) {
std::vector<MLine*> myLines;
std::list<MLine*>::iterator it = segments.begin();
MVertex *vB = (*it)->getVertex(0);
MVertex *vE = (*it)->getVertex(1);
myLines.push_back(*it);
segments.erase(it);
it++;
for (int i = 0; i < 2; i++) {
for (std::list<MLine*>::iterator it = segments.begin();
it != segments.end(); ++it){
MVertex *v1 = (*it)->getVertex(0);
MVertex *v2 = (*it)->getVertex(1);
std::list<MLine*>::iterator itp;
if (v1 == vE){
myLines.push_back(*it);
itp = it;
it++;
segments.erase(itp);
vE = v2;
i = -1;
}
else if ( v2 == vE){
myLines.push_back(*it);
itp = it;
it++;
segments.erase(itp);
vE = v1;
i = -1;
}
if (it == segments.end()) break;
}
if (vB == vE) break;
if (segments.empty()) break;
MVertex *temp = vB;
vB = vE;
vE = temp;
}
GEdge *newGe = new discreteEdge
(GModel::current(), GModel::current()->getMaxElementaryNumber(1) + 1, 0, 0);
newGe->lines.insert(newGe->lines.end(), myLines.begin(), myLines.end());
GModel::current()->add(newGe);
}
}
for (std::map<std::pair<int, int>, GEdge*>::iterator it = newEdges.begin();
it != newEdges.end(); ++it){
GEdge *ge = it->second;
GModel::current()->remove(ge);
}
while(it != tris.end()){
delete *it;
++it;
}
GModel::current()->classifyFaces(e->faces);
// remove selected, but do not delete its elements
if(e->selected){
......
......@@ -54,6 +54,8 @@
#include "meshMetric.h"
#include "meshGRegionMMG3D.h"
#include "meshGFaceBamg.h"
static const float EDGE_ANGLE_THRESHOLD = 0.698132;
#endif
#if defined(HAVE_KBIPACK)
......@@ -3812,6 +3814,42 @@ GEdge *getNewModelEdge(GFace *gf1, GFace *gf2,
#if defined(HAVE_MESH)
void GModel::classifyAllFaces()
{
std::set<GFace*> faces;
std::vector<MElement*> elements;
for(GModel::fiter it = this->firstFace(); it != this->lastFace(); ++it) {
faces.insert(*it);
elements.insert(elements.end(), (*it)->triangles.begin(),
(*it)->triangles.end());
elements.insert(elements.end(), (*it)->quadrangles.begin(),
(*it)->quadrangles.end());
}
discreteEdge* edge = new discreteEdge
(GModel::current(), GModel::current()->getMaxElementaryNumber(1) + 1, 0, 0);
GModel::current()->add(edge);
e2t_cont adj;
buildEdgeToElements(elements, adj);
std::vector<edge_angle> edges_detected, edges_lonly;
buildListOfEdgeAngle(adj, edges_detected, edges_lonly);
for(unsigned int i = 0; i < edges_detected.size(); i++){
edge_angle ea = edges_detected[i];
if (ea.angle <= EDGE_ANGLE_THRESHOLD) break;
edge->lines.push_back(new MLine(ea.v1, ea.v2));
}
this->classifyFaces(faces);
GModel::current()->remove(edge);
edge->lines.clear();
delete edge;
elements.clear();
edges_detected.clear();
edges_lonly.clear();
}
void recurClassifyEdges(MTri3 *t, std::map<MTriangle*, GFace*> &reverse,
std::map<MLine*, GEdge*, compareMLinePtr> &lines,
std::set<MLine*> &touched, std::set<MTri3*> &trisTouched,
......@@ -3865,7 +3903,6 @@ void recurClassify(MTri3 *t, GFace *gf,
#endif
void GModel::classifyFaces(std::set<GFace*> &_faces)
{
#if defined(HAVE_MESH)
......
......@@ -486,6 +486,9 @@ class GModel {
// reclassify a mesh i.e. use an angle threshold to tag edges faces and regions
void classifyFaces(std::set<GFace*> &_faces);
// classify a mesh for all faces on the current model
void classifyAllFaces();
// glue entities in the model (assume a tolerance eps and merge
// vertices that are too close, then merge edges, faces and
// regions). Warning: the gluer changes the geometric model, so that
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment