From 5fe00cd25fdf0002780c841f9aa461d3ab3860bc Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 26 Aug 2006 13:34:46 +0000 Subject: [PATCH] - better computation of bounds for discrete entities - added small widget for light position selection - infrastructure for Fourier models --- Common/Makefile | 5 +- Common/Options.cpp | 20 ++++++-- Fltk/Callbacks.cpp | 43 +++++++++++++--- Fltk/Callbacks.h | 1 + Fltk/GUI.cpp | 25 +++++++--- Fltk/GUI.h | 2 + Fltk/Makefile | 47 ++++++++++-------- Fltk/SpherePosition_Widget.h | 96 ++++++++++++++++++++++++++++++++++++ Geo/GEdge.cpp | 18 ++++--- Geo/GFace.cpp | 17 ++++--- Geo/GRegion.cpp | 17 ++++--- Geo/Makefile | 12 +++-- Geo/fourierModel.h | 52 +++++++++++++++++++ Graphics/Draw.cpp | 9 +++- Parser/Makefile | 10 ++-- Parser/OpenFile.cpp | 11 ++++- Plugin/Makefile | 4 +- configure | 2 +- configure.in | 4 +- 19 files changed, 319 insertions(+), 76 deletions(-) create mode 100644 Fltk/SpherePosition_Widget.h create mode 100644 Geo/fourierModel.h diff --git a/Common/Makefile b/Common/Makefile index 1699c28bb7..4286365aa1 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.107 2006-08-24 15:24:16 geuzaine Exp $ +# $Id: Makefile,v 1.108 2006-08-26 13:34:43 geuzaine Exp $ # # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle # @@ -112,7 +112,8 @@ Options.o: Options.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ ../Mesh/Element.h ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h \ - ../Fltk/Colorbar_Window.h ../Common/GmshUI.h ../Fltk/Popup_Button.h + ../Fltk/Colorbar_Window.h ../Common/GmshUI.h ../Fltk/Popup_Button.h \ + ../Fltk/SpherePosition_Widget.h # 1 "/Users/geuzaine/.gmsh/Common//" CommandLine.o: CommandLine.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ diff --git a/Common/Options.cpp b/Common/Options.cpp index dbb25cc8f7..61a042f253 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.304 2006-08-24 01:14:55 geuzaine Exp $ +// $Id: Options.cpp,v 1.305 2006-08-26 13:34:44 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -3523,8 +3523,12 @@ double opt_general_light00(OPT_ARGS_NUM) if(action & GMSH_SET) CTX.light_position[0][0] = val; #if defined(HAVE_FLTK) - if(WID && (action & GMSH_GUI)) + if(WID && (action & GMSH_GUI)){ WID->gen_value[2]->value(CTX.light_position[0][0]); + WID->gen_sphere->setValue(CTX.light_position[0][0], + CTX.light_position[0][1], + CTX.light_position[0][2]); + } #endif return CTX.light_position[0][0]; } @@ -3534,8 +3538,12 @@ double opt_general_light01(OPT_ARGS_NUM) if(action & GMSH_SET) CTX.light_position[0][1] = val; #if defined(HAVE_FLTK) - if(WID && (action & GMSH_GUI)) + if(WID && (action & GMSH_GUI)){ WID->gen_value[3]->value(CTX.light_position[0][1]); + WID->gen_sphere->setValue(CTX.light_position[0][0], + CTX.light_position[0][1], + CTX.light_position[0][2]); + } #endif return CTX.light_position[0][1]; } @@ -3545,8 +3553,12 @@ double opt_general_light02(OPT_ARGS_NUM) if(action & GMSH_SET) CTX.light_position[0][2] = val; #if defined(HAVE_FLTK) - if(WID && (action & GMSH_GUI)) + if(WID && (action & GMSH_GUI)){ WID->gen_value[4]->value(CTX.light_position[0][2]); + WID->gen_sphere->setValue(CTX.light_position[0][0], + CTX.light_position[0][1], + CTX.light_position[0][2]); + } #endif return CTX.light_position[0][2]; } diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 95f996d319..a12b756755 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.450 2006-08-25 23:52:56 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.451 2006-08-26 13:34:44 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -947,6 +947,41 @@ void general_options_rotation_center_select_cb(CALLBACK_ARGS) Msg(ONSCREEN, ""); } +void general_options_light_cb(CALLBACK_ARGS) +{ + char *name = (char*)data; + double x, y, z; + static double lc = 0.; + + if(lc != CTX.lc){ + lc = CTX.lc; + for(int i = 2; i < 5; i++){ + WID->gen_value[i]->minimum(-5*CTX.lc); + WID->gen_value[i]->maximum(5*CTX.lc); + } + } + + if(!strcmp(name, "x") || !strcmp(name, "y") || !strcmp(name, "z")){ + x = WID->gen_value[2]->value(); + y = WID->gen_value[3]->value(); + z = WID->gen_value[4]->value(); + WID->gen_sphere->setValue(x, y, z); + } + else if(!strcmp(name, "xyz")){ + WID->gen_sphere->getValue(x, y, z); + WID->gen_value[2]->value(x); + WID->gen_value[3]->value(y); + WID->gen_value[4]->value(z); + } + opt_general_shine(0, GMSH_SET, WID->gen_value[1]->value()); + opt_general_shine_exponent(0, GMSH_SET, WID->gen_value[0]->value()); + opt_general_light00(0, GMSH_SET, WID->gen_value[2]->value()); + opt_general_light01(0, GMSH_SET, WID->gen_value[3]->value()); + opt_general_light02(0, GMSH_SET, WID->gen_value[4]->value()); + opt_general_light03(0, GMSH_SET, WID->gen_value[13]->value()); + Draw(); +} + void general_options_ok_cb(CALLBACK_ARGS) { opt_general_axes_auto_position(0, GMSH_SET, WID->gen_butt[0]->value()); @@ -968,12 +1003,6 @@ void general_options_ok_cb(CALLBACK_ARGS) opt_general_draw_bounding_box(0, GMSH_SET, WID->gen_butt[6]->value()); opt_general_polygon_offset_always(0, GMSH_SET, WID->gen_butt[4]->value()); - opt_general_shine(0, GMSH_SET, WID->gen_value[1]->value()); - opt_general_shine_exponent(0, GMSH_SET, WID->gen_value[0]->value()); - opt_general_light00(0, GMSH_SET, WID->gen_value[2]->value()); - opt_general_light01(0, GMSH_SET, WID->gen_value[3]->value()); - opt_general_light02(0, GMSH_SET, WID->gen_value[4]->value()); - opt_general_light03(0, GMSH_SET, WID->gen_value[13]->value()); opt_general_verbosity(0, GMSH_SET, WID->gen_value[5]->value()); opt_general_point_size(0, GMSH_SET, WID->gen_value[6]->value()); opt_general_line_width(0, GMSH_SET, WID->gen_value[7]->value()); diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h index 3f8d04de52..9520226c6c 100644 --- a/Fltk/Callbacks.h +++ b/Fltk/Callbacks.h @@ -86,6 +86,7 @@ void options_ok_cb(CALLBACK_ARGS); void general_options_cb(CALLBACK_ARGS); void general_options_color_scheme_cb(CALLBACK_ARGS); void general_options_rotation_center_select_cb(CALLBACK_ARGS); +void general_options_light_cb(CALLBACK_ARGS); void general_options_ok_cb(CALLBACK_ARGS); void general_arrow_param_cb(CALLBACK_ARGS); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 8544a36d7a..02175b1ca2 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.536 2006-08-24 01:14:56 geuzaine Exp $ +// $Id: GUI.cpp,v 1.537 2006-08-26 13:34:44 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -1972,38 +1972,47 @@ void GUI::create_option_window() o->hide(); gen_value[2] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW/3, BH); - gen_value[2]->minimum(-1); - gen_value[2]->maximum(1); + gen_value[2]->minimum(-1.); + gen_value[2]->maximum(1.); gen_value[2]->step(0.01); + gen_value[2]->callback(general_options_light_cb, (void*)"x"); gen_value[3] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 1 * BH, IW/3, BH); - gen_value[3]->minimum(-1); - gen_value[3]->maximum(1); + gen_value[3]->minimum(-1.); + gen_value[3]->maximum(1.); gen_value[3]->step(0.01); + gen_value[3]->callback(general_options_light_cb, (void*)"y"); gen_value[4] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 1 * BH, IW/3, BH, "Light position"); - gen_value[4]->minimum(-1); - gen_value[4]->maximum(1); + gen_value[4]->minimum(-1.); + gen_value[4]->maximum(1.); gen_value[4]->step(0.01); gen_value[4]->align(FL_ALIGN_RIGHT); + gen_value[4]->callback(general_options_light_cb, (void*)"z"); gen_value[13] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Light position divisor"); gen_value[13]->minimum(0.); - gen_value[13]->maximum(100.); + gen_value[13]->maximum(1.); gen_value[13]->step(0.01); gen_value[13]->align(FL_ALIGN_RIGHT); + gen_value[13]->callback(general_options_light_cb, (void*)"w"); + + gen_sphere = new SpherePosition_Widget(L + 2 * WB + 2 * IW, 2 * WB + 1 * BH, 2 * BH); + gen_sphere->callback(general_options_light_cb, (void*)"xyz"); gen_value[1] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Material shininess"); gen_value[1]->minimum(0); gen_value[1]->maximum(10); gen_value[1]->step(0.1); gen_value[1]->align(FL_ALIGN_RIGHT); + gen_value[1]->callback(general_options_light_cb, (void*)"shine"); gen_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Material shininess exponent"); gen_value[0]->minimum(0); gen_value[0]->maximum(128); gen_value[0]->step(1); gen_value[0]->align(FL_ALIGN_RIGHT); + gen_value[0]->callback(general_options_light_cb, (void*)"shine_exponent"); o->end(); } diff --git a/Fltk/GUI.h b/Fltk/GUI.h index a500418801..f525b0cfa8 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -59,6 +59,7 @@ #include "Opengl_Window.h" #include "Colorbar_Window.h" #include "Popup_Button.h" +#include "SpherePosition_Widget.h" // The dynamic contexts @@ -169,6 +170,7 @@ public: Fl_Button *gen_col[50]; Fl_Input *gen_input[20]; Fl_Choice *gen_choice[20]; + SpherePosition_Widget *gen_sphere; // geometry options Fl_Group *geo_group; diff --git a/Fltk/Makefile b/Fltk/Makefile index 2d9eebaf65..d682e50da6 100644 --- a/Fltk/Makefile +++ b/Fltk/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.103 2006-08-24 15:24:16 geuzaine Exp $ +# $Id: Makefile,v 1.104 2006-08-26 13:34:46 geuzaine Exp $ # # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle # @@ -73,11 +73,11 @@ Main.o: Main.cpp GUI.h Opengl_Window.h ../Mesh/Mesh.h \ ../Mesh/Simplex.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h \ ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h \ Colorbar_Window.h ../Common/GmshUI.h ../Common/ColorTable.h \ - Popup_Button.h ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ - ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h ../Geo/Geo.h \ - ../Parser/CreateFile.h ../Graphics/Draw.h ../Common/Views.h \ - ../Common/ColorTable.h ../Common/VertexArray.h \ - ../Common/SmoothNormals.h ../Numeric/Numeric.h \ + Popup_Button.h SpherePosition_Widget.h ../Common/Gmsh.h \ + ../Common/Message.h ../DataStr/Malloc.h ../DataStr/Tools.h \ + ../DataStr/List.h ../DataStr/Tree.h ../Geo/Geo.h ../Parser/CreateFile.h \ + ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h \ + ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \ ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h \ ../Common/Options.h ../Parser/Parser.h ../Parser/OpenFile.h \ ../Common/CommandLine.h Solvers.h ../Plugin/PluginManager.h \ @@ -103,7 +103,8 @@ Message.o: Message.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \ - ../Common/ColorTable.h Popup_Button.h GUI_Extras.h ../Common/OS.h + ../Common/ColorTable.h Popup_Button.h SpherePosition_Widget.h \ + GUI_Extras.h ../Common/OS.h # 1 "/Users/geuzaine/.gmsh/Fltk//" GUI.o: GUI.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ @@ -118,9 +119,9 @@ GUI.o: GUI.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \ - Popup_Button.h Callbacks.h Bitmaps.h Win32Icon.h ../Parser/OpenFile.h \ - ../Common/CommandLine.h Solvers.h ../Plugin/PluginManager.h \ - ../Plugin/Plugin.h Shortcut_Window.h + Popup_Button.h SpherePosition_Widget.h Callbacks.h Bitmaps.h \ + Win32Icon.h ../Parser/OpenFile.h ../Common/CommandLine.h Solvers.h \ + ../Plugin/PluginManager.h ../Plugin/Plugin.h Shortcut_Window.h # 1 "/Users/geuzaine/.gmsh/Fltk//" GUI_Extras.o: GUI_Extras.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ @@ -161,11 +162,12 @@ Callbacks.o: Callbacks.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \ ../Geo/GEntity.h ../Geo/MElement.h ../Parser/CreateFile.h \ ../Parser/OpenFile.h ../Common/CommandLine.h ../Common/Options.h GUI.h \ - Opengl_Window.h Colorbar_Window.h Popup_Button.h GUI_Extras.h \ - Callbacks.h ../Plugin/Plugin.h ../Plugin/PluginManager.h \ - ../Plugin/Plugin.h ../Common/Visibility.h ../Common/GmshDefines.h \ - Solvers.h ../Common/OS.h ../Geo/GModel.h ../Geo/GVertex.h \ - ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h ../Geo/SBoundingBox3d.h + Opengl_Window.h Colorbar_Window.h Popup_Button.h \ + SpherePosition_Widget.h GUI_Extras.h Callbacks.h ../Plugin/Plugin.h \ + ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Visibility.h \ + ../Common/GmshDefines.h Solvers.h ../Common/OS.h ../Geo/GModel.h \ + ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h \ + ../Geo/SBoundingBox3d.h # 1 "/Users/geuzaine/.gmsh/Fltk//" Opengl.o: Opengl.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ @@ -189,7 +191,8 @@ Opengl.o: Opengl.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \ ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \ ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \ - ../Mesh/Matrix.h Colorbar_Window.h Popup_Button.h ../Graphics/gl2ps.h + ../Mesh/Matrix.h Colorbar_Window.h Popup_Button.h \ + SpherePosition_Widget.h ../Graphics/gl2ps.h # 1 "/Users/geuzaine/.gmsh/Fltk//" Opengl_Window.o: Opengl_Window.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ @@ -213,7 +216,8 @@ Opengl_Window.o: Opengl_Window.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \ ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \ ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \ - ../Mesh/Matrix.h Colorbar_Window.h Popup_Button.h + ../Mesh/Matrix.h Colorbar_Window.h Popup_Button.h \ + SpherePosition_Widget.h # 1 "/Users/geuzaine/.gmsh/Fltk//" Colorbar_Window.o: Colorbar_Window.cpp ../Common/Gmsh.h \ ../Common/Message.h ../DataStr/Malloc.h ../DataStr/List.h \ @@ -225,7 +229,8 @@ Colorbar_Window.o: Colorbar_Window.cpp ../Common/Gmsh.h \ ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \ - ../Common/ColorTable.h Popup_Button.h ../Common/Context.h + ../Common/ColorTable.h Popup_Button.h SpherePosition_Widget.h \ + ../Common/Context.h # 1 "/Users/geuzaine/.gmsh/Fltk//" Popup_Button.o: Popup_Button.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ @@ -242,7 +247,7 @@ Solvers.o: Solvers.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \ - ../Common/ColorTable.h Popup_Button.h ../Graphics/Draw.h \ - ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \ - ../Common/SmoothNormals.h ../Numeric/Numeric.h \ + ../Common/ColorTable.h Popup_Button.h SpherePosition_Widget.h \ + ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h \ + ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \ ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h diff --git a/Fltk/SpherePosition_Widget.h b/Fltk/SpherePosition_Widget.h new file mode 100644 index 0000000000..5c35d3cfba --- /dev/null +++ b/Fltk/SpherePosition_Widget.h @@ -0,0 +1,96 @@ +#ifndef _SPHERE_POSITION_WIDGET_H_ +#define _SPHERE_POSITION_WIDGET_H_ + +// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to <gmsh@geuz.org>. + +#include <FL/Fl_Widget.H> + +// A small 2D widget to set the coordinates of a point on the unit +// sphere. +class SpherePosition_Widget : public Fl_Widget { + private: + double _x, _y, _z; + void draw() + { + draw_box(box(), color()); + int x1 = x() + 3; + int y1 = y() + 3; + int w1 = w() - 6; + int h1 = h() - 6; + fl_color(FL_FOREGROUND_COLOR); + fl_arc(x1, y1, w1, h1, 0, 360); + int x = int(x1 + 0.5 * w1 * (1 + _x)); + int y = int(y1 + 0.5 * h1 * (1 - _y)); + draw_box(FL_UP_BOX, x - 3, y - 3, 6, 6, FL_FOREGROUND_COLOR); + } + int handle(int event) + { + switch (event) { + case FL_PUSH: + case FL_DRAG: + case FL_RELEASE: + { + int x1 = x() + Fl::box_dx(box()); + int y1 = y() + Fl::box_dy(box()); + int w1 = w() - Fl::box_dw(box()); + int h1 = h() - Fl::box_dh(box()); + double xx = (Fl::event_x() - x1) / (0.5 * w1) - 1.; + double yy = -((Fl::event_y() - y1) / (0.5 * h1) - 1.); + if(xx != _x || yy != _y) { + double norm = sqrt(xx * xx + yy * yy); + if(norm > 1.){ + xx /= norm; + yy /= norm; + norm = 1.; + } + _x = xx; _y = yy; _z = sqrt(1. - norm); + set_changed(); + redraw(); + do_callback(); + } + } + return 1; + default: + return 0; + } + } + +public: + SpherePosition_Widget(int x,int y,int w, const char *l=0) + : Fl_Widget(x, y, w, w, l), _x(0.), _y(0.), _z(0.) + { + box(FL_FLAT_BOX); + align(FL_ALIGN_BOTTOM); + } + void getValue(double &x, double &y, double &z) const { x = _x; y = _y; z = _z; } + void setValue(double x, double y, double z) + { + double norm = sqrt(x * x + y * y + z * z); + if(norm){ + _x = x / norm; _y = y / norm; _z = z / norm; + } + else{ + _x = _y = _z = 0.; + } + redraw(); + } +}; + +#endif diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index c6af68835e..6f4af768da 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -1,4 +1,4 @@ -// $Id: GEdge.cpp,v 1.13 2006-08-18 02:22:40 geuzaine Exp $ +// $Id: GEdge.cpp,v 1.14 2006-08-26 13:34:46 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -63,11 +63,17 @@ SBoundingBox3d GEdge::bounds() const { Range<double> tr = parBounds(0); SBoundingBox3d bbox; - const int N = 10; - for(int i = 0; i < N; i++){ - double t = tr.low() + (double)i/(double)(N - 1) * (tr.high() - tr.low()); - GPoint p = point(t); - bbox += SPoint3(p.x(), p.y(), p.z()); + if(geomType() != DiscreteCurve){ + const int N = 10; + for(int i = 0; i < N; i++){ + double t = tr.low() + (double)i/(double)(N - 1) * (tr.high() - tr.low()); + GPoint p = point(t); + bbox += SPoint3(p.x(), p.y(), p.z()); + } + } + else{ + for(unsigned int i = 0; i < mesh_vertices.size(); i++) + bbox += mesh_vertices[i]->point(); } return bbox; } diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index e9a3cf1cf2..cff8a2dbbf 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -1,4 +1,4 @@ -// $Id: GFace.cpp,v 1.13 2006-08-18 02:22:40 geuzaine Exp $ +// $Id: GFace.cpp,v 1.14 2006-08-26 13:34:46 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -57,12 +57,15 @@ GFace::~GFace () SBoundingBox3d GFace::bounds() const { - std::list<GEdge*>::const_iterator it = l_edges.begin(); - SBoundingBox3d res = (*it)->bounds(); - ++it; - while(it != l_edges.end()){ - res += (*it)->bounds(); - ++it; + SBoundingBox3d res; + if(geomType() != DiscreteSurface){ + std::list<GEdge*>::const_iterator it = l_edges.begin(); + for(; it != l_edges.end(); it++) + res += (*it)->bounds(); + } + else{ + for(unsigned int i = 0; i < mesh_vertices.size(); i++) + res += mesh_vertices[i]->point(); } return res; } diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index c8a2b7dfbd..a5cd03c822 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -1,4 +1,4 @@ -// $Id: GRegion.cpp,v 1.9 2006-08-18 02:22:40 geuzaine Exp $ +// $Id: GRegion.cpp,v 1.10 2006-08-26 13:34:46 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -54,12 +54,15 @@ GRegion::~GRegion () SBoundingBox3d GRegion::bounds() const { - std::list<GFace*>::const_iterator it = l_faces.begin(); - SBoundingBox3d res = (*it)->bounds(); - ++it; - while(it != l_faces.end()){ - res += (*it)->bounds(); - ++it; + SBoundingBox3d res; + if(geomType() != DiscreteVolume){ + std::list<GFace*>::const_iterator it = l_faces.begin(); + for(; it != l_faces.end(); it++) + res += (*it)->bounds(); + } + else{ + for(unsigned int i = 0; i < mesh_vertices.size(); i++) + res += mesh_vertices[i]->point(); } return res; } diff --git a/Geo/Makefile b/Geo/Makefile index da9d22b924..d6538de861 100644 --- a/Geo/Makefile +++ b/Geo/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.98 2006-08-20 14:12:40 geuzaine Exp $ +# $Id: Makefile,v 1.99 2006-08-26 13:34:46 geuzaine Exp $ # # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle # @@ -24,8 +24,7 @@ include ../variables LIB = ../lib/libGmshGeo.a INCLUDE = -I../Common -I../DataStr -I../Geo -I../Mesh -I../Numeric\ - -I../Parser -I../Fltk\ - -I../contrib/NR + -I../Parser -I../Fltk -I../contrib/NR -I../contrib/FourierModel CFLAGS = ${OPTIM} ${FLAGS} ${INCLUDE} SRC = CAD.cpp \ @@ -45,6 +44,7 @@ SRC = CAD.cpp \ gmshEdge.cpp\ gmshFace.cpp\ gmshRegion.cpp\ + fourierModel.cpp\ SVector3.cpp\ SBoundingBox3d.cpp\ ExtractContour.cpp \ @@ -231,6 +231,12 @@ gmshRegion.o: gmshRegion.cpp gmshModel.h GModel.h GVertex.h GEntity.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h gmshRegion.h Geo.h \ ../Mesh/Create.h ../Mesh/Vertex.h ../Mesh/Mesh.h # 1 "/Users/geuzaine/.gmsh/Geo//" +fourierModel.o: fourierModel.cpp fourierModel.h GModel.h GVertex.h \ + GEntity.h Range.h SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h \ + MVertex.h GPoint.h GEdge.h SVector3.h SPoint2.h MElement.h MEdge.h \ + MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \ + GFace.h Pair.h GRegion.h ../Common/SmoothNormals.h ../Common/Message.h +# 1 "/Users/geuzaine/.gmsh/Geo//" SVector3.o: SVector3.cpp SVector3.h SPoint3.h # 1 "/Users/geuzaine/.gmsh/Geo//" SBoundingBox3d.o: SBoundingBox3d.cpp SBoundingBox3d.h SPoint3.h diff --git a/Geo/fourierModel.h b/Geo/fourierModel.h new file mode 100644 index 0000000000..051ee0a6bf --- /dev/null +++ b/Geo/fourierModel.h @@ -0,0 +1,52 @@ +#ifndef _FOURIER_MODEL_H_ +#define _FOURIER_MODEL_H_ + +#include "GModel.h" + +#if defined(HAVE_FOURIER_MODEL) + +class fourierModel : public GModel { + public: + fourierModel(const std::string &name); + virtual ~fourierModel(); +}; + +#include "GFace.h" +#include "Range.h" + +class fourierFace : public GFace { + private: + int _num; + public: + fourierFace(GModel *m, int num); + virtual ~fourierFace(){} + Range<double> parBounds(int i) const; + virtual int paramDegeneracies(int dir, double *par) { return 0; } + + virtual GPoint point(double par1, double par2) const; + virtual GPoint point(const SPoint2 &pt) const; + virtual GPoint closestPoint(const SPoint3 & queryPoint) ; + + virtual int containsPoint(const SPoint3 &pt) const; + virtual int containsParam(const SPoint2 &pt) const; + + virtual SVector3 normal(const SPoint2 ¶m) const; + virtual Pair<SVector3,SVector3> firstDer(const SPoint2 ¶m) const {throw;} + virtual double * nthDerivative(const SPoint2 ¶m, int n, + double *array) const {throw;} + + virtual GEntity::GeomType geomType() const; + virtual int geomDirection() const { return 1; } + + virtual bool continuous(int dim) const { return true; } + virtual bool periodic(int dim) const { return false; } + virtual bool degenerate(int dim) const { return false; } + virtual double period(int dir) const {throw;} + void * getNativePtr() const {throw;} + virtual bool surfPeriodic(int dim) const {throw;} + virtual SPoint2 parFromPoint(const SPoint3 &) const; +}; + +#endif + +#endif diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp index 8e463b71af..c73ca07279 100644 --- a/Graphics/Draw.cpp +++ b/Graphics/Draw.cpp @@ -1,4 +1,4 @@ -// $Id: Draw.cpp,v 1.106 2006-08-20 14:12:40 geuzaine Exp $ +// $Id: Draw.cpp,v 1.107 2006-08-26 13:34:46 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -257,6 +257,11 @@ void InitRenderModel(void) { GLfloat r, g, b; + glPushMatrix(); + glLoadIdentity(); + glScaled(CTX.s[0], CTX.s[1], CTX.s[2]); + glTranslated(CTX.t[0], CTX.t[1], CTX.t[2]); + for(int i = 0; i < 6; i++) { if(CTX.light[i]) { GLfloat position[4] = {(GLfloat)CTX.light_position[i][0], @@ -290,6 +295,8 @@ void InitRenderModel(void) } } + glPopMatrix(); + // ambient and diffuse material colors track glColor automatically glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); diff --git a/Parser/Makefile b/Parser/Makefile index d7c14207f2..34568cf86f 100644 --- a/Parser/Makefile +++ b/Parser/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.101 2006-08-24 15:24:17 geuzaine Exp $ +# $Id: Makefile,v 1.102 2006-08-26 13:34:46 geuzaine Exp $ # # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle # @@ -121,8 +121,9 @@ OpenFile.o: OpenFile.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/MElement.h \ ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \ ../Geo/GEntity.h ../Geo/MElement.h ../Geo/SBoundingBox3d.h \ - ../Common/SmoothNormals.h Parser.h OpenFile.h ../Common/CommandLine.h \ - ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \ + ../Common/SmoothNormals.h ../Geo/fourierModel.h ../Geo/GModel.h \ + Parser.h OpenFile.h ../Common/CommandLine.h ../Common/Views.h \ + ../Common/ColorTable.h ../Common/VertexArray.h \ ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \ ../Common/GmshMatrix.h ../Mesh/Mesh.h ../Mesh/Vertex.h \ ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \ @@ -132,7 +133,8 @@ OpenFile.o: OpenFile.cpp ../Common/Gmsh.h ../Common/Message.h \ ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h ../Graphics/ReadImg.h \ ../Common/OS.h ../Common/GmshUI.h ../Graphics/Draw.h \ ../Graphics/SelectBuffer.h ../Fltk/GUI.h ../Fltk/Opengl_Window.h \ - ../Fltk/Colorbar_Window.h ../Fltk/Popup_Button.h + ../Fltk/Colorbar_Window.h ../Fltk/Popup_Button.h \ + ../Fltk/SpherePosition_Widget.h # 1 "/Users/geuzaine/.gmsh/Parser//" CreateFile.o: CreateFile.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 5a4e69e333..098b3155f2 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.116 2006-08-22 01:58:35 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.117 2006-08-26 13:34:46 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -25,6 +25,7 @@ #include "Gmsh.h" #include "gmshModel.h" +#include "fourierModel.h" #include "Numeric.h" #include "Context.h" #include "Parser.h" @@ -347,6 +348,14 @@ void OpenProblem(char *name) GMODEL->destroy(); +#if defined(HAVE_FOURIER_MODEL) + if(!strcmp(name, "falcon")){ + delete GMODEL; + GMODEL = new fourierModel(name); + SetBoundingBox(); + } +#endif + Init_Mesh(); // Initialize pseudo random mesh generator to the same seed diff --git a/Plugin/Makefile b/Plugin/Makefile index d9aa0b676f..574c3b0a87 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.108 2006-08-24 15:24:17 geuzaine Exp $ +# $Id: Makefile,v 1.109 2006-08-26 13:34:46 geuzaine Exp $ # # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle # @@ -267,7 +267,7 @@ Annotate.o: Annotate.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \ ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \ ../Mesh/Matrix.h ../Fltk/Colorbar_Window.h ../Fltk/Popup_Button.h \ - ../Graphics/Draw.h + ../Fltk/SpherePosition_Widget.h ../Graphics/Draw.h # 1 "/Users/geuzaine/.gmsh/Plugin//" Remove.o: Remove.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ diff --git a/configure b/configure index 97e59b847f..9f4a7dfe2f 100755 --- a/configure +++ b/configure @@ -4154,7 +4154,7 @@ fi if test "x${FOURIER}" = "xyes"; then GMSH_DIRS="${GMSH_DIRS} contrib/FourierModel" - GMSH_LIBS="${GMSH_LIBS} -Lcontrib/FourierModel -lFourierModel" + GMSH_LIBS="${GMSH_LIBS} -lGmshFourierModel" FLAGS="-DHAVE_FOURIER_MODEL ${FLAGS}" fi diff --git a/configure.in b/configure.in index 27eb08485e..3fd2c13f10 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.101 2006-08-24 16:55:28 geuzaine Exp $ +dnl $Id: configure.in,v 1.102 2006-08-26 13:34:43 geuzaine Exp $ dnl dnl Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle dnl @@ -461,7 +461,7 @@ if test "x$enable_contrib" != "xno"; then AC_CHECK_FILE(./contrib/FourierModel/model.cpp, FOURIER="yes", FOURIER="no") if test "x${FOURIER}" = "xyes"; then GMSH_DIRS="${GMSH_DIRS} contrib/FourierModel" - GMSH_LIBS="${GMSH_LIBS} -Lcontrib/FourierModel -lFourierModel" + GMSH_LIBS="${GMSH_LIBS} -lGmshFourierModel" FLAGS="-DHAVE_FOURIER_MODEL ${FLAGS}" fi -- GitLab