Skip to content
Snippets Groups Projects
Commit 6c6eebe0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix duplicate points + generate to edges

parent c6f6ace0
No related branches found
No related tags found
No related merge requests found
...@@ -58,16 +58,12 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view) ...@@ -58,16 +58,12 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view)
int outputdim = (int)MeshSubEntitiesOptions_Number[2].def; int outputdim = (int)MeshSubEntitiesOptions_Number[2].def;
int outphysical = (int)MeshSubEntitiesOptions_Number[3].def; int outphysical = (int)MeshSubEntitiesOptions_Number[3].def;
if(inputdim < 0 || inputdim > 3 || outputdim > inputdim){ if(inputdim < 0 || inputdim > 3 || outputdim < 0 || outputdim > 3 ||
outputdim > inputdim){
Msg::Error("Bad dimensions"); Msg::Error("Bad dimensions");
return view; return view;
} }
if(outputdim != 0){
Msg::Error("Only vertices coded for now");
return view;
}
GModel *m = GModel::current(); GModel *m = GModel::current();
std::map<int, std::vector<GEntity*> > groups[4]; std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups); m->getPhysicalGroups(groups);
...@@ -84,7 +80,7 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view) ...@@ -84,7 +80,7 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view)
for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++) for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++)
elements.push_back(entities[i]->getMeshElement(j)); elements.push_back(entities[i]->getMeshElement(j));
// FIXME: generalize this to outputdim != 0 ! if(outputdim == 0){ // create point elements for mesh vertices
std::set<MVertex*> vertices; std::set<MVertex*> vertices;
for(unsigned int i = 0; i < elements.size(); i++){ for(unsigned int i = 0; i < elements.size(); i++){
for(int j = 0; j < elements[i]->getNumVertices(); j++){ for(int j = 0; j < elements[i]->getNumVertices(); j++){
...@@ -105,9 +101,49 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view) ...@@ -105,9 +101,49 @@ PView *GMSH_MeshSubEntitiesPlugin::execute(PView *view)
m->add(gv); m->add(gv);
} }
gv->physicals.push_back(outphysical); gv->physicals.push_back(outphysical);
if(gv->points.empty())
gv->points.push_back(new MPoint(v)); gv->points.push_back(new MPoint(v));
} }
m->pruneMeshVertexAssociations(); m->pruneMeshVertexAssociations();
}
else if(outputdim == 1){ // create line elements for mesh edges
std::set<MEdge, Less_Edge> edges;
for(unsigned int i = 0; i < elements.size(); i++){
for(int j = 0; j < elements[i]->getNumEdges(); j++){
MEdge e = elements[i]->getEdge(j);
edges.insert(e);
}
}
for(std::set<MEdge, Less_Edge>::const_iterator it = edges.begin();
it != edges.end(); ++it){
const MEdge &e = *it;
GEdge *ge = 0;
MVertex *v0 = e.getVertex(0), *v1 = e.getVertex(1);
if(v0->onWhat() && v1->onWhat()){
if(v0->onWhat()->dim() == 1 &&
((v1->onWhat()->dim() == 1 && v0->onWhat() == v1->onWhat()) ||
v1->onWhat()->dim() == 0))
ge = (GEdge*)v0->onWhat();
else if(v1->onWhat()->dim() == 1 &&
((v0->onWhat()->dim() == 1 && v0->onWhat() == v1->onWhat()) ||
v0->onWhat()->dim() == 0))
ge = (GEdge*)v1->onWhat();
}
if(!ge){
ge = new discreteEdge(m, m->getMaxElementaryNumber(1) + 1, 0, 0);
v0->setEntity(ge);
v1->setEntity(ge);
m->add(ge);
}
ge->physicals.push_back(outphysical);
if(ge->lines.empty())
ge->lines.push_back(new MLine(v0, v1));
}
}
else{
Msg::Error("Plugin(MeshSubEntities) not coded yet for output dim %d",
outputdim);
}
CTX::instance()->mesh.changed = ENT_ALL; CTX::instance()->mesh.changed = ENT_ALL;
......
...@@ -20,7 +20,7 @@ class GMSH_MeshSubEntitiesPlugin : public GMSH_PostPlugin ...@@ -20,7 +20,7 @@ class GMSH_MeshSubEntitiesPlugin : public GMSH_PostPlugin
std::string getName() const { return "MeshSubEntities"; } std::string getName() const { return "MeshSubEntities"; }
std::string getShortHelp() const std::string getShortHelp() const
{ {
return "Mesh entities generator"; return "Mesh subentities generator";
} }
std::string getHelp() const; std::string getHelp() const;
int getNbOptions() const; int getNbOptions() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment