File: progu029.htm

package info (click to toggle)
dx 1%3A4.4.4-4
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 49,864 kB
  • sloc: ansic: 365,482; cpp: 156,594; sh: 13,801; java: 10,641; makefile: 2,373; awk: 444; yacc: 327
file content (169 lines) | stat: -rw-r--r-- 6,484 bytes parent folder | download | duplicates (12)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3//EN">
<HTML><HEAD>
<TITLE>IBM Visualization Data Explorer Programmer&#39;s Reference</TITLE>

<META HTTP-EQUIV="abstract" CONTENT="IBM Visualization Data Explorer
Programmer&#39;s Reference">
<META HTTP-EQUIV="contact" CONTENT="IBM Visualization Data Explorer
(ibmdx@watson.ibm.com)">
<META HTTP-EQUIV="owner" CONTENT="IBM Visualization Data Explorer
(ibmdx@watson.ibm.com)">
<META HTTP-EQUIV="updated" CONTENT="Tue, 16 Sep 1997 ">
<META HTTP-EQUIV="review" CONTENT="Fri, 14 Aug 1998 ">

<META HTTP-EQUIV="keywords" CONTENT="GRAPHICS VISUALIZATION VISUAL PROGRAM DATA
MINING">
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
</HEAD><BODY BGCOLOR="#FFFFFF">

<A NAME="Top_Of_Page"></A>
<H1>IBM Visualization Data Explorer Programmer&#39;s Reference</H1>
<B>&#91; <A HREF="#Bot_Of_Page">Bottom of Page</A> &#124; <A
HREF="progu028.htm">Previous Page</A> &#124; <A HREF="progu030.htm">Next
Page</A> &#124; <A HREF="../proguide.htm#ToC">Table of Contents</A> &#124; <A
HREF="progu028.htm#PToC8">Partial Table of Contents</A> &#124; <A
HREF="progu344.htm#HDRINDEX_START">Index</A> &#93;</B><HR><P>
<HR>
<H2><A NAME="HDREXMKX2" HREF="progu028.htm#PToC_62">6.2 MakeXEfficient Module
Example--Create New Positions</A></H2>
<A NAME="IDX239"></A>
<A NAME="IDX240"></A>
<A NAME="IDX241"></A>
<P>
The preceding example module, MakeX, manipulates regular (compactly
encoded) positions less efficiently than it might.
Note that the first call to <TT><STRONG>DXGetArrayData</STRONG></TT> in the file
<TT>makex.c</TT> expands the compact coding of regular
positions.
MakeXEfficient eliminates this expansion.
<P>
MakeXEfficient has the same two inputs as MakeX:
<TT><STRONG>data</STRONG></TT>, is of type <TT><STRONG>field</STRONG></TT> and
has
no default value;
<TT><STRONG>addend</STRONG></TT>, is of type <TT><STRONG>size</STRONG></TT>, and
has a default value of 1.
<P>
MakeXEfficient has the same output as MakeX:
<TT><STRONG>result</STRONG></TT> is of type <TT><STRONG>field</STRONG></TT>.
<P>
<B><U>Repeat Steps (1) through (5)</U></B> of the preceding example (see
<A HREF="progu028.htm#HDRMAKEX">6.1 , "MakeX Module Example--Create New
Positions"</A>), using the file name
"makexeff" in place of "makex."
Step (5) will produce files <TT>makexeff.c</TT>,
<TT>makexeff.mdf</TT>, and
<TT>makexeff.make</TT>.
<P>
<B><U>(6) Implement the MakeXEfficient function</U></B>.
MakeXEfficient uses Array-handling routines like those described in
<A HREF="progu046.htm#HDRARHAND">"Array Handling"</A>.
But the main differences from MakeX are a handle for manipulating the
input-positions Array, and a scratch buffer to hold the
coordinates of a single position (three floating-point
numbers in this example).
Note that there is no call to DXGetArrayData for a pointer to the
input-positions Array, thereby avoiding inefficiencies by
not expanding regular positions.
<P>
Edit the <TT>makexeff.c</TT> file and replace the line
<PRE>
  p_positions = (float*) DXGetArrayData(array)
</PRE>
with the following:
<PRE>
  if (!(handle = DXCreateArrayHandle(array)))
     goto error;
  scratch = DXAllocate(3*sizeof(float));
  if (!scratch)
    goto error;
</PRE>
<P>
Another necessary code change is one inside the loop labeled
"Now &quot;draw&quot; the x&#39;s" in the
<TT><STRONG>.c</STRONG></TT> file--a call to the
DXIterateArray routine to access the
current position.
Add the following pair of lines after the comment in the loop:
<PRE>
       in_ptr = (float *)DXIterateArray(handle, i, in_ptr, scratch);
       inpoint = DXPt(in_ptr&#91;0&#93;, in_ptr&#91;1&#93;, in_ptr&#91;2&#93;);
</PRE>
<P>
Of course, the handle and the scratch buffer have to be freed at
some point.
Add the following lines before the MakeXEfficient_worker code near
the end of the file:
<PRE>
/* Delete scratch and handle */
   DXFree((Pointer)scratch);
   DXFreeArrayHandle(handle);
/* return */
   return OK;
error:
/* Delete scratch and handle */
   DXFree((Pointer)scratch);
   DXFreeArrayHandle(handle);
   return ERROR;
</PRE>
<P>
Add the following lines after the first block of code in the doLeaf
routine:
<PRE>
  /* User-added declarations */
  float *scratch, *in_ptr, size;
  Point inpoint, *out_pos_ptr;
  ArrayHandle handle;
  Array connections;
  Line *conn_ptr;
</PRE>
<P>
The file <TT>/usr/local/dx/samples/program_guide/makexeff.c</TT>
contains a completed version of this program.
<P>
<B><U>(7) To create a version of Data Explorer that includes</U></B> the
MakeXEfficient module, enter the command:
<PRE>
make -f makexeff.make dxexec
</PRE>
<P>
(You have now created an executable that contains the MakeX
module.)
<P>
<B><U>(8) To invoke this version, enter&#58;</U></B>
<P>
<PRE>
dx  -mdf ./makexeff.mdf -exec ./dxexec
</PRE>
<P>
This command starts Data Explorer (the <TT><STRONG>makexeff.mdf</STRONG></TT>
file
tells the graphical user interface about MakeX and its
inputs and outputs).
The executable dxexec invoked here is the one created in Step 6.
<P>
<B><U>(9) With this version of Data Explorer</U></B> you can now run any visual
program that uses the MakeXEfficient module.
One such program is
<TT>/usr/local/dx/samples/program_guide/makex_efficient.net</TT>
<P><HR><B>&#91; <A HREF="#Top_Of_Page">Top of Page</A> &#124; <A
HREF="progu028.htm">Previous Page</A> &#124; <A HREF="progu030.htm">Next
Page</A> &#124; <A HREF="../proguide.htm#ToC">Table of Contents</A> &#124; <A
HREF="progu028.htm#PToC8">Partial Table of Contents</A> &#124; <A
HREF="progu344.htm#HDRINDEX_START">Index</A> &#93;</B> <br><b>&#91;<a
href="../allguide.htm">Data Explorer Documentation</a>&nbsp;&#124;&nbsp;<a
href="../qikguide.htm">QuickStart Guide</a>&nbsp;&#124;&nbsp;<a
href="../usrguide.htm">User&#39;s Guide</a>&nbsp;&#124;&nbsp;<a
href="../refguide.htm">User&#39;s Reference</a>&nbsp;&#124;&nbsp;<a
href="../proguide.htm">Programmer&#39;s Reference</a>&nbsp;&#124;&nbsp;<a
href="../insguide.htm">Installation and Configuration
Guide</a>&nbsp;&#93;</b><br><p><b>&#91;<a
href="http://www.research.ibm.com/dx">Data Explorer Home
Page</a>&#93;</b><p><HR ALIGN=LEFT WIDTH=600><b>&#91;<A
HREF="http://www.ibm.com/">IBM Home Page</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Orders/">Order</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Search/">Search</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Assist/">Contact IBM</A>&nbsp;&#124;&nbsp;<A
HREF="http://www.ibm.com/Legal/">Legal</A>&nbsp;&#93;</b><hr><p>
<A NAME="Bot_Of_Page"></A>
</BODY></HTML>