mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
use std::filesystem::path
This commit is contained in:
parent
c5eeabace1
commit
cf59f297a7
@ -5,6 +5,7 @@
|
|||||||
#include <array> // for array
|
#include <array> // for array
|
||||||
#include <complex> // for complex
|
#include <complex> // for complex
|
||||||
#include <cstring> // for size_t, strlen
|
#include <cstring> // for size_t, strlen
|
||||||
|
#include <filesystem> // for path
|
||||||
#include <fstream> // for ifstream, ofstream
|
#include <fstream> // for ifstream, ofstream
|
||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <map> // for map
|
#include <map> // for map
|
||||||
@ -740,7 +741,7 @@ namespace ngcore
|
|||||||
BinaryOutArchive(std::shared_ptr<std::ostream>&& astream)
|
BinaryOutArchive(std::shared_ptr<std::ostream>&& astream)
|
||||||
: Archive(true), stream(std::move(astream))
|
: Archive(true), stream(std::move(astream))
|
||||||
{ }
|
{ }
|
||||||
BinaryOutArchive(const std::string& filename)
|
BinaryOutArchive(const std::filesystem::path& filename)
|
||||||
: BinaryOutArchive(std::make_shared<std::ofstream>(filename)) {}
|
: BinaryOutArchive(std::make_shared<std::ofstream>(filename)) {}
|
||||||
~BinaryOutArchive () override { FlushBuffer(); }
|
~BinaryOutArchive () override { FlushBuffer(); }
|
||||||
|
|
||||||
@ -828,7 +829,7 @@ namespace ngcore
|
|||||||
BinaryInArchive (std::shared_ptr<std::istream>&& astream)
|
BinaryInArchive (std::shared_ptr<std::istream>&& astream)
|
||||||
: Archive(false), stream(std::move(astream))
|
: Archive(false), stream(std::move(astream))
|
||||||
{ }
|
{ }
|
||||||
BinaryInArchive (const std::string& filename)
|
BinaryInArchive (const std::filesystem::path& filename)
|
||||||
: BinaryInArchive(std::make_shared<std::ifstream>(filename)) { ; }
|
: BinaryInArchive(std::make_shared<std::ifstream>(filename)) { ; }
|
||||||
|
|
||||||
using Archive::operator&;
|
using Archive::operator&;
|
||||||
@ -903,7 +904,7 @@ namespace ngcore
|
|||||||
TextOutArchive (std::shared_ptr<std::ostream>&& astream)
|
TextOutArchive (std::shared_ptr<std::ostream>&& astream)
|
||||||
: Archive(true), stream(std::move(astream))
|
: Archive(true), stream(std::move(astream))
|
||||||
{ }
|
{ }
|
||||||
TextOutArchive (const std::string& filename) :
|
TextOutArchive (const std::filesystem::path& filename) :
|
||||||
TextOutArchive(std::make_shared<std::ofstream>(filename)) { }
|
TextOutArchive(std::make_shared<std::ofstream>(filename)) { }
|
||||||
|
|
||||||
using Archive::operator&;
|
using Archive::operator&;
|
||||||
@ -958,7 +959,7 @@ namespace ngcore
|
|||||||
TextInArchive (std::shared_ptr<std::istream>&& astream) :
|
TextInArchive (std::shared_ptr<std::istream>&& astream) :
|
||||||
Archive(false), stream(std::move(astream))
|
Archive(false), stream(std::move(astream))
|
||||||
{ }
|
{ }
|
||||||
TextInArchive (const std::string& filename)
|
TextInArchive (const std::filesystem::path& filename)
|
||||||
: TextInArchive(std::make_shared<std::ifstream>(filename)) {}
|
: TextInArchive(std::make_shared<std::ifstream>(filename)) {}
|
||||||
|
|
||||||
using Archive::operator&;
|
using Archive::operator&;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <pybind11/operators.h>
|
#include <pybind11/operators.h>
|
||||||
#include <pybind11/numpy.h>
|
#include <pybind11/numpy.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/stl/filesystem.h>
|
||||||
|
|
||||||
#include "array.hpp"
|
#include "array.hpp"
|
||||||
#include "table.hpp"
|
#include "table.hpp"
|
||||||
|
@ -112,13 +112,12 @@ namespace ngcore
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
NGCORE_API std::string GetTempFilename()
|
NGCORE_API std::filesystem::path GetTempFilename()
|
||||||
{
|
{
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
auto path = std::filesystem::temp_directory_path();
|
auto path = std::filesystem::temp_directory_path();
|
||||||
std::string filename = ".temp_netgen_file_"+ToString(counter++)+"_"+ToString(GetTimeCounter());
|
path += ".temp_netgen_file_"+ToString(counter++)+"_"+ToString(GetTimeCounter());
|
||||||
path.append(filename);
|
return path;
|
||||||
return path.string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ngcore
|
} // namespace ngcore
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <filesystem>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -81,6 +82,22 @@ namespace ngcore
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string ToLower( const std::string & s )
|
||||||
|
{
|
||||||
|
std::string res;
|
||||||
|
res.reserve(s.size());
|
||||||
|
|
||||||
|
for(auto & c : res)
|
||||||
|
res.push_back(tolower(c));
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string ToLower( const std::filesystem::path & p )
|
||||||
|
{
|
||||||
|
return ToLower(p.string());
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
std::ostream& operator << (std::ostream& ost, const std::map<T1,T2>& map)
|
std::ostream& operator << (std::ostream& ost, const std::map<T1,T2>& map)
|
||||||
{
|
{
|
||||||
@ -201,7 +218,7 @@ namespace ngcore
|
|||||||
NGCORE_API int GetCompiledSIMDSize();
|
NGCORE_API int GetCompiledSIMDSize();
|
||||||
NGCORE_API bool IsRangeCheckEnabled();
|
NGCORE_API bool IsRangeCheckEnabled();
|
||||||
|
|
||||||
NGCORE_API std::string GetTempFilename();
|
NGCORE_API std::filesystem::path GetTempFilename();
|
||||||
|
|
||||||
} // namespace ngcore
|
} // namespace ngcore
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSGeometry :: Save (string filename) const
|
void CSGeometry :: Save (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
ofstream ost (filename.c_str());
|
ofstream ost (filename.c_str());
|
||||||
Save (ost);
|
Save (ost);
|
||||||
@ -1619,21 +1619,21 @@ namespace netgen
|
|||||||
class CSGeometryRegister : public GeometryRegister
|
class CSGeometryRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const;
|
||||||
virtual NetgenGeometry * LoadFromMeshFile (istream & ist, string token) const;
|
virtual NetgenGeometry * LoadFromMeshFile (istream & ist, string token) const;
|
||||||
// virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
// virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CSGeometry * ParseCSG (istream & istr, CSGeometry *instance=nullptr);
|
extern CSGeometry * ParseCSG (istream & istr, CSGeometry *instance=nullptr);
|
||||||
|
|
||||||
NetgenGeometry * CSGeometryRegister :: Load (string filename) const
|
NetgenGeometry * CSGeometryRegister :: Load (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
const char * cfilename = filename.c_str();
|
string extension = filename.extension().string();
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-3], "geo") == 0)
|
if (extension == ".geo")
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load CSG geometry file ", cfilename);
|
PrintMessage (1, "Load CSG geometry file ", filename);
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
ifstream infile(filename);
|
||||||
|
|
||||||
CSGeometry * hgeom = ParseCSG (infile);
|
CSGeometry * hgeom = ParseCSG (infile);
|
||||||
if (!hgeom)
|
if (!hgeom)
|
||||||
@ -1643,19 +1643,17 @@ namespace netgen
|
|||||||
return hgeom;
|
return hgeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-3], "ngg") == 0)
|
if (extension == ".ngg")
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load new CSG geometry file ", cfilename);
|
PrintMessage (1, "Load new CSG geometry file ", filename);
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
ifstream infile(filename);
|
||||||
CSGeometry * hgeom = new CSGeometry("");
|
CSGeometry * hgeom = new CSGeometry("");
|
||||||
hgeom -> Load (infile);
|
hgeom -> Load (infile);
|
||||||
|
|
||||||
return hgeom;
|
return hgeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ namespace netgen
|
|||||||
|
|
||||||
void Clean ();
|
void Clean ();
|
||||||
|
|
||||||
virtual void Save (string filename) const override;
|
virtual void Save (const filesystem::path & filename) const override;
|
||||||
void Save (ostream & ost) const;
|
void Save (ostream & ost) const;
|
||||||
void Load (istream & ist);
|
void Load (istream & ist);
|
||||||
|
|
||||||
|
@ -547,86 +547,10 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
class CSGeometryRegister : public GeometryRegister
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
|
||||||
virtual NetgenGeometry * LoadFromMeshFile (istream & ist) const;
|
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CSGeometry * ParseCSG (istream & istr);
|
|
||||||
|
|
||||||
NetgenGeometry * CSGeometryRegister :: Load (string filename) const
|
|
||||||
{
|
|
||||||
const char * cfilename = filename.c_str();
|
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-3], "geo") == 0)
|
|
||||||
{
|
|
||||||
PrintMessage (1, "Load CSG geometry file ", cfilename);
|
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
|
||||||
|
|
||||||
CSGeometry * hgeom = ParseCSG (infile);
|
|
||||||
if (!hgeom)
|
|
||||||
throw NgException ("geo-file should start with 'algebraic3d'");
|
|
||||||
|
|
||||||
hgeom -> FindIdenticSurfaces(1e-8 * hgeom->MaxSize());
|
|
||||||
return hgeom;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-3], "ngg") == 0)
|
|
||||||
{
|
|
||||||
PrintMessage (1, "Load new CSG geometry file ", cfilename);
|
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
|
||||||
CSGeometry * hgeom = new CSGeometry("");
|
|
||||||
hgeom -> Load (infile);
|
|
||||||
|
|
||||||
return hgeom;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist) 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
VisualScene * CSGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
|
|
||||||
{
|
|
||||||
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry.get());
|
|
||||||
if (geometry)
|
|
||||||
{
|
|
||||||
vsgeom.SetGeometry (geometry);
|
|
||||||
return &vsgeom;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CSGeometryVisRegister : public GeometryRegister
|
class CSGeometryVisRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const { return NULL; }
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const { return NULL; }
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace GZSTREAM_NAMESPACE {
|
|||||||
// class gzstreambuf:
|
// class gzstreambuf:
|
||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
|
|
||||||
gzstreambuf* gzstreambuf::open( const char* name, int open_mode) {
|
gzstreambuf* gzstreambuf::open( const filesystem::path & name, int open_mode) {
|
||||||
if ( is_open())
|
if ( is_open())
|
||||||
return (gzstreambuf*)0;
|
return (gzstreambuf*)0;
|
||||||
mode = open_mode;
|
mode = open_mode;
|
||||||
@ -60,7 +60,11 @@ gzstreambuf* gzstreambuf::open( const char* name, int open_mode) {
|
|||||||
*fmodeptr++ = 'w';
|
*fmodeptr++ = 'w';
|
||||||
*fmodeptr++ = 'b';
|
*fmodeptr++ = 'b';
|
||||||
*fmodeptr = '\0';
|
*fmodeptr = '\0';
|
||||||
file = gzopen( name, fmode);
|
#ifdef WIN32
|
||||||
|
file = gzopen_w( name.c_str(), fmode);
|
||||||
|
#else // WIN32
|
||||||
|
file = gzopen( name.c_str(), fmode);
|
||||||
|
#endif // WIN32
|
||||||
if (file == 0)
|
if (file == 0)
|
||||||
return (gzstreambuf*)0;
|
return (gzstreambuf*)0;
|
||||||
opened = 1;
|
opened = 1;
|
||||||
@ -139,17 +143,17 @@ int gzstreambuf::sync() {
|
|||||||
// class gzstreambase:
|
// class gzstreambase:
|
||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
|
|
||||||
gzstreambase::gzstreambase( const char* name, int mode) {
|
gzstreambase::gzstreambase( const filesystem::path & name, int mode) {
|
||||||
init( &buf);
|
init( &buf);
|
||||||
open( name, mode);
|
open( name.c_str(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
gzstreambase::~gzstreambase() {
|
gzstreambase::~gzstreambase() {
|
||||||
buf.close();
|
buf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gzstreambase::open( const char* name, int open_mode) {
|
void gzstreambase::open( const filesystem::path & name, int open_mode) {
|
||||||
if ( ! buf.open( name, open_mode))
|
if ( ! buf.open( name.c_str(), open_mode))
|
||||||
clear( rdstate() | std::ios::badbit);
|
clear( rdstate() | std::ios::badbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
// ASSERT: both input & output capabilities will not be used together
|
// ASSERT: both input & output capabilities will not be used together
|
||||||
}
|
}
|
||||||
int is_open() { return opened; }
|
int is_open() { return opened; }
|
||||||
gzstreambuf* open( const char* name, int open_mode);
|
gzstreambuf* open( const filesystem::path & name, int open_mode);
|
||||||
gzstreambuf* close();
|
gzstreambuf* close();
|
||||||
~gzstreambuf() { close(); }
|
~gzstreambuf() { close(); }
|
||||||
|
|
||||||
@ -76,9 +76,9 @@ protected:
|
|||||||
gzstreambuf buf;
|
gzstreambuf buf;
|
||||||
public:
|
public:
|
||||||
gzstreambase() { init(&buf); }
|
gzstreambase() { init(&buf); }
|
||||||
DLL_HEADER gzstreambase( const char* name, int open_mode);
|
DLL_HEADER gzstreambase( const filesystem::path & name, int open_mode);
|
||||||
DLL_HEADER ~gzstreambase();
|
DLL_HEADER ~gzstreambase();
|
||||||
void open( const char* name, int open_mode);
|
void open( const filesystem::path & name, int open_mode);
|
||||||
void close();
|
void close();
|
||||||
gzstreambuf* rdbuf() { return &buf; }
|
gzstreambuf* rdbuf() { return &buf; }
|
||||||
};
|
};
|
||||||
@ -92,10 +92,10 @@ public:
|
|||||||
class DLL_HEADER igzstream : public gzstreambase, public std::istream {
|
class DLL_HEADER igzstream : public gzstreambase, public std::istream {
|
||||||
public:
|
public:
|
||||||
igzstream() : std::istream( &buf) {}
|
igzstream() : std::istream( &buf) {}
|
||||||
igzstream( const char* name, int open_mode = std::ios::in)
|
igzstream( const filesystem::path & name, int open_mode = std::ios::in)
|
||||||
: gzstreambase( name, open_mode), std::istream( &buf) {}
|
: gzstreambase( name, open_mode), std::istream( &buf) {}
|
||||||
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
|
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
|
||||||
void open( const char* name, int open_mode = std::ios::in) {
|
void open( const filesystem::path & name, int open_mode = std::ios::in) {
|
||||||
gzstreambase::open( name, open_mode);
|
gzstreambase::open( name, open_mode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -103,10 +103,10 @@ public:
|
|||||||
class DLL_HEADER ogzstream : public gzstreambase, public std::ostream {
|
class DLL_HEADER ogzstream : public gzstreambase, public std::ostream {
|
||||||
public:
|
public:
|
||||||
ogzstream() : std::ostream( &buf) {}
|
ogzstream() : std::ostream( &buf) {}
|
||||||
ogzstream( const char* name, int mode = std::ios::out)
|
ogzstream( const filesystem::path & name, int mode = std::ios::out)
|
||||||
: gzstreambase( name, mode), std::ostream( &buf) {}
|
: gzstreambase( name, mode), std::ostream( &buf) {}
|
||||||
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
|
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
|
||||||
void open( const char* name, int open_mode = std::ios::out) {
|
void open( const filesystem::path & name, int open_mode = std::ios::out) {
|
||||||
gzstreambase::open( name, open_mode);
|
gzstreambase::open( name, open_mode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -223,6 +223,10 @@ MyStr::MyStr(const string & st)
|
|||||||
strcpy (str, st.c_str());
|
strcpy (str, st.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyStr::MyStr(const filesystem::path & path)
|
||||||
|
: MyStr(path.string())
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MyStr MyStr::Left(unsigned r)
|
MyStr MyStr::Left(unsigned r)
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#ifndef MYSTRING__H
|
#ifndef MYSTRING__H
|
||||||
#define MYSTRING__H
|
#define MYSTRING__H
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -58,6 +60,7 @@ public:
|
|||||||
MyStr(const Point3d& p);
|
MyStr(const Point3d& p);
|
||||||
MyStr(const Vec3d& p);
|
MyStr(const Vec3d& p);
|
||||||
MyStr(const string & st);
|
MyStr(const string & st);
|
||||||
|
MyStr(const filesystem::path & st);
|
||||||
|
|
||||||
~MyStr();
|
~MyStr();
|
||||||
MyStr Left(unsigned);
|
MyStr Left(unsigned);
|
||||||
|
@ -21,7 +21,7 @@ namespace netgen
|
|||||||
class SplineGeometryVisRegister : public GeometryRegister
|
class SplineGeometryVisRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const { return NULL; }
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const { return NULL; }
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ namespace netgen
|
|||||||
return Vec<3> (0,0,1);
|
return Vec<3> (0,0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplineGeometry2d :: Load (const char * filename)
|
void SplineGeometry2d :: Load (const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
ifstream infile;
|
ifstream infile;
|
||||||
@ -104,7 +104,7 @@ namespace netgen
|
|||||||
|
|
||||||
if ( ! infile.good() )
|
if ( ! infile.good() )
|
||||||
throw NgException(string ("Input file '") +
|
throw NgException(string ("Input file '") +
|
||||||
string (filename) +
|
filename.string() +
|
||||||
string ("' not available!"));
|
string ("' not available!"));
|
||||||
|
|
||||||
TestComment ( infile );
|
TestComment ( infile );
|
||||||
@ -1075,21 +1075,20 @@ namespace netgen
|
|||||||
class SplineGeometryRegister : public GeometryRegister
|
class SplineGeometryRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
NetgenGeometry * SplineGeometryRegister :: Load (string filename) const
|
NetgenGeometry * SplineGeometryRegister :: Load (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
const char * cfilename = filename.c_str();
|
string ext = ToLower(filename.extension());
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-4], "in2d") == 0)
|
if (ext == ".in2d")
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load 2D-Spline geometry file ", cfilename);
|
PrintMessage (1, "Load 2D-Spline geometry file ", filename);
|
||||||
|
|
||||||
|
ifstream infile(filename);
|
||||||
ifstream infile(cfilename);
|
|
||||||
|
|
||||||
SplineGeometry2d * hgeom = new SplineGeometry2d();
|
SplineGeometry2d * hgeom = new SplineGeometry2d();
|
||||||
hgeom -> Load (cfilename);
|
hgeom -> Load (filename);
|
||||||
return hgeom;
|
return hgeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ namespace netgen
|
|||||||
public:
|
public:
|
||||||
DLL_HEADER virtual ~SplineGeometry2d();
|
DLL_HEADER virtual ~SplineGeometry2d();
|
||||||
|
|
||||||
DLL_HEADER void Load (const char * filename);
|
DLL_HEADER void Load (const filesystem::path & filename);
|
||||||
|
|
||||||
DLL_HEADER void LoadData( ifstream & infile );
|
DLL_HEADER void LoadData( ifstream & infile );
|
||||||
DLL_HEADER void LoadDataNew ( ifstream & infile );
|
DLL_HEADER void LoadDataNew ( ifstream & infile );
|
||||||
|
@ -60,9 +60,9 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void ReadFNFFormat (Mesh & mesh,
|
void ReadFNFFormat (Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
ifstream fin (filename.c_str());
|
ifstream fin (filename);
|
||||||
|
|
||||||
string buf;
|
string buf;
|
||||||
|
|
||||||
|
@ -20,10 +20,8 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void ReadTETFormat (Mesh & mesh,
|
void ReadTETFormat (Mesh & mesh,
|
||||||
const string & hfilename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
const char * filename = hfilename.c_str();
|
|
||||||
|
|
||||||
cout << "Reading .tet mesh" << endl;
|
cout << "Reading .tet mesh" << endl;
|
||||||
|
|
||||||
ifstream in (filename);
|
ifstream in (filename);
|
||||||
|
@ -15,22 +15,18 @@
|
|||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
void ReadFile (Mesh & mesh,
|
void ReadFile (Mesh & mesh,
|
||||||
const string & hfilename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
PrintMessage(3, "Read User File");
|
PrintMessage(3, "Read User File");
|
||||||
|
|
||||||
const char * filename = hfilename.c_str();
|
auto ext = filename.extension();
|
||||||
|
|
||||||
char reco[100];
|
char reco[100];
|
||||||
int np, nbe;
|
int np, nbe;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ".surf" - mesh
|
if ( ext == ".surf" )
|
||||||
|
|
||||||
if ( (strlen (filename) > 5) &&
|
|
||||||
strcmp (&filename[strlen (filename)-5], ".surf") == 0 )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
cout << "Surface file" << endl;
|
cout << "Surface file" << endl;
|
||||||
|
|
||||||
@ -80,11 +76,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( ext == ".unv" )
|
||||||
|
|
||||||
|
|
||||||
if ( (strlen (filename) > 4) &&
|
|
||||||
strcmp (&filename[strlen (filename)-4], ".unv") == 0 )
|
|
||||||
{
|
{
|
||||||
char reco[100];
|
char reco[100];
|
||||||
// int invert;
|
// int invert;
|
||||||
@ -407,8 +399,7 @@ namespace netgen
|
|||||||
|
|
||||||
// fepp format2d:
|
// fepp format2d:
|
||||||
|
|
||||||
if ( (strlen (filename) > 7) &&
|
if ( ext == ".mesh2d" )
|
||||||
strcmp (&filename[strlen (filename)-7], ".mesh2d") == 0 )
|
|
||||||
{
|
{
|
||||||
cout << "Reading FEPP2D Mesh" << endl;
|
cout << "Reading FEPP2D Mesh" << endl;
|
||||||
|
|
||||||
@ -449,8 +440,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if ( (strlen (filename) > 5) &&
|
else if ( ext == ".mesh" )
|
||||||
strcmp (&filename[strlen (filename)-5], ".mesh") == 0 )
|
|
||||||
{
|
{
|
||||||
cout << "Reading Neutral Format" << endl;
|
cout << "Reading Neutral Format" << endl;
|
||||||
|
|
||||||
@ -522,21 +512,17 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( (strlen (filename) > 4) &&
|
if ( ext == ".emt" )
|
||||||
strcmp (&filename[strlen (filename)-4], ".emt") == 0 )
|
|
||||||
{
|
{
|
||||||
ifstream inemt (filename);
|
ifstream inemt (filename);
|
||||||
|
|
||||||
string pktfile = filename;
|
auto pktfile = filename;
|
||||||
int len = strlen (filename);
|
pktfile.replace_extension("pkt");
|
||||||
pktfile[len-3] = 'p';
|
|
||||||
pktfile[len-2] = 'k';
|
|
||||||
pktfile[len-1] = 't';
|
|
||||||
cout << "pktfile = " << pktfile << endl;
|
cout << "pktfile = " << pktfile << endl;
|
||||||
|
|
||||||
int np, nse, i;
|
int np, nse, i;
|
||||||
int bcprop;
|
int bcprop;
|
||||||
ifstream inpkt (pktfile.c_str());
|
ifstream inpkt (pktfile);
|
||||||
inpkt >> np;
|
inpkt >> np;
|
||||||
NgArray<double> values(np);
|
NgArray<double> values(np);
|
||||||
for (i = 1; i <= np; i++)
|
for (i = 1; i <= np; i++)
|
||||||
@ -629,31 +615,20 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
// .tet mesh
|
// .tet mesh
|
||||||
if ( (strlen (filename) > 4) &&
|
if ( ext == ".tet" )
|
||||||
strcmp (&filename[strlen (filename)-4], ".tet") == 0 )
|
|
||||||
{
|
|
||||||
ReadTETFormat (mesh, filename);
|
ReadTETFormat (mesh, filename);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// .fnf mesh (FNF - PE neutral format)
|
// .fnf mesh (FNF - PE neutral format)
|
||||||
if ( (strlen (filename) > 4) &&
|
if ( ext == ".fnf" )
|
||||||
strcmp (&filename[strlen (filename)-4], ".fnf") == 0 )
|
|
||||||
{
|
|
||||||
ReadFNFFormat (mesh, filename);
|
ReadFNFFormat (mesh, filename);
|
||||||
}
|
|
||||||
|
|
||||||
// .cgns file - CFD General Notation System
|
// .cgns file - CFD General Notation System
|
||||||
if ( (strlen (filename) > 5) &&
|
if ( ext == ".cgns" )
|
||||||
strcmp (&filename[strlen (filename)-5], ".cgns") == 0 )
|
|
||||||
{
|
|
||||||
ReadCGNSMesh (mesh, filename);
|
ReadCGNSMesh (mesh, filename);
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( (strlen (filename) > 4) && strcmp (&filename[strlen (filename)-4], ".stl") == 0 ) ||
|
if ( ext == ".stl" || ext == ".stlb" )
|
||||||
( (strlen (filename) > 5) && strcmp (&filename[strlen (filename)-5], ".stlb") == 0 ) )
|
|
||||||
{
|
{
|
||||||
ifstream ist{string{filename}};
|
ifstream ist{filename};
|
||||||
auto geom = shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
auto geom = shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
||||||
|
|
||||||
mesh.SetDimension (3);
|
mesh.SetDimension (3);
|
||||||
|
@ -629,12 +629,12 @@ namespace netgen::cg
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
int ReadCGNSMesh (Mesh & mesh, const string & filename, Array<unique_ptr<cg::Zone>> & zones)
|
int ReadCGNSMesh (Mesh & mesh, const filesystem::path & filename, Array<unique_ptr<cg::Zone>> & zones)
|
||||||
{
|
{
|
||||||
mesh.SetDimension(3);
|
mesh.SetDimension(3);
|
||||||
static Timer tall("CGNS::ReadMesh"); RegionTimer rtall(tall);
|
static Timer tall("CGNS::ReadMesh"); RegionTimer rtall(tall);
|
||||||
int fn;
|
int fn;
|
||||||
cg_open(filename.c_str(),CG_MODE_READ,&fn);
|
cg_open(filename.string().c_str(),CG_MODE_READ,&fn);
|
||||||
|
|
||||||
int base = 1;
|
int base = 1;
|
||||||
int nzones;
|
int nzones;
|
||||||
@ -698,7 +698,7 @@ namespace netgen
|
|||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadCGNSMesh (Mesh & mesh, const string & filename)
|
void ReadCGNSMesh (Mesh & mesh, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
Array<unique_ptr<cg::Zone>> zones;
|
Array<unique_ptr<cg::Zone>> zones;
|
||||||
int fn = ReadCGNSMesh(mesh, filename, zones);
|
int fn = ReadCGNSMesh(mesh, filename, zones);
|
||||||
@ -706,7 +706,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reads mesh and solutions of .csns file
|
// Reads mesh and solutions of .csns file
|
||||||
tuple<shared_ptr<Mesh>, vector<string>, vector<Array<double>>, vector<int>> ReadCGNSFile(string filename, int base)
|
tuple<shared_ptr<Mesh>, vector<string>, vector<Array<double>>, vector<int>> ReadCGNSFile(const filesystem::path & filename, int base)
|
||||||
{
|
{
|
||||||
static Timer tall("CGNS::ReadFile"); RegionTimer rtall(tall);
|
static Timer tall("CGNS::ReadFile"); RegionTimer rtall(tall);
|
||||||
|
|
||||||
@ -775,11 +775,11 @@ namespace netgen
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteCGNSMesh (const Mesh & mesh, const string & filename)
|
void WriteCGNSMesh (const Mesh & mesh, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
static Timer tall("CGNS::WriteMesh"); RegionTimer rtall(tall);
|
static Timer tall("CGNS::WriteMesh"); RegionTimer rtall(tall);
|
||||||
int fn, base, zone;
|
int fn, base, zone;
|
||||||
cg_open(filename.c_str(),CG_MODE_WRITE,&fn);
|
cg_open(filename.string().c_str(),CG_MODE_WRITE,&fn);
|
||||||
|
|
||||||
WriteCGNSMesh(mesh, fn, base, zone);
|
WriteCGNSMesh(mesh, fn, base, zone);
|
||||||
|
|
||||||
@ -787,11 +787,11 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WriteCGNSFile(shared_ptr<Mesh> mesh, string filename, vector<string> fields, vector<Array<double>> values, vector<int> locations)
|
void WriteCGNSFile(shared_ptr<Mesh> mesh, const filesystem::path & filename, vector<string> fields, vector<Array<double>> values, vector<int> locations)
|
||||||
{
|
{
|
||||||
static Timer tall("CGNS::WriteFile"); RegionTimer rtall(tall);
|
static Timer tall("CGNS::WriteFile"); RegionTimer rtall(tall);
|
||||||
int fn, base, zone;
|
int fn, base, zone;
|
||||||
cg_open(filename.c_str(),CG_MODE_WRITE,&fn);
|
cg_open(filename.string().c_str(),CG_MODE_WRITE,&fn);
|
||||||
|
|
||||||
WriteCGNSMesh(*mesh, fn, base, zone);
|
WriteCGNSMesh(*mesh, fn, base, zone);
|
||||||
|
|
||||||
@ -814,22 +814,22 @@ namespace netgen
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
void ReadCGNSMesh (Mesh & mesh, const string & filename)
|
void ReadCGNSMesh (Mesh & mesh, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
PrintMessage(1, "Could not import CGNS mesh: Netgen was built without CGNS support");
|
PrintMessage(1, "Could not import CGNS mesh: Netgen was built without CGNS support");
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple<shared_ptr<Mesh>, vector<string>, vector<Array<double>>, vector<int>> ReadCGNSFile(string filename, int base)
|
tuple<shared_ptr<Mesh>, vector<string>, vector<Array<double>>, vector<int>> ReadCGNSFile(const filesystem::path & filename, int base)
|
||||||
{
|
{
|
||||||
throw Exception("Netgen was built without CGNS support");
|
throw Exception("Netgen was built without CGNS support");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteCGNSMesh (const Mesh & mesh, const string & filename)
|
void WriteCGNSMesh (const Mesh & mesh, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
PrintMessage(1, "Could not write CGNS mesh: Netgen was built without CGNS support");
|
PrintMessage(1, "Could not write CGNS mesh: Netgen was built without CGNS support");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteCGNSFile(shared_ptr<Mesh> mesh, string filename, vector<string> fields, vector<Array<double>> values, vector<int> locations)
|
void WriteCGNSFile(shared_ptr<Mesh> mesh, const filesystem::path & filename, vector<string> fields, vector<Array<double>> values, vector<int> locations)
|
||||||
{
|
{
|
||||||
throw Exception("Netgen was built without CGNS support");
|
throw Exception("Netgen was built without CGNS support");
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WriteOpenFOAM15xFormat (const Mesh & mesh, const string & casename, const bool compressed)
|
void WriteOpenFOAM15xFormat (const Mesh & mesh, const filesystem::path & dirname, const bool compressed)
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
char casefiles[256];
|
char casefiles[256];
|
||||||
@ -639,22 +639,12 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cout << "Writing OpenFOAM 1.5+ Mesh files to case: " << casename << "\n";
|
cout << "Writing OpenFOAM 1.5+ Mesh files to case: " << dirname.string() << "\n";
|
||||||
|
|
||||||
// Create the case directory if it does not already exist
|
// Create the case directory if it does not already exist
|
||||||
// NOTE: This needs to be improved for the Linux variant....!!!
|
// NOTE: This needs to be improved for the Linux variant....!!!
|
||||||
#ifdef WIN32
|
auto mesh_dir = filesystem::path(dirname).append("constant").append("polyMesh");
|
||||||
char casedir[256];
|
filesystem::create_directories(mesh_dir);
|
||||||
sprintf(casedir, "mkdir %s\\constant\\polyMesh", casename.c_str());
|
|
||||||
system(casedir);
|
|
||||||
#else
|
|
||||||
char casedir[256];
|
|
||||||
mkdir(casename.c_str(), S_IRWXU|S_IRWXG);
|
|
||||||
sprintf(casedir, "%s/constant", casename.c_str());
|
|
||||||
mkdir(casedir, S_IRWXU|S_IRWXG);
|
|
||||||
sprintf(casedir, "%s/constant/polyMesh", casename.c_str());
|
|
||||||
mkdir(casedir, S_IRWXU|S_IRWXG);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Open handles to the five required mesh files
|
// Open handles to the five required mesh files
|
||||||
// points
|
// points
|
||||||
@ -662,59 +652,21 @@ namespace netgen
|
|||||||
// owner
|
// owner
|
||||||
// neighbour
|
// neighbour
|
||||||
// boundary
|
// boundary
|
||||||
ostream *outfile_pnts;
|
|
||||||
ostream *outfile_faces;
|
|
||||||
ostream *outfile_own;
|
|
||||||
ostream *outfile_nei;
|
|
||||||
ostream *outfile_bnd;
|
|
||||||
|
|
||||||
if(compressed)
|
auto get_name = [compressed, &mesh_dir]( string s ) {
|
||||||
{
|
auto p = filesystem::path(mesh_dir).append(s);
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/points.gz", casename.c_str());
|
if(compressed)
|
||||||
outfile_pnts = new ogzstream(casefiles);
|
p.concat(".gz");
|
||||||
}
|
return p;
|
||||||
else
|
};
|
||||||
{
|
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/points", casename.c_str());
|
|
||||||
outfile_pnts = new ofstream(casefiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(compressed)
|
auto outfile_pnts = make_unique<ofstream>(get_name("points"));
|
||||||
{
|
auto outfile_faces = make_unique<ofstream>(get_name("faces"));
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/faces.gz", casename.c_str());
|
auto outfile_own = make_unique<ofstream>(get_name("owner"));
|
||||||
outfile_faces = new ogzstream(casefiles);
|
auto outfile_nei = make_unique<ofstream>(get_name("neighbor"));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/faces", casename.c_str());
|
|
||||||
outfile_faces = new ofstream(casefiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(compressed)
|
// Note... the boundary file is not compressed
|
||||||
{
|
auto outfile_bnd = make_unique<ofstream>(mesh_dir.append("boundary"));
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/owner.gz", casename.c_str());
|
|
||||||
outfile_own = new ogzstream(casefiles);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/owner", casename.c_str());
|
|
||||||
outfile_own = new ofstream(casefiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(compressed)
|
|
||||||
{
|
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/neighbour.gz", casename.c_str());
|
|
||||||
outfile_nei = new ogzstream(casefiles);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/neighbour", casename.c_str());
|
|
||||||
outfile_nei = new ofstream(casefiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note... the boundary file is not compressed
|
|
||||||
sprintf(casefiles, "%s/constant/polyMesh/boundary", casename.c_str());
|
|
||||||
outfile_bnd = new ofstream(casefiles);
|
|
||||||
|
|
||||||
ResetTime();
|
ResetTime();
|
||||||
|
|
||||||
@ -731,8 +683,7 @@ namespace netgen
|
|||||||
if(outfile_own->good() && !error)
|
if(outfile_own->good() && !error)
|
||||||
{
|
{
|
||||||
cout << "Writing the owner file: ";
|
cout << "Writing the owner file: ";
|
||||||
WriteOwnerFile(outfile_own);
|
WriteOwnerFile(outfile_own.get());
|
||||||
delete outfile_own;
|
|
||||||
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -746,8 +697,7 @@ namespace netgen
|
|||||||
if(outfile_nei->good() && !error)
|
if(outfile_nei->good() && !error)
|
||||||
{
|
{
|
||||||
cout << "Writing the neighbour file: ";
|
cout << "Writing the neighbour file: ";
|
||||||
WriteNeighbourFile(outfile_nei);
|
WriteNeighbourFile(outfile_nei.get());
|
||||||
delete outfile_nei;
|
|
||||||
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -761,8 +711,7 @@ namespace netgen
|
|||||||
if(outfile_faces->good() && !error)
|
if(outfile_faces->good() && !error)
|
||||||
{
|
{
|
||||||
cout << "Writing the faces file: ";
|
cout << "Writing the faces file: ";
|
||||||
WriteFacesFile(outfile_faces, mesh);
|
WriteFacesFile(outfile_faces.get(), mesh);
|
||||||
delete outfile_faces;
|
|
||||||
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -776,8 +725,7 @@ namespace netgen
|
|||||||
if(outfile_pnts->good() && !error)
|
if(outfile_pnts->good() && !error)
|
||||||
{
|
{
|
||||||
cout << "Writing the points file: ";
|
cout << "Writing the points file: ";
|
||||||
WritePointsFile(outfile_pnts,mesh);
|
WritePointsFile(outfile_pnts.get(),mesh);
|
||||||
delete outfile_pnts;
|
|
||||||
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -791,8 +739,7 @@ namespace netgen
|
|||||||
if(outfile_bnd->good() && !error)
|
if(outfile_bnd->good() && !error)
|
||||||
{
|
{
|
||||||
cout << "Writing the boundary file: ";
|
cout << "Writing the boundary file: ";
|
||||||
WriteBoundaryFile(outfile_bnd);
|
WriteBoundaryFile(outfile_bnd.get());
|
||||||
delete outfile_bnd;
|
|
||||||
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
cout << "Done! (Time Elapsed = " << GetTime() << " sec)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -18,13 +18,13 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void WriteAbaqusFormat (const Mesh & mesh,
|
void WriteAbaqusFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
cout << "\nWrite Abaqus Volume Mesh" << endl;
|
cout << "\nWrite Abaqus Volume Mesh" << endl;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile << "*Heading" << endl;
|
outfile << "*Heading" << endl;
|
||||||
outfile << " " << filename << endl;
|
outfile << " " << filename << endl;
|
||||||
@ -124,16 +124,11 @@ void WriteAbaqusFormat (const Mesh & mesh,
|
|||||||
// periodic identification, implementation for
|
// periodic identification, implementation for
|
||||||
// Helmut J. Boehm, TU Vienna
|
// Helmut J. Boehm, TU Vienna
|
||||||
|
|
||||||
char cfilename[255];
|
auto mpcfilename = filename;
|
||||||
strcpy (cfilename, filename.c_str());
|
if (filename.extension() == ".inp")
|
||||||
|
mpcfilename.replace_extension(".mpc");
|
||||||
char mpcfilename[255];
|
|
||||||
strcpy (mpcfilename, cfilename);
|
|
||||||
size_t len = strlen (cfilename);
|
|
||||||
if (len >= 4 && (strcmp (mpcfilename+len-4, ".inp") == 0))
|
|
||||||
strcpy (mpcfilename+len-4, ".mpc");
|
|
||||||
else
|
else
|
||||||
strcat (mpcfilename, ".mpc");
|
mpcfilename.concat(".mpc");
|
||||||
|
|
||||||
ofstream mpc (mpcfilename);
|
ofstream mpc (mpcfilename);
|
||||||
|
|
||||||
|
@ -21,12 +21,12 @@ namespace netgen
|
|||||||
|
|
||||||
void WriteDiffPackFormat (const Mesh & mesh,
|
void WriteDiffPackFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
// double scale = globflags.GetNumFlag ("scale", 1);
|
// double scale = globflags.GetNumFlag ("scale", 1);
|
||||||
double scale = 1;
|
double scale = 1;
|
||||||
|
|
||||||
ofstream outfile(filename.c_str());
|
ofstream outfile(filename);
|
||||||
outfile.precision(14);
|
outfile.precision(14);
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WriteDolfinFormat (const Mesh & mesh, const string & filename)
|
void WriteDolfinFormat (const Mesh & mesh, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "start writing dolfin export" << endl;
|
cout << "start writing dolfin export" << endl;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ namespace netgen
|
|||||||
// int invertsurf = mparam.inverttrigs;
|
// int invertsurf = mparam.inverttrigs;
|
||||||
// int i, j;
|
// int i, j;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
// char str[100];
|
// char str[100];
|
||||||
outfile.precision(8);
|
outfile.precision(8);
|
||||||
|
@ -21,7 +21,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void WriteElmerFormat (const Mesh &mesh,
|
void WriteElmerFormat (const Mesh &mesh,
|
||||||
const string &filename)
|
const filesystem::path &dirname)
|
||||||
{
|
{
|
||||||
cout << "write elmer mesh files" << endl;
|
cout << "write elmer mesh files" << endl;
|
||||||
|
|
||||||
@ -62,25 +62,17 @@ void WriteElmerFormat (const Mesh &mesh,
|
|||||||
int inverttets = mparam.inverttets;
|
int inverttets = mparam.inverttets;
|
||||||
int invertsurf = mparam.inverttrigs;
|
int invertsurf = mparam.inverttrigs;
|
||||||
|
|
||||||
#ifdef WIN32
|
filesystem::create_directories(dirname);
|
||||||
char a[256];
|
|
||||||
sprintf( a, "mkdir %s", filename.c_str() );
|
|
||||||
system( a );
|
|
||||||
#else
|
|
||||||
// int rc =
|
|
||||||
mkdir(filename.c_str(), S_IRWXU|S_IRWXG);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sprintf( str, "%s/mesh.header", filename.c_str() );
|
auto get_name = [&dirname]( string s ) {
|
||||||
ofstream outfile_h(str);
|
return filesystem::path(dirname).append(s);
|
||||||
sprintf( str, "%s/mesh.nodes", filename.c_str() );
|
};
|
||||||
ofstream outfile_n(str);
|
|
||||||
sprintf( str, "%s/mesh.elements", filename.c_str() );
|
ofstream outfile_h(get_name("mesh.header"));
|
||||||
ofstream outfile_e(str);
|
ofstream outfile_n(get_name("mesh.nodes"));
|
||||||
sprintf( str, "%s/mesh.boundary", filename.c_str() );
|
ofstream outfile_e(get_name("mesh.elements"));
|
||||||
ofstream outfile_b(str);
|
ofstream outfile_b(get_name("mesh.boundary"));
|
||||||
sprintf( str, "%s/mesh.names", filename.c_str() );
|
ofstream outfile_names(get_name("mesh.names"));
|
||||||
ofstream outfile_names(str);
|
|
||||||
|
|
||||||
for( auto codim : IntRange(0, mesh.GetDimension()-1) )
|
for( auto codim : IntRange(0, mesh.GetDimension()-1) )
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void WriteFEAPFormat (const Mesh & mesh,
|
void WriteFEAPFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Feap format by A. Rieger
|
// Feap format by A. Rieger
|
||||||
@ -35,7 +35,7 @@ void WriteFEAPFormat (const Mesh & mesh,
|
|||||||
|
|
||||||
double scale = 1; // globflags.GetNumFlag ("scale", 1);
|
double scale = 1; // globflags.GetNumFlag ("scale", 1);
|
||||||
|
|
||||||
ofstream outfile(filename.c_str());
|
ofstream outfile(filename);
|
||||||
|
|
||||||
outfile << "feap" << "\n";
|
outfile << "feap" << "\n";
|
||||||
outfile << mesh.GetNP();
|
outfile << mesh.GetNP();
|
||||||
|
@ -18,7 +18,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void WriteFluentFormat (const Mesh & mesh,
|
void WriteFluentFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
|
|
||||||
{
|
{
|
||||||
cout << "start writing fluent export" << endl;
|
cout << "start writing fluent export" << endl;
|
||||||
@ -28,7 +28,7 @@ void WriteFluentFormat (const Mesh & mesh,
|
|||||||
int nse = mesh.GetNSE();
|
int nse = mesh.GetNSE();
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
char str[100];
|
char str[100];
|
||||||
|
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
|
@ -32,9 +32,9 @@ namespace netgen
|
|||||||
|
|
||||||
void WriteGmshFormat (const Mesh & mesh,
|
void WriteGmshFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
outfile.setf (ios::showpoint);
|
outfile.setf (ios::showpoint);
|
||||||
|
@ -49,9 +49,9 @@ namespace netgen
|
|||||||
*/
|
*/
|
||||||
void WriteGmsh2Format (const Mesh & mesh,
|
void WriteGmsh2Format (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
outfile.setf (ios::showpoint);
|
outfile.setf (ios::showpoint);
|
||||||
|
@ -17,7 +17,7 @@ namespace netgen
|
|||||||
|
|
||||||
void WriteJCMFormat (const Mesh & mesh,
|
void WriteJCMFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
if (mesh.GetDimension() != 3)
|
if (mesh.GetDimension() != 3)
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ void WriteJCMFormat (const Mesh & mesh,
|
|||||||
nbquad++;
|
nbquad++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
outfile.setf (ios::showpoint);
|
outfile.setf (ios::showpoint);
|
||||||
|
@ -22,18 +22,18 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
// This should be the new function to export a PERMAS file
|
// This should be the new function to export a PERMAS file
|
||||||
void WritePermasFormat (const Mesh &mesh, const string &filename,
|
void WritePermasFormat (const Mesh &mesh, const filesystem::path &filename,
|
||||||
string &strComp, string &strSitu)
|
string &strComp, string &strSitu)
|
||||||
{
|
{
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
addComponent(strComp, strSitu, outfile);
|
addComponent(strComp, strSitu, outfile);
|
||||||
WritePermasFormat ( mesh, filename);
|
WritePermasFormat ( mesh, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WritePermasFormat (const Mesh &mesh, const string &filename)
|
void WritePermasFormat (const Mesh &mesh, const filesystem::path &filename)
|
||||||
{
|
{
|
||||||
string strComp, strSitu;
|
string strComp, strSitu;
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile.precision(8);
|
outfile.precision(8);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void WriteTecPlotFormat (const Mesh & mesh,
|
|||||||
INDEX nse = mesh.GetNSE();
|
INDEX nse = mesh.GetNSE();
|
||||||
|
|
||||||
NgArray<int> sn(np);
|
NgArray<int> sn(np);
|
||||||
ofstream outfile(filename.c_str());
|
ofstream outfile(filename);
|
||||||
|
|
||||||
outfile << "TITLE=\" " << filename << "\"" << endl;
|
outfile << "TITLE=\" " << filename << "\"" << endl;
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ofstream outfile(filename.c_str());
|
ofstream outfile(filename);
|
||||||
|
|
||||||
outfile.precision(16);
|
outfile.precision(16);
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void WriteTochnogFormat (const Mesh & mesh,
|
void WriteTochnogFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "\nWrite Tochnog Volume Mesh" << endl;
|
cout << "\nWrite Tochnog Volume Mesh" << endl;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile << "(Nodes and Elements generated with NETGEN" << endl;
|
outfile << "(Nodes and Elements generated with NETGEN" << endl;
|
||||||
outfile << " " << filename << ")" << endl;
|
outfile << " " << filename << ")" << endl;
|
||||||
|
@ -58,9 +58,9 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool WriteUserFormat (const string & format,
|
bool WriteUserFormat (const filesystem::path & format,
|
||||||
const Mesh & mesh,
|
const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
// cout << "write user &hgeom = " << &hgeom << endl;
|
// cout << "write user &hgeom = " << &hgeom << endl;
|
||||||
// const CSGeometry & geom = *dynamic_cast<const CSGeometry*> (&hgeom);
|
// const CSGeometry & geom = *dynamic_cast<const CSGeometry*> (&hgeom);
|
||||||
@ -167,7 +167,7 @@ bool WriteUserFormat (const string & format,
|
|||||||
|
|
||||||
void WriteNeutralFormat (const Mesh & mesh,
|
void WriteNeutralFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "write neutral, new" << endl;
|
cout << "write neutral, new" << endl;
|
||||||
int np = mesh.GetNP();
|
int np = mesh.GetNP();
|
||||||
@ -179,7 +179,7 @@ void WriteNeutralFormat (const Mesh & mesh,
|
|||||||
int inverttets = mparam.inverttets;
|
int inverttets = mparam.inverttets;
|
||||||
int invertsurf = mparam.inverttrigs;
|
int invertsurf = mparam.inverttrigs;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
@ -283,14 +283,14 @@ void WriteNeutralFormat (const Mesh & mesh,
|
|||||||
|
|
||||||
|
|
||||||
void WriteSurfaceFormat (const Mesh & mesh,
|
void WriteSurfaceFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
// surface mesh
|
// surface mesh
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
cout << "Write Surface Mesh" << endl;
|
cout << "Write Surface Mesh" << endl;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile << "surfacemesh" << endl;
|
outfile << "surfacemesh" << endl;
|
||||||
|
|
||||||
@ -325,16 +325,17 @@ void WriteSurfaceFormat (const Mesh & mesh,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void WriteSTLFormat (const Mesh & mesh,
|
void WriteSTLFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "\nWrite STL Surface Mesh" << endl;
|
cout << "\nWrite STL Surface Mesh" << endl;
|
||||||
|
|
||||||
|
auto ext = filename.extension();
|
||||||
ostream *outfile;
|
ostream *outfile;
|
||||||
|
|
||||||
if(filename.substr(filename.length()-3,3) == ".gz")
|
if(ext == ".gz")
|
||||||
outfile = new ogzstream(filename.c_str());
|
outfile = new ogzstream(filename);
|
||||||
else
|
else
|
||||||
outfile = new ofstream(filename.c_str());
|
outfile = new ofstream(filename);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -382,16 +383,17 @@ void WriteSTLFormat (const Mesh & mesh,
|
|||||||
* when using a third-party mesher
|
* when using a third-party mesher
|
||||||
*/
|
*/
|
||||||
void WriteSTLExtFormat (const Mesh & mesh,
|
void WriteSTLExtFormat (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "\nWrite STL Surface Mesh (with separated boundary faces)" << endl;
|
cout << "\nWrite STL Surface Mesh (with separated boundary faces)" << endl;
|
||||||
|
|
||||||
|
auto ext = filename.extension();
|
||||||
ostream *outfile;
|
ostream *outfile;
|
||||||
|
|
||||||
if(filename.substr(filename.length()-3,3) == ".gz")
|
if(ext == ".gz")
|
||||||
outfile = new ogzstream(filename.c_str());
|
outfile = new ogzstream(filename);
|
||||||
else
|
else
|
||||||
outfile = new ofstream(filename.c_str());
|
outfile = new ofstream(filename);
|
||||||
|
|
||||||
outfile->precision(10);
|
outfile->precision(10);
|
||||||
|
|
||||||
@ -474,7 +476,7 @@ void WriteSTLExtFormat (const Mesh & mesh,
|
|||||||
|
|
||||||
void WriteVRMLFormat (const Mesh & mesh,
|
void WriteVRMLFormat (const Mesh & mesh,
|
||||||
bool faces,
|
bool faces,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (faces)
|
if (faces)
|
||||||
@ -487,7 +489,7 @@ void WriteVRMLFormat (const Mesh & mesh,
|
|||||||
int nse = mesh.GetNSE();
|
int nse = mesh.GetNSE();
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
@ -563,7 +565,7 @@ void WriteVRMLFormat (const Mesh & mesh,
|
|||||||
int nse = mesh.GetNSE();
|
int nse = mesh.GetNSE();
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
@ -639,10 +641,10 @@ void WriteVRMLFormat (const Mesh & mesh,
|
|||||||
*/
|
*/
|
||||||
void WriteFEPPFormat (const Mesh & mesh,
|
void WriteFEPPFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
if (mesh.GetDimension() == 3)
|
if (mesh.GetDimension() == 3)
|
||||||
|
|
||||||
@ -770,7 +772,7 @@ void WriteFEPPFormat (const Mesh & mesh,
|
|||||||
|
|
||||||
void WriteEdgeElementFormat (const Mesh & mesh,
|
void WriteEdgeElementFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "write edge element format" << endl;
|
cout << "write edge element format" << endl;
|
||||||
|
|
||||||
@ -785,7 +787,7 @@ void WriteEdgeElementFormat (const Mesh & mesh,
|
|||||||
int invertsurf = mparam.inverttrigs;
|
int invertsurf = mparam.inverttrigs;
|
||||||
NgArray<int> edges;
|
NgArray<int> edges;
|
||||||
|
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
outfile.precision(6);
|
outfile.precision(6);
|
||||||
outfile.setf (ios::fixed, ios::floatfield);
|
outfile.setf (ios::fixed, ios::floatfield);
|
||||||
@ -908,8 +910,8 @@ void WriteEdgeElementFormat (const Mesh & mesh,
|
|||||||
void WriteFile (int typ,
|
void WriteFile (int typ,
|
||||||
const Mesh & mesh,
|
const Mesh & mesh,
|
||||||
const CSGeometry & geom,
|
const CSGeometry & geom,
|
||||||
const char * filename,
|
const filesystem::path & filename,
|
||||||
const char * geomfile,
|
const filesystem::path & geomfile,
|
||||||
double h)
|
double h)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -13,15 +13,15 @@ DLL_HEADER extern
|
|||||||
void WriteFile (int typ,
|
void WriteFile (int typ,
|
||||||
const Mesh & mesh,
|
const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const char * filename,
|
const filesystem::path & filename,
|
||||||
const char * geomfile = NULL,
|
const filesystem::path & geomfile = "",
|
||||||
double h = 0);
|
double h = 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER extern
|
DLL_HEADER extern
|
||||||
void ReadFile (Mesh & mesh,
|
void ReadFile (Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -31,15 +31,15 @@ void ReadFile (Mesh & mesh,
|
|||||||
extern
|
extern
|
||||||
void WriteNeutralFormat (const Mesh & mesh,
|
void WriteNeutralFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteSurfaceFormat (const Mesh & mesh,
|
void WriteSurfaceFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteSTLFormat (const Mesh & mesh,
|
void WriteSTLFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
// Philippose - 16 August 2010
|
// Philippose - 16 August 2010
|
||||||
@ -48,134 +48,134 @@ void WriteSTLFormat (const Mesh & mesh,
|
|||||||
// a separate "solid" entity in the STL file
|
// a separate "solid" entity in the STL file
|
||||||
extern
|
extern
|
||||||
void WriteSTLExtFormat (const Mesh & mesh,
|
void WriteSTLExtFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteVRMLFormat (const Mesh & mesh,
|
void WriteVRMLFormat (const Mesh & mesh,
|
||||||
bool faces,
|
bool faces,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteFEPPFormat (const Mesh & mesh,
|
void WriteFEPPFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteGmshFormat (const Mesh & mesh,
|
void WriteGmshFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
// Philippose - 29/01/2009
|
// Philippose - 29/01/2009
|
||||||
// Added GMSH v2.xx Mesh Export support
|
// Added GMSH v2.xx Mesh Export support
|
||||||
void WriteGmsh2Format (const Mesh & mesh,
|
void WriteGmsh2Format (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
// Philippose - 25/10/2009
|
// Philippose - 25/10/2009
|
||||||
// Added OpenFOAM 1.5+ Mesh Export support
|
// Added OpenFOAM 1.5+ Mesh Export support
|
||||||
extern
|
extern
|
||||||
void WriteOpenFOAM15xFormat (const Mesh & mesh,
|
void WriteOpenFOAM15xFormat (const Mesh & mesh,
|
||||||
const string & casename,
|
const filesystem::path & casename,
|
||||||
const bool compressed);
|
const bool compressed);
|
||||||
|
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteUserChemnitz (const Mesh & mesh,
|
void WriteUserChemnitz (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteJCMFormat (const Mesh & mesh,
|
void WriteJCMFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteDiffPackFormat (const Mesh & mesh,
|
void WriteDiffPackFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteTochnogFormat (const Mesh & mesh,
|
void WriteTochnogFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteTecPlotFormat (const Mesh & mesh,
|
void WriteTecPlotFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteAbaqusFormat (const Mesh & mesh,
|
void WriteAbaqusFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteFluentFormat (const Mesh & mesh,
|
void WriteFluentFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WritePermasFormat (const Mesh & mesh,
|
void WritePermasFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteFEAPFormat (const Mesh & mesh,
|
void WriteFEAPFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteElmerFormat (const Mesh & mesh,
|
void WriteElmerFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
extern
|
extern
|
||||||
void WriteEdgeElementFormat (const Mesh & mesh,
|
void WriteEdgeElementFormat (const Mesh & mesh,
|
||||||
const NetgenGeometry & geom,
|
const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef OLIVER
|
#ifdef OLIVER
|
||||||
extern
|
extern
|
||||||
void WriteTETFormat (const Mesh & mesh,
|
void WriteTETFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void ReadTETFormat (Mesh & mesh,
|
extern void ReadTETFormat (Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
extern void ReadFNFFormat (Mesh & mesh,
|
extern void ReadFNFFormat (Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void DLL_HEADER ReadCGNSMesh (Mesh & mesh,
|
extern void DLL_HEADER ReadCGNSMesh (Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
extern void DLL_HEADER WriteCGNSMesh (const Mesh & mesh,
|
extern void DLL_HEADER WriteCGNSMesh (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
// read/write mesh and solutions from CGNS file
|
// read/write mesh and solutions from CGNS file
|
||||||
extern tuple<shared_ptr<Mesh>, vector<string>, vector<Array<double>>, vector<int>>
|
extern tuple<shared_ptr<Mesh>, vector<string>, vector<Array<double>>, vector<int>>
|
||||||
DLL_HEADER ReadCGNSFile(string filename, int base);
|
DLL_HEADER ReadCGNSFile(const filesystem::path & filename, int base);
|
||||||
|
|
||||||
extern void DLL_HEADER WriteCGNSFile(shared_ptr<Mesh> mesh,string filename, vector<string> fields,
|
extern void DLL_HEADER WriteCGNSFile(shared_ptr<Mesh> mesh, const filesystem::path & filename, vector<string> fields,
|
||||||
vector<Array<double>> values, vector<int> locations);
|
vector<Array<double>> values, vector<int> locations);
|
||||||
|
|
||||||
|
|
||||||
void WriteDolfinFormat (const Mesh & mesh,
|
void WriteDolfinFormat (const Mesh & mesh,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
|
|
||||||
extern void DLL_HEADER RegisterUserFormats (NgArray<const char*> & names,
|
extern void DLL_HEADER RegisterUserFormats (NgArray<const char*> & names,
|
||||||
NgArray<const char*> & extensions);
|
NgArray<const char*> & extensions);
|
||||||
|
|
||||||
|
|
||||||
extern bool DLL_HEADER WriteUserFormat (const string & format,
|
extern bool DLL_HEADER WriteUserFormat (const filesystem::path & format,
|
||||||
const Mesh & mesh,
|
const Mesh & mesh,
|
||||||
// const NetgenGeometry & geom,
|
// const NetgenGeometry & geom,
|
||||||
const string & filename);
|
const filesystem::path & filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,9 +306,9 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void WriteUserChemnitz (const Mesh & mesh,
|
void WriteUserChemnitz (const Mesh & mesh,
|
||||||
const string & filename)
|
const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
ofstream outfile (filename.c_str());
|
ofstream outfile (filename);
|
||||||
|
|
||||||
ReadFileMesh (mesh);
|
ReadFileMesh (mesh);
|
||||||
Convert ();
|
Convert ();
|
||||||
|
@ -1124,7 +1124,7 @@ namespace netgen
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetgenGeometry :: Save (string filename) const
|
void NetgenGeometry :: Save (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
throw NgException("Cannot save geometry - no geometry available");
|
throw NgException("Cannot save geometry - no geometry available");
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
/* Date: 23. Aug. 09 */
|
/* Date: 23. Aug. 09 */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
struct Tcl_Interp;
|
struct Tcl_Interp;
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
@ -298,7 +297,7 @@ namespace netgen
|
|||||||
return i;
|
return i;
|
||||||
throw Exception("Couldn't find edge index");
|
throw Exception("Couldn't find edge index");
|
||||||
}
|
}
|
||||||
virtual void Save (string filename) const;
|
virtual void Save (const filesystem::path & filename) const;
|
||||||
virtual void SaveToMeshFile (ostream & /* ost */) const { ; }
|
virtual void SaveToMeshFile (ostream & /* ost */) const { ; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -310,7 +309,7 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~GeometryRegister();
|
virtual ~GeometryRegister();
|
||||||
virtual NetgenGeometry * Load (string filename) const = 0;
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const = 0;
|
||||||
virtual NetgenGeometry * LoadFromMeshFile (istream & /* ist */, string) 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; }
|
||||||
|
@ -627,9 +627,12 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Mesh :: Save (const string & filename) const
|
void Mesh :: Save (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
if (filename.find(".vol.bin") != string::npos)
|
string ext0 = filename.stem().extension().string();
|
||||||
|
string ext = filename.extension().string();
|
||||||
|
|
||||||
|
if (ext0 == ".vol" && ext == ".bin")
|
||||||
{
|
{
|
||||||
BinaryOutArchive in(filename);
|
BinaryOutArchive in(filename);
|
||||||
in & const_cast<Mesh&>(*this);
|
in & const_cast<Mesh&>(*this);
|
||||||
@ -637,12 +640,12 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
ostream * outfile;
|
ostream * outfile;
|
||||||
if (filename.find(".vol.gz")!=string::npos)
|
if (ext0 == ".vol" && ext == ".gz")
|
||||||
outfile = new ogzstream(filename.c_str());
|
outfile = new ogzstream(filename);
|
||||||
else if (filename.find(".vol")!=string::npos)
|
else if (ext == ".vol")
|
||||||
outfile = new ofstream(filename.c_str());
|
outfile = new ofstream(filename);
|
||||||
else
|
else
|
||||||
outfile = new ogzstream((filename+".vol.gz").c_str());
|
outfile = new ogzstream(filesystem::path(filename).concat(".vol.gz"));
|
||||||
|
|
||||||
Save(*outfile);
|
Save(*outfile);
|
||||||
delete outfile;
|
delete outfile;
|
||||||
@ -1109,11 +1112,14 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Mesh :: Load (const string & filename)
|
void Mesh :: Load (const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
cout << "filename = " << filename << endl;
|
PrintMessage (1, "filename = ", filename);
|
||||||
|
|
||||||
if (filename.find(".vol.bin") != string::npos)
|
string ext0 = filename.stem().extension().string();
|
||||||
|
string ext = filename.extension().string();
|
||||||
|
|
||||||
|
if (ext0 == ".vol" && ext == ".bin")
|
||||||
{
|
{
|
||||||
BinaryInArchive in(filename);
|
BinaryInArchive in(filename);
|
||||||
in & (*this);
|
in & (*this);
|
||||||
@ -1122,12 +1128,11 @@ namespace netgen
|
|||||||
|
|
||||||
istream * infile = NULL;
|
istream * infile = NULL;
|
||||||
|
|
||||||
if (filename.find(".vol.gz") != string::npos)
|
if (ext0 == ".vol" && ext == ".gz")
|
||||||
infile = new igzstream (filename.c_str());
|
infile = new igzstream (filename);
|
||||||
else
|
else
|
||||||
infile = new ifstream (filename.c_str());
|
infile = new ifstream (filename);
|
||||||
|
|
||||||
// ifstream infile(filename.c_str());
|
|
||||||
if (! (infile -> good()) )
|
if (! (infile -> good()) )
|
||||||
throw NgException ("mesh file not found");
|
throw NgException ("mesh file not found");
|
||||||
|
|
||||||
@ -1651,6 +1656,10 @@ namespace netgen
|
|||||||
clusters -> Update();
|
clusters -> Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto geo = geometryregister.LoadFromMeshFile (infile);
|
||||||
|
if(geo)
|
||||||
|
geometry = geo;
|
||||||
|
|
||||||
SetNextMajorTimeStamp();
|
SetNextMajorTimeStamp();
|
||||||
// PrintMemInfo (cout);
|
// PrintMemInfo (cout);
|
||||||
}
|
}
|
||||||
@ -1840,9 +1849,9 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mesh :: Merge (const string & filename, const int surfindex_offset)
|
void Mesh :: Merge (const filesystem::path & filename, const int surfindex_offset)
|
||||||
{
|
{
|
||||||
ifstream infile(filename.c_str());
|
ifstream infile(filename);
|
||||||
if (!infile.good())
|
if (!infile.good())
|
||||||
throw NgException ("mesh file not found");
|
throw NgException ("mesh file not found");
|
||||||
|
|
||||||
@ -3758,7 +3767,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mesh :: LoadLocalMeshSize (const string & meshsizefilename)
|
void Mesh :: LoadLocalMeshSize (const filesystem::path & meshsizefilename)
|
||||||
{
|
{
|
||||||
// Philippose - 10/03/2009
|
// Philippose - 10/03/2009
|
||||||
// Improve error checking when loading and reading
|
// Improve error checking when loading and reading
|
||||||
@ -3766,7 +3775,7 @@ namespace netgen
|
|||||||
|
|
||||||
if (meshsizefilename.empty()) return;
|
if (meshsizefilename.empty()) return;
|
||||||
|
|
||||||
ifstream msf(meshsizefilename.c_str());
|
ifstream msf(meshsizefilename);
|
||||||
|
|
||||||
// Philippose - 09/03/2009
|
// Philippose - 09/03/2009
|
||||||
// Adding print message information in case the specified
|
// Adding print message information in case the specified
|
||||||
|
@ -11,8 +11,12 @@
|
|||||||
The mesh class
|
The mesh class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include<filesystem>
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
enum resthtype { RESTRICTH_FACE, RESTRICTH_EDGE,
|
enum resthtype { RESTRICTH_FACE, RESTRICTH_EDGE,
|
||||||
RESTRICTH_SURFACEELEMENT, RESTRICTH_POINT, RESTRICTH_SEGMENT };
|
RESTRICTH_SURFACEELEMENT, RESTRICTH_POINT, RESTRICTH_SEGMENT };
|
||||||
|
|
||||||
@ -446,7 +450,7 @@ namespace netgen
|
|||||||
///
|
///
|
||||||
DLL_HEADER void RestrictLocalH (resthtype rht, int nr, double loch);
|
DLL_HEADER void RestrictLocalH (resthtype rht, int nr, double loch);
|
||||||
///
|
///
|
||||||
DLL_HEADER void LoadLocalMeshSize (const string & meshsizefilename);
|
DLL_HEADER void LoadLocalMeshSize (const filesystem::path & meshsizefilename);
|
||||||
///
|
///
|
||||||
DLL_HEADER void SetGlobalH (double h);
|
DLL_HEADER void SetGlobalH (double h);
|
||||||
///
|
///
|
||||||
@ -545,11 +549,11 @@ namespace netgen
|
|||||||
///
|
///
|
||||||
DLL_HEADER void Merge (istream & infile, const int surfindex_offset = 0);
|
DLL_HEADER void Merge (istream & infile, const int surfindex_offset = 0);
|
||||||
///
|
///
|
||||||
DLL_HEADER void Save (const string & filename) const;
|
DLL_HEADER void Save (const filesystem::path & filename) const;
|
||||||
///
|
///
|
||||||
DLL_HEADER void Load (const string & filename);
|
DLL_HEADER void Load (const filesystem::path & filename);
|
||||||
///
|
///
|
||||||
DLL_HEADER void Merge (const string & filename, const int surfindex_offset = 0);
|
DLL_HEADER void Merge (const filesystem::path & filename, const int surfindex_offset = 0);
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER void DoArchive (Archive & archive);
|
DLL_HEADER void DoArchive (Archive & archive);
|
||||||
|
@ -813,8 +813,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
if(geo!=nullptr) mesh->SetGeometry(geo);
|
if(geo!=nullptr) mesh->SetGeometry(geo);
|
||||||
else if(ng_geometry!=nullptr) mesh->SetGeometry(ng_geometry);
|
else if(ng_geometry!=nullptr) mesh->SetGeometry(ng_geometry);
|
||||||
}),py::call_guard<py::gil_scoped_release>())
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
// static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load))
|
.def("Save", static_cast<void(Mesh::*)(const filesystem::path & name)const>(&Mesh::Save),py::call_guard<py::gil_scoped_release>())
|
||||||
.def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save),py::call_guard<py::gil_scoped_release>())
|
|
||||||
.def("Export",
|
.def("Export",
|
||||||
[] (Mesh & self, string filename, string format)
|
[] (Mesh & self, string filename, string format)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
void LoadOCCInto(OCCGeometry* occgeo, const char* filename);
|
void LoadOCCInto(OCCGeometry* occgeo, const filesystem::path & filename);
|
||||||
void PrintContents (OCCGeometry * geom);
|
void PrintContents (OCCGeometry * geom);
|
||||||
|
|
||||||
std::map<Handle(TopoDS_TShape), ShapeProperties> OCCGeometry::global_shape_properties;
|
std::map<Handle(TopoDS_TShape), ShapeProperties> OCCGeometry::global_shape_properties;
|
||||||
@ -140,10 +140,10 @@ namespace netgen
|
|||||||
if(copy)
|
if(copy)
|
||||||
{
|
{
|
||||||
auto filename = GetTempFilename();
|
auto filename = GetTempFilename();
|
||||||
step_utils::WriteSTEP(_shape, filename.c_str());
|
step_utils::WriteSTEP(_shape, filename);
|
||||||
LoadOCCInto(this, filename.c_str());
|
LoadOCCInto(this, filename);
|
||||||
dimension = aoccdim;
|
dimension = aoccdim;
|
||||||
std::remove(filename.c_str());
|
filesystem::remove(filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1347,7 +1347,7 @@ namespace netgen
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
void LoadOCCInto(OCCGeometry* occgeo, const char* filename)
|
void LoadOCCInto(OCCGeometry* occgeo, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
static Timer timer_all("LoadOCC"); RegionTimer rtall(timer_all);
|
static Timer timer_all("LoadOCC"); RegionTimer rtall(timer_all);
|
||||||
static Timer timer_readfile("LoadOCC-ReadFile");
|
static Timer timer_readfile("LoadOCC-ReadFile");
|
||||||
@ -1375,7 +1375,7 @@ namespace netgen
|
|||||||
// Enable transfer of colours
|
// Enable transfer of colours
|
||||||
reader.SetColorMode(Standard_True);
|
reader.SetColorMode(Standard_True);
|
||||||
reader.SetNameMode(Standard_True);
|
reader.SetNameMode(Standard_True);
|
||||||
Standard_Integer stat = reader.ReadFile((char*)filename);
|
Standard_Integer stat = reader.ReadFile(filename.string().c_str());
|
||||||
timer_readfile.Stop();
|
timer_readfile.Stop();
|
||||||
|
|
||||||
timer_transfer.Start();
|
timer_transfer.Start();
|
||||||
@ -1411,7 +1411,7 @@ namespace netgen
|
|||||||
to extract individual surface colours via the extended
|
to extract individual surface colours via the extended
|
||||||
OpenCascade XDE and XCAF Feature set.
|
OpenCascade XDE and XCAF Feature set.
|
||||||
*/
|
*/
|
||||||
OCCGeometry *LoadOCC_IGES(const char *filename)
|
OCCGeometry *LoadOCC_IGES(const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
OCCGeometry *occgeo;
|
OCCGeometry *occgeo;
|
||||||
occgeo = new OCCGeometry;
|
occgeo = new OCCGeometry;
|
||||||
@ -1432,7 +1432,7 @@ namespace netgen
|
|||||||
|
|
||||||
IGESCAFControl_Reader reader;
|
IGESCAFControl_Reader reader;
|
||||||
|
|
||||||
Standard_Integer stat = reader.ReadFile((char*)filename);
|
Standard_Integer stat = reader.ReadFile(filename.string().c_str());
|
||||||
|
|
||||||
if(stat != IFSelect_RetDone)
|
if(stat != IFSelect_RetDone)
|
||||||
{
|
{
|
||||||
@ -1485,7 +1485,7 @@ namespace netgen
|
|||||||
to extract individual surface colours via the extended
|
to extract individual surface colours via the extended
|
||||||
OpenCascade XDE and XCAF Feature set.
|
OpenCascade XDE and XCAF Feature set.
|
||||||
*/
|
*/
|
||||||
OCCGeometry * LoadOCC_STEP (const char * filename)
|
OCCGeometry * LoadOCC_STEP (const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
OCCGeometry * occgeo;
|
OCCGeometry * occgeo;
|
||||||
occgeo = new OCCGeometry;
|
occgeo = new OCCGeometry;
|
||||||
@ -1497,13 +1497,13 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
OCCGeometry *LoadOCC_BREP (const char *filename)
|
OCCGeometry *LoadOCC_BREP (const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
OCCGeometry * occgeo;
|
OCCGeometry * occgeo;
|
||||||
occgeo = new OCCGeometry;
|
occgeo = new OCCGeometry;
|
||||||
|
|
||||||
BRep_Builder aBuilder;
|
BRep_Builder aBuilder;
|
||||||
Standard_Boolean result = BRepTools::Read(occgeo->shape, const_cast<char*> (filename),aBuilder);
|
Standard_Boolean result = BRepTools::Read(occgeo->shape, filename.string().c_str(), aBuilder);
|
||||||
|
|
||||||
if(!result)
|
if(!result)
|
||||||
{
|
{
|
||||||
@ -1521,34 +1521,36 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OCCGeometry :: Save (string sfilename) const
|
void OCCGeometry :: Save (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
const char * filename = sfilename.c_str();
|
string ext = ToLower(filename.extension());
|
||||||
if (strlen(filename) < 4)
|
auto s_filename = filename.string();
|
||||||
throw NgException ("illegal filename");
|
auto c_filename = s_filename.c_str();
|
||||||
|
|
||||||
if (strcmp (&filename[strlen(filename)-3], "igs") == 0)
|
if (ext == ".igs")
|
||||||
{
|
{
|
||||||
IGESControl_Writer writer("millimeters", 1);
|
IGESControl_Writer writer("millimeters", 1);
|
||||||
writer.AddShape (shape);
|
writer.AddShape (shape);
|
||||||
writer.Write (filename);
|
writer.Write (c_filename);
|
||||||
}
|
}
|
||||||
else if (strcmp (&filename[strlen(filename)-3], "stp") == 0)
|
else if (ext == ".stp")
|
||||||
{
|
{
|
||||||
step_utils::WriteSTEP(*this, filename);
|
step_utils::WriteSTEP(*this, filename);
|
||||||
}
|
}
|
||||||
else if (strcmp (&filename[strlen(filename)-3], "stl") == 0)
|
else if (ext == ".stl")
|
||||||
{
|
{
|
||||||
StlAPI_Writer writer;
|
StlAPI_Writer writer;
|
||||||
writer.ASCIIMode() = Standard_True;
|
writer.ASCIIMode() = Standard_True;
|
||||||
writer.Write (shape, filename);
|
writer.Write (shape, c_filename);
|
||||||
}
|
}
|
||||||
else if (strcmp (&filename[strlen(filename)-4], "stlb") == 0)
|
else if (ext == ".stlb")
|
||||||
{
|
{
|
||||||
StlAPI_Writer writer;
|
StlAPI_Writer writer;
|
||||||
writer.ASCIIMode() = Standard_False;
|
writer.ASCIIMode() = Standard_False;
|
||||||
writer.Write (shape, filename);
|
writer.Write (shape, c_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw NgException ("Unkown target format: " + filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCCGeometry :: SaveToMeshFile (ostream & ost) const
|
void OCCGeometry :: SaveToMeshFile (ostream & ost) const
|
||||||
@ -2267,7 +2269,7 @@ namespace netgen
|
|||||||
OCCGeometry::identifications[shape_origin.TShape()] = result;
|
OCCGeometry::identifications[shape_origin.TShape()] = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteSTEP(const TopoDS_Shape & shape, string filename)
|
void WriteSTEP(const TopoDS_Shape & shape, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
Interface_Static::SetCVal("write.step.schema", "AP242IS");
|
Interface_Static::SetCVal("write.step.schema", "AP242IS");
|
||||||
Interface_Static::SetIVal("write.step.assembly",1);
|
Interface_Static::SetIVal("write.step.assembly",1);
|
||||||
@ -2303,7 +2305,7 @@ namespace netgen
|
|||||||
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
for (TopExp_Explorer e(shape, typ); e.More(); e.Next())
|
||||||
WriteProperties(model, finder, e.Current());
|
WriteProperties(model, finder, e.Current());
|
||||||
|
|
||||||
writer.Write(filename.c_str());
|
writer.Write(filename.string().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace step_utils
|
} // namespace step_utils
|
||||||
|
@ -196,7 +196,7 @@ namespace netgen
|
|||||||
int nr, FlatArray<int, PointIndex> glob2loc) const override;
|
int nr, FlatArray<int, PointIndex> glob2loc) const override;
|
||||||
// void OptimizeSurface(Mesh& mesh, const MeshingParameters& mparam) const override {}
|
// void OptimizeSurface(Mesh& mesh, const MeshingParameters& mparam) const override {}
|
||||||
|
|
||||||
void Save (string filename) const override;
|
void Save (const filesystem::path & filename) const override;
|
||||||
void SaveToMeshFile (ostream & /* ost */) const override;
|
void SaveToMeshFile (ostream & /* ost */) const override;
|
||||||
|
|
||||||
void DoArchive(Archive& ar) override;
|
void DoArchive(Archive& ar) override;
|
||||||
@ -356,9 +356,9 @@ namespace netgen
|
|||||||
|
|
||||||
void PrintContents (OCCGeometry * geom);
|
void PrintContents (OCCGeometry * geom);
|
||||||
|
|
||||||
DLL_HEADER OCCGeometry * LoadOCC_IGES (const char * filename);
|
DLL_HEADER OCCGeometry * LoadOCC_IGES (const filesystem::path & filename);
|
||||||
DLL_HEADER OCCGeometry * LoadOCC_STEP (const char * filename);
|
DLL_HEADER OCCGeometry * LoadOCC_STEP (const filesystem::path & filename);
|
||||||
DLL_HEADER OCCGeometry * LoadOCC_BREP (const char * filename);
|
DLL_HEADER OCCGeometry * LoadOCC_BREP (const filesystem::path & filename);
|
||||||
|
|
||||||
// Philippose - 31.09.2009
|
// Philippose - 31.09.2009
|
||||||
// External access to the mesh generation functions within the OCC
|
// External access to the mesh generation functions within the OCC
|
||||||
@ -535,9 +535,9 @@ namespace netgen
|
|||||||
const Handle(TDocStd_Document) step_doc);
|
const Handle(TDocStd_Document) step_doc);
|
||||||
void WriteProperties(const Handle(Interface_InterfaceModel) model, const Handle(Transfer_FinderProcess) finder, const TopoDS_Shape & shape);
|
void WriteProperties(const Handle(Interface_InterfaceModel) model, const Handle(Transfer_FinderProcess) finder, const TopoDS_Shape & shape);
|
||||||
|
|
||||||
void WriteSTEP(const TopoDS_Shape & shape, string filename);
|
void WriteSTEP(const TopoDS_Shape & shape, const filesystem::path & filename);
|
||||||
|
|
||||||
inline void WriteSTEP(const OCCGeometry & geo, string filename)
|
inline void WriteSTEP(const OCCGeometry & geo, const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
WriteSTEP(geo.GetShape(), filename);
|
WriteSTEP(geo.GetShape(), filename);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace netgen
|
|||||||
class OCCGeometryRegister : public GeometryRegister
|
class OCCGeometryRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const;
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
|
|
||||||
virtual void SetParameters (Tcl_Interp * interp)
|
virtual void SetParameters (Tcl_Interp * interp)
|
||||||
@ -893,55 +893,27 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NetgenGeometry * OCCGeometryRegister :: Load (string filename) const
|
NetgenGeometry * OCCGeometryRegister :: Load (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
const char * lgfilename = filename.c_str();
|
string ext = ToLower(filename.extension());
|
||||||
|
|
||||||
|
if (ext == ".iges" || ext == ".igs")
|
||||||
/*
|
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-3], "geo") == 0)
|
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load OCCG geometry file ", cfilename);
|
PrintMessage (1, "Load IGES geometry file ", filename);
|
||||||
|
OCCGeometry * occgeometry = LoadOCC_IGES (filename);
|
||||||
extern OCCGeometry * ParseOCCG (istream & istr);
|
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
|
||||||
|
|
||||||
OCCGeometry * hgeom = ParseOCCG (infile);
|
|
||||||
if (!hgeom)
|
|
||||||
throw NgException ("geo-file should start with 'algebraic3d'");
|
|
||||||
|
|
||||||
hgeom -> FindIdenticSurfaces(1e-8 * hgeom->MaxSize());
|
|
||||||
return hgeom;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if ((strcmp (&lgfilename[strlen(lgfilename)-4], "iges") == 0) ||
|
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-3], "igs") == 0) ||
|
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-3], "IGS") == 0) ||
|
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-4], "IGES") == 0))
|
|
||||||
{
|
|
||||||
PrintMessage (1, "Load IGES geometry file ", lgfilename);
|
|
||||||
OCCGeometry * occgeometry = LoadOCC_IGES (lgfilename);
|
|
||||||
return occgeometry;
|
return occgeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "step") == 0) ||
|
else if (ext == ".stp" || ext == ".step")
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-3], "stp") == 0) ||
|
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-3], "STP") == 0) ||
|
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-4], "STEP") == 0))
|
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load STEP geometry file ", lgfilename);
|
PrintMessage (1, "Load STEP geometry file ", filename);
|
||||||
OCCGeometry * occgeometry = LoadOCC_STEP (lgfilename);
|
OCCGeometry * occgeometry = LoadOCC_STEP (filename);
|
||||||
return occgeometry;
|
return occgeometry;
|
||||||
}
|
}
|
||||||
else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "brep") == 0) ||
|
else if (ext == ".brep")
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-4], "Brep") == 0) ||
|
|
||||||
(strcmp (&lgfilename[strlen(lgfilename)-4], "BREP") == 0))
|
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load BREP geometry file ", lgfilename);
|
PrintMessage (1, "Load BREP geometry file ", filename);
|
||||||
OCCGeometry * occgeometry = LoadOCC_BREP (lgfilename);
|
OCCGeometry * occgeometry = LoadOCC_BREP (filename);
|
||||||
return occgeometry;
|
return occgeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,11 +137,11 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
{
|
{
|
||||||
shared_ptr<OCCGeometry> geo;
|
shared_ptr<OCCGeometry> geo;
|
||||||
if(EndsWith(filename, ".step") || EndsWith(filename, ".stp"))
|
if(EndsWith(filename, ".step") || EndsWith(filename, ".stp"))
|
||||||
geo.reset(LoadOCC_STEP(filename.c_str()));
|
geo.reset(LoadOCC_STEP(filename));
|
||||||
else if(EndsWith(filename, ".brep"))
|
else if(EndsWith(filename, ".brep"))
|
||||||
geo.reset(LoadOCC_BREP(filename.c_str()));
|
geo.reset(LoadOCC_BREP(filename));
|
||||||
else if(EndsWith(filename, ".iges"))
|
else if(EndsWith(filename, ".iges"))
|
||||||
geo.reset(LoadOCC_IGES(filename.c_str()));
|
geo.reset(LoadOCC_IGES(filename));
|
||||||
else
|
else
|
||||||
throw Exception("Cannot load file " + filename + "\nValid formats are: step, stp, brep, iges");
|
throw Exception("Cannot load file " + filename + "\nValid formats are: step, stp, brep, iges");
|
||||||
ng_geometry = geo;
|
ng_geometry = geo;
|
||||||
@ -279,7 +279,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
m.def("LoadOCCGeometry",[] (const string & filename)
|
m.def("LoadOCCGeometry",[] (filesystem::path filename)
|
||||||
{
|
{
|
||||||
cout << "WARNING: LoadOCCGeometry is deprecated! Just use the OCCGeometry(filename) constructor. It is able to read brep and iges files as well!" << endl;
|
cout << "WARNING: LoadOCCGeometry is deprecated! Just use the OCCGeometry(filename) constructor. It is able to read brep and iges files as well!" << endl;
|
||||||
ifstream ist(filename);
|
ifstream ist(filename);
|
||||||
|
@ -68,28 +68,27 @@ STLGeometry :: ~STLGeometry()
|
|||||||
// delete edgedata;
|
// delete edgedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLGeometry :: Save (string filename) const
|
void STLGeometry :: Save (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
const char * cfilename = filename.c_str();
|
string ext = ToLower(filename.extension());
|
||||||
if (strlen(cfilename) < 4)
|
|
||||||
throw NgException ("illegal filename");
|
|
||||||
|
|
||||||
if (strlen(cfilename) > 3 &&
|
if (ext == ".stl")
|
||||||
strcmp (&cfilename[strlen(cfilename)-3], "stl") == 0)
|
|
||||||
{
|
{
|
||||||
STLTopology::Save (cfilename);
|
STLTopology::Save (filename);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (strlen(cfilename) > 4 &&
|
else if (ext == ".stlb")
|
||||||
strcmp (&cfilename[strlen(cfilename)-4], "stlb") == 0)
|
|
||||||
{
|
{
|
||||||
SaveBinary (cfilename,"Binary STL Geometry");
|
SaveBinary (filename,"Binary STL Geometry");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (ext == ".stle")
|
||||||
|
{
|
||||||
|
SaveSTLE (filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
throw Exception ("Unknown target format: " + filename.string());
|
||||||
else if (strlen(cfilename) > 4 &&
|
|
||||||
strcmp (&cfilename[strlen(cfilename)-4], "stle") == 0)
|
|
||||||
{
|
|
||||||
SaveSTLE (cfilename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1100,22 +1099,22 @@ void STLGeometry :: ExportEdges()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLGeometry :: LoadEdgeData(const char* file)
|
void STLGeometry :: LoadEdgeData(const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
StoreEdgeData();
|
StoreEdgeData();
|
||||||
|
|
||||||
PrintFnStart("Load edges from file '", file, "'");
|
PrintFnStart("Load edges from file '", filename, "'");
|
||||||
ifstream fin(file);
|
ifstream fin(filename);
|
||||||
|
|
||||||
edgedata->Read(fin);
|
edgedata->Read(fin);
|
||||||
|
|
||||||
// calcedgedataanglesnew = 1;
|
// calcedgedataanglesnew = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLGeometry :: SaveEdgeData(const char* file)
|
void STLGeometry :: SaveEdgeData(const filesystem::path & filename)
|
||||||
{
|
{
|
||||||
PrintFnStart("save edges to file '", file, "'");
|
PrintFnStart("save edges to file '", filename, "'");
|
||||||
ofstream fout(file);
|
ofstream fout(filename);
|
||||||
|
|
||||||
edgedata->Write(fout);
|
edgedata->Write(fout);
|
||||||
}
|
}
|
||||||
@ -3627,7 +3626,7 @@ void STLGeometry :: SmoothGeometry ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLGeometry :: WriteChartToFile( ChartId chartnumber, string filename )
|
void STLGeometry :: WriteChartToFile( ChartId chartnumber, filesystem::path filename )
|
||||||
{
|
{
|
||||||
PrintMessage(1,"write chart ", int(chartnumber), " to ", filename);
|
PrintMessage(1,"write chart ", int(chartnumber), " to ", filename);
|
||||||
Array<int> trignums;
|
Array<int> trignums;
|
||||||
@ -3701,38 +3700,38 @@ void STLGeometry :: WriteChartToFile( ChartId chartnumber, string filename )
|
|||||||
class STLGeometryRegister : public GeometryRegister
|
class STLGeometryRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
NetgenGeometry * STLGeometryRegister :: Load (string filename) const
|
NetgenGeometry * STLGeometryRegister :: Load (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
const char * cfilename = filename.c_str();
|
string ext = ToLower(filename.extension());
|
||||||
|
|
||||||
if (strcmp (&cfilename[strlen(cfilename)-3], "stl") == 0)
|
if (ext == ".stl")
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load STL geometry file ", cfilename);
|
PrintMessage (1, "Load STL geometry file ", filename);
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
ifstream infile(filename);
|
||||||
|
|
||||||
STLGeometry * hgeom = STLGeometry :: Load (infile);
|
STLGeometry * hgeom = STLGeometry :: Load (infile);
|
||||||
hgeom -> edgesfound = 0;
|
hgeom -> edgesfound = 0;
|
||||||
return hgeom;
|
return hgeom;
|
||||||
}
|
}
|
||||||
else if (strcmp (&cfilename[strlen(cfilename)-4], "stlb") == 0)
|
else if (ext == ".stlb")
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load STL binary geometry file ", cfilename);
|
PrintMessage (1, "Load STL binary geometry file ", filename);
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
ifstream infile(filename);
|
||||||
|
|
||||||
STLGeometry * hgeom = STLGeometry :: LoadBinary (infile);
|
STLGeometry * hgeom = STLGeometry :: LoadBinary (infile);
|
||||||
hgeom -> edgesfound = 0;
|
hgeom -> edgesfound = 0;
|
||||||
return hgeom;
|
return hgeom;
|
||||||
}
|
}
|
||||||
else if (strcmp (&cfilename[strlen(cfilename)-3], "nao") == 0)
|
else if (ext == ".nao")
|
||||||
{
|
{
|
||||||
PrintMessage (1, "Load naomi (F. Kickinger) geometry file ", cfilename);
|
PrintMessage (1, "Load naomi (F. Kickinger) geometry file ", filename);
|
||||||
|
|
||||||
ifstream infile(cfilename);
|
ifstream infile(filename);
|
||||||
|
|
||||||
STLGeometry * hgeom = STLGeometry :: LoadNaomi (infile);
|
STLGeometry * hgeom = STLGeometry :: LoadNaomi (infile);
|
||||||
hgeom -> edgesfound = 0;
|
hgeom -> edgesfound = 0;
|
||||||
|
@ -190,7 +190,7 @@ namespace netgen
|
|||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
virtual void Save (string filename) const override;
|
virtual void Save (const filesystem::path & filename) const override;
|
||||||
|
|
||||||
bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const override;
|
bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const override;
|
||||||
PointGeomInfo ProjectPoint(INDEX surfind, Point<3> & p) const override;
|
PointGeomInfo ProjectPoint(INDEX surfind, Point<3> & p) const override;
|
||||||
@ -236,8 +236,8 @@ namespace netgen
|
|||||||
DLL_HEADER void ImportEdges();
|
DLL_HEADER void ImportEdges();
|
||||||
DLL_HEADER void AddEdges(const NgArray<Point<3> >& eps);
|
DLL_HEADER void AddEdges(const NgArray<Point<3> >& eps);
|
||||||
DLL_HEADER void ExportEdges();
|
DLL_HEADER void ExportEdges();
|
||||||
DLL_HEADER void LoadEdgeData(const char* file);
|
DLL_HEADER void LoadEdgeData(const filesystem::path & file);
|
||||||
DLL_HEADER void SaveEdgeData(const char* file);
|
DLL_HEADER void SaveEdgeData(const filesystem::path & file);
|
||||||
// void SetEdgeAtSelected(int mode);
|
// void SetEdgeAtSelected(int mode);
|
||||||
|
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ namespace netgen
|
|||||||
int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam) override;
|
int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam) override;
|
||||||
|
|
||||||
// Add additional Point to chart to close the surface and write the resulting stl to a file
|
// Add additional Point to chart to close the surface and write the resulting stl to a file
|
||||||
DLL_HEADER void WriteChartToFile( ChartId chartnumber, string filename="chart.slb" );
|
DLL_HEADER void WriteChartToFile( ChartId chartnumber, filesystem::path filename="chart.slb" );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace netgen
|
|||||||
class STLGeometryVisRegister : public GeometryRegister
|
class STLGeometryVisRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const { return NULL; }
|
virtual NetgenGeometry * Load (const filesystem::path & filename) const { return NULL; }
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
virtual void SetParameters (Tcl_Interp * interp)
|
virtual void SetParameters (Tcl_Interp * interp)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ STLGeometry * STLTopology :: LoadBinary (istream & ist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void STLTopology :: SaveBinary (const char* filename, const char* aname) const
|
void STLTopology :: SaveBinary (const filesystem::path & filename, const char* aname) const
|
||||||
{
|
{
|
||||||
ofstream ost(filename);
|
ofstream ost(filename);
|
||||||
PrintFnStart("Write STL binary file '",filename,"'");
|
PrintFnStart("Write STL binary file '",filename,"'");
|
||||||
@ -149,7 +149,7 @@ void STLTopology :: SaveBinary (const char* filename, const char* aname) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void STLTopology :: SaveSTLE (const char* filename) const
|
void STLTopology :: SaveSTLE (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
ofstream outf (filename);
|
ofstream outf (filename);
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -266,7 +266,7 @@ STLGeometry * STLTopology :: LoadNaomi (istream & ist)
|
|||||||
return geom;
|
return geom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLTopology :: Save (const char* filename) const
|
void STLTopology :: Save (const filesystem::path & filename) const
|
||||||
{
|
{
|
||||||
PrintFnStart("Write stl-file '",filename, "'");
|
PrintFnStart("Write stl-file '",filename, "'");
|
||||||
|
|
||||||
|
@ -316,9 +316,9 @@ public:
|
|||||||
static STLGeometry * Load (istream & ist);
|
static STLGeometry * Load (istream & ist);
|
||||||
static STLGeometry * LoadBinary (istream & ist);
|
static STLGeometry * LoadBinary (istream & ist);
|
||||||
|
|
||||||
void Save (const char* filename) const;
|
void Save (const filesystem::path & filename) const;
|
||||||
void SaveBinary (const char* filename, const char* aname) const;
|
void SaveBinary (const filesystem::path & filename, const char* aname) const;
|
||||||
void SaveSTLE (const char * filename) const; // stores trigs and edges
|
void SaveSTLE (const filesystem::path & filename) const; // stores trigs and edges
|
||||||
|
|
||||||
virtual void DoArchive(Archive& ar)
|
virtual void DoArchive(Archive& ar)
|
||||||
{
|
{
|
||||||
|
37
ng/ngpkg.cpp
37
ng/ngpkg.cpp
@ -205,9 +205,9 @@ namespace netgen
|
|||||||
Tcl_Interp * interp,
|
Tcl_Interp * interp,
|
||||||
int argc, tcl_const char *argv[])
|
int argc, tcl_const char *argv[])
|
||||||
{
|
{
|
||||||
string filename (argv[1]);
|
auto filename = filesystem::u8path(argv[1]);
|
||||||
|
|
||||||
if (filename.find(".vol") == string::npos)
|
if (filename.string().find(".vol") == string::npos)
|
||||||
{
|
{
|
||||||
return Ng_ImportMesh(clientData,interp,argc,argv);
|
return Ng_ImportMesh(clientData,interp,argc,argv);
|
||||||
}
|
}
|
||||||
@ -217,42 +217,15 @@ namespace netgen
|
|||||||
mesh = make_shared<Mesh>();
|
mesh = make_shared<Mesh>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
istream * infile;
|
mesh -> Load(filename);
|
||||||
// if (filename.substr (filename.length()-3, 3) == ".gz")
|
|
||||||
if (filename.find(".vol.gz") != string::npos)
|
|
||||||
infile = new igzstream (filename.c_str());
|
|
||||||
else
|
|
||||||
infile = new ifstream (filename.c_str());
|
|
||||||
|
|
||||||
// ifstream infile(filename.c_str());
|
|
||||||
mesh -> Load(*infile);
|
|
||||||
// vsmesh.SetMesh (mesh);
|
|
||||||
SetGlobalMesh (mesh);
|
SetGlobalMesh (mesh);
|
||||||
|
|
||||||
#ifdef PARALLEL
|
#ifdef PARALLEL
|
||||||
MyMPI_SendCmd ("mesh");
|
MyMPI_SendCmd ("mesh");
|
||||||
mesh -> Distribute();
|
mesh -> Distribute();
|
||||||
#endif
|
#endif
|
||||||
auto geo = geometryregister.LoadFromMeshFile (*infile);
|
if(mesh->GetGeometry())
|
||||||
if(geo)
|
ng_geometry = mesh->GetGeometry();
|
||||||
ng_geometry = geo;
|
|
||||||
delete infile;
|
|
||||||
|
|
||||||
/*
|
|
||||||
string auxstring;
|
|
||||||
if(infile.good())
|
|
||||||
{
|
|
||||||
infile >> auxstring;
|
|
||||||
if(auxstring == "csgsurfaces")
|
|
||||||
{
|
|
||||||
CSGeometry * geometry = new CSGeometry ("");
|
|
||||||
geometry -> LoadSurfaces(infile);
|
|
||||||
|
|
||||||
delete ng_geometry;
|
|
||||||
ng_geometry = geometry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
catch (NgException e)
|
catch (NgException e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user