diff --git a/Plugin/SimplePartition.cpp b/Plugin/SimplePartition.cpp index 4cba39f1757f356c6fb158e7818d0c58a5773062..9495e425e748ee4cc11f5e4a0196b4d3128ee55a 100644 --- a/Plugin/SimplePartition.cpp +++ b/Plugin/SimplePartition.cpp @@ -15,6 +15,7 @@ StringXNumber SimplePartitionOptions_Number[] = { {GMSH_FULLRC, "NumSlices", NULL, 4.}, {GMSH_FULLRC, "Direction", NULL, 0.}, + {GMSH_FULLRC, "CreateBoundaries", NULL, 1.}, }; extern "C" @@ -29,7 +30,8 @@ std::string GMSH_SimplePartitionPlugin::getHelp() const { return "Plugin(SimplePartition) partitions the current mesh into " "`NumSlices' slices, along the X-, Y- or Z-axis depending on " - "the value of `Direction' (0,1,2)."; + "the value of `Direction' (0,1,2). The plugin creates partition " + "boundaries if `CreateBoundaries' is set."; } int GMSH_SimplePartitionPlugin::getNbOptions() const @@ -46,10 +48,12 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v) { int numSlices = (int)SimplePartitionOptions_Number[0].def; int direction = (int)SimplePartitionOptions_Number[1].def; + int createBoundaries = (int)SimplePartitionOptions_Number[2].def; // partition the highest dimension elements in the current model (lower - // dimension elements en boundaries cannot be tagged a priori: there are - // special geometrical cases) + // dimension elements on boundaries cannot be tagged a priori: there are + // special geometrical cases where this will fail) + Msg::Info("Partitioning highest dimension elements"); GModel *m = GModel::current(); SBoundingBox3d bbox = m->bounds(); double pmin = bbox.min()[direction], pmax = bbox.max()[direction]; @@ -89,6 +93,7 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v) m->recomputeMeshPartitions(); // partition lower dimension elements + Msg::Info("Partitioning lower dimension elements"); for(unsigned int i = 0; i < entities.size(); i++){ GEntity *ge = entities[i]; if(ge->dim() == dim) continue; @@ -115,54 +120,56 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v) } } - // create partition boundaries + if(createBoundaries){ #if defined(HAVE_MESH) - CreatePartitionBoundaries(m, false, false); + Msg::Info("Creating partition boundaries"); + CreatePartitionBoundaries(m, false, false); +#else + Msg::Error("Creating partition boundaries requires the mesh module"); #endif - - // renumber partition boundaries using the natural slicing order - std::vector<std::pair<double, GFace*> > parFaces; - std::vector<std::pair<double, GEdge*> > parEdges; - m->getEntities(entities); - for(unsigned int i = 0; i < entities.size(); i++){ - GEntity *ge = entities[i]; - if(ge->geomType() == GEntity::PartitionSurface || - ge->geomType() == GEntity::PartitionCurve){ - double val = pmax; - for(int j = 0; j < ge->getNumMeshElements(); j++){ - MElement *e = ge->getMeshElement(j); - for(int k = 0; k < e->getNumVertices(); k++){ - MVertex *v = e->getVertex(k); - val = std::min(val, v->point()[direction]); + // renumber partition boundaries using the natural slicing order + Msg::Info("Renumbering partition boundaries"); + std::vector<std::pair<double, GFace*> > parFaces; + std::vector<std::pair<double, GEdge*> > parEdges; + m->getEntities(entities); + for(unsigned int i = 0; i < entities.size(); i++){ + GEntity *ge = entities[i]; + if(ge->geomType() == GEntity::PartitionSurface || + ge->geomType() == GEntity::PartitionCurve){ + double val = pmax; + for(int j = 0; j < ge->getNumMeshElements(); j++){ + MElement *e = ge->getMeshElement(j); + for(int k = 0; k < e->getNumVertices(); k++){ + MVertex *v = e->getVertex(k); + val = std::min(val, v->point()[direction]); + } + } + if(ge->dim() == 2){ + GFace *gf = (GFace*)ge; + parFaces.push_back(std::pair<double, GFace*>(val, gf)); + m->remove(gf); + } + else{ + GEdge *gc = (GEdge*)ge; + parEdges.push_back(std::pair<double, GEdge*>(val, gc)); + m->remove(gc); } - } - if(ge->dim() == 2){ - GFace *gf = (GFace*)ge; - parFaces.push_back(std::pair<double, GFace*>(val, gf)); - m->remove(gf); - } - else{ - GEdge *gc = (GEdge*)ge; - parEdges.push_back(std::pair<double, GEdge*>(val, gc)); - m->remove(gc); } } - } - - std::sort(parFaces.begin(), parFaces.end()); - for(unsigned int i = 0; i < parFaces.size(); i++){ - GFace *gf = parFaces[i].second; - gf->setTag(-i-1); - gf->setMeshMaster(-i-1); - m->add(gf); - } - - std::sort(parEdges.begin(), parEdges.end()); - for(unsigned int i = 0; i < parEdges.size(); i++){ - GEdge *ge = parEdges[i].second; - ge->setTag(-i-1); - ge->setMeshMaster(-i-1); - m->add(ge); + std::sort(parFaces.begin(), parFaces.end()); + for(unsigned int i = 0; i < parFaces.size(); i++){ + GFace *gf = parFaces[i].second; + gf->setTag(-i-1); + gf->setMeshMaster(-i-1); + m->add(gf); + } + std::sort(parEdges.begin(), parEdges.end()); + for(unsigned int i = 0; i < parEdges.size(); i++){ + GEdge *ge = parEdges[i].second; + ge->setTag(-i-1); + ge->setMeshMaster(-i-1); + m->add(ge); + } } return v;