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