Skip to content
Snippets Groups Projects
Commit 765fd964 authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

bug in getAllParameters

parent f439516e
No related branches found
No related tags found
No related merge requests found
...@@ -379,7 +379,7 @@ static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> &params ...@@ -379,7 +379,7 @@ static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> &params
params.push_back((*it)->reparamOnFace(gf, range.low(),-1)); params.push_back((*it)->reparamOnFace(gf, range.low(),-1));
params.push_back((*it)->reparamOnFace(gf, range.low(), 1)); params.push_back((*it)->reparamOnFace(gf, range.low(), 1));
} }
else if (gv == (*it)->getEndVertex()){ if (gv == (*it)->getEndVertex()){
params.push_back((*it)->reparamOnFace(gf, range.high(),-1)); params.push_back((*it)->reparamOnFace(gf, range.high(),-1));
params.push_back((*it)->reparamOnFace(gf, range.high(), 1)); params.push_back((*it)->reparamOnFace(gf, range.high(), 1));
} }
...@@ -419,45 +419,53 @@ bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, ...@@ -419,45 +419,53 @@ bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf,
if (p1.size() == 1 && p2.size() == 1){ if (p1.size() == 1 && p2.size() == 1){
param1 = p1[0]; param1 = p1[0];
param2 = p2[0]; param2 = p2[0];
return true;
}
else if (p1.size() == 1 && p2.size() == 2){
double d1 =
(p1[0].x() - p2[0].x()) * (p1[0].x() - p2[0].x()) +
(p1[0].y() - p2[0].y()) * (p1[0].y() - p2[0].y());
double d2 =
(p1[0].x() - p2[1].x()) * (p1[0].x() - p2[1].x()) +
(p1[0].y() - p2[1].y()) * (p1[0].y() - p2[1].y());
param1 = p1[0];
param2 = d2 < d1 ? p2[1] : p2[0];
return true;
}
else if (p2.size() == 1 && p1.size() == 2){
double d1 =
(p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) +
(p2[0].y() - p1[0].y()) * (p2[0].y() - p1[0].y());
double d2 =
(p2[0].x() - p1[1].x()) * (p2[0].x() - p1[1].x()) +
(p2[0].y() - p1[1].y()) * (p2[0].y() - p1[1].y());
param1 = d2 < d1 ? p1[1] : p1[0];
param2 = p2[0];
return true;
}
else if(p1.size() > 1 && p2.size() > 1){
param1 = p1[0];
param2 = p2[0];
printf("NO WAY : TWO VERTICES ON THE SEAM, CANNOT CHOOSE\n");
// shout, both vertices are on seams
return false;
} }
else{ else{
// brute force! int imin = 0;
param1 = gf->parFromPoint(SPoint3(v1->x(), v1->y(), v1->z())); int jmin = 0;
param2 = gf->parFromPoint(SPoint3(v2->x(), v2->y(), v2->z())); {
return true; double d =
(p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) +
(p2[0].y() - p1[0].y()) * (p2[0].y() - p1[0].y());
for (unsigned int i=0;i<p2.size();i++){
double d1 =
(p2[i].x() - p1[0].x()) * (p2[i].x() - p1[0].x()) +
(p2[i].y() - p1[0].y()) * (p2[i].y() - p1[0].y());
if (d1 < d){
imin = i;
d = d1;
}
}
}
{
double d =
(p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) +
(p2[0].y() - p1[0].y()) * (p2[0].y() - p1[0].y());
for (unsigned int i=0;i<p1.size();i++){
double d1 =
(p2[0].x() - p1[i].x()) * (p2[0].x() - p1[i].x()) +
(p2[0].y() - p1[i].y()) * (p2[0].y() - p1[i].y());
if (d1 < d){
jmin = i;
d = d1;
}
}
}
/*
if (p1.size() == 8 ||p2.size() == 8){
for (int i=0;i<p1.size();i++){
printf("p1[%d] = %g %g\n",i,p1[i].x(),p1[i].y());
}
for (int i=0;i<p2.size();i++){
printf("p2[%d] = %g %g\n",i,p2[i].x(),p2[i].y());
}
printf("%d %d\n",imin,jmin);
}
*/
param1 = p1[jmin];
param2 = p2[imin];
} }
return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment