Browse Source

VTK 9 support

master
Trevor Irons 4 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,25 +21,38 @@ set_target_properties(merlin PROPERTIES
21 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 28
 	target_link_libraries(merlin ${VTK_LIBRARIES})
30 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 42
 if (LEMMA_ENABLE_TESTING)
34 43
 	add_subdirectory(testing)
35 44
 endif()
36 45
 
37
-# Python Bindings
46
+###################
47
+# Python Bindings #
48
+###################
38 49
 if (LEMMA_PYTHON3_BINDINGS)
39 50
 	add_subdirectory(python)
40 51
 endif()
41 52
 
42
-# Install
53
+###########
54
+# Install #
55
+###########
43 56
 install ( TARGETS merlin DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
44 57
 install ( FILES include/Merlin  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
45 58
 install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma  FILES_MATCHING PATTERN "*.h")
@@ -47,7 +60,9 @@ install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma
47 60
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
48 61
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/FDEM1D  FILES_MATCHING PATTERN "*.h")
49 62
 
50
-# Examples
63
+############
64
+# Examples #
65
+############
51 66
 if (LEMMA_BUILD_EXAMPLES)
52 67
 	add_subdirectory(examples)
53 68
 endif()

+ 8
- 0
include/KernelV0.h View File

@@ -39,6 +39,9 @@
39 39
 #include "vtkHyperTreeGrid.h"
40 40
 #include "vtkXMLHyperTreeGridWriter.h"
41 41
 #include "vtkHyperTreeCursor.h"  // not in VTK 8.90
42
+#ifdef LEMMA_VTK9_SUPPORT
43
+#include "vtkHyperTreeGridNonOrientedCursor.h"
44
+#endif
42 45
 //#include "vtkHyperTreeGridLevelEntry.h" VTK 9
43 46
 #include "vtkDoubleArray.h"
44 47
 #endif
@@ -350,8 +353,13 @@ namespace Lemma {
350 353
          *  Same functionality as @see EvaluateKids, but includes generation of a VTK
351 354
          *  HyperOctree, which is useful for visualization.
352 355
          */
356
+        #ifdef LEMMA_VTK8_SUPPORT
353 357
         void EvaluateKids2(  const Vector3r& size, const int& level, const Vector3r& cpos,
354 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 364
         void GetPosition( vtkHyperTreeCursor* Cursor, Real* p );
357 365
         #endif

+ 24
- 1
src/KernelV0.cpp View File

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

Loading…
Cancel
Save