diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 7fb7b2c816f579b4d623b1108014e7d39bedcbb2..a6be728be2f03347a96285128ee587da757f1463 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -220,6 +220,10 @@ void GetOptions(int argc, char *argv[]) CTX::instance()->mesh.saveAll = 1; i++; } + else if(!strcmp(argv[i] + 1, "switch_tags")) { + CTX::instance()->mesh.switchElementTags = 1; + i++; + } else if(!strcmp(argv[i] + 1, "optimize")) { CTX::instance()->mesh.optimize = 1; i++; diff --git a/Common/Context.h b/Common/Context.h index 2f2fc2b26fec327e7b7e2040f73e8d034c3368d7..a1ee4abc428800c6e775006deedffeb3ade80cd5 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -36,7 +36,8 @@ struct contextMeshOptions { int smoothInternalEdges, minCircPoints, minCurvPoints; int saveAll, saveGroupsOfNodes, binary, bdfFieldFormat, saveParametric; int smoothNormals, reverseAllNormals, zoneDefinition, clip; - int saveElementTagType; + int saveElementTagType; + int switchElementTags; }; struct contextGeometryOptions { diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 435c93a0344bac34a0038d918b260901a4d3fd58..6cf01b4b24bbee13863ad3ba254502d9a260ea88 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1271,6 +1271,8 @@ StringXNumber MeshOptions_Number[] = { "Display faces of surface mesh?" }, { F|O, "SurfaceNumbers" , opt_mesh_surfaces_num , 0. , "Display surface mesh element numbers?" }, + { F|O, "SwitchElementTags", opt_mesh_switch_elem_tags, 0. , + "Invert elementary and physical tags when reading the mesh"}, { F|O, "Tangents" , opt_mesh_tangents , 0.0 , "Display size of tangent vectors (in pixels)" }, diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index b84169170aa8d4085806eacaa59de64fb423ef18..555497aa7407d58360886abaff85a1bd6f467d5c 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -350,10 +350,11 @@ int MergeFile(std::string fileName, bool warnIfMissing) !strncmp(header, "$MeshFormat", 11) || !strncmp(header, "$Comments", 9)) { // mesh matcher if(CTX::instance()->geom.matchGeomAndMesh && !GModel::current()->empty()){ + GModel* tmp2 = GModel::current(); GModel* tmp = new GModel(); tmp->readMSH(fileName); - if(GeomMeshMatcher::instance()->match(GModel::current(), tmp)) - fileName = "out.msh"; + if(GeomMeshMatcher::instance()->match(tmp2, tmp)) + fileName = "out.msh"; delete tmp; } status = GModel::current()->readMSH(fileName); diff --git a/Common/Options.cpp b/Common/Options.cpp index 7530791511e2efd7a116303df8edf03639a0cd2f..c07dbe1e2893b624f30a3774a4bea0aab6b74095 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -5881,6 +5881,13 @@ double opt_mesh_color_carousel(OPT_ARGS_NUM) return CTX::instance()->mesh.colorCarousel; } +double opt_mesh_switch_elem_tags(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->mesh.switchElementTags = val ? 1 : 0; + return CTX::instance()->mesh.switchElementTags; +} + double opt_mesh_zone_definition(OPT_ARGS_NUM) { if(action & GMSH_SET){ diff --git a/Common/Options.h b/Common/Options.h index 5d59107db40d61401108de27c24396b36c5d3185..913a271e22880c223719c7120e89564693ea6e56 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -549,6 +549,7 @@ double opt_mesh_save_element_tag_type(OPT_ARGS_NUM); double opt_mesh_save_parametric(OPT_ARGS_NUM); double opt_mesh_save_groups_of_nodes(OPT_ARGS_NUM); double opt_mesh_color_carousel(OPT_ARGS_NUM); +double opt_mesh_switch_elem_tags(OPT_ARGS_NUM); double opt_mesh_zone_definition(OPT_ARGS_NUM); double opt_mesh_nb_nodes(OPT_ARGS_NUM); double opt_mesh_nb_triangles(OPT_ARGS_NUM); diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index 88dcc72821b31f254456513bc6f7500027f8a736..dbbd9e0c039c623164ed427d4c1abf5a7e697c54 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -29,6 +29,7 @@ #include "discreteFace.h" #include "discreteRegion.h" #include "MVertexPositionSet.h" +#include "Context.h" #include "OS.h" #if defined(HAVE_POST) @@ -394,9 +395,15 @@ int GModel::readMSH(const std::string &name) int dom1 = 0, dom2 = 0, numVertices; std::vector<short> ghosts; if(version <= 1.0){ - if(fscanf(fp, "%d %d %d %d %d", &num, &type, &physical, &elementary, - &numVertices) != 5) - return 0; + if(CTX::instance()->mesh.switchElementTags) { + if(fscanf(fp, "%d %d %d %d %d", &num, &type, &elementary, &physical, + &numVertices) != 5) + return 0; + } else { + if(fscanf(fp, "%d %d %d %d %d", &num, &type, &physical, &elementary, + &numVertices) != 5) + return 0; + } if(numVertices != MElement::getInfoMSH(type)) return 0; } else{