mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +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:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
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;
|
// virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1659,22 +1659,14 @@ namespace netgen
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist) const
|
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist, string token) const
|
||||||
{
|
{
|
||||||
string auxstring;
|
if (token != "csgsurfaces")
|
||||||
if (ist.good())
|
return nullptr;
|
||||||
{
|
|
||||||
ist >> auxstring;
|
CSGeometry * geometry = new CSGeometry ("");
|
||||||
if (auxstring == "csgsurfaces")
|
geometry -> LoadSurfaces(ist);
|
||||||
{
|
return geometry;
|
||||||
CSGeometry * geometry = new CSGeometry ("");
|
|
||||||
geometry -> LoadSurfaces(ist);
|
|
||||||
return geometry;
|
|
||||||
}
|
|
||||||
// else
|
|
||||||
// ist.putback (auxstring);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,15 +104,8 @@ void Ng_LoadMeshFromStream ( istream & input )
|
|||||||
mesh -> Load(input);
|
mesh -> Load(input);
|
||||||
|
|
||||||
SetGlobalMesh (mesh);
|
SetGlobalMesh (mesh);
|
||||||
for (int i = 0; i < geometryregister.Size(); i++)
|
ng_geometry = geometryregister.LoadFromMeshFile (input);
|
||||||
{
|
|
||||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input);
|
|
||||||
if (hgeom)
|
|
||||||
{
|
|
||||||
ng_geometry.reset (hgeom);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!ng_geometry)
|
if (!ng_geometry)
|
||||||
ng_geometry = make_shared<NetgenGeometry>();
|
ng_geometry = make_shared<NetgenGeometry>();
|
||||||
mesh->SetGeometry (ng_geometry);
|
mesh->SetGeometry (ng_geometry);
|
||||||
|
@ -509,7 +509,7 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < Size(); i++)
|
for (int i = 0; i < Size(); i++)
|
||||||
{
|
{
|
||||||
NetgenGeometry * hgeom = (*this)[i]->LoadFromMeshFile (ist);
|
NetgenGeometry * hgeom = (*this)[i]->LoadFromMeshFile (ist, token);
|
||||||
if (hgeom)
|
if (hgeom)
|
||||||
return shared_ptr<NetgenGeometry>(hgeom);
|
return shared_ptr<NetgenGeometry>(hgeom);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ namespace netgen
|
|||||||
public:
|
public:
|
||||||
virtual ~GeometryRegister();
|
virtual ~GeometryRegister();
|
||||||
virtual NetgenGeometry * Load (string filename) const = 0;
|
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
|
virtual class VisualScene * GetVisualScene (const NetgenGeometry * /* geom */) const
|
||||||
{ return NULL; }
|
{ return NULL; }
|
||||||
virtual void SetParameters (Tcl_Interp * /* interp */) { ; }
|
virtual void SetParameters (Tcl_Interp * /* interp */) { ; }
|
||||||
|
14
ng/ngpkg.cpp
14
ng/ngpkg.cpp
@ -233,16 +233,10 @@ namespace netgen
|
|||||||
MyMPI_SendCmd ("mesh");
|
MyMPI_SendCmd ("mesh");
|
||||||
mesh -> Distribute();
|
mesh -> Distribute();
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < geometryregister.Size(); i++)
|
auto geo = geometryregister.LoadFromMeshFile (*infile);
|
||||||
{
|
if(geo)
|
||||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (*infile);
|
ng_geometry = geo;
|
||||||
if (hgeom)
|
delete infile;
|
||||||
{
|
|
||||||
ng_geometry = shared_ptr<NetgenGeometry>(hgeom);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete infile;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
string auxstring;
|
string auxstring;
|
||||||
|
Loading…
Reference in New Issue
Block a user