From: apo Date: Wed, 20 Jul 2005 05:45:31 +0000 (+0000) Subject: Starting a project with ID D5-38-2003 X-Git-Tag: BR-D5-38-2003_D2005-12-09~162 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3470ecf7d1439f8690a42d14a061828cac3627a2;p=modules%2Fvisu.git Starting a project with ID D5-38-2003 --- diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index c81e39e0..5bdeef6f 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(); @@ -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 + PField + TMesh + ::GetField(const string& theFieldName) const { - 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 PField TMesh::GetField(const string& theFieldName) const { TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = myMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != myMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const TFieldMap& aFieldMap = aMeshOnEntityMapIter->second->myFieldMap; @@ -71,7 +66,9 @@ namespace VISU{ } - PFamily FindFamily(VISU::PMesh theMesh, const string& theFamilyName) + PFamily + FindFamily(VISU::PMesh theMesh, + const string& theFamilyName) { PFamily aFamily; const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; @@ -86,7 +83,9 @@ namespace VISU{ } - PFamily GetFamily(VISU::PMeshOnEntity theMeshOnEntity, const string& theFamilyName) + PFamily + GetFamily(VISU::PMeshOnEntity theMeshOnEntity, + const string& theFamilyName) { PFamily aFamily; if(theFamilyName != ""){ @@ -100,13 +99,19 @@ namespace VISU{ } -const VISU::TMeshMap& VISU_Convertor::GetMeshMap() { +const VISU::TMeshMap& +VISU_Convertor +::GetMeshMap() +{ if(!myIsDone) { myIsDone = true; Build();} return myMeshMap; } -string VISU_Convertor::GenerateName(const VISU::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) @@ -117,7 +122,11 @@ string VISU_Convertor::GenerateName(const VISU::TTime& aTime){ return aName.latin1(); } -string VISU_Convertor::GenerateName(const string& theName, unsigned int theTimeId) { +string +VISU_Convertor +::GenerateName(const string& theName, + unsigned int theTimeId) +{ static QString aName; aName = QString(theName.c_str()).simplifyWhiteSpace(); int iEnd = strlen(aName); diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index bebb26f0..8cd141fc 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -43,212 +43,322 @@ class vtkUnstructuredGrid; namespace VISU{ - template class shared_ptr: public boost::shared_ptr + template class SharedPtr: public boost::shared_ptr { public: - shared_ptr() {} + SharedPtr() {} template - explicit shared_ptr(Y * p) - { - reset(p); - } + explicit SharedPtr(Y * p): + boost::shared_ptr(p) + {} template - shared_ptr(shared_ptr const & r): + SharedPtr(SharedPtr const & r): boost::shared_ptr(r,boost::detail::dynamic_cast_tag()) {} template - shared_ptr & operator=(shared_ptr const & r) + SharedPtr & operator=(SharedPtr const & r) { - shared_ptr(r).swap(*this); + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()).swap(*this); return *this; } - template shared_ptr& operator()(Y * p) // Y must be complete + template SharedPtr& 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; + return operator=(SharedPtr(p)); } - }; + operator const T& () const + { + return *(this->get()); + } + operator T& () + { + return *(this->get()); + } - enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY}; + }; + //--------------------------------------------------------------- - typedef std::pair TFamilyAndEntity; - typedef std::set TFamilyAndEntitySet; - typedef std::set TBindGroups; - typedef std::pair TTime; + enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY}; struct TMesh; - typedef shared_ptr PMesh; + typedef SharedPtr PMesh; typedef std::map TMeshMap; + struct TSubProfile; + typedef SharedPtr PSubProfile; + + struct TProfile; + typedef SharedPtr PProfile; + struct TMeshOnEntity; - typedef shared_ptr PMeshOnEntity; - typedef std::map TMeshOnEntityMap; + typedef SharedPtr PMeshOnEntity; struct TFamily; - typedef shared_ptr PFamily; - typedef std::map TFamilyMap; + typedef SharedPtr PFamily; struct TGroup; - typedef shared_ptr PGroup; - typedef std::map TGroupMap; + typedef SharedPtr PGroup; struct TField; - typedef shared_ptr PField; - typedef std::map TFieldMap; + typedef SharedPtr PField; + + struct TGauss; + typedef SharedPtr PGauss; struct TValForTime; - typedef shared_ptr PValForTime; - typedef std::map TValField; + typedef SharedPtr PValForTime; + - struct TBaseStructure{ - virtual ~TBaseStructure(){} + //--------------------------------------------------------------- + struct TBaseStructure + { + virtual ~TBaseStructure() + {} }; typedef std::vector TNames; - struct TMesh: TBaseStructure{ - int myDim, myNbPoints; - std::string myName; + //--------------------------------------------------------------- + typedef std::map TMeshOnEntityMap; + typedef std::map TGroupMap; + + struct TMesh: virtual TBaseStructure + { TMeshOnEntityMap myMeshOnEntityMap; TGroupMap myGroupMap; + std::string myName; + int myDim; + + TMesh(): myDim(0) + {} - TMesh() : myDim(0), myNbPoints(0) {} - const PField GetField(const std::string& theFieldName) const; + PField + GetField(const std::string& theFieldName) const; }; - struct TMeshOnEntity: TBaseStructure{ - std::string myMeshName; - TEntity myEntity; - int myNbCells, myCellsSize; + + //--------------------------------------------------------------- + struct TSubProfile: virtual TBaseStructure + {}; + + + //--------------------------------------------------------------- + struct TProfile: virtual TBaseStructure + {}; + + + //--------------------------------------------------------------- + struct TSubProfileLess + { + bool + operator()(const PSubProfile& theLeft, const PSubProfile& theRight) const; + }; + typedef std::set TProfileKey; + + + //--------------------------------------------------------------- + typedef std::map TProfileMap; + + typedef std::map TFamilyMap; + typedef std::map TFieldMap; + + struct TMeshOnEntity: virtual TBaseStructure + { + TProfileMap myProfileMap; TFamilyMap myFamilyMap; TFieldMap myFieldMap; - TMeshOnEntity() : myNbCells(0), myCellsSize(0) {} - std::pair - GetCellsDims(const std::string& theFamilyName = "") const; + std::string myMeshName; + TEntity myEntity; }; - struct TFamily: TBaseStructure{ - int myId; + + //--------------------------------------------------------------- + typedef std::set TBindGroups; + + struct TFamily: virtual TBaseStructure + { + TBindGroups myGroups; std::string myName; TEntity myEntity; - TBindGroups myGroups; - int myNbCells, myCellsSize; - TFamily() : myNbCells(0), myCellsSize(0) {} }; - struct TGroup: TBaseStructure{ + + //--------------------------------------------------------------- + typedef std::pair TFamilyAndEntity; + typedef std::set TFamilyAndEntitySet; + + struct TGroup: virtual TBaseStructure + { std::string myName; std::string myMeshName; - int myNbCells, myCellsSize; TFamilyAndEntitySet myFamilyAndEntitySet; - TGroup() : myNbCells(0), myCellsSize(0) {} }; - struct TField: TBaseStructure{ - int myId; + + //--------------------------------------------------------------- + typedef std::map TValField; + + struct TField: virtual TBaseStructure + { TEntity myEntity; - bool myIsTrimmed; std::string myName; std::string myMeshName; - int myNbComp, myDataSize; TValField myValField; TNames myCompNames; TNames myUnitNames; - TField() : myNbComp(0), myDataSize(0), myIsTrimmed(0) {} + int myNbComp; + + TField(): myNbComp(0) + {} }; - struct TValForTime: TBaseStructure{ - int myId; + + //--------------------------------------------------------------- + struct TGauss: virtual TBaseStructure + {}; + + + //--------------------------------------------------------------- + typedef std::pair TTime; + typedef std::map TGaussMap; + + struct TValForTime: virtual TBaseStructure + { TEntity myEntity; std::string myMeshName; std::string myFieldName; - int myNbComp; TTime myTime; - - TValForTime() : myNbComp(0) {} + + PProfile myProfile; + TGaussMap myGaussMap; }; - PFamily FindFamily(VISU::PMesh theMesh, - const std::string& theFamilyName); - - PFamily GetFamily(VISU::PMeshOnEntity theMeshOnEntity, - const std::string& theFamilyName); + 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); + void + WriteToFile(vtkUnstructuredGrid* theDataSet, + const std::string& theFileName); }; -class VISU_Convertor{ + +//--------------------------------------------------------------- +class VISU_Convertor +{ protected: std::string myName; VISU::TMeshMap myMeshMap; int myIsDone; + public: - virtual ~VISU_Convertor(){}; - virtual const std::string& GetName() { return myName;} - virtual int IsDone() const { return myIsDone;} + virtual + ~VISU_Convertor() + {}; + + virtual + const std::string& + GetName(){ return myName;} + + virtual + int + IsDone() const { return myIsDone; } + typedef vtkUnstructuredGrid TOutput; - virtual VISU_Convertor* Build() = 0; - virtual const VISU::TMeshMap& GetMeshMap() ; - virtual float GetSize() = 0; + virtual + VISU_Convertor* + Build() = 0; - virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFamilyName = "") = 0; - - virtual float GetMeshOnEntitySize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFamilyName = "") = 0; - - virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, - const std::string& theGroupName) = 0; + virtual + const VISU::TMeshMap& + GetMeshMap(); - virtual float GetMeshOnGroupSize(const std::string& theMeshName, - const std::string& theGroupName) = 0; + virtual + float + GetSize() = 0; - virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) = 0; + virtual + TOutput* + GetMeshOnEntity(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName = "") = 0; + + virtual + float + GetMeshOnEntitySize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFamilyName = "") = 0; + + virtual + TOutput* + GetMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName) = 0; + + virtual + float + GetMeshOnGroupSize(const std::string& theMeshName, + const std::string& theGroupName) = 0; + + virtual + TOutput* + GetTimeStampOnMesh(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) = 0; - virtual float GetTimeStampSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) = 0; + virtual + float + GetTimeStampSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) = 0; - virtual float GetFieldOnMeshSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName) = 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; + virtual + float + GetFieldOnMeshSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName) = 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::TTime& aTime); - static std::string GenerateName(const std::string& theName, unsigned int theTimeId); + static + std::string + GenerateName(const VISU::TTime& aTime); + + static + std::string + GenerateName(const std::string& theName, unsigned int theTimeId); }; -extern "C"{ - VISU_Convertor* CreateConvertor(const std::string& theFileName) ; +extern "C" +{ + VISU_Convertor* + CreateConvertor(const std::string& theFileName); }; #endif diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 477abba7..53982f41 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -27,6 +27,10 @@ #include "VISU_Convertor_impl.hxx" #include "VISU_ConvertorUtils.hxx" +#include +#include +#include + #include #include #include @@ -54,17 +58,115 @@ static int MYVTKDEBUG = 0; #ifdef _DEBUG_ static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; +static int MYDEBUGWITHFILES = 1; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -namespace{ +namespace VISU +{ + + TSource::TSource(): + myNbCells(0), + myCellsSize(0), + myIsInitialized(false), + mySource(vtkUnstructuredGrid::New()) + { + mySource->Delete(); + } + + + TMeshImpl::TMeshImpl(): + myPoints(vtkPoints::New()), + myIsInitialized(false), + myNbPoints(0) + { + myPoints->Delete(); + } + + TSubProfileImpl::TSubProfileImpl(): + myStatus(eNone) + { + myGeom = -1; + } + + + bool + TSubProfileLess + ::operator()(const PSubProfile& theLeft, const PSubProfile& theRight) const + { + PSubProfileImpl aLeft(theLeft), aRight(theRight); + if(aLeft->myGeom != aRight->myGeom) + return aLeft->myGeom < aRight->myGeom; + return aLeft->myName < aRight->myName; + } + + + TProfileImpl::TProfileImpl(): + myIsAll(true), + myIsInitialized(false), + myAppendFilter(vtkAppendFilter::New()) + { + myAppendFilter->Delete(); + } + + + pair + TMeshOnEntityImpl + ::GetCellsDims(const string& theFamilyName) const + { + 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 !!!"); + + PFamilyImpl aFamily = aFamilyMapIter->second; + + return make_pair(aFamily->myNbCells,aFamily->myCellsSize); + } + + + int + TValForTimeImpl + ::GetNbGauss(vtkIdType theGeom) const + { + TGaussMap::const_iterator anIter2 = myGaussMap.find(theGeom); + if(anIter2 != myGaussMap.end()){ + PGaussImpl aGauss = anIter2->second; + return aGauss->myNbPts; + } + return myNbGauss; + } + + + vtkIdType + VTKGeom2NbNodes(vtkIdType theGeom) + { + switch(theGeom){ + case VTK_VERTEX: return 1; + case VTK_LINE: return 2; + case VTK_TRIANGLE: return 3; + case VTK_QUAD: return 4; + case VTK_TETRA: return 4; + case VTK_HEXAHEDRON: return 8; + case VTK_WEDGE: return 6; + case VTK_PYRAMID: return 5; + } + return -1; + } +} + +namespace +{ template - std::string dtos(const std::string& fmt, T val){ + std::string + dtos(const std::string& fmt, T val) + { static QString aString; aString.sprintf(fmt.c_str(),val); return aString.latin1(); @@ -153,11 +255,14 @@ namespace{ }; typedef std::auto_ptr TCoordHelperPtr; - void GetPoints(VISU::TVTKSource& theStorage, VISU::PMeshImpl theMesh) + + void + GetPoints(VISU::TVTKSource& theSource, + VISU::PMeshImpl theMesh) { - vtkPoints* aPoints = theMesh->myPoints.GetPointer(); - if(!aPoints){ - aPoints = vtkPoints::New(); + TVTKPoints& aPoints = theMesh->myPoints; + + if(!theMesh->myIsInitialized){ TCoordHelperPtr aCoordHelperPtr; const VISU::TMeshImpl::TPointsCoord& anArray = theMesh->myPointsCoord; { @@ -196,26 +301,30 @@ namespace{ } } - if(MYVTKDEBUG) aPoints->DebugOn(); 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::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); - if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - MSG(MYDEBUG,"GetCellsOnEntity - aSubMeshOnCellType.size() = "<second; + + INITMSG(MYDEBUG,"aSubMeshID.size() = "<SetValue(j++,(unsigned char)aVtkType); } } @@ -274,7 +393,7 @@ namespace{ aConnectivity->InitTraversal(); for(int i=0; aConnectivity->GetNextCell(npts,pts); i++) aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); - theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); if(MYVTKDEBUG) aConnectivity->DebugOn(); aCellLocationsArray->Delete(); aCellTypesArray->Delete(); @@ -282,9 +401,10 @@ namespace{ } - void GetCellsOnGroup(VISU::TVTKSource& theStorage, - VISU::PMeshImpl theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) + void + GetCellsOnGroup(VISU::TVTKSource& theSource, + VISU::PMeshImpl theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { //Calculate dimentions of the group int aNbCells = 0, aCellsSize = 0; @@ -292,8 +412,8 @@ namespace{ for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter; const string& aFamilyName = aFamilyAndEntity.first; - const VISU::TEntity& anEntity = aFamilyAndEntity.second; - const VISU::PMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + VISU::TEntity anEntity = aFamilyAndEntity.second; + VISU::PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; pair aCellsDim = aMeshOnEntity->GetCellsDims(aFamilyName); aNbCells += aCellsDim.first; aCellsSize += aCellsDim.second; @@ -310,22 +430,22 @@ namespace{ const VISU::TEntity& anEntity = aFamilyAndEntity.second; 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::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second; - int aVtkType = aCellsConnIter->first; + const VISU::TGeom2Cell2Connect &aGeom2Cell2Connect = aMeshOnEntity->myGeom2Cell2Connect; + VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin(); + for(; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){ + const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second; + int aVtkType = aGeom2Cell2ConnectIter->first; MSG(MYDEBUG,"GetCellsOnGroup - aVtkType = "<> There is no elements on the family !!!"); - VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); - if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshOnCellType.size() = "<second; + MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshID.size() = "<SetValue(j++,(unsigned char)aVtkType); } } @@ -337,74 +457,116 @@ namespace{ aConnectivity->InitTraversal(); for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++) aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); - theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); aCellLocationsArray->Delete(); aCellTypesArray->Delete(); aConnectivity->Delete(); } - void InitProfile(VISU::TVTKExtractFilter& theFilter, - PMeshOnEntityImpl theMeshOnEntity, - PValForTimeImpl theValForTime) - { - 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()) - theFilter->RemoveCellsWithType(aCellType); - } - } - - - void GetValsOnTimeStamp(vtkFloatArray *theFloatArray, - const vtkIdType& theNumberOfTuples, - const std::string& theFieldName, - VISU::PFieldImpl theField, - VISU::PValForTimeImpl theValForTime) + void + GetTimeStamp3(vtkFloatArray *theFloatArray, + const vtkIdType& theNumberOfTuples, + const std::string& theFieldName, + 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::TValForTimeImpl::TValForCellsWithType& anArray = aValForCellsIter->second; - int iEnd = anArray.size()/theField->myNbComp; - int aVtkType = aValForCellsIter->first; - MSG(MYDEBUG,"GetValsOnTimeStamp - iEnd = "< 0) + for(int iElem = 0; iElem < aNbElem; iElem++){ + float aValue[3] = {0.0, 0.0, 0.0}; + for(int iComp = 0; iComp < 3; iComp++){ + int aFirstId = iElem*aStep + iComp*aNbGauss; + if(aNbGauss > 0){ + for(int iGauss = 0, anId = aFirstId; iGauss < aNbGauss; iGauss++, anId++) + aValue[iComp] += anArray[anId]; + aValue[iComp] /= aNbGauss; + }else + aValue[iComp] = anArray[aFirstId]; + + } + theFloatArray->SetTuple3(k++,aValue[0],aValue[1],aValue[2]); + } + else + EXCEPTION(runtime_error,"GetTimeStamp3 - There is no an algorithm for representation of the field !!!"); + break; } } } - string GenerateFieldName(const VISU::PFieldImpl theField, - const VISU::PValForTimeImpl theValForTime) + std::string + GenerateFieldName(const VISU::PFieldImpl theField, + const VISU::PValForTimeImpl theValForTime) { const VISU::TTime& aTime = theValForTime->myTime; string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + @@ -412,22 +574,24 @@ namespace{ return aFieldName; } - void GetTimeStamp(VISU::TVTKSource& theStorage, - const VISU::PFieldImpl theField, - const VISU::PValForTimeImpl theValForTime) + void + GetTimeStamp2(VISU::TVTKSource& theSource, + const VISU::PFieldImpl theField, + const VISU::PValForTimeImpl theValForTime) { int aNumberOfTuples = theField->myDataSize/theField->myNbComp; string aFieldName = GenerateFieldName(theField,theValForTime); - MSG(MYDEBUG,"GetTimeStamp(TVTKSource) - aFieldName = "<(aFindMeshOnEntity);; PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity); PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); - if(aFamily) - pSource = &(aFamily->myStorage); - else - pSource = &(aMeshOnEntity->myStorage); - VISU::TVTKSource& aSource = *pSource; + + TVTKSource aSource; + bool *anIsInitialized; + if(aFamily){ + aSource = aFamily->mySource; + anIsInitialized = &(aFamily->myIsInitialized); + }else{ + aSource = aMeshOnEntity->mySource; + anIsInitialized = &(aMeshOnEntity->myIsInitialized); + } + //Main part of code try{ - if(aSource.GetPointer() == NULL){ - aSource = TOutput::New(); - aSource->Delete(); + + if(!(*anIsInitialized)){ if(MYVTKDEBUG) aSource->DebugOn(); + LoadMeshOnEntity(aMeshOnEntity,theFamilyName); GetPoints(aSource,aMesh); GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName); + + (*anIsInitialized) = true; + if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1(); @@ -537,28 +674,30 @@ VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName, VISU::WriteToFile(aSource.GetPointer(),aFileName); } } + if(MYVTKDEBUG){ GetMeshOnEntitySize(theMeshName,theEntity,theFamilyName); - vtkUnstructuredGrid* aDataSet = aSource.GetPointer(); - aDataSet->Update(); - MSG(MYVTKDEBUG,"GetMeshOnEntity - GetPoints() = "<GetPoints()->GetActualMemorySize()*1000)); - MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCells() = "<GetCells()->GetActualMemorySize()*1000)); - MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellTypesArray() = "<GetCellTypesArray()->GetActualMemorySize()*1000)); - MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLocationsArray() = "<GetCellLocationsArray()->GetActualMemorySize()*1000)); - aDataSet->BuildLinks(); - MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLinks() = "<GetCellLinks()->GetActualMemorySize()*1000)); - MSG(MYVTKDEBUG,"GetMeshOnEntity - GetActualMemorySize() = "<GetActualMemorySize()*1000)); + aSource->Update(); + BEGMSG(MYVTKDEBUG,"GetPoints() = "<GetPoints()->GetActualMemorySize()*1000)<(aFindMeshOnGroup); PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet; - VISU::TVTKSource& aSource = aGroup->myStorage; //Main part of code + TVTKSource& aSource = aGroup->mySource; try{ - if(aSource.GetPointer() == NULL){ - aSource = TOutput::New(); - aSource->Delete(); + if(!aGroup->myIsInitialized){ LoadMeshOnGroup(aMesh,aFamilyAndEntitySet); GetPoints(aSource,aMesh); GetCellsOnGroup(aSource,aMesh,aFamilyAndEntitySet); + + aGroup->myIsInitialized = true; + if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); @@ -584,22 +724,144 @@ VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName, VISU::WriteToFile(aSource.GetPointer(),aFileName); } } + }catch(...){ - aSource = vtkSmartPointerBase(); throw; } + return aSource.GetPointer(); } -VISU_Convertor::TOutput* -VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName, - const VISU::TEntity& theEntity, - const string& theFieldName, - int theStampsNum) + +void +GetCells(VISU::TVTKSource& theSource, + PSubProfileImpl theSubProfile, + PMeshOnEntityImpl theMeshOnEntity) { - MSG(MYDEBUG,"GetTimeStampOnMesh - theMeshName = '"<> There is no elements for the GEOM("<second; + + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate(aCellsSize,0); + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->SetNumberOfTuples(aNbCells); + + if(theSubProfile->myStatus == eAddAll){ + VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin(); + for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ + const TConnect& anArray = aCell2Connect[anId]; + PrintCells(aConnId,aConnectivity,anArray); + aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); + aConnId += aNbNodes; + anId++; + } + }else{ + VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin(); + for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){ + vtkIdType aSubId = *anIter; + const TConnect& anArray = aCell2Connect[aSubId]; + PrintCells(aConnId,aConnectivity,anArray); + aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); + aConnId += aNbNodes; + anId++; + } + } + + vtkIdType *pts = 0, npts = 0; + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(aNbCells); + aConnectivity->InitTraversal(); + for(int i=0; aConnectivity->GetNextCell(npts,pts); i++) + aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); + theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aConnectivity->Delete(); +} + + +void +GetMeshOnSubProfile(PMeshImpl theMesh, + PMeshOnEntityImpl theMeshOnEntity, + PProfileImpl theProfile, + PSubProfileImpl theSubProfile) +{ + INITMSG(MYDEBUG,"GetMeshOnSubProfile"<mySource; + if(theSubProfile->myIsInitialized) + return; + + GetPoints(aSource,theMesh); + BEGMSG(MYDEBUG,"GetNumberOfPoints = "<GetNumberOfPoints()<GetNumberOfCells()<myIsInitialized = true; +} + +void +GetMeshOnProfile(PMeshImpl theMesh, + PMeshOnEntityImpl theMeshOnEntity, + PProfileImpl theProfile) +{ + if(theProfile->myIsInitialized) + return; + + TVTKAppendFilter& anAppendFilter = theProfile->myAppendFilter; + if(theProfile->myIsAll){ + TVTKSource& aSource = theMeshOnEntity->mySource; + anAppendFilter->AddInput(aSource.GetPointer()); + }else{ + const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; + TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); + for(; anIter != aGeom2SubProfile.end(); anIter++){ + PSubProfileImpl aSubProfile = anIter->second; + if(aSubProfile->myStatus == eRemoveAll) + continue; + + GetMeshOnSubProfile(theMesh, + theMeshOnEntity, + theProfile, + aSubProfile); + + TVTKSource& aSource = aSubProfile->mySource; + anAppendFilter->AddInput(aSource.GetPointer()); + } + } + anAppendFilter->Update(); // Fix on VTK + theProfile->myIsInitialized = true; +} + + +VISU_Convertor::TOutput* +VISU_Convertor_impl +::GetTimeStampOnMesh(const string& theMeshName, + const VISU::TEntity& theEntity, + const string& theFieldName, + int theStampsNum) +{ + INITMSG(MYDEBUG,"GetTimeStampOnMesh"<< + "; theMeshName = '"<myMeshName,aVTKMeshOnEntity->myEntity); - - anExtractFilter->SetInput(aVTKMeshOnEntity->myStorage.GetPointer()); - ::InitProfile(anExtractFilter,aMeshOnEntity,aValForTime); - } - if(!anExtractFilter->IsRemoving()){ - aSource = TOutput::New(); - aSource->Delete(); - 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; - aMergeFilter = vtkMergeDataObjectFilter::New(); - aMergeFilter->Delete(); - //aMergeFilter->DebugOn(); - - ::GetTimeStamp(anAttribyteFilter,aMergeFilter,anExtractFilter, - aField,aValForTime); - anOutput = anAttribyteFilter->GetUnstructuredGridOutput(); + try{ + LoadMeshOnEntity(aVTKMeshOnEntity); + }catch(std::exception& exc){ + aVTKMeshOnEntity = aMeshOnEntity; + MSG(MYDEBUG,"Follow exception was occured :\n"<myMeshName,aVTKMeshOnEntity->myEntity); + + PProfileImpl aProfile = aValForTime->myProfile; + GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile); + + TVTKAppendFilter& anAppendFilter = aProfile->myAppendFilter; + + aSource->ShallowCopy(anAppendFilter->GetOutput()); + GetTimeStamp2(aSource,aField,aValForTime); + + aValForTime->myIsInitialized = true; + if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; - VISU::WriteToFile(anOutput,aFileName); + VISU::WriteToFile(aSource.GetPointer(),aFileName); } if(MYVTKDEBUG){ GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum); - vtkUnstructuredGrid *aDataSet = anAttribyteFilter->GetUnstructuredGridOutput(); - aDataSet->Update(); + aSource->Update(); if(theEntity == VISU::NODE_ENTITY) - MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetData() = "<GetPointData()->GetActualMemorySize()*1000)); + BEGMSG(MYVTKDEBUG,"GetPointData() = "<GetPointData()->GetActualMemorySize()*1000)<(aFindMeshOnEntity);; @@ -892,13 +1143,15 @@ VISU_Convertor_impl::FindField(const string& theMeshName, } -float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName) +float +VISU_Convertor_impl +::GetFieldOnMeshSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName) { TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); - PField aField = boost::get<3>(aFindField); + PFieldImpl aField = boost::get<3>(aFindField); float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); float aFieldOnMeshSize = float(aField->myDataSize*sizeof(float)*aField->myValField.size()*ERR_SIZE_CALC); @@ -913,10 +1166,11 @@ float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, VISU_Convertor_impl::TFindTimeStamp -VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) +VISU_Convertor_impl +::FindTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) { TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); PField aField = boost::get<3>(aFindField); @@ -939,15 +1193,17 @@ VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName, } -float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) +float +VISU_Convertor_impl +::GetTimeStampSize(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) { TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum); PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); - PField aField = boost::get<3>(aFindTimeStamp); + PFieldImpl aField = boost::get<3>(aFindTimeStamp); float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC); @@ -963,9 +1219,10 @@ float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, const VISU::PField -VISU_Convertor_impl::GetField(const string& theMeshName, - VISU::TEntity theEntity, - const string& theFieldName) +VISU_Convertor_impl +::GetField(const string& theMeshName, + VISU::TEntity theEntity, + const string& theFieldName) { TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); PField aField = boost::get<3>(aFindField); @@ -974,10 +1231,11 @@ VISU_Convertor_impl::GetField(const string& theMeshName, const VISU::PValForTime -VISU_Convertor_impl::GetTimeStamp(const std::string& theMeshName, - const VISU::TEntity& theEntity, - const std::string& theFieldName, - int theStampsNum) +VISU_Convertor_impl +::GetTimeStamp(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) { TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum); diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 46284cba..5d226983 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -13,97 +13,172 @@ #include -#include -#include -#include -#include -#include "VISU_ExtractUnstructuredGrid.hxx" - -#include -#include - #include #include -namespace VISU{ +class vtkPoints; +class vtkAppendFilter; +class vtkUnstructuredGrid; + +namespace VISU +{ typedef vtkSmartPointer TVTKPoints; typedef vtkSmartPointer TVTKSource; - typedef vtkSmartPointer TVTKMergetFilter; - typedef vtkSmartPointer TVTKExtractFilter; - typedef vtkSmartPointer TVTKAttribyteFilter; + typedef vtkSmartPointer TVTKAppendFilter; typedef float TCoord; - struct TMeshImpl: TMesh{ - TVTKPoints myPoints; + //--------------------------------------------------------------- + struct TSource: virtual TBaseStructure + { + TSource(); + + vtkIdType myNbCells; + vtkIdType myCellsSize; + + TVTKSource mySource; + bool myIsInitialized; + }; + + + struct TIntId: virtual TBaseStructure + { + vtkIdType myId; + + TIntId(): myId(0) + {} + }; + + //--------------------------------------------------------------- + struct TMeshImpl: virtual TMesh + { typedef std::vector TPointsCoord; TPointsCoord myPointsCoord; typedef std::vector TPointsDim; TPointsDim myPointsDim; + + TVTKPoints myPoints; + bool myIsInitialized; + vtkIdType myNbPoints; + + TMeshImpl(); }; - typedef shared_ptr PMeshImpl; - - struct TMeshOnEntityImpl: TMeshOnEntity{ - TVTKSource myStorage; - typedef std::vector TConnect; - typedef std::vector TConnForCellType; - typedef std::map TCellsConn; - TCellsConn myCellsConn; + typedef SharedPtr PMeshImpl; + + + //--------------------------------------------------------------- + typedef std::vector TSubMeshID; + typedef std::map TGeom2SubMeshID; + typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; + + struct TSubProfileImpl: virtual TSubProfile, virtual TSource + { + TSubProfileImpl(); + + vtkIdType myGeom; + std::string myName; + + ESubMeshStatus myStatus; + TSubMeshID mySubMeshID; }; - typedef shared_ptr PMeshOnEntityImpl; + typedef SharedPtr PSubProfileImpl; + - struct TFamilyImpl: TFamily{ - TVTKSource myStorage; + //--------------------------------------------------------------- + typedef std::map TGeom2SubProfile; + struct TProfileImpl: virtual TProfile + { + TProfileImpl(); - typedef std::set TSubMeshOnCellType; - typedef std::map TSubMesh; - TSubMesh mySubMesh; + vtkIdType myNbCells; + vtkIdType myCellsSize; + + bool myIsAll; + bool myIsInitialized; + TVTKAppendFilter myAppendFilter; + TGeom2SubProfile myGeom2SubProfile; }; - typedef shared_ptr PFamilyImpl; + typedef SharedPtr PProfileImpl; + - struct TGroupImpl: TGroup{ - TVTKSource myStorage; + //--------------------------------------------------------------- + typedef std::vector TConnect; + typedef std::vector TCell2Connect; + typedef std::map TGeom2Cell2Connect; + + struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TSource + { + TGeom2Cell2Connect myGeom2Cell2Connect; + + std::pair + GetCellsDims(const std::string& theFamilyName = "") const; + }; + typedef SharedPtr PMeshOnEntityImpl; + + + //--------------------------------------------------------------- + struct TFamilyImpl: virtual TFamily, virtual TSource, virtual TIntId + { + TGeom2SubMeshID myGeom2SubMeshID; + }; + typedef SharedPtr PFamilyImpl; + + + //--------------------------------------------------------------- + struct TGroupImpl: virtual TGroup, virtual TSource + { + }; + typedef SharedPtr PGroupImpl; + + + //--------------------------------------------------------------- + struct TFieldImpl: virtual TField, virtual TIntId + { + vtkIdType myDataSize; + + TFieldImpl(): myDataSize(0) + {} }; - typedef shared_ptr PGroupImpl; - - struct TFieldImpl: TField{ - TVTKExtractFilter myExtractFilter; - ~TFieldImpl() - { - if(myExtractFilter.GetPointer()) - myExtractFilter->UnRegisterAllOutputs(); - } + typedef SharedPtr PFieldImpl; + + + //--------------------------------------------------------------- + struct TGaussImpl: virtual TGauss + { + vtkIdType myNbPts; }; - typedef shared_ptr PFieldImpl; + typedef SharedPtr PGaussImpl; - struct TValForTimeImpl: TValForTime{ - TVTKAttribyteFilter myAttribyteFilter; - TVTKMergetFilter myMergeFilter; - TVTKSource myStorage; - typedef std::vector TValForCellsWithType; - typedef std::map TValForCells; + //--------------------------------------------------------------- + typedef std::vector TValForCellsWithType; + typedef std::map TValForCells; + + struct TValForTimeImpl: virtual TValForTime, virtual TSource, virtual TIntId + { TValForCells myValForCells; - ~TValForTimeImpl() - { - if(myMergeFilter.GetPointer()) - myMergeFilter->UnRegisterAllOutputs(); - if(myAttribyteFilter.GetPointer()) - myAttribyteFilter->UnRegisterAllOutputs(); - } + int + GetNbGauss(vtkIdType theGeom) const; + int myNbGauss; }; - typedef shared_ptr PValForTimeImpl; + typedef SharedPtr PValForTimeImpl; + vtkIdType + VTKGeom2NbNodes(vtkIdType theGeom); } -class VISU_Convertor_impl: public VISU_Convertor{ + +class VISU_Convertor_impl: public VISU_Convertor +{ public: - virtual float GetSize() ; + virtual + float + GetSize(); virtual float @@ -145,9 +220,11 @@ public: public: VISU_Convertor_impl(); - virtual ~VISU_Convertor_impl(); + virtual + ~VISU_Convertor_impl(); - virtual VISU_Convertor* Build() { return this;}; + virtual + VISU_Convertor* Build() { return this;}; virtual TOutput* @@ -203,16 +280,22 @@ protected: int theStampsNum); protected: - virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, - const std::string& theFamilyName = "") = 0; + virtual + int + LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, + const std::string& theFamilyName = "") = 0; - virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0; + virtual + int + LoadMeshOnGroup(VISU::PMeshImpl theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0; - virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, - VISU::PMeshOnEntityImpl theMeshOnEntity, - VISU::PFieldImpl theField, - VISU::PValForTimeImpl 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 bc9e31d1..3dde308d 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -53,12 +53,16 @@ namespace{ using namespace MED; using namespace VISU; - int MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType) + + int + MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType) { return theMEDGeomType % 100; } - int MEDGeomToVTK(MED::EGeometrieElement theMEDGeomType) + + int + MEDGeomToVTK(MED::EGeometrieElement theMEDGeomType) { switch(theMEDGeomType){ case ePOINT1: return VTK_VERTEX; @@ -82,22 +86,9 @@ namespace{ return -1; } - int VTKGeom2NbNodes(int theVTKGeomType) - { - switch(theVTKGeomType){ - case VTK_VERTEX: return 1; - case VTK_LINE: return 2; - case VTK_TRIANGLE: return 3; - case VTK_QUAD: return 4; - case VTK_TETRA: return 4; - case VTK_HEXAHEDRON: return 8; - case VTK_WEDGE: return 6; - case VTK_PYRAMID: return 5; - } - return -1; - } - MED::EGeometrieElement VTKGeomToMED(int theVTKGeomType) + MED::EGeometrieElement + VTKGeomToMED(int theVTKGeomType) { switch(theVTKGeomType){ case VTK_VERTEX: return ePOINT1; @@ -114,7 +105,9 @@ namespace{ return EGeometrieElement(-1); } - TEntity MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity) + + TEntity + MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity) { switch(theMEDEntity){ case eNOEUD: return NODE_ENTITY; @@ -125,7 +118,9 @@ namespace{ return TEntity(-1); } - MED::EEntiteMaillage VTKEntityToMED(TEntity theVTKEntity) + + MED::EEntiteMaillage + VTKEntityToMED(TEntity theVTKEntity) { switch(theVTKEntity){ case NODE_ENTITY: return eNOEUD; @@ -136,353 +131,477 @@ namespace{ return MED::EEntiteMaillage(-1); } + + TProfileKey + GetProfileKey(const MED::TTimeStampVal& theTimeStampVal, + const VISU::TMEDMeshOnEntity& theMeshOnEntity, + const MED::TGeom2Size& theGeom2Size) + { + INITMSG(MYDEBUG,"GetProfileKey"<first; + vtkIdType aVGeom = MEDGeomToVTK(aMGeom); + vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom); + + PMEDSubProfile aSubProfile(new TMEDSubProfile()); + aSubProfile->myGeom = aVGeom; + aSubProfile->myStatus = eAddAll; + aSubProfile->myNbCells = 0; + + MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom); + if(aTimeStampIter == theGeom2Size.end()) + aSubProfile->myStatus = eRemoveAll; + else{ + aSubProfile->myNbCells = aTimeStampIter->second; + MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aMGeom); + if(aProfileIter != aGeom2Profile.end()){ + MED::PProfileInfo aProfileInfo = aProfileIter->second; + aSubProfile->myNbCells = aProfileInfo->myElemNum.size(); + aSubProfile->myName = aProfileInfo->GetName(); + aSubProfile->myStatus = eAddPart; + } + } + aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes; + + INITMSG(MYDEBUG,"aVGeom = "<second; + }else{ + PMEDProfile aProfile(new TMEDProfile()); + TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + + TProfileKey::const_iterator anIter = aProfileKey.begin(); + for(; anIter != aProfileKey.end(); anIter++){ + PMEDSubProfile aSubProfile(*anIter); + + if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll) + aProfile->myIsAll = false; + + vtkIdType aVGeom = aSubProfile->myGeom; + aGeom2SubProfile[aVGeom] = aSubProfile; + } + aProfileMap[aProfileKey] = aProfile; + theValForTime.myProfile = aProfile; + } + } + } extern "C" -VISU_Convertor* CreateConvertor(const string& theFileName) +VISU_Convertor* +CreateConvertor(const string& theFileName) { return new VISU_MedConvertor(theFileName); } -VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) { +VISU_MedConvertor +::VISU_MedConvertor(const string& theFileName) +{ myFileInfo.setFile(QString(theFileName.c_str())); myName = myFileInfo.baseName().latin1(); } -VISU_Convertor* VISU_MedConvertor::Build() { +VISU_Convertor* +VISU_MedConvertor +::Build() +{ PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); + + TKey2Gauss aKey2Gauss = GetKey2Gauss(aMed); + TMKey2Profile aMKey2Profile = GetMKey2Profile(aMed); + TInt aNbMeshes = aMed->GetNbMeshes(); TMeshMap& aMeshMap = myMeshMap; MSG(MYDEBUG,"VISU_MedConvertor::Build()"); INITMSG(MYDEBUG,"GetNbMeshes() = "<GetPMeshInfo(iMesh); - - PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); - - MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); - - TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); - - TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); - - TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup); - - TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); - - // creating TMesh structure and TMeshOnEntityMap - typedef map TFamilyCounterMap; - TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; - - TInt aDim = aMeshInfo->GetDim(); - const string& aMeshName = aMeshInfo->GetName(); - - 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); - 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; + PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh); + + PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); + + MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); + + TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); + + TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); + + TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup); + + TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); + + // creating TMesh structure and TMeshOnEntityMap + typedef map TFamilyCounterMap; + TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap; + + TInt aDim = aMeshInfo->GetDim(); + const string& aMeshName = aMeshInfo->GetName(); + + 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::TGeom2Size& aGeom2Size = anEntityIter->second; - for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){ - TInt aFamId = aNodeInfo->GetFamNum(iElem); - if(aFamId != 0){ - aFamilyNbCellsCounterMap[aFamId] += 1; - aFamilyCellsSizeCounterMap[aFamId] += 2; + TEntity aVEntity = MEDEntityToVTK(aMEntity); + PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); + aMeshOnEntity->myEntity = aVEntity; + aMeshOnEntity->myMeshName = aMeshName; + aMeshOnEntity->myGeom2Size = aGeom2Size; + + INITMSG(MYDEBUG,"aMEntity = "<myNbCells = 0; - aMeshOnEntity->myCellsSize = 0; - for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ - const EGeometrieElement& aGeom = anTGeomIter->first; - - switch(aGeom){ - case ePOLYGONE: - { - PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom); + + INITMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<< + endl);; + + }else{ + MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); + aMeshOnEntity->myNbCells = 0; + aMeshOnEntity->myCellsSize = 0; + for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ + const EGeometrieElement& aMGeom = aGeom2SizeIter->first; + + switch(aMGeom){ + case ePOLYGONE: { + PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aPolygoneInfo->GetNbElem(); TElemNum aConn = aPolygoneInfo->GetConnectivite(); TElemNum aIndex = aPolygoneInfo->GetIndex(); TInt aNbIndex = aIndex.size(); TInt aNbConn = aConn.size(); - - aMeshOnEntity->myNbCells += aNbElem; - for (int ii = 0; iimyNbCells += aNbElem; + + for (int ii = 0; iiGetNbConn(ii); - aMeshOnEntity->myCellsSize += aNbConnii; - } - INITMSG(MYDEBUG,"aGeom = "<myCellsSize += aNbConnii; + } - for(TInt iElem = 0; iElem < aNbElem; iElem++){ - TInt aFamId = aPolygoneInfo->GetFamNum(iElem); - if(aFamId != 0){ - aFamilyNbCellsCounterMap[aFamId] += 1; - ADDMSG(MYDEBUG,"aFamId="<GetNbConn(iElem) + 1; - } - } + INITMSG(MYDEBUG,"aMGeom = "<myCellsSize += aNbConnii; + } + INITMSG(MYDEBUG,"aMGeom = "<GetNbConn(iElem) + 1; - } - } + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + TInt aFamId = aPolyedreInfo->GetFamNum(iElem); + if(aFamId != 0){ + aFamilyNbCellsCounterMap[aFamId] += 1; + aFamilyCellsSizeCounterMap[aFamId] += aPolyedreInfo->GetNbConn(iElem) + 1; + } + } ADDMSG(MYDEBUG,endl); break; } - default: - { - int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom)); - PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); + default: { + vtkIdType aVGeom = MEDGeomToVTK(aMGeom); + int aVNbNodes = VTKGeom2NbNodes(aVGeom); + PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aCellInfo->GetNbElem(); aMeshOnEntity->myNbCells += aNbElem; aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1); - INITMSG(MYDEBUG,"aGeom = "<first; - const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; - - TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; - VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - if(aFamilyGroup.empty()) - continue; - - INITMSG(MYDEBUG,"aMEntity = "<GetId() == 0) - continue; - - const std::string& aFamilyName = aFamilyInfo->GetName(); - PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + TFamilyByEntity::const_iterator aFamilyByEntityIter = aFamilyByEntity.begin(); + BEGMSG(MYDEBUG,"TFamilyByEntity:\n"); + for(; aFamilyByEntityIter != aFamilyByEntity.end(); aFamilyByEntityIter++){ + const EEntiteMaillage& aMEntity = aFamilyByEntityIter->first; + const TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second; - aFamily->myId = aFamilyInfo->GetId(); - aFamily->myName = aFamilyInfo->GetName(); - aFamily->myEntity = aVEntity; - aFamily->myNbCells = aFamilyNbCellsCounterMap[aFamily->myId]; - aFamily->myCellsSize = aFamilyCellsSizeCounterMap[aFamily->myId]; + TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + + if(aFamilyGroup.empty()) + continue; - INITMSG(MYDEBUG,"aFamilyName = '"<myName<< - "'; myId = "<myId<<"; "<< - "; aNbAttr = "<GetNbAttr()<< - "; aNbGroup = "<GetNbGroup()<< - "; myEntity = "<myEntity<< - "; myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<<"\n"); - - VISU::TBindGroups& aBindGroups = aFamily->myGroups; - const TInt aNbGroup = aFamilyInfo->GetNbGroup(); - for(TInt i = 0; i < aNbGroup; i++){ - const string& aGroupName = aFamilyInfo->GetGroupName(i); - aBindGroups.insert(aGroupName); - INITMSG(MYDEBUG,"aGroupName = '"<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]; + + INITMSG(MYDEBUG,"aFamilyName = '"<myName<< + "'; myId = "<myId<<"; "<< + "; aNbAttr = "<GetNbAttr()<< + "; aNbGroup = "<GetNbGroup()<< + "; myEntity = "<myEntity<< + "; myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n"); + + VISU::TBindGroups& aBindGroups = aFamily->myGroups; + const TInt aNbGroup = aFamilyInfo->GetNbGroup(); + for(TInt i = 0; i < aNbGroup; i++){ + const string& aGroupName = aFamilyInfo->GetGroupName(i); + aBindGroups.insert(aGroupName); + INITMSG(MYDEBUG,"aGroupName = '"<myGroupMap; - TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); - for(;aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){ - const string& aGroupName = aGroupInfoIter->first; - const TFamilyGroup& aFamilyGroup = aGroupInfoIter->second; - PMEDGroup aGroup(new TMEDGroup()); - aGroup->myName = aGroupName; - aGroup->myMeshName = aMesh->myName; - - INITMSG(MYDEBUG,"aGroup->myName = '"<myName<<"'\n"); - - TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin(); - 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; - TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); - 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& aName = aFamilyMapIter->first; - aFamily = aFamilyMapIter->second; - if(aName == aFamilyName){ - aVEntity = aFamily->myEntity; - goto exit_lable; + + BEGMSG(MYDEBUG,"VISU::TGroup:\n"); + + 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; + PMEDGroup aGroup(new TMEDGroup()); + aGroup->myName = aGroupName; + aGroup->myMeshName = aMesh->myName; + + INITMSG(MYDEBUG,"aGroup->myName = '"<myName<<"'\n"); + + TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin(); + for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){ + const PFamilyInfo& aFamilyInfo = *aFamilyIter; + const string& aFamilyName = aFamilyInfo->GetName(); + + TEntity aVEntity = TEntity(-1); + PMEDFamily aFamily; + + // Find aVisuEntity + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); + 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& aName = aFamilyMapIter->first; + aFamily = aFamilyMapIter->second; + if(aName == aFamilyName){ + aVEntity = aFamily->myEntity; + goto exit_lable; + } } } + exit_lable: + if(aFamily && aVEntity >= 0){ + aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity)); + INITMSG(MYDEBUG,"aFamilyName = '"<myName<<"'; aVEntity = "<myNbCells += aFamily->myNbCells; + aGroup->myCellsSize += aFamily->myCellsSize; + } } - exit_lable: - if(aFamily && aVEntity >= 0){ - aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity)); - INITMSG(MYDEBUG,"aFamilyName = '"<myName<<"'; aVEntity = "<myNbCells += aFamily->myNbCells; - aGroup->myCellsSize += aFamily->myCellsSize; + if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){ + BEGMSG(MYDEBUG,"myNbCells = "<myNbCells<< + "; myCellsSize = "<myCellsSize<<"\n\n"); + aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); } } - if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){ - BEGMSG(MYDEBUG,"myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<<"\n\n"); - aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); - } - } - - TInt aNbFields = aMed->GetNbFields(); - BEGMSG(MYDEBUG,"VISU::TField: NbFields="<GetPFieldInfo(aMeshInfo,iField); - TInt aNbComp = aFieldInfo->GetNbComp(); - const string& aFieldName = aFieldInfo->GetName(); - - MED::TGeom aTGeom; - EEntiteMaillage aMEntity; - TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom); - if (aNbTimeStamps<1) - continue; - TEntity aVEntity = MEDEntityToVTK(aMEntity); - VISU::PMeshOnEntity aMeshOnEntity = aMesh->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); - } - - for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ - PTimeStampInfo aTimeStamp = aMed->GetPTimeStampInfo(aFieldInfo, - aMEntity, - aTGeom, - iTimeStamp); - TFloat aDt = aTimeStamp->GetDt(); - const string& anUnitDt = aTimeStamp->GetUnitDt(); - PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp); - 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 = "<GetNbFields(); + BEGMSG(MYDEBUG,"TField: aNbFields = "<GetPFieldInfo(aMeshInfo,iField); + TInt aNbComp = aFieldInfo->GetNbComp(); + const string& aFieldName = aFieldInfo->GetName(); + + MED::TGeom2Size aGeom2Size; + EEntiteMaillage aMEntity; + TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo, + aEntityInfo, + aMEntity, + aGeom2Size); + if(aNbTimeStamps < 1) + continue; + + TEntity aVEntity = MEDEntityToVTK(aMEntity); + PMEDMeshOnEntity aMeshOnEntity = aMesh->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); + } + + for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ + PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo, + aMEntity, + aGeom2Size, + iTimeStamp); + TFloat aDt = aTimeStampInfo->GetDt(); + const string& anUnitDt = aTimeStampInfo->GetUnitDt(); + PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo, + aMKey2Profile, + aKey2Gauss); + 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->myNbGauss = aTimeStampInfo->GetNbGauss(); + aValForTime->myTime = VISU::TTime(aDt,anUnitDt); + INITMSG(MYDEBUG,"aDt = "<myGaussMap; + const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss(); + TGeom2Gauss::const_iterator anIter = aGeom2Gauss.begin(); + for(; anIter != aGeom2Gauss.end(); anIter++){ + EGeometrieElement aMGeom = anIter->first; + PGaussInfo aGaussInfo = anIter->second; + PMEDGauss aMEDGauss(new TMEDGauss()); + aMEDGauss->myGaussInfo = aGaussInfo; + aMEDGauss->myNbPts = aGaussInfo->GetNbGauss(); + aGaussMap[MEDGeomToVTK(aMGeom)] = aMEDGauss; + } + } } + } catch(std::exception& exc){ + MSG(MYDEBUG,"Follow exception was occured in:\n"<myMeshName; @@ -498,8 +617,11 @@ int VISU_MedConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, return (isPointsUpdated || isCellsOnEntityUpdated); } -int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) + +int +VISU_MedConvertor +::LoadMeshOnGroup(VISU::PMeshImpl theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) { PWrapper aMed = CrWrapper(myFileInfo.absFilePath().latin1()); int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; @@ -520,10 +642,12 @@ int VISU_MedConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, return (isPointsUpdated || isCellsOnEntityUpdated); } -int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, - VISU::PMeshOnEntityImpl theMeshOnEntity, - VISU::PFieldImpl theField, - VISU::PValForTimeImpl 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); @@ -535,9 +659,10 @@ int VISU_MedConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, int -VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - const string& theFamilyName) +VISU_MedConvertor +::LoadPoints(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + const string& theFamilyName) { try{ //Check on existing family @@ -550,7 +675,7 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, if(isPointsLoaded) if(!aFamily) return 0; - else if(!aFamily->mySubMesh.empty()) + else if(!aFamily->myGeom2SubMeshID.empty()) return 0; INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<myDim; iDim < theMesh->myDim; iDim++, iElem2Dim++) aPointsCoord[iElem2Dim] = aNodeInfo->GetNodeCoord(iElem,iDim); - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; + VISU::TCell2Connect& aConnForCellType = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; aConnForCellType.resize(aNbElem); for (int iElem = 0; iElem < aNbElem; iElem++) - aConnForCellType[iElem] = VISU::TMeshOnEntityImpl::TConnect(1,iElem); + aConnForCellType[iElem] = VISU::TConnect(1,iElem); } if(aFamily && aNbElem > 0){ - VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; + VISU::TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX]; for (int iElem = 0; iElem < aNbElem; iElem++) if(aNodeInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshOnCellType.insert(iElem); + aSubMeshID.push_back(iElem); } return 1; - }catch(std::runtime_error& exc){ + }catch(std::exception& exc){ theMesh->myPointsCoord.clear(); throw; }catch(...){ @@ -595,20 +720,21 @@ VISU_MedConvertor::LoadPoints(const MED::PWrapper& theMed, int -VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - VISU::PMEDMeshOnEntity theMeshOnEntity, - const string& theFamilyName) +VISU_MedConvertor +::LoadCellsOnEntity(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, + const string& theFamilyName) { try{ //Check on existing family PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); + bool isCellsLoaded = !theMeshOnEntity->myGeom2Cell2Connect.empty(); if(isCellsLoaded) if(!aFamily) return 0; - else if(!aFamily->mySubMesh.empty()) + else if(!aFamily->myGeom2SubMeshID.empty()) return 0; INITMSG(MYDEBUG,"LoadCellsOnEntity - theFamilyName = '"<myGeom; - MED::TGeom::const_iterator anTGeomIter = aTGeom.begin(); - TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn; - - for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ - const EGeometrieElement& aGeom = anTGeomIter->first; - int aVTKGeomType = MEDGeomToVTK(aGeom); - ADDMSG(MYDEBUG,"LoadCellsOnEntity aGeom="<GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom); - TInt aNbElem = aPolygoneInfo->GetNbElem(); + const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; + MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); + TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; + + for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ + const EGeometrieElement& aMGeom = aGeom2SizeIter->first; + int aVGeom = MEDGeomToVTK(aMGeom); + INITMSG(MYDEBUG,"aMGeom = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); + TInt aNbElem = aPolygoneInfo->GetNbElem(); + + if(!isCellsLoaded){ + TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; + aCell2Connect.resize(aNbElem); + + const TElemNum& aIndex = aPolygoneInfo->GetIndex(); + const TElemNum& aConnect = aPolygoneInfo->GetConnectivite(); + + for (int iElem = 0; iElem < aNbElem; iElem++) { + TConnect& anArray = aCell2Connect[iElem]; + int aNbConn = aPolygoneInfo->GetNbConn(iElem); + anArray.resize(aNbConn); + for(int i = 0; i < aNbConn; i++) + anArray[i] = aConnect[aIndex[iElem]-1+i]-1; + } + } + if(aFamily){ + TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshID.push_back(iElem); + } + break; + } + case ePOLYEDRE: { + PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); + TInt aNbElem = aPolyedreInfo->GetNbElem(); + + if(!isCellsLoaded){ + TCell2Connect& aCell2Connect = aGeom2Cell2Connect[aVGeom]; + aCell2Connect.resize(aNbElem); + + const TElemNum& aConnect = aPolyedreInfo->GetConnectivite(); + const TElemNum& aFaces = aPolyedreInfo->GetFaces(); + const TElemNum& aIndex = aPolyedreInfo->GetIndex(); - if(!isCellsLoaded){ - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType]; - aConnForPolygoneType.resize(aNbElem); + for(int iElem = 0; iElem < aNbElem; iElem++){ + typedef set TConnectSet; + TConnectSet aConnectSet; + TConnect& anArray = aCell2Connect[iElem]; - int aMNbNodes = aPolygoneInfo->GetConnDim(); + int aInd1 = aIndex[iElem]-1; + int aInd2 = aIndex[iElem+1]-2; - vector aConnect(aMNbNodes); - vector aIndex = aPolygoneInfo->GetIndex(); - - for (int iElem = 0; iElem < aNbElem; iElem++) { - VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolygoneType[iElem]; - int aNbConn = aPolygoneInfo->GetNbConn(iElem); - - anArray.resize(aNbConn); - - aConnect = aPolygoneInfo->GetConnectivite(); - - for (int i=0;imySubMesh[aVTKGeomType]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshOnCellType.insert(iElem); - } - break; - } - case ePOLYEDRE: - { - PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aGeom); - TInt aNbElem = aPolyedreInfo->GetNbElem(); - - int aMNbNodes = aPolyedreInfo->GetNbConn(); - vector aConnect(aMNbNodes); - aConnect = aPolyedreInfo->GetConnectivite(); - - if(!isCellsLoaded){ - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolyedreType = aCellsConn[aVTKGeomType]; - aConnForPolyedreType.resize(aNbElem); - vector aFacesIndex = aPolyedreInfo->GetFacesIndex(); - vector aIndex = aPolyedreInfo->GetIndex(); - - for (int iElem = 0; iElem < aNbElem; iElem++) { - set aArrayNew; - VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolyedreType[iElem]; - - int aInd1 = aIndex[iElem]-1; - int aInd2 = aIndex[iElem+1]-2; - - for (int i=aInd1;i<=aInd2;i++){ - for (int j=aFacesIndex[i]-1;j::iterator aIter = aArrayNew.begin(); - for (int i=0; aIter!=aArrayNew.end();aIter++, i++) - anArray[i] = (*aIter)-1; - + int aNbConn = aConnectSet.size(); + anArray.resize(aNbConn); + TConnectSet::iterator aIter = aConnectSet.begin(); + for(int i = 0; aIter != aConnectSet.end(); aIter++, i++){ + TInt anId = *aIter; + anArray[i] = anId-1; } } - if(aFamily){ - VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aPolyedreInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshOnCellType.insert(iElem); - } - break; } - default: - { - int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType); + if(aFamily){ + TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aPolyedreInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshID.push_back(iElem); + } + break; + } + default: { + int aVNbNodes = VTKGeom2NbNodes(aVGeom); + + PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); + TInt aNbElem = aCellInfo->GetNbElem(); + + if(!isCellsLoaded){ + VISU::TCell2Connect& aConnForCellType = aGeom2Cell2Connect[aVGeom]; + aConnForCellType.resize(aNbElem); - PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom); - TInt aNbElem = aCellInfo->GetNbElem(); + int aMNbNodes = MEDGeom2NbNodes(aMGeom); + vector aConnect(aMNbNodes); - if(!isCellsLoaded){ - VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType]; - aConnForCellType.resize(aNbElem); + for (int iElem = 0; iElem < aNbElem; iElem++) { + VISU::TConnect& anArray = aConnForCellType[iElem]; + anArray.resize(aVNbNodes); - int aMNbNodes = MEDGeom2NbNodes(aGeom); - vector aConnect(aMNbNodes); - - for (int iElem = 0; iElem < aNbElem; iElem++) { - VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem]; - anArray.resize(aVNbNodes); - - if(anIsNodeNum){ - for(int i = 0; i < aMNbNodes; i++){ - aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1]; - } - }else{ - for(int i = 0; i < aMNbNodes; i++){ - aConnect[i] = aCellInfo->GetConn(iElem,i)-1; - } + if(anIsNodeNum){ + for(int i = 0; i < aMNbNodes; i++){ + aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1]; } - - switch(aGeom){ - case eTETRA4: - case eTETRA10: - anArray[0] = aConnect[0]; - anArray[1] = aConnect[1]; - anArray[2] = aConnect[3]; - anArray[3] = aConnect[2]; - break; - case ePYRA5: - case ePYRA13: - anArray[0] = aConnect[0]; - anArray[1] = aConnect[3]; - anArray[2] = aConnect[2]; - anArray[3] = aConnect[1]; - anArray[4] = aConnect[4]; - break; - default: - for(int iNode = 0; iNode < aVNbNodes; iNode++) - anArray[iNode] = aConnect[iNode]; + }else{ + for(int i = 0; i < aMNbNodes; i++){ + aConnect[i] = aCellInfo->GetConn(iElem,i)-1; } + } + + switch(aMGeom){ + case eTETRA4: + case eTETRA10: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[1]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[2]; + break; + case ePYRA5: + case ePYRA13: + anArray[0] = aConnect[0]; + anArray[1] = aConnect[3]; + anArray[2] = aConnect[2]; + anArray[3] = aConnect[1]; + anArray[4] = aConnect[4]; + break; + default: for(int iNode = 0; iNode < aVNbNodes; iNode++) - if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode]) - EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<mySubMesh[aVTKGeomType]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aCellInfo->GetFamNum(iElem) == aFamily->myId) - aSubMeshOnCellType.insert(iElem); - } + } + //Filling aFamily Geom2SubMeshID + if(aFamily){ + VISU::TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; + for(int iElem = 0; iElem < aNbElem; iElem++) + if(aCellInfo->GetFamNum(iElem) == aFamily->myId) + aSubMeshID.push_back(iElem); } } + } } return 1; - }catch(std::runtime_error& exc){ - theMeshOnEntity->myCellsConn.clear(); + }catch(std::exception& exc){ + theMeshOnEntity->myGeom2Cell2Connect.clear(); throw; }catch(...){ - theMeshOnEntity->myCellsConn.clear(); + theMeshOnEntity->myGeom2Cell2Connect.clear(); EXCEPTION(runtime_error,"Unknown exception !!!"); } return 0; } +void +LoadProfile(MED::TTimeStampVal& theTimeStampVal, + VISU::TMEDValForTime& theValForTime, + VISU::TMEDMeshOnEntity& theMeshOnEntity) +{ + INITMSG(MYDEBUG,"LoadProfile"<myIsInitialized) + return; + + const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + const TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile(); + TGeom2Profile::const_iterator anIter = aGeom2Profile.begin(); + for(; anIter != aGeom2Profile.end(); anIter++){ + MED::PProfileInfo aProfileInfo = anIter->second; + MED::EGeometrieElement aMGeom = anIter->first; + vtkIdType aVGeom = MEDGeomToVTK(aMGeom); + + TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aVGeom); + if(anIter2 != aGeom2SubProfile.end()){ + PMEDSubProfile aSubProfile = anIter2->second; + aSubProfile->mySubMeshID = aProfileInfo->myElemNum; + + INITMSG(MYDEBUG,"aVGeom = "<myValForCells.empty()) return 0; + if(!theValForTime->myValForCells.empty()) + return 0; //Main part of code const std::string& aMeshName = theMeshOnEntity->myMeshName; const PMeshInfo& aMeshInfo = theMesh->myMeshInfo; - PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo,theField->myId); + PFieldInfo aFieldInfo = theMed->GetPFieldInfo(aMeshInfo, + theField->myId); - MED::TGeom aTGeom; + MED::TGeom2Size aGeom2Size; EEntiteMaillage aMEntity; - theMed->GetNbTimeStamps(aFieldInfo,theMesh->myEntityInfo,aMEntity,aTGeom); + theMed->GetNbTimeStamps(aFieldInfo, + theMesh->myEntityInfo, + aMEntity, + aGeom2Size); + + PTimeStampInfo aTimeStampInfo = + theMed->GetPTimeStampInfo(aFieldInfo, + aMEntity, + aGeom2Size, + theValForTime->myId); + + TKey2Gauss aKey2Gauss = GetKey2Gauss(*theMed); + TMKey2Profile aMKey2Profile = GetMKey2Profile(*theMed); + + PTimeStampVal aTimeStampVal = + theMed->GetPTimeStampVal(aTimeStampInfo, + aMKey2Profile, + aKey2Gauss); + + LoadProfile(aTimeStampVal, + theValForTime, + theMeshOnEntity); + + PMEDProfile aProfile = theValForTime->myProfile; + TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; - PTimeStampInfo aTimeStampInfo = theMed->GetPTimeStampInfo(aFieldInfo, - aMEntity, - aTGeom, - theValForTime->myId); - TInt aNbGauss = aTimeStampInfo->GetNbGauss(); + const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss(); TInt aNbComp = theField->myNbComp; - PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo); - bool anIsTrimmed = theField->myIsTrimmed; - INITMSG(MYDEBUG,"LoadField - aMeshName = '"< + namespace VISU{ - struct TMEDMesh: TMeshImpl{ + struct TMEDMesh: TMeshImpl + { MED::PMeshInfo myMeshInfo; MED::TEntityInfo myEntityInfo; }; - typedef shared_ptr PMEDMesh; + typedef SharedPtr PMEDMesh; - struct TMEDMeshOnEntity: TMeshOnEntityImpl{ - MED::TGeom myGeom; - }; - typedef shared_ptr PMEDMeshOnEntity; + struct TMEDSubProfile: TSubProfileImpl + {}; + typedef SharedPtr PMEDSubProfile; - struct TMEDFamily: TFamilyImpl{ + struct TMEDProfile: TProfileImpl + {}; + typedef SharedPtr PMEDProfile; + + struct TMEDMeshOnEntity: TMeshOnEntityImpl + { + MED::TGeom2Size myGeom2Size; }; - typedef shared_ptr PMEDFamily; + typedef SharedPtr PMEDMeshOnEntity; + + struct TMEDFamily: TFamilyImpl + {}; + typedef SharedPtr PMEDFamily; - struct TMEDGroup: TGroupImpl{ - }; - typedef shared_ptr PMEDGroup; + struct TMEDGroup: TGroupImpl + {}; + typedef SharedPtr PMEDGroup; - struct TMEDField: TFieldImpl{ - }; - typedef shared_ptr PMEDField; + struct TMEDField: TFieldImpl + {}; + typedef SharedPtr PMEDField; - struct TMEDValForTime: TValForTimeImpl{ + struct TMEDGauss: TGaussImpl + { + MED::PGaussInfo myGaussInfo; }; - typedef shared_ptr PMEDValForTime; + typedef SharedPtr PMEDGauss; + + struct TMEDValForTime: TValForTimeImpl + {}; + typedef SharedPtr PMEDValForTime; } diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 56c39876..57b5df8b 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -164,21 +164,6 @@ namespace{ return -1; } - int VTKGeom2NbNodes(int theVTKGeomType) - { - switch(theVTKGeomType){ - case VTK_VERTEX: return 1; - case VTK_LINE: return 2; - case VTK_TRIANGLE: return 3; - case VTK_QUAD: return 4; - case VTK_TETRA: return 4; - case VTK_HEXAHEDRON: return 8; - case VTK_WEDGE: return 6; - case VTK_PYRAMID: return 5; - } - return -1; - } - medGeometryElement VTKGeomToMED(int theVTKGeomType) { switch(theVTKGeomType){ @@ -653,7 +638,7 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){ SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily]; CORBA::String_var aFamilyName = aMEDFamily->getName(); - PFamily aFamily = FindFamily(aMesh,aFamilyName.in()); + PCFamily aFamily = FindFamily(aMesh,aFamilyName.in()); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<myEntity); @@ -911,7 +896,7 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, if(isPointsLoaded) if(!aFamily) return 0; - else if(!aFamily->mySubMesh.empty()) + else if(!aFamily->myGeom2SubMeshID.empty()) return 0; if(MYDEBUG) @@ -935,17 +920,17 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); - TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX]; - aConnForCellType.resize(iNumElemEnd); + TCell2Connect& aCell2Connect = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; + aCell2Connect.resize(iNumElemEnd); for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aConnForCellType[iNumElem] = TMeshOnEntityImpl::TConnect(1,iNumElem); + aCell2Connect[iNumElem] = TConnect(1,iNumElem); } if(aFamily){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); + if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID"); SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); - TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX]; + TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX]; if(!anIsOnAllElements){ SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); @@ -959,11 +944,11 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp); throw std::runtime_error(aString.latin1()); } - aSubMeshOnCellType.insert(tmp); + aSubMeshID.push_back(tmp); } }else{ for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){ - aSubMeshOnCellType.insert(iNumElem); + aSubMeshID.push_back(iNumElem); } } } @@ -979,11 +964,11 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, //Check on existing family PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName); //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty(); + bool isCellsLoaded = !theMeshOnEntity->myGeom2Cell2Connect.empty(); if(isCellsLoaded) if(!aFamily) return 0; - else if(!aFamily->mySubMesh.empty()) + else if(!aFamily->myGeom2SubMeshID.empty()) return 0; SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport; @@ -1009,15 +994,15 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, if (iNumElemEnd > 0) { SALOME_MED::long_array_var conn = aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMEntity,aGeom); - TMeshOnEntityImpl::TConnForCellType& aConnForCellType = theMeshOnEntity->myCellsConn[aVGeom]; - //APO - aConnForCellType.resize(iNumElemEnd); + TCell2Connect& aCell2Connect = theMeshOnEntity->myGeom2Cell2Connect[aVGeom]; + //APO - aCell2Connect.resize(iNumElemEnd); vector aConnect(aMNbNodes); int aNbConnForElem = conn->length()/iNumElemEnd; if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aGeom = "<> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]); throw std::runtime_error(aString.latin1()); } - aConnForCellType.push_back(anArray); + aCell2Connect.push_back(anArray); } //Workaround for MED Component data structure - int aSize = aConnForCellType.size(); + int aSize = aCell2Connect.size(); theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize); aCounter += aSize; } } } - //Filling aFamily SubMesh + //Filling aFamily Geom2SubMeshID if(aFamily){ SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); @@ -1068,8 +1053,8 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom]; SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom); int aVGeom = MEDGeomToVTK(aGeom); - TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; - int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size(); + TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; + int iNumElemEndTmp = theMeshOnEntity->myGeom2Cell2Connect[aVGeom].size(); int iNumElemEnd = aCellNumForType->length(); int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first; if(MYDEBUG) @@ -1083,19 +1068,19 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp); throw std::runtime_error(aString.latin1()); } - aSubMeshOnCellType.insert(tmp); + aSubMeshID.push_back(tmp); } } }else{ - const TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn; - TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin(); + const TGeom2Cell2Connect& aCellsConn = theMeshOnEntity->myGeom2Cell2Connect; + TGeom2Cell2Connect::const_iterator aCellsConnIter = aCellsConn.begin(); for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){ int aVGeom = aCellsConnIter->first; - const TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConnIter->second; - TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; - int iNumElemEnd = aConnForCellType.size(); + const TCell2Connect& aCell2Connect = aCellsConnIter->second; + TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[aVGeom]; + int iNumElemEnd = aCell2Connect.size(); for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aSubMeshOnCellType.insert(iNumElem); + aSubMeshID.push_back(iNumElem); } } } @@ -1111,7 +1096,7 @@ ImportField(TArray& theArray, VISU::PCMeshOnEntity theMeshOnEntity) { if(theField->myEntity == NODE_ENTITY){ - TValForTimeImpl::TValForCellsWithType& aValForCellsWithType = + TValForCellsWithType& aValForCellsWithType = theValForTime->myValForCells[VTK_VERTEX]; int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp; if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<myValForCells[aVGeom]; + TValForCellsWithType& aValForCellsWithType = theValForTime->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++) diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 6b7c9410..83028671 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -40,7 +40,7 @@ namespace VISU{ struct TCMesh: TMeshImpl{ SALOME_MED::MESH_var myMesh; }; - typedef shared_ptr PCMesh; + typedef SharedPtr PCMesh; struct TCMeshOnEntity: TMeshOnEntityImpl{ SALOME_MED::SUPPORT_var mySupport; @@ -48,26 +48,26 @@ namespace VISU{ typedef std::map TCellsFirstIndex; TCellsFirstIndex myCellsFirstIndex; }; - typedef shared_ptr PCMeshOnEntity; + typedef SharedPtr PCMeshOnEntity; struct TCFamily: TFamilyImpl{ SALOME_MED::FAMILY_var myFamily; }; - typedef shared_ptr PCFamily; + typedef SharedPtr PCFamily; struct TCGroup: TGroupImpl{ SALOME_MED::GROUP_var myGroup; }; - typedef shared_ptr PCGroup; + typedef SharedPtr PCGroup; struct TCField: TFieldImpl{ }; - typedef shared_ptr PCField; + typedef SharedPtr PCField; struct TCValForTime: TValForTimeImpl{ SALOME_MED::FIELD_var myField; }; - typedef shared_ptr PCValForTime; + typedef SharedPtr PCValForTime; }