home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume38 / lic / part08 < prev    next >
Text File  |  1993-08-11  |  66KB  |  1,952 lines

  1. Newsgroups: comp.sources.misc
  2. From: casey@gauss.llnl.gov (Casey Leedom)
  3. Subject: v38i111:  lic - LLNL Line Integral Convolution, v1.2, Part08/10
  4. Message-ID: <1993Aug12.013943.14381@sparky.sterling.com>
  5. X-Md4-Signature: b1562ef7ddf7e116751da1583c916bb6
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Thu, 12 Aug 1993 01:39:43 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: casey@gauss.llnl.gov (Casey Leedom)
  12. Posting-number: Volume 38, Issue 111
  13. Archive-name: lic/part08
  14. Environment: UNIX
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  lic.1.2/README lic.1.2/avs/LIC.txt
  21. #   lic.1.2/config/Makefile.config lic.1.2/liblic/ComputeImage.c
  22. #   lic.1.2/liblic/Create.c lic.1.2/liblic/LIC_Filters.3
  23. #   lic.1.2/liblic/liblic.h lic.1.2/test/ElectroStatic.c
  24. # Wrapped by kent@sparky on Wed Aug 11 19:38:07 1993
  25. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 8 (of 10)."'
  28. if test -f 'lic.1.2/README' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'lic.1.2/README'\"
  30. else
  31.   echo shar: Extracting \"'lic.1.2/README'\" \(8211 characters\)
  32.   sed "s/^X//" >'lic.1.2/README' <<'END_OF_FILE'
  33. X$Header: /d/sisal/a/casey/tmp/lic/RCS/README,v 1.10 1993/08/11 17:34:08 casey Exp $
  34. X
  35. X
  36. X          Installation notes on the LLNL LIC distribution
  37. X
  38. X
  39. X Copyright (c) 1993 The Regents of the University of California.
  40. X All rights reserved.
  41. X
  42. X Redistribution and use in source and binary forms, with or without
  43. X modification, are permitted provided that the following conditions
  44. X are met:
  45. X 1. Redistributions of source code must retain the above copyright
  46. X    notice, this list of conditions and the following disclaimer.
  47. X 2. Redistributions in binary form must reproduce the above copyright
  48. X    notice, this list of conditions and the following disclaimer in the
  49. X    documentation and/or other materials provided with the distribution.
  50. X 3. All advertising materials mentioning features or use of this software
  51. X    must display the following acknowledgement:
  52. X    This product includes software developed by the University of
  53. X    California, Lawrence Livermore National Laboratory and its
  54. X    contributors.
  55. X 4. Neither the name of the University nor the names of its contributors
  56. X    may be used to endorse or promote products derived from this software
  57. X    without specific prior written permission.
  58. X
  59. X THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  60. X ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  61. X IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  62. X ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  63. X FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  64. X DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  65. X OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  66. X HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  67. X LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  68. X OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  69. X SUCH DAMAGE.
  70. X
  71. X
  72. XWHAT IS LLNL LIC?:
  73. X
  74. X    The LLNL LIC software distribution is an implementation of the
  75. X    Line Integral Convolution algorithm.  Line Integral Convolution
  76. X    can be used to visualize vector fields and generate a variety of
  77. X    unique special effects.  For a thorough explanation of Line
  78. X    Integral Convolutions see ``Imaging Vector Fields Using Line
  79. X    Integral Convolution'' by Brian Cabral and Casey Leedom in the
  80. X    SIGGRAPH '93 proceedings.
  81. X
  82. X    This software system consists of a library that implements the LIC
  83. X    algorithm, a command line interface and an AVS coroutine module
  84. X    interface.
  85. X
  86. X
  87. XHOW TO INSTALL LIC:
  88. X
  89. X    SPECIAL NOTES TO USERS OF SIGGRAPH '93 CD-ROM:
  90. X
  91. X    Because the complete text and images of our paper is contained
  92. X    in a separate directory on the CD-ROM, there is not a copy of
  93. X    our paper in the doc subdirectory on the SIGGRAPH '93 CD-ROM.
  94. X
  95. X    Because the SIGGRAPH '93 CD-ROM is using a file system from hell,
  96. X    we've had to rename nearly every file in the source distribution.
  97. X    To get the correct names back, type the following on a UNIX
  98. X    system that supports at least 18 character names:
  99. X
  100. X        % sh FIXNAMES.SH
  101. X
  102. X    We recommend that after using FIXNAMES.SH you immediately
  103. X    remove the script in order to save yourself from any possible
  104. X    grief in the future because of an accidental execution.
  105. X
  106. X    We have made no effort to change the source to work with these
  107. X    broken names.
  108. X
  109. X    PORTABILITY:
  110. X
  111. X    Where possible, this software has been written to conform to
  112. X    ANSI C as defined in ANSI X3.159-1989 and POSIX 1003.1 as
  113. X    defined in IEEE Std 1003.1-1990.  We strayed outside of this
  114. X    goal for the command line interface which uses the Berkeley
  115. X    mmap(2) interface to map files into virtual memory.  However,
  116. X    the use of mmap is controlled via a compile-time configuration
  117. X    define, so this shouldn't pose any portability problems.
  118. X
  119. X    The command line interface also uses getopt(3) to parse its
  120. X    command line arguments.  Unfortunately getopt(3) was not
  121. X    standardized in either of the above standards, but it a
  122. X    useful and highly common facility.  If you don't have it in
  123. X    your vendor supplied system a version can be obtained from
  124. X    the GNU project.
  125. X
  126. X    At the time of this writing the software has been compiled and
  127. X    tested on HP Snakes running HP-UX 9.01, IBM RS6000s running
  128. X    AIX 3.2, SGIs running IRIX 4.0.5 and Sun Sparcs running SunOS
  129. X    4.1.1.  The previous version of the software also ran on DEC
  130. X    Alphas running OSF1 but we've lost our access to that platform
  131. X    and can't test it for this version of the software.  However, we
  132. X    don't anticipate any large problems porting the current software
  133. X    to that platform.
  134. X
  135. X    All the configuration information is contained in the file
  136. X    "config/Makefile.config."  The configuration scheme is grossly modeled
  137. X    on the X11 imake scheme, but without imake ...  (I told you it was
  138. X    gross.)
  139. X
  140. X    In any case, each directory contains two Makefiles: "Makefile" and
  141. X    "Makefile.tmpl."  The Makefile basically reinvokes make for all
  142. X    targets with roughly the following command:
  143. X
  144. X    make -f $(TOP)/config/Makefile.config \
  145. X         -f ./Makefile \
  146. X         -f $(TOP)/config/Makefile.std
  147. X
  148. X    The Makefile.tmpl contains all the real make commands to generate and
  149. X    install the contents of the current directory.
  150. X
  151. X    After editing config/Makefile.config, type the following in the
  152. X    top level directory:
  153. X
  154. X    % make clean
  155. X    % make
  156. X
  157. X    TESTING THE SYSTEM:
  158. X
  159. X    If everything went okay, you should now have a working system.  To
  160. X    test it, try the following:
  161. X
  162. X        % cd test
  163. X        % make test
  164. X
  165. X    The Makefile will generate a 256 x 256 white noise image and a
  166. X    checker board vector field.  It will then run the lic command
  167. X    against these to generate a basket weave image.
  168. X
  169. X    Once you're happy with the software and want to install it on your
  170. X    system, just type the following in the top level directory:
  171. X
  172. X    % make install
  173. X    % make clean
  174. X
  175. X
  176. XWHERE TO GO FROM HERE:
  177. X
  178. X    Hopefully the source code to the command line and AVS interfaces
  179. X    will serve as useful trivial examples.  At least we always find it
  180. X    easier to steal code than to read manual pages. :-)
  181. X
  182. X    If you find yourself overcome with an urge to read documentation,
  183. X    a complete set of manual pages has been provided.  For general
  184. X    information of the LIC algorithm and the LIC library you should
  185. X    read LIC.3.  For information on creating, manipulating and
  186. X    destroying LIC objects you should read LIC_Create.3, LIC_Change,
  187. X    LIC_Query and LIC_Destroy.3.  Finally LIC_ComputeImage.3 will
  188. X    anticlimatically tell you how you can get the library to actually
  189. X    invoke the algorithm.  Once you feel comfortable with those, you
  190. X    should probably attack LIC_Filters.3 and LIC_Convolve.3 which let
  191. X    you get at the heart of the algorithm.
  192. X
  193. X    The file ABSTRACT contains a summary abstract of this software.
  194. X    It is used by LLNL's software release program to help catalogue
  195. X    software in a standard form.  Similarly, the file MEMO is also
  196. X    part of LLNL's software release process and contains a ``memo of
  197. X    understanding'' describing why we wanted to release this software.
  198. X
  199. X    The file TODO in the top level directory contains a brief set of
  200. X    notes describing things left to finish in the implementation.
  201. X
  202. X    The directory doc/siggraph93 contains our SIGGRAPH '93 paper.
  203. X    Minimally it should should include a PostScript version of the
  204. X    paper with most of the figures missing (the full PostScript for
  205. X    our paper is 24MB!)  Depending on where you got this distribution
  206. X    from, there may also be a subdirectory "figures" which contains
  207. X    the figures for the paper.  This is a maybe because it's 6.3MB of
  208. X    compressed TIFF and EPS files and some distributors may Just Say
  209. X    No to that much cruft.
  210. X
  211. X
  212. XWHERE TO SEND CORRESPONDENCE:
  213. X
  214. X    If you have bug reports, fixes, suggestions, or just want to talk about
  215. X    the software, address your correspondence to:
  216. X
  217. X
  218. X    Brian Cabral
  219. X    Mail Stop: L-416
  220. X        Lawrence Livermore National Laboratory
  221. X        Livermore, CA
  222. X        USA
  223. X
  224. X    email: cabral1@llnl.gov
  225. X    phone: (USA) 510-423-0201
  226. X
  227. X
  228. X
  229. X        Casey Leedom
  230. X        Mail Stop: L-410
  231. X        Lawrence Livermore National Laboratory
  232. X        Livermore, CA
  233. X        USA
  234. X
  235. X        email: casey@gauss.llnl.gov
  236. X        phone: (USA) 510-423-7775
  237. END_OF_FILE
  238.   if test 8211 -ne `wc -c <'lic.1.2/README'`; then
  239.     echo shar: \"'lic.1.2/README'\" unpacked with wrong size!
  240.   fi
  241.   # end of 'lic.1.2/README'
  242. fi
  243. if test -f 'lic.1.2/avs/LIC.txt' -a "${1}" != "-c" ; then 
  244.   echo shar: Will not clobber existing file \"'lic.1.2/avs/LIC.txt'\"
  245. else
  246.   echo shar: Extracting \"'lic.1.2/avs/LIC.txt'\" \(8630 characters\)
  247.   sed "s/^X//" >'lic.1.2/avs/LIC.txt' <<'END_OF_FILE'
  248. XAVS Modules                                            LIC
  249. XLawrence Livermore National Laboratory
  250. X
  251. XNAME
  252. X     LIC - 2D Line Integral Convolution (LIC) vector field imager
  253. X
  254. XSUMMARY
  255. X     Name       LIC
  256. X
  257. X     Type       mapper
  258. X
  259. X     Inputs       field 2D 2-vector float (vector field)
  260. X               field 2D 4-vector byte (image)
  261. X
  262. X     Outputs       field 2D 4-vector 2-space byte (filtered image)
  263. X
  264. X     Parameters       
  265. X    Name                   Type         Default        Min      Max
  266. X    ---------------------------------------------------------------------
  267. X    Filter type               choice    Box        N/A       N/A
  268. X    Normalization type        choice    Variable        N/A       N/A
  269. X    Length                    integer    10              0         1000
  270. X    Frequency                    real     3.0             0.1       100.0
  271. X    Variable length filtering  toggle    off        off      on
  272. X    Variable speed filtering   toggle    off        off       on
  273. X    Animate                    toggle       off             off       on
  274. X    red               integer      -1              -1        255
  275. X    green               integer      -1              -1        255
  276. X    blue               integer      -1              -1        255
  277. X    alpha               integer      -1              -1        255
  278. X
  279. X
  280. XDESCRIPTION
  281. X     This module one-dimensionally filters the input image along local
  282. X     stream lines defined by the input vector field. The resulting
  283. X     output image appears as though it was painted using a coarse
  284. X     brush. Many options exist for modifying the behavior of the
  285. X     algorithm and thus controlling the appearance of the output image
  286. X     (see below).  Particularly noteworthy is the ripple filter option
  287. X     used in conjunction with the animate option. One can use these
  288. X     two options to animate a sequence, visualizing the flow of the
  289. X     vector field for a single time step.
  290. X
  291. X     An arbitrary RGBA image can be used as input, however white or
  292. X     band limited noise produce the most effective scientific
  293. X     visualizations.  The input image and vector field need not be the
  294. X     same size. If the input image is smaller the input vector field
  295. X     then the image is replicated and truncated to match the vector
  296. X     field dimensions. Best results occur when contrast stretching the
  297. X     output (see example 1).
  298. X
  299. X     The algorithm details and descriptions are presented in the
  300. X     SIGGRAPH '93 paper ``Imaging Vector Fields Using Line Integral
  301. X     Convolution'' by Brian Cabral and Casey Leedom.
  302. X
  303. XINPUTS
  304. X     Input field - a 2-D 2-vector float field
  305. X    A classic 2-space 2-vector field. Note that many 3-D slicing tools
  306. X    produce 2-dimensional 3-vector fields and will require using the
  307. X    extract vector module to remove one of the 3-vector components.
  308. X
  309. X     Input texture - a 2-D 4-vector byte RGBA image
  310. X    An arbitrary RGBA image. Note currently the alpha channel is
  311. X    ignored.
  312. X
  313. XPARAMETERS
  314. X
  315. X     Filter type
  316. X    Choice: Box, Ripple, Ramp or Select
  317. X    Default: Box
  318. X
  319. X    The Box filter is the default filter. The Ripple filter can be
  320. X    used for animating vector field flow for a single time step.
  321. X    The Ramp filter can be used for motion blurring and special
  322. X    effects.  The Select filter selects an approximately one pixel
  323. X    wide window near the end of the locally advected streamline.
  324. X    This can be used to produce a warp of the input texture.
  325. X
  326. X     Normalization type
  327. X    Choice: Fixed or Variable
  328. X    Default: Variable
  329. X
  330. X    Fixed normalization uses a constant value to normalize the
  331. X    output pixel intensity. This type of normalization causes
  332. X    field singularities to appear darkener.  If the vector field
  333. X    flows out of or into an edge this edge is also attenuated.
  334. X    Variable normalization normalizes the output pixel so that the
  335. X    entire image appears uniform in brightness (assuming uniform
  336. X    brightness in the input image) irrespective of any vector
  337. X    field singularities.
  338. X
  339. X     Length
  340. X    Integer
  341. X    Default: 10
  342. X
  343. X    This parameter controls the amount of blurring or the length
  344. X    of the line integral convolution. The number is given in unit
  345. X    pixels. Note that the run time of the algorithm is
  346. X    proportional to this parameter.
  347. X
  348. X     Frequency
  349. X    (only available for filter type "ripple")
  350. X    Real
  351. X    Default: 3.0
  352. X
  353. X    This parameter is only used in conjunction with the ripple
  354. X    filter.  It specifies the number cycles of the ripple filter
  355. X    over the length of the filter.  This governs the relative
  356. X    feature size of apparent motion when used with the animate
  357. X    option. Smaller values for frequency produce bigger features.
  358. X    However, low frequency values produce animations which appear
  359. X    to come in to and out of apparent focus (i.e.  the filter
  360. X    has poor frequency response).  High frequencies have better
  361. X    frequency response, but smaller apparent features.  Finally,
  362. X    the frequency response problem can also be dealt with by
  363. X    increasing the length of the filter, but this may introduce
  364. X    more blurring than desired.  There's no free lunch.
  365. X
  366. X     Variable length filtering
  367. X    Toggle
  368. X    Default: off
  369. X
  370. X    Enabling variable length filtering.  The filter length for each
  371. X    vector v will vary from 0 to Length based on the vector's
  372. X    magnitude.  This magnitude scaling is performed by finding the
  373. X    maximum magnitude vector in the input vector field, max_v, and
  374. X    then using a filter length equal to Length * ||v|| / ||max_v||.
  375. X    The filter will be dilated to match the length of the convolution.
  376. X    This prevents any visual artifacts which might occur because of
  377. X    abrupt filter truncation if the filter were not dilated.
  378. X
  379. X     Variable speed filtering
  380. X    (only available for filter type "ripple")
  381. X    Toggle
  382. X    Default: off
  383. X
  384. X    This option is used in conjunction with the ripple filter in
  385. X    animation mode. When enabled the LIC algorithm will vary
  386. X    apparent motion flow as a function of the vector field
  387. X    magnitude so that high magnitude portions of the vector field
  388. X    move faster than low magnitude parts.  This is accomplished by
  389. X    scaling the ripple filter frequency inversely by vector
  390. X    magnitudes.
  391. X
  392. X     Animate
  393. X    (only available for filter type "ripple")
  394. X    Toggle
  395. X    Default: off
  396. X
  397. X    Enabling the animate option will cause this module to produce
  398. X    LIC_ANIMATION_FRAMES animated frames showing vector field flow
  399. X    for a single time step.  The phase of the ripple filter will
  400. X    be different for each frame, varying from 0 to 2*Pi.
  401. X    LIC_ANIMATION_FRAMES is currently hardwired to 10.
  402. X
  403. X     Red, Green, Blue and Alpha
  404. X    Integer
  405. X    Default: -1
  406. X
  407. X    These RGBA values instruct the module on how to color pixels which
  408. X    map onto zero length vectors. A value of -1 instructs the
  409. X    algorithm to use the underlying texture pixel value for the given
  410. X    color channel.
  411. X
  412. XOUTPUTS
  413. X      Output image - 2D 4-vector 2-space byte field RGBA image
  414. X    The module generates the usual RGBA AVS image which can be
  415. X        displayed or otherwise manipulated.
  416. X
  417. XEXAMPLE    1
  418. X    The first example illustrates the use of the LIC module
  419. X    to visualize a 2-D vector field. Note the use of the contrast
  420. X        stretching module to produce a crisper image. Good contrast values
  421. X        are 50 and 200 for the input minimum and maximum values
  422. X        respectively.
  423. X
  424. X    READ FIELD      GENERATE NOISE
  425. X             |            |
  426. X             +----------+ |
  427. X                        | |
  428. X                        LIC
  429. X                         |
  430. X                         |
  431. X                      CONTRAST
  432. X                         |
  433. X                 +-------+------+
  434. X                 |              |
  435. X          DISPLAY IMAGE     WRITE IMAGE
  436. X
  437. XEXAMPLE    2
  438. X    This second example is the same as first except it produces a
  439. X        single time step flow animation. Note that the ripple function and
  440. X        animation options must be enabled on the LIC algorithm the number
  441. X        of frames is equal to the length of the LIC filter. The image
  442. X        viewer will allow you to view and save the animation sequence.
  443. X
  444. X    READ FIELD      GENERATE NOISE
  445. X             |            |
  446. X             +----------+ |
  447. X                        | |
  448. X                        LIC
  449. X                         |
  450. X                         |
  451. X                      CONTRAST
  452. X                         |
  453. X                    IMAGE VIEWER
  454. X       
  455. XFEATURES/BUGS
  456. X     Asynchronous button display
  457. X        When this module is invoked and the flow executive is disabled the
  458. X        animate, period, and variable speed buttons will not become visible
  459. X        upon selection of the ripple filter. In all other cases these latter
  460. X        buttons become visible upon selection of the ripple filter and become
  461. X        invisible upon selection of another filter.
  462. X
  463. XRELATED MODULES
  464. X     Generate noise
  465. X
  466. XAUTHOR
  467. X     Brian Cabral, Casey Leedom
  468. X     Lawrence Livermore National Laboratory
  469. X
  470. X     Copyright (c) 1993 The Regents of the University of California.
  471. X     All rights reserved.
  472. X
  473. X
  474. XAVS Modules                                          LIC
  475. XLawrence Livermore National Laboratory
  476. END_OF_FILE
  477.   if test 8630 -ne `wc -c <'lic.1.2/avs/LIC.txt'`; then
  478.     echo shar: \"'lic.1.2/avs/LIC.txt'\" unpacked with wrong size!
  479.   fi
  480.   # end of 'lic.1.2/avs/LIC.txt'
  481. fi
  482. if test -f 'lic.1.2/config/Makefile.config' -a "${1}" != "-c" ; then 
  483.   echo shar: Will not clobber existing file \"'lic.1.2/config/Makefile.config'\"
  484. else
  485.   echo shar: Extracting \"'lic.1.2/config/Makefile.config'\" \(5880 characters\)
  486.   sed "s/^X//" >'lic.1.2/config/Makefile.config' <<'END_OF_FILE'
  487. X#
  488. X# $Header: /d/sisal/a/casey/tmp/lic/config/RCS/Makefile.config,v 1.6 1993/08/11 17:25:35 casey Exp $
  489. X#
  490. X
  491. X# Installation targetting.  Any user commands will be installed in BINDIR,
  492. X# libraries in LIBDIR, include files in INCDIR, manual pages in MAN1DIR
  493. X# and MAN3DIR, avs modules in AVSMODDIR, avs module document in AVSDOCDIR,
  494. X# etc.
  495. X#
  496. X      DESTDIR = 
  497. X       BINDIR = $(DESTDIR)/usr/local/bin
  498. X       LIBDIR = $(DESTDIR)/usr/local/lib
  499. X       INCDIR = $(DESTDIR)/usr/local/include
  500. X
  501. X      MANROOT = $(DESTDIR)/usr/man
  502. X      MAN1DIR = $(MANROOT)/man1
  503. X      MAN1EXT = 1
  504. X      MAN3DIR = $(MANROOT)/man3
  505. X      MAN3EXT = 3
  506. X      MANDIRS = $(MAN1DIR) $(MAN3DIR)
  507. X
  508. X       AVSDIR = $(DESTDIR)/usr/avs
  509. X    AVSMODDIR = $(AVSDIR)/unsupp_mods
  510. X    AVSDOCDIR = $(AVSDIR)/unsupp_doc
  511. X
  512. X# Specify "man" for MANINSTALL if you want unformatted troff source manual
  513. X# pages installed in the above locations.  Specify "cat" if you want nroff
  514. X# formatted manual pages installed.  Specify "none" if you don't want
  515. X# manual pages installed.
  516. X#
  517. X   MANINSTALL = man
  518. X
  519. X# Protection modes to be set on various installation targets.
  520. X#
  521. X  INSTBINPROT = 555
  522. X  INSTLIBPROT = 444
  523. X  INSTINCPROT = 444
  524. X  INSTMANPROT = 444
  525. X  INSTDOCPROT = 444
  526. X
  527. X# Specify "avs" for AVS below if you have AVS and you want to build an AVS
  528. X# LIC module.
  529. X#
  530. X# AVSLIBDIR is where AVS support libraries can be found.  AVS_INCLUDES are
  531. X# -I include definitions that point to the AVS include directories.
  532. X# AVS_DEFINES should include any special defines needed to compile AVS
  533. X# coroutine modules on your system.  AVS_EXTRALIBS should contain any extra
  534. X# library definitions needed to link AVS coroutine modules on your system.
  535. X#
  536. X# Using AVS 4.0 (under IBM AIX 3.2), we didn't need any special AVS_DEFINES
  537. X# or AVS_EXTRALIBS.
  538. X#
  539. X# Using AVS 5.0 (under SGI IRIX 4.0.5), AVS_DEFINES should contain
  540. X# -DNeedFunctionPrototypes=1 and AVS_EXTRALIBS needs to contain -lsun.
  541. X#
  542. X          AVS = 
  543. X
  544. X    AVSLIBDIR = $(AVSDIR)/lib
  545. X AVS_INCLUDES = -I$(AVSDIR)/include
  546. X  AVS_DEFINES = 
  547. XAVS_EXTRALIBS = 
  548. X
  549. X
  550. X# Algorithm configuration.  IMAGE_DEFINES should define one of the following
  551. X# (yes, this should all be handled dynamically at run-time, but we ran out
  552. X# of time):
  553. X#
  554. X#    ARGB, ABGR, RGBA, BGRA -- four byte pixels:  alpha, red, green and blue
  555. X#    RGB, BGR               -- three byte pixels: red, green and blue
  556. X#    MONOCHROME             -- one byte pixels:   grey scale
  557. X#
  558. XIMAGE_DEFINES = -DMONOCHROME
  559. X
  560. X# Setting MMAP_DEFINES to -DHAS_MMAP will cause the lic(1) command to use mmap
  561. X# calls to map its input and output files directly into its address space.
  562. X# If HAS_MMAP is not defined lic(1) will malloc memory for the input and
  563. X# output files.  Using mmap has the advantage that it won't require space
  564. X# on swap for the potentially very large images and also saves on pointless
  565. X# I/O to swap.
  566. X#
  567. X MMAP_DEFINES = -DHAS_MMAP
  568. X
  569. X# Standard compilation environment definitions:
  570. X#
  571. X#  ***  Note that neither DEFINES nor INCLUDES should be used below.  They
  572. X#  ***  are present for the benefit of various Makefile.tmpl files to add
  573. X#  ***  includes and defines to the standard CFLAGS macro.
  574. X#
  575. X# DEC OSF1(alpha)
  576. X#   1.    STD_DEFINES should contain -std1.
  577. X#   2.    CDEBUGFLAGS should contain -g or -O (or -O2) depending on your
  578. X#    debugging/performance needs.
  579. X#   3.    Set RANLIB to ranlib.
  580. X#
  581. X# HP-UX 9.01(snake)
  582. X#   1.    STD_DEFINES should contain -Aa, -D_INCLUDE_XOPEN_SOURCE,
  583. X#    -D_INCLUDE_POSIX_SOURCE and -DHAS_HP_GETOPT.  Unfortunately getopt(3)
  584. X#    wasn't part of either the ANSI C X3.159-1989 or POSIX 1003.1-1990
  585. X#    standards.  HP has chosen a prototype for getopt that is in conflict
  586. X#    with everyone else's.
  587. X#   2.    Set RANLIB to /bin/true.
  588. X#   3.    Wasn't able to use mmap even though it linked successfully.  You may
  589. X#    have to remove -DHAS_MMAP from MMAP_DEFINES above.
  590. X#
  591. X# IBM AIX 3.2(rs/6000):
  592. X#   1.    STD_DEFINES should contain -qlanglvl=ansi and -D_ALL_SOURCE.
  593. X#   2.    CDEBUGFLAGS should contain -qsrcmsg. It should probably also contain
  594. X#    -qextchk, but that causes the loader to complain about not being able
  595. X#    to resolve references to LIC_Convolve_2D and LIC_Convolve_3D.
  596. X#    CDEBUGFLAGS should also probably contain -g or -O depending on your
  597. X#    debugging/performance needs.
  598. X#   3.    Set RANLIB to /bin/true.
  599. X#
  600. X# SGI IRIX 4.0.5(mips):
  601. X#   1.    CDEBUGFLAGS should contain -prototypes in order to get C function
  602. X#    prototype checking.  CDEBUGFLAGS should also probably contain -g
  603. X#    or -O depending on your debugging/performance needs.
  604. X#   2.    Set RANLIB to /bin/true.
  605. X#
  606. X# SUN OS 4.1.1(sparc):
  607. X#   1.    CC should be an ANSI C compiler like gcc or Sun's unbundled compiler.
  608. X#    Sun's bundled compiler won't work.
  609. X#   2.    If gcc is used, you'll probably have to add -I/usr/include to
  610. X#    STD_INCLUDES because gcc seems to search its own local include
  611. X#    directory before /usr/include which leads to all sorts of problems.
  612. X#   3.    STD_DEFINES needs -DNEED_STRERROR, -DNEED_EXIT_CODES and
  613. X#    -DHAS_OLD_TIMES.  Sun OS 4.1.1 fails to supply the ANSI C X3.159-1989
  614. X#    strerror routine and the EXIT_SUCCESS and EXIT_FAILURE defines.  Its
  615. X#    version of the times(2) call also doesn't conform to the POSIX
  616. X#    definition; it returns 0 on success instead of a monotonically
  617. X#    increasing wall clock time.
  618. X#   4.    CDEBUGFLAGS should also probably contain -g or -O depending on your
  619. X#    debugging/performance needs.
  620. X#   5.    Set RANLIB to ranlib.
  621. X#
  622. X  BUILDINCTOP = $(TOP)/include
  623. X    LIBLICDIR = $(TOP)/liblic
  624. X       LIBLIC = $(LIBLICDIR)/liblic.a
  625. X
  626. X           CC = cc
  627. X STD_INCLUDES = -I.
  628. X TOP_INCLUDES = -I$(BUILDINCTOP)
  629. X     INCLUDES = 
  630. X  ALLINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  631. X  STD_DEFINES = 
  632. X      DEFINES = 
  633. X   ALLDEFINES = $(STD_DEFINES) $(DEFINES)
  634. X  CDEBUGFLAGS = -O -prototypes
  635. X       CFLAGS = $(CDEBUGFLAGS) $(ALLDEFINES) $(ALLINCLUDES)
  636. X
  637. X# Various programs we use ...
  638. X#
  639. X           AR = ar cq
  640. X        NROFF = nroff
  641. X       RANLIB = /bin/true
  642. X        SHELL = /bin/sh
  643. X        STRIP = strip
  644. END_OF_FILE
  645.   if test 5880 -ne `wc -c <'lic.1.2/config/Makefile.config'`; then
  646.     echo shar: \"'lic.1.2/config/Makefile.config'\" unpacked with wrong size!
  647.   fi
  648.   # end of 'lic.1.2/config/Makefile.config'
  649. fi
  650. if test -f 'lic.1.2/liblic/ComputeImage.c' -a "${1}" != "-c" ; then 
  651.   echo shar: Will not clobber existing file \"'lic.1.2/liblic/ComputeImage.c'\"
  652. else
  653.   echo shar: Extracting \"'lic.1.2/liblic/ComputeImage.c'\" \(5991 characters\)
  654.   sed "s/^X//" >'lic.1.2/liblic/ComputeImage.c' <<'END_OF_FILE'
  655. X/*
  656. X * $Header: /d/sisal/a/casey/tmp/lic/liblic/RCS/ComputeImage.c,v 1.9 1993/07/28 18:54:58 casey Exp $
  657. X */
  658. X
  659. X/*
  660. X * Copyright (c) 1993 The Regents of the University of California.
  661. X * All rights reserved.
  662. X *
  663. X * Redistribution and use in source and binary forms, with or without
  664. X * modification, are permitted provided that the following conditions
  665. X * are met:
  666. X * 1. Redistributions of source code must retain the above copyright
  667. X *    notice, this list of conditions and the following disclaimer.
  668. X * 2. Redistributions in binary form must reproduce the above copyright
  669. X *    notice, this list of conditions and the following disclaimer in the
  670. X *    documentation and/or other materials provided with the distribution.
  671. X * 3. All advertising materials mentioning features or use of this software
  672. X *    must display the following acknowledgement:
  673. X *    This product includes software developed by the University of
  674. X *    California, Lawrence Livermore National Laboratory and its
  675. X *    contributors.
  676. X * 4. Neither the name of the University nor the names of its contributors
  677. X *    may be used to endorse or promote products derived from this software
  678. X *    without specific prior written permission.
  679. X *
  680. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  681. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  682. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  683. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  684. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  685. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  686. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  687. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  688. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  689. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  690. X * SUCH DAMAGE.
  691. X */
  692. X
  693. X#ifndef lint
  694. X    static char rcsid[] = "$Header: /d/sisal/a/casey/tmp/lic/liblic/RCS/ComputeImage.c,v 1.9 1993/07/28 18:54:58 casey Exp $";
  695. X    static char copyright[] =
  696. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  697. X    "All rights reserved.\n";
  698. X#endif
  699. X
  700. X
  701. X#include "liblic.h"
  702. X
  703. X
  704. X/*
  705. X *    Perform Line Integral Convolution (LIC) on a LIC instance.
  706. X *    ==========================================================
  707. X */
  708. X
  709. X
  710. X#ifdef DEBUG
  711. XFILE *ps;
  712. X#endif
  713. X
  714. X
  715. X/*
  716. X *    Main code for top-level LIC computation.
  717. X *    ========================================
  718. X */
  719. X
  720. X
  721. Xvoid
  722. XLIC_ComputeImage(LIC *This)
  723. X    /*
  724. X     * Compute LIC for each vector in input vector field.
  725. X     */
  726. X{
  727. X    REGISTER int      i, j, k;
  728. X
  729. X#   ifdef DEBUG
  730. X    ps = fopen("tmp.ps", "r+");
  731. X    if (ps == NULL)
  732. X    {
  733. X        perror("tmp.ps");
  734. X        exit(1);
  735. X    }
  736. X#   endif
  737. X
  738. X    /*
  739. X     * Loop over the vector field rendering a pixel per field vector.
  740. X     */
  741. X    for (k = 0; k < This->OutputImage.Zres; k++)
  742. X    {
  743. X    /* Update status every slice for volume */
  744. X    if (This->OutputImage.Zres > 1)
  745. X        if (This->UpdateUser)
  746. X        This->UpdateUser(100.0 *  k / (float)This->OutputImage.Zres);
  747. X
  748. X    for (j = 0; j < This->OutputImage.Yres; j++)
  749. X    {
  750. X        /* Update status every 10 scan lines for 2D fields */
  751. X        if (This->OutputImage.Zres == 1 && j % 10 == 0)
  752. X        if (This->UpdateUser)
  753. X            This->UpdateUser(100.0 *  j / (float)This->OutputImage.Yres);
  754. X
  755. X        for (i = 0; i < This->OutputImage.Xres; i++)
  756. X        {
  757. X        double ForewardKernelArea, BackwardKernelArea;
  758. X        double rForewardIntegral, gForewardIntegral,
  759. X               bForewardIntegral, aForewardIntegral;
  760. X        double rBackwardIntegral, gBackwardIntegral,
  761. X               bBackwardIntegral, aBackwardIntegral;
  762. X
  763. X        if (This->OutputImage.Zres == 1)
  764. X        {
  765. X            LIC_Convolve2D(This, i, j, LIC_FOREWARD,
  766. X                   &rForewardIntegral, &gForewardIntegral,
  767. X                   &bForewardIntegral, &aForewardIntegral,
  768. X                   &ForewardKernelArea);
  769. X            LIC_Convolve2D(This, i, j, LIC_BACKWARD,
  770. X                   &rBackwardIntegral, &gBackwardIntegral,
  771. X                   &bBackwardIntegral, &aBackwardIntegral,
  772. X                   &BackwardKernelArea);
  773. X        }
  774. X        else
  775. X        {
  776. X            LIC_Convolve3D(This, i, j, k, LIC_FOREWARD,
  777. X                   &rForewardIntegral, &gForewardIntegral,
  778. X                   &bForewardIntegral, &aForewardIntegral,
  779. X                   &ForewardKernelArea);
  780. X            LIC_Convolve3D(This, i, j, k, LIC_BACKWARD,
  781. X                   &rBackwardIntegral, &gBackwardIntegral,
  782. X                   &bBackwardIntegral, &aBackwardIntegral,
  783. X                   &BackwardKernelArea);
  784. X        }
  785. X
  786. X#        if (PixelSize >= 3)
  787. X        {
  788. X            double red, green, blue;
  789. X
  790. X            red   = (rForewardIntegral + rBackwardIntegral)
  791. X            / (ForewardKernelArea + BackwardKernelArea);
  792. X            green = (gForewardIntegral + gBackwardIntegral)
  793. X            / (ForewardKernelArea + BackwardKernelArea);
  794. X            blue  = (bForewardIntegral + bBackwardIntegral)
  795. X            / (ForewardKernelArea + BackwardKernelArea);
  796. X
  797. X            /* k is 0 for 2D case ... */
  798. X            RED  (INDEX_3D(This->OutputImage, i, j, k)) = CLAMP(red);
  799. X            GREEN(INDEX_3D(This->OutputImage, i, j, k)) = CLAMP(green);
  800. X            BLUE (INDEX_3D(This->OutputImage, i, j, k)) = CLAMP(blue);
  801. X        }
  802. X#        endif
  803. X#        if (PixelSize == 4 || PixelSize == 1)
  804. X        {
  805. X            double alpha;
  806. X
  807. X            alpha = (aForewardIntegral + aBackwardIntegral)
  808. X            / (ForewardKernelArea + BackwardKernelArea);
  809. X
  810. X            ALPHA(INDEX_3D(This->OutputImage, i, j, k)) = CLAMP(alpha);
  811. X        }
  812. X#        endif
  813. X
  814. X#        ifdef DEBUG
  815. X            if (ThisPixel)
  816. X            {
  817. X            int a, b;
  818. X
  819. X            fprintf(ps,  "stroke\n");
  820. X            fprintf(ps,  "} def\n");
  821. X            fprintf(ps,  "25 25 scale\n");
  822. X            fprintf(ps,  "0.01 setlinewidth\n");
  823. X            fprintf(ps,  "11 11 translate\n");
  824. X            fprintf(ps,  "verticals\nhorizontals\n");
  825. X            fprintf(ps,  "0.02 setlinewidth\n");
  826. X            fprintf(ps,  "0.5 -0.5 translate\n");
  827. X
  828. X            for (a = i - 10; a < i + 10; a++)
  829. X            {
  830. X                for (b = j - 10; b < j + 10; b++)
  831. X                {
  832. X                fprintf(ps,  "%f %f %d %d arrow\n",
  833. X                    INDEX_2D(This->NormalField, a, b)[1],
  834. X                    INDEX_2D(This->NormalField, a, b)[0],
  835. X                    a-i, b-j);
  836. X                }
  837. X            }
  838. X            fprintf(ps,  "streamlines\n");
  839. X            fprintf(ps,  "grestore\n");
  840. X            fprintf(ps,  "showpage\n");
  841. X            fclose(ps);
  842. X            }
  843. X#        endif
  844. X        }
  845. X    }
  846. X    }
  847. X}
  848. END_OF_FILE
  849.   if test 5991 -ne `wc -c <'lic.1.2/liblic/ComputeImage.c'`; then
  850.     echo shar: \"'lic.1.2/liblic/ComputeImage.c'\" unpacked with wrong size!
  851.   fi
  852.   # end of 'lic.1.2/liblic/ComputeImage.c'
  853. fi
  854. if test -f 'lic.1.2/liblic/Create.c' -a "${1}" != "-c" ; then 
  855.   echo shar: Will not clobber existing file \"'lic.1.2/liblic/Create.c'\"
  856. else
  857.   echo shar: Extracting \"'lic.1.2/liblic/Create.c'\" \(8493 characters\)
  858.   sed "s/^X//" >'lic.1.2/liblic/Create.c' <<'END_OF_FILE'
  859. X/*
  860. X * $Header: /d/sisal/a/casey/tmp/lic/liblic/RCS/Create.c,v 1.5 1993/07/28 18:54:58 casey Exp $
  861. X */
  862. X
  863. X/*
  864. X * Copyright (c) 1993 The Regents of the University of California.
  865. X * All rights reserved.
  866. X *
  867. X * Redistribution and use in source and binary forms, with or without
  868. X * modification, are permitted provided that the following conditions
  869. X * are met:
  870. X * 1. Redistributions of source code must retain the above copyright
  871. X *    notice, this list of conditions and the following disclaimer.
  872. X * 2. Redistributions in binary form must reproduce the above copyright
  873. X *    notice, this list of conditions and the following disclaimer in the
  874. X *    documentation and/or other materials provided with the distribution.
  875. X * 3. All advertising materials mentioning features or use of this software
  876. X *    must display the following acknowledgement:
  877. X *    This product includes software developed by the University of
  878. X *    California, Lawrence Livermore National Laboratory and its
  879. X *    contributors.
  880. X * 4. Neither the name of the University nor the names of its contributors
  881. X *    may be used to endorse or promote products derived from this software
  882. X *    without specific prior written permission.
  883. X *
  884. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  885. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  886. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  887. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  888. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  889. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  890. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  891. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  892. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  893. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  894. X * SUCH DAMAGE.
  895. X */
  896. X
  897. X#ifndef lint
  898. X    static char rcsid[] = "$Header: /d/sisal/a/casey/tmp/lic/liblic/RCS/Create.c,v 1.5 1993/07/28 18:54:58 casey Exp $";
  899. X    static char copyright[] =
  900. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  901. X    "All rights reserved.\n";
  902. X#endif
  903. X
  904. X
  905. X#include "liblic.h"
  906. X
  907. X
  908. X/*
  909. X *    Create a LIC instance.
  910. X *    ======================
  911. X */
  912. X
  913. X
  914. X/*
  915. X * Local support routines.
  916. X */
  917. Xstatic void   NormalizeVectorField(LIC_VectorField *This);
  918. Xstatic double FindMaxVectorField(LIC_VectorField *This);
  919. X
  920. X
  921. XLIC *
  922. XLIC_Create(unsigned char *InputImage,
  923. X       int            iiXres,
  924. X       int            iiYres,
  925. X       int            iiZres,
  926. X       float         *InputField,
  927. X       int            ifXres,
  928. X       int            ifYres,
  929. X       int            ifZres,
  930. X       unsigned char *OutputImage,
  931. X       LIC_Filter     Filter,
  932. X       int            NormalizationType,
  933. X       int            Normalized,
  934. X       double         Length,
  935. X       double         Frequency,
  936. X       int            VariableLength,
  937. X       int            VariableSpeed,
  938. X       int            DefaultRed,
  939. X       int            DefaultGreen,
  940. X       int            DefaultBlue,
  941. X       int            DefaultAlpha,
  942. X       void        (*UpdateUser)(double),
  943. X       void        (*ReportError)(const char *))
  944. X    /*
  945. X     * Create a LIC instance variable, allocate and initialize various
  946. X     * substructures and return a pointer to the new instance.  If
  947. X     * memory can't be allocated for the new instance, return NULL.
  948. X     */
  949. X{
  950. X    LIC *This;
  951. X
  952. X    This = (LIC *)malloc(sizeof(LIC));
  953. X    if (This == NULL)
  954. X    {
  955. X    if (ReportError != NULL)
  956. X        ReportError("LIC__Create: Unable to allocate memory for LIC"
  957. X            " instance variable");
  958. X    return(NULL);
  959. X    }
  960. X
  961. X    /*
  962. X     * Copy constructor arguments into new instance variable.
  963. X     */
  964. X
  965. X    This->InputImage.data = InputImage;
  966. X    This->InputImage.Xres = iiXres;
  967. X    This->InputImage.Yres = iiYres;
  968. X    This->InputImage.Zres = iiZres;
  969. X    This->InputImage.Rank = PixelSize;
  970. X
  971. X    This->InputField.data = InputField;
  972. X    This->InputField.Xres = ifXres;
  973. X    This->InputField.Yres = ifYres;
  974. X    This->InputField.Zres = ifZres;
  975. X    This->InputField.Rank = (ifZres == 1) ? 2 : 3;
  976. X
  977. X    /*
  978. X     * Create normalized version of input vector field if it isn't already
  979. X     * normalized.  Should probably check to see if field is *really*
  980. X     * normalized, but there's only so much hand-holding you can do ...
  981. X     */
  982. X    This->NormalField = This->InputField;
  983. X    if (!Normalized)
  984. X    {
  985. X    size_t fsize =
  986. X        sizeof(float) * This->NormalField.Rank
  987. X        * ifXres * ifYres * ifZres;
  988. X
  989. X    This->NormalField.data = (float *)malloc(fsize);
  990. X    if (This->NormalField.data == NULL)
  991. X    {
  992. X        if (ReportError)
  993. X        ReportError("LIC_Create: Unable to allocate memory for"
  994. X                " normalized input vector field");
  995. X        free(This);
  996. X        return(NULL);
  997. X    }
  998. X    memcpy(This->NormalField.data, This->InputField.data, fsize);
  999. X    NormalizeVectorField(&This->NormalField);
  1000. X    }
  1001. X
  1002. X    /*
  1003. X     * Create an output image buffer if the user didn't hand us one.
  1004. X     */
  1005. X    if (OutputImage)
  1006. X    {
  1007. X    This->OutputImage.data = OutputImage;
  1008. X    This->FreeOutput = FALSE;
  1009. X    }
  1010. X    else
  1011. X    {
  1012. X    size_t isize =
  1013. X        sizeof(unsigned char) * PixelSize
  1014. X        * ifXres * ifYres * ifZres;
  1015. X
  1016. X    This->OutputImage.data = (unsigned char *)malloc(isize);
  1017. X    if (This->OutputImage.data == NULL)
  1018. X    {
  1019. X        if (ReportError)
  1020. X        ReportError("LIC_Create: Unable to allocate memory for"
  1021. X                " output image");
  1022. X        if (!This->Normalized)
  1023. X        free(This->NormalField.data);
  1024. X        free(This);
  1025. X        return(NULL);
  1026. X    }
  1027. X    This->FreeOutput = TRUE;
  1028. X    }
  1029. X
  1030. X    This->OutputImage.Xres  = ifXres;
  1031. X    This->OutputImage.Yres  = ifYres;
  1032. X    This->OutputImage.Zres  = ifZres;
  1033. X    This->OutputImage.Rank  = PixelSize;
  1034. X
  1035. X    This->Filter            = Filter;
  1036. X    This->NormalizationType = NormalizationType;
  1037. X    This->Normalized        = Normalized;
  1038. X    This->Length            = (Length < 0.0) ? 0.0 : Length;
  1039. X    This->Frequency         = (Frequency <= 0.0) ? 1e-6 : Frequency;
  1040. X    This->VariableLength    = VariableLength;
  1041. X    This->VariableSpeed     = VariableSpeed;
  1042. X
  1043. X#define SCLAMP(x) (((x) > 255) ? 255 : (((x) < -1) ?  0 : (x)))
  1044. X    This->DefaultRed        = SCLAMP(DefaultRed);
  1045. X    This->DefaultGreen      = SCLAMP(DefaultGreen);
  1046. X    This->DefaultBlue       = SCLAMP(DefaultBlue);
  1047. X    This->DefaultAlpha      = SCLAMP(DefaultAlpha);
  1048. X#undef SCLAMP
  1049. X
  1050. X    This->UpdateUser        = UpdateUser;
  1051. X    This->ReportError       = ReportError;
  1052. X
  1053. X    This->Phase             = 0.0;
  1054. X
  1055. X    if (This->VariableLength || This->VariableSpeed) {
  1056. X    This->MaxLength = FindMaxVectorField(&This->InputField);
  1057. X    if (This->MaxLength == 0.0)
  1058. X        This->MaxLength = 1.0;    /* don't want to divide by 0 */
  1059. X    }
  1060. X    else
  1061. X    This->MaxLength = 0.0;    /* unused in this case */
  1062. X    This->NeedIntegration   = TRUE;
  1063. X
  1064. X    This->TotalLength       = 0.0;
  1065. X    This->TotalLoopCount    = 0;
  1066. X
  1067. X    return(This);
  1068. X}
  1069. X
  1070. X
  1071. Xstatic void
  1072. XNormalizeVectorField(LIC_VectorField *This)
  1073. X{
  1074. X    if (This->Zres == 1)
  1075. X    {
  1076. X    REGISTER int i, j;
  1077. X
  1078. X    for (j = 0; j < This->Yres; j++)
  1079. X        for (i = 0; i < This->Xres; i++)
  1080. X        {
  1081. X        REGISTER double fx, fy, mag;
  1082. X
  1083. X        fx = INDEX_2D(*This, i, j)[0];
  1084. X        fy = INDEX_2D(*This, i, j)[1];
  1085. X        mag = sqrt(fx*fx + fy*fy);
  1086. X        if (mag != 0)
  1087. X        {
  1088. X            INDEX_2D(*This, i, j)[0] /= mag;
  1089. X            INDEX_2D(*This, i, j)[1] /= mag;
  1090. X        }
  1091. X        }
  1092. X    }
  1093. X    else
  1094. X    {
  1095. X    REGISTER int i, j, k;
  1096. X
  1097. X    for (k = 0; k < This->Zres; k++)
  1098. X        for (j = 0; j < This->Yres; j++)
  1099. X        for (i = 0; i < This->Xres; i++)
  1100. X        {
  1101. X            REGISTER double fx, fy, fz, mag;
  1102. X
  1103. X            fx = INDEX_3D(*This, i, j, k)[0];
  1104. X            fy = INDEX_3D(*This, i, j, k)[1];
  1105. X            fz = INDEX_3D(*This, i, j, k)[2];
  1106. X            mag = sqrt(fx*fx + fy*fy + fz*fz);
  1107. X            if (mag != 0)
  1108. X            {
  1109. X            INDEX_3D(*This, i, j, k)[0] /= mag;
  1110. X            INDEX_3D(*This, i, j, k)[1] /= mag;
  1111. X            INDEX_3D(*This, i, j, k)[2] /= mag;
  1112. X            }
  1113. X        }
  1114. X    }
  1115. X}
  1116. X
  1117. X
  1118. Xstatic double
  1119. XFindMaxVectorField(LIC_VectorField *This)
  1120. X{
  1121. X    REGISTER double max;
  1122. X
  1123. X    max = 0.0;
  1124. X    if (This->Zres == 1)
  1125. X    {
  1126. X    REGISTER double mag;
  1127. X    REGISTER int    i, j;
  1128. X
  1129. X    for (j = 0; j < This->Yres; j++)
  1130. X        for (i = 0; i < This->Xres; i++)
  1131. X        {
  1132. X        mag = sqrt(  SQUARE(INDEX_2D(*This, i, j)[0])
  1133. X               + SQUARE(INDEX_2D(*This, i, j)[1]));
  1134. X        if (mag > max)
  1135. X            max = mag;
  1136. X        }
  1137. X    }
  1138. X    else
  1139. X    {
  1140. X    REGISTER double mag;
  1141. X    REGISTER int    i, j, k;
  1142. X
  1143. X    for (k = 0; k < This->Yres; k++)
  1144. X        for (j = 0; j < This->Yres; j++)
  1145. X        for (i = 0; i < This->Xres; i++)
  1146. X        {
  1147. X            mag = sqrt(  SQUARE(INDEX_3D(*This, i, j, k)[0])
  1148. X                   + SQUARE(INDEX_3D(*This, i, j, k)[1])
  1149. X                   + SQUARE(INDEX_3D(*This, i, j, k)[2]));
  1150. X            if (mag > max)
  1151. X            max = mag;
  1152. X        }
  1153. X    }
  1154. X    return(max);
  1155. X}
  1156. END_OF_FILE
  1157.   if test 8493 -ne `wc -c <'lic.1.2/liblic/Create.c'`; then
  1158.     echo shar: \"'lic.1.2/liblic/Create.c'\" unpacked with wrong size!
  1159.   fi
  1160.   # end of 'lic.1.2/liblic/Create.c'
  1161. fi
  1162. if test -f 'lic.1.2/liblic/LIC_Filters.3' -a "${1}" != "-c" ; then 
  1163.   echo shar: Will not clobber existing file \"'lic.1.2/liblic/LIC_Filters.3'\"
  1164. else
  1165.   echo shar: Extracting \"'lic.1.2/liblic/LIC_Filters.3'\" \(7610 characters\)
  1166.   sed "s/^X//" >'lic.1.2/liblic/LIC_Filters.3' <<'END_OF_FILE'
  1167. X.\" Copyright (c) 1993 The Regents of the University of California.
  1168. X.\" All rights reserved.
  1169. X.\"
  1170. X.\" Redistribution and use in source and binary forms, with or without
  1171. X.\" modification, are permitted provided that the following conditions
  1172. X.\" are met:
  1173. X.\" 1. Redistributions of source code must retain the above copyright
  1174. X.\"    notice, this list of conditions and the following disclaimer.
  1175. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1176. X.\"    notice, this list of conditions and the following disclaimer in the
  1177. X.\"    documentation and/or other materials provided with the distribution.
  1178. X.\" 3. All advertising materials mentioning features or use of this software
  1179. X.\"    must display the following acknowledgement:
  1180. X.\"    This product includes software developed by the University of
  1181. X.\"    California, Lawrence Livermore National Laboratory and its
  1182. X.\"    contributors.
  1183. X.\" 4. Neither the name of the University nor the names of its contributors
  1184. X.\"    may be used to endorse or promote products derived from this software
  1185. X.\"    without specific prior written permission.
  1186. X.\"
  1187. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1188. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1189. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1190. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1191. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1192. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1193. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1194. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1195. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1196. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1197. X.\" SUCH DAMAGE.
  1198. X.\"
  1199. X.de Hd
  1200. X.ds Dt \\$4
  1201. X..
  1202. X.Hd $Header: /d/sisal/a/casey/tmp/lic/liblic/RCS/LIC_Filters.3,v 1.7 1993/08/10 23:35:32 casey Exp $
  1203. X.TH LIC_FILTERS 3 \*(Dt
  1204. X.SH NAME
  1205. XLIC_BuildIntegralTables, LIC_Box, LIC_Ripple, LIC_Ramp, LIC_Select \- Line Integral Convolution filter support
  1206. X.SH SYNOPSIS
  1207. X.nf
  1208. X#include <lic.h>
  1209. X
  1210. Xvoid \fBLIC_BuildIntegralTables\fP(LIC *\fIThis\fP)
  1211. Xdouble \fBLIC_Box\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1212. Xdouble \fBLIC_Ripple\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1213. Xdouble \fBLIC_Ramp\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1214. Xdouble \fBLIC_Select\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1215. X.fi
  1216. X.SH DESCRIPTION
  1217. X.if t .ds pi \(*p
  1218. X.if n .ds pi Pi
  1219. X.B LIC_BuildIntegralTables
  1220. Xbuilds tables of filter integral values for use in the LIC convolution
  1221. Xmethods.
  1222. X.B LIC_BuildIntegralTables
  1223. Xis automatically called by the convolution methods whenever any parameters
  1224. Xhave changed that will affect the filter integrals.
  1225. X.PP
  1226. XThe tables are discrete samples of the filter function integral for a
  1227. Xvariety of points along the filter kernel and for a variety of
  1228. X.IR speeds .
  1229. X.PP
  1230. XThe
  1231. X.I speed
  1232. Xvariations are used to implement the variable speed option of
  1233. X.BR LIC_Create .
  1234. XWith the variable speed option, high magnitude regions of the field will
  1235. Xuse higher
  1236. X.I speed
  1237. Xversions of the filter kernel.  These higher speeds variations are typically
  1238. Xfrequency scaled versions of the base frequency and are used in periodic
  1239. Xmotion animations to give the appearance of higher speed in higher magnitude
  1240. Xregions of the vector field.
  1241. XHowever, it is up to each filter integral function to implement its own
  1242. Xinterpretation of
  1243. X.I speed
  1244. X(see
  1245. X.B LIC_Ripple
  1246. Xbelow).
  1247. X.PP
  1248. XThe tables are broken up into integral values for the
  1249. Xpositive and negative halves of the filter integral as follows:
  1250. X.PP
  1251. X.RS
  1252. X.nf
  1253. Xpos[\fIspeed\fP][\fIsi\fP] = \fIFilter\fP(\fIThis\fP, 0.0, \fIs\fP, \fIspeed\fP)
  1254. Xneg[\fIspeed\fP][\fIsi\fP] = \fIFilter\fP(\fIThis\fP, -\fIs\fP, 0.0, \fIspeed\fP)
  1255. X
  1256. Xwhere
  1257. X
  1258. X0 <= \fIsi\fP < \fBLIC_INTEGRAL_LEN\fP
  1259. X0 <= \fIspeed\fP < \fBLIC_INTEGRAL_SPEEDS\fP
  1260. X
  1261. X\fIs\fP = \fILength\fP * ((double)\fIsi\fP / \fBLIC_INTEGRAL_LEN\fP)
  1262. X.fi
  1263. X.RE
  1264. X.PP
  1265. XCurrently
  1266. X.B LIC_INTEGRAL_LEN
  1267. Xis 2048 and
  1268. X.B LIC_INTEGRAL_SPEEDS
  1269. Xis 20.
  1270. X.PP
  1271. XThe tables are built up by calling a user specified filter integration
  1272. Xfunction for each of the above discrete sample points.  A simple example
  1273. Xis a ramp filter:
  1274. X.PP
  1275. X.RS
  1276. X.nf
  1277. X\fIk\fP(\fIs\fP) = (\fIs\fP + \fIL\fP) / 2\fIL\fP
  1278. X
  1279. Xintegral { \fIk\fP(\fIs\fP) \fIds\fP } = \c
  1280. X.if t (\fIs\fP\u\s-22\s+2\d + 2\fIL\fP\|\fIs\fP)/4\fIL\fP
  1281. X.if n (\fIs\fP^2 + 2\fIL\fP*\fIs\fP)/4\fIL\fP
  1282. X.fi
  1283. X.RE
  1284. X.PP
  1285. XWhich yields the following LIC filter integral function (with some algebraic
  1286. Xsimplifications):
  1287. X.PP
  1288. X.RS
  1289. X.nf
  1290. Xdouble
  1291. XLIC_Ramp(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1292. X{
  1293. X.RS
  1294. Xif (\fBLIC_Length\fP(\fIThis\fP) == 0)
  1295. X.RS
  1296. Xreturn(0.0);
  1297. X.RE
  1298. Xelse
  1299. X.RS
  1300. Xreturn((\fIa\fP*\fIa\fP - \fIb\fP*\fIb\fP)/(4*\fBLIC_Length\fP(\fIThis\fP)) + (\fIa\fP - \fIb\fP)/2);
  1301. X.RE
  1302. X.RE
  1303. X}
  1304. X.fi
  1305. X.RE
  1306. X.PP
  1307. XFilters supplied with
  1308. Xthe LIC library include:
  1309. X.PP
  1310. X.RS
  1311. X.nf
  1312. Xdouble \fBLIC_Box\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1313. Xdouble \fBLIC_Ripple\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1314. Xdouble \fBLIC_Ramp\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1315. Xdouble \fBLIC_Select\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  1316. X.fi
  1317. X.RE
  1318. X.PP
  1319. X.B LIC_Box
  1320. Ximplements a constant box shape filter: \fIk\fP(\fIs\fP) =  1.
  1321. X.PP
  1322. X.B LIC_Ripple
  1323. Ximplements a phase shifted Hanning ripple function, windowed by a Hanning
  1324. Xfunction: \fIk\fP(\fIs\fP) = (cos(\fId\fP*\fIs\fP + \fIphase\fP) + 1)/2
  1325. X* (cos(\fIc\fP*\fIs\fP) + 1)/2.
  1326. XWhere
  1327. X.I d
  1328. Xand
  1329. X.I c
  1330. Xare the dilation constants for the ripple and window functions,
  1331. Xrespectively, and
  1332. X.I phase
  1333. Xis the phase shift of the ripple function.
  1334. X.I d
  1335. Xand
  1336. X.I c
  1337. Xcontrol the number of cycles of the Hanning functions over the filter kernel
  1338. Xfrom
  1339. X.RI - Length
  1340. Xto
  1341. X.RI + Length .
  1342. X.I d
  1343. Xis equal to \fIfrequency\fP * \*(pi / \fILength\fP and
  1344. X.I c
  1345. Xis always equal to \*(pi / \fILength\fP.
  1346. X.I frequency
  1347. Xis computed as follows:
  1348. X.PP
  1349. X.RS
  1350. X.nf
  1351. X/*
  1352. X * Implement ``speed'' variations by scaling the frequency inversely
  1353. X * to speed.  This causes low magnitude vectors to be convolved using
  1354. X * a higher frequency filter which will yield less distinct output
  1355. X * features.  As the frequency increases the filter begins to approximate
  1356. X * the Hanning window filter.
  1357. X */
  1358. X\fIm\fP = 6.0 - 5.0*(double)\fIspeed\fP/(\fBLIC_INTEGRAL_SPEEDS\fP - 1);
  1359. X
  1360. X\fIfrequency\fP = \fBLIC_Frequency\fP(\fIThis\fP) * \fIm\fP;
  1361. X.fi
  1362. X.RE
  1363. X.PP
  1364. XThis causes high magnitude regions to have fast moving, long
  1365. Xblurred looking features and low magnitude regions to have
  1366. Xslow moving, small sharp features over a blurred base.
  1367. X.PP
  1368. X.B LIC_Ramp
  1369. Ximplements  a ramp shape filter whose value is
  1370. X.B 0
  1371. Xat
  1372. X.RI - Length
  1373. Xand
  1374. X.B 1
  1375. Xat
  1376. X.RI + Length :
  1377. X\fIk\fP(\fIs\fP) = (\fIs\fP + \fIL\fP) / 2\fIL\fP.
  1378. X.PP
  1379. X.B LIC_Select
  1380. Ximplements a pixel selection filter which uses a narrow Gaussian
  1381. Xfilter positioned
  1382. X.IR L -2
  1383. Xdistance along the local streamline. It is called a selection filter
  1384. Xbecause its effect is to select an approximately one pixel wide
  1385. Xsection of the input image near the end of the local streamline
  1386. Xunderneath the Gaussian and place it at the origin of the local
  1387. Xstreamline.  A narrow Gaussian was chosen for its low-pass filter
  1388. Xqualities and simple analytical form, and is given by:
  1389. X\fIk\fP(\fIs\fP) = 1 / 2 * exp(-(\fIs\fP + \fIL\fP - 2)^2).
  1390. X.SH "SEE ALSO"
  1391. X.BR LIC (3),
  1392. X.BR LIC_Convolve (3),
  1393. X.BR LIC_Create (3)
  1394. X.SH STANDARDS
  1395. XThis is unsupported, non-standard software.  It is not the subject of any
  1396. Xstandards effort.
  1397. END_OF_FILE
  1398.   if test 7610 -ne `wc -c <'lic.1.2/liblic/LIC_Filters.3'`; then
  1399.     echo shar: \"'lic.1.2/liblic/LIC_Filters.3'\" unpacked with wrong size!
  1400.   fi
  1401.   # end of 'lic.1.2/liblic/LIC_Filters.3'
  1402. fi
  1403. if test -f 'lic.1.2/liblic/liblic.h' -a "${1}" != "-c" ; then 
  1404.   echo shar: Will not clobber existing file \"'lic.1.2/liblic/liblic.h'\"
  1405. else
  1406.   echo shar: Extracting \"'lic.1.2/liblic/liblic.h'\" \(6081 characters\)
  1407.   sed "s/^X//" >'lic.1.2/liblic/liblic.h' <<'END_OF_FILE'
  1408. X/*
  1409. X * $Header: /d/sisal/a/casey/tmp/lic/liblic/RCS/liblic.h,v 1.3 1993/05/28 04:27:31 casey Exp $
  1410. X */
  1411. X
  1412. X/*
  1413. X * Copyright (c) 1993 The Regents of the University of California.
  1414. X * All rights reserved.
  1415. X *
  1416. X * Redistribution and use in source and binary forms, with or without
  1417. X * modification, are permitted provided that the following conditions
  1418. X * are met:
  1419. X * 1. Redistributions of source code must retain the above copyright
  1420. X *    notice, this list of conditions and the following disclaimer.
  1421. X * 2. Redistributions in binary form must reproduce the above copyright
  1422. X *    notice, this list of conditions and the following disclaimer in the
  1423. X *    documentation and/or other materials provided with the distribution.
  1424. X * 3. All advertising materials mentioning features or use of this software
  1425. X *    must display the following acknowledgement:
  1426. X *    This product includes software developed by the University of
  1427. X *    California, Lawrence Livermore National Laboratory and its
  1428. X *    contributors.
  1429. X * 4. Neither the name of the University nor the names of its contributors
  1430. X *    may be used to endorse or promote products derived from this software
  1431. X *    without specific prior written permission.
  1432. X *
  1433. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1434. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1435. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1436. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1437. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1438. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1439. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1440. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1441. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1442. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1443. X * SUCH DAMAGE.
  1444. X */
  1445. X
  1446. X#ifndef _LIBLIC_H_
  1447. X#define _LIBLIC_H_
  1448. X
  1449. X
  1450. X/*
  1451. X * ANSI C and POSIX includes.
  1452. X */
  1453. X#include <stdlib.h>
  1454. X#include <unistd.h>
  1455. X#include <errno.h>
  1456. X#include <string.h>
  1457. X#include <stdio.h>
  1458. X#include <sys/types.h>
  1459. X
  1460. X#include <math.h>
  1461. X
  1462. X#include <lic.h>
  1463. X
  1464. X
  1465. X/*
  1466. X * Input and output image configuration.  Should really be handled
  1467. X * dynamically at run-time ...
  1468. X */
  1469. X#if !defined(RGBA) && !defined(ABGR) && !defined(ARGB) && !defined(BGRA) \
  1470. X    && !defined(RGB) && !defined(BGR) && !defined(MONOCHROME)
  1471. X#   define ARGB
  1472. X#endif
  1473. X
  1474. X#ifdef RGBA
  1475. X#   define PixelSize    4
  1476. X#   define PixelType    "RGBA"
  1477. X#   define ALPHA(i)    (i)[3]
  1478. X#   define RED(i)    (i)[0]
  1479. X#   define GREEN(i)    (i)[1]
  1480. X#   define BLUE(i)    (i)[2]
  1481. X#endif
  1482. X
  1483. X#ifdef BGRA
  1484. X#   define PixelSize    4
  1485. X#   define PixelType    "BGRA"
  1486. X#   define ALPHA(i)    (i)[3]
  1487. X#   define RED(i)    (i)[2]
  1488. X#   define GREEN(i)    (i)[1]
  1489. X#   define BLUE(i)    (i)[0]
  1490. X#endif
  1491. X
  1492. X#ifdef ARGB
  1493. X#   define PixelSize    4
  1494. X#   define PixelType    "ARGB"
  1495. X#   define ALPHA(i)    (i)[0]
  1496. X#   define RED(i)    (i)[1]
  1497. X#   define GREEN(i)    (i)[2]
  1498. X#   define BLUE(i)    (i)[3]
  1499. X#endif
  1500. X
  1501. X#ifdef ABGR
  1502. X#   define PixelSize    4
  1503. X#   define PixelType    "ABGR"
  1504. X#   define ALPHA(i)    (i)[0]
  1505. X#   define RED(i)    (i)[3]
  1506. X#   define GREEN(i)    (i)[2]
  1507. X#   define BLUE(i)    (i)[1]
  1508. X#endif
  1509. X
  1510. X#ifdef RGB
  1511. X#   define PixelSize    3
  1512. X#   define PixelType    "RGB"
  1513. X#   define ALPHA(i)    (i)[0]
  1514. X#   define RED(i)    (i)[0]
  1515. X#   define GREEN(i)    (i)[1]
  1516. X#   define BLUE(i)    (i)[2]
  1517. X#endif
  1518. X
  1519. X#ifdef BGR
  1520. X#   define PixelSize    3
  1521. X#   define PixelType    "BGR"
  1522. X#   define ALPHA(i)    (i)[0]
  1523. X#   define RED(i)    (i)[2]
  1524. X#   define GREEN(i)    (i)[1]
  1525. X#   define BLUE(i)    (i)[0]
  1526. X#endif
  1527. X
  1528. X#ifdef MONOCHROME
  1529. X#   define PixelSize    1
  1530. X#   define PixelType    "MONOCHROME"
  1531. X#   define ALPHA(i)    (i)[0]
  1532. X#endif
  1533. X
  1534. X
  1535. X/*
  1536. X * Access macros for row major rectilinear images and other array data.
  1537. X */
  1538. X#define INDEX_2D(f, x, y) \
  1539. X    ((f).data + (f).Rank * ((y)*(f).Xres + (x)))
  1540. X
  1541. X#define INDEX_3D(f, x, y, z) \
  1542. X    ((f).data + (f).Rank * (((z)*(f).Yres + (y))*(f).Xres + (x)))
  1543. X
  1544. X
  1545. X/*
  1546. X * Amount of bias used to insure that we step over pixel/cell boundaries
  1547. X * when performing vector field stream line advection.
  1548. X */
  1549. X#define ROUND_OFF    0.00001
  1550. X
  1551. X
  1552. X/*
  1553. X * Default parallel edge/vector tolerance.  If an advected stream line and
  1554. X * an edge meet at an angle less than or equal to PARALLEL_EDGE, treat it
  1555. X * as an intersection of parallel lines (sic) and extend the advected stream
  1556. X * line out till it meets the next edge.
  1557. X */
  1558. X#define SIN_PARALLEL    0.523359562429    /* sin(three degrees) */
  1559. X#ifndef M_PI
  1560. X#   define M_PI        3.141592653589793116
  1561. X#endif
  1562. X
  1563. X
  1564. X/*
  1565. X * Define DEBUG to dump out PostScript to draw the streamline for the
  1566. X * vector field cell where the condition ThisPixel is TRUE.  Use the
  1567. X * PostScript prologue DebugPrologue.ps in this directory to get nice
  1568. X * output.  Note that this only works for two-dimensional fields.
  1569. X */
  1570. X#ifdef DEBUG
  1571. X#   define ThisPixel  (i == 42 && j == 64)
  1572. X#endif
  1573. X
  1574. X
  1575. X/*
  1576. X * define REGISTER to register on some machines for speed ...
  1577. X */
  1578. X#define REGISTER  register
  1579. X
  1580. X
  1581. X/*
  1582. X * Handy macros.
  1583. X */
  1584. X#define SQUARE(x)    ((x)*(x))
  1585. X#define SIGN(x)        (((x) > 0) ? 1 : (((x) < 0) ? -1 : 0))
  1586. X#define CLAMP(x)    (((x) > 255) ? 255 : (((x) < 0) ?  0 : (x)))
  1587. X
  1588. X
  1589. X/*
  1590. X * Macro to wrap pixel coordinates in a torus like topology: 0 .. width-1.
  1591. X */
  1592. X#define WRAP(i, width) \
  1593. X{ \
  1594. X    if ((i) < 0) \
  1595. X    { \
  1596. X    /* we'll never be off more than one width negatively */ \
  1597. X    (i) += (width); \
  1598. X    } \
  1599. X    else if ((i) >= (width)) \
  1600. X    { \
  1601. X    /* we may be very far off positively ... */ \
  1602. X    (i) %= (width); \
  1603. X    } \
  1604. X}
  1605. X
  1606. X
  1607. X/*
  1608. X * Macros to take the floor and ceil of real numbers representing coordinates
  1609. X * within a vector lattice.  Since we're dealing with lattice coordinates,
  1610. X * we know that we're dealing with positive numbers, so we get to use
  1611. X * trucation to get floor.  Moreover, since we definitely won't be working
  1612. X * with vector fields with indexes larger than an int, we get to do the
  1613. X * truncation by simply casting into an int.  Finally, since we're dealing
  1614. X * with lattice coordinates, we get to use truncation + 1 to get ceil.
  1615. X */
  1616. X#define FLOOR(x)  ((double)(int)(x))
  1617. X#define CEIL(x)   ((double)((int)(x) + 1))
  1618. X#define IFLOOR(x) ((int)(x))
  1619. X#define ICEIL(x)  ((int)(x) + 1)
  1620. X
  1621. X
  1622. X#endif /* _LIBLIC_H_ */
  1623. END_OF_FILE
  1624.   if test 6081 -ne `wc -c <'lic.1.2/liblic/liblic.h'`; then
  1625.     echo shar: \"'lic.1.2/liblic/liblic.h'\" unpacked with wrong size!
  1626.   fi
  1627.   # end of 'lic.1.2/liblic/liblic.h'
  1628. fi
  1629. if test -f 'lic.1.2/test/ElectroStatic.c' -a "${1}" != "-c" ; then 
  1630.   echo shar: Will not clobber existing file \"'lic.1.2/test/ElectroStatic.c'\"
  1631. else
  1632.   echo shar: Extracting \"'lic.1.2/test/ElectroStatic.c'\" \(7937 characters\)
  1633.   sed "s/^X//" >'lic.1.2/test/ElectroStatic.c' <<'END_OF_FILE'
  1634. X/*
  1635. X * $Header: /d/sisal/a/casey/tmp/lic/test/RCS/ElectroStatic.c,v 1.5 1993/08/11 16:31:54 casey Exp $
  1636. X */
  1637. X
  1638. X/*
  1639. X * Copyright (c) 1993 The Regents of the University of California.
  1640. X * All rights reserved.
  1641. X *
  1642. X * Redistribution and use in source and binary forms, with or without
  1643. X * modification, are permitted provided that the following conditions
  1644. X * are met:
  1645. X * 1. Redistributions of source code must retain the above copyright
  1646. X *    notice, this list of conditions and the following disclaimer.
  1647. X * 2. Redistributions in binary form must reproduce the above copyright
  1648. X *    notice, this list of conditions and the following disclaimer in the
  1649. X *    documentation and/or other materials provided with the distribution.
  1650. X * 3. All advertising materials mentioning features or use of this software
  1651. X *    must display the following acknowledgement:
  1652. X *    This product includes software developed by the University of
  1653. X *    California, Lawrence Livermore National Laboratory and its
  1654. X *    contributors.
  1655. X * 4. Neither the name of the University nor the names of its contributors
  1656. X *    may be used to endorse or promote products derived from this software
  1657. X *    without specific prior written permission.
  1658. X *
  1659. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1660. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1661. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1662. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1663. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1664. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1665. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1666. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1667. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1668. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1669. X * SUCH DAMAGE.
  1670. X */
  1671. X
  1672. X#ifndef lint
  1673. X    static char rcsid[] = "$Header: /d/sisal/a/casey/tmp/lic/test/RCS/ElectroStatic.c,v 1.5 1993/08/11 16:31:54 casey Exp $";
  1674. X    static char copyright[] =
  1675. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  1676. X    "All rights reserved.\n";
  1677. X#endif
  1678. X
  1679. X
  1680. X#include <stdlib.h>
  1681. X#include <unistd.h>
  1682. X#include <errno.h>
  1683. X#include <fcntl.h>
  1684. X#include <string.h>
  1685. X#include <stdio.h>
  1686. X
  1687. X#include <math.h>
  1688. X#include <sys/types.h>
  1689. X
  1690. X#if defined(HAS_MMAP)
  1691. X#   include <sys/mman.h>
  1692. X#endif
  1693. X
  1694. X
  1695. X#ifdef NEED_EXIT_CODES
  1696. X    /*
  1697. X     * EXIT_SUCCESS and EXIT_FAILURE are supposed to be defined in <stdlib.h>
  1698. X     * according to the ANSI C X3.159-1989 specification, but Sun OS 4.1.1
  1699. X     * fails to define them ...
  1700. X     */
  1701. X#   define EXIT_SUCCESS    0
  1702. X#   define EXIT_FAILURE    1
  1703. X#endif
  1704. X
  1705. X
  1706. X#ifdef NEED_STRERROR
  1707. X    /*
  1708. X     * strerror is supposed to be defined in <string.h> and supplied in the
  1709. X     * standard C library according to the ANSI C X3.159-1989 specification,
  1710. X     * but Sun OS 4.1.1 fails to define or supply it ...  Unfortunately the
  1711. X     * only way we can control this is with an externally supplied define.
  1712. X     */
  1713. X    extern int      errno;        /* system error number */
  1714. X    extern char     *sys_errlist[];    /* system error messages */
  1715. X    extern int      sys_nerr;        /* number of entries in sys_errlist */
  1716. X
  1717. X    char *
  1718. X    strerror(int err)
  1719. X    {
  1720. X    if (err < 0 || err >= sys_nerr) {
  1721. X        static char msg[100];
  1722. X
  1723. X        sprintf(msg, "system error number %d", err);
  1724. X        return(msg);
  1725. X    }
  1726. X    return(sys_errlist[err]);
  1727. X    }
  1728. X#endif
  1729. X
  1730. X
  1731. X/*
  1732. X * Create a three-dimensional electrostatic charge floating point vector
  1733. X * field.
  1734. X */
  1735. X
  1736. X
  1737. X#define SQUARE(x) ((x)*(x))
  1738. X
  1739. X#define N_CHARGES 2
  1740. Xdouble charge[N_CHARGES]   = { 1000.0, -1000.0 };
  1741. Xdouble charge_x[N_CHARGES] = { 1, -1 };
  1742. Xdouble charge_y[N_CHARGES] = { 1, -1 };
  1743. Xdouble charge_z[N_CHARGES] = { 1, -1 };
  1744. X
  1745. X
  1746. X/*
  1747. X * Internal routines to calculate electrostatic field values.
  1748. X */
  1749. Xdouble Fx(double x, double y, double z);
  1750. Xdouble Fy(double x, double y, double z);
  1751. Xdouble Fz(double x, double y, double z);
  1752. X
  1753. X
  1754. Xmain(int argc, char **argv)
  1755. X{
  1756. X    char          *myname;
  1757. X    char          *file;
  1758. X    int            Xres, Yres, Zres;
  1759. X    float         *VectorField;
  1760. X    size_t         FieldSize;
  1761. X    register int   i,  j, k;
  1762. X    register float x,  y,  z;
  1763. X    register float fx, fy, fz;
  1764. X    int            fd;
  1765. X    
  1766. X    myname = argv[0];
  1767. X    if (argc != 5)
  1768. X    {
  1769. X    fprintf(stderr, "\nUsage: %s file_name x_res y_res z_res\n", myname);
  1770. X    exit(1);
  1771. X    }
  1772. X    
  1773. X    /* grab arguments */
  1774. X    file = argv[1];
  1775. X    Xres = atoi(argv[2]);
  1776. X    Yres = atoi(argv[3]);
  1777. X    Zres = atoi(argv[4]);
  1778. X    FieldSize = Xres*Yres*Zres*(3*sizeof(float));
  1779. X    
  1780. X    /*
  1781. X     * Open the file here even for the non-mmap version just to make sure
  1782. X     * we can create it.
  1783. X     */
  1784. X    fd = open(file, O_CREAT|O_RDWR|O_EXCL, 0666);
  1785. X    if (fd < 0)
  1786. X    {
  1787. X    (void)fprintf(stderr, "%s: unable to open %s: %s\n",
  1788. X              myname, file, strerror(errno));
  1789. X    exit(EXIT_FAILURE);
  1790. X    /*NOTREACHED*/
  1791. X    }
  1792. X
  1793. X#if defined(HAS_MMAP)
  1794. X
  1795. X    /*
  1796. X     * Pre-extend file to it's final size and map it into memory.
  1797. X     */
  1798. X    (void)lseek(fd, (off_t)(FieldSize - sizeof(fd)), SEEK_SET);
  1799. X    if (write(fd, (void *)&fd, sizeof(fd)) != sizeof(fd))
  1800. X    {
  1801. X    (void)fprintf(stderr, "%s: unable to preextend %s to %ld bytes: %s\n",
  1802. X              myname, file, (int)FieldSize, strerror(errno));
  1803. X    (void)close(fd);
  1804. X    exit(EXIT_FAILURE);
  1805. X    /*NOTREACHED*/
  1806. X    }
  1807. X    VectorField = (float *)mmap((void *)0, (int)FieldSize, PROT_WRITE,
  1808. X                    MAP_SHARED, fd, (off_t)0);
  1809. X    if ((int)VectorField == -1)
  1810. X    {
  1811. X    (void)fprintf(stderr, "%s: unable to map %s: %s\n",
  1812. X              myname, file, strerror(errno));
  1813. X    (void)close(fd);
  1814. X    exit(EXIT_FAILURE);
  1815. X    /*NOTREACHED*/
  1816. X    }
  1817. X    (void)close(fd);
  1818. X
  1819. X#else /* HAS_MMAP */
  1820. X
  1821. X    VectorField = (float *)malloc(FieldSize);
  1822. X    if (VectorField == NULL)
  1823. X    {
  1824. X    (void)fprintf(stderr, "%s: unable to allocate %d bytes of memory\n",
  1825. X              myname, (int)FieldSize);
  1826. X    (void)close(fd);
  1827. X    exit(EXIT_FAILURE);
  1828. X    /*NOTREACHED*/
  1829. X    }
  1830. X    /*
  1831. X     * Should probably try to write the field now just to make sure there's
  1832. X     * enough disk space ...
  1833. X     */
  1834. X
  1835. X#endif /* HAS_MMAP */
  1836. X    
  1837. X    /*
  1838. X     * Create the electrostatic vector field ...
  1839. X     */
  1840. X    for (k = 0; k < Zres; k++)
  1841. X    {
  1842. X    z = (float)k/(float)Zres * 10.0 - 5.0;
  1843. X
  1844. X    for (j = 0; j < Yres; j++)
  1845. X    {
  1846. X        y = (float)j/(float)Yres * 10.0 - 5.0;
  1847. X
  1848. X        for (i = 0; i < Xres; i++)
  1849. X        {
  1850. X        x = (float)i/(float)Xres * 10.0 - 5.0;
  1851. X        
  1852. X        fx = sqrt(fabs(Fx(x,y,z)));
  1853. X        fy = sqrt(fabs(Fy(x,y,z)));
  1854. X        fz = sqrt(fabs(Fz(x,y,z)));
  1855. X        
  1856. X        VectorField[3*(i + j*Xres + k*Xres*Yres) + 0] =  fx;
  1857. X        VectorField[3*(i + j*Xres + k*Xres*Yres) + 1] = -fy;
  1858. X        VectorField[3*(i + j*Xres + k*Xres*Yres) + 2] =  fz;
  1859. X        }
  1860. X    }
  1861. X    }
  1862. X
  1863. X#if !defined(HAS_MMAP)
  1864. X    if (write(fd, (void *)VectorField, FieldSize) != FieldSize)
  1865. X    {
  1866. X    (void)fprintf(stderr, "%s: unable to write %ld bytes to %s: %s\n",
  1867. X              myname, (int)FieldSize, file, strerror(errno));
  1868. X    (void)close(fd);
  1869. X    exit(EXIT_FAILURE);
  1870. X    /*NOTREACHED*/
  1871. X    }
  1872. X    (void)close(fd);
  1873. X#endif
  1874. X}
  1875. X
  1876. X
  1877. Xdouble
  1878. XFx(double x, double y, double z)
  1879. X{
  1880. X    int    i;
  1881. X    double sum;
  1882. X    
  1883. X    sum = 0;
  1884. X    for (i = 0; i < N_CHARGES; i++)
  1885. X    {
  1886. X    double d2 =  SQUARE(x - charge_x[i])
  1887. X           + SQUARE(y - charge_y[i])
  1888. X           + SQUARE(z - charge_z[i]);
  1889. X    sum += (charge[i] / d2) * ((x - charge_x[i]) / sqrt(d2));
  1890. X    }
  1891. X    return(sum);
  1892. X}
  1893. X
  1894. X
  1895. Xdouble
  1896. XFy(double x, double y, double z)
  1897. X{
  1898. X    int    i;
  1899. X    double sum;
  1900. X    
  1901. X    sum = 0;
  1902. X    for (i = 0; i < N_CHARGES; i++)
  1903. X    {
  1904. X    double d2 =  SQUARE(x - charge_x[i])
  1905. X           + SQUARE(y - charge_y[i])
  1906. X           + SQUARE(z - charge_z[i]);
  1907. X    sum += (charge[i] / d2) * ((y - charge_y[i]) / sqrt(d2));
  1908. X    }
  1909. X    return(sum);
  1910. X}
  1911. X
  1912. X
  1913. Xdouble
  1914. XFz(double x, double y, double z)
  1915. X{
  1916. X    int    i;
  1917. X    double sum;
  1918. X    
  1919. X    sum = 0;
  1920. X    for (i = 0; i < N_CHARGES; i++)
  1921. X    {
  1922. X    double d2 =  SQUARE(x - charge_x[i])
  1923. X           + SQUARE(y - charge_y[i])
  1924. X           + SQUARE(z - charge_z[i]);
  1925. X    sum += (charge[i] / d2) * ((z - charge_z[i]) / sqrt(d2));
  1926. X    }
  1927. X    return(sum);
  1928. X}
  1929. END_OF_FILE
  1930.   if test 7937 -ne `wc -c <'lic.1.2/test/ElectroStatic.c'`; then
  1931.     echo shar: \"'lic.1.2/test/ElectroStatic.c'\" unpacked with wrong size!
  1932.   fi
  1933.   # end of 'lic.1.2/test/ElectroStatic.c'
  1934. fi
  1935. echo shar: End of archive 8 \(of 10\).
  1936. cp /dev/null ark8isdone
  1937. MISSING=""
  1938. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1939.     if test ! -f ark${I}isdone ; then
  1940.     MISSING="${MISSING} ${I}"
  1941.     fi
  1942. done
  1943. if test "${MISSING}" = "" ; then
  1944.     echo You have unpacked all 10 archives.
  1945.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1946. else
  1947.     echo You still must unpack the following archives:
  1948.     echo "        " ${MISSING}
  1949. fi
  1950. exit 0
  1951. exit 0 # Just in case...
  1952.