Salome HOME
Remove dependency to MED
[plugins/hexablockplugin.git] / src / HEXABLOCKPlugin / HEXABLOCKPlugin_Hypothesis.cxx
1 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //=============================================================================
21 // File      : HEXABLOCKPlugin_Hypothesis.cxx
22 // Created   : Wed Apr  2 12:36:29 2008
23 // Author    : Lioka RAZAFINDRAZAKA (CEA)
24 //=============================================================================
25 //
26 #include "HEXABLOCKPlugin_Hypothesis.hxx"
27 #include "Hex.hxx"
28
29 //=======================================================================
30 //function : HEXABLOCKPlugin_Hypothesis
31 //=======================================================================
32
33 HEXABLOCKPlugin_Hypothesis::HEXABLOCKPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
34   : SMESH_Hypothesis(hypId, studyId, gen)
35 {
36    hexa_root     = HEXA_NS::Hex::getInstance ();
37    hyp_document  = NULL;
38    hyp_dimension = 3;
39
40    // PutData (hexa_root->countDocument ());
41
42    _name = "HEXABLOCK_Parameters";
43    _param_algo_dim = 3;
44 }
45
46 //=======================================================================
47 //function : GetDocument
48 //=======================================================================
49
50 HEXA_NS::Document* HEXABLOCKPlugin_Hypothesis::GetDocument() const
51 {
52   return hyp_document;
53 }
54
55 //=======================================================================
56 //function : SetXmlFlow
57 //=======================================================================
58 void HEXABLOCKPlugin_Hypothesis::SetXmlFlow (cpchar xml)
59 {
60    if (hyp_document ==NULL)
61        hyp_document  = hexa_root->addDocument ("tobe_meshed");
62    hyp_document->setXml (xml); 
63 }
64
65 //=======================================================================
66 //function : SetDocument
67 //=======================================================================
68 void HEXABLOCKPlugin_Hypothesis::SetDocument (cpchar name)
69 {
70    hyp_document = hexa_root->findDocument (name);
71 }
72
73 //=======================================================================
74 //function : GetDimension
75 //=======================================================================
76
77 int HEXABLOCKPlugin_Hypothesis::GetDimension() const
78 {
79    return hyp_dimension;
80 }
81
82 //=======================================================================
83 //function : SetDimension
84 //=======================================================================
85
86 void HEXABLOCKPlugin_Hypothesis::SetDimension(int dim)
87 {
88    hyp_dimension = dim;
89 }
90
91 //=======================================================================
92 //function : SaveTo
93 //=======================================================================
94
95 std::ostream & HEXABLOCKPlugin_Hypothesis::SaveTo(std::ostream & save)
96 {
97 //save << hyp_document->getXML() << " ";
98   save << hyp_dimension           << " ";
99
100   return save;
101 }
102
103 //=======================================================================
104 //function : LoadFrom
105 //=======================================================================
106
107 std::istream & HEXABLOCKPlugin_Hypothesis::LoadFrom(std::istream & load)
108 {
109     bool isOK = true;
110     int i;
111
112 //     char* str;
113 //     isOK = (load >> str);
114 //     if (isOK)
115 //         hyp_document = xml_2_doc(str);
116 //     else
117 //         load.clear(ios::badbit | load.rdstate());
118     
119     isOK = (load >> i);
120     if (isOK)
121         hyp_dimension = i;
122     else
123         load.clear(ios::badbit | load.rdstate());
124     
125   return load;
126 }
127
128 //=======================================================================
129 //function : SetParametersByMesh
130 //=======================================================================
131
132 bool HEXABLOCKPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&)
133 {
134   return false;
135 }
136
137
138 //================================================================================
139 /*!
140  * \brief Return false
141  */
142 //================================================================================
143
144 bool HEXABLOCKPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  /*dflts*/,
145                                                      const SMESH_Mesh* /*theMesh*/)
146 {
147   return false;
148 }