From e3335e73d5a487e81e691bff8866738cb7172e52 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 17 Jan 2005 11:49:36 +0000 Subject: [PATCH] [Bug PAL7252] DEVELOPMENT: Porting to MED2.2 --- src/CONVERTOR/VISUConvertor.cxx | 44 +- src/CONVERTOR/VISU_Convertor.cxx | 96 ++-- src/CONVERTOR/VISU_Convertor.hxx | 254 ++++++----- src/CONVERTOR/VISU_Convertor_impl.cxx | 466 ++++++++++---------- src/CONVERTOR/VISU_Convertor_impl.hxx | 243 ++++++++--- src/CONVERTOR/VISU_MedConvertor.cxx | 347 +++++++-------- src/CONVERTOR/VISU_MedConvertor.hxx | 57 ++- src/PIPELINE/VISUPipeLine.cxx | 16 +- src/VISU_I/VISU_CorbaMedConvertor.cxx | 604 ++++++++++++++------------ src/VISU_I/VISU_CorbaMedConvertor.hxx | 78 ++-- src/VISU_I/VISU_CutLines_i.cc | 6 +- src/VISU_I/VISU_DeformedShape_i.cc | 4 +- src/VISU_I/VISU_Result_i.cc | 54 +-- src/VISU_I/VISU_ScalarMap_i.cc | 8 +- src/VISU_I/VISU_ScalarMap_i.hh | 6 +- src/VISU_I/VISU_StreamLines_i.cc | 1 + 16 files changed, 1259 insertions(+), 1025 deletions(-) diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index 6f360813..47cdbeea 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -44,7 +44,7 @@ static int MYDEBUG = 0; #endif void parseFile(const char* theFileName) { - try{ + //try{ MSG(MYDEBUG,"'"< aCon(CreateConvertor(theFileName)); //aCon->GetSize(); @@ -53,21 +53,21 @@ void parseFile(const char* theFileName) { VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh& aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_reverse_iterator aFieldMapIter = aFieldMap.rbegin(); for(; aFieldMapIter != aFieldMap.rend(); aFieldMapIter++){ const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::PField& aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); @@ -77,7 +77,7 @@ void parseFile(const char* theFileName) { } //continue; //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; @@ -87,9 +87,9 @@ void parseFile(const char* theFileName) { aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; //aCon->GetMeshOnEntity(aMeshName,anEntity); - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -104,15 +104,15 @@ void parseFile(const char* theFileName) { } } MSG(MYDEBUG,"OK"); - }catch(std::exception& exc){ - MSG(MYDEBUG,"Follow exception was occured in file:"< 1){ QFileInfo fi(argv[1]); for(int i = 0; i < 1; i++){ @@ -131,10 +131,10 @@ int main(int argc, char** argv){ } return 0; } - }catch(std::exception& exc){ - MSG(MYDEBUG,"Follow exception was occured :\n"< TMeshOnEntity::GetCellsDims(const string& theFamilyName) const { - bool isFamilyPresent = (theFamilyName != ""); - int aNbCells = 0, aCellsSize = 0; - if(!isFamilyPresent){ - TCellsConn::const_iterator aCellsConnIter = myCellsConn.begin(); - for(; aCellsConnIter != myCellsConn.end(); aCellsConnIter++){ - const TConnForCellType& aConnForCellType = aCellsConnIter->second; - if(!aConnForCellType.empty()){ - aNbCells += aConnForCellType.size(); - aCellsSize += aConnForCellType.size()*(aConnForCellType[0].size()+1); - } - } - }else{ - TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName); - if(aFamilyMapIter == myFamilyMap.end()) - throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!"); - const TFamily& aFamily = aFamilyMapIter->second; - const TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh; - TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.begin(); - for(; aSubMeshIter != aSubMesh.end(); aSubMeshIter++){ - const TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(!aSubMeshOnCellType.empty()){ - int tmp = aSubMeshOnCellType.size(); - aNbCells += tmp; - int aVtkType = aSubMeshIter->first; - int aVtkSize = GetNbOfPoints(aVtkType); - aCellsSize += tmp*(aVtkSize+1); - } - } - } - return make_pair(aNbCells,aCellsSize); + if(theFamilyName == "") + return make_pair(myNbCells,myCellsSize); + TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName); + if(aFamilyMapIter == myFamilyMap.end()) + throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!"); + const PFamily& aFamily = aFamilyMapIter->second; + return make_pair(aFamily->myNbCells,aFamily->myCellsSize); } - const TField* TMesh::GetField(const string& theFieldName) const { + const PField TMesh::GetField(const string& theFieldName) const { TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = myMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != myMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const TFieldMap& aFieldMap = (aMeshOnEntityMapIter->second).myFieldMap; + const TFieldMap& aFieldMap = aMeshOnEntityMapIter->second->myFieldMap; TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++) - if(theFieldName == aFieldMapIter->first) return &(aFieldMapIter->second); + if(theFieldName == aFieldMapIter->first) + return aFieldMapIter->second; } - return NULL; + return PField(); } - const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) + + PFamily FindFamily(VISU::PMesh theMesh, const string& theFamilyName) { - if(theFamilyName == "") return NULL; - const VISU::TFamilyMap& aFamilyMap = theMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); - if(aFamilyMapIter == aFamilyMap.end()) - throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!"); - const VISU::TFamily& aFamily = aFamilyMapIter->second; - return &aFamily; + PFamily aFamily; + const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + aFamily = GetFamily(aMeshOnEntity,theFamilyName); + if(aFamily) + break; + } + return aFamily; } - TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) + + PFamily GetFamily(VISU::PMeshOnEntity theMeshOnEntity, const string& theFamilyName) { - if(theFamilyName == "") return NULL; - VISU::TFamilyMap& aFamilyMap = theMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); - if(aFamilyMapIter == aFamilyMap.end()) - throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!"); - VISU::TFamily& aFamily = aFamilyMapIter->second; - return &aFamily; - } - - void TField::ShallowCopy(const TField& aField){ - myEntity = aField.myEntity; - myMeshName = aField.myMeshName; - myNbComp = aField.myNbComp; - VISU::TField::TValField::const_iterator iter = aField.myValField.begin(); - for(; iter != aField.myValField.end(); iter++) - myValField[iter->first]; + PFamily aFamily; + if(theFamilyName != ""){ + TFamilyMap& aFamilyMap = theMeshOnEntity->myFamilyMap; + TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); + if(aFamilyMapIter != aFamilyMap.end()) + aFamily = aFamilyMapIter->second; + } + return aFamily; } } @@ -130,7 +106,7 @@ const VISU::TMeshMap& VISU_Convertor::GetMeshMap() { } -string VISU_Convertor::GenerateName(const VISU::TField::TTime& aTime){ +string VISU_Convertor::GenerateName(const VISU::TTime& aTime){ static QString aName; const string aUnits = aTime.second, tmp(aUnits.size(),' '); if(aUnits == "" || aUnits == tmp) diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 4feb723a..bebb26f0 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -29,149 +29,166 @@ #include -#include -#include #include #include -#include #include #include #include #include #include -#include -#include -#include -#include -#include +#include -#include "VISU_ExtractUnstructuredGrid.hxx" -#include "MED_Common.hxx" - -#include +class vtkUnstructuredGrid; namespace VISU{ + + template class shared_ptr: public boost::shared_ptr + { + public: + shared_ptr() {} + + template + explicit shared_ptr(Y * p) + { + reset(p); + } + + template + shared_ptr(shared_ptr const & r): + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()) + {} + + template + shared_ptr & operator=(shared_ptr const & r) + { + shared_ptr(r).swap(*this); + return *this; + } + + template shared_ptr& operator()(Y * p) // Y must be complete + { + if(T* pt = dynamic_cast(p)) + boost::shared_ptr::reset(pt); + else + boost::throw_exception(std::bad_cast()); + return *this; + } + + }; + + enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY}; - typedef vtkSmartPointer TVTKPoints; - typedef vtkSmartPointer TVTKSource; - typedef vtkSmartPointer TVTKMergetFilter; - typedef vtkSmartPointer TVTKExtractFilter; - typedef vtkSmartPointer TVTKAttribyteFilter; + typedef std::pair TFamilyAndEntity; + typedef std::set TFamilyAndEntitySet; typedef std::set TBindGroups; - struct TFamily{ - TVTKSource myStorage; - vtkIdType myId; - std::string myName; - TEntity myEntity; - TBindGroups myGroups; - vtkIdType myNbCells, myCellsSize; - typedef std::set TSubMeshOnCellType; - typedef std::map TSubMesh; - TSubMesh mySubMesh; - TFamily() : myNbCells(0), myCellsSize(0) {} + typedef std::pair TTime; + + struct TMesh; + typedef shared_ptr PMesh; + typedef std::map TMeshMap; + + struct TMeshOnEntity; + typedef shared_ptr PMeshOnEntity; + typedef std::map TMeshOnEntityMap; + + struct TFamily; + typedef shared_ptr PFamily; + typedef std::map TFamilyMap; + + struct TGroup; + typedef shared_ptr PGroup; + typedef std::map TGroupMap; + + struct TField; + typedef shared_ptr PField; + typedef std::map TFieldMap; + + struct TValForTime; + typedef shared_ptr PValForTime; + typedef std::map TValField; + + struct TBaseStructure{ + virtual ~TBaseStructure(){} }; - typedef std::map TFamilyMap; - struct TField{ - TVTKExtractFilter myExtractFilter; - vtkIdType myId; + typedef std::vector TNames; + + struct TMesh: TBaseStructure{ + int myDim, myNbPoints; std::string myName; - TEntity myEntity; - std::string myMeshName; - vtkIdType myNbComp, myNbValField, myDataSize, myIsTrimmed; - typedef std::vector TValForCellsWithType; - typedef std::map TValForCells; - typedef std::pair TTime; - typedef std::vector TCompNames; - typedef std::vector TUnitNames; - struct TValForTime{ - TVTKAttribyteFilter myAttribyteFilter; - TVTKMergetFilter myMergeFilter; - TVTKSource myStorage; - vtkIdType myId; - std::string myMeshName; - TEntity myEntity; - std::string myFieldName; - vtkIdType myNbComp; - TTime myTime; - TValForCells myValForCells; - TValForTime() : myNbComp(0) {} - ~TValForTime() { - if(myMergeFilter.GetPointer()) - myMergeFilter->UnRegisterAllOutputs(); - if(myAttribyteFilter.GetPointer()) - myAttribyteFilter->UnRegisterAllOutputs(); - } - }; - typedef std::map TValField; - TValField myValField; - TCompNames myCompNames; - TUnitNames myUnitNames; - TField() : myNbComp(0), myNbValField(0), myDataSize(0), myIsTrimmed(0) {} - void ShallowCopy(const TField& aField); - ~TField() { - if(myExtractFilter.GetPointer()) - myExtractFilter->UnRegisterAllOutputs(); - } + + TMeshOnEntityMap myMeshOnEntityMap; + TGroupMap myGroupMap; + + TMesh() : myDim(0), myNbPoints(0) {} + const PField GetField(const std::string& theFieldName) const; }; - typedef std::map TFieldMap; - - struct TMeshOnEntity{ - TVTKSource myStorage; + + struct TMeshOnEntity: TBaseStructure{ std::string myMeshName; TEntity myEntity; - vtkIdType myNbCells, myCellsSize; - typedef std::vector TConnect; - typedef std::vector TConnForCellType; - typedef std::map TCellsConn; - TCellsConn myCellsConn; + int myNbCells, myCellsSize; TFamilyMap myFamilyMap; TFieldMap myFieldMap; - MED::TGeom myGeom; TMeshOnEntity() : myNbCells(0), myCellsSize(0) {} - std::pair GetCellsDims(const std::string& theFamilyName = "") const; - + + std::pair + GetCellsDims(const std::string& theFamilyName = "") const; }; - typedef std::map TMeshOnEntityMap; - const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, - const std::string& theFamilyName); - TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, - const std::string& theFamilyName); + struct TFamily: TBaseStructure{ + int myId; + std::string myName; + TEntity myEntity; + TBindGroups myGroups; + int myNbCells, myCellsSize; + TFamily() : myNbCells(0), myCellsSize(0) {} + }; - typedef std::pair TFamilyAndEntity; - typedef std::set TFamilyAndEntitySet; - struct TGroup{ - TVTKSource myStorage; + struct TGroup: TBaseStructure{ std::string myName; std::string myMeshName; - vtkIdType myNbCells, myCellsSize; - TGroup() : myNbCells(0), myCellsSize(0) {} + int myNbCells, myCellsSize; TFamilyAndEntitySet myFamilyAndEntitySet; + TGroup() : myNbCells(0), myCellsSize(0) {} }; - typedef std::map TGroupMap; - struct TMesh{ - TVTKPoints myPoints; - vtkIdType myDim, myNbPoints; + struct TField: TBaseStructure{ + int myId; + TEntity myEntity; + bool myIsTrimmed; std::string myName; - typedef float TCoord; - typedef std::vector TPointsCoord; - TPointsCoord myPointsCoord; - typedef std::vector TPointsDim; - TPointsDim myPointsDim; - TMeshOnEntityMap myMeshOnEntityMap; - TGroupMap myGroupMap; - MED::PMeshInfo myMeshInfo; - MED::TEntityInfo myEntityInfo; - TMesh() : myDim(0), myNbPoints(0) {} - const TField* GetField(const std::string& theFieldName) const; + std::string myMeshName; + int myNbComp, myDataSize; + TValField myValField; + TNames myCompNames; + TNames myUnitNames; + TField() : myNbComp(0), myDataSize(0), myIsTrimmed(0) {} + }; + + struct TValForTime: TBaseStructure{ + int myId; + TEntity myEntity; + std::string myMeshName; + std::string myFieldName; + int myNbComp; + TTime myTime; + + TValForTime() : myNbComp(0) {} }; - typedef std::map TMeshMap; - void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); + + PFamily FindFamily(VISU::PMesh theMesh, + const std::string& theFamilyName); + + PFamily GetFamily(VISU::PMeshOnEntity theMeshOnEntity, + const std::string& theFamilyName); + + void WriteToFile(vtkUnstructuredGrid* theDataSet, + const std::string& theFileName); + }; class VISU_Convertor{ @@ -217,18 +234,17 @@ public: const VISU::TEntity& theEntity, const std::string& theFieldName) = 0; - virtual const VISU::TField& GetField(const std::string& theMeshName, - VISU::TEntity theEntity, - const std::string& theFieldName) = 0; - - virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) = 0; + virtual const VISU::PField GetField(const std::string& theMeshName, + VISU::TEntity theEntity, + const std::string& theFieldName) = 0; + + virtual const VISU::PValForTime GetTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) = 0; - static std::string GenerateName(const VISU::TField::TTime& aTime); + static std::string GenerateName(const VISU::TTime& aTime); static std::string GenerateName(const std::string& theName, unsigned int theTimeId); - static void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); }; extern "C"{ diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index ee667fec..5fcb2f9e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -71,18 +71,20 @@ namespace{ } enum ECoordName{eX, eY, eZ, eNone}; - typedef VISU::TMesh::TCoord (*TGetCoord)(const VISU::TMesh::TPointsCoord&, int); + typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int); template - VISU::TMesh::TCoord GetCoord(const VISU::TMesh::TPointsCoord& thePointsCoord, - int theStartPos) + VISU::TCoord + GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, + int theStartPos) { return thePointsCoord[theStartPos+TheCoordId]; } template<> - VISU::TMesh::TCoord GetCoord(const VISU::TMesh::TPointsCoord& thePointsCoord, - int theStartPos) + VISU::TCoord + GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, + int theStartPos) { return 0.0; } @@ -134,33 +136,35 @@ namespace{ class TCoordHelper{ - const VISU::TMesh::TPointsCoord& myPointsCoord; + const VISU::TMeshImpl::TPointsCoord& myPointsCoord; TGetCoord* myGetCoord; public: - TCoordHelper(const VISU::TMesh::TPointsCoord& thePointsCoord, + TCoordHelper(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, TGetCoord* theGetCoord): myPointsCoord(thePointsCoord), myGetCoord(theGetCoord) {} virtual ~TCoordHelper(){} - VISU::TMesh::TCoord GetCoord(int theStartPos, int theCoodId){ + VISU::TCoord + GetCoord(int theStartPos, int theCoodId) + { return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos); } }; typedef std::auto_ptr TCoordHelperPtr; - void GetPoints(VISU::TVTKSource& theStorage, VISU::TMesh& theMesh) + void GetPoints(VISU::TVTKSource& theStorage, VISU::PMeshImpl theMesh) { - vtkPoints* aPoints = theMesh.myPoints.GetPointer(); + vtkPoints* aPoints = theMesh->myPoints.GetPointer(); if(!aPoints){ aPoints = vtkPoints::New(); TCoordHelperPtr aCoordHelperPtr; - const VISU::TMesh::TPointsCoord& anArray = theMesh.myPointsCoord; + const VISU::TMeshImpl::TPointsCoord& anArray = theMesh->myPointsCoord; { - int aMeshDimension = theMesh.myDim; + int aMeshDimension = theMesh->myDim; bool anIsDimPresent[3] = {false, false, false}; for(int iDim = 0; iDim < aMeshDimension; iDim++){ - string aDimName = theMesh.myPointsDim[iDim]; + string aDimName = theMesh->myPointsDim[iDim]; if(aDimName == "x" || aDimName == "X") anIsDimPresent[eX] = true; else if(aDimName == "y" || aDimName == "Y") @@ -193,16 +197,16 @@ namespace{ } if(MYVTKDEBUG) aPoints->DebugOn(); - vtkIdType iEnd = theMesh.myPointsCoord.size(); - vtkIdType aNbPoints = iEnd / theMesh.myDim; + vtkIdType iEnd = theMesh->myPointsCoord.size(); + vtkIdType aNbPoints = iEnd / theMesh->myDim; aPoints->SetNumberOfPoints(aNbPoints); - MSG(MYDEBUG,"GetPoints - aNbPoints = "<> There is no elements on the family !!!"); - VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); + VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; + const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; MSG(MYDEBUG,"GetCellsOnEntity - aSubMeshOnCellType.size() = "<SetValue(j++,(unsigned char)aVtkType); @@ -280,7 +282,7 @@ namespace{ void GetCellsOnGroup(VISU::TVTKSource& theStorage, - const VISU::TMesh& theMesh, + VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { //Calculate dimentions of the group @@ -290,8 +292,8 @@ namespace{ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; const string& aFamilyName = aFamilyAndEntity.first; const VISU::TEntity& anEntity = aFamilyAndEntity.second; - const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second; - pair aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName); + const VISU::PMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + pair aCellsDim = aMeshOnEntity->GetCellsDims(aFamilyName); aNbCells += aCellsDim.first; aCellsSize += aCellsDim.second; } @@ -305,22 +307,22 @@ namespace{ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; const string& aFamilyName = aFamilyAndEntity.first; const VISU::TEntity& anEntity = aFamilyAndEntity.second; - const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second; - const VISU::TFamily& aFamily = *(VISU::GetFamily(aMeshOnEntity,aFamilyName)); - const VISU::TMeshOnEntity::TCellsConn &aCellsConn = aMeshOnEntity.myCellsConn; - VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); + PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + PFamilyImpl aFamily = GetFamily(aMeshOnEntity,aFamilyName); + const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = aMeshOnEntity->myCellsConn; + VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ - const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second; + const VISU::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second; int aVtkType = aCellsConnIter->first; MSG(MYDEBUG,"GetCellsOnGroup - aVtkType = "<> There is no elements on the family !!!"); - VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); + VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; + const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshOnCellType.size() = "<SetValue(j++,(unsigned char)aVtkType); @@ -342,12 +344,12 @@ namespace{ void InitProfile(VISU::TVTKExtractFilter& theFilter, - const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField::TValForTime& theValForTime) + PMeshOnEntityImpl theMeshOnEntity, + PValForTimeImpl theValForTime) { - const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells; - const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn; - VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); + const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells; + const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn; + VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ const vtkIdType& aCellType = aCellsConnIter->first; if(aValForCells.find(aCellType) == aValForCells.end()) @@ -359,21 +361,21 @@ namespace{ void GetValsOnTimeStamp(vtkFloatArray *theFloatArray, const vtkIdType& theNumberOfTuples, const std::string& theFieldName, - const VISU::TField& theField, - const VISU::TField::TValForTime& theValForTime) + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) { //theFloatArray->DebugOn(); theFloatArray->SetNumberOfTuples(theNumberOfTuples); theFloatArray->SetName(theFieldName.c_str()); MSG(MYDEBUG,"GetValsOnTimeStamp - theNumberOfTuples = "<myValForCells; + VISU::TValForTimeImpl::TValForCells::const_iterator aValForCellsIter = aValForCells.begin(); for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) { - const VISU::TField::TValForCellsWithType& anArray = aValForCellsIter->second; - int iEnd = anArray.size()/theField.myNbComp; + const VISU::TValForTimeImpl::TValForCellsWithType& anArray = aValForCellsIter->second; + int iEnd = anArray.size()/theField->myNbComp; int aVtkType = aValForCellsIter->first; MSG(MYDEBUG,"GetValsOnTimeStamp - iEnd = "<myTime; + string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + VISU_Convertor::GenerateName(aTime); return aFieldName; } void GetTimeStamp(VISU::TVTKSource& theStorage, - const VISU::TMesh& theMesh, - const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, - const VISU::TField::TValForTime& theValForTime) + const VISU::PFieldImpl theField, + const VISU::PValForTimeImpl theValForTime) { - int aNumberOfTuples = theField.myDataSize/theField.myNbComp; + int aNumberOfTuples = theField->myDataSize/theField->myNbComp; string aFieldName = GenerateFieldName(theField,theValForTime); MSG(MYDEBUG,"GetTimeStamp(TVTKSource) - aFieldName = "<myStorage); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; + PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + if(aFamily) + pSource = &(aFamily->myStorage); else - pSource = &(aMeshOnEntity.myStorage); + pSource = &(aMeshOnEntity->myStorage); VISU::TVTKSource& aSource = *pSource; //Main part of code try{ @@ -565,13 +562,11 @@ VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName, MSG(MYDEBUG,"GetMeshOnGroup - theMeshName = '"<(aFindMeshOnGroup); + PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); + const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet; + VISU::TVTKSource& aSource = aGroup->myStorage; //Main part of code try{ if(aSource.GetPointer() == NULL){ @@ -605,18 +600,16 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName, MSG(MYDEBUG,"GetTimeStampOnMesh - theFieldName = '"<myMeshName,pVTKMeshOnEntity->myEntity); + GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity); - anExtractFilter->SetInput(pVTKMeshOnEntity->myStorage.GetPointer()); - ::InitProfile(anExtractFilter,*pMeshOnEntity,aValForTime); + anExtractFilter->SetInput(aVTKMeshOnEntity->myStorage.GetPointer()); + ::InitProfile(anExtractFilter,aMeshOnEntity,aValForTime); } if(!anExtractFilter->IsRemoving()){ aSource = TOutput::New(); aSource->Delete(); - aSource->ShallowCopy(pVTKMeshOnEntity->myStorage.GetPointer()); - ::GetTimeStamp(aSource,aMesh,*pVTKMeshOnEntity,aField,aValForTime); + aSource->ShallowCopy(aVTKMeshOnEntity->myStorage.GetPointer()); + ::GetTimeStamp(aSource,aField,aValForTime); anOutput = aSource.GetPointer(); }else{ anAttribyteFilter = vtkFieldDataToAttributeDataFilter::New(); anAttribyteFilter->Delete(); //anAttribyteFilter->DebugOn(); - VISU::TVTKMergetFilter& aMergeFilter = aValForTime.myMergeFilter; + VISU::TVTKMergetFilter& aMergeFilter = aValForTime->myMergeFilter; aMergeFilter = vtkMergeDataObjectFilter::New(); aMergeFilter->Delete(); //aMergeFilter->DebugOn(); ::GetTimeStamp(anAttribyteFilter,aMergeFilter,anExtractFilter, - aMesh,*pVTKMeshOnEntity,aField,aValForTime); + aField,aValForTime); anOutput = anAttribyteFilter->GetUnstructuredGridOutput(); } if(MYDEBUGWITHFILES){ @@ -693,28 +686,35 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName, return anOutput; } -void VISU_Convertor_impl::FindMesh(const string& theMeshName, VISU::TMesh*& theMesh) +VISU::PMeshImpl +VISU_Convertor_impl::FindMesh(const string& theMeshName) { GetMeshMap(); - if(myMeshMap.find(theMeshName) == myMeshMap.end()) + TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName); + if(aMeshMapIter == myMeshMap.end()) EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<second; + return aMesh; } -void VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName, - VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - const string& theFamilyName, - VISU::TFamily*& theFamily) +VISU_Convertor_impl::TFindMeshOnEntity +VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName, + const VISU::TEntity& theEntity, + const string& theFamilyName) { - FindMesh(theMeshName,theMesh); - VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; - if(aMeshOnEntityMap.find(theEntity) == aMeshOnEntityMap.end()) + PMeshImpl aMesh = FindMesh(theMeshName); + VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity); + if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()) EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<second; + + return TFindMeshOnEntity(aMesh, + aMeshOnEntityMap[theEntity], + GetFamily(aMeshOnEntity,theFamilyName)); } @@ -724,35 +724,35 @@ float VISU_Convertor_impl::GetSize() { VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::PField aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp); } } //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; aResult += GetMeshOnGroupSize(aMeshName,aGroupName); } //Import families - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -771,24 +771,28 @@ float VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName) { - VISU::TMesh* pMesh = NULL; - VISU::TFamily* pFamily = NULL; - VISU::TMeshOnEntity* pMeshOnEntity = NULL; - FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily); - vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord); + TFindMeshOnEntity aFindMeshOnEntity = + FindMeshOnEntity(theMeshName,theEntity,theFamilyName); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity); + PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + + vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord); vtkIdType aNbCells, aCellsSize; - if(!pFamily){ - aNbCells = pMeshOnEntity->myNbCells; - aCellsSize = pMeshOnEntity->myCellsSize; + + if(!aFamily){ + aNbCells = aMeshOnEntity->myNbCells; + aCellsSize = aMeshOnEntity->myCellsSize; }else{ - aNbCells = pFamily->myNbCells; - aCellsSize = pFamily->myCellsSize; + aNbCells = aFamily->myNbCells; + aCellsSize = aFamily->myCellsSize; } + vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType); vtkIdType aTypesSize = aNbCells*sizeof(char); vtkIdType aLocationsSize = aNbCells*sizeof(int); float aNbCellsPerPoint = aCellsSize / aNbCells - 1; - vtkIdType aLinksSize = pMesh->myNbPoints * + vtkIdType aLinksSize = aMesh->myNbPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link)); aLinksSize = 0; vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize; @@ -807,30 +811,34 @@ float VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshName, } -void VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh, - const std::string& theGroupName, VISU::TGroup*& theGroup) +VISU_Convertor_impl::TFindMeshOnGroup +VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName) { - FindMesh(theMeshName,theMesh); - VISU::TGroupMap& aGroupMap = theMesh->myGroupMap; + PMeshImpl aMesh = FindMesh(theMeshName); + VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName); if(aGroupMapIter == aGroupMap.end()) EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<second; + + VISU::PGroupImpl aGroup = aGroupMapIter->second; + return TFindMeshOnGroup(aMesh,aGroup); } float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, const std::string& theGroupName) { - VISU::TMesh* pMesh = NULL; - VISU::TGroup* pGroup = NULL; - FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup); - vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord); - vtkIdType aNbCells = pGroup->myNbCells, aCellsSize = pGroup->myCellsSize; + TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup); + PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); + + vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord); + vtkIdType aNbCells = aGroup->myNbCells, aCellsSize = aGroup->myCellsSize; vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType); vtkIdType aLocationsSize = aNbCells*sizeof(int); float aNbCellsPerPoint = aCellsSize / aNbCells - 1; - vtkIdType aLinksSize = pMesh->myNbPoints * + vtkIdType aLinksSize = aMesh->myNbPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short)); aLinksSize = 0; vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize; @@ -847,31 +855,39 @@ float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, return aResult; } - -void VISU_Convertor_impl::FindField(const string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - VISU::TMeshOnEntity*& theVTKMeshOnEntity, - const string& theFieldName, VISU::TField*& theField) +VISU_Convertor_impl::TFindField +VISU_Convertor_impl::FindField(const string& theMeshName, + const VISU::TEntity& theEntity, + const string& theFieldName) { - VISU::TFamily* pFamily = NULL; - VISU::TMeshOnEntity* pMeshOnEntity = NULL; - FindMeshOnEntity(theMeshName,theMesh,theEntity,pMeshOnEntity,"",pFamily); - theMeshOnEntity = pMeshOnEntity; - VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,theEntity,""); + PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; + PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + + VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + PMeshOnEntityImpl aVTKMeshOnEntity; if(theEntity == VISU::NODE_ENTITY){ if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end()) - pMeshOnEntity = &aMeshOnEntityMap[VISU::CELL_ENTITY]; + aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY]; else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end()) - pMeshOnEntity = &aMeshOnEntityMap[VISU::FACE_ENTITY]; + aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY]; else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end()) - pMeshOnEntity = &aMeshOnEntityMap[VISU::EDGE_ENTITY]; - } - theVTKMeshOnEntity = pMeshOnEntity; - VISU::TFieldMap& aFieldMap = theMeshOnEntity->myFieldMap; - if(aFieldMap.find(theFieldName) == aFieldMap.end()) + aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY]; + }else + aVTKMeshOnEntity = aMeshOnEntity; + + VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName); + if(aFieldIter == aFieldMap.end()) EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!"); - theField = &aFieldMap[theFieldName]; + + PFieldImpl aField = aFieldIter->second; + + return TFindField(aMesh, + aMeshOnEntity, + aVTKMeshOnEntity, + aField); } @@ -879,13 +895,12 @@ float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName) { - VISU::TMesh* pMesh = NULL; - VISU::TField* pField = NULL; - VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL; - FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity, - theFieldName,pField); - float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity); - float aFieldOnMeshSize = float(pField->myDataSize*sizeof(float)*pField->myNbValField * ERR_SIZE_CALC); + TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); + PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); + PField aField = boost::get<3>(aFindField); + + float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); + float aFieldOnMeshSize = float(aField->myDataSize*sizeof(float)*aField->myValField.size()*ERR_SIZE_CALC); float aResult = aMeshSize + aFieldOnMeshSize; if(MYDEBUG) MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<myValField; - if(aValField.find(theStampsNum) == aValField.end()) + TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); + PField aField = boost::get<3>(aFindField); + + VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum); + if(aValFieldIter == aValField.end()) EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!"); - theValForTime = &aValField[theStampsNum]; + + PMeshImpl aMesh = boost::get<0>(aFindField); + PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField); + PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); + PValForTimeImpl aValForTime = aValFieldIter->second; + + return TFindTimeStamp(aMesh, + aMeshOnEntity, + aVTKMeshOnEntity, + aField, + aValForTime); } @@ -916,52 +943,43 @@ float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, const std::string& theFieldName, int theStampsNum) { - VISU::TMesh* pMesh = NULL; - VISU::TField* pField = NULL; - VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL; - VISU::TField::TValForTime* pValForTime = NULL; - FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity, - theFieldName,pField,theStampsNum,pValForTime); - float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity); - float aTimeStampSize = float(pField->myDataSize*sizeof(float) * ERR_SIZE_CALC); + TFindTimeStamp aFindTimeStamp = + FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum); + PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); + PField aField = boost::get<3>(aFindTimeStamp); + + float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); + float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC); float aResult = aMeshSize + aTimeStampSize; - if(MYDEBUG) - if(MYVTKDEBUG) - MSG(MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "< + +#include +#include +#include +#include +#include "VISU_ExtractUnstructuredGrid.hxx" + #include #include +#include + +#include + +namespace VISU{ + + typedef vtkSmartPointer TVTKPoints; + typedef vtkSmartPointer TVTKSource; + typedef vtkSmartPointer TVTKMergetFilter; + typedef vtkSmartPointer TVTKExtractFilter; + typedef vtkSmartPointer TVTKAttribyteFilter; + + typedef float TCoord; + + struct TMeshImpl: TMesh{ + TVTKPoints myPoints; + + typedef std::vector TPointsCoord; + TPointsCoord myPointsCoord; + + typedef std::vector TPointsDim; + TPointsDim myPointsDim; + }; + typedef shared_ptr PMeshImpl; + + struct TMeshOnEntityImpl: TMeshOnEntity{ + TVTKSource myStorage; + typedef std::vector TConnect; + typedef std::vector TConnForCellType; + typedef std::map TCellsConn; + TCellsConn myCellsConn; + }; + typedef shared_ptr PMeshOnEntityImpl; + + struct TFamilyImpl: TFamily{ + TVTKSource myStorage; + + typedef std::set TSubMeshOnCellType; + typedef std::map TSubMesh; + TSubMesh mySubMesh; + }; + typedef shared_ptr PFamilyImpl; + + struct TGroupImpl: TGroup{ + TVTKSource myStorage; + }; + typedef shared_ptr PGroupImpl; + + struct TFieldImpl: TField{ + TVTKExtractFilter myExtractFilter; + ~TFieldImpl() + { + if(myExtractFilter.GetPointer()) + myExtractFilter->UnRegisterAllOutputs(); + } + }; + typedef shared_ptr PFieldImpl; + + struct TValForTimeImpl: TValForTime{ + TVTKAttribyteFilter myAttribyteFilter; + TVTKMergetFilter myMergeFilter; + TVTKSource myStorage; + + typedef std::vector TValForCellsWithType; + typedef std::map TValForCells; + TValForCells myValForCells; + + ~TValForTimeImpl() + { + if(myMergeFilter.GetPointer()) + myMergeFilter->UnRegisterAllOutputs(); + if(myAttribyteFilter.GetPointer()) + myAttribyteFilter->UnRegisterAllOutputs(); + } + }; + typedef shared_ptr PValForTimeImpl; + +} + class VISU_Convertor_impl: public VISU_Convertor{ public: virtual float GetSize() ; - virtual float GetMeshOnEntitySize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFamilyName = ""); - - virtual float GetMeshOnGroupSize(const std::string& theMeshName, - const std::string& theGroupName); - - virtual float GetTimeStampSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum); - - virtual float GetFieldOnMeshSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName); - - virtual const VISU::TField& GetField(const std::string& theMeshName, - VISU::TEntity theEntity, - const std::string& theFieldName); - - virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum); + virtual + float + GetMeshOnEntitySize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName = ""); + + virtual + float + GetMeshOnGroupSize(const std::string& theMeshName, + const std::string& theGroupName); + + virtual + float + GetTimeStampSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); + + virtual + float + GetFieldOnMeshSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName); + + virtual + const VISU::PField + GetField(const std::string& theMeshName, + VISU::TEntity theEntity, + const std::string& theFieldName); + + virtual + const VISU::PValForTime + GetTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); public: VISU_Convertor_impl(); @@ -50,52 +149,70 @@ public: virtual VISU_Convertor* Build() { return this;}; - virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFamilyName = ""); - - virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, - const std::string& theGroupName); - - virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum); + virtual + TOutput* + GetMeshOnEntity(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName = ""); + + virtual + TOutput* + GetMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName); + + virtual + TOutput* + GetTimeStampOnMesh(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); protected: - void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh); - - void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity, - const std::string& theFamilyName, VISU::TFamily*& theFamily); - - void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh, - const std::string& theGroupName, VISU::TGroup*& theGroup); - - void FindField(const std::string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - VISU::TMeshOnEntity*& theVTKMeshOnEntity, - const std::string& theFieldName, VISU::TField*& theField); - - void FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh, - const VISU::TEntity& theEntity, - VISU::TMeshOnEntity*& theMeshOnEntity, - VISU::TMeshOnEntity*& theVTKMeshOnEntity, - const std::string& theFieldName, VISU::TField*& theField, - int theStampsNum, VISU::TField::TValForTime*& theValForTime); - + VISU::PMeshImpl + FindMesh(const std::string& theMeshName); + + typedef boost::tuple TFindMeshOnEntity; + TFindMeshOnEntity + FindMeshOnEntity(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName); + + typedef boost::tuple TFindMeshOnGroup; + TFindMeshOnGroup + FindMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName); + + typedef boost::tuple TFindField; + TFindField + FindField(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName); + + typedef boost::tuple TFindTimeStamp; + TFindTimeStamp + FindTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum); + protected: - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, const std::string& theFamilyName = "") = 0; - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0; - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) = 0; + virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) = 0; }; #endif diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 4c7b8d88..a861616a 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -42,7 +42,7 @@ using namespace MED; using namespace VISU; #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -176,37 +176,38 @@ VISU_Convertor* VISU_MedConvertor::Build() { TInt aDim = aMeshInfo->GetDim(); const string& aMeshName = aMeshInfo->GetName(); - TMesh& aMesh = aMeshMap[aMeshName]; - aMesh.myDim = aDim; - aMesh.myName = aMeshName; - aMesh.myNbPoints = aNodeInfo->GetNbElem(); - aMesh.myMeshInfo = aMeshInfo; - aMesh.myEntityInfo = aEntityInfo; + PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh()); + aMesh->myDim = aDim; + aMesh->myName = aMeshName; + aMesh->myNbPoints = aNodeInfo->GetNbElem(); + aMesh->myMeshInfo = aMeshInfo; + aMesh->myEntityInfo = aEntityInfo; INITMSG(MYDEBUG,"aMeshName = '"<myMeshOnEntityMap; MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin(); for(; anEntityIter != aEntityInfo.end(); anEntityIter++){ const EEntiteMaillage& aMEntity = anEntityIter->first; const MED::TGeom& aTGeom = anEntityIter->second; TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; - aMeshOnEntity.myEntity = aVEntity; - aMeshOnEntity.myMeshName = aMeshName; - aMeshOnEntity.myGeom = aTGeom; + PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); + aMeshOnEntity->myEntity = aVEntity; + aMeshOnEntity->myMeshName = aMeshName; + aMeshOnEntity->myGeom = aTGeom; INITMSG(MYDEBUG,"aMEntity = "<myNbCells = aMesh->myNbPoints; + aMeshOnEntity->myCellsSize = 2*aMesh->myNbPoints; - for(TInt iElem = 0; iElem < aMesh.myNbPoints; iElem++){ + for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){ TInt aFamId = aNodeInfo->GetFamNum(iElem); if(aFamId != 0){ aFamilyNbCellsCounterMap[aFamId] += 1; @@ -214,25 +215,25 @@ VISU_Convertor* VISU_MedConvertor::Build() { } } - INITMSG(MYDEBUG,"myNbCells = "<myNbCells = 0; + aMeshOnEntity->myCellsSize = 0; for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ const EGeometrieElement& aGeom = anTGeomIter->first; int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom)); PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); TInt aNbElem = aCellInfo->GetNbElem(); - aMeshOnEntity.myNbCells += aNbElem; - aMeshOnEntity.myCellsSize += aNbElem*(aVNbNodes+1); + aMeshOnEntity->myNbCells += aNbElem; + aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1); INITMSG(MYDEBUG,"aGeom = "<myNbPoints; iElem++){ TInt aFamId = aCellInfo->GetFamNum(iElem); if(aFamId != 0){ aFamilyNbCellsCounterMap[aFamId] += 1; @@ -250,30 +251,34 @@ VISU_Convertor* VISU_MedConvertor::Build() { const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; + VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; INITMSG(MYDEBUG,"aMEntity = "<GetId() == 0) continue; - VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyInfo->GetName()]; + if (aFamilyInfo->GetId() == 0) + continue; + + const std::string& aFamilyName = aFamilyInfo->GetName(); + PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); - aFamily.myId = aFamilyInfo->GetId(); - aFamily.myName = aFamilyInfo->GetName(); - aFamily.myEntity = aVEntity; - aFamily.myNbCells = aFamilyNbCellsCounterMap[aFamily.myId]; - aFamily.myCellsSize = aFamilyCellsSizeCounterMap[aFamily.myId]; + aFamily->myId = aFamilyInfo->GetId(); + aFamily->myName = aFamilyInfo->GetName(); + aFamily->myEntity = aVEntity; + aFamily->myNbCells = aFamilyNbCellsCounterMap[aFamily->myId]; + aFamily->myCellsSize = aFamilyCellsSizeCounterMap[aFamily->myId]; - INITMSG(MYDEBUG,"aFamilyName = '"<myGroups; const TInt aNbGroup = aFamilyInfo->GetNbGroup(); for(TInt i = 0; i < aNbGroup; i++){ const string& aGroupName = aFamilyInfo->GetGroupName(i); @@ -285,59 +290,59 @@ VISU_Convertor* VISU_MedConvertor::Build() { BEGMSG(MYDEBUG,"VISU::TGroup:\n"); - VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); for(;aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){ const string& aGroupName = aGroupInfoIter->first; const TFamilyGroup& aFamilyGroup = aGroupInfoIter->second; - VISU::TGroup aGroup; - aGroup.myName = aGroupName; - aGroup.myMeshName = aMesh.myName; + PMEDGroup aGroup(new TMEDGroup()); + aGroup->myName = aGroupName; + aGroup->myMeshName = aMesh->myName; - INITMSG(MYDEBUG,"aGroup.myName = '"<myName = '"<myName<<"'\n"); TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin(); - for( ;aFamilyIter != aFamilyGroup.end(); aFamilyIter++){ + for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){ const PFamilyInfo& aFamilyInfo = *aFamilyIter; const string& aFamilyName = aFamilyInfo->GetName(); TEntity aVEntity = TEntity(-1); + PFamily aFamily; // Find aVisuEntity - const TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); - for (; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){ - const TMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; - const TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){ + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; + const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; - const TFamily& aFamily = aFamilyMapIter->second; - TFamilyGroup::const_iterator aGroupInfoIter = aFamilyGroup.begin(); - for (;aGroupInfoIter != aFamilyGroup.end(); aGroupInfoIter++){ - const PFamilyInfo& aFamilyInfo = *aGroupInfoIter; - if(aFamilyInfo->GetName() == aFamilyName){ - aVEntity = aFamily.myEntity; - goto exit_lable; + aFamily = aFamilyMapIter->second; + if(aFamily){ + TFamilyGroup::const_iterator aGroupInfoIter = aFamilyGroup.begin(); + for(; aGroupInfoIter != aFamilyGroup.end(); aGroupInfoIter++){ + const PFamilyInfo& aFamilyInfo = *aGroupInfoIter; + if(aFamilyInfo->GetName() == aFamilyName){ + aVEntity = aFamily->myEntity; + goto exit_lable; + } } } } } exit_lable: - if(aVEntity >= 0){ - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; - VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyInfo->GetName()]; - VISU::TFamilyAndEntity aFamilyAndEntity(aFamilyName,aVEntity); - aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); + if(aFamily && aVEntity >= 0){ + aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity)); INITMSG(MYDEBUG,"aFamilyName = '"<myNbCells += aFamily->myNbCells; + aGroup->myCellsSize += aFamily->myCellsSize; } } - BEGMSG(MYDEBUG,"myNbCells = "< 0){ + if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){ + BEGMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n\n"); aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); } } @@ -355,28 +360,27 @@ VISU_Convertor* VISU_MedConvertor::Build() { TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom); TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[aVEntity]; - VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName]; - aField.myId = iField; - aField.myNbComp = aNbComp; - aField.myEntity = aVEntity; - aField.myName = aFieldName; - aField.myMeshName = aMeshName; - aField.myNbValField = aNbTimeStamps; - aField.myDataSize = aMeshOnEntity.myNbCells * aNbComp; - aField.myCompNames.resize(aNbComp); - aField.myUnitNames.resize(aNbComp); - - INITMSG(MYDEBUG,"myName = '"<myMeshOnEntityMap[aVEntity]; + TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + PMEDField aField = aFieldMap[aFieldName](new TMEDField()); + aField->myId = iField; + aField->myNbComp = aNbComp; + aField->myEntity = aVEntity; + aField->myName = aFieldName; + aField->myMeshName = aMeshName; + aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp; + aField->myCompNames.resize(aNbComp); + aField->myUnitNames.resize(aNbComp); + + INITMSG(MYDEBUG,"myName = '"<myName<< + "'; myId = "<myId<< + "; myEntity = "<myEntity<< + "; myDataSize = "<myDataSize<< + "; myNbComp = "<myNbComp<<"\n"); for(TInt iComp = 0; iComp < aNbComp; iComp++){ - aField.myCompNames[iComp] = aFieldInfo->GetCompName(iComp); - aField.myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp); + aField->myCompNames[iComp] = aFieldInfo->GetCompName(iComp); + aField->myUnitNames[iComp] = aFieldInfo->GetUnitName(iComp); } for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ @@ -387,13 +391,14 @@ VISU_Convertor* VISU_MedConvertor::Build() { TFloat aDt = aTimeStamp->GetDt(); const string& anUnitDt = aTimeStamp->GetUnitDt(); PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp); - VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp]; - aValForTime.myId = iTimeStamp; - aValForTime.myFieldName = aField.myName; - aValForTime.myEntity = aField.myEntity; - aValForTime.myMeshName = aField.myMeshName; - aValForTime.myNbComp = aField.myNbComp; - aValForTime.myTime = VISU::TField::TTime(aDt,anUnitDt); + TValField& aValField = aField->myValField; + PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime()); + aValForTime->myId = iTimeStamp; + aValForTime->myFieldName = aField->myName; + aValForTime->myEntity = aField->myEntity; + aValForTime->myMeshName = aField->myMeshName; + aValForTime->myNbComp = aField->myNbComp; + aValForTime->myTime = VISU::TTime(aDt,anUnitDt); INITMSG(MYDEBUG,"aDt = "<myMeshName; + const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; + PMeshImpl aMesh = myMeshMap[aMeshName]; int isPointsUpdated; if(anEntity == VISU::NODE_ENTITY) isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName); else isPointsUpdated = LoadPoints(aMed,aMesh); - int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,theMeshOnEntity,theFamilyName); + int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,aMesh,theMeshOnEntity,theFamilyName); return (isPointsUpdated || isCellsOnEntityUpdated); } -int VISU_MedConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, +int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); @@ -428,28 +433,28 @@ int VISU_MedConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ const string& aFamilyName = aFamilyAndEntitySetIter->first; const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second; - VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[anEntity]; + const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; if(anEntity == VISU::NODE_ENTITY){ isPointsUpdated += LoadPoints(aMed,theMesh,aFamilyName); - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,aMeshOnEntity); + isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity); }else{ isPointsUpdated += LoadPoints(aMed,theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,aMeshOnEntity,aFamilyName); + isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,aMeshOnEntity,aFamilyName); } } return (isPointsUpdated || isCellsOnEntityUpdated); } -int VISU_MedConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) +int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) { PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); int isPointsUpdated = LoadPoints(aMed,theMesh); - int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,theMeshOnEntity); - int isFieldUpdated = LoadField(aMed,theMeshOnEntity,theField,theValForTime); + int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); + int isFieldUpdated = LoadField(aMed,theMesh,theMeshOnEntity,theField,theValForTime); return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated); } @@ -457,58 +462,58 @@ int VISU_MedConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, int VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, - VISU::TMesh& theMesh, + VISU::PMEDMesh theMesh, const string& theFamilyName) { try{ //Check on existing family - VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[VISU::NODE_ENTITY]; - aMeshOnEntity.myEntity = VISU::NODE_ENTITY; - aMeshOnEntity.myMeshName = theMesh.myName; - VISU::TFamily* pFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; + VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; + aMeshOnEntity->myEntity = VISU::NODE_ENTITY; + aMeshOnEntity->myMeshName = theMesh->myName; + PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName); //Check on loading already done - bool isPointsLoaded = !theMesh.myPointsCoord.empty(); + bool isPointsLoaded = !theMesh->myPointsCoord.empty(); if(isPointsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; + if(!aFamily) + return 0; + else if(!aFamily->mySubMesh.empty()) + return 0; INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<GetPNodeInfo(theMesh.myMeshInfo); + PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); TInt aNbElem = aNodeInfo->GetNbElem(); if(!isPointsLoaded){ - VISU::TMesh::TPointsDim& aPointsDim = theMesh.myPointsDim; - aPointsDim.resize(theMesh.myDim); - for(int iDim = 0; iDim < theMesh.myDim; iDim++) + VISU::TMeshImpl::TPointsDim& aPointsDim = theMesh->myPointsDim; + aPointsDim.resize(theMesh->myDim); + for(int iDim = 0; iDim < theMesh->myDim; iDim++) aPointsDim[iDim] = aNodeInfo->GetCoordName(iDim); - VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; - aPointsCoord.resize(aNbElem*theMesh.myDim); + VISU::TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord; + aPointsCoord.resize(aNbElem*theMesh->myDim); for (int iElem = 0; iElem < aNbElem; iElem++) - for(int iDim = 0, iElem2Dim = iElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iElem2Dim++) + for(int iDim = 0, iElem2Dim = iElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iElem2Dim++) aPointsCoord[iElem2Dim] = aNodeInfo->GetNodeCoord(iElem,iDim); - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; + VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; aConnForCellType.resize(aNbElem); for (int iElem = 0; iElem < aNbElem; iElem++) - aConnForCellType[iElem] = VISU::TMeshOnEntity::TConnect(1,iElem); + aConnForCellType[iElem] = VISU::TMeshOnEntityImpl::TConnect(1,iElem); } - if(isFamilyPresent && aNbElem > 0){ - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; + if(aFamily && aNbElem > 0){ + VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; for (int iElem = 0; iElem < aNbElem; iElem++) - if(aNodeInfo->GetElemNum(iElem) == aFamily.myId) + if(aNodeInfo->GetElemNum(iElem) == aFamily->myId) aSubMeshOnCellType.insert(iElem); } return 1; }catch(std::runtime_error& exc){ - theMesh.myPointsCoord.clear(); + theMesh->myPointsCoord.clear(); throw; }catch(...){ - theMesh.myPointsCoord.clear(); + theMesh->myPointsCoord.clear(); EXCEPTION(runtime_error,"Unknown exception !!!"); } return 0; @@ -517,31 +522,29 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, int VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, - VISU::TMeshOnEntity& theMeshOnEntity, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, const string& theFamilyName) { try{ //Check on existing family - VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; + PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); + bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); if(isCellsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; + if(!aFamily) + return 0; + else if(!aFamily->mySubMesh.empty()) + return 0; INITMSG(MYDEBUG,"LoadCellsOnEntity - theFamilyName = '"<myValForCells.empty()) return 0; //Main part of code - const std::string& aMeshName = theMeshOnEntity.myMeshName; - VISU::TMesh& aMesh = myMeshMap[aMeshName]; - const PMeshInfo& aMeshInfo = aMesh.myMeshInfo; - PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,theField.myId); + const std::string& aMeshName = theMeshOnEntity->myMeshName; + const PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,theField->myId); MED::TGeom aTGeom; EEntiteMaillage aMEntity; - theMed->GetNbTimeStamps(aFieldInfo,aMesh.myEntityInfo,aMEntity,aTGeom); + theMed->GetNbTimeStamps(aFieldInfo,theMesh->myEntityInfo,aMEntity,aTGeom); PTimeStampInfo aTimeStampInfo = theMed->GetPTimeStampInfo(aFieldInfo, aMEntity, aTGeom, - theValForTime.myId); + theValForTime->myId); TInt aNbGauss = aTimeStampInfo->GetNbGauss(); - TInt aNbComp = theField.myNbComp; + TInt aNbComp = theField->myNbComp; PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); INITMSG(MYDEBUG,"LoadField - aMeshName = '"<myGroups; + aBindGroups.insert(aSupportName.in()); + } } - continue; } } } @@ -583,7 +636,7 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value(); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<NewChildIterator(aFieldSObj); - for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){ + for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){ SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<getName(); CORBA::String_var aFieldName = aMEDField->getName(); - VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in()); + TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in()); if(aMeshMapIter == myMeshMap.end()) continue; - VISU::TMesh &aMesh = aMeshMapIter->second; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myName = aMeshName.in(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - aMeshOnEntity.myEntity = anEntity; - aMeshOnEntity.myMeshName = aMeshName.in(); - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity]; - aMeshOnEntity2.mySupport = aMEDSupport; - if(anEntity == VISU::NODE_ENTITY) - aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport; - GetCellsSize(aMesh,aMEDMesh,anEntity); - - VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()]; - aField.myId = iField; - aField.myName = aFieldName.in(); - aField.myEntity = anEntity; - aField.myMeshName = aMeshName.in(); - aField.myNbComp = aMEDField->getNumberOfComponents(); - aField.myNbValField = iTimeStamp; - aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp; - if(MYDEBUG && !iTimeStamp) - MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity.myNbCells = "<second; + TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity); + if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()) + continue; + + PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in()); + PCField aField; + if(aFieldMapIter == aFieldMap.end()){ + aField = aFieldMap[aFieldName.in()](new TCField()); + aField->myId = iField; + aField->myName = aFieldName.in(); + aField->myEntity = anEntity; + aField->myMeshName = aMeshName.in(); + aField->myNbComp = aMEDField->getNumberOfComponents(); + aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp; + if(MYDEBUG) + MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<myNbCells); + aField->myCompNames.resize(aField->myNbComp); + aField->myUnitNames.resize(aField->myNbComp); + }else + aField = aFieldMapIter->second; + + TValField& aValField = aField->myValField; int anId = aMEDField->getIterationNumber(); - VISU::TField::TValForTime& aValForTime = aField.myValField[anId]; - aValForTime.myId = anId; - aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),""); - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId]; - aValForTime2.myField = aMEDField; + PCValForTime aValForTime = aValField[anId](new TCValForTime()); + aValForTime->myId = anId; + CORBA::Double aDT = aMEDField->getTime(); + aValForTime->myTime = TTime(aDT,""); + aValForTime->myField = aMEDField; if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<_is_nil()) continue; + if(aMEDField->_is_nil()) + continue; + SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); - if(aMEDSupport->_is_nil()) continue; + if(aMEDSupport->_is_nil()) + continue; + SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = MEDEntityToVTK(aMEntity); + TEntity aVEntity = MEDEntityToVTK(aMEntity); SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); if(aMEDMesh->_is_nil()) continue; CORBA::String_var aMeshName = aMEDMesh->getName(); CORBA::String_var aFieldName = aMEDField->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myPointsDim.resize(aMesh.myDim); - aMesh.myName = aMeshName.in(); - aMesh.myNbPoints = aMEDMesh->getNumberOfNodes(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<myNbCells = "<myNbCells); + aField->myCompNames.resize(aField->myNbComp); + aField->myUnitNames.resize(aField->myNbComp); + } + + TValField& aValField = aField->myValField; int anId = aMEDField->getIterationNumber(); - VISU::TField::TValForTime& aValForTime = aField.myValField[anId]; - aValForTime.myId = anId; - aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),""); - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId]; - aValForTime2.myField = aMEDField; + PCValForTime aValForTime = aValField[anId](new TCValForTime()); + aValForTime->myId = anId; + CORBA::Double aDT = aMEDField->getTime(); + aValForTime->myTime = TTime(aDT,""); + aValForTime->myField = aMEDField; if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<getSpaceDimension(); + + SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh; int iNumElemEnd = aMedMesh->getNumberOfNodes(); - VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; + TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord; if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<> There is no points in the mesh !!!"); - aPointsCoord.resize(theMesh.myDim*iNumElemEnd,0.0); - SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); + aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0); + SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); if(!isPointsLoaded){ for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++) + for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++) aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim]; if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; + TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; aConnForCellType.resize(iNumElemEnd); for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem); + aConnForCellType[iNumElem] = TMeshOnEntityImpl::TConnect(1,iNumElem); } - if(isFamilyPresent){ + if(aFamily){ if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); - VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName]; - SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily; - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; + SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; + TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); int iNumElemEndTmp = iNumElemEnd; @@ -842,32 +909,33 @@ VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName) int -VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) +VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + const string& theFamilyName) { //Check on existing family - VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; + PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); + bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); if(isCellsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName]; - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity]; - SALOME_MED::SUPPORT_var& aMedSupport = aMeshOnEntity2.mySupport; + if(!aFamily) + return 0; + else if(!aFamily->mySubMesh.empty()) + return 0; + + SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport; SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh(); if(MYDEBUG) { MESSAGE("LoadCellsOnEntity - theFamilyName = '"<myValForCells[aVGeom]; + aValForCellsWithType.resize(iNumElemEnd*theField->myNbComp); for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - for(int k = 0, kj = iNumElem*theField.myNbComp; k < theField.myNbComp; k++) - aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField.myNbComp+kj+k]; + for(int k = 0, kj = iNumElem*theField->myNbComp; k < theField->myNbComp; k++) + aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField->myNbComp+kj+k]; } } } @@ -1002,30 +1069,27 @@ ImportField(TArray& theArray, } int -VISU_MEDConvertor::LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) +VISU_MEDConvertor::LoadField(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + VISU::PField theField, + VISU::PCValForTime theValForTime) { //Check on loading already done - if(!theValForTime.myValForCells.empty()) return 0; - VISU::TMesh& aMesh = myMeshMap[theMeshOnEntity.myMeshName]; - VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName]; - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity]; - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[theField.myName]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[theValForTime.myId]; - SALOME_MED::FIELD_var aMEDField = aValForTime2.myField; - //Main part of code + if(!theValForTime->myValForCells.empty()) + return 0; + + SALOME_MED::FIELD_var aMEDField = theValForTime->myField; SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField); if(!aFieldDouble->_is_nil()){ SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<length()); - ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2); + ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); } SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField); if(!aFieldInt->_is_nil()){ SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<length()); - ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2); + ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); } return 1; } diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 6500527f..6b7c9410 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -35,48 +35,45 @@ #include -namespace VISUMED{ - struct TFamily{ - SALOME_MED::FAMILY_var myFamily; - }; - typedef std::map TFamilyMap; - - struct TField{ - struct TValForTime{ - SALOME_MED::FIELD_var myField; - }; - typedef std::map TValField; - TValField myValField; +namespace VISU{ + + struct TCMesh: TMeshImpl{ + SALOME_MED::MESH_var myMesh; }; - typedef std::map TFieldMap; + typedef shared_ptr PCMesh; - struct TMeshOnEntity{ + struct TCMeshOnEntity: TMeshOnEntityImpl{ SALOME_MED::SUPPORT_var mySupport; typedef std::pair TIndexAndSize; typedef std::map TCellsFirstIndex; TCellsFirstIndex myCellsFirstIndex; - TFamilyMap myFamilyMap; - TFieldMap myFieldMap; }; - typedef std::map TMeshOnEntityMap; + typedef shared_ptr PCMeshOnEntity; + + struct TCFamily: TFamilyImpl{ + SALOME_MED::FAMILY_var myFamily; + }; + typedef shared_ptr PCFamily; - struct TGroup{ + struct TCGroup: TGroupImpl{ SALOME_MED::GROUP_var myGroup; }; - typedef std::map TGroupMap; + typedef shared_ptr PCGroup; - struct TMesh{ - SALOME_MED::MESH_var myMesh; - TMeshOnEntityMap myMeshOnEntityMap; - TGroupMap myGroupMap; + struct TCField: TFieldImpl{ + }; + typedef shared_ptr PCField; + + struct TCValForTime: TValForTimeImpl{ + SALOME_MED::FIELD_var myField; }; - typedef std::map TMeshMap; + typedef shared_ptr PCValForTime; + } class VISU_MEDConvertor: public VISU_Convertor_impl{ protected: - VISUMED::TMeshMap myMeshMap2; SALOMEDS::SObject_var mySObject; VISU_MEDConvertor() {}; @@ -89,23 +86,28 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ VISU_Convertor* Build(SALOME_MED::MED_ptr theMED); VISU_Convertor* Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator); - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, + virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, const std::string& theFamilyName = ""); - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, + virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime); - - int LoadPoints(VISU::TMesh& theMesh, const std::string& theFamilyName = "") ; + virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime); - int LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const std::string& theFamilyName = ""); + int LoadPoints(VISU::PCMesh theMesh, + const std::string& theFamilyName = "") ; - int LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime); + int LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + const std::string& theFamilyName = ""); + + int LoadField(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + VISU::PField theField, + VISU::PCValForTime theValForTime); }; @@ -113,7 +115,9 @@ class VISU_MEDFieldConvertor: public VISU_MEDConvertor{ protected: SALOME_MED::FIELD_var myField; public: - VISU_MEDFieldConvertor(SALOME_MED::FIELD_ptr theField) : myField(SALOME_MED::FIELD::_duplicate(theField)) {} + VISU_MEDFieldConvertor(SALOME_MED::FIELD_ptr theField) : + myField(SALOME_MED::FIELD::_duplicate(theField)) + {} virtual VISU_Convertor* Build() ; }; diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index 4021956f..daebefcd 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -251,9 +251,9 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){ typedef map TXYMapCont; typedef map TLineIdCont; - const VISU::TField::TValField& aValField = myField->myValField; - const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second; - const VISU::TField::TTime& aTime = aValForTime.myTime; + const VISU::TValField& aValField = myField->myValField; + const VISU::PValForTime aValForTime = aValField.find((int)myIteration)->second; + const VISU::TTime& aTime = aValForTime->myTime; QString aTitle; //aTitle.sprintf("%s %s",myTitle.c_str(),aTime.second.c_str()); aTitle.sprintf("%s",myTitle.c_str()); diff --git a/src/VISU_I/VISU_DeformedShape_i.cc b/src/VISU_I/VISU_DeformedShape_i.cc index 8333217f..7d253297 100644 --- a/src/VISU_I/VISU_DeformedShape_i.cc +++ b/src/VISU_I/VISU_DeformedShape_i.cc @@ -47,8 +47,8 @@ int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshNa { try{ if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck)) return 0; - const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - return aField.myNbComp > 1; + const VISU::PField aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); + return aField->myNbComp > 1; }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + const VISU::PField aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; try{ @@ -193,7 +193,7 @@ CORBA::Boolean VISU::Result_i::BuildAll(){ } } //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; @@ -206,7 +206,7 @@ CORBA::Boolean VISU::Result_i::BuildAll(){ } } //Import families - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -264,11 +264,11 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + const VISU::PMesh aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(),aMesh.myDim); + aMeshName.c_str(),aMesh->myDim); string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), "",aMeshName.c_str(),"",aComment.latin1(),true); if(aMeshOnEntityMap.empty()) continue; @@ -294,8 +294,8 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) } aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), "",anEntityName.c_str(),"",aComment.latin1(),true); - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const string& aFamilyName = aFamilyMapIter->first; @@ -306,7 +306,7 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) } } //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; if(aGroupMap.size() > 0){ aComment.sprintf("myComment=GROUPS;myMeshName=%s",aMeshName.c_str()); string aGroupsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), @@ -318,8 +318,8 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str()); string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(), "",aGroupName.c_str(),"",aComment.latin1(),true); - const VISU::TGroup& aGroup = aGroupMapIter->second; - const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; + const VISU::PGroup aGroup = aGroupMapIter->second; + const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet; VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; @@ -338,8 +338,8 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ if(!isFieldEntryCreated){ @@ -349,21 +349,21 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) isFieldEntryCreated = true; } const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField.myUnitNames[0]); + const VISU::PField aField = aFieldMapIter->second; + const VISU::TValField& aValField = aField->myValField; + QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]); aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField.myNbComp); + VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField->myNbComp); string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true); CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; - const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; + const VISU::PValForTime aValForTime = aValFieldIter->second; aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); - string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); + VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField->myNbComp); + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), "",aTimeStampId.c_str(),"",aComment.latin1(),true); } diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 96beba4d..aee04e00 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -435,7 +435,7 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ try{ if(myResult->GetInput() == NULL) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); - myField = &(myResult->GetInput()->GetField(myMeshName,myEntity,myFieldName)); + myField = myResult->GetInput()->GetField(myMeshName,myEntity,myFieldName); if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!"); VISU_Convertor::TOutput *anOutput = myResult->GetInput()->GetTimeStampOnMesh(myMeshName,myEntity,myFieldName,myIteration); @@ -447,9 +447,9 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ if(theRestoring <= 0){ if(theRestoring == 0) myScalarMapPL->Init(); if(!myIsFixedRange) myScalarMapPL->SetSourceRange(); - const VISU::TField::TValField& aValField = myField->myValField; - const VISU::TField::TValForTime& aValForTime = aValField.find(myIteration)->second; - aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime.myTime).c_str()); + const VISU::TValField& aValField = myField->myValField; + const VISU::PValForTime aValForTime = aValField.find(myIteration)->second; + aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str()); if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1(); } if(myAddToStudy){ diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index a42b55f0..510ff794 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -125,7 +125,7 @@ namespace VISU{ virtual void DoHook(); VISU_ScalarMapPL* myScalarMapPL; - const TField* myField; + PField myField; string myMeshName; TEntity myEntity; @@ -172,8 +172,8 @@ namespace VISU{ virtual void Update() ; virtual void SetMapScale(double theMapScale = 1.0); - const VISU::TField* GetField() const { return myField;} - const string& GetFieldName() const { return myFieldName;} + const VISU::PField GetField() const { return myField;} + const string& GetFieldName() const { return myFieldName;} virtual bool IsRangeFixed() { return myIsFixedRange; } virtual void SetSourceRange(); diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 66a2305f..f6b5a303 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -31,6 +31,7 @@ #include #include +#include using namespace VISU; using namespace std; -- 2.39.2