Salome HOME
22355: EDF SMESH: New 1D hypothesis "Adaptive"
[modules/smesh.git] / src / StdMeshers / StdMeshers_Regular_1D.hxx
1 // Copyright (C) 2007-2013  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
23 //  SMESH SMESH : implementaion of SMESH idl descriptions
24 //  File   : StdMeshers_Regular_1D.hxx
25 //           Moved here from SMESH_Regular_1D.hxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //
29 #ifndef _SMESH_REGULAR_1D_HXX_
30 #define _SMESH_REGULAR_1D_HXX_
31
32 #include "SMESH_StdMeshers.hxx"
33
34 #include "SMESH_Algo.hxx"
35
36 class Adaptor3d_Curve;
37 class StdMeshers_Adaptive1D;
38 class StdMeshers_AdaptiveAlgo_1D;
39 class StdMeshers_FixedPoints1D;
40 class StdMeshers_SegmentLengthAroundVertex;
41 class TopoDS_Vertex;
42
43 class STDMESHERS_EXPORT StdMeshers_Regular_1D: public SMESH_1D_Algo
44 {
45 public:
46   StdMeshers_Regular_1D(int hypId, int studyId, SMESH_Gen* gen);
47   virtual ~StdMeshers_Regular_1D();
48
49   virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
50                                const TopoDS_Shape& aShape,
51                                SMESH_Hypothesis::Hypothesis_Status& aStatus);
52
53   virtual bool Compute(SMESH_Mesh& aMesh,
54                        const TopoDS_Shape& aShape);
55
56   virtual bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
57                         MapShapeNbElems& aResMap);
58
59   virtual void CancelCompute();
60
61   virtual const std::list <const SMESHDS_Hypothesis *> &
62     GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, const bool=true);
63
64   /*!
65    * \brief Sets event listener to submeshes if necessary
66     * \param subMesh - submesh where algo is set
67    *
68    * This method is called when a submesh gets HYP_OK algo_state.
69    * After being set, event listener is notified on each event of a submesh.
70    */
71   virtual void SetEventListener(SMESH_subMesh* subMesh);
72
73   /*!
74    * \brief Allow algo to do something after persistent restoration
75    * \param subMesh - restored submesh
76    *
77    * This method is called only if a submesh has HYP_OK algo_state.
78    */
79   void SubmeshRestored(SMESH_subMesh* subMesh);
80
81 protected:
82
83   virtual bool computeInternalParameters (SMESH_Mesh &        theMesh,
84                                           Adaptor3d_Curve &   theC3d,
85                                           double              theLength,
86                                           double              theFirstU,
87                                           double              theLastU,
88                                           std::list<double> & theParameters,
89                                           const bool          theReverse,
90                                           bool                theConsiderPropagation = false);
91
92   virtual void redistributeNearVertices (SMESH_Mesh &          theMesh,
93                                          Adaptor3d_Curve &     theC3d,
94                                          double                theLength,
95                                          std::list< double > & theParameters,
96                                          const TopoDS_Vertex & theVf,
97                                          const TopoDS_Vertex & theVl);
98
99   /*!
100    * \brief Return StdMeshers_SegmentLengthAroundVertex assigned to vertex
101    */
102   static const
103   StdMeshers_SegmentLengthAroundVertex* getVertexHyp(SMESH_Mesh &          theMesh,
104                                                      const TopoDS_Vertex & theV);
105
106   enum HypothesisType { LOCAL_LENGTH, MAX_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, FIXED_POINTS_1D, ADAPTIVE, NONE };
107
108   enum ValueIndex {
109     SCALE_FACTOR_IND = 0,
110     BEG_LENGTH_IND   = 0,
111     END_LENGTH_IND   = 1,
112     DEFLECTION_IND   = 0,
113     PRECISION_IND    = 1
114   };
115
116   enum IValueIndex {
117     NB_SEGMENTS_IND   = 0,
118     DISTR_TYPE_IND    = 1,
119     CONV_MODE_IND     = 2
120   };
121
122   enum VValueIndex {
123     TAB_FUNC_IND  = 0
124   };
125
126   enum SValueIndex {
127     EXPR_FUNC_IND  = 0
128   };
129
130   HypothesisType _hypType;
131
132   const StdMeshers_FixedPoints1D* _fpHyp;
133   const StdMeshers_Adaptive1D*    _adaptiveHyp;
134   StdMeshers_AdaptiveAlgo_1D*     getAdaptiveAlgo();
135
136   double _value[2];
137   int    _ivalue[3];
138   std::vector<double> _vvalue[1];
139   std::string         _svalue[1];
140   std::vector<int>    _revEdgesIDs;
141
142   // a source of propagated hypothesis, is set by CheckHypothesis()
143   // always called before Compute()
144   TopoDS_Shape _mainEdge;
145 };
146
147 #endif