From 8484b79fa8595c2be261e5f645e51b6384203598 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 2 Apr 2008 20:00:38 +0000
Subject: [PATCH] pp

---
 Geo/GModelIO_MED.cpp       |  4 +--
 Post/PViewData.h           |  6 ++---
 Post/PViewDataGModelIO.cpp | 55 +++++++++-----------------------------
 Post/PViewDataIO.cpp       | 20 +++++++++++++-
 4 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/Geo/GModelIO_MED.cpp b/Geo/GModelIO_MED.cpp
index 32fd8fc89e..120139515a 100644
--- a/Geo/GModelIO_MED.cpp
+++ b/Geo/GModelIO_MED.cpp
@@ -1,4 +1,4 @@
-// $Id: GModelIO_MED.cpp,v 1.24 2008-04-02 18:57:57 geuzaine Exp $
+// $Id: GModelIO_MED.cpp,v 1.25 2008-04-02 20:00:38 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -37,7 +37,7 @@ extern "C" {
 #include <med.h>
 }
 
-static med_geometrie_element msh2medElementType(int msh)
+med_geometrie_element msh2medElementType(int msh)
 {
   switch(msh) {
   case MSH_LIN_2: return MED_SEG2;
diff --git a/Post/PViewData.h b/Post/PViewData.h
index 15f9448135..982802bd8c 100644
--- a/Post/PViewData.h
+++ b/Post/PViewData.h
@@ -118,9 +118,9 @@ class PViewData {
   virtual bool writeSTL(std::string fileName);
   virtual bool writeTXT(std::string fileName);
   virtual bool writePOS(std::string fileName, bool binary=false, bool parsed=true,
-                        bool append=false){ return false; }
-  virtual bool writeMSH(std::string fileName, bool binary=false){ return false; }
-  virtual bool writeMED(std::string fileName){ return false; }
+                        bool append=false);
+  virtual bool writeMSH(std::string fileName, bool binary=false);
+  virtual bool writeMED(std::string fileName);
 };
 
 class nameData{
diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp
index 47ea33603a..a74fdf24b7 100644
--- a/Post/PViewDataGModelIO.cpp
+++ b/Post/PViewDataGModelIO.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataGModelIO.cpp,v 1.35 2008-04-02 18:57:57 geuzaine Exp $
+// $Id: PViewDataGModelIO.cpp,v 1.36 2008-04-02 20:00:38 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -147,6 +147,7 @@ extern "C" {
 #include <med.h>
 }
 
+extern med_geometrie_element msh2medElementType(int msh);
 extern int med2mshElementType(med_geometrie_element med);
 extern int med2mshNodeIndex(med_geometrie_element med, int k);
 
@@ -408,48 +409,20 @@ bool PViewDataGModel::writeMED(std::string fileName)
   }
 
   // compute profile
-  char *profileName;
-  std::vector<med_int> profile, indices, mult;
-  if(_type == NodeData){
-    profileName = (char*)"nodeProfile";
-    for(int i = 0; i < _steps[0]->getNumData(); i++){
-      if(_steps[0]->getData(i)){
-	MVertex *v = _steps[0]->getModel()->getMeshVertexByTag(i);
-	if(!v){
-	  Msg(GERROR, "Unknown vertex %d in data", i);
-	  return false;
-	}
-	profile.push_back(v->getIndex());
-	indices.push_back(i);
-	mult.push_back(1);
-      }
-    }
-  }
-  else{
-    // FIXME: not tested
-    profileName = (char*)"elementProfile";
-    std::vector<MElement*> elements;
-    int offset = model->getNumVertices();
-    for(int i = 0; i < _steps[0]->getNumEntities(); i++)
-      for(int j = 0; j < _steps[0]->getEntity(i)->getNumMeshElements(); j++)
-	elements.push_back(_steps[0]->getEntity(i)->getMeshElement(j));
-    for(int i = 0; i < _steps[0]->getNumData(); i++){
-      if(_steps[0]->getData(i)){
-	int idx = i - offset;
-	if(idx < 0 || idx >= elements.size()){
-	  Msg(GERROR, "Unknown element %d in data", idx);
-	  return false;
-	}
-	MElement *e = elements[idx];
-	profile.push_back(idx);
-	indices.push_back(i);
-	if(_type == GaussPointData)
-	  mult.push_back(_steps[0]->getGaussPoints(e->getTypeForMSH()).size() / 3);
-	else
-	  mult.push_back(e->getNumVertices());
+  char *profileName = (char*)"nodeProfile";
+  std::vector<med_int> profile, indices;
+  for(int i = 0; i < _steps[0]->getNumData(); i++){
+    if(_steps[0]->getData(i)){
+      MVertex *v = _steps[0]->getModel()->getMeshVertexByTag(i);
+      if(!v){
+	Msg(GERROR, "Unknown vertex %d in data", i);
+	return false;
       }
+      profile.push_back(v->getIndex());
+      indices.push_back(i);
     }
   }
+
   if(profile.empty()){
     Msg(GERROR, "Nothing to save");
     return false;
@@ -467,14 +440,12 @@ bool PViewDataGModel::writeMED(std::string fileName)
     return false;
   }
 
-  // FIXME: generalize following for all _types
   med_int numNodes = MEDnEntMaa(fid, meshName, MED_COOR, MED_NOEUD, 
 				MED_NONE, (med_connectivite)0);
   if(numNodes <= 0){
     Msg(GERROR, "Could not get valid number of nodes in mesh");
     return false;
   }
-
   for(unsigned int step = 0; step < _steps.size(); step++){
     unsigned int n = 0;
     for(int i = 0; i < _steps[step]->getNumData(); i++)
diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp
index 5cd5b9a347..d29ce6d6fa 100644
--- a/Post/PViewDataIO.cpp
+++ b/Post/PViewDataIO.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataIO.cpp,v 1.7 2008-03-29 10:19:43 geuzaine Exp $
+// $Id: PViewDataIO.cpp,v 1.8 2008-04-02 20:00:38 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -116,3 +116,21 @@ bool PViewData::writeTXT(std::string fileName)
   fclose(fp);
   return true;
 }
+
+bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool append)
+{ 
+  Msg(GERROR, "POS export not implemented for this view type");
+  return false; 
+}
+
+bool PViewData::writeMSH(std::string fileName, bool binary)
+{ 
+  Msg(GERROR, "MSH export not implemented for this view type");
+  return false; 
+}
+
+bool PViewData::writeMED(std::string fileName)
+{
+  Msg(GERROR, "MED export not implemented for this view type");
+  return false; 
+}
-- 
GitLab