|
| 1 | +#### import the simple module from the paraview |
| 2 | +from paraview.simple import * |
| 3 | + |
| 4 | +# ---------------------------------------------------------------- |
| 5 | +# Choose the resampling dimension for the example |
| 6 | +# ---------------------------------------------------------------- |
| 7 | + |
| 8 | +if len(sys.argv) == 2: |
| 9 | + dim = int(sys.argv[1]) |
| 10 | +else: |
| 11 | + dim = 256 |
| 12 | + |
| 13 | +# create a new 'XML Image Data Reader' |
| 14 | +atvti = XMLImageDataReader(FileName=["at.vti"]) |
| 15 | +atvti.PointArrayStatus = ["density"] |
| 16 | + |
| 17 | +calculator1 = Calculator(Input=atvti) |
| 18 | +calculator1.ResultArrayType = "Float" |
| 19 | +calculator1.ResultArrayName = "density" |
| 20 | +calculator1.Function = "density" |
| 21 | + |
| 22 | +# create a new 'Compute Derivatives' |
| 23 | +computeDerivatives1 = ComputeDerivatives(Input=calculator1) |
| 24 | +computeDerivatives1.Scalars = ["POINTS", "density"] |
| 25 | +computeDerivatives1.Vectors = ["POINTS", "1"] |
| 26 | + |
| 27 | +# create a new 'Calculator' |
| 28 | +calculator2 = Calculator(Input=computeDerivatives1) |
| 29 | +calculator2.AttributeType = "Cell Data" |
| 30 | +calculator2.ResultArrayName = "gradientMagnitude" |
| 31 | +calculator2.Function = "mag(ScalarGradient)" |
| 32 | +calculator2.ResultArrayType = "Float" |
| 33 | + |
| 34 | + |
| 35 | +# create a new 'Cell Data to Point Data' |
| 36 | +cellDatatoPointData1 = CellDatatoPointData(Input=calculator2) |
| 37 | +cellDatatoPointData1.CellDataArraytoprocess = ["gradientMagnitude"] |
| 38 | + |
| 39 | +# create a new 'TTK PointDataSelector' |
| 40 | +tTKPointDataSelector1 = TTKPointDataSelector(Input=cellDatatoPointData1) |
| 41 | +tTKPointDataSelector1.ScalarFields = ["density", "gradientMagnitude"] |
| 42 | +tTKPointDataSelector1.RangeId = [0, 2] |
| 43 | + |
| 44 | +# create a new 'Cell Data to Point Data' |
| 45 | +cellDatatoPointData2 = CellDatatoPointData(Input=tTKPointDataSelector1) |
| 46 | +cellDatatoPointData2.CellDataArraytoprocess = ["ScalarGradient", "gradientMagnitude"] |
| 47 | + |
| 48 | +# create a new 'Resample To Image' |
| 49 | +resampleToImage1 = ResampleToImage(Input=cellDatatoPointData2) |
| 50 | +resampleToImage1.SamplingDimensions = [dim, dim, dim] |
| 51 | +resampleToImage1.SamplingBounds = [0.0, 176.0, 0.0, 94.0, 0.0, 47.0] |
| 52 | + |
| 53 | +# create a new 'TTK ScalarFieldSmoother' |
| 54 | +tTKScalarFieldSmoother1 = TTKScalarFieldSmoother(Input=resampleToImage1) |
| 55 | +tTKScalarFieldSmoother1.ScalarField = ["POINTS", "density"] |
| 56 | +tTKScalarFieldSmoother1.IterationNumber = 1 |
| 57 | + |
| 58 | +# create a new 'TTK ScalarFieldSmoother' |
| 59 | +tTKScalarFieldSmoother2 = TTKScalarFieldSmoother(Input=tTKScalarFieldSmoother1) |
| 60 | +tTKScalarFieldSmoother2.ScalarField = ["POINTS", "gradientMagnitude"] |
| 61 | +tTKScalarFieldSmoother2.IterationNumber = 10 |
| 62 | + |
| 63 | +# create a new 'TTK ScalarFieldNormalizer' |
| 64 | +tTKScalarFieldNormalizer2 = TTKScalarFieldNormalizer(Input=tTKScalarFieldSmoother2) |
| 65 | +tTKScalarFieldNormalizer2.ScalarField = ["POINTS", "density"] |
| 66 | + |
| 67 | +# create a new 'TTK ArrayPreconditioning' |
| 68 | +tTKArrayPreconditioning1 = TTKArrayPreconditioning(Input=tTKScalarFieldNormalizer2) |
| 69 | +tTKArrayPreconditioning1.PointDataArrays = ["density"] |
| 70 | + |
| 71 | +# create a new 'TTK ScalarFieldCriticalPoints' |
| 72 | +tTKScalarFieldCriticalPoints2 = TTKScalarFieldCriticalPoints( |
| 73 | + Input=tTKArrayPreconditioning1 |
| 74 | +) |
| 75 | +tTKScalarFieldCriticalPoints2.ScalarField = ["POINTS", "density"] |
| 76 | +tTKScalarFieldCriticalPoints2.Backend = "Default generic backend" |
| 77 | + |
| 78 | +# create a new 'Mask Points' |
| 79 | +maskPoints2 = MaskPoints(Input=tTKScalarFieldCriticalPoints2) |
| 80 | +maskPoints2.OnRatio = 1 |
| 81 | +maskPoints2.MaximumNumberofPoints = 99999999 |
| 82 | +maskPoints2.ProportionallyDistributeMaximumNumberOfPoints = 1 |
| 83 | +maskPoints2.RandomSampling = 1 |
| 84 | +maskPoints2.RandomSamplingMode = "Random Sampling" |
| 85 | +maskPoints2.GenerateVertices = 1 |
| 86 | +maskPoints2.SingleVertexPerCell = 1 |
| 87 | + |
| 88 | +# create a new 'Threshold' |
| 89 | +threshold1 = Threshold(Input=maskPoints2) |
| 90 | +threshold1.Scalars = ["POINTS", "CriticalType"] |
| 91 | +threshold1.LowerThreshold = 1.0 |
| 92 | +threshold1.UpperThreshold = 1.0 |
| 93 | + |
| 94 | +# create a new 'Threshold' |
| 95 | +threshold4 = Threshold(Input=threshold1) |
| 96 | +threshold4.Scalars = ["POINTS", "IsOnBoundary"] |
| 97 | + |
| 98 | +# create a new 'TTK IntegralLines' |
| 99 | +tTKIntegralLines1 = TTKIntegralLines(Domain=tTKArrayPreconditioning1, Seeds=threshold4) |
| 100 | +tTKIntegralLines1.ScalarField = ["POINTS", "density"] |
| 101 | +tTKIntegralLines1.Direction = "Backward" |
| 102 | +tTKIntegralLines1.Vertexidentifierfield = ["POINTS", "CriticalType"] |
| 103 | +tTKIntegralLines1.EnableForking = 1 |
| 104 | + |
| 105 | +# create a new 'Clean to Grid' |
| 106 | +cleantoGrid1 = CleantoGrid(Input=tTKIntegralLines1) |
| 107 | + |
| 108 | +# create a new 'TTK GeometrySmoother' |
| 109 | +tTKGeometrySmoother2 = TTKGeometrySmoother(Input=cleantoGrid1) |
| 110 | +tTKGeometrySmoother2.IterationNumber = 200 |
| 111 | + |
| 112 | +# create a new 'Resample With Dataset' |
| 113 | +resampleWithDataset1 = ResampleWithDataset( |
| 114 | + SourceDataArrays=cellDatatoPointData1, DestinationMesh=tTKGeometrySmoother2 |
| 115 | +) |
| 116 | +resampleWithDataset1.CellLocator = "Static Cell Locator" |
| 117 | +resampleWithDataset1.PassCellArrays = 1 |
| 118 | +resampleWithDataset1.PassPointArrays = 1 |
| 119 | + |
| 120 | +# create a new 'TTK ScalarFieldCriticalPoints' |
| 121 | +tTKScalarFieldCriticalPoints1 = TTKScalarFieldCriticalPoints(Input=resampleWithDataset1) |
| 122 | +tTKScalarFieldCriticalPoints1.ScalarField = ["POINTS", "gradientMagnitude"] |
| 123 | +tTKScalarFieldCriticalPoints1.Backend = "Default generic backend" |
| 124 | + |
| 125 | +SaveData("integralLines.pvtu", tTKGeometrySmoother2) |
| 126 | +SaveData("criticalPoints.pvtp", tTKScalarFieldCriticalPoints1) |
0 commit comments