From f118fe15ffb48e956e03c57506fc780267d4d654 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 19 Nov 2008 20:58:26 +0000 Subject: [PATCH] consolidate parametricCoordinates with reparamMeshVertexOnFace --- Geo/MElement.cpp | 4 +-- Geo/MVertex.cpp | 67 ++++++++++-------------------------- Geo/MVertex.h | 1 - Mesh/gmshSmoothHighOrder.cpp | 14 ++++++-- Mesh/meshGFace.cpp | 4 +-- Mesh/meshGFaceBDS.cpp | 8 ++--- Mesh/meshGFaceOptimize.cpp | 13 ++++--- 7 files changed, 46 insertions(+), 65 deletions(-) diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index e4cafe81e3..5d340647af 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 2d7d83cb59..a16d3e84b4 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 12d6373f00..bb90b48963 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 92d46d94c1..6f2ddec5bc 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 73248d70d3..3c448a3f3f 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 91ca345589..c85b684606 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 72fdb6c50b..1287e2ced9 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]; } } -- GitLab