diff --git a/Common/Context.h b/Common/Context.h index aed74f6e147a558cb833f5c75d8bca420f6b0eb4..c93a0c74e2545f1702e8eb92962adbf72c5bb7ba 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -178,7 +178,7 @@ public : double quality; int quality_type, label_type; double quality_inf, quality_sup, radius_inf, radius_sup; - double scaling_factor, lc_factor, rand_factor,nb_elem_per_rc; + double scaling_factor, lc_factor, rand_factor,nb_elem_per_rc,min_elem_size_fact; int dual, interactive; int light, light_two_side; int format, nbPartitions,nb_smoothing, algo2d, algo3d, order,algo_recombine; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index bf41ca3072c17150a94ccba7e188ea7c83cf7c1d..0f9c36ad6d6cf01b49c0c89494a0b246a760bf21 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -899,6 +899,8 @@ StringXNumber MeshOptions_Number[] = { { F|O, "NbElemsPerRadiusOfCurv" , opt_mesh_nb_elem_per_rc, 5. , "Number of elements per radius of curvature in the remesher" }, + { F|O, "MinimumElementSizeFact" , opt_mesh_min_elem_size_fact, 500. , + "Number of elements per radius of curvature in the remesher" }, { F, "NbHexahedra" , opt_mesh_nb_hexahedra , 0. , "Number of hexahedra in the current mesh (read-only)" }, { F, "NbNodes" , opt_mesh_nb_nodes , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index a83e217bc1949d800e04f63b05595f44c4ee4540..beedd4596372ed74e31684727db7e82bc8313232 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.257 2005-09-21 15:03:46 remacle Exp $ +// $Id: Options.cpp,v 1.258 2005-09-22 15:20:38 remacle Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -4390,6 +4390,17 @@ double opt_mesh_nb_elem_per_rc(OPT_ARGS_NUM) return CTX.mesh.nb_elem_per_rc; } +double opt_mesh_min_elem_size_fact(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.mesh.min_elem_size_fact = (double)val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->swiz_value[3]->value(CTX.mesh.min_elem_size_fact); +#endif + return CTX.mesh.min_elem_size_fact; +} + double opt_mesh_msh_file_version(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 620583e06cedf4857fdcca6341ba119a4bcaa524..5b56b541d59b93efd2a6aea6801e50d61568992f 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -440,6 +440,7 @@ double opt_mesh_format(OPT_ARGS_NUM); double opt_mesh_msh_file_version(OPT_ARGS_NUM); double opt_mesh_nb_smoothing(OPT_ARGS_NUM); double opt_mesh_nb_elem_per_rc(OPT_ARGS_NUM); +double opt_mesh_min_elem_size_fact(OPT_ARGS_NUM); double opt_mesh_nb_partitions(OPT_ARGS_NUM); double opt_mesh_algo2d(OPT_ARGS_NUM); double opt_mesh_recombine_algo(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index a64c2e47bb896e3f4979ce031ca154a282f3c57c..b09f98fe2888781d56048a0d48dd515c079e82d7 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.369 2005-09-21 15:03:46 remacle Exp $ +// $Id: Callbacks.cpp,v 1.370 2005-09-22 15:20:38 remacle Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -1156,6 +1156,7 @@ void mesh_options_ok_cb(CALLBACK_ARGS) opt_mesh_light_two_side(0, GMSH_SET, WID->mesh_butt[18]->value()); opt_mesh_smooth_normals(0, GMSH_SET, WID->mesh_butt[19]->value()); opt_mesh_nb_elem_per_rc(0, GMSH_SET, WID->swiz_value[4]->value()); + opt_mesh_min_elem_size_fact(0, GMSH_SET, WID->swiz_value[3]->value()); opt_mesh_nb_smoothing(0, GMSH_SET, WID->mesh_value[0]->value()); opt_mesh_scaling_factor(0, GMSH_SET, WID->mesh_value[1]->value()); opt_mesh_lc_factor(0, GMSH_SET, WID->mesh_value[2]->value()); diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index 66cc44fd1f3ab69159aeaa310a09950b84ab66b6..cfb9f9f288cbefe03cd7e7028d900083c7614ca8 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -887,6 +887,8 @@ void BDS_Point :: compute_curvature ( ) int compute_curvatures (std::list<BDS_Edge*> &edges) { + const int init_inner = 1; + { std::list<BDS_Edge*>::iterator it = edges.begin(); std::list<BDS_Edge*>::iterator ite = edges.end(); @@ -908,13 +910,14 @@ int compute_curvatures (std::list<BDS_Edge*> &edges) { if ((*it)->faces(0)->g == (*it)->faces(1)->g) { + double l1 = 2*(*it)->faces(0)->inscribed_radius(); + double l2 = 2*(*it)->faces(1)->inscribed_radius(); BDS_Vector N1=(*it)->faces(0)->N(); BDS_Vector N2=(*it)->faces(1)->N(); - BDS_Vector C1=(*it)->faces(0)->cog(); - BDS_Vector C2=(*it)->faces(1)->cog(); BDS_Vector DIFFN = N2-N1; - BDS_Vector DIST = C2-C1; + BDS_Vector DIST = l1+l2; double crv = 1./sqrt((DIFFN*DIFFN)/(DIST*DIST)); + if ((*it)->p1->radius_of_curvature > crv) (*it)->p1->radius_of_curvature = crv; if ((*it)->p2->radius_of_curvature > crv) @@ -1532,7 +1535,7 @@ bool BDS_Mesh :: read_stl ( const char *filename , const double tolerance) delete [] DATA; } fclose (f); - classify ( M_PI ); + // classify ( M_PI ); return true; } @@ -2360,7 +2363,7 @@ int BDS_Mesh :: adapt_mesh ( double l, bool smooth, BDS_Mesh *geom_mesh) SNAP_SUCCESS = 0; SNAP_FAILURE = 0; - BDS_Metric metric ( l , LC/500 , LC, CTX.mesh.nb_elem_per_rc ); + BDS_Metric metric ( l , LC/ CTX.mesh.min_elem_size_fact , LC, CTX.mesh.nb_elem_per_rc ); printf("%g\n",CTX.mesh.nb_elem_per_rc); diff --git a/Mesh/BDS.h b/Mesh/BDS.h index b495245510dc8075bebad650f28a929883f03420..8ef0384566a7da8a70250f5f2411d571279b0aec 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -341,6 +341,14 @@ public: inline double S() const {return surface;} BDS_GeomEntity *g; + inline double inscribed_radius () const + { + double l1 = e1->length(); + double l2 = e2->length(); + double l3 = e3->length(); + return (2 * S() / (l1+l2+l3)); + } + inline BDS_Tet * opposite_tet (BDS_Tet *t) { if (t == t1)return t2;