1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkTemporalPathLineFilter.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 // .NAME vtkTemporalPathLineFilter - Generate a Polydata Pointset from any Dataset. 16 // 17 // .SECTION Description 18 // vtkTemporalPathLineFilter takes any dataset as input, it extracts the point 19 // locations of all cells over time to build up a polyline trail. 20 // The point number (index) is used as the 'key' if the points are randomly 21 // changing their respective order in the points list, then you should specify 22 // a scalar that represents the unique ID. This is intended to handle the output 23 // of a filter such as the TemporalStreamTracer. 24 // 25 // .SECTION See Also 26 // vtkTemporalStreamTracer 27 // 28 // .SECTION Thanks 29 // John Bidiscombe of 30 // CSCS - Swiss National Supercomputing Centre 31 // for creating and contributing this class. 32 33 #ifndef _vtkTemporalPathLineFilter_h 34 #define _vtkTemporalPathLineFilter_h 35 36 #include "vtkFiltersGeneralModule.h" // For export macro 37 #include "vtkPolyDataAlgorithm.h" 38 39 class vtkPoints; 40 class vtkCellArray; 41 class vtkMergePoints; 42 class vtkFloatArray; 43 44 //BTX 45 #include "vtkSmartPointer.h" // for memory safety 46 #include <set> // Because we want to use it 47 class ParticleTrail; 48 class vtkTemporalPathLineFilterInternals; 49 typedef vtkSmartPointer<ParticleTrail> TrailPointer; 50 //ETX 51 52 class VTKFILTERSGENERAL_EXPORT vtkTemporalPathLineFilter : public vtkPolyDataAlgorithm 53 { 54 public: 55 // Description: 56 // Standard Type-Macro 57 static vtkTemporalPathLineFilter *New(); 58 vtkTypeMacro(vtkTemporalPathLineFilter,vtkPolyDataAlgorithm); 59 void PrintSelf(ostream& os, vtkIndent indent); 60 61 // Description: 62 // Set the number of particles to track as a ratio of the input 63 // example: setting MaskPoints to 10 will track every 10th point 64 vtkSetMacro(MaskPoints,int); 65 vtkGetMacro(MaskPoints,int); 66 67 // Description: 68 // If the Particles being traced animate for a long time, the 69 // trails or traces will become long and stringy. Setting 70 // the MaxTraceTimeLength will limit how much of the trace 71 // is displayed. Tracks longer then the Max will disappear 72 // and the trace will apppear like a snake of fixed length 73 // which progresses as the particle moves 74 vtkSetMacro(MaxTrackLength,unsigned int); 75 vtkGetMacro(MaxTrackLength,unsigned int); 76 77 // Description: 78 // Specify the name of a scalar array which will be used to fetch 79 // the index of each point. This is necessary only if the particles 80 // change position (Id order) on each time step. The Id can be used 81 // to identify particles at each step and hence track them properly. 82 // If this array is NULL, the global point ids are used. If an Id 83 // array cannot otherwise be found, the point index is used as the ID. 84 vtkSetStringMacro(IdChannelArray); 85 vtkGetStringMacro(IdChannelArray); 86 87 // Description: 88 // If a particle disappears from one end of a simulation and reappears 89 // on the other side, the track left will be unrepresentative. 90 // Set a MaxStepDistance{x,y,z} which acts as a threshold above which 91 // if a step occurs larger than the value (for the dimension), the track will 92 // be dropped and restarted after the step. (ie the part before the wrap 93 // around will be dropped and the newer part kept). 94 vtkSetVector3Macro(MaxStepDistance,double); 95 vtkGetVector3Macro(MaxStepDistance,double); 96 97 // Description: 98 // When a particle 'disappears', the trail belonging to it is removed from 99 // the list. When this flag is enabled, dead trails will persist 100 // until the next time the list is cleared. Use carefully as it may cause 101 // excessive memory consumption if left on by mistake. 102 vtkSetMacro(KeepDeadTrails,int); 103 vtkGetMacro(KeepDeadTrails,int); 104 105 // Description: 106 // Flush will wipe any existing data so that traces can be restarted from 107 // whatever time step is next supplied. 108 void Flush(); 109 110 // Description: 111 // Set a second input which is a selection. Particles with the same 112 // Id in the selection as the primary input will be chosen for pathlines 113 // Note that you must have the same IdChannelArray in the selection as the input 114 void SetSelectionConnection(vtkAlgorithmOutput *algOutput); 115 116 // Description: 117 // Set a second input which is a selection. Particles with the same 118 // Id in the selection as the primary input will be chosen for pathlines 119 // Note that you must have the same IdChannelArray in the selection as the input 120 void SetSelectionData(vtkDataSet *input); 121 122 protected: 123 vtkTemporalPathLineFilter(); 124 ~vtkTemporalPathLineFilter(); 125 126 // 127 // Make sure the pipeline knows what type we expect as input 128 // 129 virtual int FillInputPortInformation (int port, vtkInformation* info); 130 virtual int FillOutputPortInformation(int port, vtkInformation* info); 131 132 // Description: 133 // The necessary parts of the standard pipeline update mechanism 134 virtual int RequestInformation (vtkInformation *, 135 vtkInformationVector **, 136 vtkInformationVector *); 137 // 138 virtual int RequestData(vtkInformation *request, 139 vtkInformationVector** inputVector, 140 vtkInformationVector* outputVector); 141 142 //BTX 143 TrailPointer GetTrail(vtkIdType i); 144 void IncrementTrail( 145 TrailPointer trail, vtkDataSet *input, vtkIdType i); 146 //ETX 147 // internal data variables 148 int NumberOfTimeSteps; 149 int MaskPoints; 150 unsigned int MaxTrackLength; 151 unsigned int LastTrackLength; 152 int FirstTime; 153 char *IdChannelArray; 154 double MaxStepDistance[3]; 155 double LatestTime; 156 int KeepDeadTrails; 157 int UsingSelection; 158 // 159 //BTX 160 vtkSmartPointer<vtkCellArray> PolyLines; 161 vtkSmartPointer<vtkCellArray> Vertices; 162 vtkSmartPointer<vtkPoints> LineCoordinates; 163 vtkSmartPointer<vtkPoints> VertexCoordinates; 164 vtkSmartPointer<vtkFloatArray> TrailId; 165 vtkSmartPointer<vtkTemporalPathLineFilterInternals> Internals; 166 std::set<vtkIdType> SelectionIds; 167 //ETX 168 // 169 private: 170 vtkTemporalPathLineFilter(const vtkTemporalPathLineFilter&); // Not implemented. 171 void operator=(const vtkTemporalPathLineFilter&); // Not implemented. 172 }; 173 174 #endif 175