diff --git a/utils/api_demos/mainAntTweakBar.cpp b/utils/api_demos/mainAntTweakBar.cpp index 299c777018c928fced4a7d530e9335e718d1274a..2b248bdada4d5e6b07646b438989503686c56149 100644 --- a/utils/api_demos/mainAntTweakBar.cpp +++ b/utils/api_demos/mainAntTweakBar.cpp @@ -3,6 +3,7 @@ // and libAntTweakBar // +#include <cstring> #if defined(__APPLE__) # include <GLUT/glut.h> #else @@ -31,8 +32,8 @@ class drawContextTw : public drawContextGlobal{ int getStringDescent(){ return 6; } void drawString(const char *str) { - for (int i = 0; i < strlen(str); i++) - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); + for (int i = 0; i < strlen(str); i++) + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); } }; @@ -44,7 +45,7 @@ void display() glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); drawContext::global()->draw(); TwDraw(); - glutSwapBuffers(); + glutSwapBuffers(); glutPostRedisplay(); } @@ -64,7 +65,7 @@ void keyboard(unsigned char key, int x, int y) case '1': GModel::current()->mesh(1); break; case '2': GModel::current()->mesh(2); break; case '3': GModel::current()->mesh(3); break; - case 'f': + case 'f': if(fullScreen){ glutReshapeWindow(oldw, oldh); } else{ oldw = ctx->viewport[2]; oldh = ctx->viewport[3]; glutFullScreen(); } fullScreen = !fullScreen; @@ -75,7 +76,7 @@ void keyboard(unsigned char key, int x, int y) void mouseMotion(int x, int y) { if(TwEventMouseMotionGLUT(x, y)) return; - int w = ctx->viewport[2]; + int w = ctx->viewport[2]; int h = ctx->viewport[3]; mousePosition currPos; @@ -125,7 +126,7 @@ void mousePassiveMotion(int x, int y) else if(faces.size()) ge = faces[0]; else if(regions.size()) ge = regions[0]; MElement *me = elements.size() ? elements[0] : 0; - printf("%s %s\n", ge ? ge->getInfoString().c_str() : "", + printf("%s %s\n", ge ? ge->getInfoString().c_str() : "", me ? me->getInfoString().c_str() : ""); } } @@ -215,7 +216,7 @@ int main(int argc, char **argv) GmshSetOption("View", "IntervalsType", 1.); GmshSetOption("View", "AdaptVisualizationGrid", 1.); GmshSetOption("View", "TargetError", 0.00001); - GmshSetOption("View", "MaxRecursionLevel", 3.); + GmshSetOption("View", "MaxRecursionLevel", 3.); for(int i = 1; i < argc; i++) GmshMergeFile(argv[i]); @@ -244,12 +245,12 @@ int main(int argc, char **argv) TwBar *bar = TwNewBar("Options"); TwDefine("Options size='200 400' color='50 50 50' alpha=128"); { - TwEnumVal axesEV[6] = { {0, "None"}, {1, "Simple axes"}, {2, "Box"}, + TwEnumVal axesEV[6] = { {0, "None"}, {1, "Simple axes"}, {2, "Box"}, {3, "Full grid"}, {4, "Open grid"}, {5, "Ruler"} }; TwType axesType = TwDefineEnum("AxesType", axesEV, 6); - TwAddVarCB(bar, "Axes", axesType, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "Axes", axesType, SetInt32CB, GetInt32CB, (void*)"General.Axes", "group='General' help='Change axes.' "); - TwAddVarCB(bar, "LightDir", TW_TYPE_DIR3D, SetLightDirCB, GetLightDirCB, + TwAddVarCB(bar, "LightDir", TW_TYPE_DIR3D, SetLightDirCB, GetLightDirCB, 0, "group='General' label='Light direction' close help='Change " "light direction.' "); { @@ -264,36 +265,36 @@ int main(int argc, char **argv) TwDefine("Options/General close "); } { - TwAddVarCB(bar, "Points", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "Points", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Geometry.Points", "group='Geometry' help='Draw points.' "); - TwAddVarCB(bar, "Lines", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "Lines", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Geometry.Lines", "group='Geometry' help='Draw lines.' "); TwAddVarCB(bar, "Surfaces", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Geometry.Surfaces", "group='Geometry' help='Draw surfaces.' "); - TwAddVarCB(bar, "Volumes", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "Volumes", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Geometry.Volumes", "group='Geometry' help='Draw volumes.' "); } { - TwAddVarCB(bar, "Vertices", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "Vertices", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Mesh.Points", "group='Mesh' help='Draw mesh vertices.' "); - TwAddVarCB(bar, "MeshLines", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "MeshLines", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Mesh.Lines", "group='Mesh' label='Lines' help='Draw line mesh.' "); - TwAddVarCB(bar, "SurfaceEdges", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "SurfaceEdges", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Mesh.SurfaceEdges", "group='Mesh' label='Surface edges' " "help='Draw surface mesh edges.' "); - TwAddVarCB(bar, "SurfaceFaces", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "SurfaceFaces", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Mesh.SurfaceFaces", "group='Mesh' label='Surface faces' " "help='Draw surface mesh faces.' "); - TwAddVarCB(bar, "VolumeEdges", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "VolumeEdges", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Mesh.VolumeEdges", "group='Mesh' label='Volume edges' " "help='Draw volume mesh edges.' "); - TwAddVarCB(bar, "VolumeFaces", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, + TwAddVarCB(bar, "VolumeFaces", TW_TYPE_BOOL32, SetInt32CB, GetInt32CB, (void*)"Mesh.VolumeFaces", "group='Mesh' label='Volume faces' " "help='Draw volume mesh faces.' "); TwAddVarCB(bar, "Explode", TW_TYPE_DOUBLE, SetDoubleCB, GetDoubleCB, (void*)"Mesh.Explode", "group='Mesh' label='Explode factor' " "min=0 max=1 step=0.01 help='Explode mesh.' "); - TwAddVarCB(bar, "SizeFactor", TW_TYPE_DOUBLE, SetDoubleCB, GetDoubleCB, + TwAddVarCB(bar, "SizeFactor", TW_TYPE_DOUBLE, SetDoubleCB, GetDoubleCB, (void*)"Mesh.CharacteristicLengthFactor", "group='Mesh' " "label='Element size factor' min=0.01 max=100 step=0.01 "); } diff --git a/utils/api_demos/mainCartesian.cpp b/utils/api_demos/mainCartesian.cpp index 0187fb1b2bef87e5ecf6affce6316b08f74292bc..24a103799e3910fcc2d6bc32ff40d9243b8f59c0 100644 --- a/utils/api_demos/mainCartesian.cpp +++ b/utils/api_demos/mainCartesian.cpp @@ -12,8 +12,8 @@ #include "GmshMessage.h" #include "cartesian.h" -void insertActiveCells(double x, double y, double z, double rmax, - cartesianBox<double> &box) +static void insertActiveCells(double x, double y, double z, double rmax, + cartesianBox<double> &box) { int id1 = box.getCellContainingPoint(x - rmax, y - rmax, z - rmax); int id2 = box.getCellContainingPoint(x + rmax, y + rmax, z + rmax); @@ -27,13 +27,13 @@ void insertActiveCells(double x, double y, double z, double rmax, box.insertActiveCell(box.getCellIndex(i, j, k)); } -void computeLevelset(GModel *gm, cartesianBox<double> &box) +static void computeLevelset(GModel *gm, cartesianBox<double> &box) { // tolerance for desambiguation const double tol = box.getLC() * 1.e-12; std::vector<SPoint3> nodes; std::vector<int> indices; - for (cartesianBox<double>::valIter it = box.nodalValuesBegin(); + for (cartesianBox<double>::valIter it = box.nodalValuesBegin(); it != box.nodalValuesEnd(); ++it){ nodes.push_back(box.getNodeCoordinates(it->first)); indices.push_back(it->first); @@ -49,7 +49,7 @@ void computeLevelset(GModel *gm, cartesianBox<double> &box) GPoint p1 = (*fit)->point((*fit)->stl_vertices[i1]); GPoint p2 = (*fit)->point((*fit)->stl_vertices[i2]); GPoint p3 = (*fit)->point((*fit)->stl_vertices[i3]); - SPoint2 p = ((*fit)->stl_vertices[i1] + (*fit)->stl_vertices[i2] + + SPoint2 p = ((*fit)->stl_vertices[i1] + (*fit)->stl_vertices[i2] + (*fit)->stl_vertices[i3]) * 0.33333333; SVector3 N = (*fit)->normal(p); SPoint3 P1(p1.x(), p1.y(), p1.z()); @@ -60,15 +60,15 @@ void computeLevelset(GModel *gm, cartesianBox<double> &box) signedDistancesPointsTriangle(localdist, dummy, nodes, P1, P2, P3); else signedDistancesPointsTriangle(localdist, dummy, nodes, P2, P1, P3); - if(dist.empty()) + if(dist.empty()) dist = localdist; - else{ + else{ for (unsigned int j = 0; j < localdist.size(); j++){ // FIXME: if there is an ambiguity assume we are inside (to // avoid holes in the structure). This is definitely just a // hack, as it could create pockets of matter outside the // structure... - if(dist[j] * localdist[j] < 0 && + if(dist[j] * localdist[j] < 0 && fabs(fabs(dist[j]) - fabs(localdist[j])) < tol){ dist[j] = std::max(dist[j], localdist[j]); } @@ -85,7 +85,7 @@ void computeLevelset(GModel *gm, cartesianBox<double> &box) if(box.getChildBox()) computeLevelset(gm, *box.getChildBox()); } -void fillPointCloud(GEdge *ge, double sampling, std::vector<SPoint3> &points) +static void fillPointCloud(GEdge *ge, double sampling, std::vector<SPoint3> &points) { Range<double> t_bounds = ge->parBounds(0); double t_min = t_bounds.low(); @@ -99,7 +99,7 @@ void fillPointCloud(GEdge *ge, double sampling, std::vector<SPoint3> &points) } } -int removeBadChildCells(cartesianBox<double> *parent) +static int removeBadChildCells(cartesianBox<double> *parent) { cartesianBox<double> *child = parent->getChildBox(); if(!child) return 0; @@ -125,7 +125,7 @@ int removeBadChildCells(cartesianBox<double> *parent) if(exist[ii]) atLeastOne = true; if(!exist[ii]) butNotAll = true; } - if(atLeastOne && + if(atLeastOne && (butNotAll || (i != 0 && !parent->activeCellExists(parent->getCellIndex(i - 1, j, k))) || (i != I - 1 && !parent->activeCellExists(parent->getCellIndex(i + 1, j, k))) || @@ -138,7 +138,7 @@ int removeBadChildCells(cartesianBox<double> *parent) return removeBadChildCells(child); } -void removeParentCellsWithChildren(cartesianBox<double> *box) +static void removeParentCellsWithChildren(cartesianBox<double> *box) { if(!box->getChildBox()) return; for(int i = 0; i < box->getNxi(); i++) @@ -160,11 +160,11 @@ void removeParentCellsWithChildren(cartesianBox<double> *box) removeParentCellsWithChildren(box->getChildBox()); } -void removeOutsideCells(cartesianBox<double> *box) +static void removeOutsideCells(cartesianBox<double> *box) { if(!box) return; int nbErased = 0; - for(cartesianBox<double>::cellIter it = box->activeCellsBegin(); + for(cartesianBox<double>::cellIter it = box->activeCellsBegin(); it != box->activeCellsEnd();){ std::vector<double> vals; box->getNodalValuesForCell(*it, vals); @@ -172,7 +172,7 @@ void removeOutsideCells(cartesianBox<double> *box) double lsmin = *std::min_element(vals.begin(), vals.end()); double change_sign = lsmax * lsmin; double epsilon = 1.e-10; - if(change_sign > 0 && lsmax < -epsilon) { + if(change_sign > 0 && lsmax < -epsilon) { box->eraseActiveCell(*(it++)); nbErased++; } @@ -214,7 +214,7 @@ int main(int argc,char *argv[]) double rtube = std::max(lx, std::max(ly, lz)) * 2.; GModel *gm = GModel::current(); - + std::vector<SPoint3> points; Msg::Info("Filling coarse point cloud on surfaces"); for (GModel::fiter fit = gm->firstFace(); fit != gm->lastFace(); fit++) @@ -238,13 +238,13 @@ int main(int argc,char *argv[]) } SBoundingBox3d bb; - for(unsigned int i = 0; i < points.size(); i++) bb += points[i]; - for(unsigned int i = 0; i < refinePoints.size(); i++) bb += refinePoints[i]; + for(unsigned int i = 0; i < points.size(); i++) bb += points[i]; + for(unsigned int i = 0; i < refinePoints.size(); i++) bb += refinePoints[i]; bb.scale(1.21, 1.21, 1.21); - SVector3 range = bb.max() - bb.min(); - int NX = range.x() / lx; - int NY = range.y() / ly; - int NZ = range.z() / lz; + SVector3 range = bb.max() - bb.min(); + int NX = range.x() / lx; + int NY = range.y() / ly; + int NZ = range.z() / lz; if(NX < 2) NX = 2; if(NY < 2) NY = 2; if(NZ < 2) NZ = 2; @@ -253,8 +253,8 @@ int main(int argc,char *argv[]) bb.min().x(), bb.min().y(), bb.min().z(), bb.max().x(), bb.max().y(), bb.max().z()); Msg::Info(" Nx=%d Ny=%d Nz=%d", NX, NY, NZ); - - cartesianBox<double> box(bb.min().x(), bb.min().y(), bb.min().z(), + + cartesianBox<double> box(bb.min().x(), bb.min().y(), bb.min().z(), SVector3(range.x(), 0, 0), SVector3(0, range.y(), 0), SVector3(0, 0, range.z()), @@ -269,7 +269,7 @@ int main(int argc,char *argv[]) while((child = parent->getChildBox())){ Msg::Info(" level %d", child->getLevel()); for(unsigned int i = 0; i < refinePoints.size(); i++) - insertActiveCells(refinePoints[i].x(), refinePoints[i].y(), refinePoints[i].z(), + insertActiveCells(refinePoints[i].x(), refinePoints[i].y(), refinePoints[i].z(), rtube / pow(2., (levels - child->getLevel())), *child); parent = child; } @@ -287,7 +287,7 @@ int main(int argc,char *argv[]) Msg::Info("Initializing nodal values in the cartesian grid"); box.createNodalValues(); - Msg::Info("Computing levelset on the cartesian grid"); + Msg::Info("Computing levelset on the cartesian grid"); computeLevelset(gm, box); Msg::Info("Removing cells outside the structure"); @@ -295,7 +295,7 @@ int main(int argc,char *argv[]) Msg::Info("Renumbering mesh vertices across levels"); box.renumberNodes(); - + bool decomposeInSimplex = false; box.writeMSH("yeah.msh", decomposeInSimplex); diff --git a/utils/api_demos/mainElasticity.cpp b/utils/api_demos/mainElasticity.cpp index 0f395a61aa87301c24d6ec505d83fa09de5a95ac..802c1feae186585b3b43615a97296b4a6745cc65 100644 --- a/utils/api_demos/mainElasticity.cpp +++ b/utils/api_demos/mainElasticity.cpp @@ -1,3 +1,4 @@ +#include <cstring> #include "Gmsh.h" #include "elasticitySolver.h" #include "PView.h" @@ -16,7 +17,7 @@ void InitializeOnelab(std::string sockName, std::string modelName) { loader->get(ps,"Elasticity/9Compute"); // ?? ps.resize(1); ps[0].setName("Elasticity/9Compute"); - ps[0].setValue("-solve -pos"); + ps[0].setValue("-solve -pos"); choices.push_back("-solve -pos"); choices.push_back("-pos"); choices.push_back("-solve"); @@ -24,7 +25,7 @@ void InitializeOnelab(std::string sockName, std::string modelName) { loader->set(ps[0]); ps.resize(1); ps[0].setName("Elasticity/1ModelName"); - ps[0].setValue(modelName); + ps[0].setValue(modelName); loader->set(ps[0]); } /* @@ -78,23 +79,23 @@ void WhatToDoNow(int argc, char *argv[], int &solve, std::string &modelName) solve = 1; std::string sockName = ""; while (i < argc) { - + if (argv[i][0] == '-') { - if (!strcmp(argv[i]+1, "solve") || + if (!strcmp(argv[i]+1, "solve") || !strcmp(argv[i]+1, "-solve")) { solve = 1; i++; } - else if (!strcmp(argv[i]+1, "pos") || + else if (!strcmp(argv[i]+1, "pos") || !strcmp(argv[i]+1, "-pos")) { i++; } // else if (!strcmp(argv[i]+1, "onelab")) { // i++; - // if (i<argc && argv[i][0]!='-') { + // if (i<argc && argv[i][0]!='-') { // printf("INITIALIZING SOCKET %s\n",argv[i]); // sockName=argv[i]; - // InitializeOnelab(sockName,modelName); i++; + // InitializeOnelab(sockName,modelName); i++; // } // else { // printf("Error : Missing address of onelab server"); @@ -110,12 +111,12 @@ void WhatToDoNow(int argc, char *argv[], int &solve, std::string &modelName) Info(0, argv[0]); } - else if (!strcmp(argv[i]+1, "version") || + else if (!strcmp(argv[i]+1, "version") || !strcmp(argv[i]+1, "-version")) { i++; Info(1, argv[0]); } - else if (!strcmp(argv[i]+1, "info") || + else if (!strcmp(argv[i]+1, "info") || !strcmp(argv[i]+1, "-info")) { i++; Info(2, argv[0]); @@ -133,11 +134,11 @@ void WhatToDoNow(int argc, char *argv[], int &solve, std::string &modelName) int main (int argc, char* argv[]){ char* a[10]; char name[245]; - a[0] = name; + a[0] = name; GmshInitialize(1, a); GmshSetOption("General","Terminal",1.); - - // for (int i=0;i<argc;i++)printf("%s\n",argv[i]); + + // for (int i=0;i<argc;i++)printf("%s\n",argv[i]); printf("Welcome to the Simple Elasticity Program For Onelab\n"); @@ -149,9 +150,9 @@ int main (int argc, char* argv[]){ elasticitySolver mySolver (1000); mySolver.setMesh(std::string(pn+".msh").c_str()); mySolver.readInputFile(std::string(pn+".dat").c_str()); - + if (solve){ - mySolver.solve(); + mySolver.solve(); PView *pvm = mySolver.buildVonMisesView("vonMises"); PView *pv = mySolver.buildDisplacementView("displacement"); // pv->getData()->writeMSH("disp.msh", false, false); @@ -161,10 +162,10 @@ int main (int argc, char* argv[]){ } return 0; - + // solve the problem - + // stop gmsh - + } diff --git a/utils/api_demos/mainGlut.cpp b/utils/api_demos/mainGlut.cpp index 3a1cad8a87d038cac7d8a20bb38ede264363b3d1..1d17c40538e0bebc2ccc36246e5608771fde4aec 100644 --- a/utils/api_demos/mainGlut.cpp +++ b/utils/api_demos/mainGlut.cpp @@ -28,7 +28,7 @@ typedef struct { unsigned char r,g,b,a; } PIXELA; -using namespace std; +using namespace std; drawContext *ctx = 0; Camera *camera; mouseAndKeyboard mouseandkeys; @@ -49,8 +49,8 @@ public: int getStringDescent(){ return 6; } void drawString(const char *str) { - for (int i = 0; i < strlen(str); i++) - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); + for (int i = 0; i < strlen(str); i++) + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); } }; @@ -65,22 +65,22 @@ void display() glViewport(ctx->viewport[0], ctx->viewport[1], ctx->viewport[2], ctx->viewport[3]); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - camera->giveViewportDimension(ctx->viewport[2],ctx->viewport[3]); + camera->giveViewportDimension(ctx->viewport[2],ctx->viewport[3]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum(camera->glFleft,camera->glFright,camera->glFbottom,camera->glFtop,camera->near,camera->far); + glFrustum(camera->glFleft,camera->glFright,camera->glFbottom,camera->glFtop,camera->glFnear,camera->glFfar); glMatrixMode(GL_MODELVIEW); glDrawBuffer(GL_BACK); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 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); ctx->draw3d(); ctx->draw2d(); - glutSwapBuffers(); - + glutSwapBuffers(); + } else { // cout<<" display3D();"<<endl; @@ -88,7 +88,7 @@ void display() ctx->viewport[2], ctx->viewport[3]); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); camera->giveViewportDimension(ctx->viewport[2],ctx->viewport[3]); - + //right eye XYZ eye =camera->eyesep / 2.0* camera->right; glMatrixMode(GL_PROJECTION); @@ -97,17 +97,17 @@ void display() double right = camera->screenratio * camera->wd2 - 0.5 * camera->eyesep * camera->ndfl; double top = camera->wd2; double bottom = - camera->wd2; - glFrustum(left,right,bottom,top,camera->near,camera->far); + glFrustum(left,right,bottom,top,camera->glFnear,camera->glFfar); glMatrixMode(GL_MODELVIEW); glDrawBuffer(GL_BACK_RIGHT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(camera->position.x+eye.x, camera->position.y+eye.y, camera->position.z+eye.z, camera->target.x+eye.x, camera->target.y+eye.y, camera->target.z+eye.z, - camera->up.x, camera->up.y, camera->up.z); + camera->up.x, camera->up.y, camera->up.z); ctx->draw3d(); ctx->draw2d(); - + //left eye glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -115,21 +115,21 @@ void display() right = camera->screenratio * camera->wd2 + 0.5 * camera->eyesep * camera->ndfl; top = camera->wd2; bottom = - camera->wd2; - glFrustum(left,right,bottom,top,camera->near,camera->far); - + glFrustum(left,right,bottom,top,camera->glFnear,camera->glFfar); + glMatrixMode(GL_MODELVIEW); glDrawBuffer(GL_BACK_LEFT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(camera->position.x-eye.x, camera->position.y-eye.y, camera->position.z-eye.z, camera->target.x-eye.x, camera->target.y-eye.y, camera->target.z-eye.z, - camera->up.x, camera->up.y, camera->up.z); + camera->up.x, camera->up.y, camera->up.z); ctx->draw3d(); ctx->draw2d(); - - glutSwapBuffers(); + + glutSwapBuffers(); } - + } @@ -156,7 +156,7 @@ void motion(int x, int y) double yprev_r=2.*(-1.*yprev + h/2.)/h; double q[4]; trackball(q,xprev_r,yprev_r,x_r,y_r); - camera->rotate(q); + camera->rotate(q); xprev = x; yprev = y; } @@ -175,11 +175,11 @@ void motion(int x, int y) double x_r = 2.*(1.*x - w/2.)/w; double y_r = 2.*(1.*y - h/2.)/h; double xprev_r=2.*(1.*xprev - w/2.)/w; - double yprev_r=2.*(1.*yprev - h/2.)/h; + double yprev_r=2.*(1.*yprev - h/2.)/h; double theta_x=camera->aperture*(x_r-xprev_r)*0.0174532925/2. ; double theta_y=camera->aperture*(y_r-yprev_r)*0.0174532925/2. ; - camera->moveRight(theta_x); - camera->moveUp(theta_y); + camera->moveRight(theta_x); + camera->moveUp(theta_y); xprev = x; yprev = y; } @@ -193,13 +193,13 @@ void motion(int x, int y) void mouse(int button, int state, int x, int y) { - specialkey = glutGetModifiers(); + specialkey = glutGetModifiers(); xprev = x; yprev = y; if (button == GLUT_LEFT_BUTTON) { mouseandkeys.button_left_down=!state; } - else if (button == GLUT_MIDDLE_BUTTON) { + else if (button == GLUT_MIDDLE_BUTTON) { mouseandkeys.button_middle_down=!state; } else { @@ -219,12 +219,12 @@ void processSpecialKeys(int key, int x, int y) { display(); camera->focallength=camera->focallength*.99; camera->eyesep=(camera->focallength/camera->distance)*camera->distance*camera->screenratio; - break; + break; case 102 : /* 'right' */ camera->focallength=camera->focallength*1.01; camera->eyesep=(camera->focallength/camera->distance)*camera->distance*camera->screenratio; display(); - break; + break; } } else{ @@ -232,21 +232,21 @@ void processSpecialKeys(int key, int x, int y) { mouseandkeys.key= key ; case 101 : /* 'up' */ camera->focallength*=1.1; - break; + break; case 103 : /* 'down' */ camera->focallength*=0.9; - break; + break; case 100 : /* 'left' */ camera->eyesep*=.9; - break; + break; case 102 : /* 'right' */ camera->eyesep*=1.1; - break; + break; } } camera->update(); display(); - + cout<<"eyesep = "<< camera->eyesep<<" / focallength = "<< camera->focallength<<" / screenratio = "; cout<< camera->screenratio<<" / distance = "<< camera->distance<<" / closeness = "<< camera->closeness<<endl; mouseandkeys.mode = 0; @@ -260,47 +260,47 @@ void processNormalKeys(unsigned char key, int x, int y) { if (key != 0) { mouseandkeys.key= key ; mouseandkeys.mode = glutGetModifiers(); - if (mouseandkeys.mode == GLUT_ACTIVE_CTRL && key==17) exit(0); - } + if (mouseandkeys.mode == GLUT_ACTIVE_CTRL && key==17) exit(0); + } switch(key){ case 49: GModel::current()->mesh(1); break; /* '1' */ case 50: GModel::current()->mesh(2); break; /* '2' */ case 51: GModel::current()->mesh(3); break; /* '3' */ - case 48 : /* '0' */ - camera->lookAtCg(); + case 48 : /* '0' */ + camera->lookAtCg(); display(); break; - case 114 : /* 'R' */ - camera->init(); + case 114 : /* 'R' */ + camera->init(); display(); break; case 'f' : /* 'F' */ - camera->screenwidth=ctx->viewport[2]; - camera->screenheight=ctx->viewport[3]; - glutFullScreen(); + camera->screenwidth=ctx->viewport[2]; + camera->screenheight=ctx->viewport[3]; + glutFullScreen(); display(); - break; + break; case 27 : /* 'ech' */ glutReshapeWindow(camera->screenwidth ,camera->screenheight ); //glutReshapeWindow(500,500 ); - display(); - break; + display(); + break; case 100 : ; /* 'D' */ GmshSetOption("View","VectorType",5.); - display(); - break; + display(); + break; case 43 : /* '+' */ GmshGetOption("View", "DisplacementFactor", def); def*=2.; GmshSetOption("View","DisplacementFactor",def); - display(); - break; + display(); + break; case 45 : ; /* '-' */ GmshGetOption("View", "DisplacementFactor", def); def*=.5; GmshSetOption("View","DisplacementFactor",def); - display(); - break; + display(); + break; } } @@ -324,7 +324,7 @@ int main(int argc, char **argv) camera->stereoEnable = true; cout<<"mode STEREO"<<endl; GmshSetOption("General", "Stereo", 1.); - } + } for(int i = 1; i < argc; i++) GmshMergeFile(argv[i]); @@ -337,41 +337,41 @@ int main(int argc, char **argv) if (camera->stereoEnable) { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO); } - else { + else { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); } glutInitWindowSize(ctx->viewport[2], ctx->viewport[3]); glutInitWindowPosition(400,10); - glutInitWindowSize(800,800); - glutCreateWindow("GLUT Gmsh Viewer"); - glutDisplayFunc(display); + glutInitWindowSize(800,800); + glutCreateWindow("GLUT Gmsh Viewer"); + glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMotionFunc(motion); glutMouseFunc(mouse); glutKeyboardFunc(processNormalKeys); - glutSpecialFunc(processSpecialKeys); + glutSpecialFunc(processSpecialKeys); cout<<"-------------------------------------"<<endl; cout<<" SHORTCUTS "<<endl; cout<<"-------------------------------------"<<endl; - cout<<" Ctrl+Q Quit "<<endl; - cout<<" 1 mesh line "<<endl; - cout<<" 2 mesh surface "<<endl; - cout<<" 3 mesh volume "<<endl; - cout<<" R resize "<<endl; - cout<<" 0 origine "<<endl; - cout<<" option -s stereo on "<<endl; - cout<<" F full screen on "<<endl; - cout<<" ech full screen off"<<endl; - cout<<" D displacement field"<<endl; - cout<<" + deformed +"<<endl; - cout<<" - deformed -"<<endl; - cout<<" up focal length +"<<endl; - cout<<" down focal length -"<<endl; - cout<<" left eye sep -"<<endl; - cout<<" right eye sep +"<<endl; - cout<<"-------------------------------------"<<endl; + cout<<" Ctrl+Q Quit "<<endl; + cout<<" 1 mesh line "<<endl; + cout<<" 2 mesh surface "<<endl; + cout<<" 3 mesh volume "<<endl; + cout<<" R resize "<<endl; + cout<<" 0 origine "<<endl; + cout<<" option -s stereo on "<<endl; + cout<<" F full screen on "<<endl; + cout<<" ech full screen off"<<endl; + cout<<" D displacement field"<<endl; + cout<<" + deformed +"<<endl; + cout<<" - deformed -"<<endl; + cout<<" up focal length +"<<endl; + cout<<" down focal length -"<<endl; + cout<<" left eye sep -"<<endl; + cout<<" right eye sep +"<<endl; + cout<<"-------------------------------------"<<endl; glutMainLoop(); GmshFinalize(); return 0; diff --git a/utils/api_demos/mainHomology.cpp b/utils/api_demos/mainHomology.cpp index f1e55608196b30eaf94b94482bccd4983ce9db7c..be886c3a0450a9daa4aec032bb691d16a8484de3 100644 --- a/utils/api_demos/mainHomology.cpp +++ b/utils/api_demos/mainHomology.cpp @@ -36,7 +36,7 @@ int main(int argc, char **argv) homology->setFileName("homology.msh"); // construct cell complex of the meshed domain - CellComplex cc = homology->createCellComplex(); + CellComplex *cc = homology->createCellComplex(); // find homology basis elements homology->findHomologyBasis(cc);