From 35fe9db6adb88f338057faf937b64ff94080dfe8 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 1 Jul 2013 06:40:00 +0000 Subject: [PATCH] MED file mesh loading on demand. --- src/MEDLoader/CMakeLists.txt | 1 + src/MEDLoader/MEDFileMeshReadSelector.cxx | 95 +++++++++++++++++++++++ src/MEDLoader/MEDFileMeshReadSelector.hxx | 58 ++++++++++++++ src/MEDLoader/Makefile.am | 2 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 33 ++++++++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 src/MEDLoader/MEDFileMeshReadSelector.cxx create mode 100644 src/MEDLoader/MEDFileMeshReadSelector.hxx diff --git a/src/MEDLoader/CMakeLists.txt b/src/MEDLoader/CMakeLists.txt index 8666e2b55..43f3ea161 100644 --- a/src/MEDLoader/CMakeLists.txt +++ b/src/MEDLoader/CMakeLists.txt @@ -45,6 +45,7 @@ SET(medloader_SOURCES MEDFileField.cxx MEDFileParameter.cxx MEDFileData.cxx + MEDFileMeshReadSelector.cxx SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx diff --git a/src/MEDLoader/MEDFileMeshReadSelector.cxx b/src/MEDLoader/MEDFileMeshReadSelector.cxx new file mode 100644 index 000000000..9aad4e952 --- /dev/null +++ b/src/MEDLoader/MEDFileMeshReadSelector.cxx @@ -0,0 +1,95 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay (CEA/DEN) + +#include "MEDFileMeshReadSelector.hxx" + +using namespace ParaMEDMEM; + +MEDFileMeshReadSelector::MEDFileMeshReadSelector():_code(0) +{ +} + +MEDFileMeshReadSelector::MEDFileMeshReadSelector(unsigned int code):_code(code) +{ +} + +unsigned int MEDFileMeshReadSelector::getCode() const +{ + return _code; +} + +void MEDFileMeshReadSelector::setCode(unsigned int newCode) +{ + _code=newCode; +} + +bool MEDFileMeshReadSelector::isCellFamilyFieldReading() const +{ + return _code & 0x00000001; +} + +bool MEDFileMeshReadSelector::isNodeFamilyFieldReading() const +{ + return _code & 0x00000002; +} + +bool MEDFileMeshReadSelector::isCellNameFieldReading() const +{ + return _code & 0x00000004; +} + +bool MEDFileMeshReadSelector::isNodeNameFieldReading() const +{ + return _code & 0x00000008; +} + +void MEDFileMeshReadSelector::setCellFamilyFieldReading(bool b) +{ +} + +void MEDFileMeshReadSelector::setNodeFamilyFieldReading(bool b) +{ +} + +void MEDFileMeshReadSelector::setCellNameFieldReading(bool b) +{ +} + +void MEDFileMeshReadSelector::setNodeNameFieldReading(bool b) +{ +} + +void MEDFileMeshReadSelector::reprAll(std::ostream& str) const +{ + str << "MEDFileMeshReadSelector (code=" << _code << ") : \n"; + str << "Read family field on cells : " << ReprStatus(isCellFamilyFieldReading()) << std::endl; + str << "Read family field on nodes : " << ReprStatus(isNodeFamilyFieldReading()) << std::endl; + str << "Read family name on cells : " << ReprStatus(isCellNameFieldReading()) << std::endl; + str << "Read family name on nodes : " << ReprStatus(isNodeNameFieldReading()); +} + +std::string MEDFileMeshReadSelector::ReprStatus(bool v) +{ + if(v) + return std::string("ON"); + else + return std::string("OFF"); +} + diff --git a/src/MEDLoader/MEDFileMeshReadSelector.hxx b/src/MEDLoader/MEDFileMeshReadSelector.hxx new file mode 100644 index 000000000..15ac3ad6a --- /dev/null +++ b/src/MEDLoader/MEDFileMeshReadSelector.hxx @@ -0,0 +1,58 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay (CEA/DEN) + +#ifndef __MEDFILEMESHREADSELECTOR_HXX__ +#define __MEDFILEMESHREADSELECTOR_HXX__ + +#include "MEDLoaderDefines.hxx" + +#include +#include + +namespace ParaMEDMEM +{ + class MEDLOADER_EXPORT MEDFileMeshReadSelector + { + public: + MEDFileMeshReadSelector(); + MEDFileMeshReadSelector(unsigned int code); + unsigned int getCode() const; + void setCode(unsigned int newCode); + bool isCellFamilyFieldReading() const; + bool isNodeFamilyFieldReading() const; + bool isCellNameFieldReading() const; + bool isNodeNameFieldReading() const; + void setCellFamilyFieldReading(bool b); + void setNodeFamilyFieldReading(bool b); + void setCellNameFieldReading(bool b); + void setNodeNameFieldReading(bool b); + void reprAll(std::ostream& str) const; + private: + static std::string ReprStatus(bool v); + private: + //bit #0 cell family field + //bit #1 node family field + //bit #2 cell name field + //bit #3 node name field + unsigned int _code; + }; +} + +#endif diff --git a/src/MEDLoader/Makefile.am b/src/MEDLoader/Makefile.am index 3120813c4..d60916ef4 100755 --- a/src/MEDLoader/Makefile.am +++ b/src/MEDLoader/Makefile.am @@ -46,7 +46,7 @@ MEDLoader.cxx MEDLoaderBase.cxx MEDFileUtilities.cxx \ MEDFileMesh.cxx MEDFileMeshElt.cxx MEDFileBasis.cxx \ MEDFileMeshLL.cxx MEDFileField.cxx MEDFileData.cxx \ SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx \ -MEDFileParameter.cxx +MEDFileParameter.cxx MEDFileMeshReadSelector.cxx libmedloader_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ -I$(srcdir)/../INTERP_KERNEL \ diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 8e26820ea..246a1b266 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -31,6 +31,7 @@ #include "MEDFileField.hxx" #include "MEDFileParameter.hxx" #include "MEDFileData.hxx" +#include "MEDFileMeshReadSelector.hxx" #include "MEDLoaderTypemaps.i" #include "SauvReader.hxx" #include "SauvWriter.hxx" @@ -390,6 +391,38 @@ namespace ParaMEDMEM void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception); }; + class MEDFileMeshReadSelector + { + public: + MEDFileMeshReadSelector(); + MEDFileMeshReadSelector(unsigned int code); + unsigned int getCode() const; + void setCode(unsigned int newCode); + bool isCellFamilyFieldReading() const; + bool isNodeFamilyFieldReading() const; + bool isCellNameFieldReading() const; + bool isNodeNameFieldReading() const; + void setCellFamilyFieldReading(bool b); + void setNodeFamilyFieldReading(bool b); + void setCellNameFieldReading(bool b); + void setNodeNameFieldReading(bool b); + %extend + { + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; + self->reprAll(oss); + return oss.str(); + } + + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; oss << "MEDFileMeshReadSelector C++ instance at " << self << " (with code=" << self->getCode() << ")."; + return oss.str(); + } + } + }; + class MEDFileMesh : public RefCountObject, public MEDFileWritable { public: -- 2.30.2