From b04c8a2bfdc713a9b36fd70af53d8826c7e1e0f8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 22 Sep 2007 22:56:37 +0000 Subject: [PATCH] add option to test automatic skin stuff --- Common/DefaultOptions.h | 2 ++ Common/Options.cpp | 12 +++++++++++- Common/Options.h | 1 + Common/VertexArray.cpp | 14 ++++++-------- Common/VertexArray.h | 6 +++--- Graphics/Post.cpp | 15 ++++++++------- Post/PViewOptions.h | 2 +- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 4d33b58a37..018e21bf19 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1217,6 +1217,8 @@ StringXNumber ViewOptions_Number[] = { "Display post-processing quadrangles?" }, { F|O, "DrawScalars" , opt_view_draw_scalars , 1. , "Display scalar values?" }, + { F|O, "DrawSkinOnly" , opt_view_draw_skin_only , 0. , + "Draw only the skin of 3D scalar views?" }, { F|O, "DrawStrings" , opt_view_draw_strings , 1. , "Display post-processing annotation strings?" }, { F|O, "DrawTensors" , opt_view_draw_tensors , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index e30d3d2bd5..cd182443f0 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.359 2007-09-19 14:21:56 geuzaine Exp $ +// $Id: Options.cpp,v 1.360 2007-09-22 22:56:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -6511,6 +6511,16 @@ double opt_view_draw_tensors(OPT_ARGS_NUM) return opt->DrawTensors; } +double opt_view_draw_skin_only(OPT_ARGS_NUM) +{ + GET_VIEW(0.); + if(action & GMSH_SET) { + opt->DrawSkinOnly = (int)val; + if(view) view->setChanged(true); + } + return opt->DrawSkinOnly; +} + double opt_view_scale_type(OPT_ARGS_NUM) { GET_VIEW(0.); diff --git a/Common/Options.h b/Common/Options.h index 793c33033c..63eedc0afe 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -626,6 +626,7 @@ double opt_view_draw_pyramids(OPT_ARGS_NUM); double opt_view_draw_scalars(OPT_ARGS_NUM); double opt_view_draw_vectors(OPT_ARGS_NUM); double opt_view_draw_tensors(OPT_ARGS_NUM); +double opt_view_draw_skin_only(OPT_ARGS_NUM); double opt_view_scale_type(OPT_ARGS_NUM); double opt_view_tensor_type(OPT_ARGS_NUM); double opt_view_range_type(OPT_ARGS_NUM); diff --git a/Common/VertexArray.cpp b/Common/VertexArray.cpp index 198d5b1014..02f0a806b2 100644 --- a/Common/VertexArray.cpp +++ b/Common/VertexArray.cpp @@ -1,4 +1,4 @@ -// $Id: VertexArray.cpp,v 1.26 2007-09-22 20:35:18 geuzaine Exp $ +// $Id: VertexArray.cpp,v 1.27 2007-09-22 22:56:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -63,13 +63,11 @@ void VertexArray::add(float x, float y, float z, float n0, float n1, float n2, if(ele && CTX.pick_elements) _elements.push_back(ele); } -void VertexArray::add(double *x, double *y, double *z, SVector3 *n, - unsigned int *col, MElement *ele, bool unique) +void VertexArray::add(double *x, double *y, double *z, SVector3 *n, + unsigned int *col, MElement *ele, bool unique, bool boundary) { int npe = getNumVerticesPerElement(); - /* - bool boundary = true; if(boundary && npe == 3){ ElementData<3> e(x, y, z, n, col, ele); std::set<ElementData<3>, ElementDataLessThan<3> >::iterator it = _data3.find(e); @@ -79,13 +77,13 @@ void VertexArray::add(double *x, double *y, double *z, SVector3 *n, _data3.erase(it); return; } - */ if(unique){ Barycenter pc(0., 0., 0.); for(int i = 0; i < npe; i++) pc += Barycenter(x[i], y[i], z[i]); - if(_barycenters.find(pc) != _barycenters.end()) return; + if(_barycenters.find(pc) != _barycenters.end()) + return; _barycenters.insert(pc); } @@ -107,7 +105,7 @@ void VertexArray::finalize() } class AlphaElement { -public: + public: AlphaElement(float *vp, char *np, unsigned char *cp) : v(vp), n(np), c(cp) {} float *v; char *n; diff --git a/Common/VertexArray.h b/Common/VertexArray.h index 5406be5804..27a4e21bb9 100644 --- a/Common/VertexArray.h +++ b/Common/VertexArray.h @@ -80,7 +80,7 @@ class ElementDataLessThan{ { SPoint3 p1 = e1.barycenter(); SPoint3 p2 = e2.barycenter(); - float tolerance = CTX.lc * 1.e-6; + float tolerance = CTX.lc * 1.e-12; if(p1.x() - p2.x() > tolerance) return true; if(p1.x() - p2.x() < -tolerance) return false; if(p1.y() - p2.y() > tolerance) return true; @@ -105,7 +105,7 @@ class BarycenterLessThan{ public: bool operator()(const Barycenter &p1, const Barycenter &p2) const { - float tolerance = CTX.lc * 1.e-6; + float tolerance = CTX.lc * 1.e-12; if(p1.x() - p2.x() > tolerance) return true; if(p1.x() - p2.x() < -tolerance) return false; if(p1.y() - p2.y() > tolerance) return true; @@ -148,7 +148,7 @@ class VertexArray{ // element if another one with the same barycenter is not already // present) void add(double *x, double *y, double *z, SVector3 *n, unsigned int *col, - MElement *ele=0, bool unique=true); + MElement *ele=0, bool unique=true, bool boundary=false); // finalize the arrays void finalize(); // sorts the arrays with elements back to front wrt the eye position diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp index 3da062cd13..9cd674b8d6 100644 --- a/Graphics/Post.cpp +++ b/Graphics/Post.cpp @@ -1,4 +1,4 @@ -// $Id: Post.cpp,v 1.137 2007-09-22 20:35:18 geuzaine Exp $ +// $Id: Post.cpp,v 1.138 2007-09-22 22:56:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -399,7 +399,7 @@ void addOutlineTriangle(PView *p, double xyz[NMAX][3], unsigned int color, bool } void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, - int i0=0, int i1=1, int i2=2, bool unique=false) + int i0=0, int i1=1, int i2=2, bool unique=false, bool skin=false) { PViewOptions *opt = p->getOptions(); @@ -436,7 +436,7 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool } col[i] = opt->getColor(v[i], vmin, vmax); } - if(!pre) p->va_triangles->add(x, y, z, n, col, 0, unique); + if(!pre) p->va_triangles->add(x, y, z, n, col, 0, unique, skin); } else{ double x2[10], y2[10], z2[10], v2[10]; @@ -456,7 +456,7 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool } col[i] = opt->getColor(v3[i], vmin, vmax); } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, unique); + if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, unique, skin); } } } @@ -483,7 +483,7 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool else p->normals->get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); } } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, unique); + if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, unique, skin); } } if(vmin == vmax) break; @@ -580,7 +580,8 @@ void addScalarTetrahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], bo opt->IntervalsType == PViewOptions::Discrete){ opt->Boundary--; for(int i = 0; i < 4; i++) - addScalarTriangle(p, xyz, val, pre, it[i][0], it[i][1], it[i][2], true); + addScalarTriangle(p, xyz, val, pre, it[i][0], it[i][1], it[i][2], true, + (opt->Boundary > 0) ? false : opt->DrawSkinOnly); opt->Boundary++; return; } @@ -614,7 +615,7 @@ void addScalarTetrahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], bo else p->normals->get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); } } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, false); + if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, false, false); } } if(vmin == vmax) break; diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index f20731893e..700b93d624 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -85,7 +85,7 @@ class PViewOptions { int DrawPoints, DrawLines, DrawTriangles, DrawQuadrangles; int DrawTetrahedra, DrawHexahedra, DrawPrisms, DrawPyramids; int DrawScalars, DrawVectors, DrawTensors; - int Boundary, PointType, LineType; + int Boundary, PointType, LineType, DrawSkinOnly; double PointSize, LineWidth; GmshColorTable CT; int UseStipple, Stipple[10][2]; -- GitLab