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();
127 if ( listSize > 0 ) {
128 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
131 listSize = _edgeIDs.size();
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) {
157 _params.reserve( intVal );
158 for (int i = 0; i < _params.capacity() && isOK; i++) {
159 isOK = (load >> dblVal);
160 if ( isOK ) _params.push_back( dblVal );
164 isOK = (load >> intVal);
165 if (isOK && intVal > 0) {
166 _nbsegs.reserve( intVal );
167 for (int i = 0; i < _nbsegs.capacity() && isOK; i++) {
168 isOK = (load >> intVal);
169 if ( isOK ) _nbsegs.push_back( intVal );
173 isOK = (load >> intVal);
174 if (isOK && intVal > 0) {
175 _edgeIDs.reserve( intVal );
176 for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) {
177 isOK = (load >> intVal);
178 if ( isOK ) _edgeIDs.push_back( intVal );
182 isOK = (load >> _objEntry);
187 //=============================================================================
191 //=============================================================================
193 ostream & operator <<(ostream & save, StdMeshers_FixedPoints1D & hyp)
195 return hyp.SaveTo( save );
198 //=============================================================================
202 //=============================================================================
204 istream & operator >>(istream & load, StdMeshers_FixedPoints1D & hyp)
206 return hyp.LoadFrom( load );
209 //================================================================================
211 * \brief Initialize start and end length by the mesh built on the geometry
212 * \param theMesh - the built mesh
213 * \param theShape - the geometry of interest
214 * \retval bool - true if parameter values have been successfully defined
216 //================================================================================
218 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
219 const TopoDS_Shape& theShape)
221 if ( !theMesh || theShape.IsNull() )
224 _nbsegs.reserve( 1 );
225 _nbsegs.push_back( 1 );
229 //================================================================================
231 * \brief Initialize my parameter values by default parameters.
232 * \retval bool - true if parameter values have been successfully defined
234 //================================================================================
236 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& dflts,
237 const SMESH_Mesh* /*mesh*/)
239 _nbsegs.reserve( 1 );
240 _nbsegs.push_back( 1 );