0
# Specialized Applications
1
2
Ready-to-use specialized applications built on top of vedo for common scientific visualization tasks. These applications provide complete interactive visualization environments for specific use cases like volume slicing, isosurface browsing, morphing animations, and more.
3
4
## Capabilities
5
6
### Volume Slicing Applications
7
8
Interactive applications for exploring 3D volumetric data through various slicing and visualization techniques.
9
10
```python { .api }
11
class Slicer3DPlotter(Plotter):
12
"""
13
Generate a rendering window with interactive slicing planes for Volume data.
14
15
Parameters:
16
- volume: vedo.Volume
17
Input volume data to slice
18
- cmaps: tuple, default ("gist_ncar_r", "hot_r", "bone", "bone_r", "jet", "Spectral_r")
19
List of color maps to cycle through
20
- clamp: bool, default True
21
Clamp scalar range to reduce color mapping artifacts
22
- use_slider3d: bool, default False
23
Show 3D sliders attached along axes
24
- show_histo: bool, default True
25
Show histogram on bottom left
26
- show_icon: bool, default True
27
Show small 3D rendering icon of volume
28
- draggable: bool, default False
29
Make the 3D icon draggable
30
- at: int, default 0
31
Subwindow number to plot to
32
"""
33
def __init__(
34
self,
35
volume: vedo.Volume,
36
cmaps=("gist_ncar_r", "hot_r", "bone", "bone_r", "jet", "Spectral_r"),
37
clamp=True,
38
use_slider3d=False,
39
show_histo=True,
40
show_icon=True,
41
draggable=False,
42
at=0,
43
**kwargs,
44
): ...
45
46
class Slicer3DTwinPlotter(Plotter):
47
"""
48
Compare two volumes side-by-side with synchronized slicing controls.
49
50
Parameters:
51
- volume1: vedo.Volume
52
First volume for comparison
53
- volume2: vedo.Volume
54
Second volume for comparison
55
- clamp1: bool, default True
56
Clamp scalar range for first volume
57
- clamp2: bool, default True
58
Clamp scalar range for second volume
59
- alpha1: float, default 1.0
60
Transparency for first volume
61
- alpha2: float, default 1.0
62
Transparency for second volume
63
"""
64
def __init__(
65
self,
66
volume1: vedo.Volume,
67
volume2: vedo.Volume,
68
clamp1=True,
69
clamp2=True,
70
alpha1=1.0,
71
alpha2=1.0,
72
**kwargs,
73
): ...
74
75
class Slicer2DPlotter(Plotter):
76
"""
77
2D slice viewer with interactive controls for volume data.
78
79
Parameters:
80
- volume: vedo.Volume
81
Input volume data
82
- size: tuple, default (900, 700)
83
Window size
84
- bg: str, default "white"
85
Background color
86
- axes: int, default 7
87
Axes configuration
88
"""
89
def __init__(
90
self,
91
volume: vedo.Volume,
92
size=(900, 700),
93
bg="white",
94
axes=7,
95
**kwargs,
96
): ...
97
98
class RayCastPlotter(Plotter):
99
"""
100
Ray casting volume renderer with interactive transfer function control.
101
102
Parameters:
103
- volume: vedo.Volume
104
Input volume data
105
- bg: str, default "white"
106
Background color
107
- bg2: str, optional
108
Second background color for gradient
109
- crop: bool, default False
110
Enable cropping functionality
111
"""
112
def __init__(
113
self,
114
volume: vedo.Volume,
115
bg="white",
116
bg2=None,
117
crop=False,
118
**kwargs,
119
): ...
120
```
121
122
### Isosurface and Data Browsing
123
124
Applications for exploring scalar field data through isosurfaces and interactive browsing.
125
126
```python { .api }
127
class IsosurfaceBrowser(Plotter):
128
"""
129
Interactive browser for exploring isosurfaces at different scalar values.
130
131
Parameters:
132
- volume: vedo.Volume
133
Input volume data
134
- isovalue: float, optional
135
Initial isovalue for isosurface
136
- c: str, default "gold"
137
Isosurface color
138
- alpha: float, default 1.0
139
Isosurface transparency
140
- lego: bool, default False
141
Show lego-style visualization
142
- cmap: str, default "hot"
143
Colormap for scalar values
144
"""
145
def __init__(
146
self,
147
volume: vedo.Volume,
148
isovalue=None,
149
c="gold",
150
alpha=1.0,
151
lego=False,
152
cmap="hot",
153
delayed=False,
154
**kwargs,
155
): ...
156
157
class Browser(Plotter):
158
"""
159
Generic browser for navigating through sequences of objects or files.
160
161
Parameters:
162
- objects: list
163
List of objects or file paths to browse
164
- sliders: bool, default True
165
Show navigation sliders
166
"""
167
def __init__(
168
self,
169
objects,
170
sliders=True,
171
**kwargs,
172
): ...
173
```
174
175
### Interactive Drawing and Cutting
176
177
Applications for interactive drawing, sketching, and cutting operations on 3D objects.
178
179
```python { .api }
180
class FreeHandCutPlotter(Plotter):
181
"""
182
Interactive free-hand cutting tool for 3D meshes.
183
184
Parameters:
185
- obj: vedo.Mesh
186
Input mesh to cut
187
- splined: bool, default True
188
Use splined cutting curves
189
- font: str, default ""
190
Font for UI text
191
- alpha: float, default 1.0
192
Mesh transparency
193
"""
194
def __init__(
195
self,
196
obj: vedo.Mesh,
197
splined=True,
198
font="",
199
alpha=1.0,
200
**kwargs,
201
): ...
202
203
class SplinePlotter(Plotter):
204
"""
205
Interactive spline drawing and editing application.
206
207
Parameters:
208
- points: list, optional
209
Initial control points for spline
210
- splined: bool, default True
211
Create smooth spline curves
212
- closed: bool, default False
213
Create closed spline curves
214
- font: str, default ""
215
Font for UI elements
216
"""
217
def __init__(
218
self,
219
points=(),
220
splined=True,
221
closed=False,
222
font="",
223
**kwargs,
224
): ...
225
```
226
227
### Animation and Morphing
228
229
Applications for creating and controlling animations, morphing between shapes, and temporal data visualization.
230
231
```python { .api }
232
class MorphPlotter(Plotter):
233
"""
234
Interactive morphing animation between two or more 3D objects.
235
236
Parameters:
237
- start_mesh: vedo.Mesh
238
Starting mesh for morphing
239
- end_mesh: vedo.Mesh
240
Target mesh for morphing
241
- alpha: float, default 1.0
242
Mesh transparency
243
- lw: float, default 0.1
244
Line width for wireframe
245
"""
246
def __init__(
247
self,
248
start_mesh: vedo.Mesh,
249
end_mesh: vedo.Mesh,
250
alpha=1.0,
251
lw=0.1,
252
**kwargs,
253
): ...
254
255
class AnimationPlayer(vedo.Plotter):
256
"""
257
Player for animating sequences of 3D objects with playback controls.
258
259
Parameters:
260
- sequence: list
261
List of objects to animate
262
- fps: float, default 24
263
Frames per second for playback
264
- loop: bool, default True
265
Loop animation continuously
266
- show_controls: bool, default True
267
Show playback control buttons
268
"""
269
def __init__(
270
self,
271
sequence,
272
fps=24,
273
loop=True,
274
show_controls=True,
275
**kwargs,
276
): ...
277
278
class Animation(Plotter):
279
"""
280
Base class for creating custom animations with vedo objects.
281
282
Parameters:
283
- total_duration: float, default 2.0
284
Total animation duration in seconds
285
- time_range: tuple, default (0, 2)
286
Time range for animation
287
- show_progressbar: bool, default True
288
Show progress bar during animation
289
"""
290
def __init__(
291
self,
292
total_duration=2.0,
293
time_range=(0, 2),
294
show_progressbar=True,
295
**kwargs,
296
): ...
297
298
def fade_in(self, obj, t=None, alpha=1.0):
299
"""
300
Add fade-in effect for an object.
301
302
Parameters:
303
- obj: vedo object
304
Object to fade in
305
- t: float, optional
306
Time when fade-in completes
307
- alpha: float, default 1.0
308
Target alpha value
309
"""
310
311
def fade_out(self, obj, t=None, alpha=0.0):
312
"""
313
Add fade-out effect for an object.
314
315
Parameters:
316
- obj: vedo object
317
Object to fade out
318
- t: float, optional
319
Time when fade-out completes
320
- alpha: float, default 0.0
321
Target alpha value
322
"""
323
324
def move(self, obj, pt1, pt2, t1=None, t2=None):
325
"""
326
Animate object movement between two points.
327
328
Parameters:
329
- obj: vedo object
330
Object to move
331
- pt1: tuple
332
Starting position
333
- pt2: tuple
334
Ending position
335
- t1: float, optional
336
Start time
337
- t2: float, optional
338
End time
339
"""
340
341
def rotate(self, obj, axis, angle, t1=None, t2=None):
342
"""
343
Animate object rotation.
344
345
Parameters:
346
- obj: vedo object
347
Object to rotate
348
- axis: tuple
349
Rotation axis direction
350
- angle: float
351
Rotation angle in degrees
352
- t1: float, optional
353
Start time
354
- t2: float, optional
355
End time
356
"""
357
358
def scale(self, obj, factor, t1=None, t2=None):
359
"""
360
Animate object scaling.
361
362
Parameters:
363
- obj: vedo object
364
Object to scale
365
- factor: float
366
Scaling factor
367
- t1: float, optional
368
Start time
369
- t2: float, optional
370
End time
371
"""
372
```
373
374
### Utility Classes
375
376
Additional utility classes for specialized visualization needs.
377
378
```python { .api }
379
class Clock(vedo.Assembly):
380
"""
381
Create a clock-like visualization showing time progression.
382
383
Parameters:
384
- t: float, default 0
385
Initial time value
386
- font: str, default "Bongas"
387
Font for time display
388
- r1: float, default 0.1
389
Inner radius
390
- r2: float, default 1
391
Outer radius
392
- thickness: float, default 0.02
393
Clock hand thickness
394
"""
395
def __init__(
396
self,
397
t=0,
398
font="Bongas",
399
r1=0.1,
400
r2=1,
401
thickness=0.02,
402
c="k",
403
bc="t",
404
alpha=1,
405
ma=0.5,
406
): ...
407
408
def update(self, t):
409
"""
410
Update clock display to show new time.
411
412
Parameters:
413
- t: float
414
New time value to display
415
"""
416
```
417
418
## Usage Examples
419
420
```python
421
import vedo
422
import numpy as np
423
424
# Volume slicing application
425
volume_data = np.random.rand(50, 50, 50)
426
volume = vedo.Volume(volume_data)
427
428
# Create interactive 3D slicer
429
slicer = vedo.Slicer3DPlotter(
430
volume,
431
show_histo=True,
432
show_icon=True,
433
draggable=True
434
)
435
slicer.show()
436
437
# Compare two volumes side-by-side
438
volume1 = vedo.Volume(np.random.rand(40, 40, 40))
439
volume2 = vedo.Volume(np.random.rand(40, 40, 40) * 2)
440
441
twin_slicer = vedo.Slicer3DTwinPlotter(
442
volume1, volume2,
443
alpha1=0.8, alpha2=0.8
444
)
445
twin_slicer.show()
446
447
# Interactive isosurface browser
448
iso_browser = vedo.IsosurfaceBrowser(
449
volume,
450
c="gold",
451
alpha=0.7,
452
cmap="plasma"
453
)
454
iso_browser.show()
455
456
# Free-hand mesh cutting
457
mesh = vedo.Sphere(r=2, res=50)
458
cutter = vedo.FreeHandCutPlotter(
459
mesh,
460
splined=True,
461
alpha=0.8
462
)
463
cutter.show()
464
465
# Interactive spline drawing
466
spline_tool = vedo.SplinePlotter(
467
splined=True,
468
closed=False
469
)
470
spline_tool.show()
471
472
# Morphing animation between shapes
473
sphere = vedo.Sphere(r=1, res=50)
474
cube = vedo.Box(size=2).triangulate()
475
476
morph_app = vedo.MorphPlotter(
477
sphere, cube,
478
alpha=0.8
479
)
480
morph_app.show()
481
482
# Animation with custom effects
483
animation = vedo.Animation(total_duration=5.0)
484
485
# Create objects for animation
486
obj1 = vedo.Sphere(c='red').pos(-3, 0, 0)
487
obj2 = vedo.Box(c='blue').pos(3, 0, 0)
488
489
# Add animation effects
490
animation.fade_in(obj1, t=1.0)
491
animation.move(obj1, (-3, 0, 0), (0, 0, 0), t1=1.0, t2=3.0)
492
animation.rotate(obj2, axis=(0, 0, 1), angle=360, t1=0, t2=5.0)
493
animation.fade_out(obj2, t=4.0)
494
495
animation.show()
496
497
# Browse through sequence of objects
498
objects = [vedo.Sphere(), vedo.Box(), vedo.Cylinder(), vedo.Cone()]
499
browser = vedo.Browser(objects, sliders=True)
500
browser.show()
501
502
# Ray casting volume renderer
503
ray_caster = vedo.RayCastPlotter(
504
volume,
505
bg="black",
506
crop=True
507
)
508
ray_caster.show()
509
510
# Animation player for object sequences
511
frames = []
512
for i in range(20):
513
sphere = vedo.Sphere(r=1 + 0.1*i, c=i)
514
frames.append(sphere)
515
516
player = vedo.AnimationPlayer(
517
frames,
518
fps=10,
519
loop=True,
520
show_controls=True
521
)
522
player.show()
523
524
# 2D slice viewer
525
slice_viewer = vedo.Slicer2DPlotter(
526
volume,
527
size=(800, 600),
528
bg="white"
529
)
530
slice_viewer.show()
531
```
532
533
## Advanced Usage Patterns
534
535
```python
536
# Combining applications with custom functionality
537
import vedo
538
539
# Create volume data
540
volume = vedo.load("medical_scan.nrrd")
541
542
# Custom slicer with additional features
543
class CustomSlicer(vedo.Slicer3DPlotter):
544
def __init__(self, volume, **kwargs):
545
super().__init__(volume, **kwargs)
546
547
# Add custom measurement tools
548
self.add_measurement_tools()
549
550
# Add export functionality
551
self.add_export_buttons()
552
553
def add_measurement_tools(self):
554
# Add distance measurement tools
555
pass
556
557
def add_export_buttons(self):
558
# Add buttons for exporting slices
559
pass
560
561
# Use custom slicer
562
custom_slicer = CustomSlicer(volume, show_histo=True)
563
custom_slicer.show()
564
565
# Chain multiple applications
566
def create_analysis_pipeline(volume):
567
# First, browse isosurfaces to find interesting values
568
iso_browser = vedo.IsosurfaceBrowser(volume)
569
570
# Then use ray casting for detailed volume rendering
571
ray_caster = vedo.RayCastPlotter(volume)
572
573
# Finally, use 3D slicer for detailed examination
574
slicer = vedo.Slicer3DPlotter(volume)
575
576
return iso_browser, ray_caster, slicer
577
```