Change interface of LoadFromMeshFile

Fetch the first (geometry identification) token only once (and not on each try to load a different type)
This commit is contained in:
mhochsteger@cerbsim.com 2021-11-10 12:13:04 +01:00
parent 4d7ef21791
commit 17458889aa
5 changed files with 16 additions and 37 deletions

View File

@ -1620,7 +1620,7 @@ namespace netgen
{
public:
virtual NetgenGeometry * Load (string filename) const;
virtual NetgenGeometry * LoadFromMeshFile (istream & ist) const;
virtual NetgenGeometry * LoadFromMeshFile (istream & ist, string token) const;
// virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
};
@ -1659,23 +1659,15 @@ namespace netgen
return NULL;
}
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist) const
{
string auxstring;
if (ist.good())
{
ist >> auxstring;
if (auxstring == "csgsurfaces")
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist, string token) const
{
if (token != "csgsurfaces")
return nullptr;
CSGeometry * geometry = new CSGeometry ("");
geometry -> LoadSurfaces(ist);
return geometry;
}
// else
// ist.putback (auxstring);
}
return NULL;
}
class CSGInit

View File

@ -104,15 +104,8 @@ void Ng_LoadMeshFromStream ( istream & input )
mesh -> Load(input);
SetGlobalMesh (mesh);
for (int i = 0; i < geometryregister.Size(); i++)
{
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input);
if (hgeom)
{
ng_geometry.reset (hgeom);
break;
}
}
ng_geometry = geometryregister.LoadFromMeshFile (input);
if (!ng_geometry)
ng_geometry = make_shared<NetgenGeometry>();
mesh->SetGeometry (ng_geometry);

View File

@ -509,7 +509,7 @@ namespace netgen
{
for (int i = 0; i < Size(); i++)
{
NetgenGeometry * hgeom = (*this)[i]->LoadFromMeshFile (ist);
NetgenGeometry * hgeom = (*this)[i]->LoadFromMeshFile (ist, token);
if (hgeom)
return shared_ptr<NetgenGeometry>(hgeom);
}

View File

@ -224,7 +224,7 @@ namespace netgen
public:
virtual ~GeometryRegister();
virtual NetgenGeometry * Load (string filename) const = 0;
virtual NetgenGeometry * LoadFromMeshFile (istream & /* ist */) const { return NULL; }
virtual NetgenGeometry * LoadFromMeshFile (istream & /* ist */, string) const { return NULL; }
virtual class VisualScene * GetVisualScene (const NetgenGeometry * /* geom */) const
{ return NULL; }
virtual void SetParameters (Tcl_Interp * /* interp */) { ; }

View File

@ -233,15 +233,9 @@ namespace netgen
MyMPI_SendCmd ("mesh");
mesh -> Distribute();
#endif
for (int i = 0; i < geometryregister.Size(); i++)
{
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (*infile);
if (hgeom)
{
ng_geometry = shared_ptr<NetgenGeometry>(hgeom);
break;
}
}
auto geo = geometryregister.LoadFromMeshFile (*infile);
if(geo)
ng_geometry = geo;
delete infile;
/*