From 9c8595ecb21bcedf934ba5464d110f2141f289a5 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 27 Jul 2005 09:55:49 +0000 Subject: [PATCH] To improve TPoints structure, to introduce TVTKIsDone and TMEDIsDone and to use new way of Gauss Points description - TGaussMesh --- src/CONVERTOR/VISU_Convertor.hxx | 2 - src/CONVERTOR/VISU_Convertor_impl.cxx | 61 ++++++++--------- src/CONVERTOR/VISU_Convertor_impl.hxx | 41 +++++++---- src/CONVERTOR/VISU_MedConvertor.cxx | 83 ++++++++++++----------- src/CONVERTOR/VISU_MedConvertor.hxx | 98 +++++++++++++++++---------- 5 files changed, 162 insertions(+), 123 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 39c5b5e9..922d12b3 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -226,7 +226,6 @@ namespace VISU{ //--------------------------------------------------------------- typedef std::pair TTime; - typedef std::map TGaussMap; struct TValForTime: virtual TIntId { @@ -237,7 +236,6 @@ namespace VISU{ PProfile myProfile; PGaussMesh myGaussMesh; - TGaussMap myGaussMap; }; PFamily diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 341c70f3..aab17891 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -57,7 +57,7 @@ static float ERR_SIZE_CALC = 1.00; static int MYVTKDEBUG = 0; #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -71,7 +71,6 @@ namespace VISU TSource::TSource(): myNbCells(0), myCellsSize(0), - myIsInitialized(false), mySource(vtkUnstructuredGrid::New()) { mySource->Delete(); @@ -81,37 +80,32 @@ namespace VISU //--------------------------------------------------------------- void TPoints - ::Init(vtkIdType theDim) + ::Init(vtkIdType theNbCells, + vtkIdType theDim) { myDim = theDim; - } - - vtkIdType - TPoints - ::size() const - { - return myCoord.size()/myDim; + myNbCells = theNbCells; + myCoord.resize(theNbCells*theDim); } TCPointSlice TPoints - ::GetPointSlice(vtkIdType theElemId) const + ::GetPointSlice(vtkIdType theCellId) const { - return TCPointSlice(myCoord,std::slice(theElemId*myDim,myDim,1)); + return TCPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1)); } TPointSlice TPoints - ::GetPointSlice(vtkIdType theElemId) + ::GetPointSlice(vtkIdType theCellId) { - return TPointSlice(myCoord,std::slice(theElemId*myDim,myDim,1)); + return TPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1)); } //--------------------------------------------------------------- TMeshImpl::TMeshImpl(): myPoints(vtkPoints::New()), - myIsInitialized(false), myNbPoints(0) { myPoints->Delete(); @@ -142,7 +136,6 @@ namespace VISU //--------------------------------------------------------------- TProfileImpl::TProfileImpl(): myIsAll(true), - myIsInitialized(false), myAppendFilter(vtkAppendFilter::New()) { myAppendFilter->Delete(); @@ -173,8 +166,7 @@ namespace VISU //--------------------------------------------------------------- TGaussMeshImpl - ::TGaussMeshImpl(): - myIsInitialized(false) + ::TGaussMeshImpl() {} @@ -201,9 +193,12 @@ namespace VISU TValForTimeImpl ::GetNbGauss(vtkIdType theGeom) const { - TGaussMap::const_iterator anIter2 = myGaussMap.find(theGeom); - if(anIter2 != myGaussMap.end()){ - PGaussImpl aGauss = anIter2->second; + PGaussMeshImpl aGaussMesh = myGaussMesh; + const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; + TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.find(theGeom); + if(anIter != aGeom2GaussSubMesh.end()){ + PGaussSubMesh aGaussSubMesh = anIter->second; + PGaussImpl aGauss = aGaussSubMesh->myGauss; return aGauss->myNbPoints; } return myNbGauss; @@ -333,7 +328,7 @@ namespace { TVTKPoints& aPoints = theMesh->myPoints; - if(!theMesh->myIsInitialized){ + if(!theMesh->myIsVTKDone){ TCoordHelperPtr aCoordHelperPtr; const VISU::TPointsCoord& anArray = theMesh->myPointsCoord; { @@ -386,7 +381,7 @@ namespace aCoordHelperPtr->GetCoord(i,eY), aCoordHelperPtr->GetCoord(i,eZ)); - theMesh->myIsInitialized = true; + theMesh->myIsVTKDone = true; if(MYVTKDEBUG) aPoints->DebugOn(); } @@ -723,10 +718,10 @@ VISU_Convertor_impl bool *anIsInitialized; if(aFamily){ aSource = aFamily->mySource; - anIsInitialized = &(aFamily->myIsInitialized); + anIsInitialized = &(aFamily->myIsVTKDone); }else{ aSource = aMeshOnEntity->mySource; - anIsInitialized = &(aMeshOnEntity->myIsInitialized); + anIsInitialized = &(aMeshOnEntity->myIsVTKDone); } //Main part of code @@ -789,12 +784,12 @@ VISU_Convertor_impl //Main part of code TVTKSource& aSource = aGroup->mySource; try{ - if(!aGroup->myIsInitialized){ + if(!aGroup->myIsVTKDone){ LoadMeshOnGroup(aMesh,aFamilyAndEntitySet); GetPoints(aSource,aMesh); GetCellsOnGroup(aSource,aMesh,aFamilyAndEntitySet); - aGroup->myIsInitialized = true; + aGroup->myIsVTKDone = true; if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); @@ -883,7 +878,7 @@ GetMeshOnSubProfile(PMeshImpl theMesh, INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<myGeom<mySource; - if(theSubProfile->myIsInitialized) + if(theSubProfile->myIsVTKDone) return; GetPoints(aSource,theMesh); @@ -891,7 +886,7 @@ GetMeshOnSubProfile(PMeshImpl theMesh, GetCells(aSource,theSubProfile,theMeshOnEntity); BEGMSG(MYDEBUG,"GetNumberOfCells - "<GetNumberOfCells()<myIsInitialized = true; + theSubProfile->myIsVTKDone = true; } @@ -900,7 +895,7 @@ GetMeshOnProfile(PMeshImpl theMesh, PMeshOnEntityImpl theMeshOnEntity, PProfileImpl theProfile) { - if(theProfile->myIsInitialized) + if(theProfile->myIsVTKDone) return; TVTKAppendFilter& anAppendFilter = theProfile->myAppendFilter; @@ -925,7 +920,7 @@ GetMeshOnProfile(PMeshImpl theMesh, } } anAppendFilter->Update(); // Fix on VTK - theProfile->myIsInitialized = true; + theProfile->myIsVTKDone = true; } @@ -956,7 +951,7 @@ VISU_Convertor_impl #ifndef _DEBUG_ try{ #endif - if(!aValForTime->myIsInitialized){ + if(!aValForTime->myIsVTKDone){ LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); try{ @@ -979,7 +974,7 @@ VISU_Convertor_impl aSource->ShallowCopy(anAppendFilter->GetOutput()); GetTimeStamp2(aSource,aField,aValForTime); - aValForTime->myIsInitialized = true; + aValForTime->myIsVTKDone = true; if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index a8193838..754060f9 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -35,7 +35,17 @@ namespace VISU typedef float TCoord; //--------------------------------------------------------------- - struct TSource: virtual TBaseStructure + struct TIsVTKDone: virtual TBaseStructure + { + bool myIsVTKDone; + TIsVTKDone(): + myIsVTKDone(false) + {} + }; + + + //--------------------------------------------------------------- + struct TSource: virtual TIsVTKDone { TSource(); @@ -43,7 +53,6 @@ namespace VISU vtkIdType myCellsSize; TVTKSource mySource; - bool myIsInitialized; }; @@ -55,26 +64,35 @@ namespace VISU struct TPoints: virtual TBaseStructure { vtkIdType myDim; + vtkIdType myNbCells; + TPointsCoord myCoord; public: TCPointSlice - GetPointSlice(vtkIdType theElemId) const; + GetPointSlice(vtkIdType theCellId) const; TPointSlice - GetPointSlice(vtkIdType theElemId); + GetPointSlice(vtkIdType theCellId); void - Init(vtkIdType theDim); + Init(vtkIdType theNbCells, + vtkIdType theDim); + + vtkIdType + GetNbCells() const { return myNbCells; } + + vtkIdType + GetDim() const { return myDim; } vtkIdType - size() const; + size() const { return GetNbCells(); } }; //--------------------------------------------------------------- - struct TMeshImpl: virtual TMesh + struct TMeshImpl: virtual TMesh, virtual TIsVTKDone { TPointsCoord myPointsCoord; @@ -82,7 +100,6 @@ namespace VISU TPointsDim myPointsDim; TVTKPoints myPoints; - bool myIsInitialized; vtkIdType myNbPoints; TMeshImpl(); @@ -111,7 +128,7 @@ namespace VISU //--------------------------------------------------------------- typedef std::map TGeom2SubProfile; - struct TProfileImpl: virtual TProfile + struct TProfileImpl: virtual TProfile, virtual TIsVTKDone { TProfileImpl(); @@ -119,7 +136,6 @@ namespace VISU vtkIdType myCellsSize; bool myIsAll; - bool myIsInitialized; TVTKAppendFilter myAppendFilter; TGeom2SubProfile myGeom2SubProfile; }; @@ -145,18 +161,19 @@ namespace VISU TPoints myPoints; ESubMeshStatus myStatus; }; + typedef SharedPtr PGaussSubMeshImpl; //--------------------------------------------------------------- typedef std::map TGeom2GaussSubMesh; - struct TGaussMeshImpl: virtual TGaussMesh + struct TGaussMeshImpl: virtual TGaussMesh, virtual TIsVTKDone { TGaussMeshImpl(); - bool myIsInitialized; TGeom2GaussSubMesh myGeom2GaussSubMesh; }; + typedef SharedPtr PGaussMeshImpl; //--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 4bb1a353..4a900234 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -52,7 +52,8 @@ static int MY_GROUP_DEBUG = 0; #endif -namespace{ +namespace +{ using namespace MED; using namespace VISU; @@ -285,7 +286,6 @@ namespace{ PMEDGauss aGauss(new TMEDGauss()); aGaussSubMesh->myGauss = aGauss; - aGauss->myGeom = aVGeom; std::string aName; @@ -308,22 +308,19 @@ namespace{ aGaussSubMesh->myNbCells = aNbCells*aNbGauss; aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*2; - }else{ - aGaussSubMesh->myNbCells = aNbCells; - aGaussSubMesh->myCellsSize = aGaussSubMesh->myNbCells*(aVNbNodes+1); + + INITMSGA(MYDEBUG,0, + "- aVGeom = "<myIsInitialized) + if(aProfile->myIsMEDDone) return; const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; @@ -1133,6 +1118,8 @@ LoadProfile(MED::TTimeStampVal& theTimeStampVal, endl); } } + + aProfile->myIsMEDDone = true; } @@ -1148,7 +1135,7 @@ LoadGaussMesh(const MED::PWrapper& theMed, INITMSG(MYDEBUG,"LoadGaussMesh"<myIsInitialized) + if(aGaussMesh->myIsMEDDone) return; const PMeshInfo& aMeshInfo = theMesh->myMeshInfo; @@ -1197,17 +1184,29 @@ LoadGaussMesh(const MED::PWrapper& theMed, aNodeInfo, aGaussCoord); - TInt aSize = aGaussCoord.size(); - if(aSize){ + if(TInt aNbGauss = aGaussCoord.GetNbGauss()){ TPoints& aPoints = aGaussSubMesh->myPoints; - } + TInt aNbElem = aGaussCoord.GetNbElem(); + TInt aDim = aGaussCoord.GetDim(); + vtkIdType aNbCells = aNbElem*aNbGauss; + aPoints.Init(aNbCells,aDim); + for(TInt anElemId = 0, aCellId = 0; anElemId < aNbElem; anElemId++){ + TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId); + for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aCellId++){ + TPointSlice aPointSlice = aPoints.GetPointSlice(aCellId); + TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId]; + for(TInt aDimId = 0; aDimId < aDim; aDimId++) + aPointSlice[aDimId] = aCoordSlice[aDimId]; + } + } - INITMSG(MYDEBUG, - "- aVGeom = "<myValForCells.empty()) + if(theValForTime->myIsMEDDone) return 0; //Main part of code @@ -1317,5 +1318,7 @@ VISU_MedConvertor } } + theValForTime->myIsMEDDone = true; + return 1; } diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 77bcb45d..557e1b24 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -17,7 +17,18 @@ namespace VISU{ - struct TMEDMesh: TMeshImpl + //--------------------------------------------------------------- + struct TIsMEDDone: virtual TBaseStructure + { + bool myIsMEDDone; + TIsMEDDone(): + myIsMEDDone(false) + {} + }; + + + //--------------------------------------------------------------- + struct TMEDMesh: virtual TMeshImpl { MED::PMeshInfo myMeshInfo; MED::TEntityInfo myEntityInfo; @@ -26,7 +37,7 @@ namespace VISU{ //--------------------------------------------------------------- - struct TMEDSubProfile: TSubProfileImpl + struct TMEDSubProfile: virtual TSubProfileImpl { MED::PProfileInfo myProfileInfo; }; @@ -34,13 +45,13 @@ namespace VISU{ //--------------------------------------------------------------- - struct TMEDProfile: TProfileImpl + struct TMEDProfile: virtual TProfileImpl, virtual TIsMEDDone {}; typedef SharedPtr PMEDProfile; //--------------------------------------------------------------- - struct TMEDGauss: TGaussImpl + struct TMEDGauss: virtual TGaussImpl { MED::PGaussInfo myGaussInfo; }; @@ -54,13 +65,13 @@ namespace VISU{ //--------------------------------------------------------------- - struct TMEDGaussMesh: virtual TGaussMeshImpl + struct TMEDGaussMesh: virtual TGaussMeshImpl, virtual TIsMEDDone {}; typedef SharedPtr PMEDGaussMesh; //--------------------------------------------------------------- - struct TMEDMeshOnEntity: TMeshOnEntityImpl + struct TMEDMeshOnEntity: virtual TMeshOnEntityImpl { MED::TGeom2Size myGeom2Size; }; @@ -68,64 +79,79 @@ namespace VISU{ //--------------------------------------------------------------- - struct TMEDFamily: TFamilyImpl + struct TMEDFamily: virtual TFamilyImpl {}; typedef SharedPtr PMEDFamily; //--------------------------------------------------------------- - struct TMEDGroup: TGroupImpl + struct TMEDGroup: virtual TGroupImpl {}; typedef SharedPtr PMEDGroup; //--------------------------------------------------------------- - struct TMEDField: TFieldImpl + struct TMEDField: virtual TFieldImpl {}; typedef SharedPtr PMEDField; //--------------------------------------------------------------- - struct TMEDValForTime: TValForTimeImpl + struct TMEDValForTime: virtual TValForTimeImpl, virtual TIsMEDDone {}; typedef SharedPtr PMEDValForTime; } -class VISU_MedConvertor: public VISU_Convertor_impl{ +class VISU_MedConvertor: public VISU_Convertor_impl +{ VISU_MedConvertor(); VISU_MedConvertor(const VISU_MedConvertor&); + public: - VISU_MedConvertor(const std::string& theFileName) ; - virtual VISU_Convertor* Build() ; -protected: - QFileInfo myFileInfo; + VISU_MedConvertor(const std::string& theFileName); - virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, - const std::string& theFamilyName = ""); + virtual + VISU_Convertor* + Build(); - virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); +protected: + QFileInfo myFileInfo; - virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, - VISU::PMeshOnEntityImpl theMeshOnEntity, - VISU::PFieldImpl theField, - VISU::PValForTimeImpl theValForTime); + virtual + int + LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, + const std::string& theFamilyName = ""); + + virtual + int + LoadMeshOnGroup(VISU::PMeshImpl theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); + + virtual + int + LoadFieldOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime); + + int + LoadPoints(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + const std::string& theFamilyName = ""); - int LoadPoints(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - const std::string& theFamilyName = ""); - - int LoadCellsOnEntity(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - VISU::PMEDMeshOnEntity theMeshOnEntity, - const std::string& theFamilyName = ""); + int + LoadCellsOnEntity(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, + const std::string& theFamilyName = ""); - int LoadField(const MED::PWrapper& theMed, - VISU::PMEDMesh theMesh, - VISU::PMEDMeshOnEntity theMeshOnEntity, - VISU::PMEDField theField, - VISU::PMEDValForTime theValForTime); + int + LoadField(const MED::PWrapper& theMed, + VISU::PMEDMesh theMesh, + VISU::PMEDMeshOnEntity theMeshOnEntity, + VISU::PMEDField theField, + VISU::PMEDValForTime theValForTime); }; -- 2.39.2