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 : implementaion 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 :SMESH_Hypothesis(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 //=============================================================================
88 //=============================================================================
90 void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
92 if ( ids != _edgeIDs ) {
95 NotifySubMeshesHypothesisModification();
99 //=============================================================================
103 //=============================================================================
105 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
107 int listSize = _params.size();
109 if ( listSize > 0 ) {
110 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
113 listSize = _nbsegs.size();
114 save << " " << listSize;
115 if ( listSize > 0 ) {
116 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
119 listSize = _edgeIDs.size();
120 save << " " << listSize;
121 if ( listSize > 0 ) {
122 for ( int i = 0; i < listSize; i++)
123 save << " " << _edgeIDs[i];
126 save << " " << _objEntry;
131 //=============================================================================
135 //=============================================================================
137 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
143 isOK = static_cast<bool>(load >> intVal);
144 if (isOK && intVal > 0) {
146 _params.reserve( intVal );
147 for ( size_t i = 0; i < _params.capacity() && isOK; i++) {
148 isOK = static_cast<bool>(load >> dblVal);
149 if ( isOK ) _params.push_back( dblVal );
153 isOK = static_cast<bool>(load >> intVal);
154 if (isOK && intVal > 0) {
156 _nbsegs.reserve( intVal );
157 for ( size_t i = 0; i < _nbsegs.capacity() && isOK; i++) {
158 isOK = static_cast<bool>(load >> intVal);
159 if ( isOK ) _nbsegs.push_back( intVal );
163 isOK = static_cast<bool>(load >> intVal);
164 if (isOK && intVal > 0) {
166 _edgeIDs.reserve( intVal );
167 for ( size_t i = 0; i < _edgeIDs.capacity() && isOK; i++) {
168 isOK = static_cast<bool>(load >> intVal);
169 if ( isOK ) _edgeIDs.push_back( intVal );
173 isOK = static_cast<bool>(load >> _objEntry);
178 //================================================================================
180 * \brief Initialize start and end length by the mesh built on the geometry
181 * \param theMesh - the built mesh
182 * \param theShape - the geometry of interest
183 * \retval bool - true if parameter values have been successfully defined
185 //================================================================================
187 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
188 const TopoDS_Shape& theShape)
190 if ( !theMesh || theShape.IsNull() )
193 _nbsegs.reserve( 1 );
194 _nbsegs.push_back( 1 );
198 //================================================================================
200 * \brief Initialize my parameter values by default parameters.
201 * \retval bool - true if parameter values have been successfully defined
203 //================================================================================
205 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& dflts,
206 const SMESH_Mesh* /*mesh*/)
208 _nbsegs.reserve( 1 );
209 _nbsegs.push_back( 1 );