]> SALOME platform Git repositories - plugins/hexoticplugin.git/blob - src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0.
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hypothesis.cxx
1 //  HexoticPlugin : C++ implementation
2 //
3 //  Copyright (C) 2006  OPEN CASCADE, CEA/DEN, EDF R&D
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
20 //
21 //
22 // File      : HexoticPlugin_Hypothesis.cxx
23 // Author    : Lioka RAZAFINDRAZAKA (CEA)
24 // Date      : 2006/06/30
25 // Project   : SALOME
26 //=============================================================================
27
28 using namespace std;
29 #include <HexoticPlugin_Hypothesis.hxx>
30 #include <utilities.h>
31
32 //=============================================================================
33 /*!
34  *  
35  */
36 //=============================================================================
37 HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis (int hypId, int studyId,
38                                                   SMESH_Gen * gen)
39   : SMESH_Hypothesis(hypId, studyId, gen),
40     _hexesMinLevel( GetDefaultHexesMinLevel() ),
41     _hexesMaxLevel( GetDefaultHexesMaxLevel() ),
42     _hexoticQuadrangles( GetDefaultHexoticQuadrangles() ),
43     _hexoticIgnoreRidges( GetDefaultHexoticIgnoreRidges() ),
44     _hexoticInvalidElements( GetDefaultHexoticInvalidElements() ), 
45     _hexoticSharpAngleThreshold( GetDefaultHexoticSharpAngleThreshold() )
46 {
47   MESSAGE("HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis");
48   _name = "Hexotic_Parameters";
49   _param_algo_dim = 3;
50 }
51
52 //=============================================================================
53 /*!
54  *  
55  */
56 //=============================================================================
57
58 void HexoticPlugin_Hypothesis::SetHexesMinLevel(int theVal) {
59   if (theVal != _hexesMinLevel) {
60     _hexesMinLevel = theVal;
61     NotifySubMeshesHypothesisModification();
62   }
63 }
64
65 void HexoticPlugin_Hypothesis::SetHexesMaxLevel(int theVal) {
66   if (theVal != _hexesMaxLevel) {
67     _hexesMaxLevel = theVal;
68     NotifySubMeshesHypothesisModification();
69   }
70 }
71
72 void HexoticPlugin_Hypothesis::SetHexoticQuadrangles(bool theVal) {
73   if (theVal != _hexoticQuadrangles) {
74     _hexoticQuadrangles = theVal;
75     NotifySubMeshesHypothesisModification();
76   }
77 }
78
79 void HexoticPlugin_Hypothesis::SetHexoticIgnoreRidges(bool theVal) {
80   if (theVal != _hexoticIgnoreRidges) {
81     _hexoticIgnoreRidges = theVal;
82     NotifySubMeshesHypothesisModification();
83   }
84 }
85
86 void HexoticPlugin_Hypothesis::SetHexoticInvalidElements(bool theVal) {
87   if (theVal != _hexoticInvalidElements) {
88     _hexoticInvalidElements = theVal;
89     NotifySubMeshesHypothesisModification();
90   }
91 }
92
93 void HexoticPlugin_Hypothesis::SetHexoticSharpAngleThreshold(int theVal) {
94   if (theVal != _hexoticSharpAngleThreshold) {
95     _hexoticSharpAngleThreshold = theVal;
96     NotifySubMeshesHypothesisModification();
97   }
98 }
99
100 //=============================================================================
101 /*!
102  *  
103  */
104 //=============================================================================
105 ostream & HexoticPlugin_Hypothesis::SaveTo(ostream & save)
106 {
107   save << _hexesMinLevel << " " << _hexesMaxLevel;
108   save << " " << (int)_hexoticQuadrangles;
109   save << " " << (int)_hexoticIgnoreRidges;
110   save << " " << (int)_hexoticInvalidElements;
111   save << " " << _hexoticSharpAngleThreshold;
112   cout <<endl;
113   cout << "save : " << save << endl;
114   cout << endl;
115
116   return save;
117 }
118
119 //=============================================================================
120 /*!
121  *  
122  */
123 //=============================================================================
124 istream & HexoticPlugin_Hypothesis::LoadFrom(istream & load)
125 {
126 //   bool isOK = true;
127 //   int is;
128 //   double val;
129
130 //   isOK = (load >> val);
131 //   if (isOK)
132 //     _maxSize = val;
133 //   else
134 //     load.clear(ios::badbit | load.rdstate());
135
136 //   isOK = (load >> is);
137 //   if (isOK)
138 //     SetFineness((Fineness) is);
139 //   else
140 //     load.clear(ios::badbit | load.rdstate());
141
142 //   if (_fineness == UserDefined)
143 //   {
144 //     isOK = (load >> val);
145 //     if (isOK)
146 //       _growthRate = val;
147 //     else
148 //       load.clear(ios::badbit | load.rdstate());
149
150 //     isOK = (load >> val);
151 //     if (isOK)
152 //       _nbSegPerEdge = val;
153 //     else
154 //       load.clear(ios::badbit | load.rdstate());
155
156 //     isOK = (load >> val);
157 //     if (isOK)
158 //       _nbSegPerRadius = val;
159 //     else
160 //       load.clear(ios::badbit | load.rdstate());
161 //   }
162
163 //   isOK = (load >> is);
164 //   if (isOK)
165 //     _secondOrder = (bool) is;
166 //   else
167 //     load.clear(ios::badbit | load.rdstate());
168
169 //   isOK = (load >> is);
170 //   if (isOK)
171 //     _optimize = (bool) is;
172 //   else
173 //     load.clear(ios::badbit | load.rdstate());
174   return load;
175 }
176
177 //=============================================================================
178 /*!
179  *  
180  */
181 //=============================================================================
182 ostream & operator <<(ostream & save, HexoticPlugin_Hypothesis & hyp)
183 {
184   return hyp.SaveTo( save );
185 }
186
187 //=============================================================================
188 /*!
189  *  
190  */
191 //=============================================================================
192 istream & operator >>(istream & load, HexoticPlugin_Hypothesis & hyp)
193 {
194   return hyp.LoadFrom( load );
195 }
196
197
198 //================================================================================
199 /*!
200  * \brief Does nothing
201  * \param theMesh - the built mesh
202  * \param theShape - the geometry of interest
203  * \retval bool - always false
204  */
205 //================================================================================
206 bool HexoticPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh*   theMesh,
207                                                       const TopoDS_Shape& theShape)
208 {
209   return false;
210 }
211
212 //=============================================================================
213 int HexoticPlugin_Hypothesis::GetDefaultHexesMinLevel()
214 {
215   return 3;
216 }
217
218 int HexoticPlugin_Hypothesis::GetDefaultHexesMaxLevel()
219 {
220   return 8;
221 }
222
223 bool HexoticPlugin_Hypothesis::GetDefaultHexoticQuadrangles()
224 {
225   return true;
226 }
227
228 bool HexoticPlugin_Hypothesis::GetDefaultHexoticIgnoreRidges()
229 {
230   return false;
231 }
232
233 bool HexoticPlugin_Hypothesis::GetDefaultHexoticInvalidElements()
234 {
235   return false;
236 }
237
238 int HexoticPlugin_Hypothesis::GetDefaultHexoticSharpAngleThreshold()
239 {
240   return 60;
241 }