Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / MEDLoader / MEDFileMeshReadSelector.cxx
1 // Copyright (C) 2007-2020  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 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileMeshReadSelector.hxx"
22
23 using namespace MEDCoupling;
24
25 MEDFileMeshReadSelector::MEDFileMeshReadSelector():_code(0xFFFFFFFF)
26 {
27 }
28
29 MEDFileMeshReadSelector::MEDFileMeshReadSelector(unsigned int code):_code(code)
30 {
31 }
32
33 unsigned int MEDFileMeshReadSelector::getCode() const
34 {
35   return _code;
36 }
37
38 void MEDFileMeshReadSelector::setCode(unsigned int newCode)
39 {
40   _code=newCode;
41 }
42
43 bool MEDFileMeshReadSelector::isCellFamilyFieldReading() const
44 {
45   return _code & 0x00000001;
46 }
47
48 bool MEDFileMeshReadSelector::isNodeFamilyFieldReading() const
49 {
50   return _code & 0x00000002;
51 }
52
53 bool MEDFileMeshReadSelector::isCellNameFieldReading() const
54 {
55   return _code & 0x00000004;
56 }
57
58 bool MEDFileMeshReadSelector::isNodeNameFieldReading() const
59 {
60   return _code & 0x00000008;
61 }
62
63 bool MEDFileMeshReadSelector::isCellNumFieldReading() const
64 {
65   return _code & 0x00000010;
66 }
67
68 bool MEDFileMeshReadSelector::isNodeNumFieldReading() const
69 {
70   return _code & 0x00000020;
71 }
72
73 bool MEDFileMeshReadSelector::isGlobalNodeNumFieldReading() const
74 {
75   return _code & 0x00000040;
76 }
77
78 void MEDFileMeshReadSelector::setCellFamilyFieldReading(bool b)
79 {
80   unsigned int code(_code & 0xFFFFFFFE);
81   unsigned int b2=b?1:0;
82   //b2<<=0;
83   code+=b2;
84   _code=code;
85 }
86
87 void MEDFileMeshReadSelector::setNodeFamilyFieldReading(bool b)
88 {
89   unsigned int code(_code & 0xFFFFFFFD);
90   unsigned int b2=b?1:0;
91   b2<<=1;
92   code+=b2;
93   _code=code;
94 }
95
96 void MEDFileMeshReadSelector::setCellNameFieldReading(bool b)
97 {
98   unsigned int code(_code & 0xFFFFFFFB);
99   unsigned int b2=b?1:0;
100   b2<<=2;
101   code+=b2;
102   _code=code;
103 }
104
105 void MEDFileMeshReadSelector::setNodeNameFieldReading(bool b)
106 {
107   unsigned int code(_code & 0xFFFFFFF7);
108   unsigned int b2=b?1:0;
109   b2<<=3;
110   code+=b2;
111   _code=code;
112 }
113
114 void MEDFileMeshReadSelector::setCellNumFieldReading(bool b)
115 {
116   unsigned int code(_code & 0xFFFFFFEF);
117   unsigned int b2=b?1:0;
118   b2<<=4;
119   code+=b2;
120   _code=code;
121 }
122
123 void MEDFileMeshReadSelector::setNodeNumFieldReading(bool b)
124 {
125   unsigned int code(_code & 0xFFFFFFDF);
126   unsigned int b2=b?1:0;
127   b2<<=5;
128   code+=b2;
129   _code=code;
130 }
131
132 void MEDFileMeshReadSelector::setGlobalNodeNumFieldReading(bool b)
133 {
134   unsigned int code(_code & 0xFFFFFFBF);
135   unsigned int b2=b?1:0;
136   b2<<=6;
137   code+=b2;
138   _code=code;
139 }
140
141 void MEDFileMeshReadSelector::reprAll(std::ostream& str) const
142 {
143   str << "MEDFileMeshReadSelector (code=" << _code << ") : \n";
144   str << "Read family field on cells : " << ReprStatus(isCellFamilyFieldReading()) << std::endl;
145   str << "Read family field on nodes : " << ReprStatus(isNodeFamilyFieldReading()) << std::endl;
146   str << "Read name field on cells : " << ReprStatus(isCellNameFieldReading()) << std::endl;
147   str << "Read name field on nodes : " << ReprStatus(isNodeNameFieldReading()) << std::endl;
148   str << "Read number field on cells : " << ReprStatus(isCellNumFieldReading()) << std::endl;
149   str << "Read number field name on nodes : " << ReprStatus(isNodeNumFieldReading()) << std::endl;
150   str << "Read global number field name on nodes : " << ReprStatus(isGlobalNodeNumFieldReading());
151 }
152
153 std::string MEDFileMeshReadSelector::ReprStatus(bool v)
154 {
155   if(v)
156     return std::string("ON");
157   else
158     return std::string("OFF");
159 }
160