Skip to content
Snippets Groups Projects
Commit 5af753c6 authored by Emilie Marchandise's avatar Emilie Marchandise
Browse files

fixed bug in buildorthobasis, ok for harmonicplane now :-)

parent 01755261
No related branches found
No related tags found
No related merge requests found
...@@ -1103,15 +1103,24 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const ...@@ -1103,15 +1103,24 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const
} }
else if (_type == MEANPLANE){ else if (_type == MEANPLANE){
FILE * f3 = fopen("PTS.pos","w");
fprintf(f3, "View \"\"{\n");
std::vector<SPoint3> points, pointsProj, pointsUV; std::vector<SPoint3> points, pointsProj, pointsUV;
SPoint3 ptCG(0.0, 0.0, 0.0); SPoint3 ptCG(0.0, 0.0, 0.0);
for(unsigned int i = 0; i < _ordered.size(); i++){ for(unsigned int i = 0; i < _ordered.size(); i++){
MVertex *v = _ordered[i]; MVertex *v = _ordered[i];
points.push_back(SPoint3(v->x(), v->y(), v->z())); points.push_back(SPoint3(v->x(), v->y(), v->z()));
fprintf(f3, "SP(%g,%g,%g){%g};\n",
v->x(), v->y(), v->z(),
(double)v->getNum());
ptCG[0] += v->x(); ptCG[0] += v->x();
ptCG[1] += v->y(); ptCG[1] += v->y();
ptCG[2] += v->z(); ptCG[2] += v->z();
} }
fprintf(f3,"};\n");
fclose(f3);
ptCG /= points.size(); ptCG /= points.size();
mean_plane meanPlane; mean_plane meanPlane;
computeMeanPlaneSimple(points, meanPlane); computeMeanPlaneSimple(points, meanPlane);
...@@ -1124,6 +1133,7 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const ...@@ -1124,6 +1133,7 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const
else if(step == ITERV) myAssembler.fixVertex(v, 0, 1, pointsUV[i][1]); else if(step == ITERV) myAssembler.fixVertex(v, 0, 1, pointsUV[i][1]);
} }
} }
else{ else{
Msg::Error("Unknown type of parametrization"); Msg::Error("Unknown type of parametrization");
......
...@@ -146,18 +146,22 @@ inline void buildOrthoBasis(SVector3 &normal, SVector3 &tangent, SVector3 &binor ...@@ -146,18 +146,22 @@ inline void buildOrthoBasis(SVector3 &normal, SVector3 &tangent, SVector3 &binor
{ {
//pick any Unit-Vector that's not parallel to normal: //pick any Unit-Vector that's not parallel to normal:
normal.normalize(); normal.normalize();
if (normal[0] > normal[1] ) if (fabs(normal[0]) > fabs(normal[1]) )
tangent = SVector3(0.0, 1.0, 0.0); tangent = SVector3(0.0, 1.0, 0.0);
else else
tangent = SVector3(1.0, 0.0, 0.0); tangent = SVector3(1.0, 0.0, 0.0);
//build a binormal from tangent and normal: //build a binormal from tangent and normal:
binormal = crossprod(tangent, normal); binormal = crossprod(tangent, normal);
binormal.normalize(); double t1 = binormal.normalize();
//and correct the tangent from the binormal and the normal. //and correct the tangent from the binormal and the normal.
tangent = crossprod(normal, binormal); tangent = crossprod(normal, binormal);
tangent.normalize(); double t2 = tangent.normalize();
if (t1 == 0.0 || t2 == 0.0)
buildOrthoBasis_naive(normal, tangent, binormal);
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment