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_Hypothesis.hxx"
34 #include <TopoDS_Shape.hxx>
35 #include <TopoDS_Edge.hxx>
45 class SMESH_HypoFilter;
52 class SMESH_Algo:public SMESH_Hypothesis
56 * \brief Creates algorithm
57 * \param hypId - algorithm ID
58 * \param studyId - study ID
59 * \param gen - SMESH_Gen
61 SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
66 virtual ~ SMESH_Algo();
69 * \brief Saves nothing in a stream
70 * \param save - the stream
71 * \retval virtual std::ostream & - the stream
73 virtual std::ostream & SaveTo(std::ostream & save);
76 * \brief Loads nothing from a stream
77 * \param load - the stream
78 * \retval virtual std::ostream & - the stream
80 virtual std::istream & LoadFrom(std::istream & load);
83 * \brief Returns all types of compatible hypotheses
85 const std::vector < std::string > & GetCompatibleHypothesis();
88 * \brief Check hypothesis definition to mesh a shape
89 * \param aMesh - the mesh
90 * \param aShape - the shape
91 * \param aStatus - check result
92 * \retval bool - true if hypothesis is well defined
94 virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
95 const TopoDS_Shape& aShape,
96 SMESH_Hypothesis::Hypothesis_Status& aStatus) = 0;
98 * \brief Computes mesh on a shape
99 * \param aMesh - the mesh
100 * \param aShape - the shape
101 * \retval bool - is a success
103 virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
106 * \brief Returns a list of compatible hypotheses used to mesh a shape
107 * \param aMesh - the mesh
108 * \param aShape - the shape
109 * \param ignoreAuxiliary - do not include auxiliary hypotheses in the list
110 * \retval const std::list <const SMESHDS_Hypothesis*> - hypotheses list
112 * List the hypothesis used by the algorithm associated to the shape.
113 * Hypothesis associated to father shape -are- taken into account (see
114 * GetAppliedHypothesis). Relevant hypothesis have a name (type) listed in
115 * the algorithm. This method could be surcharged by specific algorithms, in
116 * case of several hypothesis simultaneously applicable.
118 virtual const std::list <const SMESHDS_Hypothesis *> &
119 GetUsedHypothesis(SMESH_Mesh & aMesh,
120 const TopoDS_Shape & aShape,
121 const bool ignoreAuxiliary=true);
123 * \brief Returns a list of compatible hypotheses assigned to a shape in a mesh
124 * \param aMesh - the mesh
125 * \param aShape - the shape
126 * \param ignoreAuxiliary - do not include auxiliary hypotheses in the list
127 * \retval const std::list <const SMESHDS_Hypothesis*> - hypotheses list
129 * List the relevant hypothesis associated to the shape. Relevant hypothesis
130 * have a name (type) listed in the algorithm. Hypothesis associated to
131 * father shape -are not- taken into account (see GetUsedHypothesis)
133 const list <const SMESHDS_Hypothesis *> &
134 GetAppliedHypothesis(SMESH_Mesh & aMesh,
135 const TopoDS_Shape & aShape,
136 const bool ignoreAuxiliary=true);
138 * \brief Make the filter recognize only compatible hypotheses
139 * \param theFilter - the filter to initialize
140 * \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
141 * \retval bool - true if the algo has compatible hypotheses
143 bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
144 const bool ignoreAuxiliary) const;
146 * \brief Initialize my parameter values by the mesh built on the geometry
147 * \param theMesh - the built mesh
148 * \param theShape - the geometry of interest
149 * \retval bool - true if parameter values have been successfully defined
151 * Just return false as the algorithm does not hold parameters values
153 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh,
154 const TopoDS_Shape& theShape);
158 // ==================================================================
159 // Algo features influencing how Compute() is called:
160 // in what turn and with what input shape
161 // ==================================================================
163 // SMESH_Hypothesis::GetDim();
164 // 1 - dimention of target mesh
166 bool OnlyUnaryInput() const { return _onlyUnaryInput; }
167 // 2 - is collection of tesselatable shapes inacceptable as input;
168 // "collection" means a shape containing shapes of dim equal
170 // Algo which can process a collection shape should expect
171 // an input temporary shape that is neither MainShape nor
174 bool NeedDescretBoundary() const { return _requireDescretBoundary; }
175 // 3 - is a Dim-1 mesh prerequisite
178 // ==================================================================
179 // Methods to track non hierarchical dependencies between submeshes
180 // ==================================================================
183 * \brief Sets event listener to submeshes if necessary
184 * \param subMesh - submesh where algo is set
186 * This method is called when a submesh gets HYP_OK algo_state.
187 * After being set, event listener is notified on each event of a submesh.
188 * By default non listener is set
190 virtual void SetEventListener(SMESH_subMesh* subMesh);
193 // ==================================================================
194 // Common algo utilities
195 // ==================================================================
197 * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
198 * \param theMesh - The mesh containing nodes
199 * \param theEdge - The geometrical edge of interest
200 * \param theParams - The resulting vector of sorted node parameters
201 * \retval bool - false if not all parameters are OK
203 static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
204 const TopoDS_Edge& theEdge,
205 std::vector< double > & theParams);
207 * \brief Find out elements orientation on a geometrical face
208 * \param theFace - The face correctly oriented in the shape being meshed
209 * \param theMeshDS - The mesh data structure
210 * \retval bool - true if the face normal and the normal of first element
211 * in the correspoding submesh point in different directions
213 static bool IsReversedSubMesh (const TopoDS_Face& theFace,
214 SMESHDS_Mesh* theMeshDS);
216 * \brief Compute length of an edge
217 * \param E - the edge
218 * \retval double - the length
220 static double EdgeLength(const TopoDS_Edge & E);
224 bool _onlyUnaryInput;
225 bool _requireDescretBoundary;
226 std::vector<std::string> _compatibleHypothesis;
227 std::list<const SMESHDS_Hypothesis *> _appliedHypList;
228 std::list<const SMESHDS_Hypothesis *> _usedHypList;
230 // quadratic mesh creation required