From 9dbade0021c7a8e21aedcfb28be257886abed924 Mon Sep 17 00:00:00 2001 From: geay Date: Wed, 12 Feb 2014 14:41:02 +0100 Subject: [PATCH] new MEDReader --- src/PV_SWIG/VTKWrapping/presentations.py | 98 +- src/Plugins/CMakeLists.txt | 4 +- src/Plugins/ExtraxtFieldFilter/CMakeLists.txt | 40 - .../ExtraxtFieldFilter/ExtractFieldFilter.xml | 42 - .../ExtraxtFieldFilter/ExtractFieldGUI.xml | 8 - .../ExtraxtFieldFilter/pqExtractField.qrc | 5 - .../resources/extract_field.png | Bin 1254 -> 0 bytes .../vtkExtractFieldFilter.cxx | 242 -- .../vtkExtractFieldFilter.h | 84 - src/Plugins/IntegrationPoints/CMakeLists.txt | 45 - src/Plugins/IntegrationPoints/ELNOFilter.xml | 281 -- .../IntegrationPoints/ELNOFilterClient.xml | 8 - .../IntegrationPoints/vtkELNOMeshFilter.cxx | 203 -- .../CMake/CTestCustom.ctest.in | 0 .../CMake/FindMED.cmake | 6 +- src/Plugins/MEDReader/CMakeLists.txt | 103 + src/Plugins/MEDReader/Doc/ELNO.txt | 3 + src/Plugins/MEDReader/Doc/HowTo0.py | 16 + src/Plugins/MEDReader/IO/CMakeLists.txt | 49 + .../IO/MEDFileFieldRepresentationTree.cxx | 1459 ++++++++ .../IO/MEDFileFieldRepresentationTree.hxx | 189 + src/Plugins/MEDReader/IO/MEDTimeReq.cxx | 133 + src/Plugins/MEDReader/IO/MEDTimeReq.hxx | 72 + .../IO/MEDUtilities.cxx} | 32 +- .../IO/MEDUtilities.hxx} | 27 +- .../IO/Testing/CMakeLists.txt | 2 +- .../MEDReader/IO/Testing/Cxx/CMakeLists.txt | 67 + .../Cxx/TestMedDescendingPolyhedron.cxx | 0 .../IO/Testing/Cxx/TestMedParallelRead.cxx | 0 .../IO/Testing/Cxx/TestMedParallelWrite.cxx | 0 .../IO/Testing/Cxx/TestMedPolyhedron.cxx | 0 .../Cxx/TestMedReadDescendingPolyhedron.cxx | 0 .../IO/Testing/Cxx/TestMedReadPolyhedron.cxx | 0 .../IO/Testing/Cxx/TestMedReader.cxx | 5 +- .../IO/Testing/Cxx/TestMedWriteOcta12.cxx | 0 .../IO/Testing/Cxx/TestReading0.cxx} | 26 +- .../IO/config.h.cmake | 4 +- .../{MedReader => MEDReader}/IO/module.cmake | 9 +- .../IO}/vtkELNOFilter.cxx | 4 +- .../IO}/vtkELNOFilter.h | 2 +- .../MEDReader/IO/vtkELNOMeshFilter.cxx | 186 + .../IO}/vtkELNOMeshFilter.h | 2 +- .../IO}/vtkELNOSurfaceFilter.cxx | 4 +- .../IO}/vtkELNOSurfaceFilter.h | 2 +- .../MEDReader/IO/vtkExtractCellType.cxx | 463 +++ src/Plugins/MEDReader/IO/vtkExtractCellType.h | 71 + src/Plugins/MEDReader/IO/vtkExtractGroup.cxx | 651 ++++ src/Plugins/MEDReader/IO/vtkExtractGroup.h | 71 + .../MEDReader/IO/vtkGenerateVectors.cxx | 108 + .../IO/vtkGenerateVectors.h} | 36 +- src/Plugins/MEDReader/IO/vtkMEDReader.cxx | 368 ++ src/Plugins/MEDReader/IO/vtkMEDReader.h | 73 + .../MEDReader/ParaViewPlugin/CMakeLists.txt | 91 + .../Resources/Icons/pqCellData16.png | Bin .../Icons/pqCellDataForWholeMesh16.png | Bin 0 -> 239 bytes .../Resources/Icons/pqElnoData16.png | Bin .../Resources/Icons/pqPointData16.png | Bin .../Resources/Icons/pqQuadratureData16.png | Bin .../Resources/Icons/pqReloadFile16.png | Bin 0 -> 851 bytes .../Resources/MEDReaderClient.xml | 6 + .../Resources/MEDReaderClient2.xml | 10 + .../Resources/MEDReaderServer.xml | 423 +++ .../Resources/UI/ExtractCellTypePanel.ui | 101 + .../Resources/UI/ExtractGroupPanel.ui | 101 + .../Resources/UI/MEDReaderPanel.ui | 227 ++ .../ParaViewPlugin/Resources/pqMEDReader.qrc} | 5 +- .../ParaViewPlugin/VectBoolSpreadSheet.cxx | 298 ++ .../ParaViewPlugin/VectBoolSpreadSheet.h | 80 + .../ParaViewPlugin/VectBoolWidget.cxx | 195 + .../MEDReader/ParaViewPlugin/VectBoolWidget.h | 91 + .../ParaViewPlugin/pqExtractCellTypePanel.cxx | 162 + .../ParaViewPlugin/pqExtractCellTypePanel.h} | 46 +- .../ParaViewPlugin/pqExtractGroupPanel.cxx | 365 ++ .../ParaViewPlugin/pqExtractGroupPanel.h | 24 +- .../ParaViewPlugin/pqMEDReaderPanel.cxx | 459 +++ .../ParaViewPlugin/pqMEDReaderPanel.h | 61 + src/Plugins/MEDReader/TODO.txt | 42 + src/Plugins/MEDReader/Test/CMakeLists.txt | 27 + src/Plugins/MEDReader/Test/testMEDReader0.py | 124 + src/Plugins/MEDReader/Test/testMEDReader1.py | 59 + src/Plugins/MEDReader/Test/testMEDReader2.py | 111 + src/Plugins/MEDReader/Test/testMEDReader3.py | 121 + src/Plugins/MEDReader/Test/testMEDReader4.py | 95 + src/Plugins/MEDReader/Test/testMEDReader5.py | 115 + src/Plugins/MEDReader/Test/testMEDReader6.py | 99 + src/Plugins/MEDReader/Test/testMEDReader7.py | 98 + .../{MedReader => MEDReader}/plugin.cmake | 4 +- src/Plugins/MedReader/CMakeLists.txt | 97 - src/Plugins/MedReader/IO/CMakeLists.txt | 125 - .../MedReader/IO/Testing/Cxx/CMakeLists.txt | 77 - src/Plugins/MedReader/IO/vtkExtractGroup.cxx | 429 --- src/Plugins/MedReader/IO/vtkExtractGroup.h | 135 - .../MedReader/IO/vtkGenerateStructElement.cxx | 217 -- .../MedReader/IO/vtkGenerateStructElement.h | 58 - .../MedReader/IO/vtkMedCartesianGrid.h | 42 - .../MedReader/IO/vtkMedConstantAttribute.cxx | 66 - .../MedReader/IO/vtkMedConstantAttribute.h | 109 - .../MedReader/IO/vtkMedCurvilinearGrid.cxx | 185 - .../MedReader/IO/vtkMedCurvilinearGrid.h | 80 - src/Plugins/MedReader/IO/vtkMedDriver.cxx | 466 --- src/Plugins/MedReader/IO/vtkMedDriver.h | 232 -- src/Plugins/MedReader/IO/vtkMedDriver30.cxx | 2407 ------------- src/Plugins/MedReader/IO/vtkMedDriver30.h | 168 - .../MedReader/IO/vtkMedEntityArray.cxx | 532 --- src/Plugins/MedReader/IO/vtkMedEntityArray.h | 200 -- src/Plugins/MedReader/IO/vtkMedFactory.cxx | 45 - src/Plugins/MedReader/IO/vtkMedFactory.h | 44 - src/Plugins/MedReader/IO/vtkMedFamily.cxx | 63 - src/Plugins/MedReader/IO/vtkMedFamily.h | 83 - .../MedReader/IO/vtkMedFamilyOnEntity.cxx | 130 - .../MedReader/IO/vtkMedFamilyOnEntity.h | 100 - .../IO/vtkMedFamilyOnEntityOnProfile.cxx | 591 --- .../IO/vtkMedFamilyOnEntityOnProfile.h | 146 - src/Plugins/MedReader/IO/vtkMedField.cxx | 326 -- src/Plugins/MedReader/IO/vtkMedField.h | 176 - .../MedReader/IO/vtkMedFieldOnProfile.cxx | 88 - .../MedReader/IO/vtkMedFieldOnProfile.h | 126 - .../MedReader/IO/vtkMedFieldOverEntity.cxx | 56 - .../MedReader/IO/vtkMedFieldOverEntity.h | 81 - src/Plugins/MedReader/IO/vtkMedFieldStep.cxx | 77 - src/Plugins/MedReader/IO/vtkMedFieldStep.h | 115 - src/Plugins/MedReader/IO/vtkMedFile.cxx | 194 - src/Plugins/MedReader/IO/vtkMedFile.h | 141 - src/Plugins/MedReader/IO/vtkMedFilter.cxx | 63 - src/Plugins/MedReader/IO/vtkMedFilter.h | 49 - src/Plugins/MedReader/IO/vtkMedFraction.cxx | 211 -- src/Plugins/MedReader/IO/vtkMedFraction.h | 94 - src/Plugins/MedReader/IO/vtkMedGrid.cxx | 98 - src/Plugins/MedReader/IO/vtkMedGrid.h | 166 - src/Plugins/MedReader/IO/vtkMedGroup.h | 57 - src/Plugins/MedReader/IO/vtkMedIntArray.cxx | 42 - src/Plugins/MedReader/IO/vtkMedIntArray.h | 68 - .../MedReader/IO/vtkMedIntArrayInternal.cxx | 53 - .../MedReader/IO/vtkMedIntArrayInternal.h | 145 - .../MedReader/IO/vtkMedInterpolation.cxx | 55 - .../MedReader/IO/vtkMedInterpolation.h | 92 - src/Plugins/MedReader/IO/vtkMedLink.cxx | 99 - src/Plugins/MedReader/IO/vtkMedLink.h | 87 - .../MedReader/IO/vtkMedLocalization.cxx | 701 ---- src/Plugins/MedReader/IO/vtkMedLocalization.h | 154 - src/Plugins/MedReader/IO/vtkMedMesh.cxx | 269 -- src/Plugins/MedReader/IO/vtkMedMesh.h | 204 -- src/Plugins/MedReader/IO/vtkMedPolarGrid.h | 42 - src/Plugins/MedReader/IO/vtkMedProfile.cxx | 69 - src/Plugins/MedReader/IO/vtkMedProfile.h | 87 - src/Plugins/MedReader/IO/vtkMedReader.cxx | 3158 ----------------- src/Plugins/MedReader/IO/vtkMedReader.h | 393 -- .../MedReader/IO/vtkMedRegularGrid.cxx | 217 -- src/Plugins/MedReader/IO/vtkMedRegularGrid.h | 84 - src/Plugins/MedReader/IO/vtkMedSelection.cxx | 118 - src/Plugins/MedReader/IO/vtkMedSelection.h | 62 - src/Plugins/MedReader/IO/vtkMedSetGet.h | 136 - .../MedReader/IO/vtkMedStructElement.cxx | 95 - .../MedReader/IO/vtkMedStructElement.h | 150 - .../MedReader/IO/vtkMedSupportMesh.cxx | 63 - src/Plugins/MedReader/IO/vtkMedSupportMesh.h | 101 - .../MedReader/IO/vtkMedUnstructuredGrid.cxx | 366 -- .../MedReader/IO/vtkMedUnstructuredGrid.h | 82 - src/Plugins/MedReader/IO/vtkMedUtilities.cxx | 890 ----- src/Plugins/MedReader/IO/vtkMedUtilities.h | 468 --- .../MedReader/IO/vtkMedVariableAttribute.cxx | 60 - .../MedReader/IO/vtkMedVariableAttribute.h | 83 - .../MedReader/ParaViewPlugin/CMakeLists.txt | 103 - .../Resources/MedReaderClient.xml | 7 - .../Resources/MedReaderServer.xml | 494 --- .../Resources/UI/ExtractGroupPanel.ui | 141 - .../Resources/UI/MedReaderPanel.ui | 286 -- .../ParaViewPlugin/pqExtractGroupPanel.cxx | 177 - .../ParaViewPlugin/pqMedReaderPanel.cxx | 338 -- .../vtkSMMedGroupSelectionDomain.cxx | 78 - .../vtkSMMedGroupSelectionDomain.h | 49 - 171 files changed, 7742 insertions(+), 20512 deletions(-) delete mode 100755 src/Plugins/ExtraxtFieldFilter/CMakeLists.txt delete mode 100755 src/Plugins/ExtraxtFieldFilter/ExtractFieldFilter.xml delete mode 100644 src/Plugins/ExtraxtFieldFilter/ExtractFieldGUI.xml delete mode 100644 src/Plugins/ExtraxtFieldFilter/pqExtractField.qrc delete mode 100644 src/Plugins/ExtraxtFieldFilter/resources/extract_field.png delete mode 100644 src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.cxx delete mode 100644 src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.h delete mode 100644 src/Plugins/IntegrationPoints/CMakeLists.txt delete mode 100644 src/Plugins/IntegrationPoints/ELNOFilter.xml delete mode 100644 src/Plugins/IntegrationPoints/ELNOFilterClient.xml delete mode 100644 src/Plugins/IntegrationPoints/vtkELNOMeshFilter.cxx rename src/Plugins/{MedReader => MEDReader}/CMake/CTestCustom.ctest.in (100%) rename src/Plugins/{MedReader => MEDReader}/CMake/FindMED.cmake (98%) create mode 100644 src/Plugins/MEDReader/CMakeLists.txt create mode 100644 src/Plugins/MEDReader/Doc/ELNO.txt create mode 100644 src/Plugins/MEDReader/Doc/HowTo0.py create mode 100644 src/Plugins/MEDReader/IO/CMakeLists.txt create mode 100644 src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx create mode 100644 src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx create mode 100644 src/Plugins/MEDReader/IO/MEDTimeReq.cxx create mode 100644 src/Plugins/MEDReader/IO/MEDTimeReq.hxx rename src/Plugins/{MedReader/IO/vtkMed.h => MEDReader/IO/MEDUtilities.cxx} (63%) rename src/Plugins/{MedReader/IO/vtkMedPolarGrid.cxx => MEDReader/IO/MEDUtilities.hxx} (67%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/CMakeLists.txt (97%) create mode 100644 src/Plugins/MEDReader/IO/Testing/Cxx/CMakeLists.txt rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedDescendingPolyhedron.cxx (100%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedParallelRead.cxx (100%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedParallelWrite.cxx (100%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedPolyhedron.cxx (100%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedReadDescendingPolyhedron.cxx (100%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedReadPolyhedron.cxx (100%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedReader.cxx (95%) rename src/Plugins/{MedReader => MEDReader}/IO/Testing/Cxx/TestMedWriteOcta12.cxx (100%) rename src/Plugins/{MedReader/IO/vtkMedCartesianGrid.cxx => MEDReader/IO/Testing/Cxx/TestReading0.cxx} (66%) rename src/Plugins/{MedReader => MEDReader}/IO/config.h.cmake (92%) rename src/Plugins/{MedReader => MEDReader}/IO/module.cmake (56%) rename src/Plugins/{IntegrationPoints => MEDReader/IO}/vtkELNOFilter.cxx (97%) rename src/Plugins/{IntegrationPoints => MEDReader/IO}/vtkELNOFilter.h (97%) create mode 100644 src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx rename src/Plugins/{IntegrationPoints => MEDReader/IO}/vtkELNOMeshFilter.h (96%) rename src/Plugins/{IntegrationPoints => MEDReader/IO}/vtkELNOSurfaceFilter.cxx (98%) rename src/Plugins/{IntegrationPoints => MEDReader/IO}/vtkELNOSurfaceFilter.h (96%) create mode 100644 src/Plugins/MEDReader/IO/vtkExtractCellType.cxx create mode 100644 src/Plugins/MEDReader/IO/vtkExtractCellType.h create mode 100644 src/Plugins/MEDReader/IO/vtkExtractGroup.cxx create mode 100644 src/Plugins/MEDReader/IO/vtkExtractGroup.h create mode 100644 src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx rename src/Plugins/{MedReader/IO/vtkMedGroup.cxx => MEDReader/IO/vtkGenerateVectors.h} (59%) create mode 100644 src/Plugins/MEDReader/IO/vtkMEDReader.cxx create mode 100644 src/Plugins/MEDReader/IO/vtkMEDReader.h create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt rename src/Plugins/{MedReader => MEDReader}/ParaViewPlugin/Resources/Icons/pqCellData16.png (100%) mode change 100755 => 100644 create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqCellDataForWholeMesh16.png rename src/Plugins/{MedReader => MEDReader}/ParaViewPlugin/Resources/Icons/pqElnoData16.png (100%) rename src/Plugins/{MedReader => MEDReader}/ParaViewPlugin/Resources/Icons/pqPointData16.png (100%) mode change 100755 => 100644 rename src/Plugins/{MedReader => MEDReader}/ParaViewPlugin/Resources/Icons/pqQuadratureData16.png (100%) mode change 100755 => 100644 create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqReloadFile16.png create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient.xml create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractCellTypePanel.ui create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui rename src/Plugins/{MedReader/ParaViewPlugin/Resources/pqMedReader.qrc => MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc} (59%) create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.h create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx rename src/Plugins/{MedReader/ParaViewPlugin/pqMedReaderPanel.h => MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h} (58%) create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx rename src/Plugins/{MedReader => MEDReader}/ParaViewPlugin/pqExtractGroupPanel.h (81%) create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx create mode 100644 src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h create mode 100644 src/Plugins/MEDReader/TODO.txt create mode 100644 src/Plugins/MEDReader/Test/CMakeLists.txt create mode 100644 src/Plugins/MEDReader/Test/testMEDReader0.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader1.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader2.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader3.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader4.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader5.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader6.py create mode 100644 src/Plugins/MEDReader/Test/testMEDReader7.py rename src/Plugins/{MedReader => MEDReader}/plugin.cmake (74%) delete mode 100644 src/Plugins/MedReader/CMakeLists.txt delete mode 100644 src/Plugins/MedReader/IO/CMakeLists.txt delete mode 100644 src/Plugins/MedReader/IO/Testing/Cxx/CMakeLists.txt delete mode 100644 src/Plugins/MedReader/IO/vtkExtractGroup.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkExtractGroup.h delete mode 100644 src/Plugins/MedReader/IO/vtkGenerateStructElement.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkGenerateStructElement.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedCartesianGrid.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedConstantAttribute.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedConstantAttribute.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedDriver.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedDriver.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedDriver30.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedDriver30.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedEntityArray.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedEntityArray.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFactory.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFactory.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFamily.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFamily.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedField.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedField.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFieldOnProfile.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFieldOnProfile.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFieldOverEntity.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFieldOverEntity.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFieldStep.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFieldStep.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFile.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFile.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFilter.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFilter.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedFraction.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedFraction.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedGrid.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedGrid.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedGroup.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedIntArray.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedIntArray.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedIntArrayInternal.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedIntArrayInternal.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedInterpolation.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedInterpolation.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedLink.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedLink.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedLocalization.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedLocalization.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedMesh.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedMesh.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedPolarGrid.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedProfile.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedProfile.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedReader.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedReader.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedRegularGrid.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedRegularGrid.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedSelection.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedSelection.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedSetGet.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedStructElement.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedStructElement.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedSupportMesh.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedSupportMesh.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedUtilities.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedUtilities.h delete mode 100644 src/Plugins/MedReader/IO/vtkMedVariableAttribute.cxx delete mode 100644 src/Plugins/MedReader/IO/vtkMedVariableAttribute.h delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/CMakeLists.txt delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderClient.xml delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderServer.xml delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/Resources/UI/MedReaderPanel.ui delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.cxx delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.cxx delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.cxx delete mode 100644 src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.h diff --git a/src/PV_SWIG/VTKWrapping/presentations.py b/src/PV_SWIG/VTKWrapping/presentations.py index 05b78de4..fb5c7584 100644 --- a/src/PV_SWIG/VTKWrapping/presentations.py +++ b/src/PV_SWIG/VTKWrapping/presentations.py @@ -783,61 +783,6 @@ def select_cells_with_data(proxy, on_points=None, on_cells=None): proxy.Entity = cell_types_on proxy.UpdatePipeline() - -def extract_groups_for_field(proxy, field_name, field_entity, force=False): - """Exctract only groups which have the field. - - Arguments: - proxy: the pipeline object, containig data - field_name: the field name - field_entity: the field entity - force: if True - ExtractGroup object will be created in any case - - Returns: - ExtractGroup object: if not all groups have the field or - the force argument is true - The initial proxy: if no groups had been filtered. - - """ - source = proxy - - # Remember the state - initial_groups = list(proxy.Groups) - - # Get data information for the field entity - entity_data_info = None - field_data = proxy.GetFieldDataInformation() - - if field_name in field_data.keys(): - entity_data_info = field_data - elif field_entity == EntityType.CELL: - entity_data_info = proxy.GetCellDataInformation() - elif field_entity == EntityType.NODE: - entity_data_info = proxy.GetPointDataInformation() - - # Collect groups for extraction - groups_to_extract = [] - - for group in initial_groups: - proxy.Groups = [group] - proxy.UpdatePipeline() - if field_name in entity_data_info.keys(): - groups_to_extract.append(group) - - # Restore state - proxy.Groups = initial_groups - proxy.UpdatePipeline() - - # Extract groups if necessary - if force or (len(groups_to_extract) < len(initial_groups)): - extract_group = pv.ExtractGroup(proxy) - extract_group.Groups = groups_to_extract - extract_group.UpdatePipeline() - source = extract_group - - return source - - def if_possible(proxy, field_name, entity, prs_type): """Check if the presentation creation is possible on the given field.""" result = True @@ -1074,12 +1019,8 @@ def ScalarMapOnField(proxy, entity, field_name, timestamp_nb, pv.GetRenderView().ViewTime = time_value pv.UpdatePipeline(time_value, proxy) - # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity, - force=True) - # Get Scalar Map representation object - scalarmap = pv.GetRepresentation(new_proxy) + scalarmap = pv.GetRepresentation(proxy) # Get lookup table lookup_table = get_lookup_table(field_name, nb_components, vector_mode) @@ -1423,8 +1364,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb, pv.UpdatePipeline(time_value, proxy) # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity) - source = new_proxy + source = proxy # Cell centers if is_data_on_cells(proxy, field_name): @@ -1467,7 +1407,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb, glyph.SetScaleFactor = scale_factor else: def_scale = get_default_scale(PrsTypeEnum.DEFORMEDSHAPE, - new_proxy, entity, field_name) + proxy, entity, field_name) glyph.SetScaleFactor = def_scale glyph.UpdatePipeline() @@ -1542,11 +1482,8 @@ def DeformedShapeOnField(proxy, entity, field_name, pv.GetRenderView().ViewTime = time_value pv.UpdatePipeline(time_value, proxy) - # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity) - # Do merge - source = pv.MergeBlocks(new_proxy) + source = pv.MergeBlocks(proxy) # Cell data to point data if is_data_on_cells(proxy, field_name): @@ -1660,11 +1597,8 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name, scalar_field_entity = entity scalar_field = field_name - # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity) - # Do merge - source = pv.MergeBlocks(new_proxy) + source = pv.MergeBlocks(proxy) # Cell data to point data if is_data_on_cells(proxy, field_name): @@ -1686,7 +1620,7 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name, warp_vector.ScaleFactor = scale_factor else: def_scale = get_default_scale(PrsTypeEnum.DEFORMEDSHAPE, - new_proxy, entity, field_name) + proxy, entity, field_name) warp_vector.ScaleFactor = def_scale # Get Defromed Shape And Scalar Map representation object @@ -1767,11 +1701,8 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb, pv.GetRenderView().ViewTime = time_value pv.UpdatePipeline(time_value, proxy) - # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity) - # Do merge - merge_blocks = pv.MergeBlocks(new_proxy) + merge_blocks = pv.MergeBlocks(proxy) merge_blocks.UpdatePipeline() poly_data = None @@ -1927,11 +1858,8 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb, pv.GetRenderView().ViewTime = time_value pv.UpdatePipeline(time_value, proxy) - # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity) - # Do merge - source = pv.MergeBlocks(new_proxy) + source = pv.MergeBlocks(proxy) # Transform cell data into point data if necessary if is_data_on_cells(proxy, field_name): @@ -2049,8 +1977,7 @@ def GaussPointsOnField(proxy, entity, field_name, pv.GetRenderView().ViewTime = time_value proxy.UpdatePipeline(time=time_value) - # Extract only groups with data for the field - source = extract_groups_for_field(proxy, field_name, entity) + source = proxy # Quadrature point arrays qp_arrays = proxy.QuadraturePointArrays.Available @@ -2348,11 +2275,8 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb, pv.GetRenderView().ViewTime = time_value pv.UpdatePipeline(time_value, proxy) - # Extract only groups with data for the field - new_proxy = extract_groups_for_field(proxy, field_name, entity) - # Do merge - source = pv.MergeBlocks(new_proxy) + source = pv.MergeBlocks(proxy) # Cell data to point data if is_data_on_cells(proxy, field_name): @@ -2387,7 +2311,7 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb, lookup_table = get_lookup_table(field_name, nb_components, vector_mode) # Set field range if necessary - data_range = get_data_range(new_proxy, entity, + data_range = get_data_range(proxy, entity, field_name, vector_mode) lookup_table.LockScalarRange = 1 lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0] diff --git a/src/Plugins/CMakeLists.txt b/src/Plugins/CMakeLists.txt index 9a4bd3ba..b7923492 100755 --- a/src/Plugins/CMakeLists.txt +++ b/src/Plugins/CMakeLists.txt @@ -29,14 +29,12 @@ ENDIF() SET(_subdirs #Filter #ToolBar - MedReader + MEDReader ParaMEDCorba TableReader NavigationMode - IntegrationPoints ElevationSurface ScaleVector - ExtraxtFieldFilter ) FOREACH(_dir ${_subdirs}) diff --git a/src/Plugins/ExtraxtFieldFilter/CMakeLists.txt b/src/Plugins/ExtraxtFieldFilter/CMakeLists.txt deleted file mode 100755 index 79b10e6a..00000000 --- a/src/Plugins/ExtraxtFieldFilter/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# create a paraview plugin containing server manager xml and the server -# manager classes to build -# this plugin can be loaded on the server side - - -cmake_minimum_required(VERSION 2.8) - -FIND_PACKAGE(ParaView REQUIRED) -INCLUDE(${PARAVIEW_USE_FILE}) - -ADD_PARAVIEW_PLUGIN(ExtractFieldFilter "1.0" - SERVER_MANAGER_XML ExtractFieldFilter.xml - SERVER_MANAGER_SOURCES vtkExtractFieldFilter.cxx - GUI_RESOURCES pqExtractField.qrc - GUI_RESOURCE_FILES ExtractFieldGUI.xml - ) - -INSTALL( - TARGETS ExtractFieldFilter - DESTINATION lib/paraview -) diff --git a/src/Plugins/ExtraxtFieldFilter/ExtractFieldFilter.xml b/src/Plugins/ExtraxtFieldFilter/ExtractFieldFilter.xml deleted file mode 100755 index d7d850eb..00000000 --- a/src/Plugins/ExtraxtFieldFilter/ExtractFieldFilter.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Plugins/ExtraxtFieldFilter/ExtractFieldGUI.xml b/src/Plugins/ExtraxtFieldFilter/ExtractFieldGUI.xml deleted file mode 100644 index 91661773..00000000 --- a/src/Plugins/ExtraxtFieldFilter/ExtractFieldGUI.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/Plugins/ExtraxtFieldFilter/pqExtractField.qrc b/src/Plugins/ExtraxtFieldFilter/pqExtractField.qrc deleted file mode 100644 index 7f06fb19..00000000 --- a/src/Plugins/ExtraxtFieldFilter/pqExtractField.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - resources/extract_field.png - - \ No newline at end of file diff --git a/src/Plugins/ExtraxtFieldFilter/resources/extract_field.png b/src/Plugins/ExtraxtFieldFilter/resources/extract_field.png deleted file mode 100644 index a8a50e87bd6a9d886f8de2dfa8a58de4ae1c709e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1254 zcmVI^(OhJ_5KnS#=iDXQWAkn2PG`jH*(4AnSD>o*tj2kgg z+~8JarHMOrWi&Q~DopSrSP+ELfxt{>I-PlM=6&3IkBd^;X{QxE$;-Pr@166z=bYa; zhp>sh_xrHc!t*?MsS#w;9vsKHZ|^@D_ANB`73Wb!nY7!?JNHi#wL97J~ zujw&ucfR}GA-Ms-bsS9Y+Y2Ir=Hepm-mSy;10-5wZQ~IEN=g{FgBqVh5S#UFwT*%F zrYtHH@)#d4p*ULDltn6K@tge`&7i#&_)8+pSc~@<*e-?u{Q7TAMMQ|WhabA1<7T&p zASMJcp&zNUVM4Ec^wP|Sk)}hjraK!V=!NlZ5AKctw-f?}LLO2O!Z1V-_~->a^dcV(+(4k3 zuw;;vB}}9qM@EhziR0Rh>(|OBj=w&97M(tQ8l(9v+Dl#det;kdHn1q|jiQW$gZdZ< zOc&R#UO}tb95h)uR4NsmIdjH!loFHs_Ts6^lh|E;6rMK%V+_J5LO%@eKVcL?8x7Z0 zD30b4hdo4LC}w76+)AY~2yjm!gCN*$jBx;9v{1m*$>jXMypgR0>Bs%O$s5V zN~Kcy`D4eXCU)-JrIadZtuy_8-wneMTInBOls@LoD=g*&?ZMWNV*4oR=JPV*z ztyb-N0059glqMlcf@r%CqDVw}5+Y4RE&&omU}nS22{ZTD+K#oh$;^#=?*M?QR;wF# za-~uMEsGFBI7H+MAyP!-5|IMYGV7QvGizp!EpyD)MwU5YYb`VLigN(?2lYiiH#E1R QdH?_b07*qoM6N<$g66q79RL6T diff --git a/src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.cxx b/src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.cxx deleted file mode 100644 index d707e3a3..00000000 --- a/src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.cxx +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkExtractFieldFilter.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -using namespace std; - - - -bool isContainsName(const std::list& aList, const std::string& theName) -{ - std::list::const_iterator aIt; - for (aIt = aList.begin(); aIt != aList.end(); aIt++) { - if ((*aIt).compare(theName) == 0) - return true; - } - return false; -} - - -void appendIfNotExists(const std::list& theSrc, std::list& theDest) -{ - std::list::const_iterator aIt; - for (aIt = theSrc.begin(); aIt != theSrc.end(); aIt++) { - if (!isContainsName(theDest, *aIt)) - theDest.push_back(*aIt); - } -} - - - - -vtkStandardNewMacro(vtkExtractFieldFilter); - - - -vtkExtractFieldFilter::vtkExtractFieldFilter() -:vtkMultiBlockDataSetAlgorithm() -{ - this->Field = NULL; - this->FieldList = vtkStringArray::New(); -} - - -vtkExtractFieldFilter::~vtkExtractFieldFilter() -{ - this->FieldList->Delete(); - if (this->Field) - delete [] this->Field; -} - -//---------------------------------------------------------------------------- -int vtkExtractFieldFilter::RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** theInputVector, - vtkInformationVector* theOutputVector) -{ - // get the info objects - vtkMultiBlockDataSet* aInput = vtkMultiBlockDataSet::GetData(theInputVector[0], 0); - vtkMultiBlockDataSet* aOutput = vtkMultiBlockDataSet::GetData(theOutputVector, 0); - - aOutput->CopyStructure(aInput); - - // Copy selected blocks over to the output. - int i; - std::list toDelList; - for (i = 0; i < aInput->GetNumberOfBlocks(); i++) { - this->CopySubTree(i, aOutput, aInput, toDelList); - } - std::list::const_reverse_iterator aIt; - for (aIt = toDelList.rbegin(); aIt != toDelList.rend(); ++aIt) - aOutput->RemoveBlock(*aIt); - return 1; -} - -//---------------------------------------------------------------------------- -int vtkExtractFieldFilter::RequestInformation(vtkInformation* reqInfo, - vtkInformationVector **theInputVector, - vtkInformationVector *theOutputVector) -{ - // get the info objects - vtkMultiBlockDataSet* aInput = vtkMultiBlockDataSet::GetData(theInputVector[0], 0); - vtkMultiBlockDataSet* aOutput = vtkMultiBlockDataSet::GetData(theOutputVector, 0); - - vtkDataObjectTreeIterator* aIter = aInput->NewTreeIterator(); - aIter->VisitOnlyLeavesOff(); - int i = 0; - std::list aList; - for (aIter->InitTraversal(); !aIter->IsDoneWithTraversal(); aIter->GoToNextItem()) { - std::list aSubList = this->GetListOfFields(aIter, aInput); - appendIfNotExists(aSubList, aList); - } - this->FieldList->SetNumberOfValues(aList.size()); - std::list::const_iterator aIt; - i = 0; - for (aIt = aList.begin(); aIt != aList.end(); aIt++) { - this->FieldList->SetValue(i, *aIt); - i++; - } - - return this->Superclass::RequestInformation(reqInfo, theInputVector, theOutputVector); -} - -//---------------------------------------------------------------------------- -void vtkExtractFieldFilter::CopySubTree(int theLoc, - vtkMultiBlockDataSet* theOutput, - vtkMultiBlockDataSet* theInput, - std::list& toDel) -{ - vtkDataObject* aInputNode = theInput->GetBlock(theLoc); - if (aInputNode->IsA("vtkCompositeDataSet")) { - vtkMultiBlockDataSet* aCInput = vtkMultiBlockDataSet::SafeDownCast(aInputNode); - vtkMultiBlockDataSet* aCOutput = vtkMultiBlockDataSet::SafeDownCast(theOutput->GetBlock(theLoc)); - std::list toDelList; - int i; - for (i = 0; i < aCInput->GetNumberOfBlocks(); i++) { - this->CopySubTree(i, aCOutput, aCInput, toDelList); - } - std::list::const_reverse_iterator aIt; - for (aIt = toDelList.rbegin(); aIt != toDelList.rend(); ++aIt) - aCOutput->RemoveBlock(*aIt); - if (aCOutput->GetNumberOfBlocks() == 0) - toDel.push_back(theLoc); - } else { - if (IsToCopy(aInputNode)) { - vtkDataObject* aClone = aInputNode->NewInstance(); - aClone->ShallowCopy(aInputNode); - theOutput->SetBlock(theLoc, aClone); - aClone->Delete(); - } else { - toDel.push_back(theLoc); - } - } -} - -//---------------------------------------------------------------------------- -std::list vtkExtractFieldFilter::GetListOfFields(vtkDataObjectTreeIterator* theLoc, vtkMultiBlockDataSet* theInput) -{ - std::list aList; - vtkDataObject* aInputNode = theInput->GetDataSet(theLoc); - if (!aInputNode->IsA("vtkCompositeDataSet")) { - std::list aSubList = this->GetListOfFields(aInputNode); - appendIfNotExists(aSubList, aList); - } else { - vtkCompositeDataSet* aCInput = vtkCompositeDataSet::SafeDownCast(aInputNode); - vtkCompositeDataIterator* aIter = aCInput->NewIterator(); - vtkDataObjectTreeIterator* aTreeIter = vtkDataObjectTreeIterator::SafeDownCast(aIter); - if (aTreeIter) { - aTreeIter->VisitOnlyLeavesOff(); - } - for (aIter->InitTraversal(); !aIter->IsDoneWithTraversal(); aIter->GoToNextItem()) { - vtkDataObject* aCurNode = aIter->GetCurrentDataObject(); - std::list aSubList = this->GetListOfFields(aCurNode); - appendIfNotExists(aSubList, aList); - } - aIter->Delete(); - } - return aList; -} - -//---------------------------------------------------------------------------- -std::list vtkExtractFieldFilter::GetListOfFields(vtkDataObject* theObject) const -{ - std::list aList; - - if (theObject->IsA("vtkDataSet")) { - vtkDataSet* aDataSet = vtkDataSet::SafeDownCast(theObject); - vtkPointData* aPntData = aDataSet->GetPointData(); - int aNbArrays = aPntData->GetNumberOfArrays(); - for (int i = 0; i < aNbArrays; i++) { - const char* aName = aPntData->GetArrayName(i); - aList.push_back(aName); - } - vtkCellData* aCellData = aDataSet->GetCellData(); - aNbArrays = aCellData->GetNumberOfArrays(); - for (int i = 0; i < aNbArrays; i++) { - const char* aName = aCellData->GetArrayName(i); - aList.push_back(aName); - } - } - return aList; -} - - -//---------------------------------------------------------------------------- -bool vtkExtractFieldFilter::IsToCopy(vtkDataObject* theObject) const -{ - if (this->Field == NULL) - return true; - - std::list aList = this->GetListOfFields(theObject); - - std::list::const_iterator aIt; - std::string aTestStr = this->Field; - for (aIt = aList.begin(); aIt != aList.end(); ++aIt) - if (aTestStr.compare(*aIt) == 0) - return true; - - return false; -} - - -//---------------------------------------------------------------------------- -void vtkExtractFieldFilter::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - os << indent << "Field name: " << this->Field << endl; - this->FieldList->PrintSelf(os, indent); -} - diff --git a/src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.h b/src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.h deleted file mode 100644 index 80049fba..00000000 --- a/src/Plugins/ExtraxtFieldFilter/vtkExtractFieldFilter.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkExtractFieldFilter_h -#define __vtkExtractFieldFilter_h - -#include -#include -#include - -class vtkDataObjectTreeIterator; -class vtkStringArray; - -/** - * Implements a class of a filter which extract a support mesh of a data field. - * It processes MultiBlockDataSet data structure extracting blocks which contain - * a field with FieldName. - * If field name is not defined then the filter just copies input data to output data -*/ -class vtkExtractFieldFilter : public vtkMultiBlockDataSetAlgorithm -{ -public: - /// Returns pointer on a new instance of the class - static vtkExtractFieldFilter* New(); - - vtkTypeMacro(vtkExtractFieldFilter, vtkMultiBlockDataSetAlgorithm); - - /// Prints current state of the objects - virtual void PrintSelf(ostream& os, vtkIndent indent); - - virtual vtkStringArray* GetFieldList() { return FieldList; } - vtkSetStringMacro(Field); - -protected: - /// Constructor - vtkExtractFieldFilter(); - - /// Destructor - virtual ~vtkExtractFieldFilter(); - - /// A method which is called on filtering data - virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - - virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - - /// Copies a sub-tree defined by a Data Set Block - void CopySubTree(int theLoc, - vtkMultiBlockDataSet* theOutput, - vtkMultiBlockDataSet* theInput, - std::list& toDel); - - /// Returns a list of strings with names of fields defined in the given Data Object - std::list GetListOfFields(vtkDataObject* theObject) const; - std::list GetListOfFields(vtkDataObjectTreeIterator* theLoc, vtkMultiBlockDataSet* theInput); - - /// Returns True if the given Data Object has to be copied into output - bool IsToCopy(vtkDataObject* theObject) const; - -private: - /// Methods for copy of the filter: Not implemented - vtkExtractFieldFilter(const vtkExtractFieldFilter&); // Not implemented - void operator=(const vtkExtractFieldFilter&); // Not implemented - - char* Field; - vtkStringArray* FieldList; -}; - -#endif diff --git a/src/Plugins/IntegrationPoints/CMakeLists.txt b/src/Plugins/IntegrationPoints/CMakeLists.txt deleted file mode 100644 index 0391f94e..00000000 --- a/src/Plugins/IntegrationPoints/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -PROJECT(ELNOFilter) -cmake_minimum_required(VERSION 2.6) - -cmake_policy(SET CMP0003 NEW) - - -FIND_PACKAGE(ParaView REQUIRED) -INCLUDE(${PARAVIEW_USE_FILE}) - -SET(SRCS - vtkELNOFilter.cxx - vtkELNOMeshFilter.cxx - vtkELNOSurfaceFilter.cxx - ) - -ADD_PARAVIEW_PLUGIN(ELNOFilter "1.0" - SERVER_MANAGER_XML ELNOFilter.xml - GUI_RESOURCE_FILES ELNOFilterClient.xml - SERVER_MANAGER_SOURCES ${SRCS}) - -install(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION lib/paraview - LIBRARY DESTINATION lib/paraview - ARCHIVE DESTINATION lib/paraview - ) - diff --git a/src/Plugins/IntegrationPoints/ELNOFilter.xml b/src/Plugins/IntegrationPoints/ELNOFilter.xml deleted file mode 100644 index 4d2322c0..00000000 --- a/src/Plugins/IntegrationPoints/ELNOFilter.xml +++ /dev/null @@ -1,281 +0,0 @@ - - - - - - - "Create a point set with data at quadrature points." - - - - - - - - - - - - - - - - - - - Specifies the offset array from which we generate ELNO points. - - - - - - - - - - - - - - - - - - - - - - - "Create a point set with data at quadrature points." - - - - - - - - - - - - - - - - - - - Specifies the offset array from which we generate Gauss points. - - - - - - - - - - - - - - - - - - - "Create a Mesh with ELNO values mapped at each - vertex." - - - - - - - - - - - - - - - - - - - Specifies the offset array from which we generate ELNO points. - - - - - - - - - - - - - - - - - - - "Extract the surface of a dataset with ELNO values." - - - - - - - - - - - - - - - - - - - Specifies the offset array from which we generate ELNO points. - - - - - - - - - - - - - - - - - - diff --git a/src/Plugins/IntegrationPoints/ELNOFilterClient.xml b/src/Plugins/IntegrationPoints/ELNOFilterClient.xml deleted file mode 100644 index 1376440c..00000000 --- a/src/Plugins/IntegrationPoints/ELNOFilterClient.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/Plugins/IntegrationPoints/vtkELNOMeshFilter.cxx b/src/Plugins/IntegrationPoints/vtkELNOMeshFilter.cxx deleted file mode 100644 index b4bec6de..00000000 --- a/src/Plugins/IntegrationPoints/vtkELNOMeshFilter.cxx +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkELNOMeshFilter.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkPolyDataAlgorithm.h" -#include "vtkPolyData.h" -#include "vtkIdTypeArray.h" -#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" -#include "vtkQuadratureSchemeDefinition.h" -#include "vtkUnstructuredGrid.h" -#include "vtkShrinkFilter.h" -#include "vtkSmartPointer.h" -#include "vtkPointData.h" -#include "vtkCellData.h" -#include "vtkIdList.h" - -//vtkCxxRevisionMacro(vtkELNOMeshFilter, "$Revision$") -//; -vtkStandardNewMacro(vtkELNOMeshFilter) -; - -vtkELNOMeshFilter::vtkELNOMeshFilter() -{ -} - -vtkELNOMeshFilter::~vtkELNOMeshFilter() -{ -} - -int vtkELNOMeshFilter::RequestData(vtkInformation *request, - vtkInformationVector **input, vtkInformationVector *output) -{ - vtkUnstructuredGrid *usgIn = vtkUnstructuredGrid::SafeDownCast( - input[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT())); - - vtkUnstructuredGrid *usgOut = vtkUnstructuredGrid::SafeDownCast( - output->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT())); - - vtkIdTypeArray* usg_offsets = vtkIdTypeArray::SafeDownCast( - this->GetInputArrayToProcess(0, input)); - - if(usgIn == NULL || usg_offsets == NULL || usgOut == NULL) - { - vtkDebugMacro("vtkELNOMeshFilter no correctly configured : offsets = " << usg_offsets); - return 1; - } - - vtkIdTypeArray* a = vtkIdTypeArray::SafeDownCast( - usgIn->GetCellData()->GetArray(usg_offsets->GetName())); - - vtkInformationVector *inArrayVec = - this->Information->Get(INPUT_ARRAYS_TO_PROCESS()); - - // first shrink the input - vtkUnstructuredGrid* usgInClone = usgIn->NewInstance(); - - usgInClone->ShallowCopy(usgIn); - - vtkSmartPointer shrink = - vtkSmartPointer::New(); - shrink->SetInputData(usgInClone); - shrink->SetShrinkFactor(0.9999); - shrink->Update(); - vtkUnstructuredGrid* shrinked = shrink->GetOutput(); - - usgInClone->Delete(); - - usgOut->ShallowCopy(shrinked); - - vtkIdTypeArray* offsets = vtkIdTypeArray::SafeDownCast( - shrinked->GetCellData()->GetArray(usg_offsets->GetName())); - - // now copy ELNO data. Start by verifying if it is possible to - // shallow copy the array. - vtkInformation *info = offsets->GetInformation(); - vtkInformationQuadratureSchemeDefinitionVectorKey *key = - vtkQuadratureSchemeDefinition::DICTIONARY(); - if(!key->Has(info)) - { - vtkDebugMacro("Dictionary is not present in array " << offsets->GetName() << " " << offsets << " Aborting." ); - return 0; - } - int dictSize = key->Size(info); - vtkQuadratureSchemeDefinition **dict = - new vtkQuadratureSchemeDefinition *[dictSize]; - key->GetRange(info, dict, 0, 0, dictSize); - - vtkIdType nVerts = shrinked->GetNumberOfPoints(); - vtkIdType ncell = usgIn->GetNumberOfCells(); - // first loop through all cells to check if a shallow copy is possible - bool shallowok = true; - vtkIdType previous = 0; - - for(vtkIdType cellId = 0; cellId < ncell; cellId++) - { - vtkIdType offset = offsets->GetValue(cellId); - if(offset != previous) - { - shallowok = false; - break; - } - int cellType = usgIn->GetCellType(cellId); - - if(dict[cellType] == NULL) - { - previous = offset; - } - else - { - previous = offset + dict[cellType]->GetNumberOfQuadraturePoints(); - } - } - if(previous != nVerts) - { - shallowok = false; - } - - vtkFieldData* fielddata = usgIn->GetFieldData(); - for(int index = 0; index < fielddata->GetNumberOfArrays(); index++) - { - vtkDataArray* data = fielddata->GetArray(index); - if(data == NULL) - continue; - - vtkInformation* info = data->GetInformation(); - const char* arrayOffsetName = info->Get( - vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME()); - - if(arrayOffsetName == NULL || - strcmp(arrayOffsetName, offsets->GetName()) != 0) - { - shrinked->GetFieldData()->AddArray(data); - continue; - } - - if(shallowok) - { - usgOut->GetPointData()->AddArray(data); - } - else - { - vtkDataArray* newArray = data->NewInstance(); - newArray->SetName(data->GetName()); - usgOut->GetPointData()->AddArray(newArray); - newArray->SetNumberOfComponents(data->GetNumberOfComponents()); - newArray->SetNumberOfTuples(usgOut->GetNumberOfPoints()); - newArray->CopyComponentNames(data); - newArray->Delete(); - vtkIdList *ids = vtkIdList::New(); - - for(vtkIdType cellId = 0; cellId < ncell; cellId++) - { - vtkIdType offset = offsets->GetValue(cellId); - int cellType = shrinked->GetCellType(cellId); - shrinked->GetCellPoints(cellId, ids); - for(int id = 0; id < dict[cellType]->GetNumberOfQuadraturePoints(); id++) - { - const double * w = dict[cellType]->GetShapeFunctionWeights(id); - int j; - for(j = 0; j < dict[cellType]->GetNumberOfNodes(); j++) - { - if(w[j] == 1.0) - break; - } - if(j == dict[cellType]->GetNumberOfNodes()) - { - j = id; - } - newArray->SetTuple(ids->GetId(id), offset + j, data); - } - } - ids->FastDelete(); - } - } - - delete[] dict; - - return 1; -} - -void vtkELNOMeshFilter::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/CMake/CTestCustom.ctest.in b/src/Plugins/MEDReader/CMake/CTestCustom.ctest.in similarity index 100% rename from src/Plugins/MedReader/CMake/CTestCustom.ctest.in rename to src/Plugins/MEDReader/CMake/CTestCustom.ctest.in diff --git a/src/Plugins/MedReader/CMake/FindMED.cmake b/src/Plugins/MEDReader/CMake/FindMED.cmake similarity index 98% rename from src/Plugins/MedReader/CMake/FindMED.cmake rename to src/Plugins/MEDReader/CMake/FindMED.cmake index eb6abe07..aaae14cf 100644 --- a/src/Plugins/MedReader/CMake/FindMED.cmake +++ b/src/Plugins/MEDReader/CMake/FindMED.cmake @@ -78,10 +78,10 @@ IF(MED_INCLUDE_DIR) ENDIF(MED_INCLUDE_DIR) IF(${MED_FOUND}) - IF(WIN32) + IF(WINDOWS) SET(MED_LIBRARIES ${MED_LIBRARIES} ${HDF5_LIBS}) SET(MED_INCLUDE_DIRS ${MED_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}) - ELSE(WIN32) + ELSE(WINDOWS) FIND_PACKAGE(SalomeHDF5 REQUIRED) SET(MED_LIBRARIES ${MED_LIBRARIES} ${HDF5_LIBRARIES}) SET(MED_INCLUDE_DIRS ${MED_INCLUDE_DIR} ${HDF5_INCLUDE_DIRS}) @@ -90,7 +90,7 @@ IF(${MED_FOUND}) SET(MED_LIBRARIES ${MED_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) SET(MED_INCLUDE_DIRS ${MED_INCLUDE_DIRS} ${MPI_INCLUDE_PATH}) ENDIF(${HDF5_IS_PARALLEL}) - ENDIF(WIN32) + ENDIF(WINDOWS) ENDIF(${MED_FOUND}) SET(MED_INCLUDE_DIR ${MED_INCLUDE_DIRS}) diff --git a/src/Plugins/MEDReader/CMakeLists.txt b/src/Plugins/MEDReader/CMakeLists.txt new file mode 100644 index 00000000..702a0937 --- /dev/null +++ b/src/Plugins/MEDReader/CMakeLists.txt @@ -0,0 +1,103 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Patch for ParaView +# cp ParaView-3.98.1/VTK/CMake/*.cmake ParaView-3.98.1_INSTALL/lib/cmake/paraview-3.98 + +# Env for MEDReader +#setenv PV_PLUGIN_PATH ".../MEDReader_INSTALL/lib/paraview" +#setenv LD_LIBRARY_PATH ...MEDReader_INSTALL/lib/salome:${LD_LIBRARY_PATH} + +# Typical cmake command +# env MED_ROOT_DIR=... cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=PATH_TO/MEDReader_INSTALL ../MEDReader_SRC -DMEDFILE_ROOT_DIR=/where/is/med-3.0.7_install + +PROJECT(MEDReader) +ENABLE_TESTING() +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +IF(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) +ENDIF(COMMAND cmake_policy) + +SET(MED_READER_MAJOR_VERSION 0) +SET(MED_READER_MINOR_VERSION 0) +SET(MED_READER_BUILD_VERSION 0) +SET(MED_READER_VERSION "${MED_READER_MAJOR_VERSION}.${MED_READER_MINOR_VERSION}.${MED_READER_BUILD_VERSION}") + +# +# Load the ParaView/VTK packages +# +SET(MEDReader_BUILD_ParaView_Plugin ON CACHE BOOL "Build the ParaView plugin") + +IF(MEDReader_BUILD_ParaView_Plugin) + FIND_PACKAGE(ParaView REQUIRED) + IF(NOT ParaView_FOUND) + MESSAGE(FATAL_ERROR "Please locate ParaView." ) + ENDIF(NOT ParaView_FOUND) + INCLUDE(${PARAVIEW_USE_FILE}) + # Load information about VTK/ParaView modules loaded/available. + PV_SETUP_MODULE_ENVIRONMENT("vtkMEDReader") +ELSE(MEDReader_BUILD_ParaView_Plugin) + FIND_PACKAGE(VTK REQUIRED) + if(NOT VTK_FOUND) + MESSAGE(FATAL_ERROR "Please locate VTK." ) + ENDIF(NOT VTK_FOUND) + INCLUDE(${VTK_USE_FILE}) +ENDIF(MEDReader_BUILD_ParaView_Plugin) + +# Standard CMake option for building libraries shared or static by default. +OPTION(BUILD_SHARED_LIBS "Build with shared libraries." ${VTK_BUILD_SHARED_LIBS}) +# +# Find dependant Library +# +SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "KERNEL_ROOT_DIR") +SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR} CACHE PATH "MED_ROOT_DIR") +#LIST(APPEND CMAKE_MODULE_PATH "${MED_ROOT_DIR}/adm_local_without_kernel/cmake_files") +LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") +LIST(APPEND CMAKE_MODULE_PATH "${MED_ROOT_DIR}/adm_local/cmake_files") +INCLUDE(SalomeMacros) +INCLUDE(SalomeSetupPlatform) +INCLUDE(SalomeMEDConfig) +FIND_PACKAGE(SalomePython REQUIRED) +FIND_PACKAGE(SalomeHDF5 REQUIRED) +FIND_PACKAGE(SalomeMEDFile REQUIRED) + +# +# process all vtk-modules defined in this plugin. This generates the necessary +# wrappings for all these modules as well. +# +SET(VTK_INSTALL_RUNTIME_DIR lib/salome) +SET(VTK_INSTALL_LIBRARY_DIR lib/salome) +SET(VTK_INSTALL_ARCHIVE_DIR lib/salome) +INCLUDE_DIRECTORIES(${MEDFILE_INCLUDE_DIRS} ${HDF5_INCLUDE_DIRS}) +PV_PROCESS_MODULES() + +# +# Build the parallel vtkPMEDReader +# +SET(MEDReader_BUILD_PARALLEL ${VTK_USE_PARALLEL} CACHE BOOL "Build the Med Reader with parallel support.") + +# +# Build the ParaView Plugin +# +IF(MEDReader_BUILD_ParaView_Plugin) + ADD_SUBDIRECTORY(ParaViewPlugin) +ENDIF(MEDReader_BUILD_ParaView_Plugin) + +ADD_SUBDIRECTORY(Test) diff --git a/src/Plugins/MEDReader/Doc/ELNO.txt b/src/Plugins/MEDReader/Doc/ELNO.txt new file mode 100644 index 00000000..456a2ea8 --- /dev/null +++ b/src/Plugins/MEDReader/Doc/ELNO.txt @@ -0,0 +1,3 @@ +1- ELNO Points: creates points on the vertices of the cells, with a shrink factor which allows you to make the distinction between the vertices of the adjacent cells +2- ELNO Surface: this filters starts by extracting the surface of the object, then project the ELNO field on it, slightly separating the cells one from the others (10-5 shrink factor compared to cell initial size) +3- ELNO Mesh: all the cells of the initial mesh are separated one from the others to be able to project the ELNO fields on them. Beware not to use this filter on big calculation cases as the memory used and the graphical performances are degraded. This filter allows to make operations such as Cut Planes keeping the ELNO fields correct. diff --git a/src/Plugins/MEDReader/Doc/HowTo0.py b/src/Plugins/MEDReader/Doc/HowTo0.py new file mode 100644 index 00000000..b5213bf1 --- /dev/null +++ b/src/Plugins/MEDReader/Doc/HowTo0.py @@ -0,0 +1,16 @@ +from paraview.simple import * + +myMedReader=MEDReader(FileName="/home/H87074/WORK/TESTS_AMA/TESTS0/ssll117a/ssll117a.med") + +# list of all keys + +keys=myMedReader.GetProperty("FieldsTreeInfo")[::2] + +# list all the names of arrays that can be seen (including their spatial discretization) + +arr_name_with_dis=[elt.split("/")[-1] for elt in keys] + +# list all the names of arrays (Equal to those in the MED File) + +arr_name=[elt.split(myMedReader.GetProperty("Separator").GetData())[0] for elt in arr_name_with_dis] + diff --git a/src/Plugins/MEDReader/IO/CMakeLists.txt b/src/Plugins/MEDReader/IO/CMakeLists.txt new file mode 100644 index 00000000..2ae70bfe --- /dev/null +++ b/src/Plugins/MEDReader/IO/CMakeLists.txt @@ -0,0 +1,49 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE_DIRECTORIES( + ${MEDFILE_INCLUDE_DIRS} + ${HDF5_INCLUDE_DIRS} + ${MED_ROOT_DIR}/include/salome + ) + +SET(MEDReader_CLASSES vtkMEDReader vtkExtractGroup vtkELNOMeshFilter vtkELNOSurfaceFilter vtkELNOFilter vtkExtractCellType) + +SET(MEDReader_SRCS) +SET(MEDReader_HDRS) + +FOREACH(class ${MEDReader_CLASSES}) + SET(MEDReader_SRCS ${MEDReader_SRCS} ${class}.cxx) + SET(MEDReader_HDRS ${MEDReader_HDRS} ${class}.h) +ENDFOREACH(class) + +ADD_LIBRARY(MEDLoaderForPV SHARED MEDFileFieldRepresentationTree.cxx MEDTimeReq.cxx MEDUtilities.cxx vtkGenerateVectors.cxx) +TARGET_LINK_LIBRARIES(MEDLoaderForPV ${MED_medloader} ${MEDFILE_C_LIBRARIES}) + +VTK_MODULE_LIBRARY(vtkMEDReader ${MEDReader_SRCS}) +TARGET_LINK_LIBRARIES(vtkMEDReader MEDLoaderForPV ${MEDFILE_C_LIBRARIES}) + +INSTALL( + TARGETS vtkMEDReader MEDLoaderForPV + RUNTIME DESTINATION lib/salome + LIBRARY DESTINATION lib/salome + ARCHIVE DESTINATION lib/salome + ) + +INSTALL(FILES ${MEDReader_HDRS} DESTINATION include) diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx new file mode 100644 index 00000000..40c072c8 --- /dev/null +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -0,0 +1,1459 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "MEDTimeReq.hxx" +#include "MEDUtilities.hxx" + +#include "MEDFileFieldRepresentationTree.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "InterpKernelGaussCoords.hxx" +#include "MEDFileData.hxx" +#include "SauvReader.hxx" + +#include "vtkXMLUnstructuredGridWriter.h"// + +#include "vtkUnstructuredGrid.h" +#include "vtkRectilinearGrid.h" +#include "vtkStructuredGrid.h" +#include "vtkUnsignedCharArray.h" +#include "vtkQuadratureSchemeDefinition.h" +#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" +#include "vtkInformationIntegerKey.h" +#include "vtkInformation.h" +#include "vtkIdTypeArray.h" +#include "vtkDoubleArray.h" +#include "vtkIntArray.h" +#include "vtkCellArray.h" +#include "vtkPointData.h" +#include "vtkFieldData.h" +#include "vtkCellData.h" + +#include "vtksys/stl/string" +#include "vtksys/ios/fstream" +#include "vtksys/stl/algorithm" +#include "vtkMutableDirectedGraph.h" + +using namespace ParaMEDMEM; + +const char MEDFileFieldRepresentationLeavesArrays::ZE_SEP[]="@@][@@"; + +const char MEDFileFieldRepresentationLeavesArrays::TS_STR[]="TS"; + +const char MEDFileFieldRepresentationLeavesArrays::COM_SUP_STR[]="ComSup"; + +const char MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME[]="FamilyIdCell"; + +const char MEDFileFieldRepresentationLeavesArrays::NUM_ID_CELL_NAME[]="NumIdCell"; + +const char MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME[]="FamilyIdNode"; + +const char MEDFileFieldRepresentationLeavesArrays::NUM_ID_NODE_NAME[]="NumIdNode"; + +const char MEDFileFieldRepresentationTree::ROOT_OF_GRPS_IN_TREE[]="zeGrps"; + +const char MEDFileFieldRepresentationTree::ROOT_OF_FAM_IDS_IN_TREE[]="zeFamIds"; + +const char MEDFileFieldRepresentationTree::COMPO_STR_TO_LOCATE_MESH_DA[]="-@?|*_"; + +vtkIdTypeArray *ELGACmp::findOrCreate(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew) const +{ + vtkIdTypeArray *try0(isExisting(locsReallyUsed,vtkd)); + if(try0) + { + isNew=false; + return try0; + } + else + { + isNew=true; + return createNew(globs,locsReallyUsed,vtkd,ds); + } +} + +vtkIdTypeArray *ELGACmp::isExisting(const std::vector& locsReallyUsed, vtkDoubleArray *vtkd) const +{ + std::vector< std::vector >::iterator it(std::find(_loc_names.begin(),_loc_names.end(),locsReallyUsed)); + if(it==_loc_names.end()) + return 0; + std::size_t pos(std::distance(_loc_names.begin(),it)); + vtkIdTypeArray *ret(_elgas[pos]); + vtkInformationQuadratureSchemeDefinitionVectorKey *key(vtkQuadratureSchemeDefinition::DICTIONARY()); + for(std::vector >::const_iterator it=_defs[pos].begin();it!=_defs[pos].end();it++) + { + key->Set(vtkd->GetInformation(),(*it).first,(*it).second); + } + vtkd->GetInformation()->Set(vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME(),ret->GetName()); + return ret; +} + +vtkIdTypeArray *ELGACmp::createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const +{ + static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + std::vector< std::vector > locNames(_loc_names); + std::vector elgas(_elgas); + std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > > defs; + // + std::vector< std::vector >::const_iterator it(std::find(locNames.begin(),locNames.end(),locsReallyUsed)); + if(it!=locNames.end()) + throw INTERP_KERNEL::Exception("ELGACmp::createNew : Method is expected to be called after isExisting call ! Entry already exists !"); + locNames.push_back(locsReallyUsed); + vtkIdTypeArray *elga(vtkIdTypeArray::New()); + elga->SetNumberOfComponents(1); + vtkInformationQuadratureSchemeDefinitionVectorKey *key(vtkQuadratureSchemeDefinition::DICTIONARY()); + std::map m; + for(std::vector::const_iterator it=locsReallyUsed.begin();it!=locsReallyUsed.end();it++) + { + vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New()); + const MEDFileFieldLoc& loc(globs->getLocalization((*it).c_str())); + INTERP_KERNEL::NormalizedCellType ct(loc.getGeoType()); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(ct)); + int nbGaussPt(loc.getNbOfGaussPtPerCell()),nbPtsPerCell((int)cm.getNumberOfNodes()),dimLoc(loc.getDimension()); + // WARNING : these 2 lines are a workaround, due to users that write a ref element with dimension not equal to dimension of the geometric element. + std::vector gsCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getGaussCoords())); + std::vector refCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getRefCoords())); + double *shape(new double[nbPtsPerCell*nbGaussPt]); + INTERP_KERNEL::GaussInfo calculator(ct,gsCoods2,nbGaussPt,refCoods2,nbPtsPerCell); + calculator.initLocalInfo(); + const std::vector& wgths(loc.getGaussWeights()); + for(int i=0;iInitialize(vtkType,nbPtsPerCell,nbGaussPt,shape,const_cast(&wgths[0])); + delete [] shape; + key->Set(elga->GetInformation(),def,vtkType); + key->Set(vtkd->GetInformation(),def,vtkType); + defs.push_back(std::pair< vtkQuadratureSchemeDefinition *, unsigned char >(def,vtkType)); + } + // + vtkIdType ncell(ds->GetNumberOfCells()); + int *pt(new int[ncell]),offset(0); + for(vtkIdType cellId=0;cellIdGetCell(cellId)); + int delta(m[cell->GetCellType()]); + pt[cellId]=offset; + offset+=delta; + } + elga->GetInformation()->Set(MEDUtilities::ELGA(),1); + elga->SetArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); + std::ostringstream oss; oss << "ELGA" << "@" << _loc_names.size(); + std::string ossStr(oss.str()); + elga->SetName(ossStr.c_str()); + elga->GetInformation()->Set(vtkAbstractArray::GUI_HIDE(),1); + vtkd->GetInformation()->Set(vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME(),elga->GetName()); + elgas.push_back(elga); + // + _loc_names=locNames; + _elgas=elgas; + _defs.push_back(defs); +} + +void ELGACmp::appendELGAIfAny(vtkDataSet *ds) const +{ + for(std::vector::const_iterator it=_elgas.begin();it!=_elgas.end();it++) + ds->GetCellData()->AddArray(*it); +} + +ELGACmp::~ELGACmp() +{ + for(std::vector::const_iterator it=_elgas.begin();it!=_elgas.end();it++) + (*it)->Delete(); + for(std::vector< std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > > >::const_iterator it0=_defs.begin();it0!=_defs.end();it0++) + for(std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + (*it1).first->Delete(); +} + +//= + +MEDFileFieldRepresentationLeavesArrays::MEDFileFieldRepresentationLeavesArrays():_id(-1) +{ +} + +MEDFileFieldRepresentationLeavesArrays::MEDFileFieldRepresentationLeavesArrays(const ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr& arr):ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr(arr),_activated(false),_id(-1) +{ + std::vector< std::vector > typs((operator->())->getTypesOfFieldAvailable()); + if(typs.size()<1) + throw INTERP_KERNEL::Exception("There is a big internal problem in MEDLoader ! The field time spitting has failed ! A CRASH will occur soon !"); + if(typs[0].size()!=1) + throw INTERP_KERNEL::Exception("There is a big internal problem in MEDLoader ! The field spitting by spatial discretization has failed ! A CRASH will occur soon !"); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr fd(MEDCouplingFieldDiscretization::New(typs[0][0])); + std::ostringstream oss2; oss2 << (operator->())->getName() << ZE_SEP << fd->getRepr(); + _ze_name=oss2.str(); +} + +MEDFileFieldRepresentationLeavesArrays& MEDFileFieldRepresentationLeavesArrays::operator=(const MEDFileFieldRepresentationLeavesArrays& other) +{ + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr::operator=(other); + _id=-1; + _activated=false; + _ze_name=other._ze_name; + _ze_full_name.clear(); + return *this; +} + +void MEDFileFieldRepresentationLeavesArrays::setId(int& id) const +{ + _id=id++; +} + +int MEDFileFieldRepresentationLeavesArrays::getId() const +{ + return _id; +} + +std::string MEDFileFieldRepresentationLeavesArrays::getZeName() const +{ + return _ze_full_name; +} + +void MEDFileFieldRepresentationLeavesArrays::feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& comSupStr, std::vector& names) const +{ + vtkIdType refId(sil->AddChild(root,edge)); + names.push_back(_ze_name); + std::ostringstream oss3; oss3 << tsName << "/" << meshName << "/" << comSupStr << "/" << _ze_name; + _ze_full_name=oss3.str(); + // + if(MEDFileFieldRepresentationTree::IsFieldMeshRegardingInfo(((operator->())->getInfo()))) + { + sil->AddChild(refId,edge); + names.push_back(std::string()); + } +} + +bool MEDFileFieldRepresentationLeavesArrays::getStatus() const +{ + return _activated; +} + +bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const +{ + bool ret(_activated!=status); + _activated=status; + return ret; +} + +void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDMeshMultiLev *mml, const ParaMEDMEM::MEDFileMeshStruct *mst, vtkDataSet *ds) const +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + tr->setNumberOfTS((operator->())->getNumberOfTS()); + tr->initIterator(); + for(int timeStepId=0;timeStepIdsize();timeStepId++,++(*tr)) + { + MEDCouplingAutoRefCountObjectPtr f1ts((operator->())->getTimeStepAtPos(tr->getCurrent())); + MEDFileAnyTypeField1TS *f1tsPtr(f1ts); + MEDFileField1TS *f1tsPtrDbl(dynamic_cast(f1tsPtr)); + MEDFileIntField1TS *f1tsPtrInt(dynamic_cast(f1tsPtr)); + DataArray *crudeArr(0),*postProcessedArr(0); + if(f1tsPtrDbl) + crudeArr=f1tsPtrDbl->getUndergroundDataArray(); + else if(f1tsPtrInt) + crudeArr=f1tsPtrInt->getUndergroundDataArray(); + else + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeavesArrays::appendFields : only FLOAT64 and INT32 fields are dealt for the moment !"); + MEDFileField1TSStructItem fsst(MEDFileField1TSStructItem::BuildItemFrom(f1ts,mst)); + f1ts->loadArraysIfNecessary(); + MEDCouplingAutoRefCountObjectPtr v(mml->buildDataArray(fsst,globs,crudeArr)); + postProcessedArr=v; + // + std::vector discs(f1ts->getTypesOfFieldAvailable()); + if(discs.size()!=1) + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeavesArrays::appendFields : internal error ! Number of spatial discretizations must be equal to one !"); + vtkFieldData *att(0); + switch(discs[0]) + { + case ON_CELLS: + { + att=ds->GetCellData(); + break; + } + case ON_NODES: + { + att=ds->GetPointData(); + break; + } + case ON_GAUSS_NE: + { + att=ds->GetFieldData(); + break; + } + case ON_GAUSS_PT: + { + att=ds->GetFieldData(); + break; + } + default: + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeavesArrays::appendFields : only CELL and NODE, GAUSS_NE and GAUSS fields are available for the moment !"); + } + if(f1tsPtrDbl) + { + DataArray *vPtr(v); DataArrayDouble *vd(static_cast(vPtr)); + vtkDoubleArray *vtkd(vtkDoubleArray::New()); + vtkd->SetNumberOfComponents(vd->getNumberOfComponents()); + for(int i=0;igetNumberOfComponents();i++) + vtkd->SetComponentName(i,vd->getInfoOnComponent(i).c_str()); + if(postProcessedArr!=crudeArr) + { + vtkd->SetArray(vd->getPointer(),vd->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); vd->accessToMemArray().setSpecificDeallocator(0); + } + else + { + vtkd->SetArray(vd->getPointer(),vd->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + } + std::string name(tr->buildName(f1ts->getName())); + vtkd->SetName(name.c_str()); + att->AddArray(vtkd); + vtkd->Delete(); + if(discs[0]==ON_GAUSS_PT) + { + bool tmp; + _elga_cmp.findOrCreate(globs,f1ts->getLocsReallyUsed(),vtkd,ds,tmp); + } + if(discs[0]==ON_GAUSS_NE) + { + vtkIdTypeArray *elno(vtkIdTypeArray::New()); + elno->SetNumberOfComponents(1); + vtkIdType ncell(ds->GetNumberOfCells()); + int *pt(new int[ncell]),offset(0); + std::set cellTypes; + for(vtkIdType cellId=0;cellIdGetCell(cellId)); + int delta(cell->GetNumberOfPoints()); + cellTypes.insert(cell->GetCellType()); + pt[cellId]=offset; + offset+=delta; + } + elno->GetInformation()->Set(MEDUtilities::ELNO(),1); + elno->SetArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); + std::string nameElno("ELNO"); nameElno+="@"; nameElno+=name; + elno->SetName(nameElno.c_str()); + ds->GetCellData()->AddArray(elno); + vtkd->GetInformation()->Set(vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME(),elno->GetName()); + elno->GetInformation()->Set(vtkAbstractArray::GUI_HIDE(),1); + // + vtkInformationQuadratureSchemeDefinitionVectorKey *key(vtkQuadratureSchemeDefinition::DICTIONARY()); + for(std::set::const_iterator it=cellTypes.begin();it!=cellTypes.end();it++) + { + const unsigned char *pos(std::find(MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH,*it)); + if(pos==MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH) + continue; + INTERP_KERNEL::NormalizedCellType ct((INTERP_KERNEL::NormalizedCellType)std::distance(MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,pos)); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(ct)); + int nbGaussPt(cm.getNumberOfNodes()),dim(cm.getDimension()); + vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New()); + double *shape(new double[nbGaussPt*nbGaussPt]); + std::size_t dummy; + const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(ct,dummy)); + const double *refCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy)); + const double *weights(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(ct,dummy)); + std::vector gsCoords2(gsCoords,gsCoords+nbGaussPt*dim),refCoords2(refCoords,refCoords+nbGaussPt*dim); + INTERP_KERNEL::GaussInfo calculator(ct,gsCoords2,nbGaussPt,refCoords2,nbGaussPt); + calculator.initLocalInfo(); + for(int i=0;iInitialize(*it,nbGaussPt,nbGaussPt,shape,const_cast(weights)); + delete [] shape; + key->Set(elno->GetInformation(),def,*it); + key->Set(vtkd->GetInformation(),def,*it); + def->Delete(); + } + // + elno->Delete(); + } + } + else if(f1tsPtrInt) + { + DataArray *vPtr(v); DataArrayInt *vi(static_cast(vPtr)); + vtkIntArray *vtkd(vtkIntArray::New()); + vtkd->SetNumberOfComponents(vi->getNumberOfComponents()); + for(int i=0;igetNumberOfComponents();i++) + vtkd->SetComponentName(i,vi->getVarOnComponent(i).c_str()); + if(postProcessedArr!=crudeArr) + { + vtkd->SetArray(vi->getPointer(),vi->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); vi->accessToMemArray().setSpecificDeallocator(0); + } + else + { + vtkd->SetArray(vi->getPointer(),vi->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + } + std::string name(tr->buildName(f1ts->getName())); + vtkd->SetName(name.c_str()); + att->AddArray(vtkd); + vtkd->Delete(); + } + else + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeavesArrays::appendFields : only FLOAT64 and INT32 fields are dealt for the moment ! Internal Error !"); + } +} + +void MEDFileFieldRepresentationLeavesArrays::appendELGAIfAny(vtkDataSet *ds) const +{ + _elga_cmp.appendELGAIfAny(ds); +} + +//////////////////// + +MEDFileFieldRepresentationLeaves::MEDFileFieldRepresentationLeaves():_cached_ds(0) +{ +} + +MEDFileFieldRepresentationLeaves::MEDFileFieldRepresentationLeaves(const std::vector< ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr >& arr, + const ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr& fsp):_arrays(arr.size()),_fsp(fsp),_cached_ds(0) +{ + for(std::size_t i=0;iDelete(); +} + +bool MEDFileFieldRepresentationLeaves::empty() const +{ + const MEDFileFastCellSupportComparator *fcscp(_fsp); + return fcscp==0 || _arrays.empty(); +} + +void MEDFileFieldRepresentationLeaves::setId(int& id) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + (*it).setId(id); +} + +std::string MEDFileFieldRepresentationLeaves::getMeshName() const +{ + return _arrays[0]->getMeshName(); +} + +int MEDFileFieldRepresentationLeaves::getNumberOfArrays() const +{ + return (int)_arrays.size(); +} + +int MEDFileFieldRepresentationLeaves::getNumberOfTS() const +{ + return _arrays[0]->getNumberOfTS(); +} + +void MEDFileFieldRepresentationLeaves::feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& comSupStr, std::vector& names) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + (*it).feedSIL(sil,root,edge,tsName,meshName,comSupStr,names); +} + +bool MEDFileFieldRepresentationLeaves::containId(int id) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + if((*it).getId()==id) + return true; + return false; +} + +bool MEDFileFieldRepresentationLeaves::containZeName(const char *name, int& id) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + if((*it).getZeName()==name) + { + id=(*it).getId(); + return true; + } + return false; +} + +bool MEDFileFieldRepresentationLeaves::isActivated() const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + if((*it).getStatus()) + return true; + return false; +} + +void MEDFileFieldRepresentationLeaves::printMySelf(std::ostream& os) const +{ + for(std::vector::const_iterator it0=_arrays.begin();it0!=_arrays.end();it0++) + { + os << " - " << (*it0).getZeName() << " ("; + if((*it0).getStatus()) + os << "X"; + else + os << " "; + os << ")" << std::endl; + } +} + +void MEDFileFieldRepresentationLeaves::activateAllArrays() const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + (*it).setStatus(true); +} + +const MEDFileFieldRepresentationLeavesArrays& MEDFileFieldRepresentationLeaves::getLeafArr(int id) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + if((*it).getId()==id) + return *it; + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeaves::getLeafArr ! No such id !"); +} + +std::vector MEDFileFieldRepresentationLeaves::getTimeSteps(const TimeKeeper& tk) const +{ + if(_arrays.size()<1) + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeaves::getTimeSteps : the array size must be at least of size one !"); + std::vector ret; + std::vector< std::pair > dtits(_arrays[0]->getTimeSteps(ret)); + return tk.getTimeStepsRegardingPolicy(dtits,ret); +} + +std::vector< std::pair > MEDFileFieldRepresentationLeaves::getTimeStepsInCoarseMEDFileFormat(std::vector& ts) const +{ + if(!_arrays.empty()) + return _arrays[0]->getTimeSteps(ts); + else + { + ts.clear(); + return std::vector< std::pair >(); + } +} + +std::string MEDFileFieldRepresentationLeaves::getHumanReadableOverviewOfTS() const +{ + std::ostringstream oss; + oss << _arrays[0]->getNumberOfTS() << " time steps [" << _arrays[0]->getDtUnit() << "]\n("; + std::vector ret1; + std::vector< std::pair > ret2(getTimeStepsInCoarseMEDFileFormat(ret1)); + std::size_t sz(ret1.size()); + for(std::size_t i=0;i200 && i!=sz-1) + { + oss << "..."; + break; + } + } + oss << ")"; + return oss.str(); +} + +void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDMeshMultiLev *mml, const ParaMEDMEM::MEDFileMeshes *meshes, vtkDataSet *ds) const +{ + if(_arrays.size()<1) + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeaves::appendFields : internal error !"); + MEDCouplingAutoRefCountObjectPtr mst(MEDFileMeshStruct::New(meshes->getMeshWithName(_arrays[0]->getMeshName().c_str()))); + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + if((*it).getStatus()) + { + (*it).appendFields(tr,globs,mml,mst,ds); + (*it).appendELGAIfAny(ds); + } +} + +vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationUnstructured(MEDUMeshMultiLev *mm) const +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + DataArrayDouble *coordsMC(0); + DataArrayByte *typesMC(0); + DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0); + bool statusOfCoords(mm->buildVTUArrays(coordsMC,typesMC,cellLocationsMC,cellsMC,faceLocationsMC,facesMC)); + MEDCouplingAutoRefCountObjectPtr coordsSafe(coordsMC); + MEDCouplingAutoRefCountObjectPtr typesSafe(typesMC); + MEDCouplingAutoRefCountObjectPtr cellLocationsSafe(cellLocationsMC),cellsSafe(cellsMC),faceLocationsSafe(faceLocationsMC),facesSafe(facesMC); + // + int nbOfCells(typesSafe->getNbOfElems()); + vtkUnstructuredGrid *ret(vtkUnstructuredGrid::New()); + vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New()); + cellTypes->SetArray(reinterpret_cast(typesSafe->getPointer()),nbOfCells,0,VTK_DATA_ARRAY_FREE); typesSafe->accessToMemArray().setSpecificDeallocator(0); + vtkIdTypeArray *cellLocations(vtkIdTypeArray::New()); + cellLocations->SetArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + vtkCellArray *cells(vtkCellArray::New()); + vtkIdTypeArray *cells2(vtkIdTypeArray::New()); + cells2->SetArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0); + cells->SetCells(nbOfCells,cells2); + cells2->Delete(); + if(faceLocationsMC!=0 && facesMC!=0) + { + vtkIdTypeArray *faces(vtkIdTypeArray::New()); + faces->SetArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0); + vtkIdTypeArray *faceLocations(vtkIdTypeArray::New()); + faceLocations->SetArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + ret->SetCells(cellTypes,cellLocations,cells,faceLocations,faces); + faceLocations->Delete(); + faces->Delete(); + } + else + ret->SetCells(cellTypes,cellLocations,cells); + cellTypes->Delete(); + cellLocations->Delete(); + cells->Delete(); + vtkPoints *pts(vtkPoints::New()); + vtkDoubleArray *pts2(vtkDoubleArray::New()); + pts2->SetNumberOfComponents(3); + if(!statusOfCoords) + { + pts2->SetArray(coordsSafe->getPointer(),coordsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); + coordsSafe->accessToMemArray().setSpecificDeallocator(0); + } + else + pts2->SetArray(coordsSafe->getPointer(),coordsSafe->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + pts->SetData(pts2); + pts2->Delete(); + ret->SetPoints(pts); + pts->Delete(); + // + return ret; +} + +vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCartesian(ParaMEDMEM::MEDCMeshMultiLev *mm) const +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + bool isInternal; + std::vector< DataArrayDouble * > arrs(mm->buildVTUArrays(isInternal)); + vtkDoubleArray *vtkTmp(0); + vtkRectilinearGrid *ret(vtkRectilinearGrid::New()); + std::size_t dim(arrs.size()); + if(dim<1 || dim>3) + throw INTERP_KERNEL::Exception("buildVTKInstanceNoTimeInterpolationCartesian : dimension must be in [1,3] !"); + int sizePerAxe[3]={1,1,1}; + sizePerAxe[0]=arrs[0]->getNbOfElems(); + if(dim>=2) + sizePerAxe[1]=arrs[1]->getNbOfElems(); + if(dim==3) + sizePerAxe[2]=arrs[2]->getNbOfElems(); + ret->SetDimensions(sizePerAxe[0],sizePerAxe[1],sizePerAxe[2]); + vtkTmp=vtkDoubleArray::New(); + vtkTmp->SetNumberOfComponents(1); + if(isInternal) + vtkTmp->SetArray(arrs[0]->getPointer(),arrs[0]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTmp->SetArray(arrs[0]->getPointer(),arrs[0]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[0]->accessToMemArray().setSpecificDeallocator(0); } + ret->SetXCoordinates(vtkTmp); + vtkTmp->Delete(); + arrs[0]->decrRef(); + if(dim>=2) + { + vtkTmp=vtkDoubleArray::New(); + vtkTmp->SetNumberOfComponents(1); + if(isInternal) + vtkTmp->SetArray(arrs[1]->getPointer(),arrs[1]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTmp->SetArray(arrs[1]->getPointer(),arrs[1]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[1]->accessToMemArray().setSpecificDeallocator(0); } + ret->SetYCoordinates(vtkTmp); + vtkTmp->Delete(); + arrs[1]->decrRef(); + } + if(dim==3) + { + vtkTmp=vtkDoubleArray::New(); + vtkTmp->SetNumberOfComponents(1); + if(isInternal) + vtkTmp->SetArray(arrs[2]->getPointer(),arrs[2]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTmp->SetArray(arrs[2]->getPointer(),arrs[2]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[2]->accessToMemArray().setSpecificDeallocator(0); } + ret->SetZCoordinates(vtkTmp); + vtkTmp->Delete(); + arrs[2]->decrRef(); + } + return ret; +} + +vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCurveLinear(ParaMEDMEM::MEDCurveLinearMeshMultiLev *mm) const +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + int meshStr[3]={1,1,1}; + DataArrayDouble *coords(0); + std::vector nodeStrct; + bool isInternal; + mm->buildVTUArrays(coords,nodeStrct,isInternal); + std::size_t dim(nodeStrct.size()); + if(dim<1 || dim>3) + throw INTERP_KERNEL::Exception("buildVTKInstanceNoTimeInterpolationCurveLinear : dimension must be in [1,3] !"); + meshStr[0]=nodeStrct[0]; + if(dim>=2) + meshStr[1]=nodeStrct[1]; + if(dim==3) + meshStr[2]=nodeStrct[2]; + vtkStructuredGrid *ret(vtkStructuredGrid::New()); + ret->SetDimensions(meshStr[0],meshStr[1],meshStr[2]); + vtkDoubleArray *da(vtkDoubleArray::New()); + da->SetNumberOfComponents(3); + if(coords->getNumberOfComponents()==3) + { + if(isInternal) + da->SetArray(coords->getPointer(),coords->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);//VTK has not the ownership of double * because MEDLoader main struct has it ! + else + { da->SetArray(coords->getPointer(),coords->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); coords->accessToMemArray().setSpecificDeallocator(0); } + } + else + { + MEDCouplingAutoRefCountObjectPtr coords2(coords->changeNbOfComponents(3,0.)); + da->SetArray(coords2->getPointer(),coords2->getNbOfElems(),0,VTK_DATA_ARRAY_FREE);//let VTK deal with double * + coords2->accessToMemArray().setSpecificDeallocator(0); + } + coords->decrRef(); + vtkPoints *points=vtkPoints::New(); + ret->SetPoints(points); + points->SetData(da); + points->Delete(); + da->Delete(); + return ret; +} + +vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDFileMeshes *meshes) const +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + vtkDataSet *ret(0); + //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs); + MEDCouplingAutoRefCountObjectPtr mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change + MEDCouplingAutoRefCountObjectPtr mml2(mml->prepare()); + MEDMeshMultiLev *ptMML2(mml2); + if(!_cached_ds) + { + MEDUMeshMultiLev *ptUMML2(dynamic_cast(ptMML2)); + MEDCMeshMultiLev *ptCMML2(dynamic_cast(ptMML2)); + MEDCurveLinearMeshMultiLev *ptCLMML2(dynamic_cast(ptMML2)); + + if(ptUMML2) + { + ret=buildVTKInstanceNoTimeInterpolationUnstructured(ptUMML2); + } + else if(ptCMML2) + { + ret=buildVTKInstanceNoTimeInterpolationCartesian(ptCMML2); + } + else if(ptCLMML2) + { + ret=buildVTKInstanceNoTimeInterpolationCurveLinear(ptCLMML2); + } + else + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation : unrecognized mesh ! Supported for the moment unstructured, cartesian, curvelinear !"); + _cached_ds=ret->NewInstance(); + _cached_ds->ShallowCopy(ret); + } + else + { + ret=_cached_ds->NewInstance(); + ret->ShallowCopy(_cached_ds); + } + // + appendFields(tr,globs,mml,meshes,ret); + // The arrays links to mesh + DataArrayInt *famCells(0),*numCells(0); + bool noCpyFamCells(false),noCpyNumCells(false); + ptMML2->retrieveFamilyIdsOnCells(famCells,noCpyFamCells); + if(famCells) + { + vtkIntArray *vtkTab(vtkIntArray::New()); + vtkTab->SetNumberOfComponents(1); + vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME); + if(noCpyFamCells) + vtkTab->SetArray(famCells->getPointer(),famCells->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTab->SetArray(famCells->getPointer(),famCells->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); famCells->accessToMemArray().setSpecificDeallocator(0); } + ret->GetCellData()->AddArray(vtkTab); + vtkTab->Delete(); + famCells->decrRef(); + } + ptMML2->retrieveNumberIdsOnCells(numCells,noCpyNumCells); + if(numCells) + { + vtkIntArray *vtkTab(vtkIntArray::New()); + vtkTab->SetNumberOfComponents(1); + vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_CELL_NAME); + if(noCpyNumCells) + vtkTab->SetArray(numCells->getPointer(),numCells->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTab->SetArray(numCells->getPointer(),numCells->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); numCells->accessToMemArray().setSpecificDeallocator(0); } + ret->GetCellData()->AddArray(vtkTab); + vtkTab->Delete(); + numCells->decrRef(); + } + // The arrays links to mesh + DataArrayInt *famNodes(0),*numNodes(0); + bool noCpyFamNodes(false),noCpyNumNodes(false); + ptMML2->retrieveFamilyIdsOnNodes(famNodes,noCpyFamNodes); + if(famNodes) + { + vtkIntArray *vtkTab(vtkIntArray::New()); + vtkTab->SetNumberOfComponents(1); + vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME); + if(noCpyFamNodes) + vtkTab->SetArray(famNodes->getPointer(),famNodes->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTab->SetArray(famNodes->getPointer(),famNodes->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); famNodes->accessToMemArray().setSpecificDeallocator(0); } + ret->GetPointData()->AddArray(vtkTab); + vtkTab->Delete(); + famNodes->decrRef(); + } + ptMML2->retrieveNumberIdsOnNodes(numNodes,noCpyNumNodes); + if(numNodes) + { + vtkIntArray *vtkTab(vtkIntArray::New()); + vtkTab->SetNumberOfComponents(1); + vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_NODE_NAME); + if(noCpyNumNodes) + vtkTab->SetArray(numNodes->getPointer(),numNodes->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + else + { vtkTab->SetArray(numNodes->getPointer(),numNodes->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); numNodes->accessToMemArray().setSpecificDeallocator(0); } + ret->GetPointData()->AddArray(vtkTab); + vtkTab->Delete(); + numNodes->decrRef(); + } + return ret; +} + +////////////////////// + +MEDFileFieldRepresentationTree::MEDFileFieldRepresentationTree() +{ +} + +int MEDFileFieldRepresentationTree::getNumberOfLeavesArrays() const +{ + int ret(0); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + ret+=(*it2).getNumberOfArrays(); + return ret; +} + +void MEDFileFieldRepresentationTree::assignIds() const +{ + int zeId(0); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + (*it2).setId(zeId); +} +void MEDFileFieldRepresentationTree::activateTheFirst() const +{ + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + { + (*it2).activateAllArrays(); + return ; + } +} + +void MEDFileFieldRepresentationTree::feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector& names) const +{ + std::size_t it0Cnt(0); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++,it0Cnt++) + { + vtkIdType InfoOnTSId(sil->AddChild(root,edge)); + names.push_back((*it0)[0][0].getHumanReadableOverviewOfTS()); + // + vtkIdType NbOfTSId(sil->AddChild(InfoOnTSId,edge)); + std::vector ts; + std::vector< std::pair > dtits((*it0)[0][0].getTimeStepsInCoarseMEDFileFormat(ts)); + std::size_t nbOfTS(dtits.size()); + std::ostringstream oss3; oss3 << nbOfTS; + names.push_back(oss3.str()); + for(std::size_t i=0;iAddChild(NbOfTSId,edge)); + names.push_back(oss4.str()); + std::ostringstream oss5; oss5 << dtits[i].second; + vtkIdType ItId(sil->AddChild(DtId,edge)); + names.push_back(oss5.str()); + std::ostringstream oss6; oss6 << ts[i]; + sil->AddChild(ItId,edge); + names.push_back(oss6.str()); + } + // + std::ostringstream oss; oss << MEDFileFieldRepresentationLeavesArrays::TS_STR << it0Cnt; + std::string tsName(oss.str()); + vtkIdType typeId0(sil->AddChild(root,edge)); + names.push_back(tsName); + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + { + std::string meshName((*it1)[0].getMeshName()); + vtkIdType typeId1(sil->AddChild(typeId0,edge)); + names.push_back(meshName); + std::size_t it2Cnt(0); + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++,it2Cnt++) + { + std::ostringstream oss2; oss2 << MEDFileFieldRepresentationLeavesArrays::COM_SUP_STR << it2Cnt; + std::string comSupStr(oss2.str()); + vtkIdType typeId2(sil->AddChild(typeId1,edge)); + names.push_back(comSupStr); + (*it2).feedSIL(sil,typeId2,edge,tsName,meshName,comSupStr,names); + } + } + } +} + +std::string MEDFileFieldRepresentationTree::feedSILForFamsAndGrps(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector& names) const +{ + int dummy0(0),dummy1(0),dummy2(0); + const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(dummy0,dummy1,dummy2)); + std::string ret(leaf.getMeshName()); + int i(0); + MEDFileMesh *m(0); + for(;i<_ms->getNumberOfMeshes();i++) + { + m=_ms->getMeshAtPos(i); + if(m->getName()==ret) + break; + } + if(i==_ms->getNumberOfMeshes()) + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationTree::feedSILForFamsAndGrps : internal error #0 !"); + vtkIdType typeId0(sil->AddChild(root,edge)); + names.push_back(m->getName()); + // + vtkIdType typeId1(sil->AddChild(typeId0,edge)); + names.push_back(std::string(ROOT_OF_GRPS_IN_TREE)); + std::vector grps(m->getGroupsNames()); + for(std::vector::const_iterator it0=grps.begin();it0!=grps.end();it0++) + { + vtkIdType typeId2(sil->AddChild(typeId1,edge)); + names.push_back(*it0); + std::vector famsOnGrp(m->getFamiliesOnGroup((*it0).c_str())); + for(std::vector::const_iterator it1=famsOnGrp.begin();it1!=famsOnGrp.end();it1++) + { + sil->AddChild(typeId2,edge); + names.push_back((*it1).c_str()); + } + } + // + vtkIdType typeId11(sil->AddChild(typeId0,edge)); + names.push_back(std::string(ROOT_OF_FAM_IDS_IN_TREE)); + std::vector fams(m->getFamiliesNames()); + for(std::vector::const_iterator it00=fams.begin();it00!=fams.end();it00++) + { + sil->AddChild(typeId11,edge); + int famId(m->getFamilyId((*it00).c_str())); + std::ostringstream oss; oss << (*it00) << MEDFileFieldRepresentationLeavesArrays::ZE_SEP << famId; + names.push_back(oss.str()); + } + return ret; +} + +const MEDFileFieldRepresentationLeavesArrays& MEDFileFieldRepresentationTree::getLeafArr(int id) const +{ + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + if((*it2).containId(id)) + return (*it2).getLeafArr(id); + throw INTERP_KERNEL::Exception("Internal error in MEDFileFieldRepresentationTree::getLeafArr !"); +} + +std::string MEDFileFieldRepresentationTree::getNameOf(int id) const +{ + const MEDFileFieldRepresentationLeavesArrays& elt(getLeafArr(id)); + return elt.getZeName(); +} + +bool MEDFileFieldRepresentationTree::getStatusOf(int id) const +{ + const MEDFileFieldRepresentationLeavesArrays& elt(getLeafArr(id)); + return elt.getStatus(); +} + +int MEDFileFieldRepresentationTree::getIdHavingZeName(const char *name) const +{ + int ret(-1); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + if((*it2).containZeName(name,ret)) + return ret; + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationTree::getIdHavingZeName : No such a name !"); +} + +bool MEDFileFieldRepresentationTree::changeStatusOfAndUpdateToHaveCoherentVTKDataSet(int id, bool status) const +{ + const MEDFileFieldRepresentationLeavesArrays& elt(getLeafArr(id)); + bool ret(elt.setStatus(status));//to be implemented + return ret; +} + +int MEDFileFieldRepresentationTree::getMaxNumberOfTimeSteps() const +{ + int ret(0); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + ret=std::max(ret,(*it2).getNumberOfTS()); + return ret; +} + +/*! + * + */ +void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv) +{ + if(isMEDOrSauv) + { + _ms=MEDFileMeshes::New(fileName); + _fields=MEDFileFields::New(fileName,false);//false is important to not read the values + } + else + { + MEDCouplingAutoRefCountObjectPtr sr(ParaMEDMEM::SauvReader::New(fileName)); + MEDCouplingAutoRefCountObjectPtr mfd(sr->loadInMEDFileDS()); + _ms=mfd->getMeshes(); _ms->incrRef(); + int nbMeshes(_ms->getNumberOfMeshes()); + for(int i=0;igetMeshAtPos(i)); + ParaMEDMEM::MEDFileUMesh *tmp2(dynamic_cast(tmp)); + if(tmp2) + tmp2->forceComputationOfParts(); + } + _fields=mfd->getFields(); + if((ParaMEDMEM::MEDFileFields *)_fields) + _fields->incrRef(); + } + if(!((ParaMEDMEM::MEDFileFields *)_fields)) + { + _fields=BuildFieldFromMeshes(_ms); + } + else + { + AppendFieldFromMeshes(_ms,_fields); + } + std::vector meshNames(_ms->getMeshesNames()); + std::vector< MEDCouplingAutoRefCountObjectPtr > fields_per_mesh(meshNames.size()); + for(std::size_t i=0;ipartOfThisLyingOnSpecifiedMeshName(meshNames[i].c_str()); + } + std::vector< MEDCouplingAutoRefCountObjectPtr > allFMTSLeavesToDisplaySafe; + std::size_t k(0); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator fields=fields_per_mesh.begin();fields!=fields_per_mesh.end();fields++) + { + for(int j=0;j<(*fields)->getNumberOfFields();j++) + { + MEDCouplingAutoRefCountObjectPtr fmts((*fields)->getFieldAtPos((int)j)); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > tmp(fmts->splitDiscretizations()); + allFMTSLeavesToDisplaySafe.insert(allFMTSLeavesToDisplaySafe.end(),tmp.begin(),tmp.end()); + } + } + std::vector< MEDFileAnyTypeFieldMultiTS *> allFMTSLeavesToDisplay(allFMTSLeavesToDisplaySafe.size()); + for(std::size_t i=0;i > allFMTSLeavesPerTimeSeries(MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(allFMTSLeavesToDisplay)); + // memory safety part + std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > allFMTSLeavesPerTimeSeriesSafe(allFMTSLeavesPerTimeSeries.size()); + for(std::size_t j=0;jincrRef();//because MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries do not increments the counter + allFMTSLeavesPerTimeSeriesSafe[j][k]=allFMTSLeavesPerTimeSeries[j][k]; + } + } + // end of memory safety part + // 1st : timesteps, 2nd : meshName, 3rd : common support + this->_data_structure.resize(allFMTSLeavesPerTimeSeriesSafe.size()); + for(std::size_t i=0;i meshNamesLoc; + std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > splitByMeshName; + for(std::size_t j=0;jgetMeshName()); + vtksys_stl::vector< vtksys_stl::string >::iterator it(std::find(meshNamesLoc.begin(),meshNamesLoc.end(),meshName)); + if(it==meshNamesLoc.end()) + { + meshNamesLoc.push_back(meshName); + splitByMeshName.resize(splitByMeshName.size()+1); + splitByMeshName.back().push_back(allFMTSLeavesPerTimeSeriesSafe[i][j]); + } + else + splitByMeshName[std::distance(meshNamesLoc.begin(),it)].push_back(allFMTSLeavesPerTimeSeriesSafe[i][j]); + } + _data_structure[i].resize(meshNamesLoc.size()); + for(std::size_t j=0;j > fsp; + std::vector< MEDFileAnyTypeFieldMultiTS *> sbmn(splitByMeshName[j].size()); + for(std::size_t k=0;k > commonSupSplit(MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(sbmn,_ms->getMeshWithName(meshNamesLoc[j].c_str()),fsp)); + std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > commonSupSplitSafe(commonSupSplit.size()); + this->_data_structure[i][j].resize(commonSupSplit.size()); + for(std::size_t k=0;kincrRef();//because MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport does not increment pointers ! + commonSupSplitSafe[k][l]=commonSupSplit[k][l]; + } + } + for(std::size_t k=0;k_data_structure[i][j][k]=MEDFileFieldRepresentationLeaves(commonSupSplitSafe[k],fsp[k]); + } + } + this->removeEmptyLeaves(); + this->assignIds(); +} + +void MEDFileFieldRepresentationTree::removeEmptyLeaves() +{ + std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > > newSD; + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + { + std::vector< std::vector< MEDFileFieldRepresentationLeaves > > newSD0; + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + { + std::vector< MEDFileFieldRepresentationLeaves > newSD1; + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + if(!(*it2).empty()) + newSD1.push_back(*it2); + if(!newSD1.empty()) + newSD0.push_back(newSD1); + } + if(!newSD0.empty()) + newSD.push_back(newSD0); + } +} + +bool MEDFileFieldRepresentationTree::IsFieldMeshRegardingInfo(const std::vector& compInfos) +{ + if(compInfos.size()!=1) + return false; + return compInfos[0]==COMPO_STR_TO_LOCATE_MESH_DA; +} + +std::string MEDFileFieldRepresentationTree::getDftMeshName() const +{ + return _data_structure[0][0][0].getMeshName(); +} + +std::vector MEDFileFieldRepresentationTree::getTimeSteps(int& lev0, const TimeKeeper& tk) const +{ + int lev1,lev2; + const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(lev0,lev1,lev2)); + return leaf.getTimeSteps(tk); +} + +vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk) const +{ + int lev0,lev1,lev2; + const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(lev0,lev1,lev2)); + meshName=leaf.getMeshName(); + std::vector ts(leaf.getTimeSteps(tk)); + std::size_t zeTimeId(0); + if(ts.size()!=1) + { + std::vector ts2(ts.size()); + std::transform(ts.begin(),ts.end(),ts2.begin(),std::bind2nd(std::plus(),-timeReq)); + std::transform(ts2.begin(),ts2.end(),ts2.begin(),std::ptr_fun(fabs)); + zeTimeId=std::distance(ts2.begin(),std::find_if(ts2.begin(),ts2.end(),std::bind2nd(std::less(),1e-14))); + } + //2nd chance + if(zeTimeId==(int)ts.size()) + zeTimeId=std::distance(ts.begin(),std::find(ts.begin(),ts.end(),timeReq)); + if(zeTimeId==(int)ts.size()) + {//OK the time requested does not fit time series given to ParaView. It is typically the case if more than one MEDReader instance are created or TimeInspector in real time mode. + //In this case the default behaviour is taken. Keep the highest time step in this lower than timeReq. + int pos(-1); + double valAttachedToPos(-std::numeric_limits::max()); + for(std::size_t i=0;ivalAttachedToPos) + { + pos=i; + valAttachedToPos=ts[i]; + } + } + } + if(pos==-1) + {// timeReq is lower than all time steps (ts). So let's keep the lowest time step greater than timeReq. + valAttachedToPos=std::numeric_limits::max(); + for(std::size_t i=0;i(oss,",")); + oss << " ! Keep time " << valAttachedToPos << " at pos #" << zeTimeId; + std::cerr << oss.str() << std::endl; + } + MEDTimeReq *tr(0); + if(!isStdOrMode) + tr=new MEDStdTimeReq((int)zeTimeId); + else + tr=new MEDModeTimeReq(tk.getTheVectOfBool()); + vtkDataSet *ret(leaf.buildVTKInstanceNoTimeInterpolation(tr,_fields,_ms)); + delete tr; + return ret; +} + +const MEDFileFieldRepresentationLeaves& MEDFileFieldRepresentationTree::getTheSingleActivated(int& lev0, int& lev1, int& lev2) const +{ + int nbOfActivated(0); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + if((*it2).isActivated()) + nbOfActivated++; + if(nbOfActivated!=1) + { + std::ostringstream oss; oss << "MEDFileFieldRepresentationTree::getTheSingleActivated : Only one leaf must be activated ! Having " << nbOfActivated << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + int i0(0),i1(0),i2(0); + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++,i0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++,i1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++,i2++) + if((*it2).isActivated()) + { + lev0=i0; lev1=i1; lev2=i2; + return *it2; + } + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationTree::getTheSingleActivated : Internal error !"); +} + +void MEDFileFieldRepresentationTree::printMySelf(std::ostream& os) const +{ + int i(0); + os << "#############################################" << std::endl; + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++,i++) + { + int j(0); + os << "TS" << i << std::endl; + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++,j++) + { + int k(0); + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++,k++) + { + if(k==0) + os << " " << (*it2).getMeshName() << std::endl; + os << " Comp" << k << std::endl; + (*it2).printMySelf(os); + } + } + } + os << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; +} + +void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms, ParaMEDMEM::MEDFileFields *ret) +{ + for(int i=0;igetNumberOfMeshes();i++) + { + MEDFileMesh *mm(ms->getMeshAtPos(i)); + MEDFileUMesh *mmu(dynamic_cast(mm)); + if(!mmu) + continue; + std::vector levs(mm->getNonEmptyLevels()); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f1tsMultiLev(ParaMEDMEM::MEDFileField1TS::New()); + for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) + { + std::vector gts(mmu->getGeoTypesAtLevel(*it)); + for(std::vector::const_iterator gt=gts.begin();gt!=gts.end();gt++) + { + ParaMEDMEM::MEDCouplingMesh *m(mmu->getDirectUndergroundSingleGeoTypeMesh(*gt)); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS)); + f->setMesh(m); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); + arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); + arr->iota(); + f->setArray(arr); + f->setName(mm->getName()); + f1tsMultiLev->setFieldNoProfileSBT(f); + } + } + if(levs.empty()) + { + std::vector levsExt(mm->getNonEmptyLevelsExt()); + if(levsExt.size()==levs.size()+1) + { + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr m(mm->getGenMeshAtLevel(1)); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES)); + f->setMesh(m); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes()); + arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); + arr->iota(); f->setArray(arr); + f->setName(mm->getName()); + f1tsMultiLev->setFieldNoProfileSBT(f); + } + else + continue; + } + // + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr fmtsMultiLev(ParaMEDMEM::MEDFileFieldMultiTS::New()); + fmtsMultiLev->pushBackTimeStep(f1tsMultiLev); + ret->pushField(fmtsMultiLev); + } +} + +ParaMEDMEM::MEDFileFields *MEDFileFieldRepresentationTree::BuildFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms) +{ + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr ret(ParaMEDMEM::MEDFileFields::New()); + AppendFieldFromMeshes(ms,ret); + return ret.retn(); +} + +/////////// + +TimeKeeper::TimeKeeper(int policy):_policy(policy) +{ +} + +std::vector TimeKeeper::getTimeStepsRegardingPolicy(const std::vector< std::pair >& tsPairs, const std::vector& ts) const +{ + switch(_policy) + { + case 0: + return getTimeStepsRegardingPolicy0(tsPairs,ts); + case 1: + return getTimeStepsRegardingPolicy0(tsPairs,ts); + default: + throw INTERP_KERNEL::Exception("TimeKeeper::getTimeStepsRegardingPolicy : only policy 0 and 1 supported presently !"); + } +} + +/*! + * policy = 0 : + * if all of ts are in -1e299,1e299 and different each other pairs are ignored ts taken directly. + * if all of ts are in -1e299,1e299 but some are not different each other ts are ignored pairs used + * if some of ts are out of -1e299,1e299 ts are ignored pairs used + */ +std::vector TimeKeeper::getTimeStepsRegardingPolicy0(const std::vector< std::pair >& tsPairs, const std::vector& ts) const +{ + std::size_t sz(ts.size()); + bool isInHumanRange(true); + std::set s; + for(std::size_t i=0;i=1e299) + isInHumanRange=false; + } + if(!isInHumanRange) + return processedUsingPairOfIds(tsPairs); + if(s.size()!=sz) + return processedUsingPairOfIds(tsPairs); + _postprocessed_time=ts; + return getPostProcessedTime(); +} + +/*! + * policy = 1 : + * idem than 0, except that ts is preaccumulated before invoking policy 0. + */ +std::vector TimeKeeper::getTimeStepsRegardingPolicy1(const std::vector< std::pair >& tsPairs, const std::vector& ts) const +{ + std::size_t sz(ts.size()); + std::vector ts2(sz); + double acc(0.); + for(std::size_t i=0;i TimeKeeper::getTheVectOfBool() const +{ + std::size_t sz(_activated_ts.size()); + std::vector ret(sz); + for(std::size_t i=0;i TimeKeeper::processedUsingPairOfIds(const std::vector< std::pair >& tsPairs) const +{ + std::size_t sz(tsPairs.size()); + std::set s0,s1; + for(std::size_t i=0;i(true,oss.str()); + } +} diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx new file mode 100644 index 00000000..56100368 --- /dev/null +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx @@ -0,0 +1,189 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __MEDFILEFIELDREPRESENTATIONTREE_HXX__ +#define __MEDFILEFIELDREPRESENTATIONTREE_HXX__ + +#include "MEDFileMesh.hxx" +#include "MEDFileField.hxx" + +#include "vtkType.h" + +#include + +class vtkQuadratureSchemeDefinition; +class vtkMutableDirectedGraph; +class vtkUnstructuredGrid; +class vtkRectilinearGrid; +class vtkStructuredGrid; +class vtkVariantArray; +class vtkIdTypeArray; +class vtkDoubleArray; +class vtkDataSet; + +class TimeKeeper; +class MEDTimeReq; + +class ELGACmp +{ +public: + vtkIdTypeArray *findOrCreate(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew) const; + void appendELGAIfAny(vtkDataSet *ds) const; + ~ELGACmp(); +private: + vtkIdTypeArray *isExisting(const std::vector& locsReallyUsed, vtkDoubleArray *vtkd) const; + vtkIdTypeArray *createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const; +private: + //! size of _loc_names is equal to _elgas. + mutable std::vector< std::vector > _loc_names; + //! size of _elgas is equal to _loc_names. All instances in _elgas are \b not null. + mutable std::vector _elgas; + //! same size than _loc_names and _elgas. + mutable std::vector< std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > > > _defs; +}; + +class MEDFileFieldRepresentationLeavesArrays : public ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr +{ +public: + MEDFileFieldRepresentationLeavesArrays(); + MEDFileFieldRepresentationLeavesArrays(const ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr& arr); + MEDFileFieldRepresentationLeavesArrays& operator=(const MEDFileFieldRepresentationLeavesArrays& other); + int getId() const; + void setId(int& id) const; + void feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& comSupStr, std::vector& names) const; + bool getStatus() const; + bool setStatus(bool status) const; + std::string getZeName() const; + void appendFields(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDMeshMultiLev *mml, const ParaMEDMEM::MEDFileMeshStruct *mst, vtkDataSet *ds) const; + void appendELGAIfAny(vtkDataSet *ds) const; +public: + static const char ZE_SEP[]; + static const char TS_STR[]; + static const char COM_SUP_STR[]; + static const char FAMILY_ID_CELL_NAME[]; + static const char NUM_ID_CELL_NAME[]; + static const char FAMILY_ID_NODE_NAME[]; + static const char NUM_ID_NODE_NAME[]; +private: + mutable bool _activated; + mutable int _id; + mutable std::string _ze_name; + mutable std::string _ze_full_name; + ELGACmp _elga_cmp; +}; + +class MEDFileFieldRepresentationLeaves +{ +public: + MEDFileFieldRepresentationLeaves(); + MEDFileFieldRepresentationLeaves(const std::vector< ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr >& arr, + const ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr& fsp); + ~MEDFileFieldRepresentationLeaves(); + bool empty() const; + void setId(int& id) const; + std::string getMeshName() const; + int getNumberOfArrays() const; + int getNumberOfTS() const; + void feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& compSupStr, std::vector& names) const; + bool containId(int id) const; + bool containZeName(const char *name, int& id) const; + bool isActivated() const; + void printMySelf(std::ostream& os) const; + void activateAllArrays() const; + const MEDFileFieldRepresentationLeavesArrays& getLeafArr(int id) const; + std::vector getTimeSteps(const TimeKeeper& tk) const; + std::vector< std::pair > getTimeStepsInCoarseMEDFileFormat(std::vector& ts) const; + std::string getHumanReadableOverviewOfTS() const; + vtkDataSet *buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDFileMeshes *meshes) const; +private: + vtkUnstructuredGrid *buildVTKInstanceNoTimeInterpolationUnstructured(ParaMEDMEM::MEDUMeshMultiLev *mm) const; + vtkRectilinearGrid *buildVTKInstanceNoTimeInterpolationCartesian(ParaMEDMEM::MEDCMeshMultiLev *mm) const; + vtkStructuredGrid *buildVTKInstanceNoTimeInterpolationCurveLinear(ParaMEDMEM::MEDCurveLinearMeshMultiLev *mm) const; + void appendFields(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDMeshMultiLev *mml, const ParaMEDMEM::MEDFileMeshes *meshes, vtkDataSet *ds) const; +private: + std::vector _arrays; + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr _fsp; + mutable vtkDataSet *_cached_ds; +}; + +class MEDFileFieldRepresentationTree +{ +public: + MEDFileFieldRepresentationTree(); + int getNumberOfLeavesArrays() const; + void assignIds() const; + void activateTheFirst() const; + void feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector& names) const; + std::string feedSILForFamsAndGrps(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector& names) const; + std::string getNameOf(int id) const; + bool getStatusOf(int id) const; + int getIdHavingZeName(const char *name) const; + bool changeStatusOfAndUpdateToHaveCoherentVTKDataSet(int id, bool status) const; + int getMaxNumberOfTimeSteps() const; + // + std::string getDftMeshName() const; + std::vector getTimeSteps(int& lev0, const TimeKeeper& tk) const; + vtkDataSet *buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk) const; + void printMySelf(std::ostream& os) const; + //non const methods + void loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv); + void removeEmptyLeaves(); + // static methods + static bool IsFieldMeshRegardingInfo(const std::vector& compInfos); +public: + static const char ROOT_OF_GRPS_IN_TREE[]; + static const char ROOT_OF_FAM_IDS_IN_TREE[]; + static const char COMPO_STR_TO_LOCATE_MESH_DA[]; +private: + const MEDFileFieldRepresentationLeavesArrays& getLeafArr(int id) const; + const MEDFileFieldRepresentationLeaves& getTheSingleActivated(int& lev0, int& lev1, int& lev2) const; + static ParaMEDMEM::MEDFileFields *BuildFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms); + static void AppendFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms, ParaMEDMEM::MEDFileFields *ret); +private: + // 1st : timesteps, 2nd : meshName, 3rd : common support + std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > > _data_structure; + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr _ms; + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr _fields; +}; + +class TimeKeeper +{ +public: + TimeKeeper(int policy); + int getPolicy() const { return _policy; } + void setPolicy(int policy) { _policy=policy; } + std::vector getTimeStepsRegardingPolicy(const std::vector< std::pair >& tsPairs, const std::vector& ts) const; + int getTimeStepIdFrom(double timeReq) const; + std::vector getPostProcessedTime() const { return _postprocessed_time; } + void printSelf(std::ostream& oss) const; + std::vector getTheVectOfBool() const; + std::vector< std::pair >& getTimesFlagArray() { return _activated_ts; } + void setMaxNumberOfTimeSteps(int maxNumberOfTS); +private: + std::vector getTimeStepsRegardingPolicy0(const std::vector< std::pair >& tsPairs, const std::vector& ts) const; + std::vector getTimeStepsRegardingPolicy1(const std::vector< std::pair >& tsPairs, const std::vector& ts) const; + std::vector processedUsingPairOfIds(const std::vector< std::pair >& tsPairs) const; +private: + int _policy; + mutable std::vector _postprocessed_time; + std::vector< std::pair > _activated_ts; +}; + +#endif diff --git a/src/Plugins/MEDReader/IO/MEDTimeReq.cxx b/src/Plugins/MEDReader/IO/MEDTimeReq.cxx new file mode 100644 index 00000000..e2b0d939 --- /dev/null +++ b/src/Plugins/MEDReader/IO/MEDTimeReq.cxx @@ -0,0 +1,133 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "MEDTimeReq.hxx" + +#include + +MEDTimeReq::~MEDTimeReq() +{ +} + +/////////// + +MEDStdTimeReq::~MEDStdTimeReq() +{ +} + +MEDStdTimeReq::MEDStdTimeReq(int timeReq):_time_req(timeReq) +{ +} + +/*! + * Does nothing ! It is not a bug + */ +void MEDStdTimeReq::setNumberOfTS(int nbOfTS) const +{ +} + +int MEDStdTimeReq::size() const +{ + return 1; +} + +int MEDStdTimeReq::getCurrent() const +{ + return _time_req; +} + +/*! + * Does nothing ! It is not a bug + */ +void MEDStdTimeReq::initIterator() const +{ +} + +std::string MEDStdTimeReq::buildName(const std::string& name) const +{ + return std::string(name); +} + +/*! + * Does nothing ! It is not a bug + */ +void MEDStdTimeReq::operator++() const +{ +} + +/////////// + +MEDModeTimeReq::MEDModeTimeReq(const std::vector& v):_v(v),_it(0),_sz(0) +{ +} + +MEDModeTimeReq::~MEDModeTimeReq() +{ +} + +int MEDModeTimeReq::size() const +{ + int ret(0); + for(int i=0;i<_sz;i++) + { + if(_v[i]) + ret++; + } + return ret; +} + +int MEDModeTimeReq::getCurrent() const +{ + return _it; +} + +void MEDModeTimeReq::setNumberOfTS(int nbOfTS) const +{ + _sz=nbOfTS; +} + +void MEDModeTimeReq::initIterator() const +{ + for(_it=0;_it<_sz;_it++) + if(_v[_it]) + return; +} + +std::string MEDModeTimeReq::buildName(const std::string& name) const +{ + std::ostringstream oss,oss2,oss3; + oss << name << " ["; + // + oss3 << _sz-1; + std::size_t len(oss3.str().length()); + oss2.width(len); + oss2.fill('0'); oss2 << _it; + // + oss << oss2.str() << "]"; + return oss.str(); +} + +void MEDModeTimeReq::operator++() const +{ + _it++; + for(;_it<_sz;_it++) + if(_v[_it]) + return; +} diff --git a/src/Plugins/MEDReader/IO/MEDTimeReq.hxx b/src/Plugins/MEDReader/IO/MEDTimeReq.hxx new file mode 100644 index 00000000..f4192411 --- /dev/null +++ b/src/Plugins/MEDReader/IO/MEDTimeReq.hxx @@ -0,0 +1,72 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __MEDTIMEREQ_HXX__ +#define __MEDTIMEREQ_HXX__ + +#include +#include + +class MEDTimeReq +{ +public: + virtual int size() const = 0; + virtual void setNumberOfTS(int nbOfTS) const = 0; + virtual std::string buildName(const std::string& name) const = 0; + virtual void initIterator() const = 0; + virtual int getCurrent() const = 0; + virtual void operator++() const = 0; + virtual ~MEDTimeReq(); +}; + +class MEDStdTimeReq : public MEDTimeReq +{ +public: + MEDStdTimeReq(int timeReq); + int size() const; + int getCurrent() const; + void initIterator() const; + void setNumberOfTS(int nbOfTS) const; + std::string buildName(const std::string& name) const; + void operator++() const; +public: + ~MEDStdTimeReq(); +private: + int _time_req; +}; + +class MEDModeTimeReq : public MEDTimeReq +{ +public: + MEDModeTimeReq(const std::vector& v); + ~MEDModeTimeReq(); + int size() const; + int getCurrent() const; + void initIterator() const; + void setNumberOfTS(int nbOfTS) const; + std::string buildName(const std::string& name) const; + void operator++() const; +private: + std::vector _v; + mutable int _it; + mutable int _sz; +}; + +#endif diff --git a/src/Plugins/MedReader/IO/vtkMed.h b/src/Plugins/MEDReader/IO/MEDUtilities.cxx similarity index 63% rename from src/Plugins/MedReader/IO/vtkMed.h rename to src/Plugins/MEDReader/IO/MEDUtilities.cxx index 9a43b3ca..4ace147b 100644 --- a/src/Plugins/MedReader/IO/vtkMed.h +++ b/src/Plugins/MEDReader/IO/MEDUtilities.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,30 +16,12 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay -#ifndef __vtkMed_h__ -#define __vtkMed_h__ +#include "MEDUtilities.hxx" -#include "hdf5.h" -#include "config.h" +#include "vtkInformationIntegerKey.h" +#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" -extern "C" -{ -#include "med.h" -#define MESGERR 1 -#include "med_utils.h" - -#ifdef MED_HAVE_MPI -#ifdef MedReader_BUILD_PARALLEL -#define MedReader_HAVE_PARALLEL_INFRASTRUCTURE -#endif -#endif - -//#define MED_HAVE_MPI 1 -//#include "mpi.h" -#ifdef MedReader_HAVE_PARALLEL_INFRASTRUCTURE -#include "mpi.h" -#endif -} - -#endif //__vtkMed_h__ +vtkInformationKeyMacro(MEDUtilities,ELGA,Integer); +vtkInformationKeyMacro(MEDUtilities,ELNO,Integer); diff --git a/src/Plugins/MedReader/IO/vtkMedPolarGrid.cxx b/src/Plugins/MEDReader/IO/MEDUtilities.hxx similarity index 67% rename from src/Plugins/MedReader/IO/vtkMedPolarGrid.cxx rename to src/Plugins/MEDReader/IO/MEDUtilities.hxx index d9721d40..b9be2e32 100644 --- a/src/Plugins/MedReader/IO/vtkMedPolarGrid.cxx +++ b/src/Plugins/MEDReader/IO/MEDUtilities.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,23 +16,18 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay -#include "vtkMedPolarGrid.h" +#ifndef __MEDUTILITIES_HXX__ +#define __MEDUTILITIES_HXX__ -#include "vtkObjectFactory.h" +class vtkInformationIntegerKey; -// vtkCxxRevisionMacro(vtkMedPolarGrid, "$Revision$") -vtkStandardNewMacro(vtkMedPolarGrid) - -vtkMedPolarGrid::vtkMedPolarGrid() -{ -} - -vtkMedPolarGrid::~vtkMedPolarGrid() +class MEDUtilities { -} +public: + static vtkInformationIntegerKey *ELGA(); + static vtkInformationIntegerKey *ELNO(); +}; -void vtkMedPolarGrid::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} +#endif diff --git a/src/Plugins/MedReader/IO/Testing/CMakeLists.txt b/src/Plugins/MEDReader/IO/Testing/CMakeLists.txt similarity index 97% rename from src/Plugins/MedReader/IO/Testing/CMakeLists.txt rename to src/Plugins/MEDReader/IO/Testing/CMakeLists.txt index b88d537c..be19ded8 100644 --- a/src/Plugins/MedReader/IO/Testing/CMakeLists.txt +++ b/src/Plugins/MEDReader/IO/Testing/CMakeLists.txt @@ -17,4 +17,4 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -add_subdirectory(Cxx) \ No newline at end of file +ADD_SUBDIRECTORY(Cxx) \ No newline at end of file diff --git a/src/Plugins/MEDReader/IO/Testing/Cxx/CMakeLists.txt b/src/Plugins/MEDReader/IO/Testing/Cxx/CMakeLists.txt new file mode 100644 index 00000000..85e0b42c --- /dev/null +++ b/src/Plugins/MEDReader/IO/Testing/Cxx/CMakeLists.txt @@ -0,0 +1,67 @@ +# Copyright (C) 2010-2013 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../..) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../..) +INCLUDE_DIRECTORIES(${MEDFILE_INCLUDE_DIRS} ${HDF5_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${MED_ROOT_DIR}/include/salome) + +SET( TestMedReader_SRCS TestMedReader.cxx ) + +SET( TestMedPolyhedron_SRCS TestMedPolyhedron.cxx ) + +SET( TestMedReadPolyhedron_SRCS TestMedReadPolyhedron.cxx ) + +SET( TestMedDescendingPolyhedron_SRCS TestMedDescendingPolyhedron.cxx ) + +SET( TestMedReadDescendingPolyhedron_SRCS TestMedReadDescendingPolyhedron.cxx ) + +SET( TestMedWriteOcta12_SRCS TestMedWriteOcta12.cxx ) + +SET( TestMedParallelRead_SRCS TestMedParallelRead.cxx ) + +SET( TestMedParallelWrite_SRCS TestMedParallelWrite.cxx ) + +ADD_EXECUTABLE(TestReading0 TestReading0.cxx) +TARGET_LINK_LIBRARIES(TestReading0 MEDLoaderForPV vtkCommonDataModel) + +#ADD_EXECUTABLE(TestMedReader ${TestMedReader_SRCS}) +#ADD_EXECUTABLE(TestMedPolyhedron ${TestMedPolyhedron_SRCS}) +#ADD_EXECUTABLE(TestMedReadPolyhedron ${TestMedReadPolyhedron_SRCS}) +#ADD_EXECUTABLE(TestMedDescendingPolyhedron ${TestMedDescendingPolyhedron_SRCS}) +#ADD_EXECUTABLE(TestMedReadDescendingPolyhedron ${TestMedReadDescendingPolyhedron_SRCS}) +#ADD_EXECUTABLE(TestMedWriteOcta12 ${TestMedWriteOcta12_SRCS}) + +IF(${HDF5_IS_PARALLEL}) + ADD_EXECUTABLE(TestMedParallelRead ${TestMedParallelRead_SRCS}) + ADD_EXECUTABLE(TestMedParallelWrite ${TestMedParallelWrite_SRCS}) + TARGET_LINK_LIBRARIES(TestMedParallelRead vtkParallelCore ${MED_LIBRARIES}) + TARGET_LINK_LIBRARIES(TestMedParallelWrite vtkParallelCore ${MED_LIBRARIES}) +ENDIF(${HDF5_IS_PARALLEL}) + +INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../module.cmake) + +#vtkIOMPIImage +#TARGET_LINK_LIBRARIES(TestMedReader ${${vtk-module-test}_DEPENDS} ${MEDFILE_C_LIBRARIES}) +#TARGET_LINK_LIBRARIES(TestMedPolyhedron ${MEDFILE_C_LIBRARIES}) +#TARGET_LINK_LIBRARIES(TestMedReadPolyhedron ${MEDFILE_C_LIBRARIES}) +#TARGET_LINK_LIBRARIES(TestMedDescendingPolyhedron ${MEDFILE_C_LIBRARIES}) +#TARGET_LINK_LIBRARIES(TestMedReadDescendingPolyhedron ${MEDFILE_C_LIBRARIES}) +#TARGET_LINK_LIBRARIES(TestMedWriteOcta12 ${MEDFILE_C_LIBRARIES}) + diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedDescendingPolyhedron.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedDescendingPolyhedron.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedDescendingPolyhedron.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedDescendingPolyhedron.cxx diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedParallelRead.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedParallelRead.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedParallelRead.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedParallelRead.cxx diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedParallelWrite.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedParallelWrite.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedParallelWrite.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedParallelWrite.cxx diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedPolyhedron.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedPolyhedron.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedPolyhedron.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedPolyhedron.cxx diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedReadDescendingPolyhedron.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReadDescendingPolyhedron.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedReadDescendingPolyhedron.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReadDescendingPolyhedron.cxx diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedReadPolyhedron.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReadPolyhedron.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedReadPolyhedron.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReadPolyhedron.cxx diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedReader.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReader.cxx similarity index 95% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedReader.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReader.cxx index d881a1b3..6012fa0a 100644 --- a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedReader.cxx +++ b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedReader.cxx @@ -25,18 +25,17 @@ #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkCylinderSource.h" -#include "vtkMedReader.h" +#include "vtkMEDReader.h" #include "vtkDataObject.h" #include "vtkDataSetAttributes.h" #include "vtkPolyDataNormals.h" -#include "vtkMedReader.h" #include "vtkTestUtilities.h" #include "vtkRegressionTestImage.h" int main(int argc, char *argv[]) { - vtkMedReader* reader = vtkMedReader::New(); + vtkMEDReader* reader = vtkMEDReader::New(); reader->SetFileName(argv[1]); reader->Update(); diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/TestMedWriteOcta12.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestMedWriteOcta12.cxx similarity index 100% rename from src/Plugins/MedReader/IO/Testing/Cxx/TestMedWriteOcta12.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestMedWriteOcta12.cxx diff --git a/src/Plugins/MedReader/IO/vtkMedCartesianGrid.cxx b/src/Plugins/MEDReader/IO/Testing/Cxx/TestReading0.cxx similarity index 66% rename from src/Plugins/MedReader/IO/vtkMedCartesianGrid.cxx rename to src/Plugins/MEDReader/IO/Testing/Cxx/TestReading0.cxx index c096256b..a9dbec04 100644 --- a/src/Plugins/MedReader/IO/vtkMedCartesianGrid.cxx +++ b/src/Plugins/MEDReader/IO/Testing/Cxx/TestReading0.cxx @@ -16,23 +16,17 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay -#include "vtkMedCartesianGrid.h" +#define private public +#define protected public +#include "MEDFileFieldRepresentationTree.hxx" -#include "vtkObjectFactory.h" - -// vtkCxxRevisionMacro(vtkMedCartesianGrid, "$Revision$") -vtkStandardNewMacro(vtkMedCartesianGrid) - -vtkMedCartesianGrid::vtkMedCartesianGrid() -{ -} - -vtkMedCartesianGrid::~vtkMedCartesianGrid() -{ -} - -void vtkMedCartesianGrid::PrintSelf(ostream& os, vtkIndent indent) +int main(int argc, char *argv[]) { - this->Superclass::PrintSelf(os, indent); + MEDFileFieldRepresentationTree *tree(new MEDFileFieldRepresentationTree); + tree->loadMainStructureOfFile("/export/home/geay/Salome7/V7_main/ForMEDReader1.med",true); + std::cerr << tree->_data_structure[0][0][0].getMeshName() << std::endl; + delete tree; + return 0; } diff --git a/src/Plugins/MedReader/IO/config.h.cmake b/src/Plugins/MEDReader/IO/config.h.cmake similarity index 92% rename from src/Plugins/MedReader/IO/config.h.cmake rename to src/Plugins/MEDReader/IO/config.h.cmake index bb04c421..1e22fe7f 100644 --- a/src/Plugins/MedReader/IO/config.h.cmake +++ b/src/Plugins/MEDReader/IO/config.h.cmake @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -22,4 +22,4 @@ #cmakedefine MedReader_BUILD_PARALLEL - #endif // __CONFIG_H__ \ No newline at end of file + #endif // __CONFIG_H__ diff --git a/src/Plugins/MedReader/IO/module.cmake b/src/Plugins/MEDReader/IO/module.cmake similarity index 56% rename from src/Plugins/MedReader/IO/module.cmake rename to src/Plugins/MEDReader/IO/module.cmake index 80282b0a..645d5d44 100644 --- a/src/Plugins/MedReader/IO/module.cmake +++ b/src/Plugins/MEDReader/IO/module.cmake @@ -1,14 +1,9 @@ SET(VTK_LIBS vtkCommonExecutionModel vtkParallelCore) -vtk_module(vtkMedReader +vtk_module(vtkMEDReader DEPENDS ${VTK_LIBS} - vtkRenderingFreeTypeOpenGL - vtkRenderingOpenGL - vtkRenderingFreeType - vtkRenderingCore - vtkInteractionStyle - TEST_DEPENDS + TEST_DEPENDS vtkRenderingCore vtkTestingRendering vtkInteractionStyle diff --git a/src/Plugins/IntegrationPoints/vtkELNOFilter.cxx b/src/Plugins/MEDReader/IO/vtkELNOFilter.cxx similarity index 97% rename from src/Plugins/IntegrationPoints/vtkELNOFilter.cxx rename to src/Plugins/MEDReader/IO/vtkELNOFilter.cxx index 640c1bef..535adb48 100644 --- a/src/Plugins/IntegrationPoints/vtkELNOFilter.cxx +++ b/src/Plugins/MEDReader/IO/vtkELNOFilter.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -28,7 +28,7 @@ #include "vtkQuadratureSchemeDefinition.h" #include "vtkUnstructuredGrid.h" -//vtkCxxRevisionMacro(vtkELNOFilter, "$Revision$"); +//vtkCxxRevisionMacro(vtkELNOFilter, "$Revision: 1.2.2.2 $"); vtkStandardNewMacro(vtkELNOFilter); vtkELNOFilter::vtkELNOFilter() diff --git a/src/Plugins/IntegrationPoints/vtkELNOFilter.h b/src/Plugins/MEDReader/IO/vtkELNOFilter.h similarity index 97% rename from src/Plugins/IntegrationPoints/vtkELNOFilter.h rename to src/Plugins/MEDReader/IO/vtkELNOFilter.h index 37e538fd..54a5e750 100644 --- a/src/Plugins/IntegrationPoints/vtkELNOFilter.h +++ b/src/Plugins/MEDReader/IO/vtkELNOFilter.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public diff --git a/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx new file mode 100644 index 00000000..c0bfddd4 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx @@ -0,0 +1,186 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "vtkELNOMeshFilter.h" +#include "vtkInformation.h" +#include "vtkInformationVector.h" +#include "vtkInformationIntegerKey.h" +#include "vtkObjectFactory.h" +#include "vtkPolyDataAlgorithm.h" +#include "vtkPolyData.h" +#include "vtkIdTypeArray.h" +#include "vtkQuadratureSchemeDefinition.h" +#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" +#include "vtkUnstructuredGrid.h" +#include "vtkShrinkFilter.h" +#include "vtkSmartPointer.h" +#include "vtkPointData.h" +#include "vtkCellData.h" +#include "vtkIdList.h" +#include "vtkCell.h" + +#include "MEDUtilities.hxx" + +#include + +vtkStandardNewMacro(vtkELNOMeshFilter); + +vtkELNOMeshFilter::vtkELNOMeshFilter() +{ +} + +vtkELNOMeshFilter::~vtkELNOMeshFilter() +{ +} + +int vtkELNOMeshFilter::RequestData(vtkInformation *request, + vtkInformationVector **input, vtkInformationVector *output) +{ + vtkUnstructuredGrid *usgIn = vtkUnstructuredGrid::SafeDownCast( + input[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT())); + + vtkUnstructuredGrid *usgOut = vtkUnstructuredGrid::SafeDownCast( + output->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT())); + + if(usgIn == NULL || usgOut == NULL) + { + vtkDebugMacro("vtkELNOMeshFilter not correctly configured : Invalid input or output !"); + return 0; + } + + // creates offsets array + + // first shrink the input + vtkUnstructuredGrid* usgInClone = usgIn->NewInstance(); + usgInClone->ShallowCopy(usgIn); + vtkSmartPointer shrink(vtkSmartPointer::New()); + shrink->SetInputData(usgInClone); + shrink->SetShrinkFactor(0.9999); + shrink->Update(); + vtkUnstructuredGrid *shrinked(shrink->GetOutput()); + usgInClone->Delete(); + usgOut->ShallowCopy(shrinked); + // OK for the output + + // now copy ELNO data. Start by verifying if it is possible to + // shallow copy the array. + vtkInformation *info(usgIn->GetInformation()); + // + vtkIdType nVerts(shrinked->GetNumberOfPoints()),ncell(usgIn->GetNumberOfCells()); + // first loop through all cells to check if a shallow copy is possible + bool shallowok(true);// Anthony : checks that shrink works well. Really necessary ? + vtkIdType previous(0),offset(0); + + for(vtkIdType cellId = 0; cellId < ncell; cellId++) + { + if(offset != previous) + { + shallowok = false; + break; + } + vtkCell *cell(usgIn->GetCell(cellId)); + vtkIdType nbptsInCell(cell->GetNumberOfPoints()); + previous = offset + nbptsInCell; + // + offset += nbptsInCell ; + } + // + if(shallowok) + shallowok = (previous == nVerts); + + vtkFieldData *fielddata(usgIn->GetFieldData()); + for(int index = 0; index < fielddata->GetNumberOfArrays(); index++) + { + vtkDataArray *data(fielddata->GetArray(index)); + vtkQuadratureSchemeDefinition **dict(0); + vtkInformationQuadratureSchemeDefinitionVectorKey *key(vtkQuadratureSchemeDefinition::DICTIONARY()); + if(key->Has(data->GetInformation())) + { + int dictSize(key->Size(data->GetInformation())); + dict=new vtkQuadratureSchemeDefinition *[dictSize]; + key->GetRange(data->GetInformation(),dict,0,0,dictSize); + } + if(data == NULL) + continue; + + vtkInformation *info(data->GetInformation()); + const char *arrayOffsetName = info->Get(vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME()); + + bool isELGA(false); + + if(arrayOffsetName) + { + vtkFieldData *cellData(usgIn->GetCellData()); + vtkDataArray *offData(cellData->GetArray(arrayOffsetName)); + isELGA=offData->GetInformation()->Get(MEDUtilities::ELGA())==1; + } + + if(arrayOffsetName == NULL || isELGA) + { + if(shallowok && data->GetNumberOfTuples()==nVerts )// Anthony : is it not a little confusing to assign a FieldData on Points because the number of tuples fits the number of nodes of shrinked mesh ? + usgOut->GetPointData()->AddArray(data); + else + shrinked->GetFieldData()->AddArray(data); + continue; + } + else + { + vtkDataArray* newArray = data->NewInstance(); + newArray->SetName(data->GetName()); + usgOut->GetPointData()->AddArray(newArray); + newArray->SetNumberOfComponents(data->GetNumberOfComponents()); + newArray->SetNumberOfTuples(usgOut->GetNumberOfPoints()); + newArray->CopyComponentNames(data); + newArray->Delete(); + vtkIdList *ids(vtkIdList::New()); + vtkIdType offset(0); + for(vtkIdType cellId = 0; cellId < ncell; cellId++) + { + int cellType = shrinked->GetCellType(cellId); + shrinked->GetCellPoints(cellId, ids); + for(int id = 0; id < dict[cellType]->GetNumberOfQuadraturePoints(); id++) + { + const double * w = dict[cellType]->GetShapeFunctionWeights(id); + int j; + for(j = 0; j < dict[cellType]->GetNumberOfNodes(); j++) + { + if(w[j] == 1.0) + break; + } + if(j == dict[cellType]->GetNumberOfNodes()) + { + j = id; + } + newArray->SetTuple(ids->GetId(id), offset + j, data); + } + vtkCell *cell(usgIn->GetCell(cellId)); + vtkIdType nbptsInCell(cell->GetNumberOfPoints()); + offset+=nbptsInCell; + } + ids->FastDelete(); + } + delete [] dict; + } + return 1; +} + +void vtkELNOMeshFilter::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); +} diff --git a/src/Plugins/IntegrationPoints/vtkELNOMeshFilter.h b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h similarity index 96% rename from src/Plugins/IntegrationPoints/vtkELNOMeshFilter.h rename to src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h index 405d52f8..611972e9 100644 --- a/src/Plugins/IntegrationPoints/vtkELNOMeshFilter.h +++ b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public diff --git a/src/Plugins/IntegrationPoints/vtkELNOSurfaceFilter.cxx b/src/Plugins/MEDReader/IO/vtkELNOSurfaceFilter.cxx similarity index 98% rename from src/Plugins/IntegrationPoints/vtkELNOSurfaceFilter.cxx rename to src/Plugins/MEDReader/IO/vtkELNOSurfaceFilter.cxx index 0403969f..31fdbce9 100644 --- a/src/Plugins/IntegrationPoints/vtkELNOSurfaceFilter.cxx +++ b/src/Plugins/MEDReader/IO/vtkELNOSurfaceFilter.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -201,7 +201,7 @@ int vtkELNOSurfaceFilter::RequestData(vtkInformation *request, } if(j==dict[originalCellType]->GetNumberOfNodes()) { - vtkErrorMacro("cannot find elno weigth."); + //vtkErrorMacro("cannot find elno weigth."); j=id; } newArray->SetTuple(shrinkedId, offset+j, data); diff --git a/src/Plugins/IntegrationPoints/vtkELNOSurfaceFilter.h b/src/Plugins/MEDReader/IO/vtkELNOSurfaceFilter.h similarity index 96% rename from src/Plugins/IntegrationPoints/vtkELNOSurfaceFilter.h rename to src/Plugins/MEDReader/IO/vtkELNOSurfaceFilter.h index 3299ef64..add03c96 100644 --- a/src/Plugins/IntegrationPoints/vtkELNOSurfaceFilter.h +++ b/src/Plugins/MEDReader/IO/vtkELNOSurfaceFilter.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public diff --git a/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx b/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx new file mode 100644 index 00000000..ff5fde36 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkExtractCellType.cxx @@ -0,0 +1,463 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "vtkExtractCellType.h" +#include "MEDFileFieldRepresentationTree.hxx" +#include "MEDFileFieldOverView.hxx" + +#include "vtkAdjacentVertexIterator.h" +#include "vtkIntArray.h" +#include "vtkCellData.h" +#include "vtkPointData.h" + +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkUnstructuredGrid.h" +#include "vtkMultiBlockDataSet.h" + +#include "vtkInformationStringKey.h" +#include "vtkAlgorithmOutput.h" +#include "vtkObjectFactory.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkDataSet.h" +#include "vtkInformationVector.h" +#include "vtkInformation.h" +#include "vtkDataArraySelection.h" +#include "vtkTimeStamp.h" +#include "vtkInEdgeIterator.h" +#include "vtkInformationDataObjectKey.h" +#include "vtkExecutive.h" +#include "vtkVariantArray.h" +#include "vtkStringArray.h" +#include "vtkDoubleArray.h" +#include "vtkCharArray.h" +#include "vtkUnsignedCharArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkDemandDrivenPipeline.h" +#include "vtkDataObjectTreeIterator.h" +#include "vtkThreshold.h" + +#include +#include + +vtkStandardNewMacro(vtkExtractCellType); + +vtkCxxSetObjectMacro(vtkExtractCellType, SIL, vtkMutableDirectedGraph); + +/////////////////// + +class ExtractCellTypeStatus +{ +public: + ExtractCellTypeStatus():_status(false),_vtkt(-1),_mct(INTERP_KERNEL::NORM_ERROR) { } + ExtractCellTypeStatus(int vtkt, INTERP_KERNEL::NormalizedCellType mct); + bool isSame(int vtkt, INTERP_KERNEL::NormalizedCellType mct) const { return _vtkt==vtkt && _mct==mct; } + bool getStatus() const { return _status; } + void setStatus(bool status) const { _status=status; } + void cpyStatusFrom(const ExtractCellTypeStatus& other) { _status=other._status; } + std::string getKey() const { return _type_str; } + const char *getKeyOfEntry() const { return _type_str.c_str(); } + int getVTKCellType() const { return _vtkt; } + void printMySelf(std::ostream& os) const; + bool isSameAs(const ExtractCellTypeStatus& other) const; + void feedSIL(vtkMutableDirectedGraph *sil, vtkIdType root, vtkVariantArray *childEdge, std::vector& names) const; +protected: + mutable bool _status; + int _vtkt; + INTERP_KERNEL::NormalizedCellType _mct; + std::string _type_str; +}; + +class vtkExtractCellType::vtkExtractCellTypeInternal +{ +public: + vtkExtractCellTypeInternal():_ref_mtime(0) { } + int getNumberOfEntries() const; + const char *getKeyOfEntry(int i) const; + bool getStatusOfEntryStr(const char *entry) const; + void setStatusOfEntryStr(const char *entry, bool status) const; + void feedSIL(vtkMutableDirectedGraph *sil) const; + std::vector getIdsToKeep() const; + void printMySelf(std::ostream& os) const; + bool setRefTime(vtkObject *input) const; + // non const methods + void loadFrom(const std::map& m); +private: + const ExtractCellTypeStatus& getEntry(const char *entry) const; + bool checkSame(const std::map& m) const; +private: + std::vector _types; + mutable unsigned long _ref_mtime; +}; + +bool vtkExtractCellType::vtkExtractCellTypeInternal::setRefTime(vtkObject *input) const +{ + unsigned long mtime(input->GetMTime()); + if(mtime>_ref_mtime) + { + _ref_mtime=mtime; + return true; + } + else + return false; +} + +std::vector vtkExtractCellType::vtkExtractCellTypeInternal::getIdsToKeep() const +{ + std::vector ret; + for(std::vector::const_iterator it=_types.begin();it!=_types.end();it++) + { + if((*it).getStatus()) + ret.push_back((*it).getVTKCellType()); + } + return ret; +} + +void vtkExtractCellType::vtkExtractCellTypeInternal::feedSIL(vtkMutableDirectedGraph *sil) const +{ + vtkSmartPointer childEdge(vtkSmartPointer::New()); + childEdge->InsertNextValue(0); + vtkSmartPointer crossEdge(vtkSmartPointer::New()); + crossEdge->InsertNextValue(1); + // CrossEdge is an edge linking hierarchies. + vtkUnsignedCharArray* crossEdgesArray=vtkUnsignedCharArray::New(); + crossEdgesArray->SetName("CrossEdges"); + sil->GetEdgeData()->AddArray(crossEdgesArray); + crossEdgesArray->Delete(); + std::vector names; + // Add global fields root + vtkIdType root(sil->AddVertex()); + names.push_back("CellTypesTree"); + // + for(std::vector::const_iterator it=_types.begin();it!=_types.end();it++) + { + (*it).feedSIL(sil,root,childEdge,names); + } + // This array is used to assign names to nodes. + vtkStringArray *namesArray(vtkStringArray::New()); + namesArray->SetName("Names"); + namesArray->SetNumberOfTuples(sil->GetNumberOfVertices()); + sil->GetVertexData()->AddArray(namesArray); + namesArray->Delete(); + std::vector::const_iterator iter; + vtkIdType cc; + for(cc=0, iter=names.begin(); iter!=names.end(); ++iter, ++cc) + namesArray->SetValue(cc,(*iter).c_str()); +} + +void vtkExtractCellType::vtkExtractCellTypeInternal::loadFrom(const std::map& m) +{ + if(checkSame(m)) + return; + // + std::size_t sz(m.size()),ii(0); + _types.resize(sz); + for(std::map::const_iterator it=m.begin();it!=m.end();it++,ii++) + { + ExtractCellTypeStatus elt((*it).first,(*it).second); + _types[ii]=elt; + } +} + +int vtkExtractCellType::vtkExtractCellTypeInternal::getNumberOfEntries() const +{ + return (int) _types.size(); +} + +const char *vtkExtractCellType::vtkExtractCellTypeInternal::getKeyOfEntry(int i) const +{ + return _types[i].getKeyOfEntry(); +} + +bool vtkExtractCellType::vtkExtractCellTypeInternal::checkSame(const std::map& m) const +{ + std::size_t sz(m.size()); + if(sz!=_types.size()) + return false; + bool ret(true); + std::map::const_iterator it(m.begin()); + for(std::size_t i=0;i::const_iterator it0=_types.begin();it0!=_types.end();it0++) + if(entryCpp==(*it0).getKey()) + return *it0; + std::ostringstream oss; oss << "vtkExtractCellTypeInternal::getEntry : no such entry \"" << entry << "\"!"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +} + +bool vtkExtractCellType::vtkExtractCellTypeInternal::getStatusOfEntryStr(const char *entry) const +{ + const ExtractCellTypeStatus& elt(getEntry(entry)); + return elt.getStatus(); +} + +void vtkExtractCellType::vtkExtractCellTypeInternal::setStatusOfEntryStr(const char *entry, bool status) const +{ + const ExtractCellTypeStatus& elt(getEntry(entry)); + elt.setStatus(status); +} + +void vtkExtractCellType::vtkExtractCellTypeInternal::printMySelf(std::ostream& os) const +{ + for(std::vector::const_iterator it0=_types.begin();it0!=_types.end();it0++) + (*it0).printMySelf(os); +} + +ExtractCellTypeStatus::ExtractCellTypeStatus(int vtkt, INTERP_KERNEL::NormalizedCellType mct):_status(false),_vtkt(vtkt),_mct(mct) +{ + std::string name(INTERP_KERNEL::CellModel::GetCellModel(mct).getRepr()); + _type_str=name.substr(5);//skip "NORM_" +} + +void ExtractCellTypeStatus::printMySelf(std::ostream& os) const +{ + os << " -" << _type_str << "("; + if(_status) + os << "X"; + else + os << " "; + os << ")" << std::endl; +} + +bool ExtractCellTypeStatus::isSameAs(const ExtractCellTypeStatus& other) const +{ + return _vtkt==other._vtkt && _mct==other._mct; +} + +void ExtractCellTypeStatus::feedSIL(vtkMutableDirectedGraph *sil, vtkIdType root, vtkVariantArray *childEdge, std::vector& names) const +{ + vtkIdType InfoGeoType(sil->AddChild(root,childEdge)); + names.push_back(_type_str); + vtkIdType InfoVTKID(sil->AddChild(InfoGeoType,childEdge)); + std::ostringstream oss; oss << _vtkt; + names.push_back(oss.str()); +} + +//////////////////// + +vtkExtractCellType::vtkExtractCellType():SIL(NULL),Internal(new vtkExtractCellTypeInternal),InsideOut(0) +{ +} + +vtkExtractCellType::~vtkExtractCellType() +{ + delete this->Internal; +} + +void vtkExtractCellType::SetInsideOut(int val) +{ + if(this->InsideOut!=val) + { + this->InsideOut=val; + this->Modified(); + } +} + +int vtkExtractCellType::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + try + { + //std::cerr << "########################################## vtkExtractCellType::RequestInformation ##########################################" << std::endl; + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkInformation *inputInfo(inputVector[0]->GetInformationObject(0)); + vtkDataSet *input(0); + { + vtkDataObject *inp(inputInfo->Get(vtkDataObject::DATA_OBJECT())); + if(vtkDataSet::SafeDownCast(inp)) + input=vtkDataSet::SafeDownCast(inp); + else + { + vtkMultiBlockDataSet *inputTmp(vtkMultiBlockDataSet::SafeDownCast(inp)); + if(inputTmp) + { + if(inputTmp->GetNumberOfBlocks()!=1) + { + vtkDebugMacro("vtkExtractCellType::RequestInformation : input vtkMultiBlockDataSet must contain exactly 1 block !"); + return 0; + } + vtkDataSet *blk0(vtkDataSet::SafeDownCast(inputTmp->GetBlock(0))); + if(!blk0) + { + vtkDebugMacro("vtkExtractCellType::RequestInformation : the single block in input vtkMultiBlockDataSet must be a vtkDataSet instance !"); + return 0; + } + input=blk0; + } + else + { + vtkDebugMacro("vtkExtractCellType::RequestInformation : supported input are vtkDataSet or vtkMultiBlockDataSet !"); + return 0; + } + } + } + if(this->Internal->setRefTime(input)) + { + vtkIdType nbOfCells(input->GetNumberOfCells()); + std::map m; + for(vtkIdType cellId=0;cellIdGetCellType(cellId)); + const std::map::const_iterator it(m.find(vtkCt)); + if(it==m.end()) + { + const unsigned char *pos(std::find(ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH,vtkCt)); + if(pos==ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH) + { + vtkDebugMacro("vtkExtractCellType::RequestInformation : cell #" << cellId << " has unrecognized type !"); + return 0; + } + m[vtkCt]=(INTERP_KERNEL::NormalizedCellType)std::distance(ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,pos); + } + } + this->Internal->loadFrom(m); + if(this->SIL) + this->SIL->Delete(); + this->SIL=vtkMutableDirectedGraph::New(); + this->Internal->feedSIL(this->SIL); + // + outInfo->Set(vtkDataObject::SIL(),this->SIL); + } + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkExtractCellType::RequestInformation : " << e.what() << std::endl; + return 0; + } + return 1; +} + +vtkDataSet *FilterFamilies(vtkDataSet *input, const std::vector& idsToKeep, bool insideOut) +{ + static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@"; + vtkDataSet *output(input->NewInstance()); + output->ShallowCopy(input); + vtkSmartPointer thres(vtkSmartPointer::New()); + thres->SetInputData(output); + vtkDataSetAttributes *dscIn(input->GetCellData()),*dscIn2(input->GetPointData()); + vtkDataSetAttributes *dscOut(output->GetCellData()),*dscOut2(output->GetPointData()); + // + double vMin(insideOut==0?1.:0.),vMax(insideOut==0?2.:1.); + thres->ThresholdBetween(vMin,vMax); + // OK for the output + vtkIdType nbOfCells(input->GetNumberOfCells()); + vtkCharArray *zeSelection(vtkCharArray::New()); + zeSelection->SetName(ZE_SELECTION_ARR_NAME); + zeSelection->SetNumberOfComponents(1); + char *pt(new char[nbOfCells]); + zeSelection->SetArray(pt,nbOfCells,0,VTK_DATA_ARRAY_DELETE); + std::fill(pt,pt+nbOfCells,0); + std::vector pt2(nbOfCells,false); + for(std::vector::const_iterator it=idsToKeep.begin();it!=idsToKeep.end();it++) + { + for(vtkIdType ii=0;iiGetCellType(ii)==*it) + pt2[ii]=true; + } + } + for(int ii=0;iiGetCellData()->AddArray(zeSelection)); + output->GetCellData()->SetActiveAttribute(idx,vtkDataSetAttributes::SCALARS); + output->GetCellData()->CopyScalarsOff(); + zeSelection->Delete(); + // + thres->SetInputArrayToProcess(idx,0,0,"vtkDataObject::FIELD_ASSOCIATION_CELLS",ZE_SELECTION_ARR_NAME); + thres->Update(); + vtkUnstructuredGrid *zeComputedOutput(thres->GetOutput()); + zeComputedOutput->GetCellData()->RemoveArray(idx); + output->Delete(); + zeComputedOutput->Register(0); + return zeComputedOutput; +} + +int vtkExtractCellType::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + try + { + //std::cerr << "########################################## vtkExtractCellType::RequestData ##########################################" << std::endl; + vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); + vtkDataSet *input(vtkDataSet::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); + vtkInformation *info(input->GetInformation()); + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkDataSet *output(vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()))); + std::vector idsToKeep(this->Internal->getIdsToKeep()); + vtkDataSet *tryOnCell(FilterFamilies(input,idsToKeep,this->InsideOut)); + // first shrink the input + output->ShallowCopy(tryOnCell); + tryOnCell->Delete(); + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkExtractCellType::RequestData : " << e.what() << std::endl; + return 0; + } + return 1; +} + +int vtkExtractCellType::GetSILUpdateStamp() +{ + return this->SILTime; +} + +void vtkExtractCellType::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); +} + +int vtkExtractCellType::GetNumberOfGeoTypesArrays() +{ + int ret(this->Internal->getNumberOfEntries()); + //std::cerr << "vtkExtractCellType::GetNumberOfGeoTypesArrays() -> " << ret << std::endl; + return ret; +} + +const char *vtkExtractCellType::GetGeoTypesArrayName(int index) +{ + const char *ret(this->Internal->getKeyOfEntry(index)); + //std::cerr << "vtkExtractCellType::GetGeoTypesArrayName(" << index << ") -> " << ret << std::endl; + return ret; +} + +int vtkExtractCellType::GetGeoTypesArrayStatus(const char *name) +{ + int ret((int)this->Internal->getStatusOfEntryStr(name)); + //std::cerr << "vtkExtractCellType::GetGeoTypesArrayStatus(" << name << ") -> " << ret << std::endl; + return ret; +} + +void vtkExtractCellType::SetGeoTypesStatus(const char *name, int status) +{ + //std::cerr << "vtkExtractCellType::SetGeoTypesStatus(" << name << "," << status << ")" << std::endl; + this->Internal->setStatusOfEntryStr(name,(bool)status); + if(std::string(name)==GetGeoTypesArrayName(GetNumberOfGeoTypesArrays()-1)) + { + this->Modified(); + //this->Internal->printMySelf(std::cerr); + } +} diff --git a/src/Plugins/MEDReader/IO/vtkExtractCellType.h b/src/Plugins/MEDReader/IO/vtkExtractCellType.h new file mode 100644 index 00000000..f4fb8a09 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkExtractCellType.h @@ -0,0 +1,71 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef vtkExtractCellType_h__ +#define vtkExtractCellType_h__ + +#include "vtkDataSetAlgorithm.h" + +class vtkMutableDirectedGraph; + +class VTK_EXPORT vtkExtractCellType : public vtkDataSetAlgorithm +{ +public: + static vtkExtractCellType* New(); + vtkTypeMacro(vtkExtractCellType, vtkDataSetAlgorithm) + void PrintSelf(ostream& os, vtkIndent indent); + virtual int GetNumberOfGeoTypesArrays(); + const char *GetGeoTypesArrayName(int index); + int GetGeoTypesArrayStatus(const char *name); + virtual void SetGeoTypesStatus(const char *name, int status); + void SetInsideOut(int val); + // Description: + // Every time the SIL is updated a this will return a different value. + virtual int GetSILUpdateStamp(); + +protected: + vtkExtractCellType(); + ~vtkExtractCellType(); + + int RequestInformation(vtkInformation *request, + vtkInformationVector **inputVector, vtkInformationVector *outputVector); + + int RequestData(vtkInformation *request, vtkInformationVector **inputVector, + vtkInformationVector *outputVector); + // Description: + // This SIL stores the structure of the mesh/groups/cell types + // that can be selected. + virtual void SetSIL(vtkMutableDirectedGraph*); + vtkGetObjectMacro(SIL, vtkMutableDirectedGraph); +protected: + vtkMutableDirectedGraph *SIL; + vtkTimeStamp SILTime; +private: + vtkExtractCellType(const vtkExtractCellType&); + void operator=(const vtkExtractCellType&); // Not implemented. + private: + //BTX + //ETX + class vtkExtractCellTypeInternal; + vtkExtractCellTypeInternal *Internal; + int InsideOut; +}; + +#endif diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx new file mode 100644 index 00000000..280e4d88 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx @@ -0,0 +1,651 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "vtkExtractGroup.h" +#include "MEDFileFieldRepresentationTree.hxx" + +#include "vtkAdjacentVertexIterator.h" +#include "vtkIntArray.h" +#include "vtkCellData.h" +#include "vtkPointData.h" + +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkUnstructuredGrid.h" +#include "vtkMultiBlockDataSet.h" + +#include "vtkInformationStringKey.h" +#include "vtkAlgorithmOutput.h" +#include "vtkObjectFactory.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkDataSet.h" +#include "vtkInformationVector.h" +#include "vtkInformation.h" +#include "vtkDataArraySelection.h" +#include "vtkTimeStamp.h" +#include "vtkInEdgeIterator.h" +#include "vtkInformationDataObjectKey.h" +#include "vtkExecutive.h" +#include "vtkVariantArray.h" +#include "vtkStringArray.h" +#include "vtkDoubleArray.h" +#include "vtkCharArray.h" +#include "vtkUnsignedCharArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkDemandDrivenPipeline.h" +#include "vtkDataObjectTreeIterator.h" +#include "vtkThreshold.h" + +#include +#include + +vtkStandardNewMacro(vtkExtractGroup); + +vtkCxxSetObjectMacro(vtkExtractGroup, SIL, vtkMutableDirectedGraph); + +/////////////////// + +class ExtractGroupStatus +{ +public: + ExtractGroupStatus():_status(false) { } + ExtractGroupStatus(const char *name); + bool getStatus() const { return _status; } + void setStatus(bool status) { _status=status; } + void cpyStatusFrom(const ExtractGroupStatus& other) { _status=other._status; } + std::string getName() const { return _name; } + const char *getKeyOfEntry() const { return _ze_key_name.c_str(); } + virtual void printMySelf(std::ostream& os) const; + virtual bool isSameAs(const ExtractGroupStatus& other) const; +protected: +bool _status; +std::string _name; +std::string _ze_key_name; +}; + +class ExtractGroupGrp : public ExtractGroupStatus +{ +public: + ExtractGroupGrp(const char *name):ExtractGroupStatus(name) { std::ostringstream oss; oss << START << name; _ze_key_name=oss.str(); } + void setFamilies(const std::vector& fams) { _fams=fams; } + const std::vector& getFamiliesLyingOn() const { return _fams; } + bool isSameAs(const ExtractGroupGrp& other) const; +public: + static const char START[]; + std::vector _fams; +}; + +class ExtractGroupFam : public ExtractGroupStatus +{ +public: + ExtractGroupFam(const char *name); + void printMySelf(std::ostream& os) const; + void fillIdsToKeep(std::set& s) const; + int getId() const { return _id; } + bool isSameAs(const ExtractGroupFam& other) const; +public: + static const char START[]; +private: + int _id; +}; + +class vtkExtractGroup::vtkExtractGroupInternal +{ +public: + void loadFrom(vtkMutableDirectedGraph *sil); + int getNumberOfEntries() const; + const char *getKeyOfEntry(int i) const; + bool getStatusOfEntryStr(const char *entry) const; + void setStatusOfEntryStr(const char *entry, bool status); + void printMySelf(std::ostream& os) const; + std::set getIdsToKeep() const; + int getIdOfFamily(const std::string& famName) const; +private: + std::map computeFamStrIdMap() const; + const ExtractGroupStatus& getEntry(const char *entry) const; + ExtractGroupStatus& getEntry(const char *entry); +private: + std::vector _groups; + std::vector _fams; +}; + +const char ExtractGroupGrp::START[]="GRP_"; + +const char ExtractGroupFam::START[]="FAM_"; + +ExtractGroupStatus::ExtractGroupStatus(const char *name):_status(false),_name(name) +{ +} + +void ExtractGroupStatus::printMySelf(std::ostream& os) const +{ + os << " -" << _ze_key_name << "("; + if(_status) + os << "X"; + else + os << " "; + os << ")" << std::endl; +} + +bool ExtractGroupStatus::isSameAs(const ExtractGroupStatus& other) const +{ + return _name==other._name && _ze_key_name==other._ze_key_name; +} + +bool ExtractGroupGrp::isSameAs(const ExtractGroupGrp& other) const +{ + bool ret(ExtractGroupStatus::isSameAs(other)); + if(ret) + return _fams==other._fams; + else + return false; +} + +void vtkExtractGroup::vtkExtractGroupInternal::loadFrom(vtkMutableDirectedGraph *sil) +{ + std::vector oldGrps(_groups); _groups.clear(); + std::vector oldFams(_fams); _fams.clear(); + int idNames(0); + vtkAbstractArray *verticesNames(sil->GetVertexData()->GetAbstractArray("Names",idNames)); + vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); + vtkIdType id0; + bool found(false); + for(int i=0;iGetNumberOfValues();i++) + { + vtkStdString &st(verticesNames2->GetValue(i)); + if(st=="MeshesFamsGrps") + { + id0=i; + found=true; + } + } + if(!found) + throw INTERP_KERNEL::Exception("There is an internal error ! The tree on server side has not the expected look !"); + vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); + sil->GetAdjacentVertices(id0,it0); + int kk(0),ll(0); + while(it0->HasNext()) + { + vtkIdType id1(it0->Next()); + std::string meshName((const char *)verticesNames2->GetValue(id1)); + vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); + sil->GetAdjacentVertices(id1,it1); + vtkIdType idZeGrps(it1->Next());//zeGroups + vtkAdjacentVertexIterator *itGrps(vtkAdjacentVertexIterator::New()); + sil->GetAdjacentVertices(idZeGrps,itGrps); + while(itGrps->HasNext()) + { + vtkIdType idg(itGrps->Next()); + ExtractGroupGrp grp((const char *)verticesNames2->GetValue(idg)); + vtkAdjacentVertexIterator *itGrps2(vtkAdjacentVertexIterator::New()); + sil->GetAdjacentVertices(idg,itGrps2); + std::vector famsOnGroup; + while(itGrps2->HasNext()) + { + vtkIdType idgf(itGrps2->Next()); + famsOnGroup.push_back(std::string((const char *)verticesNames2->GetValue(idgf))); + } + grp.setFamilies(famsOnGroup); + itGrps2->Delete(); + _groups.push_back(grp); + } + itGrps->Delete(); + vtkIdType idZeFams(it1->Next());//zeFams + it1->Delete(); + vtkAdjacentVertexIterator *itFams(vtkAdjacentVertexIterator::New()); + sil->GetAdjacentVertices(idZeFams,itFams); + while(itFams->HasNext()) + { + vtkIdType idf(itFams->Next()); + ExtractGroupFam fam((const char *)verticesNames2->GetValue(idf)); + _fams.push_back(fam); + } + itFams->Delete(); + } + it0->Delete(); + // + std::size_t szg(_groups.size()),szf(_fams.size()); + if(szg==oldGrps.size() && szf==oldFams.size()) + { + bool isSame(true); + for(std::size_t i=0;i=0 && i::const_iterator it0=_groups.begin();it0!=_groups.end();it0++) + if(entryCpp==(*it0).getKeyOfEntry()) + return *it0; + for(std::vector::const_iterator it0=_fams.begin();it0!=_fams.end();it0++) + if(entryCpp==(*it0).getKeyOfEntry()) + return *it0; + std::ostringstream oss; oss << "vtkExtractGroupInternal::getEntry : no such entry \"" << entry << "\"!"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +} + +ExtractGroupStatus& vtkExtractGroup::vtkExtractGroupInternal::getEntry(const char *entry) +{ + std::string entryCpp(entry); + for(std::vector::iterator it0=_groups.begin();it0!=_groups.end();it0++) + if(entryCpp==(*it0).getKeyOfEntry()) + return *it0; + for(std::vector::iterator it0=_fams.begin();it0!=_fams.end();it0++) + if(entryCpp==(*it0).getKeyOfEntry()) + return *it0; + std::ostringstream oss; oss << "vtkExtractGroupInternal::getEntry : no such entry \"" << entry << "\"!"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +} + +void vtkExtractGroup::vtkExtractGroupInternal::printMySelf(std::ostream& os) const +{ + os << "Groups :" << std::endl; + for(std::vector::const_iterator it0=_groups.begin();it0!=_groups.end();it0++) + (*it0).printMySelf(os); + os << "Families :" << std::endl; + for(std::vector::const_iterator it0=_fams.begin();it0!=_fams.end();it0++) + (*it0).printMySelf(os); +} + +int vtkExtractGroup::vtkExtractGroupInternal::getIdOfFamily(const std::string& famName) const +{ + for(std::vector::const_iterator it=_fams.begin();it!=_fams.end();it++) + { + if((*it).getName()==famName) + return (*it).getId(); + } +} + +ExtractGroupFam::ExtractGroupFam(const char *name):ExtractGroupStatus(name),_id(0) +{ + std::size_t pos(_name.find(MEDFileFieldRepresentationLeavesArrays::ZE_SEP)); + std::string name0(_name.substr(0,pos)),name1(_name.substr(pos+strlen(MEDFileFieldRepresentationLeavesArrays::ZE_SEP))); + std::istringstream iss(name1); + iss >> _id; + std::ostringstream oss; oss << START << name; _ze_key_name=oss.str(); _name=name0; +} + +bool ExtractGroupFam::isSameAs(const ExtractGroupFam& other) const +{ + bool ret(ExtractGroupStatus::isSameAs(other)); + if(ret) + return _id==other._id; + else + return false; +} + +void ExtractGroupFam::printMySelf(std::ostream& os) const +{ + os << " -" << _ze_key_name << " famName : \"" << _name << "\" id : " << _id << " ("; + if(_status) + os << "X"; + else + os << " "; + os << ")" << std::endl; +} + +void ExtractGroupFam::fillIdsToKeep(std::set& s) const +{ + s.insert(_id); +} + +std::set vtkExtractGroup::vtkExtractGroupInternal::getIdsToKeep() const +{ + std::map m(this->computeFamStrIdMap()); + std::set s; + for(std::vector::const_iterator it0=_groups.begin();it0!=_groups.end();it0++) + { + if((*it0).getStatus()) + { + const std::vector& fams((*it0).getFamiliesLyingOn()); + for(std::vector::const_iterator it1=fams.begin();it1!=fams.end();it1++) + { + std::map::iterator it2(m.find((*it1))); + if(it2!=m.end()) + s.insert((*it2).second); + } + } + } + for(std::vector::const_iterator it0=_fams.begin();it0!=_fams.end();it0++) + if((*it0).getStatus()) + (*it0).fillIdsToKeep(s); + return s; +} + +std::map vtkExtractGroup::vtkExtractGroupInternal::computeFamStrIdMap() const +{ + std::map ret; + for(std::vector::const_iterator it0=_fams.begin();it0!=_fams.end();it0++) + ret[(*it0).getName()]=(*it0).getId(); + return ret; +} + +//////////////////// + +vtkExtractGroup::vtkExtractGroup():SIL(NULL),Internal(new vtkExtractGroupInternal),InsideOut(0) +{ +} + +vtkExtractGroup::~vtkExtractGroup() +{ + delete this->Internal; +} + +void vtkExtractGroup::SetInsideOut(int val) +{ + if(this->InsideOut!=val) + { + this->InsideOut=val; + this->Modified(); + } +} + +int vtkExtractGroup::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + try + { + //std::cerr << "########################################## vtkExtractGroup::RequestInformation ##########################################" << std::endl; + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkInformation *inputInfo(inputVector[0]->GetInformationObject(0));//unfortunately inputInfo->Has(vtkDataObject::SIL) returns false... use executive to find it ! + // + vtkExecutive *exe(GetExecutive()); + vtkAlgorithm *alg(this); + vtkInformation *infoOnSIL(alg->GetOutputInformation(0)); + while(!infoOnSIL->Has(vtkDataObject::SIL()))// skipping vtkPVPostFilter + { + if(exe->GetNumberOfInputConnections(0)<1) + { + vtkErrorMacro("No SIL Data available ! The source of this filter must be MEDReader !"); + return 0; + } + vtkExecutive *exe2(exe->GetInputExecutive(0,0)); + // + alg=exe2->GetAlgorithm(); exe=exe2; infoOnSIL=alg->GetOutputInformation(0); + } + // + this->SetSIL(vtkMutableDirectedGraph::SafeDownCast(infoOnSIL->Get(vtkDataObject::SIL()))); + this->Internal->loadFrom(this->SIL); + //this->Internal->printMySelf(std::cerr); + outInfo->Set(vtkDataObject::SIL(),this->SIL); + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkExtractGroup::RequestInformation : " << e.what() << std::endl; + return 0; + } + return 1; +} + +template +vtkDataSet *FilterFamilies(vtkDataSet *input, const std::set& idsToKeep, bool insideOut, const char *arrNameOfFamilyField, + const char *associationForThreshold, bool& catchAll, bool& catchSmth) +{ + static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@"; + vtkDataSet *output(input->NewInstance()); + output->ShallowCopy(input); + vtkSmartPointer thres(vtkSmartPointer::New()); + thres->SetInputData(output); + vtkDataSetAttributes *dscIn(input->GetCellData()),*dscIn2(input->GetPointData()); + vtkDataSetAttributes *dscOut(output->GetCellData()),*dscOut2(output->GetPointData()); + // + double vMin(insideOut==0?1.:0.),vMax(insideOut==0?2.:1.); + thres->ThresholdBetween(vMin,vMax); + // OK for the output + // + CellPointExtractor cpe2(input); + vtkDataArray *da(cpe2.Get()->GetScalars(arrNameOfFamilyField)); + if(!da) + return 0; + std::string daName(da->GetName()); + vtkIntArray *dai(vtkIntArray::SafeDownCast(da)); + if(daName!=arrNameOfFamilyField || !dai) + return 0; + // + int nbOfTuples(dai->GetNumberOfTuples()); + vtkCharArray *zeSelection(vtkCharArray::New()); + zeSelection->SetName(ZE_SELECTION_ARR_NAME); + zeSelection->SetNumberOfComponents(1); + char *pt(new char[nbOfTuples]); + zeSelection->SetArray(pt,nbOfTuples,0,VTK_DATA_ARRAY_DELETE); + const int *inPtr(dai->GetPointer(0)); + std::fill(pt,pt+nbOfTuples,0); + catchAll=true; catchSmth=false; + std::vector pt2(nbOfTuples,false); + for(std::set::const_iterator it=idsToKeep.begin();it!=idsToKeep.end();it++) + { + bool catchFid(false); + for(int i=0;iAddArray(zeSelection)); + cpe3.Get()->SetActiveAttribute(idx,vtkDataSetAttributes::SCALARS); + cpe3.Get()->CopyScalarsOff(); + zeSelection->Delete(); + // + thres->SetInputArrayToProcess(idx,0,0,associationForThreshold,ZE_SELECTION_ARR_NAME); + thres->Update(); + vtkUnstructuredGrid *zeComputedOutput(thres->GetOutput()); + CellPointExtractor cpe(zeComputedOutput); + cpe.Get()->RemoveArray(idx); + output->Delete(); + zeComputedOutput->Register(0); + return zeComputedOutput; +} + +class CellExtractor +{ +public: + CellExtractor(vtkDataSet *ds):_ds(ds) { } + vtkDataSetAttributes *Get() { return _ds->GetCellData(); } +private: + vtkDataSet *_ds; +}; + +class PointExtractor +{ +public: + PointExtractor(vtkDataSet *ds):_ds(ds) { } + vtkDataSetAttributes *Get() { return _ds->GetPointData(); } +private: + vtkDataSet *_ds; +}; + +int vtkExtractGroup::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + try + { + //std::cerr << "########################################## vtkExtractGroup::RequestData ##########################################" << std::endl; + vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); + vtkDataSet *input(vtkDataSet::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); + vtkInformation *info(input->GetInformation()); + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkDataSet *output(vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()))); + std::set idsToKeep(this->Internal->getIdsToKeep()); + // first shrink the input + bool catchAll,catchSmth; + vtkDataSet *tryOnCell(FilterFamilies(input,idsToKeep,this->InsideOut, + MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME,"vtkDataObject::FIELD_ASSOCIATION_CELLS",catchAll,catchSmth)); + if(tryOnCell) + { + if(catchAll) + { + output->ShallowCopy(tryOnCell); + tryOnCell->Delete();// + return 1; + } + else + { + if(catchSmth) + { + vtkDataSet *tryOnNode(FilterFamilies(tryOnCell,idsToKeep,this->InsideOut, + MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME,"vtkDataObject::FIELD_ASSOCIATION_POINTS",catchAll,catchSmth)); + if(tryOnNode && catchSmth) + { + output->ShallowCopy(tryOnNode); + tryOnCell->Delete(); + tryOnNode->Delete();// + return 1; + } + else + { + if(tryOnNode) + tryOnNode->Delete(); + output->ShallowCopy(tryOnCell); + tryOnCell->Delete(); + return 1; + } + } + else + { + vtkDataSet *tryOnNode(FilterFamilies(input,idsToKeep,this->InsideOut, + MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME,"vtkDataObject::FIELD_ASSOCIATION_POINTS",catchAll,catchSmth)); + if(tryOnNode) + { + tryOnCell->Delete(); + output->ShallowCopy(tryOnNode); + tryOnNode->Delete(); + return 1; + } + else + { + output->ShallowCopy(tryOnCell); + tryOnCell->Delete(); + return 0; + } + } + } + } + else + { + vtkDataSet *tryOnNode(FilterFamilies(tryOnCell,idsToKeep,this->InsideOut, + MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME,"vtkDataObject::FIELD_ASSOCIATION_POINTS",catchAll,catchSmth)); + if(tryOnNode) + { + output->ShallowCopy(tryOnNode); + tryOnNode->Delete();// + return 1; + } + else + { + std::ostringstream oss; oss << "vtkExtractGroup::RequestData : The integer array with name \""<< MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME; + oss << "\" or \"" << MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME << "\" does not exist ! The extraction of group and/or family is not possible !"; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); + return 0; + } + } + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkExtractGroup::RequestData : " << e.what() << std::endl; + return 0; + } +} + +int vtkExtractGroup::GetSILUpdateStamp() +{ + return this->SILTime; +} + +void vtkExtractGroup::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); +} + +int vtkExtractGroup::GetNumberOfGroupsFlagsArrays() +{ + int ret(this->Internal->getNumberOfEntries()); + //std::cerr << "vtkExtractGroup::GetNumberOfFieldsTreeArrays() -> " << ret << std::endl; + return ret; +} + +const char *vtkExtractGroup::GetGroupsFlagsArrayName(int index) +{ + const char *ret(this->Internal->getKeyOfEntry(index)); + //std::cerr << "vtkExtractGroup::GetFieldsTreeArrayName(" << index << ") -> " << ret << std::endl; + return ret; +} + +int vtkExtractGroup::GetGroupsFlagsArrayStatus(const char *name) +{ + int ret((int)this->Internal->getStatusOfEntryStr(name)); + //std::cerr << "vtkExtractGroup::GetGroupsFlagsArrayStatus(" << name << ") -> " << ret << std::endl; + return ret; +} + +void vtkExtractGroup::SetGroupsFlagsStatus(const char *name, int status) +{ + //std::cerr << "vtkExtractGroup::SetFieldsStatus(" << name << "," << status << ")" << std::endl; + this->Internal->setStatusOfEntryStr(name,(bool)status); + if(std::string(name)==GetGroupsFlagsArrayName(GetNumberOfGroupsFlagsArrays()-1)) + this->Modified(); + //this->Internal->printMySelf(std::cerr); +} diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.h b/src/Plugins/MEDReader/IO/vtkExtractGroup.h new file mode 100644 index 00000000..778b1d98 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.h @@ -0,0 +1,71 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef vtkExtractGroup_h__ +#define vtkExtractGroup_h__ + +#include "vtkDataSetAlgorithm.h" + +class vtkMutableDirectedGraph; + +class VTK_EXPORT vtkExtractGroup: public vtkDataSetAlgorithm +{ +public: + static vtkExtractGroup* New(); + vtkTypeMacro(vtkExtractGroup, vtkDataSetAlgorithm) + void PrintSelf(ostream& os, vtkIndent indent); + virtual int GetNumberOfGroupsFlagsArrays(); + const char *GetGroupsFlagsArrayName(int index); + int GetGroupsFlagsArrayStatus(const char *name); + virtual void SetGroupsFlagsStatus(const char *name, int status); + void SetInsideOut(int val); + // Description: + // Every time the SIL is updated a this will return a different value. + virtual int GetSILUpdateStamp(); + +protected: + vtkExtractGroup(); + ~vtkExtractGroup(); + + int RequestInformation(vtkInformation *request, + vtkInformationVector **inputVector, vtkInformationVector *outputVector); + + int RequestData(vtkInformation *request, vtkInformationVector **inputVector, + vtkInformationVector *outputVector); + // Description: + // This SIL stores the structure of the mesh/groups/cell types + // that can be selected. + virtual void SetSIL(vtkMutableDirectedGraph*); + vtkGetObjectMacro(SIL, vtkMutableDirectedGraph); +protected: + vtkMutableDirectedGraph *SIL; + vtkTimeStamp SILTime; +private: + vtkExtractGroup(const vtkExtractGroup&); + void operator=(const vtkExtractGroup&); // Not implemented. + private: + //BTX + //ETX + class vtkExtractGroupInternal; + vtkExtractGroupInternal *Internal; + int InsideOut; +}; + +#endif diff --git a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx new file mode 100644 index 00000000..c8fa9ca1 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx @@ -0,0 +1,108 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "vtkGenerateVectors.h" +#include "vtkDoubleArray.h" +#include "vtkInformation.h" +#include "vtkQuadratureSchemeDefinition.h" +#include "MEDUtilities.hxx" +#define protected public +#include "vtkFieldData.h" + +void vtkGenerateVectors::Operate(vtkFieldData *fd) +{ + if(!fd) + return ; + const int nbOfArrs(fd->GetNumberOfArrays()); + for(int i=0;iGetArray(i)); + if(!arr) + continue; + vtkDoubleArray *arrc(vtkDoubleArray::SafeDownCast(arr)); + if(!arrc) + continue; + int nbOfCompo(arrc->GetNumberOfComponents()); + if(nbOfCompo<=1 || nbOfCompo==3) + continue; + if(nbOfCompo==2) + fd->SetArray(i,Operate2Compo(arrc)); + else + fd->SetArray(i,OperateMoreThan3Compo(arrc)); + } +} + +vtkDoubleArray *vtkGenerateVectors::Operate2Compo(vtkDoubleArray *oldArr) +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + vtkDoubleArray *ret(vtkDoubleArray::New()); + std::size_t nbOfTuples(oldArr->GetNumberOfTuples()); + const double *inPt(oldArr->GetPointer(0)); + double *pt((double *)malloc(nbOfTuples*3*sizeof(double))); + for(std::size_t i=0;iSetNumberOfComponents(3); + ret->SetName(oldArr->GetName()); + ret->SetComponentName(0,oldArr->GetComponentName(0)); + ret->SetComponentName(1,oldArr->GetComponentName(1)); + ret->SetArray(pt,3*nbOfTuples,0,VTK_DATA_ARRAY_FREE); + UpdateInformationOfArray(oldArr,ret); + return ret; +} + +vtkDoubleArray *vtkGenerateVectors::OperateMoreThan3Compo(vtkDoubleArray *oldArr) +{ + static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + vtkDoubleArray *ret(vtkDoubleArray::New()); + int nbOfCompo(oldArr->GetNumberOfComponents()); + std::size_t nbOfTuples(oldArr->GetNumberOfTuples()); + const double *inPt(oldArr->GetPointer(0)); + double *pt((double *)malloc(nbOfTuples*3*sizeof(double))); + for(std::size_t i=0;iSetNumberOfComponents(3); + ret->SetName(oldArr->GetName()); + ret->SetComponentName(0,oldArr->GetComponentName(0)); + ret->SetComponentName(1,oldArr->GetComponentName(1)); + ret->SetComponentName(2,oldArr->GetComponentName(2)); + ret->SetArray(pt,3*nbOfTuples,0,VTK_DATA_ARRAY_FREE); + UpdateInformationOfArray(oldArr,ret); + return ret; +} + +void vtkGenerateVectors::UpdateInformationOfArray(vtkDoubleArray *oldArr, vtkDoubleArray *arr) +{ + if(oldArr->GetInformation()->Has(vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME())) + { + arr->GetInformation()->Set(vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME(),oldArr->GetInformation()->Get((vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME()))); + } + if(oldArr->GetInformation()->Get(MEDUtilities::ELGA())) + arr->GetInformation()->Set(MEDUtilities::ELGA(),1); + if(oldArr->GetInformation()->Get(MEDUtilities::ELNO())) + arr->GetInformation()->Set(MEDUtilities::ELNO(),1); +} diff --git a/src/Plugins/MedReader/IO/vtkMedGroup.cxx b/src/Plugins/MEDReader/IO/vtkGenerateVectors.h similarity index 59% rename from src/Plugins/MedReader/IO/vtkMedGroup.cxx rename to src/Plugins/MEDReader/IO/vtkGenerateVectors.h index f6075f3c..c35dd0f1 100644 --- a/src/Plugins/MedReader/IO/vtkMedGroup.cxx +++ b/src/Plugins/MEDReader/IO/vtkGenerateVectors.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,28 +16,24 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay -#include "vtkMedGroup.h" +#ifndef vtkGenerateVectors_h__ +#define vtkGenerateVectors_h__ -#include "vtkObjectFactory.h" +#include "vtkDataSetAlgorithm.h" -#include "vtkMedUtilities.h" +class vtkFieldData; +class vtkDoubleArray; -// vtkCxxRevisionMacro(vtkMedGroup, "$Revision$") -vtkStandardNewMacro(vtkMedGroup) - -vtkMedGroup::vtkMedGroup() -{ - this->Name = NULL; - this->SetName(vtkMedUtilities::NoGroupName); -} - -vtkMedGroup::~vtkMedGroup() +class VTK_EXPORT vtkGenerateVectors { - this->SetName(NULL); -} +public: + static void Operate(vtkFieldData *fd); + static vtkDoubleArray *Operate2Compo(vtkDoubleArray *oldArr); + static vtkDoubleArray *OperateMoreThan3Compo(vtkDoubleArray *oldArr); +protected: + static void UpdateInformationOfArray(vtkDoubleArray *oldArr, vtkDoubleArray *arr); +}; -void vtkMedGroup::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} +#endif diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx new file mode 100644 index 00000000..6524e075 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -0,0 +1,368 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "vtkMEDReader.h" +#include "vtkGenerateVectors.h" + +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" +#include "vtkDataSetAttributes.h" +#include "vtkStringArray.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkInformationStringKey.h" +// +#include "vtkUnsignedCharArray.h" +#include "vtkInformationVector.h" +#include "vtkSmartPointer.h" +#include "vtkVariantArray.h" +#include "vtkExecutive.h" +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkMultiTimeStepAlgorithm.h" +#include "vtkUnstructuredGrid.h" +#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" +#include "vtkQuadratureSchemeDefinition.h" +#include "vtkPointData.h" +#include "vtkCellData.h" +#include "vtkCellType.h" +#include "vtkCellArray.h" +#include "vtkDoubleArray.h" +#include "vtkObjectFactory.h" + +#include "MEDFileFieldRepresentationTree.hxx" + +#include +#include +#include +#include + +class vtkMEDReader::vtkMEDReaderInternal +{ + +public: + vtkMEDReaderInternal():TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2) + { + } + + bool PluginStart0() + { + if(FirstCall0==0) + return false; + FirstCall0--; + return true; + } + + ~vtkMEDReaderInternal() + { + if(this->SIL) + this->SIL->Delete(); + } +public: + MEDFileFieldRepresentationTree Tree; + TimeKeeper TK; + std::string FileName; + //when true the file is MED file. when false it is a Sauv file + bool IsMEDOrSauv; + //when false -> std, true -> mode. By default std (false). + bool IsStdOrMode; + //when false -> do nothing. When true cut off or extend to nbOfCompo=3 vector arrays. + bool GenerateVect; + std::string DftMeshName; + // Store the vtkMutableDirectedGraph that represents links between family, groups and cell types + vtkMutableDirectedGraph* SIL; + // store the lev0 id in Tree corresponding to the TIME_STEPS in the pipeline. + int LastLev0; +private: + unsigned char FirstCall0; +}; + +vtkStandardNewMacro(vtkMEDReader); + +vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal) +{ + this->SetNumberOfInputPorts(0); + this->SetNumberOfOutputPorts(1); +} + +vtkMEDReader::~vtkMEDReader() +{ + delete this->Internal; +} + +void vtkMEDReader::Reload(int a) +{ + if(a==0) + return; + std::cerr << "vtkMEDReader::Reload" << a << std::endl; + std::string fName((const char *)this->GetFileName()); + delete this->Internal; + this->Internal=new vtkMEDReaderInternal; + this->SetFileName(fName.c_str()); +} + +void vtkMEDReader::GenerateVectors(int val) +{ + bool val2((bool)val); + if(val2!=this->Internal->GenerateVect) + { + this->Internal->GenerateVect=val2; + this->Modified(); + } +} + +void vtkMEDReader::ChangeMode(int newMode) +{ + this->Internal->IsStdOrMode=newMode!=0; + //std::cerr << "vtkMEDReader::ChangeMode : " << this->Internal->IsStdOrMode << std::endl; + this->Modified(); +} + +const char *vtkMEDReader::GetSeparator() +{ + return MEDFileFieldRepresentationLeavesArrays::ZE_SEP; +} + +void vtkMEDReader::SetFileName(const char *fname) +{ + this->Internal->FileName=fname; + std::size_t pos(this->Internal->FileName.find_last_of('.')); + if(pos!=std::string::npos) + { + std::string ext(this->Internal->FileName.substr(pos)); + if(ext.find("sauv")!=std::string::npos) + this->Internal->IsMEDOrSauv=false; + } + if(this->Internal->Tree.getNumberOfLeavesArrays()==0) + { + this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),this->Internal->IsMEDOrSauv); + this->Internal->Tree.activateTheFirst();//This line manually initialize the status of server (this) with the remote client. + this->Internal->TK.setMaxNumberOfTimeSteps(this->Internal->Tree.getMaxNumberOfTimeSteps()); + } + this->Modified(); +} + +char *vtkMEDReader::GetFileName() +{ + return const_cast(this->Internal->FileName.c_str()); +} + +int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + //std::cerr << "########################################## RequestInformation ##########################################" << std::endl; + try + { + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(),-1); + outInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkMultiBlockDataSet"); + this->UpdateSIL(outInfo); + // + bool dummy(false); + this->PublishTimeStepsIfNeeded(outInfo,dummy); + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + return 0; + } + return 1; +} + +int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + //std::cerr << "########################################## RequestData ##########################################"; + try + { + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkMultiBlockDataSet *output(vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()))); + bool isUpdated(false); + double reqTS(0.); + if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) + reqTS=outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); + //std::cerr << reqTS << std::endl; + this->FillMultiBlockDataSetInstance(output,reqTS); + output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS); + this->UpdateSIL(outInfo); + //this->UpdateProgress((float) progress/((float) maxprogress-1)); + } + catch(INTERP_KERNEL::Exception& e) + { + std::cerr << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + return 0; + } + return 1; +} + +void vtkMEDReader::SetFieldsStatus(const char* name, int status) +{ + //std::cerr << "vtkMEDReader::SetFieldsStatus(" << name << "," << status << ") called !" << std::endl; + this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(this->Internal->Tree.getIdHavingZeName(name),status); + if(std::string(name)==GetFieldsTreeArrayName(GetNumberOfFieldsTreeArrays()-1)) + if(!this->Internal->PluginStart0()) + this->Modified(); +} + +int vtkMEDReader::GetNumberOfFieldsTreeArrays() +{ + int ret(this->Internal->Tree.getNumberOfLeavesArrays()); + //std::cerr << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << ret << std::endl; + return ret; +} + +const char *vtkMEDReader::GetFieldsTreeArrayName(int index) +{ + std::string ret(this->Internal->Tree.getNameOf(index)); + //std::cerr << "vtkMEDReader::GetFieldsTreeArrayName(" << index << ") called ! " << ret << std::endl; + return ret.c_str(); +} + +int vtkMEDReader::GetFieldsTreeArrayStatus(const char *name) +{ + int zeId(this->Internal->Tree.getIdHavingZeName(name)); + int ret(this->Internal->Tree.getStatusOf(zeId)); + return ret; +} + +void vtkMEDReader::SetTimesFlagsStatus(const char *name, int status) +{ + int pos(0); + std::istringstream iss(name); iss >> pos; + this->Internal->TK.getTimesFlagArray()[pos].first=(bool)status; + if(pos==this->Internal->TK.getTimesFlagArray().size()-1) + if(!this->Internal->PluginStart0()) + { + this->Modified(); + //this->Internal->TK.printSelf(std::cerr); + } +} + +int vtkMEDReader::GetNumberOfTimesFlagsArrays() +{ + return (int)this->Internal->TK.getTimesFlagArray().size(); +} + +const char *vtkMEDReader::GetTimesFlagsArrayName(int index) +{ + return this->Internal->TK.getTimesFlagArray()[index].second.c_str(); +} + +int vtkMEDReader::GetTimesFlagsArrayStatus(const char *name) +{ + int pos(0); + std::istringstream iss(name); iss >> pos; + return (int)this->Internal->TK.getTimesFlagArray()[pos].first; +} + +void vtkMEDReader::UpdateSIL(vtkInformation *info) +{ + vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New()); + std::string meshName(this->BuildSIL(sil)); + if(meshName!=this->Internal->DftMeshName) + { + if(this->Internal->SIL) + this->Internal->SIL->Delete(); + this->Internal->SIL=sil; + this->Internal->DftMeshName=meshName; + info->Set(vtkDataObject::SIL(),this->Internal->SIL); + //request->AppendUnique(vtkExecutive::KEYS_TO_COPY(),vtkDataObject::SIL()); + } + else + { + sil->Delete(); + } +} + +/*! + * The returned string is the name of the mesh activated which groups and families are in \a sil. + */ +std::string vtkMEDReader::BuildSIL(vtkMutableDirectedGraph* sil) +{ + sil->Initialize(); + vtkSmartPointer childEdge(vtkSmartPointer::New()); + childEdge->InsertNextValue(0); + vtkSmartPointer crossEdge(vtkSmartPointer::New()); + crossEdge->InsertNextValue(1); + // CrossEdge is an edge linking hierarchies. + vtkUnsignedCharArray* crossEdgesArray=vtkUnsignedCharArray::New(); + crossEdgesArray->SetName("CrossEdges"); + sil->GetEdgeData()->AddArray(crossEdgesArray); + crossEdgesArray->Delete(); + std::vector names; + // Now build the hierarchy. + vtkIdType rootId=sil->AddVertex(); + names.push_back("SIL"); + // Add global fields root + vtkIdType fieldsRoot(sil->AddChild(rootId,childEdge)); + names.push_back("FieldsStatusTree"); + this->Internal->Tree.feedSIL(sil,fieldsRoot,childEdge,names); + vtkIdType meshesFamsGrpsRoot(sil->AddChild(rootId,childEdge)); + names.push_back("MeshesFamsGrps"); + std::string dftMeshName(this->Internal->Tree.feedSILForFamsAndGrps(sil,meshesFamsGrpsRoot,childEdge,names)); + // This array is used to assign names to nodes. + vtkStringArray *namesArray(vtkStringArray::New()); + namesArray->SetName("Names"); + namesArray->SetNumberOfTuples(sil->GetNumberOfVertices()); + sil->GetVertexData()->AddArray(namesArray); + namesArray->Delete(); + std::vector::const_iterator iter; + vtkIdType cc; + for(cc=0, iter=names.begin(); iter!=names.end(); ++iter, ++cc) + namesArray->SetValue(cc,(*iter).c_str()); + return dftMeshName; +} + +double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isUpdated) +{ + int lev0(-1); + std::vector tsteps; + if(!this->Internal->IsStdOrMode) + tsteps=this->Internal->Tree.getTimeSteps(lev0,this->Internal->TK); + else + { tsteps.resize(1); tsteps[0]=0.; } + isUpdated=false; + if(lev0!=this->Internal->LastLev0) + { + isUpdated=true; + double timeRange[2]; + timeRange[0]=tsteps.front(); + timeRange[1]=tsteps.back(); + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],tsteps.size()); + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2); + this->Internal->LastLev0=lev0; + } + return tsteps.front(); +} + +void vtkMEDReader::FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS) +{ + std::string meshName; + vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->Internal->IsStdOrMode,reqTS,meshName,this->Internal->TK)); + if(this->Internal->GenerateVect) + { + vtkGenerateVectors::Operate(ret->GetPointData()); + vtkGenerateVectors::Operate(ret->GetCellData()); + vtkGenerateVectors::Operate(ret->GetFieldData()); + } + output->SetBlock(0,ret); + ret->Delete(); +} + +void vtkMEDReader::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); +} diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.h b/src/Plugins/MEDReader/IO/vtkMEDReader.h new file mode 100644 index 00000000..a87c6bd6 --- /dev/null +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.h @@ -0,0 +1,73 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __vtkMEDReader_h_ +#define __vtkMEDReader_h_ + +#include "vtkMultiBlockDataSetAlgorithm.h" + +class vtkMutableDirectedGraph; + +class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm +{ + private: + vtkMEDReader(const vtkMEDReader&); // Not implemented. + void operator=(const vtkMEDReader&); // Not implemented. + public: + static vtkMEDReader *New(); + vtkTypeMacro(vtkMEDReader, vtkMultiBlockDataSetAlgorithm); + void PrintSelf(ostream& os, vtkIndent indent); + virtual void SetFileName(const char*); + virtual char *GetFileName(); + virtual const char *GetFileExtensions() { return ".med .rmed .sauv .sauve"; } + virtual const char *GetDescriptiveName() { return "MED file (Data Exchange Model)"; } + // + virtual void SetFieldsStatus(const char *name, int status); + virtual int GetNumberOfFieldsTreeArrays(); + virtual const char *GetFieldsTreeArrayName(int index); + virtual int GetFieldsTreeArrayStatus(const char *name); + // + virtual int GetTimesFlagsArrayStatus(const char *name); + virtual void SetTimesFlagsStatus(const char *name, int status); + virtual int GetNumberOfTimesFlagsArrays(); + virtual const char *GetTimesFlagsArrayName(int index); + //! Build the graph used to pass information to the client on the supports + virtual std::string BuildSIL(vtkMutableDirectedGraph*); + virtual void Reload(int); + virtual void GenerateVectors(int); + virtual void ChangeMode(int); + virtual const char *GetSeparator(); + protected: + vtkMEDReader(); + virtual ~vtkMEDReader(); + virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*); + virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*); + private: + void UpdateSIL(vtkInformation *info); + virtual double PublishTimeStepsIfNeeded(vtkInformation*, bool& isUpdated); + virtual void FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS); + private: + //BTX + //ETX + class vtkMEDReaderInternal; + vtkMEDReaderInternal* Internal; +}; + +#endif //__vtkMEDReader_h_ diff --git a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt new file mode 100644 index 00000000..e7fef095 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt @@ -0,0 +1,91 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE_DIRECTORIES( + ${MEDReader_SOURCE_DIR}/IO + ${MEDReader_BINARY_DIR}/IO ) + +IF(PARAVIEW_BUILD_QT_GUI) + + QT4_WRAP_UI(CLIENT_UI_SRCS Resources/UI/MEDReaderPanel.ui Resources/UI/ExtractGroupPanel.ui Resources/UI/ExtractCellTypePanel.ui) + + # create a plugin that implements an object panel for the reader + SET(CLIENT_SRCS pqMEDReaderPanel.cxx pqExtractGroupPanel.cxx pqExtractCellTypePanel.cxx VectBoolSpreadSheet.cxx VectBoolWidget.cxx) + + QT4_WRAP_CPP(MOC_SRCS pqMEDReaderPanel.h pqExtractGroupPanel.h pqExtractCellTypePanel.h VectBoolSpreadSheet.h VectBoolWidget.h) + + ADD_PARAVIEW_OBJECT_PANEL(MEDREADER_IFACES MEDREADER_IFACE_SRCS + CLASS_NAME pqMEDReaderPanel + XML_NAME MEDReader + XML_GROUP sources + ) + + ADD_PARAVIEW_OBJECT_PANEL(EXTRACTGROUP_IFACES EXTRACTGROUP_IFACE_SRCS + CLASS_NAME pqExtractGroupPanel + XML_NAME ExtractGroup + XML_GROUP filters + ) + + ADD_PARAVIEW_OBJECT_PANEL(EXTRACTCELLTYPE_IFACES EXTRACTCELLTYPE_IFACE_SRCS + CLASS_NAME pqExtractCellTypePanel + XML_NAME ExtractCellType + XML_GROUP filters + ) + + # create the med reader plugin itself + ADD_PARAVIEW_PLUGIN(MEDReaderPlugin "4.0" + SERVER_MANAGER_XML Resources/MEDReaderServer.xml + GUI_INTERFACES ${MEDREADER_IFACES} ${EXTRACTGROUP_IFACES} ${EXTRACTCELLTYPE_IFACES} + GUI_RESOURCES Resources/pqMEDReader.qrc + GUI_SOURCES ${CLIENT_SRCS} + ${CLIENT_UI_SRCS} + ${MOC_SRCS} + ${MEDREADER_IFACE_SRCS} ${EXTRACTGROUP_IFACE_SRCS} ${EXTRACTCELLTYPE_IFACE_SRCS} + CS_KITS + # this is the same name as the name in module.cmake file IO + # directory. + vtkMEDReader + ) + +ELSE(PARAVIEW_BUILD_QT_GUI) + + # create the med reader plugin itself + ADD_PARAVIEW_PLUGIN(MEDReaderPlugin "4.0" + SERVER_MANAGER_SOURCES ${SM_SRCS} + SERVER_MANAGER_XML Resources/MEDReaderServer.xml + CS_KITS + # this is the same name as the name in module.cmake file IO + # directory. + vtkMEDReader + ) + +ENDIF(PARAVIEW_BUILD_QT_GUI) + +TARGET_LINK_LIBRARIES(MEDReaderPlugin vtkMEDReader vtkMEDReaderCS) +# Install +INSTALL( + TARGETS MEDReaderPlugin + RUNTIME DESTINATION lib/paraview + LIBRARY DESTINATION lib/paraview + ARCHIVE DESTINATION lib/paraview + ) + + + + diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqCellData16.png b/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqCellData16.png old mode 100755 new mode 100644 similarity index 100% rename from src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqCellData16.png rename to src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqCellData16.png diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqCellDataForWholeMesh16.png b/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqCellDataForWholeMesh16.png new file mode 100644 index 0000000000000000000000000000000000000000..93401f4ce47fd0994050a8a097647260d0948cbd GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85pG3gD_*9)I=GeAbW|YuPgg)b}=3k^U6=Q%|M}iPZ!4!i_>o> z9^`6J5OA4)@%c`Ldw&k)3I1rjz0%0I;O(tBWvvg-uJH@~xu~;$)@ydbmt9ke%lcWA z7AdMZ`7rD`yYx_K^T3G-9 literal 0 HcmV?d00001 diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqElnoData16.png b/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqElnoData16.png similarity index 100% rename from src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqElnoData16.png rename to src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqElnoData16.png diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqPointData16.png b/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqPointData16.png old mode 100755 new mode 100644 similarity index 100% rename from src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqPointData16.png rename to src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqPointData16.png diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqQuadratureData16.png b/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqQuadratureData16.png old mode 100755 new mode 100644 similarity index 100% rename from src/Plugins/MedReader/ParaViewPlugin/Resources/Icons/pqQuadratureData16.png rename to src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqQuadratureData16.png diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqReloadFile16.png b/src/Plugins/MEDReader/ParaViewPlugin/Resources/Icons/pqReloadFile16.png new file mode 100644 index 0000000000000000000000000000000000000000..cc13970bda074a6f92d5a4c19d2fcf30fe056657 GIT binary patch literal 851 zcmV-Z1FZasP)?FaXFdr)~fM03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00Os3L_t(I%Z-z}Z<}Ql z#((eoe*SLu=P!0l;n>yRwNe0#?}!KQkf%_ z1r? z;*Uq8gzv81p+6k*;gu!QG-rQ*OqL0*Yp7Hllu`hQ2mnectRvE`+kdffZ^Y=wHrn4| z<93f>**D?Y76~-*m_+;1y>u#%3>uFRndi zx4q40pS+0gTPG}V&`-FzlQCJZX^gSRMbjH8v=N>=JI zE^}3%M%AMhIMm86)1RuHx(R!ogh!84{%l1wcZE?~$PYc1ryMpDD28QF3PBTPIl7YlbAuqT z2?Cq>xnpl4LKF#iTV1wV2jpo91hi716r>qTlh*Mc0Cf5h>o*_pe4|9U?D4~|UB2Dw z(kui_R&10Ah>+$vQ#xV!8TTY$qGYqN`GAkUx<`0smXYmInW`~S^g)Cy%Q2!DMlr9~ zgnG$B|2LNR-aN#fk zP#qjX?~pKwd23p;I-4_o_>hK*xOmDx*@dHq0W7~T&4sg5?Dt|)5!`|yeDeRBI~~HJ dL# + + + diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml new file mode 100644 index 00000000..ba96aa7d --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderClient2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml new file mode 100644 index 00000000..a69e01c2 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -0,0 +1,423 @@ + + + + + + + + This property specifies the file name for the MED reader. + + + + + + + + + + + + + + + + + + + + + + + + + + + + This property lists all the fields sorted by time steps then by mesh then by common support. + + + + + + + + + + + + + + + This property lists all groups and families to select. + + + + + + + This property specifies the file name for the MED reader. + + + + + + + Available timestep values. + + + + + + + + + + + + + + + + + + This property specifies the input to the Level Scalars filter. + + + + + + + Information property indicating the update stamp of the SIL. Every + time the SIL is rebuild, this + time stamp is changed. + + + + + + + + + + + + + + + This property lists all groups and families to select. + + + + + + Choose which part of the dataset to keep regarding the selected Groups/Families. When 0 (default) the direct selection + is kept. When 1 the complementary part is selected. + + + + + + + + + + + + + + + + + This property specifies the input to the Level Scalars filter. + + + + + + + Information property indicating the update stamp of the SIL. Every + time the SIL is rebuild, this + time stamp is changed. + + + + + + + + + + + + + + + This property lists all the geometric types to select. + + + + + Choose which part of the dataset to keep regarding the selected geometric types. When 0 (default) the direct selection + is kept. When 1 the complementary part is selected. + + + + + + + "Create a Mesh with ELNO values mapped at each vertex." + + + + + + + + + + + + + + + + "Extract the surface of a dataset with ELNO values." + + + + + + + + + + + + + + + + + Specifies the offset array from which we generate ELNO points. + + + + + + + + + + + + + + + + "Create a point set with data at quadrature points." + + + + + + + + + + + + + + + + + + + Specifies the offset array from which we generate Gauss points. + + + + + + + + + + + + + + + + + + "Create a point set with data at quadrature points." + + + + + + + + + + + + + + + + + + + Specifies the offset array from which we generate ELNO points. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This property specifies the input to the Generate Structural Element filter. + + + + + + diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractCellTypePanel.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractCellTypePanel.ui new file mode 100644 index 00000000..85ed1776 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractCellTypePanel.ui @@ -0,0 +1,101 @@ + + + ExtractCellTypePanel + + + + 0 + 0 + 649 + 839 + + + + + 0 + 0 + + + + Form + + + + 9 + + + + + + 0 + 1 + + + + Geometric types available + + + + 6 + + + 9 + + + + + + + + 0 + 200 + + + + + 1 + + + + + + + + + + Extract the complementary + + + + + + + + + + + pqTreeWidget + QTreeWidget +
pqTreeWidget.h
+
+
+ + + + + 10 + + + 10 + + + false + + + false + + + true + + +
diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui new file mode 100644 index 00000000..b328a632 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui @@ -0,0 +1,101 @@ + + + ExtractGroupPanel + + + + 0 + 0 + 649 + 839 + + + + + 0 + 0 + + + + Form + + + + 9 + + + + + + 0 + 1 + + + + Groups And Families + + + + 6 + + + 9 + + + + + + + + 0 + 200 + + + + + 1 + + + + + + + + + + Extract the complementary + + + + + + + + + + + pqTreeWidget + QTreeWidget +
pqTreeWidget.h
+
+
+ + + + + 10 + + + 10 + + + false + + + false + + + true + + +
diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui new file mode 100644 index 00000000..23361f95 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/UI/MEDReaderPanel.ui @@ -0,0 +1,227 @@ + + + MEDReaderPanel + + + + 0 + 0 + 649 + 839 + + + + + 0 + 0 + + + + Form + + + + 9 + + + + + + 0 + 1 + + + + Representation + + + + 6 + + + 9 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + Reload current file + + + true + + + + + + + :/ParaViewResources/Icons/pqReloadFile16.png:/ParaViewResources/Icons/pqReloadFile16.png + + + false + + + + + + + + + + 0 + 200 + + + + + 1 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 25 + + + + GenerateVectors + + + + + + + + + + true + + + + + + + + + Time + + + + + + + Mode + + + + + + + + + + + 0 + 0 + + + + + 250 + 400 + + + + + + + + + + + + + + + + + pqTreeWidget + QTreeWidget +
pqTreeWidget.h
+
+
+ + + + + + + 10 + + + 10 + + + false + + + false + + + true + + +
diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/pqMedReader.qrc b/src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc similarity index 59% rename from src/Plugins/MedReader/ParaViewPlugin/Resources/pqMedReader.qrc rename to src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc index bb1f914a..a2696de1 100644 --- a/src/Plugins/MedReader/ParaViewPlugin/Resources/pqMedReader.qrc +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/pqMEDReader.qrc @@ -3,7 +3,10 @@ Icons/pqCellData16.png Icons/pqPointData16.png Icons/pqQuadratureData16.png - MedReaderClient.xml + MEDReaderClient.xml + MEDReaderClient2.xml Icons/pqElnoData16.png + Icons/pqReloadFile16.png + Icons/pqCellDataForWholeMesh16.png diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx new file mode 100644 index 00000000..27b61cac --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx @@ -0,0 +1,298 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "VectBoolSpreadSheet.h" +#include +#include +#include +#include +#include + +VectBoolModel::VectBoolModel(int maxSize, int nbRows):_activated(maxSize,false),_nb_rows(nbRows) +{ + setCurSize(maxSize); +} + +int VectBoolModel::rowCount(const QModelIndex &) const +{ + return _nb_rows; +} + +int VectBoolModel::columnCount (const QModelIndex &) const +{ + int sz(curSize()); + if(sz%_nb_rows==0) + return sz/_nb_rows; + else + return sz/_nb_rows+1; +} + +QVariant VectBoolModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(role==Qt::FontRole) + { + QFont serifFont("Arial",6, QFont::Bold); + return QVariant(serifFont); + } + else if(role==Qt::DisplayRole) + { + return QVariant(section); + } + else + return QAbstractTableModel::headerData(section,orientation,role); +} + +bool VectBoolModel::setData(const QModelIndex& index, const QVariant& value, int role) +{ + if(role==Qt::UserRole) + { + int pos(index.column()*_nb_rows+index.row()); + bool v(_activated[pos]); + _activated[pos]=!v; + emit nbOfTimeStepsOnChanged((int)getNbOfActivatedTimeSteps(),_dts.size()); + return true; + } + else + return QAbstractTableModel::setData(index,value,role); +} + +QVariant VectBoolModel::data(const QModelIndex &index, int role) const +{ + if(role==Qt::FontRole) + { + QFont serifFont("Arial",8);//, QFont::Bold); + return QVariant(serifFont); + } + else if(role==Qt::UserRole) + { + int pos(index.column()*_nb_rows+index.row()); + return QVariant(_activated[pos]); + } + else if(role==Qt::DisplayRole) + { + int pos(index.column()*_nb_rows+index.row()); + if(pos=curSize()) + return QVariant(); + if(_activated[pos]) + { + QBrush b(QColor(0,255,0)); + return QVariant(b); + } + else + { + QBrush b(QColor(255,0,0)); + return QVariant(b); + } + } + else + return QVariant(); +} + +bool VectBoolModel::setCurrentItems(const QStringList& dts, const QStringList& its, const QStringList& tts) +{ + int oldSize(curSize()); + if(oldSize!=dts.size()) + { + emit layoutAboutToBeChanged(); + _dts=dts; _its=its; _tts=tts; + emit layoutChanged(); + return true; + } + else + { + _dts=dts; _its=its; _tts=tts; + return false; + } + +} + +void VectBoolModel::setNumberOfRows(int newNbOfRows) +{ + if(newNbOfRows!=_nb_rows) + { + emit beginResetModel(); + _nb_rows=newNbOfRows; + emit endResetModel(); + } +} + +void VectBoolModel::selectUnselectAll() +{ + int nbOn(getNbOfActivatedTimeSteps()),sz(curSize()),signalVal(0); + emit layoutAboutToBeChanged(); + if(nbOn>sz/2) + { + for(std::size_t ii=0;iihorizontalHeader()->setMinimumSectionSize(2); + this->horizontalHeader()->setDefaultSectionSize(2); + this->verticalHeader()->setMinimumSectionSize(2); + this->verticalHeader()->setDefaultSectionSize(2); + this->setItemDelegate(_delegate); + this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); + this->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + this->resizeColumnsToContents(); + this->resizeRowsToContents(); + //this->verticalHeader()->hide(); + //this->horizontalHeader()->hide(); +} + +void VectBoolSpreadSheet::selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) +{ + QAbstractItemModel * m(model()); + foreach(const QModelIndex& ind,selected.indexes()) + { + m->setData(ind,QVariant(true),Qt::UserRole); + } + QTableView::selectionChanged(selected,deselected); +} + +void VectBoolSpreadSheet::nbOfRowsHasChanged(int newNbOfRows) +{ + VectBoolModel *zeModel(qobject_cast(model())); + if(!zeModel) + return ; + zeModel->setNumberOfRows(newNbOfRows); + this->verticalHeader()->setUpdatesEnabled(true);//please let this line. If not a refresh problem appear at EDF configuration. +} + +void VectBoolSpreadSheet::selectUnselectAllFired() +{ + VectBoolModel *zeModel(qobject_cast(model())); + if(!zeModel) + return ; + zeModel->selectUnselectAll(); +} + +/////////////// + +OnOffDelegate::OnOffDelegate(QObject *parent):QStyledItemDelegate(parent) +{ +} + +void OnOffDelegate::paint(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex& index) const +{ + painter->save(); + const QAbstractItemModel *zeModel(index.model()); + QString cont(zeModel->data(index,Qt::DisplayRole).toString()); + bool checked(zeModel->data(index,Qt::UserRole).toBool()); + QFont font; + if(checked) + { + QFont zeFont(zeModel->data(index,Qt::FontRole).value()); + zeFont.setBold(true); + font=zeFont; + } + else + { + font=QFont("Arial",7); + font.setItalic(true); + } + painter->setFont(font); + Qt::Alignment al((Qt::Alignment)zeModel->data(index,Qt::TextAlignmentRole).toInt()); + if(checked) + {//sizeHint + //painter->drawEllipse(option.rect); + //painter->setBrush(QBrush(Qt::lightGray,Qt::Dense6Pattern)); + painter->setBrush(QBrush(QColor(230,230,255))); + painter->drawRect(option.rect); + //painter->drawLine(option.rect.topLeft(),option.rect.bottomRight()); + //painter->drawLine(option.rect.topRight(),option.rect.bottomLeft()); + } + else + { + painter->setBrush(QBrush(QColor(255,255,255))); + painter->drawRect(option.rect); + painter->setPen(Qt::lightGray); + } + painter->drawText(option.rect,cont,QTextOption(al)); + painter->restore(); +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.h b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.h new file mode 100644 index 00000000..57b7d779 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.h @@ -0,0 +1,80 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include +#include +#include +#include +#include +#include + +class OnOffDelegate : public QStyledItemDelegate//QItemDelegate +{ + Q_OBJECT + public: + OnOffDelegate(QObject *parent=0); + void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; +}; + +class VectBoolSpreadSheet : public QTableView +{ + Q_OBJECT +public: + VectBoolSpreadSheet(QWidget *parent); + ~VectBoolSpreadSheet(); + void init(); + void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected); +public slots: + void nbOfRowsHasChanged(int newNbOfRows); + void selectUnselectAllFired(); +private: + OnOffDelegate *_delegate; +}; + +class VectBoolModel : public QAbstractTableModel +{ + Q_OBJECT +public: + VectBoolModel(int maxSize, int nbRows); + std::size_t getSize() const { return _activated.size(); } + bool getStatusAt(int pos) const { return _activated[pos]; } + void setStatusAt(int pos, bool val) { _activated[pos]=val; } + int rowCount( const QModelIndex & parent = QModelIndex() ) const; + int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; + // non const methods. + bool setCurrentItems(const QStringList& dts, const QStringList& its, const QStringList& tts); + int getNbOfActivatedTimeSteps() const; +public: + void setNumberOfRows(int newNbOfRows); + void selectUnselectAll(); +signals: + void nbOfTimeStepsOnChanged(int newNbOfTimeStepsOn, int totalNbOfTS); +private: + void setCurSize(int sz); + int curSize() const; +private: + std::vector _activated; + QStringList _dts,_its,_tts; + int _cur_size; + int _nb_rows; +}; diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx new file mode 100644 index 00000000..c9e976c5 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.cxx @@ -0,0 +1,195 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "VectBoolWidget.h" +#include "VectBoolSpreadSheet.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +NbOfActiveTSDisplay::NbOfActiveTSDisplay(QWidget *parent):QLabel(parent),_nb_of_items_on(0),_total_nb_of_items(0) +{ + setFont(QFont("Arial",8,QFont::Bold)); + setTextFormat(Qt::AutoText); +} + + void NbOfActiveTSDisplay::display(int nbOfItemsOn, int totalNbOfItems) +{ + _nb_of_items_on=nbOfItemsOn; + _total_nb_of_items=totalNbOfItems; + setText(QString("%1/%2").arg(_nb_of_items_on).arg(_total_nb_of_items)); +} + +void NbOfActiveTSDisplay::totalNbOfItemsChanged(int totalNbOfItems) +{ + _total_nb_of_items=totalNbOfItems; + setText(QString("%1/%2").arg(_nb_of_items_on).arg(_total_nb_of_items)); +} + +VectBoolItem::VectBoolItem(QObject *parent, int pos, VectBoolModel *model):QObject(parent),_pos(pos),_old_status(true),_model(model) +{ +} + +bool VectBoolItem::isActivated() const +{ + return _model->getStatusAt(_pos); +} + +void VectBoolItem::activated(bool val) +{ + //_model->setStatusAt(_pos,val); +} + +void VectBoolItem::theModelHasChanged() +{ + bool val(isActivated()); + if(val!=_old_status) + { + _old_status=val; + emit changed(); + } +} + +VectBoolWidget::VectBoolWidget(QWidget *parent, int nbOfItems):QFrame(parent) +{ + QSizePolicy sizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); + this->setSizePolicy(sizePolicy); + this->setFrameShape(QFrame::StyledPanel); + this->setFrameShadow(QFrame::Raised); + _horizontal_layout=new QHBoxLayout(this); + _horizontal_layout->setSpacing(6); + _horizontal_layout->setContentsMargins(11,11,11,11); + _spreadsheet_container=new QFrame(this); + QSizePolicy sizePolicy1(QSizePolicy::Expanding,QSizePolicy::Expanding); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(_spreadsheet_container->sizePolicy().hasHeightForWidth()); + _spreadsheet_container->setSizePolicy(sizePolicy1); + _grid_layout=new QGridLayout(_spreadsheet_container); + _grid_layout->setSpacing(6); + _grid_layout->setContentsMargins(11,11,11,11); + _horizontal_layout->addWidget(_spreadsheet_container); + _group_box=new QGroupBox(this); + QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Expanding); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(_group_box->sizePolicy().hasHeightForWidth()); + _group_box->setSizePolicy(sizePolicy2); + // + _vertical_layout=new QVBoxLayout(_group_box); + _vertical_layout->setSpacing(6); + _vertical_layout->setContentsMargins(11,11,11,11); + _nb_of_time_steps_on=new NbOfActiveTSDisplay(_group_box); + _nb_of_time_steps_on->setMaximumSize(QSize(40,16777215)); + _vertical_layout->addWidget(_nb_of_time_steps_on); + _nb_of_rows_selecter=new QSlider(_group_box); + QSizePolicy sizePolicy3(QSizePolicy::Expanding,QSizePolicy::Expanding); + sizePolicy3.setHorizontalStretch(0); + sizePolicy3.setVerticalStretch(0); + sizePolicy3.setHeightForWidth(_nb_of_rows_selecter->sizePolicy().hasHeightForWidth()); + _nb_of_rows_selecter->setSizePolicy(sizePolicy3); + _nb_of_rows_selecter->setOrientation(Qt::Vertical); + _vertical_layout->addWidget(_nb_of_rows_selecter); + _sel_unsel_all=new QPushButton(_group_box); + _sel_unsel_all->setMaximumSize(QSize(40,16777215)); + _sel_unsel_all->setText(QString("Sel All")); + QFont font("Andale Mono"); + font.setPointSize(5); + _sel_unsel_all->setFont(font); + _vertical_layout->addWidget(_sel_unsel_all); + // + _horizontal_layout->addWidget(_group_box); + // + _vbw=new VectBoolSpreadSheet(_spreadsheet_container); + QSizePolicy sizePolicy4(QSizePolicy::Expanding,QSizePolicy::Expanding); + sizePolicy4.setHorizontalStretch(0); + sizePolicy4.setVerticalStretch(0); + sizePolicy4.setHeightForWidth(_vbw->sizePolicy().hasHeightForWidth()); + _vbw->setSizePolicy(sizePolicy4); + _nb_of_rows_selecter->setSizePolicy(sizePolicy3); + _nb_of_rows_selecter->setMinimum(1); + _nb_of_rows_selecter->setMaximum(GetMaxTickValueOfSlider(nbOfItems)); + _nb_of_rows_selecter->setTickInterval(1); + _nb_of_rows_selecter->setTickPosition(QSlider::TicksRight); + connect(_nb_of_rows_selecter,SIGNAL(valueChanged(int)),_vbw,SLOT(nbOfRowsHasChanged(int))); + connect(_sel_unsel_all,SIGNAL(clicked()),_vbw,SLOT(selectUnselectAllFired())); + _grid_layout->addWidget(_vbw); + _vbw->init(); + _vbm=new VectBoolModel(nbOfItems,1); + _vbw->setModel(_vbm); + connect(this->_vbm,SIGNAL(nbOfTimeStepsOnChanged(int,int)),_nb_of_time_steps_on,SLOT(display(int,int))); + _vbm->selectUnselectAll(); + _nb_of_rows_selecter->setValue(_nb_of_rows_selecter->maximum()); + // + _items.resize(nbOfItems); + for(int i=0;igetNumberOfBoolItems()) + { + std::cerr << "ERROR ! Internal Error in VectBoolWidget::setItems ! Current number of items is bigger than the current one !" << std::endl; + return ; + } + if(_vbm->setCurrentItems(dts,its,tts)) + { + _nb_of_rows_selecter->setMaximum(GetMaxTickValueOfSlider(curNbOfItems)); + _nb_of_rows_selecter->setValue(_nb_of_rows_selecter->maximum()); + _nb_of_time_steps_on->display(_vbm->getNbOfActivatedTimeSteps(),dts.size()); + } +} + +int VectBoolWidget::getNumberOfBoolItems() const +{ + return (int)_vbm->getSize(); +} + +int VectBoolWidget::GetMaxTickValueOfSlider(int val) +{ + double valf((double)val); + double ret(sqrt(valf)); + int reti((int)ret); + if(reti*reti==val) + return reti; + else + return reti+1; +} + +VectBoolWidget::~VectBoolWidget() +{ + delete _vbm; +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h new file mode 100644 index 00000000..74b8a47c --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolWidget.h @@ -0,0 +1,91 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef __VECTBOOLWIDGET_H__ +#define __VECTBOOLWIDGET_H__ + +#include +#include + +class QSlider; +class QGroupBox; +class QHBoxLayout; +class QVBoxLayout; +class QGridLayout; +class QPushButton; +class VectBoolModel; +class VectBoolSpreadSheet; + +class NbOfActiveTSDisplay : public QLabel +{ +Q_OBJECT +public: + NbOfActiveTSDisplay(QWidget *parent=0); +public slots: + void display(int nbOfItemsOn, int totalNbOfItems); + void totalNbOfItemsChanged(int totalNbOfItems); +private: + int _nb_of_items_on; + int _total_nb_of_items; +}; + +class VectBoolItem : public QObject +{ +Q_OBJECT +Q_PROPERTY(bool activated READ isActivated WRITE activated) +public: + VectBoolItem(QObject *parent, int pos, VectBoolModel *model); + bool isActivated() const; + void activated(bool val); +public slots: + void theModelHasChanged(); +signals: + void changed(); +private: + int _pos; + mutable bool _old_status; + VectBoolModel *_model; +}; + +class VectBoolWidget : public QFrame +{ +public: + VectBoolWidget(QWidget *parent, int nbOfItems); + ~VectBoolWidget(); + int getNumberOfBoolItems() const; + void setItems(const QStringList& dts, const QStringList& its, const QStringList& tts); + const QVector& getItems() const { return _items; } +private: + static int GetMaxTickValueOfSlider(int val); +private: + QVector _items; + QHBoxLayout *_horizontal_layout; + QFrame *_spreadsheet_container; + QGridLayout *_grid_layout; + QGroupBox *_group_box; + QVBoxLayout *_vertical_layout; + NbOfActiveTSDisplay *_nb_of_time_steps_on; + QSlider *_nb_of_rows_selecter; + QPushButton *_sel_unsel_all; + VectBoolSpreadSheet *_vbw; + VectBoolModel *_vbm; +}; + +#endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx new file mode 100644 index 00000000..07fe5fb1 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.cxx @@ -0,0 +1,162 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqExtractCellTypePanel.h" +#include "ui_ExtractCellTypePanel.h" + +#include "vtkProcessModule.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" +#include "vtkIntArray.h" +#include "vtkSMDoubleVectorProperty.h" +#include "vtkSMIntVectorProperty.h" +#include "vtkSMStringVectorProperty.h" +#include "vtkSMProxy.h" +#include "vtkEventQtSlotConnect.h" +#include "vtkPVSILInformation.h" +#include "vtkGraph.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkAdjacentVertexIterator.h" +#include "vtkSMPropertyHelper.h" +#include "vtkStringArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkExtractCellType.h" + +#include "pqTreeWidgetItemObject.h" +#include "pqSMAdaptor.h" +#include "pqProxy.h" +#include "pqPropertyManager.h" +#include "pqSILModel.h" +#include "pqProxySILModel.h" +#include "pqTreeViewSelectionHelper.h" +#include "pqTreeWidgetSelectionHelper.h" +#include "pqPropertyLinks.h" + +#include + +static const char ZE_SEP[]="@@][@@"; + +class pqExtractCellTypePanel::pqUI: public QObject, public Ui::ExtractCellTypePanel +{ +public: + pqUI(pqExtractCellTypePanel* p):QObject(p) + { + this->VTKConnect = vtkSmartPointer::New(); + this->SILUpdateStamp = -1; + } + + ~pqUI() { } + + pqSILModel SILModel; + vtkSmartPointer VTKConnect; + pqPropertyLinks Links; + QMap TreeItemToPropMap; + int SILUpdateStamp; +}; + +pqExtractCellTypePanel::pqExtractCellTypePanel(pqProxy* object_proxy, QWidget* p):Superclass(object_proxy, p) +{ + this->UI=new pqUI(this); + this->UI->setupUi(this); + pqProxySILModel*proxyModel2 = new pqProxySILModel("GeoTypesStatusTree", &this->UI->SILModel); + proxyModel2->setSourceModel(&this->UI->SILModel); + this->UI->Fields->setHeaderHidden(true); + this->updateSIL(); + this->linkServerManagerProperties(); + //////////////////// + vtkSMProperty *SMProperty(this->proxy()->GetProperty("GeoTypesStatus")); + //////////////////// + vtkSMProxy* reader = this->referenceProxy()->getProxy(); + vtkPVSILInformation* info=vtkPVSILInformation::New(); + reader->GatherInformation(info); + vtkGraph *g(info->GetSIL()); + vtkMutableDirectedGraph *g2(vtkMutableDirectedGraph::SafeDownCast(g)); + int idNames(0); + vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames)); + vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); + vtkIdType id0; + bool found(false); + for(int i=0;iGetNumberOfValues();i++) + { + vtkStdString &st(verticesNames2->GetValue(i)); + if(st=="CellTypesTree") + { + id0=i; + found=true; + } + } + if(!found) + std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; + vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(id0,it0); + int kk(0),ll(0); + while(it0->HasNext()) + { + vtkIdType id1(it0->Next()); + QString geoTypeName(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); + vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(id1,it1); + QList strs0; strs0.append(QString("%1").arg(geoTypeName)); + pqTreeWidgetItemObject *item0(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); + vtkAdjacentVertexIterator *itGrps(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(id1,itGrps); + vtkIdType idg(itGrps->Next()); + QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(idg))); + QString toolTipName0(QString("%1 (vtkId=%2)").arg(geoTypeName).arg(name0)); + item0->setData(0,Qt::UserRole,geoTypeName); + item0->setData(0,Qt::ToolTipRole,toolTipName0); + item0->setData(0,Qt::CheckStateRole,0); + this->propertyManager()->registerLink(item0,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,ll++); + } + it0->Delete(); + this->UI->Fields->header()->setStretchLastSection(true); + this->UI->Fields->expandAll(); + info->Delete(); + //////////////////// + vtkSMProperty *SMPropertyExtractComp(this->proxy()->GetProperty("InsideOut")); + this->propertyManager()->registerLink(this->UI->ExtractComplementary,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMPropertyExtractComp); + //////////////////// + this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent,this,SLOT(updateSIL())); +} + +pqExtractCellTypePanel::~pqExtractCellTypePanel() +{ +} + +void pqExtractCellTypePanel::linkServerManagerProperties() +{ + this->Superclass::linkServerManagerProperties(); +} + +void pqExtractCellTypePanel::updateSIL() +{ + vtkSMProxy* reader = this->referenceProxy()->getProxy(); + reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp")); + int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt(); + if (stamp != this->UI->SILUpdateStamp) + { + this->UI->SILUpdateStamp = stamp; + vtkPVSILInformation* info = vtkPVSILInformation::New(); + reader->GatherInformation(info); + this->UI->SILModel.update(info->GetSIL()); + this->UI->Fields->expandAll(); + info->Delete(); + } +} diff --git a/src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.h b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h similarity index 58% rename from src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.h rename to src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h index 22e38cda..568ca8fc 100644 --- a/src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.h +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractCellTypePanel.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,59 +16,35 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay -#ifndef _pqMedReaderPanel_h -#define _pqMedReaderPanel_h +#ifndef _pqExtractCellTypePanel_h +#define _pqExtractCellTypePanel_h #include "pqNamedObjectPanel.h" -#include +#include + class pqTreeWidgetItemObject; class vtkSMProperty; +class vtkMutableDirectedGraph; -class pqMedReaderPanel: public pqNamedObjectPanel +class pqExtractCellTypePanel : public pqNamedObjectPanel { Q_OBJECT typedef pqNamedObjectPanel Superclass; public: - /// constructor - pqMedReaderPanel(pqProxy* proxy, QWidget* p = NULL); - /// destructor - ~pqMedReaderPanel(); - + pqExtractCellTypePanel(pqProxy* proxy, QWidget* p = NULL); + ~pqExtractCellTypePanel(); protected slots: - void animationModeChanged(int mode); - - // void timeComboChanged(int timeStep); - void updateSIL(); - protected: /// populate widgets with properties from the server manager virtual void linkServerManagerProperties(); - - enum PixmapType - { - PM_NONE = -1, - PM_POINT, - PM_CELL, - PM_QUADRATURE, - PM_ELNO - }; - - void addSelectionsToTreeWidget(const QString& prop, - QTreeWidget* tree, PixmapType pix); - - void addSelectionToTreeWidget(const QString& name, - const QString& realName, QTreeWidget* tree, PixmapType pix, - const QString& prop, int propIdx); - - void setupAnimationModeWidget(); - void updateAvailableTimes(); - class pqUI; pqUI* UI; + std::vector _all_lev4; }; #endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx new file mode 100644 index 00000000..db1c26e0 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.cxx @@ -0,0 +1,365 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqExtractGroupPanel.h" +#include "ui_ExtractGroupPanel.h" + +#include "vtkProcessModule.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" +#include "vtkIntArray.h" +#include "vtkSMDoubleVectorProperty.h" +#include "vtkSMIntVectorProperty.h" +#include "vtkSMStringVectorProperty.h" +#include "vtkSMProxy.h" +#include "vtkEventQtSlotConnect.h" +#include "vtkPVSILInformation.h" +#include "vtkGraph.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkAdjacentVertexIterator.h" +#include "vtkSMPropertyHelper.h" +#include "vtkStringArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkExtractGroup.h" + +#include "pqTreeWidgetItemObject.h" +#include "pqSMAdaptor.h" +#include "pqProxy.h" +#include "pqPropertyManager.h" +#include "pqSILModel.h" +#include "pqProxySILModel.h" +#include "pqTreeViewSelectionHelper.h" +#include "pqTreeWidgetSelectionHelper.h" +#include "pqPropertyLinks.h" + +#include + +static const char ZE_SEP[]="@@][@@"; + +class PixSingleExtractPanel +{ +public: + static const PixSingleExtractPanel &GetInstance(); + QPixmap getPixFromStr(int pos) const; + PixSingleExtractPanel(); +private: + static const int NB_OF_DISCR=4; + static PixSingleExtractPanel *UNIQUE_INSTANCE; + QPixmap _pixmaps[NB_OF_DISCR]; +}; + +PixSingleExtractPanel *PixSingleExtractPanel::UNIQUE_INSTANCE=0; + +const PixSingleExtractPanel &PixSingleExtractPanel::GetInstance() +{ + if(!UNIQUE_INSTANCE) + UNIQUE_INSTANCE=new PixSingleExtractPanel; + return *UNIQUE_INSTANCE; +} + +PixSingleExtractPanel::PixSingleExtractPanel() +{ + _pixmaps[0]=QPixmap(":/ParaViewResources/Icons/pqCellData16.png"); + _pixmaps[1]=QPixmap(":/ParaViewResources/Icons/pqPointData16.png"); +} + +QPixmap PixSingleExtractPanel::getPixFromStr(int pos) const +{ + if(pos>=0 && pos<=1) + return _pixmaps[pos]; + else + return QPixmap(); +} + +class pqExtractGroupPanel::pqUI: public QObject, public Ui::ExtractGroupPanel +{ +public: + pqUI(pqExtractGroupPanel* p):QObject(p) + { + this->VTKConnect = vtkSmartPointer::New(); + this->SILUpdateStamp = -1; + } + + ~pqUI() { } + + pqSILModel SILModel; + vtkSmartPointer VTKConnect; + pqPropertyLinks Links; + QMap TreeItemToPropMap; + int SILUpdateStamp; +}; + +pqExtractGroupPanel::pqExtractGroupPanel(pqProxy* object_proxy, QWidget* p):Superclass(object_proxy, p) +{ + this->UI=new pqUI(this); + this->UI->setupUi(this); + pqProxySILModel*proxyModel2 = new pqProxySILModel("GroupsFlagsStatusTree", &this->UI->SILModel); + proxyModel2->setSourceModel(&this->UI->SILModel); + this->UI->Fields->setHeaderHidden(true); + this->updateSIL(); + this->linkServerManagerProperties(); + //////////////////// + vtkSMProperty *SMProperty(this->proxy()->GetProperty("GroupsFlagsStatus")); + //////////////////// + vtkSMProxy* reader = this->referenceProxy()->getProxy(); + vtkPVSILInformation* info=vtkPVSILInformation::New(); + reader->GatherInformation(info); + vtkGraph *g(info->GetSIL()); + vtkMutableDirectedGraph *g2(vtkMutableDirectedGraph::SafeDownCast(g)); + int idNames(0); + vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames)); + vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); + vtkIdType id0; + bool found(false); + for(int i=0;iGetNumberOfValues();i++) + { + vtkStdString &st(verticesNames2->GetValue(i)); + if(st=="MeshesFamsGrps") + { + id0=i; + found=true; + } + } + if(!found) + std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; + vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(id0,it0); + int kk(0),ll(0); + while(it0->HasNext()) + { + vtkIdType id1(it0->Next()); + QString meshName(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); + vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(id1,it1); + vtkIdType idZeGrps(it1->Next());//zeGroups + QList strs0; strs0.append(QString("Groups of \"%1\"").arg(meshName)); + pqTreeWidgetItemObject *item0(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); + std::map famIds(DeduceMapOfFamilyFromSIL(g2)); + //item0->setData(0,Qt::CheckStateRole,0); + vtkAdjacentVertexIterator *itGrps(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(idZeGrps,itGrps); + while(itGrps->HasNext()) + { + vtkIdType idg(itGrps->Next()); + QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(idg))); QList strs0; strs0.append(name0); + QString toolTipName0(name0); + pqTreeWidgetItemObject *item1(new pqTreeWidgetItemObject(item0,strs0)); + // + vtkAdjacentVertexIterator *itFamsOnGrp(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(idg,itFamsOnGrp); + bool isOnCell(true),isOnPoint(true); + while(itFamsOnGrp->HasNext()) + { + vtkIdType idfg(itFamsOnGrp->Next()); + std::string namefg((const char *)verticesNames2->GetValue(idfg)); + std::map::const_iterator ittt(famIds.find(namefg)); + if(ittt==famIds.end()) + { isOnCell=false; isOnPoint=false; break; } + int zeId((*ittt).second); + if(zeId<0) + { + if(!isOnCell) + { isOnCell=false; isOnPoint=false; break; } + else + isOnPoint=false; + } + if(zeId>0) + { + if(!isOnPoint) + { isOnCell=false; isOnPoint=false; break; } + else + isOnCell=false; + } + } + itFamsOnGrp->Delete(); + item1->setData(0,Qt::UserRole,name0); + item1->setData(0,Qt::ToolTipRole,toolTipName0); + item1->setData(0,Qt::CheckStateRole,0); + if(isOnCell && !isOnPoint) + item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(0)); + if(!isOnCell && isOnPoint) + item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(1)); + this->propertyManager()->registerLink(item1,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,ll++); + } + itGrps->Delete(); + // families + vtkIdType idZeFams(it1->Next());//zeFams + strs0.clear(); strs0.append(QString("Families of \"%1\"").arg(meshName)); + pqTreeWidgetItemObject *item00(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); + //item00->setData(0,Qt::CheckStateRole,0); + vtkAdjacentVertexIterator *itFams(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(idZeFams,itFams); + while(itFams->HasNext()) + { + vtkIdType idf(itFams->Next()); + std::string crudeFamName((const char *)verticesNames2->GetValue(idf)); + std::size_t pos(crudeFamName.find_first_of(ZE_SEP)); + std::string famName(crudeFamName.substr(0,pos)); std::string idStr(crudeFamName.substr(pos+strlen(ZE_SEP))); + int idInt(QString(idStr.c_str()).toInt()); + famIds[famName]=idInt; + QString name0(famName.c_str()); QList strs0; strs0.append(name0); + QString toolTipName0(QString("%1 (%2)").arg(QString(famName.c_str())).arg(QString(idStr.c_str()))); + pqTreeWidgetItemObject *item1(new pqTreeWidgetItemObject(item00,strs0)); + item1->setData(0,Qt::UserRole,name0); + item1->setData(0,Qt::ToolTipRole,toolTipName0); + item1->setData(0,Qt::CheckStateRole,0); + if(idInt<0) + item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(0)); + if(idInt>0) + item1->setData(0,Qt::DecorationRole,PixSingleExtractPanel::GetInstance().getPixFromStr(1)); + this->propertyManager()->registerLink(item1,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,ll++); + } + itFams->Delete(); + } + it0->Delete(); + this->UI->Fields->header()->setStretchLastSection(true); + this->UI->Fields->expandAll(); + info->Delete(); + //////////////////// + vtkSMProperty *SMPropertyExtractComp(this->proxy()->GetProperty("InsideOut")); + this->propertyManager()->registerLink(this->UI->ExtractComplementary,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMPropertyExtractComp); + //////////////////// + this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL())); +} + +pqExtractGroupPanel::~pqExtractGroupPanel() +{ +} + +void pqExtractGroupPanel::linkServerManagerProperties() +{ + this->Superclass::linkServerManagerProperties(); +} + +void pqExtractGroupPanel::updateSIL() +{ + vtkSMProxy* reader = this->referenceProxy()->getProxy(); + reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp")); + int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt(); + if (stamp != this->UI->SILUpdateStamp) + { + this->UI->SILUpdateStamp = stamp; + vtkPVSILInformation* info = vtkPVSILInformation::New(); + reader->GatherInformation(info); + this->UI->SILModel.update(info->GetSIL()); + this->UI->Fields->expandAll(); + info->Delete(); + } +} + +void pqExtractGroupPanel::aLev4HasBeenFired() +{ + pqTreeWidgetItemObject *zeItem(qobject_cast(sender())); + if(!zeItem) + return; + pqTreeWidgetItemObject *father(dynamic_cast(zeItem->QTreeWidgetItem::parent())); + if(!father) + return ; + if(zeItem->isChecked()) + { + // This part garantees that all leaves having not the same father than zeItem are desactivated + foreach(pqTreeWidgetItemObject* elt,this->_all_lev4) + { + QTreeWidgetItem *testFath(elt->QTreeWidgetItem::parent()); + if(testFath!=father) + if(elt->isChecked()) + elt->setChecked(false); + } + //If all leaves are checked the father is check too + bool allItemsAreChked(true); + for(int i=0;ichildCount() && allItemsAreChked;i++) + { + pqTreeWidgetItemObject *elt(dynamic_cast(father->child(i))); + if(elt && !elt->isChecked()) + allItemsAreChked=false; + } + if(allItemsAreChked && !father->isChecked()) + father->setChecked(true); + } + else + { + // if all are unchecked - check it again + bool allItemsAreUnChked(true); + foreach(pqTreeWidgetItemObject* elt,this->_all_lev4) + { + if(elt && elt->isChecked()) + allItemsAreUnChked=false; + } + if(allItemsAreUnChked) + zeItem->setChecked(true);// OK zeItem was required to be unchecked but as it is the last one. Recheck it ! + else + {// if all items are uncheked inside a same parent - uncheck the parent + allItemsAreUnChked=true; + for(int i=0;ichildCount() && allItemsAreUnChked;i++) + { + pqTreeWidgetItemObject *elt(dynamic_cast(father->child(i))); + if(elt && elt->isChecked()) + allItemsAreUnChked=false; + } + if(allItemsAreUnChked && father->isChecked()) + father->setChecked(false); + } + } +} + +std::map pqExtractGroupPanel::DeduceMapOfFamilyFromSIL(vtkMutableDirectedGraph *graph) +{ + std::map ret; + int idNames(0); + vtkAbstractArray *verticesNames(graph->GetVertexData()->GetAbstractArray("Names",idNames)); + vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); + vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); + vtkIdType id0; + bool found(false); + for(int i=0;iGetNumberOfValues();i++) + { + vtkStdString &st(verticesNames2->GetValue(i)); + if(st=="MeshesFamsGrps") + { + id0=i; + found=true; + } + } + if(!found) + std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; + graph->GetAdjacentVertices(id0,it0); + while(it0->HasNext()) + { + vtkIdType id1(it0->Next());//meshName + vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New()); + graph->GetAdjacentVertices(id1,it1); + it1->Next();//zeGroups + vtkIdType idZeFams(it1->Next());//zeFams + vtkAdjacentVertexIterator *itFams(vtkAdjacentVertexIterator::New()); + graph->GetAdjacentVertices(idZeFams,itFams); + while(itFams->HasNext()) + { + vtkIdType idf(itFams->Next()); + std::string crudeFamName((const char *)verticesNames2->GetValue(idf)); + std::size_t pos(crudeFamName.find_first_of(ZE_SEP)); + std::string famName(crudeFamName.substr(0,pos)); std::string idStr(crudeFamName.substr(pos+strlen(ZE_SEP))); + int idInt(QString(idStr.c_str()).toInt()); + ret[famName]=idInt; + } + it1->Delete(); + } + it0->Delete(); + return ret; +} diff --git a/src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.h b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.h similarity index 81% rename from src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.h rename to src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.h index 537bbcd3..699bd07f 100644 --- a/src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.h +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqExtractGroupPanel.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,44 +16,38 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay #ifndef _pqExtractGroupPanel_h #define _pqExtractGroupPanel_h #include "pqNamedObjectPanel.h" -#include +#include + class pqTreeWidgetItemObject; class vtkSMProperty; +class vtkMutableDirectedGraph; class pqExtractGroupPanel: public pqNamedObjectPanel { Q_OBJECT typedef pqNamedObjectPanel Superclass; public: - /// constructor pqExtractGroupPanel(pqProxy* proxy, QWidget* p = NULL); - /// destructor ~pqExtractGroupPanel(); - -public slots: - // accept changes made by this panel - //virtual void accept(); - // reset changes made by this panel - //virtual void reset(); - protected slots: - + void aLev4HasBeenFired(); void updateSIL(); - +private: + static std::map DeduceMapOfFamilyFromSIL(vtkMutableDirectedGraph *graph); protected: /// populate widgets with properties from the server manager virtual void linkServerManagerProperties(); - class pqUI; pqUI* UI; + std::vector _all_lev4; }; #endif - diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx new file mode 100644 index 00000000..2053a5ad --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.cxx @@ -0,0 +1,459 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "pqMEDReaderPanel.h" +#include "ui_MEDReaderPanel.h" +#include "VectBoolWidget.h" + +#include "vtkProcessModule.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" +#include "vtkIntArray.h" +#include "vtkSMDoubleVectorProperty.h" +#include "vtkSMIntVectorProperty.h" +#include "vtkSMStringVectorProperty.h" +#include "vtkSMProxy.h" +#include "vtkEventQtSlotConnect.h" +#include "vtkPVSILInformation.h" +#include "vtkGraph.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkAdjacentVertexIterator.h" +#include "vtkSMPropertyHelper.h" +#include "vtkStringArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkMEDReader.h" + +#include "pqTreeWidgetItemObject.h" +#include "pqSMAdaptor.h" +#include "pqProxy.h" +#include "pqPropertyManager.h" +#include "pqSILModel.h" +#include "pqProxySILModel.h" +#include "pqTreeViewSelectionHelper.h" +#include "pqTreeWidgetSelectionHelper.h" + +#include + +static const char ZE_SEP[]="@@][@@"; + +class PixSingle +{ +public: + static const PixSingle &GetInstance(); + QPixmap getPixFromStr(const std::string& st) const; + QPixmap getWholeMeshPix() const; + PixSingle(); +private: + static const int NB_OF_DISCR=4; + static PixSingle *UNIQUE_PIX_SINGLE; + QPixmap _pixmaps[NB_OF_DISCR]; + std::map _ze_map; + QPixmap _whole_mesh; +}; + +PixSingle *PixSingle::UNIQUE_PIX_SINGLE=0; + +const PixSingle &PixSingle::GetInstance() +{ + if(!UNIQUE_PIX_SINGLE) + UNIQUE_PIX_SINGLE=new PixSingle; + return *UNIQUE_PIX_SINGLE; +} + +PixSingle::PixSingle() +{ + _pixmaps[0]=QPixmap(":/ParaViewResources/Icons/pqCellData16.png"); + _pixmaps[1]=QPixmap(":/ParaViewResources/Icons/pqPointData16.png"); + _pixmaps[2]=QPixmap(":/ParaViewResources/Icons/pqQuadratureData16.png"); + _pixmaps[3]=QPixmap(":/ParaViewResources/Icons/pqElnoData16.png"); + _ze_map[std::string("P0")]=0; + _ze_map[std::string("P1")]=1; + _ze_map[std::string("GAUSS")]=2; + _ze_map[std::string("GSSNE")]=3; + _whole_mesh=QPixmap(":/ParaViewResources/Icons/pqCellDataForWholeMesh16.png"); +} + +QPixmap PixSingle::getPixFromStr(const std::string& st) const +{ + std::map::const_iterator it(_ze_map.find(st)); + if(it!=_ze_map.end()) + return _pixmaps[(*it).second]; + else + return QPixmap(); +} + +QPixmap PixSingle::getWholeMeshPix() const +{ + return _whole_mesh; +} + +class pqMEDReaderPanel::pqUI: public QObject, public Ui::MEDReaderPanel +{ +public: + pqUI(pqMEDReaderPanel *p):QObject(p) + { + this->VTKConnect = vtkSmartPointer::New(); + } + + ~pqUI() { } + + vtkSmartPointer VTKConnect; + QMap TreeItemToPropMap; +}; + +pqMEDReaderPanel::pqMEDReaderPanel(pqProxy *object_proxy, QWidget *p):Superclass(object_proxy,p),_reload_req(false),_optional_widget(0) +{ + initAll(); +} + +void pqMEDReaderPanel::initAll() +{ + _all_lev4.clear(); + this->UI=new pqUI(this); + this->UI->setupUi(this); + this->UI->Fields->setHeaderHidden(true); + this->updateSIL(); + //////////////////// + vtkSMProxy *reader(this->referenceProxy()->getProxy()); + vtkPVSILInformation *info(vtkPVSILInformation::New()); + reader->GatherInformation(info); + vtkGraph *g(info->GetSIL()); + vtkMutableDirectedGraph *g2(vtkMutableDirectedGraph::SafeDownCast(g)); + int idNames(0); + vtkAbstractArray *verticesNames(g2->GetVertexData()->GetAbstractArray("Names",idNames)); + vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames)); + vtkIdType id0; + bool found(false); + for(int i=0;iGetNumberOfValues();i++) + { + vtkStdString &st(verticesNames2->GetValue(i)); + if(st=="FieldsStatusTree") + { + id0=i; + found=true; + } + } + if(!found) + std::cerr << "There is an internal error ! The tree on server side has not the expected look !" << std::endl; + vtkAdjacentVertexIterator *it0(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(id0,it0); + int kk(0),ll(0); + while(it0->HasNext()) + { + vtkIdType idToolTipForTS(it0->Next()); + QString toolTipName0(QString::fromStdString((const char *)verticesNames2->GetValue(idToolTipForTS))); + QString nbTS; + QList dts,its,tts; + { + vtkAdjacentVertexIterator *itForTS(vtkAdjacentVertexIterator::New()); + g2->GetAdjacentVertices(idToolTipForTS,itForTS); + vtkIdType idForNbTS(itForTS->Next()); + nbTS=QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS)); + itForTS->Delete(); + int nbTSInt(nbTS.toInt()); + for(int ii=0;iiGetValue(idForNbTS+3*ii+1))); + its.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+2))); + tts.push_back(QString::fromStdString((const char *)verticesNames2->GetValue(idForNbTS+3*ii+3))); + } + } + vtkIdType id1(it0->Next()); + // + vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus")); + SMProperty->ResetToDefault();//this line is very important ! + // + QString name0(QString::fromStdString((const char *)verticesNames2->GetValue(id1))); QList strs0; strs0.append(name0); + pqTreeWidgetItemObject *item0(new pqTreeWidgetItemObject(this->UI->Fields,strs0)); + item0->setData(0,Qt::UserRole,name0); + item0->setData(0,Qt::ToolTipRole,toolTipName0); + // + QList modulesAct; + for(int i=0;isetProperty("NbOfTS",nbTS); + item0->setProperty("DTS",QVariant(dts)); + item0->setProperty("ITS",QVariant(its)); + item0->setProperty("TTS",QVariant(tts)); + item0->setProperty("ChosenTS",QVariant(modulesAct)); + // + vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New());//mesh + g2->GetAdjacentVertices(id1,it1); + while(it1->HasNext()) + { + vtkIdType id2(it1->Next()); + QString name1(QString::fromStdString((const char *)verticesNames2->GetValue(id2))); QList strs1; strs1.append(name1); + QString toolTipName1(name1); + pqTreeWidgetItemObject *item1(new pqTreeWidgetItemObject(item0,strs1)); + item1->setData(0,Qt::UserRole,name1); + item1->setData(0,Qt::ToolTipRole,toolTipName1); + vtkAdjacentVertexIterator *it2(vtkAdjacentVertexIterator::New());//common support + g2->GetAdjacentVertices(id2,it2); + while(it2->HasNext()) + { + vtkIdType id3(it2->Next()); + QString name2(QString::fromStdString((const char *)verticesNames2->GetValue(id3))); QList strs2; strs2.append(name2); + QString toolTipName2(name2); + pqTreeWidgetItemObject *item2(new pqTreeWidgetItemObject(item1,strs2)); + item2->setData(0,Qt::UserRole,name2); + item2->setData(0,Qt::ToolTipRole,toolTipName2); + item2->setData(0,Qt::CheckStateRole,0); + vtkAdjacentVertexIterator *it3(vtkAdjacentVertexIterator::New());//fields ! + g2->GetAdjacentVertices(id3,it3); + while(it3->HasNext()) + { + vtkIdType id4(it3->Next()); + std::string name3CppFull((const char *)verticesNames2->GetValue(id4)); + std::size_t pos(name3CppFull.find_first_of(ZE_SEP)); + std::string name3Only(name3CppFull.substr(0,pos)); std::string spatialDiscr(name3CppFull.substr(pos+sizeof(ZE_SEP)-1)); + QString name3(QString::fromStdString(name3Only)); QList strs3; strs3.append(name3); + QString toolTipName3(name3+QString(" (")+spatialDiscr.c_str()+QString(")")); + // + vtkAdjacentVertexIterator *it4(vtkAdjacentVertexIterator::New());// is it a special field ? A field mesh ? + g2->GetAdjacentVertices(id4,it4); + bool isSpecial(it4->HasNext()); + it4->Delete(); + // + pqTreeWidgetItemObject *item3(new pqTreeWidgetItemObject(item2,strs3)); + _all_lev4.push_back(item3); + item3->setData(0,Qt::UserRole,name3); + item3->setData(0,Qt::CheckStateRole,0); + if(isSpecial) + { + QFont font; font.setItalic(true); font.setUnderline(true); + item3->setData(0,Qt::FontRole,QVariant(font)); + item3->setData(0,Qt::ToolTipRole,QString("Whole \"%1\" mesh").arg(name3)); + item3->setData(0,Qt::DecorationRole,PixSingle::GetInstance().getWholeMeshPix()); + } + else + { + item3->setData(0,Qt::ToolTipRole,toolTipName3); + item3->setData(0,Qt::DecorationRole,PixSingle::GetInstance().getPixFromStr(spatialDiscr)); + } + this->propertyManager()->registerLink(item3,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,ll); + _leaves.insert(std::pair(item3,ll)); + connect(item2,SIGNAL(checkedStateChanged(bool)),item3,SLOT(setChecked(bool))); + connect(item3,SIGNAL(checkedStateChanged(bool)),this,SLOT(aLev4HasBeenFired())); + ll++; + } + it3->Delete(); + if(kk==0) + item2->setChecked(true); + kk++; + } + it2->Delete(); + } + it1->Delete(); + } + it0->Delete(); + this->UI->Fields->header()->setStretchLastSection(true); + this->UI->Fields->expandAll(); + info->Delete(); + this->UI->stdMode->setChecked(true); + this->UI->VTKConnect->Connect(this->proxy(),vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL())); + /// + this->UI->Reload->setProperty("NbOfReloadDynProp",QVariant(1)); + vtkSMProperty *SMProperty(this->proxy()->GetProperty("ReloadReq")); + connect(this->UI->Reload,SIGNAL(pressed()),this,SLOT(reloadFired())); + this->propertyManager()->registerLink(this->UI->Reload,"NbOfReloadDynProp",SIGNAL(pressed()),this->proxy(),SMProperty); + /// + vtkSMProperty *SMProperty0(this->proxy()->GetProperty("GenerateVectors")); + this->propertyManager()->registerLink(this->UI->GenerateVects,"checked",SIGNAL(stateChanged(int)),this->proxy(),SMProperty0); + /// + vtkSMProperty *SMProperty2(this->proxy()->GetProperty("TimeOrModal")); + SMProperty2->ResetToDefault();//this line is very important ! + this->propertyManager()->registerLink(this->UI->modeMode,"checked",SIGNAL(toggled(bool)),this->proxy(),SMProperty2); + /// + delete _optional_widget; + _optional_widget=new VectBoolWidget(this->UI->timeStepsInspector,getMaxNumberOfTS()); + _optional_widget->hide(); + this->UI->timeStepsInspector->setMinimumSize(QSize(0,0)); + connect(this->UI->modeMode,SIGNAL(toggled(bool)),this,SLOT(vectOfBoolWidgetRequested(bool))); + vtkSMProperty *SMProperty3(this->proxy()->GetProperty("TimesFlagsStatus")); + SMProperty3->ResetToDefault(); + const QVector& items(_optional_widget->getItems()); + int itt(0); + foreach(VectBoolItem *item,items) + { + this->propertyManager()->registerLink(item,"activated",SIGNAL(changed()),this->proxy(),SMProperty3,itt++); + } +} + +pqMEDReaderPanel::~pqMEDReaderPanel() +{ + delete _optional_widget; +} + +void pqMEDReaderPanel::linkServerManagerProperties() +{ + this->Superclass::linkServerManagerProperties(); +} + +void pqMEDReaderPanel::updateSIL() +{ + if(_reload_req) + { + _reload_req=false; + this->UI->geometryGroupBox->hide(); + delete this->UI; + foreach(QObject *child,children()) + { + QLayout *layout(qobject_cast(child)); + if(layout) + delete layout; + } + initAll(); + } +} + +void pqMEDReaderPanel::aLev4HasBeenFired() +{ + pqTreeWidgetItemObject *zeItem(qobject_cast(sender())); + if(!zeItem) + return; + pqTreeWidgetItemObject *father(dynamic_cast(zeItem->QTreeWidgetItem::parent())); + QTreeWidgetItem *godFather(father->QTreeWidgetItem::parent()->parent()); + if(!father) + return ; + if(zeItem->isChecked()) + { + bool isActivatedTSChanged(false); + // This part garantees that all leaves having not the same father than zeItem are desactivated + foreach(pqTreeWidgetItemObject* elt,this->_all_lev4) + { + QTreeWidgetItem *testFath(elt->QTreeWidgetItem::parent()); + if(testFath!=father) + if(elt->isChecked()) + { + elt->setChecked(false); + if(godFather!=testFath->parent()->parent()) + isActivatedTSChanged=true; + } + } + //If all leaves are checked the father is check too + bool allItemsAreChked(true); + for(int i=0;ichildCount() && allItemsAreChked;i++) + { + pqTreeWidgetItemObject *elt(dynamic_cast(father->child(i))); + if(elt && !elt->isChecked()) + allItemsAreChked=false; + } + if(allItemsAreChked && !father->isChecked()) + father->setChecked(true); + // the user by clicking to a new entry has changed of TimeStepSeries -> notify it to thee time step selector widget + if(isActivatedTSChanged) + { + QStringList its,dts,tts; + getCurrentTS(its,dts,tts); + _optional_widget->setItems(its,dts,tts); + } + } + else + { + // if all are unchecked - check it again + bool allItemsAreUnChked(true); + foreach(pqTreeWidgetItemObject* elt,this->_all_lev4) + { + if(elt && elt->isChecked()) + allItemsAreUnChked=false; + } + if(allItemsAreUnChked) + zeItem->setChecked(true);// OK zeItem was required to be unchecked but as it is the last one. Recheck it ! + else + {// if all items are uncheked inside a same parent - uncheck the parent + allItemsAreUnChked=true; + for(int i=0;ichildCount() && allItemsAreUnChked;i++) + { + pqTreeWidgetItemObject *elt(dynamic_cast(father->child(i))); + if(elt && elt->isChecked()) + allItemsAreUnChked=false; + } + if(allItemsAreUnChked && father->isChecked()) + father->setChecked(false); + } + } +} + +void pqMEDReaderPanel::reloadFired() +{ + static int iii(1); + QVariant v(iii++); + this->UI->Reload->setProperty("NbOfReloadDynProp",v); + _reload_req=true; + for(std::set >::const_iterator it=_leaves.begin();it!=_leaves.end();it++) + ((*it).first)->disconnect(SIGNAL(checkedStateChanged(bool))); + // + vtkSMProperty *SMProperty(this->proxy()->GetProperty("FieldsStatus")); + for(std::set >::const_iterator it=_leaves.begin();it!=_leaves.end();it++) + this->propertyManager()->unregisterLink((*it).first,"checked",SIGNAL(checkedStateChanged(bool)),this->proxy(),SMProperty,(*it).second); + this->propertyManager()->propertyChanged(); + vtkSMProperty *SMProperty3(this->proxy()->GetProperty("TimeOrModal")); + this->propertyManager()->unregisterLink(this->UI->modeMode,"checked",SIGNAL(toggled(bool)),this->proxy(),SMProperty3); +} + +void pqMEDReaderPanel::vectOfBoolWidgetRequested(bool isMode) +{ + if(isMode) + { + this->UI->timeStepsInspector->setMinimumSize(QSize(200,250)); + _optional_widget->show(); + QStringList its,dts,tts; + getCurrentTS(its,dts,tts); + _optional_widget->setItems(its,dts,tts); + } + else + { + _optional_widget->hide(); + this->UI->timeStepsInspector->setMinimumSize(QSize(0,0)); + } +} + +void pqMEDReaderPanel::getCurrentTS(QStringList& its, QStringList& dts, QStringList& tts) const +{ + + for(std::vector::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++) + { + if((*it)->property("checked").toInt()) + { + QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()); + pqTreeWidgetItemObject *objC(dynamic_cast(obj)); + its=objC->property("ITS").toStringList(); + dts=objC->property("DTS").toStringList(); + tts=objC->property("TTS").toStringList(); + return; + } + } + std::cerr << "pqMEDReaderPanel::getCurrentTS : internal error ! Something is going wrong !" << std::endl; +} + +int pqMEDReaderPanel::getMaxNumberOfTS() const +{ + int ret(0); + for(std::vector::const_iterator it=_all_lev4.begin();it!=_all_lev4.end();it++) + { + if((*it)->property("checked").toInt()) + { + QTreeWidgetItem *obj((*it)->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()->QTreeWidgetItem::parent()); + pqTreeWidgetItemObject *objC(dynamic_cast(obj)); + ret=std::max(ret,objC->property("NbOfTS").toInt()); + } + } + return ret; +} diff --git a/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h new file mode 100644 index 00000000..3d848967 --- /dev/null +++ b/src/Plugins/MEDReader/ParaViewPlugin/pqMEDReaderPanel.h @@ -0,0 +1,61 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#ifndef _pqMEDReaderPanel_h +#define _pqMEDReaderPanel_h + +#include "pqNamedObjectPanel.h" + +#include + +class pqTreeWidgetItemObject; +class VectBoolWidget; + +class vtkSMProperty; + +class pqMEDReaderPanel: public pqNamedObjectPanel +{ +Q_OBJECT + typedef pqNamedObjectPanel Superclass; +public: + pqMEDReaderPanel(pqProxy* proxy, QWidget* p = NULL); + ~pqMEDReaderPanel(); +protected slots: + void aLev4HasBeenFired(); + void updateSIL(); + void reloadFired(); + void vectOfBoolWidgetRequested(bool isMode); +private: + int getMaxNumberOfTS() const; + void getCurrentTS(QStringList& its, QStringList& dts, QStringList& tts) const; +protected: + /// populate widgets with properties from the server manager + virtual void linkServerManagerProperties(); + void initAll(); + class pqUI; + pqUI* UI; + std::vector _all_lev4; +private: + bool _reload_req; + std::set > _leaves; + VectBoolWidget *_optional_widget; +}; + +#endif diff --git a/src/Plugins/MEDReader/TODO.txt b/src/Plugins/MEDReader/TODO.txt new file mode 100644 index 00000000..7dd9edd4 --- /dev/null +++ b/src/Plugins/MEDReader/TODO.txt @@ -0,0 +1,42 @@ +TODO : +------ + + + +3 - propagate the update of filters connected directly or not (typically ExtractGroup) to the MEDReader when the groups have been updated. +UC : ForMEDReader16.med, then extractgroup, then return to MEDReader properties and select zeField3_1 & zeField4_1 -> ExtractGroup filter is out of date and "Apply" button not green. + + +Known bug : +----------- + +- Extract cell type + Extract Group + + +TODO in MED: +------------ + +- Manage degenerated cases. + +DONE +---- + +0- Sur le time quand tout a echouer prendre le plus grand < (07/01/2014) + +1 - Load ForMEDReader8.med, Load ForMEDReader17.med +-> throw because of missynchronization of time. -> Alejandro (07/01/2014) + +1 - ELNO to be added only once not for each GAUSS_NE -> To test a file having > 1 field with GAUSS_NE + +1 - Keep tracks of built support to accelerate rendering in MEDFileFieldRepresentation. + +2 - in branch EDF1 : adm_local_without_kernel to put in install of MED_SRC +when in STANDALONE mode. + +0 - test22 doit etre sur les seg2 et tri3 + +1 - When Reload Applied it is possible with gui to unselect all ! + +0 - protect ExtractGroup against throw + +0 - protect ExctractCellType against throw diff --git a/src/Plugins/MEDReader/Test/CMakeLists.txt b/src/Plugins/MEDReader/Test/CMakeLists.txt new file mode 100644 index 00000000..425a61ad --- /dev/null +++ b/src/Plugins/MEDReader/Test/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +ADD_TEST(testMEDReader0 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader0.py) +ADD_TEST(testMEDReader1 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader1.py) +ADD_TEST(testMEDReader2 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader2.py) +ADD_TEST(testMEDReader3 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader3.py) +ADD_TEST(testMEDReader4 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader4.py) +ADD_TEST(testMEDReader5 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader5.py) +ADD_TEST(testMEDReader6 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader6.py) +ADD_TEST(testMEDReader7 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader7.py) diff --git a/src/Plugins/MEDReader/Test/testMEDReader0.py b/src/Plugins/MEDReader/Test/testMEDReader0.py new file mode 100644 index 00000000..5b33b462 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader0.py @@ -0,0 +1,124 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +fname="testMEDReader0.med" +outImgName="testMEDReader0.png" +######### +mz=MEDCoupling1SGTUMesh("mesh",NORM_QUAD9) +mz.setNodalConnectivity(DataArrayInt([0,6,37,12,76,112,113,82,205,12,37,38,13,113,114,115,83,206,13,38,9,1,115,116,79,84,207,6,7,39,37,77,117,118,112,208,37,39,40,38,118,119,120,114,209,38,40,10,9,120,121,80,116,210,7,8,41,39,78,122,123,117,211,39,41,42,40,123,124,125,119,212,40,42,11,10,125,126,81,121,213,1,9,43,17,79,127,128,88,214,17,43,44,18,128,129,130,89,215,18,44,14,2,130,131,85,90,216,9,10,45,43,80,132,133,127,217,43,45,46,44,133,134,135,129,218,44,46,15,14,135,136,86,131,219,10,11,47,45,81,137,138,132,220,45,47,48,46,138,139,140,134,221,46,48,16,15,140,141,87,136,222,1,9,49,22,79,142,143,94,223,22,49,50,23,143,144,145,95,224,23,50,51,24,145,146,147,96,225,24,51,52,25,147,148,149,97,226,25,52,53,26,149,150,151,98,227,26,53,19,3,151,152,91,99,228,9,10,54,49,80,153,154,142,229,49,54,55,50,154,155,156,144,230,50,55,56,51,156,157,158,146,231,51,56,57,52,158,159,160,148,232,52,57,58,53,160,161,162,150,233,53,58,20,19,162,163,92,152,234,10,11,59,54,81,164,165,153,235,54,59,60,55,165,166,167,155,236,55,60,61,56,167,168,169,157,237,56,61,62,57,169,170,171,159,238,57,62,63,58,171,172,173,161,239,58,63,21,20,173,174,93,163,240,4,27,64,30,100,175,176,103,241,30,64,65,31,176,177,178,104,242,31,65,19,3,178,179,91,105,243,27,28,66,64,101,180,181,175,244,64,66,67,65,181,182,183,177,245,65,67,20,19,183,184,92,179,246,28,29,68,66,102,185,186,180,247,66,68,69,67,186,187,188,182,248,67,69,21,20,188,189,93,184,249,3,19,70,35,91,190,191,109,250,35,70,71,36,191,192,193,110,251,36,71,32,5,193,194,106,111,252,19,20,72,70,92,195,196,190,253,70,72,73,71,196,197,198,192,254,71,73,33,32,198,199,107,194,255,20,21,74,72,93,200,201,195,256,72,74,75,73,201,202,203,197,257,73,75,34,33,203,204,108,199,258])) +coords=DataArrayDouble([-0.04,0.015,0.,0.,0.015,0.,0.04,0.015,0.,0.,0.105,0.,-0.04,0.105,0.,0.04,0.105,0.,-0.04,0.015,0.015,-0.04,0.015,0.03,-0.04,0.015,0.045,0.,0.015,0.015,0.,0.015,0.03,0.,0.015,0.045,-0.026666666666666665,0.015,0.,-0.013333333333333329,0.015,0.,0.04,0.015,0.015,0.04,0.015,0.03,0.04,0.015,0.045,0.013333333333333336,0.015,0.,0.026666666666666672,0.015,0.,0.,0.105,0.015,0.,0.105,0.03,0.,0.105,0.045,0.,0.03,0.,0.,0.045,0.,0.,0.06,0.,0.,0.075,0.,0.,0.09,0.,-0.04,0.105,0.015,-0.04,0.105,0.03,-0.04,0.105,0.045,-0.026666666666666665,0.105,0.,-0.013333333333333329,0.105,0.,0.04,0.105,0.015,0.04,0.105,0.03,0.04,0.105,0.045,0.013333333333333336,0.105,0.,0.026666666666666672,0.105,0.,-0.026666666666666665,0.015,0.015,-0.013333333333333326,0.015,0.015,-0.026666666666666665,0.015,0.03,-0.013333333333333326,0.015,0.03,-0.026666666666666665,0.015,0.045,-0.013333333333333329,0.015,0.045,0.013333333333333338,0.015,0.015,0.026666666666666675,0.015,0.015,0.013333333333333338,0.015,0.03,0.026666666666666675,0.015,0.03,0.013333333333333336,0.015,0.045,0.026666666666666672,0.015,0.045,0.,0.03,0.015,0.,0.045,0.015,0.,0.06,0.015,0.,0.07500000000000001,0.015,0.,0.09,0.015,0.,0.03,0.03,0.,0.045,0.03,0.,0.06,0.03,0.,0.075,0.03,0.,0.09,0.03,0.,0.03,0.045,0.,0.045,0.045,0.,0.06,0.045,0.,0.075,0.045,0.,0.09,0.045,-0.026666666666666665,0.105,0.015,-0.013333333333333326,0.105,0.015,-0.026666666666666665,0.105,0.03,-0.013333333333333326,0.105,0.03,-0.026666666666666665,0.105,0.045,-0.013333333333333329,0.105,0.045,0.013333333333333338,0.105,0.015,0.026666666666666675,0.105,0.015,0.013333333333333338,0.105,0.03,0.026666666666666675,0.105,0.03,0.013333333333333336,0.105,0.045,0.026666666666666672,0.105,0.045,-0.04,0.015,0.0075,-0.04,0.015,0.0225,-0.04,0.015,0.0375,0.,0.015,0.0075,0.,0.015,0.0225,0.,0.015,0.0375,-0.03333333333333333,0.015,0.,-0.02,0.015,0.,-0.0066666666666666645,0.015,0.,0.04,0.015,0.0075,0.04,0.015,0.0225,0.04,0.015,0.0375,0.006666666666666668,0.015,0.,0.02,0.015,0.,0.03333333333333334,0.015,0.,0.,0.105,0.0075,0.,0.105,0.0225,0.,0.105,0.0375,0.,0.0225,0.,0.,0.0375,0.,0.,0.0525,0.,0.,0.0675,0.,0.,0.0825,0.,0.,0.0975,0.,-0.04,0.105,0.0075,-0.04,0.105,0.0225,-0.04,0.105,0.0375,-0.03333333333333333,0.105,0.,-0.02,0.105,0.,-0.0066666666666666645,0.105,0.,0.04,0.105,0.0075,0.04,0.105,0.0225,0.04,0.105,0.0375,0.006666666666666668,0.105,0.,0.02,0.105,0.,0.03333333333333334,0.105,0.,-0.03333333333333333,0.015,0.015,-0.026666666666666665,0.015,0.0075,-0.02,0.015,0.015,-0.013333333333333327,0.015,0.0075,-0.006666666666666663,0.015,0.015,-0.03333333333333333,0.015,0.03,-0.026666666666666665,0.015,0.0225,-0.02,0.015,0.03,-0.013333333333333326,0.015,0.0225,-0.006666666666666663,0.015,0.03,-0.03333333333333333,0.015,0.045,-0.026666666666666665,0.015,0.0375,-0.02,0.015,0.045,-0.013333333333333327,0.015,0.0375,-0.0066666666666666645,0.015,0.045,0.006666666666666669,0.015,0.015,0.013333333333333336,0.015,0.0075,0.020000000000000007,0.015,0.015,0.026666666666666672,0.015,0.0075,0.03333333333333334,0.015,0.015,0.006666666666666669,0.015,0.03,0.013333333333333338,0.015,0.0225,0.02,0.015,0.03,0.026666666666666675,0.015,0.0225,0.03333333333333334,0.015,0.03,0.006666666666666668,0.015,0.045,0.013333333333333336,0.015,0.0375,0.02,0.015,0.045,0.026666666666666672,0.015,0.0375,0.03333333333333334,0.015,0.045,0.,0.0225,0.015,0.,0.03,0.0075,0.,0.0375,0.015,0.,0.045,0.0075,0.,0.0525,0.015,0.,0.06,0.0075,0.,0.0675,0.015,0.,0.07500000000000001,0.0075,0.,0.0825,0.015,0.,0.09,0.0075,0.,0.0975,0.015,0.,0.0225,0.03,0.,0.03,0.0225,0.,0.0375,0.03,0.,0.045,0.0225,0.,0.0525,0.03,0.,0.06,0.0225,0.,0.0675,0.03,0.,0.07500000000000001,0.0225,0.,0.08249999999999999,0.03,0.,0.09,0.0225,0.,0.0975,0.03,0.,0.0225,0.045,0.,0.03,0.0375,0.,0.0375,0.045,0.,0.045,0.0375,0.,0.0525,0.045,0.,0.06,0.0375,0.,0.0675,0.045,0.,0.075,0.0375,0.,0.08249999999999999,0.045,0.,0.09,0.0375,0.,0.0975,0.045,-0.03333333333333333,0.105,0.015,-0.026666666666666665,0.105,0.0075,-0.02,0.105,0.015,-0.013333333333333327,0.105,0.0075,-0.006666666666666663,0.105,0.015,-0.03333333333333333,0.105,0.03,-0.026666666666666665,0.105,0.0225,-0.02,0.105,0.03,-0.013333333333333326,0.105,0.0225,-0.006666666666666663,0.105,0.03,-0.03333333333333333,0.105,0.045,-0.026666666666666665,0.105,0.0375,-0.02,0.105,0.045,-0.013333333333333327,0.105,0.0375,-0.0066666666666666645,0.105,0.045,0.006666666666666669,0.105,0.015,0.013333333333333336,0.105,0.0075,0.020000000000000007,0.105,0.015,0.026666666666666672,0.105,0.0075,0.03333333333333334,0.105,0.015,0.006666666666666669,0.105,0.03,0.013333333333333338,0.105,0.0225,0.020000000000000007,0.105,0.03,0.026666666666666675,0.105,0.0225,0.03333333333333334,0.105,0.03,0.006666666666666668,0.105,0.045,0.013333333333333336,0.105,0.0375,0.02,0.105,0.045,0.026666666666666672,0.105,0.0375,0.03333333333333334,0.105,0.045,-0.03333333333333333,0.015,0.0075,-0.02,0.015,0.0075,-0.006666666666666664,0.015,0.0075,-0.03333333333333333,0.015,0.0225,-0.02,0.015,0.0225,-0.006666666666666663,0.015,0.0225,-0.03333333333333333,0.015,0.0375,-0.02,0.015,0.0375,-0.006666666666666662,0.015,0.0375,0.006666666666666668,0.015,0.0075,0.02,0.015,0.0075,0.03333333333333334,0.015,0.0075,0.006666666666666669,0.015,0.0225,0.020000000000000007,0.015,0.0225,0.03333333333333334,0.015,0.0225,0.006666666666666668,0.015,0.0375,0.02,0.015,0.0375,0.03333333333333334,0.015,0.0375,0.,0.0225,0.0075,0.,0.0375,0.0075,0.,0.0525,0.0075,0.,0.0675,0.0075,0.,0.0825,0.0075,0.,0.0975,0.0075,0.,0.0225,0.0225,0.,0.0375,0.0225,0.,0.0525,0.0225,0.,0.0675,0.0225,0.,0.0825,0.0225,0.,0.0975,0.0225,0.,0.0225,0.0375,0.,0.0375,0.0375,0.,0.0525,0.0375,0.,0.0675,0.0375,0.,0.08249999999999999,0.0375,0.,0.0975,0.0375,-0.03333333333333333,0.105,0.0075,-0.02,0.105,0.0075,-0.006666666666666664,0.105,0.0075,-0.03333333333333333,0.105,0.0225,-0.02,0.105,0.0225,-0.006666666666666663,0.105,0.0225,-0.03333333333333333,0.105,0.0375,-0.02,0.105,0.0375,-0.006666666666666662,0.105,0.0375,0.006666666666666668,0.105,0.0075,0.02,0.105,0.0075,0.03333333333333334,0.105,0.0075,0.006666666666666669,0.105,0.0225,0.020000000000000007,0.105,0.0225,0.03333333333333334,0.105,0.0225,0.006666666666666668,0.105,0.0375,0.02,0.105,0.0375,0.03333333333333334,0.105,0.0375],259,3) +coords.setInfoOnComponents(['X [INCONNUE]','Y [INCONNUE]','Z [INCONNUE]']) +mz.setCoords(coords) +mz=mz.buildUnstructured() +# +arr0=DataArrayDouble() +vals0=9*[-3593.,85220.,-15343.,-438.,11985.,-15343.,2716.,-61248.,-15343.,5488.,101072.,-16250.,549.,13186.,-16250.,-4389.,-74699.,-16250.,9988.,101646.,-17156.,1537.,14386.,-17156.,-6913.,-72874.,-17156.,22178.,120238.,-19521.,2342.,14222.,-19521.,-17493.,-91793.,-19521.,37737.,139840.,-21887.,3147.,14059.,-21887.,-31443.,-111722.,-21887.,34350.,140668.,-18690.,3714.,16214.,-18690.,-26922.,-108238.,-18690.,34563.,153494.,-15493.,4281.,18370.,-15493.,-26000.,-116753.,-15493.,2147.,115356.,-15418.,1921.,15178.,-15418.,1695.,-84999.,-15418.,12408.,118616.,-17470.,2131.,14700.,-17470.,-8144.,-89215.,-17470.,15624.,100983.,-16718.,2286.,15441.,-16718.,-11050.,-70101.,-16718.,19381.,102680.,-17191.,2505.,16813.,-17191.,-14370.,-69054.,-17191.,22911.,103615.,-17665.,2725.,18184.,-17665.,-17461.,-67245.,-17665.,32377.,125140.,-20005.,4011.,17741.,-20005.,-24353.,-89657.,-20005.,43183.,147067.,-22345.,5298.,17297.,-22345.,-32586.,-112472.,-22345.,41570.,144664.,-22105.,4896.,15874.,-22105.,-31778.,-112915.,-22105.,40070.,142637.,-21866.,4493.,14451.,-21866.,-31083.,-113734.,-21866.,25367.,121066.,-19292.,3390.,14946.,-19292.,-18587.,-91173.,-19292.,28901.,123199.,-19648.,3701.,16343.,-19648.,-21499.,-90512.,-19648.,23716.,103481.,-17470.,2234.,18509.,-17470.,-19247.,-66463.,-17470.,22561.,104808.,-17142.,1238.,20732.,-17142.,-20084.,-63343.,-17142.,21499.,106443.,-16813.,242.,22956.,-16813.,-21014.,-60531.,-16813.,32906.,133441.,-20775.,3873.,26633.,-20775.,-25158.,-80173.,-20775.,45801.,160885.,-24737.,7505.,30311.,-24737.,-30791.,-100262.,-24737.,44184.,154705.,-23601.,5922.,24329.,-23601.,-32340.,-106046.,-23601.,42566.,148521.,-22465.,4338.,18347.,-22465.,-33888.,-111825.,-22465.,32545.,125822.,-19968.,3286.,18428.,-19968.,-25972.,-88965.,-19968.,32703.,129556.,-20371.,3580.,22531.,-20371.,-25542.,-84493.,-20371.,-580.,50781.,-14878.,-188.,10419.,-14878.,203.,-29941.,-14878.,974.,53486.,-13087.,-197.,11696.,-13087.,-1370.,-30094.,-13087.,2154.,54941.,-11297.,-206.,12972.,-11297.,-2567.,-28996.,-11297.,4921.,72039.,-13221.,709.,13770.,-13221.,-3503.,-44499.,-13221.,6472.,88772.,-15144.,1624.,14567.,-15144.,-3223.,-59637.,-15144.,4104.,85353.,-15580.,600.,13047.,-15580.,-2903.,-59258.,-15580.,1258.,80341.,-16016.,-423.,11526.,-16016.,-2105.,-57288.,-16016.,-822.,65212.,-15447.,-306.,10973.,-15447.,210.,-43266.,-15447.,2262.,69336.,-14334.,201.,12371.,-14334.,-1859.,-44593.,-14334.,4047.,55415.,-11562.,137.,13264.,-11562.,-3772.,-28887.,-11562.,6455.,56737.,-11164.,80.,14219.,-11164.,-6294.,-28298.,-11164.,8701.,57516.,-10766.,23.,15175.,-10766.,-8653.,-27166.,-10766.,12843.,74210.,-13196.,662.,16118.,-13196.,-11519.,-41972.,-13196.,17837.,91160.,-15627.,1300.,17062.,-15627.,-15237.,-57034.,-15627.,14573.,90279.,-15674.,1166.,15841.,-15674.,-12240.,-58596.,-15674.,11497.,90026.,-15722.,1033.,14619.,-15722.,-9431.,-60786.,-15722.,7014.,72493.,-13642.,585.,13941.,-13642.,-5844.,-44609.,-13642.,9922.,73330.,-13419.,623.,15030.,-13419.,-8675.,-43270.,-13419.,9608.,58062.,-10666.,-408.,15882.,-10666.,-10425.,-26297.,-10666.,10622.,58358.,-9978.,-497.,16431.,-9978.,-11617.,-25496.,-9978.,11722.,58941.,-9290.,-587.,16979.,-9290.,-12896.,-24981.,-9290.,14386.,76411.,-12130.,-417.,19190.,-12130.,-15221.,-38029.,-12130.,18009.,94168.,-14969.,-248.,21401.,-14969.,-18505.,-51365.,-14969.,19049.,93091.,-15325.,999.,19998.,-15325.,-17050.,-53095.,-15325.,20242.,92527.,-15681.,2246.,18594.,-15681.,-15748.,-55338.,-15681.,14435.,75147.,-13174.,919.,17238.,-13174.,-12597.,-40670.,-13174.,14351.,75579.,-12652.,250.,18214.,-12652.,-13849.,-39150.,-12652.0] +arr0.setValues(vals0,1458,3) +arr0.setInfoOnComponents(['SIXX','SIYY','SIYZ']) +f0z=MEDCouplingFieldDouble(ON_GAUSS_PT) +f0z.setMesh(mz) +f0z.setArray(arr0) +f0z.setGaussLocalizationOnType(NORM_QUAD9,[-1,-1,1,-1,1,1,-1,1,0,-1,1,0,0,1,-1,0,0,0],[-0.774597,-0.774597,0.774597,-0.774597,0.774597,0.774597,-0.774597,0.774597,0,-0.774597,0.774597,0,0,0.774597,-0.774597,0,0,0,-0.774597,-0.774597,0.774597,-0.774597,0.774597,0.774597,-0.774597,0.774597,0,-0.774597,0.774597,0,0,0.774597,-0.774597,0,0,0,-0.774597,-0.774597,0.774597,-0.774597,0.774597,0.774597,-0.774597,0.774597,0,-0.774597,0.774597,0,0,0.774597,-0.774597,0,0,0],[0.308642,0.308642,0.308642,0.308642,0.493827,0.493827,0.493827,0.493827,0.790123,0.308642,0.308642,0.308642,0.308642,0.493827,0.493827,0.493827,0.493827,0.790123,0.308642,0.308642,0.308642,0.308642,0.493827,0.493827,0.493827,0.493827,0.790123]) +f0z.setName("SolutionSIEF_ELGA") +f0z.checkCoherency() +ff0z=MEDFileField1TS() +ff0z.setFieldNoProfileSBT(f0z) +# +arr1=DataArrayDouble([158663.,171562.,32597.,37341.,118998.,128979.,88846.,94935.,28786.,32250.,67038.,71287.,102742.,108939.,32907.,37716.,0.,0.,138922.,155768.,41391.,47731.,114491.,128395.,94101.,100197.,31445.,35939.,67322.,71913.,94031.,103701.,34833.,39475.,0.,0.,142412.,160086.,42700.,49041.,113826.,128551.,92705.,102386.,34032.,38580.,61698.,69417.,96177.,104283.,38223.,40570.,0.,0.,87935.,89674.,30482.,34419.,66325.,69150.,53964.,55380.,28306.,32157.,37909.,40395.,53662.,55355.,22264.,24611.,0.,0.,94013.,100457.,31768.,36134.,68065.,73681.,53358.,55305.,23341.,26188.,32996.,35203.,52496.,56792.,23849.,26556.,0.,0.,92797.,102692.,33656.,38268.,61244.,68735.,52594.,56740.,24539.,27146.,29157.,33011.,52853.,57683.,25671.,28315.,0.,0.,53581.,55745.,27972.,31820.,37174.,39935.,29236.,31416.,22475.,25354.,20531.,23672.,25557.,26298.,15741.,17492.,0.,0.,53385.,55725.,23224.,25998.,32556.,35093.,25809.,26619.,16518.,18338.,18447.,21219.,23343.,26173.,16948.,19353.,0.,0.,52384.,56725.,24293.,26951.,29491.,33373.,23510.,26382.,17117.,19543.,19649.,22252.,26670.,30680.,19554.,22512.,0.,0.,158781.,178651.,54413.,62227.,103151.,116693.,96177.,104283.,38223.,40570.,56254.,64331.,92705.,102386.,34032.,38580.,0.,0.,142873.,161033.,43285.,49854.,113088.,127440.,94031.,103701.,34833.,39475.,61888.,69552.,94101.,100197.,31445.,35939.,0.,0.,132908.,149284.,42933.,49391.,109280.,123481.,102742.,108939.,32907.,37716.,75662.,80547.,88846.,94935.,28786.,32250.,0.,0.,96505.,105010.,37990.,40710.,56669.,64741.,52853.,57683.,25671.,28315.,26824.,30727.,52594.,56740.,24539.,27146.,0.,0.,92360.,101577.,33582.,37900.,61559.,69237.,52496.,56792.,23849.,26556.,29094.,32746.,53358.,55305.,23341.,26188.,0.,0.,95615.,101326.,31440.,36083.,69356.,73116.,53662.,55355.,22264.,24611.,31957.,34376.,53964.,55380.,28306.,32157.,0.,0.,53029.,58077.,25636.,28363.,27182.,31122.,26670.,30680.,19554.,22512.,20758.,22139.,23510.,26382.,17117.,19543.,0.,0.,52348.,56723.,23922.,26648.,29286.,32993.,23343.,26173.,16948.,19353.,19615.,22178.,25809.,26619.,16518.,18338.,0.,0.,53623.,55229.,22321.,24800.,32700.,34971.,25557.,26298.,15741.,17492.,18986.,21836.,29236.,31416.,22475.,25354.,0.,0.,64897.,69997.,64897.,69997.,64897.,69997.,81086.,90448.,81086.,90448.,81086.,90448.,85289.,98323.,85289.,98323.,0.,0.,71712.,82585.,71712.,82585.,71712.,82585.,83868.,96651.,83868.,96651.,83868.,96651.,86266.,99505.,86266.,99505.,0.,0.,77671.,89574.,77671.,89574.,77671.,89574.,86057.,99277.,86057.,99277.,86057.,99277.,86664.,99373.,86664.,99373.,0.,0.,80105.,91799.,80105.,91799.,80105.,91799.,86589.,99313.,86589.,99313.,86589.,99313.,85997.,97609.,85997.,97609.,0.,0.,79826.,90350.,79826.,90350.,79826.,90350.,86438.,98180.,86438.,98180.,86438.,98180.,85995.,95152.,85995.,95152.,0.,0.,75137.,82756.,75137.,82756.,75137.,82756.,88617.,98610.,88617.,98610.,88617.,98610.,79961.,83623.,79961.,83623.,0.,0.,79241.,88756.,79241.,88756.,79241.,88756.,84552.,97374.,84552.,97374.,84552.,97374.,93024.,107413.,93024.,107413.,0.,0.,85301.,98315.,85301.,98315.,85301.,98315.,92453.,106752.,92453.,106752.,92453.,106752.,93783.,108035.,93783.,108035.,0.,0.,86813.,100152.,86813.,100152.,86813.,100152.,93530.,107737.,93530.,107737.,93530.,107737.,92512.,106099.,92512.,106099.,0.,0.,87195.,100044.,87195.,100044.,87195.,100044.,92527.,106109.,92527.,106109.,92527.,106109.,90156.,102760.,90156.,102760.,0.,0.,87342.,99233.,87342.,99233.,87342.,99233.,90384.,103001.,90384.,103001.,90384.,103001.,85458.,96494.,85458.,96494.,0.,0.,90428.,100728.,90428.,100728.,90428.,100728.,85454.,96396.,85454.,96396.,85454.,96396.,70692.,78323.,70692.,78323.,0.,0.,84617.,97440.,84617.,97440.,84617.,97440.,83973.,96607.,83973.,96607.,83973.,96607.,92886.,106795.,92886.,106795.,0.,0.,92294.,106564.,92294.,106564.,92294.,106564.,92515.,106364.,92515.,106364.,92515.,106364.,94158.,108033.,94158.,108033.,0.,0.,93639.,107861.,93639.,107861.,93639.,107861.,93950.,107796.,93950.,107796.,93950.,107796.,91874.,105168.,91874.,105168.,0.,0.,92701.,106313.,92701.,106313.,92701.,106313.,91869.,105167.,91869.,105167.,91869.,105167.,87044.,99369.,87044.,99369.,0.,0.,90450.,103104.,90450.,103104.,90450.,103104.,87236.,99605.,87236.,99605.,87236.,99605.,78375.,89211.,78375.,89211.,0.,0.,84833.,95787.,84833.,95787.,84833.,95787.,78665.,89521.,78665.,89521.,78665.,89521.,63448.,71985.,63448.,71985.,0.,0.,9194.,10306.,41521.,44441.,79431.,85178.,8946.,9792.,22335.,23886.,51736.,54740.,7726.,8300.,30477.,32533.,0.,0.,25028.,27404.,28235.,31471.,75379.,84132.,7236.,8309.,29539.,31536.,54052.,58395.,22577.,23370.,39152.,41429.,0.,0.,37235.,42691.,35353.,38183.,100490.,111738.,23433.,25843.,36759.,39109.,53411.,59694.,57437.,65025.,61345.,68878.,0.,0.,6377.,6683.,22457.,23448.,49503.,50751.,10380.,10835.,19266.,19610.,28417.,28750.,20732.,22044.,26521.,27276.,0.,0.,10131.,11681.,28482.,29670.,52601.,56753.,20722.,21728.,25680.,25959.,30780.,31657.,32161.,33290.,33096.,34633.,0.,0.,21380.,22651.,37121.,39923.,54598.,60751.,34744.,36379.,35111.,37417.,35939.,39080.,46708.,51426.,44384.,48624.,0.,0.,10952.,11418.,19643.,20167.,28488.,29118.,20182.,20242.,18359.,18431.,16718.,16900.,24621.,25169.,20737.,21234.,0.,0.,20251.,21309.,25725.,26026.,31355.,32256.,24539.,25102.,20991.,21593.,17889.,18639.,31588.,32417.,27170.,29235.,0.,0.,33431.,35174.,34427.,36736.,35916.,38926.,31741.,32451.,27148.,29040.,23993.,27214.,38993.,40689.,36596.,40772.,0.,0.,41907.,48128.,77947.,87844.,152033.,169876.,57437.,65025.,61345.,68878.,74154.,85533.,23433.,25843.,36759.,39109.,0.,0.,33932.,38310.,36200.,40713.,99297.,111743.,22577.,23370.,39152.,41429.,57432.,62292.,7236.,8309.,29539.,31536.,0.,0.,22968.,26297.,27645.,30092.,72463.,80413.,7726.,8300.,30477.,32533.,57469.,61055.,8946.,9792.,22335.,23886.,0.,0.,48710.,53918.,59260.,65402.,77350.,87781.,46708.,51426.,44384.,48624.,50354.,58143.,34744.,36379.,35111.,37417.,0.,0.,20908.,22670.,38133.,39669.,56332.,59453.,32161.,33290.,33096.,34633.,34367.,36793.,20722.,21728.,25680.,25959.,0.,0.,7404.,8010.,30073.,32272.,55210.,58955.,20732.,22044.,26521.,27276.,32434.,32943.,10380.,10835.,19266.,19610.,0.,0.,45425.,49667.,44460.,48383.,51014.,58851.,38993.,40689.,36596.,40772.,38865.,44837.,31741.,32451.,27148.,29040.,0.,0.,31595.,32602.,33322.,34837.,35379.,37698.,31588.,32417.,27170.,29235.,24035.,27311.,24539.,25102.,20991.,21593.,0.,0.,19475.,20577.,25384.,25965.,31447.,32050.,24621.,25169.,20737.,21234.,17759.,18414.,20182.,20242.,18359.,18431.,0.,0.],486,2) +arr1.setInfoOnComponents(['VMIS','TRESCA']) +f1z=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f1z.setName("SolutionSIEQ_ELNO") +f1z.setArray(arr1) +f1z.setMesh(mz) +f1z.checkCoherency() +ff1z=MEDFileField1TS() +ff1z.setFieldNoProfileSBT(f1z) +# +arr2=DataArrayDouble([4.938269266683534e-28,-6.232001151245993e-28,1.0602290566170399e-27,4.029857051193646e-29,-1.1103217240985741e-27,-1.5536615528327828e-27,1.5241233363338648e-28,-3.015674201798923e-30,-1.02980203874559e-30,2.72351596604712e-29,-1.1888246600739933e-29,-2.69937196846485e-29,-4.7437993223547586e-07,1.3496193329105202e-07,-7.295395086913946e-07,7.054959528904149e-08,-8.433644218153947e-07,-1.3140517414252605e-08,-4.6699282590396373e-07,-4.307881601165781e-21,-7.181557182928824e-07,-8.028640214851634e-21,-8.231757491716489e-07,-1.2311604671716488e-20,6.500213859021137e-28,-5.36425415550288e-29,2.082592789783471e-28,1.3252863207712998e-28,-4.743799322354692e-07,-1.3496193329105909e-07,-7.295395086913853e-07,-7.054959528905818e-08,-8.433644218153849e-07,1.3140517414226876e-08,6.058451752097371e-28,5.632466863278024e-28,2.208810534618833e-28,2.2876966251409342e-28,-6.120655339318954e-07,1.623023866978208e-20,-7.136250920460284e-07,4.359903572644498e-20,-6.995066975751433e-07,7.373674095935513e-20,0.0,1.4598897976731362e-43,0.0,5.997557427310217e-43,0.0,1.156071233067974e-43,0.0,6.726232628759122e-44,0.0,1.0089348943138683e-43,-4.76082153061813e-07,1.7635130038063272e-07,-7.252650834474581e-07,1.797684522608815e-07,-7.726301925249592e-07,1.3593814652780474e-07,1.28713440720985e-28,8.66262871593868e-30,-1.7918024758329104e-28,1.9633850833341234e-29,-4.7608215306193535e-07,-1.7635130038060178e-07,-7.252650834476241e-07,-1.797684522607695e-07,-7.726301925251186e-07,-1.3593814652760442e-07,-3.0106055763582786e-29,-3.568658720396775e-29,-2.2739766223848432e-29,-1.6603258665331888e-29,-4.741010514018535e-07,5.448590612379579e-08,-4.701818411901992e-07,1.6663000490694165e-08,-7.453102534678627e-07,2.7357217239441644e-08,-7.279540615613018e-07,3.4371113890668217e-09,-8.579330208754989e-07,-2.6008405171390205e-08,-8.357526525453042e-07,-2.5729239758795502e-08,-4.701818411901952e-07,-1.6663000490702818e-08,-4.741010514018457e-07,-5.448590612380402e-08,-7.279540615612966e-07,-3.4371113890835274e-09,-7.45310253467852e-07,-2.7357217239458564e-08,-8.357526525452993e-07,2.572923975877074e-08,-8.579330208754882e-07,2.6008405171364682e-08,0.0,-3.689838846534034e-21,0.0,-3.4057248282497575e-21,0.0,-2.389474304570763e-21,0.0,1.1849907150798524e-21,0.0,7.728930340233592e-21,0.0,-9.409753747161713e-21,0.0,-9.27355993916331e-21,0.0,-5.9005465375222355e-21,0.0,3.45820724462685e-21,0.0,2.0021147143626658e-20,0.0,-1.6042705688202718e-20,0.0,-1.541762360721681e-20,0.0,-8.827856096357078e-21,0.0,6.3984676397065826e-21,0.0,3.396409774956617e-20,-5.21059344905059e-07,1.0785416831218214e-07,-5.942832234061152e-07,1.1284412735292002e-07,-7.291198556954883e-07,1.5975182005082218e-07,-7.29419534669376e-07,1.4146009988497262e-07,-7.536819640264805e-07,1.388363757438669e-07,-7.212688685979149e-07,1.1197909398607218e-07,-5.94283223406162e-07,-1.1284412735287996e-07,-5.210593449051535e-07,-1.0785416831213956e-07,-7.294195346694393e-07,-1.4146009988486582e-07,-7.291198556956173e-07,-1.5975182005070884e-07,-7.212688685979762e-07,-1.1197909398589052e-07,-7.536819640266044e-07,-1.3883637574367513e-07,-2.8576578578864835e-07,1.301140611795876e-07,-6.228581335977658e-07,1.1144407150470386e-07,-8.014360278229913e-07,2.882237382538957e-08,-2.6588034168431343e-07,-2.345549761149889e-21,-6.148909793824232e-07,-5.981322827533954e-21,-7.85277352863385e-07,-1.0225807644204478e-20,3.1049565229499025e-27,-4.196740015775783e-28,-2.887230913108903e-28,-4.403551231441193e-28,4.812051521848172e-29,3.851635443793833e-28,-2.857657857886445e-07,-1.301140611795897e-07,-6.228581335977572e-07,-1.1144407150471579e-07,-8.01436027822981e-07,-2.8822373825410947e-08,-1.5635223141480454e-27,-9.802651538976083e-29,3.278505922098525e-27,-6.797558254135845e-28,4.1020767071492614e-27,5.932234007262009e-28,-4.410314084022777e-07,7.268022452197178e-21,-6.915240267186082e-07,2.9979998916103056e-20,-7.135613152026231e-07,5.968769864060137e-20,0.0,1.793662034335766e-43,0.0,1.793662034335766e-43,0.0,8.96831017167883e-43,0.0,-5.6519283938616335e-43,0.0,1.0761972206014595e-42,0.0,9.269247757898544e-43,-2.627131752301911e-07,1.3274214899302934e-07,-6.329945799890571e-07,1.9265484727832687e-07,-7.677771910976133e-07,1.6184720841148966e-07,1.5146129380243427e-28,-5.494056542378401e-29,1.0988346067719275e-50,3.891714187734575e-29,2.524354896707238e-28,1.6407579324035087e-28,-2.62713175230267e-07,-1.3274214899303003e-07,-6.329945799892127e-07,-1.9265484727825895e-07,-7.677771910977852e-07,-1.6184720841133102e-07,-1.5146129380243427e-28,6.686637000472881e-29,-1.5146129380243427e-28,5.412840523535707e-29,5.048709949123486e-29,-1.0255191767873153e-29,-4.801584184334589e-07,9.447106112382042e-08,-2.646155245804423e-07,4.165624981437424e-08,-4.7283844479037397e-07,3.112099903692373e-08,-2.656912190102633e-07,1.2633757629192664e-08,-4.6803908104000066e-07,8.091752496288301e-09,-7.484767456103177e-07,4.8063930505815753e-08,-6.342336387597463e-07,4.783223809223803e-08,-7.371756425756432e-07,1.2491484933343017e-08,-6.217198644652372e-07,1.3160740615455145e-08,-7.210619794360716e-07,-6.140998451021678e-11,-8.616398069136549e-07,-2.0279767975595878e-08,-8.174867338143947e-07,1.761743718501197e-09,-8.474965025861739e-07,-2.8360688201075687e-08,-7.969390370704656e-07,-1.0156396041453297e-08,-8.26809188564297e-07,-1.6608029814857525e-08,-4.6803908103999843e-07,-8.091752496296909e-09,-2.6569121901026077e-07,-1.2633757629197396e-08,-4.72838444790368e-07,-3.112099903693232e-08,-2.6461552458043755e-07,-4.165624981437841e-08,-4.801584184334501e-07,-9.447106112382803e-08,-7.210619794360687e-07,6.140998449395655e-11,-6.217198644652322e-07,-1.3160740615467643e-08,-7.37175642575635e-07,-1.2491484933360037e-08,-6.342336387597367e-07,-4.783223809225061e-08,-7.484767456103061e-07,-4.8063930505832595e-08,-8.268091885642944e-07,1.6608029814832955e-08,-7.969390370704601e-07,1.015639604143253e-08,-8.474965025861654e-07,2.836068820105083e-08,-8.174867338143834e-07,-1.7617437185225845e-09,-8.616398069136434e-07,2.02797679755703e-08,0.0,-3.435877556189529e-21,0.0,-1.3776771401529971e-21,0.0,-3.403994495899553e-21,0.0,-1.3185754926235634e-21,0.0,-2.7680254878980847e-21,0.0,-1.1103673324958778e-21,0.0,-9.900107724251277e-22,0.0,4.77602156134974e-22,0.0,3.959146546409973e-21,0.0,3.776411006916986e-21,0.0,1.2124392797414627e-20,0.0,-8.731709783191639e-21,0.0,-6.144329300702704e-21,0.0,-8.89968038381516e-21,0.0,-5.404653063609732e-21,0.0,-7.547524363424233e-21,0.0,-3.3206893791145496e-21,0.0,-1.6246546029348425e-21,0.0,1.9854969588545943e-21,0.0,1.1317236337409485e-20,0.0,1.3983874347413824e-20,0.0,3.098996503833694e-20,0.0,-1.407865292807831e-20,0.0,-1.1626000835692668e-20,0.0,-1.533412146384094e-20,0.0,-1.1018823571603408e-20,0.0,-1.2512374860235445e-20,0.0,-6.514267779823197e-21,0.0,-2.4719015385819347e-21,0.0,4.858859984935085e-21,0.0,1.881348220188166e-20,0.0,2.740874292245713e-20,0.0,5.211376231395407e-20,-4.864225626157067e-07,1.3296728230814142e-07,-3.076586015279749e-07,6.740802636874205e-08,-5.594534933091086e-07,1.1066583698276748e-07,-3.841186138586638e-07,7.559745482599735e-08,-6.098267681100678e-07,9.875238991849593e-08,-7.2970765755297e-07,1.669225383108583e-07,-6.573316628421653e-07,1.465581454371536e-07,-7.316181481946474e-07,1.5542337568784254e-07,-6.912676702186072e-07,1.3829023572925456e-07,-7.20589385417476e-07,9.666451163676767e-08,-7.723884127434406e-07,1.3857930563622999e-07,-7.569169347428396e-07,1.547516335925935e-07,-7.383025429990218e-07,1.3271074092312e-07,-7.350854918831709e-07,1.2994146610617741e-07,-7.0646090437235e-07,6.938656131041383e-08,-6.098267681100908e-07,-9.875238991845998e-08,-3.841186138586908e-07,-7.559745482597872e-08,-5.594534933091803e-07,-1.1066583698272561e-07,-3.0765860152803245e-07,-6.740802636872275e-08,-4.864225626158294e-07,-1.329672823081032e-07,-7.20589385417508e-07,-9.666451163666813e-08,-6.912676702186662e-07,-1.3829023572918171e-07,-7.316181481947439e-07,-1.5542337568773118e-07,-6.573316628422832e-07,-1.4655814543707692e-07,-7.297076575531353e-07,-1.6692253831074535e-07,-7.064609043723808e-07,-6.938656131024667e-08,-7.350854918832338e-07,-1.2994146610603196e-07,-7.383025429991161e-07,-1.3271074092293177e-07,-7.56916934742969e-07,-1.5475163359243975e-07,-7.723884127435972e-07,-1.3857930563603445e-07,-2.6225523866596743e-07,7.368618860781533e-08,-2.6483901297419715e-07,2.3043552983380804e-08,-2.6569368384400127e-07,6.351605004005378e-09,-6.372294401265312e-07,7.723333950374213e-08,-6.279151194946851e-07,2.6473214771574048e-08,-6.169026138715963e-07,5.559932643680484e-09,-8.206671947434617e-07,1.419786412636469e-08,-8.077626999789484e-07,-6.830966026358984e-09,-7.886512424652054e-07,-7.805683188152915e-09,-2.6569368384400005e-07,-6.351605004010108e-09,-2.648390129741935e-07,-2.3043552983385364e-08,-2.622552386659623e-07,-7.36861886078186e-08,-6.169026138715935e-07,-5.559932643692688e-09,-6.279151194946777e-07,-2.647321477158676e-08,-6.372294401265209e-07,-7.723333950375434e-08,-7.886512424652024e-07,7.805683188132495e-09,-8.077626999789395e-07,6.830966026337777e-09,-8.2066719474345e-07,-1.4197864126386033e-08,0.0,-1.528080794868089e-21,0.0,-1.5426894495622164e-21,0.0,-1.1495211961775125e-21,0.0,-4.441807280413718e-22,0.0,1.9784166326767865e-21,0.0,5.420802477152069e-21,0.0,-6.12858914756041e-21,0.0,-6.197208509921192e-21,0.0,-4.895012827081806e-21,0.0,-1.2104071985400557e-21,0.0,7.207223659623184e-21,0.0,2.1139789648778443e-20,0.0,-1.178112680978544e-20,0.0,-1.2361618534325795e-20,0.0,-9.332953007651742e-21,0.0,-2.4549106998298197e-21,0.0,1.5192320364423287e-20,0.0,4.128606459003346e-20,-2.6179012371741095e-07,8.492155525093568e-08,-3.431936650750607e-07,6.526689580555302e-08,-4.206987870183037e-07,7.275786337707596e-08,-6.39565352471141e-07,1.6214246375922057e-07,-6.76924119958337e-07,1.4588367240696607e-07,-6.94035042843604e-07,1.042901908413762e-07,-7.689004953903582e-07,1.574343097081281e-07,-7.476782438785353e-07,1.489103868358007e-07,-7.209785981316606e-07,8.394206942691553e-08,-4.2069878701831687e-07,-7.275786337705938e-08,-3.431936650751034e-07,-6.52668958055331e-08,-2.617901237174839e-07,-8.492155525092188e-08,-6.940350428436335e-07,-1.0429019084130907e-07,-6.769241199584262e-07,-1.458836724068901e-07,-6.39565352471292e-07,-1.6214246375914686e-07,-7.209785981316918e-07,-8.394206942678136e-08,-7.476782438786325e-07,-1.4891038683565012e-07,-7.68900495390525e-07,-1.574343097079712e-07],259,2) +arr2.setInfoOnComponents(['DRX','DRZ']) +f2z=MEDCouplingFieldDouble(ON_NODES) ; f2z.setName("SolutionDEPL") ; f2z.setArray(arr2) +f2z.setMesh(mz) +f2z.checkCoherency() +ff2z=MEDFileField1TS() +ff2z.setFieldNoProfileSBT(f2z) +# +mm2=MEDFileUMesh() +mm2.setMeshAtLevel(0,mz) +mm2.setFamilyFieldArr(0,DataArrayInt([-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-4,-4,-4,-4,-4,-4,-4,-4,-4,-5,-5,-5,-5,-5,-5,-5,-5,-5])) +mm2.setFamilyFieldArr(1,DataArrayInt([1,2,3,4,5,6,0,0,0,0,0,0,1,1,0,0,0,3,3,0,0,0,7,7,7,7,7,0,0,0,5,5,0,0,0,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,3,3,3,0,0,0,7,7,7,7,7,7,0,0,0,5,5,5,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])) +for famName,famId in [('FAMILLE_ZERO',0),('ba1_beam',-1),('ba2_beam',-2),('h1',6),('h1_h2_h3',4),('h2',5),('h3',7),('h3_h4_h5',2),('h4',3),('h5',1),('to1_beam',-4),('to2_beam',-5),('web_beam',-3)]: + mm2.setFamilyId(famName,famId) + pass +for grName,famsOnGrp in [('ba1',['ba1_beam']),('ba2',['ba2_beam']),('beam',['ba1_beam','ba2_beam','to1_beam','to2_beam','web_beam']),('h1',['h1','h1_h2_h3']),('h2',['h1_h2_h3','h2']),('h3',['h1_h2_h3','h3','h3_h4_h5']),('h4',['h3_h4_h5','h4']),('h5',['h3_h4_h5','h5']),('to1',['to1_beam']),('to2',['to2_beam']),('web',['web_beam'])]: + mm2.setFamiliesOnGroup(grName,famsOnGrp) + pass +# +mm2.write(fname,2) +ff0z.write(fname,0) +ff1z.write(fname,0) +ff2z.write(fname,0) +################### MED write is done -> Go to MEDReader +from paraview.simple import * + +myMedReader=MEDReader(FileName=fname) +keys=myMedReader.GetProperty("FieldsTreeInfo")[::2] +# list all the names of arrays that can be seen (including their spatial discretization) +arr_name_with_dis=[elt.split("/")[-1] for elt in keys] +# list all the names of arrays (Equal to those in the MED File) +arr_name=[elt.split(myMedReader.GetProperty("Separator").GetData())[0] for elt in arr_name_with_dis] +myMedReader.AllArrays=keys +RenderView1 = GetRenderView() +ELNOMesh1=ELNOMesh() +ELNOMesh1.Input=myMedReader +ExtractGroup1=ExtractGroup() +ExtractGroup1.Input=ELNOMesh1 +ExtractGroup1.UpdatePipelineInformation() +ExtractGroup1.AllGroups=['GRP_ba2','GRP_to1','GRP_web'] +# +DataRepresentation3 = Show() +DataRepresentation3.ScaleFactor = 0.008999999705702066 +DataRepresentation3.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation3.SelectionPointFieldDataArrayName = 'SolutionSIEF_ELNO' +a2_SolutionSIEQ_ELNO_PiecewiseFunction = CreatePiecewiseFunction(Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0]) +#VectorMode='Magnitude' or VectorMode='Component' +a2_SolutionSIEQ_ELNO_PVLookupTable = GetLookupTableForArray("SolutionSIEQ_ELNO",2,RGBPoints=[0.0, 0.23, 0.299, 0.754, 239013.7773476667, 0.706, 0.016, 0.15], VectorMode='Component', VectorComponent=1, NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 ) +DataRepresentation3.ScalarOpacityFunction = a2_SolutionSIEQ_ELNO_PiecewiseFunction +DataRepresentation3.ColorArrayName = 'SolutionSIEQ_ELNO' +DataRepresentation3.LookupTable = a2_SolutionSIEQ_ELNO_PVLookupTable +DataRepresentation3.Visibility = 1 +# +GaussPoints1=GaussPoints() +GaussPoints1.Input=ELNOMesh1 +GaussPoints1.SelectSourceArray=['CELLS','ELGA@0'] +DataRepresentation4 = Show() +DataRepresentation4.ScaleFactor = 0.008999999705702066 +DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation4.SelectionPointFieldDataArrayName = 'SolutionSIEF_ELGA' +DataRepresentation4.ColorArrayName = 'SolutionSIEF_ELGA' +######## +RenderView1.CameraViewUp = [-0.19545466285945437, 0.837274140321886, -0.5106559396646081] +RenderView1.CameraPosition = [0.11797550069274401, 0.20119836056342144, 0.20885419432082736] +RenderView1.CameraClippingRange = [0.14700465306315827, 0.40712447273162633] +RenderView1.CameraFocalPoint = [1.0170565790969026e-18, 0.0599999981932342, 0.022500000894069675] +RenderView1.ViewSize =[300,300] +WriteImage(outImgName) + diff --git a/src/Plugins/MEDReader/Test/testMEDReader1.py b/src/Plugins/MEDReader/Test/testMEDReader1.py new file mode 100644 index 00000000..bede0eb8 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader1.py @@ -0,0 +1,59 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +""" +This test focused on ELNO. Here a 2 QUAD4 cells and a single ELNO field +is defined. +""" +fname="testMEDReader1.med" +outImgName="testMEDReader1.png" + +coords=DataArrayDouble([(0,0,0),(2,1,0),(1,0,0),(1,1,0),(2,0,0),(0,1,0)]) +m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coords) +m.allocateCells() +m.insertNextCell(NORM_QUAD4,[0,5,3,2]) +m.insertNextCell(NORM_QUAD4,[4,2,3,1]) +m.finishInsertingCells() +MEDLoader.WriteMesh(fname,m,True) +# +f0=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f0.setMesh(m) ; f0.setTimeUnit("ms") +f0.setTime(1.1,1,1) +f0.setName("myELNOField") +arr=DataArrayDouble([7,5,3,1,5,3,1,7]) ; arr.setInfoOnComponent(0,"Comp0") +f0.setArray(arr) +MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f0) +# +f0.setTime(2.2,2,1) +arr=DataArrayDouble([1,7,5,3,7,5,3,1]) ; arr.setInfoOnComponent(0,"Comp0") +f0.setArray(arr) +MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f0) +# +f0.setTime(3.3,3,1) +arr=DataArrayDouble([3,1,7,5,1,7,5,3]) ; arr.setInfoOnComponent(0,"Comp0") +f0.setArray(arr) +MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f0) +# +f0.setTime(4.4,4,1) +arr=DataArrayDouble([5,3,1,7,3,1,7,5]) ; arr.setInfoOnComponent(0,"Comp0") +f0.setArray(arr) +MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f0) diff --git a/src/Plugins/MEDReader/Test/testMEDReader2.py b/src/Plugins/MEDReader/Test/testMEDReader2.py new file mode 100644 index 00000000..86074114 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader2.py @@ -0,0 +1,111 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +fname="testMEDReader2.med" +outImgName="testMEDReader2.png" + +""" This use case is a mesh containing a large number of orphan cells (cells having no field lying on them) +""" +######### +arrX=DataArrayDouble(7) ; arrX.iota() +arrY=DataArrayDouble(7) ; arrY.iota() +arrZ=DataArrayDouble(7) ; arrZ.iota() +m=MEDCouplingCMesh() +m.setCoords(arrX,arrY,arrZ) +m=m.buildUnstructured() ; m.setName("mesh") +tmp=m[3*36:4*36] +tmp=tmp.buildDescendingConnectivity()[0] +nodeIds=tmp.findNodesOnPlane([0.,0.,3.],[0.,0.,1.],1e-12) +cellIds=tmp.getCellIdsLyingOnNodes(nodeIds,True) +m1=tmp[cellIds] +mm=MEDFileUMesh() +mm.setMeshAtLevel(0,m) +mm.setMeshAtLevel(-1,m1) +mm.write(fname,2) +# +pfl=DataArrayInt([7,8,9,10,13,14,15,16,19,20,21,22,25,26,27,28]) ; pfl.setName("pfl") +f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName("ACellField") +arr=DataArrayDouble(16) ; arr.iota() +arr2=arr.deepCpy() ; arr2.reverse() +arr=DataArrayDouble.Meld(arr,arr2) ; arr.setInfoOnComponents(["aa","bbb"]) +f.setArray(arr) +f1ts=MEDFileField1TS() +f1ts.setFieldProfile(f,mm,-1,pfl) +f1ts.write(fname,0) + +################### MED write is done -> Go to MEDReader + +from paraview.simple import * + + + +testMEDReader1=MEDReader(FileName=fname) +testMEDReader1.AllArrays=['TS0/mesh/ComSup0/ACellField@@][@@P0'] +testMEDReader2=MEDReader(FileName=fname) +testMEDReader2.AllArrays=['TS0/mesh/ComSup1/mesh@@][@@P0'] +GroupDatasets1=GroupDatasets(Input=[testMEDReader1,testMEDReader2]) + +Clip1 = Clip(ClipType="Plane") +Clip1.Input=GroupDatasets1 +Clip1.Scalars=['FamilyIdCell'] +Clip1.ClipType.Origin=[3.0, 3.0, 3.0] +Clip1.InsideOut=1 +Clip1.ClipType.Normal=[0.9255623174457069, 0.0027407477590518157, 0.378585373233375] +Clip1.Scalars=['CELLS'] + +DataRepresentation4 = Show() +DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation4.SelectionCellFieldDataArrayName = 'ACellField' +DataRepresentation4.ScalarOpacityUnitDistance = 1.61104723630366 +DataRepresentation4.ExtractedBlockIndex = 2 +DataRepresentation4.ScaleFactor = 0.6000000000000001 +DataRepresentation4.Visibility = 1 +DataRepresentation4.Representation = 'Wireframe' + +ExtractBlock1 = ExtractBlock() +ExtractBlock1.BlockIndices=[1, 2] +ExtractBlock1.Input=Clip1 + +DataRepresentation5 = Show() +DataRepresentation5.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation5.SelectionCellFieldDataArrayName = 'FamilyIdCell' +DataRepresentation5.ScaleFactor = 0.6 +a2_ACellField_PVLookupTable=GetLookupTableForArray( "ACellField", 2, RGBPoints=[10.63014581273465, 0.23, 0.299, 0.754, 15.0, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 ) +a2_ACellField_PiecewiseFunction=CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] ) +a2_ACellField_PVLookupTable.ScalarOpacityFunction = a2_ACellField_PiecewiseFunction +DataRepresentation5.ScalarOpacityFunction = a2_ACellField_PiecewiseFunction +DataRepresentation5.ColorArrayName = 'ACellField' +DataRepresentation5.LookupTable = a2_ACellField_PVLookupTable +DataRepresentation5.ColorAttributeType = 'CELL_DATA' + +RenderView1 = GetRenderView() +RenderView1.CenterOfRotation = [3.0, 3.0, 3.0] +RenderView1.CameraViewUp = [-0.03886073885859842, 0.48373409998193495, 0.8743518533691291] +RenderView1.CameraPosition = [7.351939549758929, -5.688193007926853, 8.000155023042788] +RenderView1.CameraClippingRange = [0.026023957813772633, 26.023957813772633] +RenderView1.CameraFocalPoint = [2.9999999999999996, 2.9999999999999987, 2.9999999999999982] + +RenderView1.ViewSize =[300,300] +WriteImage(outImgName) + + diff --git a/src/Plugins/MEDReader/Test/testMEDReader3.py b/src/Plugins/MEDReader/Test/testMEDReader3.py new file mode 100644 index 00000000..fea2e7ba --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader3.py @@ -0,0 +1,121 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +fname="testMEDReader3.med" +outImgName="testMEDReader3.png" + +""" This test checks that invalid double time (not in [-1e299:1e299]) + leads MEDReader to takes iteration numbers instead of double time to discriminate timesteps each other + See EDF 1956. +""" +######### + +m=MEDCouplingUMesh("mesh",2) +coords=DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(1.,1.,0.),(0.,1.,0.)],4,3) +m.setCoords(coords) +m.allocateCells() +m.insertNextCell(NORM_QUAD4,[0,3,2,1]) +mm=MEDFileUMesh() +mm.setMeshAtLevel(0,m) +mm.write(fname,2) +fmts=MEDFileFieldMultiTS() +# +f=MEDCouplingFieldDouble(ON_NODES) ; f.setName("ANodeField") +f.setTime(1.7976931348623157e+308,1,1) ; f.setMesh(m) +arr=DataArrayDouble([0.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa") +f.setArray(arr) +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(f) +fmts.pushBackTimeStep(f1ts) +# +f.setTime(1.7976931348623157e+308,2,2) +arr=DataArrayDouble([1.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa") +f.setArray(arr) +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(f) +fmts.pushBackTimeStep(f1ts) +# +f.setTime(1.7976931348623157e+308,3,3) +arr=DataArrayDouble([2.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa") +f.setArray(arr) +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(f) +fmts.pushBackTimeStep(f1ts) +# +f.setTime(1.7976931348623157e+308,4,6) +arr=DataArrayDouble([3.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa") +f.setArray(arr) +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(f) +fmts.pushBackTimeStep(f1ts) +# +f.setTime(1.7976931348623157e+308,5,7) +arr=DataArrayDouble([4.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa") +f.setArray(arr) +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(f) +fmts.pushBackTimeStep(f1ts) +# +fmts.write(fname,0) + +################### MED write is done -> Go to MEDReader + +from paraview.simple import * + +AnimationScene1=GetAnimationScene() +AnimationScene1.PlayMode='Snap To TimeSteps' +AnimationScene1.EndTime = 2.0 +AnimationScene1.AnimationTime = 1.0 +AnimationScene1.StartTime = 1.0 + +testMEDReader3=MEDReader(FileName=fname) +testMEDReader3.AllArrays=['TS0/mesh/ComSup0/ANodeField@@][@@P1'] + +assert(list(testMEDReader3.TimestepValues)==[1.,2.,3.,4.,5.]) ## <- the test is here - double time steps are too big use dt. + +RenderView1=GetRenderView() +RenderView1.ViewTime=3.0 +RenderView1.CameraPosition=[0.5,0.5,5.7320508075688776] +RenderView1.CameraClippingRange=[2.704730299493189,2.7730315696824106] +RenderView1.ViewSize=[300,300] + +DataRepresentation2=Show() +DataRepresentation2.EdgeColor=[0.0, 0.0, 0.5000076295109483] +DataRepresentation2.SelectionPointFieldDataArrayName='ANodeField' +DataRepresentation2.SelectionCellFieldDataArrayName='FamilyIdCell' +DataRepresentation2.ScalarOpacityUnitDistance=1.4142135623730951 +DataRepresentation2.ExtractedBlockIndex=1 +DataRepresentation2.ScaleFactor=0.1 + +a1_ANodeField_PVLookupTable=GetLookupTableForArray("ANodeField",1,RGBPoints=[0.0,0.23,0.299,0.754,4.0,0.706,0.016,0.15],VectorMode='Magnitude',NanColor=[0.25,0.0,0.0], + ColorSpace='Diverging',ScalarRangeInitialized=1.0,AllowDuplicateScalars=1) +a1_ANodeField_PiecewiseFunction=CreatePiecewiseFunction(Points=[0.0,0.0,0.5,0.0,1.0,1.0,0.5,0.0]) +a1_ANodeField_PVLookupTable.ScalarOpacityFunction=a1_ANodeField_PiecewiseFunction + +DataRepresentation2.ScalarOpacityFunction=a1_ANodeField_PiecewiseFunction +DataRepresentation2.ColorArrayName='ANodeField' +DataRepresentation2.LookupTable=a1_ANodeField_PVLookupTable +### +WriteImage(outImgName) + + diff --git a/src/Plugins/MEDReader/Test/testMEDReader4.py b/src/Plugins/MEDReader/Test/testMEDReader4.py new file mode 100644 index 00000000..488a4e9b --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader4.py @@ -0,0 +1,95 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +""" This test checks that umeshes with no names work properly. +""" + +fname="testMEDReader4.med" +outImgName="testMEDReader4.png" +######### +coords=DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(2.,0.,0.),(3.,0.,0.),(0.,1.,0.),(1.,1.,0.),(2.,1.,0.),(3.,1.,0.),(0.,2.,0.),(1.,2.,0.),(2.,2.,0.),(3.,2.,0.),(0.,3.,0.),(1.,3.,0.),(2.,3.,0.),(3.,3.,0.)]) +m0=MEDCouplingUMesh("mesh",2) +m0.allocateCells() +m0.setCoords(coords) +## +mm=MEDFileUMesh() +mm.setMeshAtLevel(0,m0) +mm.setFamilyFieldArr(1,DataArrayInt([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])) +# +f1ts0=MEDFileField1TS() +f1ts1=MEDFileField1TS() +# +f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m0) ; f0.setName("f0NoPfl") +arr0=DataArrayDouble([0.,1.,2.,3.,1.,1.5,2.2,3.1,2.,2.2,3.,3.1,3.,3.1,3.5,4.]) +f0.setArray(arr0) +f0.checkCoherency() +f1ts0.setFieldNoProfileSBT(f0) +# +pfl1=DataArrayInt([0,1,2,3,4,5,6,8,9,12]) ; pfl1.setName("pfl1") +f1=MEDCouplingFieldDouble(ON_NODES) ; f1.setName("f1Pfl") +arr1=DataArrayDouble([3.,2.,1.,0.,2.,1.5,0.,1.,0.,0.2]) +f1.setArray(arr1) +f1ts1.setFieldProfile(f1,mm,0,pfl1) +# +fs=MEDFileFields() +fmts0=MEDFileFieldMultiTS() +fmts0.pushBackTimeStep(f1ts0) +fmts1=MEDFileFieldMultiTS() +fmts1.pushBackTimeStep(f1ts1) +fs.pushField(fmts0) ; fs.pushField(fmts1) +mm.write(fname,2) +fs.write(fname,0) +################### MED write is done -> Go to MEDReader + +from paraview.simple import * + +testMEDReader4_med=MEDReader(FileName=fname) + +testMEDReader4_med.AllArrays=['TS0/mesh/ComSup0/f0NoPfl@@][@@P1','TS0/mesh/ComSup0/mesh@@][@@P1'] +#testMEDReader4_med.AllTimeSteps=['0000'] + +Glyph1=Glyph(GlyphType="Sphere",GlyphTransform="Transform2" ) +Glyph1.Scalars=['POINTS','f0NoPfl'] +Glyph1.SetScaleFactor=0.3 +Glyph1.Vectors=['POINTS', ''] +Glyph1.GlyphTransform="Transform2" + +DataRepresentation1 = Show() +DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation1.SelectionPointFieldDataArrayName = 'f0NoPfl' +DataRepresentation1.ScaleFactor = 0.3 +DataRepresentation1.ColorArrayName = 'f0NoPfl' +lookupTable = GetLookupTableForArray( "f0NoPfl", 1, RGBPoints=[0.0, 0.23, 0.299, 0.754, 4.0, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 ) +function=CreatePiecewiseFunction(Points=[0.0,0.0,0.5,0.0,1.0,1.0,0.5,0.0] ) +lookupTable.ScalarOpacityFunction = function +DataRepresentation1.LookupTable = lookupTable + +RenderView1 = GetRenderView() +RenderView1.CameraViewUp = [0.06254683966704512, 0.9980420295997885, 0.0] +RenderView1.CameraPosition = [0.8087292125440382, 1.3325993334207897, 12.692130429902462] +RenderView1.CameraClippingRange = [6.326709113742113, 7.168262401281963] +RenderView1.CameraFocalPoint = [0.8087292125440382, 1.3325993334207897, 0.0] +RenderView1.CameraParallelScale = 3.712804729456109 + +RenderView1.ViewSize =[300,300] +WriteImage(outImgName) diff --git a/src/Plugins/MEDReader/Test/testMEDReader5.py b/src/Plugins/MEDReader/Test/testMEDReader5.py new file mode 100644 index 00000000..9fbf6eb9 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader5.py @@ -0,0 +1,115 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +""" This test is CEA specific one. It generates a .sauv file +that is then read by MEDReader +""" + +fname="testMEDReader5.sauv" +outImgName="testMEDReader5.png" +######### +arr=DataArrayDouble(5) ; arr.iota() +c=MEDCouplingCMesh("mesh") +c.setCoords(arr,arr,arr) +m=c.buildUnstructured() +mbis=m.deepCpy() ; mbis.translate([5,0,0]) ; mbis.tetrahedrize(PLANAR_FACE_5) +m=MEDCouplingUMesh.MergeUMeshes([mbis,m]) ; m.setName(c.getName()) +mm=MEDFileUMesh() +mm.setMeshAtLevel(0,m) +grp0=DataArrayInt.Range(0,m.getNumberOfCells(),2) ; grp0.setName("grp0") +grp1=DataArrayInt.Range(1,m.getNumberOfCells(),2) ; grp1.setName("grp1") +grp2=DataArrayInt.Range(0,m.getNumberOfNodes(),7) ; grp2.setName("grp2") +mm.setGroupsAtLevel(0,[grp0,grp1]) +mm.setGroupsAtLevel(1,[grp2]) +ms=MEDFileMeshes() +ms.pushMesh(mm) +f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName("fCell") ; f.setMesh(m[:10]) +arr=DataArrayDouble(f.getNumberOfTuplesExpected()) ; arr.iota() ; f.setArray(arr) +f2=MEDCouplingFieldDouble(ON_NODES) ; f2.setName("fNode") ; f2.setMesh(m) +arr=DataArrayDouble(f2.getNumberOfTuplesExpected()) ; arr.iota() ; f2.setArray(arr) + +fs=MEDFileFields() +f1ts=MEDFileField1TS() +#f1ts.setFieldNoProfileSBT(f) +pfl=DataArrayInt(10); pfl.iota() ; pfl.setName("pfl") ; f1ts.setFieldProfile(f,mm,0,pfl) +fmts=MEDFileFieldMultiTS() +fmts.pushBackTimeStep(f1ts) +fs.pushField(fmts) +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(f2) +fmts=MEDFileFieldMultiTS() +fmts.pushBackTimeStep(f1ts) +fs.pushField(fmts) + +mfd=MEDFileData() +mfd.setMeshes(ms) +mfd.setFields(fs) +#mfd.write(fname,2) not activated because useless +# +sw=SauvWriter(); +sw.setMEDFileDS(mfd); +sw.write(fname); +del mm,m,c,f,arr +del f1ts +################### MED write is done -> Go to MEDReader +from paraview.simple import * + +myMedReader=MEDReader(FileName=fname) +myMedReader.AllArrays = ['TS0/mesh/ComSup1/fNode@@][@@P1'] +myMedReader.AllTimeSteps = ['0000'] + +Clip1=Clip(ClipType="Plane") +Clip1.Input=myMedReader +Clip1.Scalars = ['POINTS', 'FamilyIdNode'] +Clip1.ClipType.Origin = [2.0, 2.0, 2.0] +Clip1.ClipType = "Plane" +Clip1.ClipType.Normal = [0.04207410474474753, 0.9319448861971525, 0.3601506612529047] +Clip1.InsideOut = 1 + +DataRepresentation2 = Show() +DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation2.ScalarOpacityUnitDistance = 1.5768745057161244 +DataRepresentation2.ExtractedBlockIndex = 1 +DataRepresentation2.ScaleFactor = 0.4 + +RenderView1=GetRenderView() +RenderView1.CenterOfRotation=[2.,2.,2.] +RenderView1.CameraViewUp=[0.24562884954787187,0.6907950752417243,-0.680050463047831] +RenderView1.CameraPosition=[-2.5085697461776486,11.6185941755061,10.14210560568201] +RenderView1.CameraClippingRange=[5.269050059274764,23.64024625330183] +RenderView1.CameraFocalPoint=[2.,2.,2.] +RenderView1.CameraParallelScale=5.071791174723188 + +LookupTable=GetLookupTableForArray("fNode",1,RGBPoints=[0.0,0.23,0.299,0.754,55.0,0.706,0.016,0.15],VectorMode='Magnitude',NanColor=[0.25,0.0,0.0],ColorSpace='Diverging',ScalarRangeInitialized=1.0,AllowDuplicateScalars=1) +DataRepresentation2 = Show() +DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation2.ScalarOpacityUnitDistance = 1.5768745057161244 +DataRepresentation2.ExtractedBlockIndex = 1 +DataRepresentation2.ScaleFactor = 0.4 +DataRepresentation2.ColorArrayName='fNode' +DataRepresentation2.LookupTable=LookupTable +DataRepresentation2.ColorAttributeType='POINT_DATA' + + +RenderView1.ViewSize=[300,300] +WriteImage(outImgName) diff --git a/src/Plugins/MEDReader/Test/testMEDReader6.py b/src/Plugins/MEDReader/Test/testMEDReader6.py new file mode 100644 index 00000000..2154fe49 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader6.py @@ -0,0 +1,99 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +""" This test generate a GaussPoint field on a mesh with groups. +The aim of this test is to check that the ExtractGroup works well for GaussPoints +""" + +fname="testMEDReader6.med" +outImgName="testMEDReader6.png" +######### +arr=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0),(3,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(0,3,0),(1,3,0),(2,3,0),(3,3,0)]) +m0=MEDCouplingUMesh("mesh",2) ; m0.setCoords(arr) ; m0.allocateCells() +for elt in [[2,3,6],[3,7,6],[6,9,5],[6,10,9]]: + m0.insertNextCell(NORM_TRI3,elt) + pass +for elt in [[0,4,5,1],[5,6,2,1],[4,8,9,5],[6,10,11,7],[8,12,13,9],[9,13,14,10],[10,14,15,11]]: + m0.insertNextCell(NORM_QUAD4,elt) + pass +mm=MEDFileUMesh() +mm.setMeshAtLevel(0,m0) +grp0=DataArrayInt([0,1,4,5,7,10]) ; grp0.setName("grp0") +mm.setGroupsAtLevel(0,[grp0]) +# +fGauss=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fGauss.setName("fGauss") +fGauss.setMesh(m0) +fGauss.setGaussLocalizationOnType(NORM_TRI3,[0.,0.,1.,0.,0.,1.],[0.1,0.1,0.05,0.9],[0.4,0.6]) +fGauss.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.9,-0.9,0.,0.,0.9,0.9],[0.2,0.3,0.5]) +fGauss.setArray(DataArrayDouble([0.9,1.3,0.22,1.3,1.62,2.21,1.62,2.72,2.95,2.54,2.25,2.16,1.58,1.05,3.13,2.91,2.82,1.41,1.58,1.95,3.59,3.53,3.59,2.82,2.91,3.13,2.25,2.54,2.95])) +fGauss.getArray().setInfoOnComponent(0,"C0") +fGauss.checkCoherency() +# +f1ts=MEDFileField1TS() +f1ts.setFieldNoProfileSBT(fGauss) +# +mm.write(fname,2) +f1ts.write(fname,0) +################### MED write is done -> Go to MEDReader +from paraview.simple import * + +myMedReader=MEDReader(FileName=fname) +myMedReader.AllArrays = ['TS0/mesh/ComSup0/fGauss@@][@@GAUSS'] +myMedReader.AllTimeSteps = ['0000'] + +ExtractGroup1 = ExtractGroup(Input=myMedReader) +ExtractGroup1.UpdatePipelineInformation() +ExtractGroup1.AllGroups = ['GRP_grp0'] + +GaussPoints1 = GaussPoints(Input=ExtractGroup1) +GaussPoints1.SelectSourceArray = ['CELLS','ELGA@0'] + +Glyph1 = Glyph( Input=GaussPoints1, GlyphType="Sphere", GlyphTransform="Transform2" ) +Glyph1.GlyphType = "Sphere" +Glyph1.Vectors = ['POINTS', ''] +Glyph1.SetScaleFactor = 0.29 + +RenderView1 = GetRenderView() +RenderView1.CameraFocalPoint = [1.5, 1.5, 0.0] +RenderView1.CameraPosition = [1.5, 1.5, 10000.0] +RenderView1.InteractionMode = '3D' +RenderView1.CameraPosition = [1.5, 1.5, 8.196152422706632] +RenderView1.CameraClippingRange = [7.825640906782493, 8.682319698595558] +RenderView1.CameraParallelScale = 2.1213203435596424 +RenderView1.CenterOfRotation = [1.5, 1.5, 0.0] + +DataRepresentation4 = Show() +DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation4.SelectionPointFieldDataArrayName = 'fGauss' +DataRepresentation4.ScaleFactor = 0.3182729169726372 + +a1_fGauss_PVLookupTable = GetLookupTableForArray( "fGauss", 1, RGBPoints=[0.22, 0.23, 0.299, 0.754, 2.95, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 ) +a1_fGauss_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] ) +DataRepresentation4.ColorArrayName = 'fGauss' +DataRepresentation4.LookupTable = a1_fGauss_PVLookupTable +a1_fGauss_PVLookupTable.ScalarOpacityFunction = a1_fGauss_PiecewiseFunction + + +RenderView1.ViewSize=[300,300] +WriteImage(outImgName) + diff --git a/src/Plugins/MEDReader/Test/testMEDReader7.py b/src/Plugins/MEDReader/Test/testMEDReader7.py new file mode 100644 index 00000000..a3b235c3 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader7.py @@ -0,0 +1,98 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony Geay + +from MEDLoader import * + +""" This test generate a simple multi time field with a very aggressive time steps triplets. Neither dt, nor iteration nor order is considered. +In this case only the rank is considered. +""" + +fname="testMEDReader7.med" +outImgName="testMEDReader7.png" +######### +arr=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0),(3,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(0,3,0),(1,3,0),(2,3,0),(3,3,0)]) +m0=MEDCouplingUMesh("mesh",2) ; m0.setCoords(arr) ; m0.allocateCells() +for elt in [[2,3,6],[3,7,6],[6,9,5],[6,10,9]]: + m0.insertNextCell(NORM_TRI3,elt) + pass +for elt in [[0,4,5,1],[5,6,2,1],[4,8,9,5],[6,10,11,7],[8,12,13,9],[9,13,14,10],[10,14,15,11]]: + m0.insertNextCell(NORM_QUAD4,elt) + pass +mm=MEDFileUMesh() +mm.setMeshAtLevel(0,m0) +grp0=DataArrayInt([0,1,4,5,7,10]) ; grp0.setName("grp0") +mm.setGroupsAtLevel(0,[grp0]) +fmts=MEDFileFieldMultiTS() +# +fNode=MEDCouplingFieldDouble(ON_NODES) ; fNode.setName("fNode") +fNode.setMesh(m0) +fNode.setArray(DataArrayDouble([3,2,1,0,3.16,2.23,1.41,1,3.6,2.82,2.23,2,4.24,3.6,3.16,3])) +fNode.getArray().setInfoOnComponent(0,"C0") +fNode.setTime(0.5,1,1) +f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts) +# +fNode.getArray().reverse() +fNode.setTime(0.5,1,2) +f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts) +# +fNode.getArray().reverse() +fNode.setTime(0.5,2,1) +f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts) +# +fNode.getArray().reverse() +fNode.setTime(0.5,2,2) +f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts) +# +mm.write(fname,2) +fmts.write(fname,0) +################### MED write is done -> Go to MEDReader +from paraview.simple import * + + +myMedReader=MEDReader(FileName=fname) +myMedReader.AllArrays = ['TS0/mesh/ComSup0/fNode@@][@@P1'] +assert(list(myMedReader.TimestepValues)==[0.,1.,2.,3.]) + +RenderView1 = GetRenderView() +RenderView1.CameraFocalPoint = [1.5, 1.5, 0.0] +RenderView1.CameraPosition = [1.5, 1.5, 10000.0] +RenderView1.InteractionMode = '3D' +RenderView1.CameraPosition = [1.5, 1.5, 8.196152422706632] +RenderView1.CameraClippingRange = [7.825640906782493, 8.682319698595558] +RenderView1.CameraParallelScale = 2.1213203435596424 +RenderView1.CenterOfRotation = [1.5, 1.5, 0.0] + +DataRepresentation4 = Show() +DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483] +DataRepresentation4.SelectionPointFieldDataArrayName = 'fNode' +DataRepresentation4.ScaleFactor = 0.3182729169726372 + +a1_fGauss_PVLookupTable = GetLookupTableForArray( "fNode", 1, RGBPoints=[0.22, 0.23, 0.299, 0.754, 2.95, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 ) +a1_fGauss_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] ) +DataRepresentation4.ColorArrayName = 'fNode' +DataRepresentation4.LookupTable = a1_fGauss_PVLookupTable +a1_fGauss_PVLookupTable.ScalarOpacityFunction = a1_fGauss_PiecewiseFunction + +RenderView1.ViewTime = 1.0 #### Important # red is in right bottom +RenderView1.CacheKey = 1.0 +RenderView1.UseCache = 1 +RenderView1.ViewSize=[300,300] +WriteImage(outImgName) diff --git a/src/Plugins/MedReader/plugin.cmake b/src/Plugins/MEDReader/plugin.cmake similarity index 74% rename from src/Plugins/MedReader/plugin.cmake rename to src/Plugins/MEDReader/plugin.cmake index 7d1291e9..db151042 100644 --- a/src/Plugins/MedReader/plugin.cmake +++ b/src/Plugins/MEDReader/plugin.cmake @@ -1,5 +1,5 @@ -pv_plugin(MedReader +pv_plugin(MEDReader # provide a description for the plugin. DESCRIPTION "Reads the MED data format from Electricite de France" - PLUGIN_NAMES MedReader + PLUGIN_NAMES MEDReader DEFAULT_ENABLED) diff --git a/src/Plugins/MedReader/CMakeLists.txt b/src/Plugins/MedReader/CMakeLists.txt deleted file mode 100644 index 8d71a8fd..00000000 --- a/src/Plugins/MedReader/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -project(MedReader) - -cmake_minimum_required(VERSION 2.8) - -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -SET(MED_READER_MAJOR_VERSION 3) -SET(MED_READER_MINOR_VERSION 1) -SET(MED_READER_BUILD_VERSION 0) -SET(MED_READER_VERSION - "${MED_READER_MAJOR_VERSION}.${MED_READER_MINOR_VERSION}.${MED_READER_BUILD_VERSION}") - -# -# Load the ParaView/VTK packages -# -set(MedReader_BUILD_ParaView_Plugin ON CACHE BOOL "Build the ParaView plugin") - -if(MedReader_BUILD_ParaView_Plugin) - FIND_PACKAGE(ParaView REQUIRED) - if(NOT ParaView_FOUND) - MESSAGE(FATAL_ERROR "Please locate ParaView." ) - ENDIF(NOT ParaView_FOUND) - INCLUDE(${PARAVIEW_USE_FILE}) - # Load information about VTK/ParaView modules loaded/available. - pv_setup_module_environment("vtkMedReader") -else(MedReader_BUILD_ParaView_Plugin) - FIND_PACKAGE(VTK REQUIRED) - if(NOT VTK_FOUND) - MESSAGE(FATAL_ERROR "Please locate VTK." ) - ENDIF(NOT VTK_FOUND) - INCLUDE(${VTK_USE_FILE}) -endif(MedReader_BUILD_ParaView_Plugin) - - -# Standard CMake option for building libraries shared or static by default. -OPTION(BUILD_SHARED_LIBS - "Build with shared libraries." - ${VTK_BUILD_SHARED_LIBS}) -# -# Find dependant Library -# -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) -FIND_PACKAGE(MED REQUIRED) -include_directories(${MED_INCLUDE_DIRS}) -include_directories(${MEDFILE_INCLUDE_DIRS}) - -# -# process all vtk-modules defined in this plugin. This generates the necessary -# wrappings for all these modules as well. -# -SET(VTK_INSTALL_RUNTIME_DIR lib/salome) -SET(VTK_INSTALL_LIBRARY_DIR lib/salome) -SET(VTK_INSTALL_ARCHIVE_DIR lib/salome) - -pv_process_modules() - -# -# Build the vtkMedReader -# -# add_subdirectory(IO) - -# -# Build the parallel vtkPMedReader -# -set(MedReader_BUILD_PARALLEL ${VTK_USE_PARALLEL} CACHE BOOL "Build the Med Reader with parallel support.") -# MESSAGE(${MedReader_BUILD_PARALLEL}) - -# -# Build the ParaView Plugin -# -if(MedReader_BUILD_ParaView_Plugin) - add_subdirectory(ParaViewPlugin) -endif(MedReader_BUILD_ParaView_Plugin) - - - diff --git a/src/Plugins/MedReader/IO/CMakeLists.txt b/src/Plugins/MedReader/IO/CMakeLists.txt deleted file mode 100644 index d42e72a7..00000000 --- a/src/Plugins/MedReader/IO/CMakeLists.txt +++ /dev/null @@ -1,125 +0,0 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -set(MedReader_CLASSES - vtkMedReader - vtkMedDriver - vtkMedDriver30 - vtkMedFactory - vtkMedFile - vtkMedMesh - vtkMedGrid - vtkMedRegularGrid - vtkMedPolarGrid - vtkMedCartesianGrid - vtkMedCurvilinearGrid - vtkMedUnstructuredGrid - vtkMedFamily - vtkMedGroup - vtkMedField - vtkMedEntityArray - vtkMedProfile - vtkMedLocalization - vtkMedFieldOverEntity - vtkMedFieldStep - vtkMedUtilities - #vtkMedString - vtkMedIntArrayInternal - vtkMedIntArray - vtkMedFamilyOnEntity - vtkMedInterpolation - vtkMedFraction - vtkMedFilter - vtkMedFieldOnProfile - vtkExtractGroup - vtkMedSelection - vtkMedLink - vtkMedFamilyOnEntityOnProfile - vtkMedConstantAttribute - vtkMedVariableAttribute - vtkMedStructElement - vtkGenerateStructElement -) - -set(MedReader_SRCS) -set(MedReader_HDRS) - -foreach(class ${MedReader_CLASSES}) - set(MedReader_SRCS ${MedReader_SRCS} ${class}.cxx) - set(MedReader_HDRS ${MedReader_HDRS} ${class}.h) -endforeach(class) - -set_source_files_properties( - vtkMedGrid - vtkMedRegularGrid - vtkMedUtilities - PROPERTIES ABSTRACT 1 -) - -set_source_files_properties( - vtkMedIntArrayInternal - vtkMedUtilities - PROPERTIES WRAP_EXCLUDE 1 -) - -# this adds target_link_libraries dependencies on all modules listed under -# DEPENDS in module.cmake -vtk_module_library(vtkMedReader ${MedReader_SRCS}) - -# Introducing selection for parallel compilation -# CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/IO/config.h.cmake ${PROJECT_SOURCE_DIR}/IO/config.h ) -CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) - -target_link_libraries(vtkMedReader ${MEDFILE_LIBRARIES}) - -#set(MedReader_BUILD_Testing ${VTK_BUILD_TESTING} CACHE BOOL "Build tests for the MedReader filter") - -#if(MedReader_BUILD_Testing) -# add_subdirectory(Testing) -#endif(MedReader_BUILD_Testing) - -install( - TARGETS vtkMedReader - RUNTIME DESTINATION lib/salome - LIBRARY DESTINATION lib/salome - ARCHIVE DESTINATION lib/salome - ) - -install(FILES ${MedReader_HDRS} DESTINATION include) - -# ----------------------------------------------------------------------------- -# This make it easy for other projects to get the list of files etc. in this -# kit. -# ----------------------------------------------------------------------------- -# needed by vtkExportKit.cmake - -#include(${ParaView_CMAKE_DIR}/VTKMono/vtkExportKit.cmake) - -# #include(${VTK_CMAKE_DIR}/vtkExportKit.cmake) -#IF(NOT VTK_INSTALL_NO_DEVELOPMENT) -# STRING(REGEX REPLACE "^/" "" VTK_INSTALL_PACKAGE_DIR_CM24 "${VTK_INSTALL_PACKAGE_DIR}") -#ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT) - -#set(VTK_INSTALL_PACKAGE_DIR_CM24 ${VTK_MODULES_DIR}) -#vtk_export_kit2( -# "MedReader_IO" -# "MEDREADER_IO" -# ${CMAKE_CURRENT_BINARY_DIR} -# "${MedReader_SRCS}" -#) diff --git a/src/Plugins/MedReader/IO/Testing/Cxx/CMakeLists.txt b/src/Plugins/MedReader/IO/Testing/Cxx/CMakeLists.txt deleted file mode 100644 index 3240b822..00000000 --- a/src/Plugins/MedReader/IO/Testing/Cxx/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/../..) - -set(TestMedReader_SRCS - TestMedReader.cxx -) - -set(TestMedPolyhedron_SRCS - TestMedPolyhedron.cxx -) - -set(TestMedReadPolyhedron_SRCS - TestMedReadPolyhedron.cxx -) - -set(TestMedDescendingPolyhedron_SRCS - TestMedDescendingPolyhedron.cxx -) - -set(TestMedReadDescendingPolyhedron_SRCS - TestMedReadDescendingPolyhedron.cxx -) - -set(TestMedWriteOcta12_SRCS - TestMedWriteOcta12.cxx -) - -set(TestMedParallelRead_SRCS - TestMedParallelRead.cxx -) - -set(TestMedParallelWrite_SRCS - TestMedParallelWrite.cxx -) - -add_executable(TestMedReader ${TestMedReader_SRCS}) -add_executable(TestMedPolyhedron ${TestMedPolyhedron_SRCS}) -add_executable(TestMedReadPolyhedron ${TestMedReadPolyhedron_SRCS}) -add_executable(TestMedDescendingPolyhedron ${TestMedDescendingPolyhedron_SRCS}) -add_executable(TestMedReadDescendingPolyhedron ${TestMedReadDescendingPolyhedron_SRCS}) -add_executable(TestMedWriteOcta12 ${TestMedWriteOcta12_SRCS}) - -if(${HDF5_IS_PARALLEL}) - add_executable(TestMedParallelRead ${TestMedParallelRead_SRCS}) - add_executable(TestMedParallelWrite ${TestMedParallelWrite_SRCS}) - target_link_libraries(TestMedParallelRead vtkParallelCore ${MEDFILE_LIBRARIES}) - target_link_libraries(TestMedParallelWrite vtkParallelCore ${MEDFILE_LIBRARIES}) -endif(${HDF5_IS_PARALLEL}) - -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../module.cmake) - -target_link_libraries(TestMedReader ${${vtk-module-test}_DEPENDS} ${MEDFILE_LIBRARIES}) -target_link_libraries(TestMedPolyhedron ${MEDFILE_LIBRARIES}) -target_link_libraries(TestMedReadPolyhedron ${MEDFILE_LIBRARIES}) -target_link_libraries(TestMedDescendingPolyhedron ${MEDFILE_LIBRARIES}) -target_link_libraries(TestMedReadDescendingPolyhedron ${MEDFILE_LIBRARIES}) -target_link_libraries(TestMedWriteOcta12 ${MEDFILE_LIBRARIES}) - diff --git a/src/Plugins/MedReader/IO/vtkExtractGroup.cxx b/src/Plugins/MedReader/IO/vtkExtractGroup.cxx deleted file mode 100644 index 19739281..00000000 --- a/src/Plugins/MedReader/IO/vtkExtractGroup.cxx +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkExtractGroup.h" - -#include "vtkObjectFactory.h" -#include "vtkMutableDirectedGraph.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformationVector.h" -#include "vtkInformation.h" -#include "vtkDataArraySelection.h" -#include "vtkMedUtilities.h" -#include "vtkTimeStamp.h" -#include "vtkInEdgeIterator.h" -#include "vtkMedReader.h" -#include "vtkInformationDataObjectKey.h" -#include "vtkExecutive.h" -#include "vtkVariantArray.h" -#include "vtkStringArray.h" -#include "vtkUnsignedCharArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkDemandDrivenPipeline.h" -//#include "vtkCompositeDataIterator.h" -#include "vtkDataObjectTreeIterator.h" - -#include -#include -//#include -//#include - -// vtkCxxRevisionMacro(vtkExtractGroup, "$Revision$"); -vtkStandardNewMacro(vtkExtractGroup); - -vtkCxxSetObjectMacro(vtkExtractGroup, SIL, vtkMutableDirectedGraph); - -vtkExtractGroup::vtkExtractGroup() -{ - this->SIL=NULL; - this->Entities=vtkDataArraySelection::New(); - this->Families=vtkDataArraySelection::New(); - this->Groups=vtkDataArraySelection::New(); - this->PruneOutput=0; -} - -vtkExtractGroup::~vtkExtractGroup() -{ - this->Entities->Delete(); - this->Families->Delete(); - this->Groups->Delete(); -} - -int vtkExtractGroup::ModifyRequest(vtkInformation* request, int when) -{ - request->Set(vtkDemandDrivenPipeline::REQUEST_REGENERATE_INFORMATION(), 1); - return this->Superclass::ModifyRequest(request, when); -} - -int vtkExtractGroup::RequestInformation(vtkInformation *request, - vtkInformationVector **inputVector, vtkInformationVector *outputVector) -{ - vtkInformation* outInfo=outputVector->GetInformationObject(0); - - vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); - - vtkMutableDirectedGraph* old_SIL=this->GetSIL(); - - if(inputInfo->Has(vtkDataObject::SIL())) - { - this->SetSIL(vtkMutableDirectedGraph::SafeDownCast(inputInfo->Get( - vtkDataObject::SIL()))); - } - else - { - vtkMutableDirectedGraph* sil=vtkMutableDirectedGraph::New(); - this->BuildDefaultSIL(sil); - this->SetSIL(sil); - sil->Delete(); - } - - if(this->GetSIL()!=old_SIL||this->GetSIL()->GetMTime()>this->SILTime) - { - this->ClearSelections(); - this->SILTime.Modified(); - outInfo->Set(vtkDataObject::SIL(), this->GetSIL()); - } - - return 1; -} - -vtkIdType vtkExtractGroup::FindVertex(const char* name) -{ - vtkStringArray* names=vtkStringArray::SafeDownCast( - this->GetSIL()->GetVertexData()->GetAbstractArray("Names")); - - return names->LookupValue(name); -} - -void vtkExtractGroup::ClearSelections() -{ - this->Families->RemoveAllArrays(); - this->Entities->RemoveAllArrays(); - this->Groups->RemoveAllArrays(); -} - -void vtkExtractGroup::BuildDefaultSIL(vtkMutableDirectedGraph* sil) -{ - sil->Initialize(); - - vtkSmartPointer childEdge= - vtkSmartPointer::New(); - childEdge->InsertNextValue(0); - - vtkSmartPointer crossEdge= - vtkSmartPointer::New(); - crossEdge->InsertNextValue(1); - - // CrossEdge is an edge linking hierarchies. - vtkUnsignedCharArray* crossEdgesArray=vtkUnsignedCharArray::New(); - crossEdgesArray->SetName("CrossEdges"); - sil->GetEdgeData()->AddArray(crossEdgesArray); - crossEdgesArray->Delete(); - std::deque names; - - // Now build the hierarchy. - vtkIdType rootId=sil->AddVertex(); - names.push_back("SIL"); - - // Add a global entry to encode global names for the families - vtkIdType globalFamilyRoot=sil->AddChild(rootId, childEdge); - names.push_back("Families"); - - // Add a global entry to encode global names for the families - vtkIdType globalGroupRoot=sil->AddChild(rootId, childEdge); - names.push_back("Groups"); - - // Add the groups subtree - vtkIdType groupsRoot=sil->AddChild(rootId, childEdge); - names.push_back("GroupTree"); - - // Add the attributes subtree - vtkIdType attributesRoot=sil->AddChild(rootId, childEdge); - names.push_back("Attributes"); - - // Add a global entry to encode names for the cell types - vtkIdType globalEntityRoot=sil->AddChild(rootId, childEdge); - names.push_back("Entity"); - - // Add the cell types subtree - vtkIdType entityTypesRoot=sil->AddChild(rootId, childEdge); - names.push_back("EntityTree"); - - // This array is used to assign names to nodes. - vtkStringArray* namesArray=vtkStringArray::New(); - namesArray->SetName("Names"); - namesArray->SetNumberOfTuples(sil->GetNumberOfVertices()); - sil->GetVertexData()->AddArray(namesArray); - namesArray->Delete(); - std::deque::iterator iter; - vtkIdType cc; - for(cc=0, iter=names.begin(); iter!=names.end(); ++iter, ++cc) - { - namesArray->SetValue(cc, (*iter).c_str()); - } - -} - -int vtkExtractGroup::RequestData(vtkInformation *request, - vtkInformationVector **inputVector, vtkInformationVector *outputVector) - -{ - vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); - vtkMultiBlockDataSet* inmb=vtkMultiBlockDataSet::SafeDownCast(inputInfo->Get( - vtkDataObject::DATA_OBJECT())); - - if(inmb==NULL) - return 0; - - vtkMultiBlockDataSet* outmb=this->GetOutput(); - - outmb->CopyStructure(inmb); - - //vtkCompositeDataIterator* iterator = inmb->NewIterator(); - vtkDataObjectTreeIterator* iterator = vtkDataObjectTreeIterator::SafeDownCast( inmb->NewIterator() ); - iterator->SetVisitOnlyLeaves(true); - iterator->InitTraversal(); - while(!iterator->IsDoneWithTraversal()) - { - vtkDataObject* indo = iterator->GetCurrentDataObject(); - if(indo == NULL) - continue; - - if(indo->GetFieldData()->HasArray("BLOCK_NAME")) - { - - vtkStringArray* path = vtkStringArray::SafeDownCast( - indo->GetFieldData()->GetAbstractArray("BLOCK_NAME")); - - if(this->IsBlockSelected(path)) - { - vtkMultiBlockDataSet* parent = vtkMedUtilities::GetParent(outmb, path); - int nb = parent->GetNumberOfBlocks(); - parent->SetNumberOfBlocks(nb+1); - vtkDataObject *outdo = indo->NewInstance(); - outdo->ShallowCopy(indo); - parent->SetBlock(nb, outdo); - outdo->Delete(); - } - } - iterator->GoToNextItem(); - } - - if(PruneOutput) - { - this->PruneEmptyBlocks(outmb); - } - return 1; -} - -void vtkExtractGroup::SetGroupStatus(const char* key, int flag) -{ - vtkIdType index=this->Groups->GetArrayIndex(key); - if(index==-1) - { - index = this->Groups->AddArray(key); - this->Modified(); - } - int status=this->Groups->GetArraySetting(index); - if(status!=flag) - { - if(flag) - { - this->Groups->EnableArray(key); - } - else - { - this->Groups->DisableArray(key); - } - this->Modified(); - } - this->GroupSelectionTime.Modified(); -} - -void vtkExtractGroup::PruneEmptyBlocks(vtkMultiBlockDataSet* mb) -{ - if(mb==NULL) - return; - vtkIdType nn=0; - while(nnGetNumberOfBlocks()) - { - bool remove=false; - vtkDataObject* dataObj=mb->GetBlock(nn); - if(dataObj==NULL) - { - remove=true; - } - else - { - vtkMultiBlockDataSet* child=vtkMultiBlockDataSet::SafeDownCast(dataObj); - if(child!=NULL) - { - this->PruneEmptyBlocks(child); - if(child->GetNumberOfBlocks()==0) - { - remove=true; - } - } - } - if(remove) - { - mb->RemoveBlock(nn); - } - else - { - nn++; - } - } -} - -int vtkExtractGroup::IsBlockSelected(vtkStringArray* path) -{ - const char* meshName = (path->GetNumberOfValues()>0? - path->GetValue(0) : NULL); - const char* cellOrPoint = (path->GetNumberOfValues()>1? - path->GetValue(1) : NULL); - const char* familyName = (path->GetNumberOfValues()>2? - path->GetValue(2) : NULL); - - if(!this->IsFamilySelected(meshName, cellOrPoint, familyName)) - { - return 0; - } - - bool isOnPoint = (strcmp(cellOrPoint, vtkMedUtilities::OnPointName)==0); - - const char* entityName = (isOnPoint || path->GetNumberOfValues()<=3 ? NULL : - path->GetValue(3)); - - if(isOnPoint) - return true; - - return IsEntitySelected(entityName); - -} - -int vtkExtractGroup::IsEntitySelected(const char* entityKey) -{ - return this->Entities->GetArraySetting(entityKey); -} - -int vtkExtractGroup::IsFamilySelected(const char* meshName, - const char* pointOrCellKey, const char* familyName) -{ - if(this->FamilySelectionTime <= this->GroupSelectionTime) - { - this->SelectFamiliesFromGroups(); - } - - int - pointOrCell= (strcmp(vtkMedUtilities::OnPointName, pointOrCellKey)==0? - vtkMedUtilities::OnPoint - : vtkMedUtilities::OnCell); - - std::string name= - vtkMedUtilities::FamilyKey(meshName, pointOrCell, familyName); - - return this->Families->GetArraySetting(name.c_str()); -} - -void vtkExtractGroup::SelectFamiliesFromGroups() -{ - this->Families->DisableAllArrays(); - vtkStringArray* names=vtkStringArray::SafeDownCast( - this->GetSIL()->GetVertexData()->GetAbstractArray("Names")); - - for(int index = 0; index < this->Groups->GetNumberOfArrays(); index++) - { - if(this->Groups->GetArraySetting(index) == 0) - continue; - - const char* name = this->Groups->GetArrayName(index); - vtkIdType silindex = this->FindVertex(name); - - vtkInEdgeIterator* it = vtkInEdgeIterator::New(); - - this->GetSIL()->GetInEdges(silindex, it); - while(it->HasNext()) - { - vtkIdType famId = it->Next().Source; - vtkStdString famName = names->GetValue(famId); - if(strncmp(famName, "FAMILY", 6)==0) - { - this->Families->EnableArray(famName.c_str()); - } - } - it->Delete(); - } - - this->FamilySelectionTime.Modified(); -} - -void vtkExtractGroup::SetEntityStatus(const char* key, int flag) -{ - vtkIdType index=this->Entities->GetArrayIndex(key); - if(index==-1) - { - index = this->Entities->AddArray(key); - this->Modified(); - } - int status=this->Entities->GetArraySetting(index); - if(status!=flag) - { - if(flag) - { - this->Entities->EnableArray(key); - } - else - { - this->Entities->DisableArray(key); - } - this->Modified(); - } -} - -void vtkExtractGroup::SetFamilyStatus(const char* key, int flag) -{ - vtkIdType index=this->Families->GetArrayIndex(key); - if(index==-1) - { - return; - } - int status=this->Families->GetArraySetting(index); - if(status!=flag) - { - if(flag) - { - this->Families->EnableArray(key); - } - else - { - this->Families->DisableArray(key); - } - } -} - -int vtkExtractGroup::GetSILUpdateStamp() -{ - return this->SILTime; -} - -void vtkExtractGroup::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkExtractGroup.h b/src/Plugins/MedReader/IO/vtkExtractGroup.h deleted file mode 100644 index ffd38eff..00000000 --- a/src/Plugins/MedReader/IO/vtkExtractGroup.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : -// webmaster.salome@opencascade.com -// - -#ifndef vtkExtractGroup_h__ -#define vtkExtractGroup_h__ - -#include "vtkMultiBlockDataSetAlgorithm.h" -class vtkMutableDirectedGraph; -class vtkInformation; -class vtkInformationVector; -class vtkDataArraySelection; -class vtkTimeStamp; -class vtkStringArray; - -class VTK_EXPORT vtkExtractGroup: public vtkMultiBlockDataSetAlgorithm -{ -public: - static vtkExtractGroup* New(); - vtkTypeMacro(vtkExtractGroup, vtkMultiBlockDataSetAlgorithm) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Every time the SIL is updated a this will return a different value. - virtual int GetSILUpdateStamp(); - - // Description: - // use this method to enable/disable cell types - // the key is encoded with the vtkMedUtilities::CellTypeKey method - // which returns a string - // CELL_TYPE/MED_ENTITE_MAILLAGE/MED_GEOMETRIE_ELEMENT - virtual void SetEntityStatus(const char* key, int flag); - - // Description: - // use this method to enable/disable a family support - // the key is formatted by the vtkMedUtilities::FamilyKey method which - // returns a string - // GROUP/MESH_NAME/OnPoint/FAMILY_NAME or GROUP/MESH_NAME/OnCell/FAMILY_NAME - virtual void SetGroupStatus(const char* key, int flag); - - // Description : - // If set to 1, this filter will prune the empty parts in the output. - // If not, then empty datasets will be kept - vtkSetMacro(PruneOutput, int); - vtkGetMacro(PruneOutput, int); - - int ModifyRequest(vtkInformation* request, int when); - -protected: - vtkExtractGroup(); - ~vtkExtractGroup(); - - int RequestInformation(vtkInformation *request, - vtkInformationVector **inputVector, vtkInformationVector *outputVector); - - int RequestData(vtkInformation *request, vtkInformationVector **inputVector, - vtkInformationVector *outputVector); - - // Description : - // returns 1 if this cell type is to be passed through - int IsEntitySelected(const char*); - - // Description : - // returns 1 if this family is to be passed through - int IsFamilySelected(const char* meshName, const char* cellOrPoint, - const char* familyName); - - // Description : - // removes empty blocks from the vtkMultiBlockDataSet. - void PruneEmptyBlocks(vtkMultiBlockDataSet* mb); - - // Description: - // This SIL stores the structure of the mesh/groups/cell types - // that can be selected. - virtual void SetSIL(vtkMutableDirectedGraph*); - vtkGetObjectMacro(SIL, vtkMutableDirectedGraph); - - virtual void BuildDefaultSIL(vtkMutableDirectedGraph*); - - // Description: - // use this method to enable/disable a family support - // the key is formatted by the vtkMedUtilities::FamilyKey method which - // returns a string - // FAMILY/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME - virtual void SetFamilyStatus(const char* key, int flag); - - // Description: - // Update the Family status from te group status. - // The family status is lazily updated when GetFamilyStatus is called. - virtual void SelectFamiliesFromGroups(); - - // Description: - // returns true if the block described by the given information - // is selected. - virtual int IsBlockSelected(vtkStringArray* path); - - virtual void ClearSelections(); - - virtual vtkIdType FindVertex(const char* name); - - vtkMutableDirectedGraph* SIL; - - // Support selection - vtkDataArraySelection* Entities; - vtkDataArraySelection* Families; - vtkDataArraySelection* Groups; - - vtkTimeStamp SILTime; - vtkTimeStamp FamilySelectionTime; - vtkTimeStamp GroupSelectionTime; - - int PruneOutput; - -private: - vtkExtractGroup(const vtkExtractGroup&); - void operator=(const vtkExtractGroup&); // Not implemented. -}; - -#endif diff --git a/src/Plugins/MedReader/IO/vtkGenerateStructElement.cxx b/src/Plugins/MedReader/IO/vtkGenerateStructElement.cxx deleted file mode 100644 index 7943fd1a..00000000 --- a/src/Plugins/MedReader/IO/vtkGenerateStructElement.cxx +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkGenerateStructElement.h" - -#include "vtkObjectFactory.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkUnstructuredGrid.h" -#include "vtkCellData.h" -#include "vtkIdTypeArray.h" - -#include "vtkMedUtilities.h" -#include "vtkMedStructElement.h" -#include "vtkMedConstantAttribute.h" -#include "vtkMedVariableAttribute.h" - -class vtkGenerateStructElementCache -{ -public : - vtkGenerateStructElementCache(vtkMedStructElement* strelem, vtkUnstructuredGrid* ug) - { - for(int attid = 0; attid < strelem->GetNumberOfConstantAttribute(); attid++) - { - vtkMedConstantAttribute* att = strelem->GetConstantAttribute(attid); - this->cstAttribute[att->GetName()] = att; - } - - for(int attid = 0; attid < strelem->GetNumberOfVariableAttribute(); attid++) - { - vtkMedVariableAttribute* att = strelem->GetVariableAttribute(attid); - vtkDataArray* array = ug->GetFieldData()->GetArray(att->GetName()); - if(array != NULL) - this->varAttribute[att->GetName()] = array; - } - } - - bool HasParameter(const char* name) - { - return this->cstAttribute.find(name) != this->cstAttribute.end() - || this->varAttribute.find(name) != this->varAttribute.end(); - } - - double GetParameter1(const char* name, vtkIdType id) - { - if(this->cstAttribute.find(name) != this->cstAttribute.end()) - { - vtkMedConstantAttribute* att = this->cstAttribute[name]; - return att->GetValues()->GetVariantValue(0).ToDouble(); - } - if(this->varAttribute.find(name) != this->varAttribute.end()) - { - vtkDataArray* array = this->varAttribute[name]; - return array->GetTuple1(id); - } - return 0.0; - } - -protected : - std::map cstAttribute; - std::map varAttribute; -}; - -// vtkCxxRevisionMacro(vtkGenerateStructElement, "$Revision$"); -vtkStandardNewMacro(vtkGenerateStructElement); - -vtkGenerateStructElement::vtkGenerateStructElement() -{ - -} - -vtkGenerateStructElement::~vtkGenerateStructElement() -{ - -} - -int vtkGenerateStructElement::RequestData(vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector) -{ - vtkInformation* outInfo=outputVector->GetInformationObject(0); - - vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); - - vtkUnstructuredGrid* inug = vtkUnstructuredGrid::SafeDownCast( - inputInfo->Get(vtkDataObject::DATA_OBJECT())); - - vtkUnstructuredGrid* outug = vtkUnstructuredGrid::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - outug->Initialize(); - - vtkMedStructElement* strelem = vtkMedStructElement::SafeDownCast( - inug->GetInformation()->Get(vtkMedUtilities::STRUCT_ELEMENT())); - - std::cout << "Inside vtkGenerateStructElement::RequestData" << std::endl; - - if(strelem == NULL) - { - vtkDebugMacro("vtkGenerateStructElement needs a vtkMedStructElement information"); - return 1; - } - - vtkIdTypeArray* strelemindex = vtkIdTypeArray::SafeDownCast( - inug->GetCellData()->GetArray("STRUCT_ELEMENT_INDEX")); - if(strelemindex == NULL) - { - vtkDebugMacro("vtkGenerateStructElement needs some information on the structural elements"); - return 1; - } - - // loop over input cells. - // struct elements support are a set cells of same type following each other. - vtkIdType medid = -1; - vtkGenerateStructElementCache cache(strelem, inug); - - std::string name = strelem->GetName(); - - if(name == MED_BALL_NAME) - { - std::cout << "vtkGenerateStructElement::RequestData ... if(name == MED_BALL_NAME)" << std::endl; - // sanity check : is the diameter defined? - if(!cache.HasParameter(MED_BALL_DIAMETER)) - { - vtkErrorMacro("MED_BALL elements need a diameter"); - return 1; - } - std::cout << "inug->GetNumberOfCells() = " << inug->GetNumberOfCells() << std::endl; - for(vtkIdType cellId = 0; cellId < inug->GetNumberOfCells(); cellId++) - { - vtkIdType ballMedId = strelemindex->GetValue(2*cellId); - double balldiam = this->GetParameter1(MED_BALL_DIAMETER, ballMedId, cache); - std::cout << balldiam << " - "; - //TODO - //this->GenerateBall(inug, cellId, balldiam, outug); - } - std::cout << std::endl; - } - else if(name == MED_PARTICLE_NAME) - { - bool hasLabel = cache.HasParameter(MED_PARTICLE_LABEL); - for(vtkIdType cellId = 0; cellId < inug->GetNumberOfCells(); cellId++) - { - if(hasLabel) - { - vtkIdType particleMedId = strelemindex->GetValue(2*cellId); - double particlelabel = this->GetParameter1(MED_PARTICLE_LABEL, particleMedId, cache); - - //TODO - // this->GenerateParticle(inug, cellId, particlelabel, outug); - } - else - { - //TODO - // this->GenerateParticle(inug, cellId, outug); - } - } - } - else if(name == MED_BEAM_NAME) - { - // sanity check : is the diameter defined? - if(!cache.HasParameter(MED_BEAM_THICKNESS)) - { - vtkErrorMacro("MED_BEAM elements need a thickness"); - return 1; - } - for(vtkIdType cellId = 0; cellId < inug->GetNumberOfCells(); cellId++) - { - vtkIdType cellmedid = strelemindex->GetValue(2*cellId); - if(cellmedid != medid) - { - // this means that a new beam begins - medid = cellmedid; - double thickness = this->GetParameter1(MED_BEAM_THICKNESS, medid, cache); - - //TODO : generate a beam. - // rem : a beam can span several segments. - - } - } - } - else - { - vtkErrorMacro("structural elements of type " << name << " are not supported"); - } - - return 1; -} - -double vtkGenerateStructElement::GetParameter1(const char* name, - vtkIdType medid, - vtkGenerateStructElementCache& cache) -{ -#ifdef WIN32 //rnv : Avoid compliation error in the VS under windows. - return 0; -#endif -} - -void vtkGenerateStructElement::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkGenerateStructElement.h b/src/Plugins/MedReader/IO/vtkGenerateStructElement.h deleted file mode 100644 index fb37e03b..00000000 --- a/src/Plugins/MedReader/IO/vtkGenerateStructElement.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkGenerateStructElement_h__ -#define __vtkGenerateStructElement_h__ - -#include "vtkUnstructuredGridAlgorithm.h" - -class vtkMedStructElement; -class vtkGenerateStructElementCache; - -class VTK_EXPORT vtkGenerateStructElement : public vtkUnstructuredGridAlgorithm -{ -public: - static vtkGenerateStructElement* New(); - vtkTypeMacro(vtkGenerateStructElement, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - -protected : - vtkGenerateStructElement(); - virtual ~vtkGenerateStructElement(); - - // Description: - // This is called by the superclass. - // This is the method you should override. - virtual int RequestData(vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector); - - //BTX - virtual double GetParameter1(const char*, - vtkIdType, - vtkGenerateStructElementCache&); - //ETX - -private : - vtkGenerateStructElement(const vtkGenerateStructElement&);// Not implemented. - void operator=(const vtkGenerateStructElement&); // Not implemented. - -}; - -#endif //__vtkGenerateStructElement_h__ diff --git a/src/Plugins/MedReader/IO/vtkMedCartesianGrid.h b/src/Plugins/MedReader/IO/vtkMedCartesianGrid.h deleted file mode 100644 index 0d84d82e..00000000 --- a/src/Plugins/MedReader/IO/vtkMedCartesianGrid.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedCartesianGrid_h_ -#define __vtkMedCartesianGrid_h_ - -#include "vtkMedRegularGrid.h" - -class VTK_EXPORT vtkMedCartesianGrid : public vtkMedRegularGrid -{ -public : - static vtkMedCartesianGrid* New(); - vtkTypeMacro(vtkMedCartesianGrid, vtkMedRegularGrid); - void PrintSelf(ostream& os, vtkIndent indent); - -protected: - vtkMedCartesianGrid(); - virtual ~vtkMedCartesianGrid(); - -private: - vtkMedCartesianGrid(const vtkMedCartesianGrid&); // Not implemented. - void operator=(const vtkMedCartesianGrid&); // Not implemented. - -}; - -#endif //__vtkMedCartesianGrid_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedConstantAttribute.cxx b/src/Plugins/MedReader/IO/vtkMedConstantAttribute.cxx deleted file mode 100644 index 47990389..00000000 --- a/src/Plugins/MedReader/IO/vtkMedConstantAttribute.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedConstantAttribute.h" - -#include "vtkObjectFactory.h" -#include "vtkMedUtilities.h" - -#include "vtkAbstractArray.h" -#include "vtkMedStructElement.h" -#include "vtkMedProfile.h" - -#include -#include -#include -using namespace std; - -// vtkCxxRevisionMacro(vtkMedConstantAttribute, "$Revision$") -vtkStandardNewMacro(vtkMedConstantAttribute); - -vtkCxxSetObjectMacro(vtkMedConstantAttribute, Values, vtkAbstractArray); -vtkCxxSetObjectMacro(vtkMedConstantAttribute, ParentStructElement, vtkMedStructElement); -vtkCxxSetObjectMacro(vtkMedConstantAttribute, Profile, vtkMedProfile); - -vtkMedConstantAttribute::vtkMedConstantAttribute() -{ - this->Name = NULL; - this->AttributeType = MED_ATT_UNDEF; - this->NumberOfComponent = 0; - this->SupportEntityType = MED_UNDEF_ENTITY_TYPE; - this->ProfileName = NULL; - this->ProfileSize = 0; - this->Values = NULL; - this->ParentStructElement = NULL; - this->Profile = NULL; -} - -vtkMedConstantAttribute::~vtkMedConstantAttribute() -{ - this->SetName(NULL); - this->SetProfileName(NULL); - this->SetParentStructElement(NULL); - this->SetValues(NULL); - this->SetProfile(NULL); -} - -void vtkMedConstantAttribute::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedConstantAttribute.h b/src/Plugins/MedReader/IO/vtkMedConstantAttribute.h deleted file mode 100644 index 6d88a17e..00000000 --- a/src/Plugins/MedReader/IO/vtkMedConstantAttribute.h +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedConstantAttribute_h_ -#define __vtkMedConstantAttribute_h_ - -#include "vtkObject.h" -#include "vtkMed.h" - -class vtkAbstractArray; -class vtkMedStructElement; -class vtkMedProfile; - -class VTK_EXPORT vtkMedConstantAttribute : public vtkObject -{ -public : - static vtkMedConstantAttribute* New(); - vtkTypeMacro(vtkMedConstantAttribute, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the name of this attribute - vtkSetStringMacro(Name); - vtkGetStringMacro(Name); - - // Description: - // The iterator in the med file of this constant attribute - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // The Geometry type this structural elements lies on. - vtkSetMacro(AttributeType, med_attribute_type); - vtkGetMacro(AttributeType, med_attribute_type); - - // Description: - // The dimension of this structural elements model - vtkSetMacro(NumberOfComponent, med_int); - vtkGetMacro(NumberOfComponent, med_int); - - // Description: - // MED_CELL if the support mesh has any cell, MED_NODE otherwise - vtkSetMacro(SupportEntityType, med_entity_type); - vtkGetMacro(SupportEntityType, med_entity_type); - - // Description: - // The name of the profile if any, MED_NO_PROFILE by default - vtkSetStringMacro(ProfileName); - vtkGetStringMacro(ProfileName); - - // Description: - // The Size of the profile if any - vtkSetMacro(ProfileSize, med_int); - vtkGetMacro(ProfileSize, med_int); - - // Description: - // This store the values of this attribute - virtual void SetValues(vtkAbstractArray*); - vtkGetObjectMacro(Values, vtkAbstractArray); - - // Description: - // This is the pointer to the actual profile used by this attribute - virtual void SetProfile(vtkMedProfile*); - vtkGetObjectMacro(Profile, vtkMedProfile); - - // Description: - // The Structural element on which lies this attribute - virtual void SetParentStructElement(vtkMedStructElement*); - vtkGetObjectMacro(ParentStructElement, vtkMedStructElement); - -protected: - vtkMedConstantAttribute(); - virtual ~vtkMedConstantAttribute(); - - char *Name; - med_int MedIterator; - med_attribute_type AttributeType; - med_int NumberOfComponent; - med_entity_type SupportEntityType; - char* ProfileName; - med_int ProfileSize; - vtkAbstractArray* Values; - vtkMedProfile* Profile; - - vtkMedStructElement * ParentStructElement; - -private: - vtkMedConstantAttribute(const vtkMedConstantAttribute&); // Not implemented. - void operator=(const vtkMedConstantAttribute&); // Not implemented. - -}; - -#endif //__vtkMedConstantAttribute_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.cxx b/src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.cxx deleted file mode 100644 index 0aa9c86b..00000000 --- a/src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.cxx +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedCurvilinearGrid.h" - -#include "vtkMedMesh.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedFamilyOnEntityOnProfile.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedEntityArray.h" -#include "vtkMedProfile.h" -#include "vtkMedFamily.h" - -#include "vtkObjectFactory.h" -#include "vtkDataArray.h" -#include "vtkStructuredGrid.h" - -vtkCxxSetObjectMacro(vtkMedCurvilinearGrid, Coordinates, vtkDataArray); - -// vtkCxxRevisionMacro(vtkMedCurvilinearGrid, "$Revision$") -vtkStandardNewMacro(vtkMedCurvilinearGrid) - -vtkMedCurvilinearGrid::vtkMedCurvilinearGrid() -{ - this->Coordinates = NULL; - this->NumberOfPoints = 0; -} - -vtkMedCurvilinearGrid::~vtkMedCurvilinearGrid() -{ - this->SetCoordinates(NULL); -} - -void vtkMedCurvilinearGrid::SetDimension(int dim) -{ - this->AxisSize.resize(dim); -} - -int vtkMedCurvilinearGrid::GetDimension() -{ - return this->AxisSize.size(); -} - -void vtkMedCurvilinearGrid::SetAxisSize(int axis, med_int size) -{ - if(axis < 0) - return; - - if(axis >= this->AxisSize.size()) - this->AxisSize.resize(axis+1); - - this->AxisSize[axis] = size; -} - -med_int vtkMedCurvilinearGrid::GetAxisSize(int axis) -{ - if(axis < 0 || axis >= this->AxisSize.size()) - return 0; - - return this->AxisSize[axis]; -} - -void vtkMedCurvilinearGrid::LoadCoordinates() -{ - vtkMedDriver* driver = this->GetParentMesh()->GetParentFile()->GetMedDriver(); - driver->LoadCoordinates(this); -} - -int vtkMedCurvilinearGrid::IsCoordinatesLoaded() -{ - return this->Coordinates != NULL && this->Coordinates->GetNumberOfTuples() - == this->NumberOfPoints; -} - -double* vtkMedCurvilinearGrid::GetCoordTuple(med_int index) -{ - return this->Coordinates->GetTuple(index); -} - -vtkDataSet* vtkMedCurvilinearGrid::CreateVTKDataSet( - vtkMedFamilyOnEntityOnProfile* foep) -{ - vtkStructuredGrid* vtkgrid = vtkStructuredGrid::New(); - - vtkPoints* points = vtkPoints::New(); - vtkgrid->SetPoints(points); - points->Delete(); - vtkgrid->SetDimensions(this->GetAxisSize(0), - this->GetAxisSize(1), - this->GetAxisSize(2)); - - this->LoadCoordinates(); - - if(this->GetDimension() == 3) - { - vtkgrid->GetPoints()->SetData(this->GetCoordinates()); - } - else - { - if(this->GetDimension() == 1) - { - vtkgrid->SetDimensions(this->GetAxisSize(0), - 1, - 1); - } - - if(this->GetDimension() == 2) - { - vtkgrid->SetDimensions(this->GetAxisSize(0), - this->GetAxisSize(1), - 1); - } - - vtkDataArray* coords = vtkDataArray::SafeDownCast( - vtkAbstractArray::CreateArray(this->GetCoordinates()->GetDataType())); - coords->SetNumberOfComponents(3); - coords->SetNumberOfTuples(this->GetNumberOfPoints()); - vtkgrid->GetPoints()->SetData(coords); - coords->Delete(); - - med_int npts = this->GetNumberOfPoints(); - double coord[3] = {0, 0, 0}; - for(med_int id=0; idCoordinates->GetTuple(id); - for(int dim=0; dimGetDimension(); dim++) - { - coord[dim] = tuple[dim]; - } - coords->SetTuple(id, coord); - } - } - - if(foep->GetProfile() != NULL) - { - foep->GetProfile()->Load(); - vtkMedIntArray* pids = foep->GetProfile()->GetIds(); - med_int previd = -1; - for(med_int pid=0; pidGetNumberOfTuples(); pid++) - { - med_int id = pids->GetValue(pid) - 1; - for(med_int theid=previd+1; theidBlankCell(theid); - } - - previd = id; - } - } - - if(foep->GetFamilyOnEntity()->GetEntityArray()->GetNumberOfFamilyOnEntity() > 1) - { - med_int famid = foep->GetFamilyOnEntity()->GetFamily()->GetId(); - vtkMedEntityArray* ea = foep->GetFamilyOnEntity()->GetEntityArray(); - for(med_int id=0; idGetNumberOfCells(); id++) - { - if(ea->GetFamilyId(id) != famid) - vtkgrid->BlankCell(id); - } - } - - return vtkgrid; -} - -void vtkMedCurvilinearGrid::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.h b/src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.h deleted file mode 100644 index 8c8dd929..00000000 --- a/src/Plugins/MedReader/IO/vtkMedCurvilinearGrid.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedCurvilinearGrid_h_ -#define __vtkMedCurvilinearGrid_h_ - -#include "vtkMedGrid.h" -#include "vtkMed.h" - -class vtkDataArray; -#include - -class VTK_EXPORT vtkMedCurvilinearGrid : public vtkMedGrid -{ -public : - static vtkMedCurvilinearGrid* New(); - vtkTypeMacro(vtkMedCurvilinearGrid, vtkMedGrid) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // overloaded to allocate memory for the grid size - virtual void SetDimension(int); - virtual int GetDimension(); - - // Description: - // The number of nodes of this grid. This method do not - // perform any allocation. - vtkSetMacro(NumberOfPoints, med_int); - vtkGetMacro(NumberOfPoints, med_int); - - // Description: - // this array contains the coordinates of the points used by this grid. - virtual void SetCoordinates(vtkDataArray*); - vtkGetObjectMacro(Coordinates, vtkDataArray); - - // Description: - // Set/Get the size of each axis. - // Note that the number of points must match the product of the - // size of each axis. - virtual void SetAxisSize(int axis, med_int size); - virtual med_int GetAxisSize(int axis); - - virtual void LoadCoordinates(); - virtual int IsCoordinatesLoaded(); - - virtual double* GetCoordTuple(med_int index); - - virtual vtkDataSet* CreateVTKDataSet(vtkMedFamilyOnEntityOnProfile*); - -protected: - vtkMedCurvilinearGrid(); - virtual ~vtkMedCurvilinearGrid(); - - std::vector AxisSize; - med_int NumberOfPoints; - vtkDataArray* Coordinates; - -private: - vtkMedCurvilinearGrid(const vtkMedCurvilinearGrid&); // Not implemented. - void operator=(const vtkMedCurvilinearGrid&); // Not implemented. - -}; - -#endif //__vtkMedCurvilinearGrid_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedDriver.cxx b/src/Plugins/MedReader/IO/vtkMedDriver.cxx deleted file mode 100644 index 432d836e..00000000 --- a/src/Plugins/MedReader/IO/vtkMedDriver.cxx +++ /dev/null @@ -1,466 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedDriver.h" - -#include "vtkObjectFactory.h" -#include "vtkStringArray.h" -#include "vtkDataArray.h" -#include "vtkIdTypeArray.h" -#include "vtkMath.h" - -#include "vtkMedFile.h" -#include "vtkMedCartesianGrid.h" -#include "vtkMedPolarGrid.h" -#include "vtkMedCurvilinearGrid.h" -#include "vtkMedUnstructuredGrid.h" -#include "vtkMedField.h" -#include "vtkMedMesh.h" -#include "vtkMedFamily.h" -#include "vtkMedUtilities.h" -#include "vtkMedEntityArray.h" -#include "vtkMedLocalization.h" -#include "vtkMedProfile.h" -#include "vtkMedFieldOverEntity.h" -#include "vtkMedFieldStep.h" -#include "vtkMedGroup.h" -#include "vtkMedIntArray.h" -#include "vtkMedLink.h" - -#ifdef MedReader_HAVE_PARALLEL_INFRASTRUCTURE -#include "vtkMultiProcessController.h" -#include "vtkMPIController.h" -#include -#include -#endif - -vtkCxxSetObjectMacro(vtkMedDriver, MedFile, vtkMedFile); - -//vtkCxxRevisionMacro(vtkMedDriver, "$Revision$") -vtkStandardNewMacro(vtkMedDriver) - -vtkMedDriver::vtkMedDriver() -{ - this->MedFile = NULL; - this->OpenLevel = 0; - this->FileId = -1; -} - -vtkMedDriver::~vtkMedDriver() -{ - if (this->OpenLevel > 0) - { - vtkWarningMacro("The file has not be closed before destructor.") - this->OpenLevel = 1; - this->Close(); - } - this->SetMedFile(NULL); -} - -int vtkMedDriver::RestrictedOpen() -{ - int res = 0; - if (this->MedFile == NULL || this->MedFile->GetFileName() == NULL) - { - vtkDebugMacro("Error : FileName has not been set "); - return -1; - } - - if (this->OpenLevel <= 0) - { - - med_bool hdfok; - med_bool medok; - - med_err conforme = MEDfileCompatibility(this->MedFile->GetFileName(), - &hdfok, &medok); - if (!hdfok) - { - vtkErrorMacro("The file " << this->MedFile->GetFileName() - << " is not a HDF5 file, aborting."); - return -1; - } - - if (!medok) - { - vtkErrorMacro("The file " << this->MedFile->GetFileName() - << " has not been written with the" - << " same version as the one currently used to read it, this may lead" - << " to errors. Please use the medimport tool."); - return -1; - } - - if(conforme < 0) - { - vtkErrorMacro("The file " << this->MedFile->GetFileName() - << " is not compatible, please import it to the new version using medimport."); - return -1; - } - - this->FileId = MEDfileOpen(this->MedFile->GetFileName(), MED_ACC_RDONLY); - if (this->FileId < 0) - { - vtkDebugMacro("Error : unable to open file " - << this->MedFile->GetFileName()); - res = -2; - } - this->OpenLevel = 0; - - } // OpenLevel - this->OpenLevel++; - this->ParallelFileId = -1; - return res; -} - -int vtkMedDriver::Open() -{ - int res = 0; - if (this->MedFile == NULL || this->MedFile->GetFileName() == NULL) - { - vtkDebugMacro("Error : FileName has not been set "); - return -1; - } - - if (this->OpenLevel <= 0) - { - - med_bool hdfok; - med_bool medok; - - med_err conforme = MEDfileCompatibility(this->MedFile->GetFileName(), - &hdfok, &medok); - if (!hdfok) - { - vtkErrorMacro("The file " << this->MedFile->GetFileName() - << " is not a HDF5 file, aborting."); - return -1; - } - - if (!medok) - { - vtkErrorMacro("The file " << this->MedFile->GetFileName() - << " has not been written with the" - << " same version as the one currently used to read it, this may lead" - << " to errors. Please use the medimport tool."); - return -1; - } - - if(conforme < 0) - { - vtkErrorMacro("The file " << this->MedFile->GetFileName() - << " is not compatible, please import it to the new version using medimport."); - return -1; - } - - this->FileId = MEDfileOpen(this->MedFile->GetFileName(), MED_ACC_RDONLY); - if (this->FileId < 0) - { - vtkDebugMacro("Error : unable to open file " - << this->MedFile->GetFileName()); - res = -2; - } - this->OpenLevel = 0; - - this->ParallelFileId = -1; - -#ifdef MedReader_HAVE_PARALLEL_INFRASTRUCTURE - // the following code opens the file in parallel - vtkMultiProcessController* controller = - vtkMultiProcessController::GetGlobalController(); - int lpID = 0; - if (controller == NULL) - { - return -3; - } - else - { - lpID = controller->GetLocalProcessId(); - } - - vtkMPICommunicator* commu = vtkMPICommunicator::SafeDownCast( - controller->GetCommunicator() ); - if (commu == NULL) - { - //vtkErrorMacro("Communicator is NULL in Open"); - return -3; - } - MPI_Comm* mpi_com = NULL; - mpi_com = commu->GetMPIComm()->GetHandle(); - if (mpi_com == NULL) - { - vtkErrorMacro("MPI communicator is NULL in Open"); - return -3; - } - - if (controller->GetNumberOfProcesses() > 1) - { - int major, minor, release; - if (MEDfileNumVersionRd(this->FileId, &major, &minor, &release) < 0) - { - vtkErrorMacro("Impossible to read the version of this file"); - return -1; - } - - if (major >= 3) - { - this->ParallelFileId = MEDparFileOpen(this->MedFile->GetFileName(), - MED_ACC_RDONLY, - *mpi_com, - MPI_INFO_NULL); - } - else - { - vtkErrorMacro("Parallel access is not allowed in MED files prior to version 3"); - return -1; - } - } - - if (this->ParallelFileId < 0) - { - vtkDebugMacro("Error : unable to parallel-open file " - << this->MedFile->GetFileName()); - } -#endif - - } // OpenLevel - this->OpenLevel++; - return res; -} - -void vtkMedDriver::Close() -{ - this->OpenLevel--; - if (this->OpenLevel == 0) - { - if (MEDfileClose(this->FileId) < 0) - { - vtkErrorMacro("Error: unable to close the current file."); - } - this->FileId = -1; - - if (this->ParallelFileId != -1) - { - if (MEDfileClose(this->ParallelFileId) < 0) - { - vtkErrorMacro("Error: unable to parallel-close the current file."); - } - } - this->ParallelFileId = -1; - } -} - -bool vtkMedDriver::CanReadFile() -{ - bool canRead = (this->RestrictedOpen() >= 0); - this->Close(); - return canRead; -} - -void vtkMedDriver::ReadFileVersion(int* major, int* minor, int* release) -{ - FileRestrictedOpen open(this); - - med_int amajor, aminor, arelease; - if (MEDfileNumVersionRd(this->FileId, &amajor, &aminor, &arelease) < 0) - { - vtkErrorMacro("Impossible to read the version of this file"); - return; - } - *major = amajor; - *minor = aminor; - *release = arelease; -} - -void vtkMedDriver::ReadRegularGridInformation(vtkMedRegularGrid* grid) -{ - vtkErrorMacro("vtkMedDriver::ReadInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadCurvilinearGridInformation(vtkMedCurvilinearGrid* grid) -{ - vtkErrorMacro("vtkMedDriver::ReadInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadUnstructuredGridInformation(vtkMedUnstructuredGrid* grid) -{ - vtkErrorMacro("vtkMedDriver::ReadInformation not Implemented !"); - return; -} - -// Description: -// load all Information data associated with this standard grid. -void vtkMedDriver::ReadGridInformation(vtkMedGrid* grid) -{ - if(vtkMedRegularGrid::SafeDownCast(grid) != NULL) - { - this->ReadRegularGridInformation(vtkMedRegularGrid::SafeDownCast(grid)); - } - if(vtkMedCurvilinearGrid::SafeDownCast(grid) != NULL) - { - this->ReadCurvilinearGridInformation(vtkMedCurvilinearGrid::SafeDownCast(grid)); - } - if(vtkMedUnstructuredGrid::SafeDownCast(grid) != NULL) - { - this->ReadUnstructuredGridInformation(vtkMedUnstructuredGrid::SafeDownCast(grid)); - } -} - -void vtkMedDriver::ReadFamilyInformation(vtkMedMesh* mesh, vtkMedFamily* family) -{ - vtkErrorMacro("vtkMedDriver::ReadFamilyInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadFileInformation(vtkMedFile* file) -{ - vtkErrorMacro("vtkMedDriver::ReadFileInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadProfileInformation(vtkMedProfile* profile) -{ - vtkErrorMacro("vtkMedDriver::ReadProfileInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadFieldInformation(vtkMedField* field) -{ - vtkErrorMacro("vtkMedDriver::ReadFieldInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadFieldOverEntityInformation(vtkMedFieldOverEntity* fieldOverEntity) -{ - vtkErrorMacro("vtkMedDriver::ReadFieldOverEntityInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadMeshInformation(vtkMedMesh* mesh) -{ - vtkErrorMacro("vtkMedDriver::ReadMeshInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadLocalizationInformation(vtkMedLocalization* loc) -{ - vtkErrorMacro("vtkMedDriver::ReadLocalizationInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadInterpolationInformation(vtkMedInterpolation* interp) -{ - vtkErrorMacro("vtkMedDriver::ReadInterpolationInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadFieldStepInformation(vtkMedFieldStep* step, bool readAllEntityInfo) -{ - vtkErrorMacro("vtkMedDriver::ReadFieldStepInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadFieldOnProfileInformation(vtkMedFieldOnProfile* fop) -{ - vtkErrorMacro("vtkMedDriver::ReadFieldOnProfileInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadStructElementInformation( - vtkMedStructElement*) -{ - vtkErrorMacro("vtkMedDriver::ReadStructElementInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadSupportMeshInformation( - vtkMedMesh*) -{ - vtkErrorMacro("vtkMedDriver::ReadSupportMeshInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadConstantAttributeInformation(vtkMedConstantAttribute*) -{ - vtkErrorMacro("vtkMedDriver::ReadConstantAttributeInformation not Implemented !"); - return; -} - -void vtkMedDriver::ReadVariableAttributeInformation(vtkMedVariableAttribute*) -{ - vtkErrorMacro("vtkMedDriver::ReadVariableAttributeInformation not Implemented !"); - return; -} - -void vtkMedDriver::LoadPointGlobalIds(vtkMedGrid* grid) -{ - vtkErrorMacro("vtkMedDriver::LoadPointGlobalIds not Implemented !"); - return; -} - -void vtkMedDriver::LoadFamilyIds(vtkMedEntityArray* array) -{ - vtkErrorMacro("vtkMedDriver::LoadFamilyIds not Implemented !"); - return; -} - -void vtkMedDriver::LoadCoordinates(vtkMedGrid* grid) -{ - vtkErrorMacro("vtkMedDriver::LoadCoordinates not Implemented !"); - return; -} - -void vtkMedDriver::LoadProfile(vtkMedProfile* profile) -{ - vtkErrorMacro("vtkMedDriver::LoadProfile not Implemented !"); - return; -} - -void vtkMedDriver::LoadConnectivity(vtkMedEntityArray* array) -{ - vtkErrorMacro("vtkMedDriver::LoadConnectivity not Implemented !"); - return; -} - -void vtkMedDriver::LoadCellGlobalIds(vtkMedEntityArray* array) -{ - vtkErrorMacro("vtkMedDriver::LoadGlobalIds not Implemented !"); - return; -} - -void vtkMedDriver::LoadField(vtkMedFieldOnProfile* foe, med_storage_mode mode) -{ - vtkErrorMacro("vtkMedDriver::LoadFieldOnProfile not Implemented !"); - return; -} - -void vtkMedDriver::LoadVariableAttribute(vtkMedVariableAttribute*, - vtkMedEntityArray*) -{ - vtkErrorMacro("vtkMedDriver::LoadVariableAttribute not Implemented !"); - return; -} - -void vtkMedDriver::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, OpenLevel); - PRINT_IVAR(os, indent, FileId); -} diff --git a/src/Plugins/MedReader/IO/vtkMedDriver.h b/src/Plugins/MedReader/IO/vtkMedDriver.h deleted file mode 100644 index d02516af..00000000 --- a/src/Plugins/MedReader/IO/vtkMedDriver.h +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedDriver_h_ -#define __vtkMedDriver_h_ - -#include "vtkObject.h" -#include "vtkMed.h" - -class vtkMedFile; -class vtkMedMesh; -class vtkMedField; -class vtkMedFamily; -class vtkMedPolarGrid; -class vtkMedRegularGrid; -class vtkMedCurvilinearGrid; -class vtkMedUnstructuredGrid; -class vtkMedLocalization; -class vtkMedProfile; -class vtkMedFieldOverEntity; -class vtkMedEntityArray; -class vtkMedFieldStep; -class vtkMedGrid; -class vtkMedInterpolation; -class vtkMedFieldOnProfile; -class vtkMedStructElement; -class vtkMedConstantAttribute; -class vtkMedVariableAttribute; - -class VTK_EXPORT vtkMedDriver: public vtkObject -{ -public: - static vtkMedDriver* New(); - vtkTypeMacro(vtkMedDriver, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Set/Get the med file that use this driver - virtual void SetMedFile(vtkMedFile*); - vtkGetObjectMacro(MedFile, vtkMedFile); - - // Description : - // This gives the File ID to read in parallel. - vtkGetMacro(ParallelFileId, med_idt); - - // Description: - // open the file for reading. Returns 0 on success, or error code. - virtual int RestrictedOpen(); - virtual int Open(); - virtual void Close(); - virtual bool CanReadFile(); - - // Description: - // Get the Version numbers from the file - virtual void ReadFileVersion(int* major, int* minor, int* release); - - // Description: - // load all meta data associated with this file. - virtual void ReadFileInformation(vtkMedFile*); - - // Description: - // load all meta data associated with this mesh. - virtual void ReadMeshInformation(vtkMedMesh*); - - // Description: - // load all meta data associated with this field. - virtual void ReadFieldInformation(vtkMedField*); - - // Description: - // load all meta data associated with this regular (Cartesian or polar) grid. - virtual void ReadRegularGridInformation(vtkMedRegularGrid*); - - // Description: - // load all meta data associated with this standard grid. - virtual void ReadCurvilinearGridInformation(vtkMedCurvilinearGrid*); - - // Description: - // load all meta data associated with this unstructured grid. - virtual void ReadUnstructuredGridInformation(vtkMedUnstructuredGrid*); - - // Description: - // load all meta data associated with this grid. - // (call one of the above method depending on the type of grid) - virtual void ReadGridInformation(vtkMedGrid*); - - // Description: - // load all meta data associated with this family. - virtual void ReadFamilyInformation(vtkMedMesh*, vtkMedFamily*); - - // Description: - // load all meta data associated with this family. - virtual void ReadProfileInformation(vtkMedProfile*); - - // Description: - // load information on a field and a given cell type at a given step - virtual void ReadFieldOverEntityInformation(vtkMedFieldOverEntity*); - - // Description: - // load information related to the given quadrature scheme definition - virtual void ReadLocalizationInformation(vtkMedLocalization*); - - // Description: - // load all information associated witht this field step - virtual void ReadFieldStepInformation(vtkMedFieldStep*, bool readAllEntityInfo); - - // Description: - // load all information related to this interpolation function - virtual void ReadInterpolationInformation(vtkMedInterpolation*); - - // Description: - // load all information related to this field on this profile - virtual void ReadFieldOnProfileInformation(vtkMedFieldOnProfile*); - - // Description: - // read all information related to the structural elements models - // in this file - virtual void ReadStructElementInformation(vtkMedStructElement*); - - // Description: - // read all information related to the support mesh - // in this file - virtual void ReadSupportMeshInformation(vtkMedMesh*); - - // Description: - // read all information related to the support mesh - // in this file - virtual void ReadConstantAttributeInformation(vtkMedConstantAttribute*); - - // Description: - // read all information related to the support mesh - // in this file - virtual void ReadVariableAttributeInformation(vtkMedVariableAttribute*); - - // Description: - // load the field on this profile - virtual void LoadField(vtkMedFieldOnProfile* fop, med_storage_mode mode); - - // Description: - // Load the indices of the profile - virtual void LoadProfile(vtkMedProfile* profile); - - // Description: - // Load the values of the given step -// void Load(vtkMedFieldOnProfile*); - - virtual void LoadFamilyIds(vtkMedEntityArray*); - - virtual void LoadCoordinates(vtkMedGrid*); - - virtual void LoadPointGlobalIds(vtkMedGrid*); - - //virtual void LoadPointFamilyIds(vtkMedGrid*); - - virtual void LoadConnectivity(vtkMedEntityArray*); - - virtual void LoadCellGlobalIds(vtkMedEntityArray*); - - virtual void LoadVariableAttribute(vtkMedVariableAttribute*, - vtkMedEntityArray*); - - //BTX - class FileOpen - { - public: - FileOpen(vtkMedDriver* driver) - { - this->Driver = driver; - this->Driver->Open(); - } - ~FileOpen() - { - this->Driver->Close(); - } - protected: - vtkMedDriver* Driver; - vtkMedFile* File; - }; - //ETX - - //BTX - class FileRestrictedOpen - { - public: - FileRestrictedOpen(vtkMedDriver* driver) - { - this->Driver = driver; - this->Driver->RestrictedOpen(); - } - ~FileRestrictedOpen() - { - this->Driver->Close(); - } - protected: - vtkMedDriver* Driver; - vtkMedFile* File; - }; - //ETX - -protected: - vtkMedDriver(); - ~vtkMedDriver(); - - // name of the file to read from - vtkMedFile * MedFile; - - int OpenLevel; - - med_idt FileId; - med_idt ParallelFileId; - -private: - vtkMedDriver(const vtkMedDriver&); // Not implemented. - void operator=(const vtkMedDriver&); // Not implemented. -}; - -#endif //__vtkMedDriver_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedDriver30.cxx b/src/Plugins/MedReader/IO/vtkMedDriver30.cxx deleted file mode 100644 index 924cc856..00000000 --- a/src/Plugins/MedReader/IO/vtkMedDriver30.cxx +++ /dev/null @@ -1,2407 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedDriver30.h" - -#include "vtkObjectFactory.h" -#include "vtkStringArray.h" -#include "vtkDataArray.h" -#include "vtkIdTypeArray.h" -#include "vtkDoubleArray.h" -#include "vtkIntArray.h" -#include "vtkCharArray.h" - -#include "vtkMedFile.h" -#include "vtkMedCartesianGrid.h" -#include "vtkMedPolarGrid.h" -#include "vtkMedCurvilinearGrid.h" -#include "vtkMedUnstructuredGrid.h" -#include "vtkMedField.h" -#include "vtkMedMesh.h" -#include "vtkMedFamily.h" -#include "vtkMedUtilities.h" -#include "vtkMedEntityArray.h" -#include "vtkMedLocalization.h" -#include "vtkMedProfile.h" -#include "vtkMedFieldOverEntity.h" -#include "vtkMedFieldStep.h" -#include "vtkMedGroup.h" -#include "vtkMedIntArray.h" -#include "vtkMedInterpolation.h" -#include "vtkMedFieldOnProfile.h" -#include "vtkMedFraction.h" -#include "vtkMedLink.h" -#include "vtkMedStructElement.h" -#include "vtkMedConstantAttribute.h" -#include "vtkMedVariableAttribute.h" - -#include "vtkMultiProcessController.h" - -#include -#include -#include -using namespace std; - -// vtkCxxRevisionMacro(vtkMedDriver30, "$Revision$") -vtkStandardNewMacro(vtkMedDriver30) - -vtkMedDriver30::vtkMedDriver30() : vtkMedDriver() -{ -} - -vtkMedDriver30::~vtkMedDriver30() -{ -} - -// Description: -// load all Information data associated with this cartesian grid. -void vtkMedDriver30::ReadRegularGridInformation(vtkMedRegularGrid* grid) -{ - FileOpen open(this); - - grid->SetDimension(grid->GetParentMesh()->GetNumberOfAxis()); - - for(int axis=0; axis < grid->GetDimension(); axis++) - { - med_int size; - med_bool coordinatechangement, geotransformation; - - if ((size = MEDmeshnEntity( - this->FileId, - grid->GetParentMesh()->GetName(), - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - MED_NODE, - MED_NONE, - (med_data_type)(MED_COORDINATE_AXIS1 + axis), - MED_NO_CMODE, - &coordinatechangement, - &geotransformation)) < 0) - { - vtkErrorMacro("ERROR : number of coordinates on X axis ..."); - } - - grid->SetAxisSize(axis, size); - } - - med_int ncell = 1; - if(grid->GetAxisSize(0) > 1) - ncell *= grid->GetAxisSize(0)-1; - if(grid->GetAxisSize(1) > 1) - ncell *= grid->GetAxisSize(1)-1; - if(grid->GetAxisSize(2) > 1) - ncell *= grid->GetAxisSize(2)-1; - - vtkMedEntity entity; - entity.EntityType = MED_CELL; - - switch(grid->GetDimension()) - { - case 0 : - entity.GeometryType = MED_POINT1; - break; - case 1 : - entity.GeometryType = MED_SEG2; - break; - case 2 : - entity.GeometryType = MED_QUAD4; - break; - case 3 : - entity.GeometryType = MED_HEXA8; - break; - default : - vtkErrorMacro("Unsupported dimension for curvilinear grid : " - << grid->GetDimension()); - return; - } - - vtkMedEntityArray* array = vtkMedEntityArray::New(); - array->SetParentGrid(grid); - array->SetNumberOfEntity(ncell); - array->SetEntity(entity); - array->SetConnectivity(MED_NODAL); - grid->AppendEntityArray(array); - array->Delete(); - // this triggers the creation of undefined families - this->LoadFamilyIds(array); - -} - -void vtkMedDriver30::LoadRegularGridCoordinates(vtkMedRegularGrid* grid) -{ - FileOpen open(this); - - for(int axis=0; axis < grid->GetParentMesh()->GetNumberOfAxis(); axis++) - { - - vtkDataArray* coords = vtkMedUtilities::NewCoordArray(); - grid->SetAxisCoordinate(axis, coords); - coords->Delete(); - - coords->SetNumberOfComponents(1); - coords->SetNumberOfTuples(grid->GetAxisSize(axis)); - - if (MEDmeshGridIndexCoordinateRd( - this->FileId, - grid->GetParentMesh()->GetName(), - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - axis+1, - (med_float*)coords->GetVoidPointer(0)) < 0) - { - vtkErrorMacro("ERROR : read axis " << axis << " coordinates ..."); - grid->SetAxisCoordinate(axis, NULL); - return; - } - } - -} - -// Description: -// load all Information data associated with this standard grid. -void vtkMedDriver30::ReadCurvilinearGridInformation(vtkMedCurvilinearGrid* grid) -{ - FileOpen open(this); - - grid->SetDimension(grid->GetParentMesh()->GetNumberOfAxis()); - - med_int size; - med_bool coordinatechangement, geotransformation; - - if ((size = MEDmeshnEntity( - this->FileId, - grid->GetParentMesh()->GetName(), - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - MED_NODE, - MED_NONE, - MED_COORDINATE, - MED_NO_CMODE, - &coordinatechangement, - &geotransformation)) < 0) - { - vtkErrorMacro("ReadCurvilinearGridInformation MEDmeshnEntity"); - } - - grid->SetNumberOfPoints(size); - - med_int axissize[3]; - - if(MEDmeshGridStructRd( - this->FileId, - grid->GetParentMesh()->GetName(), - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - axissize) < 0) - { - vtkErrorMacro("ReadCurvilinearGridInformation MEDmeshGridStructRd"); - } - - switch(grid->GetDimension()) - { - case 0 : - break; - case 1 : - grid->SetAxisSize(0, (axissize[0] <= 0 ? 1: axissize[0])); - break; - case 2 : - grid->SetAxisSize(0, (axissize[0] <= 0 ? 1: axissize[0])); - grid->SetAxisSize(1, (axissize[1] <= 0 ? 1: axissize[1])); - break; - case 3 : - grid->SetAxisSize(0, (axissize[0] <= 0 ? 1: axissize[0])); - grid->SetAxisSize(1, (axissize[1] <= 0 ? 1: axissize[1])); - grid->SetAxisSize(2, (axissize[2] <= 0 ? 1: axissize[2])); - break; - default : - vtkErrorMacro("Unsupported dimension for curvilinear grid : " - << grid->GetDimension()); - return; - } - - // A test to verify the number of points : total number of - // points should be equal to the product of each axis size - med_int size2 = 0; - - if (grid->GetDimension() == 1) - { - size2 = grid->GetAxisSize(0); - } - - if (grid->GetDimension() == 2) - { - size2 = grid->GetAxisSize(0)*grid->GetAxisSize(1); - } - - if (grid->GetDimension() == 3) - { - size2 = grid->GetAxisSize(0)*grid->GetAxisSize(1)*grid->GetAxisSize(2); - } - - if(size != size2) - { - vtkErrorMacro("The total number of points of a Curvilinear grid should " - << "be the product of each axis size!"); - } - - med_int ncell = 1; - if ((grid->GetDimension() >= 1) && (grid->GetAxisSize(0) > 1)) - ncell *= grid->GetAxisSize(0)-1; - if ((grid->GetDimension() >= 2) && (grid->GetAxisSize(1) > 1)) - ncell *= grid->GetAxisSize(1)-1; - if ((grid->GetDimension() >= 3) && (grid->GetAxisSize(2) > 1)) - ncell *= grid->GetAxisSize(2)-1; - - vtkMedEntity entity; - entity.EntityType = MED_CELL; - - switch(grid->GetDimension()) - { - case 0 : - entity.GeometryType = MED_POINT1; - break; - case 1 : - entity.GeometryType = MED_SEG2; - break; - case 2 : - entity.GeometryType = MED_QUAD4; - break; - case 3 : - entity.GeometryType = MED_HEXA8; - break; - default : - vtkErrorMacro("Unsupported dimension for curvilinear grid : " - << grid->GetDimension()); - return; - } - - vtkMedEntityArray* array = vtkMedEntityArray::New(); - array->SetParentGrid(grid); - array->SetNumberOfEntity(ncell); - array->SetEntity(entity); - array->SetConnectivity(MED_NODAL); - grid->AppendEntityArray(array); - array->Delete(); - // this triggers the creation of undefined families - this->LoadFamilyIds(array); -} - -// Description : read the number of entity of all geometry type -// for a given entity type and a given connectivity mode -void vtkMedDriver30::ReadNumberOfEntity( - vtkMedUnstructuredGrid* grid, - med_entity_type entityType, - med_connectivity_mode connectivity) -{ - FileOpen open(this); - - med_bool changement, transformation; - - const char* meshName = grid->GetParentMesh()->GetName(); - - const vtkMedComputeStep& cs = grid->GetComputeStep(); - - med_int nentity = MEDmeshnEntity( - this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - entityType, - MED_GEO_ALL, - MED_UNDEF_DATATYPE , - connectivity, - &changement, - &transformation ); - - for(med_int geotypeit = 1; geotypeit <= nentity; geotypeit++) - { - // read cell informations - vtkMedEntity entity; - entity.EntityType = entityType; - - char geometryName[MED_NAME_SIZE+1] = ""; - - // this gives us the med_geometry_type - if( MEDmeshEntityInfo( FileId, meshName, - cs.TimeIt, - cs.IterationIt, - entityType, - geotypeit, - geometryName, - &entity.GeometryType) < 0) - { - vtkErrorMacro("MEDmeshEntityInfo"); - continue; - } - - entity.GeometryName = geometryName; - med_int ncell = 0; - - if(entity.GeometryType == MED_POLYGON) - { - // read the number of cells of this type - ncell = MEDmeshnEntity(this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - entity.EntityType, - entity.GeometryType, - MED_INDEX_NODE, - connectivity, - &changement, - &transformation ) - 1; - } - else if(entity.GeometryType == MED_POLYHEDRON) - { - // read the number of cells of this type - ncell = MEDmeshnEntity(this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - entity.EntityType, - entity.GeometryType, - MED_INDEX_FACE, - connectivity, - &changement, - &transformation ) - 1; - } - else - { - ncell = MEDmeshnEntity(this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - entity.EntityType, - entity.GeometryType, - MED_CONNECTIVITY, - connectivity, - &changement, - &transformation ); - } - - if(ncell > 0) - { - vtkMedEntityArray* array = vtkMedEntityArray::New(); - array->SetParentGrid(grid); - array->SetNumberOfEntity(ncell); - array->SetEntity(entity); - array->SetConnectivity(connectivity); - grid->AppendEntityArray(array); - array->Delete(); - // this triggers the creation of undefined families - this->LoadFamilyIds(array); - } - } -} - -// Description: -// load all Information data associated with this unstructured grid. -void vtkMedDriver30::ReadUnstructuredGridInformation( - vtkMedUnstructuredGrid* grid) -{ - FileOpen open(this); - - vtkMedMesh *mesh = grid->GetParentMesh(); - - const char *meshName = mesh->GetName(); - med_connectivity_mode connectivity; - - med_bool changement; - med_bool transformation; - med_int profilesize; - - char profilename[MED_NAME_SIZE+1]; - memset(profilename, '\0', MED_NAME_SIZE+1); - - vtkMedComputeStep cs = grid->GetComputeStep(); - - // first check if we have points - vtkIdType npoints = MEDmeshnEntityWithProfile( - this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - MED_NODE, - MED_NONE, - MED_COORDINATE, - MED_NODAL, - MED_COMPACT_PFLMODE, - profilename, - &profilesize, - &changement, - &transformation); - - if(npoints > 0) - { - grid->SetNumberOfPoints(npoints); - } - else - { - if(grid->GetPreviousGrid() == NULL) - { - vtkErrorMacro("No point and no previous grid"); - } - grid->SetUsePreviousCoordinates(true); - grid->SetNumberOfPoints(grid->GetPreviousGrid()->GetNumberOfPoints()); - return; - } - - this->ReadNumberOfEntity(grid, MED_CELL, MED_NODAL); - //this->ReadNumberOfEntity(grid, MED_CELL, MED_DESCENDING); // VSR: 29.11.2013: commented according to the issue 22327: descending connectivity is wrongly processed - this->ReadNumberOfEntity(grid, MED_DESCENDING_FACE, MED_NODAL); - this->ReadNumberOfEntity(grid, MED_DESCENDING_FACE, MED_DESCENDING); - this->ReadNumberOfEntity(grid, MED_DESCENDING_EDGE, MED_NODAL); - this->ReadNumberOfEntity(grid, MED_DESCENDING_EDGE, MED_DESCENDING); - this->ReadNumberOfEntity(grid, MED_STRUCT_ELEMENT, MED_NODAL); - this->ReadNumberOfEntity(grid, MED_STRUCT_ELEMENT, MED_DESCENDING); - - // create the point vtkMedEntityArray support - vtkMedEntity entity; - entity.EntityType = MED_NODE; - entity.GeometryType = MED_POINT1; - vtkMedEntityArray* pea = vtkMedEntityArray::New(); - pea->SetEntity(entity); - pea->SetParentGrid(grid); - pea->SetNumberOfEntity(grid->GetNumberOfPoints()); - grid->AppendEntityArray(pea); - pea->Delete(); - - this->LoadFamilyIds(pea); -} - -void vtkMedDriver30::ReadFamilyInformation(vtkMedMesh* mesh, vtkMedFamily* family) -{ - FileOpen open(this); - - med_int familyid; - med_int ngroup; - char* groupNames = NULL; - const char* meshName = mesh->GetName(); - - ngroup = MEDnFamilyGroup(FileId, meshName, family->GetMedIterator()); - - bool has_no_group = false; - if(ngroup <= 0) - { - if(ngroup < 0) - { - vtkErrorMacro("Error while reading the number of groups"); - } - ngroup = 1; - has_no_group = true; - } - - groupNames = new char[ngroup * MED_LNAME_SIZE + 1]; - memset(groupNames, '\0', ngroup * MED_LNAME_SIZE + 1); - - // special case for files written by med < 3, - // I have to use the 23 interface - if(mesh->GetParentFile()->GetVersionMajor() < 3) - { - med_int *attributenumber = NULL; - med_int *attributevalue = NULL; - char *attributedes = NULL; - - med_int nattr = MEDnFamily23Attribute( - this->FileId, - meshName, - family->GetMedIterator()); - - if(nattr < 0) - { - vtkErrorMacro("MEDnFamily23Attribute"); - } - - if(nattr > 0) - { - attributenumber = new med_int[nattr]; - attributevalue = new med_int[nattr]; - attributedes = new char[nattr*MED_COMMENT_SIZE+1]; - memset(attributedes, '\0', nattr*MED_COMMENT_SIZE+1); - } - - char familyName[MED_NAME_SIZE+1] = ""; - - if(MEDfamily23Info (this->FileId, - meshName, - family->GetMedIterator(), - familyName, - attributenumber, - attributevalue, - attributedes, - &familyid, - groupNames ) < 0) - { - vtkDebugMacro("MEDfamily23Info"); - } - - family->SetName(familyName); - - if(attributenumber != NULL) - delete[] attributenumber; - if(attributevalue != NULL) - delete[] attributevalue; - if(attributedes != NULL) - delete[] attributedes; - } - else - { - char familyName[MED_NAME_SIZE+1] = ""; - if(MEDfamilyInfo( this->FileId, - meshName, - family->GetMedIterator(), - familyName, - &familyid, - groupNames ) < 0) - { - vtkErrorMacro( - "vtkMedDriver30::ReadInformation(vtkMedFamily* family)" - << " cannot read family informations."); - return; - } - family->SetName(familyName); - } - - family->SetId(familyid); - - // Fix for the issue "0021721: [CEA 590] Invalid groups on cells - if( familyid == 0 ) { - family->SetPointOrCell( vtkMedUtilities::OnCell ); - mesh->AppendCellFamily( family ); - } else { - //rnv: improve algorithm to determine entity of the family: - // 1) Read Nb nodes - // 2) Read families of the nodes - // 3) If list of the families of the nodes contains familyid => vtkMedUtilities::OnPoint - // otherwise => vtkMedUtilities::OnCell - med_bool v1, v2; - med_int size = MEDmeshnEntity( - this->FileId, - meshName, - MED_NO_DT, - MED_NO_IT, - MED_NODE, - MED_NO_GEOTYPE, - MED_COORDINATE, - MED_NO_CMODE, - &v1, - &v2 ); - if( size < 0 ) { - vtkErrorMacro( "vtkMedDriver30::ReadInformation(vtkMedFamily* family)" - <<" cannot read nb Nodes" ); - return; - } - - vector n_fams; - n_fams.resize( size ); - - med_int ret_val = MEDmeshEntityFamilyNumberRd( this->FileId, - meshName, - MED_NO_DT, - MED_NO_IT, - MED_NODE, - MED_NO_GEOTYPE , - &n_fams[0] ); - // Remove ZERO FAMILY - remove( n_fams.begin(),n_fams.end(), 0 ); - - bool isOnPoints = ( ret_val >= 0) && (find( n_fams.begin(), n_fams.end(), familyid ) != n_fams.end() ); - if( isOnPoints ) { - family->SetPointOrCell(vtkMedUtilities::OnPoint); - mesh->AppendPointFamily(family); - } else { - family->SetPointOrCell(vtkMedUtilities::OnCell); - mesh->AppendCellFamily(family); - } - } - - family->AllocateNumberOfGroup(ngroup); - // if there where no group, set the name to the default value - if(has_no_group) - { - memcpy(groupNames, vtkMedUtilities::NoGroupName, - strlen(vtkMedUtilities::NoGroupName)); - } - - for(int index = 0; index < ngroup; index++) - { - char realGroupName[MED_LNAME_SIZE + 1]; - memset(realGroupName, '\0', MED_LNAME_SIZE + 1); - memcpy(realGroupName, groupNames + index * MED_LNAME_SIZE, - MED_LNAME_SIZE * sizeof(char)); - vtkMedGroup* group = mesh->GetOrCreateGroup(family->GetPointOrCell(), - realGroupName); - - family->SetGroup(index, group); - } - - delete[] groupNames; - - if(familyid == 0) - { - vtkMedFamily* famzero = vtkMedFamily::New(); - mesh->AppendPointFamily(famzero); - famzero->Delete(); - - famzero->SetName(family->GetName()); - famzero->SetMedIterator(family->GetMedIterator()); - famzero->SetId(family->GetId()); - famzero->SetPointOrCell(vtkMedUtilities::OnPoint); - famzero->AllocateNumberOfGroup(family->GetNumberOfGroup()); - for(int gid=0; gidGetNumberOfGroup(); gid++) - { - vtkMedGroup* group = mesh->GetOrCreateGroup( - vtkMedUtilities::OnPoint, - family->GetGroup(gid)->GetName()); - famzero->SetGroup(gid, group); - mesh->AppendPointGroup(group); - } - } -} - -void vtkMedDriver30::ReadLinkInformation(vtkMedLink* link) -{ - med_int size; - char linkMeshName[MED_NAME_SIZE+1] = ""; - if(MEDlinkInfo(this->FileId, - link->GetMedIterator(), - linkMeshName, - &size) < 0) - { - vtkErrorMacro("MEDlinkInfo"); - return; - } - link->SetMeshName(linkMeshName); - if(size <= 0) - return; - - char* path = new char[size + 1]; - memset(path, '\0', size+1); - if(MEDlinkRd(this->FileId, link->GetMeshName(), path) < 0) - { - vtkErrorMacro("MEDlinkRd"); - memset(path, '\0', size+1); - } - - link->SetLink(path); - - delete[] path; -} - -void vtkMedDriver30::ReadFileInformation(vtkMedFile* file) -{ - FileOpen open(this); - - char comment[MED_COMMENT_SIZE+1] = ""; - - MEDfileCommentRd(this->FileId, - comment); - - file->SetComment(comment); - - med_int major, minor, release; - MEDfileNumVersionRd(this->FileId, &major, &minor, &release); - file->SetVersionMajor(major); - file->SetVersionMinor(minor); - file->SetVersionRelease(release); - - int nlink = MEDnLink(this->FileId); - file->AllocateNumberOfLink(nlink); - for(int linkid=0; linkidGetLink(linkid); - link->SetMedIterator(linkid+1); - this->ReadLinkInformation(link); - } - - int nprof = MEDnProfile(FileId); - // Reading id s not possible in parallel if the file contains Profiles - vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController(); - if (controller != NULL) - if ((nprof != 0) && (controller->GetNumberOfProcesses() > 1)) - { - vtkWarningMacro("ATTENTION: The MED Reader cannot read profiles when used in parallel"); - return; - } - file->AllocateNumberOfProfile(nprof); - for(int i = 0; i < nprof; i++) - { - vtkMedProfile* profile = file->GetProfile(i); - profile->SetMedIterator(i + 1); - profile->SetParentFile(file); - this->ReadProfileInformation(profile); - } - - int nloc = MEDnLocalization(this->FileId); - file->AllocateNumberOfLocalization(nloc); - for(int i = 0; i < nloc; i++) - { - vtkMedLocalization* loc = file->GetLocalization(i); - loc->SetMedIterator(i + 1); - loc->SetParentFile(file); - this->ReadLocalizationInformation(loc); - } - - int nsupportmesh = MEDnSupportMesh(this->FileId); - file->AllocateNumberOfSupportMesh(nsupportmesh); - for(int i = 0; i < nsupportmesh; i++) - { - vtkMedMesh* supportmesh = file->GetSupportMesh(i); - supportmesh->SetMedIterator(i + 1); - supportmesh->SetParentFile(file); - this->ReadSupportMeshInformation(supportmesh); - } - - int nmesh = MEDnMesh(this->FileId); - file->AllocateNumberOfMesh(nmesh); - for(int i = 0; i < nmesh; i++) - { - vtkMedMesh* mesh = file->GetMesh(i); - mesh->SetMedIterator(i + 1); - mesh->SetParentFile(file); - this->ReadMeshInformation(mesh); - } - - int nfields = MEDnField(this->FileId); - file->AllocateNumberOfField(nfields); - for(int i = 0; i < nfields; i++) - { - vtkMedField* field = file->GetField(i); - field->SetMedIterator(i + 1); - field->SetParentFile(file); - this->ReadFieldInformation(field); - field->ComputeFieldType(); - while(field->HasManyFieldTypes()) - { - vtkMedField* newfield = vtkMedField::New(); - int type = field->GetFirstType(); - newfield->ExtractFieldType(field, type); - file->AppendField(newfield); - newfield->Delete(); - } - } - - int nstruct = MEDnStructElement(this->FileId); - - file->AllocateNumberOfStructElement(nstruct); - for(int i = 0; i < nstruct; i++) - { - vtkMedStructElement* structelem = file->GetStructElement(i); - structelem->SetMedIterator(i+1); - structelem->SetParentFile(file); - this->ReadStructElementInformation(structelem); - } - -} - -void vtkMedDriver30::ReadStructElementInformation( - vtkMedStructElement* structelem) -{ - - FileOpen open(this); - - char modelname[MED_NAME_SIZE+1] = ""; - med_geometry_type mgeotype; - med_int modeldim; - char supportmeshname[MED_NAME_SIZE+1] = ""; - med_entity_type sentitytype; - med_int snbofnode; - med_int snbofcell; - med_geometry_type sgeotype; - med_int nbofconstantattribute; - med_bool anyprofile; - med_int nbofvariableattribute; - - if(MEDstructElementInfo (this->FileId, - structelem->GetMedIterator(), - modelname, - &mgeotype, - &modeldim, - supportmeshname, - &sentitytype, - &snbofnode, - &snbofcell, - &sgeotype, - &nbofconstantattribute, - &anyprofile, - &nbofvariableattribute) < 0) - { - vtkErrorMacro("Error in MEDstructElementInfo"); - return; - } - structelem->SetName(modelname); - structelem->SetGeometryType(mgeotype); - structelem->SetModelDimension(modeldim); - structelem->SetSupportMeshName(supportmeshname); - structelem->SetSupportEntityType(sentitytype); - structelem->SetSupportNumberOfNode(snbofnode); - structelem->SetSupportNumberOfCell(snbofcell); - structelem->SetSupportGeometryType(sgeotype); - structelem->AllocateNumberOfConstantAttribute(nbofconstantattribute); - structelem->AllocateNumberOfVariableAttribute(nbofvariableattribute); - structelem->SetAnyProfile(anyprofile); - - for(int attit = 0; attit < nbofconstantattribute; attit ++) - { - vtkMedConstantAttribute* constatt = structelem->GetConstantAttribute(attit); - constatt->SetMedIterator(attit+1); - constatt->SetParentStructElement(structelem); - this->ReadConstantAttributeInformation(constatt); - } - - for(int attit = 0; attit < nbofvariableattribute; attit ++) - { - vtkMedVariableAttribute* varatt = structelem->GetVariableAttribute(attit); - varatt->SetMedIterator(attit+1); - varatt->SetParentStructElement(structelem); - this->ReadVariableAttributeInformation(varatt); - } -} - -void vtkMedDriver30::ReadConstantAttributeInformation( - vtkMedConstantAttribute* constAttr) -{ - - FileOpen open(this); - - char constattname[MED_NAME_SIZE+1] = ""; - med_attribute_type constatttype; - med_int nbofcomponent; - med_entity_type sentitytype; - char profilename[MED_NAME_SIZE+1] = ""; - med_int profilesize; - - if(MEDstructElementConstAttInfo( - this->FileId, - constAttr->GetParentStructElement()->GetName(), - constAttr->GetMedIterator(), - constattname, - &constatttype, - &nbofcomponent, - &sentitytype, - profilename, - &profilesize) < 0) - { - vtkErrorMacro("MEDstructElementConstAttInfo error"); - return; - } - - constAttr->SetName(constattname); - constAttr->SetAttributeType(constatttype); - constAttr->SetNumberOfComponent(nbofcomponent); - constAttr->SetSupportEntityType(sentitytype); - constAttr->SetProfileName(profilename); - constAttr->SetProfileSize(profilesize); - - vtkAbstractArray* values = vtkMedUtilities::NewArray(constatttype); - if(values == NULL) - return; - constAttr->SetValues(values); - values->Delete(); - - values->SetNumberOfComponents(nbofcomponent); - vtkIdType ntuple = 0; - if((strcmp(profilename, MED_NO_PROFILE) != 0) && - (strcmp(profilename, "\0") != 0)) - { - ntuple = profilesize; - } - else if(constAttr->GetSupportEntityType() == MED_CELL) - { - ntuple = constAttr->GetParentStructElement()->GetSupportNumberOfCell(); - } - else - { - ntuple = constAttr->GetParentStructElement()->GetSupportNumberOfNode(); - } - values->SetNumberOfTuples(ntuple); - - void* ptr = NULL; - vtkSmartPointer buffer = vtkSmartPointer::New(); - if(constatttype != MED_ATT_NAME) - { - ptr = values->GetVoidPointer(0); - } - else - { - buffer->SetNumberOfValues(MED_NAME_SIZE*nbofcomponent*ntuple); - ptr = buffer->GetVoidPointer(0); - } - - if(MEDstructElementConstAttRd (this->FileId, - constAttr->GetParentStructElement()->GetName(), - constAttr->GetName(), ptr) < 0) - { - vtkErrorMacro("MEDstructElementConstAttRd"); - return; - } - - if(constatttype == MED_ATT_NAME) - { - char name[MED_NAME_SIZE+1] = ""; - char* nameptr = (char*) ptr; - vtkStringArray* names = vtkStringArray::SafeDownCast(values); - for(vtkIdType id = 0; id < nbofcomponent*ntuple; id++) - { - memset(name, '\0', MED_NAME_SIZE+1); - strncpy(name, nameptr + id * MED_NAME_SIZE, MED_NAME_SIZE); - names->SetValue(id, name); - } - } - - return; -} - -void vtkMedDriver30::ReadVariableAttributeInformation( - vtkMedVariableAttribute* varAttr) -{ - - FileOpen open(this); - - char varattname[MED_NAME_SIZE+1] = ""; - med_attribute_type varatttype; - med_int nbofcomponent; - - if(MEDstructElementVarAttInfo ( - this->FileId, - varAttr->GetParentStructElement()->GetName(), - varAttr->GetMedIterator(), - varattname, - &varatttype, - &nbofcomponent) < 0) - { - vtkErrorMacro("MEDstructElementVarAttInfo"); - return; - } - - varAttr->SetName(varattname); - varAttr->SetAttributeType(varatttype); - varAttr->SetNumberOfComponent(nbofcomponent); - - return; -} - -void vtkMedDriver30::ReadProfileInformation(vtkMedProfile* profile) -{ - FileOpen open(this); - - med_int nelem; - char profileName[MED_NAME_SIZE+1] = ""; - - if(MEDprofileInfo(this->FileId, - profile->GetMedIterator(), - profileName, - &nelem) < 0) - { - vtkErrorMacro("cannot read information on profile" - << profile->GetMedIterator()); - } - profile->SetName(profileName); - profile->SetNumberOfElement(nelem); -} - -void vtkMedDriver30::ReadFieldInformation(vtkMedField* field) -{ - FileOpen open(this); - - if (field->GetMedIterator() == 0) - return; - - int ncomp = MEDfieldnComponent(FileId, field->GetMedIterator()); - - if(ncomp < 0) - { - field->SetNumberOfComponent(-1); - vtkErrorMacro("cannot read the number of component of field " - << field->GetMedIterator()) - return; - } - - field->SetNumberOfComponent(ncomp); - - char* units = new char[MED_SNAME_SIZE * ncomp + 1]; - char* componentNames = new char[MED_SNAME_SIZE * ncomp + 1]; - memset(units, '\0', MED_SNAME_SIZE * ncomp + 1); - memset(componentNames, '\0', MED_SNAME_SIZE * ncomp + 1); - - //med_type_champ dataType; - med_field_type dataType; - med_int nstep; - med_bool localmesh; - - char name[MED_NAME_SIZE+1] = ""; - char meshName[MED_NAME_SIZE+1] = ""; - char unit[MED_SNAME_SIZE+1] = ""; - - if( MEDfieldInfo( FileId, - field->GetMedIterator(), - name, - meshName, - &localmesh, - &dataType, - componentNames, - units, - unit, - &nstep) < 0) - { - vtkErrorMacro("cannot read the informations on field " - << field->GetMedIterator()) - return; - } - - field->SetName(name); - field->SetMeshName(meshName); - field->SetTimeUnit(unit); - field->SetDataType(dataType); - field->SetLocal(localmesh); - - for(int comp = 0; comp < ncomp; comp++) - { - char unit[MED_NAME_SIZE + 1] = ""; - memcpy(unit, units + MED_SNAME_SIZE * comp, MED_SNAME_SIZE * sizeof(char)); - field->GetUnit()->SetValue(comp, unit); - - char compName[MED_SNAME_SIZE + 1] = ""; - memcpy(compName, componentNames + MED_SNAME_SIZE * comp, MED_SNAME_SIZE - * sizeof(char)); - field->GetComponentName()->SetValue(comp, compName); - } - - delete[] units; - delete[] componentNames; - - med_int ninterp = MEDfieldnInterp(FileId, field->GetName()); - if(ninterp < 0) - { - vtkErrorMacro("Error in MEDfieldnInterp"); - return; - } - - field->AllocateNumberOfInterpolation(ninterp); - - for(med_int interpit=0; interpitGetInterpolation(interpit); - interp->SetMedIterator(interpit + 1); - this->ReadInterpolationInformation(interp); - } - - vtkMedFieldStep* previousStep = NULL; - - for(med_int csit = 0; csit < nstep; csit++) - { - vtkMedFieldStep* step = vtkMedFieldStep::New(); - step->SetMedIterator(csit + 1); - step->SetParentField(field); - this->ReadFieldStepInformation(step, csit == 0); - field->AddFieldStep(step); - step->SetPreviousStep(previousStep); - previousStep = step; - step->Delete(); - } -} - -void vtkMedDriver30::ReadFieldStepInformation(vtkMedFieldStep* step, bool readAllEntityInfo) -{ - vtkMedComputeStep cs; - vtkMedComputeStep meshcs; - vtkMedField* field = step->GetParentField(); - - FileOpen open(this); - - if( MEDfieldComputingStepMeshInfo( - FileId, - field->GetName(), - step->GetMedIterator(), - &cs.TimeIt, - &cs.IterationIt, - &cs.TimeOrFrequency, - &meshcs.TimeIt, - &meshcs.IterationIt) < 0) - { - vtkErrorMacro("Error in MEDfieldComputingStepMeshInfo"); - return; - } - - step->SetComputeStep(cs); - step->SetMeshComputeStep(meshcs); - - if(!readAllEntityInfo || step->GetEntityInfoLoaded()) - return; - - step->SetEntityInfoLoaded(1); - - vtkMedFile* file = field->GetParentFile(); - vtkMedMesh* mesh = file->GetMesh(field->GetMeshName()); - - if(mesh == NULL) - return; - - //rnv begin: fix the "22335: [CEA 954] Paravis 7.2.0 doesn't read ELNO fields" regression. - // this piece of code needed for the reading ELNO fields - std::set tmp_entities; - std::set entities; - mesh->GatherMedEntities(tmp_entities); - - std::set::iterator tmp_entity_it = tmp_entities.begin(); - while(tmp_entity_it != tmp_entities.end()) - { - vtkMedEntity entity = *tmp_entity_it; - tmp_entity_it++; - entities.insert(entity); - if(entity.EntityType == MED_CELL) - { - vtkMedEntity newEntity; - newEntity.EntityType = MED_NODE_ELEMENT; - newEntity.GeometryType = entity.GeometryType; - newEntity.GeometryName = entity.GeometryName; - entities.insert(newEntity); - } - } - //rnv end - - std::set::iterator entity_it = entities.begin(); - while(entity_it != entities.end()) - { - vtkMedEntity entity = *entity_it; - entity_it++; - - med_int nvalues = 0; - med_int nprofile; - char profilename[MED_NAME_SIZE+1] = ""; - char localizationname[MED_NAME_SIZE+1] = ""; - - nprofile = MEDfieldnProfile( - this->FileId, - field->GetName(), - step->GetComputeStep().TimeIt, - step->GetComputeStep().IterationIt, - entity.EntityType, - entity.GeometryType, - profilename, - localizationname); - if(nprofile < 0) - { - vtkErrorMacro("MEDfieldnProfile"); - continue; - } - - bool hasprofile = (nprofile > 0); - if(!hasprofile) - { - nprofile = 1; - } - - med_int profilesize; - med_int nintegrationpoint; - - for(int pid=0; pidFileId, - field->GetName(), - step->GetComputeStep().TimeIt, - step->GetComputeStep().IterationIt, - entity.EntityType, - entity.GeometryType, - medid, - MED_COMPACT_PFLMODE, - profilename, - &profilesize, - localizationname, - &nintegrationpoint); - - if(nvalues < 0) - { - vtkErrorMacro("MEDfieldnValueWithProfile"); - continue; - } - else if(nvalues > 0) - { - // I have found a profile with values, stop the loop here - break; - } - } - - if(nvalues > 0) - { - vtkMedFieldOverEntity* fieldOverEntity = vtkMedFieldOverEntity::New(); - step->AppendFieldOverEntity(fieldOverEntity); - fieldOverEntity->Delete(); - - fieldOverEntity->SetParentStep(step); - fieldOverEntity->SetEntity(entity); - - this->ReadFieldOverEntityInformation(fieldOverEntity); - } - } -} - -void vtkMedDriver30::ReadFieldOverEntityInformation(vtkMedFieldOverEntity* fieldOverEntity) -{ - FileOpen open(this); - - vtkMedFieldStep* step = fieldOverEntity->GetParentStep(); - vtkMedField* field = step->GetParentField(); - vtkMedEntity entity = fieldOverEntity->GetEntity(); - - const char* fieldName = field->GetName(); - const vtkMedComputeStep& cs = step->GetComputeStep(); - - char profilename[MED_NAME_SIZE+1] = ""; - char localizationname[MED_NAME_SIZE+1] = ""; - - med_int nProfiles = MEDfieldnProfile( - this->FileId, - fieldName, - cs.TimeIt, - cs.IterationIt, - entity.EntityType, - entity.GeometryType, - profilename, - localizationname); - - if(nProfiles < 0) - { - vtkErrorMacro("MEDfieldnProfile"); - } - else if(nProfiles == 0) - { - fieldOverEntity->SetHasProfile(0); - nProfiles = 1; - } - else - { - fieldOverEntity->SetHasProfile(1); - } - fieldOverEntity->AllocateNumberOfFieldOnProfile(nProfiles); - for(int profit = 0; profit < nProfiles; profit++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(profit); - med_int medid = (fieldOverEntity->GetHasProfile()? profit+1: -1); - fop->SetMedIterator(medid); - fop->SetParentFieldOverEntity(fieldOverEntity); - this->ReadFieldOnProfileInformation(fop); - } -} - -void vtkMedDriver30::ReadFieldOnProfileInformation(vtkMedFieldOnProfile* fop) -{ - vtkMedFieldOverEntity* fieldOverEntity = fop->GetParentFieldOverEntity(); - vtkMedFieldStep* step = fieldOverEntity->GetParentStep(); - vtkMedField* field = step->GetParentField(); - - const vtkMedComputeStep& cs = step->GetComputeStep(); - med_int profilesize; - med_int nbofintegrationpoint; - - char profileName[MED_NAME_SIZE+1] = ""; - char localizationName[MED_NAME_SIZE+1] = ""; - - med_int nvalue = MEDfieldnValueWithProfile(FileId, - field->GetName(), - cs.TimeIt, - cs.IterationIt, - fieldOverEntity->GetEntity().EntityType, - fieldOverEntity->GetEntity().GeometryType, - fop->GetMedIterator(), - MED_COMPACT_STMODE, - profileName, - &profilesize, - localizationName, - &nbofintegrationpoint); - - if(nvalue < 0) - { - vtkErrorMacro("Error while reading MEDfieldnValueWithProfile"); - } - - fop->SetProfileName(profileName); - fop->SetLocalizationName(localizationName); - fop->SetNumberOfValues(nvalue); - fop->SetNumberOfIntegrationPoint(nbofintegrationpoint); - fop->SetProfileSize(profilesize); -} - -void vtkMedDriver30::ReadMeshInformation(vtkMedMesh* mesh) -{ - FileOpen open(this); - - med_int mdim = 0; - med_int sdim = 0; - med_mesh_type meshtype; - - med_sorting_type sortingtype; - med_int nstep = 0; - med_axis_type axistype; - med_int naxis; - - if ( (naxis=MEDmeshnAxis(this->FileId, mesh->GetMedIterator())) <0 ) - { - vtkDebugMacro("Error reading mesh axis number"); - } - - if(naxis == 0) - naxis=MEDmeshnAxis(this->FileId, mesh->GetMedIterator()); - - char axisname[3*MED_SNAME_SIZE+1] = ""; - char axisunit[3*MED_SNAME_SIZE+1] = ""; - char name[MED_NAME_SIZE+1] = ""; - char description[MED_COMMENT_SIZE+1] = ""; - char timeUnit[MED_SNAME_SIZE+1] = ""; - - if( MEDmeshInfo( this->FileId, - mesh->GetMedIterator(), - name, - &sdim, - &mdim, - &meshtype, - description, - timeUnit, - &sortingtype, - &nstep, - &axistype, - axisname, - axisunit ) ) - { - vtkErrorMacro("Error reading mesh"); - } - - mesh->SetName(name); - mesh->SetDescription(description); - mesh->SetTimeUnit(timeUnit); - mesh->SetSpaceDimension(sdim); - mesh->SetMeshDimension(mdim); - mesh->SetMeshType(meshtype); - mesh->SetSortingType(sortingtype); - mesh->SetAxisType(axistype); - mesh->SetNumberOfAxis(naxis); - - for(int axis = 0; axis < naxis; axis++) - { - char theaxisname[MED_SNAME_SIZE+1] = ""; - char theaxisunit[MED_SNAME_SIZE+1] = ""; - strncpy(theaxisname, axisname + axis*MED_SNAME_SIZE, MED_SNAME_SIZE); - strncpy(theaxisunit, axisunit + axis*MED_SNAME_SIZE, MED_SNAME_SIZE); - mesh->GetAxisName()->SetValue(axis, theaxisname); - mesh->GetAxisUnit()->SetValue(axis, theaxisunit); - } - - char universalName[MED_LNAME_SIZE+1] = ""; - - if(MEDmeshUniversalNameRd(this->FileId, name, - universalName) < 0) - { - vtkDebugMacro("MEDmeshUniversalNameRd < 0"); - } - mesh->SetUniversalName(universalName); - - // read the Information data of all families. - // writing the family 0 is optional, - // but I need it, so add it if it is not here. - - med_int nfam = MEDnFamily(this->FileId, name); - - for(int index = 0; index < nfam; index++) - { - vtkMedFamily* family = vtkMedFamily::New(); - family->SetMedIterator(index + 1); - this->ReadFamilyInformation(mesh, family); - family->Delete(); - } - - // this creates a family 0 if none has been read - vtkMedFamily* familyZeroOnCell = mesh->GetOrCreateCellFamilyById(0); - vtkMedFamily* familyZeroOnPoint = mesh->GetOrCreatePointFamilyById(0); - - // Load Information regarding the grid type - if(meshtype == MED_STRUCTURED_MESH) - { - // Do it for structured data - med_grid_type mtg; - if(MEDmeshGridTypeRd(FileId, name, &mtg) < 0) - { - vtkErrorMacro("Error during structured grid Information loading."); - return; - } - mesh->SetStructuredGridType(mtg); - } - - vtkMedGrid* previousGrid = NULL; - for(int gid=1; gid <= nstep; gid++) - { - vtkMedComputeStep cs; - if(MEDmeshComputationStepInfo(FileId, - name, - gid, - &cs.TimeIt, - &cs.IterationIt, - &cs.TimeOrFrequency) < 0) - { - vtkErrorMacro("MEDmeshComputationStepInfo error"); - } - // Load Information regarding the grid type - vtkMedGrid* grid = NULL; - if(meshtype == MED_STRUCTURED_MESH) - { - switch(mesh->GetStructuredGridType()) - { - case MED_CARTESIAN_GRID: - grid = vtkMedCartesianGrid::New(); - break; - case MED_POLAR_GRID: - grid = vtkMedPolarGrid::New(); - break; - case MED_CURVILINEAR_GRID: - grid = vtkMedCurvilinearGrid::New(); - break; - default: - vtkErrorMacro("Unknown structured grid type " << mesh->GetStructuredGridType()); - return; - } - } - else //(mesh->GetType() == MED_STRUCTURED_MESH) - { - grid = vtkMedUnstructuredGrid::New(); - } - grid->SetParentMesh(mesh); - grid->SetComputeStep(cs); - this->ReadGridInformation(grid); - mesh->AddGridStep(grid); - grid->Delete(); - grid->SetPreviousGrid(previousGrid); - previousGrid = grid; - } -} - -void vtkMedDriver30::ReadLocalizationInformation(vtkMedLocalization* loc) -{ - FileOpen open(this); - - med_int ngp; - med_int spaceDimension; - med_geometry_type type_geo; - med_geometry_type sectiongeotype; - med_int nsectionmeshcell; - - char name[MED_NAME_SIZE+1] = ""; - char interpolationName[MED_NAME_SIZE+1] = ""; - char sectionName[MED_NAME_SIZE+1] = ""; - - if(MEDlocalizationInfo( - this->FileId, - loc->GetMedIterator(), - name, - &type_geo, - &spaceDimension, - &ngp, - interpolationName, - sectionName, - &nsectionmeshcell, - §iongeotype ) < 0) - { - vtkErrorMacro("Reading information on quadrature points definition : " - << loc->GetMedIterator()); - } - - loc->SetName(name); - loc->SetInterpolationName(interpolationName); - loc->SetSectionName(sectionName); - loc->SetNumberOfQuadraturePoint(ngp); - loc->SetGeometryType(type_geo); - loc->SetSpaceDimension(spaceDimension); - loc->SetNumberOfCellInSection(nsectionmeshcell); - loc->SetSectionGeometryType(sectiongeotype); - - med_float *localCoordinates = new med_float[loc->GetSizeOfPointLocalCoordinates()]; - med_float *pqLocalCoordinates = new med_float[loc->GetSizeOfQuadraturePointLocalCoordinates()]; - med_float *weights = new med_float[loc->GetSizeOfWeights()]; - - if(MEDlocalizationRd(FileId, - loc->GetName(), - MED_FULL_INTERLACE, - localCoordinates, - pqLocalCoordinates, - weights) < 0) - { - vtkErrorMacro("MEDlocalizationRd : " << loc->GetName()); - } - - vtkDoubleArray* lc = loc->GetPointLocalCoordinates(); - vtkDoubleArray *pqlc = loc->GetQuadraturePointLocalCoordinates(); - vtkDoubleArray *w = loc->GetWeights(); - - lc->SetNumberOfValues(loc->GetSizeOfPointLocalCoordinates()); - for(int i=0; iGetSizeOfPointLocalCoordinates(); i++) - { - lc->SetValue(i, localCoordinates[i]); - } - - pqlc->SetNumberOfValues(loc->GetSizeOfQuadraturePointLocalCoordinates()); - for(int i=0; iGetSizeOfQuadraturePointLocalCoordinates(); i++) - { - pqlc->SetValue(i, pqLocalCoordinates[i]); - } - - w->SetNumberOfValues(loc->GetSizeOfWeights()); - for(int i=0; iGetSizeOfWeights(); i++) - { - w->SetValue(i, weights[i]); - } -} - -void vtkMedDriver30::ReadInterpolationInformation(vtkMedInterpolation* interp) -{ - - med_geometry_type geotype; - med_bool cellnode; - med_int nbofbasisfunc; - med_int nbofvariable; - med_int maxdegree; - med_int nmaxcoef; - - char name[MED_NAME_SIZE+1] = ""; - - if(MEDinterpInfo (this->FileId, - interp->GetMedIterator(), - name, - &geotype, &cellnode, &nbofbasisfunc, - &nbofvariable, &maxdegree, &nmaxcoef) < 0) - { - vtkErrorMacro("MEDinterpInfo"); - return; - } - - interp->SetName(name); - interp->SetGeometryType(geotype); - interp->SetIsCellNode(cellnode); - interp->SetNumberOfVariable(nbofvariable); - interp->SetMaximumDegree(maxdegree); - interp->SetMaximumNumberOfCoefficient(nmaxcoef); - interp->AllocateNumberOfBasisFunction(nbofbasisfunc); - - for(int basisid=0; basisid < nbofbasisfunc; basisid++) - { - vtkMedFraction* func = interp->GetBasisFunction(basisid); - func->SetNumberOfVariable(nbofvariable); - - med_int ncoef = MEDinterpBaseFunctionCoefSize ( - this->FileId, - interp->GetName(), - basisid+1); - func->SetNumberOfCoefficients(ncoef); - - if(ncoef <= 0 || nbofvariable <= 0) - continue; - - med_int *power = new med_int[nbofvariable * ncoef]; - med_float *coefficient = new med_float[ncoef]; - - if(MEDinterpBaseFunctionRd ( - this->FileId, - interp->GetName(), - basisid+1, - &ncoef, - power, - coefficient) < 0) - { - vtkErrorMacro("MEDinterpBaseFunctionRd"); - continue; - } - vtkDoubleArray* coeffs = func->GetCoefficients(); - for(int cid=0; cid < ncoef; cid++) - { - coeffs->SetValue(cid, coefficient[cid]); - } - vtkIntArray* powers = func->GetPowers(); - for(int pid=0; pid < ncoef*nbofvariable; pid++) - { - powers->SetValue(pid, power[pid]); - } - - delete[] power; - delete[] coefficient; - } -} - -void vtkMedDriver30::ReadSupportMeshInformation( - vtkMedMesh* supportMesh) -{ - FileOpen open(this); - - char supportmeshname[MED_NAME_SIZE+1] = ""; - char description[MED_COMMENT_SIZE+1] = ""; - med_int spacedim; - med_int meshdim; - med_axis_type axistype; - char axisname[3*MED_SNAME_SIZE+1] = ""; - char axisunit[3*MED_SNAME_SIZE+1] = ""; - - if(MEDsupportMeshInfo (this->FileId, - supportMesh->GetMedIterator(), - supportmeshname, - &spacedim, - &meshdim, - description, - &axistype, - axisname, - axisunit) < 0) - { - vtkErrorMacro("MEDsupportMeshInfo"); - } - - supportMesh->SetName(supportmeshname); - supportMesh->SetDescription(description); - supportMesh->SetSpaceDimension(spacedim); - supportMesh->SetMeshDimension(meshdim); - supportMesh->SetAxisType(axistype); - for(int dim = 0; dim < 3; dim++) - { - char axisname_dim[MED_SNAME_SIZE+1] = ""; - char axisunit_dim[MED_SNAME_SIZE+1] = ""; - - strncpy(axisname_dim, axisname+dim*MED_SNAME_SIZE, MED_SNAME_SIZE); - strncpy(axisunit_dim, axisunit+dim*MED_SNAME_SIZE, MED_SNAME_SIZE); - - supportMesh->GetAxisName()->SetValue(dim, axisname_dim); - supportMesh->GetAxisUnit()->SetValue(dim, axisunit_dim); - } - - return; -} - -void vtkMedDriver30::LoadFamilyIds(vtkMedEntityArray* array) -{ - if(array->IsFamilyIdsLoaded()) - return; - - FileOpen open(this); - - vtkMedGrid* grid = array->GetParentGrid(); - - vtkMedComputeStep cs = grid->GetComputeStep(); - - // first, find if the family ids are implicit or explicit - med_bool changement, transformation; - - med_int nfamid = MEDmeshnEntity(this->FileId, - grid->GetParentMesh()->GetName(), - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetEntity().GeometryType, - MED_FAMILY_NUMBER, - MED_NO_CMODE, - &changement, - &transformation); - - if(nfamid == array->GetNumberOfEntity()) - { - - vtkMedIntArray* famIds = vtkMedIntArray::New(); - array->SetFamilyIds(famIds); - famIds->Delete(); - - famIds->SetNumberOfTuples(nfamid); - - if ( MEDmeshEntityFamilyNumberRd( - this->FileId, - grid->GetParentMesh()->GetName(), - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetEntity().GeometryType, - famIds->GetPointer(0) ) < 0) - { - vtkWarningMacro("Error loading the family ids of entity " - << array->GetEntity().EntityType - << " " << array->GetEntity().GeometryType - << " on mesh " << grid->GetParentMesh()->GetName()); - array->SetFamilyIds(NULL); - } - } - else - { - vtkDebugMacro("NumberOfEntity != Number of family ids"); - array->SetFamilyIds(NULL); - } - - array->ComputeFamilies(); -} - -void vtkMedDriver30::LoadPointGlobalIds(vtkMedGrid* grid) -{ - if(grid->IsPointGlobalIdsLoaded()) - return; - - FileOpen open(this); - - vtkMedIntArray* globalIds = vtkMedIntArray::New(); - grid->SetPointGlobalIds(globalIds); - globalIds->Delete(); - - globalIds->SetNumberOfTuples(grid->GetNumberOfPoints()); - - if( MEDmeshEntityNumberRd ( - this->FileId, - grid->GetParentMesh()->GetName(), - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - MED_NODE, - MED_NONE, - globalIds->GetPointer(0) ) < 0) - { - grid->SetPointGlobalIds(NULL); - } -} - -void vtkMedDriver30::LoadCoordinates(vtkMedGrid* grid) -{ - if(grid->IsCoordinatesLoaded()) - return; - - vtkMedRegularGrid* rgrid = vtkMedRegularGrid::SafeDownCast(grid); - if(rgrid != NULL) - { - this->LoadRegularGridCoordinates(rgrid); - return; - } - - vtkMedUnstructuredGrid* ugrid = vtkMedUnstructuredGrid::SafeDownCast(grid); - vtkMedCurvilinearGrid* cgrid = vtkMedCurvilinearGrid::SafeDownCast(grid); - if(ugrid == NULL && cgrid == NULL) - { - //TODO : deal with structured grids - vtkWarningMacro("this kind of grid is not yet supported"); - return; - } - - if(grid->GetUsePreviousCoordinates()) - { - vtkMedGrid* previousgrid = grid->GetPreviousGrid(); - if(previousgrid == NULL) - { - vtkErrorMacro("coordiantes have not changed, " - << "but there is no previous grid!"); - return; - } - - this->LoadCoordinates(previousgrid); - if(ugrid != NULL) - ugrid->SetCoordinates(vtkMedUnstructuredGrid::SafeDownCast(previousgrid) - ->GetCoordinates()); - if(cgrid != NULL) - cgrid->SetCoordinates(vtkMedCurvilinearGrid::SafeDownCast(previousgrid) - ->GetCoordinates()); - } - else - { - - FileOpen open(this); - - vtkDataArray* coords = vtkMedUtilities::NewCoordArray(); - if(ugrid != NULL) - ugrid->SetCoordinates(coords); - if(cgrid != NULL) - cgrid->SetCoordinates(coords); - coords->Delete(); - - vtkMedComputeStep cs = grid->GetComputeStep(); - - coords->SetNumberOfComponents(grid->GetParentMesh()->GetSpaceDimension()); - coords->SetNumberOfTuples(grid->GetNumberOfPoints()); - - if ( MEDmeshNodeCoordinateRd( this->FileId, - grid->GetParentMesh()->GetName(), - cs.TimeIt, - cs.IterationIt, - MED_FULL_INTERLACE, - (med_float*) coords->GetVoidPointer(0) ) < 0) - { - vtkErrorMacro("Load Coordinates for mesh " - << grid->GetParentMesh()->GetName()); - } - } -} - -void vtkMedDriver30::LoadProfile(vtkMedProfile* profile) -{ - if(!profile || profile->IsLoaded()) - return; - - FileOpen open(this); - - vtkMedIntArray* indices = vtkMedIntArray::New(); - profile->SetIds(indices); - indices->Delete(); - - indices->SetNumberOfTuples(profile->GetNumberOfElement()); - - char name[MED_NAME_SIZE+1] = ""; - - if( MEDprofileRd(this->FileId, - profile->GetName(), - indices->GetPointer(0) ) < 0) - { - vtkErrorMacro("Reading profile indices "); - } -} - -void vtkMedDriver30::LoadConnectivity(vtkMedEntityArray* array) -{ - if(array->IsConnectivityLoaded()) - return; - - FileOpen open(this); - - vtkMedGrid* grid = array->GetParentGrid(); - - grid = array->GetParentGrid(); - - const char* meshName = grid->GetParentMesh()->GetName(); - - vtkMedIntArray* conn = vtkMedIntArray::New(); - array->SetConnectivityArray(conn); - conn->Delete(); - - vtkMedComputeStep cs = grid->GetComputeStep(); - - med_bool change; - med_bool transformation; - - if(array->GetEntity().GeometryType == MED_POLYGON) - { - // first check if we have points - med_int connSize = MEDmeshnEntity( - this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - MED_POLYGON, - MED_CONNECTIVITY, - array->GetConnectivity(), - &change, - &transformation); - - if (connSize < 0) - { - vtkErrorMacro(<< "Error while reading polygons connectivity size." - << endl ); - return; - } - - conn->SetNumberOfTuples(connSize); - - // How many polygon in the mesh in nodal connectivity mode - // For the polygons, we get the size of array index - med_int indexsize; - if ((indexsize = MEDmeshnEntity(this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - MED_POLYGON, - MED_INDEX_NODE, - array->GetConnectivity(), - &change, - &transformation )) < 0) - { - vtkErrorMacro(<< "Error while reading polygons array index." << endl ); - return; - } - - vtkMedIntArray* index = vtkMedIntArray::New(); - array->SetFaceIndex(index); - index->Delete(); - - index->SetNumberOfTuples( indexsize ); - - if ( MEDmeshPolygonRd(this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetConnectivity(), - index->GetPointer(0), - conn->GetPointer(0) ) < 0) - { - vtkErrorMacro(<< "MEDmeshPolygonRd"); - return; - } - } - else if(array->GetEntity().GeometryType == MED_POLYHEDRON) - { - - vtkIdType connSize = MEDmeshnEntity(this->FileId, - meshName, - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - array->GetEntity().EntityType, - MED_POLYHEDRON, - MED_CONNECTIVITY, - array->GetConnectivity(), - &change, - &transformation); - if (connSize < 0) - { - vtkErrorMacro(<< "Error while reading polyhedrons connectivity size." - << endl ); - return; - } - - conn->SetNumberOfTuples(connSize); - - vtkMedIntArray* faceIndex = vtkMedIntArray::New(); - array->SetFaceIndex(faceIndex); - faceIndex->Delete(); - - vtkMedIntArray* nodeIndex = vtkMedIntArray::New(); - array->SetNodeIndex(nodeIndex); - nodeIndex->Delete(); - - vtkIdType np = array->GetNumberOfEntity() + 1; - faceIndex->SetNumberOfTuples(np); - - med_int nodeIndexSize; - - if ((nodeIndexSize = MEDmeshnEntity(this->FileId, - meshName, - grid->GetComputeStep().TimeIt, - grid->GetComputeStep().IterationIt, - array->GetEntity().EntityType, - MED_POLYHEDRON, - MED_INDEX_NODE, - array->GetConnectivity(), - &change, - &transformation )) < 0) - { - vtkErrorMacro(<< "Error while reading polygons array index." << endl ); - return; - } - - nodeIndex->SetNumberOfTuples(nodeIndexSize); - - if (MEDmeshPolyhedronRd(this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetConnectivity(), - faceIndex->GetPointer(0), - nodeIndex->GetPointer(0), - conn->GetPointer(0) ) < 0) - { - vtkErrorMacro("Error while reading connectivity of polyhedrons"); - return; - } - - } - else - { - bool doReadConnectivity = true; - if(array->GetConnectivity() == MED_NODAL) - { - if(array->GetEntity().EntityType == MED_STRUCT_ELEMENT) - { - std::cout << " -- MED_STRUCT_ELEMENT --" << std::endl; - if(array->GetStructElement() == NULL) - { - vtkErrorMacro("Entity type = MED_STRUCT_ELEMENT, but StructElement is not set!"); - return; - } - vtkIdType ntuple = array->GetNumberOfEntity() - * array->GetStructElement()->GetConnectivitySize(); - - conn->SetNumberOfTuples(ntuple); - // particles are special : connectivity is not stored in the med file - if(strcmp(array->GetStructElement()->GetName(), MED_PARTICLE_NAME) == 0 ) - { - for(vtkIdType cellId = 0; cellId < ntuple; cellId++) - { - conn->SetValue(cellId, cellId+1); - } - doReadConnectivity = false; - } - } - else - { - conn->SetNumberOfTuples(array->GetNumberOfEntity() - * vtkMedUtilities::GetNumberOfPoint( - array->GetEntity().GeometryType)); - } - } - else - { - conn->SetNumberOfTuples(array->GetNumberOfEntity() - * vtkMedUtilities::GetNumberOfSubEntity( - array->GetEntity().GeometryType)); - } - - if (this->ParallelFileId == -1) // also (array->GetFilter() == NULL) - { - if ( (MEDmeshElementConnectivityRd( - this->FileId, - meshName, - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetEntity().GeometryType, - array->GetConnectivity(), - MED_FULL_INTERLACE, - conn->GetPointer(0)) ) < 0) - { - vtkErrorMacro("Error while load connectivity of cells " - << array->GetEntity().GeometryType); - } - } - else - { - med_filter filter = MED_FILTER_INIT; - - int start; - int stride; - int count; - int blocksize; - int lastblocksize; - array->GetFilter()->GetFilterSizes(start, stride, count, - blocksize, lastblocksize ); - - med_int nbofconstituentpervalue = vtkMedUtilities::GetNumberOfNodes( - array->GetEntity().GeometryType); - - if ( MEDfilterBlockOfEntityCr( this->ParallelFileId, - array->GetNumberOfEntity(), - 1, // one is for mesh elements, more than 1 is for fields - nbofconstituentpervalue, - MED_ALL_CONSTITUENT, - MED_FULL_INTERLACE, - MED_COMPACT_STMODE, - MED_NO_PROFILE, - (med_size)start, - (med_size)stride, - (med_size)count, - (med_size)blocksize, - (med_size)lastblocksize, - &filter ) < 0 ) - { - vtkErrorMacro("Filter creation "); - } - - if ( (MEDmeshElementConnectivityAdvancedRd( - this->ParallelFileId, - meshName, - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetEntity().GeometryType, - array->GetConnectivity(), - &filter, - conn->GetPointer(0)) ) < 0) - { - vtkErrorMacro("Error while load connectivity of cells " - << array->GetEntity().GeometryType); - } - - if ( MEDfilterClose( &filter ) < 0) - { - vtkErrorMacro("ERROR : filter closing ..."); - } - - } - } -} - -void vtkMedDriver30::LoadCellGlobalIds(vtkMedEntityArray* array) -{ - if(array->IsGlobalIdsLoaded()) - return; - - FileOpen open(this); - - vtkMedIntArray* globalIds = vtkMedIntArray::New(); - array->SetGlobalIds(globalIds); - globalIds->Delete(); - - globalIds->SetNumberOfTuples(array->GetNumberOfEntity()); - - vtkMedGrid* grid = array->GetParentGrid(); - vtkMedComputeStep cs = grid->GetComputeStep(); - - if( MEDmeshEntityNumberRd ( - this->FileId, - grid->GetParentMesh()->GetName(), - cs.TimeIt, - cs.IterationIt, - array->GetEntity().EntityType, - array->GetEntity().GeometryType, - globalIds->GetPointer(0) ) < 0) - { - array->SetGlobalIds(NULL); - } -} - -void vtkMedDriver30::LoadField(vtkMedFieldOnProfile* fop, med_storage_mode mode) -{ - FileOpen open(this); - - vtkMedFieldOverEntity* fieldOverEntity = fop->GetParentFieldOverEntity(); - vtkMedFieldStep *step = fieldOverEntity->GetParentStep(); - vtkMedField* field = step->GetParentField(); - const vtkMedComputeStep& cs = step->GetComputeStep(); - - vtkDataArray* data = vtkMedUtilities::NewArray(field->GetDataType()); - fop->SetData(data); - data->Delete(); - - med_int size; - if(mode == MED_COMPACT_STMODE) - { - size = fop->GetNumberOfValues(); - } - else - { - med_int profilesize; - med_int nbofintegrationpoint; - char profileName[MED_NAME_SIZE+1] = ""; - char localizationName[MED_NAME_SIZE+1] = ""; - size = MEDfieldnValueWithProfile(this->FileId, - field->GetName(), - cs.TimeIt, - cs.IterationIt, - fieldOverEntity->GetEntity().EntityType, - fieldOverEntity->GetEntity().GeometryType, - fop->GetMedIterator(), - MED_GLOBAL_STMODE, - profileName, - &profilesize, - localizationName, - &nbofintegrationpoint); - } - - if(fop->GetNumberOfIntegrationPoint() > 1) - { - size *= fop->GetNumberOfIntegrationPoint(); - } - - data->SetNumberOfComponents(field->GetNumberOfComponent()); - data->SetNumberOfTuples(size); - if (this->ParallelFileId == -1) - { - if ( MEDfieldValueWithProfileRd( - this->FileId, - field->GetName(), - cs.TimeIt, - cs.IterationIt, - fieldOverEntity->GetEntity().EntityType, - fieldOverEntity->GetEntity().GeometryType, - mode, - fop->GetProfileName(), - MED_FULL_INTERLACE, - MED_ALL_CONSTITUENT, - (unsigned char*) data->GetVoidPointer(0) ) < 0) - { - vtkErrorMacro("Error on MEDfieldValueWithProfileRd"); - } - } - else - { - if (field->GetFieldType() == vtkMedField::CellField) - { - med_filter filter = MED_FILTER_INIT; - - int start; - int stride; - int count; - int blocksize; - int lastblocksize; - fop->GetFilter()->GetFilterSizes(start, stride, count, - blocksize, lastblocksize ); - - if ( MEDfilterBlockOfEntityCr( this->ParallelFileId, - fop->GetNumberOfValues(), - 1, // one is for mesh elements, more than 1 is for fields - field->GetNumberOfComponent(), - MED_ALL_CONSTITUENT, - MED_FULL_INTERLACE, - MED_COMPACT_STMODE, - MED_NO_PROFILE, - (med_size)start, - (med_size)stride, - (med_size)count, - (med_size)blocksize, - (med_size)lastblocksize, - &filter ) < 0 ) - { - vtkErrorMacro("Filter creation "); - } - - if ( MEDfieldValueAdvancedRd( - this->ParallelFileId, - field->GetName(), - cs.TimeIt, - cs.IterationIt, - fieldOverEntity->GetEntity().EntityType, - fieldOverEntity->GetEntity().GeometryType, - &filter, - (unsigned char*) data->GetVoidPointer(0) ) < 0) - { - vtkErrorMacro("Error on MEDfieldValueAdvancedRd"); - } - - if ( MEDfilterClose( &filter ) < 0) - { - vtkErrorMacro("ERROR : filter closing ..."); - } - } - else - {//TODO : option utilisateur pour desactiver ou non les champs avec profile en // - if ( MEDfieldValueWithProfileRd( - this->FileId, - field->GetName(), - cs.TimeIt, - cs.IterationIt, - fieldOverEntity->GetEntity().EntityType, - fieldOverEntity->GetEntity().GeometryType, - mode, - fop->GetProfileName(), - MED_FULL_INTERLACE, - MED_ALL_CONSTITUENT, - (unsigned char*) data->GetVoidPointer(0) ) < 0) - { - vtkErrorMacro("Error on MEDfieldValueWithProfileRd"); - } - } - } -} - -void vtkMedDriver30::LoadVariableAttribute(vtkMedVariableAttribute* varatt, - vtkMedEntityArray* array) -{ - FileOpen open(this); - - void *value = NULL; - - vtkAbstractArray* valuearray = array->GetVariableAttributeValue(varatt); - // first test if this is already loaded - if(valuearray != NULL && valuearray->GetNumberOfTuples() > 0) - return; - - if(valuearray == NULL) - { - valuearray = vtkMedUtilities::NewArray(varatt->GetAttributeType()); - array->SetVariableAttributeValues(varatt, valuearray); - valuearray->Delete(); - } - - valuearray->SetNumberOfComponents(varatt->GetNumberOfComponent()); - valuearray->SetNumberOfTuples(array->GetNumberOfEntity()); - valuearray->SetName(varatt->GetName()); - - vtkSmartPointer chararray = vtkSmartPointer::New(); - - if(varatt->GetAttributeType() != MED_ATT_NAME) - { - value = valuearray->GetVoidPointer(0); - } - else - { - chararray->SetNumberOfValues(varatt->GetNumberOfComponent() * - array->GetNumberOfEntity() * - MED_NAME_SIZE); - - value = chararray->GetVoidPointer(0); - } - - vtkMedComputeStep cs = array->GetParentGrid()->GetComputeStep(); - - if(MEDmeshStructElementVarAttRd( - this->FileId, - array->GetParentGrid()->GetParentMesh()->GetName(), - cs.TimeIt, - cs.IterationIt, - varatt->GetParentStructElement()->GetGeometryType(), - varatt->GetName(), - value) < 0) - { - - if(cs.IterationIt == MED_NO_IT && cs.TimeIt == MED_NO_DT && cs.TimeOrFrequency == MED_UNDEF_DT) - { - vtkErrorMacro("MEDmeshStructElementVarAttRd"); - return; - } - // try to see if I can reuse - // the variable attributes of the NO_DT, NO_IT compute step - vtkMedComputeStep nocs; - nocs.IterationIt = MED_NO_IT; - nocs.TimeIt = MED_NO_DT; - nocs.TimeOrFrequency = MED_UNDEF_DT; - vtkMedEntityArray* nocs_array = - array->GetParentGrid()->GetParentMesh()->GetGridStep(nocs)->GetEntityArray(array->GetEntity()); - if(nocs_array == NULL) - { - nocs_array = array->GetParentGrid()->GetParentMesh()->GetGridStep(0)->GetEntityArray(array->GetEntity()); - } - - if(nocs_array == NULL || nocs_array == array) - { - // try to force load the default compute step. - if(MEDmeshStructElementVarAttRd( - this->FileId, - array->GetParentGrid()->GetParentMesh()->GetName(), - nocs.TimeIt, - nocs.IterationIt, - varatt->GetParentStructElement()->GetGeometryType(), - varatt->GetName(), - value) < 0) - { - vtkErrorMacro("MEDmeshStructElementVarAttRd"); - return; - } - } - else - { - this->LoadVariableAttribute(varatt, nocs_array); - array->SetVariableAttributeValues(varatt, nocs_array->GetVariableAttributeValue(varatt)); - return; - } - } - - // If I am here, it means that I read the values - if(varatt->GetAttributeType() == MED_ATT_NAME) - { - char current_name[MED_NAME_SIZE+1] = ""; - vtkStringArray* sarray = vtkStringArray::SafeDownCast(valuearray); - for(vtkIdType id = 0; id < varatt->GetNumberOfComponent() * - array->GetNumberOfEntity(); id++) - { - memset(current_name, '\0', MED_NAME_SIZE+1); - strncpy(current_name, ((char*)value) + id*MED_NAME_SIZE, MED_NAME_SIZE); - sarray->SetValue(id, current_name); - } - } - - return; -} - -void vtkMedDriver30::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedDriver30.h b/src/Plugins/MedReader/IO/vtkMedDriver30.h deleted file mode 100644 index 86890dda..00000000 --- a/src/Plugins/MedReader/IO/vtkMedDriver30.h +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedDriver30_h_ -#define __vtkMedDriver30_h_ - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedDriver.h" - -class vtkMedFile; -class vtkMedMesh; -class vtkMedField; -class vtkMedFamily; -class vtkMedRegularGrid; -class vtkMedCurvilinearGrid; -class vtkMedUnstructuredGrid; -class vtkMedLocalization; -class vtkMedProfile; -class vtkMedFieldOverEntity; -class vtkMedEntityArray; -class vtkMedFieldStep; -class vtkMedLink; -class vtkMedStructElement; -class vtkMedConstantAttribute; -class vtkMedVariableAttribute; - -class VTK_EXPORT vtkMedDriver30: public vtkMedDriver -{ -public: - static vtkMedDriver30* New(); - vtkTypeMacro(vtkMedDriver30, vtkMedDriver) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // load all meta data associated with this file. - virtual void ReadFileInformation(vtkMedFile*); - - // Description: - // load all meta data associated with this mesh. - virtual void ReadMeshInformation(vtkMedMesh*); - - // Description: - // load all meta data associated with this field. - virtual void ReadFieldInformation(vtkMedField*); - - // Description: - // load all meta data associated with this regular (Cartesian or polar) grid. - virtual void ReadRegularGridInformation(vtkMedRegularGrid*); - - // Description: - // load all meta data associated with this standard grid. - virtual void ReadCurvilinearGridInformation(vtkMedCurvilinearGrid*); - - // Description: - // load all meta data associated with this unstructured grid. - virtual void ReadUnstructuredGridInformation(vtkMedUnstructuredGrid*); - - // Description: - // load all meta data associated with this family. - virtual void ReadFamilyInformation(vtkMedMesh*, vtkMedFamily*); - - // Description: - // load all meta data associated with this family. - virtual void ReadProfileInformation(vtkMedProfile*); - - // Description: - // load information on a field and a given cell type at a given step - virtual void ReadFieldOverEntityInformation(vtkMedFieldOverEntity*); - - // Description: - // load information related to the given quadrature scheme definition - virtual void ReadLocalizationInformation(vtkMedLocalization*); - - // Description: - // load all information associated witht this field step - virtual void ReadFieldStepInformation(vtkMedFieldStep*, bool readAllEntityInfo); - - // Description: - // load all information related to this interpolation function - virtual void ReadInterpolationInformation(vtkMedInterpolation*); - - // Description: - // load all information related to this field on this profile - virtual void ReadFieldOnProfileInformation(vtkMedFieldOnProfile*); - - // Description: - // load all information related to this field on this profile - virtual void ReadLinkInformation(vtkMedLink*); - - // Description: - // read all information related to the structural elements models - // in this file - virtual void ReadStructElementInformation(vtkMedStructElement*); - - // Description: - // read all information related to the support mesh - // in this file - virtual void ReadSupportMeshInformation(vtkMedMesh*); - - // Description: - // read all information related to the support mesh - // in this file - virtual void ReadConstantAttributeInformation(vtkMedConstantAttribute*); - - // Description: - // read all information related to the support mesh - // in this file - virtual void ReadVariableAttributeInformation(vtkMedVariableAttribute*); - - // Description: - // load the field on this profile - virtual void LoadField(vtkMedFieldOnProfile*, med_storage_mode mode); - - // Description: - // Load the indices of the profile - virtual void LoadProfile(vtkMedProfile* profile); - - // Description: - // Load the values of the given step -// void Load(vtkMedFieldOnProfile*); - - virtual void LoadFamilyIds(vtkMedEntityArray*); - - virtual void LoadCoordinates(vtkMedGrid*); - - virtual void LoadPointGlobalIds(vtkMedGrid*); - - //virtual void LoadFamilyIds(vtkMedGrid*); - - virtual void LoadConnectivity(vtkMedEntityArray*); - - virtual void LoadCellGlobalIds(vtkMedEntityArray*); - - virtual void LoadRegularGridCoordinates(vtkMedRegularGrid*); - - virtual void LoadVariableAttribute(vtkMedVariableAttribute*, - vtkMedEntityArray*); - -protected: - vtkMedDriver30(); - ~vtkMedDriver30(); - - void ReadNumberOfEntity(vtkMedUnstructuredGrid*, - med_entity_type, med_connectivity_mode); - -private: - vtkMedDriver30(const vtkMedDriver30&); // Not implemented. - void operator=(const vtkMedDriver30&); // Not implemented. -}; - -#endif //__vtkMedDriver30_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedEntityArray.cxx b/src/Plugins/MedReader/IO/vtkMedEntityArray.cxx deleted file mode 100644 index 0960055c..00000000 --- a/src/Plugins/MedReader/IO/vtkMedEntityArray.cxx +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedEntityArray.h" - -#include "vtkObjectFactory.h" -#include "vtkMedIntArray.h" -#include "vtkMedUtilities.h" -#include "vtkMedFamily.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedMesh.h" -#include "vtkMedGrid.h" -#include "vtkMedUnstructuredGrid.h" -#include "vtkMedRegularGrid.h" -#include "vtkMedCurvilinearGrid.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedStructElement.h" - -#include "vtkIdList.h" - -#include -using std::set; - -vtkCxxSetObjectVectorMacro(vtkMedEntityArray, FamilyOnEntity, vtkMedFamilyOnEntity); -vtkCxxGetObjectVectorMacro(vtkMedEntityArray, FamilyOnEntity, vtkMedFamilyOnEntity); -vtkCxxSetObjectMacro(vtkMedEntityArray,FamilyIds,vtkMedIntArray); -vtkCxxSetObjectMacro(vtkMedEntityArray,GlobalIds,vtkMedIntArray); -vtkCxxSetObjectMacro(vtkMedEntityArray,ConnectivityArray,vtkMedIntArray); -vtkCxxSetObjectMacro(vtkMedEntityArray,FaceIndex,vtkMedIntArray); -vtkCxxSetObjectMacro(vtkMedEntityArray,NodeIndex,vtkMedIntArray); - -vtkCxxSetObjectMacro(vtkMedEntityArray,ParentGrid,vtkMedGrid); -vtkCxxSetObjectMacro(vtkMedEntityArray,StructElement,vtkMedStructElement); - -// vtkCxxRevisionMacro(vtkMedEntityArray, "$Revision$"); -vtkStandardNewMacro(vtkMedEntityArray); - -vtkMedEntityArray::vtkMedEntityArray() -{ - this->NumberOfEntity = 0; - this->Connectivity = MED_NODAL; - this->FamilyIds = NULL; - this->GlobalIds = NULL; - this->ConnectivityArray = NULL; - this->FaceIndex = NULL; - this->NodeIndex = NULL; - this->InitialGlobalId = 0; - this->FamilyOnEntity = new vtkObjectVector (); - this->FamilyIdStatus = vtkMedEntityArray::FAMILY_ID_NOT_LOADED; - this->ParentGrid = NULL; - this->StructElement = NULL; - //this->Filter = NULL; -} - -vtkMedEntityArray::~vtkMedEntityArray() -{ - this->SetFamilyIds(NULL); - this->SetGlobalIds(NULL); - this->SetConnectivityArray(NULL); - this->SetFaceIndex(NULL); - this->SetNodeIndex(NULL); - delete this->FamilyOnEntity; - this->SetParentGrid(NULL); - this->SetStructElement(NULL); - //this->SetFilter(NULL); -} - -void vtkMedEntityArray::Initialize() -{ - this->SetFamilyIds(NULL); - this->SetGlobalIds(NULL); - this->SetConnectivityArray(NULL); - this->SetFaceIndex(NULL); - this->SetNodeIndex(NULL); - this->FamilyOnEntity->clear(); - this->FamilyIdStatus = FAMILY_ID_NOT_LOADED; -} - -void vtkMedEntityArray::ComputeFamilies() -{ - this->FamilyOnEntity->clear(); - vtkMedMesh* mesh = this->ParentGrid->GetParentMesh(); - - if(this->FamilyIds == NULL) - { - vtkMedFamilyOnEntity* foe = vtkMedFamilyOnEntity::New(); - foe->SetParentGrid(this->ParentGrid); - this->AppendFamilyOnEntity(foe); - foe->Delete(); - if(this->GetEntity().EntityType != MED_NODE) - { - foe->SetFamily(mesh->GetOrCreateCellFamilyById(0)); - } - else - { - foe->SetFamily(mesh->GetOrCreatePointFamilyById(0)); - } - foe->SetEntityArray(this); - this->FamilyIdStatus = vtkMedEntityArray::FAMILY_ID_IMPLICIT; - return; - } - - this->FamilyIdStatus = vtkMedEntityArray::FAMILY_ID_EXPLICIT; - - set idset; - for (vtkIdType index = 0; index < this->FamilyIds->GetNumberOfTuples(); index++) - { - med_int id = this->FamilyIds->GetValue(index); - idset.insert(id); - } - - for (set::iterator it = idset.begin(); it != idset.end(); it++) - { - vtkMedFamilyOnEntity* foe = vtkMedFamilyOnEntity::New(); - foe->SetParentGrid(this->ParentGrid); - this->AppendFamilyOnEntity(foe); - foe->Delete(); - if(this->GetEntity().EntityType != MED_NODE) - { - foe->SetFamily(mesh->GetOrCreateCellFamilyById(*it)); - } - else - { - foe->SetFamily(mesh->GetOrCreatePointFamilyById(*it)); - } - foe->SetEntityArray(this); - } -} - -med_int vtkMedEntityArray::GetFamilyId(med_int id) -{ - if(this->FamilyIdStatus == FAMILY_ID_IMPLICIT) - return 0; - if(this->FamilyIdStatus == FAMILY_ID_NOT_LOADED) - { - vtkErrorMacro("You have to load family ids before asking for it!"); - } - return this->FamilyIds->GetValue(id); -} - -int vtkMedEntityArray::HasFamily(vtkMedFamily* family) -{ - for (int i = 0; i < this->FamilyOnEntity->size(); i++) - { - vtkMedFamilyOnEntity* foe = this->FamilyOnEntity->at(i); - if(foe->GetFamily() == family) - return 1; - } - return 0; -} - -int vtkMedEntityArray::IsConnectivityLoaded() -{ - // Entity Arrays representing something else than cells - // have no connectivity - - if(vtkMedUnstructuredGrid::SafeDownCast(this->GetParentGrid()) == NULL) - return 1; - - if( this->Entity.EntityType != MED_CELL && - this->Entity.EntityType != MED_DESCENDING_FACE && - this->Entity.EntityType != MED_DESCENDING_EDGE && - this->Entity.EntityType != MED_STRUCT_ELEMENT) - return 1; - - if(this->ConnectivityArray == NULL) - return 0; - - if(this->Connectivity == MED_NODAL && this->Entity.EntityType != MED_STRUCT_ELEMENT) - { - vtkIdType connSize = this->NumberOfEntity - * vtkMedUtilities::GetNumberOfPoint(this->Entity.GeometryType); - - return connSize == this->ConnectivityArray->GetNumberOfTuples(); - } - else if (this->Connectivity == MED_NODAL && this->Entity.EntityType == MED_STRUCT_ELEMENT) - { - if(this->StructElement == NULL) - return 1; - - vtkIdType connSize = this->NumberOfEntity - * this->StructElement->GetConnectivitySize(); - - return connSize == this->ConnectivityArray->GetNumberOfTuples(); - } - else - { - vtkIdType connSize = this->NumberOfEntity - * vtkMedUtilities::GetNumberOfSubEntity(this->Entity.GeometryType); - - return connSize == this->ConnectivityArray->GetNumberOfTuples(); - } -} - -int vtkMedEntityArray::IsFamilyIdsLoaded() -{ - return this->FamilyIdStatus != vtkMedEntityArray::FAMILY_ID_NOT_LOADED;; -} - -int vtkMedEntityArray::IsGlobalIdsLoaded() -{ - return this->GlobalIds != NULL && this->GlobalIds->GetNumberOfTuples() - == this->NumberOfEntity; -} - -void vtkMedEntityArray::GetCellVertices(vtkIdType index, vtkIdList* ids) -{ - ids->Initialize(); - - if(this->Entity.EntityType == MED_NODE) - { - ids->InsertNextId(index); - return; - } - - if( this->Entity.EntityType != MED_CELL && - this->Entity.EntityType != MED_DESCENDING_FACE && - this->Entity.EntityType != MED_DESCENDING_EDGE && - this->Entity.EntityType != MED_STRUCT_ELEMENT) - { - vtkErrorMacro("This reader is not compatible with those entities (yet)..."); - return; - } - - if(vtkMedUnstructuredGrid::SafeDownCast(this->ParentGrid) == NULL) - { - // this is a structured grid, connectivity is implicit... - - if(this->Entity.GeometryType == MED_POINT1) - { - // degenerate case if there is only one point - ids->InsertNextId(0); - return; - } - if(this->Entity.GeometryType == MED_SEG2) - { - // line - ids->InsertNextId(index); - ids->InsertNextId(index+1); - return; - } - vtkMedRegularGrid* vtkrgrid = vtkMedRegularGrid::SafeDownCast( - this->GetParentGrid()); - vtkMedCurvilinearGrid* vtkcgrid = vtkMedCurvilinearGrid::SafeDownCast( - this->GetParentGrid()); - vtkIdType xncell = 0; - vtkIdType yncell = 0; - vtkIdType zncell = 0; - vtkIdType xnpts = 1; - vtkIdType ynpts = 1; - vtkIdType znpts = 1; - if(vtkrgrid!=NULL) - { - xncell = vtkrgrid->GetAxisSize(0)-1; - yncell = vtkrgrid->GetAxisSize(1)-1; - zncell = vtkrgrid->GetAxisSize(2)-1; - xnpts = vtkrgrid->GetAxisSize(0); - ynpts = vtkrgrid->GetAxisSize(1); - znpts = vtkrgrid->GetAxisSize(2); - } - if(vtkcgrid != NULL) - { - xncell = vtkcgrid->GetAxisSize(0)-1; - yncell = vtkcgrid->GetAxisSize(1)-1; - zncell = vtkcgrid->GetAxisSize(2)-1; - xnpts = vtkcgrid->GetAxisSize(0); - ynpts = vtkcgrid->GetAxisSize(1); - znpts = vtkcgrid->GetAxisSize(2); - } - vtkIdType xindex = index % xncell; - if(xncell <= 0) - return; - - vtkIdType yindex = index / xncell; - - if(this->Entity.GeometryType == MED_QUAD4) - { - // plane - - ids->InsertNextId(xindex + yindex*xnpts); - ids->InsertNextId(xindex + 1 + yindex*xnpts); - ids->InsertNextId(xindex + yindex*xnpts); - ids->InsertNextId(xindex + 1 + (yindex + 1)*xnpts); - return; - } - - if(yncell <= 0) - return; - - vtkIdType zindex = index / (xncell*yncell); - - if(this->Entity.GeometryType == MED_HEXA8) - { - // volume - ids->InsertNextId(xindex + (yindex )*xnpts + (zindex )*xnpts*ynpts); - ids->InsertNextId(xindex+1 + (yindex )*xnpts + (zindex )*xnpts*ynpts); - ids->InsertNextId(xindex + (yindex+1)*xnpts + (zindex )*xnpts*ynpts); - ids->InsertNextId(xindex+1 + (yindex+1)*xnpts + (zindex )*xnpts*ynpts); - ids->InsertNextId(xindex + (yindex )*xnpts + (zindex+1)*xnpts*ynpts); - ids->InsertNextId(xindex+1 + (yindex )*xnpts + (zindex+1)*xnpts*ynpts); - ids->InsertNextId(xindex + (yindex+1)*xnpts + (zindex+1)*xnpts*ynpts); - ids->InsertNextId(xindex+1 + (yindex+1)*xnpts + (zindex+1)*xnpts*ynpts); - return; - } - return; - } - - this->LoadConnectivity(); - - if (this->GetEntity().GeometryType==MED_POLYHEDRON) - { - vtkMedIntArray* conn = this->GetConnectivityArray(); - vtkMedIntArray* faceIndex = this->GetFaceIndex(); - vtkMedIntArray* nodeIndex = this->GetNodeIndex(); - med_int start = faceIndex->GetValue(index)-1; - med_int end = faceIndex->GetValue(index+1)-1; - // the use of a set loses the order, but VTK do not support this order anyway. - if (this->GetConnectivity()==MED_NODAL) - { - for (int ff = start; ffGetValue(ff)-1; - med_int fend = nodeIndex->GetValue(ff+1)-1; - for (int pt = fstart; ptGetValue(pt)-1; - ids->InsertNextId(ptid); - } - } - } - else // MED_DESCENDING - { - vtkMedUnstructuredGrid* ugrid = - vtkMedUnstructuredGrid::SafeDownCast(this->ParentGrid); - if (!ugrid) - { - vtkErrorMacro( - "MED_DESCENDING connectivity is only supported on unstructured grids"); - return; - } - set pts; - vtkIdList* subIds = vtkIdList::New(); - for (int ff = start; ffGetValue(ff)-1; - vtkMedEntity entity; - entity.GeometryType = (med_geometry_type) NodeIndex->GetValue(ff); - entity.EntityType = MED_DESCENDING_FACE; - vtkMedEntityArray* subarray = ugrid->GetEntityArray(entity); - subarray->GetCellVertices(fid, subIds); - for (int id = 0; idGetNumberOfIds(); id++) - { - med_int ptid = subIds->GetId(id); - if(pts.find(ptid) == pts.end()) - { - ids->InsertNextId(ptid); - pts.insert(ptid); - } - } - } - subIds->Delete(); - } - }//end polyhedron - else if (this->GetEntity().GeometryType==MED_POLYGON) - { - vtkMedIntArray* conn = this->GetConnectivityArray(); - vtkMedIntArray* nids = this->GetFaceIndex(); - med_int start = nids->GetValue(index)-1; - med_int end = nids->GetValue(index+1)-1; - if (this->GetConnectivity()==MED_NODAL) - { - for (int pt = start; ptInsertNextId(conn->GetValue(pt)-1); - } - } - else // MED_DESCENDING - { - vtkIdList* subpts=vtkIdList::New(); - vtkMedUnstructuredGrid* ugrid = - vtkMedUnstructuredGrid::SafeDownCast(this->ParentGrid); - if (!ugrid) - { - vtkErrorMacro("MED_DESCENDING connectivity is only " - << "supported on unstructured grids"); - return; - } - set pts; - for (int sub = start; subGetValue(sub)-1; - vtkMedEntity subentity; - subentity.GeometryType = MED_SEG2; - subentity.EntityType = MED_DESCENDING_EDGE; - vtkMedEntityArray* subarray = ugrid->GetEntityArray(subentity); - subarray->GetCellVertices(subid, subpts); - for(int id=0; idGetNumberOfIds(); id++) - { - med_int ptid = subpts->GetId(id); - if(pts.find(ptid) != pts.end()) - { - pts.insert(ptid); - ids->InsertNextId(ptid); - } - } - } - subpts->Delete(); - } - }//end poygon - else if (this->GetConnectivity()==MED_NODAL || - vtkMedUtilities::GetDimension(this->GetEntity().GeometryType)<1) - { - int npts = 0; - if(this->GetEntity().EntityType == MED_STRUCT_ELEMENT) - { - if(this->StructElement != NULL) - { - npts = this->StructElement->GetConnectivitySize(); - } - } - else - { - npts = vtkMedUtilities::GetNumberOfPoint(this->GetEntity().GeometryType); - } - vtkMedIntArray* conn = this->GetConnectivityArray(); - for (int i = 0; iGetValue(npts*index+i)-1; - ids->InsertNextId(ptid); - } - }//end nodal case - else - { - vtkIdList* subpts=vtkIdList::New(); - int nsub=vtkMedUtilities::GetNumberOfSubEntity( - this->GetEntity().GeometryType); - vtkMedUnstructuredGrid* ugrid = - vtkMedUnstructuredGrid::SafeDownCast(this->ParentGrid); - if (!ugrid) - { - vtkErrorMacro( - "MED_DESCENDING connectivity is only supported on unstructured grids"); - return; - } - vtkMedIntArray* conn=this->GetConnectivityArray(); - ids->SetNumberOfIds(vtkMedUtilities::GetNumberOfPoint( - this->GetEntity().GeometryType)); - for (int sub = 0; subGetValue(nsub*index+sub); - bool invert = false; - if(subid < 0) - { - subid = -subid; - invert = true; - } - subid = subid-1; - - vtkMedEntity subentity; - subentity.GeometryType = vtkMedUtilities::GetSubGeometry( - this->GetEntity().GeometryType, sub); - subentity.EntityType = vtkMedUtilities::GetSubType( - this->GetEntity().EntityType); - vtkMedEntityArray* subarray = ugrid->GetEntityArray(subentity); - if(subarray == NULL) - { - subentity.EntityType = MED_CELL; - subarray = ugrid->GetEntityArray(subentity); - } - if(subarray == NULL) - { - vtkDebugMacro( << "Missing sub entity array " << subentity.GeometryType); - this->Valid = false; - break; - } - subarray->GetCellVertices(subid, subpts); - vtkMedUtilities::ProjectConnectivity(this->GetEntity().GeometryType, ids, subpts, - sub, invert); - } - subpts->Delete(); - } -} - -void vtkMedEntityArray::LoadConnectivity() -{ - if(this->IsConnectivityLoaded()) - return; - - this->GetParentGrid()->GetParentMesh()->GetParentFile()->GetMedDriver() - ->LoadConnectivity(this); -} - -void vtkMedEntityArray::SetVariableAttributeValues( - vtkMedVariableAttribute* varatt, vtkAbstractArray* value) -{ - this->VariableAttributeValue[varatt] = value; -} - -vtkAbstractArray* vtkMedEntityArray::GetVariableAttributeValue( - vtkMedVariableAttribute* varatt) -{ - if(this->VariableAttributeValue.find(varatt) - == this->VariableAttributeValue.end()) - return NULL; - - return this->VariableAttributeValue[varatt]; -} - -void vtkMedEntityArray::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, NumberOfEntity) - PRINT_IVAR(os, indent, Connectivity) - PRINT_IVAR(os, indent, InitialGlobalId) -} diff --git a/src/Plugins/MedReader/IO/vtkMedEntityArray.h b/src/Plugins/MedReader/IO/vtkMedEntityArray.h deleted file mode 100644 index 6e4d037f..00000000 --- a/src/Plugins/MedReader/IO/vtkMedEntityArray.h +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedEntityArray_h_ -#define __vtkMedEntityArray_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMedUtilities.h" -#include "vtkMed.h" -#include "vtkMedFilter.h" - -class vtkMedIntArray; -class vtkFamilyIdSet; -class vtkMedFamily; -class vtkMedFamilyOnEntity; -class vtkMedMesh; -class vtkMedGrid; -class vtkIdList; -class vtkMedStructElement; -class vtkMedVariableAttribute; - -class VTK_EXPORT vtkMedEntityArray: public vtkObject -{ -public: - static vtkMedEntityArray* New(); - vtkTypeMacro(vtkMedEntityArray, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the number of cells of this entity type. - vtkSetMacro(NumberOfEntity, vtkIdType); - vtkGetMacro(NumberOfEntity, vtkIdType); - - // Description: - // the support of the cells : one of - void SetEntity(const vtkMedEntity& entity){this->Entity = entity;} - const vtkMedEntity& GetEntity(){return this->Entity;} - - // Description: - // This connectivity type of this entity : one of - // MED_NODAL, MED_DESCENDING, MED_NO_CMODE - vtkSetMacro(Connectivity, med_connectivity_mode); - vtkGetMacro(Connectivity, med_connectivity_mode); - - // Description: - // This array stores the family ids of each entity. - virtual void SetConnectivityArray(vtkMedIntArray*); - vtkGetObjectMacro(ConnectivityArray, vtkMedIntArray); - - // Description: - // This array stores the connectivity array for this entity. - virtual void SetFamilyIds(vtkMedIntArray*); - virtual med_int GetFamilyId(med_int id); - - // Description: - // This array stores the global Ids of the entities. - virtual void SetGlobalIds(vtkMedIntArray*); - vtkGetObjectMacro(GlobalIds, vtkMedIntArray); - - // Description: - // For polygons, this array stores the index of each edge described in - // the connectivity array - // For polyhedrons, this arrays stores the index of each face described - // in the NodeIndex array - virtual void SetFaceIndex(vtkMedIntArray*); - vtkGetObjectMacro(FaceIndex, vtkMedIntArray); - - // Description: - // For polyhedrons, this arrays can store either - // the index of each node of each face described in the Index1 array - // (node connectivity) or the type each face described in the Index1 - // array (hierarchical connectivity) - virtual void SetNodeIndex(vtkMedIntArray*); - vtkGetObjectMacro(NodeIndex, vtkMedIntArray); - - // Description: - // Arrays of entities are partitionned over families. - vtkSetObjectVectorMacro(FamilyOnEntity, vtkMedFamilyOnEntity); - vtkGetObjectVectorMacro(FamilyOnEntity, vtkMedFamilyOnEntity); - - // Description: - // For polyhedrons, this arrays can store either - // the index of each node of each face described in the Index1 array - // (node connectivity) or the type each face described in the Index1 - // array (hierarchical connectivity) - virtual void SetParentGrid(vtkMedGrid*); - vtkGetObjectMacro(ParentGrid, vtkMedGrid); - - // Description: - // Compute the list of families that are on this array - virtual void ComputeFamilies(); - - // Description: - // returns true if there are cells of the given family on this entity. - virtual int HasFamily(vtkMedFamily*); - - // Description: - // returns 1 if the connectivity array is set and matches the number of - // connectivity elements. - virtual int IsConnectivityLoaded(); - - // Description: - // returns 1 if the family ids is set and matches the number of entities. - virtual int IsFamilyIdsLoaded(); - - // Description: - // returns 1 if the global ids is set and matches the number of entities. - virtual int IsGlobalIdsLoaded(); - - // Description : - // This gives the global id of the first element of this array. - vtkSetMacro(InitialGlobalId, vtkIdType); - vtkGetMacro(InitialGlobalId, vtkIdType); - - // Description : - // resets all to default status, release memory - virtual void Initialize(); - - // Description: - // Get the indices of the vertices used by a given cell. - void GetCellVertices(vtkIdType, vtkIdList*); - - virtual void LoadConnectivity(); - - // Descritpion: - // This is a pointer to the StructElement object if any - // This pointer is set during the LinkMedInfo pass - virtual void SetStructElement(vtkMedStructElement*); - vtkGetObjectMacro(StructElement, vtkMedStructElement); - - void SetVariableAttributeValues(vtkMedVariableAttribute*, - vtkAbstractArray*); - vtkAbstractArray* GetVariableAttributeValue(vtkMedVariableAttribute*); - - // Description: - // Get/Set of the MED Filter for parallel reading. - void SetFilter(vtkMedFilter* filter){this->Filter = filter;} - vtkMedFilter* GetFilter(){return this->Filter;} - -protected: - vtkMedEntityArray(); - virtual ~vtkMedEntityArray(); - - vtkIdType NumberOfEntity; - vtkMedEntity Entity; - - vtkMedFilter* Filter; - - med_connectivity_mode Connectivity; - vtkIdType InitialGlobalId; - - vtkMedGrid* ParentGrid; - - vtkMedIntArray* FamilyIds; - vtkMedIntArray* GlobalIds; - vtkMedIntArray* ConnectivityArray; - vtkMedIntArray* FaceIndex; - vtkMedIntArray* NodeIndex; - - vtkMedStructElement* StructElement; - - int FamilyIdStatus; - enum{ - FAMILY_ID_NOT_LOADED, - FAMILY_ID_IMPLICIT, - FAMILY_ID_EXPLICIT - }; - - //BTX - vtkObjectVector* FamilyOnEntity; - - std::map > - VariableAttributeValue; - //ETX - - int Valid; - -private: - vtkMedEntityArray(const vtkMedEntityArray&); // Not implemented. - void operator=(const vtkMedEntityArray&); // Not implemented. -}; - -#endif //__vtkMedEntityArray_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFactory.cxx b/src/Plugins/MedReader/IO/vtkMedFactory.cxx deleted file mode 100644 index ecf75d81..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFactory.cxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFactory.h" - -#include "vtkObjectFactory.h" - -#include "vtkMedDriver30.h" - -// vtkCxxRevisionMacro(vtkMedFactory, "$Revision$") -vtkStandardNewMacro(vtkMedFactory) - -vtkMedFactory::vtkMedFactory() -{ -} - -vtkMedFactory::~vtkMedFactory() -{ -} - -vtkMedDriver* vtkMedFactory::NewMedDriver(int major, int minor, int release) -{ - return vtkMedDriver30::New(); -} - -void vtkMedFactory::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFactory.h b/src/Plugins/MedReader/IO/vtkMedFactory.h deleted file mode 100644 index cee9a3da..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFactory.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFactory_h_ -#define __vtkMedFactory_h_ - -#include "vtkObject.h" -class vtkMedDriver; - -class VTK_EXPORT vtkMedFactory: public vtkObject -{ -public: - static vtkMedFactory* New(); - vtkTypeMacro(vtkMedFactory, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - virtual vtkMedDriver* NewMedDriver(int major, int minor, int release); - -protected: - vtkMedFactory(); - virtual ~vtkMedFactory(); - -private: - vtkMedFactory(const vtkMedFactory&); // Not implemented. - void operator=(const vtkMedFactory&); // Not implemented. -}; - -#endif //__vtkMedFactory_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFamily.cxx b/src/Plugins/MedReader/IO/vtkMedFamily.cxx deleted file mode 100644 index 9de55e3a..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFamily.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFamily.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" - -#include "vtkMedGroup.h" -#include "vtkMedUtilities.h" - -vtkCxxGetObjectVectorMacro(vtkMedFamily, Group, vtkMedGroup); -vtkCxxSetObjectVectorMacro(vtkMedFamily, Group, vtkMedGroup); - -// vtkCxxRevisionMacro(vtkMedFamily, "$Revision$") -vtkStandardNewMacro(vtkMedFamily) - -vtkMedFamily::vtkMedFamily() -{ - this->Id = 0; - this->Name = NULL; - this->Group = new vtkObjectVector(); - this->MedIterator = -1; - this->PointOrCell = vtkMedUtilities::OnPoint; - - // by default, the family is part of the "NoGroup" fake group - this->AllocateNumberOfGroup(1); - vtkMedGroup* nogroup = this->GetGroup(0); - nogroup->SetName(vtkMedUtilities::NoGroupName); - - this->SetName("UNDEFINED_FAMILY"); -} - -vtkMedFamily::~vtkMedFamily() -{ - this->SetName(NULL); - delete this->Group; -} - -void vtkMedFamily::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, Id); - PRINT_IVAR(os, indent, MedIterator); - PRINT_IVAR(os, indent, PointOrCell); - PRINT_OBJECT_VECTOR(os, indent, Group); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFamily.h b/src/Plugins/MedReader/IO/vtkMedFamily.h deleted file mode 100644 index f87ed678..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFamily.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFamily_h_ -#define __vtkMedFamily_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" - -class vtkMedMesh; -class vtkMedGroup; -class vtkMedString; - -class VTK_EXPORT vtkMedFamily: public vtkObject -{ -public: - static vtkMedFamily* New(); - vtkTypeMacro(vtkMedFamily, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Set the name of this family. - vtkSetStringMacro(Name); - vtkGetStringMacro(Name); - - // Description: - // The id of this family. - vtkGetMacro(Id, med_int); - vtkSetMacro(Id, med_int); - - // Description: - // Each family can be part of one or several groups. - // This give access to the group names. - vtkGetObjectVectorMacro(Group, vtkMedGroup); - vtkSetObjectVectorMacro(Group, vtkMedGroup); - - // Description: - // returns id this is a node or a cell centered family. - vtkSetMacro(PointOrCell, int); - vtkGetMacro(PointOrCell, int); - - // Description: - // the index of this field in the med file. - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - -protected: - vtkMedFamily(); - virtual ~vtkMedFamily(); - - med_int Id; - med_int MedIterator; - char* Name; - int PointOrCell; - - //BTX - vtkObjectVector* Group; - //ETX - -private: - vtkMedFamily(const vtkMedFamily&); // Not implemented. - void operator=(const vtkMedFamily&); // Not implemented. - -}; - -#endif //__vtkMedFamily_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.cxx b/src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.cxx deleted file mode 100644 index 5ca047de..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFamilyOnEntity.h" - -#include "vtkObjectFactory.h" -#include "vtkMedUtilities.h" -#include "vtkMedFamily.h" -#include "vtkMedEntityArray.h" -#include "vtkMedMesh.h" -#include "vtkMedGrid.h" -#include "vtkMedFamilyOnEntityOnProfile.h" - -vtkCxxSetObjectMacro(vtkMedFamilyOnEntity, Family, vtkMedFamily); -vtkCxxSetObjectMacro(vtkMedFamilyOnEntity, EntityArray, vtkMedEntityArray); - -vtkCxxSetObjectMacro(vtkMedFamilyOnEntity, ParentGrid,vtkMedGrid); - -// vtkCxxRevisionMacro(vtkMedFamilyOnEntity, "$Revision$"); -vtkStandardNewMacro(vtkMedFamilyOnEntity) - -vtkMedFamilyOnEntity::vtkMedFamilyOnEntity() -{ - this->Family = NULL; - this->EntityArray = NULL; - this->ParentGrid = NULL; -} - -vtkMedFamilyOnEntity::~vtkMedFamilyOnEntity() -{ - this->SetFamily(NULL); - this->SetEntityArray(NULL); - this->SetParentGrid(NULL); -} - -vtkMedEntity vtkMedFamilyOnEntity::GetEntity() -{ - if(this->EntityArray != NULL) - { - return this->EntityArray->GetEntity(); - } - - return vtkMedEntity(MED_NODE, MED_POINT1); -} - -int vtkMedFamilyOnEntity::GetPointOrCell() -{ - if(this->GetEntity().EntityType == MED_NODE) - return vtkMedUtilities::OnPoint; - return vtkMedUtilities::OnCell; -} - -int vtkMedFamilyOnEntity::GetVertexOnly() -{ - if(this->GetPointOrCell() == vtkMedUtilities::OnPoint || - this->EntityArray == NULL) - return true; - - vtkMedEntity entity = this->EntityArray->GetEntity(); - if(entity.EntityType == MED_POINT1 || entity.GeometryType == MED_NONE) - return true; - - if(entity.GeometryName == MED_BALL_NAME && entity.EntityType == MED_STRUCT_ELEMENT) - return true; - - if(entity.GeometryName == MED_PARTICLE_NAME && entity.EntityType == MED_STRUCT_ELEMENT) - return true; - - return false; -} - -void vtkMedFamilyOnEntity::AddFamilyOnEntityOnProfile( - vtkMedFamilyOnEntityOnProfile* foep) -{ - this->FamilyOnEntityOnProfile[foep->GetProfile()] = foep; -} - -int vtkMedFamilyOnEntity::GetNumberOfFamilyOnEntityOnProfile() -{ - return this->FamilyOnEntityOnProfile.size(); -} - -vtkMedFamilyOnEntityOnProfile* vtkMedFamilyOnEntity:: - GetFamilyOnEntityOnProfile(vtkMedProfile* profile) -{ - if(this->FamilyOnEntityOnProfile.find(profile) - != this->FamilyOnEntityOnProfile.end()) - return this->FamilyOnEntityOnProfile[profile]; - - return NULL; -} - -vtkMedFamilyOnEntityOnProfile* vtkMedFamilyOnEntity:: - GetFamilyOnEntityOnProfile(int index) -{ - if(index < 0 || index >= this->FamilyOnEntityOnProfile.size()) - return NULL; - - std::map >::iterator it = - this->FamilyOnEntityOnProfile.begin(); - - for(int ii=0; iisecond; -} - -void vtkMedFamilyOnEntity::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_OBJECT(os, indent, Family); - PRINT_OBJECT(os, indent, EntityArray); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.h b/src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.h deleted file mode 100644 index 948d73ef..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntity.h +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFamilyOnEntity_h_ -#define __vtkMedFamilyOnEntity_h_ - -// Description : -// This class represents the intersection between a family and an entity. - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedUtilities.h" - -class vtkMedEntityArray; -class vtkMedFamily; -class vtkMedGrid; -class vtkMedFamilyOnEntityOnProfile; -class vtkMedIntArray; - -class VTK_EXPORT vtkMedFamilyOnEntity : public vtkObject -{ -public : - static vtkMedFamilyOnEntity* New(); - vtkTypeMacro(vtkMedFamilyOnEntity, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the family of this family on entity. - virtual void SetFamily(vtkMedFamily*); - vtkGetObjectMacro(Family, vtkMedFamily); - - // Description: - // This is the entity array this family on entity is on. - virtual void SetEntityArray(vtkMedEntityArray*); - vtkGetObjectMacro(EntityArray, vtkMedEntityArray); - - // Description: - // This is the grid this family on entity is reffering to - virtual void SetParentGrid(vtkMedGrid*); - vtkGetObjectMacro(ParentGrid, vtkMedGrid); - - // Description : - // Returns vtkMedUtilities::OnPoint (0) or vtkMedUtilities::OnCell (1) - virtual int GetPointOrCell(); - - // Description : - // Returns true if the family is on points or if the entity is MED_POINT1 - // of if it is MED_BALL or MED_PARTICLE elements - virtual int GetVertexOnly(); - - // Description: - // returns the entity descriptor associated with this family on entity - virtual vtkMedEntity GetEntity(); - - // Description: - // Fields can use profile to be stored on a subset of entities. - // a priori, profiles and families are independent notions. - // In case there are profiles, we create the intersection of the profile and - // the FamilyOnEntity to be able to map the field on the geometry. - // BEFORE calling those function, you have to have assigned a profile - // to the vtkMedFamilyOnEntityOnProfile - void AddFamilyOnEntityOnProfile(vtkMedFamilyOnEntityOnProfile*); - int GetNumberOfFamilyOnEntityOnProfile(); - vtkMedFamilyOnEntityOnProfile* GetFamilyOnEntityOnProfile(vtkMedProfile*); - vtkMedFamilyOnEntityOnProfile* GetFamilyOnEntityOnProfile(int index); - -protected: - vtkMedFamilyOnEntity(); - virtual ~vtkMedFamilyOnEntity(); - - vtkMedFamily* Family; - vtkMedEntityArray* EntityArray; - vtkMedGrid* ParentGrid; - - std::map > - FamilyOnEntityOnProfile; - -private: - vtkMedFamilyOnEntity(const vtkMedFamilyOnEntity&); // Not implemented. - void operator=(const vtkMedFamilyOnEntity&); // Not implemented. - -}; - -#endif //__vtkMedFamilyOnEntity_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.cxx b/src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.cxx deleted file mode 100644 index e528f2ce..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.cxx +++ /dev/null @@ -1,591 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFamilyOnEntityOnProfile.h" - -#include "vtkObjectFactory.h" -#include "vtkMedUtilities.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedProfile.h" -#include "vtkMedEntityArray.h" -#include "vtkMedFamily.h" -#include "vtkMedField.h" -#include "vtkMedGrid.h" -#include "vtkMedMesh.h" -#include "vtkMedFieldOnProfile.h" -#include "vtkMedFieldOverEntity.h" -#include "vtkMedFieldStep.h" -#include "vtkMedFile.h" -#include "vtkMedGrid.h" -#include "vtkMedDriver.h" -#include "vtkMedUnstructuredGrid.h" -#include "vtkMedIntArray.h" - -#include "vtkBitArray.h" -#include "vtkIdList.h" - -#include "vtkMultiProcessController.h" - -vtkCxxSetObjectMacro(vtkMedFamilyOnEntityOnProfile,FamilyOnEntity, vtkMedFamilyOnEntity); -vtkCxxSetObjectMacro(vtkMedFamilyOnEntityOnProfile, Profile, vtkMedProfile); - -// vtkCxxRevisionMacro(vtkMedFamilyOnEntityOnProfile, "$Revision$"); -vtkStandardNewMacro(vtkMedFamilyOnEntityOnProfile) - -vtkMedFamilyOnEntityOnProfile::vtkMedFamilyOnEntityOnProfile() -{ - this->FamilyOnEntity = NULL; - this->Profile = NULL; - this->IntersectionStatus = vtkMedFamilyOnEntityOnProfile::NotComputed; - this->UseAllPoints = false; - this->MatchComputed = false; - this->Valid = true; -} - -vtkMedFamilyOnEntityOnProfile::~vtkMedFamilyOnEntityOnProfile() -{ - this->SetFamilyOnEntity(NULL); - this->SetProfile(NULL); -} - -bool vtkMedFamilyOnEntityOnProfile::KeepPoint(med_int index) -{ - if(this->IntersectionStatus == NotComputed) - this->ComputeIntersection(NULL); - - if(this->UseAllPoints) - return true; - - if(this->MedToVTKPointIndexMap.find(index) - == this->MedToVTKPointIndexMap.end()) - return false; - - return true; -} - -bool vtkMedFamilyOnEntityOnProfile::KeepCell(med_int index) -{ - if(this->FamilyOnEntity->GetEntityArray()->GetFamilyId(index) - != this->FamilyOnEntity->GetFamily()->GetId()) - return false; - return true; -} - -int vtkMedFamilyOnEntityOnProfile::CanMapField(vtkMedFieldOnProfile* fop) -{ - // only point fields can be mapped on point supports. - if(this->GetFamilyOnEntity()->GetEntity().EntityType == MED_NODE && - fop->GetParentFieldOverEntity()->GetEntity().EntityType != MED_NODE) - return false; - - // if it is a cell-centered field, the geometry need to be the same - if(fop->GetParentFieldOverEntity()->GetEntity().EntityType != MED_NODE - && fop->GetParentFieldOverEntity()->GetEntity().GeometryType != - this->GetFamilyOnEntity()->GetEntity().GeometryType) - return false; - - int numProc = 1; - vtkMultiProcessController* controller = - vtkMultiProcessController::GetGlobalController(); - if (controller != NULL) - { - numProc = controller->GetNumberOfProcesses(); - } - - if ((this->GetValid() == 0) && numProc == 1) - return false; - - this->ComputeIntersection(fop); - - if(this->IntersectionStatus == vtkMedFamilyOnEntityOnProfile::NoIntersection) - return false; - - if(fop != NULL && - this->GetFamilyOnEntity()->GetEntity().EntityType != MED_NODE && - fop->GetParentFieldOverEntity()->GetEntity().EntityType == MED_NODE && - this->PointProfileMatch[fop->GetProfile()] == BadOrNoIntersection) - return false; - - return true; -} - -int vtkMedFamilyOnEntityOnProfile::CanShallowCopy(vtkMedFieldOnProfile *fop) -{ - if(fop == NULL) - { - bool shallow_on_points = this->CanShallowCopyPointField(NULL); - bool shallow_on_cells = this->CanShallowCopyCellField(NULL); - if(shallow_on_points && shallow_on_cells) - return true; - if(!shallow_on_points && !shallow_on_cells) - return false; - vtkErrorMacro("CanShallowCopy cannot answer : is it a point or a cell field?"); - return false; - } - - if(fop->GetParentFieldOverEntity()->GetParentStep()->GetParentField() - ->GetFieldType() == vtkMedField::PointField) - return this->CanShallowCopyPointField(fop); - else - return this->CanShallowCopyCellField(fop); -} - -void vtkMedFamilyOnEntityOnProfile::ComputeIntersection(vtkMedFieldOnProfile* fop) -{ - int nodeOrCellSupport=this->GetFamilyOnEntity()->GetPointOrCell(); - int fieldType; - if(fop) - { - fieldType = fop->GetParentFieldOverEntity()->GetParentStep()-> - GetParentField()->GetFieldType(); - } - else - { - fieldType = (nodeOrCellSupport==vtkMedUtilities::OnPoint?vtkMedField::PointField:vtkMedField::CellField); - } - // Cell fields cannot match point supports - if(fieldType != vtkMedField::PointField - && nodeOrCellSupport == vtkMedUtilities::OnPoint) - { - this->IntersectionStatus = vtkMedFamilyOnEntityOnProfile::NoIntersection; - this->UseAllPoints = false; - } - else if(fieldType != vtkMedField::PointField - && nodeOrCellSupport ==vtkMedUtilities::OnCell) - { - this->ComputeCellFamilyVsCellProfileMatch(); - } - else if(fieldType == vtkMedField::PointField - && nodeOrCellSupport ==vtkMedUtilities::OnPoint) - { - vtkMedProfile* profile = NULL; - if(fop != NULL) - { - profile = fop->GetProfile(); - } - // point fields must share the same profile as the point support. - this->ComputePointFamilyVsPointProfileMatch(); - - } - else if(fieldType == vtkMedField::PointField - && nodeOrCellSupport == vtkMedUtilities::OnCell) - { - vtkMedProfile* profile = NULL; - if(fop != NULL) - { - profile = fop->GetProfile(); - } - this->ComputeCellFamilyVsPointProfileMatch(profile); - } - - this->MatchComputed = true; -} - -int vtkMedFamilyOnEntityOnProfile::CanShallowCopyPointField(vtkMedFieldOnProfile* fop) -{ - vtkMedProfile* profile = (fop != NULL?fop->GetProfile(): NULL); - if(this->FamilyOnEntity->GetPointOrCell() == vtkMedUtilities::OnCell) - { - if(this->PointProfileMatch.find(profile) == this->PointProfileMatch.end()) - { - this->ComputeCellFamilyVsPointProfileMatch(profile); - } - int match = this->PointProfileMatch[profile]; - return match - == vtkMedFamilyOnEntityOnProfile::ProfileEqualsSupport; - } - else - { - // this is a point support. - // The only case when there is shallow copy is if there is at most 1 family - // and the profile is shared. - if(this->Profile == profile && - this->GetFamilyOnEntity()->GetEntityArray() - ->GetNumberOfFamilyOnEntity() <= 1) - { - return true; - } - else - { - return false; - } - } -} - -int vtkMedFamilyOnEntityOnProfile::CanShallowCopyCellField(vtkMedFieldOnProfile* fop) -{ - vtkMedProfile* profile = (fop != NULL?fop->GetProfile(): NULL); - // cell fields cannot be mapped to cell supports - if(this->FamilyOnEntity->GetPointOrCell() == vtkMedUtilities::OnPoint) - { - return false; - } - - // this is a cell support. - if(this->Profile != profile) - { - return false; - } - - // the only case I can shallow copy is if there is only one family - // defined on those cells. - if(this->Profile == NULL && - this->GetFamilyOnEntity()->GetEntityArray() - ->GetNumberOfFamilyOnEntity() <= 1) - return true; - - return false; -} - -void vtkMedFamilyOnEntityOnProfile::ComputeUsedPoints() -{ - this->MedToVTKPointIndexMap.clear(); - - //first test a few special cases where no heavy computing is necessary - vtkMedGrid* grid = this->FamilyOnEntity->GetParentGrid(); - if(this->Profile == NULL) - { - // If there is no profile, the entity is on points and there - // at most 1 point family, then all points are used. - if(this->FamilyOnEntity->GetPointOrCell() == vtkMedUtilities::OnPoint && - this->FamilyOnEntity->GetEntityArray()->GetNumberOfFamilyOnEntity() <= 1) - { - this->UseAllPoints = true; - return; - } - // if there is no profile, the grid is structured, the entity is on cell - // and there is at most 1 family on his entity, then all points are used - if(vtkMedUnstructuredGrid::SafeDownCast(grid) == NULL && - this->FamilyOnEntity->GetPointOrCell() == vtkMedUtilities::OnCell && - this->FamilyOnEntity->GetEntityArray()->GetNumberOfFamilyOnEntity() <= 1) - { - this->UseAllPoints = true; - return; - } - } - - vtkSmartPointer flag = vtkSmartPointer::New(); - flag->SetNumberOfTuples(grid->GetNumberOfPoints()); - - // initialize the array to false - for(vtkIdType pid = 0; pid < flag->GetNumberOfTuples(); pid++) - flag->SetValue(pid, false); - - // for each cell, flag the used points - if(this->Profile) - this->Profile->Load(); - - vtkMedIntArray* pids=(this->Profile!=NULL?this->Profile->GetIds():NULL); - - med_int famId = this->FamilyOnEntity->GetFamily()->GetId(); - vtkMedEntityArray* array = this->FamilyOnEntity->GetEntityArray(); - vtkSmartPointer ids = vtkSmartPointer::New(); - - array->LoadConnectivity(); - - vtkIdType pflsize = (pids != NULL ? pids->GetNumberOfTuples():array->GetNumberOfEntity()); - for(vtkIdType pindex=0; pindexGetValue(pindex)-1 : pindex); - med_int fid = array->GetFamilyId(pid); - if(famId==fid) - { - // this cell is of the family and on the profile. - // --> flag all vertices of this cell - array->GetCellVertices(pid, ids); - for(int id = 0; idGetNumberOfIds(); id++) - { - vtkIdType subid = ids->GetId(id); - if(subid < 0 || subid >= flag->GetNumberOfTuples()) - { - vtkDebugMacro("invalid sub id : " << subid); - this->SetValid(0); - break; - } - flag->SetValue(subid, 1); - } - } - } - - // now, the flag array contains all vertices used by this support - this->UseAllPoints = true; - for(vtkIdType pid = 0; pidGetNumberOfTuples(); pid++) - { - if(flag->GetValue(pid) == false) - { - this->UseAllPoints = false; - break; - } - } - - if(!this->UseAllPoints) - { - // If all points are not used, I compute the index mapping - vtkIdType vtk_index = 0; - - for(vtkIdType pid=0; pid < flag->GetNumberOfTuples(); pid++) - { - if(flag->GetValue(pid) == true) - { - this->MedToVTKPointIndexMap[pid] = vtk_index; - vtk_index++; - } - } - } -} - -void vtkMedFamilyOnEntityOnProfile::ComputeCellFamilyVsCellProfileMatch() -{ - if(this->MatchComputed) - return; - - // this computes the UseAllPoints flag. - this->ComputeUsedPoints(); - - if(this->Profile == NULL) - { - // If there is no profile, then the match is exact if and only - // if there is 1 cell family on this entity - if(this->FamilyOnEntity->GetEntityArray()->GetNumberOfFamilyOnEntity() == 1) - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::ProfileIncludedInFamily; - } - else - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::ProfileIntersectsFamily; - } - return; - } - - this->Profile->Load(); - vtkMedIntArray* pids=this->Profile->GetIds(); - - if(pids==NULL) - { - vtkErrorMacro("Could not load profile indices!"); - this->IntersectionStatus = vtkMedFamilyOnEntityOnProfile::NotComputed; - this->UseAllPoints = false; - return; - } - - med_int famId = this->GetFamilyOnEntity()->GetFamily()->GetId(); - vtkIdType pindex=0; - vtkMedEntityArray* array=this->FamilyOnEntity->GetEntityArray(); - bool profile_included = true; - bool profile_intersect = false; - for(int pindex=0; pindexGetNumberOfTuples(); pindex++) - { - med_int pid=pids->GetValue(pindex)-1; - med_int fid=array->GetFamilyId(pid); - if(famId==fid) - {// the current cell is on the familyand on the profile - // --> there is an overlap - profile_intersect = true; - } - else - { - // the cell is on the profile but not on the family --> no inclusion - profile_included=false; - } - } - - if(profile_included && profile_intersect) - this->IntersectionStatus = vtkMedFamilyOnEntityOnProfile::ProfileIncludedInFamily; - else if(profile_intersect) - this->IntersectionStatus = vtkMedFamilyOnEntityOnProfile::ProfileIntersectsFamily; - else - this->IntersectionStatus = vtkMedFamilyOnEntityOnProfile::NoIntersection; -} - -void vtkMedFamilyOnEntityOnProfile:: - ComputeCellFamilyVsPointProfileMatch(vtkMedProfile* profile) -{ - // first test if the cache is already set - if(this->PointProfileMatch.find(profile) != this->PointProfileMatch.end()) - return; - - // this will compute the cell match cache, as well as the UseAllPoints flag. - this->ComputeCellFamilyVsCellProfileMatch(); - - if(profile == NULL) - { - // If there is no profile, then the match is at least partial. - // It is exact if and only - // if the cell family uses all points - int match = (this->UseAllPoints? ProfileEqualsSupport : ProfileLargerThanSupport); - this->PointProfileMatch[profile] = - (this->UseAllPoints? ProfileEqualsSupport : ProfileLargerThanSupport); - return; - } - - // if profile is not NULL and I use all points --> BadOrNoIntersection - if(this->UseAllPoints) - { - this->PointProfileMatch[profile] = BadOrNoIntersection; - } - - profile->Load(); - - vtkMedIntArray* pids=profile->GetIds(); - - if(pids == NULL) - { - vtkErrorMacro("profile indices could not be loaded!"); - this->PointProfileMatch[profile] = BadOrNoIntersection; - return; - } - - med_int pindex = 0; - bool exact_match = true; - vtkIdType numberOfUsedPoints = pids->GetNumberOfTuples(); - for(med_int pindex=0; pindex < pids->GetNumberOfTuples(); pindex++) - { - med_int id = pids->GetValue(pindex); - if(this->MedToVTKPointIndexMap.find(id-1) == this->MedToVTKPointIndexMap.end()) - { - // The given point profile index is not used by this support. - // the superposition is at most partial. - exact_match = false; - numberOfUsedPoints--; - } - } - - // if this profile is smaller than the number of points, I can't match - // the profile to this support - if(numberOfUsedPoints < this->MedToVTKPointIndexMap.size()) - { - this->PointProfileMatch[profile] = BadOrNoIntersection; - } - else if(exact_match) - { - this->PointProfileMatch[profile] = ProfileEqualsSupport; - } - else - { - this->PointProfileMatch[profile] = ProfileLargerThanSupport; - } -} - -void vtkMedFamilyOnEntityOnProfile::ComputePointFamilyVsPointProfileMatch() -{ - if(this->MatchComputed) - return; - - this->ComputeUsedPoints(); - - if(this->Profile == NULL) - { - // If there is no profile, then the match is exact if there is at most - // 1 point family on the grid - if(this->FamilyOnEntity->GetParentGrid()->GetParentMesh() - ->GetNumberOfPointFamily() <= 1) - { - this->IntersectionStatus = ProfileIncludedInFamily; - } - } - - // there is a profile, we have to compute the match between the family and - // the profile - vtkMedFamilyOnEntity* foe = this->GetFamilyOnEntity(); - vtkMedEntityArray* pea = foe->GetEntityArray(); - vtkMedIntArray* pIds = NULL; - - if(this->Profile) - { - this->Profile->Load(); - pIds=this->Profile->GetIds(); - } - - if(pIds == NULL) - { - if(this->FamilyOnEntity->GetEntityArray()->GetNumberOfFamilyOnEntity() > 1) - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::ProfileIntersectsFamily; - } - else - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::ProfileIncludedInFamily; - } - return; - } - - bool profile_intersects=false; - bool profile_included=true; - med_int famId=this->FamilyOnEntity->GetFamily()->GetId(); - for(vtkIdType pindex=0; pindexGetNumberOfTuples(); pindex++) - { - med_int pid=pIds->GetValue(pindex)-1; - med_int fid = pea->GetFamilyId(pid); - // med_int fid=grid->GetPointFamilyId(pid); - if(fid==famId) - {// the family of the current point is the good one - profile_intersects=true; - } - else - { - // we are on the profile and not on the family --> - // no exact match, but the the profile might be larger than the family. - profile_included=false; - } - } - - if(!profile_intersects) - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::NoIntersection; - } - else if(profile_included) - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::ProfileIncludedInFamily; - } - else - { - this->IntersectionStatus = - vtkMedFamilyOnEntityOnProfile::ProfileIntersectsFamily; - } -} - -vtkIdType vtkMedFamilyOnEntityOnProfile::GetVTKPointIndex(vtkIdType medCIndex) -{ - if(this->IntersectionStatus == NotComputed) - this->ComputeIntersection(NULL); - - if(this->UseAllPoints) - return medCIndex; - - if(this->MedToVTKPointIndexMap.find(medCIndex) - == this->MedToVTKPointIndexMap.end()) - { - vtkDebugMacro("GetVTKPointIndex asked for " - << medCIndex << " which has not been mapped"); - return -1; - } - - return this->MedToVTKPointIndexMap[medCIndex]; -} - -void vtkMedFamilyOnEntityOnProfile::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.h b/src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.h deleted file mode 100644 index 2f9537cb..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFamilyOnEntityOnProfile.h +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFamilyOnEntityOnProfile_h_ -#define __vtkMedFamilyOnEntityOnProfile_h_ - -// Description : -// This class represents the intersection between a family and an entity and -// a cell profile. -// This is the smallest partition of the the support in a med file. -// -// Fields on points are mapped on cell supports if and only if they -// fully match the cell support. - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedUtilities.h" - -class vtkMedFamilyOnEntity; -class vtkMedProfile; - -class vtkBitArray; - -class VTK_EXPORT vtkMedFamilyOnEntityOnProfile : public vtkObject -{ -public : - static vtkMedFamilyOnEntityOnProfile* New(); - vtkTypeMacro(vtkMedFamilyOnEntityOnProfile, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the family on entity of this support. - virtual void SetFamilyOnEntity(vtkMedFamilyOnEntity*); - vtkGetObjectMacro(FamilyOnEntity, vtkMedFamilyOnEntity); - - // Description: - // This is the profile of this support. - virtual void SetProfile(vtkMedProfile*); - vtkGetObjectMacro(Profile, vtkMedProfile); - - // Description: - // This flag informs on the intersection of the family on entity - // and the profile. - // The intersection can be : - // 0 --> not computed - // 1 --> exact superposition - // 2 --> partial superposition - // 3 --> no intersection. - enum eIntersectionState - {NotComputed = 0, - ProfileIncludedInFamily = 1, - ProfileIntersectsFamily = 2, - NoIntersection = 3}; - - vtkGetMacro(IntersectionStatus, eIntersectionState); - vtkGetMacro(UseAllPoints, bool); - - // Description: - // This method computes the IntersectionStatus and the UseAllPoints flags. - virtual void ComputeIntersection(vtkMedFieldOnProfile*); - - int CanShallowCopyCellField(vtkMedFieldOnProfile* fop); - int CanShallowCopyPointField(vtkMedFieldOnProfile* fop); - int CanShallowCopy(vtkMedFieldOnProfile* fop); - int CanMapField(vtkMedFieldOnProfile* fop); - - enum ePointProfileVsSupportMatch - { - Unknown = 0, - ProfileLargerThanSupport = 1, - ProfileEqualsSupport = 2, - BadOrNoIntersection = 3 - }; - - // Description: - // returns the index to use for this support on the vtk grid - // from the index stored on the med file -1 (starting to 0) - vtkIdType GetVTKPointIndex(vtkIdType medCIndex); - - // Description: - // returns if this point is used by this support. - bool KeepPoint(med_int index); - - // Description: - // returns if this cell is used by this support. (only look at the family, - // not at the profile) - bool KeepCell(med_int index); - - // Description: - // This flag is set to false when building the - // connectivity if it is not valid. - vtkGetMacro(Valid, int); - vtkSetMacro(Valid, int); - -protected: - vtkMedFamilyOnEntityOnProfile(); - virtual ~vtkMedFamilyOnEntityOnProfile(); - - // Description: - // Compute the UseAllPoints and IntersectionStatus ivars, depending - // on the type of field and the type of support. - virtual void ComputeCellFamilyVsCellProfileMatch(); - virtual void ComputePointFamilyVsPointProfileMatch(); - virtual void ComputeCellFamilyVsPointProfileMatch(vtkMedProfile*); - - // this method compute the UseAllPoints flag, and the MedToVTKPointIndexMap - // if the flag is set to false. - virtual void ComputeUsedPoints(); - - vtkMedFamilyOnEntity* FamilyOnEntity; - vtkMedProfile* Profile; - eIntersectionState IntersectionStatus; - bool UseAllPoints; - int FieldType; - med_geometry_type FieldGeometryType; - - std::map MedToVTKPointIndexMap; - - std::map PointProfileMatch; - - bool MatchComputed; - int Valid; - -private: - vtkMedFamilyOnEntityOnProfile(const vtkMedFamilyOnEntityOnProfile&); - // Not implemented. - void operator=(const vtkMedFamilyOnEntityOnProfile&); // Not implemented. -}; - -#endif //__vtkMedFamilyOnEntityOnProfile_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedField.cxx b/src/Plugins/MedReader/IO/vtkMedField.cxx deleted file mode 100644 index 188a6ffc..00000000 --- a/src/Plugins/MedReader/IO/vtkMedField.cxx +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedField.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" -#include "vtkStringArray.h" -#include "vtkMedFieldOverEntity.h" -#include "vtkMedFieldStep.h" -#include "vtkMedUtilities.h" -#include "vtkMedFieldOnProfile.h" -#include "vtkMedInterpolation.h" -#include "vtkMedFile.h" - -#include -#include -using namespace std; - -vtkCxxGetObjectVectorMacro(vtkMedField, Interpolation, vtkMedInterpolation); -vtkCxxSetObjectVectorMacro(vtkMedField, Interpolation, vtkMedInterpolation); - -vtkCxxSetObjectMacro(vtkMedField, ParentFile, vtkMedFile); - -// vtkCxxRevisionMacro(vtkMedField, "$Revision$") -vtkStandardNewMacro(vtkMedField) - -vtkMedField::vtkMedField() -{ - this->NumberOfComponent = -1; - this->DataType = MED_FLOAT64; - this->Name = NULL; - this->MeshName = NULL; - this->TimeUnit = NULL; - this->FieldStep = new vtkMedComputeStepMap (); - this->Unit = vtkStringArray::New(); - this->ComponentName = vtkStringArray::New(); - this->Interpolation = new vtkObjectVector (); - this->MedIterator = -1; - this->FieldType = UnknownFieldType; - this->ParentFile = NULL; - this->Local = 1; -} - -vtkMedField::~vtkMedField() -{ - this->SetName(NULL); - this->SetMeshName(NULL); - this->SetTimeUnit(NULL); - delete this->FieldStep; - this->Unit->Delete(); - this->ComponentName->Delete(); -} - -void vtkMedField::ComputeFieldType() -{ - this->FieldType = UnknownFieldType; - - // look for the med_entity_type - // on which this field is. - for(int sid = 0; sid < this->GetNumberOfFieldStep(); sid++) - { - vtkMedFieldStep* step = this->GetFieldStep(sid); - - for(int eid = 0; eid < step->GetNumberOfFieldOverEntity(); eid++) - { - vtkMedFieldOverEntity* fieldOverEntity = step->GetFieldOverEntity(eid); - med_entity_type type = fieldOverEntity->GetEntity().EntityType; - - if (type == MED_NODE) - { - this->FieldType |= PointField; - } - else if(type == MED_NODE_ELEMENT ) - { - this->FieldType |= ElnoField; - } - else - { - for(int pid=0; pidGetNumberOfFieldOnProfile(); pid++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(pid); - const char* locname = fop->GetLocalizationName(); - if(strcmp(locname, MED_GAUSS_ELNO) == 0 ) - { - this->FieldType = ElnoField; - } - else if(strcmp(locname, MED_NO_LOCALIZATION) != 0 ) - { - this->FieldType |= QuadratureField; - } - else - { - this->FieldType |= CellField; - } - } - } - } - } - - if(this->FieldType == UnknownFieldType) - this->FieldType = PointField; -} - -int vtkMedField::HasManyFieldTypes() -{ - int numberOfTypes = 0; - numberOfTypes += (this->FieldType & vtkMedField::PointField) != 0; - numberOfTypes += (this->FieldType & vtkMedField::CellField) != 0; - numberOfTypes += (this->FieldType & vtkMedField::QuadratureField) != 0; - numberOfTypes += (this->FieldType & vtkMedField::ElnoField) != 0; - - return numberOfTypes > 1; -} - -int vtkMedField::GetFirstType() -{ - if((this->FieldType & vtkMedField::PointField) != 0) - return vtkMedField::PointField; - - if((this->FieldType & vtkMedField::CellField) != 0) - return vtkMedField::CellField; - - if((this->FieldType & vtkMedField::QuadratureField) != 0) - return vtkMedField::QuadratureField; - - if((this->FieldType & vtkMedField::ElnoField) != 0) - return vtkMedField::ElnoField; -} - -void vtkMedField::ExtractFieldType(vtkMedField* otherfield, int type) -{ - this->SetName(otherfield->GetName()); - this->SetLocal(otherfield->GetLocal()); - this->SetMedIterator(otherfield->GetMedIterator()); - this->SetDataType(otherfield->GetDataType()); - this->SetMeshName(otherfield->GetMeshName()); - this->SetTimeUnit(otherfield->GetTimeUnit()); - this->SetParentFile(otherfield->GetParentFile()); - - this->SetNumberOfComponent(otherfield->GetNumberOfComponent()); - for(int i=0; i< this->GetNumberOfComponent(); i++) - { - this->GetComponentName()->SetValue(i, otherfield-> - GetComponentName()->GetValue(i)); - } - - this->AllocateNumberOfInterpolation(otherfield->GetNumberOfInterpolation()); - for(int i=0; iGetNumberOfInterpolation(); i++) - { - this->SetInterpolation(i, otherfield->GetInterpolation(i)); - } - - this->GetUnit()->SetNumberOfValues( - otherfield->GetUnit()->GetNumberOfValues()); - for(int i=0; iGetUnit()->GetNumberOfValues(); i++) - { - this->GetUnit()->SetValue(i, otherfield->GetUnit()->GetValue(i)); - } - - int nstep = otherfield->GetNumberOfFieldStep(); - map stepmap; - for(int stepid=0; stepidGetFieldStep(stepid); - vtkMedFieldStep* step = vtkMedFieldStep::New(); - step->SetComputeStep(otherstep->GetComputeStep()); - this->AddFieldStep(step); - step->Delete(); - - stepmap[otherstep] = step; - - vtkMedFieldStep* previousstep = NULL; - if(stepmap.find(otherstep->GetPreviousStep()) != stepmap.end()) - { - previousstep = stepmap[otherstep->GetPreviousStep()]; - } - step->SetPreviousStep(previousstep); - step->SetParentField(this); - step->SetMeshComputeStep(otherstep->GetMeshComputeStep()); - - for(int eid=0; eidGetNumberOfFieldOverEntity(); eid++) - { - vtkMedFieldOverEntity* fieldOverEntity = otherstep->GetFieldOverEntity(eid); - - if(type == vtkMedField::PointField) - { - if(fieldOverEntity->GetEntity().EntityType != MED_NODE) - { - continue; - } - step->AppendFieldOverEntity(fieldOverEntity); - otherstep->RemoveFieldOverEntity(fieldOverEntity); - fieldOverEntity->SetParentStep(step); - } - else if(type == vtkMedField::ElnoField) - { - if(fieldOverEntity->GetEntity().EntityType != MED_NODE_ELEMENT) - { - continue; - } - - step->AppendFieldOverEntity(fieldOverEntity); - otherstep->RemoveFieldOverEntity(fieldOverEntity); - eid--; - fieldOverEntity->SetParentStep(step); - } - else - { - if(fieldOverEntity->GetEntity().EntityType == MED_NODE) - { - continue; - } - vtkMedFieldOverEntity* newfoe = vtkMedFieldOverEntity::New(); - newfoe->SetEntity(fieldOverEntity->GetEntity()); - newfoe->SetHasProfile(fieldOverEntity->GetHasProfile()); - newfoe->SetParentStep(step); - step->AppendFieldOverEntity(newfoe); - newfoe->Delete(); - for(int pid=0; pidGetNumberOfFieldOnProfile(); pid++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(pid); - const char* locname = fop->GetLocalizationName(); - if((type == vtkMedField::QuadratureField - && strcmp(locname, MED_NO_LOCALIZATION) != 0) || - (type == vtkMedField::CellField - && strcmp(locname, MED_NO_LOCALIZATION) == 0 )) - { - newfoe->AppendFieldOnProfile(fop); - fieldOverEntity->RemoveFieldOnProfile(fop); - pid--; - fop->SetParentFieldOverEntity(newfoe); - } - } - if(fieldOverEntity->GetNumberOfFieldOnProfile() == 0) - { - otherstep->RemoveFieldOverEntity(fieldOverEntity); - eid--; - } - } - } - } - - this->ComputeFieldType(); - otherfield->ComputeFieldType(); -} - -void vtkMedField::SetNumberOfComponent(int ncomp) -{ - if (this->NumberOfComponent == ncomp) - return; - - this->NumberOfComponent = ncomp; - this->GetUnit()->SetNumberOfValues(this->NumberOfComponent); - this->GetComponentName()->SetNumberOfValues(this->NumberOfComponent); - - this->Modified(); -} - -void vtkMedField::AddFieldStep(vtkMedFieldStep* step) -{ - this->FieldStep->AddObject(step->GetComputeStep(), step); -} - -void vtkMedField::ClearFieldStep() -{ - this->FieldStep->clear(); -} - -vtkMedFieldStep* vtkMedField::GetFieldStep(const vtkMedComputeStep& cs) -{ - return this->FieldStep->GetObject(cs); -} - -vtkMedFieldStep* vtkMedField::FindFieldStep(const vtkMedComputeStep& cs, - int strategy) -{ - return this->FieldStep->FindObject(cs, strategy); -} - -med_int vtkMedField::GetNumberOfFieldStep() -{ - return this->FieldStep->GetNumberOfObject(); -} - -vtkMedFieldStep* vtkMedField::GetFieldStep(med_int id) -{ - return this->FieldStep->GetObject(id); -} - -void vtkMedField::GatherFieldTimes(std::set& times) -{ - this->FieldStep->GatherTimes(times); -} - -void vtkMedField::GatherFieldIterations(med_float time, - std::set& iterations) -{ - this->FieldStep->GatherIterations(time, iterations); -} - -void vtkMedField::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, MedIterator); - PRINT_IVAR(os, indent, NumberOfComponent); - PRINT_IVAR(os, indent, FieldType); - PRINT_IVAR(os, indent, DataType); - PRINT_IVAR(os, indent, Local); -} diff --git a/src/Plugins/MedReader/IO/vtkMedField.h b/src/Plugins/MedReader/IO/vtkMedField.h deleted file mode 100644 index 81eb9efa..00000000 --- a/src/Plugins/MedReader/IO/vtkMedField.h +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedField_h_ -#define __vtkMedField_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" - -#include "vtkSmartPointer.h" - -#include - -class vtkStringArray; - -class vtkMedInterpolation; -class vtkMedFieldOverEntity; -class vtkMedString; -class vtkMedFieldStep; -class vtkMedComputeStep; -template -class vtkMedComputeStepMap; -class vtkMedFile; - -class VTK_EXPORT vtkMedField: public vtkObject -{ -public: - static vtkMedField* New(); - vtkTypeMacro(vtkMedField, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // The number of component of this field - virtual void SetNumberOfComponent(int); - vtkGetMacro(NumberOfComponent, int); - - // Description: - // The type of data stored in this field - vtkSetMacro(DataType, med_field_type); - vtkGetMacro(DataType, med_field_type); - - // Description: - // The name of this field - vtkGetStringMacro(Name); - vtkSetStringMacro(Name); - - // Description: - // The name of this mesh this field is on - vtkGetStringMacro(MeshName); - vtkSetStringMacro(MeshName); - - // Description: - // The name of this mesh this field is on - vtkGetStringMacro(TimeUnit); - vtkSetStringMacro(TimeUnit); - - // Description: - // The units of each component of this field - vtkGetObjectMacro(Unit, vtkStringArray); - - // Description: - // The name of each component of this field - vtkGetObjectMacro(ComponentName, vtkStringArray); - - // Description: - // add a cell type as support to this field - void AddFieldStep(vtkMedFieldStep*); - void ClearFieldStep(); - vtkMedFieldStep* GetFieldStep(const vtkMedComputeStep&); - vtkMedFieldStep* FindFieldStep(const vtkMedComputeStep&, int); - med_int GetNumberOfFieldStep(); - vtkMedFieldStep* GetFieldStep(med_int); - void GatherFieldTimes(std::set&); - void GatherFieldIterations(med_float,std::set&); - - // Description: - // returns if the field is on point, cell, quadrature point or elno - //BTX - enum { - UnknownFieldType = 0x00, - PointField = 0x01, - CellField = 0x02, - QuadratureField = 0x04, - ElnoField = 0x08}; - //ETX - //Description: - // returns the type of field this is. The returned code is and OR between - // the different possible types. - vtkGetMacro(FieldType, int); - - // This computes the FieldType - // (currently, it does it by looking only at the first compute step) - virtual void ComputeFieldType(); - - // Description: - // This returns true if the FieldType is composed of several types - virtual int HasManyFieldTypes(); - - // Description: - // returns the first support type this field is on. - virtual int GetFirstType(); - - // Description: - // This methods extracts from the other field all the fields that are - // on the given support type and add them to the current field. - // It also updates the other FieldType ivar. - virtual void ExtractFieldType(vtkMedField* otherfield, int type); - - // Description: - // The index of this field in the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // if the mesh is local or not. - vtkSetMacro(Local, med_int); - vtkGetMacro(Local, med_int); - - // Description: - // The interpolation functions associated with this field - vtkGetObjectVectorMacro(Interpolation, vtkMedInterpolation); - vtkSetObjectVectorMacro(Interpolation, vtkMedInterpolation); - - // Description: - // This stores the file this field is stored on. - virtual void SetParentFile(vtkMedFile*); - vtkGetObjectMacro(ParentFile, vtkMedFile); - -protected: - vtkMedField(); - virtual ~vtkMedField(); - - vtkSetMacro(FieldType, int); - - int NumberOfComponent; - med_field_type DataType; - med_int MedIterator; - med_int Local; - char* Name; - char* MeshName; - char* TimeUnit; - int FieldType; - vtkMedFile* ParentFile; - - //BTX - vtkMedComputeStepMap* FieldStep; - vtkObjectVector* Interpolation; - //ETX - - vtkStringArray* Unit; - vtkStringArray* ComponentName; - -private: - vtkMedField(const vtkMedField&); // Not implemented. - void operator=(const vtkMedField&); // Not implemented. - -}; - -#endif //__vtkMedField_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFieldOnProfile.cxx b/src/Plugins/MedReader/IO/vtkMedFieldOnProfile.cxx deleted file mode 100644 index 2dd88932..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFieldOnProfile.cxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFieldOnProfile.h" - -#include "vtkObjectFactory.h" -#include "vtkDataArray.h" - -#include "vtkMedFieldOverEntity.h" -#include "vtkMedFieldStep.h" -#include "vtkMedField.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedProfile.h" - -vtkCxxSetObjectMacro(vtkMedFieldOnProfile, Data, vtkDataArray); -vtkCxxSetObjectMacro(vtkMedFieldOnProfile, Profile, vtkMedProfile); -vtkCxxSetObjectMacro(vtkMedFieldOnProfile, ParentFieldOverEntity, vtkMedFieldOverEntity); - -// vtkCxxRevisionMacro(vtkMedFieldOnProfile, "$Revision$") -vtkStandardNewMacro(vtkMedFieldOnProfile) - -vtkMedFieldOnProfile::vtkMedFieldOnProfile() -{ - this->MedIterator = -1; - this->ParentFieldOverEntity = NULL; - this->ProfileName = NULL; - this->ProfileSize = 0; - this->LocalizationName = NULL; - this->NumberOfIntegrationPoint = 0; - this->NumberOfValues = 0; - this->Data = NULL; - this->Profile = NULL; - this->SetProfileName(MED_NO_PROFILE); - this->SetLocalizationName(MED_NO_LOCALIZATION); -} - -vtkMedFieldOnProfile::~vtkMedFieldOnProfile() -{ - this->SetProfileName(NULL); - this->SetLocalizationName(NULL); - this->SetParentFieldOverEntity(NULL); - this->SetData(NULL); -} - -int vtkMedFieldOnProfile::GetHasProfile() -{ - cout << "Profile Name = " << this->ProfileName << endl; - return strcmp(this->ProfileName, MED_NO_PROFILE) != 0; -} - -int vtkMedFieldOnProfile::IsLoaded() -{ - return this->Data!=NULL - && this->Data->GetNumberOfTuples() == this->NumberOfValues; -} - -void vtkMedFieldOnProfile::Load(med_storage_mode mode) -{ - this->ParentFieldOverEntity->GetParentStep()->GetParentField() - ->GetParentFile()->GetMedDriver()->LoadField(this, mode); -} - -void vtkMedFieldOnProfile::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - - PRINT_IVAR(os, indent, MedIterator); - PRINT_IVAR(os, indent, ProfileSize); - PRINT_IVAR(os, indent, NumberOfIntegrationPoint); - PRINT_IVAR(os, indent, NumberOfValues); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFieldOnProfile.h b/src/Plugins/MedReader/IO/vtkMedFieldOnProfile.h deleted file mode 100644 index 65ff84c0..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFieldOnProfile.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFieldOnProfile_h_ -#define __vtkMedFieldOnProfile_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" -#include"vtkMedFilter.h" - -class vtkMedFieldOverEntity; -class vtkMedString; -class vtkDataArray; -class vtkMedProfile; - -class VTK_EXPORT vtkMedFieldOnProfile: public vtkObject -{ -public: - static vtkMedFieldOnProfile* New(); - vtkTypeMacro(vtkMedFieldOnProfile, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the iterator that is used while reading fromt he med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // This is the FieldOverEntity this profile is on - virtual void SetParentFieldOverEntity(vtkMedFieldOverEntity*); - vtkGetObjectMacro(ParentFieldOverEntity, vtkMedFieldOverEntity); - - // Description: - // This is the name of the profile used by this field. - vtkGetStringMacro(ProfileName); - vtkSetStringMacro(ProfileName); - - // Description: - // This is the name of the localization used by this field on this profile. - vtkGetStringMacro(LocalizationName); - vtkSetStringMacro(LocalizationName); - - // Description: - // This stores the size of the profile. - vtkSetMacro(ProfileSize, med_int); - vtkGetMacro(ProfileSize, med_int); - - // Description: - // This stores the number of integration points for this localization. - vtkSetMacro(NumberOfIntegrationPoint, med_int); - vtkGetMacro(NumberOfIntegrationPoint, med_int); - - // Description: - // The number of values of this field on this mesh - vtkSetMacro(NumberOfValues, med_int); - vtkGetMacro(NumberOfValues, med_int); - - // Description: - // the Data that store the values read from file - virtual void SetData(vtkDataArray*); - vtkGetObjectMacro(Data, vtkDataArray); - - // Description: - // the Profile object associated witht he profile name. - virtual void SetProfile(vtkMedProfile*); - vtkGetObjectMacro(Profile, vtkMedProfile); - - // Description: - // returns true if the data has been loaded - int IsLoaded(); - - // Description: - // returns true if the profile name is not MED_NO_PROFILE - int GetHasProfile(); - - // Description: - // Load the actual data of this field - void Load(med_storage_mode mode); - - // Description: - // Get/Set of the MED Filter for parallel reading. - //void SetFilter(const med_filter& filter){this->Filter = filter;} - //med_filter GetFilter(){return this->Filter;} - void SetFilter(vtkMedFilter* filter){this->Filter = filter;} - vtkMedFilter* GetFilter(){return this->Filter;} -protected: - vtkMedFieldOnProfile(); - virtual ~vtkMedFieldOnProfile(); - - med_int MedIterator; - vtkMedFieldOverEntity *ParentFieldOverEntity; - char* ProfileName; - med_int ProfileSize; - char* LocalizationName; - med_int NumberOfIntegrationPoint; - med_int NumberOfValues; - vtkDataArray* Data; - vtkMedProfile* Profile; - - //med_filter Filter; - vtkMedFilter *Filter; - -private: - vtkMedFieldOnProfile(const vtkMedFieldOnProfile&); // Not implemented. - void operator=(const vtkMedFieldOnProfile&); // Not implemented. - -}; - -#endif //__vtkMedFieldOnProfile_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFieldOverEntity.cxx b/src/Plugins/MedReader/IO/vtkMedFieldOverEntity.cxx deleted file mode 100644 index 70b48f06..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFieldOverEntity.cxx +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFieldOverEntity.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" - -#include "vtkMedUtilities.h" -#include "vtkMedMesh.h" -#include "vtkDataArray.h" -#include "vtkMedFieldOnProfile.h" -#include "vtkMedFieldStep.h" -#include "vtkMedField.h" - -vtkCxxGetObjectVectorMacro(vtkMedFieldOverEntity, FieldOnProfile, vtkMedFieldOnProfile); -vtkCxxSetObjectVectorMacro(vtkMedFieldOverEntity, FieldOnProfile, vtkMedFieldOnProfile); - -vtkCxxSetObjectMacro(vtkMedFieldOverEntity, ParentStep, vtkMedFieldStep); - -// vtkCxxRevisionMacro(vtkMedFieldOverEntity, "$Revision$") -vtkStandardNewMacro(vtkMedFieldOverEntity) - -vtkMedFieldOverEntity::vtkMedFieldOverEntity() -{ - this->FieldOnProfile = new vtkObjectVector(); - this->HasProfile = false; - this->ParentStep = NULL; -} - -vtkMedFieldOverEntity::~vtkMedFieldOverEntity() -{ - delete this->FieldOnProfile; - this->SetParentStep(NULL); -} - -void vtkMedFieldOverEntity::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFieldOverEntity.h b/src/Plugins/MedReader/IO/vtkMedFieldOverEntity.h deleted file mode 100644 index c86cc694..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFieldOverEntity.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFieldOverEntity_h_ -#define __vtkMedFieldOverEntity_h_ - -#include "vtkObject.h" -#include "vtkMed.h" - -#include "vtkMedSetGet.h" -#include "vtkMedUtilities.h" - -class vtkMedFieldOnProfile; -class vtkMedFieldStep; - -class VTK_EXPORT vtkMedFieldOverEntity: public vtkObject -{ -public: - static vtkMedFieldOverEntity* New(); - vtkTypeMacro(vtkMedFieldOverEntity, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // the support of the cells : one of - void SetEntity(const vtkMedEntity& entity){this->Entity = entity;} - const vtkMedEntity& GetEntity(){return this->Entity;} - - // Description: - // This is the vtkMedFieldStep that owns this vtkMedFieldOverEntity - virtual void SetParentStep(vtkMedFieldStep*); - vtkGetObjectMacro(ParentStep, vtkMedFieldStep); - - // Description: - // This array store for each profile the field over this profile - vtkGetObjectVectorMacro(FieldOnProfile, vtkMedFieldOnProfile); - vtkSetObjectVectorMacro(FieldOnProfile, vtkMedFieldOnProfile); - - // Description: - // This flag is set during the information pass, and tells if - // there is a profile of not. - // Note that if there is no profile, a dummy vtkMedFieldOnProfile - // is created to store the actual data. - vtkGetMacro(HasProfile, int); - vtkSetMacro(HasProfile, int); - -protected: - vtkMedFieldOverEntity(); - virtual ~vtkMedFieldOverEntity(); - - vtkMedFieldStep* ParentStep; - - vtkMedEntity Entity; - - int HasProfile; - - //BTX - vtkObjectVector* FieldOnProfile; - //ETX - -private: - vtkMedFieldOverEntity(const vtkMedFieldOverEntity&); // Not implemented. - void operator=(const vtkMedFieldOverEntity&); // Not implemented. -}; - -#endif //__vtkMedFieldOverEntity_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFieldStep.cxx b/src/Plugins/MedReader/IO/vtkMedFieldStep.cxx deleted file mode 100644 index a5b9147b..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFieldStep.cxx +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFieldStep.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" -#include "vtkMedUtilities.h" -#include "vtkMedFieldOverEntity.h" -#include "vtkMedField.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" - -vtkCxxGetObjectVectorMacro(vtkMedFieldStep, FieldOverEntity, vtkMedFieldOverEntity); -vtkCxxSetObjectVectorMacro(vtkMedFieldStep, FieldOverEntity, vtkMedFieldOverEntity); - -vtkCxxSetObjectMacro(vtkMedFieldStep, ParentField, vtkMedField); -vtkCxxSetObjectMacro(vtkMedFieldStep, PreviousStep, vtkMedFieldStep); - -// vtkCxxRevisionMacro(vtkMedFieldStep, "$Revision$") -vtkStandardNewMacro(vtkMedFieldStep) - -vtkMedFieldStep::vtkMedFieldStep() -{ - this->FieldOverEntity = new vtkObjectVector(); - this->PreviousStep = NULL; - this->ParentField = NULL; - this->MedIterator = -1; - this->EntityInfoLoaded = 0; -} - -vtkMedFieldStep::~vtkMedFieldStep() -{ - delete this->FieldOverEntity; - this->SetPreviousStep(NULL); - this->SetParentField(NULL); -} - -vtkMedFieldOverEntity* vtkMedFieldStep::GetFieldOverEntity( - const vtkMedEntity& entity) -{ - for(int id=0; id < this->GetNumberOfFieldOverEntity(); id++) - { - vtkMedFieldOverEntity* fieldOverEntity = this->GetFieldOverEntity(id); - if(fieldOverEntity->GetEntity() == entity) - return fieldOverEntity; - } - return NULL; -} - -void vtkMedFieldStep::LoadInformation() -{ - this->GetParentField()->GetParentFile()->GetMedDriver()-> - ReadFieldStepInformation(this, true); -} - -void vtkMedFieldStep::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_OBJECT_VECTOR(os, indent, FieldOverEntity); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFieldStep.h b/src/Plugins/MedReader/IO/vtkMedFieldStep.h deleted file mode 100644 index d8f766f9..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFieldStep.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFieldStep_h_ -#define __vtkMedFieldStep_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" -#include "vtkMedUtilities.h" - -class vtkMedString; -class vtkMedMesh; -class vtkDataArray; -class vtkMedFieldOverEntity; -class vtkMedField; - -class VTK_EXPORT vtkMedFieldStep: public vtkObject -{ -public: - static vtkMedFieldStep* New(); - vtkTypeMacro(vtkMedFieldStep, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This iterator is used when reading information from the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // The compute step of this field - void SetComputeStep(const vtkMedComputeStep& cs) - { - this->ComputeStep = cs; - } - const vtkMedComputeStep& GetComputeStep() const - { - return this->ComputeStep; - } - - // Description: - // The compute step of the mesh supporting this field at this step - void SetMeshComputeStep(const vtkMedComputeStep& cs) - { - this->MeshComputeStep = cs; - } - const vtkMedComputeStep& GetMeshComputeStep() const - { - return this->MeshComputeStep; - } - - // Description: - // Set the number of steps of this field over these cells. - vtkGetObjectVectorMacro(FieldOverEntity, vtkMedFieldOverEntity); - vtkSetObjectVectorMacro(FieldOverEntity, vtkMedFieldOverEntity); - - // Description: - // returns the vtkMedFieldOverEntity for the given Type and Geometry; - virtual vtkMedFieldOverEntity* - GetFieldOverEntity(const vtkMedEntity&); - - // Description: - // The parent field is the one that owns this step - virtual void SetParentField(vtkMedField*); - vtkGetObjectMacro(ParentField, vtkMedField); - - // Description: - // The parent field is the one that owns this step - virtual void SetPreviousStep(vtkMedFieldStep*); - vtkGetObjectMacro(PreviousStep, vtkMedFieldStep); - - virtual void LoadInformation(); - - // Description: - // This flag is used to delay loading information on all entity as long as possible - vtkSetMacro(EntityInfoLoaded, med_int); - vtkGetMacro(EntityInfoLoaded, med_int); - -protected: - vtkMedFieldStep(); - virtual ~vtkMedFieldStep(); - - int EntityInfoLoaded; - med_int MedIterator; - vtkMedComputeStep ComputeStep; - vtkMedComputeStep MeshComputeStep; - vtkMedField* ParentField; - vtkMedFieldStep* PreviousStep; - - //BTX - vtkObjectVector* FieldOverEntity; - //ETX - -private: - vtkMedFieldStep(const vtkMedFieldStep&); // Not implemented. - void operator=(const vtkMedFieldStep&); // Not implemented. -}; - -#endif //__vtkMedFieldStep_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFile.cxx b/src/Plugins/MedReader/IO/vtkMedFile.cxx deleted file mode 100644 index e4ba27a1..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFile.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFile.h" - -#include "vtkObjectFactory.h" -#include "vtkDataArraySelection.h" -#include "vtkSmartPointer.h" - -#include "vtkMedMesh.h" -#include "vtkMedField.h" -#include "vtkMedProfile.h" -#include "vtkMedLocalization.h" -#include "vtkMedUtilities.h" -#include "vtkMedLink.h" -#include "vtkMedDriver.h" -#include "vtkMedFactory.h" -#include "vtkMedStructElement.h" - -vtkCxxGetObjectVectorMacro(vtkMedFile, Mesh, vtkMedMesh); -vtkCxxSetObjectVectorMacro(vtkMedFile, Mesh, vtkMedMesh); - -vtkCxxGetObjectVectorMacro(vtkMedFile, Field, vtkMedField); -vtkCxxSetObjectVectorMacro(vtkMedFile, Field, vtkMedField); - -vtkCxxGetObjectVectorMacro(vtkMedFile, Profile, vtkMedProfile); -vtkCxxSetObjectVectorMacro(vtkMedFile, Profile, vtkMedProfile); - -vtkCxxGetObjectVectorMacro(vtkMedFile, Localization, vtkMedLocalization); -vtkCxxSetObjectVectorMacro(vtkMedFile, Localization, vtkMedLocalization); - -vtkCxxGetObjectVectorMacro(vtkMedFile, Link, vtkMedLink); -vtkCxxSetObjectVectorMacro(vtkMedFile, Link, vtkMedLink); - -vtkCxxGetObjectVectorMacro(vtkMedFile, StructElement, vtkMedStructElement); -vtkCxxSetObjectVectorMacro(vtkMedFile, StructElement, vtkMedStructElement); - -vtkCxxGetObjectVectorMacro(vtkMedFile, SupportMesh, vtkMedMesh); -vtkCxxSetObjectVectorMacro(vtkMedFile, SupportMesh, vtkMedMesh); - -vtkCxxSetObjectMacro(vtkMedFile, MedDriver, vtkMedDriver); - -//vtkCxxRevisionMacro(vtkMedFile, "$Revision$") -vtkStandardNewMacro(vtkMedFile) - -vtkMedFile::vtkMedFile() -{ - this->Comment = NULL; - this->Mesh = new vtkObjectVector (); - this->Field = new vtkObjectVector (); - this->Profile = new vtkObjectVector (); - this->Localization = new vtkObjectVector (); - this->Link = new vtkObjectVector (); - this->StructElement = new vtkObjectVector(); - this->SupportMesh = new vtkObjectVector(); - this->FileName = NULL; - this->MedDriver = NULL; - this->VersionMajor = -1; - this->VersionMinor = -1; - this->VersionRelease = -1; -} - -vtkMedFile::~vtkMedFile() -{ - this->SetComment(NULL); - delete this->Mesh; - delete this->Field; - delete this->Profile; - delete this->Localization; - delete this->Link; - delete this->StructElement; - delete this->SupportMesh; - this->SetFileName(NULL); - this->SetMedDriver(NULL); -} - -int vtkMedFile::CreateDriver() -{ - int major, minor, release; - vtkMedDriver* driver=vtkMedDriver::New(); - driver->SetMedFile(this); - bool canRead=driver->CanReadFile(); - if(!canRead) - { - driver->Delete(); - this->SetMedDriver(NULL); - return 0; - } - driver->ReadFileVersion(&major, &minor, &release); - driver->Delete(); - vtkMedFactory* factory=vtkMedFactory::New(); - driver=factory->NewMedDriver(major, minor, release); - factory->Delete(); - this->SetMedDriver(driver); - if (driver) - { - driver->SetMedFile(this); - return 1; - } - return 0; -} - -void vtkMedFile::ReadInformation() -{ - if(this->MedDriver == NULL) - { - if(!this->CreateDriver()) - return; - } - - // at this point, we know that we have a valid driver. - this->MedDriver->ReadFileInformation(this); -} - -vtkMedMesh* vtkMedFile::GetMesh(const char* str) -{ - for (int m = 0; m < this->Mesh->size(); m++) - { - vtkMedMesh* mesh = this->Mesh->at(m); - if (strcmp(mesh->GetName(), str) == 0) - { - return mesh; - } - } - return NULL; -} - -vtkMedProfile* vtkMedFile::GetProfile(const char* str) -{ - for (int profId = 0; profId < this->Profile->size(); profId++) - { - vtkMedProfile* profile = this->Profile->at(profId); - if (strcmp(profile->GetName(), str) == 0) - { - return profile; - } - } - return NULL; - -} - -vtkMedLocalization* vtkMedFile::GetLocalization(const char* str) -{ - for (int quadId = 0; quadId < this->Localization->size(); quadId++) - { - vtkMedLocalization* loc = this->Localization->at(quadId); - if (strcmp(loc->GetName(), str) == 0) - { - return loc; - } - } - return NULL; -} - -vtkMedStructElement* vtkMedFile::GetStructElement(const vtkMedEntity& entity) -{ - if(entity.EntityType != MED_STRUCT_ELEMENT) - return NULL; - - for(int selemit = 0; selemit < this->GetNumberOfStructElement(); selemit++) - { - vtkMedStructElement* structelem = this->GetStructElement(selemit); - if(structelem->GetGeometryType() == entity.GeometryType) - return structelem; - } - return NULL; -} - -void vtkMedFile::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - - PRINT_OBJECT_VECTOR(os, indent, Mesh); - PRINT_OBJECT_VECTOR(os, indent, Field); - PRINT_OBJECT_VECTOR(os, indent, Profile); - PRINT_OBJECT_VECTOR(os, indent, Localization); - PRINT_OBJECT_VECTOR(os, indent, Link); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFile.h b/src/Plugins/MedReader/IO/vtkMedFile.h deleted file mode 100644 index 0ffec230..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFile.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFile_h_ -#define __vtkMedFile_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" - -class vtkMedMesh; -class vtkMedField; -class vtkMedProfile; -class vtkMedLocalization; -class vtkMedLink; -class vtkMedDriver; -class vtkMedStructElement; -class vtkMedEntity; - -class VTK_EXPORT vtkMedFile: public vtkObject -{ -public: - static vtkMedFile* New(); - vtkTypeMacro(vtkMedFile, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Set the file name to read from - vtkSetStringMacro(FileName); - vtkGetStringMacro(FileName); - - // Description: - // This is the description of this file as stored in the med file. - vtkGetObjectMacro(MedDriver, vtkMedDriver); - - // Description: - // This method tries to create a new driver for this file. - // It returns 1 on success, 0 on failure. - virtual int CreateDriver(); - - // Description: - // read information from this file, and create the meta data structure - virtual void ReadInformation(); - - // Description: - // Container of the meshes. - vtkGetObjectVectorMacro(Mesh, vtkMedMesh); - vtkSetObjectVectorMacro(Mesh, vtkMedMesh); - virtual vtkMedMesh* GetMesh(const char*); - - // Description: - // Container of the fields. - vtkGetObjectVectorMacro(Field, vtkMedField); - vtkSetObjectVectorMacro(Field, vtkMedField); - - // Description: - // Container of the fields. - vtkGetObjectVectorMacro(Link, vtkMedLink); - vtkSetObjectVectorMacro(Link, vtkMedLink); - - // Description: - // Container of the profiles. - vtkGetObjectVectorMacro(Profile, vtkMedProfile); - vtkSetObjectVectorMacro(Profile, vtkMedProfile); - virtual vtkMedProfile* GetProfile(const char*); - - // Description: - // Container of the quadrature definitions. - vtkGetObjectVectorMacro(Localization, vtkMedLocalization); - vtkSetObjectVectorMacro(Localization, vtkMedLocalization); - virtual vtkMedLocalization* GetLocalization(const char*); - - // Description: - // This is the description of this file as stored in the med file. - vtkSetStringMacro(Comment); - vtkGetStringMacro(Comment); - - // Description: - // Those 3 numbers describe the version of med used to create this file. - vtkSetMacro(VersionMajor, int); - vtkGetMacro(VersionMajor, int); - vtkSetMacro(VersionMinor, int); - vtkGetMacro(VersionMinor, int); - vtkSetMacro(VersionRelease, int); - vtkGetMacro(VersionRelease, int); - - // Description: - // Get the structural elements models - vtkGetObjectVectorMacro(StructElement, vtkMedStructElement); - vtkSetObjectVectorMacro(StructElement, vtkMedStructElement); - vtkMedStructElement* GetStructElement(const vtkMedEntity&); - - // Description: - // Get the support mesh informations - vtkGetObjectVectorMacro(SupportMesh, vtkMedMesh); - vtkSetObjectVectorMacro(SupportMesh, vtkMedMesh); - -protected: - vtkMedFile(); - virtual ~vtkMedFile(); - - char * FileName; - vtkMedDriver* MedDriver; - virtual void SetMedDriver(vtkMedDriver*); - - int VersionMajor; - int VersionMinor; - int VersionRelease; - - char* Comment; - //BTX - vtkObjectVector* Mesh; - vtkObjectVector* Field; - vtkObjectVector* Profile; - vtkObjectVector* Localization; - vtkObjectVector* Link; - vtkObjectVector* StructElement; - vtkObjectVector* SupportMesh; - //ETX - -private: - vtkMedFile(const vtkMedFile&); // Not implemented. - void operator=(const vtkMedFile&); // Not implemented. -}; - -#endif //__vtkMedMetaData_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFilter.cxx b/src/Plugins/MedReader/IO/vtkMedFilter.cxx deleted file mode 100644 index 9187d761..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFilter.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFilter.h" - -#include "vtkObjectFactory.h" - -// vtkCxxRevisionMacro(vtkMedFilter, "$Revision$") -vtkStandardNewMacro(vtkMedFilter) - -vtkMedFilter::vtkMedFilter() -{ - _start = 0; - _stride = 0; - _count = 0; - _blocksize = 0; - _lastblocksize = 0; -} - -vtkMedFilter::~vtkMedFilter() -{ -} - -void vtkMedFilter::SetFilterSizes( int start, int stride, - int count, int blocksize, int lastblocksize ) -{ - _start = start; - _stride = stride; - _count = count; - _blocksize = blocksize; - _lastblocksize = lastblocksize; -} - -void vtkMedFilter::GetFilterSizes( int& start, int& stride, - int& count, int& blocksize, int& lastblocksize ) -{ - start = _start; - stride = _stride; - count = _count; - blocksize = _blocksize; - lastblocksize = _lastblocksize; -} - -void vtkMedFilter::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFilter.h b/src/Plugins/MedReader/IO/vtkMedFilter.h deleted file mode 100644 index 39772ccc..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFilter.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFilter_h_ -#define __vtkMedFilter_h_ - -#include "vtkObject.h" -#include"vtkMed.h" - -class VTK_EXPORT vtkMedFilter : public vtkObject -{ -public: - static vtkMedFilter* New(); - vtkTypeMacro(vtkMedFilter, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - void SetFilterSizes( int , int , int , int , int ); - - void GetFilterSizes( int& , int& , int& , int& , int& ); - -protected : - vtkMedFilter(); - ~vtkMedFilter(); - - //med_filter Filter; - int _start; - int _stride; - int _count; - int _blocksize; - int _lastblocksize; -}; - -#endif //__vtkMedFilter_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedFraction.cxx b/src/Plugins/MedReader/IO/vtkMedFraction.cxx deleted file mode 100644 index d2851a6a..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFraction.cxx +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedFraction.h" - -#include "vtkObjectFactory.h" - -#include "vtkIntArray.h" -#include "vtkDoubleArray.h" - -// vtkCxxRevisionMacro(vtkMedFraction, "$Revision$") -vtkStandardNewMacro(vtkMedFraction) - -vtkMedFraction::vtkMedFraction() -{ - this->Coefficients = vtkDoubleArray::New(); - this->Powers = vtkIntArray::New(); - this->DenominatorCoefficients = vtkDoubleArray::New(); - this->DenominatorPowers = vtkIntArray::New(); - this->NumberOfVariable = 0; -} - -vtkMedFraction::~vtkMedFraction() -{ - this->Coefficients->Delete(); - this->Powers->Delete(); - this->DenominatorCoefficients->Delete(); - this->DenominatorPowers->Delete(); -} - -vtkIntArray* vtkMedFraction::GetPowers() -{ - return this->Powers; -} - -vtkDoubleArray* vtkMedFraction::GetCoefficients() -{ - return this->Coefficients; -} - -vtkIntArray* vtkMedFraction::GetDenominatorPowers() -{ - return this->DenominatorPowers; -} - -vtkDoubleArray* vtkMedFraction::GetDenominatorCoefficients() -{ - return this->DenominatorCoefficients; -} - -void vtkMedFraction::SetNumberOfCoefficients(int ncoeff) -{ - this->Powers->SetNumberOfTuples(ncoeff); - this->Coefficients->SetNumberOfTuples(ncoeff); - - int* powers = this->Powers->GetPointer(0); - memset(powers, 0, ncoeff*this->Powers->GetNumberOfComponents()*sizeof(int)); - - double* coeffs = this->Coefficients->GetPointer(0); - memset(powers, 0, ncoeff*sizeof(double)); -} - -void vtkMedFraction::SetNumberOfDenominatorCoefficients(int ncoeff) -{ - this->DenominatorPowers->SetNumberOfTuples(ncoeff); - this->DenominatorCoefficients->SetNumberOfTuples(ncoeff); - - int* powers = this->DenominatorPowers->GetPointer(0); - memset(powers, 0, - ncoeff*this->DenominatorPowers->GetNumberOfComponents()*sizeof(int)); - - double* coeffs = this->DenominatorCoefficients->GetPointer(0); - memset(powers, 0, ncoeff*sizeof(double)); -} - -void vtkMedFraction::SetNumberOfVariable(int nbofvariable) -{ - int nvar; - if(nbofvariable <= 0) - { - nvar = 1; - } - else - { - nvar = nbofvariable; - } - - this->Powers->SetNumberOfComponents(nvar); - this->DenominatorPowers->SetNumberOfComponents(nvar); - - // force an allocation - this->Powers->SetNumberOfTuples( - this->Powers->GetNumberOfTuples()); - int* powers = this->Powers->GetPointer(0); - memset(powers, 0, - nvar*this->Powers->GetNumberOfComponents()*sizeof(int)); - - this->DenominatorPowers->SetNumberOfTuples( - this->DenominatorPowers->GetNumberOfTuples()); - int* denom_powers = this->DenominatorPowers->GetPointer(0); - memset(denom_powers, 0, - nvar*this->DenominatorPowers->GetNumberOfComponents()*sizeof(int)); - - this->NumberOfVariable = nbofvariable; -} - -double vtkMedFraction::Evaluate(double* coord) -{ - if(this->Coefficients->GetNumberOfTuples() == 0) - { - return 0.0; - } - - if(this->NumberOfVariable == 0) - { - return this->Coefficients->GetValue(0); - } - - double res = 0.0; - for(int coeffid = 0; coeffid < - this->Coefficients->GetNumberOfTuples(); coeffid++) - { - double prod = this->Coefficients->GetValue(coeffid); - for(int varid=0; varidNumberOfVariable; varid++) - { - prod *= pow(coord[varid], - this->Powers->GetValue( - this->NumberOfVariable*coeffid+varid)); - } - res += prod; - } - - double denom_res = 0.0; - - if(this->DenominatorCoefficients->GetNumberOfTuples() == 0) - { - denom_res = 1.0; - } - else - { - for(int coeffid = 0; coeffid < - this->DenominatorCoefficients->GetNumberOfTuples(); coeffid++) - { - double prod = this->DenominatorCoefficients->GetValue(coeffid); - for(int varid=0; varidNumberOfVariable; varid++) - { - prod *= pow(coord[varid], - this->DenominatorPowers->GetValue( - this->NumberOfVariable*coeffid+varid)); - } - denom_res += prod; - } - } - - return res / denom_res; -} - -double vtkMedFraction::Evaluate1(double coord) -{ - if(this->NumberOfVariable != 1) - { - vtkErrorMacro("Evaluate1 can only be called if the NumberOfVariable is 1"); - } - - return this->Evaluate(&coord); -} - -double vtkMedFraction::Evaluate2(double x, double y) -{ - if(this->NumberOfVariable != 2) - { - vtkErrorMacro("Evaluate2 can only be called if the NumberOfVariable is 2"); - } - - double coord[2] = {x, y}; - - return this->Evaluate(coord); -} - -double vtkMedFraction::Evaluate3(double x, double y, double z) -{ - if(this->NumberOfVariable != 3) - { - vtkErrorMacro("Evaluate3 can only be called if the NumberOfVariable is 3"); - } - - double coord[3] = {x, y, z}; - - return this->Evaluate(coord); -} - -void vtkMedFraction::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedFraction.h b/src/Plugins/MedReader/IO/vtkMedFraction.h deleted file mode 100644 index 9f210b73..00000000 --- a/src/Plugins/MedReader/IO/vtkMedFraction.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedFraction_h_ -#define __vtkMedFraction_h_ - -#include "vtkObject.h" - -class vtkIntArray; -class vtkDoubleArray; - -class VTK_EXPORT vtkMedFraction : public vtkObject -{ -public: - static vtkMedFraction* New(); - vtkTypeMacro(vtkMedFraction, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // the powers of this polynomial function - // the number of components of this array is equal to the maximum degree - // and the number of tuples to the numner of coefficients - virtual vtkIntArray* GetPowers(); - - // Description: - // The coefficients of this polynomial function - virtual vtkDoubleArray* GetCoefficients(); - - // Description: - // the powers of this polynomial function - // the number of components of this array is equal to the maximum degree - // and the number of tuples to the numner of coefficients - virtual vtkIntArray* GetDenominatorPowers(); - - // Description: - // The coefficients of this polynomial function - virtual vtkDoubleArray* GetDenominatorCoefficients(); - - // Description: - // This sets the number of coefficients in this polynom - void SetNumberOfCoefficients(int); - - // Description: - // This sets the number of coefficients in this polynom - void SetNumberOfDenominatorCoefficients(int); - - // Description: - // This sets the maximum degree of this polynom. - // This also allocates the array to store the powers of this - // polynom - void SetNumberOfVariable(int); - vtkGetMacro(NumberOfVariable, int); - - // Description: - // Evaluate the value of this function at this point. - virtual double Evaluate(double*); - virtual double Evaluate1(double); - virtual double Evaluate2(double, double); - virtual double Evaluate3(double, double, double); - -protected : - vtkMedFraction(); - ~vtkMedFraction(); - - vtkIntArray* Powers; - vtkDoubleArray* Coefficients; - - vtkIntArray* DenominatorPowers; - vtkDoubleArray* DenominatorCoefficients; - - int NumberOfVariable; - -private : - vtkMedFraction(const vtkMedFraction&); // Not implemented. - void operator=(const vtkMedFraction&); // Not implemented. -}; - -#endif //__vtkMedFraction_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedGrid.cxx b/src/Plugins/MedReader/IO/vtkMedGrid.cxx deleted file mode 100644 index 17d7da1d..00000000 --- a/src/Plugins/MedReader/IO/vtkMedGrid.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedGrid.h" - -#include "vtkObjectFactory.h" - -#include "vtkMedUtilities.h" -#include "vtkMedMesh.h" -#include "vtkMedIntArray.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedFamily.h" -#include "vtkMedEntityArray.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" - -#include -using std::set; - -vtkCxxGetObjectVectorMacro(vtkMedGrid, EntityArray, vtkMedEntityArray); -vtkCxxSetObjectVectorMacro(vtkMedGrid, EntityArray, vtkMedEntityArray); - -vtkCxxSetObjectMacro(vtkMedGrid, PointGlobalIds, vtkMedIntArray); -vtkCxxSetObjectMacro(vtkMedGrid, ParentMesh, vtkMedMesh); -vtkCxxSetObjectMacro(vtkMedGrid, PreviousGrid, vtkMedGrid); - -// vtkCxxRevisionMacro(vtkMedGrid, "$Revision$") - -vtkMedGrid::vtkMedGrid() -{ - this->ParentMesh = NULL; - this->PointGlobalIds = NULL; - this->PreviousGrid = NULL; - - this->CoordinateSystem = MED_CARTESIAN; - this->EntityArray = new vtkObjectVector(); - this->UsePreviousCoordinates = false; -} - -vtkMedGrid::~vtkMedGrid() -{ - this->SetPointGlobalIds(NULL); - this->SetParentMesh(NULL); - delete this->EntityArray; -} - -int vtkMedGrid::IsPointGlobalIdsLoaded() -{ - return this->PointGlobalIds != NULL - && this->PointGlobalIds->GetNumberOfTuples() - == this->GetNumberOfPoints(); -} - -void vtkMedGrid::ClearMedSupports() -{ - this->SetPointGlobalIds(NULL); -} - -vtkMedEntityArray* vtkMedGrid::GetEntityArray(const vtkMedEntity& entity) -{ - for(int id = 0; id < this->EntityArray->size(); id++) - { - vtkMedEntityArray* array = this->EntityArray->at(id); - if(array->GetEntity() == entity) - return array; - } - return NULL; -} - -void vtkMedGrid::GatherMedEntities(std::set& entities) -{ - for(int id = 0; id < this->EntityArray->size(); id++) - { - vtkMedEntityArray* array = this->EntityArray->at(id); - entities.insert(array->GetEntity()); - } -} - -void vtkMedGrid::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedGrid.h b/src/Plugins/MedReader/IO/vtkMedGrid.h deleted file mode 100644 index bee5c778..00000000 --- a/src/Plugins/MedReader/IO/vtkMedGrid.h +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedGrid_h_ -#define __vtkMedGrid_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMedUtilities.h" -#include "vtkMed.h" -#include "vtkMedIntArray.h" - -class vtkMedString; -class vtkMedFamilyOnEntity; -class vtkMedIntArray; - -class VTK_EXPORT vtkMedGrid : public vtkObject -{ -public : - vtkTypeMacro(vtkMedGrid, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This identifies the time and iteration of this grid - void SetComputeStep(vtkMedComputeStep cs) - { - this->ComputeStep = cs; - } - vtkMedComputeStep GetComputeStep() - { - return this->ComputeStep; - } - - // Description: - // returns the number of points. Each sub class has to implement this method. - virtual med_int GetNumberOfPoints() = 0; - - // Description: - // Initialize the global Ids of the first element of each MedEntityArray - virtual void InitializeCellGlobalIds(){;} - - // Description: - // this stores the array giving the family id for each point of this mesh. - //vtkGetObjectVectorMacro(PointFamilyData, vtkMedFamilyOnEntity); - //vtkSetObjectVectorMacro(PointFamilyData, vtkMedFamilyOnEntity); - //virtual vtkMedFamilyOnEntity* GetPointFamilyDataById(med_int id); - - // Description: - // Gather the families that are present on this mesh nodes - //virtual void ComputePointFamilies(); - - // Description: - // this array contains the global ids of the points used by the grid. - virtual void SetPointGlobalIds(vtkMedIntArray*); - vtkGetObjectMacro(PointGlobalIds, vtkMedIntArray); - - // Description: - // this array contains the family ids of the points used by the grid. - //virtual void SetPointFamilyIds(vtkMedIntArray*); - //vtkGetObjectMacro(PointFamilyIds, vtkMedIntArray); - - // Description: - // The mesh that use this grid - virtual void SetParentMesh(vtkMedMesh*); - vtkGetObjectMacro(ParentMesh, vtkMedMesh); - - // Description: - // The mesh that use this grid - virtual void SetPreviousGrid(vtkMedGrid*); - vtkGetObjectMacro(PreviousGrid, vtkMedGrid); - - // Description: - // returns 1 if the global Ids array is set, and the - // number of tuples matches the number of points - virtual int IsPointGlobalIdsLoaded(); - - // Description: - // clear the entity arrays storing the connectivity - virtual void ClearMedSupports(); - - // Description: - // This is the coordinate system the grid live in. - vtkSetMacro(CoordinateSystem, med_axis_type); - vtkGetMacro(CoordinateSystem, med_axis_type); - - // Description: - // This flag is set during the information loading, and tells if the - // coordinates of this grid at this step has changed from the previous step. - // if not, you should request the coordinates array from the previous grid - // instead of this one. - vtkSetMacro(UsePreviousCoordinates, bool); - vtkGetMacro(UsePreviousCoordinates, bool); - - // Description: - // Add a cell array to this unstructured grid. - // each cell array represents a different cell type. - vtkGetObjectVectorMacro(EntityArray, vtkMedEntityArray); - vtkSetObjectVectorMacro(EntityArray, vtkMedEntityArray); - - // Description: - // load the family ids using the driver - //void LoadPointFamilyIds(); - - virtual void LoadCoordinates() = 0; - virtual int IsCoordinatesLoaded() = 0; - - // Description: - // return the vtkMedEntityArray that match the Entity type, if any. - virtual vtkMedEntityArray* GetEntityArray(const vtkMedEntity&); - - virtual double* GetCoordTuple(med_int index) = 0; - - // Description: - // This will instanciate a new vtkDataSet object. - // The caller is responsible for deleting it. - virtual vtkDataSet* CreateVTKDataSet(vtkMedFamilyOnEntityOnProfile*) = 0; - - // Description: - // This utility method returns all vtkMedEntity types present in this grid - virtual void GatherMedEntities(std::set& entities); - -protected: - vtkMedGrid(); - virtual ~vtkMedGrid(); - - vtkMedComputeStep ComputeStep; - vtkMedIntArray* PointGlobalIds; - //vtkMedIntArray* PointFamilyIds; - - vtkMedMesh* ParentMesh; - - vtkMedGrid* PreviousGrid; - - //BTX - //vtkObjectVector* PointFamilyData; - //ETX - - bool UsePreviousCoordinates; - med_axis_type CoordinateSystem; - //BTX - vtkObjectVector* EntityArray; - //ETX - -private: - vtkMedGrid(const vtkMedGrid&); // Not implemented. - void operator=(const vtkMedGrid&); // Not implemented. - -}; - -#endif //__vtkMedGrid_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedGroup.h b/src/Plugins/MedReader/IO/vtkMedGroup.h deleted file mode 100644 index 23515bc2..00000000 --- a/src/Plugins/MedReader/IO/vtkMedGroup.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedGroup_h_ -#define __vtkMedGroup_h_ - -#include "vtkObject.h" - -class vtkMedString; - -class VTK_EXPORT vtkMedGroup : public vtkObject -{ -public : - static vtkMedGroup* New(); - vtkTypeMacro(vtkMedGroup, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the description of this file as stored in the med file. - vtkGetStringMacro(Name); - vtkSetStringMacro(Name); - - // Description: - // This ivar says if this group contains point or cell families - // This value is either vtkMedUtilities::OnPoint or vtkMedUtilities::OnCell -// vtkSetMacro(PointOrCell, int); -// vtkGetMacro(PointOrCell, int); - -protected: - vtkMedGroup(); - virtual ~vtkMedGroup(); - - char* Name; - -private: - vtkMedGroup(const vtkMedGroup&); // Not implemented. - void operator=(const vtkMedGroup&); // Not implemented. - -}; - -#endif //__vtkMedGroup_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedIntArray.cxx b/src/Plugins/MedReader/IO/vtkMedIntArray.cxx deleted file mode 100644 index 57d19e1c..00000000 --- a/src/Plugins/MedReader/IO/vtkMedIntArray.cxx +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedIntArray.h" - -#include "vtkObjectFactory.h" - -//---------------------------------------------------------------------------- -// vtkCxxRevisionMacro(vtkMedIntArray, "$Revision$"); -vtkStandardNewMacro(vtkMedIntArray); - -//---------------------------------------------------------------------------- -vtkMedIntArray::vtkMedIntArray(vtkIdType numComp): Superclass(numComp) -{ -} - -//---------------------------------------------------------------------------- -vtkMedIntArray::~vtkMedIntArray() -{ -} - -//---------------------------------------------------------------------------- -void vtkMedIntArray::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedIntArray.h b/src/Plugins/MedReader/IO/vtkMedIntArray.h deleted file mode 100644 index c56080c5..00000000 --- a/src/Plugins/MedReader/IO/vtkMedIntArray.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// .NAME vtkMedIntArray - dynamic, self-adjusting array of med_int -// .SECTION Description -// vtkMedIntArray is an array of values of type med_int. -// It provides methods for insertion and retrieval of values and will -// automatically resize itself to hold new data. -// If the med_int type is the same as the vtkIdType, -// this class inherits from the -// vtkIdType array, allowing safe shallow copies. - -#ifndef __vtkMedIntArray_h -#define __vtkMedIntArray_h - -#include "vtkMedUtilities.h" -#include "vtkMed.h" - -#include "vtkMedIntArrayInternal.h" -#include "vtkIdTypeArray.h" -#include "vtkIntArray.h" - -//BTX -template struct med_int_vtkIdType_Traits : IsSameTraits -{ - typedef vtkMedIntArrayInternal Superclass; -}; - -template <> struct med_int_vtkIdType_Traits - : IsSameTraits -{ - typedef vtkIdTypeArray Superclass; -}; -typedef med_int_vtkIdType_Traits::Superclass - vtkMedIntArraySuperclass; -//ETX - -class VTK_EXPORT vtkMedIntArray -//BTX -: public vtkMedIntArraySuperclass -//ETX -{ -public : - static vtkMedIntArray* New(); - vtkTypeMacro(vtkMedIntArray,vtkMedIntArraySuperclass); - void PrintSelf(ostream& os, vtkIndent indent); -protected: - vtkMedIntArray(vtkIdType numComp=1); - ~vtkMedIntArray(); -}; - -#endif diff --git a/src/Plugins/MedReader/IO/vtkMedIntArrayInternal.cxx b/src/Plugins/MedReader/IO/vtkMedIntArrayInternal.cxx deleted file mode 100644 index 0c749b0c..00000000 --- a/src/Plugins/MedReader/IO/vtkMedIntArrayInternal.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// Instantiate superclass first to give the template a DLL interface. -#include "vtkMed.h" - -#ifndef WIN32 -#include "vtkDataArrayTemplate.txx" -VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(med_int); - -#include "vtkArrayIteratorTemplate.txx" -VTK_ARRAY_ITERATOR_TEMPLATE_INSTANTIATE(med_int); -#endif - -#define __vtkMedIntArrayInternal_cxx -#include "vtkMedIntArrayInternal.h" - -#include "vtkObjectFactory.h" - -// vtkCxxRevisionMacro(vtkMedIntArrayInternal, "$Revision$"); -vtkStandardNewMacro(vtkMedIntArrayInternal); - -//---------------------------------------------------------------------------- -vtkMedIntArrayInternal::vtkMedIntArrayInternal(vtkIdType numComp): RealSuperclass(numComp) -{ -} - -//---------------------------------------------------------------------------- -vtkMedIntArrayInternal::~vtkMedIntArrayInternal() -{ -} - -//---------------------------------------------------------------------------- -void vtkMedIntArrayInternal::PrintSelf(ostream& os, vtkIndent indent) -{ - this->RealSuperclass::PrintSelf(os,indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedIntArrayInternal.h b/src/Plugins/MedReader/IO/vtkMedIntArrayInternal.h deleted file mode 100644 index d8af2007..00000000 --- a/src/Plugins/MedReader/IO/vtkMedIntArrayInternal.h +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// .NAME vtkMedIntArrayInternal - dynamic, self-adjusting array of med_int -// .SECTION Description -// vtkMedIntArray is an array of values of type med_int. -// It provides methods for insertion and retrieval of values and will -// automatically resize itself to hold new data. - -#ifndef __vtkMedIntArrayInternal_h -#define __vtkMedIntArrayInternal_h - -#include "vtkMed.h" - -// Tell the template header how to give our superclass a DLL interface. -#if !defined(__vtkMedIntArrayInternal_cxx) -# define VTK_DATA_ARRAY_TEMPLATE_TYPE med_int -#endif - -#include "vtkDataArray.h" -#include "vtkDataArrayTemplate.h" // Real Superclass - -// Fake the superclass for the wrappers. -#define vtkDataArray vtkDataArrayTemplate -class VTK_EXPORT vtkMedIntArrayInternal : public vtkDataArray -#undef vtkDataArray -{ -public: - static vtkMedIntArrayInternal* New(); - vtkTypeMacro(vtkMedIntArrayInternal,vtkDataArray); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Get the data type. - // This returns the - int GetDataType() - { if(sizeof(med_int) == sizeof(vtkIdType)) return VTK_ID_TYPE; - if(sizeof(med_int) == sizeof(int)) return VTK_INT; - if(sizeof(med_int) == sizeof(long)) return VTK_LONG; - return VTK_VOID; - } - - // Description: - // Copy the tuple value into a user-provided array. - void GetTupleValue(vtkIdType i, med_int* tuple) - { this->RealSuperclass::GetTupleValue(i, tuple); } - - // Description: - // Set the tuple value at the ith location in the array. - void SetTupleValue(vtkIdType i, const med_int* tuple) - { this->RealSuperclass::SetTupleValue(i, tuple); } - - // Description: - // Insert (memory allocation performed) the tuple into the ith location - // in the array. - void InsertTupleValue(vtkIdType i, const med_int* tuple) - { this->RealSuperclass::InsertTupleValue(i, tuple); } - - // Description: - // Insert (memory allocation performed) the tuple onto the end of the array. - vtkIdType InsertNextTupleValue(const med_int* tuple) - { return this->RealSuperclass::InsertNextTupleValue(tuple); } - - // Description: - // Get the data at a particular index. - med_int GetValue(vtkIdType id) - { return this->RealSuperclass::GetValue(id); } - - // Description: - // Set the data at a particular index. Does not do range checking. Make sure - // you use the method SetNumberOfValues() before inserting data. - void SetValue(vtkIdType id, med_int value) - { this->RealSuperclass::SetValue(id, value); } - - // Description: - // Specify the number of values for this object to hold. Does an - // allocation as well as setting the MaxId ivar. Used in conjunction with - // SetValue() method for fast insertion. - void SetNumberOfValues(vtkIdType number) - { this->RealSuperclass::SetNumberOfValues(number); } - - // Description: - // Insert data at a specified position in the array. - void InsertValue(vtkIdType id, med_int f) - { this->RealSuperclass::InsertValue(id, f); } - - // Description: - // Insert data at the end of the array. Return its location in the array. - vtkIdType InsertNextValue(med_int f) - { return this->RealSuperclass::InsertNextValue(f); } - - // Description: - // Get the address of a particular data index. Make sure data is allocated - // for the number of items requested. Set MaxId according to the number of - // data values requested. - med_int* WritePointer(vtkIdType id, vtkIdType number) - { return this->RealSuperclass::WritePointer(id, number); } - - // Description: - // Get the address of a particular data index. Performs no checks - // to verify that the memory has been allocated etc. - med_int* GetPointer(vtkIdType id) - { return this->RealSuperclass::GetPointer(id); } - - // Description: - // This method lets the user specify data to be held by the array. The - // array argument is a pointer to the data. size is the size of - // the array supplied by the user. Set save to 1 to keep the class - // from deleting the array when it cleans up or reallocates memory. - // The class uses the actual array provided; it does not copy the data - // from the suppled array. - void SetArray(med_int* array, vtkIdType size, int save) - { this->RealSuperclass::SetArray(array, size, save); } - void SetArray(med_int* array, vtkIdType size, int save, int deleteMethod) - { this->RealSuperclass::SetArray(array, size, save, deleteMethod); } - -protected: - vtkMedIntArrayInternal(vtkIdType numComp=1); - ~vtkMedIntArrayInternal(); - -private: - //BTX - typedef vtkDataArrayTemplate RealSuperclass; - //ETX - vtkMedIntArrayInternal(const vtkMedIntArrayInternal&); // Not implemented. - void operator=(const vtkMedIntArrayInternal&); // Not implemented. -}; - -#endif diff --git a/src/Plugins/MedReader/IO/vtkMedInterpolation.cxx b/src/Plugins/MedReader/IO/vtkMedInterpolation.cxx deleted file mode 100644 index fddb066d..00000000 --- a/src/Plugins/MedReader/IO/vtkMedInterpolation.cxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedInterpolation.h" - -#include "vtkObjectFactory.h" - -#include "vtkMedUtilities.h" -#include "vtkMedFraction.h" - -// vtkCxxRevisionMacro(vtkMedInterpolation, "$Revision$") -vtkStandardNewMacro(vtkMedInterpolation) - -vtkCxxGetObjectVectorMacro(vtkMedInterpolation, BasisFunction, - vtkMedFraction); -vtkCxxSetObjectVectorMacro(vtkMedInterpolation, BasisFunction, - vtkMedFraction); - -vtkMedInterpolation::vtkMedInterpolation() -{ - this->GeometryType = MED_UNDEF_GEOTYPE; - this->IsCellNode = 1; - this->MaximumNumberOfCoefficient = 0; - this->MaximumDegree = 0; - this->NumberOfVariable = 0; - this->Name = NULL; - this->BasisFunction = new vtkObjectVector(); -} - -vtkMedInterpolation::~vtkMedInterpolation() -{ - delete this->BasisFunction; - this->SetName(NULL); -} - -void vtkMedInterpolation::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedInterpolation.h b/src/Plugins/MedReader/IO/vtkMedInterpolation.h deleted file mode 100644 index 0f272369..00000000 --- a/src/Plugins/MedReader/IO/vtkMedInterpolation.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedInterpolation_h_ -#define __vtkMedInterpolation_h_ - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedSetGet.h" - -class vtkMedString; -class vtkMedFraction; - -class VTK_EXPORT vtkMedInterpolation : public vtkObject -{ -public: - static vtkMedInterpolation* New(); - vtkTypeMacro(vtkMedInterpolation, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // name of the interpolation function - vtkGetStringMacro(Name); - vtkSetStringMacro(Name); - - // Description: - // This is the iterator that should be used to read this interpolation - // in the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // Type geometrique des mailles - vtkSetMacro(GeometryType, med_geometry_type); - vtkGetMacro(GeometryType, med_geometry_type); - - // Description: - // 1 if the basis functions are relative to the vertices of the cell. - vtkSetMacro(IsCellNode, int); - vtkGetMacro(IsCellNode, int); - - // Description: - // Maximum degree of any coefficient of any basis function - vtkSetMacro(MaximumDegree, int); - vtkGetMacro(MaximumDegree, int); - - // Description: - // Maximum number of coefficients for any basis function - vtkSetMacro(MaximumNumberOfCoefficient, int); - vtkGetMacro(MaximumNumberOfCoefficient, int); - - // Description: - // Maximum number of coefficients for any basis function - vtkSetMacro(NumberOfVariable, int); - vtkGetMacro(NumberOfVariable, int); - - // Description: - // The basis functions - vtkGetObjectVectorMacro(BasisFunction, vtkMedFraction); - vtkSetObjectVectorMacro(BasisFunction, vtkMedFraction); - -protected : - vtkMedInterpolation(); - ~vtkMedInterpolation(); - - med_int MedIterator; - med_geometry_type GeometryType; - int IsCellNode; - int MaximumNumberOfCoefficient; - int MaximumDegree; - int NumberOfVariable; - char* Name; - vtkObjectVector* BasisFunction; -}; - -#endif //__vtkMedInterpolation_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedLink.cxx b/src/Plugins/MedReader/IO/vtkMedLink.cxx deleted file mode 100644 index 1b320cbb..00000000 --- a/src/Plugins/MedReader/IO/vtkMedLink.cxx +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedLink.h" - -#include "vtkObjectFactory.h" - -#include "vtkMedUtilities.h" - -#include -using namespace std; - -// vtkCxxRevisionMacro(vtkMedLink, "$Revision$") -vtkStandardNewMacro(vtkMedLink) - -vtkMedLink::vtkMedLink() -{ - this->MedIterator = -1; - this->MeshName = NULL; - this->Link = NULL; -} - -vtkMedLink::~vtkMedLink() -{ - this->SetMeshName(NULL); - this->SetLink(NULL); -} - -const char* vtkMedLink::GetFullLink(const char* originalFileName) -{ -#ifdef _WIN32 - static const char sep = '\\'; -#else - static const char sep = '/'; -#endif - - if(this->Link == NULL) - { - return NULL; - } - - // First test if the Link is a full path, then return it. - if(this->Link != NULL && this->Link[0] == sep) - { - return this->Link; - } - - string name = string(originalFileName); - size_t pos = name.find_last_of(sep); - if(pos == string::npos) - { - return this->Link; - } - - string clean_link = this->Link; - string to_remove = string(".") + sep; - int to_remove_size = to_remove.size(); - while(clean_link.substr(0, to_remove_size) == to_remove) - clean_link = clean_link.substr(to_remove_size, string::npos); - - string path = name.substr(0, pos+1); - this->FullLinkPath = path + clean_link; - return this->FullLinkPath.c_str(); -} - -void vtkMedLink::SetMountedIterator(med_class what, med_int mit) -{ - this->MountedIterator[what] = mit; -} - -med_int vtkMedLink::GetMountedIterator(med_class what) -{ - if(this->MountedIterator.find(what) == this->MountedIterator.end()) - return -1; - - return this->MountedIterator[what]; -} - -void vtkMedLink::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, MedIterator); -} diff --git a/src/Plugins/MedReader/IO/vtkMedLink.h b/src/Plugins/MedReader/IO/vtkMedLink.h deleted file mode 100644 index 9d994fa9..00000000 --- a/src/Plugins/MedReader/IO/vtkMedLink.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedLink_h_ -#define __vtkMedLink_h_ - -#include "vtkObject.h" -#include "vtkMed.h" - -#include -#include - -class vtkMedString; - -class VTK_EXPORT vtkMedLink: public vtkObject -{ -public: - static vtkMedLink* New(); - vtkTypeMacro(vtkMedLink, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // the index of this field in the med file. - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // Set the name of the mesh linked to. - vtkSetStringMacro(MeshName); - vtkGetStringMacro(MeshName); - - // Description: - // Set the name of the file this link points to. - vtkSetStringMacro(Link); - vtkGetStringMacro(Link); - - // Description: - // returns the full path to the linked file. - // If the Link is already a full path, it is returned. - // If the directory is a relative path, the returned path is the - // concatenation of the directory where the - // original file is in and the Link. - const char* GetFullLink(const char* originalFileName); - - // Description: - // this stores the iterator that should be used when unmounting this link - void SetMountedIterator(med_class, med_int); - med_int GetMountedIterator(med_class); - -protected: - vtkMedLink(); - virtual ~vtkMedLink(); - - med_int MedIterator; - char* MeshName; - char * Link; - - std::string FullLinkPath; - - // BTX - std::map Status; - std::map MountedIterator; - //ETX - -private: - vtkMedLink(const vtkMedLink&); // Not implemented. - void operator=(const vtkMedLink&); // Not implemented. - -}; - -#endif //__vtkMedLink_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedLocalization.cxx b/src/Plugins/MedReader/IO/vtkMedLocalization.cxx deleted file mode 100644 index 3406b8fa..00000000 --- a/src/Plugins/MedReader/IO/vtkMedLocalization.cxx +++ /dev/null @@ -1,701 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedLocalization.h" - -#include "vtkObjectFactory.h" -#include "vtkDoubleArray.h" -#include "vtkIntArray.h" -#include "vtkFunctionParser.h" - -#include "vtkMedUtilities.h" -#include "vtkMedSetGet.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedInterpolation.h" -#include "vtkMedFraction.h" - -#include "med.h" - -// SEG2 -const static int SEG2_dim = 1; -const static int SEG2_nnode = 2; -static const int SEG2_aster2med[SEG2_nnode] = -{0, 1}; -static const char* SEG2_varnames[SEG2_dim] = {"x"}; -static const char* SEG2_functions[SEG2_nnode] = -{"1/2*(1-x)", - "1/2*(1+x)"}; - -// SEG3 -const static int SEG3_dim = 1; -const static int SEG3_nnode = 3; -static const int SEG3_aster2med[SEG3_nnode] = -{0, 1, 2}; -static const char* SEG3_varnames[SEG3_dim] = {"x"}; -static const char* SEG3_functions[SEG3_nnode] = -{"-1/2*(1-x)*x", - "1/2*(1+x)*x", - "(1+x)*(1-x)"}; - -// SEG4 -const static int SEG4_dim = 1; -const static int SEG4_nnode = 4; -static const int SEG4_aster2med[SEG4_nnode] = -{0, 1, 2, 3}; -static const char* SEG4_varnames[SEG4_dim] = {"x"}; -static const char* SEG4_functions[SEG4_nnode] = -{"16/9*(1-x)*(x+1/3)*(x-1/3)", -"-16/9*(1+x)*(1/3-x)*(x+1/3)", -"16/27*(x-1)*(x+1)*(x-1/3)", -"-16/27*(x-1)*(x+1)*(x+1/3)"}; - -// TRIA3 -const static int TRIA3_dim = 2; -const static int TRIA3_nnode = 3; -static const int TRIA3_aster2med[TRIA3_nnode] = -{0, 1, 2}; -static const char* TRIA3_varnames[TRIA3_dim] = {"x", "y"}; -static const char* TRIA3_functions[TRIA3_nnode] = -{"1-x-y", - "x", - "y"}; - -// TRIA6 -const static int TRIA6_dim = 2; -const static int TRIA6_nnode = 6; -static const int TRIA6_aster2med[TRIA6_nnode] = -{0, 1, 2, 3, 4, 5}; -static const char* TRIA6_varnames[TRIA6_dim] = {"x", "y"}; -static const char* TRIA6_functions[TRIA6_nnode] = -{"-(1-x-y)*(1-2*(1-x-y))", - "-x*(1-2*x)", - "-y*(1-2*y)", - "4*x*(1-x-y)", - "4*x*y", - "4*y*(1-x-y)"}; - -// TRIA7 -const static int TRIA7_dim = 2; -const static int TRIA7_nnode = 7; -static const int TRIA7_aster2med[TRIA7_nnode] = -{0, 1, 2, 3, 4, 5, 6}; -static const char* TRIA7_varnames[TRIA7_dim] = {"x", "y"}; -static const char* TRIA7_functions[TRIA7_nnode] = -{"1-3*(x+y)+2*(x*x+y*y)+7*x*y-3*x*y*(x+y)", - "x*(-1+2*x+3*y-3*y*(x+y))", - "y*(-1+2*x+3*y-3*x*(x+y))", - "4*x*(1-x-4*y+3*y*(x+y))", - "4*x*y*(-2+3*(x+y))", - "4*y*(1-4*x-y+3*x*(x+y))", - "27*x*y*(1-x-y)"}; - -// QUAD4 -const static int QUAD4_dim = 2; -const static int QUAD4_nnode = 4; -static const int QUAD4_aster2med[QUAD4_nnode] = -{0, 1, 2, 3}; -static const char* QUAD4_varnames[QUAD4_dim] = {"x", "y"}; -static const char* QUAD4_functions[QUAD4_nnode] = -{"(1-x)*(1-y)/4", - "(1+x)*(1-y)/4", - "(1+x)*(1+y)/4", - "(1-x)*(1+y)/4"}; - -// QUAD8 -const static int QUAD8_dim = 2; -const static int QUAD8_nnode = 8; -static const int QUAD8_aster2med[QUAD8_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7}; -static const char* QUAD8_varnames[QUAD8_dim] = {"x", "y"}; -static const char* QUAD8_functions[QUAD8_nnode] = -{"(1-x)*(1-y)*(-1-x-y)/4", - "(1+x)*(1-y)*(-1+x-y)/4", - "(1+x)*(1+y)*(-1+x+y)/4", - "(1-x)*(1+y)*(-1-x+y)/4", - "(1-x*x)*(1-y)/2", - "(1+x)*(1-y*y)/2", - "(1-x*x)*(1+y)/2", - "(1-x)*(1-y*y)/2"}; - -// QUAD9 -const static int QUAD9_dim = 2; -const static int QUAD9_nnode = 9; -static const int QUAD9_aster2med[QUAD9_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8}; -static const char* QUAD9_varnames[QUAD9_dim] = {"x", "y"}; -static const char* QUAD9_functions[QUAD9_nnode] = -{"x*y*(x-1)*(y-1)/4", - "x*y*(x+1)*(y-1)/4", - "x*y*(x+1)*(y+1)/4", - "x*y*(x-1)*(y+1)/4", - "(1-x*x)*y*(y-1)/2", - "x*(x+1)*(1-y*y)/2", - "(1-x*x)*y*(y+1)/2", - "x*(x-1)*(1-y*y)/2", - "(1-x*x)*(1-y*y)"}; - -// PENTA6 -const static int PENTA6_dim = 3; -const static int PENTA6_nnode = 6; -static const int PENTA6_aster2med[PENTA6_nnode] = -{0, 1, 2, 3, 4, 5}; -static const char* PENTA6_varnames[PENTA6_dim] = {"x", "y", "z"}; -static const char* PENTA6_functions[PENTA6_nnode] = -{"1/2*y*(1-x)", - "1/2*z*(1-x)", - "1/2*(1-y-z)*(1-x)", - "1/2*y*(1+x)", - "1/2*z*(1+x)", - "1/2*(1-y-z)*(1+x)"}; - -// PENTA15 -const static int PENTA15_dim = 3; -const static int PENTA15_nnode = 15; -static const int PENTA15_aster2med[PENTA15_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 9, 10, 11}; -static const char* PENTA15_varnames[PENTA15_dim] = {"x", "y", "z"}; -static const char* PENTA15_functions[PENTA15_nnode] = -{"y*(1-x)*(2*y-2-x)/2", - "z*(1-x)*(2*z-2-x)/2", - "(x-1)*(1-y-z)*(x+2*y+2*z)/2", - "y*(1+x)*(2*y-2+x)/2", - "z*(1+x)*(2*z-2+x)/2", - "(-x-1)*(1-y-z)*(-x+2*y+2*z)/2", - "2*y*z*(1-x)", - "2*z*(1-y-z)*(1-x)", - "2*y*(1-y-z)*(1-x)", - "2*y*z*(1+x)", - "2*z*(1-y-z)*(1+x)", - "2*y*(1-y-z)*(1+x)", - "y*(1-x*x)", - "z*(1-x*x)", - "(1-y-z)*(1-x*x)"}; - - -// PENTA18 -const static int PENTA18_dim = 3; -const static int PENTA18_nnode = 18; -const static int PENTA18_aster2med[PENTA18_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 9, 10, 11, 15, 16, 17}; -static const char* PENTA18_varnames[PENTA18_dim] = {"x", "y", "z"}; -static const char* PENTA18_functions[PENTA18_nnode] = -{"x*y*(x−1)*(2*y−1)/2", - "x*z*(x−1)*(2*z−1)/2", - "x*(x−1)*(zy−1)*(2*z2*y−1)/2", - "x*y*(x1)*(2*y−1)/2", - "x*z*(x1)*(2*z−1)/2", - "x*(x1)*(zy−1)*(2*z2*y−1)/2", - "2*x*y*z*(x−1)", - "−2*x*z*(x−1)*(zy−1)", - "−2*x*y*(x−1)*(zy−1)", - "2*x*y*z*(x1)", - "−2*x*z*(x1)*(zy−1)", - "−2*x*y*(x1)*(zy−1)", - "y*(1−x*x)*(2*y−1)", - "z*(1−x*x)*(2*z−1)", - "(1−x*x)*(zy−1)*(2*z2*y−1)", - "4*y*z*(1−x*x)", - "4*z*(x−1)*(zy−1)", - "4*y*(x−1)*(zy−1)"}; - -// HEXA8 -const static int HEXA8_dim = 3; -const static int HEXA8_nnode = 8; -static const int HEXA8_aster2med[HEXA8_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7}; -static const char* HEXA8_varnames[HEXA8_dim] = {"x", "y", "z"}; -static const char* HEXA8_functions[HEXA8_nnode] = -{"1/8*(1-x)*(1-y)*(1-z)", - "1/8*(1+x)*(1-y)*(1-z)", - "1/8*(1+x)*(1+y)*(1-z)", - "1/8*(1-x)*(1+y)*(1-z)", - "1/8*(1-x)*(1-y)*(1+z)", - "1/8*(1+x)*(1-y)*(1+z)", - "1/8*(1+x)*(1+y)*(1+z)", - "1/8*(1-x)*(1+y)*(1+z)" - }; - -// HEXA20 -const static int HEXA20_dim = 3; -const static int HEXA20_nnode = 20; -static const int HEXA20_aster2med[HEXA20_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 12, 13, 14, 15}; -static const char* HEXA20_varnames[HEXA20_dim] = {"x", "y", "z"}; -static const char* HEXA20_functions[HEXA20_nnode] = -{"1/8*(1-x)*(1-y)*(1-z)*(-2-x-y-z)", - "1/8*(1+x)*(1-y)*(1-z)*(-2+x-y-z)", - "1/8*(1+x)*(1+y)*(1-z)*(-2+x+y-z)", - "1/8*(1-x)*(1+y)*(1-z)*(-2-x+y-z)", - "1/8*(1-x)*(1-y)*(1+z)*(-2-x-y+z)", - "1/8*(1+x)*(1-y)*(1+z)*(-2+x-y+z)", - "1/8*(1+x)*(1+y)*(1+z)*(-2+x+y+z)", - "1/8*(1-x)*(1+y)*(1+z)*(-2-x+y+z)", - "1/4*(1-x*x)*(1-y)*(1-z)", - "1/4*(1-y*y)*(1+x)*(1-z)", - "1/4*(1-x*x)*(1+y)*(1-z)", - "1/4*(1-y*y)*(1-x)*(1-z)", - "1/4*(1-x*x)*(1-y)*(1+z)", - "1/4*(1-y*y)*(1+x)*(1+z)", - "1/4*(1-x*x)*(1+y)*(1+z)", - "1/4*(1-y*y)*(1-x)*(1+z)", - "1/4*(1-z*z)*(1-x)*(1-y)", - "1/4*(1-z*z)*(1+x)*(1-y)", - "1/4*(1-z*z)*(1+x)*(1+y)", - "1/4*(1-z*z)*(1-x)*(1+y)" - }; -// HEXA27 -const static int HEXA27_dim = 3; -const static int HEXA27_nnode = 27; -static const int HEXA27_aster2med[HEXA27_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 12, 13, 14, 15, 24, 22, - 21, 23, 20, 25, 26}; -static const char* HEXA27_varnames[HEXA27_dim] = {"x", "y", "z"}; -static const char* HEXA27_functions[HEXA27_nnode] = -{"1/8*x*(x-1)*y*(y-1)*z*(z-1)", - "1/8*x*(x+1)*y*(y-1)*z*(z-1)", - "1/8*x*(x+1)*y*(y+1)*z*(z-1)", - "1/8*x*(x-1)*y*(y+1)*z*(z-1)", - "1/8*x*(x-1)*y*(y-1)*z*(z+1)", - "1/8*x*(x+1)*y*(y-1)*z*(z+1)", - "1/8*x*(x+1)*y*(y+1)*z*(z+1)", - "1/8*x*(x-1)*y*(y+1)*z*(z+1)", - "1/4*(1-x*x)*y*(y-1)*z*(z-1)", - "1/4*x*(x+1)*(1-y*y)*z*(z-1)", - "1/4*(1-x*x)*y*(y+1)*z*(z-1)", - "1/4*x*(x-1)*(1-y*y)*z*(z-1)", - "1/4*(1-x*x)*y*(y-1)*z*(z+1)", - "1/4*x*(x+1)*(1-y*y)*z*(z+1)", - "1/4*(1-x*x)*y*(y+1)*z*(z+1)", - "1/4*x*(x-1)*(1-y*y)*z*(z+1)", - "1/4*x*(x-1)*y*(y-1)*(1-z*z)", - "1/4*x*(x+1)*y*(y-1)*(1-z*z)", - "1/4*x*(x+1)*y*(y+1)*(1-z*z)", - "1/4*x*(x-1)*y*(y+1)*(1-z*z)", - "1/2*x*(x-1)*(1-y*y)*(1-z*z)", - "1/2*x*(x+1)*(1-y*y)*(1-z*z)", - "1/2*(1-x*x)*y*(y-1)*(1-z*z)", - "1/2*(1-x*x)*y*(y+1)*(1-z*z)", - "1/2*(1-x*x)*(1-y*y)*z*(z-1)", - "1/2*(1-x*x)*(1-y*y)*z*(z+1)", - "(1-x*x)*(1-y*y)*(1-z*z)" - }; - -// TETRA4 -const static int TETRA4_dim = 3; -const static int TETRA4_nnode = 4; -static const int TETRA4_aster2med[TETRA4_nnode] = -{0, 1, 2, 3}; -static const char* TETRA4_varnames[TETRA4_dim] = {"x", "y", "z"}; -static const char* TETRA4_functions[TETRA4_nnode] = -{ - "y", - "z", - "1-x-y-z", - "x" -}; - -// TETRA10 -const static int TETRA10_dim = 3; -const static int TETRA10_nnode = 10; -static const int TETRA10_aster2med[TETRA10_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; -static const char* TETRA10_varnames[TETRA10_dim] = {"x", "y", "z"}; -static const char* TETRA10_functions[TETRA10_nnode] = -{ - "y*(2*y-1)", - "z*(2*z-1)", - "(1-x-y-z)*(1-2*x-2*y-2*z)", - "x*(2*x-1)", - "4*y*z", - "4*z*(1-x-y-z)", - "4*y*(1-x-y-z)", - "4*x*y", - "4*x*z", - "4*x*(1-x-y-z)" -}; - -// PYRA5 -const static int PYRA5_dim = 3; -const static int PYRA5_nnode = 5; -static const int PYRA5_aster2med[PYRA5_nnode] = -{0, 1, 2, 3, 4}; -static const char* PYRA5_varnames[PYRA5_dim] = {"x", "y", "z"}; -static const char* PYRA5_functions[PYRA5_nnode] = -{ -"(-x+y+z-1)*(-x-y+z-1)/(4*(1-z))", -"(-x-y+z-1)*( x-y+z-1)/(4*(1-z))", -"( x-y+z-1)*( x+y+z-1)/(4*(1-z))", -"( x+y+z-1)*(-x+y+z-1)/(4*(1-z))", -"z" -}; - -// PYRA13 -const static int PYRA13_dim = 3; -const static int PYRA13_nnode = 13; -static const int PYRA13_aster2med[PYRA13_nnode] = -{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; -static const char* PYRA13_varnames[PYRA13_dim] = {"x", "y", "z"}; -static const char* PYRA13_functions[PYRA13_nnode] = -{ - "(-x+y+z-1)*(-x-y+z-1)*( x-1/2)/(2*(1-z))", - "(-x-y+z-1)*( x-y+z-1)*( y-1/2)/(2*(1-z))", - "( x-y+z-1)*( x+y+z-1)*(-x-1/2)/(2*(1-z))", - "( x+y+z-1)*(-x+y+z-1)*(-y-1/2)/(2*(1-z))", - "2*z*(z-1/2)", - "-(-x+y+z-1)*(-x-y+z-1)*( x-y+z-1)/(2*(1-z))", - "-(-x-y+z-1)*( x-y+z-1)*( x+y+z-1)/(2*(1-z))", - "-( x-y+z-1)*( x+y+z-1)*(-x+y+z-1)/(2*(1-z))", - "-( x+y+z-1)*(-x+y+z-1)*(-x-y+z-1)/(2*(1-z))", - "(-x+y+z-1)*(-x-y+z-1)*z/(1-z)", - "(-x-y+z-1)*( x-y+z-1)*z/(1-z)", - "( x-y+z-1)*( x+y+z-1)*z/(1-z)", - "( x+y+z-1)*(-x+y+z-1)*z/(1-z)" -}; - -vtkCxxSetObjectMacro(vtkMedLocalization, ParentFile, vtkMedFile); -vtkCxxSetObjectMacro(vtkMedLocalization, Interpolation, vtkMedInterpolation); - -// vtkCxxRevisionMacro(vtkMedLocalization, "$Revision$") -vtkStandardNewMacro(vtkMedLocalization) - -vtkMedLocalization::vtkMedLocalization() -{ - this->GeometryType = MED_NONE; - this->NumberOfQuadraturePoint = 0; - this->Weights = vtkDoubleArray::New(); - this->PointLocalCoordinates = vtkDoubleArray::New(); - this->QuadraturePointLocalCoordinates = vtkDoubleArray::New(); - this->ShapeFunction = vtkDoubleArray::New(); - this->Name = NULL; - this->SectionName = NULL; - this->InterpolationName = NULL; - this->MedIterator = -1; - this->ParentFile = NULL; - this->SpaceDimension = 3; - this->NumberOfCellInSection = 0; - this->SectionGeometryType = MED_NONE; - this->Interpolation = NULL; - this->ShapeFunctionIsBuilt = 0; -} - -vtkMedLocalization::~vtkMedLocalization() -{ - this->SetName(NULL); - this->SetSectionName(NULL); - this->SetInterpolationName(NULL); - this->Weights->Delete(); - this->PointLocalCoordinates->Delete(); - this->QuadraturePointLocalCoordinates->Delete(); - this->ShapeFunction->Delete(); - this->SetInterpolation(NULL); - -} - -int vtkMedLocalization::GetSizeOfWeights() -{ - return this->NumberOfQuadraturePoint; -} - -int vtkMedLocalization::GetSizeOfPointLocalCoordinates() -{ - return vtkMedUtilities::GetNumberOfPoint(this->GeometryType) - * vtkMedUtilities::GetDimension(this->GeometryType); -} - -int vtkMedLocalization::GetSizeOfQuadraturePointLocalCoordinates() -{ - return this->NumberOfQuadraturePoint * vtkMedUtilities::GetDimension( - this->GeometryType); -} - -int vtkMedLocalization::GetSizeOfShapeFunction() -{ - return this->NumberOfQuadraturePoint * vtkMedUtilities::GetNumberOfPoint( - this->GeometryType); -} - -void vtkMedLocalization::BuildShapeFunction() -{ - if(this->ShapeFunctionIsBuilt) - return; - - if(this->Interpolation == NULL) - { - // If there is no interpolation given for this localization, - // I build the default aster shape function - - switch (this->GeometryType) - { - case MED_POINT1: - BuildPoint1(); - return; - case MED_SEG2: - BuildAsterShapeFunction(SEG2_dim, SEG2_nnode, - (const int *) SEG2_aster2med, - (const char**)SEG2_varnames, - (const char**)SEG2_functions); - break; - case MED_SEG3: - BuildAsterShapeFunction(SEG3_dim, SEG3_nnode, - (const int *) SEG3_aster2med, - (const char**)SEG3_varnames, - (const char**)SEG3_functions); - break; - case MED_SEG4: - BuildAsterShapeFunction(SEG4_dim, SEG4_nnode, - (const int *) SEG4_aster2med, - (const char**)SEG4_varnames, - (const char**)SEG4_functions); - break; - case MED_TRIA3: - BuildAsterShapeFunction(TRIA3_dim, TRIA3_nnode, - (const int *) TRIA3_aster2med, - (const char**)TRIA3_varnames, - (const char**)TRIA3_functions); - break; - case MED_TRIA6: - BuildAsterShapeFunction(TRIA6_dim, TRIA6_nnode, - (const int *) TRIA6_aster2med, - (const char**)TRIA6_varnames, - (const char**)TRIA6_functions); - break; - case MED_TRIA7: - BuildAsterShapeFunction(TRIA7_dim, TRIA7_nnode, - (const int *) TRIA7_aster2med, - (const char**)TRIA7_varnames, - (const char**)TRIA7_functions); - break; - case MED_QUAD4: - BuildAsterShapeFunction(QUAD4_dim, QUAD4_nnode, - (const int *) QUAD4_aster2med, - (const char**)QUAD4_varnames, - (const char**)QUAD4_functions); - break; - case MED_QUAD8: - BuildAsterShapeFunction(QUAD8_dim, QUAD8_nnode, - (const int *) QUAD8_aster2med, - (const char**)QUAD8_varnames, - (const char**)QUAD8_functions); - break; - case MED_QUAD9: - BuildAsterShapeFunction(QUAD9_dim, QUAD9_nnode, - (const int *) QUAD9_aster2med, - (const char**)QUAD9_varnames, - (const char**)QUAD9_functions); - break; - case MED_HEXA8: - BuildAsterShapeFunction(HEXA8_dim, HEXA8_nnode, - (const int *) HEXA8_aster2med, - (const char**)HEXA8_varnames, - (const char**)HEXA8_functions); - break; - case MED_HEXA20: - BuildAsterShapeFunction(HEXA20_dim, HEXA20_nnode, - (const int *) HEXA20_aster2med, - (const char**)HEXA20_varnames, - (const char**)HEXA20_functions); - break; - case MED_HEXA27: - BuildAsterShapeFunction(HEXA27_dim, HEXA27_nnode, - (const int *) HEXA27_aster2med, - (const char**)HEXA27_varnames, - (const char**)HEXA27_functions); - break; - case MED_TETRA4: - BuildAsterShapeFunction(TETRA4_dim, TETRA4_nnode, - (const int *) TETRA4_aster2med, - (const char**)TETRA4_varnames, - (const char**)TETRA4_functions); - break; - case MED_TETRA10: - BuildAsterShapeFunction(TETRA10_dim, TETRA10_nnode, - (const int *) TETRA10_aster2med, - (const char**)TETRA10_varnames, - (const char**)TETRA10_functions); - break; - case MED_PENTA6: - BuildAsterShapeFunction(PENTA6_dim, PENTA6_nnode, - (const int *) PENTA6_aster2med, - (const char**)PENTA6_varnames, - (const char**)PENTA6_functions); - break; - case MED_PENTA15: - BuildAsterShapeFunction(PENTA15_dim, PENTA15_nnode, - (const int *) PENTA15_aster2med, - (const char**)PENTA15_varnames, - (const char**)PENTA15_functions); - break; - case MED_PYRA5: - BuildAsterShapeFunction(PYRA5_dim, PYRA5_nnode, - (const int *) PYRA5_aster2med, - (const char**)PYRA5_varnames, - (const char**)PYRA5_functions); - break; - case MED_PYRA13: - BuildAsterShapeFunction(PYRA13_dim, PYRA13_nnode, - (const int *) PYRA13_aster2med, - (const char**)PYRA13_varnames, - (const char**)PYRA13_functions); - break; - default: - vtkErrorMacro("ERROR in vtkMedLocalization::BuildShapeFunction. " - << this->GeometryType - << " : Cell geometry not supported !!! "); - return; - } - } - else - { - this->BuildShapeFunctionFromInterpolation(); - } - this->ShapeFunctionIsBuilt = 1; -} - -void vtkMedLocalization::BuildShapeFunctionFromInterpolation() -{ - int nnodes = this->GeometryType % 100; - int dim = this->GeometryType / 100; - this->ShapeFunction->SetNumberOfValues(this->GetSizeOfShapeFunction()); - - int qpindex; - int nodeindex; - - vtkMedFraction* func; - - switch(dim) - { - case 0 : - this->ShapeFunction->SetValue(0, 1); - break; - default : - for(qpindex=0; qpindex < this->NumberOfQuadraturePoint; qpindex++ ) - { - double *coord = new double[dim]; - for(int dimid=0; dimidQuadraturePointLocalCoordinates - ->GetValue((qpindex * dim)+dimid); - } - - for(nodeindex=0; nodeindex < nnodes; nodeindex++) - { - func = this->Interpolation->GetBasisFunction(nodeindex); - this->ShapeFunction->SetValue( - qpindex*nnodes + nodeindex, func->Evaluate(coord)); - } - } - } -} - -void vtkMedLocalization::BuildAsterShapeFunction(int dim, - int nnodes, - const int* aster2med, - const char** varnames, - const char** functions) -{ - this->ShapeFunction->SetNumberOfValues( - this->NumberOfQuadraturePoint * nnodes); - - std::vector > parsers; - parsers.resize(nnodes); - for(int nodeindex=0; nodeindex < nnodes; nodeindex++) - { - parsers[nodeindex] = vtkSmartPointer::New(); - parsers[nodeindex]->SetFunction(functions[nodeindex]); - } - - for(int qpindex=0; qpindex < this->NumberOfQuadraturePoint; qpindex++ ) - { - - for(int nodeindex=0; nodeindex < nnodes; nodeindex++) - { - int mednodeindex = aster2med[nodeindex]; - vtkFunctionParser* parser = parsers[mednodeindex]; - for(int dimid=0; dimidQuadraturePointLocalCoordinates - ->GetValue((qpindex * dim)+dimid); - - parser->SetScalarVariableValue(varname, coord); - } - - double w = parser->GetScalarResult(); - - this->ShapeFunction->SetValue( - qpindex*nnodes + mednodeindex, w); - } - } -} - -void vtkMedLocalization::BuildPoint1() -{ - this->Weights->SetNumberOfValues(1); - this->ShapeFunction->SetNumberOfValues(1); - this->Weights->SetValue(0, 1); - this->ShapeFunction->SetValue(0, 1); -} - -void vtkMedLocalization::BuildCenter(med_geometry_type geometry) -{ - this->GeometryType = geometry; - this->NumberOfQuadraturePoint = 1; - int npts = vtkMedUtilities::GetNumberOfPoint(this->GeometryType); - this->ShapeFunction->SetNumberOfValues(npts); - this->Weights->SetNumberOfValues(1); - for (int i = 0; i < npts; i++) - { - this->ShapeFunction->SetValue(i, 1.0 / (double) npts); - } - this->Weights->SetValue(0, 1); - -} - -void vtkMedLocalization::BuildELNO(med_geometry_type geometry) -{ - this->GeometryType = geometry; - this->NumberOfQuadraturePoint = vtkMedUtilities::GetNumberOfPoint(geometry); - - int np2 = this->NumberOfQuadraturePoint * this->NumberOfQuadraturePoint; - this->ShapeFunction->SetNumberOfValues(np2); - this->Weights->SetNumberOfValues(this->NumberOfQuadraturePoint); - - for (int i = 0; i < np2; i++) - { - this->ShapeFunction->SetValue(i, 0); - } - for (int i = 0; i < this->NumberOfQuadraturePoint; i++) - { - this->ShapeFunction->SetValue(i + i * this->NumberOfQuadraturePoint, 1.0); - } - double w = 1.0 / (double) this->NumberOfQuadraturePoint; - for (int i = 0; i < this->NumberOfQuadraturePoint; i++) - { - this->Weights->SetValue(i, w); - } -} - -void vtkMedLocalization::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, GeometryType); - PRINT_IVAR(os, indent, NumberOfQuadraturePoint); - PRINT_IVAR(os, indent, MedIterator); -} diff --git a/src/Plugins/MedReader/IO/vtkMedLocalization.h b/src/Plugins/MedReader/IO/vtkMedLocalization.h deleted file mode 100644 index c769e2f0..00000000 --- a/src/Plugins/MedReader/IO/vtkMedLocalization.h +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedLocalization_h_ -#define __vtkMedLocalization_h_ - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkSmartPointer.h" - -class vtkMedString; -class vtkMedFile; -class vtkDoubleArray; -class vtkMedInterpolation; - -class VTK_EXPORT vtkMedLocalization : public vtkObject -{ -public: - static vtkMedLocalization* New(); - vtkTypeMacro(vtkMedLocalization, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the name of this definition - vtkSetStringMacro(Name); - vtkGetStringMacro(Name); - - // Description: - // This is the name of this definition - vtkSetStringMacro(SectionName); - vtkGetStringMacro(SectionName); - - // Description: - // This is the name of this definition - vtkSetStringMacro(InterpolationName); - vtkGetStringMacro(InterpolationName); - - // Description: - // This is the type of cell geometry this definition is for. - vtkSetMacro(GeometryType, med_geometry_type); - vtkGetMacro(GeometryType, med_geometry_type); - - // Description: - // This is the number of quadrature points in this definition. - vtkSetMacro(NumberOfQuadraturePoint, int); - vtkGetMacro(NumberOfQuadraturePoint, int); - - // Description: - // The index of this field in the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // The dimension of the space in which integration points are defined. - vtkSetMacro(SpaceDimension, med_int); - vtkGetMacro(SpaceDimension, med_int); - - // Description: - // The number of cell in a section for structural elements - vtkGetMacro(NumberOfCellInSection, med_int); - vtkSetMacro(NumberOfCellInSection, med_int); - - // Description: - // Type of cells that define the section, for structural elements. - vtkSetMacro(SectionGeometryType, med_geometry_type); - vtkGetMacro(SectionGeometryType, med_geometry_type); - - // Description: - // get the raw pointers to the internal arrays. - // Those arrays are allocated in SecureResources, - // and cleared in ClearResources - vtkGetObjectMacro(Weights, vtkDoubleArray); - vtkGetObjectMacro(PointLocalCoordinates, vtkDoubleArray); - vtkGetObjectMacro(QuadraturePointLocalCoordinates, vtkDoubleArray); - vtkGetObjectMacro(ShapeFunction, vtkDoubleArray); - - virtual int GetSizeOfWeights(); - virtual int GetSizeOfPointLocalCoordinates(); - virtual int GetSizeOfQuadraturePointLocalCoordinates(); - virtual int GetSizeOfShapeFunction(); - - virtual void BuildShapeFunction(); - virtual void BuildELNO(med_geometry_type geometry); - virtual void BuildCenter(med_geometry_type geometry); - - virtual void SetParentFile(vtkMedFile*); - vtkGetObjectMacro(ParentFile, vtkMedFile); - - // Description: - // The interpolation is the function that define how the interpolate - // value at integration points from values at reference points (usually nodes) - virtual void SetInterpolation(vtkMedInterpolation*); - vtkGetObjectMacro(Interpolation, vtkMedInterpolation); - -protected: - vtkMedLocalization(); - virtual ~vtkMedLocalization(); - - med_int MedIterator; - med_geometry_type GeometryType; - int NumberOfQuadraturePoint; - med_int SpaceDimension; - med_int NumberOfCellInSection; - med_geometry_type SectionGeometryType; - - vtkDoubleArray* Weights; - vtkDoubleArray* PointLocalCoordinates; - vtkDoubleArray* QuadraturePointLocalCoordinates; - vtkDoubleArray* ShapeFunction; - - char* Name; - char* SectionName; - char* InterpolationName; - - vtkMedFile* ParentFile; - - vtkMedInterpolation* Interpolation; - - int ShapeFunctionIsBuilt; - - virtual void BuildAsterShapeFunction(int dim, - int nnodes, - const int* med2aster, - const char** varnames, - const char** functions); - - virtual void BuildPoint1(); - - virtual void BuildShapeFunctionFromInterpolation(); - -private: - vtkMedLocalization(const vtkMedLocalization&); - // Not implemented. - void operator=(const vtkMedLocalization&); - // Not implemented. -}; - -#endif //__vtkMedQuadratureDefinition_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedMesh.cxx b/src/Plugins/MedReader/IO/vtkMedMesh.cxx deleted file mode 100644 index 65398d2a..00000000 --- a/src/Plugins/MedReader/IO/vtkMedMesh.cxx +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedMesh.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" -#include "vtkDataArray.h" - -#include "vtkMedFamily.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedGroup.h" -#include "vtkMedGrid.h" -#include "vtkMedUtilities.h" -#include "vtkMedIntArray.h" -#include "vtkMedFile.h" - -#include - -vtkCxxGetObjectVectorMacro(vtkMedMesh, CellFamily, vtkMedFamily); -vtkCxxSetObjectVectorMacro(vtkMedMesh, CellFamily, vtkMedFamily); -vtkCxxGetObjectVectorMacro(vtkMedMesh, PointFamily, vtkMedFamily); -vtkCxxSetObjectVectorMacro(vtkMedMesh, PointFamily, vtkMedFamily); - -vtkCxxGetObjectVectorMacro(vtkMedMesh, PointGroup, vtkMedGroup); -vtkCxxSetObjectVectorMacro(vtkMedMesh, PointGroup, vtkMedGroup); -vtkCxxGetObjectVectorMacro(vtkMedMesh, CellGroup, vtkMedGroup); -vtkCxxSetObjectVectorMacro(vtkMedMesh, CellGroup, vtkMedGroup); - -vtkCxxSetObjectMacro(vtkMedMesh, ParentFile, vtkMedFile); - -// vtkCxxRevisionMacro(vtkMedMesh, "$Revision$") -vtkStandardNewMacro(vtkMedMesh) - -vtkMedMesh::vtkMedMesh() -{ - this->GridStep = new vtkMedComputeStepMap (); - this->Name = NULL; - this->UniversalName = NULL; - this->Description = NULL; - this->TimeUnit = NULL; - this->CellFamily = new vtkObjectVector (); - this->PointFamily = new vtkObjectVector (); - this->PointGroup = new vtkObjectVector (); - this->CellGroup = new vtkObjectVector (); - this->AxisName = vtkStringArray::New(); - this->AxisUnit = vtkStringArray::New(); - this->AxisName->SetNumberOfValues(3); - this->AxisUnit->SetNumberOfValues(3); - this->MedIterator = -1; - this->MeshType = MED_UNDEF_MESH_TYPE; - this->StructuredGridType = MED_UNDEF_GRID_TYPE; - this->ParentFile = NULL; - this->AxisType = MED_CARTESIAN; - this->SortingType = MED_SORT_DTIT; - this->MeshDimension = 3; - this->SpaceDimension = 3; - this->IsSupportMesh = 0; -} - -vtkMedMesh::~vtkMedMesh() -{ - this->SetName(NULL); - this->SetUniversalName(NULL); - this->SetDescription(NULL); - delete this->CellFamily; - delete this->PointFamily; - delete this->PointGroup; - delete this->CellGroup; - this->AxisName->Delete(); - this->AxisUnit->Delete(); - delete this->GridStep; -} - -vtkMedGroup* vtkMedMesh::GetOrCreateGroup(int pointOrCell, const char* name) -{ - if(pointOrCell == vtkMedUtilities::OnCell) - { - for(int g = 0; g < this->CellGroup->size(); g++) - { - vtkMedGroup* group = this->CellGroup->at(g); - if(group != NULL && strcmp(name, group->GetName()) == 0) - { - return group; - } - } - vtkMedGroup* group = vtkMedGroup::New(); - this->CellGroup->push_back(group); - //group->SetPointOrCell(vtkMedUtilities::OnCell); - group->SetName(name); - group->Delete(); - return group; - } - else - { - for(int g = 0; g < this->PointGroup->size(); g++) - { - vtkMedGroup* group = this->PointGroup->at(g); - if(group != NULL && strcmp(name, group->GetName()) == 0) - { - return group; - } - } - vtkMedGroup* group = vtkMedGroup::New(); - this->CellGroup->push_back(group); - //group->SetPointOrCell(vtkMedUtilities::OnPoint); - group->SetName(name); - group->Delete(); - return group; - } - return NULL; -} - -int vtkMedMesh::GetNumberOfFamily() -{ - return this->GetNumberOfCellFamily() + this->GetNumberOfPointFamily(); -} - -vtkMedFamily* vtkMedMesh::GetFamily(int index) -{ - if(index < 0) - return NULL; - if(index < this->GetNumberOfCellFamily()) - return this->GetCellFamily(index); - else if(index < GetNumberOfFamily()) - return this->GetPointFamily(index - this->GetNumberOfCellFamily()); - else return NULL; -} - -vtkMedFamily* vtkMedMesh::GetOrCreateCellFamilyById(med_int id) -{ - for(int i = 0; i < this->GetNumberOfCellFamily(); i++) - { - vtkMedFamily* family = this->GetCellFamily(i); - if(family->GetId() == id) - { - return family; - } - } - vtkMedFamily* family = vtkMedFamily::New(); - family->SetId(id); - std::ostringstream sstr; - sstr << "UNDEFINED_CELL_FAMILY_" << id; - family->SetName(sstr.str().c_str()); - family->SetPointOrCell(vtkMedUtilities::OnCell); - family->SetMedIterator(-1); - this->AppendCellFamily(family); - family->Delete(); - return family; -} - -void vtkMedMesh::SetNumberOfAxis(int naxis) -{ - this->AxisName->SetNumberOfValues(naxis); - this->AxisUnit->SetNumberOfValues(naxis); -} - -int vtkMedMesh::GetNumberOfAxis() -{ - return this->AxisName->GetNumberOfValues(); -} - -vtkMedFamily* vtkMedMesh::GetOrCreatePointFamilyById(med_int id) -{ - for(int i = 0; i < this->GetNumberOfPointFamily(); i++) - { - vtkMedFamily* family = this->GetPointFamily(i); - - if(family->GetId() == id) - return family; - } - vtkMedFamily* family = vtkMedFamily::New(); - family->SetId(id); - std::ostringstream sstr; - sstr << "UNDEFINED_POINT_FAMILY_" << id; - family->SetName(sstr.str().c_str()); - family->SetPointOrCell(vtkMedUtilities::OnPoint); - this->AppendPointFamily(family); - family->Delete(); - return family; -} - -void vtkMedMesh::AddGridStep(vtkMedGrid* grid) -{ - this->GridStep->AddObject(grid->GetComputeStep(), grid); -} - -void vtkMedMesh::ClearGridStep() -{ - this->GridStep->clear(); -} - -vtkMedGrid* vtkMedMesh::GetGridStep(const vtkMedComputeStep& cs) -{ - return this->GridStep->GetObject(cs); -} - -vtkMedGrid* vtkMedMesh::FindGridStep(const vtkMedComputeStep& cs, - int strategy) -{ - return this->GridStep->FindObject(cs, strategy); -} - -void vtkMedMesh::GatherGridTimes(std::set& timeset) -{ - this->GridStep->GatherTimes(timeset); -} - -void vtkMedMesh::GatherGridIterations(med_float time, - std::set& iterationset) -{ - this->GridStep->GatherIterations(time, iterationset); -} - -void vtkMedMesh::ClearMedSupports() -{ - med_int stepnb = this->GridStep->GetNumberOfObject(); - for(med_int stepid = 0; stepidGridStep->GetObject(stepid); - grid->ClearMedSupports(); - } -} - -med_int vtkMedMesh::GetNumberOfGridStep() -{ - return this->GridStep->GetNumberOfObject(); -} - -vtkMedGrid* vtkMedMesh::GetGridStep(med_int id) -{ - return this->GridStep->GetObject(id); -} - -void vtkMedMesh::GatherMedEntities(std::set& entities) -{ - vtkMedGrid* firstStep = this->GetGridStep(0); - if(firstStep == NULL) - return; - - firstStep->GatherMedEntities(entities); -} - -void vtkMedMesh::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, MedIterator); - PRINT_OBJECT_VECTOR(os, indent, CellFamily); - PRINT_OBJECT_VECTOR(os, indent, PointFamily); - PRINT_OBJECT_VECTOR(os, indent, PointGroup); - PRINT_OBJECT_VECTOR(os, indent, CellGroup); - -} diff --git a/src/Plugins/MedReader/IO/vtkMedMesh.h b/src/Plugins/MedReader/IO/vtkMedMesh.h deleted file mode 100644 index f17162cc..00000000 --- a/src/Plugins/MedReader/IO/vtkMedMesh.h +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedMesh_h_ -#define __vtkMedMesh_h_ - -#include "vtkObject.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" -#include "vtkMedUtilities.h" - -class vtkMedGrid; -class vtkMedFamily; -class vtkMedGroup; -class vtkMedString; -class vtkMedIntArray; -class vtkMedComputeStep; -class vtkMedFile; -class vtkStringArray; - -#include - -class VTK_EXPORT vtkMedMesh: public vtkObject -{ -public: - static vtkMedMesh* New(); - vtkTypeMacro(vtkMedMesh, vtkObject); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // The name of the mesh in the med file. - vtkGetStringMacro(Name); - vtkSetStringMacro(Name); - - // Description: - // The universal name of the mesh. - vtkGetStringMacro(UniversalName); - vtkSetStringMacro(UniversalName); - - // Description: - // The name of the mesh in the med file. - vtkGetStringMacro(Description); - vtkSetStringMacro(Description); - - // Description: - // The unit of the time steps. - vtkGetStringMacro(TimeUnit); - vtkSetStringMacro(TimeUnit); - - // Description: - // The dimension of the space this mesh lives in - vtkSetMacro(SpaceDimension, med_int); - vtkGetMacro(SpaceDimension, med_int); - - // Description: - // The dimension of this mesh - vtkSetMacro(MeshDimension, med_int); - vtkGetMacro(MeshDimension, med_int); - - // Description: - // The type of grid used by this mesh - vtkSetMacro(MeshType, med_mesh_type); - vtkGetMacro(MeshType, med_mesh_type); - - // Description: - // This stores how the compute steps should be iterated over - // either first by time or first by iteration - vtkSetMacro(SortingType, med_sorting_type); - vtkGetMacro(SortingType, med_sorting_type); - - // Description: - // This is the type of the axis - // MED_CARTESIAN, MED_CYLINDRICAL, MED_SPHERICAL or MED_UNDEF_AXIS_TYPE - vtkSetMacro(AxisType, med_axis_type); - vtkGetMacro(AxisType, med_axis_type); - - // Description: - // This is the type of the axis - // MED_CARTESIAN, MED_CYLINDRICAL, MED_SPHERICAL or MED_UNDEF_AXIS_TYPE - vtkSetMacro(StructuredGridType, med_grid_type); - vtkGetMacro(StructuredGridType, med_grid_type); - - // Description: - // a mesh can be modified over time, so this stores the - // different compute steps of a given mesh - void AddGridStep(vtkMedGrid*); - void ClearGridStep(); - vtkMedGrid* GetGridStep(const vtkMedComputeStep&); - vtkMedGrid* FindGridStep(const vtkMedComputeStep&, int); - med_int GetNumberOfGridStep(); - vtkMedGrid* GetGridStep(med_int); - void GatherGridTimes(std::set&); - void GatherGridIterations(med_float,std::set&); - - // Description: - // Container of the cell families in this mesh - vtkGetObjectVectorMacro(CellFamily, vtkMedFamily); - vtkSetObjectVectorMacro(CellFamily, vtkMedFamily); - virtual vtkMedFamily* GetOrCreateCellFamilyById(med_int); - - // Description: - // Get the Point Families - vtkGetObjectVectorMacro(PointFamily, vtkMedFamily); - vtkSetObjectVectorMacro(PointFamily, vtkMedFamily); - virtual vtkMedFamily* GetOrCreatePointFamilyById(med_int); - - int GetNumberOfFamily(); - vtkMedFamily* GetFamily(int); - - // Description: - // Container of the groups in this mesh - vtkGetObjectVectorMacro(PointGroup, vtkMedGroup); - vtkSetObjectVectorMacro(PointGroup, vtkMedGroup); - vtkGetObjectVectorMacro(CellGroup, vtkMedGroup); - vtkSetObjectVectorMacro(CellGroup, vtkMedGroup); - virtual vtkMedGroup* GetOrCreateGroup(int pointOrCell, const char*); - - // Description: - // this id is the id to use when reading the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // This stores the name of each axis - vtkGetObjectMacro(AxisName, vtkStringArray); - - // Description: - // This stores the unit of each axis - vtkGetObjectMacro(AxisUnit, vtkStringArray); - - // Description: - // This sets the number of axis of this mesh, and also allocates - // the arrays to store the name and unit of each axis. - void SetNumberOfAxis(int); - int GetNumberOfAxis(); - - // Description: - // free the memory used by this mesh (coordinates, connectivity) - virtual void ClearMedSupports(); - - // Description: - // The name of the mesh in the med file. - virtual void SetParentFile(vtkMedFile*); - vtkGetObjectMacro(ParentFile, vtkMedFile); - - // Description: - // This helper method fills the std::set with all vtkMedEntity types used in the first grid step - // MED specifies that all types must be present in the first step for a varying mesh to be valid - virtual void GatherMedEntities(std::set& entities); - -protected: - vtkMedMesh(); - virtual ~vtkMedMesh(); - - char* Name; - char* UniversalName; - char* Description; - char* TimeUnit; - med_int MedIterator; - med_int SpaceDimension; - med_int MeshDimension; - med_mesh_type MeshType; - med_sorting_type SortingType; - med_axis_type AxisType; - med_grid_type StructuredGridType; - - vtkMedFile* ParentFile; - - vtkObjectVector* CellFamily; - vtkObjectVector* PointFamily; - - vtkObjectVector* PointGroup; - vtkObjectVector* CellGroup; - - vtkStringArray* AxisName; - vtkStringArray* AxisUnit; - - vtkMedComputeStepMap* GridStep; - - bool IsSupportMesh; - -private: - vtkMedMesh(const vtkMedMesh&); // Not implemented. - void operator=(const vtkMedMesh&); // Not implemented. - -}; - -#endif //__vtkMedMesh_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedPolarGrid.h b/src/Plugins/MedReader/IO/vtkMedPolarGrid.h deleted file mode 100644 index c3ccb5a8..00000000 --- a/src/Plugins/MedReader/IO/vtkMedPolarGrid.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedPolarGrid_h_ -#define __vtkMedPolarGrid_h_ - -#include "vtkMedRegularGrid.h" - -class VTK_EXPORT vtkMedPolarGrid : public vtkMedRegularGrid -{ -public : - static vtkMedPolarGrid* New(); - vtkTypeMacro(vtkMedPolarGrid, vtkMedRegularGrid); - void PrintSelf(ostream& os, vtkIndent indent); - -protected: - vtkMedPolarGrid(); - virtual ~vtkMedPolarGrid(); - -private: - vtkMedPolarGrid(const vtkMedPolarGrid&); // Not implemented. - void operator=(const vtkMedPolarGrid&); // Not implemented. - -}; - -#endif //__vtkMedPolarGrid_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedProfile.cxx b/src/Plugins/MedReader/IO/vtkMedProfile.cxx deleted file mode 100644 index 2623ae41..00000000 --- a/src/Plugins/MedReader/IO/vtkMedProfile.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedProfile.h" - -#include "vtkObjectFactory.h" -#include "vtkMedIntArray.h" -#include "vtkMedSetGet.h" -#include "vtkMedUtilities.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" - -vtkCxxSetObjectMacro(vtkMedProfile,Ids,vtkMedIntArray); -vtkCxxSetObjectMacro(vtkMedProfile,ParentFile,vtkMedFile); - -// vtkCxxRevisionMacro(vtkMedProfile, "$Revision$"); -vtkStandardNewMacro(vtkMedProfile); - -vtkMedProfile::vtkMedProfile() -{ - this->NumberOfElement = 0; - this->Ids = NULL; - this->Name = NULL; - this->MedIterator = -1; - this->GeometryType = MED_NO_GEOTYPE; - this->ParentFile = NULL; -} - -vtkMedProfile::~vtkMedProfile() -{ - this->SetName(NULL); - this->SetIds(NULL); -} - -int vtkMedProfile::IsLoaded() -{ - return this->Ids != NULL && this->Ids->GetNumberOfComponents() - == 1 && this->Ids->GetNumberOfTuples() == this->NumberOfElement - && this->NumberOfElement > 0; -} - -void vtkMedProfile::Load() -{ - this->ParentFile->GetMedDriver()->LoadProfile(this); -} - -void vtkMedProfile::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, NumberOfElement); - PRINT_IVAR(os, indent, MedIterator); - PRINT_OBJECT(os, indent, Ids); -} diff --git a/src/Plugins/MedReader/IO/vtkMedProfile.h b/src/Plugins/MedReader/IO/vtkMedProfile.h deleted file mode 100644 index b1b3c98e..00000000 --- a/src/Plugins/MedReader/IO/vtkMedProfile.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedProfile_h_ -#define __vtkMedProfile_h_ - -#include "vtkObject.h" -#include "vtkMed.h" - -class vtkMedIntArray; -class vtkMedString; -class vtkMedFile; - -class VTK_EXPORT vtkMedProfile : public vtkObject -{ -public : - static vtkMedProfile* New(); - vtkTypeMacro(vtkMedProfile, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the number of elements of this profile - vtkSetMacro(NumberOfElement, vtkIdType); - vtkGetMacro(NumberOfElement, vtkIdType); - - // Description: - // The name of the profile in the file - vtkGetStringMacro(Name); - vtkSetStringMacro(Name); - - // Description: - // Allocate and clear memory of this profil. - virtual void SetIds(vtkMedIntArray*); - vtkGetObjectMacro(Ids, vtkMedIntArray); - - // Description: - // return true if the index array is not null and the size match - virtual int IsLoaded(); - - // Description: - // The index of this field in the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // Load the profile ids - void Load(); - - // Description: - // this is the file where this Profile is stored - virtual void SetParentFile(vtkMedFile*); - vtkGetObjectMacro(ParentFile, vtkMedFile); - -protected: - vtkMedProfile(); - virtual ~vtkMedProfile(); - - med_int MedIterator; - vtkIdType NumberOfElement; - vtkMedIntArray* Ids; - char* Name; - med_geometry_type GeometryType; - vtkMedFile* ParentFile; - -private: - vtkMedProfile(const vtkMedProfile&); // Not implemented. - void operator=(const vtkMedProfile&); // Not implemented. - -}; - -#endif //__vtkMedProfil_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedReader.cxx b/src/Plugins/MedReader/IO/vtkMedReader.cxx deleted file mode 100644 index 4e45660e..00000000 --- a/src/Plugins/MedReader/IO/vtkMedReader.cxx +++ /dev/null @@ -1,3158 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedReader.h" - -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedUtilities.h" -#include "vtkMedFamily.h" -#include "vtkMedGroup.h" -#include "vtkMedMesh.h" -#include "vtkMedUnstructuredGrid.h" -#include "vtkMedCurvilinearGrid.h" -#include "vtkMedRegularGrid.h" -#include "vtkMedEntityArray.h" -#include "vtkMedField.h" -#include "vtkMedFieldStep.h" -#include "vtkMedFieldOverEntity.h" -#include "vtkMedProfile.h" -#include "vtkMedIntArray.h" -#include "vtkMedLocalization.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedFieldOnProfile.h" -#include "vtkMedSelection.h" -#include "vtkMedFamilyOnEntityOnProfile.h" -#include "vtkMedLink.h" -#include "vtkMedInterpolation.h" -#include "vtkMedStructElement.h" -#include "vtkMedConstantAttribute.h" - -#include "vtkObjectFactory.h" -#include "vtkMutableDirectedGraph.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkUnsignedCharArray.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkSmartPointer.h" -#include "vtkVariantArray.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkExecutive.h" -#include "vtkStreamingDemandDrivenPipeline.h" -#include "vtkMultiTimeStepAlgorithm.h" -#include "vtkUnstructuredGrid.h" -#include "vtkMath.h" -#include "vtkPointData.h" -#include "vtkCellData.h" -#include "vtkFieldData.h" -#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" -#include "vtkQuadratureSchemeDefinition.h" -#include "vtkCellType.h" -#include "vtkCellArray.h" -#include "vtkDoubleArray.h" -#include "vtkConfigure.h" -#include "vtkMultiProcessController.h" -#include "vtkCommunicator.h" - -#include "vtkSMDoubleVectorProperty.h" -#include "vtkInformationDataObjectKey.h" - -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -struct VTKField -{ - vtkSmartPointer DataArray; - vtkSmartPointer Vectors; - vtkSmartPointer QuadratureIndexArray; -}; - -class vtkMedListOfFieldSteps : public std::list -{}; - -typedef int LocalizationKey; - -class vtkMedReader::vtkMedReaderInternal -{ -public: - int NumberOfPieces; - int CurrentPieceNumber; - int GhostLevel; - double UpdateTimeStep; - vtkTimeStamp FileNameMTime; - vtkTimeStamp MetaDataMTime; - vtkTimeStamp GroupSelectionMTime; - vtkTimeStamp FamilySelectionMTime; - int SILUpdateStamp; - int RealAnimationMode; - vtkMedSelection* Families; - - // this stores the aggregation of all compute steps from - // both meshes and fields. - std::map > GlobalComputeStep; - - // Store the vtkMutableDirectedGraph that represents links between family, groups and cell types - vtkMutableDirectedGraph* SIL; - - // this map is used to keep clean data sets in the cache, without any field. - // for each support, store the vtkDataSet - map > DataSetCache; - - // this is the current dataset for the given support. - map CurrentDataSet; - - // for each support, cache the VTK arrays that correspond to a given field at the given step. - map > FieldCache; - //map > FieldMatchCache; - - // This list keep tracks of all the currently selected supports - set UsedSupports; - - // this map keeps for each support, the quadrature offset array so that - // different fields on the same support can use - // the same offset array, provided they use the same gauss points definitions - map > > - QuadratureOffsetCache; - - map > QuadOffsetKey; - - std::map > MedFiles; - - vtkMedReaderInternal() - { - this->SIL=vtkMutableDirectedGraph::New(); - this->SILUpdateStamp=-1; - this->RealAnimationMode=vtkMedReader::PhysicalTime; - this->Families=vtkMedSelection::New(); - this->FamilySelectionMTime.Modified(); - this->GroupSelectionMTime.Modified(); - } - ~vtkMedReaderInternal() - { - this->SIL->Delete(); - this->Families->Delete(); - } - - void ClearSupportCache(vtkMedFamilyOnEntityOnProfile* foep) - { - //this->Med2VTKPointIndex.erase(foep); - this->QuadratureOffsetCache.erase(foep); - //this->FieldMatchCache.erase(foe); - this->FieldCache.erase(foep); - this->CurrentDataSet.erase(foep); - this->DataSetCache.erase(foep); - } - - vtkIdType GetChild(vtkIdType parent, const vtkStdString childName) - { - vtkStringArray* names=vtkStringArray::SafeDownCast( - this->SIL->GetVertexData()->GetArray("Names")); - if(names==NULL) - return -1; - vtkIdType nedges=this->SIL->GetOutDegree(parent); - for(vtkIdType id=0; idSIL->GetOutEdge(parent, id); - if(names->GetValue(edge.Target)==childName) - return edge.Target; - } - return -1; - } - - vtkIdType GetGroupId(const char* key) - { - std::string meshname, celltypename, groupname; - vtkMedUtilities::SplitGroupKey(key, meshname, celltypename, groupname); - vtkIdType root=GetChild(0, "SIL"); - if(root==-1) - return -1; - vtkIdType mesh=GetChild(root, meshname); - if(mesh==-1) - return -1; - vtkIdType type=GetChild(mesh, celltypename); - if(type==-1) - return -1; - return GetChild(type, groupname); - - } - -}; - -//vtkCxxRevisionMacro(vtkMedReader, "$Revision$"); -vtkStandardNewMacro(vtkMedReader); - -vtkMedReader::vtkMedReader() -{ - this->FileName=NULL; - this->SetNumberOfInputPorts(0); - this->PointFields=vtkMedSelection::New(); - this->CellFields=vtkMedSelection::New(); - this->QuadratureFields=vtkMedSelection::New(); - this->ElnoFields=vtkMedSelection::New(); - this->Entities=vtkMedSelection::New(); - this->Groups=vtkMedSelection::New(); - this->Frequencies=vtkMedSelection::New(); - this->AnimationMode=Default; - this->TimeIndexForIterations=0; - this->CacheStrategy=CacheGeometry; - this->Internal=new vtkMedReaderInternal; - this->TimePrecision=0.00001; - this->AvailableTimes=vtkDoubleArray::New(); - this->GenerateVectors = 0; -} - -vtkMedReader::~vtkMedReader() -{ - this->SetFileName(NULL); - this->PointFields->Delete(); - this->CellFields->Delete(); - this->QuadratureFields->Delete(); - this->ElnoFields->Delete(); - this->Entities->Delete(); - this->Groups->Delete(); - this->Frequencies->Delete(); - delete this->Internal; - this->AvailableTimes->Delete(); -} - -int vtkMedReader::GetSILUpdateStamp() -{ - return this->Internal->SILUpdateStamp; -} - -void vtkMedReader::SetFileName(const char* fname) -{ - int modified=0; - if(fname==this->FileName) - return; - if(fname&&this->FileName&&!strcmp(fname, this->FileName)) - return; - modified=1; - if(this->FileName) - delete[] this->FileName; - if (fname) - { - size_t fnl=strlen(fname)+1; - char* dst=new char[fnl]; - const char* src=fname; - this->FileName=dst; - do - { - *dst++=*src++; - } - while (--fnl); - } - else - { - this->FileName=0; - } - if (modified) - { - this->Modified(); - this->Internal->MedFiles.clear(); - this->Internal->FileNameMTime.Modified(); - } -} - -int vtkMedReader::CanReadFile(const char* fname) -{ - // the factory give a driver only when it can read the file version, - // or it returns a NULL pointer. - vtkSmartPointer file=vtkSmartPointer::New(); - file->SetFileName(fname); - - if(!file->CreateDriver()) - return 0; - - return 1; -} - -int vtkMedReader::RequestInformation(vtkInformation *request, - vtkInformationVector **inputVector, vtkInformationVector *outputVector) -{ - vtkInformation* outInfo = outputVector->GetInformationObject(0); - outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(),-1); - - if(this->Internal->MetaDataMTime <= this->Internal->FileNameMTime) - { - this->ClearCaches(Initialize); - - vtkMedFile* file=vtkMedFile::New(); - file->SetFileName(this->FileName); - this->Internal->MedFiles[this->FileName] = file; - file->Delete(); - - std::list file_stack; - file_stack.push_back(file); - - // if the file cannot create a driver, this means that the filename is not - // valid, or that I do not know how to read this file. - while (file_stack.size() > 0) - { - vtkMedFile* file = file_stack.front(); - file_stack.pop_front(); - // This reads information from disk - file->ReadInformation(); - - // add all files linked to in the current file to the files to read. - for (int linkid=0; linkidGetNumberOfLink(); linkid++) - { - vtkMedLink* link = file->GetLink(linkid); - const char* filename = link->GetFullLink(file->GetFileName()); - if(this->Internal->MedFiles.find(filename) == this->Internal->MedFiles.end()) - { - vtkMedFile* newfile = vtkMedFile::New(); - newfile->SetFileName(filename); - this->Internal->MedFiles[filename] = newfile; - file_stack.push_back(newfile); - newfile->Delete(); - } - } - } - - // This computes some meta information, like which field use which - // support, but do not read large data from disk. - this->LinkMedInfo(); - - // This computes the initial global id of each cell type. - this->InitializeCellGlobalIds(); - - this->ClearSelections(); - - this->BuildSIL(this->Internal->SIL); - this->Internal->SILUpdateStamp++; - - this->GatherComputeSteps(); - - this->Internal->MetaDataMTime.Modified(); - } - - outInfo->Set(vtkDataObject::SIL(), this->Internal->SIL); - request->AppendUnique(vtkExecutive::KEYS_TO_COPY(), - vtkDataObject::SIL()); - request->AppendUnique(vtkExecutive::KEYS_TO_COPY(), - vtkMedUtilities::BLOCK_NAME()); - this->AdvertiseTime(outInfo); - return 1; -} - -int vtkMedReader::RequestData(vtkInformation *request, - vtkInformationVector **inputVector, vtkInformationVector *outputVector) -{ - if(this->FileName==NULL) - { - vtkWarningMacro( << "FileName must be set and meta data loaded"); - return 0; - } - - vtkInformation *info=outputVector->GetInformationObject(0); - - vtkMultiBlockDataSet *output=vtkMultiBlockDataSet::SafeDownCast(info->Get( - vtkDataObject::DATA_OBJECT())); - - if (info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES())) - { - this->Internal->NumberOfPieces=info->Get( - vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()); - } - else - { - vtkMultiProcessController* controller = - vtkMultiProcessController::GetGlobalController(); - if(controller) - { - this->Internal->NumberOfPieces=controller->GetNumberOfProcesses(); - } - else - { - this->Internal->NumberOfPieces = 1; - } - } - if (info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER())) - { - this->Internal->CurrentPieceNumber=info->Get( - vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()); - } - else - { - this->Internal->CurrentPieceNumber=0; - vtkMultiProcessController* controller = - vtkMultiProcessController::GetGlobalController(); - if(controller) - { - this->Internal->CurrentPieceNumber= controller->GetLocalProcessId(); - } - else - { - this->Internal->CurrentPieceNumber=0; - } - } - - if (info->Has( - vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS())) - { - this->Internal->GhostLevel=info->Get( - vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS()); - } - else - { - this->Internal->GhostLevel=0; - } - - //vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() - /* if (info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) - { - this->Internal->UpdateTimeStep=info->Get( - vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())[0]; - } - else - { - this->Internal->UpdateTimeStep=0; - } */ - - if (info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) - { - this->Internal->UpdateTimeStep=info->Get( - vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); - } - else - { - this->Internal->UpdateTimeStep=0; - } - - this->InitializeParallelRead(); - output->Initialize(); - - this->ChooseRealAnimationMode(); - - std::list openlist; - std::map >::iterator - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - openlist.push_back(vtkMedDriver::FileOpen(file->GetMedDriver())); - fileit++; - } - - // clear the dataset cache of unneeded geometry - this->ClearCaches(StartRequest); - - // This call create the vtkMedSupports, but do not create the corresponding vtkDataSet; - this->CreateMedSupports(); - this->ClearCaches(AfterCreateMedSupports); - // This call creates the actual vtkDataSet that corresponds to each support - int supportId = 0; - int progress=0; - int maxprogress=2*this->Internal->UsedSupports.size(); - supportId = 0; - int it_counter = 0; - for(set::iterator it= - this->Internal->UsedSupports.begin(); it - !=this->Internal->UsedSupports.end(); it++) - { - ostringstream sstr; - vtkMedFamilyOnEntityOnProfile* foep = *it; - sstr<<"Support : "<GetFamilyOnEntity()->GetFamily()->GetName()); - this->SetProgressText(sstr.str().c_str()); - int doBuildSupportField = 1; - it_counter++; - this->BuildVTKSupport(foep, doBuildSupportField); - this->UpdateProgress((float) progress/((float) maxprogress-1)); - progress++; - supportId++; - } - - this->ClearCaches(EndBuildVTKSupports); - // This call maps the fields to the supports - for(set::iterator it= - this->Internal->UsedSupports.begin(); it - !=this->Internal->UsedSupports.end(); it++) - { - vtkMedFamilyOnEntityOnProfile* foep = *it; - if((foep->GetValid() == 0) && (this->Internal->NumberOfPieces == 1)) - continue; - ostringstream sstr; - sstr<<"Loading fields on "<GetFamilyOnEntity()->GetFamily()->GetName()); - this->SetProgressText(sstr.str().c_str()); - int doMapField = 1; - this->MapFieldsOnSupport(*it, doMapField); - this->UpdateProgress((float) progress/((float) maxprogress-1)); - progress++; - supportId++; - } - - // This call clean up caches (what is actually done depends of the CacheStrategy) - this->ClearCaches(EndRequest); - return 1; -} - -void vtkMedReader::InitializeCellGlobalIds() -{ - std::map >::iterator - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - fileit++; - for(int m=0; mGetNumberOfMesh(); m++) - { - vtkMedMesh* mesh = file->GetMesh(m); - med_int nstep = mesh->GetNumberOfGridStep(); - for(med_int stepid=0; stepidGetGridStep(stepid); - grid->InitializeCellGlobalIds(); - } - } - } -} - -// Method to create the filters for the MED parallel read functions -// It is defined here as we have all information for initialization -void vtkMedReader::InitializeParallelRead() -{ - // If there is only one process for reading no need to enter here - if (this->Internal->NumberOfPieces <= 1) - { - return; - } - - // FIRST: Generate filters for the cells - - std::map >::iterator - meshfit = this->Internal->MedFiles.begin(); - while(meshfit != this->Internal->MedFiles.end()) - { - vtkMedFile* meshfile = meshfit->second; - meshfit++; - med_idt pFileID = meshfile->GetMedDriver()->GetParallelFileId(); - - for(int mid=0; midGetNumberOfMesh(); mid++) - { - vtkMedMesh* mesh = meshfile->GetMesh(mid); - for(int gid=0; gidGetNumberOfGridStep(); gid++) - { - vtkMedGrid* grid = mesh->GetGridStep(gid); - // read point family data and create EntityArrays - - for(int eid=0; eid < grid->GetNumberOfEntityArray(); eid++) - { - vtkMedEntityArray* array = grid->GetEntityArray(eid); - - // Next continue is to avoid to create filters for the - // points, at the moment we charge the points in all nodes - if (array->GetEntity().GeometryType == MED_POINT1) // !MED_NODE - continue; - - med_int nbofconstituentpervalue = vtkMedUtilities::GetNumberOfNodes( - array->GetEntity().GeometryType); - if (nbofconstituentpervalue == -1) - vtkErrorMacro("Still not implemented for MED_POLYGON and MED_POLYHEDRON"); // à gerer - - // Calculating block sizes - int nEntity = array->GetNumberOfEntity(); - int block_size = ( nEntity / this->Internal->NumberOfPieces ); - med_size start = block_size * this->Internal->CurrentPieceNumber + 1; - med_size stride = block_size; - med_size count = 1; - med_size blocksize = block_size; - med_size lastblocksize = (nEntity % this->Internal->NumberOfPieces); - if ((this->Internal->NumberOfPieces == - this->Internal->CurrentPieceNumber+1) && (lastblocksize != 0)) - { - blocksize += lastblocksize; - stride += lastblocksize; - } - lastblocksize = 0; - - vtkMedFilter *filter = vtkMedFilter::New(); - filter->SetFilterSizes( start, stride, count, blocksize, lastblocksize ); - array->SetFilter(filter); - }//entity array - }// grid step - }//mesh - }//mesh file - - // SECOND: Filters for the Fields - - std::map >::iterator - fieldfileit; - // link the FieldOnProfile with the profiles - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* fieldfile = fieldfileit->second; - fieldfileit++; - med_idt pFileID = fieldfile->GetMedDriver()->GetParallelFileId(); - - for(int fid=0; fidGetNumberOfField(); fid++) - { - vtkMedField* field = fieldfile->GetField(fid); - - if (field->GetFieldType() == vtkMedField::CellField) - { - for(int sid = 0; sid< field->GetNumberOfFieldStep(); sid++) - { - vtkMedFieldStep* step = field->GetFieldStep(sid); - - for(int foeid = 0; foeid < step->GetNumberOfFieldOverEntity(); foeid++) - // TODO : seul le premier pas de temps est dispo au debut - { - vtkMedFieldOverEntity* fieldOverEntity = step->GetFieldOverEntity(foeid); - - for(int fopid = 0; fopid < fieldOverEntity->GetNumberOfFieldOnProfile(); fopid++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(fopid); - // Here implement the filters as before: - // 1- Modify vtkMedFieldOnProfile to contain a filter - // 2- Create the filters here only if they are on CELLs (use GetFieldType) - med_int nbofconstituentpervalue = field->GetNumberOfComponent(); - - int nVectors = fop->GetNumberOfValues(); - - int block_size = ( nVectors / this->Internal->NumberOfPieces ); - int start = block_size * this->Internal->CurrentPieceNumber + 1; - int stride = block_size; - int count = 1; - int blocksize = block_size; - int lastblocksize = (nVectors % this->Internal->NumberOfPieces); - if ((this->Internal->NumberOfPieces == - this->Internal->CurrentPieceNumber+1) && (lastblocksize != 0)) - { - blocksize += lastblocksize; - stride += lastblocksize; - } - lastblocksize = 0; - - vtkMedFilter *filter = vtkMedFilter::New(); - filter->SetFilterSizes( start, stride, count, blocksize, lastblocksize ); - fop->SetFilter(filter); - } - } - } - } // end IF - } - } - -} - -void vtkMedReader::LinkMedInfo() -{ - std::map >::iterator - fieldfileit; - // link the FieldOnProfile with the profiles - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* fieldfile = fieldfileit->second; - fieldfileit++; - - for(int fid=0; fidGetNumberOfField(); fid++) - { - vtkMedField* field = fieldfile->GetField(fid); - - for(int sid = 0; sid< field->GetNumberOfFieldStep(); sid++) - { - vtkMedFieldStep* step = field->GetFieldStep(sid); - - for(int foeid = 0; foeid < step->GetNumberOfFieldOverEntity(); foeid++) - { - vtkMedFieldOverEntity* fieldOverEntity = step->GetFieldOverEntity(foeid); - - for(int fopid = 0; fopid < fieldOverEntity->GetNumberOfFieldOnProfile(); fopid++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(fopid); - - std::map >::iterator - profilefileit = this->Internal->MedFiles.begin(); - while(profilefileit != this->Internal->MedFiles.end() && fop->GetProfile() == NULL) - { - vtkMedFile* profilefile = profilefileit->second; - profilefileit++; - - for(int pid = 0; pid < profilefile->GetNumberOfProfile(); pid++) - { - vtkMedProfile *profile = profilefile->GetProfile(pid); - if(strcmp(profile->GetName(), fop->GetProfileName()) == 0) - { - fop->SetProfile(profile); - break; - } - } - } - } - } - } - } - } - - // first, add a familyOnEntityOnProfile to all FamilyOnEntity with a NULL - // profile. This is used if no field is mapped to this support. - std::map >::iterator - meshfit = this->Internal->MedFiles.begin(); - while(meshfit != this->Internal->MedFiles.end()) - { - vtkMedFile* meshfile = meshfit->second; - meshfit++; - - for(int mid=0; midGetNumberOfMesh(); mid++) - { - vtkMedMesh* mesh = meshfile->GetMesh(mid); - - for(int gid=0; gidGetNumberOfGridStep(); gid++) - { - vtkMedGrid* grid = mesh->GetGridStep(gid); - // read point family data and create EntityArrays - - for(int eid=0; eid < grid->GetNumberOfEntityArray(); eid++) - { - vtkMedEntityArray* array = grid->GetEntityArray(eid); - - for(int fid=0; fid < array->GetNumberOfFamilyOnEntity(); fid++) - { - vtkMedFamilyOnEntity* foe = array->GetFamilyOnEntity(fid); - if(foe->GetFamilyOnEntityOnProfile((vtkMedProfile*)NULL) == NULL) - { - vtkMedFamilyOnEntityOnProfile* foep = - vtkMedFamilyOnEntityOnProfile::New(); - foep->SetFamilyOnEntity(foe); - foep->SetProfile(NULL); - foe->AddFamilyOnEntityOnProfile(foep); - foep->Delete(); - } - }//family on entity - }//entity array - }// grid step - }//mesh - }//mesh file - - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* fieldfile = fieldfileit->second; - fieldfileit++; - - for(int fieldid=0; fieldid < fieldfile->GetNumberOfField(); fieldid++) - { - vtkMedField* field = fieldfile->GetField(fieldid); - - for(int fstepid=0; fstepid < field->GetNumberOfFieldStep(); fstepid++) - { - vtkMedFieldStep* step = field->GetFieldStep(fstepid); - - vtkMedComputeStep meshcs = step->GetMeshComputeStep(); - - for(int foeid=0; foeidGetNumberOfFieldOverEntity() ;foeid++) - { - vtkMedFieldOverEntity* fieldOverEntity = step->GetFieldOverEntity(foeid); - const vtkMedEntity& fieldentity = fieldOverEntity->GetEntity(); - - for (int fopid = 0; - fopid < fieldOverEntity->GetNumberOfFieldOnProfile(); fopid++) - { - vtkMedFieldOnProfile* fop = - fieldOverEntity->GetFieldOnProfile(fopid); - - std::map >::iterator - meshfileit = this->Internal->MedFiles.begin(); - while(meshfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* meshfile = meshfileit->second; - meshfileit++; - - if(field->GetLocal() == 1 && (meshfile != fieldfile)) - continue; - - for(int mid=0; midGetNumberOfMesh(); mid++) - { - vtkMedMesh* mesh = meshfile->GetMesh(mid); - - // the field must be on this mesh. - if(strcmp(mesh->GetName(), - field->GetMeshName()) != 0) - continue; - - vtkMedGrid* grid = mesh->GetGridStep(meshcs); - if(grid == NULL) - { - vtkErrorMacro("the field " << field->GetName() - << " at step iteration:" - << step->GetComputeStep().IterationIt - << " and time " - << step->GetComputeStep().TimeIt - << " uses mesh at step " - << meshcs.TimeIt << " " << meshcs.IterationIt - << "which does not exists!"); - continue; - } - - for(int eid=0; eid < grid->GetNumberOfEntityArray(); eid++) - { - vtkMedEntityArray* array = grid->GetEntityArray(eid); - - // if the support is on points, - // the field must also be on points - if(array->GetEntity().EntityType == MED_NODE && - fieldentity.EntityType != MED_NODE) - continue; - - if(array->GetEntity().EntityType != MED_NODE && - fieldentity.EntityType == MED_NODE) - continue; - - // for fields not on points, the geometry type - // of the support must match - if(array->GetEntity().EntityType != MED_NODE && - array->GetEntity().GeometryType != fieldentity.GeometryType) - continue; - - for(int fid = 0; fid < array->GetNumberOfFamilyOnEntity(); fid++) - { - vtkMedFamilyOnEntity* foe = array->GetFamilyOnEntity(fid); - if(foe->GetFamilyOnEntityOnProfile(fop->GetProfile()) == NULL) - { - vtkMedFamilyOnEntityOnProfile* foep = - vtkMedFamilyOnEntityOnProfile::New(); - foep->SetProfile(fop->GetProfile()); - foep->SetFamilyOnEntity(foe); - foe->AddFamilyOnEntityOnProfile(foep); - foep->Delete(); - } - // also add the family on entity with no profile. - if(foe->GetFamilyOnEntityOnProfile((vtkMedProfile*)NULL) == NULL) - { - vtkMedFamilyOnEntityOnProfile* foep = - vtkMedFamilyOnEntityOnProfile::New(); - foep->SetProfile(NULL); - foep->SetFamilyOnEntity(foe); - foe->AddFamilyOnEntityOnProfile(foep); - foep->Delete(); - } - }//familyOnEntity - }//entityArray - }//mesh - }//mesh file - }//field on profile - }//fieldOverEntity - }//fiedstep - }// fieldid - }//fieldfileit - - // Now, link localizations and interpolations - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* fieldfile = fieldfileit->second; - fieldfileit++; - - for(int locid = 0; locid < fieldfile->GetNumberOfLocalization(); locid++) - { - vtkMedLocalization* loc = fieldfile->GetLocalization(locid); - - for(int fid = 0; fid < fieldfile->GetNumberOfField() && - loc->GetInterpolation() == NULL; fid++) - { - vtkMedField* field = fieldfile->GetField(fid); - for(int interpid = 0; interpid < field->GetNumberOfInterpolation(); - interpid++) - { - vtkMedInterpolation* interp = field->GetInterpolation(interpid); - if(strcmp(loc->GetInterpolationName(), - interp->GetName()) == 0) - { - loc->SetInterpolation(interp); - break; - } - } - } - } - } - - // now that the interpolation is set, build the shape functions. - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* fieldfile = fieldfileit->second; - fieldfileit++; - - for(int locid = 0; locid < fieldfile->GetNumberOfLocalization(); locid++) - { - vtkMedLocalization* loc = fieldfile->GetLocalization(locid); - loc->BuildShapeFunction(); - } - } - - // set the supportmesh pointer in the structural element - std::map >::iterator - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - fileit++; - - for(int structelemit = 0; - structelemit < file->GetNumberOfStructElement(); - structelemit++) - { - vtkMedStructElement* structElem = - file->GetStructElement(structelemit); - - for(int supportmeshit = 0; - supportmeshit < file->GetNumberOfSupportMesh(); - supportmeshit++) - { - vtkMedMesh* supportMesh = - file->GetSupportMesh(supportmeshit); - - if(strcmp(supportMesh->GetName(), structElem->GetName()) == 0 ) - { - structElem->SetSupportMesh(supportMesh); - break; - } - } - } - } - - // set the pointer to the profile used by the constant attributes - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - fileit++; - - for(int structelemit = 0; - structelemit < file->GetNumberOfStructElement(); - structelemit++) - { - vtkMedStructElement* structElem = - file->GetStructElement(structelemit); - - for(int cstattit = 0; cstattit < structElem->GetNumberOfConstantAttribute(); cstattit++) - { - vtkMedConstantAttribute* cstatt = structElem->GetConstantAttribute(cstattit); - - for(int profit = 0; - profit < file->GetNumberOfProfile(); - profit++) - { - vtkMedProfile* profile = - file->GetProfile(profit); - - if(strcmp(profile->GetName(), cstatt->GetProfileName()) == 0 ) - { - cstatt->SetProfile(profile); - break; - } - } - } - } - } - - meshfit = this->Internal->MedFiles.begin(); - while(meshfit != this->Internal->MedFiles.end()) - { - vtkMedFile* meshfile = meshfit->second; - meshfit++; - - for(int mid=0; midGetNumberOfMesh(); mid++) - { - vtkMedMesh* mesh = meshfile->GetMesh(mid); - - for(int gid=0; gidGetNumberOfGridStep(); gid++) - { - vtkMedGrid* grid = mesh->GetGridStep(gid); - // read point family data and create EntityArrays - - for(int eid=0; eid < grid->GetNumberOfEntityArray(); eid++) - { - vtkMedEntityArray* array = grid->GetEntityArray(eid); - if(array->GetEntity().EntityType != MED_STRUCT_ELEMENT) - continue; - - for(int structelemit = 0; structelemit < meshfile->GetNumberOfStructElement(); structelemit++) - { - vtkMedStructElement* structelem = meshfile->GetStructElement(structelemit); - if(structelem->GetGeometryType() == array->GetEntity().GeometryType) - { - array->SetStructElement(structelem); - break; - } - } - } - } - } - } -} - -int vtkMedReader::GetFrequencyArrayStatus(const char* name) -{ - return this->Frequencies->GetKeyStatus(name); -} - -void vtkMedReader::SetFrequencyArrayStatus(const char* name, int status) -{ - if(this->Frequencies->GetKeyStatus(name) == status) - { - return; - } - - this->Frequencies->SetKeyStatus(name, status); - - this->Modified(); -} - -int vtkMedReader::GetNumberOfFrequencyArrays() -{ - return this->Frequencies->GetNumberOfKey(); -} - -const char* vtkMedReader::GetFrequencyArrayName(int index) -{ - return this->Frequencies->GetKey(index); -} - -struct compTimes -{ - bool operator()(pair i, pair j) - { - if(i.first!=j.first) - return (i.firstAvailableTimes->Initialize(); - this->AvailableTimes->SetNumberOfComponents(1); - - std::set newFrequencies; - - int tid = 0; - std::map >::iterator it = - this->Internal->GlobalComputeStep.begin(); - while(it != this->Internal->GlobalComputeStep.end()) - { - double time = it->first; - this->AvailableTimes->InsertNextValue(time); - string name = vtkMedUtilities::GetModeKey(tid, time, this->Internal->GlobalComputeStep.size()-1); - this->Frequencies->AddKey(name.c_str()); - newFrequencies.insert(name); - tid++; - it++; - } - - // now check if old frequencies have been removed - for(int f = 0; f < this->Frequencies->GetNumberOfKey(); f++) - { - const char* name = this->Frequencies->GetKey(f); - if(newFrequencies.find(name) == newFrequencies.end()) - { - this->Frequencies->RemoveKeyByIndex(f); - f--; - } - } - - return this->AvailableTimes; -} - -void vtkMedReader::ChooseRealAnimationMode() -{ - if(this->AnimationMode!=Default) - { - this->Internal->RealAnimationMode=this->AnimationMode; - return; - } - - // if there is exactly one physical time and more than one iteration - // set the animation mode to iteration, else default to physical time. - if (this->Internal->GlobalComputeStep.size() == 1 && - this->Internal->GlobalComputeStep[0].size() > 1) - { - this->Internal->RealAnimationMode=Iteration; - return; - } - - this->Internal->RealAnimationMode=PhysicalTime; -} - -int vtkMedReader::GetEntityStatus(const vtkMedEntity& entity) -{ - if (entity.EntityType==MED_NODE) - return 1; - if(entity.EntityType == MED_DESCENDING_FACE - || entity.EntityType == MED_DESCENDING_EDGE) - return 0; - - return this->Entities->GetKeyStatus(vtkMedUtilities::EntityKey(entity).c_str()); -} - -int vtkMedReader::GetFamilyStatus(vtkMedMesh* mesh, vtkMedFamily* family) -{ - if(!mesh||!family) - return 0; - - if(this->Internal->GroupSelectionMTime > this->Internal->FamilySelectionMTime) - { - this->SelectFamiliesFromGroups(); - } - - int status = this->Internal->Families->GetKeyStatus(vtkMedUtilities::FamilyKey( - mesh->GetName(), family->GetPointOrCell(), - family->GetName()).c_str()); - - return status; -} - -int vtkMedReader::IsMeshSelected(vtkMedMesh* mesh) -{ - for(int fam=0; famGetNumberOfPointFamily(); fam++) - { - if(this->GetFamilyStatus(mesh, mesh->GetPointFamily(fam))!=0) - return 1; - } - - for(int fam=0; famGetNumberOfCellFamily(); fam++) - { - if(this->GetFamilyStatus(mesh, mesh->GetCellFamily(fam))!=0) - return 1; - } - return 0; -} - -void vtkMedReader::GatherComputeSteps() -{ - this->Internal->GlobalComputeStep.clear(); - - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fieldfileit->second; - fieldfileit++; - - // first loop over all fields to gather their compute steps - for(int fieldId=0; fieldIdGetNumberOfField(); fieldId++) - { - vtkMedField* field=file->GetField(fieldId); - - for(int stepId=0; stepIdGetNumberOfFieldStep(); stepId++) - { - vtkMedFieldStep* step=field->GetFieldStep(stepId); - const vtkMedComputeStep& cs = step->GetComputeStep(); - this->Internal->GlobalComputeStep[cs.TimeOrFrequency].insert(cs.IterationIt); - } - }//fields - - // then loop over all meshes to gather their grid steps too. - // for meshes, do not add the MED_UNDEF_DT time - for(int meshId=0; meshIdGetNumberOfMesh(); meshId++) - { - vtkMedMesh* mesh=file->GetMesh(meshId); - - for(int stepId=0; stepIdGetNumberOfGridStep(); stepId++) - { - vtkMedGrid* grid=mesh->GetGridStep(stepId); - const vtkMedComputeStep& cs = grid->GetComputeStep(); - if(cs.TimeOrFrequency != MED_UNDEF_DT || cs.TimeIt != MED_NO_DT) - { - this->Internal->GlobalComputeStep[cs.TimeOrFrequency].insert(cs.IterationIt); - } - } - }//mesh - } - if(this->Internal->GlobalComputeStep.size() == 0) - { - this->Internal->GlobalComputeStep[MED_UNDEF_DT].insert(MED_NO_IT); - } -} - -int vtkMedReader::IsFieldSelected(vtkMedField* field) -{ - return this->IsPointFieldSelected(field)||this->IsCellFieldSelected(field) - ||this->IsQuadratureFieldSelected(field) || this->IsElnoFieldSelected(field); -} - -int vtkMedReader::IsPointFieldSelected(vtkMedField* field) -{ - return field->GetFieldType()==vtkMedField::PointField - &&this->GetPointFieldArrayStatus(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); -} - -int vtkMedReader::IsCellFieldSelected(vtkMedField* field) -{ - return field->GetFieldType()==vtkMedField::CellField - &&this->GetCellFieldArrayStatus(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); -} - -vtkMedProfile* vtkMedReader::GetProfile(const char* pname) -{ - std::map >::iterator - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - fileit++; - vtkMedProfile* profile = file->GetProfile(pname); - if(profile != NULL) - return profile; - } - return NULL; -} - -vtkMedLocalization* vtkMedReader::GetLocalization(const char* lname) -{ - std::map >::iterator - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - fileit++; - vtkMedLocalization* loc = file->GetLocalization(lname); - if(loc != NULL) - return loc; - } - return NULL; - -} - -int vtkMedReader::GetLocalizationKey(vtkMedFieldOnProfile* fop) -{ - vtkMedLocalization* def=this->GetLocalization(fop->GetLocalizationName()); - - // This is not a quadrature field with explicit definition. - // There are two possible cases : either the intergration point is - // at the center of the cell - //1 quadrature point at the cell center - int nloc = 0; - std::map >::iterator - fileit = this->Internal->MedFiles.begin(); - while(fileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fileit->second; - fileit++; - - if(def && def->GetParentFile() == file) - return nloc + def->GetMedIterator() - 1; - - nloc += file->GetNumberOfLocalization(); - } - - // center of a cell - if(fop->GetNumberOfIntegrationPoint()==1) - return nloc + 1 + fop->GetParentFieldOverEntity()->GetEntity().GeometryType; - - // or it is an elno field (field stored on nodes of the cells, - // but with discontinuities at the vertices) - return -fop->GetParentFieldOverEntity()->GetEntity().GeometryType;//ELNO -} - -int vtkMedReader::IsQuadratureFieldSelected(vtkMedField* field) -{ - return field->GetFieldType()==vtkMedField::QuadratureField - &&this->GetQuadratureFieldArrayStatus(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); -} - -int vtkMedReader::IsElnoFieldSelected(vtkMedField* field) -{ - return field->GetFieldType()==vtkMedField::ElnoField - &&this->GetElnoFieldArrayStatus(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); -} - -// Description: -// Give the animation steps to the pipeline -void vtkMedReader::AdvertiseTime(vtkInformation* info) -{ - this->ChooseRealAnimationMode(); - - if(this->Internal->RealAnimationMode==PhysicalTime) - { - // I advertise the union of all times available - // in all selected fields and meshes - set timeset; - - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fieldfileit->second; - fieldfileit++; - - // first loop over all fields to gather their compute steps - for(int fieldId=0; fieldIdGetNumberOfField(); fieldId++) - { - vtkMedField* field=file->GetField(fieldId); - - if(!this->IsFieldSelected(field)) - continue; - - field->GatherFieldTimes(timeset); - }//fields - - // then loop over all meshes to gather their grid steps too. - for(int meshId=0; meshIdGetNumberOfMesh(); meshId++) - { - vtkMedMesh* mesh=file->GetMesh(meshId); - - if(!this->IsMeshSelected(mesh)) - continue; - - mesh->GatherGridTimes(timeset); - }//meshes - } - - if(timeset.size() > 0) - { - // remove MED_UNDEF_DT if there are other time step - if(timeset.size() > 1) - timeset.erase(MED_UNDEF_DT); - - vector times; - set::iterator it = timeset.begin(); - while(it != timeset.end()) - { - times.push_back(*it); - it++; - } - sort(times.begin(), times.end()); - - info->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), ×[0], - times.size()); - double timeRange[2]; - timeRange[0]=times[0]; - timeRange[1]=times[times.size()-1]; - info->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), &timeRange[0], - 2); - } - else - { - info->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - info->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE()); - } - } - else if(this->Internal->RealAnimationMode==Iteration) - { - // I advertise the union of all iterations available at the given - // Time for all selected fields. - set iterationsets; - med_float time = MED_UNDEF_DT; - if(this->TimeIndexForIterations >= 0 && - this->TimeIndexForIterations < - this->AvailableTimes->GetNumberOfTuples()) - { - time = this->AvailableTimes-> - GetValue((vtkIdType)this->TimeIndexForIterations); - } - - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fieldfileit->second; - fieldfileit++; - - for(int fieldId=0; fieldIdGetNumberOfField(); fieldId++) - { - vtkMedField* field=file->GetField(fieldId); - if(!this->IsFieldSelected(field)) - continue; - - field->GatherFieldIterations(time, iterationsets); - } - // then loop over all meshes to gather their grid steps too. - for(int meshId=0; meshIdGetNumberOfMesh(); meshId++) - { - vtkMedMesh* mesh=file->GetMesh(meshId); - - if(!this->IsMeshSelected(mesh)) - continue; - - mesh->GatherGridIterations(time, iterationsets); - }//meshes - } - - if(iterationsets.size()>0) - { - // remove MED_NO_IT if there are other available iterations. - if(iterationsets.size()>1) - iterationsets.erase(MED_NO_IT); - - vector iterations; - set::iterator it=iterationsets.begin(); - while(it!=iterationsets.end()) - { - iterations.push_back((double)*it); - it++; - } - sort(iterations.begin(), iterations.end()); - info->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), &iterations[0], - iterations.size()); - double timeRange[2]; - timeRange[0]=iterations[0]; - timeRange[1]=iterations[iterations.size()-1]; - info->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), &timeRange[0], - 2); - } - else - { - info->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - info->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE()); - } - } - else - { - info->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - info->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE()); - } -} - -vtkIdType vtkMedReader::GetFrequencyIndex(double freq) -{ - return this->AvailableTimes->LookupValue(freq); -} - -int vtkMedReader::RequestDataObject(vtkInformation* request, - vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) -{ - vtkInformation *info = outputVector->GetInformationObject(0); - if (vtkMultiBlockDataSet::SafeDownCast( - info->Get(vtkDataObject::DATA_OBJECT()))) - { - // The output is already created - return 1; - } - else - { - vtkMultiBlockDataSet* output=vtkMultiBlockDataSet::New(); - this->GetExecutive()->SetOutputData(0, output); - output->Delete(); - this->GetOutputPortInformation(0)->Set(vtkDataObject::DATA_EXTENT_TYPE(), - output->GetExtentType()); - } - return 1; -} - -void vtkMedReader::ClearSelections() -{ - this->PointFields->Initialize(); - this->CellFields->Initialize(); - this->QuadratureFields->Initialize(); - this->ElnoFields->Initialize(); - - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fieldfileit->second; - fieldfileit++; - - for(int index=0; index < file->GetNumberOfField(); index++) - { - vtkMedField* field = file->GetField(index); - switch(field->GetFieldType()) - { - case vtkMedField::PointField : - this->PointFields->AddKey(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); - break; - case vtkMedField::CellField : - this->CellFields->AddKey(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); - break; - case vtkMedField::QuadratureField : - this->QuadratureFields->AddKey(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); - break; - case vtkMedField::ElnoField : - this->ElnoFields->AddKey(vtkMedUtilities::SimplifyName( - field->GetName()).c_str()); - break; - } - } - - this->Internal->Families->Initialize(); - this->Groups->Initialize(); - for(int meshIndex=0; meshIndex < file->GetNumberOfMesh(); meshIndex++) - { - vtkMedMesh* mesh = file->GetMesh(meshIndex); - for(int famIndex=0; famIndexGetNumberOfPointFamily(); famIndex++) - { - vtkMedFamily* fam=mesh->GetPointFamily(famIndex); - - int ng=fam->GetNumberOfGroup(); - for(int gindex=0; gindexGetGroup(gindex); - string gname=vtkMedUtilities::GroupKey(mesh->GetName(), - fam->GetPointOrCell(), group->GetName()); - - this->Groups->AddKey(gname.c_str()); - this->Groups->SetKeyStatus(gname.c_str(), 0); - } - } - for(int famIndex=0; famIndexGetNumberOfCellFamily(); famIndex++) - { - vtkMedFamily* fam=mesh->GetCellFamily(famIndex); - - int ng=fam->GetNumberOfGroup(); - for(int gindex=0; gindexGetGroup(gindex); - string gname=vtkMedUtilities::GroupKey(mesh->GetName(), - fam->GetPointOrCell(), group->GetName()); - - this->Groups->AddKey(gname.c_str()); - this->Groups->SetKeyStatus(gname.c_str(), 1); - } - } - } - this->Internal->GroupSelectionMTime.Modified(); - - for(int meshIndex=0; meshIndex< file->GetNumberOfMesh(); meshIndex++) - { - if(file->GetMesh(meshIndex)->GetNumberOfGridStep() == 0) - continue; - - vtkMedGrid* grid=file->GetMesh(meshIndex)->GetGridStep(0); - - for(int entityIndex=0; entityIndexGetNumberOfEntityArray(); - entityIndex++) - { - vtkMedEntityArray* array=grid->GetEntityArray(entityIndex); - string name=vtkMedUtilities::EntityKey(array->GetEntity()); - this->Entities->AddKey(name.c_str()); - } - } - } - this->Modified(); -} - -void vtkMedReader::SelectFamiliesFromGroups() -{ - this->Internal->Families->Initialize(); - - std::map >::iterator - meshfileit = this->Internal->MedFiles.begin(); - while(meshfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = meshfileit->second; - meshfileit++; - - for(int meshIndex=0; meshIndex < file->GetNumberOfMesh(); meshIndex++) - { - vtkMedMesh* mesh = file->GetMesh(meshIndex); - for(int famIndex=0; famIndexGetNumberOfFamily(); famIndex++) - { - vtkMedFamily* fam=mesh->GetFamily(famIndex); - string name=vtkMedUtilities::FamilyKey(mesh->GetName(), - fam->GetPointOrCell(), fam->GetName()); - - this->Internal->Families->SetKeyStatus(name.c_str(), 0); - - for(int gindex=0; gindexGetNumberOfGroup(); gindex++) - { - vtkMedGroup* group=fam->GetGroup(gindex); - string gname=vtkMedUtilities::GroupKey(mesh->GetName(), - fam->GetPointOrCell(), group->GetName()); - int state=this->Groups->GetKeyStatus(gname.c_str()); - - if(state) - { - this->SetFamilyStatus(name.c_str(), 1); - } - } - } - } - } - - this->Internal->FamilySelectionMTime.Modified(); -} - -int vtkMedReader::GetNumberOfPointFieldArrays() -{ - return this->PointFields->GetNumberOfKey(); -} - -const char* -vtkMedReader::GetPointFieldArrayName(int index) -{ - return this->PointFields->GetKey(index); -} - -int vtkMedReader::GetPointFieldArrayStatus(const char* name) -{ - return this->PointFields->GetKeyStatus(name); -} - -void vtkMedReader::SetPointFieldArrayStatus(const char* name, int status) -{ - if(this->PointFields->KeyExists(name)&&this->PointFields->GetKeyStatus( - name)==status) - return; - - this->PointFields->SetKeyStatus(name, status); - - this->Modified(); -} - -int vtkMedReader::GetNumberOfCellFieldArrays() -{ - return this->CellFields->GetNumberOfKey(); -} - -const char* -vtkMedReader::GetCellFieldArrayName(int index) -{ - return this->CellFields->GetKey(index); -} - -int vtkMedReader::GetCellFieldArrayStatus(const char* name) -{ - return this->CellFields->GetKeyStatus(name); -} - -void vtkMedReader::SetCellFieldArrayStatus(const char* name, int status) -{ - if(this->CellFields->KeyExists(name)&&this->CellFields->GetKeyStatus( - name)==status) - return; - - this->CellFields->SetKeyStatus(name, status); - - this->Modified(); -} - -int vtkMedReader::GetNumberOfQuadratureFieldArrays() -{ - return this->QuadratureFields->GetNumberOfKey(); -} - -const char* vtkMedReader::GetQuadratureFieldArrayName(int index) -{ - return this->QuadratureFields->GetKey(index); -} - -int vtkMedReader::GetQuadratureFieldArrayStatus(const char* name) -{ - return this->QuadratureFields->GetKeyStatus(name); -} - -void vtkMedReader::SetQuadratureFieldArrayStatus(const char* name, int status) -{ - if(this->QuadratureFields->KeyExists(name) - &&this->QuadratureFields->GetKeyStatus(name)==status) - return; - - this->QuadratureFields->SetKeyStatus(name, status); - - this->Modified(); -} - -int vtkMedReader::GetNumberOfElnoFieldArrays() -{ - return this->ElnoFields->GetNumberOfKey(); -} - -const char* vtkMedReader::GetElnoFieldArrayName(int index) -{ - return this->ElnoFields->GetKey(index); -} - -int vtkMedReader::GetElnoFieldArrayStatus(const char* name) -{ - return this->ElnoFields->GetKeyStatus(name); -} - -void vtkMedReader::SetElnoFieldArrayStatus(const char* name, int status) -{ - if(this->ElnoFields->KeyExists(name) - &&this->ElnoFields->GetKeyStatus(name)==status) - return; - - this->ElnoFields->SetKeyStatus(name, status); - - this->Modified(); -} - -void vtkMedReader::SetEntityStatus(const char* name, int status) -{ - if(this->Entities->KeyExists(name)&&this->Entities->GetKeyStatus(name) - ==status) - return; - - this->Entities->SetKeyStatus(name, status); - - this->Modified(); -} - -void vtkMedReader::SetFamilyStatus(const char* name, int status) -{ - if(this->Internal->Families->KeyExists(name) - &&this->Internal->Families->GetKeyStatus(name)==status) - return; - - this->Internal->Families->SetKeyStatus(name, status); -} - -void vtkMedReader::SetGroupStatus(const char* name, int status) -{ - - if(this->Groups->KeyExists(name)&&this->Groups->GetKeyStatus(name) - ==status) - return; - - this->Groups->SetKeyStatus(name, status); - - this->Modified(); - - this->Internal->GroupSelectionMTime.Modified(); -} - -int vtkMedReader::GetGroupStatus(const char* key) -{ - return this->Groups->GetKeyStatus(key); -} - -void vtkMedReader::AddQuadratureSchemeDefinition(vtkInformation* info, - vtkMedLocalization* loc) -{ - if(info==NULL||loc==NULL) - return; - - vtkInformationQuadratureSchemeDefinitionVectorKey *key= - vtkQuadratureSchemeDefinition::DICTIONARY(); - - vtkQuadratureSchemeDefinition* def=vtkQuadratureSchemeDefinition::New(); - int cellType=vtkMedUtilities::GetVTKCellType(loc->GetGeometryType()); - def->Initialize(cellType, vtkMedUtilities::GetNumberOfPoint( - loc->GetGeometryType()), loc->GetNumberOfQuadraturePoint(), - (double*)loc->GetShapeFunction()->GetVoidPointer(0), - (double*)loc->GetWeights()->GetVoidPointer(0)); - key->Set(info, def, cellType); - def->Delete(); - -} - -void vtkMedReader::LoadConnectivity(vtkMedEntityArray* array) -{ - vtkMedGrid* grid = array->GetParentGrid(); - array->LoadConnectivity(); - if (array->GetConnectivity()==MED_NODAL||vtkMedUtilities::GetDimension( - array->GetEntity().GeometryType)<2 - || grid->GetParentMesh()->GetMeshType() == MED_STRUCTURED_MESH) - return; - - vtkMedEntity subentity; - subentity.EntityType = vtkMedUtilities::GetSubType(array->GetEntity().EntityType); - - vtkMedUnstructuredGrid* ugrid = vtkMedUnstructuredGrid::SafeDownCast(grid); - if(ugrid == NULL) - return; - - for(int index=0; indexGetEntity().GeometryType); index++) - { - subentity.GeometryType = vtkMedUtilities::GetSubGeometry( - array->GetEntity().GeometryType, index); - vtkMedEntityArray* subarray=ugrid->GetEntityArray(subentity); - - if(subarray==NULL) - { - vtkErrorMacro("DESC connectivity used, but sub types do not exist in file."); - return; - } - subarray->LoadConnectivity(); - } -} - -vtkDataSet* vtkMedReader::CreateUnstructuredGridForPointSupport( - vtkMedFamilyOnEntityOnProfile* foep) -{ - vtkUnstructuredGrid* vtkgrid = vtkUnstructuredGrid::New(); - foep->ComputeIntersection(NULL); - vtkMedFamilyOnEntity* foe = foep->GetFamilyOnEntity(); - vtkMedGrid* medgrid=foe->GetParentGrid(); - vtkMedUnstructuredGrid* medugrid=vtkMedUnstructuredGrid::SafeDownCast( - medgrid); - vtkMedCurvilinearGrid* medcgrid=vtkMedCurvilinearGrid::SafeDownCast( - medgrid); - - medgrid->LoadCoordinates(); - - vtkIdType npts=medgrid->GetNumberOfPoints(); - - bool shallowCopy= (medugrid != NULL || medcgrid!=NULL); - if(medgrid->GetParentMesh()->GetSpaceDimension()!=3) - { - shallowCopy=false; - } - else - { - shallowCopy = foep->CanShallowCopyPointField(NULL); - } - - vtkDataArray* coords = NULL; - - if(medugrid != NULL) - coords = medugrid->GetCoordinates(); - if(medcgrid != NULL) - coords = medcgrid->GetCoordinates(); - - - vtkIdType numberOfPoints; - vtkPoints* points=vtkPoints::New(coords->GetDataType()); - vtkgrid->SetPoints(points); - points->Delete(); - - vtkIdTypeArray* pointGlobalIds=vtkIdTypeArray::New(); - pointGlobalIds->SetName("MED_POINT_ID"); - pointGlobalIds->SetNumberOfComponents(1); - vtkgrid->GetPointData()->SetGlobalIds(pointGlobalIds); - pointGlobalIds->Delete(); - - if (shallowCopy) - { - vtkgrid->GetPoints()->SetData(coords); - numberOfPoints=npts; - - pointGlobalIds->SetNumberOfTuples(numberOfPoints); - vtkIdType* ptr=pointGlobalIds->GetPointer(0); - for(int pid=0; pidGetNumberOfPoints(); index++) - { - if (!foep->KeepPoint(index)) - { - continue; - } - - double coord[3]={0.0, 0.0, 0.0}; - double * tuple=medgrid->GetCoordTuple(index); - for(int dim=0; dimGetParentMesh()->GetSpaceDimension()&&dim<3; dim++) - { - coord[dim]=tuple[dim]; - } - vtkgrid->GetPoints()->InsertPoint(currentIndex, coord); - pointGlobalIds->InsertNextValue(index+1); - currentIndex++; - } - vtkgrid->GetPoints()->Squeeze(); - pointGlobalIds->Squeeze(); - numberOfPoints=currentIndex; - } - - // now create the VTK_VERTEX cells - for(vtkIdType id=0; idInsertNextCell(VTK_VERTEX, 1, &id); - } - vtkgrid->Squeeze(); - - // in this particular case, the global ids of the cells is the same as the global ids of the points. - vtkgrid->GetCellData()->SetGlobalIds(vtkgrid->GetPointData()->GetGlobalIds()); - - return vtkgrid; -} - -vtkMedGrid* vtkMedReader::FindGridStep(vtkMedMesh* mesh) -{ - if(this->Internal->RealAnimationMode == vtkMedReader::PhysicalTime) - { - vtkMedComputeStep cs; - cs.TimeOrFrequency = this->Internal->UpdateTimeStep; - return mesh->FindGridStep(cs, vtkMedReader::PhysicalTime); - } - else if(this->Internal->RealAnimationMode == vtkMedReader::Modes) - { - vtkMedComputeStep cs; - cs.IterationIt = MED_NO_IT; - cs.TimeIt = MED_NO_DT; - cs.TimeOrFrequency = MED_NO_DT; - return mesh->FindGridStep(cs, vtkMedReader::Modes); - } - else // Iterations - { - vtkMedComputeStep cs; - // the time is set by choosing its index in the global - // array giving the available times : this->TimeIndexForIterations - cs.TimeOrFrequency = (med_int)this->AvailableTimes->GetValue( - (vtkIdType)this->TimeIndexForIterations); - // the iteration is asked by the pipeline - cs.IterationIt = (med_int)this->Internal->UpdateTimeStep; - return mesh->FindGridStep(cs, vtkMedReader::Iteration); - } - return NULL; -} - -void vtkMedReader::CreateMedSupports() -{ - this->Internal->UsedSupports.clear(); - - std::map >::iterator - meshfileit = this->Internal->MedFiles.begin(); - while(meshfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = meshfileit->second; - meshfileit++; - - for(int meshIndex=0; meshIndexGetNumberOfMesh(); meshIndex++) - { - vtkMedMesh* mesh = file->GetMesh(meshIndex); - vtkMedGrid* grid = this->FindGridStep(mesh); - if(grid == NULL) - continue; - - for(int entityIndex=0; entityIndexGetNumberOfEntityArray(); - entityIndex++) - { - vtkMedEntityArray* array=grid->GetEntityArray(entityIndex); - if(this->GetEntityStatus(array->GetEntity())==0) - { - continue; - } - - file->GetMedDriver()->LoadFamilyIds(array); - for(int foeIndex=0; foeIndexGetNumberOfFamilyOnEntity(); - foeIndex++) - { - vtkMedFamilyOnEntity* foe=array->GetFamilyOnEntity(foeIndex); - vtkMedFamily* family=foe->GetFamily(); - if(this->GetFamilyStatus(mesh, family)==0) - continue; - - // now, I look over all non-point fields to see which profiles - // have to be used on points. - bool selectedSupport = false; - - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* fieldfile = fieldfileit->second; - fieldfileit++; - - for(int fieldId=0; fieldIdGetNumberOfField(); fieldId++) - { - vtkMedField* field=fieldfile->GetField(fieldId); - - if (!this->IsFieldSelected(field)) - continue; - - vtkMedListOfFieldSteps steps; - - this->GatherFieldSteps(field, steps); - - vtkMedListOfFieldSteps::iterator it=steps.begin(); - while(it!=steps.end()) - { - vtkMedFieldStep *step = *it; - step->LoadInformation(); - it++; - - for(int eid=0; eidGetNumberOfFieldOverEntity(); eid++) - { - vtkMedFieldOverEntity* fieldOverEntity = - step->GetFieldOverEntity(eid); - - for(int pid = 0; pid < fieldOverEntity->GetNumberOfFieldOnProfile(); pid++) - { - vtkMedFieldOnProfile* fop = - fieldOverEntity->GetFieldOnProfile(pid); - vtkMedProfile* prof = fop->GetProfile(); - vtkMedFamilyOnEntityOnProfile* foep = - foe->GetFamilyOnEntityOnProfile(prof); - if(foep != NULL) - { - this->Internal->UsedSupports.insert(foep); - selectedSupport = true; - } - } - } - } - } - } - // If no field use this family on entity, I nevertheless create the - // support, with an empty profile. - if(!selectedSupport) - { - vtkMedFamilyOnEntityOnProfile* foep = - foe->GetFamilyOnEntityOnProfile((vtkMedProfile*)NULL); - if(foep == NULL) - { - foep = vtkMedFamilyOnEntityOnProfile::New(); - foep->SetFamilyOnEntity(foe); - foep->SetProfile(NULL); - foe->AddFamilyOnEntityOnProfile(foep); - foep->Delete(); - } - this->Internal->UsedSupports.insert(foep); - } - } - } - } - } -} - -bool vtkMedReader::BuildVTKSupport( - vtkMedFamilyOnEntityOnProfile* foep, - int doBuildSupport) -{ - - vtkMedFamilyOnEntity* foe = foep->GetFamilyOnEntity(); - - int numProc = 1; - vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController(); - if (controller != NULL) - { - numProc = controller->GetNumberOfProcesses(); - } - - if ((foep->GetValid() == 0) && numProc == 1) - { - return false; - } - - vtkMedGrid* grid=foe->GetParentGrid(); - - vtkMedEntityArray* array=foe->GetEntityArray(); - vtkMedMesh* mesh=grid->GetParentMesh(); - vtkSmartPointer path = vtkSmartPointer::New(); - string meshName=vtkMedUtilities::SimplifyName(mesh->GetName()); - path->InsertNextValue(meshName); - std::string finalName; - - if(foe->GetPointOrCell()==vtkMedUtilities::OnPoint) - { - path->InsertNextValue(vtkMedUtilities::OnPointName); - finalName=vtkMedUtilities::SimplifyName(foe->GetFamily()->GetName()); - } - else - { - path->InsertNextValue(vtkMedUtilities::OnCellName); - path->InsertNextValue(vtkMedUtilities::SimplifyName(foe->GetFamily()->GetName())); - finalName=vtkMedUtilities::EntityKey(array->GetEntity()); - } - - if(foep->GetProfile() != NULL) - { - path->InsertNextValue(finalName); - finalName = foep->GetProfile()->GetName(); - } - - ostringstream progressBarTxt; - for(int depth=0; depthGetNumberOfValues(); depth++) - { - progressBarTxt<GetValue(depth)<<" "; - } - progressBarTxt<Internal->DataSetCache.find(foep)!=this->Internal->DataSetCache.end()) - { - cachedDataSet = this->Internal->DataSetCache[foep]; - } - else - { - vtkDataSet* dataset = NULL; - if(doBuildSupport) - { - if(foe->GetPointOrCell()==vtkMedUtilities::OnPoint) - { - dataset = this->CreateUnstructuredGridForPointSupport(foep); - } - else - { - dataset = foep->GetFamilyOnEntity()->GetParentGrid()-> - CreateVTKDataSet(foep); - } - } - - if(dataset == NULL) - { - return false; - } - - this->Internal->DataSetCache[foep]=dataset; - cachedDataSet = dataset; - if(dataset != NULL) - dataset->Delete(); - } - - vtkMultiBlockDataSet* root=vtkMedUtilities::GetParent(this->GetOutput(), path); - int nb=root->GetNumberOfBlocks(); - - if(cachedDataSet != NULL) - { - vtkDataSet* realDataSet=cachedDataSet->NewInstance(); - root->SetBlock(nb, realDataSet); - realDataSet->Delete(); - - root->GetMetaData(nb)->Set(vtkCompositeDataSet::NAME(), finalName.c_str()); - realDataSet->ShallowCopy(cachedDataSet); - - this->Internal->DataSetCache[foep]=cachedDataSet; - this->Internal->CurrentDataSet[foep]=realDataSet; - - path->InsertNextValue(finalName); - path->SetName("BLOCK_NAME"); - realDataSet->GetFieldData()->AddArray(path); - realDataSet->GetInformation()->Remove(vtkMedUtilities::BLOCK_NAME()); - for(int depth=0; depthGetNumberOfValues(); depth++) - { - realDataSet->GetInformation()->Set(vtkMedUtilities::BLOCK_NAME(), - path->GetValue(depth), depth); - } - } -} - -void vtkMedReader::MapFieldOnSupport(vtkMedFieldOnProfile* fop, - vtkMedFamilyOnEntityOnProfile* foep, - int doCreateField) -{ - bool cached = false; - - if(this->Internal->FieldCache.find(foep) - !=this->Internal->FieldCache.end()) - { - map& fieldCache = - this->Internal->FieldCache[foep]; - if(fieldCache.find(fop)!=fieldCache.end()) - { - cached=true; - } - } - - if(!cached) - { - this->CreateVTKFieldOnSupport(fop, foep, doCreateField); - } - this->SetVTKFieldOnSupport(fop, foep); -} - -void vtkMedReader::MapFieldsOnSupport(vtkMedFamilyOnEntityOnProfile* foep, - int doCreateField) -{ - // now loop over all fields to map it to the created grids - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fieldfileit->second; - fieldfileit++; - - for(int fieldId=0; fieldIdGetNumberOfField(); fieldId++) - { - vtkMedField* field=file->GetField(fieldId); - - if(strcmp(foep->GetFamilyOnEntity()-> - GetParentGrid()->GetParentMesh()->GetName(), - field->GetMeshName()) != 0) - continue; - - if(strcmp(foep->GetFamilyOnEntity()-> - GetParentGrid()->GetParentMesh()->GetName(), - field->GetMeshName()) != 0) - continue; - - if (!this->IsFieldSelected(field)) - continue; - - vtkMedListOfFieldSteps steps; - - this->GatherFieldSteps(field, steps); - - vtkMedListOfFieldSteps::iterator it=steps.begin(); - while(it!=steps.end()) - { - vtkMedFieldStep *step = *it; - step->LoadInformation(); - it++; - - for(int eid=0; eidGetNumberOfFieldOverEntity(); eid++) - { - vtkMedFieldOverEntity* fieldOverEntity = step->GetFieldOverEntity(eid); - for(int pid = 0; pid < fieldOverEntity->GetNumberOfFieldOnProfile(); pid++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(pid); - if(foep->CanMapField(fop)) - { - this->MapFieldOnSupport(fop, foep, doCreateField); - } - } - } - } - } - } -} - -void vtkMedReader::GatherFieldSteps(vtkMedField* field, - vtkMedListOfFieldSteps& steps) -{ - if(this->Internal->RealAnimationMode == vtkMedReader::PhysicalTime) - { - vtkMedComputeStep cs; - cs.TimeOrFrequency = this->Internal->UpdateTimeStep; - vtkMedFieldStep* fs = - field->FindFieldStep(cs, vtkMedReader::PhysicalTime); - if(fs != NULL) - steps.push_back(fs); - } - else if(this->Internal->RealAnimationMode == vtkMedReader::Iteration) - { - vtkMedComputeStep cs; - cs.IterationIt = (med_int)this->Internal->UpdateTimeStep; - cs.TimeOrFrequency = (med_int)this->AvailableTimes->GetValue( - (vtkIdType)this->TimeIndexForIterations); - vtkMedFieldStep* fs = - field->FindFieldStep(cs, vtkMedReader::Iteration); - if(fs != NULL) - steps.push_back(fs); - } - else // modes - { - for(int modeid = 0; modeid < this->Frequencies->GetNumberOfKey(); modeid++) - { - if(this->Frequencies->GetKeyStatus( - this->Frequencies->GetKey(modeid)) == 0) - { - continue; - } - - vtkMedComputeStep cs; - cs.TimeOrFrequency = this->AvailableTimes->GetValue(modeid); - vtkMedFieldStep* fs = - field->FindFieldStep(cs, vtkMedReader::PhysicalTime); - if(fs != NULL) - steps.push_back(fs); - } - } -} - -void vtkMedReader::SetVTKFieldOnSupport(vtkMedFieldOnProfile* fop, - vtkMedFamilyOnEntityOnProfile* foep) -{ - vtkMedFamilyOnEntity* foe = foep->GetFamilyOnEntity(); - vtkMedFieldOverEntity* fieldOverEntity = fop->GetParentFieldOverEntity(); - vtkMedFieldStep* step = fieldOverEntity->GetParentStep(); - vtkMedField* field = step->GetParentField(); - - const vtkMedComputeStep& cs = step->GetComputeStep(); - - vtkDataSet* ds=this->Internal->CurrentDataSet[foep]; - if (ds == NULL) - { - // ds == NULL could arrive is some cases when working in parallel - vtkWarningMacro( "--- vtkMedReader::SetVTKFieldOnSupport: ds is NULL !!"); - return; - } - - VTKField& vtkfield=this->Internal->FieldCache[foep][fop]; - - std::string name=vtkMedUtilities::SimplifyName(field->GetName()); - std::string vectorname = name+"_Vector"; - if(this->AnimationMode==Modes) - { - double freq = cs.TimeOrFrequency; - int index = this->GetFrequencyIndex(freq); - name += string(" ") + vtkMedUtilities::GetModeKey(index, freq, - this->AvailableTimes->GetNumberOfTuples()-1); - vectorname += string(" ") + vtkMedUtilities::GetModeKey(index, freq, - this->AvailableTimes->GetNumberOfTuples()-1); - } - - vtkfield.DataArray->SetName(name.c_str()); - vtkfield.DataArray->Squeeze(); - if(vtkfield.Vectors != NULL) - { - vtkfield.Vectors->SetName(vectorname.c_str()); - vtkfield.Vectors->Squeeze(); - } - if(vtkfield.QuadratureIndexArray!=NULL) - { - vtkfield.QuadratureIndexArray->Squeeze(); - } - - if(foe->GetPointOrCell()==vtkMedUtilities::OnCell) - { - if(field->GetFieldType()==vtkMedField::PointField) - { - if(vtkfield.DataArray->GetNumberOfTuples()!=ds->GetNumberOfPoints()) - { - vtkDebugMacro("the data array " << vtkfield.DataArray->GetName() - << " do not have the good number of tuples"); - return; - } - ds->GetPointData()->AddArray(vtkfield.DataArray); - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetPointData()->AddArray(vtkfield.Vectors); - ds->GetPointData()->SetActiveVectors(vtkfield.Vectors->GetName()); - } - switch (vtkfield.DataArray->GetNumberOfComponents()) - { - case 1: - ds->GetPointData()->SetActiveScalars(vtkfield.DataArray->GetName()); - break; - case 3: - ds->GetPointData()->SetActiveVectors(vtkfield.DataArray->GetName()); - break; - } - // if the data set is only composed of VTK_VERTEX cells, - // and no field called with the same name exist on cells, - // map this field to cells too - if(foe->GetVertexOnly()==1&&ds->GetCellData()->GetArray( - vtkfield.DataArray->GetName())==NULL) - { - ds->GetCellData()->AddArray(vtkfield.DataArray); - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetCellData()->AddArray(vtkfield.Vectors); - ds->GetCellData()->SetActiveVectors(vtkfield.Vectors->GetName()); - } - switch (vtkfield.DataArray->GetNumberOfComponents()) - { - case 1: - ds->GetCellData()->SetActiveScalars(vtkfield.DataArray->GetName()); - break; - case 3: - ds->GetCellData()->SetActiveVectors(vtkfield.DataArray->GetName()); - break; - } - } - } - if(field->GetFieldType()==vtkMedField::CellField) - { - if((this->Internal->NumberOfPieces == 1) && vtkfield.DataArray->GetNumberOfTuples()!=ds->GetNumberOfCells() ) - { - vtkDebugMacro("the data array " << vtkfield.DataArray->GetName() - << " do not have the good number of tuples" - << " ncell=" << ds->GetNumberOfCells() - << " ntuple=" << vtkfield.DataArray->GetNumberOfTuples()); - return; - } - // In case we are in parallel and our process does not contain the data - if(ds->GetNumberOfCells()==0) - { - return; - } - ds->GetCellData()->AddArray(vtkfield.DataArray); - - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetCellData()->AddArray(vtkfield.Vectors); - ds->GetCellData()->SetActiveVectors(vtkfield.Vectors->GetName()); - } - switch (vtkfield.DataArray->GetNumberOfComponents()) - { - case 1: - ds->GetCellData()->SetActiveScalars(vtkfield.DataArray->GetName()); - break; - case 3: - ds->GetCellData()->SetActiveVectors(vtkfield.DataArray->GetName()); - break; - } - // if the data set is only composed of VTK_VERTEX cells, - // and no field called with the same name exist on points, - // map this field to points too - if(foe->GetVertexOnly()==1 && ds->GetPointData()->GetArray( - vtkfield.DataArray->GetName())==NULL) - { - ds->GetPointData()->AddArray(vtkfield.DataArray); - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetPointData()->AddArray(vtkfield.Vectors); - ds->GetPointData()->SetActiveVectors(vtkfield.Vectors->GetName()); - } - switch (vtkfield.DataArray->GetNumberOfComponents()) - { - case 1: - ds->GetPointData()->SetActiveScalars(vtkfield.DataArray->GetName()); - break; - case 3: - ds->GetPointData()->SetActiveVectors(vtkfield.DataArray->GetName()); - break; - } - } - } - if(field->GetFieldType()==vtkMedField::QuadratureField || - field->GetFieldType()==vtkMedField::ElnoField ) - { - vtkIdType ncells=ds->GetNumberOfCells(); - vtkIdType nid=vtkfield.QuadratureIndexArray->GetNumberOfTuples(); - vtkIdType nda=vtkfield.DataArray->GetNumberOfTuples(); - if((nid!=ncells) && (this->Internal->NumberOfPieces == 1)) - { - vtkDebugMacro( - "There should be as many quadrature index values as there are cells"); - return; - } - else - { - if (ncells == 0) - { - vtkfield.DataArray->SetNumberOfTuples( 0 ); - vtkfield.DataArray->Squeeze(); - } - if (nid>ncells) // PROBABLY NOT NECESSARY - { - vtkfield.QuadratureIndexArray->SetNumberOfTuples(ncells); - int nquad=fop->GetNumberOfIntegrationPoint(); - vtkfield.DataArray->SetNumberOfTuples( nquad * ds->GetNumberOfCells() ); - vtkfield.DataArray->Squeeze(); - } - ds->GetFieldData()->AddArray(vtkfield.DataArray); - ds->GetCellData()->AddArray(vtkfield.QuadratureIndexArray); - - nid=vtkfield.QuadratureIndexArray->GetNumberOfTuples(); - nda=vtkfield.DataArray->GetNumberOfTuples(); - - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetFieldData()->AddArray(vtkfield.Vectors); - } - } - } - }//support OnCell - else - {//support OnPoint - if(vtkfield.DataArray->GetNumberOfTuples()!=ds->GetNumberOfPoints()) - { - vtkDebugMacro("the data array " << vtkfield.DataArray->GetName() << " do not have the good number of tuples"); - return; - } - ds->GetPointData()->AddArray(vtkfield.DataArray); - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetPointData()->AddArray(vtkfield.Vectors); - ds->GetPointData()->SetActiveVectors(vtkfield.Vectors->GetName()); - } - switch (vtkfield.DataArray->GetNumberOfComponents()) - { - case 1: - ds->GetPointData()->SetActiveScalars(vtkfield.DataArray->GetName()); - break; - case 3: - ds->GetPointData()->SetActiveVectors(vtkfield.DataArray->GetName()); - break; - } - // all the VTK_VERTEX created cells have the same order than the points, - // I can safely map the point array to the cells in this particular case. - ds->GetCellData()->AddArray(vtkfield.DataArray); - if(vtkfield.Vectors != NULL && this->GenerateVectors) - { - ds->GetCellData()->AddArray(vtkfield.Vectors); - ds->GetCellData()->SetActiveVectors(vtkfield.Vectors->GetName()); - } - switch (vtkfield.DataArray->GetNumberOfComponents()) - { - case 1: - ds->GetCellData()->SetActiveScalars(vtkfield.DataArray->GetName()); - break; - case 3: - ds->GetCellData()->SetActiveVectors(vtkfield.DataArray->GetName()); - break; - } - } -} - -void vtkMedReader::InitializeQuadratureOffsets(vtkMedFieldOnProfile* fop, - vtkMedFamilyOnEntityOnProfile* foep) -{ - vtkMedFamilyOnEntity* foe = foep->GetFamilyOnEntity(); - - vtkMedFieldOverEntity* fieldOverEntity = fop->GetParentFieldOverEntity(); - vtkMedFieldStep* step = fieldOverEntity->GetParentStep(); - vtkMedField *field= step->GetParentField(); - - // then I compute the quadrature key if needed, and try to find the quadrature offsets. - if(this->Internal->QuadratureOffsetCache.find(foep) - ==this->Internal->QuadratureOffsetCache.end()) - this->Internal->QuadratureOffsetCache[foep]=map > (); - - map >& quadOffsets= - this->Internal->QuadratureOffsetCache[foep]; - - LocalizationKey quadkey=this->GetLocalizationKey(fop); - - if(quadOffsets.find(quadkey)!=quadOffsets.end()) - {// the quadrature offset array has already been created - return; - } - - vtkIdTypeArray* qoffsets=vtkIdTypeArray::New(); - quadOffsets[quadkey]=qoffsets; - qoffsets->Delete(); - - ostringstream sstr; - if(field->GetFieldType() == vtkMedField::ElnoField) - { - qoffsets->GetInformation()->Set(vtkMedUtilities::ELNO(), 1); - sstr<<"ELNO"; - } - else if(field->GetFieldType() == vtkMedField::QuadratureField) - { - qoffsets->GetInformation()->Set(vtkMedUtilities::ELGA(), 1); - sstr<<"ELGA"; - } - else - { - sstr<<"QuadraturePointOffset"; - } - - qoffsets->SetName(sstr.str().c_str()); - - vtkSmartPointer loc= - this->GetLocalization(fop->GetLocalizationName()); - - if(loc == NULL) - { - if(fop->GetNumberOfIntegrationPoint()==1) - {// cell-centered fields can be seen as quadrature fields with 1 - // quadrature point at the center - vtkMedLocalization* center=vtkMedLocalization::New(); - loc=center; - center->Delete(); - center->BuildCenter(fieldOverEntity->GetEntity().GeometryType); - } - else if(loc == NULL && field->GetFieldType() == vtkMedField::ElnoField) - {// ELNO fields have no vtkMedLocalization, - // I need to create a dummy one - vtkMedLocalization* elnodef=vtkMedLocalization::New(); - loc=elnodef; - elnodef->Delete(); - elnodef->BuildELNO(fieldOverEntity->GetEntity().GeometryType); - } - else - { - vtkErrorMacro("Cannot find localization of quadrature field " - << field->GetName()); - } - } - this->AddQuadratureSchemeDefinition(qoffsets->GetInformation(), loc); -} - -void vtkMedReader::CreateVTKFieldOnSupport(vtkMedFieldOnProfile* fop, - vtkMedFamilyOnEntityOnProfile* foep, int doCreateField) -{ - vtkMedFamilyOnEntity* foe = foep->GetFamilyOnEntity(); - vtkMedFieldOverEntity* fieldOverEntity = fop->GetParentFieldOverEntity(); - vtkMedFieldStep* step = fieldOverEntity->GetParentStep(); - vtkMedField* field = step->GetParentField(); - - if(vtkMedUnstructuredGrid::SafeDownCast( - foep->GetFamilyOnEntity()->GetParentGrid()) != NULL) - { - fop->Load(MED_COMPACT_STMODE); - } - else - { - fop->Load(MED_GLOBAL_STMODE); - } - - vtkMedIntArray* profids=NULL; - - vtkMedProfile* profile=fop->GetProfile(); - - if(profile) - { - profile->Load(); - profids=profile->GetIds(); - }//has profile - - VTKField& vtkfield=this->Internal->FieldCache[foep][fop]; - - bool shallowok = true; - - // for structured grid, the values are loaded globally, and cells which are - // not on the profile or not on the family are blanked out. - // shallow copy is therefore always possible - if(vtkMedUnstructuredGrid::SafeDownCast( - foep->GetFamilyOnEntity()->GetParentGrid()) != NULL) - { - shallowok = foep->CanShallowCopy(fop); - } - - if(shallowok) - { - vtkfield.DataArray = fop->GetData(); - } - else - { - vtkDataArray* data=vtkMedUtilities::NewArray(field->GetDataType()); - vtkfield.DataArray=data; - data->Delete(); - vtkfield.DataArray->SetNumberOfComponents(field->GetNumberOfComponent()); - } - - for(int comp=0; compGetNumberOfComponent(); comp++) - { - vtkfield.DataArray->SetComponentName(comp, vtkMedUtilities::SimplifyName( - field->GetComponentName()->GetValue(comp)).c_str()); - } - - bool createOffsets=false; - if(field->GetFieldType()==vtkMedField::QuadratureField || - field->GetFieldType()==vtkMedField::ElnoField ) - { - this->InitializeQuadratureOffsets(fop, foep); - - LocalizationKey quadKey = this->GetLocalizationKey(fop); - vtkfield.QuadratureIndexArray - =this->Internal->QuadratureOffsetCache[foep][quadKey]; - vtkDataSet* ds = this->Internal->CurrentDataSet[foep]; - - vtkfield.DataArray->GetInformation()->Set( - vtkQuadratureSchemeDefinition::QUADRATURE_OFFSET_ARRAY_NAME(), - vtkfield.QuadratureIndexArray->GetName()); - vtkfield.QuadratureIndexArray->GetInformation()->Set( - vtkAbstractArray::GUI_HIDE(), 1); - - if(vtkfield.QuadratureIndexArray->GetNumberOfTuples() - !=ds->GetNumberOfCells()) - { - vtkfield.QuadratureIndexArray->SetNumberOfTuples(0); - createOffsets=true; - } - } - - if(!doCreateField) - return; - - if(shallowok) - { - // build the quadrature offset array if needed - if(createOffsets) - { - vtkIdType noffsets; - int nquad=fop->GetNumberOfIntegrationPoint(); - noffsets=fop->GetData()->GetNumberOfTuples()/nquad; - - vtkDataSet* ds=this->Internal->CurrentDataSet[foep]; - if(noffsets!=ds->GetNumberOfCells()) - { - vtkErrorMacro( - "number of quadrature offsets (" << noffsets << ") must " - << "match the number of cells (" << ds->GetNumberOfCells() << ")!"); - } - - vtkfield.QuadratureIndexArray->SetNumberOfTuples(noffsets); - for(vtkIdType id=0; idSetValue(id, nquad*id); - } - } - - } - else if(foe->GetPointOrCell() == vtkMedUtilities::OnCell - && field->GetFieldType() != vtkMedField::PointField) - { - // Cell-centered field on cell support - int nquad = 1; - if (field->GetFieldType()==vtkMedField::QuadratureField || - field->GetFieldType()==vtkMedField::ElnoField) - { - nquad=fop->GetNumberOfIntegrationPoint(); - } - vtkMedIntArray* profids=NULL; - if (profile) - { - profids=profile->GetIds(); - } - vtkIdType maxIndex=fop->GetData()->GetNumberOfTuples(); - maxIndex/=nquad; - vtkIdType quadIndex = 0; - - for (vtkIdType id = 0; idGetValue(id)-1 : id); - if (!foep->KeepCell(realIndex)) - continue; - - if (field->GetFieldType()==vtkMedField::QuadratureField || - field->GetFieldType()==vtkMedField::ElnoField) - { - for (int q = 0; qInsertNextTuple(nquad*realIndex+q, - fop->GetData()); - } - if (createOffsets) - { - vtkfield.QuadratureIndexArray->InsertNextValue(quadIndex); - quadIndex+=nquad; - } - } - else - { - vtkfield.DataArray->InsertNextTuple(id, fop->GetData()); - } - }//copy all tuples - vtkfield.DataArray->Squeeze(); - vtkDataSet* ds = this->Internal->CurrentDataSet[foep]; - } - else if(foe->GetPointOrCell() == vtkMedUtilities::OnCell - && field->GetFieldType() == vtkMedField::PointField) - {// point field on cell support - vtkMedIntArray* profids=NULL; - - vtkMedProfile* profile=fop->GetProfile(); - - if(profile) - { - profile->Load(); - - profids=profile->GetIds(); - }//has profile - - vtkIdType maxId=fop->GetData()->GetNumberOfTuples(); - - for(vtkIdType id=0; idGetValue(id)-1; // -1 because med indices start at 1 - } - else - { - destIndex=id; - } - - if(!foep->KeepPoint(destIndex)) - continue; - // if I use the med2VTKIndex, then the index to insert - // this value is given by the map. - destIndex = foep->GetVTKPointIndex(destIndex); - vtkfield.DataArray->InsertTuple(destIndex, id, fop->GetData()); - } - vtkfield.DataArray->Squeeze(); - }// point field on cell support - else if(foe->GetPointOrCell() == vtkMedUtilities::OnPoint && - field->GetFieldType() == vtkMedField::PointField) - {//support OnPoint - - vtkIdType maxId = fop->GetData()->GetNumberOfTuples(); - - for(vtkIdType id=0; idGetValue(id)-1; // -1 because med indices start at 1 - } - - if(!foep->KeepPoint(realIndex)) - continue; - - vtkfield.DataArray->InsertNextTuple(fop->GetData()->GetTuple(realIndex)); - } - vtkfield.DataArray->Squeeze(); - }// support on point - - // now generate the vector field if asked for - if(this->GenerateVectors) - { - int ncomp = vtkfield.DataArray->GetNumberOfComponents(); - if(ncomp > 1 && ncomp != 3) - { - vtkDataArray* vectors = vtkfield.DataArray->NewInstance(); - vectors->SetNumberOfComponents(3); - vectors->SetNumberOfTuples(vtkfield.DataArray->GetNumberOfTuples()); - vtkfield.Vectors = vectors; - vectors->Delete(); - - vectors->CopyInformation(vtkfield.DataArray->GetInformation()); - - if(ncomp < 3) - vectors->SetComponentName(2, "Z"); - else - vectors->SetComponentName(2, vtkfield.DataArray->GetComponentName(2)); - - vectors->SetComponentName(1, vtkfield.DataArray->GetComponentName(1)); - vectors->SetComponentName(0, vtkfield.DataArray->GetComponentName(0)); - - int tuplesize = (ncomp > 3? ncomp: 3); - double* tuple = new double[tuplesize]; - for(int tid=0; tidGetNumberOfTuples(); id++) - { - vtkfield.DataArray->GetTuple(id, tuple); - vectors->SetTuple(id, tuple); - } - } - } -} - -int vtkMedReader::HasMeshAnyCellSelectedFamily(vtkMedMesh* mesh) -{ - int nfam = mesh->GetNumberOfCellFamily(); - for (int famid = 0; famidGetFamily(famid); - if (fam->GetPointOrCell()!=vtkMedUtilities::OnCell||!this->GetFamilyStatus( - mesh, fam)) - continue; - return true; - } - return false; -} - -int vtkMedReader::HasMeshAnyPointSelectedFamily(vtkMedMesh* mesh) -{ - int nfam = mesh->GetNumberOfCellFamily(); - for (int famid = 0; famidGetFamily(famid); - if (fam->GetPointOrCell()!=vtkMedUtilities::OnPoint - ||!this->GetFamilyStatus(mesh, fam)) - continue; - return true; - } - return false; -} - -void vtkMedReader::BuildSIL(vtkMutableDirectedGraph* sil) -{ - if(sil==NULL) - return; - - sil->Initialize(); - - vtkSmartPointer childEdge= - vtkSmartPointer::New(); - childEdge->InsertNextValue(0); - - vtkSmartPointer crossEdge= - vtkSmartPointer::New(); - crossEdge->InsertNextValue(1); - - // CrossEdge is an edge linking hierarchies. - vtkUnsignedCharArray* crossEdgesArray=vtkUnsignedCharArray::New(); - crossEdgesArray->SetName("CrossEdges"); - sil->GetEdgeData()->AddArray(crossEdgesArray); - crossEdgesArray->Delete(); - /*vtk*/std::deque names; - - // Now build the hierarchy. - vtkIdType rootId=sil->AddVertex(); - names.push_back("SIL"); - - // Add a global entry to encode global names for the families - vtkIdType globalFamilyRoot=sil->AddChild(rootId, childEdge); - names.push_back("Families"); - - // Add a global entry to encode global names for the families - vtkIdType globalGroupRoot=sil->AddChild(rootId, childEdge); - names.push_back("Groups"); - - // Add the groups subtree - vtkIdType groupsRoot=sil->AddChild(rootId, childEdge); - names.push_back("GroupTree"); - - // Add a global entry to encode names for the cell types - vtkIdType globalEntityRoot=sil->AddChild(rootId, childEdge); - names.push_back("Entity"); - - // Add the cell types subtree - vtkIdType entityTypesRoot=sil->AddChild(rootId, childEdge); - names.push_back("EntityTree"); - - // this is the map that keep added cell types - map entityMap; - map typeMap; - - std::map >::iterator - meshfileit = this->Internal->MedFiles.begin(); - while(meshfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = meshfileit->second; - meshfileit++; - - int numMeshes=file->GetNumberOfMesh(); - for(int meshIndex=0; meshIndexGetMesh(meshIndex); - vtkMedGrid* grid = this->FindGridStep(mesh); - - if(grid == NULL) - continue; - - // add all entities - for(int entityIndex=0; entityIndexGetNumberOfEntityArray(); entityIndex++) - { - vtkMedEntityArray* array=grid->GetEntityArray(entityIndex); - vtkMedEntity entity = array->GetEntity(); - - if(entityMap.find(entity)==entityMap.end()) - { - vtkIdType entityGlobalId=sil->AddChild(globalEntityRoot, childEdge); - names.push_back(vtkMedUtilities::EntityKey(entity)); - - vtkIdType typeId; - if(typeMap.find(entity.EntityType)==typeMap.end()) - { - typeId=sil->AddChild(entityTypesRoot, childEdge); - names.push_back(vtkMedUtilities::EntityName(entity.EntityType)); - typeMap[entity.EntityType]=typeId; - } - else - { - typeId=typeMap[entity.EntityType]; - } - vtkIdType entityId=sil->AddChild(typeId, childEdge); - names.push_back(entity.GeometryName); - - sil->AddEdge(entityId, entityGlobalId, crossEdge); - - entityMap[entity]=entityId; - } - } - - vtkIdType meshGroup = sil->AddChild(groupsRoot, childEdge); - names.push_back(vtkMedUtilities::SimplifyName(mesh->GetName())); - - // add the two OnPoint and OnCell entries, for groups and for families - vtkIdType meshCellGroups = sil->AddChild(meshGroup, childEdge); - names.push_back(vtkMedUtilities::OnCellName); - - vtkIdType meshPointGroups = sil->AddChild(meshGroup, childEdge); - names.push_back(vtkMedUtilities::OnPointName); - - // this maps will keep all added groups on nodes/cells of this mesh - map nodeGroupMap; - map cellGroupMap; - - // add all families - for(int famIndex=0; famIndexGetNumberOfFamily(); famIndex++) - { - vtkMedFamily* family=mesh->GetFamily(famIndex); - - vtkIdType globalFamilyId = sil->AddChild(globalFamilyRoot, childEdge); - names.push_back(vtkMedUtilities::FamilyKey(mesh->GetName(), - family->GetPointOrCell(), - family->GetName())); - - // family with Id 0 is both on cell and on points, so add it to both - map & groupMap=(family->GetPointOrCell() - ==vtkMedUtilities::OnPoint? nodeGroupMap: cellGroupMap); - - vtkIdType groupRootId = - (family->GetPointOrCell()==vtkMedUtilities::OnPoint? - meshPointGroups : meshCellGroups); - - // add all the groups of this family - for(vtkIdType groupIndex=0; groupIndexGetNumberOfGroup(); - groupIndex++) - { - vtkMedGroup* group=family->GetGroup(groupIndex); - - vtkIdType familyGroupId = sil->AddChild(globalFamilyId, childEdge); - names.push_back(vtkMedUtilities::FamilyKey( - mesh->GetName(), family->GetPointOrCell(), - family->GetName())); - - vtkIdType groupGlobalId; - if(groupMap.find(group->GetName())==groupMap.end()) - { - vtkIdType groupLocalId; - groupLocalId=sil->AddChild(groupRootId, childEdge); - names.push_back(vtkMedUtilities::SimplifyName(group->GetName())); - - groupGlobalId=sil->AddChild(globalGroupRoot, childEdge); - names.push_back(vtkMedUtilities::GroupKey( - mesh->GetName(), family->GetPointOrCell(), - group->GetName())); - groupMap[group->GetName()]=groupGlobalId; - - sil->AddEdge(groupLocalId, groupGlobalId, crossEdge); - } - vtkIdType groupId = groupMap[group->GetName()]; - sil->AddEdge(familyGroupId, groupId, childEdge); - - }//groupIndex - }//famIndex - }//meshIndex - }// file iterator - - // This array is used to assign names to nodes. - vtkStringArray* namesArray=vtkStringArray::New(); - namesArray->SetName("Names"); - namesArray->SetNumberOfTuples(sil->GetNumberOfVertices()); - sil->GetVertexData()->AddArray(namesArray); - namesArray->Delete(); - /*vtk*/std::deque::iterator iter; - vtkIdType cc; - for(cc=0, iter=names.begin(); iter!=names.end(); ++iter, ++cc) - { - namesArray->SetValue(cc, (*iter).c_str()); - } -} - -void vtkMedReader::ClearMedSupports() -{ - this->Internal->DataSetCache.clear(); - //this->Internal->Med2VTKPointIndex.clear(); - - std::map >::iterator - meshfileit = this->Internal->MedFiles.begin(); - while(meshfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = meshfileit->second; - meshfileit++; - int numMeshes=file->GetNumberOfMesh(); - for(int meshIndex=0; meshIndexGetMesh(meshIndex); - mesh->ClearMedSupports(); - } - - int numProf = file->GetNumberOfProfile(); - for (int prof = 0; profGetProfile(prof); - if (profile->GetIds()!=NULL) - profile->GetIds()->Initialize(); - } - } -} - -void vtkMedReader::ClearMedFields() -{ - this->Internal->FieldCache.clear(); - this->Internal->QuadOffsetKey.clear(); - this->Internal->QuadratureOffsetCache.clear(); - - std::map >::iterator - fieldfileit = this->Internal->MedFiles.begin(); - while(fieldfileit != this->Internal->MedFiles.end()) - { - vtkMedFile* file = fieldfileit->second; - fieldfileit++; - - int numFields=file->GetNumberOfField(); - for(int ff=0; ffGetField(ff); - int nstep=field->GetNumberOfFieldStep(); - for(int sid=0; sidGetFieldStep(sid); - for(int id=0; idGetNumberOfFieldOverEntity(); id++) - { - vtkMedFieldOverEntity * fieldOverEntity=step->GetFieldOverEntity(id); - for(int pid = 0; pid < fieldOverEntity->GetNumberOfFieldOnProfile(); pid++) - { - vtkMedFieldOnProfile* fop = fieldOverEntity->GetFieldOnProfile(pid); - if(fop->GetData() != NULL) - fop->SetData(NULL); - } - } - } - } - } -} - -void vtkMedReader::ClearCaches(int when) -{ - switch(when) - { - case Initialize: - this->Internal->CurrentDataSet.clear(); - this->Internal->DataSetCache.clear(); - this->Internal->FieldCache.clear(); - this->Internal->UsedSupports.clear(); - this->Internal->QuadratureOffsetCache.clear(); - this->Internal->QuadOffsetKey.clear(); - //this->Internal->Med2VTKPointIndex.clear(); - break; - case StartRequest: - this->Internal->CurrentDataSet.clear(); - this->Internal->UsedSupports.clear(); - if(this->CacheStrategy==CacheNothing) - { - this->ClearMedSupports(); - this->ClearMedFields(); - } - else if(this->CacheStrategy==CacheGeometry) - { - this->ClearMedFields(); - } - break; - case AfterCreateMedSupports: - // TODO : clear the unused supports and associated cached datasets and fields - break; - case EndBuildVTKSupports: - break; - case EndRequest: - if(this->CacheStrategy==CacheNothing) - { - this->ClearMedSupports(); - this->ClearMedFields(); - } - else if(this->CacheStrategy==CacheGeometry && this->AnimationMode != Modes) - { - this->ClearMedFields(); - } - break; - } -} - -void vtkMedReader::PrintSelf(ostream& os, vtkIndent indent) -{ - PRINT_STRING(os, indent, FileName); - PRINT_IVAR(os, indent, AnimationMode); - PRINT_IVAR(os, indent, TimeIndexForIterations); - PRINT_OBJECT(os, indent, PointFields); - PRINT_OBJECT(os, indent, CellFields); - PRINT_OBJECT(os, indent, QuadratureFields); - PRINT_OBJECT(os, indent, ElnoFields); - PRINT_OBJECT(os, indent, Groups); - PRINT_OBJECT(os, indent, Entities); - PRINT_IVAR(os, indent, CacheStrategy); - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedReader.h b/src/Plugins/MedReader/IO/vtkMedReader.h deleted file mode 100644 index 471e2531..00000000 --- a/src/Plugins/MedReader/IO/vtkMedReader.h +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedReader_h_ -#define __vtkMedReader_h_ - -#include "vtkMultiBlockDataSetAlgorithm.h" -#include "vtkMedSetGet.h" -#include - -class vtkMedFile; -class vtkMedDriver; -class vtkMedSelection; -class vtkMedFieldOverEntity; -class vtkMedFieldStep; -class vtkMedField; -class vtkMedMesh; -class vtkMedFamily; -class vtkMedLocalization; -class vtkMedEntityArray; -class vtkMedFamilyOnEntity; -class vtkMedFamilyOnEntityOnProfile; -class vtkMedProfile; -class vtkMedComputeStep; -class vtkMedGrid; -class vtkMedFieldOnProfile; -class vtkMedListOfFieldSteps; -class vtkMedEntity; - -class vtkUnstructuredGrid; -class vtkUnsignedCharArray; -class vtkIdList; -class vtkDoubleArray; -class vtkFieldData; -class vtkInformationDataObjectKey; -class vtkMutableDirectedGraph; -class vtkDataSet; - -class VTK_EXPORT vtkMedReader: public vtkMultiBlockDataSetAlgorithm -{ -public: - static vtkMedReader* New(); - vtkTypeMacro(vtkMedReader, vtkMultiBlockDataSetAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Set the file name to read from - virtual void SetFileName(const char*); - vtkGetStringMacro(FileName) - - // Description: - // Is the given file a MED file? - virtual int CanReadFile(const char* fname); - - // Description: - // Get the file extensions for this format. - // Returns a string with a space separated list of extensions in - // the format .extension - virtual const char* - GetFileExtensions() - { - return ".med .rmed"; - } - - // Description: - // Return a descriptive name for the file format that might be - // useful in a GUI. - virtual const char* - GetDescriptiveName() - { - return "MED file (Modele d'Echange de Donnees)"; - } - - // Description: - // use these methods to enable/disable point arrays - virtual int GetPointFieldArrayStatus(const char* name); - virtual void SetPointFieldArrayStatus(const char* name, int status); - virtual int GetNumberOfPointFieldArrays(); - virtual const char* GetPointFieldArrayName(int); - - // Description: - // use these methods to enable/disable cell arrays - virtual int GetCellFieldArrayStatus(const char* name); - virtual void SetCellFieldArrayStatus(const char* name, int status); - virtual int GetNumberOfCellFieldArrays(); - virtual const char* GetCellFieldArrayName(int); - - // Description: - // use these methods to enable/disable quadrature arrays - virtual int GetQuadratureFieldArrayStatus(const char* name); - virtual void SetQuadratureFieldArrayStatus(const char* name, int status); - virtual int GetNumberOfQuadratureFieldArrays(); - virtual const char* GetQuadratureFieldArrayName(int); - - // Description: - // use these methods to enable/disable quadrature arrays - virtual int GetElnoFieldArrayStatus(const char* name); - virtual void SetElnoFieldArrayStatus(const char* name, int status); - virtual int GetNumberOfElnoFieldArrays(); - virtual const char* GetElnoFieldArrayName(int); - - // Description: - // use this method to enable/disable cell types - // the key is encoded with the vtkMedUtilities::EntityKey method - // which returns a string - // CELL_TYPE/MED_ENTITE_MAILLAGE/MED_GEOMETRIE_ELEMENT - virtual void SetEntityStatus(const char* key, int flag); - virtual int GetEntityStatus(const vtkMedEntity&); - - // Description: - // use this method to enable/disable a family support - // the key is formatted by the vtkMedUtilities::FamilyKey method which - // returns a string - // GROUP/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME - virtual void SetGroupStatus(const char* key, int flag); - virtual int GetGroupStatus(const char* key); - - // Description: - // the animation mode modify the way the reader answers time requests from - // the pipeline. - // Default (0) : this is PhysicalTime if there are times, or Iterations - // if there are only iterations - // PhysicalTime (1) : the reader aggregates all physical times available - // in the file. - // for a given time t, the reader will return for each field the - // ComputeStep with the highest time inferior - // to t, and with the highest iteration. - // Iteration (2) : you need to also set the TimeIndexForIterations field. - // In this case, the reader will understand - // time requests has a request to iterate over iterations for the given time. - // Modes (3) : the reader will output the selected fields at all selected - // frequencies, and will output a fake TimeRange of -PI/+PI. - // Use the *FrequencyArray* interface to select them. - //BTX - enum eAnimationMode - { - Default=0, PhysicalTime=1, Iteration=2, Modes=3 - }; - //ETX - vtkSetMacro(AnimationMode, int); - vtkGetMacro(AnimationMode, int); - - // Description: - // in med files, the ComputeSteps are defined by a - // pair . - // the TimeIndexForIterations ivar is used only if the TimeMode is - // Iteration. - // it fixes the PhysicalTime index when iterating over iterations : only - // iterations with the corresponding physical time will be iterated over. - // The index given here is an index into the AvailableTimes array - // that is returned be the GetAvailableTimes Method. - vtkSetMacro(TimeIndexForIterations, double); - vtkGetMacro(TimeIndexForIterations, double); - - // Description: - // use these methods to enable/disable a given frequency for modal analysis - virtual int GetFrequencyArrayStatus(const char* name); - virtual void SetFrequencyArrayStatus(const char* name, int status); - virtual int GetNumberOfFrequencyArrays(); - virtual const char* GetFrequencyArrayName(int); - - // Description: - // returns the available physical times. Use this to get the times when in - // iteration mode. - virtual vtkDoubleArray* GetAvailableTimes(); - - // Description: - // Build the graph used to pass information to the client on the supports - virtual void BuildSIL(vtkMutableDirectedGraph*); - - // Description: - // Every time the SIL is updated a this will return a different value. - virtual int GetSILUpdateStamp(); - - // Description: - // reset the selection arrays without having to rebuild the SIL. - virtual void ClearSelections(); - - // Description: - // The CacheStrategy indicates to the reader if it - // should cache some of the arrays. - //BTX - enum eCacheStrategy - { - CacheNothing, CacheGeometry, CacheGeometryAndFields - }; - //ETX - vtkSetMacro(CacheStrategy, int) - vtkGetMacro(CacheStrategy, int) - - // Description : - // release arrays read from MED (point coordinates, profile ids, family ids) - void ClearMedSupports(); - - // Description : - // release arrays read from MED (fields) - void ClearMedFields(); - - // Description: - // If this flag is set, the reader will output a vector field for each - // field in the file that has 2 or more components by extracting the - // first 3 compoenents - vtkSetMacro(GenerateVectors, int); - vtkGetMacro(GenerateVectors, int); - -protected: - vtkMedReader(); - virtual ~vtkMedReader(); - - // Description: - // This is called by the superclass. - virtual int RequestDataObject(vtkInformation*, vtkInformationVector**, - vtkInformationVector*); - - // Description: - // This is called by the superclass. - virtual int RequestInformation(vtkInformation*, vtkInformationVector**, - vtkInformationVector*); - - // Description: - // This is called by the superclass. - virtual int RequestData(vtkInformation*, vtkInformationVector**, - vtkInformationVector*); - - // Description: - // Gather all compute steps in the fields - virtual void GatherComputeSteps(); - - // Description: - // Give the animation steps to the pipeline - virtual void AdvertiseTime(vtkInformation*); - - // Description: - // returns 1 if at least one the families of this mesh is selected, - // 0 otherwise. - virtual int IsMeshSelected(vtkMedMesh*); - - // Description: - // returns if the field is selected. - virtual int IsFieldSelected(vtkMedField*); - virtual int IsPointFieldSelected(vtkMedField*); - virtual int IsCellFieldSelected(vtkMedField*); - virtual int IsQuadratureFieldSelected(vtkMedField*); - virtual int IsElnoFieldSelected(vtkMedField*); - - virtual void AddQuadratureSchemeDefinition(vtkInformation*, - vtkMedLocalization*); - - //BTX - enum - { - Initialize, - StartRequest, - AfterCreateMedSupports, - EndBuildVTKSupports, - EndRequest - }; - //ETX - virtual void ClearCaches(int when); - - virtual void CreateMedSupports(); - - virtual bool BuildVTKSupport(vtkMedFamilyOnEntityOnProfile*, - int doBuildSupport); - - virtual void MapFieldsOnSupport(vtkMedFamilyOnEntityOnProfile* foe, - int doMapField); - - virtual void CreateVTKFieldOnSupport(vtkMedFieldOnProfile*, - vtkMedFamilyOnEntityOnProfile*, - int doCreateField); - - virtual void MapFieldOnSupport(vtkMedFieldOnProfile*, - vtkMedFamilyOnEntityOnProfile*, - int doCreateField); - - // Description: - // Necessary call for the initialization of the filters used for the MED - // library in their parallel reads - virtual void InitializeParallelRead(); - - // Description: - // This method is called after all info from all med files are read. - // it links information coming from different files : - // for instance, it creates the vtkMedFamilyOnEntityOnProfile instances - // to link mesh and field. - virtual void LinkMedInfo(); - - virtual vtkMedProfile* GetProfile(const char*); - - virtual vtkMedLocalization* GetLocalization(const char*); - - virtual int GetLocalizationKey(vtkMedFieldOnProfile*); - - virtual void InitializeQuadratureOffsets(vtkMedFieldOnProfile*, - vtkMedFamilyOnEntityOnProfile*); - - virtual void SetVTKFieldOnSupport(vtkMedFieldOnProfile*, - vtkMedFamilyOnEntityOnProfile*); - - // Description: - // returns the current grid to use for this mesh. - vtkMedGrid* FindGridStep(vtkMedMesh* mesh); - - virtual void GatherFieldSteps(vtkMedField*, vtkMedListOfFieldSteps&); - - // Description: - // returns the index of the given frequency in the AvailableTimes array. - vtkIdType GetFrequencyIndex(double); - - virtual void ChooseRealAnimationMode(); - - // Description : - // Load the connectivity of this entities, and also those of the - // sub-entities in the case of non nodal connectivity. - virtual void LoadConnectivity(vtkMedEntityArray*); - - virtual void InitializeCellGlobalIds(); - - // Description : - // returns 1 if any point/cell family of this mesh is selected. - int HasMeshAnyCellSelectedFamily(vtkMedMesh*); - int HasMeshAnyPointSelectedFamily(vtkMedMesh*); - - // Description: - // use this method to enable/disable a family support - // the key is formatted by the vtkMedUtilities::FamilyKey method which - // returns a string - // FAMILY/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME - virtual void SetFamilyStatus(const char* key, int flag); - virtual int GetFamilyStatus(vtkMedMesh*, vtkMedFamily*); - - // Description: - // This is a helper function that is called when requesting a family status - // if a group status has been set after the last family status update. - virtual void SelectFamiliesFromGroups(); - - // Description: - // Instanciate a new vtkDataSet and initialize it to the points - // of this support. - vtkDataSet* CreateUnstructuredGridForPointSupport( - vtkMedFamilyOnEntityOnProfile* foep); - - // Field selections - vtkMedSelection* PointFields; - vtkMedSelection* CellFields; - vtkMedSelection* QuadratureFields; - vtkMedSelection* ElnoFields; - - // Support selection - vtkMedSelection* Entities; - vtkMedSelection* Groups; - - // name of the file to read from - char* FileName; - - // time management - int AnimationMode; - double TimeIndexForIterations; - vtkDoubleArray* AvailableTimes; - double TimePrecision; - vtkMedSelection* Frequencies; - - int CacheStrategy; - int GenerateVectors; - - //BTX - class vtkMedReaderInternal; - vtkMedReaderInternal* Internal; - //ETX - -private: - vtkMedReader(const vtkMedReader&); // Not implemented. - void operator=(const vtkMedReader&); // Not implemented. -}; - -#endif //__vtkMedReader_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedRegularGrid.cxx b/src/Plugins/MedReader/IO/vtkMedRegularGrid.cxx deleted file mode 100644 index 799d2b3e..00000000 --- a/src/Plugins/MedReader/IO/vtkMedRegularGrid.cxx +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedRegularGrid.h" - -#include "vtkObjectFactory.h" -#include "vtkDataArray.h" -#include "vtkStructuredGrid.h" - -#include "vtkMedUtilities.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedMesh.h" -#include "vtkMedFamilyOnEntityOnProfile.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedEntityArray.h" -#include "vtkMedProfile.h" -#include "vtkMedFamily.h" - -vtkCxxGetObjectVectorMacro(vtkMedRegularGrid, AxisCoordinate, vtkDataArray); -vtkCxxSetAbstractObjectVectorMacro(vtkMedRegularGrid, AxisCoordinate, vtkDataArray); - -// vtkCxxRevisionMacro(vtkMedRegularGrid, "$Revision$") -vtkStandardNewMacro(vtkMedRegularGrid) - -vtkMedRegularGrid::vtkMedRegularGrid() -{ - this->AxisCoordinate = new vtkObjectVector(); -} - -vtkMedRegularGrid::~vtkMedRegularGrid() -{ - delete this->AxisCoordinate; -} - -void vtkMedRegularGrid::SetDimension(med_int dim) -{ - if(dim < 0) - dim = 0; - this->AxisSize.resize(dim); - this->SetNumberOfAxisCoordinate(dim); -} - -int vtkMedRegularGrid::GetDimension() -{ - return this->AxisSize.size(); -} - -void vtkMedRegularGrid::SetAxisSize(int axis, med_int size) -{ - if(axis < 0) - return; - - if(axis >= this->GetDimension()) - { - this->SetDimension(axis+1); - } - - this->AxisSize[axis] = size; -} - -med_int vtkMedRegularGrid::GetAxisSize(int dim) -{ - if(dim < 0 || dim >= this->AxisSize.size()) - return 0; - return this->AxisSize[dim]; -} - -med_int vtkMedRegularGrid::GetNumberOfPoints() -{ - med_int npts = 1; - for(int dim = 0; dim < this->AxisSize.size(); dim++) - { - npts *= this->AxisSize[dim]; - } - return npts; -} - -void vtkMedRegularGrid::LoadCoordinates() -{ - this->GetParentMesh()->GetParentFile()->GetMedDriver()->LoadCoordinates(this); -} - -int vtkMedRegularGrid::IsCoordinatesLoaded() -{ - bool res = this->GetDimension() == this->AxisSize.size() && - this->GetDimension() == this->AxisCoordinate->size(); - - if(!res) - return 0; - - med_int nloadedcoords = 1; - for(int axis=0; axis < this->GetDimension(); axis++) - { - vtkDataArray* axiscoords = this->GetAxisCoordinate(axis); - if(axiscoords != NULL) - nloadedcoords *= axiscoords->GetNumberOfTuples(); - else - nloadedcoords = 0; - } - return nloadedcoords == this->GetNumberOfPoints(); -} - -double* vtkMedRegularGrid::GetCoordTuple(med_int index) -{ - this->CoordTuple[0] = 0; - this->CoordTuple[1] = 0; - this->CoordTuple[2] = 0; - med_int prevmod = 1; - for(int axis=0; axis < this->GetDimension(); axis++) - { - med_int modulo = prevmod * this->AxisSize[axis]; - med_int axisindex = (index % modulo) / prevmod; - prevmod = modulo; - vtkDataArray* coords = this->GetAxisCoordinate(axis); - this->CoordTuple[axis] = coords-> - GetTuple1(axisindex); - } - - return this->CoordTuple; -} - -vtkDataSet* vtkMedRegularGrid::CreateVTKDataSet(vtkMedFamilyOnEntityOnProfile* foep) -{ - vtkStructuredGrid* vtkgrid = vtkStructuredGrid::New(); - - vtkPoints* points = vtkPoints::New(); - vtkgrid->SetPoints(points); - points->Delete(); - - vtkIdType dims[3] = {this->GetAxisSize(0), - this->GetAxisSize(1), - this->GetAxisSize(2)}; - - for(int dim=0; dim<3; dim++) - dims[dim] = (dims[dim] >= 1 ? dims[dim] : 1); - - vtkgrid->SetDimensions(dims[0], dims[1], dims[2]); - - this->LoadCoordinates(); - - if(this->GetAxisCoordinate(0) == NULL) - { - vtkgrid->Delete(); - return NULL; - } - - vtkDataArray* coords = vtkMedUtilities::NewCoordArray(); - coords->SetNumberOfComponents(3); - coords->SetNumberOfTuples(this->GetNumberOfPoints()); - vtkgrid->GetPoints()->SetData(coords); - coords->Delete(); - - med_int npts; - double coord[3] = {0, 0, 0}; - - npts = this->GetNumberOfPoints(); - for(med_int id=0; idGetCoordTuple(id); - for(int dim=0; dimGetDimension(); dim++) - { - coord[dim] = tuple[dim]; - } - coords->SetTuple(id, coord); - } - - if(foep->GetProfile() != NULL) - { - foep->GetProfile()->Load(); - vtkMedIntArray* pids = foep->GetProfile()->GetIds(); - med_int previd = -1; - for(med_int pid=0; pidGetNumberOfTuples(); pid++) - { - med_int id = pids->GetValue(pid) - 1; - for(med_int theid=previd+1; theidBlankCell(theid); - } - - previd = id; - } - } - - if(foep->GetFamilyOnEntity()->GetEntityArray()->GetNumberOfFamilyOnEntity() > 1) - { - med_int famid = foep->GetFamilyOnEntity()->GetFamily()->GetId(); - vtkMedEntityArray* ea = foep->GetFamilyOnEntity()->GetEntityArray(); - for(med_int id=0; idGetNumberOfCells(); id++) - { - if(ea->GetFamilyId(id) != famid) - vtkgrid->BlankCell(id); - } - } - return vtkgrid; -} - -void vtkMedRegularGrid::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedRegularGrid.h b/src/Plugins/MedReader/IO/vtkMedRegularGrid.h deleted file mode 100644 index cd0d0cfb..00000000 --- a/src/Plugins/MedReader/IO/vtkMedRegularGrid.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedRegularGrid_h_ -#define __vtkMedRegularGrid_h_ - -#include "vtkMedGrid.h" -#include "vtkMed.h" -#include "vtkMedSetGet.h" - -#include - -class vtkDataArray; - -class VTK_EXPORT vtkMedRegularGrid : public vtkMedGrid -{ -public : - static vtkMedRegularGrid* New(); - vtkTypeMacro(vtkMedRegularGrid, vtkMedGrid) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Container of the families in this mesh - vtkGetObjectVectorMacro(AxisCoordinate, vtkDataArray); - vtkSetAbstractObjectVectorMacro(AxisCoordinate, vtkDataArray); - - // Description: - // overloaded to set the number of coordinates arrays. - // Do not allocate each array. - virtual void SetDimension(med_int); - virtual int GetDimension(); - - // Description: - // the size of each dimension of the grid. - // SetDimension has to have been called before - virtual void SetAxisSize(int axis, med_int size); - virtual med_int GetAxisSize(int dim); - - // Description: - // returns the number of points of this grid. - virtual med_int GetNumberOfPoints(); - - virtual void LoadCoordinates(); - - virtual double* GetCoordTuple(med_int index); - - virtual int IsCoordinatesLoaded(); - - virtual vtkDataSet* CreateVTKDataSet(vtkMedFamilyOnEntityOnProfile*); - -protected: - vtkMedRegularGrid(); - virtual ~vtkMedRegularGrid(); - - double CoordTuple[3]; - - std::vector AxisSize; - //BTX - vtkObjectVector* AxisCoordinate; - //ETX - -private: - vtkMedRegularGrid(const vtkMedRegularGrid&); // Not implemented. - void operator=(const vtkMedRegularGrid&); // Not implemented. - -}; - -#endif //__vtkMedRegularGrid_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedSelection.cxx b/src/Plugins/MedReader/IO/vtkMedSelection.cxx deleted file mode 100644 index 0c0a38d0..00000000 --- a/src/Plugins/MedReader/IO/vtkMedSelection.cxx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedSelection.h" - -#include "vtkObjectFactory.h" -#include "vtkStringArray.h" - -#include -#include -#include -using namespace std; - -class vtkMedSelectionInternals -{ -public : - map< string, bool > Status; - vector< string > Keys; -}; - -// vtkCxxRevisionMacro(vtkMedSelection, "$Revision$") -vtkStandardNewMacro(vtkMedSelection) - -vtkMedSelection::vtkMedSelection() -{ - this->Internals = new vtkMedSelectionInternals(); -} - -vtkMedSelection::~vtkMedSelection() -{ - delete this->Internals; -} - -void vtkMedSelection::Initialize() -{ - this->Internals->Status.clear(); - this->Internals->Keys.clear(); -} - -void vtkMedSelection::AddKey(const char* key) -{ - if(this->Internals->Status.find(key) != this->Internals->Status.end()) - { - return ; - } - this->Internals->Keys.push_back(key); - this->Internals->Status[key] = 1; -} - -void vtkMedSelection::SetKeyStatus(const char* key, int status) -{ - if(this->Internals->Status.find(key) == this->Internals->Status.end()) - { - this->AddKey(key); - } - this->Internals->Status[key] = status; -} - -int vtkMedSelection::GetKeyStatus(const char* key) -{ - if(this->Internals->Status.find(key) == this->Internals->Status.end()) - { - return 0; - } - return this->Internals->Status[key]; -} - -const char* vtkMedSelection::GetKey(int index) -{ - if(index < 0 || index >= this->Internals->Keys.size()) - { - return NULL; - } - return this->Internals->Keys[index].c_str(); -} - -int vtkMedSelection::GetNumberOfKey() -{ - return this->Internals->Keys.size(); -} - -int vtkMedSelection::KeyExists(const char *key) -{ - return this->Internals->Status.find(key) - != this->Internals->Status.end(); -} - -void vtkMedSelection::RemoveKeyByIndex(int index) -{ - if(index < 0 || index >= this->Internals->Keys.size()) - { - return; - } - string name = this->Internals->Keys[index]; - this->Internals->Status.erase(name); - this->Internals->Keys.erase(this->Internals->Keys.begin() + index); -} - -void vtkMedSelection::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedSelection.h b/src/Plugins/MedReader/IO/vtkMedSelection.h deleted file mode 100644 index b3c98963..00000000 --- a/src/Plugins/MedReader/IO/vtkMedSelection.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedSelection_h_ -#define __vtkMedSelection_h_ - -#include "vtkObject.h" - -class vtkMedSelectionInternals; - -class VTK_EXPORT vtkMedSelection : public vtkObject -{ -public : - static vtkMedSelection* New(); - vtkTypeMacro(vtkMedSelection, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - virtual void Initialize(); - - virtual void AddKey(const char*); - - virtual void SetKeyStatus(const char* name, int status); - - virtual int GetKeyStatus(const char* name); - - virtual const char* GetKey(int index); - - virtual int GetNumberOfKey(); - - virtual int KeyExists(const char* name); - - virtual void RemoveKeyByIndex(int index); - -protected: - vtkMedSelection(); - virtual ~vtkMedSelection(); - - vtkMedSelectionInternals* Internals; - -private: - vtkMedSelection(const vtkMedSelection&); // Not implemented. - void operator=(const vtkMedSelection&); // Not implemented. - -}; - -#endif //__vtkMedSelection_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedSetGet.h b/src/Plugins/MedReader/IO/vtkMedSetGet.h deleted file mode 100644 index 73e07ccb..00000000 --- a/src/Plugins/MedReader/IO/vtkMedSetGet.h +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _vtkMedSetGet_h_ -#define _vtkMedSetGet_h_ - -//BTX -template class vtkObjectVector; -template class vtkList; -template class vtkMedComputeStepMap; - -#define vtkGetObjectVectorMacro(name, type)\ - virtual type* Get##name (int index);\ - virtual vtkIdType GetNumberOf##name (); - -#define vtkSetObjectVectorMacro(name, type)\ - virtual void AllocateNumberOf##name (vtkIdType size);\ - virtual void Set##name (vtkIdType index, type* obj);\ - virtual void Append##name (type* obj);\ - virtual void Remove##name (type* obj); - -#define vtkSetAbstractObjectVectorMacro(name, type)\ - virtual void SetNumberOf##name (vtkIdType size);\ - virtual void Set##name (vtkIdType index, type* obj);\ - virtual void Append##name (type* obj); - -#define vtkCxxGetObjectVectorMacro(class, name, type)\ - type* class::Get##name (int index)\ - {\ - if(index < 0 || index >= this->name->size())\ - return NULL;\ - return this->name->at(index);\ - }\ - vtkIdType class::GetNumberOf##name ()\ - {\ - return this->name->size();\ - } - -#define vtkCxxSetObjectVectorMacro(class, name, type)\ - void class::AllocateNumberOf##name (vtkIdType size)\ - {\ - if(this->name->size() == size)\ - return;\ - if(size <= 0 )\ - this->name->clear();\ - else\ - this->name->resize(size);\ - for(vtkIdType _ii=0; _iiname->size(); _ii++)\ - {\ - this->name->at(_ii) = vtkSmartPointer< type > ::New();\ - }\ - this->Modified();\ - }\ - void class::Set##name (vtkIdType index, type* obj)\ - {\ - if(index < 0 || index >= this->name->size())\ - {\ - vtkWarningMacro("has not been allocated before setting value" );\ - return;\ - }\ - if( this->name->at(index) == obj)\ - return;\ - this->name->at(index) = obj; \ - this->Modified();\ - }\ - void class::Append##name (type* obj)\ - {\ - this->name->resize(this->name->size()+1);\ - this->name->at(this->name->size()-1) = obj;\ - this->Modified();\ - }\ - void class::Remove##name (type* obj)\ - {\ - vtkIdType index=0;\ - for(index=0; index < this->name->size(); index++)\ - {\ - if(this->name->at(index) == obj) break;\ - }\ - if(index == this->name->size()) return;\ - for(vtkIdType id=index; id < this->name->size()-1; id++)\ - {\ - this->name->at(id) = this->name->at(id+1);\ - }\ - this->name->resize(this->name->size()-1);\ - this->Modified();\ - } - -#define vtkCxxSetAbstractObjectVectorMacro(class, name, type)\ - void class::SetNumberOf##name (vtkIdType size)\ - {\ - if(this->name->size() == size)\ - return;\ - if(size <= 0 )\ - this->name->clear();\ - else\ - this->name->resize(size);\ - this->Modified();\ - }\ - void class::Set##name (vtkIdType index, type* obj)\ - {\ - if(index < 0 || index >= this->name->size())\ - {\ - vtkWarningMacro("has not been allocated before setting value" );\ - return;\ - }\ - if( this->name->at(index) == obj)\ - return;\ - this->name->at(index) = obj; \ - this->Modified();\ - }\ - void class::Append##name (type* obj)\ - {\ - this->name->resize(this->name->size()+1);\ - this->name->at(this->name->size()-1) = obj;\ - this->Modified();\ - } - -//ETX - -#endif diff --git a/src/Plugins/MedReader/IO/vtkMedStructElement.cxx b/src/Plugins/MedReader/IO/vtkMedStructElement.cxx deleted file mode 100644 index caf05acd..00000000 --- a/src/Plugins/MedReader/IO/vtkMedStructElement.cxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedStructElement.h" - -#include "vtkObjectFactory.h" -#include "vtkMedUtilities.h" -#include "vtkMedVariableAttribute.h" -#include "vtkMedConstantAttribute.h" -#include "vtkMedFile.h" -#include "vtkMedMesh.h" - -#include -#include -#include -using namespace std; - -vtkCxxGetObjectVectorMacro(vtkMedStructElement, VariableAttribute, vtkMedVariableAttribute); -vtkCxxSetObjectVectorMacro(vtkMedStructElement, VariableAttribute, vtkMedVariableAttribute); -vtkCxxGetObjectVectorMacro(vtkMedStructElement, ConstantAttribute, vtkMedConstantAttribute); -vtkCxxSetObjectVectorMacro(vtkMedStructElement, ConstantAttribute, vtkMedConstantAttribute); - -vtkCxxSetObjectMacro(vtkMedStructElement, ParentFile, vtkMedFile); -vtkCxxSetObjectMacro(vtkMedStructElement, SupportMesh, vtkMedMesh); - -// vtkCxxRevisionMacro(vtkMedStructElement, "$Revision$") -vtkStandardNewMacro(vtkMedStructElement) - -vtkMedStructElement::vtkMedStructElement() -{ - this->MedIterator = -1; - this->Name = NULL; - this->GeometryType = MED_UNDEF_GEOTYPE; - this->ModelDimension = 0; - this->SupportMeshName = NULL; - this->SupportMesh = NULL; - this->SupportEntityType = MED_UNDEF_ENTITY_TYPE; - this->SupportNumberOfNode = 0; - this->SupportNumberOfCell = 0; - this->SupportGeometryType = MED_UNDEF_GEOTYPE; - this->AnyProfile = MED_FALSE; - this->VariableAttribute = new vtkObjectVector(); - this->ConstantAttribute = new vtkObjectVector(); - this->ParentFile = NULL; -} - -vtkMedStructElement::~vtkMedStructElement() -{ - this->SetName(NULL); - this->SetSupportMeshName(NULL); - this->SetParentFile(NULL); - this->SetSupportMesh(NULL); - delete this->VariableAttribute; - delete this->ConstantAttribute; -} - -void vtkMedStructElement::LoadVariableAttributes(vtkMedEntityArray* array) -{ - for(int varattit = 0; varattit < this->GetNumberOfVariableAttribute(); varattit++) - { - vtkMedVariableAttribute* varatt = this->GetVariableAttribute(varattit); - varatt->Load(array); - } -} - -int vtkMedStructElement::GetConnectivitySize() -{ - if(strcmp(this->Name, MED_PARTICLE_NAME) == 0 - || this->SupportEntityType != MED_CELL) - return this->SupportNumberOfNode; - - return this->SupportNumberOfCell * - vtkMedUtilities::GetNumberOfPoint(this->SupportGeometryType); -} - -void vtkMedStructElement::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedStructElement.h b/src/Plugins/MedReader/IO/vtkMedStructElement.h deleted file mode 100644 index 1f91b784..00000000 --- a/src/Plugins/MedReader/IO/vtkMedStructElement.h +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedStructElement_h_ -#define __vtkMedStructElement_h_ - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedSetGet.h" - -class vtkMedVariableAttribute; -class vtkMedConstantAttribute; -class vtkMedFile; -class vtkMedMesh; -class vtkMedEntityArray; - -class VTK_EXPORT vtkMedStructElement : public vtkObject -{ -public : - static vtkMedStructElement* New(); - vtkTypeMacro(vtkMedStructElement, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // The iterator to identify this struct element model in the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // This is the name of this structural element model - vtkSetStringMacro(Name); - vtkGetStringMacro(Name); - - // Description: - // The Geometry type this structural elements lies on. - vtkSetMacro(GeometryType, med_geometry_type); - vtkGetMacro(GeometryType, med_geometry_type); - - // Description: - // The dimension of this structural elements model - vtkSetMacro(ModelDimension, med_int); - vtkGetMacro(ModelDimension, med_int); - - // Description: - // The name of the support mesh used by this structural element model - vtkSetStringMacro(SupportMeshName); - vtkGetStringMacro(SupportMeshName); - - // Description: - // This is the support mesh instance, corresponding to the above name. - virtual void SetSupportMesh(vtkMedMesh*); - vtkGetObjectMacro(SupportMesh, vtkMedMesh); - - // Description: - // The type of entity contained in the support mesh - vtkSetMacro(SupportEntityType, med_entity_type); - vtkGetMacro(SupportEntityType, med_entity_type); - - // Description: - // The number of nodes of the support mesh - vtkSetMacro(SupportNumberOfNode, med_int); - vtkGetMacro(SupportNumberOfNode, med_int); - - // Description: - // The number of cells in the support mesh. - vtkSetMacro(SupportNumberOfCell, med_int); - vtkGetMacro(SupportNumberOfCell, med_int); - - // Description: - // The geometry type of the cells in the support mesh - vtkSetMacro(SupportGeometryType, med_geometry_type); - vtkGetMacro(SupportGeometryType, med_geometry_type); - - // Description: - // This boolean is set to true if the attributes are given on a profile - vtkSetMacro(AnyProfile, med_bool); - vtkGetMacro(AnyProfile, med_bool); - - // Description: - // Get the Variable Attributes - vtkGetObjectVectorMacro(VariableAttribute, vtkMedVariableAttribute); - vtkSetObjectVectorMacro(VariableAttribute, vtkMedVariableAttribute); - - // Description: - // Get the Constant Attributes - vtkGetObjectVectorMacro(ConstantAttribute, vtkMedConstantAttribute); - vtkSetObjectVectorMacro(ConstantAttribute, vtkMedConstantAttribute); - - // Description: - // The file this structural element model is stored in. - virtual void SetParentFile(vtkMedFile*); - vtkGetObjectMacro(ParentFile, vtkMedFile); - - // Description: - // This method will use the driver to load the data for this compute step - // for all variable attributes from disk. - virtual void LoadVariableAttributes(vtkMedEntityArray*); - - // Description: - // returns the size of the connectivity for one structural element. - // for MED_PARTICLE elements, it returns the number of nodes - // if SupportEntityType == MED_CELL, it returns the number of cells in the - // support mesh * the number of node for each cell. - // else it returns the number of nodes in the support mesh. - virtual int GetConnectivitySize(); - -protected: - vtkMedStructElement(); - virtual ~vtkMedStructElement(); - - med_int MedIterator; - char *Name; - med_geometry_type GeometryType; - med_int ModelDimension; - char *SupportMeshName; - med_entity_type SupportEntityType; - med_int SupportNumberOfNode; - med_int SupportNumberOfCell; - med_geometry_type SupportGeometryType; - med_bool AnyProfile; - - vtkMedFile* ParentFile; - vtkMedMesh* SupportMesh; - - vtkObjectVector* VariableAttribute; - vtkObjectVector* ConstantAttribute; - -private: - vtkMedStructElement(const vtkMedStructElement&); // Not implemented. - void operator=(const vtkMedStructElement&); // Not implemented. - -}; - -#endif //__vtkMedStructElement_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedSupportMesh.cxx b/src/Plugins/MedReader/IO/vtkMedSupportMesh.cxx deleted file mode 100644 index 8e3074e9..00000000 --- a/src/Plugins/MedReader/IO/vtkMedSupportMesh.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedSupportMesh.h" - -#include "vtkObjectFactory.h" -#include "vtkMedUtilities.h" -#include "vtkMedFile.h" - -#include "vtkStringArray.h" - -#include -#include -#include -using namespace std; - -vtkCxxSetObjectMacro(vtkMedSupportMesh, ParentFile, vtkMedFile); - -// vtkCxxRevisionMacro(vtkMedSupportMesh, "$Revision$") -vtkStandardNewMacro(vtkMedSupportMesh) - -vtkMedSupportMesh::vtkMedSupportMesh() -{ - this->MedIterator = -1; - this->Name = NULL; - this->ParentFile = NULL; - this->AxisName = vtkStringArray::New(); - this->AxisUnit = vtkStringArray::New(); - this->Description = NULL; - this->AxisType = MED_UNDEF_AXIS_TYPE; - this->SpaceDimension = 0; - this->MeshDimension = 0; -} - -vtkMedSupportMesh::~vtkMedSupportMesh() -{ - this->SetName(NULL); - this->SetDescription(NULL); - this->SetParentFile(NULL); - this->AxisName->Delete(); - this->AxisUnit->Delete(); -} - -void vtkMedSupportMesh::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedSupportMesh.h b/src/Plugins/MedReader/IO/vtkMedSupportMesh.h deleted file mode 100644 index 3dabb849..00000000 --- a/src/Plugins/MedReader/IO/vtkMedSupportMesh.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedSupportMesh_h_ -#define __vtkMedSupportMesh_h_ - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedSetGet.h" - -class vtkStringArray; -class vtkMedFile; - -class VTK_EXPORT vtkMedSupportMesh : public vtkObject -{ -public : - static vtkMedSupportMesh* New(); - vtkTypeMacro(vtkMedSupportMesh, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // The iterator to identify this struct element model in the med file - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // This is the name of this structural element model - vtkSetStringMacro(Name); - vtkGetStringMacro(Name); - - // Description: - // This is the dsecription of this structural element model - vtkSetStringMacro(Description); - vtkGetStringMacro(Description); - - // Description: - // The dimension of this support mesh lives in - vtkSetMacro(SpaceDimension, med_int); - vtkGetMacro(SpaceDimension, med_int); - - // Description: - // The dimension of this support mesh model - vtkSetMacro(MeshDimension, med_int); - vtkGetMacro(MeshDimension, med_int);; - - // Description: - // The dimension of this support mesh model - vtkSetMacro(AxisType, med_axis_type); - vtkGetMacro(AxisType, med_axis_type);; - - // Description: - // The file this support mesh is stored in. - virtual void SetParentFile(vtkMedFile*); - vtkGetObjectMacro(ParentFile, vtkMedFile); - - // Dsecription: - // This array stores the units of the axis - vtkGetObjectMacro(AxisName, vtkStringArray); - - // Description: - // This array store the units of thi support mesh for each axis - vtkGetObjectMacro(AxisUnit, vtkStringArray); - -protected: - vtkMedSupportMesh(); - virtual ~vtkMedSupportMesh(); - - med_int MedIterator; - med_int SpaceDimension; - med_int MeshDimension; - char *Name; - char *Description; - med_axis_type AxisType; - vtkStringArray *AxisName; - vtkStringArray *AxisUnit; - - vtkMedFile* ParentFile; - -private: - vtkMedSupportMesh(const vtkMedSupportMesh&); // Not implemented. - void operator=(const vtkMedSupportMesh&); // Not implemented. - -}; - -#endif //__vtkMedSupportMesh_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.cxx b/src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.cxx deleted file mode 100644 index 18c9e582..00000000 --- a/src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.cxx +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedUnstructuredGrid.h" - -#include "vtkObjectFactory.h" -#include "vtkSmartPointer.h" -#include "vtkDataArray.h" -#include "vtkUnstructuredGrid.h" -#include "vtkPointData.h" -#include "vtkCellData.h" -#include "vtkIdList.h" -#include "vtkCellType.h" -#include "vtkInformation.h" - -#include "vtkMedUtilities.h" -#include "vtkMedEntityArray.h" -#include "vtkMedMesh.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" -#include "vtkMedFamilyOnEntityOnProfile.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedProfile.h" -#include "vtkMedUtilities.h" -#include "vtkMedStructElement.h" -#include "vtkMedVariableAttribute.h" - -#include "vtkMultiProcessController.h" - -vtkCxxSetObjectMacro(vtkMedUnstructuredGrid,Coordinates,vtkDataArray); - -// vtkCxxRevisionMacro(vtkMedUnstructuredGrid, "$Revision$") -vtkStandardNewMacro(vtkMedUnstructuredGrid) - -vtkMedUnstructuredGrid::vtkMedUnstructuredGrid() -{ - this->Coordinates = NULL; - this->NumberOfPoints = 0; -} - -vtkMedUnstructuredGrid::~vtkMedUnstructuredGrid() -{ - this->SetCoordinates(NULL); -} - -int vtkMedUnstructuredGrid::IsCoordinatesLoaded() -{ - return this->Coordinates != NULL && this->Coordinates->GetNumberOfTuples() - == this->NumberOfPoints; -} - -void vtkMedUnstructuredGrid::InitializeCellGlobalIds() -{ - vtkIdType ncells = 0; - - for(int id = 0; id < this->EntityArray->size(); id++) - { - vtkMedEntityArray* array = this->EntityArray->at(id); - - if(array == NULL) - continue; - - if(array->GetEntity().EntityType == MED_NODE) - continue; - - array->SetInitialGlobalId(ncells + 1); - ncells += array->GetNumberOfEntity(); - } -} - -void vtkMedUnstructuredGrid::ClearMedSupports() -{ - this->Superclass::ClearMedSupports(); - for(int id = 0; id < this->EntityArray->size(); id++) - { - vtkMedEntityArray* array = this->EntityArray->at(id); - array->Initialize(); - } -} - -void vtkMedUnstructuredGrid::LoadCoordinates() -{ - this->GetParentMesh()->GetParentFile()->GetMedDriver()->LoadCoordinates(this); -} - -double* vtkMedUnstructuredGrid::GetCoordTuple(med_int index) -{ - return this->Coordinates->GetTuple(index); -} - -vtkDataSet* vtkMedUnstructuredGrid::CreateVTKDataSet( - vtkMedFamilyOnEntityOnProfile* foep) -{ - vtkMultiProcessController* controller = - vtkMultiProcessController::GetGlobalController(); - - vtkMedFamilyOnEntity* foe = foep->GetFamilyOnEntity(); - vtkMedEntityArray* array = foe->GetEntityArray(); - if(foep->GetValid() == 0) - { - return NULL; - } - - vtkUnstructuredGrid* vtkugrid = vtkUnstructuredGrid::New(); - - // now we copy all the flagged nodes in the grid, shallow copy if possible - bool shallowCopyPoints=true; - - if(this->GetParentMesh()->GetSpaceDimension()!=3) - { - shallowCopyPoints=false; - } - - shallowCopyPoints = shallowCopyPoints && foep->CanShallowCopyPointField(NULL); - - foe->GetParentGrid()->LoadCoordinates(); - - vtkIdType numberOfPoints; - vtkPoints* points=vtkPoints::New(this->GetCoordinates()->GetDataType()); - vtkugrid->SetPoints(points); - points->Delete(); - - vtkIdTypeArray* pointGlobalIds=vtkIdTypeArray::New(); - pointGlobalIds->SetName("MED_POINT_ID"); - pointGlobalIds->SetNumberOfComponents(1); - vtkugrid->GetPointData()->SetGlobalIds(pointGlobalIds); - pointGlobalIds->Delete(); - - vtkIdTypeArray* cellGlobalIds=vtkIdTypeArray::New(); - cellGlobalIds->SetName("MED_CELL_ID"); - cellGlobalIds->SetNumberOfComponents(1); - vtkugrid->GetCellData()->SetGlobalIds(cellGlobalIds); - cellGlobalIds->Delete(); - - if (shallowCopyPoints) - { - vtkugrid->GetPoints()->SetDataType(this->GetCoordinates()->GetDataType()); - vtkugrid->GetPoints()->SetData(this->GetCoordinates()); - // add global ids - numberOfPoints=this->GetNumberOfPoints(); - pointGlobalIds->SetNumberOfTuples(numberOfPoints); - vtkIdType* ptr=pointGlobalIds->GetPointer(0); - for(int pid=0; pidGetNumberOfPoints(); index++) - { - if(!foep->KeepPoint(index)) - continue; - - double coord[3]={0.0, 0.0, 0.0}; - double * tuple=this->GetCoordinates()->GetTuple(index); - for(int dim=0; dimGetParentMesh()->GetSpaceDimension()&&dim<3; dim++) - { - coord[dim]=tuple[dim]; - } - vtkugrid->GetPoints()->InsertPoint(currentIndex, coord); - pointGlobalIds->InsertNextValue(index+1); - currentIndex++; - } - vtkugrid->GetPoints()->Squeeze(); - pointGlobalIds->Squeeze(); - numberOfPoints=currentIndex; - } - - vtkMedStructElement* structelem = NULL; - int vtkType = VTK_EMPTY_CELL; - int nsupportcell = 1; - vtkSmartPointer supportIndex = vtkSmartPointer::New(); - supportIndex->SetName("STRUCT_ELEMENT_INDEX"); - supportIndex->SetNumberOfComponents(2); - supportIndex->GetInformation()->Set(vtkMedUtilities::STRUCT_ELEMENT_INDEX(), 1); - supportIndex->GetInformation()->Set(vtkAbstractArray::GUI_HIDE(), 1); - supportIndex->SetComponentName(0, "GLOBAL_ID"); - supportIndex->SetComponentName(1, "LOCAL_ID"); - - if(array->GetEntity().EntityType == MED_STRUCT_ELEMENT) - { - structelem = array->GetStructElement(); - if(structelem == NULL) - { - foep->SetValid(0); - } - else - { - vtkType = vtkMedUtilities::GetVTKCellType( - structelem->GetSupportGeometryType()); - nsupportcell = structelem->GetSupportNumberOfCell(); - if(structelem->GetSupportEntityType() != MED_CELL - || strcmp(structelem->GetName(), MED_PARTICLE_NAME) == 0) - { - // Special case : the support connectivity is implicit - // (for particles) - // map this to points - vtkType = VTK_VERTEX; - nsupportcell = structelem->GetSupportNumberOfNode(); - } - - vtkugrid->GetInformation()->Set(vtkMedUtilities::STRUCT_ELEMENT(), structelem); - std::cout << "structelem->GetNumberOfVariableAttribute() = " << structelem->GetNumberOfVariableAttribute() << std::endl; - for(int varattid = 0; varattidGetNumberOfVariableAttribute(); varattid++) - { - vtkMedVariableAttribute* varatt = structelem->GetVariableAttribute(varattid); - varatt->Load(array); - vtkAbstractArray* values = array->GetVariableAttributeValue(varatt); - vtkugrid->GetFieldData()->AddArray(values); - } - vtkugrid->GetCellData()->AddArray(supportIndex); - } - } - else - { - vtkType = vtkMedUtilities::GetVTKCellType( - array->GetEntity().GeometryType); - } - - vtkSmartPointer pts = vtkSmartPointer::New(); - vtkSmartPointer vtkpts = vtkSmartPointer::New(); - vtkIdType intialGlobalId = array->GetInitialGlobalId(); - vtkMedIntArray* pids = (foep->GetProfile()!=NULL? - foep->GetProfile()->GetIds() : NULL); - vtkIdType maxId = (pids!=NULL? - pids->GetNumberOfTuples(): - array->GetNumberOfEntity()); - - int valid = foep->GetValid(); - if (controller != NULL) - if (controller->GetNumberOfProcesses() > 1) - valid = 1; - - for (vtkIdType pindex = 0; pindexGetValue(pindex)-1: - pindex); - - if (!foep->KeepCell(realIndex)) - continue; - - array->GetCellVertices(realIndex, pts); - - for(int sid = 0; sid < nsupportcell; sid++) - { - cellGlobalIds->InsertNextValue(intialGlobalId+pindex); - } - - // The supportIndex array has 2 component, the first to give the index - // of the med cell in the variable attributes array, the second to give - // the index of the cell in the n cells composing the structural element - if(array->GetEntity().EntityType == MED_STRUCT_ELEMENT) - { - for(int sid = 0; sid < nsupportcell; sid++) - { - supportIndex->InsertNextTuple2(pindex, sid); - } - } - - if (array->GetEntity().GeometryType==MED_POLYHEDRON) - { - if(vtkMedUtilities::FormatPolyhedronForVTK(foep, pindex, pts)) - { - vtkugrid->InsertNextCell(VTK_POLYHEDRON, pts); - } - else - { - foep->SetValid(0); - vtkugrid->Delete(); - return NULL; - } - } - else - { - vtkpts->Initialize(); - vtkpts->SetNumberOfIds(pts->GetNumberOfIds()); - - for(vtkIdType node=0; nodeGetNumberOfIds(); node++) - { - vtkIdType pid = pts->GetId(node); - vtkIdType ptid=foep->GetVTKPointIndex(pid); - if(ptid < 0 || ptid >= vtkugrid->GetNumberOfPoints()) - { - vtkDebugMacro("Index error, this cell" << - " is not on this profile"); -#ifndef MedReader_HAVE_PARALLEL_INFRASTRUCTURE - vtkugrid->Delete(); - foep->SetValid(0); - return NULL; -#else - return vtkugrid; -#endif - } - vtkpts->SetId(vtkMedUtilities::MedToVTKIndex(vtkType, node), ptid); - } - - // for strutural elements, insert nsupportcell instead of only one - if(nsupportcell > 1) - { - vtkIdType npts = vtkpts->GetNumberOfIds() / nsupportcell; - for(int sid=0; sid < nsupportcell; sid++) - { - vtkIdType* ptids = vtkpts->GetPointer(sid * npts); - vtkugrid->InsertNextCell(vtkType, npts, ptids); - } - } - else - { - vtkugrid->InsertNextCell(vtkType, vtkpts); - } - } - } - - if(vtkugrid->GetNumberOfCells() == vtkugrid->GetNumberOfPoints()) - { - for(int fieldId = 0; fieldId < vtkugrid->GetFieldData()->GetNumberOfArrays(); fieldId++) - { - vtkDataArray* fieldData = vtkugrid->GetFieldData()->GetArray(fieldId); - - if(fieldData->GetNumberOfTuples() == vtkugrid->GetNumberOfCells()) - { - vtkugrid->GetPointData()->AddArray(fieldData); - } - else - { - vtkDataArray* real_fieldData = fieldData->NewInstance(); - real_fieldData->SetName(fieldData->GetName()); - real_fieldData->SetNumberOfComponents(fieldData->GetNumberOfComponents()); - - for(vtkIdType cellId = 0; cellId < vtkugrid->GetNumberOfPoints(); cellId++) - { - vtkIdType supportId = static_cast(supportIndex->GetTuple2(cellId)[0]); - real_fieldData->InsertNextTuple(fieldData->GetTuple(supportId)); - } - - vtkugrid->GetPointData()->AddArray(real_fieldData); - real_fieldData->Delete(); - } - } - } - - return vtkugrid; -} - -void vtkMedUnstructuredGrid::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - PRINT_IVAR(os, indent, NumberOfPoints); -} diff --git a/src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.h b/src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.h deleted file mode 100644 index 85ee87ca..00000000 --- a/src/Plugins/MedReader/IO/vtkMedUnstructuredGrid.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedUnstructuredGrid_h_ -#define __vtkMedUnstructuredGrid_h_ - -#include "vtkMedGrid.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" - -class vtkDataArray; -class vtkMedEntityArray; -class vtkMedString; - -class VTK_EXPORT vtkMedUnstructuredGrid : public vtkMedGrid -{ -public : - static vtkMedUnstructuredGrid* New(); - vtkTypeMacro(vtkMedUnstructuredGrid, vtkMedGrid); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // this array contains the coordinates of the points used by this grid. - virtual void SetCoordinates(vtkDataArray*); - vtkGetObjectMacro(Coordinates, vtkDataArray); - - // Description: - // returns true if the Coordinate array is set and corresponds - // to the number of points - virtual int IsCoordinatesLoaded(); - - // Description: - // Initialize the global Ids of the first element of each MedEntityArray - virtual void InitializeCellGlobalIds(); - - // Description: - // Free the memory associated with this grid. - virtual void ClearMedSupports(); - - // Description: - // Set the number of points in the grid. - // no allocation is performed at this points, you have to allocate the Points - // array manually. - vtkSetMacro(NumberOfPoints, med_int); - vtkGetMacro(NumberOfPoints, med_int); - - virtual void LoadCoordinates(); - - virtual double* GetCoordTuple(med_int index); - - virtual vtkDataSet* CreateVTKDataSet(vtkMedFamilyOnEntityOnProfile*); - -protected: - vtkMedUnstructuredGrid(); - virtual ~vtkMedUnstructuredGrid(); - - vtkDataArray* Coordinates; - - med_int NumberOfPoints; - -private: - vtkMedUnstructuredGrid(const vtkMedUnstructuredGrid&); // Not implemented. - void operator=(const vtkMedUnstructuredGrid&); // Not implemented. -}; - -#endif //__vtkMedUnstructuredGrid_h_ diff --git a/src/Plugins/MedReader/IO/vtkMedUtilities.cxx b/src/Plugins/MedReader/IO/vtkMedUtilities.cxx deleted file mode 100644 index 898d0460..00000000 --- a/src/Plugins/MedReader/IO/vtkMedUtilities.cxx +++ /dev/null @@ -1,890 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedUtilities.h" - -#include "vtkMedMesh.h" -#include "vtkMedFamily.h" -#include "vtkMedGroup.h" -#include "vtkMedFamilyOnEntityOnProfile.h" -#include "vtkMedFamilyOnEntity.h" -#include "vtkMedEntityArray.h" -#include "vtkMedIntArray.h" -#include "vtkMedGrid.h" - -#include "vtkObjectFactory.h" -#include "vtkInformation.h" -#include "vtkDoubleArray.h" -#include "vtkIntArray.h" -#include "vtkLongLongArray.h" -#include "vtkLongArray.h" -#include "vtkIdTypeArray.h" -#include "vtkCellType.h" -#include "vtkIdList.h" -#include "vtkMutableDirectedGraph.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkOutEdgeIterator.h" -#include "vtkInformationIntegerKey.h" -#include "vtkInformationStringVectorKey.h" -#include "vtkInformationObjectBaseKey.h" - -#include -using namespace std; -char vtkMedUtilities::Separator='/'; - -const char* vtkMedUtilities::NoGroupName="No Group"; -const char* vtkMedUtilities::OnPointName="OnPoint"; -const char* vtkMedUtilities::OnCellName="OnCell"; - -const int MED_TRIA_CHILD_TO_PARENT_INDEX[3][3]= - {{0, 1, 3}, {1, 2, 4}, {2, 0, 5}}; - -const int MED_QUAD_CHILD_TO_PARENT_INDEX[4][3]= - {{0, 1, 4}, {1, 2, 5}, {2, 3, 6}, {3, 0, 7}}; - -const int MED_TETRA_CHILD_TO_PARENT_INDEX[4][6]= - {{0, 1, 2, 4, 5, 6}, - {0, 3, 1, 7, 8, 4}, - {1, 3, 2, 8, 9, 5}, - {2, 3, 0, 9, 7, 6}}; - -const int MED_HEXA_CHILD_TO_PARENT_INDEX[6][8]= - {{0, 1, 2, 3, 8, 9, 10, 11}, - {4, 7, 6, 5, 15, 14, 13, 12}, - {0, 4, 5, 1, 16, 12, 17, 8}, - {1, 5, 6, 2, 17, 13, 18, 9}, - {2, 6, 7, 3, 18, 14, 19, 10}, - {3, 7, 4, 0, 19, 15, 16, 11}}; - -const int MED_PYRA_CHILD_TO_PARENT_INDEX[5][8]= - {{0, 1, 2, 3, 5, 6, 7, 8}, - {0, 4, 1, -1, 9, 10, 5, -1}, - {1, 4, 2, -1, 10, 11, 6, -1}, - {2, 4, 3, -1, 11, 12, 7, -1}, - {3, 4, 0, -1, 12, 9, 8, -1}}; - -const int MED_PENTA_CHILD_TO_PARENT_INDEX[5][8]= - {{0, 1, 2, -1, 6, 7, 8, -1}, - {3, 5, 4, -1, 11, 10, 9, -1}, - {0, 3, 4, 1, 12, 9, 13, 6}, - {1, 4, 5, 2, 13, 10, 14, 7}, - {2, 5, 3, 0, 14, 11, 12, 8}}; - -vtkInformationKeyMacro(vtkMedUtilities, ELNO, Integer); -vtkInformationKeyMacro(vtkMedUtilities, ELGA, Integer); -vtkInformationKeyMacro(vtkMedUtilities, BLOCK_NAME, StringVector); -vtkInformationKeyMacro(vtkMedUtilities, STRUCT_ELEMENT, ObjectBase); -vtkInformationKeyMacro(vtkMedUtilities, STRUCT_ELEMENT_INDEX, Integer); - -vtkDataArray* vtkMedUtilities::NewCoordArray() -{ - return vtkMedUtilities::NewArray(MED_FLOAT64); -} - -vtkDataArray* vtkMedUtilities::NewArray(med_field_type type) -{ - switch(type) - { - case MED_FLOAT64: - if(sizeof(double)==8 && sizeof(med_float)==8) - return vtkDoubleArray::New(); - vtkGenericWarningMacro("double type do not match med_float, aborting") - return NULL; - case MED_INT32: - if(sizeof(vtkIdType)==4) - return vtkIdTypeArray::New(); - if(sizeof(int)==4) - return vtkIntArray::New(); - if(sizeof(long)==4) - return vtkLongArray::New(); - vtkGenericWarningMacro("No vtk type matches MED_INT32, aborting") - return NULL; - case MED_INT64: - if(sizeof(vtkIdType)==8) - return vtkIdTypeArray::New(); - if(sizeof(long)==8) - return vtkLongArray::New(); - if(sizeof(long long)==8) - return vtkLongLongArray::New(); - vtkGenericWarningMacro("No vtk type matches MED_INT64, aborting") - ; - return NULL; - case MED_INT: - if(sizeof(med_int)==4) - return vtkMedUtilities::NewArray(MED_INT32); - if(sizeof(med_int)==8) - return vtkMedUtilities::NewArray(MED_INT64); - vtkGenericWarningMacro("No vtk type matches MED_INT, aborting") - return NULL; - default: - vtkGenericWarningMacro("the array type is not known, aborting.") - return NULL; - } -} - -vtkAbstractArray* vtkMedUtilities::NewArray(med_attribute_type type) -{ - switch(type) - { - case MED_ATT_FLOAT64 : - if(sizeof(double) == sizeof(med_float)) - return vtkDoubleArray::New(); - vtkGenericWarningMacro("double type do not match med_float, aborting"); - return NULL; - case MED_ATT_INT : - if(sizeof(vtkIdType) == sizeof(med_int)) - return vtkIdTypeArray::New(); - if(sizeof(int) == sizeof(med_int)) - return vtkIntArray::New(); - if(sizeof(long) == sizeof(med_int)) - return vtkLongArray::New(); - if(sizeof(long long) == sizeof(med_int)) - return vtkLongLongArray::New(); - vtkGenericWarningMacro("med_int type does not match known VTK type, aborting"); - return NULL; - case MED_ATT_NAME : - return vtkStringArray::New(); - } - return NULL; -} - -const char* vtkMedUtilities::GeometryName(med_geometry_type geometry) -{ - switch(geometry) - { - case MED_POINT1: - return "MED_POINT1"; - case MED_SEG2: - return "MED_SEG2"; - case MED_SEG3: - return "MED_SEG3"; - case MED_SEG4: - return "MED_SEG4"; - case MED_TRIA3: - return "MED_TRIA3"; - case MED_QUAD4: - return "MED_QUAD4"; - case MED_TRIA6: - return "MED_TRIA6"; - case MED_TRIA7: - return "MED_TRIA7"; - case MED_QUAD8: - return "MED_QUAD8"; - case MED_QUAD9: - return "MED_QUAD9"; - case MED_TETRA4: - return "MED_TETRA4"; - case MED_PYRA5: - return "MED_PYRA5"; - case MED_PENTA6: - return "MED_PENTA6"; - case MED_HEXA8: - return "MED_HEXA8"; - case MED_TETRA10: - return "MED_TETRA10"; - case MED_OCTA12: - return "MED_OCTA12"; - case MED_PYRA13: - return "MED_PYRA13"; - case MED_PENTA15: - return "MED_PENTA15"; - case MED_HEXA20: - return "MED_HEXA20"; - case MED_HEXA27: - return "MED_HEXA27"; - case MED_POLYGON: - return "MED_POLYGON"; - case MED_POLYHEDRON: - return "MED_POLYHEDRON"; - case MED_NO_GEOTYPE: - return "MED_NO_GEOTYPE"; - default: - return "UNKNOWN_GEOMETRY"; - } -} - -const char* vtkMedUtilities::EntityName(med_entity_type type) -{ - switch(type) - { - case MED_CELL: - return "MED_CELL"; - case MED_DESCENDING_FACE: - return "MED_DESCENDING_FACE"; - case MED_DESCENDING_EDGE: - return "MED_DESCENDING_EDGE"; - case MED_NODE: - return "MED_NODE"; - case MED_NODE_ELEMENT: - return "MED_NODE_ELEMENT"; - case MED_STRUCT_ELEMENT: - return "MED_STRUCT_ELEMENT"; - case MED_UNDEF_ENTITY_TYPE: - return "MED_UNDEF_ENTITY_TYPE"; - default: - return "UNKNOWN_ENTITY_TYPE "; - } -} - -const char* vtkMedUtilities::ConnectivityName(med_connectivity_mode conn) -{ - switch(conn) - { - case MED_NODAL: - return "MED_NODAL"; - case MED_DESCENDING: - return "MED_DESCENDING"; - case MED_NO_CMODE: - return "MED_NO_CMODE"; - default: - return "UNKNOWN_CONNECTIVITY_MODE"; - } -} - -const std::string vtkMedUtilities::SimplifyName(const char* medName) -{ - ostringstream sstr; - bool underscore=false; - bool space=false; - int l=strlen(medName); - for(int cc=0; cc(27 * floor((double)node / 27)); -} - -int vtkMedUtilities::GetNumberOfNodes(med_geometry_type geometry) -{ - switch(geometry) - { - case MED_POINT1: - return 1; - case MED_SEG2: - return 2; - case MED_SEG3: - return 3; - case MED_SEG4: - return 4; - case MED_TRIA3: - return 3; - case MED_QUAD4: - return 4; - case MED_TRIA6: - return 6; - case MED_TRIA7: - return 7; - case MED_QUAD8: - return 8; - case MED_QUAD9: - return 9; - case MED_TETRA4: - return 4; - case MED_PYRA5: - return 5; - case MED_PENTA6: - return 5; - case MED_HEXA8: - return 8; - case MED_TETRA10: - return 10; - case MED_OCTA12: - return 12; - case MED_PYRA13: - return 13; - case MED_PENTA15: - return 15; - case MED_HEXA20: - return 20; - case MED_HEXA27: - return 27; - case MED_POLYGON: - return -1; - case MED_POLYHEDRON: - return -1; - case MED_NO_GEOTYPE: - return 0; - default: - vtkGenericWarningMacro("No vtk type matches " - << vtkMedUtilities::GeometryName(geometry) - << ", aborting"); - return -1; - } -} - -int vtkMedUtilities::GetNumberOfSubEntity(med_geometry_type geometry) -{ - switch(geometry) - { - case MED_POINT1: - return 0; - case MED_SEG2: - return 2; - case MED_SEG3: - return 3; - case MED_SEG4: - return 4; - case MED_TRIA3: - return 3; - case MED_QUAD4: - return 4; - case MED_TRIA6: - return 3; - case MED_TRIA7: - return 3; - case MED_QUAD8: - return 4; - case MED_QUAD9: - return 4; - case MED_TETRA4: - return 4; - case MED_PYRA5: - return 5; - case MED_PENTA6: - return 5; - case MED_HEXA8: - return 6; - case MED_TETRA10: - return 4; - case MED_OCTA12: - return 8; - case MED_PYRA13: - return 5; - case MED_PENTA15: - return 5; - case MED_HEXA20: - return 6; - case MED_HEXA27: - return 6; - case MED_POLYGON: - return -1; - case MED_POLYHEDRON: - return -1; - case MED_NO_GEOTYPE: - return 0; - default: - vtkGenericWarningMacro("No vtk type matches " - << geometry - << ", aborting"); - return -1; - } -} - -med_entity_type vtkMedUtilities::GetSubType(med_entity_type type) -{ - switch(type) - { - case MED_CELL: - return MED_DESCENDING_FACE; - case MED_DESCENDING_FACE: - return MED_DESCENDING_EDGE; - case MED_DESCENDING_EDGE: - return MED_NODE; - default: - return MED_NODE; - } -} - -med_geometry_type vtkMedUtilities::GetSubGeometry( - med_geometry_type geometry, int index) -{ - switch(geometry) - { - case MED_SEG2: - return MED_POINT1; - case MED_SEG3: - return MED_POINT1; - case MED_SEG4: - return MED_POINT1; - - case MED_TRIA3: - return MED_SEG2; - case MED_TRIA6: - return MED_SEG3; - case MED_TRIA7: - return MED_SEG3; - - case MED_QUAD4: - return MED_SEG2; - case MED_QUAD8: - return MED_SEG3; - case MED_QUAD9: - return MED_SEG3; - - case MED_TETRA4: - return MED_TRIA3; - case MED_TETRA10: - return MED_TRIA6; - - case MED_PYRA5: - { - if(index==0) - return MED_QUAD4; - return MED_TRIA3; - } - case MED_PYRA13: - { - if(index==0) - return MED_QUAD8; - else - return MED_TRIA6; - } - - case MED_PENTA6: - { - if(index==0||index==1) - return MED_TRIA3; - else - return MED_QUAD4; - } - case MED_PENTA15: - { - if(index==0||index==1) - return MED_TRIA6; - else - return MED_QUAD8; - } - - case MED_HEXA8: - return MED_QUAD4; - case MED_HEXA20: - return MED_QUAD8; - case MED_HEXA27: - return MED_QUAD9; - default: - return MED_NONE; - } -} - -int vtkMedUtilities::FormatPolyhedronForVTK( - vtkMedFamilyOnEntityOnProfile* foep, vtkIdType index, - vtkIdList* ids ) -{ - vtkMedEntityArray* array = foep->GetFamilyOnEntity()->GetEntityArray(); - vtkMedIntArray* conn = array->GetConnectivityArray(); - vtkMedIntArray* faceIndex = array->GetFaceIndex(); - vtkMedIntArray* nodeIndex = array->GetNodeIndex(); - med_int start = faceIndex->GetValue(index)-1; - med_int end = faceIndex->GetValue(index+1)-1; - - // The format for the Polyhedrons is: - //(numCellFaces, numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...) - ids->Reset(); - - if (array->GetConnectivity()==MED_NODAL) - { - ids->InsertNextId(end-start-1); - for (int ff = start; ffGetValue(ff)-1; - med_int fend = nodeIndex->GetValue(ff+1)-1; - ids->InsertNextId(fend-fstart); - for (med_int pt = fstart; ptGetVTKPointIndex(conn->GetValue(pt)-1); - if(realIndex < 0) - { - vtkGenericWarningMacro("this polyhedron is not on this profile"); - foep->SetValid(0); - return 0; - } - ids->InsertNextId(realIndex); - } - } - } - - if (array->GetConnectivity()==MED_DESCENDING) - { - ids->InsertNextId(end-start); - vtkSmartPointer subIds = vtkSmartPointer::New(); - - for (int i = 0 ; iGetSize(); i++) - { - int numPoints = - vtkMedUtilities::GetNumberOfSubEntity(nodeIndex->GetValue(i)); - ids->InsertNextId(numPoints); - - vtkMedEntity entity; - entity.EntityType = MED_DESCENDING_FACE; - entity.GeometryType = nodeIndex->GetValue(i); - - vtkMedEntityArray* theFaces = - array->GetParentGrid()->GetEntityArray(entity); - - theFaces->GetCellVertices(conn->GetValue(i)-1, subIds); - - for (int j = 0 ; j< numPoints; j++) - { - vtkIdType realIndex = foep->GetVTKPointIndex(subIds->GetId(j)); - if(realIndex < 0) - { - vtkGenericWarningMacro("this polyhedron is not on this profile"); - return 0; - } - ids->InsertNextId(realIndex); - } - } - } - return 1; -} - -void vtkMedUtilities::SplitGroupKey(const char* name, std::string& mesh, - std::string& entity, std::string& group) -{ - std::string remain; - remain=name; - mesh="*"; - entity="*"; - group="*"; - std::string header="*"; - - if(remain=="*") - { - return; - } - std::string::size_type pos; - // First get the header, which must be "GROUP" - pos=remain.find_first_of(vtkMedUtilities::Separator); - header=remain.substr(0, pos); - remain=remain.substr(pos+1, remain.size()-pos-1); - - // then get the mesh name - pos=remain.find_first_of(vtkMedUtilities::Separator); - mesh=remain.substr(0, pos); - if(mesh=="*"||pos==remain.size()-1) - return; - remain=remain.substr(pos+1, remain.size()-pos-1); - - // then the entity name (OnPoint or OnCell) - pos=remain.find_first_of(vtkMedUtilities::Separator); - entity=remain.substr(0, pos); - if(entity=="*"||pos==remain.size()-1) - return; - - // then the group - group=remain.substr(pos+1, remain.size()-pos-1); -} - -int vtkMedUtilities::GetParentNodeIndex(med_geometry_type parentGeometry, - int subEntityIndex, int subEntityNodeIndex) -{ - switch(parentGeometry) - { - case MED_TRIA3: - case MED_TRIA6: - case MED_TRIA7: - return MED_TRIA_CHILD_TO_PARENT_INDEX[subEntityIndex][subEntityNodeIndex]; - case MED_QUAD4: - case MED_QUAD8: - case MED_QUAD9: - return MED_QUAD_CHILD_TO_PARENT_INDEX[subEntityIndex][subEntityNodeIndex]; - case MED_TETRA4: - case MED_TETRA10: - return MED_TETRA_CHILD_TO_PARENT_INDEX[subEntityIndex][subEntityNodeIndex]; - case MED_PYRA5: - case MED_PYRA13: - return MED_PYRA_CHILD_TO_PARENT_INDEX[subEntityIndex][subEntityNodeIndex]; - case MED_PENTA6: - case MED_PENTA15: - return MED_PENTA_CHILD_TO_PARENT_INDEX[subEntityIndex][subEntityNodeIndex]; - case MED_HEXA8: - case MED_HEXA20: - case MED_HEXA27: - return MED_HEXA_CHILD_TO_PARENT_INDEX[subEntityIndex][subEntityNodeIndex]; - } - return -1; -} - -void vtkMedUtilities::ProjectConnectivity(med_geometry_type parentGeometry, - vtkIdList* parentIds, vtkIdList* subEntityIds, int subEntityIndex, bool invert) -{ - for(int subEntityNodeIndex=0; subEntityNodeIndex - GetNumberOfIds(); subEntityNodeIndex++) - { - int realIndex = subEntityNodeIndex; - if(invert) - realIndex = subEntityIds->GetNumberOfIds() - subEntityNodeIndex - 1; - parentIds->SetId(GetParentNodeIndex(parentGeometry, subEntityIndex, - subEntityNodeIndex), subEntityIds->GetId(realIndex)); - } -} - -std::string vtkMedUtilities::GetModeKey(int index, double frequency, int maxindex) -{ - std::ostringstream key; - key<<"["; - if(maxindex > 0) - { - int maxdecim = (int)floor(log(1.0*maxindex)/log(10.0)); - int decim = 0; - if(index > 0) - { - decim = (int)floor(log(1.0*index)/log(10.0)); - } - for(int i=decim; i>index; - const string freq_string=k.substr(index_end+1, string::npos); - stringstream freqsstr; - freqsstr<>frequency; - return 1; -} - -vtkMultiBlockDataSet* vtkMedUtilities::GetParent(vtkMultiBlockDataSet* root, - vtkStringArray* path) -{ - vtkMultiBlockDataSet* output=root; - vtkMultiBlockDataSet* parent=output; - for(int depth = 0; depthGetNumberOfValues(); depth++) - { - vtkStdString parentName = path->GetValue(depth); - bool found=false; - for(int blockId=0; blockIdGetNumberOfBlocks(); blockId++) - { - vtkInformation* metaData=parent->GetMetaData(blockId); - if(metaData->Has(vtkCompositeDataSet::NAME())) - { - const char* blockName=metaData->Get(vtkCompositeDataSet::NAME()); - if(parentName==blockName && - vtkMultiBlockDataSet::SafeDownCast( - parent->GetBlock(blockId))!=NULL) - { - parent=vtkMultiBlockDataSet::SafeDownCast(parent->GetBlock(blockId)); - found=true; - break; - } - } - } - if (!found) - { - // If I am here, it means that I did not find any block with the good name, create one - int nb=parent->GetNumberOfBlocks(); - vtkMultiBlockDataSet* block=vtkMultiBlockDataSet::New(); - parent->SetBlock(nb, block); - block->Delete(); - parent->GetMetaData(nb)->Set(vtkCompositeDataSet::NAME(), - parentName.c_str()); - parent=block; - } - } - return parent; -} - -int vtkMedUtilities::SizeOf(med_attribute_type type) -{ - switch(type) - { - case MED_ATT_FLOAT64 : return sizeof(med_float); - case MED_ATT_INT : return sizeof(med_int); - case MED_ATT_NAME : return MED_NAME_SIZE * sizeof(char); - } - return 0; -} - -bool operator==(const vtkMedComputeStep& cs0, const vtkMedComputeStep& cs1) -{ - return cs0.IterationIt == cs1.IterationIt && cs0.TimeIt == cs1.TimeIt; -} - -bool operator!=(const vtkMedComputeStep& cs0, const vtkMedComputeStep& cs1) -{ - return cs0.IterationIt != cs1.IterationIt || cs0.TimeIt != cs1.TimeIt; -} - -bool operator<(const vtkMedComputeStep& cs0, const vtkMedComputeStep& cs1) -{ - if(cs0.IterationIt != cs1.IterationIt) - return cs0.IterationIt < cs1.IterationIt; - return cs0.TimeIt < cs1.TimeIt; -} - -bool operator==(const vtkMedEntity& e0, const vtkMedEntity& e1) -{ - return e0.EntityType == e1.EntityType && e0.GeometryType == e1.GeometryType; -} - -bool operator!=(const vtkMedEntity& e0, const vtkMedEntity& e1) -{ - return e0.EntityType != e1.EntityType || e0.GeometryType != e1.GeometryType; -} - -bool operator<(const vtkMedEntity& e0, const vtkMedEntity& e1) -{ - if(e0.EntityType != e1.EntityType) - return e0.EntityType < e1.EntityType; - return e0.GeometryType < e1.GeometryType; -} diff --git a/src/Plugins/MedReader/IO/vtkMedUtilities.h b/src/Plugins/MedReader/IO/vtkMedUtilities.h deleted file mode 100644 index 6d4e1671..00000000 --- a/src/Plugins/MedReader/IO/vtkMedUtilities.h +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _vtkMedUtilities_h_ -#define _vtkMedUtilities_h_ - -#include "vtkObject.h" -#include "vtkSmartPointer.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkStringArray.h" -#include "vtkMedSetGet.h" -#include "vtkMed.h" -#include "vtkMedReader.h" - -#include -#include -#include -#include -#include -#include - -class vtkDataArray; -class vtkMedMesh; -class vtkMedFamily; -class vtkMedGroup; -class vtkIdList; -class vtkMutableDirectedGraph; -class vtkInformationIntegerKey; -class vtkInformationObjectBaseKey; - -//BTX -class vtkMedComputeStep -{ -public : - med_int IterationIt; - med_int TimeIt; - med_float TimeOrFrequency; - - vtkMedComputeStep() - { - this->IterationIt = MED_NO_IT; - this->TimeIt = MED_NO_DT; - this->TimeOrFrequency = MED_UNDEF_DT; - } -}; - -bool operator==(const vtkMedComputeStep& cs0, const vtkMedComputeStep& cs1); -bool operator!=(const vtkMedComputeStep& cs0, const vtkMedComputeStep& cs1); -bool operator<(const vtkMedComputeStep& cs0, const vtkMedComputeStep& cs1); - -class vtkMedEntity -{ -public : - - vtkMedEntity() : EntityType(MED_NODE), - GeometryType(MED_NONE) - { - } - - vtkMedEntity(med_entity_type type, med_geometry_type geometry) : - EntityType(type), - GeometryType(geometry) - { - } - - ~vtkMedEntity() - { - } - - vtkMedEntity(const vtkMedEntity& entity) : - EntityType(entity.EntityType), - GeometryType(entity.GeometryType) - { - this->GeometryName = entity.GeometryName; - } - - void operator=(const vtkMedEntity& entity) - { - this->EntityType = entity.EntityType; - this->GeometryType = entity.GeometryType; - this->GeometryName = entity.GeometryName; - } - - med_entity_type EntityType; - med_geometry_type GeometryType; - std::string GeometryName; -}; - -bool operator==(const vtkMedEntity& cs0, const vtkMedEntity& cs1); -bool operator!=(const vtkMedEntity& cs0, const vtkMedEntity& cs1); -bool operator<(const vtkMedEntity& cs0, const vtkMedEntity& cs1); -//ETX - -class VTK_EXPORT vtkMedUtilities -{ -public: - static vtkInformationIntegerKey* ELNO(); - static vtkInformationIntegerKey* ELGA(); - static vtkInformationStringVectorKey* BLOCK_NAME(); - static vtkInformationObjectBaseKey* STRUCT_ELEMENT(); - static vtkInformationIntegerKey* STRUCT_ELEMENT_INDEX(); - - // Description: - // return an array to store the coordinates of nodes. - // the type of the elements is the same as the one in the med file - static vtkDataArray* NewCoordArray(); - - // Description: - // returns an array to store data of a given type. - // the type corresponds to med types. - static vtkDataArray* NewArray(med_field_type type); - static vtkAbstractArray* NewArray(med_attribute_type type); - - //BTX - enum - { - OnPoint, OnCell - }; - //ETX - - //BTX - // Description: - // returns a name for the given med_geometry_type - static const char* GeometryName(med_geometry_type geometry); - - // Description: - // returns a name for the given med_geometry_type - static const char* EntityName(med_entity_type type); - - // Description: - // returns a name for the given med_connectivity_mode - static const char* ConnectivityName(med_connectivity_mode conn); - - static const std::string SimplifyName(const char* medName); - - static const std::string FamilyKey(const char* meshName, int pointOrCell, - const char* familyName); - static const std::string GroupKey(const char* meshName, int pointOrCell, - const char* groupName); - - static const std::string EntityKey(const vtkMedEntity&); - - static int GetNumberOfPoint(med_geometry_type geometry); - static int GetDimension(med_geometry_type geometry); - - // returns the VTK cell type (as described in the vtkCellType.h file) - // corresponding to the given med_geometry_type - static int GetVTKCellType(med_geometry_type geometry); - - // returns the number of sub entity : the number of faces for cells, - // the number of edges for faces, the number of nodes for edges - static int GetNumberOfSubEntity(med_geometry_type geometry); - - // returns the number of Nodes - static int GetNumberOfNodes(med_geometry_type geometry); - //ETX - - static med_entity_type GetSubType(med_entity_type type); - static med_geometry_type GetSubGeometry(med_geometry_type geometry, - int index); - - static int GetParentNodeIndex(med_geometry_type parentGeometry, - int subEntityIndex, int subEntityNodeIndex); - - // Description : - // Project the ids gathered in the sub entity to the parent entity. - // used for MED_DESC connectivity. - // Rem : no check is performed, and do not work for - // MED_POLYHEDRE and MED_POLYGON - static void ProjectConnectivity(med_geometry_type parentGeometry, - vtkIdList* parentIds, vtkIdList* subEntityIds, int subEntityIndex, - bool invert); - - static char Separator; - - static const char* NoGroupName; - static const char* OnCellName; - static const char* OnPointName; - - //BTX - static void SplitGroupKey(const char* name, /*vtkstd::*/std::string& mesh, - /*vtkstd::*/std::string& entity, /*vtkstd::*/std::string& group); - - static std::string GetModeKey(int index, double frequency, int maxindex); - static int GetModeFromKey(const char*, int& index, double& frequency); - - static int MedToVTKIndex(int vtktype, int node); - - static vtkMultiBlockDataSet* GetParent(vtkMultiBlockDataSet* root, - vtkStringArray* path); - - // Description: - // Format the id list so that it respects the VTK format for polyhedrons : - // numfaces, npts_face0, pt0, ... npts_face1, pt1 .... - static int FormatPolyhedronForVTK(vtkMedFamilyOnEntityOnProfile*, - vtkIdType, vtkIdList*); - - static int SizeOf(med_attribute_type type); - //ETX -}; - -//BTX - -template -class vtkObjectVector: public std::vector > -{ -}; - -template -class vtkMedComputeStepMap: public - std::map > > -{ -public : - void AddObject(const vtkMedComputeStep& cs, T* obj) - { - (*this)[cs.TimeIt][cs.IterationIt] = obj; - this->TimeIt[cs.TimeOrFrequency] = cs.TimeIt; - } - - T* GetObject(const vtkMedComputeStep& cs) - { - if(this->find(cs.TimeIt) == this->end()) - return NULL; - - std::map >& itmap = (*this)[cs.TimeIt]; - - if(itmap.find(cs.IterationIt) == itmap.end()) - return NULL; - - return itmap[cs.IterationIt]; - } - - med_int GetNumberOfObject() - { - med_int nb = 0; - typename vtkMedComputeStepMap::iterator it = this->begin(); - while(it != this->end()) - { - nb += it->second.size(); - it++; - } - return nb; - } - - T* GetObject(med_int id) - { - med_int nb = 0; - if(id < 0) - return NULL; - - typename vtkMedComputeStepMap::iterator it = this->begin(); - while(it != this->end()) - { - std::map >& itmap = it->second; - nb += itmap.size(); - if(id < nb) - { - typename std::map >::iterator iterationit = - itmap.begin(); - for(int ii=0; iisecond; - } - it++; - } - return NULL; - } - - T* FindObject(const vtkMedComputeStep& cs, int strategy) - { - // first test if the given compute step is present - T* obj = this->GetObject(cs); - if(obj != NULL) - return obj; - - if(this->size() == 0) - return NULL; - - // let us first find the iterator that corresponds to the given time - med_int timeit = this->FindTimeIterator(cs.TimeOrFrequency, cs.TimeIt); - - std::map >& itmap = - (*this)[timeit]; - - if(itmap.size() == 0) - return NULL; - - if(strategy == vtkMedReader::PhysicalTime - || strategy == vtkMedReader::Modes) - { - // in this strategies, we return the last iteration for each time. - return itmap.rbegin()->second; - } - else if(strategy == vtkMedReader::Iteration) - { - // in this case, we look for the real iteration - typename std::map >::iterator iterationit - = itmap.lower_bound(cs.IterationIt); - - // if this is not exactly the same step and if this is not the first - // step, rool back one step to choose the one just before the asked time. - if(iterationit->first != cs.IterationIt && iterationit != itmap.begin()) - iterationit--; - - // the time iterator asked for is higher than all times, - // let us pick the last one. - if(iterationit == itmap.end()) - iterationit--; - - return iterationit->second; - } - } - - void GatherTimes(std::set& times) - { - typename std::map::iterator it - = this->TimeIt.begin(); - while(it != this->TimeIt.end()) - { - times.insert(it->first); - it++; - } - } - - void GatherIterations(med_float time, std::set& iterations) - { - med_int timeit = this->FindTimeIterator(time, -1); - if(timeit == -1) - return; - - std::map >& itmap = - (*this)[timeit]; - - typename std::map >::iterator it = - itmap.begin(); - - while(it != itmap.end()) - { - iterations.insert(it->first); - it++; - } - } - -protected : - - med_int FindTimeIterator(med_float time, med_int defaultit) - { - if(this->TimeIt.size() == 0) - return defaultit; - - typename std::map::iterator it - = this->TimeIt.lower_bound(time); - - // if this is not exactly the same step and if this is not the first step, - // rool back one step to choose the one just before the asked time. - if(it->first != time && it != this->TimeIt.begin()) - it--; - - // if the time iterator asked for is higher than all times, - // let us pick the last one. - if(it == this->TimeIt.end()) - it--; - - return it->second; - } - - std::map TimeIt; -}; - -template -class vtkList: public std::list -{ -}; - -template -struct IsSameTraits -{ - static const bool IsSame() - { - return false; - } -}; - -template -struct IsSameTraits -{ - static const bool IsSame() - { - return true; - } -}; - -#define PRINT_IVAR(os, indent, name) \ - os << indent << #name << " : " << name << endl; - -#define PRINT_STRING(os, indent, name) \ - os << indent << #name << " : " << ( name ? name : "(void)") << endl; - -#define PRINT_OBJECT(os, indent, name) \ - os << indent << #name << " : " ;\ - if(name != NULL) \ - {\ - os << endl;\ - name->PrintSelf(os, indent.GetNextIndent());\ - }\ - else os << "(NULL)" << endl; - -#define PRINT_VECTOR(os, indent, name, size) \ -{\ - os << indent << #name << " : (";\ - for(vtkIdType _index = 0; _indexsize();\ - for(vtkIdType _index = 0; _index < _size; _index++)\ - {\ - os << indent << #name << _index << " : " << endl;\ - if(name->at(_index) != NULL)\ - name->at(_index)->PrintSelf(os, indent.GetNextIndent());\ - else\ - os << indent.GetNextIndent() << "(NULL)" << endl;\ - }\ -} - -#define PRINT_STRING_VECTOR(os, indent, name)\ -{\ - os << indent << #name << ": ";\ - for(int _comp = 0; _compname->size(); _comp++)\ - {\ - os << this->name->at(_comp)->GetString();\ - if(_comp < this->name->size()-1)\ - os << ", ";\ - }\ - os << endl;\ -} - -#define PRINT_MED_STRING(os, indent, name)\ - os << indent << #name << ": " << this->name->GetString() << endl; \ - -//ETX - -#endif diff --git a/src/Plugins/MedReader/IO/vtkMedVariableAttribute.cxx b/src/Plugins/MedReader/IO/vtkMedVariableAttribute.cxx deleted file mode 100644 index 7b025a45..00000000 --- a/src/Plugins/MedReader/IO/vtkMedVariableAttribute.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkMedVariableAttribute.h" - -#include "vtkObjectFactory.h" -#include "vtkMedUtilities.h" -#include "vtkMedStructElement.h" -#include "vtkMedFile.h" -#include "vtkMedDriver.h" - -#include -#include -#include -using namespace std; - -// vtkCxxRevisionMacro(vtkMedVariableAttribute, "$Revision$") -vtkStandardNewMacro(vtkMedVariableAttribute); - -vtkCxxSetObjectMacro(vtkMedVariableAttribute, ParentStructElement, vtkMedStructElement); - -vtkMedVariableAttribute::vtkMedVariableAttribute() -{ - this->Name = NULL; - this->AttributeType = MED_ATT_UNDEF; - this->NumberOfComponent = 0; - this->ParentStructElement = NULL; -} - -vtkMedVariableAttribute::~vtkMedVariableAttribute() -{ - this->SetName(NULL); - this->SetParentStructElement(NULL); -} - -void vtkMedVariableAttribute::Load(vtkMedEntityArray* array) -{ - this->GetParentStructElement()->GetParentFile()->GetMedDriver()->LoadVariableAttribute(this, array); -} - -void vtkMedVariableAttribute::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/IO/vtkMedVariableAttribute.h b/src/Plugins/MedReader/IO/vtkMedVariableAttribute.h deleted file mode 100644 index a7db7a32..00000000 --- a/src/Plugins/MedReader/IO/vtkMedVariableAttribute.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __vtkMedVariableAttribute_h_ -#define __vtkMedVariableAttribute_h_ - -#include "vtkObject.h" -#include "vtkMed.h" -#include "vtkMedSetGet.h" - -class vtkAbstractArray; -class vtkMedStructElement; -class vtkMedEntityArray; - -class VTK_EXPORT vtkMedVariableAttribute : public vtkObject -{ -public : - static vtkMedVariableAttribute* New(); - vtkTypeMacro(vtkMedVariableAttribute, vtkObject) - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // This is the name of this attribute - vtkSetStringMacro(Name); - vtkGetStringMacro(Name); - - // Description: - // The iterator in the med file of this constant attribute - vtkSetMacro(MedIterator, med_int); - vtkGetMacro(MedIterator, med_int); - - // Description: - // The Geometry type this structural elements lies on. - vtkSetMacro(AttributeType, med_attribute_type); - vtkGetMacro(AttributeType, med_attribute_type); - - // Description: - // The dimension of this structural elements model - vtkSetMacro(NumberOfComponent, med_int); - vtkGetMacro(NumberOfComponent, med_int); - - // Description: - // The Structural element on which lies this attribute - virtual void SetParentStructElement(vtkMedStructElement*); - vtkGetObjectMacro(ParentStructElement, vtkMedStructElement); - - // Description: - // Load the values associated with this attribute for the given entity array; - void Load(vtkMedEntityArray*); - -protected: - vtkMedVariableAttribute(); - virtual ~vtkMedVariableAttribute(); - - char *Name; - med_int MedIterator; - med_attribute_type AttributeType; - med_int NumberOfComponent; - - vtkMedStructElement* ParentStructElement; - -private: - vtkMedVariableAttribute(const vtkMedVariableAttribute&); // Not implemented. - void operator=(const vtkMedVariableAttribute&); // Not implemented. -}; - -#endif //__vtkMedVariableAttribute_h_ diff --git a/src/Plugins/MedReader/ParaViewPlugin/CMakeLists.txt b/src/Plugins/MedReader/ParaViewPlugin/CMakeLists.txt deleted file mode 100644 index 49f81b13..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/CMakeLists.txt +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# add include indirectories to the vtk files in this plugin. -include_directories( - ${MedReader_SOURCE_DIR}/IO - ${MedReader_BINARY_DIR}/IO) - - -SET(SM_SRCS - vtkSMMedGroupSelectionDomain.cxx - ) - -IF(PARAVIEW_BUILD_QT_GUI) - - QT4_WRAP_UI(CLIENT_UI_SRCS - Resources/UI/MedReaderPanel.ui - Resources/UI/ExtractGroupPanel.ui - ) - - # create a plugin that implements an object panel for the reader - SET(CLIENT_SRCS - pqMedReaderPanel.cxx - pqExtractGroupPanel.cxx - ) - - QT4_WRAP_CPP(MOC_SRCS - pqMedReaderPanel.h - pqExtractGroupPanel.h - ) - - ADD_PARAVIEW_OBJECT_PANEL(MEDREADER_IFACES MEDREADER_IFACE_SRCS - CLASS_NAME pqMedReaderPanel - XML_NAME MedReader - XML_GROUP sources - ) - - ADD_PARAVIEW_OBJECT_PANEL(EXTRACTGROUP_IFACES EXTRACTGROUP_IFACE_SRCS - CLASS_NAME pqExtractGroupPanel - XML_NAME ExtractGroup - XML_GROUP filters - ) - - # create the med reader plugin itself - ADD_PARAVIEW_PLUGIN(MedReaderPlugin "4.0" - SERVER_MANAGER_SOURCES ${SM_SRCS} - SERVER_MANAGER_XML Resources/MedReaderServer.xml - GUI_INTERFACES ${MEDREADER_IFACES} ${EXTRACTGROUP_IFACES} - GUI_RESOURCES Resources/pqMedReader.qrc - GUI_SOURCES ${CLIENT_SRCS} - ${CLIENT_UI_SRCS} - ${MOC_SRCS} - ${MEDREADER_IFACE_SRCS} - ${EXTRACTGROUP_IFACE_SRCS} - CS_KITS - # this is the same name as the name in module.cmake file IO - # directory. - vtkMedReader - ) - -ELSE(PARAVIEW_BUILD_QT_GUI) - - # create the med reader plugin itself - ADD_PARAVIEW_PLUGIN(MedReaderPlugin "4.0" - SERVER_MANAGER_SOURCES ${SM_SRCS} - SERVER_MANAGER_XML Resources/MedReaderServer.xml - CS_KITS - # this is the same name as the name in module.cmake file IO - # directory. - vtkMedReader - ) - -ENDIF(PARAVIEW_BUILD_QT_GUI) - -TARGET_LINK_LIBRARIES(MedReaderPlugin vtkMedReader vtkMedReaderCS) - -# Install -INSTALL( - TARGETS MedReaderPlugin - RUNTIME DESTINATION lib/paraview - LIBRARY DESTINATION lib/paraview - ARCHIVE DESTINATION lib/paraview -) - - - - diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderClient.xml b/src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderClient.xml deleted file mode 100644 index fccdf424..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderClient.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderServer.xml b/src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderServer.xml deleted file mode 100644 index 97a4e372..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/Resources/MedReaderServer.xml +++ /dev/null @@ -1,494 +0,0 @@ - - - - - - - - This property specifies the file name for the MED reader. - - - - - - - - - - - - - - - This property lists which cell-centered arrays to read. - - - - - - - - - - - - - - - This property lists which point-centered arrays to read. - - - - - - - - - - - - - - - This property lists which integration-point-centered arrays to read. - - - - - - - - - - - - - - - This property lists which integration-point-centered arrays to read. - - - - - - - - - - - - - - - This property can be used to select the cell types to load. - Example : ['MED_CELL/MED_TRIA3'] - - - - - - - - - - - - - - - - Set the groups on cells to be loaded. - Example : SetGroups(['GROUP/MAILLAGE/OnCell/GROUP_NAME', - 'GROUP/MAILLAGE/OnPoints/GROUP_NAME']). - - - - - - - - - - - - Information property indicating the update stamp of the SIL. Every - time the SIL is rebuild, this - time stamp is changed. - - - - - - - - - - - - The animation modes defines how the animation controls of ParaView - browse the computing steps available in the med file. - Default : It is the same as "Times" if there is any time defined - in the med file. - It is the same as "Iteration" if there is no times but iterations. - Times : The reader advertise the availbale times in the med file. - If there are multiple iterations for a given time, - the reader will load the last one. - Iterations : You also have to specify the TimeIndexForIterations - parameter. The reader will then advertise iterations at the given - time index. - Modes : This mode is made for modal analysis post-processing : all - selected frequencies (use the FrequencyArrayStatus property) - are loaded so that the user can easily switch from - a frequency to another. - The reader reports no time but a time range of -PI/PI. - - - - - - - - - - - - - - Available timestep values. - - - - - - - - - - - - - - - This property lists which frequencies are in the med file for - modal analysis. - - - - - - - - - - - Set the strategy to cache data read from the disk. - 0 : Nothing. The reader tries to minimize the memory footprint, - but will read data very often from the disk. Choose this if your - dataset is large and memory is an issue. - 1 : Geometry. The reader will cache the geometry, but not field - values. A each time change, field values will be re-read from - disk. Good if your dataset fits in memory but not your time steps. - 2 : All (Default). The reader will keep all the geometry and fields - read from disk over time. Choose this if memory is not an issue. - - - - - - - If this flag is set, the reader will generate a vector field for - each field in the file that has 2 or more components. - If the field has 2 components, a third compoenent with the value - 0 will be added. - If the field has more than 3 components, the first 3 components will - be extracted. - - - - - - - - - - - - - - - - - - - This property specifies the input to the Level Scalars filter. - - - - - - - - - - - - - - - This property can be used to select the cell types to load. - Example : ['MED_MAILLE/MED_TRIA3'] - - - - - - - - - - - - - - - - - Set the groups on cells to be loaded. - Example : SetGroups(['GROUP/MAILLAGE/OnCell/GROUP_NAME', - 'GROUP/MAILLAGE/OnPoints/GROUP_NAME']). - - - - - - - - - - - - Information property indicating the update stamp of the SIL. Every - time the SIL is rebuild, this - time stamp is changed. - - - - - - - If set to true, this filter will prune the empty parts in the output. - If not, empty datasets will be kept. - - - - - - - - - - - - - - - - This property specifies the input to the Generate Structural Element filter. - - - - - - diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui b/src/Plugins/MedReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui deleted file mode 100644 index 5913a23b..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/Resources/UI/ExtractGroupPanel.ui +++ /dev/null @@ -1,141 +0,0 @@ - - - ExtractGroupPanel - - - - 0 - 0 - 649 - 786 - - - - - 0 - 0 - - - - Form - - - - 9 - - - - - - 0 - 1 - - - - Supports - - - - 6 - - - 9 - - - - - true - - - 1 - - - - Group - - - - - - - 0 - 100 - - - - QAbstractItemView::ExtendedSelection - - - false - - - - - - - - Cell Type - - - - - - - 0 - 100 - - - - QAbstractItemView::ExtendedSelection - - - false - - - - - - - - - - - - - - Prune Output - - - true - - - - - - - - pqTreeView - QTreeView -
pqTreeView.h
-
-
- - - - - 10 - - - 10 - - - false - - - false - - - true - - -
diff --git a/src/Plugins/MedReader/ParaViewPlugin/Resources/UI/MedReaderPanel.ui b/src/Plugins/MedReader/ParaViewPlugin/Resources/UI/MedReaderPanel.ui deleted file mode 100644 index 4faaa550..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/Resources/UI/MedReaderPanel.ui +++ /dev/null @@ -1,286 +0,0 @@ - - - MedReaderPanel - - - - 0 - 0 - 649 - 839 - - - - - 0 - 0 - - - - Form - - - - 9 - - - - - - 0 - 1 - - - - Supports - - - - 6 - - - 9 - - - - - true - - - 1 - - - - Group - - - - - - - 0 - 100 - - - - QAbstractItemView::ExtendedSelection - - - false - - - - - - - - Cell Type - - - - - - - 0 - 100 - - - - QAbstractItemView::ExtendedSelection - - - false - - - - - - - - - - - - - - - 0 - 1 - - - - Fields - - - - 6 - - - 9 - - - - - - 0 - 100 - - - - false - - - - Variables - - - - - - - - Generate Vectors - - - - - - - - - - Qt::Vertical - - - - 0 - 40 - - - - - - - - Animation - - - - - - - - Animation Mode - - - - - - - - - - - - - - Time - - - - - - - - - - - - - 0 - 100 - - - - false - - - - Modes - - - - - - - - - - - Qt::Vertical - - - - 0 - 40 - - - - - - - - Cache - - - - - - - - Strategy - - - - - - - - - - - - - - - - pqTreeWidget - QTreeWidget -
pqTreeWidget.h
-
- - pqTreeView - QTreeView -
pqTreeView.h
-
-
- - - - - 10 - - - 10 - - - false - - - false - - - true - - -
diff --git a/src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.cxx b/src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.cxx deleted file mode 100644 index 6ee8bd42..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/pqExtractGroupPanel.cxx +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "pqExtractGroupPanel.h" -#include "ui_ExtractGroupPanel.h" - -#include "vtkProcessModule.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformation.h" -#include "vtkIntArray.h" -#include "vtkSMDoubleVectorProperty.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMStringVectorProperty.h" -#include "vtkSMProxy.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkPVSILInformation.h" -#include "vtkGraph.h" -#include "vtkSMPropertyHelper.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" - -#include "vtkMedUtilities.h" - -#include "pqTreeWidget.h" -#include "pqTreeWidgetItemObject.h" -#include "pqSMAdaptor.h" -#include "pqProxy.h" -#include "pqPropertyManager.h" -#include "pqSILModel.h" -#include "pqProxySILModel.h" -#include "pqTreeViewSelectionHelper.h" -#include "pqTreeWidgetSelectionHelper.h" -#include "pqPropertyLinks.h" - -#include - -class pqExtractGroupPanel::pqUI : public QObject, public Ui::ExtractGroupPanel -{ -public: - pqUI(pqExtractGroupPanel* p) : - QObject(p) - { - this->VTKConnect = vtkSmartPointer::New(); - this->SILUpdateStamp = -1; - } - - ~pqUI() - { - } - - pqSILModel SILModel; - vtkSmartPointer VTKConnect; - pqPropertyLinks Links; - pqProxySILModel* entityModel; - pqProxySILModel* groupModel; - int SILUpdateStamp; -}; - -pqExtractGroupPanel::pqExtractGroupPanel(pqProxy* object_proxy, QWidget* p) : - Superclass(object_proxy, p) -{ - this->UI = new pqUI(this); - this->UI->setupUi(this); - - pqProxySILModel* proxyModel; - - // connect groups to groupsRoot - proxyModel = new pqProxySILModel("GroupTree", &this->UI->SILModel); - proxyModel->setSourceModel(&this->UI->SILModel); - this->UI->Groups->setModel(proxyModel); - this->UI->Groups->setHeaderHidden(true); - - this->UI->groupModel = new pqProxySILModel("Groups", &this->UI->SILModel); - this->UI->groupModel->setSourceModel(&this->UI->SILModel); - - // connect cell types to "EntityRoot" - proxyModel = new pqProxySILModel("EntityTree", &this->UI->SILModel); - proxyModel->setSourceModel(&this->UI->SILModel); - this->UI->Entity->setModel(proxyModel); - this->UI->Entity->setHeaderHidden(true); - - this->UI->entityModel = new pqProxySILModel("Entity", &this->UI->SILModel); - this->UI->entityModel->setSourceModel(&this->UI->SILModel); - - this->updateSIL(); - - this->UI->Groups->header()->setStretchLastSection(true); - this->UI->Entity->header()->setStretchLastSection(true); - - this->linkServerManagerProperties(); - - QList treeWidgets = this->findChildren (); - foreach (pqTreeWidget* tree, treeWidgets) - { - new pqTreeWidgetSelectionHelper(tree); - } - - QList treeViews = this->findChildren (); - foreach (pqTreeView* tree, treeViews) - { - new pqTreeViewSelectionHelper(tree); - } - - this->connect(this->UI->groupModel, SIGNAL(valuesChanged()), - this, SLOT(setModified())); - this->connect(this->UI->entityModel, SIGNAL(valuesChanged()), - this, SLOT(setModified())); - - this->UI->tabWidget->setCurrentIndex(0); - - this->UI->VTKConnect->Connect(this->proxy(), - vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL())); - -} - -pqExtractGroupPanel::~pqExtractGroupPanel() -{ -} - -void pqExtractGroupPanel::linkServerManagerProperties() -{ - this->UI->Links.addPropertyLink(this->UI->groupModel, "values", - SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty( - "Groups")); - - this->UI->Links.addPropertyLink(this->UI->entityModel, "values", - SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty( - "Entity")); - - this->Superclass::linkServerManagerProperties(); - -} - -void pqExtractGroupPanel::updateSIL() -{ -/* VSR???????? -//<<<<<<< HEAD:ParaViewPlugin/pqExtractGroupPanel.cxx - - this->proxy()->UpdatePropertyInformation( - this->proxy()->GetProperty("SILUpdateStamp")); -//======= -//>>>>>>> medparallel:ParaViewPlugin/pqExtractGroupPanel.cxx -*/ - vtkSMProxy* reader = this->referenceProxy()->getProxy(); - reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp")); - - int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt(); - if (stamp != this->UI->SILUpdateStamp) - { - this->UI->SILUpdateStamp = stamp; - vtkPVSILInformation* info = vtkPVSILInformation::New(); - reader->GatherInformation(info); - this->UI->SILModel.update(info->GetSIL()); - - this->UI->Groups->expandAll(); - this->UI->Entity->expandAll(); - - info->Delete(); - } - -} diff --git a/src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.cxx b/src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.cxx deleted file mode 100644 index 037183ba..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/pqMedReaderPanel.cxx +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "pqMedReaderPanel.h" -#include "ui_MedReaderPanel.h" - -#include "vtkProcessModule.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformation.h" -#include "vtkIntArray.h" -#include "vtkSMDoubleVectorProperty.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMStringVectorProperty.h" -#include "vtkSMProxy.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkPVSILInformation.h" -#include "vtkGraph.h" -#include "vtkSMPropertyHelper.h" -#include "vtkStringArray.h" -#include "vtkDataSetAttributes.h" -#include "vtkMedReader.h" - -#include "vtkMedUtilities.h" - -#include "pqTreeWidgetItemObject.h" -#include "pqSMAdaptor.h" -#include "pqProxy.h" -#include "pqPropertyManager.h" -#include "pqSILModel.h" -#include "pqProxySILModel.h" -#include "pqTreeViewSelectionHelper.h" -#include "pqTreeWidgetSelectionHelper.h" -#include "pqPropertyLinks.h" - -#include - -class pqMedReaderPanel::pqUI: public QObject, public Ui::MedReaderPanel -{ -public: - pqUI(pqMedReaderPanel* p) : - QObject(p) - { - this->VTKConnect = vtkSmartPointer::New(); - this->SILUpdateStamp = -1; - } - - ~pqUI() - { - } - - pqSILModel SILModel; - vtkSmartPointer VTKConnect; - pqPropertyLinks Links; - QMap TreeItemToPropMap; - pqProxySILModel* entityModel; - pqProxySILModel* groupModel; - int SILUpdateStamp; -}; - -pqMedReaderPanel::pqMedReaderPanel(pqProxy* object_proxy, QWidget* p) : - Superclass(object_proxy, p) -{ - this->UI = new pqUI(this); - this->UI->setupUi(this); - - pqProxySILModel* proxyModel; - - // connect groups to groupsRoot - proxyModel = new pqProxySILModel("GroupTree", &this->UI->SILModel); - proxyModel->setSourceModel(&this->UI->SILModel); - this->UI->Groups->setModel(proxyModel); - this->UI->Groups->setHeaderHidden(true); - - this->UI->groupModel = new pqProxySILModel("Groups", &this->UI->SILModel); - this->UI->groupModel->setSourceModel(&this->UI->SILModel); - - // connect cell types to "EntityRoot" - proxyModel = new pqProxySILModel("EntityTree", &this->UI->SILModel); - proxyModel->setSourceModel(&this->UI->SILModel); - this->UI->Entity->setModel(proxyModel); - this->UI->Entity->setHeaderHidden(true); - - this->UI->entityModel = new pqProxySILModel("Entity", &this->UI->SILModel); - this->UI->entityModel->setSourceModel(&this->UI->SILModel); - - this->updateSIL(); - - this->UI->Groups->header()->setStretchLastSection(true); - this->UI->Entity->header()->setStretchLastSection(true); - - this->linkServerManagerProperties(); - - QList treeWidgets = this->findChildren (); - foreach (pqTreeWidget* tree, treeWidgets) - { - new pqTreeWidgetSelectionHelper(tree); - } - - QList treeViews = this->findChildren (); - foreach (pqTreeView* tree, treeViews) - { - new pqTreeViewSelectionHelper(tree); - } - - this->connect(this->UI->groupModel, SIGNAL(valuesChanged()), - this, SLOT(setModified())); - this->connect(this->UI->entityModel, SIGNAL(valuesChanged()), - this, SLOT(setModified())); - this->connect(this->UI->TimeCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(setModified())); - this->connect(this->UI->GenerateVectors, SIGNAL(stateChanged(int)), - this, SLOT(setModified())); - - this->UI->tabWidget->setCurrentIndex(0); - - this->UI->VTKConnect->Connect(this->proxy(), - vtkCommand::UpdateInformationEvent, this, SLOT(updateSIL())); -} - -pqMedReaderPanel::~pqMedReaderPanel() -{ -} - -void pqMedReaderPanel::addSelectionsToTreeWidget(const QString& prop, - QTreeWidget* tree, PixmapType pix) -{ - vtkSMProperty* SMProperty = this->proxy()->GetProperty(prop.toAscii().data()); - QList SMPropertyDomain; - SMPropertyDomain = pqSMAdaptor::getSelectionPropertyDomain(SMProperty); - int j; - for(j = 0; j < SMPropertyDomain.size(); j++) - { - QString varName = SMPropertyDomain[j].toString(); - this->addSelectionToTreeWidget(varName, varName, tree, pix, prop, j); - } -} - -void pqMedReaderPanel::addSelectionToTreeWidget(const QString& name, - const QString& realName, QTreeWidget* tree, PixmapType pix, - const QString& prop, int propIdx) -{ - static QPixmap pixmaps[] = { - QPixmap(":/ParaViewResources/Icons/pqPointData16.png"), - QPixmap(":/ParaViewResources/Icons/pqCellData16.png"), - QPixmap(":/ParaViewResources/Icons/pqQuadratureData16.png"), - QPixmap(":/ParaViewResources/Icons/pqElnoData16.png") }; - - vtkSMProperty* SMProperty = this->proxy()->GetProperty(prop.toAscii().data()); - - if(!SMProperty || !tree) - { - return; - } - - QList strs; - strs.append(name); - pqTreeWidgetItemObject* item; - item = new pqTreeWidgetItemObject(tree, strs); - item->setData(0, Qt::ToolTipRole, name); - if(pix >= 0) - { - item->setData(0, Qt::DecorationRole, pixmaps[pix]); - } - item->setData(0, Qt::UserRole, QString("%1 %2").arg((int) pix).arg(realName)); - this->propertyManager()->registerLink(item, "checked", - SIGNAL(checkedStateChanged(bool)), this->proxy(), SMProperty, propIdx); - - this->UI->TreeItemToPropMap[item] = prop; -} - -void pqMedReaderPanel::linkServerManagerProperties() -{ - this->UI->Links.addPropertyLink(this->UI->groupModel, "values", - SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty( - "Groups")); - - this->UI->Links.addPropertyLink(this->UI->entityModel, "values", - SIGNAL(valuesChanged()), this->proxy(), this->proxy()->GetProperty( - "Entity")); - - this->UI->Links.addPropertyLink(this->UI->GenerateVectors, "checked", - SIGNAL(toggled(bool)), this->proxy(), this->proxy()->GetProperty( - "GenerateVectors")); - - this->Superclass::linkServerManagerProperties(); - - // do the point variables - this->addSelectionsToTreeWidget("PointFieldsArrayStatus", - this->UI->Variables, PM_POINT); - // do the cell variables - this->addSelectionsToTreeWidget("CellFieldsArrayStatus", this->UI->Variables, - PM_CELL); - // do the quadrature variables - this->addSelectionsToTreeWidget("QuadratureFieldsArrayStatus", - this->UI->Variables, PM_QUADRATURE); - - // do the Elno variables - this->addSelectionsToTreeWidget("ElnoFieldsArrayStatus", - this->UI->Variables, PM_ELNO); - this->setupAnimationModeWidget(); -} - -void pqMedReaderPanel::setupAnimationModeWidget() -{ - this->UI->AnimationModeCombo->clear(); - QList modes = pqSMAdaptor::getEnumerationPropertyDomain( - this->proxy()->GetProperty("AnimationMode")); - for(int mode = 0; mode < modes.size(); mode++) - { - QString modeName = modes[mode].toString(); - this->UI->AnimationModeCombo->addItem(modeName); - } - - this->UI->Links.addPropertyLink(this->UI->AnimationModeCombo, "currentIndex", - SIGNAL(currentIndexChanged(int)), this->proxy(), - this->proxy()->GetProperty("AnimationMode")); - - this->connect(this->UI->AnimationModeCombo, - SIGNAL(currentIndexChanged(int)), this, SLOT(animationModeChanged(int))); - - this->UI->Links.addPropertyLink(this->UI->TimeCombo, "currentIndex", - SIGNAL(currentIndexChanged(int)), this->proxy(), - this->proxy()->GetProperty("TimeIndexForIterations")); - - this->addSelectionsToTreeWidget("FrequencyArrayStatus", - this->UI->Modes, PM_NONE); - - vtkSMPropertyHelper helper(this->proxy(), "AnimationMode"); - int mode = helper.GetAsInt(0); - this->animationModeChanged(mode); - this->updateAvailableTimes(); -} - -void pqMedReaderPanel::animationModeChanged(int mode) -{ - if(mode == vtkMedReader::Default || mode == vtkMedReader::PhysicalTime) - { - this->UI->TimeCombo->hide(); - this->UI->TimeLabel->hide(); - this->UI->Modes->hide(); - } - else if(mode == vtkMedReader::Iteration) - { - this->UI->TimeCombo->show(); - this->UI->TimeLabel->show(); - this->UI->Modes->hide(); - } - else // vtkMedReader::Modes - { - this->UI->TimeCombo->hide(); - this->UI->TimeLabel->hide(); - this->UI->Modes->show(); - } - vtkSMPropertyHelper(this->proxy(), "AnimationMode").Set(mode); - this->proxy()->UpdateVTKObjects(); - this->setModified(); -} - -void pqMedReaderPanel::updateAvailableTimes() -{ - vtkSMDoubleVectorProperty* prop = vtkSMDoubleVectorProperty::SafeDownCast( - this->proxy()->GetProperty("AvailableTimes")); - - this->proxy()->UpdatePropertyInformation(prop); - - //prop->GetInformationHelper()->UpdateProperty( - // vtkProcessModuleConnectionManager::GetRootServerConnectionID(), - // vtkProcessModule::DATA_SERVER, - // this->proxy()->GetID(), - // prop); - - this->UI->TimeCombo->clear(); - double *aux = prop->GetElements(); - - for(int tid = 0; tid < prop->GetNumberOfElements(); tid++) - { - this->UI->TimeCombo->addItem( QString::number(aux[tid]) ); - } - -} - -void pqMedReaderPanel::updateSIL() -{ - vtkSMProxy* reader = this->referenceProxy()->getProxy(); - reader->UpdatePropertyInformation(reader->GetProperty("SILUpdateStamp")); - - int stamp = vtkSMPropertyHelper(reader, "SILUpdateStamp").GetAsInt(); - if (stamp != this->UI->SILUpdateStamp) - { - this->UI->SILUpdateStamp = stamp; - vtkPVSILInformation* info = vtkPVSILInformation::New(); - reader->GatherInformation(info); - this->UI->SILModel.update(info->GetSIL()); - - this->UI->Groups->expandAll(); - this->UI->Entity->expandAll(); - - info->Delete(); - } - - /* - this->proxy()->UpdatePropertyInformation( - this->proxy()->GetProperty("SILUpdateStamp")); - - int stamp = vtkSMPropertyHelper(this->proxy(), "SILUpdateStamp").GetAsInt(); - if(stamp != this->UI->SILUpdateStamp) - { - this->UI->SILUpdateStamp = stamp; - - vtkProcessModule* pm = vtkProcessModule::GetProcessModule(); - vtkPVSILInformation* info = vtkPVSILInformation::New(); - pm->GatherInformation(this->proxy()->GetConnectionID(), - vtkProcessModule::DATA_SERVER, info, this->proxy()->GetID()); - - this->UI->SILModel.update(info->GetSIL()); - - this->UI->Groups->expandAll(); - this->UI->Entity->expandAll(); - - info->Delete(); - }*/ -} diff --git a/src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.cxx b/src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.cxx deleted file mode 100644 index 35e4fa28..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.cxx +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "vtkSMMedGroupSelectionDomain.h" - -#include "vtkObjectFactory.h" -#include "vtkSMStringVectorProperty.h" -#include "vtkStringList.h" - -#include -using std::string; - -vtkStandardNewMacro(vtkSMMedGroupSelectionDomain); - -vtkSMMedGroupSelectionDomain::vtkSMMedGroupSelectionDomain() -{ -} - -vtkSMMedGroupSelectionDomain::~vtkSMMedGroupSelectionDomain() -{ -} - -int vtkSMMedGroupSelectionDomain::SetDefaultValues(vtkSMProperty* prop) -{ - vtkSMStringVectorProperty* svp = vtkSMStringVectorProperty::SafeDownCast(prop); - if(!svp || this->GetNumberOfRequiredProperties() == 0) - { - return this->Superclass::SetDefaultValues(prop); - } - - // info property has default values - vtkSMStringVectorProperty* isvp = vtkSMStringVectorProperty::SafeDownCast( - prop->GetInformationProperty()); - if (isvp) - { - vtkStringList* proplist = vtkStringList::New(); - svp->SetNumberOfElements(0); - svp->SetNumberOfElementsPerCommand(2); - for(int id=0; idGetNumberOfElements(); id++) - { - string elem = isvp->GetElement(id); - proplist->AddString(elem.c_str()); - if(elem.find("/OnCell/") != string::npos) - { - proplist->AddString("1"); - } - else - { - proplist->AddString("0"); - } - } - svp->SetElements(proplist); - proplist->Delete(); - } - - return 1; -} - -void vtkSMMedGroupSelectionDomain::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} diff --git a/src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.h b/src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.h deleted file mode 100644 index f9c9d469..00000000 --- a/src/Plugins/MedReader/ParaViewPlugin/vtkSMMedGroupSelectionDomain.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2010-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// .NAME vtkSMMedGroupSelectionDompain - domain used to -// select groups from med files. -// .SECTION Description -// This property overrides the SetDefaultValues to select only cell groups - -#ifndef __vtkSMMedGroupSelectionDomain_h -#define __vtkSMMedGroupSelectionDomain_h - -#include "vtkSMSILDomain.h" - -class VTK_EXPORT vtkSMMedGroupSelectionDomain : public vtkSMSILDomain -{ -public: - static vtkSMMedGroupSelectionDomain* New(); - vtkTypeMacro(vtkSMMedGroupSelectionDomain, vtkSMSILDomain); - void PrintSelf(ostream& os, vtkIndent indent); - - virtual int SetDefaultValues(vtkSMProperty*); - -protected: - vtkSMMedGroupSelectionDomain(); - ~vtkSMMedGroupSelectionDomain(); - -private: - vtkSMMedGroupSelectionDomain(const vtkSMMedGroupSelectionDomain&); - // Not implemented - void operator=(const vtkSMMedGroupSelectionDomain&); // Not implemented -}; - -#endif -- 2.39.2