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