1 // Copyright (C) 2007-2016 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, int studyId,
40 :StdMeshers_Reversible1D(hypId, studyId, gen)
42 _name = "FixedPoints1D";
45 _nbsegs.push_back( 1 );
48 //=============================================================================
52 //=============================================================================
54 StdMeshers_FixedPoints1D::~StdMeshers_FixedPoints1D()
58 //=============================================================================
62 //=============================================================================
64 void StdMeshers_FixedPoints1D::SetPoints(std::vector<double>& listParams)
65 throw(SALOME_Exception)
68 NotifySubMeshesHypothesisModification();
71 //=============================================================================
75 //=============================================================================
77 void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg)
78 throw(SALOME_Exception)
81 NotifySubMeshesHypothesisModification();
84 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
86 int listSize = _params.size();
89 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
92 listSize = _nbsegs.size();
93 save << " " << listSize;
95 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
98 listSize = _edgeIDs.size();
99 save << " " << listSize;
100 if ( listSize > 0 ) {
101 for ( int i = 0; i < listSize; i++)
102 save << " " << _edgeIDs[i];
105 save << " " << _objEntry;
110 //=============================================================================
114 //=============================================================================
116 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
122 isOK = static_cast<bool>(load >> intVal);
123 if (isOK && intVal > 0) {
125 _params.reserve( intVal );
126 for ( size_t i = 0; i < _params.capacity() && isOK; i++) {
127 isOK = static_cast<bool>(load >> dblVal);
128 if ( isOK ) _params.push_back( dblVal );
132 isOK = static_cast<bool>(load >> intVal);
133 if (isOK && intVal > 0) {
135 _nbsegs.reserve( intVal );
136 for ( size_t i = 0; i < _nbsegs.capacity() && isOK; i++) {
137 isOK = static_cast<bool>(load >> intVal);
138 if ( isOK ) _nbsegs.push_back( intVal );
142 isOK = static_cast<bool>(load >> intVal);
143 if (isOK && intVal > 0) {
145 _edgeIDs.reserve( intVal );
146 for ( size_t i = 0; i < _edgeIDs.capacity() && isOK; i++) {
147 isOK = static_cast<bool>(load >> intVal);
148 if ( isOK ) _edgeIDs.push_back( intVal );
152 isOK = static_cast<bool>(load >> _objEntry);
157 //================================================================================
159 * \brief Initialize start and end length by the mesh built on the geometry
160 * \param theMesh - the built mesh
161 * \param theShape - the geometry of interest
162 * \retval bool - true if parameter values have been successfully defined
164 //================================================================================
166 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
167 const TopoDS_Shape& theShape)
169 if ( !theMesh || theShape.IsNull() )
172 _nbsegs.reserve( 1 );
173 _nbsegs.push_back( 1 );
177 //================================================================================
179 * \brief Initialize my parameter values by default parameters.
180 * \retval bool - true if parameter values have been successfully defined
182 //================================================================================
184 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& dflts,
185 const SMESH_Mesh* /*mesh*/)
187 _nbsegs.reserve( 1 );
188 _nbsegs.push_back( 1 );