diff --git a/Common/Options.cpp b/Common/Options.cpp index 3ec6cd728638487e78b33997d12a1fcc8c854304..d15291eea2242450e8e4d9ed9f842846f0297eea 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -8032,7 +8032,7 @@ double opt_view_tensor_type(OPT_ARGS_NUM) GET_VIEW(0.); if(action & GMSH_SET) { opt->tensorType = (int)val; - if(opt->tensorType > 5 || opt->tensorType < 1) + if(opt->tensorType > 6 || opt->tensorType < 1) opt->tensorType = 1; if(view) view->setChanged(true); } diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 95fe7e88d9da2f6b1cf6a757321bdd393be9a934..296bc96cc3be592b570d8eb537e1d9b829df7433 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -3156,7 +3156,8 @@ optionWindow::optionWindow(int deltaFontSize) {"Maximum eigen value", 0, 0, 0}, {"Minimum eigen value", 0, 0, 0}, {"Eigen vectors", 0, 0, 0}, - {"Ellipse", 0, 0, 0}, + {"Ellipse (2d)", 0, 0, 0}, + {"Ellipsoid", 0, 0, 0}, {0} }; view.choice[4] = new Fl_Choice diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 5389dbd4edf873d60c9519f1af60ac08d411bbf1..d79f3c17c8a7b3dc4165d03655ecb7e6defdbb1c 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -55,7 +55,7 @@ drawContext::drawContext(drawTransform *transform) drawContext::~drawContext() { if(_quadric) gluDeleteQuadric(_quadric); - if(_displayLists) glDeleteLists(_displayLists, 2); + if(_displayLists) glDeleteLists(_displayLists, 3); } drawContextGlobal *drawContext::global() @@ -72,7 +72,7 @@ void drawContext::createQuadricsAndDisplayLists() return; } - if(!_displayLists) _displayLists = glGenLists(2); + if(!_displayLists) _displayLists = glGenLists(3); if(!_displayLists){ Msg::Error("Could not generate display lists"); return; @@ -112,6 +112,11 @@ void drawContext::createQuadricsAndDisplayLists() CTX::instance()->quadricSubdivisions, 1); } glEndList(); + + // display list 2 (disk) + glNewList(_displayLists + 2, GL_COMPILE); + gluDisk(_quadric, 0, 1, CTX::instance()->quadricSubdivisions, 1); + glEndList(); } void drawContext::buildRotationMatrix() diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h index 9170a4789c683a63dfb27c5e52b5062725789848..f72b9f0ccc7a5329cf6ab6963219baeb27b42875 100644 --- a/Graphics/drawContext.h +++ b/Graphics/drawContext.h @@ -201,7 +201,8 @@ class drawContext { void drawStringRight(const std::string &s); void drawString(const std::string &s, double style); void drawSphere(double R, double x, double y, double z, int n1, int n2, int light); - void drawEllipse(double x, double y, double z, float v0[3], float v1[3], float v2[3], int light); + void drawEllipsoid(double x, double y, double z, float v0[3], float v1[3], float v2[3], int light); + void drawEllipse(double x, double y, double z, float v0[3], float v1[3], int light); void drawSphere(double size, double x, double y, double z, int light); void drawCylinder(double width, double *x, double *y, double *z, int light); void drawTaperedCylinder(double width, double val1, double val2, diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp index 53e9fc24b36b2196874f639b299d09cc2f4ec0e5..c27506029de183162bf87e0593fc1643818df324 100644 --- a/Graphics/drawGlyph.cpp +++ b/Graphics/drawGlyph.cpp @@ -128,7 +128,23 @@ void drawContext::drawSphere(double R, double x, double y, double z, glDisable(GL_LIGHTING); } -void drawContext::drawEllipse(double x, double y, double z, float v0[3], float v1[3], float v2[3], int light) +void drawContext::drawEllipse(double x, double y, double z, float v0[3], float v1[3], int light) +{ + if(light) glEnable(GL_LIGHTING); + glPushMatrix(); + GLfloat m[16] = { + v0[0], v0[1], v0[2], .0d, + v1[0], v1[1], v1[2], .0d, + v0[1]*v1[2]-v0[2]*v1[1], v0[2]*v1[0]-v0[0]*v1[2], v0[0]*v1[1]-v0[1]*v1[0], .0d, + x, y, z, 1.d + }; + glMultMatrixf(m); + glCallList(_displayLists + 2); + glPopMatrix(); + glDisable(GL_LIGHTING); +} + +void drawContext::drawEllipsoid(double x, double y, double z, float v0[3], float v1[3], float v2[3], int light) { if(light) glEnable(GL_LIGHTING); glPushMatrix(); diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp index 68f4533e9455b8bf1f4e7a369ec65e779dabcf6d..931a2186a05f52e1ea153c3e4b65ff8c315edaa7 100644 --- a/Graphics/drawPost.cpp +++ b/Graphics/drawPost.cpp @@ -108,7 +108,10 @@ static void drawEllipseArray(drawContext *ctx, PView *p, VertexArray *va) } } glColor4ubv((GLubyte *)va->getColorArray(4 * i)); - ctx->drawEllipse(s[0], s[1], s[2], vv[0], vv[1], vv[2], opt->light); + if (opt->tensorType == PViewOptions::Ellipsoid) + ctx->drawEllipsoid(s[0], s[1], s[2], vv[0], vv[1], vv[2], opt->light); + else + ctx->drawEllipse(s[0], s[1], s[2], vv[0], vv[1], opt->light); } } diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index ee03adbaf365723b51d63cf26cced8d2b4b1736d..c391ad511749fa8b0c1dcbde1c3c854b6ee9e5e5 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -38,7 +38,8 @@ class PViewOptions { MaxEigenValue = 2, MinEigenValue = 3, EigenVectors = 4, - Ellipse = 5 + Ellipse = 5, + Ellipsoid = 6 }; enum GlyphLocation { COG = 1, diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp index 11f14632360bac534ed10c4fe0c1fa8eed8483ef..504beede1ed7de727061fb1cdfdd19b4bd9855a3 100644 --- a/Post/PViewVertexArrays.cpp +++ b/Post/PViewVertexArrays.cpp @@ -959,34 +959,7 @@ static void addTensorElement(PView *p, int iEnt, int iEle, int numNodes, int typ for(int i = 0; i < numNodes; i++) val[i][0] = ComputeVonMises(val[i]); addScalarElement(p, type, xyz, val, pre, numNodes); - } else if (opt->tensorType == PViewOptions::MinEigenValue || opt->tensorType == PViewOptions::MaxEigenValue || opt->tensorType == PViewOptions::EigenVectors) { - for(int i = 0; i < numNodes; i++) { - for (int j = 0; j < 3; j++) { - tensor(j,0) = val [i][0+j*3]; - tensor(j,1) = val [i][1+j*3]; - tensor(j,2) = val [i][2+j*3]; - } - tensor.eig(S, imS, V, rightV, opt->tensorType != PViewOptions::EigenVectors); - if (PViewOptions::MinEigenValue == opt->tensorType) - val[i][0] = S(0); - else if (PViewOptions::MaxEigenValue == opt->tensorType) - val[i][0] = S(2); - else if (PViewOptions::EigenVectors == opt->tensorType) { - for (int j = 0; j < 3; j++) { - vval[j][i][0] = V(j,0)*S(j); - vval[j][i][1] = V(j,1)*S(j); - vval[j][i][2] = V(j,2)*S(j); - } - } - } - if (PViewOptions::EigenVectors == opt->tensorType) { - addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[0], pre); - addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[1], pre); - addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[2], pre); - } else - addScalarElement(p, type, xyz, val, pre, numNodes); - } - else if (opt->tensorType == PViewOptions::Ellipse) { + } else if (opt->tensorType == PViewOptions::Ellipse || opt->tensorType == PViewOptions::Ellipsoid) { if(opt->glyphLocation == PViewOptions::Vertex){ double vval[3][4]= {0,0,0, 0,0,0, 0,0,0, 0,0,0}; for(int i = 0; i < numNodes; i++){ @@ -1031,6 +1004,33 @@ static void addTensorElement(PView *p, int iEnt, int iEle, int numNodes, int typ p->va_ellipses->add(vval[0], vval[1], vval[2], 0, col, 0, false); } } + else { + for(int i = 0; i < numNodes; i++) { + for (int j = 0; j < 3; j++) { + tensor(j,0) = val [i][0+j*3]; + tensor(j,1) = val [i][1+j*3]; + tensor(j,2) = val [i][2+j*3]; + } + tensor.eig(S, imS, V, rightV, opt->tensorType != PViewOptions::EigenVectors); + if (PViewOptions::MinEigenValue == opt->tensorType) + val[i][0] = S(0); + else if (PViewOptions::MaxEigenValue == opt->tensorType) + val[i][0] = S(2); + else if (PViewOptions::EigenVectors == opt->tensorType) { + for (int j = 0; j < 3; j++) { + vval[j][i][0] = V(j,0)*S(j); + vval[j][i][1] = V(j,1)*S(j); + vval[j][i][2] = V(j,2)*S(j); + } + } + } + if (PViewOptions::EigenVectors == opt->tensorType) { + addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[0], pre); + addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[1], pre); + addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[2], pre); + } else + addScalarElement(p, type, xyz, val, pre, numNodes); + } } static void addElementsInArrays(PView *p, bool preprocessNormalsOnly) @@ -1062,7 +1062,7 @@ static void addElementsInArrays(PView *p, bool preprocessNormalsOnly) continue; } if((numComp > 9 && !opt->forceNumComponents) || opt->forceNumComponents > 9){ - if(numCompError != numComp){ + if(numCompError != numComp) { numCompError = numComp; Msg::Error("You should never draw views with > 9 values per node: use"); Msg::Error("'Adapt visualization grid' to view high-order datasets!");