From: apo Date: Mon, 3 Oct 2005 16:37:21 +0000 (+0000) Subject: To support quadratic mesh elements X-Git-Tag: BR-D5-38-2003_D2005-12-10~80 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=37149c451de0f6a6818dbdc0311982b04cfa0d0d;p=modules%2Fvisu.git To support quadratic mesh elements --- diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 8b81fe72..dd489e35 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -65,6 +65,8 @@ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif +//#define ENABLE_QUADRATIC + namespace VISU { //--------------------------------------------------------------- @@ -259,10 +261,9 @@ namespace VISU //--------------------------------------------------------------- TSubProfileImpl::TSubProfileImpl(): - myStatus(eNone) - { - myGeom = -1; - } + myStatus(eNone), + myGeom(eNONE) + {} vtkIdType @@ -799,7 +800,7 @@ namespace VISU const TMeshValue& TValForTimeImpl - ::GetMeshValue(vtkIdType theGeom) const + ::GetMeshValue(EGeometry theGeom) const { TGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom); if(anIter == myGeom2Value.end()) @@ -809,14 +810,14 @@ namespace VISU TMeshValue& TValForTimeImpl - ::GetMeshValue(vtkIdType theGeom) + ::GetMeshValue(EGeometry theGeom) { return myGeom2Value[theGeom]; } int TValForTimeImpl - ::GetNbGauss(vtkIdType theGeom) const + ::GetNbGauss(EGeometry theGeom) const { if(PGaussMeshImpl aGaussMesh = myGaussMesh){ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; @@ -833,42 +834,115 @@ namespace VISU //--------------------------------------------------------------- vtkIdType - VTKGeom2NbNodes(vtkIdType theGeom) + VISUGeom2NbNodes(EGeometry 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; - - case QUADRATIC_EDGE: return 3; - case QUADRATIC_TRIANGLE: return 6; - case QUADRATIC_QUAD: return 8; - case QUADRATIC_TETRA: return 10; - case QUADRATIC_HEXAHEDRON: return 20; - case QUADRATIC_WEDGE: return 15; - case QUADRATIC_PYRAMID: return 13; + case VISU::ePOLYGONE: + case VISU::ePOLYEDRE: + return -1; + default: + return theGeom % 100; } - return -1; } vtkIdType - VTKGeom2VISU(vtkIdType theGeom) + VISUGeom2VTK(EGeometry theGeom) { switch(theGeom){ - case QUADRATIC_EDGE: return VTK_POLY_LINE; - case QUADRATIC_TRIANGLE: return VTK_POLYGON; - case QUADRATIC_QUAD: return VTK_POLYGON; - case QUADRATIC_TETRA: return VTK_CONVEX_POINT_SET; - case QUADRATIC_HEXAHEDRON: return VTK_CONVEX_POINT_SET; - case QUADRATIC_WEDGE: return VTK_CONVEX_POINT_SET; - case QUADRATIC_PYRAMID: return VTK_CONVEX_POINT_SET; + 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 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: +#ifdef VTK_QUADRATIC_EDGE + return VTK_QUADRATIC_EDGE; +#else + return VTK_POLY_LINE; +#endif + + case VISU::eTRIA6: +#ifdef VTK_QUADRATIC_TRIANGLE + return VTK_QUADRATIC_TRIANGLE; +#else + return VTK_POLYGON; +#endif + + case VISU::eQUAD8: +#ifdef VTK_QUADRATIC_QUAD + return VTK_QUADRATIC_QUAD; +#else + return VTK_POLYGON; +#endif + + case VISU::eTETRA10: +#ifdef VTK_QUADRATIC_TETRA + return VTK_QUADRATIC_QUAD; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::eHEXA20: +#ifdef VTK_QUADRATIC_HEXAHEDRON + return VTK_QUADRATIC_HEXAHEDRON; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::ePENTA15: +#ifdef VTK_QUADRATIC_WEDGE + return VTK_QUADRATIC_WEDGE; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::ePYRA13: +#ifdef VTK_QUADRATIC_PYRAMID + return VTK_QUADRATIC_PYRAMID; +#else + return VTK_CONVEX_POINT_SET; +#endif + +#endif //ENABLE_QUADRATIC + + default: + return -1; } - return theGeom; } } @@ -1125,7 +1199,8 @@ namespace const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin(); for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){ - const vtkIdType& aGeom = anIter->first; + VISU::EGeometry aEGeom = anIter->first; + vtkIdType aVGeom = VISUGeom2VTK(aEGeom); const VISU::TSubMeshImpl& aSubMesh = anIter->second; const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect; @@ -1133,13 +1208,13 @@ namespace if(aGeom2SubMeshID.empty()) EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); - VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom); + VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom); if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end()) continue; const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second; - INITMSG(MYDEBUG,"aGeom = "<> There is no elements for the GEOM("<> There is no elements for the GEOM("<second; const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; @@ -1296,7 +1371,7 @@ namespace for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ const TConnect& anArray = aCell2Connect[anId]; PrintCells(aConnId,aConnectivity,anArray); - aCellTypesArray->SetValue(anId,(unsigned char)aGeom); + aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; anId++; } @@ -1306,7 +1381,7 @@ namespace vtkIdType aSubId = *anIter; const TConnect& anArray = aCell2Connect[aSubId]; PrintCells(aConnId,aConnectivity,anArray); - aCellTypesArray->SetValue(anId,(unsigned char)aGeom); + aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; anId++; } @@ -1335,7 +1410,7 @@ namespace const PProfileImpl& theProfile, const PSubProfileImpl& theSubProfile) { - INITMSG(MYDEBUG,"GetMeshOnSubProfile - aVGeom = "<myGeom<> Can't find values for corresponding Gauss Points SubMesh"); @@ -1466,7 +1543,8 @@ namespace if(aNbGauss < 1) continue; - INITMSG(MYDEBUG,"- aVGeom = "<myGauss = aGauss; - aGauss->myGeom = aVGeom; + aGauss->myGeom = aEGeom; TInt aNbGauss = 1; std::string aName; @@ -409,7 +411,7 @@ namespace aGaussKey.insert(aGaussSubMesh); INITMSGA(MYDEBUG,0, - "- aVGeom = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aPolygoneInfo->GetNbElem(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aVGeom](new TMEDSubMesh()); + PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); aSubMesh->Init(aPolygoneInfo); aSubMesh->myNbCells = aNbElem; @@ -1553,7 +1555,7 @@ VISU_MedConvertor TInt aNbElem = aPolyedreInfo->GetNbElem(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aVGeom](new TMEDSubMesh()); + PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); aSubMesh->Init(aPolyedreInfo); aSubMesh->myNbCells = aNbElem; @@ -1589,13 +1591,13 @@ VISU_MedConvertor break; } default: { - vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom); + vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom); MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aCellInfo->GetNbElem(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aVGeom](new TMEDSubMesh()); + PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); aSubMesh->Init(aCellInfo); aSubMesh->myNbCells = aNbElem; @@ -1623,28 +1625,50 @@ VISU_MedConvertor } switch(aMGeom){ +#ifndef VTK_QUADRATIC_EDGE && ENABLE_QUADRATIC + case MED::eSEG3: + anArray[0] = aConnect[0]; + anArray[2] = aConnect[1]; + + anArray[1] = aConnect[2]; + break; +#endif +#ifndef VTK_QUADRATIC_TRIANGLE && ENABLE_QUADRATIC + case MED::eTRIA6: + anArray[0] = aConnect[0]; + anArray[2] = aConnect[1]; + anArray[4] = aConnect[2]; + + anArray[1] = aConnect[3]; + anArray[3] = aConnect[4]; + anArray[5] = aConnect[5]; + break; +#endif +#ifndef VTK_QUADRATIC_QUAD && ENABLE_QUADRATIC + case MED::eQUAD8: + anArray[0] = aConnect[0]; + anArray[2] = aConnect[1]; + anArray[4] = aConnect[2]; + anArray[6] = aConnect[3]; + + anArray[1] = aConnect[4]; + anArray[3] = aConnect[5]; + anArray[5] = aConnect[6]; + anArray[7] = aConnect[7]; + break; +#endif +#ifdef VTK_QUADRATIC_TETRA && ENABLE_QUADRATIC case MED::eTETRA10: - anArray[4] = aConnect[4]; - anArray[5] = aConnect[5]; - anArray[6] = aConnect[7]; - anArray[7] = aConnect[6]; - anArray[8] = aConnect[8]; - anArray[9] = aConnect[9]; +#endif case MED::eTETRA4: anArray[0] = aConnect[0]; anArray[1] = aConnect[1]; anArray[2] = aConnect[3]; anArray[3] = aConnect[2]; break; +#ifdef VTK_QUADRATIC_TETRA && ENABLE_QUADRATIC case MED::ePYRA13: - anArray[5] = aConnect[5]; - anArray[6] = aConnect[8]; - anArray[7] = aConnect[7]; - anArray[8] = aConnect[6]; - anArray[9] = aConnect[9]; - anArray[10] = aConnect[10]; - anArray[11] = aConnect[11]; - anArray[12] = aConnect[12]; +#endif case MED::ePYRA5: anArray[0] = aConnect[0]; anArray[1] = aConnect[3]; @@ -1733,9 +1757,9 @@ VISU_MedConvertor if(anElemInfo->GetFamNum(iElem) == anId) aSubMeshID.push_back(iElem); if(!aSubMeshID.empty()){ - TInt aVGeom = MEDGeomToVTK(aMGeom); + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); INITMSG(MYDEBUG,"aMGeom = "<second; MED::EGeometrieElement aMGeom = anIter->first; - vtkIdType aVGeom = MEDGeomToVTK(aMGeom); + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); - TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aVGeom); + TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom); if(anIter2 != aGeom2SubProfile.end()){ PMEDSubProfile aSubProfile = anIter2->second; @@ -1793,7 +1817,7 @@ LoadProfile(const MED::PWrapper& theMed, } INITMSG(MYDEBUG, - "- aVGeom = "<myGeom2SubMesh; - PSubMeshImpl aSubMesh = aGeom2SubMesh[VTK_VERTEX]; + PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1]; TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); for(int iElem = 0; iElem < aNbElem; iElem++) @@ -1002,7 +1001,7 @@ VISU_MEDConvertor SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily; CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VTK_VERTEX]; + TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; if(!anIsOnAllElements){ SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); @@ -1052,20 +1051,21 @@ VISU_MEDConvertor int aNbPoints = aCoords.GetNbPoints(); for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){ - SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom]; - int aMNbNodes = MEDGeom2NbNodes(aGeom); - int aVGeom = MEDGeomToVTK(aGeom); - int aVNbNodes = VTKGeom2NbNodes(aVGeom); - int iNumElemEnd = aMedMesh->getNumberOfElements(aMEntity,aGeom); + SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom]; + int aMNbNodes = MEDGeom2NbNodes(aMGeom); + VISU::EGeometry aEGeom = MEDGeom2VISU(aEGeom); + int aVNbNodes = VISUGeom2NbNodes(aEGeom); + int iNumElemEnd = aMedMesh->getNumberOfElements(aMEntity,aMGeom); if (iNumElemEnd > 0) { + using namespace SALOME_MED; SALOME_MED::long_array_var conn = - aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMEntity,aGeom); - PSubMeshImpl aSubMesh = aGeom2SubMesh[aVGeom]; + aMedMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,aMEntity,aMGeom); + PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom]; TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; std::vector aConnect(aMNbNodes); int aNbConnForElem = conn->length()/iNumElemEnd; - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aGeom = "<GetMeshValue(aVGeom); + TMeshValue& aMeshValue = theValForTime->GetMeshValue(aEGeom); aMeshValue.Init(aNbElem,aNbGauss,aNbComp); for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++, anId += aNbComp){ TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);