// Module : SMESH
//
#include "DriverMED_Family.h"
-#include "MED_Factory.hxx"
#include <sstream>
return aFamilies;
}
-//=============================================================================
-/*!
- * Create TFamilyInfo for this family
- */
-//=============================================================================
-MED::PFamilyInfo
-DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper,
- const MED::PMeshInfo& theMeshInfo) const
-{
- ostringstream aStr;
- aStr << "FAM_" << myId;
- set<string>::const_iterator aGrIter = myGroupNames.begin();
- for(; aGrIter != myGroupNames.end(); aGrIter++){
- aStr << "_" << *aGrIter;
- }
- string aValue = aStr.str();
- // PAL19785,0019867 - med forbids whitespace to be the last char in the name
- int maxSize = MED::GetNOMLength();
- int lastCharPos = min( maxSize, (int) aValue.size() ) - 1;
- while ( isspace( aValue[ lastCharPos ] ))
- aValue.resize( lastCharPos-- );
-
- MED::PFamilyInfo anInfo;
- if(myId == 0 || myGroupAttributVal == 0){
- anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
- aValue,
- myId,
- myGroupNames);
- }else{
- MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
- MED::TIntVector anAttrIds (1, myId); // Id=0,
- MED::TIntVector anAttrVals (1, myGroupAttributVal);
- anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
- aValue,
- myId,
- myGroupNames,
- anAttrDescs,
- anAttrIds,
- anAttrVals);
- }
-
-// cout << endl;
-// cout << "Groups: ";
-// set<string>::iterator aGrIter = myGroupNames.begin();
-// for (; aGrIter != myGroupNames.end(); aGrIter++)
-// {
-// cout << " " << *aGrIter;
-// }
-// cout << endl;
-//
-// cout << "Elements: ";
-// set<const SMDS_MeshElement *>::iterator anIter = myElements.begin();
-// for (; anIter != myElements.end(); anIter++)
-// {
-// cout << " " << (*anIter)->GetID();
-// }
-// cout << endl;
-
- return anInfo;
-}
-
//=============================================================================
/*!
* Initialize the tool by SMESHDS_GroupBase
const bool doAllInGroups);
//! Create TFamilyInfo for this family
+ template<class LowLevelWriter>
MED::PFamilyInfo
- GetFamilyInfo (const MED::PWrapper& theWrapper,
- const MED::PMeshInfo& theMeshInfo) const;
+ GetFamilyInfo(const LowLevelWriter& theWrapper,
+ const MED::PMeshInfo& theMeshInfo) const;
//! Returns elements of this family
const ElementsSet& GetElements () const;
ElemTypeSet myTypes; // Issue 0020576
};
+#include "MED_Factory.hxx"
+
+#include <set>
+#include <string>
+//=============================================================================
+/*!
+ * Create TFamilyInfo for this family
+ */
+//=============================================================================
+template<class LowLevelWriter>
+MED::PFamilyInfo
+DriverMED_Family::GetFamilyInfo(const LowLevelWriter& theWrapper,
+ const MED::PMeshInfo& theMeshInfo) const
+{
+ std::ostringstream aStr;
+ aStr << "FAM_" << myId;
+ std::set<std::string>::const_iterator aGrIter = myGroupNames.begin();
+ for(; aGrIter != myGroupNames.end(); aGrIter++){
+ aStr << "_" << *aGrIter;
+ }
+ std::string aValue = aStr.str();
+ // PAL19785,0019867 - med forbids whitespace to be the last char in the name
+ int maxSize = MED::GetNOMLength();
+ int lastCharPos = std::min( maxSize, (int) aValue.size() ) - 1;
+ while ( isspace( aValue[ lastCharPos ] ))
+ aValue.resize( lastCharPos-- );
+
+ MED::PFamilyInfo anInfo;
+ if(myId == 0 || myGroupAttributVal == 0){
+ anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
+ aValue,
+ myId,
+ myGroupNames);
+ }else{
+ MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
+ MED::TIntVector anAttrIds (1, myId); // Id=0,
+ MED::TIntVector anAttrVals (1, myGroupAttributVal);
+ anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
+ aValue,
+ myId,
+ myGroupNames,
+ anAttrDescs,
+ anAttrIds,
+ anAttrVals);
+ }
+
+// cout << endl;
+// cout << "Groups: ";
+// set<string>::iterator aGrIter = myGroupNames.begin();
+// for (; aGrIter != myGroupNames.end(); aGrIter++)
+// {
+// cout << " " << *aGrIter;
+// }
+// cout << endl;
+//
+// cout << "Elements: ";
+// set<const SMDS_MeshElement *>::iterator anIter = myElements.begin();
+// for (; anIter != myElements.end(); anIter++)
+// {
+// cout << " " << (*anIter)->GetID();
+// }
+// cout << endl;
+
+ return anInfo;
+}
+
#endif
#include "DriverMED_Family.h"
#include "MED_Factory.hxx"
#include "MED_Utilities.hxx"
+#include "MEDCoupling_Wrapper.hxx"
#include "SMDS_IteratorOnIterators.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
}
}
+Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
+{
+ MED::PWrapper myMed = CrWrapperW(myFile, myVersion);
+ return this->PerformInternal<MED::PWrapper>(myMed);
+}
+
+Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformMedcoupling()
+{
+ MED::MCPWrapper myMed(new MED::MCTWrapper);
+ return this->PerformInternal<MED::MCPWrapper>(myMed);
+}
+
//================================================================================
/*!
* \brief Write my mesh
*/
//================================================================================
-Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
+template<class LowLevelWriter>
+Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformInternal(LowLevelWriter myMed)
{
Status aResult = DRS_OK;
try {
}
}
- MED::PWrapper myMed = CrWrapperW(myFile, myVersion);
PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
myMed->SetMeshInfo(aMeshInfo);
list<DriverMED_FamilyPtr>::iterator aFamsIter;
for (aFamsIter = aFamilies.begin(); aFamsIter != aFamilies.end(); aFamsIter++)
{
- PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo(myMed,aMeshInfo);
+ PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo<LowLevelWriter>(myMed,aMeshInfo);
myMed->SetFamilyInfo(aFamilyInfo);
}
*/
virtual Status Perform();
+ Status PerformMedcoupling();
+
+ template<class LowLevelWriter>
+ Driver_Mesh::Status PerformInternal(LowLevelWriter myMed);
+
private:
std::list<SMESHDS_GroupBase*> myGroups;
--- /dev/null
+// Copyright (C) 2021 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
+//
+
+#pragma once
+
+#include "MED_Wrapper.hxx"
+
+#include "med.h"
+
+#include <memory>
+
+namespace MED
+{
+ class MEDWRAPPER_EXPORT MCTWrapper
+ {
+ public:
+ //! Create a MEDWrapper MED Mesh representation
+ PMeshInfo
+ CrMeshInfo(TInt theDim = 0,
+ TInt theSpaceDim = 0,
+ const std::string& theValue = "",
+ EMaillage theType = eNON_STRUCTURE,
+ const std::string& theDesc = "");
+ //! Write the MEDWrapper MED Mesh representation into the MED file
+ void
+ SetMeshInfo(const TMeshInfo& theInfo,
+ TErr* theErr = NULL);
+ //! Write a MEDWrapper MED Family representation into the MED file
+ void
+ SetFamilyInfo(const TFamilyInfo& theInfo,
+ TErr* theErr = NULL);
+ //! Create a MEDWrapper MED Nodes representation
+ PNodeInfo
+ CrNodeInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EModeSwitch theMode = eFULL_INTERLACE,
+ ERepere theSystem = eCART,
+ EBooleen theIsElemNum = eVRAI,
+ EBooleen theIsElemNames = eFAUX);
+ //! Write the MEDWrapper MED Nodes representation into the MED file
+ void
+ SetNodeInfo(const TNodeInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Family representation by its numbers
+ void
+ GetFamilyInfo(TInt theFamId,
+ TFamilyInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED Family representation
+ PFamilyInfo
+ CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ const std::string& theValue,
+ TInt theId,
+ const TStringSet& theGroupNames,
+ const TStringVector& theAttrDescs = TStringVector(),
+ const TIntVector& theAttrIds = TIntVector(),
+ const TIntVector& theAttrVals = TIntVector());
+
+ //! Create a MEDWrapper MED Polygones representation
+ virtual
+ PPolygoneInfo
+ CrPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theConnSize,
+ EConnectivite theConnMode = eNOD,
+ EBooleen theIsElemNum = eVRAI,
+ EBooleen theIsElemNames = eVRAI);
+
+ //! Create a MEDWrapper MED Polygones representation
+ virtual
+ PPolygoneInfo
+ CrPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode = eNOD,
+ const TIntVector& theFamilyNums = TIntVector(),
+ const TIntVector& theElemNums = TIntVector(),
+ const TStringVector& theElemNames = TStringVector());
+
+
+ //! Write a MEDWrapper MED Polygones representation into the MED file
+ virtual
+ void
+ SetPolygoneInfo(const TPolygoneInfo& theInfo,
+ TErr* theErr = NULL);
+
+
+ //! Create a MEDWrapper MED Polyedres representation
+ virtual
+ PPolyedreInfo
+ CrPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbFaces,
+ TInt theConnSize,
+ EConnectivite theConnMode = eNOD,
+ EBooleen theIsElemNum = eVRAI,
+ EBooleen theIsElemNames = eVRAI);
+
+
+ //! Write a MEDWrapper MED Polyedres representation into the MED file
+ virtual
+ void
+ SetPolyedreInfo(const TPolyedreInfo& theInfo,
+ TErr* theErr = NULL);
+
+
+ //! Create a MEDWrapper MED Balls representation
+ /*! This feature is supported since version 3.0 */
+ virtual
+ PBallInfo
+ CrBallInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbBalls,
+ EBooleen theIsElemNum = eVRAI);
+
+ //! Write a MEDWrapper representation of MED_BALL into the MED file
+ /*! This feature is supported since version 3.0 */
+ virtual
+ void
+ SetBallInfo(const TBallInfo& theInfo,
+ TErr* theErr = NULL);
+
+
+ //! Create a MEDWrapper MED Cells representation
+ virtual
+ PCellInfo
+ CrCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ EConnectivite theConnMode = eNOD,
+ EBooleen theIsElemNum = eVRAI,
+ EBooleen theIsElemNames = eFAUX,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Write the MEDWrapper MED Cells representation into the MED file
+ virtual
+ void
+ SetCellInfo(const TCellInfo& theInfo,
+ TErr* theErr = NULL);
+
+ };
+
+ using MCPWrapper = std::shared_ptr<MCTWrapper>;
+}
{
//----------------------------------------------------------------------------
class TFile;
- typedef boost::shared_ptr<TFile> PFile;
+ typedef std::shared_ptr<TFile> PFile;
typedef enum {eLECTURE, eLECTURE_ECRITURE, eLECTURE_AJOUT, eCREATION} EModeAcces;
//----------------------------------------------------------------------------
//! Specialization of SharedPtr for TWrapper
template<>
- class MEDWRAPPER_EXPORT SharedPtr<TWrapper>: public boost::shared_ptr<TWrapper>
+ class MEDWRAPPER_EXPORT SharedPtr<TWrapper>: public std::shared_ptr<TWrapper>
{
public:
SharedPtr() {}
SharedPtr(TWrapper* p):
- boost::shared_ptr<TWrapper>(p)
+ std::shared_ptr<TWrapper>(p)
{}
template<class Y>
explicit SharedPtr(Y* p):
- boost::shared_ptr<TWrapper>(p)
+ std::shared_ptr<TWrapper>(p)
{}
template<class Y>
SharedPtr(const SharedPtr<Y>& r):
- boost::shared_ptr<TWrapper>(boost::dynamic_pointer_cast<TWrapper,Y>(r))
+ std::shared_ptr<TWrapper>(boost::dynamic_pointer_cast<TWrapper,Y>(r))
{}
template<class Y>
TWrapper*
get() const // never throws
{
- return boost::shared_ptr<TWrapper>::get();
+ return std::shared_ptr<TWrapper>::get();
}
};
}