read unv file update

This commit is contained in:
Joachim Schoeberl 2011-07-20 15:08:39 +00:00
parent 29fde94bc8
commit f0f57bfa52

View File

@ -85,23 +85,14 @@ namespace netgen
// Universal mesh (AVL)
if ( (strlen (filename) > 4) && if ( (strlen (filename) > 4) &&
strcmp (&filename[strlen (filename)-4], ".unv") == 0 ) strcmp (&filename[strlen (filename)-4], ".unv") == 0 )
{ {
// int i, j, k;
// double h;
char reco[100]; char reco[100];
// int np, nbe;
int invert; int invert;
ifstream in(filename); ifstream in(filename);
invert = 0; // globflags.GetDefineFlag ("invertsurfacemesh");
double scale = 1; // globflags.GetNumFlag ("scale", 1);
mesh.ClearFaceDescriptors(); mesh.ClearFaceDescriptors();
mesh.AddFaceDescriptor (FaceDescriptor(0,1,0,0)); mesh.AddFaceDescriptor (FaceDescriptor(0,1,0,0));
@ -109,58 +100,78 @@ namespace netgen
while (in.good()) while (in.good())
{ {
in >> reco; in >> reco;
if (strcmp (reco, "NODES") == 0) cout << "reco = " << reco << endl;
if (strcmp (reco, "2411") == 0)
{ {
cout << "nodes found" << endl; cout << "nodes found" << endl;
for (int j = 1; j <= 4; j++)
in >> reco; // read dummy
while (1) while (1)
{ {
int pi, hi; int pi, hi;
// double x, y, z; Point<3> p;
Point3d p;
in >> pi; in >> pi;
if (pi == -1) if (pi == -1)
break; break;
in >> hi >> hi >> hi; in >> hi >> hi >> hi;
in >> p.X() >> p.Y() >> p.Z(); in >> p(0) >> p(1) >> p(2);
p.X() *= scale;
p.Y() *= scale;
p.Z() *= scale;
cout << "p(" << pi << ") = "
<< p << endl;
mesh.AddPoint (p); mesh.AddPoint (p);
} }
cout << "read " << mesh.GetNP() << " points" << endl;
} }
if (strcmp (reco, "ELEMENTS") == 0) if (strcmp (reco, "2412") == 0)
{ {
cout << "elements found" << endl; cout << "elements found" << endl;
for (int j = 1; j <= 4; j++)
in >> reco; // read dummy
while (1) while (1)
{ {
int hi; int label, fe_id, phys_prop, mat_prop, color, nnodes;
in >> hi; int nodes[100];
if (hi == -1) break; int hi;
for (int j = 1; j <= 7; j++)
in >> hi; in >> label;
if (label == -1) break;
Element2d el; in >> fe_id >> phys_prop >> mat_prop >> color >> nnodes;
el.SetIndex(1);
in >> el.PNum(1) >> el.PNum(2) >> el.PNum(3); cout << "fe_id = " << fe_id << " col = " << color << ", nnodes = " << nnodes << endl;
if (invert) if (fe_id >= 11 && fe_id <= 32)
swap (el.PNum(2), el.PNum(3)); in >> hi >> hi >> hi;
mesh.AddSurfaceElement (el);
for (int j = 1; j <= 5; j++) for (int j = 0; j < nnodes; j++)
in >> hi; in >> nodes[j];
switch (fe_id)
{
case 41:
{
Element2d el (TRIG);
el.SetIndex (1);
for (int j = 0; j < nnodes; j++)
el[j] = nodes[j];
mesh.AddSurfaceElement (el);
break;
}
case 111:
{
Element el (TET);
el.SetIndex (1);
for (int j = 0; j < nnodes; j++)
el[j] = nodes[j];
mesh.AddVolumeElement (el);
break;
}
}
} }
} }
} }