1 // Copyright (C) 2007-2021 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)
65 if ( _params != listParams )
68 NotifySubMeshesHypothesisModification();
72 //=============================================================================
76 //=============================================================================
78 void StdMeshers_FixedPoints1D::SetNbSegments(const std::vector<smIdType>& listNbSeg)
80 if ( _nbsegs != listNbSeg )
83 NotifySubMeshesHypothesisModification();
87 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
89 int listSize = _params.size();
92 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
95 listSize = _nbsegs.size();
96 save << " " << listSize;
98 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
101 listSize = _edgeIDs.size();
102 save << " " << listSize;
103 if ( listSize > 0 ) {
104 for ( int i = 0; i < listSize; i++)
105 save << " " << _edgeIDs[i];
108 save << " " << _objEntry;
113 //=============================================================================
117 //=============================================================================
119 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
125 isOK = static_cast<bool>(load >> intVal);
126 if (isOK && intVal > 0) {
128 _params.reserve( intVal );
129 for ( size_t i = 0; i < _params.capacity() && isOK; i++) {
130 isOK = static_cast<bool>(load >> dblVal);
131 if ( isOK ) _params.push_back( dblVal );
135 isOK = static_cast<bool>(load >> intVal);
136 if (isOK && intVal > 0) {
138 _nbsegs.reserve( intVal );
139 for ( size_t i = 0; i < _nbsegs.capacity() && isOK; i++) {
140 isOK = static_cast<bool>(load >> intVal);
141 if ( isOK ) _nbsegs.push_back( intVal );
145 isOK = static_cast<bool>(load >> intVal);
146 if (isOK && intVal > 0) {
148 _edgeIDs.reserve( intVal );
149 for ( size_t i = 0; i < _edgeIDs.capacity() && isOK; i++) {
150 isOK = static_cast<bool>(load >> intVal);
151 if ( isOK ) _edgeIDs.push_back( intVal );
155 isOK = static_cast<bool>(load >> _objEntry);
160 //================================================================================
162 * \brief Initialize start and end length by the mesh built on the geometry
163 * \param theMesh - the built mesh
164 * \param theShape - the geometry of interest
165 * \retval bool - true if parameter values have been successfully defined
167 //================================================================================
169 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
170 const TopoDS_Shape& theShape)
172 if ( !theMesh || theShape.IsNull() )
175 _nbsegs.reserve( 1 );
176 _nbsegs.push_back( 1 );
180 //================================================================================
182 * \brief Initialize my parameter values by default parameters.
183 * \retval bool - true if parameter values have been successfully defined
185 //================================================================================
187 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& /*dflts*/,
188 const SMESH_Mesh* /*mesh*/)
190 _nbsegs.reserve( 1 );
191 _nbsegs.push_back( 1 );