mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 14:10:34 +05:00
* Improved error checking for mesh size file loading / reading
* Corrected uninitialized variables in mesh size file function
This commit is contained in:
parent
ac8ac8aa14
commit
87404f51c9
@ -2826,45 +2826,77 @@ namespace netgen
|
|||||||
|
|
||||||
void Mesh :: LoadLocalMeshSize (const char * meshsizefilename)
|
void Mesh :: LoadLocalMeshSize (const char * meshsizefilename)
|
||||||
{
|
{
|
||||||
if (!meshsizefilename) return;
|
// Philippose - 10/03/2009
|
||||||
|
// Improve error checking when loading and reading
|
||||||
|
// the local mesh size file
|
||||||
|
|
||||||
ifstream msf(meshsizefilename);
|
if (!meshsizefilename) return;
|
||||||
|
|
||||||
// Philippose - 09/03/2009
|
ifstream msf(meshsizefilename);
|
||||||
// Adding print message information in case the specified
|
|
||||||
// does not exist, or does not load successfully due to
|
|
||||||
// other reasons such as access rights, etc...
|
|
||||||
if (!msf)
|
|
||||||
{
|
|
||||||
PrintMessage(2, "Error loading Mesh Size File: ", meshsizefilename, "....","Skipping!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintMessage (3, "Load local mesh-size");
|
// Philippose - 09/03/2009
|
||||||
int nmsp, nmsl;
|
// Adding print message information in case the specified
|
||||||
msf >> nmsp;
|
// does not exist, or does not load successfully due to
|
||||||
for (int i = 0; i < nmsp; i++)
|
// other reasons such as access rights, etc...
|
||||||
{
|
if (!msf)
|
||||||
Point3d pi;
|
{
|
||||||
double hi;
|
PrintMessage(3, "Error loading mesh size file: ", meshsizefilename, "....","Skipping!");
|
||||||
msf >> pi.X() >> pi.Y() >> pi.Z();
|
return;
|
||||||
msf >> hi;
|
}
|
||||||
if (!msf.good())
|
|
||||||
throw NgException ("problem in mesh-size file\n");
|
PrintMessage (3, "Load local mesh-size file: ", meshsizefilename);
|
||||||
RestrictLocalH (pi, hi);
|
|
||||||
}
|
int nmsp = 0;
|
||||||
msf >> nmsl;
|
int nmsl = 0;
|
||||||
for (int i = 0; i < nmsl; i++)
|
|
||||||
{
|
msf >> nmsp;
|
||||||
Point3d p1, p2;
|
if(nmsp > 0)
|
||||||
double hi;
|
{
|
||||||
msf >> p1.X() >> p1.Y() >> p1.Z();
|
if(!msf.good())
|
||||||
msf >> p2.X() >> p2.Y() >> p2.Z();
|
throw NgException ("Mesh-size file error: No points found\n");
|
||||||
msf >> hi;
|
PrintMessage (4, "Number of mesh-size restriction points: ", nmsp);
|
||||||
if (!msf.good())
|
}
|
||||||
throw NgException ("problem in mesh-size file\n");
|
else
|
||||||
RestrictLocalHLine (p1, p2, hi);
|
{
|
||||||
}
|
msf.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < nmsp; i++)
|
||||||
|
{
|
||||||
|
Point3d pi;
|
||||||
|
double hi;
|
||||||
|
msf >> pi.X() >> pi.Y() >> pi.Z();
|
||||||
|
msf >> hi;
|
||||||
|
if (!msf.good())
|
||||||
|
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;
|
||||||
|
double hi;
|
||||||
|
msf >> p1.X() >> p1.Y() >> p1.Z();
|
||||||
|
msf >> p2.X() >> p2.Y() >> p2.Z();
|
||||||
|
msf >> hi;
|
||||||
|
if (!msf.good())
|
||||||
|
throw NgException ("Mesh-size file error: Number of line definitions don't match specified list size\n");
|
||||||
|
RestrictLocalHLine (p1, p2, hi);
|
||||||
|
}
|
||||||
|
|
||||||
|
msf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user