diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index e4cafe81e35ed76a254fe9e82fda5972847d695b..5d340647af7fbd47caba1654f9a162d57779ae8a 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -1069,8 +1069,8 @@ void MTetrahedronN::getFaceRep(int num, double *x, double *y, double *z, SVector { static double pp[4][3] = {{0,0,0},{1,0,0},{0,1,0},{0,0,1}}; static int fak [4][3] = {{0,1,2},{0,1,3},{0,2,3},{1,2,3}}; - int iFace = num / (numSubEdges*numSubEdges); - int iSubFace = num % (numSubEdges*numSubEdges); + int iFace = num / (numSubEdges * numSubEdges); + int iSubFace = num % (numSubEdges * numSubEdges); int iVertex1 = fak [iFace][0]; int iVertex2 = fak [iFace][1]; diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 2d7d83cb590835919e2a0b2e5a8141977fc283da..a16d3e84b4f82719e93ea34079eaa30cd70cca9f 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -199,37 +199,6 @@ MVertex::linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos) return pos.end(); } -void parametricCoordinates(const MVertex *ver, const GFace *gf, double &u, double &v) -{ - if (gf->geomType() == GEntity::CompoundSurface){ - GFaceCompound *gfc = (GFaceCompound*) gf; - SPoint2 p = gfc->getCoordinates((MVertex*)ver); - u = p.x(); - v = p.y(); - return; - } - - GEntity *ge = ver->onWhat(); - if(ge->dim() == 2){ - ver->getParameter(0, u); - ver->getParameter(1, v); - } - else if(ge->dim() == 1){ - double t; - ver->getParameter(0, t); - GEdge *ged = dynamic_cast<GEdge*>(ge); - SPoint2 p = ged->reparamOnFace((GFace*)gf, t, 1); - u = p.x(); - v = p.y(); - } - else{ - GVertex *gver = dynamic_cast<GVertex*>(ge); - SPoint2 p = gver->reparamOnFace((GFace*)gf, 1); - u = p.x(); - v = p.y(); - } -} - static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> ¶ms) { params.clear(); @@ -284,19 +253,23 @@ bool reparamMeshVerticesOnFace(MVertex *v1, MVertex *v2, GFace *gf, 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].x() - 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].x() - p2[1].y())*(p1[0].y() - p2[1].y()); + double d1 = + (p1[0].x() - p2[0].x()) * (p1[0].x() - p2[0].x()) + + (p1[0].x() - 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].x() - 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].x() - 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].x() - p1[1].y())*(p2[0].y() - p1[1].y()); + double d1 = + (p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) + + (p2[0].x() - 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].x() - p1[1].y()) * (p2[0].y() - p1[1].y()); param1 = d2 < d1 ? p1[1] : p1[0]; param2 = p2[0]; return true; @@ -320,29 +293,27 @@ bool reparamMeshVertexOnFace(MVertex *v, GFace *gf, SPoint2 ¶m) if(v->onWhat()->dim() == 0){ GVertex *gv = (GVertex*)v->onWhat(); + param = gv->reparamOnFace(gf, 1); // abort if we could be on a seam std::list<GEdge*> ed = gv->edges(); for(std::list<GEdge*>::iterator it = ed.begin(); it != ed.end(); it++) if((*it)->isSeam(gf)) return false; - - param = gv->reparamOnFace(gf, 1); } else if(v->onWhat()->dim() == 1){ GEdge *ge = (GEdge*)v->onWhat(); + double t; + v->getParameter(0, t); + param = ge->reparamOnFace(gf, t, 1); // abort if we are on a seam (todo: try dir=-1 and compare) if(ge->isSeam(gf)) return false; - - double UU; - v->getParameter(0, UU); - param = ge->reparamOnFace(gf, UU, 1); } else{ - double UU, VV; - if(v->onWhat() == gf && v->getParameter(0, UU) && v->getParameter(1, VV)) - param = SPoint2(UU, VV); + double uu, vv; + if(v->onWhat() == gf && v->getParameter(0, uu) && v->getParameter(1, vv)) + param = SPoint2(uu, vv); else param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z())); } diff --git a/Geo/MVertex.h b/Geo/MVertex.h index 12d6373f000f1dd394a52174d341ff5a7bdc33b6..bb90b489637a6e9d9b2835006ec997c254fe5750 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -165,7 +165,6 @@ class MFaceVertex : public MVertex{ } }; -void parametricCoordinates(const MVertex *ver, const GFace *gf, double &u, double &v); bool reparamMeshVerticesOnFace(MVertex *v1, MVertex *v2, GFace *gf, SPoint2 ¶m1, SPoint2 ¶m2); bool reparamMeshVertexOnFace(MVertex *v, GFace *gf, SPoint2 ¶m); diff --git a/Mesh/gmshSmoothHighOrder.cpp b/Mesh/gmshSmoothHighOrder.cpp index 92d46d94c1a213f77600ffae30fa15e8d3649c4d..6f2ddec5bc7a3a4605f168f2a32a7e93f9569779 100644 --- a/Mesh/gmshSmoothHighOrder.cpp +++ b/Mesh/gmshSmoothHighOrder.cpp @@ -586,9 +586,17 @@ bool optimizeHighOrderMesh(GFace *gf, edgeContainer &edgeVertices) return success; } -void getParametricCoordnates ( GFace *gf, - std::vector<MVertex*> &e, - std::vector<SPoint2> ¶m) +static void parametricCoordinates(MVertex *v, GFace *gf, double &uu, double &vv) +{ + SPoint2 param; + reparamMeshVertexOnFace(v, gf, param); + uu = param[0]; + vv = param[1]; +} + +static void getParametricCoordnates ( GFace *gf, + std::vector<MVertex*> &e, + std::vector<SPoint2> ¶m) { param.clear(); for (unsigned int i = 0; i < e.size(); i++){ diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 73248d70d3ff73e0ba0ce75f71a07704ca82c8e9..3c448a3f3f466afe6ba70bd91ab27ab98b60674e 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -391,8 +391,8 @@ static bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) MVertex *here = *itv; SPoint2 param; reparamMeshVertexOnFace(here, gf, param); - U_[count] = param.x(); - V_[count] = param.y(); + U_[count] = param[0]; + V_[count] = param[1]; (*itv)->setIndex(count); numbered_vertices[(*itv)->getIndex()] = *itv; bbox += SPoint3(param.x(), param.y(), 0); diff --git a/Mesh/meshGFaceBDS.cpp b/Mesh/meshGFaceBDS.cpp index 91ca345589137714c50e5c750bc063f64267d69b..c85b68460693c6dd05752c0ba10ea20741f234d3 100644 --- a/Mesh/meshGFaceBDS.cpp +++ b/Mesh/meshGFaceBDS.cpp @@ -796,10 +796,10 @@ BDS_Mesh *gmsh2BDS(std::list<GFace*> &l) if (!p[j]) { p[j] = m->add_point(e->getVertex(j)->getNum(), e->getVertex(j)->x(), e->getVertex(j)->y(), e->getVertex(j)->z()); - double u0, v0; - parametricCoordinates(e->getVertex(j), gf, u0, v0); - p[j]->u = u0; - p[j]->v = v0; + SPoint2 param; + reparamMeshVertexOnFace(e->getVertex(j), gf, param); + p[j]->u = param[0]; + p[j]->v = param[1]; m->add_geom(e->getVertex(j)->onWhat()->tag(), e->getVertex(j)->onWhat()->dim()); BDS_GeomEntity *g = m->get_geom(e->getVertex(j)->onWhat()->tag(), diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index 72fdb6c50bac5b646b5a79ff0294fe741132ceca..1287e2ced915e59556d0b7edce0a33f4567e9137 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -98,10 +98,10 @@ void buidMeshGenerationDataStructures(GFace *gf, std::set<MTri3*, compareTri3Ptr it->first->setNum(NUM++); vSizes.push_back(it->second); vSizesBGM.push_back(it->second); - double u0, v0; - parametricCoordinates(it->first, gf, u0, v0); - Us.push_back(u0); - Vs.push_back(v0); + SPoint2 param; + reparamMeshVertexOnFace(it->first, gf, param); + Us.push_back(param[0]); + Vs.push_back(param[1]); } for(unsigned int i = 0; i < gf->triangles.size(); i++){ double lc = 0.3333333333 * (vSizes [gf->triangles[i]->getVertex(0)->getNum()] + @@ -178,7 +178,10 @@ void parametricCoordinates(MTriangle *t, GFace *gf, double u[3], double v[3]) { for (unsigned int j = 0; j < 3; j++){ MVertex *ver = t->getVertex(j); - parametricCoordinates(ver, gf, u[j], v[j]); + SPoint2 param; + reparamMeshVertexOnFace(ver, gf, param); + u[j] = param[0]; + v[j] = param[1]; } }