Salome HOME
MED file mesh loading on demand.
[tools/medcoupling.git] / src / MEDLoader / MEDFileMeshReadSelector.cxx
1 // Copyright (C) 2007-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 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileMeshReadSelector.hxx"
22
23 using namespace ParaMEDMEM;
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 void MEDFileMeshReadSelector::setCellFamilyFieldReading(bool b)
64 {
65   unsigned int code(_code & 0xFFFFFFFE);
66   unsigned int b2=b?1:0;
67   //b2<<=0;
68   code+=b2;
69   _code=code;
70 }
71
72 void MEDFileMeshReadSelector::setNodeFamilyFieldReading(bool b)
73 {
74   unsigned int code(_code & 0xFFFFFFFD);
75   unsigned int b2=b?1:0;
76   b2<<=1;
77   code+=b2;
78   _code=code;
79 }
80
81 void MEDFileMeshReadSelector::setCellNameFieldReading(bool b)
82 {
83   unsigned int code(_code & 0xFFFFFFFB);
84   unsigned int b2=b?1:0;
85   b2<<=2;
86   code+=b2;
87   _code=code;
88 }
89
90 void MEDFileMeshReadSelector::setNodeNameFieldReading(bool b)
91 {
92   unsigned int code(_code & 0xFFFFFFF7);
93   unsigned int b2=b?1:0;
94   b2<<=3;
95   code+=b2;
96   _code=code;
97 }
98
99 void MEDFileMeshReadSelector::reprAll(std::ostream& str) const
100 {
101   str << "MEDFileMeshReadSelector (code=" << _code << ") : \n";
102   str << "Read family field on cells : " << ReprStatus(isCellFamilyFieldReading()) << std::endl;
103   str << "Read family field on nodes : " << ReprStatus(isNodeFamilyFieldReading()) << std::endl;
104   str << "Read family name on cells : " << ReprStatus(isCellNameFieldReading()) << std::endl;
105   str << "Read family name on nodes : " << ReprStatus(isNodeNameFieldReading());
106 }
107
108 std::string MEDFileMeshReadSelector::ReprStatus(bool v)
109 {
110   if(v)
111     return std::string("ON");
112   else
113     return std::string("OFF");
114 }
115