Skip to content
Snippets Groups Projects
Commit 37fd8197 authored by Bastien Gorissen's avatar Bastien Gorissen
Browse files

Bugfix when using an opencascade model

parent 24b2594a
No related branches found
No related tags found
No related merge requests found
...@@ -28,18 +28,20 @@ template <class T> void getIntersection(std::vector<T>& res, ...@@ -28,18 +28,20 @@ template <class T> void getIntersection(std::vector<T>& res,
{ {
res.clear(); res.clear();
std::list<T> first_list = lists[0]; std::list<T> first_list = lists[0];
bool allsame = true;
for (typename std::list<T>::iterator item = first_list.begin(); for (typename std::list<T>::iterator item = first_list.begin();
item != first_list.end(); item++) { item != first_list.end(); item++) {
bool found = true; bool found = true;
for (typename std::vector<std::list<T> >::iterator list_iter = lists.begin(); for (typename std::vector<std::list<T> >::iterator list_iter = lists.begin();
list_iter != lists.end(); list_iter++) { list_iter != lists.end(); list_iter++) {
if (*(list_iter)!=first_list) {
allsame = false;
if (find((*list_iter).begin(), (*list_iter).end(), (*item)) == (*list_iter).end()) { if (find((*list_iter).begin(), (*list_iter).end(), (*item)) == (*list_iter).end()) {
found = false; found = false;
break; } else { found = true; break;}
} }
} }
if (found) { if (found || allsame ) {
res.push_back(*item); res.push_back(*item);
} }
} }
...@@ -74,6 +76,7 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok) ...@@ -74,6 +76,7 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok)
int num_matched_vertices = 0; int num_matched_vertices = 0;
int num_total_vertices = 0; int num_total_vertices = 0;
int num_mesh_vertices = 0;
int counter1 = 0; int counter1 = 0;
...@@ -101,6 +104,7 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok) ...@@ -101,6 +104,7 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok)
entity2++) entity2++)
{ {
if ((*entity2)->dim() != 0) continue; if ((*entity2)->dim() != 0) continue;
num_mesh_vertices++;
for (unsigned int ed = 0; for (unsigned int ed = 0;
ed < ((discreteVertex*) *entity2)->getNumMeshElements(); ed < ((discreteVertex*) *entity2)->getNumMeshElements();
ed++) ed++)
...@@ -122,26 +126,29 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok) ...@@ -122,26 +126,29 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok)
} }
if (best_score != DBL_MAX) { if (best_score != DBL_MAX) {
Msg::Info("Vertices %i (geom) and %i (mesh) match.", Msg::Info("Vertices %i (geom) and %i (mesh) match.\n",
(*entity1)->tag(), (*entity1)->tag(),
best_candidate_ge->tag()); best_candidate_ge->tag());
coresp_v->push_back(Pair<GVertex*,GVertex*>((GVertex*) *entity1, coresp_v->push_back(Pair<GVertex*,GVertex*>((GVertex*) *entity1,
(GVertex*) best_candidate_ge)); (GVertex*) best_candidate_ge));
((GVertex*) best_candidate_ge)->setTag(((GVertex*) *entity1)->tag()); ((GVertex*) best_candidate_ge)->setTag(((GVertex*) *entity1)->tag());
m2->remove((GVertex*) best_candidate_ge); //m2->remove((GVertex*) best_candidate_ge);
vertices.push_back((GVertex*) best_candidate_ge); //vertices.push_back((GVertex*) best_candidate_ge);
for (int v = 0; v < ((GVertex*) best_candidate_ge)->getNumMeshVertices(); v++) {
((GVertex*) best_candidate_ge)->getMeshVertex(v)->setEntity((GVertex*) *entity1);
}
num_matched_vertices++; num_matched_vertices++;
} }
counter1++; counter1++;
} }
for (std::vector<GVertex*>::iterator vert = vertices.begin(); //for (std::vector<GVertex*>::iterator vert = vertices.begin();
vert != vertices.end(); //vert != vertices.end();
vert++) //vert++)
m2->add(*vert); //m2->add(*vert);
Msg::Info("Vertices matched : %i / %i", num_matched_vertices, num_total_vertices); Msg::Info("Vertices matched : %i / %i (%i)\n", num_matched_vertices, num_total_vertices, num_mesh_vertices);
if(num_matched_vertices != num_total_vertices) ok = false; if(num_matched_vertices != num_total_vertices) ok = false;
return (coresp_v); return (coresp_v);
} }
...@@ -181,7 +188,7 @@ GeomMeshMatcher::matchEdges(GModel* m1, GModel* m2, ...@@ -181,7 +188,7 @@ GeomMeshMatcher::matchEdges(GModel* m1, GModel* m2,
getIntersection<GEdge*>(common_edges, lists); getIntersection<GEdge*>(common_edges, lists);
GEdge* choice = 0; GEdge* choice = 0;
if (common_edges.size() == 0) continue;
if (common_edges.size() == 1) { if (common_edges.size() == 1) {
choice = common_edges[0]; choice = common_edges[0];
} else { } else {
...@@ -218,6 +225,10 @@ GeomMeshMatcher::matchEdges(GModel* m1, GModel* m2, ...@@ -218,6 +225,10 @@ GeomMeshMatcher::matchEdges(GModel* m1, GModel* m2,
choice->reverse(); choice->reverse();
} }
for (int v = 0; v < ((GEdge*) choice)->getNumMeshVertices(); v++) {
if (((GEdge*) choice)->getMeshVertex(v)->onWhat()->dim() > 0)
((GEdge*) choice)->getMeshVertex(v)->setEntity((GEdge*) *entity1);
}
num_matched_edges++; num_matched_edges++;
} }
...@@ -284,6 +295,11 @@ GeomMeshMatcher:: matchFaces(GModel* m1, GModel* m2, ...@@ -284,6 +295,11 @@ GeomMeshMatcher:: matchFaces(GModel* m1, GModel* m2,
coresp_f->push_back(Pair<GFace*,GFace*>((GFace*) *entity1 , coresp_f->push_back(Pair<GFace*,GFace*>((GFace*) *entity1 ,
choice)); choice));
choice->setTag(((GFace*) *entity1)->tag()); choice->setTag(((GFace*) *entity1)->tag());
for (int v = 0; v < ((GFace*) choice)->getNumMeshVertices(); v++) {
if(((GFace*) choice)->getMeshVertex(v)->onWhat()->dim() > 1)
((GFace*) choice)->getMeshVertex(v)->setEntity((GFace*) *entity1);
}
num_matched_faces++; num_matched_faces++;
} }
...@@ -377,6 +393,11 @@ GeomMeshMatcher::matchRegions(GModel* m1, GModel* m2, ...@@ -377,6 +393,11 @@ GeomMeshMatcher::matchRegions(GModel* m1, GModel* m2,
coresp_r->push_back(Pair<GRegion*,GRegion*>((GRegion*) *entity1 , coresp_r->push_back(Pair<GRegion*,GRegion*>((GRegion*) *entity1 ,
choice)); choice));
choice->setTag(((GRegion*) *entity1)->tag()); choice->setTag(((GRegion*) *entity1)->tag());
for (int v = 0; v < ((GRegion*) choice)->getNumMeshVertices(); v++) {
if ( ((GRegion*) choice)->getMeshVertex(v)->onWhat()->dim() > 2)
((GRegion*) choice)->getMeshVertex(v)->setEntity((GRegion*) *entity1);
}
num_matched_regions++; num_matched_regions++;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment