Browse Source

VTK 9 support

master
Trevor Irons 3 years ago
parent
commit
11585c0398
3 changed files with 56 additions and 10 deletions
  1. 24
    9
      CMakeLists.txt
  2. 8
    0
      include/KernelV0.h
  3. 24
    1
      src/KernelV0.cpp

+ 24
- 9
CMakeLists.txt View File

21
 	PROJECT_LABEL "MERLIN ${LABEL_SUFFIX}"
21
 	PROJECT_LABEL "MERLIN ${LABEL_SUFFIX}"
22
 )
22
 )
23
 
23
 
24
-# Linking
25
-target_link_libraries(merlin "lemmacore" "fdem1d" )
26
-
27
-# Linking
28
-if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT ) 
24
+###########
25
+# Linking #
26
+###########
27
+if ( LEMMA_VTK8_SUPPORT ) 
29
 	target_link_libraries(merlin ${VTK_LIBRARIES})
28
 	target_link_libraries(merlin ${VTK_LIBRARIES})
30
 endif()
29
 endif()
31
 
30
 
32
-# Testing
31
+if ( LEMMA_VTK9_SUPPORT ) 
32
+	target_link_libraries(merlin ${visibility} VTK::CommonCore VTK::CommonDataModel VTK::RenderingCore VTK::FiltersHyperTree VTK::FiltersCore)
33
+	vtk_module_autoinit(TARGETS merlin MODULES VTK::CommonCore VTK::RenderingCore)
34
+endif()
35
+
36
+target_link_libraries(merlin "lemmacore" "fdem1d" )
37
+
38
+
39
+###########
40
+# Testing #
41
+###########
33
 if (LEMMA_ENABLE_TESTING)
42
 if (LEMMA_ENABLE_TESTING)
34
 	add_subdirectory(testing)
43
 	add_subdirectory(testing)
35
 endif()
44
 endif()
36
 
45
 
37
-# Python Bindings
46
+###################
47
+# Python Bindings #
48
+###################
38
 if (LEMMA_PYTHON3_BINDINGS)
49
 if (LEMMA_PYTHON3_BINDINGS)
39
 	add_subdirectory(python)
50
 	add_subdirectory(python)
40
 endif()
51
 endif()
41
 
52
 
42
-# Install
53
+###########
54
+# Install #
55
+###########
43
 install ( TARGETS merlin DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
56
 install ( TARGETS merlin DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
44
 install ( FILES include/Merlin  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
57
 install ( FILES include/Merlin  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
45
 install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma  FILES_MATCHING PATTERN "*.h")
58
 install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma  FILES_MATCHING PATTERN "*.h")
47
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
60
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
48
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/FDEM1D  FILES_MATCHING PATTERN "*.h")
61
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/FDEM1D  FILES_MATCHING PATTERN "*.h")
49
 
62
 
50
-# Examples
63
+############
64
+# Examples #
65
+############
51
 if (LEMMA_BUILD_EXAMPLES)
66
 if (LEMMA_BUILD_EXAMPLES)
52
 	add_subdirectory(examples)
67
 	add_subdirectory(examples)
53
 endif()
68
 endif()

+ 8
- 0
include/KernelV0.h View File

39
 #include "vtkHyperTreeGrid.h"
39
 #include "vtkHyperTreeGrid.h"
40
 #include "vtkXMLHyperTreeGridWriter.h"
40
 #include "vtkXMLHyperTreeGridWriter.h"
41
 #include "vtkHyperTreeCursor.h"  // not in VTK 8.90
41
 #include "vtkHyperTreeCursor.h"  // not in VTK 8.90
42
+#ifdef LEMMA_VTK9_SUPPORT
43
+#include "vtkHyperTreeGridNonOrientedCursor.h"
44
+#endif
42
 //#include "vtkHyperTreeGridLevelEntry.h" VTK 9
45
 //#include "vtkHyperTreeGridLevelEntry.h" VTK 9
43
 #include "vtkDoubleArray.h"
46
 #include "vtkDoubleArray.h"
44
 #endif
47
 #endif
350
          *  Same functionality as @see EvaluateKids, but includes generation of a VTK
353
          *  Same functionality as @see EvaluateKids, but includes generation of a VTK
351
          *  HyperOctree, which is useful for visualization.
354
          *  HyperOctree, which is useful for visualization.
352
          */
355
          */
356
+        #ifdef LEMMA_VTK8_SUPPORT
353
         void EvaluateKids2(  const Vector3r& size, const int& level, const Vector3r& cpos,
357
         void EvaluateKids2(  const Vector3r& size, const int& level, const Vector3r& cpos,
354
                             const VectorXcr& parentVal, vtkHyperTreeGrid* octree, vtkHyperTreeCursor* curse );
358
                             const VectorXcr& parentVal, vtkHyperTreeGrid* octree, vtkHyperTreeCursor* curse );
359
+        #elif LEMMA_VTK9_SUPPORT
360
+        void EvaluateKids2(  const Vector3r& size, const int& level, const Vector3r& cpos,
361
+                            const VectorXcr& parentVal, vtkHyperTree* octree, vtkHyperTreeGridNonOrientedCursor* curse );
362
+        #endif
355
 
363
 
356
         void GetPosition( vtkHyperTreeCursor* Cursor, Real* p );
364
         void GetPosition( vtkHyperTreeCursor* Cursor, Real* p );
357
         #endif
365
         #endif

+ 24
- 1
src/KernelV0.cpp View File

278
         } else {
278
         } else {
279
         #ifdef LEMMAUSEVTK
279
         #ifdef LEMMAUSEVTK
280
             vtkHyperTreeGrid* oct = vtkHyperTreeGrid::New();
280
             vtkHyperTreeGrid* oct = vtkHyperTreeGrid::New();
281
+                #if LEMMA_VTK8_SUPPORT
281
                 oct->SetGridSize( 1, 1, 1 ); // Important!
282
                 oct->SetGridSize( 1, 1, 1 ); // Important!
282
                 oct->SetDimension(3);
283
                 oct->SetDimension(3);
284
+                #elif LEMMA_VTK9_SUPPORT
285
+                oct->SetExtent( 0, 1, 0, 1, 0, 1 ); // Important!
286
+                oct->SetDimensions(1,1,1);
287
+                #endif
283
                 vtkNew<vtkDoubleArray> xcoords;
288
                 vtkNew<vtkDoubleArray> xcoords;
284
                     xcoords->SetNumberOfComponents(1);
289
                     xcoords->SetNumberOfComponents(1);
285
                     xcoords->SetNumberOfTuples(2);
290
                     xcoords->SetNumberOfTuples(2);
306
 
311
 
307
             //vtkHyperTreeGridLevelEntry* curse2 =  vtkHyperTreeGridLevelEntry::New(); // VTK 9
312
             //vtkHyperTreeGridLevelEntry* curse2 =  vtkHyperTreeGridLevelEntry::New(); // VTK 9
308
             // I belive the index in NewCursor maybe points to which cell in the Rectilinear Grid?
313
             // I belive the index in NewCursor maybe points to which cell in the Rectilinear Grid?
314
+            #if LEMMA_VTK8_SUPPORT
309
             vtkHyperTreeCursor* curse = oct->NewCursor(0, true); // true creates the cursor
315
             vtkHyperTreeCursor* curse = oct->NewCursor(0, true); // true creates the cursor
310
                 curse->ToRoot();
316
                 curse->ToRoot();
311
             EvaluateKids2( Size, 0, cpos, VectorXcr::Ones(PulseI.size()), oct, curse );
317
             EvaluateKids2( Size, 0, cpos, VectorXcr::Ones(PulseI.size()), oct, curse );
318
+            #elif LEMMA_VTK9_SUPPORT
319
+            auto curse = oct->NewNonOrientedCursor(0, true); // true creates the cursor
320
+                curse->ToRoot();
321
+            EvaluateKids2( Size, 0, cpos, VectorXcr::Ones(PulseI.size()), oct->GetTree(0, true), curse );
322
+            #endif
312
 
323
 
313
             for (int iq=0; iq<PulseI.size(); ++iq) {
324
             for (int iq=0; iq<PulseI.size(); ++iq) {
314
 
325
 
643
     //       Class:  KernelV0
654
     //       Class:  KernelV0
644
     //      Method:  EvaluateKids2 -- same as Evaluate Kids, but include VTK octree generation
655
     //      Method:  EvaluateKids2 -- same as Evaluate Kids, but include VTK octree generation
645
     //--------------------------------------------------------------------------------------
656
     //--------------------------------------------------------------------------------------
657
+    #ifdef LEMMA_VTK8_SUPPORT
646
     void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
658
     void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
647
         const VectorXcr& parentVal, vtkHyperTreeGrid* oct, vtkHyperTreeCursor* curse) {
659
         const VectorXcr& parentVal, vtkHyperTreeGrid* oct, vtkHyperTreeCursor* curse) {
648
-
660
+    #elif LEMMA_VTK9_SUPPORT
661
+    void KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
662
+        const VectorXcr& parentVal, vtkHyperTree* oct, vtkHyperTreeGridNonOrientedCursor* curse) {
663
+    #endif
649
         int pdone =  (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2]));
664
         int pdone =  (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2]));
650
         if (pdone > percent_done ) {
665
         if (pdone > percent_done ) {
651
             percent_done = pdone;
666
             percent_done = pdone;
708
         // Evaluate whether or not furthur splitting is needed
723
         // Evaluate whether or not furthur splitting is needed
709
         if ( (((ksum - parentVal).array().abs() > tol).any() && level<maxLevel) || level < minLevel ) {
724
         if ( (((ksum - parentVal).array().abs() > tol).any() && level<maxLevel) || level < minLevel ) {
710
             // 0 after curse is vtkIdType?
725
             // 0 after curse is vtkIdType?
726
+            #ifdef LEMMA_VTK8_SUPPORT
711
             oct->SubdivideLeaf(curse, 0);
727
             oct->SubdivideLeaf(curse, 0);
728
+            #elif LEMMA_VTK9_SUPPORT
729
+            curse->SubdivideLeaf();
730
+            #endif
712
             for (int ichild=0; ichild<8; ++ichild) {
731
             for (int ichild=0; ichild<8; ++ichild) {
713
                 curse->ToChild(ichild);
732
                 curse->ToChild(ichild);
714
                 Vector3r cp = pos; // Eigen complains about combining these
733
                 Vector3r cp = pos; // Eigen complains about combining these
739
          */
758
          */
740
 
759
 
741
         // 0 after curse is vtkIdType?
760
         // 0 after curse is vtkIdType?
761
+        #ifdef LEMMA_VTK8_SUPPORT
742
         oct->SubdivideLeaf(curse, 0);
762
         oct->SubdivideLeaf(curse, 0);
763
+        #elif LEMMA_VTK9_SUPPORT
764
+        curse->SubdivideLeaf();
765
+        #endif
743
         for (int ichild=0; ichild<8; ++ichild) {
766
         for (int ichild=0; ichild<8; ++ichild) {
744
             curse->ToChild(ichild);
767
             curse->ToChild(ichild);
745
             LeafDict[curse->GetVertexId()] = ksum/(8.*vol);
768
             LeafDict[curse->GetVertexId()] = ksum/(8.*vol);

Loading…
Cancel
Save