File: MakeLineMacro.net

package info (click to toggle)
dxsamples 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 26,340 kB
  • sloc: ansic: 10,079; sh: 8,445; java: 1,772; makefile: 1,102
file content (154 lines) | stat: -rw-r--r-- 6,292 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// time: Wed Feb 12 11:24:30 1997
//
// version: 3.1.1 (format), 3.1.4 (DX Beta)
//
//
// Begin MDF
// MODULE MakeLine
// CATEGORY Macros
// DESCRIPTION makes a line from two points
// INPUT data; scalar or vector or field; (none); data field
// INPUT start; value list or field or string or string list; {[0 0 0]}; starting point of line
// INPUT end; value list or field or string or string list; {[1 1 1]}; ending point of line
// INPUT density; integer list; {30}; number of points along line
// OUTPUT original_line; geometry field; a line connecting start and end
// OUTPUT newline; field; a line. position = distance along line, data = data value
// End MDF
//
// comment: This macro creates a line with data mapped onto it.  It takes as input a data field, two points defining the start and end of a line, and a number specifying how many samples to put along the line. You can see one way to use this macro by looking at the visual program "PlotLine2.net" in samples/programs.
// comment: 
// comment: The macro has two outputs. The first output is the line, which you can display in your image. The second output is the data to plot, in which the positions component contains distance along the line, and the data component contains the data values at each position. You can use this as input to the Plot module.
// workspace: width = 376, height = 615
// layout: snap = 0, width = 50, height = 50, align = CC
//
macro MakeLine(
 data
,start = {[0 0 0]}
,end = {[1 1 1]}
,density = {30}
) -> (
 original_line
,newline
) {
    // 
    // node Input[1]: x = 62, y = 1, inputs = 0, label = Input
    // parameter: position = 2, name = 'start', value = '{[0 0 0]}', descriptive = 0, description = 'starting point of line', required = 0, visible = 1
    //
MakeLine_Input_1_out_1 = start;
    // 
    // node Input[2]: x = 173, y = 0, inputs = 0, label = Input
    // parameter: position = 3, name = 'end', value = '{[1 1 1]}', descriptive = 0, description = 'ending point of line', required = 0, visible = 1
    //
MakeLine_Input_2_out_1 = end;
    // 
    // node Compute[1]: x = 86, y = 112, inputs = 3, label = Compute--finds the midpoint between start and end
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "($1 - $0)/2.0 + $0"
    // expression: value = (end - start)/2.0 + start
    // name[2]: value = start
    // name[3]: value = end
    //
MakeLine_Compute_1_out_1 = 
    Compute(
    "($1 - $0)/2.0 + $0",
    MakeLine_Input_1_out_1,
    MakeLine_Input_2_out_1
    ) [instance: 1, cache: 1];
    // 
    // node Compute[2]: x = 199, y = 113, inputs = 3, label = Compute--finds the distance from start (or end) to the midpoint
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "($1 - $0)/2.0"
    // expression: value = (end - start)/2.0
    // name[2]: value = start
    // name[3]: value = end
    //
MakeLine_Compute_2_out_1 = 
    Compute(
    "($1 - $0)/2.0",
    MakeLine_Input_1_out_1,
    MakeLine_Input_2_out_1
    ) [instance: 2, cache: 1];
    // 
    // node Input[3]: x = 334, y = 6, inputs = 0, label = Input
    // parameter: position = 4, name = 'density', value = '{30}', descriptive = 0, description = 'number of points along line', required = 0, visible = 1
    //
MakeLine_Input_3_out_1 = density;
    // 
    // node Grid[1]: x = 157, y = 213, inputs = 4, label = Grid--constructs a line from start to end with the specified number of points along it
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "line"
    //
MakeLine_Grid_1_out_1 = 
    Grid(
    MakeLine_Compute_1_out_1,
    "line",
    MakeLine_Compute_2_out_1,
    MakeLine_Input_3_out_1
    ) [instance: 1, cache: 1];
    // 
    // node Input[4]: x = 0, y = 0, inputs = 0, label = Input
    // parameter: position = 1, name = 'data', value = '(none)', descriptive = 1, description = 'data field', required = 1, visible = 1
    //
MakeLine_Input_4_out_1 = data;
    // 
    // node Map[1]: x = 62, y = 327, inputs = 4, label = Map--map the data field onto the contstructed line
    //
MakeLine_Map_1_out_1 = 
    Map(
    MakeLine_Grid_1_out_1,
    MakeLine_Input_4_out_1,
    NULL,
    NULL
    ) [instance: 1, cache: 1];
    // 
    // node Mark[1]: x = 53, y = 416, inputs = 2, label = Mark
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions"
    //
MakeLine_Mark_1_out_1 = 
    Mark(
    MakeLine_Map_1_out_1,
    "positions"
    ) [instance: 1, cache: 1];
    // 
    // node Compute[3]: x = 136, y = 454, inputs = 3, label = Compute--computes the distance along the line from the starting point
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "[sqrt(($0.x -$1.x)^2 + ($0.y - $1.y)^2 + ($0.z - $1.z)^2)]"
    // expression: value = [sqrt((a.x -start.x)^2 + (a.y - start.y)^2 + (a.z - start.z)^2)]
    // name[2]: value = a
    // name[3]: value = start
    //
MakeLine_Compute_3_out_1 = 
    Compute(
    "[sqrt(($0.x -$1.x)^2 + ($0.y - $1.y)^2 + ($0.z - $1.z)^2)]",
    MakeLine_Mark_1_out_1,
    MakeLine_Input_1_out_1
    ) [instance: 3, cache: 1];
    // 
    // node Output[2]: x = 10, y = 553, inputs = 1, label = Output
    // parameter: position = 1, name = 'original_line', value = '(NULL)', descriptive = 1, description = 'a line connecting start and end', required = 0, visible = 1
    //
original_line = MakeLine_Grid_1_out_1;
    // 
    // node Unmark[1]: x = 176, y = 528, inputs = 2, label = Unmark
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions"
    //
MakeLine_Unmark_1_out_1 = 
    Unmark(
    MakeLine_Compute_3_out_1,
    "positions"
    ) [instance: 1, cache: 1];
    // 
    // node Output[3]: x = 266, y = 553, inputs = 1, label = Output
    // parameter: position = 2, name = 'newline', value = '(NULL)', descriptive = 1, description = 'a line. position = distance along line, data = data value', required = 0, visible = 1
    //
newline = MakeLine_Unmark_1_out_1;
// network: end of macro body
}
MakeLine_Input_1_out_1 = NULL;
MakeLine_Input_2_out_1 = NULL;
MakeLine_Compute_1_out_1 = NULL;
MakeLine_Compute_2_out_1 = NULL;
MakeLine_Input_3_out_1 = NULL;
MakeLine_Grid_1_out_1 = NULL;
MakeLine_Input_4_out_1 = NULL;
MakeLine_Map_1_out_1 = NULL;
MakeLine_Mark_1_out_1 = NULL;
MakeLine_Compute_3_out_1 = NULL;
MakeLine_Unmark_1_out_1 = NULL;