Salome HOME
[SALOME platform 0019316]: Need to have a better interface with GHS3D diagnostics
authoreap <eap@opencascade.com>
Mon, 21 Jul 2008 09:41:11 +0000 (09:41 +0000)
committereap <eap@opencascade.com>
Mon, 21 Jul 2008 09:41:11 +0000 (09:41 +0000)
    store bad input elements and nodes

src/SMESH/SMESH_Algo.cxx
src/SMESH/SMESH_Algo.hxx
src/SMESH/SMESH_ComputeError.hxx

index 47346f2da3471a0d5ec93874461d9c3ae926a1ef..fea326576b4b993c166e8ae40abc8ff566a80d8b 100644 (file)
@@ -502,6 +502,7 @@ bool SMESH_Algo::error(SMESH_ComputeErrorPtr error)
   if ( error ) {
     _error   = error->myName;
     _comment = error->myComment;
+    _badInputElements = error->myBadElements;
     return error->IsOK();
   }
   return true;
@@ -515,7 +516,11 @@ bool SMESH_Algo::error(SMESH_ComputeErrorPtr error)
 
 SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const
 {
-  return SMESH_ComputeError::New( _error, _comment, this );
+  SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( _error, _comment, this );
+  // hope this method is called by only SMESH_subMesh after this->Compute()
+  err->myBadElements.splice( err->myBadElements.end(),
+                             (list<const SMDS_MeshElement*>&) _badInputElements );
+  return err;
 }
 
 //================================================================================
@@ -528,5 +533,23 @@ void SMESH_Algo::InitComputeError()
 {
   _error = COMPERR_OK;
   _comment.clear();
+  list<const SMDS_MeshElement*>::iterator elem = _badInputElements.begin();
+  for ( ; elem != _badInputElements.end(); ++elem )
+    if ( (*elem)->GetID() < 1 )
+      delete *elem;
+  _badInputElements.clear();
 }
 
+//================================================================================
+/*!
+ * \brief store a bad input element preventing computation,
+ *        which may be a temporary one i.e. not residing the mesh,
+ *        then it will be deleted by InitComputeError()
+ */
+//================================================================================
+
+void SMESH_Algo::addBadInputElement(const SMDS_MeshElement* elem)
+{
+  if ( elem )
+    _badInputElements.push_back( elem );
+}
index f08fd85e74432d4640b402d3f6469e9d938109c8..1a47fa29122704bc399de66459c581f45bf7faa5 100644 (file)
@@ -293,6 +293,12 @@ protected:
    * \brief store error and return error->IsOK()
    */
   bool error(SMESH_ComputeErrorPtr error);
+  /*!
+   * \brief store a bad input element preventing computation,
+   *        which may be a temporary one i.e. not residing the mesh,
+   *        then it will be deleted by InitComputeError()
+   */
+  void addBadInputElement(const SMDS_MeshElement* elem);
 
 protected:
 
@@ -310,6 +316,7 @@ protected:
 
   int         _error;    //!< SMESH_ComputeErrorName or anything algo specific
   std::string _comment;  //!< any text explaining what is wrong in Compute()
+  std::list<const SMDS_MeshElement*> _badInputElements; //!< to explain COMPERR_BAD_INPUT_MESH
 };
 
 #endif
index 91f2712c2f3990aca4e44895f77c5908d6c8943c..07c6116b1608331943389ceef20ed5be590e2a38 100644 (file)
 #define SMESH_ComputeError_HeaderFile
 
 #include <string>
+#include <list>
 #include <boost/shared_ptr.hpp>
 
 class SMESH_Algo;
+class SMDS_MeshElement;
 struct SMESH_ComputeError;
 
 typedef boost::shared_ptr<SMESH_ComputeError> SMESH_ComputeErrorPtr;
@@ -66,6 +68,8 @@ struct SMESH_ComputeError
   std::string       myComment;
   const SMESH_Algo* myAlgo;
 
+  std::list<const SMDS_MeshElement*> myBadElements; //!< to explain COMPERR_BAD_INPUT_MESH
+
   static SMESH_ComputeErrorPtr New( int               error   = COMPERR_OK,
                                     std::string       comment = "",
                                     const SMESH_Algo* algo    = 0)
@@ -82,19 +86,19 @@ struct SMESH_ComputeError
 
 };
 
-#define case2char(err) case err: return #err;
+#define _case2char(err) case err: return #err;
 
 std::string SMESH_ComputeError::CommonName() const
 {
   switch( myName ) {
-  case2char(COMPERR_OK            );
-  case2char(COMPERR_BAD_INPUT_MESH);
-  case2char(COMPERR_STD_EXCEPTION );
-  case2char(COMPERR_OCC_EXCEPTION );
-  case2char(COMPERR_SLM_EXCEPTION );
-  case2char(COMPERR_EXCEPTION     );
-  case2char(COMPERR_MEMORY_PB     );
-  case2char(COMPERR_ALGO_FAILED   );
+  _case2char(COMPERR_OK            );
+  _case2char(COMPERR_BAD_INPUT_MESH);
+  _case2char(COMPERR_STD_EXCEPTION );
+  _case2char(COMPERR_OCC_EXCEPTION );
+  _case2char(COMPERR_SLM_EXCEPTION );
+  _case2char(COMPERR_EXCEPTION     );
+  _case2char(COMPERR_MEMORY_PB     );
+  _case2char(COMPERR_ALGO_FAILED   );
   default:;
   }
   return "";