From c4c3773610b4f64b8cf36c69818e55f33fbccb0d Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Tue, 22 Sep 2009 07:12:00 +0000 Subject: [PATCH] save export filetype --- configure.ac | 2 +- libsrc/csg/edgeflw.cpp | 20 +++++++++++++- libsrc/csg/genmesh.cpp | 4 +-- libsrc/interface/writeuser.cpp | 47 +++++++++++++++++--------------- libsrc/interface/writeuser.hpp | 4 ++- libsrc/meshing/bcfunctions.cpp | 2 +- libsrc/meshing/hprefinement.cpp | 10 +++---- libsrc/meshing/meshclass.cpp | 6 ++--- libsrc/meshing/meshclass.hpp | 28 ++++++++++++++----- libsrc/meshing/meshing2.cpp | 17 +++++++----- libsrc/meshing/meshtype.cpp | 22 +++++++-------- libsrc/meshing/meshtype.hpp | 48 ++++++++++++++++++++++----------- ng/menustat.tcl | 15 ++++++++--- ng/ngappinit.cpp | 16 +++++++---- ng/variables.tcl | 1 + 15 files changed, 160 insertions(+), 82 deletions(-) diff --git a/configure.ac b/configure.ac index 836945fe..a5497d98 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([netgen],[4.9.11],[],[]) +AC_INIT([netgen],[4.9.12-dev],[],[]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/libsrc/csg/edgeflw.cpp b/libsrc/csg/edgeflw.cpp index adf52261..e6b6b76a 100644 --- a/libsrc/csg/edgeflw.cpp +++ b/libsrc/csg/edgeflw.cpp @@ -443,6 +443,7 @@ namespace netgen StoreShortEdge (refedges, refedgesinv, edgepoints, curvelength, layer, mesh); + for(int i = 0; i < refedges.Size(); i++) { refedges[i].surfnr1 = geometry.GetSurfaceClassRepresentant(refedges[i].surfnr1); @@ -481,7 +482,24 @@ namespace netgen mesh); } - + + /* + // not available ... + for (int i = 0; i < refedges.Size(); i++) + { + EdgeDescriptor ed; + ed.SetSurfNr(0, refedges[i].surfnr1); + ed.SetSurfNr(1, refedges[i].surfnr2); + int hnr = mesh.AddEdgeDescriptor(ed); + if (hnr != refedges[i].edgenr) + { + cerr << "edgedescriptor index wrong: new : " << hnr << " old = " << refedges[i].edgenr << endl; + } + } + */ + + + // for(int i=0; iGetDomainNr() == fd.DomainIn()) - fd.domin_singular = 1; + fd.SetDomainInSingular (1); if (geom.singfaces[j]->GetDomainNr() == fd.DomainOut()) - fd.domout_singular = 1; + fd.SetDomainOutSingular (1); } } } diff --git a/libsrc/interface/writeuser.cpp b/libsrc/interface/writeuser.cpp index 148f90a3..7f884b1a 100644 --- a/libsrc/interface/writeuser.cpp +++ b/libsrc/interface/writeuser.cpp @@ -15,34 +15,39 @@ namespace netgen #include "writeuser.hpp" -void RegisterUserFormats (Array & names) + void RegisterUserFormats (Array & names, + Array & extensions) + { const char *types[] = { - "Neutral Format", - "Surface Mesh Format" , - "DIFFPACK Format", - "TecPlot Format", - "Tochnog Format", - "Abaqus Format", - "Fluent Format", - "Permas Format", - "FEAP Format", - "Elmer Format", - "STL Format", - "VRML Format", - "Gmsh Format", - "Gmsh2 Format", - "JCMwave Format", - "TET Format", + "Neutral Format", ".mesh", + "Surface Mesh Format", ".mesh" , + "DIFFPACK Format", ".mesh", + "TecPlot Format", ".mesh", + "Tochnog Format", ".mesh", + "Abaqus Format", ".mesh", + "Fluent Format", ".mesh", + "Permas Format", ".mesh", + "FEAP Format", ".mesh", + "Elmer Format", "*", + "STL Format", ".stl", + "VRML Format", ".*", + "Gmsh Format", ".gmsh", + "Gmsh2 Format", ".gmsh2", + "JCMwave Format", ".jcm", + "TET Format", ".tet", // { "Chemnitz Format" }, 0 }; - - for (int i = 0; types[i]; i++) - names.Append (types[i]); + + for (int i = 0; types[2*i]; i++) + { + names.Append (types[2*i]); + extensions.Append (types[2*i+1]); + } } - + bool WriteUserFormat (const string & format, diff --git a/libsrc/interface/writeuser.hpp b/libsrc/interface/writeuser.hpp index c841aad0..f9b5e9fc 100644 --- a/libsrc/interface/writeuser.hpp +++ b/libsrc/interface/writeuser.hpp @@ -135,7 +135,9 @@ void WriteDolfinFormat (const Mesh & mesh, const string & filename); -extern void RegisterUserFormats (Array & names); +extern void RegisterUserFormats (Array & names, + Array & extensions); + extern bool WriteUserFormat (const string & format, const Mesh & mesh, diff --git a/libsrc/meshing/bcfunctions.cpp b/libsrc/meshing/bcfunctions.cpp index d1e031d3..1d3d4aa2 100644 --- a/libsrc/meshing/bcfunctions.cpp +++ b/libsrc/meshing/bcfunctions.cpp @@ -147,7 +147,7 @@ namespace netgen for(int i = 1; i <= numentries; i++) { int bcnum; - double col_red, col_green, col_blue; + // double col_red, col_green, col_blue; ocf >> bcnum; // Boundary condition number 0 is reserved for diff --git a/libsrc/meshing/hprefinement.cpp b/libsrc/meshing/hprefinement.cpp index 7a693da1..ca90f129 100644 --- a/libsrc/meshing/hprefinement.cpp +++ b/libsrc/meshing/hprefinement.cpp @@ -1668,21 +1668,21 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE & edges, INDEX_2_HAS const FaceDescriptor & fd = mesh.GetFaceDescriptor (el.GetIndex()); int domnr = 0; - if (fd.domin_singular * levels < act_ref && fd.domout_singular * levels < act_ref) + if (fd.DomainInSingular() * levels < act_ref && fd.DomainOutSingular() * levels < act_ref) { domnr=0; continue;} - if (fd.domin_singular * levels >= act_ref) + if (fd.DomainInSingular() * levels >= act_ref) { domnr = fd.DomainIn(); sing = 1; } - if (fd.domout_singular * levels >= act_ref) + if (fd.DomainOutSingular() * levels >= act_ref) { domnr = fd.DomainOut(); sing = 1; } - if (fd.domin_singular * levels >= act_ref - && fd.domout_singular * levels >= act_ref) + if (fd.DomainInSingular() * levels >= act_ref + && fd.DomainOutSingular() * levels >= act_ref) { domnr = -1; sing = 1; diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 5efbcc12..3e4ee599 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -7,9 +7,9 @@ namespace netgen Mesh :: Mesh () { - volelements.SetName ("vol elements"); - surfelements.SetName ("surf elements"); - points.SetName ("meshpoints"); + // volelements.SetName ("vol elements"); + // surfelements.SetName ("surf elements"); + // points.SetName ("meshpoints"); boundaryedges = NULL; surfelementht = NULL; diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index fe8916ca..122e17a8 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -23,13 +23,15 @@ class HPRefElement; class Mesh { public: - typedef MoveableArray T_POINTS; - typedef MoveableArray T_VOLELEMENTS; - typedef MoveableArray T_SURFELEMENTS; + typedef ::netgen::T_POINTS T_POINTS; + + // typedef MoveableArray T_POINTS; + // typedef MoveableArray T_VOLELEMENTS; + // typedef MoveableArray T_SURFELEMENTS; // typedef Array T_POINTS; - // typedef Array T_VOLELEMENTS; - // typedef Array T_SURFELEMENTS; + typedef Array T_VOLELEMENTS; + typedef Array T_SURFELEMENTS; private: @@ -82,10 +84,18 @@ private: */ Array facedecoding; + + /** + the edge-index of the line element maps into + this table. + */ + Array edgedecoding; + /// sub-domain materials Array materials; - Array bcnames; + /// labels for boundary conditions + Array bcnames; /// Periodic surface, close surface, etc. identifications Identifications * ident; @@ -565,6 +575,8 @@ public: int AddFaceDescriptor(const FaceDescriptor& fd) { return facedecoding.Append(fd); } + int AddEdgeDescriptor(const EdgeDescriptor & fd) + { return edgedecoding.Append(fd) - 1; } /// void SetMaterial (int domnr, const char * mat); @@ -591,6 +603,10 @@ public: const FaceDescriptor & GetFaceDescriptor (int i) const { return facedecoding.Get(i); } + const EdgeDescriptor & GetEdgeDescriptor (int i) const + { return edgedecoding[i]; } + + /// FaceDescriptor & GetFaceDescriptor (int i) { return facedecoding.Elem(i); } diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index 73e8b187..5e4112c6 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -399,12 +399,17 @@ namespace netgen debugflag = - debugparam.haltsegment && - ( ((debugparam.haltsegmentp1 == gpi1) && (debugparam.haltsegmentp2 == gpi2)) || - ((debugparam.haltsegmentp1 == gpi2) && (debugparam.haltsegmentp2 == gpi1))) || - debugparam.haltnode && - ( (debugparam.haltsegmentp1 == gpi1) || (debugparam.haltsegmentp2 == gpi1)); - + ( + debugparam.haltsegment && + ( ((debugparam.haltsegmentp1 == gpi1) && (debugparam.haltsegmentp2 == gpi2)) || + ((debugparam.haltsegmentp1 == gpi2) && (debugparam.haltsegmentp2 == gpi1))) + ) + || + ( + debugparam.haltnode && + ( (debugparam.haltsegmentp1 == gpi1) || (debugparam.haltsegmentp2 == gpi1)) + ); + if (debugparam.haltface && debugparam.haltfacenr == facenr) { diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index e7dafe0b..29ddca06 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2270,9 +2270,9 @@ namespace netgen FaceDescriptor :: FaceDescriptor(const FaceDescriptor& other) : surfnr(other.surfnr), domin(other.domin), domout(other.domout), - tlosurf(other.tlosurf), bcprop(other.bcprop), bcname(other.bcname), - domin_singular(other.domin_singular), domout_singular(other.domout_singular), - surfcolour(other.surfcolour) + tlosurf(other.tlosurf), bcprop(other.bcprop), + surfcolour(other.surfcolour), bcname(other.bcname), + domin_singular(other.domin_singular), domout_singular(other.domout_singular) { firstelement = -1; } @@ -2337,14 +2337,14 @@ namespace netgen ostream & operator<<(ostream & s, const FaceDescriptor & fd) { - s << "surfnr = " << fd.surfnr - << ", domin = " << fd.domin - << ", domout = " << fd.domout - << ", tlosurf = " << fd.tlosurf - << ", bcprop = " << fd.bcprop - << ", domin_sing = " << fd.domin_singular - << ", domout_sing = " << fd.domout_singular - << ", colour = " << fd.surfcolour; + s << "surfnr = " << fd.SurfNr() + << ", domin = " << fd.DomainIn() + << ", domout = " << fd.DomainOut() + << ", tlosurf = " << fd.TLOSurface() + << ", bcprop = " << fd.BCProperty() + << ", domin_sing = " << fd.DomainInSingular() + << ", domout_sing = " << fd.DomainOutSingular() + << ", colour = " << fd.SurfColour(); return s; } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index a71e7807..eb83dbfc 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -280,8 +280,8 @@ ostream & operator<<(ostream & s, const MeshPoint & pt); -typedef MoveableArray T_POINTS; -// typedef Array T_POINTS; +// typedef MoveableArray T_POINTS; +typedef Array T_POINTS; class Element2d; @@ -422,7 +422,7 @@ public: bool BadElement() const { return badel; } - friend ostream & operator<<(ostream & s, const Element2d & el); + // friend ostream & operator<<(ostream & s, const Element2d & el); friend class Mesh; @@ -785,15 +785,10 @@ public: ~Segment() { ; } - friend ostream & operator<<(ostream & s, const Segment & seg); + // friend ostream & operator<<(ostream & s, const Segment & seg); PointIndex pnums[3]; // p1, p2, pmid - /// point index 1 - // PointIndex p1; - /// point index 2 - // PointIndex p2; - /// edge nr int edgenr; /// double singedge_left; @@ -875,8 +870,7 @@ public: // class Surface; -class FaceDescriptor; -ostream & operator<< (ostream & s, const FaceDescriptor & fd); +// class FaceDescriptor; /// class FaceDescriptor @@ -902,10 +896,9 @@ class FaceDescriptor /// root of linked list SurfaceElementIndex firstelement; -public: - /// double domin_singular; double domout_singular; + public: FaceDescriptor(); FaceDescriptor(int surfnri, int domini, int domouti, int tlosurfi); @@ -920,6 +913,11 @@ public: int DomainOut () const { return domout; } int TLOSurface () const { return tlosurf; } int BCProperty () const { return bcprop; } + + + double DomainInSingular() const { return domin_singular; } + double DomainOutSingular() const { return domout_singular; } + // Philippose - 06/07/2009 // Get Surface colour Vec3d SurfColour () const { return surfcolour; } @@ -935,12 +933,32 @@ public: // Set the surface colour void SetSurfColour (Vec3d colour) { surfcolour = colour; } - friend ostream & operator<<(ostream & s, const FaceDescriptor & fd); + void SetDomainInSingular (double v) { domin_singular = v; } + void SetDomainOutSingular (double v) { domout_singular = v; } + + + // friend ostream & operator<<(ostream & s, const FaceDescriptor & fd); friend class Mesh; }; - +ostream & operator<< (ostream & s, const FaceDescriptor & fd); + +class EdgeDescriptor +{ + int tlosurf; + int surfnr[2]; +public: + EdgeDescriptor () + : tlosurf(-1) + { surfnr[0] = surfnr[1] = -1; } + + int SurfNr (int i) const { return surfnr[i]; } + void SetSurfNr (int i, int nr) { surfnr[i] = nr; } + + int TLOSurface() const { return tlosurf; } + void SetTLOSurface (int nr) { tlosurf = nr; } +}; diff --git a/ng/menustat.tcl b/ng/menustat.tcl index 8ad74cfc..ae1cb5f9 100644 --- a/ng/menustat.tcl +++ b/ng/menustat.tcl @@ -93,9 +93,6 @@ menu .ngmenu.file lappend types {"ACIS Geometry" {.sat} } } - - -# set file [tk_getSaveFile -filetypes $types -defaultextension ".stl" -initialdir $dirname -initialfile $basefilename ] set file [tk_getSaveFile -filetypes $types -initialdir $dirname -initialfile $basefilename ] if {$file != ""} { Ng_SaveGeometry $file @@ -234,13 +231,23 @@ loadmeshinifile; } } + .ngmenu.file add command -label "Export Mesh..." \ -command { + +# global meshexportformats + foreach exportformat $meshexportformats { + if { [lindex $exportformat 0] == $exportfiletype } { + set extension [lindex $exportformat 1] + } + } + if { $exportfiletype == "Elmer Format" } { set file [tk_chooseDirectory] } else { - set file [tk_getSaveFile] + set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {$extension} }" ] } + if {$file != ""} { Ng_ExportMesh $file $exportfiletype } diff --git a/ng/ngappinit.cpp b/ng/ngappinit.cpp index 01501310..8efc69d0 100644 --- a/ng/ngappinit.cpp +++ b/ng/ngappinit.cpp @@ -269,16 +269,22 @@ int main(int argc, char ** argv) // lookup user file formats and insert into format list: Array userformats; - RegisterUserFormats (userformats); + Array extensions; + RegisterUserFormats (userformats, extensions); ostringstream fstr; + + tcl_const char * exportft = Tcl_GetVar (myinterp, "exportfiletype", 0); for (int i = 1; i <= userformats.Size(); i++) - fstr << ".ngmenu.file.filetype add radio -label \"" - << userformats.Get(i) << "\" -variable exportfiletype\n"; - + { + fstr << ".ngmenu.file.filetype add radio -label \"" + << userformats.Get(i) << "\" -variable exportfiletype\n"; + fstr << "lappend meshexportformats { {" << userformats.Get(i) << "} {" << extensions.Get(i) << "} }\n"; + } Tcl_Eval (myinterp, (char*)fstr.str().c_str()); - Tcl_SetVar (myinterp, "exportfiletype", "Neutral Format", 0); + // Tcl_SetVar (myinterp, "exportfiletype", "Neutral Format", 0); + Tcl_SetVar (myinterp, "exportfiletype", exportft, 0); // For adding an application, parse the file here, diff --git a/ng/variables.tcl b/ng/variables.tcl index 66818153..30150c9f 100644 --- a/ng/variables.tcl +++ b/ng/variables.tcl @@ -389,6 +389,7 @@ proc saveoptions { } { set datei [open $file w] puts $datei "dirname ${dirname}" puts $datei "loadgeomtypevar \"${loadgeomtypevar}\"" + puts $datei "exportfiletype \"${exportfiletype}\"" puts $datei "meshoptions.fineness ${meshoptions.fineness}" puts $datei "meshoptions.firststep ${meshoptions.firststep}" puts $datei "meshoptions.laststep ${meshoptions.laststep}"