mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 04:50:34 +05:00
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:
parent
4d7ef21791
commit
17458889aa
@ -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,22 +1659,14 @@ namespace netgen
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist) const
|
||||
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist, string token) const
|
||||
{
|
||||
string auxstring;
|
||||
if (ist.good())
|
||||
{
|
||||
ist >> auxstring;
|
||||
if (auxstring == "csgsurfaces")
|
||||
{
|
||||
CSGeometry * geometry = new CSGeometry ("");
|
||||
geometry -> LoadSurfaces(ist);
|
||||
return geometry;
|
||||
}
|
||||
// else
|
||||
// ist.putback (auxstring);
|
||||
}
|
||||
return NULL;
|
||||
if (token != "csgsurfaces")
|
||||
return nullptr;
|
||||
|
||||
CSGeometry * geometry = new CSGeometry ("");
|
||||
geometry -> LoadSurfaces(ist);
|
||||
return geometry;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */) { ; }
|
||||
|
14
ng/ngpkg.cpp
14
ng/ngpkg.cpp
@ -233,16 +233,10 @@ 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;
|
||||
}
|
||||
}
|
||||
delete infile;
|
||||
auto geo = geometryregister.LoadFromMeshFile (*infile);
|
||||
if(geo)
|
||||
ng_geometry = geo;
|
||||
delete infile;
|
||||
|
||||
/*
|
||||
string auxstring;
|
||||
|
Loading…
Reference in New Issue
Block a user