diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index fd89bc4fd8ac5793128d9cb46359efb059503b3d..581fa46929cc1a8023fbd6552c5cbd2b65e660c8 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -196,6 +196,10 @@ void Get_Options(int argc, char *argv[]) CTX.batch = 4; i++; } + else if(!strcmp(argv[i] + 1, "new")) { + CTX.files.push_back("-new"); + i++; + } else if(!strcmp(argv[i] + 1, "socket")) { i++; if(argv[i] != NULL) @@ -204,12 +208,12 @@ void Get_Options(int argc, char *argv[]) Msg::Fatal("Missing string"); CTX.batch = 5; } - else if(!strcmp(argv[i] + 1, "refine")) { - CTX.batch = 6; - i++; + else if(!strcmp(argv[i] + 1, "refine")) { + CTX.batch = 6; + i++; } else if(!strcmp(argv[i] + 1, "part")) { - CTX.batchAfterMesh = 1; + CTX.batch = 7; i++; } else if(!strcmp(argv[i] + 1, "pid")) { diff --git a/Common/Context.h b/Common/Context.h index 81447815a284f8996d8ab25ffe3b49e7398b7c23..2a8af88c0610d74f4b2760e2bebea44353a595b4 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -64,8 +64,8 @@ class Context_T { int field_size[2]; // size of the field window on the screen int file_chooser_position[2]; // position of the file chooser window on the screen int system_menu_bar; // use the system menu bar on MacOS? - int batch; // 0=full gfx; -1=just parse; 1,2,3=batch 1D, 2D, 3D mesh - int batchAfterMesh; // 1=partition + int batch; // 0=full gfx; -1=write geo; -2=check coherence; 1,2,3=batch mesh; + // 4=adapt; 5=server daemon; 6=refine; 7=partition int initial_context; // 0=automatic; 1=geom; 2=mesh; 3=solver; 4=post int nopopup; // never popup dialogs in scripts (use default values instead) int non_modal_windows; // make all windows "non modal" diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index a8b927366ccf35c12f55163af2c6a5cf137b35ff..20352339973340abed41e7bee833eba995fd6987 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -69,6 +69,11 @@ int GmshSetOption(std::string category, std::string name, double value, int inde return 0; } +int GmshMergeFile(std::string fileName) +{ + return MergeFile(fileName.c_str(), 1); +} + int GmshFinalize() { return 1; @@ -79,8 +84,13 @@ int GmshBatch() if(!GModel::current()) return 0; OpenProject(CTX.filename); - for(unsigned int i = 1; i < CTX.files.size(); i++) - MergeFile(CTX.files[i].c_str()); + for(unsigned int i = 1; i < CTX.files.size(); i++){ + if(CTX.files[i] == "-new") + new GModel; + else + MergeFile(CTX.files[i].c_str()); + } + #if !defined(HAVE_NO_POST) if(CTX.bgm_filename) { MergeFile(CTX.bgm_filename); @@ -90,9 +100,9 @@ int GmshBatch() Msg::Error("Invalid background mesh (no view)"); } #endif - if(CTX.batch == 5) { + + if(CTX.batch == 5) GmshDaemon(CTX.solver.socket_name); - } else if(CTX.batch == 4) { AdaptMesh(GModel::current()); CreateOutputFile(CTX.output_filename, CTX.mesh.format); @@ -100,8 +110,8 @@ int GmshBatch() else if(CTX.batch > 0) { GModel::current()->mesh(CTX.batch); #if defined(HAVE_CHACO) || defined(HAVE_METIS) - if(CTX.batchAfterMesh == 1) - PartitionMesh(GModel::current(), CTX.mesh.partition_options); + if(CTX.batch == 7) + PartitionMesh(GModel::current(), CTX.mesh.partition_options); #endif CreateOutputFile(CTX.output_filename, CTX.mesh.format); } diff --git a/Common/Gmsh.h b/Common/Gmsh.h index 40acf6735839a7dc78c59e336cfd56219083c36d..663243e9a4a87a7d28b83d25fbd6c6f9bd5d6b32 100644 --- a/Common/Gmsh.h +++ b/Common/Gmsh.h @@ -13,6 +13,7 @@ int GmshInitialize(int argc=0, char **argv=0); int GmshSetMessageHandler(GmshMessage *callback); int GmshSetOption(std::string category, std::string name, std::string value, int index=0); int GmshSetOption(std::string category, std::string name, double value, int index=0); +int GmshMergeFile(std::string fileName); int GmshFinalize(); int GmshBatch(); diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index 722fff0953d1130d3630525de2b47cbd1492d50f..f536183816e58dbfb2d90ef3a323426cee776a70 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -236,11 +236,18 @@ void SetProjectName(const char *name) int MergeFile(const char *name, int warn_if_missing) { + GModel *model = GModel::current(); + if(!model){ + Msg::Error("No models exists in which to merge data"); + return 0; + } + // added 'b' for pure Windows programs, since some of these files // contain binary data FILE *fp = fopen(name, "rb"); if(!fp){ - if(warn_if_missing) Msg::Warning("Unable to open file '%s'", name); + if(warn_if_missing) + Msg::Warning("Unable to open file '%s'", name); return 0; } @@ -274,48 +281,39 @@ int MergeFile(const char *name, int warn_if_missing) CTX.geom.draw = 0; // don't try to draw the model while reading - GModel *m = GModel::current(); - - // FIXME: We need to decide what do do for CAD entities, meshes, - // etc. For meshes we should definitely create one new model per - // merge (and reset current() to the previous value after the - // merge). This will make multi-step multi-meshes post-pro views - // work out of the box. - // GModel *m = new GModel; - #if !defined(HAVE_NO_POST) int numViewsBefore = PView::list.size(); #endif int status = 0; if(!strcmp(ext, ".stl") || !strcmp(ext, ".STL")){ - status = m->readSTL(name, CTX.geom.tolerance); + status = model->readSTL(name, CTX.geom.tolerance); } else if(!strcmp(ext, ".brep") || !strcmp(ext, ".rle") || !strcmp(ext, ".brp") || !strcmp(ext, ".BRP")){ - status = m->readOCCBREP(std::string(name)); + status = model->readOCCBREP(std::string(name)); } else if(!strcmp(ext, ".iges") || !strcmp(ext, ".IGES") || !strcmp(ext, ".igs") || !strcmp(ext, ".IGS")){ - status = m->readOCCIGES(std::string(name)); + status = model->readOCCIGES(std::string(name)); } else if(!strcmp(ext, ".step") || !strcmp(ext, ".STEP") || !strcmp(ext, ".stp") || !strcmp(ext, ".STP")){ - status = m->readOCCSTEP(std::string(name)); + status = model->readOCCSTEP(std::string(name)); } else if(!strcmp(ext, ".unv") || !strcmp(ext, ".UNV")){ - status = m->readUNV(name); + status = model->readUNV(name); } else if(!strcmp(ext, ".vtk") || !strcmp(ext, ".VTK")){ - status = m->readVTK(name, CTX.big_endian); + status = model->readVTK(name, CTX.big_endian); } else if(!strcmp(ext, ".wrl") || !strcmp(ext, ".WRL") || !strcmp(ext, ".vrml") || !strcmp(ext, ".VRML") || !strcmp(ext, ".iv") || !strcmp(ext, ".IV")){ - status = m->readVRML(name); + status = model->readVRML(name); } else if(!strcmp(ext, ".mesh") || !strcmp(ext, ".MESH")){ - status = m->readMESH(name); + status = model->readMESH(name); } else if(!strcmp(ext, ".med") || !strcmp(ext, ".MED") || !strcmp(ext, ".mmed") || !strcmp(ext, ".MMED") || @@ -327,13 +325,13 @@ int MergeFile(const char *name, int warn_if_missing) } else if(!strcmp(ext, ".bdf") || !strcmp(ext, ".BDF") || !strcmp(ext, ".nas") || !strcmp(ext, ".NAS")){ - status = m->readBDF(name); + status = model->readBDF(name); } else if(!strcmp(ext, ".p3d") || !strcmp(ext, ".P3D")){ - status = m->readP3D(name); + status = model->readP3D(name); } else if(!strcmp(ext, ".fm") || !strcmp(ext, ".FM")) { - status = m->readFourier(name); + status = model->readFourier(name); } #if defined(HAVE_FLTK) else if(!strcmp(ext, ".pnm") || !strcmp(ext, ".PNM") || @@ -362,7 +360,7 @@ int MergeFile(const char *name, int warn_if_missing) if(!strncmp(header, "$PTS", 4) || !strncmp(header, "$NO", 3) || !strncmp(header, "$PARA", 5) || !strncmp(header, "$ELM", 4) || !strncmp(header, "$MeshFormat", 11)) { - status = m->readMSH(name); + status = model->readMSH(name); #if !defined(HAVE_NO_POST) if(status > 1) status = PView::readMSH(name); #endif @@ -374,7 +372,7 @@ int MergeFile(const char *name, int warn_if_missing) } #endif else { - status = m->readGEO(name); + status = model->readGEO(name); } } diff --git a/Common/Options.cpp b/Common/Options.cpp index 9eb6148a1f764df2c0403099e4b1fdca1a640a8b..069c909f1e7dcd239e17b6a62fa8cad67fdb42e3 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -457,7 +457,6 @@ void Init_Options(int num) // The following defaults cannot be set by the user CTX.batch = 0; - CTX.batchAfterMesh = 0; CTX.output_filename = NULL; CTX.bgm_filename = NULL; CTX.lc = 1.0; diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp index 1aa0c160b5f3d5c15c0fb6f6020f1faca001feb1..4bfbd7647877515295dfde5190ba9efdb854836b 100644 --- a/Fltk/Main.cpp +++ b/Fltk/Main.cpp @@ -101,8 +101,13 @@ int main(int argc, char *argv[]) // Open project file and merge all other input files OpenProject(CTX.filename); - for(unsigned int i = 1; i < CTX.files.size(); i++) - MergeFile(CTX.files[i].c_str()); + for(unsigned int i = 1; i < CTX.files.size(); i++){ + if(CTX.files[i] == "-new") + new GModel; + else + MergeFile(CTX.files[i].c_str()); + } + if(CTX.post.combine_time){ PView::combine(true, 2, CTX.post.combine_remove_orig); WID->update_views(); diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index f20b610a095b8b809b82de1ae22aa3f9aaa6ec1f..e5146f327b768b0925b9ae97c924b0fca87177a4 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -1,6 +1,12 @@ +// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to <gmsh@geuz.org>. + #include "GFaceCompound.h" #include "gmshAssembler.h" #include "gmshLaplace.h" +#include "Numeric.h" #include "Octree.h" #include "gmshLinearSystemGmm.h" diff --git a/Geo/GFaceCompound.h b/Geo/GFaceCompound.h index 085c2577564f4924fd5a1427ef0584739394b19c..7bc2698bb7b165d5e752e1d3b92829a20c95b876 100644 --- a/Geo/GFaceCompound.h +++ b/Geo/GFaceCompound.h @@ -3,11 +3,11 @@ // See the LICENSE.txt file for license information. Please report all // bugs and problems to <gmsh@geuz.org>. -#ifndef _G_FACECOMPOUND_H_ -#define _G_FACECOMPOUND_H_ +#ifndef _GFACE_COMPOUND_H_ +#define _GFACE_COMPOUND_H_ -#include "Geo.h" #include "GFace.h" +#include "GEdge.h" /* A GFaceCompound is a model face that is the compound of model faces. @@ -23,12 +23,9 @@ consist in a triangulation in the (u,v) space with parameter values at nodes. The compound can therefore be re-meshed using any surface mesh -generator of gmsh ! +generator of gmsh! */ -#include "GFace.h" -#include "GEdge.h" - typedef struct { SPoint2 p1, p2, p3; MTriangle *t; @@ -55,7 +52,7 @@ class GFaceCompound : public GFace { } void getBoundingEdges(); void getTriangle(double u, double v, MTriangle **t, double &_u, double &_v) const; -public: + public: GFaceCompound(GModel *m, int tag, std::list<GFace*> &compound, std::list<GEdge*> &U0, @@ -69,7 +66,7 @@ public: virtual GEntity::GeomType geomType() const { return CompoundSurface; } ModelType getNativeType() const { return GmshModel; } void * getNativePtr() const { return 0; } - SPoint2 getCoordinates (MVertex *v) const { parametrize() ; return coordinates[v]; } + SPoint2 getCoordinates(MVertex *v) const { parametrize() ; return coordinates[v]; } virtual bool buildRepresentationCross(){ return false; } }; diff --git a/Geo/Makefile b/Geo/Makefile index 458ee2ad9deb5c7c1a3998f97629d0a3c3d3aae7..50c036696421ee73690e47399605abe8c59bd989 100644 --- a/Geo/Makefile +++ b/Geo/Makefile @@ -96,21 +96,19 @@ GFace.o: GFace.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \ ../Common/VertexArray.h ../Geo/SVector3.h ../Numeric/Numeric.h \ ../Numeric/NumericEmbedded.h ../Numeric/GaussLegendre1D.h \ ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -GFaceCompound.o: GFaceCompound.cpp GFaceCompound.h Geo.h \ - ../Common/GmshDefines.h gmshSurface.h Pair.h Range.h SPoint2.h \ - SPoint3.h SVector3.h SBoundingBox3d.h ../Numeric/Numeric.h \ - ../Numeric/NumericEmbedded.h ../Common/ListUtils.h \ - ../Common/TreeUtils.h ../Common/avl.h ../Common/ListUtils.h \ - ExtrudeParams.h ../Common/SmoothData.h GFace.h GEntity.h GPoint.h \ - GEdgeLoop.h GEdge.h GVertex.h ../Numeric/gmshAssembler.h \ +GFaceCompound.o: GFaceCompound.cpp GFaceCompound.h GFace.h GEntity.h \ + Range.h SPoint3.h SBoundingBox3d.h GPoint.h GEdgeLoop.h GEdge.h \ + GVertex.h SPoint2.h SVector3.h Pair.h ../Numeric/gmshAssembler.h \ ../Numeric/gmshLinearSystem.h ../Numeric/gmshLaplace.h \ ../Numeric/gmshTermOfFormulation.h ../Common/GmshMatrix.h \ ../Common/Gmsh.h ../Common/GmshMessage.h ../Geo/GModel.h \ ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h \ ../Geo/GEntity.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \ - ../Geo/MElement.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MEdge.h \ - ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \ - ../Geo/SVector3.h ../Numeric/FunctionSpace.h ../Common/Octree.h \ + ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \ + ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \ + ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \ + ../Numeric/FunctionSpace.h ../Numeric/Numeric.h \ + ../Numeric/NumericEmbedded.h ../Common/Octree.h \ ../Common/OctreeInternals.h ../Numeric/gmshLinearSystemGmm.h \ ../Numeric/gmshLinearSystem.h GRegion.o: GRegion.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \ @@ -128,11 +126,11 @@ gmshVertex.o: gmshVertex.cpp GFace.h GEntity.h Range.h SPoint3.h \ MFace.h ../Numeric/FunctionSpace.h ../Common/GmshMatrix.h gmshEdge.o: gmshEdge.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \ SBoundingBox3d.h GPoint.h SPoint2.h GEdge.h SVector3.h GFace.h \ - GEdgeLoop.h Pair.h GRegion.h GFaceCompound.h Geo.h \ + GEdgeLoop.h Pair.h GRegion.h GFaceCompound.h gmshEdge.h Geo.h \ ../Common/GmshDefines.h gmshSurface.h ../Numeric/Numeric.h \ ../Numeric/NumericEmbedded.h ../Common/ListUtils.h \ ../Common/TreeUtils.h ../Common/avl.h ../Common/ListUtils.h \ - ExtrudeParams.h ../Common/SmoothData.h gmshEdge.h GeoInterpolation.h \ + ExtrudeParams.h ../Common/SmoothData.h GeoInterpolation.h \ ../Common/GmshMessage.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h gmshFace.o: gmshFace.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \ @@ -289,11 +287,8 @@ findLinks.o: findLinks.cpp ../Common/GmshMessage.h GModel.h GVertex.h \ ../Common/avl.h ../Common/ListUtils.h MVertex.o: MVertex.cpp MVertex.h SPoint3.h GEdge.h GEntity.h Range.h \ SBoundingBox3d.h GVertex.h GPoint.h SPoint2.h SVector3.h GFace.h \ - GEdgeLoop.h Pair.h GFaceCompound.h Geo.h ../Common/GmshDefines.h \ - gmshSurface.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \ - ../Common/ListUtils.h ../Common/TreeUtils.h ../Common/avl.h \ - ../Common/ListUtils.h ExtrudeParams.h ../Common/SmoothData.h \ - ../Common/GmshMessage.h ../Common/StringUtils.h + GEdgeLoop.h Pair.h GFaceCompound.h ../Common/GmshMessage.h \ + ../Common/StringUtils.h GaussQuadratureTri.o: GaussQuadratureTri.cpp MElement.h \ ../Common/GmshDefines.h MVertex.h SPoint3.h MEdge.h SVector3.h MFace.h \ ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \ diff --git a/Mesh/Makefile b/Mesh/Makefile index d9f70a0055c5873859f60433707df9a88135b898..62b220946e8ac9daa75cd51971e822614536fec4 100644 --- a/Mesh/Makefile +++ b/Mesh/Makefile @@ -421,11 +421,6 @@ HighOrder.o: HighOrder.cpp HighOrder.h ../Geo/GModel.h ../Geo/GVertex.h \ meshGFaceOptimize.h meshGFaceDelaunayInsertion.h ../Common/OS.h \ ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Context.h \ ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Geo/GFaceCompound.h \ - ../Geo/Geo.h ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h \ - ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \ - ../Geo/SBoundingBox3d.h ../Common/ListUtils.h ../Common/TreeUtils.h \ - ../Common/avl.h ../Common/ListUtils.h ../Geo/SPoint2.h \ - ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Geo/GFace.h \ ../Geo/GFace.h ../Geo/GEdge.h Partition.o: Partition.cpp ../Geo/GModel.h ../Geo/GVertex.h \ ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \