diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index d1ffdf7d0298bb5c0280af000756432bb5ff2940..9a6ea54dbfc5e1d91ec54193a33831115ce9dc8f 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -533,14 +533,11 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, std::vector<GEntity*> entities; getEntities(entities); for(unsigned int i = 0; i < entities.size(); i++) - for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++){ - if (!saveParametric) - entities[i]->mesh_vertices[j]->writeMSH(fp, binary, scalingFactor); - else - entities[i]->mesh_vertices[j]->writeMSH3(fp, binary, scalingFactor); - } + for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++) + entities[i]->mesh_vertices[j]->writeMSH(fp, binary, saveParametric, + scalingFactor); if(binary) fprintf(fp, "\n"); - + if(version >= 2.0){ if(saveParametric) fprintf(fp, "$EndParametricNodes\n"); diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 19d995c3a9d6da418f66f42b48e4bf30e455b967..7bda5e677d373e523ae2575465cf7e14dc2369f8 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -25,69 +25,59 @@ bool MVertexLessThanLexicographic::operator()(const MVertex *v1, const MVertex * return false; } -void MVertex::writeMSH3(FILE *fp, bool binary, double scalingFactor) +void MVertex::writeMSH(FILE *fp, bool binary, bool saveParametric, double scalingFactor) { if(_index < 0) return; // negative index vertices are never saved - int myDim = onWhat()->dim(); - int myTag = onWhat()->tag(); - if(!binary){ - fprintf(fp, "%d %.16g %.16g %.16g %d %d", _index, - x() * scalingFactor, - y() * scalingFactor, - z() * scalingFactor, - myDim,myTag); - } - else{ - fwrite(&_index, sizeof(int), 1, fp); - double data[3] = {x() * scalingFactor, y() * scalingFactor, z() * scalingFactor}; - fwrite(data, sizeof(double), 3, fp); - fwrite(&myDim, sizeof(int), 1, fp); - fwrite(&myTag, sizeof(int), 1, fp); - } - if (myDim == 1){ - double _u; - getParameter(0,_u); - if(!binary) - fprintf(fp, " %.16g\n", _u); - else - fwrite(&_u, sizeof(double), 1, fp); - } - else if (myDim == 2){ - double _u,_v; - getParameter(0,_u); - getParameter(1,_v); - if(!binary) - fprintf(fp, " %.16g %.16g\n", _u,_v); - else{ - fwrite(&_u, sizeof(double), 1, fp); - fwrite(&_v, sizeof(double), 1, fp); - } + int myDim = 0, myTag = 0; + if(saveParametric && onWhat()){ + myDim = onWhat()->dim(); + myTag = onWhat()->tag(); } - else - if(!binary) - fprintf(fp, "\n"); -} - - -void MVertex::writeMSH(FILE *fp, bool binary, double scalingFactor) -{ - if(_index < 0) return; // negative index vertices are never saved if(!binary){ - fprintf(fp, "%d %.16g %.16g %.16g\n", _index, - x() * scalingFactor, - y() * scalingFactor, - z() * scalingFactor); + if(!saveParametric) + fprintf(fp, "%d %.16g %.16g %.16g\n", _index, x() * scalingFactor, + y() * scalingFactor, z() * scalingFactor); + else + fprintf(fp, "%d %.16g %.16g %.16g %d %d", _index, x() * scalingFactor, + y() * scalingFactor, z() * scalingFactor, myDim, myTag); } else{ fwrite(&_index, sizeof(int), 1, fp); double data[3] = {x() * scalingFactor, y() * scalingFactor, z() * scalingFactor}; fwrite(data, sizeof(double), 3, fp); + if(saveParametric){ + fwrite(&myDim, sizeof(int), 1, fp); + fwrite(&myTag, sizeof(int), 1, fp); + } } -} - + if(saveParametric){ + if(myDim == 1){ + double _u; + getParameter(0, _u); + if(!binary) + fprintf(fp, " %.16g\n", _u); + else + fwrite(&_u, sizeof(double), 1, fp); + } + else if (myDim == 2){ + double _u, _v; + getParameter(0, _u); + getParameter(1, _v); + if(!binary) + fprintf(fp, " %.16g %.16g\n", _u, _v); + else{ + fwrite(&_u, sizeof(double), 1, fp); + fwrite(&_v, sizeof(double), 1, fp); + } + } + else + if(!binary) + fprintf(fp, "\n"); + } +} void MVertex::writeVRML(FILE *fp, double scalingFactor) { diff --git a/Geo/MVertex.h b/Geo/MVertex.h index 99611dbef96ebeea9bbf75b3340cc8a68f24f3b4..d058c7dab271ea87a332876f93e6850033a93a60 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -106,8 +106,8 @@ class MVertex{ linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos); // IO routines - void writeMSH(FILE *fp, bool binary=false, double scalingFactor=1.0); - void writeMSH3(FILE *fp, bool binary=false, double scalingFactor=1.0); + void writeMSH(FILE *fp, bool binary=false, bool saveParametric=false, + double scalingFactor=1.0); void writeVRML(FILE *fp, double scalingFactor=1.0); void writeUNV(FILE *fp, double scalingFactor=1.0); void writeVTK(FILE *fp, bool binary=false, double scalingFactor=1.0, diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index fa629ce3b413ce22bc8d2d1e2f454125eb2876bd..e31a90b1349909ac595d12866df5f81dbf13fc3b 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1279,7 +1279,7 @@ void deMeshGFace::operator() (GFace *gf) gf->meshStatistics.nbTriangle = gf->meshStatistics.nbEdge = 0; } -const int debugSurface = -100; +const int debugSurface = -1; void meshGFace::operator() (GFace *gf) {