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

fix crash due to non-check of return value of FOpen in BackgroundField::print().

Sigh...
parent 0eec360c
No related branches found
No related tags found
No related merge requests found
...@@ -177,7 +177,6 @@ static void propagateValuesOnFace(GFace *_gf, ...@@ -177,7 +177,6 @@ static void propagateValuesOnFace(GFace *_gf,
myAssembler.fixVertex(itv->first, 0, 1, itv->second); myAssembler.fixVertex(itv->first, 0, 1, itv->second);
} }
// Number vertices // Number vertices
std::set<MVertex*> vs; std::set<MVertex*> vs;
for (unsigned int k = 0; k < _gf->triangles.size(); k++) for (unsigned int k = 0; k < _gf->triangles.size(); k++)
...@@ -348,7 +347,8 @@ void backgroundMesh::propagateCrossFieldByDistance(GFace *_gf) ...@@ -348,7 +347,8 @@ void backgroundMesh::propagateCrossFieldByDistance(GFace *_gf)
#endif #endif
} }
inline double myAngle (const SVector3 &a, const SVector3 &b, const SVector3 &d){ inline double myAngle (const SVector3 &a, const SVector3 &b, const SVector3 &d)
{
double cosTheta = dot(a,b); double cosTheta = dot(a,b);
double sinTheta = dot(crossprod(a,b),d); double sinTheta = dot(crossprod(a,b),d);
return atan2 (sinTheta,cosTheta); return atan2 (sinTheta,cosTheta);
...@@ -403,7 +403,6 @@ double backgroundMesh::getSmoothness(double u, double v, double w) ...@@ -403,7 +403,6 @@ double backgroundMesh::getSmoothness(double u, double v, double w)
void backgroundMesh::propagateCrossField(GFace *_gf) void backgroundMesh::propagateCrossField(GFace *_gf)
{ {
// printf("coucou\n");
propagateCrossFieldHJ (_gf); propagateCrossFieldHJ (_gf);
// solve the non liear problem // solve the non liear problem
constantPerElement<double> C; constantPerElement<double> C;
...@@ -424,13 +423,13 @@ void backgroundMesh::propagateCrossField(GFace *_gf) ...@@ -424,13 +423,13 @@ void backgroundMesh::propagateCrossField(GFace *_gf)
if (++ITER > 0)break; if (++ITER > 0)break;
} }
// printf("converged in %d iterations\n", ITER); // printf("converged in %d iterations\n", ITER);
#if 0 // debug print
char name[256]; char name[256];
sprintf(name, "cross-%d-%d.pos", _gf->tag(), ITER); sprintf(name, "cross-%d-%d.pos", _gf->tag(), ITER);
print(name, 0, 1); print(name, 0, 1);
sprintf(name, "smooth-%d-%d.pos", _gf->tag(), ITER); sprintf(name, "smooth-%d-%d.pos", _gf->tag(), ITER);
print(name, _gf, 2); print(name, _gf, 2);
#endif
} }
void backgroundMesh::propagateCrossFieldHJ(GFace *_gf) void backgroundMesh::propagateCrossFieldHJ(GFace *_gf)
...@@ -650,6 +649,10 @@ void backgroundMesh::print(const std::string &filename, GFace *gf, ...@@ -650,6 +649,10 @@ void backgroundMesh::print(const std::string &filename, GFace *gf,
const std::map<MVertex*,double> &_whatToPrint, int smooth) const std::map<MVertex*,double> &_whatToPrint, int smooth)
{ {
FILE *f = Fopen (filename.c_str(),"w"); FILE *f = Fopen (filename.c_str(),"w");
if(!f){
Msg::Warning("Could not open file '%s'", filename.c_str());
return;
}
fprintf(f, "View \"Background Mesh\"{\n"); fprintf(f, "View \"Background Mesh\"{\n");
if (smooth){ if (smooth){
for(unsigned int i = 0; i < gf->triangles.size(); i++){ for(unsigned int i = 0; i < gf->triangles.size(); i++){
...@@ -693,6 +696,7 @@ void backgroundMesh::print(const std::string &filename, GFace *gf, ...@@ -693,6 +696,7 @@ void backgroundMesh::print(const std::string &filename, GFace *gf,
} }
MElementOctree* backgroundMesh::get_octree(){ MElementOctree* backgroundMesh::get_octree(){
return _octree; return _octree;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment