From adc6d4d8d66e0e74de9005c0df9a5a7054d3b056 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 12 Feb 2009 14:23:19 +0000 Subject: [PATCH] tests with jf --- Fltk/colorbarWindow.cpp | 43 ++++++++++------------------------------- Fltk/colorbarWindow.h | 10 ++++++++-- Fltk/graphicWindow.cpp | 2 +- Fltk/messageWindow.cpp | 2 +- Fltk/openglWindow.cpp | 11 +++-------- Geo/Geo.cpp | 13 +++++++++++-- Numeric/GmshMatrix.h | 12 ++++++++++++ Numeric/gmshAssembler.h | 8 ++++---- 8 files changed, 50 insertions(+), 51 deletions(-) diff --git a/Fltk/colorbarWindow.cpp b/Fltk/colorbarWindow.cpp index 715e2221ae..55b9684d10 100644 --- a/Fltk/colorbarWindow.cpp +++ b/Fltk/colorbarWindow.cpp @@ -16,10 +16,6 @@ #define EPS 1.e-10 -// This file defines the colorbarWindow class (subclass of Fl_Window) - -// The constructor - colorbarWindow::colorbarWindow(int x, int y, int w, int h, const char *l) : Fl_Window(x, y, w, h, l) { @@ -33,8 +29,6 @@ colorbarWindow::colorbarWindow(int x, int y, int w, int h, const char *l) minval = maxval = 0.0; } -// Convert window X coordinate to color table index - int colorbarWindow::x_to_index(int x) { int index; @@ -46,8 +40,6 @@ int colorbarWindow::x_to_index(int x) return index; } -// Convert color table index to window X coordinate - int colorbarWindow::index_to_x(int index) { int x; @@ -57,21 +49,6 @@ int colorbarWindow::index_to_x(int index) return x; } -// Convert a color intensity to a window Y coordinate - -int colorbarWindow::intensity_to_y(int intensity) -{ - int y; - y = (int)(wedge_y - intensity * (double)wedge_y / 255.); - if(y < 0) - y = 0; - else if(y >= wedge_y) - y = wedge_y - 1; - return y; -} - -// Convert a window Y coordinate to a color intensity - int colorbarWindow::y_to_intensity(int y) { int intensity; @@ -83,7 +60,16 @@ int colorbarWindow::y_to_intensity(int y) return intensity; } -// Redraw part of the colorbarWindow (between a and b) +int colorbarWindow::intensity_to_y(int intensity) +{ + int y; + y = (int)(wedge_y - intensity * (double)wedge_y / 255.); + if(y < 0) + y = 0; + else if(y >= wedge_y) + y = wedge_y - 1; + return y; +} void colorbarWindow::redraw_range(int a, int b) { @@ -259,9 +245,6 @@ void colorbarWindow::redraw_range(int a, int b) fl_draw("HSV", xx0, yy0 + font_height); } - -// Redraw the marker and the text - void colorbarWindow::redraw_marker() { int x, y0, y1; @@ -291,8 +274,6 @@ void colorbarWindow::redraw_marker() fl_draw(str, 10, label_y); } -// Draw everything - void colorbarWindow::draw() { if(!ct) return; @@ -310,8 +291,6 @@ void colorbarWindow::draw() redraw_marker(); } -// Update - void colorbarWindow::update(const char *name, double min, double max, GmshColorTable *table, bool *changed) { @@ -323,8 +302,6 @@ void colorbarWindow::update(const char *name, double min, double max, redraw(); } -// Handle - int colorbarWindow::handle(int event) { if(!ct) return Fl_Window::handle(event); diff --git a/Fltk/colorbarWindow.h b/Fltk/colorbarWindow.h index ec20b58e7d..5fecddfc43 100644 --- a/Fltk/colorbarWindow.h +++ b/Fltk/colorbarWindow.h @@ -23,16 +23,22 @@ class colorbarWindow : public Fl_Window { GmshColorTable *ct; // pointer to the color table (allocated in the view) bool *viewchanged; // pointer to changed bit in view Fl_Color color_bg; + // convert window X coordinate to color table index int x_to_index(int x); + // convert color table index to window X coordinate int index_to_x(int index); + // convert a window Y coordinate to a color intensity int y_to_intensity(int y); + // convert a color intensity to a window Y coordinate int intensity_to_y(int intensity); + // redraw part of the colorbarWindow (between a and b) void redraw_range(int a, int b); + // redraw the marker and the text void redraw_marker(); - void draw(); - int handle(int); public: colorbarWindow(int x, int y, int w, int h, const char *l=0); + void draw(); + int handle(int); void update(const char *name, double min, double max, GmshColorTable *ct, bool *changed); }; diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index b133724f4e..0b12975e0d 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -193,7 +193,7 @@ void status_options_cb(Fl_Widget *w, void *data) } } -static int stop_anim, view_in_cycle = -1; +static int stop_anim = 0, view_in_cycle = -1; void status_play_manual(int time, int step) { diff --git a/Fltk/messageWindow.cpp b/Fltk/messageWindow.cpp index 75145e617c..0a0c03ae3f 100644 --- a/Fltk/messageWindow.cpp +++ b/Fltk/messageWindow.cpp @@ -31,7 +31,7 @@ static void message_copy_cb(Fl_Widget *w, void *data) for(int i = 1; i <= GUI::instance()->messages->browser->size(); i++) { if(GUI::instance()->messages->browser->selected(i)) { const char *c = GUI::instance()->messages->browser->text(i); - if(c[0] == '@') + if(strlen(c) > 5 && c[0] == '@') buff += std::string(&c[5]); else buff += std::string(c); diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index 81e72e610d..3a563d7445 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -125,16 +125,11 @@ void openglWindow::drawBorder() */ glColor3ub(r, g, b); glLineWidth(1); -#if defined(__APPLE__) - int ww = 1; -#else - int ww = 0; -#endif glBegin(GL_LINE_LOOP); glVertex2d(_ctx->viewport[0], _ctx->viewport[1]); - glVertex2d(_ctx->viewport[2] - ww, _ctx->viewport[1]); - glVertex2d(_ctx->viewport[2] - ww, _ctx->viewport[3] - ww); - glVertex2d(_ctx->viewport[0], _ctx->viewport[3] - ww); + glVertex2d(_ctx->viewport[2], _ctx->viewport[1]); + glVertex2d(_ctx->viewport[2], _ctx->viewport[3]); + glVertex2d(_ctx->viewport[0], _ctx->viewport[3]); glEnd(); } } diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index 31e0fc7c92..e16e6a53e7 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -2904,9 +2904,18 @@ bool ProjectPointOnSurface(Surface *s, Vertex &p, double uv[2]) x(0) = uv[0]; x(1) = uv[1]; PointSurface ps = {&p, s}; - if(newton_fd(projectPS, x, &ps)){ + + double UMIN = 0.; + double UMAX = 1.; + double VMIN = 0.; + double VMAX = 1.; + while(1) { + newton_fd(projectPS, x, &ps); p = InterpolateSurface(s, x(0), x(1), 0, 0); - return true; + if(x(0) >= UMIN && x(0) <= UMAX && x(1) >= VMIN && x(1) <= VMAX) + break; + x(0) = UMIN + (UMAX - UMIN) * ((rand() % 10000) / 10000.); + x(1) = VMIN + (VMAX - VMIN) * ((rand() % 10000) / 10000.); } return false; } diff --git a/Numeric/GmshMatrix.h b/Numeric/GmshMatrix.h index e78be16628..eb2e68c2ea 100644 --- a/Numeric/GmshMatrix.h +++ b/Numeric/GmshMatrix.h @@ -6,6 +6,7 @@ #ifndef _GMSH_MATRIX_H_ #define _GMSH_MATRIX_H_ +#include <stdio.h> #include <math.h> #include "GmshConfig.h" #include "GmshMessage.h" @@ -204,6 +205,17 @@ class gmshMatrix } #endif ; + void print() + { + for(int i = 0; i < size1(); i++){ + for(int j = 0; j < size2(); j++){ + printf(" %12.5e"); + } + printf("\n"); + } + return false; + } + ; }; #endif diff --git a/Numeric/gmshAssembler.h b/Numeric/gmshAssembler.h index 43e664b75f..bad4d5b052 100644 --- a/Numeric/gmshAssembler.h +++ b/Numeric/gmshAssembler.h @@ -17,7 +17,7 @@ struct gmshDofKey{ MVertex *v; int comp; int field; - gmshDofKey (MVertex *V, int iComp , int iField) + gmshDofKey (MVertex *V, int iComp, int iField) : v(V), comp(iComp), field(iField) {} bool operator < (const gmshDofKey& d) const { @@ -107,8 +107,8 @@ class gmshAssembler { } return 0.0; } - void assemble(MVertex *vR , int iCompR, int iFieldR, - MVertex *vC , int iCompC, int iFieldC, scalar val) + void assemble(MVertex *vR, int iCompR, int iFieldR, + MVertex *vC, int iCompC, int iFieldC, scalar val) { if (!lsys->isAllocated()) lsys->allocate(numbering.size()); @@ -155,7 +155,7 @@ class gmshAssembler { } } } - void assemble(MVertex *vR , int iCompR, int iFieldR, scalar val) + void assemble(MVertex *vR, int iCompR, int iFieldR, scalar val) { if (!lsys->isAllocated())lsys->allocate(numbering.size()); std::map<gmshDofKey, int>::iterator -- GitLab