diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index 72d86b5bb554520471be5b61005a4ac23e426d82..3ec9f9414305d60b0e695e4cfb64ac32a15c4a30 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -1,4 +1,4 @@ -// $Id: BDS.cpp,v 1.74 2007-03-18 12:49:30 geuzaine Exp $ +// $Id: BDS.cpp,v 1.75 2007-04-12 13:09:09 remacle Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -1010,6 +1010,69 @@ bool test_move_point_parametric_triangle (BDS_Point * p, double u, double v, BDS return ori_init*ori_final > 0; } +bool BDS_Mesh::smooth_point_centroid(BDS_Point * p, GFace *gf) +{ + + if (!p->config_modified)return false; + if(p->g && p->g->classif_degree <= 1) + return false; + + std::list < BDS_Edge * >::iterator eit = p->edges.begin(); + while(eit != p->edges.end()) { + if ((*eit)->numfaces() == 1) return false; + eit++; + } + + double U = 0; + double V = 0; + double LC = 0; + + std::list < BDS_Face * >ts; + p->getTriangles(ts); + std::list < BDS_Face * >::iterator it = ts.begin(); + std::list < BDS_Face * >::iterator ite = ts.end(); + + double sTot = 0; + while(it != ite) { + BDS_Face *t = *it; + BDS_Point *n[4]; + t->getNodes(n); + double S = fabs(surface_triangle(n[0],n[1],n[2])); + S = 1; + sTot += S; + U += (n[0]->u + n[1]->u + n[2]->u) *S; + V += (n[0]->v + n[1]->v + n[2]->v) *S; + LC += (n[0]->lc() + n[1]->lc() + n[2]->lc()) *S; + ++it; + } + U /= (3.*sTot); + V /= (3.*sTot); + LC /= (3.*sTot); + + it = ts.begin(); + while(it != ite) { + BDS_Face *t = *it; + if (!test_move_point_parametric_triangle ( p, U, V, t)) + return false; + ++it; + } + + + GPoint gp = gf->point(U*scalingU,V*scalingV); + p->u = U; + p->v = V; + p->lc() = LC; + p->X = gp.x(); + p->Y = gp.y(); + p->Z = gp.z(); + eit = p->edges.begin(); + while(eit != p->edges.end()) { + (*eit)->update(); + ++eit; + } + return true; +} + bool BDS_Mesh::smooth_point_parametric(BDS_Point * p, GFace *gf) { diff --git a/Mesh/BDS.h b/Mesh/BDS.h index 37610de5a8777a6a409b588e48e591a1959cdd15..67f4a6f8ba399794c1b2775b1c8387dce3255add 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -424,6 +424,7 @@ public: void snap_point(BDS_Point* , BDS_Mesh *geom = 0); bool smooth_point(BDS_Point* , BDS_Mesh *geom = 0); bool smooth_point_parametric(BDS_Point * p, GFace *gf); + bool smooth_point_centroid(BDS_Point * p, GFace *gf); bool move_point(BDS_Point *p , double X, double Y, double Z); void split_edge(BDS_Edge *, BDS_Point *); bool edge_constraint ( BDS_Point *p1, BDS_Point *p2 ); diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index fdbbc8e38b3fedf70d55de69c82db9efe891dea6..3464176efa9ee77b776fdbb5d1feed6dddb15018 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFace.cpp,v 1.70 2007-04-12 08:47:25 remacle Exp $ +// $Id: meshGFace.cpp,v 1.71 2007-04-12 13:13:55 remacle Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -266,7 +266,7 @@ void OptimizeMesh(GFace *gf, BDS_Mesh &m, const int NIT) if(m.collapse_edge_parametric ( (*ite), (*itp)))break; } else - m.smooth_point_parametric(*itp,gf); + m.smooth_point_centroid(*itp,gf); ++itp; } } @@ -487,7 +487,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT) while (itp != m.points.end()) { - if(m.smooth_point_parametric(*itp,gf)) + if(m.smooth_point_centroid(*itp,gf)) nb_smooth ++; ++itp; }