1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SMESH SMESH : implementation of SMESH idl descriptions
21 // File : StdMeshers_FixedPoints1D.cxx
22 // Author : Damien COQUERET, OCC
25 #include "StdMeshers_FixedPoints1D.hxx"
27 #include "SMESH_Algo.hxx"
28 #include "SMESH_Mesh.hxx"
32 //=============================================================================
36 //=============================================================================
38 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, SMESH_Gen * gen)
39 :StdMeshers_Reversible1D(hypId, gen)
41 _name = "FixedPoints1D";
44 _nbsegs.push_back( 1 );
47 //=============================================================================
51 //=============================================================================
53 StdMeshers_FixedPoints1D::~StdMeshers_FixedPoints1D()
57 //=============================================================================
61 //=============================================================================
63 void StdMeshers_FixedPoints1D::SetPoints(const std::vector<double>& listParams)
64 throw(SALOME_Exception)
67 NotifySubMeshesHypothesisModification();
70 //=============================================================================
74 //=============================================================================
76 void StdMeshers_FixedPoints1D::SetNbSegments(const std::vector<int>& listNbSeg)
77 throw(SALOME_Exception)
80 NotifySubMeshesHypothesisModification();
83 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
85 int listSize = _params.size();
88 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
91 listSize = _nbsegs.size();
92 save << " " << listSize;
94 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
97 listSize = _edgeIDs.size();
98 save << " " << listSize;
100 for ( int i = 0; i < listSize; i++)
101 save << " " << _edgeIDs[i];
104 save << " " << _objEntry;
109 //=============================================================================
113 //=============================================================================
115 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
121 isOK = static_cast<bool>(load >> intVal);
122 if (isOK && intVal > 0) {
124 _params.reserve( intVal );
125 for ( size_t i = 0; i < _params.capacity() && isOK; i++) {
126 isOK = static_cast<bool>(load >> dblVal);
127 if ( isOK ) _params.push_back( dblVal );
131 isOK = static_cast<bool>(load >> intVal);
132 if (isOK && intVal > 0) {
134 _nbsegs.reserve( intVal );
135 for ( size_t i = 0; i < _nbsegs.capacity() && isOK; i++) {
136 isOK = static_cast<bool>(load >> intVal);
137 if ( isOK ) _nbsegs.push_back( intVal );
141 isOK = static_cast<bool>(load >> intVal);
142 if (isOK && intVal > 0) {
144 _edgeIDs.reserve( intVal );
145 for ( size_t i = 0; i < _edgeIDs.capacity() && isOK; i++) {
146 isOK = static_cast<bool>(load >> intVal);
147 if ( isOK ) _edgeIDs.push_back( intVal );
151 isOK = static_cast<bool>(load >> _objEntry);
156 //================================================================================
158 * \brief Initialize start and end length by the mesh built on the geometry
159 * \param theMesh - the built mesh
160 * \param theShape - the geometry of interest
161 * \retval bool - true if parameter values have been successfully defined
163 //================================================================================
165 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
166 const TopoDS_Shape& theShape)
168 if ( !theMesh || theShape.IsNull() )
171 _nbsegs.reserve( 1 );
172 _nbsegs.push_back( 1 );
176 //================================================================================
178 * \brief Initialize my parameter values by default parameters.
179 * \retval bool - true if parameter values have been successfully defined
181 //================================================================================
183 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& dflts,
184 const SMESH_Mesh* /*mesh*/)
186 _nbsegs.reserve( 1 );
187 _nbsegs.push_back( 1 );