File: Isosurface

package info (click to toggle)
dxsamples 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 26,340 kB
  • sloc: ansic: 10,079; sh: 8,445; java: 1,772; makefile: 1,102
file content (49 lines) | stat: -rw-r--r-- 1,659 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    // Import the data
electrondensity = Import("watermolecule");
    // Partition the data
electrondensity = Partition(electrondensity);
    // Create an isosurface at a value of 0.3
isosurface = Isosurface(electrondensity,0.3);
    // Create a camera and display
camera = AutoCamera(isosurface);
Display(isosurface,camera);

    // Create three isosurfaces
isosurfaces = Isosurface(electrondensity,{0.3,0.5,0.7});
    // Make the isosurfaces translucent
isosurfaces = Color(isosurfaces,opacity=0.3);
camera = AutoCamera(isosurfaces);
Display(isosurfaces,camera);

    // Create a cutting plane using the MapToPlane module
maptoplane = MapToPlane(electrondensity);
    // Create 5 contour lines, evenly spaced between the min and max data
    // values. Color them.
contours = Isosurface(maptoplane,number=5);
contours = AutoColor(contours);
Display(contours,camera);

    // Create 5 contour lines, of our own choosing
contours = Isosurface(maptoplane,{0.2,0.3,0.34,0.4,0.5});
contours = AutoColor(contours);
Display(contours,camera);


    //  Take the gradient of the data
gradientdensity = Gradient(electrondensity);
    // Compute the magnitude of the gradient
maggradient = Compute("mag($0)",gradientdensity);
    // Map the gradient onto the isosurface
mapped = Map(isosurface,maggradient);
    // Now create contour lines on the isosurface, and color them
contours = Isosurface(mapped,number=5);
contours = AutoColor(contours);
    // Give the isosurface an opacity of 0.2
isosurface = Color(isosurface,opacity=0.2);
    // Collect the contours with the isosurface and display
collected = Collect(isosurface,contours);
Display(collected,camera);