Go to the documentation of this file.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 class gp_XYZ;
00057
00058 typedef std::map< SMESH_subMesh*, std::vector<int> > MapShapeNbElems;
00059 typedef std::map< SMESH_subMesh*, std::vector<int> >::iterator MapShapeNbElemsItr;
00060
00070 class SMESH_EXPORT SMESH_Algo:public SMESH_Hypothesis
00071 {
00072 public:
00079 SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
00080
00084 virtual ~ SMESH_Algo();
00085
00091 virtual std::ostream & SaveTo(std::ostream & save);
00092
00098 virtual std::istream & LoadFrom(std::istream & load);
00099
00103 const std::vector < std::string > & GetCompatibleHypothesis();
00104
00112 virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
00113 const TopoDS_Shape& aShape,
00114 SMESH_Hypothesis::Hypothesis_Status& aStatus) = 0;
00125 virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
00126
00135 virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
00136
00137 #ifdef WITH_SMESH_CANCEL_COMPUTE
00138 virtual void CancelCompute();
00139 #endif
00140
00148 virtual bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
00149 MapShapeNbElems& aResMap) = 0;
00150
00164 virtual const std::list <const SMESHDS_Hypothesis *> &
00165 GetUsedHypothesis(SMESH_Mesh & aMesh,
00166 const TopoDS_Shape & aShape,
00167 const bool ignoreAuxiliary=true);
00179 const list <const SMESHDS_Hypothesis *> &
00180 GetAppliedHypothesis(SMESH_Mesh & aMesh,
00181 const TopoDS_Shape & aShape,
00182 const bool ignoreAuxiliary=true);
00189 bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
00190 const bool ignoreAuxiliary) const;
00194 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
00195 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
00199 SMESH_ComputeErrorPtr GetComputeError() const;
00203 void InitComputeError();
00204
00205 public:
00206
00207
00208
00209
00210
00211
00212
00213
00214 bool OnlyUnaryInput() const { return _onlyUnaryInput; }
00215
00216
00217
00218
00219
00220
00221
00222 bool NeedDescretBoundary() const { return _requireDescretBoundary; }
00223
00224
00225 bool NeedShape() const { return _requireShape; }
00226
00227
00228 bool SupportSubmeshes() const { return _supportSubmeshes; }
00229
00230
00231
00232 public:
00233
00234
00235
00236
00245 virtual void SetEventListener(SMESH_subMesh* subMesh);
00246
00253 virtual void SubmeshRestored(SMESH_subMesh* subMesh);
00254
00255 public:
00256
00257
00258
00266 static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
00267 const TopoDS_Edge& theEdge,
00268 std::vector< double > & theParams);
00277 static bool GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
00278 const TopoDS_Edge& theEdge,
00279 const bool ignoreMediumNodes,
00280 std::map< double, const SMDS_MeshNode* > & theNodes);
00288 static bool IsReversedSubMesh (const TopoDS_Face& theFace,
00289 SMESHDS_Mesh* theMeshDS);
00295 static double EdgeLength(const TopoDS_Edge & E);
00296
00300 static bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);
00301
00308 static GeomAbs_Shape Continuity(TopoDS_Edge E1, TopoDS_Edge E2);
00309
00313 static bool IsContinuous(const TopoDS_Edge & E1, const TopoDS_Edge & E2) {
00314 return ( Continuity( E1, E2 ) >= GeomAbs_G1 );
00315 }
00316
00323 static const SMDS_MeshNode* VertexNode(const TopoDS_Vertex& V, const SMESHDS_Mesh* meshDS);
00324
00328 static std::vector< const SMDS_MeshNode*> GetCommonNodes(const SMDS_MeshElement* e1,
00329 const SMDS_MeshElement* e2);
00330
00331 protected:
00332
00336 bool error(int error, const SMESH_Comment& comment = "");
00340 bool error(const SMESH_Comment& comment = "")
00341 { return error(COMPERR_ALGO_FAILED, comment); }
00345 bool error(SMESH_ComputeErrorPtr error);
00351 void addBadInputElement(const SMDS_MeshElement* elem);
00352
00353 protected:
00354
00355 std::vector<std::string> _compatibleHypothesis;
00356 std::list<const SMESHDS_Hypothesis *> _appliedHypList;
00357 std::list<const SMESHDS_Hypothesis *> _usedHypList;
00358
00359
00360
00361
00362 bool _onlyUnaryInput;
00363 bool _requireDescretBoundary;
00364 bool _requireShape;
00365 bool _supportSubmeshes;
00366
00367
00368
00369 bool _quadraticMesh;
00370
00371 int _error;
00372 std::string _comment;
00373 std::list<const SMDS_MeshElement*> _badInputElements;
00374 };
00375
00376 #endif