diff --git a/Geo/GModelIO_MED.cpp b/Geo/GModelIO_MED.cpp index a4a89c81a6b84f96d9e5e01d8405dd5e166eef81..263c483d4510585e5a8cdf82d3a47aeaba445e77 100644 --- a/Geo/GModelIO_MED.cpp +++ b/Geo/GModelIO_MED.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_MED.cpp,v 1.16 2008-03-24 21:39:47 geuzaine Exp $ +// $Id: GModelIO_MED.cpp,v 1.17 2008-03-25 20:48:32 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -274,7 +274,7 @@ int GModel::readMED(const std::string &name) return 0; } if(numMeshes > 1) - Msg(WARNING, "Reading mesh 1 of %d (ignoring the other)", numMeshes); + Msg(WARNING, "Reading mesh 1 of %d (ignoring the others)", numMeshes); // read mesh info char meshName[MED_TAILLE_NOM + 1], meshDesc[MED_TAILLE_DESC + 1]; diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index 296373508b725d59b03c26e0d7b7384a2ab61ea9..f14d2bb905553105f9720feaedeb84d61571b02c 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_Mesh.cpp,v 1.46 2008-03-23 21:42:57 geuzaine Exp $ +// $Id: GModelIO_Mesh.cpp,v 1.47 2008-03-25 20:48:32 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -160,7 +160,7 @@ static void createElementMSH(GModel *m, int num, int type, int physical, std::map<int, std::map<int, std::string> > physicals[4]) { int dim; - if(type == MSH_POINT){ + if(type == MSH_PNT){ dim = 0; points[reg].push_back(v[0]); } diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp index 2dd1b461f864ab7f69e25e39126a8bf746e0a3ff..743b63907c46d4539450b7997a3421f325ab52e3 100644 --- a/Post/OctreePost.cpp +++ b/Post/OctreePost.cpp @@ -1,4 +1,4 @@ -// $Id: OctreePost.cpp,v 1.7 2008-03-20 11:44:15 geuzaine Exp $ +// $Id: OctreePost.cpp,v 1.8 2008-03-25 20:48:32 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -368,9 +368,11 @@ OctreePost::OctreePost(PView *v) // that we can reuse it multiple times _GModel = Octree_Create(maxElePerBucket, min, size, MElementBB, MElementCentroid, MElementInEle); - for(int i = 0; i < _theViewDataGModel->getNumEntities(0); i++) - for(int j = 0; j < _theViewDataGModel->getEntity(0, i)->getNumMeshElements(); j++) - Octree_Insert(_theViewDataGModel->getEntity(0, i)->getMeshElement(j), _GModel); + for(int i = 0; i < _theViewDataGModel->getNumEntities(0); i++){ + GEntity *ge = _theViewDataGModel->getEntity(0, i); + for(unsigned int j = 0; j < ge->getNumMeshElements(); j++) + Octree_Insert(ge->getMeshElement(j), _GModel); + } Octree_Arrange(_GModel); } } diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 46fac88d7832eb9218da9eaed53d6eaa91332a65..adf6ed9f3f1615d2fa1e548779b48b1b0ba00357 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -39,7 +39,7 @@ class stepData{ GModel *_model; // the unrolled list of all geometrical entities in the model std::vector<GEntity*> _entities; - // the bounding box of the view (= model bbox for now) + // the bounding box of the view SBoundingBox3d _bbox; // the type of the dataset DataType _type; @@ -49,8 +49,8 @@ class stepData{ int _fileIndex; // the value of the time step and value min/max double _time, _min, _max; - // the number of components in the data (stepData only contain a - // single field type!) + // the number of components in the data (one stepData contains only + // a single field type) int _numComp; // the values, indexed by dataIndex in MVertex or MElement std::vector<real*> *_data; @@ -163,6 +163,7 @@ class PViewDataGModel : public PViewData { bool swap, int step, double time, int partition, int numComp, int numNodes); bool writeMSH(std::string name, bool binary=false); + bool writeMED(std::string name); }; #endif diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index 4fa6c93763f6e2c172ee05cfc065cd9201976f9c..13bb04c2e782b1f1b5b963cf36b20d630e84d413 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataGModelIO.cpp,v 1.12 2008-03-21 18:27:39 geuzaine Exp $ +// $Id: PViewDataGModelIO.cpp,v 1.13 2008-03-25 20:48:32 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -105,8 +105,7 @@ bool PViewDataGModel::writeMSH(std::string name, bool binary) binary = true; - bool saveAll = true; - if(!model->writeMSH(name, 2.0, binary, saveAll)) return false; + if(!model->writeMSH(name, 2.0, binary, true)) return false; // append data FILE *fp = fopen(name.c_str(), binary ? "ab" : "a"); @@ -155,3 +154,60 @@ bool PViewDataGModel::writeMSH(std::string name, bool binary) fclose(fp); return true; } + +bool PViewDataGModel::writeMED(std::string name) +{ + if(_steps.empty()) return true; + + if(hasMultipleMeshes()){ + Msg(GERROR, "Export not done for multi-mesh views"); + return false; + } + + GModel *model = _steps[0]->getModel(); + + // if(!model->writeMSH(name, 2.0, binary, true)) return false; + + // append data + FILE *fp = fopen(name.c_str(), "ab"); + if(!fp){ + Msg(GERROR, "Unable to open file '%s'", name.c_str()); + return false; + } + + // map data index to vertex tags + std::vector<int> tags(model->getMaxVertexDataIndex() + 1, 0); + for(int i = 0; i < _steps[0]->getNumEntities(); i++){ + for(unsigned int j = 0; j < _steps[0]->getEntity(i)->mesh_vertices.size(); j++){ + MVertex *v = _steps[0]->getEntity(i)->mesh_vertices[j]; + if(v->getDataIndex() >= 0) tags[v->getDataIndex()] = v->getNum(); + } + } + + for(unsigned int step = 0; step < _steps.size(); step++){ + int numNodes = 0, numComp = _steps[step]->getNumComp(); + for(int i = 0; i < _steps[step]->getNumData(); i++) + if(_steps[step]->getData(i)) numNodes++; + + if(numNodes){ + /* + fprintf(fp, "$NodeData\n"); + fprintf(fp, "\"%s\"\n", getName().c_str()); + fprintf(fp, "%d %.16g 0 0 %d %d\n", step, _steps[step]->getTime(), + numComp, numNodes); + for(int i = 0; i < _steps[step]->getNumData(); i++){ + if(_steps[step]->getData(i)){ + fprintf(fp, "%d", tags[i]); + for(int k = 0; k < numComp; k++) + fprintf(fp, " %.16g", _steps[step]->getData(i)[k]); + fprintf(fp, "\n"); + } + } + fprintf(fp, "$EndNodeData\n"); + */ + } + } + + fclose(fp); + return true; +}