Salome HOME
#18963 Minimize compiler warnings
[modules/smesh.git] / src / StdMeshers / StdMeshers_FixedPoints1D.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  SMESH SMESH : implementation of SMESH idl descriptions
21 //  File   : StdMeshers_FixedPoints1D.cxx
22 //  Author : Damien COQUERET, OCC
23 //  Module : SMESH
24 //
25 #include "StdMeshers_FixedPoints1D.hxx"
26
27 #include "SMESH_Algo.hxx"
28 #include "SMESH_Mesh.hxx"
29
30 using namespace std;
31
32 //=============================================================================
33 /*!
34  *  
35  */
36 //=============================================================================
37
38 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, SMESH_Gen * gen)
39   :StdMeshers_Reversible1D(hypId, gen)
40 {
41   _name = "FixedPoints1D";
42   _param_algo_dim = 1;
43   _nbsegs.reserve( 1 );
44   _nbsegs.push_back( 1 );
45 }
46
47 //=============================================================================
48 /*!
49  *
50  */
51 //=============================================================================
52
53 StdMeshers_FixedPoints1D::~StdMeshers_FixedPoints1D()
54 {
55 }
56
57 //=============================================================================
58 /*!
59  *  
60  */
61 //=============================================================================
62
63 void StdMeshers_FixedPoints1D::SetPoints(const std::vector<double>& listParams)
64 {
65   _params = listParams;
66   NotifySubMeshesHypothesisModification();
67 }
68
69 //=============================================================================
70 /*!
71  *  
72  */
73 //=============================================================================
74
75 void StdMeshers_FixedPoints1D::SetNbSegments(const std::vector<int>& listNbSeg) 
76 {
77   _nbsegs = listNbSeg;
78   NotifySubMeshesHypothesisModification();
79 }
80
81 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
82 {
83   int listSize = _params.size();
84   save << listSize;
85   if ( listSize > 0 ) {
86     for ( int i = 0; i < listSize; i++) save << " " << _params[i];
87   }
88
89   listSize = _nbsegs.size();
90   save << " " << listSize;
91   if ( listSize > 0 ) {
92     for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
93   }
94
95   listSize = _edgeIDs.size();
96   save << " " << listSize;
97   if ( listSize > 0 ) {
98     for ( int i = 0; i < listSize; i++)
99       save << " " << _edgeIDs[i];
100   }
101
102   save << " " << _objEntry;
103
104   return save;
105 }
106
107 //=============================================================================
108 /*!
109  *
110  */
111 //=============================================================================
112
113 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
114 {
115   bool isOK = true;
116   int intVal;
117   double dblVal;
118
119   isOK = static_cast<bool>(load >> intVal);
120   if (isOK && intVal > 0) {
121     _params.clear();
122     _params.reserve( intVal );
123     for ( size_t i = 0; i < _params.capacity() && isOK; i++) {
124       isOK = static_cast<bool>(load >> dblVal);
125       if ( isOK ) _params.push_back( dblVal );
126     }
127   }
128
129   isOK = static_cast<bool>(load >> intVal);
130   if (isOK && intVal > 0) {
131     _nbsegs.clear();
132     _nbsegs.reserve( intVal );
133     for ( size_t i = 0; i < _nbsegs.capacity() && isOK; i++) {
134       isOK = static_cast<bool>(load >> intVal);
135       if ( isOK ) _nbsegs.push_back( intVal );
136     }
137   }
138
139   isOK = static_cast<bool>(load >> intVal);
140   if (isOK && intVal > 0) {
141     _edgeIDs.clear();
142     _edgeIDs.reserve( intVal );
143     for ( size_t i = 0; i < _edgeIDs.capacity() && isOK; i++) {
144       isOK = static_cast<bool>(load >> intVal);
145       if ( isOK ) _edgeIDs.push_back( intVal );
146     }
147   }
148
149   isOK = static_cast<bool>(load >> _objEntry);
150
151   return load;
152 }
153
154 //================================================================================
155 /*!
156  * \brief Initialize start and end length by the mesh built on the geometry
157  * \param theMesh - the built mesh
158  * \param theShape - the geometry of interest
159  * \retval bool - true if parameter values have been successfully defined
160  */
161 //================================================================================
162
163 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh*   theMesh,
164                                                    const TopoDS_Shape& theShape)
165 {
166   if ( !theMesh || theShape.IsNull() )
167     return false;
168
169   _nbsegs.reserve( 1 );
170   _nbsegs.push_back( 1 );
171   return true;
172 }
173
174 //================================================================================
175 /*!
176  * \brief Initialize my parameter values by default parameters.
177  *  \retval bool - true if parameter values have been successfully defined
178  */
179 //================================================================================
180
181 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults&  /*dflts*/,
182                                                        const SMESH_Mesh* /*mesh*/)
183 {
184   _nbsegs.reserve( 1 );
185   _nbsegs.push_back( 1 );
186   return true;
187 }
188