SALOME - SMESH
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SMESH_Algo.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_Algo.hxx
24 // Author : Paul RASCLE, EDF
25 // Module : SMESH
26 // $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH/SMESH_Algo.hxx,v 1.12.2.4 2008/11/27 12:25:15 abd Exp $
27 //
28 #ifndef _SMESH_ALGO_HXX_
29 #define _SMESH_ALGO_HXX_
30 
31 #include "SMESH_SMESH.hxx"
32 
33 #include "SMESH_Hypothesis.hxx"
34 #include "SMESH_ComputeError.hxx"
35 #include "SMESH_Comment.hxx"
36 
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <GeomAbs_Shape.hxx>
40 
41 #include <string>
42 #include <vector>
43 #include <list>
44 #include <map>
45 
46 class SMESH_Gen;
47 class SMESH_Mesh;
48 class SMESH_HypoFilter;
49 class TopoDS_Vertex;
50 class TopoDS_Face;
51 class TopoDS_Shape;
52 class SMESHDS_Mesh;
53 class SMDS_MeshNode;
54 class SMESH_subMesh;
55 class SMESH_MesherHelper;
56 
57 
59 {
60 public:
67  SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
68 
72  virtual ~ SMESH_Algo();
73 
79  virtual std::ostream & SaveTo(std::ostream & save);
80 
86  virtual std::istream & LoadFrom(std::istream & load);
87 
91  const std::vector < std::string > & GetCompatibleHypothesis();
92 
100  virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
101  const TopoDS_Shape& aShape,
113  virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
114 
123  virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
124 
138  virtual const std::list <const SMESHDS_Hypothesis *> &
139  GetUsedHypothesis(SMESH_Mesh & aMesh,
140  const TopoDS_Shape & aShape,
141  const bool ignoreAuxiliary=true);
153  const std::list <const SMESHDS_Hypothesis *> &
154  GetAppliedHypothesis(SMESH_Mesh & aMesh,
155  const TopoDS_Shape & aShape,
156  const bool ignoreAuxiliary=true);
163  bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
164  const bool ignoreAuxiliary) const;
170  virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
171  virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
172 
176  SMESH_ComputeErrorPtr GetComputeError() const;
180  void InitComputeError();
181 
182 public:
183  // ==================================================================
184  // Algo features influencing how Compute() is called:
185  // in what turn and with what input shape
186  // ==================================================================
187 
188  // SMESH_Hypothesis::GetDim();
189  // 1 - dimention of target mesh
190 
191  bool OnlyUnaryInput() const { return _onlyUnaryInput; }
192  // 2 - is collection of tesselatable shapes inacceptable as input;
193  // "collection" means a shape containing shapes of dim equal
194  // to GetDim().
195  // Algo which can process a collection shape should expect
196  // an input temporary shape that is neither MainShape nor
197  // its child.
198 
199  bool NeedDescretBoundary() const { return _requireDescretBoundary; }
200  // 3 - is a Dim-1 mesh prerequisite
201 
202  bool NeedShape() const { return _requireShape; }
203  // 4 - is shape existance required
204 
205  bool SupportSubmeshes() const { return _supportSubmeshes; }
206  // 5 - whether supports submeshes if !NeedDescretBoundary()
207 
208 
209 public:
210  // ==================================================================
211  // Methods to track non hierarchical dependencies between submeshes
212  // ==================================================================
213 
222  virtual void SetEventListener(SMESH_subMesh* subMesh);
223 
230  virtual void SubmeshRestored(SMESH_subMesh* subMesh);
231 
232 public:
233  // ==================================================================
234  // Common algo utilities
235  // ==================================================================
243  static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
244  const TopoDS_Edge& theEdge,
245  std::vector< double > & theParams);
246 
255  static bool GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
256  const TopoDS_Edge& theEdge,
257  const bool ignoreMediumNodes,
258  std::map< double, const SMDS_MeshNode* > & theNodes);
259 
267  static bool IsReversedSubMesh (const TopoDS_Face& theFace,
268  SMESHDS_Mesh* theMeshDS);
274  static double EdgeLength(const TopoDS_Edge & E);
275 
282  static GeomAbs_Shape Continuity(const TopoDS_Edge & E1, const TopoDS_Edge & E2);
283 
287  static bool IsContinuous(const TopoDS_Edge & E1, const TopoDS_Edge & E2) {
288  return ( Continuity( E1, E2 ) >= GeomAbs_G1 );
289  }
290 
297  static const SMDS_MeshNode* VertexNode(const TopoDS_Vertex& V,
298  const SMESHDS_Mesh* meshDS);
299 
300 protected:
301 
305  bool error(int error, const SMESH_Comment& comment = "");
309  bool error(const SMESH_Comment& comment = "")
310  { return error(COMPERR_ALGO_FAILED, comment); }
314  bool error(SMESH_ComputeErrorPtr error);
320  void addBadInputElement(const SMDS_MeshElement* elem);
321 
322 protected:
323 
324  std::vector<std::string> _compatibleHypothesis;
325  std::list<const SMESHDS_Hypothesis *> _appliedHypList;
326  std::list<const SMESHDS_Hypothesis *> _usedHypList;
327 
328  // Algo features influencing which Compute() and how is called:
329  // in what turn and with what input shape.
330  // This fields must be redefined if necessary by each descendant at constructor.
331  bool _onlyUnaryInput; // mesh one shape of GetDim() at once. Default TRUE
332  bool _requireDescretBoundary; // GetDim()-1 mesh must be present. Default TRUE
333  bool _requireShape; // work with GetDim()-1 mesh bound to geom only. Default TRUE
334  bool _supportSubmeshes; // if !_requireDescretBoundary. Default FALSE
335 
336  // quadratic mesh creation required,
337  // is usually set trough SMESH_MesherHelper::IsQuadraticSubMesh()
339 
340  int _error;
341  std::string _comment;
342  std::list<const SMDS_MeshElement*> _badInputElements;
343 };
344 
345 #endif
std::list< const SMDS_MeshElement * > _badInputElements
to explain COMPERR_BAD_INPUT_MESH
Definition: SMESH_Algo.hxx:342
std::list< const SMESHDS_Hypothesis * > _usedHypList
Definition: SMESH_Algo.hxx:326
bool _onlyUnaryInput
Definition: SMESH_Algo.hxx:331
boost::shared_ptr< SMESH_ComputeError > SMESH_ComputeErrorPtr
bool _quadraticMesh
Definition: SMESH_Algo.hxx:338
int _error
SMESH_ComputeErrorName or anything algo specific.
Definition: SMESH_Algo.hxx:340
std::string _comment
any text explaining what is wrong in Compute()
Definition: SMESH_Algo.hxx:341
bool NeedDescretBoundary() const
Definition: SMESH_Algo.hxx:199
bool SupportSubmeshes() const
Definition: SMESH_Algo.hxx:205
bool _supportSubmeshes
Definition: SMESH_Algo.hxx:334
static bool IsContinuous(const TopoDS_Edge &E1, const TopoDS_Edge &E2)
Return true if an edge can be considered as a continuation of another.
Definition: SMESH_Algo.hxx:287
bool OnlyUnaryInput() const
Definition: SMESH_Algo.hxx:191
Base class for elements.
virtual std::istream & LoadFrom(std::istream &load)=0
virtual bool SetParametersByDefaults(const TDefaults &dflts, const SMESH_Mesh *theMesh=0)=0
Initialize my parameter values by default parameters.
virtual std::ostream & SaveTo(std::ostream &save)=0
Class to generate string from any type.
virtual bool SetParametersByMesh(const SMESH_Mesh *theMesh, const TopoDS_Shape &theShape)=0
Initialize my parameter values by the mesh built on the geometry.
std::vector< std::string > _compatibleHypothesis
Definition: SMESH_Algo.hxx:324
bool error(const SMESH_Comment &comment="")
store COMPERR_ALGO_FAILED error and comment and then return false
Definition: SMESH_Algo.hxx:309
bool _requireShape
Definition: SMESH_Algo.hxx:333
bool _requireDescretBoundary
Definition: SMESH_Algo.hxx:332
std::list< const SMESHDS_Hypothesis * > _appliedHypList
Definition: SMESH_Algo.hxx:325
algo failed for some reason
bool NeedShape() const
Definition: SMESH_Algo.hxx:202
#define SMESH_EXPORT