From b820ae470cf07c27f16b9dd2acdc168a16c38d30 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 5 Oct 2010 10:01:12 +0000 Subject: [PATCH] don't save node/element data by default --- Geo/GModel.h | 3 --- Geo/MElement.h | 5 +++-- Geo/MVertex.cpp | 2 +- Geo/MVertex.h | 5 ++--- Post/PViewDataGModelIO.cpp | 32 +++++++++++++++++++++++++------- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Geo/GModel.h b/Geo/GModel.h index 1b491bfd78..2b376b838b 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -353,9 +353,6 @@ class GModel void createTopologyFromMesh(); void createTopologyFromFaces(std::vector<discreteFace*> &pFaces); - // compute distance function - void computeDistanceFunction(); - // a container for smooth normals smooth_normals *normals; diff --git a/Geo/MElement.h b/Geo/MElement.h index 0d5ac4bc74..da25f024db 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -88,7 +88,8 @@ class MElement // get the vertex using the VTK ordering virtual MVertex *getVertexVTK(int num){ return getVertex(num); } -// get the vertex using the Nastran BDF ordering + + // get the vertex using the Nastran BDF ordering virtual MVertex *getVertexBDF(int num){ return getVertex(num); } // get the vertex using MED ordering @@ -164,7 +165,7 @@ class MElement virtual MElement *getDomain(int i) const { return NULL; } virtual void setDomain (MElement *e, int i) { } - //get the type of the element + // get the type of the element virtual int getType() const = 0; // get the max/min edge length diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index bfdedec319..3d1e5a4611 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -429,7 +429,7 @@ void MVertex::registerBindings(binding *b) cm->setDescription("return the invariant vertex id"); cm = cb->addMethod("getPolynomialOrder", &MVertex::getPolynomialOrder); cm->setDescription("return the polynomial order of vertex"); - cm = cb->addMethod("setPolynomialOrder", &MVertex::setPolynomialOrder_binding); + cm = cb->addMethod("setPolynomialOrder", &MVertex::setPolynomialOrder); cm->setDescription("assign the polynomial order of vertex"); cm->setArgNames("order",NULL); } diff --git a/Geo/MVertex.h b/Geo/MVertex.h index a568d7aa7e..0921285f94 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -58,8 +58,7 @@ class MVertex{ // get the "polynomial order" of the vertex inline int getPolynomialOrder(){ return _order; } - inline void setPolynomialOrder(char order){ _order = order; } - inline void setPolynomialOrder_binding(int order){ _order = order; } + inline void setPolynomialOrder(int order){ _order = (char)order; } // get/set the coordinates inline double x() const { return _x; } @@ -69,7 +68,7 @@ class MVertex{ inline double & y() { return _y; } inline double & z() { return _z; } // cannot use the reference to set the value in the bindings - inline void setXYZ(double x,double y, double z) {_x=x; _y=y; _z=z; } + inline void setXYZ(double x, double y, double z) { _x = x; _y = y; _z = z; } inline SPoint3 point() const { return SPoint3(_x, _y, _z); } diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index 51119e9493..9e8526776e 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -129,13 +129,31 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary) GModel *model = _steps[0]->getModel(); - if(!model->writeMSH(fileName, 2.0, binary)) return false; - - // append data - FILE *fp = fopen(fileName.c_str(), binary ? "ab" : "a"); - if(!fp){ - Msg::Error("Unable to open file '%s'", fileName.c_str()); - return false; + bool writeNodesAndElements = false; + FILE *fp; + if(writeNodesAndElements){ + if(!model->writeMSH(fileName, 2.0, binary)) return false; + // append data + fp = fopen(fileName.c_str(), binary ? "ab" : "a"); + if(!fp){ + Msg::Error("Unable to open file '%s'", fileName.c_str()); + return false; + } + } + else{ + fp = fopen(fileName.c_str(), binary ? "wb" : "w"); + if(!fp){ + Msg::Error("Unable to open file '%s'", fileName.c_str()); + return false; + } + fprintf(fp, "$MeshFormat\n"); + fprintf(fp, "%g %d %d\n", 2.2, binary ? 1 : 0, (int)sizeof(double)); + if(binary){ + int one = 1; + fwrite(&one, sizeof(int), 1, fp); + fprintf(fp, "\n"); + } + fprintf(fp, "$EndMeshFormat\n"); } for(unsigned int step = 0; step < _steps.size(); step++){ -- GitLab