home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / lic / part07 < prev    next >
Encoding:
Text File  |  1993-11-09  |  60.4 KB  |  1,992 lines

  1. Newsgroups: comp.sources.misc
  2. From: casey@gauss.llnl.gov (Casey Leedom)
  3. Subject: v40i121:  lic - LLNL Line Integral Convolution, v1.3, Part07/09
  4. Message-ID: <1993Nov9.171028.26930@sparky.sterling.com>
  5. X-Md4-Signature: da2fe49ec0f1f7f6292bb72f1da313fe
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Tue, 9 Nov 1993 17:10:28 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: casey@gauss.llnl.gov (Casey Leedom)
  12. Posting-number: Volume 40, Issue 121
  13. Archive-name: lic/part07
  14. Environment: UNIX
  15. Supersedes: lic: Volume 38, Issue 104
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  lic.1.3/config/Makefile.config lic.1.3/doc/cover.me
  22. #   lic.1.3/liblic/Filters.c lic.1.3/liblic/LIC_Filters.3
  23. #   lic.1.3/liblic/liblic.h lic.1.3/lic/Makefile.tmpl
  24. #   lic.1.3/test/ElectroStatic.c lic.1.3/test/SpiralField.c
  25. #   lic.1.3/test/SpotNoise.c
  26. # Wrapped by kent@sparky on Tue Nov  9 10:09:41 1993
  27. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  28. echo If this archive is complete, you will see the following message:
  29. echo '          "shar: End of archive 7 (of 9)."'
  30. if test -f 'lic.1.3/config/Makefile.config' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'lic.1.3/config/Makefile.config'\"
  32. else
  33.   echo shar: Extracting \"'lic.1.3/config/Makefile.config'\" \(7263 characters\)
  34.   sed "s/^X//" >'lic.1.3/config/Makefile.config' <<'END_OF_FILE'
  35. X#
  36. X# $Header: /usr/local/src/lic/config/RCS/Makefile.config,v 1.13 1993/11/05 16:06:10 casey Exp $
  37. X#
  38. X
  39. X# Installation targetting.  Any user commands will be installed in BINDIR,
  40. X# libraries in LIBDIR, include files in INCDIR, manual pages in MAN1DIR
  41. X# and MAN3DIR, etc.
  42. X#
  43. X      DESTDIR = 
  44. X       BINDIR = $(DESTDIR)/usr/local/bin
  45. X       LIBDIR = $(DESTDIR)/usr/local/lib
  46. X       INCDIR = $(DESTDIR)/usr/local/include
  47. X
  48. X      MANROOT = $(DESTDIR)/usr/local/man
  49. X      MAN1DIR = $(MANROOT)/man1
  50. X      MAN1EXT = 1
  51. X      MAN3DIR = $(MANROOT)/man3
  52. X      MAN3EXT = 3
  53. X      MANDIRS = $(MAN1DIR) $(MAN3DIR)
  54. X
  55. X# Specify "man" for MANINSTALL if you want unformatted troff source manual
  56. X# pages installed in the above locations.  Specify "cat" if you want nroff
  57. X# formatted manual pages installed.  Specify "none" if you don't want
  58. X# manual pages installed.
  59. X#
  60. X   MANINSTALL = man
  61. X
  62. X# Protection modes to be set on various installation targets.
  63. X#
  64. X  INSTBINPROT = 555
  65. X  INSTLIBPROT = 444
  66. X  INSTINCPROT = 444
  67. X  INSTMANPROT = 444
  68. X  INSTDOCPROT = 444
  69. X
  70. X
  71. X# Specify "avs" for AVS below if you have AVS and you want to build an AVS
  72. X# LIC module.
  73. X#
  74. X# AVS modules will be installed in AVSMODDIR, AVS module document in AVSDOCDIR,
  75. X# etc.
  76. X#
  77. X# AVSLIBDIR is where AVS support libraries can be found.  AVS_INCLUDES are
  78. X# -I include definitions that point to the AVS include directories.
  79. X# AVS_DEFINES should include any special defines needed to compile AVS
  80. X# coroutine modules on your system.  AVS_EXTRALIBS should contain any extra
  81. X# library definitions needed to link AVS coroutine modules on your system.
  82. X#
  83. X# Using AVS 4.0 (under IBM AIX 3.2), we didn't need any special AVS_DEFINES
  84. X# or AVS_EXTRALIBS.
  85. X#
  86. X# Using AVS 5.0 (under SGI IRIX 4.0.5), AVS_DEFINES should contain
  87. X# -DNeedFunctionPrototypes=1 and AVS_EXTRALIBS needs to contain -lsun.
  88. X#
  89. X# Note that the AVS module currently *only* understands 4-byte ARGB images.
  90. X# Thus, you'll want to select -DARGB for IMAGE_DEFINES below if you want to
  91. X# use the AVS module.
  92. X#
  93. X          AVS = 
  94. X
  95. X       AVSDIR = $(DESTDIR)/usr/avs
  96. X    AVSMODDIR = $(AVSDIR)/unsupp_mods
  97. X    AVSDOCDIR = $(AVSDIR)/unsupp_doc
  98. X
  99. X    AVSLIBDIR = $(AVSDIR)/lib
  100. X AVS_INCLUDES = -I$(AVSDIR)/include
  101. X  AVS_DEFINES = 
  102. XAVS_EXTRALIBS = 
  103. X
  104. X
  105. X# IMAGE_DEFINES should define one of the following (yes, this should all be
  106. X# handled dynamically at run-time, but we ran out of time):
  107. X#
  108. X#    ARGB, ABGR, RGBA, BGRA -- four byte pixels:  alpha, red, green and blue
  109. X#    RGB, BGR               -- three byte pixels: red, green and blue
  110. X#    MONOCHROME             -- one byte pixels:   grey scale
  111. X#
  112. XIMAGE_DEFINES = -DMONOCHROME
  113. X
  114. X
  115. X# Standard compilation environment definitions:
  116. X#
  117. X# NOTES:
  118. X#   Neither DEFINES nor INCLUDES should be used below.  They are present for
  119. X#   the benefit of various Makefile.tmpl files to add includes and defines to
  120. X#   the standard CFLAGS macro.
  121. X#
  122. X#   Setting MMAP_DEFINES to -DHAS_MMAP will cause the lic(1) command to use
  123. X#   mmap calls to map its input and output files directly into its address
  124. X#   space.  If HAS_MMAP is not defined lic(1) will malloc memory for the input
  125. X#   and output files.  Using mmap has the advantage that it won't require space
  126. X#   on swap for the potentially very large images and also saves on pointless
  127. X#   I/O to swap.
  128. X#
  129. X#   There is support for parallel processing on a limited number of platforms.
  130. X#   It shouldn't be too difficult to do the work for any other platform that
  131. X#   supports shared memory multiprocessing.  Only liblic/ComputeImage.c should
  132. X#   need to be changed.  See that file to see what was done for other
  133. X#   platforms.
  134. X#
  135. X# DEC OSF1(alpha)
  136. X#   1.    STD_DEFINES should contain -std1.
  137. X#   2.    CDEBUGFLAGS should contain -g or -O (or -O2) depending on your
  138. X#    debugging/performance needs.
  139. X#   3.    Set RANLIB to ranlib.
  140. X#
  141. X# HP-UX 9.01(snake)
  142. X#   1.    STD_DEFINES should contain -Aa, -D_INCLUDE_XOPEN_SOURCE,
  143. X#    -D_INCLUDE_POSIX_SOURCE and -DHAS_HP_GETOPT.  Unfortunately getopt(3)
  144. X#    wasn't part of either the ANSI C X3.159-1989 or POSIX 1003.1-1990
  145. X#    standards.  HP has chosen a prototype for getopt that is in conflict
  146. X#    with everyone else's.
  147. X#   2.    Wasn't able to use mmap under HP-UX 8.07 even though it linked
  148. X#    successfully.  Didn't try again with HP-UX 9.01.  If I remember right,
  149. X#    it wrote out the output image as all zeros.  When I ran it with the
  150. X#    debugger, every page of the output image that I touched in an effort
  151. X#    to find those zeros turned out to have the correct values *and* got
  152. X#    written out with the correct values.  Some weird VM problem ...
  153. X#   3.    Set RANLIB to /bin/true.
  154. X#
  155. X# IBM AIX 3.2(rs/6000):
  156. X#   1.    STD_DEFINES should contain -qlanglvl=ansi and -D_ALL_SOURCE.
  157. X#   2.    CDEBUGFLAGS should contain -qsrcmsg. It should probably also contain
  158. X#    -qextchk, but that causes the loader to complain about not being able
  159. X#    to resolve references to LIC_Convolve_2D and LIC_Convolve_3D.
  160. X#    CDEBUGFLAGS should also probably contain -g or -O depending on your
  161. X#    debugging/performance needs.
  162. X#   3.    Set MMAP_DEFINES to -DHAS_MMAP.
  163. X#   4.    Set RANLIB to /bin/true.
  164. X#
  165. X# SGI IRIX 4.0.5(mips):
  166. X#   1.    CDEBUGFLAGS should contain -prototypes in order to get C function
  167. X#    prototype checking.  CDEBUGFLAGS should also probably contain -g
  168. X#    or -O depending on your debugging/performance needs.
  169. X#   2.    Set MMAP_DEFINES to -DHAS_MMAP.
  170. X#   3.    Set MCP_DEFINES to -DPARALLEL and -DHAS_M_FORK.
  171. X#   4.    Set MPC_EXTRALIBS to -lmpc.
  172. X#   5.    Set RANLIB to /bin/true.
  173. X#
  174. X# SUN OS 4.1.1(sparc):
  175. X#   1.    CC should be an ANSI C compiler like gcc or Sun's unbundled compiler.
  176. X#    Sun's bundled compiler won't work.
  177. X#   2.    If gcc is used, you'll probably have to add -I/usr/include to
  178. X#    STD_INCLUDES because gcc seems to search its own local include
  179. X#    directory before /usr/include which leads to all sorts of problems.
  180. X#   3.    STD_DEFINES needs -DNEED_STRERROR, -DHAS_OLD_TIMES, -DEXIT_SUCCESS=0,
  181. X#    -DEXIT_FAILURE=1 and -DRAND_MAX=32767.  Sun OS 4.1.1 fails to supply
  182. X#    the ANSI C X3.159-1989 strerror routine, its version of the times(2)
  183. X#    call also doesn't conform to the POSIX definition (it returns 0 on
  184. X#    success instead of a monotonically increasing wall clock time) and the
  185. X#    EXIT_SUCCESS, EXIT_FAILURE and RAND_MAX defines are missing from
  186. X#    <stdlib.h>.  Note also that Sun OS's version of rand is so mind-
  187. X#    bogglingly bad that you'll want to use random() instead.  We didn't
  188. X#    make this change to the source because it would have required
  189. X#    diverging from the ANSI C standard too much.  You'll need to edit
  190. X#    test/WhiteNoise.c and test/SpotNoise.c.
  191. X#   4.    CDEBUGFLAGS should also probably contain -g or -O depending on your
  192. X#    debugging/performance needs.
  193. X#   5.    Set MMAP_DEFINES to -DHAS_MMAP.
  194. X#   6.    Set RANLIB to ranlib.
  195. X#
  196. X  BUILDINCTOP = $(TOP)/include
  197. X    LIBLICDIR = $(TOP)/liblic
  198. X       LIBLIC = $(LIBLICDIR)/liblic.a
  199. X
  200. X           CC = cc
  201. X STD_INCLUDES = -I.
  202. X TOP_INCLUDES = -I$(BUILDINCTOP)
  203. X     INCLUDES = 
  204. X  ALLINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  205. X  STD_DEFINES = 
  206. X      DEFINES = 
  207. X   ALLDEFINES = $(STD_DEFINES) $(DEFINES)
  208. X  CDEBUGFLAGS = -O
  209. X       CFLAGS = $(CDEBUGFLAGS) $(ALLDEFINES) $(ALLINCLUDES)
  210. X
  211. X MMAP_DEFINES = 
  212. X
  213. X  MPC_DEFINES = 
  214. XMPC_EXTRALIBS = 
  215. X
  216. X# Various programs we use ...
  217. X#
  218. X           AR = ar cq
  219. X        NROFF = nroff
  220. X       RANLIB = /bin/true
  221. X        SHELL = /bin/sh
  222. X        STRIP = strip
  223. END_OF_FILE
  224.   if test 7263 -ne `wc -c <'lic.1.3/config/Makefile.config'`; then
  225.     echo shar: \"'lic.1.3/config/Makefile.config'\" unpacked with wrong size!
  226.   fi
  227.   # end of 'lic.1.3/config/Makefile.config'
  228. fi
  229. if test -f 'lic.1.3/doc/cover.me' -a "${1}" != "-c" ; then 
  230.   echo shar: Will not clobber existing file \"'lic.1.3/doc/cover.me'\"
  231. else
  232.   echo shar: Extracting \"'lic.1.3/doc/cover.me'\" \(6377 characters\)
  233.   sed "s/^X//" >'lic.1.3/doc/cover.me' <<'END_OF_FILE'
  234. X.\" Copyright (c) 1993 The Regents of the University of California.
  235. X.\" All rights reserved.
  236. X.\"
  237. X.\" Redistribution and use in source and binary forms, with or without
  238. X.\" modification, are permitted provided that the following conditions
  239. X.\" are met:
  240. X.\" 1. Redistributions of source code must retain the above copyright
  241. X.\"    notice, this list of conditions and the following disclaimer.
  242. X.\" 2. Redistributions in binary form must reproduce the above copyright
  243. X.\"    notice, this list of conditions and the following disclaimer in the
  244. X.\"    documentation and/or other materials provided with the distribution.
  245. X.\" 3. All advertising materials mentioning features or use of this software
  246. X.\"    must display the following acknowledgement:
  247. X.\"    This product includes software developed by the University of
  248. X.\"    California, Lawrence Livermore National Laboratory and its
  249. X.\"    contributors.
  250. X.\" 4. Neither the name of the University nor the names of its contributors
  251. X.\"    may be used to endorse or promote products derived from this software
  252. X.\"    without specific prior written permission.
  253. X.\"
  254. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  255. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  256. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  257. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  258. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  259. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  260. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  261. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  262. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  263. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  264. X.\" SUCH DAMAGE.
  265. X.\"
  266. X.po 1.0in
  267. X.ll 6.5in
  268. X.nr pi 0n
  269. X.de Hd
  270. X.ds Vr 1.3
  271. X.ds Dt \\$4
  272. X..
  273. X.Hd $Header: /usr/local/src/lic/doc/RCS/cover.me,v 1.6 1993/10/22 23:59:35 casey Exp $
  274. X.(b C
  275. X.sz +10
  276. X.rs
  277. X.sp 2.25in
  278. XLLNL
  279. X.sp .25in
  280. XLine Integral Convolution
  281. X.sp .5in
  282. XDistribution
  283. X.sp 2in
  284. XVersion \*(Vr
  285. X\*(Dt
  286. X.sz -10
  287. X.)b
  288. X.\" We delay defining the footer so it won't show up on the first page ...
  289. X.of '\*(Dt''LLNL LIC version \*(Vr'
  290. X.ef '\*(Dt''LLNL LIC version \*(Vr'
  291. X.pa
  292. X.rs
  293. X.sp 3.75in
  294. XCopyright (c) 1993 The Regents of the University of California.
  295. XAll rights reserved.
  296. X.pp
  297. XRedistribution and use in source and binary forms, with or without
  298. Xmodification, are permitted provided that the following conditions
  299. Xare met:
  300. X.ip 1.
  301. XRedistributions of source code must retain the above copyright
  302. Xnotice, this list of conditions and the following disclaimer.
  303. X.ip 2.
  304. XRedistributions in binary form must reproduce the above copyright
  305. Xnotice, this list of conditions and the following disclaimer in the
  306. Xdocumentation and/or other materials provided with the distribution.
  307. X.ip 3.
  308. XAll advertising materials mentioning features or use of this software
  309. Xmust display the following acknowledgement:
  310. X.(q
  311. XThis product includes software developed by the University of
  312. XCalifornia, Lawrence Livermore National Laboratory and its contributors.
  313. X.)q
  314. X.ip 4.
  315. XNeither the name of the University nor the names of its contributors
  316. Xmay be used to endorse or promote products derived from this software
  317. Xwithout specific prior written permission.
  318. X.pp
  319. XTHIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  320. XANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  321. XIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  322. XARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  323. XFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  324. XDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  325. XOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  326. XHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  327. XLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  328. XOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  329. XSUCH DAMAGE.
  330. X.pa
  331. X.(b C
  332. X.sz +2
  333. XContents
  334. X.sz -2
  335. X.)b
  336. X.sp 3v
  337. X.(x i
  338. XIntroduction
  339. X.)x 1
  340. X.(x i
  341. XREADME
  342. X.)x 2
  343. X.(x i
  344. XABSTRACT
  345. X.)x 3
  346. X.(x i
  347. XMEMO
  348. X.)x 4
  349. X.(x i
  350. XTODO
  351. X.)x 5
  352. X.(x i
  353. XImaging Vector Fields Using Line Integral Convolution
  354. X.)x 6
  355. X.(x i
  356. XManual pages
  357. X.)x 7
  358. X.(x i
  359. XInclude file sources
  360. X.)x 8
  361. X.(x i
  362. Xlic command source
  363. X.)x 9
  364. X.(x i
  365. XLIC AVS coroutine module source
  366. X.)x 10
  367. X.(x i
  368. XLIC library sources
  369. X.)x 11
  370. X.xp i
  371. X.pa
  372. X.(b C
  373. X.sz +2
  374. X1
  375. X.sp 1v
  376. XIntroduction
  377. X.sz -2
  378. X.)b
  379. X.sp 3v
  380. X.pp
  381. XThis document contains the documentation and source code to the LLNL
  382. XLine Integral Convolution (LIC) software distribution version \*(Vr.
  383. X.pp
  384. XThe LLNL LIC software is an experimental implementation of a new
  385. Xvector visualization algorithm.  It allows researchers to experiment
  386. Xwith this algorithm and duplicate results presented in the paper
  387. X.i "Imaging Vector Fields Using Line Integral Convolution"
  388. Xby Brian Cabral and Casey Leedom in the 1993 SIGGRAPH conference.
  389. X.pp
  390. XThe software consists of an object-oriented library that implements
  391. Xthe algorithm, a command line interface and an AVS interface and
  392. Xdocumentation for all of the above.
  393. X.pa
  394. X.(b C
  395. X.sz +2
  396. X2
  397. X.sp 1v
  398. XREADME
  399. X.sz -2
  400. X.)b
  401. X.pa
  402. X.(b C
  403. X.sz +2
  404. X3
  405. X.sp 1v
  406. XABSTRACT
  407. X.sz -2
  408. X.)b
  409. X.pa
  410. X.(b C
  411. X.sz +2
  412. X4
  413. X.sp 1v
  414. XMEMO
  415. X.sz -2
  416. X.)b
  417. X.pa
  418. X.(b C
  419. X.sz +2
  420. X5
  421. X.sp 1v
  422. XTODO
  423. X.sz -2
  424. X.)b
  425. X.pa
  426. X.(b C
  427. X.sz +2
  428. X6
  429. X.sp 1v
  430. XImaging Vector Fields Using Line Integral Convolution
  431. X.sz -2
  432. X.)b
  433. X.pa
  434. X.(b C
  435. X.sz +2
  436. X7
  437. X.sp 1v
  438. XManual pages
  439. X.sz -2
  440. X.)b
  441. X.sp 3v
  442. X.pp
  443. X.(x i
  444. Xlic.1
  445. X.)x 1
  446. X.(x i
  447. XLIC.txt (AVS coroutine on-line documentation)
  448. X.)x 2
  449. X.(x i
  450. XLIC.3
  451. X.)x 3
  452. X.(x i
  453. XLIC_ComputeImage.3
  454. X.)x 4
  455. X.(x i
  456. XLIC_Convolve.3
  457. X.)x 5
  458. X.(x i
  459. XLIC_Create.3
  460. X.)x 6
  461. X.(x i
  462. XLIC_Destroy.3
  463. X.)x 7
  464. X.(x i
  465. XLIC_Filters.3
  466. X.)x 8
  467. X.(x i
  468. XLIC_Modify.3
  469. X.)x 9
  470. X.(x i
  471. XLIC_Query.3
  472. X.)x 10
  473. X.xp i
  474. X.pa
  475. X.(b C
  476. X.sz +2
  477. X8
  478. X.sp 1v
  479. XInclude file sources
  480. X.sz -2
  481. X.)b
  482. X.sp 3v
  483. X.pp
  484. X.(x i
  485. Xinclude/lic.h
  486. X.)x 1
  487. X.xp i
  488. X.pa
  489. X.(b C
  490. X.sz +2
  491. X9
  492. X.sp 1v
  493. Xlic command source
  494. X.sz -2
  495. X.)b
  496. X.sp 3v
  497. X.(x i
  498. Xlic/lic.c
  499. X.)x 1
  500. X.xp i
  501. X.pa
  502. X.(b C
  503. X.sz +2
  504. X10
  505. X.sp 1v
  506. XLIC AVS coroutine module source
  507. X.sz -2
  508. X.)b
  509. X.sp 3v
  510. X.pp
  511. X.(x i
  512. Xavs/LIC.c
  513. X.)x 1
  514. X.xp i
  515. X.pa
  516. X.(b C
  517. X.sz +2
  518. X11
  519. X.sp 1v
  520. XLIC library sources
  521. X.sz -2
  522. X.)b
  523. X.sp 3v
  524. X.pp
  525. X.(x i
  526. Xliblic.h
  527. X.)x 1
  528. X.(x i
  529. XComputeImage.c
  530. X.)x 2
  531. X.(x i
  532. XConvolve2D.c
  533. X.)x 3
  534. X.(x i
  535. XConvolve3D.c
  536. X.)x 4
  537. X.(x i
  538. XCreate.c
  539. X.)x 5
  540. X.(x i
  541. XDestroy.c
  542. X.)x 6
  543. X.(x i
  544. XFilters.c
  545. X.)x 7
  546. X.(x i
  547. XModify.c
  548. X.)x 8
  549. X.(x i
  550. XQuery.c
  551. X.)x 9
  552. X.xp i
  553. END_OF_FILE
  554.   if test 6377 -ne `wc -c <'lic.1.3/doc/cover.me'`; then
  555.     echo shar: \"'lic.1.3/doc/cover.me'\" unpacked with wrong size!
  556.   fi
  557.   # end of 'lic.1.3/doc/cover.me'
  558. fi
  559. if test -f 'lic.1.3/liblic/Filters.c' -a "${1}" != "-c" ; then 
  560.   echo shar: Will not clobber existing file \"'lic.1.3/liblic/Filters.c'\"
  561. else
  562.   echo shar: Extracting \"'lic.1.3/liblic/Filters.c'\" \(6091 characters\)
  563.   sed "s/^X//" >'lic.1.3/liblic/Filters.c' <<'END_OF_FILE'
  564. X/*
  565. X * $Header: /usr/local/src/lic/liblic/RCS/Filters.c,v 1.12 1993/08/10 23:35:32 casey Exp $
  566. X */
  567. X
  568. X/*
  569. X * Copyright (c) 1993 The Regents of the University of California.
  570. X * All rights reserved.
  571. X *
  572. X * Redistribution and use in source and binary forms, with or without
  573. X * modification, are permitted provided that the following conditions
  574. X * are met:
  575. X * 1. Redistributions of source code must retain the above copyright
  576. X *    notice, this list of conditions and the following disclaimer.
  577. X * 2. Redistributions in binary form must reproduce the above copyright
  578. X *    notice, this list of conditions and the following disclaimer in the
  579. X *    documentation and/or other materials provided with the distribution.
  580. X * 3. All advertising materials mentioning features or use of this software
  581. X *    must display the following acknowledgement:
  582. X *    This product includes software developed by the University of
  583. X *    California, Lawrence Livermore National Laboratory and its
  584. X *    contributors.
  585. X * 4. Neither the name of the University nor the names of its contributors
  586. X *    may be used to endorse or promote products derived from this software
  587. X *    without specific prior written permission.
  588. X *
  589. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  590. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  591. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  592. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  593. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  594. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  595. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  596. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  597. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  598. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  599. X * SUCH DAMAGE.
  600. X */
  601. X
  602. X#ifndef lint
  603. X    static char rcsid[] = "$Header: /usr/local/src/lic/liblic/RCS/Filters.c,v 1.12 1993/08/10 23:35:32 casey Exp $";
  604. X    static char copyright[] =
  605. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  606. X    "All rights reserved.\n";
  607. X#endif
  608. X
  609. X
  610. X#include "liblic.h"
  611. X
  612. X
  613. X/*
  614. X *    Build integral tables from filter integrator.
  615. X *    =============================================
  616. X */
  617. X
  618. Xvoid
  619. XLIC_BuildIntegralTables(LIC *This)
  620. X    /*
  621. X     * Build integral tables for LIC instance if needed.
  622. X     */
  623. X{
  624. X    int speed, length;
  625. X
  626. X    if (!This->NeedIntegration)
  627. X    return;
  628. X    This->NeedIntegration = FALSE;
  629. X
  630. X    /*
  631. X     * Build the convolution integral tables.  Build LIC_INTEGRAL_SPEEDS
  632. X     * different versions of them with speed varying between 0 and
  633. X     * LIC_INTEGRAL_SPEEDS.
  634. X     */
  635. X    for (speed = 0; speed < LIC_INTEGRAL_SPEEDS; speed++)
  636. X    {
  637. X    double s;
  638. X
  639. X    for (length = 0; length < LIC_INTEGRAL_LEN; length++)
  640. X    {
  641. X        s = LIC_Length(This) * length / (double)LIC_INTEGRAL_LEN;
  642. X        This->NegIntegralTable[speed][length] = This->Filter(This,  -s, 0.0, speed);
  643. X        This->PosIntegralTable[speed][length] = This->Filter(This, 0.0,   s, speed);
  644. X    }
  645. X    }
  646. X}
  647. X
  648. X
  649. Xdouble
  650. XLIC_Box(LIC *This, double a, double b, int speed)
  651. X    /*
  652. X     * Compute the integral bewteen points a and b, a <= b, of a box
  653. X     * filter:
  654. X     *
  655. X     *    k(s) = 1
  656. X     */
  657. X{
  658. X    return(b - a);
  659. X}
  660. X
  661. X
  662. Xdouble
  663. XLIC_Ripple(LIC *This, double a, double b, int speed)
  664. X    /*
  665. X     * Compute the integral bewteen points a and b, a <= b, of a phase shifted
  666. X     * Hanning low pass filter multiplied by a Hanning window function:
  667. X     *
  668. X     *    k(s) = (cos(d*s + phase) + 1)/2 * (cos(c*s) + 1)/2
  669. X     *
  670. X     * We need to scale the filter to the length of the filter support.  This
  671. X     * requires scaling each occurance of s by Pi/L.  Things fall out in the
  672. X     * integral which allow us to slip the scaling factors into c and d.
  673. X     */
  674. X{
  675. X    REGISTER double m;        /* speed multiple */
  676. X    REGISTER double p;        /* phase of the Hanning ripple function */
  677. X    REGISTER double f;        /* frequency of the Hanning ripple function */
  678. X    REGISTER double c;        /* Hanning window function dilation constant */
  679. X    REGISTER double d;        /* Hanning ripple filter dilation constant */
  680. X    REGISTER double w;        /* integral value */
  681. X    
  682. X    if (LIC_Length(This) == 0 || a == b)
  683. X    return(0.0);
  684. X    
  685. X    /*
  686. X     * Implement ``speed'' variations by scaling the frequency inversely
  687. X     * to speed.  This causes low magnitude vectors to be convolved using
  688. X     * a higher frequency filter which will yield less distinct output
  689. X     * features.  As the frequency increases the filter begins to approximate
  690. X     * the Hanning window filter.
  691. X     */
  692. X
  693. X    p = LIC_Phase(This);
  694. X    f = LIC_Frequency(This) * (6.0 - 5.0*(double)speed/(LIC_INTEGRAL_SPEEDS - 1));
  695. X    c = 1.0/LIC_Length(This) * M_PI;
  696. X    d = 1.0/LIC_Length(This) * M_PI * f;
  697. X    
  698. X    w =   b                          - a
  699. X    + sin(b*c)/c                 - sin(a*c)/c
  700. X    + sin(b*d + p)/d             - sin(a*d + p)/d
  701. X    + sin(b*(c+d) + p)/(2*(c+d)) - sin(a*(c+d) + p)/(2*(c+d));
  702. X    if (c != d)
  703. X    w +=  sin(b*(c-d) - p)/(2*(c-d))
  704. X        - sin(a*(c-d) - p)/(2*(c-d));
  705. X    w /= 4;
  706. X    return(w);
  707. X}
  708. X
  709. X
  710. Xdouble
  711. XLIC_Ramp(LIC *This, double a, double b, int speed)
  712. X    /*
  713. X     * Compute the integral bewteen points a and b, a <= b, of a biased
  714. X     * triangle filter:
  715. X     *
  716. X     *    k(s) = (s + L) / (2 * L)
  717. X     */
  718. X{
  719. X    if (LIC_Length(This) == 0)
  720. X    return(0.0);
  721. X    else
  722. X    return((a*a - b*b)/(4*LIC_Length(This)) + (a - b)/2);
  723. X}
  724. X
  725. X
  726. Xdouble
  727. XLIC_Select(LIC *This, double a, double b, int speed)
  728. X    /*
  729. X     * Compute the integral bewteen points a and b, a <= b, of a 
  730. X     * narrow Gaussian filter which sits at L-2 along the local
  731. X     * streamline.  This filter's delta function like shape and
  732. X     * it's location near the end of the local streamline means that
  733. X     * the filter acts as a pixel selection filter. Hence it's name.
  734. X     *
  735. X     *    k(s) = 1/2*pi * e^(x - L + 2)^2 
  736. X     */
  737. X{
  738. X    if (LIC_Length(This) == 0)
  739. X    return(0.0);
  740. X    else 
  741. X    return(  erf((b - LIC_Length(This) + 2) / sqrt(2.0))
  742. X           - erf((a - LIC_Length(This) + 2) / sqrt(2.0)));
  743. X}
  744. END_OF_FILE
  745.   if test 6091 -ne `wc -c <'lic.1.3/liblic/Filters.c'`; then
  746.     echo shar: \"'lic.1.3/liblic/Filters.c'\" unpacked with wrong size!
  747.   fi
  748.   # end of 'lic.1.3/liblic/Filters.c'
  749. fi
  750. if test -f 'lic.1.3/liblic/LIC_Filters.3' -a "${1}" != "-c" ; then 
  751.   echo shar: Will not clobber existing file \"'lic.1.3/liblic/LIC_Filters.3'\"
  752. else
  753.   echo shar: Extracting \"'lic.1.3/liblic/LIC_Filters.3'\" \(7604 characters\)
  754.   sed "s/^X//" >'lic.1.3/liblic/LIC_Filters.3' <<'END_OF_FILE'
  755. X.\" Copyright (c) 1993 The Regents of the University of California.
  756. X.\" All rights reserved.
  757. X.\"
  758. X.\" Redistribution and use in source and binary forms, with or without
  759. X.\" modification, are permitted provided that the following conditions
  760. X.\" are met:
  761. X.\" 1. Redistributions of source code must retain the above copyright
  762. X.\"    notice, this list of conditions and the following disclaimer.
  763. X.\" 2. Redistributions in binary form must reproduce the above copyright
  764. X.\"    notice, this list of conditions and the following disclaimer in the
  765. X.\"    documentation and/or other materials provided with the distribution.
  766. X.\" 3. All advertising materials mentioning features or use of this software
  767. X.\"    must display the following acknowledgement:
  768. X.\"    This product includes software developed by the University of
  769. X.\"    California, Lawrence Livermore National Laboratory and its
  770. X.\"    contributors.
  771. X.\" 4. Neither the name of the University nor the names of its contributors
  772. X.\"    may be used to endorse or promote products derived from this software
  773. X.\"    without specific prior written permission.
  774. X.\"
  775. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  776. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  777. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  778. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  779. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  780. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  781. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  782. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  783. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  784. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  785. X.\" SUCH DAMAGE.
  786. X.\"
  787. X.de Hd
  788. X.ds Dt \\$4
  789. X..
  790. X.Hd $Header: /usr/local/src/lic/liblic/RCS/LIC_Filters.3,v 1.7 1993/08/10 23:35:32 casey Exp $
  791. X.TH LIC_FILTERS 3 \*(Dt
  792. X.SH NAME
  793. XLIC_BuildIntegralTables, LIC_Box, LIC_Ripple, LIC_Ramp, LIC_Select \- Line Integral Convolution filter support
  794. X.SH SYNOPSIS
  795. X.nf
  796. X#include <lic.h>
  797. X
  798. Xvoid \fBLIC_BuildIntegralTables\fP(LIC *\fIThis\fP)
  799. Xdouble \fBLIC_Box\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  800. Xdouble \fBLIC_Ripple\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  801. Xdouble \fBLIC_Ramp\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  802. Xdouble \fBLIC_Select\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  803. X.fi
  804. X.SH DESCRIPTION
  805. X.if t .ds pi \(*p
  806. X.if n .ds pi Pi
  807. X.B LIC_BuildIntegralTables
  808. Xbuilds tables of filter integral values for use in the LIC convolution
  809. Xmethods.
  810. X.B LIC_BuildIntegralTables
  811. Xis automatically called by the convolution methods whenever any parameters
  812. Xhave changed that will affect the filter integrals.
  813. X.PP
  814. XThe tables are discrete samples of the filter function integral for a
  815. Xvariety of points along the filter kernel and for a variety of
  816. X.IR speeds .
  817. X.PP
  818. XThe
  819. X.I speed
  820. Xvariations are used to implement the variable speed option of
  821. X.BR LIC_Create .
  822. XWith the variable speed option, high magnitude regions of the field will
  823. Xuse higher
  824. X.I speed
  825. Xversions of the filter kernel.  These higher speeds variations are typically
  826. Xfrequency scaled versions of the base frequency and are used in periodic
  827. Xmotion animations to give the appearance of higher speed in higher magnitude
  828. Xregions of the vector field.
  829. XHowever, it is up to each filter integral function to implement its own
  830. Xinterpretation of
  831. X.I speed
  832. X(see
  833. X.B LIC_Ripple
  834. Xbelow).
  835. X.PP
  836. XThe tables are broken up into integral values for the
  837. Xpositive and negative halves of the filter integral as follows:
  838. X.PP
  839. X.RS
  840. X.nf
  841. Xpos[\fIspeed\fP][\fIsi\fP] = \fIFilter\fP(\fIThis\fP, 0.0, \fIs\fP, \fIspeed\fP)
  842. Xneg[\fIspeed\fP][\fIsi\fP] = \fIFilter\fP(\fIThis\fP, -\fIs\fP, 0.0, \fIspeed\fP)
  843. X
  844. Xwhere
  845. X
  846. X0 <= \fIsi\fP < \fBLIC_INTEGRAL_LEN\fP
  847. X0 <= \fIspeed\fP < \fBLIC_INTEGRAL_SPEEDS\fP
  848. X
  849. X\fIs\fP = \fILength\fP * ((double)\fIsi\fP / \fBLIC_INTEGRAL_LEN\fP)
  850. X.fi
  851. X.RE
  852. X.PP
  853. XCurrently
  854. X.B LIC_INTEGRAL_LEN
  855. Xis 2048 and
  856. X.B LIC_INTEGRAL_SPEEDS
  857. Xis 20.
  858. X.PP
  859. XThe tables are built up by calling a user specified filter integration
  860. Xfunction for each of the above discrete sample points.  A simple example
  861. Xis a ramp filter:
  862. X.PP
  863. X.RS
  864. X.nf
  865. X\fIk\fP(\fIs\fP) = (\fIs\fP + \fIL\fP) / 2\fIL\fP
  866. X
  867. Xintegral { \fIk\fP(\fIs\fP) \fIds\fP } = \c
  868. X.if t (\fIs\fP\u\s-22\s+2\d + 2\fIL\fP\|\fIs\fP)/4\fIL\fP
  869. X.if n (\fIs\fP^2 + 2\fIL\fP*\fIs\fP)/4\fIL\fP
  870. X.fi
  871. X.RE
  872. X.PP
  873. XWhich yields the following LIC filter integral function (with some algebraic
  874. Xsimplifications):
  875. X.PP
  876. X.RS
  877. X.nf
  878. Xdouble
  879. XLIC_Ramp(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  880. X{
  881. X.RS
  882. Xif (\fBLIC_Length\fP(\fIThis\fP) == 0)
  883. X.RS
  884. Xreturn(0.0);
  885. X.RE
  886. Xelse
  887. X.RS
  888. Xreturn((\fIa\fP*\fIa\fP - \fIb\fP*\fIb\fP)/(4*\fBLIC_Length\fP(\fIThis\fP)) + (\fIa\fP - \fIb\fP)/2);
  889. X.RE
  890. X.RE
  891. X}
  892. X.fi
  893. X.RE
  894. X.PP
  895. XFilters supplied with
  896. Xthe LIC library include:
  897. X.PP
  898. X.RS
  899. X.nf
  900. Xdouble \fBLIC_Box\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  901. Xdouble \fBLIC_Ripple\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  902. Xdouble \fBLIC_Ramp\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  903. Xdouble \fBLIC_Select\fP(LIC *\fIThis\fP, double \fIa\fP, double \fIb\fP, int \fIspeed\fP)
  904. X.fi
  905. X.RE
  906. X.PP
  907. X.B LIC_Box
  908. Ximplements a constant box shape filter: \fIk\fP(\fIs\fP) =  1.
  909. X.PP
  910. X.B LIC_Ripple
  911. Ximplements a phase shifted Hanning ripple function, windowed by a Hanning
  912. Xfunction: \fIk\fP(\fIs\fP) = (cos(\fId\fP*\fIs\fP + \fIphase\fP) + 1)/2
  913. X* (cos(\fIc\fP*\fIs\fP) + 1)/2.
  914. XWhere
  915. X.I d
  916. Xand
  917. X.I c
  918. Xare the dilation constants for the ripple and window functions,
  919. Xrespectively, and
  920. X.I phase
  921. Xis the phase shift of the ripple function.
  922. X.I d
  923. Xand
  924. X.I c
  925. Xcontrol the number of cycles of the Hanning functions over the filter kernel
  926. Xfrom
  927. X.RI - Length
  928. Xto
  929. X.RI + Length .
  930. X.I d
  931. Xis equal to \fIfrequency\fP * \*(pi / \fILength\fP and
  932. X.I c
  933. Xis always equal to \*(pi / \fILength\fP.
  934. X.I frequency
  935. Xis computed as follows:
  936. X.PP
  937. X.RS
  938. X.nf
  939. X/*
  940. X * Implement ``speed'' variations by scaling the frequency inversely
  941. X * to speed.  This causes low magnitude vectors to be convolved using
  942. X * a higher frequency filter which will yield less distinct output
  943. X * features.  As the frequency increases the filter begins to approximate
  944. X * the Hanning window filter.
  945. X */
  946. X\fIm\fP = 6.0 - 5.0*(double)\fIspeed\fP/(\fBLIC_INTEGRAL_SPEEDS\fP - 1);
  947. X
  948. X\fIfrequency\fP = \fBLIC_Frequency\fP(\fIThis\fP) * \fIm\fP;
  949. X.fi
  950. X.RE
  951. X.PP
  952. XThis causes high magnitude regions to have fast moving, long
  953. Xblurred looking features and low magnitude regions to have
  954. Xslow moving, small sharp features over a blurred base.
  955. X.PP
  956. X.B LIC_Ramp
  957. Ximplements  a ramp shape filter whose value is
  958. X.B 0
  959. Xat
  960. X.RI - Length
  961. Xand
  962. X.B 1
  963. Xat
  964. X.RI + Length :
  965. X\fIk\fP(\fIs\fP) = (\fIs\fP + \fIL\fP) / 2\fIL\fP.
  966. X.PP
  967. X.B LIC_Select
  968. Ximplements a pixel selection filter which uses a narrow Gaussian
  969. Xfilter positioned
  970. X.IR L -2
  971. Xdistance along the local streamline. It is called a selection filter
  972. Xbecause its effect is to select an approximately one pixel wide
  973. Xsection of the input image near the end of the local streamline
  974. Xunderneath the Gaussian and place it at the origin of the local
  975. Xstreamline.  A narrow Gaussian was chosen for its low-pass filter
  976. Xqualities and simple analytical form, and is given by:
  977. X\fIk\fP(\fIs\fP) = 1 / 2 * exp(-(\fIs\fP + \fIL\fP - 2)^2).
  978. X.SH "SEE ALSO"
  979. X.BR LIC (3),
  980. X.BR LIC_Convolve (3),
  981. X.BR LIC_Create (3)
  982. X.SH STANDARDS
  983. XThis is unsupported, non-standard software.  It is not the subject of any
  984. Xstandards effort.
  985. END_OF_FILE
  986.   if test 7604 -ne `wc -c <'lic.1.3/liblic/LIC_Filters.3'`; then
  987.     echo shar: \"'lic.1.3/liblic/LIC_Filters.3'\" unpacked with wrong size!
  988.   fi
  989.   # end of 'lic.1.3/liblic/LIC_Filters.3'
  990. fi
  991. if test -f 'lic.1.3/liblic/liblic.h' -a "${1}" != "-c" ; then 
  992.   echo shar: Will not clobber existing file \"'lic.1.3/liblic/liblic.h'\"
  993. else
  994.   echo shar: Extracting \"'lic.1.3/liblic/liblic.h'\" \(6075 characters\)
  995.   sed "s/^X//" >'lic.1.3/liblic/liblic.h' <<'END_OF_FILE'
  996. X/*
  997. X * $Header: /usr/local/src/lic/liblic/RCS/liblic.h,v 1.3 1993/05/28 04:27:31 casey Exp $
  998. X */
  999. X
  1000. X/*
  1001. X * Copyright (c) 1993 The Regents of the University of California.
  1002. X * All rights reserved.
  1003. X *
  1004. X * Redistribution and use in source and binary forms, with or without
  1005. X * modification, are permitted provided that the following conditions
  1006. X * are met:
  1007. X * 1. Redistributions of source code must retain the above copyright
  1008. X *    notice, this list of conditions and the following disclaimer.
  1009. X * 2. Redistributions in binary form must reproduce the above copyright
  1010. X *    notice, this list of conditions and the following disclaimer in the
  1011. X *    documentation and/or other materials provided with the distribution.
  1012. X * 3. All advertising materials mentioning features or use of this software
  1013. X *    must display the following acknowledgement:
  1014. X *    This product includes software developed by the University of
  1015. X *    California, Lawrence Livermore National Laboratory and its
  1016. X *    contributors.
  1017. X * 4. Neither the name of the University nor the names of its contributors
  1018. X *    may be used to endorse or promote products derived from this software
  1019. X *    without specific prior written permission.
  1020. X *
  1021. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1022. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1023. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1024. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1025. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1026. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1027. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1028. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1029. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1030. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1031. X * SUCH DAMAGE.
  1032. X */
  1033. X
  1034. X#ifndef _LIBLIC_H_
  1035. X#define _LIBLIC_H_
  1036. X
  1037. X
  1038. X/*
  1039. X * ANSI C and POSIX includes.
  1040. X */
  1041. X#include <stdlib.h>
  1042. X#include <unistd.h>
  1043. X#include <errno.h>
  1044. X#include <string.h>
  1045. X#include <stdio.h>
  1046. X#include <sys/types.h>
  1047. X
  1048. X#include <math.h>
  1049. X
  1050. X#include <lic.h>
  1051. X
  1052. X
  1053. X/*
  1054. X * Input and output image configuration.  Should really be handled
  1055. X * dynamically at run-time ...
  1056. X */
  1057. X#if !defined(RGBA) && !defined(ABGR) && !defined(ARGB) && !defined(BGRA) \
  1058. X    && !defined(RGB) && !defined(BGR) && !defined(MONOCHROME)
  1059. X#   define ARGB
  1060. X#endif
  1061. X
  1062. X#ifdef RGBA
  1063. X#   define PixelSize    4
  1064. X#   define PixelType    "RGBA"
  1065. X#   define ALPHA(i)    (i)[3]
  1066. X#   define RED(i)    (i)[0]
  1067. X#   define GREEN(i)    (i)[1]
  1068. X#   define BLUE(i)    (i)[2]
  1069. X#endif
  1070. X
  1071. X#ifdef BGRA
  1072. X#   define PixelSize    4
  1073. X#   define PixelType    "BGRA"
  1074. X#   define ALPHA(i)    (i)[3]
  1075. X#   define RED(i)    (i)[2]
  1076. X#   define GREEN(i)    (i)[1]
  1077. X#   define BLUE(i)    (i)[0]
  1078. X#endif
  1079. X
  1080. X#ifdef ARGB
  1081. X#   define PixelSize    4
  1082. X#   define PixelType    "ARGB"
  1083. X#   define ALPHA(i)    (i)[0]
  1084. X#   define RED(i)    (i)[1]
  1085. X#   define GREEN(i)    (i)[2]
  1086. X#   define BLUE(i)    (i)[3]
  1087. X#endif
  1088. X
  1089. X#ifdef ABGR
  1090. X#   define PixelSize    4
  1091. X#   define PixelType    "ABGR"
  1092. X#   define ALPHA(i)    (i)[0]
  1093. X#   define RED(i)    (i)[3]
  1094. X#   define GREEN(i)    (i)[2]
  1095. X#   define BLUE(i)    (i)[1]
  1096. X#endif
  1097. X
  1098. X#ifdef RGB
  1099. X#   define PixelSize    3
  1100. X#   define PixelType    "RGB"
  1101. X#   define ALPHA(i)    (i)[0]
  1102. X#   define RED(i)    (i)[0]
  1103. X#   define GREEN(i)    (i)[1]
  1104. X#   define BLUE(i)    (i)[2]
  1105. X#endif
  1106. X
  1107. X#ifdef BGR
  1108. X#   define PixelSize    3
  1109. X#   define PixelType    "BGR"
  1110. X#   define ALPHA(i)    (i)[0]
  1111. X#   define RED(i)    (i)[2]
  1112. X#   define GREEN(i)    (i)[1]
  1113. X#   define BLUE(i)    (i)[0]
  1114. X#endif
  1115. X
  1116. X#ifdef MONOCHROME
  1117. X#   define PixelSize    1
  1118. X#   define PixelType    "MONOCHROME"
  1119. X#   define ALPHA(i)    (i)[0]
  1120. X#endif
  1121. X
  1122. X
  1123. X/*
  1124. X * Access macros for row major rectilinear images and other array data.
  1125. X */
  1126. X#define INDEX_2D(f, x, y) \
  1127. X    ((f).data + (f).Rank * ((y)*(f).Xres + (x)))
  1128. X
  1129. X#define INDEX_3D(f, x, y, z) \
  1130. X    ((f).data + (f).Rank * (((z)*(f).Yres + (y))*(f).Xres + (x)))
  1131. X
  1132. X
  1133. X/*
  1134. X * Amount of bias used to insure that we step over pixel/cell boundaries
  1135. X * when performing vector field stream line advection.
  1136. X */
  1137. X#define ROUND_OFF    0.00001
  1138. X
  1139. X
  1140. X/*
  1141. X * Default parallel edge/vector tolerance.  If an advected stream line and
  1142. X * an edge meet at an angle less than or equal to PARALLEL_EDGE, treat it
  1143. X * as an intersection of parallel lines (sic) and extend the advected stream
  1144. X * line out till it meets the next edge.
  1145. X */
  1146. X#define SIN_PARALLEL    0.523359562429    /* sin(three degrees) */
  1147. X#ifndef M_PI
  1148. X#   define M_PI        3.141592653589793116
  1149. X#endif
  1150. X
  1151. X
  1152. X/*
  1153. X * Define DEBUG to dump out PostScript to draw the streamline for the
  1154. X * vector field cell where the condition ThisPixel is TRUE.  Use the
  1155. X * PostScript prologue DebugPrologue.ps in this directory to get nice
  1156. X * output.  Note that this only works for two-dimensional fields.
  1157. X */
  1158. X#ifdef DEBUG
  1159. X#   define ThisPixel  (i == 42 && j == 64)
  1160. X#endif
  1161. X
  1162. X
  1163. X/*
  1164. X * define REGISTER to register on some machines for speed ...
  1165. X */
  1166. X#define REGISTER  register
  1167. X
  1168. X
  1169. X/*
  1170. X * Handy macros.
  1171. X */
  1172. X#define SQUARE(x)    ((x)*(x))
  1173. X#define SIGN(x)        (((x) > 0) ? 1 : (((x) < 0) ? -1 : 0))
  1174. X#define CLAMP(x)    (((x) > 255) ? 255 : (((x) < 0) ?  0 : (x)))
  1175. X
  1176. X
  1177. X/*
  1178. X * Macro to wrap pixel coordinates in a torus like topology: 0 .. width-1.
  1179. X */
  1180. X#define WRAP(i, width) \
  1181. X{ \
  1182. X    if ((i) < 0) \
  1183. X    { \
  1184. X    /* we'll never be off more than one width negatively */ \
  1185. X    (i) += (width); \
  1186. X    } \
  1187. X    else if ((i) >= (width)) \
  1188. X    { \
  1189. X    /* we may be very far off positively ... */ \
  1190. X    (i) %= (width); \
  1191. X    } \
  1192. X}
  1193. X
  1194. X
  1195. X/*
  1196. X * Macros to take the floor and ceil of real numbers representing coordinates
  1197. X * within a vector lattice.  Since we're dealing with lattice coordinates,
  1198. X * we know that we're dealing with positive numbers, so we get to use
  1199. X * trucation to get floor.  Moreover, since we definitely won't be working
  1200. X * with vector fields with indexes larger than an int, we get to do the
  1201. X * truncation by simply casting into an int.  Finally, since we're dealing
  1202. X * with lattice coordinates, we get to use truncation + 1 to get ceil.
  1203. X */
  1204. X#define FLOOR(x)  ((double)(int)(x))
  1205. X#define CEIL(x)   ((double)((int)(x) + 1))
  1206. X#define IFLOOR(x) ((int)(x))
  1207. X#define ICEIL(x)  ((int)(x) + 1)
  1208. X
  1209. X
  1210. X#endif /* _LIBLIC_H_ */
  1211. END_OF_FILE
  1212.   if test 6075 -ne `wc -c <'lic.1.3/liblic/liblic.h'`; then
  1213.     echo shar: \"'lic.1.3/liblic/liblic.h'\" unpacked with wrong size!
  1214.   fi
  1215.   # end of 'lic.1.3/liblic/liblic.h'
  1216. fi
  1217. if test -f 'lic.1.3/lic/Makefile.tmpl' -a "${1}" != "-c" ; then 
  1218.   echo shar: Will not clobber existing file \"'lic.1.3/lic/Makefile.tmpl'\"
  1219. else
  1220.   echo shar: Extracting \"'lic.1.3/lic/Makefile.tmpl'\" \(1219 characters\)
  1221.   sed "s/^X//" >'lic.1.3/lic/Makefile.tmpl' <<'END_OF_FILE'
  1222. X#
  1223. X# $Header: /usr/local/src/lic/lic/RCS/Makefile.tmpl,v 1.4 1993/11/03 20:22:18 casey Exp $
  1224. X#
  1225. X      DEFINES = $(MMAP_DEFINES)
  1226. X
  1227. X        SRCS1 = lic.c
  1228. X        OBJS1 = lic.o
  1229. X     DEPLIBS1 = $(LIBLIC)
  1230. X     SYSLIBS1 = $(MPC_EXTRALIBS) -lm
  1231. X     PROGRAM1 = lic
  1232. X        MANS1 = lic.1
  1233. X
  1234. X         SRCS = $(SRCS1)
  1235. X          ALL = $(PROGRAM1)
  1236. X
  1237. Xall: $(ALL)
  1238. X
  1239. Xincludes:
  1240. X
  1241. X$(PROGRAM1): $(OBJS1) $(DEPLIBS1)
  1242. X    $(CC) $(CFLAGS) -o $(PROGRAM1) $(OBJS1) $(DEPLIBS1) $(SYSLIBS1)
  1243. X
  1244. Xinstall: $(ALL) $(BINDIR) install_$(MANINSTALL)
  1245. X    rm -f $(BINDIR)/$(PROGRAM1)
  1246. X    cp $(PROGRAM1) $(BINDIR)/$(PROGRAM1)
  1247. X    $(STRIP) $(BINDIR)/$(PROGRAM1)
  1248. X    chmod $(INSTBINPROT) $(BINDIR)/$(PROGRAM1)
  1249. X
  1250. Xinstall_man: $(MANROOT) $(MAN1DIR) lic.1
  1251. X    rm -f $(MAN1DIR)/$(PROGRAM1).$(MAN1EXT)
  1252. X    cp lic.1 $(MAN1DIR)/$(PROGRAM1).$(MAN1EXT)
  1253. X    chmod $(INSTMANPROT) $(MAN1DIR)/lic.$(MAN1EXT)
  1254. X
  1255. Xinstall_cat: $(MANROOT) $(MAN1DIR) lic.1
  1256. X    rm -f $(MAN1DIR)/lic.$(MAN1EXT)
  1257. X    $(NROFF) -man lic.1 > $(MAN1DIR)/$(PROGRAM1).$(MAN1EXT)
  1258. X    chmod $(INSTMANPROT) $(MAN1DIR)/$(PROGRAM1).$(MAN1EXT)
  1259. X
  1260. Xinstall_none:
  1261. X
  1262. X$(BINDIR) $(MANROOT) $(MAN1DIR):
  1263. X    mkdir $@
  1264. X
  1265. Xclean:
  1266. X    rm -f $(PROGRAM1) $(OBJS1)
  1267. X    rm -f *~ *.o core a.out MAKELOG
  1268. X
  1269. Xlint:
  1270. X    lint -x $(ALLDEFINES) $(SRCS)
  1271. X
  1272. Xdepend:
  1273. X
  1274. Xlic.o: lic.c $(BUILDINCTOP)/lic.h
  1275. END_OF_FILE
  1276.   if test 1219 -ne `wc -c <'lic.1.3/lic/Makefile.tmpl'`; then
  1277.     echo shar: \"'lic.1.3/lic/Makefile.tmpl'\" unpacked with wrong size!
  1278.   fi
  1279.   # end of 'lic.1.3/lic/Makefile.tmpl'
  1280. fi
  1281. if test -f 'lic.1.3/test/ElectroStatic.c' -a "${1}" != "-c" ; then 
  1282.   echo shar: Will not clobber existing file \"'lic.1.3/test/ElectroStatic.c'\"
  1283. else
  1284.   echo shar: Extracting \"'lic.1.3/test/ElectroStatic.c'\" \(7826 characters\)
  1285.   sed "s/^X//" >'lic.1.3/test/ElectroStatic.c' <<'END_OF_FILE'
  1286. X/*
  1287. X * $Header: /usr/local/src/lic/test/RCS/ElectroStatic.c,v 1.7 1993/11/04 02:24:20 casey Exp $
  1288. X */
  1289. X
  1290. X/*
  1291. X * Copyright (c) 1993 The Regents of the University of California.
  1292. X * All rights reserved.
  1293. X *
  1294. X * Redistribution and use in source and binary forms, with or without
  1295. X * modification, are permitted provided that the following conditions
  1296. X * are met:
  1297. X * 1. Redistributions of source code must retain the above copyright
  1298. X *    notice, this list of conditions and the following disclaimer.
  1299. X * 2. Redistributions in binary form must reproduce the above copyright
  1300. X *    notice, this list of conditions and the following disclaimer in the
  1301. X *    documentation and/or other materials provided with the distribution.
  1302. X * 3. All advertising materials mentioning features or use of this software
  1303. X *    must display the following acknowledgement:
  1304. X *    This product includes software developed by the University of
  1305. X *    California, Lawrence Livermore National Laboratory and its
  1306. X *    contributors.
  1307. X * 4. Neither the name of the University nor the names of its contributors
  1308. X *    may be used to endorse or promote products derived from this software
  1309. X *    without specific prior written permission.
  1310. X *
  1311. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1312. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1313. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1314. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1315. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1316. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1317. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1318. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1319. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1320. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1321. X * SUCH DAMAGE.
  1322. X */
  1323. X
  1324. X#ifndef lint
  1325. X    static char rcsid[] = "$Header: /usr/local/src/lic/test/RCS/ElectroStatic.c,v 1.7 1993/11/04 02:24:20 casey Exp $";
  1326. X    static char copyright[] =
  1327. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  1328. X    "All rights reserved.\n";
  1329. X#endif
  1330. X
  1331. X
  1332. X#include <stdlib.h>
  1333. X#include <unistd.h>
  1334. X#include <errno.h>
  1335. X#include <fcntl.h>
  1336. X#include <string.h>
  1337. X#include <stdio.h>
  1338. X
  1339. X#include <math.h>
  1340. X#include <sys/types.h>
  1341. X
  1342. X#if defined(HAS_MMAP)
  1343. X#   include <sys/mman.h>
  1344. X#endif
  1345. X
  1346. X
  1347. X#ifdef NEED_STRERROR
  1348. X    /*
  1349. X     * strerror is supposed to be defined in <string.h> and supplied in the
  1350. X     * standard C library according to the ANSI C X3.159-1989 specification,
  1351. X     * but Sun OS 4.1.1 fails to define or supply it ...  Unfortunately the
  1352. X     * only way we can control this is with an externally supplied define.
  1353. X     */
  1354. X    extern int      errno;        /* system error number */
  1355. X    extern char     *sys_errlist[];    /* system error messages */
  1356. X    extern int      sys_nerr;        /* number of entries in sys_errlist */
  1357. X
  1358. X    char *
  1359. X    strerror(int err)
  1360. X    {
  1361. X    if (err < 0 || err >= sys_nerr) {
  1362. X        static char msg[100];
  1363. X
  1364. X        sprintf(msg, "system error number %d", err);
  1365. X        return(msg);
  1366. X    }
  1367. X    return(sys_errlist[err]);
  1368. X    }
  1369. X#endif
  1370. X
  1371. X
  1372. X/*
  1373. X * Create a three-dimensional electrostatic charge floating point vector
  1374. X * field.
  1375. X */
  1376. X
  1377. X
  1378. X#define SQUARE(x) ((x)*(x))
  1379. X
  1380. X#define N_CHARGES 2
  1381. Xdouble charge[N_CHARGES]   = { 1000.0, -1000.0 };
  1382. Xdouble charge_x[N_CHARGES] = { 1, -1 };
  1383. Xdouble charge_y[N_CHARGES] = { 1, -1 };
  1384. Xdouble charge_z[N_CHARGES] = { 1, -1 };
  1385. X
  1386. X
  1387. X/*
  1388. X * Internal routines to calculate electrostatic field values.
  1389. X */
  1390. Xdouble Fx(double x, double y, double z);
  1391. Xdouble Fy(double x, double y, double z);
  1392. Xdouble Fz(double x, double y, double z);
  1393. X
  1394. X
  1395. Xmain(int argc, char **argv)
  1396. X{
  1397. X    char          *myname;
  1398. X    char          *file;
  1399. X    int            Xres, Yres, Zres;
  1400. X    float         *VectorField;
  1401. X    size_t         FieldSize;
  1402. X    register int   i,  j, k;
  1403. X    register float x,  y,  z;
  1404. X    register float fx, fy, fz;
  1405. X    int            fd;
  1406. X    
  1407. X    myname = argv[0];
  1408. X    if (argc != 5)
  1409. X    {
  1410. X    fprintf(stderr, "\nUsage: %s file_name x_res y_res z_res\n", myname);
  1411. X    exit(1);
  1412. X    }
  1413. X    
  1414. X    /* grab arguments */
  1415. X    file = argv[1];
  1416. X    Xres = atoi(argv[2]);
  1417. X    Yres = atoi(argv[3]);
  1418. X    Zres = atoi(argv[4]);
  1419. X    FieldSize = Xres*Yres*Zres*(3*sizeof(float));
  1420. X    
  1421. X    /*
  1422. X     * Open the file here even for the non-mmap version just to make sure
  1423. X     * we can create it.  Have to use O_RDWR rather than O_WRONLY because
  1424. X     * the mmap version will end up ``paging in pages from the file'' (sic).
  1425. X     * In reality they'll just be zero fill on demand pages ...
  1426. X     */
  1427. X    fd = open(file, O_CREAT|O_TRUNC|O_RDWR, 0666);
  1428. X    if (fd < 0)
  1429. X    {
  1430. X    (void)fprintf(stderr, "%s: unable to open %s: %s\n",
  1431. X              myname, file, strerror(errno));
  1432. X    exit(EXIT_FAILURE);
  1433. X    /*NOTREACHED*/
  1434. X    }
  1435. X
  1436. X#if defined(HAS_MMAP)
  1437. X
  1438. X    /*
  1439. X     * Pre-extend file to it's final size and map it into memory.
  1440. X     */
  1441. X    (void)lseek(fd, (off_t)(FieldSize - sizeof(fd)), SEEK_SET);
  1442. X    if (write(fd, (void *)&fd, sizeof(fd)) != sizeof(fd))
  1443. X    {
  1444. X    (void)fprintf(stderr, "%s: unable to preextend %s to %ld bytes: %s\n",
  1445. X              myname, file, (int)FieldSize, strerror(errno));
  1446. X    (void)close(fd);
  1447. X    exit(EXIT_FAILURE);
  1448. X    /*NOTREACHED*/
  1449. X    }
  1450. X    VectorField = (float *)mmap((void *)0, (int)FieldSize, PROT_WRITE,
  1451. X                    MAP_SHARED, fd, (off_t)0);
  1452. X    if ((int)VectorField == -1)
  1453. X    {
  1454. X    (void)fprintf(stderr, "%s: unable to map %s: %s\n",
  1455. X              myname, file, strerror(errno));
  1456. X    (void)close(fd);
  1457. X    exit(EXIT_FAILURE);
  1458. X    /*NOTREACHED*/
  1459. X    }
  1460. X    (void)close(fd);
  1461. X
  1462. X#else /* HAS_MMAP */
  1463. X
  1464. X    VectorField = (float *)malloc(FieldSize);
  1465. X    if (VectorField == NULL)
  1466. X    {
  1467. X    (void)fprintf(stderr, "%s: unable to allocate %d bytes of memory\n",
  1468. X              myname, (int)FieldSize);
  1469. X    (void)close(fd);
  1470. X    exit(EXIT_FAILURE);
  1471. X    /*NOTREACHED*/
  1472. X    }
  1473. X    /*
  1474. X     * Should probably try to write the field now just to make sure there's
  1475. X     * enough disk space ...
  1476. X     */
  1477. X
  1478. X#endif /* HAS_MMAP */
  1479. X    
  1480. X    /*
  1481. X     * Create the electrostatic vector field ...
  1482. X     */
  1483. X    for (k = 0; k < Zres; k++)
  1484. X    {
  1485. X    z = (float)k/(float)Zres * 10.0 - 5.0;
  1486. X
  1487. X    for (j = 0; j < Yres; j++)
  1488. X    {
  1489. X        y = (float)j/(float)Yres * 10.0 - 5.0;
  1490. X
  1491. X        for (i = 0; i < Xres; i++)
  1492. X        {
  1493. X        x = (float)i/(float)Xres * 10.0 - 5.0;
  1494. X        
  1495. X        fx = sqrt(fabs(Fx(x,y,z)));
  1496. X        fy = sqrt(fabs(Fy(x,y,z)));
  1497. X        fz = sqrt(fabs(Fz(x,y,z)));
  1498. X        
  1499. X        VectorField[3*(i + j*Xres + k*Xres*Yres) + 0] =  fx;
  1500. X        VectorField[3*(i + j*Xres + k*Xres*Yres) + 1] = -fy;
  1501. X        VectorField[3*(i + j*Xres + k*Xres*Yres) + 2] =  fz;
  1502. X        }
  1503. X    }
  1504. X    }
  1505. X
  1506. X#if !defined(HAS_MMAP)
  1507. X    if (write(fd, (void *)VectorField, FieldSize) != FieldSize)
  1508. X    {
  1509. X    (void)fprintf(stderr, "%s: unable to write %ld bytes to %s: %s\n",
  1510. X              myname, (int)FieldSize, file, strerror(errno));
  1511. X    (void)close(fd);
  1512. X    exit(EXIT_FAILURE);
  1513. X    /*NOTREACHED*/
  1514. X    }
  1515. X    (void)close(fd);
  1516. X#endif
  1517. X}
  1518. X
  1519. X
  1520. Xdouble
  1521. XFx(double x, double y, double z)
  1522. X{
  1523. X    int    i;
  1524. X    double sum;
  1525. X    
  1526. X    sum = 0;
  1527. X    for (i = 0; i < N_CHARGES; i++)
  1528. X    {
  1529. X    double d2 =  SQUARE(x - charge_x[i])
  1530. X           + SQUARE(y - charge_y[i])
  1531. X           + SQUARE(z - charge_z[i]);
  1532. X    sum += (charge[i] / d2) * ((x - charge_x[i]) / sqrt(d2));
  1533. X    }
  1534. X    return(sum);
  1535. X}
  1536. X
  1537. X
  1538. Xdouble
  1539. XFy(double x, double y, double z)
  1540. X{
  1541. X    int    i;
  1542. X    double sum;
  1543. X    
  1544. X    sum = 0;
  1545. X    for (i = 0; i < N_CHARGES; i++)
  1546. X    {
  1547. X    double d2 =  SQUARE(x - charge_x[i])
  1548. X           + SQUARE(y - charge_y[i])
  1549. X           + SQUARE(z - charge_z[i]);
  1550. X    sum += (charge[i] / d2) * ((y - charge_y[i]) / sqrt(d2));
  1551. X    }
  1552. X    return(sum);
  1553. X}
  1554. X
  1555. X
  1556. Xdouble
  1557. XFz(double x, double y, double z)
  1558. X{
  1559. X    int    i;
  1560. X    double sum;
  1561. X    
  1562. X    sum = 0;
  1563. X    for (i = 0; i < N_CHARGES; i++)
  1564. X    {
  1565. X    double d2 =  SQUARE(x - charge_x[i])
  1566. X           + SQUARE(y - charge_y[i])
  1567. X           + SQUARE(z - charge_z[i]);
  1568. X    sum += (charge[i] / d2) * ((z - charge_z[i]) / sqrt(d2));
  1569. X    }
  1570. X    return(sum);
  1571. X}
  1572. END_OF_FILE
  1573.   if test 7826 -ne `wc -c <'lic.1.3/test/ElectroStatic.c'`; then
  1574.     echo shar: \"'lic.1.3/test/ElectroStatic.c'\" unpacked with wrong size!
  1575.   fi
  1576.   # end of 'lic.1.3/test/ElectroStatic.c'
  1577. fi
  1578. if test -f 'lic.1.3/test/SpiralField.c' -a "${1}" != "-c" ; then 
  1579.   echo shar: Will not clobber existing file \"'lic.1.3/test/SpiralField.c'\"
  1580. else
  1581.   echo shar: Extracting \"'lic.1.3/test/SpiralField.c'\" \(5068 characters\)
  1582.   sed "s/^X//" >'lic.1.3/test/SpiralField.c' <<'END_OF_FILE'
  1583. X/*
  1584. X * $Header: /usr/local/src/lic/test/RCS/SpiralField.c,v 1.7 1993/11/05 01:46:08 casey Exp $
  1585. X */
  1586. X
  1587. X/*
  1588. X * Copyright (c) 1993 The Regents of the University of California.
  1589. X * All rights reserved.
  1590. X *
  1591. X * Redistribution and use in source and binary forms, with or without
  1592. X * modification, are permitted provided that the following conditions
  1593. X * are met:
  1594. X * 1. Redistributions of source code must retain the above copyright
  1595. X *    notice, this list of conditions and the following disclaimer.
  1596. X * 2. Redistributions in binary form must reproduce the above copyright
  1597. X *    notice, this list of conditions and the following disclaimer in the
  1598. X *    documentation and/or other materials provided with the distribution.
  1599. X * 3. All advertising materials mentioning features or use of this software
  1600. X *    must display the following acknowledgement:
  1601. X *    This product includes software developed by the University of
  1602. X *    California, Lawrence Livermore National Laboratory and its
  1603. X *    contributors.
  1604. X * 4. Neither the name of the University nor the names of its contributors
  1605. X *    may be used to endorse or promote products derived from this software
  1606. X *    without specific prior written permission.
  1607. X *
  1608. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1609. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1610. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1611. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1612. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1613. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1614. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1615. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1616. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1617. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1618. X * SUCH DAMAGE.
  1619. X */
  1620. X
  1621. X#ifndef lint
  1622. X    static char rcsid[] = "$Header: /usr/local/src/lic/test/RCS/SpiralField.c,v 1.7 1993/11/05 01:46:08 casey Exp $";
  1623. X    static char copyright[] =
  1624. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  1625. X    "All rights reserved.\n";
  1626. X#endif
  1627. X
  1628. X
  1629. X#include <stdlib.h>
  1630. X#include <unistd.h>
  1631. X#include <errno.h>
  1632. X#include <fcntl.h>
  1633. X#include <string.h>
  1634. X#include <stdio.h>
  1635. X
  1636. X
  1637. X/*
  1638. X * Create a three-dimensional floating point spiral vector field.  Each
  1639. X * vector will point 90 degrees, clockwise, away from the vertical (Z)
  1640. X * center of the field and slightly up: v(x, y, z) = (x, -y, 0.1).  Note
  1641. X * that the vector magnitudes are *not* equal to 1.0.
  1642. X */
  1643. X
  1644. X
  1645. X#ifdef NEED_STRERROR
  1646. X    /*
  1647. X     * strerror is supposed to be defined in <string.h> and supplied in the
  1648. X     * standard C library according to the ANSI C X3.159-1989 specification,
  1649. X     * but Sun OS 4.1.1 fails to define or supply it ...  Unfortunately the
  1650. X     * only way we can control this is with an externally supplied define.
  1651. X     */
  1652. X    extern int      errno;        /* system error number */
  1653. X    extern char     *sys_errlist[];    /* system error messages */
  1654. X    extern int      sys_nerr;        /* number of entries in sys_errlist */
  1655. X
  1656. X    char *
  1657. X    strerror(int err)
  1658. X    {
  1659. X    if (err < 0 || err >= sys_nerr) {
  1660. X        static char msg[100];
  1661. X
  1662. X        sprintf(msg, "system error number %d", err);
  1663. X        return(msg);
  1664. X    }
  1665. X    return(sys_errlist[err]);
  1666. X    }
  1667. X#endif
  1668. X
  1669. X
  1670. Xmain(int argc, char *argv[])
  1671. X{
  1672. X    char          *myname;
  1673. X    char          *file;
  1674. X    int            Xres, Yres, Zres;
  1675. X    float         *VectorField;
  1676. X    register float fx, fy;
  1677. X    register int   i, j, k;
  1678. X    int            fd, cc;
  1679. X
  1680. X    myname = argv[0];
  1681. X    if (argc != 5)
  1682. X    {
  1683. X    (void)fprintf(stderr, "usage: %s file-name x-res y-res z-res\n",
  1684. X              myname);
  1685. X    exit(EXIT_FAILURE);
  1686. X    }
  1687. X
  1688. X    /* grab arguments */
  1689. X    file    = argv[1];
  1690. X    Xres    = atoi(argv[2]);
  1691. X    Yres    = atoi(argv[3]);
  1692. X    Zres    = atoi(argv[4]);
  1693. X
  1694. X    VectorField = (float *)malloc(sizeof(float)*Yres*Xres*Zres*3);
  1695. X    if (VectorField == NULL)
  1696. X    {
  1697. X    (void)fprintf(stderr, "%s: insufficient memory for creating the spiral"
  1698. X              " field\n", myname);
  1699. X    exit(EXIT_FAILURE);
  1700. X    }
  1701. X
  1702. X    for ( k = 0; k < Yres; k++ )
  1703. X    {
  1704. X       for ( j = 0; j < Yres; j++ )
  1705. X       {
  1706. X      fy = (float)j/(float)(Yres-1) - 0.5;
  1707. X      for ( i = 0; i < Xres; i++ )
  1708. X      {
  1709. X         fx = (float)i/(float)(Xres-1) - 0.5;
  1710. X         VectorField[3*(k*Xres*Yres + (Yres-1 - j)*Xres + i) + 0] =  fy;
  1711. X         VectorField[3*(k*Xres*Yres + (Yres-1 - j)*Xres + i) + 1] = -fx;
  1712. X         VectorField[3*(k*Xres*Yres + (Yres-1 - j)*Xres + i) + 2] = 0.1;
  1713. X      }
  1714. X       }
  1715. X    }
  1716. X
  1717. X    fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666);
  1718. X    if (fd < 0)
  1719. X    {
  1720. X    (void)fprintf(stderr, "%s: unable to open %s: %s\n", myname, file,
  1721. X              strerror(errno));
  1722. X    exit(EXIT_FAILURE);
  1723. X    }
  1724. X
  1725. X    cc = write(fd, VectorField, 3*sizeof(float)*Xres*Yres*Zres);
  1726. X    if (cc != 3*sizeof(float)*Xres*Yres*Zres)
  1727. X    {
  1728. X    (void)fprintf(stderr, "%s: write returned short (%d): %s\n",
  1729. X              myname, cc, strerror(errno));
  1730. X    (void)close(fd);
  1731. X    exit(EXIT_FAILURE);
  1732. X    }
  1733. X    (void)close(fd);
  1734. X    exit(EXIT_SUCCESS);
  1735. X}
  1736. END_OF_FILE
  1737.   if test 5068 -ne `wc -c <'lic.1.3/test/SpiralField.c'`; then
  1738.     echo shar: \"'lic.1.3/test/SpiralField.c'\" unpacked with wrong size!
  1739.   fi
  1740.   # end of 'lic.1.3/test/SpiralField.c'
  1741. fi
  1742. if test -f 'lic.1.3/test/SpotNoise.c' -a "${1}" != "-c" ; then 
  1743.   echo shar: Will not clobber existing file \"'lic.1.3/test/SpotNoise.c'\"
  1744. else
  1745.   echo shar: Extracting \"'lic.1.3/test/SpotNoise.c'\" \(6438 characters\)
  1746.   sed "s/^X//" >'lic.1.3/test/SpotNoise.c' <<'END_OF_FILE'
  1747. X/*
  1748. X * $Header: /usr/local/src/lic/test/RCS/SpotNoise.c,v 1.3 1993/11/04 02:24:20 casey Exp $
  1749. X */
  1750. X
  1751. X/*
  1752. X * Copyright (c) 1993 The Regents of the University of California.
  1753. X * All rights reserved.
  1754. X *
  1755. X * Redistribution and use in source and binary forms, with or without
  1756. X * modification, are permitted provided that the following conditions
  1757. X * are met:
  1758. X * 1. Redistributions of source code must retain the above copyright
  1759. X *    notice, this list of conditions and the following disclaimer.
  1760. X * 2. Redistributions in binary form must reproduce the above copyright
  1761. X *    notice, this list of conditions and the following disclaimer in the
  1762. X *    documentation and/or other materials provided with the distribution.
  1763. X * 3. All advertising materials mentioning features or use of this software
  1764. X *    must display the following acknowledgement:
  1765. X *    This product includes software developed by the University of
  1766. X *    California, Lawrence Livermore National Laboratory and its
  1767. X *    contributors.
  1768. X * 4. Neither the name of the University nor the names of its contributors
  1769. X *    may be used to endorse or promote products derived from this software
  1770. X *    without specific prior written permission.
  1771. X *
  1772. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1773. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1774. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1775. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1776. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1777. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1778. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1779. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1780. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1781. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1782. X * SUCH DAMAGE.
  1783. X */
  1784. X
  1785. X#ifndef lint
  1786. X    static char rcsid[] = "$Header: /usr/local/src/lic/test/RCS/SpotNoise.c,v 1.3 1993/11/04 02:24:20 casey Exp $";
  1787. X    static char copyright[] =
  1788. X    "Copyright (c) 1993 The Regents of the University of California.\n"
  1789. X    "All rights reserved.\n";
  1790. X#endif
  1791. X
  1792. X
  1793. X/*
  1794. X * Create a spot noise image.  Place Gaussian blobs down in a pseudo-poisson
  1795. X * distribution using a jittered sampling technique ala Cook and Dippe.
  1796. X */
  1797. X
  1798. X
  1799. X#include <stdlib.h>
  1800. X#include <unistd.h>
  1801. X#include <errno.h>
  1802. X#include <fcntl.h>
  1803. X#include <string.h>
  1804. X#include <stdio.h>
  1805. X#include <sys/types.h>
  1806. X#include <math.h>
  1807. X
  1808. X#include <lic.h>
  1809. X
  1810. X
  1811. X#if (defined(NEED_STRERROR))
  1812. X    /*
  1813. X     * strerror is supposed to be defined in <string.h> and supplied in the
  1814. X     * standard C library according to the ANSI C X3.159-1989 specification,
  1815. X     * but Sun OS 4.1.1 fails to define or supply it ...  Unfortunately the
  1816. X     * only way we can control this is with an externally supplied define.
  1817. X     */
  1818. X    extern int      errno;        /* system error number */
  1819. X    extern char     *sys_errlist[];    /* system error messages */
  1820. X    extern int      sys_nerr;        /* number of entries in sys_errlist */
  1821. X
  1822. X    char *
  1823. X    strerror(int err)
  1824. X    {
  1825. X    if (err < 0 || err >= sys_nerr) {
  1826. X        static char msg[100];
  1827. X
  1828. X        sprintf(msg, "system error number %d", err);
  1829. X        return(msg);
  1830. X    }
  1831. X    return(sys_errlist[err]);
  1832. X    }
  1833. X#endif
  1834. X
  1835. X
  1836. X/*
  1837. X * Generate X_N_SPOTS by Y_N_SPOTS in image.  Each spot will be a soft Gaussian
  1838. X * blob 2*X_HALF_WIDTH by 2*Y_HALF_WIDTH.
  1839. X */
  1840. X#define X_N_SPOTS    20
  1841. X#define Y_N_SPOTS    20
  1842. X
  1843. X#define X_HALF_WIDTH    20
  1844. X#define Y_HALF_WIDTH    20
  1845. X
  1846. X
  1847. Xvoid RenderSpot(unsigned char *Image, int Xres, int Yres, int psize,
  1848. X        int u, int v);
  1849. Xdouble normal(double x, double s, double m);
  1850. X
  1851. X
  1852. Xmain(int argc, char *argv[])
  1853. X{
  1854. X    char          *myname;
  1855. X    char          *file;
  1856. X    int            Xres, Yres;
  1857. X    unsigned char *Image;
  1858. X    size_t         psize, ImageSize;
  1859. X    register int   i, j;
  1860. X    int            fd, cc;
  1861. X
  1862. X    myname = argv[0];
  1863. X    if (argc != 4)
  1864. X    {
  1865. X    (void)fprintf(stderr, "usage: %s file_name x_res y_res\n", myname);
  1866. X    exit(EXIT_FAILURE);
  1867. X    }
  1868. X
  1869. X    /* grab arguments */
  1870. X    file = argv[1];
  1871. X    Xres = atoi(argv[2]);
  1872. X    Yres = atoi(argv[3]);
  1873. X    
  1874. X    psize     = LIC_ConfiguredPixelSize();
  1875. X    ImageSize = sizeof(unsigned char) * Xres * Yres;
  1876. X    Image     = (unsigned char *) malloc(ImageSize*psize);
  1877. X
  1878. X    if (Image == NULL)
  1879. X    {
  1880. X    (void)fprintf(stderr, "%s: insufficient memory for creating the image"
  1881. X              " field\n", myname);
  1882. X    exit(EXIT_FAILURE);
  1883. X    }
  1884. X
  1885. X    fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666);
  1886. X    if (fd < 0)
  1887. X    {
  1888. X    (void)fprintf(stderr, "%s: unable to open %s: %s\n", myname, file,
  1889. X              strerror(errno));
  1890. X    exit(EXIT_FAILURE);
  1891. X    }
  1892. X
  1893. X    srand(98639);    /* Seed with a prime number */
  1894. X    for (i = 1; i < X_N_SPOTS; i++)
  1895. X    {
  1896. X    for (j = 1; j < Y_N_SPOTS; j++)
  1897. X    {
  1898. X        register int x, y;
  1899. X
  1900. X        x = ((rand()/(double)RAND_MAX - 0.5) * 0.70 + i)/X_N_SPOTS
  1901. X        * (double)Xres;
  1902. X        y = ((rand()/(double)RAND_MAX - 0.5) * 0.70 + j)/Y_N_SPOTS
  1903. X        * (double)Yres;
  1904. X
  1905. X#        if (defined(DEBUG))
  1906. X        fprintf(stderr, "Spot %d %d placed at %d %d\n", i, j, x, y);
  1907. X        fflush(stderr);
  1908. X#        endif
  1909. X
  1910. X        RenderSpot(Image, Xres, Yres, psize, x, y);
  1911. X    }
  1912. X    }
  1913. X
  1914. X    cc = write(fd, Image, ImageSize*psize);
  1915. X    if (cc != ImageSize*psize)
  1916. X    {
  1917. X       (void)fprintf(stderr, "%s: write returned short: %s\n", myname,
  1918. X             strerror(errno));
  1919. X       (void)close(fd);
  1920. X       exit(EXIT_FAILURE);
  1921. X    }
  1922. X    (void)close(fd);
  1923. X
  1924. X    exit(EXIT_SUCCESS);
  1925. X}
  1926. X
  1927. X
  1928. Xvoid
  1929. XRenderSpot(unsigned char *Image, int Xres, int Yres, int psize, int u, int v)
  1930. X{
  1931. X    register int            i, j, k;
  1932. X    register float          x, y, dx, dy, d, sigma;
  1933. X    register int            pixel_value;
  1934. X    register unsigned char *image;
  1935. X
  1936. X    image = &Image[(v*Xres + u)*psize];
  1937. X
  1938. X    sigma = 2.0;
  1939. X    dx = 8.0*sigma / (float)X_HALF_WIDTH;
  1940. X    dy = 8.0*sigma / (float)Y_HALF_WIDTH;
  1941. X
  1942. X    for (i = -X_HALF_WIDTH; i <= X_HALF_WIDTH; i++)
  1943. X    if (0 <= v + i  &&  v + i < Xres)
  1944. X    {
  1945. X        x = i*dx;
  1946. X
  1947. X        for (j = -Y_HALF_WIDTH; j <= Y_HALF_WIDTH; j++)
  1948. X        if (0 <= u + j  &&  u + j < Yres)
  1949. X        {
  1950. X            y = j*dy;
  1951. X            d = sqrt(x*x + y*y);
  1952. X            pixel_value = 650.0 * normal(d, sigma, 0.0);
  1953. X            if (pixel_value > 255)
  1954. X            pixel_value = 255;
  1955. X
  1956. X            if (image[(j*Xres + i)*psize] < pixel_value)
  1957. X            for (k = 0; k < psize; k++)
  1958. X                image[(j*Xres + i)*psize + k] = pixel_value;
  1959. X        }
  1960. X    }
  1961. X}
  1962. X
  1963. X
  1964. Xdouble
  1965. Xnormal(double x, double s, double m)
  1966. X{
  1967. X    return(1.0/sqrt(M_PI*2*(s)) * exp(-(((x)-(m))*((x)-(m)))/(2*(s)*(s))));
  1968. X}
  1969. END_OF_FILE
  1970.   if test 6438 -ne `wc -c <'lic.1.3/test/SpotNoise.c'`; then
  1971.     echo shar: \"'lic.1.3/test/SpotNoise.c'\" unpacked with wrong size!
  1972.   fi
  1973.   # end of 'lic.1.3/test/SpotNoise.c'
  1974. fi
  1975. echo shar: End of archive 7 \(of 9\).
  1976. cp /dev/null ark7isdone
  1977. MISSING=""
  1978. for I in 1 2 3 4 5 6 7 8 9 ; do
  1979.     if test ! -f ark${I}isdone ; then
  1980.     MISSING="${MISSING} ${I}"
  1981.     fi
  1982. done
  1983. if test "${MISSING}" = "" ; then
  1984.     echo You have unpacked all 9 archives.
  1985.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1986. else
  1987.     echo You still must unpack the following archives:
  1988.     echo "        " ${MISSING}
  1989. fi
  1990. exit 0
  1991. exit 0 # Just in case...
  1992.