From 0c2eb105df878d224d8768bfa1f7578a09eeb23a Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 4 Oct 2005 11:35:44 +0000 Subject: [PATCH] To support quadratic mesh elements --- src/CONVERTOR/VISU_Convertor_impl.cxx | 57 ++++++++++++++++++--------- src/CONVERTOR/VISU_Convertor_impl.hxx | 5 +++ src/CONVERTOR/VISU_MedConvertor.cxx | 12 +++--- src/VISU_I/VISU_CorbaMedConvertor.cxx | 14 ++++++- 4 files changed, 61 insertions(+), 27 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index dd489e35..8609f12f 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -65,8 +65,6 @@ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -//#define ENABLE_QUADRATIC - namespace VISU { //--------------------------------------------------------------- @@ -837,6 +835,22 @@ namespace VISU 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; @@ -871,7 +885,7 @@ namespace VISU case VISU::ePOLYEDRE: return VTK_CONVEX_POINT_SET; -#ifndef ENABLE_QUADRATIC +#ifndef VISU_ENABLE_QUADRATIC case VISU::eSEG3: return VTK_LINE; case VISU::eTRIA6: @@ -890,55 +904,55 @@ namespace VISU #else case VISU::eSEG3: -#ifdef VTK_QUADRATIC_EDGE +#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_EDGE; #else return VTK_POLY_LINE; #endif case VISU::eTRIA6: -#ifdef VTK_QUADRATIC_TRIANGLE +#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_TRIANGLE; #else return VTK_POLYGON; #endif case VISU::eQUAD8: -#ifdef VTK_QUADRATIC_QUAD +#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_QUAD; #else return VTK_POLYGON; #endif case VISU::eTETRA10: -#ifdef VTK_QUADRATIC_TETRA +#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_QUAD; #else return VTK_CONVEX_POINT_SET; #endif case VISU::eHEXA20: -#ifdef VTK_QUADRATIC_HEXAHEDRON +#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_HEXAHEDRON; #else return VTK_CONVEX_POINT_SET; #endif case VISU::ePENTA15: -#ifdef VTK_QUADRATIC_WEDGE +#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_WEDGE; #else return VTK_CONVEX_POINT_SET; #endif case VISU::ePYRA13: -#ifdef VTK_QUADRATIC_PYRAMID +#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC) return VTK_QUADRATIC_PYRAMID; #else return VTK_CONVEX_POINT_SET; #endif -#endif //ENABLE_QUADRATIC +#endif //VISU_ENABLE_QUADRATIC default: return -1; @@ -1201,6 +1215,7 @@ namespace for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){ VISU::EGeometry aEGeom = anIter->first; vtkIdType aVGeom = VISUGeom2VTK(aEGeom); + const VISU::TSubMeshImpl& aSubMesh = anIter->second; const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect; @@ -1214,7 +1229,9 @@ namespace const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second; - INITMSG(MYDEBUG,"aEGeom = "<AddArray(aDataArray); TGeom2Value& aGeom2Value = theValForTime->myGeom2Value; TGeom2Value::const_iterator anIter = aGeom2Value.begin(); - TVector aDataValues(aNbComp); + TVector aDataValues(aNbComp,0.0); for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){ EGeometry aEGeom = anIter->first; const TMeshValue& aMeshValue = anIter->second; @@ -1313,7 +1331,7 @@ namespace endl); int aNbComp2 = aNbComp; - if(aNbComp == 2 || aNbComp == 4) + if(aNbComp == 4) aNbComp2 = 2; else if(aNbComp > 4) aNbComp2 = 3; @@ -1350,6 +1368,8 @@ namespace vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom); vtkIdType aVGeom = VISUGeom2VTK(aEGeom); + INITMSG(MYDEBUG,"GetCells - aVGeom = "<mySubMeshID; const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; @@ -1514,18 +1534,17 @@ namespace vtkFloatArray *aDataArray = vtkFloatArray::New(); aDataArray->SetNumberOfComponents(aNbComp); aDataArray->SetNumberOfTuples(aNbTuples); - aDataSetAttributes->AddArray(aDataArray); aDataArray->SetName("VISU_FIELD"); + aDataSetAttributes->AddArray(aDataArray); const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value; PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh; const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); - TVector aDataValues(aNbComp); + TVector aDataValues(aNbComp,0.0); for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){ EGeometry aEGeom = anIter->first; - vtkIdType aVGeom = VISUGeom2VTK(aEGeom); PGaussSubMeshImpl aGaussSubMesh = anIter->second; if(!aGaussSubMesh->myIsDone) @@ -1551,7 +1570,7 @@ namespace endl); int aNbComp2 = aNbComp; - if(aNbComp == 2 || aNbComp == 4) + if(aNbComp == 4) aNbComp2 = 2; else if(aNbComp > 4) aNbComp2 = 3; diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index ad742b6a..4418d0b4 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -22,6 +22,11 @@ class VTKViewer_AppendFilter; #include "VISU_Convertor.hxx" #include "MED_SliceArray.hxx" +#ifndef VISU_ENABLE_QUADRATIC +#define VISU_ENABLE_QUADRATIC +#define VISU_USE_VTK_QUADRATIC +#endif + namespace VISU { enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203, diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 34b94fb0..9cb56ad7 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -67,8 +67,6 @@ static int MY_GROUP_DEBUG = 0; #define _EDF_NODE_IDS_ #define _NAME_MAPPING_ 0 -//#define ENABLE_QUADRATIC - namespace { //--------------------------------------------------------------- @@ -1625,7 +1623,7 @@ VISU_MedConvertor } switch(aMGeom){ -#ifndef VTK_QUADRATIC_EDGE && ENABLE_QUADRATIC +#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case MED::eSEG3: anArray[0] = aConnect[0]; anArray[2] = aConnect[1]; @@ -1633,7 +1631,7 @@ VISU_MedConvertor anArray[1] = aConnect[2]; break; #endif -#ifndef VTK_QUADRATIC_TRIANGLE && ENABLE_QUADRATIC +#if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case MED::eTRIA6: anArray[0] = aConnect[0]; anArray[2] = aConnect[1]; @@ -1644,7 +1642,7 @@ VISU_MedConvertor anArray[5] = aConnect[5]; break; #endif -#ifndef VTK_QUADRATIC_QUAD && ENABLE_QUADRATIC +#if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case MED::eQUAD8: anArray[0] = aConnect[0]; anArray[2] = aConnect[1]; @@ -1657,7 +1655,7 @@ VISU_MedConvertor anArray[7] = aConnect[7]; break; #endif -#ifdef VTK_QUADRATIC_TETRA && ENABLE_QUADRATIC +#if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case MED::eTETRA10: #endif case MED::eTETRA4: @@ -1666,7 +1664,7 @@ VISU_MedConvertor anArray[2] = aConnect[3]; anArray[3] = aConnect[2]; break; -#ifdef VTK_QUADRATIC_TETRA && ENABLE_QUADRATIC +#if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case MED::ePYRA13: #endif case MED::ePYRA5: diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 7da437c1..5457ae9c 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -1075,12 +1075,15 @@ VISU_MEDConvertor aConnect[k] = conn[kj+k] - 1; switch(aMGeom){ +#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case SALOME_MED::MED_SEG3: anArray[0] = aConnect[0]; anArray[2] = aConnect[1]; anArray[1] = aConnect[2]; break; +#endif +#if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case SALOME_MED::MED_TRIA6: anArray[0] = aConnect[0]; anArray[2] = aConnect[1]; @@ -1090,6 +1093,8 @@ VISU_MEDConvertor anArray[3] = aConnect[4]; anArray[5] = aConnect[5]; break; +#endif +#if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) case SALOME_MED::MED_QUAD8: anArray[0] = aConnect[0]; anArray[2] = aConnect[1]; @@ -1101,13 +1106,20 @@ VISU_MEDConvertor anArray[5] = aConnect[6]; anArray[7] = aConnect[7]; break; +#endif +#if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) + case SALOME_MED::MED_TETRA10 : +#endif case SALOME_MED::MED_TETRA4 : anArray[0] = aConnect[0]; anArray[1] = aConnect[1]; anArray[2] = aConnect[3]; anArray[3] = aConnect[2]; break; - case SALOME_MED::MED_PYRA13 : +#if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC) + case SALOME_MED::MED_PYRA13: +#endif + case SALOME_MED::MED_PYRA5 : anArray[0] = aConnect[0]; anArray[1] = aConnect[3]; anArray[2] = aConnect[2]; -- 2.39.2