1 // Copyright (C) 2007-2013 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.
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"
30 //#include <BRep_Tool.hxx>
31 //#include <GCPnts_AbscissaPoint.hxx>
32 //#include <GeomAdaptor_Curve.hxx>
33 //#include <Geom_Curve.hxx>
34 //#include <TopExp.hxx>
35 //#include <TopLoc_Location.hxx>
36 //#include <TopTools_IndexedMapOfShape.hxx>
37 //#include <TopoDS.hxx>
38 //#include <TopoDS_Edge.hxx>
42 //=============================================================================
46 //=============================================================================
48 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
50 :SMESH_Hypothesis(hypId, studyId, gen)
52 _name = "FixedPoints1D";
55 _nbsegs.push_back( 1 );
58 //=============================================================================
62 //=============================================================================
64 StdMeshers_FixedPoints1D::~StdMeshers_FixedPoints1D()
68 //=============================================================================
72 //=============================================================================
74 void StdMeshers_FixedPoints1D::SetPoints(std::vector<double>& listParams)
75 throw(SALOME_Exception)
78 NotifySubMeshesHypothesisModification();
81 //=============================================================================
85 //=============================================================================
87 void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg)
88 throw(SALOME_Exception)
91 NotifySubMeshesHypothesisModification();
94 //=============================================================================
98 //=============================================================================
100 void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
102 if ( ids != _edgeIDs ) {
105 NotifySubMeshesHypothesisModification();
109 //=============================================================================
113 //=============================================================================
115 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
117 int listSize = _params.size();
119 if ( listSize > 0 ) {
120 for ( int i = 0; i < listSize; i++) save << " " << _params[i];
123 listSize = _nbsegs.size();
124 save << " " << listSize;
125 if ( listSize > 0 ) {
126 for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
129 listSize = _edgeIDs.size();
130 save << " " << listSize;
131 if ( listSize > 0 ) {
132 for ( int i = 0; i < listSize; i++)
133 save << " " << _edgeIDs[i];
136 save << " " << _objEntry;
141 //=============================================================================
145 //=============================================================================
147 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
153 isOK = (load >> intVal);
154 if (isOK && intVal > 0) {
156 _params.reserve( intVal );
157 for (int i = 0; i < _params.capacity() && isOK; i++) {
158 isOK = (load >> dblVal);
159 if ( isOK ) _params.push_back( dblVal );
163 isOK = (load >> intVal);
164 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) {
176 _edgeIDs.reserve( intVal );
177 for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) {
178 isOK = (load >> intVal);
179 if ( isOK ) _edgeIDs.push_back( intVal );
183 isOK = (load >> _objEntry);
188 //=============================================================================
192 //=============================================================================
194 ostream & operator <<(ostream & save, StdMeshers_FixedPoints1D & hyp)
196 return hyp.SaveTo( save );
199 //=============================================================================
203 //=============================================================================
205 istream & operator >>(istream & load, StdMeshers_FixedPoints1D & hyp)
207 return hyp.LoadFrom( load );
210 //================================================================================
212 * \brief Initialize start and end length by the mesh built on the geometry
213 * \param theMesh - the built mesh
214 * \param theShape - the geometry of interest
215 * \retval bool - true if parameter values have been successfully defined
217 //================================================================================
219 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
220 const TopoDS_Shape& theShape)
222 if ( !theMesh || theShape.IsNull() )
225 _nbsegs.reserve( 1 );
226 _nbsegs.push_back( 1 );
230 //================================================================================
232 * \brief Initialize my parameter values by default parameters.
233 * \retval bool - true if parameter values have been successfully defined
235 //================================================================================
237 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults& dflts,
238 const SMESH_Mesh* /*mesh*/)
240 _nbsegs.reserve( 1 );
241 _nbsegs.push_back( 1 );