Salome HOME
Import a new plugin, sent by Stephane LIAUZU
[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 {
44   MESSAGE("HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis");
45   _name = "Hexotic_Parameters";
46   _param_algo_dim = 3;
47 }
48
49 //=============================================================================
50 /*!
51  *  
52  */
53 //=============================================================================
54
55 void HexoticPlugin_Hypothesis::SetHexesMinLevel(int theVal) {
56   if (theVal != _hexesMinLevel) {
57     _hexesMinLevel = theVal;
58     NotifySubMeshesHypothesisModification();
59   }
60 }
61
62 void HexoticPlugin_Hypothesis::SetHexesMaxLevel(int theVal) {
63   if (theVal != _hexesMaxLevel) {
64     _hexesMaxLevel = theVal;
65     NotifySubMeshesHypothesisModification();
66   }
67 }
68
69 void HexoticPlugin_Hypothesis::SetHexoticQuadrangles(bool theVal) {
70   if (theVal != _hexoticQuadrangles) {
71     _hexoticQuadrangles = theVal;
72     NotifySubMeshesHypothesisModification();
73   }
74 }
75
76 //=============================================================================
77 /*!
78  *  
79  */
80 //=============================================================================
81 ostream & HexoticPlugin_Hypothesis::SaveTo(ostream & save)
82 {
83   save << _hexesMinLevel << " " << _hexesMaxLevel;
84   save << " " << (int)_hexoticQuadrangles;
85   cout <<endl;
86   cout << "save : " << save << endl;
87   cout << endl;
88
89   return save;
90 }
91
92 //=============================================================================
93 /*!
94  *  
95  */
96 //=============================================================================
97 istream & HexoticPlugin_Hypothesis::LoadFrom(istream & load)
98 {
99 //   bool isOK = true;
100 //   int is;
101 //   double val;
102
103 //   isOK = (load >> val);
104 //   if (isOK)
105 //     _maxSize = val;
106 //   else
107 //     load.clear(ios::badbit | load.rdstate());
108
109 //   isOK = (load >> is);
110 //   if (isOK)
111 //     SetFineness((Fineness) is);
112 //   else
113 //     load.clear(ios::badbit | load.rdstate());
114
115 //   if (_fineness == UserDefined)
116 //   {
117 //     isOK = (load >> val);
118 //     if (isOK)
119 //       _growthRate = val;
120 //     else
121 //       load.clear(ios::badbit | load.rdstate());
122
123 //     isOK = (load >> val);
124 //     if (isOK)
125 //       _nbSegPerEdge = val;
126 //     else
127 //       load.clear(ios::badbit | load.rdstate());
128
129 //     isOK = (load >> val);
130 //     if (isOK)
131 //       _nbSegPerRadius = val;
132 //     else
133 //       load.clear(ios::badbit | load.rdstate());
134 //   }
135
136 //   isOK = (load >> is);
137 //   if (isOK)
138 //     _secondOrder = (bool) is;
139 //   else
140 //     load.clear(ios::badbit | load.rdstate());
141
142 //   isOK = (load >> is);
143 //   if (isOK)
144 //     _optimize = (bool) is;
145 //   else
146 //     load.clear(ios::badbit | load.rdstate());
147   return load;
148 }
149
150 //=============================================================================
151 /*!
152  *  
153  */
154 //=============================================================================
155 ostream & operator <<(ostream & save, HexoticPlugin_Hypothesis & hyp)
156 {
157   return hyp.SaveTo( save );
158 }
159
160 //=============================================================================
161 /*!
162  *  
163  */
164 //=============================================================================
165 istream & operator >>(istream & load, HexoticPlugin_Hypothesis & hyp)
166 {
167   return hyp.LoadFrom( load );
168 }
169
170
171 //================================================================================
172 /*!
173  * \brief Does nothing
174  * \param theMesh - the built mesh
175  * \param theShape - the geometry of interest
176  * \retval bool - always false
177  */
178 //================================================================================
179 bool HexoticPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh*   theMesh,
180                                                       const TopoDS_Shape& theShape)
181 {
182   return false;
183 }
184
185 //=============================================================================
186 int HexoticPlugin_Hypothesis::GetDefaultHexesMinLevel()
187 {
188   return 3;
189 }
190
191 int HexoticPlugin_Hypothesis::GetDefaultHexesMaxLevel()
192 {
193   return 8;
194 }
195
196 bool HexoticPlugin_Hypothesis::GetDefaultHexoticQuadrangles()
197 {
198   return true;
199 }