Salome HOME
updated copyright message
[plugins/hexablockplugin.git] / src / HEXABLOCKPlugin / HEXABLOCKPlugin_Hypothesis.cxx
1 // Copyright (C) 2009-2023  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, or (at your option) any later version.
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, SMESH_Gen * gen)
34   : SMESH_Hypothesis(hypId, 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 : GetXmlFlow
67 //=======================================================================
68 cpchar HEXABLOCKPlugin_Hypothesis::GetXmlFlow () const
69 {
70    return (hyp_document == NULL) ? NULL : hyp_document->getXml();
71 }
72
73 //=======================================================================
74 //function : SetDocument
75 //=======================================================================
76 void HEXABLOCKPlugin_Hypothesis::SetDocument (cpchar name)
77 {
78    hyp_document = hexa_root->findDocument (name);
79 }
80
81 //=======================================================================
82 //function : GetDimension
83 //=======================================================================
84
85 int HEXABLOCKPlugin_Hypothesis::GetDimension() const
86 {
87    return hyp_dimension;
88 }
89
90 //=======================================================================
91 //function : SetDimension
92 //=======================================================================
93
94 void HEXABLOCKPlugin_Hypothesis::SetDimension(int dim)
95 {
96    hyp_dimension = dim;
97 }
98
99 //=======================================================================
100 //function : SaveTo
101 //=======================================================================
102
103 std::ostream & HEXABLOCKPlugin_Hypothesis::SaveTo(std::ostream & save)
104 {
105 //save << hyp_document->getXML() << " ";
106   save << hyp_dimension           << " ";
107
108   return save;
109 }
110
111 //=======================================================================
112 //function : LoadFrom
113 //=======================================================================
114
115 std::istream & HEXABLOCKPlugin_Hypothesis::LoadFrom(std::istream & load)
116 {
117     bool isOK = true;
118     int i;
119
120 //     char* str;
121 //     isOK = (load >> str);
122 //     if (isOK)
123 //         hyp_document = xml_2_doc(str);
124 //     else
125 //         load.clear(std::ios::badbit | load.rdstate());
126     
127     isOK = static_cast<bool>(load >> i);
128     if (isOK)
129         hyp_dimension = i;
130     else
131         load.clear(std::ios::badbit | load.rdstate());
132     
133   return load;
134 }
135
136 //=======================================================================
137 //function : SetParametersByMesh
138 //=======================================================================
139
140 bool HEXABLOCKPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&)
141 {
142   return false;
143 }
144
145
146 //================================================================================
147 /*!
148  * \brief Return false
149  */
150 //================================================================================
151
152 bool HEXABLOCKPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  /*dflts*/,
153                                                      const SMESH_Mesh* /*theMesh*/)
154 {
155   return false;
156 }