Back to index

salome-smesh  6.5.0
StdMeshers_FixedPoints1D.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  SMESH SMESH : implementaion of SMESH idl descriptions
00021 //  File   : StdMeshers_FixedPoints1D.cxx
00022 //  Author : Damien COQUERET, OCC
00023 //  Module : SMESH
00024 //
00025 #include "StdMeshers_FixedPoints1D.hxx"
00026 
00027 #include "SMESH_Algo.hxx"
00028 #include "SMESH_Mesh.hxx"
00029 
00030 //#include <BRep_Tool.hxx>
00031 //#include <GCPnts_AbscissaPoint.hxx>
00032 //#include <GeomAdaptor_Curve.hxx>
00033 //#include <Geom_Curve.hxx>
00034 //#include <TopExp.hxx>
00035 //#include <TopLoc_Location.hxx>
00036 //#include <TopTools_IndexedMapOfShape.hxx>
00037 //#include <TopoDS.hxx>
00038 //#include <TopoDS_Edge.hxx>
00039 
00040 using namespace std;
00041 
00042 //=============================================================================
00046 //=============================================================================
00047 
00048 StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
00049                                                    SMESH_Gen * gen)
00050   :SMESH_Hypothesis(hypId, studyId, gen)
00051 {
00052   _name = "FixedPoints1D";
00053   _param_algo_dim = 1; 
00054   _nbsegs.reserve( 1 );
00055   _nbsegs.push_back( 1 );
00056 }
00057 
00058 //=============================================================================
00062 //=============================================================================
00063 
00064 StdMeshers_FixedPoints1D::~StdMeshers_FixedPoints1D()
00065 {
00066 }
00067 
00068 //=============================================================================
00072 //=============================================================================
00073 
00074 void StdMeshers_FixedPoints1D::SetPoints(std::vector<double>& listParams)
00075                               throw(SALOME_Exception)
00076 {
00077   _params = listParams;
00078   NotifySubMeshesHypothesisModification();
00079 }
00080 
00081 //=============================================================================
00085 //=============================================================================
00086 
00087 void StdMeshers_FixedPoints1D::SetNbSegments(std::vector<int>& listNbSeg) 
00088                               throw(SALOME_Exception)
00089 {
00090   _nbsegs = listNbSeg;
00091   NotifySubMeshesHypothesisModification();
00092 }
00093 
00094 //=============================================================================
00098 //=============================================================================
00099 
00100 void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector<int>& ids )
00101 {
00102   if ( ids != _edgeIDs ) {
00103     _edgeIDs = ids;
00104 
00105     NotifySubMeshesHypothesisModification();
00106   }
00107 }
00108 
00109 //=============================================================================
00113 //=============================================================================
00114 
00115 ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save)
00116 {
00117   int listSize = _params.size();
00118   save << listSize;
00119   if ( listSize > 0 ) {
00120     for ( int i = 0; i < listSize; i++) save << " " << _params[i];
00121   }
00122 
00123   listSize = _nbsegs.size();
00124   save << " " << listSize;
00125   if ( listSize > 0 ) {
00126     for ( int i = 0; i < listSize; i++) save << " " << _nbsegs[i];
00127   }
00128 
00129   listSize = _edgeIDs.size();
00130   save << " " << listSize;
00131   if ( listSize > 0 ) {
00132     for ( int i = 0; i < listSize; i++)
00133       save << " " << _edgeIDs[i];
00134   }
00135 
00136   save << " " << _objEntry;
00137 
00138   return save;
00139 }
00140 
00141 //=============================================================================
00145 //=============================================================================
00146 
00147 istream & StdMeshers_FixedPoints1D::LoadFrom(istream & load)
00148 {
00149   bool isOK = true;
00150   int intVal;
00151   double dblVal;
00152 
00153   isOK = (load >> intVal);
00154   if (isOK && intVal > 0) {
00155     _params.clear();
00156     _params.reserve( intVal );
00157     for (int i = 0; i < _params.capacity() && isOK; i++) {
00158       isOK = (load >> dblVal);
00159       if ( isOK ) _params.push_back( dblVal );
00160     }
00161   }
00162 
00163   isOK = (load >> intVal);
00164   if (isOK && intVal > 0) {
00165     _nbsegs.clear();
00166     _nbsegs.reserve( intVal );
00167     for (int i = 0; i < _nbsegs.capacity() && isOK; i++) {
00168       isOK = (load >> intVal);
00169       if ( isOK ) _nbsegs.push_back( intVal );
00170     }
00171   }
00172 
00173   isOK = (load >> intVal);
00174   if (isOK && intVal > 0) {
00175     _edgeIDs.clear();
00176     _edgeIDs.reserve( intVal );
00177     for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) {
00178       isOK = (load >> intVal);
00179       if ( isOK ) _edgeIDs.push_back( intVal );
00180     }
00181   }
00182 
00183   isOK = (load >> _objEntry);
00184 
00185   return load;
00186 }
00187 
00188 //=============================================================================
00192 //=============================================================================
00193 
00194 ostream & operator <<(ostream & save, StdMeshers_FixedPoints1D & hyp)
00195 {
00196   return hyp.SaveTo( save );
00197 }
00198 
00199 //=============================================================================
00203 //=============================================================================
00204 
00205 istream & operator >>(istream & load, StdMeshers_FixedPoints1D & hyp)
00206 {
00207   return hyp.LoadFrom( load );
00208 }
00209 
00210 //================================================================================
00217 //================================================================================
00218 
00219 bool StdMeshers_FixedPoints1D::SetParametersByMesh(const SMESH_Mesh*   theMesh,
00220                                                    const TopoDS_Shape& theShape)
00221 {
00222   if ( !theMesh || theShape.IsNull() )
00223     return false;
00224 
00225   _nbsegs.reserve( 1 );
00226   _nbsegs.push_back( 1 );
00227   return true;
00228 }
00229 
00230 //================================================================================
00235 //================================================================================
00236 
00237 bool StdMeshers_FixedPoints1D::SetParametersByDefaults(const TDefaults&  dflts,
00238                                                        const SMESH_Mesh* /*mesh*/)
00239 {
00240   _nbsegs.reserve( 1 );
00241   _nbsegs.push_back( 1 );
00242   return true;
00243 }
00244