Comments (3)
I really wonder why you would not use the package.
Anyway you can find hints in vtkplotter/utils.py (pointScalars() method).
from vedo.
Your code is not quite right.
try this:
pip install --upgrade vtkplotter
from vtkplotter import Plotter, sqrt
from vtkplotter.utils import pointScalars
print("enter size of the dataset ")
#limit=int(input())
limit=20
vp = Plotter()
grid=[]
scalars=[]
for i in range(0,limit):
for j in range(0,limit):
for k in range(0,limit):
vol = sqrt(pow(i,2)+pow(j,2)+pow(k,2))
scalars.append(vol)
grid.append([i,j,k])
act = vp.points(grid)
pointScalars(act, scalars, 'myscalars')
vp.write(act, 'myfile.vtk')
vp.show()
#to visualize, at command line:
# > vtkplotter myfile.vtk # (then press p and k)
from vedo.
can we do it without using vtkplotter
I tried yesterday and wrote this
import vtk
import math
fname='C:/Users/prakhyati/datafile1.vtk'
print("enter size of the dataset ")
limit=int(input())
xAxis = -50.0
yAxis = -50.0
zAxis = -50.0
domain=50
width=0
scalar = "volume"
Points = vtk.vtkPoints()
for i in range(0,limit):
xAxis=xAxis+width
for j in range(0,limit):
yAxis=yAxis+width
for k in range(0,limit):
zAxis=zAxis+width
width=((2*domain)/limit)
vol = math.sqrt(pow(xAxis, 2) + pow(yAxis, 2) + pow(zAxis, 2))
Points.InsertNextPoint(xAxis,yAxis,zAxis)
polydata = vtk.vtkPolyData()
polydata.SetPoints(Points)
if vtk.VTK_MAJOR_VERSION <= 5:
polydata.Update()
writer = vtk.vtkPolyDataWriter()
writer.SetFileName(fname)
writer.SetFileFormat(1,2)
if vtk.VTK_MAJOR_VERSION <= 5:
writer.SetInput(polydata)
else:
writer.SetInputData(polydata)
writer.Write()
It does create the file, but I am unable to add scalars (can't find set scalar function for polydata )
Also, I have doubt if I am calculating the coordinates of the grid correctly (I did this on pen and paper and implemented, domain is from -50.0 to 50.0)
Any information on the same will be a help.
from vedo.
Related Issues (20)
- plane normal HOT 3
- Adding item to Group HOT 2
- Arrow object's top point HOT 2
- Group objects HOT 1
- Help ! Legosurface Error HOT 2
- version 2024.5.2 `show()` function returns error HOT 4
- quality and resolution of the video HOT 3
- Make load functions compatible with pathlib.Path HOT 1
- Creating a plot with objects out of scene, seems to break calls to render HOT 1
- Mesh.volume() and Mesh.is_closed() don't work with Boxes and Cylinders HOT 1
- compute_normals() unexpectedly changes the appearance of a Mesh HOT 2
- Cut volume with volume HOT 1
- seg fault on vertex normal and texture indices in obj format to off conversion HOT 2
- Issues with boolean operation HOT 4
- Touching objects handling in isosurface_discrete HOT 10
- Problems with boolean operations on concave polyhedrons HOT 4
- Problem with mesh formation
- mesh.cells datatype HOT 2
- Axes order of numpy array HOT 2
- computing volume of intersecting concave polyhedra HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vedo.