From 94ac7fee4ae7f4572c409eadb41e47e357a26d3a Mon Sep 17 00:00:00 2001 From: abn Date: Thu, 22 Aug 2019 12:06:25 +0200 Subject: [PATCH] ICoCo - put things in the right order: + .h files are the official definitions of the interface + .hxx files are now also part of the official definition, and forward to the .h + rename getField() into getMCField() into MEDField class for clarity --- src/ICoCo/{ICoCoField.cxx => ICoCoField.cpp} | 5 ++ src/ICoCo/ICoCoField.h | 44 ++++++++++++++++ src/ICoCo/ICoCoField.hxx | 28 ++--------- src/ICoCo/ICoCoMEDField.cxx | 8 +++ src/ICoCo/ICoCoMEDField.h | 53 ++++++++++++++++++++ src/ICoCo/ICoCoMEDField.hxx | 32 ++---------- src/ICoCo/Readme.txt | 9 ++++ src/ICoCo/Swig/ICoCoMEDField.i | 23 ++------- src/MEDCoupling/CMakeLists.txt | 7 ++- src/MEDCoupling_Swig/ICoCoMEDFieldTest.py | 4 +- src/ParaMEDMEM/DisjointDEC.cxx | 2 +- src/ParaMEDMEM/OverlapDEC.cxx | 4 +- 12 files changed, 144 insertions(+), 75 deletions(-) rename src/ICoCo/{ICoCoField.cxx => ICoCoField.cpp} (86%) create mode 100644 src/ICoCo/ICoCoField.h create mode 100644 src/ICoCo/ICoCoMEDField.h diff --git a/src/ICoCo/ICoCoField.cxx b/src/ICoCo/ICoCoField.cpp similarity index 86% rename from src/ICoCo/ICoCoField.cxx rename to src/ICoCo/ICoCoField.cpp index 645930dff..92195af6f 100644 --- a/src/ICoCo/ICoCoField.cxx +++ b/src/ICoCo/ICoCoField.cpp @@ -17,6 +17,11 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found in the TRUST repository: +// +// https://sourceforge.net/projects/trust/ + // ICoCo file common to several codes // ICoCoField.cxx // version 1.2 10/05/2010 diff --git a/src/ICoCo/ICoCoField.h b/src/ICoCo/ICoCoField.h new file mode 100644 index 000000000..9c819cfa5 --- /dev/null +++ b/src/ICoCo/ICoCoField.h @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2019 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, or (at your option) any later version. +// +// 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found in the TRUST repository: +// +// https://sourceforge.net/projects/trust/ + +#ifndef _ICoCoField_included_ +#define _ICoCoField_included_ + +#include + +namespace ICoCo { + + class Field { + public: + Field(); + virtual ~Field(); + void setName(const std::string& name); + const std::string& getName() const; + const char* getCharName() const; + + private: + std::string* _name; + }; +} +#endif diff --git a/src/ICoCo/ICoCoField.hxx b/src/ICoCo/ICoCoField.hxx index e094ddc7e..7dbd498e7 100644 --- a/src/ICoCo/ICoCoField.hxx +++ b/src/ICoCo/ICoCoField.hxx @@ -17,27 +17,9 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// ICoCo file common to several codes -// ICoCoField.h -// version 1.2 10/05/2010 - -#ifndef _ICoCoField_included_ -#define _ICoCoField_included_ -#include - - -namespace ICoCo { +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found in the TRUST repository: +// +// https://sourceforge.net/projects/trust/ - class Field { - public: - Field(); - virtual ~Field(); - void setName(const std::string& name); - const std::string& getName() const; - const char* getCharName() const; - - private: - std::string* _name; - }; -} -#endif +#include diff --git a/src/ICoCo/ICoCoMEDField.cxx b/src/ICoCo/ICoCoMEDField.cxx index 965ed06c2..77ec34977 100644 --- a/src/ICoCo/ICoCoMEDField.cxx +++ b/src/ICoCo/ICoCoMEDField.cxx @@ -23,6 +23,9 @@ namespace ICoCo { + MEDField::MEDField() : _field(0) {} + + /*! Constructor directly attaching a MEDCouplingFieldDouble the object does not take the control the objects pointed by \a field. @@ -57,6 +60,11 @@ namespace ICoCo return *this; } + MEDCoupling::MEDCouplingFieldDouble *MEDField::getMCField() const + { + return _field; + } + void MEDField::setMCField(MEDCoupling::MEDCouplingFieldDouble * f) { if(_field) diff --git a/src/ICoCo/ICoCoMEDField.h b/src/ICoCo/ICoCoMEDField.h new file mode 100644 index 000000000..a07443e3a --- /dev/null +++ b/src/ICoCo/ICoCoMEDField.h @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2019 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, or (at your option) any later version. +// +// 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found in the TRUST repository: +// +// https://sourceforge.net/projects/trust/ + +#ifndef _ICoCoMEDField_included_ +#define _ICoCoMEDField_included_ + +#include "ICoCoField.h" + +namespace MEDCoupling +{ + class MEDCouplingFieldDouble; +} + +namespace ICoCo +{ + class MEDField : public ICoCo::Field + { + public: + MEDField(); + MEDField(MEDCoupling::MEDCouplingFieldDouble* field); + MEDField(const MEDField& field); + MEDField& operator=(const MEDField& field); + virtual ~MEDField(); + MEDCoupling::MEDCouplingFieldDouble *getMCField() const; + void setMCField(MEDCoupling::MEDCouplingFieldDouble * f); + + private: + MEDCoupling::MEDCouplingFieldDouble *_field; + }; +} + +#endif diff --git a/src/ICoCo/ICoCoMEDField.hxx b/src/ICoCo/ICoCoMEDField.hxx index e460e85fa..73149ce32 100644 --- a/src/ICoCo/ICoCoMEDField.hxx +++ b/src/ICoCo/ICoCoMEDField.hxx @@ -17,31 +17,9 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef __ICOCOMEDFIELD_HXX__ -#define __ICOCOMEDFIELD_HXX__ - -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" - -#include -#include "ICoCoField.hxx" - -namespace ICoCo -{ - class MEDField : public ICoCo::Field - { - public: - MEDField():_field(0) { } - MEDField(MEDCoupling::MEDCouplingFieldDouble* field); - MEDField(const MEDField& field); - MEDField& operator=(const MEDField& field); - virtual ~MEDField(); - MEDCoupling::MEDCouplingFieldDouble *getMCField() const { return _field; } - void setMCField(MEDCoupling::MEDCouplingFieldDouble * f); - - private: - MEDCoupling::MEDCouplingFieldDouble *_field; - }; -} +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found in the TRUST repository: +// +// https://sourceforge.net/projects/trust/ -#endif +#include diff --git a/src/ICoCo/Readme.txt b/src/ICoCo/Readme.txt index 5117faae3..5e3f62e6b 100644 --- a/src/ICoCo/Readme.txt +++ b/src/ICoCo/Readme.txt @@ -1 +1,10 @@ Linked into target 'medcoupling' library. + +The files below are part of the official ICoCo API and should NOT be modified: + - ICoCoField.h + - ICoCoField.cxx + - ICoCoMEDField.h + +Their official version can be found in the TRUST repository: + + https://sourceforge.net/projects/trust/ diff --git a/src/ICoCo/Swig/ICoCoMEDField.i b/src/ICoCo/Swig/ICoCoMEDField.i index dad8b1ace..3d50cb7ee 100644 --- a/src/ICoCo/Swig/ICoCoMEDField.i +++ b/src/ICoCo/Swig/ICoCoMEDField.i @@ -18,25 +18,10 @@ // // Author : Adrien Bruneton (CEA) - %{ -#include "ICoCoMEDField.hxx" - -using namespace MEDCoupling; +#include "ICoCoMEDField.h" %} -namespace ICoCo -{ - class MEDField - { - public: - MEDField(); - MEDField(MEDCoupling::MEDCouplingFieldDouble* field); - MEDField(const MEDField& field); - MEDField& operator=(const MEDField& field); - MEDCoupling::MEDCouplingFieldDouble *getMCField() const; - void setMCField(MEDCoupling::MEDCouplingFieldDouble * f); - }; -} - - +%include "std_string.i" +%include "ICoCoField.h" +%include "ICoCoMEDField.h" diff --git a/src/MEDCoupling/CMakeLists.txt b/src/MEDCoupling/CMakeLists.txt index 42395cf21..b8d9e5d16 100644 --- a/src/MEDCoupling/CMakeLists.txt +++ b/src/MEDCoupling/CMakeLists.txt @@ -33,6 +33,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/ExprEval ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints + ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo ) SET(medcoupling_SOURCES @@ -72,7 +73,7 @@ SET(medcoupling_SOURCES MEDCouplingPartDefinition.cxx MEDCouplingSkyLineArray.cxx MEDCouplingVoronoi.cxx - ../ICoCo/ICoCoField.cxx + ../ICoCo/ICoCoField.cpp # [ABN] Yes, .cpp, this is imposed by ICoCo. ../ICoCo/ICoCoMEDField.cxx ) @@ -89,7 +90,9 @@ ADD_LIBRARY(medcouplingremapper ${medcouplingremapper_SOURCES}) TARGET_LINK_LIBRARIES(medcouplingremapper medcouplingcpp) INSTALL(TARGETS medcouplingremapper EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS}) -FILE(GLOB medcoupling_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx" "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.hxx") +FILE(GLOB medcoupling_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx" + "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.hxx" + "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.h") FILE(GLOB medcoupling_HEADERS_TXX "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") FILE(GLOB icoco_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.hxx") INSTALL(FILES ${medcoupling_HEADERS_HXX} ${medcoupling_HEADERS_TXX} ${icoco_HEADERS_HXX} MEDCouplingNatureOfFieldEnum DESTINATION ${MEDCOUPLING_INSTALL_HEADERS}) diff --git a/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py b/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py index 63210af2f..5dae2d4d1 100755 --- a/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py +++ b/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py @@ -30,7 +30,7 @@ import unittest class ICoCoMEDFieldTest(unittest.TestCase): def generate_fields(self): ## Dummy MCFieldDouble - msh = MEDCouplingCMesh() + msh = MEDCouplingCMesh("toto") msh.setCoords(DataArrayDouble([0.,1.,2.])) msh = msh.buildUnstructured() f1 = MEDCouplingFieldDouble(ON_CELLS, ONE_TIME) @@ -46,6 +46,8 @@ class ICoCoMEDFieldTest(unittest.TestCase): def test1(self): f1, f2 = self.generate_fields() mf = MEDField() + mf.setName("titi") + self.assertEqual(mf.getName(), "titi") mfd = mf.getMCField() self.assertTrue(mfd is None) mf.setMCField(f1) diff --git a/src/ParaMEDMEM/DisjointDEC.cxx b/src/ParaMEDMEM/DisjointDEC.cxx index 28b4b1dce..1a93f9779 100644 --- a/src/ParaMEDMEM/DisjointDEC.cxx +++ b/src/ParaMEDMEM/DisjointDEC.cxx @@ -307,7 +307,7 @@ namespace MEDCoupling return ; if(!field) throw INTERP_KERNEL::Exception("DisjointDEC::attachLocalField : ICoCo::MEDField pointer is NULL !"); - attachLocalField(field->getField()); + attachLocalField(field->getMCField()); } /*! diff --git a/src/ParaMEDMEM/OverlapDEC.cxx b/src/ParaMEDMEM/OverlapDEC.cxx index fe06c5290..7e62de26e 100644 --- a/src/ParaMEDMEM/OverlapDEC.cxx +++ b/src/ParaMEDMEM/OverlapDEC.cxx @@ -351,12 +351,12 @@ namespace MEDCoupling void OverlapDEC::attachSourceLocalField(ICoCo::MEDField *field) { - attachSourceLocalField(field->getField()); + attachSourceLocalField(field->getMCField()); } void OverlapDEC::attachTargetLocalField(ICoCo::MEDField *field) { - attachTargetLocalField(field->getField()); + attachTargetLocalField(field->getMCField()); } bool OverlapDEC::isInGroup() const -- 2.39.2