1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESH_Algo.hxx
25 // Author : Paul RASCLE, EDF
29 #ifndef _SMESH_ALGO_HXX_
30 #define _SMESH_ALGO_HXX_
32 #include "SMESH_SMESH.hxx"
34 #include "SMESH_Hypothesis.hxx"
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Edge.hxx>
47 class SMESH_HypoFilter;
54 class SMESH_EXPORT SMESH_Algo:public SMESH_Hypothesis
58 * \brief Creates algorithm
59 * \param hypId - algorithm ID
60 * \param studyId - study ID
61 * \param gen - SMESH_Gen
63 SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
68 virtual ~ SMESH_Algo();
71 * \brief Saves nothing in a stream
72 * \param save - the stream
73 * \retval virtual std::ostream & - the stream
75 virtual std::ostream & SaveTo(std::ostream & save);
78 * \brief Loads nothing from a stream
79 * \param load - the stream
80 * \retval virtual std::ostream & - the stream
82 virtual std::istream & LoadFrom(std::istream & load);
85 * \brief Returns all types of compatible hypotheses
87 const std::vector < std::string > & GetCompatibleHypothesis();
90 * \brief Check hypothesis definition to mesh a shape
91 * \param aMesh - the mesh
92 * \param aShape - the shape
93 * \param aStatus - check result
94 * \retval bool - true if hypothesis is well defined
96 virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
97 const TopoDS_Shape& aShape,
98 SMESH_Hypothesis::Hypothesis_Status& aStatus) = 0;
100 * \brief Computes mesh on a shape
101 * \param aMesh - the mesh
102 * \param aShape - the shape
103 * \retval bool - is a success
105 virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
108 * \brief Returns a list of compatible hypotheses used to mesh a shape
109 * \param aMesh - the mesh
110 * \param aShape - the shape
111 * \param ignoreAuxiliary - do not include auxiliary hypotheses in the list
112 * \retval const std::list <const SMESHDS_Hypothesis*> - hypotheses list
114 * List the hypothesis used by the algorithm associated to the shape.
115 * Hypothesis associated to father shape -are- taken into account (see
116 * GetAppliedHypothesis). Relevant hypothesis have a name (type) listed in
117 * the algorithm. This method could be surcharged by specific algorithms, in
118 * case of several hypothesis simultaneously applicable.
120 virtual const std::list <const SMESHDS_Hypothesis *> &
121 GetUsedHypothesis(SMESH_Mesh & aMesh,
122 const TopoDS_Shape & aShape,
123 const bool ignoreAuxiliary=true);
125 * \brief Returns a list of compatible hypotheses assigned to a shape in a mesh
126 * \param aMesh - the mesh
127 * \param aShape - the shape
128 * \param ignoreAuxiliary - do not include auxiliary hypotheses in the list
129 * \retval const std::list <const SMESHDS_Hypothesis*> - hypotheses list
131 * List the relevant hypothesis associated to the shape. Relevant hypothesis
132 * have a name (type) listed in the algorithm. Hypothesis associated to
133 * father shape -are not- taken into account (see GetUsedHypothesis)
135 const list <const SMESHDS_Hypothesis *> &
136 GetAppliedHypothesis(SMESH_Mesh & aMesh,
137 const TopoDS_Shape & aShape,
138 const bool ignoreAuxiliary=true);
140 * \brief Make the filter recognize only compatible hypotheses
141 * \param theFilter - the filter to initialize
142 * \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
143 * \retval bool - true if the algo has compatible hypotheses
145 bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
146 const bool ignoreAuxiliary) const;
148 * \brief Initialize my parameter values by the mesh built on the geometry
149 * \param theMesh - the built mesh
150 * \param theShape - the geometry of interest
151 * \retval bool - true if parameter values have been successfully defined
153 * Just return false as the algorithm does not hold parameters values
155 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh,
156 const TopoDS_Shape& theShape);
160 // ==================================================================
161 // Algo features influencing how Compute() is called:
162 // in what turn and with what input shape
163 // ==================================================================
165 // SMESH_Hypothesis::GetDim();
166 // 1 - dimention of target mesh
168 bool OnlyUnaryInput() const { return _onlyUnaryInput; }
169 // 2 - is collection of tesselatable shapes inacceptable as input;
170 // "collection" means a shape containing shapes of dim equal
172 // Algo which can process a collection shape should expect
173 // an input temporary shape that is neither MainShape nor
176 bool NeedDescretBoundary() const { return _requireDescretBoundary; }
177 // 3 - is a Dim-1 mesh prerequisite
180 // ==================================================================
181 // Methods to track non hierarchical dependencies between submeshes
182 // ==================================================================
185 * \brief Sets event listener to submeshes if necessary
186 * \param subMesh - submesh where algo is set
188 * This method is called when a submesh gets HYP_OK algo_state.
189 * After being set, event listener is notified on each event of a submesh.
190 * By default non listener is set
192 virtual void SetEventListener(SMESH_subMesh* subMesh);
195 // ==================================================================
196 // Common algo utilities
197 // ==================================================================
199 * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
200 * \param theMesh - The mesh containing nodes
201 * \param theEdge - The geometrical edge of interest
202 * \param theParams - The resulting vector of sorted node parameters
203 * \retval bool - false if not all parameters are OK
205 static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
206 const TopoDS_Edge& theEdge,
207 std::vector< double > & theParams);
209 * \brief Find out elements orientation on a geometrical face
210 * \param theFace - The face correctly oriented in the shape being meshed
211 * \param theMeshDS - The mesh data structure
212 * \retval bool - true if the face normal and the normal of first element
213 * in the correspoding submesh point in different directions
215 static bool IsReversedSubMesh (const TopoDS_Face& theFace,
216 SMESHDS_Mesh* theMeshDS);
218 * \brief Compute length of an edge
219 * \param E - the edge
220 * \retval double - the length
222 static double EdgeLength(const TopoDS_Edge & E);
226 bool _onlyUnaryInput;
227 bool _requireDescretBoundary;
228 std::vector<std::string> _compatibleHypothesis;
229 std::list<const SMESHDS_Hypothesis *> _appliedHypList;
230 std::list<const SMESHDS_Hypothesis *> _usedHypList;
232 // quadratic mesh creation required