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)
66 NotifySubMeshesHypothesisModification();
69 //=============================================================================
73 //=============================================================================
75 void StdMeshers_FixedPoints1D::SetNbSegments(const std::vector<int>& listNbSeg)
78 NotifySubMeshesHypothesisModification();
81 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
83 int listSize = _params.size();
86 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
89 listSize = _nbsegs.size();
90 save << " " << listSize;
92 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
95 listSize = _edgeIDs.size();
96 save << " " << listSize;
98 for ( int i = 0; i < listSize; i++)
99 save << " " << _edgeIDs[i];
102 save << " " << _objEntry;
107 //=============================================================================
111 //=============================================================================
113 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
119 isOK = static_cast<bool>(load >> intVal);
120 if (isOK && intVal > 0) {
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 );
129 isOK = static_cast<bool>(load >> intVal);
130 if (isOK && intVal > 0) {
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 );
139 isOK = static_cast<bool>(load >> intVal);
140 if (isOK && intVal > 0) {
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 );
149 isOK = static_cast<bool>(load >> _objEntry);
154 //================================================================================
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
161 //================================================================================
163 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
164 const TopoDS_Shape& theShape)
166 if ( !theMesh || theShape.IsNull() )
169 _nbsegs.reserve( 1 );
170 _nbsegs.push_back( 1 );
174 //================================================================================
176 * \brief Initialize my parameter values by default parameters.
177 * \retval bool - true if parameter values have been successfully defined
179 //================================================================================
181 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& /*dflts*/,
182 const SMESH_Mesh* /*mesh*/)
184 _nbsegs.reserve( 1 );
185 _nbsegs.push_back( 1 );