1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkHyperTreeGridThreshold.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkHyperTreeGridThreshold 17 * @brief Extract cells from a hyper tree grid 18 * where selected scalar value is within given range. 19 * 20 * 21 * This filter extracts cells from a hyper tree grid that satisfy the 22 * following threshold: a cell is considered to be within range if its 23 * value for the active scalar is within a specified range (inclusive). 24 * The output remains a hyper tree grid. 25 * JB Un parametre (JustCreateNewMask=true) permet de ne pas faire 26 * le choix de la creation d'un nouveau HTG mais 27 * de redefinir juste le masque. 28 * 29 * @sa 30 * vtkHyperTreeGrid vtkHyperTreeGridAlgorithm vtkThreshold 31 * 32 * @par Thanks: 33 * This class was written by Guenole Harel and Jacques-Bernard Lekien 2014 34 * This class was revised by Philippe Pebay, 2016 35 * This class was optimized by Jacques-Bernard Lekien, 2018. 36 * This work was supported by Commissariat a l'Energie Atomique 37 * CEA, DAM, DIF, F-91297 Arpajon, France. 38 */ 39 40 #ifndef vtkHyperTreeGridThreshold_h 41 #define vtkHyperTreeGridThreshold_h 42 43 #include "vtkFiltersHyperTreeModule.h" // For export macro 44 #include "vtkHyperTreeGridAlgorithm.h" 45 46 class vtkBitArray; 47 class vtkHyperTreeGrid; 48 49 class vtkHyperTreeGridNonOrientedCursor; 50 51 class VTKFILTERSHYPERTREE_EXPORT vtkHyperTreeGridThreshold : public vtkHyperTreeGridAlgorithm 52 { 53 public: 54 static vtkHyperTreeGridThreshold* New(); 55 vtkTypeMacro(vtkHyperTreeGridThreshold, vtkHyperTreeGridAlgorithm); 56 void PrintSelf(ostream& os, vtkIndent indent) override; 57 58 ///@{ 59 /** 60 * Set/Get True, create a new mask ; false, create a new HTG. 61 */ 62 vtkSetMacro(JustCreateNewMask, bool); 63 vtkGetMacro(JustCreateNewMask, bool); 64 ///@} 65 66 ///@{ 67 /** 68 * Set/Get minimum scalar value of threshold 69 */ 70 vtkSetMacro(LowerThreshold, double); 71 vtkGetMacro(LowerThreshold, double); 72 ///@} 73 74 ///@{ 75 /** 76 * Set/Get maximum scalar value of threshold 77 */ 78 vtkSetMacro(UpperThreshold, double); 79 vtkGetMacro(UpperThreshold, double); 80 ///@} 81 82 /** 83 * Convenience method to set both threshold values at once 84 */ 85 void ThresholdBetween(double, double); 86 87 protected: 88 vtkHyperTreeGridThreshold(); 89 ~vtkHyperTreeGridThreshold() override; 90 91 /** 92 * For this algorithm the output is a vtkHyperTreeGrid instance 93 */ 94 int FillOutputPortInformation(int, vtkInformation*) override; 95 96 /** 97 * Main routine to extract cells based on thresholded value 98 */ 99 int ProcessTrees(vtkHyperTreeGrid*, vtkDataObject*) override; 100 101 /** 102 * Recursively descend into tree down to leaves 103 */ 104 bool RecursivelyProcessTree( 105 vtkHyperTreeGridNonOrientedCursor*, vtkHyperTreeGridNonOrientedCursor*); 106 bool RecursivelyProcessTreeWithCreateNewMask(vtkHyperTreeGridNonOrientedCursor*); 107 108 /** 109 * LowerThreshold scalar value to be accepted 110 */ 111 double LowerThreshold; 112 113 /** 114 * UpperThreshold scalar value to be accepted 115 */ 116 double UpperThreshold; 117 118 /** 119 * Input material mask 120 */ 121 vtkBitArray* InMask; 122 123 /** 124 * Output material mask constructed by this filter 125 */ 126 vtkBitArray* OutMask; 127 128 /** 129 * Keep track of current index in output hyper tree grid 130 */ 131 vtkIdType CurrentId; 132 133 /** 134 * Keep track of selected input scalars 135 */ 136 vtkDataArray* InScalars; 137 138 /** 139 * With or without copy 140 */ 141 bool JustCreateNewMask; 142 143 private: 144 vtkHyperTreeGridThreshold(const vtkHyperTreeGridThreshold&) = delete; 145 void operator=(const vtkHyperTreeGridThreshold&) = delete; 146 }; 147 148 #endif /* vtkHyperTreeGridThreshold */ 149