mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-13 14:40:35 +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
|
# moveablemem.hpp
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
// Standard C++ Library".
|
// Standard C++ Library".
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
#include <gzstream.h>
|
#include "gzstream.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h> // for memcpy
|
#include <string.h> // for memcpy
|
||||||
|
|
||||||
|
@ -182,9 +182,11 @@ void Ng_LoadMesh (const char * filename)
|
|||||||
if (id == 0)
|
if (id == 0)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
if ( string(filename).find(".vol") == string::npos )
|
||||||
|
/*
|
||||||
if ( (strlen (filename) > 4) &&
|
if ( (strlen (filename) > 4) &&
|
||||||
strcmp (filename + (strlen (filename)-4), ".vol") != 0 )
|
strcmp (filename + (strlen (filename)-4), ".vol") != 0 )
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
mesh.Reset (new Mesh());
|
mesh.Reset (new Mesh());
|
||||||
ReadFile(*mesh,filename);
|
ReadFile(*mesh,filename);
|
||||||
@ -194,14 +196,20 @@ void Ng_LoadMesh (const char * filename)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifstream infile(filename);
|
string fn(filename);
|
||||||
Ng_LoadMeshFromStream(infile);
|
|
||||||
|
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
|
#ifdef PARALLEL
|
||||||
if (ntasks > 1)
|
if (ntasks > 1)
|
||||||
{
|
{
|
||||||
// MyMPI_SendCmd ("mesh");
|
|
||||||
// mesh -> Distribute();
|
|
||||||
|
|
||||||
char * weightsfilename = new char [strlen(filename)+1];
|
char * weightsfilename = new char [strlen(filename)+1];
|
||||||
strcpy (weightsfilename, filename);
|
strcpy (weightsfilename, filename);
|
||||||
|
@ -187,9 +187,9 @@ loadmeshinifile;
|
|||||||
.ngmenu.file add command -label "Save Mesh..." -accelerator "<s><m>" \
|
.ngmenu.file add command -label "Save Mesh..." -accelerator "<s><m>" \
|
||||||
-command {
|
-command {
|
||||||
set types {
|
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 != ""} {
|
if {$file != ""} {
|
||||||
Ng_SaveMesh $file }
|
Ng_SaveMesh $file }
|
||||||
AddRecentMeshFile $file;
|
AddRecentMeshFile $file;
|
||||||
|
35
ng/ngpkg.cpp
35
ng/ngpkg.cpp
@ -224,8 +224,14 @@ namespace netgen
|
|||||||
mesh.Reset (new Mesh());
|
mesh.Reset (new Mesh());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ifstream infile(filename.c_str());
|
istream * infile;
|
||||||
mesh -> Load(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
|
#ifdef PARALLEL
|
||||||
MyMPI_SendCmd ("mesh");
|
MyMPI_SendCmd ("mesh");
|
||||||
@ -234,15 +240,14 @@ namespace netgen
|
|||||||
|
|
||||||
for (int i = 0; i < geometryregister.Size(); i++)
|
for (int i = 0; i < geometryregister.Size(); i++)
|
||||||
{
|
{
|
||||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (infile);
|
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (*infile);
|
||||||
if (hgeom)
|
if (hgeom)
|
||||||
{
|
{
|
||||||
// delete ng_geometry;
|
|
||||||
// ng_geometry = hgeom;
|
|
||||||
ng_geometry.Reset (hgeom);
|
ng_geometry.Reset (hgeom);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete infile;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
string auxstring;
|
string auxstring;
|
||||||
@ -286,22 +291,22 @@ namespace netgen
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string filename (argv[1]);
|
string filename (argv[1]);
|
||||||
PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
|
PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
|
||||||
|
|
||||||
// ofstream outfile(filename.c_str());
|
ostream * outfile;
|
||||||
ogzstream outfile( (filename+".gz").c_str());
|
if (filename.substr (filename.length()-3, 3) == ".gz")
|
||||||
mesh -> Save (outfile);
|
outfile = new ogzstream (filename.c_str());
|
||||||
|
else
|
||||||
|
outfile = new ofstream (filename.c_str());
|
||||||
|
|
||||||
outfile << endl << endl << "endmesh" << endl << endl;
|
mesh -> Save (*outfile);
|
||||||
|
*outfile << endl << endl << "endmesh" << endl << endl;
|
||||||
|
|
||||||
if (ng_geometry)
|
if (ng_geometry)
|
||||||
ng_geometry -> SaveToMeshFile (outfile);
|
ng_geometry -> SaveToMeshFile (*outfile);
|
||||||
/*
|
|
||||||
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
|
|
||||||
if (geometry && geometry->GetNSurf()) geometry->SaveSurfaces(outfile);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
delete outfile;
|
||||||
PrintMessage (1, "Save mesh to file .... DONE!");
|
PrintMessage (1, "Save mesh to file .... DONE!");
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user