mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
compressed mesh files (zlib)
This commit is contained in:
parent
4370277c1e
commit
b225adb2cd
@ -1,4 +1,4 @@
|
||||
noinst_HEADERS = array.hpp myadt.hpp optmem.hpp sort.hpp table.hpp autodiff.hpp flags.hpp mystring.hpp spbita2d.hpp template.hpp autoptr.hpp hashtabl.hpp netgenout.hpp profiler.hpp stack.hpp bitarray.hpp seti.hpp symbolta.hpp dynamicmem.hpp parthreads.hpp mpi_interface.hpp
|
||||
noinst_HEADERS = array.hpp myadt.hpp optmem.hpp sort.hpp table.hpp autodiff.hpp flags.hpp mystring.hpp spbita2d.hpp template.hpp autoptr.hpp hashtabl.hpp netgenout.hpp profiler.hpp stack.hpp bitarray.hpp seti.hpp symbolta.hpp dynamicmem.hpp parthreads.hpp mpi_interface.hpp gzstream.h
|
||||
|
||||
# moveablemem.hpp
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
// Standard C++ Library".
|
||||
// ============================================================================
|
||||
|
||||
#include <gzstream.h>
|
||||
#include "gzstream.h"
|
||||
#include <iostream>
|
||||
#include <string.h> // for memcpy
|
||||
|
||||
|
@ -182,9 +182,11 @@ void Ng_LoadMesh (const char * filename)
|
||||
if (id == 0)
|
||||
{
|
||||
#endif
|
||||
|
||||
if ( string(filename).find(".vol") == string::npos )
|
||||
/*
|
||||
if ( (strlen (filename) > 4) &&
|
||||
strcmp (filename + (strlen (filename)-4), ".vol") != 0 )
|
||||
*/
|
||||
{
|
||||
mesh.Reset (new Mesh());
|
||||
ReadFile(*mesh,filename);
|
||||
@ -193,15 +195,21 @@ void Ng_LoadMesh (const char * filename)
|
||||
//mesh->CalcLocalH();
|
||||
return;
|
||||
}
|
||||
|
||||
ifstream infile(filename);
|
||||
Ng_LoadMeshFromStream(infile);
|
||||
|
||||
string fn(filename);
|
||||
|
||||
istream * infile;
|
||||
if (fn.substr (fn.length()-3, 3) == ".gz")
|
||||
infile = new igzstream (filename);
|
||||
else
|
||||
infile = new ifstream (filename);
|
||||
|
||||
Ng_LoadMeshFromStream(*infile);
|
||||
delete infile;
|
||||
|
||||
#ifdef PARALLEL
|
||||
if (ntasks > 1)
|
||||
{
|
||||
// MyMPI_SendCmd ("mesh");
|
||||
// mesh -> Distribute();
|
||||
|
||||
char * weightsfilename = new char [strlen(filename)+1];
|
||||
strcpy (weightsfilename, filename);
|
||||
|
@ -187,9 +187,9 @@ loadmeshinifile;
|
||||
.ngmenu.file add command -label "Save Mesh..." -accelerator "<s><m>" \
|
||||
-command {
|
||||
set types {
|
||||
{"Mesh file" {.vol} } }
|
||||
{"Mesh file" {.vol .vol.gz} } }
|
||||
|
||||
set file [tk_getSaveFile -filetypes $types -defaultextension ".vol" -initialfile $basefilename -initialdir $dirname ]
|
||||
set file [tk_getSaveFile -filetypes $types -defaultextension ".vol.gz" -initialfile $basefilename -initialdir $dirname ]
|
||||
if {$file != ""} {
|
||||
Ng_SaveMesh $file }
|
||||
AddRecentMeshFile $file;
|
||||
|
39
ng/ngpkg.cpp
39
ng/ngpkg.cpp
@ -224,8 +224,14 @@ namespace netgen
|
||||
mesh.Reset (new Mesh());
|
||||
try
|
||||
{
|
||||
ifstream infile(filename.c_str());
|
||||
mesh -> Load(infile);
|
||||
istream * infile;
|
||||
if (filename.substr (filename.length()-3, 3) == ".gz")
|
||||
infile = new igzstream (filename.c_str());
|
||||
else
|
||||
infile = new ifstream (filename.c_str());
|
||||
|
||||
// ifstream infile(filename.c_str());
|
||||
mesh -> Load(*infile);
|
||||
|
||||
#ifdef PARALLEL
|
||||
MyMPI_SendCmd ("mesh");
|
||||
@ -234,16 +240,15 @@ namespace netgen
|
||||
|
||||
for (int i = 0; i < geometryregister.Size(); i++)
|
||||
{
|
||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (infile);
|
||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (*infile);
|
||||
if (hgeom)
|
||||
{
|
||||
// delete ng_geometry;
|
||||
// ng_geometry = hgeom;
|
||||
ng_geometry.Reset (hgeom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete infile;
|
||||
|
||||
/*
|
||||
string auxstring;
|
||||
if(infile.good())
|
||||
@ -286,22 +291,22 @@ namespace netgen
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
const string filename (argv[1]);
|
||||
string filename (argv[1]);
|
||||
PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
|
||||
|
||||
ostream * outfile;
|
||||
if (filename.substr (filename.length()-3, 3) == ".gz")
|
||||
outfile = new ogzstream (filename.c_str());
|
||||
else
|
||||
outfile = new ofstream (filename.c_str());
|
||||
|
||||
// ofstream outfile(filename.c_str());
|
||||
ogzstream outfile( (filename+".gz").c_str());
|
||||
mesh -> Save (outfile);
|
||||
|
||||
outfile << endl << endl << "endmesh" << endl << endl;
|
||||
mesh -> Save (*outfile);
|
||||
*outfile << endl << endl << "endmesh" << endl << endl;
|
||||
|
||||
if (ng_geometry)
|
||||
ng_geometry -> SaveToMeshFile (outfile);
|
||||
/*
|
||||
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
|
||||
if (geometry && geometry->GetNSurf()) geometry->SaveSurfaces(outfile);
|
||||
*/
|
||||
ng_geometry -> SaveToMeshFile (*outfile);
|
||||
|
||||
delete outfile;
|
||||
PrintMessage (1, "Save mesh to file .... DONE!");
|
||||
return TCL_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user