00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _SMESH_ALGO_HXX_
00029 #define _SMESH_ALGO_HXX_
00030
00031 #include "SMESH_SMESH.hxx"
00032
00033 #include "SMESH_Hypothesis.hxx"
00034 #include "SMESH_ComputeError.hxx"
00035 #include "SMESH_Comment.hxx"
00036
00037 #include <TopoDS_Shape.hxx>
00038 #include <TopoDS_Edge.hxx>
00039 #include <GeomAbs_Shape.hxx>
00040
00041 #include <string>
00042 #include <vector>
00043 #include <list>
00044 #include <map>
00045
00046 class SMESH_Gen;
00047 class SMESH_Mesh;
00048 class SMESH_HypoFilter;
00049 class TopoDS_Vertex;
00050 class TopoDS_Face;
00051 class TopoDS_Shape;
00052 class SMESHDS_Mesh;
00053 class SMDS_MeshNode;
00054 class SMESH_subMesh;
00055 class SMESH_MesherHelper;
00056
00057 typedef std::map< SMESH_subMesh*, std::vector<int> > MapShapeNbElems;
00058
00059 typedef std::map< SMESH_subMesh*, std::vector<int> >::iterator MapShapeNbElemsItr;
00060
00061 class SMESH_EXPORT SMESH_Algo:public SMESH_Hypothesis
00062 {
00063 public:
00070 SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
00071
00075 virtual ~ SMESH_Algo();
00076
00082 virtual std::ostream & SaveTo(std::ostream & save);
00083
00089 virtual std::istream & LoadFrom(std::istream & load);
00090
00094 const std::vector < std::string > & GetCompatibleHypothesis();
00095
00103 virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
00104 const TopoDS_Shape& aShape,
00105 SMESH_Hypothesis::Hypothesis_Status& aStatus) = 0;
00116 virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
00117
00126 virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
00127
00135 virtual bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
00136 MapShapeNbElems& aResMap) = 0;
00137
00151 virtual const std::list <const SMESHDS_Hypothesis *> &
00152 GetUsedHypothesis(SMESH_Mesh & aMesh,
00153 const TopoDS_Shape & aShape,
00154 const bool ignoreAuxiliary=true);
00166 const std::list <const SMESHDS_Hypothesis *> &
00167 GetAppliedHypothesis(SMESH_Mesh & aMesh,
00168 const TopoDS_Shape & aShape,
00169 const bool ignoreAuxiliary=true);
00176 bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
00177 const bool ignoreAuxiliary) const;
00181 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
00182 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
00186 SMESH_ComputeErrorPtr GetComputeError() const;
00190 void InitComputeError();
00191
00192 public:
00193
00194
00195
00196
00197
00198
00199
00200
00201 bool OnlyUnaryInput() const { return _onlyUnaryInput; }
00202
00203
00204
00205
00206
00207
00208
00209 bool NeedDescretBoundary() const { return _requireDescretBoundary; }
00210
00211
00212 bool NeedShape() const { return _requireShape; }
00213
00214
00215 bool SupportSubmeshes() const { return _supportSubmeshes; }
00216
00217
00218
00219 public:
00220
00221
00222
00223
00232 virtual void SetEventListener(SMESH_subMesh* subMesh);
00233
00240 virtual void SubmeshRestored(SMESH_subMesh* subMesh);
00241
00242 public:
00243
00244
00245
00253 static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
00254 const TopoDS_Edge& theEdge,
00255 std::vector< double > & theParams);
00264 static bool GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
00265 const TopoDS_Edge& theEdge,
00266 const bool ignoreMediumNodes,
00267 std::map< double, const SMDS_MeshNode* > & theNodes);
00275 static bool IsReversedSubMesh (const TopoDS_Face& theFace,
00276 SMESHDS_Mesh* theMeshDS);
00282 static double EdgeLength(const TopoDS_Edge & E);
00283
00290 static GeomAbs_Shape Continuity(const TopoDS_Edge & E1, const TopoDS_Edge & E2);
00291
00295 static bool IsContinuous(const TopoDS_Edge & E1, const TopoDS_Edge & E2) {
00296 return ( Continuity( E1, E2 ) >= GeomAbs_G1 );
00297 }
00298
00305 static const SMDS_MeshNode* VertexNode(const TopoDS_Vertex& V,
00306 const SMESHDS_Mesh* meshDS);
00307
00308 protected:
00309
00313 bool error(int error, const SMESH_Comment& comment = "");
00317 bool error(const SMESH_Comment& comment = "")
00318 { return error(COMPERR_ALGO_FAILED, comment); }
00322 bool error(SMESH_ComputeErrorPtr error);
00328 void addBadInputElement(const SMDS_MeshElement* elem);
00329
00330 protected:
00331
00332 std::vector<std::string> _compatibleHypothesis;
00333 std::list<const SMESHDS_Hypothesis *> _appliedHypList;
00334 std::list<const SMESHDS_Hypothesis *> _usedHypList;
00335
00336
00337
00338
00339 bool _onlyUnaryInput;
00340 bool _requireDescretBoundary;
00341 bool _requireShape;
00342 bool _supportSubmeshes;
00343
00344
00345
00346 bool _quadraticMesh;
00347
00348 int _error;
00349 std::string _comment;
00350 std::list<const SMDS_MeshElement*> _badInputElements;
00351 };
00352
00353 #endif