1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : HexoticPlugin_Hypothesis.cxx
21 // Author : Lioka RAZAFINDRAZAKA (CEA)
24 #include <HexoticPlugin_Hypothesis.hxx>
25 #include <utilities.h>
27 //=============================================================================
31 //=============================================================================
32 HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis (int hypId, int studyId,
34 : SMESH_Hypothesis(hypId, studyId, gen),
35 _hexesMinLevel( GetDefaultHexesMinLevel() ),
36 _hexesMaxLevel( GetDefaultHexesMaxLevel() ),
37 _hexoticQuadrangles( GetDefaultHexoticQuadrangles() ),
38 _hexoticIgnoreRidges( GetDefaultHexoticIgnoreRidges() ),
39 _hexoticInvalidElements( GetDefaultHexoticInvalidElements() ),
40 _hexoticSharpAngleThreshold( GetDefaultHexoticSharpAngleThreshold() )
42 MESSAGE("HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis");
43 _name = "Hexotic_Parameters";
47 //=============================================================================
51 //=============================================================================
53 void HexoticPlugin_Hypothesis::SetHexesMinLevel(int theVal) {
54 if (theVal != _hexesMinLevel) {
55 _hexesMinLevel = theVal;
56 NotifySubMeshesHypothesisModification();
60 void HexoticPlugin_Hypothesis::SetHexesMaxLevel(int theVal) {
61 if (theVal != _hexesMaxLevel) {
62 _hexesMaxLevel = theVal;
63 NotifySubMeshesHypothesisModification();
67 void HexoticPlugin_Hypothesis::SetHexoticQuadrangles(bool theVal) {
68 if (theVal != _hexoticQuadrangles) {
69 _hexoticQuadrangles = theVal;
70 NotifySubMeshesHypothesisModification();
74 void HexoticPlugin_Hypothesis::SetHexoticIgnoreRidges(bool theVal) {
75 if (theVal != _hexoticIgnoreRidges) {
76 _hexoticIgnoreRidges = theVal;
77 NotifySubMeshesHypothesisModification();
81 void HexoticPlugin_Hypothesis::SetHexoticInvalidElements(bool theVal) {
82 if (theVal != _hexoticInvalidElements) {
83 _hexoticInvalidElements = theVal;
84 NotifySubMeshesHypothesisModification();
88 void HexoticPlugin_Hypothesis::SetHexoticSharpAngleThreshold(int theVal) {
89 if (theVal != _hexoticSharpAngleThreshold) {
90 _hexoticSharpAngleThreshold = theVal;
91 NotifySubMeshesHypothesisModification();
95 //=============================================================================
99 //=============================================================================
100 std::ostream& HexoticPlugin_Hypothesis::SaveTo(std::ostream& save)
102 /*save << _hexesMinLevel << " " << _hexesMaxLevel;
103 save << " " << (int)_hexoticQuadrangles;
104 save << " " << (int)_hexoticIgnoreRidges;
105 save << " " << (int)_hexoticInvalidElements;
106 save << " " << _hexoticSharpAngleThreshold;
107 std::cout <<std::endl;
108 std::cout << "save : " << save << std::endl;
109 std::cout << std::endl;*/
111 //explicit outputs for future code compatibility of saved .hdf
112 //save without any whitespaces!
113 save<<"hexesMinLevel="<<_hexesMinLevel<<";";
114 save<<"hexesMaxLevel="<<_hexesMaxLevel<<";";
115 save<<"hexoticQuadrangles="<<(int)_hexoticQuadrangles<<";";
116 save<<"hexoticIgnoreRidges="<<(int)_hexoticIgnoreRidges<<";";
117 save<<"hexoticInvalidElements="<<(int)_hexoticInvalidElements<<";";
118 save<<"hexoticSharpAngleThreshold="<<_hexoticSharpAngleThreshold<<";";
122 //=============================================================================
126 //=============================================================================
127 std::istream& HexoticPlugin_Hypothesis::LoadFrom(std::istream& load)
129 //explicit inputs for future code compatibility of saved .hdf
131 std::string str1,str2,str3,str4;
133 //save without any whitespaces!
134 isOK = (load >> str1);
136 //defaults values assumed
137 load.clear(std::ios::badbit | load.rdstate());
141 int len = str1.length();
143 int found = str1.find(';',pos);
144 str2 = str1.substr(pos,found-pos);
145 int eqpos = str2.find('=',0);
146 str3 = str2.substr(0,eqpos);
147 str4 = str2.substr(eqpos+1);
150 if (str3=="hexesMinLevel") _hexesMinLevel = atoi(str4.c_str());
151 if (str3=="hexesMaxLevel") _hexesMaxLevel = atoi(str4.c_str());
152 if (str3=="hexoticQuadrangles") _hexoticQuadrangles = (bool) atoi(str4.c_str());
153 if (str3=="hexoticIgnoreRidges") _hexoticIgnoreRidges = (bool) atoi(str4.c_str());
154 if (str3=="hexoticInvalidElements") _hexoticInvalidElements = (bool) atoi(str4.c_str());
155 if (str3=="hexoticSharpAngleThreshold") _hexoticSharpAngleThreshold = atoi(str4.c_str());
160 //=============================================================================
164 //=============================================================================
165 std::ostream& operator <<(std::ostream& save, HexoticPlugin_Hypothesis& hyp)
167 return hyp.SaveTo( save );
170 //=============================================================================
174 //=============================================================================
175 std::istream& operator >>(std::istream& load, HexoticPlugin_Hypothesis& hyp)
177 return hyp.LoadFrom( load );
181 //================================================================================
183 * \brief Does nothing
184 * \param theMesh - the built mesh
185 * \param theShape - the geometry of interest
186 * \retval bool - always false
188 //================================================================================
189 bool HexoticPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh,
190 const TopoDS_Shape& theShape)
194 //================================================================================
196 * \brief Initialize my parameter values by default parameters.
197 * \retval bool - true if parameter values have been successfully defined
199 //================================================================================
201 bool HexoticPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& /*dflts*/,
202 const SMESH_Mesh* /*theMesh*/)
207 //=============================================================================
208 int HexoticPlugin_Hypothesis::GetDefaultHexesMinLevel()
213 int HexoticPlugin_Hypothesis::GetDefaultHexesMaxLevel()
218 bool HexoticPlugin_Hypothesis::GetDefaultHexoticQuadrangles()
223 bool HexoticPlugin_Hypothesis::GetDefaultHexoticIgnoreRidges()
228 bool HexoticPlugin_Hypothesis::GetDefaultHexoticInvalidElements()
233 int HexoticPlugin_Hypothesis::GetDefaultHexoticSharpAngleThreshold()