diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index c85f4c0541eb00b3c2b47e774991393591c0705f..23843c7277952f4eb1e6cbc093e13540a01516ef 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -9,7 +9,7 @@ extern Context_T CTX; #if defined(HAVE_FOURIER_MODEL) -//#define HARDCODED +#define HARDCODED uvPlot::uvPlot(int x, int y, int w, int h, const char *l) : Fl_Window(x, y, w, h, l), _dmin(0.), _dmax(0.) @@ -18,23 +18,25 @@ uvPlot::uvPlot(int x, int y, int w, int h, const char *l) ColorTable_Recompute(&_colorTable); } -void uvPlot::set(std::vector<double> &u, std::vector<double> &v, - std::vector<std::complex<double> > &f) +void uvPlot::set(std::vector<double> &u, std::vector<double> &v, + std::vector<double> &dist, std::vector<std::complex<double> > &f) { _u.clear(); _v.clear(); + _dist.clear(); _f.clear(); - if(u.size() == v.size() && u.size() == f.size()){ + if(u.size() == v.size() && u.size() == dist.size() && u.size() == f.size()){ _dmin = 1.e200; _dmax = 0.; for(unsigned int i = 0; i < u.size(); i++){ // only store valid points if(u[i] >= 0. && u[i] <= 1. && v[i] >= 0. && v[i] <= 1.){ _u.push_back(u[i]); _v.push_back(v[i]); + _dist.push_back(dist[i]); _f.push_back(f[i]); - _dmin = std::min(_dmin, f[i].real()); - _dmax = std::max(_dmax, f[i].real()); + _dmin = std::min(_dmin, dist[i]); + _dmax = std::max(_dmax, dist[i]); } } } @@ -70,7 +72,7 @@ void uvPlot::draw() for(unsigned int i = 0; i < _u.size(); i++){ int x = (int)(_u[i] * pw); int y = (int)(_v[i] * ph); - color(_f[i].real()); + color(_dist[i]); fl_rect(x, y, 3, 3); } @@ -91,7 +93,7 @@ void uvPlot::draw() static char min[256], max[256], pts[256]; sprintf(min, "%g", _dmin); sprintf(max, "%g", _dmax); - sprintf(pts, "[%d pts]", _f.size()); + sprintf(pts, "[%d pts]", _u.size()); fl_draw(min, 5, h() - 5); fl_draw(pts, pw / 2 - (int)fl_width(pts) / 2, h() - 5); fl_draw(max, pw - (int)fl_width(max) - 5, h() - 5); @@ -348,7 +350,7 @@ void update_cb(Fl_Widget *w, void *data) p->face->computeGraphicsRep(64, 64); // FIXME: hardcoded for now! // project all selected points and update u,v display - std::vector<double> u, v; + std::vector<double> u, v, dist; std::vector<std::complex<double> > f; std::vector<GEntity*> &ent(e->getEntities()); for(unsigned int i = 0; i < ent.size(); i++){ @@ -357,18 +359,20 @@ void update_cb(Fl_Widget *w, void *data) if(!ve) Msg(GERROR, "Problem in point selection processing"); else{ - double uu, vv, xx, yy, zz; + double uu, vv, p[3], n[3]; ps->OrthoProjectionOnSurface(ve->x(),ve->y(),ve->z(),uu,vv); u.push_back(uu); v.push_back(vv); - ps->F(uu,vv,xx,yy,zz); - double dx = xx - ve->x(), dy= yy - ve->y(), dz = zz - ve->z(); - f.push_back(sqrt(dx * dx + dy * dy + dz * dz)); + ps->F(uu, vv, p[0], p[1], p[2]); + ps->GetUnitNormal(uu, vv, n[0], n[1], n[2]); + double dx = ve->x() - p[0], dy = ve->y() - p[1], dz = ve->z() - p[2]; + dist.push_back(sqrt(dx * dx + dy * dy + dz * dz)); + f.push_back(dx * n[0] + dy * n[1] + dz * n[2]); } } } // loop over elements and do the same thing - e->uv()->set(u, v, f); + e->uv()->set(u, v, dist, f); } Draw(); @@ -463,6 +467,8 @@ void select_cb(Fl_Widget *w, void *data) } if(ib == 'q') { ZeroHighlight(); + ele.clear(); + ent.clear(); break; } update_cb(w, data); @@ -508,9 +514,9 @@ void compute_cb(Fl_Widget *w, void *data) projection *p = e->getCurrentProjection(); if(p){ // get the projection data - std::vector<double> u, v; + std::vector<double> u, v, dist; std::vector<std::complex<double> > f; - e->uv()->get(u, v, f); + e->uv()->get(u, v, dist, f); if(f.empty()) return; // create the Fourier faces (with boundaries) diff --git a/Fltk/GUI_Projection.h b/Fltk/GUI_Projection.h index 216c2f6cbee8d44248ffd8d3063104cd1853c24c..d2b23c637ee336254bbcf7617be93203dea5ce94 100644 --- a/Fltk/GUI_Projection.h +++ b/Fltk/GUI_Projection.h @@ -37,19 +37,19 @@ void action_cb(Fl_Widget *w, void *data); class uvPlot : public Fl_Window { private: - std::vector<double> _u, _v; - std::vector<std::complex<double> > _f; + std::vector<double> _u, _v, _dist; + std::vector<std::complex<double> > _f; // "signed" distance GmshColorTable _colorTable; double _dmin, _dmax; void color(double d); void draw(); public: uvPlot(int x, int y, int w, int h, const char *l=0); - void set(std::vector<double> &u, std::vector<double> &v, + void set(std::vector<double> &u, std::vector<double> &v, std::vector<double> &dist, std::vector<std::complex<double> > &f); - void get(std::vector<double> &u, std::vector<double> &v, + void get(std::vector<double> &u, std::vector<double> &v, std::vector<double> &dist, std::vector<std::complex<double> > &f) - { u = _u; v = _v; f = _f; } + { u = _u; v = _v; dist = _dist; f = _f; } }; class projectionEditor; diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index c3b1f09c1e4c8c39690e6dfe5b28822e1e0d83f5..0bff15a530a0fbc7a8c4ff0aeb791f05e2b5ba0a 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1,4 +1,4 @@ -// $Id: GModel.cpp,v 1.44 2007-08-06 19:52:00 geuzaine Exp $ +// $Id: GModel.cpp,v 1.45 2007-08-06 21:22:58 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -27,15 +27,20 @@ void GModel::destroy() { + std::vector<GFace*> to_keep; + for(riter it = firstRegion(); it != lastRegion(); ++it) delete *it; regions.clear(); for(fiter it = firstFace(); it != lastFace(); ++it){ - // projection faces are persistent and should never be deleted - if((*it)->geomType() != GEntity::ProjectionFace) + // projection faces are persistent + if((*it)->geomType() == GEntity::ProjectionFace) + to_keep.push_back(*it); + else delete *it; } faces.clear(); + faces.insert(to_keep.begin(), to_keep.end()); for(eiter it = firstEdge(); it != lastEdge(); ++it) delete *it; edges.clear();