diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index 1c9e54789ebddd4222106b1d5b678cc29aa650d6..daf6ba6bdc374119d23b662181dd3b07df0fefb4 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -398,16 +398,6 @@ void recur_tag ( BDS_Triangle *t , BDS_GeomEntity *g ) } } -BDS_Vector BDS_Triangle :: N () const -{ - BDS_Point *pts[3]; - getNodes (pts); - double c[3]; - normal_triangle (pts[0],pts[1],pts[2],c); - return BDS_Vector ( c[0], c[1], c[2] ); -} - - void BDS_Mesh :: reverseEngineerCAD ( ) { for (std::set<BDS_GeomEntity*,GeomLessThan>::iterator it = geom.begin(); @@ -1853,6 +1843,9 @@ bool BDS_Mesh ::collapse_edge ( BDS_Edge *e, BDS_Point *p, const double eps) */ +#ifdef _HAVE_ANN +#include <ANN/ANN.h> +#endif void project_point_on_a_list_of_triangles ( BDS_Point *p , const std::list<BDS_Triangle*> &t, @@ -1900,11 +1893,6 @@ void project_point_on_a_list_of_triangles ( BDS_Point *p , Z = ZZ; } -bool BDS_Mesh ::smooth_point_b ( BDS_Point *p ) -{ - throw; -} - bool BDS_Mesh ::smooth_point ( BDS_Point *p , BDS_Mesh *geom_mesh ) { @@ -1949,6 +1937,18 @@ bool BDS_Mesh ::smooth_point ( BDS_Point *p , BDS_Mesh *geom_mesh ) project_point_on_a_list_of_triangles ( p , gg->t, p->X,p->Y,p->Z); } } + + { + std::list<BDS_Triangle *> t; + p->getTriangles (t); + std::list<BDS_Triangle *>::iterator tit = t.begin(); + std::list<BDS_Triangle *>::iterator tite = t.end(); + while (tit!=tite) + { + (*tit)->_update(); + ++tit; + } + } return true; } @@ -1981,8 +1981,8 @@ void BDS_Mesh :: compute_metric_edge_lengths (const BDS_Metric & metric) ++it; } } - - + + { std::list<BDS_Edge*>::iterator it = edges.begin(); std::list<BDS_Edge*>::iterator ite = edges.end(); @@ -2048,7 +2048,7 @@ int BDS_Mesh :: adapt_mesh ( double l, bool smooth, BDS_Mesh *geom_mesh) { int nb_modif = 0; - BDS_Metric metric ( l , LC/200 , LC ); + BDS_Metric metric ( l , LC/100 , LC ); // printf("METRIC %g %g %g\n",LC,metric._min,metric._max); // add initial set of edges in a list diff --git a/Mesh/BDS.h b/Mesh/BDS.h index 33d648913127fdbea150c180282a885882f2fc8e..19231803763d1ddf980b55b0566ff69256694e51 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -16,6 +16,12 @@ class BDS_Triangle; class BDS_Mesh; class BDS_Point; + +void vector_triangle (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]); +void normal_triangle (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]); +double surface_triangle (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3); +double quality_triangle (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3); + class BDS_Metric { public: @@ -290,7 +296,10 @@ public: bool deleted; int status; BDS_Edge *e1,*e2,*e3; - BDS_Vector N() const ; + BDS_Vector NORMAL; + double surface; + inline BDS_Vector N() const {return NORMAL;} + inline double S() const {return surface;} BDS_GeomEntity *g; inline BDS_Vector cog() const @@ -302,6 +311,18 @@ public: (n[0]->Z+n[1]->Z+n[2]->Z)/3.); } + inline void _update () + { + BDS_Point *pts[3]; + getNodes (pts); + double c[3]; + vector_triangle (pts[0],pts[1],pts[2],c); + surface = 0.5 * sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]); + NORMAL.x = 2*c[0]/surface; + NORMAL.y = 2*c[1]/surface; + NORMAL.z = 2*c[2]/surface; + } + inline void getNodes (BDS_Point *n[3]) const { n[0] = e1->commonvertex (e3); @@ -314,6 +335,7 @@ public: e1->addface(this); e2->addface(this); e3->addface(this); + _update(); } }; @@ -467,6 +489,5 @@ class BDS_Mesh bool read_vrml ( const char *filename); void save_gmsh_format (const char *filename); }; -void normal_triangle (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]); void project_point_on_a_list_of_triangles ( BDS_Point *p , const std::list<BDS_Triangle*> &t, double &X, double &Y, double &Z);