From 023d8cb0bf3cba09c3b164124e1ad308be0451aa Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 14 Nov 2007 08:16:21 +0000 Subject: [PATCH] Fix for Bug NPAL16809 EDF 562 VISU Gauss Picking, having an alphanumeric selection (reversal Gauss Points mapping from object ID to VTK one is implemented) --- src/CONVERTOR/VISU_Convertor.cxx | 17 ++ src/CONVERTOR/VISU_Convertor.hxx | 20 +- src/CONVERTOR/VISU_Convertor_impl.cxx | 418 ++++++++++++++++++-------- src/CONVERTOR/VISU_Convertor_impl.hxx | 39 ++- src/CONVERTOR/VISU_IDMapper.hxx | 7 +- src/CONVERTOR/VISU_MedConvertor.cxx | 64 +++- src/CONVERTOR/VISU_MedConvertor.hxx | 11 + 7 files changed, 421 insertions(+), 155 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor.cxx b/src/CONVERTOR/VISU_Convertor.cxx index c18100d3..5b4a5fe6 100644 --- a/src/CONVERTOR/VISU_Convertor.cxx +++ b/src/CONVERTOR/VISU_Convertor.cxx @@ -94,3 +94,20 @@ VISU_Convertor aName.sprintf("%s_%d",aNewName,theTimeId); return aName.latin1(); } + + +vtkIdType +VISU::TGaussSubMesh +::GetElemObjID(vtkIdType theID) const +{ + return mySubProfile->GetElemObjID( theID ); +} + + +vtkIdType +VISU::TGaussSubMesh +::GetElemVTKID(vtkIdType theID) const +{ + return mySubProfile->GetElemVTKID( theID ); +} + diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index ae760147..cfefaafe 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -91,7 +91,17 @@ namespace VISU //--------------------------------------------------------------- //! Define a basic class which corresponds to MED PROFILE entity struct TSubProfile: virtual TBaseStructure - {}; + { + //! Get object number of mesh cell by its VTK one + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const = 0; + + //! Get cell VTK ID for corresponding object ID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const = 0; + }; //--------------------------------------------------------------- @@ -118,6 +128,14 @@ namespace VISU //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE struct TGaussSubMesh: virtual TBaseStructure { + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; + PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located }; diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index d9a24216..86709f56 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -69,6 +69,206 @@ static int MYDEBUGWITHFILES = 0; namespace VISU { + //--------------------------------------------------------------- + vtkIdType + VISUGeom2NbNodes(EGeometry theGeom) + { + switch(theGeom){ +#ifndef VISU_ENABLE_QUADRATIC + case VISU::eSEG3: + return 2; + case VISU::eTRIA6: + return 3; + case VISU::eQUAD8: + return 4; + case VISU::eTETRA10: + return 4; + case VISU::eHEXA20: + return 8; + case VISU::ePENTA15: + return 6; + case VISU::ePYRA13: + return 5; +#endif + case VISU::ePOLYGONE: + case VISU::ePOLYEDRE: + return -1; + default: + return theGeom % 100; + } + } + + vtkIdType + VISUGeom2VTK(EGeometry theGeom) + { + switch(theGeom){ + case VISU::ePOINT1: + return VTK_VERTEX; + case VISU::eSEG2: + return VTK_LINE; + case VISU::eTRIA3: + return VTK_TRIANGLE; + case VISU::eQUAD4: + return VTK_QUAD; + case VISU::eTETRA4: + return VTK_TETRA; + case VISU::eHEXA8: + return VTK_HEXAHEDRON; + case VISU::ePENTA6: + return VTK_WEDGE; + case VISU::ePYRA5: + return VTK_PYRAMID; + + case VISU::ePOLYGONE: + return VTK_POLYGON; + case VISU::ePOLYEDRE: + return VTK_CONVEX_POINT_SET; + +#ifndef VISU_ENABLE_QUADRATIC + case VISU::eSEG3: + return VTK_LINE; + case VISU::eTRIA6: + return VTK_TRIANGLE; + case VISU::eQUAD8: + return VTK_QUAD; + case VISU::eTETRA10: + return VTK_TETRA; + case VISU::eHEXA20: + return VTK_HEXAHEDRON; + case VISU::ePENTA15: + return VTK_WEDGE; + case VISU::ePYRA13: + return VTK_PYRAMID; + +#else + + case VISU::eSEG3: +#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_EDGE; +#else + return VTK_POLY_LINE; +#endif + + case VISU::eTRIA6: +#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_TRIANGLE; +#else + return VTK_POLYGON; +#endif + + case VISU::eQUAD8: +#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_QUAD; +#else + return VTK_POLYGON; +#endif + + case VISU::eTETRA10: +#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_TETRA; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::eHEXA20: +#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_HEXAHEDRON; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::ePENTA15: +#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_WEDGE; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::ePYRA13: +#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_PYRAMID; +#else + return VTK_CONVEX_POINT_SET; +#endif + +#endif //VISU_ENABLE_QUADRATIC + + default: + return -1; + } + } + + + EGeometry + VTKGeom2VISU(vtkIdType theGeom) + { + switch(theGeom){ + case VTK_VERTEX: + return VISU::ePOINT1; + case VTK_LINE: + return VISU::eSEG2; + case VTK_TRIANGLE: + return VISU::eTRIA3; + case VTK_QUAD: + return VISU::eQUAD4; + case VTK_TETRA: + return VISU::eTETRA4; + case VTK_HEXAHEDRON: + return VISU::eHEXA8; + case VTK_WEDGE: + return VISU::ePENTA6; + case VTK_PYRAMID: + return VISU::ePYRA5; + + case VTK_POLYGON: + return VISU::ePOLYGONE; + case VTK_CONVEX_POINT_SET: + return VISU::ePOLYEDRE; + +#if defined(VISU_ENABLE_QUADRATIC) && defined(VISU_USE_VTK_QUADRATIC) + #if defined(VTK_QUADRATIC_EDGE) + case VTK_QUADRATIC_EDGE: + return VISU::eSEG3; + #endif + + #if defined(VTK_QUADRATIC_TRIANGLE) + case VTK_QUADRATIC_TRIANGLE: + return VISU::eTRIA6; + #endif + + #if defined(VTK_QUADRATIC_QUAD) + case VTK_QUADRATIC_QUAD: + return VISU::eQUAD8; + #endif + + #if defined(VTK_QUADRATIC_TETRA) + case VTK_QUADRATIC_TETRA: + return VISU::eTETRA10; + #endif + + #if defined(VTK_QUADRATIC_HEXAHEDRON) + case VTK_QUADRATIC_HEXAHEDRON: + return VISU::eHEXA20; + #endif + + #if defined(VTK_QUADRATIC_WEDGE) + case VTK_QUADRATIC_WEDGE: + return VISU::ePENTA15; + #endif + + #if defined(VTK_QUADRATIC_PYRAMID) + case VTK_QUADRATIC_PYRAMID: + return VISU::ePYRA13; + #endif + +#endif //VISU_ENABLE_QUADRATIC + + default: + return EGeometry(-1); + } + } + + //--------------------------------------------------------------- TIsVTKDone::TIsVTKDone(): myIsVTKDone(false), @@ -274,6 +474,22 @@ namespace VISU TSubProfileImpl ::GetElemObjID(vtkIdType theID) const { + if ( !mySubMeshID.empty() ) + return mySubMeshID[theID]; + + return theID; + } + + + vtkIdType + TSubProfileImpl + ::GetElemVTKID(vtkIdType theID) const + { + if ( !mySubMeshID.empty() ) + for ( size_t anId = 0; anId < mySubMeshID.size(); anId++ ) + if ( mySubMeshID[ anId ] == theID ) + return anId; + return theID; } @@ -549,9 +765,28 @@ namespace VISU TCellID aCellID = theStartID + theID / myGauss->myNbPoints; TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; - return TGaussPointID(aCellID,aLocalPntID); + return TGaussPointID(aCellID, aLocalPntID); + } + + + vtkIdType + TGaussSubMeshImpl + ::GetVTKID(const TGaussPointID& theID, + vtkIdType theStartID) const + { + vtkIdType aResult = -1; + + TCellID aCellID = theID.first; + TLocalPntID aLocalPntID = theID.second; + + vtkIdType aNbPoints = myGauss->myNbPoints; + if ( aLocalPntID >= aNbPoints ) + return aResult; + + return ( aCellID - theStartID ) * aNbPoints + aLocalPntID; } + //--------------------------------------------------------------- bool operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) @@ -591,6 +826,44 @@ namespace VISU return aSubMeshImpl.GetObjID(anInputID,aStartId); } + vtkIdType + TGaussMeshImpl + ::GetVTKID(const TGaussPointID& theID) const + { + vtkIdType aResult = -1; + + TCellID aCellID = theID.first; + + vtkIdType aVTKCellId = GetParent()->GetElemVTKID( aCellID ); + if ( aVTKCellId < 0 ) + return aResult; + + vtkCell* aCell = GetParent()->GetElemCell( aCellID ); + if ( !aCell ) + return aResult; + + EGeometry aVGeom = VISU::VTKGeom2VISU( aCell->GetCellType() ); + if ( aVGeom < EGeometry(0) ) + return aResult; + + TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.find( aVGeom ); + if ( anIter == myGeom2GaussSubMesh.end() ) + return aResult; + + size_t aSubMeshEnd = myGaussSubMeshArr.size(); + const TVTKAppendFilter& anAppendFilter = GetFilter(); + const PGaussSubMeshImpl& aGaussSubMesh = anIter->second; + for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) { + const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId]; + if ( aGaussSubMesh.get() == aSubMesh.get() ) { + vtkIdType aStartId = anAppendFilter->GetCellOutputID( 0, aSubMeshId ); + return aGaussSubMesh->GetVTKID(theID, aStartId); + } + } + + return aResult; + } + TVTKOutput* TGaussMeshImpl ::GetVTKOutput() @@ -600,7 +873,7 @@ namespace VISU TNamedIDMapper* TGaussMeshImpl:: - GetParent() + GetParent() const { return myParent; } @@ -614,9 +887,16 @@ namespace VISU return myGaussPtsIDMapper->GetObjID(theID); } + vtkIdType + TGaussPtsIDFilter + ::GetVTKID(const TGaussPointID& theID) const + { + return myGaussPtsIDMapper->GetVTKID(theID); + } + TNamedIDMapper* TGaussPtsIDFilter:: - GetParent() + GetParent() const { return myGaussPtsIDMapper->GetParent(); } @@ -932,136 +1212,7 @@ namespace VISU } return anIter->second; } - - - //--------------------------------------------------------------- - vtkIdType - VISUGeom2NbNodes(EGeometry theGeom) - { - switch(theGeom){ -#ifndef VISU_ENABLE_QUADRATIC - case VISU::eSEG3: - return 2; - case VISU::eTRIA6: - return 3; - case VISU::eQUAD8: - return 4; - case VISU::eTETRA10: - return 4; - case VISU::eHEXA20: - return 8; - case VISU::ePENTA15: - return 6; - case VISU::ePYRA13: - return 5; -#endif - case VISU::ePOLYGONE: - case VISU::ePOLYEDRE: - return -1; - default: - return theGeom % 100; - } - } - - vtkIdType - VISUGeom2VTK(EGeometry theGeom) - { - switch(theGeom){ - case VISU::ePOINT1: - return VTK_VERTEX; - case VISU::eSEG2: - return VTK_LINE; - case VISU::eTRIA3: - return VTK_TRIANGLE; - case VISU::eQUAD4: - return VTK_QUAD; - case VISU::eTETRA4: - return VTK_TETRA; - case VISU::eHEXA8: - return VTK_HEXAHEDRON; - case VISU::ePENTA6: - return VTK_WEDGE; - case VISU::ePYRA5: - return VTK_PYRAMID; - - case VISU::ePOLYGONE: - return VTK_POLYGON; - case VISU::ePOLYEDRE: - return VTK_CONVEX_POINT_SET; - -#ifndef VISU_ENABLE_QUADRATIC - case VISU::eSEG3: - return VTK_LINE; - case VISU::eTRIA6: - return VTK_TRIANGLE; - case VISU::eQUAD8: - return VTK_QUAD; - case VISU::eTETRA10: - return VTK_TETRA; - case VISU::eHEXA20: - return VTK_HEXAHEDRON; - case VISU::ePENTA15: - return VTK_WEDGE; - case VISU::ePYRA13: - return VTK_PYRAMID; - -#else - - case VISU::eSEG3: -#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_EDGE; -#else - return VTK_POLY_LINE; -#endif - - case VISU::eTRIA6: -#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_TRIANGLE; -#else - return VTK_POLYGON; -#endif - - case VISU::eQUAD8: -#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_QUAD; -#else - return VTK_POLYGON; -#endif - - case VISU::eTETRA10: -#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_TETRA; -#else - return VTK_CONVEX_POINT_SET; -#endif - - case VISU::eHEXA20: -#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_HEXAHEDRON; -#else - return VTK_CONVEX_POINT_SET; -#endif - case VISU::ePENTA15: -#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_WEDGE; -#else - return VTK_CONVEX_POINT_SET; -#endif - - case VISU::ePYRA13: -#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_PYRAMID; -#else - return VTK_CONVEX_POINT_SET; -#endif - -#endif //VISU_ENABLE_QUADRATIC - - default: - return -1; - } - } } @@ -1666,7 +1817,8 @@ namespace vtkIdType aNbCells = aSource->GetNumberOfCells(); for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){ - anElemObj2VTKID[aSubProfile->GetElemObjID(aCell)] = aCellID; + vtkIdType anObjID = aSubProfile->GetElemObjID(aCell); + anElemObj2VTKID[anObjID] = aCellID; } aSubProfileArr[anInputID++] = aSubProfile; diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index fd1aaf05..32d16b50 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -300,10 +300,15 @@ namespace VISU EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to std::string myName; //!< Keeps its name - //! Get object number of mesh cell by its VTK one + //! Reimplement the TSubProfile::GetElemObjID virtual vtkIdType - GetElemObjID(int theVtkI) const; + GetElemObjID(vtkIdType theID) const; + + //! Reimplement the TSubProfile::GetElemVTKID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; //! Keeps status of the structure /*! @@ -493,6 +498,12 @@ namespace VISU GetObjID(vtkIdType theID, vtkIdType theStartID) const; + //! To implement the TGaussPtsIDMapper::GetVTKID + virtual + vtkIdType + GetVTKID(const TGaussPointID& theID, + vtkIdType theStartID) const; + PGaussImpl myGauss; // PGaussPtsIDFilter; diff --git a/src/CONVERTOR/VISU_IDMapper.hxx b/src/CONVERTOR/VISU_IDMapper.hxx index 9c1f6083..c9afaa66 100644 --- a/src/CONVERTOR/VISU_IDMapper.hxx +++ b/src/CONVERTOR/VISU_IDMapper.hxx @@ -190,10 +190,15 @@ namespace VISU TGaussPointID GetObjID(vtkIdType theID) const = 0; + //! Gets VTK ID by its complex Gauss Point ID + virtual + vtkIdType + GetVTKID(const TGaussPointID& theID) const = 0; + //! Gets parent TNamedIDMapper, which contains reference mesh cells virtual TNamedIDMapper* - GetParent() = 0; + GetParent() const = 0; }; typedef SharedPtr PGaussPtsIDMapper; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 60744663..9af8357c 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1083,12 +1083,29 @@ static int MY_GROUP_DEBUG = 0; TMEDSubProfile ::GetElemObjID(vtkIdType theID) const { - if(mySubMeshID.empty()) - if(myIsElemNum) - return myElemNum[theID]; - else - return theID; - return mySubMeshID[theID]; + if ( !mySubMeshID.empty() ) + theID = mySubMeshID[theID]; + + if ( myIsElemNum ) + return myElemNum[theID]; + else + return theID; + } + + + //--------------------------------------------------------------- + vtkIdType + TMEDSubProfile + ::GetElemVTKID(vtkIdType theID) const + { + if ( myIsElemNum ) + for ( size_t anId = 0; anId < myElemNum.size(); anId++ ) + if ( myElemNum[ anId ] == theID ) { + theID = anId; + break; + } + + return TSubProfileImpl::GetElemVTKID( theID ); } @@ -1115,18 +1132,43 @@ static int MY_GROUP_DEBUG = 0; ::GetObjID(vtkIdType theID, vtkIdType theStartID) const { - TCellID aCellID = theID / myGauss->myNbPoints; - TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; + vtkIdType aNbPoints = myGauss->myNbPoints; + TCellID aCellID = theID / aNbPoints; + TLocalPntID aLocalPntID = theID % aNbPoints; - if(myIsElemNum) - aCellID = myElemNum[aCellID]; - else + if ( myIsElemNum ) { + aCellID = GetElemObjID(aCellID); + } else aCellID += theStartID; return TGaussPointID(aCellID,aLocalPntID); } + //--------------------------------------------------------------- + vtkIdType + TMEDGaussSubMesh + ::GetVTKID(const TGaussPointID& theID, + vtkIdType theStartID) const + { + vtkIdType aResult = -1; + + TCellID aCellID = theID.first; + TLocalPntID aLocalPntID = theID.second; + + vtkIdType aNbPoints = myGauss->myNbPoints; + if ( aLocalPntID >= aNbPoints ) + return aResult; + + if ( myIsElemNum ) { + aCellID = GetElemVTKID( aCellID ); + } else + aCellID -= theStartID; + + return aCellID * aNbPoints + aLocalPntID + theStartID; + } + + //--------------------------------------------------------------- void TMEDSubMesh diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index a16d04fe..7c1f5dc9 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -76,9 +76,15 @@ namespace VISU MED::EBooleen myIsElemNum; MED::TElemNum myElemNum; + //! Reimplement the TSubProfileImpl::GetElemObjID virtual vtkIdType GetElemObjID(vtkIdType theID) const; + + //! Reimplement the TSubProfileImpl::GetElemVTKID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; }; typedef SharedPtr PMEDSubProfile; @@ -117,6 +123,11 @@ namespace VISU TGaussPointID GetObjID(vtkIdType theID, vtkIdType theStartID) const; + + virtual + vtkIdType + GetVTKID(const TGaussPointID& theID, + vtkIdType theStartID) const; }; typedef SharedPtr PMEDGaussSubMesh; -- 2.39.2