Use TextOutArchive to store OCCGeometry in mesh files

This commit is contained in:
mhochsteger@cerbsim.com 2021-11-10 18:19:18 +01:00
parent 17458889aa
commit e0afa0a916
3 changed files with 31 additions and 0 deletions

View File

@ -507,6 +507,24 @@ namespace netgen
shared_ptr<NetgenGeometry> GeometryRegisterArray :: LoadFromMeshFile (istream & ist) const
{
if (!ist.good())
return nullptr;
string token;
ist >> token;
if(token == "TextOutArchive")
{
NetgenGeometry *geo = nullptr;
size_t string_length;
ist >> string_length;
string buffer(string_length+1, '\0');
ist.read(&buffer[0], string_length);
auto ss = make_shared<stringstream>(buffer);
TextInArchive in(ss);
in & geo;
return shared_ptr<NetgenGeometry>(geo);
}
for (int i = 0; i < Size(); i++)
{
NetgenGeometry * hgeom = (*this)[i]->LoadFromMeshFile (ist, token);

View File

@ -1654,6 +1654,18 @@ namespace netgen
}
}
void OCCGeometry :: SaveToMeshFile (ostream & ost) const
{
auto ss = make_shared<stringstream>();
TextOutArchive out(ss);
NetgenGeometry *geo = const_cast<OCCGeometry*>(this);
out & geo;
ost << "TextOutArchive" << endl;
ost << ss->str().size() << endl;
ost << ss->str();
}
void OCCGeometry :: DoArchive(Archive& ar)
{
if(ar.Output())

View File

@ -380,6 +380,7 @@ namespace netgen
void FinalizeMesh(Mesh& mesh) const override;
void Save (string filename) const override;
void SaveToMeshFile (ostream & /* ost */) const override;
void DoArchive(Archive& ar) override;