diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 567b7ec1512fc6d79cf9eef55a9fe1d719b0dcaf..a6b6dd7511254ead271e4ab80b9bb990e58aaa08 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -41,7 +41,7 @@ int Msg::_commRank = 0; int Msg::_commSize = 1; int Msg::_verbosity = 5; -int Msg::_progressMeterStep = 10; +int Msg::_progressMeterStep = 20; int Msg::_progressMeterCurrent = 0; std::map<std::string, double> Msg::_timers; int Msg::_warningCount = 0; diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index 213199516dcc68abad07a31d5b24b7a79d918f5c..14650d5c8faaf3b4a40126b9b6e25a6fb669a71c 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -548,9 +548,9 @@ end: meanPlane.c * v->z() - meanPlane.d; if(fabs(d) > lc * 1.e-3) { Msg::Debug("Plane surface %d (%gx+%gy+%gz=%g) is not plane!", - tag(), meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d); + tag(), meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d); Msg::Debug("Control point %d = (%g,%g,%g), val=%g", - v->tag(), v->x(), v->y(), v->z(), d); + v->tag(), v->x(), v->y(), v->z(), d); break; } } diff --git a/Graphics/drawAxes.cpp b/Graphics/drawAxes.cpp index eb6be78962a945293f12bfe7e145bcc69df2c9f9..35af73e127a7a309e1a90135cd420ce1a2a69646 100644 --- a/Graphics/drawAxes.cpp +++ b/Graphics/drawAxes.cpp @@ -14,8 +14,8 @@ #include "Numeric.h" #include "gl2ps.h" -static int drawTics(drawContext *ctx, int comp, int n, std::string &format, - std::string &label, double p1[3], double p2[3], +static int drawTics(drawContext *ctx, int comp, int n, std::string &format, + std::string &label, double p1[3], double p2[3], double perp[3], int mikado, double pixelfact) { // draws n tic marks (in direction perp) and labels along the line p1->p2 @@ -43,21 +43,21 @@ static int drawTics(drawContext *ctx, int comp, int n, std::string &format, default: break; } } - + double tmp = 2. * CTX::instance()->glFontSize * pixelfact; if(n * tmp > l) n = 3; if(n * tmp > l) n = 2; - + double step = l / (double)(n - 1); for(int i = 0; i < n; i++){ double d = i * step; double p[3] = {p1[0] + t[0] * d, p1[1] + t[1] * d, p1[2] + t[2] * d}; - double q[3] = {p[0] + perp[0] * w, - p[1] + perp[1] * w, + double q[3] = {p[0] + perp[0] * w, + p[1] + perp[1] * w, p[2] + perp[2] * w}; double r[3] = {p[0] + perp[0] * w * 1.4, - p[1] + perp[1] * w * 1.4, + p[1] + perp[1] * w * 1.4, p[2] + perp[2] * w * 1.4 }; glBegin(GL_LINES); @@ -68,7 +68,7 @@ static int drawTics(drawContext *ctx, int comp, int n, std::string &format, if(i < n-1 && !mikado){ for(int j = 1; j < 10; j++){ double dd = d + j * step/10.; - double pp[3] = {p1[0] + t[0] * dd, + double pp[3] = {p1[0] + t[0] * dd, p1[1] + t[1] * dd, p1[2] + t[2] * dd}; double qq[3] = {pp[0] + perp[0] * w2, @@ -118,23 +118,23 @@ static void drawGridStipple(int n1, int n2, double p1[3], double p2[3], double p glLineStipple(1, 0x1111); gl2psEnable(GL2PS_LINE_STIPPLE); glBegin(GL_LINES); - + for(int i = 1; i < n1 - 1; i++){ double d = (double)i / (double)(n1 - 1) * l1; glVertex3d(p1[0] + t1[0] * d, p1[1] + t1[1] * d, p1[2] + t1[2] * d); - glVertex3d(p1[0] + t1[0] * d + t2[0] * l2, - p1[1] + t1[1] * d + t2[1] * l2, + glVertex3d(p1[0] + t1[0] * d + t2[0] * l2, + p1[1] + t1[1] * d + t2[1] * l2, p1[2] + t1[2] * d + t2[2] * l2); } for(int i = 1; i < n2 - 1; i++){ double d = (double)i/(double)(n2 - 1) * l2; - glVertex3d(p1[0] + t2[0] * d, - p1[1] + t2[1] * d, + glVertex3d(p1[0] + t2[0] * d, + p1[1] + t2[1] * d, p1[2] + t2[2] * d); - glVertex3d(p1[0] + t2[0] * d + t1[0] * l1, - p1[1] + t2[1] * d + t1[1] * l1, + glVertex3d(p1[0] + t2[0] * d + t1[0] * l1, + p1[1] + t2[1] * d + t1[1] * l1, p1[2] + t2[2] * d + t1[2] * l1); } @@ -144,14 +144,14 @@ static void drawGridStipple(int n1, int n2, double p1[3], double p2[3], double p } void drawContext::drawAxis(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax, + double xmax, double ymax, double zmax, int nticks, int mikado) { if(mikado){ nticks = (nticks - 1) * mikado; if(nticks < 1) nticks = 1; - double dd[3] = {(xmax - xmin) / nticks, - (ymax - ymin) / nticks, + double dd[3] = {(xmax - xmin) / nticks, + (ymax - ymin) / nticks, (zmax - zmin) / nticks}; double axe_color[4]; glGetDoublev(GL_CURRENT_COLOR, axe_color); @@ -167,7 +167,7 @@ void drawContext::drawAxis(double xmin, double ymin, double zmin, } else{ glBegin(GL_LINES); - glVertex3d(xmin, ymin, zmin); + glVertex3d(xmin, ymin, zmin); glVertex3d(xmax, ymax, zmax); glEnd(); } @@ -214,12 +214,12 @@ void drawContext::drawAxes(int mode, int tics[3], std::string format[3], double dxm[3] = {0., (ymin != ymax) ? -1. : 0., (zmin != zmax) ? -1. : 0.}; double dym[3] = {(xmin != xmax) ? -1. : 0., 0., (zmin != zmax) ? -1. : 0.}; double dzm[3] = {(xmin != xmax) ? -1. : 0., (ymin != ymax) ? -1. : 0., 0.}; - - int nx = (xmin != xmax) ? + + int nx = (xmin != xmax) ? drawTics(this, 0, tics[0], format[0], label[0], orig, xx, dxm, mikado, pixelfact) : 0; - int ny = (ymin != ymax) ? + int ny = (ymin != ymax) ? drawTics(this, 1, tics[1], format[1], label[1], orig, yy, dym, mikado, pixelfact) : 0; - int nz = (zmin != zmax) ? + int nz = (zmin != zmax) ? drawTics(this, 2, tics[2], format[2], label[2], orig, zz, dzm, mikado, pixelfact) : 0; drawAxis(xmin, ymin, zmin, xmax, ymin, zmin, nx, mikado); @@ -242,7 +242,7 @@ void drawContext::drawAxes(int mode, int tics[3], std::string format[3], drawAxis(xmax, ymin, zmax, xmax, ymax, zmax, ny, mikado); drawAxis(xmax, ymax, zmin, xmax, ymax, zmax, nz, mikado); } - + if(mode > 2){ drawGridStipple(nx, ny, orig, xx, yy); drawGridStipple(ny, nz, orig, yy, zz); @@ -260,7 +260,7 @@ void drawContext::drawAxes(int mode, int tics[3], std::string format[3], } } -void drawContext::drawAxes(int mode, int tics[3], std::string format[3], +void drawContext::drawAxes(int mode, int tics[3], std::string format[3], std::string label[3], SBoundingBox3d &bb, int mikado) { double bbox[6] = {bb.min().x(), bb.max().x(), @@ -278,13 +278,13 @@ void drawContext::drawAxes() break; } } - + if(geometryExists && (CTX::instance()->drawBBox || !CTX::instance()->mesh.draw)) { glColor4ubv((GLubyte *) & CTX::instance()->color.fg); glLineWidth((float)CTX::instance()->lineWidth); - gl2psLineWidth((float)(CTX::instance()->lineWidth * + gl2psLineWidth((float)(CTX::instance()->lineWidth * CTX::instance()->print.epsLineWidthFactor)); - drawBox(CTX::instance()->min[0], CTX::instance()->min[1], CTX::instance()->min[2], + drawBox(CTX::instance()->min[0], CTX::instance()->min[1], CTX::instance()->min[2], CTX::instance()->max[0], CTX::instance()->max[1], CTX::instance()->max[2]); glColor3d(1.,0.,0.); for(int j = 0; j < 6; j++) @@ -292,26 +292,26 @@ void drawContext::drawAxes() drawPlaneInBoundingBox (CTX::instance()->min[0], CTX::instance()->min[1], CTX::instance()->min[2], CTX::instance()->max[0], CTX::instance()->max[1], CTX::instance()->max[2], - CTX::instance()->clipPlane[j][0], CTX::instance()->clipPlane[j][1], + CTX::instance()->clipPlane[j][0], CTX::instance()->clipPlane[j][1], CTX::instance()->clipPlane[j][2], CTX::instance()->clipPlane[j][3]); } if(CTX::instance()->axes){ glColor4ubv((GLubyte *) & CTX::instance()->color.axes); glLineWidth((float)CTX::instance()->lineWidth); - gl2psLineWidth((float)(CTX::instance()->lineWidth * + gl2psLineWidth((float)(CTX::instance()->lineWidth * CTX::instance()->print.epsLineWidthFactor)); if(!CTX::instance()->axesAutoPosition){ - drawAxes(CTX::instance()->axes, CTX::instance()->axesTics, - CTX::instance()->axesFormat, CTX::instance()->axesLabel, + drawAxes(CTX::instance()->axes, CTX::instance()->axesTics, + CTX::instance()->axesFormat, CTX::instance()->axesLabel, CTX::instance()->axesPosition, CTX::instance()->axesMikado); } else if(geometryExists){ - double bb[6] = - {CTX::instance()->min[0], CTX::instance()->max[0], CTX::instance()->min[1], + double bb[6] = + {CTX::instance()->min[0], CTX::instance()->max[0], CTX::instance()->min[1], CTX::instance()->max[1], CTX::instance()->min[2], CTX::instance()->max[2]}; - drawAxes(CTX::instance()->axes, CTX::instance()->axesTics, - CTX::instance()->axesFormat, CTX::instance()->axesLabel, + drawAxes(CTX::instance()->axes, CTX::instance()->axesTics, + CTX::instance()->axesFormat, CTX::instance()->axesLabel, bb, CTX::instance()->axesMikado); } } @@ -345,7 +345,7 @@ void drawContext::drawSmallAxes() glLoadIdentity(); gluLookAt(camera.position.x,camera.position.y,camera.position.z, camera.target.x,camera.target.y,camera.target.z, - camera.up.x,camera.up.y,camera.up.z); + camera.up.x,camera.up.y,camera.up.z); glPushMatrix(); glPopMatrix(); float fvViewMatrix[16]; @@ -367,7 +367,7 @@ void drawContext::drawSmallAxes() zy = l * rot[9]; } glLineWidth((float)CTX::instance()->lineWidth); - gl2psLineWidth((float)(CTX::instance()->lineWidth * + gl2psLineWidth((float)(CTX::instance()->lineWidth * CTX::instance()->print.epsLineWidthFactor)); glColor4ubv((GLubyte *) & CTX::instance()->color.smallAxes); diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 2e1c38eb8374b5ea7ceaa3eb3e6ebc1faf6e7ccd..c3989ac6d97e847ef11159ac8f8397d1d96b7dc4 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -18,16 +18,16 @@ #include "PViewOptions.h" #include "VertexArray.h" #include "gl2ps.h" - + #if defined(HAVE_FLTK) #include <FL/Fl_JPEG_Image.H> #include <FL/Fl_PNG_Image.H> #include <FL/gl.h> #endif - + drawContextGlobal *drawContext::_global = 0; -drawContext::drawContext(drawTransform *transform) +drawContext::drawContext(drawTransform *transform) : _transform(transform) { // initialize from temp values in global context @@ -51,7 +51,7 @@ drawContext::drawContext(drawTransform *transform) _quadric = 0; // cannot create it here: needs valid opengl context _displayLists = 0; - + } drawContext::~drawContext() @@ -61,9 +61,9 @@ drawContext::~drawContext() } drawContextGlobal *drawContext::global() -{ +{ if(!_global) _global = new drawContextGlobal(); // create dummy default - return _global; + return _global; } void drawContext::createQuadricsAndDisplayLists() @@ -82,31 +82,31 @@ void drawContext::createQuadricsAndDisplayLists() // display list 0 (sphere) glNewList(_displayLists + 0, GL_COMPILE); - gluSphere(_quadric, 1., - CTX::instance()->quadricSubdivisions, + gluSphere(_quadric, 1., + CTX::instance()->quadricSubdivisions, CTX::instance()->quadricSubdivisions); glEndList(); // display list 1 (arrow) glNewList(_displayLists + 1, GL_COMPILE); glTranslated(0., 0., CTX::instance()->arrowRelStemLength); - if(CTX::instance()->arrowRelHeadRadius > 0 && + if(CTX::instance()->arrowRelHeadRadius > 0 && CTX::instance()->arrowRelStemLength < 1) - gluCylinder(_quadric, CTX::instance()->arrowRelHeadRadius, 0., - (1. - CTX::instance()->arrowRelStemLength), + gluCylinder(_quadric, CTX::instance()->arrowRelHeadRadius, 0., + (1. - CTX::instance()->arrowRelStemLength), CTX::instance()->quadricSubdivisions, 1); if(CTX::instance()->arrowRelHeadRadius > CTX::instance()->arrowRelStemRadius) - gluDisk(_quadric, CTX::instance()->arrowRelStemRadius, + gluDisk(_quadric, CTX::instance()->arrowRelStemRadius, CTX::instance()->arrowRelHeadRadius, CTX::instance()->quadricSubdivisions, 1); else - gluDisk(_quadric, CTX::instance()->arrowRelHeadRadius, + gluDisk(_quadric, CTX::instance()->arrowRelHeadRadius, CTX::instance()->arrowRelStemRadius, CTX::instance()->quadricSubdivisions, 1); glTranslated(0., 0., -CTX::instance()->arrowRelStemLength); - if(CTX::instance()->arrowRelStemRadius > 0 && + if(CTX::instance()->arrowRelStemRadius > 0 && CTX::instance()->arrowRelStemLength > 0){ - gluCylinder(_quadric, CTX::instance()->arrowRelStemRadius, + gluCylinder(_quadric, CTX::instance()->arrowRelStemRadius, CTX::instance()->arrowRelStemRadius, CTX::instance()->arrowRelStemLength, CTX::instance()->quadricSubdivisions, 1); @@ -152,7 +152,7 @@ void drawContext::addQuaternion(double p1x, double p1y, double p2x, double p2y) double quat[4]; trackball(quat, p1x, p1y, p2x, p2y); add_quats(quat, quaternion, quaternion); - if (CTX::instance()->camera) camera.rotate(quat); + if (CTX::instance()->camera) camera.rotate(quat); } @@ -161,7 +161,7 @@ void drawContext::addQuaternionFromAxisAndAngle(double axis[3], double angle) double a = angle * M_PI / 180.; double quat[4]; axis_to_quat(axis, a, quat); - add_quats(quat, quaternion, quaternion); + add_quats(quat, quaternion, quaternion); } void drawContext::setQuaternion(double q0, double q1, double q2, double q3) @@ -217,10 +217,10 @@ static int needPolygonOffset() { GModel *m = GModel::current(); if(m->getMeshStatus() == 2 && - (CTX::instance()->mesh.surfacesEdges || CTX::instance()->geom.lines || + (CTX::instance()->mesh.surfacesEdges || CTX::instance()->geom.lines || CTX::instance()->geom.surfaces)) return 1; - if(m->getMeshStatus() == 3 && + if(m->getMeshStatus() == 3 && (CTX::instance()->mesh.surfacesEdges || CTX::instance()->mesh.volumesEdges)) return 1; for(unsigned int i = 0; i < PView::list.size(); i++){ @@ -248,10 +248,10 @@ void drawContext::draw3d() // measurement of the change in depth relative to the screen area of // the polygon, and r is the smallest value that is guaranteed to // produce a resolvable offset for a given implementation. - glPolygonOffset((float)CTX::instance()->polygonOffsetFactor, + glPolygonOffset((float)CTX::instance()->polygonOffsetFactor, (float)CTX::instance()->polygonOffsetUnits); if(CTX::instance()->polygonOffsetFactor || CTX::instance()->polygonOffsetUnits) - CTX::instance()->polygonOffset = CTX::instance()->polygonOffsetAlways ? 1 : + CTX::instance()->polygonOffset = CTX::instance()->polygonOffsetAlways ? 1 : needPolygonOffset(); else CTX::instance()->polygonOffset = 0; @@ -292,11 +292,11 @@ void drawContext::draw2d() glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho((double)viewport[0], (double)viewport[2], - (double)viewport[1], (double)viewport[3], + (double)viewport[1], (double)viewport[3], -100., 100.); // in pixels, so we can draw some 3D glyphs // hack to make the 2D primitives appear "in front" in GL2PS - glTranslated(0., 0., CTX::instance()->clipFactor > 1. ? + glTranslated(0., 0., CTX::instance()->clipFactor > 1. ? 1. / CTX::instance()->clipFactor : CTX::instance()->clipFactor); glMatrixMode(GL_MODELVIEW); @@ -347,7 +347,7 @@ void drawContext::drawBackgroundGradient() int ntheta = 36; for(int i = 1; i < ntheta + 1; i ++){ double theta = i * 2 * M_PI / (double)ntheta; - glVertex2d(cx + r * cos(theta), cy + r * sin(theta)); + glVertex2d(cx + r * cos(theta), cy + r * sin(theta)); } glEnd(); } @@ -409,25 +409,25 @@ void drawContext::drawBackgroundImage() void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) { - double Va = + double Va = (double) (viewport[3] - viewport[1]) / (double) (viewport[2] - viewport[0]); - double Wa = (CTX::instance()->max[1] - CTX::instance()->min[1]) / + double Wa = (CTX::instance()->max[1] - CTX::instance()->min[1]) / (CTX::instance()->max[0] - CTX::instance()->min[0]); // compute the viewport in World coordinates (with margins) if(Va > Wa) { vxmin = CTX::instance()->min[0]; vxmax = CTX::instance()->max[0]; - vymin = 0.5 * (CTX::instance()->min[1] + CTX::instance()->max[1] - + vymin = 0.5 * (CTX::instance()->min[1] + CTX::instance()->max[1] - Va * (CTX::instance()->max[0] - CTX::instance()->min[0])); - vymax = 0.5 * (CTX::instance()->min[1] + CTX::instance()->max[1] + + vymax = 0.5 * (CTX::instance()->min[1] + CTX::instance()->max[1] + Va * (CTX::instance()->max[0] - CTX::instance()->min[0])); } else { - vxmin = 0.5 * (CTX::instance()->min[0] + CTX::instance()->max[0] - + vxmin = 0.5 * (CTX::instance()->min[0] + CTX::instance()->max[0] - (CTX::instance()->max[1] - CTX::instance()->min[1]) / Va); - vxmax = 0.5 * (CTX::instance()->min[0] + CTX::instance()->max[0] + + vxmax = 0.5 * (CTX::instance()->min[0] + CTX::instance()->max[0] + (CTX::instance()->max[1] - CTX::instance()->min[1]) / Va); vymin = CTX::instance()->min[1]; vymax = CTX::instance()->max[1]; @@ -460,7 +460,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) glLoadIdentity(); double w = (double)viewport[2]; double h = (double)viewport[3]; - double ratio = w / h; + double ratio = w / h; double dx = 1.5 * tan(camera.radians) * w * ratio; double dy = 1.5 * tan(camera.radians) * w; double dz = -w * 1.25; @@ -474,9 +474,9 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) glEnd(); glPopMatrix(); glEnable(GL_DEPTH_TEST); - } + } else if(!CTX::instance()->camera){ // if not in camera mode - + double clip_near, clip_far; if(CTX::instance()->ortho) { clip_near = -zmax * s[2] * CTX::instance()->clipFactor; @@ -496,7 +496,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) (GLdouble)wpick, (GLdouble)hpick, (GLint *)viewport); // draw background if not in selection mode - if(render_mode != GMSH_SELECT && + if(render_mode != GMSH_SELECT && (CTX::instance()->bgGradient || CTX::instance()->bgImageFileName.size()) && (!CTX::instance()->printing || CTX::instance()->print.background)){ glDisable(GL_DEPTH_TEST); @@ -507,7 +507,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) // sure that we draw the background behind the rest of the // scene) glOrtho((double)viewport[0], (double)viewport[2], - (double)viewport[1], (double)viewport[3], + (double)viewport[1], (double)viewport[3], clip_near, clip_far); glTranslated(0., 0., -0.99 * clip_far); drawBackgroundGradient(); @@ -550,7 +550,7 @@ void drawContext::initRenderModel() glLoadIdentity(); glScaled(s[0], s[1], s[2]); glTranslated(t[0], t[1], t[2]); - + for(int i = 0; i < 6; i++) { if(CTX::instance()->light[i]) { GLfloat position[4] = {(GLfloat)CTX::instance()->lightPosition[i][0], @@ -558,7 +558,7 @@ void drawContext::initRenderModel() (GLfloat)CTX::instance()->lightPosition[i][2], (GLfloat)CTX::instance()->lightPosition[i][3]}; glLightfv((GLenum)(GL_LIGHT0 + i), GL_POSITION, position); - + GLfloat r = (GLfloat)(CTX::instance()->unpackRed (CTX::instance()->color.ambientLight[i]) / 255.); GLfloat g = (GLfloat)(CTX::instance()->unpackGreen @@ -567,7 +567,7 @@ void drawContext::initRenderModel() (CTX::instance()->color.ambientLight[i]) / 255.); GLfloat ambient[4] = {r, g, b, 1.0F}; glLightfv((GLenum)(GL_LIGHT0 + i), GL_AMBIENT, ambient); - + r = (GLfloat)(CTX::instance()->unpackRed (CTX::instance()->color.diffuseLight[i]) / 255.); g = (GLfloat)(CTX::instance()->unpackGreen @@ -576,7 +576,7 @@ void drawContext::initRenderModel() (CTX::instance()->color.diffuseLight[i]) / 255.); GLfloat diffuse[4] = {r, g, b, 1.0F}; glLightfv((GLenum)(GL_LIGHT0 + i), GL_DIFFUSE, diffuse); - + r = (GLfloat)(CTX::instance()->unpackRed (CTX::instance()->color.specularLight[i]) / 255.); g = (GLfloat)(CTX::instance()->unpackGreen @@ -585,31 +585,31 @@ void drawContext::initRenderModel() (CTX::instance()->color.specularLight[i]) / 255.); GLfloat specular[4] = {r, g, b, 1.0F}; glLightfv((GLenum)(GL_LIGHT0 + i), GL_SPECULAR, specular); - + glEnable((GLenum)(GL_LIGHT0 + i)); } else{ glDisable((GLenum)(GL_LIGHT0 + i)); } } - + glPopMatrix(); - + // ambient and diffuse material colors track glColor automatically glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); // "white"-only specular material reflection color - GLfloat spec[4] = {(GLfloat)CTX::instance()->shine, - (GLfloat)CTX::instance()->shine, + GLfloat spec[4] = {(GLfloat)CTX::instance()->shine, + (GLfloat)CTX::instance()->shine, (GLfloat)CTX::instance()->shine, 1.0F}; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); // specular exponent in [0,128] (larger means more "focused" // reflection) - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, (GLfloat)CTX::instance()->shineExponent); - + glShadeModel(GL_SMOOTH); - + // Normalize the normals automatically. We could use the more // efficient glEnable(GL_RESCALE_NORMAL) instead (since we initially // specify unit normals), but GL_RESCALE_NORMAL does only work with @@ -617,7 +617,7 @@ void drawContext::initRenderModel() // myZoom). Note that GL_RESCALE_NORMAL is only available in // GL_VERSION_1_2. glEnable(GL_NORMALIZE); - + // lighting is enabled/disabled for each particular primitive later glDisable(GL_LIGHTING); } @@ -628,20 +628,20 @@ void drawContext::initPosition() glTranslated(t[0], t[1], t[2]); if(CTX::instance()->rotationCenterCg) - glTranslated(CTX::instance()->cg[0], - CTX::instance()->cg[1], + glTranslated(CTX::instance()->cg[0], + CTX::instance()->cg[1], CTX::instance()->cg[2]); else glTranslated(CTX::instance()->rotationCenter[0], CTX::instance()->rotationCenter[1], CTX::instance()->rotationCenter[2]); - + buildRotationMatrix(); glMultMatrixd(rot); if(CTX::instance()->rotationCenterCg) - glTranslated(-CTX::instance()->cg[0], - -CTX::instance()->cg[1], + glTranslated(-CTX::instance()->cg[0], + -CTX::instance()->cg[1], -CTX::instance()->cg[2]); else glTranslated(-CTX::instance()->rotationCenter[0], @@ -677,7 +677,7 @@ void drawContext::unproject(double x, double y, double p[3], double d[3]) Msg::Warning("unproject1 failed"); if(!gluUnProject(x, y, 1.0, model, proj, vp, &x1, &y1, &z1)) Msg::Warning("unproject2 failed"); - + p[0] = x0; p[1] = y0; p[2] = z0; @@ -713,7 +713,7 @@ void drawContext::world2Viewport(double xyz[3], double win[3]) class hit{ public: GLuint type, ient, depth, type2, ient2; - hit(GLuint t, GLuint i, GLuint d, GLuint t2=0, GLuint i2=0) + hit(GLuint t, GLuint i, GLuint d, GLuint t2=0, GLuint i2=0) : type(t), ient(i), depth(d), type2(t2), ient2(i2) {} }; @@ -730,7 +730,7 @@ class hitDepthLessThan{ static MElement *getElement(GEntity *e, int va_type, int index) { switch(va_type){ - case 2: + case 2: if(e->va_lines && index < e->va_lines->getNumElementPointers()) return *e->va_lines->getElementPointerArray(index); break; @@ -743,9 +743,9 @@ static MElement *getElement(GEntity *e, int va_type, int index) } bool drawContext::select(int type, bool multiple, bool mesh, - int x, int y, int w, int h, + int x, int y, int w, int h, std::vector<GVertex*> &vertices, - std::vector<GEdge*> &edges, + std::vector<GEdge*> &edges, std::vector<GFace*> &faces, std::vector<GRegion*> ®ions, std::vector<MElement*> &elements) @@ -760,7 +760,7 @@ bool drawContext::select(int type, bool multiple, bool mesh, // times the maximum number of possible hits GModel *m = GModel::current(); int eles = (mesh && CTX::instance()->pickElements) ? 4 * m->getNumMeshElements() : 0; - int size = 7 * (m->getNumVertices() + m->getNumEdges() + m->getNumFaces() + + int size = 7 * (m->getNumVertices() + m->getNumEdges() + m->getNumFaces() + m->getNumRegions() + eles); if(!size) return false; // the model is empty, don't bother! @@ -799,7 +799,7 @@ bool drawContext::select(int type, bool multiple, bool mesh, for(int i = 0; i < numhits; i++) { // in Gmsh 'names' should always be 0, 2 or 4: // * names == 0 means that there is nothing on the stack - // * if names == 2, the first name is the type of the entity + // * if names == 2, the first name is the type of the entity // (0 for point, 1 for edge, 2 for face or 3 for volume) and // the second is the entity number; // * if names == 4, the first name is the type of the entity, @@ -807,27 +807,27 @@ bool drawContext::select(int type, bool multiple, bool mesh, // of vertex array (2 for line, 3 for triangle, 4 for quad) // and the fourth is the index of the element in the vertex // array - GLuint names = *ptr++; + GLuint names = *ptr++; *ptr++; // mindepth GLuint maxdepth = *ptr++; if(names == 2){ GLuint depth = maxdepth; - GLuint type = *ptr++; + GLuint type = *ptr++; GLuint ient = *ptr++; hits.push_back(hit(type, ient, depth)); } else if(names == 4){ GLuint depth = maxdepth; - GLuint type = *ptr++; + GLuint type = *ptr++; GLuint ient = *ptr++; - GLuint type2 = *ptr++; + GLuint type2 = *ptr++; GLuint ient2 = *ptr++; hits.push_back(hit(type, ient, depth, type2, ient2)); } } delete [] selectionBuffer; - + if(!hits.size()){ // no entities return false; } @@ -910,8 +910,8 @@ bool drawContext::select(int type, bool multiple, bool mesh, } } - if(vertices.size() || edges.size() || faces.size() || - regions.size() || elements.size()) + if(vertices.size() || edges.size() || faces.size() || + regions.size() || elements.size()) return true; return false; } diff --git a/Mesh/DivideAndConquer.cpp b/Mesh/DivideAndConquer.cpp index 12ff281e2a907062ff16048e59d71069c2ca5c47..b10c8fb7d57e1601aee72c45a5ff4bf6abddb177 100644 --- a/Mesh/DivideAndConquer.cpp +++ b/Mesh/DivideAndConquer.cpp @@ -510,7 +510,7 @@ PointNumero *DocRecord::ConvertDlistToArray(DListPeek *dlist, int *n) return ptr; } -// build ready to use voronoi datas +// build ready to use voronoi data void DocRecord::ConvertDListToVoronoiData() { if (_adjacencies){ @@ -519,7 +519,7 @@ void DocRecord::ConvertDListToVoronoiData() delete [] _adjacencies[i].t; delete [] _adjacencies; } - if (_hull)delete [] _hull; + if (_hull) delete [] _hull; _hullSize = CountPointsOnHull (); _hull = new PointNumero[_hullSize]; ConvexHull(); @@ -578,8 +578,8 @@ void DocRecord::makePosView(std::string fileName, GFace *gf) if (!onHull(i)){ GPoint p0(pc[0], pc[1], 0.0); //if (gf) p0 = gf->point(pc[0], pc[1]); - fprintf(f,"SP(%g,%g,%g) {%g};\n",p0.x(),p0.y(),p0.z(),(double)i); - voronoiCell (i,pts); + fprintf(f,"SP(%g,%g,%g){%g};\n",p0.x(), p0.y(), p0.z(), (double)i); + voronoiCell(i, pts); for (unsigned int j = 0; j < pts.size(); j++){ SPoint2 pp1 = pts[j]; SPoint2 pp2 = pts[(j+1)%pts.size()]; @@ -589,13 +589,13 @@ void DocRecord::makePosView(std::string fileName, GFace *gf) // p1 = gf->point(p1.x(), p1.y()); // p2 = gf->point(p2.x(), p2.y()); // } - fprintf(f,"SL(%g,%g,%g,%g,%g,%g) {%g,%g};\n", - p1.x(),p1.y(),p1.z(),p2.x(),p2.y(),p2.z(), - (double)i,(double)i); + fprintf(f,"SL(%g,%g,%g,%g,%g,%g){%g,%g};\n", + p1.x(), p1.y(), p1.z(), p2.x(), p2.y(), p2.z(), + (double)i, (double)i); } } else { - fprintf(f,"SP(%g,%g,%g) {%g};\n",pc[0],pc[1],0.0,-(double)i); + fprintf(f,"SP(%g,%g,%g){%g};\n", pc[0] ,pc[1], 0., -(double)i); } } fprintf(f,"};\n"); @@ -605,7 +605,6 @@ void DocRecord::makePosView(std::string fileName, GFace *gf) void DocRecord::printMedialAxis(Octree *_octree, std::string fileName, GFace *gf, GEdge *ge) { - FILE *f = fopen(fileName.c_str(),"w"); if (_adjacencies){ fprintf(f,"View \"medial axis\" {\n"); @@ -615,13 +614,13 @@ void DocRecord::printMedialAxis(Octree *_octree, std::string fileName, GFace *gf if (!onHull(i)){ GPoint p0(pc[0], pc[1], 0.0); if (gf) p0 = gf->point(pc[0], pc[1]); - fprintf(f,"SP(%g,%g,%g) {%g};\n",p0.x(),p0.y(),p0.z(),(double)i); + fprintf(f,"SP(%g,%g,%g){%g};\n", p0.x(), p0.y(), p0.z(), (double)i); voronoiCell (i,pts); for (unsigned int j = 0; j < pts.size(); j++){ SVector3 pp1(pts[j].x(), pts[j].y(), 0.0); - SVector3 pp2(pts[(j+1)%pts.size()].x(),pts[(j+1)%pts.size()].y(), 0.0); - SVector3 v1(pp1.x()-pc.x(),pp1.y()-pc.y(),0.0); - SVector3 v2(pp2.x()-pc.x(),pp2.y()-pc.y(),0.0); + SVector3 pp2(pts[(j+1) % pts.size()].x(), pts[(j+1) % pts.size()].y(), 0.0); + SVector3 v1(pp1.x()-pc.x(), pp1.y()-pc.y(), 0.0); + SVector3 v2(pp2.x()-pc.x(), pp2.y()-pc.y(), 0.0); GPoint p1(pp1.x(), pp1.y(), 0.0); GPoint p2(pp2.x(), pp2.y(), 0.0); if (gf) { @@ -638,10 +637,10 @@ void DocRecord::printMedialAxis(Octree *_octree, std::string fileName, GFace *gf ge->lines.push_back(new MLine(v0, v1)); ge->mesh_vertices.push_back(v0); ge->mesh_vertices.push_back(v1); - fprintf(f,"SL(%g,%g,%g,%g,%g,%g) {%g,%g};\n", - p1.x(),p1.y(),p1.z(), - p2.x(),p2.y(),p2.z(), - (double)i,(double)i); + fprintf(f,"SL(%g,%g,%g,%g,%g,%g){%g,%g};\n", + p1.x(), p1.y(), p1.z(), + p2.x(), p2.y(), p2.z(), + (double)i, (double)i); } } } @@ -795,7 +794,7 @@ int DocRecord::ConvertDListToTriangles() for(int i = 0; i < n; i++) delete [] striangle[i].t; - delete []striangle; + delete [] striangle; return 1; } @@ -863,7 +862,6 @@ void DocRecord::setPoints(fullMatrix<double> *p) } } - void DocRecord::recur_tag_triangles(int iTriangle, std::set<int>& taggedTriangles, std::map<std::pair<void*, void*>, std::pair<int,int> > &edgesToTriangles) diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp index afbb216a56d9d6abe742ae583e4e34085bfad195..0ed7f546ede8719d4843c1d9a3eb8ff74a7c0ea5 100644 --- a/Mesh/meshGRegion.cpp +++ b/Mesh/meshGRegion.cpp @@ -121,8 +121,8 @@ void printVoronoi(GRegion *gr, std::set<SPoint3> &candidates) if (allTets.size() != 2 ) continue; SPoint3 pc1 = allTets[0]->circumcenter(); SPoint3 pc2 = allTets[1]->circumcenter(); - std::set<SPoint3>::const_iterator it1 = candidates.find(pc1); - std::set<SPoint3>::const_iterator it2 = candidates.find(pc2); + //std::set<SPoint3>::const_iterator it1 = candidates.find(pc1); + //std::set<SPoint3>::const_iterator it2 = candidates.find(pc2); //if( it1 != candidates.end() || it2 != candidates.end()) fprintf(outfile2,"SL(%g,%g,%g,%g,%g,%g) {%g,%g};\n", pc1.x(), pc1.y(), pc1.z(), pc2.x(), pc2.y(), pc2.z(), diff --git a/Post/PView.cpp b/Post/PView.cpp index eed87596aa56e526557465db9512b9c002cca208..2d27798da8d3238f8156c8dee5613cd01b473088 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -288,11 +288,16 @@ PView *PView::getViewByName(const std::string &name, int timeStep, int partition return 0; } -int PView::getViewIndexByName(const std::string &name, int timeStep, int partition) +PView *PView::getViewByFileName(const std::string &name, int timeStep, int partition) { - PView *view = getViewByName(name, timeStep, partition); - if(view) return view->getIndex(); - return -1; + // search views from most recently to least recently added + for(int i = list.size() - 1; i >= 0; i--){ + if(list[i]->getData()->getFileName() == name && + ((timeStep < 0 || !list[i]->getData()->hasTimeStep(timeStep)) || + (partition < 0 || !list[i]->getData()->hasPartition(timeStep, partition)))) + return list[i]; + } + return 0; } PView *PView::getViewByNum(int num, int timeStep, int partition) diff --git a/Post/PView.h b/Post/PView.h index 0c1990bf8ec583282c2f94c2978c6a6f3f494dfb..6addbbebc2f6f75698712680702422f16256e150 100644 --- a/Post/PView.h +++ b/Post/PView.h @@ -101,8 +101,8 @@ class PView{ // return view only if it does *not* contain that partition) static PView *getViewByName(const std::string &name, int timeStep=-1, int partition=-1); - static int getViewIndexByName(const std::string &name, int timeStep=-1, - int partition=-1); + static PView *getViewByFileName(const std::string &name, int timeStep=-1, + int partition=-1); static PView *getViewByNum(int num, int timeStep=-1, int partition=-1); // IO read routines (these are global: they can create multiple