From 3210663cc78aceb1d11c137be1fcb7054d49b6ef Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 11 Dec 2014 10:00:45 +0000 Subject: [PATCH] use same tolerance in mesh extrusion as in geometry ; if this tol is too large, we should introduce another option --- Common/Context.h | 2 ++ Common/DefaultOptions.h | 2 ++ Common/Options.cpp | 7 ++++ Common/Options.h | 1 + Fltk/FlGui.cpp | 2 +- Mesh/QuadTriExtruded2D.cpp | 4 +-- Mesh/QuadTriExtruded3D.cpp | 2 +- Mesh/QuadTriUtils.cpp | 4 +-- Mesh/meshGFaceExtruded.cpp | 2 +- Mesh/meshGRegionExtruded.cpp | 6 ++-- doc/texinfo/opt_fields.texi | 66 ++++++++++++++++++------------------ doc/texinfo/opt_general.texi | 5 +++ 12 files changed, 60 insertions(+), 43 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index f324232b97..9f10362427 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -125,6 +125,8 @@ class CTX { int fileChooserPosition[2], extraPosition[2], extraSize[2]; // use the system menu bar on Mac OS X? int systemMenuBar; + // use high-resolution opengl graphics (retina Macs) + int highResolutionGraphics; // batch mode (-4: lua session, -3: server daemon, -2: check coherence, -1: write // geo, 0: full gfx, 1: 1D mesh, 2: 2D mesh, 3: 3D mesh, 4: adapt // mesh, 5: refine mesh) diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index c24426d919..cbd094473f 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -503,6 +503,8 @@ StringXNumber GeneralOptions_Number[] = { { F|S, "HighOrderToolsPositionY" , opt_general_hot_position1 , 150. , "Vertical position (in pixels) of the upper left corner of the high order " "tools window" }, + { F|O, "HighResolutionGraphics" , opt_general_high_resolution_graphics , 1. , + "Use high-resolution OpenGL graphics (e.g. for Macs with retina displays)" }, { F|O, "InitialModule", opt_general_initial_context, 0. , "Module launched on startup (0=automatic, 1=geometry, 2=mesh, 3=solver, " diff --git a/Common/Options.cpp b/Common/Options.cpp index 62296cb7ea..ff05d8fc63 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -2317,6 +2317,13 @@ double opt_general_hot_position1(OPT_ARGS_NUM) return CTX::instance()->hotPosition[1]; } +double opt_general_high_resolution_graphics(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->highResolutionGraphics = (int)val; + return CTX::instance()->highResolutionGraphics; +} + double opt_general_session_save(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index d6c51a09b0..c75a760aab 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -163,6 +163,7 @@ double opt_general_manip_position0(OPT_ARGS_NUM); double opt_general_manip_position1(OPT_ARGS_NUM); double opt_general_hot_position0(OPT_ARGS_NUM); double opt_general_hot_position1(OPT_ARGS_NUM); +double opt_general_high_resolution_graphics(OPT_ARGS_NUM); double opt_general_session_save(OPT_ARGS_NUM); double opt_general_options_save(OPT_ARGS_NUM); double opt_general_rotation0(OPT_ARGS_NUM); diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index cc80c9f9ab..e24ad18126 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -271,7 +271,7 @@ FlGui::FlGui(int argc, char **argv) // use retina resolution if available #if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) && (FL_PATCH_VERSION >= 4) - Fl::use_high_res_GL(1); + Fl::use_high_res_GL(CTX::instance()-> highResolutionGraphics); #endif // register image formats not in core fltk library (jpeg/png) diff --git a/Mesh/QuadTriExtruded2D.cpp b/Mesh/QuadTriExtruded2D.cpp index 75a704842f..befecbc72b 100644 --- a/Mesh/QuadTriExtruded2D.cpp +++ b/Mesh/QuadTriExtruded2D.cpp @@ -370,7 +370,7 @@ static int MeshQuadToTriTopUnstructured(GFace *from, GFace *to, MVertexRTree &po return 0; // make set of source edge vertices - MVertexRTree pos_src_edge(1.e-12 * CTX::instance()->lc); + MVertexRTree pos_src_edge(CTX::instance()->geom.tolerance * CTX::instance()->lc); QuadToTriInsertFaceEdgeVertices(from, pos_src_edge); // Loop through all the quads and make the triangles with diagonals running @@ -469,7 +469,7 @@ int MeshQuadToTriTopSurface(GFace *from, GFace *to, MVertexRTree &pos) // number. if(!is_addverts){ - MVertexRTree pos_src_edge(1.e-12 * CTX::instance()->lc); + MVertexRTree pos_src_edge(CTX::instance()->geom.tolerance * CTX::instance()->lc); QuadToTriInsertFaceEdgeVertices(from, pos_src_edge); // loop through each element source quadrangle and extrude diff --git a/Mesh/QuadTriExtruded3D.cpp b/Mesh/QuadTriExtruded3D.cpp index 39f4fd3c5c..b81b4b5b49 100644 --- a/Mesh/QuadTriExtruded3D.cpp +++ b/Mesh/QuadTriExtruded3D.cpp @@ -2665,7 +2665,7 @@ static int makeEdgesForElemsWithAllVertsOnBnd(GRegion *gr, bool is_addverts, } // find edge verts of source face - MVertexRTree pos_src_edge(1.e-12 * CTX::instance()->lc); + MVertexRTree pos_src_edge(CTX::instance()->geom.tolerance * CTX::instance()->lc); QuadToTriInsertFaceEdgeVertices(reg_source, pos_src_edge); // while Loop to diagonalize 3-boundary point triangles and 4-boundary point quadrangles: diff --git a/Mesh/QuadTriUtils.cpp b/Mesh/QuadTriUtils.cpp index 055cdd785e..0ddfdd39a3 100644 --- a/Mesh/QuadTriUtils.cpp +++ b/Mesh/QuadTriUtils.cpp @@ -190,7 +190,7 @@ void ReplaceBndQuadsInFace(GFace *face) is_struct = true; GFace *root_face = findRootSourceFaceForFace(face); if(root_face == face){ - MVertexRTree pos_src_edge(1.e-12 * CTX::instance()->lc); + MVertexRTree pos_src_edge(CTX::instance()->geom.tolerance * CTX::instance()->lc); QuadToTriInsertFaceEdgeVertices(face, pos_src_edge); std::vector<MQuadrangle*> quads2; //loop through source quads, if on boundary, delete them @@ -323,7 +323,7 @@ CategorizedSourceElements::CategorizedSourceElements(GRegion *gr) source_face = source_tmp; // get source face boundary verts - MVertexRTree bnd_verts(1.e-12 * CTX::instance()->lc); + MVertexRTree bnd_verts(CTX::instance()->geom.tolerance * CTX::instance()->lc); QuadToTriInsertSourceEdgeVertices(gr, bnd_verts); unsigned int num_tri = source_face->triangles.size(); diff --git a/Mesh/meshGFaceExtruded.cpp b/Mesh/meshGFaceExtruded.cpp index ca73da2850..a7ef562917 100644 --- a/Mesh/meshGFaceExtruded.cpp +++ b/Mesh/meshGFaceExtruded.cpp @@ -249,7 +249,7 @@ int MeshExtrudedSurface(GFace *gf, Msg::Info("Meshing surface %d (extruded)", gf->tag()); // build an rtree with all the vertices on the boundary of the face gf - MVertexRTree pos(1.e-12 * CTX::instance()->lc); + MVertexRTree pos(CTX::instance()->geom.tolerance * CTX::instance()->lc); std::list<GEdge*> edges = gf->edges(); std::list<GEdge*>::iterator it = edges.begin(); while(it != edges.end()){ diff --git a/Mesh/meshGRegionExtruded.cpp b/Mesh/meshGRegionExtruded.cpp index e5317f1adb..64e466f46c 100644 --- a/Mesh/meshGRegionExtruded.cpp +++ b/Mesh/meshGRegionExtruded.cpp @@ -223,7 +223,7 @@ void meshGRegionExtruded::operator() (GRegion *gr) dem(gr); // build an rtree with all the vertices on the boundary of gr - MVertexRTree pos(1.e-12 * CTX::instance()->lc); + MVertexRTree pos(CTX::instance()->geom.tolerance * CTX::instance()->lc); insertAllVertices(gr, pos); // volume is extruded from a surface @@ -434,7 +434,7 @@ int SubdivideExtrudedMesh(GModel *m) // create a vector of quadToTri regions that have NOT been meshed // yet std::vector<GRegion*> regions, regions_quadToTri; - MVertexRTree pos(1.e-12 * CTX::instance()->lc); + MVertexRTree pos(CTX::instance()->geom.tolerance * CTX::instance()->lc); for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){ ExtrudeParams *ep = (*it)->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && @@ -519,7 +519,7 @@ int SubdivideExtrudedMesh(GModel *m) // mesh the region (should already be done in ExtrudeMesh). for(unsigned int i = 0; i < regions_quadToTri.size(); i++){ GRegion *gr = regions_quadToTri[i]; - MVertexRTree pos_local(1.e-12 * CTX::instance()->lc); + MVertexRTree pos_local(CTX::instance()->geom.tolerance * CTX::instance()->lc); insertAllVertices(gr, pos_local); meshQuadToTriRegionAfterGlobalSubdivide(gr, &edges, pos_local); } diff --git a/doc/texinfo/opt_fields.texi b/doc/texinfo/opt_fields.texi index 9bee17cb1e..ba967fd0a7 100644 --- a/doc/texinfo/opt_fields.texi +++ b/doc/texinfo/opt_fields.texi @@ -76,6 +76,39 @@ type: float@* default value: @code{0.5} @end table +@item Ball +The value of this field is VIn inside a spherical ball, VOut outside. The ball is defined by@* +@* + ||dX||^2 < R^2 &&@* + dX = (X - XC)^2 + (Y-YC)^2 + (Z-ZC)^2@* +Options:@* +@table @code +@item Radius +Radius@* +type: float@* +default value: @code{0} +@item VIn +Value inside the ball@* +type: float@* +default value: @code{0} +@item VOut +Value outside the ball@* +type: float@* +default value: @code{0} +@item XCenter +X coordinate of the ball center@* +type: float@* +default value: @code{0} +@item YCenter +Y coordinate of the ball center@* +type: float@* +default value: @code{0} +@item ZCenter +Z coordinate of the ball center@* +type: float@* +default value: @code{0} +@end table + @item BoundaryLayer hwall * ratio^(dist/hwall)@* Options:@* @@ -599,39 +632,6 @@ type: list@* default value: @code{@{@}} @end table -@item Sphere -The value of this field is VIn inside a sphere, VOut outside. The sphere is given by@* -@* - ||dX||^2 < R^2 &&@* - dX = (X - XC)^2 + (Y-YC)^2 + (Z-ZC)^2@* -Options:@* -@table @code -@item Radius -Radius@* -type: float@* -default value: @code{0} -@item VIn -Value inside the sphere@* -type: float@* -default value: @code{0} -@item VOut -Value outside the sphere@* -type: float@* -default value: @code{0} -@item XCenter -X coordinate of the sphere center@* -type: float@* -default value: @code{0} -@item YCenter -Y coordinate of the sphere center@* -type: float@* -default value: @code{0} -@item ZCenter -Z coordinate of the sphere center@* -type: float@* -default value: @code{0} -@end table - @item Structured Linearly interpolate between data provided on a 3D rectangular structured grid.@* @* diff --git a/doc/texinfo/opt_general.texi b/doc/texinfo/opt_general.texi index 8d5c618b14..8316bb26a7 100644 --- a/doc/texinfo/opt_general.texi +++ b/doc/texinfo/opt_general.texi @@ -604,6 +604,11 @@ Vertical position (in pixels) of the upper left corner of the high order tools w Default value: @code{150}@* Saved in: @code{General.SessionFileName} +@item General.HighResolutionGraphics +Use high-resolution OpenGL graphics (e.g. for Macs with retina displays)@* +Default value: @code{1}@* +Saved in: @code{General.OptionsFileName} + @item General.InitialModule Module launched on startup (0=automatic, 1=geometry, 2=mesh, 3=solver, 4=post-processing) @* Default value: @code{0}@* -- GitLab