1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : StdMeshers_FixedPoints1D.cxx
24 // Author : Damien COQUERET, OCC
27 #include "StdMeshers_FixedPoints1D.hxx"
29 #include "SMESH_Algo.hxx"
30 #include "SMESH_Mesh.hxx"
32 //#include <BRep_Tool.hxx>
33 //#include <GCPnts_AbscissaPoint.hxx>
34 //#include <GeomAdaptor_Curve.hxx>
35 //#include <Geom_Curve.hxx>
36 //#include <TopExp.hxx>
37 //#include <TopLoc_Location.hxx>
38 //#include <TopTools_IndexedMapOfShape.hxx>
39 //#include <TopoDS.hxx>
40 //#include <TopoDS_Edge.hxx>
44 //=============================================================================
48 //=============================================================================
50 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
52 :SMESH_Hypothesis(hypId, studyId, gen)
54 _name = "FixedPoints1D";
57 _nbsegs.push_back( 1 );
60 //=============================================================================
64 //=============================================================================
66 StdMeshers_FixedPoints1D::~StdMeshers_FixedPoints1D()
70 //=============================================================================
74 //=============================================================================
76 void StdMeshers_FixedPoints1D::SetPoints(std::vector<double>& listParams)
77 throw(SALOME_Exception)
80 NotifySubMeshesHypothesisModification();
83 //=============================================================================
87 //=============================================================================
89 void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg)
90 throw(SALOME_Exception)
93 NotifySubMeshesHypothesisModification();
96 //=============================================================================
100 //=============================================================================
102 void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
104 if ( ids != _edgeIDs ) {
107 NotifySubMeshesHypothesisModification();
111 //=============================================================================
115 //=============================================================================
117 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
119 int listSize = _params.size();
121 if ( listSize > 0 ) {
122 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
125 listSize = _nbsegs.size();
126 save << " " << listSize;
127 if ( listSize > 0 ) {
128 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
131 listSize = _edgeIDs.size();
132 save << " " << listSize;
133 if ( listSize > 0 ) {
134 for ( int i = 0; i < listSize; i++)
135 save << " " << _edgeIDs[i];
138 save << " " << _objEntry;
143 //=============================================================================
147 //=============================================================================
149 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
155 isOK = (load >> intVal);
156 if (isOK && intVal > 0) {
158 _params.reserve( intVal );
159 for (int i = 0; i < _params.capacity() && isOK; i++) {
160 isOK = (load >> dblVal);
161 if ( isOK ) _params.push_back( dblVal );
165 isOK = (load >> intVal);
166 if (isOK && intVal > 0) {
168 _nbsegs.reserve( intVal );
169 for (int i = 0; i < _nbsegs.capacity() && isOK; i++) {
170 isOK = (load >> intVal);
171 if ( isOK ) _nbsegs.push_back( intVal );
175 isOK = (load >> intVal);
176 if (isOK && intVal > 0) {
178 _edgeIDs.reserve( intVal );
179 for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) {
180 isOK = (load >> intVal);
181 if ( isOK ) _edgeIDs.push_back( intVal );
185 isOK = (load >> _objEntry);
190 //=============================================================================
194 //=============================================================================
196 ostream & operator <<(ostream & save, StdMeshers_FixedPoints1D & hyp)
198 return hyp.SaveTo( save );
201 //=============================================================================
205 //=============================================================================
207 istream & operator >>(istream & load, StdMeshers_FixedPoints1D & hyp)
209 return hyp.LoadFrom( load );
212 //================================================================================
214 * \brief Initialize start and end length by the mesh built on the geometry
215 * \param theMesh - the built mesh
216 * \param theShape - the geometry of interest
217 * \retval bool - true if parameter values have been successfully defined
219 //================================================================================
221 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
222 const TopoDS_Shape& theShape)
224 if ( !theMesh || theShape.IsNull() )
227 _nbsegs.reserve( 1 );
228 _nbsegs.push_back( 1 );
232 //================================================================================
234 * \brief Initialize my parameter values by default parameters.
235 * \retval bool - true if parameter values have been successfully defined
237 //================================================================================
239 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& dflts,
240 const SMESH_Mesh* /*mesh*/)
242 _nbsegs.reserve( 1 );
243 _nbsegs.push_back( 1 );