diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 82063381992f49904168fe94e5259263e2c924a1..5664d096810bb142e83d9b91ef93f22dc5919022 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -1103,26 +1103,36 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const } else if (_type == MEANPLANE){ + FILE * f3 = fopen("PTS.pos","w"); + fprintf(f3, "View \"\"{\n"); std::vector<SPoint3> points, pointsProj, pointsUV; SPoint3 ptCG(0.0, 0.0, 0.0); for(unsigned int i = 0; i < _ordered.size(); i++){ MVertex *v = _ordered[i]; 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[1] += v->y(); ptCG[2] += v->z(); } - ptCG /= points.size(); - mean_plane meanPlane; - computeMeanPlaneSimple(points, meanPlane); - projectPointsToPlane(points, pointsProj, meanPlane); - transformPointsIntoOrthoBasis(pointsProj, pointsUV, ptCG, meanPlane); - for(unsigned int i = 0; i < pointsUV.size(); i++){ - MVertex *v = _ordered[i]; - if(step == ITERU) myAssembler.fixVertex(v, 0, 1, pointsUV[i][0]); - else if(step == ITERV) myAssembler.fixVertex(v, 0, 1, pointsUV[i][1]); - } + fprintf(f3,"};\n"); + fclose(f3); + + ptCG /= points.size(); + mean_plane meanPlane; + computeMeanPlaneSimple(points, meanPlane); + projectPointsToPlane(points, pointsProj, meanPlane); + transformPointsIntoOrthoBasis(pointsProj, pointsUV, ptCG, meanPlane); + + for(unsigned int i = 0; i < pointsUV.size(); i++){ + MVertex *v = _ordered[i]; + if(step == ITERU) myAssembler.fixVertex(v, 0, 1, pointsUV[i][0]); + else if(step == ITERV) myAssembler.fixVertex(v, 0, 1, pointsUV[i][1]); + } + } else{ diff --git a/Geo/SVector3.h b/Geo/SVector3.h index db3c6e86d21ff64cb62143ad5e94cbf9bcbb65ec..0cd61b25c0de9f90c39aaea437108937a41cde7e 100644 --- a/Geo/SVector3.h +++ b/Geo/SVector3.h @@ -146,18 +146,22 @@ inline void buildOrthoBasis(SVector3 &normal, SVector3 &tangent, SVector3 &binor { //pick any Unit-Vector that's not parallel to normal: normal.normalize(); - if (normal[0] > normal[1] ) + if (fabs(normal[0]) > fabs(normal[1]) ) tangent = SVector3(0.0, 1.0, 0.0); else tangent = SVector3(1.0, 0.0, 0.0); //build a binormal from tangent and normal: binormal = crossprod(tangent, normal); - binormal.normalize(); + double t1 = binormal.normalize(); //and correct the tangent from the binormal and the normal. tangent = crossprod(normal, binormal); - tangent.normalize(); + double t2 = tangent.normalize(); + + if (t1 == 0.0 || t2 == 0.0) + buildOrthoBasis_naive(normal, tangent, binormal); + } #endif