* Improved error checking for mesh size file loading / reading

* Corrected uninitialized variables in mesh size file function
This commit is contained in:
Philippose Rajan 2009-03-10 20:39:16 +00:00
parent ac8ac8aa14
commit 87404f51c9

View File

@ -2826,6 +2826,10 @@ namespace netgen
void Mesh :: LoadLocalMeshSize (const char * meshsizefilename)
{
// Philippose - 10/03/2009
// Improve error checking when loading and reading
// the local mesh size file
if (!meshsizefilename) return;
ifstream msf(meshsizefilename);
@ -2836,13 +2840,27 @@ namespace netgen
// other reasons such as access rights, etc...
if (!msf)
{
PrintMessage(2, "Error loading Mesh Size File: ", meshsizefilename, "....","Skipping!");
PrintMessage(3, "Error loading mesh size file: ", meshsizefilename, "....","Skipping!");
return;
}
PrintMessage (3, "Load local mesh-size");
int nmsp, nmsl;
PrintMessage (3, "Load local mesh-size file: ", meshsizefilename);
int nmsp = 0;
int nmsl = 0;
msf >> nmsp;
if(nmsp > 0)
{
if(!msf.good())
throw NgException ("Mesh-size file error: No points found\n");
PrintMessage (4, "Number of mesh-size restriction points: ", nmsp);
}
else
{
msf.close();
return;
}
for (int i = 0; i < nmsp; i++)
{
Point3d pi;
@ -2850,10 +2868,22 @@ namespace netgen
msf >> pi.X() >> pi.Y() >> pi.Z();
msf >> hi;
if (!msf.good())
throw NgException ("problem in mesh-size file\n");
throw NgException ("Mesh-size file error: Number of points don't match specified list size\n");
RestrictLocalH (pi, hi);
}
msf >> nmsl;
if(nmsl > 0)
{
cout << "Number of line definitions expected = " << nmsl << endl;
if(!msf.good())
throw NgException ("Mesh-size file error: No line definitions found\n");
PrintMessage (4, "Number of mesh-size restriction lines: ", nmsl);
}
else
{
msf.close();
return;
}
for (int i = 0; i < nmsl; i++)
{
Point3d p1, p2;
@ -2862,9 +2892,11 @@ namespace netgen
msf >> p2.X() >> p2.Y() >> p2.Z();
msf >> hi;
if (!msf.good())
throw NgException ("problem in mesh-size file\n");
throw NgException ("Mesh-size file error: Number of line definitions don't match specified list size\n");
RestrictLocalHLine (p1, p2, hi);
}
msf.close();
}