Giter Club home page Giter Club logo

Comments (3)

marcomusy avatar marcomusy commented on May 24, 2024 1

I really wonder why you would not use the package.

Anyway you can find hints in vtkplotter/utils.py (pointScalars() method).

from vedo.

marcomusy avatar marcomusy commented on May 24, 2024

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.

ricky2208 avatar ricky2208 commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.