if ( error ) {
_error = error->myName;
_comment = error->myComment;
+ _badInputElements = error->myBadElements;
return error->IsOK();
}
return true;
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;
}
//================================================================================
{
_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 );
+}
* \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:
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
#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;
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)
};
-#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 "";