021382: EDF 1985 SMESH: Read/write of .mesh files (GMF format)

+  virtual void        SetOption(const std::string& optionName,
+                                const std::string& optionValue) {}
+  virtual SMESH_ComputeErrorPtr GetError();
This commit is contained in:
eap 2012-09-24 11:13:16 +00:00
parent 673b8a1d41
commit 553185b191
2 changed files with 37 additions and 7 deletions

View File

@ -26,13 +26,16 @@
// //
#include "Driver_Mesh.h" #include "Driver_Mesh.h"
#include "SMESH_Comment.hxx"
#include <utilities.h> #include <utilities.h>
using namespace std; using namespace std;
Driver_Mesh::Driver_Mesh(): Driver_Mesh::Driver_Mesh():
myFile(""), myFile(""),
myMeshId(-1) myMeshId(-1),
myStatus( DRS_OK )
{} {}
@ -78,5 +81,23 @@ Driver_Mesh::Status Driver_Mesh::addMessage(const std::string& msg,
#ifdef _DEBUG_ #ifdef _DEBUG_
cout << msg << endl; cout << msg << endl;
#endif #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 );
} }

View File

@ -27,6 +27,8 @@
#ifndef _INCLUDE_DRIVER_MESH #ifndef _INCLUDE_DRIVER_MESH
#define _INCLUDE_DRIVER_MESH #define _INCLUDE_DRIVER_MESH
#include "SMESH_ComputeError.hxx"
#include <string> #include <string>
#include <vector> #include <vector>
@ -55,19 +57,26 @@ class MESHDRIVER_EXPORT Driver_Mesh
DRS_FAIL // general failure (exception etc.) DRS_FAIL // general failure (exception etc.)
}; };
virtual Status Perform() = 0; void SetMeshId(int theMeshId);
void SetMeshId(int theMeshId); void SetFile(const std::string& theFileName);
void SetFile(const std::string& theFileName); virtual void SetMeshName(const std::string& theMeshName);
virtual void SetMeshName(const std::string& theMeshName);
virtual std::string GetMeshName() const; 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: protected:
std::string myFile; std::string myFile;
std::string myMeshName; std::string myMeshName;
int myMeshId; int myMeshId;
Status addMessage(const std::string& msg, const bool isFatal=false); Status addMessage(const std::string& msg, const bool isFatal=false);
std::vector< std::string > myErrorMessages; std::vector< std::string > myErrorMessages;
Status myStatus;
}; };
#endif #endif