Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / StdMeshers / StdMeshers_LayerDistribution.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SMESH SMESH : idl implementation based on 'SMESH' unit's classes
23 //  File   : StdMeshers_LayerDistribution.cxx
24 //  Author : Edward AGAPOV
25 //  Module : SMESH
26 //
27 #include "StdMeshers_LayerDistribution.hxx"
28
29 #include "utilities.h"
30
31 using namespace std;
32
33
34 //=============================================================================
35 /*!
36  *  StdMeshers_LayerDistribution::StdMeshers_LayerDistribution
37  *
38  *  Constructor
39  */
40 //=============================================================================
41
42 StdMeshers_LayerDistribution::StdMeshers_LayerDistribution(int hypId, int studyId,
43                                                            SMESH_Gen * gen)
44   : SMESH_Hypothesis(hypId, studyId, gen)
45 {
46   _name = "LayerDistribution"; // used by RadialPrism_3D
47   _param_algo_dim = 3; // 3D
48   myHyp = 0;
49 }
50
51 //=============================================================================
52 /*!
53  *  StdMeshers_LayerDistribution::~StdMeshers_LayerDistribution
54  *
55  *  Destructor
56  */
57 //=============================================================================
58
59 StdMeshers_LayerDistribution::~StdMeshers_LayerDistribution()
60 {
61   MESSAGE( "StdMeshers_LayerDistribution::~StdMeshers_LayerDistribution" );
62 }
63
64 //=============================================================================
65   /*!
66    * \brief Sets  1D hypothesis specifying distribution of layers
67     * \param hyp1D - 1D hypothesis
68    */
69 //=============================================================================
70
71 void StdMeshers_LayerDistribution::SetLayerDistribution(SMESH_Hypothesis* hyp1D)
72   throw ( SALOME_Exception )
73 {
74   if ( myHyp != hyp1D ) {
75     if ( myHyp && hyp1D->GetDim() != 1 )
76       throw SALOME_Exception(LOCALIZED("1D hypothesis is expected"));
77     myHyp = hyp1D;
78   }
79   std::ostringstream os;
80   if ( myHyp )
81     myHyp->SaveTo( os );
82
83   if ( mySavedHyp != os.str() )
84     NotifySubMeshesHypothesisModification();
85
86   mySavedHyp = os.str();
87 }
88
89 //=============================================================================
90 /*!
91  *  Servant saves and loads my hypothesis
92  */
93 //=============================================================================
94
95 ostream & StdMeshers_LayerDistribution::SaveTo(ostream & save)
96 {
97   return save;
98 }
99
100 //=============================================================================
101 /*!
102  *   Servant saves and loads my hypothesis
103  */
104 //=============================================================================
105
106 istream & StdMeshers_LayerDistribution::LoadFrom(istream & load)
107 {
108   return load;
109 }
110
111 //=============================================================================
112 /*!
113  *  
114  */
115 //=============================================================================
116
117 ostream & operator <<(ostream & save, StdMeshers_LayerDistribution & hyp)
118 {
119   return hyp.SaveTo( save );
120 }
121
122 //=============================================================================
123 /*!
124  *  
125  */
126 //=============================================================================
127
128 istream & operator >>(istream & load, StdMeshers_LayerDistribution & hyp)
129 {
130   return hyp.LoadFrom( load );
131 }
132
133 //================================================================================
134 /*!
135  * \brief Initialize start and end length by the mesh built on the geometry
136  * \param theMesh - the built mesh
137  * \param theShape - the geometry of interest
138  * \retval bool - true if parameter values have been successfully defined
139  */
140 //================================================================================
141
142 bool StdMeshers_LayerDistribution::SetParametersByMesh(const SMESH_Mesh*   ,
143                                                        const TopoDS_Shape& )
144 {
145   return false;
146 }
147 //================================================================================
148 /*!
149  * \brief Initialize my parameter values by default parameters.
150  *  \retval bool - true if parameter values have been successfully defined
151  */
152 //================================================================================
153
154 bool StdMeshers_LayerDistribution::SetParametersByDefaults(const TDefaults&  dflts,
155                                                            const SMESH_Mesh* theMesh)
156 {
157   return myHyp ? myHyp->SetParametersByDefaults(dflts,theMesh) : false;
158 }