Hi there,
I have a pipeline in the Paraview which start from the 3D model that i imported and end with the contour tree generated after simplification !!
I want to do samething in python, i am going to use pvpython and is there anyway i can get this exported in python and if yes can you please let me know what are the otherthings that i need to take care of like dependencies folders or packages.
Thank you
File / save state
and choose python
file format.
Also, when looking for a specific line of python, you can Tools / Start Trace
and do the action in the interface. Then Tools / Stop Trace
gives you the corresponding python script.
it seems like it uses the hard-coded value generated from each stage.
I want to make that pipeline work for all generic data input of that kind.
Is there anyway to do that?
Indeed, trace and state record all actual values for each properties to keep your scrip consistent even if default values change. If you want to rely on the default, you can simply remove the concerned lines.
Also, you can try the different options to limit the complexity of the script. For instance, the trace has the only user-modified properties
option.
Hi @nicolas.vuaille !! awesome !! now i am having one problem, it turnedout that
elevation1 = Elevation(registrationName=âElevation1â, Input=tTKGeometrySmoother1)
elevation1.ScalarRange = [0.0, 100.0]
elevation1.LowPoint = [0.0, 0.0, -0.4149]
elevation1.HighPoint = [0.0, 0.0, 0.4543553590774536]
this is my data for one mesh and for another mesh this is oviously different.
I tried commenting last two line thinking that if i dont give it, ttk might compute itself but it turned out it didnât work when i commented it out !!
can you suggest me on anything that can i do so that i can get the low and high point of the mesh ?
one not smart way might be reading all the data in the file and find the high and low point but this elevation high point and low point is to be from the smoothen mesh after applying ttkgeometrysmooth filter.
and again thank you
To get those kind of info, the correct way to do is to use DataInformation
objects, that are not in the python trace and correspond to the Information Panel
.
tTKGeometrySmoother1.UpdatePipeline() # ensure data is loaded and computed until here
di = tTKGeometrySmoother1.GetDataInformation()
bounds = di.DataInformation.GetBounds() # return [Xmin, Xmax, Ymin, Ymax, Zmin, Zmax]
Some python doc, and more in the c++ one (python API is automatically generated from there)
Hi @nicolas.vuaille, thank you !!! this is giving min and max of x, y and z coordinate or boundary whereas i need the min and max elevation position of the smoothen mesh.
not sure to see what you expect here. What is the âsmoothen meshâ and what do you mean by âelevationâ ? (I though you were configuring the elevation filterâŚ)
ohh i am really sorry if i was not able to present the problem clearly. I will try to articulate my issue again.
I have a terrain mesh and it is not smooth but somehow blocky so i did put smooth geometry filter on it with smoothing factor of 3.
and i want to find the contour tree of the terrain and get the segmented mesh from the contour tree generation filter so to get elevation i applied elevation filter like paraview dragon video demo.
I am successfully able to get/export the segmented mesh but when i see my python code, there is this code,
elevation1 = Elevation(registrationName='Elevation1', Input=tTKGeometrySmoother1)
elevation1.ScalarRange = [0.0, 100.0]
elevation1.LowPoint = [0.0, 0.0, -0.4149]
elevation1.HighPoint = [0.0, 0.0, 0.4543553590774536]
and this elevation1 is used as input for all the process afterward like for persistance diagram and topological simplication.
This is the only thing that is not not letting me run this code for other terrain and get segmented output because this point will be used for all the terrain which i believe is not intended.
I guessed that this is the minimum and maximum point in the mesh which i hope am correct.
this is the value that is supposed to be in the low point and highpoint for every mesh.
and this value is got after clicking that z axis because i dont know, z axis is up in paraview .
Ok, I better understand the situation. But not sure to see the problem.
Clicking on Z Axis
is equivalent to set Low point to [0, 0, Zmin]
and High Point to [0, 0, Zmax]
, no ?
but that [0, 0, zmin] wonât be the point of minimum elevation or lowest point !!
but lowest point will be any point (x, y, z) in terrain with minimum z, right?
Lowest Point
does not necessary belong to the mesh, it is used to define a line in 3d space.
Elevation filter algo is as following:
- for each point
P
of the mesh
- project
P
on the line [Low Point, High Point]
. It gives a 3d point, Proj
.
- compute
[Low Point, Proj]
parametric distance, as d
(scaled to fit inside Scalar Range
)
- associate
d
as data for P
, in an array called Elevation
ohh, i can not believe how wrong i was. I had checked documentation but couldnot make it helpful because i didnlt know what to get from where and how to feed to it.
Thank you so so much !!
Thank you for being patient and helping me out this issue. Thank you
and this is my code right,
elevation1 = Elevation(registrationName='Elevation1', Input=tTKGeometrySmoother1)
tTKGeometrySmoother1.UpdatePipeline()
di = tTKGeometrySmoother1.GetDataInformation()
bounds = di.DataInformation.GetBounds()
# Properties modified on elevation1
elevation1.ScalarRange = [0.0, 100.0]
elevation1.LowPoint = [0.0, 0.0, bounds[4]]
elevation1.HighPoint = [0.0, 0.0, bounds[5]]
1 Like
i dont know if i can ask the question here or need to create another topic but didnât want to make discourse crows so i am asking here.
I am new to python and i am using pvpython to run this code. I couldnât make it run with normal python.
I made pvpython as an interpreter and ran this code. I have my pvpython as:
since i am new to python, i came all the way to this from many countless hit and trail as well. Now i want to know if i can make a python based project on this pvpython.exe which i think is also python in itself.
I want to make a backend system where i can send the 3d file and run this code which will process the terrain and generate the segmented output mesh that this code is exporting !!
I have struggled a lot on this part as well, can you please help me knowing if i can do or not.
to call yout paraview python script from another python project, you should take care of 2 things:
- specify environment so paraview.simple is found
- ensure version are compatible (from what I see, your paraview module is known to work for python 3.9 for instance)
See some more info in this thread.