Esempio n. 1
0
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        vp = Plotter(qtWidget=self.vtkWidget, axes=2, N=2)

        cn = Cone()
        cc = Cube().pos(1, 1, 1).color("pink")
        ss = Torus()
        vp.show(cn, cc, at=0)
        vp.show(ss, at=1, viewup="z", interactorStyle=0)

        self.start(vp)
Esempio n. 2
0
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        vp = Plotter(qtWidget=self.vtkWidget)

        vp += Cone()
        vp.show(interactorStyle=0) # create renderer and add the actors

        # set-up the rest of the Qt window
        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)

        self.show()    # <--- show the Qt Window
Esempio n. 3
0
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        # create renderer and add the actors
        self.vp = Plotter(qtWidget=self.vtkWidget)

        self.vp += Cone().rotateX(20)
        self.vp.show(interactorStyle=0)

        # set-up the rest of the Qt window
        button = Qt.QPushButton("My Button makes the cone red")
        button.setToolTip('This is an example button')
        button.clicked.connect(self.onClick)
        self.vl.addWidget(button)
        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)
        self.show()  # <--- show the Qt Window
Esempio n. 4
0
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.layout = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)

        # Create renderer and add the vedo objects and callbacks
        self.vp = Plotter(qtWidget=self.vtkWidget)
        self.id1 = self.vp.addCallback("mouse click", self.onMouseClick)
        self.id2 = self.vp.addCallback("key press",   self.onKeypress)
        self.vp += Cone().rotateX(20)
        self.vp.show()                  # <--- show the vedo rendering

        # Set-up the rest of the Qt window
        button = Qt.QPushButton("My Button makes the cone red")
        button.setToolTip('This is an example button')
        button.clicked.connect(self.onClick)
        self.layout.addWidget(self.vtkWidget)
        self.layout.addWidget(button)
        self.frame.setLayout(self.layout)
        self.setCentralWidget(self.frame)
        self.show()                     # <--- show the Qt Window
Esempio n. 5
0
from vedo import Cone, Sphere, merge, Volume
import numpy as np
import vtk

print('---------------------------------')
print('vtkVersion', vtk.vtkVersion().GetVTKVersion())
print('---------------------------------')


#####################################
cone = Cone(res=48)
sphere = Sphere(res=24)

carr = cone.cellCenters()[:, 2]
parr = cone.points()[:, 0]
cone.addCellArray(carr, 'carr')
cone.addPointArray(parr, 'parr')

carr = sphere.cellCenters()[:, 2]
parr = sphere.points()[:, 0]
sphere.addCellArray(carr, 'carr')
sphere.addPointArray(parr, 'parr')

sphere.addPointArray(np.sin(sphere.points()), 'pvectors')
sphere.addElevationScalars()

cone.computeNormals()
sphere.computeNormals()


###################################### test clone()
Esempio n. 6
0
"""Orient and scale 'glyphs'
(use a Mesh like a symbol)"""
# Credits: original example and data from https://plotly.com/python/cone-plot
# Adapted for vedo by M. Musy, 2020.
from vedo import Cone, Glyph, show
import numpy as np
import pandas as pd

# Read cvs data
df = pd.read_csv(
    "https://raw.githubusercontent.com/plotly/datasets/master/vortex.csv")
pts = np.c_[df['x'], df['y'], df['z']]
vecs = np.c_[df['u'], df['v'], df['w']]

# Create a mesh to be used like a symbol (a "glyph") to be attached to each point
cone = Cone().scale(0.3).rotateY(
    90)  # make it smaller and orient tip to positive x
glyph = Glyph(pts, cone, vecs, scaleByVectorSize=True, colorByVectorSize=True)

glyph.lighting('ambient').cmap('Blues').addScalarBar(title='wind speed')

show(glyph, __doc__, axes=True).close()
Esempio n. 7
0
'''from vedo import *
for i in range(10):
    Cone().x(i) # no variable assigned!
show(...) # show all sofar created objs
'''
from vedo import Cone, Text2D, show

for i in range(10):
    Cone().x(2 * i).color(i)  # no variable assigned

Text2D(__doc__, font='courier')

# three points, aka ellipsis, retrieves the list of all created objects
show(..., axes=1, viewup='z')
Esempio n. 8
0
"""Simulation of an optical system with lenses and mirrors of arbitrary shapes and orientations
(points mark the exit locations of photons, many from total internal reflections)"""
from vedo import Grid, Sphere, Cube, Cone, Points, show
from optics_base import Lens, Ray, Mirror, Screen  # see file ./optics_base.py
import numpy as np

# Create meshes as ordinary vedo objects
sm = Sphere(r=8).z(-8.1)
sp = Sphere(r=8).z(+8.1)
shape1 = Sphere(r=0.9, res=53).cutWithPlane().cap().rotateY(-90).pos(0, 0, 0.5)
shape2 = Cube(side=2).triangulate().boolean('-', sm).boolean("-", sp).z(3)
shape3 = Cone().rotateY(-90).z(6)
shape4 = Cube().scale([1.7, 1, 0.2]).rotateY(70).pos(-0.3, 0, 8)
shape5 = Sphere(r=2).boolean("intersect",
                             Sphere(r=2).z(3.5)).rotateX(10).pos(0.8, 0, 7.5)
shape6 = Grid(resx=1, resy=1).rotateY(-60).rotateX(30).pos(0, -1, 11)

# Build lenses (with their refractive indices), and mirrors, using those meshes
lens1 = Lens(shape1, ref_index=1.35).c("blue9")  # constant refr. index
lens2 = Lens(shape2, ref_index="glass").c("blue7")
lens3 = Lens(shape3, ref_index="glass").c("green9")
lens4 = Lens(shape4, ref_index="glass").c("purple9").lineWidth(1)
lens5 = Lens(shape5, ref_index="glass").c("orange9")
mirror = Mirror(shape6)
screen = Screen(4, 4).rotateY(20).pos(1, 0, 12)
elements = [lens1, lens2, lens3, lens4, lens5, mirror, screen]

# Generate photons and trace them through the optical elements
lines = []
source = Grid(resx=20, resy=20).points()  # a numpy array
for pt in source: