Salome HOME
021382: EDF 1985 SMESH: Read/write of .mesh files (GMF format)
authoreap <eap@opencascade.com>
Mon, 24 Sep 2012 11:13:16 +0000 (11:13 +0000)
committereap <eap@opencascade.com>
Mon, 24 Sep 2012 11:13:16 +0000 (11:13 +0000)
+  virtual void        SetOption(const std::string& optionName,
+                                const std::string& optionValue) {}
+  virtual SMESH_ComputeErrorPtr GetError();

src/Driver/Driver_Mesh.cxx
src/Driver/Driver_Mesh.h

index 73895176fe7faa33672b36a5a1c9221a762de713..c04008f9477f5ea7053e4655182fa2cc972f1107 100644 (file)
 //
 #include "Driver_Mesh.h"
 
+#include "SMESH_Comment.hxx"
+
 #include <utilities.h>
 
 using namespace std;
 
 Driver_Mesh::Driver_Mesh():
   myFile(""),
-  myMeshId(-1)
+  myMeshId(-1),
+  myStatus( DRS_OK )
 {}
 
 
@@ -78,5 +81,23 @@ Driver_Mesh::Status Driver_Mesh::addMessage(const std::string& msg,
 #ifdef _DEBUG_
   cout << msg << endl;
 #endif
-  return isFatal ? DRS_FAIL : DRS_WARN_SKIP_ELEM;
+  return ( myStatus = isFatal ? DRS_FAIL : DRS_WARN_SKIP_ELEM );
+}
+
+//================================================================================
+/*!
+ * \brief Return a structure containing description of errors
+ */
+//================================================================================
+
+SMESH_ComputeErrorPtr Driver_Mesh::GetError()
+{
+  SMESH_Comment msg;
+  for ( size_t i = 0; i < myErrorMessages.size(); ++i )
+  {
+    msg << myErrorMessages[i];
+    if ( i+1 < myErrorMessages.size() )
+      msg << "\n";
+  }
+  return SMESH_ComputeError::New( myStatus == DRS_OK ? int(COMPERR_OK) : int(myStatus), msg );
 }
index 45861a82a784b15b22d4467fb4f373721894d346..fcaea2b3e6f0e54c4206aa30ee91d9a82ad918bb 100644 (file)
@@ -27,6 +27,8 @@
 #ifndef _INCLUDE_DRIVER_MESH
 #define _INCLUDE_DRIVER_MESH
 
+#include "SMESH_ComputeError.hxx"
+
 #include <string>
 #include <vector>
 
@@ -55,19 +57,26 @@ class MESHDRIVER_EXPORT Driver_Mesh
     DRS_FAIL            // general failure (exception etc.)
   };
 
-  virtual Status Perform() = 0;
-  void SetMeshId(int theMeshId);
-  void SetFile(const std::string& theFileName);
-  virtual void SetMeshName(const std::string& theMeshName);
+  void                SetMeshId(int theMeshId);
+  void                SetFile(const std::string& theFileName);
+  virtual void        SetMeshName(const std::string& theMeshName);
   virtual std::string GetMeshName() const;
 
+  virtual void        SetOption(const std::string& optionName,
+                                const std::string& optionValue) {}
+
+  virtual Status Perform() = 0;
+
+  virtual SMESH_ComputeErrorPtr GetError();
+
  protected:
   std::string myFile;
   std::string myMeshName;
-  int myMeshId;
+  int         myMeshId;
 
   Status addMessage(const std::string& msg, const bool isFatal=false);
   std::vector< std::string > myErrorMessages;
+  Status                     myStatus;
 };
 
 #endif