diff --git a/Box/Box.cpp b/Box/Box.cpp index 00cceb007d51b80682f87c6de979c4aa0fda9a3d..61fde2e4a39a7384e511204f91515c874bcb3bf3 100644 --- a/Box/Box.cpp +++ b/Box/Box.cpp @@ -1,4 +1,4 @@ -// $Id: Box.cpp,v 1.48 2008-03-19 17:26:48 geuzaine Exp $ +// $Id: Box.cpp,v 1.49 2008-03-20 11:44:01 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -88,11 +88,11 @@ int GMSHBOX(int argc, char *argv[]) if(CTX.bgm_filename) { MergeFile(CTX.bgm_filename); if(PView::list.size()){ - GModel::current()->getFields()->set_background_mesh(PView::list.back()->getNum() - 1); + GModel::current()->getFields()->set_background_mesh(PView::list.back()->getNum() - 1); } else{ fprintf(stderr, ERROR_STR "Invalid background mesh (no view)\n"); - exit(1); + exit(1); } } if(CTX.batch > 0) { @@ -209,7 +209,7 @@ double GetValue(const char *text, double defaultval) } bool GetBinaryAnswer(const char *question, const char *yes, const char *no, - bool defaultval) + bool defaultval) { if(CTX.nopopup || CTX.batch) return defaultval; diff --git a/Common/Colors.h b/Common/Colors.h index 489ca9a6b99f61ea242ef782c611e2cc38d0b58b..9d5c2fd6392dc9c9c95c91d950793db1b16b539b 100644 --- a/Common/Colors.h +++ b/Common/Colors.h @@ -684,6 +684,6 @@ StringX4Int ColorString[] = { } ; int Get_ColorForString(StringX4Int SX4I[], int alpha, const char *string, - int *FlagError); + int *FlagError); #endif diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index a3f707cd07e47178af7a29f2835471a553890431..e5c2979171dfbc6384afb804230b44667d5f936d 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -1,4 +1,4 @@ -// $Id: CommandLine.cpp,v 1.123 2008-03-18 11:33:04 remacle Exp $ +// $Id: CommandLine.cpp,v 1.124 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -213,8 +213,8 @@ void Get_Options(int argc, char *argv[]) i++; } else if(!strcmp(argv[i] + 1, "pid")) { - fprintf(stdout, "%d\n", GetProcessId()); - fflush(stdout); + fprintf(stdout, "%d\n", GetProcessId()); + fflush(stdout); i++; } else if(!strcmp(argv[i] + 1, "a")) { @@ -256,7 +256,7 @@ void Get_Options(int argc, char *argv[]) else if(!strcmp(argv[i] + 1, "string")) { i++; if(argv[i] != NULL) - ParseString(argv[i++]); + ParseString(argv[i++]); else { fprintf(stderr, ERROR_STR "Missing string\n"); exit(1); @@ -283,8 +283,8 @@ void Get_Options(int argc, char *argv[]) else if(!strcmp(argv[i] + 1, "bgm")) { i++; if(argv[i] != NULL){ - CTX.bgm_filename=argv[i++]; - } else { + CTX.bgm_filename=argv[i++]; + } else { fprintf(stderr, ERROR_STR "Missing file name\n"); exit(1); } @@ -297,21 +297,21 @@ void Get_Options(int argc, char *argv[]) i++; CTX.terminal = 1; CTX.batch = 1; - while(i < argc) { - char filename[256]; - sprintf(filename, "%s_new", argv[i]); - unsigned int n = PView::list.size(); + while(i < argc) { + char filename[256]; + sprintf(filename, "%s_new", argv[i]); + unsigned int n = PView::list.size(); OpenProject(argv[i]); - // convert post-processing views to latest binary format + // convert post-processing views to latest binary format for(unsigned int j = n; j < PView::list.size(); j++) - PView::list[j]->write(filename, 1, (j == n) ? false : true); - // convert mesh to latest binary format - if(GModel::current()->getMeshStatus() > 0){ - CTX.mesh.msh_file_version = 2.0; - CTX.mesh.msh_binary = 1; - CreateOutputFile(filename, FORMAT_MSH); - } - i++; + PView::list[j]->write(filename, 1, (j == n) ? false : true); + // convert mesh to latest binary format + if(GModel::current()->getMeshStatus() > 0){ + CTX.mesh.msh_file_version = 2.0; + CTX.mesh.msh_binary = 1; + CreateOutputFile(filename, FORMAT_MSH); + } + i++; } exit(1); } @@ -398,7 +398,7 @@ void Get_Options(int argc, char *argv[]) CTX.mesh.lc_integration_precision = atof(argv[i++]); if(CTX.mesh.lc_integration_precision <= 0.0) { fprintf(stderr, ERROR_STR - "Integration Accuraci for evaluation of 1D LC FIELD must be > 0\n"); + "Integration Accuraci for evaluation of 1D LC FIELD must be > 0\n"); exit(1); } } @@ -445,11 +445,11 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "c1")) { i++; - opt_mesh_c1(0, GMSH_SET, 1); + opt_mesh_c1(0, GMSH_SET, 1); } else if(!strcmp(argv[i] + 1, "statreport")) { i++; - CTX.create_append_statreport = 1; + CTX.create_append_statreport = 1; if(argv[i] != NULL) { strcpy(CTX.statreport,argv[i]); i++; @@ -461,7 +461,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "append_statreport")) { i++; - CTX.create_append_statreport = 2; + CTX.create_append_statreport = 2; if(argv[i] != NULL) { strcpy(CTX.statreport,argv[i]); i++; @@ -473,26 +473,26 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "optimize_hom")) { i++; - opt_mesh_smooth_internal_edges(0, GMSH_SET, 1); + opt_mesh_smooth_internal_edges(0, GMSH_SET, 1); } else if(!strcmp(argv[i] + 1, "format") || !strcmp(argv[i] + 1, "f")) { i++; if(argv[i] != NULL) { if(!strcmp(argv[i], "msh1")){ CTX.mesh.format = FORMAT_MSH; - CTX.mesh.msh_file_version = 1.0; - } + CTX.mesh.msh_file_version = 1.0; + } else if(!strcmp(argv[i], "msh2")){ CTX.mesh.format = FORMAT_MSH; - CTX.mesh.msh_file_version = 2.0; - } + CTX.mesh.msh_file_version = 2.0; + } else if(!strcmp(argv[i], "msh")) CTX.mesh.format = FORMAT_MSH; else if(!strcmp(argv[i], "unv")) CTX.mesh.format = FORMAT_UNV; else if(!strcmp(argv[i], "vrml")) CTX.mesh.format = FORMAT_VRML; - else if(!strcmp(argv[i], "stl")) + else if(!strcmp(argv[i], "stl")) CTX.mesh.format = FORMAT_STL; else if(!strcmp(argv[i], "mesh")) CTX.mesh.format = FORMAT_MESH; @@ -517,7 +517,7 @@ void Get_Options(int argc, char *argv[]) } else if(!strcmp(argv[i] + 1, "bin")) { i++; - CTX.mesh.stl_binary = CTX.mesh.msh_binary = 1; + CTX.mesh.stl_binary = CTX.mesh.msh_binary = 1; } else if(!strcmp(argv[i] + 1, "algo")) { i++; @@ -531,7 +531,7 @@ void Get_Options(int argc, char *argv[]) else if(!strncmp(argv[i], "bds", 3)) CTX.mesh.algo2d = ALGO_2D_MESHADAPT; else if(!strncmp(argv[i], "del", 3) || !strncmp(argv[i], "iso", 3)) - CTX.mesh.algo2d = ALGO_2D_MESHADAPT_DELAUNAY; + CTX.mesh.algo2d = ALGO_2D_MESHADAPT_DELAUNAY; else { fprintf(stderr, ERROR_STR "Unknown mesh algorithm\n"); exit(1); diff --git a/Common/Context.cpp b/Common/Context.cpp index 8a7087b77df05b88a03e05d1047f131216ee714f..4b000ca1f61b1957a2e48a063a07b9aa0b58a7dc 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -1,4 +1,4 @@ -// $Id: Context.cpp,v 1.61 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: Context.cpp,v 1.62 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -44,7 +44,7 @@ void Context_T::buildRotationMatrix(void) double BD = B * D; rot[0] = C*E; rot[1] = BD*E+A*F; rot[2] =-AD*E+B*F; rot[3] = 0.; rot[4] =-C*F; rot[5] =-BD*F+A*E; rot[6] = AD*F+B*E; rot[7] = 0.; - rot[8] = D; rot[9] =-B*C; rot[10] = A*C; rot[11] = 0.; + rot[8] = D; rot[9] =-B*C; rot[10] = A*C; rot[11] = 0.; rot[12] = 0.; rot[13] = 0.; rot[14] = 0.; rot[15] = 1.; setQuaternionFromEulerAngles(); } diff --git a/Common/Context.h b/Common/Context.h index 4f4cad68fdcf3db95915f49516592ffdc3b25be5..95ae3fb68ec25f5efead0d43f817833d5abbf124 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -91,7 +91,7 @@ class Context_T { double max[3]; // x, y and z max for the current geometry double cg[3]; // "center of mass" of the current geometry double lc; // characteristic length for the whole problem (never - // used in mesh generation ->only for geo/post) + // used in mesh generation ->only for geo/post) int db, antialiasing; // double buffer? antialiasing? int ortho; // orthogonal projection? int draw_bbox, draw_rotation_center; // draw the bounding boxes and the rot center? diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 2dccb4358f60402c4d6b5a62e24776bf4d763116..7791e6b8a880522fc0be7474292efa3b96957ae8 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -770,7 +770,7 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "Terminal" , opt_general_terminal , #if defined(HAVE_FLTK) 0. , -#else +#else 1. , #endif "Should information be printed on the terminal (if available)?" }, diff --git a/Common/GmshMatrix.h b/Common/GmshMatrix.h index 4801a3d8520857cb72d3334e9c0386faeb96307f..115d468ded22dd4e927ca2635dbdce16077f6176 100644 --- a/Common/GmshMatrix.h +++ b/Common/GmshMatrix.h @@ -275,19 +275,19 @@ public: GSL_Matrix cof(ni - 1, nj - 1); if (i > 0) { if (j > 0) - GSL_Matrix(cof.touchSubmatrix(0, i , 0, j)). - memcpy(GSL_Matrix(seeSubmatrix(0, i, 0, j))); + GSL_Matrix(cof.touchSubmatrix(0, i , 0, j)). + memcpy(GSL_Matrix(seeSubmatrix(0, i, 0, j))); if (j < nj - 1) - GSL_Matrix(cof.touchSubmatrix(0, i, j, nj - j - 1)). - memcpy(GSL_Matrix(seeSubmatrix(0, i, j + 1,nj - j - 1))); + GSL_Matrix(cof.touchSubmatrix(0, i, j, nj - j - 1)). + memcpy(GSL_Matrix(seeSubmatrix(0, i, j + 1,nj - j - 1))); } if (i < ni - 1) { if (j < nj - 1) - GSL_Matrix(cof.touchSubmatrix(i, ni - i - 1, j, nj - j - 1)). - memcpy(GSL_Matrix(seeSubmatrix(i + 1, ni - i - 1, j + 1, nj - j - 1))); + GSL_Matrix(cof.touchSubmatrix(i, ni - i - 1, j, nj - j - 1)). + memcpy(GSL_Matrix(seeSubmatrix(i + 1, ni - i - 1, j + 1, nj - j - 1))); if (j > 0) - GSL_Matrix(cof.touchSubmatrix(i, ni - i - 1, 0, j)). - memcpy(GSL_Matrix(seeSubmatrix(i + 1, ni - i - 1, 0, j))); + GSL_Matrix(cof.touchSubmatrix(i, ni - i - 1, 0, j)). + memcpy(GSL_Matrix(seeSubmatrix(i + 1, ni - i - 1, 0, j))); } return cof; } diff --git a/Common/License.cpp b/Common/License.cpp index 3ff9a3721ffc517c516cf2f205efdfe42e96a7ab..cd996e8c13475ec9243dea9984d12e0998a05d95 100644 --- a/Common/License.cpp +++ b/Common/License.cpp @@ -1,4 +1,4 @@ -// $Id: License.cpp,v 1.12 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: License.cpp,v 1.13 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -44,15 +44,15 @@ void print_license(void) Msg(DIRECT, " "); Msg(DIRECT, "End of exception."); Msg(DIRECT, " "); - Msg(DIRECT, " GNU GENERAL PUBLIC LICENSE"); - Msg(DIRECT, " Version 2, June 1991"); + Msg(DIRECT, " GNU GENERAL PUBLIC LICENSE"); + Msg(DIRECT, " Version 2, June 1991"); Msg(DIRECT, " "); Msg(DIRECT, " Copyright (C) 1989, 1991 Free Software Foundation, Inc."); Msg(DIRECT, " 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"); Msg(DIRECT, " Everyone is permitted to copy and distribute verbatim copies"); Msg(DIRECT, " of this license document, but changing it is not allowed."); Msg(DIRECT, " "); - Msg(DIRECT, " Preamble"); + Msg(DIRECT, " Preamble"); Msg(DIRECT, " "); Msg(DIRECT, " The licenses for most software are designed to take away your"); Msg(DIRECT, "freedom to share and change it. By contrast, the GNU General Public"); @@ -102,7 +102,7 @@ void print_license(void) Msg(DIRECT, " The precise terms and conditions for copying, distribution and"); Msg(DIRECT, "modification follow."); Msg(DIRECT, " "); - Msg(DIRECT, " GNU GENERAL PUBLIC LICENSE"); + Msg(DIRECT, " GNU GENERAL PUBLIC LICENSE"); Msg(DIRECT, " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION"); Msg(DIRECT, " "); Msg(DIRECT, " 0. This License applies to any program or other work which contains"); @@ -301,7 +301,7 @@ void print_license(void) Msg(DIRECT, "of preserving the free status of all derivatives of our free software and"); Msg(DIRECT, "of promoting the sharing and reuse of software generally."); Msg(DIRECT, " "); - Msg(DIRECT, " NO WARRANTY"); + Msg(DIRECT, " NO WARRANTY"); Msg(DIRECT, " "); Msg(DIRECT, " 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY"); Msg(DIRECT, "FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN"); @@ -323,9 +323,9 @@ void print_license(void) Msg(DIRECT, "PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE"); Msg(DIRECT, "POSSIBILITY OF SUCH DAMAGES."); Msg(DIRECT, " "); - Msg(DIRECT, " END OF TERMS AND CONDITIONS"); + Msg(DIRECT, " END OF TERMS AND CONDITIONS"); Msg(DIRECT, " "); - Msg(DIRECT, " How to Apply These Terms to Your New Programs"); + Msg(DIRECT, " How to Apply These Terms to Your New Programs"); Msg(DIRECT, " "); Msg(DIRECT, " If you develop a new program, and you want it to be of the greatest"); Msg(DIRECT, "possible use to the public, the best way to achieve this is to make it"); diff --git a/Common/Message.h b/Common/Message.h index 4a4d76f99f05b18a7ab92b7dee78a421198f89e8..c4f0ea39ad83617272b7bfb643f5f838d8689693 100644 --- a/Common/Message.h +++ b/Common/Message.h @@ -73,6 +73,6 @@ void Msg(int level, const char *fmt, ...); void Exit(int); double GetValue(const char *text, double defaultval); bool GetBinaryAnswer(const char *question, const char *yes, const char *no, - bool defaultval=true); + bool defaultval=true); #endif diff --git a/Common/Octree.cpp b/Common/Octree.cpp index 847fa9bddce3af047250024c1da92a4738317cb3..9dfbd4b7e598324fa49a6b925da7766b1b1207a3 100644 --- a/Common/Octree.cpp +++ b/Common/Octree.cpp @@ -1,4 +1,4 @@ -// $Id: Octree.cpp,v 1.4 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: Octree.cpp,v 1.5 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -29,13 +29,13 @@ using std::list; void free_buckets(octantBucket *); Octree* Octree_Create(int maxElements, double origin[3], double size[3], - void (*BB)(void *, double*, double*), - void (*Centroid)(void *, double *), - int (*InEle)(void *, double *)) + void (*BB)(void *, double*, double*), + void (*Centroid)(void *, double *), + int (*InEle)(void *, double *)) { Octree *myOctree = new Octree; initializeOctantBuckets (origin, size, maxElements, - &(myOctree->root), &(myOctree->info)); + &(myOctree->root), &(myOctree->info)); myOctree->function_BB = BB; myOctree->function_centroid = Centroid; myOctree->function_inElement = InEle; @@ -57,7 +57,7 @@ void Octree_Insert(void * element, Octree *myOctree) (*(myOctree->function_centroid))(element, centroid); bucket = findElementBucket(myOctree->root, centroid); addElement2Bucket(bucket, element, minBB, maxBB, - centroid, myOctree->info); + centroid, myOctree->info); } void Octree_Arrange(Octree *myOctree) @@ -75,7 +75,7 @@ void Octree_Arrange(Octree *myOctree) void * Octree_Search(double *pt, Octree *myOctree) { return searchElement(myOctree->root, pt, myOctree->info, - myOctree->function_BB, myOctree->function_inElement); + myOctree->function_BB, myOctree->function_inElement); } void free_buckets(octantBucket * bucket) @@ -95,7 +95,7 @@ void free_buckets(octantBucket * bucket) } for(i = numBuck-1; i >= 0; i--) - free_buckets((bucket->next)+i); + free_buckets((bucket->next)+i); delete []bucket->next; return; } @@ -103,5 +103,5 @@ void free_buckets(octantBucket * bucket) void Octree_SearchAll(double * pt, Octree * myOctree, list<void *> * output) { searchAllElements(myOctree->root, pt, myOctree->info, myOctree->function_BB, - myOctree->function_inElement, output); + myOctree->function_inElement, output); } diff --git a/Common/Octree.h b/Common/Octree.h index d1a4b0d156f7c649dcdd404070cf4bcd89604e67..92a28b93b9fbe2eee233c4c85d44a25fe2e5b5bc 100644 --- a/Common/Octree.h +++ b/Common/Octree.h @@ -26,11 +26,11 @@ using std::list; Octree* Octree_Create(int maxElements, // max. num of elts allowed in an octant - double *origin, // smallest x,y, z of model's bounding box - double *size, // size in x, y, z of model bounding box - void (*BB)(void *, double*, double*), - void (*Centroid)(void *, double *), - int (*InEle)(void *, double *)); + double *origin, // smallest x,y, z of model's bounding box + double *size, // size in x, y, z of model bounding box + void (*BB)(void *, double*, double*), + void (*Centroid)(void *, double *), + int (*InEle)(void *, double *)); void Octree_Delete(Octree *); void Octree_Insert(void *, Octree *); diff --git a/Common/OctreeInternals.cpp b/Common/OctreeInternals.cpp index 3c4850307aef957a46cea74b867c54ef26f7a41f..aa260011ea0879310dc0c90742aa3b9e4f868cea 100644 --- a/Common/OctreeInternals.cpp +++ b/Common/OctreeInternals.cpp @@ -1,4 +1,4 @@ -// $Id: OctreeInternals.cpp,v 1.4 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: OctreeInternals.cpp,v 1.5 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -35,7 +35,7 @@ using std::list; int initializeOctantBuckets(double *_orig, double *_size, int _maxElem, - octantBucket **buckets_head, globalInfo **globalPara) + octantBucket **buckets_head, globalInfo **globalPara) // Initialize the buckets // Given by user: orig and size -- information about the domain // maxElem -- maximum number of elements per bucket @@ -103,12 +103,12 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem, for (k = 0; k < tmp1; k++) { for (j = 0; j < tmp1; j++) { for (i = 0; i < tmp1; i++) { - buckets[i+j*tmp1+k*tmp1*tmp1].minPt[0] = (*buckets_head)->minPt[0] + tmp[0]*i; - buckets[i+j*tmp1+k*tmp1*tmp1].minPt[1] = (*buckets_head)->minPt[1] + tmp[1]*j; - buckets[i+j*tmp1+k*tmp1*tmp1].minPt[2] = (*buckets_head)->minPt[2] + tmp[2]*k; - buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[0] = (*buckets_head)->minPt[0] + tmp[0]*(i+1); - buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[1] = (*buckets_head)->minPt[1] + tmp[1]*(j+1); - buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[2] = (*buckets_head)->minPt[2] + tmp[2]*(k+1); + buckets[i+j*tmp1+k*tmp1*tmp1].minPt[0] = (*buckets_head)->minPt[0] + tmp[0]*i; + buckets[i+j*tmp1+k*tmp1*tmp1].minPt[1] = (*buckets_head)->minPt[1] + tmp[1]*j; + buckets[i+j*tmp1+k*tmp1*tmp1].minPt[2] = (*buckets_head)->minPt[2] + tmp[2]*k; + buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[0] = (*buckets_head)->minPt[0] + tmp[0]*(i+1); + buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[1] = (*buckets_head)->minPt[1] + tmp[1]*(j+1); + buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[2] = (*buckets_head)->minPt[2] + tmp[2]*(k+1); } } } @@ -116,9 +116,9 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem, #if 0 for (i = 0; i < 8; i++) { printf(" bucket %d : min[0]=%f, min[1]=%f, min[2]=%f, max[0]= %f, max[1]=%f, max[3]=%f\n", - i,buckets[i].minPt[0],buckets[i].minPt[1], - buckets[i].minPt[2], buckets[i].maxPt[0], buckets[i].maxPt[1], - buckets[i].maxPt[2]); + i,buckets[i].minPt[0],buckets[i].minPt[1], + buckets[i].minPt[2], buckets[i].maxPt[0], buckets[i].maxPt[1], + buckets[i].maxPt[2]); printf("bucket elements link list: bucket->lhead = %d\n", buckets[i].lhead); } #endif @@ -127,8 +127,8 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem, } int addElement2Bucket(octantBucket *_bucket, void * _element, - double *_minBB, double *_maxBB, - double *_ele_centroid, globalInfo *_globalPara) + double *_minBB, double *_maxBB, + double *_ele_centroid, globalInfo *_globalPara) // Add another element to the octant bucket's list. // If the bucket contains too many elements after adding this element, // refine this bucket and reallocate the elements of this bucket @@ -167,15 +167,15 @@ int addElement2Bucket(octantBucket *_bucket, void * _element, printf("bucket element list: bucket->lhead = %d", _bucket->lhead); printf(" numElements = %d\n",_bucket->numElements); printf("the element is add to this bucket: (%f, %f, %f) to (%f, %f, %f)\n", - _bucket->minPt[0],_bucket->minPt[1], _bucket->minPt[2], _bucket->maxPt[0], - _bucket->maxPt[1], _bucket->maxPt[2]); + _bucket->minPt[0],_bucket->minPt[1], _bucket->minPt[2], _bucket->maxPt[0], + _bucket->maxPt[1], _bucket->maxPt[2]); #endif // check whether the number of elements in the bucket > maxElements // if true, refine the bucket and reallocate the elements while ( flag == 1) { flag = 0; - if (_bucket->numElements > _globalPara->maxElements) { + if (_bucket->numElements > _globalPara->maxElements) { // printf(" going to subdivide\n"); @@ -185,20 +185,20 @@ int addElement2Bucket(octantBucket *_bucket, void * _element, ptr1 = _bucket->lhead; while (ptr1 != NULL) { - ptrBucket = findElementBucket(_bucket, ptr1->centroid); - ptr2 = ptr1; - ptr1 = ptr1->next; - if (ptrBucket == NULL) - Msg(GERROR, "Wrong , ptrBucket = NULL. A bug here!"); - ptr2->next = ptrBucket->lhead; - ptrBucket->lhead = ptr2; - (ptrBucket->numElements)++; - if (ptrBucket->numElements > _globalPara->maxElements) { - flag = 1; - _bucket->lhead = NULL; - _bucket = ptrBucket; - } - } + ptrBucket = findElementBucket(_bucket, ptr1->centroid); + ptr2 = ptr1; + ptr1 = ptr1->next; + if (ptrBucket == NULL) + Msg(GERROR, "Wrong , ptrBucket = NULL. A bug here!"); + ptr2->next = ptrBucket->lhead; + ptrBucket->lhead = ptr2; + (ptrBucket->numElements)++; + if (ptrBucket->numElements > _globalPara->maxElements) { + flag = 1; + _bucket->lhead = NULL; + _bucket = ptrBucket; + } + } if (flag == 0) _bucket->lhead = NULL; } } @@ -220,11 +220,11 @@ int checkElementInBucket(octantBucket *_bucket, void* _element) octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt) -// Find the leaf bucket which contains the point _pt +// Find the leaf bucket which contains the point _pt // given parameter: _buckets --- the point to buckets head // _pt --- the point to find // Return the pointer to the bucket contains the point -// if fail, return NULL +// if fail, return NULL { int i, j; int num = 8; @@ -233,21 +233,21 @@ octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt) while (tmpbucket != NULL) { for (i = 0; i < num; i ++) { - for (j = 0; j < 3; j++) { - if (tmpbucket[i].minPt[j] > _pt[j] || - tmpbucket[i].maxPt[j] < _pt[j]) - break; + for (j = 0; j < 3; j++) { + if (tmpbucket[i].minPt[j] > _pt[j] || + tmpbucket[i].maxPt[j] < _pt[j]) + break; } if (j == 3) { - prevbucket = tmpbucket+i; - tmpbucket = tmpbucket[i].next; - break; - } + prevbucket = tmpbucket+i; + tmpbucket = tmpbucket[i].next; + break; + } } // for loop i if (i == num) { - // printf("Error, no bucket contains the given point! "); + // printf("Error, no bucket contains the given point! "); return NULL; - } + } } // for while loop return prevbucket; } @@ -302,7 +302,7 @@ int subdivideOctantBucket(octantBucket *_bucket, globalInfo *_globalPara) } void * searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, - BBFunction BBElement, InEleFunction xyzInElement) + BBFunction BBElement, InEleFunction xyzInElement) { int flag; octantBucket *ptrBucket; @@ -316,19 +316,19 @@ void * searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_glob flag = xyzInElement(ptrToEle, _pt); if (flag == 1) return ptrToEle; } - + ptrBucket = findElementBucket(_buckets_head, _pt); if (ptrBucket == NULL) { // printf("Error! the point is not in the domain.\n"); return NULL; - } + } ptr1 = ptrBucket->lhead; #if 0 printf("point %lf %lf %lf has been found in bucket %lf %lf %fl -> %lf %lf %lf %p\n", - _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], - ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); + _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], + ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); if (ptr1 == NULL) { printf("empty element list for centroid list!?\n, possible!"); } @@ -341,7 +341,7 @@ void * searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_glob if (flag == 1) { _globalPara->ptrToPrevElement = ptr1->region; return ptr1->region; - } + } ptr1 = ptr1->next; } @@ -363,7 +363,7 @@ void * searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_glob int xyzInElementBB(double *_xyz, void * _region, BBFunction _BBElement) // Check if xyz is in the region's bounding box, return 1 if true, 0 otherwise // BBElement is the function given by user to find the bounding box -{ +{ int i; double minPt[3]; // corner with smallest x,y,z coords double maxPt[3]; // corner with largest x,y,z coords @@ -392,17 +392,17 @@ void insertOneBB(void* _region, double *_minPt, double *_maxPt, octantBucket *_b ptr = ptr->next; } - _bucket->listBB.insert(_bucket->listBB.end(),_region); + _bucket->listBB.insert(_bucket->listBB.end(),_region); return; } - + for (i = 0; i < 8; i++) insertOneBB(_region, _minPt, _maxPt, _bucket->next+i); return; } void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, - BBFunction BBElement, InEleFunction xyzInElement, list<void *> *_elements) + BBFunction BBElement, InEleFunction xyzInElement, list<void *> *_elements) { int flag, flag1; octantBucket *ptrBucket; @@ -416,8 +416,8 @@ void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_ #if 0 printf("point %lf %lf %lf has been found in bucket %lf %lf %fl -> %lf %lf %lf %p\n", - _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], - ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); + _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], + ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); if (ptr1 == NULL) { printf("empty element list for centroid list!?\n, possible!"); @@ -427,14 +427,14 @@ void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_ flag1 = 0; for (iter = (ptrBucket->listBB).begin(); iter != (ptrBucket->listBB).end(); iter++){ - // printf("Enter 1 \n"); + // printf("Enter 1 \n"); flag = xyzInElementBB(_pt, *iter, BBElement); if (flag == 1) flag = xyzInElement(*iter, _pt); if (flag == 1) { _elements->push_back(*iter); flag1 = 1; - } + } } if (flag1) diff --git a/Common/OctreeInternals.h b/Common/OctreeInternals.h index 8e54456b5d9b9957c3c66c9f7123a8cbcda9be3b..cf90792f83ec1289a9ab7c5866758cfad6c0ced6 100644 --- a/Common/OctreeInternals.h +++ b/Common/OctreeInternals.h @@ -44,7 +44,7 @@ struct bucket { int numElements; // number of elements contained by bucket int precision; // the level of precision of the bucket ELink lhead; // list of elements in bucket, if NULL -> no elements - std::list<void *> listBB; // list of elements in bucket by Bounding Box + std::list<void *> listBB; // list of elements in bucket by Bounding Box struct bucket *next; // link to ragged digit extensions to bucket array struct bucket *parent; // link to the parent bucket }; @@ -57,7 +57,7 @@ struct global { int maxPrecision; // current maximum octant precision for model double origin[3]; // smallest x,y, z of model's bounding box double size[3]; // size in x, y, z of model bounding box - void * ptrToPrevElement; + void * ptrToPrevElement; std::list<void *> listAllElements; }; typedef struct global globalInfo; @@ -72,23 +72,23 @@ typedef struct }Octree; void refineOctants(octantBucket *buckets, - globalInfo *globalPara); + globalInfo *globalPara); int addElement2Bucket(octantBucket *bucket, void * element, - double *minBB, double *maxBB, - double *ele_centroid, globalInfo *globalPara); + double *minBB, double *maxBB, + double *ele_centroid, globalInfo *globalPara); int subdivideOctantBucket(octantBucket *bucket, globalInfo *globalPara); int initializeOctantBuckets(double *orig, double *size, int maxElem, - octantBucket **buckets, globalInfo **globalPara); + octantBucket **buckets, globalInfo **globalPara); int checkElementInBucket(octantBucket *bucket, void * element); octantBucket* findElementBucket(octantBucket *buckets, double *pt); void * searchElement(octantBucket *buckets, double *pt, - globalInfo *globalPara, BBFunction BBElement, - InEleFunction xyzInElement); + globalInfo *globalPara, BBFunction BBElement, + InEleFunction xyzInElement); int xyzInElementBB(double *xyz, void *region, BBFunction BBElement); void insertOneBB(void *, double *, double *, octantBucket *); void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, - BBFunction BBElement, InEleFunction xyzInElement, - std::list<void *> *_elements); + BBFunction BBElement, InEleFunction xyzInElement, + std::list<void *> *_elements); #endif diff --git a/Common/Options.cpp b/Common/Options.cpp index 48cfb649728c8f1839faa87393d0ae398b91c7de..0523456f85b4337909277e5f4db48de231fe47bb 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.388 2008-03-18 08:41:20 remacle Exp $ +// $Id: Options.cpp,v 1.389 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -463,7 +463,7 @@ void Print_OptionsDoc() fprintf(file, "@item View.ColorTable\n"); fprintf(file, "Color table used to draw the view@*\n"); fprintf(file, "Saved in: @code{%s}\n\n", - Get_OptionSaveLevel(GMSH_FULLRC|GMSH_OPTIONSRC)); + Get_OptionSaveLevel(GMSH_FULLRC|GMSH_OPTIONSRC)); fprintf(file, "@end ftable\n"); fclose(file); @@ -485,26 +485,26 @@ void Print_OptionsDoc() int m = p->getNbOptionsStr(); if(m){ - fprintf(file, "String options:\n"); - fprintf(file, "@table @code\n"); - for(int i = 0; i < m; i++) { - StringXString *sxs = p->getOptionStr(i); - fprintf(file, "@item %s\n", sxs->str); - fprintf(file, "Default value: @code{\"%s\"}\n", sxs->def); - } - fprintf(file, "@end table\n"); + fprintf(file, "String options:\n"); + fprintf(file, "@table @code\n"); + for(int i = 0; i < m; i++) { + StringXString *sxs = p->getOptionStr(i); + fprintf(file, "@item %s\n", sxs->str); + fprintf(file, "Default value: @code{\"%s\"}\n", sxs->def); + } + fprintf(file, "@end table\n"); } int n = p->getNbOptions(); if(n){ - fprintf(file, "Numeric options:\n"); - fprintf(file, "@table @code\n"); - for(int i = 0; i < n; i++) { - StringXNumber *sxn = p->getOption(i); - fprintf(file, "@item %s\n", sxn->str); - fprintf(file, "Default value: @code{%g}\n", sxn->def); - } - fprintf(file, "@end table\n"); + fprintf(file, "Numeric options:\n"); + fprintf(file, "@table @code\n"); + for(int i = 0; i < n; i++) { + StringXNumber *sxn = p->getOption(i); + fprintf(file, "@item %s\n", sxn->str); + fprintf(file, "Default value: @code{%g}\n", sxn->def); + } + fprintf(file, "@end table\n"); } } @@ -566,20 +566,20 @@ void *Get_StringOption(const char *str, StringXString s[]) } void Print_StringOptions(int num, int level, int diff, int help, - StringXString s[], const char *prefix, FILE *file) + StringXString s[], const char *prefix, FILE *file) { int i = 0; char tmp[1024]; while(s[i].str) { if(s[i].level & level) { if(!diff || strcmp(s[i].function(num, GMSH_GET, NULL), s[i].def)){ - sprintf(tmp, "%s%s = \"%s\";%s%s", prefix, - s[i].str, s[i].function(num, GMSH_GET, NULL), - help ? " // " : "", help ? s[i].help : ""); - if(file) - fprintf(file, "%s\n", tmp); - else - Msg(DIRECT, "%s", tmp); + sprintf(tmp, "%s%s = \"%s\";%s%s", prefix, + s[i].str, s[i].function(num, GMSH_GET, NULL), + help ? " // " : "", help ? s[i].help : ""); + if(file) + fprintf(file, "%s\n", tmp); + else + Msg(DIRECT, "%s", tmp); } } i++; @@ -602,7 +602,7 @@ void Print_StringOptionsDoc(StringXString s[], const char *prefix, FILE *file) while(j < len){ tmp[j] = *(ptr++); if(j && tmp[j] == '\n' && tmp[j-1] == '\n') - tmp[j-1] = '.'; + tmp[j-1] = '.'; j++; if(j == 1023) break; } @@ -668,20 +668,20 @@ void *Get_NumberOption(const char *str, StringXNumber s[]) } void Print_NumberOptions(int num, int level, int diff, int help, - StringXNumber s[], const char *prefix, FILE * file) + StringXNumber s[], const char *prefix, FILE * file) { int i = 0; char tmp[1024]; while(s[i].str) { if(s[i].level & level) { if(!diff || (s[i].function(num, GMSH_GET, 0) != s[i].def)){ - sprintf(tmp, "%s%s = %.16g;%s%s", prefix, - s[i].str, s[i].function(num, GMSH_GET, 0), - help ? " // " : "", help ? s[i].help : ""); - if(file) - fprintf(file, "%s\n", tmp); - else - Msg(DIRECT, tmp); + sprintf(tmp, "%s%s = %.16g;%s%s", prefix, + s[i].str, s[i].function(num, GMSH_GET, 0), + help ? " // " : "", help ? s[i].help : ""); + if(file) + fprintf(file, "%s\n", tmp); + else + Msg(DIRECT, tmp); } } i++; @@ -730,21 +730,21 @@ void Set_DefaultColorOptions(int num, StringXColor s[]) case 1: while(s[i].str) { s[i].function(num, GMSH_SET, CTX.PACK_COLOR(s[i].def2[0], s[i].def2[1], - s[i].def2[2], s[i].def2[3])); + s[i].def2[2], s[i].def2[3])); i++; } break; case 2: while(s[i].str) { s[i].function(num, GMSH_SET, CTX.PACK_COLOR(s[i].def3[0], s[i].def3[1], - s[i].def3[2], s[i].def3[3])); + s[i].def3[2], s[i].def3[3])); i++; } break; default: while(s[i].str) { s[i].function(num, GMSH_SET, CTX.PACK_COLOR(s[i].def1[0], s[i].def1[1], - s[i].def1[2], s[i].def1[3])); + s[i].def1[2], s[i].def1[3])); i++; } break; @@ -772,7 +772,7 @@ void *Get_ColorOption(const char *str, StringXColor s[]) } void Print_ColorOptions(int num, int level, int diff, int help, - StringXColor s[], const char *prefix, FILE * file) + StringXColor s[], const char *prefix, FILE * file) { int i = 0; char tmp[1024]; @@ -781,29 +781,29 @@ void Print_ColorOptions(int num, int level, int diff, int help, unsigned int def; switch (CTX.color_scheme) { case 1: - def = CTX.PACK_COLOR(s[i].def2[0], s[i].def2[1], - s[i].def2[2], s[i].def2[3]); - break; + def = CTX.PACK_COLOR(s[i].def2[0], s[i].def2[1], + s[i].def2[2], s[i].def2[3]); + break; case 2: - def = CTX.PACK_COLOR(s[i].def3[0], s[i].def3[1], - s[i].def3[2], s[i].def3[3]); - break; + def = CTX.PACK_COLOR(s[i].def3[0], s[i].def3[1], + s[i].def3[2], s[i].def3[3]); + break; default: - def = CTX.PACK_COLOR(s[i].def1[0], s[i].def1[1], - s[i].def1[2], s[i].def1[3]); - break; + def = CTX.PACK_COLOR(s[i].def1[0], s[i].def1[1], + s[i].def1[2], s[i].def1[3]); + break; } if(!diff || (s[i].function(num, GMSH_GET, 0) != def)){ - sprintf(tmp, "%sColor.%s = {%d,%d,%d};%s%s", - prefix, s[i].str, - CTX.UNPACK_RED(s[i].function(num, GMSH_GET, 0)), - CTX.UNPACK_GREEN(s[i].function(num, GMSH_GET, 0)), - CTX.UNPACK_BLUE(s[i].function(num, GMSH_GET, 0)), - help ? " // " : "", help ? s[i].help : ""); - if(file) - fprintf(file, "%s\n", tmp); - else - Msg(DIRECT, tmp); + sprintf(tmp, "%sColor.%s = {%d,%d,%d};%s%s", + prefix, s[i].str, + CTX.UNPACK_RED(s[i].function(num, GMSH_GET, 0)), + CTX.UNPACK_GREEN(s[i].function(num, GMSH_GET, 0)), + CTX.UNPACK_BLUE(s[i].function(num, GMSH_GET, 0)), + help ? " // " : "", help ? s[i].help : ""); + if(file) + fprintf(file, "%s\n", tmp); + else + Msg(DIRECT, tmp); } } i++; @@ -817,9 +817,9 @@ void Print_ColorOptionsDoc(StringXColor s[], const char *prefix, FILE * file) fprintf(file, "@item %sColor.%s\n", prefix, s[i].str); fprintf(file, "%s@*\n", s[i].help); fprintf(file, "Default value: @code{@{%d,%d,%d@}}@*\n", - CTX.UNPACK_RED(s[i].function(0, GMSH_GET, 0)), - CTX.UNPACK_GREEN(s[i].function(0, GMSH_GET, 0)), - CTX.UNPACK_BLUE(s[i].function(0, GMSH_GET, 0))); + CTX.UNPACK_RED(s[i].function(0, GMSH_GET, 0)), + CTX.UNPACK_GREEN(s[i].function(0, GMSH_GET, 0)), + CTX.UNPACK_BLUE(s[i].function(0, GMSH_GET, 0))); fprintf(file, "Saved in: @code{%s}\n\n", Get_OptionSaveLevel(s[i].level)); i++; } @@ -838,20 +838,20 @@ int Get_ColorForString(StringX4Int SX4I[], int alpha, return CTX.PACK_COLOR(SX4I[i].int1, SX4I[i].int2, SX4I[i].int3, SX4I[i].int4); } -#define GET_VIEW(error_val) \ - PView *view = 0; \ - PViewData *data = 0; \ - PViewOptions *opt; \ - if(PView::list.empty()) \ - opt = &PViewOptions::reference; \ - else{ \ - if(num < 0 || num >= (int)PView::list.size()){ \ - Msg(WARNING, "View[%d] does not exist", num); \ - return (error_val); \ - } \ - view = PView::list[num]; \ - data = view->getData(); \ - opt = view->getOptions(); \ +#define GET_VIEW(error_val) \ + PView *view = 0; \ + PViewData *data = 0; \ + PViewOptions *opt; \ + if(PView::list.empty()) \ + opt = &PViewOptions::reference; \ + else{ \ + if(num < 0 || num >= (int)PView::list.size()){ \ + Msg(WARNING, "View[%d] does not exist", num); \ + return (error_val); \ + } \ + view = PView::list[num]; \ + data = view->getData(); \ + opt = view->getOptions(); \ } // String option routines @@ -1919,8 +1919,8 @@ const char *opt_solver_fifth_button_command4(OPT_ARGS_STR) int _gui_action_valid(int action, int num) { return ((WID) && - (action & GMSH_GUI) && - (num == WID->view_number)); + (action & GMSH_GUI) && + (num == WID->view_number)); } #endif @@ -3659,8 +3659,8 @@ double opt_general_light00(OPT_ARGS_NUM) if(WID && (action & GMSH_GUI)){ WID->gen_value[2]->value(CTX.light_position[0][0]); WID->gen_sphere->setValue(CTX.light_position[0][0], - CTX.light_position[0][1], - CTX.light_position[0][2]); + CTX.light_position[0][1], + CTX.light_position[0][2]); } #endif return CTX.light_position[0][0]; @@ -3674,8 +3674,8 @@ double opt_general_light01(OPT_ARGS_NUM) if(WID && (action & GMSH_GUI)){ WID->gen_value[3]->value(CTX.light_position[0][1]); WID->gen_sphere->setValue(CTX.light_position[0][0], - CTX.light_position[0][1], - CTX.light_position[0][2]); + CTX.light_position[0][1], + CTX.light_position[0][2]); } #endif return CTX.light_position[0][1]; @@ -3689,8 +3689,8 @@ double opt_general_light02(OPT_ARGS_NUM) if(WID && (action & GMSH_GUI)){ WID->gen_value[4]->value(CTX.light_position[0][2]); WID->gen_sphere->setValue(CTX.light_position[0][0], - CTX.light_position[0][1], - CTX.light_position[0][2]); + CTX.light_position[0][1], + CTX.light_position[0][2]); } #endif return CTX.light_position[0][2]; @@ -5049,7 +5049,7 @@ double opt_mesh_use_cut_plane(OPT_ARGS_NUM) if(WID){ double val1 = 0; for(int i = 0; i < 3; i++) - val1 = std::max(val1, std::max(fabs(CTX.min[i]), fabs(CTX.max[i]))); + val1 = std::max(val1, std::max(fabs(CTX.min[i]), fabs(CTX.max[i]))); val1 *= 1.5; WID->mesh_value[17]->step(val1/200.); WID->mesh_value[17]->minimum(-val1); @@ -5992,8 +5992,8 @@ double opt_view_max_recursion_level(OPT_ARGS_NUM) if(data && data->isAdaptive()){ PViewDataList *l = dynamic_cast<PViewDataList*>(data); if(l){ - l->adaptive->setGlobalResolutionLevel(l, opt->MaxRecursionLevel); - view->setChanged(true); + l->adaptive->setGlobalResolutionLevel(l, opt->MaxRecursionLevel); + view->setChanged(true); } } } @@ -6014,8 +6014,8 @@ double opt_view_target_error(OPT_ARGS_NUM) if(data && data->isAdaptive()){ PViewDataList *l = dynamic_cast<PViewDataList*>(data); if(l){ - l->adaptive->setTolerance(opt->TargetError); - view->setChanged(true); + l->adaptive->setTolerance(opt->TargetError); + view->setChanged(true); } } } @@ -7204,14 +7204,14 @@ double opt_print_tex_as_equation(OPT_ARGS_NUM) #if defined(HAVE_FLTK) -#define CCC(col,but) \ - if(WID && (action & GMSH_GUI)){ \ - Fl_Color c = fl_color_cube(CTX.UNPACK_RED(col)*FL_NUM_RED/256, \ - CTX.UNPACK_GREEN(col)*FL_NUM_GREEN/256, \ - CTX.UNPACK_BLUE(col)*FL_NUM_BLUE/256); \ - (but)->color(c); \ - (but)->labelcolor(fl_contrast(FL_BLACK,c)); \ - (but)->redraw(); \ +#define CCC(col,but) \ + if(WID && (action & GMSH_GUI)){ \ + Fl_Color c = fl_color_cube(CTX.UNPACK_RED(col)*FL_NUM_RED/256, \ + CTX.UNPACK_GREEN(col)*FL_NUM_GREEN/256, \ + CTX.UNPACK_BLUE(col)*FL_NUM_BLUE/256); \ + (but)->color(c); \ + (but)->labelcolor(fl_contrast(FL_BLACK,c)); \ + (but)->redraw(); \ } #endif diff --git a/Common/Options.h b/Common/Options.h index ce63a6ef56f094338a8fd066c817e0b2e858874b..b9e499fc268caabadf7bfa746fbaf796d9da4081 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -798,11 +798,11 @@ void * Get_NumberOption(const char *str, StringXNumber s[]); void * Get_ColorOption(const char *str, StringXColor s[]); void Print_StringOptions(int num, int level, int diff, int help, - StringXString s[], const char *prefix, FILE *file); + StringXString s[], const char *prefix, FILE *file); void Print_NumberOptions(int num, int level, int diff, int help, - StringXNumber s[], const char *prefix, FILE *file); + StringXNumber s[], const char *prefix, FILE *file); void Print_ColorOptions(int num, int level, int diff, int help, - StringXColor s[], const char *prefix, FILE *file); + StringXColor s[], const char *prefix, FILE *file); void Print_StringOptionsDoc(StringXString s[], const char *prefix, FILE * file); void Print_NumberOptionsDoc(StringXNumber s[], const char *prefix, FILE * file); diff --git a/Common/ShapeFunctions.h b/Common/ShapeFunctions.h index 6efb121b37791ee23971bbf37d3687c0e13e9c4e..43bc45dbe91ac82d006ba3d0e48b50d2ef74c6a5 100644 --- a/Common/ShapeFunctions.h +++ b/Common/ShapeFunctions.h @@ -49,49 +49,49 @@ public: switch(getDimension()){ case 3 : for(int i = 0; i < getNumNodes(); i++) { - getGradShapeFunction(i, u, v, w, s); - jac[0][0] += _x[i] * s[0]; jac[0][1] += _y[i] * s[0]; jac[0][2] += _z[i] * s[0]; - jac[1][0] += _x[i] * s[1]; jac[1][1] += _y[i] * s[1]; jac[1][2] += _z[i] * s[1]; - jac[2][0] += _x[i] * s[2]; jac[2][1] += _y[i] * s[2]; jac[2][2] += _z[i] * s[2]; + getGradShapeFunction(i, u, v, w, s); + jac[0][0] += _x[i] * s[0]; jac[0][1] += _y[i] * s[0]; jac[0][2] += _z[i] * s[0]; + jac[1][0] += _x[i] * s[1]; jac[1][1] += _y[i] * s[1]; jac[1][2] += _z[i] * s[1]; + jac[2][0] += _x[i] * s[2]; jac[2][1] += _y[i] * s[2]; jac[2][2] += _z[i] * s[2]; } return fabs( - jac[0][0] * jac[1][1] * jac[2][2] + jac[0][2] * jac[1][0] * jac[2][1] + - jac[0][1] * jac[1][2] * jac[2][0] - jac[0][2] * jac[1][1] * jac[2][0] - - jac[0][0] * jac[1][2] * jac[2][1] - jac[0][1] * jac[1][0] * jac[2][2]); + jac[0][0] * jac[1][1] * jac[2][2] + jac[0][2] * jac[1][0] * jac[2][1] + + jac[0][1] * jac[1][2] * jac[2][0] - jac[0][2] * jac[1][1] * jac[2][0] - + jac[0][0] * jac[1][2] * jac[2][1] - jac[0][1] * jac[1][0] * jac[2][2]); case 2 : for(int i = 0; i < getNumNodes(); i++) { - getGradShapeFunction(i, u, v, w, s); - jac[0][0] += _x[i] * s[0]; jac[0][1] += _y[i] * s[0]; jac[0][2] += _z[i] * s[0]; - jac[1][0] += _x[i] * s[1]; jac[1][1] += _y[i] * s[1]; jac[1][2] += _z[i] * s[1]; + getGradShapeFunction(i, u, v, w, s); + jac[0][0] += _x[i] * s[0]; jac[0][1] += _y[i] * s[0]; jac[0][2] += _z[i] * s[0]; + jac[1][0] += _x[i] * s[1]; jac[1][1] += _y[i] * s[1]; jac[1][2] += _z[i] * s[1]; } { - double a[3], b[3], c[3]; - a[0]= _x[1] - _x[0]; a[1]= _y[1] - _y[0]; a[2]= _z[1] - _z[0]; - b[0]= _x[2] - _x[0]; b[1]= _y[2] - _y[0]; b[2]= _z[2] - _z[0]; - prodve(a, b, c); - jac[2][0] = c[0]; jac[2][1] = c[1]; jac[2][2] = c[2]; + double a[3], b[3], c[3]; + a[0]= _x[1] - _x[0]; a[1]= _y[1] - _y[0]; a[2]= _z[1] - _z[0]; + b[0]= _x[2] - _x[0]; b[1]= _y[2] - _y[0]; b[2]= _z[2] - _z[0]; + prodve(a, b, c); + jac[2][0] = c[0]; jac[2][1] = c[1]; jac[2][2] = c[2]; } return sqrt(SQR(jac[0][0] * jac[1][1] - jac[0][1] * jac[1][0]) + - SQR(jac[0][2] * jac[1][0] - jac[0][0] * jac[1][2]) + - SQR(jac[0][1] * jac[1][2] - jac[0][2] * jac[1][1])); + SQR(jac[0][2] * jac[1][0] - jac[0][0] * jac[1][2]) + + SQR(jac[0][1] * jac[1][2] - jac[0][2] * jac[1][1])); case 1: for(int i = 0; i < getNumNodes(); i++) { - getGradShapeFunction(i, u, v, w, s); - jac[0][0] += _x[i] * s[0]; jac[0][1] += _y[i] * s[0]; jac[0][2] += _z[i] * s[0]; + getGradShapeFunction(i, u, v, w, s); + jac[0][0] += _x[i] * s[0]; jac[0][1] += _y[i] * s[0]; jac[0][2] += _z[i] * s[0]; } { - double a[3], b[3], c[3]; - a[0]= _x[1] - _x[0]; a[1]= _y[1] - _y[0]; a[2]= _z[1] - _z[0]; - if((fabs(a[0]) >= fabs(a[1]) && fabs(a[0]) >= fabs(a[2])) || - (fabs(a[1]) >= fabs(a[0]) && fabs(a[1]) >= fabs(a[2]))) { - b[0] = a[1]; b[1] = -a[0]; b[2] = 0.; - } - else { - b[0] = 0.; b[1] = a[2]; b[2] = -a[1]; - } - prodve(a, b, c); - jac[1][0] = b[0]; jac[1][1] = b[1]; jac[1][2] = b[2]; - jac[2][0] = c[0]; jac[2][1] = c[1]; jac[2][2] = c[2]; + double a[3], b[3], c[3]; + a[0]= _x[1] - _x[0]; a[1]= _y[1] - _y[0]; a[2]= _z[1] - _z[0]; + if((fabs(a[0]) >= fabs(a[1]) && fabs(a[0]) >= fabs(a[2])) || + (fabs(a[1]) >= fabs(a[0]) && fabs(a[1]) >= fabs(a[2]))) { + b[0] = a[1]; b[1] = -a[0]; b[2] = 0.; + } + else { + b[0] = 0.; b[1] = a[2]; b[2] = -a[1]; + } + prodve(a, b, c); + jac[1][0] = b[0]; jac[1][1] = b[1]; jac[1][2] = b[2]; + jac[2][0] = c[0]; jac[2][1] = c[1]; jac[2][2] = c[2]; } return sqrt(SQR(jac[0][0])+SQR(jac[0][1])+SQR(jac[0][2])); default: @@ -111,7 +111,7 @@ public: return sum; } void interpolateGrad(double val[], double u, double v, double w, double f[3], int stride=1, - double invjac[3][3]=NULL) + double invjac[3][3]=NULL) { double dfdu[3] = {0., 0., 0.}; int j = 0; @@ -175,7 +175,7 @@ public: double sum = 0, sumabs = 0.; for(int i = 0; i < getNumNodes(); i++){ sum += val[i]; - sumabs += fabs(val[i]); + sumabs += fabs(val[i]); } double res = 0.; if(sumabs) @@ -205,24 +205,24 @@ public: while (error > tol && iter < maxiter){ double jac[3][3]; if(!getJacobian(uvw[0], uvw[1], uvw[2], jac)) break; - + double xn = 0., yn = 0., zn = 0.; for (int i = 0; i < getNumNodes(); i++) { - double s; - getShapeFunction(i, uvw[0], uvw[1], uvw[2], s); - xn += _x[i] * s; - yn += _y[i] * s; - zn += _z[i] * s; + double s; + getShapeFunction(i, uvw[0], uvw[1], uvw[2], s); + xn += _x[i] * s; + yn += _y[i] * s; + zn += _z[i] * s; } double inv[3][3]; inv3x3(jac, inv); double un = uvw[0] + - inv[0][0] * (xyz[0] - xn) + inv[1][0] * (xyz[1] - yn) + inv[2][0] * (xyz[2] - zn); + inv[0][0] * (xyz[0] - xn) + inv[1][0] * (xyz[1] - yn) + inv[2][0] * (xyz[2] - zn); double vn = uvw[1] + - inv[0][1] * (xyz[0] - xn) + inv[1][1] * (xyz[1] - yn) + inv[2][1] * (xyz[2] - zn) ; + inv[0][1] * (xyz[0] - xn) + inv[1][1] * (xyz[1] - yn) + inv[2][1] * (xyz[2] - zn) ; double wn = uvw[2] + - inv[0][2] * (xyz[0] - xn) + inv[1][2] * (xyz[1] - yn) + inv[2][2] * (xyz[2] - zn) ; + inv[0][2] * (xyz[0] - xn) + inv[1][2] * (xyz[1] - yn) + inv[2][2] * (xyz[2] - zn) ; error = sqrt(SQR(un - uvw[0]) + SQR(vn - uvw[1]) + SQR(wn - uvw[2])); uvw[0] = un; @@ -649,13 +649,13 @@ public: void getGaussPoint(int num, double &u, double &v, double &w, double &weight) { double u6[6] = { 0.40824826, 0.40824826, -0.40824826, - -0.40824826, -0.81649658, 0.81649658}; + -0.40824826, -0.81649658, 0.81649658}; double v6[6] = { 0.70710678, -0.70710678, 0.70710678, - -0.70710678, 0., 0.}; + -0.70710678, 0., 0.}; double w6[6] = {-0.57735027, -0.57735027, 0.57735027, - 0.57735027, -0.57735027, 0.57735027}; + 0.57735027, -0.57735027, 0.57735027}; double p6[6] = { 1.3333333333, 1.3333333333, 1.3333333333, - 1.3333333333, 1.3333333333, 1.3333333333}; + 1.3333333333, 1.3333333333, 1.3333333333}; if(num < 0 || num > 5) return; u = u6[num]; v = v6[num]; @@ -751,13 +751,13 @@ public: void getGaussPoint(int num, double &u, double &v, double &w, double &weight) { double u6[6] = {0.166666666666666, 0.333333333333333, 0.166666666666666, - 0.166666666666666, 0.333333333333333, 0.166666666666666}; + 0.166666666666666, 0.333333333333333, 0.166666666666666}; double v6[6] = {0.166666666666666, 0.166666666666666, 0.333333333333333, - 0.166666666666666, 0.166666666666666, 0.333333333333333}; + 0.166666666666666, 0.166666666666666, 0.333333333333333}; double w6[6] = {-0.577350269189, -0.577350269189, -0.577350269189, - 0.577350269189, 0.577350269189, 0.577350269189}; + 0.577350269189, 0.577350269189, 0.577350269189}; double p6[6] = {0.166666666666666,0.166666666666666,0.166666666666666, - 0.166666666666666,0.166666666666666,0.166666666666666,}; + 0.166666666666666,0.166666666666666,0.166666666666666,}; if(num < 0 || num > 5) return; u = u6[num]; v = v6[num]; @@ -843,21 +843,21 @@ public: void getGaussPoint(int num, double &u, double &v, double &w, double &weight) { double u8[8] = {0.3595161057791018,0.09633205020967324, - 0.3595161057791018,0.09633205020967324, - 0.6920507403468987,0.1854344369976602, - 0.6920507403468987,0.1854344369976602}; + 0.3595161057791018,0.09633205020967324, + 0.6920507403468987,0.1854344369976602, + 0.6920507403468987,0.1854344369976602}; double v8[8] = {0.3595161057791018,0.3595161057791018, - 0.09633205020967324,0.09633205020967324, - 0.6920507403468987,0.6920507403468987, - 0.1854344369976602,0.1854344369976602}; + 0.09633205020967324,0.09633205020967324, + 0.6920507403468987,0.6920507403468987, + 0.1854344369976602,0.1854344369976602}; double w8[8] = {0.544151844011225,0.544151844011225, - 0.544151844011225,0.544151844011225, - 0.122514822655441,0.122514822655441, - 0.122514822655441,0.122514822655441}; + 0.544151844011225,0.544151844011225, + 0.122514822655441,0.122514822655441, + 0.122514822655441,0.122514822655441}; double p8[8] = {0.02519647051995625,0.02519647051995625, - 0.02519647051995625,0.02519647051995625, - 0.058136862813377,0.058136862813377, - 0.058136862813377,0.058136862813377}; + 0.02519647051995625,0.02519647051995625, + 0.058136862813377,0.058136862813377, + 0.058136862813377,0.058136862813377}; if(num < 0 || num > 7) return; u = u8[num]; v = v8[num]; @@ -888,11 +888,11 @@ public: else{ switch(num) { case 0 : s[0] = 0.25 * ( -(1.-v) + v*w/(1.-w) ) ; - s[1] = 0.25 * ( -(1.-u) + u*w/(1.-w) ) ; - s[2] = 0.25 * ( -1. + u*v/SQR(1.-w) ) ; break ; + s[1] = 0.25 * ( -(1.-u) + u*w/(1.-w) ) ; + s[2] = 0.25 * ( -1. + u*v/SQR(1.-w) ) ; break ; case 1 : s[0] = 0.25 * ( (1.-v) + v*w/(1.-w) ) ; - s[1] = 0.25 * ( -(1.+u) + u*w/(1.-w) ) ; - s[2] = 0.25 * ( -1. + u*v/SQR(1.-w) ) ; break ; + s[1] = 0.25 * ( -(1.+u) + u*w/(1.-w) ) ; + s[2] = 0.25 * ( -1. + u*v/SQR(1.-w) ) ; break ; case 2 : s[0] = 0.25 * ( (1.+v) + v*w/(1.-w) ) ; s[1] = 0.25 * ( (1.+u) + u*w/(1.-w) ) ; s[2] = 0.25 * ( -1. + u*v/SQR(1.-w) ) ; break ; diff --git a/Common/SmoothData.cpp b/Common/SmoothData.cpp index 1ee308dfbab62f0888bc9dc0330664eb5460806c..bfdd77d47b3f9981e54fb2499f40957cec125c2e 100644 --- a/Common/SmoothData.cpp +++ b/Common/SmoothData.cpp @@ -1,4 +1,4 @@ -// $Id: SmoothData.cpp,v 1.5 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: SmoothData.cpp,v 1.6 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -51,7 +51,7 @@ xyzv &xyzv::operator = (const xyzv &other) if(other.vals && other.nbvals) { vals = new double[other.nbvals]; for(int i = 0; i < nbvals; i++) - vals[i] = other.vals[i]; + vals[i] = other.vals[i]; } } return *this; @@ -121,11 +121,11 @@ bool smooth_data::exportview(std::string filename) switch(it->nbvals){ case 1: fprintf(fp, "SP(%.16g,%.16g,%.16g){%.16g};\n", - it->x, it->y, it->z, it->vals[0]); + it->x, it->y, it->z, it->vals[0]); break; case 3: fprintf(fp, "VP(%.16g,%.16g,%.16g){%.16g,%.16g,%.16g};\n", - it->x, it->y, it->z, it->vals[0], it->vals[1], it->vals[2]); + it->x, it->y, it->z, it->vals[0], it->vals[1], it->vals[2]); break; } it++; @@ -144,11 +144,11 @@ float xyzn::angle(int i, char nx, char ny, char nz) // returns the angle (in [-180,180]) between the ith normal stored // at point xyz and the new normal nx,ny,nz double a[3] = {char2float(n[i].nx), - char2float(n[i].ny), - char2float(n[i].nz)}; + char2float(n[i].ny), + char2float(n[i].nz)}; double b[3] = {char2float(nx), - char2float(ny), - char2float(nz)}; + char2float(ny), + char2float(nz)}; norme(a); norme(b); double c[3]; @@ -175,12 +175,12 @@ void xyzn::update(char nx, char ny, char nz, float tol) // just ignore it if we have more than 100 contributions to a // single point... if(n[i].nb < 100){ - float c1 = (float)(n[i].nb) / (float)(n[i].nb + 1); - float c2 = 1. / (float)(n[i].nb + 1); - n[i].nx = (char)(c1 * n[i].nx + c2 * nx); - n[i].ny = (char)(c1 * n[i].ny + c2 * ny); - n[i].nz = (char)(c1 * n[i].nz + c2 * nz); - n[i].nb++; + float c1 = (float)(n[i].nb) / (float)(n[i].nb + 1); + float c2 = 1. / (float)(n[i].nb + 1); + n[i].nx = (char)(c1 * n[i].nx + c2 * nx); + n[i].ny = (char)(c1 * n[i].ny + c2 * ny); + n[i].nz = (char)(c1 * n[i].nz + c2 * nz); + n[i].nb++; } return; } @@ -192,7 +192,7 @@ void xyzn::update(char nx, char ny, char nz, float tol) } void smooth_normals::add(double x, double y, double z, - double nx, double ny, double nz) + double nx, double ny, double nz) { xyzn xyz(x, y, z); std::set<xyzn, lessthanxyzn>::const_iterator it = c.find(xyz); @@ -209,7 +209,7 @@ void smooth_normals::add(double x, double y, double z, } bool smooth_normals::get(double x, double y, double z, - double &nx, double &ny, double &nz) + double &nx, double &ny, double &nz) { std::set<xyzn, lessthanxyzn>::const_iterator it = c.find(xyzn(x, y, z)); if(it == c.end()) diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index 2e9f59083672b8899d1ba6fbe3133ea5cc124665..04d1187e20abffa37cf1113dd78dcc0464dfbca1 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -1,4 +1,4 @@ -// $Id: StringUtils.cpp,v 1.1 2008-03-10 16:01:15 geuzaine Exp $ +// $Id: StringUtils.cpp,v 1.2 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -62,8 +62,8 @@ std::string sanitizeTeXString(const char *in, int equation) while(*in){ for(unsigned int i = 0; i < sizeof(bad); i++){ if(*in == bad[i]){ - out.push_back('\\'); - break; + out.push_back('\\'); + break; } } out.push_back(*in++); diff --git a/Common/VertexArray.cpp b/Common/VertexArray.cpp index 005d7fb2896737346dd5da5a92e333059510107d..8c30daada5104ca5384b52e51b8801dfa576f348 100644 --- a/Common/VertexArray.cpp +++ b/Common/VertexArray.cpp @@ -1,4 +1,4 @@ -// $Id: VertexArray.cpp,v 1.29 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: VertexArray.cpp,v 1.30 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -72,7 +72,7 @@ void VertexArray::addElement(MElement *ele) } void VertexArray::add(double *x, double *y, double *z, SVector3 *n, - unsigned int *col, MElement *ele, bool unique, bool boundary) + unsigned int *col, MElement *ele, bool unique, bool boundary) { int npe = getNumVerticesPerElement(); @@ -109,10 +109,10 @@ void VertexArray::finalize() std::set<ElementData<3>, ElementDataLessThan<3> >::iterator it = _data3.begin(); for(; it != _data3.end(); it++){ for(int i = 0; i < 3; i++){ - addVertex(it->x(i), it->y(i), it->z(i)); - addNormal(it->nx(i), it->ny(i), it->nz(i)); - addColor(it->col(i)); - addElement(it->ele()); + addVertex(it->x(i), it->y(i), it->z(i)); + addNormal(it->nx(i), it->ny(i), it->nz(i)); + addColor(it->col(i)); + addElement(it->ele()); } } _data3.clear(); @@ -174,13 +174,13 @@ void VertexArray::sort(double x, double y, double z) if(_normals.size()) for(int i = 0; i < n; i++) elements.push_back(AlphaElement(&_vertices[3 * npe * i], - &_normals[3 * npe * i], - &_colors[4 * npe * i])); + &_normals[3 * npe * i], + &_colors[4 * npe * i])); else for(int i = 0; i < n; i++) elements.push_back(AlphaElement(&_vertices[3 * npe * i], - 0, - &_colors[4 * npe * i])); + 0, + &_colors[4 * npe * i])); std::sort(elements.begin(), elements.end(), AlphaElementLessThan()); @@ -194,12 +194,12 @@ void VertexArray::sort(double x, double y, double z) for(int i = 0; i < n; i++){ for(int j = 0; j < npe; j++){ for(int k = 0; k < 3; k++){ - sortedVertices.push_back(elements[i].v[3 * j + k]); - if(elements[i].v) - sortedNormals.push_back(elements[i].n[3 * j + k]); + sortedVertices.push_back(elements[i].v[3 * j + k]); + if(elements[i].v) + sortedNormals.push_back(elements[i].n[3 * j + k]); } for(int k = 0; k < 4; k++){ - sortedColors.push_back(elements[i].c[4 * j + k]); + sortedColors.push_back(elements[i].c[4 * j + k]); } } } diff --git a/Common/VertexArray.h b/Common/VertexArray.h index c763f811e3e6884a72c97554e78b2ebbde6e3dc0..fe33e55a9bd3d91884fffa8a7ac45e6287fa5514 100644 --- a/Common/VertexArray.h +++ b/Common/VertexArray.h @@ -37,23 +37,23 @@ class ElementData { MElement *_ele; public: ElementData(double *x, double *y, double *z, SVector3 *n, unsigned int *col, - MElement *ele) + MElement *ele) { for(int i = 0; i < N; i++){ _x[i] = x[i]; _y[i] = y[i]; _z[i] = z[i]; if(n){ - _nx[i] = n[i].x(); - _ny[i] = n[i].y(); - _nz[i] = n[i].z(); + _nx[i] = n[i].x(); + _ny[i] = n[i].y(); + _nz[i] = n[i].z(); } else - _nx[i] = _ny[i] = _nz[i] = 0.; + _nx[i] = _ny[i] = _nz[i] = 0.; if(col) - _col[i] = col[i]; + _col[i] = col[i]; else - _col[i] = 0; + _col[i] = 0; } _ele = ele; } @@ -157,7 +157,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, bool boundary=false); + 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/Common/Visibility.cpp b/Common/Visibility.cpp index fed0647a9c8a34b8620a8254b847560a7c079ef9..42a0f00985afe8b9467d453a1a7bd538a29b709a 100644 --- a/Common/Visibility.cpp +++ b/Common/Visibility.cpp @@ -1,4 +1,4 @@ -// $Id: Visibility.cpp,v 1.31 2008-02-22 09:12:10 geuzaine Exp $ +// $Id: Visibility.cpp,v 1.32 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -38,12 +38,12 @@ class VisLessThan{ case -2: return v1->getTag() > v2->getTag() ? true : false; case 3: return strcmp(VisibilityManager::instance()->getLabel(v1->getTag()).c_str(), - VisibilityManager::instance()->getLabel(v2->getTag()).c_str()) < 0 ? - true : false; + VisibilityManager::instance()->getLabel(v2->getTag()).c_str()) < 0 ? + true : false; default: return strcmp(VisibilityManager::instance()->getLabel(v1->getTag()).c_str(), - VisibilityManager::instance()->getLabel(v2->getTag()).c_str()) > 0 ? - true : false; + VisibilityManager::instance()->getLabel(v2->getTag()).c_str()) > 0 ? + true : false; } } }; @@ -95,7 +95,7 @@ void VisibilityManager::update(int type) for(int i = 0; i < 4; i++){ std::map<int, std::vector<GEntity*> >::const_iterator it = groups[i].begin(); for(; it != groups[i].end(); ++it) - _entities.push_back(new VisPhysical(it->first, i, it->second)); + _entities.push_back(new VisPhysical(it->first, i, it->second)); } } else if(type == 2){ // partitions @@ -133,7 +133,7 @@ std::string VisibilityManager::getBrowserLine(int n) bool label_exists = _labels.count(tag); const char *label_color = (label_exists && _labels[tag].second) ? "@b" : ""; sprintf(str, "\t%s\t%d\t%s%s", _entities[n]->getName().c_str(), tag, - label_color, label_exists ? _labels[tag].first.c_str() : ""); + label_color, label_exists ? _labels[tag].first.c_str() : ""); return std::string(str); } @@ -185,9 +185,9 @@ std::string VisibilityManager::getStringForGEO() str += labels[i]; str += "{"; for(unsigned int j = 0; j < state[i][mode].size(); j++){ - if(j) str += ","; - sprintf(tmp, "%d", state[i][mode][j]); - str += tmp; + if(j) str += ","; + sprintf(tmp, "%d", state[i][mode][j]); + str += tmp; } str += "};\n"; } @@ -206,48 +206,48 @@ void VisibilityManager::setVisibilityByNumber(int type, int num, char val, bool case 0: // nodes for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) - if(all || (*it)->mesh_vertices[i]->getNum() == num) - (*it)->mesh_vertices[i]->setVisibility(val); + if(all || (*it)->mesh_vertices[i]->getNum() == num) + (*it)->mesh_vertices[i]->setVisibility(val); for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) - if(all || (*it)->mesh_vertices[i]->getNum() == num) - (*it)->mesh_vertices[i]->setVisibility(val); + if(all || (*it)->mesh_vertices[i]->getNum() == num) + (*it)->mesh_vertices[i]->setVisibility(val); for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) - if(all || (*it)->mesh_vertices[i]->getNum() == num) - (*it)->mesh_vertices[i]->setVisibility(val); + if(all || (*it)->mesh_vertices[i]->getNum() == num) + (*it)->mesh_vertices[i]->setVisibility(val); for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) - if(all || (*it)->mesh_vertices[i]->getNum() == num) - (*it)->mesh_vertices[i]->setVisibility(val); + if(all || (*it)->mesh_vertices[i]->getNum() == num) + (*it)->mesh_vertices[i]->setVisibility(val); break; case 1: // elements for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++){ for(unsigned int i = 0; i < (*it)->lines.size(); i++) - if(all || (*it)->lines[i]->getNum() == num) - (*it)->lines[i]->setVisibility(val); + if(all || (*it)->lines[i]->getNum() == num) + (*it)->lines[i]->setVisibility(val); } for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - if(all || (*it)->triangles[i]->getNum() == num) - (*it)->triangles[i]->setVisibility(val); + if(all || (*it)->triangles[i]->getNum() == num) + (*it)->triangles[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - if(all || (*it)->quadrangles[i]->getNum() == num) - (*it)->quadrangles[i]->setVisibility(val); + if(all || (*it)->quadrangles[i]->getNum() == num) + (*it)->quadrangles[i]->setVisibility(val); } for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){ for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) - if(all || (*it)->tetrahedra[i]->getNum() == num) - (*it)->tetrahedra[i]->setVisibility(val); + if(all || (*it)->tetrahedra[i]->getNum() == num) + (*it)->tetrahedra[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) - if(all || (*it)->hexahedra[i]->getNum() == num) - (*it)->hexahedra[i]->setVisibility(val); + if(all || (*it)->hexahedra[i]->getNum() == num) + (*it)->hexahedra[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->prisms.size(); i++) - if(all || (*it)->prisms[i]->getNum() == num) - (*it)->prisms[i]->setVisibility(val); + if(all || (*it)->prisms[i]->getNum() == num) + (*it)->prisms[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) - if(all || (*it)->pyramids[i]->getNum() == num) - (*it)->pyramids[i]->setVisibility(val); + if(all || (*it)->pyramids[i]->getNum() == num) + (*it)->pyramids[i]->setVisibility(val); } break; case 2: // point @@ -269,22 +269,22 @@ void VisibilityManager::setVisibilityByNumber(int type, int num, char val, bool case 6: // physical point for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++) for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); + if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); break; case 7: // physical line for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++) for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); + if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); break; case 8: // physical surface for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); + if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); break; case 9: // physical volume for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++) for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); + if (all || std::abs((*it)->physicals[i]) == num) (*it)->setVisibility(val, recursive); break; } } @@ -309,28 +309,28 @@ void VisPartition::setVisibility(char val, bool recursive) for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++){ for(unsigned int i = 0; i < (*it)->lines.size(); i++) if((*it)->lines[i]->getPartition() == _tag) - (*it)->lines[i]->setVisibility(val); + (*it)->lines[i]->setVisibility(val); } for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) if((*it)->triangles[i]->getPartition() == _tag) - (*it)->triangles[i]->setVisibility(val); + (*it)->triangles[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) if((*it)->quadrangles[i]->getPartition() == _tag) - (*it)->quadrangles[i]->setVisibility(val); + (*it)->quadrangles[i]->setVisibility(val); } for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){ for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) if((*it)->tetrahedra[i]->getPartition() == _tag) - (*it)->tetrahedra[i]->setVisibility(val); + (*it)->tetrahedra[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) if((*it)->hexahedra[i]->getPartition() == _tag) - (*it)->hexahedra[i]->setVisibility(val); + (*it)->hexahedra[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->prisms.size(); i++) if((*it)->prisms[i]->getPartition() == _tag) - (*it)->prisms[i]->setVisibility(val); + (*it)->prisms[i]->setVisibility(val); for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) if((*it)->pyramids[i]->getPartition() == _tag) - (*it)->pyramids[i]->setVisibility(val); + (*it)->pyramids[i]->setVisibility(val); } } diff --git a/DataStr/List.cpp b/DataStr/List.cpp index ec444ff23ae27f88367fb70a326dd91d10e47ad6..9b4dfe014a5f037012cc244e36f4aa3f1a751177 100644 --- a/DataStr/List.cpp +++ b/DataStr/List.cpp @@ -1,4 +1,4 @@ -// $Id: List.cpp,v 1.43 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: List.cpp,v 1.44 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -274,7 +274,7 @@ int List_Query(List_T * liste, void *data, } static void *lolofind(void *data, void *array, int n, int size, - int (*fcmp) (const void *a, const void *b)) + int (*fcmp) (const void *a, const void *b)) { char *ptr; int i; @@ -291,7 +291,7 @@ static void *lolofind(void *data, void *array, int n, int size, } int List_LQuery(List_T *liste, void *data, - int (*fcmp)(const void *a, const void *b), int first) + int (*fcmp)(const void *a, const void *b), int first) { char *ptr; @@ -301,8 +301,8 @@ int List_LQuery(List_T *liste, void *data, else { if (startptr != NULL) ptr = (char *) lolofind(data,startptr, - liste->n - (startptr-liste->array)/liste->size, - liste->size,fcmp); + liste->n - (startptr-liste->array)/liste->size, + liste->size,fcmp); else return(0); } @@ -452,37 +452,37 @@ List_T *List_CreateFromFile(int n, int incr, int size, FILE * file, int format, if(size == sizeof(double)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%lf", (double *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } } } else if(size == sizeof(float)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%f", (float *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } } } else if(size == sizeof(int)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%d", (int *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } } } else if(size == sizeof(char)){ for(i = 0; i < n; i++){ - char c = (char)fgetc(file); - if(c == EOF){ - error = 1; - break; - } - else{ - liste->array[i * size] = c; - } + char c = (char)fgetc(file); + if(c == EOF){ + error = 1; + break; + } + else{ + liste->array[i * size] = c; + } } } else{ @@ -532,7 +532,7 @@ void List_WriteToFile(List_T * liste, FILE * file, int format) fprintf(file, " %d", *((int *)&liste->array[i * liste->size])); else if(liste->size == sizeof(char)) for(i = 0; i < n; i++) - fputc(*((char *)&liste->array[i * liste->size]), file); + fputc(*((char *)&liste->array[i * liste->size]), file); else Msg(GERROR, "Bad type of data to write list to file (size = %d)", liste->size); @@ -549,7 +549,7 @@ void List_WriteToFile(List_T * liste, FILE * file, int format) // For backward compatibility purposes: List_T *List_CreateFromFileOld(int n, int incr, int size, FILE * file, int format, - int swap) + int swap) { int i, error = 0; List_T *liste; @@ -566,33 +566,33 @@ List_T *List_CreateFromFileOld(int n, int incr, int size, FILE * file, int forma if(size == sizeof(double)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%lf", (double *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } } } else if(size == sizeof(float)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%f", (float *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } } } else if(size == sizeof(int)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%d", (int *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } } } else if(size == sizeof(char)){ for(i = 0; i < n; i++){ if(!fscanf(file, "%c", (char *)&liste->array[i * size])){ - error = 1; - break; - } + error = 1; + break; + } if(liste->array[i * size] == '^') liste->array[i * size] = '\0'; } diff --git a/DataStr/avl.cpp b/DataStr/avl.cpp index 413f1ac6ee07681bbcd2a71759c157eeeb2956b8..fdd0394f5d02f670492f48353eabd2917478c07a 100644 --- a/DataStr/avl.cpp +++ b/DataStr/avl.cpp @@ -1,4 +1,4 @@ -// $Id: avl.cpp,v 1.9 2008-02-17 08:47:56 geuzaine Exp $ +// $Id: avl.cpp,v 1.10 2008-03-20 11:44:02 geuzaine Exp $ /* * avl package @@ -384,27 +384,27 @@ static int do_check_tree(avl_node *node, if (comp_height != node->height) { (void) printf("Bad height for %p: computed=%d stored=%d\n", - (void*)node, comp_height, node->height); + (void*)node, comp_height, node->height); ++*error; } if (bal > 1 || bal < -1) { (void) printf("Out of balance at node %p, balance = %d\n", - (void*)node, bal); + (void*)node, bal); ++*error; } if (node->left != NIL(avl_node) && (*compar)(node->left->key, node->key) > 0) { (void) printf("Bad ordering between %p and %p", - (void*)node, (void*)node->left); + (void*)node, (void*)node->left); ++*error; } if (node->right != NIL(avl_node) && (*compar)(node->key, node->right->key) > 0) { (void) printf("Bad ordering between %p and %p", - (void*)node, (void*)node->right); + (void*)node, (void*)node->right); ++*error; } diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 5a3721b6b8169f6ea2e695b01783fb9f3093aba0..50156fe3d0ecd65493d695f8a689f266d3e145b9 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.569 2008-03-19 17:26:48 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.570 2008-03-20 11:44:02 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -462,7 +462,7 @@ void status_xyz1p_cb(CALLBACK_ARGS) else if(!strcmp(str, "p")){ // toggle projection mode if(!Fl::event_state(FL_SHIFT)){ opt_general_orthographic(0, GMSH_SET | GMSH_GUI, - !opt_general_orthographic(0, GMSH_GET, 0)); + !opt_general_orthographic(0, GMSH_GET, 0)); } else{ perspective_editor(); @@ -575,10 +575,10 @@ void file_new_cb(CALLBACK_ARGS) std::string name = file_chooser_get_name(1); if(!StatFile(name.c_str())){ if(fl_choice("File '%s' already exists.\n\nDo you want to erase it?", - "Cancel", "Erase", NULL, name.c_str())) - UnlinkFile(name.c_str()); + "Cancel", "Erase", NULL, name.c_str())) + UnlinkFile(name.c_str()); else - goto test; + goto test; } FILE *fp = fopen(name.c_str(), "w"); if(!fp){ @@ -784,13 +784,13 @@ void file_save_as_cb(CALLBACK_ARGS) if(CTX.confirm_overwrite) { if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", NULL, name.c_str())) goto test; } i = file_chooser_get_filter(); if(i >= 0 && i < nbformats){ if(!formats[i].func(name.c_str())) - goto test; + goto test; } else // handle any additional automatic fltk filter _save_auto(name.c_str()); @@ -805,7 +805,7 @@ void file_rename_cb(CALLBACK_ARGS) if(CTX.confirm_overwrite) { if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", NULL, name.c_str())) goto test; } rename(CTX.filename, name.c_str()); @@ -1158,14 +1158,14 @@ void mesh_options_ok_cb(CALLBACK_ARGS) opt_mesh_point_type(0, GMSH_SET, WID->mesh_choice[0]->value()); opt_mesh_algo2d(0, GMSH_SET, - (WID->mesh_choice[2]->value() == 0) ? ALGO_2D_MESHADAPT : - (WID->mesh_choice[2]->value() == 1) ? ALGO_2D_DELAUNAY : - ALGO_2D_MESHADAPT_DELAUNAY); + (WID->mesh_choice[2]->value() == 0) ? ALGO_2D_MESHADAPT : + (WID->mesh_choice[2]->value() == 1) ? ALGO_2D_DELAUNAY : + ALGO_2D_MESHADAPT_DELAUNAY); opt_mesh_algo3d(0, GMSH_SET, - (WID->mesh_choice[3]->value() == 0) ? ALGO_3D_TETGEN_DELAUNAY : - ALGO_3D_NETGEN); + (WID->mesh_choice[3]->value() == 0) ? ALGO_3D_TETGEN_DELAUNAY : + ALGO_3D_NETGEN); opt_mesh_recombine_algo(0, GMSH_SET, - (WID->mesh_choice[5]->value() == 0) ? 1 : 2); + (WID->mesh_choice[5]->value() == 0) ? 1 : 2); opt_mesh_color_carousel(0, GMSH_SET, WID->mesh_choice[4]->value()); opt_mesh_quality_type(0, GMSH_SET, WID->mesh_choice[6]->value()); opt_mesh_label_type(0, GMSH_SET, WID->mesh_choice[7]->value()); @@ -1431,11 +1431,11 @@ void view_options_ok_cb(CALLBACK_ARGS) val = WID->view_choice[0]->value() + 1; if(force || (val != intervals_type)) - opt_view_intervals_type(i, GMSH_SET, val); + opt_view_intervals_type(i, GMSH_SET, val); val = WID->view_choice[5]->value(); if(force || (val != point_type)) - opt_view_point_type(i, GMSH_SET, val); + opt_view_point_type(i, GMSH_SET, val); val = WID->view_choice[6]->value(); if(force || (val != line_type)) @@ -1451,7 +1451,7 @@ void view_options_ok_cb(CALLBACK_ARGS) val = WID->view_choice[4]->value() + 1; if(force || (val != tensor_type)) - opt_view_tensor_type(i, GMSH_SET, val); + opt_view_tensor_type(i, GMSH_SET, val); val = WID->view_choice[7]->value() + 1; if(force || (val != range_type)) @@ -1825,9 +1825,9 @@ void view_options_ok_cb(CALLBACK_ARGS) // through callbacks, we can use the opt_XXX routines directly) if(force || (i != current)){ opt_view_color_points(i, GMSH_SET, opt_view_color_points(current, GMSH_GET, 0)); - opt_view_color_lines(i, GMSH_SET, opt_view_color_lines(current, GMSH_GET, 0)); - opt_view_color_triangles(i, GMSH_SET, opt_view_color_triangles(current, GMSH_GET, 0)); - opt_view_color_quadrangles(i, GMSH_SET, opt_view_color_quadrangles(current, GMSH_GET, 0)); + opt_view_color_lines(i, GMSH_SET, opt_view_color_lines(current, GMSH_GET, 0)); + opt_view_color_triangles(i, GMSH_SET, opt_view_color_triangles(current, GMSH_GET, 0)); + opt_view_color_quadrangles(i, GMSH_SET, opt_view_color_quadrangles(current, GMSH_GET, 0)); opt_view_color_tetrahedra(i, GMSH_SET, opt_view_color_tetrahedra(current, GMSH_GET, 0)); opt_view_color_hexahedra(i, GMSH_SET, opt_view_color_hexahedra(current, GMSH_GET, 0)); opt_view_color_prisms(i, GMSH_SET, opt_view_color_prisms(current, GMSH_GET, 0)); @@ -1844,7 +1844,7 @@ void view_options_ok_cb(CALLBACK_ARGS) if(force || (i != current)) { ColorTable_Copy(&PView::list[current]->getOptions()->CT); ColorTable_Paste(&PView::list[i]->getOptions()->CT); - PView::list[i]->setChanged(true); + PView::list[i]->setChanged(true); } } } @@ -1928,7 +1928,7 @@ void message_save_cb(CALLBACK_ARGS) if(CTX.confirm_overwrite) { if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", NULL, name.c_str())) goto test; } WID->save_message(name.c_str()); @@ -1986,11 +1986,11 @@ void visibility_ok_cb(CALLBACK_ARGS) VisibilityManager::instance()->setAllInvisible(type); for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++) if(WID->vis_browser->selected(i + 1)) - VisibilityManager::instance()->setVisibility(i, 1, recursive); + VisibilityManager::instance()->setVisibility(i, 1, recursive); // then refresh the browser to account for recursive selections for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++) if(VisibilityManager::instance()->getVisibility(i)) - WID->vis_browser->select(i + 1); + WID->vis_browser->select(i + 1); Draw(); } } @@ -2019,8 +2019,8 @@ void visibility_delete_cb(CALLBACK_ARGS) else{ for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++){ if(WID->vis_browser->selected(i + 1)){ - Vis *v = VisibilityManager::instance()->getEntity(i); - GModel::current()->deletePhysicalGroup(v->getDim(), v->getTag()); + Vis *v = VisibilityManager::instance()->getEntity(i); + GModel::current()->deletePhysicalGroup(v->getDim(), v->getTag()); } } } @@ -2070,10 +2070,10 @@ void visibility_sort_cb(CALLBACK_ARGS) else if(val == -2){ // create new parameter name for selection for(int i = 0; i < WID->vis_browser->size(); i++){ if(WID->vis_browser->selected(i + 1)){ - static char tmpstr[256]; - sprintf(tmpstr, "%d", VisibilityManager::instance()->getTag(i)); - WID->context_geometry_input[1]->value(tmpstr); - break; + static char tmpstr[256]; + sprintf(tmpstr, "%d", VisibilityManager::instance()->getTag(i)); + WID->context_geometry_input[1]->value(tmpstr); + break; } } WID->context_geometry_input[0]->value("NewName"); @@ -2121,11 +2121,11 @@ void visibility_number_cb(CALLBACK_ARGS) } static void _apply_visibility(char mode, - std::vector<GVertex*> &vertices, - std::vector<GEdge*> &edges, - std::vector<GFace*> &faces, - std::vector<GRegion*> ®ions, - std::vector<MElement*> &elements) + std::vector<GVertex*> &vertices, + std::vector<GEdge*> &edges, + std::vector<GFace*> &faces, + std::vector<GRegion*> ®ions, + std::vector<MElement*> &elements) { // type = 0 for elementary, 1 for physical and 2 for partitions int type = WID->vis_type->value(); @@ -2137,7 +2137,7 @@ static void _apply_visibility(char mode, VisibilityManager::instance()->setVisibilityByNumber(1, -1, 0, false); else for(int i = 2; i <= 5; i++) - VisibilityManager::instance()->setVisibilityByNumber(i, -1, 0, false); + VisibilityManager::instance()->setVisibilityByNumber(i, -1, 0, false); } if(mode == 2) mode = 1; @@ -2149,35 +2149,35 @@ static void _apply_visibility(char mode, else{ for(unsigned int i = 0; i < vertices.size(); i++){ if(type == 0) - vertices[i]->setVisibility(mode, recursive); + vertices[i]->setVisibility(mode, recursive); else - for(unsigned int j = 0; j < vertices[i]->physicals.size(); j++) - VisibilityManager::instance()->setVisibilityByNumber - (6, vertices[i]->physicals[j], mode, recursive); + for(unsigned int j = 0; j < vertices[i]->physicals.size(); j++) + VisibilityManager::instance()->setVisibilityByNumber + (6, vertices[i]->physicals[j], mode, recursive); } for(unsigned int i = 0; i < edges.size(); i++){ if(type == 0) - edges[i]->setVisibility(mode, recursive); + edges[i]->setVisibility(mode, recursive); else - for(unsigned int j = 0; j < edges[i]->physicals.size(); j++) - VisibilityManager::instance()->setVisibilityByNumber - (7, edges[i]->physicals[j], mode, recursive); + for(unsigned int j = 0; j < edges[i]->physicals.size(); j++) + VisibilityManager::instance()->setVisibilityByNumber + (7, edges[i]->physicals[j], mode, recursive); } for(unsigned int i = 0; i < faces.size(); i++){ if(type == 0) - faces[i]->setVisibility(mode, recursive); + faces[i]->setVisibility(mode, recursive); else - for(unsigned int j = 0; j < faces[i]->physicals.size(); j++) - VisibilityManager::instance()->setVisibilityByNumber - (8, faces[i]->physicals[j], mode, recursive); + for(unsigned int j = 0; j < faces[i]->physicals.size(); j++) + VisibilityManager::instance()->setVisibilityByNumber + (8, faces[i]->physicals[j], mode, recursive); } for(unsigned int i = 0; i < regions.size(); i++){ if(type == 0) - regions[i]->setVisibility(mode, recursive); + regions[i]->setVisibility(mode, recursive); else - for(unsigned int j = 0; j < regions[i]->physicals.size(); j++) - VisibilityManager::instance()->setVisibilityByNumber - (9, regions[i]->physicals[j], mode, recursive); + for(unsigned int j = 0; j < regions[i]->physicals.size(); j++) + VisibilityManager::instance()->setVisibilityByNumber + (9, regions[i]->physicals[j], mode, recursive); } } int pos = WID->vis_browser->position(); @@ -2285,7 +2285,7 @@ void visibility_interactive_cb(CALLBACK_ARGS) CTX.mesh.changed = ENT_ALL; Draw(); Msg(ONSCREEN, "Select %s\n[Press %s'q' to abort]", - help, mode ? "" : "'u' to undo or "); + help, mode ? "" : "'u' to undo or "); char ib = SelectEntity(what, vertices, edges, faces, regions, elements); if(ib == 'l') { @@ -2299,7 +2299,7 @@ void visibility_interactive_cb(CALLBACK_ARGS) } if(ib == 'u' && !mode){ // undo only in hide mode _apply_visibility(2, vertices_old, edges_old, faces_old, - regions_old, elements_old); + regions_old, elements_old); } if(ib == 'q'){ break; @@ -2331,7 +2331,7 @@ void clip_update_cb(CALLBACK_ARGS) CTX.clip[idx] = 0; for(int i = 0; i < WID->clip_browser->size(); i++) if(WID->clip_browser->selected(i+1)) - CTX.clip[idx] += (1<<i); + CTX.clip[idx] += (1<<i); for(int i = 0; i < 4; i++) CTX.clip_plane[idx][i] = WID->clip_value[i]->value(); } @@ -2339,15 +2339,15 @@ void clip_update_cb(CALLBACK_ARGS) for(int idx = 0; idx < 6; idx++){ CTX.clip[idx] = 0; for(int i = 0; i < WID->clip_browser->size(); i++) - if(WID->clip_browser->selected(i+1)) - CTX.clip[idx] += (1<<i); + if(WID->clip_browser->selected(i+1)) + CTX.clip[idx] += (1<<i); } double c[3] = {WID->clip_value[4]->value(), - WID->clip_value[5]->value(), - WID->clip_value[6]->value()}; + WID->clip_value[5]->value(), + WID->clip_value[6]->value()}; double d[3] = {WID->clip_value[7]->value(), - WID->clip_value[8]->value(), - WID->clip_value[9]->value()}; + WID->clip_value[8]->value(), + WID->clip_value[9]->value()}; // left CTX.clip_plane[0][0] = 1.; CTX.clip_plane[0][1] = 0.; CTX.clip_plane[0][2] = 0.; CTX.clip_plane[0][3] = -(c[0] - d[0] / 2.); @@ -2571,13 +2571,13 @@ void _replace_multi_format(const char *in, const char *val, char *out) while(i < strlen(in)){ if(in[i] == '%' && i != strlen(in) - 1){ if(in[i + 1] == 's'){ - strcat(out, val); - i += 2; - j += strlen(val); + strcat(out, val); + i += 2; + j += strlen(val); } else{ - Msg(WARNING, "Skipping unknown format '%%%c' in '%s'", in[i + 1], in); - i += 2; + Msg(WARNING, "Skipping unknown format '%%%c' in '%s'", in[i + 1], in); + i += 2; } } else{ @@ -2690,7 +2690,7 @@ void geometry_elementary_add_new_point_cb(CALLBACK_ARGS) while(1) { WID->g_opengl_window->AddPointMode = true; Msg(ONSCREEN, "Move mouse and/or enter coordinates\n" - "[Press 'Shift' to hold position, 'e' to add point or 'q' to abort]"); + "[Press 'Shift' to hold position, 'e' to add point or 'q' to abort]"); std::vector<GVertex*> vertices; std::vector<GEdge*> edges; std::vector<GFace*> faces; @@ -2699,10 +2699,10 @@ void geometry_elementary_add_new_point_cb(CALLBACK_ARGS) char ib = SelectEntity(ENT_NONE, vertices, edges, faces, regions, elements); if(ib == 'e'){ add_point(CTX.filename, - WID->context_geometry_input[2]->value(), - WID->context_geometry_input[3]->value(), - WID->context_geometry_input[4]->value(), - WID->context_geometry_input[5]->value()); + WID->context_geometry_input[2]->value(), + WID->context_geometry_input[3]->value(), + WID->context_geometry_input[4]->value(), + WID->context_geometry_input[5]->value()); WID->reset_visibility(); Draw(); } @@ -2732,15 +2732,15 @@ static void _new_multiline(int type) while(1) { if(n == 0) Msg(ONSCREEN, "Select control points\n" - "[Press 'e' to end selection or 'q' to abort]"); + "[Press 'e' to end selection or 'q' to abort]"); else Msg(ONSCREEN, "Select control points\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); char ib = SelectEntity(ENT_POINT, vertices, edges, faces, regions, elements); if(ib == 'l') { for(unsigned int i = 0; i < vertices.size(); i++){ - HighlightEntity(vertices[i]); - p[n++] = vertices[i]->tag(); + HighlightEntity(vertices[i]); + p[n++] = vertices[i]->tag(); } Draw(); } @@ -2771,9 +2771,9 @@ static void _new_multiline(int type) } if(ib == 'u') { if(n > 0){ - ZeroHighlightEntityNum(p[n-1], 0, 0, 0); - Draw(); - n--; + ZeroHighlightEntityNum(p[n-1], 0, 0, 0); + Draw(); + n--; } } if(ib == 'q') { @@ -2808,10 +2808,10 @@ void geometry_elementary_add_new_line_cb(CALLBACK_ARGS) while(1) { if(n == 0) Msg(ONSCREEN, "Select start point\n" - "[Press 'q' to abort]"); + "[Press 'q' to abort]"); if(n == 1) Msg(ONSCREEN, "Select end point\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + "[Press 'u' to undo last selection or 'q' to abort]"); char ib = SelectEntity(ENT_POINT, vertices, edges, faces, regions, elements); if(ib == 'l') { HighlightEntity(vertices[0]); @@ -2823,9 +2823,9 @@ void geometry_elementary_add_new_line_cb(CALLBACK_ARGS) } if(ib == 'u') { if(n > 0){ - ZeroHighlightEntityNum(p[n-1], 0, 0, 0); - Draw(); - n--; + ZeroHighlightEntityNum(p[n-1], 0, 0, 0); + Draw(); + n--; } } if(ib == 'q') { @@ -2872,13 +2872,13 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS) while(1) { if(n == 0) Msg(ONSCREEN, "Select start point\n" - "[Press 'q' to abort]"); + "[Press 'q' to abort]"); if(n == 1) Msg(ONSCREEN, "Select center point\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + "[Press 'u' to undo last selection or 'q' to abort]"); if(n == 2) Msg(ONSCREEN, "Select end point\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + "[Press 'u' to undo last selection or 'q' to abort]"); char ib = SelectEntity(ENT_POINT, vertices, edges, faces, regions, elements); if(ib == 'l') { HighlightEntity(vertices[0]); @@ -2890,9 +2890,9 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS) } if(ib == 'u') { if(n > 0){ - ZeroHighlightEntityNum(p[n-1], 0, 0, 0); - Draw(); - n--; + ZeroHighlightEntityNum(p[n-1], 0, 0, 0); + Draw(); + n--; } } if(ib == 'q') { @@ -2929,16 +2929,16 @@ void geometry_elementary_add_new_ellipse_cb(CALLBACK_ARGS) while(1) { if(n == 0) Msg(ONSCREEN, "Select start point\n" - "[Press 'q' to abort]"); + "[Press 'q' to abort]"); if(n == 1) Msg(ONSCREEN, "Select center point\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + "[Press 'u' to undo last selection or 'q' to abort]"); if(n == 2) Msg(ONSCREEN, "Select major axis point\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + "[Press 'u' to undo last selection or 'q' to abort]"); if(n == 3) Msg(ONSCREEN, "Select end point\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + "[Press 'u' to undo last selection or 'q' to abort]"); char ib = SelectEntity(ENT_POINT, vertices, edges, faces, regions, elements); if(ib == 'l') { HighlightEntity(vertices[0]); @@ -2950,9 +2950,9 @@ void geometry_elementary_add_new_ellipse_cb(CALLBACK_ARGS) } if(ib == 'u') { if(n > 0){ - ZeroHighlightEntityNum(p[n-1], 0, 0, 0); - Draw(); - n--; + ZeroHighlightEntityNum(p[n-1], 0, 0, 0); + Draw(); + n--; } } if(ib == 'q') { @@ -3002,20 +3002,20 @@ static void _new_surface_volume(int mode) while(1) { if(type == ENT_LINE){ - if(!List_Nbr(List1)) - Msg(ONSCREEN, "Select surface boundary\n" - "[Press 'q' to abort]"); - else - Msg(ONSCREEN, "Select surface boundary\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + if(!List_Nbr(List1)) + Msg(ONSCREEN, "Select surface boundary\n" + "[Press 'q' to abort]"); + else + Msg(ONSCREEN, "Select surface boundary\n" + "[Press 'u' to undo last selection or 'q' to abort]"); } else{ - if(!List_Nbr(List1)) - Msg(ONSCREEN, "Select volume boundary\n" - "[Press 'q' to abort]"); - else - Msg(ONSCREEN, "Select volume boundary\n" - "[Press 'u' to undo last selection or 'q' to abort]"); + if(!List_Nbr(List1)) + Msg(ONSCREEN, "Select volume boundary\n" + "[Press 'q' to abort]"); + else + Msg(ONSCREEN, "Select volume boundary\n" + "[Press 'u' to undo last selection or 'q' to abort]"); } char ib = SelectEntity(type, vertices, edges, faces, regions, elements); @@ -3025,85 +3025,85 @@ static void _new_surface_volume(int mode) goto stopall; } if(ib == 'u') { - if(List_Nbr(List1) > 0){ - List_Read(List1, List_Nbr(List1)-1, &num); - ZeroHighlightEntityNum(0, - (type == ENT_LINE) ? abs(num) : 0, - (type != ENT_LINE) ? abs(num) : 0, - 0); - List_Pop(List1); - Draw(); - } + if(List_Nbr(List1) > 0){ + List_Read(List1, List_Nbr(List1)-1, &num); + ZeroHighlightEntityNum(0, + (type == ENT_LINE) ? abs(num) : 0, + (type != ENT_LINE) ? abs(num) : 0, + 0); + List_Pop(List1); + Draw(); + } } if(ib == 'r') { - Msg(WARNING, "Entity de-selection not supported yet during surface/volume creation"); + Msg(WARNING, "Entity de-selection not supported yet during surface/volume creation"); } if(ib == 'l') { - int num = (type == ENT_LINE) ? edges[0]->tag() : faces[0]->tag(); - if(SelectContour(type, num, List1)) { - if(type == ENT_LINE) - add_lineloop(List1, CTX.filename, &num); - else - add_surfloop(List1, CTX.filename, &num); - List_Reset(List1); - List_Add(List2, &num); - while(1) { - if(!List_Nbr(List1)) - Msg(ONSCREEN, "Select hole boundaries (if none, press 'e')\n" - "[Press 'e' to end selection or 'q' to abort]"); - else - Msg(ONSCREEN, "Select hole boundaries\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); - ib = SelectEntity(type, vertices, edges, faces, regions, elements); - if(ib == 'q') { - ZeroHighlight(); - Draw(); - goto stopall; - } - if(ib == 'e') { - ZeroHighlight(); - Draw(); - List_Reset(List1); - break; - } - if(ib == 'u') { - if(List_Nbr(List1) > 0){ - List_Read(List1, List_Nbr(List1)-1, &num); - ZeroHighlightEntityNum(0, - (type == ENT_LINE) ? abs(num) : 0, - (type != ENT_LINE) ? abs(num) : 0, - 0); - List_Pop(List1); - Draw(); - } - } - if(ib == 'l') { - num = (type == ENT_LINE) ? edges[0]->tag() : faces[0]->tag(); - if(SelectContour(type, num, List1)) { - if(type == ENT_LINE) - add_lineloop(List1, CTX.filename, &num); - else - add_surfloop(List1, CTX.filename, &num); - List_Reset(List1); - List_Add(List2, &num); - } - } - if(ib == 'r') { - Msg(WARNING, "Entity de-selection not supported yet during surface/volume creation"); - } - } - if(List_Nbr(List2)) { - switch (mode) { - case 0: add_surf(List2, CTX.filename, 0, 2); break; - case 1: add_surf(List2, CTX.filename, 0, 1); break; - case 2: add_vol(List2, CTX.filename); break; - } - WID->reset_visibility(); - ZeroHighlight(); - Draw(); - break; - } - } // if SelectContour + int num = (type == ENT_LINE) ? edges[0]->tag() : faces[0]->tag(); + if(SelectContour(type, num, List1)) { + if(type == ENT_LINE) + add_lineloop(List1, CTX.filename, &num); + else + add_surfloop(List1, CTX.filename, &num); + List_Reset(List1); + List_Add(List2, &num); + while(1) { + if(!List_Nbr(List1)) + Msg(ONSCREEN, "Select hole boundaries (if none, press 'e')\n" + "[Press 'e' to end selection or 'q' to abort]"); + else + Msg(ONSCREEN, "Select hole boundaries\n" + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); + ib = SelectEntity(type, vertices, edges, faces, regions, elements); + if(ib == 'q') { + ZeroHighlight(); + Draw(); + goto stopall; + } + if(ib == 'e') { + ZeroHighlight(); + Draw(); + List_Reset(List1); + break; + } + if(ib == 'u') { + if(List_Nbr(List1) > 0){ + List_Read(List1, List_Nbr(List1)-1, &num); + ZeroHighlightEntityNum(0, + (type == ENT_LINE) ? abs(num) : 0, + (type != ENT_LINE) ? abs(num) : 0, + 0); + List_Pop(List1); + Draw(); + } + } + if(ib == 'l') { + num = (type == ENT_LINE) ? edges[0]->tag() : faces[0]->tag(); + if(SelectContour(type, num, List1)) { + if(type == ENT_LINE) + add_lineloop(List1, CTX.filename, &num); + else + add_surfloop(List1, CTX.filename, &num); + List_Reset(List1); + List_Add(List2, &num); + } + } + if(ib == 'r') { + Msg(WARNING, "Entity de-selection not supported yet during surface/volume creation"); + } + } + if(List_Nbr(List2)) { + switch (mode) { + case 0: add_surf(List2, CTX.filename, 0, 2); break; + case 1: add_surf(List2, CTX.filename, 0, 1); break; + case 2: add_vol(List2, CTX.filename); break; + } + WID->reset_visibility(); + ZeroHighlight(); + Draw(); + break; + } + } // if SelectContour } } } @@ -3175,10 +3175,10 @@ static void _action_point_line_surface_volume(int action, int mode, const char * while(1) { if(!List_Nbr(List1)) Msg(ONSCREEN, "Select %s\n" - "[Press 'e' to end selection or 'q' to abort]", str); + "[Press 'e' to end selection or 'q' to abort]", str); else Msg(ONSCREEN, "Select %s\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]", str); + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]", str); char ib = SelectEntity(type, vertices, edges, faces, regions, elements); if(ib == 'l') { @@ -3188,37 +3188,37 @@ static void _action_point_line_surface_volume(int action, int mode, const char * int tag; switch (type) { case ENT_POINT: - for(unsigned int i = 0; i < vertices.size(); i++){ - HighlightEntity(vertices[i]); - tag = vertices[i]->tag(); - if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) - List_Add(List1, &tag); - } - break; + for(unsigned int i = 0; i < vertices.size(); i++){ + HighlightEntity(vertices[i]); + tag = vertices[i]->tag(); + if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) + List_Add(List1, &tag); + } + break; case ENT_LINE: - for(unsigned int i = 0; i < edges.size(); i++){ - HighlightEntity(edges[i]); - tag = edges[i]->tag(); - if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) - List_Add(List1, &tag); - } - break; + for(unsigned int i = 0; i < edges.size(); i++){ + HighlightEntity(edges[i]); + tag = edges[i]->tag(); + if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) + List_Add(List1, &tag); + } + break; case ENT_SURFACE: - for(unsigned int i = 0; i < faces.size(); i++){ - HighlightEntity(faces[i]); - tag = faces[i]->tag(); - if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) - List_Add(List1, &tag); - } - break; + for(unsigned int i = 0; i < faces.size(); i++){ + HighlightEntity(faces[i]); + tag = faces[i]->tag(); + if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) + List_Add(List1, &tag); + } + break; case ENT_VOLUME: - for(unsigned int i = 0; i < regions.size(); i++){ - HighlightEntity(regions[i]); - tag = regions[i]->tag(); - if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) - List_Add(List1, &tag); - } - break; + for(unsigned int i = 0; i < regions.size(); i++){ + HighlightEntity(regions[i]); + tag = regions[i]->tag(); + if(List_ISearchSeq(List1, &tag, fcmp_int) < 0) + List_Add(List1, &tag); + } + break; } Draw(); } @@ -3229,50 +3229,50 @@ static void _action_point_line_surface_volume(int action, int mode, const char * int index, tag; switch (type) { case ENT_POINT: - for(unsigned int i = 0; i < vertices.size(); i++){ - tag = vertices[i]->tag(); - index = List_ISearchSeq(List1, &tag, fcmp_int); - if(index >= 0) List_PSuppress(List1, index); - ZeroHighlightEntityNum(tag, 0, 0, 0); - } - break; + for(unsigned int i = 0; i < vertices.size(); i++){ + tag = vertices[i]->tag(); + index = List_ISearchSeq(List1, &tag, fcmp_int); + if(index >= 0) List_PSuppress(List1, index); + ZeroHighlightEntityNum(tag, 0, 0, 0); + } + break; case ENT_LINE: - for(unsigned int i = 0; i < edges.size(); i++){ - tag = edges[i]->tag(); - index = List_ISearchSeq(List1, &tag, fcmp_int); - if(index >= 0) List_PSuppress(List1, index); - ZeroHighlightEntityNum(0, tag, 0, 0); - } - break; + for(unsigned int i = 0; i < edges.size(); i++){ + tag = edges[i]->tag(); + index = List_ISearchSeq(List1, &tag, fcmp_int); + if(index >= 0) List_PSuppress(List1, index); + ZeroHighlightEntityNum(0, tag, 0, 0); + } + break; case ENT_SURFACE: - for(unsigned int i = 0; i < faces.size(); i++){ - tag = faces[i]->tag(); - index = List_ISearchSeq(List1, &tag, fcmp_int); - if(index >= 0) List_PSuppress(List1, index); - ZeroHighlightEntityNum(0, 0, tag, 0); - } - break; + for(unsigned int i = 0; i < faces.size(); i++){ + tag = faces[i]->tag(); + index = List_ISearchSeq(List1, &tag, fcmp_int); + if(index >= 0) List_PSuppress(List1, index); + ZeroHighlightEntityNum(0, 0, tag, 0); + } + break; case ENT_VOLUME: - for(unsigned int i = 0; i < regions.size(); i++){ - tag = regions[i]->tag(); - index = List_ISearchSeq(List1, &tag, fcmp_int); - if(index >= 0) List_PSuppress(List1, index); - ZeroHighlightEntityNum(0, 0, 0, tag); - } - break; + for(unsigned int i = 0; i < regions.size(); i++){ + tag = regions[i]->tag(); + index = List_ISearchSeq(List1, &tag, fcmp_int); + if(index >= 0) List_PSuppress(List1, index); + ZeroHighlightEntityNum(0, 0, 0, tag); + } + break; } Draw(); } if(ib == 'u') { if(List_Nbr(List1)) { - int num; - List_Read(List1, List_Nbr(List1) - 1, &num); - ZeroHighlightEntityNum((type == ENT_POINT) ? num : 0, - (type == ENT_LINE) ? num : 0, - (type == ENT_SURFACE) ? num : 0, - (type == ENT_VOLUME) ? num : 0); - Draw(); - List_Pop(List1); + int num; + List_Read(List1, List_Nbr(List1) - 1, &num); + ZeroHighlightEntityNum((type == ENT_POINT) ? num : 0, + (type == ENT_LINE) ? num : 0, + (type == ENT_SURFACE) ? num : 0, + (type == ENT_VOLUME) ? num : 0); + Draw(); + List_Pop(List1); } } if(ib == 'i') { @@ -3280,74 +3280,74 @@ static void _action_point_line_surface_volume(int action, int mode, const char * } if(ib == 'e') { if(List_Nbr(List1)){ - switch (action) { - case 0: - translate(mode, List1, CTX.filename, what, - WID->context_geometry_input[6]->value(), - WID->context_geometry_input[7]->value(), - WID->context_geometry_input[8]->value()); - break; - case 1: - rotate(mode, List1, CTX.filename, what, - WID->context_geometry_input[12]->value(), - WID->context_geometry_input[13]->value(), - WID->context_geometry_input[14]->value(), - WID->context_geometry_input[9]->value(), - WID->context_geometry_input[10]->value(), - WID->context_geometry_input[11]->value(), - WID->context_geometry_input[15]->value()); - break; - case 2: - dilate(mode, List1, CTX.filename, what, - WID->context_geometry_input[16]->value(), - WID->context_geometry_input[17]->value(), - WID->context_geometry_input[18]->value(), - WID->context_geometry_input[19]->value()); - break; - case 3: - symmetry(mode, List1, CTX.filename, what, - WID->context_geometry_input[20]->value(), - WID->context_geometry_input[21]->value(), - WID->context_geometry_input[22]->value(), - WID->context_geometry_input[23]->value()); - break; - case 4: - extrude(List1, CTX.filename, what, - WID->context_geometry_input[6]->value(), - WID->context_geometry_input[7]->value(), - WID->context_geometry_input[8]->value()); - break; - case 5: - protude(List1, CTX.filename, what, - WID->context_geometry_input[12]->value(), - WID->context_geometry_input[13]->value(), - WID->context_geometry_input[14]->value(), - WID->context_geometry_input[9]->value(), - WID->context_geometry_input[10]->value(), - WID->context_geometry_input[11]->value(), - WID->context_geometry_input[15]->value()); - break; - case 6: - delet(List1, CTX.filename, what); - break; - case 7: - add_physical(List1, CTX.filename, type); - break; - case 8: - add_charlength(List1, CTX.filename, WID->context_mesh_input[0]->value()); - break; - case 9: - add_recosurf(List1, CTX.filename); - break; - default: - Msg(GERROR, "Unknown action on selected entities"); - break; - } - List_Reset(List1); - WID->reset_visibility(); - ZeroHighlight(); - if(action <= 6) SetBoundingBox(); - Draw(); + switch (action) { + case 0: + translate(mode, List1, CTX.filename, what, + WID->context_geometry_input[6]->value(), + WID->context_geometry_input[7]->value(), + WID->context_geometry_input[8]->value()); + break; + case 1: + rotate(mode, List1, CTX.filename, what, + WID->context_geometry_input[12]->value(), + WID->context_geometry_input[13]->value(), + WID->context_geometry_input[14]->value(), + WID->context_geometry_input[9]->value(), + WID->context_geometry_input[10]->value(), + WID->context_geometry_input[11]->value(), + WID->context_geometry_input[15]->value()); + break; + case 2: + dilate(mode, List1, CTX.filename, what, + WID->context_geometry_input[16]->value(), + WID->context_geometry_input[17]->value(), + WID->context_geometry_input[18]->value(), + WID->context_geometry_input[19]->value()); + break; + case 3: + symmetry(mode, List1, CTX.filename, what, + WID->context_geometry_input[20]->value(), + WID->context_geometry_input[21]->value(), + WID->context_geometry_input[22]->value(), + WID->context_geometry_input[23]->value()); + break; + case 4: + extrude(List1, CTX.filename, what, + WID->context_geometry_input[6]->value(), + WID->context_geometry_input[7]->value(), + WID->context_geometry_input[8]->value()); + break; + case 5: + protude(List1, CTX.filename, what, + WID->context_geometry_input[12]->value(), + WID->context_geometry_input[13]->value(), + WID->context_geometry_input[14]->value(), + WID->context_geometry_input[9]->value(), + WID->context_geometry_input[10]->value(), + WID->context_geometry_input[11]->value(), + WID->context_geometry_input[15]->value()); + break; + case 6: + delet(List1, CTX.filename, what); + break; + case 7: + add_physical(List1, CTX.filename, type); + break; + case 8: + add_charlength(List1, CTX.filename, WID->context_mesh_input[0]->value()); + break; + case 9: + add_recosurf(List1, CTX.filename); + break; + default: + Msg(GERROR, "Unknown action on selected entities"); + break; + } + List_Reset(List1); + WID->reset_visibility(); + ZeroHighlight(); + if(action <= 6) SetBoundingBox(); + Draw(); } } if(ib == 'q') { @@ -3660,8 +3660,8 @@ void mesh_save_cb(CALLBACK_ARGS) if(CTX.confirm_overwrite) { if(!StatFile(name)) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name)) - return; + "Cancel", "Replace", NULL, name)) + return; } CreateOutputFile(name, CTX.mesh.format); } @@ -3736,74 +3736,74 @@ void mesh_delete_parts_cb(CALLBACK_ARGS) if(ele.size() || ent.size()) Msg(ONSCREEN, "Select %s\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]", str); + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]", str); else Msg(ONSCREEN, "Select %s\n" - "[Press 'e' to end selection or 'q' to abort]", str); + "[Press 'e' to end selection or 'q' to abort]", str); char ib = SelectEntity(what, vertices, edges, faces, regions, elements); if(ib == 'l') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < elements.size(); i++){ - if(elements[i]->getVisibility() != 2){ - elements[i]->setVisibility(2); ele.push_back(elements[i]); - } - } + for(unsigned int i = 0; i < elements.size(); i++){ + if(elements[i]->getVisibility() != 2){ + elements[i]->setVisibility(2); ele.push_back(elements[i]); + } + } } else{ - for(unsigned int i = 0; i < edges.size(); i++){ - if(edges[i]->getSelection() != 1){ - edges[i]->setSelection(1); ent.push_back(edges[i]); - } - } - for(unsigned int i = 0; i < faces.size(); i++){ - if(faces[i]->getSelection() != 1){ - faces[i]->setSelection(1); ent.push_back(faces[i]); - } - } - for(unsigned int i = 0; i < regions.size(); i++){ - if(regions[i]->getSelection() != 1){ - regions[i]->setSelection(1); ent.push_back(regions[i]); - } - } + for(unsigned int i = 0; i < edges.size(); i++){ + if(edges[i]->getSelection() != 1){ + edges[i]->setSelection(1); ent.push_back(edges[i]); + } + } + for(unsigned int i = 0; i < faces.size(); i++){ + if(faces[i]->getSelection() != 1){ + faces[i]->setSelection(1); ent.push_back(faces[i]); + } + } + for(unsigned int i = 0; i < regions.size(); i++){ + if(regions[i]->getSelection() != 1){ + regions[i]->setSelection(1); ent.push_back(regions[i]); + } + } } } if(ib == 'r') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < elements.size(); i++) - elements[i]->setVisibility(1); + for(unsigned int i = 0; i < elements.size(); i++) + elements[i]->setVisibility(1); } else{ - for(unsigned int i = 0; i < edges.size(); i++) - edges[i]->setSelection(0); - for(unsigned int i = 0; i < faces.size(); i++) - faces[i]->setSelection(0); - for(unsigned int i = 0; i < regions.size(); i++) - regions[i]->setSelection(0); + for(unsigned int i = 0; i < edges.size(); i++) + edges[i]->setSelection(0); + for(unsigned int i = 0; i < faces.size(); i++) + faces[i]->setSelection(0); + for(unsigned int i = 0; i < regions.size(); i++) + regions[i]->setSelection(0); } } if(ib == 'u') { if(CTX.pick_elements){ - if(ele.size()){ - ele[ele.size() - 1]->setVisibility(1); - ele.pop_back(); - } + if(ele.size()){ + ele[ele.size() - 1]->setVisibility(1); + ele.pop_back(); + } } else{ - if(ent.size()){ - ent[ent.size() - 1]->setSelection(0); - ent.pop_back(); - } + if(ent.size()){ + ent[ent.size() - 1]->setSelection(0); + ent.pop_back(); + } } } if(ib == 'e') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < ele.size(); i++) - if(ele[i]->getVisibility() == 2) ele[i]->setVisibility(0); + for(unsigned int i = 0; i < ele.size(); i++) + if(ele[i]->getVisibility() == 2) ele[i]->setVisibility(0); } else{ - for(unsigned int i = 0; i < ent.size(); i++) - if(ent[i]->getSelection() == 1) ent[i]->setVisibility(0); + for(unsigned int i = 0; i < ent.size(); i++) + if(ent[i]->getSelection() == 1) ent[i]->setVisibility(0); } GModel::current()->removeInvisibleElements(); ele.clear(); @@ -3848,28 +3848,28 @@ void mesh_inspect_cb(CALLBACK_ARGS) char ib = SelectEntity(ENT_ALL, vertices, edges, faces, regions, elements); if(ib == 'l') { if(elements.size()){ - ZeroHighlight(); - elements[0]->setVisibility(2); - Msg(DIRECT, "Element %d:", elements[0]->getNum()); - Msg(DIRECT, " Type: %d", elements[0]->getTypeForMSH()); - Msg(DIRECT, " Dimension: %d", elements[0]->getDim()); - Msg(DIRECT, " Order: %d", elements[0]->getPolynomialOrder()); - Msg(DIRECT, " Partition: %d", elements[0]->getPartition()); - char tmp1[32], tmp2[512]; - sprintf(tmp2, " Vertices:"); - for(int i = 0; i < elements[0]->getNumVertices(); i++){ - sprintf(tmp1, " %d", elements[0]->getVertex(i)->getNum()); - strcat(tmp2, tmp1); - } - Msg(DIRECT, tmp2); - SPoint3 pt = elements[0]->barycenter(); - Msg(DIRECT, " Barycenter: (%g,%g,%g)", pt[0], pt[1], pt[2]); - Msg(DIRECT, " Rho: %g", elements[0]->rhoShapeMeasure()); - Msg(DIRECT, " Gamma: %g", elements[0]->gammaShapeMeasure()); - Msg(DIRECT, " Eta: %g", elements[0]->etaShapeMeasure()); - CTX.mesh.changed = ENT_ALL; - Draw(); - WID->create_message_window(); + ZeroHighlight(); + elements[0]->setVisibility(2); + Msg(DIRECT, "Element %d:", elements[0]->getNum()); + Msg(DIRECT, " Type: %d", elements[0]->getTypeForMSH()); + Msg(DIRECT, " Dimension: %d", elements[0]->getDim()); + Msg(DIRECT, " Order: %d", elements[0]->getPolynomialOrder()); + Msg(DIRECT, " Partition: %d", elements[0]->getPartition()); + char tmp1[32], tmp2[512]; + sprintf(tmp2, " Vertices:"); + for(int i = 0; i < elements[0]->getNumVertices(); i++){ + sprintf(tmp1, " %d", elements[0]->getVertex(i)->getNum()); + strcat(tmp2, tmp1); + } + Msg(DIRECT, tmp2); + SPoint3 pt = elements[0]->barycenter(); + Msg(DIRECT, " Barycenter: (%g,%g,%g)", pt[0], pt[1], pt[2]); + Msg(DIRECT, " Rho: %g", elements[0]->rhoShapeMeasure()); + Msg(DIRECT, " Gamma: %g", elements[0]->gammaShapeMeasure()); + Msg(DIRECT, " Eta: %g", elements[0]->etaShapeMeasure()); + CTX.mesh.changed = ENT_ALL; + Draw(); + WID->create_message_window(); } } if(ib == 'q') { @@ -3888,7 +3888,7 @@ void mesh_degree_cb(CALLBACK_ARGS) { if((long)data == 2) SetOrderN(GModel::current(), 2, CTX.mesh.second_order_linear, - CTX.mesh.second_order_incomplete); + CTX.mesh.second_order_incomplete); else SetOrder1(GModel::current()); CTX.mesh.changed = ENT_LINE | ENT_SURFACE | ENT_VOLUME; @@ -3963,11 +3963,11 @@ static void _add_transfinite(int dim) switch (dim) { case 1: if(n == 0) - Msg(ONSCREEN, "Select lines\n" - "[Press 'e' to end selection or 'q' to abort]"); + Msg(ONSCREEN, "Select lines\n" + "[Press 'e' to end selection or 'q' to abort]"); else - Msg(ONSCREEN, "Select lines\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); + Msg(ONSCREEN, "Select lines\n" + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); ib = SelectEntity(ENT_LINE, vertices, edges, faces, regions, elements); break; case 2: @@ -3987,9 +3987,9 @@ static void _add_transfinite(int dim) if(dim == 1) { if(n > 0) add_trsfline(n, p, CTX.filename, - WID->context_mesh_choice[0]->text(), - WID->context_mesh_input[2]->value(), - WID->context_mesh_input[1]->value()); + WID->context_mesh_choice[0]->text(), + WID->context_mesh_input[2]->value(), + WID->context_mesh_input[1]->value()); } ZeroHighlight(); Draw(); @@ -3998,10 +3998,10 @@ static void _add_transfinite(int dim) if(ib == 'u') { if(dim == 1) { if(n > 0){ - ZeroHighlightEntityNum(0, p[n-1], 0, 0); - Draw(); - n--; - } + ZeroHighlightEntityNum(0, p[n-1], 0, 0); + Draw(); + n--; + } } } if(ib == 'q') { @@ -4015,53 +4015,53 @@ static void _add_transfinite(int dim) if(ib == 'l') { switch (dim) { case 1: - for(unsigned int i = 0; i < edges.size(); i++){ - HighlightEntity(edges[i]); - p[n++] = edges[i]->tag(); - } - Draw(); + for(unsigned int i = 0; i < edges.size(); i++){ + HighlightEntity(edges[i]); + p[n++] = edges[i]->tag(); + } + Draw(); break; case 2: case 3: - if(dim == 2){ - HighlightEntity(faces[0]); - Draw(); - p[n++] = faces[0]->tag(); - } - else{ - HighlightEntity(regions[0]); - Draw(); - p[n++] = regions[0]->tag(); - } + if(dim == 2){ + HighlightEntity(faces[0]); + Draw(); + p[n++] = faces[0]->tag(); + } + else{ + HighlightEntity(regions[0]); + Draw(); + p[n++] = regions[0]->tag(); + } while(1) { - if(n == 1) - Msg(ONSCREEN, "Select (ordered) boundary points\n" - "[Press 'e' to end selection or 'q' to abort]"); - else - Msg(ONSCREEN, "Select (ordered) boundary points\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); + if(n == 1) + Msg(ONSCREEN, "Select (ordered) boundary points\n" + "[Press 'e' to end selection or 'q' to abort]"); + else + Msg(ONSCREEN, "Select (ordered) boundary points\n" + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); ib = SelectEntity(ENT_POINT, vertices, edges, faces, regions, elements); if(ib == 'l') { - HighlightEntity(vertices[0]); - Draw(); + HighlightEntity(vertices[0]); + Draw(); p[n++] = vertices[0]->tag(); } - if(ib == 'u') { - if(n > 1){ - ZeroHighlightEntityNum(p[n-1], 0, 0, 0); - Draw(); - n--; - } - } - if(ib == 'r') { - Msg(WARNING, "Entity de-selection not supported yet during transfinite definition"); - } + if(ib == 'u') { + if(n > 1){ + ZeroHighlightEntityNum(p[n-1], 0, 0, 0); + Draw(); + n--; + } + } + if(ib == 'r') { + Msg(WARNING, "Entity de-selection not supported yet during transfinite definition"); + } if(ib == 'e') { switch (dim) { case 2: if(n == 3 + 1 || n == 4 + 1) add_trsfsurf(n, p, CTX.filename, - WID->context_mesh_choice[1]->text()); + WID->context_mesh_choice[1]->text()); else Msg(GERROR, "Wrong number of points for transfinite surface"); break; @@ -4302,7 +4302,7 @@ static void _view_reload(int index) delete PView::list.back(); // in case the reloaded view has a different number of time steps if(p->getOptions()->TimeStep > p->getData()->getNumTimeSteps() - 1) - p->getOptions()->TimeStep = 0; + p->getOptions()->TimeStep = 0; p->setChanged(true); WID->update_views(); } @@ -4391,7 +4391,7 @@ static void _view_save_as(int view_num, const char *title, int format) if(CTX.confirm_overwrite) { if(!StatFile(name.c_str())) if(!fl_choice("File '%s' already exists.\n\nDo you want to replace it?", - "Cancel", "Replace", NULL, name.c_str())) + "Cancel", "Replace", NULL, name.c_str())) goto test; } view->write(name.c_str(), format); @@ -4488,8 +4488,8 @@ void view_all_visible_cb(CALLBACK_ARGS) { for(unsigned int i = 0; i < PView::list.size(); i++) opt_view_visible(i, GMSH_SET | GMSH_GUI, - (long)data < 0 ? !opt_view_visible(i, GMSH_GET, 0) : - (long)data > 0 ? 1 : 0); + (long)data < 0 ? !opt_view_visible(i, GMSH_GET, 0) : + (long)data > 0 ? 1 : 0); Draw(); } @@ -4517,65 +4517,65 @@ void view_field_cancel_cb(CALLBACK_ARGS) } void view_field_delete_cb(CALLBACK_ARGS) { - FieldDialogBox *fdb=(FieldDialogBox*)data; - fdb->group->hide(); - delete_field(fdb->current_field->id,CTX.filename); - WID->create_field_window(0); + FieldDialogBox *fdb=(FieldDialogBox*)data; + fdb->group->hide(); + delete_field(fdb->current_field->id,CTX.filename); + WID->create_field_window(0); } void view_field_set_size_btn_cb(CALLBACK_ARGS){ - FieldDialogBox *fdb=(FieldDialogBox*)data; - fdb->group->hide(); - int v=((Fl_Check_Button*)w)->value(); - if(v) - set_background_field(fdb->current_field->id,CTX.filename); - else - set_background_field(-1,CTX.filename); - WID->create_field_window(fdb->current_field->id); + FieldDialogBox *fdb=(FieldDialogBox*)data; + fdb->group->hide(); + int v=((Fl_Check_Button*)w)->value(); + if(v) + set_background_field(fdb->current_field->id,CTX.filename); + else + set_background_field(-1,CTX.filename); + WID->create_field_window(fdb->current_field->id); } void view_field_new_cb(CALLBACK_ARGS) { - Fl_Menu_Button* mb=((Fl_Menu_Button*)w); - int id=GModel::current()->getFields()->new_id(); - add_field(id,mb->text(),CTX.filename); - WID->create_field_window(id); + Fl_Menu_Button* mb=((Fl_Menu_Button*)w); + int id=GModel::current()->getFields()->new_id(); + add_field(id,mb->text(),CTX.filename); + WID->create_field_window(id); } void view_field_apply_cb(CALLBACK_ARGS){ - FieldDialogBox *fdb=(FieldDialogBox*)data; - fdb->save_values(); - int selected=WID->field_browser->value(); - std::ostringstream sstream(""); - sstream<<fdb->current_field->id; - sstream<<" "<<fdb->current_field->get_name(); - WID->field_browser->text(selected,sstream.str().c_str()); + FieldDialogBox *fdb=(FieldDialogBox*)data; + fdb->save_values(); + int selected=WID->field_browser->value(); + std::ostringstream sstream(""); + sstream<<fdb->current_field->id; + sstream<<" "<<fdb->current_field->get_name(); + WID->field_browser->text(selected,sstream.str().c_str()); } void view_field_revert_cb(CALLBACK_ARGS){ - FieldDialogBox *fdb=(FieldDialogBox*)data; - fdb->load_field(fdb->current_field); + FieldDialogBox *fdb=(FieldDialogBox*)data; + fdb->load_field(fdb->current_field); } void view_field_browser_cb(CALLBACK_ARGS) { - int selected=WID->field_browser->value(); - if(WID->selected_field_dialog_box){ - WID->selected_field_dialog_box->group->hide(); - } - if(!selected)return; - Field *f=(Field*)WID->field_browser->data(selected); - f->dialog_box()->load_field(f); - WID->selected_field_dialog_box=f->dialog_box(); + int selected=WID->field_browser->value(); + if(WID->selected_field_dialog_box){ + WID->selected_field_dialog_box->group->hide(); + } + if(!selected)return; + Field *f=(Field*)WID->field_browser->data(selected); + f->dialog_box()->load_field(f); + WID->selected_field_dialog_box=f->dialog_box(); f->dialog_box()->group->show(); } void view_field_put_on_view_cb(CALLBACK_ARGS){ - Fl_Menu_Button* mb=((Fl_Menu_Button*)w); - Field *field=((FieldDialogBox*)data)->current_field; - int iView; - sscanf(mb->text(),"View [%i]",&iView); - field->put_on_view(PView::list[iView]); - Draw(); + Fl_Menu_Button* mb=((Fl_Menu_Button*)w); + Field *field=((FieldDialogBox*)data)->current_field; + int iView; + sscanf(mb->text(),"View [%i]",&iView); + field->put_on_view(PView::list[iView]); + Draw(); } void view_field_select_node_cb(CALLBACK_ARGS){ - const char *mode="select"; - const char *help="vertices"; + const char *mode="select"; + const char *help="vertices"; CTX.pick_elements = 1; Draw(); std::vector<GVertex*> vertices, vertices_old; @@ -4583,17 +4583,17 @@ void view_field_select_node_cb(CALLBACK_ARGS){ std::vector<GFace*> faces, faces_old; std::vector<GRegion*> regions, regions_old; std::vector<MElement*> elements, elements_old; - opt_geometry_points(0, GMSH_SET | GMSH_GUI, 1); + opt_geometry_points(0, GMSH_SET | GMSH_GUI, 1); while(1) { Msg(ONSCREEN, "Select %s\n[Press %s'q' to abort]", - help, mode ? "" : "'u' to undo or "); + help, mode ? "" : "'u' to undo or "); char ib = SelectEntity(ENT_POINT, vertices, edges, faces, regions, elements); - printf("char = %c\n",ib); + printf("char = %c\n",ib); if(ib == 'q'){ - for(std::vector<GVertex*>::iterator it=vertices.begin();it!=vertices.end();it++){ - printf("%i\n",*it); - } + for(std::vector<GVertex*>::iterator it=vertices.begin();it!=vertices.end();it++){ + printf("%i\n",*it); + } break; } } @@ -4648,9 +4648,9 @@ void view_plugin_browser_cb(CALLBACK_ARGS) if(sxn->function){ p->dialogBox->value[i]->callback(view_plugin_input_value_cb, (void*)sxn->function); if(iView >= 0){ - p->dialogBox->value[i]->step(sxn->function(iView, 1, 0.)); - p->dialogBox->value[i]->minimum(sxn->function(iView, 2, 0.)); - p->dialogBox->value[i]->maximum(sxn->function(iView, 3, 0.)); + p->dialogBox->value[i]->step(sxn->function(iView, 1, 0.)); + p->dialogBox->value[i]->minimum(sxn->function(iView, 2, 0.)); + p->dialogBox->value[i]->maximum(sxn->function(iView, 3, 0.)); } } } @@ -4707,15 +4707,15 @@ void view_plugin_run_cb(CALLBACK_ARGS) for(int i = 1; i <= WID->plugin_view_browser->size(); i++) { if(WID->plugin_view_browser->selected(i)) { try{ - if(i - 1 >= 0 && i - 1 < (int)PView::list.size()) - p->execute(PView::list[i - 1]); - else - p->execute(0); + if(i - 1 >= 0 && i - 1 < (int)PView::list.size()) + p->execute(PView::list[i - 1]); + else + p->execute(0); } catch(GMSH_Plugin * err) { - char tmp[256]; - p->catchErrorMessage(tmp); - Msg(WARNING, "%s", tmp); + char tmp[256]; + p->catchErrorMessage(tmp); + Msg(WARNING, "%s", tmp); } } } @@ -4744,10 +4744,10 @@ void con_geometry_define_parameter_cb(CALLBACK_ARGS) void con_geometry_define_point_cb(CALLBACK_ARGS) { add_point(CTX.filename, - WID->context_geometry_input[2]->value(), - WID->context_geometry_input[3]->value(), - WID->context_geometry_input[4]->value(), - WID->context_geometry_input[5]->value()); + WID->context_geometry_input[2]->value(), + WID->context_geometry_input[3]->value(), + WID->context_geometry_input[4]->value(), + WID->context_geometry_input[5]->value()); WID->reset_visibility(); ZeroHighlight(); SetBoundingBox(); diff --git a/Fltk/Colorbar_Window.cpp b/Fltk/Colorbar_Window.cpp index 00144f47ce918b9d97b616d8105e4e391d9f7dd5..6da2ebf8d7641acdab631ed798ac62be22c0f777 100644 --- a/Fltk/Colorbar_Window.cpp +++ b/Fltk/Colorbar_Window.cpp @@ -1,4 +1,4 @@ -// $Id: Colorbar_Window.cpp,v 1.62 2008-02-23 15:30:06 geuzaine Exp $ +// $Id: Colorbar_Window.cpp,v 1.63 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -319,8 +319,8 @@ void Colorbar_Window::draw() marker_y = label_y - marker_height - font_height; wedge_y = marker_y - wedge_height; color_bg = fl_color_cube(CTX.UNPACK_RED(CTX.color.bg) * FL_NUM_RED / 256, - CTX.UNPACK_GREEN(CTX.color.bg) * FL_NUM_GREEN / 256, - CTX.UNPACK_BLUE(CTX.color.bg) * FL_NUM_BLUE / 256); + CTX.UNPACK_GREEN(CTX.color.bg) * FL_NUM_GREEN / 256, + CTX.UNPACK_BLUE(CTX.color.bg) * FL_NUM_BLUE / 256); redraw_range(0, ct->size - 1); redraw_marker(); } diff --git a/Fltk/Colorbar_Window.h b/Fltk/Colorbar_Window.h index df408acf81d6435af6a36c01699a2ee0ed494810..c03687bd51e80fcee633d224aaaf9c89e7c9e3f4 100644 --- a/Fltk/Colorbar_Window.h +++ b/Fltk/Colorbar_Window.h @@ -54,7 +54,7 @@ class Colorbar_Window : public Fl_Window { public: Colorbar_Window(int x, int y, int w, int h, const char *l=0); void update(const char *name, double min, double max, GmshColorTable *ct, - bool *changed); + bool *changed); }; #endif diff --git a/Fltk/File_Picker.h b/Fltk/File_Picker.h index 4c83616c9811dd3d68f2105b2a74122b44870481..d80e15d2a60b6076dc6478308d68a110fc43bc4a 100644 --- a/Fltk/File_Picker.h +++ b/Fltk/File_Picker.h @@ -45,9 +45,9 @@ public: _win->show(); rescan(); // necessary since fltk 1.1.7 if(_in) - _in->take_focus(); + _in->take_focus(); else - _win->take_focus(); + _win->take_focus(); } else Fl_File_Chooser::show(); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 41a77d094da0e66696a69831d0a61591a1a620ae..e32b4f3cdbbd3ad9411fb0a68ce854ddd252e32a 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.665 2008-03-19 17:26:48 geuzaine Exp $ +// $Id: GUI.cpp,v 1.666 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -168,124 +168,124 @@ Context_Item menu_geometry[] = { {0} }; Context_Item menu_geometry_elementary_add[] = { - {"0Geometry>Elementary>Add", NULL} , + {"0Geometry>Elementary>Add", NULL} , {"New", (Fl_Callback *)geometry_elementary_add_new_cb} , - {"Translate", (Fl_Callback *)geometry_elementary_add_translate_cb} , - {"Rotate", (Fl_Callback *)geometry_elementary_add_rotate_cb} , - {"Scale", (Fl_Callback *)geometry_elementary_add_scale_cb} , - {"Symmetry", (Fl_Callback *)geometry_elementary_add_symmetry_cb} , - {0} - }; + {"Translate", (Fl_Callback *)geometry_elementary_add_translate_cb} , + {"Rotate", (Fl_Callback *)geometry_elementary_add_rotate_cb} , + {"Scale", (Fl_Callback *)geometry_elementary_add_scale_cb} , + {"Symmetry", (Fl_Callback *)geometry_elementary_add_symmetry_cb} , + {0} + }; Context_Item menu_geometry_elementary_add_new[] = { - {"0Geometry>Elementary>Add>New", NULL} , + {"0Geometry>Elementary>Add>New", NULL} , {"Parameter", (Fl_Callback *)geometry_elementary_add_new_parameter_cb} , - {"Point", (Fl_Callback *)geometry_elementary_add_new_point_cb} , - {"Straight line", (Fl_Callback *)geometry_elementary_add_new_line_cb} , - {"Spline", (Fl_Callback *)geometry_elementary_add_new_spline_cb} , - {"B-Spline", (Fl_Callback *)geometry_elementary_add_new_bspline_cb} , - {"Circle arc", (Fl_Callback *)geometry_elementary_add_new_circle_cb} , - {"Ellipse arc", (Fl_Callback *)geometry_elementary_add_new_ellipse_cb} , - {"Plane surface", (Fl_Callback *)geometry_elementary_add_new_planesurface_cb} , - {"Ruled surface", (Fl_Callback *)geometry_elementary_add_new_ruledsurface_cb} , - {"Volume", (Fl_Callback *)geometry_elementary_add_new_volume_cb} , - {0} - }; + {"Point", (Fl_Callback *)geometry_elementary_add_new_point_cb} , + {"Straight line", (Fl_Callback *)geometry_elementary_add_new_line_cb} , + {"Spline", (Fl_Callback *)geometry_elementary_add_new_spline_cb} , + {"B-Spline", (Fl_Callback *)geometry_elementary_add_new_bspline_cb} , + {"Circle arc", (Fl_Callback *)geometry_elementary_add_new_circle_cb} , + {"Ellipse arc", (Fl_Callback *)geometry_elementary_add_new_ellipse_cb} , + {"Plane surface", (Fl_Callback *)geometry_elementary_add_new_planesurface_cb} , + {"Ruled surface", (Fl_Callback *)geometry_elementary_add_new_ruledsurface_cb} , + {"Volume", (Fl_Callback *)geometry_elementary_add_new_volume_cb} , + {0} + }; Context_Item menu_geometry_elementary_add_translate[] = { - {"0Geometry>Elementary>Add>Translate", NULL} , + {"0Geometry>Elementary>Add>Translate", NULL} , {"Point", (Fl_Callback *)geometry_elementary_add_translate_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_add_translate_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_add_translate_surface_cb} , - {0} - }; + {"Line", (Fl_Callback *)geometry_elementary_add_translate_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_add_translate_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_add_rotate[] = { - {"0Geometry>Elementary>Add>Rotate", NULL} , + {"0Geometry>Elementary>Add>Rotate", NULL} , {"Point", (Fl_Callback *)geometry_elementary_add_rotate_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_add_rotate_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_add_rotate_surface_cb} , - {0} - }; + {"Line", (Fl_Callback *)geometry_elementary_add_rotate_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_add_rotate_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_add_scale[] = { - {"0Geometry>Elementary>Add>Scale", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_add_scale_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_add_scale_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_add_scale_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Add>Scale", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_add_scale_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_add_scale_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_add_scale_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_add_symmetry[] = { - {"0Geometry>Elementary>Add>Symmetry", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_add_symmetry_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_add_symmetry_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_add_symmetry_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Add>Symmetry", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_add_symmetry_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_add_symmetry_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_add_symmetry_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_translate[] = { - {"0Geometry>Elementary>Translate", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_translate_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_translate_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_translate_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Translate", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_translate_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_translate_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_translate_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_rotate[] = { - {"0Geometry>Elementary>Rotate", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_rotate_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_rotate_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_rotate_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Rotate", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_rotate_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_rotate_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_rotate_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_scale[] = { - {"0Geometry>Elementary>Scale", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_scale_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_scale_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_scale_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Scale", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_scale_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_scale_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_scale_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_symmetry[] = { - {"0Geometry>Elementary>Symmetry", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_symmetry_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_symmetry_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_symmetry_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Symmetry", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_symmetry_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_symmetry_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_symmetry_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_extrude[] = { - {"0Geometry>Elementary>Extrude", NULL} , - {"Translate", (Fl_Callback *)geometry_elementary_extrude_translate_cb} , - {"Rotate", (Fl_Callback *)geometry_elementary_extrude_rotate_cb} , - {0} - }; + {"0Geometry>Elementary>Extrude", NULL} , + {"Translate", (Fl_Callback *)geometry_elementary_extrude_translate_cb} , + {"Rotate", (Fl_Callback *)geometry_elementary_extrude_rotate_cb} , + {0} + }; Context_Item menu_geometry_elementary_extrude_translate[] = { - {"0Geometry>Elementary>Extrude>Translate", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_extrude_translate_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_extrude_translate_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_extrude_translate_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Extrude>Translate", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_extrude_translate_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_extrude_translate_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_extrude_translate_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_extrude_rotate[] = { - {"0Geometry>Elementary>Extrude>Rotate", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_extrude_rotate_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_extrude_rotate_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_extrude_rotate_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Extrude>Rotate", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_extrude_rotate_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_extrude_rotate_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_extrude_rotate_surface_cb} , + {0} + }; Context_Item menu_geometry_elementary_delete[] = { - {"0Geometry>Elementary>Delete", NULL} , - {"Point", (Fl_Callback *)geometry_elementary_delete_point_cb} , - {"Line", (Fl_Callback *)geometry_elementary_delete_line_cb} , - {"Surface", (Fl_Callback *)geometry_elementary_delete_surface_cb} , - {0} - }; + {"0Geometry>Elementary>Delete", NULL} , + {"Point", (Fl_Callback *)geometry_elementary_delete_point_cb} , + {"Line", (Fl_Callback *)geometry_elementary_delete_line_cb} , + {"Surface", (Fl_Callback *)geometry_elementary_delete_surface_cb} , + {0} + }; Context_Item menu_geometry_physical[] = { {"0Geometry>Physical", NULL} , {"Add", (Fl_Callback *)geometry_physical_add_cb} , {0} }; Context_Item menu_geometry_physical_add[] = { - {"0Geometry>Physical>Add", NULL} , - {"Point", (Fl_Callback *)geometry_physical_add_point_cb } , - {"Line", (Fl_Callback *)geometry_physical_add_line_cb } , - {"Surface", (Fl_Callback *)geometry_physical_add_surface_cb } , - {"Volume", (Fl_Callback *)geometry_physical_add_volume_cb } , - {0} - }; + {"0Geometry>Physical>Add", NULL} , + {"Point", (Fl_Callback *)geometry_physical_add_point_cb } , + {"Line", (Fl_Callback *)geometry_physical_add_line_cb } , + {"Surface", (Fl_Callback *)geometry_physical_add_surface_cb } , + {"Volume", (Fl_Callback *)geometry_physical_add_volume_cb } , + {0} + }; Context_Item menu_mesh[] = { {"1Mesh", NULL} , @@ -317,12 +317,12 @@ Context_Item menu_mesh[] = { {0} }; Context_Item menu_mesh_define_transfinite[] = { - {"1Mesh>Define>Transfinite", NULL} , - {"Line", (Fl_Callback *)mesh_define_transfinite_line_cb} , - {"Surface", (Fl_Callback *)mesh_define_transfinite_surface_cb} , - {"Volume", (Fl_Callback *)mesh_define_transfinite_volume_cb} , - {0} - }; + {"1Mesh>Define>Transfinite", NULL} , + {"Line", (Fl_Callback *)mesh_define_transfinite_line_cb} , + {"Surface", (Fl_Callback *)mesh_define_transfinite_surface_cb} , + {"Volume", (Fl_Callback *)mesh_define_transfinite_volume_cb} , + {0} + }; Context_Item menu_mesh_delete[] = { {"1Mesh>Edit>Delete", NULL} , {"Elements", (Fl_Callback *)mesh_delete_parts_cb, (void*)"elements"} , @@ -419,7 +419,7 @@ int GetFontIndex(const char *fontname) if(fontname){ for(int i = 0; i < NUM_FONTS; i++) if(!strcmp(menu_font_names[i].label(), fontname)) - return i; + return i; } Msg(GERROR, "Unknown font \"%s\" (using \"Helvetica\" instead)", fontname); Msg(INFO, "Available fonts:"); @@ -449,10 +449,10 @@ int GetFontAlign(const char *alignstr) !strcmp(alignstr, "left")) return 0; else if(!strcmp(alignstr, "BottomCenter") || !strcmp(alignstr, "Center") || - !strcmp(alignstr, "center")) + !strcmp(alignstr, "center")) return 1; else if(!strcmp(alignstr, "BottomRight") || !strcmp(alignstr, "Right") || - !strcmp(alignstr, "right")) + !strcmp(alignstr, "right")) return 2; else if(!strcmp(alignstr, "TopLeft")) return 3; @@ -575,10 +575,10 @@ int GUI::global_shortcuts(int event) return 0; // trick: do as if we didn't use it } else if(Fl::test_shortcut(FL_Escape) || - Fl::test_shortcut(FL_META + FL_Escape) || - Fl::test_shortcut(FL_SHIFT + FL_Escape) || - Fl::test_shortcut(FL_CTRL + FL_Escape) || - Fl::test_shortcut(FL_ALT + FL_Escape)) { + Fl::test_shortcut(FL_META + FL_Escape) || + Fl::test_shortcut(FL_SHIFT + FL_Escape) || + Fl::test_shortcut(FL_CTRL + FL_Escape) || + Fl::test_shortcut(FL_ALT + FL_Escape)) { if(g_opengl_window->LassoMode){ g_opengl_window->LassoMode = false; redraw_opengl(); @@ -615,38 +615,38 @@ int GUI::global_shortcuts(int event) else if(Fl::test_shortcut(FL_SHIFT + 'w')) { if(PView::list.size()){ if(view_number >= 0 && view_number < (int)PView::list.size()) - create_view_options_window(view_number); + create_view_options_window(view_number); else - create_view_options_window(0); + create_view_options_window(0); } return 1; } else if(Fl::test_shortcut(FL_SHIFT + 'u')) { if(PView::list.size()){ if(view_number >= 0 && view_number < (int)PView::list.size()) - create_plugin_window(view_number); + create_plugin_window(view_number); else - create_plugin_window(0); + create_plugin_window(0); } return 1; } else if(Fl::test_shortcut(FL_ALT + 'f')) { opt_general_fast_redraw(0, GMSH_SET | GMSH_GUI, - !opt_general_fast_redraw(0, GMSH_GET, 0)); + !opt_general_fast_redraw(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + 'b')) { opt_general_draw_bounding_box(0, GMSH_SET | GMSH_GUI, - !opt_general_draw_bounding_box(0, GMSH_GET, 0)); + !opt_general_draw_bounding_box(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + 'i')) { for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0)) - opt_view_show_scale(i, GMSH_SET | GMSH_GUI, - !opt_view_show_scale(i, GMSH_GET, 0)); + opt_view_show_scale(i, GMSH_SET | GMSH_GUI, + !opt_view_show_scale(i, GMSH_GET, 0)); redraw_opengl(); return 1; } @@ -658,45 +658,45 @@ int GUI::global_shortcuts(int event) } else if(Fl::test_shortcut(FL_ALT + 'w')) { opt_geometry_light(0, GMSH_SET | GMSH_GUI, - !opt_geometry_light(0, GMSH_GET, 0)); + !opt_geometry_light(0, GMSH_GET, 0)); opt_mesh_light(0, GMSH_SET | GMSH_GUI, - !opt_mesh_light(0, GMSH_GET, 0)); + !opt_mesh_light(0, GMSH_GET, 0)); for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0)) - opt_view_light(i, GMSH_SET | GMSH_GUI, - !opt_view_light(i, GMSH_GET, 0)); + opt_view_light(i, GMSH_SET | GMSH_GUI, + !opt_view_light(i, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'w')) { opt_mesh_reverse_all_normals(0, GMSH_SET | GMSH_GUI, - !opt_mesh_reverse_all_normals(0, GMSH_GET, 0)); + !opt_mesh_reverse_all_normals(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + 'x') || - Fl::test_shortcut(FL_ALT + FL_SHIFT + 'x')) { + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'x')) { status_xyz1p_cb(0, (void *)"x"); return 1; } else if(Fl::test_shortcut(FL_ALT + 'y') || - Fl::test_shortcut(FL_ALT + FL_SHIFT + 'y')) { + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'y')) { status_xyz1p_cb(0, (void *)"y"); return 1; } else if(Fl::test_shortcut(FL_ALT + 'z') || - Fl::test_shortcut(FL_ALT + FL_SHIFT + 'z')) { + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'z')) { status_xyz1p_cb(0, (void *)"z"); return 1; } else if(Fl::test_shortcut(FL_ALT + 'o') || - Fl::test_shortcut(FL_ALT + FL_SHIFT + 'o')) { + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'o')) { status_xyz1p_cb(0, (void *)"p"); return 1; } else if(Fl::test_shortcut(FL_ALT + 'a')) { opt_general_axes(0, GMSH_SET | GMSH_GUI, - opt_general_axes(0, GMSH_GET, 0) + 1); + opt_general_axes(0, GMSH_GET, 0) + 1); for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0)) opt_view_axes(i, GMSH_SET | GMSH_GUI, opt_view_axes(i, GMSH_GET, 0)+1); @@ -740,37 +740,37 @@ int GUI::global_shortcuts(int event) } else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'l')) { opt_mesh_lines(0, GMSH_SET | GMSH_GUI, - !opt_mesh_lines(0, GMSH_GET, 0)); + !opt_mesh_lines(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 's')) { opt_mesh_surfaces_edges(0, GMSH_SET | GMSH_GUI, - !opt_mesh_surfaces_edges(0, GMSH_GET, 0)); + !opt_mesh_surfaces_edges(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'v')) { opt_mesh_volumes_edges(0, GMSH_SET | GMSH_GUI, - !opt_mesh_volumes_edges(0, GMSH_GET, 0)); + !opt_mesh_volumes_edges(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + 'd')){ opt_geometry_surface_type(0, GMSH_SET | GMSH_GUI, - opt_geometry_surface_type(0, GMSH_GET, 0) + 1); + opt_geometry_surface_type(0, GMSH_GET, 0) + 1); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'd')) { opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI, - !opt_mesh_surfaces_faces(0, GMSH_GET, 0)); + !opt_mesh_surfaces_faces(0, GMSH_GET, 0)); redraw_opengl(); return 1; } else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'b')) { opt_mesh_volumes_faces(0, GMSH_SET | GMSH_GUI, - !opt_mesh_volumes_faces(0, GMSH_GET, 0)); + !opt_mesh_volumes_faces(0, GMSH_GET, 0)); redraw_opengl(); return 1; } @@ -792,7 +792,7 @@ int GUI::global_shortcuts(int event) for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0)) opt_view_intervals_type(i, GMSH_SET | GMSH_GUI, - opt_view_intervals_type(i, GMSH_GET, 0) + 1); + opt_view_intervals_type(i, GMSH_GET, 0) + 1); redraw_opengl(); return 1; } @@ -800,7 +800,7 @@ int GUI::global_shortcuts(int event) for(unsigned int i = 0; i < PView::list.size(); i++) if(opt_view_visible(i, GMSH_GET, 0)) opt_view_range_type(i, GMSH_SET | GMSH_GUI, - opt_view_range_type(i, GMSH_GET, 0) + 1); + opt_view_range_type(i, GMSH_GET, 0) + 1); redraw_opengl(); return 1; } @@ -948,9 +948,9 @@ GUI::GUI(int argc, char **argv) 0x04, 0xa8, 0xea, 0x3f, 0x02, 0x55, 0x55, 0x7f, 0xa2, 0xaa, 0xaa, 0x7a, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }; m_window->icon((char*)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display), - gmsh32x32, 32, 32)); + gmsh32x32, 32, 32)); g_window->icon((char*)XCreateBitmapFromData(fl_display, DefaultRootWindow(fl_display), - gmsh32x32, 32, 32)); + gmsh32x32, 32, 32)); #endif // we must show() m_window first (at least on Win32, since the icon @@ -1160,7 +1160,7 @@ void GUI::set_context(Context_Item * menu_asked, int flag) menu[5].label = opt_solver_name4(0, GMSH_GET, 0); for(int i = 0; i < MAXSOLVERS; i++) { if(!strlen(menu[i + 1].label)) - menu[i + 1].label = NULL; + menu[i + 1].label = NULL; } } else if(menu[0].label[0] == '3'){ @@ -1262,66 +1262,66 @@ void GUI::set_context(Context_Item * menu_asked, int flag) p[1]->type(Fl_Menu_Button::POPUP3); for(int j = 0; j < 2; j++) { - p[j]->add("Reload/View", 'r', - (Fl_Callback *) view_reload_cb, (void *)nb, 0); - p[j]->add("Reload/Visible Views", 0, - (Fl_Callback *) view_reload_visible_cb, (void *)nb, 0); - p[j]->add("Reload/All Views", 0, - (Fl_Callback *) view_reload_all_cb, (void *)nb, 0); - p[j]->add("Remove/View", FL_Delete, - (Fl_Callback *) view_remove_cb, (void *)nb, 0); - p[j]->add("Remove/Other Views", 0, - (Fl_Callback *) view_remove_other_cb, (void *)nb, 0); - p[j]->add("Remove/Visible Views", 0, - (Fl_Callback *) view_remove_visible_cb, (void *)nb, 0); - p[j]->add("Remove/Invisible Views", 0, - (Fl_Callback *) view_remove_invisible_cb, (void *)nb, 0); - p[j]->add("Remove/Empty Views", 0, - (Fl_Callback *) view_remove_empty_cb, (void *)nb, 0); - p[j]->add("Remove/All Views", 0, - (Fl_Callback *) view_remove_all_cb, (void *)nb, 0); - p[j]->add("Alias/View without Options", 0, - (Fl_Callback *) view_alias_cb, (void *)nb, 0); - p[j]->add("Alias/View with Options", 0, - (Fl_Callback *) view_alias_with_options_cb, (void *)nb, 0); - p[j]->add("Combine/Elements from Visible Views", 0, - (Fl_Callback *) view_combine_space_visible_cb, (void *)nb, 0); - p[j]->add("Combine/Elements from All Views", 0, - (Fl_Callback *) view_combine_space_all_cb, (void *)nb, 0); - p[j]->add("Combine/Elements by View Name", 0, - (Fl_Callback *) view_combine_space_by_name_cb, (void *)nb, 0); - p[j]->add("Combine/Time Steps from Visible Views", 0, - (Fl_Callback *) view_combine_time_visible_cb, (void *)nb, 0); - p[j]->add("Combine/Time Steps from All Views", 0, - (Fl_Callback *) view_combine_time_all_cb, (void *)nb, 0); - p[j]->add("Combine/Time Steps by View Name", 0, - (Fl_Callback *) view_combine_time_by_name_cb, (void *)nb, 0); - p[j]->add("Set Visibility/All On", 0, - (Fl_Callback *) view_all_visible_cb, (void *)1, 0); - p[j]->add("Set Visibility/All Off", 0, - (Fl_Callback *) view_all_visible_cb, (void *)0, 0); - p[j]->add("Set Visibility/Invert", 0, - (Fl_Callback *) view_all_visible_cb, (void *)-1, 0); - p[j]->add("Save As/Parsed View...", 0, - (Fl_Callback *) view_save_parsed_cb, (void *)nb, 0); - p[j]->add("Save As/ASCII View...", 0, - (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0); - p[j]->add("Save As/Binary View...", 0, - (Fl_Callback *) view_save_binary_cb, (void *)nb, 0); - p[j]->add("Save As/STL Triangulation...", 0, - (Fl_Callback *) view_save_stl_cb, (void *)nb, 0); - p[j]->add("Save As/Raw Text...", 0, - (Fl_Callback *) view_save_txt_cb, (void *)nb, 0); - p[j]->add("Save As/Gmsh Mesh...", 0, - (Fl_Callback *) view_save_msh_cb, (void *)nb, 0); - p[j]->add("Apply As Background Mesh", 0, - (Fl_Callback *) view_applybgmesh_cb, (void *)nb, FL_MENU_DIVIDER); - p[j]->add("Options...", 'o', - (Fl_Callback *) view_options_cb, (void *)nb, 0); - p[j]->add("Plugins...", 'p', - (Fl_Callback *) view_plugin_cb, (void *)nb, 0); - p[j]->add("Fields...", 'f', - (Fl_Callback *) view_field_cb, (void *)nb, 0); + p[j]->add("Reload/View", 'r', + (Fl_Callback *) view_reload_cb, (void *)nb, 0); + p[j]->add("Reload/Visible Views", 0, + (Fl_Callback *) view_reload_visible_cb, (void *)nb, 0); + p[j]->add("Reload/All Views", 0, + (Fl_Callback *) view_reload_all_cb, (void *)nb, 0); + p[j]->add("Remove/View", FL_Delete, + (Fl_Callback *) view_remove_cb, (void *)nb, 0); + p[j]->add("Remove/Other Views", 0, + (Fl_Callback *) view_remove_other_cb, (void *)nb, 0); + p[j]->add("Remove/Visible Views", 0, + (Fl_Callback *) view_remove_visible_cb, (void *)nb, 0); + p[j]->add("Remove/Invisible Views", 0, + (Fl_Callback *) view_remove_invisible_cb, (void *)nb, 0); + p[j]->add("Remove/Empty Views", 0, + (Fl_Callback *) view_remove_empty_cb, (void *)nb, 0); + p[j]->add("Remove/All Views", 0, + (Fl_Callback *) view_remove_all_cb, (void *)nb, 0); + p[j]->add("Alias/View without Options", 0, + (Fl_Callback *) view_alias_cb, (void *)nb, 0); + p[j]->add("Alias/View with Options", 0, + (Fl_Callback *) view_alias_with_options_cb, (void *)nb, 0); + p[j]->add("Combine/Elements from Visible Views", 0, + (Fl_Callback *) view_combine_space_visible_cb, (void *)nb, 0); + p[j]->add("Combine/Elements from All Views", 0, + (Fl_Callback *) view_combine_space_all_cb, (void *)nb, 0); + p[j]->add("Combine/Elements by View Name", 0, + (Fl_Callback *) view_combine_space_by_name_cb, (void *)nb, 0); + p[j]->add("Combine/Time Steps from Visible Views", 0, + (Fl_Callback *) view_combine_time_visible_cb, (void *)nb, 0); + p[j]->add("Combine/Time Steps from All Views", 0, + (Fl_Callback *) view_combine_time_all_cb, (void *)nb, 0); + p[j]->add("Combine/Time Steps by View Name", 0, + (Fl_Callback *) view_combine_time_by_name_cb, (void *)nb, 0); + p[j]->add("Set Visibility/All On", 0, + (Fl_Callback *) view_all_visible_cb, (void *)1, 0); + p[j]->add("Set Visibility/All Off", 0, + (Fl_Callback *) view_all_visible_cb, (void *)0, 0); + p[j]->add("Set Visibility/Invert", 0, + (Fl_Callback *) view_all_visible_cb, (void *)-1, 0); + p[j]->add("Save As/Parsed View...", 0, + (Fl_Callback *) view_save_parsed_cb, (void *)nb, 0); + p[j]->add("Save As/ASCII View...", 0, + (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0); + p[j]->add("Save As/Binary View...", 0, + (Fl_Callback *) view_save_binary_cb, (void *)nb, 0); + p[j]->add("Save As/STL Triangulation...", 0, + (Fl_Callback *) view_save_stl_cb, (void *)nb, 0); + p[j]->add("Save As/Raw Text...", 0, + (Fl_Callback *) view_save_txt_cb, (void *)nb, 0); + p[j]->add("Save As/Gmsh Mesh...", 0, + (Fl_Callback *) view_save_msh_cb, (void *)nb, 0); + p[j]->add("Apply As Background Mesh", 0, + (Fl_Callback *) view_applybgmesh_cb, (void *)nb, FL_MENU_DIVIDER); + p[j]->add("Options...", 'o', + (Fl_Callback *) view_options_cb, (void *)nb, 0); + p[j]->add("Plugins...", 'p', + (Fl_Callback *) view_plugin_cb, (void *)nb, 0); + p[j]->add("Fields...", 'f', + (Fl_Callback *) view_field_cb, (void *)nb, 0); } m_toggle_butt.push_back(b1); @@ -2034,9 +2034,9 @@ void GUI::create_option_window() o->hide(); static Fl_Menu_Item menu_projection[] = { - {"Orthographic", 0, 0, 0}, - {"Perspective", 0, 0, 0}, - {0} + {"Orthographic", 0, 0, 0}, + {"Perspective", 0, 0, 0}, + {0} }; gen_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Projection mode"); gen_choice[2]->menu(menu_projection); @@ -2091,11 +2091,11 @@ void GUI::create_option_window() gen_value[7]->callback(general_options_ok_cb); static Fl_Menu_Item menu_genvectype[] = { - {"Line", 0, 0, 0}, - {"Arrow", 0, 0, 0}, - {"Pyramid", 0, 0, 0}, - {"3D arrow", 0, 0, 0}, - {0} + {"Line", 0, 0, 0}, + {"Arrow", 0, 0, 0}, + {"Pyramid", 0, 0, 0}, + {"3D arrow", 0, 0, 0}, + {0} }; gen_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Vector display"); gen_choice[0]->menu(menu_genvectype); @@ -2173,10 +2173,10 @@ void GUI::create_option_window() o->hide(); static Fl_Menu_Item menu_color_scheme[] = { - {"Dark", 0, 0, 0}, - {"Light", 0, 0, 0}, - {"Grayscale", 0, 0, 0}, - {0} + {"Dark", 0, 0, 0}, + {"Light", 0, 0, 0}, + {"Grayscale", 0, 0, 0}, + {0} }; gen_choice[3] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Predefined color scheme"); @@ -2186,11 +2186,11 @@ void GUI::create_option_window() gen_choice[3]->callback(general_options_color_scheme_cb); static Fl_Menu_Item menu_bg_grad[] = { - {"None", 0, 0, 0}, - {"Vertical", 0, 0, 0}, - {"Horizontal", 0, 0, 0}, - {"Radial", 0, 0, 0}, - {0} + {"None", 0, 0, 0}, + {"Vertical", 0, 0, 0}, + {"Horizontal", 0, 0, 0}, + {"Radial", 0, 0, 0}, + {0} }; gen_choice[5] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Background gradient"); @@ -2332,7 +2332,7 @@ void GUI::create_option_window() geo_choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display"); geo_choice[1]->menu(menu_line_display); - geo_choice[1]->align(FL_ALIGN_RIGHT); + geo_choice[1]->align(FL_ALIGN_RIGHT); geo_choice[1]->callback(geometry_options_ok_cb); geo_value[4] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width"); @@ -2351,7 +2351,7 @@ void GUI::create_option_window() geo_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Surface display"); geo_choice[2]->menu(menu_surface_display); - geo_choice[2]->align(FL_ALIGN_RIGHT); + geo_choice[2]->align(FL_ALIGN_RIGHT); geo_choice[2]->callback(geometry_options_ok_cb); geo_choice[2]->tooltip("(Alt+d)"); @@ -2582,13 +2582,13 @@ void GUI::create_option_window() mesh_value[12]->callback(mesh_options_ok_cb); static Fl_Menu_Item menu_mesh_element_types[] = { - {"Triangles", 0, 0, 0, FL_MENU_TOGGLE}, - {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE}, - {"Tetrahedra", 0, 0, 0, FL_MENU_TOGGLE}, - {"Hexahedra", 0, 0, 0, FL_MENU_TOGGLE}, - {"Prisms", 0, 0, 0, FL_MENU_TOGGLE}, - {"Pyramids", 0, 0, 0, FL_MENU_TOGGLE}, - {0} + {"Triangles", 0, 0, 0, FL_MENU_TOGGLE}, + {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE}, + {"Tetrahedra", 0, 0, 0, FL_MENU_TOGGLE}, + {"Hexahedra", 0, 0, 0, FL_MENU_TOGGLE}, + {"Prisms", 0, 0, 0, FL_MENU_TOGGLE}, + {"Pyramids", 0, 0, 0, FL_MENU_TOGGLE}, + {0} }; mesh_menu_butt = new Fl_Menu_Button(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Elements"); @@ -2813,24 +2813,24 @@ void GUI::create_option_window() Fl_Tabs *o = new Fl_Tabs(L + WB, WB, width - 2 * WB, height - 2 * WB); { { - Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General"); - - solver_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Maximum delay for solver response"); - solver_value[0]->minimum(0); - solver_value[0]->maximum(10); - solver_value[0]->step(1); - solver_value[0]->align(FL_ALIGN_RIGHT); - solver_value[0]->callback(solver_options_ok_cb); - - solver_input[0] = new Fl_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Socket name"); - solver_input[0]->align(FL_ALIGN_RIGHT); - solver_input[0]->callback(solver_options_ok_cb); - - solver_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Always listen to incoming connection requests"); - solver_butt[0]->type(FL_TOGGLE_BUTTON); - solver_butt[0]->callback(solver_options_ok_cb); - - o->end(); + Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General"); + + solver_value[0] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Maximum delay for solver response"); + solver_value[0]->minimum(0); + solver_value[0]->maximum(10); + solver_value[0]->step(1); + solver_value[0]->align(FL_ALIGN_RIGHT); + solver_value[0]->callback(solver_options_ok_cb); + + solver_input[0] = new Fl_Input(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Socket name"); + solver_input[0]->align(FL_ALIGN_RIGHT); + solver_input[0]->callback(solver_options_ok_cb); + + solver_butt[0] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Always listen to incoming connection requests"); + solver_butt[0]->type(FL_TOGGLE_BUTTON); + solver_butt[0]->callback(solver_options_ok_cb); + + o->end(); } } o->end(); @@ -2896,10 +2896,10 @@ void GUI::create_option_window() Fl_Group *o = new Fl_Group(L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "General"); static Fl_Menu_Item menu_plot_type[] = { - {"3D", 0, 0, 0}, - {"2D space", 0, 0, 0}, - {"2D time", 0, 0, 0}, - {0} + {"3D", 0, 0, 0}, + {"2D space", 0, 0, 0}, + {"2D time", 0, 0, 0}, + {0} }; view_choice[13] = new Fl_Choice(L + 2 * WB, 2 * WB + 1 * BH, IW, BH, "Plot type"); view_choice[13]->menu(menu_plot_type); @@ -3105,12 +3105,12 @@ void GUI::create_option_window() view_butt[4]->callback(view_options_ok_cb); static Fl_Menu_Item time_display[] = { - {"None", 0, 0, 0}, - {"Value if multi-step", 0, 0, 0}, - {"Value", 0, 0, 0}, - {"Step if multi-step", 0, 0, 0}, - {"Step", 0, 0, 0}, - {0} + {"None", 0, 0, 0}, + {"Value if multi-step", 0, 0, 0}, + {"Value", 0, 0, 0}, + {"Step if multi-step", 0, 0, 0}, + {"Step", 0, 0, 0}, + {0} }; view_choice[12] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Time display mode"); view_choice[12]->menu(time_display); @@ -3132,15 +3132,15 @@ void GUI::create_option_window() view_butt[2]->callback(view_options_ok_cb); static Fl_Menu_Item menu_view_element_types[] = { - {"Points", 0, 0, 0, FL_MENU_TOGGLE}, - {"Lines", 0, 0, 0, FL_MENU_TOGGLE}, - {"Triangles", 0, 0, 0, FL_MENU_TOGGLE}, - {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE}, - {"Tetrahedra", 0, 0, 0, FL_MENU_TOGGLE}, - {"Hexahedra", 0, 0, 0, FL_MENU_TOGGLE}, - {"Prisms", 0, 0, 0, FL_MENU_TOGGLE}, - {"Pyramids", 0, 0, 0, FL_MENU_TOGGLE}, - {0} + {"Points", 0, 0, 0, FL_MENU_TOGGLE}, + {"Lines", 0, 0, 0, FL_MENU_TOGGLE}, + {"Triangles", 0, 0, 0, FL_MENU_TOGGLE}, + {"Quadrangles", 0, 0, 0, FL_MENU_TOGGLE}, + {"Tetrahedra", 0, 0, 0, FL_MENU_TOGGLE}, + {"Hexahedra", 0, 0, 0, FL_MENU_TOGGLE}, + {"Prisms", 0, 0, 0, FL_MENU_TOGGLE}, + {"Pyramids", 0, 0, 0, FL_MENU_TOGGLE}, + {0} }; view_menu_butt[1] = new Fl_Menu_Button(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Elements"); @@ -3148,11 +3148,11 @@ void GUI::create_option_window() view_menu_butt[1]->callback(view_options_ok_cb); static Fl_Menu_Item menu_boundary[] = { - {"None", 0, 0, 0}, - {"Dimension - 1", 0, 0, 0}, - {"Dimension - 2", 0, 0, 0}, - {"Dimension - 3", 0, 0, 0}, - {0} + {"None", 0, 0, 0}, + {"Dimension - 1", 0, 0, 0}, + {"Dimension - 2", 0, 0, 0}, + {"Dimension - 3", 0, 0, 0}, + {0} }; view_choice[9] = new Fl_Choice(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Element boundary mode"); view_choice[9]->menu(menu_boundary); @@ -3176,10 +3176,10 @@ void GUI::create_option_window() view_value[1]->callback(view_options_ok_cb); static Fl_Menu_Item menu_view_field_types[] = { - {"Scalar", 0, 0, 0, FL_MENU_TOGGLE}, - {"Vector", 0, 0, 0, FL_MENU_TOGGLE}, - {"Tensor", 0, 0, 0, FL_MENU_TOGGLE}, - {0} + {"Scalar", 0, 0, 0, FL_MENU_TOGGLE}, + {"Vector", 0, 0, 0, FL_MENU_TOGGLE}, + {"Tensor", 0, 0, 0, FL_MENU_TOGGLE}, + {0} }; view_menu_butt[0] = new Fl_Menu_Button(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Fields"); @@ -3237,17 +3237,17 @@ void GUI::create_option_window() view_value[46] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, 3*ss, BH, "Normal raise"); for(int i = 40; i <= 46; i++){ - view_value[i]->align(FL_ALIGN_RIGHT); - view_value[i]->when(FL_WHEN_RELEASE); - view_value[i]->callback(view_options_ok_cb); + view_value[i]->align(FL_ALIGN_RIGHT); + view_value[i]->when(FL_WHEN_RELEASE); + view_value[i]->callback(view_options_ok_cb); } for(int i = 51; i <= 59; i++){ - view_value[i]->minimum(-1.); - view_value[i]->maximum(1.); - view_value[i]->step(0.1); - view_value[i]->align(FL_ALIGN_RIGHT); - view_value[i]->when(FL_WHEN_RELEASE); - view_value[i]->callback(view_options_ok_cb); + view_value[i]->minimum(-1.); + view_value[i]->maximum(1.); + view_value[i]->step(0.1); + view_value[i]->align(FL_ALIGN_RIGHT); + view_value[i]->when(FL_WHEN_RELEASE); + view_value[i]->callback(view_options_ok_cb); } view_butt[6] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Use general transformation expressions"); @@ -3328,9 +3328,9 @@ void GUI::create_option_window() view_choice[2] = new Fl_Choice(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Vector display"); view_choice[2]->menu(menu_vectype); view_choice[2]->align(FL_ALIGN_RIGHT); - view_choice[2]->callback(view_options_ok_cb); + view_choice[2]->callback(view_options_ok_cb); - view_push_butt[0] = new Fl_Button(L + 2 * IW - 2 * WB, 2 * WB + 6 * BH, (int)(1.5*BB), BH, "Edit arrow shape"); + view_push_butt[0] = new Fl_Button(L + 2 * IW - 2 * WB, 2 * WB + 6 * BH, (int)(1.5*BB), BH, "Edit arrow shape"); view_push_butt[0]->callback(view_arrow_param_cb); view_value[60] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Arrow size"); @@ -3338,32 +3338,32 @@ void GUI::create_option_window() view_value[60]->maximum(500); view_value[60]->step(1); view_value[60]->align(FL_ALIGN_RIGHT); - view_value[60]->callback(view_options_ok_cb); + view_value[60]->callback(view_options_ok_cb); - view_butt[0] = new Fl_Check_Button(L + 2 * IW - 2 * WB, 2 * WB + 7 * BH, (int)(1.5*BB), BH, "Proportional"); - view_butt[0]->type(FL_TOGGLE_BUTTON); - view_butt[0]->callback(view_options_ok_cb); + view_butt[0] = new Fl_Check_Button(L + 2 * IW - 2 * WB, 2 * WB + 7 * BH, (int)(1.5*BB), BH, "Proportional"); + view_butt[0]->type(FL_TOGGLE_BUTTON); + view_butt[0]->callback(view_options_ok_cb); view_value[63] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Displacement factor"); view_value[63]->minimum(0.); view_value[63]->maximum(1.); view_value[63]->step(0.01); view_value[63]->align(FL_ALIGN_RIGHT); - view_value[63]->when(FL_WHEN_RELEASE); - view_value[63]->callback(view_options_ok_cb); + view_value[63]->when(FL_WHEN_RELEASE); + view_value[63]->callback(view_options_ok_cb); view_choice[10] = new Fl_Choice(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Data source"); view_choice[10]->align(FL_ALIGN_RIGHT); - view_choice[10]->add("Self"); - view_choice[10]->callback(view_options_ok_cb); + view_choice[10]->add("Self"); + view_choice[10]->callback(view_options_ok_cb); view_vector->end(); } static Fl_Menu_Item menu_vecloc[] = { - {"Barycenter", 0, 0, 0}, - {"Vertex", 0, 0, 0}, - {0} + {"Barycenter", 0, 0, 0}, + {"Vertex", 0, 0, 0}, + {0} }; view_choice[3] = new Fl_Choice(L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Glyph location"); view_choice[3]->menu(menu_vecloc); @@ -3375,8 +3375,8 @@ void GUI::create_option_window() view_butt[1]->callback(view_options_ok_cb); static Fl_Menu_Item menu_tensor[] = { - {"Von-Mises", 0, 0, 0}, - {0} + {"Von-Mises", 0, 0, 0}, + {0} }; view_choice[4] = new Fl_Choice(L + 2 * WB, 2 * WB + 11 * BH, IW, BH, "Tensor display"); view_choice[4]->menu(menu_tensor); @@ -3657,7 +3657,7 @@ void GUI::update_view_window(int num) opt_view_color_axes(num, GMSH_GUI, 0); view_colorbar_window->update(data->getName().c_str(), data->getMin(), - data->getMax(), &opt->CT, &view->getChanged()); + data->getMax(), &opt->CT, &view->getChanged()); } // Create the plugin manager window @@ -3685,14 +3685,14 @@ void GUI::create_plugin_dialog_box(GMSH_Plugin *p, int x, int y, int width, int p->dialogBox->input[i] = new Fl_Input(x + WB, y + WB + (k + 1) * BH, IW, BH, sxs->str); p->dialogBox->input[i]->align(FL_ALIGN_RIGHT); p->dialogBox->input[i]->value(sxs->def); - k++; + k++; } for(int i = 0; i < n; i++) { StringXNumber *sxn = p->getOption(i); p->dialogBox->value[i] = new Fl_Value_Input(x + WB, y + WB + (k + 1) * BH, IW, BH, sxn->str); p->dialogBox->value[i]->align(FL_ALIGN_RIGHT); p->dialogBox->value[i]->value(sxn->def); - k++; + k++; } s->end(); @@ -3748,7 +3748,7 @@ void GUI::reset_plugin_view_browser() } for(int i = 0; i < plugin_view_browser->size(); i++){ if(i < (int)state.size() && state[i]) - plugin_view_browser->select(i + 1); + plugin_view_browser->select(i + 1); } } else{ @@ -3809,8 +3809,8 @@ void GUI::create_plugin_window(int numview) create_plugin_dialog_box(p, 2 * WB + L1 + L2, WB, width - L1 - L2 - 3 * WB, height - 3 * WB - BH); // select first plugin by default if(it == GMSH_PluginManager::instance()->begin()){ - plugin_browser->select(1); - p->dialogBox->group->show(); + plugin_browser->select(1); + p->dialogBox->group->show(); } } } @@ -3825,143 +3825,143 @@ void GUI::create_plugin_window(int numview) void FieldDialogBox::save_values() { - std::list<Fl_Widget*>::iterator input=inputs.begin(); - Field *f=current_field; - std::ostringstream sstream; - std::istringstream istream; - int i; - char a; - sstream.precision(16); - for(std::map<const char*,FieldOption*>::iterator it=f->options.begin();it!=f->options.end();it++){ - FieldOption *option=it->second; - sstream.str(""); - switch(option->get_type()){ - case FIELD_OPTION_STRING: - case FIELD_OPTION_PATH: - sstream<<"\""<<((Fl_Input*)*input)->value()<<"\""; - break; - case FIELD_OPTION_INT: - sstream<<(int)((Fl_Value_Input*)*input)->value(); - break; - case FIELD_OPTION_DOUBLE: - sstream<<((Fl_Value_Input*)*input)->value(); - break; - case FIELD_OPTION_BOOL: - sstream<<(bool)((Fl_Check_Button*)*input)->value(); - break; - case FIELD_OPTION_LIST: - sstream<<"{"; - istream.str(((Fl_Input*)*input)->value()); - while(istream>>i){ - sstream<<i; - if(istream>>a){ - if(a!=',') - Msg(GERROR, "Unexpected character \'%c\' while parsing option '%s' of field \'%s\'",a,it->first,f->id); - sstream<<", "; - } - } - sstream<<"}"; - break; - } - if((*input)->changed()){ - add_field_option(f->id,it->first,sstream.str().c_str(),CTX.filename); - (*input)->clear_changed(); - } - input++; - } + std::list<Fl_Widget*>::iterator input=inputs.begin(); + Field *f=current_field; + std::ostringstream sstream; + std::istringstream istream; + int i; + char a; + sstream.precision(16); + for(std::map<const char*,FieldOption*>::iterator it=f->options.begin();it!=f->options.end();it++){ + FieldOption *option=it->second; + sstream.str(""); + switch(option->get_type()){ + case FIELD_OPTION_STRING: + case FIELD_OPTION_PATH: + sstream<<"\""<<((Fl_Input*)*input)->value()<<"\""; + break; + case FIELD_OPTION_INT: + sstream<<(int)((Fl_Value_Input*)*input)->value(); + break; + case FIELD_OPTION_DOUBLE: + sstream<<((Fl_Value_Input*)*input)->value(); + break; + case FIELD_OPTION_BOOL: + sstream<<(bool)((Fl_Check_Button*)*input)->value(); + break; + case FIELD_OPTION_LIST: + sstream<<"{"; + istream.str(((Fl_Input*)*input)->value()); + while(istream>>i){ + sstream<<i; + if(istream>>a){ + if(a!=',') + Msg(GERROR, "Unexpected character \'%c\' while parsing option '%s' of field \'%s\'",a,it->first,f->id); + sstream<<", "; + } + } + sstream<<"}"; + break; + } + if((*input)->changed()){ + add_field_option(f->id,it->first,sstream.str().c_str(),CTX.filename); + (*input)->clear_changed(); + } + input++; + } } void FieldDialogBox::load_field(Field *f){ - current_field=f; - std::list<Fl_Widget*>::iterator input=inputs.begin(); - for(std::map<const char*,FieldOption*>::iterator it=f->options.begin();it!=f->options.end();it++){ - FieldOption *option=it->second; - std::ostringstream vstr; - std::list<int>::iterator list_it;; - switch(option->get_type()){ - case FIELD_OPTION_STRING: - case FIELD_OPTION_PATH: - ((Fl_Input*)(*input))->value(option->string().c_str()); - break; - case FIELD_OPTION_INT: - case FIELD_OPTION_DOUBLE: - ((Fl_Value_Input*)(*input))->value(option->numerical_value()); - break; - case FIELD_OPTION_BOOL: - ((Fl_Check_Button*)(*input))->value(option->numerical_value()); - break; - case FIELD_OPTION_LIST: - vstr.str(""); - for(list_it=option->list().begin();list_it!=option->list().end();list_it++){ - if(list_it!=option->list().begin()) - vstr<<", "; - vstr<<*list_it; - } - ((Fl_Input*)(*input))->value(vstr.str().c_str()); - break; - } - input++; - } + current_field=f; + std::list<Fl_Widget*>::iterator input=inputs.begin(); + for(std::map<const char*,FieldOption*>::iterator it=f->options.begin();it!=f->options.end();it++){ + FieldOption *option=it->second; + std::ostringstream vstr; + std::list<int>::iterator list_it;; + switch(option->get_type()){ + case FIELD_OPTION_STRING: + case FIELD_OPTION_PATH: + ((Fl_Input*)(*input))->value(option->string().c_str()); + break; + case FIELD_OPTION_INT: + case FIELD_OPTION_DOUBLE: + ((Fl_Value_Input*)(*input))->value(option->numerical_value()); + break; + case FIELD_OPTION_BOOL: + ((Fl_Check_Button*)(*input))->value(option->numerical_value()); + break; + case FIELD_OPTION_LIST: + vstr.str(""); + for(list_it=option->list().begin();list_it!=option->list().end();list_it++){ + if(list_it!=option->list().begin()) + vstr<<", "; + vstr<<*list_it; + } + ((Fl_Input*)(*input))->value(vstr.str().c_str()); + break; + } + input++; + } if(PView::list.size()){ put_on_view_btn->activate(); for(unsigned int i = 0; i < PView::list.size(); i++) { - std::ostringstream s; - s<<"View ["<<i<<"]"; + std::ostringstream s; + s<<"View ["<<i<<"]"; put_on_view_btn->add(s.str().c_str()); } }else{ - put_on_view_btn->deactivate(); - } + put_on_view_btn->deactivate(); + } set_size_btn->value(GModel::current()->getFields()->background_field==f->id); } FieldDialogBox::FieldDialogBox(Field *f, int x, int y, int width, int height,int fontsize) { - current_field=NULL; - group=new Fl_Group(x, y, width, height); + current_field=NULL; + group=new Fl_Group(x, y, width, height); { - Fl_Box *b = new Fl_Box(x, y, width, BH,f->get_name()); - b->labelfont(FL_BOLD); + Fl_Box *b = new Fl_Box(x, y, width, BH,f->get_name()); + b->labelfont(FL_BOLD); Fl_Tabs *o = new Fl_Tabs(x, y + BH + WB, width, height-2*BH-2*WB); - group->resizable(o); + group->resizable(o); { Fl_Group *g = new Fl_Group(x, y + 2*BH + WB, width, height - 2*BH-3*WB, "Options"); - apply_btn = new Fl_Return_Button(x+width - BB-WB ,y+ height - 2*BH -2*WB, BB, BH, "Apply"); - apply_btn->callback(view_field_apply_cb,this); - revert_btn = new Fl_Button(x+width - 2*BB-2*WB ,y+ height - 2*BH -2*WB, BB, BH, "Revert"); - revert_btn->callback(view_field_revert_cb,this); + apply_btn = new Fl_Return_Button(x+width - BB-WB ,y+ height - 2*BH -2*WB, BB, BH, "Apply"); + apply_btn->callback(view_field_apply_cb,this); + revert_btn = new Fl_Button(x+width - 2*BB-2*WB ,y+ height - 2*BH -2*WB, BB, BH, "Revert"); + revert_btn->callback(view_field_revert_cb,this); Fl_Scroll *s = new Fl_Scroll(x + WB, y + 2*WB + 2*BH, width - 2 * WB, height - 4*BH - 5 * WB); - double yy=y+3*WB+2*BH; - for(std::map<const char*,FieldOption*>::iterator it=f->options.begin();it!=f->options.end();it++){ - Fl_Widget *input; - switch(it->second->get_type()){ - case FIELD_OPTION_INT: - case FIELD_OPTION_DOUBLE: - input=new Fl_Value_Input(x+WB,yy,IW,BH,it->first); - break; - case FIELD_OPTION_BOOL: - input=new Fl_Check_Button(x+WB,yy,BH,BH,it->first); - break; - case FIELD_OPTION_PATH: - case FIELD_OPTION_STRING: - input=new Fl_Input(x+WB,yy,IW,BH,it->first); - break; - case FIELD_OPTION_LIST: - /*{ - Fl_Button *b=new Fl_Button(x+WB,yy,BH,BH); - b->label("@+"); - b->callback(view_field_select_node_cb); - } - input=new Fl_Input(x+WB+2*BH,yy,IW-2*BH,BH,it->first);*/ - input=new Fl_Input(x+WB,yy,IW,BH,it->first); - break; - } - input->align(FL_ALIGN_RIGHT); - inputs.push_back(input); - yy+=WB+BH; - } + double yy=y+3*WB+2*BH; + for(std::map<const char*,FieldOption*>::iterator it=f->options.begin();it!=f->options.end();it++){ + Fl_Widget *input; + switch(it->second->get_type()){ + case FIELD_OPTION_INT: + case FIELD_OPTION_DOUBLE: + input=new Fl_Value_Input(x+WB,yy,IW,BH,it->first); + break; + case FIELD_OPTION_BOOL: + input=new Fl_Check_Button(x+WB,yy,BH,BH,it->first); + break; + case FIELD_OPTION_PATH: + case FIELD_OPTION_STRING: + input=new Fl_Input(x+WB,yy,IW,BH,it->first); + break; + case FIELD_OPTION_LIST: + /*{ + Fl_Button *b=new Fl_Button(x+WB,yy,BH,BH); + b->label("@+"); + b->callback(view_field_select_node_cb); + } + input=new Fl_Input(x+WB+2*BH,yy,IW-2*BH,BH,it->first);*/ + input=new Fl_Input(x+WB,yy,IW,BH,it->first); + break; + } + input->align(FL_ALIGN_RIGHT); + inputs.push_back(input); + yy+=WB+BH; + } o->resizable(g); // to avoid ugly resizing of tab labels - g->resizable(s); + g->resizable(s); s->end(); g->end(); } @@ -3986,18 +3986,18 @@ FieldDialogBox::FieldDialogBox(Field *f, int x, int y, int width, int height,int } o->end(); } - { - Fl_Button *b = new Fl_Button(x+width - BB,y+ height - BH , BB, BH, "Delete"); - b->callback(view_field_delete_cb,this); - } - put_on_view_btn = new Fl_Menu_Button(x+BB*3/2+WB,y+ height - BH ,BB*3/2,BH,"Put on view"); - put_on_view_btn->callback(view_field_put_on_view_cb,this); + { + Fl_Button *b = new Fl_Button(x+width - BB,y+ height - BH , BB, BH, "Delete"); + b->callback(view_field_delete_cb,this); + } + put_on_view_btn = new Fl_Menu_Button(x+BB*3/2+WB,y+ height - BH ,BB*3/2,BH,"Put on view"); + put_on_view_btn->callback(view_field_put_on_view_cb,this); - set_size_btn = new Fl_Check_Button(x,y+ height - BH ,BB*3/2,BH,"Background size"); - set_size_btn->callback(view_field_set_size_btn_cb,this); + set_size_btn = new Fl_Check_Button(x,y+ height - BH ,BB*3/2,BH,"Background size"); + set_size_btn->callback(view_field_set_size_btn_cb,this); - group->end(); - group->hide(); + group->end(); + group->hide(); } void GUI::create_field_window(int numfield) @@ -4009,48 +4009,48 @@ void GUI::create_field_window(int numfield) int height = (CTX.field_size[1] < height0) ? height0 : CTX.field_size[1]; int L1 = BB; - int i_entry=1; + int i_entry=1; if(field_window) { - width=field_window->w(); - height=field_window->h(); - FieldManager &fields=*GModel::current()->getFields(); - field_browser->clear(); - for(FieldManager::iterator it=fields.begin();it!=fields.end();it++){ - Field *field=it->second; - std::ostringstream sstream; - if(it->first==fields.background_field) - sstream<<"*"; - sstream<<it->first; - sstream<<" "<<field->get_name(); - field_browser->add(sstream.str().c_str(),field); - if(!field->dialog_box()){ - field_window->begin(); - field->dialog_box()=new FieldDialogBox(field, 2 * WB + L1 , WB, width - L1 - 3 * WB, height - 2*WB ,fontsize); - field_window->end(); - } - if(it->second->id==numfield){ - field_browser->select(i_entry); - field_browser->do_callback(); - } - i_entry++; - } + width=field_window->w(); + height=field_window->h(); + FieldManager &fields=*GModel::current()->getFields(); + field_browser->clear(); + for(FieldManager::iterator it=fields.begin();it!=fields.end();it++){ + Field *field=it->second; + std::ostringstream sstream; + if(it->first==fields.background_field) + sstream<<"*"; + sstream<<it->first; + sstream<<" "<<field->get_name(); + field_browser->add(sstream.str().c_str(),field); + if(!field->dialog_box()){ + field_window->begin(); + field->dialog_box()=new FieldDialogBox(field, 2 * WB + L1 , WB, width - L1 - 3 * WB, height - 2*WB ,fontsize); + field_window->end(); + } + if(it->second->id==numfield){ + field_browser->select(i_entry); + field_browser->do_callback(); + } + i_entry++; + } field_window->show(); return; } - selected_field_dialog_box=NULL; + selected_field_dialog_box=NULL; field_window = new Dialog_Window(width, height, "Fields"); field_window->box(GMSH_WINDOW_BOX); Fl_Group *resize_box = new Fl_Group(2*WB+L1, 2*WB+BB,width-3*WB-L1, height - 3 * WB-BB); - resize_box->end(); - { - Fl_Menu_Button *b= new Fl_Menu_Button(WB,WB,L1,BH,"New"); - FieldManager &fields=*GModel::current()->getFields(); - std::map<const std::string, FieldFactory*>::iterator it; - for(it=fields.map_type_name.begin();it!=fields.map_type_name.end();it++) - b->add(it->first.c_str()); - b->callback(view_field_new_cb); - } + resize_box->end(); + { + Fl_Menu_Button *b= new Fl_Menu_Button(WB,WB,L1,BH,"New"); + FieldManager &fields=*GModel::current()->getFields(); + std::map<const std::string, FieldFactory*>::iterator it; + for(it=fields.map_type_name.begin();it!=fields.map_type_name.end();it++) + b->add(it->first.c_str()); + b->callback(view_field_new_cb); + } field_browser = new Fl_Hold_Browser(WB, 2*WB+BH, L1, height - 3 * WB - BH); field_browser->callback(view_field_browser_cb); field_window->resizable(resize_box); @@ -4336,8 +4336,8 @@ class Vis_Browser : public Fl_Browser{ switch(Fl::event_key()) { case FL_Enter: case FL_KP_Enter: - visibility_ok_cb(NULL, NULL); - return 1; + visibility_ok_cb(NULL, NULL); + return 1; } } return Fl_Browser::handle(event); @@ -4376,7 +4376,7 @@ void GUI::create_visibility_window(bool redraw_only) vis_type->menu(type_table); vis_butt[0] = new Fl_Check_Button(WB + (width - 3 * WB) / 2 + WB, WB, (width - 3 * WB) / 2, BH, - "Set visibility recursively"); + "Set visibility recursively"); vis_butt[0]->type(FL_TOGGLE_BUTTON); vis_butt[0]->value(1); @@ -4475,7 +4475,7 @@ void GUI::create_visibility_window(bool redraw_only) int ll = width/2 - BH - WB - IW; Fl_Box *b2 = new Fl_Box(FL_NO_BOX, ll, 3 * WB + 2 * BH, IW, BH, - "Hide with the mouse:"); + "Hide with the mouse:"); b2->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER); Fl_Button *butt1 = new Fl_Button(ll, 3 * WB + 3 * BH, IW, BH, "Elements"); @@ -4495,7 +4495,7 @@ void GUI::create_visibility_window(bool redraw_only) int ll2 = ll + IW + WB + 2*BH + WB; Fl_Box *b12 = new Fl_Box(FL_NO_BOX, ll2, 3 * WB + 2 * BH, IW, BH, - "Show with the mouse:"); + "Show with the mouse:"); b12->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER); Fl_Button *butt11 = new Fl_Button(ll2, 3 * WB + 3 * BH, IW, BH, "Elements"); @@ -4789,7 +4789,7 @@ void GUI::create_about_window() sprintf(buffer, "@c@.License: %s", Get_GmshShortLicense()); o->add(buffer); sprintf(buffer, "@c@.Graphical user interface toolkit: FLTK %d.%d.%d", - FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION); + FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION); o->add(buffer); sprintf(buffer, "@c@.Build OS: %s", Get_GmshBuildOS()); o->add(buffer); @@ -4802,21 +4802,21 @@ void GUI::create_about_window() strcpy(str1, Get_BuildOptions()); unsigned int len = 30; if(strlen(str1) > len){ - int split; - for(split = len - 1; split >= 0; split--){ - if(str1[split] == ' '){ - str1[split] = '\0'; - break; - } - } - sprintf(buffer, "@c@.Build options: %s", str1); - o->add(buffer); - sprintf(buffer, "@c@.%s", &str1[split+1]); - o->add(buffer); + int split; + for(split = len - 1; split >= 0; split--){ + if(str1[split] == ' '){ + str1[split] = '\0'; + break; + } + } + sprintf(buffer, "@c@.Build options: %s", str1); + o->add(buffer); + sprintf(buffer, "@c@.%s", &str1[split+1]); + o->add(buffer); } else{ - sprintf(buffer, "@c@.Options: %s", str1); - o->add(buffer); + sprintf(buffer, "@c@.Options: %s", str1); + o->add(buffer); } } sprintf(buffer, "@c@.Packaged by: %s", Get_GmshPackager()); @@ -4838,7 +4838,7 @@ void GUI::create_about_window() } about_window->position(Fl::x() + Fl::w()/2 - width / 2, - Fl::y() + Fl::h()/2 - height / 2); + Fl::y() + Fl::h()/2 - height / 2); about_window->end(); } @@ -5116,8 +5116,8 @@ void GUI::create_solver_window(int num) solver[num].butt[1] = new Fl_Check_Button(3 * WB + ww, 2 * WB + 2 * BH, ww, BH, "Auto-load results"); for(int i = 0; i < 3; i++){ - solver[num].butt[i]->type(FL_TOGGLE_BUTTON); - solver[num].butt[i]->callback(solver_ok_cb, (void *)num); + solver[num].butt[i]->type(FL_TOGGLE_BUTTON); + solver[num].butt[i]->callback(solver_ok_cb, (void *)num); } solver[num].input[0] = new Fl_Input(2 * WB + BB / 2, 2 * WB + 4 * BH, LL - BB / 2, BH, "Input"); @@ -5137,20 +5137,20 @@ void GUI::create_solver_window(int num) for(int i = 0; i < SINFO[num].nboptions; i++) { solver[num].choice[i] = new Fl_Choice(2 * WB, 2 * WB + (6 + i) * BH, LL, BH, - SINFO[num].option_name[i]); + SINFO[num].option_name[i]); solver[num].choice[i]->align(FL_ALIGN_RIGHT); } static int arg[MAXSOLVERS][5][2]; for(int i = 0; i < 5; i++) { - if(strlen(SINFO[num].button_name[i])) { - arg[num][i][0] = num; - arg[num][i][1] = i; - solver[num].command[i] = new Fl_Button((2 + i) * WB + i * BBS, - 3 * WB + (6 + SINFO[num].nboptions) * BH, - BBS, BH, SINFO[num].button_name[i]); - solver[num].command[i]->callback(solver_command_cb, (void *)arg[num][i]); - } + if(strlen(SINFO[num].button_name[i])) { + arg[num][i][0] = num; + arg[num][i][1] = i; + solver[num].command[i] = new Fl_Button((2 + i) * WB + i * BBS, + 3 * WB + (6 + SINFO[num].nboptions) * BH, + BBS, BH, SINFO[num].button_name[i]); + solver[num].command[i]->callback(solver_command_cb, (void *)arg[num][i]); + } } g->end(); diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 7885788f3f9c77925358620f91ee0e95047088b6..bb3b57ccced466e56b6906b0fcb593230fc2a1c8 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -115,15 +115,15 @@ class FieldDialogBox { std::list<Fl_Widget*> inputs; std::list<std::string> inputs_values; - public: - Field *current_field; + public: + Field *current_field; Fl_Group *group; - Fl_Menu_Button *put_on_view_btn; - Fl_Check_Button *set_size_btn; - Fl_Button *apply_btn,*revert_btn; - FieldDialogBox(Field *field,int x,int y, int width, int height,int fontsize); - void load_field(Field *field); - void save_values(); + Fl_Menu_Button *put_on_view_btn; + Fl_Check_Button *set_size_btn; + Fl_Button *apply_btn,*revert_btn; + FieldDialogBox(Field *field,int x,int y, int width, int height,int fontsize); + void load_field(Field *field); + void save_values(); }; // The dialog for solvers @@ -229,10 +229,10 @@ public: Fl_Return_Button *view_ok; Fl_Menu_Button *view_menu_butt[2]; - // Field window + // Field window Fl_Window *field_window; - Fl_Hold_Browser *field_browser; - FieldDialogBox *selected_field_dialog_box; + Fl_Hold_Browser *field_browser; + FieldDialogBox *selected_field_dialog_box; // Plugin window Fl_Window *plugin_window; @@ -306,7 +306,7 @@ public: void create_view_options_window(int numview); void create_plugin_dialog_box(GMSH_Plugin *p, int x, int y, int width, int height); void create_plugin_window(int numview); - void create_field_dialog_box(Field *f, int x, int y, int width, int height); + void create_field_dialog_box(Field *f, int x, int y, int width, int height); void create_field_window(int numview); void create_visibility_window(bool redraw_only=false); void create_clip_window(); diff --git a/Fltk/GUI_Classifier.cpp b/Fltk/GUI_Classifier.cpp index 354fcbb8989dfb2c8d2ec6ffe0d7f0980b703bb5..ca3f704b6cb38e4092bd6a13416bacb847ce5d94 100644 --- a/Fltk/GUI_Classifier.cpp +++ b/Fltk/GUI_Classifier.cpp @@ -1,4 +1,4 @@ -// $Id: GUI_Classifier.cpp,v 1.9 2008-02-17 08:47:57 geuzaine Exp $ +// $Id: GUI_Classifier.cpp,v 1.10 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -104,9 +104,9 @@ struct compareMLinePtr void recurClassify ( MTri3 *t , - GFace *gf, - std::map<MLine*, GEdge*, compareMLinePtr> &lines, - std::map<MTriangle*, GFace*> &reverse) + GFace *gf, + std::map<MLine*, GEdge*, compareMLinePtr> &lines, + std::map<MTriangle*, GFace*> &reverse) { if (!t->isDeleted()) { @@ -116,17 +116,17 @@ void recurClassify ( MTri3 *t , t->setDeleted ( true ); for (int i=0;i<3;i++) - { - MTri3 *tn = t->getNeigh(i); - if (tn) - { - edgeXface exf ( t, i); - MLine ml (exf.v[0],exf.v[1]); - std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml); - if (it==lines.end()) - recurClassify (tn, gf,lines, reverse); - } - } + { + MTri3 *tn = t->getNeigh(i); + if (tn) + { + edgeXface exf ( t, i); + MLine ml (exf.v[0],exf.v[1]); + std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml); + if (it==lines.end()) + recurClassify (tn, gf,lines, reverse); + } + } } } @@ -155,10 +155,10 @@ GEdge * getNewModelEdge (GFace *gf1, GFace *gf2, std::map< std::pair <int, int> void recurClassifyEdges ( MTri3 *t , - std::map<MTriangle*, GFace*> &reverse, - std::map<MLine*, GEdge*, compareMLinePtr> &lines, - std::set<MLine*> &touched, - std::map< std::pair <int, int> , GEdge* > &newEdges) + std::map<MTriangle*, GFace*> &reverse, + std::map<MLine*, GEdge*, compareMLinePtr> &lines, + std::set<MLine*> &touched, + std::map< std::pair <int, int> , GEdge* > &newEdges) { if (!t->isDeleted()) { @@ -166,27 +166,27 @@ void recurClassifyEdges ( MTri3 *t , GFace *gf1 = reverse[t->tri()]; for (int i=0;i<3;i++) - { - GFace *gf2 = 0; - MTri3 *tn = t->getNeigh(i); - if (tn) - gf2 = reverse[tn->tri()]; - - edgeXface exf ( t, i); - MLine ml (exf.v[0],exf.v[1]); - std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml); - if (it != lines.end()) - { - if (touched.find(it->first) == touched.end()) - { - GEdge *ge = getNewModelEdge (gf1, gf2, newEdges); - if (ge) ge->lines.push_back(it->first); - touched.insert(it->first); - } - } - if (tn) - recurClassifyEdges (tn, reverse,lines, touched,newEdges); - } + { + GFace *gf2 = 0; + MTri3 *tn = t->getNeigh(i); + if (tn) + gf2 = reverse[tn->tri()]; + + edgeXface exf ( t, i); + MLine ml (exf.v[0],exf.v[1]); + std::map<MLine*, GEdge*, compareMLinePtr>::iterator it = lines.find(&ml); + if (it != lines.end()) + { + if (touched.find(it->first) == touched.end()) + { + GEdge *ge = getNewModelEdge (gf1, gf2, newEdges); + if (ge) ge->lines.push_back(it->first); + touched.insert(it->first); + } + } + if (tn) + recurClassifyEdges (tn, reverse,lines, touched,newEdges); + } } } @@ -201,7 +201,7 @@ void class_color_cb(Fl_Widget* w, void* data) GModel::eiter ite = GModel::current()->lastEdge(); for( ;it!=ite;++it) { - for (unsigned int i=0;i<(*it)->lines.size();i++)lines[(*it)->lines[i] ] = *it; + for (unsigned int i=0;i<(*it)->lines.size();i++)lines[(*it)->lines[i] ] = *it; } } @@ -211,13 +211,13 @@ void class_color_cb(Fl_Widget* w, void* data) std::set<GFace*>::iterator it = e->_faces.begin(); while (it != e->_faces.end()) { - GFace *gf = *it; - for (unsigned int i=0;i<gf->triangles.size();i++) - { - tris.push_back (new MTri3 ( gf->triangles [i] , 0 ) ); - } - gf->triangles.clear(); - ++it; + GFace *gf = *it; + for (unsigned int i=0;i<gf->triangles.size();i++) + { + tris.push_back (new MTri3 ( gf->triangles [i] , 0 ) ); + } + gf->triangles.clear(); + ++it; } } @@ -231,21 +231,21 @@ void class_color_cb(Fl_Widget* w, void* data) std::list<MTri3*> ::iterator it = tris.begin(); while (it != tris.end()) { - if (!(*it)->isDeleted()) - { - discreteFace *temporary = new discreteFace(GModel::current(), maxFaceNum() + 1); - recurClassify(*it, temporary, lines, reverse); - GModel::current()->add(temporary); - } - ++it; + if (!(*it)->isDeleted()) + { + discreteFace *temporary = new discreteFace(GModel::current(), maxFaceNum() + 1); + recurClassify(*it, temporary, lines, reverse); + GModel::current()->add(temporary); + } + ++it; } // color some lines it = tris.begin(); while (it != tris.end()) { - (*it)->setDeleted(false); - ++it; + (*it)->setDeleted(false); + ++it; } it = tris.begin(); @@ -257,8 +257,8 @@ void class_color_cb(Fl_Widget* w, void* data) while (it != tris.end()) { - delete *it; - ++it; + delete *it; + ++it; } } @@ -285,17 +285,17 @@ void updateedges_cb(Fl_Widget* w, void* data) edge_angle ea = e->edges_detected[i]; // printf("angle = %g\n",ea.angle); if ( ea.angle <= e -> _inputs[CLASSVALUE_ANGLE] ->value() / 180 * M_PI) - break; + break; e->temporary->lines.push_back(new MLine(ea.v1, ea.v2)); } if (e->_togbuttons[CLASSTOGBUTTON_CLOS]->value()) { for (unsigned int i=0 ; i<e->edges_lonly.size();i++) - { - edge_angle ea = e->edges_lonly[i]; - e->temporary->lines.push_back(new MLine(ea.v1, ea.v2)); - } + { + edge_angle ea = e->edges_lonly[i]; + e->temporary->lines.push_back(new MLine(ea.v1, ea.v2)); + } } @@ -313,24 +313,24 @@ edge_angle:: edge_angle ( MVertex *_v1, MVertex *_v2, MTriangle *t1, MTriangle double c2[3]; double c3[3]; { - MVertex *p1 = t1->getVertex(0); - MVertex *p2 = t1->getVertex(1); - MVertex *p3 = t1->getVertex(2); - double a[3] = { p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z() }; - double b[3] = { p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z() }; - c1[2] = a[0] * b[1] - a[1] * b[0]; - c1[1] = -a[0] * b[2] + a[2] * b[0]; - c1[0] = a[1] * b[2] - a[2] * b[1]; + MVertex *p1 = t1->getVertex(0); + MVertex *p2 = t1->getVertex(1); + MVertex *p3 = t1->getVertex(2); + double a[3] = { p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z() }; + double b[3] = { p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z() }; + c1[2] = a[0] * b[1] - a[1] * b[0]; + c1[1] = -a[0] * b[2] + a[2] * b[0]; + c1[0] = a[1] * b[2] - a[2] * b[1]; } { - MVertex *p1 = t2->getVertex(0); - MVertex *p2 = t2->getVertex(1); - MVertex *p3 = t2->getVertex(2); - double a[3] = { p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z() }; - double b[3] = { p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z() }; - c2[2] = a[0] * b[1] - a[1] * b[0]; - c2[1] = -a[0] * b[2] + a[2] * b[0]; - c2[0] = a[1] * b[2] - a[2] * b[1]; + MVertex *p1 = t2->getVertex(0); + MVertex *p2 = t2->getVertex(1); + MVertex *p3 = t2->getVertex(2); + double a[3] = { p1->x() - p2->x(), p1->y() - p2->y(), p1->z() - p2->z() }; + double b[3] = { p1->x() - p3->x(), p1->y() - p3->y(), p1->z() - p3->z() }; + c2[2] = a[0] * b[1] - a[1] * b[0]; + c2[1] = -a[0] * b[2] + a[2] * b[0]; + c2[0] = a[1] * b[2] - a[2] * b[1]; } norme(c1); norme(c2); @@ -347,9 +347,9 @@ void buildListOfEdgeAngle ( e2t_cont adj,std::vector<edge_angle> &edges_detected for ( ; it!=adj.end();++it ) { if ( it->second.second ) edges_detected.push_back ( edge_angle ( it->first.getVertex (0) ,it->first.getVertex (1) , - it->second.first,it->second.second) ); + it->second.first,it->second.second) ); else edges_lonly.push_back ( edge_angle ( it->first.getVertex (0) ,it->first.getVertex (1) , - it->second.first,it->second.second) ); + it->second.first,it->second.second) ); } std::sort ( edges_detected .begin() , edges_detected .end() ); } @@ -486,21 +486,21 @@ void class_select_cb(Fl_Widget *w, void *data) Draw(); Msg(ONSCREEN, "Select Elements\n" - "[Press 'e' to end selection or 'q' to abort]"); + "[Press 'e' to end selection or 'q' to abort]"); char ib = SelectEntity(ENT_ALL, vertices, edges, faces, regions, elements); if(ib == 'l') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < elements.size(); i++){ - if(elements[i]->getNumEdges() == 3 && elements[i]->getVisibility() != 2){ - elements[i]->setVisibility(2); ele.push_back((MTriangle*)elements[i]); - } - } + for(unsigned int i = 0; i < elements.size(); i++){ + if(elements[i]->getNumEdges() == 3 && elements[i]->getVisibility() != 2){ + elements[i]->setVisibility(2); ele.push_back((MTriangle*)elements[i]); + } + } } } if(ib == 'r') { for(unsigned int i = 0; i < elements.size(); i++) - elements[i]->setVisibility(1); + elements[i]->setVisibility(1); } // ok, we compute edges ! if(ib == 'e') { @@ -545,20 +545,20 @@ void class_selectgface_cb(Fl_Widget *w, void *data) Draw(); Msg(ONSCREEN, "Select Model Face\n" - "[Press 'e' to end selection or 'q' to abort]"); + "[Press 'e' to end selection or 'q' to abort]"); char ib = SelectEntity(ENT_SURFACE, vertices, edges, faces, regions, elements); if(ib == 'l') { for(unsigned int i = 0; i < faces.size(); i++){ - HighlightEntity(faces[i]); - temp.push_back(faces[i]); + HighlightEntity(faces[i]); + temp.push_back(faces[i]); } } // ok store the list of gfaces ! if(ib == 'e') { ZeroHighlight(); for(unsigned int i = 0; i < temp.size(); i++){ - e->_faces.insert (temp[i]); + e->_faces.insert (temp[i]); } break; } @@ -591,21 +591,21 @@ void class_deleteedge_cb(Fl_Widget *w, void *data) Draw(); Msg(ONSCREEN, "Select Elements\n" - "[Press 'e' to end selection or 'q' to abort]"); + "[Press 'e' to end selection or 'q' to abort]"); char ib = SelectEntity(ENT_ALL, vertices, edges, faces, regions, elements); if(ib == 'l') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < elements.size(); i++){ - if(elements[i]->getNumEdges() == 1 && elements[i]->getVisibility() != 2){ - elements[i]->setVisibility(2); ele.push_back((MLine*)elements[i]); - } - } + for(unsigned int i = 0; i < elements.size(); i++){ + if(elements[i]->getNumEdges() == 1 && elements[i]->getVisibility() != 2){ + elements[i]->setVisibility(2); ele.push_back((MLine*)elements[i]); + } + } } } if(ib == 'r') { for(unsigned int i = 0; i < elements.size(); i++) - elements[i]->setVisibility(1); + elements[i]->setVisibility(1); } // ok, we compute edges ! if(ib == 'e') { @@ -630,9 +630,9 @@ void class_deleteedge_cb(Fl_Widget *w, void *data) { std::vector<MLine*>::iterator it = std::find (ele.begin(),ele.end(),temp[i]); if (it != ele.end()) - { - delete temp[i]; - } + { + delete temp[i]; + } else e->temporary->lines.push_back(temp[i]); } diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp index 065d0be223bcd1db7e627dbbd796469c8858619a..7031e0a7181c115881ed7a23f2772602beb7248c 100644 --- a/Fltk/GUI_Extras.cpp +++ b/Fltk/GUI_Extras.cpp @@ -1,4 +1,4 @@ -// $Id: GUI_Extras.cpp,v 1.44 2008-02-17 08:47:57 geuzaine Exp $ +// $Id: GUI_Extras.cpp,v 1.45 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,7 +45,7 @@ extern Context_T CTX; // File chooser int file_chooser(int multi, int create, const char *message, - const char *filter, const char *fname) + const char *filter, const char *fname) { static char thefilter[1024] = ""; static int thefilterindex = 0; @@ -84,7 +84,7 @@ int file_chooser(int multi, int create, const char *message, Fl_File_Chooser::all_files_label = "All files (*)"; if(!fc) { fc = new File_Picker(getenv("PWD") ? "." : CTX.home_dir, thefilter, - Fl_File_Chooser::SINGLE, message); + Fl_File_Chooser::SINGLE, message); fc->position(CTX.file_chooser_position[0], CTX.file_chooser_position[1]); } if(multi) @@ -177,14 +177,14 @@ int arrow_editor(const char *title, double &a, double &b, double &c) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == editor->apply) { - a = editor->sa->value(); - b = editor->sb->value(); - c = editor->sc->value(); - return 1; + a = editor->sa->value(); + b = editor->sb->value(); + c = editor->sc->value(); + return 1; } if (o == editor->window || o == editor->cancel){ - editor->window->hide(); - return 0; + editor->window->hide(); + return 0; } } } @@ -203,7 +203,7 @@ class Release_Slider : public Fl_Slider { switch (event) { case FL_RELEASE: if(window()) - window()->hide(); + window()->hide(); return 1; default: return Fl_Slider::handle(event); @@ -280,14 +280,14 @@ int generic_bitmap_dialog(const char *name, const char *title, int format) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_print_text(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); - CreateOutputFile(name, format); - dialog->window->hide(); - return 1; + opt_print_text(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); + CreateOutputFile(name, format); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -333,14 +333,14 @@ int latex_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_print_tex_as_equation(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); - CreateOutputFile(name, FORMAT_TEX); - dialog->window->hide(); - return 1; + opt_print_tex_as_equation(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); + CreateOutputFile(name, FORMAT_TEX); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -401,16 +401,16 @@ int jpeg_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_print_jpeg_quality(0, GMSH_SET | GMSH_GUI, (int)dialog->s[0]->value()); - opt_print_jpeg_smoothing(0, GMSH_SET | GMSH_GUI, (int)dialog->s[1]->value()); - opt_print_text(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); - CreateOutputFile(name, FORMAT_JPEG); - dialog->window->hide(); - return 1; + opt_print_jpeg_quality(0, GMSH_SET | GMSH_GUI, (int)dialog->s[0]->value()); + opt_print_jpeg_smoothing(0, GMSH_SET | GMSH_GUI, (int)dialog->s[1]->value()); + opt_print_text(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); + CreateOutputFile(name, FORMAT_JPEG); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -466,18 +466,18 @@ int gif_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_print_gif_dither(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value()); - opt_print_gif_interlace(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value()); - opt_print_gif_sort(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value()); - opt_print_gif_transparent(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value()); - opt_print_text(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value()); - CreateOutputFile(name, FORMAT_GIF); - dialog->window->hide(); - return 1; + opt_print_gif_dither(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value()); + opt_print_gif_interlace(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value()); + opt_print_gif_sort(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value()); + opt_print_gif_transparent(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value()); + opt_print_text(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value()); + CreateOutputFile(name, FORMAT_GIF); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -589,23 +589,23 @@ int gl2ps_dialog(const char *name, const char *title, int format) if (!o) break; if (o == dialog->c){ - activate_gl2ps_choices(format, dialog->c->value(), dialog->b); + activate_gl2ps_choices(format, dialog->c->value(), dialog->b); } if (o == dialog->ok) { - opt_print_eps_quality(0, GMSH_SET | GMSH_GUI, dialog->c->value()); - opt_print_eps_compress(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value()); - opt_print_eps_background(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value()); - opt_print_eps_occlusion_culling(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value()); - opt_print_eps_best_root(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value()); - opt_print_eps_ps3shading(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value()); - opt_print_text(0, GMSH_SET | GMSH_GUI, dialog->b[5]->value()); - CreateOutputFile(name, format); - dialog->window->hide(); - return 1; + opt_print_eps_quality(0, GMSH_SET | GMSH_GUI, dialog->c->value()); + opt_print_eps_compress(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value()); + opt_print_eps_background(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value()); + opt_print_eps_occlusion_culling(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value()); + opt_print_eps_best_root(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value()); + opt_print_eps_ps3shading(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value()); + opt_print_text(0, GMSH_SET | GMSH_GUI, dialog->b[5]->value()); + CreateOutputFile(name, format); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -654,13 +654,13 @@ int options_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - Print_Options(0, GMSH_FULLRC, dialog->b[0]->value(), dialog->b[1]->value(), name); - dialog->window->hide(); - return 1; + Print_Options(0, GMSH_FULLRC, dialog->b[0]->value(), dialog->b[1]->value(), name); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -706,14 +706,14 @@ int geo_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_print_geo_labels(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); - CreateOutputFile(name, FORMAT_GEO); - dialog->window->hide(); - return 1; + opt_print_geo_labels(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_GEO); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -768,19 +768,19 @@ int pos_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); - opt_print_pos_elementary(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0); - opt_print_pos_element(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value() ? 1 : 0); - opt_print_pos_gamma(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value() ? 1 : 0); - opt_print_pos_eta(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value() ? 1 : 0); - opt_print_pos_rho(0, GMSH_SET | GMSH_GUI, dialog->b[5]->value() ? 1 : 0); - CreateOutputFile(name, FORMAT_POS); - dialog->window->hide(); - return 1; + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); + opt_print_pos_elementary(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0); + opt_print_pos_element(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value() ? 1 : 0); + opt_print_pos_gamma(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value() ? 1 : 0); + opt_print_pos_eta(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value() ? 1 : 0); + opt_print_pos_rho(0, GMSH_SET | GMSH_GUI, dialog->b[5]->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_POS); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -827,14 +827,14 @@ int generic_mesh_dialog(const char *name, const char *title, int format) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); - CreateOutputFile(name, format); - dialog->window->hide(); - return 1; + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); + CreateOutputFile(name, format); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -883,7 +883,7 @@ int msh_dialog(const char *name) } dialog->c->value((CTX.mesh.msh_file_version == 1.0) ? 0 : - CTX.mesh.msh_binary ? 2 : 1); + CTX.mesh.msh_binary ? 2 : 1); dialog->b->value(CTX.mesh.save_all ? 1 : 0); dialog->window->show(); @@ -893,18 +893,18 @@ int msh_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_msh_file_version(0, GMSH_SET | GMSH_GUI, - (dialog->c->value() == 0) ? 1. : 2.); - opt_mesh_msh_binary(0, GMSH_SET | GMSH_GUI, - (dialog->c->value() == 2) ? 1 : 0); - opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); - CreateOutputFile(name, FORMAT_MSH); - dialog->window->hide(); - return 1; + opt_mesh_msh_file_version(0, GMSH_SET | GMSH_GUI, + (dialog->c->value() == 0) ? 1. : 2.); + opt_mesh_msh_binary(0, GMSH_SET | GMSH_GUI, + (dialog->c->value() == 2) ? 1 : 0); + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_MSH); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -953,15 +953,15 @@ int unv_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); - opt_mesh_save_groups_of_nodes(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0); - CreateOutputFile(name, FORMAT_UNV); - dialog->window->hide(); - return 1; + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); + opt_mesh_save_groups_of_nodes(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_UNV); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -1019,15 +1019,15 @@ int bdf_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_bdf_field_format(0, GMSH_SET | GMSH_GUI, dialog->c->value()); - opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); - CreateOutputFile(name, FORMAT_BDF); - dialog->window->hide(); - return 1; + opt_mesh_bdf_field_format(0, GMSH_SET | GMSH_GUI, dialog->c->value()); + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_BDF); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } @@ -1084,15 +1084,15 @@ int stl_dialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_stl_binary(0, GMSH_SET | GMSH_GUI, dialog->c->value()); - opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); - CreateOutputFile(name, FORMAT_STL); - dialog->window->hide(); - return 1; + opt_mesh_stl_binary(0, GMSH_SET | GMSH_GUI, dialog->c->value()); + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_STL); + dialog->window->hide(); + return 1; } if (o == dialog->window || o == dialog->cancel){ - dialog->window->hide(); - return 0; + dialog->window->hide(); + return 0; } } } diff --git a/Fltk/GUI_Extras.h b/Fltk/GUI_Extras.h index 4afc207f8e2d699b8f5cd3a4c65a46fbd34d65b5..508616abeeae33354365603c72c9917be278f815 100644 --- a/Fltk/GUI_Extras.h +++ b/Fltk/GUI_Extras.h @@ -23,7 +23,7 @@ #include <string> int file_chooser(int multi, int create, const char *message, - const char *pat, const char *fname=NULL); + const char *pat, const char *fname=NULL); std::string file_chooser_get_name(int num); int file_chooser_get_filter(); void file_chooser_get_position(int *x, int *y); diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index 52912c1f70e37928d6570092a3abd7bbed733c62..1cf337553fcbab0518556cdcc292e3d303ac02db 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -57,7 +57,7 @@ uvPlot::uvPlot(int x, int y, int w, int h, const char *l) } void uvPlot::set(std::vector<double> &u, std::vector<double> &v, - std::vector<double> &dist, std::vector<std::complex<double> > &f) + std::vector<double> &dist, std::vector<std::complex<double> > &f) { _u = u; _v = v; @@ -131,7 +131,7 @@ void uvPlot::draw() } projection::projection(fourierProjectionFace *f, int x, int y, int w, int h, - int BB, int BH, projectionEditor *e) + int BB, int BH, projectionEditor *e) : face(f) { group = new Fl_Scroll(x, y, w, h); @@ -156,11 +156,11 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h, Fl_Repeat_Button *bm[3], *bp[3]; for(int i = 0; i < 3; i++){ new Fl_Box(x + w - BB / 3 - BB / 6, y + (1 + i) * BH, BB / 8, BH, - (i == 0) ? "E0" : (i == 1) ? "E1" : "E2"); + (i == 0) ? "E0" : (i == 1) ? "E1" : "E2"); bp[i] = new Fl_Repeat_Button(x + w - BB / 3, y + (1 + i) * BH, - BB / 8, BH / 2, "+"); + BB / 8, BH / 2, "+"); bm[i] = new Fl_Repeat_Button(x + w - BB / 3, y + (1 + i) * BH + BH / 2, - BB / 8, BH / 2, "-"); + BB / 8, BH / 2, "-"); } bp[0]->callback(translate_p0_cb, e); bp[1]->callback(translate_p1_cb, e); @@ -281,13 +281,13 @@ projectionEditor::projectionEditor() int uvh = height - 8 * WB - 15 * BH - 2 * hard; _hardEdges[0] = new Fl_Toggle_Button(WB, 3 * WB + 9 * BH + hard, - hard, uvh); + hard, uvh); _hardEdges[1] = new Fl_Toggle_Button(width - 4 * WB - hard, 3 * WB + 9 * BH + hard, - hard, uvh); + hard, uvh); _hardEdges[2] = new Fl_Toggle_Button(WB + hard, 3 * WB + 9 * BH, - uvw, hard); + uvw, hard); _hardEdges[3] = new Fl_Toggle_Button(WB + hard, height - 5 * WB - 6 * BH - hard, - uvw, hard); + uvw, hard); for(int i = 0; i < 4; i++) _hardEdges[i]->tooltip("Push to mark edge as `hard'"); @@ -302,16 +302,16 @@ projectionEditor::projectionEditor() _slider->tooltip("Filter selection by distance to projection surface"); _orientation = new Fl_Toggle_Button(width - 3 * WB, height - 5 * WB - 6 * BH - hard, - 2 * WB, hard); + 2 * WB, hard); _orientation->callback(filter_cb, this); _orientation->tooltip("Filter elements using orientation"); new Fl_Box(WB, height - 4 * WB - 6 * BH, BB, BH, "Patch Type:"); Fl_Group *oo = new Fl_Group( WB, height - 4 * WB - 6 * BH, 3 * BB, BH); _pselect[0] = new Fl_Round_Button(2 * WB + BB, height - 4 * WB - 6 * BH, - BB, BH, "Continuation"); + BB, BH, "Continuation"); _pselect[1] = new Fl_Round_Button(3 * WB + 2 * BB, height - 4 * WB - - 6 * BH, BB, BH, "Windowing"); + 6 * BH, BB, BH, "Windowing"); for(int i = 0; i < 2; i++) _pselect[i]->type(FL_RADIO_BUTTON); @@ -323,12 +323,12 @@ projectionEditor::projectionEditor() _modes[0] = new Fl_Value_Input(WB, height - 4 * WB - 5 * BH, BB / 2, BH); _modes[0]->tooltip("Number of Fourier modes along u"); _modes[1] = new Fl_Value_Input(WB + BB / 2, height - 4 * WB - 5 * BH, BB / 2, BH, - "Fourier modes"); + "Fourier modes"); _modes[1]->tooltip("Number of Fourier modes along v"); _modes[2] = new Fl_Value_Input(WB, height - 4 * WB - 4 * BH, BB / 2, BH); _modes[2]->tooltip("Number of Chebyshev modes along u"); _modes[3] = new Fl_Value_Input(WB + BB / 2, height - 4 * WB - 4 * BH, BB / 2, BH, - "Chebyshev modes"); + "Chebyshev modes"); _modes[3]->tooltip("Number of Chebyshev modes along v"); for(int i = 0; i < 4; i++){ _modes[i]->value(8); @@ -340,7 +340,7 @@ projectionEditor::projectionEditor() { Fl_Button *b = new Fl_Button(width - WB - BB, height - 4 * WB - 5 * BH, - BB, 2 * BH, "Generate\nPatch"); + BB, 2 * BH, "Generate\nPatch"); b->callback(compute_cb, this); } @@ -348,13 +348,13 @@ projectionEditor::projectionEditor() int bb = (int)(0.37 * BB); new Fl_Box(WB, height - 3 * WB - 3 * BH, BB / 2, BH, "Delete:"); Fl_Button *b1 = new Fl_Button(WB + BB / 2, height - 3 * WB - 3 * BH, - bb, BH, "last"); + bb, BH, "last"); b1->callback(action_cb, (void*)"delete_last"); Fl_Button *b2 = new Fl_Button(WB + BB / 2 + bb, height - 3 * WB - 3 * BH, - bb, BH, "all"); + bb, BH, "all"); b2->callback(action_cb, (void*)"delete_all"); Fl_Button *b3 = new Fl_Button(WB + BB / 2 + 2 * bb, height - 3 * WB - 3 * BH, - bb, BH, "sel."); + bb, BH, "sel."); b3->callback(action_cb, (void*)"delete_select"); } @@ -363,23 +363,23 @@ projectionEditor::projectionEditor() int s = width - WB - BB / 2 - 3 * bb; new Fl_Box(s, height - 3 * WB - 3 * BH, BB / 2, BH, "Save:"); Fl_Button *b1 = new Fl_Button(s + BB / 2, height - 3 * WB - 3 * BH, - bb, BH, "last"); + bb, BH, "last"); b1->callback(action_cb, (void*)"save_last"); Fl_Button *b2 = new Fl_Button(s + BB / 2 + bb, height - 3 * WB - 3 * BH, - bb, BH, "all"); + bb, BH, "all"); b2->callback(action_cb, (void*)"save_all"); Fl_Button *b3 = new Fl_Button(s + BB / 2 + 2 * bb, height - 3 * WB - 3 * BH, - bb, BH, "sel."); + bb, BH, "sel."); b3->callback(action_cb, (void*)"save_select"); } { Fl_Button *b1 = new Fl_Button(WB, height - 2 * WB - 2 * BH, BB, BH, - "Blend"); + "Blend"); b1->callback(blend_cb, this); Fl_Button *b2 = new Fl_Button(2 * WB + BB, height - 2 * WB - 2 * BH, BB, - BH, "Intersect"); + BH, "Intersect"); } Fl_Button *b = new Fl_Button(width - WB - BB, height - WB - BH, BB, BH, "Cancel"); @@ -396,7 +396,7 @@ void projectionEditor::load(fourierProjectionFace *face, std::string tag) FM::ProjectionSurface *ps = (FM::ProjectionSurface*)face->getNativePtr(); _browser->add(tag.size() ? tag.c_str() : ps->GetName().c_str()); projection *p = new projection(face, _paramWin[0], _paramWin[1], _paramWin[2], - _paramWin[3], _paramWin[4], _paramWin[5], this); + _paramWin[3], _paramWin[4], _paramWin[5], this); _projections.push_back(p); _window->add(p->group); } @@ -449,10 +449,10 @@ void browse_cb(Fl_Widget *w, void *data) } void project_point(FM::ProjectionSurface *ps, double x, double y, double z, - std::vector<double> &u, std::vector<double> &v, - std::vector<double> &dist, - std::vector<std::complex<double> > &f) -{ + std::vector<double> &u, std::vector<double> &v, + std::vector<double> &dist, + std::vector<std::complex<double> > &f) +{ double uu, vv, p[3], n[3]; ps->OrthoProjectionOnSurface(x, y, z, uu, vv); if(uu >= 0. && uu <= 1. && vv >= 0. && vv <= 1.){ @@ -485,8 +485,8 @@ void translate(void *data, int axis, bool plus) if(p){ FM::ProjectionSurface *ps = (FM::ProjectionSurface*)p->face->getNativePtr(); SVector3 origin(p->parameters[0]->value(), - p->parameters[1]->value(), - p->parameters[2]->value()); + p->parameters[1]->value(), + p->parameters[2]->value()); SVector3 vec; if(axis == 0) ps->GetE0(vec[0], vec[1], vec[2]); @@ -525,22 +525,22 @@ void set_position_cb(Fl_Widget *w, void *data) char ib = SelectEntity(ENT_ALL, vertices, edges, faces, regions, elements); if(ib == 'l'){ if(vertices.size()){ - p->parameters[0]->value(vertices[0]->x()); - p->parameters[1]->value(vertices[0]->y()); - p->parameters[2]->value(vertices[0]->z()); + p->parameters[0]->value(vertices[0]->x()); + p->parameters[1]->value(vertices[0]->y()); + p->parameters[2]->value(vertices[0]->z()); } else if(elements.size()){ - SPoint3 pc = elements[0]->barycenter(); - p->parameters[0]->value(pc.x()); - p->parameters[1]->value(pc.y()); - p->parameters[2]->value(pc.z()); - if(elements[0]->getNumFaces()){ - MFace f = elements[0]->getFace(0); - SVector3 n = f.normal(); - p->parameters[3]->value(n[0]); - p->parameters[4]->value(n[1]); - p->parameters[5]->value(n[2]); - } + SPoint3 pc = elements[0]->barycenter(); + p->parameters[0]->value(pc.x()); + p->parameters[1]->value(pc.y()); + p->parameters[2]->value(pc.z()); + if(elements[0]->getNumFaces()){ + MFace f = elements[0]->getFace(0); + SVector3 n = f.normal(); + p->parameters[3]->value(n[0]); + p->parameters[4]->value(n[1]); + p->parameters[5]->value(n[2]); + } } } ((Fl_Toggle_Button*)w)->value(0); @@ -586,11 +586,11 @@ void update_cb(Fl_Widget *w, void *data) if(p){ FM::ProjectionSurface *ps = (FM::ProjectionSurface*)p->face->getNativePtr(); ps->SetOrigin(p->parameters[0]->value(), - p->parameters[1]->value(), - p->parameters[2]->value()); + p->parameters[1]->value(), + p->parameters[2]->value()); SVector3 n(p->parameters[3]->value(), - p->parameters[4]->value(), - p->parameters[5]->value()); + p->parameters[4]->value(), + p->parameters[5]->value()); if(!n.normalize()) n[2] = 1.; SVector3 t1, t2; getTangents(n, t1, t2, p->parameters[6]->value()); @@ -598,8 +598,8 @@ void update_cb(Fl_Widget *w, void *data) ps->SetE1(t1[0], t1[1], t1[2]); ps->SetE2(t2[0], t2[1], t2[2]); ps->SetScale(p->parameters[7]->value(), - p->parameters[8]->value(), - p->parameters[9]->value()); + p->parameters[8]->value(), + p->parameters[9]->value()); for (int i = 0; i < ps->GetNumParameters(); i++) ps->SetParameter(i, p->parameters[i + 10]->value()); @@ -611,19 +611,19 @@ void update_cb(Fl_Widget *w, void *data) std::vector<GEntity*> &ent(e->getEntities()); for(unsigned int i = 0; i < ent.size(); i++){ if(ent[i]->getSelection()){ - GVertex *gv = dynamic_cast<GVertex*>(ent[i]); - if(!gv) - Msg(GERROR, "Problem in point selection processing"); - else - project_point(ps, gv->x(), gv->y(), gv->z(), u, v, dist, f); + GVertex *gv = dynamic_cast<GVertex*>(ent[i]); + if(!gv) + Msg(GERROR, "Problem in point selection processing"); + else + project_point(ps, gv->x(), gv->y(), gv->z(), u, v, dist, f); } } std::vector<MElement*> &ele(e->getElements()); std::set<MVertex*> verts; for(unsigned int i = 0; i < ele.size(); i++) if(ele[i]->getVisibility() == 2) - for(int j = 0; j < ele[i]->getNumVertices(); j++) - verts.insert(ele[i]->getVertex(j)); + for(int j = 0; j < ele[i]->getNumVertices(); j++) + verts.insert(ele[i]->getVertex(j)); for(std::set<MVertex*>::iterator it = verts.begin(); it != verts.end(); it++) project_point(ps, (*it)->x(), (*it)->y(), (*it)->z(), u, v, dist, f); e->uv()->set(u, v, dist, f); @@ -661,55 +661,55 @@ void select_cb(Fl_Widget *w, void *data) if(ele.size() || ent.size()) Msg(ONSCREEN, "Select %s\n" - "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]", str); + "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]", str); else Msg(ONSCREEN, "Select %s\n" - "[Press 'e' to end selection or 'q' to abort]", str); + "[Press 'e' to end selection or 'q' to abort]", str); char ib = SelectEntity(what, vertices, edges, faces, regions, elements); if(ib == 'l') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < elements.size(); i++){ - if(elements[i]->getVisibility() != 2){ - elements[i]->setVisibility(2); ele.push_back(elements[i]); - } - } + for(unsigned int i = 0; i < elements.size(); i++){ + if(elements[i]->getVisibility() != 2){ + elements[i]->setVisibility(2); ele.push_back(elements[i]); + } + } } else{ - for(unsigned int i = 0; i < vertices.size(); i++){ - if(vertices[i]->getSelection() != 1){ - vertices[i]->setSelection(1); ent.push_back(vertices[i]); - } - } - for(unsigned int i = 0; i < faces.size(); i++){ - if(faces[i]->getSelection() != 1){ - faces[i]->setSelection(1); ent.push_back(faces[i]); - } - } + for(unsigned int i = 0; i < vertices.size(); i++){ + if(vertices[i]->getSelection() != 1){ + vertices[i]->setSelection(1); ent.push_back(vertices[i]); + } + } + for(unsigned int i = 0; i < faces.size(); i++){ + if(faces[i]->getSelection() != 1){ + faces[i]->setSelection(1); ent.push_back(faces[i]); + } + } } } if(ib == 'r') { if(CTX.pick_elements){ - for(unsigned int i = 0; i < elements.size(); i++) - elements[i]->setVisibility(1); + for(unsigned int i = 0; i < elements.size(); i++) + elements[i]->setVisibility(1); } else{ - for(unsigned int i = 0; i < vertices.size(); i++) - vertices[i]->setSelection(0); - for(unsigned int i = 0; i < faces.size(); i++) - faces[i]->setSelection(0); + for(unsigned int i = 0; i < vertices.size(); i++) + vertices[i]->setSelection(0); + for(unsigned int i = 0; i < faces.size(); i++) + faces[i]->setSelection(0); } } if(ib == 'u') { if(CTX.pick_elements){ - if(ele.size()){ - ele[ele.size() - 1]->setVisibility(1); ele.pop_back(); - } + if(ele.size()){ + ele[ele.size() - 1]->setVisibility(1); ele.pop_back(); + } } else{ - if(ent.size()){ - ent[ent.size() - 1]->setSelection(0); ent.pop_back(); - } + if(ent.size()){ + ent[ent.size() - 1]->setSelection(0); ent.pop_back(); + } } } if(ib == 'e') { @@ -745,15 +745,15 @@ void filter_cb(Fl_Widget *w, void *data) for(unsigned int i = 0; i < ent.size(); i++){ GVertex *gv = dynamic_cast<GVertex*>(ent[i]); if(gv){ - double uu, vv, p[3]; - ps->OrthoProjectionOnSurface(gv->x(), gv->y(), gv->z(), uu, vv); - ps->F(uu, vv, p[0], p[1], p[2]); - double dx = gv->x() - p[0], dy = gv->y() - p[1], dz = gv->z() - p[2]; - if(uu >= 0. && uu <= 1. && vv >= 0. && vv < 1. && - sqrt(dx * dx + dy * dy + dz * dz) < threshold) - gv->setSelection(true); - else - gv->setSelection(false); + double uu, vv, p[3]; + ps->OrthoProjectionOnSurface(gv->x(), gv->y(), gv->z(), uu, vv); + ps->F(uu, vv, p[0], p[1], p[2]); + double dx = gv->x() - p[0], dy = gv->y() - p[1], dz = gv->z() - p[2]; + if(uu >= 0. && uu <= 1. && vv >= 0. && vv < 1. && + sqrt(dx * dx + dy * dy + dz * dz) < threshold) + gv->setSelection(true); + else + gv->setSelection(false); } } std::vector<MElement*> &ele(e->getElements()); @@ -764,19 +764,19 @@ void filter_cb(Fl_Widget *w, void *data) ps->F(uu, vv, p[0], p[1], p[2]); double dx = pc.x() - p[0], dy = pc.y() - p[1], dz = pc.z() - p[2]; if(uu >= 0. && uu <= 1. && vv >= 0. && vv < 1. && - sqrt(dx * dx + dy * dy + dz * dz) < threshold){ - ele[i]->setVisibility(2); - // keep only the elements oriented in the same direction as - // the projection surface - if(e->getOrientation() && ele[i]->getNumFaces()){ - MFace f = ele[i]->getFace(0); - SVector3 n = f.normal(), n2; - ps->GetNormal(uu, vv, n2[0], n2[1], n2[2]); - if(dot(n, n2) < 0.) ele[i]->setVisibility(1); - } + sqrt(dx * dx + dy * dy + dz * dz) < threshold){ + ele[i]->setVisibility(2); + // keep only the elements oriented in the same direction as + // the projection surface + if(e->getOrientation() && ele[i]->getNumFaces()){ + MFace f = ele[i]->getFace(0); + SVector3 n = f.normal(), n2; + ps->GetNormal(uu, vv, n2[0], n2[1], n2[2]); + if(dot(n, n2) < 0.) ele[i]->setVisibility(1); + } } else - ele[i]->setVisibility(1); + ele[i]->setVisibility(1); } if(ele.size()) CTX.mesh.changed = ENT_ALL; } @@ -808,27 +808,27 @@ void save_selection_cb(Fl_Widget *w, void *data) for(unsigned int i = 0; i < ent.size(); i++){ GVertex *gv = dynamic_cast<GVertex*>(ent[i]); if(gv && gv->getSelection()) - fprintf(fp, "Point(%d) = {%.16g,%.16g,%.16g,1};\n", gv->tag(), - gv->x(), gv->y(), gv->z()); + fprintf(fp, "Point(%d) = {%.16g,%.16g,%.16g,1};\n", gv->tag(), + gv->x(), gv->y(), gv->z()); } std::vector<MElement*> &ele(e->getElements()); if(ele.size()){ int nelm = 0; std::set<MVertex*> verts; for(unsigned int i = 0; i < ele.size(); i++){ - if(ele[i]->getVisibility() == 2){ - nelm++; - for(int j = 0; j < ele[i]->getNumVertices(); j++) - verts.insert(ele[i]->getVertex(j)); - } + if(ele[i]->getVisibility() == 2){ + nelm++; + for(int j = 0; j < ele[i]->getNumVertices(); j++) + verts.insert(ele[i]->getVertex(j)); + } } fprintf(fp, "$NOD\n%d\n", (int)verts.size()); for(std::set<MVertex*>::iterator it = verts.begin(); it != verts.end(); it++) - (*it)->writeMSH(fp); + (*it)->writeMSH(fp); fprintf(fp, "$ENDNOD\n$ELM\n%d\n", nelm); for(unsigned int i = 0; i < ele.size(); i++) - if(ele[i]->getVisibility() == 2) - ele[i]->writeMSH(fp, 1.0); + if(ele[i]->getVisibility() == 2) + ele[i]->writeMSH(fp, 1.0); fprintf(fp, "$ENDELM\n"); } fclose(fp); @@ -852,23 +852,23 @@ void load_projection_cb(Fl_Widget *w, void *data) for(int proj = 0; proj < num; proj++){ char name[256], tag[256]; if(!fscanf(fp, "%s", tag) || !fscanf(fp, "%s", name)){ - Msg(GERROR, "Bad projection file format"); - return; + Msg(GERROR, "Bad projection file format"); + return; } fourierProjectionFace *face = createProjectionFaceFromName(name); if(face){ - e->load(face, tag); - projection *p = e->getLastProjection(); - if(p){ - for(unsigned int i = 0; i < p->parameters.size(); i++){ - double val; - if(!fscanf(fp, "%lf", &val)){ - Msg(GERROR, "Missing paramater for projection `%s'", name); - break; - } - p->parameters[i]->value(val); - } - } + e->load(face, tag); + projection *p = e->getLastProjection(); + if(p){ + for(unsigned int i = 0; i < p->parameters.size(); i++){ + double val; + if(!fscanf(fp, "%lf", &val)){ + Msg(GERROR, "Missing paramater for projection `%s'", name); + break; + } + p->parameters[i]->value(val); + } + } } } fclose(fp); @@ -886,14 +886,14 @@ void save_projection_cb(Fl_Widget *w, void *data) std::string name = file_chooser_get_name(1); FILE *fp = fopen(name.c_str(), "w"); if(!fp){ - Msg(GERROR, "Unable to open file `%s'", name.c_str()); - return; + Msg(GERROR, "Unable to open file `%s'", name.c_str()); + return; } char no_ext[256], ext[256], base[256]; SplitFileName(name.c_str(), no_ext, ext, base); fprintf(fp, "1\n%s\n%s\n", base, ps->GetName().c_str()); for(unsigned int i = 0; i < p->parameters.size(); i++) - fprintf(fp, "%.16g\n", p->parameters[i]->value()); + fprintf(fp, "%.16g\n", p->parameters[i]->value()); fclose(fp); } } @@ -930,44 +930,44 @@ void compute_cb(Fl_Widget *w, void *data) if (e->getPatchType()) { // create the US-FFT/Windowing faces (with boundaries) FM::Patch* patch = - new FM::WFPatch(0, ps->clone(), u, v, f, 3, uModes, vModes); + new FM::WFPatch(0, ps->clone(), u, v, f, 3, uModes, vModes); makeGFace(GModel::current(), patch); } else { // create the Fourier faces (with boundaries) if(ps->IsUPeriodic()) { - FM::Patch* patchL = - new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, - uM, vM, h0, h1, h2, h3); - patchL->SetMinU(-0.35); - patchL->SetMaxU(0.35); - makeGFace(GModel::current(), patchL); - FM::Patch* patchR = - new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, - uM, vM, h0, h1, h2, h3); - patchR->SetMinU(0.15); - patchR->SetMaxU(0.85); - makeGFace(GModel::current(), patchR); + FM::Patch* patchL = + new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, + uM, vM, h0, h1, h2, h3); + patchL->SetMinU(-0.35); + patchL->SetMaxU(0.35); + makeGFace(GModel::current(), patchL); + FM::Patch* patchR = + new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, + uM, vM, h0, h1, h2, h3); + patchR->SetMinU(0.15); + patchR->SetMaxU(0.85); + makeGFace(GModel::current(), patchR); } else if (ps->IsVPeriodic()) { - FM::Patch* patchL = - new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, - uM, vM, h0, h1, h2, h3); - patchL->SetMinV(-0.35); - patchL->SetMaxV(0.35); - makeGFace(GModel::current(), patchL); - FM::Patch* patchR = - new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, - uM, vM, h0, h1, h2, h3); - patchR->SetMinV(0.15); - patchR->SetMaxV(0.85); - makeGFace(GModel::current(), patchR); + FM::Patch* patchL = + new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, + uM, vM, h0, h1, h2, h3); + patchL->SetMinV(-0.35); + patchL->SetMaxV(0.35); + makeGFace(GModel::current(), patchL); + FM::Patch* patchR = + new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, + uM, vM, h0, h1, h2, h3); + patchR->SetMinV(0.15); + patchR->SetMaxV(0.85); + makeGFace(GModel::current(), patchR); } else { - FM::Patch* patch = - new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, - uM, vM, h0, h1, h2, h3); - makeGFace(GModel::current(), patch); + FM::Patch* patch = + new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, + uM, vM, h0, h1, h2, h3); + makeGFace(GModel::current(), patch); } } } @@ -1030,13 +1030,13 @@ void action_cb(Fl_Widget *w, void *data) int id = -1; for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) if((*it)->getNativeType() == GEntity::FourierModel) - id = std::max(id, (*it)->tag()); + id = std::max(id, (*it)->tag()); if(id > 0) faces.push_back(m->getFaceByTag(id)); } else if(what == "delete_all" || what == "save_all"){ for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) if((*it)->getNativeType() == GEntity::FourierModel) - faces.push_back(*it); + faces.push_back(*it); } else if(what == "delete_select" || what == "save_select"){ Msg(ONSCREEN, "Select Surface\n[Press 'e' to end selection 'q' to abort]"); @@ -1058,13 +1058,13 @@ void action_cb(Fl_Widget *w, void *data) if(file_chooser(0, 1, "Save Fourier Model", "*.fm")){ FILE *fp = fopen(file_chooser_get_name(1).c_str(), "w"); if(!fp){ - Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1).c_str()); - return; + Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1).c_str()); + return; } fprintf(fp, "%d\n", (int)faces.size()); for(unsigned int i = 0; i < faces.size(); i++){ - fourierFace* ff = (fourierFace*)faces[i]; - ((FM::TopoFace*)ff->getNativePtr())->GetPatch()->Export(fp); + fourierFace* ff = (fourierFace*)faces[i]; + ((FM::TopoFace*)ff->getNativePtr())->GetPatch()->Export(fp); } fclose(fp); } diff --git a/Fltk/GUI_Projection.h b/Fltk/GUI_Projection.h index 77f7a5b51162307fdfc2641654c90d8dd78202f6..9f6bfa164bb6fea79ba215ee57461b9931bcd697 100644 --- a/Fltk/GUI_Projection.h +++ b/Fltk/GUI_Projection.h @@ -49,9 +49,9 @@ class uvPlot : public Fl_Window { public: uvPlot(int x, int y, int w, int h, const char *l=0); void set(std::vector<double> &u, std::vector<double> &v, std::vector<double> &dist, - std::vector<std::complex<double> > &f); + std::vector<std::complex<double> > &f); void get(std::vector<double> &u, std::vector<double> &v, std::vector<double> &dist, - std::vector<std::complex<double> > &f) + std::vector<std::complex<double> > &f) { u = _u; v = _v; dist = _dist; f = _f; } }; @@ -63,7 +63,7 @@ class projection { Fl_Group *group; std::vector<Fl_Value_Input*> parameters; projection(fourierProjectionFace *f, int x, int y, int w, int h, int BB, int BH, - projectionEditor *e); + projectionEditor *e); }; class projectionEditor { diff --git a/Fltk/GmshServer.h b/Fltk/GmshServer.h index 76bfd8b937e9200a077f56ca872d056e547ac376..5b733db9f26b5428c055c3eab9ec45dc5b02fe61 100644 --- a/Fltk/GmshServer.h +++ b/Fltk/GmshServer.h @@ -74,18 +74,18 @@ class GmshServer { // receive data from a machine with a different byte ordering, and // we just swap the bytes) typedef enum{ CLIENT_START = 1, - CLIENT_STOP = 2, - CLIENT_INFO = 10, - CLIENT_WARNING = 11, - CLIENT_ERROR = 12, - CLIENT_PROGRESS = 13, - CLIENT_MERGE_FILE = 20, // old name: CLIENT_VIEW - CLIENT_PARSE_STRING = 21, - CLIENT_OPTION_1 = 100, - CLIENT_OPTION_2 = 101, - CLIENT_OPTION_3 = 102, - CLIENT_OPTION_4 = 103, - CLIENT_OPTION_5 = 104 } MessageType; + CLIENT_STOP = 2, + CLIENT_INFO = 10, + CLIENT_WARNING = 11, + CLIENT_ERROR = 12, + CLIENT_PROGRESS = 13, + CLIENT_MERGE_FILE = 20, // old name: CLIENT_VIEW + CLIENT_PARSE_STRING = 21, + CLIENT_OPTION_1 = 100, + CLIENT_OPTION_2 = 101, + CLIENT_OPTION_3 = 102, + CLIENT_OPTION_4 = 103, + CLIENT_OPTION_5 = 104 } MessageType; static int init, s; private: @@ -99,7 +99,7 @@ class GmshServer { do { ssize_t len = recv(_sock, buf + sofar, remaining, 0); if(len <= 0) - return 0; + return 0; sofar += len; remaining -= len; } while(remaining > 0); @@ -112,7 +112,7 @@ class GmshServer { char *a = &array[i * size]; memcpy(x, a, size); for(int c = 0; c < size; c++) - a[size - 1 - c] = x[c]; + a[size - 1 - c] = x[c]; } delete [] x; } @@ -176,7 +176,7 @@ class GmshServer { // make the socket s = socket(PF_UNIX, SOCK_STREAM, 0); if(s < 0) - return -1; // Error: Couldn't create socket + return -1; // Error: Couldn't create socket // bind the socket to its name struct sockaddr_un addr_un; @@ -184,7 +184,7 @@ class GmshServer { strcpy(addr_un.sun_path, _sockname); addr_un.sun_family = AF_UNIX; if(bind(s, (struct sockaddr *)&addr_un, sizeof(addr_un)) < 0) - return -2; // Error: Couldn't bind socket to name + return -2; // Error: Couldn't bind socket to name // change permissions on the socket name in case it has to be rm'd later chmod(_sockname, 0666); @@ -195,34 +195,34 @@ class GmshServer { else{ #if defined(WIN32) && !defined(__CYGWIN__) if(!init){ - WSADATA wsaData; - int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); - if(iResult != NO_ERROR) - return -8; // Error: Couldn't initialize Windows sockets + WSADATA wsaData; + int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); + if(iResult != NO_ERROR) + return -8; // Error: Couldn't initialize Windows sockets } #endif if(init != _portno){ - // We need a better solution to deal with addresses that have - // already been bound... - init = _portno; - - // make the socket - s = socket(AF_INET, SOCK_STREAM, 0); + // We need a better solution to deal with addresses that have + // already been bound... + init = _portno; + + // make the socket + s = socket(AF_INET, SOCK_STREAM, 0); #if !defined(WIN32) || defined(__CYGWIN__) - if(s < 0) + if(s < 0) #else - if(s == INVALID_SOCKET) + if(s == INVALID_SOCKET) #endif - return -1; // Error: Couldn't create socket - - // bind the socket to its name - struct sockaddr_in addr_in; - memset((char *) &addr_in, 0, sizeof(addr_in)); - addr_in.sin_family = AF_INET; - addr_in.sin_addr.s_addr = INADDR_ANY; - addr_in.sin_port = htons(_portno); - if(bind(s, (struct sockaddr *)&addr_in, sizeof(addr_in)) < 0) - return -2; // Error: Couldn't bind socket to name + return -1; // Error: Couldn't create socket + + // bind the socket to its name + struct sockaddr_in addr_in; + memset((char *) &addr_in, 0, sizeof(addr_in)); + addr_in.sin_family = AF_INET; + addr_in.sin_addr.s_addr = INADDR_ANY; + addr_in.sin_port = htons(_portno); + if(bind(s, (struct sockaddr *)&addr_in, sizeof(addr_in)) < 0) + return -2; // Error: Couldn't bind socket to name } } @@ -237,13 +237,13 @@ class GmshServer { if(justwait){ // wait indefinitely until we get data if(WaitForData(s, -1, 0.5)) - return -6; // not an actual error: we just stopped listening + return -6; // not an actual error: we just stopped listening } else{ // Wait at most _maxdelay seconds for data, issue error if no // connection in that amount of time if(!myselect(s, _maxdelay)) - return -4; // Error: Socket listening timeout + return -4; // Error: Socket listening timeout } // accept connection request @@ -258,15 +258,15 @@ class GmshServer { if(_ReceiveData(type, sizeof(int))){ if(*type < 0) return 0; if(*type > 65535){ - // the data comes from a machine with different endianness and - // we must swap the bytes - swap = true; - _SwapBytes((char*)type, sizeof(int), 1); + // the data comes from a machine with different endianness and + // we must swap the bytes + swap = true; + _SwapBytes((char*)type, sizeof(int), 1); } if(_ReceiveData(len, sizeof(int))){ - if(*len < 0) return 0; - if(swap) _SwapBytes((char*)len, sizeof(int), 1); - return 1; + if(*len < 0) return 0; + if(swap) _SwapBytes((char*)len, sizeof(int), 1); + return 1; } } return 0; @@ -285,7 +285,7 @@ class GmshServer { if(_portno < 0){ // UNIX socket if(unlink(_sockname) == -1) - return -1; // Impossible to unlink the socket + return -1; // Impossible to unlink the socket } close(_sock); #else diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp index 3f330374e7e29be06c5ed9d5cea35583444aa8dd..9af7058daa640e6d290ee02acbdacaa9461b0e11 100644 --- a/Fltk/Main.cpp +++ b/Fltk/Main.cpp @@ -1,4 +1,4 @@ -// $Id: Main.cpp,v 1.124 2008-03-19 17:26:48 geuzaine Exp $ +// $Id: Main.cpp,v 1.125 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -84,11 +84,11 @@ int main(int argc, char *argv[]) for(unsigned int i = 1; i < CTX.files.size(); i++) MergeFile(CTX.files[i].c_str()); if(CTX.post.combine_time) - PView::combine(true, 2, CTX.post.combine_remove_orig); + PView::combine(true, 2, CTX.post.combine_remove_orig); if(CTX.bgm_filename) { MergeFile(CTX.bgm_filename); if(PView::list.size()){ - GModel::current()->getFields()->set_background_mesh(PView::list.back()->getNum() - 1); + GModel::current()->getFields()->set_background_mesh(PView::list.back()->getNum() - 1); } else Msg(GERROR, "Invalid background mesh (no view)"); @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) else if(CTX.batch == -1) CreateOutputFile(CTX.output_filename, FORMAT_GEO); else if(CTX.batch == -2) - GModel::current()->checkMeshCoherence(); + GModel::current()->checkMeshCoherence(); exit(0); } } diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp index b1187aebd0dae9109e5cf0aaf4c404e5eb5d39ae..82ef727087f2ebed09c1f9855e94d86169f46c2c 100644 --- a/Fltk/Message.cpp +++ b/Fltk/Message.cpp @@ -1,4 +1,4 @@ -// $Id: Message.cpp,v 1.87 2008-03-18 08:41:21 remacle Exp $ +// $Id: Message.cpp,v 1.88 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -65,25 +65,25 @@ void Msg(int level, const char *fmt, ...) case FATAL1 : str = FATAL_STR; break ; case FATAL2 : str = WHITE_STR; break ; case FATAL3 : str = WHITE_STR; abort = 1; break ; - - case GERROR : + + case GERROR : case GERROR1 : str = ERROR_STR; break ; - case GERROR2 : + case GERROR2 : case GERROR3 : str = WHITE_STR; break ; - - case WARNING : + + case WARNING : case WARNING1 : str = WARNING_STR; verb = 1; break ; - case WARNING2 : + case WARNING2 : case WARNING3 : str = WHITE_STR; verb = 1; break ; - - case INFO : + + case INFO : case INFO1 : str = INFO_STR; verb = 3; break ; - case INFO2 : + case INFO2 : case INFO3 : str = WHITE_STR; verb = 3; break ; - - case DEBUG : + + case DEBUG : case DEBUG1 : str = DEBUG_STR; verb = 4; break ; - case DEBUG2 : + case DEBUG2 : case DEBUG3 : str = WHITE_STR; verb = 4; break ; default : return; @@ -109,12 +109,12 @@ void Msg(int level, const char *fmt, ...) // (mai3d(), CreateFile(), etc.) with 'CTX.threads_lock', but // this is far from perfect... if(level != DEBUG && - level != DEBUG1 && - level != DEBUG2 && - level != DEBUG3 && - level != STATUS1N && - level != STATUS2N){ - WID->check(); + level != DEBUG1 && + level != DEBUG2 && + level != DEBUG3 && + level != STATUS1N && + level != STATUS2N){ + WID->check(); } } @@ -128,8 +128,8 @@ void Msg(int level, const char *fmt, ...) #endif WID->set_status(buff[window], window); if(log && strlen(buff[window])){ - strcpy(buff1, str ? str : ""); - strncat(buff1, buff[window], BUFFSIZE-strlen(buff1)); + strcpy(buff1, str ? str : ""); + strncat(buff1, buff[window], BUFFSIZE-strlen(buff1)); WID->add_message(buff1); } } @@ -221,7 +221,7 @@ void Exit(int level) CTX.solver_position[0] = WID->solver[0].window->x(); CTX.solver_position[1] = WID->solver[0].window->y(); file_chooser_get_position(&CTX.file_chooser_position[0], - &CTX.file_chooser_position[1]); + &CTX.file_chooser_position[1]); Print_Options(0, GMSH_SESSIONRC, 0, 0, CTX.session_filename_fullpath); } if(CTX.options_save) @@ -257,7 +257,7 @@ double GetValue(const char *text, double defaultval) } bool GetBinaryAnswer(const char *question, const char *yes, const char *no, - bool defaultval) + bool defaultval) { if(CTX.nopopup || CTX.batch || !WID) return defaultval; diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp index 9b63d20546533f5f9db2d8edf3129bf01095bbea..93fc2c785a86daa01d16e12c15a8b1615612118c 100644 --- a/Fltk/Opengl.cpp +++ b/Fltk/Opengl.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl.cpp,v 1.79 2008-03-10 16:01:15 geuzaine Exp $ +// $Id: Opengl.cpp,v 1.80 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -99,9 +99,9 @@ void Draw_String(const char *s, const char *font_name, int font_enum, int font_s gl2psTextOpt(tmp.c_str(), font_name, font_size, opt, 0.); } else if(CTX.print.eps_quality && (CTX.print.format == FORMAT_PS || - CTX.print.format == FORMAT_EPS || - CTX.print.format == FORMAT_PDF || - CTX.print.format == FORMAT_SVG)){ + CTX.print.format == FORMAT_EPS || + CTX.print.format == FORMAT_PDF || + CTX.print.format == FORMAT_SVG)){ gl2psText(s, font_name, font_size); } else{ @@ -167,11 +167,11 @@ void Draw_OnScreenMessages() // Select entity routine char SelectEntity(int type, - std::vector<GVertex*> &vertices, - std::vector<GEdge*> &edges, - std::vector<GFace*> &faces, - std::vector<GRegion*> ®ions, - std::vector<MElement*> &elements) + std::vector<GVertex*> &vertices, + std::vector<GEdge*> &edges, + std::vector<GFace*> &faces, + std::vector<GRegion*> ®ions, + std::vector<MElement*> &elements) { if(!WID) return 'q'; @@ -218,22 +218,22 @@ char SelectEntity(int type, bool multi = (abs(WID->try_selection) > 1) ? true : false; WID->try_selection = 0; if(WID->selection == ENT_NONE){ // just report the mouse click - WID->g_opengl_window->SelectionMode = false; - return 'c'; + WID->g_opengl_window->SelectionMode = false; + return 'c'; } else if(ProcessSelectionBuffer(WID->selection, multi, true, - WID->try_selection_xywh[0], - WID->try_selection_xywh[1], - WID->try_selection_xywh[2], - WID->try_selection_xywh[3], - vertices, edges, faces, regions, - elements)){ - WID->selection = ENT_NONE; - WID->g_opengl_window->SelectionMode = false; - if(add) - return 'l'; - else - return 'r'; + WID->try_selection_xywh[0], + WID->try_selection_xywh[1], + WID->try_selection_xywh[2], + WID->try_selection_xywh[3], + vertices, edges, faces, regions, + elements)){ + WID->selection = ENT_NONE; + WID->g_opengl_window->SelectionMode = false; + if(add) + return 'l'; + else + return 'r'; } } } diff --git a/Fltk/Opengl_Window.cpp b/Fltk/Opengl_Window.cpp index d5decf47d8722d33f4397d63fa17d253f11aa1ae..894e515298d0edbde753863ae91f3f3d87b62249 100644 --- a/Fltk/Opengl_Window.cpp +++ b/Fltk/Opengl_Window.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl_Window.cpp,v 1.82 2008-02-17 08:47:57 geuzaine Exp $ +// $Id: Opengl_Window.cpp,v 1.83 2008-03-20 11:44:03 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -116,7 +116,7 @@ void Opengl_Window::draw() glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho((double)CTX.viewport[0], (double)CTX.viewport[2], - (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); + (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3d(1., 1., 1.); @@ -199,56 +199,56 @@ int Opengl_Window::handle(int event) !Fl::event_state(FL_SHIFT) && !Fl::event_state(FL_ALT)) { if(!LassoMode && Fl::event_state(FL_CTRL)) { LassoMode = true; - lasso.set(); + lasso.set(); } else if(LassoMode) { LassoMode = false; - if(SelectionMode && CTX.mouse_selection){ - WID->try_selection = 2; // will try to select multiple entities - WID->try_selection_xywh[0] = (int)(click.win[0] + curr.win[0])/2; - WID->try_selection_xywh[1] = (int)(click.win[1] + curr.win[1])/2; - WID->try_selection_xywh[2] = (int)fabs(click.win[0] - curr.win[0]); - WID->try_selection_xywh[3] = (int)fabs(click.win[1] - curr.win[1]); - } - else{ - lasso_zoom(click, curr); - } + if(SelectionMode && CTX.mouse_selection){ + WID->try_selection = 2; // will try to select multiple entities + WID->try_selection_xywh[0] = (int)(click.win[0] + curr.win[0])/2; + WID->try_selection_xywh[1] = (int)(click.win[1] + curr.win[1])/2; + WID->try_selection_xywh[2] = (int)fabs(click.win[0] - curr.win[0]); + WID->try_selection_xywh[3] = (int)fabs(click.win[1] - curr.win[1]); + } + else{ + lasso_zoom(click, curr); + } } else if(CTX.mouse_selection){ WID->try_selection = 1; // will try to select clicked entity - WID->try_selection_xywh[0] = (int)curr.win[0]; - WID->try_selection_xywh[1] = (int)curr.win[1]; - WID->try_selection_xywh[2] = 5; - WID->try_selection_xywh[3] = 5; + WID->try_selection_xywh[0] = (int)curr.win[0]; + WID->try_selection_xywh[1] = (int)curr.win[1]; + WID->try_selection_xywh[2] = 5; + WID->try_selection_xywh[3] = 5; } } else if(Fl::event_button() == 2 || - (Fl::event_button() == 1 && Fl::event_state(FL_SHIFT))) { + (Fl::event_button() == 1 && Fl::event_state(FL_SHIFT))) { if(!LassoMode && Fl::event_state(FL_CTRL)) { - // make zoom isotropic + // make zoom isotropic CTX.s[1] = CTX.s[0]; CTX.s[2] = CTX.s[0]; redraw(); } else if(LassoMode) { - LassoMode = false; - if(SelectionMode && CTX.mouse_selection){ - WID->try_selection = -2; // will try to unselect multiple entities - WID->try_selection_xywh[0] = (int)(click.win[0] + curr.win[0])/2; - WID->try_selection_xywh[1] = (int)(click.win[1] + curr.win[1])/2; - WID->try_selection_xywh[2] = (int)fabs(click.win[0] - curr.win[0]); - WID->try_selection_xywh[3] = (int)fabs(click.win[1] - curr.win[1]); - } - else{ - lasso_zoom(click, curr); - } + LassoMode = false; + if(SelectionMode && CTX.mouse_selection){ + WID->try_selection = -2; // will try to unselect multiple entities + WID->try_selection_xywh[0] = (int)(click.win[0] + curr.win[0])/2; + WID->try_selection_xywh[1] = (int)(click.win[1] + curr.win[1])/2; + WID->try_selection_xywh[2] = (int)fabs(click.win[0] - curr.win[0]); + WID->try_selection_xywh[3] = (int)fabs(click.win[1] - curr.win[1]); + } + else{ + lasso_zoom(click, curr); + } } else if(CTX.mouse_selection){ WID->try_selection = -1; // will try to unselect clicked entity - WID->try_selection_xywh[0] = (int)curr.win[0]; - WID->try_selection_xywh[1] = (int)curr.win[1]; - WID->try_selection_xywh[2] = 5; - WID->try_selection_xywh[3] = 5; + WID->try_selection_xywh[0] = (int)curr.win[0]; + WID->try_selection_xywh[1] = (int)curr.win[1]; + WID->try_selection_xywh[2] = 5; + WID->try_selection_xywh[3] = 5; } } else { @@ -257,8 +257,8 @@ int Opengl_Window::handle(int event) CTX.setQuaternion(0., 0., 0., 1.); else CTX.r[0] = CTX.r[1] = CTX.r[2] = 0.; - CTX.t[0] = CTX.t[1] = CTX.t[2] = 0.; - CTX.s[0] = CTX.s[1] = CTX.s[2] = 1.; + CTX.t[0] = CTX.t[1] = CTX.t[2] = 0.; + CTX.s[0] = CTX.s[1] = CTX.s[2] = 1.; redraw(); } else { @@ -300,52 +300,52 @@ int Opengl_Window::handle(int event) double dx = curr.win[0] - prev.win[0]; double dy = curr.win[1] - prev.win[1]; if(LassoMode) { - redraw(); + redraw(); } else { - if(Fl::event_state(FL_META)) { - // will try to select or unselect entities on the fly - WID->try_selection = Fl::event_state(FL_SHIFT) ? -1 : 1; - WID->try_selection_xywh[0] = (int)curr.win[0]; - WID->try_selection_xywh[1] = (int)curr.win[1]; - WID->try_selection_xywh[2] = 5; - WID->try_selection_xywh[3] = 5; - } - else if(Fl::event_button() == 1 && - !Fl::event_state(FL_SHIFT) && !Fl::event_state(FL_ALT)) { - if(CTX.useTrackball) - CTX.addQuaternion((2. * prev.win[0] - w()) / w(), - (h() - 2. * prev.win[1]) / h(), - (2. * curr.win[0] - w()) / w(), - (h() - 2. * curr.win[1]) / h()); - else { - CTX.r[1] += ((fabs(dx) > fabs(dy)) ? 180. * dx / (double)w() : 0.); - CTX.r[0] += ((fabs(dx) > fabs(dy)) ? 0. : 180. * dy / (double)h()); - } - } - else if(Fl::event_button() == 2 || - (Fl::event_button() == 1 && Fl::event_state(FL_SHIFT))) { - if(fabs(dy) > fabs(dx)) { - double fact = (CTX.zoom_factor * fabs(dy) + h()) / (double)h(); - CTX.s[0] *= ((dy > 0) ? fact : 1./fact); - CTX.s[1] = CTX.s[0]; - CTX.s[2] = CTX.s[0]; - click.recenter(); - } - else if(!CTX.useTrackball) - CTX.r[2] += -180. * dx / (double)w(); - } - else { - CTX.t[0] += (curr.wnr[0] - click.wnr[0]); - CTX.t[1] += (curr.wnr[1] - click.wnr[1]); - CTX.t[2] = 0.; - } - CTX.draw_rotation_center = 1; - if(CTX.fast_redraw) { - CTX.mesh.draw = 0; - CTX.post.draw = 0; - } - redraw(); + if(Fl::event_state(FL_META)) { + // will try to select or unselect entities on the fly + WID->try_selection = Fl::event_state(FL_SHIFT) ? -1 : 1; + WID->try_selection_xywh[0] = (int)curr.win[0]; + WID->try_selection_xywh[1] = (int)curr.win[1]; + WID->try_selection_xywh[2] = 5; + WID->try_selection_xywh[3] = 5; + } + else if(Fl::event_button() == 1 && + !Fl::event_state(FL_SHIFT) && !Fl::event_state(FL_ALT)) { + if(CTX.useTrackball) + CTX.addQuaternion((2. * prev.win[0] - w()) / w(), + (h() - 2. * prev.win[1]) / h(), + (2. * curr.win[0] - w()) / w(), + (h() - 2. * curr.win[1]) / h()); + else { + CTX.r[1] += ((fabs(dx) > fabs(dy)) ? 180. * dx / (double)w() : 0.); + CTX.r[0] += ((fabs(dx) > fabs(dy)) ? 0. : 180. * dy / (double)h()); + } + } + else if(Fl::event_button() == 2 || + (Fl::event_button() == 1 && Fl::event_state(FL_SHIFT))) { + if(fabs(dy) > fabs(dx)) { + double fact = (CTX.zoom_factor * fabs(dy) + h()) / (double)h(); + CTX.s[0] *= ((dy > 0) ? fact : 1./fact); + CTX.s[1] = CTX.s[0]; + CTX.s[2] = CTX.s[0]; + click.recenter(); + } + else if(!CTX.useTrackball) + CTX.r[2] += -180. * dx / (double)w(); + } + else { + CTX.t[0] += (curr.wnr[0] - click.wnr[0]); + CTX.t[1] += (curr.wnr[1] - click.wnr[1]); + CTX.t[2] = 0.; + } + CTX.draw_rotation_center = 1; + if(CTX.fast_redraw) { + CTX.mesh.draw = 0; + CTX.post.draw = 0; + } + redraw(); } } prev.set(); @@ -366,14 +366,14 @@ int Opengl_Window::handle(int event) double r[3] = {CTX.cg[0] - p[0], CTX.cg[1] - p[1], CTX.cg[2] - p[2]}, t; prosca(r, d, &t); for(int i = 0; i < 3; i++){ - point[i] = p[i] + t * d[i]; - if(CTX.geom.snap[i]){ - double d = point[i]/CTX.geom.snap[i]; - double f = floor(d); - double c = ceil(d); - double n = (d - f < c - d) ? f : c; - point[i] = n * CTX.geom.snap[i]; - } + point[i] = p[i] + t * d[i]; + if(CTX.geom.snap[i]){ + double d = point[i]/CTX.geom.snap[i]; + double f = floor(d); + double c = ceil(d); + double n = (d - f < c - d) ? f : c; + point[i] = n * CTX.geom.snap[i]; + } } char str[32]; sprintf(str, "%g", point[0]); WID->context_geometry_input[2]->value(str); @@ -383,34 +383,34 @@ int Opengl_Window::handle(int event) } else{ // hover mode if(curr.win[0] != prev.win[0] || curr.win[1] != prev.win[1]){ - WID->make_opengl_current(); - std::vector<GVertex*> vertices; - std::vector<GEdge*> edges; - std::vector<GFace*> faces; - std::vector<GRegion*> regions; - std::vector<MElement*> elements; - bool res = ProcessSelectionBuffer(WID->selection, false, - CTX.mouse_hover_meshes, - (int)curr.win[0], (int)curr.win[1], 5, 5, - vertices, edges, faces, regions, - elements); - if((WID->selection == ENT_ALL && res) || - (WID->selection == ENT_POINT && vertices.size()) || - (WID->selection == ENT_LINE && edges.size()) || - (WID->selection == ENT_SURFACE && faces.size()) || - (WID->selection == ENT_VOLUME && regions.size())) - WID->g_window->cursor(FL_CURSOR_CROSS, FL_BLACK, FL_WHITE); - else - WID->g_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); - GEntity *ge = 0; - if(vertices.size()) ge = vertices[0]; - else if(edges.size()) ge = edges[0]; - else if(faces.size()) ge = faces[0]; - else if(regions.size()) ge = regions[0]; - MElement *me = elements.size() ? elements[0] : 0; - Msg(STATUS2N, "%s %s", - ge ? ge->getInfoString().c_str() : "", - me ? me->getInfoString().c_str() : ""); + WID->make_opengl_current(); + std::vector<GVertex*> vertices; + std::vector<GEdge*> edges; + std::vector<GFace*> faces; + std::vector<GRegion*> regions; + std::vector<MElement*> elements; + bool res = ProcessSelectionBuffer(WID->selection, false, + CTX.mouse_hover_meshes, + (int)curr.win[0], (int)curr.win[1], 5, 5, + vertices, edges, faces, regions, + elements); + if((WID->selection == ENT_ALL && res) || + (WID->selection == ENT_POINT && vertices.size()) || + (WID->selection == ENT_LINE && edges.size()) || + (WID->selection == ENT_SURFACE && faces.size()) || + (WID->selection == ENT_VOLUME && regions.size())) + WID->g_window->cursor(FL_CURSOR_CROSS, FL_BLACK, FL_WHITE); + else + WID->g_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); + GEntity *ge = 0; + if(vertices.size()) ge = vertices[0]; + else if(edges.size()) ge = edges[0]; + else if(faces.size()) ge = faces[0]; + else if(regions.size()) ge = regions[0]; + MElement *me = elements.size() ? elements[0] : 0; + Msg(STATUS2N, "%s %s", + ge ? ge->getInfoString().c_str() : "", + me ? me->getInfoString().c_str() : ""); } } prev.set(); diff --git a/Fltk/Popup_Button.h b/Fltk/Popup_Button.h index 9b5928d67f60b4383ed40b962b685701e26910c8..e6f6e6641b54e276fda364120e47d5357e27c882 100644 --- a/Fltk/Popup_Button.h +++ b/Fltk/Popup_Button.h @@ -43,9 +43,9 @@ class Popup_Button : public Fl_Menu_Button { return (box() && !type()) ? 1 : 0; case FL_PUSH: if (!box()) { - if (Fl::event_button() != 3) return 0; + if (Fl::event_button() != 3) return 0; } else if (type()) { - if (!(type() & (1 << (Fl::event_button()-1)))) return 0; + if (!(type() & (1 << (Fl::event_button()-1)))) return 0; } if (Fl::visible_focus()) Fl::focus(this); popup(); @@ -53,9 +53,9 @@ class Popup_Button : public Fl_Menu_Button { case FL_KEYBOARD: if (!box()) return 0; if (Fl::event_key() == ' ' && - !(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) { - popup(); - return 1; + !(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) { + popup(); + return 1; } else return 0; case FL_SHORTCUT: if (Fl_Widget::test_shortcut()) {popup(); return 1;} @@ -63,8 +63,8 @@ class Popup_Button : public Fl_Menu_Button { case FL_FOCUS: case FL_UNFOCUS: if (box() && Fl::visible_focus()) { - redraw(); - return 1; + redraw(); + return 1; } default: return 0; diff --git a/Fltk/Shortcut_Window.h b/Fltk/Shortcut_Window.h index 259652fb92a887a2caf03c7a3c853f0f993c5ca1..5fa293058c5b82d364636903e78e481febf8b366 100644 --- a/Fltk/Shortcut_Window.h +++ b/Fltk/Shortcut_Window.h @@ -41,8 +41,8 @@ class Dialog_Window : public Fl_Double_Window { #else if(Fl::test_shortcut(FL_CTRL+'w') || Fl::test_shortcut(FL_Escape)){ #endif - do_callback(); - return 1; + do_callback(); + return 1; } break; } @@ -73,9 +73,9 @@ class Main_Window : public Fl_Window { #else if(Fl::test_shortcut(FL_CTRL+'w')){ #endif - if(fl_choice("Do you really want to quit?", "Cancel", "Quit", NULL)) - do_callback(); - return 1; + if(fl_choice("Do you really want to quit?", "Cancel", "Quit", NULL)) + do_callback(); + return 1; } break; } diff --git a/Fltk/Solvers.cpp b/Fltk/Solvers.cpp index 03ab1e551d6acb22ae10b1c15d9991bd5bb1798a..7ae2a0803bc61cf7cd8cf93680b86b45c315610d 100644 --- a/Fltk/Solvers.cpp +++ b/Fltk/Solvers.cpp @@ -1,4 +1,4 @@ -// $Id: Solvers.cpp,v 1.61 2008-02-23 15:30:07 geuzaine Exp $ +// $Id: Solvers.cpp,v 1.62 2008-03-20 11:44:04 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -68,7 +68,7 @@ int WaitForData(int socket, int num, double waitint) else{ // an error happened if(num >= 0) - SINFO[num].pid = -1; + SINFO[num].pid = -1; return 1; } } @@ -162,7 +162,7 @@ int Solver(int num, const char *args) } if(num >= 0){ for(int i = 0; i < SINFO[num].nboptions; i++) - WID->solver[num].choice[i]->clear(); + WID->solver[num].choice[i]->clear(); } return 0; } @@ -191,73 +191,73 @@ int Solver(int num, const char *args) if(server.ReceiveMessageHeader(&type, &length)){ char *message = new char[length + 1]; if(server.ReceiveMessageBody(length, message)){ - switch (type) { - case GmshServer::CLIENT_START: - if(num >= 0) - SINFO[num].pid = atoi(message); - break; - case GmshServer::CLIENT_STOP: - stop = 1; - if(num >= 0) - SINFO[num].pid = -1; - break; - case GmshServer::CLIENT_PROGRESS: - if(num >= 0) - Msg(STATUS2N, "%s %s", SINFO[num].name, message); - else - Msg(STATUS2N, "%s", message); - break; - case GmshServer::CLIENT_OPTION_1: - if(num >= 0) - strcpy(SINFO[num].option[0][SINFO[num].nbval[0]++], message); - break; - case GmshServer::CLIENT_OPTION_2: - if(num >= 0) - strcpy(SINFO[num].option[1][SINFO[num].nbval[1]++], message); - break; - case GmshServer::CLIENT_OPTION_3: - if(num >= 0) - strcpy(SINFO[num].option[2][SINFO[num].nbval[2]++], message); - break; - case GmshServer::CLIENT_OPTION_4: - if(num >= 0) - strcpy(SINFO[num].option[3][SINFO[num].nbval[3]++], message); - break; - case GmshServer::CLIENT_OPTION_5: - if(num >= 0) - strcpy(SINFO[num].option[4][SINFO[num].nbval[4]++], message); - break; - case GmshServer::CLIENT_MERGE_FILE: - if(num < 0 || (num >= 0 && SINFO[num].merge_views)) { - int n = PView::list.size(); - MergeFile(message); - Draw(); - if(n != (int)PView::list.size()) - WID->set_context(menu_post, 0); - } - break; - case GmshServer::CLIENT_PARSE_STRING: - ParseString(message); - Draw(); - break; - case GmshServer::CLIENT_INFO: - Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message); - break; - case GmshServer::CLIENT_WARNING: - case GmshServer::CLIENT_ERROR: - Msg(SOLVERR, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message); - break; - default: - Msg(WARNING, "Unknown type of message received from %s", - num >= 0 ? SINFO[num].name : "client"); - Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message); - break; - } - WID->check(); + switch (type) { + case GmshServer::CLIENT_START: + if(num >= 0) + SINFO[num].pid = atoi(message); + break; + case GmshServer::CLIENT_STOP: + stop = 1; + if(num >= 0) + SINFO[num].pid = -1; + break; + case GmshServer::CLIENT_PROGRESS: + if(num >= 0) + Msg(STATUS2N, "%s %s", SINFO[num].name, message); + else + Msg(STATUS2N, "%s", message); + break; + case GmshServer::CLIENT_OPTION_1: + if(num >= 0) + strcpy(SINFO[num].option[0][SINFO[num].nbval[0]++], message); + break; + case GmshServer::CLIENT_OPTION_2: + if(num >= 0) + strcpy(SINFO[num].option[1][SINFO[num].nbval[1]++], message); + break; + case GmshServer::CLIENT_OPTION_3: + if(num >= 0) + strcpy(SINFO[num].option[2][SINFO[num].nbval[2]++], message); + break; + case GmshServer::CLIENT_OPTION_4: + if(num >= 0) + strcpy(SINFO[num].option[3][SINFO[num].nbval[3]++], message); + break; + case GmshServer::CLIENT_OPTION_5: + if(num >= 0) + strcpy(SINFO[num].option[4][SINFO[num].nbval[4]++], message); + break; + case GmshServer::CLIENT_MERGE_FILE: + if(num < 0 || (num >= 0 && SINFO[num].merge_views)) { + int n = PView::list.size(); + MergeFile(message); + Draw(); + if(n != (int)PView::list.size()) + WID->set_context(menu_post, 0); + } + break; + case GmshServer::CLIENT_PARSE_STRING: + ParseString(message); + Draw(); + break; + case GmshServer::CLIENT_INFO: + Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message); + break; + case GmshServer::CLIENT_WARNING: + case GmshServer::CLIENT_ERROR: + Msg(SOLVERR, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message); + break; + default: + Msg(WARNING, "Unknown type of message received from %s", + num >= 0 ? SINFO[num].name : "client"); + Msg(SOLVER, "%-8.8s: %s", num >= 0 ? SINFO[num].name : "Client", message); + break; + } + WID->check(); } else{ - Msg(WARNING, "Failed to receive message body on socket: aborting"); - break; + Msg(WARNING, "Failed to receive message body on socket: aborting"); + break; } delete [] message; } @@ -270,10 +270,10 @@ int Solver(int num, const char *args) if(num >= 0){ for(int i = 0; i < SINFO[num].nboptions; i++) { if(SINFO[num].nbval[i]) { - WID->solver[num].choice[i]->clear(); - for(int j = 0; j < SINFO[num].nbval[i]; j++) - WID->solver[num].choice[i]->add(SINFO[num].option[i][j]); - WID->solver[num].choice[i]->value(0); + WID->solver[num].choice[i]->clear(); + for(int j = 0; j < SINFO[num].nbval[i]; j++) + WID->solver[num].choice[i]->add(SINFO[num].option[i][j]); + WID->solver[num].choice[i]->value(0); } } } diff --git a/Fltk/SpherePosition_Widget.h b/Fltk/SpherePosition_Widget.h index e27118172e54383d4ab9e0d61beea0e7ce981241..d8915f647102498a9a91a84cd4209aba7c57bb63 100644 --- a/Fltk/SpherePosition_Widget.h +++ b/Fltk/SpherePosition_Widget.h @@ -48,24 +48,24 @@ class SpherePosition_Widget : public Fl_Widget { case FL_DRAG: case FL_RELEASE: { - int x1 = x() + 3; - int y1 = y() + 3; - int w1 = w() - 6; - int h1 = h() - 6; - double xx = (Fl::event_x() - x1) / (0.5 * w1) - 1.; - double yy = -((Fl::event_y() - y1) / (0.5 * h1) - 1.); - if(xx != _x || yy != _y) { - double norm = sqrt(xx * xx + yy * yy); - if(norm > 1.){ - xx /= norm; - yy /= norm; - norm = 1.; - } - _x = xx; _y = yy; _z = sqrt(1. - norm); - set_changed(); - redraw(); - do_callback(); - } + int x1 = x() + 3; + int y1 = y() + 3; + int w1 = w() - 6; + int h1 = h() - 6; + double xx = (Fl::event_x() - x1) / (0.5 * w1) - 1.; + double yy = -((Fl::event_y() - y1) / (0.5 * h1) - 1.); + if(xx != _x || yy != _y) { + double norm = sqrt(xx * xx + yy * yy); + if(norm > 1.){ + xx /= norm; + yy /= norm; + norm = 1.; + } + _x = xx; _y = yy; _z = sqrt(1. - norm); + set_changed(); + redraw(); + do_callback(); + } } return 1; default: diff --git a/Geo/ExtrudeParams.h b/Geo/ExtrudeParams.h index 35c65b03e82b348c98a7f8bb7d1919d5e824bd91..4360a548b01b4231740a0e7704da0779d7ec62d1 100644 --- a/Geo/ExtrudeParams.h +++ b/Geo/ExtrudeParams.h @@ -40,12 +40,12 @@ public : static smooth_data *normals; ExtrudeParams(int Mode = EXTRUDED_ENTITY); void fill(int type, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double angle); + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double angle); double u(int iLayer, int iElemLayer); void Extrude(int iLayer, int iElemLayer, - double &dx, double &dy, double &dz); + double &dx, double &dy, double &dz); void Extrude(double t, double &x, double &y, double &z); void Rotate(double matr[3][3]); struct{ diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index ae46c4e480d0aa21eff3a21281a1c4f34579232f..9a61c98c8e548b63f7329cbf6bf705985bcefd6b 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -1,4 +1,4 @@ -// $Id: GEdge.cpp,v 1.45 2008-02-23 16:19:22 remacle Exp $ +// $Id: GEdge.cpp,v 1.46 2008-03-20 11:44:04 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -175,8 +175,8 @@ double GEdge::curvature(double par) const GPoint P2 = point(par + eps2); double D = sqrt ((P1.x() - P2.x()) * (P1.x() - P2.x()) + - (P1.y() - P2.y()) * (P1.y() - P2.y()) + - (P1.z() - P2.z()) * (P1.z() - P2.z())); + (P1.y() - P2.y()) * (P1.y() - P2.y()) + + (P1.z() - P2.z()) * (P1.z() - P2.z())); n1.normalize(); n2.normalize(); diff --git a/Geo/GEdgeLoop.cpp b/Geo/GEdgeLoop.cpp index 668e87dcae655ddfc1726f6c2f05dbdea239a191..a120f82b57f8219db1a870d1f75c4b4324665f05 100644 --- a/Geo/GEdgeLoop.cpp +++ b/Geo/GEdgeLoop.cpp @@ -1,4 +1,4 @@ -// $Id: GEdgeLoop.cpp,v 1.12 2008-02-17 08:47:58 geuzaine Exp $ +// $Id: GEdgeLoop.cpp,v 1.13 2008-03-20 11:44:04 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -73,8 +73,8 @@ GEdgeSigned nextOne(GEdgeSigned *thisOne, std::list<GEdge*> &wire) GEdge *ge = *it; if(countInList(possibleChoices, ge) == 2){ wire.erase(std::remove_if(wire.begin(), wire.end(), - std::bind2nd(std::equal_to<GEdge*>(), ge)), - wire.end()); + std::bind2nd(std::equal_to<GEdge*>(), ge)), + wire.end()); wire.push_back(ge); GVertex *v1 = ge->getBeginVertex(); GVertex *v2 = ge->getEndVertex(); @@ -90,8 +90,8 @@ GEdgeSigned nextOne(GEdgeSigned *thisOne, std::list<GEdge*> &wire) GEdge *ge = *it; if(ge != thisOne->ge){ wire.erase(std::remove_if(wire.begin(),wire.end(), - std::bind2nd(std::equal_to<GEdge*>(), ge)), - wire.end()); + std::bind2nd(std::equal_to<GEdge*>(), ge)), + wire.end()); GVertex *v1 = ge->getBeginVertex(); GVertex *v2 = ge->getEndVertex(); if(v1 == gv) return GEdgeSigned(1, ge); diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index d53b3e0e251bbbc9f8fb650ab1ce1533824073a0..b1fe9d4e7e3f4374b17ca935ec585c600ef91354 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -1,4 +1,4 @@ -// $Id: GFace.cpp,v 1.59 2008-03-03 22:04:22 geuzaine Exp $ +// $Id: GFace.cpp,v 1.60 2008-03-20 11:44:04 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -369,7 +369,7 @@ end: meanPlane.x = meanPlane.d / meanPlane.a; } else if(fabs(meanPlane.b) >= fabs(meanPlane.a) && - fabs(meanPlane.b) >= fabs(meanPlane.c)){ + fabs(meanPlane.b) >= fabs(meanPlane.c)){ meanPlane.y = meanPlane.d / meanPlane.b; } else{ @@ -396,13 +396,13 @@ end: for(; itv != verts.end(); itv++){ const GVertex *v = *itv; double d = meanPlane.a * v->x() + meanPlane.b * v->y() + - meanPlane.c * v->z() - meanPlane.d; + meanPlane.c * v->z() - meanPlane.d; if(fabs(d) > lc * 1.e-3) { - Msg(GERROR1, "Plane surface %d (%gx+%gy+%gz+%g=0) is not plane!", - tag(), meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d); - Msg(GERROR3, "Control point %d = (%g,%g,%g), val=%g", - v->tag(), v->x(), v->y(), v->z(), d); - return; + Msg(GERROR1, "Plane surface %d (%gx+%gy+%gz+%g=0) is not plane!", + tag(), meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d); + Msg(GERROR3, "Control point %d = (%g,%g,%g), val=%g", + v->tag(), v->x(), v->y(), v->z(), d); + return; } } } @@ -410,7 +410,7 @@ end: } void GFace::getMeanPlaneData(double VX[3], double VY[3], - double &x, double &y, double &z) const + double &x, double &y, double &z) const { VX[0] = meanPlane.plan[0][0]; VX[1] = meanPlane.plan[0][1]; @@ -467,8 +467,8 @@ double GFace::curvature (const SPoint2 ¶m) const } void GFace::XYZtoUV(const double X, const double Y, const double Z, - double &U, double &V, const double relax, - const bool onSurface) const + double &U, double &V, const double relax, + const bool onSurface) const { #if !defined(HAVE_GMSH_EMBEDDED) const double Precision = 1.e-8; @@ -502,45 +502,45 @@ void GFace::XYZtoUV(const double X, const double Y, const double Z, if (err2 < 1.e-8 * CTX.lc) return; while(err > Precision && iter < MaxIter) { - P = point(U, V); - Pair<SVector3, SVector3> der = firstDer(SPoint2(U, V)); - mat[0][0] = der.left().x(); - mat[0][1] = der.left().y(); - mat[0][2] = der.left().z(); - mat[1][0] = der.right().x(); - mat[1][1] = der.right().y(); - mat[1][2] = der.right().z(); - mat[2][0] = 0.; - mat[2][1] = 0.; - mat[2][2] = 0.; - invert_singular_matrix3x3(mat, jac); - - Unew = U + relax * - (jac[0][0] * (X - P.x()) + jac[1][0] * (Y - P.y()) + - jac[2][0] * (Z - P.z())); - Vnew = V + relax * - (jac[0][1] * (X - P.x()) + jac[1][1] * (Y - P.y()) + - jac[2][1] * (Z - P.z())); - - //if(Unew > umax || Vnew > vmax || Unew < umin || Vnew < vmin) break; - - err = DSQR(Unew - U) + DSQR(Vnew - V); - err2 = sqrt(DSQR(X - P.x()) + DSQR(Y - P.y()) + DSQR(Z - P.z())); - iter++; - U = Unew; - V = Vnew; + P = point(U, V); + Pair<SVector3, SVector3> der = firstDer(SPoint2(U, V)); + mat[0][0] = der.left().x(); + mat[0][1] = der.left().y(); + mat[0][2] = der.left().z(); + mat[1][0] = der.right().x(); + mat[1][1] = der.right().y(); + mat[1][2] = der.right().z(); + mat[2][0] = 0.; + mat[2][1] = 0.; + mat[2][2] = 0.; + invert_singular_matrix3x3(mat, jac); + + Unew = U + relax * + (jac[0][0] * (X - P.x()) + jac[1][0] * (Y - P.y()) + + jac[2][0] * (Z - P.z())); + Vnew = V + relax * + (jac[0][1] * (X - P.x()) + jac[1][1] * (Y - P.y()) + + jac[2][1] * (Z - P.z())); + + //if(Unew > umax || Vnew > vmax || Unew < umin || Vnew < vmin) break; + + err = DSQR(Unew - U) + DSQR(Vnew - V); + err2 = sqrt(DSQR(X - P.x()) + DSQR(Y - P.y()) + DSQR(Z - P.z())); + iter++; + U = Unew; + V = Vnew; } //printf("i=%d j=%d err=%g iter=%d err2=%g u=%.16g v=%.16g x=%g y=%g z=%g\n", // i, j, err, iter, err2, U, V, X, Y, Z); if(iter < MaxIter && err <= Precision && - Unew <= umax && Vnew <= vmax && - Unew >= umin && Vnew >= vmin){ - if (onSurface && err2 > 1.e-4 * CTX.lc) - Msg(WARNING, "Converged for i=%d j=%d (err=%g iter=%d) BUT xyz error = %g", - i, j, err, iter, err2); - return; + Unew <= umax && Vnew <= vmax && + Unew >= umin && Vnew >= vmin){ + if (onSurface && err2 > 1.e-4 * CTX.lc) + Msg(WARNING, "Converged for i=%d j=%d (err=%g iter=%d) BUT xyz error = %g", + i, j, err, iter, err2); + return; } } } @@ -595,11 +595,11 @@ bool GFace::buildRepresentationCross() else{ Range<double> t_bounds = ge->parBounds(0); GPoint p[3] = {ge->point(t_bounds.low()), - ge->point(0.5 * (t_bounds.low() + t_bounds.high())), - ge->point(t_bounds.high())}; + ge->point(0.5 * (t_bounds.low() + t_bounds.high())), + ge->point(t_bounds.high())}; for(int i = 0; i < 3; i++){ - SPoint2 uv = parFromPoint(SPoint3(p[i].x(), p[i].y(), p[i].z())); - bb += SPoint3(uv.x(), uv.y(), 0.); + SPoint2 uv = parFromPoint(SPoint3(p[i].x(), p[i].y(), p[i].z())); + bb += SPoint3(uv.x(), uv.y(), 0.); } } } @@ -616,22 +616,22 @@ bool GFace::buildRepresentationCross() double t = (double)i / (double)(N - 1); double x, y, z; if(!dir){ - x = 0.5 * (t * (v0.x() + v1.x()) + (1. - t) * (v2.x() + v3.x())); - y = 0.5 * (t * (v0.y() + v1.y()) + (1. - t) * (v2.y() + v3.y())); - z = 0.5 * (t * (v0.z() + v1.z()) + (1. - t) * (v2.z() + v3.z())); + x = 0.5 * (t * (v0.x() + v1.x()) + (1. - t) * (v2.x() + v3.x())); + y = 0.5 * (t * (v0.y() + v1.y()) + (1. - t) * (v2.y() + v3.y())); + z = 0.5 * (t * (v0.z() + v1.z()) + (1. - t) * (v2.z() + v3.z())); } else{ - x = 0.5 * (t * (v0.x() + v3.x()) + (1. - t) * (v2.x() + v1.x())); - y = 0.5 * (t * (v0.y() + v3.y()) + (1. - t) * (v2.y() + v1.y())); - z = 0.5 * (t * (v0.z() + v3.z()) + (1. - t) * (v2.z() + v1.z())); + x = 0.5 * (t * (v0.x() + v3.x()) + (1. - t) * (v2.x() + v1.x())); + y = 0.5 * (t * (v0.y() + v3.y()) + (1. - t) * (v2.y() + v1.y())); + z = 0.5 * (t * (v0.z() + v3.z()) + (1. - t) * (v2.z() + v1.z())); } pt.setPosition(x, y, z); if(containsPoint(pt)){ - pt_last_inside.setPosition(x, y, z); - if(!end_line) { cross.push_back(pt); end_line = 1; } + pt_last_inside.setPosition(x, y, z); + if(!end_line) { cross.push_back(pt); end_line = 1; } } else { - if(end_line) { cross.push_back(pt_last_inside); end_line = 0; } + if(end_line) { cross.push_back(pt_last_inside); end_line = 0; } } } if(end_line) cross.push_back(pt_last_inside); diff --git a/Geo/GFace.h b/Geo/GFace.h index 2ef61ed548bb6ec282b77f41ebb38a4295e43127..46600eb1e5f38fbe5732ed40a2bdbf9673c34025 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -89,8 +89,8 @@ class GFace : public GEntity // compute the parameters UV from a point XYZ void XYZtoUV(const double X, const double Y, const double Z, - double &U, double &V, const double relax, - const bool onSurface=true) const; + double &U, double &V, const double relax, + const bool onSurface=true) const; // The bounding box virtual SBoundingBox3d bounds() const; @@ -160,7 +160,7 @@ class GFace : public GEntity // Get the mean plane info void getMeanPlaneData(double VX[3], double VY[3], - double &x, double &y, double &z) const; + double &x, double &y, double &z) const; void getMeanPlaneData(double plan[3][3]) const; // Get number of elements in the mesh and get element by index diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 2024ff620d0b4c8b37cd72d8d70b77d87f4f0dc4..8c86186d7ba77777d42f9b2d6b7a0c6b7e199c9d 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1,4 +1,4 @@ -// $Id: GModel.cpp,v 1.75 2008-03-19 20:13:44 geuzaine Exp $ +// $Id: GModel.cpp,v 1.76 2008-03-20 11:44:04 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -188,20 +188,20 @@ void GModel::snapVertices() Range<double> parb = (*it)->parBounds(0); double t; if ((*it)->getBeginVertex() == *vit){ - t = parb.low(); + t = parb.low(); } else if ((*it)->getEndVertex() == *vit){ - t = parb.high(); + t = parb.high(); } else throw; GPoint gp = (*it)->point(t); double d = sqrt((gp.x() - (*vit)->x()) * (gp.x() - (*vit)->x()) + - (gp.y() - (*vit)->y()) * (gp.y() - (*vit)->y()) + - (gp.z() - (*vit)->z()) * (gp.z() - (*vit)->z())); + (gp.y() - (*vit)->y()) * (gp.y() - (*vit)->y()) + + (gp.z() - (*vit)->z()) * (gp.z() - (*vit)->z())); if (d > tol){ - (*vit)->setPosition(gp); - Msg(WARNING, "Geom Vertex %d Corrupted (%12.5E)... Snap performed", - (*vit)->tag(), d); + (*vit)->setPosition(gp); + Msg(WARNING, "Geom Vertex %d Corrupted (%12.5E)... Snap performed", + (*vit)->tag(), d); } } vit++; @@ -263,7 +263,7 @@ void GModel::deletePhysicalGroup(int dim, int num) for(viter it = firstVertex(); it != lastVertex(); ++it){ std::vector<int> p; for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); + if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); (*it)->physicals = p; } break; @@ -271,7 +271,7 @@ void GModel::deletePhysicalGroup(int dim, int num) for(eiter it = firstEdge(); it != lastEdge(); ++it){ std::vector<int> p; for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); + if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); (*it)->physicals = p; } break; @@ -279,7 +279,7 @@ void GModel::deletePhysicalGroup(int dim, int num) for(fiter it = firstFace(); it != lastFace(); ++it){ std::vector<int> p; for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); + if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); (*it)->physicals = p; } break; @@ -287,7 +287,7 @@ void GModel::deletePhysicalGroup(int dim, int num) for(riter it = firstRegion(); it != lastRegion(); ++it){ std::vector<int> p; for(unsigned int i = 0; i < (*it)->physicals.size(); i++) - if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); + if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]); (*it)->physicals = p; } break; @@ -367,7 +367,7 @@ int GModel::getMeshStatus(bool countDiscrete) for(riter it = firstRegion(); it != lastRegion(); ++it) if((countDiscrete || (*it)->geomType() != GEntity::DiscreteVolume) && ((*it)->tetrahedra.size() ||(*it)->hexahedra.size() || - (*it)->prisms.size() || (*it)->pyramids.size())) return 3; + (*it)->prisms.size() || (*it)->pyramids.size())) return 3; for(fiter it = firstFace(); it != lastFace(); ++it) if((countDiscrete || (*it)->geomType() != GEntity::DiscreteSurface) && ((*it)->triangles.size() || (*it)->quadrangles.size())) return 2; @@ -422,23 +422,23 @@ MVertex *GModel::getMeshVertexByTag(int n) if(dense){ _vertexVectorCache.resize(MVertex::getGlobalNumber()); for(viter it = firstVertex(); it != lastVertex(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); + insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); for(eiter it = firstEdge(); it != lastEdge(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); + insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); for(fiter it = firstFace(); it != lastFace(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); + insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); for(riter it = firstRegion(); it != lastRegion(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); + insertMeshVertices((*it)->mesh_vertices, _vertexVectorCache); } else{ for(viter it = firstVertex(); it != lastVertex(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); + insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); for(eiter it = firstEdge(); it != lastEdge(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); + insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); for(fiter it = firstFace(); it != lastFace(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); + insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); for(riter it = firstRegion(); it != lastRegion(); ++it) - insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); + insertMeshVertices((*it)->mesh_vertices, _vertexMapCache); } } @@ -542,37 +542,37 @@ int GModel::renumberMeshVertices(bool saveAll) for(viter it = firstVertex(); it != lastVertex(); ++it) if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) - (*it)->mesh_vertices[i]->setNum(0); + (*it)->mesh_vertices[i]->setNum(0); } for(eiter it = firstEdge(); it != lastEdge(); ++it) if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->lines.size(); i++) - for(int j = 0; j < (*it)->lines[i]->getNumVertices(); j++) - (*it)->lines[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->lines[i]->getNumVertices(); j++) + (*it)->lines[i]->getVertex(j)->setNum(0); } for(fiter it = firstFace(); it != lastFace(); ++it) if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - for(int j = 0; j < (*it)->triangles[i]->getNumVertices(); j++) - (*it)->triangles[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->triangles[i]->getNumVertices(); j++) + (*it)->triangles[i]->getVertex(j)->setNum(0); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - for(int j = 0; j < (*it)->quadrangles[i]->getNumVertices(); j++) - (*it)->quadrangles[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->quadrangles[i]->getNumVertices(); j++) + (*it)->quadrangles[i]->getVertex(j)->setNum(0); } for(riter it = firstRegion(); it != lastRegion(); ++it) if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) - for(int j = 0; j < (*it)->tetrahedra[i]->getNumVertices(); j++) - (*it)->tetrahedra[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->tetrahedra[i]->getNumVertices(); j++) + (*it)->tetrahedra[i]->getVertex(j)->setNum(0); for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) - for(int j = 0; j < (*it)->hexahedra[i]->getNumVertices(); j++) - (*it)->hexahedra[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->hexahedra[i]->getNumVertices(); j++) + (*it)->hexahedra[i]->getVertex(j)->setNum(0); for(unsigned int i = 0; i < (*it)->prisms.size(); i++) - for(int j = 0; j < (*it)->prisms[i]->getNumVertices(); j++) - (*it)->prisms[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->prisms[i]->getNumVertices(); j++) + (*it)->prisms[i]->getVertex(j)->setNum(0); for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) - for(int j = 0; j < (*it)->pyramids[i]->getNumVertices(); j++) - (*it)->pyramids[i]->getVertex(j)->setNum(0); + for(int j = 0; j < (*it)->pyramids[i]->getNumVertices(); j++) + (*it)->pyramids[i]->getVertex(j)->setNum(0); } // renumber all the mesh vertices tagged with 0 @@ -580,19 +580,19 @@ int GModel::renumberMeshVertices(bool saveAll) for(viter it = firstVertex(); it != lastVertex(); ++it) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) if(!(*it)->mesh_vertices[i]->getNum()) - (*it)->mesh_vertices[i]->setNum(++numVertices); + (*it)->mesh_vertices[i]->setNum(++numVertices); for(eiter it = firstEdge(); it != lastEdge(); ++it) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) if(!(*it)->mesh_vertices[i]->getNum()) - (*it)->mesh_vertices[i]->setNum(++numVertices); + (*it)->mesh_vertices[i]->setNum(++numVertices); for(fiter it = firstFace(); it != lastFace(); ++it) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) if(!(*it)->mesh_vertices[i]->getNum()) - (*it)->mesh_vertices[i]->setNum(++numVertices); + (*it)->mesh_vertices[i]->setNum(++numVertices); for(riter it = firstRegion(); it != lastRegion(); ++it) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) if(!(*it)->mesh_vertices[i]->getNum()) - (*it)->mesh_vertices[i]->setNum(++numVertices); + (*it)->mesh_vertices[i]->setNum(++numVertices); return numVertices; } @@ -620,7 +620,7 @@ void GModel::deleteMeshPartitions() } static int checkVertices(std::vector<MVertex*> &vertices, - std::set<MVertex*, MVertexLessThanLexicographic> &pos) + std::set<MVertex*, MVertexLessThanLexicographic> &pos) { int num = 0; for(unsigned int i = 0; i < vertices.size(); i++){ @@ -631,7 +631,7 @@ static int checkVertices(std::vector<MVertex*> &vertices, } else{ Msg(INFO, "Vertices %d and %d have identical position (%g, %g, %g)", - (*it)->getNum(), v->getNum(), v->x(), v->y(), v->z()); + (*it)->getNum(), v->getNum(), v->x(), v->y(), v->z()); num++; } } @@ -640,8 +640,8 @@ static int checkVertices(std::vector<MVertex*> &vertices, template <class T> static int checkElements(int tag, - std::vector<T*> &elements, - std::set<MElement*, MElementLessThanLexicographic> &pos) + std::vector<T*> &elements, + std::set<MElement*, MElementLessThanLexicographic> &pos) { int num = 0; for(unsigned int i = 0; i < elements.size(); i++){ @@ -654,15 +654,15 @@ static int checkElements(int tag, char temp[256], temp2[256]; sprintf(temp, "Elements %d ( ", (*it)->getNum()); for (int i = 0; i < (*it)->getNumVertices();i++){ - sprintf(temp2, "%d ", (*it)->getVertex(i)->getNum()); - strcat(temp, temp2); + sprintf(temp2, "%d ", (*it)->getVertex(i)->getNum()); + strcat(temp, temp2); } sprintf(temp2, ") on entity %d has same barycenter as element %d ( ", - tag, e->getNum()); + tag, e->getNum()); strcat(temp, temp2); for (int i = 0; i < e->getNumVertices(); i++){ - sprintf(temp2, "%d ", e->getVertex(i)->getNum()); - strcat(temp, temp2); + sprintf(temp2, "%d ", e->getVertex(i)->getNum()); + strcat(temp, temp2); } sprintf(temp2, ")"); strcat(temp, temp2); diff --git a/Geo/GModel.h b/Geo/GModel.h index eaecd3c2d868bde00ed01a8248d8ad94e10dcb5e..11c96342d9e21d2a91ca8f663a589e91db80eb3e 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -209,42 +209,42 @@ class GModel // Gmsh mesh file format int readMSH(const std::string &name); int writeMSH(const std::string &name, double version=1.0, bool binary=false, - bool saveAll=false, double scalingFactor=1.0); + bool saveAll=false, double scalingFactor=1.0); // Mesh statistics (as Gmsh post-processing views) int writePOS(const std::string &name, bool printElementary, - bool printElementNumber, bool printGamma, bool printEta, bool printRho, - bool saveAll=false, double scalingFactor=1.0); + bool printElementNumber, bool printGamma, bool printEta, bool printRho, + bool saveAll=false, double scalingFactor=1.0); // Stereo lithography format int readSTL(const std::string &name, double tolerance=1.e-3); int writeSTL(const std::string &name, bool binary=false, - bool saveAll=false, double scalingFactor=1.0); + bool saveAll=false, double scalingFactor=1.0); // Inventor/VRML format int readVRML(const std::string &name); int writeVRML(const std::string &name, - bool saveAll=false, double scalingFactor=1.0); + bool saveAll=false, double scalingFactor=1.0); // I-deas universal mesh format int readUNV(const std::string &name); int writeUNV(const std::string &name, bool saveAll=false, - bool saveGroupsOfNodes=false, double scalingFactor=1.0); + bool saveGroupsOfNodes=false, double scalingFactor=1.0); // Medit (INRIA) mesh format int readMESH(const std::string &name); int writeMESH(const std::string &name, - bool saveAll=false, double scalingFactor=1.0); + bool saveAll=false, double scalingFactor=1.0); // Nastran Bulk Data File format int readBDF(const std::string &name); int writeBDF(const std::string &name, int format=0, - bool saveAll=false, double scalingFactor=1.0); + bool saveAll=false, double scalingFactor=1.0); // Plot3D structured mesh format int readP3D(const std::string &name); int writeP3D(const std::string &name, - bool saveAll=false, double scalingFactor=1.0); + bool saveAll=false, double scalingFactor=1.0); // CFD General Notation System files int readCGNS(const std::string &name); diff --git a/Geo/GModelIO_Fourier.cpp b/Geo/GModelIO_Fourier.cpp index 97efcb1d47542f7f0e39675b72cba1e23ea47614..866b2a06dcd36088be971d63b4b39a0e76020f1d 100644 --- a/Geo/GModelIO_Fourier.cpp +++ b/Geo/GModelIO_Fourier.cpp @@ -50,22 +50,22 @@ void makeGFace(GModel *m, FM::Patch* patch) i1 = eB->GetStartPoint()->GetTag(); i2 = eB->GetEndPoint()->GetTag(); m->add(new fourierEdge(m, eB, eB->GetTag(), m->getVertexByTag(i1), - m->getVertexByTag(i2))); + m->getVertexByTag(i2))); FM::TopoEdge* eR = new FM::TopoEdge(++tagEdge, curveR, vLR, vUR); i1 = eR->GetStartPoint()->GetTag(); i2 = eR->GetEndPoint()->GetTag(); m->add(new fourierEdge(m, eR, eR->GetTag(), m->getVertexByTag(i1), - m->getVertexByTag(i2))); + m->getVertexByTag(i2))); FM::TopoEdge* eT = new FM::TopoEdge(++tagEdge, curveT, vUR, vUL); i1 = eT->GetStartPoint()->GetTag(); i2 = eT->GetEndPoint()->GetTag(); m->add(new fourierEdge(m, eT, eT->GetTag(), m->getVertexByTag(i1), - m->getVertexByTag(i2))); + m->getVertexByTag(i2))); FM::TopoEdge* eL = new FM::TopoEdge(++tagEdge, curveL, vUL, vLL); i1 = eL->GetStartPoint()->GetTag(); i2 = eL->GetEndPoint()->GetTag(); m->add(new fourierEdge(m, eL, eL->GetTag(), m->getVertexByTag(i1), - m->getVertexByTag(i2))); + m->getVertexByTag(i2))); FM::TopoFace* face = new FM::TopoFace(m->getNumFaces() + 1, patch); face->AddEdge(eB); face->AddEdge(eR); diff --git a/Geo/GModelIO_Geo.cpp b/Geo/GModelIO_Geo.cpp index f9e394c94b1743577a1bd7da78163f467d70baab..937b9e15b83a34f010075ec36d203ea1faa650b3 100644 --- a/Geo/GModelIO_Geo.cpp +++ b/Geo/GModelIO_Geo.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_Geo.cpp,v 1.18 2008-03-19 17:26:48 geuzaine Exp $ +// $Id: GModelIO_Geo.cpp,v 1.19 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -58,8 +58,8 @@ int GModel::importGEOInternals() List_Read(points, i, &p); GVertex *v = getVertexByTag(p->Num); if(!v){ - v = new gmshVertex(this, p); - add(v); + v = new gmshVertex(this, p); + add(v); } if(!p->Visible) v->setVisibility(0); } @@ -71,17 +71,17 @@ int GModel::importGEOInternals() Curve *c; List_Read(curves, i, &c); if(c->Num >= 0 && c->beg && c->end){ - GEdge *e = getEdgeByTag(c->Num); - if(!e){ - e = new gmshEdge(this, c, - getVertexByTag(c->beg->Num), - getVertexByTag(c->end->Num)); - add(e); - } - else - e->resetMeshAttributes(); - if(!c->Visible) e->setVisibility(0); - if(c->Color.type) e->setColor(c->Color.mesh); + GEdge *e = getEdgeByTag(c->Num); + if(!e){ + e = new gmshEdge(this, c, + getVertexByTag(c->beg->Num), + getVertexByTag(c->end->Num)); + add(e); + } + else + e->resetMeshAttributes(); + if(!c->Visible) e->setVisibility(0); + if(c->Color.type) e->setColor(c->Color.mesh); } } List_Delete(curves); @@ -93,11 +93,11 @@ int GModel::importGEOInternals() List_Read(surfaces, i, &s); GFace *f = getFaceByTag(s->Num); if(!f){ - f = new gmshFace(this, s); - add(f); + f = new gmshFace(this, s); + add(f); } else - f->resetMeshAttributes(); + f->resetMeshAttributes(); if(!s->Visible) f->setVisibility(0); if(s->Color.type) f->setColor(s->Color.mesh); } @@ -110,11 +110,11 @@ int GModel::importGEOInternals() List_Read(volumes, i, &v); GRegion *r = getRegionByTag(v->Num); if(!r){ - r = new gmshRegion(this, v); - add(r); + r = new gmshRegion(this, v); + add(r); } else - r->resetMeshAttributes(); + r->resetMeshAttributes(); if(!v->Visible) r->setVisibility(0); if(v->Color.type) r->setColor(v->Color.mesh); } @@ -135,8 +135,8 @@ int GModel::importGEOInternals() } int pnum = sign(num) * p->Num; if(ge && std::find(ge->physicals.begin(), ge->physicals.end(), pnum) == - ge->physicals.end()) - ge->physicals.push_back(pnum); + ge->physicals.end()) + ge->physicals.push_back(pnum); } } @@ -172,7 +172,7 @@ class writeFieldGEO{ { fprintf(geo, "Field[%i] = %s;\n", it.first, it.second->get_name()); std::for_each(it.second->options.begin(), it.second->options.end(), - writeFieldOptionGEO(geo, it.second)); + writeFieldOptionGEO(geo, it.second)); } }; @@ -187,12 +187,12 @@ class writeGVertexGEO { Vertex *v = (Vertex*)gv->getNativePtr(); if(!v) return; fprintf(geo, "Point (%d) = {%.16g, %.16g, %.16g, %.16g};\n", - v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc); + v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc); } else{ fprintf(geo, "Point (%d) = {%.16g, %.16g, %.16g, %.16g};\n", - gv->tag(), gv->x(), gv->y(), gv->z(), - gv->prescribedMeshSizeAtVertex()); + gv->tag(), gv->x(), gv->y(), gv->z(), + gv->prescribedMeshSizeAtVertex()); } } }; @@ -211,89 +211,89 @@ class writeGEdgeGEO { if(!c || c->Num < 0) return; switch (c->Typ) { case MSH_SEGM_LINE: - fprintf(geo, "Line (%d) = ", c->Num); - break; + fprintf(geo, "Line (%d) = ", c->Num); + break; case MSH_SEGM_CIRC: case MSH_SEGM_CIRC_INV: - fprintf(geo, "Circle (%d) = ", c->Num); - break; + fprintf(geo, "Circle (%d) = ", c->Num); + break; case MSH_SEGM_ELLI: case MSH_SEGM_ELLI_INV: - fprintf(geo, "Ellipse (%d) = ", c->Num); - break; + fprintf(geo, "Ellipse (%d) = ", c->Num); + break; case MSH_SEGM_NURBS: - fprintf(geo, "Nurbs (%d) = {", c->Num); - for(int i = 0; i < List_Nbr(c->Control_Points); i++) { - Vertex *v; - List_Read(c->Control_Points, i, &v); - if(!i) - fprintf(geo, "%d", v->Num); - else - fprintf(geo, ", %d", v->Num); - if(i % 8 == 7 && i != List_Nbr(c->Control_Points) - 1) - fprintf(geo, "\n"); - } - fprintf(geo, "}\n"); - fprintf(geo, " Knots {"); - for(int j = 0; j < List_Nbr(c->Control_Points) + c->degre + 1; j++) { - if(!j) - fprintf(geo, "%.16g", c->k[j]); - else - fprintf(geo, ", %.16g", c->k[j]); - if(j % 5 == 4 && j != List_Nbr(c->Control_Points) + c->degre) - fprintf(geo, "\n "); - } - fprintf(geo, "}\n"); - fprintf(geo, " Order %d;\n", c->degre); - return; + fprintf(geo, "Nurbs (%d) = {", c->Num); + for(int i = 0; i < List_Nbr(c->Control_Points); i++) { + Vertex *v; + List_Read(c->Control_Points, i, &v); + if(!i) + fprintf(geo, "%d", v->Num); + else + fprintf(geo, ", %d", v->Num); + if(i % 8 == 7 && i != List_Nbr(c->Control_Points) - 1) + fprintf(geo, "\n"); + } + fprintf(geo, "}\n"); + fprintf(geo, " Knots {"); + for(int j = 0; j < List_Nbr(c->Control_Points) + c->degre + 1; j++) { + if(!j) + fprintf(geo, "%.16g", c->k[j]); + else + fprintf(geo, ", %.16g", c->k[j]); + if(j % 5 == 4 && j != List_Nbr(c->Control_Points) + c->degre) + fprintf(geo, "\n "); + } + fprintf(geo, "}\n"); + fprintf(geo, " Order %d;\n", c->degre); + return; case MSH_SEGM_SPLN: - fprintf(geo, "CatmullRom (%d) = ", c->Num); - break; + fprintf(geo, "CatmullRom (%d) = ", c->Num); + break; case MSH_SEGM_BSPLN: - fprintf(geo, "BSpline (%d) = ", c->Num); - break; + fprintf(geo, "BSpline (%d) = ", c->Num); + break; case MSH_SEGM_BEZIER: - fprintf(geo, "Bezier (%d) = ", c->Num); - break; + fprintf(geo, "Bezier (%d) = ", c->Num); + break; default: - Msg(GERROR, "Unknown curve type %d", c->Typ); - return; + Msg(GERROR, "Unknown curve type %d", c->Typ); + return; } for(int i = 0; i < List_Nbr(c->Control_Points); i++) { - Vertex *v; - List_Read(c->Control_Points, i, &v); - if(i) - fprintf(geo, ", %d", v->Num); - else - fprintf(geo, "{%d", v->Num); - if(i % 6 == 7) - fprintf(geo, "\n"); + Vertex *v; + List_Read(c->Control_Points, i, &v); + if(i) + fprintf(geo, ", %d", v->Num); + else + fprintf(geo, "{%d", v->Num); + if(i % 6 == 7) + fprintf(geo, "\n"); } fprintf(geo, "};\n"); } else{ if(ge->getBeginVertex() && ge->getEndVertex()){ - if(ge->geomType() == GEntity::Line){ - fprintf(geo, "Line (%d) = {%d, %d};\n", - ge->tag(), ge->getBeginVertex()->tag(), ge->getEndVertex()->tag()); - } - else{ - // approximate all other curves by splines - Range<double> bounds = ge->parBounds(0); - double umin = bounds.low(); - double umax = bounds.high(); - fprintf(geo, "p%d = newp;\n", ge->tag()); - for(int i = 1; i < ge->minimumDrawSegments(); i++){ - double u = umin + (double)i / ge->minimumDrawSegments() * (umax - umin); - GPoint p = ge->point(u); - fprintf(geo, "Point (p%d + %d) = {%.16g, %.16g, %.16g, 1.e+22};\n", - ge->tag(), i, p.x(), p.y(), p.z()); - } - fprintf(geo, "CatmullRom (%d) = {%d", ge->tag(), ge->getBeginVertex()->tag()); - for(int i = 1; i < ge->minimumDrawSegments(); i++) - fprintf(geo, ", p%d + %d", ge->tag(), i); - fprintf(geo, ", %d};\n", ge->getEndVertex()->tag()); - } + if(ge->geomType() == GEntity::Line){ + fprintf(geo, "Line (%d) = {%d, %d};\n", + ge->tag(), ge->getBeginVertex()->tag(), ge->getEndVertex()->tag()); + } + else{ + // approximate all other curves by splines + Range<double> bounds = ge->parBounds(0); + double umin = bounds.low(); + double umax = bounds.high(); + fprintf(geo, "p%d = newp;\n", ge->tag()); + for(int i = 1; i < ge->minimumDrawSegments(); i++){ + double u = umin + (double)i / ge->minimumDrawSegments() * (umax - umin); + GPoint p = ge->point(u); + fprintf(geo, "Point (p%d + %d) = {%.16g, %.16g, %.16g, 1.e+22};\n", + ge->tag(), i, p.x(), p.y(), p.z()); + } + fprintf(geo, "CatmullRom (%d) = {%d", ge->tag(), ge->getBeginVertex()->tag()); + for(int i = 1; i < ge->minimumDrawSegments(); i++) + fprintf(geo, ", p%d + %d", ge->tag(), i); + fprintf(geo, ", %d};\n", ge->getEndVertex()->tag()); + } } } } @@ -313,25 +313,25 @@ class writeGFaceGEO { if(edges.size() && orientations.size() == edges.size()){ std::vector<int> num, ori; for(std::list<GEdge*>::iterator it = edges.begin(); it != edges.end(); it++) - num.push_back((*it)->tag()); + num.push_back((*it)->tag()); for(std::list<int>::iterator it = orientations.begin(); it != orientations.end(); it++) - ori.push_back((*it) > 0 ? 1 : -1); + ori.push_back((*it) > 0 ? 1 : -1); fprintf(geo, "Line Loop (%d) = ", gf->tag()); for(unsigned int i = 0; i < num.size(); i++){ - if(i) - fprintf(geo, ", %d", num[i] * ori[i]); - else - fprintf(geo, "{%d", num[i] * ori[i]); + if(i) + fprintf(geo, ", %d", num[i] * ori[i]); + else + fprintf(geo, "{%d", num[i] * ori[i]); } fprintf(geo, "};\n"); if(gf->geomType() == GEntity::Plane){ - fprintf(geo, "Plane Surface (%d) = {%d};\n", gf->tag(), gf->tag()); + fprintf(geo, "Plane Surface (%d) = {%d};\n", gf->tag(), gf->tag()); } else if(edges.size() == 3 || edges.size() == 4){ - fprintf(geo, "Ruled Surface (%d) = {%d};\n", gf->tag(), gf->tag()); + fprintf(geo, "Ruled Surface (%d) = {%d};\n", gf->tag(), gf->tag()); } else{ - Msg(GERROR, "Skipping surface %d in export", gf->tag()); + Msg(GERROR, "Skipping surface %d in export", gf->tag()); } } } @@ -350,10 +350,10 @@ class writeGRegionGEO { if(faces.size()){ fprintf(geo, "Surface Loop (%d) = ", gr->tag()); for(std::list<GFace*>::iterator it = faces.begin(); it != faces.end(); it++) { - if(it != faces.begin()) - fprintf(geo, ", %d", (*it)->tag()); - else - fprintf(geo, "{%d", (*it)->tag()); + if(it != faces.begin()) + fprintf(geo, ", %d", (*it)->tag()); + else + fprintf(geo, "{%d", (*it)->tag()); } fprintf(geo, "};\n"); fprintf(geo, "Volume (%d) = {%d};\n", gr->tag(), gr->tag()); @@ -369,8 +369,8 @@ class writePhysicalGroupGEO { std::map<int, std::string> &oldLabels, &newLabels; public : writePhysicalGroupGEO(FILE *fp, int i, bool labels, - std::map<int, std::string> &o, - std::map<int, std::string> &n) + std::map<int, std::string> &o, + std::map<int, std::string> &n) : dim(i), printLabels(labels), oldLabels(o), newLabels(n) { geo = fp ? fp : stdout; @@ -380,11 +380,11 @@ class writePhysicalGroupGEO { std::string oldName, newName; if(printLabels){ if(oldLabels.count(g.first)) { - oldName = oldLabels[g.first]; - fprintf(geo, "%s = %d;\n", oldName.c_str(), g.first); + oldName = oldLabels[g.first]; + fprintf(geo, "%s = %d;\n", oldName.c_str(), g.first); } else if(newLabels.count(g.first)) { - newName = newLabels[g.first]; + newName = newLabels[g.first]; } } @@ -435,7 +435,7 @@ int GModel::writeGEO(const std::string &name, bool printLabels) getPhysicalGroups(groups); for(int i = 0; i < 4; i++) std::for_each(groups[i].begin(), groups[i].end(), - writePhysicalGroupGEO(fp, i, printLabels, labels, physicalNames)); + writePhysicalGroupGEO(fp, i, printLabels, labels, physicalNames)); std::for_each(getFields()->begin(), getFields()->end(), writeFieldGEO(fp)); if(getFields()->background_field > 0) diff --git a/Geo/GModelIO_MED.cpp b/Geo/GModelIO_MED.cpp index 034d5073f5cec594ef85e02dd6256fde2124bb6e..45b88d616967e8c2813f69a65e416df63b2405a6 100644 --- a/Geo/GModelIO_MED.cpp +++ b/Geo/GModelIO_MED.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_MED.cpp,v 1.8 2008-01-20 11:39:47 geuzaine Exp $ +// $Id: GModelIO_MED.cpp,v 1.9 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -49,131 +49,131 @@ typedef std::list<int>::const_iterator listIter; ConversionData::ConversionData() { - // Correspondance des types GMSH et MEd - static const med_geometrie_element ValuesTypesOfElts[] = { MED_SEG2, MED_TRIA3, MED_QUAD4, MED_TETRA4, - MED_HEXA8, MED_PENTA6, MED_PYRA5, MED_SEG3, - MED_TRIA6, MED_QUAD8, MED_TETRA10, MED_HEXA20, - MED_PENTA15, MED_PYRA13, MED_POINT1, MED_QUAD8, - MED_HEXA20, MED_PENTA15, MED_PYRA13, MED_NONE}; - - int i=0; - while (ValuesTypesOfElts[i] != MED_NONE) - { - typesOfElts[i+1]=ValuesTypesOfElts[i]; - ++i; - } - - // ************************** - // Num�rotation des Noeuds - // ************************** - // - // line ( 1er et 2nd Ordre) - i=1; - while ( i!=3 ) { - medVertexOrder[1].push_back(i); - medVertexOrder[8].push_back(i); - ++i; - } - medVertexOrder[8].push_back(3); - - // tria - i=1; - while ( i!=4 ) { - medVertexOrder[2].push_back(i); - medVertexOrder[9].push_back(i); - ++i; - } - medVertexOrder[9].push_back(4); - medVertexOrder[9].push_back(5); - medVertexOrder[9].push_back(6); - - // quad - i=1; - while ( i!=5 ) { - medVertexOrder[3].push_back(i); - medVertexOrder[10].push_back(i); - medVertexOrder[16].push_back(i); - ++i; - } - medVertexOrder[10].push_back(5); - medVertexOrder[16].push_back(5); - medVertexOrder[10].push_back(6); - medVertexOrder[16].push_back(6); - medVertexOrder[10].push_back(7); - medVertexOrder[16].push_back(7); - medVertexOrder[10].push_back(8); - medVertexOrder[16].push_back(8); - - // tetra - static const int OrderforTetra[] = { 1, 3, 2, 4, 0 }; - i=0; - while ( OrderforTetra[i] != 0 ) { - medVertexOrder[4].push_back(OrderforTetra[i]); - medVertexOrder[11].push_back(OrderforTetra[i]); - ++i; - } - static const int OrderforTetra2[] = { 7, 6 , 5, 8 , 9 , 10, 0 }; - i=0; - while ( OrderforTetra2[i] != 0 ) { - medVertexOrder[11].push_back(OrderforTetra2[i]); - ++i; - } - - // hexa - // le 1 MED est le 1er Gmsh, le 2nd Med est le 4ieme Gmsh , le 3 le 6 ... - static const int OrderforHexa[] = { 1, 5, 8, 4, 2, 6, 7, 3, 0}; - i=0; - while (OrderforHexa[i] != 0) - { - medVertexOrder[5].push_back(OrderforHexa[i]); - medVertexOrder[12].push_back(OrderforHexa[i]); - medVertexOrder[17].push_back(OrderforHexa[i]); - ++i; - }; - static const int OrderforHexa2[] = { 11,18,16,10,13,19,15,16,9,17,20,14, 0 }; - i=0; - while ( OrderforHexa2[i] != 0 ) { - medVertexOrder[12].push_back(OrderforHexa2[i]); - medVertexOrder[17].push_back(OrderforHexa2[i]); - ++i; - } - - // Prism - static const int OrderforPrism[] = { 1, 3, 2, 4, 6, 5, 0}; - i=0; - while (OrderforPrism[i] != 0) - { - medVertexOrder[6].push_back(OrderforPrism[i]); - medVertexOrder[13].push_back(OrderforPrism[i]); - medVertexOrder[18].push_back(OrderforPrism[i]); - ++i; - }; - static const int OrderforPrism2[] = { 8, 10, 7, 14, 13, 15, 9, 12, 11, 0}; - i=0; - while ( OrderforPrism2[i] != 0 ) { - medVertexOrder[13].push_back(OrderforPrism2[i]); - medVertexOrder[18].push_back(OrderforPrism2[i]); - ++i; - } - - - //Pyra - static const int OrderforPyra[] = { 1, 4, 3, 2, 5, 0}; - i=0; - while (OrderforPyra[i] != 0) - { - medVertexOrder[7].push_back(OrderforPyra[i]); - medVertexOrder[14].push_back(OrderforPyra[i]); - medVertexOrder[19].push_back(OrderforPyra[i]); - ++i; - }; - static const int OrderforPyra2[] = { 7, 11 ,9 , 6, 8, 13, 12 , 10, 0}; - i=0; - while ( OrderforPyra2[i] != 0 ) { - medVertexOrder[14].push_back(OrderforPyra2[i]); - medVertexOrder[19].push_back(OrderforPyra2[i]); - ++i; - } + // Correspondance des types GMSH et MEd + static const med_geometrie_element ValuesTypesOfElts[] = { MED_SEG2, MED_TRIA3, MED_QUAD4, MED_TETRA4, + MED_HEXA8, MED_PENTA6, MED_PYRA5, MED_SEG3, + MED_TRIA6, MED_QUAD8, MED_TETRA10, MED_HEXA20, + MED_PENTA15, MED_PYRA13, MED_POINT1, MED_QUAD8, + MED_HEXA20, MED_PENTA15, MED_PYRA13, MED_NONE}; + + int i=0; + while (ValuesTypesOfElts[i] != MED_NONE) + { + typesOfElts[i+1]=ValuesTypesOfElts[i]; + ++i; + } + + // ************************** + // Num�rotation des Noeuds + // ************************** + // + // line ( 1er et 2nd Ordre) + i=1; + while ( i!=3 ) { + medVertexOrder[1].push_back(i); + medVertexOrder[8].push_back(i); + ++i; + } + medVertexOrder[8].push_back(3); + + // tria + i=1; + while ( i!=4 ) { + medVertexOrder[2].push_back(i); + medVertexOrder[9].push_back(i); + ++i; + } + medVertexOrder[9].push_back(4); + medVertexOrder[9].push_back(5); + medVertexOrder[9].push_back(6); + + // quad + i=1; + while ( i!=5 ) { + medVertexOrder[3].push_back(i); + medVertexOrder[10].push_back(i); + medVertexOrder[16].push_back(i); + ++i; + } + medVertexOrder[10].push_back(5); + medVertexOrder[16].push_back(5); + medVertexOrder[10].push_back(6); + medVertexOrder[16].push_back(6); + medVertexOrder[10].push_back(7); + medVertexOrder[16].push_back(7); + medVertexOrder[10].push_back(8); + medVertexOrder[16].push_back(8); + + // tetra + static const int OrderforTetra[] = { 1, 3, 2, 4, 0 }; + i=0; + while ( OrderforTetra[i] != 0 ) { + medVertexOrder[4].push_back(OrderforTetra[i]); + medVertexOrder[11].push_back(OrderforTetra[i]); + ++i; + } + static const int OrderforTetra2[] = { 7, 6 , 5, 8 , 9 , 10, 0 }; + i=0; + while ( OrderforTetra2[i] != 0 ) { + medVertexOrder[11].push_back(OrderforTetra2[i]); + ++i; + } + + // hexa + // le 1 MED est le 1er Gmsh, le 2nd Med est le 4ieme Gmsh , le 3 le 6 ... + static const int OrderforHexa[] = { 1, 5, 8, 4, 2, 6, 7, 3, 0}; + i=0; + while (OrderforHexa[i] != 0) + { + medVertexOrder[5].push_back(OrderforHexa[i]); + medVertexOrder[12].push_back(OrderforHexa[i]); + medVertexOrder[17].push_back(OrderforHexa[i]); + ++i; + }; + static const int OrderforHexa2[] = { 11,18,16,10,13,19,15,16,9,17,20,14, 0 }; + i=0; + while ( OrderforHexa2[i] != 0 ) { + medVertexOrder[12].push_back(OrderforHexa2[i]); + medVertexOrder[17].push_back(OrderforHexa2[i]); + ++i; + } + + // Prism + static const int OrderforPrism[] = { 1, 3, 2, 4, 6, 5, 0}; + i=0; + while (OrderforPrism[i] != 0) + { + medVertexOrder[6].push_back(OrderforPrism[i]); + medVertexOrder[13].push_back(OrderforPrism[i]); + medVertexOrder[18].push_back(OrderforPrism[i]); + ++i; + }; + static const int OrderforPrism2[] = { 8, 10, 7, 14, 13, 15, 9, 12, 11, 0}; + i=0; + while ( OrderforPrism2[i] != 0 ) { + medVertexOrder[13].push_back(OrderforPrism2[i]); + medVertexOrder[18].push_back(OrderforPrism2[i]); + ++i; + } + + + //Pyra + static const int OrderforPyra[] = { 1, 4, 3, 2, 5, 0}; + i=0; + while (OrderforPyra[i] != 0) + { + medVertexOrder[7].push_back(OrderforPyra[i]); + medVertexOrder[14].push_back(OrderforPyra[i]); + medVertexOrder[19].push_back(OrderforPyra[i]); + ++i; + }; + static const int OrderforPyra2[] = { 7, 11 ,9 , 6, 8, 13, 12 , 10, 0}; + i=0; + while ( OrderforPyra2[i] != 0 ) { + medVertexOrder[14].push_back(OrderforPyra2[i]); + medVertexOrder[19].push_back(OrderforPyra2[i]); + ++i; + } }; @@ -247,21 +247,21 @@ int MedIO::CreateFamilles( ) numFamilles.insert(0); std::set<int>::const_iterator itFam; for (itFam = numFamilles.begin(); itFam != numFamilles.end(); ++itFam) { - med_err CR; - if (*itFam != 0 ) - { std::ostringstream oss; + med_err CR; + if (*itFam != 0 ) + { std::ostringstream oss; oss << *itFam; std::string fam = "F_" + oss.str(); std::string group = "G_" + oss.str(); - while (group.size() < 80) group = group + " "; + while (group.size() < 80) group = group + " "; CR = MEDfamCr (_fid, (char *) _meshName.c_str(),(char *)fam.c_str(),*itFam, 0,0,0,0,(char *)group.c_str(),1); - CR=0; - } - else - { + CR=0; + } + else + { std::string fam = "Famille0"; CR = MEDfamCr (_fid, (char *) _meshName.c_str(),(char *)fam.c_str(),*itFam, 0,0,0,0,0,0); - } + } if ( CR < 0 ) { Msg(GERROR, "Error in Family Creation '%d'", *itFam ); @@ -284,10 +284,10 @@ int MedIO::CreateElemt() int nbElements = LesConn[typemed].size() / nbNoeudElt; if (nbElements != 0 ) med_err CR = MEDelementsEcr (_fid, (char*) _meshName.c_str(),(med_int) 3, - &LesConn[typemed][0], MED_FULL_INTERLACE, - NULL, MED_FAUX, NULL, MED_FAUX, - &famElts[typemed][0],nbElements, - MED_MAILLE,typemed,MED_NOD); + &LesConn[typemed][0], MED_FULL_INTERLACE, + NULL, MED_FAUX, NULL, MED_FAUX, + &famElts[typemed][0],nbElements, + MED_MAILLE,typemed,MED_NOD); } }; @@ -298,14 +298,14 @@ int MedIO::Ecrit() if (_boolOpen != 1) { Msg(GERROR, "File not Open"); - return 0; + return 0; } int nbNoeuds=coordonnees.size() / 3; if (nbNoeuds != families.size()) { Msg(GERROR, "bad Vectors"); - return 0; + return 0; } // ********************* @@ -325,10 +325,10 @@ int MedIO::Ecrit() char unicoo[3*MED_TAILLE_PNOM+1] = "inconnu inconnu inconnu "; med_err CR = MEDnoeudsEcr(_fid, (char*) _meshName.c_str(),(med_int) 3, - &coordonnees[0], MED_FULL_INTERLACE, MED_CART, - nomcoo,unicoo, NULL, MED_FAUX, - &numOpt[0], MED_VRAI, - &families[0], nbNoeuds); + &coordonnees[0], MED_FULL_INTERLACE, MED_CART, + nomcoo,unicoo, NULL, MED_FAUX, + &numOpt[0], MED_VRAI, + &families[0], nbNoeuds); Msg(INFO, "%d ", CR); if ( CR < 0 ) { diff --git a/Geo/GModelIO_MED.h b/Geo/GModelIO_MED.h index 185a06006b257748c4e9b1fc4f11c45f0f721430..d840c50bf8ffcdfc0e8e44a5a2fef0903fbffc56 100644 --- a/Geo/GModelIO_MED.h +++ b/Geo/GModelIO_MED.h @@ -17,7 +17,7 @@ extern "C" { - #include "med.h" + #include "med.h" } typedef std::map<med_geometrie_element,std::vector<int> > connectivities; @@ -33,15 +33,15 @@ class MedIO ; // class ConversionData { - public : + public : - ConversionData(); + ConversionData(); std::map<int,med_geometrie_element> typesOfElts; std::map<int,std::list<int> > medVertexOrder; - std::map<int,int> familleParDimension; - std::map<int,int> famillefamille; + std::map<int,int> familleParDimension; + std::map<int,int> famillefamille; }; @@ -92,7 +92,7 @@ template <> struct TraiteMaille<GEdge> : public TraiteMailledeBase<GEdge> { static inline void AddElement(const GEdge & ele, MedIO& monDriver) { - RecupereElement (ele.lines, RecupereFamille(ele, 1, monDriver), monDriver); + RecupereElement (ele.lines, RecupereFamille(ele, 1, monDriver), monDriver); } }; @@ -100,8 +100,8 @@ template <> struct TraiteMaille<GFace> : public TraiteMailledeBase<GFace> { static inline void AddElement(const GFace & ele, MedIO& monDriver) { - RecupereElement (ele.triangles, RecupereFamille(ele, 2, monDriver), monDriver); - RecupereElement (ele.quadrangles, RecupereFamille(ele, 2, monDriver), monDriver); + RecupereElement (ele.triangles, RecupereFamille(ele, 2, monDriver), monDriver); + RecupereElement (ele.quadrangles, RecupereFamille(ele, 2, monDriver), monDriver); } }; @@ -109,10 +109,10 @@ template <> struct TraiteMaille<GRegion> : public TraiteMailledeBase<GRegion>{ static inline void AddElement(const GRegion & ele, MedIO & monDriver) { - RecupereElement (ele.tetrahedra, RecupereFamille(ele, 3, monDriver), monDriver ); - RecupereElement (ele.hexahedra, RecupereFamille(ele, 3, monDriver), monDriver); - RecupereElement (ele.prisms, RecupereFamille(ele, 3, monDriver), monDriver); - RecupereElement (ele.pyramids, RecupereFamille(ele, 3, monDriver), monDriver); + RecupereElement (ele.tetrahedra, RecupereFamille(ele, 3, monDriver), monDriver ); + RecupereElement (ele.hexahedra, RecupereFamille(ele, 3, monDriver), monDriver); + RecupereElement (ele.prisms, RecupereFamille(ele, 3, monDriver), monDriver); + RecupereElement (ele.pyramids, RecupereFamille(ele, 3, monDriver), monDriver); } }; @@ -130,7 +130,7 @@ class MedIO MedIO(); int SetFile (const std::string& theFileName); int AddNode (MVertex* const v, const int famille ); - int Ecrit (); + int Ecrit (); int CloseFile (); private : @@ -186,7 +186,7 @@ void TraiteMaille<GVertex>::AddElement(const GVertex & ele, MedIO& monDriver) monDriver.AddNode(ele.mesh_vertices[0],famille); } -// *-*-*-*-*-*-*-*-*-* +// *-*-*-*-*-*-*-*-*-* template<class T> int TraiteMailledeBase<T>::RecupereFamille(const T &ele, const int dimension, MedIO & monDriver) // @@ -204,16 +204,16 @@ template<class T> int TraiteMailledeBase<T>::RecupereFamille(const T &ele, const { if (monDriver.numFamilles.find(famille) == monDriver.numFamilles.end()) { monDriver.numFamilles.insert(famille); - MyConversionData.familleParDimension[famille]=dimension; + MyConversionData.familleParDimension[famille]=dimension; } - else famille=famille-1000; + else famille=famille-1000; } MyConversionData.famillefamille[familleInitiale]=famille; return famille; } -// *-*-*-*-*-*-*-*-*-* +// *-*-*-*-*-*-*-*-*-* template<class T> template<class G> void TraiteMailledeBase<T>::RecupereElement(const std::vector<G*> &ele, const int famille, MedIO& monDriver) @@ -228,16 +228,16 @@ template<class G> void TraiteMailledeBase<T>::RecupereElement(const std::vector< const med_geometrie_element medType= Data::MyConversionData.typesOfElts[type]; for (unsigned int elt = 0; elt < ele.size(); ++elt) { - const int monNum=ele[elt]->getNum(); - for (listIter monIter = Data::MyConversionData.medVertexOrder[type].begin(); - monIter != Data::MyConversionData.medVertexOrder[type].end(); - ++monIter) { - const int NoeudATraiter = *monIter - 1; - const int Noeud = ele[elt]->getVertex(NoeudATraiter)->getNum(); - monDriver.AddNode(ele[elt]->getVertex(NoeudATraiter),0); - monDriver.LesConn[medType].push_back(monDriver.elements[Noeud]); + const int monNum=ele[elt]->getNum(); + for (listIter monIter = Data::MyConversionData.medVertexOrder[type].begin(); + monIter != Data::MyConversionData.medVertexOrder[type].end(); + ++monIter) { + const int NoeudATraiter = *monIter - 1; + const int Noeud = ele[elt]->getVertex(NoeudATraiter)->getNum(); + monDriver.AddNode(ele[elt]->getVertex(NoeudATraiter),0); + monDriver.LesConn[medType].push_back(monDriver.elements[Noeud]); } - monDriver.famElts[medType].push_back(famille); + monDriver.famElts[medType].push_back(famille); } } diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index f6db22a9fbdae7f70d9a8c6babd05069be1a2503..b9ce716527a91969d77301d8b71e251e4076d4ef 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_Mesh.cpp,v 1.43 2008-03-18 19:30:14 geuzaine Exp $ +// $Id: GModelIO_Mesh.cpp,v 1.44 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,7 +45,7 @@ static void addElements(std::vector<T*> &dst, const std::vector<MElement*> &src) } static void storeElementsInEntities(GModel *m, - std::map<int, std::vector<MElement*> > &map) + std::map<int, std::vector<MElement*> > &map) { std::map<int, std::vector<MElement*> >::const_iterator it = map.begin(); for(; it != map.end(); ++it){ @@ -54,36 +54,36 @@ static void storeElementsInEntities(GModel *m, switch(numEdges){ case 1: { - GEdge *e = m->getEdgeByTag(it->first); - if(!e){ - e = new discreteEdge(m, it->first); - m->add(e); - } - addElements(e->lines, it->second); + GEdge *e = m->getEdgeByTag(it->first); + if(!e){ + e = new discreteEdge(m, it->first); + m->add(e); + } + addElements(e->lines, it->second); } break; case 3: case 4: { - GFace *f = m->getFaceByTag(it->first); - if(!f){ - f = new discreteFace(m, it->first); - m->add(f); - } - if(numEdges == 3) addElements(f->triangles, it->second); - else addElements(f->quadrangles, it->second); + GFace *f = m->getFaceByTag(it->first); + if(!f){ + f = new discreteFace(m, it->first); + m->add(f); + } + if(numEdges == 3) addElements(f->triangles, it->second); + else addElements(f->quadrangles, it->second); } break; case 6: case 12: case 9: case 8: { - GRegion *r = m->getRegionByTag(it->first); - if(!r){ - r = new discreteRegion(m, it->first); - m->add(r); - } - if(numEdges == 6) addElements(r->tetrahedra, it->second); - else if(numEdges == 12) addElements(r->hexahedra, it->second); - else if(numEdges == 9) addElements(r->prisms, it->second); - else addElements(r->pyramids, it->second); + GRegion *r = m->getRegionByTag(it->first); + if(!r){ + r = new discreteRegion(m, it->first); + m->add(r); + } + if(numEdges == 6) addElements(r->tetrahedra, it->second); + else if(numEdges == 12) addElements(r->hexahedra, it->second); + else if(numEdges == 9) addElements(r->prisms, it->second); + else addElements(r->pyramids, it->second); } break; } @@ -110,15 +110,15 @@ static void storeVerticesInEntities(std::vector<MVertex*> &vertices) if(v){ // the vector can have null entries (first or last element) GEntity *ge = v->onWhat(); if(ge) - ge->mesh_vertices.push_back(v); + ge->mesh_vertices.push_back(v); else - delete v; // we delete all unused vertices + delete v; // we delete all unused vertices } } } static void storePhysicalTagsInEntities(GModel *m, int dim, - std::map<int, std::map<int, std::string> > &map) + std::map<int, std::map<int, std::string> > &map) { std::map<int, std::map<int, std::string> >::const_iterator it = map.begin(); for(; it != map.end(); ++it){ @@ -132,16 +132,16 @@ static void storePhysicalTagsInEntities(GModel *m, int dim, if(ge){ std::map<int, std::string>::const_iterator it2 = it->second.begin(); for(; it2 != it->second.end(); ++it2){ - if(std::find(ge->physicals.begin(), ge->physicals.end(), it2->first) == - ge->physicals.end()) - ge->physicals.push_back(it2->first); + if(std::find(ge->physicals.begin(), ge->physicals.end(), it2->first) == + ge->physicals.end()) + ge->physicals.push_back(it2->first); } } } } static bool getVertices(int num, int *indices, std::map<int, MVertex*> &map, - std::vector<MVertex*> &vertices) + std::vector<MVertex*> &vertices) { for(int i = 0; i < num; i++){ if(!map.count(indices[i])){ @@ -155,7 +155,7 @@ static bool getVertices(int num, int *indices, std::map<int, MVertex*> &map, } static bool getVertices(int num, int *indices, std::vector<MVertex*> &vec, - std::vector<MVertex*> &vertices) + std::vector<MVertex*> &vertices) { for(int i = 0; i < num; i++){ if(indices[i] < 0 || indices[i] > (int)(vec.size() - 1)){ @@ -206,10 +206,10 @@ static int getNumVerticesForElementTypeMSH(int type) } static void createElementMSH(GModel *m, int num, int type, int physical, - int reg, int part, std::vector<MVertex*> &v, - std::map<int, std::vector<MVertex*> > &points, - std::map<int, std::vector<MElement*> > elem[7], - std::map<int, std::map<int, std::string> > physicals[4]) + int reg, int part, std::vector<MVertex*> &v, + std::map<int, std::vector<MVertex*> > &points, + std::map<int, std::vector<MElement*> > elem[7], + std::map<int, std::map<int, std::string> > physicals[4]) { int dim = 0; @@ -287,14 +287,14 @@ int GModel::readMSH(const std::string &name) int format, size; if(sscanf(str, "%lf %d %d", &version, &format, &size) != 3) return 0; if(format){ - binary = true; - Msg(INFO, "Mesh is in binary format"); - int one; - if(fread(&one, sizeof(int), 1, fp) != 1) return 0; - if(one != 1){ - swap = true; - Msg(INFO, "Swapping bytes from binary file"); - } + binary = true; + Msg(INFO, "Mesh is in binary format"); + int one; + if(fread(&one, sizeof(int), 1, fp) != 1) return 0; + if(one != 1){ + swap = true; + Msg(INFO, "Swapping bytes from binary file"); + } } } @@ -304,11 +304,11 @@ int GModel::readMSH(const std::string &name) int numNames; if(sscanf(str, "%d", &numNames) != 1) return 0; for(int i = 0; i < numNames; i++) { - int num; - if(fscanf(fp, "%d", &num) != 1) return 0; - if(!fgets(str, sizeof(str), fp)) return 0; - std::string name = extractDoubleQuotedString(str, 256); - if(name.size()) setPhysicalName(name, num); + int num; + if(fscanf(fp, "%d", &num) != 1) return 0; + if(!fgets(str, sizeof(str), fp)) return 0; + std::string name = extractDoubleQuotedString(str, 256); + if(name.size()) setPhysicalName(name, num); } } @@ -323,42 +323,42 @@ int GModel::readMSH(const std::string &name) int progress = (numVertices > 100000) ? numVertices / 25 : 0; int minVertex = numVertices + 1, maxVertex = -1; for(int i = 0; i < numVertices; i++) { - int num; - double xyz[3]; - if(!binary){ - if(fscanf(fp, "%d %lf %lf %lf", &num, &xyz[0], &xyz[1], &xyz[2]) != 4) return 0; - } - else{ - if(fread(&num, sizeof(int), 1, fp) != 1) return 0; - if(swap) swapBytes((char*)&num, sizeof(int), 1); - if(fread(xyz, sizeof(double), 3, fp) != 3) return 0; - if(swap) swapBytes((char*)xyz, sizeof(double), 3); - } - minVertex = std::min(minVertex, num); - maxVertex = std::max(maxVertex, num); - if(vertexMap.count(num)) - Msg(WARNING, "Skipping duplicate vertex %d", num); - else - vertexMap[num] = new MVertex(xyz[0], xyz[1], xyz[2], 0, num); - if(progress && (i % progress == progress - 1)) - Msg(PROGRESS, "Read %d vertices", i + 1); + int num; + double xyz[3]; + if(!binary){ + if(fscanf(fp, "%d %lf %lf %lf", &num, &xyz[0], &xyz[1], &xyz[2]) != 4) return 0; + } + else{ + if(fread(&num, sizeof(int), 1, fp) != 1) return 0; + if(swap) swapBytes((char*)&num, sizeof(int), 1); + if(fread(xyz, sizeof(double), 3, fp) != 3) return 0; + if(swap) swapBytes((char*)xyz, sizeof(double), 3); + } + minVertex = std::min(minVertex, num); + maxVertex = std::max(maxVertex, num); + if(vertexMap.count(num)) + Msg(WARNING, "Skipping duplicate vertex %d", num); + else + vertexMap[num] = new MVertex(xyz[0], xyz[1], xyz[2], 0, num); + if(progress && (i % progress == progress - 1)) + Msg(PROGRESS, "Read %d vertices", i + 1); } if(progress) Msg(PROGRESS, ""); // If the vertex numbering is dense, tranfer the map into a // vector to speed up element creation if((int)vertexMap.size() == numVertices && - ((minVertex == 1 && maxVertex == numVertices) || - (minVertex == 0 && maxVertex == numVertices - 1))){ - Msg(INFO, "Vertex numbering is dense"); - vertexVector.resize(vertexMap.size() + 1); - if(minVertex == 1) - vertexVector[0] = 0; - else - vertexVector[numVertices] = 0; - std::map<int, MVertex*>::const_iterator it = vertexMap.begin(); - for(; it != vertexMap.end(); ++it) - vertexVector[it->first] = it->second; - vertexMap.clear(); + ((minVertex == 1 && maxVertex == numVertices) || + (minVertex == 0 && maxVertex == numVertices - 1))){ + Msg(INFO, "Vertex numbering is dense"); + vertexVector.resize(vertexMap.size() + 1); + if(minVertex == 1) + vertexVector[0] = 0; + else + vertexVector[numVertices] = 0; + std::map<int, MVertex*>::const_iterator it = vertexMap.begin(); + for(; it != vertexMap.end(); ++it) + vertexVector[it->first] = it->second; + vertexMap.clear(); } } @@ -370,75 +370,75 @@ int GModel::readMSH(const std::string &name) Msg(INFO, "%d elements", numElements); int progress = (numElements > 100000) ? numElements / 25 : 0; if(!binary){ - for(int i = 0; i < numElements; i++) { - int num, type, physical = 0, elementary = 0, partition = 0, numVertices; - if(version <= 1.0){ - fscanf(fp, "%d %d %d %d %d", &num, &type, &physical, &elementary, &numVertices); - if(numVertices != getNumVerticesForElementTypeMSH(type)) return 0; - } - else{ - int numTags; - fscanf(fp, "%d %d %d", &num, &type, &numTags); - for(int j = 0; j < numTags; j++){ - int tag; - fscanf(fp, "%d", &tag); - if(j == 0) physical = tag; - else if(j == 1) elementary = tag; - else if(j == 2) partition = tag; - // ignore any other tags for now - } - if(!(numVertices = getNumVerticesForElementTypeMSH(type))) return 0; - } - int indices[30]; - for(int j = 0; j < numVertices; j++) fscanf(fp, "%d", &indices[j]); - std::vector<MVertex*> vertices; - if(vertexVector.size()){ - if(!getVertices(numVertices, indices, vertexVector, vertices)) return 0; - } - else{ - if(!getVertices(numVertices, indices, vertexMap, vertices)) return 0; - } - createElementMSH(this, num, type, physical, elementary, partition, - vertices, points, elements, physicals); - if(progress && (i % progress == progress - 1)) - Msg(PROGRESS, "Read %d elements", i + 1); - } + for(int i = 0; i < numElements; i++) { + int num, type, physical = 0, elementary = 0, partition = 0, numVertices; + if(version <= 1.0){ + fscanf(fp, "%d %d %d %d %d", &num, &type, &physical, &elementary, &numVertices); + if(numVertices != getNumVerticesForElementTypeMSH(type)) return 0; + } + else{ + int numTags; + fscanf(fp, "%d %d %d", &num, &type, &numTags); + for(int j = 0; j < numTags; j++){ + int tag; + fscanf(fp, "%d", &tag); + if(j == 0) physical = tag; + else if(j == 1) elementary = tag; + else if(j == 2) partition = tag; + // ignore any other tags for now + } + if(!(numVertices = getNumVerticesForElementTypeMSH(type))) return 0; + } + int indices[30]; + for(int j = 0; j < numVertices; j++) fscanf(fp, "%d", &indices[j]); + std::vector<MVertex*> vertices; + if(vertexVector.size()){ + if(!getVertices(numVertices, indices, vertexVector, vertices)) return 0; + } + else{ + if(!getVertices(numVertices, indices, vertexMap, vertices)) return 0; + } + createElementMSH(this, num, type, physical, elementary, partition, + vertices, points, elements, physicals); + if(progress && (i % progress == progress - 1)) + Msg(PROGRESS, "Read %d elements", i + 1); + } } else{ - int numElementsPartial = 0; - while(numElementsPartial < numElements){ - int header[3]; - if(fread(header, sizeof(int), 3, fp) != 3) return 0; - if(swap) swapBytes((char*)header, sizeof(int), 3); - int type = header[0]; - int numElms = header[1]; - int numTags = header[2]; - int numVertices = getNumVerticesForElementTypeMSH(type); - unsigned int n = 1 + numTags + numVertices; - int *data = new int[n]; - for(int i = 0; i < numElms; i++) { - if(fread(data, sizeof(int), n, fp) != n) return 0; - if(swap) swapBytes((char*)data, sizeof(int), n); - int num = data[0]; - int physical = (numTags > 0) ? data[4 - numTags] : 0; - int elementary = (numTags > 1) ? data[4 - numTags + 1] : 0; - int partition = (numTags > 2) ? data[4 - numTags + 2] : 0; - int *indices = &data[numTags + 1]; - std::vector<MVertex*> vertices; - if(vertexVector.size()){ - if(!getVertices(numVertices, indices, vertexVector, vertices)) return 0; - } - else{ - if(!getVertices(numVertices, indices, vertexMap, vertices)) return 0; - } - createElementMSH(this, num, type, physical, elementary, partition, - vertices, points, elements, physicals); - if(progress && ((numElementsPartial + i) % progress == progress - 1)) - Msg(PROGRESS, "Read %d elements", i + 1); - } - delete [] data; - numElementsPartial += numElms; - } + int numElementsPartial = 0; + while(numElementsPartial < numElements){ + int header[3]; + if(fread(header, sizeof(int), 3, fp) != 3) return 0; + if(swap) swapBytes((char*)header, sizeof(int), 3); + int type = header[0]; + int numElms = header[1]; + int numTags = header[2]; + int numVertices = getNumVerticesForElementTypeMSH(type); + unsigned int n = 1 + numTags + numVertices; + int *data = new int[n]; + for(int i = 0; i < numElms; i++) { + if(fread(data, sizeof(int), n, fp) != n) return 0; + if(swap) swapBytes((char*)data, sizeof(int), n); + int num = data[0]; + int physical = (numTags > 0) ? data[4 - numTags] : 0; + int elementary = (numTags > 1) ? data[4 - numTags + 1] : 0; + int partition = (numTags > 2) ? data[4 - numTags + 2] : 0; + int *indices = &data[numTags + 1]; + std::vector<MVertex*> vertices; + if(vertexVector.size()){ + if(!getVertices(numVertices, indices, vertexVector, vertices)) return 0; + } + else{ + if(!getVertices(numVertices, indices, vertexMap, vertices)) return 0; + } + createElementMSH(this, num, type, physical, elementary, partition, + vertices, points, elements, physicals); + if(progress && ((numElementsPartial + i) % progress == progress - 1)) + Msg(PROGRESS, "Read %d elements", i + 1); + } + delete [] data; + numElementsPartial += numElms; + } } if(progress) Msg(PROGRESS, ""); @@ -448,9 +448,9 @@ int GModel::readMSH(const std::string &name) // there's some nodal post-processing data to read later on, so // cache the vertex indexing data if(vertexVector.size()) - _vertexVectorCache = vertexVector; + _vertexVectorCache = vertexVector; else - _vertexMapCache = vertexMap; + _vertexMapCache = vertexMap; postpro = true; break; @@ -465,7 +465,7 @@ int GModel::readMSH(const std::string &name) do { if(!fgets(str, sizeof(str), fp) || feof(fp)) - Msg(GERROR, "Prematured end of mesh file"); + Msg(GERROR, "Prematured end of mesh file"); } while(str[0] != '$'); } @@ -486,7 +486,7 @@ int GModel::readMSH(const std::string &name) if(v) points[v->getNum()].push_back(v); } for(std::map<int, MVertex*>::iterator it = vertexMap.begin(); - it != vertexMap.end(); ++it) + it != vertexMap.end(); ++it) points[it->second->getNum()].push_back(it->second); } @@ -526,8 +526,8 @@ int GModel::readMSH(const std::string &name) } static void writeElementHeaderMSH(bool binary, FILE *fp, std::map<int,int> &elements, - int t1, int t2=0, int t3=0, int t4=0, - int t5=0, int t6=0, int t7=0, int t8=0) + int t1, int t2=0, int t3=0, int t4=0, + int t5=0, int t6=0, int t7=0, int t8=0) { if(!binary) return; @@ -569,19 +569,19 @@ static void writeElementHeaderMSH(bool binary, FILE *fp, std::map<int,int> &elem template<class T> static void writeElementsMSH(FILE *fp, const std::vector<T*> &ele, int saveAll, - double version, bool binary, int &num, int elementary, - std::vector<int> &physicals) + double version, bool binary, int &num, int elementary, + std::vector<int> &physicals) { for(unsigned int i = 0; i < ele.size(); i++) if(saveAll) ele[i]->writeMSH(fp, version, binary, ++num, elementary, 0); else for(unsigned int j = 0; j < physicals.size(); j++) - ele[i]->writeMSH(fp, version, binary, ++num, elementary, physicals[j]); + ele[i]->writeMSH(fp, version, binary, ++num, elementary, physicals[j]); } int GModel::writeMSH(const std::string &name, double version, bool binary, - bool saveAll, double scalingFactor) + bool saveAll, double scalingFactor) { FILE *fp = fopen(name.c_str(), binary ? "wb" : "w"); if(!fp){ @@ -651,7 +651,7 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, fprintf(fp, "$PhysicalNames\n"); fprintf(fp, "%d\n", numPhysicalNames()); for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++) - fprintf(fp, "%d \"%s\"\n", it->first, it->second.c_str()); + fprintf(fp, "%d \"%s\"\n", it->first, it->second.c_str()); fprintf(fp, "$EndPhysicalNames\n"); } @@ -691,36 +691,36 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, writeElementHeaderMSH(binary, fp, elements, MSH_PNT); for(viter it = firstVertex(); it != lastVertex(); ++it) writeElementsMSH(fp, (*it)->mesh_vertices, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_LIN_2, MSH_LIN_3, MSH_LIN_4, MSH_LIN_5); for(eiter it = firstEdge(); it != lastEdge(); ++it) writeElementsMSH(fp, (*it)->lines, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_TRI_3, MSH_TRI_6, MSH_TRI_9, - MSH_TRI_10, MSH_TRI_12, MSH_TRI_15, MSH_TRI_15I, MSH_TRI_21); + MSH_TRI_10, MSH_TRI_12, MSH_TRI_15, MSH_TRI_15I, MSH_TRI_21); for(fiter it = firstFace(); it != lastFace(); ++it) writeElementsMSH(fp, (*it)->triangles, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_QUA_4, MSH_QUA_9, MSH_QUA_8); for(fiter it = firstFace(); it != lastFace(); ++it) writeElementsMSH(fp, (*it)->quadrangles, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_TET_4, MSH_TET_10); for(riter it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, (*it)->tetrahedra, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_HEX_8, MSH_HEX_27, MSH_HEX_20); for(riter it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, (*it)->hexahedra, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_PRI_6, MSH_PRI_18, MSH_PRI_15); for(riter it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, (*it)->prisms, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); writeElementHeaderMSH(binary, fp, elements, MSH_PYR_5, MSH_PYR_14, MSH_PYR_13); for(riter it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, (*it)->pyramids, saveAll, version, binary, num, - (*it)->tag(), (*it)->physicals); + (*it)->tag(), (*it)->physicals); if(binary) fprintf(fp, "\n"); @@ -736,8 +736,8 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, } int GModel::writePOS(const std::string &name, bool printElementary, - bool printElementNumber, bool printGamma, bool printEta, - bool printRho, bool saveAll, double scalingFactor) + bool printElementNumber, bool printGamma, bool printEta, + bool printRho, bool saveAll, double scalingFactor) { FILE *fp = fopen(name.c_str(), "w"); if(!fp){ @@ -780,36 +780,36 @@ int GModel::writePOS(const std::string &name, bool printElementary, for(eiter it = firstEdge(); it != lastEdge(); ++it) { if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->lines.size(); i++) - (*it)->lines[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->lines[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); } } for(fiter it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->triangles[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->triangles[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - (*it)->quadrangles[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->quadrangles[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); } } for(riter it = firstRegion(); it != lastRegion(); ++it) { if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) - (*it)->tetrahedra[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->tetrahedra[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) - (*it)->hexahedra[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->hexahedra[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); for(unsigned int i = 0; i < (*it)->prisms.size(); i++) - (*it)->prisms[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->prisms[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) - (*it)->pyramids[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], - scalingFactor, (*it)->tag()); + (*it)->pyramids[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); } } @@ -848,11 +848,11 @@ int GModel::readSTL(const std::string &name, double tolerance) if(!fgets(buffer, sizeof(buffer), fp)) break; // "vertex x y z" for(int i = 0; i < 3; i++){ - if(!fgets(buffer, sizeof(buffer), fp)) break; - sscanf(buffer, "%s %f %f %f", s1, &x, &y, &z); - SPoint3 p(x, y, z); - points.push_back(p); - bbox += p; + if(!fgets(buffer, sizeof(buffer), fp)) break; + sscanf(buffer, "%s %f %f %f", s1, &x, &y, &z); + SPoint3 p(x, y, z); + points.push_back(p); + bbox += p; } // "endloop" if(!fgets(buffer, sizeof(buffer), fp)) break; @@ -870,25 +870,25 @@ int GModel::readSTL(const std::string &name, double tolerance) size_t ret = fread(&nfacets, sizeof(unsigned int), 1, fp); bool swap = false; if(nfacets > 10000000){ - Msg(INFO, "Swapping bytes from binary file"); - swap = true; - swapBytes((char*)&nfacets, sizeof(unsigned int), 1); + Msg(INFO, "Swapping bytes from binary file"); + swap = true; + swapBytes((char*)&nfacets, sizeof(unsigned int), 1); } if(ret && nfacets){ - char *data = new char[nfacets * 50 * sizeof(char)]; - ret = fread(data, sizeof(char), nfacets * 50, fp); - if(ret == nfacets * 50){ - for(unsigned int i = 0; i < nfacets; i++) { - float *xyz = (float *)&data[i * 50 * sizeof(char)]; - if(swap) swapBytes((char*)xyz, sizeof(float), 12); - for(int j = 0; j < 3; j++){ - SPoint3 p(xyz[3 + 3 * j], xyz[3 + 3 * j + 1], xyz[3 + 3 * j + 2]); - points.push_back(p); - bbox += p; - } - } - } - delete data; + char *data = new char[nfacets * 50 * sizeof(char)]; + ret = fread(data, sizeof(char), nfacets * 50, fp); + if(ret == nfacets * 50){ + for(unsigned int i = 0; i < nfacets; i++) { + float *xyz = (float *)&data[i * 50 * sizeof(char)]; + if(swap) swapBytes((char*)xyz, sizeof(float), 12); + for(int j = 0; j < 3; j++){ + SPoint3 p(xyz[3 + 3 * j], xyz[3 + 3 * j + 1], xyz[3 + 3 * j + 2]); + points.push_back(p); + bbox += p; + } + } + } + delete data; } } } @@ -924,8 +924,8 @@ int GModel::readSTL(const std::string &name, double tolerance) } else { v[j] = new MVertex(x, y, z, face); - vertices.insert(v[j]); - face->mesh_vertices.push_back(v[j]); + vertices.insert(v[j]); + face->mesh_vertices.push_back(v[j]); } } face->triangles.push_back(new MTriangle(v[0], v[1], v[2])); @@ -936,7 +936,7 @@ int GModel::readSTL(const std::string &name, double tolerance) } int GModel::writeSTL(const std::string &name, bool binary, bool saveAll, - double scalingFactor) + double scalingFactor) { FILE *fp = fopen(name.c_str(), binary ? "wb" : "w"); if(!fp){ @@ -956,7 +956,7 @@ int GModel::writeSTL(const std::string &name, bool binary, bool saveAll, unsigned int nfacets = 0; for(fiter it = firstFace(); it != lastFace(); ++it){ if(saveAll || (*it)->physicals.size()){ - nfacets += (*it)->triangles.size() + 2 * (*it)->quadrangles.size(); + nfacets += (*it)->triangles.size() + 2 * (*it)->quadrangles.size(); } } fwrite(&nfacets, sizeof(unsigned int), 1, fp); @@ -965,9 +965,9 @@ int GModel::writeSTL(const std::string &name, bool binary, bool saveAll, for(fiter it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->triangles[i]->writeSTL(fp, binary, scalingFactor); + (*it)->triangles[i]->writeSTL(fp, binary, scalingFactor); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - (*it)->quadrangles[i]->writeSTL(fp, binary, scalingFactor); + (*it)->quadrangles[i]->writeSTL(fp, binary, scalingFactor); } } @@ -996,7 +996,7 @@ static int skipUntil(FILE *fp, const char *key) } static int readVerticesVRML(FILE *fp, std::vector<MVertex*> &vertexVector, - std::vector<MVertex*> &allVertexVector) + std::vector<MVertex*> &allVertexVector) { double x, y, z; if(fscanf(fp, "%lf %lf %lf", &x, &y, &z) != 3) return 0; @@ -1010,8 +1010,8 @@ static int readVerticesVRML(FILE *fp, std::vector<MVertex*> &vertexVector, } static int readElementsVRML(FILE *fp, std::vector<MVertex*> &vertexVector, int region, - std::map<int, std::vector<MElement*> > elements[3], - bool strips=false) + std::map<int, std::vector<MElement*> > elements[3], + bool strips=false) { int i; std::vector<int> idx; @@ -1039,32 +1039,32 @@ static int readElementsVRML(FILE *fp, std::vector<MVertex*> &vertexVector, int r if(!getVertices(idx.size(), &idx[0], vertexVector, vertices)) return 0; idx.clear(); if(vertices.size() < 2){ - Msg(INFO, "Skipping %d-vertex element", (int)vertices.size()); + Msg(INFO, "Skipping %d-vertex element", (int)vertices.size()); } else if(vertices.size() == 2){ - elements[0][region].push_back(new MLine(vertices)); + elements[0][region].push_back(new MLine(vertices)); } else if(vertices.size() == 3){ - elements[1][region].push_back(new MTriangle(vertices)); + elements[1][region].push_back(new MTriangle(vertices)); } else if(!strips && vertices.size() == 4){ - elements[2][region].push_back(new MQuadrangle(vertices)); + elements[2][region].push_back(new MQuadrangle(vertices)); } else if(strips){ // triangle strip - for(unsigned int j = 2; j < vertices.size(); j++){ - if(j % 2) - elements[1][region].push_back - (new MTriangle(vertices[j], vertices[j - 1], vertices[j - 2])); - else - elements[1][region].push_back - (new MTriangle(vertices[j - 2], vertices[j - 1], vertices[j])); - } + for(unsigned int j = 2; j < vertices.size(); j++){ + if(j % 2) + elements[1][region].push_back + (new MTriangle(vertices[j], vertices[j - 1], vertices[j - 2])); + else + elements[1][region].push_back + (new MTriangle(vertices[j - 2], vertices[j - 1], vertices[j])); + } } else{ // import polygon as triangle fan - for(unsigned int j = 2; j < vertices.size(); j++){ - elements[1][region].push_back - (new MTriangle(vertices[0], vertices[j-1], vertices[j])); - } + for(unsigned int j = 2; j < vertices.size(); j++){ + elements[1][region].push_back + (new MTriangle(vertices[0], vertices[j-1], vertices[j])); + } } } } @@ -1097,43 +1097,43 @@ int GModel::readVRML(const std::string &name) if(buffer[0] != '#'){ // skip comments sscanf(buffer, "%s", str); if(!strcmp(str, "Coordinate3")){ - vertexVector.clear(); - if(!skipUntil(fp, "point")) break; - if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; + vertexVector.clear(); + if(!skipUntil(fp, "point")) break; + if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; } else if(!strcmp(str, "coord")){ - vertexVector.clear(); - if(!skipUntil(fp, "point")) break; - if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; - if(!skipUntil(fp, "coordIndex")) break; - if(!readElementsVRML(fp, vertexVector, region, elements, true)) break; + vertexVector.clear(); + if(!skipUntil(fp, "point")) break; + if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; + if(!skipUntil(fp, "coordIndex")) break; + if(!readElementsVRML(fp, vertexVector, region, elements, true)) break; } else if(!strcmp(str, "IndexedTriangleStripSet")){ - region++; - vertexVector.clear(); - if(!skipUntil(fp, "vertex")) break; - if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; - if(!skipUntil(fp, "coordIndex")) break; - if(!readElementsVRML(fp, vertexVector, region, elements, true)) break; + region++; + vertexVector.clear(); + if(!skipUntil(fp, "vertex")) break; + if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; + if(!skipUntil(fp, "coordIndex")) break; + if(!readElementsVRML(fp, vertexVector, region, elements, true)) break; } else if(!strcmp(str, "IndexedFaceSet") || !strcmp(str, "IndexedLineSet")){ - region++; - if(!skipUntil(fp, "coordIndex")) break; - if(!readElementsVRML(fp, vertexVector, region, elements)) break; + region++; + if(!skipUntil(fp, "coordIndex")) break; + if(!readElementsVRML(fp, vertexVector, region, elements)) break; } else if(!strcmp(str, "DEF")){ - char str1[256], str2[256]; - if(!sscanf(buffer, "%s %s %s", str1, str2, str)) break; - if(!strcmp(str, "Coordinate")){ - vertexVector.clear(); - if(!skipUntil(fp, "point")) break; - if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; - } - else if(!strcmp(str, "IndexedFaceSet") || !strcmp(str, "IndexedLineSet")){ - region++; - if(!skipUntil(fp, "coordIndex")) break; - if(!readElementsVRML(fp, vertexVector, region, elements)) break; - } + char str1[256], str2[256]; + if(!sscanf(buffer, "%s %s %s", str1, str2, str)) break; + if(!strcmp(str, "Coordinate")){ + vertexVector.clear(); + if(!skipUntil(fp, "point")) break; + if(!readVerticesVRML(fp, vertexVector, allVertexVector)) break; + } + else if(!strcmp(str, "IndexedFaceSet") || !strcmp(str, "IndexedLineSet")){ + region++; + if(!skipUntil(fp, "coordIndex")) break; + if(!readElementsVRML(fp, vertexVector, region, elements)) break; + } } } } @@ -1182,7 +1182,7 @@ int GModel::writeVRML(const std::string &name, bool saveAll, double scalingFacto fprintf(fp, "DEF Curve%d IndexedLineSet {\n", (*it)->tag()); fprintf(fp, " coordIndex [\n"); for(unsigned int i = 0; i < (*it)->lines.size(); i++) - (*it)->lines[i]->writeVRML(fp); + (*it)->lines[i]->writeVRML(fp); fprintf(fp, " ]\n"); fprintf(fp, "}\n"); } @@ -1193,9 +1193,9 @@ int GModel::writeVRML(const std::string &name, bool saveAll, double scalingFacto fprintf(fp, "DEF Surface%d IndexedFaceSet {\n", (*it)->tag()); fprintf(fp, " coordIndex [\n"); for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->triangles[i]->writeVRML(fp); + (*it)->triangles[i]->writeVRML(fp); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - (*it)->quadrangles[i]->writeVRML(fp); + (*it)->quadrangles[i]->writeVRML(fp); fprintf(fp, " ]\n"); fprintf(fp, "}\n"); } @@ -1223,120 +1223,120 @@ int GModel::readUNV(const std::string &name) if(!strncmp(buffer, " -1", 6)){ if(!fgets(buffer, sizeof(buffer), fp)) break; if(!strncmp(buffer, " -1", 6)) - if(!fgets(buffer, sizeof(buffer), fp)) break; + if(!fgets(buffer, sizeof(buffer), fp)) break; int record = 0; sscanf(buffer, "%d", &record); if(record == 2411){ // nodes - while(fgets(buffer, sizeof(buffer), fp)){ - if(!strncmp(buffer, " -1", 6)) break; - int num, dum; - if(sscanf(buffer, "%d %d %d %d", &num, &dum, &dum, &dum) != 4) break; - if(!fgets(buffer, sizeof(buffer), fp)) break; - double x, y, z; - for(unsigned int i = 0; i < strlen(buffer); i++) - if(buffer[i] == 'D') buffer[i] = 'E'; - if(sscanf(buffer, "%lf %lf %lf", &x, &y, &z) != 3) break; - vertexMap[num] = new MVertex(x, y, z, 0, num); - } + while(fgets(buffer, sizeof(buffer), fp)){ + if(!strncmp(buffer, " -1", 6)) break; + int num, dum; + if(sscanf(buffer, "%d %d %d %d", &num, &dum, &dum, &dum) != 4) break; + if(!fgets(buffer, sizeof(buffer), fp)) break; + double x, y, z; + for(unsigned int i = 0; i < strlen(buffer); i++) + if(buffer[i] == 'D') buffer[i] = 'E'; + if(sscanf(buffer, "%lf %lf %lf", &x, &y, &z) != 3) break; + vertexMap[num] = new MVertex(x, y, z, 0, num); + } } else if(record == 2412){ // elements - while(fgets(buffer, sizeof(buffer), fp)){ - if(strlen(buffer) < 3) continue; // possible line ending after last fscanf - if(!strncmp(buffer, " -1", 6)) break; - int num, type, elementary, physical, color, numNodes; - if(sscanf(buffer, "%d %d %d %d %d %d", &num, &type, &elementary, &physical, - &color, &numNodes) != 6) break; - if(elementary < 0) elementary = 1; - if(physical < 0) physical = 0; - switch(type){ - case 11: case 21: case 22: case 31: - case 23: case 24: case 32: - // beam elements - if(!fgets(buffer, sizeof(buffer), fp)) break; - int dum; - if(sscanf(buffer, "%d %d %d", &dum, &dum, &dum) != 3) break; - break; - } - int n[30]; - for(int i = 0; i < numNodes; i++) if(!fscanf(fp, "%d", &n[i])) return 0; - std::vector<MVertex*> vertices; - if(!getVertices(numNodes, n, vertexMap, vertices)) return 0; - - int dim = -1; - switch(type){ - case 11: case 21: case 22: case 31: - elements[0][elementary].push_back(new MLine(vertices, num)); - dim = 1; - break; - case 23: case 24: case 32: - elements[0][elementary].push_back - (new MLine3(vertices[0], vertices[2], vertices[1], num)); - dim = 1; - break; - case 41: case 51: case 61: case 74: case 81: case 91: - elements[1][elementary].push_back(new MTriangle(vertices, num)); - dim = 2; - break; - case 42: case 52: case 62: case 72: case 82: case 92: - elements[1][elementary].push_back - (new MTriangle6(vertices[0], vertices[2], vertices[4], vertices[1], - vertices[3], vertices[5], num)); - dim = 2; - break; - case 44: case 54: case 64: case 71: case 84: case 94: - elements[2][elementary].push_back(new MQuadrangle(vertices, num)); - dim = 2; - break; - case 45: case 55: case 65: case 75: case 85: case 95: - elements[2][elementary].push_back - (new MQuadrangle8(vertices[0], vertices[2], vertices[4], vertices[6], - vertices[1], vertices[3], vertices[5], vertices[7], - num)); - dim = 2; - break; - case 111: - elements[3][elementary].push_back(new MTetrahedron(vertices, num)); - dim = 3; - break; - case 118: - elements[3][elementary].push_back - (new MTetrahedron10(vertices[0], vertices[2], vertices[4], vertices[9], - vertices[1], vertices[3], vertices[5], vertices[8], - vertices[6], vertices[7], num)); - dim = 3; - break; - case 104: case 115: - elements[4][elementary].push_back(new MHexahedron(vertices, num)); - dim = 3; - break; - case 105: case 116: - elements[4][elementary].push_back - (new MHexahedron20(vertices[0], vertices[2], vertices[4], vertices[6], - vertices[12], vertices[14], vertices[16], vertices[18], - vertices[1], vertices[7], vertices[8], vertices[3], - vertices[9], vertices[5], vertices[10], vertices[11], - vertices[13], vertices[19], vertices[15], vertices[17], - num)); - dim = 3; - break; - case 101: case 112: - elements[5][elementary].push_back(new MPrism(vertices, num)); - dim = 3; - break; - case 102: case 113: - elements[5][elementary].push_back - (new MPrism15(vertices[0], vertices[2], vertices[4], vertices[9], - vertices[11], vertices[13], vertices[1], vertices[5], - vertices[6], vertices[3], vertices[7], vertices[8], - vertices[10], vertices[14], vertices[12], num)); - dim = 3; - break; - } + while(fgets(buffer, sizeof(buffer), fp)){ + if(strlen(buffer) < 3) continue; // possible line ending after last fscanf + if(!strncmp(buffer, " -1", 6)) break; + int num, type, elementary, physical, color, numNodes; + if(sscanf(buffer, "%d %d %d %d %d %d", &num, &type, &elementary, &physical, + &color, &numNodes) != 6) break; + if(elementary < 0) elementary = 1; + if(physical < 0) physical = 0; + switch(type){ + case 11: case 21: case 22: case 31: + case 23: case 24: case 32: + // beam elements + if(!fgets(buffer, sizeof(buffer), fp)) break; + int dum; + if(sscanf(buffer, "%d %d %d", &dum, &dum, &dum) != 3) break; + break; + } + int n[30]; + for(int i = 0; i < numNodes; i++) if(!fscanf(fp, "%d", &n[i])) return 0; + std::vector<MVertex*> vertices; + if(!getVertices(numNodes, n, vertexMap, vertices)) return 0; + + int dim = -1; + switch(type){ + case 11: case 21: case 22: case 31: + elements[0][elementary].push_back(new MLine(vertices, num)); + dim = 1; + break; + case 23: case 24: case 32: + elements[0][elementary].push_back + (new MLine3(vertices[0], vertices[2], vertices[1], num)); + dim = 1; + break; + case 41: case 51: case 61: case 74: case 81: case 91: + elements[1][elementary].push_back(new MTriangle(vertices, num)); + dim = 2; + break; + case 42: case 52: case 62: case 72: case 82: case 92: + elements[1][elementary].push_back + (new MTriangle6(vertices[0], vertices[2], vertices[4], vertices[1], + vertices[3], vertices[5], num)); + dim = 2; + break; + case 44: case 54: case 64: case 71: case 84: case 94: + elements[2][elementary].push_back(new MQuadrangle(vertices, num)); + dim = 2; + break; + case 45: case 55: case 65: case 75: case 85: case 95: + elements[2][elementary].push_back + (new MQuadrangle8(vertices[0], vertices[2], vertices[4], vertices[6], + vertices[1], vertices[3], vertices[5], vertices[7], + num)); + dim = 2; + break; + case 111: + elements[3][elementary].push_back(new MTetrahedron(vertices, num)); + dim = 3; + break; + case 118: + elements[3][elementary].push_back + (new MTetrahedron10(vertices[0], vertices[2], vertices[4], vertices[9], + vertices[1], vertices[3], vertices[5], vertices[8], + vertices[6], vertices[7], num)); + dim = 3; + break; + case 104: case 115: + elements[4][elementary].push_back(new MHexahedron(vertices, num)); + dim = 3; + break; + case 105: case 116: + elements[4][elementary].push_back + (new MHexahedron20(vertices[0], vertices[2], vertices[4], vertices[6], + vertices[12], vertices[14], vertices[16], vertices[18], + vertices[1], vertices[7], vertices[8], vertices[3], + vertices[9], vertices[5], vertices[10], vertices[11], + vertices[13], vertices[19], vertices[15], vertices[17], + num)); + dim = 3; + break; + case 101: case 112: + elements[5][elementary].push_back(new MPrism(vertices, num)); + dim = 3; + break; + case 102: case 113: + elements[5][elementary].push_back + (new MPrism15(vertices[0], vertices[2], vertices[4], vertices[9], + vertices[11], vertices[13], vertices[1], vertices[5], + vertices[6], vertices[3], vertices[7], vertices[8], + vertices[10], vertices[14], vertices[12], num)); + dim = 3; + break; + } - if(dim >= 0 && physical && (!physicals[dim].count(elementary) || - !physicals[dim][elementary].count(physical))) - physicals[dim][elementary][physical] = "unnamed"; - } + if(dim >= 0 && physical && (!physicals[dim].count(elementary) || + !physicals[dim][elementary].count(physical))) + physicals[dim][elementary][physical] = "unnamed"; + } } } } @@ -1354,18 +1354,18 @@ int GModel::readUNV(const std::string &name) template<class T> static void writeElementsUNV(FILE *fp, const std::vector<T*> &ele, int saveAll, - int &num, int elementary, std::vector<int> &physicals) + int &num, int elementary, std::vector<int> &physicals) { for(unsigned int i = 0; i < ele.size(); i++) if(saveAll) ele[i]->writeUNV(fp, ++num, elementary, 0); else for(unsigned int j = 0; j < physicals.size(); j++) - ele[i]->writeUNV(fp, ++num, elementary, physicals[j]); + ele[i]->writeUNV(fp, ++num, elementary, physicals[j]); } int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNodes, - double scalingFactor) + double scalingFactor) { FILE *fp = fopen(name.c_str(), "w"); if(!fp){ @@ -1421,53 +1421,53 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod int gr = 1; for(int dim = 1; dim <= 3; dim++){ for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin(); - it != groups[dim].end(); it++){ - std::set<MVertex*> nodes; - for(unsigned int i = 0; i < it->second.size(); i++){ - if(dim == 1){ - GEdge *ge = (GEdge*)it->second[i]; - for(unsigned int j = 0; j < ge->lines.size(); j++) - for(int k = 0; k < ge->lines[j]->getNumVertices(); k++) - nodes.insert(ge->lines[j]->getVertex(k)); - } - else if(dim == 2){ - GFace *gf = (GFace*)it->second[i]; - for(unsigned int j = 0; j < gf->triangles.size(); j++) - for(int k = 0; k < gf->triangles[j]->getNumVertices(); k++) - nodes.insert(gf->triangles[j]->getVertex(k)); - for(unsigned int j = 0; j < gf->quadrangles.size(); j++) - for(int k = 0; k < gf->quadrangles[j]->getNumVertices(); k++) - nodes.insert(gf->quadrangles[j]->getVertex(k)); - } - else if(dim == 3){ - GRegion *gr = (GRegion*)it->second[i]; - for(unsigned int j = 0; j < gr->tetrahedra.size(); j++) - for(int k = 0; k < gr->tetrahedra[j]->getNumVertices(); k++) - nodes.insert(gr->tetrahedra[j]->getVertex(k)); - for(unsigned int j = 0; j < gr->hexahedra.size(); j++) - for(int k = 0; k < gr->hexahedra[j]->getNumVertices(); k++) - nodes.insert(gr->hexahedra[j]->getVertex(k)); - for(unsigned int j = 0; j < gr->prisms.size(); j++) - for(int k = 0; k < gr->prisms[j]->getNumVertices(); k++) - nodes.insert(gr->prisms[j]->getVertex(k)); - for(unsigned int j = 0; j < gr->pyramids.size(); j++) - for(int k = 0; k < gr->pyramids[j]->getNumVertices(); k++) - nodes.insert(gr->pyramids[j]->getVertex(k)); - } - } - fprintf(fp, "%10d%10d%10d%10d%10d%10d%10d%10d\n", - gr, 0, 0, 0, 0, 0, 0, (int)nodes.size()); - fprintf(fp, "PERMENENT GROUP%d\n", gr++); - int row = 0; - for(std::set<MVertex*>::iterator it2 = nodes.begin(); it2 != nodes.end(); it2++){ - if(row == 2) { - fprintf(fp, "\n"); - row = 0; - } - fprintf(fp, "%10d%10d%10d%10d", 7, (*it2)->getNum(), 0, 0); - row++; - } - fprintf(fp, "\n"); + it != groups[dim].end(); it++){ + std::set<MVertex*> nodes; + for(unsigned int i = 0; i < it->second.size(); i++){ + if(dim == 1){ + GEdge *ge = (GEdge*)it->second[i]; + for(unsigned int j = 0; j < ge->lines.size(); j++) + for(int k = 0; k < ge->lines[j]->getNumVertices(); k++) + nodes.insert(ge->lines[j]->getVertex(k)); + } + else if(dim == 2){ + GFace *gf = (GFace*)it->second[i]; + for(unsigned int j = 0; j < gf->triangles.size(); j++) + for(int k = 0; k < gf->triangles[j]->getNumVertices(); k++) + nodes.insert(gf->triangles[j]->getVertex(k)); + for(unsigned int j = 0; j < gf->quadrangles.size(); j++) + for(int k = 0; k < gf->quadrangles[j]->getNumVertices(); k++) + nodes.insert(gf->quadrangles[j]->getVertex(k)); + } + else if(dim == 3){ + GRegion *gr = (GRegion*)it->second[i]; + for(unsigned int j = 0; j < gr->tetrahedra.size(); j++) + for(int k = 0; k < gr->tetrahedra[j]->getNumVertices(); k++) + nodes.insert(gr->tetrahedra[j]->getVertex(k)); + for(unsigned int j = 0; j < gr->hexahedra.size(); j++) + for(int k = 0; k < gr->hexahedra[j]->getNumVertices(); k++) + nodes.insert(gr->hexahedra[j]->getVertex(k)); + for(unsigned int j = 0; j < gr->prisms.size(); j++) + for(int k = 0; k < gr->prisms[j]->getNumVertices(); k++) + nodes.insert(gr->prisms[j]->getVertex(k)); + for(unsigned int j = 0; j < gr->pyramids.size(); j++) + for(int k = 0; k < gr->pyramids[j]->getNumVertices(); k++) + nodes.insert(gr->pyramids[j]->getVertex(k)); + } + } + fprintf(fp, "%10d%10d%10d%10d%10d%10d%10d%10d\n", + gr, 0, 0, 0, 0, 0, 0, (int)nodes.size()); + fprintf(fp, "PERMENENT GROUP%d\n", gr++); + int row = 0; + for(std::set<MVertex*>::iterator it2 = nodes.begin(); it2 != nodes.end(); it2++){ + if(row == 2) { + fprintf(fp, "\n"); + row = 0; + } + fprintf(fp, "%10d%10d%10d%10d", 7, (*it2)->getNum(), 0, 0); + row++; + } + fprintf(fp, "\n"); } } fprintf(fp, "%6d\n", -1); @@ -1505,66 +1505,66 @@ int GModel::readMESH(const std::string &name) if(buffer[0] != '#'){ // skip comments sscanf(buffer, "%s", str); if(!strcmp(str, "Dimension")){ - if(!fgets(buffer, sizeof(buffer), fp)) break; + if(!fgets(buffer, sizeof(buffer), fp)) break; } else if(!strcmp(str, "Vertices")){ - if(!fgets(buffer, sizeof(buffer), fp)) break; - int nbv; - sscanf(buffer, "%d", &nbv); - Msg(INFO, "%d vertices", nbv); - vertexVector.resize(nbv); - for(int i = 0; i < nbv; i++) { - if(!fgets(buffer, sizeof(buffer), fp)) break; - int dum; - double x, y, z; - sscanf(buffer, "%lf %lf %lf %d", &x, &y, &z, &dum); - vertexVector[i] = new MVertex(x, y, z); - } + if(!fgets(buffer, sizeof(buffer), fp)) break; + int nbv; + sscanf(buffer, "%d", &nbv); + Msg(INFO, "%d vertices", nbv); + vertexVector.resize(nbv); + for(int i = 0; i < nbv; i++) { + if(!fgets(buffer, sizeof(buffer), fp)) break; + int dum; + double x, y, z; + sscanf(buffer, "%lf %lf %lf %d", &x, &y, &z, &dum); + vertexVector[i] = new MVertex(x, y, z); + } } else if(!strcmp(str, "Triangles")){ - if(!fgets(buffer, sizeof(buffer), fp)) break; - int nbe; - sscanf(buffer, "%d", &nbe); - Msg(INFO, "%d triangles", nbe); - for(int i = 0; i < nbe; i++) { - if(!fgets(buffer, sizeof(buffer), fp)) break; - int n[3], cl; - sscanf(buffer, "%d %d %d %d", &n[0], &n[1], &n[2], &cl); - for(int j = 0; j < 3; j++) n[j]--; - std::vector<MVertex*> vertices; - if(!getVertices(3, n, vertexVector, vertices)) return 0; - elements[0][cl].push_back(new MTriangle(vertices)); - } + if(!fgets(buffer, sizeof(buffer), fp)) break; + int nbe; + sscanf(buffer, "%d", &nbe); + Msg(INFO, "%d triangles", nbe); + for(int i = 0; i < nbe; i++) { + if(!fgets(buffer, sizeof(buffer), fp)) break; + int n[3], cl; + sscanf(buffer, "%d %d %d %d", &n[0], &n[1], &n[2], &cl); + for(int j = 0; j < 3; j++) n[j]--; + std::vector<MVertex*> vertices; + if(!getVertices(3, n, vertexVector, vertices)) return 0; + elements[0][cl].push_back(new MTriangle(vertices)); + } } else if(!strcmp(str, "Quadrilaterals")) { - if(!fgets(buffer, sizeof(buffer), fp)) break; - int nbe; - sscanf(buffer, "%d", &nbe); - Msg(INFO, "%d quadrangles", nbe); - for(int i = 0; i < nbe; i++) { - if(!fgets(buffer, sizeof(buffer), fp)) break; - int n[4], cl; - sscanf(buffer, "%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &cl); - for(int j = 0; j < 4; j++) n[j]--; - std::vector<MVertex*> vertices; - if(!getVertices(4, n, vertexVector, vertices)) return 0; - elements[1][cl].push_back(new MQuadrangle(vertices)); - } + if(!fgets(buffer, sizeof(buffer), fp)) break; + int nbe; + sscanf(buffer, "%d", &nbe); + Msg(INFO, "%d quadrangles", nbe); + for(int i = 0; i < nbe; i++) { + if(!fgets(buffer, sizeof(buffer), fp)) break; + int n[4], cl; + sscanf(buffer, "%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &cl); + for(int j = 0; j < 4; j++) n[j]--; + std::vector<MVertex*> vertices; + if(!getVertices(4, n, vertexVector, vertices)) return 0; + elements[1][cl].push_back(new MQuadrangle(vertices)); + } } else if(!strcmp(str, "Tetrahedra")) { - if(!fgets(buffer, sizeof(buffer), fp)) break; - int nbe; - sscanf(buffer, "%d", &nbe); - Msg(INFO, "%d tetrahedra", nbe); - for(int i = 0; i < nbe; i++) { - if(!fgets(buffer, sizeof(buffer), fp)) break; - int n[4], cl; - sscanf(buffer, "%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &cl); - for(int j = 0; j < 4; j++) n[j]--; - std::vector<MVertex*> vertices; - if(!getVertices(4, n, vertexVector, vertices)) return 0; - elements[2][cl].push_back(new MTetrahedron(vertices)); - } + if(!fgets(buffer, sizeof(buffer), fp)) break; + int nbe; + sscanf(buffer, "%d", &nbe); + Msg(INFO, "%d tetrahedra", nbe); + for(int i = 0; i < nbe; i++) { + if(!fgets(buffer, sizeof(buffer), fp)) break; + int n[4], cl; + sscanf(buffer, "%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &cl); + for(int j = 0; j < 4; j++) n[j]--; + std::vector<MVertex*> vertices; + if(!getVertices(4, n, vertexVector, vertices)) return 0; + elements[2][cl].push_back(new MTetrahedron(vertices)); + } } } } @@ -1627,8 +1627,8 @@ int GModel::writeMESH(const std::string &name, bool saveAll, double scalingFacto fprintf(fp, " %d\n", numTriangles); for(fiter it = firstFace(); it != lastFace(); ++it){ if(saveAll || (*it)->physicals.size()){ - for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->triangles[i]->writeMESH(fp, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->triangles.size(); i++) + (*it)->triangles[i]->writeMESH(fp, (*it)->tag()); } } } @@ -1637,8 +1637,8 @@ int GModel::writeMESH(const std::string &name, bool saveAll, double scalingFacto fprintf(fp, " %d\n", numQuadrangles); for(fiter it = firstFace(); it != lastFace(); ++it){ if(saveAll || (*it)->physicals.size()){ - for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->quadrangles[i]->writeMESH(fp, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->triangles.size(); i++) + (*it)->quadrangles[i]->writeMESH(fp, (*it)->tag()); } } } @@ -1647,8 +1647,8 @@ int GModel::writeMESH(const std::string &name, bool saveAll, double scalingFacto fprintf(fp, " %d\n", numTetrahedra); for(riter it = firstRegion(); it != lastRegion(); ++it){ if(saveAll || (*it)->physicals.size()){ - for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) - (*it)->tetrahedra[i]->writeMESH(fp, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) + (*it)->tetrahedra[i]->writeMESH(fp, (*it)->tag()); } } } @@ -1695,7 +1695,7 @@ static double atofBDF(char *str) } static int readVertexBDF(FILE *fp, char *buffer, int keySize, - int *num, double *x, double *y, double *z) + int *num, double *x, double *y, double *z) { char tmp[5][32]; int j = keySize; @@ -1757,14 +1757,14 @@ static void readLineBDF(char *buffer, int format, std::vector<char*> &fields) else{ // small or long fields for(int i = 0; i < nmax + 1; i++){ if(!emptyFieldBDF(&buffer[8 + cmax * i], cmax)) - fields.push_back(&buffer[8 + cmax * i]); + fields.push_back(&buffer[8 + cmax * i]); } } } static int readElementBDF(FILE *fp, char *buffer, int keySize, int numVertices, - int &num, int ®ion, std::vector<MVertex*> &vertices, - std::map<int, MVertex*> &vertexMap) + int &num, int ®ion, std::vector<MVertex*> &vertices, + std::map<int, MVertex*> &vertexMap) { char buffer2[256], buffer3[256]; std::vector<char*> fields; @@ -1828,10 +1828,10 @@ int GModel::readBDF(const std::string &name) if(!fgets(buffer, sizeof(buffer), fp)) break; if(buffer[0] != '$'){ // skip comments if(!strncmp(buffer, "GRID", 4)){ - int num; - double x, y, z; - if(!readVertexBDF(fp, buffer, 4, &num, &x, &y, &z)) break; - vertexMap[num] = new MVertex(x, y, z, 0, num); + int num; + double x, y, z; + if(!readVertexBDF(fp, buffer, 4, &num, &x, &y, &z)) break; + vertexMap[num] = new MVertex(x, y, z, 0, num); } } } @@ -1845,70 +1845,70 @@ int GModel::readBDF(const std::string &name) int num, region; std::vector<MVertex*> vertices; if(!strncmp(buffer, "CBAR", 4)){ - if(readElementBDF(fp, buffer, 4, 2, num, region, vertices, vertexMap)) - elements[0][region].push_back(new MLine(vertices, num)); + if(readElementBDF(fp, buffer, 4, 2, num, region, vertices, vertexMap)) + elements[0][region].push_back(new MLine(vertices, num)); } else if(!strncmp(buffer, "CROD", 4)){ - if(readElementBDF(fp, buffer, 4, 2, num, region, vertices, vertexMap)) - elements[0][region].push_back(new MLine(vertices, num)); + if(readElementBDF(fp, buffer, 4, 2, num, region, vertices, vertexMap)) + elements[0][region].push_back(new MLine(vertices, num)); } else if(!strncmp(buffer, "CBEAM", 5)){ - if(readElementBDF(fp, buffer, 5, 2, num, region, vertices, vertexMap)) - elements[0][region].push_back(new MLine(vertices, num)); + if(readElementBDF(fp, buffer, 5, 2, num, region, vertices, vertexMap)) + elements[0][region].push_back(new MLine(vertices, num)); } else if(!strncmp(buffer, "CTRIA3", 6)){ - if(readElementBDF(fp, buffer, 6, 3, num, region, vertices, vertexMap)) - elements[1][region].push_back(new MTriangle(vertices, num)); + if(readElementBDF(fp, buffer, 6, 3, num, region, vertices, vertexMap)) + elements[1][region].push_back(new MTriangle(vertices, num)); } else if(!strncmp(buffer, "CTRIA6", 6)){ - if(readElementBDF(fp, buffer, 6, 6, num, region, vertices, vertexMap)) - elements[1][region].push_back(new MTriangle6(vertices, num)); + if(readElementBDF(fp, buffer, 6, 6, num, region, vertices, vertexMap)) + elements[1][region].push_back(new MTriangle6(vertices, num)); } else if(!strncmp(buffer, "CQUAD4", 6)){ - if(readElementBDF(fp, buffer, 6, 4, num, region, vertices, vertexMap)) - elements[2][region].push_back(new MQuadrangle(vertices, num)); + if(readElementBDF(fp, buffer, 6, 4, num, region, vertices, vertexMap)) + elements[2][region].push_back(new MQuadrangle(vertices, num)); } else if(!strncmp(buffer, "CQUAD8", 6)){ - if(readElementBDF(fp, buffer, 6, 8, num, region, vertices, vertexMap)) - elements[2][region].push_back(new MQuadrangle8(vertices, num)); + if(readElementBDF(fp, buffer, 6, 8, num, region, vertices, vertexMap)) + elements[2][region].push_back(new MQuadrangle8(vertices, num)); } else if(!strncmp(buffer, "CQUAD", 5)){ - if(readElementBDF(fp, buffer, 5, -4, num, region, vertices, vertexMap)){ - if(vertices.size() == 9) - elements[2][region].push_back(new MQuadrangle9(vertices, num)); - else if(vertices.size() == 8) - elements[2][region].push_back(new MQuadrangle8(vertices, num)); - else - elements[2][region].push_back(new MQuadrangle(vertices, num)); - } + if(readElementBDF(fp, buffer, 5, -4, num, region, vertices, vertexMap)){ + if(vertices.size() == 9) + elements[2][region].push_back(new MQuadrangle9(vertices, num)); + else if(vertices.size() == 8) + elements[2][region].push_back(new MQuadrangle8(vertices, num)); + else + elements[2][region].push_back(new MQuadrangle(vertices, num)); + } } else if(!strncmp(buffer, "CTETRA", 6)){ - if(readElementBDF(fp, buffer, 6, -4, num, region, vertices, vertexMap)){ - if(vertices.size() == 10) - elements[3][region].push_back(new MTetrahedron10(vertices, num)); - else - elements[3][region].push_back(new MTetrahedron(vertices, num)); - } + if(readElementBDF(fp, buffer, 6, -4, num, region, vertices, vertexMap)){ + if(vertices.size() == 10) + elements[3][region].push_back(new MTetrahedron10(vertices, num)); + else + elements[3][region].push_back(new MTetrahedron(vertices, num)); + } } else if(!strncmp(buffer, "CHEXA", 5)){ - if(readElementBDF(fp, buffer, 5, -8, num, region, vertices, vertexMap)){ - if(vertices.size() == 20) - elements[4][region].push_back(new MHexahedron20(vertices, num)); - else - elements[4][region].push_back(new MHexahedron(vertices, num)); - } + if(readElementBDF(fp, buffer, 5, -8, num, region, vertices, vertexMap)){ + if(vertices.size() == 20) + elements[4][region].push_back(new MHexahedron20(vertices, num)); + else + elements[4][region].push_back(new MHexahedron(vertices, num)); + } } else if(!strncmp(buffer, "CPENTA", 6)){ - if(readElementBDF(fp, buffer, 6, -6, num, region, vertices, vertexMap)){ - if(vertices.size() == 15) - elements[5][region].push_back(new MPrism15(vertices, num)); - else - elements[5][region].push_back(new MPrism(vertices, num)); - } + if(readElementBDF(fp, buffer, 6, -6, num, region, vertices, vertexMap)){ + if(vertices.size() == 15) + elements[5][region].push_back(new MPrism15(vertices, num)); + else + elements[5][region].push_back(new MPrism(vertices, num)); + } } else if(!strncmp(buffer, "CPYRAM", 6)){ - if(readElementBDF(fp, buffer, 6, 5, num, region, vertices, vertexMap)) - elements[6][region].push_back(new MPyramid(vertices, num)); + if(readElementBDF(fp, buffer, 6, 5, num, region, vertices, vertexMap)) + elements[6][region].push_back(new MPyramid(vertices, num)); } } } @@ -1923,7 +1923,7 @@ int GModel::readBDF(const std::string &name) } int GModel::writeBDF(const std::string &name, int format, bool saveAll, - double scalingFactor) + double scalingFactor) { FILE *fp = fopen(name.c_str(), "w"); if(!fp){ @@ -1953,27 +1953,27 @@ int GModel::writeBDF(const std::string &name, int format, bool saveAll, for(eiter it = firstEdge(); it != lastEdge(); ++it){ if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->lines.size(); i++) - (*it)->lines[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->lines[i]->writeBDF(fp, format, (*it)->tag()); } } for(fiter it = firstFace(); it != lastFace(); ++it){ if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->triangles[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->triangles[i]->writeBDF(fp, format, (*it)->tag()); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - (*it)->quadrangles[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->quadrangles[i]->writeBDF(fp, format, (*it)->tag()); } } for(riter it = firstRegion(); it != lastRegion(); ++it){ if(saveAll || (*it)->physicals.size()){ for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) - (*it)->tetrahedra[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->tetrahedra[i]->writeBDF(fp, format, (*it)->tag()); for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) - (*it)->hexahedra[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->hexahedra[i]->writeBDF(fp, format, (*it)->tag()); for(unsigned int i = 0; i < (*it)->prisms.size(); i++) - (*it)->prisms[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->prisms[i]->writeBDF(fp, format, (*it)->tag()); for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) - (*it)->pyramids[i]->writeBDF(fp, format, (*it)->tag()); + (*it)->pyramids[i]->writeBDF(fp, format, (*it)->tag()); } } @@ -2004,77 +2004,77 @@ int GModel::readP3D(const std::string &name) add(gf); gf->transfinite_vertices.resize(Ni[n]); for(int i = 0; i < Ni[n]; i++) - gf->transfinite_vertices[i].resize(Nj[n]); + gf->transfinite_vertices[i].resize(Nj[n]); for(int coord = 0; coord < 3; coord++){ - for(int i = 0; i < Ni[n]; i++){ - for(int j = 0; j < Nj[n]; j++){ - double d; - if(fscanf(fp, "%lf", &d) != 1) return 0; - if(coord == 0){ - MVertex *v = new MVertex(d, 0., 0., gf); - gf->transfinite_vertices[i][j] = v; - gf->mesh_vertices.push_back(v); - } - else if(coord == 1){ - gf->transfinite_vertices[i][j]->y() = d; - } - else if(coord == 2){ - gf->transfinite_vertices[i][j]->z() = d; - } - } - } + for(int i = 0; i < Ni[n]; i++){ + for(int j = 0; j < Nj[n]; j++){ + double d; + if(fscanf(fp, "%lf", &d) != 1) return 0; + if(coord == 0){ + MVertex *v = new MVertex(d, 0., 0., gf); + gf->transfinite_vertices[i][j] = v; + gf->mesh_vertices.push_back(v); + } + else if(coord == 1){ + gf->transfinite_vertices[i][j]->y() = d; + } + else if(coord == 2){ + gf->transfinite_vertices[i][j]->z() = d; + } + } + } } for(unsigned int i = 0; i < gf->transfinite_vertices.size() - 1; i++) - for(unsigned int j = 0; j < gf->transfinite_vertices[0].size() - 1; j++) - gf->quadrangles.push_back - (new MQuadrangle(gf->transfinite_vertices[i ][j ], - gf->transfinite_vertices[i + 1][j ], - gf->transfinite_vertices[i + 1][j + 1], - gf->transfinite_vertices[i ][j + 1])); + for(unsigned int j = 0; j < gf->transfinite_vertices[0].size() - 1; j++) + gf->quadrangles.push_back + (new MQuadrangle(gf->transfinite_vertices[i ][j ], + gf->transfinite_vertices[i + 1][j ], + gf->transfinite_vertices[i + 1][j + 1], + gf->transfinite_vertices[i ][j + 1])); } else{ GRegion *gr = new discreteRegion(this, getNumRegions() + 1); add(gr); gr->transfinite_vertices.resize(Ni[n]); for(int i = 0; i < Ni[n]; i++){ - gr->transfinite_vertices[i].resize(Nj[n]); - for(int j = 0; j < Nj[n]; j++){ - gr->transfinite_vertices[i][j].resize(Nk[n]); - } + gr->transfinite_vertices[i].resize(Nj[n]); + for(int j = 0; j < Nj[n]; j++){ + gr->transfinite_vertices[i][j].resize(Nk[n]); + } } for(int coord = 0; coord < 3; coord++){ - for(int i = 0; i < Ni[n]; i++){ - for(int j = 0; j < Nj[n]; j++){ - for(int k = 0; k < Nk[n]; k++){ - double d; - if(fscanf(fp, "%lf", &d) != 1) return 0; - if(coord == 0){ - MVertex *v = new MVertex(d, 0., 0., gr); - gr->transfinite_vertices[i][j][k] = v; - gr->mesh_vertices.push_back(v); - } - else if(coord == 1){ - gr->transfinite_vertices[i][j][k]->y() = d; - } - else if(coord == 2){ - gr->transfinite_vertices[i][j][k]->z() = d; - } - } - } - } + for(int i = 0; i < Ni[n]; i++){ + for(int j = 0; j < Nj[n]; j++){ + for(int k = 0; k < Nk[n]; k++){ + double d; + if(fscanf(fp, "%lf", &d) != 1) return 0; + if(coord == 0){ + MVertex *v = new MVertex(d, 0., 0., gr); + gr->transfinite_vertices[i][j][k] = v; + gr->mesh_vertices.push_back(v); + } + else if(coord == 1){ + gr->transfinite_vertices[i][j][k]->y() = d; + } + else if(coord == 2){ + gr->transfinite_vertices[i][j][k]->z() = d; + } + } + } + } } for(unsigned int i = 0; i < gr->transfinite_vertices.size() - 1; i++) - for(unsigned int j = 0; j < gr->transfinite_vertices[0].size() - 1; j++) - for(unsigned int k = 0; k < gr->transfinite_vertices[0][0].size() - 1; k++) - gr->hexahedra.push_back - (new MHexahedron(gr->transfinite_vertices[i ][j ][k ], - gr->transfinite_vertices[i + 1][j ][k ], - gr->transfinite_vertices[i + 1][j + 1][k ], - gr->transfinite_vertices[i ][j + 1][k ], - gr->transfinite_vertices[i ][j ][k + 1], - gr->transfinite_vertices[i + 1][j ][k + 1], - gr->transfinite_vertices[i + 1][j + 1][k + 1], - gr->transfinite_vertices[i ][j + 1][k + 1])); + for(unsigned int j = 0; j < gr->transfinite_vertices[0].size() - 1; j++) + for(unsigned int k = 0; k < gr->transfinite_vertices[0][0].size() - 1; k++) + gr->hexahedra.push_back + (new MHexahedron(gr->transfinite_vertices[i ][j ][k ], + gr->transfinite_vertices[i + 1][j ][k ], + gr->transfinite_vertices[i + 1][j + 1][k ], + gr->transfinite_vertices[i ][j + 1][k ], + gr->transfinite_vertices[i ][j ][k + 1], + gr->transfinite_vertices[i + 1][j ][k + 1], + gr->transfinite_vertices[i + 1][j + 1][k + 1], + gr->transfinite_vertices[i ][j + 1][k + 1])); } } @@ -2115,25 +2115,25 @@ int GModel::writeP3D(const std::string &name, bool saveAll, double scalingFactor for(unsigned int i = 0; i < faces.size(); i++) fprintf(fp, "%d %d 1\n", - (int)faces[i]->transfinite_vertices.size(), - (int)faces[i]->transfinite_vertices[0].size()); + (int)faces[i]->transfinite_vertices.size(), + (int)faces[i]->transfinite_vertices[0].size()); for(unsigned int i = 0; i < regions.size(); i++) fprintf(fp, "%d %d %d\n", - (int)regions[i]->transfinite_vertices.size(), - (int)regions[i]->transfinite_vertices[0].size(), - (int)regions[i]->transfinite_vertices[0][0].size()); + (int)regions[i]->transfinite_vertices.size(), + (int)regions[i]->transfinite_vertices[0].size(), + (int)regions[i]->transfinite_vertices[0][0].size()); for(unsigned int i = 0; i < faces.size(); i++){ GFace *gf = faces[i]; for(int coord = 0; coord < 3; coord++){ for(unsigned int j = 0; j < gf->transfinite_vertices.size(); j++){ - for(unsigned int k = 0; k < gf->transfinite_vertices[j].size(); k++){ - MVertex *v = gf->transfinite_vertices[j][k]; - double d = (coord == 0) ? v->x() : (coord == 1) ? v->y() : v->z(); - fprintf(fp, "%g ", d * scalingFactor); - } - fprintf(fp, "\n"); + for(unsigned int k = 0; k < gf->transfinite_vertices[j].size(); k++){ + MVertex *v = gf->transfinite_vertices[j][k]; + double d = (coord == 0) ? v->x() : (coord == 1) ? v->y() : v->z(); + fprintf(fp, "%g ", d * scalingFactor); + } + fprintf(fp, "\n"); } } } @@ -2142,14 +2142,14 @@ int GModel::writeP3D(const std::string &name, bool saveAll, double scalingFactor GRegion *gr = regions[i]; for(int coord = 0; coord < 3; coord++){ for(unsigned int j = 0; j < gr->transfinite_vertices.size(); j++){ - for(unsigned int k = 0; k < gr->transfinite_vertices[j].size(); k++){ - for(unsigned int l = 0; l < gr->transfinite_vertices[j][k].size(); l++){ - MVertex *v = gr->transfinite_vertices[j][k][l]; - double d = (coord == 0) ? v->x() : (coord == 1) ? v->y() : v->z(); - fprintf(fp, "%g ", d * scalingFactor); - } - fprintf(fp, "\n"); - } + for(unsigned int k = 0; k < gr->transfinite_vertices[j].size(); k++){ + for(unsigned int l = 0; l < gr->transfinite_vertices[j][k].size(); l++){ + MVertex *v = gr->transfinite_vertices[j][k][l]; + double d = (coord == 0) ? v->x() : (coord == 1) ? v->y() : v->z(); + fprintf(fp, "%g ", d * scalingFactor); + } + fprintf(fp, "\n"); + } } } } diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index f59080f18dbcb821d3165dd65133f47a08656e61..a503a4aafd94e2366d5c96f0e4b023e0baebaf0c 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_OCC.cpp,v 1.29 2008-02-22 21:09:00 geuzaine Exp $ +// $Id: GModelIO_OCC.cpp,v 1.30 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -47,37 +47,37 @@ void OCC_Internals::buildLists() somap.Add(TopoDS::Solid(exp0.Current())); for(exp1.Init(exp0.Current(), TopAbs_SHELL); exp1.More(); exp1.Next()){ - TopoDS_Shell shell = TopoDS::Shell(exp1.Current().Composed(exp0.Current().Orientation())); - if(shmap.FindIndex(shell) < 1){ - shmap.Add(shell); - - for(exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()){ - TopoDS_Face face = TopoDS::Face(exp2.Current().Composed(shell.Orientation())); - if(fmap.FindIndex(face) < 1){ - fmap.Add(face); - - for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){ - TopoDS_Wire wire = TopoDS::Wire(exp3.Current().Composed(face.Orientation())); - if(wmap.FindIndex(wire) < 1){ - wmap.Add(wire); - - for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ - TopoDS_Edge edge = TopoDS::Edge(exp4.Current().Composed(wire.Orientation())); - if(emap.FindIndex(edge) < 1){ - emap.Add(edge); - - for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); - if(vmap.FindIndex(vertex) < 1) - vmap.Add(vertex); - } - } - } - } - } - } - } - } + TopoDS_Shell shell = TopoDS::Shell(exp1.Current().Composed(exp0.Current().Orientation())); + if(shmap.FindIndex(shell) < 1){ + shmap.Add(shell); + + for(exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()){ + TopoDS_Face face = TopoDS::Face(exp2.Current().Composed(shell.Orientation())); + if(fmap.FindIndex(face) < 1){ + fmap.Add(face); + + for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){ + TopoDS_Wire wire = TopoDS::Wire(exp3.Current().Composed(face.Orientation())); + if(wmap.FindIndex(wire) < 1){ + wmap.Add(wire); + + for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ + TopoDS_Edge edge = TopoDS::Edge(exp4.Current().Composed(wire.Orientation())); + if(emap.FindIndex(edge) < 1){ + emap.Add(edge); + + for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); + if(vmap.FindIndex(vertex) < 1) + vmap.Add(vertex); + } + } + } + } + } + } + } + } } } } @@ -89,30 +89,30 @@ void OCC_Internals::buildLists() shmap.Add(shell); for(exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()){ - TopoDS_Face face = TopoDS::Face(exp2.Current().Composed(shell.Orientation())); - if(fmap.FindIndex(face) < 1){ - fmap.Add(face); - - for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){ - TopoDS_Wire wire = TopoDS::Wire(exp3.Current()); - if(wmap.FindIndex(wire) < 1){ - wmap.Add(wire); - - for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ - TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); - if(emap.FindIndex(edge) < 1){ - emap.Add(edge); - - for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); - if(vmap.FindIndex(vertex) < 1) - vmap.Add(vertex); - } - } - } - } - } - } + TopoDS_Face face = TopoDS::Face(exp2.Current().Composed(shell.Orientation())); + if(fmap.FindIndex(face) < 1){ + fmap.Add(face); + + for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){ + TopoDS_Wire wire = TopoDS::Wire(exp3.Current()); + if(wmap.FindIndex(wire) < 1){ + wmap.Add(wire); + + for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ + TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); + if(emap.FindIndex(edge) < 1){ + emap.Add(edge); + + for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); + if(vmap.FindIndex(vertex) < 1) + vmap.Add(vertex); + } + } + } + } + } + } } } } @@ -122,25 +122,25 @@ void OCC_Internals::buildLists() TopoDS_Face face = TopoDS::Face(exp2.Current()); if(fmap.FindIndex(face) < 1){ fmap.Add(face); - + for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){ - TopoDS_Wire wire = TopoDS::Wire(exp3.Current()); - if(wmap.FindIndex(wire) < 1){ - wmap.Add(wire); - - for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ - TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); - if(emap.FindIndex(edge) < 1){ - emap.Add(edge); - - for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); - if(vmap.FindIndex(vertex) < 1) - vmap.Add(vertex); - } - } - } - } + TopoDS_Wire wire = TopoDS::Wire(exp3.Current()); + if(wmap.FindIndex(wire) < 1){ + wmap.Add(wire); + + for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ + TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); + if(emap.FindIndex(edge) < 1){ + emap.Add(edge); + + for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); + if(vmap.FindIndex(vertex) < 1) + vmap.Add(vertex); + } + } + } + } } } } @@ -152,16 +152,16 @@ void OCC_Internals::buildLists() wmap.Add(wire); for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){ - TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); - if(emap.FindIndex(edge) < 1){ - emap.Add(edge); - - for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); - if(vmap.FindIndex(vertex) < 1) - vmap.Add(vertex); - } - } + TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); + if(emap.FindIndex(edge) < 1){ + emap.Add(edge); + + for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); + if(vmap.FindIndex(vertex) < 1) + vmap.Add(vertex); + } + } } } } @@ -173,9 +173,9 @@ void OCC_Internals::buildLists() emap.Add(edge); for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){ - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); - if(vmap.FindIndex(vertex) < 1) - vmap.Add(vertex); + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); + if(vmap.FindIndex(vertex) < 1) + vmap.Add(vertex); } } } @@ -190,8 +190,8 @@ void OCC_Internals::buildLists() } void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges, - bool fixspotstripfaces, bool sewfaces, - bool makesolids) + bool fixspotstripfaces, bool sewfaces, + bool makesolids) { int nrc = 0, nrcs = 0; TopExp_Explorer e; @@ -218,19 +218,19 @@ void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges, for(int i = 1; i <= fmap.Extent(); i++){ TopExp_Explorer exp1; for(exp1.Init(fmap(i), TopAbs_WIRE); exp1.More(); exp1.Next()){ - TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current()); - sfw = new ShapeFix_Wire(oldwire, TopoDS::Face(fmap(i)), tolerance); - sfw->ModifyTopologyMode() = Standard_True; - - if(sfw->FixSmall(false, tolerance)){ - Msg(INFO, "Fixed small edge in wire %d", wmap.FindIndex(oldwire)); - TopoDS_Wire newwire = sfw->Wire(); - rebuild->Replace(oldwire, newwire, Standard_False); - } - if((sfw->StatusSmall(ShapeExtend_FAIL1)) || - (sfw->StatusSmall(ShapeExtend_FAIL2)) || - (sfw->StatusSmall(ShapeExtend_FAIL3))) - Msg(INFO, "Failed to fix small edge in wire %d", wmap.FindIndex(oldwire)); + TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current()); + sfw = new ShapeFix_Wire(oldwire, TopoDS::Face(fmap(i)), tolerance); + sfw->ModifyTopologyMode() = Standard_True; + + if(sfw->FixSmall(false, tolerance)){ + Msg(INFO, "Fixed small edge in wire %d", wmap.FindIndex(oldwire)); + TopoDS_Wire newwire = sfw->Wire(); + rebuild->Replace(oldwire, newwire, Standard_False); + } + if((sfw->StatusSmall(ShapeExtend_FAIL1)) || + (sfw->StatusSmall(ShapeExtend_FAIL2)) || + (sfw->StatusSmall(ShapeExtend_FAIL3))) + Msg(INFO, "Failed to fix small edge in wire %d", wmap.FindIndex(oldwire)); } } shape = rebuild->Apply(shape); @@ -240,16 +240,16 @@ void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges, rebuild->Apply(shape); TopExp_Explorer exp1; for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ - TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); - if(vmap.FindIndex(TopExp::FirstVertex(edge)) == - vmap.FindIndex(TopExp::LastVertex(edge))){ - GProp_GProps system; - BRepGProp::LinearProperties(edge, system); - if(system.Mass() < tolerance){ - Msg(INFO, "removing degenerated edge %d", emap.FindIndex(edge)); - rebuild->Remove(edge, false); - } - } + TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); + if(vmap.FindIndex(TopExp::FirstVertex(edge)) == + vmap.FindIndex(TopExp::LastVertex(edge))){ + GProp_GProps system; + BRepGProp::LinearProperties(edge, system); + if(system.Mass() < tolerance){ + Msg(INFO, "removing degenerated edge %d", emap.FindIndex(edge)); + rebuild->Remove(edge, false); + } + } } shape = rebuild->Apply(shape); } @@ -325,27 +325,27 @@ void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges, else{ BRepCheck_Analyzer ba(ms); if(ba.IsValid()){ - Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; - sfs->Init(ms); - sfs->SetPrecision(tolerance); - sfs->SetMaxTolerance(tolerance); - sfs->Perform(); - shape = sfs->Shape(); - - for(exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()){ - TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); - TopoDS_Solid newsolid = solid; - BRepLib::OrientClosedSolid(newsolid); - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; - // rebuild->Apply(shape); - rebuild->Replace(solid, newsolid, Standard_False); - TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID, 1); - // TopoDS_Shape newshape = rebuild->Apply(shape); - shape = newshape; - } + Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; + sfs->Init(ms); + sfs->SetPrecision(tolerance); + sfs->SetMaxTolerance(tolerance); + sfs->Perform(); + shape = sfs->Shape(); + + for(exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()){ + TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); + TopoDS_Solid newsolid = solid; + BRepLib::OrientClosedSolid(newsolid); + Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + // rebuild->Apply(shape); + rebuild->Replace(solid, newsolid, Standard_False); + TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID, 1); + // TopoDS_Shape newshape = rebuild->Apply(shape); + shape = newshape; + } } else - Msg(INFO, " not possible"); + Msg(INFO, " not possible"); } } buildLists(); @@ -358,9 +358,9 @@ void OCC_Internals::loadBREP(const char *fn) BRepTools::Clean(shape); buildLists(); HealGeometry(CTX.geom.tolerance, - CTX.geom.occ_fix_small_edges, - CTX.geom.occ_fix_small_faces, - CTX.geom.occ_sew_faces); + CTX.geom.occ_fix_small_edges, + CTX.geom.occ_fix_small_faces, + CTX.geom.occ_sew_faces); BRepTools::Clean(shape); } @@ -374,9 +374,9 @@ void OCC_Internals::loadSTEP(const char *fn) BRepTools::Clean(shape); buildLists(); HealGeometry(CTX.geom.tolerance, - CTX.geom.occ_fix_small_edges, - CTX.geom.occ_fix_small_faces, - CTX.geom.occ_sew_faces); + CTX.geom.occ_fix_small_edges, + CTX.geom.occ_fix_small_faces, + CTX.geom.occ_sew_faces); BRepTools::Clean(shape); } @@ -390,9 +390,9 @@ void OCC_Internals::loadIGES(const char *fn) BRepTools::Clean(shape); buildLists(); HealGeometry(CTX.geom.tolerance, - CTX.geom.occ_fix_small_edges, - CTX.geom.occ_fix_small_faces, - CTX.geom.occ_sew_faces); + CTX.geom.occ_fix_small_edges, + CTX.geom.occ_fix_small_faces, + CTX.geom.occ_sew_faces); BRepTools::Clean(shape); } @@ -509,57 +509,57 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperat switch(op){ case OCC_Internals::Add : { - TopoDS_Shape theNewShape; - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - TopTools_ListOfShape listShape1, listShape2; - AddSimpleShapes(shape, listShape1); - AddSimpleShapes(tool, listShape2); - Standard_Boolean isCompound = - (listShape1.Extent() > 1 || listShape2.Extent() > 1); - - TopTools_ListIteratorOfListOfShape itSub1 (listShape1); - for (; itSub1.More(); itSub1.Next()) { - TopoDS_Shape aValue1 = itSub1.Value(); - TopTools_ListIteratorOfListOfShape itSub2 (listShape2); - for (; itSub2.More(); itSub2.Next()) { - TopoDS_Shape aValue2 = itSub2.Value(); - BRepAlgoAPI_Common BO (aValue1, aValue2); - if (!BO.IsDone()) { - Msg(GERROR,"Boolean Add Operator can not be performed"); - } - if (isCompound) { - TopoDS_Shape aStepResult = BO.Shape(); - if (aStepResult.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter (aStepResult); - for (; aCompIter.More(); aCompIter.Next()) { - B.Add(C, aCompIter.Value()); - } - } - else { - B.Add(C, aStepResult); - } - } - else - theNewShape = BO.Shape(); - } - } - if (isCompound) { - TopTools_ListOfShape listShapeC; - AddSimpleShapes(C, listShapeC); - TopTools_ListIteratorOfListOfShape itSubC (listShapeC); - bool isOnlySolids = true; - for (; itSubC.More(); itSubC.Next()) { - TopoDS_Shape aValueC = itSubC.Value(); - if (aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; - } - if (isOnlySolids) - throw; - // theNewShape = GEOMImpl_GlueDriver::GlueFaces(C, Precision::Confusion()); - else - theNewShape = C; - } + TopoDS_Shape theNewShape; + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + TopTools_ListOfShape listShape1, listShape2; + AddSimpleShapes(shape, listShape1); + AddSimpleShapes(tool, listShape2); + Standard_Boolean isCompound = + (listShape1.Extent() > 1 || listShape2.Extent() > 1); + + TopTools_ListIteratorOfListOfShape itSub1 (listShape1); + for (; itSub1.More(); itSub1.Next()) { + TopoDS_Shape aValue1 = itSub1.Value(); + TopTools_ListIteratorOfListOfShape itSub2 (listShape2); + for (; itSub2.More(); itSub2.Next()) { + TopoDS_Shape aValue2 = itSub2.Value(); + BRepAlgoAPI_Common BO (aValue1, aValue2); + if (!BO.IsDone()) { + Msg(GERROR,"Boolean Add Operator can not be performed"); + } + if (isCompound) { + TopoDS_Shape aStepResult = BO.Shape(); + if (aStepResult.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator aCompIter (aStepResult); + for (; aCompIter.More(); aCompIter.Next()) { + B.Add(C, aCompIter.Value()); + } + } + else { + B.Add(C, aStepResult); + } + } + else + theNewShape = BO.Shape(); + } + } + if (isCompound) { + TopTools_ListOfShape listShapeC; + AddSimpleShapes(C, listShapeC); + TopTools_ListIteratorOfListOfShape itSubC (listShapeC); + bool isOnlySolids = true; + for (; itSubC.More(); itSubC.Next()) { + TopoDS_Shape aValueC = itSubC.Value(); + if (aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; + } + if (isOnlySolids) + throw; + // theNewShape = GEOMImpl_GlueDriver::GlueFaces(C, Precision::Confusion()); + else + theNewShape = C; + } } break; case OCC_Internals::Cut : @@ -572,7 +572,7 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperat } void OCC_Internals::Sphere(const SPoint3 & center, const double & radius, - const BooleanOperator & op) + const BooleanOperator & op) { // build a sphere gp_Pnt aP(center.x(), center.y(), center.z()); diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index 55c8c514ec8eca2012d08d94acbaf5860b4bbefa..780eaedafa372dc3629d332efe492ac00cdd23af 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -1,7 +1,7 @@ #ifndef _GMODELIO_OCC_H_ #define _GMODELIO_OCC_H_ -// $Id: GModelIO_OCC.h,v 1.4 2008-02-17 08:47:58 geuzaine Exp $ +// $Id: GModelIO_OCC.h,v 1.5 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,8 +45,8 @@ class OCC_Internals { vmap.Clear(); } void HealGeometry(double tolerance, bool fixsmalledges, - bool fixspotstripfaces, bool sewfaces, - bool makesolids=false); + bool fixspotstripfaces, bool sewfaces, + bool makesolids=false); void loadSTEP(const char *); void loadIGES(const char *); void loadBREP(const char *); diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index c56837f931df161cadc117e739c3b95dd9fef3d3..8c2860a47b6738bdc64bf71b13eebe2e35210c43 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -1,4 +1,4 @@ -// $Id: GRegion.cpp,v 1.26 2008-02-23 15:40:29 geuzaine Exp $ +// $Id: GRegion.cpp,v 1.27 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -174,7 +174,7 @@ std::list<GEdge*> GRegion::edges() const std::list<GEdge*>::const_iterator it2 = e2.begin(); while (it2 != e2.end()){ if (std::find(e.begin(), e.end(), *it2) == e.end()) - e.push_back(*it2); + e.push_back(*it2); ++it2; } ++it; diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index 321c9cd981e9aba5b012108f880032a5fdc019a0..183a9457d4c9a8c2666e8b61940bbbaabf314549 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -1,4 +1,4 @@ -// $Id: Geo.cpp,v 1.108 2008-03-19 17:26:48 geuzaine Exp $ +// $Id: Geo.cpp,v 1.109 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -266,9 +266,9 @@ void End_Curve(Curve *c) for(int i = 1; i < NN; i++){ List_Read (c->Control_Points, i, &pV); if(c->geometry != pV->geometry){ - c->geometry = 0; - break; - } + c->geometry = 0; + break; + } } } @@ -467,9 +467,9 @@ void End_Surface(Surface *s) for (int i = 1; i < NN; i++){ List_Read (s->Generatrices, i, &c); if (c->geometry != s->geometry){ - s->geometry = 0; - break; - } + s->geometry = 0; + break; + } } } } @@ -478,17 +478,17 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T *Liste, List_T *Knots, int p1, int p2, double u1, double u2) { double matcr[4][4] = { {-0.5, 1.5, -1.5, 0.5}, - {1.0, -2.5, 2.0, -0.5}, - {-0.5, 0.0, 0.5, 0.0}, - {0.0, 1.0, 0.0, 0.0} }; + {1.0, -2.5, 2.0, -0.5}, + {-0.5, 0.0, 0.5, 0.0}, + {0.0, 1.0, 0.0, 0.0} }; double matbs[4][4] = { {-1.0, 3, -3, 1}, - {3, -6, 3.0, 0}, - {-3, 0.0, 3, 0.0}, - {1, 4, 1, 0.0} }; + {3, -6, 3.0, 0}, + {-3, 0.0, 3, 0.0}, + {1, 4, 1, 0.0} }; double matbez[4][4] = { {-1.0, 3, -3, 1}, - {3, -6, 3.0, 0}, - {-3, 3.0, 0, 0.0}, - {1, 0, 0, 0.0} }; + {3, -6, 3.0, 0}, + {-3, 3.0, 0, 0.0}, + {1, 0, 0, 0.0} }; Curve *pC = (Curve *)Malloc(sizeof(Curve)); pC->Color.type = 0; @@ -847,7 +847,7 @@ PhysicalGroup *FindPhysicalGroup(int num, int type) pp->Typ = type; if((ppp = (PhysicalGroup **) List_PQuery(GModel::current()->getGEOInternals()->PhysicalGroups, &pp, - comparePhysicalGroup))) { + comparePhysicalGroup))) { return *ppp; } return NULL; @@ -1037,7 +1037,7 @@ void DeletePoint(int ip) List_Read(Curves, i, &c); for(int j = 0; j < List_Nbr(c->Control_Points); j++) { if(!compareVertex(List_Pointer(c->Control_Points, j), &v)){ - List_Delete(Curves); + List_Delete(Curves); return; } } @@ -1060,7 +1060,7 @@ void DeleteCurve(int ip) List_Read(Surfs, i, &s); for(int j = 0; j < List_Nbr(s->Generatrices); j++) { if(!compareAbsCurve(List_Pointer(s->Generatrices, j), &c)){ - List_Delete(Surfs); + List_Delete(Surfs); return; } } @@ -1083,7 +1083,7 @@ void DeleteSurface(int is) List_Read(Vols, i, &v); for(int j = 0; j < List_Nbr(v->Surfaces); j++) { if(!compareSurface(List_Pointer(v->Surfaces, j), &s)){ - List_Delete(Vols); + List_Delete(Vols); return; } } @@ -1305,7 +1305,7 @@ Curve *CreateReversedCurve(Curve *c) if(c->Typ == MSH_SEGM_NURBS && c->k) { newc->k = (float *)malloc((c->degre + List_Nbr(c->Control_Points) + 1) * - sizeof(float)); + sizeof(float)); for(i = 0; i < c->degre + List_Nbr(c->Control_Points) + 1; i++) newc->k[c->degre + List_Nbr(c->Control_Points) - i] = c->k[i]; } @@ -1573,7 +1573,7 @@ void printSurface(Surface *s) } void ApplyTransformationToPoint(double matrix[4][4], Vertex *v, - bool end_curve_surface=false) + bool end_curve_surface=false) { double pos[4], vec[4]; @@ -1608,11 +1608,11 @@ void ApplyTransformationToPoint(double matrix[4][4], Vertex *v, Curve *c; List_Read(All, i, &c); for(int j = 0; j < List_Nbr(c->Control_Points); j++) { - Vertex *pv = *(Vertex **)List_Pointer(c->Control_Points, j); - if(pv->Num == v->Num){ - End_Curve(c); - break; - } + Vertex *pv = *(Vertex **)List_Pointer(c->Control_Points, j); + if(pv->Num == v->Num){ + End_Curve(c); + break; + } } } List_Delete(All); @@ -1621,11 +1621,11 @@ void ApplyTransformationToPoint(double matrix[4][4], Vertex *v, Surface *s; List_Read(All, i, &s); for(int j = 0; j < List_Nbr(s->Control_Points); j++) { - Vertex *pv = *(Vertex **)List_Pointer(s->Control_Points, j); - if(pv->Num == v->Num){ - End_Surface(s); - break; - } + Vertex *pv = *(Vertex **)List_Pointer(s->Control_Points, j); + if(pv->Num == v->Num){ + End_Surface(s); + break; + } } } List_Delete(All); @@ -1815,23 +1815,23 @@ void BoundaryShapes(List_T *shapes, List_T *shapesBoundary) case MSH_SEGM_PARAMETRIC: case MSH_SEGM_BND_LAYER: { - Curve *c = FindCurve(O.Num); - if(c){ - if(c->beg){ - Shape sh; - sh.Type = MSH_POINT; - sh.Num = c->beg->Num; - List_Add(shapesBoundary, &sh); - } - if(c->end){ - Shape sh; - sh.Type = MSH_POINT; - sh.Num = c->end->Num; - List_Add(shapesBoundary, &sh); - } - } - else - Msg(GERROR, "Unknown curve %d", O.Num); + Curve *c = FindCurve(O.Num); + if(c){ + if(c->beg){ + Shape sh; + sh.Type = MSH_POINT; + sh.Num = c->beg->Num; + List_Add(shapesBoundary, &sh); + } + if(c->end){ + Shape sh; + sh.Type = MSH_POINT; + sh.Num = c->end->Num; + List_Add(shapesBoundary, &sh); + } + } + else + Msg(GERROR, "Unknown curve %d", O.Num); } break; case MSH_SURF_PLAN: @@ -1839,36 +1839,36 @@ void BoundaryShapes(List_T *shapes, List_T *shapesBoundary) case MSH_SURF_TRIC: case MSH_SURF_BND_LAYER: { - Surface *s = FindSurface(O.Num); - if(s){ - for(int j = 0; j < List_Nbr(s->Generatrices); j++){ - Curve *c; - List_Read(s->Generatrices, j, &c); - Shape sh; - sh.Type = c->Typ; - sh.Num = c->Num; - List_Add(shapesBoundary, &sh); - } - } - else - Msg(GERROR, "Unknown surface %d", O.Num); + Surface *s = FindSurface(O.Num); + if(s){ + for(int j = 0; j < List_Nbr(s->Generatrices); j++){ + Curve *c; + List_Read(s->Generatrices, j, &c); + Shape sh; + sh.Type = c->Typ; + sh.Num = c->Num; + List_Add(shapesBoundary, &sh); + } + } + else + Msg(GERROR, "Unknown surface %d", O.Num); } break; case MSH_VOLUME: { - Volume *v = FindVolume(O.Num); - if(v){ - for(int j = 0; j < List_Nbr(v->Surfaces); j++){ - Surface *s; - List_Read(v->Surfaces, j, &s); - Shape sh; - sh.Type = s->Typ; - sh.Num = s->Num; - List_Add(shapesBoundary, &sh); - } - } - else - Msg(GERROR, "Unknown volume %d", O.Num); + Volume *v = FindVolume(O.Num); + if(v){ + for(int j = 0; j < List_Nbr(v->Surfaces); j++){ + Surface *s; + List_Read(v->Surfaces, j, &s); + Shape sh; + sh.Type = s->Typ; + sh.Num = s->Num; + List_Add(shapesBoundary, &sh); + } + } + else + Msg(GERROR, "Unknown volume %d", O.Num); } break; default: @@ -1913,11 +1913,11 @@ void ProtudeXYZ(double &x, double &y, double &z, ExtrudeParams *e) } int Extrude_ProtudePoint(int type, int ip, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - Curve **pc, Curve **prc, int final, - ExtrudeParams *e) + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + Curve **pc, Curve **prc, int final, + ExtrudeParams *e) { double matrix[4][4], T[3], Ax[3], d; Vertex V, *pv, *newp, *chapeau; @@ -2077,11 +2077,11 @@ int Extrude_ProtudePoint(int type, int ip, } int Extrude_ProtudeCurve(int type, int ic, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - Surface **ps, int final, - ExtrudeParams *e) + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + Surface **ps, int final, + ExtrudeParams *e) { double matrix[4][4], T[3], Ax[3]; Curve *CurveBeg, *CurveEnd; @@ -2237,10 +2237,10 @@ int Extrude_ProtudeCurve(int type, int ic, } int Extrude_ProtudeSurface(int type, int is, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - Volume **pv, ExtrudeParams *e) + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + Volume **pv, ExtrudeParams *e) { double matrix[4][4], T[3], Ax[3]; Curve *c, *c2; @@ -2307,12 +2307,12 @@ int Extrude_ProtudeSurface(int type, int is, for(i = 0; i < List_Nbr(ps->Generatrices); i++) { List_Read(ps->Generatrices, i, &c); Extrude_ProtudeCurve(type, c->Num, T0, T1, T2, A0, A1, A2, X0, X1, X2, - alpha, &s, 0, e); + alpha, &s, 0, e); if(s){ if(c->Num < 0) - ori = -1; + ori = -1; else - ori = 1; + ori = 1; List_Add(v->Surfaces, &s); List_Add(v->SurfacesOrientations, &ori); } @@ -2409,11 +2409,11 @@ int Extrude_ProtudeSurface(int type, int is, } void ExtrudeShape(int extrude_type, int shape_type, int shape_num, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - ExtrudeParams *e, - List_T *list_out) + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + ExtrudeParams *e, + List_T *list_out) { Shape shape; shape.Type = shape_type; @@ -2421,20 +2421,20 @@ void ExtrudeShape(int extrude_type, int shape_type, int shape_num, List_T *tmp = List_Create(1, 1, sizeof(Shape)); List_Add(tmp, &shape); ExtrudeShapes(extrude_type, tmp, - T0, T1, T2, - A0, A1, A2, - X0, X1, X2, alpha, - e, - list_out); + T0, T1, T2, + A0, A1, A2, + X0, X1, X2, alpha, + e, + list_out); List_Delete(tmp); } void ExtrudeShapes(int type, List_T *list_in, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - ExtrudeParams *e, - List_T *list_out) + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + ExtrudeParams *e, + List_T *list_out) { for(int i = 0; i < List_Nbr(list_in); i++){ Shape shape; @@ -2442,19 +2442,19 @@ void ExtrudeShapes(int type, List_T *list_in, switch(shape.Type){ case MSH_POINT: { - Curve *pc = 0, *prc = 0; - Shape top; - top.Num = Extrude_ProtudePoint(type, shape.Num, T0, T1, T2, - A0, A1, A2, X0, X1, X2, alpha, - &pc, &prc, 1, e); - top.Type = MSH_POINT; - List_Add(list_out, &top); - if(pc){ - Shape body; - body.Num = pc->Num; - body.Type = pc->Typ; - List_Add(list_out, &body); - } + Curve *pc = 0, *prc = 0; + Shape top; + top.Num = Extrude_ProtudePoint(type, shape.Num, T0, T1, T2, + A0, A1, A2, X0, X1, X2, alpha, + &pc, &prc, 1, e); + top.Type = MSH_POINT; + List_Add(list_out, &top); + if(pc){ + Shape body; + body.Num = pc->Num; + body.Type = pc->Typ; + List_Add(list_out, &body); + } } break; case MSH_SEGM_LINE: @@ -2468,32 +2468,32 @@ void ExtrudeShapes(int type, List_T *list_in, case MSH_SEGM_NURBS: case MSH_SEGM_PARAMETRIC: { - Surface *ps = 0; - Shape top; - top.Num = Extrude_ProtudeCurve(type, shape.Num, T0, T1, T2, - A0, A1, A2, X0, X1, X2, alpha, - &ps, 1, e); - Curve *pc = FindCurve(top.Num); - top.Type = pc ? pc->Typ : 0; - List_Add(list_out, &top); - if(ps){ - Shape body; - body.Num = ps->Num; - body.Type = ps->Typ; - List_Add(list_out, &body); - if(CTX.geom.extrude_return_lateral){ - for(int j = 0; j < List_Nbr(ps->Generatrices); j++){ - Curve *c; - List_Read(ps->Generatrices, j, &c); - if(abs(c->Num) != shape.Num && abs(c->Num) != top.Num){ - Shape side; - side.Num = c->Num; - side.Type = c->Typ; - List_Add(list_out, &side); - } - } - } - } + Surface *ps = 0; + Shape top; + top.Num = Extrude_ProtudeCurve(type, shape.Num, T0, T1, T2, + A0, A1, A2, X0, X1, X2, alpha, + &ps, 1, e); + Curve *pc = FindCurve(top.Num); + top.Type = pc ? pc->Typ : 0; + List_Add(list_out, &top); + if(ps){ + Shape body; + body.Num = ps->Num; + body.Type = ps->Typ; + List_Add(list_out, &body); + if(CTX.geom.extrude_return_lateral){ + for(int j = 0; j < List_Nbr(ps->Generatrices); j++){ + Curve *c; + List_Read(ps->Generatrices, j, &c); + if(abs(c->Num) != shape.Num && abs(c->Num) != top.Num){ + Shape side; + side.Num = c->Num; + side.Type = c->Typ; + List_Add(list_out, &side); + } + } + } + } } break; case MSH_SURF_REGL: @@ -2501,37 +2501,37 @@ void ExtrudeShapes(int type, List_T *list_in, case MSH_SURF_PLAN: case MSH_SURF_DISCRETE: { - Volume *pv = 0; - Shape top; - top.Num = Extrude_ProtudeSurface(type, shape.Num, T0, T1, T2, - A0, A1, A2, X0, X1, X2, alpha, - &pv, e); - Surface *ps = FindSurface(top.Num); - top.Type = ps ? ps->Typ : 0; - List_Add(list_out, &top); - if(pv){ - Shape body; - body.Num = pv->Num; - body.Type = pv->Typ; - List_Add(list_out, &body); - if(CTX.geom.extrude_return_lateral){ - for(int j = 0; j < List_Nbr(pv->Surfaces); j++){ - Surface *s; - List_Read(pv->Surfaces, j, &s); - if(abs(s->Num) != shape.Num && abs(s->Num) != top.Num){ - Shape side; - side.Num = s->Num; - side.Type = s->Typ; - List_Add(list_out, &side); - } - } - } - } + Volume *pv = 0; + Shape top; + top.Num = Extrude_ProtudeSurface(type, shape.Num, T0, T1, T2, + A0, A1, A2, X0, X1, X2, alpha, + &pv, e); + Surface *ps = FindSurface(top.Num); + top.Type = ps ? ps->Typ : 0; + List_Add(list_out, &top); + if(pv){ + Shape body; + body.Num = pv->Num; + body.Type = pv->Typ; + List_Add(list_out, &body); + if(CTX.geom.extrude_return_lateral){ + for(int j = 0; j < List_Nbr(pv->Surfaces); j++){ + Surface *s; + List_Read(pv->Surfaces, j, &s); + if(abs(s->Num) != shape.Num && abs(s->Num) != top.Num){ + Shape side; + side.Num = s->Num; + side.Type = s->Typ; + List_Add(list_out, &side); + } + } + } + } } break; default: Msg(GERROR, "Impossible to extrude entity %d (of type %d)", - shape.Num, shape.Type); + shape.Num, shape.Type); break; } } @@ -2588,7 +2588,7 @@ int compareTwoCurves(const void *a, const void *b) List_Read(c2->Control_Points, i, &v2); comp = compareVertex(&v1, &v2); if(comp) - return comp; + return comp; } } @@ -2715,9 +2715,9 @@ void ReplaceDuplicatePoints() for(j = 0; j < List_Nbr(s->TrsfPoints); j++){ pv = (Vertex **)List_Pointer(s->TrsfPoints, j); if(!(pv2 = (Vertex **)Tree_PQuery(allNonDuplicatedPoints, pv))) - Msg(GERROR, "Weird point %d in Coherence", (*pv)->Num); + Msg(GERROR, "Weird point %d in Coherence", (*pv)->Num); else - List_Write(s->TrsfPoints, j, pv2); + List_Write(s->TrsfPoints, j, pv2); } } List_Delete(All); @@ -2730,9 +2730,9 @@ void ReplaceDuplicatePoints() for(j = 0; j < List_Nbr(vol->TrsfPoints); j++){ pv = (Vertex **)List_Pointer(vol->TrsfPoints, j); if(!(pv2 = (Vertex **)Tree_PQuery(allNonDuplicatedPoints, pv))) - Msg(GERROR, "Weird point %d in Coherence", (*pv)->Num); + Msg(GERROR, "Weird point %d in Coherence", (*pv)->Num); else - List_Write(vol->TrsfPoints, j, pv2); + List_Write(vol->TrsfPoints, j, pv2); } } List_Delete(All); @@ -2928,7 +2928,7 @@ static double projectPC(double u) Vertex c = InterpolateCurve(CURVE, u, 0); return sqrt(DSQR(c.Pos.X - VERTEX->Pos.X) + DSQR(c.Pos.Y - VERTEX->Pos.Y) + - DSQR(c.Pos.Z - VERTEX->Pos.Z)); + DSQR(c.Pos.Z - VERTEX->Pos.Z)); } bool ProjectPointOnCurve(Curve *c, Vertex *v, Vertex *RES, Vertex *DER) @@ -3030,13 +3030,13 @@ bool IntersectCurvesWithSurface(List_T *curve_ids, int surface_id, List_T *shape if(c){ double x[4] = {0., 0.5, 0.5, 0.5}; if(IntersectCurveSurface(c, s, x)){ - Vertex p = InterpolateCurve(c, x[3], 0); - Vertex *v = Create_Vertex(NEWPOINT(), p.Pos.X, p.Pos.Y, p.Pos.Z, p.lc, p.u); - Tree_Insert(GModel::current()->getGEOInternals()->Points, &v); - Shape s; - s.Type = MSH_POINT; - s.Num = v->Num; - List_Add(shapes, &s); + Vertex p = InterpolateCurve(c, x[3], 0); + Vertex *v = Create_Vertex(NEWPOINT(), p.Pos.X, p.Pos.Y, p.Pos.Z, p.lc, p.u); + Tree_Insert(GModel::current()->getGEOInternals()->Points, &v); + Shape s; + s.Type = MSH_POINT; + s.Num = v->Num; + List_Add(shapes, &s); } } else{ @@ -3077,19 +3077,19 @@ void sortEdgesInLoop(int num, List_T *edges) for(int i = 0; i < List_Nbr(temp); i++) { c2 = *(Curve **)List_Pointer(temp, i); if(c1->end == c2->beg) { - List_Add(edges, &c2->Num); - List_PSuppress(temp, i); - c1 = c2; - if(c2->end == c0->beg) { - if(List_Nbr(temp)) { - Msg(INFO, "Starting subloop %d in Line Loop %d (are you sure about this?)", - ++k, num); - c0 = c1 = *(Curve **)List_Pointer(temp, 0); - List_Add(edges, &c1->Num); - List_PSuppress(temp, 0); - } - } - break; + List_Add(edges, &c2->Num); + List_PSuppress(temp, i); + c1 = c2; + if(c2->end == c0->beg) { + if(List_Nbr(temp)) { + Msg(INFO, "Starting subloop %d in Line Loop %d (are you sure about this?)", + ++k, num); + c0 = c1 = *(Curve **)List_Pointer(temp, 0); + List_Add(edges, &c1->Num); + List_PSuppress(temp, 0); + } + } + break; } } if(j++ > nbEdges) { @@ -3150,35 +3150,35 @@ void setSurfaceGeneratrices(Surface *s, List_T *loops) int ic; Curve *c; if((i == 0 && iLoop > 0) || // exterior boundary - (i != 0 && iLoop < 0)){ // hole - for(int j = 0; j < List_Nbr(el->Curves); j++) { - List_Read(el->Curves, j, &ic); - ic *= sign(iLoop); - if(i != 0) ic *= -1; // hole - if(!(c = FindCurve(ic))) { - Msg(GERROR, "Unknown curve %d", ic); - List_Delete(s->Generatrices); - s->Generatrices = NULL; - return; - } - else - List_Add(s->Generatrices, &c); - } + (i != 0 && iLoop < 0)){ // hole + for(int j = 0; j < List_Nbr(el->Curves); j++) { + List_Read(el->Curves, j, &ic); + ic *= sign(iLoop); + if(i != 0) ic *= -1; // hole + if(!(c = FindCurve(ic))) { + Msg(GERROR, "Unknown curve %d", ic); + List_Delete(s->Generatrices); + s->Generatrices = NULL; + return; + } + else + List_Add(s->Generatrices, &c); + } } else{ - for(int j = List_Nbr(el->Curves)-1; j >= 0; j--) { - List_Read(el->Curves, j, &ic); - ic *= sign(iLoop); - if(i != 0) ic *= -1; // hole - if(!(c = FindCurve(ic))) { - Msg(GERROR, "Unknown curve %d", ic); - List_Delete(s->Generatrices); - s->Generatrices = NULL; - return; - } - else - List_Add(s->Generatrices, &c); - } + for(int j = List_Nbr(el->Curves)-1; j >= 0; j--) { + List_Read(el->Curves, j, &ic); + ic *= sign(iLoop); + if(i != 0) ic *= -1; // hole + if(!(c = FindCurve(ic))) { + Msg(GERROR, "Unknown curve %d", ic); + List_Delete(s->Generatrices); + s->Generatrices = NULL; + return; + } + else + List_Add(s->Generatrices, &c); + } } } } @@ -3199,28 +3199,28 @@ void setVolumeSurfaces(Volume *v, List_T *loops) } else { for(int j = 0; j < List_Nbr(sl->Surfaces); j++) { - int is; + int is; List_Read(sl->Surfaces, j, &is); - Surface *s = FindSurface(abs(is)); + Surface *s = FindSurface(abs(is)); if(s) { - // contrary to curves in edge loops, we don't actually - // create "negative" surfaces. So we just store the signs in - // another list + // contrary to curves in edge loops, we don't actually + // create "negative" surfaces. So we just store the signs in + // another list List_Add(v->Surfaces, &s); - int tmp = sign(is) * sign(il); - if(i > 0) tmp *= -1; // this is a hole - List_Add(v->SurfacesOrientations, &tmp); - } - else{ - GFace *gf = GModel::current()->getFaceByTag(abs(is)); - if(gf) { - List_Add(v->SurfacesByTag, &is); - } - else{ - Msg(GERROR, "Unknown surface %d", is); - return; - } - } + int tmp = sign(is) * sign(il); + if(i > 0) tmp *= -1; // this is a hole + List_Add(v->SurfacesOrientations, &tmp); + } + else{ + GFace *gf = GModel::current()->getFaceByTag(abs(is)); + if(gf) { + List_Add(v->SurfacesByTag, &is); + } + else{ + Msg(GERROR, "Unknown surface %d", is); + return; + } + } } } } diff --git a/Geo/Geo.h b/Geo/Geo.h index 2fada331e3a1bce0d22ee7a63bf46b48ed061cf1..bf2fa979828ca842add89f9a028ba68d1705f298 100644 --- a/Geo/Geo.h +++ b/Geo/Geo.h @@ -102,8 +102,8 @@ class Vertex { Vertex operator % (Vertex & autre) // cross product { return Vertex(Pos.Y * autre.Pos.Z - Pos.Z * autre.Pos.Y, - -(Pos.X * autre.Pos.Z - Pos.Z * autre.Pos.X), - Pos.X * autre.Pos.Y - Pos.Y * autre.Pos.X, lc, w); + -(Pos.X * autre.Pos.Z - Pos.Z * autre.Pos.X), + Pos.X * autre.Pos.Y - Pos.Y * autre.Pos.X, lc, w); } }; @@ -234,7 +234,7 @@ int comparePhysicalGroup(const void *a, const void *b); Vertex *Create_Vertex(int Num, double X, double Y, double Z, double lc, double u); Vertex *Create_Vertex(int Num, double u, double v, gmshSurface *s, double lc); Curve *Create_Curve(int Num, int Typ, int Order, List_T * Liste, - List_T * Knots, int p1, int p2, double u1, double u2); + List_T * Knots, int p1, int p2, double u1, double u2); Curve *CreateReversedCurve(Curve *c); Surface *Create_Surface(int Num, int Typ); Volume *Create_Volume(int Num, int Typ); @@ -274,7 +274,7 @@ PhysicalGroup *FindPhysicalGroup(int inum, int type); void TranslateShapes(double X,double Y,double Z, List_T *shapes); void DilatShapes(double X,double Y,double Z, double A, List_T *shapes); void RotateShapes(double Ax,double Ay,double Az, - double Px,double Py, double Pz, double alpha, List_T *shapes); + double Px,double Py, double Pz, double alpha, List_T *shapes); void SymmetryShapes(double A,double B,double C, double D, List_T *shapes); void BoundaryShapes(List_T *shapes, List_T *shapesBoundary); void CopyShape(int Type, int Num, int *New); @@ -283,17 +283,17 @@ void ColorShape(int Type, int Num, unsigned int Color); void VisibilityShape(int Type, int Num, int Mode); void VisibilityShape(char *str, int Type, int Mode); void ExtrudeShape(int extrude_type, int shape_type, int shape_num, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - ExtrudeParams *e, - List_T *out); + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + ExtrudeParams *e, + List_T *out); void ExtrudeShapes(int extrude_type, List_T *in, - double T0, double T1, double T2, - double A0, double A1, double A2, - double X0, double X1, double X2, double alpha, - ExtrudeParams *e, - List_T *out); + double T0, double T1, double T2, + double A0, double A1, double A2, + double X0, double X1, double X2, double alpha, + ExtrudeParams *e, + List_T *out); void ProtudeXYZ(double &x, double &y, double &z, ExtrudeParams *e); diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp index 11cc7ddc97f13aec85200f90e6e71c728274e029..2da67eb3ca9930ff192f8ad8ae584bd3cfb4cc43 100644 --- a/Geo/GeoInterpolation.cpp +++ b/Geo/GeoInterpolation.cpp @@ -1,4 +1,4 @@ -// $Id: GeoInterpolation.cpp,v 1.33 2008-03-03 22:04:22 geuzaine Exp $ +// $Id: GeoInterpolation.cpp,v 1.34 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -337,14 +337,14 @@ Vertex InterpolateCurve(Curve *c, double u, int derivee) List_Read(c->Control_Points, i + 1, &v[2]); if(!i) { if(c->beg == c->end){ - List_Read(c->Control_Points, N - 2, &v[0]); + List_Read(c->Control_Points, N - 2, &v[0]); } else{ - v[0] = &temp1; - v[0]->Pos.X = 2. * v[1]->Pos.X - v[2]->Pos.X; - v[0]->Pos.Y = 2. * v[1]->Pos.Y - v[2]->Pos.Y; - v[0]->Pos.Z = 2. * v[1]->Pos.Z - v[2]->Pos.Z; - v[0]->pntOnGeometry = v[1]->pntOnGeometry * 2. - v[2]->pntOnGeometry; + v[0] = &temp1; + v[0]->Pos.X = 2. * v[1]->Pos.X - v[2]->Pos.X; + v[0]->Pos.Y = 2. * v[1]->Pos.Y - v[2]->Pos.Y; + v[0]->Pos.Z = 2. * v[1]->Pos.Z - v[2]->Pos.Z; + v[0]->pntOnGeometry = v[1]->pntOnGeometry * 2. - v[2]->pntOnGeometry; } } else { @@ -352,14 +352,14 @@ Vertex InterpolateCurve(Curve *c, double u, int derivee) } if(i == N - 2) { if(c->beg == c->end){ - List_Read(c->Control_Points, 1, &v[3]); + List_Read(c->Control_Points, 1, &v[3]); } else{ - v[3] = &temp2; - v[3]->Pos.X = 2. * v[2]->Pos.X - v[1]->Pos.X; - v[3]->Pos.Y = 2. * v[2]->Pos.Y - v[1]->Pos.Y; - v[3]->Pos.Z = 2. * v[2]->Pos.Z - v[1]->Pos.Z; - v[3]->pntOnGeometry = v[2]->pntOnGeometry * 2. - v[1]->pntOnGeometry; + v[3] = &temp2; + v[3]->Pos.X = 2. * v[2]->Pos.X - v[1]->Pos.X; + v[3]->Pos.Y = 2. * v[2]->Pos.Y - v[1]->Pos.Y; + v[3]->Pos.Z = 2. * v[2]->Pos.Z - v[1]->Pos.Z; + v[3]->pntOnGeometry = v[2]->pntOnGeometry * 2. - v[1]->pntOnGeometry; } } else { @@ -441,10 +441,10 @@ Vertex TransfiniteTri(Vertex c1, Vertex c2, Vertex c3, void TransfiniteSph(Vertex S, Vertex center, Vertex *T) { double r = sqrt(DSQR(S.Pos.X - center.Pos.X) + DSQR(S.Pos.Y - center.Pos.Y) - + DSQR(S.Pos.Z - center.Pos.Z)); + + DSQR(S.Pos.Z - center.Pos.Z)); double s = sqrt(DSQR(T->Pos.X - center.Pos.X) + DSQR(T->Pos.Y - center.Pos.Y) - + DSQR(T->Pos.Z - center.Pos.Z)); + + DSQR(T->Pos.Z - center.Pos.Z)); double dirx = (T->Pos.X - center.Pos.X) / s; double diry = (T->Pos.Y - center.Pos.Y) / s; @@ -467,26 +467,26 @@ Vertex InterpolateRuledSurface(Surface *s, double u, double v) } else if(isSphere){ if(!i){ - List_Read(C[i]->Control_Points, 1, &O); + List_Read(C[i]->Control_Points, 1, &O); } else{ - Vertex *tmp; - List_Read(C[i]->Control_Points, 1, &tmp); - if(compareVertex(&O, &tmp)) - isSphere = false; + Vertex *tmp; + List_Read(C[i]->Control_Points, 1, &tmp); + if(compareVertex(&O, &tmp)) + isSphere = false; } } } if(isSphere){ double n[3] = {C[0]->Circle.invmat[0][2], - C[0]->Circle.invmat[1][2], - C[0]->Circle.invmat[2][2]}; + C[0]->Circle.invmat[1][2], + C[0]->Circle.invmat[2][2]}; bool isPlane = true; for(int i = 1; i < std::min(List_Nbr(s->Generatrices), 4); i++) isPlane &= (n[0] == C[i]->Circle.invmat[0][2] && - n[1] == C[i]->Circle.invmat[1][2] && - n[2] == C[i]->Circle.invmat[2][2]); + n[1] == C[i]->Circle.invmat[1][2] && + n[2] == C[i]->Circle.invmat[2][2]); if(isPlane) isSphere = false; } @@ -611,9 +611,9 @@ Vertex InterpolateSurface(Surface *s, double u, double v, int derivee, int u_v) Vertex V(s->a, s->b, s->c); Projette(&V, s->plan); if(V.Pos.Z != 0.) - T.Pos.Z = (s->d - V.Pos.X * T.Pos.X - V.Pos.Y * T.Pos.Y) / V.Pos.Z; + T.Pos.Z = (s->d - V.Pos.X * T.Pos.X - V.Pos.Y * T.Pos.Y) / V.Pos.Z; else - T.Pos.Z = 0.; + T.Pos.Z = 0.; return T; } case MSH_SURF_BND_LAYER: diff --git a/Geo/GeoInterpolation.h b/Geo/GeoInterpolation.h index 1675683533c4e529cab13247befd2f5391fa3d01..e878cbe6ed601887718ed0543b5e3eed502948d3 100644 --- a/Geo/GeoInterpolation.h +++ b/Geo/GeoInterpolation.h @@ -25,5 +25,5 @@ Vertex InterpolateCurve(Curve *Curve, double u, int derivee); Vertex InterpolateSurface(Surface *s, double u, double v, int derivee, int u_v); SPoint2 InterpolateCubicSpline(Vertex * v[4], double t, double mat[4][4], - int derivee, double t1, double t2, gmshSurface *s); + int derivee, double t1, double t2, gmshSurface *s); #endif diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp index 1e6ee3a8ace07b7399f6a8b563a2cafeb1c68b81..fb655fc11afdad26f5d9cab7ecb425de071858cc 100644 --- a/Geo/GeoStringInterface.cpp +++ b/Geo/GeoStringInterface.cpp @@ -1,4 +1,4 @@ -// $Id: GeoStringInterface.cpp,v 1.19 2008-03-18 08:41:21 remacle Exp $ +// $Id: GeoStringInterface.cpp,v 1.20 2008-03-20 11:44:05 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -116,15 +116,15 @@ void add_infile(const char *text, const char *fich, bool deleted_something) if(strlen(ext) && strcmp(ext, ".geo") && strcmp(ext, ".GEO")){ char question[1024]; sprintf(question, - "A scripting command is going to be appended to a non-`.geo' file.\n\n" - "Are you sure you want to proceed?\n\n" - "(You might want to create a new `.geo' file containing the command\n\n" - "Merge \"%s\";\n\n" - "and use that file instead. To disable this warning in the future, select\n" - "`Enable expert mode' in the option dialog.)", fich); + "A scripting command is going to be appended to a non-`.geo' file.\n\n" + "Are you sure you want to proceed?\n\n" + "(You might want to create a new `.geo' file containing the command\n\n" + "Merge \"%s\";\n\n" + "and use that file instead. To disable this warning in the future, select\n" + "`Enable expert mode' in the option dialog.)", fich); if(!GetBinaryAnswer(question, "Proceed", "Cancel", false)){ - fclose(file); - return; + fclose(file); + return; } } } @@ -206,7 +206,7 @@ void add_recosurf(List_T *list, const char *fich) } void add_trsfline(int N, int *l, const char *fich, const char *type, - const char *typearg, const char *pts) + const char *typearg, const char *pts) { char text[BUFFSIZE], text2[BUFFSIZE]; @@ -234,7 +234,7 @@ void add_param(const char *par, const char *value, const char *fich) } void add_point(const char *fich, const char *x, const char *y, const char *z, - const char *lc) + const char *lc) { char text[BUFFSIZE]; int ip = NEWPOINT(); @@ -243,24 +243,24 @@ void add_point(const char *fich, const char *x, const char *y, const char *z, } void add_field_option(int field_id, const char *option_name, const char *option_value, const char *fich){ - std::ostringstream sstream; - sstream<<"Field["<<field_id<<"]."<<std::string(option_name)<<" = "<<std::string(option_value)<<";"; - add_infile(sstream.str().c_str(),fich); + std::ostringstream sstream; + sstream<<"Field["<<field_id<<"]."<<std::string(option_name)<<" = "<<std::string(option_value)<<";"; + add_infile(sstream.str().c_str(),fich); } void add_field(int field_id, const char *type_name, const char *fich){ - std::ostringstream sstream; - sstream<<"Field["<<field_id<<"] = "<<std::string(type_name)<<";"; - add_infile(sstream.str().c_str(),fich); + std::ostringstream sstream; + sstream<<"Field["<<field_id<<"] = "<<std::string(type_name)<<";"; + add_infile(sstream.str().c_str(),fich); } void delete_field(int field_id, const char *fich){ - std::ostringstream sstream; - sstream<<"Delete Field ["<<field_id<<"];"; - add_infile(sstream.str().c_str(),fich); + std::ostringstream sstream; + sstream<<"Delete Field ["<<field_id<<"];"; + add_infile(sstream.str().c_str(),fich); } void set_background_field(int field_id,const char *fich){ - std::ostringstream sstream; - sstream<<"Background Field = "<<field_id<<";"; - add_infile(sstream.str().c_str(),fich); + std::ostringstream sstream; + sstream<<"Background Field = "<<field_id<<";"; + add_infile(sstream.str().c_str(),fich); } void add_line(int p1, int p2, const char *fich) @@ -467,7 +467,7 @@ int add_physical(List_T *list, const char *fich, int type) } void translate(int add, List_T *list, const char *fich, const char *what, - const char *tx, const char *ty, const char *tz) + const char *tx, const char *ty, const char *tz) { char text[BUFFSIZE]; @@ -487,8 +487,8 @@ void translate(int add, List_T *list, const char *fich, const char *what, } void rotate(int add, List_T *list, const char *fich, const char *what, - const char *ax, const char *ay, const char *az, - const char *px, const char *py, const char *pz, const char *angle) + const char *ax, const char *ay, const char *az, + const char *px, const char *py, const char *pz, const char *angle) { char text[BUFFSIZE]; @@ -510,7 +510,7 @@ void rotate(int add, List_T *list, const char *fich, const char *what, } void dilate(int add, List_T *list, const char *fich, const char *what, - const char *dx, const char *dy, const char *dz, const char *df) + const char *dx, const char *dy, const char *dz, const char *df) { char text[BUFFSIZE]; @@ -532,7 +532,7 @@ void dilate(int add, List_T *list, const char *fich, const char *what, } void symmetry(int add, List_T *list, const char *fich, const char *what, - const char *sa, const char *sb, const char *sc, const char *sd) + const char *sa, const char *sb, const char *sc, const char *sd) { char text[BUFFSIZE]; @@ -554,7 +554,7 @@ void symmetry(int add, List_T *list, const char *fich, const char *what, } void extrude(List_T *list, const char *fich, const char *what, - const char *tx, const char *ty, const char *tz) + const char *tx, const char *ty, const char *tz) { char text[BUFFSIZE]; @@ -565,8 +565,8 @@ void extrude(List_T *list, const char *fich, const char *what, } void protude(List_T *list, const char *fich, const char *what, - const char *ax, const char *ay, const char *az, - const char *px, const char *py, const char *pz, const char *angle) + const char *ax, const char *ay, const char *az, + const char *px, const char *py, const char *pz, const char *angle) { char text[BUFFSIZE]; diff --git a/Geo/GeoStringInterface.h b/Geo/GeoStringInterface.h index ac61dca160acedeb8810b4f8eeac29b7f41b9d6f..c6c2ae76115870b9f39ca5121b7d42e7b62e1622 100644 --- a/Geo/GeoStringInterface.h +++ b/Geo/GeoStringInterface.h @@ -28,14 +28,14 @@ void coherence(const char *fich); void delet(List_T *list, const char *fich, const char *what); void add_infile(const char *text, const char *fich, bool deleted_something=false); void add_trsfline(int N, int *l, const char *fich, const char *type, - const char *typearg, const char *pts); + const char *typearg, const char *pts); void add_trsfsurf(int N, int *l, const char *fich, const char *dir); void add_trsfvol(int N, int *l, const char *fich); void add_charlength(List_T *list, const char *fich, const char *lc); void add_recosurf(List_T *list, const char *fich); void add_param(const char *par, const char *value, const char *fich); void add_point(const char *fich, const char *x, const char *y, const char *z, - const char *lc); + const char *lc); void add_line(int p1, int p2, const char *fich); void add_circ(int p1, int p2, int p3, const char *fich); void add_ell(int p1, int p2, int p3, int p4, const char *fich); @@ -53,18 +53,18 @@ void add_surfloop(List_T *list, const char *fich, int *numvol); void add_vol(List_T *list, const char *fich); int add_physical(List_T *list, const char *fich, int type); void translate(int add, List_T *list, const char *fich, const char *what, - const char *tx, const char *ty, const char *tz); + const char *tx, const char *ty, const char *tz); void rotate(int add, List_T *list, const char *fich, const char *what, - const char *ax, const char *ay, const char *az, - const char *px, const char *py, const char *pz, const char *angle); + const char *ax, const char *ay, const char *az, + const char *px, const char *py, const char *pz, const char *angle); void dilate(int add, List_T *list, const char *fich, const char *what, - const char *dx, const char *dy, const char *dz, const char *df); + const char *dx, const char *dy, const char *dz, const char *df); void symmetry(int add, List_T *list, const char *fich, const char *what, - const char *sa, const char *sb, const char *sc, const char *sd); + const char *sa, const char *sb, const char *sc, const char *sd); void extrude(List_T *list, const char *fich, const char *what, const char *tx, - const char *ty, const char *tz); + const char *ty, const char *tz); void protude(List_T *list, const char *fich, const char *what, - const char *ax, const char *ay, const char *az, - const char *px, const char *py, const char *pz, const char *angle); + const char *ax, const char *ay, const char *az, + const char *px, const char *py, const char *pz, const char *angle); #endif diff --git a/Geo/MEdge.h b/Geo/MEdge.h index 49eb1c99686661bb8ea6e7b22a408560a12a929c..3812182ecda6508ddaeea02cef756d4f5711365f 100644 --- a/Geo/MEdge.h +++ b/Geo/MEdge.h @@ -51,8 +51,8 @@ class MEdge { SVector3 tangent() const { SVector3 t(_v[1]->x() - _v[0]->x(), - _v[1]->y() - _v[0]->y(), - _v[1]->z() - _v[0]->z()); + _v[1]->y() - _v[0]->y(), + _v[1]->z() - _v[0]->z()); t.normalize(); return t; } @@ -78,7 +78,7 @@ class MEdge { { return SPoint3(t * _v[1]->x() + (1. - t) * _v[0]->x(), t * _v[1]->y() + (1. - t) * _v[0]->y(), - t * _v[1]->z() + (1. - t) * _v[0]->z()); + t * _v[1]->z() + (1. - t) * _v[0]->z()); } }; diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index adcf36203dcafa8f518a080cadbb026cb0e88fcb..ebc5446bce0c49f4ec2bd4b9a08f9a5fd16da9c2 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -1,4 +1,4 @@ -// $Id: MElement.cpp,v 1.60 2008-03-19 21:22:36 geuzaine Exp $ +// $Id: MElement.cpp,v 1.61 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -40,8 +40,8 @@ int MElement::_globalNum = 0; double MElementLessThanLexicographic::tolerance = 1.e-6; void MElement::_getEdgeRep(MVertex *v0, MVertex *v1, - double *x, double *y, double *z, SVector3 *n, - int faceIndex) + double *x, double *y, double *z, SVector3 *n, + int faceIndex) { x[0] = v0->x(); y[0] = v0->y(); z[0] = v0->z(); x[1] = v1->x(); y[1] = v1->y(); z[1] = v1->z(); @@ -55,7 +55,7 @@ void MElement::_getEdgeRep(MVertex *v0, MVertex *v1, } void MElement::_getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, - double *x, double *y, double *z, SVector3 *n) + double *x, double *y, double *z, SVector3 *n) { x[0] = v0->x(); x[1] = v1->x(); x[2] = v2->x(); y[0] = v0->y(); y[1] = v1->y(); y[2] = v2->y(); @@ -233,8 +233,8 @@ double MElement::getJacobian(double u, double v, double w, double jac[3][3]) jac[2][0] += p->x() * s[2]; jac[2][1] += p->y() * s[2]; jac[2][2] += p->z() * s[2]; } return fabs(jac[0][0] * jac[1][1] * jac[2][2] + jac[0][2] * jac[1][0] * jac[2][1] + - jac[0][1] * jac[1][2] * jac[2][0] - jac[0][2] * jac[1][1] * jac[2][0] - - jac[0][0] * jac[1][2] * jac[2][1] - jac[0][1] * jac[1][0] * jac[2][2]); + jac[0][1] * jac[1][2] * jac[2][0] - jac[0][2] * jac[1][1] * jac[2][0] - + jac[0][0] * jac[1][2] * jac[2][1] - jac[0][1] * jac[1][0] * jac[2][2]); case 2 : for(int i = 0; i < getNumVertices(); i++) { getGradShapeFunction(i, u, v, w, s); @@ -244,18 +244,18 @@ double MElement::getJacobian(double u, double v, double w, double jac[3][3]) } { double a[3], b[3], c[3]; - a[0]= getVertex(1)->x() - getVertex(0)->x(); - a[1]= getVertex(1)->y() - getVertex(0)->y(); - a[2]= getVertex(1)->z() - getVertex(0)->z(); - b[0]= getVertex(2)->x() - getVertex(0)->x(); - b[1]= getVertex(2)->y() - getVertex(0)->y(); - b[2]= getVertex(2)->z() - getVertex(0)->z(); + a[0] = getVertex(1)->x() - getVertex(0)->x(); + a[1] = getVertex(1)->y() - getVertex(0)->y(); + a[2] = getVertex(1)->z() - getVertex(0)->z(); + b[0] = getVertex(2)->x() - getVertex(0)->x(); + b[1] = getVertex(2)->y() - getVertex(0)->y(); + b[2] = getVertex(2)->z() - getVertex(0)->z(); prodve(a, b, c); jac[2][0] = c[0]; jac[2][1] = c[1]; jac[2][2] = c[2]; } return sqrt(SQR(jac[0][0] * jac[1][1] - jac[0][1] * jac[1][0]) + - SQR(jac[0][2] * jac[1][0] - jac[0][0] * jac[1][2]) + - SQR(jac[0][1] * jac[1][2] - jac[0][2] * jac[1][1])); + SQR(jac[0][2] * jac[1][0] - jac[0][0] * jac[1][2]) + + SQR(jac[0][1] * jac[1][2] - jac[0][2] * jac[1][1])); case 1: for(int i = 0; i < getNumVertices(); i++) { getGradShapeFunction(i, u, v, w, s); @@ -264,15 +264,15 @@ double MElement::getJacobian(double u, double v, double w, double jac[3][3]) } { double a[3], b[3], c[3]; - a[0]= getVertex(1)->x() - getVertex(0)->x(); - a[1]= getVertex(1)->y() - getVertex(0)->y(); - a[2]= getVertex(1)->z() - getVertex(0)->z(); + a[0] = getVertex(1)->x() - getVertex(0)->x(); + a[1] = getVertex(1)->y() - getVertex(0)->y(); + a[2] = getVertex(1)->z() - getVertex(0)->z(); if((fabs(a[0]) >= fabs(a[1]) && fabs(a[0]) >= fabs(a[2])) || - (fabs(a[1]) >= fabs(a[0]) && fabs(a[1]) >= fabs(a[2]))) { - b[0] = a[1]; b[1] = -a[0]; b[2] = 0.; + (fabs(a[1]) >= fabs(a[0]) && fabs(a[1]) >= fabs(a[2]))) { + b[0] = a[1]; b[1] = -a[0]; b[2] = 0.; } else { - b[0] = 0.; b[1] = a[2]; b[2] = -a[1]; + b[0] = 0.; b[1] = a[2]; b[2] = -a[1]; } prodve(a, b, c); jac[1][0] = b[0]; jac[1][1] = b[1]; jac[1][2] = b[2]; @@ -335,7 +335,7 @@ double MElement::interpolate(double val[], double u, double v, double w, int str } void MElement::interpolateGrad(double val[], double u, double v, double w, double f[3], - int stride, double invjac[3][3]) + int stride, double invjac[3][3]) { double dfdu[3] = {0., 0., 0.}; int j = 0; @@ -359,7 +359,7 @@ void MElement::interpolateGrad(double val[], double u, double v, double w, doubl } void MElement::interpolateCurl(double val[], double u, double v, double w, double f[3], - int stride) + int stride) { double fx[3], fy[3], fz[3], jac[3][3], inv[3][3]; getJacobian(u, v, w, jac); @@ -384,7 +384,7 @@ double MElement::interpolateDiv(double val[], double u, double v, double w, int } void MElement::writeMSH(FILE *fp, double version, bool binary, int num, - int elementary, int physical) + int elementary, int physical) { int type = getTypeForMSH(); @@ -426,8 +426,8 @@ void MElement::writeMSH(FILE *fp, double version, bool binary, int num, } void MElement::writePOS(FILE *fp, bool printElementary, bool printElementNumber, - bool printGamma, bool printEta, bool printRho, - double scalingFactor, int elementary) + bool printGamma, bool printEta, bool printRho, + double scalingFactor, int elementary) { const char *str = getStringForPOS(); if(!str) return; @@ -437,7 +437,7 @@ void MElement::writePOS(FILE *fp, bool printElementary, bool printElementNumber, for(int i = 0; i < n; i++){ if(i) fprintf(fp, ","); fprintf(fp, "%g,%g,%g", getVertex(i)->x() * scalingFactor, - getVertex(i)->y() * scalingFactor, getVertex(i)->z() * scalingFactor); + getVertex(i)->y() * scalingFactor, getVertex(i)->z() * scalingFactor); } fprintf(fp, "){"); bool first = true; @@ -487,19 +487,19 @@ void MElement::writeSTL(FILE *fp, bool binary, double scalingFactor) fprintf(fp, " outer loop\n"); for(int j = 0; j < 3; j++) fprintf(fp, " vertex %g %g %g\n", - getVertex(j)->x() * scalingFactor, - getVertex(j)->y() * scalingFactor, - getVertex(j)->z() * scalingFactor); + getVertex(j)->x() * scalingFactor, + getVertex(j)->y() * scalingFactor, + getVertex(j)->z() * scalingFactor); fprintf(fp, " endloop\n"); fprintf(fp, "endfacet\n"); if(getNumVertices() == 4){ fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); fprintf(fp, " outer loop\n"); for(int j = 0; j < 3; j++) - fprintf(fp, " vertex %g %g %g\n", - getVertex(qid[j])->x() * scalingFactor, - getVertex(qid[j])->y() * scalingFactor, - getVertex(qid[j])->z() * scalingFactor); + fprintf(fp, " vertex %g %g %g\n", + getVertex(qid[j])->x() * scalingFactor, + getVertex(qid[j])->y() * scalingFactor, + getVertex(qid[j])->z() * scalingFactor); fprintf(fp, " endloop\n"); fprintf(fp, "endfacet\n"); } @@ -519,9 +519,9 @@ void MElement::writeSTL(FILE *fp, bool binary, double scalingFactor) fwrite(data, sizeof(char), 50, fp); if(getNumVertices() == 4){ for(int j = 0; j < 3; j++){ - coords[3 + 3 * j] = getVertex(qid[j])->x() * scalingFactor; - coords[3 + 3 * j + 1] = getVertex(qid[j])->y() * scalingFactor; - coords[3 + 3 * j + 2] = getVertex(qid[j])->z() * scalingFactor; + coords[3 + 3 * j] = getVertex(qid[j])->x() * scalingFactor; + coords[3 + 3 * j + 1] = getVertex(qid[j])->y() * scalingFactor; + coords[3 + 3 * j + 2] = getVertex(qid[j])->z() * scalingFactor; } fwrite(data, sizeof(char), 50, fp); } @@ -546,7 +546,7 @@ void MElement::writeUNV(FILE *fp, int num, int elementary, int physical) int material_property = abs(physical); int color = 7; fprintf(fp, "%10d%10d%10d%10d%10d%10d\n", - num ? num : _num, type, physical_property, material_property, color, n); + num ? num : _num, type, physical_property, material_property, color, n); if(type == 21 || type == 24) // linear beam or parabolic beam fprintf(fp, "%10d%10d%10d\n", 0, 0, 0); @@ -585,8 +585,8 @@ void MElement::writeBDF(FILE *fp, int format, int elementary) for(int i = 0; i < n; i++){ fprintf(fp, ",%d", getVertex(i)->getNum()); if(i != n - 1 && !((i + 3) % 8)){ - fprintf(fp, ",+%s%d\n+%s%d", cont[ncont], _num, cont[ncont], _num); - ncont++; + fprintf(fp, ",+%s%d\n+%s%d", cont[ncont], _num, cont[ncont], _num); + ncont++; } } if(n == 2) // CBAR @@ -598,8 +598,8 @@ void MElement::writeBDF(FILE *fp, int format, int elementary) for(int i = 0; i < n; i++){ fprintf(fp, "%-8d", getVertex(i)->getNum()); if(i != n - 1 && !((i + 3) % 8)){ - fprintf(fp, "+%s%-6d\n+%s%-6d", cont[ncont], _num, cont[ncont], _num); - ncont++; + fprintf(fp, "+%s%-6d\n+%s%-6d", cont[ncont], _num, cont[ncont], _num); + ncont++; } } if(n == 2) // CBAR diff --git a/Geo/MElement.h b/Geo/MElement.h index 222070a36b2d4f7f3982e716c77a7af7b7be0e0a..69001261d0bbf17fbb4a0f21e4b6f3c9b3180d1e 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -40,10 +40,10 @@ class MElement char _visible; protected: void _getEdgeRep(MVertex *v0, MVertex *v1, - double *x, double *y, double *z, SVector3 *n, - int faceIndex=-1); + double *x, double *y, double *z, SVector3 *n, + int faceIndex=-1); void _getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, - double *x, double *y, double *z, SVector3 *n); + double *x, double *y, double *z, SVector3 *n); public : MElement(int num=0, int part=0) : _visible(true) @@ -145,13 +145,13 @@ class MElement // Returns the interpolating nodal shape function associated with // node num, evaluated at point (u,v,w) in parametric coordinates virtual void getShapeFunction(int num, double u, double v, double w, - double &s) = 0; + double &s) = 0; // Returns the gradient of of the nodal shape function associated // with node num, evaluated at point (u,v,w) in parametric // coordinates virtual void getGradShapeFunction(int num, double u, double v, double w, - double s[3]) = 0; + double s[3]) = 0; // Returns the Jacobian of the element evaluated at point (u,v,w) in // parametric coordinates @@ -168,17 +168,17 @@ class MElement // divergence) at point (u,v,w) in parametric coordinates double interpolate(double val[], double u, double v, double w, int stride=1); void interpolateGrad(double val[], double u, double v, double w, double f[3], - int stride=1, double invjac[3][3]=0); + int stride=1, double invjac[3][3]=0); void interpolateCurl(double val[], double u, double v, double w, double f[3], - int stride=3); + int stride=3); double interpolateDiv(double val[], double u, double v, double w, int stride=3); // IO routines virtual void writeMSH(FILE *fp, double version=1.0, bool binary=false, - int num=0, int elementary=1, int physical=1); + int num=0, int elementary=1, int physical=1); virtual void writePOS(FILE *fp, bool printElementary, bool printElementNumber, - bool printGamma, bool printEta, bool printRho, - double scalingFactor=1.0, int elementary=1); + bool printGamma, bool printEta, bool printRho, + double scalingFactor=1.0, int elementary=1); virtual void writeSTL(FILE *fp, bool binary=false, double scalingFactor=1.0); virtual void writeVRML(FILE *fp); virtual void writeUNV(FILE *fp, int num=0, int elementary=1, int physical=1); @@ -339,8 +339,8 @@ class MLineN : public MLine { virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n) { _getEdgeRep(getVertex((num == 0) ? 0 : num + 1), - getVertex((num == getNumEdgesRep() - 1) ? 1 : num + 2), - x, y, z, n); + getVertex((num == getNumEdgesRep() - 1) ? 1 : num + 2), + x, y, z, n); } virtual int getTypeForMSH(){ if(_vs.size() == 2) return MSH_LIN_4; @@ -454,7 +454,7 @@ class MTriangle6 : public MTriangle { MVertex *_vs[3]; public : MTriangle6(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, int num=0, int part=0) + MVertex *v5, int num=0, int part=0) : MTriangle(v0, v1, v2, num, part) { _vs[0] = v3; _vs[1] = v4; _vs[2] = v5; @@ -493,7 +493,7 @@ class MTriangle6 : public MTriangle { {0, 3, 5}, {1, 4, 3}, {2, 5, 4}, {3, 4, 5} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_TRI_6; } virtual int getTypeForUNV(){ return 92; } // thin shell parabolic triangle @@ -530,7 +530,7 @@ class MTriangleN : public MTriangle { } public: MTriangleN(MVertex *v0, MVertex *v1, MVertex *v2, - std::vector<MVertex*> &v, int order, int num=0, int part=0) + std::vector<MVertex*> &v, int order, int num=0, int part=0) : MTriangle(v0, v1, v2, num, part) , _vs (v), _order(order) { for(unsigned int i = 0; i < _vs.size(); i++) _vs[i]->setPolynomialOrder(_order); @@ -638,7 +638,7 @@ class MQuadrangle : public MElement { {0, 1, 2}, {0, 2, 3} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_QUA_4; } virtual int getTypeForUNV(){ return 94; } // thin shell linear quadrilateral @@ -681,7 +681,7 @@ class MQuadrangle8 : public MQuadrangle { MVertex *_vs[4]; public : MQuadrangle8(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, int num=0, int part=0) : MQuadrangle(v0, v1, v2, v3, num, part) { _vs[0] = v4; _vs[1] = v5; _vs[2] = v6; _vs[3] = v7; @@ -721,7 +721,7 @@ class MQuadrangle8 : public MQuadrangle { {0, 4, 7}, {1, 5, 4}, {2, 6, 5}, {3, 7, 6}, {4, 5, 6}, {4, 6, 7} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_QUA_8; } virtual int getTypeForUNV(){ return 95; } // shell parabolic quadrilateral @@ -741,7 +741,7 @@ class MQuadrangle9 : public MQuadrangle { MVertex *_vs[5]; public : MQuadrangle9(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, int num=0, int part=0) : MQuadrangle(v0, v1, v2, v3, num, part) { _vs[0] = v4; _vs[1] = v5; _vs[2] = v6; _vs[3] = v7; _vs[4] = v8; @@ -778,7 +778,7 @@ class MQuadrangle9 : public MQuadrangle { {2, 6, 8}, {2, 8, 5}, {3, 7, 8}, {3, 8, 6} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_QUA_9; } virtual int getTypeForUNV(){ return 0; } // not available @@ -841,8 +841,8 @@ class MTetrahedron : public MElement { {3, 1, 2} }; return MFace(_v[faces_tetra[num][0]], - _v[faces_tetra[num][1]], - _v[faces_tetra[num][2]]); + _v[faces_tetra[num][1]], + _v[faces_tetra[num][2]]); } virtual int getNumFacesRep(){ return 4; } virtual void getFaceRep(int num, double *x, double *y, double *z, SVector3 *n) @@ -908,8 +908,8 @@ class MTetrahedron10 : public MTetrahedron { MVertex *_vs[6]; public : MTetrahedron10(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + int num=0, int part=0) : MTetrahedron(v0, v1, v2, v3, num, part) { _vs[0] = v4; _vs[1] = v5; _vs[2] = v6; _vs[3] = v7; _vs[4] = v8; _vs[5] = v9; @@ -960,7 +960,7 @@ class MTetrahedron10 : public MTetrahedron { {3, 9, 8}, {1, 5, 9}, {2, 8, 5}, {9, 5, 8} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_TET_10; } virtual int getTypeForUNV(){ return 118; } // solid parabolic tetrahedron @@ -980,7 +980,7 @@ class MHexahedron : public MElement { MVertex *_v[8]; public : MHexahedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, int num=0, int part=0) : MElement(num, part) { _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; @@ -1033,9 +1033,9 @@ class MHexahedron : public MElement { {4, 5, 6, 7} }; return MFace(_v[faces_hexa[num][0]], - _v[faces_hexa[num][1]], - _v[faces_hexa[num][2]], - _v[faces_hexa[num][3]]); + _v[faces_hexa[num][1]], + _v[faces_hexa[num][2]], + _v[faces_hexa[num][3]]); } virtual int getNumFacesRep(){ return 12; } virtual void getFaceRep(int num, double *x, double *y, double *z, SVector3 *n) @@ -1049,7 +1049,7 @@ class MHexahedron : public MElement { {4, 5, 6}, {4, 6, 7} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_HEX_8; } virtual int getTypeForUNV(){ return 115; } // solid linear brick @@ -1120,10 +1120,10 @@ class MHexahedron20 : public MHexahedron { MVertex *_vs[12]; public : MHexahedron20(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, - MVertex *v15, MVertex *v16, MVertex *v17, MVertex *v18, MVertex *v19, - int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, + MVertex *v15, MVertex *v16, MVertex *v17, MVertex *v18, MVertex *v19, + int num=0, int part=0) : MHexahedron(v0, v1, v2, v3, v4, v5, v6, v7, num, part) { _vs[0] = v8; _vs[1] = v9; _vs[2] = v10; _vs[3] = v11; _vs[4] = v12; @@ -1144,13 +1144,13 @@ class MHexahedron20 : public MHexahedron { virtual MVertex *getVertexUNV(int num) { static const int map[20] = {0, 8, 1, 11, 2, 13, 3, 9, 10, 12, - 14, 15, 4, 16, 5, 18, 6, 19, 7, 17}; + 14, 15, 4, 16, 5, 18, 6, 19, 7, 17}; return getVertex(map[num]); } virtual MVertex *getVertexBDF(int num) { static const int map[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 13, - 9, 10, 12, 14, 15, 16, 18, 19, 17}; + 9, 10, 12, 14, 15, 16, 18, 19, 17}; return getVertex(map[num]); } virtual int getNumEdgeVertices(){ return 12; } @@ -1186,7 +1186,7 @@ class MHexahedron20 : public MHexahedron { {4, 16, 17}, {5, 18, 16}, {6, 19, 18}, {7, 17, 19}, {16, 18, 19}, {16, 19, 17} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_HEX_20; } virtual int getTypeForUNV(){ return 116; } // solid parabolic brick @@ -1212,11 +1212,11 @@ class MHexahedron27 : public MHexahedron { MVertex *_vs[19]; public : MHexahedron27(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, - MVertex *v15, MVertex *v16, MVertex *v17, MVertex *v18, MVertex *v19, - MVertex *v20, MVertex *v21, MVertex *v22, MVertex *v23, MVertex *v24, - MVertex *v25, MVertex *v26, int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, + MVertex *v15, MVertex *v16, MVertex *v17, MVertex *v18, MVertex *v19, + MVertex *v20, MVertex *v21, MVertex *v22, MVertex *v23, MVertex *v24, + MVertex *v25, MVertex *v26, int num=0, int part=0) : MHexahedron(v0, v1, v2, v3, v4, v5, v6, v7, num, part) { _vs[0] = v8; _vs[1] = v9; _vs[2] = v10; _vs[3] = v11; _vs[4] = v12; @@ -1276,7 +1276,7 @@ class MHexahedron27 : public MHexahedron { {6, 19, 25}, {6, 25, 18}, {7, 17, 25}, {7, 25, 19} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_HEX_27; } virtual int getTypeForUNV(){ return 0; } // not available @@ -1306,7 +1306,7 @@ class MPrism : public MElement { MVertex *_v[6]; public : MPrism(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, int num=0, int part=0) + MVertex *v5, int num=0, int part=0) : MElement(num, part) { _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; @@ -1358,13 +1358,13 @@ class MPrism : public MElement { }; if(num < 2) return MFace(_v[trifaces_prism[num][0]], - _v[trifaces_prism[num][1]], - _v[trifaces_prism[num][2]]); + _v[trifaces_prism[num][1]], + _v[trifaces_prism[num][2]]); else return MFace(_v[quadfaces_prism[num - 2][0]], - _v[quadfaces_prism[num - 2][1]], - _v[quadfaces_prism[num - 2][2]], - _v[quadfaces_prism[num - 2][3]]); + _v[quadfaces_prism[num - 2][1]], + _v[quadfaces_prism[num - 2][2]], + _v[quadfaces_prism[num - 2][3]]); } virtual int getNumFacesRep(){ return 8; } virtual void getFaceRep(int num, double *x, double *y, double *z, SVector3 *n) @@ -1377,7 +1377,7 @@ class MPrism : public MElement { {1, 2, 5}, {1, 5, 4} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_PRI_6; } virtual int getTypeForUNV(){ return 112; } // solid linear wedge @@ -1440,9 +1440,9 @@ class MPrism15 : public MPrism { MVertex *_vs[9]; public : MPrism15(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, - int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, + int num=0, int part=0) : MPrism(v0, v1, v2, v3, v4, v5, num, part) { _vs[0] = v6; _vs[1] = v7; _vs[2] = v8; _vs[3] = v9; _vs[4] = v10; @@ -1498,7 +1498,7 @@ class MPrism15 : public MPrism { {1, 9, 10}, {2, 11, 9}, {5, 14, 11}, {4, 10, 14}, {9, 11, 14}, {9, 14, 10} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_PRI_15; } virtual int getTypeForUNV(){ return 113; } // solid parabolic wedge @@ -1520,9 +1520,9 @@ class MPrism18 : public MPrism { MVertex *_vs[12]; public : MPrism18(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, - MVertex *v15, MVertex *v16, MVertex *v17, int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14, + MVertex *v15, MVertex *v16, MVertex *v17, int num=0, int part=0) : MPrism(v0, v1, v2, v3, v4, v5, num, part) { _vs[0] = v6; _vs[1] = v7; _vs[2] = v8; _vs[3] = v9; _vs[4] = v10; @@ -1573,7 +1573,7 @@ class MPrism18 : public MPrism { {5, 14, 17}, {5, 17, 11}, {4, 10, 17}, {4, 17, 14} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_PRI_18; } virtual int getTypeForUNV(){ return 0; } // not available @@ -1598,7 +1598,7 @@ class MPyramid : public MElement { MVertex *_v[5]; public : MPyramid(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - int num=0, int part=0) + int num=0, int part=0) : MElement(num, part) { _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[4] = v4; @@ -1645,8 +1645,8 @@ class MPyramid : public MElement { }; if(num < 4) return MFace(_v[faces_pyramid[num][0]], - _v[faces_pyramid[num][1]], - _v[faces_pyramid[num][2]]); + _v[faces_pyramid[num][1]], + _v[faces_pyramid[num][2]]); else return MFace(_v[0], _v[3], _v[2], _v[1]); } @@ -1661,7 +1661,7 @@ class MPyramid : public MElement { {0, 3, 2}, {0, 2, 1} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_PYR_5; } virtual int getTypeForUNV(){ return 0; } // not available @@ -1696,11 +1696,11 @@ class MPyramid : public MElement { else{ switch(num) { case 0 : s[0] = 0.25 * (-(1. - v) + v * w / (1. - w)); - s[1] = 0.25 * (-(1. - u) + u * w / (1. - w)); - s[2] = 0.25 * (-1. + u * v / (1. - w) / (1. - w)); break; + s[1] = 0.25 * (-(1. - u) + u * w / (1. - w)); + s[2] = 0.25 * (-1. + u * v / (1. - w) / (1. - w)); break; case 1 : s[0] = 0.25 * ( (1. - v) + v * w / (1. - w)); - s[1] = 0.25 * (-(1. + u) + u * w / (1. - w)); - s[2] = 0.25 * (-1. + u * v / (1. - w) / (1. - w)); break; + s[1] = 0.25 * (-(1. + u) + u * w / (1. - w)); + s[2] = 0.25 * (-1. + u * v / (1. - w) / (1. - w)); break; case 2 : s[0] = 0.25 * ( (1. + v) + v * w / (1. - w)); s[1] = 0.25 * ( (1. + u) + u * w / (1. - w)); s[2] = 0.25 * (-1. + u * v / (1. - w) / (1. - w)); break; @@ -1728,8 +1728,8 @@ class MPyramid13 : public MPyramid { MVertex *_vs[8]; public : MPyramid13(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - MVertex *v10, MVertex *v11, MVertex *v12, int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + MVertex *v10, MVertex *v11, MVertex *v12, int num=0, int part=0) : MPyramid(v0, v1, v2, v3, v4, num, part) { _vs[0] = v5; _vs[1] = v6; _vs[2] = v7; _vs[3] = v8; _vs[4] = v9; @@ -1774,7 +1774,7 @@ class MPyramid13 : public MPyramid { {0, 6, 5}, {3, 10, 6}, {2, 8, 10}, {1, 5, 8}, {5, 6, 10}, {5, 10, 8} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_PYR_13; } virtual int getTypeForUNV(){ return 0; } // not available @@ -1795,9 +1795,9 @@ class MPyramid14 : public MPyramid { MVertex *_vs[9]; public : MPyramid14(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, - MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, - MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, - int num=0, int part=0) + MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9, + MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, + int num=0, int part=0) : MPyramid(v0, v1, v2, v3, v4, num, part) { _vs[0] = v5; _vs[1] = v6; _vs[2] = v7; _vs[3] = v8; _vs[4] = v9; @@ -1844,7 +1844,7 @@ class MPyramid14 : public MPyramid { {2, 8, 13}, {2, 13, 10}, {1, 5, 13}, {1, 13, 8} }; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), - x, y, z, n); + x, y, z, n); } virtual int getTypeForMSH(){ return MSH_PYR_14; } virtual int getTypeForUNV(){ return 0; } // not available diff --git a/Geo/MFace.cpp b/Geo/MFace.cpp index 8c38d5ba96a0bc22b69346b96ecd5e60ee574fa2..795c38608f3e350fec2ee5d8a8ebb2e8ccfb64e8 100644 --- a/Geo/MFace.cpp +++ b/Geo/MFace.cpp @@ -70,11 +70,11 @@ MFace::MFace(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3) if(_v[3] < _v[int(_si[1])]) { _si[2] = _si[1]; if(_v[3] < _v[int(_si[0])]) { - _si[1] = _si[0]; - _si[0] = 3; + _si[1] = _si[0]; + _si[0] = 3; } else - _si[1] = 3; + _si[1] = 3; } else _si[2] = 3; @@ -87,8 +87,8 @@ SVector3 MFace::normal() const { double n[3]; normal3points(_v[0]->x(), _v[0]->y(), _v[0]->z(), - _v[1]->x(), _v[1]->y(), _v[1]->z(), - _v[2]->x(), _v[2]->y(), _v[2]->z(), n); + _v[1]->x(), _v[1]->y(), _v[1]->z(), + _v[2]->x(), _v[2]->y(), _v[2]->z(), n); return SVector3(n[0], n[1], n[2]); } diff --git a/Geo/MFace.h b/Geo/MFace.h index 7131893451577cae80dba860f04a5631612af4e1..2a0146ca35794982f59e0e7e511b14ab823c195a 100644 --- a/Geo/MFace.h +++ b/Geo/MFace.h @@ -52,8 +52,8 @@ class MFace { SVector3 tangent(int num) const { SVector3 t0(_v[1]->x() - _v[0]->x(), - _v[1]->y() - _v[0]->y(), - _v[1]->z() - _v[0]->z()); + _v[1]->y() - _v[0]->y(), + _v[1]->z() - _v[0]->z()); t0.normalize(); if(!num) return t0; SVector3 n = normal(); @@ -82,23 +82,23 @@ class MFace { if(n == 3){ const double ff[3] = {1. - u - v, u, v}; for(int i = 0; i < n; i++) { - MVertex *v = getVertex(i); - p[0] += v->x() * ff[i]; - p[1] += v->y() * ff[i]; - p[2] += v->z() * ff[i]; + MVertex *v = getVertex(i); + p[0] += v->x() * ff[i]; + p[1] += v->y() * ff[i]; + p[2] += v->z() * ff[i]; } } else if(n == 4){ const double ff[4] = {(1 - u) * (1. - v), - (1 + u) * (1. - v), - (1 + u) * (1. + v), - (1 - u) * (1. + v)}; + (1 + u) * (1. - v), + (1 + u) * (1. + v), + (1 - u) * (1. + v)}; for(int i = 0; i < n; i++) { - MVertex *v = getVertex(i); - p[0] += v->x() * ff[i] * .25; - p[1] += v->y() * ff[i] * .25; - p[2] += v->z() * ff[i] * .25; - } + MVertex *v = getVertex(i); + p[0] += v->x() * ff[i] * .25; + p[1] += v->y() * ff[i] * .25; + p[2] += v->z() * ff[i] * .25; + } } else throw; return p; diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 90e30d5200a3336c0c807722e2a922f89f9b6b58..503707c27af90f18b1389da5f96074416a24e890 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -1,4 +1,4 @@ -// $Id: MVertex.cpp,v 1.21 2008-02-18 18:46:49 geuzaine Exp $ +// $Id: MVertex.cpp,v 1.22 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -50,9 +50,9 @@ void MVertex::writeMSH(FILE *fp, bool binary, double scalingFactor) if(!binary){ fprintf(fp, "%d %.16g %.16g %.16g\n", _num, - x() * scalingFactor, - y() * scalingFactor, - z() * scalingFactor); + x() * scalingFactor, + y() * scalingFactor, + z() * scalingFactor); } else{ fwrite(&_num, sizeof(int), 1, fp); @@ -62,7 +62,7 @@ void MVertex::writeMSH(FILE *fp, bool binary, double scalingFactor) } void MVertex::writeMSH(FILE *fp, double version, bool binary, int num, - int elementary, int physical) + int elementary, int physical) { if(!binary){ fprintf(fp, "%d 15", num); @@ -85,7 +85,7 @@ void MVertex::writeVRML(FILE *fp, double scalingFactor) if(_num < 0) return; // negative vertices are never saved fprintf(fp, "%.16g %.16g %.16g,\n", - x() * scalingFactor, y() * scalingFactor, z() * scalingFactor); + x() * scalingFactor, y() * scalingFactor, z() * scalingFactor); } void MVertex::writeUNV(FILE *fp, double scalingFactor) @@ -99,7 +99,7 @@ void MVertex::writeUNV(FILE *fp, double scalingFactor) // hack to print the numbers with "D+XX" exponents char tmp[128]; sprintf(tmp, "%25.16E%25.16E%25.16E\n", x() * scalingFactor, - y() * scalingFactor, z() * scalingFactor); + y() * scalingFactor, z() * scalingFactor); for(unsigned int i = 0; i < strlen(tmp); i++) if(tmp[i] == 'E') tmp[i] = 'D'; fprintf(fp, tmp); } @@ -109,7 +109,7 @@ void MVertex::writeMESH(FILE *fp, double scalingFactor) if(_num < 0) return; // negative vertices are never saved fprintf(fp, " %20.14G %20.14G %20.14G %d\n", - x() * scalingFactor, y() * scalingFactor, z() * scalingFactor, 0); + x() * scalingFactor, y() * scalingFactor, z() * scalingFactor, 0); } static void double_to_char8(double val, char *str) @@ -180,7 +180,7 @@ void parametricCoordinates(const MVertex *ver, const GFace *gf, double &u, doubl GEntity *ge = ver->onWhat(); if(ge->dim() == 2){ ver->getParameter(0, u); - ver->getParameter(1, v); + ver->getParameter(1, v); } else if(ge->dim() == 1){ double t; diff --git a/Geo/MVertex.h b/Geo/MVertex.h index 1ed03d5361b538478ff9cc90eee655c30c8a561b..142f03e88778893c5bec6ee23700f91a32e47c94 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -111,7 +111,7 @@ class MVertex{ // IO routines void writeMSH(FILE *fp, bool binary=false, double scalingFactor=1.0); void writeMSH(FILE *fp, double version, bool binary, int num, - int elementary, int physical); + int elementary, int physical); void writeVRML(FILE *fp, double scalingFactor=1.0); void writeUNV(FILE *fp, double scalingFactor=1.0); void writeMESH(FILE *fp, double scalingFactor=1.0); diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp index 0d68fee52f955049a9f8b031fd32394d0af5cb8a..f4be162722a387436a78de22d8c0314196333740 100644 --- a/Geo/OCCEdge.cpp +++ b/Geo/OCCEdge.cpp @@ -1,4 +1,4 @@ -// $Id: OCCEdge.cpp,v 1.36 2008-02-23 17:43:54 geuzaine Exp $ +// $Id: OCCEdge.cpp,v 1.37 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -77,7 +77,7 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar, int dir) const if(c2d.IsNull()){ Msg(FATAL,"Reparam on face failed: curve %d is not on surface %d", - tag(), face->tag()); + tag(), face->tag()); } double u, v; @@ -93,11 +93,11 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar, int dir) const if(sqrt(dx * dx + dy * dy + dz * dz) > 1.e-4 * CTX.lc){ // return reparamOnFace(face, epar,-1); Msg(WARNING, "Reparam on face partially failed for curve %d surface %d at point %g", - tag(), face->tag(), epar); + tag(), face->tag(), epar); Msg(WARNING, "On the face %d local (%g %g) global (%g %g %g)", - face->tag(), u, v, p2.x(), p2.y(), p2.z()); + face->tag(), u, v, p2.x(), p2.y(), p2.z()); Msg(WARNING, "On the edge %d local (%g) global (%g %g %g)", - tag(), epar, p1.x(), p1.y(), p1.z()); + tag(), epar, p1.x(), p1.y(), p1.z()); // GPoint ppp = face->closestPoint(SPoint3(p1.x(), p1.y(), p1.z())); // return SPoint2(ppp.u(), ppp.v()); } diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index bb6d3d9a6482d0ce8684ef7b07c413f1ca2d8b56..05c14c22175c9915b2d41eac7795d5de58bcb3b5 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -1,4 +1,4 @@ -// $Id: OCCFace.cpp,v 1.38 2008-02-23 16:19:22 remacle Exp $ +// $Id: OCCFace.cpp,v 1.39 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -49,7 +49,7 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape Msg(DEBUG2,"OCC Face %d - New Wire",num); std::list<GEdge*> l_wire; std::list<int> l_oris; - for(exp3.Init(wire, TopAbs_EDGE); exp3.More(); exp3.Next()){ + for(exp3.Init(wire, TopAbs_EDGE); exp3.More(); exp3.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp3.Current()); int index = emap.FindIndex(edge); GEdge *e = m->getEdgeByTag(index); @@ -59,8 +59,8 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape Msg(DEBUG2, "Edge %d ori %d", e->tag(), edge.Orientation()); e->addFace(this); if(!e->is3D()){ - OCCEdge *occe = (OCCEdge*)e; - occe->setTrimmed(this); + OCCEdge *occe = (OCCEdge*)e; + occe->setTrimmed(this); } } @@ -71,12 +71,12 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape l_edges.push_back(it->ge); l_dirs.push_back(it->_sign); if (el.count() == 2){ - it->ge->meshAttributes.minimumMeshSegments = - std::max(it->ge->meshAttributes.minimumMeshSegments,2); + it->ge->meshAttributes.minimumMeshSegments = + std::max(it->ge->meshAttributes.minimumMeshSegments,2); } if (el.count() == 1){ - it->ge->meshAttributes.minimumMeshSegments = - std::max(it->ge->meshAttributes.minimumMeshSegments,3); + it->ge->meshAttributes.minimumMeshSegments = + std::max(it->ge->meshAttributes.minimumMeshSegments,3); } } @@ -133,7 +133,7 @@ Pair<SVector3,SVector3> OCCFace::firstDer(const SPoint2 ¶m) const occface->D1(param.x(), param.y(), pnt, du, dv); return Pair<SVector3,SVector3>(SVector3(du.X(), du.Y(), du.Z()), - SVector3(dv.X(), dv.Y(), dv.Z())); + SVector3(dv.X(), dv.Y(), dv.Z())); } GPoint OCCFace::point(double par1, double par2) const @@ -229,23 +229,23 @@ int OCCFace::containsPoint(const SPoint3 &pt) const GEdge *c = *it; int ori = 1; if(ito != l_dirs.end()){ - ori = *ito; - ++ito; + ori = *ito; + ++ito; } int N = 10; Range<double> range = c->parBounds(0); for(int j = 0; j < N ; j++) { - double u1 = (double)j / (double)N; - double u2 = (double)(j + 1) / (double)N; - if(ori < 0){ - u1 = 1. - u1; - u2 = 1. - u2; - } - GPoint pp1 = c->point(range.low() + u1 * (range.high() - range.low())); - GPoint pp2 = c->point(range.low() + u2 * (range.high() - range.low())); - double v1[3] = {pp1.x(), pp1.y(), pp1.z()}; - double v2[3] = {pp2.x(), pp2.y(), pp2.z()}; - angle += angle_plan(v, v1, v2, n); + double u1 = (double)j / (double)N; + double u2 = (double)(j + 1) / (double)N; + if(ori < 0){ + u1 = 1. - u1; + u2 = 1. - u2; + } + GPoint pp1 = c->point(range.low() + u1 * (range.high() - range.low())); + GPoint pp2 = c->point(range.low() + u2 * (range.high() - range.low())); + double v1[3] = {pp1.x(), pp1.y(), pp1.z()}; + double v2[3] = {pp2.x(), pp2.y(), pp2.z()}; + angle += angle_plan(v, v1, v2, n); } } // we're inside if angle equals 2 * pi @@ -301,7 +301,7 @@ bool OCCFace::buildSTLTriangulation() aCoeff = 0.01; aDiscret = aCoeff * dMax; BRepMesh_FastDiscret aMesher(aDiscret, 0.5, aBox, bWithShare, Standard_True, - Standard_False, Standard_True); + Standard_False, Standard_True); aMesher.Add(s); Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(s, loc); if (triangulation.IsNull()){ diff --git a/Geo/OCCRegion.cpp b/Geo/OCCRegion.cpp index ab9ba07ce0e7273817cadb9fd095ab18291efc2c..a5c164ef9599db5d9c720855d6d55c20a7617977 100644 --- a/Geo/OCCRegion.cpp +++ b/Geo/OCCRegion.cpp @@ -1,4 +1,4 @@ -// $Id: OCCRegion.cpp,v 1.10 2008-02-22 21:09:00 geuzaine Exp $ +// $Id: OCCRegion.cpp,v 1.11 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -35,7 +35,7 @@ OCCRegion::OCCRegion(GModel *m, TopoDS_Solid _s, int num, TopTools_IndexedMapOfS for(exp2.Init(s, TopAbs_SHELL); exp2.More(); exp2.Next()){ TopoDS_Shape shell = exp2.Current(); Msg(INFO,"OCC Region %d - New Shell",num); - for(exp3.Init(shell, TopAbs_FACE); exp3.More(); exp3.Next()){ + for(exp3.Init(shell, TopAbs_FACE); exp3.More(); exp3.Next()){ TopoDS_Face face = TopoDS::Face(exp3.Current()); int index = fmap.FindIndex(face); GFace *f = m->getFaceByTag(index); diff --git a/Geo/OCCVertex.cpp b/Geo/OCCVertex.cpp index be44b9abbf1d1d1ac3f504da6af300b95dd6c93b..a9c0dada6be0a0975df73062a50abe8eedb281b5 100644 --- a/Geo/OCCVertex.cpp +++ b/Geo/OCCVertex.cpp @@ -1,4 +1,4 @@ -// $Id: OCCVertex.cpp,v 1.14 2008-02-17 08:47:59 geuzaine Exp $ +// $Id: OCCVertex.cpp,v 1.15 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -27,7 +27,7 @@ #if defined(HAVE_OCC) double max_surf_curvature(const GVertex *gv, double x, double y, double z, - const GEdge *_myGEdge) + const GEdge *_myGEdge) { std::list<GFace *> faces = _myGEdge->faces(); std::list<GFace *>::iterator it = faces.begin(); @@ -45,9 +45,9 @@ double OCCVertex::max_curvature_of_surfaces() const { if(max_curvature < 0){ for(std::list<GEdge*>::const_iterator it = l_edges.begin(); - it != l_edges.end(); ++it){ + it != l_edges.end(); ++it){ max_curvature = std::max(max_surf_curvature(this, x(), y(), z(), *it), - max_curvature); + max_curvature); } // printf("max curvature (%d) = %12.5E lc = %12.5E\n",tag(), // max_curvature, prescribedMeshSizeAtVertex()); @@ -62,14 +62,14 @@ SPoint2 OCCVertex::reparamOnFace(GFace *gf, int dir) const std::list<GEdge*> l_edges = gf->edges(); if(std::find(l_edges.begin(),l_edges.end(),*it) != l_edges.end()){ if((*it)->isSeam(gf)){ - const TopoDS_Face *s = (TopoDS_Face*)gf->getNativePtr(); - const TopoDS_Edge *c = (TopoDS_Edge*)(*it)->getNativePtr(); - double s1,s0; - Handle(Geom2d_Curve) curve2d = BRep_Tool::CurveOnSurface(*c, *s, s0, s1); - if((*it)->getBeginVertex() == this) - return (*it)->reparamOnFace(gf, s0, dir); - else if((*it)->getEndVertex() == this) - return (*it)->reparamOnFace(gf, s1, dir); + const TopoDS_Face *s = (TopoDS_Face*)gf->getNativePtr(); + const TopoDS_Edge *c = (TopoDS_Edge*)(*it)->getNativePtr(); + double s1,s0; + Handle(Geom2d_Curve) curve2d = BRep_Tool::CurveOnSurface(*c, *s, s0, s1); + if((*it)->getBeginVertex() == this) + return (*it)->reparamOnFace(gf, s0, dir); + else if((*it)->getEndVertex() == this) + return (*it)->reparamOnFace(gf, s1, dir); } } ++it; @@ -83,9 +83,9 @@ SPoint2 OCCVertex::reparamOnFace(GFace *gf, int dir) const double s1,s0; Handle(Geom2d_Curve) curve2d = BRep_Tool::CurveOnSurface(*c, *s, s0, s1); if((*it)->getBeginVertex() == this) - return (*it)->reparamOnFace(gf, s0, dir); + return (*it)->reparamOnFace(gf, s0, dir); else if((*it)->getEndVertex() == this) - return (*it)->reparamOnFace(gf, s1, dir); + return (*it)->reparamOnFace(gf, s1, dir); } ++it; } diff --git a/Geo/SVector3.h b/Geo/SVector3.h index 7b01fcd39477a4f3897da1cd800c4fd82b40e1f1..5e473872777d9d29cee71347ea53112d7795b800 100644 --- a/Geo/SVector3.h +++ b/Geo/SVector3.h @@ -83,8 +83,8 @@ inline double norm(const SVector3 &v) inline SVector3 crossprod(const SVector3 &a, const SVector3 &b) { return SVector3(a.y() * b.z() - b.y() * a.z(), - -(a.x() * b.z() - b.x() * a.z()), - a.x() * b.y() - b.x() * a.y()); } + -(a.x() * b.z() - b.x() * a.z()), + a.x() * b.y() - b.x() * a.y()); } inline SVector3 operator*(double m,const SVector3 &v) { return SVector3(v[0] * m, v[1] * m, v[2] * m); } diff --git a/Geo/findLinks.cpp b/Geo/findLinks.cpp index ea991353b9d4e95a8b277c9336a37c1e31d6d951..7f6841ccc7a04c2f8771877366bca4fba8217867 100644 --- a/Geo/findLinks.cpp +++ b/Geo/findLinks.cpp @@ -1,4 +1,4 @@ -// $Id: findLinks.cpp,v 1.6 2008-02-22 21:09:00 geuzaine Exp $ +// $Id: findLinks.cpp,v 1.7 2008-03-20 11:44:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -46,7 +46,7 @@ static int complink(const void *a, const void *b) // to do multi-level, user-friendly undos in the GUI) static void recurFindLinkedEdges(int ed, List_T *edges, Tree_T *points, - Tree_T *links) + Tree_T *links) { GEdge *ge = GModel::current()->getEdgeByTag(ed); if(!ge){ @@ -68,14 +68,14 @@ static void recurFindLinkedEdges(int ed, List_T *edges, Tree_T *points, Tree_Query(links, &lk); if(List_Nbr(lk.l) == 2) { for(int i = 0; i < 2; i++) { - nxa na; - List_Read(lk.l, i, &na); - if(na.a != ed) { - if(List_ISearchSeq(edges, &na.a, fcmp_absint) < 0){ - List_Add(edges, &na.a); - recurFindLinkedEdges(na.a, edges, points, links); - } - } + nxa na; + List_Read(lk.l, i, &na); + if(na.a != ed) { + if(List_ISearchSeq(edges, &na.a, fcmp_absint) < 0){ + List_Add(edges, &na.a); + recurFindLinkedEdges(na.a, edges, points, links); + } + } } } } @@ -97,16 +97,16 @@ static int createEdgeLinks(Tree_T *links) ip[0] = ge->getBeginVertex()->tag(); ip[1] = ge->getEndVertex()->tag(); for(int k = 0; k < 2; k++){ - lnk li, *pli; - li.n = ip[k]; - if((pli = (lnk*)Tree_PQuery(links, &li))) { - List_Add(pli->l, &na); - } - else { - li.l = List_Create(20, 1, sizeof(nxa)); - List_Add(li.l, &na); - Tree_Add(links, &li); - } + lnk li, *pli; + li.n = ip[k]; + if((pli = (lnk*)Tree_PQuery(links, &li))) { + List_Add(pli->l, &na); + } + else { + li.l = List_Create(20, 1, sizeof(nxa)); + List_Add(li.l, &na); + Tree_Add(links, &li); + } } } } @@ -141,22 +141,22 @@ static void orientAndSortEdges(List_T *edges, Tree_T *links) nxa na; List_Read(lk.l, j, &na); if(ge0->tag() != na.a && List_Search(temp, &na.a, fcmp_absint)){ - GEdge *ge1 = GModel::current()->getEdgeByTag(abs(na.a)); - if(!ge1){ - Msg(GERROR, "Unknown curve %d", abs(na.a)); - return; - } - if(lk.n == ge1->getBeginVertex()->tag()){ - sign = 1; - num = na.a; - } - else{ - sign = -1; - num = -na.a; - } - List_Add(edges, &num); - ge0 = ge1; - break; + GEdge *ge1 = GModel::current()->getEdgeByTag(abs(na.a)); + if(!ge1){ + Msg(GERROR, "Unknown curve %d", abs(na.a)); + return; + } + if(lk.n == ge1->getBeginVertex()->tag()){ + sign = 1; + num = na.a; + } + else{ + sign = -1; + num = -na.a; + } + List_Add(edges, &num); + ge0 = ge1; + break; } } } @@ -186,9 +186,9 @@ int allEdgesLinked(int ed, List_T *edges) ip[1] = ge->getEndVertex()->tag(); for(int k = 0; k < 2; k++){ if(!Tree_Search(points, &ip[k])) - Tree_Add(points, &ip[k]); + Tree_Add(points, &ip[k]); else - Tree_Suppress(points, &ip[k]); + Tree_Suppress(points, &ip[k]); } } @@ -218,7 +218,7 @@ int allEdgesLinked(int ed, List_T *edges) // Find all linked faces static void recurFindLinkedFaces(int fac, List_T *faces, Tree_T *edges, - Tree_T *links) + Tree_T *links) { GFace *gf = GModel::current()->getFaceByTag(abs(fac)); if(!gf){ @@ -238,14 +238,14 @@ static void recurFindLinkedFaces(int fac, List_T *faces, Tree_T *edges, Tree_Query(links, &lk); if(List_Nbr(lk.l) == 2) { for(int i = 0; i < 2; i++) { - nxa na; + nxa na; List_Read(lk.l, i, &na); if(na.a != fac) { if(List_ISearchSeq(faces, &na.a, fcmp_absint) < 0){ - List_Add(faces, &na.a); - recurFindLinkedFaces(na.a, faces, edges, links); - } - } + List_Add(faces, &na.a); + recurFindLinkedFaces(na.a, faces, edges, links); + } + } } } } @@ -261,17 +261,17 @@ static void createFaceLinks(Tree_T *links) na.a = gf->tag(); std::list<GEdge*> l = gf->edges(); for(std::list<GEdge*>::iterator ite = l.begin(); ite != l.end(); ite++) { - GEdge *ge = *ite; - lnk li, *pli; - li.n = abs(ge->tag()); - if((pli = (lnk*)Tree_PQuery(links, &li))) { - List_Add(pli->l, &na); - } - else { - li.l = List_Create(20, 1, sizeof(nxa)); - List_Add(li.l, &na); - Tree_Add(links, &li); - } + GEdge *ge = *ite; + lnk li, *pli; + li.n = abs(ge->tag()); + if((pli = (lnk*)Tree_PQuery(links, &li))) { + List_Add(pli->l, &na); + } + else { + li.l = List_Create(20, 1, sizeof(nxa)); + List_Add(li.l, &na); + Tree_Add(links, &li); + } } } } @@ -298,9 +298,9 @@ int allFacesLinked(int fac, List_T *faces) GEdge *ge = *it; int ic = abs(ge->tag()); if(!Tree_Search(edges, &ic)) - Tree_Add(edges, &ic); + Tree_Add(edges, &ic); else - Tree_Suppress(edges, &ic); + Tree_Suppress(edges, &ic); } } diff --git a/Geo/fourierEdge.cpp b/Geo/fourierEdge.cpp index 5b18e2f752e240691c82adcf4a64f6e89e7da8f9..fd785e1901fe8f172bd5ec004959a97853a88717 100644 --- a/Geo/fourierEdge.cpp +++ b/Geo/fourierEdge.cpp @@ -6,7 +6,7 @@ extern Context_T CTX; #if defined(HAVE_FOURIER_MODEL) fourierEdge::fourierEdge(GModel *model, FM::TopoEdge* edge_, int tag, - GVertex *v0, GVertex *v1) + GVertex *v0, GVertex *v1) : GEdge(model, tag, v0, v1), edge(edge_) { //meshAttributes.Method = TRANSFINI; diff --git a/Geo/fourierFace.cpp b/Geo/fourierFace.cpp index ead0e16fd10ea852f16f1d999cec075e11cf5644..9a4081f696202b5e7d6be3d079840c807f41184f 100644 --- a/Geo/fourierFace.cpp +++ b/Geo/fourierFace.cpp @@ -6,7 +6,7 @@ #if defined(HAVE_FOURIER_MODEL) fourierFace::fourierFace(GModel *m, FM::TopoFace *face_, int tag, - std::list<GEdge*> l_edges_) + std::list<GEdge*> l_edges_) : GFace(m,tag), face(face_) { for (std::list<GEdge*>::iterator it = l_edges_.begin(); diff --git a/Geo/fourierProjectionFace.cpp b/Geo/fourierProjectionFace.cpp index 9a29c3b9498b3e454ad3dab63aff525205c9380b..081520429271dddc1a89fcbe7d7b584ec08959c0 100644 --- a/Geo/fourierProjectionFace.cpp +++ b/Geo/fourierProjectionFace.cpp @@ -35,7 +35,7 @@ Pair<SVector3,SVector3> fourierProjectionFace::firstDer(const SPoint2 ¶m) co } SVector3 fourierProjectionFace::normal(const SPoint2 ¶m) const -{ +{ double x, y, z; ps_->GetUnitNormal(param.x(),param.y(),x,y,z); return SVector3(x,y,z); diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp index d267fa83d23949eef5888482cfc54a1046e18be7..49f6f6ca041288e263cd3af6adf2ecd8b2871ea5 100644 --- a/Geo/gmshEdge.cpp +++ b/Geo/gmshEdge.cpp @@ -1,4 +1,4 @@ -// $Id: gmshEdge.cpp,v 1.47 2008-02-23 17:38:34 geuzaine Exp $ +// $Id: gmshEdge.cpp,v 1.48 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -111,7 +111,7 @@ int gmshEdge::minimumMeshSegments () const np = GEdge::minimumMeshSegments(); else if(geomType() == Circle || geomType() == Ellipse) np = (int)(fabs(c->Circle.t1 - c->Circle.t2) * - (double)CTX.mesh.min_circ_points / Pi) - 1; + (double)CTX.mesh.min_circ_points / Pi) - 1; else np = CTX.mesh.min_curv_points - 1; return std::max(np, meshAttributes.minimumMeshSegments); @@ -139,77 +139,77 @@ SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const switch (c->Typ) { case MSH_SEGM_LINE: { - Vertex *v[3]; - List_Read(c->Control_Points, 0, &v[1]); - List_Read(c->Control_Points, 1, &v[2]); - SPoint2 p = v[1]->pntOnGeometry + - (v[2]->pntOnGeometry - v[1]->pntOnGeometry) * epar; - return p; + Vertex *v[3]; + List_Read(c->Control_Points, 0, &v[1]); + List_Read(c->Control_Points, 1, &v[2]); + SPoint2 p = v[1]->pntOnGeometry + + (v[2]->pntOnGeometry - v[1]->pntOnGeometry) * epar; + return p; } case MSH_SEGM_BSPLN: case MSH_SEGM_BEZIER: { - int NbControlPoints = List_Nbr(c->Control_Points); - int NbCurves = NbControlPoints + (periodic ? -1 : 1); - int iCurve = (int)floor(epar * (double)NbCurves); - if(iCurve >= NbCurves) - iCurve = NbCurves - 1; - else if (iCurve < 0) // ? does it happen ? - iCurve = 0; - double t1 = (double)(iCurve) / (double)(NbCurves); - double t2 = (double)(iCurve+1) / (double)(NbCurves); - double t = (epar - t1) / (t2 - t1); - Vertex *v[4]; - for(int j = 0; j < 4; j ++ ){ - int k = iCurve - (periodic ? 1 : 2) + j; - if(k < 0) - k = periodic ? k + NbControlPoints - 1 : 0; - if(k >= NbControlPoints) - k = periodic ? k - NbControlPoints + 1: NbControlPoints - 1; - List_Read(c->Control_Points, k, &v[j]); - } - return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2, c->geometry); + int NbControlPoints = List_Nbr(c->Control_Points); + int NbCurves = NbControlPoints + (periodic ? -1 : 1); + int iCurve = (int)floor(epar * (double)NbCurves); + if(iCurve >= NbCurves) + iCurve = NbCurves - 1; + else if (iCurve < 0) // ? does it happen ? + iCurve = 0; + double t1 = (double)(iCurve) / (double)(NbCurves); + double t2 = (double)(iCurve+1) / (double)(NbCurves); + double t = (epar - t1) / (t2 - t1); + Vertex *v[4]; + for(int j = 0; j < 4; j ++ ){ + int k = iCurve - (periodic ? 1 : 2) + j; + if(k < 0) + k = periodic ? k + NbControlPoints - 1 : 0; + if(k >= NbControlPoints) + k = periodic ? k - NbControlPoints + 1: NbControlPoints - 1; + List_Read(c->Control_Points, k, &v[j]); + } + return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2, c->geometry); } case MSH_SEGM_SPLN : { - Vertex temp1, temp2; - int N = List_Nbr(c->Control_Points); - int i = (int)((double)(N - 1) * epar); - if(i < 0) - i = 0; - if(i >= N - 1) - i = N - 2; - double t1 = (double)(i) / (double)(N - 1); - double t2 = (double)(i + 1) / (double)(N - 1); - double t = (epar - t1) / (t2 - t1); - Vertex *v[4]; - List_Read(c->Control_Points, i, &v[1]); - List_Read(c->Control_Points, i + 1, &v[2]); - if(!i) { - if(c->beg == c->end){ - List_Read(c->Control_Points,N-2,&v[0]); - } - else{ - v[0] = &temp1; - v[0]->pntOnGeometry = v[1]->pntOnGeometry * 2. - v[2]->pntOnGeometry; - } - } - else{ - List_Read(c->Control_Points, i - 1, &v[0]); - } - if(i == N - 2) { - if(c->beg == c->end){ - List_Read(c->Control_Points,1,&v[3]); - } - else{ - v[3] = &temp2; - v[3]->pntOnGeometry = v[2]->pntOnGeometry * 2. - v[1]->pntOnGeometry; - } - } - else{ - List_Read(c->Control_Points, i + 2, &v[3]); - } - return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2, c->geometry); + Vertex temp1, temp2; + int N = List_Nbr(c->Control_Points); + int i = (int)((double)(N - 1) * epar); + if(i < 0) + i = 0; + if(i >= N - 1) + i = N - 2; + double t1 = (double)(i) / (double)(N - 1); + double t2 = (double)(i + 1) / (double)(N - 1); + double t = (epar - t1) / (t2 - t1); + Vertex *v[4]; + List_Read(c->Control_Points, i, &v[1]); + List_Read(c->Control_Points, i + 1, &v[2]); + if(!i) { + if(c->beg == c->end){ + List_Read(c->Control_Points,N-2,&v[0]); + } + else{ + v[0] = &temp1; + v[0]->pntOnGeometry = v[1]->pntOnGeometry * 2. - v[2]->pntOnGeometry; + } + } + else{ + List_Read(c->Control_Points, i - 1, &v[0]); + } + if(i == N - 2) { + if(c->beg == c->end){ + List_Read(c->Control_Points,1,&v[3]); + } + else{ + v[3] = &temp2; + v[3]->pntOnGeometry = v[2]->pntOnGeometry * 2. - v[1]->pntOnGeometry; + } + } + else{ + List_Read(c->Control_Points, i + 2, &v[3]); + } + return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2, c->geometry); } default: throw; diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp index d6c72bfd7392357cb8360394425d8907767f526e..684b750d87b02cf2c32c59f5a4436798eb68a130 100644 --- a/Geo/gmshFace.cpp +++ b/Geo/gmshFace.cpp @@ -1,4 +1,4 @@ -// $Id: gmshFace.cpp,v 1.54 2008-03-03 22:04:22 geuzaine Exp $ +// $Id: gmshFace.cpp,v 1.55 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -41,8 +41,8 @@ gmshFace::gmshFace(GModel *m, Surface *face) e->addFace(this); l_dirs.push_back((c->Num > 0) ? 1 : -1); if (List_Nbr(s->Generatrices) == 2){ - e->meshAttributes.minimumMeshSegments = - std::max(e->meshAttributes.minimumMeshSegments, 2); + e->meshAttributes.minimumMeshSegments = + std::max(e->meshAttributes.minimumMeshSegments, 2); } } else @@ -55,7 +55,7 @@ gmshFace::gmshFace(GModel *m, Surface *face) computeMeanPlane(); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) - s->plan[i][j] = meanPlane.plan[i][j]; + s->plan[i][j] = meanPlane.plan[i][j]; s->a = meanPlane.a; s->b = meanPlane.b; s->c = meanPlane.c; @@ -68,9 +68,9 @@ gmshFace::gmshFace(GModel *m, Surface *face) List_Read(s->EmbeddedCurves, i, &c); GEdge *e = m->getEdgeByTag(abs(c->Num)); if(e) - embedded_edges.push_back(e); + embedded_edges.push_back(e); else - Msg(GERROR, "Unknown curve %d", c->Num); + Msg(GERROR, "Unknown curve %d", c->Num); } } if(s->EmbeddedPoints){ @@ -79,9 +79,9 @@ gmshFace::gmshFace(GModel *m, Surface *face) List_Read(s->EmbeddedPoints, i, &v); GVertex *gv = m->getVertexByTag(v->Num); if(gv) - embedded_vertices.push_back(gv); + embedded_vertices.push_back(gv); else - Msg(GERROR, "Unknown point %d", v->Num); + Msg(GERROR, "Unknown point %d", v->Num); } } } @@ -116,9 +116,9 @@ void gmshFace::resetMeshAttributes() List_Read(s->TrsfPoints, i, &corn); GVertex *gv = model()->getVertexByTag(corn->Num); if(gv) - meshAttributes.corners.push_back(gv); + meshAttributes.corners.push_back(gv); else - Msg(GERROR, "Unknown vertex %d in transfinite attributes", corn->Num); + Msg(GERROR, "Unknown vertex %d in transfinite attributes", corn->Num); } } } @@ -155,13 +155,13 @@ SVector3 gmshFace::normal(const SPoint2 ¶m) const List_Read(s->Generatrices, i, &c); int N = (c->Typ == MSH_SEGM_LINE) ? 1 : 3; for(int j = 0; j < N; j++) { - double u1 = (double)j / (double)N; - double u2 = (double)(j + 1) / (double)N; - Vertex p1 = InterpolateCurve(c, u1, 0); - Vertex p2 = InterpolateCurve(c, u2, 0); - double v1[3] = {p1.Pos.X, p1.Pos.Y, p1.Pos.Z}; - double v2[3] = {p2.Pos.X, p2.Pos.Y, p2.Pos.Z}; - angle += angle_plan(v, v1, v2, n); + double u1 = (double)j / (double)N; + double u2 = (double)(j + 1) / (double)N; + Vertex p1 = InterpolateCurve(c, u1, 0); + Vertex p2 = InterpolateCurve(c, u2, 0); + double v1[3] = {p1.Pos.X, p1.Pos.Y, p1.Pos.Z}; + double v2[3] = {p2.Pos.X, p2.Pos.Y, p2.Pos.Z}; + angle += angle_plan(v, v1, v2, n); } } if(angle > 0) @@ -176,7 +176,7 @@ Pair<SVector3,SVector3> gmshFace::firstDer(const SPoint2 ¶m) const Vertex vu = InterpolateSurface(s, param[0], param[1], 1, 1); Vertex vv = InterpolateSurface(s, param[0], param[1], 1, 2); return Pair<SVector3, SVector3>(SVector3(vu.Pos.X, vu.Pos.Y, vu.Pos.Z), - SVector3(vv.Pos.X, vv.Pos.Y, vv.Pos.Z)); + SVector3(vv.Pos.X, vv.Pos.Y, vv.Pos.Z)); } GPoint gmshFace::point(double par1, double par2) const @@ -186,8 +186,8 @@ GPoint gmshFace::point(double par1, double par2) const double x, y, z, VX[3], VY[3]; getMeanPlaneData(VX, VY, x, y, z); return GPoint(x + VX[0] * par1 + VY[0] * par2, - y + VX[1] * par1 + VY[1] * par2, - z + VX[2] * par1 + VY[2] * par2, this, pp); + y + VX[1] * par1 + VY[1] * par2, + z + VX[2] * par1 + VY[2] * par2, this, pp); } else{ Vertex v = InterpolateSurface(s, par1, par2, 0, 0); @@ -247,13 +247,13 @@ int gmshFace::containsPoint(const SPoint3 &pt) const List_Read(s->Generatrices, i, &c); int N = (c->Typ == MSH_SEGM_LINE) ? 1 : 10; for(int j = 0; j < N; j++) { - double u1 = (double)j / (double)N; - double u2 = (double)(j + 1) / (double)N; - Vertex p1 = InterpolateCurve(c, u1, 0); - Vertex p2 = InterpolateCurve(c, u2, 0); - double v1[3] = {p1.Pos.X, p1.Pos.Y, p1.Pos.Z}; - double v2[3] = {p2.Pos.X, p2.Pos.Y, p2.Pos.Z}; - angle += angle_plan(v, v1, v2, n); + double u1 = (double)j / (double)N; + double u2 = (double)(j + 1) / (double)N; + Vertex p1 = InterpolateCurve(c, u1, 0); + Vertex p2 = InterpolateCurve(c, u2, 0); + double v1[3] = {p1.Pos.X, p1.Pos.Y, p1.Pos.Z}; + double v2[3] = {p2.Pos.X, p2.Pos.Y, p2.Pos.Z}; + angle += angle_plan(v, v1, v2, n); } } // we're inside if angle equals 2 * pi diff --git a/Geo/gmshRegion.cpp b/Geo/gmshRegion.cpp index 1d82195f9b4bcb991d93a267fd2c3a0c99b4fc12..44dda0ad020324be86b421def1ae5203e152882c 100644 --- a/Geo/gmshRegion.cpp +++ b/Geo/gmshRegion.cpp @@ -1,4 +1,4 @@ -// $Id: gmshRegion.cpp,v 1.20 2008-02-22 21:09:00 geuzaine Exp $ +// $Id: gmshRegion.cpp,v 1.21 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -66,9 +66,9 @@ void gmshRegion::resetMeshAttributes() List_Read(v->TrsfPoints, i, &corn); GVertex *gv = model()->getVertexByTag(corn->Num); if(gv) - meshAttributes.corners.push_back(gv); + meshAttributes.corners.push_back(gv); else - Msg(GERROR, "Unknown vertex %d in transfinite attributes", corn->Num); + Msg(GERROR, "Unknown vertex %d in transfinite attributes", corn->Num); } } } diff --git a/Geo/gmshSurface.cpp b/Geo/gmshSurface.cpp index 2030499965f92682481378f6b780cb9a502378b7..ad078bb8b81471ef29a0f6d814343abcdfbdbcc1 100644 --- a/Geo/gmshSurface.cpp +++ b/Geo/gmshSurface.cpp @@ -1,4 +1,4 @@ -// $Id: gmshSurface.cpp,v 1.12 2008-03-18 08:41:21 remacle Exp $ +// $Id: gmshSurface.cpp,v 1.13 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -60,7 +60,7 @@ SPoint3 gmshSphere::point(double par1, double par2) const } gmshSurface *gmshPolarSphere::NewPolarSphere(int iSphere, double x, double y, double z, - double r) + double r) { gmshPolarSphere *sph = new gmshPolarSphere(x, y, z, r); @@ -78,14 +78,14 @@ SPoint3 gmshPolarSphere::point(double parA, double parB) const //at the center of the sphere //parA=2rx/(r+z) parB=2ry/(r+z) double rp2 = parA * parA + parB * parB; - SPoint3 p(2*parA/(1+rp2),2*parB/(1+rp2),(rp2-1)/(rp2+1)); - p*=-r; - p+=o; - return p; + SPoint3 p(2*parA/(1+rp2),2*parB/(1+rp2),(rp2-1)/(rp2+1)); + p*=-r; + p+=o; + return p; } gmshSurface *gmshParametricSurface::NewParametricSurface(int iSurf, char *valX, - char *valY, char *valZ) + char *valY, char *valZ) { gmshParametricSurface *sph = new gmshParametricSurface(valX, valY, valZ); diff --git a/Geo/gmshSurface.h b/Geo/gmshSurface.h index 2e58b4704a5ada7e7376b1e772a408b1c2aa7807..b3857681c1a82e208f4dc854c877e590f4b9c2f6 100644 --- a/Geo/gmshSurface.h +++ b/Geo/gmshSurface.h @@ -106,7 +106,7 @@ public: class gmshPolarSphere : public gmshSurface { double r; - SPoint3 o; + SPoint3 o; gmshPolarSphere(double x, double y, double z, double _r) : o(x,y,z), r(_r){} public: static gmshSurface *NewPolarSphere(int _iSphere, double _x, double _y, double _z, double _r); diff --git a/Geo/gmshVertex.cpp b/Geo/gmshVertex.cpp index 92434803cfb03104e0f312724590266451b9a52c..be50cc0db04cf07752f032833cc86c8e86c4870c 100644 --- a/Geo/gmshVertex.cpp +++ b/Geo/gmshVertex.cpp @@ -1,4 +1,4 @@ -// $Id: gmshVertex.cpp,v 1.9 2008-02-17 08:47:59 geuzaine Exp $ +// $Id: gmshVertex.cpp,v 1.10 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -48,29 +48,29 @@ SPoint2 gmshVertex::reparamOnFace(GFace *face, int dir) const double U, V; if ((C[0]->beg == v && C[3]->beg == v) || - (C[0]->end == v && C[3]->beg == v) || - (C[0]->beg == v && C[3]->end == v) || - (C[0]->end == v && C[3]->end == v)){ + (C[0]->end == v && C[3]->beg == v) || + (C[0]->beg == v && C[3]->end == v) || + (C[0]->end == v && C[3]->end == v)){ U = V = 0; } else if ((C[0]->beg == v && C[1]->beg == v) || - (C[0]->end == v && C[1]->beg == v) || - (C[0]->beg == v && C[1]->end == v) || - (C[0]->end == v && C[1]->end == v)){ + (C[0]->end == v && C[1]->beg == v) || + (C[0]->beg == v && C[1]->end == v) || + (C[0]->end == v && C[1]->end == v)){ U = 1; V = 0; } else if ((C[2]->beg == v && C[1]->beg == v) || - (C[2]->end == v && C[1]->beg == v) || - (C[2]->beg == v && C[1]->end == v) || - (C[2]->end == v && C[1]->end == v)){ + (C[2]->end == v && C[1]->beg == v) || + (C[2]->beg == v && C[1]->end == v) || + (C[2]->end == v && C[1]->end == v)){ U = 1; V = 1; } else if ((C[2]->beg == v && C[3]->beg == v) || - (C[2]->end == v && C[3]->beg == v) || - (C[2]->beg == v && C[3]->end == v) || - (C[2]->end == v && C[3]->end == v)){ + (C[2]->end == v && C[3]->beg == v) || + (C[2]->beg == v && C[3]->end == v) || + (C[2]->end == v && C[3]->end == v)){ U = 0; V = 1; } diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp index d5d4266021eb690fb2c82cb1015e922223ed7d88..88ac0da096b49be8b13486a505bca125f899a015 100644 --- a/Graphics/Draw.cpp +++ b/Graphics/Draw.cpp @@ -1,4 +1,4 @@ -// $Id: Draw.cpp,v 1.117 2008-02-17 08:47:59 geuzaine Exp $ +// $Id: Draw.cpp,v 1.118 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -240,8 +240,8 @@ void InitProjection(int xpick, int ypick, int wpick, int hpick) glVertex3d(cx + r, cy, 0.); int ntheta = 36; for(int i = 1; i < ntheta + 1; i ++){ - double theta = i * 2 * M_PI / (double)ntheta; - glVertex3d(cx + r * cos(theta), cy + r * sin(theta), 0.); + double theta = i * 2 * M_PI / (double)ntheta; + glVertex3d(cx + r * cos(theta), cy + r * sin(theta), 0.); } glEnd(); } @@ -261,9 +261,9 @@ void InitRenderModel() for(int i = 0; i < 6; i++) { if(CTX.light[i]) { GLfloat position[4] = {(GLfloat)CTX.light_position[i][0], - (GLfloat)CTX.light_position[i][1], - (GLfloat)CTX.light_position[i][2], - (GLfloat)CTX.light_position[i][3]}; + (GLfloat)CTX.light_position[i][1], + (GLfloat)CTX.light_position[i][2], + (GLfloat)CTX.light_position[i][3]}; glLightfv((GLenum)(GL_LIGHT0 + i), GL_POSITION, position); r = CTX.UNPACK_RED(CTX.color.ambient_light[i])/255.; @@ -326,8 +326,8 @@ void InitPosition() glTranslated(CTX.cg[0], CTX.cg[1], CTX.cg[2]); else glTranslated(CTX.rotation_center[0], - CTX.rotation_center[1], - CTX.rotation_center[2]); + CTX.rotation_center[1], + CTX.rotation_center[2]); CTX.buildRotationMatrix(); glMultMatrixd(CTX.rot); @@ -336,8 +336,8 @@ void InitPosition() glTranslated(-CTX.cg[0], -CTX.cg[1], -CTX.cg[2]); else glTranslated(-CTX.rotation_center[0], - -CTX.rotation_center[1], - -CTX.rotation_center[2]); + -CTX.rotation_center[1], + -CTX.rotation_center[2]); // store the projection and modelview matrices at this precise // moment (so that we can use them at any later time, even if the diff --git a/Graphics/Draw.h b/Graphics/Draw.h index 8056e3c12a1af97792ea0425e7efe6652e168d1e..56952996b669abd2bb4728abfaff6eccc0525545 100644 --- a/Graphics/Draw.h +++ b/Graphics/Draw.h @@ -59,21 +59,21 @@ void Draw_Scales(); void Draw_Sphere(double size, double x, double y, double z, int light); void Draw_Cylinder(double width, double *x, double *y, double *z, int light); void Draw_TapCylinder(double width, double val1, double val2, double ValMin, - double ValMax, double *x, double *y, double *z, int light); + double ValMax, double *x, double *y, double *z, int light); void Draw_Vector(int Type, int Fill, - double relHeadRadius, double relStemLength, double relStemRadius, - double x, double y, double z, double dx, double dy, double dz, - int light); + double relHeadRadius, double relStemLength, double relStemRadius, + double x, double y, double z, double dx, double dy, double dz, + int light); void Draw_Box(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax, bool labels=true); + double xmax, double ymax, double zmax, bool labels=true); void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax, - double a, double b, double c, double d, int shade=0); + double xmax, double ymax, double zmax, + double a, double b, double c, double d, int shade=0); void Draw_SmallAxes(); void Draw_Axes(int mode, int tics[3], char format[3][256], char label[3][256], - double bbox[6],int mikado); + double bbox[6],int mikado); void Draw_Axes(int mode, int tics[3], char format[3][256], char label[3][256], - SBoundingBox3d &bbox,int mikado); + SBoundingBox3d &bbox,int mikado); #endif diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index e42ae750a99433e367c7057dc4ac1258c335ba81..5effa715b47bd8e6bf9ef99e4f3f69ece7f34c57 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.82 2008-02-17 08:47:59 geuzaine Exp $ +// $Id: Entity.cpp,v 1.83 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -65,8 +65,8 @@ void Draw_Sphere(double size, double x, double y, double z, int light) void Draw_TapCylinder(double width, double val1, double val2, - double ValMin, double ValMax, - double *x, double *y, double *z, int light) + double ValMin, double ValMax, + double *x, double *y, double *z, int light) { if(light) glEnable(GL_LIGHTING); @@ -157,10 +157,10 @@ void Draw_Line(int type, double width, double *x, double *y, double *z, } void Draw_SimpleVector(int arrow, int fill, - double relHeadRadius, double relStemLength, double relStemRadius, - double x, double y, double z, - double dx, double dy, double dz, - double d, int light) + double relHeadRadius, double relStemLength, double relStemRadius, + double x, double y, double z, + double dx, double dy, double dz, + double d, int light) { double n[3], t[3], u[3]; @@ -211,23 +211,23 @@ void Draw_SimpleVector(int arrow, int fill, if(light) glNormal3dv(u); glVertex3d(x + dx, y + dy, z + dz); glVertex3d(x + f2 * dx + b * (t[0]), y + f2 * dy + b * (t[1]), - z + f2 * dz + b * (t[2])); + z + f2 * dz + b * (t[2])); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f2 * dx + b * (-t[0]), y + f2 * dy + b * (-t[1]), - z + f2 * dz + b * (-t[2])); + z + f2 * dz + b * (-t[2])); glVertex3d(x + dx, y + dy, z + dz); if(light) glNormal3dv(t); glVertex3d(x + dx, y + dy, z + dz); glVertex3d(x + f2 * dx + b * (-u[0]), y + f2 * dy + b * (-u[1]), - z + f2 * dz + b * (-u[2])); + z + f2 * dz + b * (-u[2])); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f2 * dx + b * (u[0]), y + f2 * dy + b * (u[1]), - z + f2 * dz + b * (u[2])); + z + f2 * dz + b * (u[2])); glVertex3d(x + dx, y + dy, z + dz); glEnd(); glDisable(GL_LIGHTING); @@ -237,16 +237,16 @@ void Draw_SimpleVector(int arrow, int fill, glVertex3d(x, y, z); glVertex3d(x + dx, y + dy, z + dz); glVertex3d(x + f2 * dx + b * (t[0]), y + f2 * dy + b * (t[1]), - z + f2 * dz + b * (t[2])); + z + f2 * dz + b * (t[2])); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f2 * dx + b * (-t[0]), y + f2 * dy + b * (-t[1]), - z + f2 * dz + b * (-t[2])); + z + f2 * dz + b * (-t[2])); glVertex3d(x + dx, y + dy, z + dz); glVertex3d(x + f2 * dx + b * (-u[0]), y + f2 * dy + b * (-u[1]), - z + f2 * dz + b * (-u[2])); + z + f2 * dz + b * (-u[2])); glVertex3d(x + f1 * dx, y + f1 * dy, z + f1 * dz); glVertex3d(x + f2 * dx + b * (u[0]), y + f2 * dy + b * (u[1]), - z + f2 * dz + b * (u[2])); + z + f2 * dz + b * (u[2])); glVertex3d(x + dx, y + dy, z + dz); glEnd(); } @@ -263,36 +263,36 @@ void Draw_SimpleVector(int arrow, int fill, if(light && fill) glEnable(GL_LIGHTING); glBegin(GL_TRIANGLES); if(light){ - normal3points(tm[0], tm[1], tm[2], um[0], um[1], um[2], - top[0], top[1], top[2], nn); - glNormal3dv(nn); + normal3points(tm[0], tm[1], tm[2], um[0], um[1], um[2], + top[0], top[1], top[2], nn); + glNormal3dv(nn); } glVertex3d(tm[0], tm[1], tm[2]); glVertex3d(um[0], um[1], um[2]); glVertex3d(top[0], top[1], top[2]); if(light){ - normal3points(um[0], um[1], um[2], tp[0], tp[1], tp[2], - top[0], top[1], top[2], nn); - glNormal3dv(nn); + normal3points(um[0], um[1], um[2], tp[0], tp[1], tp[2], + top[0], top[1], top[2], nn); + glNormal3dv(nn); } glVertex3d(um[0], um[1], um[2]); glVertex3d(tp[0], tp[1], tp[2]); glVertex3d(top[0], top[1], top[2]); if(light){ - normal3points(tp[0], tp[1], tp[2], up[0], up[1], up[2], - top[0], top[1], top[2], nn); - glNormal3dv(nn); + normal3points(tp[0], tp[1], tp[2], up[0], up[1], up[2], + top[0], top[1], top[2], nn); + glNormal3dv(nn); } glVertex3d(tp[0], tp[1], tp[2]); glVertex3d(up[0], up[1], up[2]); glVertex3d(top[0], top[1], top[2]); if(light){ - normal3points(up[0], up[1], up[2], tm[0], tm[1], tm[2], - top[0], top[1], top[2], nn); - glNormal3dv(nn); + normal3points(up[0], up[1], up[2], tm[0], tm[1], tm[2], + top[0], top[1], top[2], nn); + glNormal3dv(nn); } glVertex3d(up[0], up[1], up[2]); glVertex3d(tm[0], tm[1], tm[2]); @@ -327,8 +327,8 @@ void Draw_SimpleVector(int arrow, int fill, } void Draw_3DArrow(double relHeadRadius, double relStemLength, double relStemRadius, - double x, double y, double z, double dx, double dy, double dz, - double length, int light) + double x, double y, double z, double dx, double dy, double dz, + double length, int light) { if(light) glEnable(GL_LIGHTING); @@ -379,7 +379,7 @@ void Draw_3DArrow(double relHeadRadius, double relStemLength, double relStemRadi } void Draw_Vector(int Type, int Fill, - double relHeadRadius, double relStemLength, double relStemRadius, + double relHeadRadius, double relStemLength, double relStemRadius, double x, double y, double z, double dx, double dy, double dz, int light) { @@ -396,16 +396,16 @@ void Draw_Vector(int Type, int Fill, break; case 2: Draw_SimpleVector(1, Fill, relHeadRadius, relStemLength, relStemRadius, - x, y, z, dx, dy, dz, length, light); + x, y, z, dx, dy, dz, length, light); break; case 3: Draw_SimpleVector(0, Fill, relHeadRadius, relStemLength, relStemRadius, - x, y, z, dx, dy, dz, length, light); + x, y, z, dx, dy, dz, length, light); break; case 4: default: Draw_3DArrow(relHeadRadius, relStemLength, relStemRadius, - x, y, z, dx, dy, dz, length, light); + x, y, z, dx, dy, dz, length, light); break; } } @@ -424,35 +424,35 @@ private: double _a, _b, _c, _d; public: plane(double a, double b, double c, double d) : - _a(a), _b(b), _c(c), _d(d) {;}; + _a(a), _b(b), _c(c), _d(d) {;}; double val(point &p){ - return _a*p.x + _b*p.y + _c*p.z + _d; + return _a*p.x + _b*p.y + _c*p.z + _d; }; point intersect(point &p1, point &p2){ - double v1 = val(p1), v2 = val(p2); - if(fabs(v1) < 1.e-12){ - if(fabs(v2) < 1.e-12) - return point(); - else - return point(p1.x, p1.y, p1.z); - } - else if(fabs(v2) < 1.e-12){ - return point(p2.x, p2.y, p2.z); - } - else if(v1 * v2 < 0.){ - double coef = - v1 / (v2 - v1); - return point(coef * (p2.x - p1.x) + p1.x, - coef * (p2.y - p1.y) + p1.y, - coef * (p2.z - p1.z) + p1.z); - } - else - return point(); + double v1 = val(p1), v2 = val(p2); + if(fabs(v1) < 1.e-12){ + if(fabs(v2) < 1.e-12) + return point(); + else + return point(p1.x, p1.y, p1.z); + } + else if(fabs(v2) < 1.e-12){ + return point(p2.x, p2.y, p2.z); + } + else if(v1 * v2 < 0.){ + double coef = - v1 / (v2 - v1); + return point(coef * (p2.x - p1.x) + p1.x, + coef * (p2.y - p1.y) + p1.y, + coef * (p2.z - p1.z) + p1.z); + } + else + return point(); }; }; void Draw_Box(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax, - bool labels) + double xmax, double ymax, double zmax, + bool labels) { glBegin(GL_LINE_LOOP); glVertex3d(xmin, ymin, zmin); @@ -480,22 +480,22 @@ void Draw_Box(double xmin, double ymin, double zmin, char label[256]; double offset = 0.3 * CTX.gl_fontsize * CTX.pixel_equiv_x; glRasterPos3d(xmin + offset / CTX.s[0], - ymin + offset / CTX.s[1], - zmin + offset / CTX.s[2]); + ymin + offset / CTX.s[1], + zmin + offset / CTX.s[2]); sprintf(label, "(%g,%g,%g)", xmin, ymin, zmin); Draw_String(label); glRasterPos3d(xmax + offset / CTX.s[0], - ymax + offset / CTX.s[1], - zmax + offset / CTX.s[2]); + ymax + offset / CTX.s[1], + zmax + offset / CTX.s[2]); sprintf(label, "(%g,%g,%g)", xmax, ymax, zmax); Draw_String(label); } } void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax, - double a, double b, double c, double d, - int shade) + double xmax, double ymax, double zmax, + double a, double b, double c, double d, + int shade) { plane pl(a, b, c, d); @@ -544,25 +544,25 @@ void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin, point p[4]; for(int j = 0; j < 4; j++){ if(edge[face[i][j]].valid == true) - p[nb++] = edge[face[i][j]]; + p[nb++] = edge[face[i][j]]; } if(nb > 1){ for(int j = 1; j < nb; j++){ - double xx[2] = {p[j].x, p[j-1].x}; - double yy[2] = {p[j].y, p[j-1].y}; - double zz[2] = {p[j].z, p[j-1].z}; - Draw_Cylinder(CTX.line_width, xx, yy, zz, 1); + double xx[2] = {p[j].x, p[j-1].x}; + double yy[2] = {p[j].y, p[j-1].y}; + double zz[2] = {p[j].z, p[j-1].z}; + Draw_Cylinder(CTX.line_width, xx, yy, zz, 1); } for(int j = 0; j < nb; j++){ - Draw_3DArrow(CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - p[j].x, p[j].y, p[j].z, n[0], n[1], n[2], length, 1); - if(shade){ - p_shade[n_shade].x = p[j].x; - p_shade[n_shade].y = p[j].y; - p_shade[n_shade].z = p[j].z; - n_shade++; - } + Draw_3DArrow(CTX.arrow_rel_head_radius, + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + p[j].x, p[j].y, p[j].z, n[0], n[1], n[2], length, 1); + if(shade){ + p_shade[n_shade].x = p[j].x; + p_shade[n_shade].y = p[j].y; + p_shade[n_shade].z = p[j].z; + n_shade++; + } } } } @@ -577,7 +577,7 @@ void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin, glNormal3d(n[0], n[1], n[2]); for(int j = 0; j < n_shade; j++){ glVertex3d(p_shade[j].x, p_shade[j].y, p_shade[j].z); - } + } glEnd(); glDisable(GL_LIGHTING); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, twoside); @@ -621,7 +621,7 @@ void Draw_SmallAxes() } int Draw_Tics(int comp, int n, char *format, char *label, - double p1[3], double p2[3], double perp[3], int mikado) + double p1[3], double p2[3], double perp[3], int mikado) { // draws n tic marks (in direction perp) and labels along the line p1->p2 @@ -666,13 +666,13 @@ int Draw_Tics(int comp, int n, char *format, char *label, 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, p1[1]+t[1]*dd, p1[2]+t[2]*dd }; - double qq[3] = { pp[0]+perp[0]*w2, pp[1]+perp[1]*w2, pp[2]+perp[2]*w2 }; - glBegin(GL_LINES); - glVertex3d(pp[0], pp[1], pp[2]); - glVertex3d(qq[0], qq[1], qq[2]); - glEnd(); + double dd = d + j * step/10.; + 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, pp[1]+perp[1]*w2, pp[2]+perp[2]*w2 }; + glBegin(GL_LINES); + glVertex3d(pp[0], pp[1], pp[2]); + glVertex3d(qq[0], qq[1], qq[2]); + glEnd(); } } @@ -716,20 +716,20 @@ void Draw_GridStipple(int n1, int n2, double p1[3], double p2[3], double p3[3]) 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); + 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, - p1[2] + t1[2]*d + t2[2]*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, - p1[2] + t2[2]*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, - p1[2] + t2[2]*d + t1[2]*l1); + p1[1] + t2[1]*d + t1[1]*l1, + p1[2] + t2[2]*d + t1[2]*l1); } glEnd(); @@ -738,23 +738,23 @@ void Draw_GridStipple(int n1, int n2, double p1[3], double p2[3], double p3[3]) } void Draw_Axes(int mode, int tics[3], char format[3][256], char label[3][256], - SBoundingBox3d &bb, int mikado) + SBoundingBox3d &bb, int mikado) { double bbox[6] = {bb.min().x(), bb.max().x(), - bb.min().y(), bb.max().y(), - bb.min().z(), bb.max().z()}; + bb.min().y(), bb.max().y(), + bb.min().z(), bb.max().z()}; Draw_Axes(mode, tics, format, label, bbox, mikado); } void Draw_Axe(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax, int nticks, int mikado) + 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, - (zmax - zmin) / nticks}; + (ymax - ymin) / nticks, + (zmax - zmin) / nticks}; double axe_color[4]; glGetDoublev(GL_CURRENT_COLOR, axe_color); for(int i = 1; i <= nticks; i++){ @@ -776,7 +776,7 @@ void Draw_Axe(double xmin, double ymin, double zmin, } void Draw_Axes(int mode, int tics[3], char format[3][256], char label[3][256], - double bb[6], int mikado) + double bb[6], int mikado) { // mode 0: nothing // 1: axes diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index 16c1c733ae02038ed277584b71e37a89d6d538a9..d8dff1b22888f24fd32e2e723e7432be85f5cad0 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.155 2008-02-23 10:43:44 geuzaine Exp $ +// $Id: Geom.cpp,v 1.156 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -37,7 +37,7 @@ void drawBBox(GEntity *e) gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); SBoundingBox3d bb = e->bounds(); Draw_Box(bb.min().x(), bb.min().y(), bb.min().z(), - bb.max().x(), bb.max().y(), bb.max().z()); + bb.max().x(), bb.max().y(), bb.max().z()); } class drawGVertex { @@ -66,24 +66,24 @@ class drawGVertex { if(CTX.geom.highlight_orphans){ std::list<GEdge*> edges = v->edges(); if(edges.size() == 0) - glColor4ubv((GLubyte *) & CTX.color.geom.highlight[0]); + glColor4ubv((GLubyte *) & CTX.color.geom.highlight[0]); else if(edges.size() == 1) - glColor4ubv((GLubyte *) & CTX.color.geom.highlight[1]); + glColor4ubv((GLubyte *) & CTX.color.geom.highlight[1]); } if(CTX.geom.points) { if(CTX.geom.point_type > 0) { - if(v->getSelection()) - Draw_Sphere(CTX.geom.point_sel_size, v->x(), v->y(), v->z(), - CTX.geom.light); - else - Draw_Sphere(CTX.geom.point_size, v->x(), v->y(), v->z(), - CTX.geom.light); + if(v->getSelection()) + Draw_Sphere(CTX.geom.point_sel_size, v->x(), v->y(), v->z(), + CTX.geom.light); + else + Draw_Sphere(CTX.geom.point_size, v->x(), v->y(), v->z(), + CTX.geom.light); } else { - glBegin(GL_POINTS); - glVertex3d(v->x(), v->y(), v->z()); - glEnd(); + glBegin(GL_POINTS); + glVertex3d(v->x(), v->y(), v->z()); + glEnd(); } } @@ -91,10 +91,10 @@ class drawGVertex { char Num[100]; sprintf(Num, "%d", v->tag()); double offset = (0.5 * CTX.geom.point_size + 0.3 * CTX.gl_fontsize) * - CTX.pixel_equiv_x; + CTX.pixel_equiv_x; glRasterPos3d(v->x() + offset / CTX.s[0], - v->y() + offset / CTX.s[1], - v->z() + offset / CTX.s[2]); + v->y() + offset / CTX.s[1], + v->z() + offset / CTX.s[2]); Draw_String(Num); } @@ -132,9 +132,9 @@ class drawGEdge { if(CTX.geom.highlight_orphans){ std::list<GFace*> faces = e->faces(); if(faces.size() == 0) - glColor4ubv((GLubyte *) & CTX.color.geom.highlight[0]); + glColor4ubv((GLubyte *) & CTX.color.geom.highlight[0]); else if(faces.size() == 1) - glColor4ubv((GLubyte *) & CTX.color.geom.highlight[1]); + glColor4ubv((GLubyte *) & CTX.color.geom.highlight[1]); } Range<double> t_bounds = e->parBounds(0); @@ -144,26 +144,26 @@ class drawGEdge { if(CTX.geom.lines) { int N = e->minimumDrawSegments() + 1; if(CTX.geom.line_type > 0) { - for(int i = 0; i < N - 1; i++) { - double t1 = t_min + (double)i / (double)(N - 1) * (t_max - t_min); - GPoint p1 = e->point(t1); - double t2 = t_min + (double)(i + 1) / (double)(N - 1) * (t_max - t_min); - GPoint p2 = e->point(t2); - double x[2] = {p1.x(), p2.x()}; - double y[2] = {p1.y(), p2.y()}; - double z[2] = {p1.z(), p2.z()}; - Draw_Cylinder(e->getSelection() ? CTX.geom.line_sel_width : - CTX.geom.line_width, x, y, z, CTX.geom.light); - } + for(int i = 0; i < N - 1; i++) { + double t1 = t_min + (double)i / (double)(N - 1) * (t_max - t_min); + GPoint p1 = e->point(t1); + double t2 = t_min + (double)(i + 1) / (double)(N - 1) * (t_max - t_min); + GPoint p2 = e->point(t2); + double x[2] = {p1.x(), p2.x()}; + double y[2] = {p1.y(), p2.y()}; + double z[2] = {p1.z(), p2.z()}; + Draw_Cylinder(e->getSelection() ? CTX.geom.line_sel_width : + CTX.geom.line_width, x, y, z, CTX.geom.light); + } } else { - glBegin(GL_LINE_STRIP); - for(int i = 0; i < N; i++) { - double t = t_min + (double)i / (double)(N - 1) * (t_max - t_min); - GPoint p = e->point(t); - glVertex3d(p.x(), p.y(), p.z()); - } - glEnd(); + glBegin(GL_LINE_STRIP); + for(int i = 0; i < N; i++) { + double t = t_min + (double)i / (double)(N - 1) * (t_max - t_min); + GPoint p = e->point(t); + glVertex3d(p.x(), p.y(), p.z()); + } + glEnd(); } } @@ -172,10 +172,10 @@ class drawGEdge { char Num[100]; sprintf(Num, "%d", e->tag()); double offset = (0.5 * CTX.geom.line_width + 0.3 * CTX.gl_fontsize) * - CTX.pixel_equiv_x; + CTX.pixel_equiv_x; glRasterPos3d(p.x() + offset / CTX.s[0], - p.y() + offset / CTX.s[1], - p.z() + offset / CTX.s[2]); + p.y() + offset / CTX.s[1], + p.z() + offset / CTX.s[2]); Draw_String(Num); } @@ -185,11 +185,11 @@ class drawGEdge { SVector3 der = e->firstDer(t); der.normalize(); for(int i = 0; i < 3; i++) - der[i] *= CTX.geom.tangents * CTX.pixel_equiv_x / CTX.s[i]; + der[i] *= CTX.geom.tangents * CTX.pixel_equiv_x / CTX.s[i]; glColor4ubv((GLubyte *) & CTX.color.geom.tangents); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - p.x(), p.y(), p.z(), der[0], der[1], der[2], CTX.geom.light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + p.x(), p.y(), p.z(), der[0], der[1], der[2], CTX.geom.light); } if(CTX.draw_bbox) drawBBox(e); @@ -204,7 +204,7 @@ class drawGEdge { class drawGFace { private: void _drawVertexArray(VertexArray *va, bool useNormalArray, int forceColor=0, - unsigned int color=0) + unsigned int color=0) { if(!va) return; glVertexPointer(3, GL_FLOAT, 0, va->getVertexArray()); @@ -246,33 +246,33 @@ class drawGFace { if(CTX.geom.surfaces){ if(CTX.geom.surface_type > 0 && f->va_geom_triangles){ - _drawVertexArray - (f->va_geom_triangles, CTX.geom.light, - (f->geomType() == GEntity::ProjectionFace) ? true : f->getSelection(), - (f->geomType() == GEntity::ProjectionFace) ? CTX.color.geom.projection : - CTX.color.geom.selection); + _drawVertexArray + (f->va_geom_triangles, CTX.geom.light, + (f->geomType() == GEntity::ProjectionFace) ? true : f->getSelection(), + (f->geomType() == GEntity::ProjectionFace) ? CTX.color.geom.projection : + CTX.color.geom.selection); } else{ - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0x1F1F); - gl2psEnable(GL2PS_LINE_STIPPLE); - int N = 20; - const double ud = (ubounds.high() - ubounds.low()); - const double vd = (vbounds.high() - vbounds.low()); - glBegin(GL_LINE_STRIP); - for(int i = 0; i < N; i++) { - GPoint p = f->point(ubounds.low() + ud * (double)i / (double)(N - 1), vav); - glVertex3d(p.x(), p.y(), p.z()); - } - glEnd(); - glBegin(GL_LINE_STRIP); - for(int i = 0; i < N; i++) { - GPoint p = f->point(uav, vbounds.low() + vd * (double)i / (double)(N - 1)); - glVertex3d(p.x(), p.y(), p.z()); - } - glEnd(); - glDisable(GL_LINE_STIPPLE); - gl2psDisable(GL2PS_LINE_STIPPLE); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0x1F1F); + gl2psEnable(GL2PS_LINE_STIPPLE); + int N = 20; + const double ud = (ubounds.high() - ubounds.low()); + const double vd = (vbounds.high() - vbounds.low()); + glBegin(GL_LINE_STRIP); + for(int i = 0; i < N; i++) { + GPoint p = f->point(ubounds.low() + ud * (double)i / (double)(N - 1), vav); + glVertex3d(p.x(), p.y(), p.z()); + } + glEnd(); + glBegin(GL_LINE_STRIP); + for(int i = 0; i < N; i++) { + GPoint p = f->point(uav, vbounds.low() + vd * (double)i / (double)(N - 1)); + glVertex3d(p.x(), p.y(), p.z()); + } + glEnd(); + glDisable(GL_LINE_STIPPLE); + gl2psDisable(GL2PS_LINE_STIPPLE); } } @@ -282,8 +282,8 @@ class drawGFace { sprintf(Num, "%d", f->tag()); double offset = 0.3 * CTX.gl_fontsize * CTX.pixel_equiv_x; glRasterPos3d(p.x() + offset / CTX.s[0], - p.y() + offset / CTX.s[1], - p.z() + offset / CTX.s[2]); + p.y() + offset / CTX.s[1], + p.z() + offset / CTX.s[2]); Draw_String(Num); } @@ -291,11 +291,11 @@ class drawGFace { GPoint p = f->point(uav, vav); SVector3 n = f->normal(SPoint2(uav, vav)); for(int i = 0; i < 3; i++) - n[i] *= CTX.geom.normals * CTX.pixel_equiv_x / CTX.s[i]; + n[i] *= CTX.geom.normals * CTX.pixel_equiv_x / CTX.s[i]; glColor4ubv((GLubyte *) & CTX.color.geom.normals); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - p.x(), p.y(), p.z(), n[0], n[1], n[2], CTX.geom.light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + p.x(), p.y(), p.z(), n[0], n[1], n[2], CTX.geom.light); } } void _drawPlaneGFace(GFace *f) @@ -307,54 +307,54 @@ class drawGFace { // redraw events are fired in rapid succession static bool busy = false; if(!f->cross.size() && !busy) { - busy = true; - f->buildRepresentationCross(); - busy = false; + busy = true; + f->buildRepresentationCross(); + busy = false; } } if(CTX.geom.surfaces) { if(CTX.geom.surface_type > 0 && f->va_geom_triangles){ - _drawVertexArray(f->va_geom_triangles, CTX.geom.light, - f->getSelection(), CTX.color.geom.selection); + _drawVertexArray(f->va_geom_triangles, CTX.geom.light, + f->getSelection(), CTX.color.geom.selection); } else{ - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0x1F1F); - gl2psEnable(GL2PS_LINE_STIPPLE); - glBegin(GL_LINES); - for(unsigned int i = 0; i < f->cross.size(); i++) - glVertex3d(f->cross[i].x(), f->cross[i].y(), f->cross[i].z()); - glEnd(); - glDisable(GL_LINE_STIPPLE); - gl2psDisable(GL2PS_LINE_STIPPLE); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0x1F1F); + gl2psEnable(GL2PS_LINE_STIPPLE); + glBegin(GL_LINES); + for(unsigned int i = 0; i < f->cross.size(); i++) + glVertex3d(f->cross[i].x(), f->cross[i].y(), f->cross[i].z()); + glEnd(); + glDisable(GL_LINE_STIPPLE); + gl2psDisable(GL2PS_LINE_STIPPLE); } } if(f->cross.size() < 2) return; - + if(CTX.geom.surfaces_num) { char Num[100]; sprintf(Num, "%d", f->tag()); double offset = 0.3 * CTX.gl_fontsize * CTX.pixel_equiv_x; glRasterPos3d(0.5 * (f->cross[0].x() + f->cross[1].x()) + offset / CTX.s[0], - 0.5 * (f->cross[0].y() + f->cross[1].y()) + offset / CTX.s[0], - 0.5 * (f->cross[0].z() + f->cross[1].z()) + offset / CTX.s[0]); + 0.5 * (f->cross[0].y() + f->cross[1].y()) + offset / CTX.s[0], + 0.5 * (f->cross[0].z() + f->cross[1].z()) + offset / CTX.s[0]); Draw_String(Num); } if(CTX.geom.normals) { SPoint3 p(0.5 * (f->cross[0].x() + f->cross[1].x()), - 0.5 * (f->cross[0].y() + f->cross[1].y()), - 0.5 * (f->cross[0].z() + f->cross[1].z())); + 0.5 * (f->cross[0].y() + f->cross[1].y()), + 0.5 * (f->cross[0].z() + f->cross[1].z())); SPoint2 uv = f->parFromPoint(p); SVector3 n = f->normal(uv); for(int i = 0; i < 3; i++) - n[i] *= CTX.geom.normals * CTX.pixel_equiv_x / CTX.s[i]; + n[i] *= CTX.geom.normals * CTX.pixel_equiv_x / CTX.s[i]; glColor4ubv((GLubyte *) & CTX.color.geom.normals); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - p.x(), p.y(), p.z(), n[0], n[1], n[2], CTX.geom.light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + p.x(), p.y(), p.z(), n[0], n[1], n[2], CTX.geom.light); } } @@ -373,7 +373,7 @@ public : if(f->getSelection()) { glLineWidth(CTX.geom.line_sel_width / 2.); gl2psLineWidth(CTX.geom.line_sel_width / 2. * - CTX.print.eps_line_width_factor); + CTX.print.eps_line_width_factor); glColor4ubv((GLubyte *) & CTX.color.geom.selection); } else { @@ -424,8 +424,8 @@ class drawGRegion { sprintf(Num, "%d", r->tag()); double offset = (0.5 * size + 0.3 * CTX.gl_fontsize) * CTX.pixel_equiv_x; glRasterPos3d(p.x() + offset / CTX.s[0], - p.y() + offset / CTX.s[1], - p.z() + offset / CTX.s[2]); + p.y() + offset / CTX.s[1], + p.z() + offset / CTX.s[2]); Draw_String(Num); } @@ -478,19 +478,19 @@ void Draw_Geom() glLineWidth(CTX.line_width); gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); Draw_Box(CTX.min[0], CTX.min[1], CTX.min[2], - CTX.max[0], CTX.max[1], CTX.max[2]); + CTX.max[0], CTX.max[1], CTX.max[2]); glColor3d(1.,0.,0.); for(int i = 0; i < 6; i++) if(CTX.clip[i] & 1 || CTX.clip[i] & 2) - Draw_PlaneInBoundingBox(CTX.min[0], CTX.min[1], CTX.min[2], - CTX.max[0], CTX.max[1], CTX.max[2], - CTX.clip_plane[i][0], CTX.clip_plane[i][1], - CTX.clip_plane[i][2], CTX.clip_plane[i][3]); + Draw_PlaneInBoundingBox(CTX.min[0], CTX.min[1], CTX.min[2], + CTX.max[0], CTX.max[1], CTX.max[2], + CTX.clip_plane[i][0], CTX.clip_plane[i][1], + CTX.clip_plane[i][2], CTX.clip_plane[i][3]); if(CTX.mesh.use_cut_plane) Draw_PlaneInBoundingBox(CTX.min[0], CTX.min[1], CTX.min[2], - CTX.max[0], CTX.max[1], CTX.max[2], - CTX.mesh.cut_planea, CTX.mesh.cut_planeb, - CTX.mesh.cut_planec, CTX.mesh.cut_planed); + CTX.max[0], CTX.max[1], CTX.max[2], + CTX.mesh.cut_planea, CTX.mesh.cut_planeb, + CTX.mesh.cut_planec, CTX.mesh.cut_planed); } if(CTX.axes){ @@ -499,13 +499,13 @@ void Draw_Geom() gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); if(!CTX.axes_auto_position){ Draw_Axes(CTX.axes, CTX.axes_tics, CTX.axes_format, CTX.axes_label, - CTX.axes_position, CTX.axes_mikado); + CTX.axes_position, CTX.axes_mikado); } else if(geometryExists){ double bb[6] = {CTX.min[0], CTX.max[0], CTX.min[1], - CTX.max[1], CTX.min[2], CTX.max[2]}; + CTX.max[1], CTX.min[2], CTX.max[2]}; Draw_Axes(CTX.axes, CTX.axes_tics, CTX.axes_format, CTX.axes_label, - bb, CTX.axes_mikado); + bb, CTX.axes_mikado); } } @@ -515,7 +515,7 @@ void Draw_Geom() Draw_Sphere(CTX.point_size, CTX.cg[0], CTX.cg[1], CTX.cg[2], CTX.geom.light); else Draw_Sphere(CTX.point_size, CTX.rotation_center[0], CTX.rotation_center[1], - CTX.rotation_center[2], CTX.geom.light); + CTX.rotation_center[2], CTX.geom.light); } } diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp index 2c3f5104698c10397dc6e6dce2870f86d340e726..17a9447de38e755d9c78985be6d069d7eb4ccfb6 100644 --- a/Graphics/Graph2D.cpp +++ b/Graphics/Graph2D.cpp @@ -1,4 +1,4 @@ -// $Id: Graph2D.cpp,v 1.77 2008-03-19 20:06:17 geuzaine Exp $ +// $Id: Graph2D.cpp,v 1.78 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -54,19 +54,19 @@ void Draw_Text2D() if(opt->Visible && opt->DrawStrings){ glColor4ubv((GLubyte *) & opt->color.text2d); for(int j = 0; j < data->getNumStrings2D(); j++){ - double x, y, style; - std::string str; - data->getString2D(j, opt->TimeStep, str, x, y, style); - Fix2DCoordinates(&x, &y); - glRasterPos2d(x, y); - Draw_String(str.c_str(), style); + double x, y, style; + std::string str; + data->getString2D(j, opt->TimeStep, str, x, y, style); + Fix2DCoordinates(&x, &y); + glRasterPos2d(x, y); + Draw_String(str.c_str(), style); } } } } static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, - double &xmax, std::vector<std::vector<double> > &y) + double &xmax, std::vector<std::vector<double> > &y) { PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); @@ -81,7 +81,7 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, numy = 0; for(int ent = 0; ent < data->getNumEntities(0); ent++) for(int i = 0; i < data->getNumElements(0, ent); i++) - if(data->getDimension(0, ent, i) < 2) numy++; + if(data->getDimension(0, ent, i) < 2) numy++; } if(!numy) return false; @@ -96,33 +96,33 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, for(int i = 0; i < data->getNumElements(0, ent); i++){ int dim = data->getDimension(0, ent, i); if(dim < 2){ - int numNodes = data->getNumNodes(0, ent, i); - for(int ts = space ? opt->TimeStep : 0; ts < opt->TimeStep + 1; ts++){ - int numComp = data->getNumComponents(ts, ent, i); - for(int j = 0; j < numNodes; j++){ - double val[9], xyz[3]; - data->getNode(ts, ent, i, j, xyz[0], xyz[1], xyz[2]); - for(int k = 0; k < numComp; k++) - data->getValue(ts, ent, i, j, k, val[k]); - double vy = ComputeScalarRep(numComp, val); - if(space){ - // store offset to origin + distance to first point - if(x.empty()){ - p0 = SPoint3(xyz[0], xyz[1], xyz[2]); - x.push_back(ComputeScalarRep(3, xyz)); - } - else{ - x.push_back(x[0] + p0.distance(SPoint3(xyz[0], xyz[1], xyz[2]))); - } - y[0].push_back(vy); - } - else{ - if(!numy) x.push_back(data->getTime(ts)); - y[numy].push_back(vy); - } - } - } - numy++; + int numNodes = data->getNumNodes(0, ent, i); + for(int ts = space ? opt->TimeStep : 0; ts < opt->TimeStep + 1; ts++){ + int numComp = data->getNumComponents(ts, ent, i); + for(int j = 0; j < numNodes; j++){ + double val[9], xyz[3]; + data->getNode(ts, ent, i, j, xyz[0], xyz[1], xyz[2]); + for(int k = 0; k < numComp; k++) + data->getValue(ts, ent, i, j, k, val[k]); + double vy = ComputeScalarRep(numComp, val); + if(space){ + // store offset to origin + distance to first point + if(x.empty()){ + p0 = SPoint3(xyz[0], xyz[1], xyz[2]); + x.push_back(ComputeScalarRep(3, xyz)); + } + else{ + x.push_back(x[0] + p0.distance(SPoint3(xyz[0], xyz[1], xyz[2]))); + } + y[0].push_back(vy); + } + else{ + if(!numy) x.push_back(data->getTime(ts)); + y[numy].push_back(vy); + } + } + } + numy++; } } } @@ -133,15 +133,15 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, bool monotone = true; for(unsigned int i = 1; i < x.size(); i++){ if(x[i] < x[i - 1]){ - monotone = false; - break; + monotone = false; + break; } } if(monotone){ // use the "coordinate" xmin = xmax = x[0]; for(unsigned int i = 1; i < x.size(); i++){ - xmin = std::min(xmin, x[i]); - xmax = std::max(xmax, x[i]); + xmin = std::min(xmin, x[i]); + xmax = std::max(xmax, x[i]); } } else{ // just use an index @@ -158,7 +158,7 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, } static void drawGraphAxes(PView *p, double xleft, double ytop, double width, - double height, double xmin, double xmax) + double height, double xmin, double xmax) { PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); @@ -223,32 +223,32 @@ static void drawGraphAxes(PView *p, double xleft, double ytop, double width, double dv = (opt->TmpMax - opt->TmpMin) / (double)nb; for(int i = 0; i < nb + 1; i++){ if(opt->Axes > 0){ - glBegin(GL_LINES); - glVertex2d(xleft, ytop - i * dy); - glVertex2d(xleft + tic, ytop - i * dy); - if(opt->Axes > 1){ - glVertex2d(xleft + width - tic, ytop - i * dy); - glVertex2d(xleft + width, ytop - i * dy); - } - glEnd(); - if(opt->Axes > 2 && i != 0 && i != nb){ - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0x1111); - gl2psEnable(GL2PS_LINE_STIPPLE); - gl2psLineWidth(1. * CTX.print.eps_line_width_factor); - glBegin(GL_LINES); - glVertex2d(xleft, ytop - i * dy); - glVertex2d(xleft + width, ytop - i * dy); - glEnd(); - glDisable(GL_LINE_STIPPLE); - gl2psDisable(GL2PS_LINE_STIPPLE); - gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); - } + glBegin(GL_LINES); + glVertex2d(xleft, ytop - i * dy); + glVertex2d(xleft + tic, ytop - i * dy); + if(opt->Axes > 1){ + glVertex2d(xleft + width - tic, ytop - i * dy); + glVertex2d(xleft + width, ytop - i * dy); + } + glEnd(); + if(opt->Axes > 2 && i != 0 && i != nb){ + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0x1111); + gl2psEnable(GL2PS_LINE_STIPPLE); + gl2psLineWidth(1. * CTX.print.eps_line_width_factor); + glBegin(GL_LINES); + glVertex2d(xleft, ytop - i * dy); + glVertex2d(xleft + width, ytop - i * dy); + glEnd(); + glDisable(GL_LINE_STIPPLE); + gl2psDisable(GL2PS_LINE_STIPPLE); + gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); + } } if(opt->ShowScale){ - sprintf(label, opt->Format, (i == nb) ? opt->TmpMin : (opt->TmpMax - i * dv)); - glRasterPos2d(xleft - 2 * tic, ytop - i * dy - font_a / 3.); - Draw_String_Right(label); + sprintf(label, opt->Format, (i == nb) ? opt->TmpMin : (opt->TmpMax - i * dv)); + glRasterPos2d(xleft - 2 * tic, ytop - i * dy - font_a / 3.); + Draw_String_Right(label); } } } @@ -259,7 +259,7 @@ static void drawGraphAxes(PView *p, double xleft, double ytop, double width, if(opt->Axes){ sprintf(label, opt->AxesFormat[0], - M_PI * 1.e-4); if((nb - 1) * gl_width(label) > width) - nb = (int)(width / gl_width(label)) + 1; + nb = (int)(width / gl_width(label)) + 1; } if(nb == 1) nb++; @@ -268,35 +268,35 @@ static void drawGraphAxes(PView *p, double xleft, double ytop, double width, for(int i = 0; i < nb; i++){ if(opt->Axes){ - glBegin(GL_LINES); - glVertex2d(xleft + i * dx, ybot); - glVertex2d(xleft + i * dx, ybot + tic); - if(opt->Axes > 1){ - glVertex2d(xleft + i * dx, ytop); - glVertex2d(xleft + i * dx, ytop - tic); - } - glEnd(); - if(opt->Axes > 2 && i != 0 && i != nb - 1){ - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0x1111); - gl2psEnable(GL2PS_LINE_STIPPLE); - gl2psLineWidth(1. * CTX.print.eps_line_width_factor); - glBegin(GL_LINES); - glVertex2d(xleft + i * dx, ytop); - glVertex2d(xleft + i * dx, ybot); - glEnd(); - glDisable(GL_LINE_STIPPLE); - gl2psDisable(GL2PS_LINE_STIPPLE); - gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); - } - - if(nb == 1) - sprintf(label, opt->AxesFormat[0], xmin); - else - sprintf(label, opt->AxesFormat[0], - xmin + i * (xmax - xmin) / (double)(nb - 1)); - glRasterPos2d(xleft + i * dx, ybot - font_h - tic); - Draw_String_Center(label); + glBegin(GL_LINES); + glVertex2d(xleft + i * dx, ybot); + glVertex2d(xleft + i * dx, ybot + tic); + if(opt->Axes > 1){ + glVertex2d(xleft + i * dx, ytop); + glVertex2d(xleft + i * dx, ytop - tic); + } + glEnd(); + if(opt->Axes > 2 && i != 0 && i != nb - 1){ + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0x1111); + gl2psEnable(GL2PS_LINE_STIPPLE); + gl2psLineWidth(1. * CTX.print.eps_line_width_factor); + glBegin(GL_LINES); + glVertex2d(xleft + i * dx, ytop); + glVertex2d(xleft + i * dx, ybot); + glEnd(); + glDisable(GL_LINE_STIPPLE); + gl2psDisable(GL2PS_LINE_STIPPLE); + gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); + } + + if(nb == 1) + sprintf(label, opt->AxesFormat[0], xmin); + else + sprintf(label, opt->AxesFormat[0], + xmin + i * (xmax - xmin) / (double)(nb - 1)); + glRasterPos2d(xleft + i * dx, ybot - font_h - tic); + Draw_String_Center(label); } } } @@ -304,8 +304,8 @@ static void drawGraphAxes(PView *p, double xleft, double ytop, double width, } static void addGraphPoint(PView *p, double xleft, double ytop, double width, - double height, double x, double y, double xmin, - double xmax, double ymin, double ymax, bool numeric) + double height, double x, double y, double xmin, + double xmax, double ymin, double ymax, bool numeric) { PViewOptions *opt = p->getOptions(); @@ -338,8 +338,8 @@ static void addGraphPoint(PView *p, double xleft, double ytop, double width, } static void drawGraphCurves(PView *p, double xleft, double ytop, double width, - double height, std::vector<double> &x, double xmin, - double xmax, std::vector<std::vector<double> > &y) + double height, std::vector<double> &x, double xmin, + double xmax, std::vector<std::vector<double> > &y) { PViewOptions *opt = p->getOptions(); @@ -352,8 +352,8 @@ static void drawGraphCurves(PView *p, double xleft, double ytop, double width, if(opt->IntervalsType == PViewOptions::Numeric){ for(unsigned int i = 0; i < y.size(); i++) for(unsigned int j = 0; j < x.size(); j++) - addGraphPoint(p, xleft, ytop, width, height, x[j], y[i][j], - xmin, xmax, opt->TmpMin, opt->TmpMax, true); + addGraphPoint(p, xleft, ytop, width, height, x[j], y[i][j], + xmin, xmax, opt->TmpMin, opt->TmpMax, true); } if(opt->IntervalsType == PViewOptions::Iso || @@ -362,8 +362,8 @@ static void drawGraphCurves(PView *p, double xleft, double ytop, double width, glBegin(GL_POINTS); for(unsigned int i = 0; i < y.size(); i++) for(unsigned int j = 0; j < x.size(); j++) - addGraphPoint(p, xleft, ytop, width, height, x[j], y[i][j], - xmin, xmax, opt->TmpMin, opt->TmpMax, false); + addGraphPoint(p, xleft, ytop, width, height, x[j], y[i][j], + xmin, xmax, opt->TmpMin, opt->TmpMax, false); glEnd(); } @@ -371,18 +371,18 @@ static void drawGraphCurves(PView *p, double xleft, double ytop, double width, opt->IntervalsType == PViewOptions::Continuous){ for(unsigned int i = 0; i < y.size(); i++){ if(opt->UseStipple){ - glEnable(GL_LINE_STIPPLE); - glLineStipple(opt->Stipple[i % 10][0], opt->Stipple[i % 10][1]); - gl2psEnable(GL2PS_LINE_STIPPLE); + glEnable(GL_LINE_STIPPLE); + glLineStipple(opt->Stipple[i % 10][0], opt->Stipple[i % 10][1]); + gl2psEnable(GL2PS_LINE_STIPPLE); } glBegin(GL_LINE_STRIP); for(unsigned int j = 0; j < x.size(); j++) - addGraphPoint(p, xleft, ytop, width, height, x[j], y[i][j], - xmin, xmax, opt->TmpMin, opt->TmpMax, false); + addGraphPoint(p, xleft, ytop, width, height, x[j], y[i][j], + xmin, xmax, opt->TmpMin, opt->TmpMax, false); glEnd(); if(opt->UseStipple){ - glDisable(GL_LINE_STIPPLE); - gl2psDisable(GL2PS_LINE_STIPPLE); + glDisable(GL_LINE_STIPPLE); + gl2psDisable(GL2PS_LINE_STIPPLE); } } } @@ -441,38 +441,38 @@ void Draw_Graph2D() double x = opt->Position[0], y = opt->Position[1]; int center = Fix2DCoordinates(&x, &y); drawGraph(p, x - (center & 1 ? opt->Size[0] / 2. : 0), - y + (center & 2 ? opt->Size[1] / 2. : 0), - opt->Size[0], opt->Size[1]); + y + (center & 2 ? opt->Size[1] / 2. : 0), + opt->Size[0], opt->Size[1]); } else{ double winw = CTX.viewport[2] - CTX.viewport[0]; double winh = CTX.viewport[3] - CTX.viewport[1]; if(graphs.size() == 1){ - double fracw = 0.75, frach = 0.75; - double w = fracw * winw - xsep; - double h = frach * winh - ysep; - double x = CTX.viewport[0] + (1 - fracw) / 2. * winw; - double y = CTX.viewport[1] + (1 - frach) / 2. * winh; - drawGraph(p, x + 0.95 * xsep, CTX.viewport[3] - (y + 0.4 * ysep), w, h); + double fracw = 0.75, frach = 0.75; + double w = fracw * winw - xsep; + double h = frach * winh - ysep; + double x = CTX.viewport[0] + (1 - fracw) / 2. * winw; + double y = CTX.viewport[1] + (1 - frach) / 2. * winh; + drawGraph(p, x + 0.95 * xsep, CTX.viewport[3] - (y + 0.4 * ysep), w, h); } else if(graphs.size() == 2){ - double fracw = 0.75, frach = 0.85; - double w = fracw * winw - xsep; - double h = frach * winh / 2. - ysep; - double x = CTX.viewport[0] + (1 - fracw) / 2. * winw; - double y = CTX.viewport[1] + (1 - frach) / 3. * winh; - if(i == 1) y += (h + ysep + (1 - frach) / 3. * winh); - drawGraph(p, x + 0.95 * xsep, CTX.viewport[3] - (y + 0.4 * ysep), w, h); + double fracw = 0.75, frach = 0.85; + double w = fracw * winw - xsep; + double h = frach * winh / 2. - ysep; + double x = CTX.viewport[0] + (1 - fracw) / 2. * winw; + double y = CTX.viewport[1] + (1 - frach) / 3. * winh; + if(i == 1) y += (h + ysep + (1 - frach) / 3. * winh); + drawGraph(p, x + 0.95 * xsep, CTX.viewport[3] - (y + 0.4 * ysep), w, h); } else{ - double fracw = 0.85, frach = 0.85; - double w = fracw * winw / 2. - xsep; - double h = frach * winh / 2. - ysep; - double x = CTX.viewport[0] + (1 - fracw) / 3. * winw; - if(i == 1 || i == 3) x += (w + xsep + (1-fracw)/3. * winw); - double y = CTX.viewport[1] + (1 - frach) / 3. * winh; - if(i == 2 || i == 3) y += (h + ysep + (1 - frach) / 3. * winh); - drawGraph(p, x + 0.95 * xsep, CTX.viewport[3] - (y + 0.4 * ysep), w, h); + double fracw = 0.85, frach = 0.85; + double w = fracw * winw / 2. - xsep; + double h = frach * winh / 2. - ysep; + double x = CTX.viewport[0] + (1 - fracw) / 3. * winw; + if(i == 1 || i == 3) x += (w + xsep + (1-fracw)/3. * winw); + double y = CTX.viewport[1] + (1 - frach) / 3. * winh; + if(i == 2 || i == 3) y += (h + ysep + (1 - frach) / 3. * winh); + drawGraph(p, x + 0.95 * xsep, CTX.viewport[3] - (y + 0.4 * ysep), w, h); } } } diff --git a/Graphics/Iso.cpp b/Graphics/Iso.cpp index 92f542a167e4cdf2e929e4e29f611e0bdafae922..994d3f946547944095affe343cce54cd87016f08 100644 --- a/Graphics/Iso.cpp +++ b/Graphics/Iso.cpp @@ -1,4 +1,4 @@ -// $Id: Iso.cpp,v 1.43 2008-02-17 08:47:59 geuzaine Exp $ +// $Id: Iso.cpp,v 1.44 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -22,7 +22,7 @@ #include "Numeric.h" static void affect(double *xi, double *yi, double *zi, int i, - double *xp, double *yp, double *zp, int j) + double *xp, double *yp, double *zp, int j) { xi[i] = xp[j]; yi[i] = yp[j]; @@ -32,7 +32,7 @@ static void affect(double *xi, double *yi, double *zi, int i, // Compute an iso-point in a line int IsoLine(double *X, double *Y, double *Z, double *Val, double V, - double *Xp, double *Yp, double *Zp) + double *Xp, double *Yp, double *Zp) { if(Val[0] == Val[1]) return 0; @@ -47,7 +47,7 @@ int IsoLine(double *X, double *Y, double *Z, double *Val, double V, // Compute an iso-line inside a triangle int IsoTriangle(double *X, double *Y, double *Z, double *Val, double V, - double *Xp, double *Yp, double *Zp) + double *Xp, double *Yp, double *Zp) { if(Val[0] == Val[1] && Val[0] == Val[2]) return 0; @@ -72,7 +72,7 @@ int IsoTriangle(double *X, double *Y, double *Z, double *Val, double V, // Compute an iso-polygon inside a tetrahedron int IsoSimplex(double *X, double *Y, double *Z, double *Val, double V, - double *Xp, double *Yp, double *Zp, double n[3]) + double *Xp, double *Yp, double *Zp, double n[3]) { if(Val[0] == Val[1] && Val[0] == Val[2] && Val[0] == Val[3]) return 0; @@ -113,15 +113,15 @@ int IsoSimplex(double *X, double *Y, double *Z, double *Val, double V, int ni = 1; for(int j = 1; j < nb; j++) { for(int i = 0; i < ni; i++) { - if(fabs(Xp[j] - xi[i]) < 1.e-12 && - fabs(Yp[j] - yi[i]) < 1.e-12 && - fabs(Zp[j] - zi[i]) < 1.e-12) { - break; - } - if(i == ni - 1) { - affect(xi, yi, zi, i + 1, Xp, Yp, Zp, j); - ni++; - } + if(fabs(Xp[j] - xi[i]) < 1.e-12 && + fabs(Yp[j] - yi[i]) < 1.e-12 && + fabs(Zp[j] - zi[i]) < 1.e-12) { + break; + } + if(i == ni - 1) { + affect(xi, yi, zi, i + 1, Xp, Yp, Zp, j); + ni++; + } } } for(int i = 0; i < ni; i++) @@ -184,8 +184,8 @@ int IsoSimplex(double *X, double *Y, double *Z, double *Val, double V, // Compute the line between the two iso-points V1 and V2 in a line int CutLine(double *X, double *Y, double *Z, double *Val, - double V1, double V2, - double *Xp2, double *Yp2, double *Zp2, double *Vp2) + double V1, double V2, + double *Xp2, double *Yp2, double *Zp2, double *Vp2) { int io[2]; if(Val[0] < Val[1]) { @@ -238,8 +238,8 @@ int CutLine(double *X, double *Y, double *Z, double *Val, // triangle int CutTriangle(double *X, double *Y, double *Z, double *Val, - double V1, double V2, - double *Xp2, double *Yp2, double *Zp2, double *Vp2) + double V1, double V2, + double *Xp2, double *Yp2, double *Zp2, double *Vp2) { // fill io so that it contains an indexing of the nodes such that // Val[io[i]] > Val[io[j]] if i > j diff --git a/Graphics/Iso.h b/Graphics/Iso.h index 9a8aa267a97cd0fd937de62a5a1ef1d18a34a4d7..acc23b13a92d04f8d7c03cf70ad703c69165bf3d 100644 --- a/Graphics/Iso.h +++ b/Graphics/Iso.h @@ -21,20 +21,20 @@ // Please report all bugs and problems to <gmsh@geuz.org>. int IsoLine(double *X, double *Y, double *Z, double *Val, double V, - double *Xp, double *Yp, double *Zp); + double *Xp, double *Yp, double *Zp); int IsoTriangle(double *X, double *Y, double *Z, double *Val, double V, - double *Xp, double *Yp, double *Zp); + double *Xp, double *Yp, double *Zp); int IsoSimplex(double *X, double *Y, double *Z, double *Val, double V, - double *Xp, double *Yp, double *Zp, double n[3]); + double *Xp, double *Yp, double *Zp, double n[3]); int CutLine(double *x, double *y, double *z, double *v, - double min, double max, - double *xp, double *yp, double *zp, double *vp); + double min, double max, + double *xp, double *yp, double *zp, double *vp); int CutTriangle(double *x, double *y, double *z, double *v, - double min, double max, - double *xp, double *yp, double *zp, double *vp); + double min, double max, + double *xp, double *yp, double *zp, double *vp); #endif diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index 29649de436135f3d5e728001edb8b6547f37582d..8c257fc0fca5cfbe18291b1f8a136032537d6dcb 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.218 2008-03-07 19:02:59 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.219 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -83,7 +83,7 @@ static unsigned int getColorByElement(MElement *ele) for(int i = 0; i < ele->getNumVertices(); i++){ GEntity *e = ele->getVertex(i)->onWhat(); if(e && (e->dim() == ele->getDim())) - return getColorByEntity(e); + return getColorByEntity(e); } } return CTX.color.fg; @@ -154,7 +154,7 @@ static int getLabelStep(int total) template<class T> static void drawElementLabels(GEntity *e, std::vector<T*> &elements, - int forceColor=0, unsigned int color=0) + int forceColor=0, unsigned int color=0) { unsigned col = forceColor ? color : getColorByEntity(e); glColor4ubv((GLubyte *) & col); @@ -168,18 +168,18 @@ static void drawElementLabels(GEntity *e, std::vector<T*> &elements, SPoint3 pc = ele->barycenter(); char str[256]; if(CTX.mesh.label_type == 4) - sprintf(str, "(%g,%g,%g)", pc.x(), pc.y(), pc.z()); + sprintf(str, "(%g,%g,%g)", pc.x(), pc.y(), pc.z()); else if(CTX.mesh.label_type == 3) - sprintf(str, "%d", ele->getPartition()); + sprintf(str, "%d", ele->getPartition()); else if(CTX.mesh.label_type == 2){ - int np = e->physicals.size(); - int p = np ? e->physicals[np - 1] : 0; - sprintf(str, "%d", p); + int np = e->physicals.size(); + int p = np ? e->physicals[np - 1] : 0; + sprintf(str, "%d", p); } else if(CTX.mesh.label_type == 1) - sprintf(str, "%d", e->tag()); + sprintf(str, "%d", e->tag()); else - sprintf(str, "%d", ele->getNum()); + sprintf(str, "%d", ele->getNum()); glRasterPos3d(pc.x(), pc.y(), pc.z()); Draw_String(str); } @@ -198,8 +198,8 @@ static void drawNormals(std::vector<T*> &elements) n[j] *= CTX.mesh.normals * CTX.pixel_equiv_x / CTX.s[j]; SPoint3 pc = ele->barycenter(); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc.x(), pc.y(), pc.z(), n[0], n[1], n[2], CTX.mesh.light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + pc.x(), pc.y(), pc.z(), n[0], n[1], n[2], CTX.mesh.light); } } @@ -215,8 +215,8 @@ static void drawTangents(std::vector<T*> &elements) t[j] *= CTX.mesh.tangents * CTX.pixel_equiv_x / CTX.s[j]; SPoint3 pc = ele->barycenter(); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc.x(), pc.y(), pc.z(), t[0], t[1], t[2], CTX.mesh.light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + pc.x(), pc.y(), pc.z(), t[0], t[1], t[2], CTX.mesh.light); } } @@ -245,7 +245,7 @@ static void drawVertexLabel(GEntity *e, MVertex *v, int partition=-1) if(v->getPolynomialOrder() > 1) glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); else - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); glRasterPos3d(v->x(), v->y(), v->z()); Draw_String(str); } @@ -255,25 +255,25 @@ static void drawVerticesPerEntity(GEntity *e) if(CTX.mesh.points) { if(CTX.mesh.point_type) { for(unsigned int i = 0; i < e->mesh_vertices.size(); i++){ - MVertex *v = e->mesh_vertices[i]; - if(!v->getVisibility()) continue; - if(v->getPolynomialOrder() > 1) - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); - else - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); - Draw_Sphere(CTX.mesh.point_size, v->x(), v->y(), v->z(), CTX.mesh.light); + MVertex *v = e->mesh_vertices[i]; + if(!v->getVisibility()) continue; + if(v->getPolynomialOrder() > 1) + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); + else + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); + Draw_Sphere(CTX.mesh.point_size, v->x(), v->y(), v->z(), CTX.mesh.light); } } else{ glBegin(GL_POINTS); for(unsigned int i = 0; i < e->mesh_vertices.size(); i++){ - MVertex *v = e->mesh_vertices[i]; - if(!v->getVisibility()) continue; - if(v->getPolynomialOrder() > 1) - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); - else - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); - glVertex3d(v->x(), v->y(), v->z()); + MVertex *v = e->mesh_vertices[i]; + if(!v->getVisibility()) continue; + if(v->getPolynomialOrder() > 1) + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); + else + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); + glVertex3d(v->x(), v->y(), v->z()); } glEnd(); } @@ -293,21 +293,21 @@ static void drawVerticesPerElement(GEntity *e, std::vector<T*> &elements) for(int j = 0; j < ele->getNumVertices(); j++){ MVertex *v = ele->getVertex(j); if(isElementVisible(ele) && v->getVisibility()){ - if(CTX.mesh.points) { - if(v->getPolynomialOrder() > 1) - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); - else - glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); - if(CTX.mesh.point_type) - Draw_Sphere(CTX.mesh.point_size, v->x(), v->y(), v->z(), CTX.mesh.light); - else{ - glBegin(GL_POINTS); - glVertex3d(v->x(), v->y(), v->z()); - glEnd(); - } - } - if(CTX.mesh.points_num) - drawVertexLabel(e, v); + if(CTX.mesh.points) { + if(v->getPolynomialOrder() > 1) + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_sup); + else + glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); + if(CTX.mesh.point_type) + Draw_Sphere(CTX.mesh.point_size, v->x(), v->y(), v->z(), CTX.mesh.light); + else{ + glBegin(GL_POINTS); + glVertex3d(v->x(), v->y(), v->z()); + glEnd(); + } + } + if(CTX.mesh.points_num) + drawVertexLabel(e, v); } } } @@ -327,25 +327,25 @@ static void drawBarycentricDual(std::vector<T*> &elements) SPoint3 pc = ele->barycenter(); if(ele->getDim() == 2){ for(int j = 0; j < ele->getNumEdges(); j++){ - MEdge e = ele->getEdge(j); - SPoint3 p = e.barycenter(); - glVertex3d(pc.x(), pc.y(), pc.z()); - glVertex3d(p.x(), p.y(), p.z()); + MEdge e = ele->getEdge(j); + SPoint3 p = e.barycenter(); + glVertex3d(pc.x(), pc.y(), pc.z()); + glVertex3d(p.x(), p.y(), p.z()); } } else if(ele->getDim() == 3){ for(int j = 0; j < ele->getNumFaces(); j++){ - MFace f = ele->getFace(j); - SPoint3 p = f.barycenter(); - glVertex3d(pc.x(), pc.y(), pc.z()); - glVertex3d(p.x(), p.y(), p.z()); - for(int k = 0; k < f.getNumVertices(); k++){ - MEdge e(f.getVertex(k), (k == f.getNumVertices() - 1) ? - f.getVertex(0) : f.getVertex(k + 1)); - SPoint3 pe = e.barycenter(); - glVertex3d(p.x(), p.y(), p.z()); - glVertex3d(pe.x(), pe.y(), pe.z()); - } + MFace f = ele->getFace(j); + SPoint3 p = f.barycenter(); + glVertex3d(pc.x(), pc.y(), pc.z()); + glVertex3d(p.x(), p.y(), p.z()); + for(int k = 0; k < f.getNumVertices(); k++){ + MEdge e(f.getVertex(k), (k == f.getNumVertices() - 1) ? + f.getVertex(0) : f.getVertex(k + 1)); + SPoint3 pe = e.barycenter(); + glVertex3d(p.x(), p.y(), p.z()); + glVertex3d(pe.x(), pe.y(), pe.z()); + } } } } @@ -368,12 +368,12 @@ static void addSmoothNormals(GEntity *e, std::vector<T*> &elements) SVector3 n[3]; ele->getFaceRep(j, x, y, z, n); for(int k = 0; k < 3; k++){ - if(CTX.mesh.explode != 1.){ - x[k] = pc[0] + CTX.mesh.explode * (x[k] - pc[0]); - y[k] = pc[1] + CTX.mesh.explode * (y[k] - pc[1]); - z[k] = pc[2] + CTX.mesh.explode * (z[k] - pc[2]); - } - e->model()->normals->add(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]); + if(CTX.mesh.explode != 1.){ + x[k] = pc[0] + CTX.mesh.explode * (x[k] - pc[0]); + y[k] = pc[1] + CTX.mesh.explode * (y[k] - pc[1]); + z[k] = pc[2] + CTX.mesh.explode * (z[k] - pc[2]); + } + e->model()->normals->add(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]); } } } @@ -383,7 +383,7 @@ static void addSmoothNormals(GEntity *e, std::vector<T*> &elements) template<class T> static void addElementsInArrays(GEntity *e, std::vector<T*> &elements, - bool edges, bool faces) + bool edges, bool faces) { for(unsigned int i = 0; i < elements.size(); i++){ MElement *ele = elements[i]; @@ -402,20 +402,20 @@ static void addElementsInArrays(GEntity *e, std::vector<T*> &elements, if(edges){ bool unique = e->dim() > 1 && !CTX.pick_elements; for(int j = 0; j < ele->getNumEdgesRep(); j++){ - double x[2], y[2], z[2]; - SVector3 n[2]; - ele->getEdgeRep(j, x, y, z, n); - if(CTX.mesh.explode != 1.){ - for(int k = 0; k < 2; k++){ - x[k] = pc[0] + CTX.mesh.explode * (x[k] - pc[0]); - y[k] = pc[1] + CTX.mesh.explode * (y[k] - pc[1]); - z[k] = pc[2] + CTX.mesh.explode * (z[k] - pc[2]); - } - } - if(e->dim() == 2 && CTX.mesh.smooth_normals) - for(int k = 0; k < 2; k++) - e->model()->normals->get(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]); - e->va_lines->add(x, y, z, n, col, ele, unique); + double x[2], y[2], z[2]; + SVector3 n[2]; + ele->getEdgeRep(j, x, y, z, n); + if(CTX.mesh.explode != 1.){ + for(int k = 0; k < 2; k++){ + x[k] = pc[0] + CTX.mesh.explode * (x[k] - pc[0]); + y[k] = pc[1] + CTX.mesh.explode * (y[k] - pc[1]); + z[k] = pc[2] + CTX.mesh.explode * (z[k] - pc[2]); + } + } + if(e->dim() == 2 && CTX.mesh.smooth_normals) + for(int k = 0; k < 2; k++) + e->model()->normals->get(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]); + e->va_lines->add(x, y, z, n, col, ele, unique); } } @@ -423,27 +423,27 @@ static void addElementsInArrays(GEntity *e, std::vector<T*> &elements, bool unique = e->dim() > 2 && !CTX.pick_elements; bool skin = e->dim() > 2 && CTX.mesh.draw_skin_only; for(int j = 0; j < ele->getNumFacesRep(); j++){ - double x[3], y[3], z[3]; - SVector3 n[3]; - ele->getFaceRep(j, x, y, z, n); - if(CTX.mesh.explode != 1.){ - for(int k = 0; k < 3; k++){ - x[k] = pc[0] + CTX.mesh.explode * (x[k] - pc[0]); - y[k] = pc[1] + CTX.mesh.explode * (y[k] - pc[1]); - z[k] = pc[2] + CTX.mesh.explode * (z[k] - pc[2]); - } - } - if(e->dim() == 2 && CTX.mesh.smooth_normals) - for(int k = 0; k < 3; k++) - e->model()->normals->get(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]); - e->va_triangles->add(x, y, z, n, col, ele, unique, skin); + double x[3], y[3], z[3]; + SVector3 n[3]; + ele->getFaceRep(j, x, y, z, n); + if(CTX.mesh.explode != 1.){ + for(int k = 0; k < 3; k++){ + x[k] = pc[0] + CTX.mesh.explode * (x[k] - pc[0]); + y[k] = pc[1] + CTX.mesh.explode * (y[k] - pc[1]); + z[k] = pc[2] + CTX.mesh.explode * (z[k] - pc[2]); + } + } + if(e->dim() == 2 && CTX.mesh.smooth_normals) + for(int k = 0; k < 3; k++) + e->model()->normals->get(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]); + e->va_triangles->add(x, y, z, n, col, ele, unique, skin); } } } } static void drawArrays(GEntity *e, VertexArray *va, GLint type, bool useNormalArray, - int forceColor=0, unsigned int color=0) + int forceColor=0, unsigned int color=0) { if(!va) return; @@ -452,14 +452,14 @@ static void drawArrays(GEntity *e, VertexArray *va, GLint type, bool useNormalAr if(CTX.render_mode == GMSH_SELECT && CTX.pick_elements) { if(va->getNumElementPointers() == va->getNumVertices()){ for(int i = 0; i < va->getNumVertices(); i += va->getNumVerticesPerElement()){ - glPushName(va->getNumVerticesPerElement()); - glPushName(i); - glBegin(type); - for(int j = 0; j < va->getNumVerticesPerElement(); j++) - glVertex3fv(va->getVertexArray(3 * (i + j))); - glEnd(); - glPopName(); - glPopName(); + glPushName(va->getNumVerticesPerElement()); + glPushName(i); + glBegin(type); + for(int j = 0; j < va->getNumVerticesPerElement(); j++) + glVertex3fv(va->getVertexArray(3 * (i + j))); + glEnd(); + glPopName(); + glPopName(); } return; } @@ -483,8 +483,8 @@ static void drawArrays(GEntity *e, VertexArray *va, GLint type, bool useNormalAr glColor4ubv((GLubyte *) & color); } else if(CTX.pick_elements || - (!e->getSelection() && (CTX.mesh.color_carousel == 0 || - CTX.mesh.color_carousel == 3))){ + (!e->getSelection() && (CTX.mesh.color_carousel == 0 || + CTX.mesh.color_carousel == 3))){ glEnableClientState(GL_COLOR_ARRAY); } else{ @@ -577,9 +577,9 @@ class drawMeshGEdge { if(CTX.mesh.points || CTX.mesh.points_num){ if(e->getAllElementsVisible()) - drawVerticesPerEntity(e); + drawVerticesPerEntity(e); else - drawVerticesPerElement(e, e->lines); + drawVerticesPerElement(e, e->lines); } if(CTX.mesh.tangents) @@ -639,7 +639,7 @@ class initMeshGFace { bool fac = CTX.mesh.surfaces_faces; if(edg || fac){ _curved = (areSomeElementsCurved(f->triangles) || - areSomeElementsCurved(f->quadrangles)); + areSomeElementsCurved(f->quadrangles)); f->va_lines = new VertexArray(2, _estimateNumLines(f)); f->va_triangles = new VertexArray(3, _estimateNumTriangles(f)); if(CTX.mesh.triangles) addElementsInArrays(f, f->triangles, edg, fac); @@ -662,22 +662,22 @@ class drawMeshGFace { } drawArrays(f, f->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, - CTX.mesh.surfaces_faces, CTX.color.mesh.line); + CTX.mesh.surfaces_faces, CTX.color.mesh.line); drawArrays(f, f->va_triangles, GL_TRIANGLES, CTX.mesh.light); if(CTX.mesh.surfaces_num) { if(CTX.mesh.triangles) - drawElementLabels(f, f->triangles, CTX.mesh.surfaces_faces, CTX.color.mesh.line); + drawElementLabels(f, f->triangles, CTX.mesh.surfaces_faces, CTX.color.mesh.line); if(CTX.mesh.quadrangles) - drawElementLabels(f, f->quadrangles, CTX.mesh.surfaces_faces, CTX.color.mesh.line); + drawElementLabels(f, f->quadrangles, CTX.mesh.surfaces_faces, CTX.color.mesh.line); } if(CTX.mesh.points || CTX.mesh.points_num){ if(f->getAllElementsVisible()) - drawVerticesPerEntity(f); + drawVerticesPerEntity(f); else{ - if(CTX.mesh.triangles) drawVerticesPerElement(f, f->triangles); - if(CTX.mesh.quadrangles) drawVerticesPerElement(f, f->quadrangles); + if(CTX.mesh.triangles) drawVerticesPerElement(f, f->triangles); + if(CTX.mesh.quadrangles) drawVerticesPerElement(f, f->quadrangles); } } @@ -709,9 +709,9 @@ class initMeshGRegion { if(CTX.mesh.volumes_edges){ // suppose edge shared by 4 elements on averge (pessmistic) num += (12 * r->tetrahedra.size() + 24 * r->hexahedra.size() + - 18 * r->prisms.size() + 16 * r->pyramids.size()) / 4; + 18 * r->prisms.size() + 16 * r->pyramids.size()) / 4; if(CTX.mesh.use_cut_plane && CTX.mesh.cut_plane_draw_intersect) - num = (int)sqrt(num); + num = (int)sqrt(num); if(CTX.mesh.explode != 1.) num *= 4; if(_curved) num *= 2; } @@ -722,9 +722,9 @@ class initMeshGRegion { int num = 0; if(CTX.mesh.volumes_faces){ num += (4 * r->tetrahedra.size() + 12 * r->hexahedra.size() + - 8 * r->prisms.size() + 6 * r->pyramids.size()) / 2; + 8 * r->prisms.size() + 6 * r->pyramids.size()) / 2; if(CTX.mesh.use_cut_plane && CTX.mesh.cut_plane_draw_intersect) - num = (int)sqrt(num); + num = (int)sqrt(num); if(CTX.mesh.explode != 1.) num *= 2; if(_curved) num *= 4; } @@ -746,9 +746,9 @@ class initMeshGRegion { bool fac = CTX.mesh.volumes_faces; if(edg || fac){ _curved = (areSomeElementsCurved(r->tetrahedra) || - areSomeElementsCurved(r->hexahedra) || - areSomeElementsCurved(r->prisms) || - areSomeElementsCurved(r->pyramids)); + areSomeElementsCurved(r->hexahedra) || + areSomeElementsCurved(r->prisms) || + areSomeElementsCurved(r->pyramids)); r->va_lines = new VertexArray(2, _estimateNumLines(r)); r->va_triangles = new VertexArray(3, _estimateNumTriangles(r)); if(CTX.mesh.tetrahedra) addElementsInArrays(r, r->tetrahedra, edg, fac); @@ -773,32 +773,32 @@ class drawMeshGRegion { } drawArrays(r, r->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, - CTX.mesh.volumes_faces, CTX.color.mesh.line); + CTX.mesh.volumes_faces, CTX.color.mesh.line); drawArrays(r, r->va_triangles, GL_TRIANGLES, CTX.mesh.light); if(CTX.mesh.volumes_num) { if(CTX.mesh.tetrahedra) - drawElementLabels(r, r->tetrahedra, CTX.mesh.volumes_faces || - CTX.mesh.surfaces_faces, CTX.color.mesh.line); + drawElementLabels(r, r->tetrahedra, CTX.mesh.volumes_faces || + CTX.mesh.surfaces_faces, CTX.color.mesh.line); if(CTX.mesh.hexahedra) - drawElementLabels(r, r->hexahedra, CTX.mesh.volumes_faces || - CTX.mesh.surfaces_faces, CTX.color.mesh.line); + drawElementLabels(r, r->hexahedra, CTX.mesh.volumes_faces || + CTX.mesh.surfaces_faces, CTX.color.mesh.line); if(CTX.mesh.prisms) - drawElementLabels(r, r->prisms, CTX.mesh.volumes_faces || - CTX.mesh.surfaces_faces, CTX.color.mesh.line); + drawElementLabels(r, r->prisms, CTX.mesh.volumes_faces || + CTX.mesh.surfaces_faces, CTX.color.mesh.line); if(CTX.mesh.pyramids) - drawElementLabels(r, r->pyramids, CTX.mesh.volumes_faces || - CTX.mesh.surfaces_faces, CTX.color.mesh.line); + drawElementLabels(r, r->pyramids, CTX.mesh.volumes_faces || + CTX.mesh.surfaces_faces, CTX.color.mesh.line); } if(CTX.mesh.points || CTX.mesh.points_num){ if(r->getAllElementsVisible()) - drawVerticesPerEntity(r); + drawVerticesPerEntity(r); else{ - if(CTX.mesh.tetrahedra) drawVerticesPerElement(r, r->tetrahedra); - if(CTX.mesh.hexahedra) drawVerticesPerElement(r, r->hexahedra); - if(CTX.mesh.prisms) drawVerticesPerElement(r, r->prisms); - if(CTX.mesh.pyramids) drawVerticesPerElement(r, r->pyramids); + if(CTX.mesh.tetrahedra) drawVerticesPerElement(r, r->tetrahedra); + if(CTX.mesh.hexahedra) drawVerticesPerElement(r, r->hexahedra); + if(CTX.mesh.prisms) drawVerticesPerElement(r, r->prisms); + if(CTX.mesh.pyramids) drawVerticesPerElement(r, r->pyramids); } } @@ -848,16 +848,16 @@ void Draw_Mesh() if(CTX.mesh.changed) { Msg(DEBUG, "Mesh has changed: reinitializing drawing data", CTX.mesh.changed); if(status >= 1 && CTX.mesh.changed & ENT_LINE) - std::for_each(m->firstEdge(), m->lastEdge(), initMeshGEdge()); + std::for_each(m->firstEdge(), m->lastEdge(), initMeshGEdge()); if(status >= 2 && CTX.mesh.changed & ENT_SURFACE){ - if(m->normals) delete m->normals; - m->normals = new smooth_normals(CTX.mesh.angle_smooth_normals); - if(CTX.mesh.smooth_normals) - std::for_each(m->firstFace(), m->lastFace(), initSmoothNormalsGFace()); - std::for_each(m->firstFace(), m->lastFace(), initMeshGFace()); + if(m->normals) delete m->normals; + m->normals = new smooth_normals(CTX.mesh.angle_smooth_normals); + if(CTX.mesh.smooth_normals) + std::for_each(m->firstFace(), m->lastFace(), initSmoothNormalsGFace()); + std::for_each(m->firstFace(), m->lastFace(), initMeshGFace()); } if(status >= 3 && CTX.mesh.changed & ENT_VOLUME) - std::for_each(m->firstRegion(), m->lastRegion(), initMeshGRegion()); + std::for_each(m->firstRegion(), m->lastRegion(), initMeshGRegion()); } if(status >= 0) std::for_each(m->firstVertex(), m->lastVertex(), drawMeshGVertex()); diff --git a/Graphics/PixelBuffer.h b/Graphics/PixelBuffer.h index ebc5e486dd607706ab8730aebbe8086507f38944..54abfa412386e85fbec5fbff73caafbea619fcdf 100644 --- a/Graphics/PixelBuffer.h +++ b/Graphics/PixelBuffer.h @@ -89,16 +89,16 @@ class PixelBuffer{ else{ #if defined(HAVE_OSMESA) if(_format != GL_RGB && _type != GL_UNSIGNED_BYTE){ - Msg(GERROR, "Offscreen rendering only implemented for GL_RGB/GL_UNSIGNED_BYTE"); - return; + Msg(GERROR, "Offscreen rendering only implemented for GL_RGB/GL_UNSIGNED_BYTE"); + return; } OSMesaContext ctx = OSMesaCreateContextExt(OSMESA_RGB, 16, 0, 0, NULL); if(!ctx){ - Msg(GERROR, "OSMesaCreateContext failed"); - return; + Msg(GERROR, "OSMesaCreateContext failed"); + return; } if(!OSMesaMakeCurrent(ctx, _pixels, GL_UNSIGNED_BYTE, _width, _height)){ - Msg(GERROR, "OSMesaMakeCurrent failed"); + Msg(GERROR, "OSMesaMakeCurrent failed"); } ClearOpengl(); Draw3d(); diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp index c6bc6d02ef64d3cd127b115a2a3faaee599d5434..89e43ec783fd597595f4c6513bb792d5e385a630 100644 --- a/Graphics/Post.cpp +++ b/Graphics/Post.cpp @@ -1,4 +1,4 @@ -// $Id: Post.cpp,v 1.157 2008-03-19 16:38:16 geuzaine Exp $ +// $Id: Post.cpp,v 1.158 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -40,8 +40,8 @@ extern Context_T CTX; #define NMAX 20 void saturate(int nb, double val[NMAX][9], double vmin, double vmax, - int i0=0, int i1=1, int i2=2, int i3=3, - int i4=4, int i5=5, int i6=6, int i7=7) + int i0=0, int i1=1, int i2=2, int i3=3, + int i4=4, int i5=5, int i6=6, int i7=7) { int id[8] = {i0, i1, i2, i3, i4, i5, i6, i7}; for(int i = 0; i < nb; i++){ @@ -53,11 +53,11 @@ void saturate(int nb, double val[NMAX][9], double vmin, double vmax, SVector3 normal3(double xyz[NMAX][3], int i0=0, int i1=1, int i2=2) { SVector3 t1(xyz[i1][0] - xyz[i0][0], - xyz[i1][1] - xyz[i0][1], - xyz[i1][2] - xyz[i0][2]); + xyz[i1][1] - xyz[i0][1], + xyz[i1][2] - xyz[i0][2]); SVector3 t2(xyz[i2][0] - xyz[i0][0], - xyz[i2][1] - xyz[i0][1], - xyz[i2][2] - xyz[i0][2]); + xyz[i2][1] - xyz[i0][1], + xyz[i2][2] - xyz[i0][2]); SVector3 n = crossprod(t1, t2); n.normalize(); return n; @@ -78,7 +78,7 @@ SVector3 getPointNormal(PView *p, double v) } void getLineNormal(PView *p, double x[2], double y[2], double z[2], - double *v, SVector3 n[2], bool computeNormal) + double *v, SVector3 n[2], bool computeNormal) { PViewOptions *opt = p->getOptions(); @@ -109,11 +109,11 @@ void getLineNormal(PView *p, double x[2], double y[2], double z[2], SVector3 t(x[1] - x[0], y[1] - y[0], z[1] - z[0]); SVector3 ex(0., 0., 0.); if(t[0] == 0.) - ex[0] = 1.; + ex[0] = 1.; else if(t[1] == 0.) - ex[1] = 1.; + ex[1] = 1.; else - ex[2] = 1.; + ex[2] = 1.; n[0] = crossprod(t, ex); n[0].normalize(); n[1] = n[0]; @@ -122,8 +122,8 @@ void getLineNormal(PView *p, double x[2], double y[2], double z[2], } bool getExternalValues(PView *p, int index, int ient, int iele, int numNodes, - int numComp, double val[NMAX][9], - int &numComp2, double val2[NMAX][9]) + int numComp, double val[NMAX][9], + int &numComp2, double val2[NMAX][9]) { PViewOptions *opt = p->getOptions(); @@ -145,19 +145,19 @@ bool getExternalValues(PView *p, int index, int ient, int iele, int numNodes, if(data2->getNumNodes(opt->TimeStep, ient, iele) == numNodes){ numComp2 = data2->getNumComponents(opt->TimeStep, ient, iele); for(int i = 0; i < numNodes; i++) - for(int j = 0; j < numComp2; j++) - data2->getValue(opt->TimeStep, ient, iele, i, j, val2[i][j]); + for(int j = 0; j < numComp2; j++) + data2->getValue(opt->TimeStep, ient, iele, i, j, val2[i][j]); if(opt->RangeType == PViewOptions::Custom){ - opt->ExternalMin = opt->CustomMin; - opt->ExternalMax = opt->CustomMax; + opt->ExternalMin = opt->CustomMin; + opt->ExternalMax = opt->CustomMax; } else if(opt->RangeType == PViewOptions::PerTimeStep){ - opt->ExternalMin = data2->getMin(opt->TimeStep); - opt->ExternalMax = data2->getMax(opt->TimeStep); + opt->ExternalMin = data2->getMin(opt->TimeStep); + opt->ExternalMax = data2->getMax(opt->TimeStep); } else{ - opt->ExternalMin = data2->getMin(); - opt->ExternalMax = data2->getMax(); + opt->ExternalMin = data2->getMin(); + opt->ExternalMax = data2->getMax(); } return true; } @@ -166,7 +166,7 @@ bool getExternalValues(PView *p, int index, int ient, int iele, int numNodes, } void applyGeneralRaise(PView *p, int numNodes, int numComp, - double vals[NMAX][9], double xyz[NMAX][3]) + double vals[NMAX][9], double xyz[NMAX][3]) { PViewOptions *opt = p->getOptions(); @@ -175,26 +175,26 @@ void applyGeneralRaise(PView *p, int numNodes, int numComp, for(int l = 0; l < numComp; l++) d[l] = vals[k][l]; #if defined(HAVE_MATH_EVAL) char *names[] = { "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8" , - "x", "y", "z" }; + "x", "y", "z" }; double values[] = { d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], - xyz[k][0], xyz[k][1], xyz[k][2] }; + xyz[k][0], xyz[k][1], xyz[k][2] }; for(int i = 0; i < 3; i++) { if(opt->GenRaise_f[i]) xyz[k][i] += opt->GenRaiseFactor * evaluator_evaluate - (opt->GenRaise_f[i], sizeof(names) / sizeof(names[0]), names, values); + (opt->GenRaise_f[i], sizeof(names) / sizeof(names[0]), names, values); } #else for(int i = 0; i < 3; i++){ int comp = (int)opt->GenRaise_f[i]; if(comp >= 0) - xyz[k][i] += opt->GenRaiseFactor * d[comp]; + xyz[k][i] += opt->GenRaiseFactor * d[comp]; } #endif } } void changeCoordinates(PView *p, int ient, int iele, int numNodes, int numEdges, - int numComp, double xyz[NMAX][3], double val[NMAX][9]) + int numComp, double xyz[NMAX][3], double val[NMAX][9]) { PViewOptions *opt = p->getOptions(); @@ -202,12 +202,12 @@ void changeCoordinates(PView *p, int ient, int iele, int numNodes, int numEdges, double barycenter[3] = {0., 0., 0.}; for(int i = 0; i < numNodes; i++) for(int j = 0; j < 3; j++) - barycenter[j] += xyz[i][j]; + barycenter[j] += xyz[i][j]; for(int j = 0; j < 3; j++) barycenter[j] /= (double)numNodes; for(int i = 0; i < numNodes; i++) for(int j = 0; j < 3; j++) - xyz[i][j] = barycenter[j] + opt->Explode * (xyz[i][j] - barycenter[j]); + xyz[i][j] = barycenter[j] + opt->Explode * (xyz[i][j] - barycenter[j]); } if(opt->Transform[0][0] != 1. || opt->Transform[0][1] != 0. || @@ -218,9 +218,9 @@ void changeCoordinates(PView *p, int ient, int iele, int numNodes, int numEdges, for(int i = 0; i < numNodes; i++) { double old[3] = {xyz[i][0], xyz[i][1], xyz[i][2]}; for(int j = 0; j < 3; j++){ - xyz[i][j] = 0.; - for(int k = 0; k < 3; k++) - xyz[i][j] += opt->Transform[j][k] * old[k]; + xyz[i][j] = 0.; + for(int k = 0; k < 3; k++) + xyz[i][j] += opt->Transform[j][k] * old[k]; } } } @@ -228,14 +228,14 @@ void changeCoordinates(PView *p, int ient, int iele, int numNodes, int numEdges, if(opt->Offset[0] || opt->Offset[1] || opt->Offset[2]){ for(int i = 0; i < numNodes; i++) for(int j = 0; j < 3; j++) - xyz[i][j] += opt->Offset[j]; + xyz[i][j] += opt->Offset[j]; } if(opt->Raise[0] || opt->Raise[1] || opt->Raise[2]){ for(int i = 0; i < numNodes; i++){ double v = ComputeScalarRep(numComp, val[i]); for(int j = 0; j < 3; j++) - xyz[i][j] += opt->Raise[j] * v; + xyz[i][j] += opt->Raise[j] * v; } } @@ -256,14 +256,14 @@ void changeCoordinates(PView *p, int ient, int iele, int numNodes, int numEdges, for(int i = 0; i < numNodes; i++){ double v = ComputeScalarRep(numComp, val[i]); for(int j = 0; j < 3; j++) - xyz[i][j] += n[j] * opt->NormalRaise * v; + xyz[i][j] += n[j] * opt->NormalRaise * v; } } if(numComp == 3 && opt->VectorType == PViewOptions::Displacement){ for(int i = 0; i < numNodes; i++){ for(int j = 0; j < 3; j++) - xyz[i][j] += opt->DisplacementFactor * val[i][j]; + xyz[i][j] += opt->DisplacementFactor * val[i][j]; } } @@ -271,13 +271,13 @@ void changeCoordinates(PView *p, int ient, int iele, int numNodes, int numEdges, int numComp2; double val2[NMAX][9]; getExternalValues(p, opt->ViewIndexForGenRaise, ient, iele, numNodes, - numComp, val, numComp2, val2); + numComp, val, numComp2, val2); applyGeneralRaise(p, numNodes, numComp2, val2, xyz); } } void addOutlinePoint(PView *p, double xyz[NMAX][3], unsigned int color, bool pre, - int i0=0) + int i0=0) { if(pre) return; SVector3 n = getPointNormal(p, 1.); @@ -285,7 +285,7 @@ void addOutlinePoint(PView *p, double xyz[NMAX][3], unsigned int color, bool pre } void addScalarPoint(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, - int i0=0, bool unique=false) + int i0=0, bool unique=false) { if(pre) return; @@ -302,7 +302,7 @@ void addScalarPoint(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre } void addOutlineLine(PView *p, double xyz[NMAX][3], unsigned int color, bool pre, - int i0=0, int i1=1) + int i0=0, int i1=1) { if(pre) return; @@ -319,7 +319,7 @@ void addOutlineLine(PView *p, double xyz[NMAX][3], unsigned int color, bool pre, } void addScalarLine(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, - int i0=0, int i1=1, bool unique=false) + int i0=0, int i1=1, bool unique=false) { if(pre) return; @@ -348,17 +348,17 @@ void addScalarLine(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, val[i1][0] >= vmin && val[i1][0] <= vmax){ unsigned int col[2]; for(int i = 0; i < 2; i++) - col[i] = opt->getColor(v[i], vmin, vmax); + col[i] = opt->getColor(v[i], vmin, vmax); p->va_lines->add(x, y, z, n, col, 0, unique); } else{ double x2[2], y2[2], z2[2], v2[2]; int nb = CutLine(x, y, z, v, vmin, vmax, x2, y2, z2, v2); if(nb == 2){ - unsigned int col[2]; - for(int i = 0; i < 2; i++) - col[i] = opt->getColor(v2[i], vmin, vmax); - p->va_lines->add(x2, y2, z2, n, col, 0, unique); + unsigned int col[2]; + for(int i = 0; i < 2; i++) + col[i] = opt->getColor(v2[i], vmin, vmax); + p->va_lines->add(x2, y2, z2, n, col, 0, unique); } } } @@ -371,11 +371,11 @@ void addScalarLine(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, double x2[2], y2[2], z2[2], v2[2]; int nb = CutLine(x, y, z, v, min, max, x2, y2, z2, v2); if(nb == 2){ - unsigned color = opt->getColor(k, opt->NbIso); - unsigned int col[2] = {color, color}; - SVector3 n[2]; - getLineNormal(p, x2, y2, z2, v2, n, true); - p->va_lines->add(x2, y2, z2, n, col, 0, unique); + unsigned color = opt->getColor(k, opt->NbIso); + unsigned int col[2] = {color, color}; + SVector3 n[2]; + getLineNormal(p, x2, y2, z2, v2, n, true); + p->va_lines->add(x2, y2, z2, n, col, 0, unique); } if(vmin == vmax) break; } @@ -388,9 +388,9 @@ void addScalarLine(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, double x2[1], y2[1], z2[1]; int nb = IsoLine(x, y, z, v, iso, x2, y2, z2); if(nb == 1){ - unsigned int color = opt->getColor(k, opt->NbIso); - SVector3 n = getPointNormal(p, iso); - p->va_points->add(x2, y2, z2, &n, &color, 0, unique); + unsigned int color = opt->getColor(k, opt->NbIso); + SVector3 n = getPointNormal(p, iso); + p->va_points->add(x2, y2, z2, &n, &color, 0, unique); } if(vmin == vmax) break; } @@ -398,7 +398,7 @@ void addScalarLine(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, } void addOutlineTriangle(PView *p, double xyz[NMAX][3], unsigned int color, bool pre, - int i0=0, int i1=1, int i2=2) + int i0=0, int i1=1, int i2=2) { PViewOptions *opt = p->getOptions(); @@ -414,8 +414,8 @@ void addOutlineTriangle(PView *p, double xyz[NMAX][3], unsigned int color, bool unsigned int col[2] = {color, color}; if(opt->SmoothNormals){ for(int j = 0; j < 2; j++){ - if(pre) p->normals->add(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); - else p->normals->get(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); + if(pre) p->normals->add(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); + else p->normals->get(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); } } getLineNormal(p, x, y, z, 0, n, false); @@ -424,7 +424,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, bool skin=false) + int i0=0, int i1=1, int i2=2, bool unique=false, bool skin=false) { PViewOptions *opt = p->getOptions(); @@ -455,11 +455,11 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool SVector3 n[3] = {nfac, nfac, nfac}; unsigned int col[3]; for(int i = 0; i < 3; i++){ - if(opt->SmoothNormals){ - if(pre) p->normals->add(x[i], y[i], z[i], n[i][0], n[i][1], n[i][2]); - else p->normals->get(x[i], y[i], z[i], n[i][0], n[i][1], n[i][2]); - } - col[i] = opt->getColor(v[i], vmin, vmax); + if(opt->SmoothNormals){ + if(pre) p->normals->add(x[i], y[i], z[i], n[i][0], n[i][1], n[i][2]); + else p->normals->get(x[i], y[i], z[i], n[i][0], n[i][1], n[i][2]); + } + col[i] = opt->getColor(v[i], vmin, vmax); } if(!pre) p->va_triangles->add(x, y, z, n, col, 0, unique, skin); } @@ -467,22 +467,22 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool double x2[10], y2[10], z2[10], v2[10]; int nb = CutTriangle(x, y, z, v, vmin, vmax, x2, y2, z2, v2); if(nb >= 3){ - for(int j = 2; j < nb; j++){ - double x3[3] = {x2[0], x2[j - 1], x2[j]}; - double y3[3] = {y2[0], y2[j - 1], y2[j]}; - double z3[3] = {z2[0], z2[j - 1], z2[j]}; - double v3[3] = {v2[0], v2[j - 1], v2[j]}; - SVector3 n[3] = {nfac, nfac, nfac}; - unsigned int col[3]; - for(int i = 0; i < 3; i++){ - if(opt->SmoothNormals){ - if(pre) p->normals->add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); - else p->normals->get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); - } - col[i] = opt->getColor(v3[i], vmin, vmax); - } - if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, unique, skin); - } + for(int j = 2; j < nb; j++){ + double x3[3] = {x2[0], x2[j - 1], x2[j]}; + double y3[3] = {y2[0], y2[j - 1], y2[j]}; + double z3[3] = {z2[0], z2[j - 1], z2[j]}; + double v3[3] = {v2[0], v2[j - 1], v2[j]}; + SVector3 n[3] = {nfac, nfac, nfac}; + unsigned int col[3]; + for(int i = 0; i < 3; i++){ + if(opt->SmoothNormals){ + if(pre) p->normals->add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); + else p->normals->get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); + } + col[i] = opt->getColor(v3[i], vmin, vmax); + } + if(!pre) p->va_triangles->add(x3, y3, z3, n, col, 0, unique, skin); + } } } } @@ -495,21 +495,21 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool double x2[10], y2[10], z2[10], v2[10]; int nb = CutTriangle(x, y, z, v, min, max, x2, y2, z2, v2); if(nb >= 3){ - unsigned color = opt->getColor(k, opt->NbIso); - unsigned int col[3] = {color, color, color}; - for(int j = 2; j < nb; j++){ - double x3[3] = {x2[0], x2[j - 1], x2[j]}; - double y3[3] = {y2[0], y2[j - 1], y2[j]}; - double z3[3] = {z2[0], z2[j - 1], z2[j]}; - SVector3 n[3] = {nfac, nfac, nfac}; - if(opt->SmoothNormals){ - for(int i = 0; i < 3; i++){ - if(pre) p->normals->add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); - 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, skin); - } + unsigned color = opt->getColor(k, opt->NbIso); + unsigned int col[3] = {color, color, color}; + for(int j = 2; j < nb; j++){ + double x3[3] = {x2[0], x2[j - 1], x2[j]}; + double y3[3] = {y2[0], y2[j - 1], y2[j]}; + double z3[3] = {z2[0], z2[j - 1], z2[j]}; + SVector3 n[3] = {nfac, nfac, nfac}; + if(opt->SmoothNormals){ + for(int i = 0; i < 3; i++){ + if(pre) p->normals->add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); + 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, skin); + } } if(vmin == vmax) break; } @@ -522,18 +522,18 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool double x2[3], y2[3], z2[3]; int nb = IsoTriangle(x, y, z, v, iso, x2, y2, z2); if(nb == 2){ - unsigned int color = opt->getColor(k, opt->NbIso); - unsigned int col[2] = {color, color}; - SVector3 n[2] = {nfac, nfac}; - if(opt->SmoothNormals){ - for(int i = 0; i < 2; i++){ - if(pre) p->normals->add(x2[i], y2[i], z2[i], n[i][0], n[i][1], n[i][2]); - else p->normals->get(x2[i], y2[i], z2[i], n[i][0], n[i][1], n[i][2]); - } - } - double v[2] = {iso, iso}; - getLineNormal(p, x, y, z, v, n, false); - if(!pre) p->va_lines->add(x2, y2, z2, n, col, 0, unique); + unsigned int color = opt->getColor(k, opt->NbIso); + unsigned int col[2] = {color, color}; + SVector3 n[2] = {nfac, nfac}; + if(opt->SmoothNormals){ + for(int i = 0; i < 2; i++){ + if(pre) p->normals->add(x2[i], y2[i], z2[i], n[i][0], n[i][1], n[i][2]); + else p->normals->get(x2[i], y2[i], z2[i], n[i][0], n[i][1], n[i][2]); + } + } + double v[2] = {iso, iso}; + getLineNormal(p, x, y, z, v, n, false); + if(!pre) p->va_lines->add(x2, y2, z2, n, col, 0, unique); } if(vmin == vmax) break; } @@ -541,7 +541,7 @@ void addScalarTriangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool } void addOutlineQuadrangle(PView *p, double xyz[NMAX][3], unsigned int color, bool pre, - int i0=0, int i1=1, int i2=2, int i3=3) + int i0=0, int i1=1, int i2=2, int i3=3) { PViewOptions *opt = p->getOptions(); @@ -557,8 +557,8 @@ void addOutlineQuadrangle(PView *p, double xyz[NMAX][3], unsigned int color, boo unsigned int col[2] = {color, color}; if(opt->SmoothNormals){ for(int j = 0; j < 2; j++){ - if(pre) p->normals->add(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); - else p->normals->get(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); + if(pre) p->normals->add(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); + else p->normals->get(x[j], y[j], z[j], n[j][0], n[j][1], n[j][2]); } } getLineNormal(p, x, y, z, 0, n, false); @@ -567,7 +567,7 @@ void addOutlineQuadrangle(PView *p, double xyz[NMAX][3], unsigned int color, boo } void addScalarQuadrangle(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, - int i0=0, int i1=1, int i2=2, int i3=3, bool unique=false) + int i0=0, int i1=1, int i2=2, int i3=3, bool unique=false) { PViewOptions *opt = p->getOptions(); @@ -594,7 +594,7 @@ void addOutlineTetrahedron(PView *p, double xyz[NMAX][3], unsigned int color, bo } void addScalarTetrahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre, - int i0=0, int i1=1, int i2=2, int i3=3) + int i0=0, int i1=1, int i2=2, int i3=3) { PViewOptions *opt = p->getOptions(); @@ -626,22 +626,22 @@ void addScalarTetrahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], bo double x2[NMAX], y2[NMAX], z2[NMAX], nn[3]; int nb = IsoSimplex(x, y, z, v, iso, x2, y2, z2, nn); if(nb >= 3){ - unsigned int color = opt->getColor(k, opt->NbIso); - unsigned int col[3] = {color, color, color}; - for(int j = 2; j < nb; j++){ - double x3[3] = {x2[0], x2[j - 1], x2[j]}; - double y3[3] = {y2[0], y2[j - 1], y2[j]}; - double z3[3] = {z2[0], z2[j - 1], z2[j]}; - SVector3 n[3]; - for(int i = 0; i < 3; i++){ - n[i][0] = nn[0]; n[i][1] = nn[1]; n[i][2] = nn[2]; - if(opt->SmoothNormals){ - if(pre) p->normals->add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); - 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, false); - } + unsigned int color = opt->getColor(k, opt->NbIso); + unsigned int col[3] = {color, color, color}; + for(int j = 2; j < nb; j++){ + double x3[3] = {x2[0], x2[j - 1], x2[j]}; + double y3[3] = {y2[0], y2[j - 1], y2[j]}; + double z3[3] = {z2[0], z2[j - 1], z2[j]}; + SVector3 n[3]; + for(int i = 0; i < 3; i++){ + n[i][0] = nn[0]; n[i][1] = nn[1]; n[i][2] = nn[2]; + if(opt->SmoothNormals){ + if(pre) p->normals->add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]); + 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, false); + } } if(vmin == vmax) break; } @@ -651,11 +651,11 @@ void addScalarTetrahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], bo void addOutlineHexahedron(PView *p, double xyz[NMAX][3], unsigned int color, bool pre) { const int iq[6][4] = {{0, 3, 2, 1}, {0, 1, 5, 4}, {0, 4, 7, 3}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {4, 5, 6, 7}}; + {1, 2, 6, 5}, {2, 3, 7, 6}, {4, 5, 6, 7}}; for(int i = 0; i < 6; i++) addOutlineQuadrangle(p, xyz, color, pre, iq[i][0], iq[i][1], - iq[i][2], iq[i][3]); + iq[i][2], iq[i][3]); } void addScalarHexahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], bool pre) @@ -663,9 +663,9 @@ void addScalarHexahedron(PView *p, double xyz[NMAX][3], double val[NMAX][9], boo PViewOptions *opt = p->getOptions(); const int iq[6][4] = {{0, 3, 2, 1}, {0, 1, 5, 4}, {0, 4, 7, 3}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {4, 5, 6, 7}}; + {1, 2, 6, 5}, {2, 3, 7, 6}, {4, 5, 6, 7}}; const int is[6][4] = {{0, 1, 3, 7}, {0, 4, 1, 7}, {1, 4, 5, 7}, - {1, 2, 3, 7}, {1, 6, 2, 7}, {1, 5, 6, 7}}; + {1, 2, 3, 7}, {1, 6, 2, 7}, {1, 5, 6, 7}}; if(opt->Boundary > 0){ opt->Boundary--; @@ -757,7 +757,7 @@ void addOutlineElement(PView *p, int numEdges, double xyz[NMAX][3], bool pre) } void addScalarElement(PView *p, int numEdges, double xyz[NMAX][3], - double val[NMAX][9], bool pre) + double val[NMAX][9], bool pre) { switch(numEdges){ case 0: addScalarPoint(p, xyz, val, pre); break; @@ -772,7 +772,7 @@ void addScalarElement(PView *p, int numEdges, double xyz[NMAX][3], } void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, - double xyz[NMAX][3], double val[NMAX][9], bool pre) + double xyz[NMAX][3], double val[NMAX][9], bool pre) { PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); @@ -780,7 +780,7 @@ void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, int numComp2; double val2[NMAX][9]; getExternalValues(p, opt->ExternalViewIndex, ient, iele, numNodes, - 3, val, numComp2, val2); + 3, val, numComp2, val2); if(opt->VectorType == PViewOptions::Displacement){ for(int i = 0; i < numNodes; i++) @@ -797,27 +797,27 @@ void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, // add point trajectories if(!pre && numNodes == 1 && opt->TimeStep > 0 && opt->LineWidth){ for(int ts = 0; ts < opt->TimeStep; ts++){ - double xyz0[3], dxyz[3][2]; - for(int j = 0; j < 3; j++){ - data->getNode(ts, ient, iele, 0, xyz0[0], xyz0[1], xyz0[2]); - data->getValue(ts, ient, iele, 0, j, dxyz[j][0]); - data->getValue(ts + 1, ient, iele, 0, j, dxyz[j][1]); - } - unsigned int col[2]; - double norm[2]; - for(int i = 0; i < 2; i++){ - norm[i] = sqrt(dxyz[0][i] * dxyz[0][i] + - dxyz[1][i] * dxyz[1][i] + - dxyz[2][i] * dxyz[2][i]); - col[i] = opt->getColor(norm[i], opt->TmpMin, opt->TmpMax); - } - for(int j = 0; j < 3; j++){ - dxyz[j][0] = xyz0[j] + dxyz[j][0] * opt->DisplacementFactor; - dxyz[j][1] = xyz0[j] + dxyz[j][1] * opt->DisplacementFactor; - } - SVector3 n[2]; - getLineNormal(p, dxyz[0], dxyz[1], dxyz[2], norm, n, true); - p->va_lines->add(dxyz[0], dxyz[1], dxyz[2], n, col, 0, false); + double xyz0[3], dxyz[3][2]; + for(int j = 0; j < 3; j++){ + data->getNode(ts, ient, iele, 0, xyz0[0], xyz0[1], xyz0[2]); + data->getValue(ts, ient, iele, 0, j, dxyz[j][0]); + data->getValue(ts + 1, ient, iele, 0, j, dxyz[j][1]); + } + unsigned int col[2]; + double norm[2]; + for(int i = 0; i < 2; i++){ + norm[i] = sqrt(dxyz[0][i] * dxyz[0][i] + + dxyz[1][i] * dxyz[1][i] + + dxyz[2][i] * dxyz[2][i]); + col[i] = opt->getColor(norm[i], opt->TmpMin, opt->TmpMax); + } + for(int j = 0; j < 3; j++){ + dxyz[j][0] = xyz0[j] + dxyz[j][0] * opt->DisplacementFactor; + dxyz[j][1] = xyz0[j] + dxyz[j][1] * opt->DisplacementFactor; + } + SVector3 n[2]; + getLineNormal(p, dxyz[0], dxyz[1], dxyz[2], norm, n, true); + p->va_lines->add(dxyz[0], dxyz[1], dxyz[2], n, col, 0, false); } } return; @@ -829,14 +829,14 @@ void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, for(int i = 0; i < numNodes; i++){ double v2 = ComputeScalarRep(numComp2, val2[i]); if(v2 >= opt->ExternalMin && v2 <= opt->ExternalMax){ - unsigned int color = opt->getColor(v2, opt->ExternalMin, opt->ExternalMax); - unsigned int col[2] = {color, color}; - double dxyz[3][2]; - for(int j = 0; j < 3; j++){ - dxyz[j][0] = xyz[i][j]; - dxyz[j][1] = val[i][j]; - } - p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], 0, col, 0, false); + unsigned int color = opt->getColor(v2, opt->ExternalMin, opt->ExternalMax); + unsigned int col[2] = {color, color}; + double dxyz[3][2]; + for(int j = 0; j < 3; j++){ + dxyz[j][0] = xyz[i][j]; + dxyz[j][1] = val[i][j]; + } + p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], 0, col, 0, false); } } } @@ -864,8 +864,8 @@ void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, unsigned int col[2] = {color, color}; double dxyz[3][2]; for(int i = 0; i < 3; i++){ - dxyz[i][0] = pc[i]; - dxyz[i][1] = d[i]; + dxyz[i][0] = pc[i]; + dxyz[i][1] = d[i]; } p->va_vectors->add(dxyz[0], dxyz[1], dxyz[2], 0, col, 0, false); } @@ -873,7 +873,7 @@ void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, } void addTensorElement(PView *p, int numNodes, int numEdges, double xyz[NMAX][3], - double val[NMAX][9], bool pre) + double val[NMAX][9], bool pre) { PViewOptions *opt = p->getOptions(); @@ -901,25 +901,25 @@ void addElementsInArrays(PView *p, bool preprocessNormalsOnly) int numComp = data->getNumComponents(opt->TimeStep, ent, i); int numNodes = data->getNumNodes(opt->TimeStep, ent, i); for(int j = 0; j < numNodes; j++){ - data->getNode(opt->TimeStep, ent, i, j, xyz[j][0], xyz[j][1], xyz[j][2]); - for(int k = 0; k < numComp; k++) - data->getValue(opt->TimeStep, ent, i, j, k, val[j][k]); + data->getNode(opt->TimeStep, ent, i, j, xyz[j][0], xyz[j][1], xyz[j][2]); + for(int k = 0; k < numComp; k++) + data->getValue(opt->TimeStep, ent, i, j, k, val[j][k]); } changeCoordinates(p, ent, i, numNodes, numEdges, numComp, xyz, val); for(int j = 0; j < numNodes; j++) - opt->TmpBBox += SPoint3(xyz[j][0], xyz[j][1], xyz[j][2]); + opt->TmpBBox += SPoint3(xyz[j][0], xyz[j][1], xyz[j][2]); if(opt->ShowElement) - addOutlineElement(p, numEdges, xyz, preprocessNormalsOnly); + addOutlineElement(p, numEdges, xyz, preprocessNormalsOnly); if(opt->IntervalsType != PViewOptions::Numeric){ - if(numComp == 1 && opt->DrawScalars) - addScalarElement(p, numEdges, xyz, val, preprocessNormalsOnly); - else if(numComp == 3 && opt->DrawVectors) - addVectorElement(p, ent, i, numNodes, numEdges, xyz, val, preprocessNormalsOnly); - else if(numComp == 9 && opt->DrawTensors) - addTensorElement(p, numNodes, numEdges, xyz, val, preprocessNormalsOnly); + if(numComp == 1 && opt->DrawScalars) + addScalarElement(p, numEdges, xyz, val, preprocessNormalsOnly); + else if(numComp == 3 && opt->DrawVectors) + addVectorElement(p, ent, i, numNodes, numEdges, xyz, val, preprocessNormalsOnly); + else if(numComp == 9 && opt->DrawTensors) + addTensorElement(p, numNodes, numEdges, xyz, val, preprocessNormalsOnly); } } } @@ -940,8 +940,8 @@ void drawArrays(PView *p, VertexArray *va, GLint type, bool useNormalArray) glColor4ubv((GLubyte *)va->getColorArray(4 * i)); double f = 1.; if(opt->PointType == 2){ - char *n = va->getNormalArray(3 * i); - f = char2float(*n); + char *n = va->getNormalArray(3 * i); + f = char2float(*n); } Draw_Sphere(opt->PointSize * f, p[0], p[1], p[2], opt->Light); } @@ -953,13 +953,13 @@ void drawArrays(PView *p, VertexArray *va, GLint type, bool useNormalArray) double x[2] = {p0[0], p1[0]}, y[2] = {p0[1], p1[1]}, z[2] = {p0[2], p1[2]}; glColor4ubv((GLubyte *)va->getColorArray(4 * i)); if(opt->LineType == 2){ - char *n0 = va->getNormalArray(3 * i); - char *n1 = va->getNormalArray(3 * (i + 1)); - double v0 = char2float(*n0), v1 = char2float(*n1); - Draw_TapCylinder(opt->LineWidth, v0, v1, 0., 1., x, y, z, opt->Light); + char *n0 = va->getNormalArray(3 * i); + char *n1 = va->getNormalArray(3 * (i + 1)); + double v0 = char2float(*n0), v1 = char2float(*n1); + Draw_TapCylinder(opt->LineWidth, v0, v1, 0., 1., x, y, z, opt->Light); } else - Draw_Cylinder(opt->LineWidth, x, y, z, opt->Light); + Draw_Cylinder(opt->LineWidth, x, y, z, opt->Light); } } else{ @@ -1004,17 +1004,17 @@ void drawVectorArray(PView *p, VertexArray *va) double px = v[0] * scale, py = v[1] * scale, pz = v[2] * scale; // only draw vectors larger than 1 pixel on screen if(fabs(px) > 1. || fabs(py) > 1. || fabs(pz) > 1.){ - double d = CTX.pixel_equiv_x / CTX.s[0]; - double dx = px * d, dy = py * d, dz = pz * d; - double x = s[0], y = s[1], z = s[2]; - if(opt->CenterGlyphs){ - x -= 0.5 * dx; - y -= 0.5 * dy; - z -= 0.5 * dz; - } - Draw_Vector(opt->VectorType, opt->IntervalsType != PViewOptions::Iso, - opt->ArrowRelHeadRadius, opt->ArrowRelStemLength, - opt->ArrowRelStemRadius, x, y, z, dx, dy, dz, opt->Light); + double d = CTX.pixel_equiv_x / CTX.s[0]; + double dx = px * d, dy = py * d, dz = pz * d; + double x = s[0], y = s[1], z = s[2]; + if(opt->CenterGlyphs){ + x -= 0.5 * dx; + y -= 0.5 * dy; + z -= 0.5 * dz; + } + Draw_Vector(opt->VectorType, opt->IntervalsType != PViewOptions::Iso, + opt->ArrowRelHeadRadius, opt->ArrowRelStemLength, + opt->ArrowRelStemRadius, x, y, z, dx, dy, dz, opt->Light); } } } @@ -1038,7 +1038,7 @@ std::string stringValue(int numComp, double d[9], double norm, char *format) } void drawNumberGlyphs(PView *p, int numNodes, int numComp, - double xyz[NMAX][3], double val[NMAX][9]) + double xyz[NMAX][3], double val[NMAX][9]) { PViewOptions *opt = p->getOptions(); double d[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}; @@ -1060,30 +1060,30 @@ void drawNumberGlyphs(PView *p, int numNodes, int numComp, glRasterPos3d(pc.x(), pc.y(), pc.z()); const char *txt = stringValue(numComp, d, v, opt->Format).c_str(); if(opt->CenterGlyphs) - Draw_String_Center(txt); + Draw_String_Center(txt); else - Draw_String(txt); + Draw_String(txt); } } else if(opt->GlyphLocation == PViewOptions::Vertex){ for(int i = 0; i < numNodes; i++){ double v = ComputeScalarRep(numComp, val[i]); if(v >= vmin && v <= vmax){ - unsigned int col = opt->getColor(v, vmin, vmax); - glColor4ubv((GLubyte *) & col); - glRasterPos3d(xyz[i][0], xyz[i][1], xyz[i][2]); - const char *txt = stringValue(numComp, val[i], v, opt->Format).c_str(); - if(opt->CenterGlyphs) - Draw_String_Center(txt); - else - Draw_String(txt); + unsigned int col = opt->getColor(v, vmin, vmax); + glColor4ubv((GLubyte *) & col); + glRasterPos3d(xyz[i][0], xyz[i][1], xyz[i][2]); + const char *txt = stringValue(numComp, val[i], v, opt->Format).c_str(); + if(opt->CenterGlyphs) + Draw_String_Center(txt); + else + Draw_String(txt); } } } } void drawNormalVectorGlyphs(PView *p, int numNodes, double xyz[NMAX][3], - double val[NMAX][9]) + double val[NMAX][9]) { PViewOptions *opt = p->getOptions(); @@ -1098,12 +1098,12 @@ void drawNormalVectorGlyphs(PView *p, int numNodes, double xyz[NMAX][3], n[i] *= opt->Normals * CTX.pixel_equiv_x / CTX.s[i]; glColor4ubv((GLubyte *) & opt->color.normals); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc[0], pc[1], pc[2], n[0], n[1], n[2], opt->Light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + pc[0], pc[1], pc[2], n[0], n[1], n[2], opt->Light); } void drawTangentVectorGlyphs(PView *p, int numNodes, double xyz[NMAX][3], - double val[NMAX][9]) + double val[NMAX][9]) { PViewOptions *opt = p->getOptions(); @@ -1116,8 +1116,8 @@ void drawTangentVectorGlyphs(PView *p, int numNodes, double xyz[NMAX][3], t[i] *= opt->Tangents * CTX.pixel_equiv_x / CTX.s[i]; glColor4ubv((GLubyte *) & opt->color.tangents); Draw_Vector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc[0], pc[1], pc[2], t[0], t[1], t[2], opt->Light); + CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, + pc[0], pc[1], pc[2], t[0], t[1], t[2], opt->Light); } void drawGlyphs(PView *p) @@ -1141,17 +1141,17 @@ void drawGlyphs(PView *p) int numComp = data->getNumComponents(opt->TimeStep, ent, i); int numNodes = data->getNumNodes(opt->TimeStep, ent, i); for(int j = 0; j < numNodes; j++){ - data->getNode(opt->TimeStep, ent, i, j, xyz[j][0], xyz[j][1], xyz[j][2]); - for(int k = 0; k < numComp; k++) - data->getValue(opt->TimeStep, ent, i, j, k, val[j][k]); + data->getNode(opt->TimeStep, ent, i, j, xyz[j][0], xyz[j][1], xyz[j][2]); + for(int k = 0; k < numComp; k++) + data->getValue(opt->TimeStep, ent, i, j, k, val[j][k]); } changeCoordinates(p, ent, i, numNodes, numEdges, numComp, xyz, val); if(opt->IntervalsType == PViewOptions::Numeric) - drawNumberGlyphs(p, numNodes, numComp, xyz, val); + drawNumberGlyphs(p, numNodes, numComp, xyz, val); if(dim == 2 && opt->Normals) - drawNormalVectorGlyphs(p, numNodes, xyz, val); + drawNormalVectorGlyphs(p, numNodes, xyz, val); else if(dim == 1 && opt->Tangents) - drawTangentVectorGlyphs(p, numNodes, xyz, val); + drawTangentVectorGlyphs(p, numNodes, xyz, val); } } } @@ -1190,10 +1190,10 @@ class initPView { heuristic = (tets + prisms + pyrs + hexas) / 10; else if(opt->IntervalsType == PViewOptions::Continuous) heuristic = (tris + 2 * quads + 6 * tets + - 8 * prisms + 6 * pyrs + 12 * hexas); + 8 * prisms + 6 * pyrs + 12 * hexas); else if(opt->IntervalsType == PViewOptions::Discrete) heuristic = (tris + 2 * quads + 6 * tets + - 8 * prisms + 6 * pyrs + 12 * hexas) * 2; + 8 * prisms + 6 * pyrs + 12 * hexas) * 2; return heuristic + 10000; } int _estimateNumVectors(PView *p) @@ -1246,8 +1246,8 @@ class initPView { p->va_vectors->finalize(); Msg(INFO, "Rendering %d vertices", p->va_points->getNumVertices() + - p->va_lines->getNumVertices() + p->va_triangles->getNumVertices() + - p->va_vectors->getNumVertices()); + p->va_lines->getNumVertices() + p->va_triangles->getNumVertices() + + p->va_vectors->getNumVertices()); p->setChanged(false); } @@ -1286,28 +1286,28 @@ class drawPView { for(int i = 0; i < 6; i++) if(CTX.clip[i] & (1 << (2 + p->getIndex()))) - glEnable((GLenum)(GL_CLIP_PLANE0 + i)); + glEnable((GLenum)(GL_CLIP_PLANE0 + i)); else - glDisable((GLenum)(GL_CLIP_PLANE0 + i)); + glDisable((GLenum)(GL_CLIP_PLANE0 + i)); if(CTX.alpha && ColorTable_IsAlpha(&opt->CT)){ if(opt->FakeTransparency){ - // simple additive blending "a la xpost": - glBlendFunc(GL_SRC_ALPHA, GL_ONE); // glBlendEquation(GL_FUNC_ADD); - // maximum intensity projection "a la volsuite": - // glBlendFunc(GL_ONE, GL_ONE); // glBlendEquation(GL_MAX); - glEnable(GL_BLEND); - glDisable(GL_DEPTH_TEST); + // simple additive blending "a la xpost": + glBlendFunc(GL_SRC_ALPHA, GL_ONE); // glBlendEquation(GL_FUNC_ADD); + // maximum intensity projection "a la volsuite": + // glBlendFunc(GL_ONE, GL_ONE); // glBlendEquation(GL_MAX); + glEnable(GL_BLEND); + glDisable(GL_DEPTH_TEST); } else{ - // real translucent blending (requires back-to-front traversal) - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // glBlendEquation(GL_FUNC_ADD); - glEnable(GL_BLEND); - if(eyeChanged(p)){ - Msg(DEBUG, "Sorting View[%d] for transparency", p->getIndex()); - p->va_triangles->sort(p->getEye().x(), p->getEye().y(), p->getEye().z()); - } + // real translucent blending (requires back-to-front traversal) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // glBlendEquation(GL_FUNC_ADD); + glEnable(GL_BLEND); + if(eyeChanged(p)){ + Msg(DEBUG, "Sorting View[%d] for transparency", p->getIndex()); + p->va_triangles->sort(p->getEye().x(), p->getEye().y(), p->getEye().z()); + } } } @@ -1340,11 +1340,11 @@ class drawPView { if(opt->DrawStrings){ glColor4ubv((GLubyte *) & opt->color.text3d); for(int i = 0; i < data->getNumStrings3D(); i++){ - double x, y, z, style; - std::string str; - data->getString3D(i, opt->TimeStep, str, x, y, z, style); - glRasterPos3d(x, y, z); - Draw_String(str.c_str(), style); + double x, y, z, style; + std::string str; + data->getString3D(i, opt->TimeStep, str, x, y, z, style); + glRasterPos3d(x, y, z); + Draw_String(str.c_str(), style); } } @@ -1361,11 +1361,11 @@ class drawPView { glLineWidth(CTX.line_width); gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); if(!opt->AxesAutoPosition) - Draw_Axes(opt->Axes, opt->AxesTics, opt->AxesFormat, opt->AxesLabel, - opt->AxesPosition,opt->AxesMikado); + Draw_Axes(opt->Axes, opt->AxesTics, opt->AxesFormat, opt->AxesLabel, + opt->AxesPosition,opt->AxesMikado); else if(!opt->TmpBBox.empty()) - Draw_Axes(opt->Axes, opt->AxesTics, opt->AxesFormat, opt->AxesLabel, - opt->TmpBBox,opt->AxesMikado); + Draw_Axes(opt->Axes, opt->AxesTics, opt->AxesFormat, opt->AxesLabel, + opt->TmpBBox,opt->AxesMikado); } } @@ -1388,14 +1388,14 @@ class drawPViewBoundingBox { gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor); Draw_Box(bb.min().x(), bb.min().y(), bb.min().z(), - bb.max().x(), bb.max().y(), bb.max().z()); + bb.max().x(), bb.max().y(), bb.max().z()); glColor3d(1., 0., 0.); for(int i = 0; i < 6; i++) if(CTX.clip[i] & (1 << (2 + p->getIndex()))) - Draw_PlaneInBoundingBox(bb.min().x(), bb.min().y(), bb.min().z(), - bb.max().x(), bb.max().y(), bb.max().z(), - CTX.clip_plane[i][0], CTX.clip_plane[i][1], - CTX.clip_plane[i][2], CTX.clip_plane[i][3]); + Draw_PlaneInBoundingBox(bb.min().x(), bb.min().y(), bb.min().z(), + bb.max().x(), bb.max().y(), bb.max().z(), + CTX.clip_plane[i][0], CTX.clip_plane[i][1], + CTX.clip_plane[i][2], CTX.clip_plane[i][3]); } }; diff --git a/Graphics/ReadImg.cpp b/Graphics/ReadImg.cpp index 311f83c33190722204b15eab3b53faed4bfe82e0..f6fe800c714685292e52cffb103ef4b7df109484 100644 --- a/Graphics/ReadImg.cpp +++ b/Graphics/ReadImg.cpp @@ -1,4 +1,4 @@ -// $Id: ReadImg.cpp,v 1.23 2008-02-22 07:49:39 geuzaine Exp $ +// $Id: ReadImg.cpp,v 1.24 2008-03-20 11:44:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -34,7 +34,7 @@ // from an image, we create a post-procession view static PViewDataList *Img2Data(Fl_RGB_Image &img_init, int quads=1, - int resizex=0, int resizey=0) + int resizex=0, int resizey=0) { img_init.desaturate(); // convert to grayscale @@ -71,27 +71,27 @@ static PViewDataList *Img2Data(Fl_RGB_Image &img_init, int quads=1, double val3 = (double)a1[j + 1]/255.; double val4 = (double)a[j + 1]/255.; if(quads){ // generate quads - List_Add(d->SQ, &x); List_Add(d->SQ, &x); - List_Add(d->SQ, &x1); List_Add(d->SQ, &x1); - List_Add(d->SQ, &y); List_Add(d->SQ, &y1); - List_Add(d->SQ, &y1); List_Add(d->SQ, &y); - List_Add(d->SQ, &z); List_Add(d->SQ, &z); - List_Add(d->SQ, &z); List_Add(d->SQ, &z); - List_Add(d->SQ, &val1); List_Add(d->SQ, &val2); - List_Add(d->SQ, &val3); List_Add(d->SQ, &val4); - d->NbSQ++; + List_Add(d->SQ, &x); List_Add(d->SQ, &x); + List_Add(d->SQ, &x1); List_Add(d->SQ, &x1); + List_Add(d->SQ, &y); List_Add(d->SQ, &y1); + List_Add(d->SQ, &y1); List_Add(d->SQ, &y); + List_Add(d->SQ, &z); List_Add(d->SQ, &z); + List_Add(d->SQ, &z); List_Add(d->SQ, &z); + List_Add(d->SQ, &val1); List_Add(d->SQ, &val2); + List_Add(d->SQ, &val3); List_Add(d->SQ, &val4); + d->NbSQ++; } else{ // generate triangles - List_Add(d->ST, &x); List_Add(d->ST, &x); List_Add(d->ST, &x1); - List_Add(d->ST, &y); List_Add(d->ST, &y1); List_Add(d->ST, &y1); - List_Add(d->ST, &z); List_Add(d->ST, &z); List_Add(d->ST, &z); - List_Add(d->ST, &val1); List_Add(d->ST, &val2); List_Add(d->ST, &val3); - d->NbST++; - List_Add(d->ST, &x); List_Add(d->ST, &x1); List_Add(d->ST, &x1); - List_Add(d->ST, &y); List_Add(d->ST, &y1); List_Add(d->ST, &y); - List_Add(d->ST, &z); List_Add(d->ST, &z); List_Add(d->ST, &z); - List_Add(d->ST, &val1); List_Add(d->ST, &val3); List_Add(d->ST, &val4); - d->NbST++; + List_Add(d->ST, &x); List_Add(d->ST, &x); List_Add(d->ST, &x1); + List_Add(d->ST, &y); List_Add(d->ST, &y1); List_Add(d->ST, &y1); + List_Add(d->ST, &z); List_Add(d->ST, &z); List_Add(d->ST, &z); + List_Add(d->ST, &val1); List_Add(d->ST, &val2); List_Add(d->ST, &val3); + d->NbST++; + List_Add(d->ST, &x); List_Add(d->ST, &x1); List_Add(d->ST, &x1); + List_Add(d->ST, &y); List_Add(d->ST, &y1); List_Add(d->ST, &y); + List_Add(d->ST, &z); List_Add(d->ST, &z); List_Add(d->ST, &z); + List_Add(d->ST, &val1); List_Add(d->ST, &val3); List_Add(d->ST, &val4); + d->NbST++; } } } diff --git a/Graphics/Scale.cpp b/Graphics/Scale.cpp index 5799974834bcd4c3494799d83e8ca882e34e0334..afef5c9e23b5546320079fadf47b8d98aa7fbee9 100644 --- a/Graphics/Scale.cpp +++ b/Graphics/Scale.cpp @@ -1,4 +1,4 @@ -// $Id: Scale.cpp,v 1.69 2008-02-17 08:48:00 geuzaine Exp $ +// $Id: Scale.cpp,v 1.70 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -28,7 +28,7 @@ extern Context_T CTX; static void drawScaleBar(PView *p, double xmin, double ymin, double width, - double height, double tic, int horizontal) + double height, double tic, int horizontal) { PViewOptions *opt = p->getOptions(); @@ -40,16 +40,16 @@ static void drawScaleBar(PView *p, double xmin, double ymin, double width, glColor4ubv((GLubyte *) &col); glBegin(GL_QUADS); if(horizontal){ - glVertex2d(xmin + i * box, ymin); - glVertex2d(xmin + (i + 1) * box, ymin); - glVertex2d(xmin + (i + 1) * box, ymin + height); - glVertex2d(xmin + i * box, ymin + height); + glVertex2d(xmin + i * box, ymin); + glVertex2d(xmin + (i + 1) * box, ymin); + glVertex2d(xmin + (i + 1) * box, ymin + height); + glVertex2d(xmin + i * box, ymin + height); } else{ - glVertex2d(xmin, ymin + i * box); - glVertex2d(xmin + width, ymin + i * box); - glVertex2d(xmin + width, ymin + (i + 1) * box); - glVertex2d(xmin, ymin + (i + 1) * box); + glVertex2d(xmin, ymin + i * box); + glVertex2d(xmin + width, ymin + i * box); + glVertex2d(xmin + width, ymin + (i + 1) * box); + glVertex2d(xmin, ymin + (i + 1) * box); } glEnd(); } @@ -60,23 +60,23 @@ static void drawScaleBar(PView *p, double xmin, double ymin, double width, unsigned int col1 = opt->getColor(v1, opt->TmpMin, opt->TmpMax); glColor4ubv((GLubyte *) &col1); if(horizontal){ - glVertex2d(xmin + i * box, ymin + height); - glVertex2d(xmin + i * box, ymin); + glVertex2d(xmin + i * box, ymin + height); + glVertex2d(xmin + i * box, ymin); } else{ - glVertex2d(xmin, ymin + i * box); - glVertex2d(xmin + width, ymin + i * box); + glVertex2d(xmin, ymin + i * box); + glVertex2d(xmin + width, ymin + i * box); } double v2 = opt->TmpMin + (i + 1) * dv; unsigned int col2 = opt->getColor(v2, opt->TmpMin, opt->TmpMax); glColor4ubv((GLubyte *) &col2); if(horizontal){ - glVertex2d(xmin + (i + 1) * box, ymin); - glVertex2d(xmin + (i + 1) * box, ymin + height); + glVertex2d(xmin + (i + 1) * box, ymin); + glVertex2d(xmin + (i + 1) * box, ymin + height); } else{ - glVertex2d(xmin + width, ymin + (i + 1) * box); - glVertex2d(xmin, ymin + (i + 1) * box); + glVertex2d(xmin + width, ymin + (i + 1) * box); + glVertex2d(xmin, ymin + (i + 1) * box); } glEnd(); } @@ -85,12 +85,12 @@ static void drawScaleBar(PView *p, double xmin, double ymin, double width, glColor4ubv((GLubyte *) &col); glBegin(GL_LINES); if(horizontal){ - glVertex2d(xmin + box / 2. + i * box, ymin); - glVertex2d(xmin + box / 2. + i * box, ymin + height); + glVertex2d(xmin + box / 2. + i * box, ymin); + glVertex2d(xmin + box / 2. + i * box, ymin + height); } else{ - glVertex2d(xmin, ymin + box / 2. + i * box); - glVertex2d(xmin + width, ymin + box / 2. + i * box); + glVertex2d(xmin, ymin + box / 2. + i * box); + glVertex2d(xmin + width, ymin + box / 2. + i * box); } glEnd(); } @@ -98,7 +98,7 @@ static void drawScaleBar(PView *p, double xmin, double ymin, double width, } static void drawScaleValues(PView *p, double xmin, double ymin, double width, - double height, double tic, int horizontal) + double height, double tic, int horizontal) { PViewOptions *opt = p->getOptions(); @@ -114,7 +114,7 @@ static void drawScaleValues(PView *p, double xmin, double ymin, double width, int nbv = opt->NbIso; double f = (opt->IntervalsType == PViewOptions::Discrete || - opt->IntervalsType == PViewOptions::Continuous) ? 2 : 2.5; + opt->IntervalsType == PViewOptions::Continuous) ? 2 : 2.5; if(horizontal && width < nbv * maxw){ if(width < f * maxw) nbv = 1; @@ -136,12 +136,12 @@ static void drawScaleValues(PView *p, double xmin, double ymin, double width, double v = opt->getScaleValue(i, nbv + 1, opt->TmpMin, opt->TmpMax); sprintf(label, opt->Format, v); if(horizontal){ - glRasterPos2d(xmin + i * vbox, ymin + height + tic); - Draw_String_Center(label); + glRasterPos2d(xmin + i * vbox, ymin + height + tic); + Draw_String_Center(label); } else{ - glRasterPos2d(xmin + width + tic, ymin + i * vbox - font_a / 3.); - Draw_String(label); + glRasterPos2d(xmin + width + tic, ymin + i * vbox - font_a / 3.); + Draw_String(label); } } } @@ -154,19 +154,19 @@ static void drawScaleValues(PView *p, double xmin, double ymin, double width, double v = opt->getScaleValue(i, nbv, opt->TmpMin, opt->TmpMax); sprintf(label, opt->Format, v); if(horizontal){ - glRasterPos2d(xmin + box / 2. + i * vbox, ymin + height + tic); - Draw_String_Center(label); + glRasterPos2d(xmin + box / 2. + i * vbox, ymin + height + tic); + Draw_String_Center(label); } else{ - glRasterPos2d(xmin + width + tic, ymin + box / 2. + i * vbox - font_a / 3.); - Draw_String(label); + glRasterPos2d(xmin + width + tic, ymin + box / 2. + i * vbox - font_a / 3.); + Draw_String(label); } } } } static void drawScaleLabel(PView *p, double xmin, double ymin, double width, - double height, double tic, int horizontal) + double height, double tic, int horizontal) { PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); @@ -199,7 +199,7 @@ static void drawScaleLabel(PView *p, double xmin, double ymin, double width, } static void drawScale(PView *p, double xmin, double ymin, double width, - double height, double tic, int horizontal) + double height, double tic, int horizontal) { PViewData *data = p->getData(); PViewOptions *opt = p->getOptions(); @@ -267,49 +267,49 @@ void Draw_Scales() double ysep = 20.; double xc = (CTX.viewport[2] - CTX.viewport[0]) / 2.; if(scales.size() == 1){ - double w = (CTX.viewport[2] - CTX.viewport[0]) / 2., h = bar_size; - double x = xc - w / 2., y = CTX.viewport[1] + ysep; - drawScale(p, x, y, w, h, tic, 1); + double w = (CTX.viewport[2] - CTX.viewport[0]) / 2., h = bar_size; + double x = xc - w / 2., y = CTX.viewport[1] + ysep; + drawScale(p, x, y, w, h, tic, 1); } else{ - double xsep = maxw / 4. + (CTX.viewport[2] - CTX.viewport[0]) / 10.; - double w = (CTX.viewport[2] - CTX.viewport[0] - 4 * xsep) / 2.; - if(w < 20.) w = 20.; - double h = bar_size; - double x = xc - (i % 2 ? -xsep / 1.5 : w + xsep / 1.5); - double y = CTX.viewport[1] + ysep + - (i / 2) * (bar_size + tic + 2 * gl_height() + ysep); - drawScale(p, x, y, w, h, tic, 1); + double xsep = maxw / 4. + (CTX.viewport[2] - CTX.viewport[0]) / 10.; + double w = (CTX.viewport[2] - CTX.viewport[0] - 4 * xsep) / 2.; + if(w < 20.) w = 20.; + double h = bar_size; + double x = xc - (i % 2 ? -xsep / 1.5 : w + xsep / 1.5); + double y = CTX.viewport[1] + ysep + + (i / 2) * (bar_size + tic + 2 * gl_height() + ysep); + drawScale(p, x, y, w, h, tic, 1); } } else{ double xsep = 20.; double dy = 2. * gl_height(); if(scales.size() == 1){ - double ysep = (CTX.viewport[3] - CTX.viewport[1]) / 6.; - double w = bar_size, h = CTX.viewport[3] - CTX.viewport[1] - 2 * ysep - dy; - double x = CTX.viewport[0] + xsep, y = CTX.viewport[1] + ysep + dy; - drawScale(p, x, y, w, h, tic, 0); + double ysep = (CTX.viewport[3] - CTX.viewport[1]) / 6.; + double w = bar_size, h = CTX.viewport[3] - CTX.viewport[1] - 2 * ysep - dy; + double x = CTX.viewport[0] + xsep, y = CTX.viewport[1] + ysep + dy; + drawScale(p, x, y, w, h, tic, 0); } else{ - double ysep = (CTX.viewport[3] - CTX.viewport[1]) / 15.; - double w = bar_size; - double h = (CTX.viewport[3] - CTX.viewport[1] - 3 * ysep - 2.5 * dy) / 2.; - double x = CTX.viewport[0] + xsep + width_total + (i / 2) * xsep; - double y = CTX.viewport[1] + ysep + dy + (1 - i % 2) * (h + 1.5 * dy + ysep); - drawScale(p, x, y, w, h, tic, 0); + double ysep = (CTX.viewport[3] - CTX.viewport[1]) / 15.; + double w = bar_size; + double h = (CTX.viewport[3] - CTX.viewport[1] - 3 * ysep - 2.5 * dy) / 2.; + double x = CTX.viewport[0] + xsep + width_total + (i / 2) * xsep; + double y = CTX.viewport[1] + ysep + dy + (1 - i % 2) * (h + 1.5 * dy + ysep); + drawScale(p, x, y, w, h, tic, 0); } // compute width width_prev = width; sprintf(label, opt->Format, -M_PI * 1.e-4); width = bar_size + tic + gl_width(label); if(opt->ShowTime){ - char tmp[256]; - sprintf(tmp, opt->Format, data->getTime(opt->TimeStep)); - sprintf(label, "%s (%s)", data->getName().c_str(), tmp); + char tmp[256]; + sprintf(tmp, opt->Format, data->getTime(opt->TimeStep)); + sprintf(label, "%s (%s)", data->getName().c_str(), tmp); } else - sprintf(label, "%s", data->getName().c_str()); + sprintf(label, "%s", data->getName().c_str()); width = std::max(width, gl_width(label)); if(i % 2) width_total += std::max(bar_size + width, bar_size + width_prev); } diff --git a/Graphics/SelectBuffer.cpp b/Graphics/SelectBuffer.cpp index 33861bf5aefbb844d3cbbc6b2d18dbd7ea86bb7f..2bb7a873261309fc389a70f1265a7f380e5f272f 100644 --- a/Graphics/SelectBuffer.cpp +++ b/Graphics/SelectBuffer.cpp @@ -1,4 +1,4 @@ -// $Id: SelectBuffer.cpp,v 1.20 2008-02-22 21:09:00 geuzaine Exp $ +// $Id: SelectBuffer.cpp,v 1.21 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -64,13 +64,13 @@ MElement *getElement(GEntity *e, int va_type, int index) } bool ProcessSelectionBuffer(int entityType, - bool multipleSelection, bool meshSelection, - int x, int y, int w, int h, - std::vector<GVertex*> &vertices, - std::vector<GEdge*> &edges, - std::vector<GFace*> &faces, - std::vector<GRegion*> ®ions, - std::vector<MElement*> &elements) + bool multipleSelection, bool meshSelection, + int x, int y, int w, int h, + std::vector<GVertex*> &vertices, + std::vector<GEdge*> &edges, + std::vector<GFace*> &faces, + std::vector<GRegion*> ®ions, + std::vector<MElement*> &elements) { vertices.clear(); edges.clear(); @@ -83,7 +83,7 @@ bool ProcessSelectionBuffer(int entityType, GModel *m = GModel::current(); int eles = (meshSelection && CTX.pick_elements) ? 4 * m->getNumMeshElements() : 0; int size = 7 * (m->getNumVertices() + m->getNumEdges() + m->getNumFaces() + - m->getNumRegions() + eles) + 1000 ; + m->getNumRegions() + eles) + 1000 ; GLuint *selectionBuffer = new GLuint[size]; glSelectBuffer(size, selectionBuffer); @@ -170,61 +170,61 @@ bool ProcessSelectionBuffer(int entityType, (entityType == ENT_VOLUME && hits[i].type == 3)){ switch (hits[i].type) { case 0: - { - GVertex *v = m->getVertexByTag(hits[i].ient); - if(!v){ - Msg(GERROR, "Problem in point selection processing"); - return false; - } - vertices.push_back(v); - if(!multipleSelection) return true; - } - break; + { + GVertex *v = m->getVertexByTag(hits[i].ient); + if(!v){ + Msg(GERROR, "Problem in point selection processing"); + return false; + } + vertices.push_back(v); + if(!multipleSelection) return true; + } + break; case 1: - { - GEdge *e = m->getEdgeByTag(hits[i].ient); - if(!e){ - Msg(GERROR, "Problem in line selection processing"); - return false; - } - if(hits[i].type2){ - MElement *ele = getElement(e, hits[i].type2, hits[i].ient2); - if(ele) elements.push_back(ele); - } - edges.push_back(e); - if(!multipleSelection) return true; - } - break; + { + GEdge *e = m->getEdgeByTag(hits[i].ient); + if(!e){ + Msg(GERROR, "Problem in line selection processing"); + return false; + } + if(hits[i].type2){ + MElement *ele = getElement(e, hits[i].type2, hits[i].ient2); + if(ele) elements.push_back(ele); + } + edges.push_back(e); + if(!multipleSelection) return true; + } + break; case 2: - { - GFace *f = m->getFaceByTag(hits[i].ient); - if(!f){ - Msg(GERROR, "Problem in surface selection processing"); - return false; - } - if(hits[i].type2){ - MElement *ele = getElement(f, hits[i].type2, hits[i].ient2); - if(ele) elements.push_back(ele); - } - faces.push_back(f); - if(!multipleSelection) return true; - } - break; + { + GFace *f = m->getFaceByTag(hits[i].ient); + if(!f){ + Msg(GERROR, "Problem in surface selection processing"); + return false; + } + if(hits[i].type2){ + MElement *ele = getElement(f, hits[i].type2, hits[i].ient2); + if(ele) elements.push_back(ele); + } + faces.push_back(f); + if(!multipleSelection) return true; + } + break; case 3: - { - GRegion *r = m->getRegionByTag(hits[i].ient); - if(!r){ - Msg(GERROR, "Problem in volume selection processing"); - return false; - } - if(hits[i].type2){ - MElement *ele = getElement(r, hits[i].type2, hits[i].ient2); - if(ele) elements.push_back(ele); - } - regions.push_back(r); - if(!multipleSelection) return true; - } - break; + { + GRegion *r = m->getRegionByTag(hits[i].ient); + if(!r){ + Msg(GERROR, "Problem in volume selection processing"); + return false; + } + if(hits[i].type2){ + MElement *ele = getElement(r, hits[i].type2, hits[i].ient2); + if(ele) elements.push_back(ele); + } + regions.push_back(r); + if(!multipleSelection) return true; + } + break; } } } @@ -311,29 +311,29 @@ void ZeroHighlight() for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++){ for(unsigned int i = 0; i < (*it)->lines.size(); i++) if((*it)->lines[i]->getVisibility() == 2) - (*it)->lines[i]->setVisibility(1); + (*it)->lines[i]->setVisibility(1); } for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++){ for(unsigned int i = 0; i < (*it)->triangles.size(); i++) if((*it)->triangles[i]->getVisibility() == 2) - (*it)->triangles[i]->setVisibility(1); + (*it)->triangles[i]->setVisibility(1); for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) if((*it)->quadrangles[i]->getVisibility() == 2) - (*it)->quadrangles[i]->setVisibility(1); + (*it)->quadrangles[i]->setVisibility(1); } for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){ for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) if((*it)->tetrahedra[i]->getVisibility() == 2) - (*it)->tetrahedra[i]->setVisibility(1); + (*it)->tetrahedra[i]->setVisibility(1); for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) if((*it)->hexahedra[i]->getVisibility() == 2) - (*it)->hexahedra[i]->setVisibility(1); + (*it)->hexahedra[i]->setVisibility(1); for(unsigned int i = 0; i < (*it)->prisms.size(); i++) if((*it)->prisms[i]->getVisibility() == 2) - (*it)->prisms[i]->setVisibility(1); + (*it)->prisms[i]->setVisibility(1); for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) if((*it)->pyramids[i]->getVisibility() == 2) - (*it)->pyramids[i]->setVisibility(1); + (*it)->pyramids[i]->setVisibility(1); } } diff --git a/Graphics/SelectBuffer.h b/Graphics/SelectBuffer.h index 667ab64d9b58b22e0f6339e777e67d190becc979..5f270d75e441a93168da13db04636d691a38b600 100644 --- a/Graphics/SelectBuffer.h +++ b/Graphics/SelectBuffer.h @@ -29,19 +29,19 @@ class MElement; bool ProcessSelectionBuffer(int entityType, - bool multipleSelection, bool meshSelection, - int x, int y, int w, int h, - std::vector<GVertex*> &vertices, - std::vector<GEdge*> &edges, - std::vector<GFace*> &faces, - std::vector<GRegion*> ®ions, - std::vector<MElement*> &elements); + bool multipleSelection, bool meshSelection, + int x, int y, int w, int h, + std::vector<GVertex*> &vertices, + std::vector<GEdge*> &edges, + std::vector<GFace*> &faces, + std::vector<GRegion*> ®ions, + std::vector<MElement*> &elements); char SelectEntity(int entityType, - std::vector<GVertex*> &vertices, - std::vector<GEdge*> &edges, - std::vector<GFace*> &faces, - std::vector<GRegion*> ®ions, - std::vector<MElement*> &elements); + std::vector<GVertex*> &vertices, + std::vector<GEdge*> &edges, + std::vector<GFace*> &faces, + std::vector<GRegion*> ®ions, + std::vector<MElement*> &elements); void HighlightEntity(GEntity *e); void HighlightEntityNum(int v, int c, int s, int r); void ZeroHighlightEntity(GEntity *e); diff --git a/Graphics/gl2gif.h b/Graphics/gl2gif.h index 9849ee83461ec800559108c92b8a0e4dd8ce14a4..20e5b810cfd5692c900bc9d1fa2e5e95f8b353b6 100644 --- a/Graphics/gl2gif.h +++ b/Graphics/gl2gif.h @@ -71,8 +71,8 @@ typedef colorhist_list* colorhash_table; /* Public function */ void create_gif(FILE *outfile, PixelBuffer *buffer, - int dither, int sort, int interlace, - int transparency, int r, int g, int b); + int dither, int sort, int interlace, + int transparency, int r, int g, int b); #endif diff --git a/Graphics/gl2png.cpp b/Graphics/gl2png.cpp index fc2252bedf494fa2ab5fba319b52c19b36c29352..f53ddebe6a96936f681a35bbcc5c0ee87ef19a89 100644 --- a/Graphics/gl2png.cpp +++ b/Graphics/gl2png.cpp @@ -1,4 +1,4 @@ -// $Id: gl2png.cpp,v 1.8 2008-02-17 08:48:00 geuzaine Exp $ +// $Id: gl2png.cpp,v 1.9 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -74,8 +74,8 @@ void create_png(FILE *file, PixelBuffer *buffer, int quality) // Z_DEFAULT_COMPRESSION, Z_BEST_SPEED, Z_BEST_COMPRESSION, Z_NO_COMPRESSION png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION); png_set_IHDR(png_ptr, info_ptr, width, height, 8, - (numcomp == 3) ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGBA, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + (numcomp == 3) ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGBA, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); time_t now; time(&now); png_text text_ptr[10]; diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index a2f6397488e1055fa1f787d40c71838986a2d074..18d3d9b206bf38064a66c151e7ba0bdaf1cf7320 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -1,4 +1,4 @@ -// $Id: BDS.cpp,v 1.103 2008-03-01 01:32:03 geuzaine Exp $ +// $Id: BDS.cpp,v 1.104 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -42,25 +42,25 @@ void outputScalarField(std::list<BDS_Face*> t, const char *iii, int param, GFace (*tit)->getNodes(pts); if(param) fprintf(f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%d,%d,%d};\n", - pts[0]->u, pts[0]->v, 0.0, - pts[1]->u, pts[1]->v, 0.0, - pts[2]->u, pts[2]->v, 0.0, - pts[0]->iD, pts[1]->iD, pts[2]->iD); + pts[0]->u, pts[0]->v, 0.0, + pts[1]->u, pts[1]->v, 0.0, + pts[2]->u, pts[2]->v, 0.0, + pts[0]->iD, pts[1]->iD, pts[2]->iD); else{ if(!gf) - fprintf(f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%d,%d,%d};\n", - pts[0]->X, pts[0]->Y, pts[0]->Z, - pts[1]->X, pts[1]->Y, pts[1]->Z, - pts[2]->X, pts[2]->Y, pts[2]->Z, - pts[0]->iD, pts[1]->iD, pts[2]->iD); + fprintf(f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%d,%d,%d};\n", + pts[0]->X, pts[0]->Y, pts[0]->Z, + pts[1]->X, pts[1]->Y, pts[1]->Z, + pts[2]->X, pts[2]->Y, pts[2]->Z, + pts[0]->iD, pts[1]->iD, pts[2]->iD); else - fprintf(f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n", - pts[0]->X, pts[0]->Y, pts[0]->Z, - pts[1]->X, pts[1]->Y, pts[1]->Z, - pts[2]->X, pts[2]->Y, pts[2]->Z, - gf->curvature(SPoint2(pts[0]->u, pts[0]->v)), - gf->curvature(SPoint2(pts[1]->u, pts[1]->v)), - gf->curvature(SPoint2(pts[2]->u, pts[2]->v))); + fprintf(f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n", + pts[0]->X, pts[0]->Y, pts[0]->Z, + pts[1]->X, pts[1]->Y, pts[1]->Z, + pts[2]->X, pts[2]->Y, pts[2]->Z, + gf->curvature(SPoint2(pts[0]->u, pts[0]->v)), + gf->curvature(SPoint2(pts[1]->u, pts[1]->v)), + gf->curvature(SPoint2(pts[2]->u, pts[2]->v))); } ++tit; } @@ -84,7 +84,7 @@ void vector_triangle(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, } void vector_triangle_parametric(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, - double &c) + double &c) { double a[2] = {p1->u - p2->u, p1->v - p2->v}; double b[2] = {p1->u - p3->u, p1->v - p3->v}; @@ -192,7 +192,7 @@ BDS_Edge *BDS_Mesh::find_edge(int num1, int num2) } int Intersect_Edges_2d(double x1, double y1, double x2, double y2, - double x3, double y3, double x4, double y4) + double x3, double y3, double x4, double y4) { // double p1[2] = {x1,y1}; @@ -229,7 +229,7 @@ int Intersect_Edges_2d(double x1, double y1, double x2, double y2, } BDS_Edge *BDS_Mesh::recover_edge(int num1, int num2, std::set<EdgeToRecover> *e2r, - std::set<EdgeToRecover> *not_recovered) + std::set<EdgeToRecover> *not_recovered) { BDS_Edge *e = find_edge(num1, num2); @@ -250,32 +250,32 @@ BDS_Edge *BDS_Mesh::recover_edge(int num1, int num2, std::set<EdgeToRecover> *e2 while(it != edges.end()){ e = (*it); if(!e->deleted && e->p1 != p1 && e->p1 != p2 && e->p2 != p1 && e->p2 != p2) - if(Intersect_Edges_2d(e->p1->u, e->p1->v, - e->p2->u, e->p2->v, - p1->u, p1->v, - p2->u, p2->v)){ - // intersect - if(e2r && e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, 0)) != e2r->end()){ - std::set<EdgeToRecover>::iterator itr1 = - e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, 0)); - std::set<EdgeToRecover>::iterator itr2 = - e2r->find(EdgeToRecover(num1, num2, 0)); - Msg(DEBUG2, "edge %d %d on model edge %d cannot be recovered because" - " it intersects %d %d on model edge %d", num1, num2, itr2->ge->tag(), - e->p1->iD, e->p2->iD, itr1->ge->tag()); - // now throw a class that contains the diagnostic - not_recovered->insert(EdgeToRecover(num1, num2, itr2->ge)); - not_recovered->insert(EdgeToRecover(e->p1->iD, e->p2->iD, itr1->ge)); - ixMax = -1; - } - intersected.push_back(e); - } + if(Intersect_Edges_2d(e->p1->u, e->p1->v, + e->p2->u, e->p2->v, + p1->u, p1->v, + p2->u, p2->v)){ + // intersect + if(e2r && e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, 0)) != e2r->end()){ + std::set<EdgeToRecover>::iterator itr1 = + e2r->find(EdgeToRecover(e->p1->iD, e->p2->iD, 0)); + std::set<EdgeToRecover>::iterator itr2 = + e2r->find(EdgeToRecover(num1, num2, 0)); + Msg(DEBUG2, "edge %d %d on model edge %d cannot be recovered because" + " it intersects %d %d on model edge %d", num1, num2, itr2->ge->tag(), + e->p1->iD, e->p2->iD, itr1->ge->tag()); + // now throw a class that contains the diagnostic + not_recovered->insert(EdgeToRecover(num1, num2, itr2->ge)); + not_recovered->insert(EdgeToRecover(e->p1->iD, e->p2->iD, itr1->ge)); + ixMax = -1; + } + intersected.push_back(e); + } ++it; } // if(ix > 300){ // Msg(WARNING, "edge %d %d cannot be recovered after %d iterations, trying again", -// num1, num2, ix); +// num1, num2, ix); // ix = 0; // } // printf("%d %d\n",intersected.size(),ix); @@ -283,11 +283,11 @@ BDS_Edge *BDS_Mesh::recover_edge(int num1, int num2, std::set<EdgeToRecover> *e2 if(!intersected.size() || ix > 1000){ BDS_Edge *eee = find_edge(num1, num2); if(!eee){ - outputScalarField(triangles, "debugp.pos", 1); - outputScalarField(triangles, "debugr.pos", 0); - Msg(GERROR, "edge %d %d cannot be recovered at all, look at debugp.pos " - "and debugr.pos", num1, num2); - return 0; + outputScalarField(triangles, "debugp.pos", 1); + outputScalarField(triangles, "debugr.pos", 0); + Msg(GERROR, "edge %d %d cannot be recovered at all, look at debugp.pos " + "and debugr.pos", num1, num2); + return 0; } return eee; } @@ -393,7 +393,7 @@ BDS_Face *BDS_Mesh::add_triangle(BDS_Edge *e1, BDS_Edge *e2, BDS_Edge *e3) } BDS_Face *BDS_Mesh::add_quadrangle(BDS_Edge *e1, BDS_Edge *e2, - BDS_Edge *e3, BDS_Edge *e4) + BDS_Edge *e3, BDS_Edge *e4) { BDS_Face *t = new BDS_Face(e1, e2, e3, e4); triangles.push_back(t); @@ -494,23 +494,23 @@ void BDS_Mesh::cleanup() std::list<BDS_Face*>::iterator it = triangles.begin(); while(it != triangles.end()){ if((*it)->deleted){ - delete *it; - it = triangles.erase(it); + delete *it; + it = triangles.erase(it); } else - it++; + it++; } } { std::list<BDS_Edge*>::iterator it = edges.begin(); while(it != edges.end()){ if((*it)->deleted){ - delete *it; - it = edges.erase(it); - } + delete *it; + it = edges.erase(it); + } else - it++; - } + it++; + } } } @@ -675,7 +675,7 @@ bool BDS_Mesh::split_edge(BDS_Edge *e, BDS_Point *mid) // taken into account before doing the edge swap bool BDS_SwapEdgeTestQuality::operator () (BDS_Point *_p1, BDS_Point *_p2, - BDS_Point *_q1, BDS_Point *_q2) const + BDS_Point *_q1, BDS_Point *_q2) const { if(!testSmallTriangles){ double p1 [2] = {_p1->u,_p1->v}; @@ -701,9 +701,9 @@ bool BDS_SwapEdgeTestQuality::operator () (BDS_Point *_p1, BDS_Point *_p2, } bool BDS_SwapEdgeTestQuality::operator () (BDS_Point *_p1, BDS_Point *_p2, BDS_Point *_p3, - BDS_Point *_q1, BDS_Point *_q2, BDS_Point *_q3, - BDS_Point *_op1, BDS_Point *_op2, BDS_Point *_op3, - BDS_Point *_oq1, BDS_Point *_oq2, BDS_Point *_oq3) const + BDS_Point *_q1, BDS_Point *_q2, BDS_Point *_q3, + BDS_Point *_op1, BDS_Point *_op2, BDS_Point *_op3, + BDS_Point *_oq1, BDS_Point *_oq2, BDS_Point *_oq3) const { if(!testQuality) return true; double n[3], q[3], on[3], oq[3]; @@ -735,10 +735,10 @@ bool BDS_SwapEdgeTestQuality::operator () (BDS_Point *_p1, BDS_Point *_p2, BDS_P } void swap_config(BDS_Edge *e, - BDS_Point **p11, BDS_Point **p12, BDS_Point **p13, - BDS_Point **p21, BDS_Point **p22, BDS_Point **p23, - BDS_Point **p31, BDS_Point **p32, BDS_Point **p33, - BDS_Point **p41, BDS_Point **p42, BDS_Point **p43) + BDS_Point **p11, BDS_Point **p12, BDS_Point **p13, + BDS_Point **p21, BDS_Point **p22, BDS_Point **p23, + BDS_Point **p31, BDS_Point **p32, BDS_Point **p33, + BDS_Point **p41, BDS_Point **p42, BDS_Point **p43) { BDS_Point *op[2]; BDS_Point *p1 = e->p1; @@ -848,16 +848,16 @@ bool BDS_Mesh::swap_edge(BDS_Edge *e, const BDS_SwapEdgeTest &theTest) if(orientation == 1) { if(!theTest(p1, p2, op[0], - p2, p1, op[1], - p1, op[1], op[0], - op[1], p2, op[0])) + p2, p1, op[1], + p1, op[1], op[0], + op[1], p2, op[0])) return false; } else{ if(!theTest(p2, p1, op[0], - p1, p2, op[1], - p1, op[0], op[1], - op[1], op[0], p2)) + p1, p2, op[1], + p1, op[0], op[1], + op[1], op[0], p2)) return false; } @@ -1028,19 +1028,19 @@ bool BDS_Mesh::collapse_edge_parametric(BDS_Edge *e, BDS_Point *p) while(it != ite) { BDS_Face *t = *it; if(t->e1 != e && t->e2 != e && t->e3 != e) { - if(!test_move_point_parametric_triangle(p, o->u, o->v, t)) - return false; + if(!test_move_point_parametric_triangle(p, o->u, o->v, t)) + return false; gs[nt] = t->g; - BDS_Point *pts[4]; - t->getNodes(pts); + BDS_Point *pts[4]; + t->getNodes(pts); pt[0][nt] = (pts[0] == p) ? o : pts[0]; pt[1][nt] = (pts[1] == p) ? o : pts[1]; pt[2][nt] = (pts[2] == p) ? o : pts[2]; -// double qnew = qmTriangle(pt[0][nt], pt[1][nt], pt[2][nt], QMTRI_RHO); -// double qold = qmTriangle(pts[0], pts[1], pts[2], QMTRI_RHO); -// if(qold > 1.e-4 && qnew < 1.e-4) return false; - nt++; +// double qnew = qmTriangle(pt[0][nt], pt[1][nt], pt[2][nt], QMTRI_RHO); +// double qold = qmTriangle(pts[0], pts[1], pts[2], QMTRI_RHO); +// if(qold > 1.e-4 && qnew < 1.e-4) return false; + nt++; // pt[0][nt] = (pts[0] == p) ? o->iD : pts[0]->iD; // pt[1][nt] = (pts[1] == p) ? o->iD : pts[1]->iD; // pt[2][nt++] = (pts[2] == p) ? o->iD : pts[2]->iD; @@ -1138,7 +1138,7 @@ bool test_move_point_parametric_triangle(BDS_Point *p, double u, double v, BDS_F } // d^2_i = (x^2_i - x)^T M (x_i - x) -// = M11 (x_i - x)^2 + 2 M21 (x_i-x)(y_i-y) + M22 (y_i-y)^2 +// = M11 (x_i - x)^2 + 2 M21 (x_i-x)(y_i-y) + M22 (y_i-y)^2 struct smoothVertexData{ BDS_Point *p; @@ -1148,8 +1148,8 @@ struct smoothVertexData{ }; double smoothing_objective_function(double U, double V, BDS_Point *v, - std::list<BDS_Face*> &ts, double su, double sv, - GFace *gf) + std::list<BDS_Face*> &ts, double su, double sv, + GFace *gf) { GPoint gp = gf->point(U * su, V * sv); @@ -1175,19 +1175,19 @@ double smoothing_objective_function(double U, double V, BDS_Point *v, } void deriv_smoothing_objective_function(double U, double V, - double &F, double &dFdU, double &dFdV, - void *data) + double &F, double &dFdU, double &dFdV, + void *data) { smoothVertexData *svd = (smoothVertexData*)data; BDS_Point *v = svd->p; const double LARGE = 1.e5; const double SMALL = 1./LARGE; F = smoothing_objective_function(U, V, v, svd->ts, - svd->scalu, svd->scalv, svd->gf); + svd->scalu, svd->scalv, svd->gf); double F_U = smoothing_objective_function(U + SMALL, V, v, svd->ts, - svd->scalu, svd->scalv, svd->gf); + svd->scalu, svd->scalv, svd->gf); double F_V = smoothing_objective_function(U, V + SMALL, v, svd->ts, - svd->scalu, svd->scalv, svd->gf); + svd->scalu, svd->scalv, svd->gf); dFdU = (F_U - F) * LARGE; dFdV = (F_V - F) * LARGE; } @@ -1196,7 +1196,7 @@ double smooth_obj(double U, double V, void *data) { smoothVertexData *svd = (smoothVertexData*)data; return smoothing_objective_function(U, V, svd->p, svd->ts, - svd->scalu, svd->scalv, svd->gf); + svd->scalu, svd->scalv, svd->gf); } void optimize_vertex_position(GFace *GF, BDS_Point *data, double su, double sv) @@ -1268,8 +1268,8 @@ bool BDS_Mesh::smooth_point_centroid(BDS_Point *p, GFace *gf, bool test_quality) // du[0]/=ldu; // du[1]/=ldu; // double fact = 1./sqrt (metric[0] * du[0] * du[0] + -// 2 * metric[1] * du[0] * du[1] + -// metric[2] * du[1] * du[1]); +// 2 * metric[1] * du[0] * du[1] + +// metric[2] * du[1] * du[1]); double fact = 1.0; sTot += fact; @@ -1438,9 +1438,9 @@ void BDS_Mesh::recombineIntoQuads(const double angle_limit, GFace *gf) for(int i = 0; i < 5; i++){ std::set<recombine_T> pairs; for(std::list<BDS_Edge*>::const_iterator it = edges.begin(); - it != edges.end(); ++it){ + it != edges.end(); ++it){ if(!(*it)->deleted && (*it)->numfaces () == 2) - pairs.insert(recombine_T(*it)); + pairs.insert(recombine_T(*it)); } bool rec = false; @@ -1449,7 +1449,7 @@ void BDS_Mesh::recombineIntoQuads(const double angle_limit, GFace *gf) // recombine if difference between max quad angle and right // angle is smaller than tol if(itp->angle < gf->meshAttributes.recombineAngle) - rec |= recombine_edge((BDS_Edge*)itp->e); + rec |= recombine_edge((BDS_Edge*)itp->e); ++itp; } diff --git a/Mesh/BDS.h b/Mesh/BDS.h index 124d5d872ec5c952be95cf6af9e1af6dd27a9cd3..1622b46c3d9bb0db72e9c380ae6dcf8c1d8753b3 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -50,10 +50,10 @@ double surface_triangle(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3); double surface_triangle_param(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3); void optimize_vertex_position(GFace *GF, BDS_Point *data, double su, double sv); void swap_config(BDS_Edge *e, - BDS_Point **p11, BDS_Point **p12, BDS_Point **p13, - BDS_Point **p21, BDS_Point **p22, BDS_Point **p23, - BDS_Point **p31, BDS_Point **p32, BDS_Point **p33, - BDS_Point **p41, BDS_Point **p42, BDS_Point **p43); + BDS_Point **p11, BDS_Point **p12, BDS_Point **p13, + BDS_Point **p21, BDS_Point **p22, BDS_Point **p23, + BDS_Point **p31, BDS_Point **p32, BDS_Point **p33, + BDS_Point **p41, BDS_Point **p42, BDS_Point **p43); class BDS_GeomEntity @@ -104,8 +104,8 @@ public: inline BDS_Vector operator % (const BDS_Vector &other) const { return BDS_Vector(y * other.z - z * other.y, - z * other.x - x * other.z, - x * other.y - y * other.x); + z * other.x - x * other.z, + x * other.y - y * other.x); } BDS_Vector& operator += (const BDS_Vector &v) { @@ -194,8 +194,8 @@ public: std::list<BDS_Edge*>::iterator ite = edges.end(); while(it != ite){ if(*it == e){ - edges.erase(it); - break; + edges.erase(it); + break; } ++it; } @@ -204,7 +204,7 @@ public: BDS_Point(int id, double x=0, double y=0, double z=0) : _lcBGM(1.e22), _lcPTS(1.e22), X(x), Y(y), Z(z), u(0), v(0), config_modified(true), iD(id), g(0) - { + { } }; @@ -262,8 +262,8 @@ public: inline void del(BDS_Face *t) { _faces.erase(std::remove_if(_faces.begin(),_faces.end(), - std::bind2nd(std::equal_to<BDS_Face*>(), t)), - _faces.end()); + std::bind2nd(std::equal_to<BDS_Face*>(), t)), + _faces.end()); } void oppositeof(BDS_Point * oface[2]) const; @@ -271,13 +271,13 @@ public: void update() { _length = sqrt((p1->X - p2->X) * (p1->X - p2->X) + - (p1->Y - p2->Y) * (p1->Y - p2->Y) + - (p1->Z - p2->Z) * (p1->Z - p2->Z)); + (p1->Y - p2->Y) * (p1->Y - p2->Y) + + (p1->Z - p2->Z) * (p1->Z - p2->Z)); } BDS_Edge(BDS_Point *A, BDS_Point *B) : deleted(false), g(0) - { + { if(*A < *B){ p1 = A; p2 = B; @@ -317,7 +317,7 @@ public: BDS_Face(BDS_Edge *A, BDS_Edge *B, BDS_Edge *C,BDS_Edge *D = 0) : deleted(false), e1(A), e2(B), e3(C), e4(D), g(0) - { + { e1->addface(this); e2->addface(this); e3->addface(this); @@ -371,11 +371,11 @@ class BDS_SwapEdgeTest { public: virtual bool operator() (BDS_Point *p1, BDS_Point *p2, - BDS_Point *q1, BDS_Point *q2) const = 0; + BDS_Point *q1, BDS_Point *q2) const = 0; virtual bool operator() (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, - BDS_Point *q1, BDS_Point *q2, BDS_Point *q3, - BDS_Point *op1, BDS_Point *op2, BDS_Point *op3, - BDS_Point *oq1, BDS_Point *oq2, BDS_Point *oq3) const = 0; + BDS_Point *q1, BDS_Point *q2, BDS_Point *q3, + BDS_Point *op1, BDS_Point *op2, BDS_Point *op3, + BDS_Point *oq1, BDS_Point *oq2, BDS_Point *oq3) const = 0; virtual ~BDS_SwapEdgeTest(){} }; @@ -385,11 +385,11 @@ class BDS_SwapEdgeTestQuality : public BDS_SwapEdgeTest public: BDS_SwapEdgeTestQuality(bool a, bool b=true) : testQuality(a), testSmallTriangles(b) {} virtual bool operator() (BDS_Point *p1, BDS_Point *p2, - BDS_Point *q1, BDS_Point *q2) const ; + BDS_Point *q1, BDS_Point *q2) const ; virtual bool operator() (BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, - BDS_Point *q1, BDS_Point *q2, BDS_Point *q3, - BDS_Point *op1, BDS_Point *op2, BDS_Point *op3, - BDS_Point *oq1, BDS_Point *oq2, BDS_Point *oq3) const ; + BDS_Point *q1, BDS_Point *q2, BDS_Point *q3, + BDS_Point *op1, BDS_Point *op2, BDS_Point *op3, + BDS_Point *oq1, BDS_Point *oq2, BDS_Point *oq3) const ; virtual ~BDS_SwapEdgeTestQuality(){} }; @@ -458,7 +458,7 @@ public: BDS_GeomEntity *get_geom(int p1, int p2); // 2D operators BDS_Edge *recover_edge(int p1, int p2, std::set<EdgeToRecover> *e2r=0, - std::set<EdgeToRecover> *not_recovered=0); + std::set<EdgeToRecover> *not_recovered=0); bool swap_edge(BDS_Edge*, const BDS_SwapEdgeTest &theTest); bool collapse_edge_parametric(BDS_Edge*, BDS_Point*); void snap_point(BDS_Point*, BDS_Mesh *geom = 0); diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp index 5d3f4ff5466e8c7ffd5a8c10478e0c4b146d4234..87a3c0f2a7878d11ff9aece7f031b986005a5228 100644 --- a/Mesh/BackgroundMesh.cpp +++ b/Mesh/BackgroundMesh.cpp @@ -1,4 +1,4 @@ -// $Id: BackgroundMesh.cpp,v 1.44 2008-03-19 20:09:45 geuzaine Exp $ +// $Id: BackgroundMesh.cpp,v 1.45 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -146,7 +146,7 @@ double LC_MVertex_PNTS(GEntity *ge, double U, double V) Range<double> range = ged->parBounds(0); double a = (U - range.low())/(range.high() - range.low()); double lc = (1-a) * v1->prescribedMeshSizeAtVertex() + - (a) * v2->prescribedMeshSizeAtVertex() ; + (a) * v2->prescribedMeshSizeAtVertex() ; if(lc >= MAX_LC) return CTX.lc / 10.; return lc; } @@ -164,11 +164,11 @@ double BGM_MeshSize(GEntity *ge, double U, double V, double X, double Y, double double l4 = MAX_LC; double lc; FieldManager &fields=*GModel::current()->getFields(); - if(fields.background_field>0){ - Field *f=fields.get(fields.background_field); - if(f) l4=(*f)(X,Y,Z); - } - + if(fields.background_field>0){ + Field *f=fields.get(fields.background_field); + if(f) l4=(*f)(X,Y,Z); + } + if(l4 < MAX_LC && !CTX.mesh.constrained_bgmesh){ // use the fields unconstrained by other characteristic lengths lc = l4 * CTX.mesh.lc_factor; diff --git a/Mesh/BoundaryLayer.cpp b/Mesh/BoundaryLayer.cpp index ba9293c2f7e7c11b12f30f47e9eb11864e751891..9b5883415d2c95a2e219ad2a1d27b8324db8c764 100644 --- a/Mesh/BoundaryLayer.cpp +++ b/Mesh/BoundaryLayer.cpp @@ -1,4 +1,4 @@ -// $Id: BoundaryLayer.cpp,v 1.10 2008-02-22 21:09:01 geuzaine Exp $ +// $Id: BoundaryLayer.cpp,v 1.11 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -36,12 +36,12 @@ static void addExtrudeNormals(std::vector<T*> &elements) MFace fac = ele->getFace(j); SVector3 n = fac.normal(); if(n[0] || n[1] || n[2]){ - double nn[3] = {n[0], n[1], n[2]}; - for(int k = 0; k < fac.getNumVertices(); k++){ - MVertex *v = fac.getVertex(k); - SPoint3 p(v->x(), v->y(), v->z()); - ExtrudeParams::normals->add(p[0], p[1], p[2], 3, nn); - } + double nn[3] = {n[0], n[1], n[2]}; + for(int k = 0; k < fac.getNumVertices(); k++){ + MVertex *v = fac.getVertex(k); + SPoint3 p(v->x(), v->y(), v->z()); + ExtrudeParams::normals->add(p[0], p[1], p[2], 3, nn); + } } } } @@ -56,14 +56,14 @@ int Mesh2DWithBoundaryLayers(GModel *m) if(gf->geomType() == GEntity::BoundaryLayerSurface){ ExtrudeParams *ep = gf->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == COPIED_ENTITY){ - GFace *from = m->getFaceByTag(std::abs(ep->geo.Source)); - if(!from){ - Msg(GERROR, "Unknown source face %d for boundary layer", ep->geo.Source); - return 0; - } - sourceFaces.insert(from); - std::list<GEdge*> e = from->edges(); - sourceEdges.insert(e.begin(), e.end()); + GFace *from = m->getFaceByTag(std::abs(ep->geo.Source)); + if(!from){ + Msg(GERROR, "Unknown source face %d for boundary layer", ep->geo.Source); + return 0; + } + sourceFaces.insert(from); + std::list<GEdge*> e = from->edges(); + sourceEdges.insert(e.begin(), e.end()); } } } @@ -102,19 +102,19 @@ int Mesh2DWithBoundaryLayers(GModel *m) if(ge->geomType() == GEntity::BoundaryLayerCurve){ ExtrudeParams *ep = ge->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY){ - GVertex *vsrc, *vdest; - if(ge->getBeginVertex()->geomType() == GEntity::BoundaryLayerPoint){ - vsrc = ge->getEndVertex(); - vdest = ge->getBeginVertex(); - } - else{ - vsrc = ge->getBeginVertex(); - vdest = ge->getEndVertex(); - } - GPoint p = vsrc->point(); - ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], - p.x(), p.y(), p.z()); - vdest->setPosition(p); + GVertex *vsrc, *vdest; + if(ge->getBeginVertex()->geomType() == GEntity::BoundaryLayerPoint){ + vsrc = ge->getEndVertex(); + vdest = ge->getBeginVertex(); + } + else{ + vsrc = ge->getBeginVertex(); + vdest = ge->getEndVertex(); + } + GPoint p = vsrc->point(); + ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], + p.x(), p.y(), p.z()); + vdest->setPosition(p); } } } diff --git a/Mesh/DivideAndConquer.cpp b/Mesh/DivideAndConquer.cpp index 8956f8749d078183f57ef183c4d1e6188102ef70..4fa5da53a4af0c962d7df0aae5537bd39e74956e 100644 --- a/Mesh/DivideAndConquer.cpp +++ b/Mesh/DivideAndConquer.cpp @@ -1,4 +1,4 @@ -// $Id: DivideAndConquer.cpp,v 1.16 2008-03-01 01:32:03 geuzaine Exp $ +// $Id: DivideAndConquer.cpp,v 1.17 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -529,7 +529,7 @@ int ConvertDListToTriangles(DocRecord *doc) // on cree une liste de points connectes au point i (t) + nombre // de points (t_length) striangle[i].t = ConvertDlistToArray(&gPointArray[i].adjacent, - &striangle[i].t_length); + &striangle[i].t_length); striangle[i].info = NULL; striangle[i].info_length = 0; } @@ -544,8 +544,8 @@ int ConvertDListToTriangles(DocRecord *doc) bb = striangle[i].t[j]; cc = striangle[i].t[j + 1]; doc->triangles[count].a = aa; - doc->triangles[count].b = bb; - doc->triangles[count].c = cc; + doc->triangles[count].b = bb; + doc->triangles[count].c = cc; count++; } } diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index 97566e929c2992d01623c47773da7c60e648b68a..bf1217ef465d89ff9e5dd91a4b18b7b9a65c3574 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -1,4 +1,4 @@ -// $Id: Generator.cpp,v 1.138 2008-03-11 20:03:10 geuzaine Exp $ +// $Id: Generator.cpp,v 1.139 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -38,10 +38,10 @@ extern Context_T CTX; template<class T> static void GetQualityMeasure(std::vector<T*> &ele, - double &gamma, double &gammaMin, double &gammaMax, - double &eta, double &etaMin, double &etaMax, - double &rho, double &rhoMin, double &rhoMax, - double quality[3][100]) + double &gamma, double &gammaMin, double &gammaMax, + double &eta, double &etaMin, double &etaMax, + double &rho, double &rhoMin, double &rhoMax, + double quality[3][100]) { for(unsigned int i = 0; i < ele.size(); i++){ double g = ele[i]->gammaShapeMeasure(); @@ -106,19 +106,19 @@ void GetStatistics(double stat[50], double quality[3][100]) if(quality){ for(int i = 0; i < 3; i++) for(int j = 0; j < 100; j++) - quality[i][j] = 0.; + quality[i][j] = 0.; double gamma=0., gammaMin=1., gammaMax=0.; double eta=0., etaMin=1., etaMax=0.; double rho=0., rhoMin=1., rhoMax=0.; for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it){ GetQualityMeasure((*it)->tetrahedra, gamma, gammaMin, gammaMax, - eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); + eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); GetQualityMeasure((*it)->hexahedra, gamma, gammaMin, gammaMax, - eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); + eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); GetQualityMeasure((*it)->prisms, gamma, gammaMin, gammaMax, - eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); + eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); GetQualityMeasure((*it)->pyramids, gamma, gammaMin, gammaMax, - eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); + eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality); } double N = stat[9] + stat[10] + stat[11] + stat[12]; stat[17] = N ? gamma / N : 0.; @@ -160,10 +160,10 @@ static bool TooManyElements(GModel *m, int dim) sumAllLc /= (double)m->getNumVertices(); if(!sumAllLc || pow(CTX.lc / sumAllLc, dim) > 1.e10) return !GetBinaryAnswer("Your choice of characteristic lengths will likely produce\n" - "a very large mesh. Do you really want to continue?\n\n" - "(To disable this warning in the future, select `Enable\n" - "expert mode' in the option dialog.)", - "Continue", "Cancel"); + "a very large mesh. Do you really want to continue?\n\n" + "(To disable this warning in the future, select `Enable\n" + "expert mode' in the option dialog.)", + "Continue", "Cancel"); return false; } @@ -204,7 +204,7 @@ static void PrintMesh2dStatistics(GModel *m) e_long = std::max((*it)->meshStatistics.longest_edge_length, e_long); e_short = std::min((*it)->meshStatistics.smallest_edge_length, e_short); if ((*it)->meshStatistics.status == GFace::FAILED || - (*it)->meshStatistics.status == GFace::PENDING) nUnmeshed++; + (*it)->meshStatistics.status == GFace::PENDING) nUnmeshed++; nTotT += (*it)->meshStatistics.nbTriangle; nTotE += (*it)->meshStatistics.nbEdge; nTotGoodLength += (*it)->meshStatistics.nbGoodLength; @@ -214,17 +214,17 @@ static void PrintMesh2dStatistics(GModel *m) if(CTX.create_append_statreport == 1){ fprintf(statreport, "2D stats\tname\t\t#faces\t\t#fail\t\t" - "#t\t\tQavg\t\tQbest\t\tQworst\t\t#Q>90\t\t#Q>90/#t\t" - "#e\t\ttau\t\t#Egood\t\t#Egood/#e\tCPU\n"); + "#t\t\tQavg\t\tQbest\t\tQworst\t\t#Q>90\t\t#Q>90/#t\t" + "#e\t\ttau\t\t#Egood\t\t#Egood/#e\tCPU\n"); } fprintf(statreport,"\t%16s\t%d\t\t%d\t\t", CTX.base_filename, numFaces, nUnmeshed); fprintf(statreport,"%d\t\t%8.7f\t%8.7f\t%8.7f\t%d\t\t%8.7f\t", - nTotT, avg / (double)nTotT, best, worst, nTotGoodQuality, - (double)nTotGoodQuality / nTotT); + nTotT, avg / (double)nTotT, best, worst, nTotGoodQuality, + (double)nTotGoodQuality / nTotT); fprintf(statreport,"%d\t\t%8.7f\t%d\t\t%8.7f\t%8.1f\n", - nTotE, exp(e_avg / (double)nTotE), nTotGoodLength, - (double)nTotGoodLength / nTotE, CTX.mesh_timer[1]); + nTotE, exp(e_avg / (double)nTotE), nTotGoodLength, + (double)nTotGoodLength / nTotE, CTX.mesh_timer[1]); fclose(statreport); } @@ -234,11 +234,11 @@ static void Mesh2D(GModel *m) if(CTX.mesh.algo2d == ALGO_2D_DELAUNAY && !CTX.expert_mode){ if(!GetBinaryAnswer("The 2D Delaunay algorithm is still highly experimental\n" - "and produces triangles with random orientations. Do you\n" - "really want to continue?\n\n" - "(To disable this warning in the future, select `Enable\n" - "expert mode' in the option dialog.)", - "Continue", "Cancel")) return; + "and produces triangles with random orientations. Do you\n" + "really want to continue?\n\n" + "(To disable this warning in the future, select `Enable\n" + "expert mode' in the option dialog.)", + "Continue", "Cancel")) return; } Msg(STATUS1, "Meshing 2D..."); @@ -254,10 +254,10 @@ static void Mesh2D(GModel *m) meshGFace mesher; int nbPending = 0; for(GModel::fiter it = m->firstFace() ; it!=m->lastFace(); ++it){ - if ((*it)->meshStatistics.status == GFace::PENDING){ - mesher(*it); - nbPending++; - } + if ((*it)->meshStatistics.status == GFace::PENDING){ + mesher(*it); + nbPending++; + } } if(!nbPending) break; if(nIter++ > 10) break; @@ -275,7 +275,7 @@ static void Mesh2D(GModel *m) } static void FindConnectedRegions(std::vector<GRegion*> &delaunay, - std::vector<std::vector<GRegion*> > &connected) + std::vector<std::vector<GRegion*> > &connected) { // FIXME: need to split region vector into connected components here! connected.push_back(delaunay); @@ -413,7 +413,7 @@ void GenerateMesh(GModel *m, int ask) // Create high order elements if(m->getMeshStatus() && CTX.mesh.order > 1) SetOrderN(m, CTX.mesh.order, CTX.mesh.second_order_linear, - CTX.mesh.second_order_incomplete); + CTX.mesh.second_order_incomplete); Msg(INFO, "%d vertices %d elements", m->getNumMeshVertices(), m->getNumMeshElements()); diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp index 2a1af1ac7e7ed035e5af1632d59f15ceeb276119..52e7c03a3bd67441539244e0e2f6611a1b78013a 100644 --- a/Mesh/HighOrder.cpp +++ b/Mesh/HighOrder.cpp @@ -1,4 +1,4 @@ -// $Id: HighOrder.cpp,v 1.26 2008-03-12 14:52:58 geuzaine Exp $ +// $Id: HighOrder.cpp,v 1.27 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -122,7 +122,7 @@ bool computeEquidistantParameters(GEdge *ge, double u0, double uN, int N, double u[i + 1] += eps; myresid(N, ge, u, Rp); for (int j = 0; j < M; j++){ - J(i, j) = (Rp(j) - R(j)) / eps; + J(i, j) = (Rp(j) - R(j)) / eps; } u[i+1] -= eps; } @@ -166,7 +166,7 @@ static void myresid(int N, GFace *gf, double *u, double *v, Double_Vector &r) } bool computeEquidistantParameters(GFace *gf, double u0, double uN, double v0, double vN, - int N, double *u, double *v) + int N, double *u, double *v) { const double PRECISION = 1.e-6; const int MAX_ITER = 50; @@ -210,7 +210,7 @@ bool computeEquidistantParameters(GFace *gf, double u0, double uN, double v0, do v[i + 1] = p.y(); myresid(N, gf, u, v, Rp); for (int j = 0; j < M; j++){ - J(i, j) = (Rp(j) - R(j)) / eps; + J(i, j) = (Rp(j) - R(j)) / eps; } t[i + 1] -= eps; u[i + 1] = tempu; @@ -257,16 +257,16 @@ bool reparamOnEdge(MVertex *v, GEdge *ge, double ¶m) } void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve, - edgeContainer &edgeVertices, bool linear, int nPts = 1) + edgeContainer &edgeVertices, bool linear, int nPts = 1) { for(int i = 0; i < ele->getNumEdges(); i++){ MEdge edge = ele->getEdge(i); std::pair<MVertex*, MVertex*> p(edge.getMinVertex(), edge.getMaxVertex()); if(edgeVertices.count(p)){ if(edge.getVertex(0) == edge.getMinVertex()) - ve.insert(ve.end(), edgeVertices[p].begin(), edgeVertices[p].end()); + ve.insert(ve.end(), edgeVertices[p].begin(), edgeVertices[p].end()); else - ve.insert(ve.end(), edgeVertices[p].rbegin(), edgeVertices[p].rend()); + ve.insert(ve.end(), edgeVertices[p].rbegin(), edgeVertices[p].rend()); } else{ MVertex *v0 = edge.getVertex(0), *v1 = edge.getVertex(1); @@ -274,135 +274,135 @@ void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve, double u0 = 0., u1 = 0.; bool reparamOK = true; if(!linear && ge->geomType() != GEntity::DiscreteCurve && - ge->geomType() != GEntity::BoundaryLayerCurve){ - reparamOK &= reparamOnEdge(v0, ge, u0); - - if (ge->periodic(0) && v1 == ge->getEndVertex()->mesh_vertices[0]){ - Range<double> par = ge->parBounds(0); - u1 = par.high(); - } - else - reparamOK &= reparamOnEdge(v1, ge, u1); + ge->geomType() != GEntity::BoundaryLayerCurve){ + reparamOK &= reparamOnEdge(v0, ge, u0); + + if (ge->periodic(0) && v1 == ge->getEndVertex()->mesh_vertices[0]){ + Range<double> par = ge->parBounds(0); + u1 = par.high(); + } + else + reparamOK &= reparamOnEdge(v1, ge, u1); } double US[100]; if(reparamOK && !linear && ge->geomType() != GEntity::DiscreteCurve){ - double relax = 1.; - while (1){ - if (computeEquidistantParameters(ge, u0, u1, nPts + 2, US,relax))break; - relax /= 2.0; - if (relax < 1.e-2)break; - } - if (relax < 1.e-2)printf("failure in computing equidistant parameters %g\n",relax); + double relax = 1.; + while (1){ + if (computeEquidistantParameters(ge, u0, u1, nPts + 2, US,relax))break; + relax /= 2.0; + if (relax < 1.e-2)break; + } + if (relax < 1.e-2)printf("failure in computing equidistant parameters %g\n",relax); } std::vector<MVertex*> temp; for(int j = 0; j < nPts; j++){ - const double t = (double)(j + 1)/(nPts + 1); - double uc = (1. - t) * u0 + t * u1; - MVertex *v; - if(!reparamOK || linear || ge->geomType() == GEntity::DiscreteCurve || - uc < u0 || uc > u1){ // need to treat periodic curves properly! - SPoint3 pc = edge.interpolate(t); - v = new MVertex(pc.x(), pc.y(), pc.z(), ge); - v->setParameter (0,t); - } - else { - GPoint pc = ge->point(US[j+1]); - v = new MEdgeVertex(pc.x(), pc.y(), pc.z(), ge, US[j+1]); - } - temp.push_back(v); - ge->mesh_vertices.push_back(v); - ve.push_back(v); + const double t = (double)(j + 1)/(nPts + 1); + double uc = (1. - t) * u0 + t * u1; + MVertex *v; + if(!reparamOK || linear || ge->geomType() == GEntity::DiscreteCurve || + uc < u0 || uc > u1){ // need to treat periodic curves properly! + SPoint3 pc = edge.interpolate(t); + v = new MVertex(pc.x(), pc.y(), pc.z(), ge); + v->setParameter (0,t); + } + else { + GPoint pc = ge->point(US[j+1]); + v = new MEdgeVertex(pc.x(), pc.y(), pc.z(), ge, US[j+1]); + } + temp.push_back(v); + ge->mesh_vertices.push_back(v); + ve.push_back(v); } if(edge.getVertex(0) == edge.getMinVertex()) - edgeVertices[p].insert(edgeVertices[p].end(), temp.begin(), temp.end()); + edgeVertices[p].insert(edgeVertices[p].end(), temp.begin(), temp.end()); else - edgeVertices[p].insert(edgeVertices[p].end(), temp.rbegin(), temp.rend()); + edgeVertices[p].insert(edgeVertices[p].end(), temp.rbegin(), temp.rend()); } } } void getEdgeVertices(GFace *gf, MElement *ele, std::vector<MVertex*> &ve, - edgeContainer &edgeVertices, bool linear, int nPts = 1) + edgeContainer &edgeVertices, bool linear, int nPts = 1) { for(int i = 0; i < ele->getNumEdges(); i++){ MEdge edge = ele->getEdge(i); std::pair<MVertex*, MVertex*> p(edge.getMinVertex(), edge.getMaxVertex()); if(edgeVertices.count(p)){ if(edge.getVertex(0) == edge.getMinVertex()) - ve.insert(ve.end(), edgeVertices[p].begin(), edgeVertices[p].end()); + ve.insert(ve.end(), edgeVertices[p].begin(), edgeVertices[p].end()); else - ve.insert(ve.end(), edgeVertices[p].rbegin(), edgeVertices[p].rend()); + ve.insert(ve.end(), edgeVertices[p].rbegin(), edgeVertices[p].rend()); } else{ MVertex *v0 = edge.getVertex(0), *v1 = edge.getVertex(1); SPoint2 p0, p1; bool reparamOK = true; if(!linear && - gf->geomType() != GEntity::DiscreteSurface && - gf->geomType() != GEntity::BoundaryLayerSurface){ - reparamOK &= reparamOnFace(v0, gf, p0); - reparamOK &= reparamOnFace(v1, gf, p1); + gf->geomType() != GEntity::DiscreteSurface && + gf->geomType() != GEntity::BoundaryLayerSurface){ + reparamOK &= reparamOnFace(v0, gf, p0); + reparamOK &= reparamOnFace(v1, gf, p1); } double US[100], VS[100]; if(reparamOK && !linear && gf->geomType() != GEntity::DiscreteCurve){ - computeEquidistantParameters(gf, p0[0], p1[0], p0[1], p1[1], nPts + 2, US, VS); + computeEquidistantParameters(gf, p0[0], p1[0], p0[1], p1[1], nPts + 2, US, VS); } std::vector<MVertex*> temp; for(int j = 0; j < nPts; j++){ - const double t = (double)(j + 1) / (nPts + 1); - MVertex *v; - if(!reparamOK || linear || gf->geomType() == GEntity::DiscreteSurface){ - SPoint3 pc = edge.interpolate(t); - v = new MVertex(pc.x(), pc.y(), pc.z(), gf); - } - else{ - GPoint pc = gf->point(US[j+1], VS[j+1]); - v = new MFaceVertex(pc.x(), pc.y(), pc.z(), gf, US[j+1], VS[j+1]); - } - temp.push_back(v); - gf->mesh_vertices.push_back(v); - ve.push_back(v); + const double t = (double)(j + 1) / (nPts + 1); + MVertex *v; + if(!reparamOK || linear || gf->geomType() == GEntity::DiscreteSurface){ + SPoint3 pc = edge.interpolate(t); + v = new MVertex(pc.x(), pc.y(), pc.z(), gf); + } + else{ + GPoint pc = gf->point(US[j+1], VS[j+1]); + v = new MFaceVertex(pc.x(), pc.y(), pc.z(), gf, US[j+1], VS[j+1]); + } + temp.push_back(v); + gf->mesh_vertices.push_back(v); + ve.push_back(v); } if(edge.getVertex(0) == edge.getMinVertex()) - edgeVertices[p].insert(edgeVertices[p].end(), temp.begin(), temp.end()); + edgeVertices[p].insert(edgeVertices[p].end(), temp.begin(), temp.end()); else - edgeVertices[p].insert(edgeVertices[p].end(), temp.rbegin(), temp.rend()); + edgeVertices[p].insert(edgeVertices[p].end(), temp.rbegin(), temp.rend()); } } } void getEdgeVertices(GRegion *gr, MElement *ele, std::vector<MVertex*> &ve, - edgeContainer &edgeVertices, bool linear, int nPts = 1) + edgeContainer &edgeVertices, bool linear, int nPts = 1) { for(int i = 0; i < ele->getNumEdges(); i++){ MEdge edge = ele->getEdge(i); std::pair<MVertex*, MVertex*> p(edge.getMinVertex(), edge.getMaxVertex()); if(edgeVertices.count(p)){ if(edge.getVertex(0) == edge.getMinVertex()) - ve.insert(ve.end(), edgeVertices[p].begin(), edgeVertices[p].end()); + ve.insert(ve.end(), edgeVertices[p].begin(), edgeVertices[p].end()); else - ve.insert(ve.end(), edgeVertices[p].rbegin(), edgeVertices[p].rend()); + ve.insert(ve.end(), edgeVertices[p].rbegin(), edgeVertices[p].rend()); } else{ std::vector<MVertex*> temp; for(int j = 0; j < nPts; j++){ - double t = (double)(j + 1) / (nPts + 1); - SPoint3 pc = edge.interpolate(t); - MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); - temp.push_back(v); - gr->mesh_vertices.push_back(v); - ve.push_back(v); + double t = (double)(j + 1) / (nPts + 1); + SPoint3 pc = edge.interpolate(t); + MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); + temp.push_back(v); + gr->mesh_vertices.push_back(v); + ve.push_back(v); } if(edge.getVertex(0) == edge.getMinVertex()) - edgeVertices[p].insert(edgeVertices[p].end(), temp.begin(), temp.end()); + edgeVertices[p].insert(edgeVertices[p].end(), temp.begin(), temp.end()); else - edgeVertices[p].insert(edgeVertices[p].end(), temp.rbegin(), temp.rend()); + edgeVertices[p].insert(edgeVertices[p].end(), temp.rbegin(), temp.rend()); } } } void getFaceVertices(GFace *gf, MElement *ele, std::vector<MVertex*> &vf, - faceContainer &faceVertices, bool linear, int nPts = 1) + faceContainer &faceVertices, bool linear, int nPts = 1) { Double_Matrix points; int start = 0; @@ -436,64 +436,64 @@ void getFaceVertices(GFace *gf, MElement *ele, std::vector<MVertex*> &vf, SPoint2 p0, p1, p2, p3; bool reparamOK = true; if(!linear && - gf->geomType() != GEntity::DiscreteSurface && - gf->geomType() != GEntity::BoundaryLayerSurface){ - reparamOK &= reparamOnFace(ele->getVertex(0), gf, p0); - reparamOK &= reparamOnFace(ele->getVertex(1), gf, p1); - reparamOK &= reparamOnFace(ele->getVertex(2), gf, p2); - if(face.getNumVertices() == 4) - reparamOK &= reparamOnFace(ele->getVertex(3), gf, p3); + gf->geomType() != GEntity::DiscreteSurface && + gf->geomType() != GEntity::BoundaryLayerSurface){ + reparamOK &= reparamOnFace(ele->getVertex(0), gf, p0); + reparamOK &= reparamOnFace(ele->getVertex(1), gf, p1); + reparamOK &= reparamOnFace(ele->getVertex(2), gf, p2); + if(face.getNumVertices() == 4) + reparamOK &= reparamOnFace(ele->getVertex(3), gf, p3); } if(face.getNumVertices() == 3){ // triangles - for(int k = start ; k < points.size1() ; k++){ - MVertex *v; - const double t1 = points(k, 0); - const double t2 = points(k, 1); - if(!reparamOK || linear || gf->geomType() == GEntity::DiscreteSurface){ - SPoint3 pc = face.interpolate(t1, t2); - v = new MVertex(pc.x(), pc.y(), pc.z(), gf); - } - else{ - double uc = (1. - t1 - t2) * p0[0] + t1 * p1[0] + t2 * p2[0]; - double vc = (1. - t1 - t2) * p0[1] + t1 * p1[1] + t2 * p2[1]; - GPoint pc = gf->point(uc, vc); - v = new MFaceVertex(pc.x(), pc.y(), pc.z(), gf, uc, vc); - v->setParameter (0,uc); - v->setParameter (1,vc); - } - faceVertices[p].push_back(v); - gf->mesh_vertices.push_back(v); - vf.push_back(v); - } + for(int k = start ; k < points.size1() ; k++){ + MVertex *v; + const double t1 = points(k, 0); + const double t2 = points(k, 1); + if(!reparamOK || linear || gf->geomType() == GEntity::DiscreteSurface){ + SPoint3 pc = face.interpolate(t1, t2); + v = new MVertex(pc.x(), pc.y(), pc.z(), gf); + } + else{ + double uc = (1. - t1 - t2) * p0[0] + t1 * p1[0] + t2 * p2[0]; + double vc = (1. - t1 - t2) * p0[1] + t1 * p1[1] + t2 * p2[1]; + GPoint pc = gf->point(uc, vc); + v = new MFaceVertex(pc.x(), pc.y(), pc.z(), gf, uc, vc); + v->setParameter (0,uc); + v->setParameter (1,vc); + } + faceVertices[p].push_back(v); + gf->mesh_vertices.push_back(v); + vf.push_back(v); + } } else if(face.getNumVertices() == 4){ // quadrangles - for(int j = 0; j < nPts; j++){ - for(int k = 0; k < nPts; k++){ - MVertex *v; - // parameters are between -1 and 1 - double t1 = 2. * (double)(j + 1) / (nPts + 1) - 1.; - double t2 = 2. * (double)(k + 1) / (nPts + 1) - 1.; - if(!reparamOK || linear || gf->geomType() == GEntity::DiscreteSurface){ - SPoint3 pc = face.interpolate(t1, t2); - v = new MVertex(pc.x(), pc.y(), pc.z(), gf); - } - else{ - double uc = 0.25 * ((1 - t1) * (1 - t2) * p0[0] + - (1 + t1) * (1 - t2) * p1[0] + - (1 + t1) * (1 + t2) * p2[0] + - (1 - t1) * (1 + t2) * p3[0]); - double vc = 0.25 * ((1 - t1) * (1 - t2) * p0[1] + - (1 + t1) * (1 - t2) * p1[1] + - (1 + t1) * (1 + t2) * p2[1] + - (1 - t1) * (1 + t2) * p3[1]); - GPoint pc = gf->point(uc, vc); - v = new MFaceVertex(pc.x(), pc.y(), pc.z(), gf, uc, vc); - } - faceVertices[p].push_back(v); - gf->mesh_vertices.push_back(v); - vf.push_back(v); - } - } + for(int j = 0; j < nPts; j++){ + for(int k = 0; k < nPts; k++){ + MVertex *v; + // parameters are between -1 and 1 + double t1 = 2. * (double)(j + 1) / (nPts + 1) - 1.; + double t2 = 2. * (double)(k + 1) / (nPts + 1) - 1.; + if(!reparamOK || linear || gf->geomType() == GEntity::DiscreteSurface){ + SPoint3 pc = face.interpolate(t1, t2); + v = new MVertex(pc.x(), pc.y(), pc.z(), gf); + } + else{ + double uc = 0.25 * ((1 - t1) * (1 - t2) * p0[0] + + (1 + t1) * (1 - t2) * p1[0] + + (1 + t1) * (1 + t2) * p2[0] + + (1 - t1) * (1 + t2) * p3[0]); + double vc = 0.25 * ((1 - t1) * (1 - t2) * p0[1] + + (1 + t1) * (1 - t2) * p1[1] + + (1 + t1) * (1 + t2) * p2[1] + + (1 - t1) * (1 + t2) * p3[1]); + GPoint pc = gf->point(uc, vc); + v = new MFaceVertex(pc.x(), pc.y(), pc.z(), gf, uc, vc); + } + faceVertices[p].push_back(v); + gf->mesh_vertices.push_back(v); + vf.push_back(v); + } + } } else throw; // not tri or quad } @@ -501,7 +501,7 @@ void getFaceVertices(GFace *gf, MElement *ele, std::vector<MVertex*> &vf, } void getFaceVertices(GRegion *gr, MElement *ele, std::vector<MVertex*> &vf, - faceContainer &faceVertices, bool linear, int nPts = 1) + faceContainer &faceVertices, bool linear, int nPts = 1) { for(int i = 0; i < ele->getNumFaces(); i++){ MFace face = ele->getFace(i); @@ -512,31 +512,31 @@ void getFaceVertices(GRegion *gr, MElement *ele, std::vector<MVertex*> &vf, } else{ if(face.getNumVertices() == 3){ // triangles - for(int j = 0; j < nPts; j++){ - for(int k = 0 ; k < nPts - j - 1; k++){ - double t1 = (double)(j + 1) / (nPts + 1); - double t2 = (double)(k + 1) / (nPts + 1); - SPoint3 pc = face.interpolate(t1, t2); - MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); - faceVertices[p].push_back(v); - gr->mesh_vertices.push_back(v); - vf.push_back(v); - } - } + for(int j = 0; j < nPts; j++){ + for(int k = 0 ; k < nPts - j - 1; k++){ + double t1 = (double)(j + 1) / (nPts + 1); + double t2 = (double)(k + 1) / (nPts + 1); + SPoint3 pc = face.interpolate(t1, t2); + MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); + faceVertices[p].push_back(v); + gr->mesh_vertices.push_back(v); + vf.push_back(v); + } + } } else if(face.getNumVertices() == 4){ // quadrangles - for(int j = 0; j < nPts; j++){ - for(int k = 0; k < nPts; k++){ - // parameters are between -1 and 1 - double t1 = 2. * (double)(j + 1) / (nPts + 1) - 1.; - double t2 = 2. * (double)(k + 1) / (nPts + 1) - 1.; - SPoint3 pc = face.interpolate(t1, t2); - MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); - faceVertices[p].push_back(v); - gr->mesh_vertices.push_back(v); - vf.push_back(v); - } - } + for(int j = 0; j < nPts; j++){ + for(int k = 0; k < nPts; k++){ + // parameters are between -1 and 1 + double t1 = 2. * (double)(j + 1) / (nPts + 1) - 1.; + double t2 = 2. * (double)(k + 1) / (nPts + 1) - 1.; + SPoint3 pc = face.interpolate(t1, t2); + MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); + faceVertices[p].push_back(v); + gr->mesh_vertices.push_back(v); + vf.push_back(v); + } + } } else throw; // not tri or quad } @@ -544,7 +544,7 @@ void getFaceVertices(GRegion *gr, MElement *ele, std::vector<MVertex*> &vf, } void setHighOrder(GEdge *ge, edgeContainer &edgeVertices, bool linear, - int nbPts = 1) + int nbPts = 1) { std::vector<MLine*> lines2; for(unsigned int i = 0; i < ge->lines.size(); i++){ @@ -562,8 +562,8 @@ void setHighOrder(GEdge *ge, edgeContainer &edgeVertices, bool linear, } void setHighOrder(GFace *gf, edgeContainer &edgeVertices, - faceContainer &faceVertices, bool linear, bool incomplete, - int nPts = 1) + faceContainer &faceVertices, bool linear, bool incomplete, + int nPts = 1) { std::vector<MTriangle*> triangles2; for(unsigned int i = 0; i < gf->triangles.size(); i++){ @@ -572,21 +572,21 @@ void setHighOrder(GFace *gf, edgeContainer &edgeVertices, getEdgeVertices(gf, t, ve, edgeVertices, linear, nPts); if(nPts == 1){ triangles2.push_back - (new MTriangle6(t->getVertex(0), t->getVertex(1), t->getVertex(2), - ve[0], ve[1], ve[2])); + (new MTriangle6(t->getVertex(0), t->getVertex(1), t->getVertex(2), + ve[0], ve[1], ve[2])); } else{ if(incomplete){ - triangles2.push_back - (new MTriangleN(t->getVertex(0), t->getVertex(1), t->getVertex(2), - ve, nPts + 1)); + triangles2.push_back + (new MTriangleN(t->getVertex(0), t->getVertex(1), t->getVertex(2), + ve, nPts + 1)); } else{ - getFaceVertices(gf, t, vf, faceVertices, linear, nPts); - ve.insert(ve.end(), vf.begin(), vf.end()); - triangles2.push_back - (new MTriangleN(t->getVertex(0), t->getVertex(1), t->getVertex(2), - ve, nPts + 1)); + getFaceVertices(gf, t, vf, faceVertices, linear, nPts); + ve.insert(ve.end(), vf.begin(), vf.end()); + triangles2.push_back + (new MTriangleN(t->getVertex(0), t->getVertex(1), t->getVertex(2), + ve, nPts + 1)); } } delete t; @@ -600,14 +600,14 @@ void setHighOrder(GFace *gf, edgeContainer &edgeVertices, getEdgeVertices(gf, q, ve, edgeVertices, linear, nPts); if(incomplete){ quadrangles2.push_back - (new MQuadrangle8(q->getVertex(0), q->getVertex(1), q->getVertex(2), - q->getVertex(3), ve[0], ve[1], ve[2], ve[3])); + (new MQuadrangle8(q->getVertex(0), q->getVertex(1), q->getVertex(2), + q->getVertex(3), ve[0], ve[1], ve[2], ve[3])); } else{ getFaceVertices(gf, q, vf, faceVertices, linear, nPts); quadrangles2.push_back - (new MQuadrangle9(q->getVertex(0), q->getVertex(1), q->getVertex(2), - q->getVertex(3), ve[0], ve[1], ve[2], ve[3], vf[0])); + (new MQuadrangle9(q->getVertex(0), q->getVertex(1), q->getVertex(2), + q->getVertex(3), ve[0], ve[1], ve[2], ve[3], vf[0])); } delete q; } @@ -616,8 +616,8 @@ void setHighOrder(GFace *gf, edgeContainer &edgeVertices, } void setHighOrder(GRegion *gr, edgeContainer &edgeVertices, - faceContainer &faceVertices, bool linear, bool incomplete, - int nPts = 1) + faceContainer &faceVertices, bool linear, bool incomplete, + int nPts = 1) { std::vector<MTetrahedron*> tetrahedra2; for(unsigned int i = 0; i < gr->tetrahedra.size(); i++){ @@ -626,7 +626,7 @@ void setHighOrder(GRegion *gr, edgeContainer &edgeVertices, getEdgeVertices(gr, t, ve, edgeVertices, linear, nPts); tetrahedra2.push_back (new MTetrahedron10(t->getVertex(0), t->getVertex(1), t->getVertex(2), - t->getVertex(3), ve[0], ve[1], ve[2], ve[3], ve[4], ve[5])); + t->getVertex(3), ve[0], ve[1], ve[2], ve[3], ve[4], ve[5])); delete t; } gr->tetrahedra = tetrahedra2; @@ -638,11 +638,11 @@ void setHighOrder(GRegion *gr, edgeContainer &edgeVertices, getEdgeVertices(gr, h, ve, edgeVertices, linear, nPts); if(incomplete){ hexahedra2.push_back - (new MHexahedron20(h->getVertex(0), h->getVertex(1), h->getVertex(2), - h->getVertex(3), h->getVertex(4), h->getVertex(5), - h->getVertex(6), h->getVertex(7), ve[0], ve[1], ve[2], - ve[3], ve[4], ve[5], ve[6], ve[7], ve[8], ve[9], ve[10], - ve[11])); + (new MHexahedron20(h->getVertex(0), h->getVertex(1), h->getVertex(2), + h->getVertex(3), h->getVertex(4), h->getVertex(5), + h->getVertex(6), h->getVertex(7), ve[0], ve[1], ve[2], + ve[3], ve[4], ve[5], ve[6], ve[7], ve[8], ve[9], ve[10], + ve[11])); } else{ getFaceVertices(gr, h, vf, faceVertices, linear, nPts); @@ -650,11 +650,11 @@ void setHighOrder(GRegion *gr, edgeContainer &edgeVertices, MVertex *v = new MVertex(pc.x(), pc.y(), pc.z(), gr); gr->mesh_vertices.push_back(v); hexahedra2.push_back - (new MHexahedron27(h->getVertex(0), h->getVertex(1), h->getVertex(2), - h->getVertex(3), h->getVertex(4), h->getVertex(5), - h->getVertex(6), h->getVertex(7), ve[0], ve[1], ve[2], - ve[3], ve[4], ve[5], ve[6], ve[7], ve[8], ve[9], ve[10], - ve[11], vf[0], vf[1], vf[2], vf[3], vf[4], vf[5], v)); + (new MHexahedron27(h->getVertex(0), h->getVertex(1), h->getVertex(2), + h->getVertex(3), h->getVertex(4), h->getVertex(5), + h->getVertex(6), h->getVertex(7), ve[0], ve[1], ve[2], + ve[3], ve[4], ve[5], ve[6], ve[7], ve[8], ve[9], ve[10], + ve[11], vf[0], vf[1], vf[2], vf[3], vf[4], vf[5], v)); } delete h; } @@ -667,17 +667,17 @@ void setHighOrder(GRegion *gr, edgeContainer &edgeVertices, getEdgeVertices(gr, p, ve, edgeVertices, linear, nPts); if(incomplete){ prisms2.push_back - (new MPrism15(p->getVertex(0), p->getVertex(1), p->getVertex(2), - p->getVertex(3), p->getVertex(4), p->getVertex(5), - ve[0], ve[1], ve[2], ve[3], ve[4], ve[5], ve[6], ve[7], ve[8])); + (new MPrism15(p->getVertex(0), p->getVertex(1), p->getVertex(2), + p->getVertex(3), p->getVertex(4), p->getVertex(5), + ve[0], ve[1], ve[2], ve[3], ve[4], ve[5], ve[6], ve[7], ve[8])); } else{ getFaceVertices(gr, p, vf, faceVertices, linear, nPts); prisms2.push_back - (new MPrism18(p->getVertex(0), p->getVertex(1), p->getVertex(2), - p->getVertex(3), p->getVertex(4), p->getVertex(5), - ve[0], ve[1], ve[2], ve[3], ve[4], ve[5], ve[6], ve[7], ve[8], - vf[0], vf[1], vf[2])); + (new MPrism18(p->getVertex(0), p->getVertex(1), p->getVertex(2), + p->getVertex(3), p->getVertex(4), p->getVertex(5), + ve[0], ve[1], ve[2], ve[3], ve[4], ve[5], ve[6], ve[7], ve[8], + vf[0], vf[1], vf[2])); } delete p; } @@ -690,16 +690,16 @@ void setHighOrder(GRegion *gr, edgeContainer &edgeVertices, getEdgeVertices(gr, p, ve, edgeVertices, linear, nPts); if(incomplete){ pyramids2.push_back - (new MPyramid13(p->getVertex(0), p->getVertex(1), p->getVertex(2), - p->getVertex(3), p->getVertex(4), ve[0], ve[1], ve[2], - ve[3], ve[4], ve[5], ve[6], ve[7])); + (new MPyramid13(p->getVertex(0), p->getVertex(1), p->getVertex(2), + p->getVertex(3), p->getVertex(4), ve[0], ve[1], ve[2], + ve[3], ve[4], ve[5], ve[6], ve[7])); } else{ getFaceVertices(gr, p, vf, faceVertices, linear, nPts); pyramids2.push_back - (new MPyramid14(p->getVertex(0), p->getVertex(1), p->getVertex(2), - p->getVertex(3), p->getVertex(4), ve[0], ve[1], ve[2], - ve[3], ve[4], ve[5], ve[6], ve[7], vf[0])); + (new MPyramid14(p->getVertex(0), p->getVertex(1), p->getVertex(2), + p->getVertex(3), p->getVertex(4), ve[0], ve[1], ve[2], + ve[3], ve[4], ve[5], ve[6], ve[7], vf[0])); } delete p; } @@ -850,7 +850,7 @@ struct smoothVertexDataHON{ }; double smoothing_objective_function_HighOrder(double U, double V, MVertex *v, - std::vector<MTriangle*> &ts, GFace *gf) + std::vector<MTriangle*> &ts, GFace *gf) { GPoint gp = gf->point(U, V); const double oldX = v->x(); @@ -874,8 +874,8 @@ double smoothing_objective_function_HighOrder(double U, double V, MVertex *v, } void deriv_smoothing_objective_function_HighOrder(double U, double V, - double &F, double &dFdU, - double &dFdV, void *data) + double &F, double &dFdU, + double &dFdV, void *data) { smoothVertexDataHO *svd = (smoothVertexDataHO*)data; MVertex *v = svd->v; @@ -921,7 +921,7 @@ double smooth_obj_HighOrderN(double *uv, void *data) } void deriv_smoothing_objective_function_HighOrderN(double *uv, double *dF, - double &F, void *data) + double &F, void *data) { const double LARGE = -1.e2; const double SMALL = 1. / LARGE; @@ -947,21 +947,21 @@ void optimizeNodeLocations(GFace *gf, smoothVertexDataHON &vdN, double eps = .2) if (F < eps){ double val; minimize_N(2 * vdN.v.size(), - smooth_obj_HighOrderN, - deriv_smoothing_objective_function_HighOrderN, - &vdN, 1, uv,val); + smooth_obj_HighOrderN, + deriv_smoothing_objective_function_HighOrderN, + &vdN, 1, uv,val); double Fafter = -smooth_obj_HighOrderN(uv, &vdN); printf("%12.5E %12.5E\n", F, Fafter); if (F < Fafter){ for (unsigned int i = 0; i < vdN.v.size(); i++){ - vdN.v[i]->setParameter(0, uv[2 * i]); - vdN.v[i]->setParameter(1, uv[2 * i + 1]); - GPoint gp = gf->point(uv[2 * i], uv[2 * i + 1]); - vdN.v[i]->x() = gp.x(); - vdN.v[i]->y() = gp.y(); - vdN.v[i]->z() = gp.z(); + vdN.v[i]->setParameter(0, uv[2 * i]); + vdN.v[i]->setParameter(1, uv[2 * i + 1]); + GPoint gp = gf->point(uv[2 * i], uv[2 * i + 1]); + vdN.v[i]->x() = gp.x(); + vdN.v[i]->y() = gp.y(); + vdN.v[i]->z() = gp.z(); } - } + } } } @@ -1002,12 +1002,12 @@ bool optimizeHighOrderMesh(GFace *gf, edgeContainer &edgeVertices) if (ge->dim() == 2){ double initu,initv; ver->getParameter(0, initu); - ver->getParameter(1, initv); + ver->getParameter(1, initv); smoothVertexDataHON vdN; vdN.ts = it->second; for (int i=0;i<vdN.ts.size();i++){ - MTriangle *t = vdN.ts[i]; + MTriangle *t = vdN.ts[i]; } vdN.v = e; @@ -1016,19 +1016,19 @@ bool optimizeHighOrderMesh(GFace *gf, edgeContainer &edgeVertices) double val; double F = -smooth_obj_HighOrder(initu,initv, &vd); if (F < .2){ - minimize_2(smooth_obj_HighOrder, - deriv_smoothing_objective_function_HighOrder, &vd, 1, initu,initv,val); - double Fafter = -smooth_obj_HighOrder(initu,initv, &vd); - if (F < Fafter){ - success = true; - ver->setParameter(0,initu); - ver->setParameter(1,initv); - GPoint gp = gf->point(initu,initv); - ver->x() = gp.x(); - ver->y() = gp.y(); - ver->z() = gp.z(); - } - } + minimize_2(smooth_obj_HighOrder, + deriv_smoothing_objective_function_HighOrder, &vd, 1, initu,initv,val); + double Fafter = -smooth_obj_HighOrder(initu,initv, &vd); + if (F < Fafter){ + success = true; + ver->setParameter(0,initu); + ver->setParameter(1,initv); + GPoint gp = gf->point(initu,initv); + ver->x() = gp.x(); + ver->y() = gp.y(); + ver->z() = gp.z(); + } + } } ++it; } @@ -1045,18 +1045,18 @@ bool optimizeHighOrderMesh(GFace *gf, edgeContainer &edgeVertices) MTriangle *t1 = (MTriangle*)triangles[0]; MTriangle *t2 = (MTriangle*)triangles[1]; if(n2 < n4) - e = edgeVertices[std::make_pair<MVertex*, MVertex*> (n2, n4)]; + e = edgeVertices[std::make_pair<MVertex*, MVertex*> (n2, n4)]; else - e = edgeVertices[std::make_pair<MVertex*, MVertex*> (n4, n2)]; + e = edgeVertices[std::make_pair<MVertex*, MVertex*> (n4, n2)]; if (e.size() < 5){ - smoothVertexDataHON vdN; - vdN.v = e; - vdN.gf = gf; - vdN.ts.clear(); + smoothVertexDataHON vdN; + vdN.v = e; + vdN.gf = gf; + vdN.ts.clear(); vdN.ts.push_back(t1); - vdN.ts.push_back(t2); - optimizeNodeLocations(gf, vdN); + vdN.ts.push_back(t2); + optimizeNodeLocations(gf, vdN); } } } @@ -1093,110 +1093,110 @@ bool smoothInternalEdges(GFace *gf, edgeContainer &edgeVertices) MVertex *n1 = t1->getOtherVertex(n2, n4); MVertex *n3 = t2->getOtherVertex(n2, n4); if(n1 < n2) - e1 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n1, n2)]; + e1 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n1, n2)]; else - e1 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n2, n1)]; + e1 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n2, n1)]; if(n2 < n3) - e2 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n2, n3)]; + e2 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n2, n3)]; else - e2 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n3, n2)]; + e2 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n3, n2)]; if(n3 < n4) - e3 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n3, n4)]; + e3 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n3, n4)]; else - e3 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n4, n3)]; + e3 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n4, n3)]; if(n4 < n1) - e4 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n4, n1)]; + e4 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n4, n1)]; else - e4 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n1, n4)]; + e4 = edgeVertices[std::make_pair<MVertex*, MVertex*>(n1, n4)]; if(n2 < n4) - e = edgeVertices[std::make_pair<MVertex*, MVertex*>(n2, n4)]; + e = edgeVertices[std::make_pair<MVertex*, MVertex*>(n2, n4)]; else - e = edgeVertices[std::make_pair<MVertex*, MVertex*>(n4, n2)]; + e = edgeVertices[std::make_pair<MVertex*, MVertex*>(n4, n2)]; if((!straightLine(e1, n1, n2) || !straightLine(e2, n2, n3) || - !straightLine(e3, n3, n4) || !straightLine(e4, n4, n1))){ - - double Unew[NBST][10],Vnew[NBST][10]; - double Xold[10],Yold[10],Zold[10]; - - for(unsigned int i = 0; i < e.size(); i++){ - Xold[i] = e[i]->x(); - Yold[i] = e[i]->y(); - Zold[i] = e[i]->z(); - } - - double minJ = 1.e22; - double maxJ = -1.e22; - getMinMaxJac (t1, minJ, maxJ); - getMinMaxJac (t2, minJ, maxJ); - int kopt = -1; - for (int k=0;k<NBST;k++){ - double relax = (k+1)/(double)NBST; - for(unsigned int i = 0; i < e.size(); i++){ - double v = (double)(i + 1) / (e.size() + 1); - double u = 1. - v; - MVertex *vert = (n2 < n4) ? e[i] : e[e.size() - i - 1]; - MVertex *vert1 = (n1 < n2) ? e1[e1.size() - i - 1] : e1[i]; - MVertex *vert3 = (n3 < n4) ? e3[i] : e3[e3.size() - i - 1]; - MVertex *vert4 = (n4 < n1) ? e4[e4.size() - i - 1] : e4[i]; - MVertex *vert2 = (n2 < n3) ? e2[i] : e2[e2.size() - i - 1]; - double U1,V1,U2,V2,U3,V3,U4,V4,U,V,nU1,nV1,nU2,nV2,nU3,nV3,nU4,nV4; - parametricCoordinates(vert , gf, U, V); - parametricCoordinates(vert1, gf, U1, V1); - parametricCoordinates(vert2, gf, U2, V2); - parametricCoordinates(vert3, gf, U3, V3); - parametricCoordinates(vert4, gf, U4, V4); - parametricCoordinates(n1, gf, nU1, nV1); - parametricCoordinates(n2, gf, nU2, nV2); - parametricCoordinates(n3, gf, nU3, nV3); - parametricCoordinates(n4, gf, nU4, nV4); - - Unew[k][i] = U + relax * ((1.-u) * U4 + u * U2 + - (1.-v) * U1 + v * U3 - - ((1.-u)*(1.-v) * nU1 - + u * (1.-v) * nU2 - + u * v * nU3 - + (1.-u) * v * nU4) - U); - Vnew[k][i] = V + relax * ((1.-u) * V4 + u * V2 + - (1.-v) * V1 + v * V3 - - ((1.-u)*(1.-v) * nV1 - + u * (1.-v) * nV2 - + u * v * nV3 - + (1.-u) * v * nV4) - V); - GPoint gp = gf->point(Unew[k][i],Vnew[k][i]); - vert->x() = gp.x(); - vert->y() = gp.y(); - vert->z() = gp.z(); - } - double minJloc = 1.e22; - double maxJloc = -1.e22; - getMinMaxJac(t1, minJloc, maxJloc); - getMinMaxJac(t2, minJloc, maxJloc); - - if (minJloc > minJ){ - kopt = k; - minJ = minJloc; - } - } - if (kopt == -1){ - for(unsigned int i = 0; i < e.size(); i++){ - e[i]->x() = Xold[i]; - e[i]->y() = Yold[i]; - e[i]->z() = Zold[i]; - } - } - else{ - success = true; - for(unsigned int i = 0; i < e.size(); i++){ - MVertex *vert = (n2 < n4) ? e[i] : e[e.size() - i - 1]; - vert->setParameter(0,Unew[kopt][i]); - vert->setParameter(1,Vnew[kopt][i]); - GPoint gp = gf->point(Unew[kopt][i],Vnew[kopt][i]); - vert->x() = gp.x(); - vert->y() = gp.y(); - vert->z() = gp.z(); - } - } + !straightLine(e3, n3, n4) || !straightLine(e4, n4, n1))){ + + double Unew[NBST][10],Vnew[NBST][10]; + double Xold[10],Yold[10],Zold[10]; + + for(unsigned int i = 0; i < e.size(); i++){ + Xold[i] = e[i]->x(); + Yold[i] = e[i]->y(); + Zold[i] = e[i]->z(); + } + + double minJ = 1.e22; + double maxJ = -1.e22; + getMinMaxJac (t1, minJ, maxJ); + getMinMaxJac (t2, minJ, maxJ); + int kopt = -1; + for (int k=0;k<NBST;k++){ + double relax = (k+1)/(double)NBST; + for(unsigned int i = 0; i < e.size(); i++){ + double v = (double)(i + 1) / (e.size() + 1); + double u = 1. - v; + MVertex *vert = (n2 < n4) ? e[i] : e[e.size() - i - 1]; + MVertex *vert1 = (n1 < n2) ? e1[e1.size() - i - 1] : e1[i]; + MVertex *vert3 = (n3 < n4) ? e3[i] : e3[e3.size() - i - 1]; + MVertex *vert4 = (n4 < n1) ? e4[e4.size() - i - 1] : e4[i]; + MVertex *vert2 = (n2 < n3) ? e2[i] : e2[e2.size() - i - 1]; + double U1,V1,U2,V2,U3,V3,U4,V4,U,V,nU1,nV1,nU2,nV2,nU3,nV3,nU4,nV4; + parametricCoordinates(vert , gf, U, V); + parametricCoordinates(vert1, gf, U1, V1); + parametricCoordinates(vert2, gf, U2, V2); + parametricCoordinates(vert3, gf, U3, V3); + parametricCoordinates(vert4, gf, U4, V4); + parametricCoordinates(n1, gf, nU1, nV1); + parametricCoordinates(n2, gf, nU2, nV2); + parametricCoordinates(n3, gf, nU3, nV3); + parametricCoordinates(n4, gf, nU4, nV4); + + Unew[k][i] = U + relax * ((1.-u) * U4 + u * U2 + + (1.-v) * U1 + v * U3 - + ((1.-u)*(1.-v) * nU1 + + u * (1.-v) * nU2 + + u * v * nU3 + + (1.-u) * v * nU4) - U); + Vnew[k][i] = V + relax * ((1.-u) * V4 + u * V2 + + (1.-v) * V1 + v * V3 - + ((1.-u)*(1.-v) * nV1 + + u * (1.-v) * nV2 + + u * v * nV3 + + (1.-u) * v * nV4) - V); + GPoint gp = gf->point(Unew[k][i],Vnew[k][i]); + vert->x() = gp.x(); + vert->y() = gp.y(); + vert->z() = gp.z(); + } + double minJloc = 1.e22; + double maxJloc = -1.e22; + getMinMaxJac(t1, minJloc, maxJloc); + getMinMaxJac(t2, minJloc, maxJloc); + + if (minJloc > minJ){ + kopt = k; + minJ = minJloc; + } + } + if (kopt == -1){ + for(unsigned int i = 0; i < e.size(); i++){ + e[i]->x() = Xold[i]; + e[i]->y() = Yold[i]; + e[i]->z() = Zold[i]; + } + } + else{ + success = true; + for(unsigned int i = 0; i < e.size(); i++){ + MVertex *vert = (n2 < n4) ? e[i] : e[e.size() - i - 1]; + vert->setParameter(0,Unew[kopt][i]); + vert->setParameter(1,Vnew[kopt][i]); + GPoint gp = gf->point(Unew[kopt][i],Vnew[kopt][i]); + vert->x() = gp.x(); + vert->y() = gp.y(); + vert->z() = gp.z(); + } + } } } } @@ -1212,12 +1212,12 @@ void checkHighOrderTriangles(GModel *m) double maxJ = -1.e22; for(unsigned int i = 0; i < (*it)->triangles.size(); i++){ double minJloc = 1.e22; - double maxJloc = -1.e22; + double maxJloc = -1.e22; MTriangle *t = (*it)->triangles[i]; if(t->getPolynomialOrder() > 1 && t->getPolynomialOrder() < 6){ - getMinMaxJac (t, minJloc, maxJloc); - minJ = std::min(minJ, minJloc); - maxJ = std::max(maxJ, maxJloc); + getMinMaxJac (t, minJloc, maxJloc); + minJ = std::min(minJ, minJloc); + maxJ = std::max(maxJ, maxJloc); } } minJGlob = std::min(minJGlob,minJ); @@ -1243,35 +1243,35 @@ void printJacobians(GModel *m, const char *nm) for(unsigned int i = 0; i < (*it)->triangles.size(); i++){ MTriangle *t = (*it)->triangles[i]; for(int i = 0; i < n; i++){ - for(int k = 0; k < n - i; k++){ - SPoint3 pt; - double u = (double)i / (n - 1); - double v = (double)k / (n - 1); - t->pnt(u,v, pt); - D[i][k] = mesh_functional_distorsion (t,u,v); - X[i][k] = pt.x(); - Y[i][k] = pt.y(); - Z[i][k] = pt.z(); - } + for(int k = 0; k < n - i; k++){ + SPoint3 pt; + double u = (double)i / (n - 1); + double v = (double)k / (n - 1); + t->pnt(u,v, pt); + D[i][k] = mesh_functional_distorsion (t,u,v); + X[i][k] = pt.x(); + Y[i][k] = pt.y(); + Z[i][k] = pt.z(); + } } for(int i = 0; i < n -1; i++){ - for(int k = 0; k < n - i -1; k++){ - fprintf(f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%22.15E,%22.15E,%22.15E};\n", - X[i][k],Y[i][k],Z[i][k], - X[i+1][k],Y[i+1][k],Z[i+1][k], - X[i][k+1],Y[i][k+1],Z[i][k+1], - D[i][k], - D[i+1][k], - D[i][k+1]); - if (i != n-2 && k != n - i -2) - fprintf(f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%22.15E,%22.15E,%22.15E};\n", - X[i+1][k],Y[i+1][k],Z[i+1][k], - X[i+1][k+1],Y[i+1][k+1],Z[i+1][k+1], - X[i][k+1],Y[i][k+1],Z[i][k+1], - D[i+1][k], - D[i+1][k+1], - D[i][k+1]); - } + for(int k = 0; k < n - i -1; k++){ + fprintf(f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%22.15E,%22.15E,%22.15E};\n", + X[i][k],Y[i][k],Z[i][k], + X[i+1][k],Y[i+1][k],Z[i+1][k], + X[i][k+1],Y[i][k+1],Z[i][k+1], + D[i][k], + D[i+1][k], + D[i][k+1]); + if (i != n-2 && k != n - i -2) + fprintf(f,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%22.15E,%22.15E,%22.15E};\n", + X[i+1][k],Y[i+1][k],Z[i+1][k], + X[i+1][k+1],Y[i+1][k+1],Z[i+1][k+1], + X[i][k+1],Y[i][k+1],Z[i][k+1], + D[i+1][k], + D[i+1][k+1], + D[i][k+1]); + } } } } @@ -1321,15 +1321,15 @@ void SetOrderN(GModel *m, int order, bool linear, bool incomplete) for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ Msg(INFO, "Smoothing internal Edges in Surface %d",(*it)->tag()); for (int i = 0; i < 10; i++) { - if (!smoothInternalEdges(*it, edgeVertices))break; - checkHighOrderTriangles(m); + if (!smoothInternalEdges(*it, edgeVertices))break; + checkHighOrderTriangles(m); } optimizeHighOrderMeshInternalNodes(*it); } for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ for (int i=0;i<CTX.mesh.nb_smoothing;i++){ - if(!optimizeHighOrderMesh(*it, edgeVertices))break; - checkHighOrderTriangles(m); + if(!optimizeHighOrderMesh(*it, edgeVertices))break; + checkHighOrderTriangles(m); } } } diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index a6a7bb299e2b194a005574b4affda6d77dfceb36..ecf6e7c7cfe09be5a851c47095b91d1303fbc646 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -1,4 +1,4 @@ -// $Id: meshGEdge.cpp,v 1.56 2008-03-18 14:43:53 remacle Exp $ +// $Id: meshGEdge.cpp,v 1.57 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -54,11 +54,11 @@ static std::vector<xi2lc> interpLc; void smoothInterpLc(int nbSmooth) { for(int j = 0; j < nbSmooth; j++){ - for(int i = 0 ; i < (int)interpLc.size(); i++){ + for(int i = 0 ; i < (int)interpLc.size(); i++){ xi2lc &left = (i == 0) ? interpLc[0] : interpLc[i - 1]; xi2lc &mid = interpLc[i]; xi2lc &right = (i == (int)interpLc.size() - 1) ? - interpLc[interpLc.size() - 1] : interpLc[i+1]; + interpLc[interpLc.size() - 1] : interpLc[i+1]; if(1. / mid.lc > 1.1 * 1. / left.lc) mid.lc = left.lc / 1.1; if(1. / mid.lc > 1.1 * 1. / right.lc) mid.lc = right.lc / 1.1; } @@ -68,7 +68,7 @@ void smoothInterpLc(int nbSmooth) void printInterpLc(const char *name) { FILE *f = fopen(name,"w"); - for(unsigned int i = 0; i < interpLc.size(); i++){ + for(unsigned int i = 0; i < interpLc.size(); i++){ xi2lc &interp = interpLc[i]; fprintf(f,"%12.5E %12.5E\n", interp.xi, 1 / interp.lc); } @@ -88,7 +88,7 @@ void buildInterpLc(List_T *lcPoints) double F_Lc_usingInterpLc(GEdge *ge, double t) { std::vector<xi2lc>::iterator it = std::lower_bound(interpLc.begin(), - interpLc.end(), xi2lc(t, 0)); + interpLc.end(), xi2lc(t, 0)); double t1 = it->xi; double l1 = it->lc; it++; @@ -161,32 +161,32 @@ double F_Transfinite(GEdge *ge, double t) case 1: // Geometric progression ar^i; Sum of n terms = length = a (r^n-1)/(r-1) { - if(sign(type) >= 0) - r = coef; - else - r = 1. / coef; - double a = ge->length() * (r - 1.) / (pow(r, nbpt - 1.) - 1.); - int i = (int)(log(t * ge->length() / a * (r - 1.) + 1.) / log(r)); - val = d / (a * pow(r, (double)i)); + if(sign(type) >= 0) + r = coef; + else + r = 1. / coef; + double a = ge->length() * (r - 1.) / (pow(r, nbpt - 1.) - 1.); + int i = (int)(log(t * ge->length() / a * (r - 1.) + 1.) / log(r)); + val = d / (a * pow(r, (double)i)); } break; - + case 2: // Bump { - double a; - if(coef > 1.0) { - a = -4. * sqrt(coef - 1.) * - atan2(1., sqrt(coef - 1.)) / - ((double)nbpt * ge->length()); - } - else { - a = 2. * sqrt(1. - coef) * - log(fabs((1. + 1. / sqrt(1. - coef)) - / (1. - 1. / sqrt(1. - coef)))) - / ((double)nbpt * ge->length()); - } - double b = -a * ge->length() * ge->length() / (4. * (coef - 1.)); - val = d / (-a * DSQR(t * ge->length() - (ge->length()) * 0.5) + b); + double a; + if(coef > 1.0) { + a = -4. * sqrt(coef - 1.) * + atan2(1., sqrt(coef - 1.)) / + ((double)nbpt * ge->length()); + } + else { + a = 2. * sqrt(1. - coef) * + log(fabs((1. + 1. / sqrt(1. - coef)) + / (1. - 1. / sqrt(1. - coef)))) + / ((double)nbpt * ge->length()); + } + double b = -a * ge->length() * ge->length() / (4. * (coef - 1.)); + val = d / (-a * DSQR(t * ge->length() - (ge->length()) * 0.5) + b); } break; @@ -244,7 +244,7 @@ void RecursiveIntegration(GEdge *ge, IntPoint * from, IntPoint * to, } double Integration(GEdge *ge, double t1, double t2, - double (*f) (GEdge *e, double X), + double (*f) (GEdge *e, double X), List_T * pPoints, double Prec) { IntPoint from, to; @@ -299,8 +299,8 @@ void meshGEdge::operator() (GEdge *ge) double t_end = bounds.high(); // first compute the length of the curve by integrating one - SPoint3 p1=ge->model()->bounds().min(); - SPoint3 p2=ge->model()->bounds().max(); + SPoint3 p1=ge->model()->bounds().min(); + SPoint3 p2=ge->model()->bounds().max(); double length = Integration(ge, t_begin, t_end, F_One, Points, 1.e-8*p1.distance(p2)); ge->setLength(length); // Send a messsage to the GMSH environment @@ -322,7 +322,7 @@ void meshGEdge::operator() (GEdge *ge) else{ if(CTX.mesh.lc_integration_precision > 1.e-8){ Integration(ge, t_begin, t_end, F_Lc_usingInterpLcBis, lcPoints, - CTX.mesh.lc_integration_precision); + CTX.mesh.lc_integration_precision); buildInterpLc(lcPoints); // printInterpLc("toto1.dat"); // smoothInterpLc(20); @@ -367,15 +367,15 @@ void meshGEdge::operator() (GEdge *ge) const double d = (double)NUMP * b; if((fabs(P2.p) >= fabs(d)) && (fabs(P1.p) < fabs(d))) { double dt = P2.t - P1.t; - double dlc = P2.lc - P1.lc; + double dlc = P2.lc - P1.lc; double dp = P2.p - P1.p; double t = P1.t + dt / dp * (d - P1.p); - SVector3 der = ge->firstDer(t); - const double d = norm(der); + SVector3 der = ge->firstDer(t); + const double d = norm(der); double lc = d/(P1.lc + dlc / dp * (d - P1.p)); GPoint V = ge->point(t); - ge->mesh_vertices[NUMP - 1] = new MEdgeVertex(V.x(), V.y(), V.z(), ge, t, lc); - // printf("lc = %12.5E %12.5E \n",lc,P1.lc,P2.lc); + ge->mesh_vertices[NUMP - 1] = new MEdgeVertex(V.x(), V.y(), V.z(), ge, t, lc); + // printf("lc = %12.5E %12.5E \n",lc,P1.lc,P2.lc); NUMP++; } else { diff --git a/Mesh/meshGEdgeExtruded.cpp b/Mesh/meshGEdgeExtruded.cpp index 56387e2e5a7c1320b6830d42386d8363c245de91..668e393f6fd4147342b12f6dd337ea7e4f0cd4c3 100644 --- a/Mesh/meshGEdgeExtruded.cpp +++ b/Mesh/meshGEdgeExtruded.cpp @@ -1,4 +1,4 @@ -// $Id: meshGEdgeExtruded.cpp,v 1.11 2008-02-22 21:09:01 geuzaine Exp $ +// $Id: meshGEdgeExtruded.cpp,v 1.12 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -35,7 +35,7 @@ void extrudeMesh(GVertex *from, GEdge *to) double x = v->x(), y = v->y(), z = v->z(); ep->Extrude(j, k + 1, x, y, z); if(j != ep->mesh.NbLayer - 1 || k != ep->mesh.NbElmLayer[j] - 1) - to->mesh_vertices.push_back(new MEdgeVertex(x, y, z, to, ep->u(j, k + 1))); + to->mesh_vertices.push_back(new MEdgeVertex(x, y, z, to, ep->u(j, k + 1))); } } } @@ -55,7 +55,7 @@ void copyMesh(GEdge *from, GEdge *to) MVertex *v = from->mesh_vertices[index]; double x = v->x(), y = v->y(), z = v->z(); ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], - x, y, z); + x, y, z); double u; v->getParameter(0, u); double newu = (direction > 0) ? u : (u_max - u + u_min); diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 9edb7e115fcac014a5f1e30af9502ef7770ae446..6503e7fdfa864125025a6fe32c41f0f9657c2b2d 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFace.cpp,v 1.126 2008-03-18 19:30:14 geuzaine Exp $ +// $Id: meshGFace.cpp,v 1.127 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -50,8 +50,8 @@ void fourthPoint(double *p1, double *p2, double *p3, double *p4) double vz[3]; prodve(vx, vy, vz); norme(vz); double R = sqrt((p1[0] - c[0]) * (p1[0] - c[0]) + - (p1[1] - c[1]) * (p1[1] - c[1]) + - (p1[2] - c[2]) * (p1[2] - c[2])); + (p1[1] - c[1]) * (p1[1] - c[1]) + + (p1[2] - c[2]) * (p1[2] - c[2])); p4[0] = c[0] + R * vz[0]; p4[1] = c[1] + R * vz[1]; p4[2] = c[2] + R * vz[2]; @@ -71,7 +71,7 @@ bool noseam(GFace *gf) } void remeshUnrecoveredEdges(std::set<EdgeToRecover> &edgesNotRecovered, - std::list<GFace*> &facesToRemesh) + std::list<GFace*> &facesToRemesh) { facesToRemesh.clear(); deMeshGFace dem; @@ -82,8 +82,8 @@ void remeshUnrecoveredEdges(std::set<EdgeToRecover> &edgesNotRecovered, // Un-mesh model faces adjacent to the model edge for(std::list<GFace*>::iterator it = l_faces.begin(); it != l_faces.end(); ++it){ if ((*it)->triangles.size() ||(*it)->quadrangles.size()){ - facesToRemesh.push_back(*it); - dem(*it); + facesToRemesh.push_back(*it); + dem(*it); } } @@ -101,47 +101,47 @@ void remeshUnrecoveredEdges(std::set<EdgeToRecover> &edgesNotRecovered, MVertex *v1 = itr->ge->lines[i]->getVertex(0); MVertex *v2 = itr->ge->lines[i]->getVertex(1); if ((v1->getNum() == p1 && v2->getNum() == p2) || - (v1->getNum() == p2 && v2->getNum() == p1)){ - double t1; - double lc1 = -1; - if (v1->onWhat() == g1) t1 = bb.low(); - else if (v1->onWhat() == g2) t1 = bb.high(); - else { - MEdgeVertex *ev1 = (MEdgeVertex*)v1; - lc1 = ev1->getLc(); - v1->getParameter(0, t1); - } - double t2; - double lc2 = -1; - if (v2->onWhat() == g1) t2 = bb.low(); - else if (v2->onWhat() == g2) t2 = bb.high(); - else { - MEdgeVertex *ev2 = (MEdgeVertex*)v2; - lc2 = ev2->getLc(); - v2->getParameter(0, t2); - } - - // periodic - if (v1->onWhat() == g1 && v1->onWhat() == g2) - t1 = fabs(t2-bb.low()) < fabs(t2-bb.high()) ? bb.low() : bb.high(); - if (v2->onWhat() == g1 && v2->onWhat() == g2) - t2 = fabs(t1-bb.low()) < fabs(t1-bb.high()) ? bb.low() : bb.high(); - - if (lc1 == -1) - lc1 = BGM_MeshSize(v1->onWhat(), 0, 0, v1->x(), v1->y(), v1->z()); - if (lc2 == -1) - lc2 = BGM_MeshSize(v2->onWhat(), 0, 0, v2->x(), v2->y(), v2->z()); - // should be better, i.e. equidistant - double t = 0.5 * (t2 + t1); - double lc = 0.5 * (lc1 + lc2); - GPoint V = itr->ge->point(t); - MEdgeVertex * newv = new MEdgeVertex(V.x(), V.y(), V.z(), itr->ge, t, lc); - newLines.push_back(new MLine(v1, newv)); - newLines.push_back(new MLine(newv, v2)); - delete itr->ge->lines[i]; + (v1->getNum() == p2 && v2->getNum() == p1)){ + double t1; + double lc1 = -1; + if (v1->onWhat() == g1) t1 = bb.low(); + else if (v1->onWhat() == g2) t1 = bb.high(); + else { + MEdgeVertex *ev1 = (MEdgeVertex*)v1; + lc1 = ev1->getLc(); + v1->getParameter(0, t1); + } + double t2; + double lc2 = -1; + if (v2->onWhat() == g1) t2 = bb.low(); + else if (v2->onWhat() == g2) t2 = bb.high(); + else { + MEdgeVertex *ev2 = (MEdgeVertex*)v2; + lc2 = ev2->getLc(); + v2->getParameter(0, t2); + } + + // periodic + if (v1->onWhat() == g1 && v1->onWhat() == g2) + t1 = fabs(t2-bb.low()) < fabs(t2-bb.high()) ? bb.low() : bb.high(); + if (v2->onWhat() == g1 && v2->onWhat() == g2) + t2 = fabs(t1-bb.low()) < fabs(t1-bb.high()) ? bb.low() : bb.high(); + + if (lc1 == -1) + lc1 = BGM_MeshSize(v1->onWhat(), 0, 0, v1->x(), v1->y(), v1->z()); + if (lc2 == -1) + lc2 = BGM_MeshSize(v2->onWhat(), 0, 0, v2->x(), v2->y(), v2->z()); + // should be better, i.e. equidistant + double t = 0.5 * (t2 + t1); + double lc = 0.5 * (lc1 + lc2); + GPoint V = itr->ge->point(t); + MEdgeVertex * newv = new MEdgeVertex(V.x(), V.y(), V.z(), itr->ge, t, lc); + newLines.push_back(new MLine(v1, newv)); + newLines.push_back(new MLine(newv, v2)); + delete itr->ge->lines[i]; } else { - newLines.push_back(itr->ge->lines[i]); + newLines.push_back(itr->ge->lines[i]); } } itr->ge->lines = newLines; @@ -162,8 +162,8 @@ bool AlgoDelaunay2D(GFace *gf) } void computeEdgeLoops(const GFace *gf, - std::vector<MVertex*> &all_mvertices, - std::vector<int> &indices) + std::vector<MVertex*> &all_mvertices, + std::vector<int> &indices) { std::list<GEdge*> edges = gf->edges(); std::list<int> ori = gf->orientations(); @@ -201,15 +201,15 @@ void computeEdgeLoops(const GFace *gf, all_mvertices.push_back(v_start->mesh_vertices[0]); if(*ito == 1) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) - all_mvertices.push_back((*it)->mesh_vertices[i]); + all_mvertices.push_back((*it)->mesh_vertices[i]); else for (int i = (*it)->mesh_vertices.size()-1; i >= 0; i--) - all_mvertices.push_back((*it)->mesh_vertices[i]); + all_mvertices.push_back((*it)->mesh_vertices[i]); } } void computeElementShapes(GFace *gf, double &worst, double &avg, double &best, - int &nT, int &greaterThan) + int &nT, int &greaterThan) { worst = 1.e22; avg = 0.0; @@ -228,7 +228,7 @@ void computeElementShapes(GFace *gf, double &worst, double &avg, double &best, } bool recover_medge(BDS_Mesh *m, GEdge *ge, std::set<EdgeToRecover> *e2r, - std::set<EdgeToRecover> *not_recovered, int pass_) + std::set<EdgeToRecover> *not_recovered, int pass_) { BDS_GeomEntity *g = 0; if (pass_ == 2){ @@ -247,20 +247,20 @@ bool recover_medge(BDS_Mesh *m, GEdge *ge, std::set<EdgeToRecover> *e2r, BDS_Point *pstart = m->find_point(vstart->getNum()); BDS_Point *pend = m->find_point(vend->getNum()); if(!pstart->g){ - m->add_geom (vstart->getNum(), 0); - BDS_GeomEntity *g0 = m->get_geom(vstart->getNum(), 0); - pstart->g = g0; + m->add_geom (vstart->getNum(), 0); + BDS_GeomEntity *g0 = m->get_geom(vstart->getNum(), 0); + pstart->g = g0; } if(!pend->g){ - m->add_geom(vend->getNum(), 0); - BDS_GeomEntity *g0 = m->get_geom(vend->getNum(), 0); - pend->g = g0; + m->add_geom(vend->getNum(), 0); + BDS_GeomEntity *g0 = m->get_geom(vend->getNum(), 0); + pend->g = g0; } BDS_Edge * e = m->recover_edge(vstart->getNum(), vend->getNum(), e2r, not_recovered); if (e) e->g = g; else { - // Msg(GERROR, "The unrecoverable edge is on model edge %d",ge->tag()); - return false; + // Msg(GERROR, "The unrecoverable edge is on model edge %d",ge->tag()); + return false; } return true; } @@ -294,10 +294,10 @@ bool recover_medge(BDS_Mesh *m, GEdge *ge, std::set<EdgeToRecover> *e2r, e = m->recover_edge(vstart->getNum(), vend->getNum(), e2r, not_recovered); if (e) e->g = g; else { - // Msg(GERROR, "Unable to recover an edge %g %g && %g %g (%d/%d)", - // vstart->x(), vstart->y(), vend->x(), vend->y(), i, - // ge->mesh_vertices.size()); - // return false; + // Msg(GERROR, "Unable to recover an edge %g %g && %g %g (%d/%d)", + // vstart->x(), vstart->y(), vend->x(), vend->y(), i, + // ge->mesh_vertices.size()); + // return false; } } } @@ -341,11 +341,11 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) if ((*it)->isSeam(gf)) return false; if(!(*it)->isMeshDegenerated()){ all_vertices.insert((*it)->mesh_vertices.begin(), - (*it)->mesh_vertices.end()); + (*it)->mesh_vertices.end()); all_vertices.insert((*it)->getBeginVertex()->mesh_vertices.begin(), - (*it)->getBeginVertex()->mesh_vertices.end()); + (*it)->getBeginVertex()->mesh_vertices.end()); all_vertices.insert((*it)->getEndVertex()->mesh_vertices.begin(), - (*it)->getEndVertex()->mesh_vertices.end()); + (*it)->getEndVertex()->mesh_vertices.end()); } ++it; } @@ -353,11 +353,11 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) it = emb_edges.begin(); while(it != emb_edges.end()){ all_vertices.insert((*it)->mesh_vertices.begin(), - (*it)->mesh_vertices.end() ); + (*it)->mesh_vertices.end() ); all_vertices.insert((*it)->getBeginVertex()->mesh_vertices.begin(), - (*it)->getBeginVertex()->mesh_vertices.end()); + (*it)->getBeginVertex()->mesh_vertices.end()); all_vertices.insert((*it)->getEndVertex()->mesh_vertices.begin(), - (*it)->getEndVertex()->mesh_vertices.end()); + (*it)->getEndVertex()->mesh_vertices.end()); ++it; } @@ -393,9 +393,9 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) else{ double UU, VV; if(here->onWhat() == gf && here->getParameter(0, UU) && here->getParameter(1, VV)) - param = SPoint2(UU, VV); + param = SPoint2(UU, VV); else - param = gf->parFromPoint(SPoint3(here->x(), here->y(), here->z())); + param = gf->parFromPoint(SPoint3(here->x(), here->y(), here->z())); } U_[count] = param.x(); V_[count] = param.y(); @@ -467,27 +467,27 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) int num = here->getNum(); double U, V; if(num < 0){ // fake bbox points - U = bb[-1 - num]->x(); - V = bb[-1 - num]->y(); + U = bb[-1 - num]->x(); + V = bb[-1 - num]->y(); } else{ - U = U_[num]; - V = V_[num]; + U = U_[num]; + V = V_[num]; } BDS_Point *pp = m->add_point(num, U, V, gf); GEntity *ge = here->onWhat(); if(ge->dim() == 0){ - pp->lcBGM() = BGM_MeshSize(ge, 0, 0, here->x(), here->y(), here->z()); + pp->lcBGM() = BGM_MeshSize(ge, 0, 0, here->x(), here->y(), here->z()); } else if(ge->dim() == 1){ - double u; - here->getParameter(0,u); - pp->lcBGM() = BGM_MeshSize(ge, u, 0, here->x(), here->y(), here->z()); + double u; + here->getParameter(0,u); + pp->lcBGM() = BGM_MeshSize(ge, u, 0, here->x(), here->y(), here->z()); } else - pp->lcBGM() = 1.e22; + pp->lcBGM() = 1.e22; pp->lc() = pp->lcBGM(); } @@ -547,7 +547,7 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) if (edgesNotRecovered.size()){ Msg(WARNING, ":-( There exists %d intersections in the 1d mesh", - edgesNotRecovered.size()); + edgesNotRecovered.size()); Msg(WARNING, "8-| Gmsh splits those edges and tries again"); std::list<GFace *> facesToRemesh; remeshUnrecoveredEdges(edgesNotRecovered, facesToRemesh); @@ -568,7 +568,7 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) } if(RECUR_ITER > 0) Msg(WARNING, ":-) Gmsh was able to recover all edges after %d ITERATIONS", - RECUR_ITER); + RECUR_ITER); // Msg(INFO, "Boundary Edges recovered for surface %d",gf->tag()); // Look for an edge that is on the boundary for which one of the two @@ -581,16 +581,16 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) while (ite != m->edges.end()){ BDS_Edge *e = *ite; if(e->g && e->numfaces() == 2){ - BDS_Point *oface[2]; - e->oppositeof(oface); - if (oface[0]->iD < 0){ - recur_tag(e->faces(1), &CLASS_F); - break; - } - else if (oface[1]->iD < 0){ - recur_tag(e->faces(0), &CLASS_F); - break; - } + BDS_Point *oface[2]; + e->oppositeof(oface); + if (oface[0]->iD < 0){ + recur_tag(e->faces(1), &CLASS_F); + break; + } + else if (oface[1]->iD < 0){ + recur_tag(e->faces(0), &CLASS_F); + break; + } } ++ite; } @@ -617,12 +617,12 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) while (ite != m->edges.end()){ BDS_Edge *e = *ite; if (e->numfaces() == 0) - m->del_edge(e); + m->del_edge(e); else{ - if (!e->g) - e->g = &CLASS_F; - if (!e->p1->g || e->p1->g->classif_degree > e->g->classif_degree)e->p1->g = e->g; - if (!e->p2->g || e->p2->g->classif_degree > e->g->classif_degree)e->p2->g = e->g; + if (!e->g) + e->g = &CLASS_F; + if (!e->p1->g || e->p1->g->classif_degree > e->g->classif_degree)e->p1->g = e->g; + if (!e->p2->g || e->p2->g->classif_degree > e->g->classif_degree)e->p2->g = e->g; } ++ite; } @@ -658,10 +658,10 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) } computeMeshSizeFieldAccuracy(gf, *m, gf->meshStatistics.efficiency_index, - gf->meshStatistics.longest_edge_length, - gf->meshStatistics.smallest_edge_length, - gf->meshStatistics.nbEdge, - gf->meshStatistics.nbGoodLength); + gf->meshStatistics.longest_edge_length, + gf->meshStatistics.smallest_edge_length, + gf->meshStatistics.nbEdge, + gf->meshStatistics.nbGoodLength); gf->meshStatistics.status = GFace::DONE; // fill the small gmsh structures @@ -670,9 +670,9 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) while (itp != m->points.end()){ BDS_Point *p = *itp; if (numbered_vertices.find(p->iD) == numbered_vertices.end()){ - MVertex *v = new MFaceVertex (p->X, p->Y, p->Z, gf, p->u, p->v); - numbered_vertices[p->iD]=v; - gf->mesh_vertices.push_back(v); + MVertex *v = new MFaceVertex (p->X, p->Y, p->Z, gf, p->u, p->v); + numbered_vertices[p->iD]=v; + gf->mesh_vertices.push_back(v); } ++itp; } @@ -682,17 +682,17 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) while (itt != m->triangles.end()){ BDS_Face *t = *itt; if (!t->deleted){ - BDS_Point *n[4]; - t->getNodes(n); - MVertex *v1 = numbered_vertices[n[0]->iD]; - MVertex *v2 = numbered_vertices[n[1]->iD]; - MVertex *v3 = numbered_vertices[n[2]->iD]; - if (!n[3]) - gf->triangles.push_back(new MTriangle(v1, v2, v3)); - else{ - MVertex *v4 = numbered_vertices[n[3]->iD]; - gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); - } + BDS_Point *n[4]; + t->getNodes(n); + MVertex *v1 = numbered_vertices[n[0]->iD]; + MVertex *v2 = numbered_vertices[n[1]->iD]; + MVertex *v3 = numbered_vertices[n[2]->iD]; + if (!n[3]) + gf->triangles.push_back(new MTriangle(v1, v2, v3)); + else{ + MVertex *v4 = numbered_vertices[n[3]->iD]; + gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); + } } ++itt; } @@ -719,10 +719,10 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true) delete [] V_; computeElementShapes(gf, gf->meshStatistics.worst_element_shape, - gf->meshStatistics.average_element_shape, - gf->meshStatistics.best_element_shape, - gf->meshStatistics.nbTriangle, - gf->meshStatistics.nbGoodQuality); + gf->meshStatistics.average_element_shape, + gf->meshStatistics.best_element_shape, + gf->meshStatistics.nbTriangle, + gf->meshStatistics.nbGoodQuality); return true; } @@ -747,11 +747,11 @@ void printMesh1d (int iEdge, int seam, std::vector<SPoint2> &m) } bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, - std::vector<BDS_Point*> &result, - SBoundingBox3d &bbox, BDS_Mesh *m, - std::map<BDS_Point*, MVertex*> &recover_map_global, - int &count, int countTot, double tol, - bool seam_the_first = false) + std::vector<BDS_Point*> &result, + SBoundingBox3d &bbox, BDS_Mesh *m, + std::map<BDS_Point*, MVertex*> &recover_map_global, + int &count, int countTot, double tol, + bool seam_the_first = false) { // for each edge, we build a list of points that are the mapping of // the edge points on the face for seams, we build the list for @@ -771,7 +771,7 @@ bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, if (MYDEBUG) printf("face %d with %d edges case %d\n", gf->tag(), - (int)gf->edges().size(), seam_the_first); + (int)gf->edges().size(), seam_the_first); while (it != gel.end()){ GEdgeSigned ges = *it ; @@ -797,7 +797,7 @@ bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, if ( seam ) mesh1d_seam.push_back(ges.ge->reparamOnFace(gf, range.high(), -1)); meshes.insert(std::pair<GEntity*,std::vector<SPoint2> >(ges.ge, mesh1d)); if(seam) meshes_seam.insert(std::pair<GEntity*,std::vector<SPoint2> > - (ges.ge, mesh1d_seam)); + (ges.ge, mesh1d_seam)); // printMesh1d (ges.ge->tag(), seam, mesh1d); // if (seam)printMesh1d (ges.ge->tag(), seam, mesh1d_seam); it++; @@ -827,73 +827,73 @@ bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, if (seam){ mesh1d_seam = meshes_seam[ge]; } mesh1d_reversed.insert(mesh1d_reversed.begin(), mesh1d.rbegin(), mesh1d.rend()); if (seam) mesh1d_seam_reversed.insert(mesh1d_seam_reversed.begin(), - mesh1d_seam.rbegin(),mesh1d_seam.rend()); + mesh1d_seam.rbegin(),mesh1d_seam.rend()); if (!counter){ - counter++; - if (seam && seam_the_first){ - coords = ((*it)._sign == 1) ? mesh1d_seam : mesh1d_seam_reversed; - found = (*it); - Msg(INFO, "This test case would have failed in Previous Gmsh Version ;-)"); - } - else{ - coords = ((*it)._sign == 1) ? mesh1d : mesh1d_reversed; - found = (*it); - } - unordered.erase(it); - if (MYDEBUG) - printf("Starting with edge = %d seam %d\n", (*it).ge->tag(), seam); - break; + counter++; + if (seam && seam_the_first){ + coords = ((*it)._sign == 1) ? mesh1d_seam : mesh1d_seam_reversed; + found = (*it); + Msg(INFO, "This test case would have failed in Previous Gmsh Version ;-)"); + } + else{ + coords = ((*it)._sign == 1) ? mesh1d : mesh1d_reversed; + found = (*it); + } + unordered.erase(it); + if (MYDEBUG) + printf("Starting with edge = %d seam %d\n", (*it).ge->tag(), seam); + break; } else{ - if (MYDEBUG) - printf("Followed by edge = %d\n", (*it).ge->tag()); - SPoint2 first_coord = mesh1d[0]; - double d = -1, d_reversed = -1, d_seam = -1, d_seam_reversed = -1; - d = dist2(last_coord, first_coord); - if (MYDEBUG) - printf("%g %g dist = %12.5E\n", first_coord.x(), first_coord.y(), d); - if (d < tol){ - coords.clear(); - coords = mesh1d; - found = GEdgeSigned(1,ge); - unordered.erase(it); - goto Finalize; - } - SPoint2 first_coord_reversed = mesh1d_reversed[0]; - d_reversed = dist2(last_coord, first_coord_reversed); - if (MYDEBUG) - printf("%g %g dist_reversed = %12.5E\n", - first_coord_reversed.x(), first_coord_reversed.y(),d_reversed); - if (d_reversed < tol){ - coords.clear(); - coords = mesh1d_reversed; - found = (GEdgeSigned(-1,ge)); - unordered.erase(it); - goto Finalize; - } - if (seam){ - SPoint2 first_coord_seam = mesh1d_seam[0]; - SPoint2 first_coord_seam_reversed = mesh1d_seam_reversed[0]; - d_seam = dist2(last_coord,first_coord_seam); - if (MYDEBUG) printf("dist_seam = %12.5E\n", d_seam); - if (d_seam < tol){ - coords.clear(); - coords = mesh1d_seam; - found = (GEdgeSigned(1,ge)); - unordered.erase(it); - goto Finalize; - } - d_seam_reversed = dist2(last_coord, first_coord_seam_reversed); - if (MYDEBUG) printf("dist_seam_reversed = %12.5E\n", d_seam_reversed); - if (d_seam_reversed < tol){ - coords.clear(); - coords = mesh1d_seam_reversed; - found = GEdgeSigned(-1, ge); - unordered.erase(it); - break; - goto Finalize; - } - } + if (MYDEBUG) + printf("Followed by edge = %d\n", (*it).ge->tag()); + SPoint2 first_coord = mesh1d[0]; + double d = -1, d_reversed = -1, d_seam = -1, d_seam_reversed = -1; + d = dist2(last_coord, first_coord); + if (MYDEBUG) + printf("%g %g dist = %12.5E\n", first_coord.x(), first_coord.y(), d); + if (d < tol){ + coords.clear(); + coords = mesh1d; + found = GEdgeSigned(1,ge); + unordered.erase(it); + goto Finalize; + } + SPoint2 first_coord_reversed = mesh1d_reversed[0]; + d_reversed = dist2(last_coord, first_coord_reversed); + if (MYDEBUG) + printf("%g %g dist_reversed = %12.5E\n", + first_coord_reversed.x(), first_coord_reversed.y(),d_reversed); + if (d_reversed < tol){ + coords.clear(); + coords = mesh1d_reversed; + found = (GEdgeSigned(-1,ge)); + unordered.erase(it); + goto Finalize; + } + if (seam){ + SPoint2 first_coord_seam = mesh1d_seam[0]; + SPoint2 first_coord_seam_reversed = mesh1d_seam_reversed[0]; + d_seam = dist2(last_coord,first_coord_seam); + if (MYDEBUG) printf("dist_seam = %12.5E\n", d_seam); + if (d_seam < tol){ + coords.clear(); + coords = mesh1d_seam; + found = (GEdgeSigned(1,ge)); + unordered.erase(it); + goto Finalize; + } + d_seam_reversed = dist2(last_coord, first_coord_seam_reversed); + if (MYDEBUG) printf("dist_seam_reversed = %12.5E\n", d_seam_reversed); + if (d_seam_reversed < tol){ + coords.clear(); + coords = mesh1d_seam_reversed; + found = GEdgeSigned(-1, ge); + unordered.erase(it); + break; + goto Finalize; + } + } } ++it; } @@ -904,8 +904,8 @@ bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, // has to be taken with the other parametric coordinates (because it is // only present once in the closure of the domain). for (std::map<BDS_Point*, MVertex*>::iterator it = recover_map.begin(); - it != recover_map.end(); ++it){ - m->del_point(it->first); + it != recover_map.end(); ++it){ + m->del_point(it->first); } return false; } @@ -914,17 +914,17 @@ bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, if (found._sign == 1){ edgeLoop.push_back(found.ge->getBeginVertex()->mesh_vertices[0]); for (unsigned int i = 0; i <found.ge->mesh_vertices.size(); i++) - edgeLoop.push_back(found.ge->mesh_vertices[i]); + edgeLoop.push_back(found.ge->mesh_vertices[i]); } else{ edgeLoop.push_back(found.ge->getEndVertex()->mesh_vertices[0]); for (int i = found.ge->mesh_vertices.size() - 1; i >= 0; i--) - edgeLoop.push_back(found.ge->mesh_vertices[i]); + edgeLoop.push_back(found.ge->mesh_vertices[i]); } if(MYDEBUG) printf("edge %d size %d size %d\n", - found.ge->tag(), (int)edgeLoop.size(), (int)coords.size()); + found.ge->tag(), (int)edgeLoop.size(), (int)coords.size()); std::vector<BDS_Point*> edgeLoop_BDS; for (unsigned int i = 0; i < edgeLoop.size(); i++){ @@ -936,24 +936,24 @@ bool buildConsecutiveListOfVertices(GFace *gf, GEdgeLoop &gel, V = param.y() / m->scalingV; BDS_Point *pp = m->add_point(count + countTot, U, V, gf); if(ge->dim() == 0){ - pp->lcBGM() = BGM_MeshSize(ge, 0, 0, here->x(), here->y(), here->z()); + pp->lcBGM() = BGM_MeshSize(ge, 0, 0, here->x(), here->y(), here->z()); } else if (ge->dim() == 1){ - double u; - here->getParameter(0, u); - pp->lcBGM() = BGM_MeshSize(ge, u, 0,here->x(), here->y(), here->z()); + double u; + here->getParameter(0, u); + pp->lcBGM() = BGM_MeshSize(ge, u, 0,here->x(), here->y(), here->z()); } else - pp->lcBGM() = 1.e22; + pp->lcBGM() = 1.e22; pp->lc() = pp->lcBGM(); m->add_geom (ge->tag(), ge->dim()); BDS_GeomEntity *g = m->get_geom(ge->tag(), ge->dim()); pp->g = g; if (MYDEBUG) - printf("point %3d (%8.5f %8.5f : %8.5f %8.5f) (%2d,%2d)\n", - count, pp->u, pp->v, param.x(), param.y(), pp->g->classif_tag, - pp->g->classif_degree); + printf("point %3d (%8.5f %8.5f : %8.5f %8.5f) (%2d,%2d)\n", + count, pp->u, pp->v, param.x(), param.y(), pp->g->classif_tag, + pp->g->classif_degree); bbox += SPoint3(U, V, 0); edgeLoop_BDS.push_back(pp); recover_map[pp] = here; @@ -992,29 +992,29 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) int nbPointsTotal = 0; { for (std::list<GEdgeLoop>::iterator it = gf->edgeLoops.begin(); - it != gf->edgeLoops.end(); it++){ + it != gf->edgeLoops.end(); it++){ std::vector<BDS_Point* > edgeLoop_BDS; int nbPointsLocal; if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, - recover_map, nbPointsLocal, nbPointsTotal, - 1.e-7*LC2D)) - if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, - recover_map, nbPointsLocal, nbPointsTotal, - 1.e-7 * LC2D, true)) - if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, - recover_map, nbPointsLocal, nbPointsTotal, - 1.e-5 * LC2D)) - if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, - recover_map , nbPointsLocal, nbPointsTotal, - 1.e-5 * LC2D, true)) - if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, - recover_map , nbPointsLocal, nbPointsTotal, - 1.e-3 * LC2D)){ - gf->meshStatistics.status = GFace::FAILED; - Msg(GERROR, "The 1D Mesh seems not to be forming a closed loop"); - m->scalingU = m->scalingV = 1.0; - return false; - } + recover_map, nbPointsLocal, nbPointsTotal, + 1.e-7*LC2D)) + if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, + recover_map, nbPointsLocal, nbPointsTotal, + 1.e-7 * LC2D, true)) + if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, + recover_map, nbPointsLocal, nbPointsTotal, + 1.e-5 * LC2D)) + if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, + recover_map , nbPointsLocal, nbPointsTotal, + 1.e-5 * LC2D, true)) + if(!buildConsecutiveListOfVertices(gf, *it, edgeLoop_BDS, bbox, m, + recover_map , nbPointsLocal, nbPointsTotal, + 1.e-3 * LC2D)){ + gf->meshStatistics.status = GFace::FAILED; + Msg(GERROR, "The 1D Mesh seems not to be forming a closed loop"); + m->scalingU = m->scalingV = 1.0; + return false; + } nbPointsTotal += nbPointsLocal; edgeLoops_BDS.push_back(edgeLoop_BDS); } @@ -1029,16 +1029,16 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) for (unsigned int i = 0; i < edgeLoops_BDS.size(); i++){ std::vector<BDS_Point*> &edgeLoop_BDS = edgeLoops_BDS[i]; for (unsigned int j = 0; j < edgeLoop_BDS.size(); j++){ - BDS_Point *pp = edgeLoop_BDS[j]; - const double U = pp->u; - const double V = pp->v; - double XX = CTX.mesh.rand_factor * LC2D * (double)rand() / (double)RAND_MAX; - double YY = CTX.mesh.rand_factor * LC2D * (double)rand() / (double)RAND_MAX; - doc.points[count].where.h = U + XX; - doc.points[count].where.v = V + YY; - doc.points[count].adjacent = NULL; - doc.points[count].data = pp; - count++; + BDS_Point *pp = edgeLoop_BDS[j]; + const double U = pp->u; + const double V = pp->v; + double XX = CTX.mesh.rand_factor * LC2D * (double)rand() / (double)RAND_MAX; + double YY = CTX.mesh.rand_factor * LC2D * (double)rand() / (double)RAND_MAX; + doc.points[count].where.h = U + XX; + doc.points[count].where.v = V + YY; + doc.points[count].adjacent = NULL; + doc.points[count].data = pp; + count++; } } @@ -1096,12 +1096,12 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) std::vector<BDS_Point*> &edgeLoop_BDS = edgeLoops_BDS[i]; for (unsigned int j = 0; j < edgeLoop_BDS.size(); j++){ BDS_Edge * e = m->recover_edge(edgeLoop_BDS[j]->iD, - edgeLoop_BDS[(j + 1) % edgeLoop_BDS.size()]->iD); + edgeLoop_BDS[(j + 1) % edgeLoop_BDS.size()]->iD); if (!e){ - Msg(GERROR, "impossible to recover the edge %d %d", - edgeLoop_BDS[j]->iD, edgeLoop_BDS[(j + 1) % edgeLoop_BDS.size()]->iD); - gf->meshStatistics.status = GFace::FAILED; - return false; + Msg(GERROR, "impossible to recover the edge %d %d", + edgeLoop_BDS[j]->iD, edgeLoop_BDS[(j + 1) % edgeLoop_BDS.size()]->iD); + gf->meshStatistics.status = GFace::FAILED; + return false; } else e->g = &CLASS_E; } @@ -1118,16 +1118,16 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) while (ite != m->edges.end()){ BDS_Edge *e = *ite; if(e->g && e->numfaces () == 2){ - BDS_Point *oface[2]; - e->oppositeof(oface); - if (oface[0]->iD < 0){ - recur_tag(e->faces(1), &CLASS_F); - break; - } - else if (oface[1]->iD < 0){ - recur_tag(e->faces(0), &CLASS_F); - break; - } + BDS_Point *oface[2]; + e->oppositeof(oface); + if (oface[0]->iD < 0){ + recur_tag(e->faces(1), &CLASS_F); + break; + } + else if (oface[1]->iD < 0){ + recur_tag(e->faces(0), &CLASS_F); + break; + } } ++ite; } @@ -1139,7 +1139,7 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) while (itt != m->triangles.end()){ BDS_Face *t = *itt; if (!t->g){ - m->del_face (t); + m->del_face (t); } ++itt; } @@ -1152,12 +1152,12 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) while (ite != m->edges.end()){ BDS_Edge *e = *ite; if (e->numfaces() == 0) - m->del_edge(e); + m->del_edge(e); else{ - if (!e->g) - e->g = &CLASS_F; - if (!e->p1->g || e->p1->g->classif_degree > e->g->classif_degree)e->p1->g = e->g; - if (!e->p2->g || e->p2->g->classif_degree > e->g->classif_degree)e->p2->g = e->g; + if (!e->g) + e->g = &CLASS_F; + if (!e->p1->g || e->p1->g->classif_degree > e->g->classif_degree)e->p1->g = e->g; + if (!e->p2->g || e->p2->g->classif_degree > e->g->classif_degree)e->p2->g = e->g; } ++ite; } @@ -1187,10 +1187,10 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) } // compute mesh statistics computeMeshSizeFieldAccuracy(gf, *m, gf->meshStatistics.efficiency_index, - gf->meshStatistics.longest_edge_length, - gf->meshStatistics.smallest_edge_length, - gf->meshStatistics.nbEdge, - gf->meshStatistics.nbGoodLength); + gf->meshStatistics.longest_edge_length, + gf->meshStatistics.smallest_edge_length, + gf->meshStatistics.nbEdge, + gf->meshStatistics.nbGoodLength); gf->meshStatistics.status = GFace::DONE; } @@ -1200,9 +1200,9 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) while (itp != m->points.end()){ BDS_Point *p = *itp; if (recover_map.find(p) == recover_map.end()){ - MVertex *v = new MFaceVertex (p->X,p->Y,p->Z,gf,m->scalingU*p->u,m->scalingV*p->v); - recover_map[p] = v; - gf->mesh_vertices.push_back(v); + MVertex *v = new MFaceVertex (p->X,p->Y,p->Z,gf,m->scalingU*p->u,m->scalingV*p->v); + recover_map[p] = v; + gf->mesh_vertices.push_back(v); } ++itp; } @@ -1213,22 +1213,22 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) while (itt != m->triangles.end()){ BDS_Face *t = *itt; if (!t->deleted){ - BDS_Point *n[4]; - t->getNodes(n); - MVertex *v1 = recover_map[n[0]]; - MVertex *v2 = recover_map[n[1]]; - MVertex *v3 = recover_map[n[2]]; - if (!n[3]){ - // when a singular point is present, degenerated triangles - // may be created, for example on a sphere that contains one - // pole - if (v1 != v2 && v1 != v3 && v2 != v3) - gf->triangles.push_back(new MTriangle(v1, v2, v3)); - } - else{ - MVertex *v4 = recover_map[n[3]]; - gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); - } + BDS_Point *n[4]; + t->getNodes(n); + MVertex *v1 = recover_map[n[0]]; + MVertex *v2 = recover_map[n[1]]; + MVertex *v3 = recover_map[n[2]]; + if (!n[3]){ + // when a singular point is present, degenerated triangles + // may be created, for example on a sphere that contains one + // pole + if (v1 != v2 && v1 != v3 && v2 != v3) + gf->triangles.push_back(new MTriangle(v1, v2, v3)); + } + else{ + MVertex *v4 = recover_map[n[3]]; + gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); + } } ++itt; } @@ -1251,10 +1251,10 @@ bool gmsh2DMeshGeneratorPeriodic(GFace *gf, bool debug = true) delete m; computeElementShapes(gf, gf->meshStatistics.worst_element_shape, - gf->meshStatistics.average_element_shape, - gf->meshStatistics.best_element_shape, - gf->meshStatistics.nbTriangle, - gf->meshStatistics.nbGoodQuality); + gf->meshStatistics.average_element_shape, + gf->meshStatistics.best_element_shape, + gf->meshStatistics.nbTriangle, + gf->meshStatistics.nbGoodQuality); return true; } @@ -1342,12 +1342,12 @@ bool shouldRevert(MEdge &reference, std::vector<T*> &elements) for(int j = 0; j < elements[i]->getNumEdges(); j++){ MEdge e = elements[i]->getEdge(j); if(e.getVertex(0) == reference.getVertex(0) && - e.getVertex(1) == reference.getVertex(1)){ - return false; + e.getVertex(1) == reference.getVertex(1)){ + return false; } else if(e.getVertex(1) == reference.getVertex(0) && - e.getVertex(0) == reference.getVertex(1)){ - return true; + e.getVertex(0) == reference.getVertex(1)){ + return true; } } } diff --git a/Mesh/meshGFace.h b/Mesh/meshGFace.h index fabc824f569ea895e87800d6313daf705721c080..7edc8816c8e5d9460a58afa480f6e0e09c6f9ffe 100644 --- a/Mesh/meshGFace.h +++ b/Mesh/meshGFace.h @@ -52,12 +52,12 @@ class orientMeshGFace { // Compute edge loops of the face, all_mvertices are the vertices of // the void computeEdgeLoops(const GFace *gf, - std::vector<MVertex*> &all_mvertices, - std::vector<int> &indices); + std::vector<MVertex*> &all_mvertices, + std::vector<int> &indices); int MeshTransfiniteSurface(GFace *gf); int MeshExtrudedSurface(GFace *gf, - std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges=0); + std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges=0); void fourthPoint (double *p1, double *p2, double *p3, double *p4); #endif diff --git a/Mesh/meshGFaceBDS.cpp b/Mesh/meshGFaceBDS.cpp index 6695c2e635d22b70960326f936240a0f64a8ab94..18e216bb89322a16d4f97a4477039ac61d8b52b8 100644 --- a/Mesh/meshGFaceBDS.cpp +++ b/Mesh/meshGFaceBDS.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFaceBDS.cpp,v 1.9 2008-03-01 01:32:03 geuzaine Exp $ +// $Id: meshGFaceBDS.cpp,v 1.10 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -49,10 +49,10 @@ inline double computeEdgeLinearLength(BDS_Point *p1, BDS_Point *p2) } inline double computeEdgeLinearLength(BDS_Point *p1, BDS_Point *p2, GFace *f, - double SCALINGU, double SCALINGV) + double SCALINGU, double SCALINGV) { GPoint GP = f->point(SPoint2(0.5 * (p1->u + p2->u) * SCALINGU, - 0.5 * (p1->v + p2->v) * SCALINGV)); + 0.5 * (p1->v + p2->v) * SCALINGV)); const double dx1 = p1->X - GP.x(); const double dy1 = p1->Y - GP.y(); @@ -66,13 +66,13 @@ inline double computeEdgeLinearLength(BDS_Point *p1, BDS_Point *p2, GFace *f, } inline double computeEdgeMiddleCoord(BDS_Point *p1, BDS_Point *p2, GFace *f, - double SCALINGU, double SCALINGV) + double SCALINGU, double SCALINGV) { if (f->geomType() == GEntity::Plane) return 0.5; GPoint GP = f->point (SPoint2(0.5 * (p1->u + p2->u) * SCALINGU, - 0.5 * (p1->v + p2->v) * SCALINGV)); + 0.5 * (p1->v + p2->v) * SCALINGV)); const double dx1 = p1->X - GP.x(); const double dy1 = p1->Y - GP.y(); @@ -90,7 +90,7 @@ inline double computeEdgeMiddleCoord(BDS_Point *p1, BDS_Point *p2, GFace *f, } inline double computeEdgeLinearLength(BDS_Edge *e, GFace *f, - double SCALINGU, double SCALINGV) + double SCALINGU, double SCALINGV) { if (f->geomType() == GEntity::Plane) return e->length(); @@ -120,7 +120,7 @@ double NewGetLc(BDS_Point *p1,BDS_Point *p2, GFace *f, double su, double sv) } void computeMeshSizeFieldAccuracy(GFace *gf, BDS_Mesh &m, double &avg, - double &max_e, double &min_e, int &nE, int &GS) + double &max_e, double &min_e, int &nE, int &GS) { std::list<BDS_Edge*>::iterator it = m.edges.begin(); avg=0; @@ -144,7 +144,7 @@ void computeMeshSizeFieldAccuracy(GFace *gf, BDS_Mesh &m, double &avg, } void computeElementShapes(GFace *gf, BDS_Mesh &m, double &worst, double &avg, - double &best, int &nT, int &nbGQ) + double &best, int &nT, int &nbGQ) { std::list<BDS_Face*>::iterator it = m.triangles.begin(); worst = 1.e22; @@ -290,8 +290,8 @@ bool edgeSwapTestDelaunayAniso(BDS_Edge *e, GFace *gf, std::set<swapquad> &confi configs.insert(sq); double edgeCenter[2] ={0.5 * (e->p1->u + e->p2->u), - 0.5 * (e->p1->v + e->p2->v)}; - + 0.5 * (e->p1->v + e->p2->v)}; + double p1[2] ={e->p1->u, e->p1->v}; double p2[2] ={e->p2->u, e->p2->v}; double p3[2] ={op[0]->u, op[0]->v}; @@ -359,9 +359,9 @@ void swapEdgePass(GFace *gf, BDS_Mesh &m, int &nb_swap) const double qual = CTX.mesh.algo2d == ALGO_2D_MESHADAPT ? 1 : 5; int result = edgeSwapTestQuality(*it,qual); if (CTX.mesh.algo2d == ALGO_2D_MESHADAPT ) - { if (m.swap_edge(*it, BDS_SwapEdgeTestQuality(true)))nb_swap++; } + { if (m.swap_edge(*it, BDS_SwapEdgeTestQuality(true)))nb_swap++; } else if ( result >= 0 && edgeSwapTestDelaunay(*it,gf)) - { if (m.swap_edge(*it, BDS_SwapEdgeTestQuality(false))) nb_swap++; } + { if (m.swap_edge(*it, BDS_SwapEdgeTestQuality(false))) nb_swap++; } } ++it; } @@ -379,11 +379,11 @@ void gmshDelaunayizeBDS(GFace *gf, BDS_Mesh &m, int &nb_swap) while (1){ if (NN2++ >= NN1)break; if (!(*it)->deleted){ - if (edgeSwapTestDelaunayAniso(*it, gf, configs)){ - if (m.swap_edge(*it , BDS_SwapEdgeTestQuality(false))){ - NSW++; - } - } + if (edgeSwapTestDelaunayAniso(*it, gf, configs)){ + if (m.swap_edge(*it , BDS_SwapEdgeTestQuality(false))){ + NSW++; + } + } } ++it; } @@ -402,21 +402,21 @@ void splitEdgePassUnsorted(GFace *gf, BDS_Mesh &m, double MAXE_, int &nb_split) if (!(*it)->deleted){ double lone = NewGetLc(*it, gf, m.scalingU, m.scalingV); if ((*it)->numfaces() == 2 && (lone > MAXE_)){ - //const double coord = 0.5; - const double coord = computeEdgeMiddleCoord((*it)->p1, (*it)->p2, gf, - m.scalingU, m.scalingV); - BDS_Point *mid; - mid = m.add_point(++m.MAXPOINTNUMBER, - coord * (*it)->p1->u + (1 - coord) * (*it)->p2->u, - coord * (*it)->p1->v + (1 - coord) * (*it)->p2->v, gf); - mid->lcBGM() = BGM_MeshSize - (gf, - (coord * (*it)->p1->u + (1 - coord) * (*it)->p2->u)*m.scalingU, - (coord * (*it)->p1->v + (1 - coord) * (*it)->p2->v)*m.scalingV, - mid->X,mid->Y,mid->Z); - mid->lc() = 0.5 * ((*it)->p1->lc() + (*it)->p2->lc()); - if(!m.split_edge(*it, mid)) m.del_point(mid); - else nb_split++; + //const double coord = 0.5; + const double coord = computeEdgeMiddleCoord((*it)->p1, (*it)->p2, gf, + m.scalingU, m.scalingV); + BDS_Point *mid; + mid = m.add_point(++m.MAXPOINTNUMBER, + coord * (*it)->p1->u + (1 - coord) * (*it)->p2->u, + coord * (*it)->p1->v + (1 - coord) * (*it)->p2->v, gf); + mid->lcBGM() = BGM_MeshSize + (gf, + (coord * (*it)->p1->u + (1 - coord) * (*it)->p2->u)*m.scalingU, + (coord * (*it)->p1->v + (1 - coord) * (*it)->p2->v)*m.scalingV, + mid->X,mid->Y,mid->Z); + mid->lc() = 0.5 * ((*it)->p1->lc() + (*it)->p2->lc()); + if(!m.split_edge(*it, mid)) m.del_point(mid); + else nb_split++; } } ++it; @@ -432,7 +432,7 @@ void splitEdgePass(GFace *gf, BDS_Mesh &m, double MAXE_, int &nb_split) if(!(*it)->deleted && (*it)->numfaces() == 2){ double lone = NewGetLc(*it, gf, m.scalingU, m.scalingV); if(lone > MAXE_){ - edges.push_back(std::make_pair(-lone, *it)); + edges.push_back(std::make_pair(-lone, *it)); } } ++it; @@ -446,13 +446,13 @@ void splitEdgePass(GFace *gf, BDS_Mesh &m, double MAXE_, int &nb_split) const double coord = 0.5; BDS_Point *mid ; mid = m.add_point(++m.MAXPOINTNUMBER, - coord * e->p1->u + (1 - coord) * e->p2->u, - coord * e->p1->v + (1 - coord) * e->p2->v,gf); + coord * e->p1->u + (1 - coord) * e->p2->u, + coord * e->p1->v + (1 - coord) * e->p2->v,gf); mid->lcBGM() = BGM_MeshSize - (gf, - (coord * e->p1->u + (1 - coord) * e->p2->u)*m.scalingU, - (coord * e->p1->v + (1 - coord) * e->p2->v)*m.scalingV, - mid->X,mid->Y,mid->Z); + (gf, + (coord * e->p1->u + (1 - coord) * e->p2->u)*m.scalingU, + (coord * e->p1->v + (1 - coord) * e->p2->v)*m.scalingV, + mid->X,mid->Y,mid->Z); mid->lc() = 0.5 * (e->p1->lc() + e->p2->lc()); if(!m.split_edge(e, mid)) m.del_point(mid); else nb_split++; @@ -469,7 +469,7 @@ void collapseEdgePass(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP, int &nb_c if(!(*it)->deleted && (*it)->numfaces() == 2){ double lone = NewGetLc(*it, gf,m.scalingU,m.scalingV); if(lone < MINE_){ - edges.push_back (std::make_pair(lone, *it)); + edges.push_back (std::make_pair(lone, *it)); } } ++it; @@ -482,17 +482,17 @@ void collapseEdgePass(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP, int &nb_c if(!e->deleted){ bool res = false; if(e->p1->iD > MAXNP) - res = m.collapse_edge_parametric(e, e->p1); + res = m.collapse_edge_parametric(e, e->p1); else if(e->p2->iD > MAXNP) - res = m.collapse_edge_parametric(e, e->p2); + res = m.collapse_edge_parametric(e, e->p2); if(res) - nb_collaps++; + nb_collaps++; } } } void collapseEdgePassUnSorted(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP, - int &nb_collaps) + int &nb_collaps) { int NN1 = m.edges.size(); int NN2 = 0; @@ -504,13 +504,13 @@ void collapseEdgePassUnSorted(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP, if(!(*it)->deleted){ double lone = NewGetLc(*it, gf, m.scalingU, m.scalingV); if(!(*it)->deleted && (*it)->numfaces() == 2 && lone < MINE_){ - bool res = false; - if((*it)->p1->iD > MAXNP) - res = m.collapse_edge_parametric(*it, (*it)->p1); - else if((*it)->p2->iD > MAXNP) - res = m.collapse_edge_parametric(*it, (*it)->p2); - if(res) - nb_collaps++; + bool res = false; + if((*it)->p1->iD > MAXNP) + res = m.collapse_edge_parametric(*it, (*it)->p1); + else if((*it)->p2->iD > MAXNP) + res = m.collapse_edge_parametric(*it, (*it)->p2); + if(res) + nb_collaps++; } } ++it; @@ -528,7 +528,7 @@ void smoothVertexPass(GFace *gf, BDS_Mesh &m, int &nb_smooth, bool q) } void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, - const bool computeNodalSizeField) + const bool computeNodalSizeField) { int IT = 0; @@ -543,16 +543,16 @@ void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, double L = 0; int ne = 0; while(it != ite){ - double l = (*it)->length(); - if ((*it)->g && (*it)->g->classif_degree == 1){ - L = ne ? std::max(L, l) : l; - ne++; - } - ++it; + double l = (*it)->length(); + if ((*it)->g && (*it)->g->classif_degree == 1){ + L = ne ? std::max(L, l) : l; + ne++; + } + ++it; } if (!ne) L = 1.e22; if(!CTX.mesh.constrained_bgmesh) - (*itp)->lc() = L; + (*itp)->lc() = L; (*itp)->lcBGM() = L; ++itp; } @@ -577,11 +577,11 @@ void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, while (1){ if (NN2++ >= NN1)break; if (!(*it)->deleted){ - (*it)->p1->config_modified = false; - (*it)->p2->config_modified = false; - double lone = NewGetLc(*it, gf, m.scalingU, m.scalingV); - maxL = std::max(maxL, lone); - minL = std::min(minL, lone); + (*it)->p1->config_modified = false; + (*it)->p2->config_modified = false; + double lone = NewGetLc(*it, gf, m.scalingU, m.scalingV); + maxL = std::max(maxL, lone); + minL = std::min(minL, lone); } ++it; } @@ -609,11 +609,11 @@ void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, t_sw += t7 - t6; t_col += t4 - t3; t_sm += t6 - t5; - m.cleanup(); + m.cleanup(); IT++; Msg(DEBUG1, " iter %3d minL %8.3f/%8.3f maxL %8.3f/%8.3f : " - "%6d splits, %6d swaps, %6d collapses, %6d moves", - IT, minL, minE, maxL, maxE, nb_split, nb_swap, nb_collaps, nb_smooth); + "%6d splits, %6d swaps, %6d collapses, %6d moves", + IT, minL, minE, maxL, maxE, nb_split, nb_swap, nb_collaps, nb_smooth); if (nb_split == 0 && nb_collaps == 0) break; } @@ -636,7 +636,7 @@ void allowAppearanceofEdge (BDS_Point *p1, BDS_Point *p2) } void invalidEdgesPeriodic(BDS_Mesh &m, std::map<BDS_Point*,MVertex*> *recover_map, - std::set<BDS_Edge*> &toSplit) + std::set<BDS_Edge*> &toSplit) { // first look for degenerated vertices std::list<BDS_Edge*>::iterator it = m.edges.begin(); @@ -647,9 +647,9 @@ void invalidEdgesPeriodic(BDS_Mesh &m, std::map<BDS_Point*,MVertex*> *recover_ma std::map<BDS_Point*,MVertex*>::iterator itp1 = recover_map->find(e->p1); std::map<BDS_Point*,MVertex*>::iterator itp2 = recover_map->find(e->p2); if (itp1 != recover_map->end() && - itp2 != recover_map->end() && - itp1->second == itp2->second){ - degenerated.insert(itp1->second); + itp2 != recover_map->end() && + itp1->second == itp2->second){ + degenerated.insert(itp1->second); } } ++it; @@ -664,25 +664,25 @@ void invalidEdgesPeriodic(BDS_Mesh &m, std::map<BDS_Point*,MVertex*> *recover_ma std::map<BDS_Point*,MVertex*>::iterator itp1 = recover_map->find(e->p1); std::map<BDS_Point*,MVertex*>::iterator itp2 = recover_map->find(e->p2); if (itp1 != recover_map->end() && - itp2 != recover_map->end() && - itp1->second == itp2->second) toSplit.insert(e); + itp2 != recover_map->end() && + itp1->second == itp2->second) toSplit.insert(e); else if (itp1 != recover_map->end() && itp2 == recover_map->end()){ - std::pair<MVertex*,BDS_Point*> a ( itp1->second, e->p2 ); - std::map<std::pair<MVertex*, BDS_Point*>, BDS_Edge*>::iterator itf = - touchPeriodic.find(a); - if (itf == touchPeriodic.end()) touchPeriodic[a] = e; - else if (degenerated.find(itp1->second) == degenerated.end()){ - toSplit.insert(e); toSplit.insert(itf->second); - } + std::pair<MVertex*,BDS_Point*> a ( itp1->second, e->p2 ); + std::map<std::pair<MVertex*, BDS_Point*>, BDS_Edge*>::iterator itf = + touchPeriodic.find(a); + if (itf == touchPeriodic.end()) touchPeriodic[a] = e; + else if (degenerated.find(itp1->second) == degenerated.end()){ + toSplit.insert(e); toSplit.insert(itf->second); + } } else if (itp1 == recover_map->end() && itp2 != recover_map->end()){ - std::pair<MVertex*,BDS_Point*> a(itp2->second, e->p1); - std::map<std::pair<MVertex*, BDS_Point*>, BDS_Edge*>::iterator itf = - touchPeriodic.find (a); - if (itf == touchPeriodic.end()) touchPeriodic[a] = e; - else if (degenerated.find(itp2->second) == degenerated.end()){ - toSplit.insert(e); toSplit.insert(itf->second); - } + std::pair<MVertex*,BDS_Point*> a(itp2->second, e->p1); + std::map<std::pair<MVertex*, BDS_Point*>, BDS_Edge*>::iterator itf = + touchPeriodic.find (a); + if (itf == touchPeriodic.end()) touchPeriodic[a] = e; + else if (degenerated.find(itp2->second) == degenerated.end()){ + toSplit.insert(e); toSplit.insert(itf->second); + } } } ++it; @@ -697,7 +697,7 @@ void invalidEdgesPeriodic(BDS_Mesh &m, std::map<BDS_Point*,MVertex*> *recover_ma // if p1 p2 exists and it is internal, split it int gmshSolveInvalidPeriodic(GFace *gf, BDS_Mesh &m, - std::map<BDS_Point*,MVertex*> *recover_map) + std::map<BDS_Point*,MVertex*> *recover_map) { std::set<BDS_Edge*> toSplit; invalidEdgesPeriodic(m, recover_map, toSplit); @@ -709,12 +709,12 @@ int gmshSolveInvalidPeriodic(GFace *gf, BDS_Mesh &m, const double coord = 0.5; BDS_Point *mid ; mid = m.add_point(++m.MAXPOINTNUMBER, - coord * e->p1->u + (1 - coord) * e->p2->u, - coord * e->p1->v + (1 - coord) * e->p2->v, gf); + coord * e->p1->u + (1 - coord) * e->p2->u, + coord * e->p1->v + (1 - coord) * e->p2->v, gf); mid->lcBGM() = BGM_MeshSize(gf, - (coord * e->p1->u + (1 - coord) * e->p2->u) * m.scalingU, - (coord * e->p1->v + (1 - coord) * e->p2->v) * m.scalingV, - mid->X, mid->Y, mid->Z); + (coord * e->p1->u + (1 - coord) * e->p2->u) * m.scalingU, + (coord * e->p1->v + (1 - coord) * e->p2->v) * m.scalingV, + mid->X, mid->Y, mid->Z); mid->lc() = 0.5 * (e->p1->lc() + e->p2->lc()); if(!m.split_edge(e, mid)) m.del_point(mid); } @@ -726,7 +726,7 @@ int gmshSolveInvalidPeriodic(GFace *gf, BDS_Mesh &m, } void gmshOptimizeMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, - std::map<BDS_Point*,MVertex*> *recover_map=0) + std::map<BDS_Point*,MVertex*> *recover_map=0) { int nb_swap; gmshDelaunayizeBDS(gf, m, nb_swap); @@ -738,10 +738,10 @@ void gmshOptimizeMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, int NN2 = 0; std::list<BDS_Edge*>::iterator it = m.edges.begin(); while (1){ - if (NN2++ >= NN1)break; - if (evalSwapForOptimize(*it, gf, m)) - m.swap_edge(*it, BDS_SwapEdgeTestQuality(false)); - ++it; + if (NN2++ >= NN1)break; + if (evalSwapForOptimize(*it, gf, m)) + m.swap_edge(*it, BDS_SwapEdgeTestQuality(false)); + ++it; } m.cleanup(); int nb_smooth; @@ -777,20 +777,20 @@ BDS_Mesh *gmsh2BDS(std::list<GFace*> &l) MTriangle *e = gf->triangles[i]; BDS_Point *p[3]; for (int j = 0; j < 3; j++){ - p[j] = m->find_point(e->getVertex(j)->getNum()); - if (!p[j]) { - p[j] = m->add_point(e->getVertex(j)->getNum(), e->getVertex(j)->x(), - e->getVertex(j)->y(), e->getVertex(j)->z()); - double u0, v0; - parametricCoordinates(e->getVertex(j), gf, u0, v0); - p[j]->u = u0; - p[j]->v = v0; - m->add_geom(e->getVertex(j)->onWhat()->tag(), - e->getVertex(j)->onWhat()->dim()); - BDS_GeomEntity *g = m->get_geom(e->getVertex(j)->onWhat()->tag(), - e->getVertex(j)->onWhat()->dim()); - p[j]->g = g; - } + p[j] = m->find_point(e->getVertex(j)->getNum()); + if (!p[j]) { + p[j] = m->add_point(e->getVertex(j)->getNum(), e->getVertex(j)->x(), + e->getVertex(j)->y(), e->getVertex(j)->z()); + double u0, v0; + parametricCoordinates(e->getVertex(j), gf, u0, v0); + p[j]->u = u0; + p[j]->v = v0; + m->add_geom(e->getVertex(j)->onWhat()->tag(), + e->getVertex(j)->onWhat()->dim()); + BDS_GeomEntity *g = m->get_geom(e->getVertex(j)->onWhat()->tag(), + e->getVertex(j)->onWhat()->dim()); + p[j]->g = g; + } } BDS_Face *f = m->add_triangle(p[0]->iD, p[1]->iD, p[2]->iD); f->g = g2; diff --git a/Mesh/meshGFaceBDS.h b/Mesh/meshGFaceBDS.h index b03655d77bf019d03ba75104972bcf13e47d3f38..342f324faa0c873f6a07a3bd1803c5a47e70e320 100644 --- a/Mesh/meshGFaceBDS.h +++ b/Mesh/meshGFaceBDS.h @@ -28,13 +28,13 @@ class BDS_Point; class MVertex; void computeMeshSizeFieldAccuracy(GFace *gf, BDS_Mesh &m, double &avg, - double &max_e, double &min_e, int &nE, int &GS); + double &max_e, double &min_e, int &nE, int &GS); void computeElementShapes(GFace *gf, BDS_Mesh &m, double &worst, double &avg, - double &best, int &nT, int &nbGQ); + double &best, int &nT, int &nbGQ); void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, - const bool computeNodalSizeField); + const bool computeNodalSizeField); void gmshOptimizeMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT, - std::map<BDS_Point*,MVertex*> *recover_map=0); + std::map<BDS_Point*,MVertex*> *recover_map=0); void gmshDelaunayizeBDS(GFace *gf, BDS_Mesh &m, int &nb_swap); void gmshCollapseSmallEdges(GModel &gm); diff --git a/Mesh/meshGFaceDelaunayInsertion.cpp b/Mesh/meshGFaceDelaunayInsertion.cpp index a9297656cbfdb79bc241b7e3f3089ecc5a1528f6..0ec2b63f1220df463c7ec177e00426b625a3a42a 100644 --- a/Mesh/meshGFaceDelaunayInsertion.cpp +++ b/Mesh/meshGFaceDelaunayInsertion.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFaceDelaunayInsertion.cpp,v 1.14 2008-03-18 19:30:14 geuzaine Exp $ +// $Id: meshGFaceDelaunayInsertion.cpp,v 1.15 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -73,7 +73,7 @@ void circumCenterXYZ(double *p1, double *p2, double *p3, double *res, double *uv if(uv){ double mat[2][2] = {{p2P[0] - p1P[0], p3P[0] - p1P[0]}, - {p2P[1] - p1P[1], p3P[1] - p1P[1]}}; + {p2P[1] - p1P[1], p3P[1] - p1P[1]}}; double rhs[2] = {resP[0] - p1P[0], resP[1] - p1P[1]}; sys2x2(mat, rhs, uv); } @@ -84,9 +84,9 @@ void circumCenterXYZ(double *p1, double *p2, double *p3, double *res, double *uv } bool circumCenterMetricInTriangle(MTriangle *base, - const double *metric, - const std::vector<double> &Us, - const std::vector<double> &Vs) + const double *metric, + const std::vector<double> &Us, + const std::vector<double> &Vs) { double R, x[2], uv[2]; circumCenterMetric(base, metric, Us, Vs, x, R); @@ -94,8 +94,8 @@ bool circumCenterMetricInTriangle(MTriangle *base, } void circumCenterMetric(double *pa, double *pb, double *pc, - const double *metric, - double *x, double &Radius2) + const double *metric, + double *x, double &Radius2) { // d = (u2-u1) M (u2-u1) = u2 M u2 + u1 M u1 - 2 u2 M u1 double sys[2][2]; @@ -128,18 +128,18 @@ void circumCenterMetric(double *pa, double *pb, double *pc, } void circumCenterMetric(MTriangle *base, - const double *metric, - const std::vector<double> &Us, - const std::vector<double> &Vs, - double *x, double &Radius2) + const double *metric, + const std::vector<double> &Us, + const std::vector<double> &Vs, + double *x, double &Radius2) { // d = (u2-u1) M (u2-u1) = u2 M u2 + u1 M u1 - 2 u2 M u1 double pa[2] = {Us[base->getVertex(0)->getNum()], - Vs[base->getVertex(0)->getNum()]}; + Vs[base->getVertex(0)->getNum()]}; double pb[2] = {Us[base->getVertex(1)->getNum()], - Vs[base->getVertex(1)->getNum()]}; + Vs[base->getVertex(1)->getNum()]}; double pc[2] = {Us[base->getVertex(2)->getNum()], - Vs[base->getVertex(2)->getNum()]}; + Vs[base->getVertex(2)->getNum()]}; circumCenterMetric(pa, pb, pc, metric, x, Radius2); } @@ -152,7 +152,7 @@ void buildMetric(GFace *gf, double *uv, double *metric) } int inCircumCircleAniso(GFace *gf, double *p1, double *p2, double *p3, - double *uv, double *metric) + double *uv, double *metric) { double x[2], Radius2; circumCenterMetric(p1, p2, p3, metric, x, Radius2); @@ -166,15 +166,15 @@ int inCircumCircleAniso(GFace *gf, double *p1, double *p2, double *p3, } int inCircumCircleAniso(GFace *gf, MTriangle *base, - const double *uv, const double *metricb, - const std::vector<double> &Us, - const std::vector<double> &Vs) + const double *uv, const double *metricb, + const std::vector<double> &Us, + const std::vector<double> &Vs) { double x[2], Radius2, metric[3]; double pa[2] = {(Us[base->getVertex(0)->getNum()] + Us[base->getVertex(1)->getNum()] + - Us[base->getVertex(2)->getNum()]) / 3., - (Vs[base->getVertex(0)->getNum()] + Vs[base->getVertex(1)->getNum()] + - Vs[base->getVertex(2)->getNum()]) / 3.}; + Us[base->getVertex(2)->getNum()]) / 3., + (Vs[base->getVertex(0)->getNum()] + Vs[base->getVertex(1)->getNum()] + + Vs[base->getVertex(2)->getNum()]) / 3.}; buildMetric(gf, pa, metric); circumCenterMetric(base, metric, Us, Vs, x, Radius2); @@ -222,15 +222,15 @@ int MTri3::inCircumCircle(const double *p) const } int inCircumCircle(MTriangle *base, - const double *p, const double *param , - std::vector<double> &Us, std::vector<double> &Vs) + const double *p, const double *param , + std::vector<double> &Us, std::vector<double> &Vs) { double pa[2] = {Us[base->getVertex(0)->getNum()], - Vs[base->getVertex(0)->getNum()]}; + Vs[base->getVertex(0)->getNum()]}; double pb[2] = {Us[base->getVertex(1)->getNum()], - Vs[base->getVertex(1)->getNum()]}; + Vs[base->getVertex(1)->getNum()]}; double pc[2] = {Us[base->getVertex(2)->getNum()], - Vs[base->getVertex(2)->getNum()]}; + Vs[base->getVertex(2)->getNum()]}; double result = gmsh::incircle(pa, pb, pc, (double*)param) * gmsh::orient2d(pa, pb, pc); return (result > 0) ? 1 : 0; @@ -243,14 +243,14 @@ void connectTris(ITER beg, ITER end) while (beg != end){ if (!(*beg)->isDeleted()){ for (int i = 0; i < 3; i++){ - edgeXface fxt(*beg, i); - std::set<edgeXface>::iterator found = conn.find(fxt); - if (found == conn.end()) - conn.insert(fxt); - else if (found->t1 != *beg){ - found->t1->setNeigh(found->i1, *beg); - (*beg)->setNeigh(i, found->t1); - } + edgeXface fxt(*beg, i); + std::set<edgeXface>::iterator found = conn.find(fxt); + if (found == conn.end()) + conn.insert(fxt); + else if (found->t1 != *beg){ + found->t1->setNeigh(found->i1, *beg); + (*beg)->setNeigh(i, found->t1); + } } } ++beg; @@ -273,8 +273,8 @@ void connectTriangles(std::set<MTri3*, compareTri3Ptr> &l) } void recurFindCavity(std::list<edgeXface> &shell, std::list<MTri3*> &cavity, - double *v, double *param, MTri3 *t, - std::vector<double> &Us, std::vector<double> &Vs) + double *v, double *param, MTri3 *t, + std::vector<double> &Us, std::vector<double> &Vs) { t->setDeleted(true); // the cavity that has to be removed @@ -288,17 +288,17 @@ void recurFindCavity(std::list<edgeXface> &shell, std::list<MTri3*> &cavity, else if (!neigh->isDeleted()){ int circ = inCircumCircle(neigh->tri(), v , param, Us, Vs); if (circ) - recurFindCavity(shell, cavity, v, param, neigh, Us, Vs); + recurFindCavity(shell, cavity, v, param, neigh, Us, Vs); else - shell.push_back(edgeXface(t, i)); + shell.push_back(edgeXface(t, i)); } } } void recurFindCavityAniso (GFace *gf, - std::list<edgeXface> &shell, std::list<MTri3*> &cavity, - double *metric, double *param, MTri3 *t, - std::vector<double> &Us, std::vector<double> &Vs) + std::list<edgeXface> &shell, std::list<MTri3*> &cavity, + double *metric, double *param, MTri3 *t, + std::vector<double> &Us, std::vector<double> &Vs) { t->setDeleted(true); // the cavity that has to be removed @@ -312,15 +312,15 @@ void recurFindCavityAniso (GFace *gf, else if (!neigh->isDeleted()){ int circ = inCircumCircleAniso(gf, neigh->tri(), param, metric, Us, Vs); if (circ) - recurFindCavityAniso(gf, shell, cavity,metric, param, neigh, Us, Vs); + recurFindCavityAniso(gf, shell, cavity,metric, param, neigh, Us, Vs); else - shell.push_back(edgeXface(t, i)); + shell.push_back(edgeXface(t, i)); } } } bool circUV(MTriangle *t, std::vector<double> & Us, std::vector<double> &Vs, - double *res, GFace *gf) + double *res, GFace *gf) { double u1 [3] = {Us[t->getVertex(0)->getNum()], Vs[t->getVertex(0)->getNum()], 0}; double u2 [3] = {Us[t->getVertex(1)->getNum()], Vs[t->getVertex(1)->getNum()], 0}; @@ -336,8 +336,8 @@ bool circUV(MTriangle *t, std::vector<double> & Us, std::vector<double> &Vs, } bool invMapUV(MTriangle *t, double *p, - const std::vector<double> &Us, const std::vector<double> &Vs, - double *uv, double tol) + const std::vector<double> &Us, const std::vector<double> &Vs, + double *uv, double tol) { double mat[2][2]; double b[2]; @@ -383,10 +383,10 @@ double getSurfUV(MTriangle *t, std::vector<double> &Us, std::vector<double> &Vs) } bool insertVertex(GFace *gf, MVertex *v, double *param , MTri3 *t, - std::set<MTri3*, compareTri3Ptr> &allTets, - std::vector<double> &vSizes, std::vector<double> &vSizesBGM, - std::vector<double> &Us, std::vector<double> &Vs, - double *metric = 0) + std::set<MTri3*, compareTri3Ptr> &allTets, + std::vector<double> &vSizes, std::vector<double> &vSizesBGM, + std::vector<double> &Us, std::vector<double> &Vs, + double *metric = 0) { std::list<edgeXface> shell; std::list<MTri3*> cavity; @@ -418,11 +418,11 @@ bool insertVertex(GFace *gf, MVertex *v, double *param , MTri3 *t, while (it != shell.end()){ MTriangle *t = new MTriangle(it->v[0], it->v[1], v); double lc = 0.3333333333 * (vSizes[t->getVertex(0)->getNum()] + - vSizes[t->getVertex(1)->getNum()] + - vSizes[t->getVertex(2)->getNum()]); + vSizes[t->getVertex(1)->getNum()] + + vSizes[t->getVertex(2)->getNum()]); double lcBGM = 0.3333333333 * (vSizesBGM[t->getVertex(0)->getNum()] + - vSizesBGM[t->getVertex(1)->getNum()] + - vSizesBGM[t->getVertex(2)->getNum()]); + vSizesBGM[t->getVertex(1)->getNum()] + + vSizesBGM[t->getVertex(2)->getNum()]); MTri3 *t4 = new MTri3(t, Extend1dMeshIn2dSurfaces() ? std::min(lc, lcBGM) : lcBGM); newTris[k++] = t4; // all new triangles are pushed front in order to @@ -458,7 +458,7 @@ bool insertVertex(GFace *gf, MVertex *v, double *param , MTri3 *t, } void _printTris(char *name, std::set<MTri3*, compareTri3Ptr> &AllTris, - std::vector<double> &Us, std::vector<double> &Vs) + std::vector<double> &Us, std::vector<double> &Vs) { FILE *ff = fopen (name,"w"); fprintf(ff,"View\"test\"{\n"); @@ -467,15 +467,15 @@ void _printTris(char *name, std::set<MTri3*, compareTri3Ptr> &AllTris, MTri3 *worst = *it; if (!worst->isDeleted()){ fprintf(ff,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g) {0,0,0};\n", - Us [(worst)->tri()->getVertex(0)->getNum()], - Vs [(worst)->tri()->getVertex(0)->getNum()], - 0.0, - Us [(worst)->tri()->getVertex(1)->getNum()], - Vs [(worst)->tri()->getVertex(1)->getNum()], - 0.0, - Us [(worst)->tri()->getVertex(2)->getNum()], - Vs [(worst)->tri()->getVertex(2)->getNum()], - 0.0); + Us [(worst)->tri()->getVertex(0)->getNum()], + Vs [(worst)->tri()->getVertex(0)->getNum()], + 0.0, + Us [(worst)->tri()->getVertex(1)->getNum()], + Vs [(worst)->tri()->getVertex(1)->getNum()], + 0.0, + Us [(worst)->tri()->getVertex(2)->getNum()], + Vs [(worst)->tri()->getVertex(2)->getNum()], + 0.0); } ++it; } @@ -505,69 +505,69 @@ void insertVerticesInFace(GFace *gf, BDS_Mesh *bds) } else{ if(ITER++ % 5000 == 0) - Msg(DEBUG,"%7d points created -- Worst tri radius is %8.3f", - vSizes.size(), worst->getRadius()); + Msg(DEBUG,"%7d points created -- Worst tri radius is %8.3f", + vSizes.size(), worst->getRadius()); double center[2],uv[2],metric[3],r2; if (worst->getRadius() < 0.5 * sqrt(2.0)) break; circUV(worst->tri(), Us, Vs, center, gf); MTriangle *base = worst->tri(); double pa[2] = {(Us[base->getVertex(0)->getNum()] + - Us[base->getVertex(1)->getNum()] + - Us[base->getVertex(2)->getNum()]) / 3., - (Vs[base->getVertex(0)->getNum()] + - Vs[base->getVertex(1)->getNum()] + - Vs[base->getVertex(2)->getNum()]) / 3.}; + Us[base->getVertex(1)->getNum()] + + Us[base->getVertex(2)->getNum()]) / 3., + (Vs[base->getVertex(0)->getNum()] + + Vs[base->getVertex(1)->getNum()] + + Vs[base->getVertex(2)->getNum()]) / 3.}; buildMetric(gf, pa, metric); circumCenterMetric(worst->tri(), metric, Us, Vs, center, r2); bool inside = invMapUV(worst->tri(), center, Us, Vs, uv, 1.e-8); if (!inside && worst->getNeigh(0)) - inside |= invMapUV(worst->getNeigh(0)->tri(), center, Us, Vs, uv, 1.e-8); + inside |= invMapUV(worst->getNeigh(0)->tri(), center, Us, Vs, uv, 1.e-8); if (!inside && worst->getNeigh(1)) - inside |= invMapUV(worst->getNeigh(1)->tri(), center, Us, Vs, uv, 1.e-8); + inside |= invMapUV(worst->getNeigh(1)->tri(), center, Us, Vs, uv, 1.e-8); if (!inside && worst->getNeigh(2)) - inside |= invMapUV(worst->getNeigh(2)->tri(), center, Us, Vs, uv, 1.e-8); + inside |= invMapUV(worst->getNeigh(2)->tri(), center, Us, Vs, uv, 1.e-8); if (inside) { - // we use here local coordinates as real coordinates - // x,y and z will be computed hereafter - // Msg(INFO,"Point is inside"); - GPoint p = gf->point(center[0], center[1]); - MVertex *v = new MFaceVertex(p.x(), p.y(), p.z(), gf, center[0], center[1]); - v->setNum(Us.size()); - double lc1 = ((1. - uv[0] - uv[1]) * vSizes[worst->tri()->getVertex(0)->getNum()] + - uv[0] * vSizes [worst->tri()->getVertex(1)->getNum()] + - uv[1] * vSizes [worst->tri()->getVertex(2)->getNum()]); - // double eigMetricSurface = gf->getMetricEigenvalue(SPoint2(center[0],center[1])); - double lc = BGM_MeshSize(gf,center[0],center[1],p.x(),p.y(),p.z()); - vSizesBGM.push_back(lc); - vSizes.push_back(lc1); - Us.push_back(center[0]); - Vs.push_back(center[1]); - - if (!insertVertex(gf, v, center, worst, AllTris, vSizes, vSizesBGM, - Us, Vs, metric)) { - Msg(DEBUG,"2D Delaunay : a cavity is not star shaped"); - AllTris.erase(AllTris.begin()); - worst->forceRadius(-1); - AllTris.insert(worst); - delete v; - } - else - gf->mesh_vertices.push_back(v); + // we use here local coordinates as real coordinates + // x,y and z will be computed hereafter + // Msg(INFO,"Point is inside"); + GPoint p = gf->point(center[0], center[1]); + MVertex *v = new MFaceVertex(p.x(), p.y(), p.z(), gf, center[0], center[1]); + v->setNum(Us.size()); + double lc1 = ((1. - uv[0] - uv[1]) * vSizes[worst->tri()->getVertex(0)->getNum()] + + uv[0] * vSizes [worst->tri()->getVertex(1)->getNum()] + + uv[1] * vSizes [worst->tri()->getVertex(2)->getNum()]); + // double eigMetricSurface = gf->getMetricEigenvalue(SPoint2(center[0],center[1])); + double lc = BGM_MeshSize(gf,center[0],center[1],p.x(),p.y(),p.z()); + vSizesBGM.push_back(lc); + vSizes.push_back(lc1); + Us.push_back(center[0]); + Vs.push_back(center[1]); + + if (!insertVertex(gf, v, center, worst, AllTris, vSizes, vSizesBGM, + Us, Vs, metric)) { + Msg(DEBUG,"2D Delaunay : a cavity is not star shaped"); + AllTris.erase(AllTris.begin()); + worst->forceRadius(-1); + AllTris.insert(worst); + delete v; + } + else + gf->mesh_vertices.push_back(v); } else { - Msg(DEBUG,"Point %g %g is outside (%g %g , %g %g , %g %g) (metric %g %g %g)", - center[0], center[1], - Us[base->getVertex(0)->getNum()], - Vs[base->getVertex(0)->getNum()], - Us[base->getVertex(1)->getNum()], - Vs[base->getVertex(1)->getNum()], - Us[base->getVertex(2)->getNum()], - Vs[base->getVertex(2)->getNum()], - metric[0], metric[1], metric[2]); - AllTris.erase(AllTris.begin()); - worst->forceRadius(0); - AllTris.insert(worst); + Msg(DEBUG,"Point %g %g is outside (%g %g , %g %g , %g %g) (metric %g %g %g)", + center[0], center[1], + Us[base->getVertex(0)->getNum()], + Vs[base->getVertex(0)->getNum()], + Us[base->getVertex(1)->getNum()], + Vs[base->getVertex(1)->getNum()], + Us[base->getVertex(2)->getNum()], + Vs[base->getVertex(2)->getNum()], + metric[0], metric[1], metric[2]); + AllTris.erase(AllTris.begin()); + worst->forceRadius(0); + AllTris.insert(worst); } } } diff --git a/Mesh/meshGFaceDelaunayInsertion.h b/Mesh/meshGFaceDelaunayInsertion.h index ab9160c99682f6b279ee4c11d9c6561329e17eb8..fc956acee6bd187c6e7d3e32caf90864870396fd 100644 --- a/Mesh/meshGFaceDelaunayInsertion.h +++ b/Mesh/meshGFaceDelaunayInsertion.h @@ -32,22 +32,22 @@ class BDS_Point; void buildMetric(GFace *gf, double *uv, double *metric); int inCircumCircleAniso(GFace *gf, double *p1, double *p2, double *p3, double *p4, - double *metric); + double *metric); int inCircumCircleAniso(GFace *gf, MTriangle *base, const double *uv, const double *metric, - const std::vector<double> &Us, const std::vector<double> &Vs); + const std::vector<double> &Us, const std::vector<double> &Vs); void circumCenterXYZ(double *p1, double *p2, double *p3, double *res, double *uv=0); void circumCenterMetric(MTriangle *base, - const double *metric, - const std::vector<double> &Us, - const std::vector<double> &Vs, - double *x, double &Radius2); + const double *metric, + const std::vector<double> &Us, + const std::vector<double> &Vs, + double *x, double &Radius2); bool circumCenterMetricInTriangle(MTriangle *base, - const double *metric, - const std::vector<double> &Us, - const std::vector<double> &Vs); + const double *metric, + const std::vector<double> &Us, + const std::vector<double> &Vs); bool invMapUV(MTriangle *t, double *p, - const std::vector<double> &Us, const std::vector<double> &Vs, - double *uv, double tol); + const std::vector<double> &Us, const std::vector<double> &Vs, + double *uv, double tol); class MTri3 { diff --git a/Mesh/meshGFaceExtruded.cpp b/Mesh/meshGFaceExtruded.cpp index f26b13d56009129919988a5d0cef198e14097cdf..846661baa4b2b6b3f3225fd4c88e1f60b66f37f6 100644 --- a/Mesh/meshGFaceExtruded.cpp +++ b/Mesh/meshGFaceExtruded.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFaceExtruded.cpp,v 1.27 2008-02-22 21:09:01 geuzaine Exp $ +// $Id: meshGFaceExtruded.cpp,v 1.28 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -29,7 +29,7 @@ extern Context_T CTX; void createQuaTri(std::vector<MVertex*> &v, GFace *to, - std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges) + std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges) { ExtrudeParams *ep = to->meshAttributes.extrude; @@ -50,20 +50,20 @@ void createQuaTri(std::vector<MVertex*> &v, GFace *to, else{ std::pair<MVertex*, MVertex*> p(std::min(v[1], v[2]), std::max(v[1], v[2])); if(constrainedEdges->count(p)){ - to->triangles.push_back(new MTriangle(v[2], v[1], v[0])); - to->triangles.push_back(new MTriangle(v[2], v[3], v[1])); + to->triangles.push_back(new MTriangle(v[2], v[1], v[0])); + to->triangles.push_back(new MTriangle(v[2], v[3], v[1])); } else{ - to->triangles.push_back(new MTriangle(v[2], v[3], v[0])); - to->triangles.push_back(new MTriangle(v[0], v[3], v[1])); + to->triangles.push_back(new MTriangle(v[2], v[3], v[0])); + to->triangles.push_back(new MTriangle(v[0], v[3], v[1])); } } } } void extrudeMesh(GEdge *from, GFace *to, - std::set<MVertex*, MVertexLessThanLexicographic> &pos, - std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges) + std::set<MVertex*, MVertexLessThanLexicographic> &pos, + std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges) { ExtrudeParams *ep = to->meshAttributes.extrude; @@ -72,15 +72,15 @@ void extrudeMesh(GEdge *from, GFace *to, for(unsigned int i = 0; i < from->mesh_vertices.size(); i++){ MVertex *v = from->mesh_vertices[i]; for(int j = 0; j < ep->mesh.NbLayer; j++) { - for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - double x = v->x(), y = v->y(), z = v->z(); - ep->Extrude(j, k + 1, x, y, z); - if(j != ep->mesh.NbLayer - 1 || k != ep->mesh.NbElmLayer[j] - 1){ - MVertex *newv = new MVertex(x, y, z, to); - to->mesh_vertices.push_back(newv); - pos.insert(newv); - } - } + for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { + double x = v->x(), y = v->y(), z = v->z(); + ep->Extrude(j, k + 1, x, y, z); + if(j != ep->mesh.NbLayer - 1 || k != ep->mesh.NbElmLayer[j] - 1){ + MVertex *newv = new MVertex(x, y, z, to); + to->mesh_vertices.push_back(newv); + pos.insert(newv); + } + } } } } @@ -94,36 +94,36 @@ void extrudeMesh(GEdge *from, GFace *to, MVertex *v1 = from->lines[i]->getVertex(1); for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - std::vector<MVertex*> verts; - double x[4] = {v0->x(), v1->x(), v0->x(), v1->x()}; - double y[4] = {v0->y(), v1->y(), v0->y(), v1->y()}; - double z[4] = {v0->z(), v1->z(), v0->z(), v1->z()}; - for(int p = 0; p < 2; p++){ - ep->Extrude(j, k, x[p], y[p], z[p]); - ep->Extrude(j, k + 1, x[p + 2], y[p + 2], z[p + 2]); - } - for(int p = 0; p < 4; p++){ - MVertex tmp(x[p], y[p], z[p], 0, -1); - itp = pos.find(&tmp); - if(itp == pos.end()){ // FIXME: workaround - Msg(INFO, "Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); - itp = tmp.linearSearch(pos); - } - if(itp == pos.end()){ - Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", - tmp.x(), tmp.y(), tmp.z(), to->tag()); - return; - } - verts.push_back(*itp); - } - createQuaTri(verts, to, constrainedEdges); + std::vector<MVertex*> verts; + double x[4] = {v0->x(), v1->x(), v0->x(), v1->x()}; + double y[4] = {v0->y(), v1->y(), v0->y(), v1->y()}; + double z[4] = {v0->z(), v1->z(), v0->z(), v1->z()}; + for(int p = 0; p < 2; p++){ + ep->Extrude(j, k, x[p], y[p], z[p]); + ep->Extrude(j, k + 1, x[p + 2], y[p + 2], z[p + 2]); + } + for(int p = 0; p < 4; p++){ + MVertex tmp(x[p], y[p], z[p], 0, -1); + itp = pos.find(&tmp); + if(itp == pos.end()){ // FIXME: workaround + Msg(INFO, "Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); + itp = tmp.linearSearch(pos); + } + if(itp == pos.end()){ + Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", + tmp.x(), tmp.y(), tmp.z(), to->tag()); + return; + } + verts.push_back(*itp); + } + createQuaTri(verts, to, constrainedEdges); } } } } void copyMesh(GFace *from, GFace *to, - std::set<MVertex*, MVertexLessThanLexicographic> &pos) + std::set<MVertex*, MVertexLessThanLexicographic> &pos) { ExtrudeParams *ep = to->meshAttributes.extrude; @@ -132,7 +132,7 @@ void copyMesh(GFace *from, GFace *to, MVertex *v = from->mesh_vertices[i]; double x = v->x(), y = v->y(), z = v->z(); ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], - x, y, z); + x, y, z); MVertex *newv = new MVertex(x, y, z, to); to->mesh_vertices.push_back(newv); pos.insert(newv); @@ -146,16 +146,16 @@ void copyMesh(GFace *from, GFace *to, MVertex *v = from->triangles[i]->getVertex(j); MVertex tmp(v->x(), v->y(), v->z(), 0, -1); ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], - tmp.x(), tmp.y(), tmp.z()); + tmp.x(), tmp.y(), tmp.z()); itp = pos.find(&tmp); if(itp == pos.end()){ // FIXME: workaround - Msg(INFO, "Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); - itp = tmp.linearSearch(pos); + Msg(INFO, "Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); + itp = tmp.linearSearch(pos); } if(itp == pos.end()) { - Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", - tmp.x(), tmp.y(), tmp.z(), to->tag()); - return; + Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", + tmp.x(), tmp.y(), tmp.z(), to->tag()); + return; } verts.push_back(*itp); } @@ -167,16 +167,16 @@ void copyMesh(GFace *from, GFace *to, MVertex *v = from->quadrangles[i]->getVertex(j); MVertex tmp(v->x(), v->y(), v->z(), 0, -1); ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], - tmp.x(), tmp.y(), tmp.z()); + tmp.x(), tmp.y(), tmp.z()); itp = pos.find(&tmp); if(itp == pos.end()){ // FIXME: workaround - Msg(INFO, "Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); - itp = tmp.linearSearch(pos); + Msg(INFO, "Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); + itp = tmp.linearSearch(pos); } if(itp == pos.end()) { - Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", - tmp.x(), tmp.y(), tmp.z(), to->tag()); - return; + Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", + tmp.x(), tmp.y(), tmp.z(), to->tag()); + return; } verts.push_back(*itp); } @@ -185,7 +185,7 @@ void copyMesh(GFace *from, GFace *to, } int MeshExtrudedSurface(GFace *gf, - std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges) + std::set<std::pair<MVertex*, MVertex*> > *constrainedEdges) { ExtrudeParams *ep = gf->meshAttributes.extrude; @@ -204,9 +204,9 @@ int MeshExtrudedSurface(GFace *gf, while(it != edges.end()){ pos.insert((*it)->mesh_vertices.begin(), (*it)->mesh_vertices.end()); pos.insert((*it)->getBeginVertex()->mesh_vertices.begin(), - (*it)->getBeginVertex()->mesh_vertices.end()); + (*it)->getBeginVertex()->mesh_vertices.end()); pos.insert((*it)->getEndVertex()->mesh_vertices.begin(), - (*it)->getEndVertex()->mesh_vertices.end()); + (*it)->getEndVertex()->mesh_vertices.end()); ++it; } diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index 34ab2d09761279e6d6507370606d7b4ce1863d6c..394f8db7f77aece0f37c3ce98c064459535dbb0a 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFaceOptimize.cpp,v 1.12 2008-03-01 10:52:05 geuzaine Exp $ +// $Id: meshGFaceOptimize.cpp,v 1.13 2008-03-20 11:44:08 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -50,8 +50,8 @@ static void setLcs(MTriangle *t, std::map<MVertex*,double> &vSizes) double dy = vi->y()-vj->y(); double dz = vi->z()-vj->z(); double l = sqrt(dx * dx + dy * dy + dz * dz); - std::map<MVertex*,double>::iterator iti = vSizes.find(vi); - std::map<MVertex*,double>::iterator itj = vSizes.find(vj); + std::map<MVertex*,double>::iterator iti = vSizes.find(vi); + std::map<MVertex*,double>::iterator itj = vSizes.find(vj); if (iti->second > l) iti->second = l; if (itj->second > l) itj->second = l; } @@ -59,10 +59,10 @@ static void setLcs(MTriangle *t, std::map<MVertex*,double> &vSizes) } void buidMeshGenerationDataStructures(GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris, - std::vector<double> &vSizes, - std::vector<double> &vSizesBGM, - std::vector<double> &Us, - std::vector<double> &Vs) + std::vector<double> &vSizes, + std::vector<double> &vSizesBGM, + std::vector<double> &Us, + std::vector<double> &Vs) { std::map<MVertex*, double> vSizesMap; for (unsigned int i = 0;i < gf->triangles.size(); i++) @@ -82,8 +82,8 @@ void buidMeshGenerationDataStructures(GFace *gf, std::set<MTri3*, compareTri3Ptr } for(unsigned int i = 0; i < gf->triangles.size(); i++){ double lc = 0.3333333333 * (vSizes [gf->triangles[i]->getVertex(0)->getNum()] + - vSizes [gf->triangles[i]->getVertex(1)->getNum()] + - vSizes [gf->triangles[i]->getVertex(2)->getNum()]); + vSizes [gf->triangles[i]->getVertex(1)->getNum()] + + vSizes [gf->triangles[i]->getVertex(2)->getNum()]); AllTris.insert(new MTri3(gf->triangles[i], lc)); } gf->triangles.clear(); @@ -113,12 +113,12 @@ void buildVertexToTriangle(std::vector<MTriangle*> &triangles, v2t_cont &adj) MVertex *v = t->getVertex(j); v2t_cont :: iterator it = adj.find(v); if (it == adj.end()){ - std::vector<MTriangle*> one; - one.push_back(t); - adj[v] = one; + std::vector<MTriangle*> one; + one.push_back(t); + adj[v] = one; } else{ - it->second.push_back(t); + it->second.push_back(t); } } } @@ -140,13 +140,13 @@ void buildEdgeToTriangle(std::vector<MTriangle*> &triangles, e2t_cont &adj) MEdge e(v1, v2); e2t_cont::iterator it = adj.find(e); if (it == adj.end()){ - std::pair<MTriangle*, MTriangle*> one = std::make_pair(t, (MTriangle*)0); - adj[e] = one; + std::pair<MTriangle*, MTriangle*> one = std::make_pair(t, (MTriangle*)0); + adj[e] = one; } else - { - it->second.second = t; - } + { + it->second.second = t; + } } } } @@ -171,25 +171,25 @@ void laplaceSmoothing(GFace *gf) GEntity *ge = ver->onWhat(); // this vertex in internal to the face if (ge->dim() == 2){ - double initu,initv; - ver->getParameter(0, initu); - ver->getParameter(1, initv); - const std::vector<MTriangle*> < = it->second; - double fact = lt.size() ? 1. / (3. * lt.size()) : 0; - double cu = 0, cv = 0; - double pu[3], pv[3]; - for (unsigned int i = 0; i < lt.size(); i++){ - parametricCoordinates(lt[i], gf, pu, pv); - cu += fact * (pu[0] + pu[1] + pu[2]); - cv += fact * (pv[0] + pv[1] + pv[2]); - // have to test validity ! - } - ver->setParameter(0, cu); - ver->setParameter(1, cv); - GPoint pt = gf->point(SPoint2(cu, cv)); - ver->x() = pt.x(); - ver->y() = pt.y(); - ver->z() = pt.z(); + double initu,initv; + ver->getParameter(0, initu); + ver->getParameter(1, initv); + const std::vector<MTriangle*> < = it->second; + double fact = lt.size() ? 1. / (3. * lt.size()) : 0; + double cu = 0, cv = 0; + double pu[3], pv[3]; + for (unsigned int i = 0; i < lt.size(); i++){ + parametricCoordinates(lt[i], gf, pu, pv); + cu += fact * (pu[0] + pu[1] + pu[2]); + cv += fact * (pv[0] + pv[1] + pv[2]); + // have to test validity ! + } + ver->setParameter(0, cu); + ver->setParameter(1, cv); + GPoint pt = gf->point(SPoint2(cu, cv)); + ver->x() = pt.x(); + ver->y() = pt.y(); + ver->z() = pt.z(); } ++it; } @@ -198,21 +198,21 @@ void laplaceSmoothing(GFace *gf) extern void fourthPoint(double *p1, double *p2, double *p3, double *p4); -double surfaceTriangleUV(MVertex *v1, MVertex *v2, MVertex *v3, - const std::vector<double> &Us, - const std::vector<double> &Vs) +double surfaceTriangleUV(MVertex *v1, MVertex *v2, MVertex *v3, + const std::vector<double> &Us, + const std::vector<double> &Vs) { const double v12[2] = {Us[v2->getNum()] - Us[v1->getNum()], - Vs[v2->getNum()] - Vs[v1->getNum()]}; + Vs[v2->getNum()] - Vs[v1->getNum()]}; const double v13[2] = {Us[v3->getNum()] - Us[v1->getNum()], - Vs[v3->getNum()] - Vs[v1->getNum()]}; + Vs[v3->getNum()] - Vs[v1->getNum()]}; return 0.5 * fabs (v12[0] * v13[1] - v12[1] * v13[0]); } bool gmshEdgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalEdge, - std::vector<MTri3*> &newTris, const gmshSwapCriterion &cr, - const std::vector<double> &Us, const std::vector<double> &Vs, - const std::vector<double> &vSizes, const std::vector<double> &vSizesBGM) + std::vector<MTri3*> &newTris, const gmshSwapCriterion &cr, + const std::vector<double> &Us, const std::vector<double> &Vs, + const std::vector<double> &vSizes, const std::vector<double> &vSizesBGM) { MTri3 *t2 = t1->getNeigh(iLocalEdge); if (!t2) return false; @@ -249,51 +249,51 @@ bool gmshEdgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalE case SWCR_QUAL: { const double triQualityRef = std::min(qmTriangle(t1->tri(), QMTRI_RHO), - qmTriangle(t2->tri(), QMTRI_RHO)); + qmTriangle(t2->tri(), QMTRI_RHO)); const double triQuality = std::min(qmTriangle(t1b, QMTRI_RHO), - qmTriangle(t2b, QMTRI_RHO)); + qmTriangle(t2b, QMTRI_RHO)); if (triQuality < triQualityRef){ - delete t1b; - delete t2b; - return false; + delete t1b; + delete t2b; + return false; } break; } case SWCR_DEL: { double edgeCenter[2] ={(Us[v1->getNum()] + Us[v2->getNum()] + Us[v3->getNum()] + - Us[v4->getNum()]) * .25, - (Vs[v1->getNum()] + Vs[v2->getNum()] + Vs[v3->getNum()] + - Vs[v4->getNum()]) * .25}; + Us[v4->getNum()]) * .25, + (Vs[v1->getNum()] + Vs[v2->getNum()] + Vs[v3->getNum()] + + Vs[v4->getNum()]) * .25}; double uv4[2] ={Us[v4->getNum()], Vs[v4->getNum()]}; double metric[3]; buildMetric(gf, edgeCenter, metric); if (!inCircumCircleAniso(gf, t1->tri(), uv4, metric, Us, Vs)){ - delete t1b; - delete t2b; - return false; + delete t1b; + delete t2b; + return false; } } break; case SWCR_CLOSE: { double avg1[3] = {(v1->x() + v2->x()) *.5,(v1->y() + v2->y()) *.5, - (v1->z() + v2->z()) *.5}; + (v1->z() + v2->z()) *.5}; double avg2[3] = {(v3->x() + v4->x()) *.5,(v3->y() + v4->y()) *.5, - (v3->z() + v4->z()) *.5}; + (v3->z() + v4->z()) *.5}; GPoint gp1 = gf->point(SPoint2((Us[v1->getNum()] + Us[v2->getNum()]) * .5, - (Vs[v1->getNum()] + Vs[v2->getNum()]) * .5)); + (Vs[v1->getNum()] + Vs[v2->getNum()]) * .5)); GPoint gp2 = gf->point(SPoint2((Us[v3->getNum()] + Us[v4->getNum()]) * .5, - (Vs[v3->getNum()] + Vs[v4->getNum()]) * .5)); + (Vs[v3->getNum()] + Vs[v4->getNum()]) * .5)); double d1 = (avg1[0] - gp1.x()) * (avg1[0] - gp1.x()) + (avg1[1] - gp1.y()) * - (avg1[1]-gp1.y()) + (avg1[2] - gp1.z()) * (avg1[2] - gp1.z()); + (avg1[1]-gp1.y()) + (avg1[2] - gp1.z()) * (avg1[2] - gp1.z()); double d2 = (avg2[0] - gp2.x()) * (avg2[0] - gp2.x()) + (avg2[1] - gp2.y()) * - (avg2[1] - gp2.y()) + (avg2[2] - gp2.z()) * (avg2[2] - gp2.z()); + (avg2[1] - gp2.y()) + (avg2[2] - gp2.z()) * (avg2[2] - gp2.z()); if (d1 < d2){ - delete t1b; - delete t2b; - return false; + delete t1b; + delete t2b; + return false; } } break; @@ -306,7 +306,7 @@ bool gmshEdgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalE if (t1->getNeigh(i) && t1->getNeigh(i) != t2){ bool found = false; for (std::list<MTri3*>::iterator it = cavity.begin(); it != cavity.end(); it++){ - if (*it == t1->getNeigh(i)) found = true; + if (*it == t1->getNeigh(i)) found = true; } if (!found)cavity.push_back(t1->getNeigh(i)); } @@ -315,27 +315,27 @@ bool gmshEdgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalE if (t2->getNeigh(i) && t2->getNeigh(i) != t1){ bool found = false; for (std::list<MTri3*>::iterator it = cavity.begin(); it != cavity.end(); it++){ - if (*it == t2->getNeigh(i)) found = true; + if (*it == t2->getNeigh(i)) found = true; } if (!found)cavity.push_back(t2->getNeigh(i)); } } double lc1 = 0.3333333333 * (vSizes[t1b->getVertex(0)->getNum()] + - vSizes[t1b->getVertex(1)->getNum()] + - vSizes[t1b->getVertex(2)->getNum()]); + vSizes[t1b->getVertex(1)->getNum()] + + vSizes[t1b->getVertex(2)->getNum()]); double lcBGM1 = 0.3333333333 * (vSizesBGM[t1b->getVertex(0)->getNum()] + - vSizesBGM[t1b->getVertex(1)->getNum()] + - vSizesBGM[t1b->getVertex(2)->getNum()]); + vSizesBGM[t1b->getVertex(1)->getNum()] + + vSizesBGM[t1b->getVertex(2)->getNum()]); double lc2 = 0.3333333333 * (vSizes[t2b->getVertex(0)->getNum()] + - vSizes[t2b->getVertex(1)->getNum()] + - vSizes[t2b->getVertex(2)->getNum()]); + vSizes[t2b->getVertex(1)->getNum()] + + vSizes[t2b->getVertex(2)->getNum()]); double lcBGM2 = 0.3333333333 * (vSizesBGM[t2b->getVertex(0)->getNum()] + - vSizesBGM[t2b->getVertex(1)->getNum()] + - vSizesBGM[t2b->getVertex(2)->getNum()]); + vSizesBGM[t2b->getVertex(1)->getNum()] + + vSizesBGM[t2b->getVertex(2)->getNum()]); MTri3 *t1b3 = new MTri3(t1b, Extend1dMeshIn2dSurfaces() ? - std::min(lc1, lcBGM1) : lcBGM1); + std::min(lc1, lcBGM1) : lcBGM1); MTri3 *t2b3 = new MTri3(t2b, Extend1dMeshIn2dSurfaces() ? - std::min(lc2, lcBGM2) : lcBGM2); + std::min(lc2, lcBGM2) : lcBGM2); cavity.push_back(t1b3); cavity.push_back(t2b3); @@ -349,13 +349,13 @@ bool gmshEdgeSwap(std::set<swapquad> &configs, MTri3 *t1, GFace *gf, int iLocalE } inline double computeEdgeAdimLength(MVertex *v1, MVertex *v2, GFace *f, - const std::vector<double> &Us, - const std::vector<double> &Vs, - const std::vector<double> &vSizes , - const std::vector<double> &vSizesBGM) + const std::vector<double> &Us, + const std::vector<double> &Vs, + const std::vector<double> &vSizes , + const std::vector<double> &vSizesBGM) { const double edgeCenter[2] ={(Us[v1->getNum()] + Us[v2->getNum()]) * .5, - (Vs[v1->getNum()] + Vs[v2->getNum()]) * .5}; + (Vs[v1->getNum()] + Vs[v2->getNum()]) * .5}; GPoint GP = f->point (edgeCenter[0], edgeCenter[1]); const double dx1 = v1->x() - GP.x(); @@ -368,14 +368,14 @@ inline double computeEdgeAdimLength(MVertex *v1, MVertex *v2, GFace *f, const double l2 = sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2); if (Extend1dMeshIn2dSurfaces()) return 2 * (l1 + l2) / (std::min(vSizes[v1->getNum()], vSizesBGM[v1->getNum()]) + - std::min(vSizes[v2->getNum()], vSizesBGM[v2->getNum()])); + std::min(vSizes[v2->getNum()], vSizesBGM[v2->getNum()])); return 2 * (l1 + l2) / (vSizesBGM[v1->getNum()] + vSizesBGM[v2->getNum()]); } bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, - std::vector<MTri3*> &newTris, const gmshSplitCriterion &cr, - std::vector<double> &Us, std::vector<double> &Vs, - std::vector<double> &vSizes, std::vector<double> &vSizesBGM) + std::vector<MTri3*> &newTris, const gmshSplitCriterion &cr, + std::vector<double> &Us, std::vector<double> &Vs, + std::vector<double> &vSizes, std::vector<double> &vSizesBGM) { MTri3 *t2 = t1->getNeigh(iLocalEdge); if (!t2) return false; @@ -383,7 +383,7 @@ bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, MVertex *v1 = t1->tri()->getVertex(iLocalEdge == 0 ? 2 : iLocalEdge - 1); MVertex *v2 = t1->tri()->getVertex(iLocalEdge % 3); double edgeCenter[2] ={(Us[v1->getNum()] + Us[v2->getNum()]) * .5, - (Vs[v1->getNum()] + Vs[v2->getNum()]) * .5}; + (Vs[v1->getNum()] + Vs[v2->getNum()]) * .5}; double al = computeEdgeAdimLength(v1, v2, gf,Us, Vs, vSizes, vSizesBGM); if (al <= lMax) return false; @@ -396,7 +396,7 @@ bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, GPoint p = gf->point(edgeCenter[0], edgeCenter[1]); MVertex *vnew = new MFaceVertex(p.x(), p.y(), p.z(), gf, - edgeCenter[0], edgeCenter[1]); + edgeCenter[0], edgeCenter[1]); MTriangle *t1b = new MTriangle(v1, vnew, v3); MTriangle *t2b = new MTriangle(vnew, v2, v3); @@ -407,19 +407,19 @@ bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, case SPCR_QUAL: { const double triQualityRef = std::min(qmTriangle(t1->tri(), QMTRI_RHO), - qmTriangle(t2->tri(), QMTRI_RHO)); + qmTriangle(t2->tri(), QMTRI_RHO)); const double triQuality = - std::min(std::min(std::min(qmTriangle(t1b, QMTRI_RHO), - qmTriangle(t2b, QMTRI_RHO)), - qmTriangle(t3b, QMTRI_RHO)), - qmTriangle(t4b, QMTRI_RHO)); + std::min(std::min(std::min(qmTriangle(t1b, QMTRI_RHO), + qmTriangle(t2b, QMTRI_RHO)), + qmTriangle(t3b, QMTRI_RHO)), + qmTriangle(t4b, QMTRI_RHO)); if (triQuality < triQualityRef){ - delete t1b; - delete t2b; - delete t3b; - delete t4b; - delete vnew; - return false; + delete t1b; + delete t2b; + delete t3b; + delete t4b; + delete vnew; + return false; } break; } @@ -444,7 +444,7 @@ bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, if (t1->getNeigh(i) && t1->getNeigh(i) != t2){ bool found = false; for (std::list<MTri3*>::iterator it = cavity.begin();it != cavity.end(); it++){ - if (*it == t1->getNeigh(i)) found = true; + if (*it == t1->getNeigh(i)) found = true; } if (!found) cavity.push_back(t1->getNeigh(i)); } @@ -453,35 +453,35 @@ bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, if (t2->getNeigh(i) && t2->getNeigh(i) != t1){ bool found = false; for (std::list<MTri3*>::iterator it = cavity.begin(); it != cavity.end(); it++){ - if (*it == t2->getNeigh(i))found = true; + if (*it == t2->getNeigh(i))found = true; } if (!found) cavity.push_back(t2->getNeigh(i)); } } double lc1 = 0.3333333333 * (vSizes[t1b->getVertex(0)->getNum()] + - vSizes[t1b->getVertex(1)->getNum()] + - vSizes[t1b->getVertex(2)->getNum()]); + vSizes[t1b->getVertex(1)->getNum()] + + vSizes[t1b->getVertex(2)->getNum()]); double lcBGM1 = 0.3333333333 * (vSizesBGM[t1b->getVertex(0)->getNum()] + - vSizesBGM[t1b->getVertex(1)->getNum()] + - vSizesBGM[t1b->getVertex(2)->getNum()]); + vSizesBGM[t1b->getVertex(1)->getNum()] + + vSizesBGM[t1b->getVertex(2)->getNum()]); double lc2 = 0.3333333333 * (vSizes[t2b->getVertex(0)->getNum()] + - vSizes[t2b->getVertex(1)->getNum()] + - vSizes[t2b->getVertex(2)->getNum()]); + vSizes[t2b->getVertex(1)->getNum()] + + vSizes[t2b->getVertex(2)->getNum()]); double lcBGM2 = 0.3333333333 * (vSizesBGM[t2b->getVertex(0)->getNum()] + - vSizesBGM[t2b->getVertex(1)->getNum()] + - vSizesBGM[t2b->getVertex(2)->getNum()]); + vSizesBGM[t2b->getVertex(1)->getNum()] + + vSizesBGM[t2b->getVertex(2)->getNum()]); double lc3 = 0.3333333333 * (vSizes[t3b->getVertex(0)->getNum()] + - vSizes[t3b->getVertex(1)->getNum()] + - vSizes[t3b->getVertex(2)->getNum()]); + vSizes[t3b->getVertex(1)->getNum()] + + vSizes[t3b->getVertex(2)->getNum()]); double lcBGM3 = 0.3333333333 * (vSizesBGM[t3b->getVertex(0)->getNum()] + - vSizesBGM[t3b->getVertex(1)->getNum()] + - vSizesBGM[t3b->getVertex(2)->getNum()]); + vSizesBGM[t3b->getVertex(1)->getNum()] + + vSizesBGM[t3b->getVertex(2)->getNum()]); double lc4 = 0.3333333333 * (vSizes[t4b->getVertex(0)->getNum()] + - vSizes[t4b->getVertex(1)->getNum()] + - vSizes[t4b->getVertex(2)->getNum()]); + vSizes[t4b->getVertex(1)->getNum()] + + vSizes[t4b->getVertex(2)->getNum()]); double lcBGM4 = 0.3333333333 * (vSizesBGM[t4b->getVertex(0)->getNum()] + - vSizesBGM[t4b->getVertex(1)->getNum()] + - vSizesBGM[t4b->getVertex(2)->getNum()]); + vSizesBGM[t4b->getVertex(1)->getNum()] + + vSizesBGM[t4b->getVertex(2)->getNum()]); MTri3 *t1b3 = new MTri3(t1b, Extend1dMeshIn2dSurfaces() ? std::min(lc1, lcBGM1) : lcBGM1); MTri3 *t2b3 = new MTri3(t2b, Extend1dMeshIn2dSurfaces() ? std::min(lc2, lcBGM2) : lcBGM2); MTri3 *t3b3 = new MTri3(t3b, Extend1dMeshIn2dSurfaces() ? std::min(lc3, lcBGM3) : lcBGM3); @@ -503,36 +503,36 @@ bool gmshEdgeSplit(const double lMax, MTri3 *t1, GFace *gf, int iLocalEdge, } void computeNeighboringTrisOfACavity(const std::vector<MTri3*> &cavity, - std::vector<MTri3*> &outside) + std::vector<MTri3*> &outside) { outside.clear(); for (unsigned int i = 0; i < cavity.size(); i++){ for (int j = 0; j < 3; j++){ MTri3 * neigh = cavity[i]->getNeigh(j); if(neigh){ - bool found = false; - for(unsigned int k = 0; k < outside.size(); k++){ - if(outside[k] == neigh){ - found = true; - break; - } - } - if(!found){ - for (unsigned int k = 0; k < cavity.size(); k++){ - if(cavity[k] == neigh){ - found = true; - } - } - } - if(!found) outside.push_back(neigh); + bool found = false; + for(unsigned int k = 0; k < outside.size(); k++){ + if(outside[k] == neigh){ + found = true; + break; + } + } + if(!found){ + for (unsigned int k = 0; k < cavity.size(); k++){ + if(cavity[k] == neigh){ + found = true; + } + } + } + if(!found) outside.push_back(neigh); } } } } - + bool gmshBuildVertexCavity(MTri3 *t, int iLocalVertex, MVertex **v1, - std::vector<MTri3*> &cavity, std::vector<MTri3*> &outside, - std::vector<MVertex*> &ring) + std::vector<MTri3*> &cavity, std::vector<MTri3*> &outside, + std::vector<MVertex*> &ring) { cavity.clear(); ring.clear(); @@ -549,24 +549,24 @@ bool gmshBuildVertexCavity(MTri3 *t, int iLocalVertex, MVertex **v1, MVertex *v2 = t->tri()->getVertex((i + 2) % 3); MVertex *v3 = t->tri()->getVertex(i); if ((v2 == *v1 && v3 == lastinring) || - (v2 == lastinring && v3 == *v1)){ - iEdge = i; - t = t->getNeigh(i); - if (t == cavity[0]) { - computeNeighboringTrisOfACavity(cavity, outside); - return true; - } - if (!t) return false; - if (t->isDeleted()){ printf("weird\n"); throw; } - cavity.push_back(t); - for (int j = 0; j < 3; j++){ - if (t->tri()->getVertex(j) !=lastinring && t->tri()->getVertex(j) != *v1){ - lastinring = t->tri()->getVertex(j); - ring.push_back(lastinring); - j = 100; - } - } - break; + (v2 == lastinring && v3 == *v1)){ + iEdge = i; + t = t->getNeigh(i); + if (t == cavity[0]) { + computeNeighboringTrisOfACavity(cavity, outside); + return true; + } + if (!t) return false; + if (t->isDeleted()){ printf("weird\n"); throw; } + cavity.push_back(t); + for (int j = 0; j < 3; j++){ + if (t->tri()->getVertex(j) !=lastinring && t->tri()->getVertex(j) != *v1){ + lastinring = t->tri()->getVertex(j); + ring.push_back(lastinring); + j = 100; + } + } + break; } } if (iEdge == -1) { printf("not found\n"); throw; } @@ -574,9 +574,9 @@ bool gmshBuildVertexCavity(MTri3 *t, int iLocalVertex, MVertex **v1, } bool gmshVertexCollapse(const double lMin, MTri3 *t1, GFace *gf, - int iLocalVertex, std::vector<MTri3*> &newTris, - std::vector<double> &Us, std::vector<double> &Vs, - std::vector<double> &vSizes, std::vector<double> &vSizesBGM) + int iLocalVertex, std::vector<MTri3*> &newTris, + std::vector<double> &Us, std::vector<double> &Vs, + std::vector<double> &vSizes, std::vector<double> &vSizesBGM) { MVertex *v; std::vector<MTri3*> cavity; @@ -620,11 +620,11 @@ bool gmshVertexCollapse(const double lMin, MTri3 *t1, GFace *gf, MVertex *v2 = ring[(iMin + 1 + i + 1) % ring.size()]; MTriangle *t = new MTriangle(v1,v2,ring[iMin]); double lc = 0.3333333333 * (vSizes[t->getVertex(0)->getNum()] + - vSizes[t->getVertex(1)->getNum()] + - vSizes[t->getVertex(2)->getNum()]); + vSizes[t->getVertex(1)->getNum()] + + vSizes[t->getVertex(2)->getNum()]); double lcBGM = 0.3333333333 * (vSizesBGM[t->getVertex(0)->getNum()] + - vSizesBGM[t->getVertex(1)->getNum()] + - vSizesBGM[t->getVertex(2)->getNum()]); + vSizesBGM[t->getVertex(1)->getNum()] + + vSizesBGM[t->getVertex(2)->getNum()]); MTri3 *t3 = new MTri3(t, Extend1dMeshIn2dSurfaces() ? std::min(lc, lcBGM) : lcBGM); // printf("Creation %p = %d %d %d\n",t3,v1->getNum(),v2->getNum(),ring[iMin]->getNum()); outside.push_back(t3); @@ -637,9 +637,9 @@ bool gmshVertexCollapse(const double lMin, MTri3 *t1, GFace *gf, } int edgeSwapPass (GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, - const gmshSwapCriterion &cr, - const std::vector<double> &Us, const std::vector<double> &Vs, - const std::vector<double> &vSizes, const std::vector<double> &vSizesBGM) + const gmshSwapCriterion &cr, + const std::vector<double> &Us, const std::vector<double> &Vs, + const std::vector<double> &vSizes, const std::vector<double> &vSizesBGM) { typedef std::set<MTri3*, compareTri3Ptr> CONTAINER ; @@ -650,19 +650,19 @@ int edgeSwapPass (GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, std::vector<MTri3*> newTris; for (CONTAINER::iterator it = allTris.begin(); it != allTris.end(); ++it){ if (!(*it)->isDeleted()){ - for (int i = 0; i < 3; i++){ - if (gmshEdgeSwap(configs, *it, gf, i, newTris, cr, Us, Vs, vSizes, vSizesBGM)){ - nbSwap++; - break; - } - } + for (int i = 0; i < 3; i++){ + if (gmshEdgeSwap(configs, *it, gf, i, newTris, cr, Us, Vs, vSizes, vSizesBGM)){ + nbSwap++; + break; + } + } } else{ - delete *it; - CONTAINER::iterator itb = it; - ++it; - allTris.erase(itb); - if (it == allTris.end()) break; + delete *it; + CONTAINER::iterator itb = it; + ++it; + allTris.erase(itb); + if (it == allTris.end()) break; } } allTris.insert(newTris.begin(), newTris.end()); @@ -673,9 +673,9 @@ int edgeSwapPass (GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, } int edgeSplitPass(double maxLC, GFace *gf, std::set<MTri3*,compareTri3Ptr> &allTris, - const gmshSplitCriterion &cr, - std::vector<double> &Us, std::vector<double> &Vs, - std::vector<double> &vSizes, std::vector<double> &vSizesBGM) + const gmshSplitCriterion &cr, + std::vector<double> &Us, std::vector<double> &Vs, + std::vector<double> &vSizes, std::vector<double> &vSizesBGM) { typedef std::set<MTri3*, compareTri3Ptr> CONTAINER ; std::vector<MTri3*> newTris; @@ -685,10 +685,10 @@ int edgeSplitPass(double maxLC, GFace *gf, std::set<MTri3*,compareTri3Ptr> &allT for (CONTAINER::iterator it = allTris.begin(); it != allTris.end(); ++it){ if (!(*it)->isDeleted()){ for (int i = 0; i < 3; i++){ - if (gmshEdgeSplit(maxLC, *it, gf, i, newTris, cr, Us, Vs, vSizes, vSizesBGM)) { - nbSplit++; - break; - } + if (gmshEdgeSplit(maxLC, *it, gf, i, newTris, cr, Us, Vs, vSizes, vSizesBGM)) { + nbSplit++; + break; + } } } else{ @@ -706,8 +706,8 @@ int edgeSplitPass(double maxLC, GFace *gf, std::set<MTri3*,compareTri3Ptr> &allT } int edgeCollapsePass(double minLC, GFace *gf, std::set<MTri3*,compareTri3Ptr> &allTris, - std::vector<double> &Us, std::vector<double> &Vs, - std::vector<double> &vSizes, std::vector<double> &vSizesBGM) + std::vector<double> &Us, std::vector<double> &Vs, + std::vector<double> &vSizes, std::vector<double> &vSizesBGM) { typedef std::set<MTri3*,compareTri3Ptr> CONTAINER ; std::vector<MTri3*> newTris; @@ -717,10 +717,10 @@ int edgeCollapsePass(double minLC, GFace *gf, std::set<MTri3*,compareTri3Ptr> &a for (CONTAINER::reverse_iterator it = allTris.rbegin(); it != allTris.rend(); ++it){ if (!(*it)->isDeleted()){ for (int i = 0; i < 3; i++){ - if (gmshVertexCollapse(minLC, *it, gf, i, newTris, Us, Vs, vSizes, vSizesBGM)) { - nbCollapse++; - break; - } + if (gmshVertexCollapse(minLC, *it, gf, i, newTris, Us, Vs, vSizes, vSizesBGM)) { + nbCollapse++; + break; + } } } // else{ diff --git a/Mesh/meshGFaceOptimize.h b/Mesh/meshGFaceOptimize.h index 25b68fc524647be620ff67a90f4dee36f80e31a1..154991aeb2d2551f439cf783416afb22381b7e1b 100644 --- a/Mesh/meshGFaceOptimize.h +++ b/Mesh/meshGFaceOptimize.h @@ -37,29 +37,29 @@ void edgeSwappingLawson(GFace *gf); enum gmshSwapCriterion {SWCR_DEL, SWCR_QUAL,SWCR_NORM, SWCR_CLOSE}; enum gmshSplitCriterion {SPCR_CLOSE, SPCR_QUAL, SPCR_ALLWAYS}; int edgeSwapPass(GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, - const gmshSwapCriterion &cr, - const std::vector<double> &Us, - const std::vector<double> &Vs, - const std::vector<double> &vSizes, - const std::vector<double> &vSizesBGM); + const gmshSwapCriterion &cr, + const std::vector<double> &Us, + const std::vector<double> &Vs, + const std::vector<double> &vSizes, + const std::vector<double> &vSizesBGM); int edgeSplitPass(double maxLC, - GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, - const gmshSplitCriterion &cr, - std::vector<double> &Us , - std::vector<double> &Vs, - std::vector<double> &vSizes , - std::vector<double> &vSizesBGM); + GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, + const gmshSplitCriterion &cr, + std::vector<double> &Us , + std::vector<double> &Vs, + std::vector<double> &vSizes , + std::vector<double> &vSizesBGM); int edgeCollapsePass(double minLC, - GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, - std::vector<double> &Us, - std::vector<double> &Vs, - std::vector<double> &vSizes , - std::vector<double> &vSizesBGM); + GFace *gf, std::set<MTri3*, compareTri3Ptr> &allTris, + std::vector<double> &Us, + std::vector<double> &Vs, + std::vector<double> &vSizes , + std::vector<double> &vSizesBGM); void buidMeshGenerationDataStructures(GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris, - std::vector<double> &vSizes, - std::vector<double> &vSizesBGM, - std::vector<double> &Us, - std::vector<double> &Vs); + std::vector<double> &vSizes, + std::vector<double> &vSizesBGM, + std::vector<double> &Us, + std::vector<double> &Vs); void transferDataStructure (GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris); struct swapquad{ diff --git a/Mesh/meshGFaceTransfinite.cpp b/Mesh/meshGFaceTransfinite.cpp index 69bca3cb069f768b722339d012d30c158017c098..fd6bc01b4a4410d23ae50d4ed094391ad4797a56 100644 --- a/Mesh/meshGFaceTransfinite.cpp +++ b/Mesh/meshGFaceTransfinite.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFaceTransfinite.cpp,v 1.25 2008-02-17 08:48:01 geuzaine Exp $ +// $Id: meshGFaceTransfinite.cpp,v 1.26 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -67,12 +67,12 @@ int MeshTransfiniteSurface(GFace *gf) if(corners.size () != 3 && corners.size () != 4){ Msg(GERROR,"Surface %d is transfinite but has %d corners", - gf->tag(), corners.size()); + gf->tag(), corners.size()); return 0; } if(indices.size () != 2){ Msg(GERROR,"Surface %d is transfinite but has %d holes", - gf->tag(), indices.size() - 2); + gf->tag(), indices.size() - 2); return 0; } @@ -115,10 +115,10 @@ int MeshTransfiniteSurface(GFace *gf) MVertex *v = m_vertices[i]; if(v == corners[0] || v == corners[1] || v == corners[2] || (corners.size() == 4 && v == corners[3])){ - N[iCorner++] = i; + N[iCorner++] = i; if(iCorner > 4){ - Msg(GERROR,"Surface %d transfinite parameters are incoherent", gf->tag()); - return 0; + Msg(GERROR,"Surface %d transfinite parameters are incoherent", gf->tag()); + return 0; } } SPoint2 param; @@ -135,9 +135,9 @@ int MeshTransfiniteSurface(GFace *gf) else{ double UU, VV; if(v->onWhat() == gf && v->getParameter(0, UU) && v->getParameter(1, VV)) - param = SPoint2(UU, VV); + param = SPoint2(UU, VV); else - param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z())); + param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z())); } U.push_back(param.x()); V.push_back(param.y()); @@ -156,7 +156,7 @@ int MeshTransfiniteSurface(GFace *gf) int Hb = m_vertices.size() - N4; if(Lb != L || Hb != H){ Msg(GERROR,"Surface %d cannot be meshed using the transfinite algo", - gf->tag()); + gf->tag()); return 0; } } @@ -164,7 +164,7 @@ int MeshTransfiniteSurface(GFace *gf) int Lb = m_vertices.size() - N3; if(Lb != L){ Msg(GERROR,"Surface %d cannot be meshed using the transfinite algo %d != %d", - gf->tag(), L, Lb); + gf->tag(), L, Lb); return 0; } } @@ -247,17 +247,17 @@ int MeshTransfiniteSurface(GFace *gf) for(int i = 1; i < L; i++){ double u = lengths_i[i] / L_i; for(int j = 1; j < H; j++){ - double v = lengths_j[j] / L_j; - int iP1 = N1 + i; - int iP2 = N2 + j; - int iP3 = N4 - i; - int iP4 = (N4 + (N3 - N2) - j) % m_vertices.size(); - double Up = TRAN_QUA(U[iP1], U[iP2], U[iP3], U[iP4], UC1, UC2, UC3, UC4, u, v); - double Vp = TRAN_QUA(V[iP1], V[iP2], V[iP3], V[iP4], VC1, VC2, VC3, VC4, u, v); - GPoint gp = gf->point(SPoint2(Up, Vp)); - MFaceVertex *newv = new MFaceVertex(gp.x(), gp.y(), gp.z(), gf, Up, Vp); - gf->mesh_vertices.push_back(newv); - tab[i][j] = newv; + double v = lengths_j[j] / L_j; + int iP1 = N1 + i; + int iP2 = N2 + j; + int iP3 = N4 - i; + int iP4 = (N4 + (N3 - N2) - j) % m_vertices.size(); + double Up = TRAN_QUA(U[iP1], U[iP2], U[iP3], U[iP4], UC1, UC2, UC3, UC4, u, v); + double Vp = TRAN_QUA(V[iP1], V[iP2], V[iP3], V[iP4], VC1, VC2, VC3, VC4, u, v); + GPoint gp = gf->point(SPoint2(Up, Vp)); + MFaceVertex *newv = new MFaceVertex(gp.x(), gp.y(), gp.z(), gf, Up, Vp); + gf->mesh_vertices.push_back(newv); + tab[i][j] = newv; } } } @@ -265,36 +265,36 @@ int MeshTransfiniteSurface(GFace *gf) for(int i = 1; i < L; i++){ double u = lengths_i[i] / L_i; for(int j = 1; j < H; j++){ - double v = lengths_j[j] / L_j; - int iP1 = N1 + i; - int iP2 = N2 + j; - int iP3 = ((N3 + N2) - i) % m_vertices.size(); - double Up, Vp; - if(gf->geomType() != GEntity::RuledSurface){ - Up = TRAN_TRI(U[iP1], U[iP2], U[iP3], UC1, UC2, UC3, u, v); - Vp = TRAN_TRI(V[iP1], V[iP2], V[iP3], VC1, VC2, VC3, u, v); - } - else{ - // FIXME: to get nice meshes we would need to make the u,v - // coords match with the (degenerate) coordinates of the - // underlying ruled surface; so instead we just interpolate - // in real space - double xp = TRAN_TRI(m_vertices[iP1]->x(), m_vertices[iP2]->x(), - m_vertices[iP3]->x(), m_vertices[N1]->x(), - m_vertices[N2]->x(), m_vertices[N3]->x(), u, v); - double yp = TRAN_TRI(m_vertices[iP1]->y(), m_vertices[iP2]->y(), - m_vertices[iP3]->y(), m_vertices[N1]->y(), - m_vertices[N2]->y(), m_vertices[N3]->y(), u, v); - double zp = TRAN_TRI(m_vertices[iP1]->z(), m_vertices[iP2]->z(), - m_vertices[iP3]->z(), m_vertices[N1]->z(), - m_vertices[N2]->z(), m_vertices[N3]->z(), u, v); - // xp,yp,zp can be off the surface so we cannot use parFromPoint - gf->XYZtoUV(xp, yp, zp, Up, Vp, 1.0, false); - } - GPoint gp = gf->point(SPoint2(Up, Vp)); - MFaceVertex *newv = new MFaceVertex(gp.x(), gp.y(), gp.z(), gf, Up, Vp); - gf->mesh_vertices.push_back(newv); - tab[i][j] = newv; + double v = lengths_j[j] / L_j; + int iP1 = N1 + i; + int iP2 = N2 + j; + int iP3 = ((N3 + N2) - i) % m_vertices.size(); + double Up, Vp; + if(gf->geomType() != GEntity::RuledSurface){ + Up = TRAN_TRI(U[iP1], U[iP2], U[iP3], UC1, UC2, UC3, u, v); + Vp = TRAN_TRI(V[iP1], V[iP2], V[iP3], VC1, VC2, VC3, u, v); + } + else{ + // FIXME: to get nice meshes we would need to make the u,v + // coords match with the (degenerate) coordinates of the + // underlying ruled surface; so instead we just interpolate + // in real space + double xp = TRAN_TRI(m_vertices[iP1]->x(), m_vertices[iP2]->x(), + m_vertices[iP3]->x(), m_vertices[N1]->x(), + m_vertices[N2]->x(), m_vertices[N3]->x(), u, v); + double yp = TRAN_TRI(m_vertices[iP1]->y(), m_vertices[iP2]->y(), + m_vertices[iP3]->y(), m_vertices[N1]->y(), + m_vertices[N2]->y(), m_vertices[N3]->y(), u, v); + double zp = TRAN_TRI(m_vertices[iP1]->z(), m_vertices[iP2]->z(), + m_vertices[iP3]->z(), m_vertices[N1]->z(), + m_vertices[N2]->z(), m_vertices[N3]->z(), u, v); + // xp,yp,zp can be off the surface so we cannot use parFromPoint + gf->XYZtoUV(xp, yp, zp, Up, Vp, 1.0, false); + } + GPoint gp = gf->point(SPoint2(Up, Vp)); + MFaceVertex *newv = new MFaceVertex(gp.x(), gp.y(), gp.z(), gf, Up, Vp); + gf->mesh_vertices.push_back(newv); + tab[i][j] = newv; } } } @@ -308,47 +308,47 @@ int MeshTransfiniteSurface(GFace *gf) numSmooth = gf->meshAttributes.transfiniteSmoothing; for (int IT = 0; IT < numSmooth; IT++){ for(int i = 1; i < L; i++){ - for(int j = 1; j < H; j++){ - MVertex *v11 = tab[i - 1][j - 1]; - MVertex *v12 = tab[i - 1][j ]; - MVertex *v13 = tab[i - 1][j + 1]; - MVertex *v21 = tab[i ][j - 1]; - MVertex *v22 = tab[i ][j ]; - MVertex *v23 = tab[i ][j + 1]; - MVertex *v31 = tab[i + 1][j - 1]; - MVertex *v32 = tab[i + 1][j ]; - MVertex *v33 = tab[i + 1][j + 1]; - double alpha = 0.25 * (DSQR(v23->x() - v21->x()) + - DSQR(v23->y() - v21->y()) + - DSQR(v23->z() - v21->z())); - double gamma = 0.25 * (DSQR(v32->x() - v12->x()) + - DSQR(v32->y() - v12->y()) + - DSQR(v32->z() - v12->z())); - double beta = 0.0625 * ((v32->x() - v12->x()) * (v23->x() - v21->x()) + - (v32->y() - v12->y()) * (v23->y() - v21->y()) + - (v32->z() - v12->z()) * (v23->z() - v21->z())); - v22->x() = 0.5 * (alpha * (v32->x() + v12->x()) + - gamma * (v23->x() + v21->x()) - - 2. * beta * (v33->x() - v13->x() - - v31->x() + v11->x())) / (alpha + gamma); - v22->y() = 0.5 * (alpha * (v32->y() + v12->y()) + - gamma * (v23->y() + v21->y()) - - 2. * beta * (v33->y() - v13->y() - - v31->y() + v11->y())) / (alpha + gamma); - v22->z() = 0.5 * (alpha * (v32->z() + v12->z()) + - gamma * (v23->z() + v21->z()) - - 2. * beta * (v33->z() - v13->z() - - v31->z() + v11->z())) / (alpha + gamma); - } + for(int j = 1; j < H; j++){ + MVertex *v11 = tab[i - 1][j - 1]; + MVertex *v12 = tab[i - 1][j ]; + MVertex *v13 = tab[i - 1][j + 1]; + MVertex *v21 = tab[i ][j - 1]; + MVertex *v22 = tab[i ][j ]; + MVertex *v23 = tab[i ][j + 1]; + MVertex *v31 = tab[i + 1][j - 1]; + MVertex *v32 = tab[i + 1][j ]; + MVertex *v33 = tab[i + 1][j + 1]; + double alpha = 0.25 * (DSQR(v23->x() - v21->x()) + + DSQR(v23->y() - v21->y()) + + DSQR(v23->z() - v21->z())); + double gamma = 0.25 * (DSQR(v32->x() - v12->x()) + + DSQR(v32->y() - v12->y()) + + DSQR(v32->z() - v12->z())); + double beta = 0.0625 * ((v32->x() - v12->x()) * (v23->x() - v21->x()) + + (v32->y() - v12->y()) * (v23->y() - v21->y()) + + (v32->z() - v12->z()) * (v23->z() - v21->z())); + v22->x() = 0.5 * (alpha * (v32->x() + v12->x()) + + gamma * (v23->x() + v21->x()) - + 2. * beta * (v33->x() - v13->x() - + v31->x() + v11->x())) / (alpha + gamma); + v22->y() = 0.5 * (alpha * (v32->y() + v12->y()) + + gamma * (v23->y() + v21->y()) - + 2. * beta * (v33->y() - v13->y() - + v31->y() + v11->y())) / (alpha + gamma); + v22->z() = 0.5 * (alpha * (v32->z() + v12->z()) + + gamma * (v23->z() + v21->z()) - + 2. * beta * (v33->z() - v13->z() - + v31->z() + v11->z())) / (alpha + gamma); + } } } // recompute corresponding u,v coordinates (necessary e.g. for 2nd order algo) for(int i = 1; i < L; i++){ for(int j = 1; j < H; j++){ - MVertex *v = tab[i][j]; - SPoint2 param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z())); - v->setParameter(0, param[0]); - v->setParameter(1, param[1]); + MVertex *v = tab[i][j]; + SPoint2 param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z())); + v->setParameter(0, param[0]); + v->setParameter(1, param[1]); } } } @@ -357,23 +357,23 @@ int MeshTransfiniteSurface(GFace *gf) // create elements for(int i = 0; i < L ; i++){ for(int j = 0; j < H; j++){ - MVertex *v1 = tab[i ][j ]; - MVertex *v2 = tab[i + 1][j ]; - MVertex *v3 = tab[i + 1][j + 1]; - MVertex *v4 = tab[i ][j + 1]; - if(gf->meshAttributes.recombine) - gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); - else if(gf->meshAttributes.transfiniteArrangement == 1 || - (gf->meshAttributes.transfiniteArrangement == 0 && - ((i % 2 == 0 && j % 2 == 1) || - (i % 2 == 1 && j % 2 == 0)))){ - gf->triangles.push_back(new MTriangle(v1, v2, v3)); - gf->triangles.push_back(new MTriangle(v3, v4, v1)); - } - else{ - gf->triangles.push_back(new MTriangle(v1, v2, v4)); - gf->triangles.push_back(new MTriangle(v4, v2, v3)); - } + MVertex *v1 = tab[i ][j ]; + MVertex *v2 = tab[i + 1][j ]; + MVertex *v3 = tab[i + 1][j + 1]; + MVertex *v4 = tab[i ][j + 1]; + if(gf->meshAttributes.recombine) + gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); + else if(gf->meshAttributes.transfiniteArrangement == 1 || + (gf->meshAttributes.transfiniteArrangement == 0 && + ((i % 2 == 0 && j % 2 == 1) || + (i % 2 == 1 && j % 2 == 0)))){ + gf->triangles.push_back(new MTriangle(v1, v2, v3)); + gf->triangles.push_back(new MTriangle(v3, v4, v1)); + } + else{ + gf->triangles.push_back(new MTriangle(v1, v2, v4)); + gf->triangles.push_back(new MTriangle(v4, v2, v3)); + } } } } @@ -386,23 +386,23 @@ int MeshTransfiniteSurface(GFace *gf) } for(int i = 1; i < L ; i++){ for(int j = 0; j < H; j++){ - MVertex *v1 = tab[i ][j ]; - MVertex *v2 = tab[i + 1][j ]; - MVertex *v3 = tab[i + 1][j + 1]; - MVertex *v4 = tab[i ][j + 1]; - if(gf->meshAttributes.recombine) - gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); - else if(gf->meshAttributes.transfiniteArrangement == 1 || - (gf->meshAttributes.transfiniteArrangement == 0 && - ((i % 2 == 0 && j % 2 == 1) || - (i % 2 == 1 && j % 2 == 0)))){ - gf->triangles.push_back(new MTriangle(v1, v2, v3)); - gf->triangles.push_back(new MTriangle(v3, v4, v1)); - } - else{ - gf->triangles.push_back(new MTriangle(v1, v2, v4)); - gf->triangles.push_back(new MTriangle(v4, v2, v3)); - } + MVertex *v1 = tab[i ][j ]; + MVertex *v2 = tab[i + 1][j ]; + MVertex *v3 = tab[i + 1][j + 1]; + MVertex *v4 = tab[i ][j + 1]; + if(gf->meshAttributes.recombine) + gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4)); + else if(gf->meshAttributes.transfiniteArrangement == 1 || + (gf->meshAttributes.transfiniteArrangement == 0 && + ((i % 2 == 0 && j % 2 == 1) || + (i % 2 == 1 && j % 2 == 0)))){ + gf->triangles.push_back(new MTriangle(v1, v2, v3)); + gf->triangles.push_back(new MTriangle(v3, v4, v1)); + } + else{ + gf->triangles.push_back(new MTriangle(v1, v2, v4)); + gf->triangles.push_back(new MTriangle(v4, v2, v3)); + } } } } diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp index bc598b00a2d705be0c2ac26b46c2b9a5b67ed8db..11646ceb5ec0d60324aa0cf92fe00ce9dd495f90 100644 --- a/Mesh/meshGRegion.cpp +++ b/Mesh/meshGRegion.cpp @@ -1,4 +1,4 @@ -// $Id: meshGRegion.cpp,v 1.44 2008-03-06 14:19:01 geuzaine Exp $ +// $Id: meshGRegion.cpp,v 1.45 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -43,8 +43,8 @@ void getAllBoundingVertices(GRegion *gr, std::set<MVertex*> &allBoundingVertices for(unsigned int i = 0; i < gf->triangles.size(); i++){ MTriangle *t = gf->triangles[i]; for(int k = 0; k < 3; k++) - if(allBoundingVertices.find(t->getVertex(k)) == allBoundingVertices.end()) - allBoundingVertices.insert(t->getVertex(k)); + if(allBoundingVertices.find(t->getVertex(k)) == allBoundingVertices.end()) + allBoundingVertices.insert(t->getVertex(k)); } ++it; } @@ -115,12 +115,12 @@ void buildTetgenStructure(GRegion *gr, tetgenio &in, std::vector<MVertex*> &numb } void TransferTetgenMesh(GRegion *gr, tetgenio &in, tetgenio &out, - std::vector<MVertex*> &numberedV) + std::vector<MVertex*> &numberedV) { for(int i = numberedV.size(); i < out.numberofpoints; i++){ MVertex *v = new MVertex(out.pointlist[i * 3 + 0], - out.pointlist[i * 3 + 1], - out.pointlist[i * 3 + 2], gr); + out.pointlist[i * 3 + 1], + out.pointlist[i * 3 + 2], gr); gr->mesh_vertices.push_back(v); numberedV.push_back(v); } @@ -157,21 +157,21 @@ void TransferTetgenMesh(GRegion *gr, tetgenio &in, tetgenio &out, v[1] = numberedV[out.trifacelist[i * 3 + 1] - 1]; v[2] = numberedV[out.trifacelist[i * 3 + 2] - 1]; GFace *gf = gr->model()->getFaceByTag(out.trifacemarkerlist[i]); - for(int j = 0; j < 3; j++){ + for(int j = 0; j < 3; j++){ if(v[j]->onWhat()->dim() == 3){ - v[j]->onWhat()->mesh_vertices.erase - (std::find(v[j]->onWhat()->mesh_vertices.begin(), - v[j]->onWhat()->mesh_vertices.end(), - v[j])); - MVertex *v1b = new MVertex(v[j]->x(), v[j]->y(), v[j]->z(), gf); - gf->mesh_vertices.push_back(v1b); - numberedV[out.trifacelist[i * 3 + j] - 1] = v1b; - delete v[j]; - v[j] = v1b; + v[j]->onWhat()->mesh_vertices.erase + (std::find(v[j]->onWhat()->mesh_vertices.begin(), + v[j]->onWhat()->mesh_vertices.end(), + v[j])); + MVertex *v1b = new MVertex(v[j]->x(), v[j]->y(), v[j]->z(), gf); + gf->mesh_vertices.push_back(v1b); + numberedV[out.trifacelist[i * 3 + j] - 1] = v1b; + delete v[j]; + v[j] = v1b; } } MTriangle *t = new MTriangle(v[0], v[1], v[2]); - gf->triangles.push_back(t); + gf->triangles.push_back(t); } for(int i = 0; i < out.numberoftetrahedra; i++){ MVertex *v1 = numberedV[out.tetrahedronlist[i * 4 + 0] - 1]; @@ -223,21 +223,21 @@ void MeshDelaunayVolume(std::vector<GRegion*> ®ions) } catch (int error){ Msg (WARNING, "Self intersecting Surface Mesh, computing intersections " - "(this could take a while)"); + "(this could take a while)"); sprintf(opts, "dV"); try{ - tetrahedralize(opts, &in, &out); - Msg(INFO,"%d faces self-intersect",out.numberoftrifaces); - for (int i = 0; i < out.numberoftrifaces; i++){ - Msg(INFO,"face (%d %d %d) on model face %d", - numberedV[out.trifacelist[i * 3 + 0] - 1]->getNum(), - numberedV[out.trifacelist[i * 3 + 1] - 1]->getNum(), - numberedV[out.trifacelist[i * 3 + 2] - 1]->getNum(), - out.trifacemarkerlist[i]); - } + tetrahedralize(opts, &in, &out); + Msg(INFO,"%d faces self-intersect",out.numberoftrifaces); + for (int i = 0; i < out.numberoftrifaces; i++){ + Msg(INFO,"face (%d %d %d) on model face %d", + numberedV[out.trifacelist[i * 3 + 0] - 1]->getNum(), + numberedV[out.trifacelist[i * 3 + 1] - 1]->getNum(), + numberedV[out.trifacelist[i * 3 + 2] - 1]->getNum(), + out.trifacemarkerlist[i]); + } } catch (int error2){ - Msg(GERROR, "Surface Mesh is wrong, cannot do the 3D mesh"); + Msg(GERROR, "Surface Mesh is wrong, cannot do the 3D mesh"); } gr->set(faces); return; @@ -271,7 +271,7 @@ namespace nglib { using namespace nglib; Ng_Mesh *buildNetgenStructure(GRegion *gr, bool importVolumeMesh, - std::vector<MVertex*> &numberedV) + std::vector<MVertex*> &numberedV) { NgAddOn_Init(); Ng_Mesh *ngmesh = Ng_NewMesh(); @@ -336,7 +336,7 @@ Ng_Mesh *buildNetgenStructure(GRegion *gr, bool importVolumeMesh, } void TransferVolumeMesh(GRegion *gr, Ng_Mesh *ngmesh, - std::vector<MVertex*> &numberedV) + std::vector<MVertex*> &numberedV) { // Gets total number of vertices of Netgen's mesh int nbv = Ng_GetNP(ngmesh); @@ -361,9 +361,9 @@ void TransferVolumeMesh(GRegion *gr, Ng_Mesh *ngmesh, int tmp[4]; Ng_GetVolumeElement(ngmesh, i + 1, tmp); MTetrahedron *t = new MTetrahedron(numberedV[tmp[0] - 1], - numberedV[tmp[1] - 1], - numberedV[tmp[2] - 1], - numberedV[tmp[3] - 1]); + numberedV[tmp[1] - 1], + numberedV[tmp[2] - 1], + numberedV[tmp[3] - 1]); gr->tetrahedra.push_back(t); } } @@ -394,7 +394,7 @@ void deMeshGRegion::operator() (GRegion *gr) } int intersect_line_triangle(double X[3], double Y[3], double Z[3] , - double P[3], double N[3] ) + double P[3], double N[3] ) { double mat[3][3], det; double b[3], res[3]; @@ -428,8 +428,8 @@ int intersect_line_triangle(double X[3], double Y[3], double Z[3] , return (res[2] > 0) ? 1 : 0; } else if(res[0] < -eps_prec || res[0] > 1.0 + eps_prec || - res[1] < -eps_prec || res[1] > 1.0 + eps_prec || - 1 - res[0] - res[1] < -eps_prec || 1 - res[0] - res[1] > 1.0 + eps_prec){ + res[1] < -eps_prec || res[1] > 1.0 + eps_prec || + 1 - res[0] - res[1] < -eps_prec || 1 - res[0] - res[1] > 1.0 + eps_prec){ // the line clearly does NOT intersect the triangle return 0; } @@ -452,7 +452,7 @@ void meshNormalsPointOutOfTheRegion(GRegion *gr) double rrr[6]; setRand(rrr); - + while(it != faces.end()){ GFace *gf = (*it); int nb_intersect = 0; @@ -475,21 +475,21 @@ void meshNormalsPointOutOfTheRegion(GRegion *gr) norme(N); std::list<GFace*>::iterator it_b = faces.begin(); while(it_b != faces.end()){ - GFace *gf_b = (*it_b); - for(unsigned int i_b = 0; i_b < gf_b->triangles.size(); i_b++){ - MTriangle *t_b = gf_b->triangles[i_b]; - if(t_b != t){ - double X_b[3] = {t_b->getVertex(0)->x(), t_b->getVertex(1)->x(), - t_b->getVertex(2)->x()}; - double Y_b[3] = {t_b->getVertex(0)->y(), t_b->getVertex(1)->y(), - t_b->getVertex(2)->y()}; - double Z_b[3] = {t_b->getVertex(0)->z(), t_b->getVertex(1)->z(), - t_b->getVertex(2)->z()}; - int inters = intersect_line_triangle(X_b, Y_b, Z_b, P, N); - nb_intersect += inters; - } - } - ++it_b; + GFace *gf_b = (*it_b); + for(unsigned int i_b = 0; i_b < gf_b->triangles.size(); i_b++){ + MTriangle *t_b = gf_b->triangles[i_b]; + if(t_b != t){ + double X_b[3] = {t_b->getVertex(0)->x(), t_b->getVertex(1)->x(), + t_b->getVertex(2)->x()}; + double Y_b[3] = {t_b->getVertex(0)->y(), t_b->getVertex(1)->y(), + t_b->getVertex(2)->y()}; + double Z_b[3] = {t_b->getVertex(0)->z(), t_b->getVertex(1)->z(), + t_b->getVertex(2)->z()}; + int inters = intersect_line_triangle(X_b, Y_b, Z_b, P, N); + nb_intersect += inters; + } + } + ++it_b; } Msg(INFO,"Region %d Face %d, %d intersect", gr->tag(), gf->tag(), nb_intersect); if(nb_intersect >= 0) break; // negative value means intersection is not "robust" @@ -500,10 +500,10 @@ void meshNormalsPointOutOfTheRegion(GRegion *gr) } else{ if(nb_intersect % 2 == 1){ - // odd nb of intersections: the normal points inside the region - for (unsigned int i = 0; i < gf->triangles.size(); i++){ - gf->triangles[i]->revert(); - } + // odd nb of intersections: the normal points inside the region + for (unsigned int i = 0; i < gf->triangles.size(); i++){ + gf->triangles[i]->revert(); + } } ++it; } @@ -625,7 +625,7 @@ bool buildFaceSearchStructure(GModel *model, fs_cont &search) MVertex *p3 = (*fit)->triangles[i]->getVertex(2); MVertex *p = std::min(p1, std::min(p2, p3)); search.insert(std::pair<MVertex*, std::pair<MTriangle*, GFace*> > - (p, std::pair<MTriangle*, GFace*>((*fit)->triangles[i], *fit))); + (p, std::pair<MTriangle*, GFace*>((*fit)->triangles[i], *fit))); } ++fit; } @@ -643,7 +643,7 @@ bool buildEdgeSearchStructure(GModel *model, es_cont &search) MVertex *p2 = (*eit)->lines[i]->getVertex(1); MVertex *p = std::min(p1, p2); search.insert(std::pair<MVertex*, std::pair<MLine*, GEdge*> > - (p, std::pair<MLine*, GEdge*>((*eit)->lines[i], *eit))); + (p, std::pair<MLine*, GEdge*>((*eit)->lines[i], *eit))); } ++eit; } @@ -651,7 +651,7 @@ bool buildEdgeSearchStructure(GModel *model, es_cont &search) } GFace *findInFaceSearchStructure(MVertex *p1, MVertex *p2, MVertex *p3, - const fs_cont &search) + const fs_cont &search) { MVertex *p = std::min(p1, std::min(p2, p3)); @@ -678,7 +678,7 @@ GEdge *findInEdgeSearchStructure(MVertex *p1, MVertex *p2, const es_cont &search MLine *l = it->second.first; GEdge *ge = it->second.second; if ((l->getVertex(0) == p1 || l->getVertex(0) == p2) && - (l->getVertex(1) == p1 || l->getVertex(1) == p2)) + (l->getVertex(1) == p1 || l->getVertex(1) == p2)) return ge; } return 0; diff --git a/Mesh/meshGRegionCarveHole.cpp b/Mesh/meshGRegionCarveHole.cpp index c70d0e69ae5c331122bb612165aae97cc7a33cf5..cce32c05e39584c799c4069a43a9cd6eb70df163 100644 --- a/Mesh/meshGRegionCarveHole.cpp +++ b/Mesh/meshGRegionCarveHole.cpp @@ -1,4 +1,4 @@ -// $Id: meshGRegionCarveHole.cpp,v 1.6 2008-02-22 21:09:01 geuzaine Exp $ +// $Id: meshGRegionCarveHole.cpp,v 1.7 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -50,8 +50,8 @@ void carveHole(std::vector<T*> &elements, double distance, ANNkd_tree *kdtree) kdtree->annkSearch(xyz, 1, index, dist); double d = sqrt(dist[0]); if(d < distance){ - delete elements[i]; - break; + delete elements[i]; + break; } else if(j == elements[i]->getNumVertices() - 1){ temp.push_back(elements[i]); @@ -71,9 +71,9 @@ void addFaces(std::vector<T*> &elements, std::set<MFace, Less_Face> &faces) MFace f = elements[i]->getFace(j); std::set<MFace, Less_Face>::iterator it = faces.find(f); if(it == faces.end()) - faces.insert(f); + faces.insert(f); else - faces.erase(it); + faces.erase(it); } } } @@ -143,10 +143,10 @@ void carveHole(GRegion *gr, int num, double distance, std::vector<int> &surfaces } if(it->getNumVertices() == 3) gf->triangles.push_back(new MTriangle(it->getVertex(0), it->getVertex(1), - it->getVertex(2))); + it->getVertex(2))); else if(it->getNumVertices() == 4) gf->quadrangles.push_back(new MQuadrangle(it->getVertex(0), it->getVertex(1), - it->getVertex(2), it->getVertex(3))); + it->getVertex(2), it->getVertex(3))); } } diff --git a/Mesh/meshGRegionDelaunayInsertion.cpp b/Mesh/meshGRegionDelaunayInsertion.cpp index f903157c0237451014e0e20ead27493ac1e867b8..0091f290a59119f0955bdd835112a2447670f43b 100644 --- a/Mesh/meshGRegionDelaunayInsertion.cpp +++ b/Mesh/meshGRegionDelaunayInsertion.cpp @@ -1,4 +1,4 @@ -// $Id: meshGRegionDelaunayInsertion.cpp,v 1.42 2008-03-19 21:22:36 geuzaine Exp $ +// $Id: meshGRegionDelaunayInsertion.cpp,v 1.43 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -35,17 +35,17 @@ int MTet4::inCircumSphere(const double *p) const { double pa[3] = {base->getVertex(0)->x(), - base->getVertex(0)->y(), - base->getVertex(0)->z()}; + base->getVertex(0)->y(), + base->getVertex(0)->z()}; double pb[3] = {base->getVertex(1)->x(), - base->getVertex(1)->y(), - base->getVertex(1)->z()}; + base->getVertex(1)->y(), + base->getVertex(1)->z()}; double pc[3] = {base->getVertex(2)->x(), - base->getVertex(2)->y(), - base->getVertex(2)->z()}; + base->getVertex(2)->y(), + base->getVertex(2)->z()}; double pd[3] = {base->getVertex(3)->x(), - base->getVertex(3)->y(), - base->getVertex(3)->z()}; + base->getVertex(3)->y(), + base->getVertex(3)->z()}; double result = gmsh::insphere(pa, pb, pc, pd, (double*)p) * gmsh::orient3d(pa, pb, pc, pd); return (result > 0) ? 1 : 0; @@ -82,14 +82,14 @@ void connectTets(ITER beg, ITER end) while (beg != end){ if (!(*beg)->isDeleted()){ for (int i = 0; i < 4; i++){ - faceXtet fxt(*beg, i); - std::set<faceXtet>::iterator found = conn.find(fxt); - if (found == conn.end()) - conn.insert(fxt); - else if (found->t1 != *beg){ - found->t1->setNeigh(found->i1, *beg); - (*beg)->setNeigh(i, found->t1); - } + faceXtet fxt(*beg, i); + std::set<faceXtet>::iterator found = conn.find(fxt); + if (found == conn.end()) + conn.insert(fxt); + else if (found->t1 != *beg){ + found->t1->setNeigh(found->i1, *beg); + (*beg)->setNeigh(i, found->t1); + } } } ++beg; @@ -100,9 +100,9 @@ void connectTets(std::list<MTet4*> &l) { connectTets(l.begin(), l.end()); } void connectTets(std::vector<MTet4*> &l) { connectTets(l.begin(), l.end()); } void recurFindCavity(std::list<faceXtet> & shell, - std::list<MTet4*> & cavity, - MVertex *v , - MTet4 *t) + std::list<MTet4*> & cavity, + MVertex *v , + MTet4 *t) { // Msg(INFO,"tet %d %d %d %d",t->tet()->getVertex(0)->getNum(), // t->tet()->getVertex(1)->getNum(), @@ -124,19 +124,19 @@ void recurFindCavity(std::list<faceXtet> & shell, else if (!neigh->isDeleted()){ int circ = neigh->inCircumSphere(v); if (circ && (neigh->onWhat() == t->onWhat())) - recurFindCavity(shell, cavity, v, neigh); + recurFindCavity(shell, cavity, v, neigh); else - shell.push_back(faceXtet(t, i)); + shell.push_back(faceXtet(t, i)); } } } bool insertVertex(MVertex *v, - MTet4 *t, - MTet4Factory &myFactory, - std::set<MTet4*,compareTet4Ptr> &allTets, - std::vector<double> & vSizes, - std::vector<double> & vSizesBGM) + MTet4 *t, + MTet4Factory &myFactory, + std::set<MTet4*,compareTet4Ptr> &allTets, + std::vector<double> & vSizes, + std::vector<double> & vSizesBGM) { std::list<faceXtet> shell; std::list<MTet4*> cavity; @@ -160,18 +160,18 @@ bool insertVertex(MVertex *v, while (ittet != ittete){ oldVolume += fabs((*ittet)->getVolume()); // fprintf(ff2,"SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g) {0,0,0,0};\n", -// (*ittet)->tet()->getVertex(0)->x(), -// (*ittet)->tet()->getVertex(0)->y(), -// (*ittet)->tet()->getVertex(0)->z(), -// (*ittet)->tet()->getVertex(1)->x(), -// (*ittet)->tet()->getVertex(1)->y(), -// (*ittet)->tet()->getVertex(1)->z(), -// (*ittet)->tet()->getVertex(2)->x(), -// (*ittet)->tet()->getVertex(2)->y(), -// (*ittet)->tet()->getVertex(2)->z(), -// (*ittet)->tet()->getVertex(3)->x(), -// (*ittet)->tet()->getVertex(3)->y(), -// (*ittet)->tet()->getVertex(3)->z()); +// (*ittet)->tet()->getVertex(0)->x(), +// (*ittet)->tet()->getVertex(0)->y(), +// (*ittet)->tet()->getVertex(0)->z(), +// (*ittet)->tet()->getVertex(1)->x(), +// (*ittet)->tet()->getVertex(1)->y(), +// (*ittet)->tet()->getVertex(1)->z(), +// (*ittet)->tet()->getVertex(2)->x(), +// (*ittet)->tet()->getVertex(2)->y(), +// (*ittet)->tet()->getVertex(2)->z(), +// (*ittet)->tet()->getVertex(3)->x(), +// (*ittet)->tet()->getVertex(3)->y(), +// (*ittet)->tet()->getVertex(3)->z()); // if(!(*ittet)->inCircumSphere ( v ))throw; ++ittet; } @@ -199,15 +199,15 @@ bool insertVertex(MVertex *v, MTetrahedron *tr = new MTetrahedron(it->v[0], it->v[1], it->v[2], v); // Msg(INFO,"shell %d %d %d",it->v[0]->getNum(),it->v[1]->getNum(),it->v[2]->getNum()); // fprintf(ff,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g) {0,0,0};\n", -// it->v[0]->x(), -// it->v[0]->y(), -// it->v[0]->z(), -// it->v[1]->x(), -// it->v[1]->y(), -// it->v[1]->z(), -// it->v[2]->x(), -// it->v[2]->y(), -// it->v[2]->z()); +// it->v[0]->x(), +// it->v[0]->y(), +// it->v[0]->z(), +// it->v[1]->x(), +// it->v[1]->y(), +// it->v[1]->z(), +// it->v[2]->x(), +// it->v[2]->y(), +// it->v[2]->z()); MTet4 *t4 = myFactory.Create(tr, vSizes, vSizesBGM); t4->setOnWhat(t->onWhat()); @@ -220,7 +220,7 @@ bool insertVertex(MVertex *v, MTet4 *otherSide = it->t1->getNeigh(it->i1); if (otherSide) - new_cavity.push_back(otherSide); + new_cavity.push_back(otherSide); // if (!it->t1->isDeleted())throw; newVolume += fabs(t4->getVolume()); ++it; @@ -236,8 +236,8 @@ bool insertVertex(MVertex *v, // ittet = cavity.begin(); // ittete = cavity.end(); // while ( ittet != ittete ){ -// myFactory.Free (*ittet); -// ++ittet; +// myFactory.Free (*ittet); +// ++ittet; // } delete [] newTets; return true; @@ -265,8 +265,8 @@ static void setLcs(MTetrahedron *t, std::map<MVertex*, double> &vSizes) double dy = vi->y()-vj->y(); double dz = vi->z()-vj->z(); double l = sqrt(dx * dx + dy * dy + dz * dz); - std::map<MVertex*,double>::iterator iti = vSizes.find(vi); - std::map<MVertex*,double>::iterator itj = vSizes.find(vj); + std::map<MVertex*,double>::iterator iti = vSizes.find(vi); + std::map<MVertex*,double>::iterator itj = vSizes.find(vj); if (iti == vSizes.end() || iti->second > l) vSizes[vi] = l; if (itj == vSizes.end() || itj->second > l) vSizes[vj] = l; } @@ -291,8 +291,8 @@ bool find_triangle_in_model(GModel *model, MTriangle *tri, GFace **gfound, bool GModel::fiter fit = model->firstFace() ; while (fit != model->lastFace()){ bool found = std::binary_search((*fit)->triangles.begin(), - (*fit)->triangles.end(), - tri, cmp); + (*fit)->triangles.end(), + tri, cmp); if(found){ *gfound = *fit; return true; @@ -303,7 +303,7 @@ bool find_triangle_in_model(GModel *model, MTriangle *tri, GFace **gfound, bool } GRegion *getRegionFromBoundingFaces(GModel *model, - std::set<GFace *> &faces_bound) + std::set<GFace *> &faces_bound) { GModel::riter git = model->firstRegion(); while (git != model->lastRegion()){ @@ -311,7 +311,7 @@ GRegion *getRegionFromBoundingFaces(GModel *model, if(_faces.size() == faces_bound.size()){ bool ok = true; for (std::list<GFace *>::iterator it = _faces.begin(); it != _faces.end(); ++it){ - if(faces_bound.find (*it) == faces_bound.end()) ok = false; + if(faces_bound.find (*it) == faces_bound.end()) ok = false; } if (ok) return *git; } @@ -320,9 +320,9 @@ GRegion *getRegionFromBoundingFaces(GModel *model, return 0; } -void recur_classify(MTet4 *t, std::list<MTet4*> &theRegion, - std::set<GFace*> &faces_bound, GRegion *bidon, - GModel *model, const fs_cont &search) +void recur_classify(MTet4 *t, std::list<MTet4*> &theRegion, + std::set<GFace*> &faces_bound, GRegion *bidon, + GModel *model, const fs_cont &search) { if (!t) Msg (GERROR,"a tet is not connected by a boundary face"); if (t->onWhat()) return; // should never return here... @@ -335,23 +335,23 @@ void recur_classify(MTet4 *t, std::list<MTet4*> &theRegion, // if (!t->getNeigh(i) || !t->getNeigh(i)->onWhat()) { GFace* gfound = findInFaceSearchStructure (t->tet()->getVertex(faces[i][0]), - t->tet()->getVertex(faces[i][1]), - t->tet()->getVertex(faces[i][2]), - search); + t->tet()->getVertex(faces[i][1]), + t->tet()->getVertex(faces[i][2]), + search); if (gfound){ - FF[i] = true; - if (faces_bound.find(gfound) == faces_bound.end()) - faces_bound.insert(gfound); + FF[i] = true; + if (faces_bound.find(gfound) == faces_bound.end()) + faces_bound.insert(gfound); } -// MTriangle tri (t->tet()->getVertex (faces[i][0]), -// t->tet()->getVertex (faces[i][1]), -// t->tet()->getVertex (faces[i][2])); -// GFace *gfound; -// if (FF[i] = find_triangle_in_model(model, &tri, &gfound, false)){ -// if (faces_bound.find(gfound) == faces_bound.end()) -// faces_bound.insert(gfound); -// } +// MTriangle tri (t->tet()->getVertex (faces[i][0]), +// t->tet()->getVertex (faces[i][1]), +// t->tet()->getVertex (faces[i][2])); +// GFace *gfound; +// if (FF[i] = find_triangle_in_model(model, &tri, &gfound, false)){ +// if (faces_bound.find(gfound) == faces_bound.end()) +// faces_bound.insert(gfound); +// } } } for (int i = 0; i < 4; i++){ @@ -385,27 +385,27 @@ void adaptMeshGRegion::operator () (GRegion *gr) for (int i = 0; i < nbRanges; i++) quality_ranges[i] = 0; for (CONTAINER::iterator it = allTets.begin();it!=allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double vol = fabs((*it)->tet()->getVolume()); - double qual = (*it)->getQuality(); - worst = std::min(qual, worst); - avg += qual; - count++; - totalVolumeb += vol; - for (int i = 0; i < nbRanges; i++){ - double low = (double)i / nbRanges; - double high = (double)(i + 1) / nbRanges; - if (qual >= low && qual < high) quality_ranges[i]++; - } + double vol = fabs((*it)->tet()->getVolume()); + double qual = (*it)->getQuality(); + worst = std::min(qual, worst); + avg += qual; + count++; + totalVolumeb += vol; + for (int i = 0; i < nbRanges; i++){ + double low = (double)i / nbRanges; + double high = (double)(i + 1) / nbRanges; + if (qual >= low && qual < high) quality_ranges[i]++; + } } } Msg(INFO,"Adaptation : START with %12.5E QBAD %12.5E QAVG %12.5E", - totalVolumeb, worst, avg / count); + totalVolumeb, worst, avg / count); for (int i = 0; i < nbRanges; i++){ double low = (double)i / nbRanges; double high = (double)(i + 1) / nbRanges; Msg(INFO,"Opti : %3.2f < QUAL < %3.2f : %9d elements ", - low, high, quality_ranges[i]); - } + low, high, quality_ranges[i]); + } } double qMin = 0.5; @@ -417,13 +417,13 @@ void adaptMeshGRegion::operator () (GRegion *gr) std::vector<MTet4*> newTets; for (CONTAINER::iterator it = allTets.begin(); it!=allTets.end(); ++it){ if (!(*it)->isDeleted()){ - for (int i = 0; i < 4; i++){ - for (int j = 0; j < 4; j++){ - if (gmshCollapseVertex(newTets, *it, i, j, QMTET_2)){ - nbCollapse++; i = j = 10; - } - } - } + for (int i = 0; i < 4; i++){ + for (int j = 0; j < 4; j++){ + if (gmshCollapseVertex(newTets, *it, i, j, QMTET_2)){ + nbCollapse++; i = j = 10; + } + } + } } } @@ -431,15 +431,15 @@ void adaptMeshGRegion::operator () (GRegion *gr) for (CONTAINER::iterator it = allTets.begin(); it!=allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double qq = (*it)->getQuality(); - if (qq < qMin){ - for (int i = 0; i < 4; i++){ - if (gmshFaceSwap(newTets, *it, i, qm)){ - nbFSwap++; - break; - } - } - } + double qq = (*it)->getQuality(); + if (qq < qMin){ + for (int i = 0; i < 4; i++){ + if (gmshFaceSwap(newTets, *it, i, qm)){ + nbFSwap++; + break; + } + } + } } } @@ -448,22 +448,22 @@ void adaptMeshGRegion::operator () (GRegion *gr) for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double qq = (*it)->getQuality(); - if (qq < qMin) - for (int i = 0; i < 6; i++){ - if (gmshEdgeSwap(newTets, *it, i, qm)) { - nbESwap++; - break; - } - } - if (!(*it)->isDeleted()){ - if (qq < sliverLimit) illegals.push_back(*it); - for (int i = 0; i < nbRanges; i++){ - double low = (double)i / nbRanges; - double high = (double)(i + 1)/ nbRanges; - if (qq >= low && qq < high) quality_ranges[i]++; - } - } + double qq = (*it)->getQuality(); + if (qq < qMin) + for (int i = 0; i < 6; i++){ + if (gmshEdgeSwap(newTets, *it, i, qm)) { + nbESwap++; + break; + } + } + if (!(*it)->isDeleted()){ + if (qq < sliverLimit) illegals.push_back(*it); + for (int i = 0; i < nbRanges; i++){ + double low = (double)i / nbRanges; + double high = (double)(i + 1)/ nbRanges; + if (qq >= low && qq < high) quality_ranges[i]++; + } + } } } @@ -472,22 +472,22 @@ void adaptMeshGRegion::operator () (GRegion *gr) // add all the new tets in the container for(unsigned int i = 0; i < newTets.size(); i++){ if(!newTets[i]->isDeleted()){ - allTets.push_back(newTets[i]); + allTets.push_back(newTets[i]); } else{ - delete newTets[i]->tet(); - delete newTets[i]; + delete newTets[i]->tet(); + delete newTets[i]; } } // relocate vertices for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double qq = (*it)->getQuality(); - if (qq < qMin) - for (int i = 0; i < 4; i++){ - if (gmshSmoothVertex(*it, i, qm)) nbReloc++; - } + double qq = (*it)->getQuality(); + if (qq < qMin) + for (int i = 0; i < 4; i++){ + if (gmshSmoothVertex(*it, i, qm)) nbReloc++; + } } } @@ -497,17 +497,17 @@ void adaptMeshGRegion::operator () (GRegion *gr) int count = 0; for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double vol = fabs((*it)->tet()->getVolume()); - double qual = (*it)->getQuality(); - worst = std::min(qual, worst); - avg += qual; - count++; - totalVolumeb += vol; + double vol = fabs((*it)->tet()->getVolume()); + double qual = (*it)->getQuality(); + worst = std::min(qual, worst); + avg += qual; + count++; + totalVolumeb += vol; } } double t2 = Cpu(); Msg(INFO,"Opti : (%d,%d,%d) = %12.5E QBAD %12.5E QAVG %12.5E (%8.3f sec)", - nbESwap, nbFSwap, nbReloc, totalVolumeb, worst, avg / count, t2 - t1); + nbESwap, nbFSwap, nbReloc, totalVolumeb, worst, avg / count, t2 - t1); break; } @@ -517,7 +517,7 @@ void adaptMeshGRegion::operator () (GRegion *gr) if (nbSlivers){ Msg(INFO,"Opti : %d illegal tets are still in the mesh, trying to remove them", - nbSlivers); + nbSlivers); } else{ Msg(INFO,"Opti : no illegal tets in the mesh ;-)", nbSlivers); @@ -527,8 +527,8 @@ void adaptMeshGRegion::operator () (GRegion *gr) double low = (double)i / nbRanges; double high = (double)(i + 1) / nbRanges; Msg(INFO,"Opti : %3.2f < QUAL < %3.2f : %9d elements", - low, high, quality_ranges[i]); - } + low, high, quality_ranges[i]); + } for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ @@ -537,7 +537,7 @@ void adaptMeshGRegion::operator () (GRegion *gr) } else{ delete (*it)->tet(); - delete *it; + delete *it; } } } @@ -568,27 +568,27 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) for (int i = 0; i < nbRanges; i++) quality_ranges[i] = 0; for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double vol = fabs((*it)->tet()->getVolume()); - double qual = (*it)->getQuality(); - worst = std::min(qual, worst); - avg += qual; - count++; - totalVolumeb += vol; - for (int i = 0; i < nbRanges; i++){ - double low = (double)i / nbRanges; - double high = (double)(i + 1) / nbRanges; - if (qual >= low && qual < high) quality_ranges[i]++; - } + double vol = fabs((*it)->tet()->getVolume()); + double qual = (*it)->getQuality(); + worst = std::min(qual, worst); + avg += qual; + count++; + totalVolumeb += vol; + for (int i = 0; i < nbRanges; i++){ + double low = (double)i / nbRanges; + double high = (double)(i + 1) / nbRanges; + if (qual >= low && qual < high) quality_ranges[i]++; + } } } Msg(INFO,"Opti : START with %12.5E QBAD %12.5E QAVG %12.5E", - totalVolumeb, worst, avg / count); + totalVolumeb, worst, avg / count); for (int i = 0; i < nbRanges; i++){ double low = (double)i / nbRanges; double high = (double)(i + 1) / nbRanges; Msg(INFO,"Opti : %3.2f < QUAL < %3.2f : %9d elements", - low, high, quality_ranges[i]); - } + low, high, quality_ranges[i]); + } } double qMin = 0.5; @@ -600,15 +600,15 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) std::vector<MTet4*> newTets; for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double qq = (*it)->getQuality(); - if (qq < qMin){ - for (int i = 0; i < 4; i++){ - if (gmshFaceSwap(newTets, *it, i, qm)){ - nbFSwap++; - break; - } - } - } + double qq = (*it)->getQuality(); + if (qq < qMin){ + for (int i = 0; i < 4; i++){ + if (gmshFaceSwap(newTets, *it, i, qm)){ + nbFSwap++; + break; + } + } + } } } @@ -617,22 +617,22 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double qq = (*it)->getQuality(); - if (qq < qMin) - for (int i = 0; i < 6; i++){ - if (gmshEdgeSwap(newTets, *it, i, qm)) { - nbESwap++; - break; - } - } - if (!(*it)->isDeleted()){ - if (qq < sliverLimit) illegals.push_back(*it); - for (int i = 0; i < nbRanges; i++){ - double low = (double)i / nbRanges; - double high = (double)(i + 1) / nbRanges; - if (qq >= low && qq < high) quality_ranges[i]++; - } - } + double qq = (*it)->getQuality(); + if (qq < qMin) + for (int i = 0; i < 6; i++){ + if (gmshEdgeSwap(newTets, *it, i, qm)) { + nbESwap++; + break; + } + } + if (!(*it)->isDeleted()){ + if (qq < sliverLimit) illegals.push_back(*it); + for (int i = 0; i < nbRanges; i++){ + double low = (double)i / nbRanges; + double high = (double)(i + 1) / nbRanges; + if (qq >= low && qq < high) quality_ranges[i]++; + } + } } } @@ -640,11 +640,11 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) int nbSlivers = 0; int nbSliversWeCanDoSomething = 0; for(unsigned int i = 0; i < illegals.size(); i++) - if(!(illegals[i]->isDeleted())){ - if(gmshSliverRemoval(newTets, illegals[i], qm)) - nbSliversWeCanDoSomething++; - nbSlivers++; - } + if(!(illegals[i]->isDeleted())){ + if(gmshSliverRemoval(newTets, illegals[i], qm)) + nbSliversWeCanDoSomething++; + nbSlivers++; + } Msg(INFO, "Opti : %d Sliver Removals", nbSliversWeCanDoSomething); } @@ -655,22 +655,22 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) // add all the new tets in the container for(unsigned int i = 0; i < newTets.size(); i++){ if(!newTets[i]->isDeleted()){ - allTets.push_back(newTets[i]); + allTets.push_back(newTets[i]); } else{ - delete newTets[i]->tet(); - delete newTets[i]; + delete newTets[i]->tet(); + delete newTets[i]; } } // relocate vertices for (CONTAINER::iterator it = allTets.begin();it!=allTets.end();++it){ if (!(*it)->isDeleted()){ - double qq = (*it)->getQuality(); - if (qq < qMin) - for (int i = 0; i < 4; i++){ - if (gmshSmoothVertex(*it, i, qm)) nbReloc++; - } + double qq = (*it)->getQuality(); + if (qq < qMin) + for (int i = 0; i < 4; i++){ + if (gmshSmoothVertex(*it, i, qm)) nbReloc++; + } } } @@ -680,17 +680,17 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) int count = 0; for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ - double vol = fabs((*it)->tet()->getVolume()); - double qual = (*it)->getQuality(); - worst = std::min(qual, worst); - avg += qual; - count++; - totalVolumeb += vol; + double vol = fabs((*it)->tet()->getVolume()); + double qual = (*it)->getQuality(); + worst = std::min(qual, worst); + avg += qual; + count++; + totalVolumeb += vol; } } double t2 = Cpu(); Msg(INFO, "Opti : (%d,%d,%d) = %12.5E QBAD %12.5E QAVG %12.5E (%8.3f sec)", - nbESwap, nbFSwap, nbReloc, totalVolumeb, worst, avg / count, t2 - t1); + nbESwap, nbFSwap, nbReloc, totalVolumeb, worst, avg / count, t2 - t1); } if (illegals.size()){ @@ -704,8 +704,8 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) double low = (double)i / nbRanges; double high = (double)(i + 1) / nbRanges; Msg(INFO,"Opti : %3.2f < QUAL < %3.2f : %9d elements", - low, high, quality_ranges[i]); - } + low, high, quality_ranges[i]); + } for (CONTAINER::iterator it = allTets.begin(); it != allTets.end(); ++it){ if (!(*it)->isDeleted()){ @@ -714,7 +714,7 @@ void gmshOptimizeMesh(GRegion *gr, const gmshQualityMeasure4Tet &qm) } else{ delete (*it)->tet(); - delete *it; + delete *it; } } } @@ -735,7 +735,7 @@ void insertVerticesInRegion (GRegion *gr) for(unsigned int i = 0; i < gr->tetrahedra.size(); i++) setLcs(gr->tetrahedra[i], vSizesMap); for(std::map<MVertex*, double>::iterator it = vSizesMap.begin(); - it != vSizesMap.end(); ++it){ + it != vSizesMap.end(); ++it){ it->first->setNum(NUM++); vSizes.push_back(it->second); vSizesBGM.push_back(it->second); @@ -760,19 +760,19 @@ void insertVerticesInRegion (GRegion *gr) std::set<GFace *> faces_bound; GRegion *bidon = (GRegion*)123; double _t1 = Cpu(); - Msg(DEBUG2,"start with a non classified tet"); + Msg(DEBUG2,"start with a non classified tet"); recur_classify(*it, theRegion, faces_bound, bidon, gr->model(), search); double _t2 = Cpu(); Msg(DEBUG2, "found %d tets with %d faces (%g sec for the classification)", - theRegion.size(), faces_bound.size(), _t2 - _t1); + theRegion.size(), faces_bound.size(), _t2 - _t1); GRegion *myGRegion = getRegionFromBoundingFaces(gr->model(), faces_bound); // Msg (INFO,"a region is found %p",myGRegion); if(myGRegion) // a geometrical region associated to the list of faces has been found - for(std::list<MTet4*>::iterator it2 = theRegion.begin(); - it2 != theRegion.end(); ++it2) (*it2)->setOnWhat(myGRegion); + for(std::list<MTet4*>::iterator it2 = theRegion.begin(); + it2 != theRegion.end(); ++it2) (*it2)->setOnWhat(myGRegion); else // the tets are in the void - for(std::list<MTet4*>::iterator it2 = theRegion.begin(); - it2 != theRegion.end(); ++it2)(*it2)->setDeleted(true); + for(std::list<MTet4*>::iterator it2 = theRegion.begin(); + it2 != theRegion.end(); ++it2)(*it2)->setDeleted(true); } } search.clear(); @@ -805,35 +805,35 @@ void insertVerticesInRegion (GRegion *gr) } else{ if(ITER++ %5000 == 0) - Msg(INFO, "%d points created -- Worst tet radius is %g", - vSizes.size(), worst->getRadius()); + Msg(INFO, "%d points created -- Worst tet radius is %g", + vSizes.size(), worst->getRadius()); if(worst->getRadius() < 1) break; double center[3]; worst->circumcenter(center); double uvw[3]; worst->tet()->xyz2uvw(center, uvw); if(worst->tet()->isInside(uvw[0], uvw[1], uvw[2])){ - MVertex *v = new MVertex(center[0], center[1], center[2], worst->onWhat()); - v->setNum(NUM++); - double lc1 = - (1 - uvw[0] - uvw[1] - uvw[2]) * vSizes[worst->tet()->getVertex(0)->getNum()] + - uvw[0] * vSizes[worst->tet()->getVertex(1)->getNum()] + - uvw[1] * vSizes[worst->tet()->getVertex(2)->getNum()] + - uvw[2] * vSizes[worst->tet()->getVertex(3)->getNum()]; - double lc = BGM_MeshSize(gr, 0, 0, center[0], center[1], center[2]); - // double lc = std::min(lc1, BGM_MeshSize(gr, 0, 0, center[0], center[1], center[2])); - vSizes.push_back(lc1); - vSizesBGM.push_back(lc); - // compute mesh spacing there - if(!insertVertex(v, worst, myFactory, allTets, vSizes,vSizesBGM)){ - myFactory.changeTetRadius(allTets.begin(), 0.); - delete v; - } - else - v->onWhat()->mesh_vertices.push_back(v); + MVertex *v = new MVertex(center[0], center[1], center[2], worst->onWhat()); + v->setNum(NUM++); + double lc1 = + (1 - uvw[0] - uvw[1] - uvw[2]) * vSizes[worst->tet()->getVertex(0)->getNum()] + + uvw[0] * vSizes[worst->tet()->getVertex(1)->getNum()] + + uvw[1] * vSizes[worst->tet()->getVertex(2)->getNum()] + + uvw[2] * vSizes[worst->tet()->getVertex(3)->getNum()]; + double lc = BGM_MeshSize(gr, 0, 0, center[0], center[1], center[2]); + // double lc = std::min(lc1, BGM_MeshSize(gr, 0, 0, center[0], center[1], center[2])); + vSizes.push_back(lc1); + vSizesBGM.push_back(lc); + // compute mesh spacing there + if(!insertVertex(v, worst, myFactory, allTets, vSizes,vSizesBGM)){ + myFactory.changeTetRadius(allTets.begin(), 0.); + delete v; + } + else + v->onWhat()->mesh_vertices.push_back(v); } else{ - myFactory.changeTetRadius(allTets.begin(), 0.); + myFactory.changeTetRadius(allTets.begin(), 0.); } } @@ -844,12 +844,12 @@ void insertVerticesInRegion (GRegion *gr) int n1 = allTets.size(); std::set<MTet4*,compareTet4Ptr>::iterator itd = allTets.begin(); while(itd != allTets.end()){ - if((*itd)->isDeleted()){ - myFactory.Free((*itd)); - allTets.erase(itd++); - } - else - itd++; + if((*itd)->isDeleted()){ + myFactory.Free((*itd)); + allTets.erase(itd++); + } + else + itd++; } Msg(INFO,"cleaning up the memory %d -> %d", n1, allTets.size()); } diff --git a/Mesh/meshGRegionDelaunayInsertion.h b/Mesh/meshGRegionDelaunayInsertion.h index ff09da3593f4c0c4eaa4ad31f8c99592fe518349..c007fc31af58a65c3116cc5dc5d5dece72f51146 100644 --- a/Mesh/meshGRegionDelaunayInsertion.h +++ b/Mesh/meshGRegionDelaunayInsertion.h @@ -129,13 +129,13 @@ class MTet4 const double dz = base->getVertex(0)->z() - center[2]; circum_radius = sqrt(dx * dx + dy * dy + dz * dz); double lc1 = 0.25*(sizes[base->getVertex(0)->getNum()]+ - sizes[base->getVertex(1)->getNum()]+ - sizes[base->getVertex(2)->getNum()]+ - sizes[base->getVertex(3)->getNum()]); + sizes[base->getVertex(1)->getNum()]+ + sizes[base->getVertex(2)->getNum()]+ + sizes[base->getVertex(3)->getNum()]); double lcBGM = 0.25*(sizesBGM[base->getVertex(0)->getNum()]+ - sizesBGM[base->getVertex(1)->getNum()]+ - sizesBGM[base->getVertex(2)->getNum()]+ - sizesBGM[base->getVertex(3)->getNum()]); + sizesBGM[base->getVertex(1)->getNum()]+ + sizesBGM[base->getVertex(2)->getNum()]+ + sizesBGM[base->getVertex(3)->getNum()]); double lc = Extend2dMeshIn3dVolumes() ? std::min(lc1, lcBGM) : lcBGM; circum_radius /= lc; deleted = false; @@ -239,7 +239,7 @@ class MTet4Factory #endif } MTet4 *Create(MTetrahedron * t, std::vector<double> &sizes, - std::vector<double> &sizesBGM) + std::vector<double> &sizesBGM) { #ifdef _GMSH_PRE_ALLOCATE_STRATEGY_ MTet4 *t4 = getAnEmptySlot(); diff --git a/Mesh/meshGRegionExtruded.cpp b/Mesh/meshGRegionExtruded.cpp index 95c9756f9852320652065a55200cd65020290700..4c18effc3ed2830b0e2b83e92d813a29c7e7497f 100644 --- a/Mesh/meshGRegionExtruded.cpp +++ b/Mesh/meshGRegionExtruded.cpp @@ -1,4 +1,4 @@ -// $Id: meshGRegionExtruded.cpp,v 1.23 2008-02-22 21:09:01 geuzaine Exp $ +// $Id: meshGRegionExtruded.cpp,v 1.24 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -93,8 +93,8 @@ void createTet(MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, GRegion *to) } int getExtrudedVertices(MElement *ele, ExtrudeParams *ep, int j, int k, - std::set<MVertex*, MVertexLessThanLexicographic> &pos, - std::vector<MVertex*> &verts) + std::set<MVertex*, MVertexLessThanLexicographic> &pos, + std::vector<MVertex*> &verts) { std::set<MVertex*, MVertexLessThanLexicographic>::iterator itp; double x[8], y[8], z[8]; @@ -118,7 +118,7 @@ int getExtrudedVertices(MElement *ele, ExtrudeParams *ep, int j, int k, } if(itp == pos.end()) Msg(GERROR, "Could not find extruded vertex (%.16g, %.16g, %.16g)", - tmp.x(), tmp.y(), tmp.z()); + tmp.x(), tmp.y(), tmp.z()); else verts.push_back(*itp); } @@ -126,7 +126,7 @@ int getExtrudedVertices(MElement *ele, ExtrudeParams *ep, int j, int k, } void extrudeMesh(GFace *from, GRegion *to, - std::set<MVertex*, MVertexLessThanLexicographic> &pos) + std::set<MVertex*, MVertexLessThanLexicographic> &pos) { ExtrudeParams *ep = to->meshAttributes.extrude; @@ -135,13 +135,13 @@ void extrudeMesh(GFace *from, GRegion *to, MVertex *v = from->mesh_vertices[i]; for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - double x = v->x(), y = v->y(), z = v->z(); - ep->Extrude(j, k + 1, x, y, z); - if(j != ep->mesh.NbLayer - 1 || k != ep->mesh.NbElmLayer[j] - 1){ - MVertex *newv = new MVertex(x, y, z, to); - to->mesh_vertices.push_back(newv); - pos.insert(newv); - } + double x = v->x(), y = v->y(), z = v->z(); + ep->Extrude(j, k + 1, x, y, z); + if(j != ep->mesh.NbLayer - 1 || k != ep->mesh.NbElmLayer[j] - 1){ + MVertex *newv = new MVertex(x, y, z, to); + to->mesh_vertices.push_back(newv); + pos.insert(newv); + } } } } @@ -152,25 +152,25 @@ void extrudeMesh(GFace *from, GRegion *to, for(unsigned int i = 0; i < from->triangles.size(); i++){ for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - std::vector<MVertex*> verts; - if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, verts) == 6) - createPriPyrTet(verts, to); + std::vector<MVertex*> verts; + if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, verts) == 6) + createPriPyrTet(verts, to); } } } for(unsigned int i = 0; i < from->quadrangles.size(); i++){ for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - std::vector<MVertex*> verts; - if(getExtrudedVertices(from->quadrangles[i], ep, j, k, pos, verts) == 8) - createHexPri(verts, to); + std::vector<MVertex*> verts; + if(getExtrudedVertices(from->quadrangles[i], ep, j, k, pos, verts) == 8) + createHexPri(verts, to); } } } } void insertAllVertices(GRegion *gr, - std::set<MVertex*, MVertexLessThanLexicographic> &pos) + std::set<MVertex*, MVertexLessThanLexicographic> &pos) { pos.insert(gr->mesh_vertices.begin(), gr->mesh_vertices.end()); std::list<GFace*> faces = gr->faces(); @@ -182,9 +182,9 @@ void insertAllVertices(GRegion *gr, while(ite != edges.end()){ pos.insert((*ite)->mesh_vertices.begin(), (*ite)->mesh_vertices.end()); pos.insert((*ite)->getBeginVertex()->mesh_vertices.begin(), - (*ite)->getBeginVertex()->mesh_vertices.end()); + (*ite)->getBeginVertex()->mesh_vertices.end()); pos.insert((*ite)->getEndVertex()->mesh_vertices.begin(), - (*ite)->getEndVertex()->mesh_vertices.end()); + (*ite)->getEndVertex()->mesh_vertices.end()); ++ite; } ++itf; @@ -232,21 +232,21 @@ void meshGRegionExtruded::operator() (GRegion *gr) } int edgeExists(MVertex *v1, MVertex *v2, - std::set<std::pair<MVertex*, MVertex*> > &edges) + std::set<std::pair<MVertex*, MVertex*> > &edges) { std::pair<MVertex*, MVertex*> p(std::min(v1, v2), std::max(v1, v2)); return edges.count(p); } void createEdge(MVertex *v1, MVertex *v2, - std::set<std::pair<MVertex*, MVertex*> > &edges) + std::set<std::pair<MVertex*, MVertex*> > &edges) { std::pair<MVertex*, MVertex*> p(std::min(v1, v2), std::max(v1, v2)); edges.insert(p); } void deleteEdge(MVertex *v1, MVertex *v2, - std::set<std::pair<MVertex*, MVertex*> > &edges) + std::set<std::pair<MVertex*, MVertex*> > &edges) { std::pair<MVertex*, MVertex*> p(std::min(v1, v2), std::max(v1, v2)); edges.erase(p); @@ -254,8 +254,8 @@ void deleteEdge(MVertex *v1, MVertex *v2, // subdivide the 3 lateral faces of each prism void phase1(GRegion *gr, - std::set<MVertex*, MVertexLessThanLexicographic> &pos, - std::set<std::pair<MVertex*, MVertex*> > &edges) + std::set<MVertex*, MVertexLessThanLexicographic> &pos, + std::set<std::pair<MVertex*, MVertex*> > &edges) { ExtrudeParams *ep = gr->meshAttributes.extrude; GFace *from = gr->model()->getFaceByTag(std::abs(ep->geo.Source)); @@ -264,7 +264,7 @@ void phase1(GRegion *gr, for(unsigned int i = 0; i < from->triangles.size(); i++){ for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - std::vector<MVertex*> v; + std::vector<MVertex*> v; if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){ #if 0 // old if(!edgeExists(v[0], v[4], edges)) @@ -274,14 +274,14 @@ void phase1(GRegion *gr, if(!edgeExists(v[3], v[2], edges)) createEdge(v[0], v[5], edges); #else // new from Michel Benhamou - if(v[1] < v[0]) createEdge(v[1], v[3], edges); - else createEdge(v[0], v[4], edges); - if(v[1] < v[2]) createEdge(v[1], v[5], edges); - else createEdge(v[4], v[2], edges); - if(v[0] < v[2]) createEdge(v[0], v[5], edges); - else createEdge(v[3], v[2], edges); + if(v[1] < v[0]) createEdge(v[1], v[3], edges); + else createEdge(v[0], v[4], edges); + if(v[1] < v[2]) createEdge(v[1], v[5], edges); + else createEdge(v[4], v[2], edges); + if(v[0] < v[2]) createEdge(v[0], v[5], edges); + else createEdge(v[3], v[2], edges); #endif - } + } } } } @@ -289,10 +289,10 @@ void phase1(GRegion *gr, // modify lateral edges to make them "tet-compatible" void phase2(GRegion *gr, - std::set<MVertex*, MVertexLessThanLexicographic> &pos, - std::set<std::pair<MVertex*, MVertex*> > &edges, - std::set<std::pair<MVertex*, MVertex*> > &edges_swap, - int &swap) + std::set<MVertex*, MVertexLessThanLexicographic> &pos, + std::set<std::pair<MVertex*, MVertex*> > &edges, + std::set<std::pair<MVertex*, MVertex*> > &edges_swap, + int &swap) { ExtrudeParams *ep = gr->meshAttributes.extrude; GFace *from = gr->model()->getFaceByTag(std::abs(ep->geo.Source)); @@ -301,55 +301,55 @@ void phase2(GRegion *gr, for(unsigned int i = 0; i < from->triangles.size(); i++){ for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - std::vector<MVertex*> v; - if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){ - if(edgeExists(v[3], v[1], edges) && - edgeExists(v[4], v[2], edges) && - edgeExists(v[0], v[5], edges)) { - swap++; - if(!edgeExists(v[3], v[1], edges_swap)) { - deleteEdge(v[3], v[1], edges); - createEdge(v[0], v[4], edges); - createEdge(v[3], v[1], edges_swap); - createEdge(v[0], v[4], edges_swap); - } - else if(!edgeExists(v[4], v[2], edges_swap)) { - deleteEdge(v[4], v[2], edges); - createEdge(v[1], v[5], edges); - createEdge(v[4], v[2], edges_swap); - createEdge(v[1], v[5], edges_swap); - } - else if(!edgeExists(v[0], v[5], edges_swap)) { - deleteEdge(v[0], v[5], edges); - createEdge(v[3], v[2], edges); - createEdge(v[0], v[5], edges_swap); - createEdge(v[3], v[2], edges_swap); - } - } - else if(edgeExists(v[0], v[4], edges) && - edgeExists(v[1], v[5], edges) && - edgeExists(v[3], v[2], edges)) { - swap++; - if(!edgeExists(v[0], v[4], edges_swap)) { - deleteEdge(v[0], v[4], edges); - createEdge(v[3], v[1], edges); - createEdge(v[0], v[4], edges_swap); - createEdge(v[3], v[1], edges_swap); - } - else if(!edgeExists(v[1], v[5], edges_swap)) { - deleteEdge(v[1], v[5], edges); - createEdge(v[4], v[2], edges); - createEdge(v[1], v[5], edges_swap); - createEdge(v[4], v[2], edges_swap); - } - else if(!edgeExists(v[3], v[2], edges_swap)) { - deleteEdge(v[3], v[2], edges); - createEdge(v[0], v[5], edges); - createEdge(v[3], v[2], edges_swap); - createEdge(v[0], v[5], edges_swap); - } - } - } + std::vector<MVertex*> v; + if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){ + if(edgeExists(v[3], v[1], edges) && + edgeExists(v[4], v[2], edges) && + edgeExists(v[0], v[5], edges)) { + swap++; + if(!edgeExists(v[3], v[1], edges_swap)) { + deleteEdge(v[3], v[1], edges); + createEdge(v[0], v[4], edges); + createEdge(v[3], v[1], edges_swap); + createEdge(v[0], v[4], edges_swap); + } + else if(!edgeExists(v[4], v[2], edges_swap)) { + deleteEdge(v[4], v[2], edges); + createEdge(v[1], v[5], edges); + createEdge(v[4], v[2], edges_swap); + createEdge(v[1], v[5], edges_swap); + } + else if(!edgeExists(v[0], v[5], edges_swap)) { + deleteEdge(v[0], v[5], edges); + createEdge(v[3], v[2], edges); + createEdge(v[0], v[5], edges_swap); + createEdge(v[3], v[2], edges_swap); + } + } + else if(edgeExists(v[0], v[4], edges) && + edgeExists(v[1], v[5], edges) && + edgeExists(v[3], v[2], edges)) { + swap++; + if(!edgeExists(v[0], v[4], edges_swap)) { + deleteEdge(v[0], v[4], edges); + createEdge(v[3], v[1], edges); + createEdge(v[0], v[4], edges_swap); + createEdge(v[3], v[1], edges_swap); + } + else if(!edgeExists(v[1], v[5], edges_swap)) { + deleteEdge(v[1], v[5], edges); + createEdge(v[4], v[2], edges); + createEdge(v[1], v[5], edges_swap); + createEdge(v[4], v[2], edges_swap); + } + else if(!edgeExists(v[3], v[2], edges_swap)) { + deleteEdge(v[3], v[2], edges); + createEdge(v[0], v[5], edges); + createEdge(v[3], v[2], edges_swap); + createEdge(v[0], v[5], edges_swap); + } + } + } } } } @@ -357,8 +357,8 @@ void phase2(GRegion *gr, // create tets void phase3(GRegion *gr, - std::set<MVertex*, MVertexLessThanLexicographic> &pos, - std::set<std::pair<MVertex*, MVertex*> > &edges) + std::set<MVertex*, MVertexLessThanLexicographic> &pos, + std::set<std::pair<MVertex*, MVertex*> > &edges) { ExtrudeParams *ep = gr->meshAttributes.extrude; GFace *from = gr->model()->getFaceByTag(std::abs(ep->geo.Source)); @@ -367,51 +367,51 @@ void phase3(GRegion *gr, for(unsigned int i = 0; i < from->triangles.size(); i++){ for(int j = 0; j < ep->mesh.NbLayer; j++) { for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) { - std::vector<MVertex*> v; - if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){ - if(edgeExists(v[3], v[1], edges) && - edgeExists(v[4], v[2], edges) && - edgeExists(v[3], v[2], edges)) { - createTet(v[0], v[1], v[2], v[3], gr); - createTet(v[3], v[4], v[5], v[2], gr); - createTet(v[1], v[3], v[4], v[2], gr); - } - else if(edgeExists(v[3], v[1], edges) && - edgeExists(v[1], v[5], edges) && - edgeExists(v[3], v[2], edges)) { - createTet(v[0], v[1], v[2], v[3], gr); - createTet(v[3], v[4], v[5], v[1], gr); - createTet(v[3], v[1], v[5], v[2], gr); - } - else if(edgeExists(v[3], v[1], edges) && - edgeExists(v[1], v[5], edges) && - edgeExists(v[5], v[0], edges)) { - createTet(v[0], v[1], v[2], v[5], gr); - createTet(v[3], v[4], v[5], v[1], gr); - createTet(v[1], v[3], v[5], v[0], gr); - } - else if(edgeExists(v[4], v[0], edges) && - edgeExists(v[4], v[2], edges) && - edgeExists(v[3], v[2], edges)) { - createTet(v[0], v[1], v[2], v[4], gr); - createTet(v[3], v[4], v[5], v[2], gr); - createTet(v[0], v[3], v[4], v[2], gr); - } - else if(edgeExists(v[4], v[0], edges) && - edgeExists(v[4], v[2], edges) && - edgeExists(v[5], v[0], edges)) { - createTet(v[0], v[1], v[2], v[4], gr); - createTet(v[3], v[4], v[5], v[0], gr); - createTet(v[0], v[2], v[4], v[5], gr); - } - else if(edgeExists(v[4], v[0], edges) && - edgeExists(v[1], v[5], edges) && - edgeExists(v[5], v[0], edges)) { - createTet(v[0], v[1], v[2], v[5], gr); - createTet(v[3], v[4], v[5], v[0], gr); - createTet(v[0], v[1], v[4], v[5], gr); - } - } + std::vector<MVertex*> v; + if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){ + if(edgeExists(v[3], v[1], edges) && + edgeExists(v[4], v[2], edges) && + edgeExists(v[3], v[2], edges)) { + createTet(v[0], v[1], v[2], v[3], gr); + createTet(v[3], v[4], v[5], v[2], gr); + createTet(v[1], v[3], v[4], v[2], gr); + } + else if(edgeExists(v[3], v[1], edges) && + edgeExists(v[1], v[5], edges) && + edgeExists(v[3], v[2], edges)) { + createTet(v[0], v[1], v[2], v[3], gr); + createTet(v[3], v[4], v[5], v[1], gr); + createTet(v[3], v[1], v[5], v[2], gr); + } + else if(edgeExists(v[3], v[1], edges) && + edgeExists(v[1], v[5], edges) && + edgeExists(v[5], v[0], edges)) { + createTet(v[0], v[1], v[2], v[5], gr); + createTet(v[3], v[4], v[5], v[1], gr); + createTet(v[1], v[3], v[5], v[0], gr); + } + else if(edgeExists(v[4], v[0], edges) && + edgeExists(v[4], v[2], edges) && + edgeExists(v[3], v[2], edges)) { + createTet(v[0], v[1], v[2], v[4], gr); + createTet(v[3], v[4], v[5], v[2], gr); + createTet(v[0], v[3], v[4], v[2], gr); + } + else if(edgeExists(v[4], v[0], edges) && + edgeExists(v[4], v[2], edges) && + edgeExists(v[5], v[0], edges)) { + createTet(v[0], v[1], v[2], v[4], gr); + createTet(v[3], v[4], v[5], v[0], gr); + createTet(v[0], v[2], v[4], v[5], gr); + } + else if(edgeExists(v[4], v[0], edges) && + edgeExists(v[1], v[5], edges) && + edgeExists(v[5], v[0], edges)) { + createTet(v[0], v[1], v[2], v[5], gr); + createTet(v[3], v[4], v[5], v[0], gr); + createTet(v[0], v[1], v[4], v[5], gr); + } + } } } } @@ -486,10 +486,10 @@ int SubdivideExtrudedMesh(GModel *m) GFace *gf = *it; Msg(INFO, "Remeshing surface %d", gf->tag()); for(unsigned int i = 0; i < gf->triangles.size(); i++) - delete gf->triangles[i]; + delete gf->triangles[i]; gf->triangles.clear(); for(unsigned int i = 0; i < gf->quadrangles.size(); i++) - delete gf->quadrangles[i]; + delete gf->quadrangles[i]; gf->quadrangles.clear(); MeshExtrudedSurface(gf, &edges); } @@ -502,7 +502,7 @@ int SubdivideExtrudedMesh(GModel *m) if(ep->mesh.Holes.size()){ std::map<int, std::pair<double, std::vector<int> > >::iterator it; for(it = ep->mesh.Holes.begin(); it != ep->mesh.Holes.end(); it++) - carveHole(gr, it->first, it->second.first, it->second.second); + carveHole(gr, it->first, it->second.first, it->second.second); } } diff --git a/Mesh/meshGRegionLocalMeshMod.cpp b/Mesh/meshGRegionLocalMeshMod.cpp index 22e1addbc7f790af3b947c6acadfba851728c19c..d1c2e819aab46e95b4805a3dd4f403a1e958b39a 100644 --- a/Mesh/meshGRegionLocalMeshMod.cpp +++ b/Mesh/meshGRegionLocalMeshMod.cpp @@ -1,4 +1,4 @@ -// $Id: meshGRegionLocalMeshMod.cpp,v 1.11 2008-02-17 08:48:01 geuzaine Exp $ +// $Id: meshGRegionLocalMeshMod.cpp,v 1.12 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -39,39 +39,39 @@ static int vFac[4][3] = {{0,1,2},{0,2,3},{0,1,3},{1,2,3}}; // we return true if the cavity is closed and false if it is open void computeNeighboringTetsOfACavity(const std::vector<MTet4*> &cavity, - std::vector<MTet4*> &outside) + std::vector<MTet4*> &outside) { outside.clear(); for (unsigned int i = 0; i < cavity.size(); i++){ for (int j = 0; j < 4; j++){ MTet4 * neigh = cavity[i]->getNeigh(j); if(neigh){ - bool found = false; - for (unsigned int k = 0; k < outside.size(); k++){ - if(outside[k] == neigh){ - found = true; - break; - } - } - if(!found){ - for (unsigned int k = 0; k < cavity.size(); k++){ - if(cavity[k] == neigh){ - found = true; - } - } - } - if(!found)outside.push_back(neigh); + bool found = false; + for (unsigned int k = 0; k < outside.size(); k++){ + if(outside[k] == neigh){ + found = true; + break; + } + } + if(!found){ + for (unsigned int k = 0; k < cavity.size(); k++){ + if(cavity[k] == neigh){ + found = true; + } + } + } + if(!found)outside.push_back(neigh); } } } } - + bool gmshBuildEdgeCavity(MTet4 *t, - int iLocalEdge, - MVertex **v1,MVertex **v2, - std::vector<MTet4*> &cavity, - std::vector<MTet4*> &outside, - std::vector<MVertex*> &ring) + int iLocalEdge, + MVertex **v1,MVertex **v2, + std::vector<MTet4*> &cavity, + std::vector<MTet4*> &outside, + std::vector<MVertex*> &ring) { cavity.clear(); ring.clear(); @@ -94,11 +94,11 @@ bool gmshBuildEdgeCavity(MTet4 *t, int iFace1 = efaces[iLocalEdge][0]; int iFace2 = efaces[iLocalEdge][1]; if (faces[iFace1][0] == edges[5-iLocalEdge][K] || - faces[iFace1][1] == edges[5-iLocalEdge][K] || - faces[iFace1][2] == edges[5-iLocalEdge][K] ) iFace = iFace1; + faces[iFace1][1] == edges[5-iLocalEdge][K] || + faces[iFace1][2] == edges[5-iLocalEdge][K] ) iFace = iFace1; else if (faces[iFace2][0] == edges[5-iLocalEdge][K] || - faces[iFace2][1] == edges[5-iLocalEdge][K] || - faces[iFace2][2] == edges[5-iLocalEdge][K] ) iFace = iFace2; + faces[iFace2][1] == edges[5-iLocalEdge][K] || + faces[iFace2][2] == edges[5-iLocalEdge][K] ) iFace = iFace2; else { Msg(GERROR, "Error of connexion"); throw; } t=t->getNeigh(iFace); if (!t) return false; @@ -111,8 +111,8 @@ bool gmshBuildEdgeCavity(MTet4 *t, MVertex *a = t->tet()->getVertex(edges[i][0]); MVertex *b = t->tet()->getVertex(edges[i][1]); if ((a == *v1 && b == *v2) || (a == *v2 && b == *v1)){ - iLocalEdge = i; - break; + iLocalEdge = i; + break; } } if (iLocalEdge == -1){ @@ -219,9 +219,9 @@ void BuildSwapPattern7(SwapPattern *sc) } bool gmshEdgeSwap (std::vector<MTet4 *> &newTets, - MTet4 *tet, - int iLocalEdge, - const gmshQualityMeasure4Tet &cr) + MTet4 *tet, + int iLocalEdge, + const gmshQualityMeasure4Tet &cr) { std::vector<MTet4*> cavity; std::vector<MTet4*> outside; @@ -327,10 +327,10 @@ bool gmshEdgeSwap (std::vector<MTet4 *> &newTets, } bool gmshEdgeSplit(std::vector<MTet4 *> &newTets, - MTet4 *tet, - MVertex *newVertex, - int iLocalEdge, - const gmshQualityMeasure4Tet &cr) + MTet4 *tet, + MVertex *newVertex, + int iLocalEdge, + const gmshQualityMeasure4Tet &cr) { std::vector<MTet4*> cavity; std::vector<MTet4*> outside; @@ -364,9 +364,9 @@ bool gmshEdgeSplit(std::vector<MTet4 *> &newTets, // swap a face i.e. remove a face shared by 2 tets bool gmshFaceSwap(std::vector<MTet4 *> &newTets, - MTet4 *t1, - int iLocalFace, - const gmshQualityMeasure4Tet &cr) + MTet4 *t1, + int iLocalFace, + const gmshQualityMeasure4Tet &cr) { MTet4 *t2 = t1->getNeigh(iLocalFace); if (!t2) return false; @@ -411,7 +411,7 @@ bool gmshFaceSwap(std::vector<MTet4 *> &newTets, if(t1->getNeigh(i) && t1->getNeigh(i) != t2){ bool found = false; for(unsigned int j = 0; j < outside.size(); j++){ - if(outside[j] == t1->getNeigh(i)) { found = true; break; } + if(outside[j] == t1->getNeigh(i)) { found = true; break; } } if(!found) outside.push_back(t1->getNeigh(i)); } @@ -420,7 +420,7 @@ bool gmshFaceSwap(std::vector<MTet4 *> &newTets, if(t2->getNeigh(i) && t2->getNeigh(i) != t1){ bool found = false; for(unsigned int j = 0; j < outside.size(); j++){ - if(outside[j] == t2->getNeigh(i)) { found = true; break; } + if(outside[j] == t2->getNeigh(i)) { found = true; break; } } if(!found) outside.push_back(t2->getNeigh(i)); } @@ -451,8 +451,8 @@ bool gmshFaceSwap(std::vector<MTet4 *> &newTets, } void gmshBuildVertexCavity_recur(MTet4 *t, - MVertex *v, - std::vector<MTet4*> &cavity) + MVertex *v, + std::vector<MTet4*> &cavity) { // if (recur > 20)printf("oufti %d\n",recur); if(t->isDeleted()){ @@ -467,21 +467,21 @@ void gmshBuildVertexCavity_recur(MTet4 *t, } if (iV == -1){ Msg(FATAL, "trying to build a cavity of tets for a vertex that does not " - "belong to this tet"); + "belong to this tet"); } for (int i = 0; i < 3; i++){ MTet4 *neigh = t->getNeigh(vFac[iV][i]); if (neigh){ bool found = false; for(unsigned int j = 0; j < cavity.size(); j++){ - if(cavity[j] == neigh){ - found = true; - j = cavity.size(); - } + if(cavity[j] == neigh){ + found = true; + j = cavity.size(); + } } if(!found){ - cavity.push_back(neigh); - gmshBuildVertexCavity_recur(neigh, v, cavity); + cavity.push_back(neigh); + gmshBuildVertexCavity_recur(neigh, v, cavity); } } } @@ -493,8 +493,8 @@ void gmshBuildVertexCavity_recur(MTet4 *t, // after that crap, the sliver is trashed bool gmshSliverRemoval(std::vector<MTet4*> &newTets, - MTet4 *t, - const gmshQualityMeasure4Tet &cr) + MTet4 *t, + const gmshQualityMeasure4Tet &cr) { std::vector<MTet4*> cavity; std::vector<MTet4*> outside; @@ -525,33 +525,33 @@ bool gmshSliverRemoval(std::vector<MTet4*> &newTets, MVertex *v1 = t->tet()->getVertex(edges[iSwappable][0]); MVertex *v2 = t->tet()->getVertex(edges[iSwappable][1]); MVertex *newv = new MVertex (0.5 * (v1->x() + v2->x()), - 0.5 * (v1->y() + v2->y()), - 0.5 * (v1->z() + v2->z()), t->onWhat()); + 0.5 * (v1->y() + v2->y()), + 0.5 * (v1->z() + v2->z()), t->onWhat()); t->onWhat()->mesh_vertices.push_back(newv); if (!gmshEdgeSplit(newTets, t, newv, iSwappable, QMTET_ONE)) return false; for (int i = 0; i < 4; i++){ if (newTets[newTets.size() - 1]->tet()->getVertex(i) == newv){ - gmshSmoothVertex(newTets[newTets.size() - 1], i, cr); - gmshSmoothVertexOptimize (newTets[newTets.size() - 1], i, cr); + gmshSmoothVertex(newTets[newTets.size() - 1], i, cr); + gmshSmoothVertexOptimize (newTets[newTets.size() - 1], i, cr); } } for (unsigned int i = 0; i < newTets.size(); i++){ MTet4 *new_t = newTets[i]; if (!(new_t->isDeleted())){ - for (int j = 0; j < 6; j++){ - MVertex *va = new_t->tet()->getVertex(edges[j][0]); - MVertex *vb = new_t->tet()->getVertex(edges[j][1]); - if (va == newv && - (va != v1 && vb != v1 && va != v2 && vb != v2)){ - gmshCollapseVertex(newTets,new_t,edges[j][0],edges[j][1],cr); - } - else if (vb == newv && - (va != v1 && vb != v1 && va != v2 && vb != v2)){ - gmshCollapseVertex(newTets,new_t,edges[j][1],edges[j][0],cr); - } - } + for (int j = 0; j < 6; j++){ + MVertex *va = new_t->tet()->getVertex(edges[j][0]); + MVertex *vb = new_t->tet()->getVertex(edges[j][1]); + if (va == newv && + (va != v1 && vb != v1 && va != v2 && vb != v2)){ + gmshCollapseVertex(newTets,new_t,edges[j][0],edges[j][1],cr); + } + else if (vb == newv && + (va != v1 && vb != v1 && va != v2 && vb != v2)){ + gmshCollapseVertex(newTets,new_t,edges[j][1],edges[j][0],cr); + } + } } } return true; @@ -566,12 +566,12 @@ bool gmshSliverRemoval(std::vector<MTet4*> &newTets, } bool gmshCollapseVertex(std::vector<MTet4 *> &newTets, - MTet4 *t, - int iVertex, - int iTarget, - const gmshQualityMeasure4Tet &cr, - const gmshLocalMeshModAction action, - double *minQual) + MTet4 *t, + int iVertex, + int iTarget, + const gmshQualityMeasure4Tet &cr, + const gmshLocalMeshModAction action, + double *minQual) { if(t->isDeleted()) throw; @@ -656,8 +656,8 @@ bool gmshCollapseVertex(std::vector<MTet4 *> &newTets, } bool gmshSmoothVertex(MTet4 *t, - int iVertex, - const gmshQualityMeasure4Tet &cr) + int iVertex, + const gmshQualityMeasure4Tet &cr) { if(t->isDeleted()) throw; if(t->tet()->getVertex(iVertex)->onWhat()->dim() < 3) return false; @@ -675,17 +675,17 @@ bool gmshSmoothVertex(MTet4 *t, double q = cavity[i]->getQuality(); worst = std::min(worst,q); xcg += 0.25 * (cavity[i]->tet()->getVertex(0)->x() + - cavity[i]->tet()->getVertex(1)->x() + - cavity[i]->tet()->getVertex(2)->x() + - cavity[i]->tet()->getVertex(3)->x()) * volume; + cavity[i]->tet()->getVertex(1)->x() + + cavity[i]->tet()->getVertex(2)->x() + + cavity[i]->tet()->getVertex(3)->x()) * volume; ycg += 0.25 * (cavity[i]->tet()->getVertex(0)->y() + - cavity[i]->tet()->getVertex(1)->y() + - cavity[i]->tet()->getVertex(2)->y() + - cavity[i]->tet()->getVertex(3)->y()) * volume; + cavity[i]->tet()->getVertex(1)->y() + + cavity[i]->tet()->getVertex(2)->y() + + cavity[i]->tet()->getVertex(3)->y()) * volume; zcg += 0.25 * (cavity[i]->tet()->getVertex(0)->z() + - cavity[i]->tet()->getVertex(1)->z() + - cavity[i]->tet()->getVertex(2)->z() + - cavity[i]->tet()->getVertex(3)->z()) * volume; + cavity[i]->tet()->getVertex(1)->z() + + cavity[i]->tet()->getVertex(2)->z() + + cavity[i]->tet()->getVertex(3)->z()) * volume; vTot += volume; } xcg /= (vTot); @@ -732,7 +732,7 @@ struct smoothVertexData3D{ }; double smoothing_objective_function_3D(double X, double Y, double Z, - MVertex *v, std::vector<MTet4 *> &ts) + MVertex *v, std::vector<MTet4 *> &ts) { const double oldX = v->x(); const double oldY = v->y(); @@ -755,9 +755,9 @@ double smoothing_objective_function_3D(double X, double Y, double Z, } void deriv_smoothing_objective_function_3D(double X, double Y, double Z, - double &F, - double &dFdX, double &dFdY, double &dFdZ, - void *data) + double &F, + double &dFdX, double &dFdY, double &dFdZ, + void *data) { smoothVertexData3D *svd = (smoothVertexData3D*)data; MVertex *v = svd->v; @@ -779,8 +779,8 @@ double smooth_obj_3D(double X, double Y, double Z, void *data) } bool gmshSmoothVertexOptimize(MTet4 *t, - int iVertex, - const gmshQualityMeasure4Tet &cr) + int iVertex, + const gmshQualityMeasure4Tet &cr) { if(t->tet()->getVertex(iVertex)->onWhat()->dim() < 3) return false; @@ -796,7 +796,7 @@ bool gmshSmoothVertexOptimize(MTet4 *t, double val; minimize_3(smooth_obj_3D, deriv_smoothing_objective_function_3D, &vd, 4, - xopti, yopti, zopti, val); + xopti, yopti, zopti, val); double vTot = 0; @@ -845,27 +845,27 @@ bool gmshSmoothVertexOptimize(MTet4 *t, // the resulting triangles are 012 and 230 in vector res // void splitPrism (std::vector<MTet4 *> &newTets, -// std::vector<MVertex *> &steinerPoints, -// MVertex* v1, -// MVertex* v2, -// MVertex* v3, -// MVertex* v4, -// MVertex* v5, -// MVertex* v6, -// const gmshQualityMeasure4Tet &cr, -// MVertex *res[4], -// fs_cont &search, -// GFace *fakeFace){ +// std::vector<MVertex *> &steinerPoints, +// MVertex* v1, +// MVertex* v2, +// MVertex* v3, +// MVertex* v4, +// MVertex* v5, +// MVertex* v6, +// const gmshQualityMeasure4Tet &cr, +// MVertex *res[4], +// fs_cont &search, +// GFace *fakeFace){ // } // void splitQuadFace (MVertex* newv1, -// MVertex* newv2, -// MVertex* v21, -// MVertex* v11, -// const gmshQualityMeasure4Tet &cr, -// MVertex *res[4], -// fs_cont &search, -// GFace *fakeFace){ +// MVertex* newv2, +// MVertex* v21, +// MVertex* v11, +// const gmshQualityMeasure4Tet &cr, +// MVertex *res[4], +// fs_cont &search, +// GFace *fakeFace){ // GFace* gfound = findInFaceSearchStructure (newv1,newv2,v11,search); // if (gfound){ // res[0] = newv2; @@ -886,50 +886,50 @@ bool gmshSmoothVertexOptimize(MTet4 *t, // double q1 = std::min(qmTri(newv1,newv2,v11,cr),qmTet(newv2,v11,v21,cr)); // double q2 = std::min(qmTet(newv1,newv2,v21,cr),qmTet(newv1,v11,v21,cr)); // if (q1 > q2){ -// res[0] = newv2; -// res[1] = newv1; -// res[2] = v11; -// res[3] = v21; -// MVertex *p1 = std::min(std::min(newv1,newv2),v11); -// MVertex *p2 = std::min(std::min(newv2,v11),v21); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v11),fakeFace))); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv2,v11,v21),fakeFace))); +// res[0] = newv2; +// res[1] = newv1; +// res[2] = v11; +// res[3] = v21; +// MVertex *p1 = std::min(std::min(newv1,newv2),v11); +// MVertex *p2 = std::min(std::min(newv2,v11),v21); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v11),fakeFace))); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv2,v11,v21),fakeFace))); // } // else{ -// res[0] = newv1; -// res[1] = newv2; -// res[2] = v21; -// res[3] = v11; -// MVertex *p1 = std::min(std::min(newv1,newv2),v21); -// MVertex *p2 = std::min(std::min(newv2,v11),v21); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v21),fakeFace))); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,v11,v21),fakeFace))); +// res[0] = newv1; +// res[1] = newv2; +// res[2] = v21; +// res[3] = v11; +// MVertex *p1 = std::min(std::min(newv1,newv2),v21); +// MVertex *p2 = std::min(std::min(newv2,v11),v21); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v21),fakeFace))); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,v11,v21),fakeFace))); // } // } -// } +// } // } // void splitQuadFace (std::vector<MTet4 *> &newTets, -// std::vector<MVertex *> &steinerPoints, -// MVertex* newv1, -// MVertex* newv2, -// MVertex* v21, -// MVertex* v11, -// MVertex* other, -// const gmshQualityMeasure4Tet &cr, -// fs_cont &search, -// GFace *fakeFace){ +// std::vector<MVertex *> &steinerPoints, +// MVertex* newv1, +// MVertex* newv2, +// MVertex* v21, +// MVertex* v11, +// MVertex* other, +// const gmshQualityMeasure4Tet &cr, +// fs_cont &search, +// GFace *fakeFace){ // MTetrahedron *tr3,*tr4; // // now we look if there exists a face with the same vertices // GFace* gfound = findInFaceSearchStructure (newv1,newv2,v11,search); // if (gfound){ -// tr3 = new MTetrahedron ( newv1,newv2,v11,other); -// tr4 = new MTetrahedron ( newv2,v11,v21,other); +// tr3 = new MTetrahedron ( newv1,newv2,v11,other); +// tr4 = new MTetrahedron ( newv2,v11,v21,other); // } // else{ // GFace* gfound = findInFaceSearchStructure (newv1,newv2,v21,search); // if (gfound){ -// tr3 = new MTetrahedron ( newv1,newv2,v21,other); -// tr4 = new MTetrahedron ( newv1,v11,v21,other); +// tr3 = new MTetrahedron ( newv1,newv2,v21,other); +// tr4 = new MTetrahedron ( newv1,v11,v21,other); // } // // choose the best configuration // else{ @@ -937,34 +937,34 @@ bool gmshSmoothVertexOptimize(MTet4 *t, // double q1 = std::min(qmTet(newv1,newv2,v11,other,cr,vol),qmTet(newv2,v11,v21,other,cr,vol)); // double q2 = std::min(qmTet(newv1,newv2,v21,other,cr,vol),qmTet(newv1,v11,v21,other,cr,vol)); // if (q1 > q2){ -// tr3 = new MTetrahedron ( newv1,newv2,v11,other); -// tr4 = new MTetrahedron ( newv2,v11,v21,other); -// MVertex *p1 = std::min(std::min(newv1,newv2),v11); -// MVertex *p2 = std::min(std::min(newv2,v11),v21); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v11),fakeFace))); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv2,v11,v21),fakeFace))); +// tr3 = new MTetrahedron ( newv1,newv2,v11,other); +// tr4 = new MTetrahedron ( newv2,v11,v21,other); +// MVertex *p1 = std::min(std::min(newv1,newv2),v11); +// MVertex *p2 = std::min(std::min(newv2,v11),v21); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v11),fakeFace))); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv2,v11,v21),fakeFace))); // } // else{ -// tr3 = new MTetrahedron ( newv1,newv2,v21,other); -// tr4 = new MTetrahedron ( newv1,v11,v21,other); -// MVertex *p1 = std::min(std::min(newv1,newv2),v21); -// MVertex *p2 = std::min(std::min(newv2,v11),v21); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v21),fakeFace))); -// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,v11,v21),fakeFace))); +// tr3 = new MTetrahedron ( newv1,newv2,v21,other); +// tr4 = new MTetrahedron ( newv1,v11,v21,other); +// MVertex *p1 = std::min(std::min(newv1,newv2),v21); +// MVertex *p2 = std::min(std::min(newv2,v11),v21); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p1, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,newv2,v21),fakeFace))); +// search.insert ( std::pair<MVertex*,std::pair<MTriangle*,GFace*> > ( p2, std::pair<MTriangle*,GFace*>(new MTriangle(newv1,v11,v21),fakeFace))); // } // } -// } +// } // } // bool splitEdgesOfTet (std::vector<MTet4 *> &newTets, -// std::vector<MVertex *> &steinerPoints, -// MTet4 *t1, -// int nbEdges, -// int e[6], -// MVertex* pts[6], -// const gmshQualityMeasure4Tet &cr, -// fs_cont &search, -// GFace *fakeFace){ +// std::vector<MVertex *> &steinerPoints, +// MTet4 *t1, +// int nbEdges, +// int e[6], +// MVertex* pts[6], +// const gmshQualityMeasure4Tet &cr, +// fs_cont &search, +// GFace *fakeFace){ // switch(nbEdges){ // case 1 : // { @@ -997,37 +997,37 @@ bool gmshSmoothVertexOptimize(MTet4 *t, // MVertex *v22 = t1->tet()->getVertex(e[iE2][1]); // if (iE1 == 5-iE2){ // two opposite edges -// MTetrahedron *tr1 = new MTetrahedron ( newv1,newv2,v11,v21); -// MTetrahedron *tr2 = new MTetrahedron ( newv1,newv2,v21,v12); -// MTetrahedron *tr3 = new MTetrahedron ( newv1,newv2,v12,v22); -// MTetrahedron *tr4 = new MTetrahedron ( newv1,newv2,v22,v11); -// MTet4 *t41 = new MTet4 (tr1,cr); -// MTet4 *t42 = new MTet4 (tr2,cr); -// MTet4 *t43 = new MTet4 (tr3,cr); -// MTet4 *t44 = new MTet4 (tr4,cr); -// newTets.push_back(t41); -// newTets.push_back(t42); -// newTets.push_back(t43); -// newTets.push_back(t44); +// MTetrahedron *tr1 = new MTetrahedron ( newv1,newv2,v11,v21); +// MTetrahedron *tr2 = new MTetrahedron ( newv1,newv2,v21,v12); +// MTetrahedron *tr3 = new MTetrahedron ( newv1,newv2,v12,v22); +// MTetrahedron *tr4 = new MTetrahedron ( newv1,newv2,v22,v11); +// MTet4 *t41 = new MTet4 (tr1,cr); +// MTet4 *t42 = new MTet4 (tr2,cr); +// MTet4 *t43 = new MTet4 (tr3,cr); +// MTet4 *t44 = new MTet4 (tr4,cr); +// newTets.push_back(t41); +// newTets.push_back(t42); +// newTets.push_back(t43); +// newTets.push_back(t44); // } // else{ //two adjacend edges -// MVertex *vsame,*other=0; -// if (v11 == v21){vsame=v11; v11=v12; v21=v22;} -// else if (v11 == v22){vsame=v11; v11=v12} -// else if (v12 == v21){vsame=v12; v21=v22} -// else if (v12 == v22){vsame=v12;} -// else throw; -// for (int i=0;i<4;i++){ -// if (vsame != t1->tet()->getVertex(i) && -// v11 != t1->tet()->getVertex(i) && -// v21 != t1->tet()->getVertex(i)){ -// other = t1->tet->getVertex(i); -// break; -// } -// } -// if (!other)throw; -// MTetrahedron *tr1 = new MTetrahedron ( newv1,newv2,vsame,other); -// splitQuadFace (newTets,steinerPoints,newv1,newv2,v21,v11,other,cr,search,fakeFace); +// MVertex *vsame,*other=0; +// if (v11 == v21){vsame=v11; v11=v12; v21=v22;} +// else if (v11 == v22){vsame=v11; v11=v12} +// else if (v12 == v21){vsame=v12; v21=v22} +// else if (v12 == v22){vsame=v12;} +// else throw; +// for (int i=0;i<4;i++){ +// if (vsame != t1->tet()->getVertex(i) && +// v11 != t1->tet()->getVertex(i) && +// v21 != t1->tet()->getVertex(i)){ +// other = t1->tet->getVertex(i); +// break; +// } +// } +// if (!other)throw; +// MTetrahedron *tr1 = new MTetrahedron ( newv1,newv2,vsame,other); +// splitQuadFace (newTets,steinerPoints,newv1,newv2,v21,v11,other,cr,search,fakeFace); // } // } // break; @@ -1058,65 +1058,65 @@ bool gmshSmoothVertexOptimize(MTet4 *t, // // the 3 edges coincide at one vertex // int config; // if (iE1 == 0 && iE2 == 1 && iE3 == 2){ -// config = 1; -// v[0] = t1->tet()->getVertex(0); -// v[1] = t1->tet()->getVertex(1); -// v[2] = t1->tet()->getVertex(2); -// v[3] = t1->tet()->getVertex(3); +// config = 1; +// v[0] = t1->tet()->getVertex(0); +// v[1] = t1->tet()->getVertex(1); +// v[2] = t1->tet()->getVertex(2); +// v[3] = t1->tet()->getVertex(3); // } // else if (iE1 == 0 && iE2 == 3 && iE3 == 4){ -// config = 1; -// v[0] = t1->tet()->getVertex(1); -// v[1] = t1->tet()->getVertex(0); -// v[2] = t1->tet()->getVertex(2); -// v[3] = t1->tet()->getVertex(3); +// config = 1; +// v[0] = t1->tet()->getVertex(1); +// v[1] = t1->tet()->getVertex(0); +// v[2] = t1->tet()->getVertex(2); +// v[3] = t1->tet()->getVertex(3); // } // else if (iE1 == 1 && iE2 == 3 && iE3 == 5){ -// config = 1; -// v[0] = t1->tet()->getVertex(2); -// v[1] = t1->tet()->getVertex(0); -// v[2] = t1->tet()->getVertex(1); -// v[3] = t1->tet()->getVertex(3); +// config = 1; +// v[0] = t1->tet()->getVertex(2); +// v[1] = t1->tet()->getVertex(0); +// v[2] = t1->tet()->getVertex(1); +// v[3] = t1->tet()->getVertex(3); // } // else if (iE1 == 2 && iE2 == 4 && iE3 == 5){ -// config = 1; -// v[0] = t1->tet()->getVertex(3); -// v[1] = t1->tet()->getVertex(0); -// v[2] = t1->tet()->getVertex(1); -// v[3] = t1->tet()->getVertex(2); +// config = 1; +// v[0] = t1->tet()->getVertex(3); +// v[1] = t1->tet()->getVertex(0); +// v[2] = t1->tet()->getVertex(1); +// v[3] = t1->tet()->getVertex(2); // } // // three edges of the same face are cut // else if (iE1 == 0 && iE2 == 1 && iE3 == 3){ -// config = 2; -// v[0] = t1->tet()->getVertex(3); -// v[1] = t1->tet()->getVertex(1); -// v[2] = t1->tet()->getVertex(0); -// v[3] = t1->tet()->getVertex(2); +// config = 2; +// v[0] = t1->tet()->getVertex(3); +// v[1] = t1->tet()->getVertex(1); +// v[2] = t1->tet()->getVertex(0); +// v[3] = t1->tet()->getVertex(2); // } // else if (iE1 == 0 && iE2 == 2 && iE3 == 4){ -// config = 2; -// v[0] = t1->tet()->getVertex(2); -// v[1] = t1->tet()->getVertex(1); -// v[2] = t1->tet()->getVertex(0); -// v[3] = t1->tet()->getVertex(3); +// config = 2; +// v[0] = t1->tet()->getVertex(2); +// v[1] = t1->tet()->getVertex(1); +// v[2] = t1->tet()->getVertex(0); +// v[3] = t1->tet()->getVertex(3); // } // else if (iE1 == 1 && iE2 == 2 && iE3 == 5){ -// config = 2; -// v[0] = t1->tet()->getVertex(1); -// v[1] = t1->tet()->getVertex(2); -// v[2] = t1->tet()->getVertex(0); -// v[3] = t1->tet()->getVertex(3); +// config = 2; +// v[0] = t1->tet()->getVertex(1); +// v[1] = t1->tet()->getVertex(2); +// v[2] = t1->tet()->getVertex(0); +// v[3] = t1->tet()->getVertex(3); // } // else if (iE1 == 3 && iE2 == 4 && iE3 == 5){ -// config = 2; -// v[0] = t1->tet()->getVertex(0); -// v[1] = t1->tet()->getVertex(2); -// v[2] = t1->tet()->getVertex(1); -// v[3] = t1->tet()->getVertex(3); +// config = 2; +// v[0] = t1->tet()->getVertex(0); +// v[1] = t1->tet()->getVertex(2); +// v[2] = t1->tet()->getVertex(1); +// v[3] = t1->tet()->getVertex(3); // } // // the three edges for a kind of Z // else if (iE1 == 0 && iE2 == 3 && iE3 == 5){ -// config = 3; +// config = 3; // } // if (config == 1){ @@ -1124,7 +1124,7 @@ bool gmshSmoothVertexOptimize(MTet4 *t, // else if (config == 2){ // } // else{ -// throw; // for the moment. +// throw; // for the moment. // } // } // default : diff --git a/Mesh/meshGRegionLocalMeshMod.h b/Mesh/meshGRegionLocalMeshMod.h index f17c2e0aadcea287beafb541dbb4d6a714b1e06b..39cee644e47081471852b37b7421fc3be5ea8e9c 100644 --- a/Mesh/meshGRegionLocalMeshMod.h +++ b/Mesh/meshGRegionLocalMeshMod.h @@ -30,28 +30,28 @@ enum gmshLocalMeshModAction {GMSH_DOIT, GMSH_EVALONLY}; bool gmshEdgeSwap(std::vector<MTet4*> &newTets, MTet4 *tet, - int iLocalEdge, const gmshQualityMeasure4Tet &cr); + int iLocalEdge, const gmshQualityMeasure4Tet &cr); bool gmshFaceSwap(std::vector<MTet4*> &newTets, MTet4 *tet, - int iLocalFace, const gmshQualityMeasure4Tet &cr); + int iLocalFace, const gmshQualityMeasure4Tet &cr); bool gmshSmoothVertex(MTet4 *t, int iLocalVertex, - const gmshQualityMeasure4Tet &cr); + const gmshQualityMeasure4Tet &cr); bool gmshSmoothVertexOptimize(MTet4 *t, int iVertex, - const gmshQualityMeasure4Tet &cr); + const gmshQualityMeasure4Tet &cr); bool gmshCollapseVertex(std::vector<MTet4*> &newTets, MTet4 *t, - int iVertex, int iTarget, - const gmshQualityMeasure4Tet &cr, - const gmshLocalMeshModAction = GMSH_DOIT, - double *result = 0); + int iVertex, int iTarget, + const gmshQualityMeasure4Tet &cr, + const gmshLocalMeshModAction = GMSH_DOIT, + double *result = 0); bool gmshEdgeSplit(std::vector<MTet4*> &newTets, MTet4 *tet, - MVertex *newVertex, int iLocalEdge, - const gmshQualityMeasure4Tet &cr); + MVertex *newVertex, int iLocalEdge, + const gmshQualityMeasure4Tet &cr); bool gmshSliverRemoval(std::vector<MTet4*> &newTets, MTet4 *t, - const gmshQualityMeasure4Tet &cr); + const gmshQualityMeasure4Tet &cr); #endif diff --git a/Mesh/meshGRegionTransfinite.cpp b/Mesh/meshGRegionTransfinite.cpp index ac1e6369ef98c3b245a90cb608b0a810b6ee624d..44f80f1b9e3f0000d30a44638f83e04e890f6497 100644 --- a/Mesh/meshGRegionTransfinite.cpp +++ b/Mesh/meshGRegionTransfinite.cpp @@ -1,4 +1,4 @@ -// $Id: meshGRegionTransfinite.cpp,v 1.8 2008-02-17 08:48:01 geuzaine Exp $ +// $Id: meshGRegionTransfinite.cpp,v 1.9 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -60,66 +60,66 @@ */ #define CREATE_HEX new MHexahedron(tab[i ][j ][k ], \ - tab[i + 1][j ][k ], \ - tab[i + 1][j + 1][k ], \ - tab[i ][j + 1][k ], \ - tab[i ][j ][k + 1], \ - tab[i + 1][j ][k + 1], \ - tab[i + 1][j + 1][k + 1], \ - tab[i ][j + 1][k + 1]) + tab[i + 1][j ][k ], \ + tab[i + 1][j + 1][k ], \ + tab[i ][j + 1][k ], \ + tab[i ][j ][k + 1], \ + tab[i + 1][j ][k + 1], \ + tab[i + 1][j + 1][k + 1], \ + tab[i ][j + 1][k + 1]) #define CREATE_PRISM_1 new MPrism(tab[i ][j ][k ], \ - tab[i + 1][j ][k ], \ - tab[i ][j + 1][k ], \ - tab[i ][j ][k + 1], \ - tab[i + 1][j ][k + 1], \ - tab[i ][j + 1][k + 1]) + tab[i + 1][j ][k ], \ + tab[i ][j + 1][k ], \ + tab[i ][j ][k + 1], \ + tab[i + 1][j ][k + 1], \ + tab[i ][j + 1][k + 1]) #define CREATE_PRISM_2 new MPrism(tab[i + 1][j + 1][k ], \ - tab[i ][j + 1][k ], \ - tab[i + 1][j ][k ], \ - tab[i + 1][j + 1][k + 1], \ - tab[i ][j + 1][k + 1], \ - tab[i + 1][j ][k + 1]) + tab[i ][j + 1][k ], \ + tab[i + 1][j ][k ], \ + tab[i + 1][j + 1][k + 1], \ + tab[i ][j + 1][k + 1], \ + tab[i + 1][j ][k + 1]) #define CREATE_SIM_1 new MTetrahedron(tab[i ][j ][k ], \ - tab[i + 1][j ][k ], \ - tab[i ][j + 1][k ], \ - tab[i ][j ][k + 1]) + tab[i + 1][j ][k ], \ + tab[i ][j + 1][k ], \ + tab[i ][j ][k + 1]) #define CREATE_SIM_2 new MTetrahedron(tab[i + 1][j ][k ], \ - tab[i ][j + 1][k ], \ - tab[i ][j ][k + 1], \ - tab[i + 1][j ][k + 1]) + tab[i ][j + 1][k ], \ + tab[i ][j ][k + 1], \ + tab[i + 1][j ][k + 1]) #define CREATE_SIM_3 new MTetrahedron(tab[i ][j ][k + 1], \ - tab[i + 1][j ][k + 1], \ - tab[i ][j + 1][k ], \ - tab[i ][j + 1][k + 1]) + tab[i + 1][j ][k + 1], \ + tab[i ][j + 1][k ], \ + tab[i ][j + 1][k + 1]) #define CREATE_SIM_4 new MTetrahedron(tab[i + 1][j ][k ], \ - tab[i ][j + 1][k ], \ - tab[i + 1][j ][k + 1], \ - tab[i + 1][j + 1][k ]) + tab[i ][j + 1][k ], \ + tab[i + 1][j ][k + 1], \ + tab[i + 1][j + 1][k ]) #define CREATE_SIM_5 new MTetrahedron(tab[i ][j + 1][k ], \ - tab[i ][j + 1][k + 1], \ - tab[i + 1][j ][k + 1], \ - tab[i + 1][j + 1][k ]) + tab[i ][j + 1][k + 1], \ + tab[i + 1][j ][k + 1], \ + tab[i + 1][j + 1][k ]) #define CREATE_SIM_6 new MTetrahedron(tab[i + 1][j ][k + 1], \ - tab[i ][j + 1][k + 1], \ - tab[i + 1][j + 1][k + 1], \ - tab[i + 1][j + 1][k ]) + tab[i ][j + 1][k + 1], \ + tab[i + 1][j + 1][k + 1], \ + tab[i + 1][j + 1][k ]) double transfiniteHex(double f1, double f2, double f3, double f4, - double f5, double f6, - double c1, double c2, double c3, double c4, - double c5, double c6, double c7, double c8, - double c9, double c10, double c11, double c12, - double s1, double s2, double s3, double s4, - double s5, double s6, double s7, double s8, - double u, double v, double w) + double f5, double f6, + double c1, double c2, double c3, double c4, + double c5, double c6, double c7, double c8, + double c9, double c10, double c11, double c12, + double s1, double s2, double s3, double s4, + double s5, double s6, double s7, double s8, + double u, double v, double w) { return (1-u)*f4 + u*f2 + (1-v)*f1 + v*f3 + (1-w)*f5 + w*f6 - ((1-u)*(1-v)*c9 + (1-u)*v*c12 + u*(1-v)*c10 + u*v*c11) - @@ -130,32 +130,32 @@ double transfiniteHex(double f1, double f2, double f3, double f4, } MVertex *transfiniteHex(MVertex *f1, MVertex *f2, MVertex *f3, MVertex *f4, - MVertex *f5, MVertex *f6, - MVertex *c1, MVertex *c2, MVertex *c3, MVertex *c4, - MVertex *c5, MVertex *c6, MVertex *c7, MVertex *c8, - MVertex *c9, MVertex *c10, MVertex *c11, MVertex *c12, - MVertex *s1, MVertex *s2, MVertex *s3, MVertex *s4, - MVertex *s5, MVertex *s6, MVertex *s7, MVertex *s8, - double u, double v, double w) + MVertex *f5, MVertex *f6, + MVertex *c1, MVertex *c2, MVertex *c3, MVertex *c4, + MVertex *c5, MVertex *c6, MVertex *c7, MVertex *c8, + MVertex *c9, MVertex *c10, MVertex *c11, MVertex *c12, + MVertex *s1, MVertex *s2, MVertex *s3, MVertex *s4, + MVertex *s5, MVertex *s6, MVertex *s7, MVertex *s8, + double u, double v, double w) { double x = transfiniteHex(f1->x(), f2->x(), f3->x(), f4->x(), f5->x(), f6->x(), - c1->x(), c2->x(), c3->x(), c4->x(), c5->x(), c6->x(), - c7->x(), c8->x(), c9->x(), c10->x(), c11->x(), c12->x(), - s1->x(), s2->x(), s3->x(), s4->x(), - s5->x(), s6->x(), s7->x(), s8->x(), - u, v, w); + c1->x(), c2->x(), c3->x(), c4->x(), c5->x(), c6->x(), + c7->x(), c8->x(), c9->x(), c10->x(), c11->x(), c12->x(), + s1->x(), s2->x(), s3->x(), s4->x(), + s5->x(), s6->x(), s7->x(), s8->x(), + u, v, w); double y = transfiniteHex(f1->y(), f2->y(), f3->y(), f4->y(), f5->y(), f6->y(), - c1->y(), c2->y(), c3->y(), c4->y(), c5->y(), c6->y(), - c7->y(), c8->y(), c9->y(), c10->y(), c11->y(), c12->y(), - s1->y(), s2->y(), s3->y(), s4->y(), - s5->y(), s6->y(), s7->y(), s8->y(), - u, v, w); + c1->y(), c2->y(), c3->y(), c4->y(), c5->y(), c6->y(), + c7->y(), c8->y(), c9->y(), c10->y(), c11->y(), c12->y(), + s1->y(), s2->y(), s3->y(), s4->y(), + s5->y(), s6->y(), s7->y(), s8->y(), + u, v, w); double z = transfiniteHex(f1->z(), f2->z(), f3->z(), f4->z(), f5->z(), f6->z(), - c1->z(), c2->z(), c3->z(), c4->z(), c5->z(), c6->z(), - c7->z(), c8->z(), c9->z(), c10->z(), c11->z(), c12->z(), - s1->z(), s2->z(), s3->z(), s4->z(), - s5->z(), s6->z(), s7->z(), s8->z(), - u, v, w); + c1->z(), c2->z(), c3->z(), c4->z(), c5->z(), c6->z(), + c7->z(), c8->z(), c9->z(), c10->z(), c11->z(), c12->z(), + s1->z(), s2->z(), s3->z(), s4->z(), + s5->z(), s6->z(), s7->z(), s8->z(), + u, v, w); return new MVertex(x, y, z); } @@ -184,7 +184,7 @@ public: std::vector<MVertex*> s(8); if(corners.size() == 8){ for(int i = 0; i < 8; i++) - s[i] = corners[i]->mesh_vertices[0]; + s[i] = corners[i]->mesh_vertices[0]; } else if(corners.size() == 6){ s[0] = corners[0]->mesh_vertices[0]; @@ -218,9 +218,9 @@ public: // map the surface mesh onto the canonical transfinite hexahedron int faces[] = {0, 1, 5, 4, 1, 2, 6, 5, 3, 2, 6, 7, - 0, 3, 7, 4, 0, 1, 2, 3, 4, 5, 6, 7}; + 0, 3, 7, 4, 0, 1, 2, 3, 4, 5, 6, 7}; int permutations[] = {0, 1, 2, 3, 1, 2, 3, 0, 2, 3, 0, 1, 3, 0, 1, 2, - 3, 2, 1, 0, 2, 1, 0, 3, 1, 0, 3, 2, 0, 3, 2, 1}; + 3, 2, 1, 0, 2, 1, 0, 3, 1, 0, 3, 2, 0, 3, 2, 1}; for(int p = 0; p < 8; p++) { for(int f = 0; f < 6; f++) { if(s[faces[4 * f + 0]] == c[permutations[4 * p + 0]] && @@ -229,14 +229,14 @@ public: s[faces[4 * f + 3]] == c[permutations[4 * p + 3]]) { _index = f; _permutation = p; - break; + break; } } } Msg(DEBUG, "Found face index %d (permutation = %d)", _index, _permutation); for(int i = 0; i <= _LL; i++) for(int j = 0; j <= _HH; j++) - _list.push_back(_gf->transfinite_vertices[i][j]); + _list.push_back(_gf->transfinite_vertices[i][j]); } // returns the index of the face in the reference hexahedron @@ -269,7 +269,7 @@ public: if(index >= 0 && index < (int)_list.size()) v = _list[index]; if(index < 0 || index >= (int)_list.size() || !v){ Msg(GERROR, "Wrong index in transfinite mesh of surface %d: " - "m=%d n=%d M=%d N=%d perm=%d", _gf->tag(), m, n, M, N, _permutation); + "m=%d n=%d M=%d N=%d perm=%d", _gf->tag(), m, n, M, N, _permutation); return _list[0]; } return v; @@ -293,7 +293,7 @@ int MeshTransfiniteVolume(GRegion *gr) GOrientedTransfiniteFace f(*it, gr->meshAttributes.corners); if(f.index() < 0){ Msg(GERROR, "Incompatible surface %d in transfinite volume %d", - (*it)->tag(), gr->tag()); + (*it)->tag(), gr->tag()); return 0; } orientedFaces[f.index()] = f; @@ -368,28 +368,28 @@ int MeshTransfiniteVolume(GRegion *gr) MVertex *f5 = orientedFaces[5].getVertex(i, j); for(int k = 0; k < N_k; k++) { - double w = lengths_k[k] / L_k; + double w = lengths_k[k] / L_k; MVertex *c8 = orientedFaces[0].getVertex(0, k); MVertex *c9 = orientedFaces[0].getVertex(N_i - 1, k); MVertex *c10 = orientedFaces[2].getVertex(N_i - 1, k); MVertex *c11 = orientedFaces[2].getVertex(0, k); - MVertex *f0 = orientedFaces[0].getVertex(i, k); - MVertex *f1 = orientedFaces[1].getVertex(j, k); - MVertex *f2 = orientedFaces[2].getVertex(i, k); - MVertex *f3; + MVertex *f0 = orientedFaces[0].getVertex(i, k); + MVertex *f1 = orientedFaces[1].getVertex(j, k); + MVertex *f2 = orientedFaces[2].getVertex(i, k); + MVertex *f3; if(gr->meshAttributes.corners.size() == 8) f3 = orientedFaces[3].getVertex(j, k); - else + else f3 = c8; if(i && j && k && i != N_i - 1 && j != N_j - 1 && k != N_k - 1) { MVertex *newv = transfiniteHex(f0, f1, f2, f3, f4, f5, - c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, - s0, s1, s2, s3, s4, s5, s6, s7, - u, v, w); - gr->mesh_vertices.push_back(newv); + c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, + s0, s1, s2, s3, s4, s5, s6, s7, + u, v, w); + gr->mesh_vertices.push_back(newv); tab[i][j][k] = newv; } else if(!i) { @@ -421,51 +421,51 @@ int MeshTransfiniteVolume(GRegion *gr) for(int j = 0; j < N_j - 1; j++) { for(int k = 0; k < N_k - 1; k++) { if(orientedFaces[0].recombined() && orientedFaces[1].recombined() && - orientedFaces[2].recombined() && orientedFaces[3].recombined() && - orientedFaces[4].recombined() && orientedFaces[5].recombined()) { + orientedFaces[2].recombined() && orientedFaces[3].recombined() && + orientedFaces[4].recombined() && orientedFaces[5].recombined()) { gr->hexahedra.push_back(CREATE_HEX); } else if(!orientedFaces[0].recombined() && orientedFaces[1].recombined() && - !orientedFaces[2].recombined() && orientedFaces[3].recombined() && - orientedFaces[4].recombined() && orientedFaces[5].recombined()) { + !orientedFaces[2].recombined() && orientedFaces[3].recombined() && + orientedFaces[4].recombined() && orientedFaces[5].recombined()) { gr->prisms.push_back(new MPrism(tab[i ][j ][k ], - tab[i + 1][j ][k ], - tab[i ][j ][k + 1], - tab[i ][j + 1][k ], - tab[i + 1][j + 1][k ], - tab[i ][j + 1][k + 1])); - gr->prisms.push_back(new MPrism(tab[i + 1][j ][k + 1], - tab[i ][j ][k + 1], - tab[i + 1][j ][k ], - tab[i + 1][j + 1][k + 1], - tab[i ][j + 1][k + 1], - tab[i + 1][j + 1][k ])); + tab[i + 1][j ][k ], + tab[i ][j ][k + 1], + tab[i ][j + 1][k ], + tab[i + 1][j + 1][k ], + tab[i ][j + 1][k + 1])); + gr->prisms.push_back(new MPrism(tab[i + 1][j ][k + 1], + tab[i ][j ][k + 1], + tab[i + 1][j ][k ], + tab[i + 1][j + 1][k + 1], + tab[i ][j + 1][k + 1], + tab[i + 1][j + 1][k ])); } else if(orientedFaces[0].recombined() && !orientedFaces[1].recombined() && - orientedFaces[2].recombined() && !orientedFaces[3].recombined() && - orientedFaces[4].recombined() && orientedFaces[5].recombined()) { + orientedFaces[2].recombined() && !orientedFaces[3].recombined() && + orientedFaces[4].recombined() && orientedFaces[5].recombined()) { gr->prisms.push_back(new MPrism(tab[i + 1][j ][k ], - tab[i + 1][j + 1][k ], - tab[i + 1][j ][k + 1], - tab[i ][j ][k ], - tab[i ][j + 1][k ], - tab[i ][j ][k + 1])); + tab[i + 1][j + 1][k ], + tab[i + 1][j ][k + 1], + tab[i ][j ][k ], + tab[i ][j + 1][k ], + tab[i ][j ][k + 1])); gr->prisms.push_back(new MPrism(tab[i + 1][j + 1][k + 1], - tab[i + 1][j ][k + 1], - tab[i + 1][j + 1][k ], - tab[i ][j + 1][k + 1], - tab[i ][j ][k + 1], - tab[i ][j + 1][k ])); + tab[i + 1][j ][k + 1], + tab[i + 1][j + 1][k ], + tab[i ][j + 1][k + 1], + tab[i ][j ][k + 1], + tab[i ][j + 1][k ])); } else if(orientedFaces[0].recombined() && orientedFaces[1].recombined() && - orientedFaces[2].recombined() && orientedFaces[3].recombined() && - !orientedFaces[4].recombined() && !orientedFaces[5].recombined()) { + orientedFaces[2].recombined() && orientedFaces[3].recombined() && + !orientedFaces[4].recombined() && !orientedFaces[5].recombined()) { gr->prisms.push_back(CREATE_PRISM_1); gr->prisms.push_back(CREATE_PRISM_2); } else if(!orientedFaces[0].recombined() && !orientedFaces[1].recombined() && - !orientedFaces[2].recombined() && !orientedFaces[3].recombined() && - !orientedFaces[4].recombined() && !orientedFaces[5].recombined()) { + !orientedFaces[2].recombined() && !orientedFaces[3].recombined() && + !orientedFaces[4].recombined() && !orientedFaces[5].recombined()) { gr->tetrahedra.push_back(CREATE_SIM_1); gr->tetrahedra.push_back(CREATE_SIM_2); gr->tetrahedra.push_back(CREATE_SIM_3); @@ -485,33 +485,33 @@ int MeshTransfiniteVolume(GRegion *gr) for(int j = 0; j < N_j - 1; j++) { for(int k = 0; k < N_k - 1; k++) { if((orientedFaces[0].recombined() && orientedFaces[1].recombined() && - orientedFaces[2].recombined() && orientedFaces[4].recombined() && - orientedFaces[5].recombined()) || + orientedFaces[2].recombined() && orientedFaces[4].recombined() && + orientedFaces[5].recombined()) || (orientedFaces[0].recombined() && orientedFaces[1].recombined() && - orientedFaces[2].recombined() && !orientedFaces[4].recombined() && - !orientedFaces[5].recombined())) { + orientedFaces[2].recombined() && !orientedFaces[4].recombined() && + !orientedFaces[5].recombined())) { gr->prisms.push_back(new MPrism(tab[0 ][j ][k ], - tab[1 ][j ][k ], - tab[1 ][j + 1][k ], - tab[0 ][j ][k + 1], - tab[1 ][j ][k + 1], - tab[1 ][j + 1][k + 1])); + tab[1 ][j ][k ], + tab[1 ][j + 1][k ], + tab[0 ][j ][k + 1], + tab[1 ][j ][k + 1], + tab[1 ][j + 1][k + 1])); } else if(!orientedFaces[0].recombined() && !orientedFaces[1].recombined() && - !orientedFaces[2].recombined() && !orientedFaces[4].recombined() && - !orientedFaces[5].recombined()) { + !orientedFaces[2].recombined() && !orientedFaces[4].recombined() && + !orientedFaces[5].recombined()) { gr->tetrahedra.push_back(new MTetrahedron(tab[0 ][j ][k ], - tab[1 ][j ][k ], - tab[1 ][j + 1][k ], - tab[0 ][j ][k + 1])); + tab[1 ][j ][k ], + tab[1 ][j + 1][k ], + tab[0 ][j ][k + 1])); gr->tetrahedra.push_back(new MTetrahedron(tab[1 ][j ][k ], - tab[1 ][j + 1][k ], - tab[0 ][j ][k + 1], - tab[1 ][j ][k + 1])); + tab[1 ][j + 1][k ], + tab[0 ][j ][k + 1], + tab[1 ][j ][k + 1])); gr->tetrahedra.push_back(new MTetrahedron(tab[0 ][j ][k + 1], - tab[1 ][j + 1][k + 1], - tab[1 ][j ][k + 1], - tab[1 ][j + 1][k ])); + tab[1 ][j + 1][k + 1], + tab[1 ][j ][k + 1], + tab[1 ][j + 1][k ])); } else { Msg(GERROR, "Wrong surface recombination in transfinite volume %d", gr->tag()); @@ -523,19 +523,19 @@ int MeshTransfiniteVolume(GRegion *gr) for(int j = 0; j < N_j - 1; j++) { for(int k = 0; k < N_k - 1; k++) { if(orientedFaces[0].recombined() && orientedFaces[1].recombined() && - orientedFaces[2].recombined() && orientedFaces[4].recombined() && - orientedFaces[5].recombined()) { + orientedFaces[2].recombined() && orientedFaces[4].recombined() && + orientedFaces[5].recombined()) { gr->hexahedra.push_back(CREATE_HEX); } else if(orientedFaces[0].recombined() && orientedFaces[1].recombined() && - orientedFaces[2].recombined() && !orientedFaces[4].recombined() && - !orientedFaces[5].recombined()) { + orientedFaces[2].recombined() && !orientedFaces[4].recombined() && + !orientedFaces[5].recombined()) { gr->prisms.push_back(CREATE_PRISM_1); gr->prisms.push_back(CREATE_PRISM_2); } else if(!orientedFaces[0].recombined() && !orientedFaces[1].recombined() && - !orientedFaces[2].recombined() && !orientedFaces[4].recombined() && - !orientedFaces[5].recombined()) { + !orientedFaces[2].recombined() && !orientedFaces[4].recombined() && + !orientedFaces[5].recombined()) { gr->tetrahedra.push_back(CREATE_SIM_1); gr->tetrahedra.push_back(CREATE_SIM_2); gr->tetrahedra.push_back(CREATE_SIM_3); diff --git a/Mesh/qualityMeasures.cpp b/Mesh/qualityMeasures.cpp index e58c061b940576e527c6071d56bfbdab97df2f8e..d77fe61f93e0152ce11dd0818131dab35d9fbd09 100644 --- a/Mesh/qualityMeasures.cpp +++ b/Mesh/qualityMeasures.cpp @@ -1,4 +1,4 @@ -// $Id: qualityMeasures.cpp,v 1.12 2008-02-21 19:20:58 geuzaine Exp $ +// $Id: qualityMeasures.cpp,v 1.13 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -26,7 +26,7 @@ #include "Numeric.h" double qmTriangle(const BDS_Point *p1, const BDS_Point *p2, const BDS_Point *p3, - const gmshQualityMeasure4Triangle &cr) + const gmshQualityMeasure4Triangle &cr) { return qmTriangle(p1->X, p1->Y, p1->Z, p2->X, p2->Y, p2->Z, p3->X, p3->Y, p3->Z, cr); } @@ -44,19 +44,19 @@ double qmTriangle(MTriangle*t, const gmshQualityMeasure4Triangle &cr) } double qmTriangle(const MVertex *v1, const MVertex *v2, const MVertex *v3, - const gmshQualityMeasure4Triangle &cr) + const gmshQualityMeasure4Triangle &cr) { return qmTriangle(v1->x(), v1->y(), v1->z(), v2->x(), v2->y(), v2->z(), - v3->x(), v3->y(), v3->z(), cr); + v3->x(), v3->y(), v3->z(), cr); } // Triangle abc // quality is between 0 and 1 double qmTriangle(const double &xa, const double &ya, const double &za, - const double &xb, const double &yb, const double &zb, - const double &xc, const double &yc, const double &zc, - const gmshQualityMeasure4Triangle &cr) + const double &xb, const double &yb, const double &zb, + const double &xc, const double &yc, const double &zc, + const gmshQualityMeasure4Triangle &cr) { double quality; switch(cr){ @@ -84,8 +84,8 @@ double qmTriangle(const double &xa, const double &ya, const double &za, double b [3] = {xb - xa, yb - ya, zb - za}; double c [3] ; prodve(a, b, c); norme(c); double A[3][3] = {{a[0] , b[0] , c[0]} , - {a[1] , b[1] , c[1]} , - {a[2] , b[2] , c[2]}}; + {a[1] , b[1] , c[1]} , + {a[2] , b[2] , c[2]}}; quality = -1; } break; @@ -99,21 +99,21 @@ double qmTriangle(const double &xa, const double &ya, const double &za, double qmTet(MTetrahedron *t, const gmshQualityMeasure4Tet &cr, double *volume) { return qmTet(t->getVertex(0), t->getVertex(1), t->getVertex(2), t->getVertex(3), - cr, volume); + cr, volume); } double qmTet(const MVertex *v1, const MVertex *v2, const MVertex *v3, - const MVertex *v4, const gmshQualityMeasure4Tet &cr, double *volume) + const MVertex *v4, const gmshQualityMeasure4Tet &cr, double *volume) { return qmTet(v1->x(), v1->y(), v1->z(), v2->x(), v2->y(), v2->z(), - v3->x(), v3->y(), v3->z(), v4->x(), v4->y(), v4->z(), cr, volume); + v3->x(), v3->y(), v3->z(), v4->x(), v4->y(), v4->z(), cr, volume); } double qmTet(const double &x1, const double &y1, const double &z1, - const double &x2, const double &y2, const double &z2, - const double &x3, const double &y3, const double &z3, - const double &x4, const double &y4, const double &z4, - const gmshQualityMeasure4Tet &cr, double *volume) + const double &x2, const double &y2, const double &z2, + const double &x3, const double &y3, const double &z3, + const double &x4, const double &y4, const double &z4, + const gmshQualityMeasure4Tet &cr, double *volume) { double quality; switch(cr){ @@ -133,8 +133,8 @@ double qmTet(const double &x1, const double &y1, const double &z1, mat[2][2] = z4 - z1; *volume = fabs(det3x3(mat)) / 6.; double l = ((x2 - x1) * (x2 - x1) + - (y2 - y1) * (y2 - y1) + - (z2 - z1) * (z2 - z1)); + (y2 - y1) * (y2 - y1) + + (z2 - z1) * (z2 - z1)); l += ((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1) + (z3 - z1) * (z3 - z1)); l += ((x4 - x1) * (x4 - x1) + (y4 - y1) * (y4 - y1) + (z4 - z1) * (z4 - z1)); l += ((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2) + (z3 - z2) * (z3 - z2)); @@ -165,19 +165,19 @@ double qmTet(const double &x1, const double &y1, const double &z1, double s4 = fabs(triangle_area(p1, p2, p3)); double rhoin = 3. * fabs(*volume) / (s1 + s2 + s3 + s4); double l = sqrt((x2 - x1) * (x2 - x1) + - (y2 - y1) * (y2 - y1) + - (z2 - z1) * (z2 - z1)); + (y2 - y1) * (y2 - y1) + + (z2 - z1) * (z2 - z1)); l = std::max(l, sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1) + - (z3 - z1) * (z3 - z1))); + (z3 - z1) * (z3 - z1))); l = std::max(l, sqrt((x4 - x1) * (x4 - x1) + (y4 - y1) * (y4 - y1) + - (z4 - z1) * (z4 - z1))); + (z4 - z1) * (z4 - z1))); l = std::max(l, sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2) + - (z3 - z2) * (z3 - z2))); + (z3 - z2) * (z3 - z2))); l = std::max(l, sqrt((x4 - x2) * (x4 - x2) + (y4 - y2) * (y4 - y2) + - (z4 - z2) * (z4 - z2))); + (z4 - z2) * (z4 - z2))); l = std::max(l, sqrt((x3 - x4) * (x3 - x4) + (y3 - y4) * (y3 - y4) + - (z3 - z4) * (z3 - z4))); - return 2. * sqrt(6.) * rhoin / l; + (z3 - z4) * (z3 - z4))); + return 2. * sqrt(6.) * rhoin / l; } break; default: diff --git a/Mesh/qualityMeasures.h b/Mesh/qualityMeasures.h index 66c51e274426daac5f3d95a1dfc19c96794c4d84..47309a41baa9821653bf17640e37b49c52d18408 100644 --- a/Mesh/qualityMeasures.h +++ b/Mesh/qualityMeasures.h @@ -31,22 +31,22 @@ enum gmshQualityMeasure4Tet{QMTET_1, QMTET_2, QMTET_3, QMTET_ONE, QMTET_COND}; double qmTriangle(MTriangle *f, const gmshQualityMeasure4Triangle &cr); double qmTriangle(BDS_Face *f, const gmshQualityMeasure4Triangle &cr); double qmTriangle(const BDS_Point *p1, const BDS_Point *p2, const BDS_Point *p3, - const gmshQualityMeasure4Triangle &cr); + const gmshQualityMeasure4Triangle &cr); double qmTriangle(const MVertex *v1, const MVertex *v2, const MVertex *v3, - const gmshQualityMeasure4Triangle &cr); + const gmshQualityMeasure4Triangle &cr); double qmTriangle(const double *d1, const double *d2, const double *d3, - const gmshQualityMeasure4Triangle &cr); + const gmshQualityMeasure4Triangle &cr); double qmTriangle(const double &x1, const double &y1, const double &z1, - const double &x2, const double &y2, const double &z2, - const double &x3, const double &y3, const double &z3, - const gmshQualityMeasure4Triangle &cr); + const double &x2, const double &y2, const double &z2, + const double &x3, const double &y3, const double &z3, + const gmshQualityMeasure4Triangle &cr); double qmTet(MTetrahedron *t, const gmshQualityMeasure4Tet &cr, double *volume = 0); double qmTet(const MVertex *v1, const MVertex *v2, const MVertex *v3, - const MVertex *v4, const gmshQualityMeasure4Tet &cr, double *volume = 0); + const MVertex *v4, const gmshQualityMeasure4Tet &cr, double *volume = 0); double qmTet(const double &x1, const double &y1, const double &z1, - const double &x2, const double &y2, const double &z2, - const double &x3, const double &y3, const double &z3, - const double &x4, const double &y4, const double &z4, - const gmshQualityMeasure4Tet &cr, double *volume = 0); + const double &x2, const double &y2, const double &z2, + const double &x3, const double &y3, const double &z3, + const double &x4, const double &y4, const double &z4, + const gmshQualityMeasure4Tet &cr, double *volume = 0); #endif diff --git a/Numeric/EigSolve.cpp b/Numeric/EigSolve.cpp index 5cfc9a194049438f12e4e856a48c9c6d7bc7ea2f..7ce8e4e8338b11b8ec65d955c863735df624e7bf 100644 --- a/Numeric/EigSolve.cpp +++ b/Numeric/EigSolve.cpp @@ -1,4 +1,4 @@ -// $Id: EigSolve.cpp,v 1.9 2008-02-17 08:48:02 geuzaine Exp $ +// $Id: EigSolve.cpp,v 1.10 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -640,13 +640,13 @@ static void normvec(int n, double *Z, double *wi) for (int i = 0; i < n; i++){ double absxi = fabs(Z[j*n+i]); if (absxi > PREC){ - double dummy = scale/absxi; - if (scale < absxi){ - ssq = 1.0 + ssq*dummy*dummy; - scale = absxi; - } - else - ssq += 1.0/dummy/dummy; + double dummy = scale/absxi; + if (scale < absxi){ + ssq = 1.0 + ssq*dummy*dummy; + scale = absxi; + } + else + ssq += 1.0/dummy/dummy; } } @@ -654,16 +654,16 @@ static void normvec(int n, double *Z, double *wi) // If complex eigenvalue, take into account imaginary part of // eigenvector for (int i = 0; i < n; i++){ - double absxi = fabs(Z[(j + 1)*n+i]); - if (absxi > PREC){ - double dummy = scale/absxi; - if (scale < absxi){ - ssq = 1.0 + ssq*dummy*dummy; - scale = absxi; - } - else - ssq += 1.0/dummy/dummy; - } + double absxi = fabs(Z[(j + 1)*n+i]); + if (absxi > PREC){ + double dummy = scale/absxi; + if (scale < absxi){ + ssq = 1.0 + ssq*dummy*dummy; + scale = absxi; + } + else + ssq += 1.0/dummy/dummy; + } } } @@ -678,13 +678,13 @@ static void normvec(int n, double *Z, double *wi) // eigenvector j++; for (int i = 0; i < n; i++) - Z[j*n+i] /= norm; + Z[j*n+i] /= norm; } } } int EigSolve(int nm,int n,double *A,double *wr,double *wi, - double *v,int *work1,double *work2) + double *v,int *work1,double *work2) { int is1,is2,ierr; @@ -702,7 +702,7 @@ int EigSolve(int nm,int n,double *A,double *wr,double *wi, // algorithm (based on a routine from Laurent Stainier) int EigSolveSym(int n,int nm,double *A,double *d,double *V, - double *b,double *z) + double *b,double *z) { static const int NSWMAX = 50; @@ -823,8 +823,8 @@ void EigSort(int n, double *wr, double *wi, double *B) for (int j = i + 1; j < n; j++){ const double ej = wr[j]; if(ej < ek){ - k = j; - ek = ej; + k = j; + ek = ej; } } if (k != i){ @@ -845,16 +845,16 @@ int EigSolve3x3(const double A[9], double wr[3], double wi[3], double v[9]) fabs(A[2]-A[6]) < PREC && fabs(A[5]-A[7]) < PREC){ double work1[3], work2[3], S[6] = { A[0], - A[1], A[4], - A[2], A[5], A[8]}; + A[1], A[4], + A[2], A[5], A[8]}; ierr = EigSolveSym(3, 3, S, wr, v, work1, work2); wi[0] = wi[1] = wi[2] = 0.0; } else{ int work1[3]; double work2[3], M[9] = { A[0], A[1], A[2], - A[3], A[4], A[5], - A[6], A[7], A[8]}; + A[3], A[4], A[5], + A[6], A[7], A[8]}; ierr = EigSolve(3, 3, M, wr, wi, v, work1, work2); } EigSort(3, wr, wi, v); @@ -865,8 +865,8 @@ int EigSolve3x3(const double A[9], double wr[3], double wi[3], double v[9]) int main () { //double A[9] = {-0.00299043,-8.67362e-19,0, - // -8.67362e-19,-0.00299043,-1.73472e-18, - // 0,-1.73472e-18,0.01}; + // -8.67362e-19,-0.00299043,-1.73472e-18, + // 0,-1.73472e-18,0.01}; double A[9] = {1, 2, 3, 2, 4, 5, 3, 5, 6}; //double A[9] = {1, 2, 3, 1, 4, 5, 3, 5, 6}; double wr[3], wi[3], B[9]; diff --git a/Numeric/EigSolve.h b/Numeric/EigSolve.h index 713696997d32494da2addc60986cbe5e699a09fc..b7b300e827f99a84adc76375b740d9421c7b15af 100644 --- a/Numeric/EigSolve.h +++ b/Numeric/EigSolve.h @@ -24,9 +24,9 @@ // Laurent Stainier int EigSolve(int nm,int n,double *A,double *wr,double *wi, - double *v,int *work1,double *work2); + double *v,int *work1,double *work2); int EigSolveSym(int n,int nm,double *A,double *d,double *V, - double *b,double *z); + double *b,double *z); void EigSort(int n, double *wr, double *wi, double *B); int EigSolve3x3(const double A[9], double wr[3], double wi[3], double v[9]); diff --git a/Numeric/FunctionSpace.cpp b/Numeric/FunctionSpace.cpp index e95ea074491e741cc156e3dbc13a8d2c2940aff9..285a0b4a70d1838914236f6b3f62dbec6ad957ab 100644 --- a/Numeric/FunctionSpace.cpp +++ b/Numeric/FunctionSpace.cpp @@ -1,4 +1,4 @@ -// $Id: FunctionSpace.cpp,v 1.3 2008-02-21 13:44:56 geuzaine Exp $ +// $Id: FunctionSpace.cpp,v 1.4 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -185,7 +185,7 @@ void nodepositionface0(int order, double *u, double *v, double *w) if (order > 2){ int nbdoftemp = nbdoftriangle(order - 3); nodepositionface0(order - 3, &u[3 + 3 * (order - 1)], &v[3 + 3 * (order - 1)], - &w[3 + 3* (order - 1)]); + &w[3 + 3* (order - 1)]); for (int k = 0; k < nbdoftemp; k++){ u[3 + k + 3 * (order - 1)] = u[3 + k + 3 * (order - 1)] * (order - 3) + 1.; v[3 + k + 3 * (order - 1)] = v[3 + k + 3 * (order - 1)] * (order - 3) + 1.; @@ -224,7 +224,7 @@ void nodepositionface1(int order, double *u, double *v, double *w) if (order > 2){ int nbdoftemp = nbdoftriangle(order - 3); nodepositionface1(order - 3, &u[3 + 3 * (order - 1)], &v[3 + 3 * (order -1 )], - &w[3 + 3 * (order - 1)]); + &w[3 + 3 * (order - 1)]); for (int k = 0; k < nbdoftemp; k++){ u[3 + k + 3 * (order - 1)] = u[3 + k + 3 * (order - 1)] * (order - 3) + 1.; v[3 + k + 3 * (order - 1)] = v[3 + k + 3 * (order - 1)] * (order - 3); @@ -263,7 +263,7 @@ void nodepositionface2(int order, double *u, double *v, double *w) if (order > 2){ int nbdoftemp = nbdoftriangle(order - 3); nodepositionface2(order - 3, &u[3 + 3 * (order - 1)], &v[3 + 3 * (order - 1)], - &w[3 + 3 * (order - 1)]); + &w[3 + 3 * (order - 1)]); for (int k = 0; k < nbdoftemp; k++){ u[3 + k + 3 * (order - 1)] = u[3 + k + 3 * (order - 1)] * (order - 3) + 1.; v[3 + k + 3 * (order - 1)] = v[3 + k + 3 * (order - 1)] * (order - 3) + 1.; @@ -302,7 +302,7 @@ void nodepositionface3(int order, double *u, double *v, double *w) if (order > 2){ int nbdoftemp = nbdoftriangle(order - 3); nodepositionface3(order - 3, &u[3 + 3 * (order - 1)], &v[3 + 3 * (order - 1)], - &w[3 + 3 * (order - 1)]); + &w[3 + 3 * (order - 1)]); for (int k = 0; k < nbdoftemp; k++){ u[3 + k + 3 * (order - 1)] = u[3 + k + 3 * (order - 1)] * (order - 3); v[3 + k + 3 * (order - 1)] = v[3 + k + 3 * (order - 1)] * (order - 3) + 1.; @@ -352,7 +352,7 @@ Double_Matrix gmshGeneratePointsTetrahedron(int order, bool serendip) point(4 + 3 * (order - 1) + k, 0) = 0.; point(4 + 4 * (order - 1) + k, 0) = order - 1 - k; point(4 + 5 * (order - 1) + k, 0) = 0.; - + point(4 + k, 1) = 0.; point(4 + order - 1 + k, 1) = k + 1; point(4 + 2 * (order - 1) + k, 1) = order - 1 - k; @@ -420,7 +420,7 @@ Double_Matrix gmshGeneratePointsTetrahedron(int order, bool serendip) delete [] v; delete [] w; - if (!serendip && order > 3) { + if (!serendip && order > 3) { Double_Matrix interior = gmshGeneratePointsTetrahedron(order - 4, false); for (int k = 0; k < interior.size1(); k++) { @@ -496,7 +496,7 @@ Double_Matrix gmshGeneratePointsTriangle(int order, bool serendip) } Double_Matrix generateLagrangeMonomialCoefficients(const Double_Matrix& monomial, - const Double_Matrix& point) + const Double_Matrix& point) { if (monomial.size1() != point.size1()) throw; if (monomial.size2() != point.size2()) throw; diff --git a/Numeric/FunctionSpace.h b/Numeric/FunctionSpace.h index 308313207123c795ecae3a76dfec90e4d4e755ff..7726e26bc9d777f3ff567f7406f1969f207ec081 100644 --- a/Numeric/FunctionSpace.h +++ b/Numeric/FunctionSpace.h @@ -41,8 +41,8 @@ struct gmshFunctionSpace for(int i = 0; i < coefficients.size1(); i++){ sf[i] = 0; for(int j = 0; j < coefficients.size2(); j++){ - sf[i] += coefficients(i, j) * pow(u, monomials(j, 0)) * - pow(v, monomials(j, 1)) * pow(w, monomials(j, 2)); + sf[i] += coefficients(i, j) * pow(u, monomials(j, 0)) * + pow(v, monomials(j, 1)) * pow(w, monomials(j, 2)); } } } @@ -53,7 +53,7 @@ struct gmshFunctionSpace for (int i = 0; i < coefficients.size1(); i++){ sf[i] = 0; for(int j = 0; j < coefficients.size2(); j++){ - sf[i] += coefficients(i, j) * p[j][0] * p[j][1]; + sf[i] += coefficients(i, j) * p[j][0] * p[j][1]; } } } @@ -64,18 +64,18 @@ struct gmshFunctionSpace grads[i][1] = 0; grads[i][2] = 0; for(int j = 0; j < coefficients.size2(); j++){ - if ((monomials)(j, 0) > 0) - grads[i][0] += (coefficients)(i, j) * pow(u, (monomials)(j, 0) - 1) * - (monomials)(j, 0) * pow(v, (monomials)(j, 1)) * - pow(w, (monomials)(j, 2)); - if ((monomials)(j, 1) > 0) - grads[i][1] += (coefficients)(i, j) * pow(u,(monomials)(j, 0)) * - pow(v, (monomials)(j, 1) - 1) * (monomials)(j, 1) * - pow(w, (monomials)(j, 2)); - if ((monomials)(j, 2) > 0) - grads[i][2] += (coefficients)(i, j) * pow(u, (monomials)(j, 0)) * - pow(v, (monomials)(j, 1)) * pow(w, (monomials)(j, 2) - 1) * - (monomials)(j, 2); + if ((monomials)(j, 0) > 0) + grads[i][0] += (coefficients)(i, j) * pow(u, (monomials)(j, 0) - 1) * + (monomials)(j, 0) * pow(v, (monomials)(j, 1)) * + pow(w, (monomials)(j, 2)); + if ((monomials)(j, 1) > 0) + grads[i][1] += (coefficients)(i, j) * pow(u,(monomials)(j, 0)) * + pow(v, (monomials)(j, 1) - 1) * (monomials)(j, 1) * + pow(w, (monomials)(j, 2)); + if ((monomials)(j, 2) > 0) + grads[i][2] += (coefficients)(i, j) * pow(u, (monomials)(j, 0)) * + pow(v, (monomials)(j, 1)) * pow(w, (monomials)(j, 2) - 1) * + (monomials)(j, 2); } } } @@ -87,12 +87,12 @@ struct gmshFunctionSpace grads[i][0] = 0; grads[i][1] = 0; for(int j = 0; j < coefficients.size2(); j++){ - if ((monomials)(j, 0) > 0) - grads[i][0] += (coefficients)(i, j) * - pow(u, (monomials)(j, 0) - 1) * (monomials)(j, 0) * p[j][1]; - if ((monomials)(j, 1) > 0) - grads[i][1] += (coefficients)(i, j) * p[j][0] * - pow(v, (monomials)(j, 1) - 1) * (monomials)(j, 1); + if ((monomials)(j, 0) > 0) + grads[i][0] += (coefficients)(i, j) * + pow(u, (monomials)(j, 0) - 1) * (monomials)(j, 0) * p[j][1]; + if ((monomials)(j, 1) > 0) + grads[i][1] += (coefficients)(i, j) * p[j][0] * + pow(v, (monomials)(j, 1) - 1) * (monomials)(j, 1); } } } diff --git a/Numeric/Numeric.h b/Numeric/Numeric.h index f8f3e16ec194f68582fad24b7327f412078a34ca..a6a91686cab76a3b8eb367a4a49f41c6c6fa9a9f 100644 --- a/Numeric/Numeric.h +++ b/Numeric/Numeric.h @@ -28,25 +28,25 @@ void invert_singular_matrix3x3(double MM[3][3], double II[3][3]); // Numerical routines implemented using either Numerical Recipes or // the GSL double brent(double ax, double bx, double cx, - double (*f)(double), double tol, double *xmin); + double (*f)(double), double tol, double *xmin); void mnbrak(double *ax, double *bx, double *cx, double *fa, double *fb, - double *fc, double (*func)(double)); + double *fc, double (*func)(double)); void newt(double x[], int n, int *check, - void (*vecfunc)(int, double [], double [])); + void (*vecfunc)(int, double [], double [])); void minimize_2 (double (*f) (double, double, void *data), - void (*df) (double, double, double &, double &, double &, void *data) , - void *data,int niter, - double &U, double &V, double &res); + void (*df) (double, double, double &, double &, double &, void *data) , + void *data,int niter, + double &U, double &V, double &res); void minimize_3 (double (*f) (double, double, double, void *data), - void (*df) (double, double, double , double &, double &, - double &, double &, void *data), - void *data,int niter, - double &U, double &V, double &W, double &res); + void (*df) (double, double, double , double &, double &, + double &, double &, void *data), + void *data,int niter, + double &U, double &V, double &W, double &res); void minimize_N (int N, - double (*f) (double*, void *data), - void (*df) (double*, double*, double &, void *data) , - void *data,int niter, - double *, double &res); + double (*f) (double*, void *data), + void (*df) (double*, double*, double &, void *data) , + void *data,int niter, + double *, double &res); // Robust geometrical predicates namespace gmsh{ diff --git a/Numeric/NumericEmbedded.cpp b/Numeric/NumericEmbedded.cpp index 4c480709bda667cd99f8ccc2a78baece6cc81598..aa32eed9fdbc690b0cf57732bf67dbc73b12b21f 100644 --- a/Numeric/NumericEmbedded.cpp +++ b/Numeric/NumericEmbedded.cpp @@ -1,4 +1,4 @@ -// $Id: NumericEmbedded.cpp,v 1.3 2008-02-17 08:48:02 geuzaine Exp $ +// $Id: NumericEmbedded.cpp,v 1.4 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -66,9 +66,9 @@ void matvec(double mat[3][3], double vec[3], double res[3]) } void normal3points(double x0, double y0, double z0, - double x1, double y1, double z1, - double x2, double y2, double z2, - double n[3]) + double x1, double y1, double z1, + double x2, double y2, double z2, + double n[3]) { double t1[3] = {x1 - x0, y1 - y0, z1 - z0}; double t2[3] = {x2 - x0, y2 - y0, z2 - z0}; @@ -106,8 +106,8 @@ int sys2x2(double mat[2][2], double b[2], double res[2]) double det3x3(double mat[3][3]) { return (mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) - - mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) + - mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0])); + mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) + + mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0])); } double trace3x3(double mat[3][3]) @@ -207,7 +207,7 @@ double inv2x2(double mat[2][2], double inv[2][2]) Msg(GERROR, "Singular matrix"); for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) - inv[i][j] = 0.; + inv[i][j] = 0.; } return det; } @@ -231,7 +231,7 @@ double inv3x3(double mat[3][3], double inv[3][3]) Msg(GERROR, "Singular matrix"); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) - inv[i][j] = 0.; + inv[i][j] = 0.; } return det; } diff --git a/Numeric/NumericEmbedded.h b/Numeric/NumericEmbedded.h index 8110cffe9351eede817095e3853ec9c2cde7cad3..219aa263031a94cd041a8ec78567ee12afe1f470 100644 --- a/Numeric/NumericEmbedded.h +++ b/Numeric/NumericEmbedded.h @@ -79,9 +79,9 @@ inline double norme(double a[3]) return mod; } void normal3points(double x0, double y0, double z0, - double x1, double y1, double z1, - double x2, double y2, double z2, - double n[3]); + double x1, double y1, double z1, + double x2, double y2, double z2, + double n[3]); int sys2x2(double mat[2][2], double b[2], double res[2]); int sys3x3(double mat[3][3], double b[3], double res[3], double *det); int sys3x3_with_tol(double mat[3][3], double b[3], double res[3], double *det); @@ -101,8 +101,8 @@ void eigenvalue(double mat[3][3], double re[3]); void FindCubicRoots(const double coeff[4], double re[3], double im[3]); void eigsort(double d[3]); double InterpolateIso(double *X, double *Y, double *Z, - double *Val, double V, int I1, int I2, - double *XI, double *YI ,double *ZI); + double *Val, double V, int I1, int I2, + double *XI, double *YI ,double *ZI); void gradSimplex(double *x, double *y, double *z, double *v, double *grad); double ComputeVonMises(double *val); double ComputeScalarRep(int numComp, double *val); diff --git a/Numeric/gsl_brent.cpp b/Numeric/gsl_brent.cpp index eb06d3bcc9961c566c45d513db68d3d5290b8783..fccb5d066666425adc5903674f6c29163129234e 100644 --- a/Numeric/gsl_brent.cpp +++ b/Numeric/gsl_brent.cpp @@ -1,4 +1,4 @@ -// $Id: gsl_brent.cpp,v 1.18 2008-02-17 08:48:02 geuzaine Exp $ +// $Id: gsl_brent.cpp,v 1.19 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -112,8 +112,8 @@ double brent(double ax, double bx, double cx, #define SIGN(a,b)((b) >= 0.0 ? fabs(a) : -fabs(a)) void mnbrak(double *ax, double *bx, double *cx, - double *fa_dummy, double *fb_dummy, double *fc_dummy, - double (*func) (double)) + double *fa_dummy, double *fb_dummy, double *fc_dummy, + double (*func) (double)) { double ulim, u, r, q; volatile double f_a, f_b, f_c, f_u; diff --git a/Numeric/gsl_min.cpp b/Numeric/gsl_min.cpp index ce7a6a5d038e8476dc5b1b7ccc037f2e73b6a101..80b6cc703c9d5a0092e5472ec21ee1ce92cb2617 100644 --- a/Numeric/gsl_min.cpp +++ b/Numeric/gsl_min.cpp @@ -1,4 +1,4 @@ -// $Id: gsl_min.cpp,v 1.5 2008-02-21 13:44:56 geuzaine Exp $ +// $Id: gsl_min.cpp,v 1.6 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -105,9 +105,9 @@ void fdfobjN (const gsl_vector * x, void * params, double * f, gsl_vector * g){ } void minimize_2 ( double (*f) (double, double, void *data), - void (*df) (double, double, double &, double &, double &, void *data) , - void *data,int niter, - double &U, double &V, double &res){ + void (*df) (double, double, double &, double &, double &, void *data) , + void *data,int niter, + double &U, double &V, double &res){ f_stat = f; df_stat = df; @@ -148,14 +148,14 @@ void minimize_2 ( double (*f) (double, double, void *data), res = s->f; gsl_multimin_fdfminimizer_free (s); gsl_vector_free (x); -} +} void minimize_3(double (*f) (double, double, double,void *data), - void (*df) (double , double , double , - double &, double &, double &, double &, - void *data) , - void *data,int niter, - double &U, double &V, double &W, double &res) + void (*df) (double , double , double , + double &, double &, double &, double &, + void *data) , + void *data,int niter, + double &U, double &V, double &W, double &res) { f_stat3 = f; df_stat3 = df; @@ -199,13 +199,13 @@ void minimize_3(double (*f) (double, double, double,void *data), res = s->f; gsl_multimin_fdfminimizer_free (s); gsl_vector_free (x); -} +} void minimize_N(int N, - double (*f) (double*,void *data), - void (*df) (double*,double*,double &,void *data) , - void *data,int niter, - double *U, double &res){ + double (*f) (double*,void *data), + void (*df) (double*,double*,double &,void *data) , + void *data,int niter, + double *U, double &res){ f_statN = f; df_statN = df; @@ -249,31 +249,31 @@ void minimize_N(int N, gsl_multimin_fdfminimizer_free (s); gsl_vector_free (x); -} +} #else void minimize_2 ( double (*f) (double, double, void *data), - void (*df) (double, double, double &, double &, double &, void *data) , - void *data,int niter, - double &U, double &V, double &res) + void (*df) (double, double, double &, double &, double &, void *data) , + void *data,int niter, + double &U, double &V, double &res) { Msg(GERROR, "Gmsh must be compiled with GSL support for minimize_2"); } void minimize_3 ( double (*f) (double, double, double, void *data), - void (*df) (double, double, double , double &, double &, double &, double &, void *data) , - void *data,int niter, - double &U, double &V, double &W, double &res) + void (*df) (double, double, double , double &, double &, double &, double &, void *data) , + void *data,int niter, + double &U, double &V, double &W, double &res) { Msg(GERROR, "Gmsh must be compiled with GSL support for minimize_3"); } void minimize_N (int N, - double (*f) (double*, void *data), - void (*df) (double*, double*, double &, void *data) , - void *data,int niter, - double *, double &res) + double (*f) (double*, void *data), + void (*df) (double*, double*, double &, void *data) , + void *data,int niter, + double *, double &res) { Msg(GERROR, "Gmsh must be compiled with GSL support for minimize_N"); } diff --git a/Parser/CreateFile.cpp b/Parser/CreateFile.cpp index 41ea6225c54afb7d9ad463f11969836d44b4ec8d..d53ff7cbfabcceed232fe49d07a012c05abd50b8 100644 --- a/Parser/CreateFile.cpp +++ b/Parser/CreateFile.cpp @@ -1,4 +1,4 @@ -// $Id: CreateFile.cpp,v 1.25 2008-02-22 07:49:39 geuzaine Exp $ +// $Id: CreateFile.cpp,v 1.26 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -151,12 +151,12 @@ void CreateOutputFile(const char *filename, int format) case FORMAT_MSH: GModel::current()->writeMSH(name, CTX.mesh.msh_file_version, CTX.mesh.msh_binary, - CTX.mesh.save_all, CTX.mesh.scaling_factor); + CTX.mesh.save_all, CTX.mesh.scaling_factor); break; case FORMAT_STL: GModel::current()->writeSTL(name, CTX.mesh.stl_binary, - CTX.mesh.save_all, CTX.mesh.scaling_factor); + CTX.mesh.save_all, CTX.mesh.scaling_factor); break; case FORMAT_VRML: @@ -165,7 +165,7 @@ void CreateOutputFile(const char *filename, int format) case FORMAT_UNV: GModel::current()->writeUNV(name, CTX.mesh.save_all, CTX.mesh.save_groups_of_nodes, - CTX.mesh.scaling_factor); + CTX.mesh.scaling_factor); break; case FORMAT_MESH: @@ -174,7 +174,7 @@ void CreateOutputFile(const char *filename, int format) case FORMAT_BDF: GModel::current()->writeBDF(name, CTX.mesh.bdf_field_format, - CTX.mesh.save_all, CTX.mesh.scaling_factor); + CTX.mesh.save_all, CTX.mesh.scaling_factor); break; case FORMAT_P3D: @@ -191,8 +191,8 @@ void CreateOutputFile(const char *filename, int format) case FORMAT_POS: GModel::current()->writePOS(name, CTX.print.pos_elementary, CTX.print.pos_element, - CTX.print.pos_gamma, CTX.print.pos_eta, CTX.print.pos_rho, - CTX.mesh.save_all, CTX.mesh.scaling_factor); + CTX.print.pos_gamma, CTX.print.pos_eta, CTX.print.pos_rho, + CTX.mesh.save_all, CTX.mesh.scaling_factor); break; case FORMAT_GEO: @@ -208,39 +208,39 @@ void CreateOutputFile(const char *filename, int format) { FILE *fp; if(!(fp = fopen(name, "wb"))) { - Msg(GERROR, "Unable to open file '%s'", name); - break; + Msg(GERROR, "Unable to open file '%s'", name); + break; } PixelBuffer buffer(width, height, GL_RGB, GL_UNSIGNED_BYTE); int old_bg_gradient = CTX.bg_gradient; if(format == FORMAT_GIF && CTX.print.gif_transparent) - CTX.bg_gradient = 0; + CTX.bg_gradient = 0; buffer.Fill(CTX.batch); CTX.bg_gradient = old_bg_gradient; if(format == FORMAT_PPM){ - create_ppm(fp, &buffer); + create_ppm(fp, &buffer); } else if(format == FORMAT_YUV){ - create_yuv(fp, &buffer); + create_yuv(fp, &buffer); } else if(format == FORMAT_GIF){ - create_gif(fp, &buffer, - CTX.print.gif_dither, - CTX.print.gif_sort, - CTX.print.gif_interlace, - CTX.print.gif_transparent, - CTX.UNPACK_RED(CTX.color.bg), - CTX.UNPACK_GREEN(CTX.color.bg), - CTX.UNPACK_BLUE(CTX.color.bg)); + create_gif(fp, &buffer, + CTX.print.gif_dither, + CTX.print.gif_sort, + CTX.print.gif_interlace, + CTX.print.gif_transparent, + CTX.UNPACK_RED(CTX.color.bg), + CTX.UNPACK_GREEN(CTX.color.bg), + CTX.UNPACK_BLUE(CTX.color.bg)); } else if(format == FORMAT_JPEG){ - create_jpeg(fp, &buffer, CTX.print.jpeg_quality, CTX.print.jpeg_smoothing); + create_jpeg(fp, &buffer, CTX.print.jpeg_quality, CTX.print.jpeg_smoothing); } else{ - create_png(fp, &buffer, 100); + create_png(fp, &buffer, 100); } fclose(fp); } @@ -253,24 +253,24 @@ void CreateOutputFile(const char *filename, int format) { FILE *fp; if(!(fp = fopen(name, "wb"))) { - Msg(GERROR, "Unable to open file '%s'", name); - break; + Msg(GERROR, "Unable to open file '%s'", name); + break; } int psformat; switch(format){ case FORMAT_PDF: - psformat = GL2PS_PDF; - break; + psformat = GL2PS_PDF; + break; case FORMAT_PS: - psformat = GL2PS_PS; - break; + psformat = GL2PS_PS; + break; case FORMAT_SVG: - psformat = GL2PS_SVG; - break; + psformat = GL2PS_SVG; + break; default: - psformat = GL2PS_EPS; - break; + psformat = GL2PS_EPS; + break; } int old_bg_gradient = CTX.bg_gradient; @@ -279,48 +279,48 @@ void CreateOutputFile(const char *filename, int format) PixelBuffer buffer(width, height, GL_RGB, GL_FLOAT); if(CTX.print.eps_quality == 0) - buffer.Fill(CTX.batch); + buffer.Fill(CTX.batch); int pssort = - (CTX.print.eps_quality == 3) ? GL2PS_NO_SORT : - (CTX.print.eps_quality == 2) ? GL2PS_BSP_SORT : - GL2PS_SIMPLE_SORT; + (CTX.print.eps_quality == 3) ? GL2PS_NO_SORT : + (CTX.print.eps_quality == 2) ? GL2PS_BSP_SORT : + GL2PS_SIMPLE_SORT; int psoptions = - GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT | - (CTX.print.eps_occlusion_culling ? GL2PS_OCCLUSION_CULL : 0) | - (CTX.print.eps_best_root ? GL2PS_BEST_ROOT : 0) | - (CTX.print.eps_background ? GL2PS_DRAW_BACKGROUND : 0) | - (CTX.print.eps_compress ? GL2PS_COMPRESS : 0) | - (CTX.print.eps_ps3shading ? 0 : GL2PS_NO_PS3_SHADING); + GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT | + (CTX.print.eps_occlusion_culling ? GL2PS_OCCLUSION_CULL : 0) | + (CTX.print.eps_best_root ? GL2PS_BEST_ROOT : 0) | + (CTX.print.eps_background ? GL2PS_DRAW_BACKGROUND : 0) | + (CTX.print.eps_compress ? GL2PS_COMPRESS : 0) | + (CTX.print.eps_ps3shading ? 0 : GL2PS_NO_PS3_SHADING); GLint buffsize = 0; int res = GL2PS_OVERFLOW; while(res == GL2PS_OVERFLOW) { - buffsize += 2048 * 2048; - gl2psBeginPage(CTX.base_filename, "Gmsh", viewport, - psformat, pssort, psoptions, GL_RGBA, 0, NULL, - 15, 20, 10, buffsize, fp, base); - if(CTX.print.eps_quality == 0){ - double modelview[16], projection[16]; - glGetDoublev(GL_PROJECTION_MATRIX, projection); - glGetDoublev(GL_MODELVIEW_MATRIX, modelview); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho((double)CTX.viewport[0], (double)CTX.viewport[2], - (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glRasterPos2d(0, 0); - gl2psDrawPixels(width, height, 0, 0, GL_RGB, GL_FLOAT, buffer.GetPixels()); - glMatrixMode(GL_PROJECTION); - glLoadMatrixd(projection); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixd(modelview); - } - else{ - buffer.Fill(CTX.batch); - } - res = gl2psEndPage(); + buffsize += 2048 * 2048; + gl2psBeginPage(CTX.base_filename, "Gmsh", viewport, + psformat, pssort, psoptions, GL_RGBA, 0, NULL, + 15, 20, 10, buffsize, fp, base); + if(CTX.print.eps_quality == 0){ + double modelview[16], projection[16]; + glGetDoublev(GL_PROJECTION_MATRIX, projection); + glGetDoublev(GL_MODELVIEW_MATRIX, modelview); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho((double)CTX.viewport[0], (double)CTX.viewport[2], + (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glRasterPos2d(0, 0); + gl2psDrawPixels(width, height, 0, 0, GL_RGB, GL_FLOAT, buffer.GetPixels()); + glMatrixMode(GL_PROJECTION); + glLoadMatrixd(projection); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixd(modelview); + } + else{ + buffer.Fill(CTX.batch); + } + res = gl2psEndPage(); } CTX.bg_gradient = old_bg_gradient; @@ -332,22 +332,22 @@ void CreateOutputFile(const char *filename, int format) { FILE *fp; if(!(fp = fopen(name, "w"))) { - Msg(GERROR, "Unable to open file '%s'", name); - break; + Msg(GERROR, "Unable to open file '%s'", name); + break; } GLint buffsize = 0; int res = GL2PS_OVERFLOW; while(res == GL2PS_OVERFLOW) { - buffsize += 2048 * 2048; - gl2psBeginPage(CTX.base_filename, "Gmsh", viewport, - GL2PS_TEX, GL2PS_NO_SORT, GL2PS_NONE, GL_RGBA, 0, NULL, - 0, 0, 0, buffsize, fp, base); - PixelBuffer buffer(width, height, GL_RGB, GL_UNSIGNED_BYTE); - int oldtext = CTX.print.text; - CTX.print.text = 1; - buffer.Fill(CTX.batch); - CTX.print.text = oldtext; - res = gl2psEndPage(); + buffsize += 2048 * 2048; + gl2psBeginPage(CTX.base_filename, "Gmsh", viewport, + GL2PS_TEX, GL2PS_NO_SORT, GL2PS_NONE, GL_RGBA, 0, NULL, + 0, 0, 0, buffsize, fp, base); + PixelBuffer buffer(width, height, GL_RGB, GL_UNSIGNED_BYTE); + int oldtext = CTX.print.text; + CTX.print.text = 1; + buffer.Fill(CTX.batch); + CTX.print.text = oldtext; + res = gl2psEndPage(); } fclose(fp); } diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index af6df7ce46cd6145bb59de07d6a931d972b0cc0c..c250e5afa491493b062e7ec8cb95240f8e77f026 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -324,7 +324,7 @@ /* Copy the first part of user declarations. */ #line 1 "Gmsh.y" -// $Id: Gmsh.tab.cpp,v 1.352 2008-03-19 17:26:49 geuzaine Exp $ +// $Id: Gmsh.tab.cpp,v 1.353 2008-03-20 11:44:09 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp index ddd5f2343da1a83bd71e1617f47f2750d9a1602f..9183b16d121ed02fcd9f0ee07ee1980c73a80627 100644 --- a/Parser/Gmsh.yy.cpp +++ b/Parser/Gmsh.yy.cpp @@ -835,7 +835,7 @@ int gmsh_yy_flex_debug = 0; char *gmsh_yytext; #line 1 "Gmsh.l" #line 2 "Gmsh.l" -// $Id: Gmsh.yy.cpp,v 1.352 2008-03-19 17:26:53 geuzaine Exp $ +// $Id: Gmsh.yy.cpp,v 1.353 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 68e8782921598efd4a8df7d8d7dad13d62731d71..6daebad69e9a37c64a104b5fcc6afd1cfd06a0ba 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.178 2008-03-10 16:01:16 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.179 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -109,18 +109,18 @@ static void FinishUpBoundingBox() CTX.lc = 1.; } else if(range[0] < CTX.geom.tolerance && - range[1] < CTX.geom.tolerance) { + range[1] < CTX.geom.tolerance) { CTX.lc = range[2]; CTX.min[0] -= CTX.lc; CTX.min[1] -= CTX.lc; CTX.max[0] += CTX.lc; CTX.max[1] += CTX.lc; } else if(range[0] < CTX.geom.tolerance && - range[2] < CTX.geom.tolerance) { + range[2] < CTX.geom.tolerance) { CTX.lc = range[1]; CTX.min[0] -= CTX.lc; CTX.max[0] += CTX.lc; } else if(range[1] < CTX.geom.tolerance && - range[2] < CTX.geom.tolerance) { + range[2] < CTX.geom.tolerance) { CTX.lc = range[0]; CTX.min[1] -= CTX.lc; CTX.max[1] += CTX.lc; } @@ -141,8 +141,8 @@ static void FinishUpBoundingBox() } void SetBoundingBox(double xmin, double xmax, - double ymin, double ymax, - double zmin, double zmax) + double ymin, double ymax, + double zmin, double zmax) { CTX.min[0] = xmin; CTX.max[0] = xmax; CTX.min[1] = ymin; CTX.max[1] = ymax; @@ -159,7 +159,7 @@ void SetBoundingBox(void) if(bb.empty()) { for(unsigned int i = 0; i < PView::list.size(); i++) if(!PView::list[i]->getData()->getBoundingBox().empty()) - bb += PView::list[i]->getData()->getBoundingBox(); + bb += PView::list[i]->getData()->getBoundingBox(); } if(bb.empty()){ @@ -304,14 +304,14 @@ int MergeFile(const char *name, int warn_if_missing) // the real solution would be to rewrite all our I/O functions in // terms of gzFile, but until then, this is better than nothing if(fl_choice("File '%s' is in gzip format.\n\nDo you want to uncompress it?", - "Cancel", "Uncompress", NULL, name)){ - char tmp[256]; - sprintf(tmp, "gunzip -c %s > %s", name, no_ext); - if(SystemCall(tmp)) - Msg(GERROR, "Failed to uncompress `%s': check directory permissions", name); - if(!strcmp(CTX.filename, name)) // this is the project file - SetProjectName(no_ext); - return MergeFile(no_ext); + "Cancel", "Uncompress", NULL, name)){ + char tmp[256]; + sprintf(tmp, "gunzip -c %s > %s", name, no_ext); + if(SystemCall(tmp)) + Msg(GERROR, "Failed to uncompress `%s': check directory permissions", name); + if(!strcmp(CTX.filename, name)) // this is the project file + SetProjectName(no_ext); + return MergeFile(no_ext); } } } @@ -328,30 +328,30 @@ int MergeFile(const char *name, int warn_if_missing) status = m->readSTL(name, CTX.geom.tolerance); } else if(!strcmp(ext, ".brep") || !strcmp(ext, ".rle") || - !strcmp(ext, ".brp") || !strcmp(ext, ".BRP")){ + !strcmp(ext, ".brp") || !strcmp(ext, ".BRP")){ status = m->readOCCBREP(std::string(name)); } else if(!strcmp(ext, ".iges") || !strcmp(ext, ".IGES") || - !strcmp(ext, ".igs") || !strcmp(ext, ".IGS")){ + !strcmp(ext, ".igs") || !strcmp(ext, ".IGS")){ status = m->readOCCIGES(std::string(name)); } else if(!strcmp(ext, ".step") || !strcmp(ext, ".STEP") || - !strcmp(ext, ".stp") || !strcmp(ext, ".STP")){ + !strcmp(ext, ".stp") || !strcmp(ext, ".STP")){ status = m->readOCCSTEP(std::string(name)); } else if(!strcmp(ext, ".unv") || !strcmp(ext, ".UNV")){ status = m->readUNV(name); } else if(!strcmp(ext, ".wrl") || !strcmp(ext, ".WRL") || - !strcmp(ext, ".vrml") || !strcmp(ext, ".VRML") || - !strcmp(ext, ".iv") || !strcmp(ext, ".IV")){ + !strcmp(ext, ".vrml") || !strcmp(ext, ".VRML") || + !strcmp(ext, ".iv") || !strcmp(ext, ".IV")){ status = m->readVRML(name); } else if(!strcmp(ext, ".mesh") || !strcmp(ext, ".MESH")){ status = m->readMESH(name); } else if(!strcmp(ext, ".bdf") || !strcmp(ext, ".BDF") || - !strcmp(ext, ".nas") || !strcmp(ext, ".NAS")){ + !strcmp(ext, ".nas") || !strcmp(ext, ".NAS")){ status = m->readBDF(name); } else if(!strcmp(ext, ".p3d") || !strcmp(ext, ".P3D")){ @@ -362,9 +362,9 @@ int MergeFile(const char *name, int warn_if_missing) } #if defined(HAVE_FLTK) else if(!strcmp(ext, ".pnm") || !strcmp(ext, ".PNM") || - !strcmp(ext, ".pbm") || !strcmp(ext, ".PBM") || - !strcmp(ext, ".pgm") || !strcmp(ext, ".PGM") || - !strcmp(ext, ".ppm") || !strcmp(ext, ".PPM")) { + !strcmp(ext, ".pbm") || !strcmp(ext, ".PBM") || + !strcmp(ext, ".pgm") || !strcmp(ext, ".PGM") || + !strcmp(ext, ".ppm") || !strcmp(ext, ".PPM")) { status = read_pnm(name); } else if(!strcmp(ext, ".bmp") || !strcmp(ext, ".BMP")) { @@ -372,7 +372,7 @@ int MergeFile(const char *name, int warn_if_missing) } #if defined(HAVE_LIBJPEG) else if(!strcmp(ext, ".jpg") || !strcmp(ext, ".JPG") || - !strcmp(ext, ".jpeg") || !strcmp(ext, ".JPEG")) { + !strcmp(ext, ".jpeg") || !strcmp(ext, ".JPEG")) { status = read_jpeg(name); } #endif @@ -389,10 +389,10 @@ int MergeFile(const char *name, int warn_if_missing) !strncmp(header, "$MeshFormat", 11)) { status = m->readMSH(name); if(status > 1) - status = PView::readMSH(name); + status = PView::readMSH(name); } else if(!strncmp(header, "$PostFormat", 11) || - !strncmp(header, "$View", 5)) { + !strncmp(header, "$View", 5)) { status = PView::readPOS(name); } else { diff --git a/Parser/OpenFile.h b/Parser/OpenFile.h index 9a5cc8923edf44fe85192850e1e77f673cbc2614..05d32a87e34f226e8cd592c3fd464e3f7b74a559 100644 --- a/Parser/OpenFile.h +++ b/Parser/OpenFile.h @@ -29,8 +29,8 @@ void FixRelativePath(const char *in, char *out); void FixWindowsPath(const char *in, char *out); void SplitFileName(const char *name, char *no_ext, char *ext, char *base); void SetBoundingBox(double xmin, double xmax, - double ymin, double ymax, - double zmin, double zmax); + double ymin, double ymax, + double zmin, double zmax); void SetBoundingBox(void); void AddToTemporaryBoundingBox(double x, double y, double z); diff --git a/Plugin/Annotate.cpp b/Plugin/Annotate.cpp index fcc06cf75eaaf7b1223076dce76b7170e640f3c0..1b694d8c96a02ce910de25622af9c6489d188090 100644 --- a/Plugin/Annotate.cpp +++ b/Plugin/Annotate.cpp @@ -1,4 +1,4 @@ -// $Id: Annotate.cpp,v 1.20 2008-02-23 15:30:10 geuzaine Exp $ +// $Id: Annotate.cpp,v 1.21 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -97,7 +97,7 @@ void GMSH_AnnotatePlugin::draw() glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho((double)CTX.viewport[0], (double)CTX.viewport[2], - (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); + (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Fix2DCoordinates(&X, &Y); @@ -118,7 +118,7 @@ void GMSH_AnnotatePlugin::draw() } double GMSH_AnnotatePlugin::callback(int num, int action, double value, double *opt, - double step, double min, double max) + double step, double min, double max) { switch(action){ // configure the input field case 1: return step; @@ -134,7 +134,7 @@ double GMSH_AnnotatePlugin::callback(int num, int action, double value, double * } const char *GMSH_AnnotatePlugin::callbackStr(int num, int action, const char *value, - const char **opt) + const char **opt) { *opt = value; #if defined(HAVE_FLTK) @@ -148,9 +148,9 @@ double GMSH_AnnotatePlugin::callbackX(int num, int action, double value) // not perfect: the change will only take place if we reopen the dialog... int dim3 = (int)AnnotateOptions_Number[3].def; return callback(num, action, value, &AnnotateOptions_Number[0].def, - dim3 ? CTX.lc/200. : 0.5, - dim3 ? -CTX.lc : -100., - dim3 ? CTX.lc : 100000.); + dim3 ? CTX.lc/200. : 0.5, + dim3 ? -CTX.lc : -100., + dim3 ? CTX.lc : 100000.); } double GMSH_AnnotatePlugin::callbackY(int num, int action, double value) @@ -158,9 +158,9 @@ double GMSH_AnnotatePlugin::callbackY(int num, int action, double value) // not perfect: the change will only take place if we reopen the dialog... int dim3 = (int)AnnotateOptions_Number[3].def; return callback(num, action, value, &AnnotateOptions_Number[1].def, - dim3 ? CTX.lc/200. : 0.5, - dim3 ? -CTX.lc : -100., - dim3 ? CTX.lc : 100000.); + dim3 ? CTX.lc/200. : 0.5, + dim3 ? -CTX.lc : -100., + dim3 ? CTX.lc : 100000.); } double GMSH_AnnotatePlugin::callbackZ(int num, int action, double value) @@ -168,21 +168,21 @@ double GMSH_AnnotatePlugin::callbackZ(int num, int action, double value) // not perfect: the change will only take place if we reopen the dialog... int dim3 = (int)AnnotateOptions_Number[3].def; return callback(num, action, value, &AnnotateOptions_Number[2].def, - dim3 ? CTX.lc/200. : 0.5, - dim3 ? -CTX.lc : -100., - dim3 ? CTX.lc : 100000.); + dim3 ? CTX.lc/200. : 0.5, + dim3 ? -CTX.lc : -100., + dim3 ? CTX.lc : 100000.); } double GMSH_AnnotatePlugin::callback3D(int num, int action, double value) { return callback(num, action, value, &AnnotateOptions_Number[3].def, - 1, 0, 1); + 1, 0, 1); } double GMSH_AnnotatePlugin::callbackFontSize(int num, int action, double value) { return callback(num, action, value, &AnnotateOptions_Number[4].def, - 1, 5, 100); + 1, 5, 100); } const char *GMSH_AnnotatePlugin::callbackText(int num, int action, const char *value) @@ -206,22 +206,22 @@ void GMSH_AnnotatePlugin::getName(char *name) const } void GMSH_AnnotatePlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Annotate) adds the text string `Text',\n" - "in font `Font' and size `FontSize', in the view\n" - "`iView'. If `ThreeD' is equal to 1, the plugin inserts\n" - "the string in model coordinates at the position\n" - "(`X',`Y',`Z'). If `ThreeD' is equal to 0, the plugin\n" - "inserts the string in screen coordinates at\n" - "the position (`X',`Y'). The string is aligned\n" - "according to `Align'. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(Annotate) is executed in-place.\n"); + "in font `Font' and size `FontSize', in the view\n" + "`iView'. If `ThreeD' is equal to 1, the plugin inserts\n" + "the string in model coordinates at the position\n" + "(`X',`Y',`Z'). If `ThreeD' is equal to 0, the plugin\n" + "inserts the string in screen coordinates at\n" + "the position (`X',`Y'). The string is aligned\n" + "according to `Align'. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(Annotate) is executed in-place.\n"); } int GMSH_AnnotatePlugin::getNbOptions() const diff --git a/Plugin/Annotate.h b/Plugin/Annotate.h index c59c27142b5610ff0514641b4014341edf18af00..604f8f9099187313655519f81a40353a0f364a68 100644 --- a/Plugin/Annotate.h +++ b/Plugin/Annotate.h @@ -31,7 +31,7 @@ class GMSH_AnnotatePlugin : public GMSH_Post_Plugin { private: static double callback(int num, int action, double value, double *opt, - double step, double min, double max); + double step, double min, double max); static const char *callbackStr(int num, int action, const char *value, const char **opt); public: GMSH_AnnotatePlugin(); diff --git a/Plugin/Curl.cpp b/Plugin/Curl.cpp index 07d9689e1caebb3f34aa73071010ec3285ec99cc..860f3dc4166cab254788f984227c98fca49f740b 100644 --- a/Plugin/Curl.cpp +++ b/Plugin/Curl.cpp @@ -1,4 +1,4 @@ -// $Id: Curl.cpp,v 1.6 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: Curl.cpp,v 1.7 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,16 +45,16 @@ void GMSH_CurlPlugin::getName(char *name) const } void GMSH_CurlPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, - "Plugin(Curl) computes the curl of the field\n" - "in the view `iView'. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(Curl) creates one new view.\n"); + "Plugin(Curl) computes the curl of the field\n" + "in the view `iView'. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(Curl) creates one new view.\n"); } int GMSH_CurlPlugin::getNbOptions() const @@ -73,7 +73,7 @@ void GMSH_CurlPlugin::catchErrorMessage(char *errorMessage) const } static void curl(int inNb, List_T *inList, int *outNb, List_T *outList, - int dim, int nbNod, int nbTime) + int dim, int nbNod, int nbTime) { if(!inNb) return; @@ -90,12 +90,12 @@ static void curl(int inNb, List_T *inList, int *outNb, List_T *outList, for(int j = 0; j < nbTime; j++){ double *val = (double *)List_Pointer(inList, i + 3 * nbNod + nbNod * 3 * j); for(int k = 0; k < nbNod; k++){ - double u, v, w, f[3]; - element->getNode(k, u, v, w); - element->interpolateCurl(val, u, v, w, f, 3); - List_Add(outList, &f[0]); - List_Add(outList, &f[1]); - List_Add(outList, &f[2]); + double u, v, w, f[3]; + element->getNode(k, u, v, w); + element->interpolateCurl(val, u, v, w, f, 3); + List_Add(outList, &f[0]); + List_Add(outList, &f[1]); + List_Add(outList, &f[2]); } } delete element; diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp index f45a6e934a6916db76eb30cbf420a0bb53914cb0..2768f6a1abf3f0406bb0ba6282c98bad78b434e2 100644 --- a/Plugin/CutGrid.cpp +++ b/Plugin/CutGrid.cpp @@ -1,4 +1,4 @@ -// $Id: CutGrid.cpp,v 1.25 2008-03-20 10:52:36 geuzaine Exp $ +// $Id: CutGrid.cpp,v 1.26 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -84,8 +84,8 @@ void GMSH_CutGridPlugin::draw() else{ for(int i = 0; i < getNbU(); ++i){ for(int j = 0; j < getNbV(); ++j){ - getPoint(i, j, p); - Draw_Sphere(CTX.point_size, p[0], p[1], p[2], 1); + getPoint(i, j, p); + Draw_Sphere(CTX.point_size, p[0], p[1], p[2], 1); } } } @@ -93,7 +93,7 @@ void GMSH_CutGridPlugin::draw() } double GMSH_CutGridPlugin::callback(int num, int action, double value, double *opt, - double step, double min, double max) + double step, double min, double max) { switch(action){ // configure the input field case 1: return step; @@ -111,73 +111,73 @@ double GMSH_CutGridPlugin::callback(int num, int action, double value, double *o double GMSH_CutGridPlugin::callbackX0(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[0].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackY0(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[1].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackZ0(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[2].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackX1(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[3].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackY1(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[4].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackZ1(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[5].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackX2(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[6].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackY2(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[7].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackZ2(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[8].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutGridPlugin::callbackU(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[9].def, - 1, 1, 100); + 1, 1, 100); } double GMSH_CutGridPlugin::callbackV(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[10].def, - 1, 1, 100); + 1, 1, 100); } double GMSH_CutGridPlugin::callbackConnect(int num, int action, double value) { return callback(num, action, value, &CutGridOptions_Number[11].def, - 1, 0, 1); + 1, 0, 1); } void GMSH_CutGridPlugin::getName(char *name) const @@ -192,18 +192,18 @@ void GMSH_CutGridPlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(CutGrid) cuts the view `iView' with a\n" - "rectangular grid defined by the 3 points\n" - "(`X0',`Y0',`Z0') (origin), (`X1',`Y1',`Z1') (axis of\n" - "U) and (`X2',`Y2',`Z2') (axis of V). The number of\n" - "points along U and V is set with the options\n" - "`nPointsU' and `nPointsV'. If `ConnectPoints' is\n" - "zero, the plugin creates points; otherwise, the\n" - "plugin generates quadrangles, lines or points\n" - " depending on the values of `nPointsU' and\n" - "`nPointsV'. If `iView' < 0, the plugin is run on\n" - "the current view.\n" - "\n" - "Plugin(CutGrid) creates one new view.\n"); + "rectangular grid defined by the 3 points\n" + "(`X0',`Y0',`Z0') (origin), (`X1',`Y1',`Z1') (axis of\n" + "U) and (`X2',`Y2',`Z2') (axis of V). The number of\n" + "points along U and V is set with the options\n" + "`nPointsU' and `nPointsV'. If `ConnectPoints' is\n" + "zero, the plugin creates points; otherwise, the\n" + "plugin generates quadrangles, lines or points\n" + " depending on the values of `nPointsU' and\n" + "`nPointsV'. If `iView' < 0, the plugin is run on\n" + "the current view.\n" + "\n" + "Plugin(CutGrid) creates one new view.\n"); } int GMSH_CutGridPlugin::getNbOptions() const @@ -247,23 +247,23 @@ void GMSH_CutGridPlugin::getPoint(int iU, int iV, double *X) } void GMSH_CutGridPlugin::addInView(int numsteps, int connect, int nbcomp, - double ***pnts, double ***vals, - List_T *P, int *nP, - List_T *L, int *nL, - List_T *Q, int *nQ) + double ***pnts, double ***vals, + List_T *P, int *nP, + List_T *L, int *nL, + List_T *Q, int *nQ) { if(!connect || (getNbU() == 1 && getNbV() == 1)){ // generate points for(int i = 0; i < getNbU(); ++i){ for(int j = 0; j < getNbV(); ++j){ - List_Add(P, &pnts[i][j][0]); - List_Add(P, &pnts[i][j][1]); - List_Add(P, &pnts[i][j][2]); - (*nP)++; - for(int k = 0; k < numsteps; ++k){ - for(int l = 0; l < nbcomp; ++l) - List_Add(P, &vals[i][j][nbcomp*k+l]); - } + List_Add(P, &pnts[i][j][0]); + List_Add(P, &pnts[i][j][1]); + List_Add(P, &pnts[i][j][2]); + (*nP)++; + for(int k = 0; k < numsteps; ++k){ + for(int l = 0; l < nbcomp; ++l) + List_Add(P, &vals[i][j][nbcomp*k+l]); + } } } @@ -272,56 +272,56 @@ void GMSH_CutGridPlugin::addInView(int numsteps, int connect, int nbcomp, if(getNbU() == 1){ for(int i = 0; i < getNbV()-1; ++i){ - List_Add(L, &pnts[0][i][0]); List_Add(L, &pnts[0][i+1][0]); - List_Add(L, &pnts[0][i][1]); List_Add(L, &pnts[0][i+1][1]); - List_Add(L, &pnts[0][i][2]); List_Add(L, &pnts[0][i+1][2]); - (*nL)++; - for(int k = 0; k < numsteps; ++k){ - for(int l = 0; l < nbcomp; ++l) - List_Add(L, &vals[0][i ][nbcomp*k+l]); - for(int l = 0; l < nbcomp; ++l) - List_Add(L, &vals[0][i+1][nbcomp*k+l]); - } + List_Add(L, &pnts[0][i][0]); List_Add(L, &pnts[0][i+1][0]); + List_Add(L, &pnts[0][i][1]); List_Add(L, &pnts[0][i+1][1]); + List_Add(L, &pnts[0][i][2]); List_Add(L, &pnts[0][i+1][2]); + (*nL)++; + for(int k = 0; k < numsteps; ++k){ + for(int l = 0; l < nbcomp; ++l) + List_Add(L, &vals[0][i ][nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(L, &vals[0][i+1][nbcomp*k+l]); + } } } else if(getNbV() == 1){ for(int i = 0; i < getNbU()-1; ++i){ - List_Add(L, &pnts[i][0][0]); List_Add(L, &pnts[i+1][0][0]); - List_Add(L, &pnts[i][0][1]); List_Add(L, &pnts[i+1][0][1]); - List_Add(L, &pnts[i][0][2]); List_Add(L, &pnts[i+1][0][2]); - (*nL)++; - for(int k = 0; k < numsteps; ++k){ - for(int l = 0; l < nbcomp; ++l) - List_Add(L, &vals[i ][0][nbcomp*k+l]); - for(int l = 0; l < nbcomp; ++l) - List_Add(L, &vals[i+1][0][nbcomp*k+l]); - } + List_Add(L, &pnts[i][0][0]); List_Add(L, &pnts[i+1][0][0]); + List_Add(L, &pnts[i][0][1]); List_Add(L, &pnts[i+1][0][1]); + List_Add(L, &pnts[i][0][2]); List_Add(L, &pnts[i+1][0][2]); + (*nL)++; + for(int k = 0; k < numsteps; ++k){ + for(int l = 0; l < nbcomp; ++l) + List_Add(L, &vals[i ][0][nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(L, &vals[i+1][0][nbcomp*k+l]); + } } } else{ for(int i = 0; i < getNbU()-1; ++i){ - for(int j = 0; j < getNbV()-1; ++j){ - List_Add(Q, &pnts[i ][j ][0]); List_Add(Q, &pnts[i+1][j ][0]); - List_Add(Q, &pnts[i+1][j+1][0]); List_Add(Q, &pnts[i ][j+1][0]); - List_Add(Q, &pnts[i ][j ][1]); List_Add(Q, &pnts[i+1][j ][1]); - List_Add(Q, &pnts[i+1][j+1][1]); List_Add(Q, &pnts[i ][j+1][1]); - List_Add(Q, &pnts[i ][j ][2]); List_Add(Q, &pnts[i+1][j ][2]); - List_Add(Q, &pnts[i+1][j+1][2]); List_Add(Q, &pnts[i ][j+1][2]); - (*nQ)++; - for(int k = 0; k < numsteps; ++k){ - for(int l = 0; l < nbcomp; ++l) - List_Add(Q, &vals[i ][j ][nbcomp*k+l]); - for(int l = 0; l < nbcomp; ++l) - List_Add(Q, &vals[i+1][j ][nbcomp*k+l]); - for(int l = 0; l < nbcomp; ++l) - List_Add(Q, &vals[i+1][j+1][nbcomp*k+l]); - for(int l = 0; l < nbcomp; ++l) - List_Add(Q, &vals[i ][j+1][nbcomp*k+l]); - } - } + for(int j = 0; j < getNbV()-1; ++j){ + List_Add(Q, &pnts[i ][j ][0]); List_Add(Q, &pnts[i+1][j ][0]); + List_Add(Q, &pnts[i+1][j+1][0]); List_Add(Q, &pnts[i ][j+1][0]); + List_Add(Q, &pnts[i ][j ][1]); List_Add(Q, &pnts[i+1][j ][1]); + List_Add(Q, &pnts[i+1][j+1][1]); List_Add(Q, &pnts[i ][j+1][1]); + List_Add(Q, &pnts[i ][j ][2]); List_Add(Q, &pnts[i+1][j ][2]); + List_Add(Q, &pnts[i+1][j+1][2]); List_Add(Q, &pnts[i ][j+1][2]); + (*nQ)++; + for(int k = 0; k < numsteps; ++k){ + for(int l = 0; l < nbcomp; ++l) + List_Add(Q, &vals[i ][j ][nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(Q, &vals[i+1][j ][nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(Q, &vals[i+1][j+1][nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(Q, &vals[i ][j+1][nbcomp*k+l]); + } + } } } - } + } } PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) @@ -357,25 +357,25 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) if(nbs){ for(int i = 0; i < getNbU(); i++) for(int j = 0; j < getNbV(); j++) - o.searchScalar(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); + o.searchScalar(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); addInView(numsteps, connect, 1, pnts, vals, data2->SP, &data2->NbSP, - data2->SL, &data2->NbSL, data2->SQ, &data2->NbSQ); + data2->SL, &data2->NbSL, data2->SQ, &data2->NbSQ); } if(nbv){ for(int i = 0; i < getNbU(); i++) for(int j = 0; j < getNbV(); j++) - o.searchVector(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); + o.searchVector(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); addInView(numsteps, connect, 3, pnts, vals, data2->VP, &data2->NbVP, - data2->VL, &data2->NbVL, data2->VQ, &data2->NbVQ); + data2->VL, &data2->NbVL, data2->VQ, &data2->NbVQ); } if(nbt){ for(int i = 0; i < getNbU(); i++) for(int j = 0; j < getNbV(); j++) - o.searchTensor(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); + o.searchTensor(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); addInView(numsteps, connect, 9, pnts, vals, data2->TP, &data2->NbTP, - data2->TL, &data2->NbTL, data2->TQ, &data2->NbTQ); + data2->TL, &data2->NbTL, data2->TQ, &data2->NbTQ); } for(int i = 0; i < getNbU(); i++){ diff --git a/Plugin/CutGrid.h b/Plugin/CutGrid.h index 3981dacd22aa5cc7d566ed55f7f89282e1af6840..57adfe30bf4efbf3ac6872803271f5cc2d5cae2a 100644 --- a/Plugin/CutGrid.h +++ b/Plugin/CutGrid.h @@ -30,19 +30,19 @@ extern "C" class GMSH_CutGridPlugin : public GMSH_Post_Plugin { static double callback(int num, int action, double value, double *opt, - double step, double min, double max); + double step, double min, double max); void addInView(int numsteps, int connect, int nbcomp, - double ***pnts, double ***vals, - List_T *P, int *nP, - List_T *L, int *nL, - List_T *Q, int *nQ); + double ***pnts, double ***vals, + List_T *P, int *nP, + List_T *L, int *nL, + List_T *Q, int *nQ); PView *GenerateView (PView *v, int connectPoints); public: GMSH_CutGridPlugin(); void getName (char *name) const; void getInfos (char *author, - char *copyright, - char *help_text) const; + char *copyright, + char *help_text) const; void catchErrorMessage (char *errorMessage) const; int getNbOptions() const; StringXNumber *getOption (int iopt); diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp index 3f9f53e66f7d0a6b75dc40895c57427936cbb04e..654d8d366e6801e57a2cf483442c1b4a2b34b654 100644 --- a/Plugin/CutMap.cpp +++ b/Plugin/CutMap.cpp @@ -1,4 +1,4 @@ -// $Id: CutMap.cpp,v 1.57 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: CutMap.cpp,v 1.58 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -113,19 +113,19 @@ void GMSH_CutMapPlugin::getInfos(char *author, char *copyright, strcpy(help_text, "Plugin(CutMap) extracts the isosurface of value\n" "`A' from the view `iView' and draws the\n" - "`dTimeStep'-th value of the view `dView' on the\n" - "isosurface. If `iView' < 0, the plugin is run\n" - "on the current view. If `dTimeStep' < 0, the\n" - "plugin uses, for each time step in `iView', the\n" - "corresponding time step in `dView'. If `dView'\n" - "< 0, the plugin uses `iView' as the value source.\n" - "If `ExtractVolume' is nonzero, the plugin\n" - "extracts the isovolume with values greater (if\n" - "`ExtractVolume' > 0) or smaller (if `ExtractVolume'\n" - "< 0) than the isosurface `A'.\n" - "\n" - "Plugin(CutMap) creates as many views as there\n" - "are time steps in `iView'.\n"); + "`dTimeStep'-th value of the view `dView' on the\n" + "isosurface. If `iView' < 0, the plugin is run\n" + "on the current view. If `dTimeStep' < 0, the\n" + "plugin uses, for each time step in `iView', the\n" + "corresponding time step in `dView'. If `dView'\n" + "< 0, the plugin uses `iView' as the value source.\n" + "If `ExtractVolume' is nonzero, the plugin\n" + "extracts the isovolume with values greater (if\n" + "`ExtractVolume' > 0) or smaller (if `ExtractVolume'\n" + "< 0) than the isosurface `A'.\n" + "\n" + "Plugin(CutMap) creates as many views as there\n" + "are time steps in `iView'.\n"); } int GMSH_CutMapPlugin::getNbOptions() const diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp index e67bd93e590cff40c08bd08268b7dcb9838619b3..aecf25a1431a103e1cca31ca62cb0058fc6aaaf1 100644 --- a/Plugin/CutParametric.cpp +++ b/Plugin/CutParametric.cpp @@ -1,4 +1,4 @@ -// $Id: CutParametric.cpp,v 1.26 2008-03-20 10:52:36 geuzaine Exp $ +// $Id: CutParametric.cpp,v 1.27 2008-03-20 11:44:12 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -147,7 +147,7 @@ void GMSH_CutParametricPlugin::draw() } double GMSH_CutParametricPlugin::callback(int num, int action, double value, double *opt, - double step, double min, double max) + double step, double min, double max) { switch(action){ // configure the input field case 1: return step; @@ -164,7 +164,7 @@ double GMSH_CutParametricPlugin::callback(int num, int action, double value, dou } const char *GMSH_CutParametricPlugin::callbackStr(int num, int action, const char *value, - const char **opt) + const char **opt) { *opt = value; #if defined(HAVE_FLTK) @@ -177,25 +177,25 @@ const char *GMSH_CutParametricPlugin::callbackStr(int num, int action, const cha double GMSH_CutParametricPlugin::callbackMinU(int num, int action, double value) { return callback(num, action, value, &CutParametricOptions_Number[0].def, - 0.01, 0., 10.); + 0.01, 0., 10.); } double GMSH_CutParametricPlugin::callbackMaxU(int num, int action, double value) { return callback(num, action, value, &CutParametricOptions_Number[1].def, - 0.01, 0., 10.); + 0.01, 0., 10.); } double GMSH_CutParametricPlugin::callbackN(int num, int action, double value) { return callback(num, action, value, &CutParametricOptions_Number[2].def, - 1, 1, 1000); + 1, 1, 1000); } double GMSH_CutParametricPlugin::callbackConnect(int num, int action, double value) { return callback(num, action, value, &CutParametricOptions_Number[3].def, - 1, 0, 1); + 1, 0, 1); } const char *GMSH_CutParametricPlugin::callbackX(int num, int action, const char *value) @@ -225,14 +225,14 @@ void GMSH_CutParametricPlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(CutParametric) cuts the view `iView' with\n" - "the parametric function (`X'(u), `Y'(u), `Z'(u)),\n" - "using `nPointsU' values of the parameter u in\n" - "[`MinU', `MaxU']. If `ConnectPoints' is set, the\n" - "plugin creates line elements; otherwise, the\n" - "plugin generates points. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(CutParametric) creates one new view.\n"); + "the parametric function (`X'(u), `Y'(u), `Z'(u)),\n" + "using `nPointsU' values of the parameter u in\n" + "[`MinU', `MaxU']. If `ConnectPoints' is set, the\n" + "plugin creates line elements; otherwise, the\n" + "plugin generates points. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(CutParametric) creates one new view.\n"); } int GMSH_CutParametricPlugin::getNbOptions() const @@ -261,9 +261,9 @@ void GMSH_CutParametricPlugin::catchErrorMessage(char *errorMessage) const } static void addInView(int connect, int i, int nbcomp, int nbtime, - double x0, double y0, double z0, double *res0, - double x, double y, double z, double *res, - List_T *P, int *nP, List_T *L, int *nL) + double x0, double y0, double z0, double *res0, + double x, double y, double z, double *res, + List_T *P, int *nP, List_T *L, int *nL) { if(connect){ if(i){ @@ -271,10 +271,10 @@ static void addInView(int connect, int i, int nbcomp, int nbtime, List_Add(L, &y0); List_Add(L, &y); List_Add(L, &z0); List_Add(L, &z); for(int k = 0; k < nbtime; ++k){ - for(int l = 0; l < nbcomp; ++l) - List_Add(L, &res0[nbcomp*k+l]); - for(int l = 0; l < nbcomp; ++l) - List_Add(L, &res[nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(L, &res0[nbcomp*k+l]); + for(int l = 0; l < nbcomp; ++l) + List_Add(L, &res[nbcomp*k+l]); } (*nL)++; } @@ -285,7 +285,7 @@ static void addInView(int connect, int i, int nbcomp, int nbtime, List_Add(P, &z); for(int k = 0; k < nbtime; ++k) for(int l = 0; l < nbcomp; ++l) - List_Add(P, &res[nbcomp*k+l]); + List_Add(P, &res[nbcomp*k+l]); (*nP)++; } } @@ -332,17 +332,17 @@ PView *GMSH_CutParametricPlugin::execute(PView *v) if(data1->getNumScalars()){ o.searchScalar(x1, y1, z1, res1); addInView(connect, i, 1, numSteps, x0, y0, z0, res0, x1, y1, z1, res1, - data2->SP, &data2->NbSP, data2->SL, &data2->NbSL); + data2->SP, &data2->NbSP, data2->SL, &data2->NbSL); } if(data1->getNumVectors()){ o.searchVector(x1, y1, z1, res1); addInView(connect, i, 3, numSteps, x0, y0, z0, res0, x1, y1, z1, res1, - data2->VP, &data2->NbVP, data2->VL, &data2->NbVL); + data2->VP, &data2->NbVP, data2->VL, &data2->NbVL); } if(data1->getNumTensors()){ o.searchTensor(x1, y1, z1, res1); addInView(connect, i, 9, numSteps, x0, y0, z0, res0, x1, y1, z1, res1, - data2->TP, &data2->NbTP, data2->TL, &data2->NbTL); + data2->TP, &data2->NbTP, data2->TL, &data2->NbTL); } } diff --git a/Plugin/CutParametric.h b/Plugin/CutParametric.h index fb958fd36422b57f9f03864d8cff32f5c21eea0b..abf81766914e7f5450aa85d851b4a153e9892b21 100644 --- a/Plugin/CutParametric.h +++ b/Plugin/CutParametric.h @@ -33,9 +33,9 @@ class GMSH_CutParametricPlugin : public GMSH_Post_Plugin { private: static double callback(int num, int action, double value, double *opt, - double step, double min, double max); + double step, double min, double max); static const char *callbackStr(int num, int action, const char *value, - const char **opt); + const char **opt); static int fillXYZ(); static int recompute; static std::vector<double> x, y, z; diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index 4c7880ab5a7590640a8fa0be42efdcd710403f22..19f25977ef7c090ef1b1575fefa525b78edcee25 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -1,4 +1,4 @@ -// $Id: CutPlane.cpp,v 1.55 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: CutPlane.cpp,v 1.56 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -66,17 +66,17 @@ void GMSH_CutPlanePlugin::draw() glLineWidth(CTX.line_width); SBoundingBox3d bb = PView::list[num]->getData()->getBoundingBox(); Draw_PlaneInBoundingBox(bb.min().x(), bb.min().y(), bb.min().z(), - bb.max().x(), bb.max().y(), bb.max().z(), - CutPlaneOptions_Number[0].def, - CutPlaneOptions_Number[1].def, - CutPlaneOptions_Number[2].def, - CutPlaneOptions_Number[3].def); + bb.max().x(), bb.max().y(), bb.max().z(), + CutPlaneOptions_Number[0].def, + CutPlaneOptions_Number[1].def, + CutPlaneOptions_Number[2].def, + CutPlaneOptions_Number[3].def); } #endif } double GMSH_CutPlanePlugin::callback(int num, int action, double value, double *opt, - double step, double min, double max) + double step, double min, double max) { if(action > 0) iview = num; switch(action){ // configure the input field @@ -95,43 +95,43 @@ double GMSH_CutPlanePlugin::callback(int num, int action, double value, double * double GMSH_CutPlanePlugin::callbackA(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[0].def, - 0.01, -1, 1); + 0.01, -1, 1); } double GMSH_CutPlanePlugin::callbackB(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[1].def, - 0.01, -1, 1); + 0.01, -1, 1); } double GMSH_CutPlanePlugin::callbackC(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[2].def, - 0.01, -1, 1); + 0.01, -1, 1); } double GMSH_CutPlanePlugin::callbackD(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[3].def, - CTX.lc/200., -CTX.lc, CTX.lc); + CTX.lc/200., -CTX.lc, CTX.lc); } double GMSH_CutPlanePlugin::callbackVol(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[4].def, - 1., -1, 1); + 1., -1, 1); } double GMSH_CutPlanePlugin::callbackRecur(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[5].def, - 1, 0, 10); + 1, 0, 10); } double GMSH_CutPlanePlugin::callbackTarget(int num, int action, double value) { return callback(num, action, value, &CutPlaneOptions_Number[6].def, - 0.01, 0., 1.); + 0.01, 0., 1.); } void GMSH_CutPlanePlugin::getName(char *name) const @@ -146,13 +146,13 @@ void GMSH_CutPlanePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(CutPlane) cuts the view `iView' with\n" - "the plane `A'*X + `B'*Y + `C'*Z + `D' = 0. If\n" - "`ExtractVolume' is nonzero, the plugin extracts\n" - "the elements on one side of the plane (depending\n" - "on the sign of `ExtractVolume'). If `iView' < 0,\n" - "the plugin is run on the current view.\n" - "\n" - "Plugin(CutPlane) creates one new view.\n"); + "the plane `A'*X + `B'*Y + `C'*Z + `D' = 0. If\n" + "`ExtractVolume' is nonzero, the plugin extracts\n" + "the elements on one side of the plane (depending\n" + "on the sign of `ExtractVolume'). If `iView' < 0,\n" + "the plugin is run on the current view.\n" + "\n" + "Plugin(CutPlane) creates one new view.\n"); } int GMSH_CutPlanePlugin::getNbOptions() const @@ -180,12 +180,12 @@ double GMSH_CutPlanePlugin::levelset(double x, double y, double z, double val) c bool GMSH_CutPlanePlugin::geometricalFilter(Double_Matrix *node_positions) const { const double l0 = levelset((*node_positions)(0, 0), - (*node_positions)(0, 1), - (*node_positions)(0, 2), 1); + (*node_positions)(0, 1), + (*node_positions)(0, 2), 1); for (int i = 1; i < node_positions->size1(); i++) if (levelset((*node_positions)(i, 0), - (*node_positions)(i, 1), - (*node_positions)(i, 2), 1) * l0 < 0) return true; + (*node_positions)(i, 1), + (*node_positions)(i, 2), 1) * l0 < 0) return true; return false; } diff --git a/Plugin/CutPlane.h b/Plugin/CutPlane.h index 542e9e27ead0d435d09bf0998ff61bfd6260e2be..656bf9d1ee90cb9c921ef3e2ae25f3e65737f0c6 100644 --- a/Plugin/CutPlane.h +++ b/Plugin/CutPlane.h @@ -31,7 +31,7 @@ class GMSH_CutPlanePlugin : public GMSH_LevelsetPlugin { double levelset(double x, double y, double z, double val) const; static double callback(int num, int action, double value, double *opt, - double step, double min, double max); + double step, double min, double max); static int iview; public: GMSH_CutPlanePlugin(); diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp index 3f879920703ab1f9a13980c199f6c34bc68b98a9..438c40782a82b8dff1d9650d44d4b8e6387db61e 100644 --- a/Plugin/CutSphere.cpp +++ b/Plugin/CutSphere.cpp @@ -1,4 +1,4 @@ -// $Id: CutSphere.cpp,v 1.49 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: CutSphere.cpp,v 1.50 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -70,8 +70,8 @@ void GMSH_CutSpherePlugin::draw() glColor4ubv((GLubyte *) & CTX.color.fg); glLineWidth(CTX.line_width); glTranslated(CutSphereOptions_Number[0].def, - CutSphereOptions_Number[1].def, - CutSphereOptions_Number[2].def); + CutSphereOptions_Number[1].def, + CutSphereOptions_Number[2].def); gluSphere(qua, CutSphereOptions_Number[3].def, 40, 40); glPopMatrix(); glPolygonMode(GL_FRONT_AND_BACK, mode[1]); @@ -79,7 +79,7 @@ void GMSH_CutSpherePlugin::draw() } double GMSH_CutSpherePlugin::callback(int num, int action, double value, double *opt, - double step, double min, double max) + double step, double min, double max) { switch(action){ // configure the input field case 1: return step; @@ -97,37 +97,37 @@ double GMSH_CutSpherePlugin::callback(int num, int action, double value, double double GMSH_CutSpherePlugin::callbackX(int num, int action, double value) { return callback(num, action, value, &CutSphereOptions_Number[0].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutSpherePlugin::callbackY(int num, int action, double value) { return callback(num, action, value, &CutSphereOptions_Number[1].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutSpherePlugin::callbackZ(int num, int action, double value) { return callback(num, action, value, &CutSphereOptions_Number[2].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_CutSpherePlugin::callbackR(int num, int action, double value) { return callback(num, action, value, &CutSphereOptions_Number[3].def, - CTX.lc/100., 0., 2*CTX.lc); + CTX.lc/100., 0., 2*CTX.lc); } double GMSH_CutSpherePlugin::callbackVol(int num, int action, double value) { return callback(num, action, value, &CutSphereOptions_Number[4].def, - 1., -1., 1.); + 1., -1., 1.); } double GMSH_CutSpherePlugin::callbackRecur(int num, int action, double value) { return callback(num, action, value, &CutSphereOptions_Number[5].def, - 1, 0, 10); + 1, 0, 10); } void GMSH_CutSpherePlugin::getName(char *name) const @@ -142,13 +142,13 @@ void GMSH_CutSpherePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(CutSphere) cuts the view `iView' with the\n" - "sphere (X-`Xc')^2 + (Y-`Yc')^2 + (Z-`Zc')^2 = `R'^2.\n" - "If `ExtractVolume' is nonzero, the plugin extracts\n" - "the elements inside (if `ExtractVolume' < 0) or\n" - "outside (if `ExtractVolume' > 0) the sphere. If\n" - "`iView' < 0, the plugin is run on the current view.\n" - "\n" - "Plugin(CutSphere) creates one new view.\n"); + "sphere (X-`Xc')^2 + (Y-`Yc')^2 + (Z-`Zc')^2 = `R'^2.\n" + "If `ExtractVolume' is nonzero, the plugin extracts\n" + "the elements inside (if `ExtractVolume' < 0) or\n" + "outside (if `ExtractVolume' > 0) the sphere. If\n" + "`iView' < 0, the plugin is run on the current view.\n" + "\n" + "Plugin(CutSphere) creates one new view.\n"); } int GMSH_CutSpherePlugin::getNbOptions() const diff --git a/Plugin/CutSphere.h b/Plugin/CutSphere.h index f7ac1910692bee8f4337b5a74c84f7a5f5462c44..546afc647b7fcba67ec570ece1a11daf2ca9e1cd 100644 --- a/Plugin/CutSphere.h +++ b/Plugin/CutSphere.h @@ -31,7 +31,7 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin { double levelset(double x, double y, double z, double val) const; static double callback(int num, int action, double value, double *opt, - double step, double min, double max); + double step, double min, double max); public: GMSH_CutSpherePlugin(); void getName(char *name) const; diff --git a/Plugin/Divergence.cpp b/Plugin/Divergence.cpp index 3705cf6a2727733f3caf76128d0c93940edaf909..aaa1501c4b85c845ba022c9d1e03fa32a1408bb6 100644 --- a/Plugin/Divergence.cpp +++ b/Plugin/Divergence.cpp @@ -1,4 +1,4 @@ -// $Id: Divergence.cpp,v 1.6 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: Divergence.cpp,v 1.7 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,16 +45,16 @@ void GMSH_DivergencePlugin::getName(char *name) const } void GMSH_DivergencePlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, - "Plugin(Divergence) computes the divergence of the\n" - "field in the view `iView'. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(Divergence) creates one new view.\n"); + "Plugin(Divergence) computes the divergence of the\n" + "field in the view `iView'. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(Divergence) creates one new view.\n"); } int GMSH_DivergencePlugin::getNbOptions() const @@ -73,7 +73,7 @@ void GMSH_DivergencePlugin::catchErrorMessage(char *errorMessage) const } static void divergence(int inNb, List_T *inList, int *outNb, List_T *outList, - int dim, int nbNod, int nbTime) + int dim, int nbNod, int nbTime) { if(!inNb) return; @@ -90,10 +90,10 @@ static void divergence(int inNb, List_T *inList, int *outNb, List_T *outList, for(int j = 0; j < nbTime; j++){ double *val = (double *)List_Pointer(inList, i + 3 * nbNod + nbNod * 3 * j); for(int k = 0; k < nbNod; k++){ - double u, v, w; - element->getNode(k, u, v, w); - double f = element->interpolateDiv(val, u, v, w, 3); - List_Add(outList, &f); + double u, v, w; + element->getNode(k, u, v, w); + double f = element->interpolateDiv(val, u, v, w, 3); + List_Add(outList, &f); } } delete element; diff --git a/Plugin/Eigenvalues.cpp b/Plugin/Eigenvalues.cpp index 03e922bbb0b05f0b1ea033ef109575df42c82b9c..3ea813d9482131beee665be6bea898aca794ab7d 100644 --- a/Plugin/Eigenvalues.cpp +++ b/Plugin/Eigenvalues.cpp @@ -1,4 +1,4 @@ -// $Id: Eigenvalues.cpp,v 1.6 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: Eigenvalues.cpp,v 1.7 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -50,10 +50,10 @@ void GMSH_EigenvaluesPlugin::getInfos(char *author, char *copyright, char *help_ strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Eigenvalues) computes the three real\n" - "eigenvalues of each tensor in the view `iView'.\n" - "If `iView' < 0, the plugin is run on the current view.\n" - "\n" - "Plugin(Eigenvalues) creates three new scalar views.\n"); + "eigenvalues of each tensor in the view `iView'.\n" + "If `iView' < 0, the plugin is run on the current view.\n" + "\n" + "Plugin(Eigenvalues) creates three new scalar views.\n"); } int GMSH_EigenvaluesPlugin::getNbOptions() const @@ -72,10 +72,10 @@ void GMSH_EigenvaluesPlugin::catchErrorMessage(char *errorMessage) const } static void eigenvalues(List_T *inList, int inNb, - int nbNod, int nbTime, - List_T *minList, int *minNb, - List_T *midList, int *midNb, - List_T *maxList, int *maxNb) + int nbNod, int nbTime, + List_T *minList, int *minNb, + List_T *midList, int *midNb, + List_T *maxList, int *maxNb) { if(!inNb) return; @@ -88,17 +88,17 @@ static void eigenvalues(List_T *inList, int inNb, } for(int j = 0; j < nbTime; j++){ for(int k = 0; k < nbNod; k++){ - double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + - nbNod * 9 * j + 9 * k); - double w[3], A[3][3] = { {v[0], v[1], v[2]}, - {v[3], v[4], v[5]}, - {v[6], v[7], v[8]} }; - eigenvalue(A, w); - for(int l = 0; l < 3; l++){ - List_Add(minList, &w[2]); - List_Add(midList, &w[1]); - List_Add(maxList, &w[0]); - } + double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + + nbNod * 9 * j + 9 * k); + double w[3], A[3][3] = { {v[0], v[1], v[2]}, + {v[3], v[4], v[5]}, + {v[6], v[7], v[8]} }; + eigenvalue(A, w); + for(int l = 0; l < 3; l++){ + List_Add(minList, &w[2]); + List_Add(midList, &w[1]); + List_Add(maxList, &w[0]); + } } } (*minNb)++; @@ -126,21 +126,21 @@ PView *GMSH_EigenvaluesPlugin::execute(PView *v) PViewDataList *dmax = getDataList(max); eigenvalues(data1->TP, data1->NbTP, 1, data1->getNumTimeSteps(), - dmin->SP, &dmin->NbSP, dmid->SP, &dmid->NbSP, dmax->SP, &dmax->NbSP); + dmin->SP, &dmin->NbSP, dmid->SP, &dmid->NbSP, dmax->SP, &dmax->NbSP); eigenvalues(data1->TL, data1->NbTL, 2, data1->getNumTimeSteps(), - dmin->SL, &dmin->NbSL, dmid->SL, &dmid->NbSL, dmax->SL, &dmax->NbSL); + dmin->SL, &dmin->NbSL, dmid->SL, &dmid->NbSL, dmax->SL, &dmax->NbSL); eigenvalues(data1->TT, data1->NbTT, 3, data1->getNumTimeSteps(), - dmin->ST, &dmin->NbST, dmid->ST, &dmid->NbST, dmax->ST, &dmax->NbST); + dmin->ST, &dmin->NbST, dmid->ST, &dmid->NbST, dmax->ST, &dmax->NbST); eigenvalues(data1->TQ, data1->NbTQ, 4, data1->getNumTimeSteps(), - dmin->SQ, &dmin->NbSQ, dmid->SQ, &dmid->NbSQ, dmax->SQ, &dmax->NbSQ); + dmin->SQ, &dmin->NbSQ, dmid->SQ, &dmid->NbSQ, dmax->SQ, &dmax->NbSQ); eigenvalues(data1->TS, data1->NbTS, 4, data1->getNumTimeSteps(), - dmin->SS, &dmin->NbSS, dmid->SS, &dmid->NbSS, dmax->SS, &dmax->NbSS); + dmin->SS, &dmin->NbSS, dmid->SS, &dmid->NbSS, dmax->SS, &dmax->NbSS); eigenvalues(data1->TH, data1->NbTH, 8, data1->getNumTimeSteps(), - dmin->SH, &dmin->NbSH, dmid->SH, &dmid->NbSH, dmax->SH, &dmax->NbSH); + dmin->SH, &dmin->NbSH, dmid->SH, &dmid->NbSH, dmax->SH, &dmax->NbSH); eigenvalues(data1->TI, data1->NbTI, 6, data1->getNumTimeSteps(), - dmin->SI, &dmin->NbSI, dmid->SI, &dmid->NbSI, dmax->SI, &dmax->NbSI); + dmin->SI, &dmin->NbSI, dmid->SI, &dmid->NbSI, dmax->SI, &dmax->NbSI); eigenvalues(data1->TY, data1->NbTY, 5, data1->getNumTimeSteps(), - dmin->SY, &dmin->NbSY, dmid->SY, &dmid->NbSY, dmax->SY, &dmax->NbSY); + dmin->SY, &dmin->NbSY, dmid->SY, &dmid->NbSY, dmax->SY, &dmax->NbSY); for(int i = 0; i < List_Nbr(data1->Time); i++){ List_Add(dmin->Time, List_Pointer(data1->Time, i)); diff --git a/Plugin/Eigenvectors.cpp b/Plugin/Eigenvectors.cpp index 659b63ec23b1df223b7f73d6bd7c3f55f9104841..41fe60be0bd5f3a9783c117fa26c48293fb56773 100644 --- a/Plugin/Eigenvectors.cpp +++ b/Plugin/Eigenvectors.cpp @@ -1,4 +1,4 @@ -// $Id: Eigenvectors.cpp,v 1.10 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: Eigenvectors.cpp,v 1.11 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -52,16 +52,16 @@ void GMSH_EigenvectorsPlugin::getInfos(char *author, char *copyright, char *help strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Eigenvectors) computes the three (right)\n" - "eigenvectors of each tensor in the view `iView'\n" - "and sorts them according to the value of the\n" - "associated eigenvalues. If `ScaleByEigenvalues'\n" - "is set, each eigenvector is scaled by its\n" - "associated eigenvalue. The plugin gives an error\n" - "if the eigenvectors are complex. If `iView' < 0,\n" - "the plugin is run on the current view.\n" - "\n" - "Plugin(Eigenvectors) creates three new\n" - "vector views.\n"); + "eigenvectors of each tensor in the view `iView'\n" + "and sorts them according to the value of the\n" + "associated eigenvalues. If `ScaleByEigenvalues'\n" + "is set, each eigenvector is scaled by its\n" + "associated eigenvalue. The plugin gives an error\n" + "if the eigenvectors are complex. If `iView' < 0,\n" + "the plugin is run on the current view.\n" + "\n" + "Plugin(Eigenvectors) creates three new\n" + "vector views.\n"); } int GMSH_EigenvectorsPlugin::getNbOptions() const @@ -87,10 +87,10 @@ static int nonzero(double v[3]) } static void eigenvectors(List_T *inList, int inNb, - int nbNod, int nbTime, int scale, - List_T *minList, int *minNb, - List_T *midList, int *midNb, - List_T *maxList, int *maxNb) + int nbNod, int nbTime, int scale, + List_T *minList, int *minNb, + List_T *midList, int *midNb, + List_T *maxList, int *maxNb) { if(!inNb) return; @@ -105,22 +105,22 @@ static void eigenvectors(List_T *inList, int inNb, } for(int j = 0; j < nbTime; j++){ for(int k = 0; k < nbNod; k++){ - double *val = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + - nbNod * 9 * j + 9 * k); - double wr[3], wi[3], B[9]; - if(!EigSolve3x3(val, wr, wi, B)) - Msg(GERROR, "Eigensolver failed to converge"); - nbcomplex += nonzero(wi); - if(!scale) - wr[0] = wr[1] = wr[2] = 1.; - for(int l = 0; l < 3; l++){ - double res; - // wrong if there are complex eigenvals (B contains both - // real and imag parts: cf. explanation in EigSolve.cpp) - res = wr[0] * B[l]; List_Add(minList, &res); - res = wr[1] * B[3+l]; List_Add(midList, &res); - res = wr[2] * B[6+l]; List_Add(maxList, &res); - } + double *val = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + + nbNod * 9 * j + 9 * k); + double wr[3], wi[3], B[9]; + if(!EigSolve3x3(val, wr, wi, B)) + Msg(GERROR, "Eigensolver failed to converge"); + nbcomplex += nonzero(wi); + if(!scale) + wr[0] = wr[1] = wr[2] = 1.; + for(int l = 0; l < 3; l++){ + double res; + // wrong if there are complex eigenvals (B contains both + // real and imag parts: cf. explanation in EigSolve.cpp) + res = wr[0] * B[l]; List_Add(minList, &res); + res = wr[1] * B[3+l]; List_Add(midList, &res); + res = wr[2] * B[6+l]; List_Add(maxList, &res); + } } } (*minNb)++; @@ -152,21 +152,21 @@ PView *GMSH_EigenvectorsPlugin::execute(PView *v) PViewDataList *dmax = getDataList(max); eigenvectors(data1->TP, data1->NbTP, 1, data1->getNumTimeSteps(), scale, - dmin->VP, &dmin->NbVP, dmid->VP, &dmid->NbVP, dmax->VP, &dmax->NbVP); + dmin->VP, &dmin->NbVP, dmid->VP, &dmid->NbVP, dmax->VP, &dmax->NbVP); eigenvectors(data1->TL, data1->NbTL, 2, data1->getNumTimeSteps(), scale, - dmin->VL, &dmin->NbVL, dmid->VL, &dmid->NbVL, dmax->VL, &dmax->NbVL); + dmin->VL, &dmin->NbVL, dmid->VL, &dmid->NbVL, dmax->VL, &dmax->NbVL); eigenvectors(data1->TT, data1->NbTT, 3, data1->getNumTimeSteps(), scale, - dmin->VT, &dmin->NbVT, dmid->VT, &dmid->NbVT, dmax->VT, &dmax->NbVT); + dmin->VT, &dmin->NbVT, dmid->VT, &dmid->NbVT, dmax->VT, &dmax->NbVT); eigenvectors(data1->TQ, data1->NbTQ, 4, data1->getNumTimeSteps(), scale, - dmin->VQ, &dmin->NbVQ, dmid->VQ, &dmid->NbVQ, dmax->VQ, &dmax->NbVQ); + dmin->VQ, &dmin->NbVQ, dmid->VQ, &dmid->NbVQ, dmax->VQ, &dmax->NbVQ); eigenvectors(data1->TS, data1->NbTS, 4, data1->getNumTimeSteps(), scale, - dmin->VS, &dmin->NbVS, dmid->VS, &dmid->NbVS, dmax->VS, &dmax->NbVS); + dmin->VS, &dmin->NbVS, dmid->VS, &dmid->NbVS, dmax->VS, &dmax->NbVS); eigenvectors(data1->TH, data1->NbTH, 8, data1->getNumTimeSteps(), scale, - dmin->VH, &dmin->NbVH, dmid->VH, &dmid->NbVH, dmax->VH, &dmax->NbVH); + dmin->VH, &dmin->NbVH, dmid->VH, &dmid->NbVH, dmax->VH, &dmax->NbVH); eigenvectors(data1->TI, data1->NbTI, 6, data1->getNumTimeSteps(), scale, - dmin->VI, &dmin->NbVI, dmid->VI, &dmid->NbVI, dmax->VI, &dmax->NbVI); + dmin->VI, &dmin->NbVI, dmid->VI, &dmid->NbVI, dmax->VI, &dmax->NbVI); eigenvectors(data1->TY, data1->NbTY, 5, data1->getNumTimeSteps(), scale, - dmin->VY, &dmin->NbVY, dmid->VY, &dmid->NbVY, dmax->VY, &dmax->NbVY); + dmin->VY, &dmin->NbVY, dmid->VY, &dmid->NbVY, dmax->VY, &dmax->NbVY); for(int i = 0; i < List_Nbr(data1->Time); i++){ List_Add(dmin->Time, List_Pointer(data1->Time, i)); diff --git a/Plugin/Evaluate.cpp b/Plugin/Evaluate.cpp index 21805d84ba0b4d2916ed028eca15de8507339530..777cda9c771e1af8bef8b7124312881d8c269022 100644 --- a/Plugin/Evaluate.cpp +++ b/Plugin/Evaluate.cpp @@ -1,4 +1,4 @@ -// $Id: Evaluate.cpp,v 1.34 2008-02-23 15:30:10 geuzaine Exp $ +// $Id: Evaluate.cpp,v 1.35 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -57,56 +57,56 @@ void GMSH_EvaluatePlugin::getName(char *name) const } void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Evaluate) sets the `Component'-th\n" - "component of the `TimeStep'-th time step in the\n" - "view `iView' to the expression `Expression'.\n" - "`Expression' can contain:\n" - "\n" - "- the usual mathematical functions (Log, Sqrt,\n" - "Sin, Cos, Fabs, ...) and operators (+, -, *, /, ^);\n" - "\n" - "- the symbols x, y and z, to retrieve the\n" - "coordinates of the current node;\n" - "\n" - "- the symbols Time and TimeStep, to retrieve the\n" - "current time and time step values;\n" - "\n" - "- the symbol v, to retrieve the `Component'-th\n" - "component of the field in `iView' at the\n" - "`TimeStep'-th time step;\n" - "\n" - "- the symbols v0, v1, v2, ..., v8, to retrieve each\n" - "component of the field in `iView' at the\n" - "`TimeStep'-th time step;\n" - "\n" - "- the symbol w, to retrieve the `Component'-th\n" - "component of the field in `ExternalView' at the\n" - "`ExternalTimeStep'-th time step. If `ExternalView'\n" - "and `iView' are based on different spatial grids,\n" - "or if their data types are different, `ExternalView'\n" - "is interpolated onto `iView';\n" - "\n" - "- the symbols w0, w1, w2, ..., w8, to retrieve each\n" - "component of the field in `ExternalView' at the\n" - "`ExternalTimeStep'-th time step.\n" - "\n" - "If `TimeStep' < 0, the plugin automatically loops\n" - "over all the time steps in `iView' and evaluates\n" - "`Expression' for each one. If `ExternalTimeStep'\n" - "< 0, the plugin uses `TimeStep' instead. If\n" - "`Component' < 0, the plugin automatically loops\n" - "over all the components in the view and\n" - "evaluates `Expression' for each one. If `iView'\n" - "< 0, the plugin is run on the current view. If\n" - "`ExternalView' < 0, the plugin uses `iView'\n" - "instead.\n" - "\n" - "Plugin(Evaluate) is executed in-place.\n"); + "component of the `TimeStep'-th time step in the\n" + "view `iView' to the expression `Expression'.\n" + "`Expression' can contain:\n" + "\n" + "- the usual mathematical functions (Log, Sqrt,\n" + "Sin, Cos, Fabs, ...) and operators (+, -, *, /, ^);\n" + "\n" + "- the symbols x, y and z, to retrieve the\n" + "coordinates of the current node;\n" + "\n" + "- the symbols Time and TimeStep, to retrieve the\n" + "current time and time step values;\n" + "\n" + "- the symbol v, to retrieve the `Component'-th\n" + "component of the field in `iView' at the\n" + "`TimeStep'-th time step;\n" + "\n" + "- the symbols v0, v1, v2, ..., v8, to retrieve each\n" + "component of the field in `iView' at the\n" + "`TimeStep'-th time step;\n" + "\n" + "- the symbol w, to retrieve the `Component'-th\n" + "component of the field in `ExternalView' at the\n" + "`ExternalTimeStep'-th time step. If `ExternalView'\n" + "and `iView' are based on different spatial grids,\n" + "or if their data types are different, `ExternalView'\n" + "is interpolated onto `iView';\n" + "\n" + "- the symbols w0, w1, w2, ..., w8, to retrieve each\n" + "component of the field in `ExternalView' at the\n" + "`ExternalTimeStep'-th time step.\n" + "\n" + "If `TimeStep' < 0, the plugin automatically loops\n" + "over all the time steps in `iView' and evaluates\n" + "`Expression' for each one. If `ExternalTimeStep'\n" + "< 0, the plugin uses `TimeStep' instead. If\n" + "`Component' < 0, the plugin automatically loops\n" + "over all the components in the view and\n" + "evaluates `Expression' for each one. If `iView'\n" + "< 0, the plugin is run on the current view. If\n" + "`ExternalView' < 0, the plugin uses `iView'\n" + "instead.\n" + "\n" + "Plugin(Evaluate) is executed in-place.\n"); } int GMSH_EvaluatePlugin::getNbOptions() const @@ -135,10 +135,10 @@ void GMSH_EvaluatePlugin::catchErrorMessage(char *errorMessage) const } void GMSH_EvaluatePlugin::evaluate(PView *v1, List_T *list1, int nbElm1, - PView *v2, List_T *list2, int nbElm2, - int nbNod, int nbComp, int comp, - int timeStep1, int timeStep2, - const char *expression) + PView *v2, List_T *list2, int nbElm2, + int nbNod, int nbComp, int comp, + int timeStep1, int timeStep2, + const char *expression) { #if !defined(HAVE_MATH_EVAL) @@ -173,41 +173,41 @@ void GMSH_EvaluatePlugin::evaluate(PView *v1, List_T *list1, int nbElm1, // store data from the main view into v double v[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}; double *val1 = (double *)List_Pointer_Fast(list1, - i + 3 * nbNod + - nbNod * nbComp * timeStep1 + nbComp * j); + i + 3 * nbNod + + nbNod * nbComp * timeStep1 + nbComp * j); for(int k = 0; k < nbComp; k++) v[k] = val1[k]; // store data from the external view into w double w[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}; double *val2; if(_octree){ - double tmp[9]; - val2 = tmp; - if(_octree->searchScalar(x[j], y[j], z[j], val2, timeStep2)){ - w[0] = val2[0]; - } - else if(_octree->searchVector(x[j], y[j], z[j], val2, timeStep2)){ - for(int k = 0; k < 3; k++) w[k] = val2[k]; - } - else if(_octree->searchTensor(x[j], y[j], z[j], val2, timeStep2)){ - for(int k = 0; k < 9; k++) w[k] = val2[k]; - } + double tmp[9]; + val2 = tmp; + if(_octree->searchScalar(x[j], y[j], z[j], val2, timeStep2)){ + w[0] = val2[0]; + } + else if(_octree->searchVector(x[j], y[j], z[j], val2, timeStep2)){ + for(int k = 0; k < 3; k++) w[k] = val2[k]; + } + else if(_octree->searchTensor(x[j], y[j], z[j], val2, timeStep2)){ + for(int k = 0; k < 9; k++) w[k] = val2[k]; + } } else{ - val2 = (double *)List_Pointer_Fast(list2, - i2 + 3 * nbNod + - nbNod * nbComp * timeStep2 + nbComp * j); - for(int k = 0; k < nbComp; k++) w[k] = val2[k]; + val2 = (double *)List_Pointer_Fast(list2, + i2 + 3 * nbNod + + nbNod * nbComp * timeStep2 + nbComp * j); + for(int k = 0; k < nbComp; k++) w[k] = val2[k]; } double time = v1->getData()->getTime(timeStep1); double tstep = timeStep1; char *names[] = { "x", "y", "z", "Time", "TimeStep", - "v", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", - "w", "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8" }; + "v", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", + "w", "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8" }; double values[] = { x[j], y[j], z[j], time, tstep, - v[comp], v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], - w[comp], w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8] }; + v[comp], v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], + w[comp], w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8] }; val1[comp] = evaluator_evaluate(f, sizeof(names)/sizeof(names[0]), names, values); } } @@ -233,7 +233,7 @@ PView *GMSH_EvaluatePlugin::execute(PView *v) if(timeStep > data1->getNumTimeSteps() - 1){ Msg(GERROR, "Invalid time step (%d) in View[%d]: using step 0 instead", - timeStep, v1->getIndex()); + timeStep, v1->getIndex()); timeStep = 0; } @@ -255,7 +255,7 @@ PView *GMSH_EvaluatePlugin::execute(PView *v) } else if(externalTimeStep > data2->getNumTimeSteps() - 1){ Msg(GERROR, "Invalid time step (%d) in View[%d]: using step 0 instead", - externalTimeStep, v2->getIndex()); + externalTimeStep, v2->getIndex()); externalTimeStep = 0; } @@ -266,67 +266,67 @@ PView *GMSH_EvaluatePlugin::execute(PView *v) int t2; if(externalTimeStep < 0) - t2 = tt; + t2 = tt; else - t2 = externalTimeStep; + t2 = externalTimeStep; evaluate(v1, data1->SP, data1->NbSP, - v2, data2->SP, data2->NbSP, 1, 1, 0, tt, t2, expr); + v2, data2->SP, data2->NbSP, 1, 1, 0, tt, t2, expr); evaluate(v1, data1->SL, data1->NbSL, - v2, data2->SL, data2->NbSL, 2, 1, 0, tt, t2, expr); + v2, data2->SL, data2->NbSL, 2, 1, 0, tt, t2, expr); evaluate(v1, data1->ST, data1->NbST, - v2, data2->ST, data2->NbST, 3, 1, 0, tt, t2, expr); + v2, data2->ST, data2->NbST, 3, 1, 0, tt, t2, expr); evaluate(v1, data1->SQ, data1->NbSQ, - v2, data2->SQ, data2->NbSQ, 4, 1, 0, tt, t2, expr); + v2, data2->SQ, data2->NbSQ, 4, 1, 0, tt, t2, expr); evaluate(v1, data1->SS, data1->NbSS, - v2, data2->SS, data2->NbSS, 4, 1, 0, tt, t2, expr); + v2, data2->SS, data2->NbSS, 4, 1, 0, tt, t2, expr); evaluate(v1, data1->SH, data1->NbSH, - v2, data2->SH, data2->NbSH, 8, 1, 0, tt, t2, expr); + v2, data2->SH, data2->NbSH, 8, 1, 0, tt, t2, expr); evaluate(v1, data1->SI, data1->NbSI, - v2, data2->SI, data2->NbSI, 6, 1, 0, tt, t2, expr); + v2, data2->SI, data2->NbSI, 6, 1, 0, tt, t2, expr); evaluate(v1, data1->SY, data1->NbSY, - v2, data2->SY, data2->NbSY, 5, 1, 0, tt, t2, expr); + v2, data2->SY, data2->NbSY, 5, 1, 0, tt, t2, expr); for(int cc = 0; cc < 3; cc++){ - if(comp < 0 || comp == cc){ - evaluate(v1, data1->VP, data1->NbVP, - v2, data2->VP, data2->NbVP, 1, 3, cc, tt, t2, expr); - evaluate(v1, data1->VL, data1->NbVL, - v2, data2->VL, data2->NbVL, 2, 3, cc, tt, t2, expr); - evaluate(v1, data1->VT, data1->NbVT, - v2, data2->VT, data2->NbVT, 3, 3, cc, tt, t2, expr); - evaluate(v1, data1->VQ, data1->NbVQ, - v2, data2->VQ, data2->NbVQ, 4, 3, cc, tt, t2, expr); - evaluate(v1, data1->VS, data1->NbVS, - v2, data2->VS, data2->NbVS, 4, 3, cc, tt, t2, expr); - evaluate(v1, data1->VH, data1->NbVH, - v2, data2->VH, data2->NbVH, 8, 3, cc, tt, t2, expr); - evaluate(v1, data1->VI, data1->NbVI, - v2, data2->VI, data2->NbVI, 6, 3, cc, tt, t2, expr); - evaluate(v1, data1->VY, data1->NbVY, - v2, data2->VY, data2->NbVY, 5, 3, cc, tt, t2, expr); - } + if(comp < 0 || comp == cc){ + evaluate(v1, data1->VP, data1->NbVP, + v2, data2->VP, data2->NbVP, 1, 3, cc, tt, t2, expr); + evaluate(v1, data1->VL, data1->NbVL, + v2, data2->VL, data2->NbVL, 2, 3, cc, tt, t2, expr); + evaluate(v1, data1->VT, data1->NbVT, + v2, data2->VT, data2->NbVT, 3, 3, cc, tt, t2, expr); + evaluate(v1, data1->VQ, data1->NbVQ, + v2, data2->VQ, data2->NbVQ, 4, 3, cc, tt, t2, expr); + evaluate(v1, data1->VS, data1->NbVS, + v2, data2->VS, data2->NbVS, 4, 3, cc, tt, t2, expr); + evaluate(v1, data1->VH, data1->NbVH, + v2, data2->VH, data2->NbVH, 8, 3, cc, tt, t2, expr); + evaluate(v1, data1->VI, data1->NbVI, + v2, data2->VI, data2->NbVI, 6, 3, cc, tt, t2, expr); + evaluate(v1, data1->VY, data1->NbVY, + v2, data2->VY, data2->NbVY, 5, 3, cc, tt, t2, expr); + } } for(int cc = 0; cc < 9; cc++){ - if(comp < 0 || comp == cc){ - evaluate(v1, data1->TP, data1->NbTP, - v2, data2->TP, data2->NbTP, 1, 9, cc, tt, t2, expr); - evaluate(v1, data1->TL, data1->NbTL, - v2, data2->TL, data2->NbTL, 2, 9, cc, tt, t2, expr); - evaluate(v1, data1->TT, data1->NbTT, - v2, data2->TT, data2->NbTT, 3, 9, cc, tt, t2, expr); - evaluate(v1, data1->TQ, data1->NbTQ, - v2, data2->TQ, data2->NbTQ, 4, 9, cc, tt, t2, expr); - evaluate(v1, data1->TS, data1->NbTS, - v2, data2->TS, data2->NbTS, 4, 9, cc, tt, t2, expr); - evaluate(v1, data1->TH, data1->NbTH, - v2, data2->TH, data2->NbTH, 8, 9, cc, tt, t2, expr); - evaluate(v1, data1->TI, data1->NbTI, - v2, data2->TI, data2->NbTI, 6, 9, cc, tt, t2, expr); - evaluate(v1, data1->TY, data1->NbTY, - v2, data2->TY, data2->NbTY, 5, 9, cc, tt, t2, expr); - } + if(comp < 0 || comp == cc){ + evaluate(v1, data1->TP, data1->NbTP, + v2, data2->TP, data2->NbTP, 1, 9, cc, tt, t2, expr); + evaluate(v1, data1->TL, data1->NbTL, + v2, data2->TL, data2->NbTL, 2, 9, cc, tt, t2, expr); + evaluate(v1, data1->TT, data1->NbTT, + v2, data2->TT, data2->NbTT, 3, 9, cc, tt, t2, expr); + evaluate(v1, data1->TQ, data1->NbTQ, + v2, data2->TQ, data2->NbTQ, 4, 9, cc, tt, t2, expr); + evaluate(v1, data1->TS, data1->NbTS, + v2, data2->TS, data2->NbTS, 4, 9, cc, tt, t2, expr); + evaluate(v1, data1->TH, data1->NbTH, + v2, data2->TH, data2->NbTH, 8, 9, cc, tt, t2, expr); + evaluate(v1, data1->TI, data1->NbTI, + v2, data2->TI, data2->NbTI, 6, 9, cc, tt, t2, expr); + evaluate(v1, data1->TY, data1->NbTY, + v2, data2->TY, data2->NbTY, 5, 9, cc, tt, t2, expr); + } } } } diff --git a/Plugin/Evaluate.h b/Plugin/Evaluate.h index ebeffd16758b7b1f417f07ca8b2bbd4c3b600e71..7af020345048d0f7ae299e7f6b13619dcc963c5a 100644 --- a/Plugin/Evaluate.h +++ b/Plugin/Evaluate.h @@ -33,10 +33,10 @@ class GMSH_EvaluatePlugin : public GMSH_Post_Plugin private: OctreePost *_octree; void evaluate(PView *v1, List_T *list1, int nbElm1, - PView *v2, List_T *list2, int nbElm2, - int nbNod, int nbComp, int comp, - int timeStep, int timeStep2, - const char *expression); + PView *v2, List_T *list2, int nbElm2, + int nbNod, int nbComp, int comp, + int timeStep, int timeStep2, + const char *expression); public: GMSH_EvaluatePlugin(); void getName(char *name) const; diff --git a/Plugin/Extract.cpp b/Plugin/Extract.cpp index 838f474ac6726262ce505f267cb014349b2c8f60..25a4eb564edca8c2650308aa8419e3988183b249 100644 --- a/Plugin/Extract.cpp +++ b/Plugin/Extract.cpp @@ -1,4 +1,4 @@ -// $Id: Extract.cpp,v 1.26 2008-02-23 15:30:10 geuzaine Exp $ +// $Id: Extract.cpp,v 1.27 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -70,26 +70,26 @@ void GMSH_ExtractPlugin::getInfos(char *author, char *copyright, char *help_text strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Extract) extracts a combination of\n" - "components from the `TimeStep'th time step\n" - "in the view `iView'. If only `Expression0' is\n" - "given (and `Expression1', ..., `Expression8' are\n" - "all empty), the plugin creates a scalar view.\n" - "If `Expression0', `Expression1' and/or\n" - "`Expression2' are given (and `Expression3',\n" - "..., `Expression8' are all empty) the plugin\n" - "creates a vector view. Otherwise the plugin\n" - "creates a tensor view. In addition to the usual\n" - "mathematical functions (Exp, Log, Sqrt, Sin, Cos,\n" - "Fabs, etc.) and operators (+, -, *, /, ^), all\n" - "expressions can contain the symbols v0, v1, v2,\n" - " ..., vn, which represent the n components of the\n" - "field, and the symbols x, y and z, which represent\n" - "the three spatial coordinates. If `TimeStep' < 0,\n" - "the plugin extracts data from all the time steps\n" - "in the view. If `iView' < 0, the plugin is run on\n" - "the current view.\n" - "\n" - "Plugin(Extract) creates one new view.\n"); + "components from the `TimeStep'th time step\n" + "in the view `iView'. If only `Expression0' is\n" + "given (and `Expression1', ..., `Expression8' are\n" + "all empty), the plugin creates a scalar view.\n" + "If `Expression0', `Expression1' and/or\n" + "`Expression2' are given (and `Expression3',\n" + "..., `Expression8' are all empty) the plugin\n" + "creates a vector view. Otherwise the plugin\n" + "creates a tensor view. In addition to the usual\n" + "mathematical functions (Exp, Log, Sqrt, Sin, Cos,\n" + "Fabs, etc.) and operators (+, -, *, /, ^), all\n" + "expressions can contain the symbols v0, v1, v2,\n" + " ..., vn, which represent the n components of the\n" + "field, and the symbols x, y and z, which represent\n" + "the three spatial coordinates. If `TimeStep' < 0,\n" + "the plugin extracts data from all the time steps\n" + "in the view. If `iView' < 0, the plugin is run on\n" + "the current view.\n" + "\n" + "Plugin(Extract) creates one new view.\n"); } int GMSH_ExtractPlugin::getNbOptions() const @@ -118,10 +118,10 @@ void GMSH_ExtractPlugin::catchErrorMessage(char *errorMessage) const } static void extract(const char *expr[9], List_T *inList, int inNb, - List_T *outListScalar, int *outNbScalar, - List_T *outListVector, int *outNbVector, - List_T *outListTensor, int *outNbTensor, - int timeStep, int nbNod, int nbComp) + List_T *outListScalar, int *outNbScalar, + List_T *outListVector, int *outNbVector, + List_T *outListTensor, int *outNbTensor, + int timeStep, int nbNod, int nbComp) { if(!inNb) return; @@ -160,7 +160,7 @@ static void extract(const char *expr[9], List_T *inList, int inNb, if(!f[i]){ Msg(GERROR, "Invalid expression '%s'", expr[i]); for(int j = 0; j < i; j++) - if(f[j]) evaluator_destroy(f[j]); + if(f[j]) evaluator_destroy(f[j]); return; } } @@ -195,22 +195,22 @@ static void extract(const char *expr[9], List_T *inList, int inNb, List_Add(outList, List_Pointer_Fast(inList, i + j)); for(int j = timeBeg; j < timeEnd; j++){ for(int k = 0; k < nbNod; k++){ - double xx = x[k]; - double yy = y[k]; - double zz = z[k]; - double d[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}; - for(int l = 0; l < nbComp; l++) - List_Read(inList, i + 3 * nbNod + nbNod * nbComp * j + nbComp * k + l, &d[l]); - for(int l = 0; l < outNbComp; l++){ + double xx = x[k]; + double yy = y[k]; + double zz = z[k]; + double d[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}; + for(int l = 0; l < nbComp; l++) + List_Read(inList, i + 3 * nbNod + nbNod * nbComp * j + nbComp * k + l, &d[l]); + for(int l = 0; l < outNbComp; l++){ #if defined(HAVE_MATH_EVAL) - char *names[] = { "x", "y", "z", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8" }; - double values[] = { xx, yy, zz, d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8] }; - double res = evaluator_evaluate(f[l], sizeof(names)/sizeof(names[0]), names, values); + char *names[] = { "x", "y", "z", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8" }; + double values[] = { xx, yy, zz, d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8] }; + double res = evaluator_evaluate(f[l], sizeof(names)/sizeof(names[0]), names, values); #else - double res = d[comp[l]]; + double res = d[comp[l]]; #endif - List_Add(outList, &res); - } + List_Add(outList, &res); + } } } (*outNb)++; @@ -227,14 +227,14 @@ PView *GMSH_ExtractPlugin::execute(PView *v) int step = (int)ExtractOptions_Number[0].def; int iView = (int)ExtractOptions_Number[1].def; const char *expr[9] = { ExtractOptions_String[0].def, - ExtractOptions_String[1].def, - ExtractOptions_String[2].def, - ExtractOptions_String[3].def, - ExtractOptions_String[4].def, - ExtractOptions_String[5].def, - ExtractOptions_String[6].def, - ExtractOptions_String[7].def, - ExtractOptions_String[8].def }; + ExtractOptions_String[1].def, + ExtractOptions_String[2].def, + ExtractOptions_String[3].def, + ExtractOptions_String[4].def, + ExtractOptions_String[5].def, + ExtractOptions_String[6].def, + ExtractOptions_String[7].def, + ExtractOptions_String[8].def }; PView *v1 = getView(iView, v); if(!v1) return v; @@ -252,66 +252,66 @@ PView *GMSH_ExtractPlugin::execute(PView *v) } else if(step > data1->getNumTimeSteps() - 1){ Msg(GERROR, "Invalid time step (%d) in View[%d]: using all steps instead", - step, v1->getIndex()); + step, v1->getIndex()); step = - data1->getNumTimeSteps(); } // points extract(expr, data1->SP, data1->NbSP, data2->SP, &data2->NbSP, - data2->VP, &data2->NbVP, data2->TP, &data2->NbTP, step, 1, 1); + data2->VP, &data2->NbVP, data2->TP, &data2->NbTP, step, 1, 1); extract(expr, data1->VP, data1->NbVP, data2->SP, &data2->NbSP, - data2->VP, &data2->NbVP, data2->TP, &data2->NbTP, step, 1, 3); + data2->VP, &data2->NbVP, data2->TP, &data2->NbTP, step, 1, 3); extract(expr, data1->TP, data1->NbTP, data2->SP, &data2->NbSP, - data2->VP, &data2->NbVP, data2->TP, &data2->NbTP, step, 1, 9); - // lines + data2->VP, &data2->NbVP, data2->TP, &data2->NbTP, step, 1, 9); + // lines extract(expr, data1->SL, data1->NbSL, data2->SL, &data2->NbSL, - data2->VL, &data2->NbVL, data2->TL, &data2->NbTL, step, 2, 1); + data2->VL, &data2->NbVL, data2->TL, &data2->NbTL, step, 2, 1); extract(expr, data1->VL, data1->NbVL, data2->SL, &data2->NbSL, - data2->VL, &data2->NbVL, data2->TL, &data2->NbTL, step, 2, 3); + data2->VL, &data2->NbVL, data2->TL, &data2->NbTL, step, 2, 3); extract(expr, data1->TL, data1->NbTL, data2->SL, &data2->NbSL, - data2->VL, &data2->NbVL, data2->TL, &data2->NbTL, step, 2, 9); - // triangles + data2->VL, &data2->NbVL, data2->TL, &data2->NbTL, step, 2, 9); + // triangles extract(expr, data1->ST, data1->NbST, data2->ST, &data2->NbST, - data2->VT, &data2->NbVT, data2->TT, &data2->NbTT, step, 3, 1); + data2->VT, &data2->NbVT, data2->TT, &data2->NbTT, step, 3, 1); extract(expr, data1->VT, data1->NbVT, data2->ST, &data2->NbST, - data2->VT, &data2->NbVT, data2->TT, &data2->NbTT, step, 3, 3); + data2->VT, &data2->NbVT, data2->TT, &data2->NbTT, step, 3, 3); extract(expr, data1->TT, data1->NbTT, data2->ST, &data2->NbST, - data2->VT, &data2->NbVT, data2->TT, &data2->NbTT, step, 3, 9); - // quadrangles + data2->VT, &data2->NbVT, data2->TT, &data2->NbTT, step, 3, 9); + // quadrangles extract(expr, data1->SQ, data1->NbSQ, data2->SQ, &data2->NbSQ, - data2->VQ, &data2->NbVQ, data2->TQ, &data2->NbTQ, step, 4, 1); + data2->VQ, &data2->NbVQ, data2->TQ, &data2->NbTQ, step, 4, 1); extract(expr, data1->VQ, data1->NbVQ, data2->SQ, &data2->NbSQ, - data2->VQ, &data2->NbVQ, data2->TQ, &data2->NbTQ, step, 4, 3); + data2->VQ, &data2->NbVQ, data2->TQ, &data2->NbTQ, step, 4, 3); extract(expr, data1->TQ, data1->NbTQ, data2->SQ, &data2->NbSQ, - data2->VQ, &data2->NbVQ, data2->TQ, &data2->NbTQ, step, 4, 9); - // tets + data2->VQ, &data2->NbVQ, data2->TQ, &data2->NbTQ, step, 4, 9); + // tets extract(expr, data1->SS, data1->NbSS, data2->SS, &data2->NbSS, - data2->VS, &data2->NbVS, data2->TS, &data2->NbTS, step, 4, 1); + data2->VS, &data2->NbVS, data2->TS, &data2->NbTS, step, 4, 1); extract(expr, data1->VS, data1->NbVS, data2->SS, &data2->NbSS, - data2->VS, &data2->NbVS, data2->TS, &data2->NbTS, step, 4, 3); + data2->VS, &data2->NbVS, data2->TS, &data2->NbTS, step, 4, 3); extract(expr, data1->TS, data1->NbTS, data2->SS, &data2->NbSS, - data2->VS, &data2->NbVS, data2->TS, &data2->NbTS, step, 4, 9); - // hexas + data2->VS, &data2->NbVS, data2->TS, &data2->NbTS, step, 4, 9); + // hexas extract(expr, data1->SH, data1->NbSH, data2->SH, &data2->NbSH, - data2->VH, &data2->NbVH, data2->TH, &data2->NbTH, step, 8, 1); + data2->VH, &data2->NbVH, data2->TH, &data2->NbTH, step, 8, 1); extract(expr, data1->VH, data1->NbVH, data2->SH, &data2->NbSH, - data2->VH, &data2->NbVH, data2->TH, &data2->NbTH, step, 8, 3); + data2->VH, &data2->NbVH, data2->TH, &data2->NbTH, step, 8, 3); extract(expr, data1->TH, data1->NbTH, data2->SH, &data2->NbSH, - data2->VH, &data2->NbVH, data2->TH, &data2->NbTH, step, 8, 9); - // prisms + data2->VH, &data2->NbVH, data2->TH, &data2->NbTH, step, 8, 9); + // prisms extract(expr, data1->SI, data1->NbSI, data2->SI, &data2->NbSI, - data2->VI, &data2->NbVI, data2->TI, &data2->NbTI, step, 6, 1); + data2->VI, &data2->NbVI, data2->TI, &data2->NbTI, step, 6, 1); extract(expr, data1->VI, data1->NbVI, data2->SI, &data2->NbSI, - data2->VI, &data2->NbVI, data2->TI, &data2->NbTI, step, 6, 3); + data2->VI, &data2->NbVI, data2->TI, &data2->NbTI, step, 6, 3); extract(expr, data1->TI, data1->NbTI, data2->SI, &data2->NbSI, - data2->VI, &data2->NbVI, data2->TI, &data2->NbTI, step, 6, 9); - // pyramids + data2->VI, &data2->NbVI, data2->TI, &data2->NbTI, step, 6, 9); + // pyramids extract(expr, data1->SY, data1->NbSY, data2->SY, &data2->NbSY, - data2->VY, &data2->NbVY, data2->TY, &data2->NbTY, step, 5, 1); + data2->VY, &data2->NbVY, data2->TY, &data2->NbTY, step, 5, 1); extract(expr, data1->VY, data1->NbVY, data2->SY, &data2->NbSY, - data2->VY, &data2->NbVY, data2->TY, &data2->NbTY, step, 5, 3); + data2->VY, &data2->NbVY, data2->TY, &data2->NbTY, step, 5, 3); extract(expr, data1->TY, data1->NbTY, data2->SY, &data2->NbSY, - data2->VY, &data2->NbVY, data2->TY, &data2->NbTY, step, 5, 9); + data2->VY, &data2->NbVY, data2->TY, &data2->NbTY, step, 5, 9); if(step < 0) for(int i = 0; i < List_Nbr(data1->Time); i++) diff --git a/Plugin/ExtractEdges.cpp b/Plugin/ExtractEdges.cpp index b163a64915c92eb4a4a43382d9c714b65fbaa4ed..306ddee0f1027d0e7ab307800cb0cb98d094b6a8 100644 --- a/Plugin/ExtractEdges.cpp +++ b/Plugin/ExtractEdges.cpp @@ -1,4 +1,4 @@ -// $Id: ExtractEdges.cpp,v 1.8 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: ExtractEdges.cpp,v 1.9 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -51,11 +51,11 @@ void GMSH_ExtractEdgesPlugin::getInfos(char *author, char *copyright, char *help strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(ExtractEdges) extracts the geometry edges\n" - "from the surface view `iView', using `Angle' as\n" - "the dihedral angle tolerance. If `iView' < 0, then\n" - "plugin is run on the current view.\n" - "\n" - "Plugin(ExtractEdges) creates one new view.\n"); + "from the surface view `iView', using `Angle' as\n" + "the dihedral angle tolerance. If `iView' < 0, then\n" + "plugin is run on the current view.\n" + "\n" + "Plugin(ExtractEdges) creates one new view.\n"); } int GMSH_ExtractEdgesPlugin::getNbOptions() const diff --git a/Plugin/ExtractElements.cpp b/Plugin/ExtractElements.cpp index e219ec88ee4aaf37b7d305cf73c8bd1c0ae5ba94..efa5985402154b3c251b4dc489771ecc2aa2afc8 100644 --- a/Plugin/ExtractElements.cpp +++ b/Plugin/ExtractElements.cpp @@ -1,4 +1,4 @@ -// $Id: ExtractElements.cpp,v 1.11 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: ExtractElements.cpp,v 1.12 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -53,12 +53,12 @@ void GMSH_ExtractElementsPlugin::getInfos(char *author, char *copyright, char *h strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(ExtractElements) extracts the elements\n" - "from the view `iView' whose `TimeStep'-th values\n" - "(averaged by element) are comprised between\n" - "`MinVal' and `MaxVal'. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(ExtractElements) creates one new view.\n"); + "from the view `iView' whose `TimeStep'-th values\n" + "(averaged by element) are comprised between\n" + "`MinVal' and `MaxVal'. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(ExtractElements) creates one new view.\n"); } int GMSH_ExtractElementsPlugin::getNbOptions() const @@ -77,8 +77,8 @@ void GMSH_ExtractElementsPlugin::catchErrorMessage(char *errorMessage) const } static void extract(List_T *inList, int inNb, - List_T *outList, int *outNb, - int timeStep, int nbNod, int nbComp) + List_T *outList, int *outNb, + int timeStep, int nbNod, int nbComp) { if(!inNb) return; @@ -89,20 +89,20 @@ static void extract(List_T *inList, int inNb, int nb = List_Nbr(inList) / inNb; for(int i = 0; i < List_Nbr(inList); i += nb) { double *vals = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + - timeStep * nbNod * nbComp); + timeStep * nbNod * nbComp); double d = 0.; for(int k = 0; k < nbNod; k++) { double *v = &vals[nbComp * k]; switch(nbComp) { case 1: // scalar - d += v[0]; - break; + d += v[0]; + break; case 3 : // vector - d += sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2])); - break; + d += sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2])); + break; case 9 : // tensor - d += ComputeVonMises(v); - break; + d += ComputeVonMises(v); + break; } } d /= (double)nbNod; @@ -110,7 +110,7 @@ static void extract(List_T *inList, int inNb, // worrying about roundoff errors if(d >= MinVal && d < MaxVal){ for(int j = 0; j < nb; j++) - List_Add(outList, List_Pointer_Fast(inList, i + j)); + List_Add(outList, List_Pointer_Fast(inList, i + j)); (*outNb)++; } } @@ -134,7 +134,7 @@ PView *GMSH_ExtractElementsPlugin::execute(PView *v) if(step < 0 || step > data1->getNumTimeSteps() - 1){ Msg(GERROR, "Invalid time step (%d) in View[%d]: using first step instead", - step, v1->getIndex()); + step, v1->getIndex()); step = 0; } @@ -142,31 +142,31 @@ PView *GMSH_ExtractElementsPlugin::execute(PView *v) extract(data1->SP, data1->NbSP, data2->SP, &data2->NbSP, step, 1, 1); extract(data1->VP, data1->NbVP, data2->VP, &data2->NbVP, step, 1, 3); extract(data1->TP, data1->NbTP, data2->TP, &data2->NbTP, step, 1, 9); - // lines + // lines extract(data1->SL, data1->NbSL, data2->SL, &data2->NbSL, step, 2, 1); extract(data1->VL, data1->NbVL, data2->VL, &data2->NbVL, step, 2, 3); extract(data1->TL, data1->NbTL, data2->TL, &data2->NbTL, step, 2, 9); - // triangles + // triangles extract(data1->ST, data1->NbST, data2->ST, &data2->NbST, step, 3, 1); extract(data1->VT, data1->NbVT, data2->VT, &data2->NbVT, step, 3, 3); extract(data1->TT, data1->NbTT, data2->TT, &data2->NbTT, step, 3, 9); - // quadrangles + // quadrangles extract(data1->SQ, data1->NbSQ, data2->SQ, &data2->NbSQ, step, 4, 1); extract(data1->VQ, data1->NbVQ, data2->VQ, &data2->NbVQ, step, 4, 3); extract(data1->TQ, data1->NbTQ, data2->TQ, &data2->NbTQ, step, 4, 9); - // tets + // tets extract(data1->SS, data1->NbSS, data2->SS, &data2->NbSS, step, 4, 1); extract(data1->VS, data1->NbVS, data2->VS, &data2->NbVS, step, 4, 3); extract(data1->TS, data1->NbTS, data2->TS, &data2->NbTS, step, 4, 9); - // hexas + // hexas extract(data1->SH, data1->NbSH, data2->SH, &data2->NbSH, step, 8, 1); extract(data1->VH, data1->NbVH, data2->VH, &data2->NbVH, step, 8, 3); extract(data1->TH, data1->NbTH, data2->TH, &data2->NbTH, step, 8, 9); - // prisms + // prisms extract(data1->SI, data1->NbSI, data2->SI, &data2->NbSI, step, 6, 1); extract(data1->VI, data1->NbVI, data2->VI, &data2->NbVI, step, 6, 3); extract(data1->TI, data1->NbTI, data2->TI, &data2->NbTI, step, 6, 9); - // pyramids + // pyramids extract(data1->SY, data1->NbSY, data2->SY, &data2->NbSY, step, 5, 1); extract(data1->VY, data1->NbVY, data2->VY, &data2->NbVY, step, 5, 3); extract(data1->TY, data1->NbTY, data2->TY, &data2->NbTY, step, 5, 9); diff --git a/Plugin/FieldView.cpp b/Plugin/FieldView.cpp index b607568aa3e0c80b730901c410fcba5f8d1e3ab2..73e37c35ea8fd65ac67f3a9e5c83b242b341b769 100644 --- a/Plugin/FieldView.cpp +++ b/Plugin/FieldView.cpp @@ -1,4 +1,4 @@ -// $Id: FieldView.cpp,v 1.7 2008-03-19 17:26:54 geuzaine Exp $ +// $Id: FieldView.cpp,v 1.8 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -43,12 +43,12 @@ void GMSH_FieldViewPlugin::getName(char *name) const } void GMSH_FieldViewPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "J. Lambrechts (jonathanlambrechts@gmail.org)"); strcpy(copyright, "GPL"); strcpy(help_text, - "Plugin(FieldView) evaluate a field on the choosen view.\n"); + "Plugin(FieldView) evaluate a field on the choosen view.\n"); } int GMSH_FieldViewPlugin::getNbOptions() const @@ -78,6 +78,6 @@ PView *GMSH_FieldViewPlugin::execute(PView *v) } PView *v1 = getView(iView, v); if(!v1) return v; - field->put_on_view(v1); + field->put_on_view(v1); return v1; } diff --git a/Plugin/GSHHS.cpp b/Plugin/GSHHS.cpp index 26d9766ad1fd921a4cee3749501c300ee8bbc527..7d0b5e41275757f323ba09253a602d1b15e289e0 100644 --- a/Plugin/GSHHS.cpp +++ b/Plugin/GSHHS.cpp @@ -1,4 +1,4 @@ -// $Id: GSHHS.cpp,v 1.3 2008-03-20 10:21:15 remacle Exp $ +// $Id: GSHHS.cpp,v 1.4 2008-03-20 11:44:13 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -30,34 +30,34 @@ extern Context_T CTX; // ************** GSHHS ************** -/* $Id: GSHHS.cpp,v 1.3 2008-03-20 10:21:15 remacle Exp $ +/* $Id: GSHHS.cpp,v 1.4 2008-03-20 11:44:13 geuzaine Exp $ * - * PROGRAM: gshhs.c - * AUTHOR: Paul Wessel (pwessel@hawaii.edu) - * CREATED: JAN. 28, 1996 - * PURPOSE: To extract ASCII data from binary shoreline data - * as described in the 1996 Wessel & Smith JGR Data Analysis Note. - * VERSION: 1.1 (Byte flipping added) - * 1.2 18-MAY-1999: - * Explicit binary open for DOS systems - * POSIX.1 compliant - * 1.3 08-NOV-1999: Released under GNU GPL - * 1.4 05-SEPT-2000: Made a GMT supplement; FLIP no longer needed - * 1.5 14-SEPT-2004: Updated to deal with latest GSHHS database (1.3) + * PROGRAM: gshhs.c + * AUTHOR: Paul Wessel (pwessel@hawaii.edu) + * CREATED: JAN. 28, 1996 + * PURPOSE: To extract ASCII data from binary shoreline data + * as described in the 1996 Wessel & Smith JGR Data Analysis Note. + * VERSION: 1.1 (Byte flipping added) + * 1.2 18-MAY-1999: + * Explicit binary open for DOS systems + * POSIX.1 compliant + * 1.3 08-NOV-1999: Released under GNU GPL + * 1.4 05-SEPT-2000: Made a GMT supplement; FLIP no longer needed + * 1.5 14-SEPT-2004: Updated to deal with latest GSHHS database (1.3) * - * Copyright (c) 1996-2004 by P. Wessel and W. H. F. Smith - * See COPYING file for copying and redistribution conditions. + * Copyright (c) 1996-2004 by P. Wessel and W. H. F. Smith + * See COPYING file for copying and redistribution conditions. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Contact info: www.soest.hawaii.edu/pwessel */ + * Contact info: www.soest.hawaii.edu/pwessel */ /* For byte swapping on little-endian systems (GSHHS is bigendian) */ #define swabi2(i2) (((i2) >> 8) + (((i2) & 255) << 8)) #define swabi4(i4) (((i4) >> 24) + (((i4) >> 8) & 65280) + (((i4) & 65280) << 8) + (((i4) & 255) << 24)) diff --git a/Plugin/GeoEarthImport.cpp b/Plugin/GeoEarthImport.cpp index dde759acf04b6035478cb9ccadfe0bf9f970a2fb..b43b89fd2f6d365e3a7509e02b43a46d3fc866b6 100644 --- a/Plugin/GeoEarthImport.cpp +++ b/Plugin/GeoEarthImport.cpp @@ -99,19 +99,19 @@ void GeoEarthImport::end_surface() } /*static void projectLatLon(Point3D &psphere,Point &pplan){ - pplan.x=asin(psphere.z); - pplan.y=atan2(psphere.y,psphere.x); - pplan.zone_id=psphere.zone_id; + pplan.x=asin(psphere.z); + pplan.y=atan2(psphere.y,psphere.x); + pplan.zone_id=psphere.zone_id; } static void projectInvStereo(Point &pplan,Point3D &psphere){ - double rp2=pplan.x*pplan.x+pplan.y*pplan.y; - psphere.z= (4-rp2)/(4+rp2); - psphere.x= (1+psphere.z)/2*pplan.x; - psphere.y= (1+psphere.z)/2*pplan.y; - psphere.zone_id=pplan.zone_id; + double rp2=pplan.x*pplan.x+pplan.y*pplan.y; + psphere.z= (4-rp2)/(4+rp2); + psphere.x= (1+psphere.z)/2*pplan.x; + psphere.y= (1+psphere.z)/2*pplan.y; + psphere.zone_id=pplan.zone_id; } static void projectStereo(Point3D &psphere,Point &pplan){ - pplan.x=2*psphere.x/(psphere.z+1); - pplan.y=2*psphere.y/(psphere.z+1); - pplan.zone_id=psphere.zone_id; + pplan.x=2*psphere.x/(psphere.z+1); + pplan.y=2*psphere.y/(psphere.z+1); + pplan.zone_id=psphere.zone_id; }*/ diff --git a/Plugin/Gradient.cpp b/Plugin/Gradient.cpp index 271438523be030729544f47d3bd84c90bd16f75e..9ec9bf4205cd4098fbffb91990a7b0842845494a 100644 --- a/Plugin/Gradient.cpp +++ b/Plugin/Gradient.cpp @@ -1,4 +1,4 @@ -// $Id: Gradient.cpp,v 1.11 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: Gradient.cpp,v 1.12 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,16 +45,16 @@ void GMSH_GradientPlugin::getName(char *name) const } void GMSH_GradientPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, - "Plugin(Gradient) computes the gradient of the\n" - "field in the view `iView'. If `iView' < 0, the\n" - "plugin is run on the current view.\n" - "\n" - "Plugin(Gradient) creates one new view.\n"); + "Plugin(Gradient) computes the gradient of the\n" + "field in the view `iView'. If `iView' < 0, the\n" + "plugin is run on the current view.\n" + "\n" + "Plugin(Gradient) creates one new view.\n"); } int GMSH_GradientPlugin::getNbOptions() const @@ -73,7 +73,7 @@ void GMSH_GradientPlugin::catchErrorMessage(char *errorMessage) const } static void gradient(int inNb, List_T *inList, int *outNb, List_T *outList, - int dim, int nbNod, int nbComp, int nbTime) + int dim, int nbNod, int nbComp, int nbTime) { if(!inNb) return; @@ -90,14 +90,14 @@ static void gradient(int inNb, List_T *inList, int *outNb, List_T *outList, for(int j = 0; j < nbTime; j++){ double *val = (double *)List_Pointer(inList, i + 3 * nbNod + nbNod * nbComp * j); for(int k = 0; k < nbNod; k++){ - double u, v, w, f[3]; - element->getNode(k, u, v, w); - for(int l = 0; l < nbComp; l++){ - element->interpolateGrad(val+l, u, v, w, f, nbComp); - List_Add(outList, &f[0]); - List_Add(outList, &f[1]); - List_Add(outList, &f[2]); - } + double u, v, w, f[3]; + element->getNode(k, u, v, w); + for(int l = 0; l < nbComp; l++){ + element->interpolateGrad(val+l, u, v, w, f, nbComp); + List_Add(outList, &f[0]); + List_Add(outList, &f[1]); + List_Add(outList, &f[2]); + } } } delete element; diff --git a/Plugin/HarmonicToTime.cpp b/Plugin/HarmonicToTime.cpp index c584cc410ea2a48ad5ccface075e3b8fd6bfb30c..c374451bfb21f818127d24cc6c18f2280c7d4f58 100644 --- a/Plugin/HarmonicToTime.cpp +++ b/Plugin/HarmonicToTime.cpp @@ -1,4 +1,4 @@ -// $Id: HarmonicToTime.cpp,v 1.15 2008-02-17 08:48:06 geuzaine Exp $ +// $Id: HarmonicToTime.cpp,v 1.16 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -54,15 +54,15 @@ void GMSH_HarmonicToTimePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(HarmonicToTime) takes the values in the\n" - "time steps `RealPart' and `ImaginaryPart' of\n" + "time steps `RealPart' and `ImaginaryPart' of\n" "the view `iView', and creates a new view\n" "containing (`iView'[`RealPart'] * cos(p) -\n" "`iView'[`ImaginaryPart'] * sin(p)), with\n" "p = 2*Pi*k/`nSteps', k = 0, ..., `nSteps'-1.\n" - "If `iView' < 0, the plugin is run on the\n" - "current view.\n" - "\n" - "Plugin(HarmonicToTime) creates one new view.\n"); + "If `iView' < 0, the plugin is run on the\n" + "current view.\n" + "\n" + "Plugin(HarmonicToTime) creates one new view.\n"); } int GMSH_HarmonicToTimePlugin::getNbOptions() const @@ -82,7 +82,7 @@ void GMSH_HarmonicToTimePlugin::catchErrorMessage(char *errorMessage) const static void h2t(int nb1, List_T *list1, int *nb2, List_T *list2, - int nbNod, int nbComp, int rIndex, int iIndex, int nSteps) + int nbNod, int nbComp, int rIndex, int iIndex, int nSteps) { if(!nb1) return; @@ -91,16 +91,16 @@ static void h2t(int nb1, List_T *list1, int *nb2, List_T *list2, for(int j = 0; j < 3 * nbNod; j++) List_Add(list2, List_Pointer_Fast(list1, i + j)); double *valr = (double *)List_Pointer_Fast(list1, i + 3 * nbNod + - nbNod * nbComp * rIndex); + nbNod * nbComp * rIndex); double *vali = (double *)List_Pointer_Fast(list1, i + 3 * nbNod + - nbNod * nbComp * iIndex); + nbNod * nbComp * iIndex); for(int t = 0; t < nSteps; t++) { double p = 2. * M_PI * t / nSteps; for(int j = 0; j < nbNod; j++) { - for(int k = 0; k < nbComp; k++) { - double val = valr[nbComp * j + k] * cos(p) - vali[nbComp * j + k] * sin(p); - List_Add(list2, &val); - } + for(int k = 0; k < nbComp; k++) { + double val = valr[nbComp * j + k] * cos(p) - vali[nbComp * j + k] * sin(p); + List_Add(list2, &val); + } } } } diff --git a/Plugin/Integrate.cpp b/Plugin/Integrate.cpp index aa65203cb03b9db9c083c4e02ff77d91b6eabeae..7a7ead93be12f775513ef7b2fadd03a4fea84f3c 100644 --- a/Plugin/Integrate.cpp +++ b/Plugin/Integrate.cpp @@ -1,4 +1,4 @@ -// $Id: Integrate.cpp,v 1.23 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: Integrate.cpp,v 1.24 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -45,18 +45,18 @@ void GMSH_IntegratePlugin::getName(char *name) const } void GMSH_IntegratePlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, - "Plugin(Integrate) integrates scalar fields over\n" - "all the elements in the view `iView', as well\n" - "as the circulation/flux of vector fields over\n" - "line/surface elements. If `iView' < 0, the\n" - "plugin is run on the current view.\n" - "\n" - "Plugin(Integrate) creates one new view.\n"); + "Plugin(Integrate) integrates scalar fields over\n" + "all the elements in the view `iView', as well\n" + "as the circulation/flux of vector fields over\n" + "line/surface elements. If `iView' < 0, the\n" + "plugin is run on the current view.\n" + "\n" + "Plugin(Integrate) creates one new view.\n"); } int GMSH_IntegratePlugin::getNbOptions() const @@ -75,7 +75,7 @@ void GMSH_IntegratePlugin::catchErrorMessage(char *errorMessage) const } static double integrate(int nbList, List_T *list, int dim, - int nbNod, int nbComp, int step) + int nbNod, int nbComp, int step) { if(!nbList) return 0.; @@ -86,7 +86,7 @@ static double integrate(int nbList, List_T *list, int dim, double *y = (double *)List_Pointer_Fast(list, i + nbNod); double *z = (double *)List_Pointer_Fast(list, i + 2 * nbNod); double *v = (double *)List_Pointer_Fast(list, i + 3 * nbNod + - nbNod * nbComp * step); + nbNod * nbComp * step); elementFactory factory; element *element = factory.create(nbNod, dim, x, y, z); if(!element) return 0.; @@ -95,9 +95,9 @@ static double integrate(int nbList, List_T *list, int dim, } else if(nbComp == 3){ if(dim == 1) - res += element->integrateCirculation(v); + res += element->integrateCirculation(v); else if(dim == 2) - res += element->integrateFlux(v); + res += element->integrateFlux(v); } delete element; } diff --git a/Plugin/Lambda2.cpp b/Plugin/Lambda2.cpp index eab09ed04323dd857dd38278434f0612b5cc5fa4..5042f0fce88af43438a7a37343c7c76d67cf5562 100644 --- a/Plugin/Lambda2.cpp +++ b/Plugin/Lambda2.cpp @@ -1,4 +1,4 @@ -// $Id: Lambda2.cpp,v 1.13 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: Lambda2.cpp,v 1.14 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -46,27 +46,27 @@ void GMSH_Lambda2Plugin::getName(char *name) const } void GMSH_Lambda2Plugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "E. Marchandise"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Lambda2) computes the eigenvalues\n" - "Lambda(1,2,3) of the tensor (S_ik S_kj +\n" - "Om_ik Om_kj), where S_ij = 0.5 (ui,j + uj,i)\n" - "and Om_ij = 0.5 (ui,j - uj,i) are respectively\n" - "the symmetric and antisymmetric parts of the\n" - "velocity gradient tensor. Vortices are well\n" - "represented by regions where Lambda(2) is\n" - "negative. If `iView' contains tensor elements,\n" - "the plugin directly uses the tensors as the\n" - "values of the velocity gradient tensor; if\n" - "`iView' contains vector elements, the plugin\n" - "uses them as the velocities from which to derive\n" - "the velocity gradient tensor. If `iView' < 0,\n" - "the plugin is run on the current view.\n" - "\n" - "Plugin(Lambda2) creates one new view.\n"); + "Lambda(1,2,3) of the tensor (S_ik S_kj +\n" + "Om_ik Om_kj), where S_ij = 0.5 (ui,j + uj,i)\n" + "and Om_ij = 0.5 (ui,j - uj,i) are respectively\n" + "the symmetric and antisymmetric parts of the\n" + "velocity gradient tensor. Vortices are well\n" + "represented by regions where Lambda(2) is\n" + "negative. If `iView' contains tensor elements,\n" + "the plugin directly uses the tensors as the\n" + "values of the velocity gradient tensor; if\n" + "`iView' contains vector elements, the plugin\n" + "uses them as the velocities from which to derive\n" + "the velocity gradient tensor. If `iView' < 0,\n" + "the plugin is run on the current view.\n" + "\n" + "Plugin(Lambda2) creates one new view.\n"); } int GMSH_Lambda2Plugin::getNbOptions() const @@ -108,8 +108,8 @@ static int inv3x3tran(double mat[3][3], double inv[3][3], double *det) } static void eigen(List_T *inList, int inNb, - List_T *outList, int *outNb, - int nbTime, int nbNod, int nbComp, int lam) + List_T *outList, int *outNb, + int nbTime, int nbNod, int nbComp, int lam) { if(!inNb || (nbComp != 3 && nbComp != 9) || lam < 1 || lam > 3) return; @@ -136,104 +136,104 @@ static void eigen(List_T *inList, int inNb, double GradVel[3][3]; if(nbComp == 9){ - // val is the velocity gradient tensor: we assume that it is - // constant per element - double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + - nbNod * nbComp * j + nbComp * 0); - GradVel[0][0] = v[0]; GradVel[0][1] = v[1]; GradVel[0][2] = v[2]; - GradVel[1][0] = v[3]; GradVel[1][1] = v[4]; GradVel[1][2] = v[5]; - GradVel[2][0] = v[6]; GradVel[2][1] = v[7]; GradVel[2][2] = v[8]; + // val is the velocity gradient tensor: we assume that it is + // constant per element + double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + + nbNod * nbComp * j + nbComp * 0); + GradVel[0][0] = v[0]; GradVel[0][1] = v[1]; GradVel[0][2] = v[2]; + GradVel[1][0] = v[3]; GradVel[1][1] = v[4]; GradVel[1][2] = v[5]; + GradVel[2][0] = v[6]; GradVel[2][1] = v[7]; GradVel[2][2] = v[8]; } else if(nbComp == 3){ - // FIXME: the following could be greatly simplified and - // generalized by using the classes in ShapeFunctions.h + // FIXME: the following could be greatly simplified and + // generalized by using the classes in ShapeFunctions.h - // val contains the velocities: compute the gradient tensor - // from them - const int MAX_NOD = 4; - double val[3][MAX_NOD]; - for(int k = 0; k < nbNod; k++){ - double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + - nbNod * nbComp * j + nbComp * k); - for(int l = 0; l < 3; l++){ - val[l][k] = v[l]; - } - } - // compute gradient of shape functions - double GradPhi_x[MAX_NOD][3]; - double GradPhi_ksi[MAX_NOD][3]; - double dx_dksi[3][3]; - double dksi_dx[3][3]; - double det; - if(nbNod == 3){ // triangles - double a[3], b[3], cross[3]; - a[0]= x[1]-x[0]; a[1]= y[1]-y[0]; a[2]= z[1]-z[0]; - b[0]= x[2]-x[0]; b[1]= y[2]-y[0]; b[2]= z[2]-z[0]; - prodve(a, b, cross); - dx_dksi[0][0] = x[1] - x[0]; dx_dksi[0][1] = x[2]-x[0]; dx_dksi[0][2] = cross[0]; - dx_dksi[1][0] = y[1] - y[0]; dx_dksi[1][1] = y[2]-y[0]; dx_dksi[1][2] = cross[1]; - dx_dksi[2][0] = z[1] - z[0]; dx_dksi[2][1] = z[2]-z[0]; dx_dksi[2][2] = cross[2]; - inv3x3tran(dx_dksi, dksi_dx, &det); - GradPhi_ksi[0][0]= -1; GradPhi_ksi[0][1]= -1; GradPhi_ksi[0][2]= 0; - GradPhi_ksi[1][0]= 1; GradPhi_ksi[1][1]= 0; GradPhi_ksi[1][2]= 0; - GradPhi_ksi[2][0]= 0; GradPhi_ksi[2][1]= 1; GradPhi_ksi[2][2]= 0; - } - else if (nbNod == 4){ // tetrahedra - dx_dksi[0][0] = x[1] - x[0]; dx_dksi[0][1] = x[2]-x[0]; dx_dksi[0][2] = x[3]-x[0]; - dx_dksi[1][0] = y[1] - y[0]; dx_dksi[1][1] = y[2]-y[0]; dx_dksi[1][2] = y[3]-y[0]; - dx_dksi[2][0] = z[1] - z[0]; dx_dksi[2][1] = z[2]-z[0]; dx_dksi[2][2] = z[3]-z[0]; - inv3x3tran(dx_dksi, dksi_dx, &det); - GradPhi_ksi[0][0]= -1; GradPhi_ksi[0][1]= -1; GradPhi_ksi[0][2]= -1; - GradPhi_ksi[1][0]= 1; GradPhi_ksi[1][1]= 0; GradPhi_ksi[1][2]= 0; - GradPhi_ksi[2][0]= 0; GradPhi_ksi[2][1]= 1; GradPhi_ksi[2][2]= 0; - GradPhi_ksi[3][0]= 0; GradPhi_ksi[3][1]= 0; GradPhi_ksi[3][2]= 1; - } - else{ - Msg(GERROR, "Lambda2 not ready for this type of element"); - return; - } - for(int k = 0; k < nbNod ; k++){ - for(int l = 0; l < 3; l++){ - GradPhi_x[k][l] = 0.0; - for(int m = 0; m < 3; m++){ - GradPhi_x[k][l] += GradPhi_ksi[k][m] * dksi_dx[l][m]; - } - } - } - // compute gradient of velocities - for(int k = 0; k < 3; k++){ - for(int l = 0; l < 3; l++){ - GradVel[k][l] = 0.0; - for(int m = 0; m < nbNod; m++){ - GradVel[k][l] += val[k][m]* GradPhi_x[m][l]; - } - } - } + // val contains the velocities: compute the gradient tensor + // from them + const int MAX_NOD = 4; + double val[3][MAX_NOD]; + for(int k = 0; k < nbNod; k++){ + double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + + nbNod * nbComp * j + nbComp * k); + for(int l = 0; l < 3; l++){ + val[l][k] = v[l]; + } + } + // compute gradient of shape functions + double GradPhi_x[MAX_NOD][3]; + double GradPhi_ksi[MAX_NOD][3]; + double dx_dksi[3][3]; + double dksi_dx[3][3]; + double det; + if(nbNod == 3){ // triangles + double a[3], b[3], cross[3]; + a[0]= x[1]-x[0]; a[1]= y[1]-y[0]; a[2]= z[1]-z[0]; + b[0]= x[2]-x[0]; b[1]= y[2]-y[0]; b[2]= z[2]-z[0]; + prodve(a, b, cross); + dx_dksi[0][0] = x[1] - x[0]; dx_dksi[0][1] = x[2]-x[0]; dx_dksi[0][2] = cross[0]; + dx_dksi[1][0] = y[1] - y[0]; dx_dksi[1][1] = y[2]-y[0]; dx_dksi[1][2] = cross[1]; + dx_dksi[2][0] = z[1] - z[0]; dx_dksi[2][1] = z[2]-z[0]; dx_dksi[2][2] = cross[2]; + inv3x3tran(dx_dksi, dksi_dx, &det); + GradPhi_ksi[0][0]= -1; GradPhi_ksi[0][1]= -1; GradPhi_ksi[0][2]= 0; + GradPhi_ksi[1][0]= 1; GradPhi_ksi[1][1]= 0; GradPhi_ksi[1][2]= 0; + GradPhi_ksi[2][0]= 0; GradPhi_ksi[2][1]= 1; GradPhi_ksi[2][2]= 0; + } + else if (nbNod == 4){ // tetrahedra + dx_dksi[0][0] = x[1] - x[0]; dx_dksi[0][1] = x[2]-x[0]; dx_dksi[0][2] = x[3]-x[0]; + dx_dksi[1][0] = y[1] - y[0]; dx_dksi[1][1] = y[2]-y[0]; dx_dksi[1][2] = y[3]-y[0]; + dx_dksi[2][0] = z[1] - z[0]; dx_dksi[2][1] = z[2]-z[0]; dx_dksi[2][2] = z[3]-z[0]; + inv3x3tran(dx_dksi, dksi_dx, &det); + GradPhi_ksi[0][0]= -1; GradPhi_ksi[0][1]= -1; GradPhi_ksi[0][2]= -1; + GradPhi_ksi[1][0]= 1; GradPhi_ksi[1][1]= 0; GradPhi_ksi[1][2]= 0; + GradPhi_ksi[2][0]= 0; GradPhi_ksi[2][1]= 1; GradPhi_ksi[2][2]= 0; + GradPhi_ksi[3][0]= 0; GradPhi_ksi[3][1]= 0; GradPhi_ksi[3][2]= 1; + } + else{ + Msg(GERROR, "Lambda2 not ready for this type of element"); + return; + } + for(int k = 0; k < nbNod ; k++){ + for(int l = 0; l < 3; l++){ + GradPhi_x[k][l] = 0.0; + for(int m = 0; m < 3; m++){ + GradPhi_x[k][l] += GradPhi_ksi[k][m] * dksi_dx[l][m]; + } + } + } + // compute gradient of velocities + for(int k = 0; k < 3; k++){ + for(int l = 0; l < 3; l++){ + GradVel[k][l] = 0.0; + for(int m = 0; m < nbNod; m++){ + GradVel[k][l] += val[k][m]* GradPhi_x[m][l]; + } + } + } } - + // compute the sym and antisymetric parts double sym[3][3]; double asym[3][3]; for(int m = 0; m < 3; m++){ - for(int n = 0; n < 3; n++){ - sym[m][n] = 0.5 * (GradVel[m][n] + GradVel[n][m]); - asym[m][n] = 0.5 * (GradVel[m][n] - GradVel[n][m]); - } + for(int n = 0; n < 3; n++){ + sym[m][n] = 0.5 * (GradVel[m][n] + GradVel[n][m]); + asym[m][n] = 0.5 * (GradVel[m][n] - GradVel[n][m]); + } } double a[3][3]; for(int m = 0; m < 3; m++){ - for(int n = 0; n < 3; n++){ - a[m][n] = 0.0; - for(int l = 0; l < 3; l++) - a[m][n] += sym[m][l] * sym[l][n] + asym[m][l] * asym[l][n]; - } + for(int n = 0; n < 3; n++){ + a[m][n] = 0.0; + for(int l = 0; l < 3; l++) + a[m][n] += sym[m][l] * sym[l][n] + asym[m][l] * asym[l][n]; + } } // compute the eigenvalues double lambda[3]; eigenvalue(a, lambda); for(int k = 0; k < nbNod; k++) - List_Add(outList, &lambda[lam-1]); + List_Add(outList, &lambda[lam-1]); } (*outNb)++; diff --git a/Plugin/Levelset.cpp b/Plugin/Levelset.cpp index 19c0f406f8a2b10147f037a6af6a5bc2dbb0070e..d9e0671256d2846c9f6a269cd28276a4ea82c28e 100644 --- a/Plugin/Levelset.cpp +++ b/Plugin/Levelset.cpp @@ -1,4 +1,4 @@ -// $Id: Levelset.cpp,v 1.42 2008-03-19 20:06:17 geuzaine Exp $ +// $Id: Levelset.cpp,v 1.43 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -52,12 +52,12 @@ static int numSimplexDec(int numEdges) } static void getSimplexDec(int numNodes, int numEdges, int i, - int &n0, int &n1, int &n2, int &n3, - int &nn, int &ne) + int &n0, int &n1, int &n2, int &n3, + int &nn, int &ne) { static const int qua[2][3] = {{0,1,2}, {0,2,3}}; static const int hex[6][4] = {{0,1,3,7}, {0,4,1,7}, {1,4,5,7}, - {1,2,3,7}, {1,6,2,7}, {1,5,6,7}}; + {1,2,3,7}, {1,6,2,7}, {1,5,6,7}}; static const int pri[3][4] = {{0,1,2,4}, {0,2,4,5}, {0,3,4,5}}; static const int pyr[2][4] = {{0,1,3,4}, {1,2,3,4}}; switch(numEdges){ @@ -80,9 +80,9 @@ static void getSimplexDec(int numNodes, int numEdges, int i, } static void affect(double *xpi, double *ypi, double *zpi, - double valpi[12][9], int epi[12], int i, - double *xp, double *yp, double *zp, - double valp[12][9], int ep[12], int j, int nb) + double valpi[12][9], int epi[12], int i, + double *xp, double *yp, double *zp, + double valp[12][9], int ep[12], int j, int nb) { xpi[i] = xp[j]; ypi[i] = yp[j]; @@ -92,8 +92,8 @@ static void affect(double *xpi, double *ypi, double *zpi, } static void removeIdenticalNodes(int *np, int numComp, - double xp[12], double yp[12], double zp[12], - double valp[12][9], int ep[12]) + double xp[12], double yp[12], double zp[12], + double valp[12][9], int ep[12]) { double xpi[12], ypi[12], zpi[12], valpi[12][9]; int epi[12]; @@ -103,14 +103,14 @@ static void removeIdenticalNodes(int *np, int numComp, for(int j = 1; j < *np; j++) { for(int i = 0; i < npi; i++) { if(fabs(xp[j] - xpi[i]) < 1.e-12 && - fabs(yp[j] - ypi[i]) < 1.e-12 && - fabs(zp[j] - zpi[i]) < 1.e-12) { - break; + fabs(yp[j] - ypi[i]) < 1.e-12 && + fabs(zp[j] - zpi[i]) < 1.e-12) { + break; } if(i == npi-1) { - affect(xpi, ypi, zpi, valpi, epi, npi, xp, yp, zp, valp, ep, j, numComp); - npi++; - break; + affect(xpi, ypi, zpi, valpi, epi, npi, xp, yp, zp, valp, ep, j, numComp); + npi++; + break; } } } @@ -120,7 +120,7 @@ static void removeIdenticalNodes(int *np, int numComp, } static void reorderQuad(int numComp, double xp[12], double yp[12], double zp[12], - double valp[12][9], int ep[12]) + double valp[12][9], int ep[12]) { double xpi[1], ypi[1], zpi[1], valpi[1][9]; int epi[12]; @@ -130,7 +130,7 @@ static void reorderQuad(int numComp, double xp[12], double yp[12], double zp[12] } static void reorderPrism(int numComp, double xp[12], double yp[12], double zp[12], - double valp[12][9], int ep[12], int nbCut) + double valp[12][9], int ep[12], int nbCut) { double xpi[6], ypi[6], zpi[6], valpi[6][9]; int epi[12]; @@ -144,9 +144,9 @@ static void reorderPrism(int numComp, double xp[12], double yp[12], double zp[12 for(int i = 0; i < 3; i++){ int edgecut = ep[i]-1; for(int j = 0; j < 3; j++){ - int p = -epi[j]-1; - if(exn[9][edgecut][0] == p || exn[9][edgecut][1] == p) - affect(xp, yp, zp, valp, ep, 3+i, xpi, ypi, zpi, valpi, epi, j, numComp); + int p = -epi[j]-1; + if(exn[9][edgecut][0] == p || exn[9][edgecut][1] == p) + affect(xp, yp, zp, valp, ep, 3+i, xpi, ypi, zpi, valpi, epi, j, numComp); } } } @@ -159,31 +159,31 @@ static void reorderPrism(int numComp, double xp[12], double yp[12], double zp[12 if(exn[9][edgecut][0] == p0 || exn[9][edgecut][1] == p0){ affect(xpi, ypi, zpi, valpi, epi, 1, xp, yp, zp, valp, ep, 4, numComp); if(exn[9][ep[1]-1][0] == p0 || exn[9][ep[1]-1][1] == p0){ - affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 1, numComp); - affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 3, numComp); - affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 5, numComp); - affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); + affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 1, numComp); + affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 3, numComp); + affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 5, numComp); + affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); } else{ - affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 3, numComp); - affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 1, numComp); - affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 5, numComp); - affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); + affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 3, numComp); + affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 1, numComp); + affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 5, numComp); + affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); } } else{ affect(xpi, ypi, zpi, valpi, epi, 1, xp, yp, zp, valp, ep, 5, numComp); if(exn[9][ep[1]-1][0] == p0 || exn[9][ep[1]-1][1] == p0){ - affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 1, numComp); - affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 3, numComp); - affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 4, numComp); - affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); + affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 1, numComp); + affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 3, numComp); + affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 4, numComp); + affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); } else{ - affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 3, numComp); - affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 1, numComp); - affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 4, numComp); - affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); + affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 3, numComp); + affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 1, numComp); + affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 4, numComp); + affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp); } } for(int i = 0; i < 6; i++) @@ -205,8 +205,8 @@ GMSH_LevelsetPlugin::GMSH_LevelsetPlugin() } void GMSH_LevelsetPlugin::_addElement(int step, int np, int numEdges, int numComp, - double xp[12], double yp[12], double zp[12], - double valp[12][9], PViewDataList *out) + double xp[12], double yp[12], double zp[12], + double valp[12][9], PViewDataList *out) { List_T *list; int *nbPtr; @@ -273,10 +273,10 @@ void GMSH_LevelsetPlugin::_addElement(int step, int np, int numEdges, int numCom } void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata, - int ent, int ele, int step, int wstep, - double x[8], double y[8], double z[8], - double levels[8], double scalarValues[8], - PViewDataList* out) + int ent, int ele, int step, int wstep, + double x[8], double y[8], double z[8], + double levels[8], double scalarValues[8], + PViewDataList* out) { int numNodes = vdata->getNumNodes(step, ent, ele); int numEdges = vdata->getNumEdges(step, ent, ele); @@ -290,15 +290,15 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata, for(int i = 0; i < nse; i++){ int n0 = exn[nse][i][0], n1 = exn[nse][i][1]; if(levels[n[n0]] * levels[n[n1]] <= 0.) { - double c = InterpolateIso(x, y, z, levels, 0., n[n0], n[n1], - &xp[np], &yp[np], &zp[np]); - for(int comp = 0; comp < numComp; comp++){ - double v0, v1; - wdata->getValue(wstep, ent, ele, n[n0], comp, v0); - wdata->getValue(wstep, ent, ele, n[n1], comp, v1); - valp[np][comp] = v0 + c * (v1 - v0); - } - ep[np++] = i + 1; + double c = InterpolateIso(x, y, z, levels, 0., n[n0], n[n1], + &xp[np], &yp[np], &zp[np]); + for(int comp = 0; comp < numComp; comp++){ + double v0, v1; + wdata->getValue(wstep, ent, ele, n[n0], comp, v0); + wdata->getValue(wstep, ent, ele, n[n1], comp, v1); + valp[np][comp] = v0 + c * (v1 - v0); + } + ep[np++] = i + 1; } } @@ -318,36 +318,36 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata, // orient the triangles and the quads to get the normals right if(!_extractVolume && (np == 3 || np == 4)) { if(!step || !_valueIndependent) { - // test this only once for spatially-fixed views - double v1[3] = {xp[2] - xp[0], yp[2] - yp[0], zp[2] - zp[0]}; - double v2[3] = {xp[1] - xp[0], yp[1] - yp[0], zp[1] - zp[0]}; - double gr[3], normal[3]; - prodve(v1, v2, normal); - switch (_orientation) { - case MAP: - gradSimplex(x, y, z, scalarValues, gr); - prosca(gr, normal, &_invert); - break; - case PLANE: - prosca(normal, _ref, &_invert); - break; - case SPHERE: - gr[0] = xp[0] - _ref[0]; - gr[1] = yp[0] - _ref[1]; - gr[2] = zp[0] - _ref[2]; - prosca(gr, normal, &_invert); - case NONE: - default: - break; - } + // test this only once for spatially-fixed views + double v1[3] = {xp[2] - xp[0], yp[2] - yp[0], zp[2] - zp[0]}; + double v2[3] = {xp[1] - xp[0], yp[1] - yp[0], zp[1] - zp[0]}; + double gr[3], normal[3]; + prodve(v1, v2, normal); + switch (_orientation) { + case MAP: + gradSimplex(x, y, z, scalarValues, gr); + prosca(gr, normal, &_invert); + break; + case PLANE: + prosca(normal, _ref, &_invert); + break; + case SPHERE: + gr[0] = xp[0] - _ref[0]; + gr[1] = yp[0] - _ref[1]; + gr[2] = zp[0] - _ref[2]; + prosca(gr, normal, &_invert); + case NONE: + default: + break; + } } if(_invert > 0.) { - double xpi[12], ypi[12], zpi[12], valpi[12][9]; - int epi[12]; - for(int k = 0; k < np; k++) - affect(xpi, ypi, zpi, valpi, epi, k, xp, yp, zp, valp, ep, k, numComp); - for(int k = 0; k < np; k++) - affect(xp, yp, zp, valp, ep, k, xpi, ypi, zpi, valpi, epi, np - k - 1, numComp); + double xpi[12], ypi[12], zpi[12], valpi[12][9]; + int epi[12]; + for(int k = 0; k < np; k++) + affect(xpi, ypi, zpi, valpi, epi, k, xp, yp, zp, valp, ep, k, numComp); + for(int k = 0; k < np; k++) + affect(xp, yp, zp, valp, ep, k, xpi, ypi, zpi, valpi, epi, np - k - 1, numComp); } } @@ -357,24 +357,24 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata, if(_extractVolume){ int nbCut = np; for(int nod = 0; nod < nsn; nod++){ - if((_extractVolume < 0. && levels[n[nod]] < 0.) || - (_extractVolume > 0. && levels[n[nod]] > 0.)){ - xp[np] = x[n[nod]]; - yp[np] = y[n[nod]]; - zp[np] = z[n[nod]]; - for(int comp = 0; comp < numComp; comp++) - wdata->getValue(wstep, ent, ele, n[nod], comp, valp[np][comp]); - ep[np] = -(nod + 1); // store node num! - np++; - } + if((_extractVolume < 0. && levels[n[nod]] < 0.) || + (_extractVolume > 0. && levels[n[nod]] > 0.)){ + xp[np] = x[n[nod]]; + yp[np] = y[n[nod]]; + zp[np] = z[n[nod]]; + for(int comp = 0; comp < numComp; comp++) + wdata->getValue(wstep, ent, ele, n[nod], comp, valp[np][comp]); + ep[np] = -(nod + 1); // store node num! + np++; + } } removeIdenticalNodes(&np, numComp, xp, yp, zp, valp, ep); if(np == 4 && numEdges <= 4) - reorderQuad(numComp, xp, yp, zp, valp, ep); + reorderQuad(numComp, xp, yp, zp, valp, ep); if(np == 6) - reorderPrism(numComp, xp, yp, zp, valp, ep, nbCut); + reorderPrism(numComp, xp, yp, zp, valp, ep, nbCut); if(np > 8) // can't deal with this - continue; + continue; } _addElement(step, np, numEdges, numComp, xp, yp, zp, valp, out); @@ -386,19 +386,19 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata, bool add = true; for(int nod = 0; nod < numNodes; nod++){ if((_extractVolume < 0. && levels[nod] > 0.) || - (_extractVolume > 0. && levels[nod] < 0.)){ - add = false; - break; + (_extractVolume > 0. && levels[nod] < 0.)){ + add = false; + break; } } if(add){ double xp[12], yp[12], zp[12], valp[12][9]; for(int nod = 0; nod < numNodes; nod++){ - xp[nod] = x[nod]; - yp[nod] = y[nod]; - zp[nod] = z[nod]; - for(int comp = 0; comp < numComp; comp++) - wdata->getValue(wstep, ent, ele, nod, comp, valp[nod][comp]); + xp[nod] = x[nod]; + yp[nod] = y[nod]; + zp[nod] = z[nod]; + for(int comp = 0; comp < numComp; comp++) + wdata->getValue(wstep, ent, ele, nod, comp, valp[nod][comp]); } _addElement(step, numNodes, numEdges, numComp, xp, yp, zp, valp, out); } @@ -412,8 +412,8 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) if(dv){ dv->adaptive->setTolerance(_targetError); if(dv->NbST || dv->NbSS || dv->NbSQ || dv->NbSH){ - dv->adaptive->setAdaptiveResolutionLevel(dv, _recurLevel, this); - v->setChanged(true); + dv->adaptive->setAdaptiveResolutionLevel(dv, _recurLevel, this); + v->setChanged(true); } } } @@ -424,7 +424,7 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) } else if(_valueView > (int)PView::list.size() - 1){ Msg(GERROR, "View[%d] does not exist: reverting to View[%d]", - _valueView, v->getIndex()); + _valueView, v->getIndex()); wdata = vdata; } else{ @@ -454,15 +454,15 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) PViewDataList *out = getDataList(new PView(true)); for(int ent = 0; ent < vdata->getNumEntities(0); ent++){ for(int ele = 0; ele < vdata->getNumElements(0, ent); ele++){ - for(int nod = 0; nod < vdata->getNumNodes(0, ent, ele); nod++){ - vdata->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]); - levels[nod] = levelset(x[nod], y[nod], z[nod], 0.); - } - for(int step = 0; step < vdata->getNumTimeSteps(); step++){ - int wstep = (_valueTimeStep < 0) ? step : _valueTimeStep; - _cutAndAddElements(vdata, wdata, ent, ele, step, wstep, x, y, z, - levels, scalarValues, out); - } + for(int nod = 0; nod < vdata->getNumNodes(0, ent, ele); nod++){ + vdata->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]); + levels[nod] = levelset(x[nod], y[nod], z[nod], 0.); + } + for(int step = 0; step < vdata->getNumTimeSteps(); step++){ + int wstep = (_valueTimeStep < 0) ? step : _valueTimeStep; + _cutAndAddElements(vdata, wdata, ent, ele, step, wstep, x, y, z, + levels, scalarValues, out); + } } } out->setName(vdata->getName() + "_Levelset"); @@ -474,16 +474,16 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) for(int step = 0; step < vdata->getNumTimeSteps(); step++){ PViewDataList *out = getDataList(new PView(true)); for(int ent = 0; ent < vdata->getNumEntities(step); ent++){ - for(int ele = 0; ele < vdata->getNumElements(step, ent); ele++){ - for(int nod = 0; nod < vdata->getNumNodes(step, ent, ele); nod++){ - vdata->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]); - vdata->getScalarValue(step, ent, ele, nod, scalarValues[nod]); - levels[nod] = levelset(x[nod], y[nod], z[nod], scalarValues[nod]); - } - int wstep = (_valueTimeStep < 0) ? step : _valueTimeStep; - _cutAndAddElements(vdata, wdata, ent, ele, step, wstep, x, y, z, - levels, scalarValues, out); - } + for(int ele = 0; ele < vdata->getNumElements(step, ent); ele++){ + for(int nod = 0; nod < vdata->getNumNodes(step, ent, ele); nod++){ + vdata->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]); + vdata->getScalarValue(step, ent, ele, nod, scalarValues[nod]); + levels[nod] = levelset(x[nod], y[nod], z[nod], scalarValues[nod]); + } + int wstep = (_valueTimeStep < 0) ? step : _valueTimeStep; + _cutAndAddElements(vdata, wdata, ent, ele, step, wstep, x, y, z, + levels, scalarValues, out); + } } char tmp[246]; sprintf(tmp, "_Levelset_%d", step); @@ -500,7 +500,7 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) // the levelset, this is as accurate as it should be static bool recur_sign_change(adapt_triangle *t, double val, - const GMSH_LevelsetPlugin *plug) + const GMSH_LevelsetPlugin *plug) { if(!t->e[0] || t->visible){ double v1 = plug->levelset(t->p[0]->X, t->p[0]->Y, t->p[0]->Z, t->p[0]->val); @@ -530,7 +530,7 @@ static bool recur_sign_change(adapt_triangle *t, double val, } static bool recur_sign_change(adapt_tet *t, double val, - const GMSH_LevelsetPlugin *plug) + const GMSH_LevelsetPlugin *plug) { if(!t->e[0] || t->visible){ double v1 = plug->levelset(t->p[0]->X, t->p[0]->Y, t->p[0]->Z, t->p[0]->val); @@ -569,7 +569,7 @@ static bool recur_sign_change(adapt_tet *t, double val, } static bool recur_sign_change(adapt_hex *t, double val, - const GMSH_LevelsetPlugin *plug) + const GMSH_LevelsetPlugin *plug) { if (!t->e[0] || t->visible){ double v1 = plug->levelset(t->p[0]->X, t->p[0]->Y, t->p[0]->Z, t->p[0]->val); @@ -613,7 +613,7 @@ static bool recur_sign_change(adapt_hex *t, double val, } static bool recur_sign_change(adapt_quad *q, double val, - const GMSH_LevelsetPlugin *plug) + const GMSH_LevelsetPlugin *plug) { if(!q->e[0]|| q->visible){ double v1 = plug->levelset(q->p[0]->X, q->p[0]->Y, q->p[0]->Z, q->p[0]->val); diff --git a/Plugin/Levelset.h b/Plugin/Levelset.h index 93e62c64c84428b23045f71ecfb76a2e8d20d40d..394d37773e678c2982c72229c315d60b1c4737c1 100644 --- a/Plugin/Levelset.h +++ b/Plugin/Levelset.h @@ -27,13 +27,13 @@ class GMSH_LevelsetPlugin : public GMSH_Post_Plugin private: double _invert; void _addElement(int step, int np, int numEdges, int numComp, - double xp[12], double yp[12], double zp[12], - double valp[12][9], PViewDataList *out); + double xp[12], double yp[12], double zp[12], + double valp[12][9], PViewDataList *out); void _cutAndAddElements(PViewData *vdata, PViewData *wdata, - int ent, int ele, int step, int wstep, - double x[8], double y[8], double z[8], - double levels[8], double scalarValues[8], - PViewDataList *out); + int ent, int ele, int step, int wstep, + double x[8], double y[8], double z[8], + double levels[8], double scalarValues[8], + PViewDataList *out); protected: double _ref[3], _targetError; int _valueTimeStep, _valueView, _valueIndependent, _recurLevel, _extractVolume; diff --git a/Plugin/MakeSimplex.cpp b/Plugin/MakeSimplex.cpp index 7831612b97e214ac4d2fa83014acff063e50afde..e316a0dc3b57cdbdb791073b090c4a9500405553 100644 --- a/Plugin/MakeSimplex.cpp +++ b/Plugin/MakeSimplex.cpp @@ -1,4 +1,4 @@ -// $Id: MakeSimplex.cpp,v 1.7 2008-03-18 19:30:14 geuzaine Exp $ +// $Id: MakeSimplex.cpp,v 1.8 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -44,19 +44,19 @@ void GMSH_MakeSimplexPlugin::getName(char *name) const } void GMSH_MakeSimplexPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(MakeSimplex) decomposes all non-\n" - "simplectic elements (quadrangles, prisms,\n" - "hexahedra, pyramids) in the view `iView' into\n" - "simplices (triangles, tetrahedra). If `iView' < 0,\n" - "the plugin is run on the current view.\n" - "\n" - "Plugin(MakeSimplex) is executed\n" - "in-place.\n"); + "simplectic elements (quadrangles, prisms,\n" + "hexahedra, pyramids) in the view `iView' into\n" + "simplices (triangles, tetrahedra). If `iView' < 0,\n" + "the plugin is run on the current view.\n" + "\n" + "Plugin(MakeSimplex) is executed\n" + "in-place.\n"); } int GMSH_MakeSimplexPlugin::getNbOptions() const @@ -75,7 +75,7 @@ void GMSH_MakeSimplexPlugin::catchErrorMessage(char *errorMessage) const } static void decomposeList(PViewDataList *data, int nbNod, int nbComp, - List_T **listIn, int *nbIn, List_T *listOut, int *nbOut) + List_T **listIn, int *nbIn, List_T *listOut, int *nbOut) { double xNew[4], yNew[4], zNew[4]; double *valNew = new double[data->getNumTimeSteps() * nbComp * nbNod]; @@ -93,13 +93,13 @@ static void decomposeList(PViewDataList *data, int nbNod, int nbComp, for(int j = 0; j < dec.numSimplices(); j++){ dec.decompose(j, x, y, z, val, xNew, yNew, zNew, valNew); for(int k = 0; k < dec.numSimplexNodes(); k++) - List_Add(listOut, &xNew[k]); + List_Add(listOut, &xNew[k]); for(int k = 0; k < dec.numSimplexNodes(); k++) - List_Add(listOut, &yNew[k]); + List_Add(listOut, &yNew[k]); for(int k = 0; k < dec.numSimplexNodes(); k++) - List_Add(listOut, &zNew[k]); + List_Add(listOut, &zNew[k]); for(int k = 0; k < dec.numSimplexNodes() * data->getNumTimeSteps() * nbComp; k++) - List_Add(listOut, &valNew[k]); + List_Add(listOut, &valNew[k]); (*nbOut)++; } } @@ -124,18 +124,18 @@ PView *GMSH_MakeSimplexPlugin::execute(PView *v) decomposeList(data1, 4, 1, &data1->SQ, &data1->NbSQ, data1->ST, &data1->NbST); decomposeList(data1, 4, 3, &data1->VQ, &data1->NbVQ, data1->VT, &data1->NbVT); decomposeList(data1, 4, 9, &data1->TQ, &data1->NbTQ, data1->TT, &data1->NbTT); - - // hexas + + // hexas decomposeList(data1, 8, 1, &data1->SH, &data1->NbSH, data1->SS, &data1->NbSS); decomposeList(data1, 8, 3, &data1->VH, &data1->NbVH, data1->VS, &data1->NbVS); decomposeList(data1, 8, 9, &data1->TH, &data1->NbTH, data1->TS, &data1->NbTS); - - // prisms + + // prisms decomposeList(data1, 6, 1, &data1->SI, &data1->NbSI, data1->SS, &data1->NbSS); decomposeList(data1, 6, 3, &data1->VI, &data1->NbVI, data1->VS, &data1->NbVS); decomposeList(data1, 6, 9, &data1->TI, &data1->NbTI, data1->TS, &data1->NbTS); - - // pyramids + + // pyramids decomposeList(data1, 5, 1, &data1->SY, &data1->NbSY, data1->SS, &data1->NbSS); decomposeList(data1, 5, 3, &data1->VY, &data1->NbVY, data1->VS, &data1->NbVS); decomposeList(data1, 5, 9, &data1->TY, &data1->NbTY, data1->TS, &data1->NbTS); @@ -174,8 +174,8 @@ int MakeSimplex::numSimplexNodes() } void MakeSimplex::reorder(int map[4], int n, - double *x, double *y, double *z, double *val, - double *xn, double *yn, double *zn, double *valn) + double *x, double *y, double *z, double *val, + double *xn, double *yn, double *zn, double *valn) { for(int i = 0; i < n; i++) { xn[i] = x[map[i]]; @@ -187,14 +187,14 @@ void MakeSimplex::reorder(int map[4], int n, for(int ts = 0; ts < _numTimeSteps; ts++) for(int i = 0; i < n; i++) { for(int j = 0; j < _numComponents; j++) - valn[ts*n*_numComponents + i*_numComponents + j] = - val[ts*_numNodes*_numComponents + map2[i]*_numComponents + j]; + valn[ts*n*_numComponents + i*_numComponents + j] = + val[ts*_numNodes*_numComponents + map2[i]*_numComponents + j]; } } void MakeSimplex::decompose(int num, - double *x, double *y, double *z, double *val, - double *xn, double *yn, double *zn, double *valn) + double *x, double *y, double *z, double *val, + double *xn, double *yn, double *zn, double *valn) { int quadTri[2][4] = {{0,1,2,-1}, {0,2,3,-1}}; int hexaTet[6][4] = {{0,1,3,7}, {0,4,1,7}, {1,4,5,7}, {1,2,3,7}, {1,6,2,7}, {1,5,6,7}}; diff --git a/Plugin/MakeSimplex.h b/Plugin/MakeSimplex.h index 614005d2fca38bb18140e981983edef892ec7b12..faca2674b4f07e6c02e36144cb8d11547d4e43fd 100644 --- a/Plugin/MakeSimplex.h +++ b/Plugin/MakeSimplex.h @@ -49,8 +49,8 @@ class MakeSimplex{ int _numTimeSteps; // create a simplex void reorder(int map[4], int n, - double *x, double *y, double *z, double *val, - double *xn, double *yn, double *zn, double *valn); + double *x, double *y, double *z, double *val, + double *xn, double *yn, double *zn, double *valn); public: // default constructor MakeSimplex(int numNodes, int numComponents, int numTimeSteps=1); @@ -60,8 +60,8 @@ class MakeSimplex{ int numSimplexNodes(); // returns the i-th simplex in the decomposition void decompose(int num, - double *x, double *y, double *z, double *val, - double *xn, double *yn, double *zn, double *valn); + double *x, double *y, double *z, double *val, + double *xn, double *yn, double *zn, double *valn); }; #endif diff --git a/Plugin/ModulusPhase.cpp b/Plugin/ModulusPhase.cpp index 2dd6cebbcd7b3c10e29c7dde6ed6962e43192bf2..e1a1bb69149bc14c9892a6c968a3fc8f598b7508 100644 --- a/Plugin/ModulusPhase.cpp +++ b/Plugin/ModulusPhase.cpp @@ -1,4 +1,4 @@ -// $Id: ModulusPhase.cpp,v 1.8 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: ModulusPhase.cpp,v 1.9 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -53,13 +53,13 @@ void GMSH_ModulusPhasePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(ModulusPhase) interprets the time steps\n" - "`realPart' and `imaginaryPart' in the view `iView'\n" - "as the real and imaginary parts of a complex field\n" - "and replaces them with their corresponding\n" - "modulus and phase. If `iView' < 0, the plugin is\n" - "run on the current view.\n" - "\n" - "Plugin(ModulusPhase) is executed in-place.\n"); + "`realPart' and `imaginaryPart' in the view `iView'\n" + "as the real and imaginary parts of a complex field\n" + "and replaces them with their corresponding\n" + "modulus and phase. If `iView' < 0, the plugin is\n" + "run on the current view.\n" + "\n" + "Plugin(ModulusPhase) is executed in-place.\n"); } int GMSH_ModulusPhasePlugin::getNbOptions() const @@ -88,17 +88,17 @@ static void mp(int nb1, List_T *list1, int nbNod, int nbComp) int nb = List_Nbr(list1) / nb1; for(int i = 0; i < List_Nbr(list1); i += nb) { double *valr = (double *)List_Pointer_Fast(list1, i + 3 * nbNod + - nbNod * nbComp * rIndex); + nbNod * nbComp * rIndex); double *vali = (double *)List_Pointer_Fast(list1, i + 3 * nbNod + - nbNod * nbComp * iIndex); + nbNod * nbComp * iIndex); for(int j = 0; j < nbNod; j++) { for(int k = 0; k < nbComp; k++) { - double vr = valr[nbComp * j + k]; - double vi = vali[nbComp * j + k]; - double modulus = sqrt(vr*vr+vi*vi); - double phase = atan2(vi, vr); - valr[nbComp * j + k] = modulus; - vali[nbComp * j + k] = phase; + double vr = valr[nbComp * j + k]; + double vi = vali[nbComp * j + k]; + double modulus = sqrt(vr*vr+vi*vi); + double phase = atan2(vi, vr); + valr[nbComp * j + k] = modulus; + vali[nbComp * j + k] = phase; } } } diff --git a/Plugin/PluginManager.cpp b/Plugin/PluginManager.cpp index 63e12660b66e5177adae3ccc55711b2e05887842..29d21a11dcbf6f66695666f8f29a6a4b0ac6a205 100644 --- a/Plugin/PluginManager.cpp +++ b/Plugin/PluginManager.cpp @@ -1,4 +1,4 @@ -// $Id: PluginManager.cpp,v 1.6 2008-03-18 08:41:26 remacle Exp $ +// $Id: PluginManager.cpp,v 1.7 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -174,72 +174,72 @@ void GMSH_PluginManager::registerDefaultPlugins() if(CTX.post.plugins){ allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("StreamLines", GMSH_RegisterStreamLinesPlugin())); + ("StreamLines", GMSH_RegisterStreamLinesPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("CutGrid", GMSH_RegisterCutGridPlugin())); + ("CutGrid", GMSH_RegisterCutGridPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("CutMap", GMSH_RegisterCutMapPlugin())); + ("CutMap", GMSH_RegisterCutMapPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("CutPlane", GMSH_RegisterCutPlanePlugin())); + ("CutPlane", GMSH_RegisterCutPlanePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("CutSphere", GMSH_RegisterCutSpherePlugin())); + ("CutSphere", GMSH_RegisterCutSpherePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Skin", GMSH_RegisterSkinPlugin())); + ("Skin", GMSH_RegisterSkinPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Extract", GMSH_RegisterExtractPlugin())); + ("Extract", GMSH_RegisterExtractPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("ExtractElements", GMSH_RegisterExtractElementsPlugin())); + ("ExtractElements", GMSH_RegisterExtractElementsPlugin())); #if 0 // waiting for BDS rewrite allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("ExtractEdges", GMSH_RegisterExtractEdgesPlugin())); + ("ExtractEdges", GMSH_RegisterExtractEdgesPlugin())); #endif allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("MakeSimplex", GMSH_RegisterMakeSimplexPlugin())); + ("MakeSimplex", GMSH_RegisterMakeSimplexPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Smooth", GMSH_RegisterSmoothPlugin())); + ("Smooth", GMSH_RegisterSmoothPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Transform", GMSH_RegisterTransformPlugin())); + ("Transform", GMSH_RegisterTransformPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("TransformLatLon", GMSH_RegisterTransformLatLonPlugin())); + ("TransformLatLon", GMSH_RegisterTransformLatLonPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Warp", GMSH_RegisterWarpPlugin())); + ("Warp", GMSH_RegisterWarpPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("SphericalRaise", GMSH_RegisterSphericalRaisePlugin())); + ("SphericalRaise", GMSH_RegisterSphericalRaisePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin())); + ("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("ModulusPhase", GMSH_RegisterModulusPhasePlugin())); + ("ModulusPhase", GMSH_RegisterModulusPhasePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Integrate", GMSH_RegisterIntegratePlugin())); + ("Integrate", GMSH_RegisterIntegratePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Gradient", GMSH_RegisterGradientPlugin())); + ("Gradient", GMSH_RegisterGradientPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Curl", GMSH_RegisterCurlPlugin())); + ("Curl", GMSH_RegisterCurlPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Divergence", GMSH_RegisterDivergencePlugin())); + ("Divergence", GMSH_RegisterDivergencePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Annotate", GMSH_RegisterAnnotatePlugin())); + ("Annotate", GMSH_RegisterAnnotatePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Remove", GMSH_RegisterRemovePlugin())); + ("Remove", GMSH_RegisterRemovePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Eigenvectors", GMSH_RegisterEigenvectorsPlugin())); + ("Eigenvectors", GMSH_RegisterEigenvectorsPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Eigenvalues", GMSH_RegisterEigenvaluesPlugin())); + ("Eigenvalues", GMSH_RegisterEigenvaluesPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Lambda2", GMSH_RegisterLambda2Plugin())); + ("Lambda2", GMSH_RegisterLambda2Plugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Probe", GMSH_RegisterProbePlugin())); + ("Probe", GMSH_RegisterProbePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("FieldView", GMSH_RegisterFieldViewPlugin())); + ("FieldView", GMSH_RegisterFieldViewPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Triangulate", GMSH_RegisterTriangulatePlugin())); + ("Triangulate", GMSH_RegisterTriangulatePlugin())); #if defined(HAVE_MATH_EVAL) allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("Evaluate", GMSH_RegisterEvaluatePlugin())); + ("Evaluate", GMSH_RegisterEvaluatePlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("CutParametric", GMSH_RegisterCutParametricPlugin())); + ("CutParametric", GMSH_RegisterCutParametricPlugin())); allPlugins.insert(std::pair<const char*, GMSH_Plugin*> - ("GSHHS", GMSH_RegisterGSHHSPlugin())); + ("GSHHS", GMSH_RegisterGSHHSPlugin())); #endif } diff --git a/Plugin/Probe.cpp b/Plugin/Probe.cpp index a975415ff845bd3105d5ed82340bff99556b102f..4094118c689dd0abdb0fe710589794b48b74e785 100644 --- a/Plugin/Probe.cpp +++ b/Plugin/Probe.cpp @@ -1,4 +1,4 @@ -// $Id: Probe.cpp,v 1.20 2008-03-20 07:34:43 geuzaine Exp $ +// $Id: Probe.cpp,v 1.21 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -131,10 +131,10 @@ void GMSH_ProbePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Probe) gets the value of the view `iView' at\n" - "the point (`X',`Y',`Z'). If `iView' < 0, the plugin is\n" - "run on the current view.\n" - "\n" - "Plugin(Probe) creates one new view.\n"); + "the point (`X',`Y',`Z'). If `iView' < 0, the plugin is\n" + "run on the current view.\n" + "\n" + "Plugin(Probe) creates one new view.\n"); } int GMSH_ProbePlugin::getNbOptions() const @@ -185,7 +185,7 @@ PView *GMSH_ProbePlugin::execute(PView *v) List_Add(data2->VP, &z); for(int i = 0; i < numSteps; i++){ for(int j = 0; j < 3; j++) - List_Add(data2->VP, &val[3*i+j]); + List_Add(data2->VP, &val[3*i+j]); } data2->NbVP++; } @@ -196,7 +196,7 @@ PView *GMSH_ProbePlugin::execute(PView *v) List_Add(data2->TP, &z); for(int i = 0; i < numSteps; i++){ for(int j = 0; j < 9; j++) - List_Add(data2->TP, &val[9*i+j]); + List_Add(data2->TP, &val[9*i+j]); } data2->NbTP++; } diff --git a/Plugin/Remove.cpp b/Plugin/Remove.cpp index 915e875e7512bc841646d1eba3eb1d923741fffe..74cd3c09d75037ddcac2f40c3e7a44bc7f53a608 100644 --- a/Plugin/Remove.cpp +++ b/Plugin/Remove.cpp @@ -1,4 +1,4 @@ -// $Id: Remove.cpp,v 1.13 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: Remove.cpp,v 1.14 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -57,16 +57,16 @@ void GMSH_RemovePlugin::getName(char *name) const } void GMSH_RemovePlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "C. Geuzaine"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Remove) removes the marked items\n" - "from the view `iView'. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(Remove) is executed in-place.\n"); + "from the view `iView'. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(Remove) is executed in-place.\n"); } int GMSH_RemovePlugin::getNbOptions() const diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp index c234ad3b5a968d55c13276de6e60b4e3de7cc0da..51b6aa048bcd6c97823e09b8cd2c8bed0db06fd0 100644 --- a/Plugin/Skin.cpp +++ b/Plugin/Skin.cpp @@ -1,4 +1,4 @@ -// $Id: Skin.cpp,v 1.36 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: Skin.cpp,v 1.37 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -60,10 +60,10 @@ void GMSH_SkinPlugin::getInfos(char *author, char *copyright, char *help_text) c strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Skin) extracts the skin (the boundary) of\n" - "the view `iView'. If `iView' < 0, the plugin is run\n" - "on the current view.\n" - "\n" - "Plugin(Skin) creates one new view.\n"); + "the view `iView'. If `iView' < 0, the plugin is run\n" + "on the current view.\n" + "\n" + "Plugin(Skin) creates one new view.\n"); } int GMSH_SkinPlugin::getNbOptions() const @@ -132,7 +132,7 @@ void GMSH_SkinPlugin::addInView(void *a, void *b) } void GMSH_SkinPlugin::skinList(List_T *inList, int inNbList, - int inNbNod, int inNbFac, int fxn[6][4]) + int inNbNod, int inNbFac, int fxn[6][4]) { if(!inNbList) return; @@ -144,17 +144,17 @@ void GMSH_SkinPlugin::skinList(List_T *inList, int inNbList, for(int j = 0; j < inNbFac; j++) { Elm e, *pe; for(int k = 0; k < _nbNod; k++) { - e.coord[k] = coord[fxn[j][k]]; // x - e.coord[_nbNod + k] = coord[inNbNod + fxn[j][k]]; // y - e.coord[2 * _nbNod + k] = coord[2 * inNbNod + fxn[j][k]]; // z + e.coord[k] = coord[fxn[j][k]]; // x + e.coord[_nbNod + k] = coord[inNbNod + fxn[j][k]]; // y + e.coord[2 * _nbNod + k] = coord[2 * inNbNod + fxn[j][k]]; // z } if(!(pe = (Elm *)Tree_PQuery(_skin, &e))) { - e.val = (double *)Malloc(_nbNod * _nbComp * _nbTimeStep * sizeof(double)); - for(int k = 0; k < _nbNod; k++) - for(int ts = 0; ts < _nbTimeStep; ts++) - for(int n = 0; n < _nbComp; n++) - e.val[_nbNod * _nbComp * ts + _nbComp * k + n] = - val[inNbNod * _nbComp * ts + _nbComp * fxn[j][k] + n]; + e.val = (double *)Malloc(_nbNod * _nbComp * _nbTimeStep * sizeof(double)); + for(int k = 0; k < _nbNod; k++) + for(int ts = 0; ts < _nbTimeStep; ts++) + for(int n = 0; n < _nbComp; n++) + e.val[_nbNod * _nbComp * ts + _nbComp * k + n] = + val[inNbNod * _nbComp * ts + _nbComp * fxn[j][k] + n]; Tree_Add(_skin, &e); } else { @@ -186,7 +186,7 @@ PView *GMSH_SkinPlugin::execute(PView *v) int skinQua[6][4] = {{0,1,-1,-1}, {1,2,-1,-1}, {2,3,-1,-1}, {3,0,-1,-1}}; int skinTet[6][4] = {{0,1,3,-1}, {0,2,1,-1}, {0,3,2,-1}, {1,2,3,-1}}; int skinHex[6][4] = {{0,1,5,4}, {0,3,2,1}, {0,4,7,3}, - {1,2,6,5}, {2,3,7,6}, {4,5,6,7}}; + {1,2,6,5}, {2,3,7,6}, {4,5,6,7}}; int skinPri1[6][4] = {{0,1,4,3}, {0,3,5,2}, {1,2,5,4}}; int skinPri2[6][4] = {{0,2,1,-1}, {3,4,5,-1}}; int skinPyr1[6][4] = {{0,3,2,1}}; diff --git a/Plugin/Skin.h b/Plugin/Skin.h index 4a35546103aea9be643b9ed505d484857fcbb3b8..d3b7005983413db1f47531a3d44cff2f5f7e807c 100644 --- a/Plugin/Skin.h +++ b/Plugin/Skin.h @@ -41,7 +41,7 @@ class GMSH_SkinPlugin : public GMSH_Post_Plugin static int fcmpElm(const void *a, const void *b); static void addInView(void *a, void *b); void skinList(List_T *inList, int inNbList, - int inNbNod, int inNbFac, int fxn[6][4]); + int inNbNod, int inNbFac, int fxn[6][4]); public: GMSH_SkinPlugin(); void getName(char *name) const; diff --git a/Plugin/Smooth.cpp b/Plugin/Smooth.cpp index f69f0c36b6ee7cbf985d0c5c576c130fca6f5a4a..01d526b8cf4b93ee2eead4700512ee6c04f7a863 100644 --- a/Plugin/Smooth.cpp +++ b/Plugin/Smooth.cpp @@ -1,4 +1,4 @@ -// $Id: Smooth.cpp,v 1.30 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: Smooth.cpp,v 1.31 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -51,10 +51,10 @@ void GMSH_SmoothPlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Smooth) averages the values at the nodes\n" - "of the scalar view `iView'. If `iView' < 0, the\n" - "plugin is run on the current view.\n" - "\n" - "Plugin(Smooth) is executed in-place.\n"); + "of the scalar view `iView'. If `iView' < 0, the\n" + "plugin is run on the current view.\n" + "\n" + "Plugin(Smooth) is executed in-place.\n"); } int GMSH_SmoothPlugin::getNbOptions() const diff --git a/Plugin/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp index 5f1544a42065a92bb019343e6fd2dc3ef72cfbbb..22184277520740bed91a4ad32152b35a8d5d3920 100644 --- a/Plugin/SphericalRaise.cpp +++ b/Plugin/SphericalRaise.cpp @@ -1,4 +1,4 @@ -// $Id: SphericalRaise.cpp,v 1.31 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: SphericalRaise.cpp,v 1.32 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -62,16 +62,16 @@ void GMSH_SphericalRaisePlugin::getInfos(char *author, char *copyright, "`iView' using the values associated with the\n" "`TimeStep'-th time step. Instead of elevating\n" "the nodes along the X, Y and Z axes as in\n" - "View[`iView'].RaiseX, View[`iView'].RaiseY\n" - "and View[`iView'].RaiseZ, the raise is applied\n" - " along the radius of a sphere centered at\n" - "(`Xc', `Yc', `Zc'). To produce a standard\n" - "radiation pattern, set `Offset' to minus the\n" - "radius of the sphere the original data lives on.\n" - "If `iView' < 0, the plugin is run on the current\n" - "view.\n" - "\n" - "Plugin(SphericalRaise) is executed in-place.\n"); + "View[`iView'].RaiseX, View[`iView'].RaiseY\n" + "and View[`iView'].RaiseZ, the raise is applied\n" + " along the radius of a sphere centered at\n" + "(`Xc', `Yc', `Zc'). To produce a standard\n" + "radiation pattern, set `Offset' to minus the\n" + "radius of the sphere the original data lives on.\n" + "If `iView' < 0, the plugin is run on the current\n" + "view.\n" + "\n" + "Plugin(SphericalRaise) is executed in-place.\n"); } int GMSH_SphericalRaisePlugin::getNbOptions() const @@ -90,8 +90,8 @@ void GMSH_SphericalRaisePlugin::catchErrorMessage(char *errorMessage) const } static void sphericalRaise(PViewData *data, List_T *list, int nbElm, - int nbNod, int timeStep, double center[3], - double raise, double offset) + int nbNod, int timeStep, double center[3], + double raise, double offset) { double *x, *y, *z, *val, d[3], coef; int nb, i, j; diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp index 8b23ed9bb124c39d1e5d6210bb61f81a6393b465..b86fec33255e4d2cdec7e90007bf5fd23b7bebcf 100644 --- a/Plugin/StreamLines.cpp +++ b/Plugin/StreamLines.cpp @@ -1,4 +1,4 @@ -// $Id: StreamLines.cpp,v 1.33 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: StreamLines.cpp,v 1.34 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -78,7 +78,7 @@ void GMSH_StreamLinesPlugin::draw() } double GMSH_StreamLinesPlugin::callback(int num, int action, double value, double *opt, - double step, double min, double max) + double step, double min, double max) { switch(action){ // configure the input field case 1: return step; @@ -96,67 +96,67 @@ double GMSH_StreamLinesPlugin::callback(int num, int action, double value, doubl double GMSH_StreamLinesPlugin::callbackX0(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[0].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackY0(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[1].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackZ0(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[2].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackX1(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[3].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackY1(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[4].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackZ1(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[5].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackX2(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[6].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackY2(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[7].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackZ2(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[8].def, - CTX.lc/100., -2*CTX.lc, 2*CTX.lc); + CTX.lc/100., -2*CTX.lc, 2*CTX.lc); } double GMSH_StreamLinesPlugin::callbackU(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[9].def, - 1, 1, 100); + 1, 1, 100); } double GMSH_StreamLinesPlugin::callbackV(int num, int action, double value) { return callback(num, action, value, &StreamLinesOptions_Number[10].def, - 1, 1, 100); + 1, 1, 100); } void GMSH_StreamLinesPlugin::getName(char *name) const @@ -165,33 +165,33 @@ void GMSH_StreamLinesPlugin::getName(char *name) const } void GMSH_StreamLinesPlugin::getInfos(char *author, char *copyright, - char *help_text) const + char *help_text) const { strcpy(author, "J.-F. Remacle"); strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, - "Plugin(StreamLines) computes stream lines\n" - "from the `TimeStep'-th time step of a vector\n" - "view `iView' and optionally interpolates the\n" - "scalar view `dView' on the resulting stream\n" - "lines. The plugin takes as input a grid defined\n" - "by the 3 points (`X0',`Y0',`Z0') (origin),\n" - "(`X1',`Y1',`Z1') (axis of U) and (`X2',`Y2',`Z2')\n" - "(axis of V). The number of points that are to\n" - "be transported along U and V is set with the\n" - "options `nPointsU' and `nPointsV'. The equation\n" - "DX(t)/dt=V(x,y,z) is then solved with the initial\n" - "condition X(t=0) chosen as the grid and with V(x,y,z)\n" - "interpolated on the vector view. The time stepping\n" - "scheme is a RK44 with step size `DT' and `MaxIter'\n" - "maximum number of iterations. If `iView' < 0, the\n" - "plugin is run on the current view. If `TimeStep' < 0,\n" - "the plugin tries to compute streamlines of the unsteady\n" - "flow.\n" - "\n" - "Plugin(StreamLines) creates one new view. This\n" - "view contains multi-step vector points if `dView'\n" - "< 0, or single-step scalar lines if `dView' >= 0.\n"); + "Plugin(StreamLines) computes stream lines\n" + "from the `TimeStep'-th time step of a vector\n" + "view `iView' and optionally interpolates the\n" + "scalar view `dView' on the resulting stream\n" + "lines. The plugin takes as input a grid defined\n" + "by the 3 points (`X0',`Y0',`Z0') (origin),\n" + "(`X1',`Y1',`Z1') (axis of U) and (`X2',`Y2',`Z2')\n" + "(axis of V). The number of points that are to\n" + "be transported along U and V is set with the\n" + "options `nPointsU' and `nPointsV'. The equation\n" + "DX(t)/dt=V(x,y,z) is then solved with the initial\n" + "condition X(t=0) chosen as the grid and with V(x,y,z)\n" + "interpolated on the vector view. The time stepping\n" + "scheme is a RK44 with step size `DT' and `MaxIter'\n" + "maximum number of iterations. If `iView' < 0, the\n" + "plugin is run on the current view. If `TimeStep' < 0,\n" + "the plugin tries to compute streamlines of the unsteady\n" + "flow.\n" + "\n" + "Plugin(StreamLines) creates one new view. This\n" + "view contains multi-step vector points if `dView'\n" + "< 0, or single-step scalar lines if `dView' >= 0.\n"); } int GMSH_StreamLinesPlugin::getNbOptions() const @@ -254,7 +254,7 @@ PView *GMSH_StreamLinesPlugin::GenerateView(PView *v1, PView *v2) int timestep = (int)StreamLinesOptions_Number[13].def; if(timestep > data1->getNumTimeSteps() - 1){ - Msg(GERROR, "Invalid time step (%d) in view: using step 0 instead", timestep); + Msg(GERROR, "Invalid time step (%d) in view: using step 0 instead", timestep); timestep = 0; } @@ -270,81 +270,81 @@ PView *GMSH_StreamLinesPlugin::GenerateView(PView *v1, PView *v2) for(int j = 0; j < getNbV(); ++j){ getPoint(i, j, XINIT); getPoint(i, j, X); - + if(data2){ - o2->searchScalar(X[0], X[1], X[2], val2, -1); + o2->searchScalar(X[0], X[1], X[2], val2, -1); } else{ - data->NbVP++; - List_Add(data->VP, &X[0]); - List_Add(data->VP, &X[1]); - List_Add(data->VP, &X[2]); + data->NbVP++; + List_Add(data->VP, &X[0]); + List_Add(data->VP, &X[1]); + List_Add(data->VP, &X[2]); } int currentTimeStep = 0; for(int iter = 0; iter < (int)StreamLinesOptions_Number[11].def; iter++){ - double XPREV[3] = { X[0], X[1], X[2] }; - - if(timestep < 0){ - double T0 = data1->getTime(0); - double currentT = T0 + DT * iter; - List_Add(data->Time, ¤tT); - for(; currentTimeStep < data1->getNumTimeSteps() - 1 && - currentT > 0.5 * (data1->getTime(currentTimeStep) + - data1->getTime(currentTimeStep + 1)); - currentTimeStep++); - } - else{ - currentTimeStep = timestep; - } - //Msg(DEBUG, "iter = %d, currentTimeStep = %d", iter, currentTimeStep); - - // dX/dt = V - // X1 = X + a1 * DT * V(X) - // X2 = X + a2 * DT * V(X1) - // X3 = X + a3 * DT * V(X2) - // X4 = X + a4 * DT * V(X3) - // X = X + b1 X1 + b2 X2 + b3 X3 + b4 x4 - - // o.searchVector(X[0], X[1], X[2], val, currentTimeStep, &sizeElem); - // double normV = sqrt(val[0]*val[0]+val[1]*val[1]+val[2]*val[2]); - // if (normV==0.0) normV = 1.0; - // double DT = sizeElem / normV ; // CFL = 1 ==> secure - o.searchVector(X[0], X[1], X[2], val, currentTimeStep); - for(int k = 0; k < 3; k++) X1[k] = X[k] + DT * val[k] * a1; - o.searchVector(X1[0], X1[1], X1[2], val, currentTimeStep); - for(int k = 0; k < 3; k++) X2[k] = X[k] + DT * val[k] * a2; - o.searchVector(X2[0], X2[1], X2[2], val, currentTimeStep); - for(int k = 0; k < 3; k++) X3[k] = X[k] + DT * val[k] * a3; - o.searchVector(X3[0], X3[1], X3[2], val, currentTimeStep); - for(int k = 0; k < 3; k++) X4[k] = X[k] + DT * val[k] * a4; - - for(int k = 0; k < 3; k++) - X[k] += (b1*(X1[k]-X[k]) + b2*(X2[k]-X[k]) + - b3*(X3[k]-X[k]) + b4*(X4[k]-X[k])) ; - for(int k = 0; k < 3; k++) DX[k] = X[k] - XINIT[k]; - - if(data2){ - data->NbSL++; - List_Add(data->SL, &XPREV[0]); - List_Add(data->SL, &X[0]); - List_Add(data->SL, &XPREV[1]); - List_Add(data->SL, &X[1]); - List_Add(data->SL, &XPREV[2]); - List_Add(data->SL, &X[2]); - for(int k = 0; k < data2->getNumTimeSteps(); k++) - List_Add(data->SL, &val2[k]); - o2->searchScalar(X[0], X[1], X[2], val2, -1); - for(int k = 0; k < data2->getNumTimeSteps(); k++) - List_Add(data->SL, &val2[k]); - } - else{ - List_Add(data->VP, &DX[0]); - List_Add(data->VP, &DX[1]); - List_Add(data->VP, &DX[2]); - } + double XPREV[3] = { X[0], X[1], X[2] }; + + if(timestep < 0){ + double T0 = data1->getTime(0); + double currentT = T0 + DT * iter; + List_Add(data->Time, ¤tT); + for(; currentTimeStep < data1->getNumTimeSteps() - 1 && + currentT > 0.5 * (data1->getTime(currentTimeStep) + + data1->getTime(currentTimeStep + 1)); + currentTimeStep++); + } + else{ + currentTimeStep = timestep; + } + //Msg(DEBUG, "iter = %d, currentTimeStep = %d", iter, currentTimeStep); + + // dX/dt = V + // X1 = X + a1 * DT * V(X) + // X2 = X + a2 * DT * V(X1) + // X3 = X + a3 * DT * V(X2) + // X4 = X + a4 * DT * V(X3) + // X = X + b1 X1 + b2 X2 + b3 X3 + b4 x4 + + // o.searchVector(X[0], X[1], X[2], val, currentTimeStep, &sizeElem); + // double normV = sqrt(val[0]*val[0]+val[1]*val[1]+val[2]*val[2]); + // if (normV==0.0) normV = 1.0; + // double DT = sizeElem / normV ; // CFL = 1 ==> secure + o.searchVector(X[0], X[1], X[2], val, currentTimeStep); + for(int k = 0; k < 3; k++) X1[k] = X[k] + DT * val[k] * a1; + o.searchVector(X1[0], X1[1], X1[2], val, currentTimeStep); + for(int k = 0; k < 3; k++) X2[k] = X[k] + DT * val[k] * a2; + o.searchVector(X2[0], X2[1], X2[2], val, currentTimeStep); + for(int k = 0; k < 3; k++) X3[k] = X[k] + DT * val[k] * a3; + o.searchVector(X3[0], X3[1], X3[2], val, currentTimeStep); + for(int k = 0; k < 3; k++) X4[k] = X[k] + DT * val[k] * a4; + + for(int k = 0; k < 3; k++) + X[k] += (b1*(X1[k]-X[k]) + b2*(X2[k]-X[k]) + + b3*(X3[k]-X[k]) + b4*(X4[k]-X[k])) ; + for(int k = 0; k < 3; k++) DX[k] = X[k] - XINIT[k]; + + if(data2){ + data->NbSL++; + List_Add(data->SL, &XPREV[0]); + List_Add(data->SL, &X[0]); + List_Add(data->SL, &XPREV[1]); + List_Add(data->SL, &X[1]); + List_Add(data->SL, &XPREV[2]); + List_Add(data->SL, &X[2]); + for(int k = 0; k < data2->getNumTimeSteps(); k++) + List_Add(data->SL, &val2[k]); + o2->searchScalar(X[0], X[1], X[2], val2, -1); + for(int k = 0; k < data2->getNumTimeSteps(); k++) + List_Add(data->SL, &val2[k]); + } + else{ + List_Add(data->VP, &DX[0]); + List_Add(data->VP, &DX[1]); + List_Add(data->VP, &DX[2]); + } } } } diff --git a/Plugin/StreamLines.h b/Plugin/StreamLines.h index 6038ca47e4c333aaa09fc4909cfee157d811aadd..a484b2e7334a249b177bcf1608c66a82c9a30c30 100644 --- a/Plugin/StreamLines.h +++ b/Plugin/StreamLines.h @@ -30,13 +30,13 @@ extern "C" class GMSH_StreamLinesPlugin : public GMSH_Post_Plugin { static double callback(int num, int action, double value, double *opt, - double step, double min, double max); + double step, double min, double max); public: GMSH_StreamLinesPlugin(); void getName(char *name) const; void getInfos(char *author, - char *copyright, - char *help_text) const; + char *copyright, + char *help_text) const; void catchErrorMessage (char *errorMessage) const; int getNbOptions() const; StringXNumber *getOption(int iopt); diff --git a/Plugin/Transform.cpp b/Plugin/Transform.cpp index 321609e67a8f43c6b91403362f90f92046ce9209..b2f4ae86b8bf9c3b774642516100deda2281df16 100644 --- a/Plugin/Transform.cpp +++ b/Plugin/Transform.cpp @@ -1,4 +1,4 @@ -// $Id: Transform.cpp,v 1.37 2008-02-17 08:48:07 geuzaine Exp $ +// $Id: Transform.cpp,v 1.38 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -63,16 +63,16 @@ void GMSH_TransformPlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Transform) transforms the homogeneous\n" - "node coordinates (x,y,z,1) of the elements in\n" - "the view `iView' by the matrix\n" + "node coordinates (x,y,z,1) of the elements in\n" + "the view `iView' by the matrix\n" "[`A11' `A12' `A13' `Tx']\n" - "[`A21' `A22' `A23' `Ty']\n" - "[`A31' `A32' `A33' `Tz'].\n" - "If `SwapOrientation' is set, the orientation of the\n" - "elements is reversed. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(Transform) is executed in-place.\n"); + "[`A21' `A22' `A23' `Ty']\n" + "[`A31' `A32' `A33' `Tz'].\n" + "If `SwapOrientation' is set, the orientation of the\n" + "elements is reversed. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(Transform) is executed in-place.\n"); } int GMSH_TransformPlugin::getNbOptions() const @@ -101,7 +101,7 @@ static void transform(double mat[3][4], double v[3], } static void transform_list(PViewDataList *data, List_T *list, int nbList, - int nbVert, int nbComp, double mat[3][4], int swap) + int nbVert, int nbComp, double mat[3][4], int swap) { if(!nbList) return; @@ -128,19 +128,19 @@ static void transform_list(PViewDataList *data, List_T *list, int nbList, } if(copy){ for(int j = 0; j < nb; j++) - copy[j] = x[j]; + copy[j] = x[j]; for(int j = 0; j < nbVert; j++){ - x[j] = copy[nbVert - j - 1]; - x[nbVert + j] = copy[2 * nbVert - j - 1]; - x[2 * nbVert + j] = copy[3 * nbVert - j - 1]; + x[j] = copy[nbVert - j - 1]; + x[nbVert + j] = copy[2 * nbVert - j - 1]; + x[2 * nbVert + j] = copy[3 * nbVert - j - 1]; } for(int ts = 0; ts < data->getNumTimeSteps(); ts++){ - for(int j = 0; j < nbVert; j++){ - for(int k = 0; k < nbComp; k++){ - x[3 * nbVert + nbComp * nbVert * ts + nbComp * j + k] = - copy[3 * nbVert + nbComp * nbVert * ts + nbComp * (nbVert - j - 1) + k]; - } - } + for(int j = 0; j < nbVert; j++){ + for(int k = 0; k < nbComp; k++){ + x[3 * nbVert + nbComp * nbVert * ts + nbComp * j + k] = + copy[3 * nbVert + nbComp * nbVert * ts + nbComp * (nbVert - j - 1) + k]; + } + } } } } diff --git a/Plugin/TransformLatLon.cpp b/Plugin/TransformLatLon.cpp index 05dd94d34adac86f282c439ca9aca91e173d3ba7..49bd57444a9770614ab8e99af8bca633644ab55a 100644 --- a/Plugin/TransformLatLon.cpp +++ b/Plugin/TransformLatLon.cpp @@ -1,4 +1,4 @@ -// $Id: TransformLatLon.cpp,v 1.4 2008-02-17 08:48:08 geuzaine Exp $ +// $Id: TransformLatLon.cpp,v 1.5 2008-03-20 11:44:14 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -51,16 +51,16 @@ void GMSH_TransformLatLonPlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(TransformLatLon) transforms the homogeneous\n" - "node coordinates (x,y,z,1) of the elements in\n" - "the view `iView' by the matrix\n" + "node coordinates (x,y,z,1) of the elements in\n" + "the view `iView' by the matrix\n" "[`A11' `A12' `A13' `Tx']\n" - "[`A21' `A22' `A23' `Ty']\n" - "[`A31' `A32' `A33' `Tz'].\n" - "If `SwapOrientation' is set, the orientation of the\n" - "elements is reversed. If `iView' < 0, the plugin\n" - "is run on the current view.\n" - "\n" - "Plugin(TransformLatLon) is executed in-place.\n"); + "[`A21' `A22' `A23' `Ty']\n" + "[`A31' `A32' `A33' `Tz'].\n" + "If `SwapOrientation' is set, the orientation of the\n" + "elements is reversed. If `iView' < 0, the plugin\n" + "is run on the current view.\n" + "\n" + "Plugin(TransformLatLon) is executed in-place.\n"); } int GMSH_TransformLatLonPlugin::getNbOptions() const @@ -82,21 +82,21 @@ void GMSH_TransformLatLonPlugin::catchErrorMessage(char *errorMessage) const static void transform(double v[3], double *x, double *y, double *z,double rotate) { - double r = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); - *y=asin(v[2]/r)*180/M_PI; - *x=atan2(v[1],v[0])*180/M_PI+rotate; - while(*x>180)*x-=360; - *z=0; + double r = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); + *y=asin(v[2]/r)*180/M_PI; + *x=atan2(v[1],v[0])*180/M_PI+rotate; + while(*x>180)*x-=360; + *z=0; } static void transform_list(List_T *list, int nbList, List_T *list2, int *nbList2, - int nbVert, int nbComp,double rotate) + int nbVert, int nbComp,double rotate) { if(!nbList) return; int nb = List_Nbr(list) / nbList; - double *x2=new double[nbVert]; - double *y2=new double[nbVert]; - double *z2=new double[nbVert]; + double *x2=new double[nbVert]; + double *y2=new double[nbVert]; + double *z2=new double[nbVert]; for(int i = 0; i < List_Nbr(list); i += nb) { double *x = (double *)List_Pointer_Fast(list, i); double *y = (double *)List_Pointer_Fast(list, i + nbVert); @@ -105,49 +105,49 @@ static void transform_list(List_T *list, int nbList, List_T *list2, int *nbList2 double v[3] = { x[j], y[j], z[j] }; transform(v, &x2[j], &y2[j], &z2[j],rotate); } - // check the periodicity - bool cross=false; - for(int j=1;j<nbVert;j++) cross|=(fabs(x2[j]-x2[0])>180); - if(cross) for(int j=0;j<nbVert;j++) if(x2[j]<0)x2[j]+=360; + // check the periodicity + bool cross=false; + for(int j=1;j<nbVert;j++) cross|=(fabs(x2[j]-x2[0])>180); + if(cross) for(int j=0;j<nbVert;j++) if(x2[j]<0)x2[j]+=360; for(int j = 0; j < nbVert; j++)List_Add(list2,&x2[j]); for(int j = 0; j < nbVert; j++)List_Add(list2,&y2[j]); for(int j = 0; j < nbVert; j++)List_Add(list2,&z2[j]); - for(int k = 0; k < nbVert; k++){ - double d; - for(int l = 0; l < nbComp; l++){ - List_Read(list, i + 3 * nbVert + nbComp * k + l, &d); - List_Add(list2, &d); - } - } + for(int k = 0; k < nbVert; k++){ + double d; + for(int l = 0; l < nbComp; l++){ + List_Read(list, i + 3 * nbVert + nbComp * k + l, &d); + List_Add(list2, &d); + } + } (*nbList2)++; - if(cross){ - for(int j=0;j<nbVert;j++) x2[j]-=360; - for(int j = 0; j < nbVert; j++)List_Add(list2,&x2[j]); - for(int j = 0; j < nbVert; j++)List_Add(list2,&y2[j]); - for(int j = 0; j < nbVert; j++)List_Add(list2,&z2[j]); - for(int k = 0; k < nbVert; k++){ - double d; - for(int l = 0; l < nbComp; l++){ - List_Read(list, i + 3 * nbVert + nbComp * k + l, &d); - List_Add(list2, &d); - } - } - (*nbList2)++; - } + if(cross){ + for(int j=0;j<nbVert;j++) x2[j]-=360; + for(int j = 0; j < nbVert; j++)List_Add(list2,&x2[j]); + for(int j = 0; j < nbVert; j++)List_Add(list2,&y2[j]); + for(int j = 0; j < nbVert; j++)List_Add(list2,&z2[j]); + for(int k = 0; k < nbVert; k++){ + double d; + for(int l = 0; l < nbComp; l++){ + List_Read(list, i + 3 * nbVert + nbComp * k + l, &d); + List_Add(list2, &d); + } + } + (*nbList2)++; + } } - delete []x2; - delete []y2; - delete []z2; + delete []x2; + delete []y2; + delete []z2; } PView *GMSH_TransformLatLonPlugin::execute(PView *v) { int iView = (int)TransformLatLonOptions_Number[0].def; - double rotate = (double)TransformLatLonOptions_Number[1].def; + double rotate = (double)TransformLatLonOptions_Number[1].def; PView *v1 = getView(iView, v); if(!v1) return v; - PView *v2 = new PView(true); + PView *v2 = new PView(true); PViewDataList *data2 = getDataList(v2); if(!data2) return v; @@ -157,31 +157,31 @@ PView *GMSH_TransformLatLonPlugin::execute(PView *v) transform_list(data1->SP, data1->NbSP, data2->SP, &data2->NbSP, 1, 1, rotate); transform_list(data1->VP, data1->NbVP, data2->VP, &data2->NbVP, 1, 3, rotate); transform_list(data1->TP, data1->NbTP, data2->TP, &data2->NbTP, 1, 9, rotate); - // lines + // lines transform_list(data1->SL, data1->NbSL, data2->SL, &data2->NbSL, 2, 1, rotate); transform_list(data1->VL, data1->NbVL, data2->VL, &data2->NbVL, 2, 3, rotate); transform_list(data1->TL, data1->NbTL, data2->TL, &data2->NbTL, 2, 9, rotate); - // triangles + // triangles transform_list(data1->ST, data1->NbST, data2->ST, &data2->NbST, 3, 1, rotate); transform_list(data1->VT, data1->NbVT, data2->VT, &data2->NbVT, 3, 3, rotate); transform_list(data1->TT, data1->NbTT, data2->TT, &data2->NbTT, 3, 9, rotate); - // quadrangles + // quadrangles transform_list(data1->SQ, data1->NbSQ, data2->SQ, &data2->NbSQ, 4, 1, rotate); transform_list(data1->VQ, data1->NbVQ, data2->VQ, &data2->NbVQ, 4, 3, rotate); transform_list(data1->TQ, data1->NbTQ, data2->TQ, &data2->NbTQ, 4, 9, rotate); - // tets + // tets transform_list(data1->SS, data1->NbSS, data2->SS, &data2->NbSS, 4, 1, rotate); transform_list(data1->VS, data1->NbVS, data2->VS, &data2->NbVS, 4, 3, rotate); transform_list(data1->TS, data1->NbTS, data2->TS, &data2->NbTS, 4, 9, rotate); - // hexas + // hexas transform_list(data1->SH, data1->NbSH, data2->SH, &data2->NbSH, 8, 1, rotate); transform_list(data1->VH, data1->NbVH, data2->VH, &data2->NbVH, 8, 3, rotate); transform_list(data1->TH, data1->NbTH, data2->TH, &data2->NbTH, 8, 9, rotate); - // prisms + // prisms transform_list(data1->SI, data1->NbSI, data2->SI, &data2->NbSI, 6, 1, rotate); transform_list(data1->VI, data1->NbVI, data2->VI, &data2->NbVI, 6, 3, rotate); transform_list(data1->TI, data1->NbTI, data2->TI, &data2->NbTI, 6, 9, rotate); - // pyramids + // pyramids transform_list(data1->SY, data1->NbSY, data2->SY, &data2->NbSY, 5, 1, rotate); transform_list(data1->VY, data1->NbVY, data2->VY, &data2->NbVY, 5, 3, rotate); transform_list(data1->TY, data1->NbTY, data2->TY, &data2->NbTY, 5, 9, rotate); diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index 9e79310cedde9df626b75860594ad49d13acaeac..567a2ed789d17791f211e8d8cb5040f3de462c08 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -1,4 +1,4 @@ -// $Id: Triangulate.cpp,v 1.46 2008-03-01 01:32:03 geuzaine Exp $ +// $Id: Triangulate.cpp,v 1.47 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -59,12 +59,12 @@ void GMSH_TriangulatePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Triangulate) triangulates the points in the\n" - "view `iView', assuming that all the points belong\n" + "view `iView', assuming that all the points belong\n" "to a surface that can be projected one-to-one\n" - "onto a plane. If `iView' < 0, the plugin is run on\n" - "the current view.\n" - "\n" - "Plugin(Triangulate) creates one new view.\n"); + "onto a plane. If `iView' < 0, the plugin is run on\n" + "the current view.\n" + "\n" + "Plugin(Triangulate) creates one new view.\n"); } int GMSH_TriangulatePlugin::getNbOptions() const @@ -93,7 +93,7 @@ static void Project(MVertex *v, double mat[3][3]) } static void Triangulate(int nbIn, List_T *inList, int *nbOut, List_T *outList, - int nbTimeStep, int nbComp) + int nbTimeStep, int nbComp) { if(nbIn < 3) return; diff --git a/Plugin/Warp.cpp b/Plugin/Warp.cpp index 45a71a7f2f5e08ce2b9028891812c1c6784c8ac9..01144819bb6d47fe404a63b2342f8d87f05285ed 100644 --- a/Plugin/Warp.cpp +++ b/Plugin/Warp.cpp @@ -1,4 +1,4 @@ -// $Id: Warp.cpp,v 1.12 2008-02-17 08:48:08 geuzaine Exp $ +// $Id: Warp.cpp,v 1.13 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -58,17 +58,17 @@ void GMSH_WarpPlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Warp) transforms the elements in the\n" - "view `iView' by adding to their node coordinates\n" - "the vector field stored in the `TimeStep'-th time\n" - "step of the view `dView', scaled by `Factor'. If\n" - "`dView' < 0, the vector field is taken as the field\n" - "of surface normals multiplied by the `TimeStep'\n" - "value in `iView'. (The smoothing of the surface\n" - "normals is controlled by the `SmoothingAngle'\n" - "parameter.) If `iView' < 0, the plugin is run on\n" - "the current view.\n" - "\n" - "Plugin(Warp) is executed in-place.\n"); + "view `iView' by adding to their node coordinates\n" + "the vector field stored in the `TimeStep'-th time\n" + "step of the view `dView', scaled by `Factor'. If\n" + "`dView' < 0, the vector field is taken as the field\n" + "of surface normals multiplied by the `TimeStep'\n" + "value in `iView'. (The smoothing of the surface\n" + "normals is controlled by the `SmoothingAngle'\n" + "parameter.) If `iView' < 0, the plugin is run on\n" + "the current view.\n" + "\n" + "Plugin(Warp) is executed in-place.\n"); } int GMSH_WarpPlugin::getNbOptions() const @@ -87,7 +87,7 @@ void GMSH_WarpPlugin::catchErrorMessage(char *errorMessage) const } static void addNormals(List_T *listElm, int nbElm, int nbNod, - smooth_normals *normals) + smooth_normals *normals) { if(!nbElm || nbNod < 3) return; int nb = List_Nbr(listElm) / nbElm; @@ -103,16 +103,16 @@ static void addNormals(List_T *listElm, int nbElm, int nbNod, } static void warpList(List_T *iList, int iNbElm, - List_T *dList, int dNbElm, - int nbNod, double factor, int TimeStep, - int nbComp, smooth_normals *normals, double explode) + List_T *dList, int dNbElm, + int nbNod, double factor, int TimeStep, + int nbComp, smooth_normals *normals, double explode) { if(!iNbElm) return; if(!normals && (iNbElm != dNbElm)){ Msg(GERROR, "Views have a different number of elements (%d != %d)", - iNbElm, dNbElm); + iNbElm, dNbElm); return; } @@ -138,41 +138,41 @@ static void warpList(List_T *iList, int iNbElm, for(int k = 0; k < nbNod; k++) { if(normals){ - double d = 1.; - if(TimeStep >= 0){ - double *v = &val[nbComp * nbNod * TimeStep + nbComp * k]; - if(nbComp == 1) - d = v[0]; - else if(nbComp == 3) - d = sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2])); - else if(nbComp == 9) - d = ComputeVonMises(v); - } - normals->get(x[k], y[k], z[k], nn[0], nn[1], nn[2]); - x[k] += factor * d * nn[0]; - y[k] += factor * d * nn[1]; - z[k] += factor * d * nn[2]; + double d = 1.; + if(TimeStep >= 0){ + double *v = &val[nbComp * nbNod * TimeStep + nbComp * k]; + if(nbComp == 1) + d = v[0]; + else if(nbComp == 3) + d = sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2])); + else if(nbComp == 9) + d = ComputeVonMises(v); + } + normals->get(x[k], y[k], z[k], nn[0], nn[1], nn[2]); + x[k] += factor * d * nn[0]; + y[k] += factor * d * nn[1]; + z[k] += factor * d * nn[2]; } else{ - if(TimeStep < 0) TimeStep = 0; - x[k] += factor * val[3 * nbNod * TimeStep + 3 * k]; - y[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 1]; - z[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 2]; + if(TimeStep < 0) TimeStep = 0; + x[k] += factor * val[3 * nbNod * TimeStep + 3 * k]; + y[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 1]; + z[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 2]; } } if(explode != 1.){ double cg[3] = {0., 0., 0.}; for(int k = 0; k < nbNod; k++) { - cg[0] += x[k]; - cg[1] += y[k]; - cg[2] += z[k]; + cg[0] += x[k]; + cg[1] += y[k]; + cg[2] += z[k]; } for(int k = 0; k < 3; k++) cg[k] /= (double)nbNod; for(int k = 0; k < nbNod; k++) { - x[k] = cg[0] + explode * (x[k] - cg[0]); - y[k] = cg[1] + explode * (y[k] - cg[1]); - z[k] = cg[2] + explode * (z[k] - cg[2]); + x[k] = cg[0] + explode * (x[k] - cg[0]); + y[k] = cg[1] + explode * (y[k] - cg[1]); + z[k] = cg[2] + explode * (z[k] - cg[2]); } } @@ -181,7 +181,7 @@ static void warpList(List_T *iList, int iNbElm, } static void warp(PViewDataList *data1, PViewDataList *data2, double factor, - int ts, double tol, double e) + int ts, double tol, double e) { smooth_normals *nn = 0; if(WarpOptions_Number[4].def < 0){ @@ -202,7 +202,7 @@ static void warp(PViewDataList *data1, PViewDataList *data2, double factor, warpList(data1->SH, data1->NbSH, data2->VH, data2->NbVH, 8, factor, ts, 1, nn, e); warpList(data1->SI, data1->NbSI, data2->VI, data2->NbVI, 6, factor, ts, 1, nn, e); warpList(data1->SY, data1->NbSY, data2->VY, data2->NbVY, 5, factor, ts, 1, nn, e); - + warpList(data1->VP, data1->NbVP, data2->VP, data2->NbVP, 1, factor, ts, 3, nn, e); warpList(data1->VL, data1->NbVL, data2->VL, data2->NbVL, 2, factor, ts, 3, nn, e); warpList(data1->VT, data1->NbVT, data2->VT, data2->NbVT, 3, factor, ts, 3, nn, e); @@ -211,7 +211,7 @@ static void warp(PViewDataList *data1, PViewDataList *data2, double factor, warpList(data1->VH, data1->NbVH, data2->VH, data2->NbVH, 8, factor, ts, 3, nn, e); warpList(data1->VI, data1->NbVI, data2->VI, data2->NbVI, 6, factor, ts, 3, nn, e); warpList(data1->VY, data1->NbVY, data2->VY, data2->NbVY, 5, factor, ts, 3, nn, e); - + warpList(data1->TP, data1->NbTP, data2->VP, data2->NbVP, 1, factor, ts, 9, nn, e); warpList(data1->TL, data1->NbTL, data2->VL, data2->NbVL, 2, factor, ts, 9, nn, e); warpList(data1->TT, data1->NbTT, data2->VT, data2->NbVT, 3, factor, ts, 9, nn, e); diff --git a/Post/AdaptiveViews.cpp b/Post/AdaptiveViews.cpp index b014e8b0830dbf90bad798b1ebe6f475aea2d1ec..c092cdca5f554845d0c448c662511181d025638d 100644 --- a/Post/AdaptiveViews.cpp +++ b/Post/AdaptiveViews.cpp @@ -155,7 +155,7 @@ void adapt_edge::Recur_Create(adapt_edge *e, int maxlevel, int level, adapt_point *p1 = e->p[0]; adapt_point *p2 = e->p[1]; adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, - (p1->z + p2->z) * 0.5, coeffs, eexps); + (p1->z + p2->z) * 0.5, coeffs, eexps); adapt_edge *e1 = new adapt_edge(p1, p12); Recur_Create(e1, maxlevel, level, coeffs, eexps); adapt_edge *e2 = new adapt_edge(p12, p2); @@ -183,11 +183,11 @@ void adapt_triangle::Recur_Create(adapt_triangle *t, int maxlevel, int level, adapt_point *p2 = t->p[1]; adapt_point *p3 = t->p[2]; adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_point *p13 = adapt_point::New((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_point *p23 = adapt_point::New((p3->x + p2->x) * 0.5, (p3->y + p2->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_triangle *t1 = new adapt_triangle(p1, p12, p13); Recur_Create(t1, maxlevel, level, coeffs, eexps); adapt_triangle *t2 = new adapt_triangle(p2, p23, p12); @@ -221,16 +221,16 @@ void adapt_quad::Recur_Create(adapt_quad *q, int maxlevel, int level, adapt_point *p3 = q->p[2]; adapt_point *p4 = q->p[3]; adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_point *p23 = adapt_point::New((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_point *p34 = adapt_point::New((p3->x + p4->x) * 0.5, (p3->y + p4->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_point *p14 = adapt_point::New((p1->x + p4->x) * 0.5, (p1->y + p4->y) * 0.5, 0, - coeffs, eexps); + coeffs, eexps); adapt_point *pc = adapt_point::New((p1->x + p2->x + p3->x + p4->x) * 0.25, - (p1->y + p2->y + p3->y + p4->y) * 0.25, 0, - coeffs, eexps); + (p1->y + p2->y + p3->y + p4->y) * 0.25, 0, + coeffs, eexps); adapt_quad *q1 = new adapt_quad(p1, p12, pc, p14); Recur_Create(q1, maxlevel, level, coeffs, eexps); adapt_quad *q2 = new adapt_quad(p2, p23, pc, p12); @@ -256,17 +256,17 @@ void adapt_tet::Recur_Create(adapt_tet *t, int maxlevel, int level, adapt_point *p2 = t->p[2]; adapt_point *p3 = t->p[3]; adapt_point *pe0 = adapt_point::New((p0->x + p1->x) * 0.5, (p0->y + p1->y) * 0.5, - (p0->z + p1->z) * 0.5, coeffs, eexps); + (p0->z + p1->z) * 0.5, coeffs, eexps); adapt_point *pe1 = adapt_point::New((p0->x + p2->x) * 0.5, (p0->y + p2->y) * 0.5, - (p0->z + p2->z) * 0.5, coeffs, eexps); + (p0->z + p2->z) * 0.5, coeffs, eexps); adapt_point *pe2 = adapt_point::New((p0->x + p3->x) * 0.5, (p0->y + p3->y) * 0.5, - (p0->z + p3->z) * 0.5, coeffs, eexps); + (p0->z + p3->z) * 0.5, coeffs, eexps); adapt_point *pe3 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, - (p1->z + p2->z) * 0.5, coeffs, eexps); + (p1->z + p2->z) * 0.5, coeffs, eexps); adapt_point *pe4 = adapt_point::New((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5, - (p1->z + p3->z) * 0.5, coeffs, eexps); + (p1->z + p3->z) * 0.5, coeffs, eexps); adapt_point *pe5 = adapt_point::New((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, - (p2->z + p3->z) * 0.5, coeffs, eexps); + (p2->z + p3->z) * 0.5, coeffs, eexps); adapt_tet *t1 = new adapt_tet(p0, pe0, pe2, pe1); Recur_Create(t1, maxlevel, level, coeffs, eexps); @@ -311,48 +311,48 @@ void adapt_hex::Recur_Create(adapt_hex *h, int maxlevel, int level, adapt_point *p6 = h->p[6]; adapt_point *p7 = h->p[7]; adapt_point *p01 = adapt_point::New((p0->x + p1->x) * 0.5, (p0->y + p1->y) * 0.5, - (p0->z + p1->z) * 0.5, coeffs, eexps); + (p0->z + p1->z) * 0.5, coeffs, eexps); adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, - (p1->z + p2->z) * 0.5, coeffs, eexps); + (p1->z + p2->z) * 0.5, coeffs, eexps); adapt_point *p23 = adapt_point::New((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, - (p2->z + p3->z) * 0.5, coeffs, eexps); + (p2->z + p3->z) * 0.5, coeffs, eexps); adapt_point *p03 = adapt_point::New((p3->x + p0->x) * 0.5, (p3->y + p0->y) * 0.5, - (p3->z + p0->z) * 0.5, coeffs, eexps); + (p3->z + p0->z) * 0.5, coeffs, eexps); adapt_point *p45 = adapt_point::New((p4->x + p5->x) * 0.5, (p4->y + p5->y) * 0.5, - (p4->z + p5->z) * 0.5, coeffs, eexps); + (p4->z + p5->z) * 0.5, coeffs, eexps); adapt_point *p56 = adapt_point::New((p5->x + p6->x) * 0.5, (p5->y + p6->y) * 0.5, - (p5->z + p6->z) * 0.5, coeffs, eexps); + (p5->z + p6->z) * 0.5, coeffs, eexps); adapt_point *p67 = adapt_point::New((p6->x + p7->x) * 0.5, (p6->y + p7->y) * 0.5, - (p6->z + p7->z) * 0.5, coeffs, eexps); + (p6->z + p7->z) * 0.5, coeffs, eexps); adapt_point *p47 = adapt_point::New((p7->x + p4->x) * 0.5, (p7->y + p4->y) * 0.5, - (p7->z + p4->z) * 0.5, coeffs, eexps); + (p7->z + p4->z) * 0.5, coeffs, eexps); adapt_point *p04 = adapt_point::New((p4->x + p0->x) * 0.5, (p4->y + p0->y) * 0.5, - (p4->z + p0->z) * 0.5, coeffs, eexps); + (p4->z + p0->z) * 0.5, coeffs, eexps); adapt_point *p15 = adapt_point::New((p5->x + p1->x) * 0.5, (p5->y + p1->y) * 0.5, - (p5->z + p1->z) * 0.5, coeffs, eexps); + (p5->z + p1->z) * 0.5, coeffs, eexps); adapt_point *p26 = adapt_point::New((p6->x + p2->x) * 0.5, (p6->y + p2->y) * 0.5, - (p6->z + p2->z) * 0.5, coeffs, eexps); + (p6->z + p2->z) * 0.5, coeffs, eexps); adapt_point *p37 = adapt_point::New((p7->x + p3->x) * 0.5, (p7->y + p3->y) * 0.5, - (p7->z + p3->z) * 0.5, coeffs, eexps); + (p7->z + p3->z) * 0.5, coeffs, eexps); adapt_point *p0145 = adapt_point::New((p45->x + p01->x) * 0.5, (p45->y + p01->y) * 0.5, - (p45->z + p01->z) * 0.5, coeffs, eexps); + (p45->z + p01->z) * 0.5, coeffs, eexps); adapt_point *p1256 = adapt_point::New((p12->x + p56->x) * 0.5, (p12->y + p56->y) * 0.5, - (p12->z + p56->z) * 0.5, coeffs, eexps); + (p12->z + p56->z) * 0.5, coeffs, eexps); adapt_point *p2367 = adapt_point::New((p23->x + p67->x) * 0.5, (p23->y + p67->y) * 0.5, - (p23->z + p67->z) * 0.5, coeffs, eexps); + (p23->z + p67->z) * 0.5, coeffs, eexps); adapt_point *p0347 = adapt_point::New((p03->x + p47->x) * 0.5, (p03->y + p47->y) * 0.5, - (p03->z + p47->z) * 0.5, coeffs, eexps); + (p03->z + p47->z) * 0.5, coeffs, eexps); adapt_point *p4756 = adapt_point::New((p47->x + p56->x) * 0.5, (p47->y + p56->y) * 0.5, - (p47->z + p56->z) * 0.5, coeffs, eexps); + (p47->z + p56->z) * 0.5, coeffs, eexps); adapt_point *p0312 = adapt_point::New((p03->x + p12->x) * 0.5, (p03->y + p12->y) * 0.5, - (p03->z + p12->z) * 0.5, coeffs, eexps); + (p03->z + p12->z) * 0.5, coeffs, eexps); adapt_point *pc = adapt_point::New((p0->x + p1->x + p2->x + p3->x + p4->x + p5->x + p6->x + p7->x) * 0.125, - (p0->y + p1->y + p2->y + p3->y + p4->y + p5->y + p6->y + p7->y) * 0.125, - (p0->z + p1->z + p2->z + p3->z + p4->z + p5->z + p6->z + p7->z) * 0.125, - coeffs, eexps); + (p0->y + p1->y + p2->y + p3->y + p4->y + p5->y + p6->y + p7->y) * 0.125, + (p0->z + p1->z + p2->z + p3->z + p4->z + p5->z + p6->z + p7->z) * 0.125, + coeffs, eexps); adapt_hex *h1 = new adapt_hex(p0, p01, p0312, p03, p04, p0145, pc, p0347); //p0 Recur_Create(h1, maxlevel, level, coeffs, eexps); @@ -678,10 +678,10 @@ void adapt_hex::Recur_Error(adapt_hex *h, double AVG, double tol) template < class ELEM > int Adaptive_Post_View::zoomElement(int ielem, - int level, - int levelmax, - GMSH_Post_Plugin *plug, - List_T *theList, int *counter) + int level, + int levelmax, + GMSH_Post_Plugin *plug, + List_T *theList, int *counter) { const int nbNod = ELEM::nbNod; @@ -714,7 +714,7 @@ int Adaptive_Post_View::zoomElement(int ielem, valx(k) = (*_STvalX)(ielem, k); valy(k) = (*_STvalY)(ielem, k); valz(k) = (*_STvalZ)(ielem, k); - } + } _Interpolate->mult(valx, resx); _Interpolate->mult(valy, resy); _Interpolate->mult(valz, resz); @@ -771,14 +771,14 @@ int Adaptive_Post_View::zoomElement(int ielem, for(int k=0; k < nbNod; ++k) List_Add(theList, &p[k]->Y); for(int k=0; k < nbNod; ++k) List_Add(theList, &p[k]->Z); if(_STvalX){ - for(int k = 0; k < nbNod; ++k){ - List_Add(theList, &p[k]->valx); - List_Add(theList, &p[k]->valy); - List_Add(theList, &p[k]->valz); - } + for(int k = 0; k < nbNod; ++k){ + List_Add(theList, &p[k]->valx); + List_Add(theList, &p[k]->valy); + List_Add(theList, &p[k]->valz); + } } else{ - for (int k = 0; k < nbNod; ++k) List_Add(theList, &p[k]->val); + for (int k = 0; k < nbNod; ++k) List_Add(theList, &p[k]->val); } (*counter)++; } @@ -819,7 +819,7 @@ void Adaptive_Post_View::setAdaptiveResolutionLevel(PViewDataList *data, int lev TYP = 5; List_Delete(data->VT); data->NbVT = 0; - data->VT = List_Create(nbelm * 36, nbelm , sizeof(double)); + data->VT = List_Create(nbelm * 36, nbelm , sizeof(double)); } else if(data->NbST) { TYP = 1; @@ -857,25 +857,25 @@ void Adaptive_Post_View::setAdaptiveResolutionLevel(PViewDataList *data, int lev while(1){ if(TYP == 7) setAdaptiveResolutionLevel_TEMPL<adapt_edge>(level_act, level, plug, - &(data->SL), &(data->NbSL), done); + &(data->SL), &(data->NbSL), done); if(TYP == 1) setAdaptiveResolutionLevel_TEMPL<adapt_triangle>(level_act, level, plug, - &(data->ST), &(data->NbST), done); + &(data->ST), &(data->NbST), done); if(TYP == 5) setAdaptiveResolutionLevel_TEMPL<adapt_triangle>(level_act, level, plug, - &(data->VT), &(data->NbVT), done); + &(data->VT), &(data->NbVT), done); if(TYP == 2) setAdaptiveResolutionLevel_TEMPL<adapt_quad>(level_act, level, plug, - &(data->SQ), &(data->NbSQ), done); + &(data->SQ), &(data->NbSQ), done); if(TYP == 6) setAdaptiveResolutionLevel_TEMPL<adapt_quad>(level_act, level, plug, - &(data->VQ), &(data->NbVQ), done); + &(data->VQ), &(data->NbVQ), done); if(TYP == 4) setAdaptiveResolutionLevel_TEMPL<adapt_hex>(level_act, level, plug, - &(data->SH), &(data->NbSH), done); + &(data->SH), &(data->NbSH), done); if(TYP == 3) setAdaptiveResolutionLevel_TEMPL<adapt_tet>(level_act, level, plug, - &(data->SS), &(data->NbSS), done); + &(data->SS), &(data->NbSS), done); int nbDone = 0; for(int i = 0; i < _STposX->size1(); ++i) nbDone += done[i]; if(nbDone == _STposX->size1()) break; @@ -893,9 +893,9 @@ void Adaptive_Post_View::setAdaptiveResolutionLevel(PViewDataList *data, int lev template<class ELEM> void Adaptive_Post_View::setAdaptiveResolutionLevel_TEMPL(int level, int levelmax, - GMSH_Post_Plugin *plug, - List_T **myList, - int *counter, int *done) + GMSH_Post_Plugin *plug, + List_T **myList, + int *counter, int *done) { const int N = _coefs->size1(); const int nbelm = _STposX->size1(); @@ -979,16 +979,16 @@ void Adaptive_Post_View::initWithLowResolution(PViewDataList *data) nbelm = data->NbSH; nbnod = 8; } - else if(data->NbSI){ - myList = data->SI; - nbelm = data->NbSI; - nbnod = 6; - } - else if(data->NbVI){ - myList = data->VI; - nbelm = data->NbVI; - nbnod = 6; - } + else if(data->NbSI){ + myList = data->SI; + nbelm = data->NbSI; + nbnod = 6; + } + else if(data->NbVI){ + myList = data->VI; + nbelm = data->NbVI; + nbnod = 6; + } else return; // if there exists a polynomial representation @@ -1027,22 +1027,22 @@ void Adaptive_Post_View::initWithLowResolution(PViewDataList *data) double *val = (double*)List_Pointer_Fast(myList, i + 3 * nbnod); if(nbComp == 1){ for(int j = 0; j < (nb - 3 * nbnod) / nbComp; j++){ - (*_STval)(k, j) = val[j]; - } + (*_STval)(k, j) = val[j]; + } } else if(nbComp == 3){ int size = (nb - 3 * nbnod) / 3; for(int j = 0; j < size; j++){ - int index1 = j; - int index2 = j + size; - int index3 = j + 2 * size; - // adaptation of the visualization mesh bases on the norm squared of the vector - (*_STval)(k, j) = (val[index1] * val[index1] + val[index2] * val[index2] + - val[index3] * val[index3]); - (*_STvalX)(k, j) = val[index1]; - (*_STvalY)(k, j) = val[index2]; - (*_STvalZ)(k, j) = val[index3]; - } + int index1 = j; + int index2 = j + size; + int index3 = j + 2 * size; + // adaptation of the visualization mesh bases on the norm squared of the vector + (*_STval)(k, j) = (val[index1] * val[index1] + val[index2] * val[index2] + + val[index3] * val[index3]); + (*_STvalX)(k, j) = val[index1]; + (*_STvalY)(k, j) = val[index2]; + (*_STvalZ)(k, j) = val[index3]; + } } k++; } @@ -1050,10 +1050,10 @@ void Adaptive_Post_View::initWithLowResolution(PViewDataList *data) } Adaptive_Post_View::Adaptive_Post_View(PViewDataList *data, - List_T *_c, + List_T *_c, List_T *_pol, - List_T *_cGeom, - List_T *_polGeom) + List_T *_cGeom, + List_T *_polGeom) : tol(1.e-3), _coefsGeom(0), _eexpsGeom(0) { @@ -1098,9 +1098,9 @@ Adaptive_Post_View::Adaptive_Post_View(PViewDataList *data, (*_eexpsGeom)(i, 1) = dpowv; (*_eexpsGeom)(i, 2) = dpoww; for(int j = 0; j < List_Nbr(*line); ++j) { - double val; - List_Read(*line, j, &val); - (*_coefsGeom)(i, j) = val; + double val; + List_Read(*line, j, &val); + (*_coefsGeom)(i, j) = val; } } } diff --git a/Post/AdaptiveViews.h b/Post/AdaptiveViews.h index 9804e6f009e6e3d7e70efbe160a7bdf70f93755d..3708ef8e108721df8b2a4fb654b4fb987dd58d23 100644 --- a/Post/AdaptiveViews.h +++ b/Post/AdaptiveViews.h @@ -40,7 +40,7 @@ class adapt_point double X, Y, Z, val, valx, valy, valz; double shape_functions[128]; static adapt_point *New(double x, double y, double z, - Double_Matrix *coeffs, Double_Matrix *eexps); + Double_Matrix *coeffs, Double_Matrix *eexps); bool operator < (const adapt_point &other) const { if(other.x < x) return true; @@ -74,7 +74,7 @@ class adapt_edge } static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps); static void Recur_Create(adapt_edge *e, int maxlevel, int level, - Double_Matrix *coeffs, Double_Matrix *eexps); + Double_Matrix *coeffs, Double_Matrix *eexps); static void Error(double AVG, double tol); static void Recur_Error(adapt_edge *e, double AVG, double tol); bool visible; @@ -107,7 +107,7 @@ class adapt_triangle } static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps); static void Recur_Create(adapt_triangle *t, int maxlevel, int level, - Double_Matrix *coeffs, Double_Matrix *eexps); + Double_Matrix *coeffs, Double_Matrix *eexps); static void Error(double AVG, double tol); static void Recur_Error(adapt_triangle *t, double AVG, double tol); bool visible; @@ -142,7 +142,7 @@ class adapt_quad } static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps); static void Recur_Create(adapt_quad *q, int maxlevel, int level, - Double_Matrix *coeffs, Double_Matrix *eexps); + Double_Matrix *coeffs, Double_Matrix *eexps); static void Error(double AVG, double tol); static void Recur_Error(adapt_quad *q, double AVG, double tol); bool visible; @@ -178,7 +178,7 @@ class adapt_tet } static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps); static void Recur_Create(adapt_tet *t, int maxlevel, int level, - Double_Matrix *coeffs, Double_Matrix *eexps); + Double_Matrix *coeffs, Double_Matrix *eexps); static void Error(double AVG, double tol); static void Recur_Error(adapt_tet *t, double AVG, double tol); bool visible; @@ -192,7 +192,7 @@ class adapt_hex { public: adapt_hex(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4, - adapt_point *p5, adapt_point *p6, adapt_point *p7, adapt_point *p8) + adapt_point *p5, adapt_point *p6, adapt_point *p7, adapt_point *p8) : visible(false) { p[0] = p1; @@ -220,11 +220,11 @@ class adapt_hex inline double V() const { return (p[0]->val + p[1]->val + p[2]->val+ p[3]->val + - p[4]->val + p[5]->val + p[6]->val+ p[7]->val) / 8.; + p[4]->val + p[5]->val + p[6]->val+ p[7]->val) / 8.; } static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps); static void Recur_Create(adapt_hex *h, int maxlevel, int level, - Double_Matrix *coeffs, Double_Matrix *eexps); + Double_Matrix *coeffs, Double_Matrix *eexps); static void Error(double AVG, double tol); static void Recur_Error(adapt_hex *h, double AVG, double tol); bool visible; @@ -256,7 +256,7 @@ class Adaptive_Post_View Double_Matrix *_Geometry; public: Adaptive_Post_View(PViewDataList *data, List_T *_coeffs, List_T *_eexps, - List_T *_coeffsGeom=0, List_T *_eexpsGeom=0); + List_T *_coeffsGeom=0, List_T *_eexpsGeom=0); ~Adaptive_Post_View(); int getGlobalResolutionLevel() const { return presentZoomLevel; } void setGlobalResolutionLevel(PViewDataList *data, int level) @@ -264,17 +264,17 @@ public: setAdaptiveResolutionLevel(data, level); } void setAdaptiveResolutionLevel(PViewDataList *data, int levelmax, - GMSH_Post_Plugin *plug=0); + GMSH_Post_Plugin *plug=0); template <class ELEM> void setAdaptiveResolutionLevel_TEMPL(int level, int lemvelmax, - GMSH_Post_Plugin *plug, List_T **myList, - int *counter, int *done); + GMSH_Post_Plugin *plug, List_T **myList, + int *counter, int *done); void initWithLowResolution(PViewDataList *data); void setTolerance(const double eps) { tol = eps; } double getTolerance() const { return tol; } template <class ELEM> int zoomElement(int ielem, int level, int levelmax, - GMSH_Post_Plugin *plug, List_T *theList, int *counter); + GMSH_Post_Plugin *plug, List_T *theList, int *counter); }; template <class ELEM> diff --git a/Post/ColorTable.cpp b/Post/ColorTable.cpp index f0c4d7834b7155a923ed312424fb02ac4b6e9594..5d852f68ef767a8343caff07f1a8aea1bc3573fb 100644 --- a/Post/ColorTable.cpp +++ b/Post/ColorTable.cpp @@ -1,4 +1,4 @@ -// $Id: ColorTable.cpp,v 1.4 2008-02-17 08:48:08 geuzaine Exp $ +// $Id: ColorTable.cpp,v 1.5 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -110,132 +110,132 @@ void ColorTable_Recompute(GmshColorTable * ct) break; case 2: // matlab "jet" { - double ii = (double)(s - bias) * 128.; - if(ii < 0) ii = 0; - if(ii > 128) ii = 128; - double rr = - ii <= 46 ? 0. : - ii >= 111 ? -0.03125 * (ii - 111) + 1. : - ii >= 78 ? 1. : - 0.03125 * (ii - 46); - double gg = - ii <= 14 || ii >= 111 ? 0. : - ii >= 79 ? -0.03125 * (ii - 111) : - ii <= 46 ? 0.03125 * (ii - 14) : - 1.; - double bb = - ii >= 79 ? 0. : - ii >= 47 ? -0.03125 * (ii - 79) : - ii <= 14 ? 0.03125 * (ii - 14) + 1.: - 1.; - r = (int)(rr * 255.); - g = (int)(gg * 255.); - b = (int)(bb * 255.); + double ii = (double)(s - bias) * 128.; + if(ii < 0) ii = 0; + if(ii > 128) ii = 128; + double rr = + ii <= 46 ? 0. : + ii >= 111 ? -0.03125 * (ii - 111) + 1. : + ii >= 78 ? 1. : + 0.03125 * (ii - 46); + double gg = + ii <= 14 || ii >= 111 ? 0. : + ii >= 79 ? -0.03125 * (ii - 111) : + ii <= 46 ? 0.03125 * (ii - 14) : + 1.; + double bb = + ii >= 79 ? 0. : + ii >= 47 ? -0.03125 * (ii - 79) : + ii <= 14 ? 0.03125 * (ii - 14) + 1.: + 1.; + r = (int)(rr * 255.); + g = (int)(gg * 255.); + b = (int)(bb * 255.); } break; case 3: // lucie, samcef (?) if(s - bias <= 0.) { - r = 0; - g = 0; - b = 255; + r = 0; + g = 0; + b = 255; } else if(s - bias <= 0.40) { - r = 0; - g = (int)((s - bias) * 637.5); - b = (int)(255. - (s - bias) * 637.5); + r = 0; + g = (int)((s - bias) * 637.5); + b = (int)(255. - (s - bias) * 637.5); } else if(s - bias <= 0.60) { - r = (int)(1275. * (s - bias - 0.4)); - g = 255; - b = 0; + r = (int)(1275. * (s - bias - 0.4)); + g = 255; + b = 0; } else if(s - bias <= 1.) { - r = 255; - g = (int)(255. - 637.5 * (s - bias - 0.6)); - b = 0; + r = 255; + g = (int)(255. - 637.5 * (s - bias - 0.6)); + b = 0; } else { - r = 255; - g = 0; - b = 0; + r = 255; + g = 0; + b = 0; } break; case 4: // rainbow if(s - bias <= 0.) { - r = 0; - g = 0; - b = 255; + r = 0; + g = 0; + b = 255; } else if(s - bias <= 0.25 + curvature) { - curvature = (curvature == -0.25) ? -0.26 : curvature; - r = 0; - g = (int)((s - bias) * (255. / (0.25 + curvature))); - b = 255; + curvature = (curvature == -0.25) ? -0.26 : curvature; + r = 0; + g = (int)((s - bias) * (255. / (0.25 + curvature))); + b = 255; } else if(s - bias <= 0.50) { - curvature = (curvature == 0.25) ? 0.26 : curvature; - r = 0; - g = 255; - b = (int)(255. - (255. / (0.25 - curvature)) * (s - bias - 0.25 - curvature)); + curvature = (curvature == 0.25) ? 0.26 : curvature; + r = 0; + g = 255; + b = (int)(255. - (255. / (0.25 - curvature)) * (s - bias - 0.25 - curvature)); } else if(s - bias <= 0.75 - curvature) { - curvature = (curvature == 0.25) ? 0.26 : curvature; - r = (int)((s - bias - 0.5) * (255. / (0.25 - curvature))); - g = 255; - b = 0; + curvature = (curvature == 0.25) ? 0.26 : curvature; + r = (int)((s - bias - 0.5) * (255. / (0.25 - curvature))); + g = 255; + b = 0; } else if(s - bias <= 1.) { - curvature = (curvature == -0.25) ? -0.26 : curvature; - r = 255; - g = (int)(255. - (255. / (0.25 + curvature)) * (s - bias - 0.75 + curvature)); - b = 0; + curvature = (curvature == -0.25) ? -0.26 : curvature; + r = 255; + g = (int)(255. - (255. / (0.25 + curvature)) * (s - bias - 0.75 + curvature)); + b = 0; } else { - r = 255; - g = 0; - b = 0; + r = 255; + g = 0; + b = 0; } break; case 5: // emc2000 (rainbow with black and white) if(s - bias <= 0.) { - r = 0; - g = 0; - b = 0; + r = 0; + g = 0; + b = 0; } else if(s - bias <= 0.2) { - r = (int)(57 * (1 - 100 * ((s - bias) - 0.1) * ((s - bias) - 0.1))); - g = 0; - b = (int)((s - bias) * (255. / 0.2)); + r = (int)(57 * (1 - 100 * ((s - bias) - 0.1) * ((s - bias) - 0.1))); + g = 0; + b = (int)((s - bias) * (255. / 0.2)); } else if(s - bias <= 0.3624) { - r = 0; - g = (int)((s - bias - 0.2) * (255. / 0.1624)); - b = 255; + r = 0; + g = (int)((s - bias - 0.2) * (255. / 0.1624)); + b = 255; } else if(s - bias <= 0.50) { - r = 0; - g = 255; - b = (int)(255. - (255. / 0.1376) * (s - bias - 0.3624)); + r = 0; + g = 255; + b = (int)(255. - (255. / 0.1376) * (s - bias - 0.3624)); } else if(s - bias <= 0.6376) { - r = (int)((s - bias - 0.5) * (255. / 0.1376)); - g = 255; - b = 0; + r = (int)((s - bias - 0.5) * (255. / 0.1376)); + g = 255; + b = 0; } else if(s - bias <= 0.8) { - r = 255; - g = (int)(255. - (255. / 0.1624) * (s - bias - 0.6376)); - b = 0; + r = 255; + g = (int)(255. - (255. / 0.1624) * (s - bias - 0.6376)); + b = 0; } else if(s - bias <= 1.0) { - r = 255; - g = (int)((255. / 0.2) * (s - bias - 0.8)); - b = (int)(-3187.66 * (s - bias) * (s - bias) + 7012.76 * (s - bias) - 3570.61); + r = 255; + g = (int)((255. / 0.2) * (s - bias - 0.8)); + b = (int)(-3187.66 * (s - bias) * (s - bias) + 7012.76 * (s - bias) - 3570.61); } else { - r = 255; - g = 255; - b = 255; + r = 255; + g = 255; + b = 255; } break; case 6: // darkblue->red->yellow->white @@ -255,13 +255,13 @@ void ColorTable_Recompute(GmshColorTable * ct) break; case 9: // grayscale if(s - bias <= 0.) { - r = g = b = 0; + r = g = b = 0; } else if(s - bias <= 1.) { - r = g = b = (int)(255 * (1. - curvature) * (s - bias)); + r = g = b = (int)(255 * (1. - curvature) * (s - bias)); } else { - r = g = b = (int)(255 * (1. - curvature)); + r = g = b = (int)(255 * (1. - curvature)); } break; case 10: // all white @@ -269,20 +269,20 @@ void ColorTable_Recompute(GmshColorTable * ct) break; case 11: // matlab "hsv" { - double H = 6. * s + 1.e-10, R, G, B; - HSV_to_RGB(H, 1., 1., &R, &G, &B); - r = (int)(255 * R); - g = (int)(255 * G); - b = (int)(255 * B); + double H = 6. * s + 1.e-10, R, G, B; + HSV_to_RGB(H, 1., 1., &R, &G, &B); + r = (int)(255 * R); + g = (int)(255 * G); + b = (int)(255 * B); } break; case 12: // spectrum (truncated hsv) { - double H = 5. * s + 1.e-10, R, G, B; - HSV_to_RGB(H, 1., 1., &R, &G, &B); - r = (int)(255 * R); - g = (int)(255 * G); - b = (int)(255 * B); + double H = 5. * s + 1.e-10, R, G, B; + HSV_to_RGB(H, 1., 1., &R, &G, &B); + r = (int)(255 * R); + g = (int)(255 * G); + b = (int)(255 * B); } break; case 13: // matlab "bone" @@ -332,9 +332,9 @@ void ColorTable_Recompute(GmshColorTable * ct) if(ct->dpar[COLORTABLE_BETA]) { if(ct->dpar[COLORTABLE_BETA] > 0.0) - gamma = 1. - ct->dpar[COLORTABLE_BETA]; + gamma = 1. - ct->dpar[COLORTABLE_BETA]; else - gamma = 1. / (1.001 + ct->dpar[COLORTABLE_BETA]); // beta is thresholded to [-1,1] + gamma = 1. / (1.001 + ct->dpar[COLORTABLE_BETA]); // beta is thresholded to [-1,1] r = (int)(255. * pow((double)r / 255., gamma)); g = (int)(255. * pow((double)g / 255., gamma)); b = (int)(255. * pow((double)b / 255., gamma)); @@ -426,7 +426,7 @@ int ColorTable_IsAlpha(GmshColorTable * ct) // HSV/RBG conversion routines void HSV_to_RGB(double H, double S, double V, - double *R, double *G, double *B) + double *R, double *G, double *B) { if(S < 5.0e-6) { *R = *G = *B = V; @@ -449,7 +449,7 @@ void HSV_to_RGB(double H, double S, double V, } void RGB_to_HSV(double R, double G, double B, - double *H, double *S, double *V) + double *H, double *S, double *V) { double maxv = R > G ? R : G; if(B > maxv) maxv = B; *V = maxv; diff --git a/Post/ColorTable.h b/Post/ColorTable.h index b76498d815904b8e4a9b8f4363ca033aac6ae14a..fb793f4a3da5a692f83fee66eafb86837c73af3f 100644 --- a/Post/ColorTable.h +++ b/Post/ColorTable.h @@ -62,8 +62,8 @@ int ColorTable_IsAlpha(GmshColorTable *ct) ; int ColorTable_Diff(GmshColorTable *ct1, GmshColorTable *ct2); void RGB_to_HSV(double R, double G, double B, - double *H, double *S, double *V); + double *H, double *S, double *V); void HSV_to_RGB(double H, double S, double V, - double *R, double *G, double *B); + double *R, double *G, double *B); #endif diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp index 57bc8e66bac1fea1a5e668511f82ec54cb7f77b0..2dd1b461f864ab7f69e25e39126a8bf746e0a3ff 100644 --- a/Post/OctreePost.cpp +++ b/Post/OctreePost.cpp @@ -1,4 +1,4 @@ -// $Id: OctreePost.cpp,v 1.6 2008-03-20 10:52:36 geuzaine Exp $ +// $Id: OctreePost.cpp,v 1.7 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -34,7 +34,7 @@ // helper routines for list-based views static void minmax(int n, double *X, double *Y, double *Z, - double *min, double *max) + double *min, double *max) { min[0] = X[0]; min[1] = Y[0]; @@ -283,8 +283,8 @@ OctreePost::OctreePost(PView *v) double min[3] = {bb.min().x(), bb.min().y(), bb.min().z()}; double size[3] = {bb.max().x() - bb.min().x(), - bb.max().y() - bb.min().y(), - bb.max().z() - bb.min().z()}; + bb.max().y() - bb.min().y(), + bb.max().z() - bb.min().z()}; const int maxElePerBucket = 100; // memory vs. speed trade-off @@ -364,11 +364,13 @@ OctreePost::OctreePost(PView *v) else{ _theViewDataGModel = dynamic_cast<PViewDataGModel*>(_theView->getData()); if(_theViewDataGModel){ + // we should think about storing the octree in the model, so + // that we can reuse it multiple times _GModel = Octree_Create(maxElePerBucket, min, size, - MElementBB, MElementCentroid, MElementInEle); + MElementBB, MElementCentroid, MElementInEle); for(int i = 0; i < _theViewDataGModel->getNumEntities(0); i++) - for(int j = 0; j < _theViewDataGModel->getEntity(0, i)->getNumMeshElements(); j++) - Octree_Insert(_theViewDataGModel->getEntity(0, i)->getMeshElement(j), _GModel); + for(int j = 0; j < _theViewDataGModel->getEntity(0, i)->getNumMeshElements(); j++) + Octree_Insert(_theViewDataGModel->getEntity(0, i)->getMeshElement(j), _GModel); Octree_Arrange(_GModel); } } @@ -376,8 +378,8 @@ OctreePost::OctreePost(PView *v) } bool OctreePost::_getValue(void *in, int dim, int nbNod, int nbComp, - double P[3], int step, double *values, - double *elementSize) + double P[3], int step, double *values, + double *elementSize) { if(!in) return false; @@ -391,13 +393,13 @@ bool OctreePost::_getValue(void *in, int dim, int nbNod, int nbComp, if(step < 0){ for(int i = 0; i < _theViewDataList->getNumTimeSteps(); i++) for(int j = 0; j < nbComp; j++) - values[nbComp * i + j] = e->interpolate(&V[nbNod * nbComp * i + j], - U[0], U[1], U[2], nbComp); + values[nbComp * i + j] = e->interpolate(&V[nbNod * nbComp * i + j], + U[0], U[1], U[2], nbComp); } else{ for(int j = 0; j < nbComp; j++) values[j] = e->interpolate(&V[nbNod * nbComp * step + j], - U[0], U[1], U[2], nbComp); + U[0], U[1], U[2], nbComp); } if(elementSize) *elementSize = e->maxEdgeLength(); @@ -407,7 +409,7 @@ bool OctreePost::_getValue(void *in, int dim, int nbNod, int nbComp, } bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, double *values, - double *elementSize) + double *elementSize) { if(!in) return false; @@ -428,18 +430,18 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, doub for(int step = 0; step < _theViewDataGModel->getNumTimeSteps(); step++){ if(timestep < 0 || step == timestep){ for(int nod = 0; nod < e->getNumVertices(); nod++){ - for(int comp = 0; comp < nbComp; comp++){ - if(!_theViewDataGModel->getValue(step, dataIndex[nod], comp, - nodeval[nod*nbComp+comp])) - return false; - } + for(int comp = 0; comp < nbComp; comp++){ + if(!_theViewDataGModel->getValue(step, dataIndex[nod], comp, + nodeval[nod*nbComp+comp])) + return false; + } } for(int comp = 0; comp < nbComp; comp++){ - double val = e->interpolate(nodeval, U[0], U[1], U[2], nbComp); - if(timestep < 0) - values[nbComp * step + comp] = val; - else - values[comp] = val; + double val = e->interpolate(nodeval, U[0], U[1], U[2], nbComp); + if(timestep < 0) + values[nbComp * step + comp] = val; + else + values[comp] = val; } } } @@ -449,7 +451,7 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, doub } bool OctreePost::searchScalar(double x, double y, double z, double *values, - int step, double *size) + int step, double *size) { double P[3] = {x, y, z}; @@ -476,7 +478,7 @@ bool OctreePost::searchScalar(double x, double y, double z, double *values, } bool OctreePost::searchVector(double x, double y, double z, double *values, - int step, double *size) + int step, double *size) { double P[3] = {x, y, z}; @@ -504,7 +506,7 @@ bool OctreePost::searchVector(double x, double y, double z, double *values, } bool OctreePost::searchTensor(double x, double y, double z, double *values, - int step, double *size) + int step, double *size) { double P[3] = {x, y, z}; diff --git a/Post/OctreePost.h b/Post/OctreePost.h index cd8d008fb337b6fdf7d98801b14d1341f7ff7593..110edff831e2af42f2d4ea61c99639432e6c23f0 100644 --- a/Post/OctreePost.h +++ b/Post/OctreePost.h @@ -41,10 +41,10 @@ class OctreePost PViewDataList *_theViewDataList; PViewDataGModel *_theViewDataGModel; bool _getValue(void *in, int dim, int nbNod, int nbComp, - double P[3], int step, double *values, - double *elementSize); + double P[3], int step, double *values, + double *elementSize); bool _getValue(void *in, int nbComp, double P[3], int step, - double *values, double *elementSize); + double *values, double *elementSize); public : OctreePost(PView *); ~OctreePost(); @@ -54,11 +54,11 @@ class OctreePost // interpolated unless time step is set to a different value than // -1. bool searchScalar(double x, double y, double z, double *values, - int step = -1, double *size = 0); + int step = -1, double *size = 0); bool searchVector(double x, double y, double z, double *values, - int step = -1, double *size = 0); + int step = -1, double *size = 0); bool searchTensor(double x, double y, double z, double *values, - int step = -1, double *size = 0); + int step = -1, double *size = 0); }; #endif diff --git a/Post/PView.cpp b/Post/PView.cpp index 0192373d4978274a82fa51ef58864458064f46cf..5044e2e35cfced0a74bafbfa739e97b31e4ed631 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -1,4 +1,4 @@ -// $Id: PView.cpp,v 1.24 2008-03-19 16:38:16 geuzaine Exp $ +// $Id: PView.cpp,v 1.25 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -73,7 +73,7 @@ PView::PView(PView *ref, bool copyOptions) } PView::PView(std::string xname, std::string yname, - std::vector<double> &x, std::vector<double> &y) + std::vector<double> &x, std::vector<double> &y) { _init(); PViewDataList *data = new PViewDataList(true); @@ -125,7 +125,7 @@ PView::~PView() if(_aliasOf) for(unsigned int i = 0; i < list.size(); i++) if(list[i]->getNum() == _aliasOf || list[i]->getAliasOf() == _aliasOf) - return; + return; Msg(DEBUG, "Deleting data in View[%d] (unique num = %d)", _index, _num); delete _data; @@ -171,24 +171,24 @@ void PView::combine(bool time, int how, bool remove) // this will lead to weird results if there are views named // "__all__" or "__vis__" :-) if(how == 2) - nd.name = data->getName(); + nd.name = data->getName(); else if(how == 1) - nd.name = "__all__"; + nd.name = "__all__"; else - nd.name = "__vis__"; + nd.name = "__vis__"; unsigned int j = 0; while(j < nds.size()){ - if(nds[j].name == nd.name){ - nds[j].data.push_back(data); - nds[j].indices.push_back(i); - break; - } - j++; + if(nds[j].name == nd.name){ + nds[j].data.push_back(data); + nds[j].indices.push_back(i); + break; + } + j++; } if(j == nds.size()){ - nd.data.push_back(data); - nd.indices.push_back(i); - nds.push_back(nd); + nd.data.push_back(data); + nd.indices.push_back(i); + nds.push_back(nd); } } } @@ -201,10 +201,10 @@ void PView::combine(bool time, int how, bool remove) PViewData *data = p->getData(); bool res = time ? data->combineTime(nds[i]): data->combineSpace(nds[i]); if(res) - for(unsigned int j = 0; j < nds[i].indices.size(); j++) - rm.insert(list[nds[i].indices[j]]); + for(unsigned int j = 0; j < nds[i].indices.size(); j++) + rm.insert(list[nds[i].indices[j]]); else - delete p; + delete p; } } if(remove) @@ -217,7 +217,7 @@ PView *PView::getViewByName(std::string name, int timeStep, int partition) for(unsigned int i = 0; i < list.size(); i++){ if(list[i]->getData()->getName() == name && ((timeStep < 0 || !list[i]->getData()->hasTimeStep(timeStep)) || - (partition < 0 || !list[i]->getData()->hasPartition(partition)))) + (partition < 0 || !list[i]->getData()->hasPartition(partition)))) return list[i]; } return 0; @@ -275,24 +275,24 @@ bool PView::readPOS(std::string fileName, int fileIndex) index++; if(fileIndex < 0 || fileIndex == index){ - PViewDataList *d = new PViewDataList(false); - if(!d->readPOS(fp, version, format, size)){ - Msg(GERROR, "Could not read data in list format"); - delete d; - return false; - } - else{ - d->setFileName(fileName); - d->setFileIndex(index); - new PView(d); - } + PViewDataList *d = new PViewDataList(false); + if(!d->readPOS(fp, version, format, size)){ + Msg(GERROR, "Could not read data in list format"); + delete d; + return false; + } + else{ + d->setFileName(fileName); + d->setFileIndex(index); + new PView(d); + } } } do { if(!fgets(str, sizeof(str), fp) || feof(fp)) - break; + break; } while(str[0] != '$'); } @@ -318,7 +318,7 @@ bool PView::readMSH(std::string fileName, int fileIndex) while(str[0] != '$'){ if(!fgets(str, sizeof(str), fp) || feof(fp)) - break; + break; } if(feof(fp)) @@ -330,51 +330,51 @@ bool PView::readMSH(std::string fileName, int fileIndex) int format, size; if(sscanf(str, "%lf %d %d", &version, &format, &size) != 3) return false; if(format){ - binary = true; - Msg(INFO, "Mesh is in binary format"); - int one; - if(fread(&one, sizeof(int), 1, fp) != 1) return 0; - if(one != 1){ - swap = true; - Msg(INFO, "Swapping bytes from binary file"); - } + binary = true; + Msg(INFO, "Mesh is in binary format"); + int one; + if(fread(&one, sizeof(int), 1, fp) != 1) return 0; + if(one != 1){ + swap = true; + Msg(INFO, "Swapping bytes from binary file"); + } } } else if(!strncmp(&str[1], "NodeData", 8)) { index++; if(fileIndex < 0 || fileIndex == index){ - // read data info - if(!fgets(str, sizeof(str), fp)) return false; - std::string name = extractDoubleQuotedString(str, sizeof(str)); - int timeStep, partition, interpolationScheme, numComp, numNodes; - double time; - if(!fgets(str, sizeof(str), fp)) return false; - if(sscanf(str, "%d %lf %d %d %d %d", &timeStep, &time, &partition, - &interpolationScheme, &numComp, &numNodes) != 6) return false; - // either get existing viewData, or create new one - PView *p = getViewByName(name, timeStep, partition); - PViewDataGModel *d = 0; - if(p) d = dynamic_cast<PViewDataGModel*>(p->getData()); - bool create = d ? false : true; - if(create) d = new PViewDataGModel(); - if(!d->readMSH(fileName, fileIndex, fp, binary, swap, timeStep, - time, partition, numComp, numNodes)){ - Msg(GERROR, "Could not read data in msh file"); - if(create) delete d; - return false; - } - else{ - d->setName(name); - d->setFileName(fileName); - d->setFileIndex(index); - if(create) new PView(d); - } + // read data info + if(!fgets(str, sizeof(str), fp)) return false; + std::string name = extractDoubleQuotedString(str, sizeof(str)); + int timeStep, partition, interpolationScheme, numComp, numNodes; + double time; + if(!fgets(str, sizeof(str), fp)) return false; + if(sscanf(str, "%d %lf %d %d %d %d", &timeStep, &time, &partition, + &interpolationScheme, &numComp, &numNodes) != 6) return false; + // either get existing viewData, or create new one + PView *p = getViewByName(name, timeStep, partition); + PViewDataGModel *d = 0; + if(p) d = dynamic_cast<PViewDataGModel*>(p->getData()); + bool create = d ? false : true; + if(create) d = new PViewDataGModel(); + if(!d->readMSH(fileName, fileIndex, fp, binary, swap, timeStep, + time, partition, numComp, numNodes)){ + Msg(GERROR, "Could not read data in msh file"); + if(create) delete d; + return false; + } + else{ + d->setName(name); + d->setFileName(fileName); + d->setFileIndex(index); + if(create) new PView(d); + } } } do { if(!fgets(str, sizeof(str), fp) || feof(fp)) - break; + break; } while(str[0] != '$'); } diff --git a/Post/PView.h b/Post/PView.h index 6a5de42f2832e30ec3aea8dfacf383a36ef357a5..319d11a92b01279fc7ae29a38cd03600aa4e0b8b 100644 --- a/Post/PView.h +++ b/Post/PView.h @@ -57,7 +57,7 @@ class PView{ PView(PView *ref, bool copyOptions=true); // constructs a new list-based view from a simple 2D dataset PView(std::string xname, std::string yname, - std::vector<double> &x, std::vector<double> &y); + std::vector<double> &x, std::vector<double> &y); // default destructor ~PView(); void deleteVertexArrays(); @@ -84,7 +84,7 @@ class PView{ // does *not* contain that timestep; if partition >=0, return view // only if it does *not* contain that partition) static PView *getViewByName(std::string name, int timeStep=-1, - int partition=-1); + int partition=-1); // read view(s) in list format from a file static bool readPOS(std::string fileName, int fileIndex=-1); diff --git a/Post/PViewData.h b/Post/PViewData.h index 2c342d96362fe090311bc1ca4550bceb2abb6fd3..c9f405a5959384da2ee6d85261813a3514188f78 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -81,7 +81,7 @@ class PViewData { // Returns the coordinates of the nod-th node from the ele-th element // in the ent-th entity virtual void getNode(int step, int ent, int ele, int nod, - double &x, double &y, double &z) = 0; + double &x, double &y, double &z) = 0; // Returns the number of componts available for the ele-th element // in the ent-th entity virtual int getNumComponents(int step, int ent, int ele) = 0; @@ -99,9 +99,9 @@ class PViewData { virtual int getNumStrings2D(){ return 0; } virtual int getNumStrings3D(){ return 0; } virtual void getString2D(int i, int step, std::string &str, - double &x, double &y, double &style){} + double &x, double &y, double &style){} virtual void getString3D(int i, int step, std::string &str, - double &x, double &y, double &z, double &style){} + double &x, double &y, double &z, double &style){} virtual bool empty(); virtual void smooth(){} virtual bool combineTime(nameData &nd){ return false; } @@ -117,7 +117,7 @@ class PViewData { virtual bool writeSTL(std::string name); virtual bool writeTXT(std::string name); virtual bool writePOS(std::string name, bool binary=false, bool parsed=true, - bool append=false){ return false; } + bool append=false){ return false; } virtual bool writeMSH(std::string name, bool binary=false){ return false; } }; diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 132d8d95a5355d10d7316dc2e408b117218dde2a..7c72740d5f18148f5344d604ed1348d7ccb46057 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataGModel.cpp,v 1.33 2008-03-20 11:05:08 geuzaine Exp $ +// $Id: PViewDataGModel.cpp,v 1.34 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -114,9 +114,9 @@ int PViewDataGModel::getNumElements(int step, int ent) int num = 0; for(unsigned int i = 0; i < _steps.size(); i++){ if(ent < 0) - num += _steps[i]->getModel()->getNumMeshElements(); + num += _steps[i]->getModel()->getNumMeshElements(); else - num += _steps[i]->getEntity(ent)->getNumMeshElements(); + num += _steps[i]->getEntity(ent)->getNumMeshElements(); } return num; } @@ -135,7 +135,7 @@ int PViewDataGModel::getNumNodes(int step, int ent, int ele) } void PViewDataGModel::getNode(int step, int ent, int ele, int nod, - double &x, double &y, double &z) + double &x, double &y, double &z) { MVertex *v = _steps[step]->getEntity(ent)->getMeshElement(ele)->getVertex(nod); x = v->x(); diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index d7529bbb0429becd739c5454fbd943a218164458..7512ff133eb615c83c9f6da4ebf0265bf31d7dc8 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -56,8 +56,8 @@ class stepData{ std::vector<real*> *_data; public: stepData(GModel *model, DataType type, int numComp, - std::string fileName="", int fileIndex=-1, double time=0., - double min=VAL_INF, double max=-VAL_INF) + std::string fileName="", int fileIndex=-1, double time=0., + double min=VAL_INF, double max=-VAL_INF) : _model(model), _type(type), _numComp(numComp), _fileName(fileName), _fileIndex(fileIndex), _time(time), _min(min), _max(max), _data(0) @@ -109,7 +109,7 @@ class stepData{ { if(_data){ for(unsigned int i = 0; i < _data->size(); i++) - if((*_data)[i]) delete [] (*_data)[i]; + if((*_data)[i]) delete [] (*_data)[i]; delete _data; _data = 0; } @@ -161,8 +161,8 @@ class PViewDataGModel : public PViewData { // I/O routines bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary, - bool swap, int step, double time, int partition, - int numComp, int numNodes); + bool swap, int step, double time, int partition, + int numComp, int numNodes); bool writeMSH(std::string name, bool binary=false); }; diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index 664146dd92368463c0323ced85ef8b53236a5e38..662e3b73e4db650173f956e489d4b55dd9c99c9b 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataGModelIO.cpp,v 1.10 2008-03-19 20:06:17 geuzaine Exp $ +// $Id: PViewDataGModelIO.cpp,v 1.11 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -30,15 +30,15 @@ #include "StringUtils.h" bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp, - bool binary, bool swap, int step, double time, - int partition, int numComp, int numNodes) + bool binary, bool swap, int step, double time, + int partition, int numComp, int numNodes) { Msg(INFO, "Reading step %d (time %g) partition %d: %d nodes", step, time, partition, numNodes); while(step >= (int)_steps.size()) _steps.push_back(new stepData<double>(GModel::current(), - stepData<double>::NodeData, numComp)); + stepData<double>::NodeData, numComp)); _steps[step]->setFileName(fileName); _steps[step]->setFileIndex(fileIndex); @@ -79,7 +79,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp, } else{ for(int j = 0; j < numComp; j++) - if(fscanf(fp, "%lf", &d[j]) != 1) return false; + if(fscanf(fp, "%lf", &d[j]) != 1) return false; } double s = ComputeScalarRep(numComp, d); _steps[step]->setMin(std::min(_steps[step]->getMin(), s)); @@ -132,20 +132,20 @@ bool PViewDataGModel::writeMSH(std::string name, bool binary) fprintf(fp, "$NodeData\n"); fprintf(fp, "\"%s\"\n", getName().c_str()); fprintf(fp, "%d %.16g 0 0 %d %d\n", step, _steps[step]->getTime(), - numComp, numNodes); + numComp, numNodes); for(unsigned int i = 0; i < _steps[step]->getNumData(); i++){ - if(_steps[step]->getData(i)){ - if(binary){ - fwrite(&tags[i], sizeof(int), 1, fp); - fwrite(_steps[step]->getData(i), sizeof(double), numComp, fp); - } - else{ - fprintf(fp, "%d", tags[i]); - for(int k = 0; k < numComp; k++) - fprintf(fp, " %.16g", _steps[step]->getData(i)[k]); - fprintf(fp, "\n"); - } - } + if(_steps[step]->getData(i)){ + if(binary){ + fwrite(&tags[i], sizeof(int), 1, fp); + fwrite(_steps[step]->getData(i), sizeof(double), numComp, fp); + } + else{ + fprintf(fp, "%d", tags[i]); + for(int k = 0; k < numComp; k++) + fprintf(fp, " %.16g", _steps[step]->getData(i)[k]); + fprintf(fp, "\n"); + } + } } if(binary) fprintf(fp, "\n"); fprintf(fp, "$EndNodeData\n"); diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp index 17d6678fa62b26aa0a97dc3c79d5ded75a9dca01..c24384fc9a160a6cbea373c6c864ce7755795849 100644 --- a/Post/PViewDataIO.cpp +++ b/Post/PViewDataIO.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataIO.cpp,v 1.5 2008-03-19 16:38:16 geuzaine Exp $ +// $Id: PViewDataIO.cpp,v 1.6 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -50,32 +50,32 @@ bool PViewData::writeSTL(std::string name) if(N != 3 && N != 4) continue; double x[4], y[4], z[4], n[3]; for(int i = 0; i < N; i++) - getNode(step, ent, ele, i, x[i], y[i], z[i]); + getNode(step, ent, ele, i, x[i], y[i], z[i]); normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n); if(N == 3){ - fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); - fprintf(fp, " outer loop\n"); - fprintf(fp, " vertex %g %g %g\n", x[0], y[0], z[0]); - fprintf(fp, " vertex %g %g %g\n", x[1], y[1], z[1]); - fprintf(fp, " vertex %g %g %g\n", x[2], y[2], z[2]); - fprintf(fp, " endloop\n"); - fprintf(fp, "endfacet\n"); + fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); + fprintf(fp, " outer loop\n"); + fprintf(fp, " vertex %g %g %g\n", x[0], y[0], z[0]); + fprintf(fp, " vertex %g %g %g\n", x[1], y[1], z[1]); + fprintf(fp, " vertex %g %g %g\n", x[2], y[2], z[2]); + fprintf(fp, " endloop\n"); + fprintf(fp, "endfacet\n"); } else{ - fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); - fprintf(fp, " outer loop\n"); - fprintf(fp, " vertex %g %g %g\n", x[0], y[0], z[0]); - fprintf(fp, " vertex %g %g %g\n", x[1], y[1], z[1]); - fprintf(fp, " vertex %g %g %g\n", x[2], y[2], z[2]); - fprintf(fp, " endloop\n"); - fprintf(fp, "endfacet\n"); - fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); - fprintf(fp, " outer loop\n"); - fprintf(fp, " vertex %g %g %g\n", x[0], y[0], z[0]); - fprintf(fp, " vertex %g %g %g\n", x[2], y[1], z[1]); - fprintf(fp, " vertex %g %g %g\n", x[3], y[3], z[3]); - fprintf(fp, " endloop\n"); - fprintf(fp, "endfacet\n"); + fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); + fprintf(fp, " outer loop\n"); + fprintf(fp, " vertex %g %g %g\n", x[0], y[0], z[0]); + fprintf(fp, " vertex %g %g %g\n", x[1], y[1], z[1]); + fprintf(fp, " vertex %g %g %g\n", x[2], y[2], z[2]); + fprintf(fp, " endloop\n"); + fprintf(fp, "endfacet\n"); + fprintf(fp, "facet normal %g %g %g\n", n[0], n[1], n[2]); + fprintf(fp, " outer loop\n"); + fprintf(fp, " vertex %g %g %g\n", x[0], y[0], z[0]); + fprintf(fp, " vertex %g %g %g\n", x[2], y[1], z[1]); + fprintf(fp, " vertex %g %g %g\n", x[3], y[3], z[3]); + fprintf(fp, " endloop\n"); + fprintf(fp, "endfacet\n"); } } } @@ -93,20 +93,20 @@ bool PViewData::writeTXT(std::string name) return false; } - for(int step = 0; step < getNumTimeSteps(); step++){ + for(int step = 0; step < getNumTimeSteps(); step++){ for(int ent = 0; ent < getNumEntities(step); ent++){ for(int ele = 0; ele < getNumElements(step, ent); ele++){ - for(int nod = 0; nod < getNumNodes(step, ent, ele); nod++){ - double x, y, z; - getNode(step, ent, ele, nod, x, y, z); - fprintf(fp, "%.16g %.16g %.16g ", x, y, z); - for(int comp = 0; comp < getNumComponents(step, ent, ele); comp++){ - double val; - getValue(step, ent, ele, nod, comp, val); - fprintf(fp, "%.16g ", val); - } - } - fprintf(fp, "\n"); + for(int nod = 0; nod < getNumNodes(step, ent, ele); nod++){ + double x, y, z; + getNode(step, ent, ele, nod, x, y, z); + fprintf(fp, "%.16g %.16g %.16g ", x, y, z); + for(int comp = 0; comp < getNumComponents(step, ent, ele); comp++){ + double val; + getValue(step, ent, ele, nod, comp, val); + fprintf(fp, "%.16g ", val); + } + } + fprintf(fp, "\n"); } fprintf(fp, "\n"); } diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp index bebac5f51fbbb052c71d7dc0f9da6be75b3a0654..6f0fe6e9091bcdf38bcc23856388b988e508bb86 100644 --- a/Post/PViewDataList.cpp +++ b/Post/PViewDataList.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataList.cpp,v 1.18 2008-03-19 16:38:16 geuzaine Exp $ +// $Id: PViewDataList.cpp,v 1.19 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -135,8 +135,8 @@ bool PViewDataList::finalize() // compute starting element indices int nb[24] = {NbSP, NbVP, NbTP, NbSL, NbVL, NbTL, NbST, NbVT, NbTT, - NbSQ, NbVQ, NbTQ, NbSS, NbVS, NbTS, NbSH, NbVH, NbTH, - NbSI, NbVI, NbTI, NbSY, NbVY, NbTY}; + NbSQ, NbVQ, NbTQ, NbSS, NbVS, NbTS, NbSH, NbVH, NbTH, + NbSI, NbVI, NbTI, NbSY, NbVY, NbTY}; for(int i = 0; i < 24; i++){ _index[i] = 0; for(int j = 0; j <= i; j++) @@ -241,8 +241,8 @@ void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod) TimeStepMin.clear(); TimeStepMax.clear(); for(int j = 0; j < NbTimeStep; j++){ - TimeStepMin.push_back(VAL_INF); - TimeStepMax.push_back(-VAL_INF); + TimeStepMin.push_back(VAL_INF); + TimeStepMax.push_back(-VAL_INF); } } else if(N / (nbcomp * nbnod) < NbTimeStep){ @@ -257,15 +257,15 @@ void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod) Max = std::max(l0, Max); int ts = j / (nbcomp * nbnod); if(ts < NbTimeStep){ // security - TimeStepMin[ts] = std::min(l0, TimeStepMin[ts]); - TimeStepMax[ts] = std::max(l0, TimeStepMax[ts]); + TimeStepMin[ts] = std::min(l0, TimeStepMin[ts]); + TimeStepMax[ts] = std::max(l0, TimeStepMax[ts]); } } } } void PViewDataList::_setLast(int ele, int dim, int nbnod, int nbcomp, int nbedg, - List_T *list, int nblist) + List_T *list, int nblist) { _lastDimension = dim; _lastNumNodes = nbnod; @@ -334,7 +334,7 @@ int PViewDataList::getNumNodes(int step, int ent, int ele) } void PViewDataList::getNode(int step, int ent, int ele, int nod, - double &x, double &y, double &z) + double &x, double &y, double &z) { if(ele != _lastElement) _setLast(ele); x = _lastXYZ[nod]; @@ -352,8 +352,8 @@ void PViewDataList::getValue(int step, int ent, int ele, int nod, int comp, doub { if(ele != _lastElement) _setLast(ele); val = _lastVal[step * _lastNumNodes * _lastNumComponents + - nod * _lastNumComponents + - comp]; + nod * _lastNumComponents + + comp]; } int PViewDataList::getNumEdges(int step, int ent, int ele) @@ -363,7 +363,7 @@ int PViewDataList::getNumEdges(int step, int ent, int ele) } void PViewDataList::_getString(int dim, int i, int step, std::string &str, - double &x, double &y, double &z, double &style) + double &x, double &y, double &z, double &style) { // 3D: T3D is a list of double: x,y,z,style,index,x,y,z,style,index,... // T3C is a list of chars: string\0,string\0,string\0,string\0,... @@ -415,21 +415,21 @@ void PViewDataList::_getString(int dim, int i, int step, std::string &str, } void PViewDataList::getString2D(int i, int step, std::string &str, - double &x, double &y, double &style) + double &x, double &y, double &style) { double z; _getString(2, i, step, str, x, y, z, style); } void PViewDataList::getString3D(int i, int step, std::string &str, - double &x, double &y, double &z, double &style) + double &x, double &y, double &z, double &style) { _getString(3, i, step, str, x, y, z, style); } static void splitCurvedElement(List_T **in, int *nbin, List_T *out, int *nbout, - int nodin, int nodout, int nbcomp, int nbsplit, - int split[][8], int remove=1) + int nodin, int nodout, int nbcomp, int nbsplit, + int split[][8], int remove=1) { if(*nbin){ int nb = List_Nbr(*in) / *nbin; @@ -438,20 +438,20 @@ static void splitCurvedElement(List_T **in, int *nbin, List_T *out, int *nbout, double *coord = (double *)List_Pointer_Fast(*in, i); double *val = (double *)List_Pointer_Fast(*in, i + 3 * nodin); for(int j = 0; j < nbsplit; j++){ - for(int k = 0; k < nodout; k++) - List_Add(out, &coord[split[j][k]]); - for(int k = 0; k < nodout; k++) - List_Add(out, &coord[nodin + split[j][k]]); - for(int k = 0; k < nodout; k++) - List_Add(out, &coord[2 * nodin + split[j][k]]); - for(int ts = 0; ts < nbstep; ts++){ - for(int k = 0; k < nodout; k++){ - for(int l = 0; l < nbcomp; l++){ - List_Add(out, &val[nodin * nbcomp * ts + nbcomp * split[j][k] + l]); - } - } - } - (*nbout)++; + for(int k = 0; k < nodout; k++) + List_Add(out, &coord[split[j][k]]); + for(int k = 0; k < nodout; k++) + List_Add(out, &coord[nodin + split[j][k]]); + for(int k = 0; k < nodout; k++) + List_Add(out, &coord[2 * nodin + split[j][k]]); + for(int ts = 0; ts < nbstep; ts++){ + for(int k = 0; k < nodout; k++){ + for(int l = 0; l < nbcomp; l++){ + List_Add(out, &val[nodin * nbcomp * ts + nbcomp * split[j][k] + l]); + } + } + } + (*nbout)++; } } } @@ -529,7 +529,7 @@ void PViewDataList::_splitCurvedElements() } static void generateConnectivities(List_T *list, int nbList, int nbTimeStep, - int nbVert, smooth_data &data) + int nbVert, smooth_data &data) { if(!nbList) return; double *vals = new double[nbTimeStep]; @@ -549,7 +549,7 @@ static void generateConnectivities(List_T *list, int nbList, int nbTimeStep, } static void smoothList(List_T *list, int nbList, int nbTimeStep, - int nbVert, smooth_data &data) + int nbVert, smooth_data &data) { if(!nbList) return; double *vals = new double[nbTimeStep]; @@ -561,7 +561,7 @@ static void smoothList(List_T *list, int nbList, int nbTimeStep, double *v = (double *)List_Pointer_Fast(list, i + 3 * nbVert); for(int j = 0; j < nbVert; j++) { if(data.get(x[j], y[j], z[j], nbTimeStep, vals)){ - for(int k = 0; k < nbTimeStep; k++) + for(int k = 0; k < nbTimeStep; k++) v[j + k * nbVert] = vals[k]; } } @@ -634,12 +634,12 @@ bool PViewDataList::combineSpace(nameData &nd) double beg, end; List_Read(l->T2D, i + 3, &beg); if(i > List_Nbr(l->T2D) - 8) - end = (double)List_Nbr(l->T2C); + end = (double)List_Nbr(l->T2C); else - List_Read(l->T2D, i + 3 + 4, &end); + List_Read(l->T2D, i + 3 + 4, &end); char *c = (char*)List_Pointer(l->T2C, (int)beg); for(int j = 0; j < (int)(end - beg); j++) - List_Add(T2C, &c[j]); + List_Add(T2C, &c[j]); NbT2++; } for(int i = 0; i < List_Nbr(l->T3D); i += 5){ @@ -652,12 +652,12 @@ bool PViewDataList::combineSpace(nameData &nd) double beg, end; List_Read(l->T3D, i + 4, &beg); if(i > List_Nbr(l->T3D) - 10) - end = (double)List_Nbr(l->T3C); + end = (double)List_Nbr(l->T3C); else - List_Read(l->T3D, i + 4 + 5, &end); + List_Read(l->T3D, i + 4 + 5, &end); char *c = (char*)List_Pointer(l->T3C, (int)beg); for(int j = 0; j < (int)(end-beg); j++) - List_Add(T3C, &c[j]); + List_Add(T3C, &c[j]); NbT3++; } } @@ -738,19 +738,19 @@ bool PViewDataList::combineTime(nameData &nd) getRawData(i, &list, &nbe, &nbc, &nbn); for(int j = 0; j < *nbe; j++){ for(unsigned int k = 0; k < data.size(); k++){ - data[k]->getRawData(i, &list2, &nbe2, &nbc2, &nbn2); - if(*nbe && *nbe == *nbe2){ - int nb2 = List_Nbr(list2) / *nbe2; - if(!k){ - // copy coordinates of elm j (we are always here as - // expected, since the ref view is the first one) - for(int l = 0; l < 3 * nbn2; l++) - List_Add(list, List_Pointer(list2, j * nb2 + l)); - } - // copy values of elm j - for(int l = 0; l < data[k]->getNumTimeSteps() * nbc2 * nbn2; l++) - List_Add(list, List_Pointer(list2, j * nb2 + 3 * nbn2 + l)); - } + data[k]->getRawData(i, &list2, &nbe2, &nbc2, &nbn2); + if(*nbe && *nbe == *nbe2){ + int nb2 = List_Nbr(list2) / *nbe2; + if(!k){ + // copy coordinates of elm j (we are always here as + // expected, since the ref view is the first one) + for(int l = 0; l < 3 * nbn2; l++) + List_Add(list, List_Pointer(list2, j * nb2 + l)); + } + // copy values of elm j + for(int l = 0; l < data[k]->getNumTimeSteps() * nbc2 * nbn2; l++) + List_Add(list, List_Pointer(list2, j * nb2 + 3 * nbn2 + l)); + } } } } @@ -759,25 +759,25 @@ bool PViewDataList::combineTime(nameData &nd) for(int j = 0; j < NbT2; j++){ for(unsigned int k = 0; k < data.size(); k++){ if(NbT2 == data[k]->NbT2){ - if(!k){ - // copy coordinates - List_Add(T2D, List_Pointer(data[k]->T2D, j * 4)); - List_Add(T2D, List_Pointer(data[k]->T2D, j * 4 + 1)); - List_Add(T2D, List_Pointer(data[k]->T2D, j * 4 + 2)); - // index - double d = List_Nbr(T2C); - List_Add(T2D, &d); - } - // copy char values - double beg, end; - List_Read(data[k]->T2D, j * 4 + 3, &beg); - if(j == NbT2 - 1) - end = (double)List_Nbr(data[k]->T2C); - else - List_Read(data[k]->T2D, j * 4 + 4 + 3, &end); - char *c = (char*)List_Pointer(data[k]->T2C, (int)beg); - for(int l = 0; l < (int)(end - beg); l++) - List_Add(T2C, &c[l]); + if(!k){ + // copy coordinates + List_Add(T2D, List_Pointer(data[k]->T2D, j * 4)); + List_Add(T2D, List_Pointer(data[k]->T2D, j * 4 + 1)); + List_Add(T2D, List_Pointer(data[k]->T2D, j * 4 + 2)); + // index + double d = List_Nbr(T2C); + List_Add(T2D, &d); + } + // copy char values + double beg, end; + List_Read(data[k]->T2D, j * 4 + 3, &beg); + if(j == NbT2 - 1) + end = (double)List_Nbr(data[k]->T2C); + else + List_Read(data[k]->T2D, j * 4 + 4 + 3, &end); + char *c = (char*)List_Pointer(data[k]->T2C, (int)beg); + for(int l = 0; l < (int)(end - beg); l++) + List_Add(T2C, &c[l]); } } } @@ -786,26 +786,26 @@ bool PViewDataList::combineTime(nameData &nd) for(int j = 0; j < NbT3; j++){ for(unsigned int k = 0; k < data.size(); k++){ if(NbT3 == data[k]->NbT3){ - if(!k){ - // copy coordinates - List_Add(T3D, List_Pointer(data[k]->T3D, j * 5)); - List_Add(T3D, List_Pointer(data[k]->T3D, j * 5 + 1)); - List_Add(T3D, List_Pointer(data[k]->T3D, j * 5 + 2)); - List_Add(T3D, List_Pointer(data[k]->T3D, j * 5 + 3)); - // index - double d = List_Nbr(T3C); - List_Add(T3D, &d); - } - // copy char values - double beg, end; - List_Read(data[k]->T3D, j * 5 + 4, &beg); - if(j == NbT3 - 1) - end = (double)List_Nbr(data[k]->T3C); - else - List_Read(data[k]->T3D, j * 5 + 5 + 4, &end); - char *c = (char*)List_Pointer(data[k]->T3C, (int)beg); - for(int l = 0; l < (int)(end - beg); l++) - List_Add(T3C, &c[l]); + if(!k){ + // copy coordinates + List_Add(T3D, List_Pointer(data[k]->T3D, j * 5)); + List_Add(T3D, List_Pointer(data[k]->T3D, j * 5 + 1)); + List_Add(T3D, List_Pointer(data[k]->T3D, j * 5 + 2)); + List_Add(T3D, List_Pointer(data[k]->T3D, j * 5 + 3)); + // index + double d = List_Nbr(T3C); + List_Add(T3D, &d); + } + // copy char values + double beg, end; + List_Read(data[k]->T3D, j * 5 + 4, &beg); + if(j == NbT3 - 1) + end = (double)List_Nbr(data[k]->T3C); + else + List_Read(data[k]->T3D, j * 5 + 5 + 4, &end); + char *c = (char*)List_Pointer(data[k]->T3C, (int)beg); + for(int l = 0; l < (int)(end - beg); l++) + List_Add(T3C, &c[l]); } } } @@ -824,8 +824,8 @@ bool PViewDataList::combineTime(nameData &nd) for(int i = 1; i < List_Nbr(Time); i++){ List_Read(Time, i, &ti); if(ti != t0){ - allTheSame = false; - break; + allTheSame = false; + break; } } if(allTheSame) List_Reset(Time); diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h index dc3bb53a748ce13f605f93d232287741237e2bb7..72d17e36d90eddd0133462ad4d23e5f5c9fd52ec 100644 --- a/Post/PViewDataList.h +++ b/Post/PViewDataList.h @@ -66,9 +66,9 @@ class PViewDataList : public PViewData { void _stat(List_T *list, int nbcomp, int nbelm, int nbnod); void _setLast(int ele); void _setLast(int ele, int dim, int nbnod, int nbcomp, int nbedg, - List_T *list, int nblist); + List_T *list, int nblist); void _getString(int dim, int i, int timestep, std::string &str, - double &x, double &y, double &z, double &style); + double &x, double &y, double &z, double &style); void _splitCurvedElements(); public: PViewDataList(bool allocate=true); @@ -101,9 +101,9 @@ class PViewDataList : public PViewData { int getNumStrings2D(){ return NbT2; } int getNumStrings3D(){ return NbT3; } void getString2D(int i, int step, std::string &str, - double &x, double &y, double &style); + double &x, double &y, double &style); void getString3D(int i, int step, std::string &str, - double &x, double &y, double &z, double &style); + double &x, double &y, double &z, double &style); void smooth(); bool combineTime(nameData &nd); bool combineSpace(nameData &nd); @@ -115,7 +115,7 @@ class PViewDataList : public PViewData { // I/O routines bool readPOS(FILE *fp, double version, int format, int size); bool writePOS(std::string name, bool binary=false, bool parsed=true, - bool append=false); + bool append=false); bool writeMSH(std::string name, bool binary=false); }; diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index 637934f2541e9facda5b127680f9d6a6bffe28a6..9c9eb050d86c336b9b00bb94274b7c84c2654992 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataListIO.cpp,v 1.16 2008-03-10 19:59:01 geuzaine Exp $ +// $Id: PViewDataListIO.cpp,v 1.17 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -39,8 +39,8 @@ bool PViewDataList::readPOS(FILE *fp, double version, int format, int size) if(version <= 1.0) { Msg(DEBUG, "Detected post-processing view format <= 1.0"); if(!fscanf(fp, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d\n", - name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, - &NbST, &NbVT, &NbTT, &NbSS, &NbVS, &NbTS)){ + name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, + &NbST, &NbVT, &NbTT, &NbSS, &NbVS, &NbTS)){ Msg(GERROR, "Read error"); return false; } @@ -49,9 +49,9 @@ bool PViewDataList::readPOS(FILE *fp, double version, int format, int size) else if(version == 1.1) { Msg(DEBUG, "Detected post-processing view format 1.1"); if(!fscanf(fp, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", - name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, - &NbST, &NbVT, &NbTT, &NbSS, &NbVS, &NbTS, &NbT2, &t2l, &NbT3, - &t3l)){ + name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, + &NbST, &NbVT, &NbTT, &NbSS, &NbVS, &NbTS, &NbT2, &t2l, &NbT3, + &t3l)){ Msg(GERROR, "Read error"); return false; } @@ -59,11 +59,11 @@ bool PViewDataList::readPOS(FILE *fp, double version, int format, int size) else if(version == 1.2 || version == 1.3) { Msg(DEBUG, "Detected post-processing view format %g", version); if(!fscanf(fp, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " - "%d %d %d %d %d %d %d %d %d %d %d %d %d\n", - name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, - &NbST, &NbVT, &NbTT, &NbSQ, &NbVQ, &NbTQ, &NbSS, &NbVS, &NbTS, - &NbSH, &NbVH, &NbTH, &NbSI, &NbVI, &NbTI, &NbSY, &NbVY, &NbTY, - &NbT2, &t2l, &NbT3, &t3l)){ + "%d %d %d %d %d %d %d %d %d %d %d %d %d\n", + name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, + &NbST, &NbVT, &NbTT, &NbSQ, &NbVQ, &NbTQ, &NbSS, &NbVS, &NbTS, + &NbSH, &NbVH, &NbTH, &NbSI, &NbVI, &NbTI, &NbSY, &NbVY, &NbTY, + &NbT2, &t2l, &NbT3, &t3l)){ Msg(GERROR, "Read error"); return false; } @@ -71,14 +71,14 @@ bool PViewDataList::readPOS(FILE *fp, double version, int format, int size) else if(version == 1.4) { Msg(DEBUG, "Detected post-processing view format 1.4"); if(!fscanf(fp, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " - "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " - "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", - name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, - &NbST, &NbVT, &NbTT, &NbSQ, &NbVQ, &NbTQ, &NbSS, &NbVS, &NbTS, - &NbSH, &NbVH, &NbTH, &NbSI, &NbVI, &NbTI, &NbSY, &NbVY, &NbTY, - &NbSL2, &NbVL2, &NbTL2, &NbST2, &NbVT2, &NbTT2, &NbSQ2, &NbVQ2, - &NbTQ2, &NbSS2, &NbVS2, &NbTS2, &NbSH2, &NbVH2, &NbTH2, &NbSI2, - &NbVI2, &NbTI2, &NbSY2, &NbVY2, &NbTY2, &NbT2, &t2l, &NbT3, &t3l)){ + "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " + "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + name, &NbTimeStep, &NbSP, &NbVP, &NbTP, &NbSL, &NbVL, &NbTL, + &NbST, &NbVT, &NbTT, &NbSQ, &NbVQ, &NbTQ, &NbSS, &NbVS, &NbTS, + &NbSH, &NbVH, &NbTH, &NbSI, &NbVI, &NbTI, &NbSY, &NbVY, &NbTY, + &NbSL2, &NbVL2, &NbTL2, &NbST2, &NbVT2, &NbTT2, &NbSQ2, &NbVQ2, + &NbTQ2, &NbSS2, &NbVS2, &NbTS2, &NbSH2, &NbVH2, &NbTH2, &NbSI2, + &NbVI2, &NbTI2, &NbSY2, &NbVY2, &NbTY2, &NbT2, &t2l, &NbT3, &t3l)){ Msg(GERROR, "Read error"); return false; } @@ -263,7 +263,7 @@ static void writeTimePOS(FILE *fp, List_T *list) } static void writeElementPOS(FILE *fp, const char *str, int nbnod, int nb, - List_T *list) + List_T *list) { if(nb){ int n = List_Nbr(list) / nb; @@ -273,13 +273,13 @@ static void writeElementPOS(FILE *fp, const char *str, int nbnod, int nb, double *z = (double *)List_Pointer(list, i + 2 * nbnod); fprintf(fp, "%s(", str); for(int j = 0; j < nbnod; j++) { - if(j) fprintf(fp, ","); - fprintf(fp, "%.16g,%.16g,%.16g", x[j], y[j], z[j]); + if(j) fprintf(fp, ","); + fprintf(fp, "%.16g,%.16g,%.16g", x[j], y[j], z[j]); } fprintf(fp, "){"); for(int j = 3 * nbnod; j < n; j++) { - if(j - 3 * nbnod) fprintf(fp, ","); - fprintf(fp, "%.16g", *(double *)List_Pointer(list, i + j)); + if(j - 3 * nbnod) fprintf(fp, ","); + fprintf(fp, "%.16g", *(double *)List_Pointer(list, i + j)); } fprintf(fp, "};\n"); } @@ -319,7 +319,7 @@ static void writeTextPOS(FILE *fp, int nbc, int nb, List_T *TD, List_T *TC) bool PViewDataList::writePOS(std::string name, bool binary, bool parsed, bool append) { FILE *fp = fopen(name.c_str(), - append ? (binary ? "ab" : "a") : (binary ? "wb" : "w")); + append ? (binary ? "ab" : "a") : (binary ? "wb" : "w")); if(!fp){ Msg(GERROR, "Unable to open file '%s'", name.c_str()); return false; @@ -340,19 +340,19 @@ bool PViewDataList::writePOS(std::string name, bool binary, bool parsed, bool ap fprintf(fp, "$View /* %s */\n", getName().c_str()); fprintf(fp, "%s ", str); fprintf(fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " - "%d %d %d %d %d %d %d %d %d %d %d %d\n", - List_Nbr(Time), - NbSP, NbVP, NbTP, NbSL, NbVL, NbTL, - NbST, NbVT, NbTT, NbSQ, NbVQ, NbTQ, - NbSS, NbVS, NbTS, NbSH, NbVH, NbTH, - NbSI, NbVI, NbTI, NbSY, NbVY, NbTY, - NbT2, List_Nbr(T2C), NbT3, List_Nbr(T3C)); + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + List_Nbr(Time), + NbSP, NbVP, NbTP, NbSL, NbVL, NbTL, + NbST, NbVT, NbTT, NbSQ, NbVQ, NbTQ, + NbSS, NbVS, NbTS, NbSH, NbVH, NbTH, + NbSI, NbVI, NbTI, NbSY, NbVY, NbTY, + NbT2, List_Nbr(T2C), NbT3, List_Nbr(T3C)); int f = binary ? LIST_FORMAT_BINARY : LIST_FORMAT_ASCII; if(binary) { int one = 1; if(!fwrite(&one, sizeof(int), 1, fp)){ - Msg(GERROR, "Write error"); - return false; + Msg(GERROR, "Write error"); + return false; } } List_WriteToFile(Time, fp, f); @@ -420,7 +420,7 @@ class pVertexLessThan{ }; static void getNodeMSH(int nbelm, List_T *list, int nbnod, int nbcomp, int nbstep, - std::set<pVertex, pVertexLessThan> *nodes, int *numelm) + std::set<pVertex, pVertexLessThan> *nodes, int *numelm) { if(!nbelm) return; int nb = List_Nbr(list) / nbelm; @@ -433,11 +433,11 @@ static void getNodeMSH(int nbelm, List_T *list, int nbnod, int nbcomp, int nbste pVertex n(x[j], y[j], z[j]); std::set<pVertex, pVertexLessThan>::iterator it = nodes->find(n); if(it == nodes->end()){ - n.Num = nodes->size() + 1; - for(int ts = 0; ts < nbstep; ts++) - for(int k = 0; k < nbcomp; k++) - n.Val.push_back(v[nbcomp * nbnod * ts + nbcomp * j + k]); - nodes->insert(n); + n.Num = nodes->size() + 1; + for(int ts = 0; ts < nbstep; ts++) + for(int k = 0; k < nbcomp; k++) + n.Val.push_back(v[nbcomp * nbnod * ts + nbcomp * j + k]); + nodes->insert(n); } } (*numelm)++; @@ -445,7 +445,7 @@ static void getNodeMSH(int nbelm, List_T *list, int nbnod, int nbcomp, int nbste } static void writeElementMSH(FILE *fp, int num, int nbnod, pVertex nod[8], - int nbcomp, double *vals, int dim) + int nbcomp, double *vals, int dim) { switch(dim){ case 0: @@ -459,31 +459,31 @@ static void writeElementMSH(FILE *fp, int num, int nbnod, pVertex nod[8], fprintf(fp, "%d 2 0 %d %d %d\n", num, nod[0].Num, nod[1].Num, nod[2].Num); else fprintf(fp, "%d 3 0 %d %d %d %d\n", num, nod[0].Num, nod[1].Num, - nod[2].Num, nod[3].Num); + nod[2].Num, nod[3].Num); break; case 3: default: if(nbnod == 4) fprintf(fp, "%d 4 0 %d %d %d %d\n", num, nod[0].Num, nod[1].Num, - nod[2].Num, nod[3].Num); + nod[2].Num, nod[3].Num); else if(nbnod == 5) fprintf(fp, "%d 7 0 %d %d %d %d %d\n", num, nod[0].Num, nod[1].Num, - nod[2].Num, nod[3].Num, nod[4].Num); + nod[2].Num, nod[3].Num, nod[4].Num); else if(nbnod == 6) fprintf(fp, "%d 6 0 %d %d %d %d %d %d\n", num, nod[0].Num, nod[1].Num, - nod[2].Num, nod[3].Num, nod[4].Num, nod[5].Num); + nod[2].Num, nod[3].Num, nod[4].Num, nod[5].Num); else fprintf(fp, "%d 5 0 %d %d %d %d %d %d %d %d\n", num, nod[0].Num, - nod[1].Num, nod[2].Num, nod[3].Num, nod[4].Num, nod[5].Num, - nod[6].Num, nod[7].Num); + nod[1].Num, nod[2].Num, nod[3].Num, nod[4].Num, nod[5].Num, + nod[6].Num, nod[7].Num); break; } } static void writeElementsMSH(FILE *fp, int nbelm, List_T *list, - int nbnod, int nbcomp, int dim, - std::set<pVertex, pVertexLessThan> *nodes, - int *numelm) + int nbnod, int nbcomp, int dim, + std::set<pVertex, pVertexLessThan> *nodes, + int *numelm) { if(!nbelm) return; pVertex nod[8]; @@ -497,11 +497,11 @@ static void writeElementsMSH(FILE *fp, int nbelm, List_T *list, pVertex n(x[j], y[j], z[j]); std::set<pVertex, pVertexLessThan>::iterator it = nodes->find(n); if(it == nodes->end()){ - Msg(GERROR, "Unknown node in element"); - return; + Msg(GERROR, "Unknown node in element"); + return; } else{ - nod[j] = (pVertex)(*it); + nod[j] = (pVertex)(*it); } } (*numelm)++; @@ -593,10 +593,10 @@ bool PViewDataList::writeMSH(std::string name, bool binary) fprintf(fp, "\"%s\"\n", getName().c_str()); fprintf(fp, "%d %.16g 0 0 %d %d\n", ts, time, numComp, numNodes); for(std::set<pVertex, pVertexLessThan>::iterator it = nodes.begin(); - it != nodes.end(); ++it){ - fprintf(fp, "%d", it->Num); - for(int i = 0; i < numComp; i++) - fprintf(fp, " %.16g", it->Val[ts * numComp + i]); + it != nodes.end(); ++it){ + fprintf(fp, "%d", it->Num); + for(int i = 0; i < numComp; i++) + fprintf(fp, " %.16g", it->Val[ts * numComp + i]); fprintf(fp, "\n"); } fprintf(fp, "$EndNodeData\n"); diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp index aaef4c40b1f44aa87a794af88b73d8e2282e33cc..a77154b2960a3f8933f118e82e4298cd768633ae 100644 --- a/Post/PViewOptions.cpp +++ b/Post/PViewOptions.cpp @@ -1,4 +1,4 @@ -// $Id: PViewOptions.cpp,v 1.19 2008-02-24 16:18:19 geuzaine Exp $ +// $Id: PViewOptions.cpp,v 1.20 2008-03-20 11:44:15 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -66,7 +66,7 @@ double PViewOptions::getScaleValue(int iso, int numIso, double min, double max) } int PViewOptions::getScaleIndex(double val, int numIso, double min, double max, - bool forceLinear) + bool forceLinear) { if(min == max) return numIso / 2; @@ -87,7 +87,7 @@ int PViewOptions::getScaleIndex(double val, int numIso, double min, double max, // val in [min, max] unsigned int PViewOptions::getColor(double val, double min, double max, - bool forceLinear) + bool forceLinear) { if(CT.size == 1) return CT.table[0]; int index = getScaleIndex(val, CT.size, min, max, forceLinear); diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index 865bb3d55938f2b309f688282e41c8bc9eeaa89b..8e111aedb2e72cf66b5ba9df63dfa64149a77460 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -113,7 +113,7 @@ class PViewOptions { void destroyGeneralRaise(); double getScaleValue(int iso, int numIso, double min, double max); int getScaleIndex(double val, int numIso, double min, double max, - bool forceLinear=false); + bool forceLinear=false); unsigned int getColor(int i, int nb); unsigned int getColor(double val, double min, double max, bool forceLinear=false); bool skipElement(int numEdges);