File: RubberSheet

package info (click to toggle)
dxsamples 4.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 26,348 kB
  • ctags: 1,513
  • sloc: ansic: 10,079; sh: 8,445; java: 1,772; makefile: 1,101
file content (65 lines) | stat: -rw-r--r-- 2,283 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

     // Import the data
electrondensity = Import("watermolecule");
     // Partition the data
electrondensity = Partition(electrondensity);
     // Create a camera for the data
camera = AutoCamera(electrondensity,"off-diagonal");
     // Create a cutting plane through the data. The point [1 0 -0.9] and
     // the normals [0 0 1] (the default) define the plane 
plane = MapToPlane(electrondensity,[1 0 -0.9]);
     // Color the plane based on the data values
plane = AutoColor(plane);
     // RubberSheet deforms the plane based on the data values.
rubbersheet = RubberSheet(plane);
     // Add shading using the Normals module
rubbersheet = Normals(rubbersheet);
     // Display the result
Display(rubbersheet,camera);


    // Create a maptoplane through the center of the data
plane = MapToPlane(electrondensity);
    // Post the data so that it is dependent on connections rather than 
    // upon positions
plane = Post(plane,"connections");
    // Color the plane using AutoColor
plane = AutoColor(plane);
    // Deform the colored plane using RubberSheet
deformed = RubberSheet(plane);
    // Add face-dependent normals and Display
deformed = FaceNormals(deformed);

macro movecamera(direction)
{
   camera = AutoCamera(deformed,direction,width=3);
   Display(deformed,camera);
}

direction = Direction(azimuth=50, elevation=30);
movecamera(direction);
direction = Direction(azimuth=30, elevation=30);
movecamera(direction);
direction = Direction(azimuth=10, elevation=30);
movecamera(direction);
direction = Direction(azimuth=-10, elevation=30);
movecamera(direction);


    // create an isosurface of the data
isosurface = Isosurface(electrondensity,0.3);
    // compute the gradient of the electron density and map it onto the 
    // isosurface
gradient = Gradient(electrondensity);
mapped = Map(isosurface,gradient);
    // Take the magnitude of the gradient on the isosurface
mapped = Compute("mag($0)", mapped);
    // RubberSheet the mapped isosurface, then give it an opacity < 1.0
mapped = AutoColor(mapped);
deformed = RubberSheet(mapped);
deformed = Color(deformed,opacity=0.3);
    // Collect the deformed isosurface with the original isosurface and display
collected = Collect(isosurface,deformed);
camera = AutoCamera(collected);
Display(collected,camera);