# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
SET(_${PROJECT_NAME}_exposed_targets
SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
- MeshDriverSTL MeshDriverUNV MEDWrapperBase MEDWrapper MEDWrapper_V2_2
+ MeshDriverSTL MeshDriverUNV MEDWrapper
SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
SET(SMESH_MeshDriverMED MeshDriverMED)
SET(SMESH_MeshDriverSTL MeshDriverSTL)
SET(SMESH_MeshDriverUNV MeshDriverUNV)
-SET(SMESH_MEDWrapperBase MEDWrapperBase)
SET(SMESH_MEDWrapper MEDWrapper)
-SET(SMESH_MEDWrapper_V2_2 MEDWrapper_V2_2)
IF(SALOME_SMESH_ENABLE_MEFISTO)
SET(SMESH_MEFISTO2D MEFISTO2D)
ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
*/
long GetObjectId(in Object theObject);
+ /*!
+ * \brief Get version of MED format being used.
+ */
+ string GetMEDFileVersion();
+
/*!
* \brief Get MED version of the file by its name.
*/
- boolean GetMEDVersion(in string theFileName, out MED_VERSION theVersion);
+ string GetMEDVersion(in string theFileName);
+
+ /*!
+ * \brief Check compatibility of file with MED format being used.
+ */
+ boolean CheckCompatibility(in string theFileName);
/*!
* \brief Get names of meshes defined in file with the specified name.
DRS_FAIL // general failure (exception etc.)
};
- /*!
- * Enumeration for ExportToMED*()
- */
- enum MED_VERSION
- {
- MED_V2_1,
- MED_V2_2
- };
-
/*!
* \brief A structure containing information about MED file
*/
boolean HasDuplicatedGroupNamesMED();
/*!
- * Export Mesh to a MED Format file
+ * Export a Mesh to MED file.
* @params
- * - file : name of the MED file
+ * - fileName : name of the MED file
* - auto_groups : boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false.
- * - version : defines the version of format of MED file, that will be created
* - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
* - autoDimension : if @c true, a space dimension of a MED mesh can be either
* - 1D if all mesh nodes lie on OX coordinate axis, or
* - 3D in the rest cases.
* If @a autoDimension is @c false, the space dimension is always 3.
*/
- void ExportToMEDX( in string file,
- in boolean auto_groups,
- in MED_VERSION version,
- in boolean overwrite,
- in boolean autoDimension) raises (SALOME::SALOME_Exception);
+ void ExportMED( in string fileName,
+ in boolean auto_groups,
+ in boolean overwrite,
+ in boolean autoDimension) raises (SALOME::SALOME_Exception);
/*!
* Export a [part of] Mesh into a MED file
* @params
* - meshPart : a part of mesh to store
- * - file : name of the MED file
- * - version : define the version of format of MED file, that will be created
+ * - fileName : name of the MED file
* - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
* - autoDimension : if @c True, a space dimension for export is defined by mesh
* configuration; for example a planar mesh lying on XOY plane
* - 's' stands for _solids_ field.
*/
void ExportPartToMED( in SMESH_IDSource meshPart,
- in string file,
+ in string fileName,
in boolean auto_groups,
- in MED_VERSION version,
in boolean overwrite,
in boolean autoDimension,
in GEOM::ListOfFields fields,
in string geomAssocFields ) raises (SALOME::SALOME_Exception);
- /*!
- * Export Mesh to a MED Format file
- * Works, just the same as ExportToMEDX, with overwrite parameter equal to true.
- * The method is kept in order to support old functionality
- */
- void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
- raises (SALOME::SALOME_Exception);
-
- /*!
- * Export Mesh to MED_V2_1 MED format
- * Works, just the same as ExportToMEDX with MED_VERSION parameter equal to MED_V2_1
- * and overwrite parameter equal to true
- * The method is kept in order to support old functionality
- */
- void ExportMED( in string file, in boolean auto_groups )
- raises (SALOME::SALOME_Exception);
-
/*!
* Export Mesh to SAUV formatted file
* Write a temporary med file and use med2sauv
void ExportSAUV( in string file, in boolean auto_groups )
raises (SALOME::SALOME_Exception);
- /*!
- * Return string representation of a MED file version comprising nbDigits
- */
- string GetVersionString(in MED_VERSION version, in short nbDigits);
-
/*!
* Export Mesh to different Formats
* (UNV supported version is I-DEAS 10)
${CAS_INCLUDE_DIRS}
${VTK_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
- ${PROJECT_SOURCE_DIR}/src/MEDWrapper/Base
- ${PROJECT_SOURCE_DIR}/src/MEDWrapper/Factory
+ ${PROJECT_SOURCE_DIR}/src/MEDWrapper
${PROJECT_SOURCE_DIR}/src/Driver
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${Boost_LIBRARIES}
MeshDriver
MEDWrapper
- MEDWrapperBase
- MEDWrapper_V2_2
)
SET(_link_LIBRARIES_bin
}
string aValue = aStr.str();
// PAL19785,0019867 - med forbids whitespace to be the last char in the name
- int maxSize;
- //if ( theWrapper->GetVersion() == MED::eV2_1 )
- // maxSize = MED::GetNOMLength<MED::eV2_1>();
- //else
- maxSize = MED::GetNOMLength<MED::eV2_2>();
+ int maxSize = MED::GetNOMLength();
int lastCharPos = min( maxSize, (int) aValue.size() ) - 1;
while ( isspace( aValue[ lastCharPos ] ))
aValue.resize( lastCharPos-- );
#endif
myFamilies.clear();
if(MYDEBUG) MESSAGE("Perform - myFile : "<<myFile);
- PWrapper aMed = CrWrapper(myFile,true);
+ PWrapper aMed = CrWrapperR(myFile);
aResult = DRS_EMPTY;
TInt aNbMeshes = aMed->GetNbMeshes();
try {
if(MYDEBUG) MESSAGE("GetMeshNames - myFile : " << myFile);
theStatus = DRS_OK;
- PWrapper aMed = CrWrapper(myFile);
+ PWrapper aMed = CrWrapperR(myFile);
if (TInt aNbMeshes = aMed->GetNbMeshes()) {
for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
if ( !myMesh )
return addMessage("Supporting mesh not set", /*isFatal=*/true );
- MED::PWrapper medFile = MED::CrWrapper( myFile, MED::eV2_2 );
+ MED::PWrapper medFile = MED::CrWrapperW( myFile );
MED::PMeshInfo meshInfo;
if ( myMeshId > 0 )
{
DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
- myMedVersion(MED::eV2_2),
myAllSubMeshes (false),
myDoGroupOfNodes (false),
myDoGroupOfEdges (false),
myDoAllInGroups(false)
{}
-void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
- MED::EVersion theId)
-{
- Driver_SMESHDS_Mesh::SetFile(theFileName);
- myMedVersion = theId;
-}
-
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
{
Driver_SMESHDS_Mesh::SetFile(theFileName);
}
-string DriverMED_W_SMESHDS_Mesh::GetVersionString(const MED::EVersion theVersion, int theNbDigits)
-{
- TInt majeur, mineur, release;
- majeur = mineur = release = 0;
-// if ( theVersion == eV2_1 )
-// MED::GetVersionRelease<eV2_1>(majeur, mineur, release);
-// else
- MED::GetVersionRelease<eV2_2>(majeur, mineur, release);
- ostringstream name;
- if ( theNbDigits > 0 )
- name << majeur;
- if ( theNbDigits > 1 )
- name << "." << mineur;
- if ( theNbDigits > 2 )
- name << "." << release;
- return name.str();
-}
-
void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
{
myGroups.push_back(theGroup);
}
}
- MED::PWrapper myMed = CrWrapper(myFile,myMedVersion);
+ MED::PWrapper myMed = CrWrapperW(myFile);
PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
myMed->SetMeshInfo(aMeshInfo);
DriverMED_W_SMESHDS_Mesh();
- virtual void SetFile(const std::string& theFileName);
- void SetFile(const std::string& theFileName, MED::EVersion theId);
+ void SetFile(const std::string& theFileName);
void SetAutoDimension(bool toFindOutDimension) { myAutoDimension = toFindOutDimension; }
- static std::string GetVersionString(const MED::EVersion theVersion, int theNbDigits=2);
-
void AddGroupOfNodes();
void AddGroupOfEdges();
void AddGroupOfFaces();
private:
- MED::EVersion myMedVersion;
std::list<SMESHDS_GroupBase*> myGroups;
bool myAllSubMeshes;
std::vector<SMESHDS_SubMesh*> mySubMeshes;
+++ /dev/null
-# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# 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
-#
-
-# --- options ---
-# additional include directories
-INCLUDE_DIRECTORIES(
- ${HDF5_INCLUDE_DIRS}
- ${Boost_INCLUDE_DIRS}
- ${KERNEL_INCLUDE_DIRS}
- ${MEDFILE_INCLUDE_DIRS}
-)
-
-# additional preprocessor / compiler flags
-ADD_DEFINITIONS(
- ${HDF5_DEFINITIONS}
- ${BOOST_DEFINITIONS}
-)
-
-SET(_link_LIBRARIES
- ${Boost_LIBRARIES}
-)
-
-# --- headers ---
-
-# header files / no moc processing
-SET(MEDWrapperBase_HEADERS
- MED_Common.hxx
- MED_Vector.hxx
- MED_SharedPtr.hxx
- MED_SliceArray.hxx
- MED_Wrapper.hxx
- MED_TWrapper.hxx
- MED_Structures.hxx
- MED_TStructures.hxx
- MED_Algorithm.hxx
- MED_GaussUtils.hxx
- MED_CoordUtils.hxx
- MED_Utilities.hxx
- MED_GaussDef.hxx
- MED_WrapperBase.hxx
-)
-
-# --- sources ---
-
-# sources / static
-SET(MEDWrapperBase_SOURCES
- MED_Structures.cxx
- MED_Wrapper.cxx
- MED_Algorithm.cxx
- MED_GaussUtils.cxx
- MED_CoordUtils.cxx
- MED_Utilities.cxx
- MED_GaussDef.cxx
-)
-
-# --- rules ---
-
-ADD_LIBRARY(MEDWrapperBase ${MEDWrapperBase_SOURCES})
-TARGET_LINK_LIBRARIES(MEDWrapperBase ${_link_LIBRARIES})
-INSTALL(TARGETS MEDWrapperBase EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
-
-INSTALL(FILES ${MEDWrapperBase_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#include "MED_Algorithm.hxx"
-#include "MED_Wrapper.hxx"
-
-#include "MED_Utilities.hxx"
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-static int MYVALUEDEBUG = 0;
-#else
-// static int MYDEBUG = 0;
-// static int MYVALUEDEBUG = 0;
-#endif
-
-namespace MED
-{
- //---------------------------------------------------------------
- TEntity2TGeom2ElemInfo
- GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper,
- const PMeshInfo& theMeshInfo,
- const MED::TEntityInfo& theEntityInfo)
- {
- MSG(MYDEBUG,"GetElemsByEntity(...)");
- TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo;
- MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin();
- PElemInfo anElemInfo;
- TErr anErr;
- for(; anIter != theEntityInfo.end(); anIter++){
- const EEntiteMaillage& anEntity = anIter->first;
- const TGeom2Size& aGeom2Size = anIter->second;
- TGeom2ElemInfo& aGeom2ElemInfo = anEntity2TGeom2ElemInfo[anEntity];
-
- if(anEntity == eNOEUD){
- aGeom2ElemInfo[ePOINT1] = theWrapper->GetPElemInfo(theMeshInfo);
- continue;
- }
-
- TGeom2Size::const_iterator anIter2 = aGeom2Size.begin();
- for(; anIter2 != aGeom2Size.end(); anIter2++){
- const EGeometrieElement& aGeom = anIter2->first;
- aGeom2ElemInfo[aGeom] = theWrapper->GetPElemInfo(theMeshInfo,anEntity,aGeom,MED::eNOD,&anErr);
- }
- }
- ADDMSG(MYDEBUG,"\n");
- return anEntity2TGeom2ElemInfo;
- }
-
-
- //---------------------------------------------------------------
- TFamilyInfoSet
- GetFamilyInfoSet(const PWrapper& theWrapper,
- const PMeshInfo& theMeshInfo)
- {
- MSG(MYDEBUG,"GetFamilies(...)");
- TErr anErr;
- TFamilyInfoSet aFamilyInfoSet;
- TInt aNbFam = theWrapper->GetNbFamilies(*theMeshInfo);
- INITMSG(MYDEBUG,"GetNbFamilies() = "<<aNbFam<<"\n");
- for(TInt iFam = 1; iFam <= aNbFam; iFam++){
- PFamilyInfo aFamilyInfo = theWrapper->GetPFamilyInfo(theMeshInfo,iFam,&anErr);
- if(anErr >= 0)
- aFamilyInfoSet.insert(aFamilyInfo);
- }
- ADDMSG(MYDEBUG,"\n");
- return aFamilyInfoSet;
- }
-
-
- //---------------------------------------------------------------
- TGroupInfo
- GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet)
- {
- MSG(MYDEBUG,"GetFamiliesByGroup(...)");
- TGroupInfo aGroup;
- TFamilyInfoSet::const_iterator anIter = theFamilyInfoSet.begin();
- for(; anIter != theFamilyInfoSet.end(); anIter++){
- const PFamilyInfo& aFamilyInfo = *anIter;
- TInt aNbGroup = aFamilyInfo->GetNbGroup();
- for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
- aGroup[aFamilyInfo->GetGroupName(iGroup)].insert(aFamilyInfo);
- }
- }
-
-#ifdef _DEBUG_
- if(MYDEBUG){
- TGroupInfo::const_iterator anIter = aGroup.begin();
- for(; anIter != aGroup.end(); anIter++){
- const std::string& aName = anIter->first;
- INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
- const TFamilyInfoSet& aFamilyInfoSet = anIter->second;
- TFamilyInfoSet::const_iterator anFamIter = aFamilyInfoSet.begin();
- for(; anFamIter != aFamilyInfoSet.end(); anFamIter++){
- const PFamilyInfo& aFamilyInfo = *anFamIter;
- INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyInfo->GetName()<<"'\n");
- }
- }
- ADDMSG(MYDEBUG,"\n");
- }
-#endif
-
- return aGroup;
- }
-
-
- //---------------------------------------------------------------
- TFieldInfo2TimeStampInfoSet
- GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper,
- const PMeshInfo& theMeshInfo,
- const MED::TEntityInfo& theEntityInfo)
- {
- MSG(MYDEBUG,"GetFieldsByEntity(...)");
- TFieldInfo2TimeStampInfoSet aFieldInfo2TimeStampInfoSet;
- TInt aNbFields = theWrapper->GetNbFields();
- INITMSG(MYDEBUG,"GetNbFields() = "<<aNbFields<<"\n");
- for(TInt iField = 1; iField <= aNbFields; iField++){
- PFieldInfo aFieldInfo = theWrapper->GetPFieldInfo(theMeshInfo,iField);
- INITMSG(MYDEBUG,"aFieldName = '"<<aFieldInfo->GetName()<<
- "'; aNbComp = "<<aFieldInfo->GetNbComp()<<"; ");
- TGeom2Size aGeom2Size;
- EEntiteMaillage anEntity = EEntiteMaillage(-1);
- TInt aNbTimeStamps = theWrapper->GetNbTimeStamps(aFieldInfo,theEntityInfo,anEntity,aGeom2Size);
- ADDMSG(MYDEBUG,"anEntity = "<<anEntity<<"; GetNbTimeStamps = "<<aNbTimeStamps<<"\n");
- for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
- PTimeStampInfo aTimeStamp =
- theWrapper->GetPTimeStampInfo(aFieldInfo,anEntity,aGeom2Size,iTimeStamp);
- aFieldInfo2TimeStampInfoSet[aFieldInfo].insert(aTimeStamp);
- INITMSG(MYDEBUG,
- "aDt = "<<aTimeStamp->GetDt()<<
- ", Unit = \'"<<aTimeStamp->GetUnitDt()<<"\n");
- }
- }
- ADDMSG(MYDEBUG,"\n");
- return aFieldInfo2TimeStampInfoSet;
- }
-
-
- //---------------------------------------------------------------
- TEntite2TFieldInfo2TimeStampInfoSet
- GetEntite2TFieldInfo2TimeStampInfoSet(const TFieldInfo2TimeStampInfoSet& theFieldInfo2TimeStampInfoSet)
- {
- TEntite2TFieldInfo2TimeStampInfoSet anEntite2TFieldInfo2TimeStampInfoSet;
- TFieldInfo2TimeStampInfoSet::const_iterator anIter = theFieldInfo2TimeStampInfoSet.begin();
- for(; anIter != theFieldInfo2TimeStampInfoSet.end(); anIter++){
- const TTimeStampInfoSet& aTimeStampInfoSet = anIter->second;
- //const PFieldInfo& aFieldInfo = anIter->first;
- if(aTimeStampInfoSet.empty())
- continue;
- const PTimeStampInfo& aTimeStampInfo = *aTimeStampInfoSet.begin();
- anEntite2TFieldInfo2TimeStampInfoSet[ConvertEntity(aTimeStampInfo->GetEntity())].insert(*anIter);
- }
- return anEntite2TFieldInfo2TimeStampInfoSet;
- }
-
-
- //---------------------------------------------------------------
- bool
- operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight)
- {
- const MED::PFamilyInfo& aLeftInfo = boost::get<0>(theLeft);
- const MED::PFamilyInfo& aRightInfo = boost::get<0>(theRight);
- return aLeftInfo->GetId() < aRightInfo->GetId();
- }
-
-
- //---------------------------------------------------------------
- TEntity2FamilySet
- GetEntity2FamilySet(const PWrapper& theWrapper,
- const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
- const TFamilyInfoSet& theFamilyInfoSet)
- {
- MSG(MYDEBUG,"GetFamiliesByEntity(...)");
- TEntity2FamilySet anEntity2FamilySet;
-
- typedef std::map<TInt,PFamilyInfo> TId2Family;
- TId2Family anId2Family;
- TFamilyInfoSet::const_iterator anIter = theFamilyInfoSet.begin();
- for(; anIter != theFamilyInfoSet.end(); anIter++){
- const PFamilyInfo& aFamilyInfo = *anIter;
- anId2Family.insert(TId2Family::value_type(aFamilyInfo->GetId(),aFamilyInfo));
- }
-
- if(!anId2Family.empty()){
- typedef std::map<TInt,TInt> TFamilyID2Size;
- typedef std::map<EEntiteMaillage,TFamilyID2Size> TEntity2FamilyID;
- TEntity2FamilyID anEntity2FamilyID;
-
- if(!theEntity2TGeom2ElemInfo.empty()){
- TEntity2TGeom2ElemInfo::const_iterator anIter = theEntity2TGeom2ElemInfo.begin();
- for(; anIter != theEntity2TGeom2ElemInfo.end(); anIter++){
- const EEntiteMaillage& anEntity = anIter->first;
- TFamilyID2Size& aFamilyID2Size = anEntity2FamilyID[anEntity];
- const TGeom2ElemInfo& aGeom2ElemInfo = anIter->second;
- TGeom2ElemInfo::const_iterator aGeom2ElemInfoIter = aGeom2ElemInfo.begin();
- for(; aGeom2ElemInfoIter != aGeom2ElemInfo.end(); aGeom2ElemInfoIter++){
- const PElemInfo& aElemInfo = aGeom2ElemInfoIter->second;
- if(TInt aNbElem = aElemInfo->GetNbElem()){
- for(TInt i = 0; i < aNbElem; i++){
- aFamilyID2Size[aElemInfo->GetFamNum(i)] += 1;
- }
- }
- }
- }
- }
-
- if(!anEntity2FamilyID.empty()){
- TEntity2FamilyID::const_iterator anIter = anEntity2FamilyID.begin();
- for(; anIter != anEntity2FamilyID.end(); anIter++){
- const EEntiteMaillage& anEntity = anIter->first;
- INITMSG(MYDEBUG,"anEntity = "<<anEntity<<":\n");
- const TFamilyID2Size& aFamilyID2Size = anIter->second;
- TFamilyID2Size::const_iterator anIter2 = aFamilyID2Size.begin();
- for(; anIter2 != aFamilyID2Size.end(); anIter2++){
- TInt anId = anIter2->first;
- TInt aSize = anIter2->second;
- TId2Family::const_iterator anIter3 = anId2Family.find(anId);
- if(anIter3 != anId2Family.end()){
- const PFamilyInfo& aFamilyInfo = anIter3->second;
- anEntity2FamilySet[anEntity].insert(TFamilyTSize(aFamilyInfo,aSize));
- INITMSG(MYDEBUG,
- "aFamilyName = '"<<aFamilyInfo->GetName()<<
- "' anId = "<<aFamilyInfo->GetId()<<"\n");
- }
- }
- }
- }
- }
- ADDMSG(MYDEBUG,"\n");
- return anEntity2FamilySet;
- }
-
-
- //---------------------------------------------------------------
- TKey2Gauss
- GetKey2Gauss(const PWrapper& theWrapper,
- TErr* theErr,
- EModeSwitch theMode)
- {
- INITMSG(MYDEBUG,"GetKey2Gauss - theMode = "<<theMode<<std::endl);
- TKey2Gauss aKey2Gauss;
- TInt aNbGauss = theWrapper->GetNbGauss(theErr);
- for(TInt anId = 1; anId <= aNbGauss; anId++){
- TGaussInfo::TInfo aPreInfo = theWrapper->GetGaussPreInfo(anId);
- PGaussInfo anInfo = theWrapper->CrGaussInfo(aPreInfo,theMode);
- theWrapper->GetGaussInfo(anId,anInfo,theErr);
- TGaussInfo::TKey aKey = boost::get<0>(aPreInfo);
- aKey2Gauss[aKey] = anInfo;
-
-#ifdef _DEBUG_
- const EGeometrieElement& aGeom = boost::get<0>(aKey);
- const std::string& aName = boost::get<1>(aKey);
- INITMSG(MYDEBUG,
- "- aGeom = "<<aGeom<<
- "; aName = '"<<aName<<"'"<<
- std::endl);
-#endif
-
- }
- return aKey2Gauss;
- }
-
-
- //---------------------------------------------------------------
- PProfileInfo
- GetProfileInfo(const PWrapper& theWrapper,
- const std::string& theProfileName,
- TErr* theErr,
- EModeProfil theMode)
- {
- PProfileInfo anInfo;
- TInt aNbProfiles = theWrapper->GetNbProfiles(theErr);
- for(TInt anId = 1; anId <= aNbProfiles; anId++){
- TProfileInfo::TInfo aPreInfo = theWrapper->GetProfilePreInfo(anId);
- const std::string& aName = boost::get<0>(aPreInfo);
- if(aName == theProfileName)
- return theWrapper->GetPProfileInfo(anId,theMode,theErr);
- }
- return anInfo;
- }
-
-
- //---------------------------------------------------------------
- TMKey2Profile
- GetMKey2Profile(const PWrapper& theWrapper,
- TErr* theErr,
- EModeProfil theMode)
- {
- INITMSG(MYDEBUG,"GetMKey2Profile - theMode = "<<theMode<<std::endl);
- TKey2Profile aKey2Profile;
- TInt aNbProfiles = theWrapper->GetNbProfiles(theErr);
- for(TInt anId = 1; anId <= aNbProfiles; anId++){
- TProfileInfo::TInfo aPreInfo = theWrapper->GetProfilePreInfo(anId);
- PProfileInfo anInfo = theWrapper->GetPProfileInfo(anId,theMode,theErr);
- const std::string& aName = boost::get<0>(aPreInfo);
- aKey2Profile[aName] = anInfo;
-
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,
- "- aName = '"<<aName<<"'"<<
- " : "<<
- std::endl);
- TInt aNbElem = anInfo->GetSize();
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
-#endif
-
- }
- return TMKey2Profile(theMode,aKey2Profile);
- }
-
- //---------------------------------------------------------------
- EEntiteMaillage
- GetEntityByFamilyId(PGrilleInfo& theInfo,TInt theId){
- TElemNum::iterator aNodeFamIter = (theInfo->myFamNumNode).begin();
- for(;aNodeFamIter != (theInfo->myFamNumNode).end(); aNodeFamIter++){
- if(theId == *aNodeFamIter)
- return eNOEUD;
- }
- TElemNum::iterator aCellFamIter = (theInfo->myFamNum).begin();
- for(;aCellFamIter != (theInfo->myFamNum).end(); aCellFamIter++){
- if(theId == *aCellFamIter)
- return eMAILLE;
- }
- EXCEPTION(std::runtime_error, "GetEntityByFamilyId - fails");
- return EEntiteMaillage(-1);
- }
-
- TFamilyID2NbCells
- GetFamilyID2NbCells(PGrilleInfo& theInfo){
- TFamilyID2NbCells aFamily2NbCells;
- TInt aNbNodes = theInfo->myFamNumNode.size();
- TInt aNbCells = theInfo->myFamNum.size();
- for(TInt i=0; i<aNbNodes; i++) aFamily2NbCells[theInfo->GetFamNumNode(i)] = 0;
- for(TInt i=0; i<aNbCells; i++) aFamily2NbCells[theInfo->GetFamNum(i)] = 0;
- for(TInt i=0; i<aNbNodes; i++) aFamily2NbCells[theInfo->GetFamNumNode(i)] += 1;
- for(TInt i=0; i<aNbCells; i++) aFamily2NbCells[theInfo->GetFamNum(i)] += 1;
- return aFamily2NbCells;
- }
-
- EEntiteMaillage ConvertEntity(const EEntiteMaillage& aEntity){
- switch( aEntity ){
-
- case eNOEUD_ELEMENT:
- case eMAILLE: return eMAILLE; //eNOEUD_ELEMENT it is eMAILLE
-
- case eFACE:
- case eARETE:
- case eNOEUD: return aEntity; break;
- default: return EEntiteMaillage(-1);
-
- }
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_Algorithm_HeaderFile
-#define MED_Algorithm_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-#include "MED_Structures.hxx"
-
-#include <set>
-
-namespace MED
-{
- //---------------------------------------------------------------
- typedef std::map<EGeometrieElement,PElemInfo> TGeom2ElemInfo;
- typedef std::map<EEntiteMaillage,TGeom2ElemInfo> TEntity2TGeom2ElemInfo;
-
- //! Get set of TElemInfo by its geometrical type and corresponding MED ENTITY
- MEDWRAPPER_EXPORT
- TEntity2TGeom2ElemInfo
- GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper,
- const PMeshInfo& theMeshInfo,
- const MED::TEntityInfo& theEntityInfo);
-
-
- //---------------------------------------------------------------
- typedef std::set<PFamilyInfo> TFamilyInfoSet;
-
- //! Read set of MED FAMILIES for defined MED file
- MEDWRAPPER_EXPORT
- TFamilyInfoSet
- GetFamilyInfoSet(const PWrapper& theWrapper,
- const PMeshInfo& theMeshInfo);
-
-
- //---------------------------------------------------------------
- typedef boost::tuple<PFamilyInfo,TInt> TFamilyTSize;
-
- bool
- operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight);
- typedef std::set<TFamilyTSize> TFamilyTSizeSet;
-
-
- //---------------------------------------------------------------
- typedef std::map<EEntiteMaillage,TFamilyTSizeSet> TEntity2FamilySet;
-
- //! Split set of MED FAMILIES by corresponding MED ENTITY
- MEDWRAPPER_EXPORT
- TEntity2FamilySet
- GetEntity2FamilySet(const PWrapper& theWrapper,
- const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
- const TFamilyInfoSet& theFamilyInfoSet);
-
-
- //---------------------------------------------------------------
- typedef std::map<std::string,TFamilyInfoSet> TGroupInfo;
-
- //! Split the input set of MED FAMILIES by corresponding MED GROUPS
- MEDWRAPPER_EXPORT
- TGroupInfo
- GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet);
-
-
- //---------------------------------------------------------------
- typedef std::set<PTimeStampInfo> TTimeStampInfoSet;
- typedef std::map<PFieldInfo,TTimeStampInfoSet> TFieldInfo2TimeStampInfoSet;
-
- //! Read set of MED TIMESTAMPS groupped by corresponding MED FIELDS
- MEDWRAPPER_EXPORT
- TFieldInfo2TimeStampInfoSet
- GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper,
- const PMeshInfo& theMeshInfo,
- const MED::TEntityInfo& theEntityInfo);
-
-
- //---------------------------------------------------------------
- typedef std::map<EEntiteMaillage,TFieldInfo2TimeStampInfoSet> TEntite2TFieldInfo2TimeStampInfoSet;
-
- //! Split the input set of MED TIMESTAMPS by corresponding MED FIELDS and MED ENTITIES
- MEDWRAPPER_EXPORT
- TEntite2TFieldInfo2TimeStampInfoSet
- GetEntite2TFieldInfo2TimeStampInfoSet(const TFieldInfo2TimeStampInfoSet& theFieldInfo2TimeStampInfoSet);
-
-
- //---------------------------------------------------------------
- typedef std::map<TGaussInfo::TKey,PGaussInfo,TGaussInfo::TLess> TKey2Gauss;
-
- //! Read set of MED GAUSS
- MEDWRAPPER_EXPORT
- TKey2Gauss
- GetKey2Gauss(const PWrapper& theWrapper,
- TErr* theErr = NULL,
- EModeSwitch theMode = eFULL_INTERLACE);
-
-
- //---------------------------------------------------------------
- //! Get MED PROFILE by its name
- MEDWRAPPER_EXPORT
- PProfileInfo
- GetProfileInfo(const PWrapper& theWrapper,
- const std::string& theProfileName,
- TErr* theErr = NULL,
- EModeProfil theMode = eCOMPACT);
-
-
- //---------------------------------------------------------------
- typedef std::map<TProfileInfo::TKey,PProfileInfo> TKey2Profile;
- typedef boost::tuple<EModeProfil,TKey2Profile> TMKey2Profile;
-
- //! Read set of MED PROFILES
- MEDWRAPPER_EXPORT
- TMKey2Profile
- GetMKey2Profile(const PWrapper& theWrapper,
- TErr* theErr = NULL,
- EModeProfil theMode = eCOMPACT);
-
- //---------------------------------------------------------------
- //! Get Entity for Grille by family id.
- MEDWRAPPER_EXPORT
- EEntiteMaillage
- GetEntityByFamilyId(PGrilleInfo& theInfo,
- TInt theId);
-
- typedef std::map<TInt,TInt> TFamilyID2NbCells;
-
- //! Get Number of cells for theId family, for Grille
- MEDWRAPPER_EXPORT
- TFamilyID2NbCells
- GetFamilyID2NbCells(PGrilleInfo& theInfo);
-
- //! Convert eNOEUD_ELEMENT to eMAILLE
- MEDWRAPPER_EXPORT
- EEntiteMaillage
- ConvertEntity(const EEntiteMaillage& aEntity);
-
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#ifndef MED_Common_HeaderFile
-#define MED_Common_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-
-#include <string>
-#include <set>
-#include <map>
-
-#include <hdf5.h>
-
-#include <boost/tuple/tuple.hpp>
-
-#include "SALOMEconfig.h"
-
-#include "MED_Vector.hxx"
-#include "MED_SharedPtr.hxx"
-#include "MED_SliceArray.hxx"
-
-#ifdef WIN32
-#pragma warning(disable:4099)
-#endif
-
-namespace MED{
-
- enum EVersion {eVUnknown = -1, eV2_1, eV2_2};
-
- typedef enum {eFAUX, eVRAI} EBooleen ;
- typedef double TFloat;
-#if defined(HAVE_F77INT64)
- typedef long TInt;
-#else
- typedef int TInt;
-#endif
- typedef hid_t TIdt;
- typedef herr_t TErr;
-
- typedef enum {eFULL_INTERLACE, eNO_INTERLACE} EModeSwitch;
-
- typedef enum {eFLOAT64=6, eINT=24, eLONG=26 } ETypeChamp;
-
- typedef enum {eNON_STRUCTURE, eSTRUCTURE} EMaillage;
-
- typedef enum {eCART, eCYL, eSPHER} ERepere;
-
- typedef enum {eNOD, eDESC} EConnectivite ;
-
- typedef enum {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
- eQUAD4=204, eTRIA6=206, eTRIA7=207, eQUAD8=208, eQUAD9=209,eTETRA4=304,
- ePYRA5=305, ePENTA6=306, eHEXA8=308, eOCTA12=312, eTETRA10=310,
- ePYRA13=313, ePENTA15=315, eHEXA20=320, eHEXA27=327,
- ePOLYGONE=400, ePOLYGON2=420, ePOLYEDRE=500, eNONE=0,
- eBALL=1101 /*no such a type in med.h, it's just a trick*/,
- eAllGeoType=-1 } EGeometrieElement;
-
- typedef enum {eMAILLE, eFACE, eARETE, eNOEUD, eNOEUD_ELEMENT, eSTRUCT_ELEMENT} EEntiteMaillage;
-
- typedef enum {eNO_PFLMOD, eGLOBAL, eCOMPACT} EModeProfil;
-
- typedef enum {eGRILLE_CARTESIENNE, eGRILLE_POLAIRE, eGRILLE_STANDARD} EGrilleType;
-
- typedef enum {eCOOR, eCONN, eNOM, eNUM, eFAM, eCOOR_IND1, eCOOR_IND2, eCOOR_IND3} ETable;
-
- typedef TVector<TFloat> TFloatVector;
- typedef TVector<std::string> TStringVector;
- typedef TVector<TInt> TIntVector;
- typedef std::set<std::string> TStringSet;
-
- typedef std::map<EGeometrieElement,TInt> TGeom2Size;
- typedef std::map<EEntiteMaillage,TGeom2Size> TEntityInfo;
-
- typedef std::set<EGeometrieElement> TGeomSet;
- typedef std::map<EEntiteMaillage,TGeomSet> TEntity2GeomSet;
-
- MEDWRAPPER_EXPORT
- const TEntity2GeomSet&
- GetEntity2GeomSet();
-
- template<EVersion>
- TInt MEDWRAPPER_EXPORT
- GetDESCLength();
-
- template<EVersion>
- TInt MEDWRAPPER_EXPORT
- GetIDENTLength();
-
- template<EVersion>
- TInt MEDWRAPPER_EXPORT
- GetNOMLength();
-
- template<EVersion>
- TInt MEDWRAPPER_EXPORT
- GetLNOMLength();
-
- template<EVersion>
- TInt MEDWRAPPER_EXPORT
- GetPNOMLength();
-
- template<EVersion>
- void MEDWRAPPER_EXPORT
- GetVersionRelease(TInt& majeur, TInt& mineur, TInt& release);
-
- template<EVersion>
- MEDWRAPPER_EXPORT
- TInt
- GetNbConn(EGeometrieElement typmai,
- EEntiteMaillage typent,
- TInt mdim);
-
- MEDWRAPPER_EXPORT
- TInt
- GetNbNodes(EGeometrieElement typmai);
-
- struct TNameInfo;
- typedef SharedPtr<TNameInfo> PNameInfo;
-
- struct TMeshInfo;
- typedef SharedPtr<TMeshInfo> PMeshInfo;
-
- struct TFamilyInfo;
- typedef SharedPtr<TFamilyInfo> PFamilyInfo;
-
- struct TElemInfo;
- typedef SharedPtr<TElemInfo> PElemInfo;
-
- struct TNodeInfo;
- typedef SharedPtr<TNodeInfo> PNodeInfo;
-
- struct TPolygoneInfo;
- typedef SharedPtr<TPolygoneInfo> PPolygoneInfo;
-
- struct TPolyedreInfo;
- typedef SharedPtr<TPolyedreInfo> PPolyedreInfo;
-
- struct TCellInfo;
- typedef SharedPtr<TCellInfo> PCellInfo;
-
- struct TBallInfo;
- typedef SharedPtr<TBallInfo> PBallInfo;
-
- struct TFieldInfo;
- typedef SharedPtr<TFieldInfo> PFieldInfo;
-
- struct TTimeStampInfo;
- typedef SharedPtr<TTimeStampInfo> PTimeStampInfo;
-
- struct TProfileInfo;
- typedef SharedPtr<TProfileInfo> PProfileInfo;
-
- struct TGaussInfo;
- typedef SharedPtr<TGaussInfo> PGaussInfo;
-
- class TGrilleInfo;
- typedef SharedPtr<TGrilleInfo> PGrilleInfo;
-
- struct TTimeStampValueBase;
- typedef SharedPtr<TTimeStampValueBase> PTimeStampValueBase;
-
- struct TWrapper;
- typedef SharedPtr<TWrapper> PWrapper;
-}
-
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#include "MED_CoordUtils.hxx"
-#include "MED_Utilities.hxx"
-
-namespace MED
-{
-
- enum ECoordName{eX, eY, eZ, eNone};
-
- template<ECoordName TCoordId>
- TFloat
- GetCoord(const TCCoordSlice& theCoordSlice)
- {
- return theCoordSlice[TCoordId];
- }
-
- template<>
- TFloat
- GetCoord<eNone>(const TCCoordSlice& theCoordSlice)
- {
- return 0.0;
- }
-
- TGetCoord
- aXYZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eZ>
- };
-
- TGetCoord
- aXYGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eNone>
- };
-
- TGetCoord
- aYZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eY>
- };
-
- TGetCoord
- aXZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eY>
- };
-
-
- TGetCoord
- aXGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eNone>
- };
-
- TGetCoord
- aYGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eNone>
- };
-
- TGetCoord
- aZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eNone>,
- &GetCoord<eX>
- };
-
-
- //---------------------------------------------------------------
- TCoordHelper
- ::TCoordHelper(TGetCoord* theGetCoord):
- myGetCoord(theGetCoord)
- {}
-
- TFloat
- TCoordHelper
- ::GetCoord(TCCoordSlice& theCoordSlice,
- TInt theCoordId)
- {
- return (*myGetCoord[theCoordId])(theCoordSlice);
- }
-
-
- //---------------------------------------------------------------
- PCoordHelper
- GetCoordHelper(PNodeInfo theNodeInfo)
- {
- PCoordHelper aCoordHelper;
- {
- PMeshInfo aMeshInfo = theNodeInfo->GetMeshInfo();
- TInt aMeshDimension = aMeshInfo->GetDim();
- bool anIsDimPresent[3] = {false, false, false};
- for(int iDim = 0; iDim < aMeshDimension; iDim++){
- // PAL16857(SMESH not conform to the MED convention) ->
- // 1D - always along X
- // 2D - always in XOY plane
- anIsDimPresent[iDim] = iDim < aMeshDimension;
-// std::string aName = theNodeInfo->GetCoordName(iDim);
-// if ( aName.size() > 1 ) // PAL12148, aName has size 8 or 16
-// aName = aName.substr(0,1);
-// if(aName == "x" || aName == "X")
-// anIsDimPresent[eX] = true;
-// else if(aName == "y" || aName == "Y")
-// anIsDimPresent[eY] = true;
-// else if(aName == "z" || aName == "Z")
-// anIsDimPresent[eZ] = true;
- }
-
- switch(aMeshDimension){
- case 3:
- aCoordHelper.reset(new TCoordHelper(aXYZGetCoord));
- break;
- case 2:
- if(anIsDimPresent[eY] && anIsDimPresent[eZ])
- aCoordHelper.reset(new TCoordHelper(aYZGetCoord));
- else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
- aCoordHelper.reset(new TCoordHelper(aXZGetCoord));
- else
- aCoordHelper.reset(new TCoordHelper(aXYGetCoord));
- break;
- case 1:
- if(anIsDimPresent[eY])
- aCoordHelper.reset(new TCoordHelper(aYGetCoord));
- else if(anIsDimPresent[eZ])
- aCoordHelper.reset(new TCoordHelper(aZGetCoord));
- else
- aCoordHelper.reset(new TCoordHelper(aXGetCoord));
- break;
- }
- }
- return aCoordHelper;
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_CoordUtils_HeaderFile
-#define MED_CoordUtils_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-
-#include "MED_Structures.hxx"
-
-namespace MED
-{
- typedef TFloat (*TGetCoord)(const TCCoordSlice& theCoordSlice);
-
-
- //---------------------------------------------------------------
- class MEDWRAPPER_EXPORT TCoordHelper
- {
- TGetCoord* myGetCoord;
-
- public:
- TCoordHelper(TGetCoord* theGetCoord);
-
- TFloat
- GetCoord(TCCoordSlice& theCoordSlice,
- TInt theCoordId);
- };
- typedef SharedPtr<TCoordHelper> PCoordHelper;
-
-
- //---------------------------------------------------------------
- MEDWRAPPER_EXPORT
- PCoordHelper
- GetCoordHelper(PNodeInfo theNodeInfo);
-
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// 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
-//
-// File : MED_GaussDef.hxx
-// Author : Edward AGAPOV (eap)
-//
-#include "MED_GaussDef.hxx"
-#include "MED_Utilities.hxx"
-#include "MED_GaussUtils.hxx"
-
-namespace MED
-{
- using namespace std;
- using namespace MED;
- //---------------------------------------------------------------
-
- void TGaussDef::add(const double x, const double weight)
- {
- if ( dim() != 1 )
- EXCEPTION( logic_error,"dim() != 1");
- if ( myWeights.capacity() == myWeights.size() )
- EXCEPTION( logic_error,"Extra gauss point");
- myCoords.push_back( x );
- myWeights.push_back( weight );
- }
- void TGaussDef::add(const double x, const double y, const double weight)
- {
- if ( dim() != 2 )
- EXCEPTION( logic_error,"dim() != 2");
- if ( myWeights.capacity() == myWeights.size() )
- EXCEPTION( logic_error,"Extra gauss point");
- myCoords.push_back( x );
- myCoords.push_back( y );
- myWeights.push_back( weight );
- }
- void TGaussDef::add(const double x, const double y, const double z, const double weight)
- {
- if ( dim() != 3 )
- EXCEPTION( logic_error,"dim() != 3");
- if ( myWeights.capacity() == myWeights.size() )
- EXCEPTION( logic_error,"Extra gauss point");
- myCoords.push_back( x );
- myCoords.push_back( y );
- myCoords.push_back( z );
- myWeights.push_back( weight );
- }
- void TGaussDef::setRefCoords(const TShapeFun& aShapeFun)
- {
- myRefCoords.reserve( aShapeFun.myRefCoord.size() );
- myRefCoords.assign( aShapeFun.myRefCoord.begin(),
- aShapeFun.myRefCoord.end() );
- }
-
-
- //---------------------------------------------------------------
- /*!
- * \brief Fill definition of gauss points family
- */
- //---------------------------------------------------------------
-
- TGaussDef::TGaussDef(const int geom, const int nbGauss, const int variant)
- {
- myType = geom;
- myCoords .reserve( nbGauss * dim() );
- myWeights.reserve( nbGauss );
-
- switch ( geom ) {
-
- case eSEG2:
- case eSEG3:
- if (geom == eSEG2) setRefCoords( TSeg2a() );
- else setRefCoords( TSeg3a() );
- switch ( nbGauss ) {
- case 1: {
- add( 0.0, 2.0 ); break;
- }
- case 2: {
- const double a = 0.577350269189626;
- add( a, 1.0 );
- add( -a, 1.0 ); break;
- }
- case 3: {
- const double a = 0.774596669241;
- const double P1 = 1./1.8;
- const double P2 = 1./1.125;
- add( -a, P1 );
- add( 0, P2 );
- add( a, P1 ); break;
- }
- case 4: {
- const double a = 0.339981043584856, b = 0.861136311594053;
- const double P1 = 0.652145154862546, P2 = 0.347854845137454 ;
- add( a, P1 );
- add( -a, P1 );
- add( b, P2 );
- add( -b, P2 ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for SEG"<<nbGauss);
- }
- break;
-
- case eTRIA3:
- case eTRIA6:
- if ( variant == 1 ) {
- if (geom == eTRIA3) setRefCoords( TTria3b() );
- else setRefCoords( TTria6b() );
- switch ( nbGauss ) {
- case 1: { // FPG1
- add( 1/3., 1/3., 1/2. ); break;
- }
- case 3: { // FPG3
- // what about COT3 ???
- add( 1/6., 1/6., 1/6. );
- add( 2/3., 1/6., 1/6. );
- add( 1/6., 2/3., 1/6. ); break;
- }
- case 4: { // FPG4
- add( 1/5., 1/5., 25/(24*4.) );
- add( 3/5., 1/5., 25/(24*4.) );
- add( 1/5., 3/5., 25/(24*4.) );
- add( 1/3., 1/3., -27/(24*4.) ); break;
- }
- case 6: { // FPG6
- const double P1 = 0.11169079483905, P2 = 0.0549758718227661;
- const double a = 0.445948490915965, b = 0.091576213509771;
- add( b, b, P2 );
- add( 1-2*b, b, P2 );
- add( b, 1-2*b, P2 );
- add( a, 1-2*a, P1 );
- add( a, a, P1 );
- add( 1-2*a, a, P1 ); break;
- }
- case 7: { // FPG7
- const double A = 0.470142064105115;
- const double B = 0.101286507323456;
- const double P1 = 0.066197076394253;
- const double P2 = 0.062969590272413;
- add( 1/3., 1/3., 9/80. );
- add( A, A, P1 );
- add( 1-2*A, A, P1 );
- add( A, 1-2*A, P1 );
- add( B, B, P2 );
- add( 1-2*B, B, P2 );
- add( B, 1-2*B, P2 ); break;
- }
- case 12: { // FPG12
- const double A = 0.063089014491502;
- const double B = 0.249286745170910;
- const double C = 0.310352451033785;
- const double D = 0.053145049844816;
- const double P1 = 0.025422453185103;
- const double P2 = 0.058393137863189;
- const double P3 = 0.041425537809187;
- add( A, A, P1 );
- add( 1-2*A, A, P1 );
- add( A, 1-2*A, P1 );
- add( B, B, P2 );
- add( 1-2*B, B, P2 );
- add( B, 1-2*B, P2 );
- add( C, D, P3 );
- add( D, C, P3 );
- add( 1-C-D, C, P3 );
- add( 1-C-D, D, P3 );
- add( C, 1-C-D, P3 );
- add( D, 1-C-D, P3 ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for TRIA, variant 1: "
- <<nbGauss);
- }
- }
- else if ( variant == 2 ) {
- if (geom == eTRIA3) setRefCoords( TTria3a() );
- else setRefCoords( TTria6a() );
- switch ( nbGauss ) {
- case 1: {
- add( -1/3., -1/3., 2. ); break;
- }
- case 3: {
- add( -2/3., 1/3., 2/3. );
- add( -2/3., -2/3., 2/3. );
- add( 1/3., -2/3., 2/3. ); break;
- }
- case 6: {
- const double P1 = 0.11169079483905, P2 = 0.0549758718227661;
- const double A = 0.445948490915965, B = 0.091576213509771;
- add( 2*B-1, 1-4*B, 4*P2 );
- add( 2*B-1, 2*B-1, 4*P2 );
- add( 1-4*B, 2*B-1, 4*P2 );
- add( 1-4*A, 2*A-1, 4*P1 );
- add( 2*A-1, 1-4*A, 4*P1 );
- add( 2*A-1, 2*A-1, 4*P1 ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for TRIA, variant 2: "
- <<nbGauss);
- }
- }
- else if ( variant == 3 ) {
- if (geom == eTRIA3) setRefCoords( TTria3b() );
- else setRefCoords( TTria6b() );
- switch ( nbGauss ) {
- case 4: {
- add( 1/3., 1/3., -27/96 );
- add( 0.2 , 0.2 , 25/96 );
- add( 0.6 , 0.2 , 25/96 );
- add( 0.2 , 0.6 , 25/96 ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for TRIA, variant 3: "
- <<nbGauss);
- }
- }
- break;
-
- case eQUAD4:
- case eQUAD8:
- if ( variant == 1 ) {
- if (geom == eQUAD4) setRefCoords( TQuad4b() );
- else setRefCoords( TQuad8b() );
- switch ( nbGauss ) {
- case 1: { // FPG1
- add( 0, 0, 4 ); break;
- }
- case 4: { // FPG4
- const double a = 1/sqrt(3.);
- add( -a, -a, 1 );
- add( a, -a, 1 );
- add( a, a, 1 );
- add( -a, a, 1 ); break;
- }
- case 9: { // FPG9
- const double a = 0.774596669241483;
- add( -a, -a, 25/81. );
- add( a, -a, 25/81. );
- add( a, a, 25/81. );
- add( -a, a, 25/81. );
- add( 0., -a, 40/81. );
- add( a, 0., 40/81. );
- add( 0., a, 40/81. );
- add( -a, 0., 40/81. );
- add( 0., 0., 64/81. ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for QUAD, variant 1: "
- <<nbGauss);
- }
- }
- else if ( variant == 2 ) {
- if (geom == eQUAD4) setRefCoords( TQuad4a() );
- else setRefCoords( TQuad8a() );
- switch ( nbGauss ) {
- case 4: {
- const double a = 1/sqrt(3.);
- add( -a, a, 1 );
- add( -a, -a, 1 );
- add( a, -a, 1 );
- add( a, a, 1 ); break;
- }
- case 9: {
- const double a = 0.774596669241483;
- add( -a, a, 25/81. );
- add( -a, -a, 25/81. );
- add( a, -a, 25/81. );
- add( a, a, 25/81. );
- add( -a, 0., 40/81. );
- add( 0., -a, 40/81. );
- add( a, 0., 40/81. );
- add( 0., a, 40/81. );
- add( 0., 0., 64/81. ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for QUAD, variant 1: "
- <<nbGauss);
- }
- }
- else if ( variant == 3 ) {
- if (geom == eQUAD4) setRefCoords( TQuad4b() );
- else setRefCoords( TQuad8b() );
- switch ( nbGauss ) {
- case 4: {
- const double a = 3/sqrt(3.);
- add( -a, -a, 1 );
- add( -a, a, 1 );
- add( a, -a, 1 );
- add( a, a, 1 ); break;
- }
- case 9: {
- const double a = sqrt(3/5.), c1 = 5/9., c2 = 8/9.;
- const double c12 = c1*c2, c22 = c2*c2, c1c2 = c1*c2;
- add( -a, -a, c12 );
- add( -a, 0., c1c2 );
- add( -a, a, c12 );
- add( 0., -a, c1c2 );
- add( 0., 0., c22 );
- add( 0., a, c1c2 );
- add( a, -a, c12 );
- add( a, 0., c1c2 );
- add( a, a, c12 ); break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for QUAD, variant 3: "
- <<nbGauss);
- }
- }
- break;
-
- case eTETRA4:
- case eTETRA10:
- if (geom == eTETRA4) setRefCoords( TTetra4a() );
- else setRefCoords( TTetra10a() );
- switch ( nbGauss ) {
- case 4: { // FPG4
- const double a = (5 - sqrt(5.))/20., b = (5 + 3*sqrt(5.))/20.;
- add( a, a, a, 1/24. );
- add( a, a, b, 1/24. );
- add( a, b, a, 1/24. );
- add( b, a, a, 1/24. ); break;
- }
- case 5: { // FPG5
- const double a = 0.25, b = 1/6., c = 0.5;
- add( a, a, a, -2/15. );
- add( b, b, b, 3/40. );
- add( b, b, c, 3/40. );
- add( b, c, b, 3/40. );
- add( c, b, b, 3/40. ); break;
- }
- case 15: { // FPG15
- const double a = 0.25;
- const double b1 = (7 + sqrt(15.))/34., c1 = (13 + 3*sqrt(15.))/34., d = (5 - sqrt(15.))/20.;
- const double b2 = (7 - sqrt(15.))/34., c2 = (13 - 3*sqrt(15.))/34., e = (5 + sqrt(15.))/20.;
- const double P1 = (2665 - 14*sqrt(15.))/226800.;
- const double P2 = (2665 + 14*sqrt(15.))/226800.;
- add( a, a, a, 8/405.);//_____
- add( b1, b1, b1, P1 );
- add( b1, b1, c1, P1 );
- add( b1, c1, b1, P1 );
- add( c1, b1, b1, P1 );//_____
- add( b2, b2, b2, P2 );
- add( b2, b2, c2, P2 );
- add( b2, c2, b2, P2 );
- add( c2, b2, b2, P2 );//_____
- add( d, d, e, 5/567.);
- add( d, e, d, 5/567.);
- add( e, d, d, 5/567.);
- add( d, e, e, 5/567.);
- add( e, d, e, 5/567.);
- add( e, e, d, 5/567.);
- break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for TETRA: "<<nbGauss);
- }
- break;
-
- case ePYRA5:
- case ePYRA13:
- if (geom == ePYRA5) setRefCoords( TPyra5a() );
- else setRefCoords( TPyra13a() );
- switch ( nbGauss ) {
- case 5: { // FPG5
- const double h1 = 0.1531754163448146;
- const double h2 = 0.6372983346207416;
- add( .5, 0., h1, 2/15. );
- add( 0., .5, h1, 2/15. );
- add( -.5, 0., h1, 2/15. );
- add( 0., -.5, h1, 2/15. );
- add( 0., 0., h2, 2/15. ); break;
- }
- case 6: { // FPG6
- const double p1 = 0.1024890634400000 ;
- const double p2 = 0.1100000000000000 ;
- const double p3 = 0.1467104129066667 ;
- const double a = 0.5702963741068025 ;
- const double h1 = 0.1666666666666666 ;
- const double h2 = 0.08063183038464675;
- const double h3 = 0.6098484849057127 ;
- add( a, 0., h1, p1 );
- add( 0., a, h1, p1 );
- add( -a, 0., h1, p1 );
- add( 0., -a, h1, p1 );
- add( 0., 0., h2, p2 );
- add( 0., 0., h3, p3 ); break;
- }
- case 27: { // FPG27
- const double a1 = 0.788073483;
- const double b6 = 0.499369002;
- const double b1 = 0.848418011;
- const double c8 = 0.478508449;
- const double c1 = 0.652816472;
- const double d12 = 0.032303742;
- const double d1 = 1.106412899;
- double z = 1/2., fz = b1/2*(1 - z);
- add( 0., 0., z, a1 ); // 1
- add( fz, fz, z, b6 ); // 2
- add( -fz, fz, z, b6 ); // 3
- add( -fz, -fz, z, b6 ); // 4
- add( fz, -fz, z, b6 ); // 5
- z = (1 - b1)/2.;
- add( 0., 0., z, b6 ); // 6
- z = (1 + b1)/2.;
- add( 0., 0., z, b6 ); // 7
- z = (1 - c1)/2.; fz = c1*(1 - z);
- add( fz, 0., z, c8 ); // 8
- add( 0., fz, z, c8 ); // 9
- add( -fz, 0., z, c8 ); // 10
- add( 0., -fz, z, c8 ); // 11
- z = (1 + c1)/2.; fz = c1*(1 - z);
- add( fz, 0., z, c8 ); // 12
- add( 0., fz, z, c8 ); // 13
- add( -fz, 0., z, c8 ); // 14
- add( 0., -fz, z, c8 ); // 15
- z = (1 - d1)/2., fz = d1/2*(1 - z);
- add( fz, fz, z, d12); // 16
- add( -fz, fz, z, d12); // 17
- add( -fz, -fz, z, d12); // 18
- add( fz, -fz, z, d12); // 19
- z = 1/2.; fz = d1*(1 - z);
- add( fz, 0., z, d12); // 20
- add( 0., fz, z, d12); // 21
- add( -fz, 0., z, d12); // 22
- add( 0., -fz, z, d12); // 23
- z = (1 + d1)/2., fz = d1/2*(1 - z);
- add( fz, fz, z, d12); // 24
- add( -fz, fz, z, d12); // 25
- add( -fz, -fz, z, d12); // 26
- add( fz, -fz, z, d12); // 27
- break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for PYRA: "<<nbGauss);
- }
- break;
- case ePENTA6:
- case ePENTA15:
- if (geom == ePENTA6) setRefCoords( TPenta6a() );
- else setRefCoords( TPenta15a() );
- switch ( nbGauss ) {
- case 6: { // FPG6
- const double a = sqrt(3.)/3.;
- add( -a, .5, .5, 1/6. );
- add( -a, 0., .5, 1/6. );
- add( -a, .5, 0., 1/6. );
- add( a, .5, .5, 1/6. );
- add( a, 0., .5, 1/6. );
- add( a, .5, 0., 1/6. ); break;
- }
- case 8: { // FPG8
- const double a = 0.577350269189626;
- add( -a, 1/3., 1/3., -27/96. );
- add( -a, 0.6, 0.2, 25/96. );
- add( -a, 0.2, 0.6, 25/96. );
- add( -a, 0.2, 0.2, 25/96. );
- add( +a, 1/3., 1/3., -27/96. );
- add( +a, 0.6, 0.2, 25/96. );
- add( +a, 0.2, 0.6, 25/96. );
- add( +a, 0.2, 0.2, 25/96. ); break;
- }
- case 21: { // FPG21
- const double d = sqrt(3/5.), c1 = 5/9., c2 = 8/9.; // d <=> alfa
- const double a = (6 + sqrt(15.))/21.;
- const double b = (6 - sqrt(15.))/21.;
- const double P1 = (155 + sqrt(15.))/2400.;
- const double P2 = (155 - sqrt(15.))/2400.; //___
- add( -d, 1/3., 1/3., c1*9/80. );//___
- add( -d, a, a, c1*P1 );
- add( -d, 1-2*a, a, c1*P1 );
- add( -d, a, 1-2*a, c1*P1 );//___
- add( -d, b, b, c1*P2 );
- add( -d, 1-2*b, b, c1*P2 );
- add( -d, b, 1-2*b, c1*P2 );//___
- add( 0., 1/3., 1/3., c2*9/80. );//___
- add( 0., a, a, c2*P1 );
- add( 0., 1-2*a, a, c2*P1 );
- add( 0., a, 1-2*a, c2*P1 );//___
- add( 0., b, b, c2*P2 );
- add( 0., 1-2*b, b, c2*P2 );
- add( 0., b, 1-2*b, c2*P2 );//___
- add( d, 1/3., 1/3., c1*9/80. );//___
- add( d, a, a, c1*P1 );
- add( d, 1-2*a, a, c1*P1 );
- add( d, a, 1-2*a, c1*P1 );//___
- add( d, b, b, c1*P2 );
- add( d, 1-2*b, b, c1*P2 );
- add( d, b, 1-2*b, c1*P2 );//___
- break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for PENTA: " <<nbGauss);
- }
- break;
-
- case eHEXA8:
- case eHEXA20:
- if (geom == eHEXA8) setRefCoords( THexa8a() );
- else setRefCoords( THexa20a() );
- switch ( nbGauss ) {
- case 8: { // FPG8
- const double a = sqrt(3.)/3.;
- add( -a, -a, -a, 1. );
- add( -a, -a, a, 1. );
- add( -a, a, -a, 1. );
- add( -a, a, a, 1. );
- add( a, -a, -a, 1. );
- add( a, -a, a, 1. );
- add( a, a, -a, 1. );
- add( a, a, a, 1. ); break;
- }
- case 27: { // FPG27
- const double a = sqrt(3/5.), c1 = 5/9., c2 = 8/9.;
- const double c12 = c1*c1, c13 = c1*c1*c1;
- const double c22 = c2*c2, c23 = c2*c2*c2;
- add( -a, -a, -a, c13 ); // 1
- add( -a, -a, 0., c12*c2 ); // 2
- add( -a, -a, a, c13 ); // 3
- add( -a, 0., -a, c12*c2 ); // 4
- add( -a, 0., 0., c1*c22 ); // 5
- add( -a, 0., a, c12*c2 ); // 6
- add( -a, a, -a, c13 ); // 7
- add( -a, a, 0., c12*c2 ); // 8
- add( -a, a, a, c13 ); // 9
- add( 0., -a, -a, c12*c2 ); // 10
- add( 0., -a, 0., c1*c22 ); // 11
- add( 0., -a, a, c12*c2 ); // 12
- add( 0., 0., -a, c1*c22 ); // 13
- add( 0., 0., 0., c23 ); // 14
- add( 0., 0., a, c1*c22 ); // 15
- add( 0., a, -a, c12*c2 ); // 16
- add( 0., a, 0., c1*c22 ); // 17
- add( 0., a, a, c12*c2 ); // 18
- add( a, -a, -a, c13 ); // 19
- add( a, -a, 0., c12*c2 ); // 20
- add( a, -a, a, c13 ); // 21
- add( a, 0., -a, c12*c2 ); // 22
- add( a, 0., 0., c1*c22 ); // 23
- add( a, 0., a, c12*c2 ); // 24
- add( a, a, -a, c13 ); // 25
- add( a, a, 0., c12*c2 ); // 26
- add( a, a, a, c13 ); // 27
- break;
- }
- default:
- EXCEPTION( logic_error,"Invalid nb of gauss points for PENTA: " <<nbGauss);
- }
- break;
-
- default:
- EXCEPTION( logic_error,"unexpected EGeometrieElement: "<< geom);
- }
-
- if ( myWeights.capacity() != myWeights.size() )
- EXCEPTION( logic_error,"Not all gauss points defined");
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// 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
-//
-// File : MED_GaussDef.hxx
-// Author : Edward AGAPOV (eap)
-//
-#ifndef MED_GaussDef_HeaderFile
-#define MED_GaussDef_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-
-//#include "MED_GaussUtils.hxx" <<<---- avoid dependence on boost
-#include <vector>
-
-namespace MED
-{
- class TShapeFun;
- typedef std::vector<double> TDoubleVector;
- /*!
- * \brief Description of family of integration points
- */
- struct TGaussDef
- {
- int myType; //!< element geometry (EGeometrieElement or med_geometrie_element)
- TDoubleVector myRefCoords; //!< description of reference points
- TDoubleVector myCoords; //!< coordinates of Gauss points
- TDoubleVector myWeights; //!< weights, len(weights)==<nb of gauss points>
-
- /*!
- * \brief Creates definition of gauss points family
- * \param geomType - element geometry (EGeometrieElement or med_geometrie_element)
- * \param nbPoints - nb gauss point
- * \param variant - [1-3] to choose the variant of definition
- *
- * Throws in case of invalid parameters
- * variant == 1 refers to "Fonctions de forme et points d'integration
- * des elements finis" v7.4 by J. PELLET, X. DESROCHES, 15/09/05
- * variant == 2 refers to the same doc v6.4 by J.P. LEFEBVRE, X. DESROCHES, 03/07/03
- * variant == 3 refers to the same doc v6.4, second variant for 2D elements
- */
- MEDWRAPPER_EXPORT TGaussDef(const int geomType, const int nbPoints, const int variant=1);
-
- MEDWRAPPER_EXPORT int dim() const { return myType/100; }
- MEDWRAPPER_EXPORT int nbPoints() const { return myWeights.capacity(); }
-
- private:
- void add(const double x, const double weight);
- void add(const double x, const double y, const double weight);
- void add(const double x, const double y, const double z, const double weight);
- void setRefCoords(const TShapeFun& aShapeFun);
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#include "MED_GaussUtils.hxx"
-#include "MED_Utilities.hxx"
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-static int MYVALUEDEBUG = 0;
-#else
-// static int MYDEBUG = 0;
-// static int MYVALUEDEBUG = 0;
-#endif
-
-//#define _DEBUG_REF_COORDS_
-
-namespace MED
-{
- //---------------------------------------------------------------
- TGaussCoord
- ::TGaussCoord():
- TModeSwitchInfo(eFULL_INTERLACE),
- myNbElem(0),
- myNbGauss(0),
- myDim(0),
- myGaussStep(0)
- {
- }
-
- void
- TGaussCoord
- ::Init(TInt theNbElem,
- TInt theNbGauss,
- TInt theDim,
- EModeSwitch theMode)
- {
- myModeSwitch = theMode;
-
- myNbElem = theNbElem;
- myNbGauss = theNbGauss;
- myDim = theDim;
-
- myGaussStep = myNbGauss*myDim;
-
- myGaussCoord.resize(theNbElem*myGaussStep);
- }
-
-
- TInt
- TGaussCoord
- ::GetNbElem() const
- {
- return myNbElem;
- }
-
- TInt
- TGaussCoord
- ::GetNbGauss() const
- {
- return myNbGauss;
- }
-
- TInt
- TGaussCoord
- ::GetDim() const
- {
- return myDim;
- }
-
- unsigned char*
- TGaussCoord
- ::GetValuePtr()
- {
- return (unsigned char*)&(myGaussCoord[0]);
- }
-
-
- TCCoordSliceArr
- TGaussCoord
- ::GetCoordSliceArr(TInt theElemId) const
- {
- TCCoordSliceArr aCoordSliceArr(myNbGauss);
- if(GetModeSwitch() == eFULL_INTERLACE){
- TInt anId = theElemId*myGaussStep;
- for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
- aCoordSliceArr[anGaussId] =
- TCCoordSlice(myGaussCoord,std::slice(anId,myDim,1));
- anId += myDim;
- }
- }
- else{
- for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
- aCoordSliceArr[anGaussId] =
- TCCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep));
- }
- }
- return aCoordSliceArr;
- }
-
-
- TCoordSliceArr
- TGaussCoord
- ::GetCoordSliceArr(TInt theElemId)
- {
- TCoordSliceArr aCoordSliceArr(myNbGauss);
- if(GetModeSwitch() == eFULL_INTERLACE){
- TInt anId = theElemId*myGaussStep;
- for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
- aCoordSliceArr[anGaussId] =
- TCoordSlice(myGaussCoord,std::slice(anId,myDim,1));
- anId += myDim;
- }
- }
- else{
- for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
- aCoordSliceArr[anGaussId] =
- TCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep));
- }
- }
- return aCoordSliceArr;
- }
-
-
- //---------------------------------------------------------------
- inline
- bool
- IsEqual(TFloat theLeft, TFloat theRight)
- {
- static TFloat EPS = 1.0E-3;
- if(fabs(theLeft) + fabs(theRight) > EPS)
- return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS;
- return true;
- }
-
-
- //---------------------------------------------------------------
- class TShapeFun::TFun
- {
- TFloatVector myFun;
- TInt myNbRef;
-
- public:
-
- void
- Init(TInt theNbGauss,
- TInt theNbRef)
- {
- myFun.resize(theNbGauss*theNbRef);
- myNbRef = theNbRef;
- }
-
- TCFloatVecSlice
- GetFunSlice(TInt theGaussId) const
- {
- return TCFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1));
- }
-
- TFloatVecSlice
- GetFunSlice(TInt theGaussId)
- {
- return TFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1));
- }
- };
-
- //---------------------------------------------------------------
-
- TShapeFun::TShapeFun(TInt theDim, TInt theNbRef):
- myRefCoord(theNbRef*theDim),
- myDim(theDim),
- myNbRef(theNbRef)
- {}
-
- TCCoordSlice
- TShapeFun::GetCoord(TInt theRefId) const
- {
- return TCCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1));
- }
-
- TCoordSlice
- TShapeFun::GetCoord(TInt theRefId)
- {
- return TCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1));
- }
-
- void
- TShapeFun::GetFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- TInt aNbRef = theRef.size();
- TInt aNbGauss = theGauss.size();
- theFun.Init(aNbGauss,aNbRef);
- }
-
- bool
- TShapeFun::IsSatisfy(const TCCoordSliceArr& theRefCoord) const
- {
- TInt aNbRef = theRefCoord.size();
- TInt aNbRef2 = GetNbRef();
- INITMSG(MYDEBUG,"TShapeFun::IsSatisfy "<<
- "- aNbRef("<<aNbRef<<")"<<
- "; aNbRef2("<<aNbRef2<<")\n");
- bool anIsSatisfy = (aNbRef == aNbRef2);
- if(anIsSatisfy){
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- const TCCoordSlice& aCoord2 = theRefCoord[aRefId];
- TCCoordSlice aCoord = GetCoord(aRefId);
- TInt aDim = aCoord.size();
- bool anIsEqual = false;
- for(TInt anId = 0; anId < aDim; anId++){
- anIsEqual = IsEqual(aCoord[anId],aCoord2[anId]);
- if(!anIsEqual){
- anIsSatisfy = false;
- break;
- }
- }
- if(!anIsEqual){
-#ifdef _DEBUG_
- TCCoordSlice aCoord = GetCoord(aRefId);
- INITMSG(MYDEBUG,aRefId + 1<<": aCoord = {");
- TInt aDim = aCoord.size();
- for(TInt anId = 0; anId < aDim; anId++)
- ADDMSG(MYDEBUG,"\t"<<aCoord[anId]);
- const TCCoordSlice& aCoord2 = theRefCoord[aRefId];
- ADDMSG(MYDEBUG,"}\t!=\taCoord2 = {");
- for(TInt anId = 0; anId < aDim; anId++)
- ADDMSG(MYDEBUG,"\t"<<aCoord2[anId]);
- ADDMSG(MYDEBUG,"}\n");
-#endif
-#ifndef _DEBUG_
- BEGMSG(MYDEBUG,"anIsSatisfy = "<<anIsSatisfy<<"\n");
- return anIsSatisfy;
-#endif
- }
- }
- }
-
- BEGMSG(MYDEBUG,"anIsSatisfy = "<<anIsSatisfy<<"\n");
- return anIsSatisfy;
- }
-
- bool
- TShapeFun::Eval(const TCellInfo& theCellInfo,
- const TNodeInfo& theNodeInfo,
- const TElemNum& theElemNum,
- const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TGaussCoord& theGaussCoord,
- EModeSwitch theMode)
- {
- INITMSG(MYDEBUG,"TShapeFun::Eval"<<std::endl);
-
- if(IsSatisfy(theRef)){
- const PMeshInfo& aMeshInfo = theCellInfo.GetMeshInfo();
- TInt aDim = aMeshInfo->GetDim();
- TInt aNbGauss = theGauss.size();
-
- bool anIsSubMesh = !theElemNum.empty();
- TInt aNbElem;
- if(anIsSubMesh)
- aNbElem = theElemNum.size();
- else
- aNbElem = theCellInfo.GetNbElem();
-
- theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
-
- TFun aFun;
- InitFun(theRef,theGauss,aFun);
- TInt aConnDim = theCellInfo.GetConnDim();
-
- INITMSG(MYDEBUG,"aDim = "<<aDim<<
- "; aNbGauss = "<<aNbGauss<<
- "; aNbElem = "<<aNbElem<<
- "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
- std::endl);
-
- for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
- TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
- TCConnSlice aConnSlice = theCellInfo.GetConnSlice(aCellId);
- TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
-
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
- TCFloatVecSlice aFunSlice = aFun.GetFunSlice(aGaussId);
-
- for(TInt aConnId = 0; aConnId < aConnDim; aConnId++){
- TInt aNodeId = aConnSlice[aConnId] - 1;
- TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
-
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId]*aFunSlice[aConnId];
- }
- }
- }
- }
-
-#ifdef _DEBUG_
- {
- INITMSG(MYVALUEDEBUG,"theGauss: ");
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCCoordSlice aCoordSlice = theGauss[aGaussId];
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- ADDMSG(MYVALUEDEBUG,aCoordSlice[aDimId]<<" ");
- }
- ADDMSG(MYVALUEDEBUG,"} ");
- }
- ADDMSG(MYVALUEDEBUG,std::endl);
- }
- for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
- TCCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
- INITMSG(MYVALUEDEBUG,"");
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- ADDMSG(MYVALUEDEBUG,aCoordSlice[aDimId]<<" ");
- }
- ADDMSG(MYVALUEDEBUG,"} ");
- }
- ADDMSG(MYVALUEDEBUG,std::endl);
- }
-#endif
- return true;
- }
-
- return false;
- }
-
-
- //---------------------------------------------------------------
- TSeg2a::TSeg2a():TShapeFun(1,2)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; break;
- case 1: aCoord[0] = 1.0; break;
- }
- }
- }
-
- void
- TSeg2a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*(1.0 - aCoord[0]);
- aSlice[1] = 0.5*(1.0 + aCoord[0]);
- }
- }
-
-
- //---------------------------------------------------------------
- TSeg3a::TSeg3a():TShapeFun(1,3)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; break;
- case 1: aCoord[0] = 1.0; break;
- case 2: aCoord[0] = 0.0; break;
- }
- }
- }
-
- void
- TSeg3a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*(1.0 - aCoord[0])*aCoord[0];
- aSlice[1] = 0.5*(1.0 + aCoord[0])*aCoord[0];
- aSlice[2] = (1.0 + aCoord[0])*(1.0 - aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTria3a::TTria3a():
- TShapeFun(2,3)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- }
- }
- }
-
- void
- TTria3a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*(1.0 + aCoord[1]);
- aSlice[1] = -0.5*(aCoord[0] + aCoord[1]);
- aSlice[2] = 0.5*(1.0 + aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTria6a::TTria6a():TShapeFun(2,6)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
-
- case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
- case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
- }
- }
- }
-
- void
- TTria6a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*(1.0 + aCoord[1])*aCoord[1];
- aSlice[1] = 0.5*(aCoord[0] + aCoord[1])*(aCoord[0] + aCoord[1] + 1);
- aSlice[2] = 0.5*(1.0 + aCoord[0])*aCoord[0];
-
- aSlice[3] = -1.0*(1.0 + aCoord[1])*(aCoord[0] + aCoord[1]);
- aSlice[4] = -1.0*(1.0 + aCoord[0])*(aCoord[0] + aCoord[1]);
- aSlice[5] = (1.0 + aCoord[1])*(1.0 + aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTria3b::TTria3b():
- TShapeFun(2,3)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
- case 2: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
- }
- }
- }
-
- void
- TTria3b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 1.0 - aCoord[0] - aCoord[1];
- aSlice[1] = aCoord[0];
- aSlice[2] = aCoord[1];
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTria6b::TTria6b():
- TShapeFun(2,6)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
- case 2: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
-
- case 3: aCoord[0] = 0.5; aCoord[1] = 0.0; break;
- case 4: aCoord[0] = 0.5; aCoord[1] = 0.5; break;
- case 5: aCoord[0] = 0.0; aCoord[1] = 0.5; break;
- }
- }
- }
-
- void
- TTria6b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = (1.0 - aCoord[0] - aCoord[1])*(1.0 - 2.0*aCoord[0] - 2.0*aCoord[1]);
- aSlice[1] = aCoord[0]*(2.0*aCoord[0] - 1.0);
- aSlice[2] = aCoord[1]*(2.0*aCoord[1] - 1.0);
-
- aSlice[3] = 4.0*aCoord[0]*(1.0 - aCoord[0] - aCoord[1]);
- aSlice[4] = 4.0*aCoord[0]*aCoord[1];
- aSlice[5] = 4.0*aCoord[1]*(1.0 - aCoord[0] - aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TQuad4a::TQuad4a():
- TShapeFun(2,4)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
- }
- }
- }
-
- void
- TQuad4a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.25*(1.0 + aCoord[1])*(1.0 - aCoord[0]);
- aSlice[1] = 0.25*(1.0 - aCoord[1])*(1.0 - aCoord[0]);
- aSlice[2] = 0.25*(1.0 - aCoord[1])*(1.0 + aCoord[0]);
- aSlice[3] = 0.25*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TQuad8a::TQuad8a():
- TShapeFun(2,8)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
-
- case 4: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
- case 5: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
- case 6: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
- case 7: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
- }
- }
- }
-
- void
- TQuad8a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.25*(1.0 + aCoord[1])*(1.0 - aCoord[0])*(aCoord[1] - aCoord[0] - 1.0);
- aSlice[1] = 0.25*(1.0 - aCoord[1])*(1.0 - aCoord[0])*(-aCoord[1] - aCoord[0] - 1.0);
- aSlice[2] = 0.25*(1.0 - aCoord[1])*(1.0 + aCoord[0])*(-aCoord[1] + aCoord[0] - 1.0);
- aSlice[3] = 0.25*(1.0 + aCoord[1])*(1.0 + aCoord[0])*(aCoord[1] + aCoord[0] - 1.0);
-
- aSlice[4] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[1]);
- aSlice[5] = 0.5*(1.0 - aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[0]);
- aSlice[6] = 0.5*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[1]);
- aSlice[7] = 0.5*(1.0 + aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TQuad9a::TQuad9a():
- TShapeFun(2,9)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
-
- case 4: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
- case 5: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
- case 6: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
- case 7: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
-
- case 8: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
- }
- }
- }
-
- void
- TQuad9a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] - 1.0);
- aSlice[1] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] + 1.0);
- aSlice[2] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] + 1.0);
- aSlice[3] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] - 1.0);
-
- aSlice[4] = 0.5*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1]);
- aSlice[5] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0);
- aSlice[6] = 0.5*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1]);
- aSlice[7] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0);
-
- aSlice[8] = (1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TQuad4b::TQuad4b():
- TShapeFun(2,4)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
- case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
- }
- }
- }
-
- void
- TQuad4b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.25*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
- aSlice[1] = 0.25*(1.0 + aCoord[0])*(1.0 - aCoord[1]);
- aSlice[2] = 0.25*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
- aSlice[3] = 0.25*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TQuad8b::TQuad8b():
- TShapeFun(2,8)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
- case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
-
- case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
- case 6: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
- case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
- }
- }
- }
-
- void
- TQuad8b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.25*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(-1.0 - aCoord[0] - aCoord[1]);
- aSlice[1] = 0.25*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(-1.0 + aCoord[0] - aCoord[1]);
- aSlice[2] = 0.25*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(-1.0 + aCoord[0] + aCoord[1]);
- aSlice[3] = 0.25*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(-1.0 - aCoord[0] + aCoord[1]);
-
- aSlice[4] = 0.5*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]);
- aSlice[5] = 0.5*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0]);
- aSlice[6] = 0.5*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1]);
- aSlice[7] = 0.5*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0]);
-
- //aSlice[4] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
- //aSlice[5] = 0.5*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[1]);
- //aSlice[6] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
- //aSlice[7] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TQuad9b::TQuad9b():
- TShapeFun(2,9)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
- case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
-
- case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
- case 6: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
- case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
-
- case 8: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
- }
- }
- }
-
- void
- TQuad9b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] - 1.0);
- aSlice[1] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] - 1.0);
- aSlice[2] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] + 1.0);
- aSlice[3] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] + 1.0);
-
- aSlice[4] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0);
- aSlice[5] = 0.5*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1]);
- aSlice[6] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0);
- aSlice[7] = 0.5*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1]);
-
- aSlice[8] = (1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTetra4a::TTetra4a():
- TShapeFun(3,4)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TTetra4a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = aCoord[1];
- aSlice[1] = aCoord[2];
- aSlice[2] = 1.0 - aCoord[0] - aCoord[1] - aCoord[2];
- aSlice[3] = aCoord[0];
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTetra10a::TTetra10a():
- TShapeFun(3,10)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
-
- case 4: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 6: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
-
- case 7: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 8: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TTetra10a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = aCoord[1]*(2.0*aCoord[1] - 1.0);
- aSlice[1] = aCoord[2]*(2.0*aCoord[2] - 1.0);
- aSlice[2] = (1.0 - aCoord[0] - aCoord[1] - aCoord[2])*(1.0 - 2.0*aCoord[0] - 2.0*aCoord[1] - 2.0*aCoord[2]);
- aSlice[3] = aCoord[0]*(2.0*aCoord[0] - 1.0);
-
- aSlice[4] = 4.0*aCoord[1]*aCoord[2];
- aSlice[5] = 4.0*aCoord[2]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
- aSlice[6] = 4.0*aCoord[1]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
-
- aSlice[7] = 4.0*aCoord[0]*aCoord[1];
- aSlice[8] = 4.0*aCoord[0]*aCoord[2];
- aSlice[9] = 4.0*aCoord[0]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
-
-
- TTetra4b::TTetra4b():
- TShapeFun(3,4)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TTetra4b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = aCoord[1];
- aSlice[2] = aCoord[2];
- aSlice[1] = 1.0 - aCoord[0] - aCoord[1] - aCoord[2];
- aSlice[3] = aCoord[0];
- }
- }
-
-
-
- //---------------------------------------------------------------
- TTetra10b::TTetra10b():
- TShapeFun(3,10)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
-
- case 6: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 4: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
-
- case 7: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 8: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TTetra10b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = aCoord[1]*(2.0*aCoord[1] - 1.0);
- aSlice[2] = aCoord[2]*(2.0*aCoord[2] - 1.0);
- aSlice[1] = (1.0 - aCoord[0] - aCoord[1] - aCoord[2])*(1.0 - 2.0*aCoord[0] - 2.0*aCoord[1] - 2.0*aCoord[2]);
- aSlice[3] = aCoord[0]*(2.0*aCoord[0] - 1.0);
-
- aSlice[6] = 4.0*aCoord[1]*aCoord[2];
- aSlice[5] = 4.0*aCoord[2]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
- aSlice[4] = 4.0*aCoord[1]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
-
- aSlice[7] = 4.0*aCoord[0]*aCoord[1];
- aSlice[9] = 4.0*aCoord[0]*aCoord[2];
- aSlice[8] = 4.0*aCoord[0]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- THexa8a::THexa8a():
- TShapeFun(3,8)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- case 7: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- }
- }
- }
-
- void
- THexa8a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
- aSlice[1] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
- aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
- aSlice[3] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
-
- aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
- aSlice[5] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
- aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
- aSlice[7] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
- }
- }
-
-
- //---------------------------------------------------------------
- THexa20a::THexa20a(TInt theDim, TInt theNbRef):
- TShapeFun(theDim,theNbRef)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- case 7: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
-
- case 8: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 9: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
- case 10: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 11: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
- case 12: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 13: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 14: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 15: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 16: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 17: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 18: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- case 19: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- }
- }
- }
-
- void
- THexa20a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 - aCoord[0] - aCoord[1] - aCoord[2]);
- aSlice[1] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 + aCoord[0] - aCoord[1] - aCoord[2]);
- aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 + aCoord[0] + aCoord[1] - aCoord[2]);
- aSlice[3] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 - aCoord[0] + aCoord[1] - aCoord[2]);
- aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 - aCoord[0] - aCoord[1] + aCoord[2]);
- aSlice[5] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 + aCoord[0] - aCoord[1] + aCoord[2]);
- aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 + aCoord[0] + aCoord[1] + aCoord[2]);
- aSlice[7] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 - aCoord[0] + aCoord[1] + aCoord[2]);
-
- aSlice[8] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
- aSlice[9] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 - aCoord[2]);
- aSlice[10] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
- aSlice[11] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 - aCoord[2]);
- aSlice[12] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
- aSlice[13] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 - aCoord[1]);
- aSlice[14] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
- aSlice[15] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
- aSlice[16] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
- aSlice[17] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 + aCoord[2]);
- aSlice[18] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
- aSlice[19] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- THexa27a::THexa27a():
- THexa20a(3,27)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 20: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
- case 21: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 22: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 23: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 24: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 25: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 26: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- THexa27a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.125*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[1] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[2] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[3] = 0.125*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[4] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[5] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[6] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[7] = 0.125*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] + 1.0);
-
- aSlice[8] = 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[9] = 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[10]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[11]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[12]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] - 1.0)*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[13]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[14]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] + 1.0)*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[15]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] + 1.0)*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[16]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[17]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[18]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[19]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[20]= 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
- aSlice[21]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0)*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[22]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[23]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0)*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[24]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[2]*aCoord[2]);
- aSlice[25]= 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] + 1.0);
- aSlice[26]= 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[1]*aCoord[1]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- THexa8b::THexa8b():
- TShapeFun(3,8)
- {
- TInt aNbRef = GetNbRef();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 7: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- case 5: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- }
- }
- }
-
- void
- THexa8b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
- aSlice[3] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
- aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
- aSlice[1] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
-
- aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
- aSlice[7] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
- aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
- aSlice[5] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- THexa20b::THexa20b(TInt theDim, TInt theNbRef):
- TShapeFun(theDim,theNbRef)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 7: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- case 5: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
-
- case 11: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
- case 10: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
- case 9: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
- case 8: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
- case 16: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 19: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 18: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 17: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 15: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
- case 14: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 13: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
- case 12: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- }
- }
- }
-
- void
- THexa20b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 - aCoord[0] - aCoord[1] - aCoord[2]);
- aSlice[3] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 + aCoord[0] - aCoord[1] - aCoord[2]);
- aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 + aCoord[0] + aCoord[1] - aCoord[2]);
- aSlice[1] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
- (-2.0 - aCoord[0] + aCoord[1] - aCoord[2]);
- aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 - aCoord[0] - aCoord[1] + aCoord[2]);
- aSlice[7] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 + aCoord[0] - aCoord[1] + aCoord[2]);
- aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 + aCoord[0] + aCoord[1] + aCoord[2]);
- aSlice[5] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
- (-2.0 - aCoord[0] + aCoord[1] + aCoord[2]);
-
- aSlice[11] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
- aSlice[10] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 - aCoord[2]);
- aSlice[9] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
- aSlice[8] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 - aCoord[2]);
- aSlice[16] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
- aSlice[19] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 - aCoord[1]);
- aSlice[18] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
- aSlice[17] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
- aSlice[15] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
- aSlice[14] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 + aCoord[2]);
- aSlice[13] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
- aSlice[12] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPenta6a::TPenta6a():
- TShapeFun(3,6)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TPenta6a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0]);
- aSlice[1] = 0.5*aCoord[2]*(1.0 - aCoord[0]);
- aSlice[2] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
-
- aSlice[3] = 0.5*aCoord[1]*(aCoord[0] + 1.0);
- aSlice[4] = 0.5*aCoord[2]*(aCoord[0] + 1.0);
- aSlice[5] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPenta6b::TPenta6b():
- TShapeFun(3,6)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TPenta6b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0]);
- aSlice[2] = 0.5*aCoord[2]*(1.0 - aCoord[0]);
- aSlice[1] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
-
- aSlice[3] = 0.5*aCoord[1]*(aCoord[0] + 1.0);
- aSlice[5] = 0.5*aCoord[2]*(aCoord[0] + 1.0);
- aSlice[4] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPenta15a::TPenta15a():
- TShapeFun(3,15)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
-
- case 6: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 8: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 9: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 10: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 11: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 12: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 13: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 14: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TPenta15a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0])*(2.0*aCoord[1] - 2.0 - aCoord[0]);
- aSlice[1] = 0.5*aCoord[2]*(1.0 - aCoord[0])*(2.0*aCoord[2] - 2.0 - aCoord[0]);
- aSlice[2] = 0.5*(aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
-
- aSlice[3] = 0.5*aCoord[1]*(1.0 + aCoord[0])*(2.0*aCoord[1] - 2.0 + aCoord[0]);
- aSlice[4] = 0.5*aCoord[2]*(1.0 + aCoord[0])*(2.0*aCoord[2] - 2.0 + aCoord[0]);
- aSlice[5] = 0.5*(-aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(-aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
-
- aSlice[6] = 2.0*aCoord[1]*aCoord[2]*(1.0 - aCoord[0]);
- aSlice[7] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
- aSlice[8] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
-
- aSlice[9] = aCoord[1]*(1.0 - aCoord[0]*aCoord[0]);
- aSlice[10] = aCoord[2]*(1.0 - aCoord[0]*aCoord[0]);
- aSlice[11] = (1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]*aCoord[0]);
-
- aSlice[12] = 2.0*aCoord[1]*aCoord[2]*(1.0 + aCoord[0]);
- aSlice[13] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
- aSlice[14] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPenta15b::TPenta15b():
- TShapeFun(3,15)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
- case 1: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
-
- case 8: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 6: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 12: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 14: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- case 13: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 11: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 10: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 9: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- }
- }
- }
-
- void
- TPenta15b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0])*(2.0*aCoord[1] - 2.0 - aCoord[0]);
- aSlice[2] = 0.5*aCoord[2]*(1.0 - aCoord[0])*(2.0*aCoord[2] - 2.0 - aCoord[0]);
- aSlice[1] = 0.5*(aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
-
- aSlice[3] = 0.5*aCoord[1]*(1.0 + aCoord[0])*(2.0*aCoord[1] - 2.0 + aCoord[0]);
- aSlice[5] = 0.5*aCoord[2]*(1.0 + aCoord[0])*(2.0*aCoord[2] - 2.0 + aCoord[0]);
- aSlice[4] = 0.5*(-aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(-aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
-
- aSlice[8] = 2.0*aCoord[1]*aCoord[2]*(1.0 - aCoord[0]);
- aSlice[7] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
- aSlice[6] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
-
- aSlice[12] = aCoord[1]*(1.0 - aCoord[0]*aCoord[0]);
- aSlice[14] = aCoord[2]*(1.0 - aCoord[0]*aCoord[0]);
- aSlice[13] = (1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]*aCoord[0]);
-
- aSlice[11] = 2.0*aCoord[1]*aCoord[2]*(1.0 + aCoord[0]);
- aSlice[10] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
- aSlice[9] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPyra5a::TPyra5a():
- TShapeFun(3,5)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- }
- }
- }
-
- void
- TPyra5a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
- // APO & RNV:
- // Fix for 0019920: EDF 788 VISU: Bad localisation of gauss points for pyramids
- // Seems shape function for ePYRA5 elements is:
- // w0 = 0.25*(-X + Y - 1.0)*(-X - Y - 1.0)*(1.0 - Z);
- // w1 = 0.25*(-X - Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
- // w2 = 0.25*(+X + Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
- // w3 = 0.25*(+X + Y - 1.0)*(-X + Y - 1.0)*(1.0 - Z);
- // w4 = +Z;
- aSlice[0] = 0.25*(-aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[1] = 0.25*(-aCoord[0] - aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[2] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[3] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] + aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[4] = aCoord[2];
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPyra5b::TPyra5b():
- TShapeFun(3,5)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
- }
- }
- }
-
- void
- TPyra5b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
- // APO & RNV:
- // Fix for 0019920: EDF 788 VISU: Bad localisation of gauss points for pyramids
- // Seems shape function for ePYRA5 elements is:
- // w0 = 0.25*(-X + Y - 1.0)*(-X - Y - 1.0)*(1.0 - Z);
- // w1 = 0.25*(-X - Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
- // w2 = 0.25*(+X + Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
- // w3 = 0.25*(+X + Y - 1.0)*(-X + Y - 1.0)*(1.0 - Z);
- // w4 = +Z;
- aSlice[0] = 0.25*(-aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[3] = 0.25*(-aCoord[0] - aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[2] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[1] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] + aCoord[1] - 1.0)*(1.0 - aCoord[2]);
- aSlice[4] = aCoord[2];
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPyra13a::TPyra13a():
- TShapeFun(3,13)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
-
- case 5: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 6: aCoord[0] = -0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 7: aCoord[0] = -0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
- case 8: aCoord[0] = 0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
- case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 10: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 11: aCoord[0] = -0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 12: aCoord[0] = 0.0; aCoord[1] = -0.5; aCoord[2] = 0.5; break;
- }
- }
- }
-
- void
- TPyra13a::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[0] - 0.5)/(1.0 - aCoord[2]);
- aSlice[1] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[1] - 0.5)/(1.0 - aCoord[2]);
- aSlice[2] = 0.5*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[0] - 0.5)/(1.0 - aCoord[2]);
- aSlice[3] = 0.5*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[1] - 0.5)/(1.0 - aCoord[2]);
-
- aSlice[4] = 2.0*aCoord[2]*(aCoord[2] - 0.5);
-
- aSlice[5] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
- aSlice[6] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
- aSlice[7] = 0.5*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
- aSlice[8] = 0.5*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
-
- aSlice[9] = 0.5*aCoord[2]*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- aSlice[10] = 0.5*aCoord[2]*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- aSlice[11] = 0.5*aCoord[2]*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- aSlice[12] = 0.5*aCoord[2]*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- TPyra13b::TPyra13b():
- TShapeFun(3,13)
- {
- TInt aNbRef = myRefCoord.size();
- for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
- TCoordSlice aCoord = GetCoord(aRefId);
- switch(aRefId){
- case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 3: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
- case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
- case 1: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
- case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
-
- case 8: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 7: aCoord[0] = -0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
- case 6: aCoord[0] = -0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
- case 5: aCoord[0] = 0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
- case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 12: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
- case 11: aCoord[0] = -0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
- case 10: aCoord[0] = 0.0; aCoord[1] = -0.5; aCoord[2] = 0.5; break;
- }
- }
- }
-
- void
- TPyra13b::InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const
- {
- GetFun(theRef,theGauss,theFun);
-
- TInt aNbGauss = theGauss.size();
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- const TCCoordSlice& aCoord = theGauss[aGaussId];
- TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
-
- aSlice[0] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[0] - 0.5)/(1.0 - aCoord[2]);
- aSlice[3] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[1] - 0.5)/(1.0 - aCoord[2]);
- aSlice[2] = 0.5*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[0] - 0.5)/(1.0 - aCoord[2]);
- aSlice[1] = 0.5*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[1] - 0.5)/(1.0 - aCoord[2]);
-
- aSlice[4] = 2.0*aCoord[2]*(aCoord[2] - 0.5);
-
- aSlice[8] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
- aSlice[7] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
- (aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
- aSlice[6] = 0.5*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
- aSlice[5] = 0.5*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
- (-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
-
- aSlice[9] = 0.5*aCoord[2]*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- aSlice[12] = 0.5*aCoord[2]*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- aSlice[11] = 0.5*aCoord[2]*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- aSlice[10] = 0.5*aCoord[2]*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
- (1.0 - aCoord[2]);
- }
- }
-
-
-
- //---------------------------------------------------------------
- bool
- GetGaussCoord3D(const TGaussInfo& theGaussInfo,
- const TCellInfo& theCellInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum,
- EModeSwitch theMode)
- {
- INITMSG(MYDEBUG,"GetGaussCoord3D\n");
-
- if(theGaussInfo.myGeom == theCellInfo.myGeom){
- EGeometrieElement aGeom = theGaussInfo.myGeom;
-
- TInt aNbRef = theGaussInfo.GetNbRef();
- TCCoordSliceArr aRefSlice(aNbRef);
- for(TInt anId = 0; anId < aNbRef; anId++)
- aRefSlice[anId] = theGaussInfo.GetRefCoordSlice(anId);
-
- TInt aNbGauss = theGaussInfo.GetNbGauss();
- TCCoordSliceArr aGaussSlice(aNbGauss);
- for(TInt anId = 0; anId < aNbGauss; anId++)
- aGaussSlice[anId] = theGaussInfo.GetGaussCoordSlice(anId);
-
- switch(aGeom){
- case eSEG2: {
- INITMSG(MYDEBUG,"eSEG2"<<std::endl);
-
- if(TSeg2a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eSEG3: {
- INITMSG(MYDEBUG,"eSEG3"<<std::endl);
-
- if(TSeg3a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eTRIA3: {
- INITMSG(MYDEBUG,"eTRIA3"<<std::endl);
-
- if(TTria3a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TTria3b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eTRIA6: {
- INITMSG(MYDEBUG,"eTRIA6"<<std::endl);
-
- if(TTria6a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TTria6b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eQUAD4: {
- INITMSG(MYDEBUG,"eQUAD4"<<std::endl);
-
- if(TQuad4a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TQuad4b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eQUAD8: {
- INITMSG(MYDEBUG,"eQUAD8"<<std::endl);
-
- if(TQuad8a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TQuad8b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eQUAD9: {
- INITMSG(MYDEBUG,"eQUAD9"<<std::endl);
-
- if(TQuad9a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TQuad9b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eTETRA4: {
- INITMSG(MYDEBUG,"eTETRA4"<<std::endl);
-
- if(TTetra4a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TTetra4b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case ePYRA5: {
- INITMSG(MYDEBUG,"ePYRA5"<<std::endl);
-
- if(TPyra5a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TPyra5b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case ePENTA6: {
- INITMSG(MYDEBUG,"ePENTA6"<<std::endl);
-
- if(TPenta6a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TPenta6b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eHEXA8: {
- INITMSG(MYDEBUG,"eHEXA8"<<std::endl);
-
- if(THexa8a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(THexa8b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eTETRA10: {
- INITMSG(MYDEBUG,"eTETRA10"<<std::endl);
-
- if(TTetra10a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TTetra10b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case ePYRA13: {
- INITMSG(MYDEBUG,"ePYRA13"<<std::endl);
-
- if(TPyra13a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TPyra13b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case ePENTA15: {
- INITMSG(MYDEBUG,"ePENTA15"<<std::endl);
-
- if(TPenta15a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(TPenta15b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- case eHEXA20: {
- INITMSG(MYDEBUG,"eHEXA20"<<std::endl);
-
- if(THexa20a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- if(THexa20b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
- return true;
-
- break;
- }
- default:
- INITMSG(MYDEBUG,"eNONE"<<std::endl);
- return false;
- }
- }
-
- return false;
- }
-
- //---------------------------------------------------------------
- bool
- GetBaryCenter(const TCellInfo& theCellInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum,
- EModeSwitch theMode)
- {
- INITMSG(MYDEBUG,"GetBaryCenter\n");
- const PMeshInfo& aMeshInfo = theCellInfo.GetMeshInfo();
- TInt aDim = aMeshInfo->GetDim();
- static TInt aNbGauss = 1;
-
- bool anIsSubMesh = !theElemNum.empty();
- TInt aNbElem;
- if(anIsSubMesh)
- aNbElem = theElemNum.size();
- else
- aNbElem = theCellInfo.GetNbElem();
-
- theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
-
- TInt aConnDim = theCellInfo.GetConnDim();
-
- INITMSGA(MYDEBUG,0,
- "- aDim = "<<aDim<<
- "; aNbGauss = "<<aNbGauss<<
- "; aNbElem = "<<aNbElem<<
- "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
- std::endl);
-
- for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
- TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
- TCConnSlice aConnSlice = theCellInfo.GetConnSlice(aCellId);
- TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
-
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
-
- for(TInt aConnId = 0; aConnId < aConnDim; aConnId++){
- TInt aNodeId = aConnSlice[aConnId] - 1;
- TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
-
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId];
- }
- }
-
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] /= aConnDim;
- }
- }
- }
-
-#ifdef _DEBUG_
- for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
- TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
- INITMSG(MYVALUEDEBUG,"");
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCoordSlice& aCoordSlice = aCoordSliceArr[aGaussId];
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- ADDMSG(MYVALUEDEBUG,aCoordSlice[aDimId]<<" ");
- }
- ADDMSG(MYVALUEDEBUG,"} ");
- }
- ADDMSG(MYVALUEDEBUG,std::endl);
- }
-#endif
-
- return true;
- }
-
-
- //---------------------------------------------------------------
- bool
- GetBaryCenter(const TPolygoneInfo& thePolygoneInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum,
- EModeSwitch theMode)
- {
- INITMSG(MYDEBUG,"GetBaryCenter\n");
- const PMeshInfo& aMeshInfo = thePolygoneInfo.GetMeshInfo();
- TInt aDim = aMeshInfo->GetDim();
- static TInt aNbGauss = 1;
-
- bool anIsSubMesh = !theElemNum.empty();
- TInt aNbElem;
- if(anIsSubMesh)
- aNbElem = theElemNum.size();
- else
- aNbElem = thePolygoneInfo.GetNbElem();
-
- theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
-
- INITMSGA(MYDEBUG,0,
- "- aDim = "<<aDim<<
- "; aNbGauss = "<<aNbGauss<<
- "; aNbElem = "<<aNbElem<<
- "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
- std::endl);
-
- for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
- TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
-
- TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
- TCConnSlice aConnSlice = thePolygoneInfo.GetConnSlice(aCellId);
- TInt aNbConn = thePolygoneInfo.GetNbConn(aCellId);
- TInt aNbNodes = thePolygoneInfo.GetNbConn(aCellId);
-
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
-
- for(TInt aConnId = 0; aConnId < aNbConn; aConnId++){
- TInt aNodeId = aConnSlice[aConnId] - 1;
- TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
-
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId];
- }
- }
-
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] /= aNbNodes;
- }
- }
- }
-
- return true;
- }
-
-
- //---------------------------------------------------------------
- bool
- GetBaryCenter(const TPolyedreInfo& thePolyedreInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum,
- EModeSwitch theMode)
- {
- INITMSG(MYDEBUG,"GetBaryCenter\n");
- const PMeshInfo& aMeshInfo = thePolyedreInfo.GetMeshInfo();
- TInt aDim = aMeshInfo->GetDim();
- static TInt aNbGauss = 1;
-
- bool anIsSubMesh = !theElemNum.empty();
- TInt aNbElem;
- if(anIsSubMesh)
- aNbElem = theElemNum.size();
- else
- aNbElem = thePolyedreInfo.GetNbElem();
-
- theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
-
- INITMSGA(MYDEBUG,0,
- "- aDim = "<<aDim<<
- "; aNbGauss = "<<aNbGauss<<
- "; aNbElem = "<<aNbElem<<
- "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
- std::endl);
-
- for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
- TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
-
- TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
- TCConnSliceArr aConnSliceArr = thePolyedreInfo.GetConnSliceArr(aCellId);
- TInt aNbFaces = aConnSliceArr.size();
-
- TInt aNbNodes = thePolyedreInfo.GetNbNodes(aCellId);
-
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
- TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
-
- for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++){
- TCConnSlice aConnSlice = aConnSliceArr[aFaceId];
- TInt aNbConn = aConnSlice.size();
- for(TInt aConnId = 0; aConnId < aNbConn; aConnId++){
- TInt aNodeId = aConnSlice[aConnId] - 1;
- TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
-
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId];
- }
- }
- }
- for(TInt aDimId = 0; aDimId < aDim; aDimId++){
- aGaussCoordSlice[aDimId] /= aNbNodes;
- }
- }
- }
-
- return true;
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_GaussUtils_HeaderFile
-#define MED_GaussUtils_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-
-#include "MED_Structures.hxx"
-
-namespace MED
-{
- //---------------------------------------------------------------
- typedef TVector<TCCoordSlice> TCCoordSliceArr;
- typedef TVector<TCoordSlice> TCoordSliceArr;
-
- //! Define a helper class to handle Gauss Points coordinates
- class MEDWRAPPER_EXPORT TGaussCoord:
- virtual TModeSwitchInfo
- {
- TInt myNbElem;
- TInt myNbGauss;
- TInt myDim;
-
- TInt myGaussStep;
-
- TNodeCoord myGaussCoord;
-
- public:
-
- TGaussCoord();
-
- //! To init the class
- void
- Init(TInt theNbElem,
- TInt theNbGauss,
- TInt theDim,
- EModeSwitch theMode = eFULL_INTERLACE);
-
- TInt
- GetNbElem() const;
-
- TInt
- GetNbGauss() const;
-
- TInt
- GetDim() const;
-
- unsigned char*
- GetValuePtr();
-
- //! Get slice of the coordinate that corresponds to defined cell (const version)
- TCCoordSliceArr
- GetCoordSliceArr(TInt theElemId) const;
-
- //! Get slice of the coordinate that corresponds to defined cell
- TCoordSliceArr
- GetCoordSliceArr(TInt theElemId);
- };
- typedef SharedPtr<TGaussCoord> PGaussCoord;
-
-
- //---------------------------------------------------------------
- //! To calculate Gauss Points coordinates
- MEDWRAPPER_EXPORT
- bool
- GetGaussCoord3D(const TGaussInfo& theGaussInfo,
- const TCellInfo& theCellInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum = TElemNum(),
- EModeSwitch theMode = eFULL_INTERLACE);
-
-
- //---------------------------------------------------------------
- //! To calculate Gauss Points coordinates for defined TCellInfo as its bary center
- MEDWRAPPER_EXPORT
- bool
- GetBaryCenter(const TCellInfo& theCellInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum = TElemNum(),
- EModeSwitch theMode = eFULL_INTERLACE);
-
- //! To calculate Gauss Points coordinates for defined TPolygoneInfo as its bary center
- MEDWRAPPER_EXPORT
- bool
- GetBaryCenter(const TPolygoneInfo& thePolygoneInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum = TElemNum(),
- EModeSwitch theMode = eFULL_INTERLACE);
-
- //! To calculate Gauss Points coordinates for defined TPolyedreInfo as its bary center
- MEDWRAPPER_EXPORT
- bool
- GetBaryCenter(const TPolyedreInfo& thePolyedreInfo,
- const TNodeInfo& theNodeInfo,
- TGaussCoord& theGaussCoord,
- const TElemNum& theElemNum = TElemNum(),
- EModeSwitch theMode = eFULL_INTERLACE);
-
- //---------------------------------------------------------------
- //! Shape function definitions
- //---------------------------------------------------------------
- struct MEDWRAPPER_EXPORT TShapeFun
- {
- class TFun;
-
- TFloatVector myRefCoord;
- TInt myDim;
- TInt myNbRef;
-
- TShapeFun(TInt theDim = 0, TInt theNbRef = 0);
-
- TInt GetNbRef() const { return myNbRef; }
-
- TCCoordSlice GetCoord(TInt theRefId) const;
-
- TCoordSlice GetCoord(TInt theRefId);
-
- void GetFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- virtual
- void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const = 0;
- virtual
- bool IsSatisfy(const TCCoordSliceArr& theRefCoord) const;
-
- bool Eval(const TCellInfo& theCellInfo,
- const TNodeInfo& theNodeInfo,
- const TElemNum& theElemNum,
- const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TGaussCoord& theGaussCoord,
- EModeSwitch theMode);
- };
- //---------------------------------------------------------------
- struct TSeg2a: TShapeFun {
- TSeg2a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TSeg3a: TShapeFun {
- TSeg3a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTria3a: TShapeFun {
- TTria3a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTria6a: TShapeFun {
- TTria6a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTria3b: TShapeFun {
- TTria3b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTria6b: TShapeFun {
- TTria6b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TQuad4a: TShapeFun {
- TQuad4a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TQuad8a: TShapeFun {
- TQuad8a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TQuad9a: TShapeFun {
- TQuad9a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TQuad4b: TShapeFun {
- TQuad4b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TQuad8b: TShapeFun {
- TQuad8b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TQuad9b: TShapeFun {
- TQuad9b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTetra4a: TShapeFun {
- TTetra4a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTetra10a: TShapeFun {
- TTetra10a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTetra4b: TShapeFun {
- TTetra4b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TTetra10b: TShapeFun {
- TTetra10b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct THexa8a: TShapeFun {
- THexa8a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct THexa20a: TShapeFun {
- THexa20a(TInt theDim = 3, TInt theNbRef = 20);
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct THexa27a: THexa20a {
- THexa27a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct THexa8b: TShapeFun {
- THexa8b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct THexa20b: TShapeFun {
- THexa20b(TInt theDim = 3, TInt theNbRef = 20);
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPenta6a: TShapeFun {
- TPenta6a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPenta6b: TShapeFun {
- TPenta6b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPenta15a: TShapeFun {
- TPenta15a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPenta15b: TShapeFun {
- TPenta15b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPyra5a: TShapeFun {
- TPyra5a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPyra5b: TShapeFun {
- TPyra5b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPyra13a: TShapeFun {
- TPyra13a();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
- struct TPyra13b: TShapeFun {
- TPyra13b();
- virtual void InitFun(const TCCoordSliceArr& theRef,
- const TCCoordSliceArr& theGauss,
- TFun& theFun) const;
- };
- //---------------------------------------------------------------
-
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_SharedPtr_HeaderFile
-#define MED_SharedPtr_HeaderFile
-
-#include <boost/shared_ptr.hpp>
-
-namespace MED
-{
-
- //! To extend the boost::shared_ptr to support such features automatic dynamic cast
- /*!
- All entities of the MEDWrapper package are handled as pointer.
- This class was introduced to provide correct and flexible memory management
- for all of the MEDWrapper objects.
- */
- template<class T> class SharedPtr: public boost::shared_ptr<T>
- {
- public:
- //! Default constructor
- SharedPtr() {}
-
- //! Construct the class by any type of a pointer
- template<class Y>
- explicit SharedPtr(Y * p):
- boost::shared_ptr<T>(p)
- {}
-
- //! Construct the class by any specialisation of the class
- template<class Y>
- SharedPtr(SharedPtr<Y> const & r):
- boost::shared_ptr<T>(boost::dynamic_pointer_cast<T,Y>(r))
- {}
-
- //! Copy-constructor
- template<class Y>
- SharedPtr&
- operator=(SharedPtr<Y> const & r)
- {
- SharedPtr<T>(r).swap(*this);
- return *this;
- }
-
- //! Introduce a flexible way to reset the wrapped pointer
- template<class Y>
- SharedPtr&
- operator()(Y * p) // Y must be complete
- {
- return operator=<Y>(SharedPtr<Y>(p));
- }
-
- //! Introduce a flexible way to reset the wrapped pointer
- template<class Y>
- SharedPtr&
- operator()(SharedPtr<Y> const & r) // Y must be complete
- {
- return operator=<Y>(SharedPtr<Y>(r));
- }
-
- //! To provide a flexible way to use reference to the wrapped pointer (const version)
- operator const T& () const
- {
- return *(this->get());
- }
-
- //! To provide a flexible way to use reference to the wrapped pointer
- operator T& ()
- {
- return *(this->get());
- }
- };
-
-}
-
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_SliceArray_HeaderFile
-#define MED_SliceArray_HeaderFile
-
-#ifdef WIN32 // for correctly compiling "valarray" in modules, which includes this file
- #undef max
- #undef min
-#endif
-
-#include <valarray>
-#include <stdexcept>
-
-//#if defined(_DEBUG_)
-# define MED_TCSLICE_CHECK_RANGE
-//#endif
-
-namespace MED
-{
- //---------------------------------------------------------------
- //! This class intends to provide a uniform way to handle multidimensional data (const version)
- /*!
- It just contains a pointer to real sequence and implement proper calculation of its indexes.
- This class deals with constant pointer to the sources data and provides const method to
- read them (data).
- */
- template<class TValueType>
- class TCSlice
- {
- const TValueType* myCValuePtr; //!< Reference to source multidimensional data
- size_t mySourceSize; //!< Size of the source multidimensional data
- std::slice mySlice; //!< Defines algorithm of index calculation
-
- protected:
- void
- check_id(size_t theId) const
- {
- long int anId = -1;
- if(theId < mySlice.size()){
- anId = mySlice.start() + theId*mySlice.stride();
- if(anId < (long int)mySourceSize)
- return;
- }
- throw std::out_of_range("TCSlice::check_id");
- }
-
- //! Calculate internal index to get proper element from the source multidimensional data
- size_t
- calculate_id(size_t theId) const
- {
- return mySlice.start() + theId*mySlice.stride();
- }
-
- size_t
- get_id(size_t theId) const
- {
-#ifdef MED_TCSLICE_CHECK_RANGE
- check_id(theId);
-#endif
- return calculate_id(theId);
- }
-
- size_t
- get_id_at(size_t theId) const
- {
- check_id(theId);
- return calculate_id(theId);
- }
-
- public:
- typedef TValueType value_type;
-
- //! Construct the class from bare pointer
- TCSlice(const value_type* theValuePtr,
- size_t theSourceSize,
- const std::slice& theSlice):
- myCValuePtr(theValuePtr),
- mySourceSize(theSourceSize),
- mySlice(theSlice)
- {}
-
- //! Construct the class from corresponding container
- TCSlice(const TVector<value_type>& theContainer,
- const std::slice& theSlice):
- myCValuePtr(&theContainer[0]),
- mySourceSize(theContainer.size()),
- mySlice(theSlice)
- {}
-
- //! Default constructor (dangerous)
- TCSlice():
- myCValuePtr(NULL)
- {}
-
- //! Get element by its number (const version)
- const value_type&
- operator[](size_t theId) const
- {
- return *(myCValuePtr + get_id(theId));
- }
-
- const value_type&
- at(size_t theId) const
- {
- return *(myCValuePtr + get_id_at(theId));
- }
-
- //! Get range of the order numbers
- size_t
- size() const
- {
- return mySlice.size();
- }
- };
-
-
- //---------------------------------------------------------------
- //! This class extends TCSlice functionality for non-constant case
- template<class TValueType>
- class TSlice: public TCSlice<TValueType>
- {
- TValueType* myValuePtr;
-
- public:
- typedef TValueType value_type;
- typedef TCSlice<TValueType> TSupperClass;
-
- //! Construct the class from bare pointer
- TSlice(value_type* theValuePtr,
- size_t theSourceSize,
- const std::slice& theSlice):
- TSupperClass(theValuePtr, theSourceSize, theSlice),
- myValuePtr(theValuePtr)
- {}
-
- //! Construct the class from corresponding container
- TSlice(TVector<value_type>& theContainer,
- const std::slice& theSlice):
- TSupperClass(theContainer, theSlice),
- myValuePtr(&theContainer[0])
- {}
-
- //! Default constructor (dangerous)
- TSlice():
- myValuePtr(NULL)
- {}
-
- //! Get element by its number
- value_type&
- operator[](size_t theId)
- {
- return *(myValuePtr + this->get_id(theId));
- }
-
- value_type&
- at(size_t theId)
- {
- return *(myValuePtr + this->get_id_at(theId));
- }
- };
-
-}
-
-#undef MED_TCSLICE_CHECK_RANGE
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-// File : MED_Structure.cxx
-// Author : Eugeny NIKOLAEV
-//
-#include "MED_Structures.hxx"
-#include "MED_Utilities.hxx"
-
-#include <cstring>
-
-using namespace MED;
-
-namespace MED
-{
- TInt
- GetNbNodes(EGeometrieElement typmai)
- {
- return typmai%100;
- }
-
- std::string
- GetString(TInt theId,
- TInt theStep,
- const TString& theString)
- {
- const char* aPos = &theString[theId*theStep];
- TInt aSize = std::min(TInt(strlen(aPos)),theStep);
- return std::string(aPos,aSize);
- }
-
- void
- SetString(TInt theId,
- TInt theStep,
- TString& theString,
- const std::string& theValue)
- {
- TInt aSize = std::min(TInt(theValue.size()+1),theStep);
- char* aPos = &theString[theId*theStep];
- strncpy(aPos,theValue.c_str(),aSize);
- }
-
- void
- SetString(TInt theId,
- TInt theStep,
- TString& theString,
- const TString& theValue)
- {
- TInt aSize = std::min(TInt(theValue.size()+1),theStep);
- char* aPos = &theString[theId*theStep];
- const char* aValue = &theValue[0];
- strncpy(aPos,aValue,aSize);
- }
-
- TInt
- GetDimGaussCoord(EGeometrieElement theGeom)
- {
- return theGeom/100;
- }
-
- TInt
- GetNbRefCoord(EGeometrieElement theGeom)
- {
- return (theGeom%100);
- }
-
- //---------------------------------------------------------------
- PFloatTimeStampValue
- CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue)
- {
- return theTimeStampValue;
- }
-
- PIntTimeStampValue
- CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue)
- {
- return theTimeStampValue;
- }
-}
-
-//---------------------------------------------------------------
-TInt
-TFamilyInfo
-::GetAttrId(TInt theId) const
-{
- return myAttrId[theId];
-}
-
-TInt
-TFamilyInfo
-::GetAttrVal(TInt theId) const
-{
- return myAttrVal[theId];
-}
-
-void
-TFamilyInfo
-::SetAttrId(TInt theId,TInt theVal)
-{
- myAttrId[theId] = theVal;
-}
-
-void
-TFamilyInfo
-::SetAttrVal(TInt theId,TInt theVal)
-{
- myAttrVal[theId] = theVal;
-}
-
-//---------------------------------------------------------------
-TInt
-TElemInfo
-::GetFamNum(TInt theId) const
-{
- return (*myFamNum)[theId];
-}
-
-void
-TElemInfo
-::SetFamNum(TInt theId, TInt theVal)
-{
- (*myFamNum)[theId] = theVal;
- myIsFamNum = eVRAI;
-}
-
-TInt
-TElemInfo
-::GetElemNum(TInt theId) const
-{
- return (*myElemNum)[theId];
-}
-
-void
-TElemInfo
-::SetElemNum(TInt theId, TInt theVal)
-{
- (*myElemNum)[theId] = theVal;
-}
-
-//---------------------------------------------------------------
-TCCoordSlice
-TNodeInfo
-::GetCoordSlice(TInt theId) const
-{
- TInt aDim = myMeshInfo->GetSpaceDim();
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCCoordSlice(*myCoord, std::slice(theId*aDim, aDim, 1));
- else
- return TCCoordSlice(*myCoord, std::slice(theId, aDim, aDim));
-}
-
-TCoordSlice
-TNodeInfo
-::GetCoordSlice(TInt theId)
-{
- TInt aDim = myMeshInfo->GetSpaceDim();
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCoordSlice(*myCoord, std::slice(theId*aDim,aDim,1));
- else
- return TCoordSlice(*myCoord, std::slice(theId,aDim,aDim));
-}
-
-//---------------------------------------------------------------
-TCConnSlice
-TCellInfo
-::GetConnSlice(TInt theElemId) const
-{
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1));
- else
- return TCConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim()));
-}
-
-TConnSlice
-TCellInfo
-::GetConnSlice(TInt theElemId)
-{
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1));
- else
- return TConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim()));
-}
-
-
-//---------------------------------------------------------------
-TInt
-TPolygoneInfo
-::GetNbConn(TInt theElemId) const
-{
- return (*myIndex)[theElemId + 1] - (*myIndex)[theElemId];
-}
-
-TCConnSlice
-TPolygoneInfo
-::GetConnSlice(TInt theElemId) const
-{
- return TCConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1));
-}
-
-TConnSlice
-TPolygoneInfo
-::GetConnSlice(TInt theElemId)
-{
- return TConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1));
-}
-
-
-//---------------------------------------------------------------
-TInt
-TPolyedreInfo
-::GetNbFaces(TInt theElemId) const
-{
- return (*myIndex)[theElemId+1] - (*myIndex)[theElemId];
-}
-
-TInt
-TPolyedreInfo
-::GetNbNodes(TInt theElemId) const
-{
- TInt aNbNodes = 0;
- TInt aNbFaces = GetNbFaces(theElemId);
- TInt aStartFaceId = (*myIndex)[theElemId] - 1;
- for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
- TInt aCurrentId = (*myFaces)[aStartFaceId];
- TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
- aNbNodes += aDiff;
- }
- return aNbNodes;
-}
-
-TCConnSliceArr
-TPolyedreInfo
-::GetConnSliceArr(TInt theElemId) const
-{
- TInt aNbFaces = GetNbFaces(theElemId);
- TCConnSliceArr aConnSliceArr(aNbFaces);
- TInt aStartFaceId = (*myIndex)[theElemId] - 1;
- for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
- TInt aCurrentId = (*myFaces)[aStartFaceId];
- TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
- aConnSliceArr[aFaceId] =
- TCConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1));
- }
- return aConnSliceArr;
-}
-
-TConnSliceArr
-TPolyedreInfo
-::GetConnSliceArr(TInt theElemId)
-{
- TInt aNbFaces = GetNbFaces(theElemId);
- TConnSliceArr aConnSliceArr(aNbFaces);
- TInt aStartFaceId = (*myIndex)[theElemId] - 1;
- for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
- TInt aCurrentId = (*myFaces)[aStartFaceId];
- TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
- aConnSliceArr[aFaceId] =
- TConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1));
- }
- return aConnSliceArr;
-}
-
-
-//---------------------------------------------------------------
-TMeshValueBase
-::TMeshValueBase():
- myNbElem(0),
- myNbComp(0),
- myNbGauss(0),
- myStep(0)
-{}
-
-void
-TMeshValueBase
-::Allocate(TInt theNbElem,
- TInt theNbGauss,
- TInt theNbComp,
- EModeSwitch theMode)
-{
- myModeSwitch = theMode;
-
- myNbElem = theNbElem;
- myNbGauss = theNbGauss;
- myNbComp = theNbComp;
-
- myStep = theNbComp*theNbGauss;
-}
-
-size_t
-TMeshValueBase
-::GetSize() const
-{
- return myNbElem * myStep;
-}
-
-size_t
-TMeshValueBase
-::GetNbVal() const
-{
- return myNbElem * myNbGauss;
-}
-
-size_t
-TMeshValueBase
-::GetNbGauss() const
-{
- return myNbGauss;
-}
-
-size_t
-TMeshValueBase
-::GetStep() const
-{
- return myStep;
-}
-
-
-//---------------------------------------------------------------
-TInt
-TProfileInfo
-::GetElemNum(TInt theId) const
-{
- return (*myElemNum)[theId];
-}
-
-void
-TProfileInfo
-::SetElemNum(TInt theId,TInt theVal)
-{
- (*myElemNum)[theId] = theVal;
-}
-
-//---------------------------------------------------------------
-bool
-TGaussInfo::TLess
-::operator()(const TKey& theLeft, const TKey& theRight) const
-{
- EGeometrieElement aLGeom = boost::get<0>(theLeft);
- EGeometrieElement aRGeom = boost::get<0>(theRight);
- if(aLGeom != aRGeom)
- return aLGeom < aRGeom;
-
- const std::string& aLStr = boost::get<1>(theLeft);
- const std::string& aRStr = boost::get<1>(theRight);
- return aLStr < aRStr;
-}
-
-bool
-TGaussInfo::TLess
-::operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const
-{
- if(!&theLeft)
- return true;
-
- if(!&theRight)
- return false;
-
- if(theLeft.myGeom != theRight.myGeom)
- return theLeft.myGeom < theRight.myGeom;
-
- if(theLeft.myRefCoord != theRight.myRefCoord)
- return theLeft.myRefCoord < theRight.myRefCoord;
-
- return theLeft.myGaussCoord < theRight.myGaussCoord;
-}
-
-TCCoordSlice
-TGaussInfo
-::GetRefCoordSlice(TInt theId) const
-{
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
- else
- return TCCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
-}
-
-TCoordSlice
-TGaussInfo
-::GetRefCoordSlice(TInt theId)
-{
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
- else
- return TCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
-}
-
-TCCoordSlice
-TGaussInfo
-::GetGaussCoordSlice(TInt theId) const
-{
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetDim(),1));
- else
- return TCCoordSlice(myGaussCoord,std::slice(theId,GetDim(),GetDim()));
-}
-
-TCoordSlice
-TGaussInfo
-::GetGaussCoordSlice(TInt theId)
-{
- if(GetModeSwitch() == eFULL_INTERLACE)
- return TCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetNbGauss(),1));
- else
- return TCoordSlice(myGaussCoord,std::slice(theId,GetNbGauss(),GetDim()));
-}
-
-
-//---------------------------------------------------------------
-TInt
-TTimeStampInfo
-::GetNbGauss(EGeometrieElement theGeom) const
-{
- TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
- if(anIter == myGeom2NbGauss.end())
- return 1;//EXCEPTION(runtime_error,"TTimeStampInfo::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
-
- return anIter->second;
-}
-
-
-//---------------------------------------------------------------
-// TGrilleInfo structure methods
-//---------------------------------------------------------------
-const EGrilleType&
-TGrilleInfo
-::GetGrilleType() const
-{
- return myGrilleType;
-}
-
-EGrilleType
-TGrilleInfo
-::GetGrilleType()
-{
- return myGrilleType;
-}
-
-void
-TGrilleInfo
-::SetGrilleType(EGrilleType theGrilleType)
-{
- myGrilleType = theGrilleType;
-}
-
-const
-TIndexes&
-TGrilleInfo
-::GetMapOfIndexes() const
-{
- return myIndixes;
-}
-
-TIndexes&
-TGrilleInfo
-::GetMapOfIndexes()
-{
- return myIndixes;
-}
-
-const
-TFloatVector&
-TGrilleInfo
-::GetIndexes(TInt theAxisNumber) const
-{
- TIndexes::const_iterator aIter=myIndixes.find(theAxisNumber);
- if(aIter==myIndixes.end())
- EXCEPTION(std::runtime_error, "const TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber); fails");
- return aIter->second;
-}
-
-TFloatVector&
-TGrilleInfo
-::GetIndexes(TInt theAxisNumber)
-{
- TIndexes::iterator aIter=myIndixes.find(theAxisNumber);
- if(aIter==myIndixes.end())
- EXCEPTION(std::runtime_error, "TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber="<<theAxisNumber<<"); fails");
- return aIter->second;
-}
-
-TInt
-TGrilleInfo
-::GetNbIndexes(TInt theAxisNumber)
-{
- const TFloatVector& aVector=GetIndexes(theAxisNumber);
- return aVector.size();
-}
-
-TInt
-TGrilleInfo
-::GetNbNodes()
-{
- TInt nbNodes=0;
- TInt aDim = myMeshInfo->GetDim();
- for(int i=0;i<aDim;i++)
- if(nbNodes == 0)
- nbNodes = this->GetGrilleStructure()[i];
- else
- nbNodes = nbNodes*this->GetGrilleStructure()[i];
-
- return nbNodes;
-}
-
-TInt
-TGrilleInfo
-::GetNbCells()
-{
- TInt nbCells=0;
- TInt aDim = myMeshInfo->GetDim();
- for(int i=0;i<aDim;i++)
- if(nbCells == 0)
- nbCells = this->GetGrilleStructure()[i]-1;
- else
- nbCells = nbCells*(this->GetGrilleStructure()[i]-1);
- return nbCells;
-}
-
-TInt
-TGrilleInfo
-::GetNbSubCells()
-{
- TInt nb=0;
- TInt aDim = myMeshInfo->GetDim();
- switch (aDim) {
- case 3:
- nb =
- (myGrilleStructure[0] ) * (myGrilleStructure[1]-1) * (myGrilleStructure[2]-1) +
- (myGrilleStructure[0]-1) * (myGrilleStructure[1] ) * (myGrilleStructure[2]-1) +
- (myGrilleStructure[0]-1) * (myGrilleStructure[1]-1) * (myGrilleStructure[2] );
- break;
- case 2:
- nb =
- (myGrilleStructure[0] ) * (myGrilleStructure[1]-1) +
- (myGrilleStructure[0]-1) * (myGrilleStructure[1] );
- break;
- }
- return nb;
-}
-
-EGeometrieElement
-TGrilleInfo
-::GetGeom()
-{
- TInt aDim = myMeshInfo->GetDim();
- switch(aDim){
- case 1:
- return eSEG2;
- case 2:
- return eQUAD4;
- case 3:
- return eHEXA8;
- default:
- return eNONE;
- }
-}
-
-EGeometrieElement
-TGrilleInfo
-::GetSubGeom()
-{
- TInt aDim = myMeshInfo->GetDim();
- switch(aDim){
- case 2:
- return eSEG2;
- case 3:
- return eQUAD4;
- }
- return eNONE;
-}
-
-EEntiteMaillage
-TGrilleInfo
-::GetEntity()
-{
- return eMAILLE;
-}
-
-EEntiteMaillage
-TGrilleInfo
-::GetSubEntity()
-{
- TInt aDim = myMeshInfo->GetDim();
- switch(aDim){
- case 2:
- return eARETE;
- case 3:
- return eFACE;
- }
- return EEntiteMaillage(-1);
-}
-
-const
-TIntVector&
-TGrilleInfo
-::GetGrilleStructure() const
-{
- return myGrilleStructure;
-}
-
-TIntVector
-TGrilleInfo
-::GetGrilleStructure()
-{
- return myGrilleStructure;
-}
-
-void
-TGrilleInfo
-::SetGrilleStructure(TInt theAxis,TInt theNb)
-{
- if(theAxis >= 0 && theAxis <=2 && theNb >= 0)
- myGrilleStructure[theAxis]=theNb;
-}
-
-const
-TNodeCoord&
-TGrilleInfo
-::GetNodeCoord() const
-{
- return myCoord;
-}
-
-TNodeCoord&
-TGrilleInfo
-::GetNodeCoord()
-{
- return myCoord;
-}
-
-TNodeCoord
-TGrilleInfo
-::GetCoord(TInt theId)
-{
- TNodeCoord aCoord;
- TInt aDim = myMeshInfo->GetDim();
- TInt aNbNodes = this->GetNbNodes();
- aCoord.resize(aDim);
-
- if(theId >= aNbNodes)
- EXCEPTION(std::runtime_error, "TGrilleInfo::GetCoord - theId out of range");
-
- if(myGrilleType == eGRILLE_STANDARD){
- switch(aDim){
- case 3:
- aCoord[2] = myCoord[aDim*theId+2];
- case 2:
- aCoord[1] = myCoord[aDim*theId+1];
- case 1:{
- aCoord[0] = myCoord[aDim*theId];
- break;
- }
- }
- } else {
-
- TFloatVector aVecX = this->GetIndexes(0);
- TInt nbIndxX = this->GetNbIndexes(0);
-
- switch(aDim){
- case 1:{
- aCoord[0] = aVecX[theId];
- break;
- }
- case 2:{
- TFloatVector aVecY = this->GetIndexes(1);
- TInt i,j,k;
- i = j = k = 0;
- i = theId % nbIndxX;
- j = theId / nbIndxX;
- if(myGrilleType == eGRILLE_CARTESIENNE){
- aCoord[0] = aVecX[i];
- aCoord[1] = aVecY[j];
- } else { // eGRILLE_POLAIRE (cylindrical)
- aCoord[0] = aVecX[i] * cos(aVecY[j]);
- aCoord[1] = aVecX[i] * sin(aVecY[j]);
- }
- break;
- }
- case 3:{
- TFloatVector aVecY = this->GetIndexes(1);
- TInt nbIndxY = this->GetNbIndexes(1);
- TFloatVector aVecZ = this->GetIndexes(2);
- TInt i,j,k;
- i = j = k = 0;
-
- i = theId % nbIndxX;
- j = (theId / nbIndxX) % nbIndxY;
- k = theId / (nbIndxX*nbIndxY);
-
- if(myGrilleType == eGRILLE_CARTESIENNE){
- aCoord[0] = aVecX[i];
- aCoord[1] = aVecY[j];
- aCoord[2] = aVecZ[k];
- } else { // eGRILLE_POLAIRE (cylindrical)
- aCoord[0] = aVecX[i] * cos(aVecY[j]);
- aCoord[1] = aVecX[i] * sin(aVecY[j]);
- aCoord[2] = aVecZ[k];
- }
-
- break;
- }
- }
- }
-
- return aCoord;
-}
-
-TIntVector
-TGrilleInfo
-::GetConn(TInt theId, const bool isSub)
-{
- TIntVector anIndexes;
- TInt aDim = myMeshInfo->GetDim();
-
- TInt idx;
- TInt iMin, jMin, kMin, iMax, jMax, kMax;
- TInt loc[3];
-
- loc[0] = loc[1] = loc[2] = 0;
- iMin = iMax = jMin = jMax = kMin = kMax = 0;
-
- switch(aDim) {
- case 3:
- {
- TInt nbX = this->GetGrilleStructure()[0];
- TInt nbY = this->GetGrilleStructure()[1];
- TInt nbZ = this->GetGrilleStructure()[2];
- TInt d01 = nbX*nbY, dX = 1, dY = 1, dZ = 1;
- if ( isSub )
- {
- if ( theId < nbX * (nbY-1) * (nbZ-1))
- { // face is normal to X axis
- dX = 0;
- }
- else if ( theId < nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1))
- { // face is normal to Y axis
- theId -= nbX * (nbY-1) * (nbZ-1);
- dY = 0;
- }
- else
- {
- theId -= nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1);
- dZ = 0;
- }
- }
- //else
- {
- iMin = theId % (nbX - dX);
- jMin = (theId / (nbX - dX)) % (nbY - dY);
- kMin = theId / ((nbX - dX) * (nbY - dY));
- iMax = iMin+dX;
- jMax = jMin+dY;
- kMax = kMin+dZ;
- }
- for (loc[2]=kMin; loc[2]<=kMax; loc[2]++)
- for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
- for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
- {
- idx = loc[0] + loc[1]*nbX + loc[2]*d01;
- anIndexes.push_back(idx);
- }
- break;
- }
- case 2:
- {
- TInt nbX = this->GetGrilleStructure()[0];
- TInt nbY = this->GetGrilleStructure()[1];
- TInt dX = 1, dY = 1;
- if ( isSub )
- {
- if ( theId < nbX * (nbY-1))
- { // edge is normal to X axis
- dX = 0;
- }
- else
- {
- theId -= nbX * (nbY-1);
- dY = 0;
- }
- }
- iMin = theId % (nbX-dX);
- jMin = theId / (nbX-dX);
- iMax = iMin+dX;
- jMax = jMin+dY;
- for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
- for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
- {
- idx = loc[0] + loc[1]*nbX;
- anIndexes.push_back(idx);
- }
- break;
- }
- case 1:
- {
- iMin = theId;
- for (loc[0]=iMin; loc[0]<=iMin+1; loc[0]++)
- {
- idx = loc[0];
- anIndexes.push_back(idx);
- }
- break;
- }
- }
-
- return anIndexes;
-}
-
-TInt
-TGrilleInfo
-::GetFamNumNode(TInt theId) const
-{
- return myFamNumNode[theId];
-}
-
-void
-TGrilleInfo
-::SetFamNumNode(TInt theId,TInt theVal)
-{
- myFamNumNode[theId] = theVal;
-}
-
-TInt
-TGrilleInfo
-::GetFamNum(TInt theId) const
-{
- return myFamNum[theId];
-}
-
-void
-TGrilleInfo
-::SetFamNum(TInt theId,TInt theVal)
-{
- myFamNum[theId] = theVal;
-}
-
-TInt
-TGrilleInfo
-::GetFamSubNum(TInt theId) const
-{
- return myFamSubNum[theId];
-}
-
-void
-TGrilleInfo
-::SetFamSubNum(TInt theId,TInt theVal)
-{
- myFamSubNum[theId] = theVal;
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#ifndef MED_Structures_HeaderFile
-#define MED_Structures_HeaderFile
-
-#include "MED_Common.hxx"
-#include "MED_Utilities.hxx"
-
-#ifdef WIN32
-#pragma warning(disable:4251)
-#endif
-
-namespace MED
-{
-
- //---------------------------------------------------------------
- //! Defines a type for managing sequence of strings
- typedef TVector<char> TString;
- typedef SharedPtr<TString> PString;
-
- //! Extract a substring from the sequence of the strings
- MEDWRAPPER_EXPORT
- std::string
- GetString(TInt theId, TInt theStep,
- const TString& theString);
-
- //! Set a substring in the sequence of the strings
- MEDWRAPPER_EXPORT
- void
- SetString(TInt theId, TInt theStep,
- TString& theString,
- const std::string& theValue);
-
- //! Set a substring in the sequence of the strings
- MEDWRAPPER_EXPORT
- void
- SetString(TInt theId, TInt theStep,
- TString& theString,
- const TString& theValue);
-
- //---------------------------------------------------------------
- //! Define a parent class for all MEDWrapper classes
- struct MEDWRAPPER_EXPORT TBase
- {
- virtual ~TBase() {}
- };
-
-
- //---------------------------------------------------------------
- //! Define a parent class for all named MED entities
- struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase
- {
- TString myName; //!< Keeps its name
- virtual std::string GetName() const = 0; //!< Gets its name
- virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
- virtual void SetName(const TString& theValue) = 0; //!< Set a new name
- };
-
-
- //---------------------------------------------------------------
- //! Define a parent class for all MED entities that contains a sequence of numbers
- /*!
- It defines through corresponding enumeration (EModeSwitch) how the sequence
- should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
- */
- struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase
- {
- //! To construct instance of the class by default
- TModeSwitchInfo():
- myModeSwitch(eFULL_INTERLACE)
- {}
-
- //! To construct instance of the class
- TModeSwitchInfo(EModeSwitch theModeSwitch):
- myModeSwitch(theModeSwitch)
- {}
-
- EModeSwitch myModeSwitch; //!< Keeps the
- EModeSwitch GetModeSwitch() const { return myModeSwitch;}
- };
-
-
- //---------------------------------------------------------------
- //! Define a base class which represents MED Mesh entity
- struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo
- {
- TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
- TInt GetDim() const { return myDim;} //!< Gets dimension of the mesh
-
- TInt mySpaceDim;
- TInt GetSpaceDim() const { return mySpaceDim; }
-
- EMaillage myType; //!< Type of the mesh
- EMaillage GetType() const { return myType;} //!< Gets type of the mesh
-
- TString myDesc; //!< Description of the mesh
- virtual std::string GetDesc() const = 0; //!< Get description for the mesh
- virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
-
-
- };
-
-
- //---------------------------------------------------------------
- typedef TVector<TInt> TIntVector;
- typedef TSlice<TInt> TIntVecSlice;
- typedef TCSlice<TInt> TCIntVecSlice;
-
- typedef TIntVector TFamAttr;
-
- //! Define a base class which represents MED Family entity
- struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo
- {
- PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
- //! Get a reference to corresponding MED Mesh
- const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
-
- TInt myId; //!< An unique index of the MED FAMILY
- TInt GetId() const { return myId;} //!< Gets number of the MED FAMILY
- void SetId(TInt theId) { myId = theId;} //! Define number of the MED FAMILY
-
- TInt myNbGroup; //!< Defines number MED Groups connected to
- //! Gets number of MED GROUPS the MED FAMILY is bound to
- TInt GetNbGroup() const { return myNbGroup;}
-
- //! Contains sequence of the names for the MED Groups connected to
- TString myGroupNames;
- //! Gets name of a bound MED GROUP by its number
- virtual std::string GetGroupName(TInt theId) const = 0;
- //! Sets name of the defined MED GROUP by its number
- virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
-
- TInt myNbAttr; //!< Defines number of the MED Family attributes
- //! Gets number of attached attributes for the MED FAMILY
- TInt GetNbAttr() const { return myNbAttr;}
-
- //! Defines sequence of the indexes of the MED Family attributes
- TFamAttr myAttrId;
- //! Get MED FAMILY attribute by its number
- TInt GetAttrId(TInt theId) const;
- //! Set MED FAMILY attribute by its number
- void SetAttrId(TInt theId, TInt theVal);
-
- //! Defines sequence of the values of the MED Family attributes
- TFamAttr myAttrVal;
- //! Get MED FAMILY attribute by its number
- TInt GetAttrVal(TInt theId) const;
- //! Set MED FAMILY attribute by its number
- void SetAttrVal(TInt theId, TInt theVal);
-
- //! Defines sequence of the names of the MED Family attributes
- TString myAttrDesc;
- //! Get value of the MED FAMILY attribute by its number
- virtual std::string GetAttrDesc(TInt theId) const = 0;
- //! Set value of the MED FAMILY attribute by its number
- virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
- };
-
-
- //---------------------------------------------------------------
- typedef TIntVector TElemNum;
- typedef SharedPtr<TElemNum> PElemNum;
-
- //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells.
- struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase
- {
- PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
- //! Get a reference to corresponding MED Mesh
- const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
-
- TInt myNbElem; //<! Number of corresponding mesh entities
- TInt GetNbElem() const { return myNbElem;} //! Get number of mesh elements
-
- //! Defines sequence MED Family indexes for corresponding mesh entites
- PElemNum myFamNum;
- //! Get number of a MED FAMILY by order number of the mesh element
- TInt GetFamNum(TInt theId) const;
- //! Set number of a MED FAMILY for the mesh element with the order number
- void SetFamNum(TInt theId, TInt theVal);
-
- //! Defines if the mesh elements are indexed
- EBooleen myIsElemNum;
- //! Let know if the mesh elements are indexed
- EBooleen IsElemNum() const { return myIsElemNum;}
-
- //! Defines if the mesh elements family are indexed
- EBooleen myIsFamNum;
- //! Let know if the mesh elements family are indexed
- EBooleen IsFamNum() const { return myIsFamNum;}
-
-
- //! Contains sequence of the indexes for the mesh elements
- PElemNum myElemNum;
- //! Get a reference number of the mesh element by its order number
- TInt GetElemNum(TInt theId) const;
- //! Set a reference number for the mesh element by its order number
- void SetElemNum(TInt theId, TInt theVal);
-
- //! Defines if the mesh elements are named
- EBooleen myIsElemNames;
- //! Let know if the mesh elements havew names
- EBooleen IsElemNames() const { return myIsElemNames;}
-
- //! Contains sequence of the names for the mesh elements
- PString myElemNames;
- //! Get name of the mesh element by its order number
- virtual std::string GetElemName(TInt theId) const = 0;
- //! Set name of the mesh element by its order number
- virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
- };
-
-
- //---------------------------------------------------------------
- typedef TVector<TFloat> TFloatVector;
- typedef TSlice<TFloat> TFloatVecSlice;
- typedef TCSlice<TFloat> TCFloatVecSlice;
-
- typedef TFloatVector TNodeCoord;
- typedef SharedPtr<TNodeCoord> PNodeCoord;
-
- typedef TFloatVecSlice TCoordSlice;
- typedef TCFloatVecSlice TCCoordSlice;
-
- //! Define a base class which represents MED Nodes entity
- struct MEDWRAPPER_EXPORT TNodeInfo:
- virtual TElemInfo,
- virtual TModeSwitchInfo
- {
- PNodeCoord myCoord; //!< Contains all nodal coordinates
-
- //! Gives coordinates for mesh node by its number (const version)
- TCCoordSlice GetCoordSlice(TInt theId) const;
- //! Gives coordinates for mesh node by its number
- TCoordSlice GetCoordSlice(TInt theId);
-
- ERepere mySystem; //!< Defines, which coordinate system is used
- //! Get which coordinate system is used for the node describing
- ERepere GetSystem() const { return mySystem;}
- //! Set coordinate system to be used for the node describing
- void SetSystem(ERepere theSystem) { mySystem = theSystem;}
-
- TString myCoordNames; //!< Contains names for the coordinate dimensions
- //! Get name of the coordinate dimension by its order number
- virtual std::string GetCoordName(TInt theId) const = 0;
- //! Set name of the coordinate dimension by its order number
- virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
-
- TString myCoordUnits; //!< Contains units for the coordinate dimensions
- //! Get name of unit for the coordinate dimension by its order number
- virtual std::string GetCoordUnit(TInt theId) const = 0;
- //! Set name of unit for the coordinate dimension by its order number
- virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
- };
-
-
- //---------------------------------------------------------------
- typedef TIntVecSlice TConnSlice;
- typedef TCIntVecSlice TCConnSlice;
-
- //! Define a base class which represents MED Cells entity
- struct MEDWRAPPER_EXPORT TCellInfo:
- virtual TElemInfo,
- virtual TModeSwitchInfo
- {
- EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
- //! Find out what MED ENTITY the cells belong to
- EEntiteMaillage GetEntity() const { return myEntity;}
-
- EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
- //! Find out what MED geometrical type the cells belong to
- EGeometrieElement GetGeom() const { return myGeom;}
-
- EConnectivite myConnMode; //!< Defines connectivity mode
- //! Find out in what connectivity the cells are written
- EConnectivite GetConnMode() const { return myConnMode;}
-
- virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
-
- PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell
-
- //! Gives connectivities for mesh cell by its number (const version)
- TCConnSlice GetConnSlice(TInt theElemId) const;
- //! Gives connectivities for mesh cell by its number
- TConnSlice GetConnSlice(TInt theElemId);
- };
-
- //---------------------------------------------------------------
- //! Define a base class which represents MED Polygon entity
- struct MEDWRAPPER_EXPORT TPolygoneInfo:
- virtual TElemInfo
- {
- //! Defines the MED Entity where the polygons belongs to
- EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
- //! Find out what MED ENTITY the MED Polygons belong to
- EEntiteMaillage GetEntity() const { return myEntity;}
-
- //! Defines the MED Geometric type of the instance
- EGeometrieElement myGeom; // ePOLYGONE
- //! Find out what MED geometrical type the MED Polygons belong to
- EGeometrieElement GetGeom() const { return ePOLYGONE;}
-
- //! Defines connectivity mode
- EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
- //! Find out in what connectivity the cells are written
- EConnectivite GetConnMode() const { return myConnMode;}
-
- PElemNum myConn; //!< Table de connectivities
- PElemNum myIndex; //!< Table de indexes
-
- //! Gives number of the connectivities for the defined polygon
- TInt GetNbConn(TInt theElemId) const;
-
- //! Gives connectivities for polygon by its number (const version)
- TCConnSlice GetConnSlice(TInt theElemId) const;
- //! Gives connectivities for polygon by its number
- TConnSlice GetConnSlice(TInt theElemId);
- };
-
- //---------------------------------------------------------------
- //! Define a class representing MED_BALL structure element.
- //
- // This could be a generic class for any structure element
- // holding any number of contant and variable attributes
- // but it's too hard to implement
- //
- struct MEDWRAPPER_EXPORT TBallInfo:
- virtual TCellInfo
- {
- TFloatVector myDiameters;
- };
-
- //---------------------------------------------------------------
- typedef TVector<TCConnSlice> TCConnSliceArr;
- typedef TVector<TConnSlice> TConnSliceArr;
-
- //! Define a base class which represents MED Polyedre entity
- struct MEDWRAPPER_EXPORT TPolyedreInfo:
- virtual TElemInfo
- {
- //! Defines the MED Entity where the polyedres belongs to
- EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
- //! Find out what MED ENTITY the MED Polyedres belong to
- EEntiteMaillage GetEntity() const { return myEntity;}
-
- //! Defines the MED Geometric type of the instance
- EGeometrieElement myGeom; // ePOLYEDRE
- //! Find out what MED geometrical type the MED Polyedres belong to
- EGeometrieElement GetGeom() const { return ePOLYEDRE;}
-
- //! Defines connectivity mode
- EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
- //! Find out in what connectivity the cells are written
- EConnectivite GetConnMode() const { return myConnMode;}
-
- PElemNum myConn; //!< Table de connectivities
- PElemNum myFaces; //!< Table de faces indexes
- PElemNum myIndex; //!< Table de indexes
-
- //! Gives number of the faces for the defined polyedre (const version)
- TInt GetNbFaces(TInt theElemId) const;
- //! Gives number of the nodes for the defined polyedre
- TInt GetNbNodes(TInt theElemId) const;
-
- //! Gives sequence of the face connectivities for polyedre by its number (const version)
- TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
- //! Gives sequence of the face connectivities for polyedre by its number
- TConnSliceArr GetConnSliceArr(TInt theElemId);
- };
-
- //---------------------------------------------------------------
- //! Define a base class which represents MED Field entity
- struct MEDWRAPPER_EXPORT TFieldInfo:
- virtual TNameInfo
- {
- PMeshInfo myMeshInfo; //!< A reference to corresponding MED Mesh
- //! Get a reference to corresponding MED Mesh
- const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
-
- ETypeChamp myType; //!< Defines type of MED Field
- //! Find out what type of MED FIELD is used
- ETypeChamp GetType() const { return myType;}
-
- TInt myNbComp; //!< Defines number of components stored in the field
- //! Get number of components for MED FIELD
- TInt GetNbComp() const { return myNbComp;}
-
- EBooleen myIsLocal; //!< Defines if the MED Field is local
- //! Find out if MED FIELD is local or not
- EBooleen GetIsLocal() const { return myIsLocal;}
-
- TInt myNbRef; //!< Defines number of references of the field
- //! Find out number of references for the MED FIELD
- TInt GetNbRef() const { return myNbRef;}
-
- TString myCompNames; //!< Contains names for each of MED Field components
- //! Get name of the component by its order number
- virtual std::string GetCompName(TInt theId) const = 0;
- //! Set name for the component by its order number
- virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
-
- TString myUnitNames; //!< Contains units for each of MED Field components
- //! Get unit of the component by its order number
- virtual std::string GetUnitName(TInt theId) const = 0;
- //! Set unit for the component by its order number
- virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
-
- };
-
-
- //---------------------------------------------------------------
- //! Get dimension of the Gauss coordinates for the defined type of mesh cell
- MEDWRAPPER_EXPORT
- TInt
- GetDimGaussCoord(EGeometrieElement theGeom);
-
- //! Get number of referenced nodes for the defined type of mesh cell
- MEDWRAPPER_EXPORT
- TInt
- GetNbRefCoord(EGeometrieElement theGeom);
-
- typedef TFloatVector TWeight;
-
- //! The class represents MED Gauss entity
- struct MEDWRAPPER_EXPORT TGaussInfo:
- virtual TNameInfo,
- virtual TModeSwitchInfo
- {
- typedef boost::tuple<EGeometrieElement,std::string> TKey;
- typedef boost::tuple<TKey,TInt> TInfo;
- struct MEDWRAPPER_EXPORT TLess
- {
- bool
- operator()(const TKey& theLeft, const TKey& theRight) const;
-
- bool
- operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
- };
-
- //! Defines, which geometrical type the MED Gauss entity belongs to
- EGeometrieElement myGeom;
- //! Find out what MED geometrical type the MED GAUSS entity belong to
- EGeometrieElement GetGeom() const { return myGeom;}
-
- //! Contains coordinates for the refereced nodes
- TNodeCoord myRefCoord;
-
- //! Gives coordinates for the referenced node by its number
- TCCoordSlice GetRefCoordSlice(TInt theId) const;
- //! Gives coordinates for the referenced node by its number
- TCoordSlice GetRefCoordSlice(TInt theId);
-
- //! Contains coordinates for the Gauss points
- TNodeCoord myGaussCoord;
-
- //! Gives coordinates for the Gauss points by its number
- TCCoordSlice GetGaussCoordSlice(TInt theId) const;
- //! Gives coordinates for the Gauss points by its number
- TCoordSlice GetGaussCoordSlice(TInt theId);
-
- //! Contains wheights for the Gauss points
- TWeight myWeight;
-
- //! Gives number of the referenced nodes
- TInt GetNbRef() const { return GetNbRefCoord(GetGeom());}
-
- //! Gives dimension of the referenced nodes
- TInt GetDim() const { return GetDimGaussCoord(GetGeom());}
-
- //! Gives number of the Gauss Points
- TInt GetNbGauss() const { return (TInt)(myGaussCoord.size()/GetDim());}
- };
-
-
- //---------------------------------------------------------------
- typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
- typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
-
- //! Define a base class which represents MED TimeStamp
- struct MEDWRAPPER_EXPORT TTimeStampInfo:
- virtual TBase
- {
- PFieldInfo myFieldInfo; //!< A reference to correspondig MED Field
- //! Get a reference to corresponding MED Field
- const PFieldInfo& GetFieldInfo() const { return myFieldInfo;}
-
- //! Defines the MED Entity where the MED TimeStamp belongs to
- EEntiteMaillage myEntity;
- //! Find out to what MED Entity the MED TimeStamp belong to
- EEntiteMaillage GetEntity() const { return myEntity;}
-
- //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to
- TGeom2Size myGeom2Size;
- //! Get map of number of cells per geometric type where the MED TimeStamp belongs to
- const TGeom2Size& GetGeom2Size() const { return myGeom2Size;}
-
- TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp
- TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp
-
- TInt myNumDt; //!< Keeps number in time for the MED TimeStamp
- TInt GetNumDt() const { return myNumDt;} //!< Defines number in time for the MED TimeStamp
-
- TInt myNumOrd; //!< Keeps number for the MED TimeStamp
- TInt GetNumOrd() const { return myNumOrd;} //!< Defines number for the MED TimeStamp
-
- TFloat myDt; //!< Keeps time for the MED TimeStamp
- TFloat GetDt() const { return myDt;} //!< Defines time for the MED TimeStamp
-
- //! Keeps map of MED Gauss entityes per geometric type
- TGeom2Gauss myGeom2Gauss;
- //! Gets a map of MED Gauss entityes per geometric type
- const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss;}
-
- TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp
- //! Get unit of time for the MED TimeStamp
- virtual std::string GetUnitDt() const = 0;
- //! Set unit of time for the MED TimeStamp
- virtual void SetUnitDt(const std::string& theValue) = 0;
- };
-
-
- //---------------------------------------------------------------
- //! The class represents MED Profile entity
- struct MEDWRAPPER_EXPORT TProfileInfo:
- virtual TNameInfo
- {
- typedef std::string TKey;
- typedef boost::tuple<TKey,TInt> TInfo;
-
- EModeProfil myMode; //!< Keeps mode for the MED Profile
- //! Find out what mode of MED Profile is used
- EModeProfil GetMode() const { return myMode;}
- //! Set mode for the MED Profile
- void SetMode(EModeProfil theMode) { myMode = theMode;}
-
- PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
- //! Get number of mesh elelemts by its order number
- TInt GetElemNum(TInt theId) const;
- //! Set number of mesh elelemts by its order number
- void SetElemNum(TInt theId, TInt theVal);
-
- //! Find out if the MED Profile defined
- bool IsPresent() const { return GetName() != "";}
-
- //! Find out size of the MED Profile
- TInt GetSize() const { return (TInt)myElemNum->size();}
- };
-
-
- //---------------------------------------------------------------
- //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
- struct MEDWRAPPER_EXPORT TMeshValueBase:
- virtual TModeSwitchInfo
- {
- TInt myNbElem;
- TInt myNbComp;
- TInt myNbGauss;
- TInt myStep;
-
- TMeshValueBase();
-
- //! Initialize the class
- void
- Allocate(TInt theNbElem,
- TInt theNbGauss,
- TInt theNbComp,
- EModeSwitch theMode = eFULL_INTERLACE);
-
- //! Returns size of the value container
- size_t
- GetSize() const;
-
- //! Returns MED interpetation of the value size
- size_t
- GetNbVal() const;
-
- //! Returns number of Gauss Points bounded with the value
- size_t
- GetNbGauss() const;
-
- //! Returns step inside of the data array
- size_t
- GetStep() const;
-
- //! Returns bare pointer on the internal value representation
- virtual
- unsigned char*
- GetValuePtr() = 0;
- };
-
- //---------------------------------------------------------------
- //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
- template<class TValueType>
- struct TTMeshValue:
- virtual TMeshValueBase
- {
- typedef TValueType TValue;
- typedef typename TValueType::value_type TElement;
-
- typedef TSlice<TElement> TValueSlice;
- typedef TCSlice<TElement> TCValueSlice;
-
- typedef TVector<TCValueSlice> TCValueSliceArr;
- typedef TVector<TValueSlice> TValueSliceArr;
-
- TValue myValue;
-
- //! Initialize the class
- void
- Allocate(TInt theNbElem,
- TInt theNbGauss,
- TInt theNbComp,
- EModeSwitch theMode = eFULL_INTERLACE)
- {
- TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode);
- myValue.resize(theNbElem * this->GetStep());
- }
-
- //! Returns bare pointer on the internal value representation
- virtual
- unsigned char*
- GetValuePtr()
- {
- return (unsigned char*)&myValue[0];
- }
-
- //! Returns bare pointer on the internal value representation
- virtual
- TElement*
- GetPointer()
- {
- return &myValue[0];
- }
-
- //! Returns bare pointer on the internal value representation
- virtual
- const TElement*
- GetPointer() const
- {
- return &myValue[0];
- }
-
- //! Iteration through Gauss Points by their components
- TCValueSliceArr
- GetGaussValueSliceArr(TInt theElemId) const
- {
- TCValueSliceArr aValueSliceArr(myNbGauss);
- if(GetModeSwitch() == eFULL_INTERLACE){
- TInt anId = theElemId * myStep;
- for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TCValueSlice(myValue, std::slice(anId, myNbComp, 1));
- anId += myNbComp;
- }
- }
- else{
- for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
- }
- }
- return aValueSliceArr;
- }
-
- //! Iteration through Gauss Points by their components
- TValueSliceArr
- GetGaussValueSliceArr(TInt theElemId)
- {
- TValueSliceArr aValueSliceArr(myNbGauss);
- if(GetModeSwitch() == eFULL_INTERLACE){
- TInt anId = theElemId*myStep;
- for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TValueSlice(myValue, std::slice(anId, myNbComp, 1));
- anId += myNbComp;
- }
- }
- else{
- for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
- }
- }
- return aValueSliceArr;
- }
-
- //! Iteration through components by corresponding Gauss Points
- TCValueSliceArr
- GetCompValueSliceArr(TInt theElemId) const
- {
- TCValueSliceArr aValueSliceArr(myNbComp);
- if(GetModeSwitch() == eFULL_INTERLACE){
- TInt anId = theElemId*myStep;
- for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
- aValueSliceArr[aCompId] =
- TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
- anId += 1;
- }
- }
- else{
- for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
- aValueSliceArr[aCompId] =
- TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep));
- }
- }
- return aValueSliceArr;
- }
-
- //! Iteration through components by corresponding Gauss Points
- TValueSliceArr
- GetCompValueSliceArr(TInt theElemId)
- {
- if(GetModeSwitch() == eFULL_INTERLACE){
- TValueSliceArr aValueSliceArr(myNbComp);
- TInt anId = theElemId*myStep;
- for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
- aValueSliceArr[aCompId] =
- TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
- anId += 1;
- }
- return aValueSliceArr;
- }
- else{
- TValueSliceArr aValueSliceArr(myNbGauss);
- for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep));
- }
- return aValueSliceArr;
- }
- }
- };
-
- typedef TTMeshValue<TFloatVector> TFloatMeshValue;
- typedef TTMeshValue<TIntVector> TIntMeshValue;
-
- //---------------------------------------------------------------
- // Backward compatibility declarations
- typedef TFloatVector TValue;
- typedef TSlice<TFloat> TValueSlice;
- typedef TCSlice<TFloat> TCValueSlice;
-
- typedef TVector<TCValueSlice> TCValueSliceArr;
- typedef TVector<TValueSlice> TValueSliceArr;
-
- typedef TFloatMeshValue TMeshValue;
- typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
-
- //---------------------------------------------------------------
- typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
- typedef std::set<EGeometrieElement> TGeom;
-
- //! The class is a base class for MED TimeStamp values holder
- struct MEDWRAPPER_EXPORT TTimeStampValueBase:
- virtual TModeSwitchInfo
- {
- //! A reference to correspondig MED TimeStamp
- PTimeStampInfo myTimeStampInfo;
- //!< Get a reference to correspondig MED TimeStamp
- const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo;}
-
- //! Keeps set of MED EGeometrieElement which contains values for the timestamp
- TGeomSet myGeomSet;
- const TGeomSet& GetGeomSet() const { return myGeomSet;}
-
- //! Keeps map of MED Profiles per geometric type
- TGeom2Profile myGeom2Profile;
- //! Gets a map of MED Profiles per geometric type
- const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile;}
-
- //! Gets type of the champ
- virtual
- ETypeChamp
- GetTypeChamp() const = 0;
-
- //! Allocates values for the given geometry
- virtual
- void
- AllocateValue(EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theNbGauss,
- TInt theNbComp,
- EModeSwitch theMode = eFULL_INTERLACE) = 0;
-
- virtual
- size_t
- GetValueSize(EGeometrieElement theGeom) const = 0;
-
- virtual
- size_t
- GetNbVal(EGeometrieElement theGeom) const = 0;
-
- virtual
- size_t
- GetNbGauss(EGeometrieElement theGeom) const = 0;
-
- virtual
- unsigned char*
- GetValuePtr(EGeometrieElement theGeom) = 0;
- };
-
-
- //---------------------------------------------------------------
- //! The class implements a container for MED TimeStamp values
- template<class TMeshValueType>
- struct TTimeStampValue:
- virtual TTimeStampValueBase
- {
- typedef TMeshValueType TTMeshValue;
- typedef SharedPtr<TMeshValueType> PTMeshValue;
- typedef typename TMeshValueType::TElement TElement;
- typedef std::map<EGeometrieElement, PTMeshValue> TTGeom2Value;
-
- ETypeChamp myTypeChamp; //<! Keeps type of the champ
-
- //! Gets type of the champ
- virtual
- ETypeChamp
- GetTypeChamp() const
- {
- return myTypeChamp;
- }
-
- //! Keeps map of MED TimeStamp values per geometric type (const version)
- TTGeom2Value myGeom2Value;
-
- const TTGeom2Value&
- GetGeom2Value() const
- {
- return myGeom2Value;
- }
-
- //! Gets MED TimeStamp values for the given geometric type (const version)
- const PTMeshValue&
- GetMeshValuePtr(EGeometrieElement theGeom) const
- {
- typename TTGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
- if(anIter == myGeom2Value.end())
- EXCEPTION(std::runtime_error,"TTimeStampValue::GetMeshValuePtr - myGeom2Value.find(theGeom) fails");
- return anIter->second;
- }
-
- //! Gets MED TimeStamp values for the given geometric type
- PTMeshValue&
- GetMeshValuePtr(EGeometrieElement theGeom)
- {
- myGeomSet.insert(theGeom);
- if(myGeom2Value.find(theGeom) == myGeom2Value.end()){
- myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue());
- return myGeom2Value[theGeom];
- }
- return myGeom2Value[theGeom];
- }
-
- //! Gets MED TimeStamp values for the given geometric type (const version)
- const TTMeshValue&
- GetMeshValue(EGeometrieElement theGeom) const
- {
- return *(this->GetMeshValuePtr(theGeom));
- }
-
- //! Gets MED TimeStamp values for the given geometric type
- TTMeshValue&
- GetMeshValue(EGeometrieElement theGeom)
- {
- return *(this->GetMeshValuePtr(theGeom));
- }
- };
-
-
- //---------------------------------------------------------------
- typedef TTimeStampValue<TFloatMeshValue> TFloatTimeStampValue;
- typedef SharedPtr<TFloatTimeStampValue> PFloatTimeStampValue;
-
- PFloatTimeStampValue MEDWRAPPER_EXPORT
- CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
-
- typedef TTimeStampValue<TIntMeshValue> TIntTimeStampValue;
- typedef SharedPtr<TIntTimeStampValue> PIntTimeStampValue;
-
- PIntTimeStampValue MEDWRAPPER_EXPORT
- CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
-
-
- //---------------------------------------------------------------
- template<class TMeshValueTypeFrom, class TMeshValueTypeTo>
- void
- CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueTypeFrom> > theTimeStampValueFrom,
- SharedPtr<TTimeStampValue<TMeshValueTypeTo> > theTimeStampValueTo)
- {
- typedef TTimeStampValue<TMeshValueTypeFrom> TimeStampValueTypeFrom;
- typedef TTimeStampValue<TMeshValueTypeTo> TimeStampValueTypeTo;
- typedef typename TMeshValueTypeTo::TElement TElementTo;
-
- typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
- typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
- for(; anIter != aGeom2Value.end(); anIter++){
- const EGeometrieElement& aGeom = anIter->first;
- const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second;
- typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
- aMeshValue2.Allocate(aMeshValue.myNbElem,
- aMeshValue.myNbGauss,
- aMeshValue.myNbComp,
- aMeshValue.myModeSwitch);
- const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue;
- typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue;
- TInt aSize = aValue.size();
- for(TInt anId = 0; anId < aSize; anId++)
- aValue2[anId] = TElementTo(aValue[anId]);
- }
- }
-
- template<class TMeshValueType>
- void
- CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueFrom,
- SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueTo)
- {
- typedef TTimeStampValue<TMeshValueType> TimeStampValueType;
- typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
- typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
- for(; anIter != aGeom2Value.end(); anIter++){
- const EGeometrieElement& aGeom = anIter->first;
- const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second;
- typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
- aMeshValue2 = aMeshValue;
- }
- }
-
- //---------------------------------------------------------------
- inline
- void
- CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom,
- const PTimeStampValueBase& theValueTo)
- {
- if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){
- if(theValueFrom->GetTypeChamp() == eFLOAT64)
- CopyTimeStampValue<TFloatMeshValue>(theValueFrom, theValueTo);
- else if(theValueFrom->GetTypeChamp() == eINT)
- CopyTimeStampValue<TIntMeshValue>(theValueFrom, theValueTo);
- }else{
- if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT)
- CopyTimeStampValue<TFloatMeshValue, TIntMeshValue>(theValueFrom, theValueTo);
- else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64)
- CopyTimeStampValue<TIntMeshValue, TFloatMeshValue>(theValueFrom, theValueTo);
- }
- }
-
-
- //---------------------------------------------------------------
- // Backward compatibility declarations
- typedef TFloatTimeStampValue TTimeStampVal;
- typedef PFloatTimeStampValue PTimeStampVal;
-
- //---------------------------------------------------------------
- typedef std::map<TInt,TFloatVector> TIndexes;
- typedef std::map<TInt,TString> TNames;
-
- //! Define a base class which represents MED Grille (structured mesh)
- struct MEDWRAPPER_EXPORT TGrilleInfo:
- virtual TModeSwitchInfo
- {
-
- PMeshInfo myMeshInfo;
- const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
-
- TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD
- //! Gives coordinates for mesh nodes (const version)
- const TNodeCoord& GetNodeCoord() const;
- TNodeCoord& GetNodeCoord();
- //! Gives coordinates for mesh node by its number, array index from 0
- TNodeCoord GetCoord(TInt theId);
- //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0
- TIntVector GetConn(TInt theId, const bool isSub=false);
-
- EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD)
- //!Gets grille type (const version)
- const EGrilleType& GetGrilleType() const;
- //!Gets grille type
- EGrilleType GetGrilleType();
- //!Sets grille type
- void SetGrilleType(EGrilleType theGrilleType);
-
-
-
- TString myCoordNames; //!< Contains names for the coordinate dimensions
- //! Get name of the coordinate dimension by its order number
- virtual std::string GetCoordName(TInt theId) const = 0 ;
- //! Set name of the coordinate dimension by its order number
- virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
-
- TString myCoordUnits; //!< Contains units for the coordinate dimensions
- //! Get name of unit for the coordinate dimension by its order number
- virtual std::string GetCoordUnit(TInt theId) const = 0;
- //! Set name of unit for the coordinate dimension by its order number
- virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
-
-
- //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
- TIndexes myIndixes;
- //!Gets a map of Tables (const version)
- const TIndexes& GetMapOfIndexes() const ;
- //!Gets a map of Tables
- TIndexes& GetMapOfIndexes();
- //!Gets a Table of indexes for certain axe(const version)
- const TFloatVector& GetIndexes(TInt theAxisNumber) const;
- //!Gets a Table of indexes for certain axe
- TFloatVector& GetIndexes(TInt theAxisNumber);
- //!Gets a number of indices per axe
- TInt GetNbIndexes(TInt theAxisNumber);
-
- TInt GetNbNodes();//! Return count of all points
- TInt GetNbCells();//! Return count of all cells
- TInt GetNbSubCells();//! Return count of all entities of <mesh dimension-1>
- EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension)
- EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension)
- EEntiteMaillage GetEntity();//! Return entity (eMAILLE)
- EEntiteMaillage GetSubEntity();//! Return sub entity
-
- /*!
- *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...)
- */
- TIntVector myGrilleStructure;
- //!Gets grille structure(const version)
- const TIntVector& GetGrilleStructure() const;
- //!Gets grille structure
- TIntVector GetGrilleStructure();
- //!Sets the grille structure of theAxis axe to theNb.
- void SetGrilleStructure(TInt theAxis,TInt theNb);
-
- /*!
- *Defines sequence MED Family indexes for corresponding mesh entites
- */
- TElemNum myFamNum;
- //! Get number of a MED FAMILY by order number of the mesh element
- TInt GetFamNum(TInt theId) const;
- //! Set number of a MED FAMILY for the mesh element with the order number
- void SetFamNum(TInt theId, TInt theVal);
-
- /*!
- *Defines sequence MED Family indexes for sub entites
- */
- TElemNum myFamSubNum;
- //! Get number of a MED FAMILY by order number of sub element
- TInt GetFamSubNum(TInt theId) const;
- //! Set number of a MED FAMILY for theId-th sub element
- void SetFamSubNum(TInt theId, TInt theVal);
-
- /*!
- *Defines sequence MED Family indexes for corresponding mesh nodes
- */
- TElemNum myFamNumNode;
- //! Get number of a MED FAMILY by order number of the mesh node
- TInt GetFamNumNode(TInt theId) const;
- //! Set number of a MED FAMILY for the mesh node with the order number
- void SetFamNumNode(TInt theId, TInt theVal);
-
- };
-
-
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_TStructures_HeaderFile
-#define MED_TStructures_HeaderFile
-
-#include "MED_Structures.hxx"
-
-#ifdef WIN32
-#pragma warning(disable:4250)
-#endif
-
-namespace MED
-{
- //---------------------------------------------------------------
- //! To provide a common way to handle values of MEDWrapper types as native MED types
- template<class TValue, class TRepresentation>
- struct TValueHolder
- {
- TValue& myValue;
- TRepresentation myRepresentation;
-
- TValueHolder(TValue& theValue):
- myValue(theValue),
- myRepresentation(TRepresentation(theValue))
- {}
-
- ~TValueHolder()
- {
- myValue = TValue(myRepresentation);
- }
-
- TRepresentation*
- operator& ()
- {
- return &myRepresentation;
- }
-
- operator TRepresentation () const
- {
- return myRepresentation;
- }
-
- const TValue&
- operator() () const
- {
- return myValue;
- }
- };
-
- //! To customize TValueHolder common template definition for TVector
- template<class TVal, class TRepresentation>
- struct TValueHolder<TVector<TVal>, TRepresentation>
- {
- typedef TVector<TVal> TValue;
- TValue& myValue;
- TRepresentation* myRepresentation;
-
- TValueHolder(TValue& theValue):
- myValue(theValue)
- {
- if(theValue.empty())
- myRepresentation = (TRepresentation*)NULL;
- else
- myRepresentation = (TRepresentation*)&theValue[0];
- }
-
- TRepresentation*
- operator& ()
- {
- return myRepresentation;
- }
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTNameInfo: virtual TNameInfo
- {
- TTNameInfo(const std::string& theValue)
- {
- myName.resize(GetNOMLength<eVersion>()+1);
- SetName(theValue);
- }
-
- virtual
- std::string
- GetName() const
- {
- return GetString(0, GetNOMLength<eVersion>(), myName);
- }
-
- virtual
- void
- SetName(const std::string& theValue)
- {
- SetString(0, GetNOMLength<eVersion>(), myName, theValue);
- }
-
- virtual
- void
- SetName(const TString& theValue)
- {
- SetString(0, GetNOMLength<eVersion>(), myName, theValue);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTMeshInfo:
- virtual TMeshInfo,
- virtual TTNameInfo<eVersion>
- {
- typedef TTNameInfo<eVersion> TNameInfoBase;
-
- TTMeshInfo(const PMeshInfo& theInfo):
- TNameInfoBase(theInfo->GetName())
- {
- myDim = theInfo->GetDim();
- mySpaceDim = theInfo->GetSpaceDim();
- myType = theInfo->GetType();
-
- myDesc.resize(GetDESCLength<eVersion>()+1);
- SetDesc(theInfo->GetDesc());
- }
-
- TTMeshInfo(TInt theDim, TInt theSpaceDim,
- const std::string& theValue,
- EMaillage theType,
- const std::string& theDesc):
- TNameInfoBase(theValue)
- {
- myDim = theDim;
- mySpaceDim = theSpaceDim;
- myType = theType;
-
- myDesc.resize(GetDESCLength<eVersion>()+1);
- SetDesc(theDesc);
- }
-
- virtual
- std::string
- GetDesc() const
- {
- return GetString(0, GetDESCLength<eVersion>(), myDesc);
- }
-
- virtual
- void
- SetDesc(const std::string& theValue)
- {
- SetString(0, GetDESCLength<eVersion>(), myDesc, theValue);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTFamilyInfo:
- virtual TFamilyInfo,
- virtual TTNameInfo<eVersion>
- {
- typedef TTNameInfo<eVersion> TNameInfoBase;
-
- TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo):
- TNameInfoBase(theInfo->GetName())
- {
- myMeshInfo = theMeshInfo;
-
- myId = theInfo->GetId();
-
- myNbGroup = theInfo->GetNbGroup();
- myGroupNames.resize(myNbGroup*GetLNOMLength<eVersion>()+1);
- if(myNbGroup){
- for(TInt anId = 0; anId < myNbGroup; anId++){
- SetGroupName(anId,theInfo->GetGroupName(anId));
- }
- }
-
- myNbAttr = theInfo->GetNbAttr();
- myAttrId.resize(myNbAttr);
- myAttrVal.resize(myNbAttr);
- myAttrDesc.resize(myNbAttr*GetDESCLength<eVersion>()+1);
- if(myNbAttr){
- for(TInt anId = 0; anId < myNbAttr; anId++){
- SetAttrDesc(anId,theInfo->GetAttrDesc(anId));
- myAttrVal[anId] = theInfo->GetAttrVal(anId);
- myAttrId[anId] = theInfo->GetAttrId(anId);
- }
- }
- }
-
- TTFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theNbGroup,
- TInt theNbAttr,
- TInt theId,
- const std::string& theValue):
- TNameInfoBase(theValue)
- {
- myMeshInfo = theMeshInfo;
-
- myId = theId;
-
- myNbGroup = theNbGroup;
- myGroupNames.resize(theNbGroup*GetLNOMLength<eVersion>()+1);
-
- myNbAttr = theNbAttr;
- myAttrId.resize(theNbAttr);
- myAttrVal.resize(theNbAttr);
- myAttrDesc.resize(theNbAttr*GetDESCLength<eVersion>()+1);
- }
-
- TTFamilyInfo(const PMeshInfo& theMeshInfo,
- const std::string& theValue,
- TInt theId,
- const TStringSet& theGroupNames,
- const TStringVector& theAttrDescs,
- const TIntVector& theAttrIds,
- const TIntVector& theAttrVals):
- TNameInfoBase(theValue)
- {
- myMeshInfo = theMeshInfo;
-
- myId = theId;
-
- myNbGroup = (TInt)theGroupNames.size();
- myGroupNames.resize(myNbGroup*GetLNOMLength<eVersion>()+1);
- if(myNbGroup){
- TStringSet::const_iterator anIter = theGroupNames.begin();
- for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){
- const std::string& aVal = *anIter;
- SetGroupName(anId,aVal);
- }
- }
-
- myNbAttr = (TInt)theAttrDescs.size();
- myAttrId.resize(myNbAttr);
- myAttrVal.resize(myNbAttr);
- myAttrDesc.resize(myNbAttr*GetDESCLength<eVersion>()+1);
- if(myNbAttr){
- for(TInt anId = 0, anEnd = (TInt)theAttrDescs.size(); anId < anEnd; anId++){
- SetAttrDesc(anId,theAttrDescs[anId]);
- myAttrVal[anId] = theAttrVals[anId];
- myAttrId[anId] = theAttrIds[anId];
- }
- }
- }
-
- virtual
- std::string
- GetGroupName(TInt theId) const
- {
- return GetString(theId, GetLNOMLength<eVersion>(), myGroupNames);
- }
-
- virtual
- void
- SetGroupName(TInt theId, const std::string& theValue)
- {
- SetString(theId, GetLNOMLength<eVersion>(), myGroupNames, theValue);
- }
-
- virtual
- std::string
- GetAttrDesc(TInt theId) const
- {
- return GetString(theId, GetDESCLength<eVersion>(), myAttrDesc);
- }
-
- virtual
- void
- SetAttrDesc(TInt theId, const std::string& theValue)
- {
- SetString(theId, GetDESCLength<eVersion>(), myAttrDesc, theValue);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTElemInfo: virtual TElemInfo
- {
- TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo)
- {
- myMeshInfo = theMeshInfo;
-
- myNbElem = theInfo->GetNbElem();
- myFamNum.reset(new TElemNum(myNbElem));
- myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
-
- myIsElemNum = theInfo->IsElemNum();
- if(theInfo->IsElemNum())
- myElemNum.reset(new TElemNum(myNbElem));
- else
- myElemNum.reset(new TElemNum());
-
- myIsElemNames = theInfo->IsElemNames();
- if(theInfo->IsElemNames())
- myElemNames.reset(new TString(myNbElem*GetPNOMLength<eVersion>() + 1));
- else
- myElemNames.reset(new TString());
-
- if(theInfo->GetNbElem()){
- for(TInt anId = 0; anId < myNbElem; anId++){
- SetFamNum(anId, theInfo->GetFamNum(anId));
- }
- if(theInfo->IsElemNum() == eVRAI){
- for(TInt anId = 0; anId < myNbElem; anId++){
- SetElemNum(anId, theInfo->GetElemNum(anId));
- }
- }
- if(theInfo->IsElemNames() == eVRAI){
- for(TInt anId = 0; anId < myNbElem; anId++){
- SetElemName(anId,theInfo->GetElemName(anId));
- }
- }
- }
- }
-
- TTElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames)
- {
- myMeshInfo = theMeshInfo;
-
- myNbElem = theNbElem;
- myFamNum.reset(new TElemNum(theNbElem));
- myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
-
- myIsElemNum = theIsElemNum;
- if(theIsElemNum)
- myElemNum.reset(new TElemNum(theNbElem));
- else
- myElemNum.reset(new TElemNum());
-
- myIsElemNames = theIsElemNames;
- if(theIsElemNames)
- myElemNames.reset(new TString(theNbElem*GetPNOMLength<eVersion>() + 1));
- else
- myElemNames.reset(new TString());
- }
-
- TTElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
- const TStringVector& theElemNames)
- {
- myMeshInfo = theMeshInfo;
-
- myNbElem = theNbElem;
- myFamNum.reset(new TElemNum(theNbElem));
- myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
-
- myIsElemNum = theElemNums.size()? eVRAI: eFAUX;
- if(myIsElemNum)
- myElemNum.reset(new TElemNum(theNbElem));
- else
- myElemNum.reset(new TElemNum());
-
- myIsElemNames = theElemNames.size()? eVRAI: eFAUX;
- if(myIsElemNames)
- myElemNames.reset(new TString(theNbElem*GetPNOMLength<eVersion>() + 1));
- else
- myElemNames.reset(new TString());
-
- if(theNbElem){
-
- if(theFamilyNums.size())
- *myFamNum = theFamilyNums;
-
- if(myIsElemNum)
- *myElemNum = theElemNums;
-
- if(myIsElemNames){
- for(TInt anId = 0; anId < theNbElem; anId++){
- const std::string& aVal = theElemNames[anId];
- SetElemName(anId,aVal);
- }
- }
- }
- }
-
- virtual
- std::string
- GetElemName(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(), *myElemNames);
- }
-
- virtual
- void
- SetElemName(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(), *myElemNames, theValue);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTNodeInfo:
- virtual TNodeInfo,
- virtual TTElemInfo<eVersion>
- {
- typedef TTElemInfo<eVersion> TElemInfoBase;
-
- TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo):
- TNodeInfo(theInfo),
- TElemInfoBase(theMeshInfo, theInfo)
- {
- myModeSwitch = theInfo->GetModeSwitch();
-
- mySystem = theInfo->GetSystem();
-
- myCoord.reset(new TNodeCoord(*theInfo->myCoord));
-
- TInt aSpaceDim = theMeshInfo->GetSpaceDim();
-
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- for(TInt anId = 0; anId < aSpaceDim; anId++)
- SetCoordName(anId,theInfo->GetCoordName(anId));
-
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- for(TInt anId = 0; anId < aSpaceDim; anId++)
- SetCoordUnit(anId,theInfo->GetCoordUnit(anId));
- }
-
- TTNodeInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EModeSwitch theMode,
- ERepere theSystem,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames):
- TModeSwitchInfo(theMode),
- TElemInfoBase(theMeshInfo,
- theNbElem,
- theIsElemNum,
- theIsElemNames)
- {
- mySystem = theSystem;
-
- myCoord.reset(new TNodeCoord(theNbElem * theMeshInfo->mySpaceDim));
-
- myCoordUnits.resize(theMeshInfo->mySpaceDim*GetPNOMLength<eVersion>()+1);
-
- myCoordNames.resize(theMeshInfo->mySpaceDim*GetPNOMLength<eVersion>()+1);
- }
-
-
- TTNodeInfo(const PMeshInfo& theMeshInfo,
- const TFloatVector& theNodeCoords,
- EModeSwitch theMode,
- ERepere theSystem,
- const TStringVector& theCoordNames,
- const TStringVector& theCoordUnits,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
- const TStringVector& theElemNames):
- TModeSwitchInfo(theMode),
- TElemInfoBase(theMeshInfo,
- (TInt)theNodeCoords.size()/theMeshInfo->GetDim(),
- theFamilyNums,
- theElemNums,
- theElemNames)
- {
- mySystem = theSystem;
-
- myCoord.reset(new TNodeCoord(theNodeCoords));
-
- TInt aSpaceDim = theMeshInfo->GetSpaceDim();
-
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- if(!theCoordNames.empty())
- for(TInt anId = 0; anId < aSpaceDim; anId++)
- SetCoordName(anId,theCoordNames[anId]);
-
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>() + 1);
- if(!theCoordUnits.empty())
- for(TInt anId = 0; anId < aSpaceDim; anId++)
- SetCoordUnit(anId, theCoordUnits[anId]);
- }
-
- virtual
- std::string
- GetCoordName(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(),myCoordNames);
- }
-
- virtual
- void
- SetCoordName(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(),myCoordNames,theValue);
- }
-
- virtual
- std::string
- GetCoordUnit(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(),myCoordUnits);
- }
-
- virtual
- void
- SetCoordUnit(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(),myCoordUnits,theValue);
- }
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTPolygoneInfo:
- virtual TPolygoneInfo,
- virtual TTElemInfo<eVersion>
- {
- typedef TTElemInfo<eVersion> TElemInfoBase;
-
- TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo):
- TElemInfoBase(theMeshInfo,theInfo)
- {
- myEntity = theInfo->GetEntity();
- myGeom = theInfo->GetGeom();
-
- myIndex.reset(new TElemNum(*theInfo->myIndex));
- myConn.reset(new TElemNum(*theInfo->myConn));
-
- myConnMode = theInfo->GetConnMode();
- }
-
- TTPolygoneInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theConnSize,
- EConnectivite theConnMode,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames):
- TElemInfoBase(theMeshInfo,
- theNbElem,
- theIsElemNum,
- theIsElemNames)
- {
- myEntity = theEntity;
- myGeom = theGeom;
-
- myIndex.reset(new TElemNum(theNbElem + 1));
- myConn.reset(new TElemNum(theConnSize));
-
- myConnMode = theConnMode;
- }
-
- TTPolygoneInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theIndexes,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
- const TStringVector& theElemNames):
- TElemInfoBase(theMeshInfo,
- (TInt)theIndexes.size() - 1,
- theFamilyNums,
- theElemNums,
- theElemNames)
- {
- myEntity = theEntity;
- myGeom = theGeom;
-
- myIndex.reset(new TElemNum(theIndexes));
- myConn.reset(new TElemNum(theConnectivities));
-
- myConnMode = theConnMode;
- }
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTPolyedreInfo:
- virtual TPolyedreInfo,
- virtual TTElemInfo<eVersion>
- {
- typedef TTElemInfo<eVersion> TElemInfoBase;
-
- TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo):
- TElemInfoBase(theMeshInfo,theInfo)
- {
- myEntity = theInfo->GetEntity();
- myGeom = theInfo->GetGeom();
-
- myIndex.reset(new TElemNum(*theInfo->myIndex));
- myFaces.reset(new TElemNum(*theInfo->myFaces));
- myConn.reset(new TElemNum(*theInfo->myConn));
-
- myConnMode = theInfo->GetConnMode();
- }
-
- TTPolyedreInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theNbFaces,
- TInt theConnSize,
- EConnectivite theConnMode,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames):
- TElemInfoBase(theMeshInfo,
- theNbElem,
- theIsElemNum,
- theIsElemNames)
- {
- myEntity = theEntity;
- myGeom = theGeom;
-
- myIndex.reset(new TElemNum(theNbElem + 1));
- myFaces.reset(new TElemNum(theNbFaces));
- myConn.reset(new TElemNum(theConnSize));
-
- myConnMode = theConnMode;
- }
-
- TTPolyedreInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theIndexes,
- const TIntVector& theFaces,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
- const TStringVector& theElemNames):
- TElemInfoBase(theMeshInfo,
- (TInt)theIndexes.size()-1,
- theFamilyNums,
- theElemNums,
- theElemNames)
- {
- myEntity = theEntity;
- myGeom = theGeom;
-
- myIndex.reset(new TElemNum(theIndexes));
- myFaces.reset(new TElemNum(theFaces));
- myConn.reset(new TElemNum(theConnectivities));
-
- myConnMode = theConnMode;
- }
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTCellInfo:
- virtual TCellInfo,
- virtual TTElemInfo<eVersion>
- {
- typedef TTElemInfo<eVersion> TElemInfoBase;
-
- TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo):
- TElemInfoBase(theMeshInfo,theInfo)
- {
- myEntity = theInfo->GetEntity();
- myGeom = theInfo->GetGeom();
- myConnMode = theInfo->GetConnMode();
-
- TInt aConnDim = GetNbNodes(myGeom);
- TInt aNbConn = GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
- myConn.reset(new TElemNum(myNbElem * aNbConn));
- for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
- TConnSlice aConnSlice = GetConnSlice(anElemId);
- TCConnSlice aConnSlice2 = theInfo->GetConnSlice(anElemId);
- for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
- aConnSlice[anConnId] = aConnSlice2[anConnId];
- }
- }
- }
-
- TTCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TInt theNbElem,
- EConnectivite theConnMode,
- EBooleen theIsElemNum,
- EBooleen theIsElemNames,
- EModeSwitch theMode):
- TModeSwitchInfo(theMode),
- TElemInfoBase(theMeshInfo,
- theNbElem,
- theIsElemNum,
- theIsElemNames)
- {
- myEntity = theEntity;
- myGeom = theGeom;
-
- myConnMode = theConnMode;
- TInt aNbConn = GetNbConn<eVersion>(theGeom, myEntity, theMeshInfo->myDim);
- myConn.reset(new TElemNum(theNbElem * aNbConn));
- }
-
- TTCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums,
- const TStringVector& theElemNames,
- EModeSwitch theMode):
- TModeSwitchInfo(theMode),
- TElemInfoBase(theMeshInfo,
- (TInt)theConnectivities.size() / GetNbNodes(theGeom),
- theFamilyNums,
- theElemNums,
- theElemNames)
- {
- myEntity = theEntity;
- myGeom = theGeom;
-
- myConnMode = theConnMode;
- TInt aConnDim = GetNbNodes(myGeom);
- TInt aNbConn = GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
- myConn.reset(new TElemNum(myNbElem * aNbConn));
- for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
- TConnSlice aConnSlice = GetConnSlice(anElemId);
- for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
- aConnSlice[anConnId] = theConnectivities[anElemId*aConnDim + anConnId];
- }
- }
- }
-
- virtual
- TInt
- GetConnDim() const
- {
- return GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
- }
-
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTBallInfo:
- virtual TBallInfo,
- virtual TTCellInfo<eVersion>
- {
- typedef TTCellInfo<eVersion> TCellInfoBase;
-
- TTBallInfo(const PMeshInfo& theMeshInfo, const PBallInfo& theInfo):
- TCellInfoBase::TElemInfoBase(theMeshInfo, theInfo),
- TCellInfoBase(theMeshInfo,theInfo)
- {
- myDiameters = theInfo->myDiameters;
- }
-
- TTBallInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EBooleen theIsElemNum ):
- TCellInfoBase::TElemInfoBase(theMeshInfo,
- theNbElem,
- theIsElemNum,
- /*theIsElemNames=*/eFAUX),
- TCellInfoBase(theMeshInfo,
- eSTRUCT_ELEMENT,
- eBALL,
- theNbElem,
- /*EConnectivite=*/eNOD,
- theIsElemNum,
- /*theIsElemNames=*/eFAUX,
- eFULL_INTERLACE)
- {
- myDiameters.resize( theNbElem );
- }
-
- TTBallInfo(const PMeshInfo& theMeshInfo,
- const TIntVector& theNodes,
- TFloatVector& theDiameters,
- const TIntVector& theFamilyNums,
- const TIntVector& theElemNums):
- TCellInfoBase::TElemInfoBase(theMeshInfo,
- (TInt)std::max(theNodes.size(),theDiameters.size() ),
- theFamilyNums,
- theElemNums,
- TStringVector()),
- TCellInfoBase(theMeshInfo,
- eSTRUCT_ELEMENT,
- eBALL,
- theNodes,
- /*EConnectivite=*/eNOD,
- theFamilyNums,
- theElemNums,
- TStringVector(),
- eFULL_INTERLACE)
- {
- myDiameters.swap( theDiameters );
- }
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTFieldInfo:
- virtual TFieldInfo,
- virtual TTNameInfo<eVersion>
- {
- typedef TTNameInfo<eVersion> TNameInfoBase;
-
- TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo):
- TNameInfoBase(theInfo->GetName())
- {
- myMeshInfo = theMeshInfo;
-
- myNbComp = theInfo->GetNbComp();
- myCompNames.resize(myNbComp*GetPNOMLength<eVersion>()+1);
- for(TInt anId = 0; anId < myNbComp; anId++){
- SetCompName(anId,theInfo->GetCompName(anId));
- }
-
- myUnitNames.resize(myNbComp*GetPNOMLength<eVersion>()+1);
- for(TInt anId = 0; anId < myNbComp; anId++){
- SetUnitName(anId,theInfo->GetUnitName(anId));
- }
-
- myType = theInfo->GetType();
-
- myIsLocal = theInfo->GetIsLocal();
- myNbRef = theInfo->GetNbRef();
- }
-
- TTFieldInfo(const PMeshInfo& theMeshInfo,
- TInt theNbComp,
- ETypeChamp theType,
- const std::string& theValue,
- EBooleen theIsLocal,
- TInt theNbRef):
- TNameInfoBase(theValue)
- {
- myMeshInfo = theMeshInfo;
-
- myNbComp = theNbComp;
- myCompNames.resize(theNbComp*GetPNOMLength<eVersion>()+1);
- myUnitNames.resize(theNbComp*GetPNOMLength<eVersion>()+1);
-
- myType = theType;
-
- myIsLocal = theIsLocal;
- myNbRef = theNbRef;
- }
-
- virtual
- std::string
- GetCompName(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(),myCompNames);
- }
-
- virtual
- void
- SetCompName(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(),myCompNames,theValue);
- }
-
- virtual
- std::string
- GetUnitName(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(),myUnitNames);
- }
-
- virtual
- void
- SetUnitName(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(),myUnitNames,theValue);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTGaussInfo:
- virtual TGaussInfo,
- virtual TTNameInfo<eVersion>
- {
- typedef TTNameInfo<eVersion> TNameInfoBase;
-
- TTGaussInfo(const TGaussInfo::TInfo& theInfo,
- EModeSwitch theMode):
- TModeSwitchInfo(theMode),
- TNameInfoBase(boost::get<1>(boost::get<0>(theInfo)))
- {
- const TGaussInfo::TKey& aKey = boost::get<0>(theInfo);
-
- myGeom = boost::get<0>(aKey);
- myRefCoord.resize(GetNbRef()*GetDim());
-
- TInt aNbGauss = boost::get<1>(theInfo);
- myGaussCoord.resize(aNbGauss*GetDim());
- myWeight.resize(aNbGauss);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTTimeStampInfo: virtual TTimeStampInfo
- {
- TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo)
- {
- myFieldInfo = theFieldInfo;
-
- myEntity = theInfo->GetEntity();
- myGeom2Size = theInfo->GetGeom2Size();
-
- myNumDt = theInfo->GetNumDt();
- myNumOrd = theInfo->GetNumOrd();
- myDt = theInfo->GetDt();
-
- myUnitDt.resize(GetPNOMLength<eVersion>()+1);
- SetUnitDt(theInfo->GetUnitDt());
-
- myGeom2NbGauss = theInfo->myGeom2NbGauss;
- myGeom2Gauss = theInfo->GetGeom2Gauss();
- }
-
- TTTimeStampInfo(const PFieldInfo& theFieldInfo,
- EEntiteMaillage theEntity,
- const TGeom2Size& theGeom2Size,
- const TGeom2NbGauss& theGeom2NbGauss,
- TInt theNumDt,
- TInt theNumOrd,
- TFloat theDt,
- const std::string& theUnitDt,
- const TGeom2Gauss& theGeom2Gauss)
- {
- myFieldInfo = theFieldInfo;
-
- myEntity = theEntity;
- myGeom2Size = theGeom2Size;
-
- myNumDt = theNumDt;
- myNumOrd = theNumDt;
- myDt = theDt;
-
- myUnitDt.resize(GetPNOMLength<eVersion>()+1);
- SetUnitDt(theUnitDt);
-
- myGeom2NbGauss = theGeom2NbGauss;
- myGeom2Gauss = theGeom2Gauss;
- }
-
- virtual
- std::string
- GetUnitDt() const
- {
- return GetString(0,GetPNOMLength<eVersion>(),myUnitDt);
- }
-
- virtual
- void
- SetUnitDt(const std::string& theValue)
- {
- SetString(0,GetPNOMLength<eVersion>(),myUnitDt,theValue);
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTProfileInfo:
- virtual TProfileInfo,
- virtual TTNameInfo<eVersion>
- {
- typedef TTNameInfo<eVersion> TNameInfoBase;
-
- TTProfileInfo(const TProfileInfo::TInfo& theInfo,
- EModeProfil theMode):
- TNameInfoBase(boost::get<0>(theInfo))
- {
- TInt aSize = boost::get<1>(theInfo);
- myElemNum.reset(new TElemNum(aSize));
- myMode = aSize > 0? theMode: eNO_PFLMOD;
- }
- };
-
-
- //---------------------------------------------------------------
- template<EVersion eVersion, class TMeshValueType>
- struct TTTimeStampValue: virtual TTimeStampValue<TMeshValueType>
- {
- TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampValueBase& theInfo,
- ETypeChamp theTypeChamp)
- {
- typedef TTimeStampValue<TMeshValueType> TCompatible;
- if(TCompatible* aCompatible = dynamic_cast<TCompatible*>(theInfo.get())){
- this->myTimeStampInfo = theTimeStampInfo;
- this->myTypeChamp = theTypeChamp;
- this->myGeom2Profile = aCompatible->GetGeom2Profile();
- this->myGeom2Value = aCompatible->myGeom2Value;
- this->myGeomSet = aCompatible->GetGeomSet();
- }else
- EXCEPTION(std::runtime_error,"TTTimeStampValue::TTTimeStampValue - use incompatible arguments!");
- }
-
- TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- ETypeChamp theTypeChamp,
- const TGeom2Profile& theGeom2Profile,
- EModeSwitch theMode):
- TModeSwitchInfo(theMode)
- {
- this->myTimeStampInfo = theTimeStampInfo;
-
- this->myTypeChamp = theTypeChamp;
-
- this->myGeom2Profile = theGeom2Profile;
-
- TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp;
-
- const TGeom2Size& aGeom2Size = theTimeStampInfo->GetGeom2Size();
- TGeom2Size::const_iterator anIter = aGeom2Size.begin();
- for(; anIter != aGeom2Size.end(); anIter++){
- const EGeometrieElement& aGeom = anIter->first;
- TInt aNbElem = anIter->second;
-
- MED::PProfileInfo aProfileInfo;
- MED::TGeom2Profile::const_iterator anIter = theGeom2Profile.find(aGeom);
- if(anIter != theGeom2Profile.end())
- aProfileInfo = anIter->second;
-
- if(aProfileInfo && aProfileInfo->IsPresent())
- aNbElem = aProfileInfo->GetSize();
-
- TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom);
-
- this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp);
- }
- }
-
- virtual
- size_t
- GetValueSize(EGeometrieElement theGeom) const
- {
- return this->GetMeshValue(theGeom).GetSize();
- }
-
- virtual
- size_t
- GetNbVal(EGeometrieElement theGeom) const
- {
- return this->GetMeshValue(theGeom).GetNbVal();
- }
-
- virtual
- size_t
- GetNbGauss(EGeometrieElement theGeom) const
- {
- return this->GetMeshValue(theGeom).GetNbGauss();
- }
-
- virtual
- void
- AllocateValue(EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theNbGauss,
- TInt theNbComp,
- EModeSwitch theMode = eFULL_INTERLACE)
- {
- this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode);
- }
-
- virtual
- unsigned char*
- GetValuePtr(EGeometrieElement theGeom)
- {
- return this->GetMeshValue(theGeom).GetValuePtr();
- }
- };
-
- //---------------------------------------------------------------
- template<EVersion eVersion>
- struct TTGrilleInfo:
- virtual TGrilleInfo
- {
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
- const PGrilleInfo& theInfo)
- {
- myMeshInfo = theMeshInfo;
-
- myCoord = theInfo->GetNodeCoord();
-
- myGrilleType = theInfo->GetGrilleType();
-
- myCoordNames = theInfo->myCoordNames;
-
- myCoordUnits = theInfo->myCoordUnits;
-
- myIndixes = theInfo->GetMapOfIndexes();
-
- myGrilleStructure = theInfo->GetGrilleStructure();
-
- myGrilleType = theInfo->GetGrilleType();
-
- myFamNumNode.resize(theInfo->GetNbNodes());
- myFamNumNode = theInfo->myFamNumNode;
-
- myFamNum = theInfo->myFamNum;
- }
-
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
- const TInt nnoeuds)
- {
- myMeshInfo = theMeshInfo;
- TInt aSpaceDim = theMeshInfo->GetSpaceDim();
- if(type == eGRILLE_STANDARD){
- myCoord.resize(aSpaceDim*nnoeuds);
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- } else { //if(type == eGRILLE_CARTESIENNE){
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
- }
- myGrilleStructure.resize(aSpaceDim);
- myFamNumNode.resize(nnoeuds);
- }
-
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type)
- {
- myMeshInfo = theMeshInfo;
- TInt aSpaceDim = theMeshInfo->GetSpaceDim();
- if(type == eGRILLE_STANDARD){
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- } else {// if(type == eGRILLE_CARTESIENNE){
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
- }
- myGrilleStructure.resize(aSpaceDim);
- }
-
- TTGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
- const MED::TIntVector& nbNodeVec)
- {
- myMeshInfo = theMeshInfo;
-
- TInt aSpaceDim = theMeshInfo->GetSpaceDim();
- if(type == eGRILLE_STANDARD){
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
- } else {// if(type == eGRILLE_CARTESIENNE){
- myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
- myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
- }
-
- if(type != eGRILLE_STANDARD)
- for(unsigned int aAxe=0;aAxe<nbNodeVec.size();aAxe++){
- myIndixes[aAxe].resize(nbNodeVec[aAxe]);
- }
- myGrilleStructure.resize(aSpaceDim);
- }
-
- virtual
- std::string
- GetCoordName(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(),myCoordNames);
- }
-
- virtual
- void
- SetCoordName(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(),myCoordNames,theValue);
- }
-
- virtual
- std::string
- GetCoordUnit(TInt theId) const
- {
- return GetString(theId,GetPNOMLength<eVersion>(),myCoordUnits);
- }
-
- virtual
- void
- SetCoordUnit(TInt theId, const std::string& theValue)
- {
- SetString(theId,GetPNOMLength<eVersion>(),myCoordUnits,theValue);
- }
-
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_TWrapper_HeaderFile
-#define MED_TWrapper_HeaderFile
-
-#include "MED_TStructures.hxx"
-#include "MED_Wrapper.hxx"
-
-namespace MED
-{
-
- template<EVersion eVersion>
- class TTWrapper: public TWrapper
- {
- public:
- //----------------------------------------------------------------------------
- //! Gets version of the MED library used for the MED file
- virtual
- EVersion
- GetVersion()
- {
- return eVersion;
- }
-
- //----------------------------------------------------------------------------
- virtual
- PMeshInfo
- CrMeshInfo(TInt theDim = 0, TInt theSpaceDim = 0,
- const std::string& theValue = "",
- EMaillage theType = eNON_STRUCTURE,
- const std::string& theDesc = "")
- {
- return PMeshInfo(new TTMeshInfo<eVersion>
- (theDim,
- theSpaceDim,
- theValue,
- theType,
- theDesc));
- }
-
- virtual
- PMeshInfo
- CrMeshInfo(const PMeshInfo& theInfo)
- {
- return PMeshInfo(new TTMeshInfo<eVersion>(theInfo));
- }
-
-
- //----------------------------------------------------------------------------
- virtual
- PFamilyInfo
- CrFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theNbGroup = 0,
- TInt theNbAttr = 0,
- TInt theId = 0,
- const std::string& theValue = "")
- {
- return PFamilyInfo(new TTFamilyInfo<eVersion>
- (theMeshInfo,
- theNbGroup,
- theNbAttr,
- theId,
- theValue));
- }
-
- virtual
- PFamilyInfo
- CrFamilyInfo(const PMeshInfo& theMeshInfo,
- const std::string& theValue,
- TInt theId,
- const MED::TStringSet& theGroupNames,
- const MED::TStringVector& theAttrDescs = MED::TStringVector(),
- const MED::TIntVector& theAttrIds = MED::TIntVector(),
- const MED::TIntVector& theAttrVals = MED::TIntVector())
- {
- return PFamilyInfo(new TTFamilyInfo<eVersion>
- (theMeshInfo,
- theValue,
- theId,
- theGroupNames,
- theAttrDescs,
- theAttrIds,
- theAttrVals));
- }
-
- virtual
- PFamilyInfo
- CrFamilyInfo(const PMeshInfo& theMeshInfo,
- const PFamilyInfo& theInfo)
- {
- return PFamilyInfo(new TTFamilyInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
-
- //----------------------------------------------------------------------------
- virtual
- PElemInfo
- CrElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI)
- {
- return PElemInfo(new TTElemInfo<eVersion>
- (theMeshInfo,
- theNbElem,
- theIsElemNum,
- theIsElemNames));
- }
-
- virtual
- PElemInfo
- CrElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- const TIntVector& theFamNum,
- const TIntVector& aElemNum,
- const TStringVector& aElemNames)
- {
- return PElemInfo(new TTElemInfo<eVersion>
- (theMeshInfo,
- theNbElem,
- theFamNum,
- aElemNum,
- aElemNames));
- }
-
- //----------------------------------------------------------------------------
- virtual
- PNodeInfo
- CrNodeInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EModeSwitch theMode = eFULL_INTERLACE,
- ERepere theSystem = eCART,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI)
- {
- return PNodeInfo(new TTNodeInfo<eVersion>
- (theMeshInfo,
- theNbElem,
- theMode,
- theSystem,
- theIsElemNum,
- theIsElemNames));
- }
-
- virtual
- PNodeInfo
- CrNodeInfo(const PMeshInfo& theMeshInfo,
- const TFloatVector& theNodeCoords,
- EModeSwitch theMode = eFULL_INTERLACE,
- ERepere theSystem = eCART,
- const TStringVector& theCoordNames = TStringVector(),
- const TStringVector& theCoordUnits = TStringVector(),
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector(),
- const TStringVector& theElemNames = TStringVector())
- {
- return PNodeInfo(new TTNodeInfo<eVersion>
- (theMeshInfo,
- theNodeCoords,
- theMode,
- theSystem,
- theCoordNames,
- theCoordUnits,
- theFamilyNums,
- theElemNums,
- theElemNames));
- }
-
- virtual
- PNodeInfo
- CrNodeInfo(const PMeshInfo& theMeshInfo,
- const PNodeInfo& theInfo)
- {
- return PNodeInfo(new TTNodeInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
-
- //----------------------------------------------------------------------------
- virtual
- PPolygoneInfo
- CrPolygoneInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theConnSize,
- EConnectivite theConnMode = eNOD,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI)
- {
- return PPolygoneInfo(new TTPolygoneInfo<eVersion>
- (theMeshInfo,
- theEntity,
- theGeom,
- theNbElem,
- theConnSize,
- theConnMode,
- theIsElemNum,
- theIsElemNames));
- }
-
- 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())
- {
- return PPolygoneInfo(new TTPolygoneInfo<eVersion>
- (theMeshInfo,
- theEntity,
- theGeom,
- theIndexes,
- theConnectivities,
- theConnMode,
- theFamilyNums,
- theElemNums,
- theElemNames));
- }
-
- virtual
- PPolygoneInfo
- CrPolygoneInfo(const PMeshInfo& theMeshInfo,
- const PPolygoneInfo& theInfo)
- {
- return PPolygoneInfo(new TTPolygoneInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
-
- //----------------------------------------------------------------------------
- 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)
- {
- return PPolyedreInfo(new TTPolyedreInfo<eVersion>
- (theMeshInfo,
- theEntity,
- theGeom,
- theNbElem,
- theNbFaces,
- theConnSize,
- theConnMode,
- theIsElemNum,
- theIsElemNames));
- }
-
- virtual
- PPolyedreInfo
- CrPolyedreInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theIndexes,
- const TIntVector& theFaces,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode = eNOD,
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector(),
- const TStringVector& theElemNames = TStringVector())
- {
- return PPolyedreInfo(new TTPolyedreInfo<eVersion>
- (theMeshInfo,
- theEntity,
- theGeom,
- theIndexes,
- theFaces,
- theConnectivities,
- theConnMode,
- theFamilyNums,
- theElemNums,
- theElemNames));
- }
-
- virtual
- PPolyedreInfo
- CrPolyedreInfo(const PMeshInfo& theMeshInfo,
- const PPolyedreInfo& theInfo)
- {
- return PPolyedreInfo(new TTPolyedreInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
-
- //----------------------------------------------------------------------------
- virtual
- PCellInfo
- CrCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TInt theNbElem,
- EConnectivite theConnMode = eNOD,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI,
- EModeSwitch theMode = eFULL_INTERLACE)
- {
- return PCellInfo(new TTCellInfo<eVersion>
- (theMeshInfo,
- theEntity,
- theGeom,
- theNbElem,
- theConnMode,
- theIsElemNum,
- theIsElemNames,
- theMode));
- }
-
- virtual
- PCellInfo
- CrCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode = eNOD,
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector(),
- const TStringVector& theElemNames = TStringVector(),
- EModeSwitch theMode = eFULL_INTERLACE)
- {
- return PCellInfo(new TTCellInfo<eVersion>
- (theMeshInfo,
- theEntity,
- theGeom,
- theConnectivities,
- theConnMode,
- theFamilyNums,
- theElemNums,
- theElemNames,
- theMode));
- }
-
- virtual
- PCellInfo
- CrCellInfo(const PMeshInfo& theMeshInfo,
- const PCellInfo& theInfo)
- {
- return PCellInfo(new TTCellInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
-
- //----------------------------------------------------------------------------
- //! Creates a MEDWrapper MED Balls representation
- virtual PBallInfo CrBallInfo(const PMeshInfo& theMeshInfo,
- TInt theNbBalls,
- EBooleen theIsElemNum = eVRAI)
- {
- return PBallInfo( new TTBallInfo<eVersion>( theMeshInfo, theNbBalls, theIsElemNum ));
- }
-
- //! Creates a MEDWrapper MED Balls representation
- virtual PBallInfo CrBallInfo(const PMeshInfo& theMeshInfo,
- const TIntVector& theNodes,
- TFloatVector& theDiameters,
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector())
- {
- return PBallInfo( new TTBallInfo<eVersion>( theMeshInfo, theNodes, theDiameters,
- theFamilyNums, theElemNums));
- }
-
- //! A copy-constructor for the MEDWrapper MED Balls representation
- virtual PBallInfo CrBallInfo(const PMeshInfo& theMeshInfo,
- const PBallInfo& theInfo)
- {
- return PBallInfo( new TTBallInfo<eVersion>( theMeshInfo, theInfo ));
- }
-
- //----------------------------------------------------------------------------
- virtual
- PFieldInfo
- CrFieldInfo(const PMeshInfo& theMeshInfo,
- TInt theNbComp = 0,
- ETypeChamp theType = eFLOAT64,
- const std::string& theValue = "",
- EBooleen theIsLocal = eVRAI,
- TInt theNbRef = 1)
- {
- return PFieldInfo(new TTFieldInfo<eVersion>
- (theMeshInfo,
- theNbComp,
- theType,
- theValue,
- theIsLocal,
- theNbRef));
- }
-
- virtual
- PFieldInfo
- CrFieldInfo(const PMeshInfo& theMeshInfo,
- const PFieldInfo& theInfo)
- {
- return PFieldInfo(new TTFieldInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
-
-
- //----------------------------------------------------------------------------
- virtual
- PTimeStampInfo
- CrTimeStampInfo(const PFieldInfo& theFieldInfo,
- EEntiteMaillage theEntity,
- const TGeom2Size& theGeom2Size,
- const TGeom2NbGauss& theGeom2NbGauss = TGeom2NbGauss(),
- TInt theNumDt = 0,
- TInt theNumOrd = 0,
- TFloat theDt = 0,
- const std::string& theUnitDt = "",
- const TGeom2Gauss& theGeom2Gauss = TGeom2Gauss())
- {
- return PTimeStampInfo(new TTTimeStampInfo<eVersion>
- (theFieldInfo,
- theEntity,
- theGeom2Size,
- theGeom2NbGauss,
- theNumDt,
- theNumOrd,
- theDt,
- theUnitDt,
- theGeom2Gauss));
- }
-
- virtual
- PTimeStampInfo
- CrTimeStampInfo(const PFieldInfo& theFieldInfo,
- const PTimeStampInfo& theInfo)
- {
- return PTimeStampInfo(new TTTimeStampInfo<eVersion>
- (theFieldInfo,
- theInfo));
- }
-
-
- //----------------------------------------------------------------------------
- virtual
- PGaussInfo
- CrGaussInfo(const TGaussInfo::TInfo& theInfo,
- EModeSwitch theMode = eFULL_INTERLACE)
- {
- return PGaussInfo(new TTGaussInfo<eVersion>
- (theInfo,
- theMode));
- }
-
-
- //----------------------------------------------------------------------------
- virtual
- PProfileInfo
- CrProfileInfo(const TProfileInfo::TInfo& theInfo,
- EModeProfil theMode = eCOMPACT)
- {
- return PProfileInfo(new TTProfileInfo<eVersion>
- (theInfo,
- theMode));
- }
-
-
- //----------------------------------------------------------------------------
- virtual
- PTimeStampValueBase
- CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- ETypeChamp theTypeChamp,
- const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
- EModeSwitch theMode = eFULL_INTERLACE)
- {
- if(theTypeChamp == eFLOAT64)
- return PTimeStampValueBase(new TTTimeStampValue<eVersion, TFloatMeshValue>
- (theTimeStampInfo,
- theTypeChamp,
- theGeom2Profile,
- theMode));
- return PTimeStampValueBase(new TTTimeStampValue<eVersion, TIntMeshValue>
- (theTimeStampInfo,
- theTypeChamp,
- theGeom2Profile,
- theMode));
- }
-
- virtual
- PTimeStampValueBase
- CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampValueBase& theInfo,
- ETypeChamp theTypeChamp)
- {
- if(theTypeChamp == eFLOAT64)
- return PTimeStampValueBase(new TTTimeStampValue<eVersion, TFloatMeshValue>
- (theTimeStampInfo,
- theInfo,
- theTypeChamp));
- return PTimeStampValueBase(new TTTimeStampValue<eVersion, TIntMeshValue>
- (theTimeStampInfo,
- theInfo,
- theTypeChamp));
- }
-
- //----------------------------------------------------------------------------
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const PGrilleInfo& theInfo)
- {
- return PGrilleInfo(new TTGrilleInfo<eVersion>
- (theMeshInfo,
- theInfo));
- }
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type)
- {
- return PGrilleInfo(new TTGrilleInfo<eVersion>
- (theMeshInfo,
- type));
- }
-
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
- const TInt& nbNodes)
- {
- return PGrilleInfo(new TTGrilleInfo<eVersion>
- (theMeshInfo,
- type,
- nbNodes));
- }
-
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
- const MED::TIntVector& nbNodeVec)
- {
- return PGrilleInfo(new TTGrilleInfo<eVersion>
- (theMeshInfo,
- type,
- nbNodeVec));
- }
- //----------------------------------------------------------------------------
- };
-
-}
-
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#include "MED_Utilities.hxx"
-#include "MED_Common.hxx"
-
-using namespace std;
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-// static int MYDEBUG = 0;
-#endif
-
-
-int MED::PrefixPrinter::myCounter = 0;
-
-MED::PrefixPrinter::PrefixPrinter(bool theIsActive):
- myIsActive(theIsActive)
-{
- if(myIsActive)
- myCounter++;
- MSG(MYDEBUG,"MED::PrefixPrinter::PrefixPrinter(...)- "<<myCounter);
-}
-
-MED::PrefixPrinter::~PrefixPrinter()
-{
- if(myIsActive){
- myCounter--;
- if(myCounter < 0)
- EXCEPTION(runtime_error,"PrefixPrinter::~PrefixPrinter() - myCounter("<<myCounter<<") < 0");
- }
-}
-
-string MED::PrefixPrinter::GetPrefix()
-{
- if(myCounter){
- if(myCounter < 0)
- EXCEPTION(runtime_error,"PrefixPrinter::~PrefixPrinter() - myCounter("<<myCounter<<") < 0");
- return string(myCounter*2,' ');
- }
- return "";
-}
-
-
-static MED::TEntity2GeomSet Entity2GeomSet;
-
-bool InitEntity2GeomSet()
-{
- using namespace MED;
-
- TGeomSet& aGeomARETESet = Entity2GeomSet[eARETE];
- aGeomARETESet.insert(eSEG2);
- aGeomARETESet.insert(eSEG3);
-
- TGeomSet& aGeomFACESet = Entity2GeomSet[eFACE];
- aGeomFACESet.insert(eTRIA3);
- aGeomFACESet.insert(eQUAD4);
- aGeomFACESet.insert(eTRIA6);
- aGeomFACESet.insert(eTRIA7);
- aGeomFACESet.insert(eQUAD8);
- aGeomFACESet.insert(eQUAD9);
- aGeomFACESet.insert(ePOLYGONE);
- aGeomFACESet.insert(ePOLYGON2);
-
- TGeomSet& aGeomMAILLESet = Entity2GeomSet[eMAILLE];
- aGeomMAILLESet.insert(ePOINT1);
- aGeomMAILLESet.insert(aGeomARETESet.begin(),aGeomARETESet.end());
- aGeomMAILLESet.insert(aGeomFACESet.begin(),aGeomFACESet.end());
- aGeomMAILLESet.insert(eTETRA4);
- aGeomMAILLESet.insert(ePYRA5);
- aGeomMAILLESet.insert(ePENTA6);
- aGeomMAILLESet.insert(eHEXA8);
- aGeomMAILLESet.insert(eOCTA12);
- aGeomMAILLESet.insert(eTETRA10);
- aGeomMAILLESet.insert(ePYRA13);
- aGeomMAILLESet.insert(ePENTA15);
- aGeomMAILLESet.insert(eHEXA20);
- aGeomMAILLESet.insert(eHEXA27);
- aGeomMAILLESet.insert(ePOLYEDRE);
-
- /* This combination allows reading nb of models of structure elements */
- Entity2GeomSet[eSTRUCT_ELEMENT].insert(eAllGeoType);
-
- return true;
-}
-
-static bool anIsInited = InitEntity2GeomSet();
-
-const MED::TEntity2GeomSet& MED::GetEntity2GeomSet()
-{
- return Entity2GeomSet;
-}
-
-
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_Utilities_HeaderFile
-#define MED_Utilities_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <string.h>
-#include <stdexcept>
-
-
-namespace MED
-{
- class MEDWRAPPER_EXPORT PrefixPrinter
- {
- static int myCounter;
- bool myIsActive;
- public:
- PrefixPrinter(bool theIsActive = true);
- ~PrefixPrinter();
-
- static std::string GetPrefix();
- };
-}
-
-#ifdef _DEBUG_
- #define MSG(deb,msg) if(deb) std::cout<<MED::PrefixPrinter::GetPrefix()<<msg<<" ("<<__FILE__<<" ["<<__LINE__<<"])\n"
- #define BEGMSG(deb,msg) if(deb) std::cout<<MED::PrefixPrinter::GetPrefix()<<msg
- #define INITMSGA(deb,lev,msg) MED::PrefixPrinter aPrefixPrinter_##lev(deb); BEGMSG(deb,msg)
- #define INITMSG(deb,msg) INITMSGA(deb,,msg)
- #define ADDMSG(deb,msg) if(deb) std::cout<<msg
-#else
- #define MSG(deb,msg)
- #define BEGMSG(deb,msg)
- #define INITMSGA(deb,lev,msg)
- #define INITMSG(deb,msg)
- #define ADDMSG(deb,msg)
-#endif
-
-
-#ifndef EXCEPTION
-
-#define EXCEPTION(TYPE, MSG) {\
- std::ostringstream aStream;\
- aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
- throw TYPE(aStream.str().c_str());\
-}
-
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_Vector_HeaderFile
-#define MED_Vector_HeaderFile
-
-#include <vector>
-#include <stdexcept>
-
-//#if defined(_DEBUG_)
-# define MED_TVECTOR_CHECK_RANGE
-//#endif
-
-namespace MED
-{
-
- //! Main purpose to introduce the class was to customize operator []
- template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
- class TVector : public std::vector<_Tp, _Alloc>
- {
- public:
- typedef size_t size_type;
-
- typedef std::vector<_Tp, _Alloc> superclass;
- typedef typename superclass::allocator_type allocator_type;
-
- typedef _Tp value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
-
- protected:
- void
- check_range(size_type __n) const
- {
- if (__n >= this->size())
- throw std::out_of_range("TVector [] access out of range");
- }
-
- const_reference
- get_value(size_type __n) const
- {
- return superclass::operator[](__n);
- }
-
- reference
- get_value(size_type __n)
- {
- return superclass::operator[](__n);
- }
-
- public:
- explicit
- TVector(const allocator_type& __a = allocator_type()):
- superclass(__a)
- {}
-
- TVector(size_type __n, const value_type& __val,
- const allocator_type& __a = allocator_type()):
- superclass(__n, __val, __a)
- {}
-
- explicit
- TVector(size_type __n):
- superclass(__n)
- {}
-
- TVector(const TVector& __x):
- superclass(__x)
- {}
-
- template<typename _InputIterator>
- TVector(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a = allocator_type()):
- superclass(__first, __last, __a)
- {}
-
- template<typename _Yp, typename _Al>
- TVector(TVector<_Yp, _Al> __y):
- superclass(__y.begin(), __y.end())
- {}
-
- TVector&
- operator=(const TVector& __x)
- {
- superclass::operator=(__x);
- return *this;
- }
-
- template<typename _Yp, typename _Al>
- TVector&
- operator=(TVector<_Yp, _Al> __y)
- {
- this->assign(__y.begin(), __y.end());
- return *this;
- }
-
- reference
- operator[](size_type __n)
- {
-#if defined(MED_TVECTOR_CHECK_RANGE)
- check_range(__n);
-#endif
- return get_value(__n);
- }
-
- const_reference
- operator[](size_type __n) const
- {
-#if defined(MED_TVECTOR_CHECK_RANGE)
- check_range(__n);
-#endif
- return get_value(__n);
- }
-
- reference
- at(size_type __n)
- {
- check_range(__n);
- return get_value(__n);
- }
-
- const_reference
- at(size_type __n) const
- {
- check_range(__n);
- return get_value(__n);
- }
- };
-
-}
-
-#undef MED_TVECTOR_CHECK_RANGE
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-// File : MED_Wrapper.cxx
-// Author : Alexey PETROV
-//
-#include "MED_Wrapper.hxx"
-#include "MED_Utilities.hxx"
-
-#include <boost/version.hpp>
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-static int MYVALUEDEBUG = 0;
-#else
-// static int MYDEBUG = 0;
-// static int MYVALUEDEBUG = 0;
-#endif
-
-namespace MED
-{
- TLockProxy
- ::TLockProxy(TWrapper* theWrapper):
- myWrapper(theWrapper)
- {
-#if BOOST_VERSION >= 103500
- myWrapper->myMutex.lock();
-#else
- boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
-#endif
- INITMSG(MYDEBUG,"TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
- }
-
- TLockProxy
- ::~TLockProxy()
- {
- INITMSG(MYDEBUG,"~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
-#if BOOST_VERSION >= 103500
- myWrapper->myMutex.unlock();
-#else
- boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
-#endif
- }
-
- TWrapper*
- TLockProxy
- ::operator-> () const // never throws
- {
- return myWrapper;
- }
-
- //----------------------------------------------------------------------------
- TWrapper::~TWrapper()
- {
- }
-
- //----------------------------------------------------------------------------
- PMeshInfo
- TWrapper
- ::GetPMeshInfo(TInt theId,
- TErr* theErr)
- {
- PMeshInfo anInfo = CrMeshInfo();
- GetMeshInfo(theId,*anInfo,theErr);
- return anInfo;
- }
-
-
- //----------------------------------------------------------------------------
- PFamilyInfo
- TWrapper
- ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theId,
- TErr* theErr)
- {
- // must be reimplemented in connection with mesh type eSTRUCTURE
- // if(theMeshInfo->GetType() != eNON_STRUCTURE)
- // return PFamilyInfo();
-
- TInt aNbAttr = GetNbFamAttr(theId,*theMeshInfo);
- TInt aNbGroup = GetNbFamGroup(theId,*theMeshInfo);
- PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo,aNbGroup,aNbAttr);
- GetFamilyInfo(theId,*anInfo,theErr);
-
-#ifdef _DEBUG_
- std::string aName = anInfo->GetName();
- INITMSG(MYDEBUG,"GetPFamilyInfo - aFamilyName = '"<<aName<<
- "'; andId = "<<anInfo->GetId()<<
- "; aNbAttr = "<<aNbAttr<<
- "; aNbGroup = "<<aNbGroup<<"\n");
- for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
- aName = anInfo->GetGroupName(iGroup);
- INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
- }
-#endif
-
- return anInfo;
- }
-
-
- //----------------------------------------------------------------------------
- PNodeInfo
- TWrapper
- ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
- TErr* theErr)
- {
- TInt aNbElems = GetNbNodes(*theMeshInfo);
- if(aNbElems == 0){
- return PNodeInfo();
- }
-
- PNodeInfo anInfo = CrNodeInfo(theMeshInfo,aNbElems);
- GetNodeInfo(*anInfo,theErr);
-
-#ifdef _DEBUG_
- TInt aDim = theMeshInfo->myDim;
- TInt aNbElem = anInfo->GetNbElem();
- INITMSG(MYDEBUG,"GetPNodeInfo: ");
- {
- INITMSG(MYDEBUG,"aCoords: "<<aNbElem<<": ");
- TNodeCoord& aCoord = anInfo->myCoord;
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- for(TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++){
- ADDMSG(MYVALUEDEBUG,aCoord[anId]<<",");
- }
- ADDMSG(MYVALUEDEBUG," ");
- }
- ADDMSG(MYDEBUG, std::endl);
-
- BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
-
- if(anInfo->IsElemNum()){
- BEGMSG(MYVALUEDEBUG,"GetElemNum: ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
- }
- }
- ADDMSG(MYDEBUG, std::endl);
-#endif
-
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- PPolygoneInfo
- TWrapper
- ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode)
- {
- if(theMeshInfo->GetType() != eNON_STRUCTURE)
- return PPolygoneInfo();
-
- TInt aNbElem = GetNbPolygones(theMeshInfo,theEntity,theGeom,theConnMode);
- TInt aConnSize = GetPolygoneConnSize(theMeshInfo,theEntity,theGeom,theConnMode);
- PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo,theEntity,theGeom,aNbElem,aConnSize,theConnMode);
- GetPolygoneInfo(anInfo);
-
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,"GetPPolygoneInfo"<<
- " - theGeom = "<<theGeom<<
- "; aNbElem = "<<aNbElem<<": ");
- for(TInt iElem = 1; iElem < aNbElem; iElem++){
- TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
- TInt aConnDim = aConnSlice.size();
- for(TInt iConn = 0; iConn < aConnDim; iConn++){
- ADDMSG(MYVALUEDEBUG,aConnSlice[iConn]<<",");
- }
- ADDMSG(MYDEBUG," ");
- }
- ADDMSG(MYDEBUG, std::endl);
-#endif
-
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- PPolyedreInfo
- TWrapper
- ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode)
- {
- if(theMeshInfo->GetType() != eNON_STRUCTURE)
- return PPolyedreInfo();
- TInt aNbElem = GetNbPolyedres(theMeshInfo,theEntity,theGeom,theConnMode);
- TInt aNbFaces, aConnSize;
- GetPolyedreConnSize(theMeshInfo,aNbFaces,aConnSize,theConnMode);
- PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo,theEntity,theGeom,aNbElem,aNbFaces,aConnSize,theConnMode);
- GetPolyedreInfo(anInfo);
-
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,"GetPPolyedreInfo"<<
- " - theGeom = "<<theGeom<<
- "; aNbElem = "<<aNbElem<<": ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
- TInt aNbFaces = aConnSliceArr.size();
- ADDMSG(MYDEBUG,"{");
- for(TInt iFace = 0; iFace < aNbFaces; iFace++){
- TCConnSlice aConnSlice = aConnSliceArr[iFace];
- TInt aNbConn = aConnSlice.size();
- ADDMSG(MYDEBUG,"[");
- for(TInt iConn = 0; iConn < aNbConn; iConn++){
- ADDMSG(MYVALUEDEBUG,aConnSlice[iConn]<<",");
- }
- ADDMSG(MYDEBUG,"] ");
- }
- ADDMSG(MYDEBUG,"} ");
- }
- ADDMSG(MYDEBUG, std::endl);
-#endif
-
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- PElemInfo
- TWrapper
- ::GetPElemInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- EMaillage aType = theMeshInfo->GetType();
- if(aType == eNON_STRUCTURE){
- switch(theGeom){
- case ePOINT1:
- if(theEntity == eNOEUD)
- return GetPNodeInfo(theMeshInfo,theErr);
- return GetPCellInfo(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
- break;
- case ePOLYGONE:
- return GetPPolygoneInfo(theMeshInfo,theEntity,theGeom,theConnMode);
- break;
- case ePOLYEDRE:
- return GetPPolyedreInfo(theMeshInfo,theEntity,theGeom,theConnMode);
- break;
- default:
- return GetPCellInfo(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
- }
- } else {
- PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
-
- TInt nbElems;
- EBooleen theIsElemNum = eFAUX;
- // nodes
- switch(theGeom){
- case ePOINT1:
- nbElems = aGrille->GetNbNodes();
- theIsElemNum = eVRAI;
- break;
- case eSEG2:
- case eQUAD4:
- case eHEXA8:
- nbElems = aGrille->GetNbCells();
- break;
- default:
- nbElems = 0;
- }
-
- TIntVector aFamNum;
- TIntVector aElemNum;
- TStringVector aElemNames;
-
- PElemInfo aElemInfo;
-
- if(theGeom == ePOINT1){
- aElemInfo = CrElemInfo(theMeshInfo,
- nbElems,
- theIsElemNum);
- MED::TElemInfo &aTElemInfo = *aElemInfo;
-
- // must be reimplemente in connection with mesh type eSTRUCTURE
-// GetNumeration(aTElemInfo,
-// nbElems,
-// theEntity,
-// theGeom,
-// theErr);
-
- GetFamilies(aTElemInfo,
- nbElems,
- theEntity,
- theGeom,
- theErr);
-
- // must be reimplemente in connection with mesh type eSTRUCTURE
-// GetNames(aTElemInfo,
-// nbElems,
-// theEntity,
-// theGeom,
-// theErr);
- } else {
- aElemInfo = CrElemInfo(theMeshInfo,
- nbElems,
- aFamNum,
- aElemNum,
- aElemNames);
- }
-
- return aElemInfo;
- }
- return PElemInfo();
- }
-
-
- //----------------------------------------------------------------------------
- PCellInfo
- TWrapper
- ::GetPCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- if(theMeshInfo->GetType() != eNON_STRUCTURE)
- return PCellInfo();
- TInt aNbElem = GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode);
- PCellInfo anInfo = CrCellInfo(theMeshInfo,theEntity,theGeom,aNbElem,theConnMode);
- GetCellInfo(anInfo,theErr);
-
-#ifdef _DEBUG_
- TInt aConnDim = anInfo->GetConnDim();
- INITMSG(MYDEBUG,"GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
- BEGMSG(MYDEBUG,"GetPCellInfo - aNbElem: "<<aNbElem<<": ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
- for(TInt iConn = 0; iConn < aConnDim; iConn++){
- ADDMSG(MYVALUEDEBUG,aConnSlice[iConn]<<",");
- }
- ADDMSG(MYVALUEDEBUG," ");
- }
- ADDMSG(MYDEBUG, std::endl);
-
- BEGMSG(MYVALUEDEBUG,"GetPCellInfo - GetFamNum: ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
-
- if(anInfo->IsElemNum()){
- BEGMSG(MYVALUEDEBUG,"GetPCellInfo - GetElemNum: ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
- }
- ADDMSG(MYDEBUG, std::endl);
-#endif
-
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- //! Read a MEDWrapped representation of MED Balls from the MED file
- PBallInfo
- TWrapper
- ::GetPBallInfo(const PMeshInfo& theMeshInfo)
- {
- TInt nbBalls = GetNbBalls(theMeshInfo);
- if ( nbBalls < 1 ) return PBallInfo();
-
- PBallInfo anInfo = CrBallInfo( theMeshInfo, nbBalls );
- GetBallInfo(anInfo);
-
- return anInfo;
- }
- //----------------------------------------------------------------------------
- PFieldInfo
- TWrapper
- ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
- TInt theId,
- TErr* theErr)
- {
- TInt aNbComp = GetNbComp(theId);
- PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp);
- GetFieldInfo(theId,*anInfo,theErr);
-
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,
- "GetPFieldInfo "<<
- "- aName = '"<<anInfo->GetName()<<"'"<<
- "; aType = "<<anInfo->GetType()<<
- "; aNbComp = "<<aNbComp<<
- std::endl);
-#endif
-
- return anInfo;
- }
-
-
- //----------------------------------------------------------------------------
- PTimeStampInfo
- TWrapper
- ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
- EEntiteMaillage theEntity,
- const TGeom2Size& theGeom2Size,
- TInt theId,
- TErr* theErr)
- {
- PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo,theEntity,theGeom2Size);
- GetTimeStampInfo(theId,*anInfo,theErr);
-
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,"GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
- TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
- TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
- for(; anIter != aGeom2NbGauss.end(); anIter++){
- const EGeometrieElement& aGeom = anIter->first;
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
- }
-#endif
-
- return anInfo;
- }
-
-
- //----------------------------------------------------------------------------
- PProfileInfo
- TWrapper
- ::GetPProfileInfo(TInt theId,
- EModeProfil theMode,
- TErr* theErr)
- {
- TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
- PProfileInfo anInfo = CrProfileInfo(aPreInfo,theMode);
- GetProfileInfo(theId,*anInfo,theErr);
-
- return anInfo;
- }
-
-
- //----------------------------------------------------------------------------
- PTimeStampValueBase
- TWrapper
- ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const TGeom2Profile& theGeom2Profile,
- EModeSwitch theMode)
- {
- PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
- return CrTimeStampValue(theTimeStampInfo,
- aFieldInfo->GetType(),
- theGeom2Profile,
- theMode);
- }
-
- //----------------------------------------------------------------------------
- PTimeStampValueBase
- TWrapper
- ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampValueBase& theInfo)
- {
- PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
- return CrTimeStampValue(theTimeStampInfo,
- theInfo,
- aFieldInfo->GetType());
- }
-
- //----------------------------------------------------------------------------
- template<class TimeStampValueType>
- void
- Print(SharedPtr<TimeStampValueType> theTimeStampValue)
- {
- INITMSG(MYDEBUG,"Print - TimeStampValue\n");
- typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
- typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
- for(; anIter != aGeom2Value.end(); anIter++){
- const EGeometrieElement& aGeom = anIter->first;
- const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
- TInt aNbElem = aMeshValue.myNbElem;
- TInt aNbGauss = aMeshValue.myNbGauss;
- TInt aNbComp = aMeshValue.myNbComp;
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(TInt iComp = 0; iComp < aNbComp; iComp++){
- ADDMSG(MYVALUEDEBUG,aValueSlice[iComp]<<" ");
- }
- ADDMSG(MYVALUEDEBUG,"| ");
- }
- ADDMSG(MYVALUEDEBUG,"} ");
- }
- ADDMSG(MYDEBUG,"\n");
- }
- }
-
- //----------------------------------------------------------------------------
- PTimeStampValueBase
- TWrapper
- ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr)
- {
- PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
- PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
- aFieldInfo->GetType());
- GetTimeStampValue(anInfo,
- theMKey2Profile,
- theKey2Gauss,
- theErr);
-#ifdef _DEBUG_
- if(aFieldInfo->GetType() == eFLOAT64)
- Print<TFloatTimeStampValue>(anInfo);
- else
- Print<TIntTimeStampValue>(anInfo);
-#endif
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- void
- TWrapper
- ::GetTimeStampVal(const PTimeStampVal& theVal,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr)
- {
- PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
- PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
- if(aFieldInfo->GetType() == eFLOAT64)
- GetTimeStampValue(theVal,
- theMKey2Profile,
- theKey2Gauss,
- theErr);
- else{
- PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
- theVal,
- eINT);
- GetTimeStampValue(aVal,
- theMKey2Profile,
- theKey2Gauss,
- theErr);
- CopyTimeStampValueBase(aVal, theVal);
- }
- }
-
- //----------------------------------------------------------------------------
- void
- TWrapper
- ::SetTimeStamp(const PTimeStampVal& theVal,
- TErr* theErr)
- {
- PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
- PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
- if(aFieldInfo->GetType() == eFLOAT64)
- SetTimeStampValue(theVal, theErr);
- else{
- PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
- eINT,
- theVal->GetGeom2Profile(),
- theVal->GetModeSwitch());
- CopyTimeStampValueBase(theVal, aVal);
- SetTimeStampValue(aVal, theErr);
- }
- }
-
- //----------------------------------------------------------------------------
- PTimeStampVal
- TWrapper
- ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
- const TGeom2Profile& theGeom2Profile,
- EModeSwitch theMode)
- {
- return CrTimeStampValue(theTimeStampInfo,
- eFLOAT64,
- theGeom2Profile,
- theMode);
- }
-
- //----------------------------------------------------------------------------
- PTimeStampVal
- TWrapper
- ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampVal& theInfo)
- {
- return CrTimeStampValue(theTimeStampInfo,
- theInfo,
- eFLOAT64);
- }
-
- //----------------------------------------------------------------------------
- PTimeStampVal
- TWrapper
- ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr)
- {
- PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
- GetTimeStampVal(anInfo,
- theMKey2Profile,
- theKey2Gauss,
- theErr);
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- PGrilleInfo
- TWrapper
- ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
- {
- if(theMeshInfo->GetType() != eSTRUCTURE)
- return PGrilleInfo();
-
- EGrilleType type;
- GetGrilleType(*theMeshInfo,type);
- PGrilleInfo anInfo;
- if(type == eGRILLE_STANDARD){
- const TInt nnoeuds = GetNbNodes(*theMeshInfo);
- anInfo = CrGrilleInfo(theMeshInfo,type,nnoeuds);
- }
- else {
- TIntVector aVec;
- aVec.resize(theMeshInfo->GetDim());
- for(int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++){
- ETable aATable = eCOOR_IND1;
- switch(aAxe){
- case 0:
- aATable = eCOOR_IND1;
- break;
- case 1:
- aATable = eCOOR_IND2;
- break;
- case 2:
- aATable = eCOOR_IND3;
- break;
- }
- aVec[aAxe] = GetNbNodes(*theMeshInfo,aATable);
- }
- anInfo = CrGrilleInfo(theMeshInfo,type,aVec);
- }
-
- GetGrilleInfo(anInfo);
- anInfo->SetGrilleType(type);
-
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,"GetPGrilleInfo: ");
- {
- TInt aNbElem = anInfo->GetNbNodes();
- BEGMSG(MYVALUEDEBUG,"GetFamNumNode: ");
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetFamNumNode(iElem)<<", ");
- }
- TInt aNbCells = anInfo->GetNbCells();
- BEGMSG(MYVALUEDEBUG,"GetFamNum: ");
- for(TInt iElem = 0; iElem < aNbCells; iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
- BEGMSG(MYVALUEDEBUG,"GetCoordName: ");
- for(TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetCoordName(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
- BEGMSG(MYVALUEDEBUG,"GetCoordUnit: ");
- for(TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++){
- ADDMSG(MYVALUEDEBUG,anInfo->GetCoordUnit(iElem)<<", ");
- }
- ADDMSG(MYVALUEDEBUG, std::endl);
-
- }
-#endif
-
- return anInfo;
- }
-
- //----------------------------------------------------------------------------
- PGrilleInfo
- TWrapper
- ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
- const PGrilleInfo& theInfo)
- {
- PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo,theInfo);
- return anInfo;
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#ifndef MED_Wrapper_HeaderFile
-#define MED_Wrapper_HeaderFile
-
-#include "MED_WrapperBase.hxx"
-
-#include "MED_Structures.hxx"
-#include "MED_Algorithm.hxx"
-
-#include <boost/thread/mutex.hpp>
-
-namespace MED
-{
-
- //----------------------------------------------------------------------------
- //! Define a base class that wraps the MED API
- struct MEDWRAPPER_EXPORT TWrapper
- {
- typedef boost::mutex TMutex;
- //! This is a synchronization primitive which allow to support thread safety for the MED access
- TMutex myMutex;
-
- virtual
- ~TWrapper();
-
- //----------------------------------------------------------------------------
- //! Gets version of the MED library used for the MED file
- virtual
- EVersion
- GetVersion() = 0;
-
- //----------------------------------------------------------------------------
- //! Creates a MEDWrapper MED Mesh representation
- virtual
- PMeshInfo
- CrMeshInfo(TInt theDim = 0, TInt theSpaceDim = 0,
- const std::string& theValue = "",
- EMaillage theType = eNON_STRUCTURE,
- const std::string& theDesc = "") = 0;
-
- //! A copy-constructor for the MEDWrapper MED Mesh representation
- virtual
- PMeshInfo
- CrMeshInfo(const PMeshInfo& theInfo) = 0;
-
- //! Read number of MED Mesh entities in the defined MED file
- virtual
- TInt
- GetNbMeshes(TErr* theErr = NULL) = 0;
-
- //! Read a MEDWrapper MED Mesh representation by its number
- virtual
- void
- GetMeshInfo(TInt theMeshId,
- TMeshInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Write the MEDWrapper MED Mesh representation in the defined MED file
- virtual
- void
- SetMeshInfo(const TMeshInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Read a MEDWrapper MED Mesh representation by its number
- virtual
- PMeshInfo
- GetPMeshInfo(TInt theId,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- //! Read number of MED Family entities in the defined MED file
- virtual
- TInt
- GetNbFamilies(const TMeshInfo& theMeshInfo,
- TErr* theErr = NULL) = 0;
-
- //! Read number of attributes for defined MED Family
- virtual
- TInt
- GetNbFamAttr(TInt theFamId,
- const TMeshInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Read number of MED Groups where MED Family with the number belong to
- virtual
- TInt
- GetNbFamGroup(TInt theFamId,
- const TMeshInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Read a MEDWrapper MED Family representation by its number
- virtual
- void
- GetFamilyInfo(TInt theFamId,
- TFamilyInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Write a MEDWrapper MED Family representation by its number
- virtual
- void
- SetFamilyInfo(const TFamilyInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Creates a MEDWrapper MED Family representation
- virtual
- PFamilyInfo
- CrFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theNbGroup = 0,
- TInt theNbAttr = 0,
- TInt theId = 0,
- const std::string& theValue = "") = 0;
-
- //! Creates a MEDWrapper MED Family representation
- virtual
- 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()) = 0;
-
- //! A copy-constructor for the MEDWrapper MED Family representation
- virtual
- PFamilyInfo
- CrFamilyInfo(const PMeshInfo& theMeshInfo,
- const PFamilyInfo& theInfo) = 0;
-
- //! Write a MEDWrapper MED Family representation by its number
- PFamilyInfo
- GetPFamilyInfo(const PMeshInfo& theMeshInfo,
- TInt theId,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- //! Read sequence of names for any descendant of TElemInfo
- virtual
- void
- GetNames(TElemInfo& theInfo,
- TInt theNb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL)
- {}
-
- //! Read sequence of numerous for any descendant of TElemInfo
- virtual
- void
- GetNumeration(TElemInfo& theInfo,
- TInt theNb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL)
- {}
-
- //! Read sequence MED Family indexes for any descendant of TElemInfo
- virtual
- void
- GetFamilies(TElemInfo& theInfo,
- TInt theNb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL)
- {}
-
- //! Write sequence of names for any descendant of TElemInfo
- virtual
- void
- SetNames(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL)
- {}
-
- //! Write sequence of numerous for any descendant of TElemInfo
- virtual
- void
- SetNumeration(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL)
- {}
-
- //! Write sequence MED Family indexes for any descendant of TElemInfo
- virtual
- void
- SetFamilies(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL)
- {}
-
- //! Read a MEDWrapper MED Element representation from defined MED file
- PElemInfo
- GetPElemInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity = eNOEUD,
- EGeometrieElement theGeom = ePOINT1,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- //! Read number of nodes in defined MED Mesh
- virtual
- TInt
- GetNbNodes(const TMeshInfo& theMeshInfo,
- TErr* theErr = NULL) = 0;
-
- virtual
- TInt
- GetNbNodes(const TMeshInfo& theMeshInfo,
- ETable theTable,
- TErr* theErr = NULL)
- {
- return 0;
- }
-
- //! Read a MEDWrapper MED Nodes representation from defined MED file
- virtual
- void
- GetNodeInfo(TNodeInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Write the MEDWrapper MED Nodes representation into defined MED file
- virtual
- void
- SetNodeInfo(const TNodeInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Creates a MEDWrapper MED Nodes representation
- virtual
- PElemInfo
- CrElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI)
- {
- return PElemInfo();
- }
-
- //! Creates a MEDWrapper MED Nodes representation
- virtual
- PElemInfo
- CrElemInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- const TIntVector& theFamNum,
- const TIntVector& aElemNum,
- const TStringVector& aElemNames)
- {
- return PElemInfo();
- }
-
- //! Creates a MEDWrapper MED Nodes representation
- virtual
- PNodeInfo
- CrNodeInfo(const PMeshInfo& theMeshInfo,
- TInt theNbElem,
- EModeSwitch theMode = eFULL_INTERLACE,
- ERepere theSystem = eCART,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI) = 0;
-
- //! Creates a MEDWrapper MED Nodes representation
- virtual
- PNodeInfo
- CrNodeInfo(const PMeshInfo& theMeshInfo,
- const TFloatVector& theNodeCoords,
- EModeSwitch theMode = eFULL_INTERLACE,
- ERepere theSystem = eCART,
- const TStringVector& theCoordNames = TStringVector(),
- const TStringVector& theCoordUnits = TStringVector(),
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector(),
- const TStringVector& theElemNames = TStringVector()) = 0;
-
- //! A copy-constructor for the MEDWrapper MED Nodes representation
- virtual
- PNodeInfo
- CrNodeInfo(const PMeshInfo& theMeshInfo,
- const PNodeInfo& theInfo) = 0;
-
- //! Read a MEDWrapper MED Nodes representation from defined MED file
- PNodeInfo
- GetPNodeInfo(const PMeshInfo& theMeshInfo,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- //! Read a MEDWrapper MED Polygones representation from defined MED file
- /*! This feature is supported only for version of 2.2 and higher */
- virtual
- void
- GetPolygoneInfo(TPolygoneInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Write a MEDWrapper MED Polygones representation from defined MED file
- /*! This feature is supported only for version of 2.2 and higher */
- virtual
- void
- SetPolygoneInfo(const TPolygoneInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Read number of MED Polygones in defined MED Mesh
- /*! This feature is supported only for version of 2.2 and higher */
- virtual
- TInt
- GetNbPolygones(const TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL)
- {
- return 0;
- }
-
- //! Read connectivity infroamtion for the MED Polygones in defined MED Mesh
- /*! This feature is supported only for version of 2.2 and higher */
- virtual
- TInt
- GetPolygoneConnSize(const TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL)
- {
- return 0;
- }
-
- //! Creates a MEDWrapper MED Polygones representation
- /*! This feature is supported only for version of 2.2 and higher */
- virtual
- PPolygoneInfo
- CrPolygoneInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TInt theNbElem,
- TInt theConnSize,
- EConnectivite theConnMode = eNOD,
- EBooleen theIsElemNum = eVRAI,
- EBooleen theIsElemNames = eVRAI)
- {
- return PPolygoneInfo();
- }
-
- //! Creates a MEDWrapper MED Polygones representation
- /*! This feature is supported only for version of 2.2 and higher */
- 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())
- {
- return PPolygoneInfo();
- }
-
- //! A copy-constructor for the MEDWrapper MED Polygones representation
- virtual
- PPolygoneInfo
- CrPolygoneInfo(const PMeshInfo& theMeshInfo,
- const PPolygoneInfo& theInfo)
- {
- return PPolygoneInfo();
- }
-
- //! Read a MEDWrapper MED Polygones representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- PPolygoneInfo
- GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD);
-
- //----------------------------------------------------------------------------
- //! Read a MEDWrapper MED Polyedres representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- GetPolyedreInfo(TPolyedreInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Write a MEDWrapper MED Polyedres representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- SetPolyedreInfo(const TPolyedreInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Read number of MED Polyedres in defined MED Mesh
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- TInt
- GetNbPolyedres(const TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL)
- {
- return 0;
- }
-
- //! Read connectivity infroamtion for the MED Polyedres in defined MED Mesh
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
- TInt& theNbFaces,
- TInt& theConnSize,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL)
- {
- theNbFaces = theConnSize = 0;
- }
-
- 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)
- {
- return PPolyedreInfo();
- }
-
- //! Creates a MEDWrapper MED Polyedres representation
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PPolyedreInfo
- CrPolyedreInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theIndexes,
- const TIntVector& theFaces,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode = eNOD,
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector(),
- const TStringVector& theElemNames = TStringVector())
- {
- return PPolyedreInfo();
- }
-
- //! A copy-constructor for the MEDWrapper MED Polyedres representation
- virtual
- PPolyedreInfo
- CrPolyedreInfo(const PMeshInfo& theMeshInfo,
- const PPolyedreInfo& theInfo)
- {
- return PPolyedreInfo();
- }
-
- //! Read a MEDWrapper MED Polyedres representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- PPolyedreInfo
- GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD);
-
- //----------------------------------------------------------------------------
- //! Get TEntityInfo which contains brief information about existing cells and their destribution among MED ENTITIES
- virtual
- TEntityInfo
- GetEntityInfo(const TMeshInfo& theMeshInfo,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL) = 0;
-
- //! Read number of cells for defined MED Mesh, ENTITY and geometrical type with define mode of connectivity
- virtual
- TInt
- GetNbCells(const TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL) = 0;
-
- //! Read a MEDWrapper MED Cells representation from defined MED file
- virtual
- void
- GetCellInfo(TCellInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Write the MEDWrapper MED Cells representation into defined MED file
- virtual
- void
- SetCellInfo(const TCellInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Creates 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 = eVRAI,
- EModeSwitch theMode = eFULL_INTERLACE) = 0;
-
- //! Creates a MEDWrapper MED Cells representation
- virtual
- PCellInfo
- CrCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- const TIntVector& theConnectivities,
- EConnectivite theConnMode = eNOD,
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector(),
- const TStringVector& theElemNames = TStringVector(),
- EModeSwitch theMode = eFULL_INTERLACE) = 0;
-
- //! A copy-constructor for the MEDWrapper MED Cells representation
- virtual
- PCellInfo
- CrCellInfo(const PMeshInfo& theMeshInfo,
- const PCellInfo& theInfo) = 0;
-
- //! Read a MEDWrapper MED Cells representation from defined MED file
- PCellInfo
- GetPCellInfo(const PMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- //! Read number of balls in the Mesh
- /*! This feature is supported since version 3.0 */
- virtual
- TInt
- GetNbBalls(const TMeshInfo& theMeshInfo)
- {
- return 0;
- }
-
- //! Read a MEDWrapped representation of MED_BALL from the MED file
- /*! This feature is supported since version 3.0 */
- virtual
- void
- GetBallInfo(TBallInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Write a MEDWrapped representation of MED_BALL to the MED file
- /*! This feature is supported since version 3.0 */
- virtual
- void
- SetBallInfo(const TBallInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Creates a MEDWrapper MED Balls representation
- /*! This feature is supported since version 3.0 */
- virtual
- PBallInfo
- CrBallInfo(const PMeshInfo& theMeshInfo,
- TInt theNbBalls,
- EBooleen theIsElemNum = eVRAI)
- {
- return PBallInfo();
- }
-
- //! Creates a MEDWrapper MED Balls representation
- /*! This feature is supported since version 3.0 */
- virtual
- PBallInfo
- CrBallInfo(const PMeshInfo& theMeshInfo,
- const TIntVector& theNodes,
- TFloatVector& theDiameters,
- const TIntVector& theFamilyNums = TIntVector(),
- const TIntVector& theElemNums = TIntVector())
- {
- return PBallInfo();
- }
-
- //! A copy-constructor for the MEDWrapped MED Balls representation
- virtual
- PBallInfo
- CrBallInfo(const PMeshInfo& theMeshInfo,
- const PBallInfo& theInfo)
- {
- return PBallInfo();
- }
-
- //! Read a MEDWrapped MED Balls representation from defined MED file
- /*! This feature is supported since version 3.0 */
- virtual
- PBallInfo
- GetPBallInfo(const PMeshInfo& theMeshInfo);
-
- //----------------------------------------------------------------------------
- //! Read number of MED FIELDS in defined MED Mesh
- virtual
- TInt
- GetNbFields(TErr* theErr = NULL) = 0;
-
- //! Read number of components for the defined MED FIELD by its order number
- virtual
- TInt
- GetNbComp(TInt theFieldId,
- TErr* theErr = NULL) = 0;
-
- //! Read MEDWrapper MED FIELD representation by its order number
- virtual
- void
- GetFieldInfo(TInt theFieldId,
- TFieldInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Write MEDWrapper MED FIELD representation into defined MED file
- virtual
- void
- SetFieldInfo(const TFieldInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
-
- //! Creates a MEDWrapper MED FIELD representation
- virtual
- PFieldInfo
- CrFieldInfo(const PMeshInfo& theMeshInfo,
- TInt theNbComp = 0,
- ETypeChamp theType = eFLOAT64,
- const std::string& theValue = "",
- EBooleen theIsLocal = eVRAI,
- TInt theNbRef = 1) = 0;
-
- //! A copy-constructor for the MEDWrapper MED FIELD representation
- virtual
- PFieldInfo
- CrFieldInfo(const PMeshInfo& theMeshInfo,
- const PFieldInfo& theInfo) = 0;
-
- //! Read a MEDWrapper MED FIELD representation from defined MED file
- PFieldInfo
- GetPFieldInfo(const PMeshInfo& theMeshInfo,
- TInt theId,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- //! Read number of MED GAUSS in defined MED Mesh
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- TInt
- GetNbGauss(TErr* theErr = NULL)
- {
- return TInt();
- }
-
- //! Read brief MED GAUSS information by its order number from defined MED Mesh
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- TGaussInfo::TInfo
- GetGaussPreInfo(TInt theId,
- TErr* theErr = NULL)
- {
- return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
- }
-
- //! Read a MEDWrapper MED GAUSS representation by its order number from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- GetGaussInfo(TInt theId,
- TGaussInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Creates a MEDWrapper MED GAUSS representation
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PGaussInfo
- CrGaussInfo(const TGaussInfo::TInfo& theInfo,
- EModeSwitch theMode = eFULL_INTERLACE) = 0;
-
-
- //----------------------------------------------------------------------------
- //! Read number of MED TIMESTAMPS in defined MED Mesh
- /*!
- By the way some additional information can be obtained:
- - to what MED ENTITY the MED TIMESTAMP conntected to;
- - on what geometrical types the MED TIMESTAMP defined to.
- */
- virtual
- TInt
- GetNbTimeStamps(const TFieldInfo& theInfo,
- const TEntityInfo& theEntityInfo,
- EEntiteMaillage& theEntity,
- TGeom2Size& theGeom2Size,
- TErr* theErr = NULL) = 0;
-
- //! Read MEDWrapper MED TIMESTAMP representation by its order number
- virtual
- void
- GetTimeStampInfo(TInt theTimeStampId,
- TTimeStampInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Creates a MEDWrapper MED TIMESTAMP representation
- virtual
- PTimeStampInfo
- CrTimeStampInfo(const PFieldInfo& theFieldInfo,
- EEntiteMaillage theEntity,
- const TGeom2Size& theGeom2Size,
- const TGeom2NbGauss& theGeom2NbGauss = TGeom2NbGauss(),
- TInt theNumDt = 0,
- TInt theNumOrd = 0,
- TFloat theDt = 0,
- const std::string& theUnitDt = "",
- const TGeom2Gauss& theGeom2Gauss = TGeom2Gauss()) = 0;
-
- //! A copy-constructor for the MEDWrapper MED TIMESTAMP representation
- virtual
- PTimeStampInfo
- CrTimeStampInfo(const PFieldInfo& theFieldInfo,
- const PTimeStampInfo& theInfo) = 0;
-
- //! Read MEDWrapper MED TIMESTAMP representation by its order number
- PTimeStampInfo
- GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
- EEntiteMaillage theEntity,
- const TGeom2Size& theGeom2Size,
- TInt theId,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- //! Read number of MED PROFILES in defined MED Mesh
- virtual
- TInt
- GetNbProfiles(TErr* theErr = NULL) = 0;
-
- //! Read brief MED PROFILE information by its order number from defined MED Mesh
- virtual
- TProfileInfo::TInfo
- GetProfilePreInfo(TInt theId,
- TErr* theErr = NULL) = 0;
-
- //! Read a MEDWrapper MED PROFILE representation by its order number from defined MED file
- virtual
- void
- GetProfileInfo(TInt theId,
- TProfileInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Creates a MEDWrapper MED PROFILE representation
- virtual
- PProfileInfo
- CrProfileInfo(const TProfileInfo::TInfo& theInfo,
- EModeProfil theMode = eCOMPACT) = 0;
-
- //! Write a MEDWrapper MED PROFILE representation
- virtual
- void
- SetProfileInfo(const TProfileInfo& theInfo,
- TErr* theErr = NULL) = 0;
-
- //! Read a MEDWrapper MED PROFILE representation by its order number from defined MED file
- PProfileInfo
- GetPProfileInfo(TInt theId,
- EModeProfil theMode = eCOMPACT,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file
- virtual
- void
- GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr = NULL) = 0;
-
- //! Write the values for MEDWrapper MED TIEMSTAMP to defined MED file
- virtual
- void
- SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- TErr* theErr = NULL) = 0;
-
- //! Creates the values for MEDWrapper MED TIEMSTAMP representation
- virtual
- PTimeStampValueBase
- CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- ETypeChamp theTypeChamp,
- const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
- EModeSwitch theMode = eFULL_INTERLACE) = 0;
-
- //! Creates the values for MEDWrapper MED TIEMSTAMP representation
- virtual
- PTimeStampValueBase
- CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
- EModeSwitch theMode = eFULL_INTERLACE);
-
- //! A copy-constructor for the values for MEDWrapper MED TIEMSTAMP representation
- virtual
- PTimeStampValueBase
- CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampValueBase& theInfo,
- ETypeChamp theTypeChamp) = 0;
-
- //! A copy-constructor for the values for MEDWrapper MED TIEMSTAMP representation
- virtual
- PTimeStampValueBase
- CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampValueBase& theInfo);
-
- //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file
- PTimeStampValueBase
- GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- // Backward compatibility declarations
- //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file
- virtual
- void
- GetTimeStampVal(const PTimeStampVal& theVal,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr = NULL);
-
- //! Write the values for MEDWrapper MED TIEMSTAMP to defined MED file
- virtual
- void
- SetTimeStamp(const PTimeStampVal& theVal,
- TErr* theErr = NULL);
-
- //! Creates the values for MEDWrapper MED TIEMSTAMP representation
- virtual
- PTimeStampVal
- CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
- const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
- EModeSwitch theMode = eFULL_INTERLACE);
-
- //! A copy-constructor for the values for MEDWrapper MED TIEMSTAMP representation
- virtual
- PTimeStampVal
- CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
- const PTimeStampVal& theInfo);
-
- //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file
- PTimeStampVal
- GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- //! Read a MEDWrapper MED Grille representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- PGrilleInfo
- GetPGrilleInfo(const PMeshInfo& theMeshInfo);
-
- //! Read a MEDWrapper MED Grille representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- PGrilleInfo
- GetPGrilleInfo(const PMeshInfo& theMeshInfo,
- const PGrilleInfo& theInfo);
-
- //! Read a MEDWrapper MED Grille representation from defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- GetGrilleInfo(TGrilleInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- //! Write the MEDWrapper MED Grille representation into defined MED file
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- SetGrilleInfo(const TGrilleInfo& theInfo,
- TErr* theErr = NULL)
- {}
-
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const PGrilleInfo& theGrilleInfo)
- {
- return PGrilleInfo();
- }
-
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo)
- {
- return PGrilleInfo();
- }
-
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type)
- {
- return PGrilleInfo();
- }
-
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
- const TInt& nbNodes)
- {
- return PGrilleInfo();
- }
-
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- PGrilleInfo
- CrGrilleInfo(const PMeshInfo& theMeshInfo,
- const EGrilleType& type,
- const MED::TIntVector& nbNodeVec)
- {
- return PGrilleInfo();
- }
-
- /*! This feature is support only for version of 2.2 and higher */
- virtual
- void
- GetGrilleType(const TMeshInfo& theMeshInfo,
- EGrilleType& type,
- TErr* theErr = NULL)
- {
- }
-
- };
-
-
- //----------------------------------------------------------------------------
- //! This class provide thread-safety for MEDWrapper interaction
- class MEDWRAPPER_EXPORT TLockProxy
- {
- TLockProxy& operator=(const TLockProxy& );
- TWrapper* myWrapper;
-
- public:
- TLockProxy(TWrapper* theWrapper);
-
- ~TLockProxy();
-
- TWrapper * operator-> () const;
- };
-
-
- //----------------------------------------------------------------------------
- //! To specialize the SharedPtr for TWrapper
- template<>
- class MEDWRAPPER_EXPORT SharedPtr<TWrapper>: public boost::shared_ptr<TWrapper>
- {
- public:
- SharedPtr() {}
-
- template<class Y>
- explicit SharedPtr(Y * p):
- boost::shared_ptr<TWrapper>(p)
- {}
-
- template<class Y>
- SharedPtr(SharedPtr<Y> const & r):
- boost::shared_ptr<TWrapper>(boost::dynamic_pointer_cast<TWrapper,Y>(r))
- {}
-
- template<class Y>
- SharedPtr&
- operator=(SharedPtr<Y> const & r)
- {
- SharedPtr<TWrapper>(r).swap(*this);
- return *this;
- }
-
- template<class Y>
- SharedPtr&
- operator()(Y * p) // Y must be complete
- {
- return operator=<Y>(SharedPtr<Y>(p));
- }
-
- template<class Y>
- SharedPtr&
- operator()(SharedPtr<Y> const & r) // Y must be complete
- {
- return operator=<Y>(SharedPtr<Y>(r));
- }
-
- TLockProxy operator-> () const // never throws
- {
- return TLockProxy(this->get());
- }
-
- protected:
- operator const TWrapper& () const;
-
- operator TWrapper& ();
-
- TWrapper& operator* () const;
-
- TWrapper * get() const // never throws
- {
- return boost::shared_ptr<TWrapper>::get();
- }
- };
-
- //----------------------------------------------------------------------------
- typedef SharedPtr<TWrapper> PWrapper;
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-// File : MED_WrapperBase.hxx
-// Author : Alexander A. BORODIN
-//
-#ifndef _MED_WrapperBase_HXX_
-#define _MED_WrapperBase_HXX_
-
-#ifdef WIN32
- #if defined MEDWRAPPER_BASE_EXPORTS || defined MEDWrapperBase_EXPORTS
- #if defined WIN32
- #define MEDWRAPPER_EXPORT __declspec( dllexport )
- #else
- #define MEDWRAPPER_EXPORT
- #endif
- #else
- #if defined WIN32
- #define MEDWRAPPER_EXPORT __declspec( dllimport )
- #else
- #define MEDWRAPPER_EXPORT
- #endif
- #endif
-#else
- #define MEDWRAPPER_EXPORT
-#endif
-
-#endif
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-ADD_SUBDIRECTORY(Base)
-ADD_SUBDIRECTORY(V2_2)
-ADD_SUBDIRECTORY(Factory)
+# --- options ---
+# additional include directories
+INCLUDE_DIRECTORIES(
+ ${Boost_INCLUDE_DIRS}
+ ${HDF5_INCLUDE_DIRS}
+ ${MEDFILE_INCLUDE_DIRS}
+ ${KERNEL_INCLUDE_DIRS}
+)
+
+# additional preprocessor / compiler flags
+ADD_DEFINITIONS(
+ ${BOOST_DEFINITIONS}
+ ${HDF5_DEFINITIONS}
+)
+
+SET(_link_LIBRARIES
+ ${Boost_LIBRARIES}
+ ${HDF5_LIBS}
+ ${MEDFILE_C_LIBRARIES}
+)
+
+# --- headers ---
+
+# header files / no moc processing
+SET(MEDWrapper_HEADERS
+ MED_Algorithm.hxx
+ MED_Common.hxx
+ MED_CoordUtils.hxx
+ MED_Factory.hxx
+ MED_GaussDef.hxx
+ MED_GaussUtils.hxx
+ MED_SharedPtr.hxx
+ MED_SliceArray.hxx
+ MED_Structures.hxx
+ MED_TStructures.hxx
+ MED_Utilities.hxx
+ MED_Vector.hxx
+ MED_Wrapper.hxx
+ MED_WrapperDef.hxx
+)
+
+# --- sources ---
+
+# sources / static
+SET(MEDWrapper_SOURCES
+ MED_Algorithm.cxx
+ MED_Common.cxx
+ MED_CoordUtils.cxx
+ MED_Factory.cxx
+ MED_GaussDef.cxx
+ MED_GaussUtils.cxx
+ MED_Structures.cxx
+ MED_Utilities.cxx
+ MED_Wrapper.cxx
+)
+
+# --- rules ---
+
+ADD_LIBRARY(MEDWrapper ${MEDWrapper_SOURCES})
+TARGET_LINK_LIBRARIES(MEDWrapper ${_link_LIBRARIES})
+INSTALL(TARGETS MEDWrapper EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
+ADD_EXECUTABLE(mprint_version mprint_version.cxx)
+TARGET_LINK_LIBRARIES(mprint_version ${MEDFILE_C_LIBRARIES})
+INSTALL(TARGETS mprint_version EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
+
+INSTALL(FILES ${MEDWrapper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+++ /dev/null
-# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# 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
-#
-
-# --- options ---
-# additional include directories
-INCLUDE_DIRECTORIES(
- ${HDF5_INCLUDE_DIRS}
- ${Boost_INCLUDE_DIRS}
- ${MEDFILE_INCLUDE_DIRS}
- ${KERNEL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../Base
- ${CMAKE_CURRENT_SOURCE_DIR}/../V2_2
-)
-
-# additional preprocessor / compiler flags
-ADD_DEFINITIONS(
- ${HDF5_DEFINITIONS}
- ${BOOST_DEFINITIONS}
-)
-
-SET(_link_LIBRARIES
- MEDWrapperBase
- MEDWrapper_V2_2
- ${Boost_LIBRARIES}
- ${MEDFILE_C_LIBRARIES}
-)
-
-# --- headers ---
-
-# header files / no moc processing
-SET(MEDWrapper_HEADERS
- MED_Factory.hxx
- MED_WrapperFactory.hxx
-)
-
-# --- sources ---
-
-# sources / static
-SET(MEDWrapper_SOURCES
- MED_Factory.cxx
-)
-
-# --- rules ---
-
-ADD_LIBRARY(MEDWrapper ${MEDWrapper_SOURCES})
-TARGET_LINK_LIBRARIES(MEDWrapper ${_link_LIBRARIES} ${MED_medloader} )
-INSTALL(TARGETS MEDWrapper EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
-
-ADD_EXECUTABLE(mprint_version mprint_version.cxx)
-TARGET_LINK_LIBRARIES(mprint_version ${_link_LIBRARIES} MEDWrapper)
-
-ADD_EXECUTABLE(MED_Test MED_Test.cxx)
-TARGET_LINK_LIBRARIES(MED_Test ${_link_LIBRARIES} MEDWrapper)
-
-INSTALL(TARGETS mprint_version MED_Test EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
-
-INSTALL(FILES ${MEDWrapper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#include "MED_Factory.hxx"
-#include "MED_Utilities.hxx"
-#include "MED_V2_2_Wrapper.hxx"
-
-#include <stdio.h>
-#include <errno.h>
-#include <sstream>
-
-#include <med.h>
-extern "C"
-{
-#ifndef WIN32
- #include <unistd.h>
-#endif
-}
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
-namespace MED
-{
-
- EVersion GetVersionId(const std::string& theFileName,
- bool theDoPreCheckInSeparateProcess)
- {
- INITMSG(MYDEBUG,"GetVersionId - theFileName = '"<<theFileName<<"'"<<std::endl);
- EVersion aVersion = eVUnknown;
-
-#ifndef WIN32
- if (access(theFileName.c_str(),F_OK))
- return aVersion;
- if ( theDoPreCheckInSeparateProcess ) {
- // First check, is it possible to deal with the file
- std::ostringstream aStr;
- // File name is in quotes for the case of space(s) inside it (PAL13009)
- aStr<<"bash -c \""<<getenv("SMESH_ROOT_DIR")<<"/bin/salome/mprint_version \'"<<theFileName<<"\'\"";
- if(!MYDEBUG)
- aStr<<" 2>&1 > /dev/null";
-
- std::string aCommand = aStr.str();
- int aStatus = system(aCommand.c_str());
-
- BEGMSG( MYDEBUG,"aCommand = '" << aCommand << "'; aStatus = " << aStatus
- << "; errno = " << errno << " = " << strerror( errno ) << std::endl );
- if ( aStatus != 0 && errno != EAGAIN && errno != ENOMEM ) // "Cannot allocate memory" is OK
- return aVersion;
- }
-#endif
- // check compatibility of hdf and med versions
- med_bool hdfok, medok;
- MEDfileCompatibility(theFileName.c_str(), &hdfok, &medok);
- if ((!hdfok) /*|| (!medok)*/) // med-2.1 is KO since med-3.0.0
- return aVersion;
-
- // Next, try to open the file trough the MED API
- const char* aFileName = theFileName.c_str();
- med_idt aFid = MEDfileOpen(aFileName,MED_ACC_RDONLY);
-
- MSG(MYDEBUG,"GetVersionId - theFileName = '"<<theFileName<<"'; aFid = "<<aFid<<std::endl);
- if(aFid >= 0){
- med_int aMajor, aMinor, aRelease;
- med_err aRet = MEDfileNumVersionRd(aFid,&aMajor,&aMinor,&aRelease);
- INITMSG(MYDEBUG,"GetVersionId - theFileName = '"<<theFileName<<"'; aRet = "<<aRet<<std::endl);
- if(aRet >= 0){
- if(aMajor == 2 && aMinor == 1)
- aVersion = eV2_1;
- else
- aVersion = eV2_2;
- }
- else {
- // VSR: simulate med 2.3.6 behavior, med file version is assumed to 2.1
- aVersion = eV2_1;
- }
- }
- MEDfileClose(aFid);
-
- BEGMSG(MYDEBUG,"GetVersionId - theFileName = '"<<theFileName<<"'; aVersion = "<<aVersion<<std::endl);
- return aVersion;
- }
-
- bool getMEDVersion( const std::string& fname, int& major, int& minor, int& release )
- {
- med_idt f = MEDfileOpen(fname.c_str(), MED_ACC_RDONLY );
- if( f<0 )
- return false;
-
- med_int aMajor, aMinor, aRelease;
- med_err aRet = MEDfileNumVersionRd( f, &aMajor, &aMinor, &aRelease );
- major = aMajor;
- minor = aMinor;
- release = aRelease;
- MEDfileClose( f );
- if( aRet<0 ) {
- // VSR: simulate med 2.3.6 behavior, med file version is assumed to 2.1
- major = 2; minor = release = -1;
- //return false;
- }
- return true;
- }
-
- PWrapper CrWrapper(const std::string& theFileName,
- bool theDoPreCheckInSeparateProcess)
- {
- PWrapper aWrapper;
- EVersion aVersion = GetVersionId(theFileName,theDoPreCheckInSeparateProcess);
- switch(aVersion){
- case eV2_2:
- aWrapper.reset(new MED::V2_2::TVWrapper(theFileName));
- break;
- case eV2_1:
- EXCEPTION(std::runtime_error,"Cannot open file '"<<theFileName<<"'. Med version 2.1 is not supported any more.");
- //aWrapper.reset(new MED::V2_1::TVWrapper(theFileName));
- break;
- default:
- EXCEPTION(std::runtime_error,"MED::CrWrapper - theFileName = '"<<theFileName<<"'");
- }
- return aWrapper;
- }
-
- PWrapper CrWrapper(const std::string& theFileName, EVersion theId)
- {
- EVersion aVersion = GetVersionId(theFileName);
-
- if(aVersion != theId)
- remove(theFileName.c_str());
-
- PWrapper aWrapper;
- switch(theId){
- case eV2_2:
- aWrapper.reset(new MED::V2_2::TVWrapper(theFileName));
- break;
- case eV2_1:
- EXCEPTION(std::runtime_error,"Cannot open file '"<<theFileName<<"'. Med version 2.1 is not supported any more.");
- //aWrapper.reset(new MED::V2_1::TVWrapper(theFileName));
- break;
- default:
- aWrapper.reset(new MED::V2_2::TVWrapper(theFileName));
- }
- return aWrapper;
- }
-
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#ifndef MED_Factory_HeaderFile
-#define MED_Factory_HeaderFile
-
-#include "MED_WrapperFactory.hxx"
-#include "MED_Wrapper.hxx"
-
-namespace MED
-{
- MEDWRAPPER_FACTORY_EXPORT
- EVersion
- GetVersionId(const std::string& theFileName,
- bool theDoPreCheckInSeparateProcess = false);
-
- MEDWRAPPER_FACTORY_EXPORT
- bool getMEDVersion( const std::string&, int&, int&, int& );
-
- MEDWRAPPER_FACTORY_EXPORT
- PWrapper
- CrWrapper(const std::string& theFileName,
- bool theDoPreCheckInSeparateProcess = false);
-
- MEDWRAPPER_FACTORY_EXPORT
- PWrapper
- CrWrapper(const std::string& theFileName, EVersion theId);
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#include "MED_Utilities.hxx"
-#include "MED_Algorithm.hxx"
-#include "MED_GaussUtils.hxx"
-#include "MED_Factory.hxx"
-
-#ifdef _DEBUG_
-static int MYDEBUG = 1;
-#else
-// static int MYDEBUG = 0;
-#endif
-
-static int MYWRITEDEBUG = 1;
-
-using namespace MED;
-
-#undef _DEBUG_
-
-void CheckMed(const std::string& theFileName)
-{
- MSG(MYDEBUG,"CheckMed - theFileName = '"<<theFileName<<"'");
- {
- //TErr anErr;
- PWrapper aMed = CrWrapper(theFileName);
-
- TKey2Gauss aKey2Gauss = GetKey2Gauss(aMed);
- TMKey2Profile aMKey2Profile = GetMKey2Profile(aMed);
- INITMSG(MYDEBUG,"aMed->GetNbProfiles() = "<<aMed->GetNbProfiles()<<std::endl);
-
- TInt aNbMeshes = aMed->GetNbMeshes();
- BEGMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<std::endl);
- for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
-
- PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
- INITMSG(MYDEBUG,"aMeshInfo->GetName() = '"<<aMeshInfo->GetName()<<"'"<<std::endl);
-
- TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
-
- TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
- GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,aEntityInfo);
-
- TFieldInfo2TimeStampInfoSet aFieldInfo2TimeStampInfoSet =
- GetFieldInfo2TimeStampInfoSet(aMed,aMeshInfo,aEntityInfo);
-
- TEntite2TFieldInfo2TimeStampInfoSet anEntite2TFieldInfo2TimeStampInfoSet =
- GetEntite2TFieldInfo2TimeStampInfoSet(aFieldInfo2TimeStampInfoSet);
-
- TEntite2TFieldInfo2TimeStampInfoSet::const_iterator anEntite2TFieldInfo2TimeStampInfoSetIter =
- anEntite2TFieldInfo2TimeStampInfoSet.begin();
- for(; anEntite2TFieldInfo2TimeStampInfoSetIter != anEntite2TFieldInfo2TimeStampInfoSet.end(); anEntite2TFieldInfo2TimeStampInfoSetIter++){
- const TFieldInfo2TimeStampInfoSet& aFieldInfo2TimeStampInfoSet = anEntite2TFieldInfo2TimeStampInfoSetIter->second;
- TFieldInfo2TimeStampInfoSet::const_iterator aFieldInfo2TimeStampInfoSetIter = aFieldInfo2TimeStampInfoSet.begin();
- for(; aFieldInfo2TimeStampInfoSetIter != aFieldInfo2TimeStampInfoSet.end(); aFieldInfo2TimeStampInfoSetIter++){
- PFieldInfo aFieldInfo = aFieldInfo2TimeStampInfoSetIter->first;
- INITMSG(MYDEBUG,
- "GetPFieldInfo "<<
- "- aName = '"<<aFieldInfo->GetName()<<"'"<<
- "; aType = "<<aFieldInfo->GetType()<<
- "; aNbComp = "<<aFieldInfo->GetNbComp()<<
- std::endl);
- const TTimeStampInfoSet& aTimeStampInfoSet = aFieldInfo2TimeStampInfoSetIter->second;
- TTimeStampInfoSet::const_iterator aTimeStampInfoSettIter = aTimeStampInfoSet.begin();
- for(; aTimeStampInfoSettIter != aTimeStampInfoSet.end(); aTimeStampInfoSettIter++){
- PTimeStampInfo aTimeStampInfo = *aTimeStampInfoSettIter;
- INITMSG(MYDEBUG,
- "GetPTimeStampInfo "<<
- "- anEntity = "<<aTimeStampInfo->GetEntity()<<
- "; aNumDt = "<<aTimeStampInfo->GetNumDt()<<
- std::endl);
- PTimeStampValueBase aTimeStampValue =
- aMed->GetPTimeStampValue(aTimeStampInfo,
- aMKey2Profile,
- aKey2Gauss);
- }
- }
- }
-
- continue;
-
- TFamilyInfoSet aFamilyInfoSet = GetFamilyInfoSet(aMed,aMeshInfo);
-
- TEntity2FamilySet aEntity2FamilySet =
- GetEntity2FamilySet(aMed,anEntity2TGeom2ElemInfo,aFamilyInfoSet);
-
- TGroupInfo aGroupInfo = GetGroupInfo(aFamilyInfoSet);
-
- PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
- TEntity2TGeom2ElemInfo::const_iterator anIter = anEntity2TGeom2ElemInfo.begin();
- for(; anIter != anEntity2TGeom2ElemInfo.end(); anIter++){
- const EEntiteMaillage& anEntity = anIter->first;
- if(anEntity != eNOEUD){
- const TGeom2ElemInfo& aGeom2ElemInfo = anIter->second;
- TKey2Gauss::const_iterator anIter2 = aKey2Gauss.begin();
- for(; anIter2 != aKey2Gauss.end(); anIter2++){
- const TGaussInfo::TKey& aKey = anIter2->first;
- EGeometrieElement aGeom = boost::get<0>(aKey);
- TGeom2ElemInfo::const_iterator anIter3 = aGeom2ElemInfo.find(aGeom);
- if(anIter3 != aGeom2ElemInfo.end()){
- if(PCellInfo aCellInfo = anIter3->second){
- PGaussInfo aGaussInfo = anIter2->second;
- TGaussCoord aGaussCoord;
- GetGaussCoord3D(aGaussInfo,aCellInfo,aNodeInfo,aGaussCoord);
- }
- }
- }
- }
- }
-
- }
- }
- MSG(MYDEBUG,"OK");
-}
-
-
-void CopyMed(const PWrapper& theMed,
- const PWrapper& theMed2,
- int theIncr)
-{
- TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
- TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
-
- TInt aNbMeshes = theMed->GetNbMeshes();
- MSG(MYDEBUG,"aNbMeshes = "<<aNbMeshes);
- std::string aName;
- for(TInt iMesh = 0; iMesh < aNbMeshes; iMesh++){
- PMeshInfo aMeshInfo = theMed->GetPMeshInfo(iMesh+1);
-#ifdef _DEBUG_
- TInt aDim = aMeshInfo->myDim;
- aName = aMeshInfo->GetName();
- INITMSG(MYDEBUG,"GetMeshInfo - aName = '"<<aName<<"'; aDim = "<<aDim<<"\n");
-#endif
- PMeshInfo aMeshInfo2 = theMed2->CrMeshInfo(aMeshInfo);
- if(MYWRITEDEBUG){
- aName = aMeshInfo2->GetName();
-
- aName[0] += theIncr;
- aMeshInfo2->SetName(aName);
- theMed2->SetMeshInfo(aMeshInfo2);
- BEGMSG(MYDEBUG,"aNbMeshes2 = "<<theMed2->GetNbMeshes()<<"\n");
- }
-
- TEntityInfo aEntityInfo = theMed->GetEntityInfo(aMeshInfo);
-
- //continue;
-
- TInt aNbFields = theMed->GetNbFields();
- MSG(MYDEBUG,"GetNbFields() = "<<aNbFields);
- for(TInt iField = 0; iField < aNbFields; iField++){
- PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,iField+1);
-#ifdef _DEBUG_
- TInt aNbComp = aFieldInfo->GetNbComp();
- INITMSG(MYDEBUG,"aName = '"<<aFieldInfo->GetName()<<"'; aNbComp = "<<aNbComp<<";\n");
-#endif
- PFieldInfo aFieldInfo2 = theMed->CrFieldInfo(aMeshInfo2,aFieldInfo);
-
- if(MYWRITEDEBUG){
- aName = aFieldInfo->GetName();
- aName[0] += theIncr;
- aFieldInfo2->SetName(aName);
- theMed2->SetFieldInfo(aFieldInfo2);
- }
-
- EEntiteMaillage anEntity;
- TGeom2Size aGeom2Size;
- TInt aNbTimeStamps =
- theMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,anEntity,aGeom2Size);
- {
- INITMSG(MYDEBUG,"GetNbTimeStamps = "<<aNbTimeStamps<<std::endl);
- for(TInt iTimeStamp = 0; iTimeStamp < aNbTimeStamps; iTimeStamp++){
- PTimeStampInfo aTimeStampInfo =
- theMed->GetPTimeStampInfo(aFieldInfo,anEntity,aGeom2Size,iTimeStamp+1);
-#ifdef _DEBUG_
- TInt aNumDt = aTimeStampInfo->GetNumDt();
- INITMSG(MYDEBUG,"aNumDt = "<<aNumDt<<"\n");
-#endif
-
- PTimeStampInfo aTimeStampInfo2 =
- theMed->CrTimeStampInfo(aFieldInfo2,aTimeStampInfo);
-
- PTimeStampValueBase aTimeStampValue =
- theMed->GetPTimeStampValue(aTimeStampInfo,
- aMKey2Profile,
- aKey2Gauss);
-
- PTimeStampValueBase aTimeStampValue2 =
- theMed->CrTimeStampValue(aTimeStampInfo2,
- aTimeStampValue);
-
- if(MYWRITEDEBUG) theMed2->SetTimeStamp(aTimeStampValue2);
- }
- }
- }
-
- TInt aNbFam = theMed->GetNbFamilies(aMeshInfo);
- MSG(MYDEBUG,"GetNbFamilies() = "<<aNbFam);
- for(TInt iFam = 0; iFam < aNbFam; iFam++){
- PFamilyInfo aFamilyInfo = theMed->GetPFamilyInfo(aMeshInfo,iFam+1);
- TInt aNbGroup = aFamilyInfo->GetNbGroup();
-#ifdef _DEBUG_
- TInt aNbAttr = aFamilyInfo->GetNbAttr();
-#endif
- TInt anId = aFamilyInfo->GetId();
- if(anId == 0)
- continue;
-
- aName = aFamilyInfo->GetName();
-#ifdef _DEBUG_
- INITMSG(MYDEBUG,"aName = '"<<aName<<"'; anId = "<<anId<<
- "; aNbAttr = "<<aNbAttr<<"; aNbGroup = "<<aNbGroup<<"\n");
-#endif
- PFamilyInfo aFamilyInfo2 = theMed->CrFamilyInfo(aMeshInfo2,aFamilyInfo);
- for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
- aName = aFamilyInfo->GetGroupName(iGroup);
- INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
- aName[0] += theIncr;
- aFamilyInfo2->SetGroupName(iGroup,aName);
- }
-
- if(MYWRITEDEBUG){
- aName = aFamilyInfo->GetName();
- aName[0] += theIncr;
- aFamilyInfo2->SetName(aName);
- theMed2->SetFamilyInfo(aFamilyInfo2);
- INITMSG(MYDEBUG,"GetNbFamilies = "<<theMed2->GetNbFamilies(aMeshInfo2)<<std::endl);
- }
- }
-
- MSG(MYDEBUG,"GetEntityInfo - aNbEntities = "<<aEntityInfo.size());
- TEntityInfo::iterator anEntityInfoIter = aEntityInfo.begin();
- for(; anEntityInfoIter != aEntityInfo.end(); anEntityInfoIter++){
- const EEntiteMaillage& anEntity = anEntityInfoIter->first;
- INITMSG(MYDEBUG,"anEntity = "<<anEntity<<"\n");
- if(anEntity == eNOEUD){
- PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
- PNodeInfo aNodeInfo2 = theMed->CrNodeInfo(aMeshInfo2,aNodeInfo);
- if(MYWRITEDEBUG) theMed2->SetNodeInfo(aNodeInfo2);
- continue;
- }
- TGeom2Size& aGeom2Size = anEntityInfoIter->second;
- TGeom2Size::iterator aGeomIter = aGeom2Size.begin();
- for(; aGeomIter != aGeom2Size.end(); aGeomIter++){
- const EGeometrieElement& aGeom = aGeomIter->first;
-#ifdef _DEBUG_
- const TInt& aNbElem = aGeomIter->second;
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<": ");
-#endif
- switch(aGeom){
- case ePOLYGONE: {
- PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
- PPolygoneInfo aPolygoneInfo2 = theMed->CrPolygoneInfo(aMeshInfo2,aPolygoneInfo);
- if(MYWRITEDEBUG) theMed2->SetPolygoneInfo(aPolygoneInfo2);
- break;
- }
- case ePOLYEDRE: {
- PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
- PPolyedreInfo aPolyedreInfo2 = theMed->CrPolyedreInfo(aMeshInfo2,aPolyedreInfo);
- if(MYWRITEDEBUG) theMed2->SetPolyedreInfo(aPolyedreInfo2);
- break;
- }
- default:
- PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
- PCellInfo aCellInfo2 = theMed2->CrCellInfo(aMeshInfo2,aCellInfo);
- if(MYWRITEDEBUG) theMed2->SetCellInfo(aCellInfo2);
- }
- }
- }
-
- }
- MSG(MYDEBUG,"OK");
-}
-
-
-void CopyMed(const std::string& theFileName,
- const std::string& theFileName2,
- MED::EVersion theVersion,
- int theNbCopy)
-{
- MSG(MYDEBUG,"CopyMed - theFileName = '"<<theFileName<<"'; theFileName2 = '"<<theFileName2<<"', theVersion = "<<theVersion);
-
- PWrapper aMed = CrWrapper(theFileName);
-
- PWrapper aMed2 = CrWrapper(theFileName2,theVersion);
-
- for(int i = 0; i < theNbCopy; i++)
- CopyMed(aMed,aMed2,i);
-}
-
-
-void ReadMed(const char* theFileName,
- const char* theFileName2,
- MED::EVersion theVersion = eV2_2,
- int theNbCopy = 1)
-{
- MSG(MYDEBUG,"theFileName = '"<<theFileName<<"'; "<<
- "theFileName2 = '"<<theFileName2<<"'; "<<
- "theVersion = "<<theVersion<<"; "<<
- "theNbCopy = "<<theNbCopy);
-
- CopyMed(theFileName,theFileName2,theVersion,theNbCopy);
-}
-
-#ifdef WIN32
-#pragma warning(disable:4101) // exc unreferenced ... ??
-#endif
-
-int main(int argc, char** argv){
-#ifndef _DEBUG_
- try{
-#endif
- if(argc == 2)
- CheckMed(argv[1]);
- if(argc == 3)
- ReadMed(argv[1],argv[2]);
- if(argc == 4)
- ReadMed(argv[1],argv[2],MED::EVersion(atoi(argv[3])));
- if(argc == 5)
- ReadMed(argv[1],argv[2],MED::EVersion(atoi(argv[3])),atoi(argv[4]));
- return 0;
-#ifndef _DEBUG_
- }catch(std::exception& exc){
- MSG(MYDEBUG,"Follow exception was accured :\n"<<exc.what());
- }catch(...){
- MSG(MYDEBUG,"Unknown exception was accured");
- }
-#endif
- return 1;
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-// File : MED_WrapperFactory.hxx
-// Author : Alexander A. BORODIN
-//
-#ifndef _MED_WrapperFactory_HXX_
-#define _MED_WrapperFactory_HXX_
-
-#ifdef WIN32
- #if defined MEDWRAPPER_FACTORY_EXPORTS || defined MEDWrapper_EXPORTS
- #if defined WIN32
- #define MEDWRAPPER_FACTORY_EXPORT __declspec( dllexport )
- #else
- #define MEDWRAPPER_FACTORY_EXPORT
- #endif
- #else
- #if defined WIN32
- #define MEDWRAPPER_FACTORY_EXPORT __declspec( dllimport )
- #else
- #define MEDWRAPPER_FACTORY_EXPORT
- #endif
- #endif
-#else
- #define MEDWRAPPER_FACTORY_EXPORT
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#include <med.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main (int argc, char **argv)
-{
- med_idt aFid = MEDfileOpen(argv[1],MED_ACC_RDONLY);
- if(aFid < 0)
- exit(1);
-
- med_int aMajor, aMinor, aRelease;
- med_err aRet = MEDfileNumVersionRd(aFid,&aMajor,&aMinor,&aRelease);
- MEDfileClose(aFid);
- if(aRet < 0) {
- // VSR: simulate med 2.3.6 behavior, med file version is assumed to 2.1
- aMajor=2;
- aMinor=aRelease=-1;
- }
-
- printf("%d.%d.%d\n",aMajor,aMinor,aRelease);
-}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_Algorithm.hxx"
+#include "MED_Wrapper.hxx"
+#include "MED_Utilities.hxx"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ TEntity2TGeom2ElemInfo
+ GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper,
+ const PMeshInfo& theMeshInfo,
+ const MED::TEntityInfo& theEntityInfo)
+ {
+ MSG(MYDEBUG,"GetElemsByEntity(...)");
+ TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo;
+ MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin();
+ PElemInfo anElemInfo;
+ TErr anErr;
+ for(; anIter != theEntityInfo.end(); anIter++){
+ const EEntiteMaillage& anEntity = anIter->first;
+ const TGeom2Size& aGeom2Size = anIter->second;
+ TGeom2ElemInfo& aGeom2ElemInfo = anEntity2TGeom2ElemInfo[anEntity];
+
+ if(anEntity == eNOEUD){
+ aGeom2ElemInfo[ePOINT1] = theWrapper->GetPElemInfo(theMeshInfo);
+ continue;
+ }
+
+ TGeom2Size::const_iterator anIter2 = aGeom2Size.begin();
+ for(; anIter2 != aGeom2Size.end(); anIter2++){
+ const EGeometrieElement& aGeom = anIter2->first;
+ aGeom2ElemInfo[aGeom] = theWrapper->GetPElemInfo(theMeshInfo,anEntity,aGeom,MED::eNOD,&anErr);
+ }
+ }
+ ADDMSG(MYDEBUG,"\n");
+ return anEntity2TGeom2ElemInfo;
+ }
+
+ //---------------------------------------------------------------
+ TFamilyInfoSet
+ GetFamilyInfoSet(const PWrapper& theWrapper,
+ const PMeshInfo& theMeshInfo)
+ {
+ MSG(MYDEBUG,"GetFamilies(...)");
+ TErr anErr;
+ TFamilyInfoSet aFamilyInfoSet;
+ TInt aNbFam = theWrapper->GetNbFamilies(*theMeshInfo);
+ INITMSG(MYDEBUG,"GetNbFamilies() = "<<aNbFam<<"\n");
+ for(TInt iFam = 1; iFam <= aNbFam; iFam++){
+ PFamilyInfo aFamilyInfo = theWrapper->GetPFamilyInfo(theMeshInfo,iFam,&anErr);
+ if(anErr >= 0)
+ aFamilyInfoSet.insert(aFamilyInfo);
+ }
+ ADDMSG(MYDEBUG,"\n");
+ return aFamilyInfoSet;
+ }
+
+ //---------------------------------------------------------------
+ TGroupInfo
+ GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet)
+ {
+ MSG(MYDEBUG,"GetFamiliesByGroup(...)");
+ TGroupInfo aGroup;
+ TFamilyInfoSet::const_iterator anIter = theFamilyInfoSet.begin();
+ for(; anIter != theFamilyInfoSet.end(); anIter++){
+ const PFamilyInfo& aFamilyInfo = *anIter;
+ TInt aNbGroup = aFamilyInfo->GetNbGroup();
+ for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){
+ aGroup[aFamilyInfo->GetGroupName(iGroup)].insert(aFamilyInfo);
+ }
+ }
+
+#ifdef _DEBUG_
+ if(MYDEBUG){
+ TGroupInfo::const_iterator anIter = aGroup.begin();
+ for(; anIter != aGroup.end(); anIter++){
+ const std::string& aName = anIter->first;
+ INITMSG(MYDEBUG,"aGroupName = '"<<aName<<"'\n");
+ const TFamilyInfoSet& aFamilyInfoSet = anIter->second;
+ TFamilyInfoSet::const_iterator anFamIter = aFamilyInfoSet.begin();
+ for(; anFamIter != aFamilyInfoSet.end(); anFamIter++){
+ const PFamilyInfo& aFamilyInfo = *anFamIter;
+ INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyInfo->GetName()<<"'\n");
+ }
+ }
+ ADDMSG(MYDEBUG,"\n");
+ }
+#endif
+
+ return aGroup;
+ }
+
+ //---------------------------------------------------------------
+ TFieldInfo2TimeStampInfoSet
+ GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper,
+ const PMeshInfo& theMeshInfo,
+ const MED::TEntityInfo& theEntityInfo)
+ {
+ MSG(MYDEBUG,"GetFieldsByEntity(...)");
+ TFieldInfo2TimeStampInfoSet aFieldInfo2TimeStampInfoSet;
+ TInt aNbFields = theWrapper->GetNbFields();
+ INITMSG(MYDEBUG,"GetNbFields() = "<<aNbFields<<"\n");
+ for(TInt iField = 1; iField <= aNbFields; iField++){
+ PFieldInfo aFieldInfo = theWrapper->GetPFieldInfo(theMeshInfo,iField);
+ INITMSG(MYDEBUG,"aFieldName = '"<<aFieldInfo->GetName()<<
+ "'; aNbComp = "<<aFieldInfo->GetNbComp()<<"; ");
+ TGeom2Size aGeom2Size;
+ EEntiteMaillage anEntity = EEntiteMaillage(-1);
+ TInt aNbTimeStamps = theWrapper->GetNbTimeStamps(aFieldInfo,theEntityInfo,anEntity,aGeom2Size);
+ ADDMSG(MYDEBUG,"anEntity = "<<anEntity<<"; GetNbTimeStamps = "<<aNbTimeStamps<<"\n");
+ for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
+ PTimeStampInfo aTimeStamp =
+ theWrapper->GetPTimeStampInfo(aFieldInfo,anEntity,aGeom2Size,iTimeStamp);
+ aFieldInfo2TimeStampInfoSet[aFieldInfo].insert(aTimeStamp);
+ INITMSG(MYDEBUG,
+ "aDt = "<<aTimeStamp->GetDt()<<
+ ", Unit = \'"<<aTimeStamp->GetUnitDt()<<"\n");
+ }
+ }
+ ADDMSG(MYDEBUG,"\n");
+ return aFieldInfo2TimeStampInfoSet;
+ }
+
+ //---------------------------------------------------------------
+ TEntite2TFieldInfo2TimeStampInfoSet
+ GetEntite2TFieldInfo2TimeStampInfoSet(const TFieldInfo2TimeStampInfoSet& theFieldInfo2TimeStampInfoSet)
+ {
+ TEntite2TFieldInfo2TimeStampInfoSet anEntite2TFieldInfo2TimeStampInfoSet;
+ TFieldInfo2TimeStampInfoSet::const_iterator anIter = theFieldInfo2TimeStampInfoSet.begin();
+ for(; anIter != theFieldInfo2TimeStampInfoSet.end(); anIter++){
+ const TTimeStampInfoSet& aTimeStampInfoSet = anIter->second;
+ //const PFieldInfo& aFieldInfo = anIter->first;
+ if(aTimeStampInfoSet.empty())
+ continue;
+ const PTimeStampInfo& aTimeStampInfo = *aTimeStampInfoSet.begin();
+ anEntite2TFieldInfo2TimeStampInfoSet[ConvertEntity(aTimeStampInfo->GetEntity())].insert(*anIter);
+ }
+ return anEntite2TFieldInfo2TimeStampInfoSet;
+ }
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight)
+ {
+ const MED::PFamilyInfo& aLeftInfo = boost::get<0>(theLeft);
+ const MED::PFamilyInfo& aRightInfo = boost::get<0>(theRight);
+ return aLeftInfo->GetId() < aRightInfo->GetId();
+ }
+
+ //---------------------------------------------------------------
+ TEntity2FamilySet
+ GetEntity2FamilySet(const PWrapper& theWrapper,
+ const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
+ const TFamilyInfoSet& theFamilyInfoSet)
+ {
+ MSG(MYDEBUG,"GetFamiliesByEntity(...)");
+ TEntity2FamilySet anEntity2FamilySet;
+
+ typedef std::map<TInt,PFamilyInfo> TId2Family;
+ TId2Family anId2Family;
+ TFamilyInfoSet::const_iterator anIter = theFamilyInfoSet.begin();
+ for(; anIter != theFamilyInfoSet.end(); anIter++){
+ const PFamilyInfo& aFamilyInfo = *anIter;
+ anId2Family.insert(TId2Family::value_type(aFamilyInfo->GetId(),aFamilyInfo));
+ }
+
+ if(!anId2Family.empty()){
+ typedef std::map<TInt,TInt> TFamilyID2Size;
+ typedef std::map<EEntiteMaillage,TFamilyID2Size> TEntity2FamilyID;
+ TEntity2FamilyID anEntity2FamilyID;
+
+ if(!theEntity2TGeom2ElemInfo.empty()){
+ TEntity2TGeom2ElemInfo::const_iterator anIter = theEntity2TGeom2ElemInfo.begin();
+ for(; anIter != theEntity2TGeom2ElemInfo.end(); anIter++){
+ const EEntiteMaillage& anEntity = anIter->first;
+ TFamilyID2Size& aFamilyID2Size = anEntity2FamilyID[anEntity];
+ const TGeom2ElemInfo& aGeom2ElemInfo = anIter->second;
+ TGeom2ElemInfo::const_iterator aGeom2ElemInfoIter = aGeom2ElemInfo.begin();
+ for(; aGeom2ElemInfoIter != aGeom2ElemInfo.end(); aGeom2ElemInfoIter++){
+ const PElemInfo& aElemInfo = aGeom2ElemInfoIter->second;
+ if(TInt aNbElem = aElemInfo->GetNbElem()){
+ for(TInt i = 0; i < aNbElem; i++){
+ aFamilyID2Size[aElemInfo->GetFamNum(i)] += 1;
+ }
+ }
+ }
+ }
+ }
+
+ if(!anEntity2FamilyID.empty()){
+ TEntity2FamilyID::const_iterator anIter = anEntity2FamilyID.begin();
+ for(; anIter != anEntity2FamilyID.end(); anIter++){
+ const EEntiteMaillage& anEntity = anIter->first;
+ INITMSG(MYDEBUG,"anEntity = "<<anEntity<<":\n");
+ const TFamilyID2Size& aFamilyID2Size = anIter->second;
+ TFamilyID2Size::const_iterator anIter2 = aFamilyID2Size.begin();
+ for(; anIter2 != aFamilyID2Size.end(); anIter2++){
+ TInt anId = anIter2->first;
+ TInt aSize = anIter2->second;
+ TId2Family::const_iterator anIter3 = anId2Family.find(anId);
+ if(anIter3 != anId2Family.end()){
+ const PFamilyInfo& aFamilyInfo = anIter3->second;
+ anEntity2FamilySet[anEntity].insert(TFamilyTSize(aFamilyInfo,aSize));
+ INITMSG(MYDEBUG,
+ "aFamilyName = '"<<aFamilyInfo->GetName()<<
+ "' anId = "<<aFamilyInfo->GetId()<<"\n");
+ }
+ }
+ }
+ }
+ }
+ ADDMSG(MYDEBUG,"\n");
+ return anEntity2FamilySet;
+ }
+
+ //---------------------------------------------------------------
+ TKey2Gauss
+ GetKey2Gauss(const PWrapper& theWrapper,
+ TErr* theErr,
+ EModeSwitch theMode)
+ {
+ INITMSG(MYDEBUG,"GetKey2Gauss - theMode = "<<theMode<<std::endl);
+ TKey2Gauss aKey2Gauss;
+ TInt aNbGauss = theWrapper->GetNbGauss(theErr);
+ for(TInt anId = 1; anId <= aNbGauss; anId++){
+ TGaussInfo::TInfo aPreInfo = theWrapper->GetGaussPreInfo(anId);
+ PGaussInfo anInfo = theWrapper->CrGaussInfo(aPreInfo,theMode);
+ theWrapper->GetGaussInfo(anId,anInfo,theErr);
+ TGaussInfo::TKey aKey = boost::get<0>(aPreInfo);
+ aKey2Gauss[aKey] = anInfo;
+
+#ifdef _DEBUG_
+ const EGeometrieElement& aGeom = boost::get<0>(aKey);
+ const std::string& aName = boost::get<1>(aKey);
+ INITMSG(MYDEBUG,
+ "- aGeom = "<<aGeom<<
+ "; aName = '"<<aName<<"'"<<
+ std::endl);
+#endif
+
+ }
+ return aKey2Gauss;
+ }
+
+ //---------------------------------------------------------------
+ PProfileInfo
+ GetProfileInfo(const PWrapper& theWrapper,
+ const std::string& theProfileName,
+ TErr* theErr,
+ EModeProfil theMode)
+ {
+ PProfileInfo anInfo;
+ TInt aNbProfiles = theWrapper->GetNbProfiles(theErr);
+ for(TInt anId = 1; anId <= aNbProfiles; anId++){
+ TProfileInfo::TInfo aPreInfo = theWrapper->GetProfilePreInfo(anId);
+ const std::string& aName = boost::get<0>(aPreInfo);
+ if(aName == theProfileName)
+ return theWrapper->GetPProfileInfo(anId,theMode,theErr);
+ }
+ return anInfo;
+ }
+
+ //---------------------------------------------------------------
+ TMKey2Profile
+ GetMKey2Profile(const PWrapper& theWrapper,
+ TErr* theErr,
+ EModeProfil theMode)
+ {
+ INITMSG(MYDEBUG,"GetMKey2Profile - theMode = "<<theMode<<std::endl);
+ TKey2Profile aKey2Profile;
+ TInt aNbProfiles = theWrapper->GetNbProfiles(theErr);
+ for(TInt anId = 1; anId <= aNbProfiles; anId++){
+ TProfileInfo::TInfo aPreInfo = theWrapper->GetProfilePreInfo(anId);
+ PProfileInfo anInfo = theWrapper->GetPProfileInfo(anId,theMode,theErr);
+ const std::string& aName = boost::get<0>(aPreInfo);
+ aKey2Profile[aName] = anInfo;
+
+#ifdef _DEBUG_
+ INITMSG(MYDEBUG,
+ "- aName = '"<<aName<<"'"<<
+ " : "<<
+ std::endl);
+ TInt aNbElem = anInfo->GetSize();
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+#endif
+
+ }
+ return TMKey2Profile(theMode,aKey2Profile);
+ }
+
+ //---------------------------------------------------------------
+ EEntiteMaillage
+ GetEntityByFamilyId(PGrilleInfo& theInfo,
+ TInt theId)
+ {
+ TElemNum::iterator aNodeFamIter = (theInfo->myFamNumNode).begin();
+ for(;aNodeFamIter != (theInfo->myFamNumNode).end(); aNodeFamIter++){
+ if(theId == *aNodeFamIter)
+ return eNOEUD;
+ }
+ TElemNum::iterator aCellFamIter = (theInfo->myFamNum).begin();
+ for(;aCellFamIter != (theInfo->myFamNum).end(); aCellFamIter++){
+ if(theId == *aCellFamIter)
+ return eMAILLE;
+ }
+ EXCEPTION(std::runtime_error, "GetEntityByFamilyId - fails");
+ return EEntiteMaillage(-1);
+ }
+
+ //---------------------------------------------------------------
+ TFamilyID2NbCells
+ GetFamilyID2NbCells(PGrilleInfo& theInfo)
+ {
+ TFamilyID2NbCells aFamily2NbCells;
+ TInt aNbNodes = theInfo->myFamNumNode.size();
+ TInt aNbCells = theInfo->myFamNum.size();
+ for(TInt i=0; i<aNbNodes; i++) aFamily2NbCells[theInfo->GetFamNumNode(i)] = 0;
+ for(TInt i=0; i<aNbCells; i++) aFamily2NbCells[theInfo->GetFamNum(i)] = 0;
+ for(TInt i=0; i<aNbNodes; i++) aFamily2NbCells[theInfo->GetFamNumNode(i)] += 1;
+ for(TInt i=0; i<aNbCells; i++) aFamily2NbCells[theInfo->GetFamNum(i)] += 1;
+ return aFamily2NbCells;
+ }
+
+ //---------------------------------------------------------------
+ EEntiteMaillage
+ ConvertEntity(const EEntiteMaillage& aEntity)
+ {
+ switch( aEntity ){
+ case eNOEUD_ELEMENT:
+ case eMAILLE:
+ return eMAILLE; // eNOEUD_ELEMENT is eMAILLE
+ case eFACE:
+ case eARETE:
+ case eNOEUD:
+ return aEntity;
+ default:
+ break;
+ }
+ return EEntiteMaillage(-1);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Algorithm_HeaderFile
+#define MED_Algorithm_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Structures.hxx"
+
+#include <boost/tuple/tuple.hpp>
+
+#include <set>
+#include <string>
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ typedef std::map<EGeometrieElement,PElemInfo> TGeom2ElemInfo;
+ typedef std::map<EEntiteMaillage,TGeom2ElemInfo> TEntity2TGeom2ElemInfo;
+ typedef std::set<PFamilyInfo> TFamilyInfoSet;
+ typedef std::map<std::string,TFamilyInfoSet> TGroupInfo;
+ typedef boost::tuple<PFamilyInfo,TInt> TFamilyTSize;
+ typedef std::set<TFamilyTSize> TFamilyTSizeSet;
+ typedef std::map<EEntiteMaillage,TFamilyTSizeSet> TEntity2FamilySet;
+ typedef std::set<PTimeStampInfo> TTimeStampInfoSet;
+ typedef std::map<PFieldInfo,TTimeStampInfoSet> TFieldInfo2TimeStampInfoSet;
+ typedef std::map<EEntiteMaillage,TFieldInfo2TimeStampInfoSet> TEntite2TFieldInfo2TimeStampInfoSet;
+ typedef std::map<TGaussInfo::TKey,PGaussInfo,TGaussInfo::TLess> TKey2Gauss;
+ typedef std::map<TProfileInfo::TKey,PProfileInfo> TKey2Profile;
+ typedef boost::tuple<EModeProfil,TKey2Profile> TMKey2Profile;
+ typedef std::map<TInt,TInt> TFamilyID2NbCells;
+
+ //---------------------------------------------------------------
+ //! Get set of TElemInfo by its geometrical type and corresponding MED ENTITY
+ MEDWRAPPER_EXPORT
+ TEntity2TGeom2ElemInfo
+ GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper,
+ const PMeshInfo& theMeshInfo,
+ const MED::TEntityInfo& theEntityInfo);
+
+ //---------------------------------------------------------------
+ //! Read set of MED FAMILIES for defined MED file
+ MEDWRAPPER_EXPORT
+ TFamilyInfoSet
+ GetFamilyInfoSet(const PWrapper& theWrapper,
+ const PMeshInfo& theMeshInfo);
+
+ //---------------------------------------------------------------
+ //! Compare two MED FAMILIES
+ MEDWRAPPER_EXPORT
+ bool
+ operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight);
+
+ //---------------------------------------------------------------
+ //! Split set of MED FAMILIES by corresponding MED ENTITY
+ MEDWRAPPER_EXPORT
+ TEntity2FamilySet
+ GetEntity2FamilySet(const PWrapper& theWrapper,
+ const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
+ const TFamilyInfoSet& theFamilyInfoSet);
+
+ //---------------------------------------------------------------
+ //! Split the input set of MED FAMILIES by corresponding MED GROUPS
+ MEDWRAPPER_EXPORT
+ TGroupInfo
+ GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet);
+
+ //---------------------------------------------------------------
+ //! Read set of MED TIMESTAMPS groupped by corresponding MED FIELDS
+ MEDWRAPPER_EXPORT
+ TFieldInfo2TimeStampInfoSet
+ GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper,
+ const PMeshInfo& theMeshInfo,
+ const MED::TEntityInfo& theEntityInfo);
+
+ //---------------------------------------------------------------
+ //! Split the input set of MED TIMESTAMPS by corresponding MED FIELDS and MED ENTITIES
+ MEDWRAPPER_EXPORT
+ TEntite2TFieldInfo2TimeStampInfoSet
+ GetEntite2TFieldInfo2TimeStampInfoSet(const TFieldInfo2TimeStampInfoSet& theFieldInfo2TimeStampInfoSet);
+
+ //---------------------------------------------------------------
+ //! Read set of MED GAUSS
+ MEDWRAPPER_EXPORT
+ TKey2Gauss
+ GetKey2Gauss(const PWrapper& theWrapper,
+ TErr* theErr = NULL,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //---------------------------------------------------------------
+ //! Get MED PROFILE by its name
+ MEDWRAPPER_EXPORT
+ PProfileInfo
+ GetProfileInfo(const PWrapper& theWrapper,
+ const std::string& theProfileName,
+ TErr* theErr = NULL,
+ EModeProfil theMode = eCOMPACT);
+
+ //---------------------------------------------------------------
+ //! Read set of MED PROFILES
+ MEDWRAPPER_EXPORT
+ TMKey2Profile
+ GetMKey2Profile(const PWrapper& theWrapper,
+ TErr* theErr = NULL,
+ EModeProfil theMode = eCOMPACT);
+
+ //---------------------------------------------------------------
+ //! Get Entity for Grille by family id.
+ MEDWRAPPER_EXPORT
+ EEntiteMaillage
+ GetEntityByFamilyId(PGrilleInfo& theInfo,
+ TInt theId);
+
+ //---------------------------------------------------------------
+ //! Get Number of cells for theId family, for Grille
+ MEDWRAPPER_EXPORT
+ TFamilyID2NbCells
+ GetFamilyID2NbCells(PGrilleInfo& theInfo);
+
+ //---------------------------------------------------------------
+ //! Convert eNOEUD_ELEMENT to eMAILLE
+ MEDWRAPPER_EXPORT
+ EEntiteMaillage
+ ConvertEntity(const EEntiteMaillage& aEntity);
+}
+
+#endif // MED_Algorithm_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_Common.hxx"
+#include <med.h>
+
+namespace MED
+{
+ TInt
+ GetDESCLength()
+ {
+ return 200;
+ }
+
+ TInt
+ GetIDENTLength()
+ {
+ return 8;
+ }
+
+ TInt
+ GetNOMLength()
+ {
+ return 64;
+ }
+
+ TInt
+ GetLNOMLength()
+ {
+ return 80;
+ }
+
+ TInt
+ GetPNOMLength()
+ {
+ return 16;
+ }
+
+ void
+ GetVersionRelease(TInt& major, TInt& minor, TInt& release)
+ {
+ major = MED_MAJOR_NUM;
+ minor = MED_MINOR_NUM;
+ release = MED_RELEASE_NUM;
+ }
+
+ TInt
+ GetNbConn(EGeometrieElement typmai,
+ EEntiteMaillage typent,
+ TInt mdim)
+ {
+ return typmai % 100;
+ }
+
+ TInt
+ GetNbNodes(EGeometrieElement typmai)
+ {
+ return typmai % 100;
+ }
+
+ const MED::TEntity2GeomSet& GetEntity2GeomSet()
+ {
+ static MED::TEntity2GeomSet Entity2GeomSet;
+
+ if ( Entity2GeomSet.empty() ) {
+ TGeomSet& aGeomARETESet = Entity2GeomSet[MED::eARETE];
+ aGeomARETESet.insert(MED::eSEG2);
+ aGeomARETESet.insert(MED::eSEG3);
+
+ TGeomSet& aGeomFACESet = Entity2GeomSet[MED::eFACE];
+ aGeomFACESet.insert(MED::eTRIA3);
+ aGeomFACESet.insert(MED::eQUAD4);
+ aGeomFACESet.insert(MED::eTRIA6);
+ aGeomFACESet.insert(MED::eTRIA7);
+ aGeomFACESet.insert(MED::eQUAD8);
+ aGeomFACESet.insert(MED::eQUAD9);
+ aGeomFACESet.insert(MED::ePOLYGONE);
+ aGeomFACESet.insert(MED::ePOLYGON2);
+
+ TGeomSet& aGeomMAILLESet = Entity2GeomSet[MED::eMAILLE];
+ aGeomMAILLESet.insert(MED::ePOINT1);
+ aGeomMAILLESet.insert(aGeomARETESet.begin(), aGeomARETESet.end());
+ aGeomMAILLESet.insert(aGeomFACESet.begin(), aGeomFACESet.end());
+ aGeomMAILLESet.insert(MED::eTETRA4);
+ aGeomMAILLESet.insert(MED::ePYRA5);
+ aGeomMAILLESet.insert(MED::ePENTA6);
+ aGeomMAILLESet.insert(MED::eHEXA8);
+ aGeomMAILLESet.insert(MED::eOCTA12);
+ aGeomMAILLESet.insert(MED::eTETRA10);
+ aGeomMAILLESet.insert(MED::ePYRA13);
+ aGeomMAILLESet.insert(MED::ePENTA15);
+ aGeomMAILLESet.insert(MED::eHEXA20);
+ aGeomMAILLESet.insert(MED::eHEXA27);
+ aGeomMAILLESet.insert(MED::ePOLYEDRE);
+
+ /* This combination allows reading nb of models of structure elements */
+ Entity2GeomSet[MED::eSTRUCT_ELEMENT].insert(MED::eAllGeoType);
+ }
+
+ return Entity2GeomSet;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Common_HeaderFile
+#define MED_Common_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Vector.hxx"
+#include "MED_SharedPtr.hxx"
+
+#include <string>
+#include <set>
+#include <map>
+
+#include <hdf5.h>
+
+#ifdef WIN32
+#pragma warning(disable:4099)
+#endif
+
+namespace MED
+{
+ typedef enum {eFAUX, eVRAI} EBooleen;
+ typedef double TFloat;
+#if defined(HAVE_F77INT64)
+ typedef long TInt;
+#else
+ typedef int TInt;
+#endif
+ typedef hid_t TIdt;
+ typedef herr_t TErr;
+
+ typedef enum {eFULL_INTERLACE, eNO_INTERLACE} EModeSwitch;
+
+ typedef enum {eFLOAT64=6, eINT=24, eLONG=26} ETypeChamp;
+
+ typedef enum {eNON_STRUCTURE, eSTRUCTURE} EMaillage;
+
+ typedef enum {eCART, eCYL, eSPHER} ERepere;
+
+ typedef enum {eNOD, eDESC} EConnectivite;
+
+ typedef enum {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
+ eQUAD4=204, eTRIA6=206, eTRIA7=207, eQUAD8=208, eQUAD9=209, eTETRA4=304,
+ ePYRA5=305, ePENTA6=306, eHEXA8=308, eOCTA12=312, eTETRA10=310,
+ ePYRA13=313, ePENTA15=315, eHEXA20=320, eHEXA27=327,
+ ePOLYGONE=400, ePOLYGON2=420, ePOLYEDRE=500, eNONE=0,
+ eBALL=1101, // no such a type in med.h, it's just a trick
+ eAllGeoType=-1} EGeometrieElement;
+
+ typedef enum {eMAILLE, eFACE, eARETE, eNOEUD, eNOEUD_ELEMENT, eSTRUCT_ELEMENT} EEntiteMaillage;
+
+ typedef enum {eNO_PFLMOD, eGLOBAL, eCOMPACT} EModeProfil;
+
+ typedef enum {eGRILLE_CARTESIENNE, eGRILLE_POLAIRE, eGRILLE_STANDARD} EGrilleType;
+
+ typedef enum {eCOOR, eCONN, eNOM, eNUM, eFAM, eCOOR_IND1, eCOOR_IND2, eCOOR_IND3} ETable;
+
+ typedef TVector<TInt> TIntVector;
+ typedef TVector<TFloat> TFloatVector;
+ typedef TVector<std::string> TStringVector;
+ typedef std::set<std::string> TStringSet;
+
+ typedef std::map<EGeometrieElement,TInt> TGeom2Size;
+ typedef std::map<EEntiteMaillage,TGeom2Size> TEntityInfo;
+
+ typedef std::set<EGeometrieElement> TGeomSet;
+ typedef std::map<EEntiteMaillage,TGeomSet> TEntity2GeomSet;
+
+ struct TNameInfo;
+ typedef SharedPtr<TNameInfo> PNameInfo;
+
+ struct TMeshInfo;
+ typedef SharedPtr<TMeshInfo> PMeshInfo;
+
+ struct TFamilyInfo;
+ typedef SharedPtr<TFamilyInfo> PFamilyInfo;
+
+ struct TElemInfo;
+ typedef SharedPtr<TElemInfo> PElemInfo;
+
+ struct TNodeInfo;
+ typedef SharedPtr<TNodeInfo> PNodeInfo;
+
+ struct TPolygoneInfo;
+ typedef SharedPtr<TPolygoneInfo> PPolygoneInfo;
+
+ struct TPolyedreInfo;
+ typedef SharedPtr<TPolyedreInfo> PPolyedreInfo;
+
+ struct TCellInfo;
+ typedef SharedPtr<TCellInfo> PCellInfo;
+
+ struct TBallInfo;
+ typedef SharedPtr<TBallInfo> PBallInfo;
+
+ struct TFieldInfo;
+ typedef SharedPtr<TFieldInfo> PFieldInfo;
+
+ struct TTimeStampInfo;
+ typedef SharedPtr<TTimeStampInfo> PTimeStampInfo;
+
+ struct TProfileInfo;
+ typedef SharedPtr<TProfileInfo> PProfileInfo;
+
+ struct TGaussInfo;
+ typedef SharedPtr<TGaussInfo> PGaussInfo;
+
+ class TGrilleInfo;
+ typedef SharedPtr<TGrilleInfo> PGrilleInfo;
+
+ struct TTimeStampValueBase;
+ typedef SharedPtr<TTimeStampValueBase> PTimeStampValueBase;
+
+ struct TWrapper;
+ typedef SharedPtr<TWrapper> PWrapper;
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetDESCLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetIDENTLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNOMLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetLNOMLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetPNOMLength();
+
+ MEDWRAPPER_EXPORT
+ void
+ GetVersionRelease(TInt&, TInt&, TInt&);
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNbConn(EGeometrieElement, EEntiteMaillage, TInt);
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNbNodes(EGeometrieElement typmai);
+
+ MEDWRAPPER_EXPORT
+ const TEntity2GeomSet&
+ GetEntity2GeomSet();
+}
+
+#endif // MED_Common_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_CoordUtils.hxx"
+#include "MED_Utilities.hxx"
+
+namespace MED
+{
+ enum ECoordName{eX, eY, eZ, eNone};
+
+ template<ECoordName TCoordId>
+ TFloat
+ GetCoord(const TCCoordSlice& theCoordSlice)
+ {
+ return theCoordSlice[TCoordId];
+ }
+
+ template<>
+ TFloat
+ GetCoord<eNone>(const TCCoordSlice& theCoordSlice)
+ {
+ return 0.0;
+ }
+
+ TGetCoord
+ aXYZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eZ>
+ };
+
+ TGetCoord
+ aXYGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord
+ aYZGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eX>,
+ &GetCoord<eY>
+ };
+
+ TGetCoord
+ aXZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNone>,
+ &GetCoord<eY>
+ };
+
+ TGetCoord
+ aXGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNone>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord
+ aYGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eX>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord
+ aZGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eNone>,
+ &GetCoord<eX>
+ };
+
+ //---------------------------------------------------------------
+ TCoordHelper
+ ::TCoordHelper(TGetCoord* theGetCoord):
+ myGetCoord(theGetCoord)
+ {}
+
+ TFloat
+ TCoordHelper
+ ::GetCoord(TCCoordSlice& theCoordSlice,
+ TInt theCoordId)
+ {
+ return (*myGetCoord[theCoordId])(theCoordSlice);
+ }
+
+ //---------------------------------------------------------------
+ PCoordHelper
+ GetCoordHelper(PNodeInfo theNodeInfo)
+ {
+ PCoordHelper aCoordHelper;
+ {
+ PMeshInfo aMeshInfo = theNodeInfo->GetMeshInfo();
+ TInt aMeshDimension = aMeshInfo->GetDim();
+ bool anIsDimPresent[3] = {false, false, false};
+ for(int iDim = 0; iDim < aMeshDimension; iDim++){
+ // PAL16857(SMESH not conform to the MED convention) ->
+ // 1D - always along X
+ // 2D - always in XOY plane
+ anIsDimPresent[iDim] = iDim < aMeshDimension;
+// std::string aName = theNodeInfo->GetCoordName(iDim);
+// if ( aName.size() > 1 ) // PAL12148, aName has size 8 or 16
+// aName = aName.substr(0,1);
+// if(aName == "x" || aName == "X")
+// anIsDimPresent[eX] = true;
+// else if(aName == "y" || aName == "Y")
+// anIsDimPresent[eY] = true;
+// else if(aName == "z" || aName == "Z")
+// anIsDimPresent[eZ] = true;
+ }
+
+ switch(aMeshDimension){
+ case 3:
+ aCoordHelper.reset(new TCoordHelper(aXYZGetCoord));
+ break;
+ case 2:
+ if(anIsDimPresent[eY] && anIsDimPresent[eZ])
+ aCoordHelper.reset(new TCoordHelper(aYZGetCoord));
+ else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
+ aCoordHelper.reset(new TCoordHelper(aXZGetCoord));
+ else
+ aCoordHelper.reset(new TCoordHelper(aXYGetCoord));
+ break;
+ case 1:
+ if(anIsDimPresent[eY])
+ aCoordHelper.reset(new TCoordHelper(aYGetCoord));
+ else if(anIsDimPresent[eZ])
+ aCoordHelper.reset(new TCoordHelper(aZGetCoord));
+ else
+ aCoordHelper.reset(new TCoordHelper(aXGetCoord));
+ break;
+ }
+ }
+ return aCoordHelper;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_CoordUtils_HeaderFile
+#define MED_CoordUtils_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Structures.hxx"
+
+namespace MED
+{
+ typedef TFloat (*TGetCoord)(const TCCoordSlice& theCoordSlice);
+
+ //---------------------------------------------------------------
+ class MEDWRAPPER_EXPORT TCoordHelper
+ {
+ TGetCoord* myGetCoord;
+
+ public:
+ TCoordHelper(TGetCoord* theGetCoord);
+
+ TFloat
+ GetCoord(TCCoordSlice& theCoordSlice,
+ TInt theCoordId);
+ };
+ typedef SharedPtr<TCoordHelper> PCoordHelper;
+
+ //---------------------------------------------------------------
+ MEDWRAPPER_EXPORT
+ PCoordHelper
+ GetCoordHelper(PNodeInfo theNodeInfo);
+}
+
+#endif // MED_CoordUtils_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_Factory.hxx"
+#include "MED_Utilities.hxx"
+#include "MED_Wrapper.hxx"
+
+#include <stdio.h>
+#include <errno.h>
+#include <sstream>
+
+#include <med.h>
+extern "C"
+{
+#ifndef WIN32
+ #include <unistd.h>
+#endif
+}
+
+namespace MED
+{
+ bool exists(const std::string& fileName)
+ {
+#ifdef WIN32
+ return (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES);
+#else
+ return (access(fileName.c_str(), F_OK) == 0);
+#endif
+ }
+
+ bool CheckCompatibility(const std::string& fileName)
+ {
+ bool ok = false;
+ // check that file is accessible
+ if ( exists(fileName) ) {
+ // check HDF5 && MED compatibility
+ med_bool hdfok, medok;
+ MEDfileCompatibility(fileName.c_str(), &hdfok, &medok);
+ if ( hdfok && medok ) {
+ med_idt aFid = MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY);
+ if (aFid >= 0) {
+ med_int major, minor, release;
+ med_err ret = MEDfileNumVersionRd(aFid, &major, &minor, &release);
+ if (ret >= 0) {
+ int version = 100*major + minor;
+ if (version >= 202)
+ ok = true;
+ }
+ }
+ MEDfileClose(aFid);
+ }
+ }
+ return ok;
+ }
+
+ bool GetMEDVersion(const std::string& fileName, int& major, int& minor, int& release)
+ {
+ bool ok = false;
+ major = minor = release = 0;
+ med_idt aFid = MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY);
+ if (aFid >= 0) {
+ med_int _major, _minor, _release;
+ med_err ret = MEDfileNumVersionRd(aFid, &_major, &_minor, &_release);
+ if (ret == 0) {
+ major = _major;
+ minor = _minor;
+ release = _release;
+ ok = true;
+ }
+ MEDfileClose(aFid);
+ }
+ return ok;
+ }
+
+ std::string GetMEDVersion(const std::string& fileName)
+ {
+ std::string version;
+ int major, minor, release;
+ if (GetMEDVersion(fileName, major, minor, release)) {
+ std::ostringstream os;
+ os << major << "." << minor << "." << release;
+ version = os.str();
+ }
+ return version;
+ }
+
+ PWrapper CrWrapperR(const std::string& fileName)
+ {
+ if (!CheckCompatibility(fileName)) {
+ EXCEPTION(std::runtime_error, "Cannot open file '"<<fileName<<"'.");
+ }
+ return new MED::TWrapper(fileName);
+ }
+
+ PWrapper CrWrapperW(const std::string& fileName)
+ {
+ if (!CheckCompatibility(fileName))
+ remove(fileName.c_str());
+ return new MED::TWrapper(fileName);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Factory_HeaderFile
+#define MED_Factory_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Wrapper.hxx"
+
+#include <string>
+
+namespace MED
+{
+ MEDWRAPPER_EXPORT
+ std::string GetMEDVersion( const std::string& );
+
+ MEDWRAPPER_EXPORT
+ bool GetMEDVersion( const std::string&, int&, int&, int& );
+
+ MEDWRAPPER_EXPORT
+ bool CheckCompatibility( const std::string& );
+
+ MEDWRAPPER_EXPORT
+ PWrapper CrWrapperR( const std::string& );
+
+ MEDWRAPPER_EXPORT
+ PWrapper CrWrapperW( const std::string& );
+}
+
+#endif // MED_Factory_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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
+//
+
+#include "MED_GaussDef.hxx"
+#include "MED_Utilities.hxx"
+#include "MED_GaussUtils.hxx"
+
+namespace MED
+{
+ //---------------------------------------------------------------
+
+ void TGaussDef::add(const double x, const double weight)
+ {
+ if ( dim() != 1 )
+ EXCEPTION( std::logic_error,"dim() != 1");
+ if ( myWeights.capacity() == myWeights.size() )
+ EXCEPTION( std::logic_error,"Extra gauss point");
+ myCoords.push_back( x );
+ myWeights.push_back( weight );
+ }
+ void TGaussDef::add(const double x, const double y, const double weight)
+ {
+ if ( dim() != 2 )
+ EXCEPTION( std::logic_error,"dim() != 2");
+ if ( myWeights.capacity() == myWeights.size() )
+ EXCEPTION( std::logic_error,"Extra gauss point");
+ myCoords.push_back( x );
+ myCoords.push_back( y );
+ myWeights.push_back( weight );
+ }
+ void TGaussDef::add(const double x, const double y, const double z, const double weight)
+ {
+ if ( dim() != 3 )
+ EXCEPTION( std::logic_error,"dim() != 3");
+ if ( myWeights.capacity() == myWeights.size() )
+ EXCEPTION( std::logic_error,"Extra gauss point");
+ myCoords.push_back( x );
+ myCoords.push_back( y );
+ myCoords.push_back( z );
+ myWeights.push_back( weight );
+ }
+ void TGaussDef::setRefCoords(const TShapeFun& aShapeFun)
+ {
+ myRefCoords.reserve( aShapeFun.myRefCoord.size() );
+ myRefCoords.assign( aShapeFun.myRefCoord.begin(),
+ aShapeFun.myRefCoord.end() );
+ }
+
+ //---------------------------------------------------------------
+ /*!
+ * \brief Fill definition of gauss points family
+ */
+ //---------------------------------------------------------------
+
+ TGaussDef::TGaussDef(const int geom, const int nbGauss, const int variant)
+ {
+ myType = geom;
+ myCoords .reserve( nbGauss * dim() );
+ myWeights.reserve( nbGauss );
+
+ switch ( geom ) {
+
+ case eSEG2:
+ case eSEG3:
+ if (geom == eSEG2) setRefCoords( TSeg2a() );
+ else setRefCoords( TSeg3a() );
+ switch ( nbGauss ) {
+ case 1: {
+ add( 0.0, 2.0 ); break;
+ }
+ case 2: {
+ const double a = 0.577350269189626;
+ add( a, 1.0 );
+ add( -a, 1.0 ); break;
+ }
+ case 3: {
+ const double a = 0.774596669241;
+ const double P1 = 1./1.8;
+ const double P2 = 1./1.125;
+ add( -a, P1 );
+ add( 0, P2 );
+ add( a, P1 ); break;
+ }
+ case 4: {
+ const double a = 0.339981043584856, b = 0.861136311594053;
+ const double P1 = 0.652145154862546, P2 = 0.347854845137454 ;
+ add( a, P1 );
+ add( -a, P1 );
+ add( b, P2 );
+ add( -b, P2 ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for SEG"<<nbGauss);
+ }
+ break;
+
+ case eTRIA3:
+ case eTRIA6:
+ if ( variant == 1 ) {
+ if (geom == eTRIA3) setRefCoords( TTria3b() );
+ else setRefCoords( TTria6b() );
+ switch ( nbGauss ) {
+ case 1: { // FPG1
+ add( 1/3., 1/3., 1/2. ); break;
+ }
+ case 3: { // FPG3
+ // what about COT3 ???
+ add( 1/6., 1/6., 1/6. );
+ add( 2/3., 1/6., 1/6. );
+ add( 1/6., 2/3., 1/6. ); break;
+ }
+ case 4: { // FPG4
+ add( 1/5., 1/5., 25/(24*4.) );
+ add( 3/5., 1/5., 25/(24*4.) );
+ add( 1/5., 3/5., 25/(24*4.) );
+ add( 1/3., 1/3., -27/(24*4.) ); break;
+ }
+ case 6: { // FPG6
+ const double P1 = 0.11169079483905, P2 = 0.0549758718227661;
+ const double a = 0.445948490915965, b = 0.091576213509771;
+ add( b, b, P2 );
+ add( 1-2*b, b, P2 );
+ add( b, 1-2*b, P2 );
+ add( a, 1-2*a, P1 );
+ add( a, a, P1 );
+ add( 1-2*a, a, P1 ); break;
+ }
+ case 7: { // FPG7
+ const double A = 0.470142064105115;
+ const double B = 0.101286507323456;
+ const double P1 = 0.066197076394253;
+ const double P2 = 0.062969590272413;
+ add( 1/3., 1/3., 9/80. );
+ add( A, A, P1 );
+ add( 1-2*A, A, P1 );
+ add( A, 1-2*A, P1 );
+ add( B, B, P2 );
+ add( 1-2*B, B, P2 );
+ add( B, 1-2*B, P2 ); break;
+ }
+ case 12: { // FPG12
+ const double A = 0.063089014491502;
+ const double B = 0.249286745170910;
+ const double C = 0.310352451033785;
+ const double D = 0.053145049844816;
+ const double P1 = 0.025422453185103;
+ const double P2 = 0.058393137863189;
+ const double P3 = 0.041425537809187;
+ add( A, A, P1 );
+ add( 1-2*A, A, P1 );
+ add( A, 1-2*A, P1 );
+ add( B, B, P2 );
+ add( 1-2*B, B, P2 );
+ add( B, 1-2*B, P2 );
+ add( C, D, P3 );
+ add( D, C, P3 );
+ add( 1-C-D, C, P3 );
+ add( 1-C-D, D, P3 );
+ add( C, 1-C-D, P3 );
+ add( D, 1-C-D, P3 ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for TRIA, variant 1: "
+ <<nbGauss);
+ }
+ }
+ else if ( variant == 2 ) {
+ if (geom == eTRIA3) setRefCoords( TTria3a() );
+ else setRefCoords( TTria6a() );
+ switch ( nbGauss ) {
+ case 1: {
+ add( -1/3., -1/3., 2. ); break;
+ }
+ case 3: {
+ add( -2/3., 1/3., 2/3. );
+ add( -2/3., -2/3., 2/3. );
+ add( 1/3., -2/3., 2/3. ); break;
+ }
+ case 6: {
+ const double P1 = 0.11169079483905, P2 = 0.0549758718227661;
+ const double A = 0.445948490915965, B = 0.091576213509771;
+ add( 2*B-1, 1-4*B, 4*P2 );
+ add( 2*B-1, 2*B-1, 4*P2 );
+ add( 1-4*B, 2*B-1, 4*P2 );
+ add( 1-4*A, 2*A-1, 4*P1 );
+ add( 2*A-1, 1-4*A, 4*P1 );
+ add( 2*A-1, 2*A-1, 4*P1 ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for TRIA, variant 2: "
+ <<nbGauss);
+ }
+ }
+ else if ( variant == 3 ) {
+ if (geom == eTRIA3) setRefCoords( TTria3b() );
+ else setRefCoords( TTria6b() );
+ switch ( nbGauss ) {
+ case 4: {
+ add( 1/3., 1/3., -27/96 );
+ add( 0.2 , 0.2 , 25/96 );
+ add( 0.6 , 0.2 , 25/96 );
+ add( 0.2 , 0.6 , 25/96 ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for TRIA, variant 3: "
+ <<nbGauss);
+ }
+ }
+ break;
+
+ case eQUAD4:
+ case eQUAD8:
+ if ( variant == 1 ) {
+ if (geom == eQUAD4) setRefCoords( TQuad4b() );
+ else setRefCoords( TQuad8b() );
+ switch ( nbGauss ) {
+ case 1: { // FPG1
+ add( 0, 0, 4 ); break;
+ }
+ case 4: { // FPG4
+ const double a = 1/sqrt(3.);
+ add( -a, -a, 1 );
+ add( a, -a, 1 );
+ add( a, a, 1 );
+ add( -a, a, 1 ); break;
+ }
+ case 9: { // FPG9
+ const double a = 0.774596669241483;
+ add( -a, -a, 25/81. );
+ add( a, -a, 25/81. );
+ add( a, a, 25/81. );
+ add( -a, a, 25/81. );
+ add( 0., -a, 40/81. );
+ add( a, 0., 40/81. );
+ add( 0., a, 40/81. );
+ add( -a, 0., 40/81. );
+ add( 0., 0., 64/81. ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for QUAD, variant 1: "
+ <<nbGauss);
+ }
+ }
+ else if ( variant == 2 ) {
+ if (geom == eQUAD4) setRefCoords( TQuad4a() );
+ else setRefCoords( TQuad8a() );
+ switch ( nbGauss ) {
+ case 4: {
+ const double a = 1/sqrt(3.);
+ add( -a, a, 1 );
+ add( -a, -a, 1 );
+ add( a, -a, 1 );
+ add( a, a, 1 ); break;
+ }
+ case 9: {
+ const double a = 0.774596669241483;
+ add( -a, a, 25/81. );
+ add( -a, -a, 25/81. );
+ add( a, -a, 25/81. );
+ add( a, a, 25/81. );
+ add( -a, 0., 40/81. );
+ add( 0., -a, 40/81. );
+ add( a, 0., 40/81. );
+ add( 0., a, 40/81. );
+ add( 0., 0., 64/81. ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for QUAD, variant 1: "
+ <<nbGauss);
+ }
+ }
+ else if ( variant == 3 ) {
+ if (geom == eQUAD4) setRefCoords( TQuad4b() );
+ else setRefCoords( TQuad8b() );
+ switch ( nbGauss ) {
+ case 4: {
+ const double a = 3/sqrt(3.);
+ add( -a, -a, 1 );
+ add( -a, a, 1 );
+ add( a, -a, 1 );
+ add( a, a, 1 ); break;
+ }
+ case 9: {
+ const double a = sqrt(3/5.), c1 = 5/9., c2 = 8/9.;
+ const double c12 = c1*c2, c22 = c2*c2, c1c2 = c1*c2;
+ add( -a, -a, c12 );
+ add( -a, 0., c1c2 );
+ add( -a, a, c12 );
+ add( 0., -a, c1c2 );
+ add( 0., 0., c22 );
+ add( 0., a, c1c2 );
+ add( a, -a, c12 );
+ add( a, 0., c1c2 );
+ add( a, a, c12 ); break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for QUAD, variant 3: "
+ <<nbGauss);
+ }
+ }
+ break;
+
+ case eTETRA4:
+ case eTETRA10:
+ if (geom == eTETRA4) setRefCoords( TTetra4a() );
+ else setRefCoords( TTetra10a() );
+ switch ( nbGauss ) {
+ case 4: { // FPG4
+ const double a = (5 - sqrt(5.))/20., b = (5 + 3*sqrt(5.))/20.;
+ add( a, a, a, 1/24. );
+ add( a, a, b, 1/24. );
+ add( a, b, a, 1/24. );
+ add( b, a, a, 1/24. ); break;
+ }
+ case 5: { // FPG5
+ const double a = 0.25, b = 1/6., c = 0.5;
+ add( a, a, a, -2/15. );
+ add( b, b, b, 3/40. );
+ add( b, b, c, 3/40. );
+ add( b, c, b, 3/40. );
+ add( c, b, b, 3/40. ); break;
+ }
+ case 15: { // FPG15
+ const double a = 0.25;
+ const double b1 = (7 + sqrt(15.))/34., c1 = (13 + 3*sqrt(15.))/34., d = (5 - sqrt(15.))/20.;
+ const double b2 = (7 - sqrt(15.))/34., c2 = (13 - 3*sqrt(15.))/34., e = (5 + sqrt(15.))/20.;
+ const double P1 = (2665 - 14*sqrt(15.))/226800.;
+ const double P2 = (2665 + 14*sqrt(15.))/226800.;
+ add( a, a, a, 8/405.);//_____
+ add( b1, b1, b1, P1 );
+ add( b1, b1, c1, P1 );
+ add( b1, c1, b1, P1 );
+ add( c1, b1, b1, P1 );//_____
+ add( b2, b2, b2, P2 );
+ add( b2, b2, c2, P2 );
+ add( b2, c2, b2, P2 );
+ add( c2, b2, b2, P2 );//_____
+ add( d, d, e, 5/567.);
+ add( d, e, d, 5/567.);
+ add( e, d, d, 5/567.);
+ add( d, e, e, 5/567.);
+ add( e, d, e, 5/567.);
+ add( e, e, d, 5/567.);
+ break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for TETRA: "<<nbGauss);
+ }
+ break;
+
+ case ePYRA5:
+ case ePYRA13:
+ if (geom == ePYRA5) setRefCoords( TPyra5a() );
+ else setRefCoords( TPyra13a() );
+ switch ( nbGauss ) {
+ case 5: { // FPG5
+ const double h1 = 0.1531754163448146;
+ const double h2 = 0.6372983346207416;
+ add( .5, 0., h1, 2/15. );
+ add( 0., .5, h1, 2/15. );
+ add( -.5, 0., h1, 2/15. );
+ add( 0., -.5, h1, 2/15. );
+ add( 0., 0., h2, 2/15. ); break;
+ }
+ case 6: { // FPG6
+ const double p1 = 0.1024890634400000 ;
+ const double p2 = 0.1100000000000000 ;
+ const double p3 = 0.1467104129066667 ;
+ const double a = 0.5702963741068025 ;
+ const double h1 = 0.1666666666666666 ;
+ const double h2 = 0.08063183038464675;
+ const double h3 = 0.6098484849057127 ;
+ add( a, 0., h1, p1 );
+ add( 0., a, h1, p1 );
+ add( -a, 0., h1, p1 );
+ add( 0., -a, h1, p1 );
+ add( 0., 0., h2, p2 );
+ add( 0., 0., h3, p3 ); break;
+ }
+ case 27: { // FPG27
+ const double a1 = 0.788073483;
+ const double b6 = 0.499369002;
+ const double b1 = 0.848418011;
+ const double c8 = 0.478508449;
+ const double c1 = 0.652816472;
+ const double d12 = 0.032303742;
+ const double d1 = 1.106412899;
+ double z = 1/2., fz = b1/2*(1 - z);
+ add( 0., 0., z, a1 ); // 1
+ add( fz, fz, z, b6 ); // 2
+ add( -fz, fz, z, b6 ); // 3
+ add( -fz, -fz, z, b6 ); // 4
+ add( fz, -fz, z, b6 ); // 5
+ z = (1 - b1)/2.;
+ add( 0., 0., z, b6 ); // 6
+ z = (1 + b1)/2.;
+ add( 0., 0., z, b6 ); // 7
+ z = (1 - c1)/2.; fz = c1*(1 - z);
+ add( fz, 0., z, c8 ); // 8
+ add( 0., fz, z, c8 ); // 9
+ add( -fz, 0., z, c8 ); // 10
+ add( 0., -fz, z, c8 ); // 11
+ z = (1 + c1)/2.; fz = c1*(1 - z);
+ add( fz, 0., z, c8 ); // 12
+ add( 0., fz, z, c8 ); // 13
+ add( -fz, 0., z, c8 ); // 14
+ add( 0., -fz, z, c8 ); // 15
+ z = (1 - d1)/2., fz = d1/2*(1 - z);
+ add( fz, fz, z, d12); // 16
+ add( -fz, fz, z, d12); // 17
+ add( -fz, -fz, z, d12); // 18
+ add( fz, -fz, z, d12); // 19
+ z = 1/2.; fz = d1*(1 - z);
+ add( fz, 0., z, d12); // 20
+ add( 0., fz, z, d12); // 21
+ add( -fz, 0., z, d12); // 22
+ add( 0., -fz, z, d12); // 23
+ z = (1 + d1)/2., fz = d1/2*(1 - z);
+ add( fz, fz, z, d12); // 24
+ add( -fz, fz, z, d12); // 25
+ add( -fz, -fz, z, d12); // 26
+ add( fz, -fz, z, d12); // 27
+ break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for PYRA: "<<nbGauss);
+ }
+ break;
+ case ePENTA6:
+ case ePENTA15:
+ if (geom == ePENTA6) setRefCoords( TPenta6a() );
+ else setRefCoords( TPenta15a() );
+ switch ( nbGauss ) {
+ case 6: { // FPG6
+ const double a = sqrt(3.)/3.;
+ add( -a, .5, .5, 1/6. );
+ add( -a, 0., .5, 1/6. );
+ add( -a, .5, 0., 1/6. );
+ add( a, .5, .5, 1/6. );
+ add( a, 0., .5, 1/6. );
+ add( a, .5, 0., 1/6. ); break;
+ }
+ case 8: { // FPG8
+ const double a = 0.577350269189626;
+ add( -a, 1/3., 1/3., -27/96. );
+ add( -a, 0.6, 0.2, 25/96. );
+ add( -a, 0.2, 0.6, 25/96. );
+ add( -a, 0.2, 0.2, 25/96. );
+ add( +a, 1/3., 1/3., -27/96. );
+ add( +a, 0.6, 0.2, 25/96. );
+ add( +a, 0.2, 0.6, 25/96. );
+ add( +a, 0.2, 0.2, 25/96. ); break;
+ }
+ case 21: { // FPG21
+ const double d = sqrt(3/5.), c1 = 5/9., c2 = 8/9.; // d <=> alfa
+ const double a = (6 + sqrt(15.))/21.;
+ const double b = (6 - sqrt(15.))/21.;
+ const double P1 = (155 + sqrt(15.))/2400.;
+ const double P2 = (155 - sqrt(15.))/2400.; //___
+ add( -d, 1/3., 1/3., c1*9/80. );//___
+ add( -d, a, a, c1*P1 );
+ add( -d, 1-2*a, a, c1*P1 );
+ add( -d, a, 1-2*a, c1*P1 );//___
+ add( -d, b, b, c1*P2 );
+ add( -d, 1-2*b, b, c1*P2 );
+ add( -d, b, 1-2*b, c1*P2 );//___
+ add( 0., 1/3., 1/3., c2*9/80. );//___
+ add( 0., a, a, c2*P1 );
+ add( 0., 1-2*a, a, c2*P1 );
+ add( 0., a, 1-2*a, c2*P1 );//___
+ add( 0., b, b, c2*P2 );
+ add( 0., 1-2*b, b, c2*P2 );
+ add( 0., b, 1-2*b, c2*P2 );//___
+ add( d, 1/3., 1/3., c1*9/80. );//___
+ add( d, a, a, c1*P1 );
+ add( d, 1-2*a, a, c1*P1 );
+ add( d, a, 1-2*a, c1*P1 );//___
+ add( d, b, b, c1*P2 );
+ add( d, 1-2*b, b, c1*P2 );
+ add( d, b, 1-2*b, c1*P2 );//___
+ break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for PENTA: " <<nbGauss);
+ }
+ break;
+
+ case eHEXA8:
+ case eHEXA20:
+ if (geom == eHEXA8) setRefCoords( THexa8a() );
+ else setRefCoords( THexa20a() );
+ switch ( nbGauss ) {
+ case 8: { // FPG8
+ const double a = sqrt(3.)/3.;
+ add( -a, -a, -a, 1. );
+ add( -a, -a, a, 1. );
+ add( -a, a, -a, 1. );
+ add( -a, a, a, 1. );
+ add( a, -a, -a, 1. );
+ add( a, -a, a, 1. );
+ add( a, a, -a, 1. );
+ add( a, a, a, 1. ); break;
+ }
+ case 27: { // FPG27
+ const double a = sqrt(3/5.), c1 = 5/9., c2 = 8/9.;
+ const double c12 = c1*c1, c13 = c1*c1*c1;
+ const double c22 = c2*c2, c23 = c2*c2*c2;
+ add( -a, -a, -a, c13 ); // 1
+ add( -a, -a, 0., c12*c2 ); // 2
+ add( -a, -a, a, c13 ); // 3
+ add( -a, 0., -a, c12*c2 ); // 4
+ add( -a, 0., 0., c1*c22 ); // 5
+ add( -a, 0., a, c12*c2 ); // 6
+ add( -a, a, -a, c13 ); // 7
+ add( -a, a, 0., c12*c2 ); // 8
+ add( -a, a, a, c13 ); // 9
+ add( 0., -a, -a, c12*c2 ); // 10
+ add( 0., -a, 0., c1*c22 ); // 11
+ add( 0., -a, a, c12*c2 ); // 12
+ add( 0., 0., -a, c1*c22 ); // 13
+ add( 0., 0., 0., c23 ); // 14
+ add( 0., 0., a, c1*c22 ); // 15
+ add( 0., a, -a, c12*c2 ); // 16
+ add( 0., a, 0., c1*c22 ); // 17
+ add( 0., a, a, c12*c2 ); // 18
+ add( a, -a, -a, c13 ); // 19
+ add( a, -a, 0., c12*c2 ); // 20
+ add( a, -a, a, c13 ); // 21
+ add( a, 0., -a, c12*c2 ); // 22
+ add( a, 0., 0., c1*c22 ); // 23
+ add( a, 0., a, c12*c2 ); // 24
+ add( a, a, -a, c13 ); // 25
+ add( a, a, 0., c12*c2 ); // 26
+ add( a, a, a, c13 ); // 27
+ break;
+ }
+ default:
+ EXCEPTION( std::logic_error,"Invalid nb of gauss points for PENTA: " <<nbGauss);
+ }
+ break;
+
+ default:
+ EXCEPTION( std::logic_error,"unexpected EGeometrieElement: "<< geom);
+ }
+
+ if ( myWeights.capacity() != myWeights.size() )
+ EXCEPTION( std::logic_error,"Not all gauss points defined");
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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
+//
+
+#ifndef MED_GaussDef_HeaderFile
+#define MED_GaussDef_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+
+#include <vector>
+
+namespace MED
+{
+ class TShapeFun;
+ typedef std::vector<double> TDoubleVector;
+
+ /*!
+ * \brief Description of family of integration points
+ */
+ struct TGaussDef
+ {
+ int myType; //!< element geometry (EGeometrieElement or med_geometrie_element)
+ TDoubleVector myRefCoords; //!< description of reference points
+ TDoubleVector myCoords; //!< coordinates of Gauss points
+ TDoubleVector myWeights; //!< weights, len(weights)==<nb of gauss points>
+
+ /*!
+ * \brief Creates definition of gauss points family
+ * \param geomType - element geometry (EGeometrieElement or med_geometrie_element)
+ * \param nbPoints - nb gauss point
+ * \param variant - [1-3] to choose the variant of definition
+ *
+ * Throws in case of invalid parameters
+ * variant == 1 refers to "Fonctions de forme et points d'integration
+ * des elements finis" v7.4 by J. PELLET, X. DESROCHES, 15/09/05
+ * variant == 2 refers to the same doc v6.4 by J.P. LEFEBVRE, X. DESROCHES, 03/07/03
+ * variant == 3 refers to the same doc v6.4, second variant for 2D elements
+ */
+ MEDWRAPPER_EXPORT TGaussDef(const int geomType, const int nbPoints, const int variant=1);
+
+ MEDWRAPPER_EXPORT int dim() const { return myType/100; }
+ MEDWRAPPER_EXPORT int nbPoints() const { return myWeights.capacity(); }
+
+ private:
+ void add(const double x, const double weight);
+ void add(const double x, const double y, const double weight);
+ void add(const double x, const double y, const double z, const double weight);
+ void setRefCoords(const TShapeFun& aShapeFun);
+ };
+}
+
+#endif // MED_GaussDef_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_GaussUtils.hxx"
+#include "MED_Utilities.hxx"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ TGaussCoord
+ ::TGaussCoord():
+ TModeSwitchInfo(eFULL_INTERLACE),
+ myNbElem(0),
+ myNbGauss(0),
+ myDim(0),
+ myGaussStep(0)
+ {
+ }
+
+ void
+ TGaussCoord
+ ::Init(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theDim,
+ EModeSwitch theMode)
+ {
+ myModeSwitch = theMode;
+
+ myNbElem = theNbElem;
+ myNbGauss = theNbGauss;
+ myDim = theDim;
+
+ myGaussStep = myNbGauss*myDim;
+
+ myGaussCoord.resize(theNbElem*myGaussStep);
+ }
+
+ TInt
+ TGaussCoord
+ ::GetNbElem() const
+ {
+ return myNbElem;
+ }
+
+ TInt
+ TGaussCoord
+ ::GetNbGauss() const
+ {
+ return myNbGauss;
+ }
+
+ TInt
+ TGaussCoord
+ ::GetDim() const
+ {
+ return myDim;
+ }
+
+ unsigned char*
+ TGaussCoord
+ ::GetValuePtr()
+ {
+ return (unsigned char*)&(myGaussCoord[0]);
+ }
+
+ TCCoordSliceArr
+ TGaussCoord
+ ::GetCoordSliceArr(TInt theElemId) const
+ {
+ TCCoordSliceArr aCoordSliceArr(myNbGauss);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId*myGaussStep;
+ for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
+ aCoordSliceArr[anGaussId] =
+ TCCoordSlice(myGaussCoord,std::slice(anId,myDim,1));
+ anId += myDim;
+ }
+ }
+ else{
+ for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
+ aCoordSliceArr[anGaussId] =
+ TCCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep));
+ }
+ }
+ return aCoordSliceArr;
+ }
+
+ TCoordSliceArr
+ TGaussCoord
+ ::GetCoordSliceArr(TInt theElemId)
+ {
+ TCoordSliceArr aCoordSliceArr(myNbGauss);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId*myGaussStep;
+ for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
+ aCoordSliceArr[anGaussId] =
+ TCoordSlice(myGaussCoord,std::slice(anId,myDim,1));
+ anId += myDim;
+ }
+ }
+ else{
+ for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){
+ aCoordSliceArr[anGaussId] =
+ TCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep));
+ }
+ }
+ return aCoordSliceArr;
+ }
+
+ //---------------------------------------------------------------
+ inline
+ bool
+ IsEqual(TFloat theLeft, TFloat theRight)
+ {
+ static TFloat EPS = 1.0E-3;
+ if(fabs(theLeft) + fabs(theRight) > EPS)
+ return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS;
+ return true;
+ }
+
+ //---------------------------------------------------------------
+ class TShapeFun::TFun
+ {
+ TFloatVector myFun;
+ TInt myNbRef;
+
+ public:
+
+ void
+ Init(TInt theNbGauss,
+ TInt theNbRef)
+ {
+ myFun.resize(theNbGauss*theNbRef);
+ myNbRef = theNbRef;
+ }
+
+ TCFloatVecSlice
+ GetFunSlice(TInt theGaussId) const
+ {
+ return TCFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1));
+ }
+
+ TFloatVecSlice
+ GetFunSlice(TInt theGaussId)
+ {
+ return TFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1));
+ }
+ };
+
+ //---------------------------------------------------------------
+
+ TShapeFun::TShapeFun(TInt theDim, TInt theNbRef):
+ myRefCoord(theNbRef*theDim),
+ myDim(theDim),
+ myNbRef(theNbRef)
+ {}
+
+ TCCoordSlice
+ TShapeFun::GetCoord(TInt theRefId) const
+ {
+ return TCCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1));
+ }
+
+ TCoordSlice
+ TShapeFun::GetCoord(TInt theRefId)
+ {
+ return TCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1));
+ }
+
+ void
+ TShapeFun::GetFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ TInt aNbRef = theRef.size();
+ TInt aNbGauss = theGauss.size();
+ theFun.Init(aNbGauss,aNbRef);
+ }
+
+ bool
+ TShapeFun::IsSatisfy(const TCCoordSliceArr& theRefCoord) const
+ {
+ TInt aNbRef = theRefCoord.size();
+ TInt aNbRef2 = GetNbRef();
+ INITMSG(MYDEBUG,"TShapeFun::IsSatisfy "<<
+ "- aNbRef("<<aNbRef<<")"<<
+ "; aNbRef2("<<aNbRef2<<")\n");
+ bool anIsSatisfy = (aNbRef == aNbRef2);
+ if(anIsSatisfy){
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ const TCCoordSlice& aCoord2 = theRefCoord[aRefId];
+ TCCoordSlice aCoord = GetCoord(aRefId);
+ TInt aDim = aCoord.size();
+ bool anIsEqual = false;
+ for(TInt anId = 0; anId < aDim; anId++){
+ anIsEqual = IsEqual(aCoord[anId],aCoord2[anId]);
+ if(!anIsEqual){
+ anIsSatisfy = false;
+ break;
+ }
+ }
+ if(!anIsEqual){
+#ifdef _DEBUG_
+ TCCoordSlice aCoord = GetCoord(aRefId);
+ INITMSG(MYDEBUG,aRefId + 1<<": aCoord = {");
+ TInt aDim = aCoord.size();
+ for(TInt anId = 0; anId < aDim; anId++)
+ ADDMSG(MYDEBUG,"\t"<<aCoord[anId]);
+ const TCCoordSlice& aCoord2 = theRefCoord[aRefId];
+ ADDMSG(MYDEBUG,"}\t!=\taCoord2 = {");
+ for(TInt anId = 0; anId < aDim; anId++)
+ ADDMSG(MYDEBUG,"\t"<<aCoord2[anId]);
+ ADDMSG(MYDEBUG,"}\n");
+#endif
+#ifndef _DEBUG_
+ BEGMSG(MYDEBUG,"anIsSatisfy = "<<anIsSatisfy<<"\n");
+ return anIsSatisfy;
+#endif
+ }
+ }
+ }
+
+ BEGMSG(MYDEBUG,"anIsSatisfy = "<<anIsSatisfy<<"\n");
+ return anIsSatisfy;
+ }
+
+ bool
+ TShapeFun::Eval(const TCellInfo& theCellInfo,
+ const TNodeInfo& theNodeInfo,
+ const TElemNum& theElemNum,
+ const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TGaussCoord& theGaussCoord,
+ EModeSwitch theMode)
+ {
+ INITMSG(MYDEBUG,"TShapeFun::Eval"<<std::endl);
+
+ if(IsSatisfy(theRef)){
+ const PMeshInfo& aMeshInfo = theCellInfo.GetMeshInfo();
+ TInt aDim = aMeshInfo->GetDim();
+ TInt aNbGauss = theGauss.size();
+
+ bool anIsSubMesh = !theElemNum.empty();
+ TInt aNbElem;
+ if(anIsSubMesh)
+ aNbElem = theElemNum.size();
+ else
+ aNbElem = theCellInfo.GetNbElem();
+
+ theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
+
+ TFun aFun;
+ InitFun(theRef,theGauss,aFun);
+ TInt aConnDim = theCellInfo.GetConnDim();
+
+ INITMSG(MYDEBUG,"aDim = "<<aDim<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
+ std::endl);
+
+ for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
+ TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
+ TCConnSlice aConnSlice = theCellInfo.GetConnSlice(aCellId);
+ TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
+
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
+ TCFloatVecSlice aFunSlice = aFun.GetFunSlice(aGaussId);
+
+ for(TInt aConnId = 0; aConnId < aConnDim; aConnId++){
+ TInt aNodeId = aConnSlice[aConnId] - 1;
+ TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
+
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId]*aFunSlice[aConnId];
+ }
+ }
+ }
+ }
+
+#ifdef _DEBUG_
+ {
+ INITMSG(MYVALUEDEBUG,"theGauss: ");
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCCoordSlice aCoordSlice = theGauss[aGaussId];
+ ADDMSG(MYVALUEDEBUG,"{");
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ ADDMSG(MYVALUEDEBUG,aCoordSlice[aDimId]<<" ");
+ }
+ ADDMSG(MYVALUEDEBUG,"} ");
+ }
+ ADDMSG(MYVALUEDEBUG,std::endl);
+ }
+ for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
+ TCCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
+ INITMSG(MYVALUEDEBUG,"");
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
+ ADDMSG(MYVALUEDEBUG,"{");
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ ADDMSG(MYVALUEDEBUG,aCoordSlice[aDimId]<<" ");
+ }
+ ADDMSG(MYVALUEDEBUG,"} ");
+ }
+ ADDMSG(MYVALUEDEBUG,std::endl);
+ }
+#endif
+ return true;
+ }
+
+ return false;
+ }
+
+ //---------------------------------------------------------------
+ TSeg2a::TSeg2a():TShapeFun(1,2)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; break;
+ case 1: aCoord[0] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TSeg2a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*(1.0 - aCoord[0]);
+ aSlice[1] = 0.5*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TSeg3a::TSeg3a():TShapeFun(1,3)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; break;
+ case 1: aCoord[0] = 1.0; break;
+ case 2: aCoord[0] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TSeg3a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*(1.0 - aCoord[0])*aCoord[0];
+ aSlice[1] = 0.5*(1.0 + aCoord[0])*aCoord[0];
+ aSlice[2] = (1.0 + aCoord[0])*(1.0 - aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTria3a::TTria3a():
+ TShapeFun(2,3)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ }
+ }
+ }
+
+ void
+ TTria3a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*(1.0 + aCoord[1]);
+ aSlice[1] = -0.5*(aCoord[0] + aCoord[1]);
+ aSlice[2] = 0.5*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTria6a::TTria6a():TShapeFun(2,6)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+
+ case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
+ case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TTria6a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*(1.0 + aCoord[1])*aCoord[1];
+ aSlice[1] = 0.5*(aCoord[0] + aCoord[1])*(aCoord[0] + aCoord[1] + 1);
+ aSlice[2] = 0.5*(1.0 + aCoord[0])*aCoord[0];
+
+ aSlice[3] = -1.0*(1.0 + aCoord[1])*(aCoord[0] + aCoord[1]);
+ aSlice[4] = -1.0*(1.0 + aCoord[0])*(aCoord[0] + aCoord[1]);
+ aSlice[5] = (1.0 + aCoord[1])*(1.0 + aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTria3b::TTria3b():
+ TShapeFun(2,3)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
+ case 2: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TTria3b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 1.0 - aCoord[0] - aCoord[1];
+ aSlice[1] = aCoord[0];
+ aSlice[2] = aCoord[1];
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTria6b::TTria6b():
+ TShapeFun(2,6)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
+ case 2: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
+
+ case 3: aCoord[0] = 0.5; aCoord[1] = 0.0; break;
+ case 4: aCoord[0] = 0.5; aCoord[1] = 0.5; break;
+ case 5: aCoord[0] = 0.0; aCoord[1] = 0.5; break;
+ }
+ }
+ }
+
+ void
+ TTria6b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = (1.0 - aCoord[0] - aCoord[1])*(1.0 - 2.0*aCoord[0] - 2.0*aCoord[1]);
+ aSlice[1] = aCoord[0]*(2.0*aCoord[0] - 1.0);
+ aSlice[2] = aCoord[1]*(2.0*aCoord[1] - 1.0);
+
+ aSlice[3] = 4.0*aCoord[0]*(1.0 - aCoord[0] - aCoord[1]);
+ aSlice[4] = 4.0*aCoord[0]*aCoord[1];
+ aSlice[5] = 4.0*aCoord[1]*(1.0 - aCoord[0] - aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TQuad4a::TQuad4a():
+ TShapeFun(2,4)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TQuad4a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.25*(1.0 + aCoord[1])*(1.0 - aCoord[0]);
+ aSlice[1] = 0.25*(1.0 - aCoord[1])*(1.0 - aCoord[0]);
+ aSlice[2] = 0.25*(1.0 - aCoord[1])*(1.0 + aCoord[0]);
+ aSlice[3] = 0.25*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TQuad8a::TQuad8a():
+ TShapeFun(2,8)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
+
+ case 4: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
+ case 5: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
+ case 6: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
+ case 7: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TQuad8a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.25*(1.0 + aCoord[1])*(1.0 - aCoord[0])*(aCoord[1] - aCoord[0] - 1.0);
+ aSlice[1] = 0.25*(1.0 - aCoord[1])*(1.0 - aCoord[0])*(-aCoord[1] - aCoord[0] - 1.0);
+ aSlice[2] = 0.25*(1.0 - aCoord[1])*(1.0 + aCoord[0])*(-aCoord[1] + aCoord[0] - 1.0);
+ aSlice[3] = 0.25*(1.0 + aCoord[1])*(1.0 + aCoord[0])*(aCoord[1] + aCoord[0] - 1.0);
+
+ aSlice[4] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[1]);
+ aSlice[5] = 0.5*(1.0 - aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[0]);
+ aSlice[6] = 0.5*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[1]);
+ aSlice[7] = 0.5*(1.0 + aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TQuad9a::TQuad9a():
+ TShapeFun(2,9)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
+
+ case 4: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
+ case 5: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
+ case 6: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
+ case 7: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
+
+ case 8: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TQuad9a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] - 1.0);
+ aSlice[1] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] + 1.0);
+ aSlice[2] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] + 1.0);
+ aSlice[3] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] - 1.0);
+
+ aSlice[4] = 0.5*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1]);
+ aSlice[5] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0);
+ aSlice[6] = 0.5*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1]);
+ aSlice[7] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0);
+
+ aSlice[8] = (1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TQuad4b::TQuad4b():
+ TShapeFun(2,4)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
+ case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TQuad4b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.25*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[1] = 0.25*(1.0 + aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[2] = 0.25*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
+ aSlice[3] = 0.25*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TQuad8b::TQuad8b():
+ TShapeFun(2,8)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
+ case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+
+ case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
+ case 6: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
+ case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TQuad8b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.25*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(-1.0 - aCoord[0] - aCoord[1]);
+ aSlice[1] = 0.25*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(-1.0 + aCoord[0] - aCoord[1]);
+ aSlice[2] = 0.25*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(-1.0 + aCoord[0] + aCoord[1]);
+ aSlice[3] = 0.25*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(-1.0 - aCoord[0] + aCoord[1]);
+
+ aSlice[4] = 0.5*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[5] = 0.5*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0]);
+ aSlice[6] = 0.5*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1]);
+ aSlice[7] = 0.5*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0]);
+
+ //aSlice[4] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
+ //aSlice[5] = 0.5*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[1]);
+ //aSlice[6] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
+ //aSlice[7] = 0.5*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TQuad9b::TQuad9b():
+ TShapeFun(2,9)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; break;
+ case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; break;
+
+ case 4: aCoord[0] = 0.0; aCoord[1] = -1.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; break;
+ case 6: aCoord[0] = 0.0; aCoord[1] = 1.0; break;
+ case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; break;
+
+ case 8: aCoord[0] = 0.0; aCoord[1] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TQuad9b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] - 1.0);
+ aSlice[1] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] - 1.0);
+ aSlice[2] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] + 1.0)*(aCoord[1] + 1.0);
+ aSlice[3] = 0.25*aCoord[0]*aCoord[1]*(aCoord[0] - 1.0)*(aCoord[1] + 1.0);
+
+ aSlice[4] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0);
+ aSlice[5] = 0.5*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1]);
+ aSlice[6] = 0.5*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0);
+ aSlice[7] = 0.5*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1]);
+
+ aSlice[8] = (1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTetra4a::TTetra4a():
+ TShapeFun(3,4)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TTetra4a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = aCoord[1];
+ aSlice[1] = aCoord[2];
+ aSlice[2] = 1.0 - aCoord[0] - aCoord[1] - aCoord[2];
+ aSlice[3] = aCoord[0];
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTetra10a::TTetra10a():
+ TShapeFun(3,10)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+
+ case 4: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 6: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+
+ case 7: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 8: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TTetra10a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = aCoord[1]*(2.0*aCoord[1] - 1.0);
+ aSlice[1] = aCoord[2]*(2.0*aCoord[2] - 1.0);
+ aSlice[2] = (1.0 - aCoord[0] - aCoord[1] - aCoord[2])*(1.0 - 2.0*aCoord[0] - 2.0*aCoord[1] - 2.0*aCoord[2]);
+ aSlice[3] = aCoord[0]*(2.0*aCoord[0] - 1.0);
+
+ aSlice[4] = 4.0*aCoord[1]*aCoord[2];
+ aSlice[5] = 4.0*aCoord[2]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+ aSlice[6] = 4.0*aCoord[1]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+
+ aSlice[7] = 4.0*aCoord[0]*aCoord[1];
+ aSlice[8] = 4.0*aCoord[0]*aCoord[2];
+ aSlice[9] = 4.0*aCoord[0]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+
+ TTetra4b::TTetra4b():
+ TShapeFun(3,4)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TTetra4b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = aCoord[1];
+ aSlice[2] = aCoord[2];
+ aSlice[1] = 1.0 - aCoord[0] - aCoord[1] - aCoord[2];
+ aSlice[3] = aCoord[0];
+ }
+ }
+
+ //---------------------------------------------------------------
+ TTetra10b::TTetra10b():
+ TShapeFun(3,10)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+
+ case 6: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 5: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 4: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+
+ case 7: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 8: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TTetra10b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = aCoord[1]*(2.0*aCoord[1] - 1.0);
+ aSlice[2] = aCoord[2]*(2.0*aCoord[2] - 1.0);
+ aSlice[1] = (1.0 - aCoord[0] - aCoord[1] - aCoord[2])*(1.0 - 2.0*aCoord[0] - 2.0*aCoord[1] - 2.0*aCoord[2]);
+ aSlice[3] = aCoord[0]*(2.0*aCoord[0] - 1.0);
+
+ aSlice[6] = 4.0*aCoord[1]*aCoord[2];
+ aSlice[5] = 4.0*aCoord[2]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+ aSlice[4] = 4.0*aCoord[1]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+
+ aSlice[7] = 4.0*aCoord[0]*aCoord[1];
+ aSlice[9] = 4.0*aCoord[0]*aCoord[2];
+ aSlice[8] = 4.0*aCoord[0]*(1.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ THexa8a::THexa8a():
+ TShapeFun(3,8)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ case 7: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ THexa8a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[1] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[3] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
+
+ aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[5] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[7] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ THexa20a::THexa20a(TInt theDim, TInt theNbRef):
+ TShapeFun(theDim,theNbRef)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 1: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 3: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ case 7: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+
+ case 8: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 9: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
+ case 10: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 11: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
+ case 12: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 13: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 14: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 15: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 16: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 17: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 18: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ case 19: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ THexa20a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+ aSlice[1] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 + aCoord[0] - aCoord[1] - aCoord[2]);
+ aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 + aCoord[0] + aCoord[1] - aCoord[2]);
+ aSlice[3] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 - aCoord[0] + aCoord[1] - aCoord[2]);
+ aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 - aCoord[0] - aCoord[1] + aCoord[2]);
+ aSlice[5] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 + aCoord[0] - aCoord[1] + aCoord[2]);
+ aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 + aCoord[0] + aCoord[1] + aCoord[2]);
+ aSlice[7] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 - aCoord[0] + aCoord[1] + aCoord[2]);
+
+ aSlice[8] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[9] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 - aCoord[2]);
+ aSlice[10] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[11] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 - aCoord[2]);
+ aSlice[12] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[13] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[14] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
+ aSlice[15] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
+ aSlice[16] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[17] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 + aCoord[2]);
+ aSlice[18] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[19] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ THexa27a::THexa27a():
+ THexa20a(3,27)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 20: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
+ case 21: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 22: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 23: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 24: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 25: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 26: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ THexa27a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.125*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[1] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[2] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[3] = 0.125*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[4] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[5] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[6] = 0.125*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[7] = 0.125*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] + 1.0);
+
+ aSlice[8] = 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[9] = 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[10]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[11]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[12]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] - 1.0)*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[13]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] - 1.0)*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[14]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*aCoord[1]*(aCoord[1] + 1.0)*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[15]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*aCoord[1]*(aCoord[1] + 1.0)*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[16]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0)*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[17]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[18]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0)*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[19]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[20]= 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] - 1.0);
+ aSlice[21]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] - 1.0)*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[22]= 0.25*aCoord[0]*(aCoord[0] + 1.0)*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[23]= 0.25*(1.0 - aCoord[0]*aCoord[0])*aCoord[1]*(aCoord[1] + 1.0)*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[24]= 0.25*aCoord[0]*(aCoord[0] - 1.0)*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[2]*aCoord[2]);
+ aSlice[25]= 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1])*aCoord[2]*(aCoord[2] + 1.0);
+ aSlice[26]= 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[1]*aCoord[1]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ THexa8b::THexa8b():
+ TShapeFun(3,8)
+ {
+ TInt aNbRef = GetNbRef();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 7: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ case 5: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ THexa8b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[3] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[1] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
+
+ aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[7] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[5] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ THexa20b::THexa20b(TInt theDim, TInt theNbRef):
+ TShapeFun(theDim,theNbRef)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 2: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 4: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 7: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 6: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ case 5: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+
+ case 11: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = -1.0; break;
+ case 10: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
+ case 9: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = -1.0; break;
+ case 8: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = -1.0; break;
+ case 16: aCoord[0] = -1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 19: aCoord[0] = 1.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 18: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 17: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 15: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 1.0; break;
+ case 14: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 13: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 1.0; break;
+ case 12: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ THexa20b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 - aCoord[0] - aCoord[1] - aCoord[2]);
+ aSlice[3] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 + aCoord[0] - aCoord[1] - aCoord[2]);
+ aSlice[2] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 + aCoord[0] + aCoord[1] - aCoord[2]);
+ aSlice[1] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2])*
+ (-2.0 - aCoord[0] + aCoord[1] - aCoord[2]);
+ aSlice[4] = 0.125*(1.0 - aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 - aCoord[0] - aCoord[1] + aCoord[2]);
+ aSlice[7] = 0.125*(1.0 + aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 + aCoord[0] - aCoord[1] + aCoord[2]);
+ aSlice[6] = 0.125*(1.0 + aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 + aCoord[0] + aCoord[1] + aCoord[2]);
+ aSlice[5] = 0.125*(1.0 - aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2])*
+ (-2.0 - aCoord[0] + aCoord[1] + aCoord[2]);
+
+ aSlice[11] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[10] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 - aCoord[2]);
+ aSlice[9] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 - aCoord[2]);
+ aSlice[8] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 - aCoord[2]);
+ aSlice[16] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[19] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 - aCoord[1]);
+ aSlice[18] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 + aCoord[0])*(1.0 + aCoord[1]);
+ aSlice[17] = 0.25*(1.0 - aCoord[2]*aCoord[2])*(1.0 - aCoord[0])*(1.0 + aCoord[1]);
+ aSlice[15] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 - aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[14] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 + aCoord[0])*(1.0 + aCoord[2]);
+ aSlice[13] = 0.25*(1.0 - aCoord[0]*aCoord[0])*(1.0 + aCoord[1])*(1.0 + aCoord[2]);
+ aSlice[12] = 0.25*(1.0 - aCoord[1]*aCoord[1])*(1.0 - aCoord[0])*(1.0 + aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPenta6a::TPenta6a():
+ TShapeFun(3,6)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TPenta6a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0]);
+ aSlice[1] = 0.5*aCoord[2]*(1.0 - aCoord[0]);
+ aSlice[2] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
+
+ aSlice[3] = 0.5*aCoord[1]*(aCoord[0] + 1.0);
+ aSlice[4] = 0.5*aCoord[2]*(aCoord[0] + 1.0);
+ aSlice[5] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPenta6b::TPenta6b():
+ TShapeFun(3,6)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TPenta6b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0]);
+ aSlice[2] = 0.5*aCoord[2]*(1.0 - aCoord[0]);
+ aSlice[1] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
+
+ aSlice[3] = 0.5*aCoord[1]*(aCoord[0] + 1.0);
+ aSlice[5] = 0.5*aCoord[2]*(aCoord[0] + 1.0);
+ aSlice[4] = 0.5*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPenta15a::TPenta15a():
+ TShapeFun(3,15)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+
+ case 6: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 8: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 9: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 10: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 11: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 12: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 13: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 14: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TPenta15a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0])*(2.0*aCoord[1] - 2.0 - aCoord[0]);
+ aSlice[1] = 0.5*aCoord[2]*(1.0 - aCoord[0])*(2.0*aCoord[2] - 2.0 - aCoord[0]);
+ aSlice[2] = 0.5*(aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
+
+ aSlice[3] = 0.5*aCoord[1]*(1.0 + aCoord[0])*(2.0*aCoord[1] - 2.0 + aCoord[0]);
+ aSlice[4] = 0.5*aCoord[2]*(1.0 + aCoord[0])*(2.0*aCoord[2] - 2.0 + aCoord[0]);
+ aSlice[5] = 0.5*(-aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(-aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
+
+ aSlice[6] = 2.0*aCoord[1]*aCoord[2]*(1.0 - aCoord[0]);
+ aSlice[7] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
+ aSlice[8] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
+
+ aSlice[9] = aCoord[1]*(1.0 - aCoord[0]*aCoord[0]);
+ aSlice[10] = aCoord[2]*(1.0 - aCoord[0]*aCoord[0]);
+ aSlice[11] = (1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]*aCoord[0]);
+
+ aSlice[12] = 2.0*aCoord[1]*aCoord[2]*(1.0 + aCoord[0]);
+ aSlice[13] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
+ aSlice[14] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPenta15b::TPenta15b():
+ TShapeFun(3,15)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = -1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = -0.0; aCoord[2] = 1.0; break;
+ case 1: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 1.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 5: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 4: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+
+ case 8: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 7: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 6: aCoord[0] = -1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 12: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 14: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ case 13: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 11: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 10: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 9: aCoord[0] = 1.0; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ }
+ }
+ }
+
+ void
+ TPenta15b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*aCoord[1]*(1.0 - aCoord[0])*(2.0*aCoord[1] - 2.0 - aCoord[0]);
+ aSlice[2] = 0.5*aCoord[2]*(1.0 - aCoord[0])*(2.0*aCoord[2] - 2.0 - aCoord[0]);
+ aSlice[1] = 0.5*(aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
+
+ aSlice[3] = 0.5*aCoord[1]*(1.0 + aCoord[0])*(2.0*aCoord[1] - 2.0 + aCoord[0]);
+ aSlice[5] = 0.5*aCoord[2]*(1.0 + aCoord[0])*(2.0*aCoord[2] - 2.0 + aCoord[0]);
+ aSlice[4] = 0.5*(-aCoord[0] - 1.0)*(1.0 - aCoord[1] - aCoord[2])*(-aCoord[0] + 2.0*aCoord[1] + 2.0*aCoord[2]);
+
+ aSlice[8] = 2.0*aCoord[1]*aCoord[2]*(1.0 - aCoord[0]);
+ aSlice[7] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
+ aSlice[6] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]);
+
+ aSlice[12] = aCoord[1]*(1.0 - aCoord[0]*aCoord[0]);
+ aSlice[14] = aCoord[2]*(1.0 - aCoord[0]*aCoord[0]);
+ aSlice[13] = (1.0 - aCoord[1] - aCoord[2])*(1.0 - aCoord[0]*aCoord[0]);
+
+ aSlice[11] = 2.0*aCoord[1]*aCoord[2]*(1.0 + aCoord[0]);
+ aSlice[10] = 2.0*aCoord[2]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
+ aSlice[9] = 2.0*aCoord[1]*(1.0 - aCoord[1] - aCoord[2])*(1.0 + aCoord[0]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPyra5a::TPyra5a():
+ TShapeFun(3,5)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TPyra5a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+ // APO & RNV:
+ // Fix for 0019920: EDF 788 VISU: Bad localisation of gauss points for pyramids
+ // Seems shape function for ePYRA5 elements is:
+ // w0 = 0.25*(-X + Y - 1.0)*(-X - Y - 1.0)*(1.0 - Z);
+ // w1 = 0.25*(-X - Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
+ // w2 = 0.25*(+X + Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
+ // w3 = 0.25*(+X + Y - 1.0)*(-X + Y - 1.0)*(1.0 - Z);
+ // w4 = +Z;
+ aSlice[0] = 0.25*(-aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[1] = 0.25*(-aCoord[0] - aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[2] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[3] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] + aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[4] = aCoord[2];
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPyra5b::TPyra5b():
+ TShapeFun(3,5)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+ }
+ }
+ }
+
+ void
+ TPyra5b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+ // APO & RNV:
+ // Fix for 0019920: EDF 788 VISU: Bad localisation of gauss points for pyramids
+ // Seems shape function for ePYRA5 elements is:
+ // w0 = 0.25*(-X + Y - 1.0)*(-X - Y - 1.0)*(1.0 - Z);
+ // w1 = 0.25*(-X - Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
+ // w2 = 0.25*(+X + Y - 1.0)*(+X - Y - 1.0)*(1.0 - Z);
+ // w3 = 0.25*(+X + Y - 1.0)*(-X + Y - 1.0)*(1.0 - Z);
+ // w4 = +Z;
+ aSlice[0] = 0.25*(-aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[3] = 0.25*(-aCoord[0] - aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[2] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(+aCoord[0] - aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[1] = 0.25*(+aCoord[0] + aCoord[1] - 1.0)*(-aCoord[0] + aCoord[1] - 1.0)*(1.0 - aCoord[2]);
+ aSlice[4] = aCoord[2];
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPyra13a::TPyra13a():
+ TShapeFun(3,13)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+
+ case 5: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 6: aCoord[0] = -0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 7: aCoord[0] = -0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
+ case 8: aCoord[0] = 0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
+ case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 10: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 11: aCoord[0] = -0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 12: aCoord[0] = 0.0; aCoord[1] = -0.5; aCoord[2] = 0.5; break;
+ }
+ }
+ }
+
+ void
+ TPyra13a::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[0] - 0.5)/(1.0 - aCoord[2]);
+ aSlice[1] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[1] - 0.5)/(1.0 - aCoord[2]);
+ aSlice[2] = 0.5*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[0] - 0.5)/(1.0 - aCoord[2]);
+ aSlice[3] = 0.5*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[1] - 0.5)/(1.0 - aCoord[2]);
+
+ aSlice[4] = 2.0*aCoord[2]*(aCoord[2] - 0.5);
+
+ aSlice[5] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+ aSlice[6] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+ aSlice[7] = 0.5*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+ aSlice[8] = 0.5*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+
+ aSlice[9] = 0.5*aCoord[2]*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ aSlice[10] = 0.5*aCoord[2]*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ aSlice[11] = 0.5*aCoord[2]*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ aSlice[12] = 0.5*aCoord[2]*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ TPyra13b::TPyra13b():
+ TShapeFun(3,13)
+ {
+ TInt aNbRef = myRefCoord.size();
+ for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){
+ TCoordSlice aCoord = GetCoord(aRefId);
+ switch(aRefId){
+ case 0: aCoord[0] = 1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 3: aCoord[0] = 0.0; aCoord[1] = 1.0; aCoord[2] = 0.0; break;
+ case 2: aCoord[0] = -1.0; aCoord[1] = 0.0; aCoord[2] = 0.0; break;
+ case 1: aCoord[0] = 0.0; aCoord[1] = -1.0; aCoord[2] = 0.0; break;
+ case 4: aCoord[0] = 0.0; aCoord[1] = 0.0; aCoord[2] = 1.0; break;
+
+ case 8: aCoord[0] = 0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 7: aCoord[0] = -0.5; aCoord[1] = 0.5; aCoord[2] = 0.0; break;
+ case 6: aCoord[0] = -0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
+ case 5: aCoord[0] = 0.5; aCoord[1] = -0.5; aCoord[2] = 0.0; break;
+ case 9: aCoord[0] = 0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 12: aCoord[0] = 0.0; aCoord[1] = 0.5; aCoord[2] = 0.5; break;
+ case 11: aCoord[0] = -0.5; aCoord[1] = 0.0; aCoord[2] = 0.5; break;
+ case 10: aCoord[0] = 0.0; aCoord[1] = -0.5; aCoord[2] = 0.5; break;
+ }
+ }
+ }
+
+ void
+ TPyra13b::InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const
+ {
+ GetFun(theRef,theGauss,theFun);
+
+ TInt aNbGauss = theGauss.size();
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ const TCCoordSlice& aCoord = theGauss[aGaussId];
+ TFloatVecSlice aSlice = theFun.GetFunSlice(aGaussId);
+
+ aSlice[0] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[0] - 0.5)/(1.0 - aCoord[2]);
+ aSlice[3] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[1] - 0.5)/(1.0 - aCoord[2]);
+ aSlice[2] = 0.5*(+aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[0] - 0.5)/(1.0 - aCoord[2]);
+ aSlice[1] = 0.5*(+aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[1] - 0.5)/(1.0 - aCoord[2]);
+
+ aSlice[4] = 2.0*aCoord[2]*(aCoord[2] - 0.5);
+
+ aSlice[8] = 0.5*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+ aSlice[7] = 0.5*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*
+ (aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+ aSlice[6] = 0.5*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+ aSlice[5] = 0.5*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*
+ (-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/(1.0 - aCoord[2]);
+
+ aSlice[9] = 0.5*aCoord[2]*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ aSlice[12] = 0.5*aCoord[2]*(-aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ aSlice[11] = 0.5*aCoord[2]*(aCoord[0] - aCoord[1] + aCoord[2] - 1.0)*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ aSlice[10] = 0.5*aCoord[2]*(aCoord[0] + aCoord[1] + aCoord[2] - 1.0)*(-aCoord[0] + aCoord[1] + aCoord[2] - 1.0)/
+ (1.0 - aCoord[2]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ bool
+ GetGaussCoord3D(const TGaussInfo& theGaussInfo,
+ const TCellInfo& theCellInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum,
+ EModeSwitch theMode)
+ {
+ INITMSG(MYDEBUG,"GetGaussCoord3D\n");
+
+ if(theGaussInfo.myGeom == theCellInfo.myGeom){
+ EGeometrieElement aGeom = theGaussInfo.myGeom;
+
+ TInt aNbRef = theGaussInfo.GetNbRef();
+ TCCoordSliceArr aRefSlice(aNbRef);
+ for(TInt anId = 0; anId < aNbRef; anId++)
+ aRefSlice[anId] = theGaussInfo.GetRefCoordSlice(anId);
+
+ TInt aNbGauss = theGaussInfo.GetNbGauss();
+ TCCoordSliceArr aGaussSlice(aNbGauss);
+ for(TInt anId = 0; anId < aNbGauss; anId++)
+ aGaussSlice[anId] = theGaussInfo.GetGaussCoordSlice(anId);
+
+ switch(aGeom){
+ case eSEG2: {
+ INITMSG(MYDEBUG,"eSEG2"<<std::endl);
+
+ if(TSeg2a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eSEG3: {
+ INITMSG(MYDEBUG,"eSEG3"<<std::endl);
+
+ if(TSeg3a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eTRIA3: {
+ INITMSG(MYDEBUG,"eTRIA3"<<std::endl);
+
+ if(TTria3a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TTria3b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eTRIA6: {
+ INITMSG(MYDEBUG,"eTRIA6"<<std::endl);
+
+ if(TTria6a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TTria6b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eQUAD4: {
+ INITMSG(MYDEBUG,"eQUAD4"<<std::endl);
+
+ if(TQuad4a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TQuad4b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eQUAD8: {
+ INITMSG(MYDEBUG,"eQUAD8"<<std::endl);
+
+ if(TQuad8a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TQuad8b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eQUAD9: {
+ INITMSG(MYDEBUG,"eQUAD9"<<std::endl);
+
+ if(TQuad9a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TQuad9b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eTETRA4: {
+ INITMSG(MYDEBUG,"eTETRA4"<<std::endl);
+
+ if(TTetra4a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TTetra4b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case ePYRA5: {
+ INITMSG(MYDEBUG,"ePYRA5"<<std::endl);
+
+ if(TPyra5a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TPyra5b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case ePENTA6: {
+ INITMSG(MYDEBUG,"ePENTA6"<<std::endl);
+
+ if(TPenta6a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TPenta6b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eHEXA8: {
+ INITMSG(MYDEBUG,"eHEXA8"<<std::endl);
+
+ if(THexa8a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(THexa8b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eTETRA10: {
+ INITMSG(MYDEBUG,"eTETRA10"<<std::endl);
+
+ if(TTetra10a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TTetra10b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case ePYRA13: {
+ INITMSG(MYDEBUG,"ePYRA13"<<std::endl);
+
+ if(TPyra13a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TPyra13b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case ePENTA15: {
+ INITMSG(MYDEBUG,"ePENTA15"<<std::endl);
+
+ if(TPenta15a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(TPenta15b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ case eHEXA20: {
+ INITMSG(MYDEBUG,"eHEXA20"<<std::endl);
+
+ if(THexa20a().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ if(THexa20b().Eval(theCellInfo,theNodeInfo,theElemNum,aRefSlice,aGaussSlice,theGaussCoord,theMode))
+ return true;
+
+ break;
+ }
+ default:
+ INITMSG(MYDEBUG,"eNONE"<<std::endl);
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+ //---------------------------------------------------------------
+ bool
+ GetBaryCenter(const TCellInfo& theCellInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum,
+ EModeSwitch theMode)
+ {
+ INITMSG(MYDEBUG,"GetBaryCenter\n");
+ const PMeshInfo& aMeshInfo = theCellInfo.GetMeshInfo();
+ TInt aDim = aMeshInfo->GetDim();
+ static TInt aNbGauss = 1;
+
+ bool anIsSubMesh = !theElemNum.empty();
+ TInt aNbElem;
+ if(anIsSubMesh)
+ aNbElem = theElemNum.size();
+ else
+ aNbElem = theCellInfo.GetNbElem();
+
+ theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
+
+ TInt aConnDim = theCellInfo.GetConnDim();
+
+ INITMSGA(MYDEBUG,0,
+ "- aDim = "<<aDim<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
+ std::endl);
+
+ for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
+ TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
+ TCConnSlice aConnSlice = theCellInfo.GetConnSlice(aCellId);
+ TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
+
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
+
+ for(TInt aConnId = 0; aConnId < aConnDim; aConnId++){
+ TInt aNodeId = aConnSlice[aConnId] - 1;
+ TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
+
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId];
+ }
+ }
+
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] /= aConnDim;
+ }
+ }
+ }
+
+#ifdef _DEBUG_
+ for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
+ TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
+ INITMSG(MYVALUEDEBUG,"");
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCoordSlice& aCoordSlice = aCoordSliceArr[aGaussId];
+ ADDMSG(MYVALUEDEBUG,"{");
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ ADDMSG(MYVALUEDEBUG,aCoordSlice[aDimId]<<" ");
+ }
+ ADDMSG(MYVALUEDEBUG,"} ");
+ }
+ ADDMSG(MYVALUEDEBUG,std::endl);
+ }
+#endif
+
+ return true;
+ }
+
+ //---------------------------------------------------------------
+ bool
+ GetBaryCenter(const TPolygoneInfo& thePolygoneInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum,
+ EModeSwitch theMode)
+ {
+ INITMSG(MYDEBUG,"GetBaryCenter\n");
+ const PMeshInfo& aMeshInfo = thePolygoneInfo.GetMeshInfo();
+ TInt aDim = aMeshInfo->GetDim();
+ static TInt aNbGauss = 1;
+
+ bool anIsSubMesh = !theElemNum.empty();
+ TInt aNbElem;
+ if(anIsSubMesh)
+ aNbElem = theElemNum.size();
+ else
+ aNbElem = thePolygoneInfo.GetNbElem();
+
+ theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
+
+ INITMSGA(MYDEBUG,0,
+ "- aDim = "<<aDim<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
+ std::endl);
+
+ for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
+ TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
+
+ TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
+ TCConnSlice aConnSlice = thePolygoneInfo.GetConnSlice(aCellId);
+ TInt aNbConn = thePolygoneInfo.GetNbConn(aCellId);
+ TInt aNbNodes = thePolygoneInfo.GetNbConn(aCellId);
+
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
+
+ for(TInt aConnId = 0; aConnId < aNbConn; aConnId++){
+ TInt aNodeId = aConnSlice[aConnId] - 1;
+ TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
+
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId];
+ }
+ }
+
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] /= aNbNodes;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ //---------------------------------------------------------------
+ bool
+ GetBaryCenter(const TPolyedreInfo& thePolyedreInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum,
+ EModeSwitch theMode)
+ {
+ INITMSG(MYDEBUG,"GetBaryCenter\n");
+ const PMeshInfo& aMeshInfo = thePolyedreInfo.GetMeshInfo();
+ TInt aDim = aMeshInfo->GetDim();
+ static TInt aNbGauss = 1;
+
+ bool anIsSubMesh = !theElemNum.empty();
+ TInt aNbElem;
+ if(anIsSubMesh)
+ aNbElem = theElemNum.size();
+ else
+ aNbElem = thePolyedreInfo.GetNbElem();
+
+ theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode);
+
+ INITMSGA(MYDEBUG,0,
+ "- aDim = "<<aDim<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbNodes = "<<theNodeInfo.GetNbElem()<<
+ std::endl);
+
+ for(TInt anElemId = 0; anElemId < aNbElem; anElemId++){
+ TInt aCellId = anIsSubMesh? theElemNum[anElemId]-1: anElemId;
+
+ TCoordSliceArr aCoordSliceArr = theGaussCoord.GetCoordSliceArr(anElemId);
+ TCConnSliceArr aConnSliceArr = thePolyedreInfo.GetConnSliceArr(aCellId);
+ TInt aNbFaces = aConnSliceArr.size();
+
+ TInt aNbNodes = thePolyedreInfo.GetNbNodes(aCellId);
+
+ for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++){
+ TCoordSlice& aGaussCoordSlice = aCoordSliceArr[aGaussId];
+
+ for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++){
+ TCConnSlice aConnSlice = aConnSliceArr[aFaceId];
+ TInt aNbConn = aConnSlice.size();
+ for(TInt aConnId = 0; aConnId < aNbConn; aConnId++){
+ TInt aNodeId = aConnSlice[aConnId] - 1;
+ TCCoordSlice aNodeCoordSlice = theNodeInfo.GetCoordSlice(aNodeId);
+
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] += aNodeCoordSlice[aDimId];
+ }
+ }
+ }
+ for(TInt aDimId = 0; aDimId < aDim; aDimId++){
+ aGaussCoordSlice[aDimId] /= aNbNodes;
+ }
+ }
+ }
+
+ return true;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_GaussUtils_HeaderFile
+#define MED_GaussUtils_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Structures.hxx"
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ typedef TVector<TCCoordSlice> TCCoordSliceArr;
+ typedef TVector<TCoordSlice> TCoordSliceArr;
+
+ //! Define a helper class to handle Gauss Points coordinates
+ class MEDWRAPPER_EXPORT TGaussCoord:
+ virtual TModeSwitchInfo
+ {
+ TInt myNbElem;
+ TInt myNbGauss;
+ TInt myDim;
+
+ TInt myGaussStep;
+
+ TNodeCoord myGaussCoord;
+
+ public:
+
+ TGaussCoord();
+
+ //! To init the class
+ void
+ Init(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theDim,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ TInt
+ GetNbElem() const;
+
+ TInt
+ GetNbGauss() const;
+
+ TInt
+ GetDim() const;
+
+ unsigned char*
+ GetValuePtr();
+
+ //! Get slice of the coordinate that corresponds to defined cell (const version)
+ TCCoordSliceArr
+ GetCoordSliceArr(TInt theElemId) const;
+
+ //! Get slice of the coordinate that corresponds to defined cell
+ TCoordSliceArr
+ GetCoordSliceArr(TInt theElemId);
+ };
+ typedef SharedPtr<TGaussCoord> PGaussCoord;
+
+ //---------------------------------------------------------------
+ //! To calculate Gauss Points coordinates
+ MEDWRAPPER_EXPORT
+ bool
+ GetGaussCoord3D(const TGaussInfo& theGaussInfo,
+ const TCellInfo& theCellInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum = TElemNum(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //---------------------------------------------------------------
+ //! To calculate Gauss Points coordinates for defined TCellInfo as its bary center
+ MEDWRAPPER_EXPORT
+ bool
+ GetBaryCenter(const TCellInfo& theCellInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum = TElemNum(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! To calculate Gauss Points coordinates for defined TPolygoneInfo as its bary center
+ MEDWRAPPER_EXPORT
+ bool
+ GetBaryCenter(const TPolygoneInfo& thePolygoneInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum = TElemNum(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! To calculate Gauss Points coordinates for defined TPolyedreInfo as its bary center
+ MEDWRAPPER_EXPORT
+ bool
+ GetBaryCenter(const TPolyedreInfo& thePolyedreInfo,
+ const TNodeInfo& theNodeInfo,
+ TGaussCoord& theGaussCoord,
+ const TElemNum& theElemNum = TElemNum(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //---------------------------------------------------------------
+ //! Shape function definitions
+ //---------------------------------------------------------------
+ struct MEDWRAPPER_EXPORT TShapeFun
+ {
+ class TFun;
+
+ TFloatVector myRefCoord;
+ TInt myDim;
+ TInt myNbRef;
+
+ TShapeFun(TInt theDim = 0, TInt theNbRef = 0);
+
+ TInt GetNbRef() const { return myNbRef; }
+
+ TCCoordSlice GetCoord(TInt theRefId) const;
+
+ TCoordSlice GetCoord(TInt theRefId);
+
+ void GetFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ virtual
+ void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const = 0;
+ virtual
+ bool IsSatisfy(const TCCoordSliceArr& theRefCoord) const;
+
+ bool Eval(const TCellInfo& theCellInfo,
+ const TNodeInfo& theNodeInfo,
+ const TElemNum& theElemNum,
+ const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TGaussCoord& theGaussCoord,
+ EModeSwitch theMode);
+ };
+ //---------------------------------------------------------------
+ struct TSeg2a: TShapeFun {
+ TSeg2a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TSeg3a: TShapeFun {
+ TSeg3a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTria3a: TShapeFun {
+ TTria3a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTria6a: TShapeFun {
+ TTria6a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTria3b: TShapeFun {
+ TTria3b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTria6b: TShapeFun {
+ TTria6b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TQuad4a: TShapeFun {
+ TQuad4a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TQuad8a: TShapeFun {
+ TQuad8a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TQuad9a: TShapeFun {
+ TQuad9a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TQuad4b: TShapeFun {
+ TQuad4b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TQuad8b: TShapeFun {
+ TQuad8b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TQuad9b: TShapeFun {
+ TQuad9b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTetra4a: TShapeFun {
+ TTetra4a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTetra10a: TShapeFun {
+ TTetra10a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTetra4b: TShapeFun {
+ TTetra4b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TTetra10b: TShapeFun {
+ TTetra10b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct THexa8a: TShapeFun {
+ THexa8a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct THexa20a: TShapeFun {
+ THexa20a(TInt theDim = 3, TInt theNbRef = 20);
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct THexa27a: THexa20a {
+ THexa27a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct THexa8b: TShapeFun {
+ THexa8b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct THexa20b: TShapeFun {
+ THexa20b(TInt theDim = 3, TInt theNbRef = 20);
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPenta6a: TShapeFun {
+ TPenta6a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPenta6b: TShapeFun {
+ TPenta6b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPenta15a: TShapeFun {
+ TPenta15a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPenta15b: TShapeFun {
+ TPenta15b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPyra5a: TShapeFun {
+ TPyra5a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPyra5b: TShapeFun {
+ TPyra5b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPyra13a: TShapeFun {
+ TPyra13a();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+ struct TPyra13b: TShapeFun {
+ TPyra13b();
+ virtual void InitFun(const TCCoordSliceArr& theRef,
+ const TCCoordSliceArr& theGauss,
+ TFun& theFun) const;
+ };
+ //---------------------------------------------------------------
+}
+
+#endif // MED_GaussUtils_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_SharedPtr_HeaderFile
+#define MED_SharedPtr_HeaderFile
+
+#include <boost/shared_ptr.hpp>
+
+namespace MED
+{
+ //! To extend the boost::shared_ptr to support such features automatic dynamic cast
+ /*!
+ All entities of the MEDWrapper package are handled as pointer.
+ This class was introduced to provide correct and flexible memory management
+ for all of the MEDWrapper objects.
+ */
+ template<class T> class SharedPtr: public boost::shared_ptr<T>
+ {
+ public:
+ //! Default constructor
+ SharedPtr() {}
+
+ //! Construct the class by any type of a pointer
+ template<class Y>
+ explicit SharedPtr(Y * p):
+ boost::shared_ptr<T>(p)
+ {}
+
+ //! Construct the class by any specialisation of the class
+ template<class Y>
+ SharedPtr(SharedPtr<Y> const & r):
+ boost::shared_ptr<T>(boost::dynamic_pointer_cast<T,Y>(r))
+ {}
+
+ //! Copy-constructor
+ template<class Y>
+ SharedPtr&
+ operator=(SharedPtr<Y> const & r)
+ {
+ SharedPtr<T>(r).swap(*this);
+ return *this;
+ }
+
+ //! Introduce a flexible way to reset the wrapped pointer
+ template<class Y>
+ SharedPtr&
+ operator()(Y * p) // Y must be complete
+ {
+ return operator=<Y>(SharedPtr<Y>(p));
+ }
+
+ //! Introduce a flexible way to reset the wrapped pointer
+ template<class Y>
+ SharedPtr&
+ operator()(SharedPtr<Y> const & r) // Y must be complete
+ {
+ return operator=<Y>(SharedPtr<Y>(r));
+ }
+
+ //! To provide a flexible way to use reference to the wrapped pointer (const version)
+ operator const T& () const
+ {
+ return *(this->get());
+ }
+
+ //! To provide a flexible way to use reference to the wrapped pointer
+ operator T& ()
+ {
+ return *(this->get());
+ }
+ };
+}
+
+#endif // MED_SharedPtr_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_SliceArray_HeaderFile
+#define MED_SliceArray_HeaderFile
+
+#ifdef WIN32 // for correct compiling of "valarray" in modules, which include this file
+ #undef max
+ #undef min
+#endif
+
+#include <valarray>
+#include <stdexcept>
+
+//#if defined(_DEBUG_)
+# define MED_TCSLICE_CHECK_RANGE
+//#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ //! This class intends to provide a uniform way to handle multidimensional data (const version)
+ /*!
+ It just contains a pointer to real sequence and implement proper calculation of its indexes.
+ This class deals with constant pointer to the sources data and provides const method to
+ read them (data).
+ */
+ template<class TValueType>
+ class TCSlice
+ {
+ const TValueType* myCValuePtr; //!< Reference to source multidimensional data
+ size_t mySourceSize; //!< Size of the source multidimensional data
+ std::slice mySlice; //!< Defines algorithm of index calculation
+
+ protected:
+ void
+ check_id(size_t theId) const
+ {
+ long int anId = -1;
+ if(theId < mySlice.size()){
+ anId = mySlice.start() + theId*mySlice.stride();
+ if(anId < (long int)mySourceSize)
+ return;
+ }
+ throw std::out_of_range("TCSlice::check_id");
+ }
+
+ //! Calculate internal index to get proper element from the source multidimensional data
+ size_t
+ calculate_id(size_t theId) const
+ {
+ return mySlice.start() + theId*mySlice.stride();
+ }
+
+ size_t
+ get_id(size_t theId) const
+ {
+#ifdef MED_TCSLICE_CHECK_RANGE
+ check_id(theId);
+#endif
+ return calculate_id(theId);
+ }
+
+ size_t
+ get_id_at(size_t theId) const
+ {
+ check_id(theId);
+ return calculate_id(theId);
+ }
+
+ public:
+ typedef TValueType value_type;
+
+ //! Construct the class from bare pointer
+ TCSlice(const value_type* theValuePtr,
+ size_t theSourceSize,
+ const std::slice& theSlice):
+ myCValuePtr(theValuePtr),
+ mySourceSize(theSourceSize),
+ mySlice(theSlice)
+ {}
+
+ //! Construct the class from corresponding container
+ TCSlice(const TVector<value_type>& theContainer,
+ const std::slice& theSlice):
+ myCValuePtr(&theContainer[0]),
+ mySourceSize(theContainer.size()),
+ mySlice(theSlice)
+ {}
+
+ //! Default constructor (dangerous)
+ TCSlice():
+ myCValuePtr(NULL)
+ {}
+
+ //! Get element by its number (const version)
+ const value_type&
+ operator[](size_t theId) const
+ {
+ return *(myCValuePtr + get_id(theId));
+ }
+
+ const value_type&
+ at(size_t theId) const
+ {
+ return *(myCValuePtr + get_id_at(theId));
+ }
+
+ //! Get range of the order numbers
+ size_t
+ size() const
+ {
+ return mySlice.size();
+ }
+ };
+
+ //---------------------------------------------------------------
+ //! This class extends TCSlice functionality for non-constant case
+ template<class TValueType>
+ class TSlice: public TCSlice<TValueType>
+ {
+ TValueType* myValuePtr;
+
+ public:
+ typedef TValueType value_type;
+ typedef TCSlice<TValueType> TSupperClass;
+
+ //! Construct the class from bare pointer
+ TSlice(value_type* theValuePtr,
+ size_t theSourceSize,
+ const std::slice& theSlice):
+ TSupperClass(theValuePtr, theSourceSize, theSlice),
+ myValuePtr(theValuePtr)
+ {}
+
+ //! Construct the class from corresponding container
+ TSlice(TVector<value_type>& theContainer,
+ const std::slice& theSlice):
+ TSupperClass(theContainer, theSlice),
+ myValuePtr(&theContainer[0])
+ {}
+
+ //! Default constructor (dangerous)
+ TSlice():
+ myValuePtr(NULL)
+ {}
+
+ //! Get element by its number
+ value_type&
+ operator[](size_t theId)
+ {
+ return *(myValuePtr + this->get_id(theId));
+ }
+
+ value_type&
+ at(size_t theId)
+ {
+ return *(myValuePtr + this->get_id_at(theId));
+ }
+ };
+}
+
+#undef MED_TCSLICE_CHECK_RANGE
+
+#endif // MED_SliceArray_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_Structures.hxx"
+#include "MED_Utilities.hxx"
+
+#include <cstring>
+
+namespace MED
+{
+ std::string
+ GetString(TInt theId,
+ TInt theStep,
+ const TString& theString)
+ {
+ const char* aPos = &theString[theId*theStep];
+ TInt aSize = std::min(TInt(strlen(aPos)),theStep);
+ return std::string(aPos,aSize);
+ }
+
+ void
+ SetString(TInt theId,
+ TInt theStep,
+ TString& theString,
+ const std::string& theValue)
+ {
+ TInt aSize = std::min(TInt(theValue.size()+1),theStep);
+ char* aPos = &theString[theId*theStep];
+ strncpy(aPos,theValue.c_str(),aSize);
+ }
+
+ void
+ SetString(TInt theId,
+ TInt theStep,
+ TString& theString,
+ const TString& theValue)
+ {
+ TInt aSize = std::min(TInt(theValue.size()+1),theStep);
+ char* aPos = &theString[theId*theStep];
+ const char* aValue = &theValue[0];
+ strncpy(aPos,aValue,aSize);
+ }
+
+ TInt
+ GetDimGaussCoord(EGeometrieElement theGeom)
+ {
+ return theGeom/100;
+ }
+
+ TInt
+ GetNbRefCoord(EGeometrieElement theGeom)
+ {
+ return (theGeom%100);
+ }
+
+ //---------------------------------------------------------------
+ PFloatTimeStampValue
+ CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue)
+ {
+ return theTimeStampValue;
+ }
+
+ PIntTimeStampValue
+ CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue)
+ {
+ return theTimeStampValue;
+ }
+
+ //---------------------------------------------------------------
+ TInt
+ TFamilyInfo
+ ::GetAttrId(TInt theId) const
+ {
+ return myAttrId[theId];
+ }
+
+ TInt
+ TFamilyInfo
+ ::GetAttrVal(TInt theId) const
+ {
+ return myAttrVal[theId];
+ }
+
+ void
+ TFamilyInfo
+ ::SetAttrId(TInt theId,TInt theVal)
+ {
+ myAttrId[theId] = theVal;
+ }
+
+ void
+ TFamilyInfo
+ ::SetAttrVal(TInt theId,TInt theVal)
+ {
+ myAttrVal[theId] = theVal;
+ }
+
+ //---------------------------------------------------------------
+ TInt
+ TElemInfo
+ ::GetFamNum(TInt theId) const
+ {
+ return (*myFamNum)[theId];
+ }
+
+ void
+ TElemInfo
+ ::SetFamNum(TInt theId, TInt theVal)
+ {
+ (*myFamNum)[theId] = theVal;
+ myIsFamNum = eVRAI;
+ }
+
+ TInt
+ TElemInfo
+ ::GetElemNum(TInt theId) const
+ {
+ return (*myElemNum)[theId];
+ }
+
+ void
+ TElemInfo
+ ::SetElemNum(TInt theId, TInt theVal)
+ {
+ (*myElemNum)[theId] = theVal;
+ }
+
+ //---------------------------------------------------------------
+ TCCoordSlice
+ TNodeInfo
+ ::GetCoordSlice(TInt theId) const
+ {
+ TInt aDim = myMeshInfo->GetSpaceDim();
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCCoordSlice(*myCoord, std::slice(theId*aDim, aDim, 1));
+ else
+ return TCCoordSlice(*myCoord, std::slice(theId, aDim, aDim));
+ }
+
+ TCoordSlice
+ TNodeInfo
+ ::GetCoordSlice(TInt theId)
+ {
+ TInt aDim = myMeshInfo->GetSpaceDim();
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCoordSlice(*myCoord, std::slice(theId*aDim,aDim,1));
+ else
+ return TCoordSlice(*myCoord, std::slice(theId,aDim,aDim));
+ }
+
+ //---------------------------------------------------------------
+ TCConnSlice
+ TCellInfo
+ ::GetConnSlice(TInt theElemId) const
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1));
+ else
+ return TCConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim()));
+ }
+
+ TConnSlice
+ TCellInfo
+ ::GetConnSlice(TInt theElemId)
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1));
+ else
+ return TConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim()));
+ }
+
+ //---------------------------------------------------------------
+ TInt
+ TPolygoneInfo
+ ::GetNbConn(TInt theElemId) const
+ {
+ return (*myIndex)[theElemId + 1] - (*myIndex)[theElemId];
+ }
+
+ TCConnSlice
+ TPolygoneInfo
+ ::GetConnSlice(TInt theElemId) const
+ {
+ return TCConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1));
+ }
+
+ TConnSlice
+ TPolygoneInfo
+ ::GetConnSlice(TInt theElemId)
+ {
+ return TConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1));
+ }
+
+ //---------------------------------------------------------------
+ TInt
+ TPolyedreInfo
+ ::GetNbFaces(TInt theElemId) const
+ {
+ return (*myIndex)[theElemId+1] - (*myIndex)[theElemId];
+ }
+
+ TInt
+ TPolyedreInfo
+ ::GetNbNodes(TInt theElemId) const
+ {
+ TInt aNbNodes = 0;
+ TInt aNbFaces = GetNbFaces(theElemId);
+ TInt aStartFaceId = (*myIndex)[theElemId] - 1;
+ for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
+ TInt aCurrentId = (*myFaces)[aStartFaceId];
+ TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
+ aNbNodes += aDiff;
+ }
+ return aNbNodes;
+ }
+
+ TCConnSliceArr
+ TPolyedreInfo
+ ::GetConnSliceArr(TInt theElemId) const
+ {
+ TInt aNbFaces = GetNbFaces(theElemId);
+ TCConnSliceArr aConnSliceArr(aNbFaces);
+ TInt aStartFaceId = (*myIndex)[theElemId] - 1;
+ for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
+ TInt aCurrentId = (*myFaces)[aStartFaceId];
+ TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
+ aConnSliceArr[aFaceId] =
+ TCConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1));
+ }
+ return aConnSliceArr;
+ }
+
+ TConnSliceArr
+ TPolyedreInfo
+ ::GetConnSliceArr(TInt theElemId)
+ {
+ TInt aNbFaces = GetNbFaces(theElemId);
+ TConnSliceArr aConnSliceArr(aNbFaces);
+ TInt aStartFaceId = (*myIndex)[theElemId] - 1;
+ for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
+ TInt aCurrentId = (*myFaces)[aStartFaceId];
+ TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
+ aConnSliceArr[aFaceId] =
+ TConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1));
+ }
+ return aConnSliceArr;
+ }
+
+ //---------------------------------------------------------------
+ TMeshValueBase
+ ::TMeshValueBase():
+ myNbElem(0),
+ myNbComp(0),
+ myNbGauss(0),
+ myStep(0)
+ {}
+
+ void
+ TMeshValueBase
+ ::Allocate(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode)
+ {
+ myModeSwitch = theMode;
+
+ myNbElem = theNbElem;
+ myNbGauss = theNbGauss;
+ myNbComp = theNbComp;
+
+ myStep = theNbComp*theNbGauss;
+ }
+
+ size_t
+ TMeshValueBase
+ ::GetSize() const
+ {
+ return myNbElem * myStep;
+ }
+
+ size_t
+ TMeshValueBase
+ ::GetNbVal() const
+ {
+ return myNbElem * myNbGauss;
+ }
+
+ size_t
+ TMeshValueBase
+ ::GetNbGauss() const
+ {
+ return myNbGauss;
+ }
+
+ size_t
+ TMeshValueBase
+ ::GetStep() const
+ {
+ return myStep;
+ }
+
+ //---------------------------------------------------------------
+ TInt
+ TProfileInfo
+ ::GetElemNum(TInt theId) const
+ {
+ return (*myElemNum)[theId];
+ }
+
+ void
+ TProfileInfo
+ ::SetElemNum(TInt theId,TInt theVal)
+ {
+ (*myElemNum)[theId] = theVal;
+ }
+
+ //---------------------------------------------------------------
+ bool
+ TGaussInfo::TLess
+ ::operator()(const TKey& theLeft, const TKey& theRight) const
+ {
+ EGeometrieElement aLGeom = boost::get<0>(theLeft);
+ EGeometrieElement aRGeom = boost::get<0>(theRight);
+ if(aLGeom != aRGeom)
+ return aLGeom < aRGeom;
+
+ const std::string& aLStr = boost::get<1>(theLeft);
+ const std::string& aRStr = boost::get<1>(theRight);
+ return aLStr < aRStr;
+ }
+
+ bool
+ TGaussInfo::TLess
+ ::operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const
+ {
+ if(!&theLeft)
+ return true;
+
+ if(!&theRight)
+ return false;
+
+ if(theLeft.myGeom != theRight.myGeom)
+ return theLeft.myGeom < theRight.myGeom;
+
+ if(theLeft.myRefCoord != theRight.myRefCoord)
+ return theLeft.myRefCoord < theRight.myRefCoord;
+
+ return theLeft.myGaussCoord < theRight.myGaussCoord;
+ }
+
+ TCCoordSlice
+ TGaussInfo
+ ::GetRefCoordSlice(TInt theId) const
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
+ else
+ return TCCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
+ }
+
+ TCoordSlice
+ TGaussInfo
+ ::GetRefCoordSlice(TInt theId)
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
+ else
+ return TCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
+ }
+
+ TCCoordSlice
+ TGaussInfo
+ ::GetGaussCoordSlice(TInt theId) const
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetDim(),1));
+ else
+ return TCCoordSlice(myGaussCoord,std::slice(theId,GetDim(),GetDim()));
+ }
+
+ TCoordSlice
+ TGaussInfo
+ ::GetGaussCoordSlice(TInt theId)
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE)
+ return TCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetNbGauss(),1));
+ else
+ return TCoordSlice(myGaussCoord,std::slice(theId,GetNbGauss(),GetDim()));
+ }
+
+ //---------------------------------------------------------------
+ TInt
+ TTimeStampInfo
+ ::GetNbGauss(EGeometrieElement theGeom) const
+ {
+ TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
+ if(anIter == myGeom2NbGauss.end())
+ return 1;//EXCEPTION(runtime_error,"TTimeStampInfo::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
+
+ return anIter->second;
+ }
+
+ //---------------------------------------------------------------
+ // TGrilleInfo structure methods
+ //---------------------------------------------------------------
+ const EGrilleType&
+ TGrilleInfo
+ ::GetGrilleType() const
+ {
+ return myGrilleType;
+ }
+
+ EGrilleType
+ TGrilleInfo
+ ::GetGrilleType()
+ {
+ return myGrilleType;
+ }
+
+ void
+ TGrilleInfo
+ ::SetGrilleType(EGrilleType theGrilleType)
+ {
+ myGrilleType = theGrilleType;
+ }
+
+ const
+ TIndexes&
+ TGrilleInfo
+ ::GetMapOfIndexes() const
+ {
+ return myIndixes;
+ }
+
+ TIndexes&
+ TGrilleInfo
+ ::GetMapOfIndexes()
+ {
+ return myIndixes;
+ }
+
+ const
+ TFloatVector&
+ TGrilleInfo
+ ::GetIndexes(TInt theAxisNumber) const
+ {
+ TIndexes::const_iterator aIter=myIndixes.find(theAxisNumber);
+ if(aIter==myIndixes.end())
+ EXCEPTION(std::runtime_error, "const TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber); fails");
+ return aIter->second;
+ }
+
+ TFloatVector&
+ TGrilleInfo
+ ::GetIndexes(TInt theAxisNumber)
+ {
+ TIndexes::iterator aIter=myIndixes.find(theAxisNumber);
+ if(aIter==myIndixes.end())
+ EXCEPTION(std::runtime_error, "TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber="<<theAxisNumber<<"); fails");
+ return aIter->second;
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetNbIndexes(TInt theAxisNumber)
+ {
+ const TFloatVector& aVector=GetIndexes(theAxisNumber);
+ return aVector.size();
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetNbNodes()
+ {
+ TInt nbNodes=0;
+ TInt aDim = myMeshInfo->GetDim();
+ for(int i=0;i<aDim;i++)
+ if(nbNodes == 0)
+ nbNodes = this->GetGrilleStructure()[i];
+ else
+ nbNodes = nbNodes*this->GetGrilleStructure()[i];
+
+ return nbNodes;
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetNbCells()
+ {
+ TInt nbCells=0;
+ TInt aDim = myMeshInfo->GetDim();
+ for(int i=0;i<aDim;i++)
+ if(nbCells == 0)
+ nbCells = this->GetGrilleStructure()[i]-1;
+ else
+ nbCells = nbCells*(this->GetGrilleStructure()[i]-1);
+ return nbCells;
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetNbSubCells()
+ {
+ TInt nb=0;
+ TInt aDim = myMeshInfo->GetDim();
+ switch (aDim) {
+ case 3:
+ nb =
+ (myGrilleStructure[0] ) * (myGrilleStructure[1]-1) * (myGrilleStructure[2]-1) +
+ (myGrilleStructure[0]-1) * (myGrilleStructure[1] ) * (myGrilleStructure[2]-1) +
+ (myGrilleStructure[0]-1) * (myGrilleStructure[1]-1) * (myGrilleStructure[2] );
+ break;
+ case 2:
+ nb =
+ (myGrilleStructure[0] ) * (myGrilleStructure[1]-1) +
+ (myGrilleStructure[0]-1) * (myGrilleStructure[1] );
+ break;
+ }
+ return nb;
+ }
+
+ EGeometrieElement
+ TGrilleInfo
+ ::GetGeom()
+ {
+ TInt aDim = myMeshInfo->GetDim();
+ switch(aDim){
+ case 1:
+ return eSEG2;
+ case 2:
+ return eQUAD4;
+ case 3:
+ return eHEXA8;
+ default:
+ return eNONE;
+ }
+ }
+
+ EGeometrieElement
+ TGrilleInfo
+ ::GetSubGeom()
+ {
+ TInt aDim = myMeshInfo->GetDim();
+ switch(aDim){
+ case 2:
+ return eSEG2;
+ case 3:
+ return eQUAD4;
+ }
+ return eNONE;
+ }
+
+ EEntiteMaillage
+ TGrilleInfo
+ ::GetEntity()
+ {
+ return eMAILLE;
+ }
+
+ EEntiteMaillage
+ TGrilleInfo
+ ::GetSubEntity()
+ {
+ TInt aDim = myMeshInfo->GetDim();
+ switch(aDim){
+ case 2:
+ return eARETE;
+ case 3:
+ return eFACE;
+ }
+ return EEntiteMaillage(-1);
+ }
+
+ const
+ TIntVector&
+ TGrilleInfo
+ ::GetGrilleStructure() const
+ {
+ return myGrilleStructure;
+ }
+
+ TIntVector
+ TGrilleInfo
+ ::GetGrilleStructure()
+ {
+ return myGrilleStructure;
+ }
+
+ void
+ TGrilleInfo
+ ::SetGrilleStructure(TInt theAxis,TInt theNb)
+ {
+ if(theAxis >= 0 && theAxis <=2 && theNb >= 0)
+ myGrilleStructure[theAxis]=theNb;
+ }
+
+ const
+ TNodeCoord&
+ TGrilleInfo
+ ::GetNodeCoord() const
+ {
+ return myCoord;
+ }
+
+ TNodeCoord&
+ TGrilleInfo
+ ::GetNodeCoord()
+ {
+ return myCoord;
+ }
+
+ TNodeCoord
+ TGrilleInfo
+ ::GetCoord(TInt theId)
+ {
+ TNodeCoord aCoord;
+ TInt aDim = myMeshInfo->GetDim();
+ TInt aNbNodes = this->GetNbNodes();
+ aCoord.resize(aDim);
+
+ if(theId >= aNbNodes)
+ EXCEPTION(std::runtime_error, "TGrilleInfo::GetCoord - theId out of range");
+
+ if(myGrilleType == eGRILLE_STANDARD){
+ switch(aDim){
+ case 3:
+ aCoord[2] = myCoord[aDim*theId+2];
+ case 2:
+ aCoord[1] = myCoord[aDim*theId+1];
+ case 1:{
+ aCoord[0] = myCoord[aDim*theId];
+ break;
+ }
+ }
+ } else {
+
+ TFloatVector aVecX = this->GetIndexes(0);
+ TInt nbIndxX = this->GetNbIndexes(0);
+
+ switch(aDim){
+ case 1:{
+ aCoord[0] = aVecX[theId];
+ break;
+ }
+ case 2:{
+ TFloatVector aVecY = this->GetIndexes(1);
+ TInt i,j,k;
+ i = j = k = 0;
+ i = theId % nbIndxX;
+ j = theId / nbIndxX;
+ if(myGrilleType == eGRILLE_CARTESIENNE){
+ aCoord[0] = aVecX[i];
+ aCoord[1] = aVecY[j];
+ } else { // eGRILLE_POLAIRE (cylindrical)
+ aCoord[0] = aVecX[i] * cos(aVecY[j]);
+ aCoord[1] = aVecX[i] * sin(aVecY[j]);
+ }
+ break;
+ }
+ case 3:{
+ TFloatVector aVecY = this->GetIndexes(1);
+ TInt nbIndxY = this->GetNbIndexes(1);
+ TFloatVector aVecZ = this->GetIndexes(2);
+ TInt i,j,k;
+ i = j = k = 0;
+
+ i = theId % nbIndxX;
+ j = (theId / nbIndxX) % nbIndxY;
+ k = theId / (nbIndxX*nbIndxY);
+
+ if(myGrilleType == eGRILLE_CARTESIENNE){
+ aCoord[0] = aVecX[i];
+ aCoord[1] = aVecY[j];
+ aCoord[2] = aVecZ[k];
+ } else { // eGRILLE_POLAIRE (cylindrical)
+ aCoord[0] = aVecX[i] * cos(aVecY[j]);
+ aCoord[1] = aVecX[i] * sin(aVecY[j]);
+ aCoord[2] = aVecZ[k];
+ }
+
+ break;
+ }
+ }
+ }
+
+ return aCoord;
+ }
+
+ TIntVector
+ TGrilleInfo
+ ::GetConn(TInt theId, const bool isSub)
+ {
+ TIntVector anIndexes;
+ TInt aDim = myMeshInfo->GetDim();
+
+ TInt idx;
+ TInt iMin, jMin, kMin, iMax, jMax, kMax;
+ TInt loc[3];
+
+ loc[0] = loc[1] = loc[2] = 0;
+ iMin = iMax = jMin = jMax = kMin = kMax = 0;
+
+ switch(aDim) {
+ case 3:
+ {
+ TInt nbX = this->GetGrilleStructure()[0];
+ TInt nbY = this->GetGrilleStructure()[1];
+ TInt nbZ = this->GetGrilleStructure()[2];
+ TInt d01 = nbX*nbY, dX = 1, dY = 1, dZ = 1;
+ if ( isSub )
+ {
+ if ( theId < nbX * (nbY-1) * (nbZ-1))
+ { // face is normal to X axis
+ dX = 0;
+ }
+ else if ( theId < nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1))
+ { // face is normal to Y axis
+ theId -= nbX * (nbY-1) * (nbZ-1);
+ dY = 0;
+ }
+ else
+ {
+ theId -= nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1);
+ dZ = 0;
+ }
+ }
+ //else
+ {
+ iMin = theId % (nbX - dX);
+ jMin = (theId / (nbX - dX)) % (nbY - dY);
+ kMin = theId / ((nbX - dX) * (nbY - dY));
+ iMax = iMin+dX;
+ jMax = jMin+dY;
+ kMax = kMin+dZ;
+ }
+ for (loc[2]=kMin; loc[2]<=kMax; loc[2]++)
+ for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
+ for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
+ {
+ idx = loc[0] + loc[1]*nbX + loc[2]*d01;
+ anIndexes.push_back(idx);
+ }
+ break;
+ }
+ case 2:
+ {
+ TInt nbX = this->GetGrilleStructure()[0];
+ TInt nbY = this->GetGrilleStructure()[1];
+ TInt dX = 1, dY = 1;
+ if ( isSub )
+ {
+ if ( theId < nbX * (nbY-1))
+ { // edge is normal to X axis
+ dX = 0;
+ }
+ else
+ {
+ theId -= nbX * (nbY-1);
+ dY = 0;
+ }
+ }
+ iMin = theId % (nbX-dX);
+ jMin = theId / (nbX-dX);
+ iMax = iMin+dX;
+ jMax = jMin+dY;
+ for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
+ for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
+ {
+ idx = loc[0] + loc[1]*nbX;
+ anIndexes.push_back(idx);
+ }
+ break;
+ }
+ case 1:
+ {
+ iMin = theId;
+ for (loc[0]=iMin; loc[0]<=iMin+1; loc[0]++)
+ {
+ idx = loc[0];
+ anIndexes.push_back(idx);
+ }
+ break;
+ }
+ }
+
+ return anIndexes;
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetFamNumNode(TInt theId) const
+ {
+ return myFamNumNode[theId];
+ }
+
+ void
+ TGrilleInfo
+ ::SetFamNumNode(TInt theId,TInt theVal)
+ {
+ myFamNumNode[theId] = theVal;
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetFamNum(TInt theId) const
+ {
+ return myFamNum[theId];
+ }
+
+ void
+ TGrilleInfo
+ ::SetFamNum(TInt theId,TInt theVal)
+ {
+ myFamNum[theId] = theVal;
+ }
+
+ TInt
+ TGrilleInfo
+ ::GetFamSubNum(TInt theId) const
+ {
+ return myFamSubNum[theId];
+ }
+
+ void
+ TGrilleInfo
+ ::SetFamSubNum(TInt theId,TInt theVal)
+ {
+ myFamSubNum[theId] = theVal;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Structures_HeaderFile
+#define MED_Structures_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Common.hxx"
+#include "MED_Utilities.hxx"
+#include "MED_SliceArray.hxx"
+
+#include <boost/tuple/tuple.hpp>
+
+#ifdef WIN32
+#pragma warning(disable:4251)
+#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ //! Defines a type for managing sequence of strings
+ typedef TVector<char> TString;
+ typedef SharedPtr<TString> PString;
+
+ //---------------------------------------------------------------
+ //! Extract a substring from the sequence of the strings
+ MEDWRAPPER_EXPORT
+ std::string
+ GetString(TInt theId,
+ TInt theStep,
+ const TString& theString);
+
+ //---------------------------------------------------------------
+ //! Set a substring in the sequence of the strings
+ MEDWRAPPER_EXPORT
+ void
+ SetString(TInt theId,
+ TInt theStep,
+ TString& theString,
+ const std::string& theValue);
+
+ //---------------------------------------------------------------
+ //! Set a substring in the sequence of the strings
+ MEDWRAPPER_EXPORT
+ void
+ SetString(TInt theId,
+ TInt theStep,
+ TString& theString,
+ const TString& theValue);
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all MEDWrapper classes
+ struct MEDWRAPPER_EXPORT TBase
+ {
+ virtual ~TBase() {}
+ };
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all named MED entities
+ struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase
+ {
+ TString myName; //!< Keeps its name
+ virtual std::string GetName() const = 0; //!< Gets its name
+ virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
+ virtual void SetName(const TString& theValue) = 0; //!< Set a new name
+ };
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all MED entities that contains a sequence of numbers
+ /*!
+ It defines through corresponding enumeration (EModeSwitch) how the sequence
+ should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
+ */
+ struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase
+ {
+ //! To construct instance of the class by default
+ TModeSwitchInfo():
+ myModeSwitch(eFULL_INTERLACE)
+ {}
+
+ //! To construct instance of the class
+ TModeSwitchInfo(EModeSwitch theModeSwitch):
+ myModeSwitch(theModeSwitch)
+ {}
+
+ EModeSwitch myModeSwitch; //!< Keeps the interlace mode
+ EModeSwitch GetModeSwitch() const { return myModeSwitch; }
+ };
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Mesh entity
+ struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo
+ {
+ TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
+ TInt GetDim() const { return myDim; } //!< Gets dimension of the mesh
+
+ TInt mySpaceDim;
+ TInt GetSpaceDim() const { return mySpaceDim; }
+
+ EMaillage myType; //!< Type of the mesh
+ EMaillage GetType() const { return myType; } //!< Gets type of the mesh
+
+ TString myDesc; //!< Description of the mesh
+ virtual std::string GetDesc() const = 0; //!< Get description for the mesh
+ virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
+ };
+
+ //---------------------------------------------------------------
+ typedef TSlice<TInt> TIntVecSlice;
+ typedef TCSlice<TInt> TCIntVecSlice;
+ typedef TIntVector TFamAttr;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Family entity
+ struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo
+ {
+ PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
+ //! Get a reference to corresponding MED Mesh
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ TInt myId; //!< An unique index of the MED FAMILY
+ TInt GetId() const { return myId; } //!< Gets number of the MED FAMILY
+ void SetId(TInt theId) { myId = theId; } //! Define number of the MED FAMILY
+
+ TInt myNbGroup; //!< Defines number MED Groups connected to
+ //! Gets number of MED GROUPS the MED FAMILY is bound to
+ TInt GetNbGroup() const { return myNbGroup; }
+
+ //! Contains sequence of the names for the MED Groups connected to
+ TString myGroupNames;
+ //! Gets name of a bound MED GROUP by its number
+ virtual std::string GetGroupName(TInt theId) const = 0;
+ //! Sets name of the defined MED GROUP by its number
+ virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
+
+ TInt myNbAttr; //!< Defines number of the MED Family attributes
+ //! Gets number of attached attributes for the MED FAMILY
+ TInt GetNbAttr() const { return myNbAttr; }
+
+ //! Defines sequence of the indexes of the MED Family attributes
+ TFamAttr myAttrId;
+ //! Get MED FAMILY attribute by its number
+ TInt GetAttrId(TInt theId) const;
+ //! Set MED FAMILY attribute by its number
+ void SetAttrId(TInt theId, TInt theVal);
+
+ //! Defines sequence of the values of the MED Family attributes
+ TFamAttr myAttrVal;
+ //! Get MED FAMILY attribute by its number
+ TInt GetAttrVal(TInt theId) const;
+ //! Set MED FAMILY attribute by its number
+ void SetAttrVal(TInt theId, TInt theVal);
+
+ //! Defines sequence of the names of the MED Family attributes
+ TString myAttrDesc;
+ //! Get value of the MED FAMILY attribute by its number
+ virtual std::string GetAttrDesc(TInt theId) const = 0;
+ //! Set value of the MED FAMILY attribute by its number
+ virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ typedef TIntVector TElemNum;
+ typedef SharedPtr<TElemNum> PElemNum;
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells.
+ struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase
+ {
+ PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
+ //! Get a reference to corresponding MED Mesh
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ TInt myNbElem; //<! Number of corresponding mesh entities
+ TInt GetNbElem() const { return myNbElem; } //! Get number of mesh elements
+
+ //! Defines sequence MED Family indexes for corresponding mesh entites
+ PElemNum myFamNum;
+ //! Get number of a MED FAMILY by order number of the mesh element
+ TInt GetFamNum(TInt theId) const;
+ //! Set number of a MED FAMILY for the mesh element with the order number
+ void SetFamNum(TInt theId, TInt theVal);
+
+ //! Defines if the mesh elements are indexed
+ EBooleen myIsElemNum;
+ //! Let know if the mesh elements are indexed
+ EBooleen IsElemNum() const { return myIsElemNum; }
+
+ //! Defines if the mesh elements family are indexed
+ EBooleen myIsFamNum;
+ //! Let know if the mesh elements family are indexed
+ EBooleen IsFamNum() const { return myIsFamNum; }
+
+ //! Contains sequence of the indexes for the mesh elements
+ PElemNum myElemNum;
+ //! Get a reference number of the mesh element by its order number
+ TInt GetElemNum(TInt theId) const;
+ //! Set a reference number for the mesh element by its order number
+ void SetElemNum(TInt theId, TInt theVal);
+
+ //! Defines if the mesh elements are named
+ EBooleen myIsElemNames;
+ //! Let know if the mesh elements havew names
+ EBooleen IsElemNames() const { return myIsElemNames; }
+
+ //! Contains sequence of the names for the mesh elements
+ PString myElemNames;
+ //! Get name of the mesh element by its order number
+ virtual std::string GetElemName(TInt theId) const = 0;
+ //! Set name of the mesh element by its order number
+ virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ typedef TSlice<TFloat> TFloatVecSlice;
+ typedef TCSlice<TFloat> TCFloatVecSlice;
+ typedef TFloatVector TNodeCoord;
+ typedef SharedPtr<TNodeCoord> PNodeCoord;
+ typedef TFloatVecSlice TCoordSlice;
+ typedef TCFloatVecSlice TCCoordSlice;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Nodes entity
+ struct MEDWRAPPER_EXPORT TNodeInfo:
+ virtual TElemInfo,
+ virtual TModeSwitchInfo
+ {
+ PNodeCoord myCoord; //!< Contains all nodal coordinates
+
+ //! Gives coordinates for mesh node by its number (const version)
+ TCCoordSlice GetCoordSlice(TInt theId) const;
+ //! Gives coordinates for mesh node by its number
+ TCoordSlice GetCoordSlice(TInt theId);
+
+ ERepere mySystem; //!< Defines, which coordinate system is used
+ //! Get which coordinate system is used for the node describing
+ ERepere GetSystem() const { return mySystem; }
+ //! Set coordinate system to be used for the node describing
+ void SetSystem(ERepere theSystem) { mySystem = theSystem; }
+
+ TString myCoordNames; //!< Contains names for the coordinate dimensions
+ //! Get name of the coordinate dimension by its order number
+ virtual std::string GetCoordName(TInt theId) const = 0;
+ //! Set name of the coordinate dimension by its order number
+ virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
+
+ TString myCoordUnits; //!< Contains units for the coordinate dimensions
+ //! Get name of unit for the coordinate dimension by its order number
+ virtual std::string GetCoordUnit(TInt theId) const = 0;
+ //! Set name of unit for the coordinate dimension by its order number
+ virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ typedef TIntVecSlice TConnSlice;
+ typedef TCIntVecSlice TCConnSlice;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Cells entity
+ struct MEDWRAPPER_EXPORT TCellInfo:
+ virtual TElemInfo,
+ virtual TModeSwitchInfo
+ {
+ EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
+ //! Find out what MED ENTITY the cells belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
+ //! Find out what MED geometrical type the cells belong to
+ EGeometrieElement GetGeom() const { return myGeom; }
+
+ EConnectivite myConnMode; //!< Defines connectivity mode
+ //! Find out in what connectivity the cells are writen
+ EConnectivite GetConnMode() const { return myConnMode; }
+
+ virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
+
+ PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell
+
+ //! Gives connectivities for mesh cell by its number (const version)
+ TCConnSlice GetConnSlice(TInt theElemId) const;
+ //! Gives connectivities for mesh cell by its number
+ TConnSlice GetConnSlice(TInt theElemId);
+ };
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Polygon entity
+ struct MEDWRAPPER_EXPORT TPolygoneInfo:
+ virtual TElemInfo
+ {
+ //! Defines the MED Entity where the polygons belongs to
+ EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
+ //! Find out what MED ENTITY the MED Polygons belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ //! Defines the MED Geometric type of the instance
+ EGeometrieElement myGeom; // ePOLYGONE
+ //! Find out what MED geometrical type the MED Polygons belong to
+ EGeometrieElement GetGeom() const { return ePOLYGONE; }
+
+ //! Defines connectivity mode
+ EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
+ //! Find out in what connectivity the cells are writen
+ EConnectivite GetConnMode() const { return myConnMode; }
+
+ PElemNum myConn; //!< Table de connectivities
+ PElemNum myIndex; //!< Table de indexes
+
+ //! Gives number of the connectivities for the defined polygon
+ TInt GetNbConn(TInt theElemId) const;
+
+ //! Gives connectivities for polygon by its number (const version)
+ TCConnSlice GetConnSlice(TInt theElemId) const;
+ //! Gives connectivities for polygon by its number
+ TConnSlice GetConnSlice(TInt theElemId);
+ };
+
+ //---------------------------------------------------------------
+ //! Define a class representing MED_BALL structure element.
+ /*!
+ This could be a generic class for any structure element
+ holding any number of contant and variable attributes
+ but it's too hard to implement
+ */
+ struct MEDWRAPPER_EXPORT TBallInfo:
+ virtual TCellInfo
+ {
+ TFloatVector myDiameters;
+ };
+
+ //---------------------------------------------------------------
+ typedef TVector<TCConnSlice> TCConnSliceArr;
+ typedef TVector<TConnSlice> TConnSliceArr;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Polyedre entity
+ struct MEDWRAPPER_EXPORT TPolyedreInfo:
+ virtual TElemInfo
+ {
+ //! Defines the MED Entity where the polyedres belongs to
+ EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
+ //! Find out what MED ENTITY the MED Polyedres belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ //! Defines the MED Geometric type of the instance
+ EGeometrieElement myGeom; // ePOLYEDRE
+ //! Find out what MED geometrical type the MED Polyedres belong to
+ EGeometrieElement GetGeom() const { return ePOLYEDRE; }
+
+ //! Defines connectivity mode
+ EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
+ //! Find out in what connectivity the cells are writen
+ EConnectivite GetConnMode() const { return myConnMode; }
+
+ PElemNum myConn; //!< Table de connectivities
+ PElemNum myFaces; //!< Table de faces indexes
+ PElemNum myIndex; //!< Table de indexes
+
+ //! Gives number of the faces for the defined polyedre (const version)
+ TInt GetNbFaces(TInt theElemId) const;
+ //! Gives number of the nodes for the defined polyedre
+ TInt GetNbNodes(TInt theElemId) const;
+
+ //! Gives sequence of the face connectivities for polyedre by its number (const version)
+ TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
+ //! Gives sequence of the face connectivities for polyedre by its number
+ TConnSliceArr GetConnSliceArr(TInt theElemId);
+ };
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Field entity
+ struct MEDWRAPPER_EXPORT TFieldInfo:
+ virtual TNameInfo
+ {
+ PMeshInfo myMeshInfo; //!< A reference to corresponding MED Mesh
+ //! Get a reference to corresponding MED Mesh
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ ETypeChamp myType; //!< Defines type of MED Field
+ //! Find out what type of MED FIELD is used
+ ETypeChamp GetType() const { return myType; }
+
+ TInt myNbComp; //!< Defines number of components stored in the field
+ //! Get number of components for MED FIELD
+ TInt GetNbComp() const { return myNbComp; }
+
+ EBooleen myIsLocal; //!< Defines if the MED Field is local
+ //! Find out if MED FIELD is local or not
+ EBooleen GetIsLocal() const { return myIsLocal; }
+
+ TInt myNbRef; //!< Defines number of references of the field
+ //! Find out number of references for the MED FIELD
+ TInt GetNbRef() const { return myNbRef; }
+
+ TString myCompNames; //!< Contains names for each of MED Field components
+ //! Get name of the component by its order number
+ virtual std::string GetCompName(TInt theId) const = 0;
+ //! Set name for the component by its order number
+ virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
+
+ TString myUnitNames; //!< Contains units for each of MED Field components
+ //! Get unit of the component by its order number
+ virtual std::string GetUnitName(TInt theId) const = 0;
+ //! Set unit for the component by its order number
+ virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! Get dimension of the Gauss coordinates for the defined type of mesh cell
+ MEDWRAPPER_EXPORT
+ TInt
+ GetDimGaussCoord(EGeometrieElement theGeom);
+
+ //---------------------------------------------------------------
+ //! Get number of referenced nodes for the defined type of mesh cell
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNbRefCoord(EGeometrieElement theGeom);
+
+ //---------------------------------------------------------------
+ typedef TFloatVector TWeight;
+
+ //---------------------------------------------------------------
+ //! The class represents MED Gauss entity
+ struct MEDWRAPPER_EXPORT TGaussInfo:
+ virtual TNameInfo,
+ virtual TModeSwitchInfo
+ {
+ typedef boost::tuple<EGeometrieElement,std::string> TKey;
+ typedef boost::tuple<TKey,TInt> TInfo;
+ struct MEDWRAPPER_EXPORT TLess
+ {
+ bool
+ operator()(const TKey& theLeft, const TKey& theRight) const;
+
+ bool
+ operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
+ };
+
+ //! Defines, which geometrical type the MED Gauss entity belongs to
+ EGeometrieElement myGeom;
+ //! Find out what MED geometrical type the MED GAUSS entity belong to
+ EGeometrieElement GetGeom() const { return myGeom; }
+
+ //! Contains coordinates for the refereced nodes
+ TNodeCoord myRefCoord;
+
+ //! Gives coordinates for the referenced node by its number
+ TCCoordSlice GetRefCoordSlice(TInt theId) const;
+ //! Gives coordinates for the referenced node by its number
+ TCoordSlice GetRefCoordSlice(TInt theId);
+
+ //! Contains coordinates for the Gauss points
+ TNodeCoord myGaussCoord;
+
+ //! Gives coordinates for the Gauss points by its number
+ TCCoordSlice GetGaussCoordSlice(TInt theId) const;
+ //! Gives coordinates for the Gauss points by its number
+ TCoordSlice GetGaussCoordSlice(TInt theId);
+
+ //! Contains wheights for the Gauss points
+ TWeight myWeight;
+
+ //! Gives number of the referenced nodes
+ TInt GetNbRef() const { return GetNbRefCoord(GetGeom()); }
+
+ //! Gives dimension of the referenced nodes
+ TInt GetDim() const { return GetDimGaussCoord(GetGeom()); }
+
+ //! Gives number of the Gauss Points
+ TInt GetNbGauss() const { return (TInt)(myGaussCoord.size() / GetDim()); }
+ };
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
+ typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED TimeStamp
+ struct MEDWRAPPER_EXPORT TTimeStampInfo:
+ virtual TBase
+ {
+ PFieldInfo myFieldInfo; //!< A reference to correspondig MED Field
+ //! Get a reference to corresponding MED Field
+ const PFieldInfo& GetFieldInfo() const { return myFieldInfo; }
+
+ //! Defines the MED Entity where the MED TimeStamp belongs to
+ EEntiteMaillage myEntity;
+ //! Find out to what MED Entity the MED TimeStamp belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to
+ TGeom2Size myGeom2Size;
+ //! Get map of number of cells per geometric type where the MED TimeStamp belongs to
+ const TGeom2Size& GetGeom2Size() const { return myGeom2Size; }
+
+ TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp
+ TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp
+
+ TInt myNumDt; //!< Keeps number in time for the MED TimeStamp
+ TInt GetNumDt() const { return myNumDt; } //!< Defines number in time for the MED TimeStamp
+
+ TInt myNumOrd; //!< Keeps number for the MED TimeStamp
+ TInt GetNumOrd() const { return myNumOrd; } //!< Defines number for the MED TimeStamp
+
+ TFloat myDt; //!< Keeps time for the MED TimeStamp
+ TFloat GetDt() const { return myDt; } //!< Defines time for the MED TimeStamp
+
+ //! Keeps map of MED Gauss entityes per geometric type
+ TGeom2Gauss myGeom2Gauss;
+ //! Gets a map of MED Gauss entityes per geometric type
+ const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss; }
+
+ TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp
+ //! Get unit of time for the MED TimeStamp
+ virtual std::string GetUnitDt() const = 0;
+ //! Set unit of time for the MED TimeStamp
+ virtual void SetUnitDt(const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! The class represents MED Profile entity
+ struct MEDWRAPPER_EXPORT TProfileInfo:
+ virtual TNameInfo
+ {
+ typedef std::string TKey;
+ typedef boost::tuple<TKey,TInt> TInfo;
+
+ EModeProfil myMode; //!< Keeps mode for the MED Profile
+ //! Find out what mode of MED Profile is used
+ EModeProfil GetMode() const { return myMode; }
+ //! Set mode for the MED Profile
+ void SetMode(EModeProfil theMode) { myMode = theMode; }
+
+ PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
+ //! Get number of mesh elelemts by its order number
+ TInt GetElemNum(TInt theId) const;
+ //! Set number of mesh elelemts by its order number
+ void SetElemNum(TInt theId, TInt theVal);
+
+ //! Find out if the MED Profile defined
+ bool IsPresent() const { return GetName() != ""; }
+
+ //! Find out size of the MED Profile
+ TInt GetSize() const { return (TInt)myElemNum->size(); }
+ };
+
+ //---------------------------------------------------------------
+ //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
+ struct MEDWRAPPER_EXPORT TMeshValueBase:
+ virtual TModeSwitchInfo
+ {
+ TInt myNbElem;
+ TInt myNbComp;
+ TInt myNbGauss;
+ TInt myStep;
+
+ TMeshValueBase();
+
+ //! Initialize the class
+ void
+ Allocate(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Returns size of the value container
+ size_t
+ GetSize() const;
+
+ //! Returns MED interpetation of the value size
+ size_t
+ GetNbVal() const;
+
+ //! Returns number of Gauss Points bounded with the value
+ size_t
+ GetNbGauss() const;
+
+ //! Returns step inside of the data array
+ size_t
+ GetStep() const;
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ unsigned char*
+ GetValuePtr() = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
+ template<class TValueType>
+ struct TTMeshValue:
+ virtual TMeshValueBase
+ {
+ typedef TValueType TValue;
+ typedef typename TValueType::value_type TElement;
+
+ typedef TSlice<TElement> TValueSlice;
+ typedef TCSlice<TElement> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ TValue myValue;
+
+ //! Initialize the class
+ void
+ Allocate(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE)
+ {
+ TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode);
+ myValue.resize(theNbElem * this->GetStep());
+ }
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ unsigned char*
+ GetValuePtr()
+ {
+ return (unsigned char*)&myValue[0];
+ }
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ TElement*
+ GetPointer()
+ {
+ return &myValue[0];
+ }
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ const TElement*
+ GetPointer() const
+ {
+ return &myValue[0];
+ }
+
+ //! Iteration through Gauss Points by their components
+ TCValueSliceArr
+ GetGaussValueSliceArr(TInt theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(myNbGauss);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId * myStep;
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(myValue, std::slice(anId, myNbComp, 1));
+ anId += myNbComp;
+ }
+ }
+ else{
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
+ }
+ }
+ return aValueSliceArr;
+ }
+
+ //! Iteration through Gauss Points by their components
+ TValueSliceArr
+ GetGaussValueSliceArr(TInt theElemId)
+ {
+ TValueSliceArr aValueSliceArr(myNbGauss);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId*myStep;
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue, std::slice(anId, myNbComp, 1));
+ anId += myNbComp;
+ }
+ }
+ else{
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
+ }
+ }
+ return aValueSliceArr;
+ }
+
+ //! Iteration through components by corresponding Gauss Points
+ TCValueSliceArr
+ GetCompValueSliceArr(TInt theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(myNbComp);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId*myStep;
+ for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
+ anId += 1;
+ }
+ }
+ else{
+ for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep));
+ }
+ }
+ return aValueSliceArr;
+ }
+
+ //! Iteration through components by corresponding Gauss Points
+ TValueSliceArr
+ GetCompValueSliceArr(TInt theElemId)
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TValueSliceArr aValueSliceArr(myNbComp);
+ TInt anId = theElemId*myStep;
+ for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
+ else{
+ TValueSliceArr aValueSliceArr(myNbGauss);
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep));
+ }
+ return aValueSliceArr;
+ }
+ }
+ };
+
+ //---------------------------------------------------------------
+ typedef TTMeshValue<TFloatVector> TFloatMeshValue;
+ typedef TTMeshValue<TIntVector> TIntMeshValue;
+
+ //---------------------------------------------------------------
+ // Backward compatibility declarations
+ typedef TFloatVector TValue;
+ typedef TSlice<TFloat> TValueSlice;
+ typedef TCSlice<TFloat> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ typedef TFloatMeshValue TMeshValue;
+ typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
+ typedef std::set<EGeometrieElement> TGeom;
+
+ //---------------------------------------------------------------
+ //! The class is a base class for MED TimeStamp values holder
+ struct MEDWRAPPER_EXPORT TTimeStampValueBase:
+ virtual TModeSwitchInfo
+ {
+ //! A reference to correspondig MED TimeStamp
+ PTimeStampInfo myTimeStampInfo;
+ //!< Get a reference to correspondig MED TimeStamp
+ const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo; }
+
+ //! Keeps set of MED EGeometrieElement which contains values for the timestamp
+ TGeomSet myGeomSet;
+ const TGeomSet& GetGeomSet() const { return myGeomSet; }
+
+ //! Keeps map of MED Profiles per geometric type
+ TGeom2Profile myGeom2Profile;
+ //! Gets a map of MED Profiles per geometric type
+ const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile; }
+
+ //! Gets type of the champ
+ virtual
+ ETypeChamp
+ GetTypeChamp() const = 0;
+
+ //! Allocates values for the given geometry
+ virtual
+ void
+ AllocateValue(EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE) = 0;
+
+ virtual
+ size_t
+ GetValueSize(EGeometrieElement theGeom) const = 0;
+
+ virtual
+ size_t
+ GetNbVal(EGeometrieElement theGeom) const = 0;
+
+ virtual
+ size_t
+ GetNbGauss(EGeometrieElement theGeom) const = 0;
+
+ virtual
+ unsigned char*
+ GetValuePtr(EGeometrieElement theGeom) = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! The class implements a container for MED TimeStamp values
+ template<class TMeshValueType>
+ struct TTimeStampValue:
+ virtual TTimeStampValueBase
+ {
+ typedef TMeshValueType TTMeshValue;
+ typedef SharedPtr<TMeshValueType> PTMeshValue;
+ typedef typename TMeshValueType::TElement TElement;
+ typedef std::map<EGeometrieElement, PTMeshValue> TTGeom2Value;
+
+ ETypeChamp myTypeChamp; //<! Keeps type of the champ
+
+ //! Gets type of the champ
+ virtual
+ ETypeChamp
+ GetTypeChamp() const
+ {
+ return myTypeChamp;
+ }
+
+ //! Keeps map of MED TimeStamp values per geometric type (const version)
+ TTGeom2Value myGeom2Value;
+
+ const TTGeom2Value&
+ GetGeom2Value() const
+ {
+ return myGeom2Value;
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type (const version)
+ const PTMeshValue&
+ GetMeshValuePtr(EGeometrieElement theGeom) const
+ {
+ typename TTGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
+ if(anIter == myGeom2Value.end())
+ EXCEPTION(std::runtime_error,"TTimeStampValue::GetMeshValuePtr - myGeom2Value.find(theGeom) fails");
+ return anIter->second;
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type
+ PTMeshValue&
+ GetMeshValuePtr(EGeometrieElement theGeom)
+ {
+ myGeomSet.insert(theGeom);
+ if(myGeom2Value.find(theGeom) == myGeom2Value.end()){
+ myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue());
+ return myGeom2Value[theGeom];
+ }
+ return myGeom2Value[theGeom];
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type (const version)
+ const TTMeshValue&
+ GetMeshValue(EGeometrieElement theGeom) const
+ {
+ return *(this->GetMeshValuePtr(theGeom));
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type
+ TTMeshValue&
+ GetMeshValue(EGeometrieElement theGeom)
+ {
+ return *(this->GetMeshValuePtr(theGeom));
+ }
+ };
+
+ //---------------------------------------------------------------
+ typedef TTimeStampValue<TFloatMeshValue> TFloatTimeStampValue;
+ typedef SharedPtr<TFloatTimeStampValue> PFloatTimeStampValue;
+
+ PFloatTimeStampValue MEDWRAPPER_EXPORT
+ CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
+
+ typedef TTimeStampValue<TIntMeshValue> TIntTimeStampValue;
+ typedef SharedPtr<TIntTimeStampValue> PIntTimeStampValue;
+
+ PIntTimeStampValue MEDWRAPPER_EXPORT
+ CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
+
+ //---------------------------------------------------------------
+ template<class TMeshValueTypeFrom, class TMeshValueTypeTo>
+ void
+ CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueTypeFrom> > theTimeStampValueFrom,
+ SharedPtr<TTimeStampValue<TMeshValueTypeTo> > theTimeStampValueTo)
+ {
+ typedef TTimeStampValue<TMeshValueTypeFrom> TimeStampValueTypeFrom;
+ typedef TTimeStampValue<TMeshValueTypeTo> TimeStampValueTypeTo;
+ typedef typename TMeshValueTypeTo::TElement TElementTo;
+
+ typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
+ typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const EGeometrieElement& aGeom = anIter->first;
+ const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second;
+ typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
+ aMeshValue2.Allocate(aMeshValue.myNbElem,
+ aMeshValue.myNbGauss,
+ aMeshValue.myNbComp,
+ aMeshValue.myModeSwitch);
+ const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue;
+ typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue;
+ TInt aSize = aValue.size();
+ for(TInt anId = 0; anId < aSize; anId++)
+ aValue2[anId] = TElementTo(aValue[anId]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ template<class TMeshValueType>
+ void
+ CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueFrom,
+ SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueTo)
+ {
+ typedef TTimeStampValue<TMeshValueType> TimeStampValueType;
+ typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
+ typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const EGeometrieElement& aGeom = anIter->first;
+ const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second;
+ typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
+ aMeshValue2 = aMeshValue;
+ }
+ }
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom,
+ const PTimeStampValueBase& theValueTo)
+ {
+ if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){
+ if(theValueFrom->GetTypeChamp() == eFLOAT64)
+ CopyTimeStampValue<TFloatMeshValue>(theValueFrom, theValueTo);
+ else if(theValueFrom->GetTypeChamp() == eINT)
+ CopyTimeStampValue<TIntMeshValue>(theValueFrom, theValueTo);
+ }else{
+ if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT)
+ CopyTimeStampValue<TFloatMeshValue, TIntMeshValue>(theValueFrom, theValueTo);
+ else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64)
+ CopyTimeStampValue<TIntMeshValue, TFloatMeshValue>(theValueFrom, theValueTo);
+ }
+ }
+
+ //---------------------------------------------------------------
+ // Backward compatibility declarations
+ typedef TFloatTimeStampValue TTimeStampVal;
+ typedef PFloatTimeStampValue PTimeStampVal;
+
+ //---------------------------------------------------------------
+ typedef std::map<TInt,TFloatVector> TIndexes;
+ typedef std::map<TInt,TString> TNames;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Grille (structured mesh)
+ struct MEDWRAPPER_EXPORT TGrilleInfo:
+ virtual TModeSwitchInfo
+ {
+ PMeshInfo myMeshInfo;
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD
+ //! Gives coordinates for mesh nodes (const version)
+ const TNodeCoord& GetNodeCoord() const;
+ TNodeCoord& GetNodeCoord();
+ //! Gives coordinates for mesh node by its number, array index from 0
+ TNodeCoord GetCoord(TInt theId);
+ //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0
+ TIntVector GetConn(TInt theId, const bool isSub=false);
+
+ EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD)
+ //!Gets grille type (const version)
+ const EGrilleType& GetGrilleType() const;
+ //!Gets grille type
+ EGrilleType GetGrilleType();
+ //!Sets grille type
+ void SetGrilleType(EGrilleType theGrilleType);
+
+ TString myCoordNames; //!< Contains names for the coordinate dimensions
+ //! Get name of the coordinate dimension by its order number
+ virtual std::string GetCoordName(TInt theId) const = 0 ;
+ //! Set name of the coordinate dimension by its order number
+ virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
+
+ TString myCoordUnits; //!< Contains units for the coordinate dimensions
+ //! Get name of unit for the coordinate dimension by its order number
+ virtual std::string GetCoordUnit(TInt theId) const = 0;
+ //! Set name of unit for the coordinate dimension by its order number
+ virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
+
+ //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
+ TIndexes myIndixes;
+ //!Gets a map of Tables (const version)
+ const TIndexes& GetMapOfIndexes() const ;
+ //!Gets a map of Tables
+ TIndexes& GetMapOfIndexes();
+ //!Gets a Table of indexes for certain axe(const version)
+ const TFloatVector& GetIndexes(TInt theAxisNumber) const;
+ //!Gets a Table of indexes for certain axe
+ TFloatVector& GetIndexes(TInt theAxisNumber);
+ //!Gets a number of indices per axe
+ TInt GetNbIndexes(TInt theAxisNumber);
+
+ TInt GetNbNodes();//! Return count of all points
+ TInt GetNbCells();//! Return count of all cells
+ TInt GetNbSubCells();//! Return count of all entities of <mesh dimension-1>
+ EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension)
+ EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension)
+ EEntiteMaillage GetEntity();//! Return entity (eMAILLE)
+ EEntiteMaillage GetSubEntity();//! Return sub entity
+
+ /*!
+ *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...)
+ */
+ TIntVector myGrilleStructure;
+ //!Gets grille structure(const version)
+ const TIntVector& GetGrilleStructure() const;
+ //!Gets grille structure
+ TIntVector GetGrilleStructure();
+ //!Sets the grille structure of theAxis axe to theNb.
+ void SetGrilleStructure(TInt theAxis,TInt theNb);
+
+ /*!
+ *Defines sequence MED Family indexes for corresponding mesh entites
+ */
+ TElemNum myFamNum;
+ //! Get number of a MED FAMILY by order number of the mesh element
+ TInt GetFamNum(TInt theId) const;
+ //! Set number of a MED FAMILY for the mesh element with the order number
+ void SetFamNum(TInt theId, TInt theVal);
+
+ /*!
+ *Defines sequence MED Family indexes for sub entites
+ */
+ TElemNum myFamSubNum;
+ //! Get number of a MED FAMILY by order number of sub element
+ TInt GetFamSubNum(TInt theId) const;
+ //! Set number of a MED FAMILY for theId-th sub element
+ void SetFamSubNum(TInt theId, TInt theVal);
+
+ /*!
+ *Defines sequence MED Family indexes for corresponding mesh nodes
+ */
+ TElemNum myFamNumNode;
+ //! Get number of a MED FAMILY by order number of the mesh node
+ TInt GetFamNumNode(TInt theId) const;
+ //! Set number of a MED FAMILY for the mesh node with the order number
+ void SetFamNumNode(TInt theId, TInt theVal);
+ };
+}
+
+#endif // MED_Structures_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_TStructures_HeaderFile
+#define MED_TStructures_HeaderFile
+
+#include "MED_Structures.hxx"
+
+#ifdef WIN32
+#pragma warning(disable:4250)
+#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ //! To provide a common way to handle values of MEDWrapper types as native MED types
+ template<class TValue, class TRepresentation>
+ struct TValueHolder
+ {
+ TValue& myValue;
+ TRepresentation myRepresentation;
+
+ TValueHolder(TValue& theValue):
+ myValue(theValue),
+ myRepresentation(TRepresentation(theValue))
+ {}
+
+ ~TValueHolder()
+ {
+ myValue = TValue(myRepresentation);
+ }
+
+ TRepresentation*
+ operator& ()
+ {
+ return &myRepresentation;
+ }
+
+ operator TRepresentation () const
+ {
+ return myRepresentation;
+ }
+
+ const TValue&
+ operator() () const
+ {
+ return myValue;
+ }
+ };
+
+ //! To customize TValueHolder common template definition for TVector
+ template<class TVal, class TRepresentation>
+ struct TValueHolder<TVector<TVal>, TRepresentation>
+ {
+ typedef TVector<TVal> TValue;
+ TValue& myValue;
+ TRepresentation* myRepresentation;
+
+ TValueHolder(TValue& theValue):
+ myValue(theValue)
+ {
+ if(theValue.empty())
+ myRepresentation = (TRepresentation*)NULL;
+ else
+ myRepresentation = (TRepresentation*)&theValue[0];
+ }
+
+ TRepresentation*
+ operator& ()
+ {
+ return myRepresentation;
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTNameInfo: virtual TNameInfo
+ {
+ TTNameInfo(const std::string& theValue)
+ {
+ myName.resize(GetNOMLength()+1);
+ SetName(theValue);
+ }
+
+ virtual
+ std::string
+ GetName() const
+ {
+ return GetString(0, GetNOMLength(), myName);
+ }
+
+ virtual
+ void
+ SetName(const std::string& theValue)
+ {
+ SetString(0, GetNOMLength(), myName, theValue);
+ }
+
+ virtual
+ void
+ SetName(const TString& theValue)
+ {
+ SetString(0, GetNOMLength(), myName, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTMeshInfo:
+ virtual TMeshInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTMeshInfo(const PMeshInfo& theInfo):
+ TNameInfoBase(theInfo->GetName())
+ {
+ myDim = theInfo->GetDim();
+ mySpaceDim = theInfo->GetSpaceDim();
+ myType = theInfo->GetType();
+
+ myDesc.resize(GetDESCLength()+1);
+ SetDesc(theInfo->GetDesc());
+ }
+
+ TTMeshInfo(TInt theDim, TInt theSpaceDim,
+ const std::string& theValue,
+ EMaillage theType,
+ const std::string& theDesc):
+ TNameInfoBase(theValue)
+ {
+ myDim = theDim;
+ mySpaceDim = theSpaceDim;
+ myType = theType;
+
+ myDesc.resize(GetDESCLength()+1);
+ SetDesc(theDesc);
+ }
+
+ virtual
+ std::string
+ GetDesc() const
+ {
+ return GetString(0, GetDESCLength(), myDesc);
+ }
+
+ virtual
+ void
+ SetDesc(const std::string& theValue)
+ {
+ SetString(0, GetDESCLength(), myDesc, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTFamilyInfo:
+ virtual TFamilyInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo):
+ TNameInfoBase(theInfo->GetName())
+ {
+ myMeshInfo = theMeshInfo;
+
+ myId = theInfo->GetId();
+
+ myNbGroup = theInfo->GetNbGroup();
+ myGroupNames.resize(myNbGroup*GetLNOMLength()+1);
+ if(myNbGroup){
+ for(TInt anId = 0; anId < myNbGroup; anId++){
+ SetGroupName(anId,theInfo->GetGroupName(anId));
+ }
+ }
+
+ myNbAttr = theInfo->GetNbAttr();
+ myAttrId.resize(myNbAttr);
+ myAttrVal.resize(myNbAttr);
+ myAttrDesc.resize(myNbAttr*GetDESCLength()+1);
+ if(myNbAttr){
+ for(TInt anId = 0; anId < myNbAttr; anId++){
+ SetAttrDesc(anId,theInfo->GetAttrDesc(anId));
+ myAttrVal[anId] = theInfo->GetAttrVal(anId);
+ myAttrId[anId] = theInfo->GetAttrId(anId);
+ }
+ }
+ }
+
+ TTFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbGroup,
+ TInt theNbAttr,
+ TInt theId,
+ const std::string& theValue):
+ TNameInfoBase(theValue)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myId = theId;
+
+ myNbGroup = theNbGroup;
+ myGroupNames.resize(theNbGroup*GetLNOMLength()+1);
+
+ myNbAttr = theNbAttr;
+ myAttrId.resize(theNbAttr);
+ myAttrVal.resize(theNbAttr);
+ myAttrDesc.resize(theNbAttr*GetDESCLength()+1);
+ }
+
+ TTFamilyInfo(const PMeshInfo& theMeshInfo,
+ const std::string& theValue,
+ TInt theId,
+ const TStringSet& theGroupNames,
+ const TStringVector& theAttrDescs,
+ const TIntVector& theAttrIds,
+ const TIntVector& theAttrVals):
+ TNameInfoBase(theValue)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myId = theId;
+
+ myNbGroup = (TInt)theGroupNames.size();
+ myGroupNames.resize(myNbGroup*GetLNOMLength()+1);
+ if(myNbGroup){
+ TStringSet::const_iterator anIter = theGroupNames.begin();
+ for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){
+ const std::string& aVal = *anIter;
+ SetGroupName(anId,aVal);
+ }
+ }
+
+ myNbAttr = (TInt)theAttrDescs.size();
+ myAttrId.resize(myNbAttr);
+ myAttrVal.resize(myNbAttr);
+ myAttrDesc.resize(myNbAttr*GetDESCLength()+1);
+ if(myNbAttr){
+ for(TInt anId = 0, anEnd = (TInt)theAttrDescs.size(); anId < anEnd; anId++){
+ SetAttrDesc(anId,theAttrDescs[anId]);
+ myAttrVal[anId] = theAttrVals[anId];
+ myAttrId[anId] = theAttrIds[anId];
+ }
+ }
+ }
+
+ virtual
+ std::string
+ GetGroupName(TInt theId) const
+ {
+ return GetString(theId, GetLNOMLength(), myGroupNames);
+ }
+
+ virtual
+ void
+ SetGroupName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId, GetLNOMLength(), myGroupNames, theValue);
+ }
+
+ virtual
+ std::string
+ GetAttrDesc(TInt theId) const
+ {
+ return GetString(theId, GetDESCLength(), myAttrDesc);
+ }
+
+ virtual
+ void
+ SetAttrDesc(TInt theId, const std::string& theValue)
+ {
+ SetString(theId, GetDESCLength(), myAttrDesc, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTElemInfo: virtual TElemInfo
+ {
+ TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbElem = theInfo->GetNbElem();
+ myFamNum.reset(new TElemNum(myNbElem));
+ myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
+
+ myIsElemNum = theInfo->IsElemNum();
+ if(theInfo->IsElemNum())
+ myElemNum.reset(new TElemNum(myNbElem));
+ else
+ myElemNum.reset(new TElemNum());
+
+ myIsElemNames = theInfo->IsElemNames();
+ if(theInfo->IsElemNames())
+ myElemNames.reset(new TString(myNbElem*GetPNOMLength() + 1));
+ else
+ myElemNames.reset(new TString());
+
+ if(theInfo->GetNbElem()){
+ for(TInt anId = 0; anId < myNbElem; anId++){
+ SetFamNum(anId, theInfo->GetFamNum(anId));
+ }
+ if(theInfo->IsElemNum() == eVRAI){
+ for(TInt anId = 0; anId < myNbElem; anId++){
+ SetElemNum(anId, theInfo->GetElemNum(anId));
+ }
+ }
+ if(theInfo->IsElemNames() == eVRAI){
+ for(TInt anId = 0; anId < myNbElem; anId++){
+ SetElemName(anId,theInfo->GetElemName(anId));
+ }
+ }
+ }
+ }
+
+ TTElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbElem = theNbElem;
+ myFamNum.reset(new TElemNum(theNbElem));
+ myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
+
+ myIsElemNum = theIsElemNum;
+ if(theIsElemNum)
+ myElemNum.reset(new TElemNum(theNbElem));
+ else
+ myElemNum.reset(new TElemNum());
+
+ myIsElemNames = theIsElemNames;
+ if(theIsElemNames)
+ myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1));
+ else
+ myElemNames.reset(new TString());
+ }
+
+ TTElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbElem = theNbElem;
+ myFamNum.reset(new TElemNum(theNbElem));
+ myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
+
+ myIsElemNum = theElemNums.size()? eVRAI: eFAUX;
+ if(myIsElemNum)
+ myElemNum.reset(new TElemNum(theNbElem));
+ else
+ myElemNum.reset(new TElemNum());
+
+ myIsElemNames = theElemNames.size()? eVRAI: eFAUX;
+ if(myIsElemNames)
+ myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1));
+ else
+ myElemNames.reset(new TString());
+
+ if(theNbElem){
+
+ if(theFamilyNums.size())
+ *myFamNum = theFamilyNums;
+
+ if(myIsElemNum)
+ *myElemNum = theElemNums;
+
+ if(myIsElemNames){
+ for(TInt anId = 0; anId < theNbElem; anId++){
+ const std::string& aVal = theElemNames[anId];
+ SetElemName(anId,aVal);
+ }
+ }
+ }
+ }
+
+ virtual
+ std::string
+ GetElemName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(), *myElemNames);
+ }
+
+ virtual
+ void
+ SetElemName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(), *myElemNames, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTNodeInfo:
+ virtual TNodeInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo):
+ TNodeInfo(theInfo),
+ TElemInfoBase(theMeshInfo, theInfo)
+ {
+ myModeSwitch = theInfo->GetModeSwitch();
+
+ mySystem = theInfo->GetSystem();
+
+ myCoord.reset(new TNodeCoord(*theInfo->myCoord));
+
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordName(anId,theInfo->GetCoordName(anId));
+
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordUnit(anId,theInfo->GetCoordUnit(anId));
+ }
+
+ TTNodeInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EModeSwitch theMode,
+ ERepere theSystem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ mySystem = theSystem;
+
+ myCoord.reset(new TNodeCoord(theNbElem * theMeshInfo->mySpaceDim));
+
+ myCoordUnits.resize(theMeshInfo->mySpaceDim*GetPNOMLength()+1);
+
+ myCoordNames.resize(theMeshInfo->mySpaceDim*GetPNOMLength()+1);
+ }
+
+
+ TTNodeInfo(const PMeshInfo& theMeshInfo,
+ const TFloatVector& theNodeCoords,
+ EModeSwitch theMode,
+ ERepere theSystem,
+ const TStringVector& theCoordNames,
+ const TStringVector& theCoordUnits,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ (TInt)theNodeCoords.size()/theMeshInfo->GetDim(),
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ mySystem = theSystem;
+
+ myCoord.reset(new TNodeCoord(theNodeCoords));
+
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ if(!theCoordNames.empty())
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordName(anId,theCoordNames[anId]);
+
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength() + 1);
+ if(!theCoordUnits.empty())
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordUnit(anId, theCoordUnits[anId]);
+ }
+
+ virtual
+ std::string
+ GetCoordName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordNames);
+ }
+
+ virtual
+ void
+ SetCoordName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordNames,theValue);
+ }
+
+ virtual
+ std::string
+ GetCoordUnit(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordUnits);
+ }
+
+ virtual
+ void
+ SetCoordUnit(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordUnits,theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTPolygoneInfo:
+ virtual TPolygoneInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo):
+ TElemInfoBase(theMeshInfo,theInfo)
+ {
+ myEntity = theInfo->GetEntity();
+ myGeom = theInfo->GetGeom();
+
+ myIndex.reset(new TElemNum(*theInfo->myIndex));
+ myConn.reset(new TElemNum(*theInfo->myConn));
+
+ myConnMode = theInfo->GetConnMode();
+ }
+
+ TTPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theConnSize,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames):
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theNbElem + 1));
+ myConn.reset(new TElemNum(theConnSize));
+
+ myConnMode = theConnMode;
+ }
+
+ TTPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames):
+ TElemInfoBase(theMeshInfo,
+ (TInt)theIndexes.size() - 1,
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theIndexes));
+ myConn.reset(new TElemNum(theConnectivities));
+
+ myConnMode = theConnMode;
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTPolyedreInfo:
+ virtual TPolyedreInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo):
+ TElemInfoBase(theMeshInfo,theInfo)
+ {
+ myEntity = theInfo->GetEntity();
+ myGeom = theInfo->GetGeom();
+
+ myIndex.reset(new TElemNum(*theInfo->myIndex));
+ myFaces.reset(new TElemNum(*theInfo->myFaces));
+ myConn.reset(new TElemNum(*theInfo->myConn));
+
+ myConnMode = theInfo->GetConnMode();
+ }
+
+ TTPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbFaces,
+ TInt theConnSize,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames):
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theNbElem + 1));
+ myFaces.reset(new TElemNum(theNbFaces));
+ myConn.reset(new TElemNum(theConnSize));
+
+ myConnMode = theConnMode;
+ }
+
+ TTPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theFaces,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames):
+ TElemInfoBase(theMeshInfo,
+ (TInt)theIndexes.size()-1,
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theIndexes));
+ myFaces.reset(new TElemNum(theFaces));
+ myConn.reset(new TElemNum(theConnectivities));
+
+ myConnMode = theConnMode;
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTCellInfo:
+ virtual TCellInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo):
+ TElemInfoBase(theMeshInfo,theInfo)
+ {
+ myEntity = theInfo->GetEntity();
+ myGeom = theInfo->GetGeom();
+ myConnMode = theInfo->GetConnMode();
+
+ TInt aConnDim = GetNbNodes(myGeom);
+ TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
+ myConn.reset(new TElemNum(myNbElem * aNbConn));
+ for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
+ TConnSlice aConnSlice = GetConnSlice(anElemId);
+ TCConnSlice aConnSlice2 = theInfo->GetConnSlice(anElemId);
+ for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
+ aConnSlice[anConnId] = aConnSlice2[anConnId];
+ }
+ }
+ }
+
+ TTCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myConnMode = theConnMode;
+ TInt aNbConn = GetNbConn(theGeom, myEntity, theMeshInfo->myDim);
+ myConn.reset(new TElemNum(theNbElem * aNbConn));
+ }
+
+ TTCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ (TInt)theConnectivities.size() / GetNbNodes(theGeom),
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myConnMode = theConnMode;
+ TInt aConnDim = GetNbNodes(myGeom);
+ TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
+ myConn.reset(new TElemNum(myNbElem * aNbConn));
+ for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
+ TConnSlice aConnSlice = GetConnSlice(anElemId);
+ for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
+ aConnSlice[anConnId] = theConnectivities[anElemId*aConnDim + anConnId];
+ }
+ }
+ }
+
+ virtual
+ TInt
+ GetConnDim() const
+ {
+ return GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
+ }
+
+ };
+
+ //---------------------------------------------------------------
+ struct TTBallInfo:
+ virtual TBallInfo,
+ virtual TTCellInfo
+ {
+ typedef TTCellInfo TCellInfoBase;
+
+ TTBallInfo(const PMeshInfo& theMeshInfo, const PBallInfo& theInfo):
+ TCellInfoBase::TElemInfoBase(theMeshInfo, theInfo),
+ TCellInfoBase(theMeshInfo,theInfo)
+ {
+ myDiameters = theInfo->myDiameters;
+ }
+
+ TTBallInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum ):
+ TCellInfoBase::TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ /*theIsElemNames=*/eFAUX),
+ TCellInfoBase(theMeshInfo,
+ eSTRUCT_ELEMENT,
+ eBALL,
+ theNbElem,
+ /*EConnectivite=*/eNOD,
+ theIsElemNum,
+ /*theIsElemNames=*/eFAUX,
+ eFULL_INTERLACE)
+ {
+ myDiameters.resize( theNbElem );
+ }
+
+ TTBallInfo(const PMeshInfo& theMeshInfo,
+ const TIntVector& theNodes,
+ TFloatVector& theDiameters,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums):
+ TCellInfoBase::TElemInfoBase(theMeshInfo,
+ (TInt)std::max(theNodes.size(),theDiameters.size() ),
+ theFamilyNums,
+ theElemNums,
+ TStringVector()),
+ TCellInfoBase(theMeshInfo,
+ eSTRUCT_ELEMENT,
+ eBALL,
+ theNodes,
+ /*EConnectivite=*/eNOD,
+ theFamilyNums,
+ theElemNums,
+ TStringVector(),
+ eFULL_INTERLACE)
+ {
+ myDiameters.swap( theDiameters );
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTFieldInfo:
+ virtual TFieldInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo):
+ TNameInfoBase(theInfo->GetName())
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbComp = theInfo->GetNbComp();
+ myCompNames.resize(myNbComp*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < myNbComp; anId++){
+ SetCompName(anId,theInfo->GetCompName(anId));
+ }
+
+ myUnitNames.resize(myNbComp*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < myNbComp; anId++){
+ SetUnitName(anId,theInfo->GetUnitName(anId));
+ }
+
+ myType = theInfo->GetType();
+
+ myIsLocal = theInfo->GetIsLocal();
+ myNbRef = theInfo->GetNbRef();
+ }
+
+ TTFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbComp,
+ ETypeChamp theType,
+ const std::string& theValue,
+ EBooleen theIsLocal,
+ TInt theNbRef):
+ TNameInfoBase(theValue)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbComp = theNbComp;
+ myCompNames.resize(theNbComp*GetPNOMLength()+1);
+ myUnitNames.resize(theNbComp*GetPNOMLength()+1);
+
+ myType = theType;
+
+ myIsLocal = theIsLocal;
+ myNbRef = theNbRef;
+ }
+
+ virtual
+ std::string
+ GetCompName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCompNames);
+ }
+
+ virtual
+ void
+ SetCompName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCompNames,theValue);
+ }
+
+ virtual
+ std::string
+ GetUnitName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myUnitNames);
+ }
+
+ virtual
+ void
+ SetUnitName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myUnitNames,theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTGaussInfo:
+ virtual TGaussInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTGaussInfo(const TGaussInfo::TInfo& theInfo,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode),
+ TNameInfoBase(boost::get<1>(boost::get<0>(theInfo)))
+ {
+ const TGaussInfo::TKey& aKey = boost::get<0>(theInfo);
+
+ myGeom = boost::get<0>(aKey);
+ myRefCoord.resize(GetNbRef()*GetDim());
+
+ TInt aNbGauss = boost::get<1>(theInfo);
+ myGaussCoord.resize(aNbGauss*GetDim());
+ myWeight.resize(aNbGauss);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTTimeStampInfo: virtual TTimeStampInfo
+ {
+ TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo)
+ {
+ myFieldInfo = theFieldInfo;
+
+ myEntity = theInfo->GetEntity();
+ myGeom2Size = theInfo->GetGeom2Size();
+
+ myNumDt = theInfo->GetNumDt();
+ myNumOrd = theInfo->GetNumOrd();
+ myDt = theInfo->GetDt();
+
+ myUnitDt.resize(GetPNOMLength()+1);
+ SetUnitDt(theInfo->GetUnitDt());
+
+ myGeom2NbGauss = theInfo->myGeom2NbGauss;
+ myGeom2Gauss = theInfo->GetGeom2Gauss();
+ }
+
+ TTTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
+ const TGeom2NbGauss& theGeom2NbGauss,
+ TInt theNumDt,
+ TInt theNumOrd,
+ TFloat theDt,
+ const std::string& theUnitDt,
+ const TGeom2Gauss& theGeom2Gauss)
+ {
+ myFieldInfo = theFieldInfo;
+
+ myEntity = theEntity;
+ myGeom2Size = theGeom2Size;
+
+ myNumDt = theNumDt;
+ myNumOrd = theNumDt;
+ myDt = theDt;
+
+ myUnitDt.resize(GetPNOMLength()+1);
+ SetUnitDt(theUnitDt);
+
+ myGeom2NbGauss = theGeom2NbGauss;
+ myGeom2Gauss = theGeom2Gauss;
+ }
+
+ virtual
+ std::string
+ GetUnitDt() const
+ {
+ return GetString(0,GetPNOMLength(),myUnitDt);
+ }
+
+ virtual
+ void
+ SetUnitDt(const std::string& theValue)
+ {
+ SetString(0,GetPNOMLength(),myUnitDt,theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTProfileInfo:
+ virtual TProfileInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTProfileInfo(const TProfileInfo::TInfo& theInfo,
+ EModeProfil theMode):
+ TNameInfoBase(boost::get<0>(theInfo))
+ {
+ TInt aSize = boost::get<1>(theInfo);
+ myElemNum.reset(new TElemNum(aSize));
+ myMode = aSize > 0? theMode: eNO_PFLMOD;
+ }
+ };
+
+ //---------------------------------------------------------------
+ template<class TMeshValueType>
+ struct TTTimeStampValue: virtual TTimeStampValue<TMeshValueType>
+ {
+ TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampValueBase& theInfo,
+ ETypeChamp theTypeChamp)
+ {
+ typedef TTimeStampValue<TMeshValueType> TCompatible;
+ if(TCompatible* aCompatible = dynamic_cast<TCompatible*>(theInfo.get())){
+ this->myTimeStampInfo = theTimeStampInfo;
+ this->myTypeChamp = theTypeChamp;
+ this->myGeom2Profile = aCompatible->GetGeom2Profile();
+ this->myGeom2Value = aCompatible->myGeom2Value;
+ this->myGeomSet = aCompatible->GetGeomSet();
+ }else
+ EXCEPTION(std::runtime_error,"TTTimeStampValue::TTTimeStampValue - use incompatible arguments!");
+ }
+
+ TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ ETypeChamp theTypeChamp,
+ const TGeom2Profile& theGeom2Profile,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode)
+ {
+ this->myTimeStampInfo = theTimeStampInfo;
+
+ this->myTypeChamp = theTypeChamp;
+
+ this->myGeom2Profile = theGeom2Profile;
+
+ TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp;
+
+ const TGeom2Size& aGeom2Size = theTimeStampInfo->GetGeom2Size();
+ TGeom2Size::const_iterator anIter = aGeom2Size.begin();
+ for(; anIter != aGeom2Size.end(); anIter++){
+ const EGeometrieElement& aGeom = anIter->first;
+ TInt aNbElem = anIter->second;
+
+ MED::PProfileInfo aProfileInfo;
+ MED::TGeom2Profile::const_iterator anIter = theGeom2Profile.find(aGeom);
+ if(anIter != theGeom2Profile.end())
+ aProfileInfo = anIter->second;
+
+ if(aProfileInfo && aProfileInfo->IsPresent())
+ aNbElem = aProfileInfo->GetSize();
+
+ TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom);
+
+ this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp);
+ }
+ }
+
+ virtual
+ size_t
+ GetValueSize(EGeometrieElement theGeom) const
+ {
+ return this->GetMeshValue(theGeom).GetSize();
+ }
+
+ virtual
+ size_t
+ GetNbVal(EGeometrieElement theGeom) const
+ {
+ return this->GetMeshValue(theGeom).GetNbVal();
+ }
+
+ virtual
+ size_t
+ GetNbGauss(EGeometrieElement theGeom) const
+ {
+ return this->GetMeshValue(theGeom).GetNbGauss();
+ }
+
+ virtual
+ void
+ AllocateValue(EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE)
+ {
+ this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode);
+ }
+
+ virtual
+ unsigned char*
+ GetValuePtr(EGeometrieElement theGeom)
+ {
+ return this->GetMeshValue(theGeom).GetValuePtr();
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTGrilleInfo:
+ virtual TGrilleInfo
+ {
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const PGrilleInfo& theInfo)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myCoord = theInfo->GetNodeCoord();
+
+ myGrilleType = theInfo->GetGrilleType();
+
+ myCoordNames = theInfo->myCoordNames;
+
+ myCoordUnits = theInfo->myCoordUnits;
+
+ myIndixes = theInfo->GetMapOfIndexes();
+
+ myGrilleStructure = theInfo->GetGrilleStructure();
+
+ myGrilleType = theInfo->GetGrilleType();
+
+ myFamNumNode.resize(theInfo->GetNbNodes());
+ myFamNumNode = theInfo->myFamNumNode;
+
+ myFamNum = theInfo->myFamNum;
+ }
+
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const TInt nnoeuds)
+ {
+ myMeshInfo = theMeshInfo;
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+ if(type == eGRILLE_STANDARD){
+ myCoord.resize(aSpaceDim*nnoeuds);
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ } else { //if(type == eGRILLE_CARTESIENNE){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ }
+ myGrilleStructure.resize(aSpaceDim);
+ myFamNumNode.resize(nnoeuds);
+ }
+
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type)
+ {
+ myMeshInfo = theMeshInfo;
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+ if(type == eGRILLE_STANDARD){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ } else {// if(type == eGRILLE_CARTESIENNE){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ }
+ myGrilleStructure.resize(aSpaceDim);
+ }
+
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const MED::TIntVector& nbNodeVec)
+ {
+ myMeshInfo = theMeshInfo;
+
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+ if(type == eGRILLE_STANDARD){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ } else {// if(type == eGRILLE_CARTESIENNE){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ }
+
+ if(type != eGRILLE_STANDARD)
+ for(unsigned int aAxe=0;aAxe<nbNodeVec.size();aAxe++){
+ myIndixes[aAxe].resize(nbNodeVec[aAxe]);
+ }
+ myGrilleStructure.resize(aSpaceDim);
+ }
+
+ virtual
+ std::string
+ GetCoordName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordNames);
+ }
+
+ virtual
+ void
+ SetCoordName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordNames,theValue);
+ }
+
+ virtual
+ std::string
+ GetCoordUnit(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordUnits);
+ }
+
+ virtual
+ void
+ SetCoordUnit(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordUnits,theValue);
+ }
+ };
+}
+
+#endif // MED_TStructures_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_Utilities.hxx"
+#include "MED_Common.hxx"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+int MED::PrefixPrinter::myCounter = 0;
+
+MED::PrefixPrinter::PrefixPrinter(bool theIsActive):
+ myIsActive(theIsActive)
+{
+ if(myIsActive)
+ myCounter++;
+ MSG(MYDEBUG,"MED::PrefixPrinter::PrefixPrinter(...)- "<<myCounter);
+}
+
+MED::PrefixPrinter::~PrefixPrinter()
+{
+ if(myIsActive){
+ myCounter--;
+ if(myCounter < 0)
+ EXCEPTION(std::runtime_error,"PrefixPrinter::~PrefixPrinter() - myCounter("<<myCounter<<") < 0");
+ }
+}
+
+std::string MED::PrefixPrinter::GetPrefix()
+{
+ if(myCounter){
+ if(myCounter < 0)
+ EXCEPTION(std::runtime_error,"PrefixPrinter::~PrefixPrinter() - myCounter("<<myCounter<<") < 0");
+ return std::string(myCounter*2,' ');
+ }
+ return "";
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Utilities_HeaderFile
+#define MED_Utilities_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <string.h>
+#include <stdexcept>
+
+namespace MED
+{
+ class MEDWRAPPER_EXPORT PrefixPrinter
+ {
+ static int myCounter;
+ bool myIsActive;
+ public:
+ PrefixPrinter(bool theIsActive = true);
+ ~PrefixPrinter();
+
+ static std::string GetPrefix();
+ };
+}
+
+#ifdef _DEBUG_
+ #define MSG(deb,msg) if(deb) std::cout<<MED::PrefixPrinter::GetPrefix()<<msg<<" ("<<__FILE__<<" ["<<__LINE__<<"])\n"
+ #define BEGMSG(deb,msg) if(deb) std::cout<<MED::PrefixPrinter::GetPrefix()<<msg
+ #define INITMSGA(deb,lev,msg) MED::PrefixPrinter aPrefixPrinter_##lev(deb); BEGMSG(deb,msg)
+ #define INITMSG(deb,msg) INITMSGA(deb,,msg)
+ #define ADDMSG(deb,msg) if(deb) std::cout<<msg
+#else // _DEBUG_
+ #define MSG(deb,msg)
+ #define BEGMSG(deb,msg)
+ #define INITMSGA(deb,lev,msg)
+ #define INITMSG(deb,msg)
+ #define ADDMSG(deb,msg)
+#endif // _DEBUG_
+
+#ifndef EXCEPTION
+
+#define EXCEPTION(TYPE, MSG) {\
+ std::ostringstream aStream;\
+ aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
+ throw TYPE(aStream.str().c_str());\
+}
+
+#endif // EXCEPTION
+
+#endif // MED_Utilities_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Vector_HeaderFile
+#define MED_Vector_HeaderFile
+
+#include <vector>
+#include <stdexcept>
+
+//#if defined(_DEBUG_)
+# define MED_TVECTOR_CHECK_RANGE
+//#endif
+
+namespace MED
+{
+ //! Main purpose to introduce the class was to customize operator []
+ template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
+ class TVector : public std::vector<_Tp, _Alloc>
+ {
+ public:
+ typedef size_t size_type;
+
+ typedef std::vector<_Tp, _Alloc> superclass;
+ typedef typename superclass::allocator_type allocator_type;
+
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+
+ protected:
+ void
+ check_range(size_type __n) const
+ {
+ if (__n >= this->size())
+ throw std::out_of_range("TVector [] access out of range");
+ }
+
+ const_reference
+ get_value(size_type __n) const
+ {
+ return superclass::operator[](__n);
+ }
+
+ reference
+ get_value(size_type __n)
+ {
+ return superclass::operator[](__n);
+ }
+
+ public:
+ explicit
+ TVector(const allocator_type& __a = allocator_type()):
+ superclass(__a)
+ {}
+
+ TVector(size_type __n, const value_type& __val,
+ const allocator_type& __a = allocator_type()):
+ superclass(__n, __val, __a)
+ {}
+
+ explicit
+ TVector(size_type __n):
+ superclass(__n)
+ {}
+
+ TVector(const TVector& __x):
+ superclass(__x)
+ {}
+
+ template<typename _InputIterator>
+ TVector(_InputIterator __first, _InputIterator __last,
+ const allocator_type& __a = allocator_type()):
+ superclass(__first, __last, __a)
+ {}
+
+ template<typename _Yp, typename _Al>
+ TVector(TVector<_Yp, _Al> __y):
+ superclass(__y.begin(), __y.end())
+ {}
+
+ TVector&
+ operator=(const TVector& __x)
+ {
+ superclass::operator=(__x);
+ return *this;
+ }
+
+ template<typename _Yp, typename _Al>
+ TVector&
+ operator=(TVector<_Yp, _Al> __y)
+ {
+ this->assign(__y.begin(), __y.end());
+ return *this;
+ }
+
+ reference
+ operator[](size_type __n)
+ {
+#if defined(MED_TVECTOR_CHECK_RANGE)
+ check_range(__n);
+#endif
+ return get_value(__n);
+ }
+
+ const_reference
+ operator[](size_type __n) const
+ {
+#if defined(MED_TVECTOR_CHECK_RANGE)
+ check_range(__n);
+#endif
+ return get_value(__n);
+ }
+
+ reference
+ at(size_type __n)
+ {
+ check_range(__n);
+ return get_value(__n);
+ }
+
+ const_reference
+ at(size_type __n) const
+ {
+ check_range(__n);
+ return get_value(__n);
+ }
+ };
+}
+
+#undef MED_TVECTOR_CHECK_RANGE
+
+#endif // MED_Vector_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "MED_Wrapper.hxx"
+#include "MED_TStructures.hxx"
+#include "MED_Utilities.hxx"
+
+#include <med.h>
+#include <med_err.h>
+
+#include <boost/version.hpp>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+static int MYVALUEDEBUG = 0;
+#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ TLockProxy
+ ::TLockProxy(TWrapper* theWrapper):
+ myWrapper(theWrapper)
+ {
+#if BOOST_VERSION >= 103500
+ myWrapper->myMutex.lock();
+#else
+ boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
+#endif
+ INITMSG(MYDEBUG, "TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
+ }
+
+ TLockProxy
+ ::~TLockProxy()
+ {
+ INITMSG(MYDEBUG, "~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
+#if BOOST_VERSION >= 103500
+ myWrapper->myMutex.unlock();
+#else
+ boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
+#endif
+ }
+
+ TWrapper*
+ TLockProxy
+ ::operator->() const // never throws
+ {
+ return myWrapper;
+ }
+
+ //---------------------------------------------------------------
+ class TFile
+ {
+ TFile();
+ TFile(const TFile&);
+
+ public:
+ TFile(const std::string& theFileName):
+ myCount(0),
+ myFid(0),
+ myFileName(theFileName)
+ {}
+
+ ~TFile()
+ {
+ Close();
+ }
+
+ void
+ Open(EModeAcces theMode,
+ TErr* theErr = NULL)
+ {
+ if (myCount++ == 0) {
+ const char* aFileName = myFileName.c_str();
+ myFid = MEDfileOpen(aFileName, med_access_mode(theMode));
+ }
+ if (theErr)
+ *theErr = TErr(myFid);
+ else if (myFid < 0)
+ EXCEPTION(std::runtime_error, "TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
+ }
+
+ const TIdt&
+ Id() const
+ {
+ if (myFid < 0)
+ EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
+ return myFid;
+ }
+
+ void
+ Close()
+ {
+ if (--myCount == 0)
+ MEDfileClose(myFid);
+ }
+
+ protected:
+ TInt myCount;
+ TIdt myFid;
+ std::string myFileName;
+ };
+
+ //---------------------------------------------------------------
+ class TFileWrapper
+ {
+ PFile myFile;
+
+ public:
+ TFileWrapper(const PFile& theFile,
+ EModeAcces theMode,
+ TErr* theErr = NULL):
+ myFile(theFile)
+ {
+ myFile->Open(theMode, theErr);
+ }
+
+ ~TFileWrapper()
+ {
+ myFile->Close();
+ }
+ };
+
+ //----------------------------------------------------------------------------
+ template<class TimeStampValueType>
+ void
+ Print(SharedPtr<TimeStampValueType> theTimeStampValue)
+ {
+ INITMSG(MYDEBUG,"Print - TimeStampValue\n");
+ typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
+ typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for (; anIter != aGeom2Value.end(); anIter++) {
+ const EGeometrieElement& aGeom = anIter->first;
+ const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
+ TInt aNbElem = aMeshValue.myNbElem;
+ TInt aNbGauss = aMeshValue.myNbGauss;
+ TInt aNbComp = aMeshValue.myNbComp;
+ INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr =
+ aMeshValue.GetGaussValueSliceArr(iElem);
+ ADDMSG(MYVALUEDEBUG, "{");
+ for (TInt iGauss = 0; iGauss < aNbGauss; iGauss++) {
+ const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice =
+ aValueSliceArr[iGauss];
+ for (TInt iComp = 0; iComp < aNbComp; iComp++) {
+ ADDMSG(MYVALUEDEBUG, aValueSlice[iComp]<<" ");
+ }
+ ADDMSG(MYVALUEDEBUG, "| ");
+ }
+ ADDMSG(MYVALUEDEBUG, "} ");
+ }
+ ADDMSG(MYDEBUG, "\n");
+ }
+ }
+
+ //---------------------------------------------------------------
+ TWrapper
+ ::TWrapper(const std::string& theFileName):
+ myFile(new TFile(theFileName))
+ {
+ TErr aRet;
+ myFile->Open(eLECTURE_ECRITURE, &aRet);
+ // if (aRet < 0)
+ // myFile->Close();
+ // myFile->Open(eLECTURE_AJOUT, &aRet);
+ // }
+ if (aRet < 0) {
+ myFile->Close();
+ myFile->Open(eLECTURE, &aRet);
+ }
+ if (aRet < 0) {
+ myFile->Close();
+ myFile->Open(eCREATION, &aRet);
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ TWrapper::
+ ~TWrapper()
+ {
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbMeshes(TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ return MEDnMesh(myFile->Id());
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetMeshInfo(TInt theMeshId,
+ MED::TMeshInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TValueHolder<TString, char> aMeshName(theInfo.myName);
+ TValueHolder<TInt, med_int> aDim(theInfo.myDim);
+ TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
+ TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
+ char dtunit[MED_SNAME_SIZE+1];
+ med_sorting_type sorttype;
+ med_int nstep;
+ med_axis_type at;
+ int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
+ char *axisname = new char[naxis*MED_SNAME_SIZE+1];
+ char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
+ TErr aRet = MEDmeshInfo(myFile->Id(),
+ theMeshId,
+ &aMeshName,
+ &aSpaceDim,
+ &aDim,
+ &aType,
+ &theInfo.myDesc[0],
+ dtunit,
+ &sorttype,
+ &nstep,
+ &at,
+ axisname,
+ axisunit);
+ delete [] axisname;
+ delete [] axisunit;
+ if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetMeshInfo(const MED::TMeshInfo& theInfo,
+ TErr* theErr)
+ {
+ TErr aRet;
+ SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
+
+ if (aRet < 0)
+ SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
+
+ if (aRet < 0)
+ SetMeshInfo(theInfo, eCREATION, &aRet);
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetMeshInfo(const MED::TMeshInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
+
+ TValueHolder<TString, char> aMeshName(anInfo.myName);
+ TValueHolder<TInt, med_int> aDim(anInfo.myDim);
+ TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
+ TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
+ TValueHolder<TString, char> aDesc(anInfo.myDesc);
+
+ char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
+ std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
+ char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
+ std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
+ TErr aRet = MEDmeshCr(myFile->Id(),
+ &aMeshName,
+ aSpaceDim,
+ aDim,
+ aType,
+ &aDesc,
+ "",
+ MED_SORT_DTIT,
+ MED_CARTESIAN,
+ nam,
+ unit);
+ delete [] nam;
+ delete [] unit;
+
+ //if (aRet == 0)
+ // aRet = MEDunvCr(myFile->Id(),&aMeshName);
+
+ INITMSG(MYDEBUG, "TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PMeshInfo
+ TWrapper
+ ::CrMeshInfo(TInt theDim,
+ TInt theSpaceDim,
+ const std::string& theValue,
+ EMaillage theType,
+ const std::string& theDesc)
+ {
+ return PMeshInfo(new TTMeshInfo
+ (theDim,
+ theSpaceDim,
+ theValue,
+ theType,
+ theDesc));
+ }
+
+ //----------------------------------------------------------------------------
+ PMeshInfo
+ TWrapper
+ ::CrMeshInfo(const PMeshInfo& theInfo)
+ {
+ return PMeshInfo(new TTMeshInfo(theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PMeshInfo
+ TWrapper
+ ::GetPMeshInfo(TInt theId,
+ TErr* theErr)
+ {
+ PMeshInfo anInfo = CrMeshInfo();
+ GetMeshInfo(theId, *anInfo, theErr);
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbFamilies(const MED::TMeshInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
+ TValueHolder<TString, char> aName(anInfo.myName);
+ return MEDnFamily(myFile->Id(), &aName);
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbFamAttr(TInt theFamId,
+ const MED::TMeshInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
+
+ TValueHolder<TString, char> aName(anInfo.myName);
+
+ return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbFamGroup(TInt theFamId,
+ const MED::TMeshInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
+
+ TValueHolder<TString, char> aName(anInfo.myName);
+
+ return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetFamilyInfo(TInt theFamId,
+ MED::TFamilyInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TString, char> aFamilyName(theInfo.myName);
+ TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
+ TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
+ TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
+ TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
+ TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
+
+ TErr aRet = MEDfamily23Info(myFile->Id(),
+ &aMeshName,
+ theFamId,
+ &aFamilyName,
+ &anAttrId,
+ &anAttrVal,
+ &anAttrDesc,
+ &aFamilyId,
+ &aGroupNames);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
+ " aMeshInfo.myName = '"<<&aMeshName<<
+ "'; theFamId = "<<theFamId<<
+ "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
+ "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
+ TErr* theErr)
+ {
+ TErr aRet;
+ SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
+
+ if (aRet < 0)
+ SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TString, char> aFamilyName(anInfo.myName);
+ TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
+ TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
+ TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
+ TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
+ TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
+ TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
+ TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
+
+ TErr aRet = MEDfamilyCr(myFile->Id(),
+ &aMeshName,
+ &aFamilyName,
+ aFamilyId,
+ aNbGroup,
+ &aGroupNames);
+
+ INITMSG(MYDEBUG, "TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PFamilyInfo
+ TWrapper
+ ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbGroup,
+ TInt theNbAttr,
+ TInt theId,
+ const std::string& theValue)
+ {
+ return PFamilyInfo(new TTFamilyInfo
+ (theMeshInfo,
+ theNbGroup,
+ theNbAttr,
+ theId,
+ theValue));
+ }
+
+ //----------------------------------------------------------------------------
+ PFamilyInfo
+ TWrapper
+ ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ const std::string& theValue,
+ TInt theId,
+ const MED::TStringSet& theGroupNames,
+ const MED::TStringVector& theAttrDescs,
+ const MED::TIntVector& theAttrIds,
+ const MED::TIntVector& theAttrVals)
+ {
+ return PFamilyInfo(new TTFamilyInfo
+ (theMeshInfo,
+ theValue,
+ theId,
+ theGroupNames,
+ theAttrDescs,
+ theAttrIds,
+ theAttrVals));
+ }
+
+ //----------------------------------------------------------------------------
+ PFamilyInfo
+ TWrapper
+ ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ const PFamilyInfo& theInfo)
+ {
+ return PFamilyInfo(new TTFamilyInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PFamilyInfo
+ TWrapper
+ ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theId,
+ TErr* theErr)
+ {
+ // must be reimplemented in connection with mesh type eSTRUCTURE
+ // if (theMeshInfo->GetType() != eNON_STRUCTURE)
+ // return PFamilyInfo();
+
+ TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
+ TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
+ PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
+ GetFamilyInfo(theId, *anInfo, theErr);
+
+#ifdef _DEBUG_
+ std::string aName = anInfo->GetName();
+ INITMSG(MYDEBUG, "GetPFamilyInfo - aFamilyName = '"<<aName<<
+ "'; andId = "<<anInfo->GetId()<<
+ "; aNbAttr = "<<aNbAttr<<
+ "; aNbGroup = "<<aNbGroup<<"\n");
+ for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
+ aName = anInfo->GetGroupName(iGroup);
+ INITMSG(MYDEBUG, "aGroupName = '"<<aName<<"'\n");
+ }
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetNames(TElemInfo& theInfo,
+ TInt theNb,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ if (theGeom == eBALL)
+ theGeom = GetBallGeom(theInfo.myMeshInfo);
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
+ TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
+
+ TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ &anElemNames);
+
+ theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetNames(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetNames(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ if (theGeom == eBALL)
+ theGeom = GetBallGeom(theInfo.myMeshInfo);
+
+ MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TErr aRet = 0;
+ if (theInfo.myIsElemNames) {
+ TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
+ TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
+
+ aRet = MEDmeshEntityNameWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ (TInt)anInfo.myElemNames->size(),
+ &anElemNames);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetNumeration(TElemInfo& theInfo,
+ TInt theNb,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ if (theGeom == eBALL)
+ theGeom = GetBallGeom(theInfo.myMeshInfo);
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
+
+ TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ &anElemNum);
+
+ theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetNumeration(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetNumeration(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ if (theGeom == eBALL)
+ theGeom = GetBallGeom(theInfo.myMeshInfo);
+
+ MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TErr aRet = 0;
+ if (theInfo.myIsElemNum) {
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
+
+ aRet = MEDmeshEntityNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ (TInt)anInfo.myElemNum->size(),
+ &anElemNum);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetFamilies(TElemInfo& theInfo,
+ TInt theNb,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ if (theGeom == eBALL)
+ theGeom = GetBallGeom(theInfo.myMeshInfo);
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
+
+ TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ &aFamNum);
+
+ if (aRet < 0) {
+ // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
+ {
+ int aSize = (int)theInfo.myFamNum->size();
+ theInfo.myFamNum->clear();
+ theInfo.myFamNum->resize(aSize,0);
+ aRet = 0;
+ }
+ // else
+ // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
+ }
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetFamilies(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetFamilies(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ if (theGeom == eBALL)
+ theGeom = GetBallGeom(theInfo.myMeshInfo);
+
+ MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
+
+ TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ (TInt)anInfo.myFamNum->size(),
+ &aFamNum);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
+ TErr* theErr)
+ {
+ return GetNbNodes(theMeshInfo, eCOOR, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
+ ETable theTable,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<ETable, med_data_type > aTable(theTable);
+ med_bool chgt,trsf;
+ return MEDmeshnEntity(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ aTable,
+ MED_NO_CMODE,
+ &chgt,
+ &trsf);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetNodeInfo(MED::TNodeInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
+ TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
+ TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
+ TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
+ TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
+ TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
+ //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
+ TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
+ //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
+ TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
+ TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
+
+ TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ aModeSwitch,
+ &aCoord);
+
+ TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ &aFamNum);
+ if (aRet2 < 0) {
+ // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
+ {
+ int mySize = (int)theInfo.myFamNum->size();
+ theInfo.myFamNum->clear();
+ theInfo.myFamNum->resize(mySize,0);
+ }
+ // else
+ // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
+ }
+
+ if (MEDmeshEntityNameRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
+
+ if (MEDmeshEntityNumberRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetNodeInfo(const MED::TNodeInfo& theInfo,
+ TErr* theErr)
+ {
+ TErr aRet;
+ SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
+
+ if (aRet < 0)
+ SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetNodeInfo(const MED::TNodeInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
+ TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
+ TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
+ TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
+ TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
+ TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
+ TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
+ TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
+ TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
+ TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
+ TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
+
+ TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NO_DT,
+ aModeSwitch,
+ aNbElem,
+ &aCoord);
+
+ MEDmeshEntityFamilyNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ aNbElem,
+ &aFamNum);
+ if (anIsElemNames)
+ MEDmeshEntityNameWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ aNbElem,
+ &anElemNames);
+ if (anIsElemNum)
+ MEDmeshEntityNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ aNbElem,
+ &anElemNum);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PNodeInfo
+ TWrapper
+ ::CrNodeInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EModeSwitch theMode,
+ ERepere theSystem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
+ {
+ return PNodeInfo(new TTNodeInfo
+ (theMeshInfo,
+ theNbElem,
+ theMode,
+ theSystem,
+ theIsElemNum,
+ theIsElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PNodeInfo
+ TWrapper
+ ::CrNodeInfo(const PMeshInfo& theMeshInfo,
+ const TFloatVector& theNodeCoords,
+ EModeSwitch theMode,
+ ERepere theSystem,
+ const TStringVector& theCoordNames,
+ const TStringVector& theCoordUnits,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames)
+ {
+ return PNodeInfo(new TTNodeInfo
+ (theMeshInfo,
+ theNodeCoords,
+ theMode,
+ theSystem,
+ theCoordNames,
+ theCoordUnits,
+ theFamilyNums,
+ theElemNums,
+ theElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PNodeInfo
+ TWrapper
+ ::CrNodeInfo(const PMeshInfo& theMeshInfo,
+ const PNodeInfo& theInfo)
+ {
+ return PNodeInfo(new TTNodeInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PNodeInfo
+ TWrapper
+ ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
+ TErr* theErr)
+ {
+ TInt aNbElems = GetNbNodes(*theMeshInfo);
+ if (aNbElems == 0) {
+ return PNodeInfo();
+ }
+
+ PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
+ GetNodeInfo(*anInfo, theErr);
+
+#ifdef _DEBUG_
+ TInt aDim = theMeshInfo->myDim;
+ TInt aNbElem = anInfo->GetNbElem();
+ INITMSG(MYDEBUG, "GetPNodeInfo: ");
+ {
+ INITMSG(MYDEBUG, "aCoords: "<<aNbElem<<": ");
+ TNodeCoord& aCoord = anInfo->myCoord;
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
+ ADDMSG(MYVALUEDEBUG, aCoord[anId]<<",");
+ }
+ ADDMSG(MYVALUEDEBUG, " ");
+ }
+ ADDMSG(MYDEBUG, std::endl);
+
+ BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+
+ if (anInfo->IsElemNum()) {
+ BEGMSG(MYVALUEDEBUG, "GetElemNum: ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+ }
+ }
+ ADDMSG(MYDEBUG, std::endl);
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ PElemInfo
+ TWrapper
+ ::CrElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
+ {
+ return PElemInfo(new TTElemInfo
+ (theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PElemInfo
+ TWrapper
+ ::CrElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ const TIntVector& theFamNum,
+ const TIntVector& aElemNum,
+ const TStringVector& aElemNames)
+ {
+ return PElemInfo(new TTElemInfo
+ (theMeshInfo,
+ theNbElem,
+ theFamNum,
+ aElemNum,
+ aElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PElemInfo
+ TWrapper
+ ::GetPElemInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ EMaillage aType = theMeshInfo->GetType();
+ if (aType == eNON_STRUCTURE) {
+ switch (theGeom) {
+ case ePOINT1:
+ if (theEntity == eNOEUD)
+ return GetPNodeInfo(theMeshInfo, theErr);
+ return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
+ break;
+ case ePOLYGONE:
+ return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
+ break;
+ case ePOLYEDRE:
+ return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
+ break;
+ default:
+ return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
+ }
+ }
+ else {
+ PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
+
+ TInt nbElems;
+ EBooleen theIsElemNum = eFAUX;
+ // nodes
+ switch (theGeom) {
+ case ePOINT1:
+ nbElems = aGrille->GetNbNodes();
+ theIsElemNum = eVRAI;
+ break;
+ case eSEG2:
+ case eQUAD4:
+ case eHEXA8:
+ nbElems = aGrille->GetNbCells();
+ break;
+ default:
+ nbElems = 0;
+ }
+
+ TIntVector aFamNum;
+ TIntVector aElemNum;
+ TStringVector aElemNames;
+
+ PElemInfo aElemInfo;
+
+ if (theGeom == ePOINT1) {
+ aElemInfo = CrElemInfo(theMeshInfo,
+ nbElems,
+ theIsElemNum);
+ MED::TElemInfo &aTElemInfo = *aElemInfo;
+
+ // must be reimplemente in connection with mesh type eSTRUCTURE
+ // GetNumeration(aTElemInfo,
+ // nbElems,
+ // theEntity,
+ // theGeom,
+ // theErr);
+
+ GetFamilies(aTElemInfo,
+ nbElems,
+ theEntity,
+ theGeom,
+ theErr);
+
+ // must be reimplemente in connection with mesh type eSTRUCTURE
+ // GetNames(aTElemInfo,
+ // nbElems,
+ // theEntity,
+ // theGeom,
+ // theErr);
+ }
+ else {
+ aElemInfo = CrElemInfo(theMeshInfo,
+ nbElems,
+ aFamNum,
+ aElemNum,
+ aElemNames);
+ }
+
+ return aElemInfo;
+ }
+ return PElemInfo();
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return 0;
+
+ MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ med_int aTaille = 0;
+ med_bool chgt,trsf;
+ aTaille=MEDmeshnEntity(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ med_entity_type(theEntity),
+ med_geometry_type(theGeom),
+ MED_CONNECTIVITY,
+ med_connectivity_mode(theConnMode),
+ &chgt,
+ &trsf);
+
+ if (aTaille < 0)
+ EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
+
+ return TInt(aTaille);
+ }
+
+ //-----------------------------------------------------------------
+ void
+ TWrapper
+ ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
+ TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
+ TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
+ TInt aNbElem = (TInt)theInfo.myElemNum->size();
+
+ TErr aRet;
+ aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT,
+ anEntity, aGeom,
+ aConnMode, &anIndex, &aConn);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
+
+ if (theInfo.myIsElemNames) {
+ GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ if (theInfo.myIsElemNum) {
+ GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
+ TErr* theErr)
+ {
+ SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
+ TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
+ TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
+
+ TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
+ anEntity, aGeom,
+ aConnMode, anInfo.myNbElem + 1,
+ &anIndex, &aConn);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
+
+ SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
+ if (theErr)
+ *theErr = aRet;
+
+ SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
+ if (theErr)
+ *theErr = aRet;
+
+ SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ PPolygoneInfo
+ TWrapper
+ ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theConnSize,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
+ {
+ return PPolygoneInfo(new TTPolygoneInfo
+ (theMeshInfo,
+ theEntity,
+ theGeom,
+ theNbElem,
+ theConnSize,
+ theConnMode,
+ theIsElemNum,
+ theIsElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PPolygoneInfo
+ TWrapper
+ ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames)
+ {
+ return PPolygoneInfo(new TTPolygoneInfo
+ (theMeshInfo,
+ theEntity,
+ theGeom,
+ theIndexes,
+ theConnectivities,
+ theConnMode,
+ theFamilyNums,
+ theElemNums,
+ theElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PPolygoneInfo
+ TWrapper
+ ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
+ const PPolygoneInfo& theInfo)
+ {
+ return PPolygoneInfo(new TTPolygoneInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PPolygoneInfo
+ TWrapper
+ ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode)
+ {
+ if (theMeshInfo->GetType() != eNON_STRUCTURE)
+ return PPolygoneInfo();
+
+ TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
+ TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
+ PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
+ GetPolygoneInfo(anInfo);
+
+#ifdef _DEBUG_
+ INITMSG(MYDEBUG, "GetPPolygoneInfo"<<
+ " - theGeom = "<<theGeom<<
+ "; aNbElem = "<<aNbElem<<": ");
+ for (TInt iElem = 1; iElem < aNbElem; iElem++) {
+ TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
+ TInt aConnDim = aConnSlice.size();
+ for (TInt iConn = 0; iConn < aConnDim; iConn++) {
+ ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
+ }
+ ADDMSG(MYDEBUG, " ");
+ }
+ ADDMSG(MYDEBUG, std::endl);
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
+ TInt& theNbFaces,
+ TInt& theConnSize,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
+
+ MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
+ //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
+ //TValueHolder<TInt, med_int> aConnSize(theConnSize);
+
+ med_bool chgt, trsf;
+ theNbFaces = MEDmeshnEntity(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_CELL,
+ MED_POLYHEDRON,
+ MED_INDEX_NODE,
+ aConnMode,
+ &chgt,
+ &trsf);
+
+ theConnSize = MEDmeshnEntity(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_CELL,
+ MED_POLYHEDRON,
+ MED_CONNECTIVITY,
+ aConnMode,
+ &chgt,
+ &trsf);
+
+ if (theNbFaces < 0 || theConnSize<0)
+ EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
+
+ }
+
+ //-----------------------------------------------------------------
+ void
+ TWrapper
+ ::GetPolyedreInfo(TPolyedreInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TInt aNbElem = (TInt)theInfo.myElemNum->size();
+ TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
+ TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
+ TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
+
+ TErr aRet;
+ aRet = MEDmeshPolyhedronRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_CELL,
+ aConnMode,
+ &anIndex,
+ &aFaces,
+ &aConn);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
+
+ if (theInfo.myIsElemNames) {
+ GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ if (theInfo.myIsElemNum) {
+ GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
+ TErr* theErr)
+ {
+ SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
+ TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
+ TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
+
+ TErr aRet;
+ aRet = MEDmeshPolyhedronWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_UNDEF_DT,
+ MED_CELL,
+ aConnMode,
+ anInfo.myNbElem+1,
+ &anIndex,
+ (TInt)anInfo.myFaces->size(),
+ &aFaces,
+ &aConn);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
+
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
+
+ if (theInfo.myIsElemNames) {
+ TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
+ aRet = MEDmeshEntityNameWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ MED_POLYHEDRON,
+ (TInt)anInfo.myElemNames->size(),
+ &anElemNames);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
+ }
+
+ if (theInfo.myIsElemNum) {
+ TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
+ aRet = MEDmeshEntityNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ MED_POLYHEDRON,
+ (TInt)anInfo.myElemNum->size(),
+ &anElemNum);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
+ }
+
+ TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
+ aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ MED_POLYHEDRON,
+ (TInt)anInfo.myFamNum->size(),
+ &aFamNum);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PPolyedreInfo
+ TWrapper
+ ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbFaces,
+ TInt theConnSize,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
+ {
+ return PPolyedreInfo(new TTPolyedreInfo
+ (theMeshInfo,
+ theEntity,
+ theGeom,
+ theNbElem,
+ theNbFaces,
+ theConnSize,
+ theConnMode,
+ theIsElemNum,
+ theIsElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PPolyedreInfo
+ TWrapper
+ ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theFaces,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames)
+ {
+ return PPolyedreInfo(new TTPolyedreInfo
+ (theMeshInfo,
+ theEntity,
+ theGeom,
+ theIndexes,
+ theFaces,
+ theConnectivities,
+ theConnMode,
+ theFamilyNums,
+ theElemNums,
+ theElemNames));
+ }
+
+ //----------------------------------------------------------------------------
+ PPolyedreInfo
+ TWrapper
+ ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
+ const PPolyedreInfo& theInfo)
+ {
+ return PPolyedreInfo(new TTPolyedreInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PPolyedreInfo
+ TWrapper
+ ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode)
+ {
+ if (theMeshInfo->GetType() != eNON_STRUCTURE)
+ return PPolyedreInfo();
+ TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
+ TInt aNbFaces, aConnSize;
+ GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
+ PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
+ GetPolyedreInfo(anInfo);
+
+#ifdef _DEBUG_
+ INITMSG(MYDEBUG, "GetPPolyedreInfo"<<
+ " - theGeom = "<<theGeom<<
+ "; aNbElem = "<<aNbElem<<": ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
+ TInt aNbFaces = aConnSliceArr.size();
+ ADDMSG(MYDEBUG, "{");
+ for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
+ TCConnSlice aConnSlice = aConnSliceArr[iFace];
+ TInt aNbConn = aConnSlice.size();
+ ADDMSG(MYDEBUG, "[");
+ for (TInt iConn = 0; iConn < aNbConn; iConn++) {
+ ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
+ }
+ ADDMSG(MYDEBUG, "] ");
+ }
+ ADDMSG(MYDEBUG, "} ");
+ }
+ ADDMSG(MYDEBUG, std::endl);
+#endif
+
+ return anInfo;
+ }
+
+ //-----------------------------------------------------------------
+ TEntityInfo
+ TWrapper
+ ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ TEntityInfo anInfo;
+
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return anInfo;
+
+ if (theMeshInfo.GetType() == eNON_STRUCTURE) {
+ TInt aNbElem = GetNbNodes(theMeshInfo);
+ if (aNbElem > 0) {
+ anInfo[eNOEUD][ePOINT1] = aNbElem;
+ const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
+ TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
+ TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
+ for (; anIter != anIterEnd; anIter++) {
+ const EEntiteMaillage& anEntity = anIter->first;
+ const TGeomSet& aGeomSet = anIter->second;
+ TGeomSet::const_iterator anIter2 = aGeomSet.begin();
+ TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
+ for (; anIter2 != anIterEnd2; anIter2++) {
+ const EGeometrieElement& aGeom = *anIter2;
+ aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
+ if (aNbElem > 0) {
+ if (anEntity == eSTRUCT_ELEMENT) {
+ const TInt nbStructTypes = aNbElem;
+ for (TInt structType = 0; structType < nbStructTypes; ++structType) {
+ // check type name to keep only "MED_BALL" structured element
+ TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
+ char geotypename[ MED_NAME_SIZE + 1] = "";
+ med_geometry_type geotype;
+ MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
+ med_entity_type(anEntity), structType+1,
+ geotypename, &geotype);
+ if (strcmp(geotypename, MED_BALL_NAME) == 0) {
+ aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
+ theConnMode, theErr);
+ if (aNbElem > 0)
+ anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
+ }
+ }
+ }
+ else {
+ anInfo[anEntity][aGeom] = aNbElem;
+ }
+ }
+ }
+ }
+ }
+ }
+ else { // eSTRUCTURE
+ EGrilleType aGrilleType;
+ TInt aNbNodes = 1;
+ TInt aNbElem = 1;
+ TInt aNbSub = 0;
+ TInt aDim = theMeshInfo.GetDim();
+ EGeometrieElement aGeom, aSubGeom;
+ EEntiteMaillage aSubEntity = eMAILLE;
+
+ GetGrilleType(theMeshInfo, aGrilleType);
+
+ TIntVector aStruct(aDim);
+ if (aGrilleType == eGRILLE_STANDARD)
+ {
+ GetGrilleStruct(theMeshInfo, aStruct, theErr);
+ }
+ else
+ { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
+ ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
+ for (med_int anAxis = 0; anAxis < aDim; anAxis++)
+ aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
+ }
+ for (med_int i = 0; i < aDim; i++) {
+ aNbNodes = aNbNodes * aStruct[i];
+ aNbElem = aNbElem * (aStruct[i] - 1);
+ }
+ switch (aDim) {
+ case 1:
+ aGeom = eSEG2;
+ break;
+ case 2:
+ aGeom = eQUAD4;
+ aSubGeom = eSEG2;
+ aSubEntity = eARETE;
+ aNbSub =
+ (aStruct[0]) * (aStruct[1]-1) +
+ (aStruct[0]-1) * (aStruct[1]);
+ break;
+ case 3:
+ aGeom = eHEXA8;
+ aSubGeom = eQUAD4;
+ aSubEntity = eFACE;
+ aNbSub =
+ (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
+ (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
+ (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
+ break;
+ }
+ anInfo[eNOEUD][ePOINT1] = aNbNodes;
+ anInfo[eMAILLE][aGeom] = aNbElem;
+ if (aDim > 1)
+ anInfo[aSubEntity][aSubGeom] = aNbSub;
+ }
+ return anInfo;
+ }
+
+ //-----------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ med_bool chgt, trsf;
+ switch (theGeom)
+ {
+ case MED::ePOLYGONE:
+ case MED::ePOLYGON2:
+ {
+ return MEDmeshnEntity(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT,
+ med_entity_type(theEntity), med_geometry_type(theGeom),
+ MED_INDEX_NODE, med_connectivity_mode(theConnMode),
+ &chgt, &trsf)-1;
+ }
+ case MED::ePOLYEDRE:
+ {
+ return MEDmeshnEntity(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT,
+ med_entity_type(theEntity), MED_POLYHEDRON,
+ MED_INDEX_FACE, med_connectivity_mode(theConnMode),
+ &chgt, &trsf)-1;
+ }
+ case MED::eBALL:
+ {
+ return GetNbBalls(theMeshInfo);
+ }
+ default:
+ {
+ return MEDmeshnEntity(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT,
+ med_entity_type(theEntity), med_geometry_type(theGeom),
+ MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
+ &chgt, &trsf);
+ }
+ }
+ return 0;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetCellInfo(MED::TCellInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
+ TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
+ TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
+ TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
+ TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
+ TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
+ TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
+
+ TErr aRet;
+ aRet = MEDmeshElementRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ aConnMode,
+ aModeSwitch,
+ &aConn,
+ &anIsElemNames,
+ &anElemNames,
+ &anIsElemNum,
+ &anElemNum,
+ &anIsFamNum,
+ &aFamNum);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
+
+ if (anIsFamNum == MED_FALSE)
+ {
+ int mySize = (int) theInfo.myFamNum->size();
+ theInfo.myFamNum->clear();
+ theInfo.myFamNum->resize(mySize, 0);
+ }
+
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetCellInfo(const MED::TCellInfo& theInfo,
+ TErr* theErr)
+ {
+ SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetCellInfo(const MED::TCellInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
+ TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
+ TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
+ TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
+ TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
+ TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
+ TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
+ TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
+ TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
+ TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
+
+ TErr aRet;
+ aRet = MEDmeshElementConnectivityWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_UNDEF_DT,
+ anEntity,
+ aGeom,
+ aConnMode,
+ aModeSwitch,
+ aNbElem,
+ &aConn);
+
+ MEDmeshEntityFamilyNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ aNbElem,
+ &aFamNum);
+ if (anIsElemNames)
+ MEDmeshEntityNameWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ aNbElem,
+ &anElemNames);
+ if (anIsElemNum)
+ MEDmeshEntityNumberWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ anEntity,
+ aGeom,
+ aNbElem,
+ &anElemNum);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PCellInfo
+ TWrapper
+ ::CrCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames,
+ EModeSwitch theMode)
+ {
+ return PCellInfo(new TTCellInfo
+ (theMeshInfo,
+ theEntity,
+ theGeom,
+ theNbElem,
+ theConnMode,
+ theIsElemNum,
+ theIsElemNames,
+ theMode));
+ }
+
+ //----------------------------------------------------------------------------
+ PCellInfo
+ TWrapper
+ ::CrCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames,
+ EModeSwitch theMode)
+ {
+ return PCellInfo(new TTCellInfo
+ (theMeshInfo,
+ theEntity,
+ theGeom,
+ theConnectivities,
+ theConnMode,
+ theFamilyNums,
+ theElemNums,
+ theElemNames,
+ theMode));
+ }
+
+ //----------------------------------------------------------------------------
+ PCellInfo
+ TWrapper
+ ::CrCellInfo(const PMeshInfo& theMeshInfo,
+ const PCellInfo& theInfo)
+ {
+ return PCellInfo(new TTCellInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PCellInfo
+ TWrapper
+ ::GetPCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode,
+ TErr* theErr)
+ {
+ if (theMeshInfo->GetType() != eNON_STRUCTURE)
+ return PCellInfo();
+ TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
+ PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
+ GetCellInfo(anInfo, theErr);
+
+#ifdef _DEBUG_
+ TInt aConnDim = anInfo->GetConnDim();
+ INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
+ BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
+ for (TInt iConn = 0; iConn < aConnDim; iConn++) {
+ ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
+ }
+ ADDMSG(MYVALUEDEBUG, " ");
+ }
+ ADDMSG(MYDEBUG, std::endl);
+
+ BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+
+ if (anInfo->IsElemNum()) {
+ BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+ }
+ ADDMSG(MYDEBUG, std::endl);
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ EGeometrieElement
+ TWrapper
+ ::GetBallGeom(const TMeshInfo& theMeshInfo)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE);
+
+ // read med_geometry_type of "MED_BALL" element
+ char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
+ return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbBalls(const TMeshInfo& theMeshInfo)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE);
+
+ EGeometrieElement ballType = GetBallGeom(theMeshInfo);
+ if (ballType < 0)
+ return 0;
+
+ return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetBallInfo(TBallInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ // check geometry of MED_BALL
+ if (theInfo.myGeom == eBALL)
+ {
+ theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
+ if (theInfo.myGeom < 0) {
+ if (!theErr)
+ EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
+ *theErr = theInfo.myGeom;
+ return;
+ }
+ }
+
+ // read nodes ids
+ GetCellInfo(theInfo);
+
+ // read diameters
+ TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
+ TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
+ char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
+
+ TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT,
+ aGeom,
+ varattname,
+ &aDiam);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetBallInfo(const TBallInfo& theInfo,
+ TErr* theErr)
+ {
+ SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetBallInfo(const TBallInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ TErr ret;
+ char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
+ EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
+ if (ballGeom < 0)
+ {
+ // no ball model in the file, create support mesh for it
+ char dummyname [MED_NAME_SIZE*3+1] = "";
+ if ((ret = MEDsupportMeshCr(myFile->Id(),
+ ballsupportname,
+ theInfo.myMeshInfo->GetSpaceDim(),
+ theInfo.myMeshInfo->GetDim(),
+ "Support mesh for a ball model",
+ MED_CARTESIAN,
+ /*axisname=*/dummyname,
+ /*unitname=*/dummyname)) < 0) {
+ if (!theErr)
+ EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
+ *theErr = ret;
+ return;
+ }
+ // write coordinates of 1 node
+ med_float coord[3] = {0, 0, 0};
+ if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
+ ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
+ MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
+ if (!theErr)
+ EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
+ *theErr = ret;
+ return;
+ }
+ // ball model creation
+ char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
+ if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
+ geotypename,
+ theInfo.myMeshInfo->GetSpaceDim(),
+ ballsupportname,
+ MED_NODE,MED_NONE)) < 0) {
+ if (!theErr)
+ EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
+ *theErr = ret;
+ return;
+ }
+ // create diameter attribute
+ if ((ret = MEDstructElementVarAttCr(myFile->Id(),
+ geotypename, MED_BALL_DIAMETER,
+ MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
+ if (!theErr)
+ EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
+ *theErr = ret;
+ return;
+ }
+ } // ballGeom < 0
+
+ TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
+ aBallInfo.myGeom = ballGeom;
+
+ // write node ids
+ SetCellInfo(theInfo, theMode, theErr);
+ if (theErr && theErr < 0)
+ return;
+
+ // write diameter
+ TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
+ TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
+ TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
+ ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
+ MED_NO_DT, MED_NO_IT,
+ aGeom, MED_BALL_DIAMETER,
+ theInfo.myNbElem, &aDiam);
+ if (theErr)
+ *theErr = ret;
+ else if (ret < 0)
+ EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
+ }
+
+ //----------------------------------------------------------------------------
+ PBallInfo
+ TWrapper
+ ::CrBallInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbBalls,
+ EBooleen theIsElemNum)
+ {
+ return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
+ }
+
+ //----------------------------------------------------------------------------
+ PBallInfo
+ TWrapper
+ ::CrBallInfo(const PMeshInfo& theMeshInfo,
+ const TIntVector& theNodes,
+ TFloatVector& theDiameters,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums)
+ {
+ return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
+ theFamilyNums, theElemNums));
+ }
+
+ //----------------------------------------------------------------------------
+ PBallInfo
+ TWrapper
+ ::CrBallInfo(const PMeshInfo& theMeshInfo,
+ const PBallInfo& theInfo)
+ {
+ return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PBallInfo
+ TWrapper
+ ::GetPBallInfo(const PMeshInfo& theMeshInfo)
+ {
+ TInt nbBalls = GetNbBalls(theMeshInfo);
+ if (nbBalls < 1) return PBallInfo();
+
+ PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
+ GetBallInfo(anInfo);
+
+ return anInfo;
+ }
+
+ //-----------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbFields(TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ return MEDnField(myFile->Id());
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbComp(TInt theFieldId,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ return MEDfieldnComponent(myFile->Id(), theFieldId);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetFieldInfo(TInt theFieldId,
+ MED::TFieldInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TString aFieldName(256); // Protect from memory problems with too long names
+ TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
+ TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
+ TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
+ MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
+
+ TErr aRet;
+ med_bool local;
+ char dtunit[MED_SNAME_SIZE+1];
+ char local_mesh_name[MED_NAME_SIZE+1]="";
+ med_int nbofstp;
+ theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
+ aRet = MEDfieldInfo(myFile->Id(),
+ theFieldId,
+ &aFieldName[0],
+ local_mesh_name,
+ &local,
+ &aType,
+ &aCompNames,
+ &anUnitNames,
+ dtunit,
+ &nbofstp);
+
+ if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
+ if (theErr)
+ *theErr = -1;
+ return;
+ }
+
+ theInfo.SetName(aFieldName);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetFieldInfo(const MED::TFieldInfo& theInfo,
+ TErr* theErr)
+ {
+ TErr aRet;
+ SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
+
+ if (aRet < 0)
+ SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetFieldInfo(const MED::TFieldInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
+
+ TValueHolder<TString, char> aFieldName(anInfo.myName);
+ TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
+ TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
+ TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
+ MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
+ TErr aRet;
+ char dtunit[MED_SNAME_SIZE+1];
+ std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
+ aRet = MEDfieldCr(myFile->Id(),
+ &aFieldName,
+ aType,
+ anInfo.myNbComp,
+ &aCompNames,
+ &anUnitNames,
+ dtunit,
+ &aMeshInfo.myName[0]);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PFieldInfo
+ TWrapper
+ ::CrFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbComp,
+ ETypeChamp theType,
+ const std::string& theValue,
+ EBooleen theIsLocal,
+ TInt theNbRef)
+ {
+ return PFieldInfo(new TTFieldInfo
+ (theMeshInfo,
+ theNbComp,
+ theType,
+ theValue,
+ theIsLocal,
+ theNbRef));
+ }
+
+ //----------------------------------------------------------------------------
+ PFieldInfo
+ TWrapper
+ ::CrFieldInfo(const PMeshInfo& theMeshInfo,
+ const PFieldInfo& theInfo)
+ {
+ return PFieldInfo(new TTFieldInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PFieldInfo
+ TWrapper
+ ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theId,
+ TErr* theErr)
+ {
+ TInt aNbComp = GetNbComp(theId);
+ PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
+ GetFieldInfo(theId, *anInfo, theErr);
+
+#ifdef _DEBUG_
+ INITMSG(MYDEBUG,
+ "GetPFieldInfo "<<
+ "- aName = '"<<anInfo->GetName()<<"'"<<
+ "; aType = "<<anInfo->GetType()<<
+ "; aNbComp = "<<aNbComp<<
+ std::endl);
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbGauss(TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ return MEDnLocalization(myFile->Id());
+ }
+
+ //----------------------------------------------------------------------------
+ TGaussInfo::TInfo
+ TWrapper
+ ::GetGaussPreInfo(TInt theId,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
+
+ med_int aNbGaussPoints = med_int();
+ TVector<char> aName(GetNOMLength()+1);
+ med_geometry_type aGeom = MED_NONE;
+
+ TErr aRet;
+ med_int dim;
+ char geointerpname[MED_NAME_SIZE+1] = "";
+ char ipointstructmeshname[MED_NAME_SIZE+1] = "";
+ med_int nsectionmeshcell;
+ med_geometry_type sectiongeotype;
+ aRet = MEDlocalizationInfo (myFile->Id(),
+ theId,
+ &aName[0],
+ &aGeom,
+ &dim,
+ &aNbGaussPoints,
+ geointerpname,
+ ipointstructmeshname,
+ &nsectionmeshcell,
+ §iongeotype);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
+ return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
+ TInt(aNbGaussPoints));
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetGaussInfo(TInt theId,
+ TGaussInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
+ TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
+ TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
+ TValueHolder<TString, char> aGaussName(theInfo.myName);
+
+ TErr aRet;
+ aRet = MEDlocalizationRd(myFile->Id(),
+ &aGaussName,
+ aModeSwitch,
+ &aRefCoord,
+ &aGaussCoord,
+ &aWeight);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PGaussInfo
+ TWrapper
+ ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
+ EModeSwitch theMode)
+ {
+ return PGaussInfo(new TTGaussInfo
+ (theInfo,
+ theMode));
+ }
+
+ //-----------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
+ const MED::TEntityInfo& theEntityInfo,
+ EEntiteMaillage& theEntity,
+ TGeom2Size& theGeom2Size,
+ TErr* theErr)
+ {
+ theEntity = EEntiteMaillage(-1);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr) {
+ if (theEntityInfo.empty())
+ *theErr = -1;
+ if (*theErr < 0)
+ return -1;
+ }
+ else if (theEntityInfo.empty())
+ EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
+
+ bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
+
+ theGeom2Size.clear();
+ TInt aNbTimeStamps = 0;
+ TIdt anId = myFile->Id();
+
+ MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
+ TValueHolder<TString, char> aFieldName(anInfo.myName);
+ MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
+
+ // workaround for IPAL13676
+ MED::TEntityInfo localEntityInfo = theEntityInfo;
+ TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
+ if (anLocalIter != localEntityInfo.end()) {
+ localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
+ }
+
+ TEntityInfo::const_iterator anIter = localEntityInfo.begin();
+ for (; anIter != localEntityInfo.end(); anIter++) {
+ med_entity_type anEntity = med_entity_type(anIter->first);
+ const TGeom2Size& aGeom2Size = anIter->second;
+ TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
+ for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
+ med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
+ char aMeshName[MED_NAME_SIZE+1];
+ med_bool islocal;
+ med_field_type ft;
+ char dtunit[MED_SNAME_SIZE+1];
+ med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
+ char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
+ char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
+ TInt aNbStamps;
+ MEDfieldInfoByName(anId,
+ &aFieldName,
+ aMeshName,
+ &islocal,
+ &ft,
+ cname,
+ unitname,
+ dtunit,
+ &aNbStamps);
+ delete [] cname;
+ delete [] unitname;
+ med_int nval = 0;
+ med_int aNumDt;
+ med_int aNumOrd;
+ med_float aDt;
+ if (aNbStamps > 0)
+ {
+ MEDfieldComputingStepInfo(anId,
+ &aFieldName,
+ 1,
+ &aNumDt,
+ &aNumOrd,
+ &aDt);
+ char profilename[MED_NAME_SIZE+1];
+ char locname[MED_NAME_SIZE+1];
+ med_int profilsize;
+ med_int aNbGauss;
+
+ // protection from crash (division by zero)
+ // inside MEDfieldnValueWithProfile function
+ // caused by the workaround for IPAL13676 (see above)
+ if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
+ continue;
+
+ nval = MEDfieldnValueWithProfile(anId,
+ &aFieldName,
+ aNumDt,
+ aNumOrd,
+ anEntity,
+ med_geometry_type(aGeom),
+ 1,
+ MED_COMPACT_STMODE,
+ profilename,
+ &profilsize,
+ locname,
+ &aNbGauss);
+ }
+ bool anIsSatisfied =(nval > 0);
+ if (anIsSatisfied) {
+ INITMSG(MYDEBUG,
+ "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
+ "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
+ if (anIsPerformAdditionalCheck) {
+ anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
+ if (!anIsSatisfied) {
+ INITMSG(MYDEBUG,
+ "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
+ "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
+ }
+ }
+ }
+ if (anIsSatisfied) {
+ theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
+ theEntity = EEntiteMaillage(anEntity);
+ aNbTimeStamps = aNbStamps;
+ }
+ }
+ if (!theGeom2Size.empty())
+ break;
+ }
+ return aNbTimeStamps;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetTimeStampInfo(TInt theTimeStampId,
+ MED::TTimeStampInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
+
+ if (theErr) {
+ if (aGeom2Size.empty())
+ *theErr = -1;
+ if (*theErr < 0)
+ return;
+ }
+ else if (aGeom2Size.empty())
+ EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
+
+ MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
+ MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
+
+ TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
+ TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
+ TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
+ TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
+ TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
+ TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
+
+ TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
+
+ // just to get a time stamp unit (anUnitDt)
+ med_field_type aFieldType;
+ med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
+ char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
+ char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
+ TInt aNbStamps;
+ MEDfieldInfoByName(myFile->Id(),
+ &aFieldName,
+ &aMeshName,
+ &anIsLocal,
+ &aFieldType,
+ aCompName,
+ aCompUnit,
+ &anUnitDt,
+ &aNbStamps);
+ delete [] aCompName;
+ delete [] aCompUnit;
+
+ TGeom2Size::const_iterator anIter = aGeom2Size.begin();
+ for (; anIter != aGeom2Size.end(); anIter++) {
+ const EGeometrieElement& aGeom = anIter->first;
+ med_int aNbGauss = -1;
+
+ TErr aRet;
+ aRet = MEDfieldComputingStepInfo(myFile->Id(),
+ &aFieldName,
+ theTimeStampId,
+ &aNumDt,
+ &aNumOrd,
+ &aDt);
+ char profilename[MED_NAME_SIZE+1];
+ med_int profilsize;
+ char locname[MED_NAME_SIZE+1];
+ MEDfieldnValueWithProfile(myFile->Id(),
+ &aFieldName,
+ aNumDt,
+ aNumOrd,
+ anEntity,
+ med_geometry_type(aGeom),
+ 1,
+ MED_COMPACT_STMODE,
+ profilename,
+ &profilsize,
+ locname,
+ &aNbGauss);
+
+ static TInt MAX_NB_GAUSS_POINTS = 32;
+ if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
+ aNbGauss = 1;
+
+ aGeom2NbGauss[aGeom] = aNbGauss;
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampInfo
+ TWrapper
+ ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
+ const TGeom2NbGauss& theGeom2NbGauss,
+ TInt theNumDt,
+ TInt theNumOrd,
+ TFloat theDt,
+ const std::string& theUnitDt,
+ const TGeom2Gauss& theGeom2Gauss)
+ {
+ return PTimeStampInfo(new TTTimeStampInfo
+ (theFieldInfo,
+ theEntity,
+ theGeom2Size,
+ theGeom2NbGauss,
+ theNumDt,
+ theNumOrd,
+ theDt,
+ theUnitDt,
+ theGeom2Gauss));
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampInfo
+ TWrapper
+ ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
+ const PTimeStampInfo& theInfo)
+ {
+ return PTimeStampInfo(new TTTimeStampInfo
+ (theFieldInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampInfo
+ TWrapper
+ ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
+ TInt theId,
+ TErr* theErr)
+ {
+ PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
+ GetTimeStampInfo(theId, *anInfo, theErr);
+
+#ifdef _DEBUG_
+ INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
+ TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
+ TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
+ for (; anIter != aGeom2NbGauss.end(); anIter++) {
+ const EGeometrieElement& aGeom = anIter->first;
+ INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
+ }
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ TInt
+ TWrapper
+ ::GetNbProfiles(TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return -1;
+
+ return MEDnProfile(myFile->Id());
+ }
+
+ //----------------------------------------------------------------------------
+ TProfileInfo::TInfo
+ TWrapper
+ ::GetProfilePreInfo(TInt theId,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return TProfileInfo::TInfo();
+
+ med_int aSize = -1;
+ TVector<char> aName(GetNOMLength()+1);
+
+ TErr aRet;
+ aRet = MEDprofileInfo(myFile->Id(),
+ theId,
+ &aName[0],
+ &aSize);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
+
+ return TProfileInfo::TInfo(&aName[0], aSize);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetProfileInfo(TInt theId,
+ TProfileInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
+ TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
+ TValueHolder<TString, char> aProfileName(anInfo.myName);
+
+ TErr aRet;
+ aRet = MEDprofileRd(myFile->Id(),
+ &aProfileName,
+ &anElemNum);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetProfileInfo(const TProfileInfo& theInfo,
+ TErr* theErr)
+ {
+ TErr aRet;
+ SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
+
+ if (aRet < 0)
+ SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
+
+ if (aRet < 0)
+ SetProfileInfo(theInfo, eCREATION, &aRet);
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetProfileInfo(const TProfileInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
+ TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
+ TValueHolder<TString, char> aProfileName(anInfo.myName);
+
+ TErr aRet;
+ aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
+ &aProfileName, // tableau de valeurs du profil.
+ theInfo.GetSize(), // taille du profil.
+ &anElemNum); // nom profil.
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
+ }
+
+ //----------------------------------------------------------------------------
+ PProfileInfo
+ TWrapper
+ ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
+ EModeProfil theMode)
+ {
+ return PProfileInfo(new TTProfileInfo
+ (theInfo,
+ theMode));
+ }
+
+ //----------------------------------------------------------------------------
+ PProfileInfo
+ TWrapper
+ ::GetPProfileInfo(TInt theId,
+ EModeProfil theMode,
+ TErr* theErr)
+ {
+ TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
+ PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
+ GetProfileInfo(theId, *anInfo, theErr);
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TIdt anId = myFile->Id();
+
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
+ MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
+
+ MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
+ TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
+ TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
+
+ MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
+ TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
+ TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
+
+ MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
+ TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
+
+ TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
+ TVector<char> aGaussName(GetNOMLength()+1);
+
+ med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
+ MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
+ TVector<char> aProfileName(GetNOMLength()+1);
+
+ TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
+ TGeom2Size::iterator anIter = aGeom2Size.begin();
+ for (; anIter != aGeom2Size.end(); anIter++) {
+ EGeometrieElement aGeom = anIter->first;
+ TInt aNbElem = anIter->second;
+ med_int profilesize, aNbGauss;
+
+ TInt aNbVal = MEDfieldnValueWithProfile(anId,
+ &aFieldName,
+ aNumDt,
+ aNumOrd,
+ anEntity,
+ med_geometry_type(aGeom),
+ 1,
+ aProfileMode,
+ &aProfileName[0],
+ &profilesize,
+ &aGaussName[0],
+ &aNbGauss);
+
+ if (aNbVal <= 0) {
+ if (theErr) {
+ *theErr = -1;
+ return;
+ }
+ EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
+ }
+
+ TInt aNbComp = aFieldInfo->myNbComp;
+ TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
+ theTimeStampValue->AllocateValue(aGeom,
+ aNbValue,
+ aNbGauss,
+ aNbComp);
+ TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
+
+ INITMSG(MYDEBUG,
+ "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
+ "; aNbVal = "<<aNbVal<<
+ "; aNbValue = "<<aNbValue<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aNbComp = "<<aNbComp<<
+ std::endl);
+
+ TErr aRet = MEDfieldValueWithProfileRd(anId,
+ &aFieldName,
+ aNumDt,
+ aNumOrd,
+ anEntity,
+ med_geometry_type(aGeom),
+ aProfileMode,
+ &aProfileName[0],
+ aModeSwitch,
+ MED_ALL_CONSTITUENT,
+ theTimeStampValue->GetValuePtr(aGeom));
+ if (aRet < 0) {
+ if (theErr) {
+ *theErr = MED_FALSE;
+ return;
+ }
+ EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
+ }
+
+ MED::PGaussInfo aGaussInfo;
+ TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
+ if (strcmp(&aGaussName[0], "") != 0) {
+ MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
+ if (anIter != theKey2Gauss.end()) {
+ aGaussInfo = anIter->second;
+ aGeom2Gauss[aGeom] = aGaussInfo;
+ }
+ }
+
+ MED::PProfileInfo aProfileInfo;
+ if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
+ MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
+ if (anIter != aKey2Profile.end()) {
+ aProfileInfo = anIter->second;
+ aGeom2Profile[aGeom] = aProfileInfo;
+ }
+ }
+
+ if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
+ if (theErr) {
+ *theErr = MED_FALSE;
+ return;
+ }
+ EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
+ }
+
+ if (aProfileInfo && aProfileInfo->IsPresent()) {
+ TInt aNbSubElem = aProfileInfo->GetSize();
+ TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
+ if (aProfileSize != aValueSize) {
+ if (theErr) {
+ *theErr = -1;
+ return;
+ }
+ EXCEPTION(std::runtime_error,
+ "GetTimeStampValue - aProfileSize("<<aProfileSize<<
+ ") != aValueSize("<<aValueSize<<
+ "); aNbVal = "<<aNbVal<<
+ "; anEntity = "<<anEntity<<
+ "; aGeom = "<<aGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbSubElem = "<<aNbSubElem<<
+ "; aNbComp = "<<aNbComp<<
+ "; aNbGauss = "<<aNbGauss<<
+ "");
+ }
+ }
+ else{
+ if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
+ if (theErr) {
+ *theErr = -1;
+ return;
+ }
+ EXCEPTION(std::runtime_error,
+ "GetTimeStampValue - aNbElem("<<aNbElem<<
+ ") != aNbValue("<<aNbValue<<
+ "); aNbVal = "<<aNbVal<<
+ "; anEntity = "<<anEntity<<
+ "; aGeom = "<<aGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbComp = "<<aNbComp<<
+ "; aNbGauss = "<<aNbGauss<<
+ "");
+ }
+ }
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
+ TErr* theErr)
+ {
+ TErr aRet;
+ SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
+
+ if (aRet < 0)
+ SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
+
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TErr aRet;
+ TIdt anId = myFile->Id();
+
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
+ MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
+
+ MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
+ TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
+ TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
+ TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
+ TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
+ TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
+ MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
+
+ MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
+ TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
+
+ MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
+ TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
+
+ const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
+ TGeomSet::const_iterator anIter = aGeomSet.begin();
+ for (; anIter != aGeomSet.end(); anIter++) {
+ EGeometrieElement aGeom = *anIter;
+
+ TVector<char> aGaussName(GetNOMLength()+1);
+ MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
+ if (aGaussIter != aGeom2Gauss.end()) {
+ MED::PGaussInfo aGaussInfo = aGaussIter->second;
+ strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
+ }
+
+ TVector<char> aProfileName(GetNOMLength()+1);
+ med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
+ MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
+ if (aProfileIter != aGeom2Profile.end()) {
+ MED::PProfileInfo aProfileInfo = aProfileIter->second;
+ aProfileMode = med_storage_mode(aProfileInfo->myMode);
+ strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
+ }
+
+ med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
+
+ aRet = MEDfieldValueWithProfileWr(anId,
+ &aFieldName,
+ aNumDt,
+ aNumOrd,
+ aDt,
+ anEntity,
+ med_geometry_type(aGeom),
+ aProfileMode,
+ &aProfileName[0],
+ &aGaussName[0],
+ aModeSwitch,
+ MED_ALL_CONSTITUENT,
+ aNbVal,
+ theTimeStampValue->GetValuePtr(aGeom));
+ if (aRet < 0) {
+ if (theErr) {
+ *theErr = MED_FALSE;
+ break;
+ }
+ EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
+ }
+
+ }
+
+ INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampValueBase
+ TWrapper
+ ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ ETypeChamp theTypeChamp,
+ const TGeom2Profile& theGeom2Profile,
+ EModeSwitch theMode)
+ {
+ if (theTypeChamp == eFLOAT64)
+ return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
+ (theTimeStampInfo,
+ theTypeChamp,
+ theGeom2Profile,
+ theMode));
+ return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
+ (theTimeStampInfo,
+ theTypeChamp,
+ theGeom2Profile,
+ theMode));
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampValueBase
+ TWrapper
+ ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const TGeom2Profile& theGeom2Profile,
+ EModeSwitch theMode)
+ {
+ PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
+ return CrTimeStampValue(theTimeStampInfo,
+ aFieldInfo->GetType(),
+ theGeom2Profile,
+ theMode);
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampValueBase
+ TWrapper
+ ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampValueBase& theInfo,
+ ETypeChamp theTypeChamp)
+ {
+ if (theTypeChamp == eFLOAT64)
+ return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
+ (theTimeStampInfo,
+ theInfo,
+ theTypeChamp));
+ return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
+ (theTimeStampInfo,
+ theInfo,
+ theTypeChamp));
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampValueBase
+ TWrapper
+ ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampValueBase& theInfo)
+ {
+ PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
+ return CrTimeStampValue(theTimeStampInfo,
+ theInfo,
+ aFieldInfo->GetType());
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampValueBase
+ TWrapper
+ ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr)
+ {
+ PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
+ PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
+ aFieldInfo->GetType());
+ GetTimeStampValue(anInfo,
+ theMKey2Profile,
+ theKey2Gauss,
+ theErr);
+#ifdef _DEBUG_
+ if (aFieldInfo->GetType() == eFLOAT64)
+ Print<TFloatTimeStampValue>(anInfo);
+ else
+ Print<TIntTimeStampValue>(anInfo);
+#endif
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetTimeStampVal(const PTimeStampVal& theVal,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr)
+ {
+ PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
+ PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
+ if (aFieldInfo->GetType() == eFLOAT64)
+ GetTimeStampValue(theVal,
+ theMKey2Profile,
+ theKey2Gauss,
+ theErr);
+ else{
+ PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
+ theVal,
+ eINT);
+ GetTimeStampValue(aVal,
+ theMKey2Profile,
+ theKey2Gauss,
+ theErr);
+ CopyTimeStampValueBase(aVal, theVal);
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetTimeStamp(const PTimeStampVal& theVal,
+ TErr* theErr)
+ {
+ PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
+ PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
+ if (aFieldInfo->GetType() == eFLOAT64)
+ SetTimeStampValue(theVal, theErr);
+ else{
+ PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
+ eINT,
+ theVal->GetGeom2Profile(),
+ theVal->GetModeSwitch());
+ CopyTimeStampValueBase(theVal, aVal);
+ SetTimeStampValue(aVal, theErr);
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampVal
+ TWrapper
+ ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
+ const TGeom2Profile& theGeom2Profile,
+ EModeSwitch theMode)
+ {
+ return CrTimeStampValue(theTimeStampInfo,
+ eFLOAT64,
+ theGeom2Profile,
+ theMode);
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampVal
+ TWrapper
+ ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampVal& theInfo)
+ {
+ return CrTimeStampValue(theTimeStampInfo,
+ theInfo,
+ eFLOAT64);
+ }
+
+ //----------------------------------------------------------------------------
+ PTimeStampVal
+ TWrapper
+ ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr)
+ {
+ PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
+ GetTimeStampVal(anInfo,
+ theMKey2Profile,
+ theKey2Gauss,
+ theErr);
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
+ {
+ if (theMeshInfo->GetType() != eSTRUCTURE)
+ return PGrilleInfo();
+
+ EGrilleType type;
+ GetGrilleType(*theMeshInfo, type);
+ PGrilleInfo anInfo;
+ if (type == eGRILLE_STANDARD) {
+ const TInt nnoeuds = GetNbNodes(*theMeshInfo);
+ anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
+ }
+ else {
+ TIntVector aVec;
+ aVec.resize(theMeshInfo->GetDim());
+ for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
+ ETable aATable = eCOOR_IND1;
+ switch (aAxe) {
+ case 0:
+ aATable = eCOOR_IND1;
+ break;
+ case 1:
+ aATable = eCOOR_IND2;
+ break;
+ case 2:
+ aATable = eCOOR_IND3;
+ break;
+ }
+ aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
+ }
+ anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
+ }
+
+ GetGrilleInfo(anInfo);
+ anInfo->SetGrilleType(type);
+
+#ifdef _DEBUG_
+ INITMSG(MYDEBUG, "GetPGrilleInfo: ");
+ {
+ TInt aNbElem = anInfo->GetNbNodes();
+ BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
+ for (TInt iElem = 0; iElem < aNbElem; iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
+ }
+ TInt aNbCells = anInfo->GetNbCells();
+ BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
+ for (TInt iElem = 0; iElem < aNbCells; iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+ BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
+ for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+ BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
+ for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
+ ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
+ }
+ ADDMSG(MYVALUEDEBUG, std::endl);
+
+ }
+#endif
+
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
+ const PGrilleInfo& theInfo)
+ {
+ PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
+ return anInfo;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetGrilleInfo(TGrilleInfo& theInfo,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ EMaillage aMaillageType = aMeshInfo.myType;
+
+ GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
+ EGrilleType aGrilleType = theInfo.myGrilleType;
+
+ TErr aRet = 0;
+ if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
+ GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
+
+ TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
+ TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
+ TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
+ //med_axis_type aRepere;
+
+ aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ aModeSwitch,
+ &aCoord);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
+
+ //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
+ TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
+
+ aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ &aFamNumNode);
+
+ if (aRet < 0) {
+ // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
+ {
+ int mySize = (int)theInfo.myFamNumNode.size();
+ theInfo.myFamNumNode.clear();
+ theInfo.myFamNumNode.resize(mySize,0);
+ aRet = 0;
+ }
+ // else
+ // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
+ }
+ if (theErr)
+ *theErr = aRet;
+
+ //============================
+ }
+
+ if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
+ ETable aTable = eCOOR_IND1;
+ for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
+ switch (anAxis) {
+ case 1:
+ aTable = eCOOR_IND1;
+ break;
+ case 2:
+ aTable = eCOOR_IND2;
+ break;
+ case 3:
+ aTable = eCOOR_IND3;
+ break;
+ default:
+ aRet = -1;
+ }
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
+
+ TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
+ if (aNbIndexes < 0)
+ EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
+
+ TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
+ //TValueHolder<ETable, med_data_type > table(aTable);
+ //char aCompNames[MED_SNAME_SIZE+1];
+ //char anUnitNames[MED_SNAME_SIZE+1];
+ aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,MED_NO_IT,
+ anAxis,
+ &anIndexes);
+
+ //theInfo.SetCoordName(anAxis-1, aCompNames);
+ //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
+ theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
+
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
+ }
+ }
+
+ EGeometrieElement aGeom = theInfo.GetGeom();
+ EEntiteMaillage aEntity = theInfo.GetEntity();
+ TInt aNbCells = theInfo.GetNbCells();
+
+ theInfo.myFamNum.resize(aNbCells);
+ TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
+
+ aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
+ &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
+ med_geometry_type(aGeom), &aFamNum);
+
+ if (aMeshInfo.myDim == 3)
+ {
+ aGeom = theInfo.GetSubGeom();
+ aEntity = theInfo.GetSubEntity();
+ aNbCells = theInfo.GetNbSubCells();
+
+ theInfo.myFamSubNum.resize(aNbCells, 0);
+ TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
+
+ aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ med_entity_type(aEntity),
+ med_geometry_type(aGeom),
+ &aFamNum);
+ }
+ if (aRet < 0) {
+ // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
+ {
+ int mySize = (int)theInfo.myFamNumNode.size();
+ theInfo.myFamNumNode.clear();
+ theInfo.myFamNumNode.resize(mySize, 0);
+ aRet = 0;
+ }
+ // else
+ // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
+ }
+ if (theErr)
+ *theErr = aRet;
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
+ TErr* theErr)
+ {
+ SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr)
+ {
+ if (theInfo.myMeshInfo->myType != eSTRUCTURE)
+ return;
+ TFileWrapper aFileWrapper(myFile, theMode, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
+
+ MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+
+ TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
+
+ TErr aRet = 0;
+ aRet = MEDmeshGridTypeRd(myFile->Id(),
+ &aMeshName,
+ &aGrilleType);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
+
+ if (anInfo.myGrilleType == eGRILLE_STANDARD) {
+ TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
+ TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
+ TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
+ TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
+ med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
+ //med_axis_type aRepere = MED_CARTESIAN;
+
+ aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_UNDEF_DT,
+ aModeSwitch,
+ aNbNoeuds,
+ &aCoord);
+
+ if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
+
+ TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
+ aRet = MEDmeshGridStructWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_UNDEF_DT,
+ &aGrilleStructure);
+ if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
+
+ }
+ else {
+ for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
+ aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_UNDEF_DT,
+ aAxis+1,
+ anInfo.GetIndexes(aAxis).size(),
+ &anInfo.GetIndexes(aAxis)[0]);
+
+ if (aRet < 0)
+ EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
+ }
+
+ }
+
+ return;
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const PGrilleInfo& theInfo)
+ {
+ return PGrilleInfo(new TTGrilleInfo
+ (theMeshInfo,
+ theInfo));
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
+ {
+ return PGrilleInfo(); // not implemented????
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type)
+ {
+ return PGrilleInfo(new TTGrilleInfo
+ (theMeshInfo,
+ type));
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const TInt& nbNodes)
+ {
+ return PGrilleInfo(new TTGrilleInfo
+ (theMeshInfo,
+ type,
+ nbNodes));
+ }
+
+ //----------------------------------------------------------------------------
+ PGrilleInfo
+ TWrapper
+ ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const MED::TIntVector& nbNodeVec)
+ {
+ return PGrilleInfo(new TTGrilleInfo
+ (theMeshInfo,
+ type,
+ nbNodeVec));
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
+ EGrilleType& theGridType,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
+
+ MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
+
+ if (aMeshInfo.myType == eSTRUCTURE) {
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
+ TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
+ &aMeshName,
+ &aGridType);
+
+ if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ TWrapper
+ ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
+ TIntVector& theStruct,
+ TErr* theErr)
+ {
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+
+ if (theErr && *theErr < 0)
+ return;
+
+ TErr aRet;
+ MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
+
+ TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
+ TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
+
+ aRet = MEDmeshGridStructRd(myFile->Id(),
+ &aMeshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ &aGridStructure);
+ if (theErr)
+ *theErr = aRet;
+ else if (aRet < 0)
+ EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_Wrapper_HeaderFile
+#define MED_Wrapper_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Structures.hxx"
+#include "MED_Algorithm.hxx"
+
+#include <boost/thread/mutex.hpp>
+
+namespace MED
+{
+ //----------------------------------------------------------------------------
+ class TFile;
+ typedef boost::shared_ptr<TFile> PFile;
+
+ typedef enum {eLECTURE, eLECTURE_ECRITURE, eLECTURE_AJOUT, eCREATION} EModeAcces;
+
+ //----------------------------------------------------------------------------
+ //! Class that wraps the MED API
+ class MEDWRAPPER_EXPORT TWrapper
+ {
+ friend class TLockProxy;
+
+ typedef boost::mutex TMutex;
+ //! Synchronization primitive that allows supporting thread safety for the MED access
+ TMutex myMutex;
+
+ TWrapper();
+ TWrapper(const TWrapper&);
+ TWrapper& operator=(const TWrapper&);
+
+ public:
+ TWrapper(const std::string& theFileName);
+
+ virtual
+ ~TWrapper();
+
+ //! Read number of MED Mesh entities in the MED file
+ virtual
+ TInt
+ GetNbMeshes(TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Mesh representation by its number
+ virtual
+ void
+ GetMeshInfo(TInt theMeshId,
+ TMeshInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write the MEDWrapper MED Mesh representation into the MED file
+ virtual
+ void
+ SetMeshInfo(const TMeshInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetMeshInfo(const MED::TMeshInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED Mesh representation
+ virtual
+ PMeshInfo
+ CrMeshInfo(TInt theDim = 0,
+ TInt theSpaceDim = 0,
+ const std::string& theValue = "",
+ EMaillage theType = eNON_STRUCTURE,
+ const std::string& theDesc = "");
+
+ //! Copy constructor for the MEDWrapper MED Mesh representation
+ virtual
+ PMeshInfo
+ CrMeshInfo(const PMeshInfo& theInfo);
+
+ //! Get a MEDWrapper MED Mesh representation by its number
+ virtual
+ PMeshInfo
+ GetPMeshInfo(TInt theId,
+ TErr* theErr = NULL);
+
+ //! Read number of MED Family entities in the MED file
+ virtual
+ TInt
+ GetNbFamilies(const TMeshInfo& theMeshInfo,
+ TErr* theErr = NULL);
+
+ //! Read number of attributes for MED Family
+ virtual
+ TInt
+ GetNbFamAttr(TInt theFamId,
+ const TMeshInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Read number of MED Groups to which the MED Family belongs to
+ virtual
+ TInt
+ GetNbFamGroup(TInt theFamId,
+ const TMeshInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Family representation by its number
+ virtual
+ void
+ GetFamilyInfo(TInt theFamId,
+ TFamilyInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write a MEDWrapper MED Family representation into the MED file
+ virtual
+ void
+ SetFamilyInfo(const TFamilyInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetFamilyInfo(const MED::TFamilyInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED Family representation
+ virtual
+ PFamilyInfo
+ CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbGroup = 0,
+ TInt theNbAttr = 0,
+ TInt theId = 0,
+ const std::string& theValue = "");
+
+ //! Create a MEDWrapper MED Family representation
+ virtual
+ 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());
+
+ //! Copy constructor for the MEDWrapper MED Family representation
+ virtual
+ PFamilyInfo
+ CrFamilyInfo(const PMeshInfo& theMeshInfo,
+ const PFamilyInfo& theInfo);
+
+ //! Get a MEDWrapper MED Family representation by its number
+ PFamilyInfo
+ GetPFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theId,
+ TErr* theErr = NULL);
+
+ //! Read sequence of names for any descendant of TElemInfo
+ virtual
+ void
+ GetNames(TElemInfo& theInfo,
+ TInt theNb,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ //! Write sequence of names for any descendant of TElemInfo
+ virtual
+ void
+ SetNames(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ void
+ SetNames(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ //! Read sequence of numerated data for any descendant of TElemInfo
+ virtual
+ void
+ GetNumeration(TElemInfo& theInfo,
+ TInt theNb,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ //! Write sequence of numerated data for any descendant of TElemInfo
+ virtual
+ void
+ SetNumeration(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ void
+ SetNumeration(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ //! Read sequence of MED Families' indices for any descendant of TElemInfo
+ virtual
+ void
+ GetFamilies(TElemInfo& theInfo,
+ TInt theNb,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ //! Write sequence of MED Families' indices for any descendant of TElemInfo
+ virtual
+ void
+ SetFamilies(const TElemInfo& theInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ void
+ SetFamilies(const TElemInfo& theInfo,
+ EModeAcces theMode,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TErr* theErr = NULL);
+
+ //! Read number of nodes in MED Mesh
+ virtual
+ TInt
+ GetNbNodes(const TMeshInfo& theMeshInfo,
+ TErr* theErr = NULL);
+
+ virtual
+ TInt
+ GetNbNodes(const TMeshInfo& theMeshInfo,
+ ETable theTable,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Nodes representation from the MED file
+ virtual
+ void
+ GetNodeInfo(TNodeInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write the MEDWrapper MED Nodes representation into the MED file
+ virtual
+ void
+ SetNodeInfo(const TNodeInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetNodeInfo(const MED::TNodeInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED Nodes representation
+ virtual
+ PNodeInfo
+ CrNodeInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EModeSwitch theMode = eFULL_INTERLACE,
+ ERepere theSystem = eCART,
+ EBooleen theIsElemNum = eVRAI,
+ EBooleen theIsElemNames = eVRAI);
+
+ //! Create a MEDWrapper MED Nodes representation
+ virtual
+ PNodeInfo
+ CrNodeInfo(const PMeshInfo& theMeshInfo,
+ const TFloatVector& theNodeCoords,
+ EModeSwitch theMode = eFULL_INTERLACE,
+ ERepere theSystem = eCART,
+ const TStringVector& theCoordNames = TStringVector(),
+ const TStringVector& theCoordUnits = TStringVector(),
+ const TIntVector& theFamilyNums = TIntVector(),
+ const TIntVector& theElemNums = TIntVector(),
+ const TStringVector& theElemNames = TStringVector());
+
+ //! Copy constructor for the MEDWrapper MED Nodes representation
+ virtual
+ PNodeInfo
+ CrNodeInfo(const PMeshInfo& theMeshInfo,
+ const PNodeInfo& theInfo);
+
+ //! Get a MEDWrapper MED Nodes representation from the MED file
+ PNodeInfo
+ GetPNodeInfo(const PMeshInfo& theMeshInfo,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED Elements representation
+ virtual
+ PElemInfo
+ CrElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum = eVRAI,
+ EBooleen theIsElemNames = eVRAI);
+
+ //! Create a MEDWrapper MED Elements representation
+ virtual
+ PElemInfo
+ CrElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ const TIntVector& theFamNum,
+ const TIntVector& aElemNum,
+ const TStringVector& aElemNames);
+
+ //! Get a MEDWrapper MED Element representation from the MED file
+ PElemInfo
+ GetPElemInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity = eNOEUD,
+ EGeometrieElement theGeom = ePOINT1,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read number of MED Polygones in MED Mesh
+ virtual
+ TInt
+ GetNbPolygones(const TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read connectivity information for the MED Polygones in defined MED Mesh
+ virtual
+ TInt
+ GetPolygoneConnSize(const TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Polygones representation from the MED file
+ virtual
+ void
+ GetPolygoneInfo(TPolygoneInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write a MEDWrapper MED Polygones representation into the MED file
+ virtual
+ void
+ SetPolygoneInfo(const TPolygoneInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! 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());
+
+ //! Copy constructor for the MEDWrapper MED Polygones representation
+ virtual
+ PPolygoneInfo
+ CrPolygoneInfo(const PMeshInfo& theMeshInfo,
+ const PPolygoneInfo& theInfo);
+
+ //! Get a MEDWrapper MED Polygones representation from the MED file
+ PPolygoneInfo
+ GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD);
+
+ //! Read number of MED Polyedres in MED Mesh
+ virtual
+ TInt
+ GetNbPolyedres(const TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read connectivity information for the MED Polyedres in MED Mesh
+ virtual
+ void
+ GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
+ TInt& theNbFaces,
+ TInt& theConnSize,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Polyedres representation from the MED file
+ virtual
+ void
+ GetPolyedreInfo(TPolyedreInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write a MEDWrapper MED Polyedres representation into the MED file
+ virtual
+ void
+ SetPolyedreInfo(const TPolyedreInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
+ EModeAcces theMode,
+ 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);
+
+ //! Create a MEDWrapper MED Polyedres representation
+ virtual
+ PPolyedreInfo
+ CrPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theFaces,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode = eNOD,
+ const TIntVector& theFamilyNums = TIntVector(),
+ const TIntVector& theElemNums = TIntVector(),
+ const TStringVector& theElemNames = TStringVector());
+
+ //! Copy constructor for the MEDWrapper MED Polyedres representation
+ virtual
+ PPolyedreInfo
+ CrPolyedreInfo(const PMeshInfo& theMeshInfo,
+ const PPolyedreInfo& theInfo);
+
+ //! Get a MEDWrapper MED Polyedres representation from the MED file
+ PPolyedreInfo
+ GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD);
+
+ //! Get TEntityInfo which contains brief information about existing cells
+ // and their destribution among MED ENTITIES
+ virtual
+ TEntityInfo
+ GetEntityInfo(const TMeshInfo& theMeshInfo,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read number of cells for defined MED Mesh, ENTITY and geometrical type with given connectivity mode
+ virtual
+ TInt
+ GetNbCells(const TMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Cells representation from the MED file
+ virtual
+ void
+ GetCellInfo(TCellInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write the MEDWrapper MED Cells representation into the MED file
+ virtual
+ void
+ SetCellInfo(const TCellInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetCellInfo(const MED::TCellInfo& theInfo,
+ EModeAcces theMode,
+ 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 = eVRAI,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Create a MEDWrapper MED Cells representation
+ virtual
+ PCellInfo
+ CrCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode = eNOD,
+ const TIntVector& theFamilyNums = TIntVector(),
+ const TIntVector& theElemNums = TIntVector(),
+ const TStringVector& theElemNames = TStringVector(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Copy constructor for the MEDWrapper MED Cells representation
+ virtual
+ PCellInfo
+ CrCellInfo(const PMeshInfo& theMeshInfo,
+ const PCellInfo& theInfo);
+
+ //! Get a MEDWrapper MED Cells representation from the MED file
+ PCellInfo
+ GetPCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ EConnectivite theConnMode = eNOD,
+ TErr* theErr = NULL);
+
+ //! Read geom type of MED_BALL structural element
+ EGeometrieElement
+ GetBallGeom(const TMeshInfo& theMeshInfo);
+
+ //! Read number of balls in the Mesh
+ /*! This feature is supported since version 3.0 */
+ virtual
+ TInt
+ GetNbBalls(const TMeshInfo& theMeshInfo);
+
+ //! Read a MEDWrapper representation of MED_BALL from the MED file
+ /*! This feature is supported since version 3.0 */
+ virtual
+ void
+ GetBallInfo(TBallInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! 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);
+
+ void
+ SetBallInfo(const TBallInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr);
+
+ //! 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);
+
+ //! Create a MEDWrapper MED Balls representation
+ /*! This feature is supported since version 3.0 */
+ virtual
+ PBallInfo
+ CrBallInfo(const PMeshInfo& theMeshInfo,
+ const TIntVector& theNodes,
+ TFloatVector& theDiameters,
+ const TIntVector& theFamilyNums = TIntVector(),
+ const TIntVector& theElemNums = TIntVector());
+
+ //! Copy constructor for the MEDWrapper MED Balls representation
+ /*! This feature is supported since version 3.0 */
+ virtual
+ PBallInfo
+ CrBallInfo(const PMeshInfo& theMeshInfo,
+ const PBallInfo& theInfo);
+
+ //! Get a MEDWrapper MED Balls representation from the MED file
+ /*! This feature is supported since version 3.0 */
+ virtual
+ PBallInfo
+ GetPBallInfo(const PMeshInfo& theMeshInfo);
+
+ //! Read number of MED FIELDS in the MED Mesh
+ virtual
+ TInt
+ GetNbFields(TErr* theErr = NULL);
+
+ //! Read number of components for the MED FIELD by its order number
+ virtual
+ TInt
+ GetNbComp(TInt theFieldId,
+ TErr* theErr = NULL);
+
+ //! Read MEDWrapper MED FIELD representation from the MED file by its order number
+ virtual
+ void
+ GetFieldInfo(TInt theFieldId,
+ TFieldInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write MEDWrapper MED FIELD representation into the MED file
+ virtual
+ void
+ SetFieldInfo(const TFieldInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetFieldInfo(const MED::TFieldInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED FIELD representation
+ virtual
+ PFieldInfo
+ CrFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbComp = 0,
+ ETypeChamp theType = eFLOAT64,
+ const std::string& theValue = "",
+ EBooleen theIsLocal = eVRAI,
+ TInt theNbRef = 1);
+
+ //! Copy constructor for the MEDWrapper MED FIELD representation
+ virtual
+ PFieldInfo
+ CrFieldInfo(const PMeshInfo& theMeshInfo,
+ const PFieldInfo& theInfo);
+
+ //! Get a MEDWrapper MED FIELD representation from the MED file
+ PFieldInfo
+ GetPFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theId,
+ TErr* theErr = NULL);
+
+ //! Read number of MED GAUSS in the MED Mesh
+ virtual
+ TInt
+ GetNbGauss(TErr* theErr = NULL);
+
+ //! Read brief MED GAUSS information by its order number from the MED file
+ virtual
+ TGaussInfo::TInfo
+ GetGaussPreInfo(TInt theId,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED GAUSS representation by its order number from the MED file
+ virtual
+ void
+ GetGaussInfo(TInt theId,
+ TGaussInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED GAUSS representation
+ virtual
+ PGaussInfo
+ CrGaussInfo(const TGaussInfo::TInfo& theInfo,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Read number of MED TIMESTAMPS in the MED Mesh
+ /*!
+ In addition, the following information can be obtained:
+ - what MED ENTITY the MED TIMESTAMP is connected to;
+ - what geometrical types the MED TIMESTAMP is defined on.
+ */
+ virtual
+ TInt
+ GetNbTimeStamps(const TFieldInfo& theInfo,
+ const TEntityInfo& theEntityInfo,
+ EEntiteMaillage& theEntity,
+ TGeom2Size& theGeom2Size,
+ TErr* theErr = NULL);
+
+ //! Read MEDWrapper MED TIMESTAMP representation by its order number from the MED file
+ virtual
+ void
+ GetTimeStampInfo(TInt theTimeStampId,
+ TTimeStampInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampInfo
+ CrTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
+ const TGeom2NbGauss& theGeom2NbGauss = TGeom2NbGauss(),
+ TInt theNumDt = 0,
+ TInt theNumOrd = 0,
+ TFloat theDt = 0,
+ const std::string& theUnitDt = "",
+ const TGeom2Gauss& theGeom2Gauss = TGeom2Gauss());
+
+ //! Copy constructor for the MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampInfo
+ CrTimeStampInfo(const PFieldInfo& theFieldInfo,
+ const PTimeStampInfo& theInfo);
+
+ //! Get MEDWrapper MED TIMESTAMP representation from the MED file
+ PTimeStampInfo
+ GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
+ TInt theId,
+ TErr* theErr = NULL);
+
+ //! Read number of MED PROFILES in the MED file
+ virtual
+ TInt
+ GetNbProfiles(TErr* theErr = NULL);
+
+ //! Read brief MED PROFILE information by its order number from the MED file
+ virtual
+ TProfileInfo::TInfo
+ GetProfilePreInfo(TInt theId,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED PROFILE representation by its order number from the MED file
+ virtual
+ void
+ GetProfileInfo(TInt theId,
+ TProfileInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write a MEDWrapper MED PROFILE representation into the MED file
+ virtual
+ void
+ SetProfileInfo(const TProfileInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetProfileInfo(const TProfileInfo& theInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create a MEDWrapper MED PROFILE representation
+ virtual
+ PProfileInfo
+ CrProfileInfo(const TProfileInfo::TInfo& theInfo,
+ EModeProfil theMode = eCOMPACT);
+
+ //! Get a MEDWrapper MED PROFILE representation from the MED file
+ PProfileInfo
+ GetPProfileInfo(TInt theId,
+ EModeProfil theMode = eCOMPACT,
+ TErr* theErr = NULL);
+
+ //! Read the values for MEDWrapper MED TIMESTAMP from the MED file
+ virtual
+ void
+ GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr = NULL);
+
+ //! Write the values for MEDWrapper MED TIMESTAMP into the MED file
+ virtual
+ void
+ SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
+ TErr* theErr = NULL);
+
+ void
+ SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create the values for MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampValueBase
+ CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ ETypeChamp theTypeChamp,
+ const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Create the values for MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampValueBase
+ CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Copy constructor for the values for MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampValueBase
+ CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampValueBase& theInfo,
+ ETypeChamp theTypeChamp);
+
+ //! Copy constructor for the values for MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampValueBase
+ CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampValueBase& theInfo);
+
+ //! Get the values for MEDWrapper MED TIMESTAMP from the MED file
+ PTimeStampValueBase
+ GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr = NULL);
+
+ //
+ // Backward compatibility declarations
+ //
+
+ //! Read the values for MEDWrapper MED TIMESTAMP from the MED file
+ virtual
+ void
+ GetTimeStampVal(const PTimeStampVal& theVal,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr = NULL);
+
+ //! Write the values for MEDWrapper MED TIMESTAMP into the MED file
+ virtual
+ void
+ SetTimeStamp(const PTimeStampVal& theVal,
+ TErr* theErr = NULL);
+
+ //! Create the values for MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampVal
+ CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
+ const TGeom2Profile& theGeom2Profile = TGeom2Profile(),
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Copy constructor for the values for MEDWrapper MED TIMESTAMP representation
+ virtual
+ PTimeStampVal
+ CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampVal& theInfo);
+
+ //! Get the values for MEDWrapper MED TIMESTAMP from the MED file
+ PTimeStampVal
+ GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
+ const TMKey2Profile& theMKey2Profile,
+ const TKey2Gauss& theKey2Gauss,
+ TErr* theErr = NULL);
+
+ //! Read a MEDWrapper MED Grille representation from the MED file
+ PGrilleInfo
+ GetPGrilleInfo(const PMeshInfo& theMeshInfo);
+
+ //! Read a MEDWrapper MED Grille representation from the MED file
+ PGrilleInfo
+ GetPGrilleInfo(const PMeshInfo& theMeshInfo,
+ const PGrilleInfo& theInfo);
+
+ //! Read a MEDWrapper MED Grille representation from the MED file
+ virtual
+ void
+ GetGrilleInfo(TGrilleInfo& theInfo,
+ TErr* theErr = NULL);
+
+ //! Write the MEDWrapper MED Grille representation into the MED file
+ virtual
+ void
+ SetGrilleInfo(const TGrilleInfo& theInfo,
+ TErr* theErr = NULL);
+
+ void
+ SetGrilleInfo(const MED::TGrilleInfo& theGrilleInfo,
+ EModeAcces theMode,
+ TErr* theErr = NULL);
+
+ //! Create the MEDWrapper MED Grille representation
+ virtual
+ PGrilleInfo
+ CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const PGrilleInfo& theGrilleInfo);
+
+ //! Create the MEDWrapper MED Grille representation
+ virtual
+ PGrilleInfo
+ CrGrilleInfo(const PMeshInfo& theMeshInfo);
+
+ //! Create the MEDWrapper MED Grille representation
+ virtual
+ PGrilleInfo
+ CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type);
+
+ //! Create the MEDWrapper MED Grille representation
+ virtual
+ PGrilleInfo
+ CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const TInt& nbNodes);
+
+ //! Create the MEDWrapper MED Grille representation
+ virtual
+ PGrilleInfo
+ CrGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const MED::TIntVector& nbNodeVec);
+
+ //! Get a MEDWrapper MED Grille type
+ virtual
+ void
+ GetGrilleType(const TMeshInfo& theMeshInfo,
+ EGrilleType& type,
+ TErr* theErr = NULL);
+
+ //! Get a MEDWrapper MED Grille structure
+ void
+ GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
+ TIntVector& theStruct,
+ TErr* theErr = NULL);
+
+ protected:
+ PFile myFile;
+ };
+
+ //----------------------------------------------------------------------------
+ typedef SharedPtr<TWrapper> PWrapper;
+
+ //----------------------------------------------------------------------------
+ //! This class provides thread-safety for MEDWrapper interaction
+ class MEDWRAPPER_EXPORT TLockProxy
+ {
+ TLockProxy& operator=(const TLockProxy& );
+ TWrapper* myWrapper;
+
+ public:
+ TLockProxy(TWrapper* theWrapper);
+ ~TLockProxy();
+
+ TWrapper* operator->() const;
+ };
+
+ //----------------------------------------------------------------------------
+ //! Specialization of SharedPtr for TWrapper
+ template<>
+ class MEDWRAPPER_EXPORT SharedPtr<TWrapper>: public boost::shared_ptr<TWrapper>
+ {
+ public:
+ SharedPtr() {}
+
+ SharedPtr(TWrapper* p):
+ boost::shared_ptr<TWrapper>(p)
+ {}
+
+ template<class Y>
+ explicit SharedPtr(Y* p):
+ boost::shared_ptr<TWrapper>(p)
+ {}
+
+ template<class Y>
+ SharedPtr(const SharedPtr<Y>& r):
+ boost::shared_ptr<TWrapper>(boost::dynamic_pointer_cast<TWrapper,Y>(r))
+ {}
+
+ template<class Y>
+ SharedPtr&
+ operator=(const SharedPtr<Y>& r)
+ {
+ SharedPtr<TWrapper>(r).swap(*this);
+ return *this;
+ }
+
+ template<class Y>
+ SharedPtr&
+ operator()(Y* p) // Y must be complete
+ {
+ return operator=<Y>(SharedPtr<Y>(p));
+ }
+
+ template<class Y>
+ SharedPtr&
+ operator()(const SharedPtr<Y>& r) // Y must be complete
+ {
+ return operator=<Y>(SharedPtr<Y>(r));
+ }
+
+ TLockProxy
+ operator->() const // never throws
+ {
+ return TLockProxy(this->get());
+ }
+
+ protected:
+ operator const TWrapper&() const;
+
+ operator TWrapper&();
+
+ TWrapper&
+ operator*() const;
+
+ TWrapper*
+ get() const // never throws
+ {
+ return boost::shared_ptr<TWrapper>::get();
+ }
+ };
+}
+
+#endif // MED_Wrapper_HeaderFile
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef MED_WrapperDef_HeaderFile
+#define MED_WrapperDef_HeaderFile
+
+#ifdef WIN32
+# if defined(MEDWRAPPER_EXPORTS) || defined(MEDWrapper_EXPORTS)
+# define MEDWRAPPER_EXPORT __declspec( dllexport )
+# else
+# define MEDWRAPPER_EXPORT __declspec( dllimport )
+# endif // WIN32
+#else
+# define MEDWRAPPER_EXPORT
+#endif
+
+#endif // MED_WrapperDef_HeaderFile
+++ /dev/null
-# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# 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
-#
-
-# --- options ---
-# additional include directories
-INCLUDE_DIRECTORIES(
- ${MEDFILE_INCLUDE_DIRS}
- ${HDF5_INCLUDE_DIRS}
- ${Boost_INCLUDE_DIRS}
- ${KERNEL_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../Base
-)
-
-# additional preprocessor / compiler flags
-ADD_DEFINITIONS(
- ${HDF5_DEFINITIONS}
- ${BOOST_DEFINITIONS}
-)
-
-SET(_link_LIBRARIES
- ${HDF5_LIBS}
- ${MEDFILE_C_LIBRARIES}
- ${Boost_LIBRARIES}
- MEDWrapperBase
-)
-
-# --- headers ---
-
-# header files / no moc processing
-SET(MEDWrapper_V2_2_HEADERS
- MED_V2_2_Wrapper.hxx
-)
-
-# --- sources ---
-
-# sources / static
-SET(MEDWrapper_V2_2_SOURCES
- MED_V2_2_Wrapper.cxx
-)
-
-# --- rules ---
-
-ADD_LIBRARY(MEDWrapper_V2_2 ${MEDWrapper_V2_2_SOURCES})
-TARGET_LINK_LIBRARIES(MEDWrapper_V2_2 ${_link_LIBRARIES})
-INSTALL(TARGETS MEDWrapper_V2_2 EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
-
-INSTALL(FILES ${MEDWrapper_V2_2_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-
-#include "MED_V2_2_Wrapper.hxx"
-#include "MED_Algorithm.hxx"
-#include "MED_Utilities.hxx"
-
-#include <med.h>
-#include <med_err.h>
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-// #else
-// static int MYDEBUG = 0;
-#endif
-
-
-
-namespace MED
-{
- template<>
- TInt
- GetDESCLength<eV2_2>()
- {
- return 200;
- }
-
- template<>
- TInt
- GetIDENTLength<eV2_2>()
- {
- return 8;
- }
-
- template<>
- TInt
- GetNOMLength<eV2_2>()
- {
- return 64;
- }
-
- template<>
- TInt
- GetLNOMLength<eV2_2>()
- {
- return 80;
- }
-
- template<>
- TInt
- GetPNOMLength<eV2_2>()
- {
- return 16;
- }
-
- template<>
- void
- GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release)
- {
- majeur=MED_MAJOR_NUM;
- mineur=MED_MINOR_NUM;
- release=MED_RELEASE_NUM;
- }
-
- template<>
- TInt
- GetNbConn<eV2_2>(EGeometrieElement typmai,
- EEntiteMaillage typent,
- TInt mdim)
- {
- return typmai%100;
- }
-
- namespace V2_2
- {
-
- //---------------------------------------------------------------
- class TFile{
- TFile();
- TFile(const TFile&);
-
- public:
- TFile(const std::string& theFileName):
- myCount(0),
- myFid(0),
- myFileName(theFileName)
- {}
-
- ~TFile()
- {
- Close();
- }
-
- void
- Open(EModeAcces theMode, TErr* theErr = NULL)
- {
- if(myCount++ == 0){
- const char* aFileName = myFileName.c_str();
- myFid = MEDfileOpen(aFileName,med_access_mode(theMode));
- }
- if(theErr)
- *theErr = TErr(myFid);
- else if(myFid < 0)
- EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
- }
-
- const TIdt& Id() const
- {
- if(myFid < 0)
- EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
- return myFid;
- }
-
- void Close()
- {
- if(--myCount == 0)
- MEDfileClose(myFid);
- }
-
- protected:
- TInt myCount;
- TIdt myFid;
- std::string myFileName;
- };
-
-
- //---------------------------------------------------------------
- class TFileWrapper
- {
- PFile myFile;
-
- public:
- TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
- myFile(theFile)
- {
- myFile->Open(theMode,theErr);
- }
-
- ~TFileWrapper()
- {
- myFile->Close();
- }
- };
-
-
- //---------------------------------------------------------------
- TVWrapper::TVWrapper(const std::string& theFileName):
- myFile(new TFile(theFileName))
- {
- TErr aRet;
- myFile->Open( eLECTURE_ECRITURE, &aRet );
- // if(aRet < 0)
- // myFile->Close();
- // myFile->Open( eLECTURE_AJOUT, &aRet );
- // }
- if(aRet < 0) {
- myFile->Close();
- myFile->Open( eLECTURE, &aRet );
- }
- if(aRet < 0) {
- myFile->Close();
- myFile->Open( eCREATION, &aRet );
- }
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbMeshes(TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- return MEDnMesh(myFile->Id());
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetMeshInfo(TInt theMeshId,
- MED::TMeshInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TValueHolder<TString, char> aMeshName(theInfo.myName);
- TValueHolder<TInt, med_int> aDim(theInfo.myDim);
- TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
- TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
- char dtunit[MED_SNAME_SIZE+1];
- med_sorting_type sorttype;
- med_int nstep;
- med_axis_type at;
- int naxis=MEDmeshnAxis(myFile->Id(),theMeshId);
- char *axisname=new char[naxis*MED_SNAME_SIZE+1];
- char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
- TErr aRet = MEDmeshInfo(myFile->Id(),
- theMeshId,
- &aMeshName,
- &aSpaceDim,
- &aDim,
- &aType,
- &theInfo.myDesc[0],
- dtunit,
- &sorttype,
- &nstep,
- &at,
- axisname,
- axisunit);
- delete [] axisname;
- delete [] axisunit;
- if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmeshInfo(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetMeshInfo(const MED::TMeshInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
-
- TValueHolder<TString, char> aMeshName(anInfo.myName);
- TValueHolder<TInt, med_int> aDim(anInfo.myDim);
- TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
- TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
- TValueHolder<TString, char> aDesc(anInfo.myDesc);
-
- char *nam=new char[aSpaceDim*MED_SNAME_SIZE+1];
- std::fill(nam,nam+aSpaceDim*MED_SNAME_SIZE+1,'\0');
- char *unit=new char[aSpaceDim*MED_SNAME_SIZE+1];
- std::fill(unit,unit+aSpaceDim*MED_SNAME_SIZE+1,'\0');
- TErr aRet = MEDmeshCr(myFile->Id(),
- &aMeshName,
- aSpaceDim,
- aDim,
- aType,
- &aDesc,
- "",
- MED_SORT_DTIT,
- MED_CARTESIAN,
- nam,
- unit);
- delete [] nam;
- delete [] unit;
-
- //if(aRet == 0)
- // aRet = MEDunvCr(myFile->Id(),&aMeshName);
-
- INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmeshCr(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetMeshInfo(const MED::TMeshInfo& theInfo,
- TErr* theErr)
- {
- TErr aRet;
- SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
-
- if(aRet < 0)
- SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
-
- if(aRet < 0)
- SetMeshInfo(theInfo,eCREATION,&aRet);
-
- if(theErr)
- *theErr = aRet;
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbFamilies(const MED::TMeshInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
- TValueHolder<TString, char> aName(anInfo.myName);
- return MEDnFamily(myFile->Id(),&aName);
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbFamAttr(TInt theFamId,
- const MED::TMeshInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
-
- TValueHolder<TString, char> aName(anInfo.myName);
-
- return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId);
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbFamGroup(TInt theFamId,
- const MED::TMeshInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
-
- TValueHolder<TString, char> aName(anInfo.myName);
-
- return MEDnFamilyGroup(myFile->Id(),&aName,theFamId);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetFamilyInfo(TInt theFamId,
- MED::TFamilyInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TString, char> aFamilyName(theInfo.myName);
- TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
- TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
- TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
- TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
- TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
-
- TErr aRet = MEDfamily23Info(myFile->Id(),
- &aMeshName,
- theFamId,
- &aFamilyName,
- &anAttrId,
- &anAttrVal,
- &anAttrDesc,
- &aFamilyId,
- &aGroupNames);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<<
- " aMeshInfo.myName = '"<<&aMeshName<<
- "'; theFamId = "<<theFamId<<
- "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
- "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TString, char> aFamilyName(anInfo.myName);
- TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
- TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
- TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
- TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
- TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
- TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
- TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
-
- TErr aRet = MEDfamilyCr(myFile->Id(),
- &aMeshName,
- &aFamilyName,
- aFamilyId,
- aNbGroup,
- &aGroupNames);
-
- INITMSG(MYDEBUG,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamilyCr(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
- TErr* theErr)
- {
- TErr aRet;
- SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
-
- if(aRet < 0)
- SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
-
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetNames(TElemInfo& theInfo,
- TInt theNb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- if ( theGeom == eBALL )
- theGeom = GetBallGeom( theInfo.myMeshInfo );
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
- TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
-
- TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- &anElemNames);
-
- theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
-
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetNumeration(TElemInfo& theInfo,
- TInt theNb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- if ( theGeom == eBALL )
- theGeom = GetBallGeom( theInfo.myMeshInfo );
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
-
- TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- &anElemNum);
-
- theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
-
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetFamilies(TElemInfo& theInfo,
- TInt theNb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- if ( theGeom == eBALL )
- theGeom = GetBallGeom( theInfo.myMeshInfo );
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
-
- TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- &aFamNum);
-
- if(aRet < 0)
- {
-// if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
- {
- int aSize = (int)theInfo.myFamNum->size();
- theInfo.myFamNum->clear();
- theInfo.myFamNum->resize(aSize,0);
- aRet = 0;
- }
-// else
-// EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
- }
- if(theErr)
- *theErr = aRet;
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetNames(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetNames(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- if ( theGeom == eBALL )
- theGeom = GetBallGeom( theInfo.myMeshInfo );
-
- MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TErr aRet = 0;
- if(theInfo.myIsElemNames)
- {
- TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
- TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
-
- aRet = MEDmeshEntityNameWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- (TInt)anInfo.myElemNames->size(),
- &anElemNames);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)");
- }
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetNumeration(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetNumeration(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- if ( theGeom == eBALL )
- theGeom = GetBallGeom( theInfo.myMeshInfo );
-
- MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TErr aRet = 0;
- if(theInfo.myIsElemNum)
- {
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
-
- aRet = MEDmeshEntityNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- (TInt)anInfo.myElemNum->size(),
- &anElemNum);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)");
- }
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetFamilies(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetFamilies(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- if ( theGeom == eBALL )
- theGeom = GetBallGeom( theInfo.myMeshInfo );
-
- MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
-
- TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- (TInt)anInfo.myFamNum->size(),
- &aFamNum);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
- }
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
- ETable theTable,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<ETable, med_data_type > aTable(theTable);
- med_bool chgt,trsf;
- return MEDmeshnEntity(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE,
- aTable,
- MED_NO_CMODE,
- &chgt,
- &trsf);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetNodeInfo(MED::TNodeInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
- TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
- TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
- TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
- TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
- TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
- //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
- TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
- //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
- TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
- TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
-
- TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- aModeSwitch,
- &aCoord);
-
- TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE ,
- &aFamNum);
- if (aRet2 < 0)
- {
-// if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
- {
- int mySize = (int)theInfo.myFamNum->size();
- theInfo.myFamNum->clear();
- theInfo.myFamNum->resize(mySize,0);
- }
-// else
-// EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
- }
-
- if ( MEDmeshEntityNameRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE ,
- &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
-
- if ( MEDmeshEntityNumberRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE ,
- &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX;
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetNodeInfo(const MED::TNodeInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
- TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
- TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
- TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
- TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
- TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
- TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
- TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
- TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
- TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
- TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
-
- TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NO_DT,
- aModeSwitch,
- aNbElem,
- &aCoord);
-
- MEDmeshEntityFamilyNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE,
- aNbElem,
- &aFamNum);
- if(anIsElemNames)
- MEDmeshEntityNameWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE,
- aNbElem,
- &anElemNames);
- if(anIsElemNum)
- MEDmeshEntityNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE,
- aNbElem,
- &anElemNum);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetNodeInfo(const MED::TNodeInfo& theInfo,
- TErr* theErr)
- {
- TErr aRet;
- SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
-
- if(aRet < 0)
- SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
-
- if(theErr)
- *theErr = aRet;
- }
-
-
- //-----------------------------------------------------------------
- void
- TVWrapper
- ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
- TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
- TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
- TInt aNbElem = (TInt)theInfo.myElemNum->size();
-
- TErr aRet;
- aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
- MED_NO_DT, MED_NO_IT,
- anEntity, aGeom,
- aConnMode, &anIndex, &aConn);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
-
- if(theInfo.myIsElemNames){
- GetNames(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- if(theInfo.myIsElemNum){
- GetNumeration(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- GetFamilies(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
- TErr* theErr)
- {
- SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
- TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
- TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
-
- TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
- MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
- anEntity, aGeom,
- aConnMode, anInfo.myNbElem + 1,
- &anIndex, &aConn);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
-
- SetNames(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
- if(theErr)
- *theErr = aRet;
-
- SetNumeration(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
- if(theErr)
- *theErr = aRet;
-
- SetFamilies(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
- }
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return 0;
-
- MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- med_int aTaille = 0;
- med_bool chgt,trsf;
- aTaille=MEDmeshnEntity(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- med_entity_type(theEntity),
- med_geometry_type(theGeom),
- MED_CONNECTIVITY,
- med_connectivity_mode(theConnMode),
- &chgt,
- &trsf);
-
-
- if(aTaille < 0)
- EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
-
- return TInt(aTaille);
- }
-
- //-----------------------------------------------------------------
- void
- TVWrapper
- ::GetPolyedreInfo(TPolyedreInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TInt aNbElem = (TInt)theInfo.myElemNum->size();
- TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
- TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
- TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
-
- TErr aRet;
- aRet = MEDmeshPolyhedronRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_CELL,
- aConnMode,
- &anIndex,
- &aFaces,
- &aConn);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
-
- if(theInfo.myIsElemNames){
- GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- if(theInfo.myIsElemNum){
- GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
- TErr* theErr)
- {
- SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
- TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
- TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
-
- TErr aRet;
- aRet = MEDmeshPolyhedronWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_UNDEF_DT,
- MED_CELL,
- aConnMode,
- anInfo.myNbElem+1,
- &anIndex,
- (TInt)anInfo.myFaces->size(),
- &aFaces,
- &aConn);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
-
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
-
- if(theInfo.myIsElemNames){
- TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
- aRet = MEDmeshEntityNameWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- MED_POLYHEDRON,
- (TInt)anInfo.myElemNames->size(),
- &anElemNames);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
- }
-
- if(theInfo.myIsElemNum){
- TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
- aRet = MEDmeshEntityNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- MED_POLYHEDRON,
- (TInt)anInfo.myElemNum->size(),
- &anElemNum);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
- }
-
-
- TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
- aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- MED_POLYHEDRON,
- (TInt)anInfo.myFamNum->size(),
- &aFamNum);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
- }
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
- TInt& theNbFaces,
- TInt& theConnSize,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
-
- MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
- //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
- //TValueHolder<TInt, med_int> aConnSize(theConnSize);
-
- med_bool chgt,trsf;
- theNbFaces = MEDmeshnEntity(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_CELL,
- MED_POLYHEDRON,
- MED_INDEX_NODE,
- aConnMode,
- &chgt,
- &trsf);
-
- theConnSize = MEDmeshnEntity(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_CELL,
- MED_POLYHEDRON,
- MED_CONNECTIVITY,
- aConnMode,
- &chgt,
- &trsf);
-
- if(theNbFaces < 0 || theConnSize<0)
- EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
-
- }
-
- //-----------------------------------------------------------------
- TEntityInfo
- TVWrapper
- ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- TEntityInfo anInfo;
-
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return anInfo;
-
- if(theMeshInfo.GetType() == eNON_STRUCTURE) {
- TInt aNbElem = GetNbNodes(theMeshInfo);
- if(aNbElem > 0){
- anInfo[eNOEUD][ePOINT1] = aNbElem;
- const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
- TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
- TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
- for(; anIter != anIterEnd; anIter++){
- const EEntiteMaillage& anEntity = anIter->first;
- const TGeomSet& aGeomSet = anIter->second;
- TGeomSet::const_iterator anIter2 = aGeomSet.begin();
- TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
- for(; anIter2 != anIterEnd2; anIter2++){
- const EGeometrieElement& aGeom = *anIter2;
- aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
- if(aNbElem > 0) {
- if ( anEntity == eSTRUCT_ELEMENT ) {
- const TInt nbStructTypes = aNbElem;
- for ( TInt structType = 0; structType < nbStructTypes; ++structType ) {
- // check type name to keep only "MED_BALL" structured element
- TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName );
- char geotypename[ MED_NAME_SIZE + 1] = "";
- med_geometry_type geotype;
- MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
- med_entity_type(anEntity), structType+1,
- geotypename, &geotype);
- if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) {
- aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype),
- theConnMode, theErr);
- if ( aNbElem > 0 )
- anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
- }
- }
- }
- else {
- anInfo[anEntity][aGeom] = aNbElem;
- }
- }
- }
- }
- }
- } else { // eSTRUCTURE
- EGrilleType aGrilleType;
- TInt aNbNodes = 1;
- TInt aNbElem = 1;
- TInt aNbSub = 0;
- TInt aDim = theMeshInfo.GetDim();
- EGeometrieElement aGeom, aSubGeom;
- EEntiteMaillage aSubEntity = eMAILLE;
-
- GetGrilleType(theMeshInfo, aGrilleType);
-
- TIntVector aStruct(aDim);
- if(aGrilleType == eGRILLE_STANDARD)
- {
- GetGrilleStruct(theMeshInfo, aStruct, theErr);
- }
- else
- { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
- ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
- for(med_int anAxis = 0; anAxis < aDim; anAxis++)
- aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
- }
- for(med_int i = 0; i < aDim; i++){
- aNbNodes = aNbNodes * aStruct[i];
- aNbElem = aNbElem * (aStruct[i] - 1);
- }
- switch(aDim){
- case 1:
- aGeom = eSEG2;
- break;
- case 2:
- aGeom = eQUAD4;
- aSubGeom = eSEG2;
- aSubEntity = eARETE;
- aNbSub =
- (aStruct[0] ) * (aStruct[1]-1) +
- (aStruct[0]-1) * (aStruct[1] );
- break;
- case 3:
- aGeom = eHEXA8;
- aSubGeom = eQUAD4;
- aSubEntity = eFACE;
- aNbSub =
- (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) +
- (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) +
- (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] );
- break;
- }
- anInfo[eNOEUD][ePOINT1] = aNbNodes;
- anInfo[eMAILLE][aGeom] = aNbElem;
- if ( aDim > 1 )
- anInfo[aSubEntity][aSubGeom] = aNbSub;
- }
- return anInfo;
- }
-
-
- //-----------------------------------------------------------------
- TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- med_bool chgt,trsf;
- switch ( theGeom )
- {
- case MED::ePOLYGONE:
- case MED::ePOLYGON2:
- {
- return MEDmeshnEntity(myFile->Id(),&aMeshName,
- MED_NO_DT,MED_NO_IT,
- med_entity_type(theEntity),med_geometry_type(theGeom),
- MED_INDEX_NODE,med_connectivity_mode(theConnMode),
- &chgt,&trsf)-1;
- }
- case MED::ePOLYEDRE:
- {
- return MEDmeshnEntity(myFile->Id(),&aMeshName,
- MED_NO_DT,MED_NO_IT,
- med_entity_type(theEntity),MED_POLYHEDRON,
- MED_INDEX_FACE,med_connectivity_mode(theConnMode),
- &chgt,&trsf)-1;
- }
- case MED::eBALL:
- {
- return GetNbBalls( theMeshInfo );
- }
- default:
- {
- return MEDmeshnEntity(myFile->Id(),&aMeshName,
- MED_NO_DT,MED_NO_IT,
- med_entity_type(theEntity),med_geometry_type(theGeom),
- MED_CONNECTIVITY,med_connectivity_mode(theConnMode),
- &chgt,&trsf);
- }
- }
- return 0;
- }
-
-
- //----------------------------------------------------------------------------
- void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
- TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
- TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
- TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
- TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
- TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
- TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
-
- TErr aRet;
- aRet = MEDmeshElementRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- aConnMode,
- aModeSwitch,
- &aConn,
- &anIsElemNames,
- &anElemNames,
- &anIsElemNum,
- &anElemNum,
- &anIsFamNum,
- &aFamNum);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
-
- if (anIsFamNum == MED_FALSE)
- {
- int mySize = (int) theInfo.myFamNum->size();
- theInfo.myFamNum->clear();
- theInfo.myFamNum->resize(mySize, 0);
- }
-
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetCellInfo(const MED::TCellInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
-
- TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
- TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
- TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
- TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
- TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
- TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
- TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
- TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
- TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
- TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
-
- TErr aRet;
- aRet = MEDmeshElementConnectivityWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_UNDEF_DT,
- anEntity,
- aGeom,
- aConnMode,
- aModeSwitch,
- aNbElem,
- &aConn);
-
- MEDmeshEntityFamilyNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- aNbElem,
- &aFamNum);
- if(anIsElemNames)
- MEDmeshEntityNameWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- aNbElem,
- &anElemNames);
- if(anIsElemNum)
- MEDmeshEntityNumberWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- anEntity,
- aGeom,
- aNbElem,
- &anElemNum);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetCellInfo(const MED::TCellInfo& theInfo,
- TErr* theErr)
- {
- SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
- }
-
- //----------------------------------------------------------------------------
- //! Read geom type of MED_BALL structural element
- EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE);
-
- // read med_geometry_type of "MED_BALL" element
- char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
- return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) );
- }
-
- //----------------------------------------------------------------------------
- //! Read number of balls in the Mesh
- TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE);
-
- EGeometrieElement ballType = GetBallGeom( theMeshInfo );
- if ( ballType < 0 )
- return 0;
-
- return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD );
- }
-
- //----------------------------------------------------------------------------
- //! Read a MEDWrapped representation of MED_BALL from the MED file
- void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- // check geometry of MED_BALL
- if ( theInfo.myGeom == eBALL )
- {
- theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo );
- if ( theInfo.myGeom < 0 ) {
- if ( !theErr )
- EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh");
- *theErr = theInfo.myGeom;
- return;
- }
- }
-
- // read nodes ids
- GetCellInfo( theInfo );
-
- // read diameters
- TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
- TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
- char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
-
- TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName,
- MED_NO_DT, MED_NO_IT,
- aGeom,
- varattname,
- &aDiam);
- if ( theErr )
- *theErr = aRet;
- else if ( aRet < 0 )
- EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters");
- }
-
-
- //----------------------------------------------------------------------------
- //! Write a MEDWrapped representation of MED_BALL to the MED file
- void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- TErr ret;
- char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
- EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo );
- if ( ballGeom < 0 )
- {
- // no ball model in the file, create support mesh for it
- char dummyname [MED_NAME_SIZE*3+1]="";
- if (( ret = MEDsupportMeshCr( myFile->Id(),
- ballsupportname,
- theInfo.myMeshInfo->GetSpaceDim(),
- theInfo.myMeshInfo->GetDim(),
- "Support mesh for a ball model",
- MED_CARTESIAN,
- /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) {
- if ( !theErr )
- EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr");
- *theErr = ret;
- return;
- }
- // write coordinates of 1 node
- med_float coord[3] = {0,0,0};
- if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
- ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
- MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
- if ( !theErr )
- EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr");
- *theErr = ret;
- return;
- }
- // ball model creation
- char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
- if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
- geotypename,
- theInfo.myMeshInfo->GetSpaceDim(),
- ballsupportname,
- MED_NODE,MED_NONE)) < 0 ) {
- if ( !theErr )
- EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr");
- *theErr = ret;
- return;
- }
- // create diameter attribute
- if (( ret = MEDstructElementVarAttCr(myFile->Id(),
- geotypename, MED_BALL_DIAMETER,
- MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
- if ( !theErr )
- EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr");
- *theErr = ret;
- return;
- }
- } // ballGeom < 0
-
- TBallInfo& aBallInfo = ((TBallInfo&) theInfo );
- aBallInfo.myGeom = ballGeom;
-
- // write node ids
- SetCellInfo(theInfo,theMode,theErr);
- if ( theErr && theErr < 0 )
- return;
-
- // write diameter
- TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
- TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
- TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
- ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
- MED_NO_DT, MED_NO_IT,
- aGeom, MED_BALL_DIAMETER,
- theInfo.myNbElem, &aDiam);
- if ( theErr )
- *theErr = ret;
- else if ( ret < 0 )
- EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr");
- }
-
- //----------------------------------------------------------------------------
- //! Write a MEDWrapped representation of MED_BALL to the MED file
- void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr)
- {
- SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr );
- }
-
- //-----------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbFields(TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- return MEDnField(myFile->Id());
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbComp(TInt theFieldId,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- return MEDfieldnComponent(myFile->Id(),theFieldId);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetFieldInfo(TInt theFieldId,
- MED::TFieldInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TString aFieldName(256); // Protect from memory problems with too long names
- TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
- TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
- TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
- MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
-
- TErr aRet;
- med_bool local;
- char dtunit[MED_SNAME_SIZE+1];
- char local_mesh_name[MED_NAME_SIZE+1]="";
- med_int nbofstp;
- theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
- aRet = MEDfieldInfo(myFile->Id(),
- theFieldId,
- &aFieldName[0],
- local_mesh_name,
- &local,
- &aType,
- &aCompNames,
- &anUnitNames,
- dtunit,
- &nbofstp);
-
- if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
- if(theErr)
- *theErr = -1;
- return;
- }
-
- theInfo.SetName(aFieldName);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetFieldInfo(const MED::TFieldInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
-
- TValueHolder<TString, char> aFieldName(anInfo.myName);
- TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
- TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
- TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
- MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
- TErr aRet;
- char dtunit[MED_SNAME_SIZE+1];
- std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
- aRet = MEDfieldCr(myFile->Id(),
- &aFieldName,
- aType,
- anInfo.myNbComp,
- &aCompNames,
- &anUnitNames,
- dtunit,
- &aMeshInfo.myName[0]);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetFieldInfo(const MED::TFieldInfo& theInfo,
- TErr* theErr)
- {
- TErr aRet;
- SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
-
- if(aRet < 0)
- SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
-
- if(theErr)
- *theErr = aRet;
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbGauss(TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- return MEDnLocalization(myFile->Id());
- }
-
-
- //----------------------------------------------------------------------------
- TGaussInfo::TInfo
- TVWrapper
- ::GetGaussPreInfo(TInt theId,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
-
- med_int aNbGaussPoints = med_int();
- TVector<char> aName(GetNOMLength<eV2_2>()+1);
- med_geometry_type aGeom = MED_NONE;
-
- TErr aRet;
- med_int dim;
- char geointerpname[MED_NAME_SIZE+1]="";
- char ipointstructmeshname[MED_NAME_SIZE+1]="";
- med_int nsectionmeshcell;
- med_geometry_type sectiongeotype;
- aRet = MEDlocalizationInfo (myFile->Id(),
- theId,
- &aName[0],
- &aGeom,
- &dim,
- &aNbGaussPoints,
- geointerpname,
- ipointstructmeshname,
- &nsectionmeshcell,
- §iongeotype);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
- return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
- TInt(aNbGaussPoints));
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetGaussInfo(TInt theId,
- TGaussInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
- TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
- TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
- TValueHolder<TString, char> aGaussName(theInfo.myName);
-
- TErr aRet;
- aRet = MEDlocalizationRd(myFile->Id(),
- &aGaussName,
- aModeSwitch,
- &aRefCoord,
- &aGaussCoord,
- &aWeight);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
- }
-
-
- //----------------------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbProfiles(TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return -1;
-
- return MEDnProfile(myFile->Id());
- }
-
- TProfileInfo::TInfo
- TVWrapper
- ::GetProfilePreInfo(TInt theId,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return TProfileInfo::TInfo();
-
- med_int aSize = -1;
- TVector<char> aName(GetNOMLength<eV2_2>()+1);
-
- TErr aRet;
- aRet = MEDprofileInfo(myFile->Id(),
- theId,
- &aName[0],
- &aSize);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
-
- return TProfileInfo::TInfo(&aName[0],aSize);
- }
-
- void
- TVWrapper
- ::GetProfileInfo(TInt theId,
- TProfileInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
- TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
- TValueHolder<TString, char> aProfileName(anInfo.myName);
-
- TErr aRet;
- aRet = MEDprofileRd(myFile->Id(),
- &aProfileName,
- &anElemNum);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
- }
-
- void
- TVWrapper
- ::SetProfileInfo(const TProfileInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
- TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
- TValueHolder<TString, char> aProfileName(anInfo.myName);
-
- TErr aRet;
- aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
- &aProfileName, // tableau de valeurs du profil.
- theInfo.GetSize(), // taille du profil.
- &anElemNum); // nom profil.
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
- }
-
- void
- TVWrapper
- ::SetProfileInfo(const TProfileInfo& theInfo,
- TErr* theErr)
- {
- TErr aRet;
- SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
-
- if(aRet < 0)
- SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
-
- if(aRet < 0)
- SetProfileInfo(theInfo,eCREATION,&aRet);
-
- if(theErr)
- *theErr = aRet;
- }
-
- //-----------------------------------------------------------------
- TInt
- TVWrapper
- ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
- const MED::TEntityInfo& theEntityInfo,
- EEntiteMaillage& theEntity,
- TGeom2Size& theGeom2Size,
- TErr* theErr)
- {
- theEntity = EEntiteMaillage(-1);
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr){
- if(theEntityInfo.empty())
- *theErr = -1;
- if(*theErr < 0)
- return -1;
- }else if(theEntityInfo.empty())
- EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
-
- bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
-
- theGeom2Size.clear();
- TInt aNbTimeStamps = 0;
- TIdt anId = myFile->Id();
-
- MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
- TValueHolder<TString, char> aFieldName(anInfo.myName);
- MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
-
- // workaround for IPAL13676
- MED::TEntityInfo localEntityInfo = theEntityInfo;
- TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
- if(anLocalIter != localEntityInfo.end()){
- localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
- }
-
- TEntityInfo::const_iterator anIter = localEntityInfo.begin();
- for(; anIter != localEntityInfo.end(); anIter++){
- med_entity_type anEntity = med_entity_type(anIter->first);
- const TGeom2Size& aGeom2Size = anIter->second;
- TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
- for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
- med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
- char aMeshName[MED_NAME_SIZE+1];
- med_bool islocal;
- med_field_type ft;
- char dtunit[MED_SNAME_SIZE+1];
- med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
- char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
- char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
- TInt aNbStamps;
- MEDfieldInfoByName(anId,
- &aFieldName,
- aMeshName,
- &islocal,
- &ft,
- cname,
- unitname,
- dtunit,
- &aNbStamps);
- delete [] cname;
- delete [] unitname;
- med_int nval = 0;
- med_int aNumDt;
- med_int aNumOrd;
- med_float aDt;
- if (aNbStamps > 0)
- {
- MEDfieldComputingStepInfo(anId,
- &aFieldName,
- 1,
- &aNumDt,
- &aNumOrd,
- &aDt);
- char profilename[MED_NAME_SIZE+1];
- char locname[MED_NAME_SIZE+1];
- med_int profilsize;
- med_int aNbGauss;
-
- // protection from crash (division by zero)
- // inside MEDfieldnValueWithProfile function
- // caused by the workaround for IPAL13676 (see above)
- if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
- continue;
-
- nval = MEDfieldnValueWithProfile(anId,
- &aFieldName,
- aNumDt,
- aNumOrd,
- anEntity,
- med_geometry_type(aGeom),
- 1,
- MED_COMPACT_STMODE,
- profilename,
- &profilsize,
- locname,
- &aNbGauss);
- }
- bool anIsSatisfied =(nval > 0);
- if(anIsSatisfied){
- INITMSG(MYDEBUG,
- "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
- "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
- if(anIsPerformAdditionalCheck){
- anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
- if(!anIsSatisfied){
- INITMSG(MYDEBUG,
- "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
- "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
- }
- }
- }
- if(anIsSatisfied){
- theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
- theEntity = EEntiteMaillage(anEntity);
- aNbTimeStamps = aNbStamps;
- }
- }
- if(!theGeom2Size.empty())
- break;
- }
- return aNbTimeStamps;
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetTimeStampInfo(TInt theTimeStampId,
- MED::TTimeStampInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
-
- if(theErr){
- if(aGeom2Size.empty())
- *theErr = -1;
- if(*theErr < 0)
- return;
- }else if(aGeom2Size.empty())
- EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
-
- MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
- MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
-
- TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
- TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
- TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
- TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
- TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
- TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
-
- TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
-
- // just to get a time stamp unit (anUnitDt)
- med_field_type aFieldType;
- med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
- char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
- char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
- TInt aNbStamps;
- MEDfieldInfoByName(myFile->Id(),
- &aFieldName,
- &aMeshName,
- &anIsLocal,
- &aFieldType,
- aCompName,
- aCompUnit,
- &anUnitDt,
- &aNbStamps);
- delete [] aCompName;
- delete [] aCompUnit;
-
- TGeom2Size::const_iterator anIter = aGeom2Size.begin();
- for(; anIter != aGeom2Size.end(); anIter++){
- const EGeometrieElement& aGeom = anIter->first;
- med_int aNbGauss = -1;
-
- TErr aRet;
- aRet = MEDfieldComputingStepInfo(myFile->Id(),
- &aFieldName,
- theTimeStampId,
- &aNumDt,
- &aNumOrd,
- &aDt);
- char profilename[MED_NAME_SIZE+1];
- med_int profilsize;
- char locname[MED_NAME_SIZE+1];
- MEDfieldnValueWithProfile(myFile->Id(),
- &aFieldName,
- aNumDt,
- aNumOrd,
- anEntity,
- med_geometry_type(aGeom),
- 1,
- MED_COMPACT_STMODE,
- profilename,
- &profilsize,
- locname,
- &aNbGauss);
-
- static TInt MAX_NB_GAUSS_POINTS = 32;
- if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
- aNbGauss = 1;
-
- aGeom2NbGauss[aGeom] = aNbGauss;
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
- }
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TIdt anId = myFile->Id();
-
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
- MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
-
- MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
- TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
- TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
-
- MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
- TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
- TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
-
- MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
- TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
-
- TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
- TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
-
- med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
- MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
- TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
-
- TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
- TGeom2Size::iterator anIter = aGeom2Size.begin();
- for(; anIter != aGeom2Size.end(); anIter++){
- EGeometrieElement aGeom = anIter->first;
- TInt aNbElem = anIter->second;
- med_int profilesize,aNbGauss;
-
- TInt aNbVal = MEDfieldnValueWithProfile(anId,
- &aFieldName,
- aNumDt,
- aNumOrd,
- anEntity,
- med_geometry_type(aGeom),
- 1,
- aProfileMode,
- &aProfileName[0],
- &profilesize,
- &aGaussName[0],
- &aNbGauss);
-
- if(aNbVal <= 0){
- if(theErr){
- *theErr = -1;
- return;
- }
- EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
- }
-
- TInt aNbComp = aFieldInfo->myNbComp;
- TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
- theTimeStampValue->AllocateValue(aGeom,
- aNbValue,
- aNbGauss,
- aNbComp);
- TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
-
- INITMSG(MYDEBUG,
- "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
- "; aNbVal = "<<aNbVal<<
- "; aNbValue = "<<aNbValue<<
- "; aNbGauss = "<<aNbGauss<<
- "; aNbComp = "<<aNbComp<<
- std::endl);
-
- TErr aRet = MEDfieldValueWithProfileRd(anId,
- &aFieldName,
- aNumDt,
- aNumOrd,
- anEntity,
- med_geometry_type(aGeom),
- aProfileMode,
- &aProfileName[0],
- aModeSwitch,
- MED_ALL_CONSTITUENT,
- theTimeStampValue->GetValuePtr(aGeom));
- if(aRet < 0){
- if(theErr){
- *theErr = MED_FALSE;
- return;
- }
- EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
- }
-
- MED::PGaussInfo aGaussInfo;
- TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
- if(strcmp(&aGaussName[0],"") != 0){
- MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
- if(anIter != theKey2Gauss.end()){
- aGaussInfo = anIter->second;
- aGeom2Gauss[aGeom] = aGaussInfo;
- }
- }
-
- MED::PProfileInfo aProfileInfo;
- if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
- MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
- if(anIter != aKey2Profile.end()){
- aProfileInfo = anIter->second;
- aGeom2Profile[aGeom] = aProfileInfo;
- }
- }
-
- if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
- if(theErr){
- *theErr = MED_FALSE;
- return;
- }
- EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
- }
-
- if(aProfileInfo && aProfileInfo->IsPresent()){
- TInt aNbSubElem = aProfileInfo->GetSize();
- TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
- if(aProfileSize != aValueSize){
- if(theErr){
- *theErr = -1;
- return;
- }
- EXCEPTION(std::runtime_error,
- "GetTimeStampValue - aProfileSize("<<aProfileSize<<
- ") != aValueSize("<<aValueSize<<
- "); aNbVal = "<<aNbVal<<
- "; anEntity = "<<anEntity<<
- "; aGeom = "<<aGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbSubElem = "<<aNbSubElem<<
- "; aNbComp = "<<aNbComp<<
- "; aNbGauss = "<<aNbGauss<<
- "");
- }
- }else{
- if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
- if(theErr){
- *theErr = -1;
- return;
- }
- EXCEPTION(std::runtime_error,
- "GetTimeStampValue - aNbElem("<<aNbElem<<
- ") != aNbValue("<<aNbValue<<
- "); aNbVal = "<<aNbVal<<
- "; anEntity = "<<anEntity<<
- "; aGeom = "<<aGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbComp = "<<aNbComp<<
- "; aNbGauss = "<<aNbGauss<<
- "");
- }
- }
- }
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
- EModeAcces theMode,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TErr aRet;
- TIdt anId = myFile->Id();
-
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
- MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
-
- MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
- TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
- TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
- TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
- TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
- TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
- MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
-
- MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
- TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
-
- MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
- TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
-
- const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
- TGeomSet::const_iterator anIter = aGeomSet.begin();
- for(; anIter != aGeomSet.end(); anIter++){
- EGeometrieElement aGeom = *anIter;
-
- TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
- MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
- if(aGaussIter != aGeom2Gauss.end()){
- MED::PGaussInfo aGaussInfo = aGaussIter->second;
- strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
- }
-
- TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
- med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
- MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
- if(aProfileIter != aGeom2Profile.end()){
- MED::PProfileInfo aProfileInfo = aProfileIter->second;
- aProfileMode = med_storage_mode(aProfileInfo->myMode);
- strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
- }
-
- med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
-
- aRet = MEDfieldValueWithProfileWr(anId,
- &aFieldName,
- aNumDt,
- aNumOrd,
- aDt,
- anEntity,
- med_geometry_type(aGeom),
- aProfileMode,
- &aProfileName[0],
- &aGaussName[0],
- aModeSwitch,
- MED_ALL_CONSTITUENT,
- aNbVal,
- theTimeStampValue->GetValuePtr(aGeom));
- if(aRet < 0){
- if(theErr){
- *theErr = MED_FALSE;
- break;
- }
- EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
- }
-
- }
-
- INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
- }
-
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- TErr* theErr)
- {
- TErr aRet;
- SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
-
- if(aRet < 0)
- SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
-
- if(theErr)
- *theErr = aRet;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
- TErr* theErr)
- {
- SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr)
- {
- if(theInfo.myMeshInfo->myType != eSTRUCTURE)
- return;
- TFileWrapper aFileWrapper(myFile,theMode,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
-
- MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
-
- TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
-
- TErr aRet = 0;
- aRet = MEDmeshGridTypeRd(myFile->Id(),
- &aMeshName,
- &aGrilleType);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
-
- if(anInfo.myGrilleType == eGRILLE_STANDARD){
- TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
- TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
- TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
- med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
- //med_axis_type aRepere = MED_CARTESIAN;
-
- aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_UNDEF_DT,
- aModeSwitch,
- aNbNoeuds,
- &aCoord);
-
- if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
-
- TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
- aRet = MEDmeshGridStructWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_UNDEF_DT,
- &aGrilleStructure);
- if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
-
- } else {
- for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
- aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_UNDEF_DT,
- aAxis+1,
- anInfo.GetIndexes(aAxis).size(),
- &anInfo.GetIndexes(aAxis)[0]);
-
- if(aRet < 0)
- EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
- }
-
- }
-
- return;
- }
-
- //----------------------------------------------------------------------------
- void
- TVWrapper
- ::GetGrilleInfo(TGrilleInfo& theInfo,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- EMaillage aMaillageType = aMeshInfo.myType;
-
- GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
- EGrilleType aGrilleType = theInfo.myGrilleType;
-
- TErr aRet = 0;
- if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
- GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
-
- TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
- TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
- TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
- TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
- //med_axis_type aRepere;
-
- aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- aModeSwitch,
- &aCoord);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
-
- //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
- TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
-
- aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- MED_NODE,
- MED_NO_GEOTYPE,
- &aFamNumNode);
-
- if(aRet < 0)
- {
-// if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
- {
- int mySize = (int)theInfo.myFamNumNode.size();
- theInfo.myFamNumNode.clear();
- theInfo.myFamNumNode.resize(mySize,0);
- aRet = 0;
- }
-// else
-// EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
- }
- if(theErr)
- *theErr = aRet;
-
- //============================
- }
-
- if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
- ETable aTable = eCOOR_IND1;
- for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
- switch(anAxis){
- case 1 :
- aTable = eCOOR_IND1;
- break;
- case 2 :
- aTable = eCOOR_IND2;
- break;
- case 3 :
- aTable = eCOOR_IND3;
- break;
- default :
- aRet = -1;
- }
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
-
- TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
- if(aNbIndexes < 0)
- EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
-
- TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
- //TValueHolder<ETable, med_data_type > table(aTable);
- //char aCompNames[MED_SNAME_SIZE+1];
- //char anUnitNames[MED_SNAME_SIZE+1];
- aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
- MED_NO_DT,MED_NO_IT,
- anAxis,
- &anIndexes);
-
- //theInfo.SetCoordName(anAxis-1, aCompNames);
- //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
- theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
-
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
- }
- }
-
- EGeometrieElement aGeom = theInfo.GetGeom();
- EEntiteMaillage aEntity = theInfo.GetEntity();
- TInt aNbCells = theInfo.GetNbCells();
-
- theInfo.myFamNum.resize(aNbCells);
- TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
-
- aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
- &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
- med_geometry_type(aGeom),&aFamNum);
-
- if ( aMeshInfo.myDim == 3 )
- {
- aGeom = theInfo.GetSubGeom();
- aEntity = theInfo.GetSubEntity();
- aNbCells = theInfo.GetNbSubCells();
-
- theInfo.myFamSubNum.resize(aNbCells,0);
- TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
-
- aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
- &aMeshName,MED_NO_DT,MED_NO_IT,
- med_entity_type(aEntity),
- med_geometry_type(aGeom),&aFamNum);
- }
- if(aRet < 0)
- {
-// if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
- {
- int mySize = (int)theInfo.myFamNumNode.size();
- theInfo.myFamNumNode.clear();
- theInfo.myFamNumNode.resize(mySize,0);
- aRet = 0;
- }
-// else
-// EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
- }
- if(theErr)
- *theErr = aRet;
- }
-
- void
- TVWrapper
- ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
- EGrilleType& theGridType,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
-
- MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
-
- if(aMeshInfo.myType == eSTRUCTURE){
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
- TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
- &aMeshName,
- &aGridType);
-
- if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
- }
- }
-
- void
- TVWrapper
- ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
- TIntVector& theStruct,
- TErr* theErr)
- {
- TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
-
- if(theErr && *theErr < 0)
- return;
-
- TErr aRet;
- MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
-
- TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
- TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
-
- aRet = MEDmeshGridStructRd(myFile->Id(),
- &aMeshName,
- MED_NO_DT,
- MED_NO_IT,
- &aGridStructure);
- if(theErr)
- *theErr = aRet;
- else if(aRet < 0)
- EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");
- }
-
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-#ifndef MED_V2_2_Wrapper_HeaderFile
-#define MED_V2_2_Wrapper_HeaderFile
-
-#ifdef WIN32
- #if defined MEDWRAPPER_V2_2_EXPORTS || defined MEDWrapper_V2_2_EXPORTS
- #if defined WIN32
- #define MED_V22_WRAPPER_EXPORT __declspec( dllexport )
- #else
- #define MED_V22_WRAPPER_EXPORT
- #endif
- #else
- #if defined WIN32
- #define MED_V22_WRAPPER_EXPORT __declspec( dllimport )
- #else
- #define MED_V22_WRAPPER_EXPORT
- #endif
- #endif
-#else
- #define MED_V22_WRAPPER_EXPORT
-#endif
-
-#include "MED_Structures.hxx"
-#include "MED_TWrapper.hxx"
-
-namespace MED
-{
- template<>
- TInt MED_V22_WRAPPER_EXPORT
- GetDESCLength<eV2_2>();
-
- template<>
- TInt MED_V22_WRAPPER_EXPORT
- GetIDENTLength<eV2_2>();
-
- template<>
- TInt MED_V22_WRAPPER_EXPORT
- GetNOMLength<eV2_2>();
-
- template<>
- TInt MED_V22_WRAPPER_EXPORT
- GetLNOMLength<eV2_2>();
-
- template<>
- TInt MED_V22_WRAPPER_EXPORT
- GetPNOMLength<eV2_2>();
-
- template<>
- void MED_V22_WRAPPER_EXPORT
- GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release);
-
- template<>
- TInt MED_V22_WRAPPER_EXPORT
- GetNbConn<eV2_2>(EGeometrieElement typmai,
- EEntiteMaillage typent,
- TInt mdim);
-
- namespace V2_2
- {
- //----------------------------------------------------------------------------
- class TFile;
- typedef boost::shared_ptr<TFile> PFile;
-
- typedef enum {eLECTURE, eLECTURE_ECRITURE, eLECTURE_AJOUT, eCREATION} EModeAcces;
-
- //----------------------------------------------------------------------------
- class MED_V22_WRAPPER_EXPORT TVWrapper: public MED::TTWrapper<eV2_2>
- {
- TVWrapper();
- TVWrapper(const TVWrapper&);
- TVWrapper& operator=(const TVWrapper&);
-
- public:
- TVWrapper(const std::string& theFileName);
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbMeshes(TErr* theErr = NULL);
-
- virtual
- void
- GetMeshInfo(TInt theMeshId, MED::TMeshInfo&,
- TErr* theErr = NULL);
-
- virtual
- void
- SetMeshInfo(const MED::TMeshInfo& theInfo,
- TErr* theErr = NULL);
-
- void SetMeshInfo(const MED::TMeshInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbFamilies(const MED::TMeshInfo& theMeshInfo,
- TErr* theErr = NULL);
-
- virtual
- TInt
- GetNbFamAttr(TInt theFamId,
- const MED::TMeshInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- TInt
- GetNbFamGroup(TInt theFamId,
- const MED::TMeshInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- GetFamilyInfo(TInt theFamId,
- MED::TFamilyInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetFamilyInfo(const MED::TFamilyInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetFamilyInfo(const MED::TFamilyInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- virtual
- void
- GetNames(TElemInfo& theInfo,
- TInt nb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- virtual
- void
- GetNumeration(TElemInfo& theInfo,
- TInt nb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- virtual
- void
- GetFamilies(TElemInfo& theInfo,
- TInt nb,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- virtual
- void
- SetNames(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- void
- SetNames(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- virtual
- void
- SetNumeration(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
- void
- SetNumeration(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- virtual
- void
- SetFamilies(const TElemInfo& theInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
- void
- SetFamilies(const TElemInfo& theInfo,
- EModeAcces theMode,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbNodes(const MED::TMeshInfo& theMeshInfo,
- TErr* theErr = NULL)
- {
- return GetNbNodes(theMeshInfo,eCOOR,theErr);
- }
-
- TInt
- GetNbNodes(const MED::TMeshInfo& theMeshInfo,
- ETable theTable,
- TErr* theErr = NULL);
-
- virtual
- void
- GetNodeInfo(MED::TNodeInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetNodeInfo(const MED::TNodeInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetNodeInfo(const MED::TNodeInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- void
- GetPolygoneInfo(TPolygoneInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetPolygoneInfo(const TPolygoneInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- virtual
- TInt
- GetNbPolygones(const TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- virtual
- TInt
- GetPolygoneConnSize(const TMeshInfo& theMeshInfo,
- EEntiteMaillage theEntity,
- EGeometrieElement theGeom,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- void
- GetPolyedreInfo(TPolyedreInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetPolyedreInfo(const TPolyedreInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- virtual
- TInt
- GetNbPolyedres(const TMeshInfo& theMeshInfo,
- EEntiteMaillage,
- EGeometrieElement,
- EConnectivite,
- TErr* theErr = NULL);
-
- virtual
- void
- GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
- TInt& theNbFaces,
- TInt& theConnSize,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- TEntityInfo
- GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- virtual
- TInt
- GetNbCells(const MED::TMeshInfo& theMeshInfo,
- EEntiteMaillage,
- EGeometrieElement,
- EConnectivite theConnMode = eNOD,
- TErr* theErr = NULL);
-
- virtual
- void
- GetCellInfo(MED::TCellInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetCellInfo(const MED::TCellInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetCellInfo(const MED::TCellInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- //! Read geom type of MED_BALL structural element
- EGeometrieElement GetBallGeom(const TMeshInfo& theMeshInfo);
-
- //! Read number of balls in the Mesh
- virtual TInt GetNbBalls(const TMeshInfo& theMeshInfo);
-
- //! Read a MEDWrapped representation of MED_BALL from the MED file
- virtual void GetBallInfo(TBallInfo& theInfo, TErr* theErr = NULL);
-
- //! Write a MEDWrapped representation of MED_BALL to the MED file
- virtual void SetBallInfo(const TBallInfo& theInfo, TErr* theErr);
-
- //! Write a MEDWrapped representation of MED_BALL to the MED file
- void SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr);
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbFields(TErr* theErr = NULL);
-
- virtual
- TInt
- GetNbComp(TInt theFieldId,
- TErr* theErr = NULL);
-
- virtual
- void
- GetFieldInfo(TInt theFieldId,
- MED::TFieldInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetFieldInfo(const MED::TFieldInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetFieldInfo(const MED::TFieldInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbGauss(TErr* theErr = NULL);
-
- virtual
- TGaussInfo::TInfo
- GetGaussPreInfo(TInt theId,
- TErr* theErr = NULL);
-
- virtual
- void
- GetGaussInfo(TInt theId,
- TGaussInfo& theInfo,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbProfiles(TErr* theErr = NULL);
-
- virtual
- TProfileInfo::TInfo
- GetProfilePreInfo(TInt theId,
- TErr* theErr = NULL);
-
- virtual
- void
- GetProfileInfo(TInt theId,
- TProfileInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetProfileInfo(const TProfileInfo& theInfo,
- TErr* theErr = NULL);
-
- void
- SetProfileInfo(const TProfileInfo& theInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- //----------------------------------------------------------------------------
- virtual
- TInt
- GetNbTimeStamps(const MED::TFieldInfo& theInfo,
- const MED::TEntityInfo& theEntityInfo,
- EEntiteMaillage& theEntity,
- TGeom2Size& theGeom2Size,
- TErr* theErr = NULL);
-
- virtual
- void
- GetTimeStampInfo(TInt theTimeStampId,
- MED::TTimeStampInfo& theInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- const TMKey2Profile& theMKey2Profile,
- const TKey2Gauss& theKey2Gauss,
- TErr* theErr = NULL);
-
- virtual
- void
- SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- TErr* theErr = NULL);
-
- void
- SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
-
- //----------------------------------------------------------------------------
- virtual
- void
- GetGrilleInfo(TGrilleInfo& theGrilleInfo,
- TErr* theErr = NULL);
-
- virtual
- void
- SetGrilleInfo(const MED::TGrilleInfo& theGrilleInfo,
- TErr* theErr = NULL);
-
- void
- SetGrilleInfo(const MED::TGrilleInfo& theGrilleInfo,
- EModeAcces theMode,
- TErr* theErr = NULL);
-
- virtual
- void
- GetGrilleType(const MED::TMeshInfo& theMeshInfo,
- EGrilleType& type,
- TErr* theErr = NULL);
-
- void
- GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
- TIntVector& theStruct,
- TErr* theErr = NULL);
-
- protected:
- PFile myFile;
- };
- }
-}
-
-#endif
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include <med.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main (int argc, char **argv)
+{
+ if ( argc < 2 )
+ return -1;
+
+ med_idt fid = MEDfileOpen(argv[1], MED_ACC_RDONLY);
+ if (fid < 0)
+ return 1;
+
+ med_int major, minor, release;
+ med_err aRet = MEDfileNumVersionRd(fid, &major, &minor, &release);
+ MEDfileClose(fid);
+ if (aRet < 0) {
+ // VSR: simulate med 2.3.6 behavior, med file version is assumed to be 2.1 or older
+ major = 2;
+ minor = release = -1;
+ }
+
+ printf("%d.%d.%d\n", major, minor, release);
+ return 0;
+}
${Boost_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/Controls
- ${PROJECT_SOURCE_DIR}/src/MEDWrapper/Base
+ ${PROJECT_SOURCE_DIR}/src/MEDWrapper
${PROJECT_SOURCE_DIR}/src/Driver
${PROJECT_SOURCE_DIR}/src/DriverDAT
${PROJECT_SOURCE_DIR}/src/DriverMED
* \param [in] theAutoGroups - boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false.
- * \param [in] theVersion - defines the version of format of MED file, that will be created
* \param [in] meshPart - mesh data to export
* \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
* - 1D if all mesh nodes lie on OX coordinate axis, or
void SMESH_Mesh::ExportMED(const char * file,
const char* theMeshName,
bool theAutoGroups,
- int theVersion,
const SMESHDS_Mesh* meshPart,
bool theAutoDimension,
bool theAddODOnVertices,
SMESH_TRY;
DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile ( file, MED::EVersion(theVersion) );
+ myWriter.SetFile ( file );
myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
myWriter.SetAutoDimension( theAutoDimension );
myWriter.AddODOnVertices ( theAddODOnVertices );
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
cmd += "\"";
system(cmd.c_str());
- ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*theVersion=*/1,
+ ExportMED(medfilename.c_str(), theMeshName, theAutoGroups,
/*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
/*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
#ifdef WIN32
void ExportMED(const char * theFile,
const char* theMeshName = NULL,
bool theAutoGroups = true,
- int theVersion = 0,
const SMESHDS_Mesh* theMeshPart = 0,
bool theAutoDimension = false,
bool theAddODOnVertices = false,
SMESHDS
SMESHControls
MEDWrapper
- MEDWrapperBase
- MEDWrapper_V2_2
)
# --- headers ---
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${PROJECT_SOURCE_DIR}/src/Controls
${PROJECT_SOURCE_DIR}/src/SMESHClient
- ${PROJECT_SOURCE_DIR}/src/MEDWrapper/Base
+ ${PROJECT_SOURCE_DIR}/src/MEDWrapper
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/idl
)
}
else if ( theCommandID == SMESHOp::OpImportSAUV ||
theCommandID == SMESHOp::OpPopupImportSAUV ) {
- filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
- filter.append( QObject::tr( "All files (*)" ) );
+ filter.append( QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)" );
+ filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
}
else if ( theCommandID == SMESHOp::OpImportGMF ||
theCommandID == SMESHOp::OpPopupImportGMF ) {
// Get parameters of export operation
- QString aFilename;
- SMESH::MED_VERSION aFormat = SMESH::MED_V2_2;
+ QString aFilename;
// Init the parameters with the default values
bool aIsASCII_STL = true;
bool toCreateGroups = false;
}
else if ( isMED || isSAUV ) // Export to MED or SAUV
{
- QMap<QString, SMESH::MED_VERSION> aFilterMap;
- //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
+ QStringList filters;
if ( isMED ) {
- QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
- //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
- aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
+ filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
}
else { // isSAUV
- aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
- aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
- aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
+ filters << QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)";
}
- QStringList filters;
- QString aDefaultFilter;
- QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
- for ( ; it != aFilterMap.end(); ++it ) {
- filters.push_back( it.key() );
- if (it.value() == SMESH::MED_V2_2)
- aDefaultFilter = it.key();
- }
QStringList checkBoxes;
checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
fd->setWindowTitle( aTitle );
fd->setNameFilters( filters );
- fd->selectNameFilter( aDefaultFilter );
fd->SetChecked( toCreateGroups, 0 );
fd->SetChecked( toFindOutDim, 1 );
if ( !anInitialPath.isEmpty() )
aFilename = QString::null;
break;
}
- aFormat = aFilterMap[fd->selectedNameFilter()];
toOverwrite = fv->isOverwrite();
is_ok = true;
if ( !aFilename.isEmpty() ) {
- // med-2.1 does not support poly elements
- if ( aFormat==SMESH::MED_V2_1 )
- for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
- SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
- SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
- if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
- nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
- {
- int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
- QObject::tr("SMESH_BUT_YES"),
- QObject::tr("SMESH_BUT_NO"), 0, 1);
- if (aRet != 0) {
- is_ok = false;
- break;
- }
- }
- }
if( !toOverwrite ) {
// can't append to an existing using other format
- SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
- bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
- if( !isVersionOk || aVersion != aFormat ) {
+ bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckCompatibility( aFilename.toUtf8().constData() );
+ if ( !isVersionOk ) {
int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
- aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
- aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
+ aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups,
+ toOverwrite && aMeshIndex == 0, toFindOutDim );
else
aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
- aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
+ toOverwrite && aMeshIndex == 0, toFindOutDim,
fields, geoAssFields.toLatin1().data() );
}
}
//
#include "SMESHGUI_FileInfoDlg.h"
-#include "MED_Common.hxx"
-
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
<source>MED_FILES_FILTER</source>
<translation>MED files</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>SAUV files</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>IDEAS files</translation>
<source>TEXT_FILES_FILTER</source>
<translation>TXT files</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>MED %1 files</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>STL files</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>You are going to export the group without its mesh.
Do you want to continue?</translation>
- </message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>During export mesh with name - "%1" to MED 2.1
-polygons and polyhedrons elements will be missed
-For correct export use MED 2.2
-Are you sure want to export to MED 2.1?</translation>
</message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
<source>MED_FILES_FILTER</source>
<translation>Fichiers MED</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>Fichiers SAUV</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>Fichiers IDEAS</translation>
<source>TEXT_FILES_FILTER</source>
<translation>Fichiers TXT</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>Fichiers MED %1</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>Fichiers STL</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>Vous allez export le groupe sans son maillage.
Voulez-vous continuer ?</translation>
- </message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>Les éléments polygonaux et polyèdriques seront omis
-dans le cas d'exportation du maillage "%1" à MED 2.1
-Utilisez MED 2.2 pour l'exportation correcte.
-Voulez-vous effectuer l'exportation à MED 2.1 ?</translation>
</message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
<source>MED_FILES_FILTER</source>
<translation>MEDファイル</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>SAUVファイル</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>IDEAS ファイル</translation>
<source>TEXT_FILES_FILTER</source>
<translation>TXT ファイル</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>ファイル MED %1</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>STL ファイル</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>そのメッシュなしでグループのエクスポートをしようとしています。続行しますか?</translation>
</message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>多角形、多面体要素は正しいエクスポート用 MED 2.1 MED 2.2 にメッシュ '%' のエクスポートの場合省略されます。MED 2.1 をエクスポートしますか。</translation>
- </message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
<translation>ファイル「%1」MED バージョンは知られていないか、選択したバージョンと一致しません。ファイルを上書きしますか。</translation>
${PROJECT_SOURCE_DIR}/src/Controls
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESHDS
- ${PROJECT_SOURCE_DIR}/src/MEDWrapper/Base
- ${PROJECT_SOURCE_DIR}/src/MEDWrapper/Factory
+ ${PROJECT_SOURCE_DIR}/src/MEDWrapper
${PROJECT_SOURCE_DIR}/src/Driver
${PROJECT_SOURCE_DIR}/src/DriverMED
${PROJECT_SOURCE_DIR}/src/DriverCGNS
SET(SMESHEngine_SOURCES
SMESH_Gen_i.cxx
SMESH_Gen_i_1.cxx
- SMESH_DumpPython.cxx
+ SMESH_PythonDump.cxx
SMESH_Mesh_i.cxx
SMESH_subMesh_i.cxx
SMESH_MeshEditor_i.cxx
}
}
}
+
+ bool _FilterArg( const _AString& theArg )
+ {
+ static std::list<_AString> filteredArgs;
+ static bool initialized = false;
+ if ( !initialized ) {
+ initialized = true;
+ filteredArgs.push_back( "SMESH.MED_V2_1" );
+ filteredArgs.push_back( "SMESH.MED_V2_2" );
+ }
+ return std::find( filteredArgs.begin(), filteredArgs.end(), theArg ) != filteredArgs.end();
+ }
}
//================================================================================
// ----------------------------------------------------------------------
else if ( theCommand->MethodStartsFrom( "Export" ))
{
- if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
- method == "ExportToMEDX" ) // ExportToMEDX() --> ExportMED()
+ if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
+ method == "ExportToMEDX" || // ExportToMEDX() --> ExportMED()
+ method == "ExportMED" )
{
theCommand->SetMethod( "ExportMED" );
- if ( theCommand->GetNbArgs() == 5 )
+ // filter out deprecated version parameter
+ vector< _AString > args;
+ for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
+ if ( !_FilterArg( theCommand->GetArg( i ) ) )
+ args.push_back( theCommand->GetArg( i ) );
+ }
+ theCommand->RemoveArgs();
+ for ( uint i = 0; i < args.size(); i++ )
+ theCommand->SetArg( i+1, args[i] );
+ if ( theCommand->GetNbArgs() == 4 )
{
// ExportToMEDX(...,autoDimension) -> ExportToMEDX(...,meshPart=None,autoDimension)
- _AString autoDimension = theCommand->GetArg( 5 );
- theCommand->SetArg( 5, "None" );
- theCommand->SetArg( 6, autoDimension );
+ _AString autoDimension = theCommand->GetArg( 4 );
+ theCommand->SetArg( 4, "None" );
+ theCommand->SetArg( 5, autoDimension );
}
}
else if ( method == "ExportCGNS" )
TCollection_AsciiString newMethod = method;
newMethod.Remove( /*where=*/7, /*howmany=*/6 );
theCommand->SetMethod( newMethod );
+ // filter out deprecated version parameter
+ vector< _AString > args;
+ for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
+ if ( !_FilterArg( theCommand->GetArg( i ) ) )
+ args.push_back( theCommand->GetArg( i ) );
+ }
+ theCommand->RemoveArgs();
+ for ( uint i = 0; i < args.size(); i++ )
+ theCommand->SetArg( i+1, args[i] );
// make the 1st arg be the last one (or last but three for ExportMED())
_pyID partID = theCommand->GetArg( 1 );
int nbArgs = theCommand->GetNbArgs() - 3 * (newMethod == "ExportMED");
+++ /dev/null
-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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
-//
-// File : SMESH_DumpPython.cxx
-// Created : Thu Mar 24 17:17:59 2005
-// Author : Julia DOROVSKIKH
-// Module : SMESH
-
-#include "SMESH_PythonDump.hxx"
-
-#include "SMESH_2smeshpy.hxx"
-#include "SMESH_Comment.hxx"
-#include "SMESH_Filter_i.hxx"
-#include "SMESH_Gen_i.hxx"
-#include "SMESH_MeshEditor_i.hxx"
-
-#include <SALOMEDS_wrap.hxx>
-
-#include <LDOMParser.hxx>
-#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
-#include <TColStd_HSequenceOfInteger.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
-#include "SMESH_TryCatch.hxx"
-
-namespace SMESH
-{
-
- size_t TPythonDump::myCounter = 0;
- const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
-
- TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
- {
- for ( size_t i = 0; i < value.length(); i++)
- myVals[i] = SMESH_Comment(value[i]);
- }
-
- TPythonDump::
- TPythonDump():myVarsCounter(0)
- {
- ++myCounter;
- }
- TPythonDump::
- ~TPythonDump()
- {
- if(--myCounter == 0){
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- std::string aString = myStream.str();
- TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
- if(!aCollection.IsEmpty())
- {
- const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
- if ( !objEntry.empty() )
- aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
- aSMESHGen->AddToPythonScript(aCollection);
- if(MYDEBUG) MESSAGE(aString);
- // prevent misuse of already treated variables
- aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
- }
- }
- }
-
- TPythonDump& //!< store a variable value. Write either a value or '$varID$'
- TPythonDump::
- operator<<(const TVar& theVarValue)
- {
- const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
- if ( theVarValue.myIsList )
- {
- myStream << "[ ";
- for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
- {
- if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
- myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
- else
- myStream << theVarValue.myVals[i-1];
- if ( i < theVarValue.myVals.size() )
- myStream << ", ";
- ++myVarsCounter;
- }
- myStream << " ]";
- }
- else
- {
- if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
- myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
- else
- myStream << theVarValue.myVals[0];
- ++myVarsCounter;
- }
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(long int theArg){
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(int theArg){
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(double theArg){
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(float theArg){
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(const void* theArg){
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(const char* theArg){
- if ( theArg )
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(const std::string& theArg){
- myStream<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(const SMESH::ElementType& theArg)
- {
- myStream<<"SMESH.";
- switch(theArg){
- case ALL: myStream<<"ALL"; break;
- case NODE: myStream<<"NODE"; break;
- case EDGE: myStream<<"EDGE"; break;
- case FACE: myStream<<"FACE"; break;
- case VOLUME: myStream<<"VOLUME"; break;
- case ELEM0D: myStream<<"ELEM0D"; break;
- case BALL: myStream<<"BALL"; break;
- default: myStream<<"__UNKNOWN__ElementType: " << theArg;
- }
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(const SMESH::GeometryType& theArg)
- {
- myStream<<"SMESH.";
- switch(theArg){
- case Geom_POINT: myStream<<"Geom_POINT"; break;
- case Geom_EDGE: myStream<<"Geom_EDGE"; break;
- case Geom_TRIANGLE: myStream<<"Geom_TRIANGLE"; break;
- case Geom_QUADRANGLE: myStream<<"Geom_QUADRANGLE"; break;
- case Geom_POLYGON: myStream<<"Geom_POLYGON"; break;
- case Geom_TETRA: myStream<<"Geom_TETRA"; break;
- case Geom_PYRAMID: myStream<<"Geom_PYRAMID"; break;
- case Geom_HEXA: myStream<<"Geom_HEXA"; break;
- case Geom_PENTA: myStream<<"Geom_PENTA"; break;
- case Geom_POLYHEDRA: myStream<<"Geom_POLYHEDRA"; break;
- case Geom_BALL: myStream<<"Geom_BALL"; break;
- default: myStream<<"__UNKNOWN__GeometryType: " << theArg;
- }
- return *this;
- }
- TPythonDump&
- TPythonDump::
- operator<<(const SMESH::EntityType& theArg)
- {
- myStream<<"SMESH.";
- switch(theArg){
- case Entity_0D: myStream<<"Entity_0D"; break;
- case Entity_Edge: myStream<<"Entity_Edge"; break;
- case Entity_Quad_Edge: myStream<<"Entity_Quad_Edge"; break;
- case Entity_Triangle: myStream<<"Entity_Triangle"; break;
- case Entity_Quad_Triangle: myStream<<"Entity_Quad_Triangle"; break;
- case Entity_BiQuad_Triangle: myStream<<"Entity_BiQuad_Triangle"; break;
- case Entity_Quadrangle: myStream<<"Entity_Quadrangle"; break;
- case Entity_Quad_Quadrangle: myStream<<"Entity_Quad_Quadrangle"; break;
- case Entity_BiQuad_Quadrangle: myStream<<"Entity_BiQuad_Quadrangle"; break;
- case Entity_Polygon: myStream<<"Entity_Polygon"; break;
- case Entity_Quad_Polygon: myStream<<"Entity_Quad_Polygon"; break;
- case Entity_Tetra: myStream<<"Entity_Tetra"; break;
- case Entity_Quad_Tetra: myStream<<"Entity_Quad_Tetra"; break;
- case Entity_Pyramid: myStream<<"Entity_Pyramid"; break;
- case Entity_Quad_Pyramid: myStream<<"Entity_Quad_Pyramid"; break;
- case Entity_Hexa: myStream<<"Entity_Hexa"; break;
- case Entity_Quad_Hexa: myStream<<"Entity_Quad_Hexa"; break;
- case Entity_TriQuad_Hexa: myStream<<"Entity_TriQuad_Hexa"; break;
- case Entity_Penta: myStream<<"Entity_Penta"; break;
- case Entity_Quad_Penta: myStream<<"Entity_Quad_Penta"; break;
- case Entity_Hexagonal_Prism: myStream<<"Entity_Hexagonal_Prism"; break;
- case Entity_Polyhedra: myStream<<"Entity_Polyhedra"; break;
- case Entity_Quad_Polyhedra: myStream<<"Entity_Quad_Polyhedra"; break;
- case Entity_Ball: myStream<<"Entity_Ball"; break;
- case Entity_Last: myStream<<"Entity_Last"; break;
- default: myStream<<"__UNKNOWN__EntityType: " << theArg;
- }
- return *this;
- }
-
- template<class TArray>
- void DumpArray(const TArray& theArray, TPythonDump & theStream)
- {
- if ( theArray.length() == 0 )
- {
- theStream << "[]";
- }
- else
- {
- theStream << "[ ";
- for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
- theStream << theArray[i-1];
- if ( i < theArray.length() )
- theStream << ", ";
- }
- theStream << " ]";
- }
- }
-
- TPythonDump&
- TPythonDump::operator<<(const SMESH::long_array& theArg)
- {
- DumpArray( theArg, *this );
- return *this;
- }
-
- TPythonDump&
- TPythonDump::operator<<(const SMESH::double_array& theArg)
- {
- DumpArray( theArg, *this );
- return *this;
- }
-
- TPythonDump&
- TPythonDump::operator<<(const SMESH::nodes_array& theArg)
- {
- DumpArray( theArg, *this );
- return *this;
- }
-
- TPythonDump&
- TPythonDump::operator<<(const SMESH::string_array& theArray)
- {
- myStream << "[ ";
- for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
- myStream << "'" << theArray[i-1] << "'";
- if ( i < theArray.length() )
- myStream << ", ";
- }
- myStream << " ]";
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SALOMEDS::SObject_ptr aSObject)
- {
- if ( !aSObject->_is_nil() ) {
- CORBA::String_var entry = aSObject->GetID();
- myStream << entry.in();
- }
- else {
- myStream << theNotPublishedObjectName;
- }
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(CORBA::Object_ptr theArg)
- {
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
- if(!aSObject->_is_nil()) {
- CORBA::String_var id = aSObject->GetID();
- myStream << id;
- } else if ( !CORBA::is_nil(theArg)) {
- if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
- myStream << "smeshObj_" << size_t(theArg);
- else
- myStream << theNotPublishedObjectName;
- }
- else
- myStream << "None";
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
- {
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
- if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
- myStream << "hyp_" << theArg->GetId();
- else
- *this << aSObject;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::SMESH_IDSource_ptr theArg)
- {
- if ( CORBA::is_nil( theArg ) )
- return *this << "None";
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
- if(!aSObject->_is_nil())
- {
- return *this << aSObject;
- }
- if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
- {
- return *this << filter;
- }
- if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
- {
- SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
- SMESH::long_array_var anElementsId = theArg->GetIDs();
- SMESH::array_of_ElementType_var types = theArg->GetTypes();
- SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
- SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
- if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
- return *this << mesh << ".GetIDSource([], " << type << ")";
- else
- return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
- }
- return *this << theNotPublishedObjectName;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::FilterLibrary_i* theArg)
- {
- myStream<<"aFilterLibrary"<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::FilterManager_i* theArg)
- {
- myStream<<"aFilterManager";
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::Filter_i* theArg)
- {
- myStream<<"aFilter"<<theArg;
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::Functor_i* theArg)
- {
- if ( theArg ) {
- FunctorType aFunctorType = theArg->GetFunctorType();
- switch(aFunctorType) {
- case FT_AspectRatio: myStream<< "aAspectRatio"; break;
- case FT_AspectRatio3D: myStream<< "aAspectRatio3D"; break;
- case FT_Warping: myStream<< "aWarping"; break;
- case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
- case FT_Taper: myStream<< "aTaper"; break;
- case FT_Skew: myStream<< "aSkew"; break;
- case FT_Area: myStream<< "aArea"; break;
- case FT_Volume3D: myStream<< "aVolume3D"; break;
- case FT_MaxElementLength2D: myStream<< "aMaxElementLength2D"; break;
- case FT_MaxElementLength3D: myStream<< "aMaxElementLength3D"; break;
- case FT_FreeBorders: myStream<< "aFreeBorders"; break;
- case FT_FreeEdges: myStream<< "aFreeEdges"; break;
- case FT_FreeNodes: myStream<< "aFreeNodes"; break;
- case FT_FreeFaces: myStream<< "aFreeFaces"; break;
- case FT_EqualNodes: myStream<< "aEqualNodes"; break;
- case FT_EqualEdges: myStream<< "aEqualEdges"; break;
- case FT_EqualFaces: myStream<< "aEqualFaces"; break;
- case FT_EqualVolumes: myStream<< "aEqualVolumes"; break;
- case FT_MultiConnection: myStream<< "aMultiConnection"; break;
- case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
- case FT_Length: myStream<< "aLength"; break;
- case FT_Length2D: myStream<< "aLength2D"; break;
- case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
- case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
- case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
- case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
- case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
- case FT_BelongToGenSurface: myStream<< "aBelongToGenSurface"; break;
- case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
- case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
- case FT_BadOrientedVolume: myStream<< "aBadOrientedVolume"; break;
- case FT_BareBorderVolume: myStream<< "aBareBorderVolume"; break;
- case FT_BareBorderFace: myStream<< "aBareBorderFace"; break;
- case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
- case FT_OverConstrainedFace: myStream<< "aOverConstrainedFace"; break;
- case FT_LinearOrQuadratic: myStream<< "aLinearOrQuadratic"; break;
- case FT_GroupColor: myStream<< "aGroupColor"; break;
- case FT_ElemGeomType: myStream<< "aElemGeomType"; break;
- case FT_EntityType: myStream<< "aEntityType"; break;
- case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
- case FT_BallDiameter: myStream<< "aBallDiameter"; break;
- case FT_ConnectedElements: myStream<< "aConnectedElements"; break;
- case FT_LessThan: myStream<< "aLessThan"; break;
- case FT_MoreThan: myStream<< "aMoreThan"; break;
- case FT_EqualTo: myStream<< "aEqualTo"; break;
- case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
- case FT_LogicalAND: myStream<< "aLogicalAND"; break;
- case FT_LogicalOR: myStream<< "aLogicalOR"; break;
- case FT_Undefined: myStream<< "anUndefined"; break;
- //default: -- commented to have a compilation warning
- }
- myStream<<theArg;
- }
- return *this;
- }
-
- TPythonDump&
- TPythonDump::
- operator<<(SMESH::Measurements_i* theArg)
- {
- myStream<<"aMeasurements";
- return *this;
- }
-
-
- TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
- {
- myStream << SMESHGenName(); return *this;
- }
-
- TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
- {
- myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
- }
-
- TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
- {
- myStream << theStr; return *this;
- }
-
-
- TPythonDump& TPythonDump::operator<<(SMESH::MED_VERSION theVersion)
- {
- switch (theVersion) {
- case SMESH::MED_V2_1: myStream << "SMESH.MED_V2_1"; break;
- case SMESH::MED_V2_2: myStream << "SMESH.MED_V2_2"; break;
- default: myStream << theVersion;
- }
- return *this;
- }
-
- TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
- {
- *this << "SMESH.AxisStruct( "
- << TVar( theAxis.x ) << ", "
- << TVar( theAxis.y ) << ", "
- << TVar( theAxis.z ) << ", "
- << TVar( theAxis.vx ) << ", "
- << TVar( theAxis.vy ) << ", "
- << TVar( theAxis.vz ) << " )";
- return *this;
- }
-
- TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
- {
- const SMESH::PointStruct & P = theDir.PS;
- *this << "SMESH.DirStruct( SMESH.PointStruct ( "
- << TVar( P.x ) << ", "
- << TVar( P.y ) << ", "
- << TVar( P.z ) << " ))";
- return *this;
- }
-
- TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
- {
- *this << "SMESH.PointStruct ( "
- << TVar( P.x ) << ", "
- << TVar( P.y ) << ", "
- << TVar( P.z ) << " )";
- return *this;
- }
-
- TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
- {
- DumpArray( theList, *this );
- return *this;
- }
- TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
- {
- DumpArray( *theList, *this );
- return *this;
- }
- TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
- {
- DumpArray( theList, *this );
- return *this;
- }
- TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
- {
- DumpArray( theList, *this );
- return *this;
- }
- TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
- {
- DumpArray( theList, *this );
- return *this;
- }
- TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
- {
- // dump CoincidentFreeBorders as a list of lists, each enclosed list
- // contains node IDs of a group of coincident free borders where
- // each consequent triple of IDs describe a free border: (n1, n2, nLast)
- // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
- // two groups of coincident free borders, each group including two borders
-
- myStream << "[";
- for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
- {
- const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
- if ( i ) myStream << ",";
- myStream << "[";
- for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
- {
- const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
- if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
- {
- if ( iP ) myStream << ", ";
- const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
- myStream << aBRD.nodeIDs[ aPART.node1 ] << ",";
- myStream << aBRD.nodeIDs[ aPART.node2 ] << ",";
- myStream << aBRD.nodeIDs[ aPART.nodeLast ];
- }
- }
- myStream << "]";
- }
- myStream << "]";
-
- return *this;
- }
-
- const char* TPythonDump::NotPublishedObjectName()
- {
- return theNotPublishedObjectName;
- }
-
- TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
- TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );
-
- //================================================================================
- /*!
- * \brief Return marker of long string literal beginning
- * \param type - a name of functionality producing the string literal
- * \retval TCollection_AsciiString - the marker string to be written into
- * a raw python script
- */
- //================================================================================
-
- TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
- {
- return
- myLongStringStart +
- (Standard_Integer) strlen(type) +
- " " +
- (char*) type;
- }
-
- //================================================================================
- /*!
- * \brief Return marker of long string literal end
- * \retval TCollection_AsciiString - the marker string to be written into
- * a raw python script
- */
- //================================================================================
-
- TCollection_AsciiString TPythonDump::LongStringEnd()
- {
- return myLongStringEnd;
- }
-
- //================================================================================
- /*!
- * \brief Cut out a long string literal from a string
- * \param theText - text possibly containing string literals
- * \param theFrom - position in the text to search from
- * \param theLongString - the retrieved literal
- * \param theStringType - a name of functionality produced the literal
- * \retval bool - true if a string literal found
- *
- * The literal is removed from theText; theFrom points position right after
- * the removed literal
- */
- //================================================================================
-
- bool TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
- int & theFrom,
- TCollection_AsciiString & theLongString,
- TCollection_AsciiString & theStringType)
- {
- if ( theFrom < 1 || theFrom > theText.Length() )
- return false;
-
- // ...script \ beg marker \ \ type \ literal \ end marker \ script...
- // "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
- // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
- // 0 1 2 3 4 5 6 7 8
-
- theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
- if ( !theFrom )
- return false;
-
- // find where literal begins
- int literalBeg = theFrom + myLongStringStart.Length(); // = 26
- char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
- int typeLen = atoi ( typeLenStr ); // = 7
- while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
- literalBeg++; // 26 -> 27
- typeLenStr++;
- }
- literalBeg += typeLen + 1; // = 35
- if ( literalBeg > theText.Length() )
- return false;
-
- // where literal ends (i.e. end marker begins)
- int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
- if ( !literalEnd )
- literalEnd = theText.Length();
-
- // literal
- theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
- // type
- theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
- // cut off literal
- literalEnd += myLongStringEnd.Length(); // = 79
- TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
- theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
-
- return true;
- }
-
- void printException( const char* text )
- {
-#ifdef _DEBUG_
- cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
-#endif
- }
-}
-
-//=======================================================================
-//function : RemoveTabulation
-//purpose :
-//=======================================================================
-void RemoveTabulation( TCollection_AsciiString& theScript )
-{
- std::string aString( theScript.ToCString() );
- std::string::size_type aPos = 0;
- while( aPos < aString.length() )
- {
- aPos = aString.find( "\n\t", aPos );
- if( aPos == std::string::npos )
- break;
- aString.replace( aPos, 2, "\n" );
- aPos++;
- }
- theScript = aString.c_str();
-}
-
-//=======================================================================
-//function : DumpPython
-//purpose :
-//=======================================================================
-Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean& isValidScript)
-{
- SALOMEDS::Study_var aStudy = getStudyServant();
- if (CORBA::is_nil(aStudy))
- return new Engines::TMPFile(0);
-
- CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
- if (CORBA::is_nil(aSO))
- return new Engines::TMPFile(0);
-
- // Map study entries to object names
- Resource_DataMapOfAsciiStringAsciiString aMap;
- Resource_DataMapOfAsciiStringAsciiString aMapNames;
-
- SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
- for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
- SALOMEDS::SObject_wrap aValue = Itr->Value();
- CORBA::String_var anID = aValue->GetID();
- CORBA::String_var aName = aValue->GetName();
- TCollection_AsciiString aGUIName ( (char*) aName.in() );
- TCollection_AsciiString anEntry ( (char*) anID.in() );
- if (aGUIName.Length() > 0) {
- aMapNames.Bind( anEntry, aGUIName );
- aMap.Bind( anEntry, aGUIName );
- }
- }
-
- // Get trace of restored study
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- SALOMEDS::GenericAttribute_wrap anAttr =
- aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
-
- SALOMEDS::AttributePythonObject_var pyAttr =
- SALOMEDS::AttributePythonObject::_narrow(anAttr);
- CORBA::String_var oldValue = pyAttr->GetObject();
- TCollection_AsciiString aSavedTrace (oldValue.in());
-
- // Add trace of API methods calls and replace study entries by names
- TCollection_AsciiString aScript;
- aScript += DumpPython_impl(aMap, aMapNames, isPublished, isMultiFile,
- myIsHistoricalPythonDump, isValidScript, aSavedTrace);
-
- int aLen = aScript.Length();
- unsigned char* aBuffer = new unsigned char[aLen+1];
- strcpy((char*)aBuffer, aScript.ToCString());
-
- CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
- Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
-
- bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
- isValidScript = isValidScript && !hasNotPublishedObjects;
-
- return aStreamFile._retn();
-}
-
-//=============================================================================
-/*!
- * AddToPythonScript
- */
-//=============================================================================
-void SMESH_Gen_i::AddToPythonScript (const TCollection_AsciiString& theString)
-{
- if (myPythonScript.IsNull()) {
- myPythonScript = new TColStd_HSequenceOfAsciiString;
- }
- myPythonScript->Append(theString);
-}
-
-//=============================================================================
-/*!
- * RemoveLastFromPythonScript
- */
-//=============================================================================
-void SMESH_Gen_i::RemoveLastFromPythonScript()
-{
- if (!myPythonScript.IsNull()) {
- int aLen = myPythonScript->Length();
- myPythonScript->Remove(aLen);
- }
-}
-
-//=======================================================================
-//function : SavePython
-//purpose :
-//=======================================================================
-void SMESH_Gen_i::SavePython()
-{
- // Dump trace of API methods calls
- TCollection_AsciiString aScript = GetNewPythonLines();
-
- // Check contents of PythonObject attribute
- CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SObject_wrap aSO = getStudyServant()->FindComponent( compDataType.in() );
- SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
- SALOMEDS::GenericAttribute_wrap anAttr =
- aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
-
- SALOMEDS::AttributePythonObject_var pyAttr =
- SALOMEDS::AttributePythonObject::_narrow(anAttr);
- CORBA::String_var oldValue = pyAttr->GetObject();
- TCollection_AsciiString oldScript (oldValue.in());
-
- if (oldScript.Length() > 0) {
- oldScript += "\n";
- oldScript += aScript;
- } else {
- oldScript = aScript;
- }
-
- // Store in PythonObject attribute
- pyAttr->SetObject(oldScript.ToCString(), 1);
-
- // Clean trace of API methods calls
- CleanPythonTrace();
-}
-
-
-// impl
-
-
-//=============================================================================
-/*!
- * FindEntries: Returns a sequence of start/end positions of entries in the string
- */
-//=============================================================================
-Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
-{
- Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
- Standard_Integer aLen = theString.Length();
- Standard_Boolean isFound = Standard_False;
-
- char* arr = (char*) theString.ToCString();
- Standard_Integer i = 0, j;
-
- while(i < aLen) {
- int c = (int)arr[i];
- j = i+1;
- if ( isdigit( c )) { //Is digit?
-
- isFound = Standard_False;
- while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
- c = (int)arr[j++];
- if(c == ':') isFound = Standard_True;
- }
-
- if (isFound) {
- int prev = (i < 1) ? 0 : (int)arr[i - 1];
- // to distinguish from a sketcher command:
- // last char should be a digit, not ":",
- // previous char should not be '"'.
- if (arr[j-2] != ':' && prev != '"') {
- aSeq->Append(i+1); // +1 because AsciiString starts from 1
- aSeq->Append(j-1);
- }
- }
- }
-
- i = j;
- }
-
- return aSeq;
-}
-
-namespace {
-
- //================================================================================
- /*!
- * \brief Make a string be a valid python name
- * \param aName - a string to fix
- * \retval bool - true if aName was not modified
- */
- //================================================================================
-
- bool fixPythonName(TCollection_AsciiString & aName)
- {
- bool isValidName = true;
- int nbUnderscore = 0;
- int p;
- // replace not allowed chars by underscore
- const char* name = aName.ToCString();
- for ( p = 0; name[p]; ++p ) {
- if ( !isalnum( name[p] ) && name[p] != '_' )
- {
- if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
- {
- aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
- --p;
- name = aName.ToCString();
- }
- else
- {
- aName.SetValue( p+1, '_');
- nbUnderscore++;
- }
- isValidName = false;
- }
- }
- // aName must not start with a digit
- if ( aName.IsIntegerValue() ) {
- aName.Insert( 1, 'a' );
- isValidName = false;
- }
- // shorten names like CartesianParameters3D_400_400_400_1000000_1
- const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
- posted to SALOME Forum */
- if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
- {
- p = aName.Location( "_", 20, aName.Length());
- if ( p > 1 )
- aName.Trunc( p-1 );
- }
- return isValidName;
- }
-
- //================================================================================
- /*!
- * \brief Return Python module names of available plug-ins.
- */
- //================================================================================
-
- std::vector<std::string> getPluginNames()
- {
- std::vector<std::string> pluginNames;
- std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
- LDOMParser xmlParser;
- for ( size_t i = 0; i < xmlPaths.size(); ++i )
- {
- bool error = xmlParser.parse( xmlPaths[i].c_str() );
- if ( error )
- {
- TCollection_AsciiString data;
- INFOS( xmlParser.GetError(data) );
- continue;
- }
- // <meshers-group name="Standard Meshers"
- // resources="StdMeshers"
- // idl-module="StdMeshers"
- // server-lib="StdMeshersEngine"
- // gui-lib="StdMeshersGUI">
- LDOM_Document xmlDoc = xmlParser.getDocument();
- LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
- for ( int i = 0; i < nodeList.getLength(); ++i )
- {
- LDOM_Node node = nodeList.item( i );
- LDOM_Element& elem = (LDOM_Element&) node;
- LDOMString idlModule = elem.getAttribute( "idl-module" );
- if ( strlen( idlModule.GetString() ) > 0 )
- pluginNames.push_back( idlModule.GetString() );
- }
- }
- return pluginNames;
- }
-}
-
-//================================================================================
-/*!
- * \brief Createa a Dump Python script
- * \param [in,out] theObjectNames - map of an entry to a study and python name
- * \param [in] theNames - - map of an entry to a study name
- * \param [in] isPublished - \c true if dump of object publication in study is needed
- * \param [in] isMultiFile - \c true if dump of each module goes to a separate file
- * \param [in] isHistoricalDump - \c true if removed object should be dumped
- * \param [out] aValidScript - returns \c true if the returned script seems valid
- * \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
- * decrease memory usage.
- * \return TCollection_AsciiString - the result dump script.
- */
-//================================================================================
-
-TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
- (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
- Resource_DataMapOfAsciiStringAsciiString& theNames,
- bool isPublished,
- bool isMultiFile,
- bool isHistoricalDump,
- bool& aValidScript,
- TCollection_AsciiString& theSavedTrace)
-{
- SMESH_TRY;
-
- const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
- const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
- const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
- const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
- const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
-
- std::list< TCollection_AsciiString > lines; // lines of a script
- std::list< TCollection_AsciiString >::iterator linesIt;
-
- if ( isPublished )
- lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
- else
- lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" );
- lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
- lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
-
- // Treat dump trace of restored study
- if (theSavedTrace.Length() > 0)
- {
- linesIt = --lines.end();
- // Split theSavedTrace into lines
- int from = 1, end = theSavedTrace.Length(), to;
- while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
- {
- if ( theSavedTrace.ToCString()[from-1] == '\t' )
- ++from;
- if ( to != from )
- lines.push_back( theSavedTrace.SubString( from, to - 1 ));
- from = to + 1;
- }
- // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
- // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
- // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
- bool isNewVersion =
- theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
- theSavedTrace.Clear();
- if ( !isNewVersion )
- {
- const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
- int beg, end, from;
- for ( ++linesIt; linesIt != lines.end(); ++linesIt )
- {
- TCollection_AsciiString& aSavedLine = *linesIt;
- end = aSavedLine.Length(), from = 1;
- while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
- {
- char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
- if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
- aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
- end += gen.Length();
- }
- from = beg + aSmeshCall.Length();
- }
- }
- }
- }
-
- // Add new dump trace of API methods calls to script lines
- if (!myPythonScript.IsNull())
- {
- Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
- Standard_Integer istr, aLen = aPythonScript->Length();
- for (istr = 1; istr <= aLen; istr++)
- lines.push_back( aPythonScript->Value( istr ));
- }
-
- // Convert IDL API calls into smeshBuilder.py API.
- // Some objects are wrapped with python classes and
- // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
- Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
- std::set< TCollection_AsciiString > aRemovedObjIDs;
- if ( !getenv("NO_2smeshpy_conversion"))
- SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
- theObjectNames, aRemovedObjIDs,
- isHistoricalDump );
-
- bool importGeom = false;
- GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
- {
- // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
- GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
- int ign = 0, nbgn = aGeomNames->length();
- for (; ign < nbgn; ign++) {
- TCollection_AsciiString aName = aGeomNames[ign].in();
- theObjectNames.Bind(aName, "1");
- }
- }
-
- TCollection_AsciiString anUpdatedScript;
-
- Resource_DataMapOfAsciiStringAsciiString mapRemoved;
- Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
- Standard_Integer objectCounter = 0;
- TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
-
- // Treat every script line and add it to anUpdatedScript
- for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
- {
- TCollection_AsciiString& aLine = *linesIt;
- anUpdatedScript += tab;
- {
- //Replace characters used instead of quote marks to quote notebook variables
- int pos = 1;
- while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
- aLine.SetValue( pos, '"' );
- }
- // Find entries to be replaced by names
- Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
- const Standard_Integer aSeqLen = aSeq->Length();
- Standard_Integer aStart = 1;
- for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
- {
- if ( aStart < aSeq->Value(i) )
- anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
- anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
- // is a GEOM object?
- CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
- if ( !geomName.in() || !geomName.in()[0] ) {
- // is a SMESH object
- if ( theObjectNames.IsBound( anEntry )) {
- // The Object is in Study
- aName = theObjectNames.Find( anEntry );
- // check validity of aName
- bool isValidName = fixPythonName( aName );
- if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
- // diff objects have same name - make a new name by appending a digit
- TCollection_AsciiString aName2;
- Standard_Integer i = 0;
- do {
- aName2 = aName + "_" + ++i;
- } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
- aName = aName2;
- isValidName = false;
- }
- if ( !isValidName )
- theObjectNames(anEntry) = aName;
-
- if ( aLine.Value(1) != '#' )
- mapEntries.Bind(anEntry, aName);
- }
- else
- {
- // Removed Object
- do {
- aName = aBaseName + (++objectCounter);
- } while (theObjectNames.IsBound(aName));
-
- if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
- mapRemoved.Bind(anEntry, aName);
-
- theObjectNames.Bind(anEntry, aName);
- }
- theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
- }
- else
- {
- aName = geomName.in();
- importGeom = true;
- }
- anUpdatedScript += aName;
- aStart = aSeq->Value(i + 1) + 1;
-
- } // loop on entries within aLine
-
- if ( aSeqLen == 0 )
- anUpdatedScript += aLine;
- else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
- anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
-
- anUpdatedScript += '\n';
- }
-
- // Make an initial part of aSript
-
- TCollection_AsciiString initPart = "import ";
- if ( isMultiFile )
- initPart += "salome, ";
- initPart += " SMESH, SALOMEDS\n";
- initPart += "from salome.smesh import smeshBuilder\n";
- if ( importGeom && isMultiFile )
- {
- initPart += ("\n## import GEOM dump file ## \n"
- "import string, os, sys, re, inspect\n"
- "thisFile = inspect.getfile( inspect.currentframe() )\n"
- "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
- "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
- "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
- }
- // import python files corresponding to plugins if they are used in anUpdatedScript
- {
- TCollection_AsciiString importStr;
- std::vector<std::string> pluginNames = getPluginNames();
- for ( size_t i = 0; i < pluginNames.size(); ++i )
- {
- // Convert access to plugin members:
- // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
- TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
- int iFrom = 1, iPos;
- while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
- {
- anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
- iFrom = iPos + pluginNames[i].size() + 8;
- }
- // if any plugin member is used, import the plugin
- if ( iFrom > 1 )
- importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
- " import " + pluginNames[i].c_str() +"Builder" );
- }
- if ( !importStr.IsEmpty() )
- initPart += importStr + "\n";
- }
-
- if ( isMultiFile )
- initPart += "def RebuildData():";
- initPart += "\n";
-
- anUpdatedScript.Prepend( initPart );
-
- // Make a final part of aScript
-
- // Dump object removal
- TCollection_AsciiString removeObjPart;
- if ( !mapRemoved.IsEmpty() ) {
- removeObjPart += nt + "## some objects were removed";
- removeObjPart += nt + "aStudyBuilder = salome.myStudy.NewBuilder()";
- Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
- for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
- aName = mapRemovedIt.Value(); // python name
- anEntry = mapRemovedIt.Key();
- removeObjPart += nt + "SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(";
- removeObjPart += aName;
- // for object wrapped by class of smeshBuilder.py
- if ( anEntry2AccessorMethod.IsBound( anEntry ) )
- removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
- removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
- }
- }
-
- // Set object names
- TCollection_AsciiString setNamePart;
- Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
- for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
- {
- anEntry = mapEntriesIt.Key();
- aName = mapEntriesIt.Value(); // python name
- if ( theNames.IsBound( anEntry ))
- {
- aGUIName = theNames.Find(anEntry);
- aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
- setNamePart += nt + aSMESHGen + ".SetName(" + aName;
- if ( anEntry2AccessorMethod.IsBound( anEntry ) )
- setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
- setNamePart += helper + ", '" + aGUIName + "')";
- }
- }
- if ( !setNamePart.IsEmpty() )
- {
- setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
- }
-
- // Store visual properties of displayed objects
-
- TCollection_AsciiString visualPropertiesPart;
- if (isPublished)
- {
- //Output the script that sets up the visual parameters.
- CORBA::String_var compDataType = ComponentDataType();
- CORBA::String_var script = getStudyServant()->GetDefaultScript( compDataType.in(), tab.ToCString() );
- if ( script.in() && script.in()[0] ) {
- visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
- visualPropertiesPart += script.in();
- }
- }
-
- anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
-
- if ( isMultiFile )
- {
- anUpdatedScript +=
- "\n\tpass"
- "\n"
- "\nif __name__ == '__main__':"
- "\n\tSMESH_RebuildData = RebuildData"
- "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
- "\n\tGEOM_dump.RebuildData()"
- "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
- "\n\tSMESH_RebuildData()";
- }
- anUpdatedScript += "\n";
-
- // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
- // if( !isMultiFile ) // remove unnecessary tabulation
- // RemoveTabulation( anUpdatedScript );
-
- // -----------------------------------------------------------------
- // put string literals describing patterns into separate functions
- // -----------------------------------------------------------------
-
- TCollection_AsciiString aLongString, aFunctionType;
- int where = 1;
- std::set< std::string > functionNameSet;
- while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
- {
- // make a python string literal
- aLongString.Prepend(":\n\treturn '''\n");
- aLongString += "\n\t'''\n\tpass\n";
-
- TCollection_AsciiString functionName;
-
- // check if the function returning this literal is already defined
- int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
- if ( posAlready ) // already defined
- {
- // find the function name
- int functBeg = posAlready;
- char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
- while ( *script != ' ' ) {
- script--;
- functBeg--;
- }
- functBeg++; // do not take ' '
- posAlready--; // do not take ':'
- functionName = anUpdatedScript.SubString( functBeg, posAlready );
- }
- else // not defined yet
- {
- // find a unique function name
- fixPythonName( aFunctionType );
- Standard_Integer nb = 0;
- do functionName = aFunctionType + "_" + ( nb++ ) + "()";
- while ( !functionNameSet.insert( functionName.ToCString() ).second );
-
- // define function
- TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
- if ( isMultiFile )
- {
- anUpdatedScript += helper + "\n\n" + funDef;
- }
- else
- {
- funDef += "\n\n";
- anUpdatedScript.Insert( 1, funDef);
- where += funDef.Length();
- }
- }
- anUpdatedScript.InsertBefore( where, functionName ); // call function
- }
-
- aValidScript = true;
-
- return anUpdatedScript;
-
- SMESH_CATCH( SMESH::printException );
-
- aValidScript = false;
- return "";
-}
-
-//=============================================================================
-/*!
- * GetNewPythonLines
- */
-//=============================================================================
-TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines()
-{
- TCollection_AsciiString aScript;
-
- // Dump trace of API methods calls
- if (!myPythonScript.IsNull()) {
- Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
- Standard_Integer istr, aLen = aPythonScript->Length();
- for (istr = 1; istr <= aLen; istr++) {
- aScript += "\n";
- aScript += aPythonScript->Value(istr);
- }
- aScript += "\n";
- }
-
- return aScript;
-}
-
-//=============================================================================
-/*!
- * CleanPythonTrace
- */
-//=============================================================================
-void SMESH_Gen_i::CleanPythonTrace()
-{
- TCollection_AsciiString aScript;
-
- // Clean trace of API methods calls
- if (!myPythonScript.IsNull()) {
- myPythonScript->Clear();
- }
-}
#include <map>
#include <fstream>
+#include <sstream>
#include <cstdio>
#include <cstdlib>
return newMesh._retn();
}
+//================================================================================
+/*!
+ * \brief Get version of MED format being used.
+ */
+//================================================================================
+
+char* SMESH_Gen_i::GetMEDFileVersion()
+{
+ MED::TInt majeur, mineur, release;
+ majeur = mineur = release = 0;
+ MED::GetVersionRelease(majeur, mineur, release);
+ std::ostringstream version;
+ version << majeur << "." << mineur << "." << release;
+ return CORBA::string_dup( version.str().c_str() );
+}
+
//================================================================================
/*!
* SMESH_Gen_i::GetMEDVersion
* Get MED version of the file by its name
*/
//================================================================================
-CORBA::Boolean SMESH_Gen_i::GetMEDVersion(const char* theFileName,
- SMESH::MED_VERSION& theVersion)
+char* SMESH_Gen_i::GetMEDVersion(const char* theFileName)
{
- theVersion = SMESH::MED_V2_1;
- MED::EVersion aVersion = MED::GetVersionId( theFileName );
- switch( aVersion ) {
- case MED::eV2_1 : theVersion = SMESH::MED_V2_1; return true;
- case MED::eV2_2 : theVersion = SMESH::MED_V2_2; return true;
- case MED::eVUnknown : return false;
- }
- return false;
+ std::string version = MED::GetMEDVersion( theFileName );
+ return CORBA::string_dup( version.c_str() );
+}
+
+//================================================================================
+/*!
+ * SMESH_Gen_i::CheckCompatibility
+ *
+ * Check compatibility of file with MED format being used.
+ */
+//================================================================================
+CORBA::Boolean SMESH_Gen_i::CheckCompatibility(const char* theFileName)
+{
+ return MED::CheckCompatibility( theFileName );
}
//================================================================================
SMESH::string_array* SMESH_Gen_i::GetMeshNames(const char* theFileName)
{
SMESH::string_array_var aResult = new SMESH::string_array();
- MED::PWrapper aMed = MED::CrWrapper( theFileName );
+ MED::PWrapper aMed = MED::CrWrapperR( theFileName );
MED::TErr anErr;
MED::TInt aNbMeshes = aMed->GetNbMeshes( &anErr );
if( anErr >= 0 ) {
CORBA::Double mergeTolerance)
throw ( SALOME::SALOME_Exception );
+ // Get version of MED format being used.
+ char* GetMEDFileVersion();
+
// Get MED version of the file by its name
- CORBA::Boolean GetMEDVersion(const char* theFileName,
- SMESH::MED_VERSION& theVersion);
+ char* GetMEDVersion(const char* theFileName);
+
+ // Check compatibility of file with MED format being used.
+ CORBA::Boolean CheckCompatibility(const char* theFileName);
// Get names of meshes defined in file with the specified name
SMESH::string_array* GetMeshNames(const char* theFileName);
CreateGroupServants();
int major, minor, release;
- if( !MED::getMEDVersion( theFileName, major, minor, release ) )
- major = minor = release = -1;
+ major = minor = release = 0;
+ MED::GetMEDVersion(theFileName, major, minor, release);
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->fileSize = 0;
return ConvertDriverMEDReadStatus(status);
}
-//================================================================================
-/*!
- * \brief Return string representation of a MED file version comprising nbDigits
- */
-//================================================================================
-
-char* SMESH_Mesh_i::GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits)
-{
- string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(MED::EVersion(version),
- nbDigits);
- return CORBA::string_dup( ver.c_str() );
-}
-
//=============================================================================
/*!
* ImportUNVFile
//================================================================================
/*!
- * \brief Export to med file
+ * \brief Export to MED file
*/
//================================================================================
-void SMESH_Mesh_i::ExportToMEDX (const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION theVersion,
- CORBA::Boolean overwrite,
- CORBA::Boolean autoDimension)
+void SMESH_Mesh_i::ExportMED(const char* file,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean overwrite,
+ CORBA::Boolean autoDimension)
throw(SALOME::SALOME_Exception)
{
SMESH_TRY;
_preMeshInfo->FullLoadFromFile();
string aMeshName = prepareMeshNameAndGroups(file, overwrite);
- _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion, 0, autoDimension );
+ _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportToMEDX( r'"
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
<< file << "', " << auto_groups << ", "
- << theVersion << ", " << overwrite << ", "
+ << overwrite << ", "
<< autoDimension << " )";
SMESH_CATCH( SMESH::throwCorbaException );
}
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportToMED (const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION theVersion)
- throw(SALOME::SALOME_Exception)
-{
- ExportToMEDX(file,auto_groups,theVersion,true);
-}
-
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportMED (const char* file,
- CORBA::Boolean auto_groups)
- throw(SALOME::SALOME_Exception)
-{
- ExportToMEDX(file,auto_groups,SMESH::MED_V2_2,true);
-}
-
//================================================================================
/*!
* \brief Export a mesh to a SAUV file
void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
CORBA::Boolean overwrite,
CORBA::Boolean autoDimension,
const GEOM::ListOfFields& fields,
{
aMeshName = prepareMeshNameAndGroups(file, overwrite);
_impl->ExportMED( file, aMeshName.c_str(), auto_groups,
- version, 0, autoDimension, /*addODOnVertices=*/have0dField);
+ 0, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = _impl->GetMeshDS();
}
else
SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
_impl->ExportMED( file, aMeshName.c_str(), auto_groups,
- version, partDS, autoDimension, /*addODOnVertices=*/have0dField);
+ partDS, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = tmpDSDeleter._obj = partDS;
}
}
TPythonDump() << _this() << ".ExportPartToMED( "
<< meshPart << ", r'" << file << "', "
- << auto_groups << ", " << version << ", " << overwrite << ", "
+ << auto_groups << ", " << overwrite << ", "
<< autoDimension << ", " << goList
<< ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
* Consider maximum group name length stored in MED file.
*/
CORBA::Boolean HasDuplicatedGroupNamesMED();
- /*!
- * Return string representation of a MED file version comprising nbDigits
- */
- char* GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits);
- void ExportToMEDX( const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
- CORBA::Boolean overwrite,
- CORBA::Boolean autoDimension=true) throw (SALOME::SALOME_Exception);
- void ExportToMED ( const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version ) throw (SALOME::SALOME_Exception);
- void ExportMED ( const char* file,
- CORBA::Boolean auto_groups ) throw (SALOME::SALOME_Exception);
+ void ExportMED( const char* file,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean overwrite,
+ CORBA::Boolean autoDimension = true) throw (SALOME::SALOME_Exception);
void ExportSAUV( const char* file, CORBA::Boolean auto_groups ) throw (SALOME::SALOME_Exception);
void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
CORBA::Boolean overwrite,
CORBA::Boolean autoDim,
const GEOM::ListOfFields& fields,
CORBA::Long NbPolygons()
throw (SALOME::SALOME_Exception);
- CORBA::Long NbPolygonsOfOrder(SMESH::ElementOrder order=SMESH::ORDER_ANY)
+ CORBA::Long NbPolygonsOfOrder(SMESH::ElementOrder order = SMESH::ORDER_ANY)
throw (SALOME::SALOME_Exception);
CORBA::Long NbVolumes()
{
_isInfoOk = true;
- MED::PWrapper aMed = MED::CrWrapper(_medFileName,true);
- // if ( aMed->GetVersion() != MED::eV2_2 )
- // return false;
-
+ MED::PWrapper aMed = MED::CrWrapperR(_medFileName);
MED::PMeshInfo medMeshInfo = aMed->CrMeshInfo(3,3,SMESH_Comment( _meshID ));
// read nb nodes
map< int, vector< SMESH_PreMeshInfo* > > famId2grInfo;
- MED::PWrapper aMed = MED::CrWrapper(_medFileName,false);
+ MED::PWrapper aMed = MED::CrWrapperR(_medFileName);
MED::PMeshInfo medMeshInfo = aMed->CrMeshInfo(3,3,SMESH_Comment( _meshID ));
// read families to fill in famId2grInfo
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+// File : SMESH_DumpPython.cxx
+// Created : Thu Mar 24 17:17:59 2005
+// Author : Julia DOROVSKIKH
+// Module : SMESH
+
+#include "SMESH_PythonDump.hxx"
+
+#include "SMESH_2smeshpy.hxx"
+#include "SMESH_Comment.hxx"
+#include "SMESH_Filter_i.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_MeshEditor_i.hxx"
+
+#include <SALOMEDS_wrap.hxx>
+
+#include <LDOMParser.hxx>
+#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+#include "SMESH_TryCatch.hxx"
+
+namespace SMESH
+{
+
+ size_t TPythonDump::myCounter = 0;
+ const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
+
+ TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
+ {
+ for ( size_t i = 0; i < value.length(); i++)
+ myVals[i] = SMESH_Comment(value[i]);
+ }
+
+ TPythonDump::
+ TPythonDump():myVarsCounter(0)
+ {
+ ++myCounter;
+ }
+ TPythonDump::
+ ~TPythonDump()
+ {
+ if(--myCounter == 0){
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ std::string aString = myStream.str();
+ TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
+ if(!aCollection.IsEmpty())
+ {
+ const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
+ if ( !objEntry.empty() )
+ aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
+ aSMESHGen->AddToPythonScript(aCollection);
+ if(MYDEBUG) MESSAGE(aString);
+ // prevent misuse of already treated variables
+ aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
+ }
+ }
+ }
+
+ TPythonDump& //!< store a variable value. Write either a value or '$varID$'
+ TPythonDump::
+ operator<<(const TVar& theVarValue)
+ {
+ const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
+ if ( theVarValue.myIsList )
+ {
+ myStream << "[ ";
+ for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
+ {
+ if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
+ myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
+ else
+ myStream << theVarValue.myVals[i-1];
+ if ( i < theVarValue.myVals.size() )
+ myStream << ", ";
+ ++myVarsCounter;
+ }
+ myStream << " ]";
+ }
+ else
+ {
+ if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
+ myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
+ else
+ myStream << theVarValue.myVals[0];
+ ++myVarsCounter;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(long int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(double theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(float theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const void* theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const char* theArg){
+ if ( theArg )
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const std::string& theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::ElementType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case ALL: myStream<<"ALL"; break;
+ case NODE: myStream<<"NODE"; break;
+ case EDGE: myStream<<"EDGE"; break;
+ case FACE: myStream<<"FACE"; break;
+ case VOLUME: myStream<<"VOLUME"; break;
+ case ELEM0D: myStream<<"ELEM0D"; break;
+ case BALL: myStream<<"BALL"; break;
+ default: myStream<<"__UNKNOWN__ElementType: " << theArg;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::GeometryType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case Geom_POINT: myStream<<"Geom_POINT"; break;
+ case Geom_EDGE: myStream<<"Geom_EDGE"; break;
+ case Geom_TRIANGLE: myStream<<"Geom_TRIANGLE"; break;
+ case Geom_QUADRANGLE: myStream<<"Geom_QUADRANGLE"; break;
+ case Geom_POLYGON: myStream<<"Geom_POLYGON"; break;
+ case Geom_TETRA: myStream<<"Geom_TETRA"; break;
+ case Geom_PYRAMID: myStream<<"Geom_PYRAMID"; break;
+ case Geom_HEXA: myStream<<"Geom_HEXA"; break;
+ case Geom_PENTA: myStream<<"Geom_PENTA"; break;
+ case Geom_POLYHEDRA: myStream<<"Geom_POLYHEDRA"; break;
+ case Geom_BALL: myStream<<"Geom_BALL"; break;
+ default: myStream<<"__UNKNOWN__GeometryType: " << theArg;
+ }
+ return *this;
+ }
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::EntityType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case Entity_0D: myStream<<"Entity_0D"; break;
+ case Entity_Edge: myStream<<"Entity_Edge"; break;
+ case Entity_Quad_Edge: myStream<<"Entity_Quad_Edge"; break;
+ case Entity_Triangle: myStream<<"Entity_Triangle"; break;
+ case Entity_Quad_Triangle: myStream<<"Entity_Quad_Triangle"; break;
+ case Entity_BiQuad_Triangle: myStream<<"Entity_BiQuad_Triangle"; break;
+ case Entity_Quadrangle: myStream<<"Entity_Quadrangle"; break;
+ case Entity_Quad_Quadrangle: myStream<<"Entity_Quad_Quadrangle"; break;
+ case Entity_BiQuad_Quadrangle: myStream<<"Entity_BiQuad_Quadrangle"; break;
+ case Entity_Polygon: myStream<<"Entity_Polygon"; break;
+ case Entity_Quad_Polygon: myStream<<"Entity_Quad_Polygon"; break;
+ case Entity_Tetra: myStream<<"Entity_Tetra"; break;
+ case Entity_Quad_Tetra: myStream<<"Entity_Quad_Tetra"; break;
+ case Entity_Pyramid: myStream<<"Entity_Pyramid"; break;
+ case Entity_Quad_Pyramid: myStream<<"Entity_Quad_Pyramid"; break;
+ case Entity_Hexa: myStream<<"Entity_Hexa"; break;
+ case Entity_Quad_Hexa: myStream<<"Entity_Quad_Hexa"; break;
+ case Entity_TriQuad_Hexa: myStream<<"Entity_TriQuad_Hexa"; break;
+ case Entity_Penta: myStream<<"Entity_Penta"; break;
+ case Entity_Quad_Penta: myStream<<"Entity_Quad_Penta"; break;
+ case Entity_Hexagonal_Prism: myStream<<"Entity_Hexagonal_Prism"; break;
+ case Entity_Polyhedra: myStream<<"Entity_Polyhedra"; break;
+ case Entity_Quad_Polyhedra: myStream<<"Entity_Quad_Polyhedra"; break;
+ case Entity_Ball: myStream<<"Entity_Ball"; break;
+ case Entity_Last: myStream<<"Entity_Last"; break;
+ default: myStream<<"__UNKNOWN__EntityType: " << theArg;
+ }
+ return *this;
+ }
+
+ template<class TArray>
+ void DumpArray(const TArray& theArray, TPythonDump & theStream)
+ {
+ if ( theArray.length() == 0 )
+ {
+ theStream << "[]";
+ }
+ else
+ {
+ theStream << "[ ";
+ for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
+ theStream << theArray[i-1];
+ if ( i < theArray.length() )
+ theStream << ", ";
+ }
+ theStream << " ]";
+ }
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::long_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::double_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::nodes_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::string_array& theArray)
+ {
+ myStream << "[ ";
+ for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
+ myStream << "'" << theArray[i-1] << "'";
+ if ( i < theArray.length() )
+ myStream << ", ";
+ }
+ myStream << " ]";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SALOMEDS::SObject_ptr aSObject)
+ {
+ if ( !aSObject->_is_nil() ) {
+ CORBA::String_var entry = aSObject->GetID();
+ myStream << entry.in();
+ }
+ else {
+ myStream << theNotPublishedObjectName;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(CORBA::Object_ptr theArg)
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(!aSObject->_is_nil()) {
+ CORBA::String_var id = aSObject->GetID();
+ myStream << id;
+ } else if ( !CORBA::is_nil(theArg)) {
+ if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
+ myStream << "smeshObj_" << size_t(theArg);
+ else
+ myStream << theNotPublishedObjectName;
+ }
+ else
+ myStream << "None";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
+ {
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
+ myStream << "hyp_" << theArg->GetId();
+ else
+ *this << aSObject;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::SMESH_IDSource_ptr theArg)
+ {
+ if ( CORBA::is_nil( theArg ) )
+ return *this << "None";
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(!aSObject->_is_nil())
+ {
+ return *this << aSObject;
+ }
+ if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
+ {
+ return *this << filter;
+ }
+ if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
+ {
+ SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
+ SMESH::long_array_var anElementsId = theArg->GetIDs();
+ SMESH::array_of_ElementType_var types = theArg->GetTypes();
+ SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
+ SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
+ if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
+ return *this << mesh << ".GetIDSource([], " << type << ")";
+ else
+ return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
+ }
+ return *this << theNotPublishedObjectName;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterLibrary_i* theArg)
+ {
+ myStream<<"aFilterLibrary"<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterManager_i* theArg)
+ {
+ myStream<<"aFilterManager";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Filter_i* theArg)
+ {
+ myStream<<"aFilter"<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Functor_i* theArg)
+ {
+ if ( theArg ) {
+ FunctorType aFunctorType = theArg->GetFunctorType();
+ switch(aFunctorType) {
+ case FT_AspectRatio: myStream<< "aAspectRatio"; break;
+ case FT_AspectRatio3D: myStream<< "aAspectRatio3D"; break;
+ case FT_Warping: myStream<< "aWarping"; break;
+ case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
+ case FT_Taper: myStream<< "aTaper"; break;
+ case FT_Skew: myStream<< "aSkew"; break;
+ case FT_Area: myStream<< "aArea"; break;
+ case FT_Volume3D: myStream<< "aVolume3D"; break;
+ case FT_MaxElementLength2D: myStream<< "aMaxElementLength2D"; break;
+ case FT_MaxElementLength3D: myStream<< "aMaxElementLength3D"; break;
+ case FT_FreeBorders: myStream<< "aFreeBorders"; break;
+ case FT_FreeEdges: myStream<< "aFreeEdges"; break;
+ case FT_FreeNodes: myStream<< "aFreeNodes"; break;
+ case FT_FreeFaces: myStream<< "aFreeFaces"; break;
+ case FT_EqualNodes: myStream<< "aEqualNodes"; break;
+ case FT_EqualEdges: myStream<< "aEqualEdges"; break;
+ case FT_EqualFaces: myStream<< "aEqualFaces"; break;
+ case FT_EqualVolumes: myStream<< "aEqualVolumes"; break;
+ case FT_MultiConnection: myStream<< "aMultiConnection"; break;
+ case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
+ case FT_Length: myStream<< "aLength"; break;
+ case FT_Length2D: myStream<< "aLength2D"; break;
+ case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
+ case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
+ case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
+ case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
+ case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
+ case FT_BelongToGenSurface: myStream<< "aBelongToGenSurface"; break;
+ case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
+ case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
+ case FT_BadOrientedVolume: myStream<< "aBadOrientedVolume"; break;
+ case FT_BareBorderVolume: myStream<< "aBareBorderVolume"; break;
+ case FT_BareBorderFace: myStream<< "aBareBorderFace"; break;
+ case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
+ case FT_OverConstrainedFace: myStream<< "aOverConstrainedFace"; break;
+ case FT_LinearOrQuadratic: myStream<< "aLinearOrQuadratic"; break;
+ case FT_GroupColor: myStream<< "aGroupColor"; break;
+ case FT_ElemGeomType: myStream<< "aElemGeomType"; break;
+ case FT_EntityType: myStream<< "aEntityType"; break;
+ case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
+ case FT_BallDiameter: myStream<< "aBallDiameter"; break;
+ case FT_ConnectedElements: myStream<< "aConnectedElements"; break;
+ case FT_LessThan: myStream<< "aLessThan"; break;
+ case FT_MoreThan: myStream<< "aMoreThan"; break;
+ case FT_EqualTo: myStream<< "aEqualTo"; break;
+ case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
+ case FT_LogicalAND: myStream<< "aLogicalAND"; break;
+ case FT_LogicalOR: myStream<< "aLogicalOR"; break;
+ case FT_Undefined: myStream<< "anUndefined"; break;
+ //default: -- commented to have a compilation warning
+ }
+ myStream<<theArg;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Measurements_i* theArg)
+ {
+ myStream<<"aMeasurements";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
+ {
+ myStream << SMESHGenName(); return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
+ {
+ myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
+ {
+ myStream << theStr; return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
+ {
+ *this << "SMESH.AxisStruct( "
+ << TVar( theAxis.x ) << ", "
+ << TVar( theAxis.y ) << ", "
+ << TVar( theAxis.z ) << ", "
+ << TVar( theAxis.vx ) << ", "
+ << TVar( theAxis.vy ) << ", "
+ << TVar( theAxis.vz ) << " )";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
+ {
+ const SMESH::PointStruct & P = theDir.PS;
+ *this << "SMESH.DirStruct( SMESH.PointStruct ( "
+ << TVar( P.x ) << ", "
+ << TVar( P.y ) << ", "
+ << TVar( P.z ) << " ))";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
+ {
+ *this << "SMESH.PointStruct ( "
+ << TVar( P.x ) << ", "
+ << TVar( P.y ) << ", "
+ << TVar( P.z ) << " )";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
+ {
+ DumpArray( *theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
+ {
+ // dump CoincidentFreeBorders as a list of lists, each enclosed list
+ // contains node IDs of a group of coincident free borders where
+ // each consequent triple of IDs describe a free border: (n1, n2, nLast)
+ // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
+ // two groups of coincident free borders, each group including two borders
+
+ myStream << "[";
+ for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
+ {
+ const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
+ if ( i ) myStream << ",";
+ myStream << "[";
+ for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
+ {
+ const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
+ if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
+ {
+ if ( iP ) myStream << ", ";
+ const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
+ myStream << aBRD.nodeIDs[ aPART.node1 ] << ",";
+ myStream << aBRD.nodeIDs[ aPART.node2 ] << ",";
+ myStream << aBRD.nodeIDs[ aPART.nodeLast ];
+ }
+ }
+ myStream << "]";
+ }
+ myStream << "]";
+
+ return *this;
+ }
+
+ const char* TPythonDump::NotPublishedObjectName()
+ {
+ return theNotPublishedObjectName;
+ }
+
+ TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
+ TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );
+
+ //================================================================================
+ /*!
+ * \brief Return marker of long string literal beginning
+ * \param type - a name of functionality producing the string literal
+ * \retval TCollection_AsciiString - the marker string to be written into
+ * a raw python script
+ */
+ //================================================================================
+
+ TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
+ {
+ return
+ myLongStringStart +
+ (Standard_Integer) strlen(type) +
+ " " +
+ (char*) type;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Return marker of long string literal end
+ * \retval TCollection_AsciiString - the marker string to be written into
+ * a raw python script
+ */
+ //================================================================================
+
+ TCollection_AsciiString TPythonDump::LongStringEnd()
+ {
+ return myLongStringEnd;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Cut out a long string literal from a string
+ * \param theText - text possibly containing string literals
+ * \param theFrom - position in the text to search from
+ * \param theLongString - the retrieved literal
+ * \param theStringType - a name of functionality produced the literal
+ * \retval bool - true if a string literal found
+ *
+ * The literal is removed from theText; theFrom points position right after
+ * the removed literal
+ */
+ //================================================================================
+
+ bool TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
+ int & theFrom,
+ TCollection_AsciiString & theLongString,
+ TCollection_AsciiString & theStringType)
+ {
+ if ( theFrom < 1 || theFrom > theText.Length() )
+ return false;
+
+ // ...script \ beg marker \ \ type \ literal \ end marker \ script...
+ // "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
+ // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+ // 0 1 2 3 4 5 6 7 8
+
+ theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
+ if ( !theFrom )
+ return false;
+
+ // find where literal begins
+ int literalBeg = theFrom + myLongStringStart.Length(); // = 26
+ char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
+ int typeLen = atoi ( typeLenStr ); // = 7
+ while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
+ literalBeg++; // 26 -> 27
+ typeLenStr++;
+ }
+ literalBeg += typeLen + 1; // = 35
+ if ( literalBeg > theText.Length() )
+ return false;
+
+ // where literal ends (i.e. end marker begins)
+ int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
+ if ( !literalEnd )
+ literalEnd = theText.Length();
+
+ // literal
+ theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
+ // type
+ theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
+ // cut off literal
+ literalEnd += myLongStringEnd.Length(); // = 79
+ TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
+ theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
+
+ return true;
+ }
+
+ void printException( const char* text )
+ {
+#ifdef _DEBUG_
+ cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
+#endif
+ }
+}
+
+//=======================================================================
+//function : RemoveTabulation
+//purpose :
+//=======================================================================
+void RemoveTabulation( TCollection_AsciiString& theScript )
+{
+ std::string aString( theScript.ToCString() );
+ std::string::size_type aPos = 0;
+ while( aPos < aString.length() )
+ {
+ aPos = aString.find( "\n\t", aPos );
+ if( aPos == std::string::npos )
+ break;
+ aString.replace( aPos, 2, "\n" );
+ aPos++;
+ }
+ theScript = aString.c_str();
+}
+
+//=======================================================================
+//function : DumpPython
+//purpose :
+//=======================================================================
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript)
+{
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if (CORBA::is_nil(aStudy))
+ return new Engines::TMPFile(0);
+
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
+ if (CORBA::is_nil(aSO))
+ return new Engines::TMPFile(0);
+
+ // Map study entries to object names
+ Resource_DataMapOfAsciiStringAsciiString aMap;
+ Resource_DataMapOfAsciiStringAsciiString aMapNames;
+
+ SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
+ for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
+ SALOMEDS::SObject_wrap aValue = Itr->Value();
+ CORBA::String_var anID = aValue->GetID();
+ CORBA::String_var aName = aValue->GetName();
+ TCollection_AsciiString aGUIName ( (char*) aName.in() );
+ TCollection_AsciiString anEntry ( (char*) anID.in() );
+ if (aGUIName.Length() > 0) {
+ aMapNames.Bind( anEntry, aGUIName );
+ aMap.Bind( anEntry, aGUIName );
+ }
+ }
+
+ // Get trace of restored study
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow(anAttr);
+ CORBA::String_var oldValue = pyAttr->GetObject();
+ TCollection_AsciiString aSavedTrace (oldValue.in());
+
+ // Add trace of API methods calls and replace study entries by names
+ TCollection_AsciiString aScript;
+ aScript += DumpPython_impl(aMap, aMapNames, isPublished, isMultiFile,
+ myIsHistoricalPythonDump, isValidScript, aSavedTrace);
+
+ int aLen = aScript.Length();
+ unsigned char* aBuffer = new unsigned char[aLen+1];
+ strcpy((char*)aBuffer, aScript.ToCString());
+
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
+
+ bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
+ isValidScript = isValidScript && !hasNotPublishedObjects;
+
+ return aStreamFile._retn();
+}
+
+//=============================================================================
+/*!
+ * AddToPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::AddToPythonScript (const TCollection_AsciiString& theString)
+{
+ if (myPythonScript.IsNull()) {
+ myPythonScript = new TColStd_HSequenceOfAsciiString;
+ }
+ myPythonScript->Append(theString);
+}
+
+//=============================================================================
+/*!
+ * RemoveLastFromPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::RemoveLastFromPythonScript()
+{
+ if (!myPythonScript.IsNull()) {
+ int aLen = myPythonScript->Length();
+ myPythonScript->Remove(aLen);
+ }
+}
+
+//=======================================================================
+//function : SavePython
+//purpose :
+//=======================================================================
+void SMESH_Gen_i::SavePython()
+{
+ // Dump trace of API methods calls
+ TCollection_AsciiString aScript = GetNewPythonLines();
+
+ // Check contents of PythonObject attribute
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = getStudyServant()->FindComponent( compDataType.in() );
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow(anAttr);
+ CORBA::String_var oldValue = pyAttr->GetObject();
+ TCollection_AsciiString oldScript (oldValue.in());
+
+ if (oldScript.Length() > 0) {
+ oldScript += "\n";
+ oldScript += aScript;
+ } else {
+ oldScript = aScript;
+ }
+
+ // Store in PythonObject attribute
+ pyAttr->SetObject(oldScript.ToCString(), 1);
+
+ // Clean trace of API methods calls
+ CleanPythonTrace();
+}
+
+
+// impl
+
+
+//=============================================================================
+/*!
+ * FindEntries: Returns a sequence of start/end positions of entries in the string
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
+{
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ Standard_Integer aLen = theString.Length();
+ Standard_Boolean isFound = Standard_False;
+
+ char* arr = (char*) theString.ToCString();
+ Standard_Integer i = 0, j;
+
+ while(i < aLen) {
+ int c = (int)arr[i];
+ j = i+1;
+ if ( isdigit( c )) { //Is digit?
+
+ isFound = Standard_False;
+ while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
+ c = (int)arr[j++];
+ if(c == ':') isFound = Standard_True;
+ }
+
+ if (isFound) {
+ int prev = (i < 1) ? 0 : (int)arr[i - 1];
+ // to distinguish from a sketcher command:
+ // last char should be a digit, not ":",
+ // previous char should not be '"'.
+ if (arr[j-2] != ':' && prev != '"') {
+ aSeq->Append(i+1); // +1 because AsciiString starts from 1
+ aSeq->Append(j-1);
+ }
+ }
+ }
+
+ i = j;
+ }
+
+ return aSeq;
+}
+
+namespace {
+
+ //================================================================================
+ /*!
+ * \brief Make a string be a valid python name
+ * \param aName - a string to fix
+ * \retval bool - true if aName was not modified
+ */
+ //================================================================================
+
+ bool fixPythonName(TCollection_AsciiString & aName)
+ {
+ bool isValidName = true;
+ int nbUnderscore = 0;
+ int p;
+ // replace not allowed chars by underscore
+ const char* name = aName.ToCString();
+ for ( p = 0; name[p]; ++p ) {
+ if ( !isalnum( name[p] ) && name[p] != '_' )
+ {
+ if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
+ {
+ aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
+ --p;
+ name = aName.ToCString();
+ }
+ else
+ {
+ aName.SetValue( p+1, '_');
+ nbUnderscore++;
+ }
+ isValidName = false;
+ }
+ }
+ // aName must not start with a digit
+ if ( aName.IsIntegerValue() ) {
+ aName.Insert( 1, 'a' );
+ isValidName = false;
+ }
+ // shorten names like CartesianParameters3D_400_400_400_1000000_1
+ const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
+ posted to SALOME Forum */
+ if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
+ {
+ p = aName.Location( "_", 20, aName.Length());
+ if ( p > 1 )
+ aName.Trunc( p-1 );
+ }
+ return isValidName;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Return Python module names of available plug-ins.
+ */
+ //================================================================================
+
+ std::vector<std::string> getPluginNames()
+ {
+ std::vector<std::string> pluginNames;
+ std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
+ LDOMParser xmlParser;
+ for ( size_t i = 0; i < xmlPaths.size(); ++i )
+ {
+ bool error = xmlParser.parse( xmlPaths[i].c_str() );
+ if ( error )
+ {
+ TCollection_AsciiString data;
+ INFOS( xmlParser.GetError(data) );
+ continue;
+ }
+ // <meshers-group name="Standard Meshers"
+ // resources="StdMeshers"
+ // idl-module="StdMeshers"
+ // server-lib="StdMeshersEngine"
+ // gui-lib="StdMeshersGUI">
+ LDOM_Document xmlDoc = xmlParser.getDocument();
+ LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
+ for ( int i = 0; i < nodeList.getLength(); ++i )
+ {
+ LDOM_Node node = nodeList.item( i );
+ LDOM_Element& elem = (LDOM_Element&) node;
+ LDOMString idlModule = elem.getAttribute( "idl-module" );
+ if ( strlen( idlModule.GetString() ) > 0 )
+ pluginNames.push_back( idlModule.GetString() );
+ }
+ }
+ return pluginNames;
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Createa a Dump Python script
+ * \param [in,out] theObjectNames - map of an entry to a study and python name
+ * \param [in] theNames - - map of an entry to a study name
+ * \param [in] isPublished - \c true if dump of object publication in study is needed
+ * \param [in] isMultiFile - \c true if dump of each module goes to a separate file
+ * \param [in] isHistoricalDump - \c true if removed object should be dumped
+ * \param [out] aValidScript - returns \c true if the returned script seems valid
+ * \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
+ * decrease memory usage.
+ * \return TCollection_AsciiString - the result dump script.
+ */
+//================================================================================
+
+TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
+ (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ Resource_DataMapOfAsciiStringAsciiString& theNames,
+ bool isPublished,
+ bool isMultiFile,
+ bool isHistoricalDump,
+ bool& aValidScript,
+ TCollection_AsciiString& theSavedTrace)
+{
+ SMESH_TRY;
+
+ const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
+ const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
+ const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
+ const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
+ const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
+
+ std::list< TCollection_AsciiString > lines; // lines of a script
+ std::list< TCollection_AsciiString >::iterator linesIt;
+
+ if ( isPublished )
+ lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
+ else
+ lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" );
+ lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
+ lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
+
+ // Treat dump trace of restored study
+ if (theSavedTrace.Length() > 0)
+ {
+ linesIt = --lines.end();
+ // Split theSavedTrace into lines
+ int from = 1, end = theSavedTrace.Length(), to;
+ while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
+ {
+ if ( theSavedTrace.ToCString()[from-1] == '\t' )
+ ++from;
+ if ( to != from )
+ lines.push_back( theSavedTrace.SubString( from, to - 1 ));
+ from = to + 1;
+ }
+ // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
+ // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
+ // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
+ bool isNewVersion =
+ theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
+ theSavedTrace.Clear();
+ if ( !isNewVersion )
+ {
+ const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
+ int beg, end, from;
+ for ( ++linesIt; linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aSavedLine = *linesIt;
+ end = aSavedLine.Length(), from = 1;
+ while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
+ {
+ char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
+ if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
+ aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
+ end += gen.Length();
+ }
+ from = beg + aSmeshCall.Length();
+ }
+ }
+ }
+ }
+
+ // Add new dump trace of API methods calls to script lines
+ if (!myPythonScript.IsNull())
+ {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++)
+ lines.push_back( aPythonScript->Value( istr ));
+ }
+
+ // Convert IDL API calls into smeshBuilder.py API.
+ // Some objects are wrapped with python classes and
+ // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
+ Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
+ std::set< TCollection_AsciiString > aRemovedObjIDs;
+ if ( !getenv("NO_2smeshpy_conversion"))
+ SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
+ theObjectNames, aRemovedObjIDs,
+ isHistoricalDump );
+
+ bool importGeom = false;
+ GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
+ {
+ // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
+ GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
+ int ign = 0, nbgn = aGeomNames->length();
+ for (; ign < nbgn; ign++) {
+ TCollection_AsciiString aName = aGeomNames[ign].in();
+ theObjectNames.Bind(aName, "1");
+ }
+ }
+
+ TCollection_AsciiString anUpdatedScript;
+
+ Resource_DataMapOfAsciiStringAsciiString mapRemoved;
+ Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
+ Standard_Integer objectCounter = 0;
+ TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
+
+ // Treat every script line and add it to anUpdatedScript
+ for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aLine = *linesIt;
+ anUpdatedScript += tab;
+ {
+ //Replace characters used instead of quote marks to quote notebook variables
+ int pos = 1;
+ while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
+ aLine.SetValue( pos, '"' );
+ }
+ // Find entries to be replaced by names
+ Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
+ const Standard_Integer aSeqLen = aSeq->Length();
+ Standard_Integer aStart = 1;
+ for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
+ {
+ if ( aStart < aSeq->Value(i) )
+ anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
+ anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
+ // is a GEOM object?
+ CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
+ if ( !geomName.in() || !geomName.in()[0] ) {
+ // is a SMESH object
+ if ( theObjectNames.IsBound( anEntry )) {
+ // The Object is in Study
+ aName = theObjectNames.Find( anEntry );
+ // check validity of aName
+ bool isValidName = fixPythonName( aName );
+ if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
+ // diff objects have same name - make a new name by appending a digit
+ TCollection_AsciiString aName2;
+ Standard_Integer i = 0;
+ do {
+ aName2 = aName + "_" + ++i;
+ } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
+ aName = aName2;
+ isValidName = false;
+ }
+ if ( !isValidName )
+ theObjectNames(anEntry) = aName;
+
+ if ( aLine.Value(1) != '#' )
+ mapEntries.Bind(anEntry, aName);
+ }
+ else
+ {
+ // Removed Object
+ do {
+ aName = aBaseName + (++objectCounter);
+ } while (theObjectNames.IsBound(aName));
+
+ if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
+ mapRemoved.Bind(anEntry, aName);
+
+ theObjectNames.Bind(anEntry, aName);
+ }
+ theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
+ }
+ else
+ {
+ aName = geomName.in();
+ importGeom = true;
+ }
+ anUpdatedScript += aName;
+ aStart = aSeq->Value(i + 1) + 1;
+
+ } // loop on entries within aLine
+
+ if ( aSeqLen == 0 )
+ anUpdatedScript += aLine;
+ else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
+ anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
+
+ anUpdatedScript += '\n';
+ }
+
+ // Make an initial part of aSript
+
+ TCollection_AsciiString initPart = "import ";
+ if ( isMultiFile )
+ initPart += "salome, ";
+ initPart += " SMESH, SALOMEDS\n";
+ initPart += "from salome.smesh import smeshBuilder\n";
+ if ( importGeom && isMultiFile )
+ {
+ initPart += ("\n## import GEOM dump file ## \n"
+ "import string, os, sys, re, inspect\n"
+ "thisFile = inspect.getfile( inspect.currentframe() )\n"
+ "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
+ "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
+ "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
+ }
+ // import python files corresponding to plugins if they are used in anUpdatedScript
+ {
+ TCollection_AsciiString importStr;
+ std::vector<std::string> pluginNames = getPluginNames();
+ for ( size_t i = 0; i < pluginNames.size(); ++i )
+ {
+ // Convert access to plugin members:
+ // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
+ TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
+ int iFrom = 1, iPos;
+ while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
+ {
+ anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
+ iFrom = iPos + pluginNames[i].size() + 8;
+ }
+ // if any plugin member is used, import the plugin
+ if ( iFrom > 1 )
+ importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
+ " import " + pluginNames[i].c_str() +"Builder" );
+ }
+ if ( !importStr.IsEmpty() )
+ initPart += importStr + "\n";
+ }
+
+ if ( isMultiFile )
+ initPart += "def RebuildData():";
+ initPart += "\n";
+
+ anUpdatedScript.Prepend( initPart );
+
+ // Make a final part of aScript
+
+ // Dump object removal
+ TCollection_AsciiString removeObjPart;
+ if ( !mapRemoved.IsEmpty() ) {
+ removeObjPart += nt + "## some objects were removed";
+ removeObjPart += nt + "aStudyBuilder = salome.myStudy.NewBuilder()";
+ Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
+ for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
+ aName = mapRemovedIt.Value(); // python name
+ anEntry = mapRemovedIt.Key();
+ removeObjPart += nt + "SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(";
+ removeObjPart += aName;
+ // for object wrapped by class of smeshBuilder.py
+ if ( anEntry2AccessorMethod.IsBound( anEntry ) )
+ removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
+ removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
+ }
+ }
+
+ // Set object names
+ TCollection_AsciiString setNamePart;
+ Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
+ for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
+ {
+ anEntry = mapEntriesIt.Key();
+ aName = mapEntriesIt.Value(); // python name
+ if ( theNames.IsBound( anEntry ))
+ {
+ aGUIName = theNames.Find(anEntry);
+ aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
+ setNamePart += nt + aSMESHGen + ".SetName(" + aName;
+ if ( anEntry2AccessorMethod.IsBound( anEntry ) )
+ setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
+ setNamePart += helper + ", '" + aGUIName + "')";
+ }
+ }
+ if ( !setNamePart.IsEmpty() )
+ {
+ setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
+ }
+
+ // Store visual properties of displayed objects
+
+ TCollection_AsciiString visualPropertiesPart;
+ if (isPublished)
+ {
+ //Output the script that sets up the visual parameters.
+ CORBA::String_var compDataType = ComponentDataType();
+ CORBA::String_var script = getStudyServant()->GetDefaultScript( compDataType.in(), tab.ToCString() );
+ if ( script.in() && script.in()[0] ) {
+ visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
+ visualPropertiesPart += script.in();
+ }
+ }
+
+ anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
+
+ if ( isMultiFile )
+ {
+ anUpdatedScript +=
+ "\n\tpass"
+ "\n"
+ "\nif __name__ == '__main__':"
+ "\n\tSMESH_RebuildData = RebuildData"
+ "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
+ "\n\tGEOM_dump.RebuildData()"
+ "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
+ "\n\tSMESH_RebuildData()";
+ }
+ anUpdatedScript += "\n";
+
+ // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
+ // if( !isMultiFile ) // remove unnecessary tabulation
+ // RemoveTabulation( anUpdatedScript );
+
+ // -----------------------------------------------------------------
+ // put string literals describing patterns into separate functions
+ // -----------------------------------------------------------------
+
+ TCollection_AsciiString aLongString, aFunctionType;
+ int where = 1;
+ std::set< std::string > functionNameSet;
+ while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
+ {
+ // make a python string literal
+ aLongString.Prepend(":\n\treturn '''\n");
+ aLongString += "\n\t'''\n\tpass\n";
+
+ TCollection_AsciiString functionName;
+
+ // check if the function returning this literal is already defined
+ int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
+ if ( posAlready ) // already defined
+ {
+ // find the function name
+ int functBeg = posAlready;
+ char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
+ while ( *script != ' ' ) {
+ script--;
+ functBeg--;
+ }
+ functBeg++; // do not take ' '
+ posAlready--; // do not take ':'
+ functionName = anUpdatedScript.SubString( functBeg, posAlready );
+ }
+ else // not defined yet
+ {
+ // find a unique function name
+ fixPythonName( aFunctionType );
+ Standard_Integer nb = 0;
+ do functionName = aFunctionType + "_" + ( nb++ ) + "()";
+ while ( !functionNameSet.insert( functionName.ToCString() ).second );
+
+ // define function
+ TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
+ if ( isMultiFile )
+ {
+ anUpdatedScript += helper + "\n\n" + funDef;
+ }
+ else
+ {
+ funDef += "\n\n";
+ anUpdatedScript.Insert( 1, funDef);
+ where += funDef.Length();
+ }
+ }
+ anUpdatedScript.InsertBefore( where, functionName ); // call function
+ }
+
+ aValidScript = true;
+
+ return anUpdatedScript;
+
+ SMESH_CATCH( SMESH::printException );
+
+ aValidScript = false;
+ return "";
+}
+
+//=============================================================================
+/*!
+ * GetNewPythonLines
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines()
+{
+ TCollection_AsciiString aScript;
+
+ // Dump trace of API methods calls
+ if (!myPythonScript.IsNull()) {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++) {
+ aScript += "\n";
+ aScript += aPythonScript->Value(istr);
+ }
+ aScript += "\n";
+ }
+
+ return aScript;
+}
+
+//=============================================================================
+/*!
+ * CleanPythonTrace
+ */
+//=============================================================================
+void SMESH_Gen_i::CleanPythonTrace()
+{
+ TCollection_AsciiString aScript;
+
+ // Clean trace of API methods calls
+ if (!myPythonScript.IsNull()) {
+ myPythonScript->Clear();
+ }
+}
TPythonDump&
operator<<(SMESH_MeshEditor_i* theArg);
- TPythonDump&
- operator<<(SMESH::MED_VERSION theArg);
-
TPythonDump&
operator<<(const SMESH::AxisStruct & theAxis);
from salome.geom import geomBuilder
import SMESH # This is necessary for back compatibility
+import omniORB # back compatibility
+SMESH.MED_V2_1 = omniORB.EnumItem("MED_V2_1", 0) # back compatibility
+SMESH.MED_V2_2 = omniORB.EnumItem("MED_V2_2", 1) # back compatibility
+
from SMESH import *
from salome.smesh.smesh_algorithm import Mesh_Algorithm
## Export the mesh in a file in MED format
## allowing to overwrite the file if it exists or add the exported data to its contents
- # @param f is the file name
+ # @param fileName is the file name
# @param auto_groups boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
# the typical use is auto_groups=False.
- # @param version MED format version (MED_V2_1 or MED_V2_2,
- # the latter meaning any current version). The parameter is
- # obsolete since MED_V2_1 is no longer supported.
# @param overwrite boolean parameter for overwriting/not overwriting the file
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
# - 'f' stands for "_faces _" field;
# - 's' stands for "_solids _" field.
# @ingroup l2_impexp
- def ExportMED(self, f, auto_groups=0, version=MED_V2_2,
- overwrite=1, meshPart=None, autoDimension=True, fields=[], geomAssocFields=''):
+ def ExportMED(self, *args, **kwargs):
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ meshPart = args[3] if len(args) > 3 else None
+ autoDimension = args[4] if len(args) > 4 else True
+ fields = args[5] if len(args) > 5 else []
+ geomAssocFields = args[6] if len(args) > 6 else ''
+ # process keywords arguments
+ auto_groups = kwargs.get("auto_groups", auto_groups)
+ overwrite = kwargs.get("overwrite", overwrite)
+ meshPart = kwargs.get("meshPart", meshPart)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ fields = kwargs.get("fields", fields)
+ geomAssocFields = kwargs.get("geomAssocFields", geomAssocFields)
+ # invoke engine's function
if meshPart or fields or geomAssocFields:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
- self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension,
+ self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension,
fields, geomAssocFields)
else:
- self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension)
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
## Export the mesh in a file in SAUV format
# @param f is the file name
## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
# Export the mesh in a file in MED format
# allowing to overwrite the file if it exists or add the exported data to its contents
- # @param f the file name
- # @param version MED format version (MED_V2_1 or MED_V2_2,
- # the latter meaning any current version). The parameter is
- # obsolete since MED_V2_1 is no longer supported.
+ # @param fileName the file name
+ # @param opt boolean parameter for creating/not creating
+ # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
+ # @param overwrite boolean parameter for overwriting/not overwriting the file
+ # @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
+ # - 1D if all mesh nodes lie on OX coordinate axis, or
+ # - 2D if all mesh nodes lie on XOY coordinate plane, or
+ # - 3D in the rest cases.<br>
+ # If @a autoDimension is @c False, the space dimension is always 3.
+ # @ingroup l2_impexp
+ def ExportToMED(self, *args, **kwargs):
+ print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ autoDimension = args[3] if len(args) > 3 else True
+ # process keywords arguments
+ auto_groups = kwargs.get("opt", auto_groups) # old keyword name
+ auto_groups = kwargs.get("auto_groups", auto_groups) # new keyword name
+ overwrite = kwargs.get("overwrite", overwrite)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ # invoke engine's function
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+
+ ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
+ # Export the mesh in a file in MED format
+ # allowing to overwrite the file if it exists or add the exported data to its contents
+ # @param fileName the file name
# @param opt boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ...
# @param overwrite boolean parameter for overwriting/not overwriting the file
# - 3D in the rest cases.<br>
# If @a autoDimension is @c False, the space dimension is always 3.
# @ingroup l2_impexp
- def ExportToMED(self, f, version=MED_V2_2, opt=0, overwrite=1, autoDimension=True):
- self.mesh.ExportToMEDX(f, opt, version, overwrite, autoDimension)
+ def ExportToMEDX(self, *args, **kwargs):
+ print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ autoDimension = args[3] if len(args) > 3 else True
+ # process keywords arguments
+ auto_groups = kwargs.get("auto_groups", auto_groups)
+ overwrite = kwargs.get("overwrite", overwrite)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ # invoke engine's function
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
# Operations with groups:
# ----------------------
def CreateDimGroup(self,*args): # 2 args added: nbCommonNodes, underlyingOnly
if len( args ) == 3:
args += SMESH.ALL_NODES, True
- return SMESH._objref_SMESH_Mesh.CreateDimGroup( self, *args )
+ return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
+ def ExportToMEDX(self, *args): # function removed
+ print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
+ def ExportToMED(self, *args): # function removed
+ print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
+ args.append(True)
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
+ def ExportPartToMED(self, *args): # 'version' parameter removed
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
+ def ExportMED(self, *args): # signature of method changed
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
+ args.append(True)
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
pass
omniORB.registerObjref(SMESH._objref_SMESH_Mesh._NP_RepositoryId, meshProxy)
aFilter_1.SetMesh(Maillage_1.GetMesh())
FACE_temp = Maillage_1.GroupOnFilter( SMESH.FACE, noms[cont], aFilter_1 )
- Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage_1.ExportMED(outFile)
#if salome.sg.hasDesktop():
#salome.sg.updateObjBrowser(True)
aFilter_1.SetMesh(Maillage_1.GetMesh())
EDGE_temp = Maillage_1.GroupOnFilter( SMESH.EDGE, noms[cont], aFilter_1 )
- Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage_1.ExportMED(outFile)
#if salome.sg.hasDesktop():
#salome.sg.updateObjBrowser(True)
Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim)
try:
- Maillage.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage.ExportMED(outFile)
smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
except:
- print('ExportToMEDX() failed. Invalid file name?')
+ print('ExportMED() failed. Invalid file name?')
## Set names of Mesh objects
else:
Group_1 = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'crack' )
nbAdd = Group_1.AddFrom( Maillage_1.GetMesh() )
- Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage_1.ExportMED(outFile)
return(True)
Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim)
try:
- Maillage.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage.ExportMED(outFile)
smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
except:
- print('ExportToMEDX() failed. Invalid file name?')
+ print('ExportMED() failed. Invalid file name?')
if salome.sg.hasDesktop():
Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim=3)
try:
- Maillage.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage.ExportMED(outFile)
smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
except:
- print('ExportToMEDX() failed. Invalid file name?')
+ print('ExportMED() failed. Invalid file name?')
## Set names of Mesh objects
if len(front)==0: crackOnly=False
if crackOnly:
- mesh.ExportMED(outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ mesh.ExportMED(outFile)
return('crack')
# Propagates color using elem connectivity
mesh.MakeGroupByIds('Extended_side%d' %n ,SMESH.EDGE,grElemList[2][n])
if outFile==None: outFile=meshFile
- mesh.ExportMED(outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ mesh.ExportMED(outFile)
return(True)
Hexa_3D = boite.Hexahedron(algo=smeshBuilder.Hexa)
isDone = boite.Compute()
smesh.SetName(boite, 'boite')
-boite.ExportMED( r'boite.med', 0, SMESH.MED_V2_2, 1 )
+boite.ExportMED(r'boite.med')
## set object names
smesh.SetName(boite.GetMesh(), 'boite')
fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
logging.info("export maillage fini")
- maillageComplet.ExportMED( fichierMaillageFissure, 0, SMESH.MED_V2_2, 1 )
+ maillageComplet.ExportMED(fichierMaillageFissure)
putName(maillageComplet, nomFicFissure)
logging.info("fichier maillage fissure %s", fichierMaillageFissure)
[origShapes, verticesShapes, dmoyen] = \
creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut, nomZones, coordsNoeudsFissure)
- maillageSain.ExportMED( fichierMaillageSain, 0, SMESH.MED_V2_2, 1 )
+ maillageSain.ExportMED(fichierMaillageSain)
logging.debug("fichier maillage sain %s", fichierMaillageSain)
[maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges] = \
peauInterne(fichierMaillageSain, shapeDefaut, nomZones)
if step == 18:
return None
- maillageComplet.ExportMED( fichierMaillageFissure, 0, SMESH.MED_V2_2, 1 )
+ maillageComplet.ExportMED(fichierMaillageFissure)
putName(maillageComplet, nomFicFissure)
logging.info("fichier maillage fissure : %s", fichierMaillageFissure)
fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
logging.info("export maillage fini")
- maillageComplet.ExportMED( fichierMaillageFissure, 0, SMESH.MED_V2_2, 1 )
+ maillageComplet.ExportMED(fichierMaillageFissure)
putName(maillageComplet, nomFicFissure)
logging.info("fichier maillage fissure %s", fichierMaillageFissure)
#isDone = maillageComplet.ReorientObject( grps[0] )
fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
- maillageComplet.ExportMED( fichierMaillageFissure, 0, SMESH.MED_V2_2, 1 )
+ maillageComplet.ExportMED(fichierMaillageFissure)
putName(maillageComplet, nomFicFissure)
logging.info("fichier maillage fissure %s", fichierMaillageFissure)
Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
isDone = Mesh_1.Compute()
smesh.SetName(Mesh_1, 'Mesh_1')
-Mesh_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/CubeAngle.med"), 0, SMESH.MED_V2_2, 1 )
+Mesh_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/CubeAngle.med"))
## set object names
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
smesh.SetName(cubeFin_1.GetMesh(), 'cubeFin')
smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
-cubeFin_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/cubeFin.med"), 0, SMESH.MED_V2_2, 1 )
+cubeFin_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/cubeFin.med"))
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
Nb_Segments_3.SetDistrType( 0 )
isDone = CylindreSain_1.Compute()
smesh.SetName(CylindreSain_1, 'CylindreSain')
-CylindreSain_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests//CylindreSain.med"), 0, SMESH.MED_V2_2, 1 )
+CylindreSain_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests//CylindreSain.med"))
SubMesh_1 = Regular_1D_1.GetSubMesh()
SubMesh_2 = Regular_1D_2.GetSubMesh()
Quadrangle_2D = Disque_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
isDone = Disque_1.Compute()
smesh.SetName(Disque_1, 'Disque')
-Disque_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/disque.med"), 0, SMESH.MED_V2_2, 1 )
+Disque_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/disque.med"))
SubMesh_1 = Regular_1D_1.GetSubMesh()
SubMesh_2 = Regular_1D_2.GetSubMesh()
Nb_Segments_3.SetDistrType( 0 )
isDone = EprouvetteCourbe_1.Compute()
smesh.SetName(EprouvetteCourbe_1, 'EprouvetteCourbe')
-EprouvetteCourbe_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteCourbe.med"), 0, SMESH.MED_V2_2, 1 )
+EprouvetteCourbe_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteCourbe.med"))
SubMesh_1 = Regular_1D_1.GetSubMesh()
SubMesh_2 = Regular_1D_2.GetSubMesh()
Nb_Segments_3.SetDistrType( 0 )
isDone = eprouvetteDroite_1.Compute()
smesh.SetName(eprouvetteDroite_1, 'eprouvetteDroite')
-eprouvetteDroite_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/eprouvetteDroite.med"), 0, SMESH.MED_V2_2, 1 )
+eprouvetteDroite_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/eprouvetteDroite.med"))
SubMesh_1 = Regular_1D_1.GetSubMesh()
SubMesh_2 = Regular_1D_2.GetSubMesh()
Nb_Segments_3.SetDistrType( 0 )
isDone = objetSain_1.Compute()
smesh.SetName(objetSain_1, 'objetSain')
-objetSain_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/faceGaucheSain.med"), 0, SMESH.MED_V2_2, 1 )
+objetSain_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/faceGaucheSain.med"))
SubMesh_1 = Regular_1D_1.GetSubMesh()
SubMesh_2 = Regular_1D_2.GetSubMesh()
Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
isDone = Mesh_1.Compute()
smesh.SetName(Mesh_1, 'Mesh_1')
-Mesh_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/boiteSaine.med"), 0, SMESH.MED_V2_2, 1 )
+Mesh_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/boiteSaine.med"))
## set object names
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
[ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2, tige_rotated, tige_top, section_rotated, section_top, tige_haute_rotated, tige_haute_top, rond_rotated, rond_top, tete_rotated, tete_top, section_tete_rotated, section_tete_top, conge_rotated, conge_top, appui_rotated, appui_top, p_imp_rotated, p_imp_top ] = visHex80.GetGroups()
Sub_mesh_1 = Regular_1D_1.GetSubMesh()
Sub_mesh_2 = Regular_1D_2.GetSubMesh()
-visHex80.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/visSain.med"), 0, SMESH.MED_V2_2, 1 )
+visHex80.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/visSain.med"))
## Set names of Mesh objects
name. This returns the filename.
'''
filename=str("/tmp/padder_inputfile_"+meshName+".med")
- meshObject.ExportToMEDX( filename, 0, SMESH.MED_V2_2, 1, 1 )
+ meshObject.ExportMED(filename, False, True, True)
return filename
def clear(self):