Salome HOME
PAL14921 (memory limitation and Salome freeze)
[modules/smesh.git] / src / SMESH / SMESH_Algo.hxx
index 675264e36cd74cc2e4544b354480a00ea7c7a8aa..d2cde332ee7f5358b14b5b08e86c99fbaa40ace2 100644 (file)
 #define _SMESH_ALGO_HXX_
 
 #include "SMESH_Hypothesis.hxx"
+#include "SMESH_ComputeError.hxx"
+#include "SMESH_Comment.hxx"
 
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Edge.hxx>
-#include <gp_XY.hxx>
 #include <GeomAbs_Shape.hxx>
 
 #include <string>
 #include <vector>
 #include <list>
-#include <map>
 
 class SMESH_Gen;
 class SMESH_Mesh;
@@ -52,6 +52,7 @@ class SMDS_MeshNode;
 class SMESH_subMesh;
 class SMESH_MesherHelper;
 
+
 class SMESH_Algo:public SMESH_Hypothesis
 {
 public:
@@ -102,6 +103,10 @@ public:
     * \param aMesh - the mesh
     * \param aShape - the shape
     * \retval bool - is a success
+    *
+    * Algorithms that !NeedDescretBoundary() || !OnlyUnaryInput() are
+    * to set SMESH_ComputeError returned by SMESH_submesh::GetComputeError()
+    * to report problematic subshapes
    */
   virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
 
@@ -157,15 +162,19 @@ public:
                                  const bool         ignoreAuxiliary) const;
   /*!
    * \brief Initialize my parameter values by the mesh built on the geometry
-   * \param theMesh - the built mesh
-   * \param theShape - the geometry of interest
-   * \retval bool - true if parameter values have been successfully defined
    *
    * Just return false as the algorithm does not hold parameters values
    */
   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh,
                                    const TopoDS_Shape& theShape);
-
+  /*!
+   * \brief return compute error
+   */
+  SMESH_ComputeErrorPtr GetComputeError() const;
+  /*!
+   * \brief initialize compute error
+   */
+  void InitComputeError();
 
 public:
   // ==================================================================
@@ -262,7 +271,24 @@ public:
                                          SMESHDS_Mesh*        meshDS);
 
 protected:
-  std::vector<std::string> _compatibleHypothesis;
+
+  /*!
+   * \brief store error and comment and then return ( error == COMPERR_OK )
+   */
+  bool error(int error, const SMESH_Comment& comment = "");
+  /*!
+   * \brief store COMPERR_ALGO_FAILED error and comment and then return false
+   */
+  bool error(const SMESH_Comment& comment = "")
+  { return error(COMPERR_ALGO_FAILED, comment); }
+  /*!
+   * \brief store error and return error->IsOK()
+   */
+  bool error(SMESH_ComputeErrorPtr error);
+
+protected:
+
+  std::vector<std::string>              _compatibleHypothesis;
   std::list<const SMESHDS_Hypothesis *> _appliedHypList;
   std::list<const SMESHDS_Hypothesis *> _usedHypList;
 
@@ -270,8 +296,12 @@ protected:
   bool _requireDescretBoundary;
   bool _requireShape;
 
-  // quadratic mesh creation required
+  // quadratic mesh creation required,
+  // is usually set trough SMESH_MesherHelper::IsQuadraticSubMesh()
   bool _quadraticMesh;
+
+  int         _error;    //!< SMESH_ComputeErrorName or anything algo specific
+  std::string _comment;  //!< any text explaining what is wrong in Compute()
 };
 
 #endif