Skip to content
Snippets Groups Projects
Commit 6ee6a598 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

merge both writeMSH routines

parent a0ff1498
Branches
Tags
No related merge requests found
...@@ -533,12 +533,9 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, ...@@ -533,12 +533,9 @@ int GModel::writeMSH(const std::string &name, double version, bool binary,
std::vector<GEntity*> entities; std::vector<GEntity*> entities;
getEntities(entities); getEntities(entities);
for(unsigned int i = 0; i < entities.size(); i++) for(unsigned int i = 0; i < entities.size(); i++)
for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++){ for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++)
if (!saveParametric) entities[i]->mesh_vertices[j]->writeMSH(fp, binary, saveParametric,
entities[i]->mesh_vertices[j]->writeMSH(fp, binary, scalingFactor); scalingFactor);
else
entities[i]->mesh_vertices[j]->writeMSH3(fp, binary, scalingFactor);
}
if(binary) fprintf(fp, "\n"); if(binary) fprintf(fp, "\n");
if(version >= 2.0){ if(version >= 2.0){
......
...@@ -25,26 +25,35 @@ bool MVertexLessThanLexicographic::operator()(const MVertex *v1, const MVertex * ...@@ -25,26 +25,35 @@ bool MVertexLessThanLexicographic::operator()(const MVertex *v1, const MVertex *
return false; 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 if(_index < 0) return; // negative index vertices are never saved
int myDim = onWhat()->dim();
int myTag = onWhat()->tag(); int myDim = 0, myTag = 0;
if(saveParametric && onWhat()){
myDim = onWhat()->dim();
myTag = onWhat()->tag();
}
if(!binary){ if(!binary){
fprintf(fp, "%d %.16g %.16g %.16g %d %d", _index, if(!saveParametric)
x() * scalingFactor, fprintf(fp, "%d %.16g %.16g %.16g\n", _index, x() * scalingFactor,
y() * scalingFactor, y() * scalingFactor, z() * scalingFactor);
z() * scalingFactor, else
myDim,myTag); fprintf(fp, "%d %.16g %.16g %.16g %d %d", _index, x() * scalingFactor,
y() * scalingFactor, z() * scalingFactor, myDim, myTag);
} }
else{ else{
fwrite(&_index, sizeof(int), 1, fp); fwrite(&_index, sizeof(int), 1, fp);
double data[3] = {x() * scalingFactor, y() * scalingFactor, z() * scalingFactor}; double data[3] = {x() * scalingFactor, y() * scalingFactor, z() * scalingFactor};
fwrite(data, sizeof(double), 3, fp); fwrite(data, sizeof(double), 3, fp);
if(saveParametric){
fwrite(&myDim, sizeof(int), 1, fp); fwrite(&myDim, sizeof(int), 1, fp);
fwrite(&myTag, sizeof(int), 1, fp); fwrite(&myTag, sizeof(int), 1, fp);
} }
}
if(saveParametric){
if(myDim == 1){ if(myDim == 1){
double _u; double _u;
getParameter(0, _u); getParameter(0, _u);
...@@ -68,27 +77,8 @@ void MVertex::writeMSH3(FILE *fp, bool binary, double scalingFactor) ...@@ -68,27 +77,8 @@ void MVertex::writeMSH3(FILE *fp, bool binary, double scalingFactor)
if(!binary) if(!binary)
fprintf(fp, "\n"); 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);
}
else{
fwrite(&_index, sizeof(int), 1, fp);
double data[3] = {x() * scalingFactor, y() * scalingFactor, z() * scalingFactor};
fwrite(data, sizeof(double), 3, fp);
}
} }
void MVertex::writeVRML(FILE *fp, double scalingFactor) void MVertex::writeVRML(FILE *fp, double scalingFactor)
{ {
if(_index < 0) return; // negative index vertices are never saved if(_index < 0) return; // negative index vertices are never saved
......
...@@ -106,8 +106,8 @@ class MVertex{ ...@@ -106,8 +106,8 @@ class MVertex{
linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos); linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos);
// IO routines // IO routines
void writeMSH(FILE *fp, bool binary=false, double scalingFactor=1.0); void writeMSH(FILE *fp, bool binary=false, bool saveParametric=false,
void writeMSH3(FILE *fp, bool binary=false, double scalingFactor=1.0); double scalingFactor=1.0);
void writeVRML(FILE *fp, double scalingFactor=1.0); void writeVRML(FILE *fp, double scalingFactor=1.0);
void writeUNV(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, void writeVTK(FILE *fp, bool binary=false, double scalingFactor=1.0,
......
...@@ -1279,7 +1279,7 @@ void deMeshGFace::operator() (GFace *gf) ...@@ -1279,7 +1279,7 @@ void deMeshGFace::operator() (GFace *gf)
gf->meshStatistics.nbTriangle = gf->meshStatistics.nbEdge = 0; gf->meshStatistics.nbTriangle = gf->meshStatistics.nbEdge = 0;
} }
const int debugSurface = -100; const int debugSurface = -1;
void meshGFace::operator() (GFace *gf) void meshGFace::operator() (GFace *gf)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment